bfa_fcpim_priv.h 7.5 KB

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