bfa_iocfc.h 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  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_IOCFC_H__
  18. #define __BFA_IOCFC_H__
  19. #include <bfa_ioc.h>
  20. #include <bfa.h>
  21. #include <bfi/bfi_iocfc.h>
  22. #include <bfi/bfi_pbc.h>
  23. #include <bfa_callback_priv.h>
  24. #define BFA_REQQ_NELEMS_MIN (4)
  25. #define BFA_RSPQ_NELEMS_MIN (4)
  26. struct bfa_iocfc_regs_s {
  27. bfa_os_addr_t intr_status;
  28. bfa_os_addr_t intr_mask;
  29. bfa_os_addr_t cpe_q_pi[BFI_IOC_MAX_CQS];
  30. bfa_os_addr_t cpe_q_ci[BFI_IOC_MAX_CQS];
  31. bfa_os_addr_t cpe_q_depth[BFI_IOC_MAX_CQS];
  32. bfa_os_addr_t cpe_q_ctrl[BFI_IOC_MAX_CQS];
  33. bfa_os_addr_t rme_q_ci[BFI_IOC_MAX_CQS];
  34. bfa_os_addr_t rme_q_pi[BFI_IOC_MAX_CQS];
  35. bfa_os_addr_t rme_q_depth[BFI_IOC_MAX_CQS];
  36. bfa_os_addr_t rme_q_ctrl[BFI_IOC_MAX_CQS];
  37. };
  38. /**
  39. * MSIX vector handlers
  40. */
  41. #define BFA_MSIX_MAX_VECTORS 22
  42. typedef void (*bfa_msix_handler_t)(struct bfa_s *bfa, int vec);
  43. struct bfa_msix_s {
  44. int nvecs;
  45. bfa_msix_handler_t handler[BFA_MSIX_MAX_VECTORS];
  46. };
  47. /**
  48. * Chip specific interfaces
  49. */
  50. struct bfa_hwif_s {
  51. void (*hw_reginit)(struct bfa_s *bfa);
  52. void (*hw_reqq_ack)(struct bfa_s *bfa, int reqq);
  53. void (*hw_rspq_ack)(struct bfa_s *bfa, int rspq);
  54. void (*hw_msix_init)(struct bfa_s *bfa, int nvecs);
  55. void (*hw_msix_install)(struct bfa_s *bfa);
  56. void (*hw_msix_uninstall)(struct bfa_s *bfa);
  57. void (*hw_isr_mode_set)(struct bfa_s *bfa, bfa_boolean_t msix);
  58. void (*hw_msix_getvecs)(struct bfa_s *bfa, u32 *vecmap,
  59. u32 *nvecs, u32 *maxvec);
  60. void (*hw_msix_get_rme_range) (struct bfa_s *bfa, u32 *start,
  61. u32 *end);
  62. };
  63. typedef void (*bfa_cb_iocfc_t) (void *cbarg, enum bfa_status status);
  64. struct bfa_iocfc_s {
  65. struct bfa_s *bfa;
  66. struct bfa_iocfc_cfg_s cfg;
  67. int action;
  68. u32 req_cq_pi[BFI_IOC_MAX_CQS];
  69. u32 rsp_cq_ci[BFI_IOC_MAX_CQS];
  70. struct bfa_cb_qe_s init_hcb_qe;
  71. struct bfa_cb_qe_s stop_hcb_qe;
  72. struct bfa_cb_qe_s dis_hcb_qe;
  73. struct bfa_cb_qe_s stats_hcb_qe;
  74. bfa_boolean_t cfgdone;
  75. struct bfa_dma_s cfg_info;
  76. struct bfi_iocfc_cfg_s *cfginfo;
  77. struct bfa_dma_s cfgrsp_dma;
  78. struct bfi_iocfc_cfgrsp_s *cfgrsp;
  79. struct bfi_iocfc_cfg_reply_s *cfg_reply;
  80. u8 *stats_kva;
  81. u64 stats_pa;
  82. struct bfa_fw_stats_s *fw_stats;
  83. struct bfa_timer_s stats_timer; /* timer */
  84. struct bfa_iocfc_stats_s *stats_ret; /* driver stats location */
  85. bfa_status_t stats_status; /* stats/statsclr status */
  86. bfa_boolean_t stats_busy; /* outstanding stats */
  87. bfa_cb_ioc_t stats_cbfn; /* driver callback function */
  88. void *stats_cbarg; /* user callback arg */
  89. struct bfa_dma_s req_cq_ba[BFI_IOC_MAX_CQS];
  90. struct bfa_dma_s req_cq_shadow_ci[BFI_IOC_MAX_CQS];
  91. struct bfa_dma_s rsp_cq_ba[BFI_IOC_MAX_CQS];
  92. struct bfa_dma_s rsp_cq_shadow_pi[BFI_IOC_MAX_CQS];
  93. struct bfa_iocfc_regs_s bfa_regs; /* BFA device registers */
  94. struct bfa_hwif_s hwif;
  95. bfa_cb_iocfc_t updateq_cbfn; /* bios callback function */
  96. void *updateq_cbarg; /* bios callback arg */
  97. u32 intr_mask;
  98. };
  99. #define bfa_lpuid(__bfa) bfa_ioc_portid(&(__bfa)->ioc)
  100. #define bfa_msix_init(__bfa, __nvecs) \
  101. ((__bfa)->iocfc.hwif.hw_msix_init(__bfa, __nvecs))
  102. #define bfa_msix_install(__bfa) \
  103. ((__bfa)->iocfc.hwif.hw_msix_install(__bfa))
  104. #define bfa_msix_uninstall(__bfa) \
  105. ((__bfa)->iocfc.hwif.hw_msix_uninstall(__bfa))
  106. #define bfa_isr_mode_set(__bfa, __msix) \
  107. ((__bfa)->iocfc.hwif.hw_isr_mode_set(__bfa, __msix))
  108. #define bfa_msix_getvecs(__bfa, __vecmap, __nvecs, __maxvec) \
  109. ((__bfa)->iocfc.hwif.hw_msix_getvecs(__bfa, __vecmap, \
  110. __nvecs, __maxvec))
  111. #define bfa_msix_get_rme_range(__bfa, __start, __end) \
  112. ((__bfa)->iocfc.hwif.hw_msix_get_rme_range(__bfa, __start, __end))
  113. /*
  114. * FC specific IOC functions.
  115. */
  116. void bfa_iocfc_meminfo(struct bfa_iocfc_cfg_s *cfg, u32 *km_len,
  117. u32 *dm_len);
  118. void bfa_iocfc_attach(struct bfa_s *bfa, void *bfad,
  119. struct bfa_iocfc_cfg_s *cfg, struct bfa_meminfo_s *meminfo,
  120. struct bfa_pcidev_s *pcidev);
  121. void bfa_iocfc_detach(struct bfa_s *bfa);
  122. void bfa_iocfc_init(struct bfa_s *bfa);
  123. void bfa_iocfc_start(struct bfa_s *bfa);
  124. void bfa_iocfc_stop(struct bfa_s *bfa);
  125. void bfa_iocfc_isr(void *bfa, struct bfi_mbmsg_s *msg);
  126. void bfa_iocfc_set_snsbase(struct bfa_s *bfa, u64 snsbase_pa);
  127. bfa_boolean_t bfa_iocfc_is_operational(struct bfa_s *bfa);
  128. void bfa_iocfc_reset_queues(struct bfa_s *bfa);
  129. void bfa_iocfc_updateq(struct bfa_s *bfa, u32 reqq_ba, u32 rspq_ba,
  130. u32 reqq_sci, u32 rspq_spi,
  131. bfa_cb_iocfc_t cbfn, void *cbarg);
  132. void bfa_msix_all(struct bfa_s *bfa, int vec);
  133. void bfa_msix_reqq(struct bfa_s *bfa, int vec);
  134. void bfa_msix_rspq(struct bfa_s *bfa, int vec);
  135. void bfa_msix_lpu_err(struct bfa_s *bfa, int vec);
  136. void bfa_hwcb_reginit(struct bfa_s *bfa);
  137. void bfa_hwcb_reqq_ack(struct bfa_s *bfa, int rspq);
  138. void bfa_hwcb_rspq_ack(struct bfa_s *bfa, int rspq);
  139. void bfa_hwcb_msix_init(struct bfa_s *bfa, int nvecs);
  140. void bfa_hwcb_msix_install(struct bfa_s *bfa);
  141. void bfa_hwcb_msix_uninstall(struct bfa_s *bfa);
  142. void bfa_hwcb_isr_mode_set(struct bfa_s *bfa, bfa_boolean_t msix);
  143. void bfa_hwcb_msix_getvecs(struct bfa_s *bfa, u32 *vecmap,
  144. u32 *nvecs, u32 *maxvec);
  145. void bfa_hwcb_msix_get_rme_range(struct bfa_s *bfa, u32 *start, u32 *end);
  146. void bfa_hwct_reginit(struct bfa_s *bfa);
  147. void bfa_hwct_reqq_ack(struct bfa_s *bfa, int rspq);
  148. void bfa_hwct_rspq_ack(struct bfa_s *bfa, int rspq);
  149. void bfa_hwct_msix_init(struct bfa_s *bfa, int nvecs);
  150. void bfa_hwct_msix_install(struct bfa_s *bfa);
  151. void bfa_hwct_msix_uninstall(struct bfa_s *bfa);
  152. void bfa_hwct_isr_mode_set(struct bfa_s *bfa, bfa_boolean_t msix);
  153. void bfa_hwct_msix_getvecs(struct bfa_s *bfa, u32 *vecmap,
  154. u32 *nvecs, u32 *maxvec);
  155. void bfa_hwct_msix_get_rme_range(struct bfa_s *bfa, u32 *start, u32 *end);
  156. void bfa_com_meminfo(bfa_boolean_t mincfg, u32 *dm_len);
  157. void bfa_com_attach(struct bfa_s *bfa, struct bfa_meminfo_s *mi,
  158. bfa_boolean_t mincfg);
  159. void bfa_iocfc_get_bootwwns(struct bfa_s *bfa, u8 *nwwns, wwn_t *wwns);
  160. void bfa_iocfc_get_pbc_boot_cfg(struct bfa_s *bfa,
  161. struct bfa_boot_pbc_s *pbcfg);
  162. int bfa_iocfc_get_pbc_vports(struct bfa_s *bfa,
  163. struct bfi_pbc_vport_s *pbc_vport);
  164. #endif /* __BFA_IOCFC_H__ */