rxe_task.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. #ifndef RXE_TASK_H
  7. #define RXE_TASK_H
  8. enum {
  9. TASK_STATE_START = 0,
  10. TASK_STATE_BUSY = 1,
  11. TASK_STATE_ARMED = 2,
  12. };
  13. /*
  14. * data structure to describe a 'task' which is a short
  15. * function that returns 0 as long as it needs to be
  16. * called again.
  17. */
  18. struct rxe_task {
  19. struct tasklet_struct tasklet;
  20. int state;
  21. spinlock_t state_lock; /* spinlock for task state */
  22. void *arg;
  23. int (*func)(void *arg);
  24. int ret;
  25. bool destroyed;
  26. };
  27. /*
  28. * init rxe_task structure
  29. * arg => parameter to pass to fcn
  30. * func => function to call until it returns != 0
  31. */
  32. int rxe_init_task(struct rxe_task *task, void *arg, int (*func)(void *));
  33. /* cleanup task */
  34. void rxe_cleanup_task(struct rxe_task *task);
  35. /*
  36. * raw call to func in loop without any checking
  37. * can call when tasklets are disabled
  38. */
  39. int __rxe_do_task(struct rxe_task *task);
  40. /*
  41. * common function called by any of the main tasklets
  42. * If there is any chance that there is additional
  43. * work to do someone must reschedule the task before
  44. * leaving
  45. */
  46. void rxe_do_task(struct tasklet_struct *t);
  47. void rxe_run_task(struct rxe_task *task);
  48. void rxe_sched_task(struct rxe_task *task);
  49. /* keep a task from scheduling */
  50. void rxe_disable_task(struct rxe_task *task);
  51. /* allow task to run */
  52. void rxe_enable_task(struct rxe_task *task);
  53. #endif /* RXE_TASK_H */