Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2005-2010 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 | |
| 18 | #ifndef __BFA_FCPIM_H__ |
| 19 | #define __BFA_FCPIM_H__ |
| 20 | |
| 21 | #include "bfa.h" |
| 22 | #include "bfa_svc.h" |
| 23 | #include "bfi_ms.h" |
| 24 | #include "bfa_defs_svc.h" |
| 25 | #include "bfa_cs.h" |
| 26 | |
Krishna Gudipati | e2187d7 | 2011-06-13 15:53:58 -0700 | [diff] [blame] | 27 | /* FCP module related definitions */ |
Krishna Gudipati | 4507025 | 2011-06-24 20:24:29 -0700 | [diff] [blame] | 28 | #define BFA_IO_MAX BFI_IO_MAX |
| 29 | #define BFA_FWTIO_MAX 2000 |
Krishna Gudipati | e2187d7 | 2011-06-13 15:53:58 -0700 | [diff] [blame] | 30 | |
| 31 | struct bfa_fcp_mod_s; |
| 32 | struct bfa_iotag_s { |
| 33 | struct list_head qe; /* queue element */ |
| 34 | u16 tag; /* FW IO tag */ |
| 35 | }; |
| 36 | |
| 37 | struct bfa_itn_s { |
| 38 | bfa_isr_func_t isr; |
| 39 | }; |
| 40 | |
| 41 | void bfa_itn_create(struct bfa_s *bfa, struct bfa_rport_s *rport, |
| 42 | void (*isr)(struct bfa_s *bfa, struct bfi_msg_s *m)); |
| 43 | void bfa_itn_isr(struct bfa_s *bfa, struct bfi_msg_s *m); |
Krishna Gudipati | 4507025 | 2011-06-24 20:24:29 -0700 | [diff] [blame] | 44 | void bfa_iotag_attach(struct bfa_fcp_mod_s *fcp); |
Krishna Gudipati | 3fd4598 | 2011-06-24 20:24:08 -0700 | [diff] [blame] | 45 | void bfa_fcp_res_recfg(struct bfa_s *bfa, u16 num_ioim_fw); |
Krishna Gudipati | e2187d7 | 2011-06-13 15:53:58 -0700 | [diff] [blame] | 46 | |
| 47 | #define BFA_FCP_MOD(_hal) (&(_hal)->modules.fcp_mod) |
Krishna Gudipati | 4507025 | 2011-06-24 20:24:29 -0700 | [diff] [blame] | 48 | #define BFA_MEM_FCP_KVA(__bfa) (&(BFA_FCP_MOD(__bfa)->kva_seg)) |
Krishna Gudipati | e2187d7 | 2011-06-13 15:53:58 -0700 | [diff] [blame] | 49 | #define BFA_IOTAG_FROM_TAG(_fcp, _tag) \ |
| 50 | (&(_fcp)->iotag_arr[(_tag & BFA_IOIM_IOTAG_MASK)]) |
| 51 | #define BFA_ITN_FROM_TAG(_fcp, _tag) \ |
| 52 | ((_fcp)->itn_arr + ((_tag) & ((_fcp)->num_itns - 1))) |
| 53 | #define BFA_SNSINFO_FROM_TAG(_fcp, _tag) \ |
Krishna Gudipati | 4507025 | 2011-06-24 20:24:29 -0700 | [diff] [blame] | 54 | bfa_mem_get_dmabuf_kva(_fcp, _tag, BFI_IOIM_SNSLEN) |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 55 | |
| 56 | #define BFA_ITNIM_MIN 32 |
| 57 | #define BFA_ITNIM_MAX 1024 |
| 58 | |
| 59 | #define BFA_IOIM_MIN 8 |
| 60 | #define BFA_IOIM_MAX 2000 |
| 61 | |
| 62 | #define BFA_TSKIM_MIN 4 |
| 63 | #define BFA_TSKIM_MAX 512 |
| 64 | #define BFA_FCPIM_PATHTOV_DEF (30 * 1000) /* in millisecs */ |
| 65 | #define BFA_FCPIM_PATHTOV_MAX (90 * 1000) /* in millisecs */ |
| 66 | |
| 67 | |
| 68 | #define bfa_itnim_ioprofile_update(__itnim, __index) \ |
| 69 | (__itnim->ioprofile.iocomps[__index]++) |
| 70 | |
| 71 | #define BFA_IOIM_RETRY_TAG_OFFSET 11 |
Krishna Gudipati | 15821f0 | 2010-12-13 16:23:27 -0800 | [diff] [blame] | 72 | #define BFA_IOIM_IOTAG_MASK 0x07ff /* 2K IOs */ |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 73 | #define BFA_IOIM_RETRY_MAX 7 |
| 74 | |
| 75 | /* Buckets are are 512 bytes to 2MB */ |
| 76 | static inline u32 |
| 77 | bfa_ioim_get_index(u32 n) { |
| 78 | int pos = 0; |
| 79 | if (n >= (1UL)<<22) |
| 80 | return BFA_IOBUCKET_MAX - 1; |
| 81 | n >>= 8; |
Krishna Gudipati | 42a8e6e | 2011-07-20 17:01:52 -0700 | [diff] [blame] | 82 | if (n >= (1UL)<<16) { |
| 83 | n >>= 16; |
| 84 | pos += 16; |
| 85 | } |
| 86 | if (n >= 1 << 8) { |
| 87 | n >>= 8; |
| 88 | pos += 8; |
| 89 | } |
| 90 | if (n >= 1 << 4) { |
| 91 | n >>= 4; |
| 92 | pos += 4; |
| 93 | } |
| 94 | if (n >= 1 << 2) { |
| 95 | n >>= 2; |
| 96 | pos += 2; |
| 97 | } |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 98 | if (n >= 1 << 1) |
| 99 | pos += 1; |
| 100 | |
| 101 | return (n == 0) ? (0) : pos; |
| 102 | } |
| 103 | |
| 104 | /* |
| 105 | * forward declarations |
| 106 | */ |
| 107 | struct bfa_ioim_s; |
| 108 | struct bfa_tskim_s; |
| 109 | struct bfad_ioim_s; |
| 110 | struct bfad_tskim_s; |
| 111 | |
| 112 | typedef void (*bfa_fcpim_profile_t) (struct bfa_ioim_s *ioim); |
Krishna Gudipati | 83763d5 | 2011-07-20 17:04:03 -0700 | [diff] [blame] | 113 | typedef bfa_boolean_t (*bfa_ioim_lm_proc_rsp_data_t) (struct bfa_ioim_s *ioim); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 114 | |
Krishna Gudipati | e2187d7 | 2011-06-13 15:53:58 -0700 | [diff] [blame] | 115 | struct bfa_fcpim_s { |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 116 | struct bfa_s *bfa; |
Krishna Gudipati | e2187d7 | 2011-06-13 15:53:58 -0700 | [diff] [blame] | 117 | struct bfa_fcp_mod_s *fcp; |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 118 | struct bfa_itnim_s *itnim_arr; |
| 119 | struct bfa_ioim_s *ioim_arr; |
| 120 | struct bfa_ioim_sp_s *ioim_sp_arr; |
| 121 | struct bfa_tskim_s *tskim_arr; |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 122 | int num_itnims; |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 123 | int num_tskim_reqs; |
| 124 | u32 path_tov; |
| 125 | u16 q_depth; |
| 126 | u8 reqq; /* Request queue to be used */ |
Krishna Gudipati | 83763d5 | 2011-07-20 17:04:03 -0700 | [diff] [blame] | 127 | u8 lun_masking_pending; |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 128 | struct list_head itnim_q; /* queue of active itnim */ |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 129 | struct list_head ioim_resfree_q; /* IOs waiting for f/w */ |
| 130 | struct list_head ioim_comp_q; /* IO global comp Q */ |
| 131 | struct list_head tskim_free_q; |
Krishna Gudipati | 3fd4598 | 2011-06-24 20:24:08 -0700 | [diff] [blame] | 132 | struct list_head tskim_unused_q; /* Unused tskim Q */ |
Maggie Zhang | da99dcc | 2010-12-09 19:13:20 -0800 | [diff] [blame] | 133 | u32 ios_active; /* current active IOs */ |
| 134 | u32 delay_comp; |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 135 | struct bfa_fcpim_del_itn_stats_s del_itn_stats; |
| 136 | bfa_boolean_t ioredirect; |
| 137 | bfa_boolean_t io_profile; |
Maggie Zhang | da99dcc | 2010-12-09 19:13:20 -0800 | [diff] [blame] | 138 | u32 io_profile_start_time; |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 139 | bfa_fcpim_profile_t profile_comp; |
| 140 | bfa_fcpim_profile_t profile_start; |
| 141 | }; |
| 142 | |
Krishna Gudipati | 4507025 | 2011-06-24 20:24:29 -0700 | [diff] [blame] | 143 | /* Max FCP dma segs required */ |
| 144 | #define BFA_FCP_DMA_SEGS BFI_IOIM_SNSBUF_SEGS |
| 145 | |
Krishna Gudipati | e2187d7 | 2011-06-13 15:53:58 -0700 | [diff] [blame] | 146 | struct bfa_fcp_mod_s { |
| 147 | struct bfa_s *bfa; |
| 148 | struct list_head iotag_ioim_free_q; /* free IO resources */ |
| 149 | struct list_head iotag_tio_free_q; /* free IO resources */ |
Krishna Gudipati | 3fd4598 | 2011-06-24 20:24:08 -0700 | [diff] [blame] | 150 | struct list_head iotag_unused_q; /* unused IO resources*/ |
Krishna Gudipati | e2187d7 | 2011-06-13 15:53:58 -0700 | [diff] [blame] | 151 | struct bfa_iotag_s *iotag_arr; |
| 152 | struct bfa_itn_s *itn_arr; |
| 153 | int num_ioim_reqs; |
| 154 | int num_fwtio_reqs; |
| 155 | int num_itns; |
Krishna Gudipati | 4507025 | 2011-06-24 20:24:29 -0700 | [diff] [blame] | 156 | struct bfa_dma_s snsbase[BFA_FCP_DMA_SEGS]; |
Krishna Gudipati | e2187d7 | 2011-06-13 15:53:58 -0700 | [diff] [blame] | 157 | struct bfa_fcpim_s fcpim; |
Krishna Gudipati | 4507025 | 2011-06-24 20:24:29 -0700 | [diff] [blame] | 158 | struct bfa_mem_dma_s dma_seg[BFA_FCP_DMA_SEGS]; |
| 159 | struct bfa_mem_kva_s kva_seg; |
Krishna Gudipati | e2187d7 | 2011-06-13 15:53:58 -0700 | [diff] [blame] | 160 | }; |
| 161 | |
Jing Huang | acdc79a | 2010-10-18 17:15:55 -0700 | [diff] [blame] | 162 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 163 | * BFA IO (initiator mode) |
| 164 | */ |
| 165 | struct bfa_ioim_s { |
| 166 | struct list_head qe; /* queue elememt */ |
| 167 | bfa_sm_t sm; /* BFA ioim state machine */ |
| 168 | struct bfa_s *bfa; /* BFA module */ |
Krishna Gudipati | e2187d7 | 2011-06-13 15:53:58 -0700 | [diff] [blame] | 169 | struct bfa_fcpim_s *fcpim; /* parent fcpim module */ |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 170 | struct bfa_itnim_s *itnim; /* i-t-n nexus for this IO */ |
| 171 | struct bfad_ioim_s *dio; /* driver IO handle */ |
Maggie Zhang | da99dcc | 2010-12-09 19:13:20 -0800 | [diff] [blame] | 172 | u16 iotag; /* FWI IO tag */ |
| 173 | u16 abort_tag; /* unqiue abort request tag */ |
| 174 | u16 nsges; /* number of SG elements */ |
| 175 | u16 nsgpgs; /* number of SG pages */ |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 176 | struct bfa_sgpg_s *sgpg; /* first SG page */ |
| 177 | struct list_head sgpg_q; /* allocated SG pages */ |
| 178 | struct bfa_cb_qe_s hcb_qe; /* bfa callback qelem */ |
| 179 | bfa_cb_cbfn_t io_cbfn; /* IO completion handler */ |
Maggie Zhang | da99dcc | 2010-12-09 19:13:20 -0800 | [diff] [blame] | 180 | struct bfa_ioim_sp_s *iosp; /* slow-path IO handling */ |
| 181 | u8 reqq; /* Request queue for I/O */ |
Krishna Gudipati | 83763d5 | 2011-07-20 17:04:03 -0700 | [diff] [blame] | 182 | u8 mode; /* IO is passthrough or not */ |
Maggie Zhang | da99dcc | 2010-12-09 19:13:20 -0800 | [diff] [blame] | 183 | u64 start_time; /* IO's Profile start val */ |
Krishna Gudipati | 83763d5 | 2011-07-20 17:04:03 -0700 | [diff] [blame] | 184 | bfa_ioim_lm_proc_rsp_data_t proc_rsp_data; /* RSP data adjust */ |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 185 | }; |
| 186 | |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 187 | struct bfa_ioim_sp_s { |
| 188 | struct bfi_msg_s comp_rspmsg; /* IO comp f/w response */ |
Maggie Zhang | da99dcc | 2010-12-09 19:13:20 -0800 | [diff] [blame] | 189 | struct bfa_sgpg_wqe_s sgpg_wqe; /* waitq elem for sgpg */ |
| 190 | struct bfa_reqq_wait_s reqq_wait; /* to wait for room in reqq */ |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 191 | bfa_boolean_t abort_explicit; /* aborted by OS */ |
| 192 | struct bfa_tskim_s *tskim; /* Relevant TM cmd */ |
| 193 | }; |
| 194 | |
Jing Huang | acdc79a | 2010-10-18 17:15:55 -0700 | [diff] [blame] | 195 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 196 | * BFA Task management command (initiator mode) |
| 197 | */ |
| 198 | struct bfa_tskim_s { |
| 199 | struct list_head qe; |
| 200 | bfa_sm_t sm; |
Maggie Zhang | da99dcc | 2010-12-09 19:13:20 -0800 | [diff] [blame] | 201 | struct bfa_s *bfa; /* BFA module */ |
Krishna Gudipati | e2187d7 | 2011-06-13 15:53:58 -0700 | [diff] [blame] | 202 | struct bfa_fcpim_s *fcpim; /* parent fcpim module */ |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 203 | struct bfa_itnim_s *itnim; /* i-t-n nexus for this IO */ |
Maggie Zhang | f314878 | 2010-12-09 19:11:39 -0800 | [diff] [blame] | 204 | struct bfad_tskim_s *dtsk; /* driver task mgmt cmnd */ |
Maggie Zhang | da99dcc | 2010-12-09 19:13:20 -0800 | [diff] [blame] | 205 | bfa_boolean_t notify; /* notify itnim on TM comp */ |
Maggie Zhang | f314878 | 2010-12-09 19:11:39 -0800 | [diff] [blame] | 206 | struct scsi_lun lun; /* lun if applicable */ |
Maggie Zhang | da99dcc | 2010-12-09 19:13:20 -0800 | [diff] [blame] | 207 | enum fcp_tm_cmnd tm_cmnd; /* task management command */ |
| 208 | u16 tsk_tag; /* FWI IO tag */ |
| 209 | u8 tsecs; /* timeout in seconds */ |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 210 | struct bfa_reqq_wait_s reqq_wait; /* to wait for room in reqq */ |
| 211 | struct list_head io_q; /* queue of affected IOs */ |
Maggie Zhang | da99dcc | 2010-12-09 19:13:20 -0800 | [diff] [blame] | 212 | struct bfa_wc_s wc; /* waiting counter */ |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 213 | struct bfa_cb_qe_s hcb_qe; /* bfa callback qelem */ |
| 214 | enum bfi_tskim_status tsk_status; /* TM status */ |
| 215 | }; |
| 216 | |
Jing Huang | acdc79a | 2010-10-18 17:15:55 -0700 | [diff] [blame] | 217 | /* |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 218 | * BFA i-t-n (initiator mode) |
| 219 | */ |
| 220 | struct bfa_itnim_s { |
Maggie Zhang | da99dcc | 2010-12-09 19:13:20 -0800 | [diff] [blame] | 221 | struct list_head qe; /* queue element */ |
| 222 | bfa_sm_t sm; /* i-t-n im BFA state machine */ |
| 223 | struct bfa_s *bfa; /* bfa instance */ |
| 224 | struct bfa_rport_s *rport; /* bfa rport */ |
| 225 | void *ditn; /* driver i-t-n structure */ |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 226 | struct bfi_mhdr_s mhdr; /* pre-built mhdr */ |
Maggie Zhang | da99dcc | 2010-12-09 19:13:20 -0800 | [diff] [blame] | 227 | u8 msg_no; /* itnim/rport firmware handle */ |
| 228 | u8 reqq; /* CQ for requests */ |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 229 | struct bfa_cb_qe_s hcb_qe; /* bfa callback qelem */ |
| 230 | struct list_head pending_q; /* queue of pending IO requests */ |
| 231 | struct list_head io_q; /* queue of active IO requests */ |
| 232 | struct list_head io_cleanup_q; /* IO being cleaned up */ |
| 233 | struct list_head tsk_q; /* queue of active TM commands */ |
| 234 | struct list_head delay_comp_q; /* queue of failed inflight cmds */ |
| 235 | bfa_boolean_t seq_rec; /* SQER supported */ |
| 236 | bfa_boolean_t is_online; /* itnim is ONLINE for IO */ |
| 237 | bfa_boolean_t iotov_active; /* IO TOV timer is active */ |
Maggie Zhang | da99dcc | 2010-12-09 19:13:20 -0800 | [diff] [blame] | 238 | struct bfa_wc_s wc; /* waiting counter */ |
| 239 | struct bfa_timer_s timer; /* pending IO TOV */ |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 240 | struct bfa_reqq_wait_s reqq_wait; /* to wait for room in reqq */ |
Krishna Gudipati | e2187d7 | 2011-06-13 15:53:58 -0700 | [diff] [blame] | 241 | struct bfa_fcpim_s *fcpim; /* fcpim module */ |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 242 | struct bfa_itnim_iostats_s stats; |
| 243 | struct bfa_itnim_ioprofile_s ioprofile; |
| 244 | }; |
| 245 | |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 246 | #define bfa_itnim_is_online(_itnim) ((_itnim)->is_online) |
Krishna Gudipati | e2187d7 | 2011-06-13 15:53:58 -0700 | [diff] [blame] | 247 | #define BFA_FCPIM(_hal) (&(_hal)->modules.fcp_mod.fcpim) |
Krishna Gudipati | 15821f0 | 2010-12-13 16:23:27 -0800 | [diff] [blame] | 248 | #define BFA_IOIM_TAG_2_ID(_iotag) ((_iotag) & BFA_IOIM_IOTAG_MASK) |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 249 | #define BFA_IOIM_FROM_TAG(_fcpim, _iotag) \ |
Krishna Gudipati | 15821f0 | 2010-12-13 16:23:27 -0800 | [diff] [blame] | 250 | (&fcpim->ioim_arr[(_iotag & BFA_IOIM_IOTAG_MASK)]) |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 251 | #define BFA_TSKIM_FROM_TAG(_fcpim, _tmtag) \ |
| 252 | (&fcpim->tskim_arr[_tmtag & (fcpim->num_tskim_reqs - 1)]) |
| 253 | |
| 254 | #define bfa_io_profile_start_time(_bfa) \ |
Krishna Gudipati | e2187d7 | 2011-06-13 15:53:58 -0700 | [diff] [blame] | 255 | ((_bfa)->modules.fcp_mod.fcpim.io_profile_start_time) |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 256 | #define bfa_fcpim_get_io_profile(_bfa) \ |
Krishna Gudipati | e2187d7 | 2011-06-13 15:53:58 -0700 | [diff] [blame] | 257 | ((_bfa)->modules.fcp_mod.fcpim.io_profile) |
Krishna Gudipati | 15821f0 | 2010-12-13 16:23:27 -0800 | [diff] [blame] | 258 | #define bfa_ioim_update_iotag(__ioim) do { \ |
| 259 | uint16_t k = (__ioim)->iotag >> BFA_IOIM_RETRY_TAG_OFFSET; \ |
| 260 | k++; (__ioim)->iotag &= BFA_IOIM_IOTAG_MASK; \ |
| 261 | (__ioim)->iotag |= k << BFA_IOIM_RETRY_TAG_OFFSET; \ |
| 262 | } while (0) |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 263 | |
Krishna Gudipati | 83763d5 | 2011-07-20 17:04:03 -0700 | [diff] [blame] | 264 | #define BFA_IOIM_TO_LPS(__ioim) \ |
| 265 | BFA_LPS_FROM_TAG(BFA_LPS_MOD(__ioim->bfa), \ |
| 266 | __ioim->itnim->rport->rport_info.lp_tag) |
| 267 | |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 268 | static inline bfa_boolean_t |
Krishna Gudipati | 15821f0 | 2010-12-13 16:23:27 -0800 | [diff] [blame] | 269 | bfa_ioim_maxretry_reached(struct bfa_ioim_s *ioim) |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 270 | { |
Krishna Gudipati | 15821f0 | 2010-12-13 16:23:27 -0800 | [diff] [blame] | 271 | uint16_t k = ioim->iotag >> BFA_IOIM_RETRY_TAG_OFFSET; |
| 272 | if (k < BFA_IOIM_RETRY_MAX) |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 273 | return BFA_FALSE; |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 274 | return BFA_TRUE; |
| 275 | } |
Krishna Gudipati | 15821f0 | 2010-12-13 16:23:27 -0800 | [diff] [blame] | 276 | |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 277 | /* |
| 278 | * function prototypes |
| 279 | */ |
Krishna Gudipati | 4507025 | 2011-06-24 20:24:29 -0700 | [diff] [blame] | 280 | void bfa_ioim_attach(struct bfa_fcpim_s *fcpim); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 281 | void bfa_ioim_isr(struct bfa_s *bfa, struct bfi_msg_s *msg); |
| 282 | void bfa_ioim_good_comp_isr(struct bfa_s *bfa, |
| 283 | struct bfi_msg_s *msg); |
| 284 | void bfa_ioim_cleanup(struct bfa_ioim_s *ioim); |
| 285 | void bfa_ioim_cleanup_tm(struct bfa_ioim_s *ioim, |
| 286 | struct bfa_tskim_s *tskim); |
| 287 | void bfa_ioim_iocdisable(struct bfa_ioim_s *ioim); |
| 288 | void bfa_ioim_tov(struct bfa_ioim_s *ioim); |
| 289 | |
Krishna Gudipati | 4507025 | 2011-06-24 20:24:29 -0700 | [diff] [blame] | 290 | void bfa_tskim_attach(struct bfa_fcpim_s *fcpim); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 291 | void bfa_tskim_isr(struct bfa_s *bfa, struct bfi_msg_s *msg); |
| 292 | void bfa_tskim_iodone(struct bfa_tskim_s *tskim); |
| 293 | void bfa_tskim_iocdisable(struct bfa_tskim_s *tskim); |
| 294 | void bfa_tskim_cleanup(struct bfa_tskim_s *tskim); |
Krishna Gudipati | 3fd4598 | 2011-06-24 20:24:08 -0700 | [diff] [blame] | 295 | void bfa_tskim_res_recfg(struct bfa_s *bfa, u16 num_tskim_fw); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 296 | |
Krishna Gudipati | 4507025 | 2011-06-24 20:24:29 -0700 | [diff] [blame] | 297 | void bfa_itnim_meminfo(struct bfa_iocfc_cfg_s *cfg, u32 *km_len); |
| 298 | void bfa_itnim_attach(struct bfa_fcpim_s *fcpim); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 299 | void bfa_itnim_iocdisable(struct bfa_itnim_s *itnim); |
| 300 | void bfa_itnim_isr(struct bfa_s *bfa, struct bfi_msg_s *msg); |
| 301 | void bfa_itnim_iodone(struct bfa_itnim_s *itnim); |
| 302 | void bfa_itnim_tskdone(struct bfa_itnim_s *itnim); |
| 303 | bfa_boolean_t bfa_itnim_hold_io(struct bfa_itnim_s *itnim); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 304 | |
| 305 | /* |
| 306 | * bfa fcpim module API functions |
| 307 | */ |
Maggie Zhang | da99dcc | 2010-12-09 19:13:20 -0800 | [diff] [blame] | 308 | void bfa_fcpim_path_tov_set(struct bfa_s *bfa, u16 path_tov); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 309 | u16 bfa_fcpim_path_tov_get(struct bfa_s *bfa); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 310 | u16 bfa_fcpim_qdepth_get(struct bfa_s *bfa); |
Krishna Gudipati | 6013806 | 2011-06-24 20:25:15 -0700 | [diff] [blame] | 311 | bfa_status_t bfa_fcpim_port_iostats(struct bfa_s *bfa, |
| 312 | struct bfa_itnim_iostats_s *stats, u8 lp_tag); |
| 313 | void bfa_fcpim_add_stats(struct bfa_itnim_iostats_s *fcpim_stats, |
| 314 | struct bfa_itnim_iostats_s *itnim_stats); |
Krishna Gudipati | 42a8e6e | 2011-07-20 17:01:52 -0700 | [diff] [blame] | 315 | bfa_status_t bfa_fcpim_profile_on(struct bfa_s *bfa, u32 time); |
| 316 | bfa_status_t bfa_fcpim_profile_off(struct bfa_s *bfa); |
Maggie Zhang | da99dcc | 2010-12-09 19:13:20 -0800 | [diff] [blame] | 317 | |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 318 | #define bfa_fcpim_ioredirect_enabled(__bfa) \ |
Krishna Gudipati | e2187d7 | 2011-06-13 15:53:58 -0700 | [diff] [blame] | 319 | (((struct bfa_fcpim_s *)(BFA_FCPIM(__bfa)))->ioredirect) |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 320 | |
| 321 | #define bfa_fcpim_get_next_reqq(__bfa, __qid) \ |
| 322 | { \ |
Krishna Gudipati | e2187d7 | 2011-06-13 15:53:58 -0700 | [diff] [blame] | 323 | struct bfa_fcpim_s *__fcpim = BFA_FCPIM(__bfa); \ |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 324 | __fcpim->reqq++; \ |
| 325 | __fcpim->reqq &= (BFI_IOC_MAX_CQS - 1); \ |
| 326 | *(__qid) = __fcpim->reqq; \ |
| 327 | } |
| 328 | |
| 329 | #define bfa_iocfc_map_msg_to_qid(__msg, __qid) \ |
| 330 | *(__qid) = (u8)((__msg) & (BFI_IOC_MAX_CQS - 1)); |
| 331 | /* |
| 332 | * bfa itnim API functions |
| 333 | */ |
| 334 | struct bfa_itnim_s *bfa_itnim_create(struct bfa_s *bfa, |
Maggie Zhang | da99dcc | 2010-12-09 19:13:20 -0800 | [diff] [blame] | 335 | struct bfa_rport_s *rport, void *itnim); |
| 336 | void bfa_itnim_delete(struct bfa_itnim_s *itnim); |
| 337 | void bfa_itnim_online(struct bfa_itnim_s *itnim, bfa_boolean_t seq_rec); |
| 338 | void bfa_itnim_offline(struct bfa_itnim_s *itnim); |
| 339 | void bfa_itnim_clear_stats(struct bfa_itnim_s *itnim); |
| 340 | bfa_status_t bfa_itnim_get_ioprofile(struct bfa_itnim_s *itnim, |
| 341 | struct bfa_itnim_ioprofile_s *ioprofile); |
| 342 | |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 343 | #define bfa_itnim_get_reqq(__ioim) (((struct bfa_ioim_s *)__ioim)->itnim->reqq) |
| 344 | |
Jing Huang | acdc79a | 2010-10-18 17:15:55 -0700 | [diff] [blame] | 345 | /* |
Maggie Zhang | da99dcc | 2010-12-09 19:13:20 -0800 | [diff] [blame] | 346 | * BFA completion callback for bfa_itnim_online(). |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 347 | */ |
| 348 | void bfa_cb_itnim_online(void *itnim); |
| 349 | |
Jing Huang | acdc79a | 2010-10-18 17:15:55 -0700 | [diff] [blame] | 350 | /* |
Maggie Zhang | da99dcc | 2010-12-09 19:13:20 -0800 | [diff] [blame] | 351 | * BFA completion callback for bfa_itnim_offline(). |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 352 | */ |
| 353 | void bfa_cb_itnim_offline(void *itnim); |
| 354 | void bfa_cb_itnim_tov_begin(void *itnim); |
| 355 | void bfa_cb_itnim_tov(void *itnim); |
| 356 | |
Jing Huang | acdc79a | 2010-10-18 17:15:55 -0700 | [diff] [blame] | 357 | /* |
Maggie Zhang | da99dcc | 2010-12-09 19:13:20 -0800 | [diff] [blame] | 358 | * BFA notification to FCS/driver for second level error recovery. |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 359 | * Atleast one I/O request has timedout and target is unresponsive to |
| 360 | * repeated abort requests. Second level error recovery should be initiated |
| 361 | * by starting implicit logout and recovery procedures. |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 362 | */ |
| 363 | void bfa_cb_itnim_sler(void *itnim); |
| 364 | |
| 365 | /* |
| 366 | * bfa ioim API functions |
| 367 | */ |
| 368 | struct bfa_ioim_s *bfa_ioim_alloc(struct bfa_s *bfa, |
| 369 | struct bfad_ioim_s *dio, |
| 370 | struct bfa_itnim_s *itnim, |
| 371 | u16 nsgles); |
| 372 | |
| 373 | void bfa_ioim_free(struct bfa_ioim_s *ioim); |
| 374 | void bfa_ioim_start(struct bfa_ioim_s *ioim); |
| 375 | bfa_status_t bfa_ioim_abort(struct bfa_ioim_s *ioim); |
| 376 | void bfa_ioim_delayed_comp(struct bfa_ioim_s *ioim, |
| 377 | bfa_boolean_t iotov); |
Jing Huang | acdc79a | 2010-10-18 17:15:55 -0700 | [diff] [blame] | 378 | /* |
Maggie Zhang | da99dcc | 2010-12-09 19:13:20 -0800 | [diff] [blame] | 379 | * I/O completion notification. |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 380 | * |
| 381 | * @param[in] dio driver IO structure |
| 382 | * @param[in] io_status IO completion status |
| 383 | * @param[in] scsi_status SCSI status returned by target |
| 384 | * @param[in] sns_len SCSI sense length, 0 if none |
| 385 | * @param[in] sns_info SCSI sense data, if any |
| 386 | * @param[in] residue Residual length |
| 387 | * |
| 388 | * @return None |
| 389 | */ |
Maggie Zhang | da99dcc | 2010-12-09 19:13:20 -0800 | [diff] [blame] | 390 | void bfa_cb_ioim_done(void *bfad, struct bfad_ioim_s *dio, |
| 391 | enum bfi_ioim_status io_status, |
| 392 | u8 scsi_status, int sns_len, |
| 393 | u8 *sns_info, s32 residue); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 394 | |
Jing Huang | acdc79a | 2010-10-18 17:15:55 -0700 | [diff] [blame] | 395 | /* |
Maggie Zhang | da99dcc | 2010-12-09 19:13:20 -0800 | [diff] [blame] | 396 | * I/O good completion notification. |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 397 | */ |
Maggie Zhang | da99dcc | 2010-12-09 19:13:20 -0800 | [diff] [blame] | 398 | void bfa_cb_ioim_good_comp(void *bfad, struct bfad_ioim_s *dio); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 399 | |
Jing Huang | acdc79a | 2010-10-18 17:15:55 -0700 | [diff] [blame] | 400 | /* |
Maggie Zhang | da99dcc | 2010-12-09 19:13:20 -0800 | [diff] [blame] | 401 | * I/O abort completion notification |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 402 | */ |
Maggie Zhang | da99dcc | 2010-12-09 19:13:20 -0800 | [diff] [blame] | 403 | void bfa_cb_ioim_abort(void *bfad, struct bfad_ioim_s *dio); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 404 | |
| 405 | /* |
| 406 | * bfa tskim API functions |
| 407 | */ |
Maggie Zhang | da99dcc | 2010-12-09 19:13:20 -0800 | [diff] [blame] | 408 | struct bfa_tskim_s *bfa_tskim_alloc(struct bfa_s *bfa, |
| 409 | struct bfad_tskim_s *dtsk); |
| 410 | void bfa_tskim_free(struct bfa_tskim_s *tskim); |
| 411 | void bfa_tskim_start(struct bfa_tskim_s *tskim, |
| 412 | struct bfa_itnim_s *itnim, struct scsi_lun lun, |
| 413 | enum fcp_tm_cmnd tm, u8 t_secs); |
| 414 | void bfa_cb_tskim_done(void *bfad, struct bfad_tskim_s *dtsk, |
| 415 | enum bfi_tskim_status tsk_status); |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 416 | |
Krishna Gudipati | 83763d5 | 2011-07-20 17:04:03 -0700 | [diff] [blame] | 417 | void bfa_fcpim_lunmask_rp_update(struct bfa_s *bfa, wwn_t lp_wwn, |
| 418 | wwn_t rp_wwn, u16 rp_tag, u8 lp_tag); |
Krishna Gudipati | 4c5d22b | 2011-07-20 17:04:24 -0700 | [diff] [blame] | 419 | bfa_status_t bfa_fcpim_lunmask_update(struct bfa_s *bfa, u32 on_off); |
| 420 | bfa_status_t bfa_fcpim_lunmask_query(struct bfa_s *bfa, void *buf); |
| 421 | bfa_status_t bfa_fcpim_lunmask_delete(struct bfa_s *bfa, u16 vf_id, |
| 422 | wwn_t *pwwn, wwn_t rpwwn, struct scsi_lun lun); |
| 423 | bfa_status_t bfa_fcpim_lunmask_add(struct bfa_s *bfa, u16 vf_id, |
| 424 | wwn_t *pwwn, wwn_t rpwwn, struct scsi_lun lun); |
| 425 | bfa_status_t bfa_fcpim_lunmask_clear(struct bfa_s *bfa); |
Krishna Gudipati | 83763d5 | 2011-07-20 17:04:03 -0700 | [diff] [blame] | 426 | |
Krishna Gudipati | a36c61f | 2010-09-15 11:50:55 -0700 | [diff] [blame] | 427 | #endif /* __BFA_FCPIM_H__ */ |