bfa_intr_priv.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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_INTR_PRIV_H__
  18. #define __BFA_INTR_PRIV_H__
  19. /**
  20. * Message handler
  21. */
  22. typedef void (*bfa_isr_func_t) (struct bfa_s *bfa, struct bfi_msg_s *m);
  23. void bfa_isr_unhandled(struct bfa_s *bfa, struct bfi_msg_s *m);
  24. void bfa_isr_bind(enum bfi_mclass mc, bfa_isr_func_t isr_func);
  25. #define bfa_reqq_pi(__bfa, __reqq) ((__bfa)->iocfc.req_cq_pi[__reqq])
  26. #define bfa_reqq_ci(__bfa, __reqq) \
  27. (*(u32 *)((__bfa)->iocfc.req_cq_shadow_ci[__reqq].kva))
  28. #define bfa_reqq_full(__bfa, __reqq) \
  29. (((bfa_reqq_pi(__bfa, __reqq) + 1) & \
  30. ((__bfa)->iocfc.cfg.drvcfg.num_reqq_elems - 1)) == \
  31. bfa_reqq_ci(__bfa, __reqq))
  32. #define bfa_reqq_next(__bfa, __reqq) \
  33. (bfa_reqq_full(__bfa, __reqq) ? NULL : \
  34. ((void *)((struct bfi_msg_s *)((__bfa)->iocfc.req_cq_ba[__reqq].kva) \
  35. + bfa_reqq_pi((__bfa), (__reqq)))))
  36. #define bfa_reqq_produce(__bfa, __reqq) do { \
  37. (__bfa)->iocfc.req_cq_pi[__reqq]++; \
  38. (__bfa)->iocfc.req_cq_pi[__reqq] &= \
  39. ((__bfa)->iocfc.cfg.drvcfg.num_reqq_elems - 1); \
  40. bfa_reg_write((__bfa)->iocfc.bfa_regs.cpe_q_pi[__reqq], \
  41. (__bfa)->iocfc.req_cq_pi[__reqq]); \
  42. bfa_os_mmiowb(); \
  43. } while (0)
  44. #define bfa_rspq_pi(__bfa, __rspq) \
  45. (*(u32 *)((__bfa)->iocfc.rsp_cq_shadow_pi[__rspq].kva))
  46. #define bfa_rspq_ci(__bfa, __rspq) ((__bfa)->iocfc.rsp_cq_ci[__rspq])
  47. #define bfa_rspq_elem(__bfa, __rspq, __ci) \
  48. (&((struct bfi_msg_s *)((__bfa)->iocfc.rsp_cq_ba[__rspq].kva))[__ci])
  49. #define CQ_INCR(__index, __size) do { \
  50. (__index)++; \
  51. (__index) &= ((__size) - 1); \
  52. } while (0)
  53. /**
  54. * Queue element to wait for room in request queue. FIFO order is
  55. * maintained when fullfilling requests.
  56. */
  57. struct bfa_reqq_wait_s {
  58. struct list_head qe;
  59. void (*qresume) (void *cbarg);
  60. void *cbarg;
  61. };
  62. /**
  63. * Circular queue usage assignments
  64. */
  65. enum {
  66. BFA_REQQ_IOC = 0, /* all low-priority IOC msgs */
  67. BFA_REQQ_FCXP = 0, /* all FCXP messages */
  68. BFA_REQQ_LPS = 0, /* all lport service msgs */
  69. BFA_REQQ_PORT = 0, /* all port messages */
  70. BFA_REQQ_FLASH = 0, /* for flash module */
  71. BFA_REQQ_DIAG = 0, /* for diag module */
  72. BFA_REQQ_RPORT = 0, /* all port messages */
  73. BFA_REQQ_SBOOT = 0, /* all san boot messages */
  74. BFA_REQQ_QOS_LO = 1, /* all low priority IO */
  75. BFA_REQQ_QOS_MD = 2, /* all medium priority IO */
  76. BFA_REQQ_QOS_HI = 3, /* all high priority IO */
  77. };
  78. static inline void
  79. bfa_reqq_winit(struct bfa_reqq_wait_s *wqe, void (*qresume) (void *cbarg),
  80. void *cbarg)
  81. {
  82. wqe->qresume = qresume;
  83. wqe->cbarg = cbarg;
  84. }
  85. #define bfa_reqq(__bfa, __reqq) (&(__bfa)->reqq_waitq[__reqq])
  86. /**
  87. * static inline void
  88. * bfa_reqq_wait(struct bfa_s *bfa, int reqq, struct bfa_reqq_wait_s *wqe)
  89. */
  90. #define bfa_reqq_wait(__bfa, __reqq, __wqe) do { \
  91. \
  92. struct list_head *waitq = bfa_reqq(__bfa, __reqq); \
  93. \
  94. bfa_assert(((__reqq) < BFI_IOC_MAX_CQS)); \
  95. bfa_assert((__wqe)->qresume && (__wqe)->cbarg); \
  96. \
  97. list_add_tail(&(__wqe)->qe, waitq); \
  98. } while (0)
  99. #define bfa_reqq_wcancel(__wqe) list_del(&(__wqe)->qe)
  100. #endif /* __BFA_INTR_PRIV_H__ */