Mention branches and keyring.
[releases.git] / sw / rxe / rxe_task.h
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  */
6
7 #ifndef RXE_TASK_H
8 #define RXE_TASK_H
9
10 enum {
11         TASK_STATE_IDLE         = 0,
12         TASK_STATE_BUSY         = 1,
13         TASK_STATE_ARMED        = 2,
14         TASK_STATE_DRAINING     = 3,
15         TASK_STATE_DRAINED      = 4,
16         TASK_STATE_INVALID      = 5,
17 };
18
19 /*
20  * data structure to describe a 'task' which is a short
21  * function that returns 0 as long as it needs to be
22  * called again.
23  */
24 struct rxe_task {
25         struct work_struct      work;
26         int                     state;
27         spinlock_t              lock;
28         struct rxe_qp           *qp;
29         int                     (*func)(struct rxe_qp *qp);
30         int                     ret;
31         long                    num_sched;
32         long                    num_done;
33 };
34
35 int rxe_alloc_wq(void);
36
37 void rxe_destroy_wq(void);
38
39 /*
40  * init rxe_task structure
41  *      qp  => parameter to pass to func
42  *      func => function to call until it returns != 0
43  */
44 int rxe_init_task(struct rxe_task *task, struct rxe_qp *qp,
45                   int (*func)(struct rxe_qp *));
46
47 /* cleanup task */
48 void rxe_cleanup_task(struct rxe_task *task);
49
50 void rxe_run_task(struct rxe_task *task);
51
52 void rxe_sched_task(struct rxe_task *task);
53
54 /* keep a task from scheduling */
55 void rxe_disable_task(struct rxe_task *task);
56
57 /* allow task to run */
58 void rxe_enable_task(struct rxe_task *task);
59
60 #endif /* RXE_TASK_H */