WIP FPC-III support
[linux/fpc-iii.git] / drivers / infiniband / sw / rxe / rxe_task.h
blob11d183fd333863d74a888dcfed916e14067b3150
1 /* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */
2 /*
3 * Copyright (c) 2016 Mellanox Technologies Ltd. All rights reserved.
4 * Copyright (c) 2015 System Fabric Works, Inc. All rights reserved.
5 */
7 #ifndef RXE_TASK_H
8 #define RXE_TASK_H
10 enum {
11 TASK_STATE_START = 0,
12 TASK_STATE_BUSY = 1,
13 TASK_STATE_ARMED = 2,
17 * data structure to describe a 'task' which is a short
18 * function that returns 0 as long as it needs to be
19 * called again.
21 struct rxe_task {
22 void *obj;
23 struct tasklet_struct tasklet;
24 int state;
25 spinlock_t state_lock; /* spinlock for task state */
26 void *arg;
27 int (*func)(void *arg);
28 int ret;
29 char name[16];
30 bool destroyed;
34 * init rxe_task structure
35 * arg => parameter to pass to fcn
36 * func => function to call until it returns != 0
38 int rxe_init_task(void *obj, struct rxe_task *task,
39 void *arg, int (*func)(void *), char *name);
41 /* cleanup task */
42 void rxe_cleanup_task(struct rxe_task *task);
45 * raw call to func in loop without any checking
46 * can call when tasklets are disabled
48 int __rxe_do_task(struct rxe_task *task);
51 * common function called by any of the main tasklets
52 * If there is any chance that there is additional
53 * work to do someone must reschedule the task before
54 * leaving
56 void rxe_do_task(struct tasklet_struct *t);
58 /* run a task, else schedule it to run as a tasklet, The decision
59 * to run or schedule tasklet is based on the parameter sched.
61 void rxe_run_task(struct rxe_task *task, int sched);
63 /* keep a task from scheduling */
64 void rxe_disable_task(struct rxe_task *task);
66 /* allow task to run */
67 void rxe_enable_task(struct rxe_task *task);
69 #endif /* RXE_TASK_H */