From: rpearson-klaOcWyJdxkshyMvu7JE4pqQE7yCjDx5@public.gmane.org
To: linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: rpearson-klaOcWyJdxkshyMvu7JE4pqQE7yCjDx5@public.gmane.org
Subject: [patch v2 17/37] add rxe_task.c
Date: Sun, 24 Jul 2011 14:43:17 -0500 [thread overview]
Message-ID: <20110724201228.964102039@systemfabricworks.com> (raw)
In-Reply-To: 20110724194300.421253331@systemfabricworks.com
[-- Attachment #1: add-rxe_task.c --]
[-- Type: text/plain, Size: 5072 bytes --]
Tasklet handling details.
Signed-off-by: Bob Pearson <rpearson-klaOcWyJdxkshyMvu7JE4pqQE7yCjDx5@public.gmane.org>
---
drivers/infiniband/hw/rxe/rxe_task.c | 169 +++++++++++++++++++++++++++++++++++
1 file changed, 169 insertions(+)
Index: infiniband/drivers/infiniband/hw/rxe/rxe_task.c
===================================================================
--- /dev/null
+++ infiniband/drivers/infiniband/hw/rxe/rxe_task.c
@@ -0,0 +1,169 @@
+/*
+ * Copyright (c) 2009-2011 Mellanox Technologies Ltd. All rights reserved.
+ * Copyright (c) 2009-2011 System Fabric Works, Inc. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <linux/kernel.h>
+#include <linux/interrupt.h>
+#include <linux/hardirq.h>
+
+#include "rxe_task.h"
+
+int __rxe_do_task(struct rxe_task *task)
+
+{
+ int ret;
+
+ while ((ret = task->func(task->arg)) == 0)
+ ;
+
+ task->ret = ret;
+
+ return ret;
+}
+
+/*
+ * this locking is due to a potential race where
+ * a second caller finds the task already running
+ * but looks just after the last call to func
+ */
+void rxe_do_task(unsigned long data)
+{
+ int cont;
+ int ret;
+ unsigned long flags;
+ struct rxe_task *task = (struct rxe_task *)data;
+
+ spin_lock_irqsave(&task->state_lock, flags);
+ switch (task->state) {
+ case TASK_STATE_START:
+ task->state = TASK_STATE_BUSY;
+ spin_unlock_irqrestore(&task->state_lock, flags);
+ break;
+
+ case TASK_STATE_BUSY:
+ task->state = TASK_STATE_ARMED;
+ /* fall through to */
+ case TASK_STATE_ARMED:
+ spin_unlock_irqrestore(&task->state_lock, flags);
+ return;
+
+ default:
+ spin_unlock_irqrestore(&task->state_lock, flags);
+ pr_warn("bad state = %d in rxe_do_task\n", task->state);
+ return;
+ }
+
+ do {
+ cont = 0;
+ ret = task->func(task->arg);
+
+ spin_lock_irqsave(&task->state_lock, flags);
+ switch (task->state) {
+ case TASK_STATE_BUSY:
+ if (ret)
+ task->state = TASK_STATE_START;
+ else
+ cont = 1;
+ break;
+
+ /* soneone tried to run the task since the
+ last time we called func, so we will call
+ one more time regardless of the return value */
+ case TASK_STATE_ARMED:
+ task->state = TASK_STATE_BUSY;
+ cont = 1;
+ break;
+
+ default:
+ pr_warn("bad state = %d in rxe_do_task\n",
+ task->state);
+ }
+ spin_unlock_irqrestore(&task->state_lock, flags);
+ } while (cont);
+
+ task->ret = ret;
+}
+
+int rxe_init_task(void *obj, struct rxe_task *task, int *fast,
+ void *arg, int (*func)(void *), char *name)
+{
+ task->obj = obj;
+ task->fast = fast;
+ task->arg = arg;
+ task->func = func;
+ snprintf(task->name, sizeof(task->name), "%s", name);
+
+ tasklet_init(&task->tasklet, rxe_do_task, (unsigned long)task);
+
+ task->state = TASK_STATE_START;
+ spin_lock_init(&task->state_lock);
+
+ return 0;
+}
+
+void rxe_cleanup_task(struct rxe_task *task)
+{
+ tasklet_kill(&task->tasklet);
+}
+
+/*
+ * depending on value of fast allow bypassing
+ * tasklet call or not
+ * 0 => never
+ * 1 => only if not in interrupt level
+ * >1 => always
+ */
+static inline int rxe_fast_path_ok(int fast)
+{
+ if (fast == 0 || (fast == 1 && (in_irq() || irqs_disabled())))
+ return 0;
+ else
+ return 1;
+}
+
+void rxe_run_task(struct rxe_task *task, int sched)
+{
+ if (sched || !rxe_fast_path_ok(*task->fast))
+ tasklet_schedule(&task->tasklet);
+ else
+ rxe_do_task((unsigned long)task);
+}
+
+void rxe_disable_task(struct rxe_task *task)
+{
+ tasklet_disable(&task->tasklet);
+}
+
+void rxe_enable_task(struct rxe_task *task)
+{
+ tasklet_enable(&task->tasklet);
+}
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2011-07-24 19:43 UTC|newest]
Thread overview: 85+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-07-24 19:43 [patch v2 00/37] add rxe (soft RoCE) rpearson-klaOcWyJdxkshyMvu7JE4pqQE7yCjDx5
2011-07-24 19:43 ` [patch v2 01/37] add slice by 8 algorithm to crc32.c rpearson-klaOcWyJdxkshyMvu7JE4pqQE7yCjDx5
[not found] ` <20110724201228.154338911-klaOcWyJdxkshyMvu7JE4pqQE7yCjDx5@public.gmane.org>
2011-08-05 18:39 ` Bart Van Assche
[not found] ` <CAO+b5-rFs79znwVcG42Px2i351vhiz9hFyCJV5qg77of8Y6P5Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-08-05 19:24 ` Bob Pearson
2011-07-24 19:43 ` [patch v2 02/37] add opcodes to ib_pack.h rpearson-klaOcWyJdxkshyMvu7JE4pqQE7yCjDx5
[not found] ` <20110724201228.204265835-klaOcWyJdxkshyMvu7JE4pqQE7yCjDx5@public.gmane.org>
2011-08-15 9:13 ` Bart Van Assche
[not found] ` <CAO+b5-pb3p0n5MZYNSJicAdUfZ4PtMNG5vdzDOiZNQwLnB3Wcw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-08-15 16:15 ` Bob Pearson
2011-08-20 14:47 ` Bart Van Assche
[not found] ` <CAO+b5-qV9uxs=V_uHbVZ_3sm1LqkQUB0em=K=nrRxUvFQYWo5A-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-08-22 18:08 ` Bart Van Assche
[not found] ` <CAO+b5-pKPuhsrQV6igqo78y_1+gZ=09GxHoABOVnLxX3myFYZA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-09-01 3:15 ` Bob Pearson
2011-09-01 17:29 ` Jason Gunthorpe
2011-09-01 17:51 ` Bart Van Assche
2011-09-01 3:38 ` Bob Pearson
2011-07-24 19:43 ` [patch v2 03/37] add rxe_hdr.h rpearson-klaOcWyJdxkshyMvu7JE4pqQE7yCjDx5
2011-07-24 19:43 ` [patch v2 04/37] add rxe_opcode.h rpearson-klaOcWyJdxkshyMvu7JE4pqQE7yCjDx5
2011-07-24 19:43 ` [patch v2 05/37] add rxe_opcode.c rpearson-klaOcWyJdxkshyMvu7JE4pqQE7yCjDx5
2011-07-24 19:43 ` [patch v2 06/37] add rxe_param.h rpearson-klaOcWyJdxkshyMvu7JE4pqQE7yCjDx5
[not found] ` <20110724201228.415281967-klaOcWyJdxkshyMvu7JE4pqQE7yCjDx5@public.gmane.org>
2011-08-20 15:27 ` Bart Van Assche
[not found] ` <CAO+b5-q5ohgttDAc45MSKrSUdUVOfR3xHMSY99JtfX_MetSw8Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-09-01 3:50 ` Bob Pearson
2011-07-24 19:43 ` [patch v2 07/37] add rxe.h rpearson-klaOcWyJdxkshyMvu7JE4pqQE7yCjDx5
2011-07-24 19:43 ` [patch v2 08/37] add rxe_loc.h rpearson-klaOcWyJdxkshyMvu7JE4pqQE7yCjDx5
2011-07-24 19:43 ` [patch v2 09/37] add rxe_mmap.c rpearson-klaOcWyJdxkshyMvu7JE4pqQE7yCjDx5
2011-07-24 19:43 ` [patch v2 10/37] add rxe_queue.h rpearson-klaOcWyJdxkshyMvu7JE4pqQE7yCjDx5
2011-07-24 19:43 ` [patch v2 11/37] add rxe_queue.c rpearson-klaOcWyJdxkshyMvu7JE4pqQE7yCjDx5
2011-07-24 19:43 ` [patch v2 12/37] add rxe_verbs.h rpearson-klaOcWyJdxkshyMvu7JE4pqQE7yCjDx5
[not found] ` <20110724201228.710989476-klaOcWyJdxkshyMvu7JE4pqQE7yCjDx5@public.gmane.org>
2011-08-15 12:32 ` Bart Van Assche
[not found] ` <CAO+b5-okTDAJ6iOTv_JKXeGttt0MFM+na-FRaNwJMFqHktKHJQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-09-01 4:32 ` Bob Pearson
2011-08-15 12:59 ` Bart Van Assche
[not found] ` <CAO+b5-qQBWeyFacCU3tx92jG2zw1=YZJRRX5SbQ57Ztx+zxuew-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-09-01 4:35 ` Bob Pearson
2011-07-24 19:43 ` [patch v2 13/37] add rxe_verbs.c rpearson-klaOcWyJdxkshyMvu7JE4pqQE7yCjDx5
[not found] ` <20110724201228.761358826-klaOcWyJdxkshyMvu7JE4pqQE7yCjDx5@public.gmane.org>
2011-08-15 13:24 ` Bart Van Assche
[not found] ` <CAO+b5-r3UtgnyfhyaodHQTj_xB5d2MQkZ8kRbrpZ1hF_0W1ONw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-09-01 5:20 ` Bob Pearson
2011-09-01 10:33 ` Bart Van Assche
2011-09-01 11:02 ` Bart Van Assche
2011-08-15 14:33 ` Bart Van Assche
[not found] ` <CAO+b5-pRQXn08aVOPxeQBzrYXAV+3zD+HZdCCmPTTwBCCzY=ag-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-08-15 14:45 ` Greg KH
[not found] ` <20110815144503.GA12014-l3A5Bk7waGM@public.gmane.org>
2011-08-15 14:58 ` Bart Van Assche
[not found] ` <CAO+b5-rsofKNdcjCjBdj1fH7i3DpbHhFajhk0QfNK4DE7nj_SQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-08-15 15:07 ` Greg KH
[not found] ` <20110815150726.GA12490-l3A5Bk7waGM@public.gmane.org>
2011-08-15 16:02 ` Bart Van Assche
[not found] ` <CAO+b5-ocwYv2_A8PfVUh1yp0CFNYasjTJNQ0F6bj-+wT8npavA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-08-15 16:13 ` Greg KH
2011-08-15 16:31 ` Bart Van Assche
2011-07-24 19:43 ` [patch v2 14/37] add rxe_pool.h rpearson-klaOcWyJdxkshyMvu7JE4pqQE7yCjDx5
2011-07-24 19:43 ` [patch v2 15/37] add rxe_pool.c rpearson-klaOcWyJdxkshyMvu7JE4pqQE7yCjDx5
2011-07-24 19:43 ` [patch v2 16/37] add rxe_task.h rpearson-klaOcWyJdxkshyMvu7JE4pqQE7yCjDx5
2011-07-24 19:43 ` rpearson-klaOcWyJdxkshyMvu7JE4pqQE7yCjDx5 [this message]
2011-07-24 19:43 ` [patch v2 18/37] add rxe_av.c rpearson-klaOcWyJdxkshyMvu7JE4pqQE7yCjDx5
2011-07-24 19:43 ` [patch v2 19/37] add rxe_srq.c rpearson-klaOcWyJdxkshyMvu7JE4pqQE7yCjDx5
2011-07-24 19:43 ` [patch v2 20/37] add rxe_cq.c rpearson-klaOcWyJdxkshyMvu7JE4pqQE7yCjDx5
[not found] ` <20110724201229.112267527-klaOcWyJdxkshyMvu7JE4pqQE7yCjDx5@public.gmane.org>
2011-08-20 15:53 ` Bart Van Assche
2011-07-24 19:43 ` [patch v2 21/37] add rxe_qp.c rpearson-klaOcWyJdxkshyMvu7JE4pqQE7yCjDx5
[not found] ` <20110724201229.163423781-klaOcWyJdxkshyMvu7JE4pqQE7yCjDx5@public.gmane.org>
2011-08-15 16:13 ` Bart Van Assche
[not found] ` <CAO+b5-opA-W4Lp69NzS=9MLEv1V7jWhHPo=bayKhaR-kPgTQTQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-08-15 16:58 ` Jason Gunthorpe
2011-07-24 19:43 ` [patch v2 22/37] add rxe_mr.c rpearson-klaOcWyJdxkshyMvu7JE4pqQE7yCjDx5
2011-07-24 19:43 ` [patch v2 23/37] add rxe_mcast.c rpearson-klaOcWyJdxkshyMvu7JE4pqQE7yCjDx5
[not found] ` <20110724201229.264963653-klaOcWyJdxkshyMvu7JE4pqQE7yCjDx5@public.gmane.org>
2011-08-20 16:13 ` Bart Van Assche
2011-07-24 19:43 ` [patch v2 24/37] add rxe_recv.c rpearson-klaOcWyJdxkshyMvu7JE4pqQE7yCjDx5
2011-07-24 19:43 ` [patch v2 25/37] add rxe_comp.c rpearson-klaOcWyJdxkshyMvu7JE4pqQE7yCjDx5
2011-07-24 19:43 ` [patch v2 26/37] add rxe_req.c rpearson-klaOcWyJdxkshyMvu7JE4pqQE7yCjDx5
[not found] ` <20110724201229.415319539-klaOcWyJdxkshyMvu7JE4pqQE7yCjDx5@public.gmane.org>
2011-08-10 18:44 ` Bart Van Assche
2011-07-24 19:43 ` [patch v2 27/37] add rxe_resp.c rpearson-klaOcWyJdxkshyMvu7JE4pqQE7yCjDx5
[not found] ` <20110724201229.464927217-klaOcWyJdxkshyMvu7JE4pqQE7yCjDx5@public.gmane.org>
2011-08-20 16:26 ` Bart Van Assche
2011-07-24 19:43 ` [patch v2 28/37] add rxe_arbiter.c rpearson-klaOcWyJdxkshyMvu7JE4pqQE7yCjDx5
[not found] ` <20110724201229.515453123-klaOcWyJdxkshyMvu7JE4pqQE7yCjDx5@public.gmane.org>
2011-08-10 18:46 ` Bart Van Assche
[not found] ` <CAO+b5-p=++ofCDj4ZB_PS9LiT5bcHsJiYDW8EL_2OrrzqjZmhg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-08-10 19:12 ` Bob Pearson
2011-07-24 19:43 ` [patch v2 29/37] add rxe_dma.c rpearson-klaOcWyJdxkshyMvu7JE4pqQE7yCjDx5
[not found] ` <20110724201229.565188525-klaOcWyJdxkshyMvu7JE4pqQE7yCjDx5@public.gmane.org>
2011-08-20 15:32 ` Bart Van Assche
2011-07-24 19:43 ` [patch v2 30/37] add rxe_icrc.c rpearson-klaOcWyJdxkshyMvu7JE4pqQE7yCjDx5
2011-07-24 19:43 ` [patch v2 31/37] add rxe.c rpearson-klaOcWyJdxkshyMvu7JE4pqQE7yCjDx5
[not found] ` <20110724201229.666252623-klaOcWyJdxkshyMvu7JE4pqQE7yCjDx5@public.gmane.org>
2011-08-20 15:12 ` Bart Van Assche
2011-07-24 19:43 ` [patch v2 32/37] add rxe_net.h rpearson-klaOcWyJdxkshyMvu7JE4pqQE7yCjDx5
[not found] ` <20110724201229.715886208-klaOcWyJdxkshyMvu7JE4pqQE7yCjDx5@public.gmane.org>
2011-08-07 8:51 ` Bart Van Assche
2011-07-24 19:43 ` [patch v2 33/37] add rxe_net.c rpearson-klaOcWyJdxkshyMvu7JE4pqQE7yCjDx5
[not found] ` <20110724201229.765038738-klaOcWyJdxkshyMvu7JE4pqQE7yCjDx5@public.gmane.org>
2011-08-05 18:47 ` Bart Van Assche
[not found] ` <CAO+b5-pk-X7aGgg12ND17OLcqcLU6qyiV+vf22anh9bYsXUUzw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-08-05 19:17 ` Bob Pearson
2011-08-06 8:02 ` Bart Van Assche
2011-07-24 19:43 ` [patch v2 34/37] add rxe_net_sysfs.c rpearson-klaOcWyJdxkshyMvu7JE4pqQE7yCjDx5
[not found] ` <20110724201229.815123934-klaOcWyJdxkshyMvu7JE4pqQE7yCjDx5@public.gmane.org>
2011-08-07 9:27 ` Bart Van Assche
2011-07-24 19:43 ` [patch v2 35/37] add rxe_sample.c rpearson-klaOcWyJdxkshyMvu7JE4pqQE7yCjDx5
[not found] ` <20110724201229.865806162-klaOcWyJdxkshyMvu7JE4pqQE7yCjDx5@public.gmane.org>
2011-08-07 8:08 ` Bart Van Assche
2011-07-24 19:43 ` [patch v2 36/37] add Makefile rpearson-klaOcWyJdxkshyMvu7JE4pqQE7yCjDx5
2011-07-24 19:43 ` [patch v2 37/37] add Kconfig rpearson-klaOcWyJdxkshyMvu7JE4pqQE7yCjDx5
[not found] ` <20110724201229.966262587-klaOcWyJdxkshyMvu7JE4pqQE7yCjDx5@public.gmane.org>
2011-08-05 18:44 ` Bart Van Assche
[not found] ` <CAO+b5-oFKiAhTkCntAo5_mMCtdg1vb1eM_mTi-8E-T_atHa_3w-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-08-05 19:19 ` Bob Pearson
2011-08-06 18:44 ` Bart Van Assche
[not found] ` <20110724194300.421253331-klaOcWyJdxkshyMvu7JE4pqQE7yCjDx5@public.gmane.org>
2012-09-05 10:36 ` [patch v2 00/37] add rxe (soft RoCE) Stefan (metze) Metzmacher
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20110724201228.964102039@systemfabricworks.com \
--to=rpearson-klaocwyjdxkshymvu7je4pqqe7ycjdx5@public.gmane.org \
--cc=linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).