bfa_intr_priv.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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) \
  50. (__index)++; (__index) &= ((__size) - 1)
  51. /**
  52. * Queue element to wait for room in request queue. FIFO order is
  53. * maintained when fullfilling requests.
  54. */
  55. struct bfa_reqq_wait_s {
  56. struct list_head qe;
  57. void (*qresume) (void *cbarg);
  58. void *cbarg;
  59. };
  60. /**
  61. * Circular queue usage assignments
  62. */
  63. enum {
  64. BFA_REQQ_IOC = 0, /* all low-priority IOC msgs */
  65. BFA_REQQ_FCXP = 0, /* all FCXP messages */
  66. BFA_REQQ_LPS = 0, /* all lport service msgs */
  67. BFA_REQQ_PORT = 0, /* all port messages */
  68. BFA_REQQ_FLASH = 0, /* for flash module */
  69. BFA_REQQ_DIAG = 0, /* for diag module */
  70. BFA_REQQ_RPORT = 0, /* all port messages */
  71. BFA_REQQ_SBOOT = 0, /* all san boot messages */
  72. BFA_REQQ_QOS_LO = 1, /* all low priority IO */
  73. BFA_REQQ_QOS_MD = 2, /* all medium priority IO */
  74. BFA_REQQ_QOS_HI = 3, /* all high priority IO */
  75. };
  76. static inline void
  77. bfa_reqq_winit(struct bfa_reqq_wait_s *wqe, void (*qresume) (void *cbarg),
  78. void *cbarg)
  79. {
  80. wqe->qresume = qresume;
  81. wqe->cbarg = cbarg;
  82. }
  83. #define bfa_reqq(__bfa, __reqq) &(__bfa)->reqq_waitq[__reqq]
  84. /**
  85. * static inline void
  86. * bfa_reqq_wait(struct bfa_s *bfa, int reqq, struct bfa_reqq_wait_s *wqe)
  87. */
  88. #define bfa_reqq_wait(__bfa, __reqq, __wqe) do { \
  89. \
  90. struct list_head *waitq = bfa_reqq(__bfa, __reqq); \
  91. \
  92. bfa_assert(((__reqq) < BFI_IOC_MAX_CQS)); \
  93. bfa_assert((__wqe)->qresume && (__wqe)->cbarg); \
  94. \
  95. list_add_tail(&(__wqe)->qe, waitq); \
  96. } while (0)
  97. #define bfa_reqq_wcancel(__wqe) list_del(&(__wqe)->qe)
  98. #endif /* __BFA_INTR_PRIV_H__ */