bfa_fcpim_priv.h 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  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_FCPIM_PRIV_H__
  18. #define __BFA_FCPIM_PRIV_H__
  19. #include <bfa_fcpim.h>
  20. #include <defs/bfa_defs_fcpim.h>
  21. #include <cs/bfa_wc.h>
  22. #include "bfa_sgpg_priv.h"
  23. #define BFA_ITNIM_MIN 32
  24. #define BFA_ITNIM_MAX 1024
  25. #define BFA_IOIM_MIN 8
  26. #define BFA_IOIM_MAX 2000
  27. #define BFA_TSKIM_MIN 4
  28. #define BFA_TSKIM_MAX 512
  29. #define BFA_FCPIM_PATHTOV_DEF (30 * 1000) /* in millisecs */
  30. #define BFA_FCPIM_PATHTOV_MAX (90 * 1000) /* in millisecs */
  31. #define bfa_fcpim_stats(__fcpim, __stats) \
  32. ((__fcpim)->stats.__stats++)
  33. struct bfa_fcpim_mod_s {
  34. struct bfa_s *bfa;
  35. struct bfa_itnim_s *itnim_arr;
  36. struct bfa_ioim_s *ioim_arr;
  37. struct bfa_ioim_sp_s *ioim_sp_arr;
  38. struct bfa_tskim_s *tskim_arr;
  39. struct bfa_dma_s snsbase;
  40. int num_itnims;
  41. int num_ioim_reqs;
  42. int num_tskim_reqs;
  43. u32 path_tov;
  44. u16 q_depth;
  45. u8 reqq; /* Request queue to be used */
  46. u8 rsvd;
  47. struct list_head itnim_q; /* queue of active itnim */
  48. struct list_head ioim_free_q; /* free IO resources */
  49. struct list_head ioim_resfree_q; /* IOs waiting for f/w */
  50. struct list_head ioim_comp_q; /* IO global comp Q */
  51. struct list_head tskim_free_q;
  52. u32 ios_active; /* current active IOs */
  53. u32 delay_comp;
  54. struct bfa_fcpim_stats_s stats;
  55. bfa_boolean_t ioredirect;
  56. };
  57. struct bfa_ioim_s;
  58. struct bfa_tskim_s;
  59. /**
  60. * BFA IO (initiator mode)
  61. */
  62. struct bfa_ioim_s {
  63. struct list_head qe; /* queue elememt */
  64. bfa_sm_t sm; /* BFA ioim state machine */
  65. struct bfa_s *bfa; /* BFA module */
  66. struct bfa_fcpim_mod_s *fcpim; /* parent fcpim module */
  67. struct bfa_itnim_s *itnim; /* i-t-n nexus for this IO */
  68. struct bfad_ioim_s *dio; /* driver IO handle */
  69. u16 iotag; /* FWI IO tag */
  70. u16 abort_tag; /* unqiue abort request tag */
  71. u16 nsges; /* number of SG elements */
  72. u16 nsgpgs; /* number of SG pages */
  73. struct bfa_sgpg_s *sgpg; /* first SG page */
  74. struct list_head sgpg_q; /* allocated SG pages */
  75. struct bfa_cb_qe_s hcb_qe; /* bfa callback qelem */
  76. bfa_cb_cbfn_t io_cbfn; /* IO completion handler */
  77. struct bfa_ioim_sp_s *iosp; /* slow-path IO handling */
  78. u8 reqq; /* Request queue for I/O */
  79. };
  80. struct bfa_ioim_sp_s {
  81. struct bfi_msg_s comp_rspmsg; /* IO comp f/w response */
  82. u8 *snsinfo; /* sense info for this IO */
  83. struct bfa_sgpg_wqe_s sgpg_wqe; /* waitq elem for sgpg */
  84. struct bfa_reqq_wait_s reqq_wait; /* to wait for room in reqq */
  85. bfa_boolean_t abort_explicit; /* aborted by OS */
  86. struct bfa_tskim_s *tskim; /* Relevant TM cmd */
  87. };
  88. /**
  89. * BFA Task management command (initiator mode)
  90. */
  91. struct bfa_tskim_s {
  92. struct list_head qe;
  93. bfa_sm_t sm;
  94. struct bfa_s *bfa; /* BFA module */
  95. struct bfa_fcpim_mod_s *fcpim; /* parent fcpim module */
  96. struct bfa_itnim_s *itnim; /* i-t-n nexus for this IO */
  97. struct bfad_tskim_s *dtsk; /* driver task mgmt cmnd */
  98. bfa_boolean_t notify; /* notify itnim on TM comp */
  99. lun_t lun; /* lun if applicable */
  100. enum fcp_tm_cmnd tm_cmnd; /* task management command */
  101. u16 tsk_tag; /* FWI IO tag */
  102. u8 tsecs; /* timeout in seconds */
  103. struct bfa_reqq_wait_s reqq_wait; /* to wait for room in reqq */
  104. struct list_head io_q; /* queue of affected IOs */
  105. struct bfa_wc_s wc; /* waiting counter */
  106. struct bfa_cb_qe_s hcb_qe; /* bfa callback qelem */
  107. enum bfi_tskim_status tsk_status; /* TM status */
  108. };
  109. /**
  110. * BFA i-t-n (initiator mode)
  111. */
  112. struct bfa_itnim_s {
  113. struct list_head qe; /* queue element */
  114. bfa_sm_t sm; /* i-t-n im BFA state machine */
  115. struct bfa_s *bfa; /* bfa instance */
  116. struct bfa_rport_s *rport; /* bfa rport */
  117. void *ditn; /* driver i-t-n structure */
  118. struct bfi_mhdr_s mhdr; /* pre-built mhdr */
  119. u8 msg_no; /* itnim/rport firmware handle */
  120. u8 reqq; /* CQ for requests */
  121. struct bfa_cb_qe_s hcb_qe; /* bfa callback qelem */
  122. struct list_head pending_q; /* queue of pending IO requests*/
  123. struct list_head io_q; /* queue of active IO requests */
  124. struct list_head io_cleanup_q; /* IO being cleaned up */
  125. struct list_head tsk_q; /* queue of active TM commands */
  126. struct list_head delay_comp_q;/* queue of failed inflight cmds */
  127. bfa_boolean_t seq_rec; /* SQER supported */
  128. bfa_boolean_t is_online; /* itnim is ONLINE for IO */
  129. bfa_boolean_t iotov_active; /* IO TOV timer is active */
  130. struct bfa_wc_s wc; /* waiting counter */
  131. struct bfa_timer_s timer; /* pending IO TOV */
  132. struct bfa_reqq_wait_s reqq_wait; /* to wait for room in reqq */
  133. struct bfa_fcpim_mod_s *fcpim; /* fcpim module */
  134. struct bfa_itnim_hal_stats_s stats;
  135. struct bfa_itnim_latency_s io_latency;
  136. };
  137. #define bfa_itnim_is_online(_itnim) ((_itnim)->is_online)
  138. #define BFA_FCPIM_MOD(_hal) (&(_hal)->modules.fcpim_mod)
  139. #define BFA_IOIM_FROM_TAG(_fcpim, _iotag) \
  140. (&fcpim->ioim_arr[_iotag])
  141. #define BFA_TSKIM_FROM_TAG(_fcpim, _tmtag) \
  142. (&fcpim->tskim_arr[_tmtag & (fcpim->num_tskim_reqs - 1)])
  143. /*
  144. * function prototypes
  145. */
  146. void bfa_ioim_attach(struct bfa_fcpim_mod_s *fcpim,
  147. struct bfa_meminfo_s *minfo);
  148. void bfa_ioim_detach(struct bfa_fcpim_mod_s *fcpim);
  149. void bfa_ioim_isr(struct bfa_s *bfa, struct bfi_msg_s *msg);
  150. void bfa_ioim_good_comp_isr(struct bfa_s *bfa,
  151. struct bfi_msg_s *msg);
  152. void bfa_ioim_cleanup(struct bfa_ioim_s *ioim);
  153. void bfa_ioim_cleanup_tm(struct bfa_ioim_s *ioim,
  154. struct bfa_tskim_s *tskim);
  155. void bfa_ioim_iocdisable(struct bfa_ioim_s *ioim);
  156. void bfa_ioim_tov(struct bfa_ioim_s *ioim);
  157. void bfa_tskim_attach(struct bfa_fcpim_mod_s *fcpim,
  158. struct bfa_meminfo_s *minfo);
  159. void bfa_tskim_detach(struct bfa_fcpim_mod_s *fcpim);
  160. void bfa_tskim_isr(struct bfa_s *bfa, struct bfi_msg_s *msg);
  161. void bfa_tskim_iodone(struct bfa_tskim_s *tskim);
  162. void bfa_tskim_iocdisable(struct bfa_tskim_s *tskim);
  163. void bfa_tskim_cleanup(struct bfa_tskim_s *tskim);
  164. void bfa_itnim_meminfo(struct bfa_iocfc_cfg_s *cfg, u32 *km_len,
  165. u32 *dm_len);
  166. void bfa_itnim_attach(struct bfa_fcpim_mod_s *fcpim,
  167. struct bfa_meminfo_s *minfo);
  168. void bfa_itnim_detach(struct bfa_fcpim_mod_s *fcpim);
  169. void bfa_itnim_iocdisable(struct bfa_itnim_s *itnim);
  170. void bfa_itnim_isr(struct bfa_s *bfa, struct bfi_msg_s *msg);
  171. void bfa_itnim_iodone(struct bfa_itnim_s *itnim);
  172. void bfa_itnim_tskdone(struct bfa_itnim_s *itnim);
  173. bfa_boolean_t bfa_itnim_hold_io(struct bfa_itnim_s *itnim);
  174. #endif /* __BFA_FCPIM_PRIV_H__ */