bfa_callback_priv.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /*
  2. * Copyright (c) 2005-2009 Brocade Communications Systems, Inc.
  3. * All rights reserved
  4. * www.brocade.com
  5. *
  6. * Linux driver for Brocade Fibre Channel Host Bus Adapter.
  7. *
  8. * This program is free software; you can redistribute it and/or modify it
  9. * under the terms of the GNU General Public License (GPL) Version 2 as
  10. * published by the Free Software Foundation
  11. *
  12. * This program is distributed in the hope that it will be useful, but
  13. * WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * General Public License for more details.
  16. */
  17. #ifndef __BFA_CALLBACK_PRIV_H__
  18. #define __BFA_CALLBACK_PRIV_H__
  19. #include <cs/bfa_q.h>
  20. typedef void (*bfa_cb_cbfn_t) (void *cbarg, bfa_boolean_t complete);
  21. /**
  22. * Generic BFA callback element.
  23. */
  24. struct bfa_cb_qe_s {
  25. struct list_head qe;
  26. bfa_cb_cbfn_t cbfn;
  27. bfa_boolean_t once;
  28. u32 rsvd;
  29. void *cbarg;
  30. };
  31. #define bfa_cb_queue(__bfa, __hcb_qe, __cbfn, __cbarg) do { \
  32. (__hcb_qe)->cbfn = (__cbfn); \
  33. (__hcb_qe)->cbarg = (__cbarg); \
  34. list_add_tail(&(__hcb_qe)->qe, &(__bfa)->comp_q); \
  35. } while (0)
  36. #define bfa_cb_dequeue(__hcb_qe) list_del(&(__hcb_qe)->qe)
  37. #define bfa_cb_queue_once(__bfa, __hcb_qe, __cbfn, __cbarg) do { \
  38. (__hcb_qe)->cbfn = (__cbfn); \
  39. (__hcb_qe)->cbarg = (__cbarg); \
  40. if (!(__hcb_qe)->once) { \
  41. list_add_tail((__hcb_qe), &(__bfa)->comp_q); \
  42. (__hcb_qe)->once = BFA_TRUE; \
  43. } \
  44. } while (0)
  45. #define bfa_cb_queue_done(__hcb_qe) do { \
  46. (__hcb_qe)->once = BFA_FALSE; \
  47. } while (0)
  48. #endif /* __BFA_CALLBACK_PRIV_H__ */