0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef __BFA_FCPIM_H__
0012 #define __BFA_FCPIM_H__
0013
0014 #include "bfa.h"
0015 #include "bfa_svc.h"
0016 #include "bfi_ms.h"
0017 #include "bfa_defs_svc.h"
0018 #include "bfa_cs.h"
0019
0020
0021 #define BFA_IO_MAX BFI_IO_MAX
0022 #define BFA_FWTIO_MAX 2000
0023
0024 struct bfa_fcp_mod_s;
0025 struct bfa_iotag_s {
0026 struct list_head qe;
0027 u16 tag;
0028 };
0029
0030 struct bfa_itn_s {
0031 bfa_isr_func_t isr;
0032 };
0033
0034 void bfa_itn_create(struct bfa_s *bfa, struct bfa_rport_s *rport,
0035 void (*isr)(struct bfa_s *bfa, struct bfi_msg_s *m));
0036 void bfa_itn_isr(struct bfa_s *bfa, struct bfi_msg_s *m);
0037 void bfa_iotag_attach(struct bfa_fcp_mod_s *fcp);
0038 void bfa_fcp_res_recfg(struct bfa_s *bfa, u16 num_ioim_fw, u16 max_ioim_fw);
0039
0040 #define BFA_FCP_MOD(_hal) (&(_hal)->modules.fcp_mod)
0041 #define BFA_MEM_FCP_KVA(__bfa) (&(BFA_FCP_MOD(__bfa)->kva_seg))
0042 #define BFA_IOTAG_FROM_TAG(_fcp, _tag) \
0043 (&(_fcp)->iotag_arr[(_tag & BFA_IOIM_IOTAG_MASK)])
0044 #define BFA_ITN_FROM_TAG(_fcp, _tag) \
0045 ((_fcp)->itn_arr + ((_tag) & ((_fcp)->num_itns - 1)))
0046 #define BFA_SNSINFO_FROM_TAG(_fcp, _tag) \
0047 bfa_mem_get_dmabuf_kva(_fcp, (_tag & BFA_IOIM_IOTAG_MASK), \
0048 BFI_IOIM_SNSLEN)
0049
0050
0051 #define BFA_ITNIM_MIN 32
0052 #define BFA_ITNIM_MAX 1024
0053
0054 #define BFA_IOIM_MIN 8
0055 #define BFA_IOIM_MAX 2000
0056
0057 #define BFA_TSKIM_MIN 4
0058 #define BFA_TSKIM_MAX 512
0059 #define BFA_FCPIM_PATHTOV_DEF (30 * 1000)
0060 #define BFA_FCPIM_PATHTOV_MAX (90 * 1000)
0061
0062
0063 #define bfa_itnim_ioprofile_update(__itnim, __index) \
0064 (__itnim->ioprofile.iocomps[__index]++)
0065
0066 #define BFA_IOIM_RETRY_TAG_OFFSET 11
0067 #define BFA_IOIM_IOTAG_MASK 0x07ff
0068 #define BFA_IOIM_RETRY_MAX 7
0069
0070
0071 static inline u32
0072 bfa_ioim_get_index(u32 n) {
0073 int pos = 0;
0074 if (n >= (1UL)<<22)
0075 return BFA_IOBUCKET_MAX - 1;
0076 n >>= 8;
0077 if (n >= (1UL)<<16) {
0078 n >>= 16;
0079 pos += 16;
0080 }
0081 if (n >= 1 << 8) {
0082 n >>= 8;
0083 pos += 8;
0084 }
0085 if (n >= 1 << 4) {
0086 n >>= 4;
0087 pos += 4;
0088 }
0089 if (n >= 1 << 2) {
0090 n >>= 2;
0091 pos += 2;
0092 }
0093 if (n >= 1 << 1)
0094 pos += 1;
0095
0096 return (n == 0) ? (0) : pos;
0097 }
0098
0099
0100
0101
0102 struct bfa_ioim_s;
0103 struct bfa_tskim_s;
0104 struct bfad_ioim_s;
0105 struct bfad_tskim_s;
0106
0107 typedef void (*bfa_fcpim_profile_t) (struct bfa_ioim_s *ioim);
0108
0109 struct bfa_fcpim_s {
0110 struct bfa_s *bfa;
0111 struct bfa_fcp_mod_s *fcp;
0112 struct bfa_itnim_s *itnim_arr;
0113 struct bfa_ioim_s *ioim_arr;
0114 struct bfa_ioim_sp_s *ioim_sp_arr;
0115 struct bfa_tskim_s *tskim_arr;
0116 int num_itnims;
0117 int num_tskim_reqs;
0118 u32 path_tov;
0119 u16 q_depth;
0120 u8 reqq;
0121 struct list_head itnim_q;
0122 struct list_head ioim_resfree_q;
0123 struct list_head ioim_comp_q;
0124 struct list_head tskim_free_q;
0125 struct list_head tskim_unused_q;
0126 u32 ios_active;
0127 u32 delay_comp;
0128 struct bfa_fcpim_del_itn_stats_s del_itn_stats;
0129 bfa_boolean_t ioredirect;
0130 bfa_boolean_t io_profile;
0131 time64_t io_profile_start_time;
0132 bfa_fcpim_profile_t profile_comp;
0133 bfa_fcpim_profile_t profile_start;
0134 };
0135
0136
0137 #define BFA_FCP_DMA_SEGS BFI_IOIM_SNSBUF_SEGS
0138
0139 struct bfa_fcp_mod_s {
0140 struct bfa_s *bfa;
0141 struct list_head iotag_ioim_free_q;
0142 struct list_head iotag_tio_free_q;
0143 struct list_head iotag_unused_q;
0144 struct bfa_iotag_s *iotag_arr;
0145 struct bfa_itn_s *itn_arr;
0146 int max_ioim_reqs;
0147 int num_ioim_reqs;
0148 int num_fwtio_reqs;
0149 int num_itns;
0150 struct bfa_dma_s snsbase[BFA_FCP_DMA_SEGS];
0151 struct bfa_fcpim_s fcpim;
0152 struct bfa_mem_dma_s dma_seg[BFA_FCP_DMA_SEGS];
0153 struct bfa_mem_kva_s kva_seg;
0154 int throttle_update_required;
0155 };
0156
0157
0158
0159
0160 struct bfa_ioim_s {
0161 struct list_head qe;
0162 bfa_sm_t sm;
0163 struct bfa_s *bfa;
0164 struct bfa_fcpim_s *fcpim;
0165 struct bfa_itnim_s *itnim;
0166 struct bfad_ioim_s *dio;
0167 u16 iotag;
0168 u16 abort_tag;
0169 u16 nsges;
0170 u16 nsgpgs;
0171 struct bfa_sgpg_s *sgpg;
0172 struct list_head sgpg_q;
0173 struct bfa_cb_qe_s hcb_qe;
0174 bfa_cb_cbfn_t io_cbfn;
0175 struct bfa_ioim_sp_s *iosp;
0176 u8 reqq;
0177 u8 mode;
0178 u64 start_time;
0179 };
0180
0181 struct bfa_ioim_sp_s {
0182 struct bfi_msg_s comp_rspmsg;
0183 struct bfa_sgpg_wqe_s sgpg_wqe;
0184 struct bfa_reqq_wait_s reqq_wait;
0185 bfa_boolean_t abort_explicit;
0186 struct bfa_tskim_s *tskim;
0187 };
0188
0189
0190
0191
0192 struct bfa_tskim_s {
0193 struct list_head qe;
0194 bfa_sm_t sm;
0195 struct bfa_s *bfa;
0196 struct bfa_fcpim_s *fcpim;
0197 struct bfa_itnim_s *itnim;
0198 struct bfad_tskim_s *dtsk;
0199 bfa_boolean_t notify;
0200 struct scsi_lun lun;
0201 enum fcp_tm_cmnd tm_cmnd;
0202 u16 tsk_tag;
0203 u8 tsecs;
0204 struct bfa_reqq_wait_s reqq_wait;
0205 struct list_head io_q;
0206 struct bfa_wc_s wc;
0207 struct bfa_cb_qe_s hcb_qe;
0208 enum bfi_tskim_status tsk_status;
0209 };
0210
0211
0212
0213
0214 struct bfa_itnim_s {
0215 struct list_head qe;
0216 bfa_sm_t sm;
0217 struct bfa_s *bfa;
0218 struct bfa_rport_s *rport;
0219 void *ditn;
0220 struct bfi_mhdr_s mhdr;
0221 u8 msg_no;
0222 u8 reqq;
0223 struct bfa_cb_qe_s hcb_qe;
0224 struct list_head pending_q;
0225 struct list_head io_q;
0226 struct list_head io_cleanup_q;
0227 struct list_head tsk_q;
0228 struct list_head delay_comp_q;
0229 bfa_boolean_t seq_rec;
0230 bfa_boolean_t is_online;
0231 bfa_boolean_t iotov_active;
0232 struct bfa_wc_s wc;
0233 struct bfa_timer_s timer;
0234 struct bfa_reqq_wait_s reqq_wait;
0235 struct bfa_fcpim_s *fcpim;
0236 struct bfa_itnim_iostats_s stats;
0237 struct bfa_itnim_ioprofile_s ioprofile;
0238 };
0239
0240 #define bfa_itnim_is_online(_itnim) ((_itnim)->is_online)
0241 #define BFA_FCPIM(_hal) (&(_hal)->modules.fcp_mod.fcpim)
0242 #define BFA_IOIM_TAG_2_ID(_iotag) ((_iotag) & BFA_IOIM_IOTAG_MASK)
0243 #define BFA_IOIM_FROM_TAG(_fcpim, _iotag) \
0244 (&fcpim->ioim_arr[(_iotag & BFA_IOIM_IOTAG_MASK)])
0245 #define BFA_TSKIM_FROM_TAG(_fcpim, _tmtag) \
0246 (&fcpim->tskim_arr[_tmtag & (fcpim->num_tskim_reqs - 1)])
0247
0248 #define bfa_io_profile_start_time(_bfa) \
0249 ((_bfa)->modules.fcp_mod.fcpim.io_profile_start_time)
0250 #define bfa_fcpim_get_io_profile(_bfa) \
0251 ((_bfa)->modules.fcp_mod.fcpim.io_profile)
0252 #define bfa_ioim_update_iotag(__ioim) do { \
0253 uint16_t k = (__ioim)->iotag >> BFA_IOIM_RETRY_TAG_OFFSET; \
0254 k++; (__ioim)->iotag &= BFA_IOIM_IOTAG_MASK; \
0255 (__ioim)->iotag |= k << BFA_IOIM_RETRY_TAG_OFFSET; \
0256 } while (0)
0257
0258 static inline bfa_boolean_t
0259 bfa_ioim_maxretry_reached(struct bfa_ioim_s *ioim)
0260 {
0261 uint16_t k = ioim->iotag >> BFA_IOIM_RETRY_TAG_OFFSET;
0262 if (k < BFA_IOIM_RETRY_MAX)
0263 return BFA_FALSE;
0264 return BFA_TRUE;
0265 }
0266
0267
0268
0269
0270 void bfa_ioim_attach(struct bfa_fcpim_s *fcpim);
0271 void bfa_ioim_isr(struct bfa_s *bfa, struct bfi_msg_s *msg);
0272 void bfa_ioim_good_comp_isr(struct bfa_s *bfa,
0273 struct bfi_msg_s *msg);
0274 void bfa_ioim_cleanup(struct bfa_ioim_s *ioim);
0275 void bfa_ioim_cleanup_tm(struct bfa_ioim_s *ioim,
0276 struct bfa_tskim_s *tskim);
0277 void bfa_ioim_iocdisable(struct bfa_ioim_s *ioim);
0278 void bfa_ioim_tov(struct bfa_ioim_s *ioim);
0279
0280 void bfa_tskim_attach(struct bfa_fcpim_s *fcpim);
0281 void bfa_tskim_isr(struct bfa_s *bfa, struct bfi_msg_s *msg);
0282 void bfa_tskim_iodone(struct bfa_tskim_s *tskim);
0283 void bfa_tskim_iocdisable(struct bfa_tskim_s *tskim);
0284 void bfa_tskim_cleanup(struct bfa_tskim_s *tskim);
0285 void bfa_tskim_res_recfg(struct bfa_s *bfa, u16 num_tskim_fw);
0286
0287 void bfa_itnim_meminfo(struct bfa_iocfc_cfg_s *cfg, u32 *km_len);
0288 void bfa_itnim_attach(struct bfa_fcpim_s *fcpim);
0289 void bfa_itnim_iocdisable(struct bfa_itnim_s *itnim);
0290 void bfa_itnim_isr(struct bfa_s *bfa, struct bfi_msg_s *msg);
0291 void bfa_itnim_iodone(struct bfa_itnim_s *itnim);
0292 void bfa_itnim_tskdone(struct bfa_itnim_s *itnim);
0293 bfa_boolean_t bfa_itnim_hold_io(struct bfa_itnim_s *itnim);
0294
0295
0296
0297
0298 void bfa_fcpim_path_tov_set(struct bfa_s *bfa, u16 path_tov);
0299 u16 bfa_fcpim_path_tov_get(struct bfa_s *bfa);
0300 u16 bfa_fcpim_qdepth_get(struct bfa_s *bfa);
0301 bfa_status_t bfa_fcpim_port_iostats(struct bfa_s *bfa,
0302 struct bfa_itnim_iostats_s *stats, u8 lp_tag);
0303 void bfa_fcpim_add_stats(struct bfa_itnim_iostats_s *fcpim_stats,
0304 struct bfa_itnim_iostats_s *itnim_stats);
0305 bfa_status_t bfa_fcpim_profile_on(struct bfa_s *bfa, time64_t time);
0306 bfa_status_t bfa_fcpim_profile_off(struct bfa_s *bfa);
0307
0308 #define bfa_fcpim_ioredirect_enabled(__bfa) \
0309 (((struct bfa_fcpim_s *)(BFA_FCPIM(__bfa)))->ioredirect)
0310
0311 #define bfa_fcpim_get_next_reqq(__bfa, __qid) \
0312 { \
0313 struct bfa_fcpim_s *__fcpim = BFA_FCPIM(__bfa); \
0314 __fcpim->reqq++; \
0315 __fcpim->reqq &= (BFI_IOC_MAX_CQS - 1); \
0316 *(__qid) = __fcpim->reqq; \
0317 }
0318
0319 #define bfa_iocfc_map_msg_to_qid(__msg, __qid) \
0320 *(__qid) = (u8)((__msg) & (BFI_IOC_MAX_CQS - 1));
0321
0322
0323
0324 struct bfa_itnim_s *bfa_itnim_create(struct bfa_s *bfa,
0325 struct bfa_rport_s *rport, void *itnim);
0326 void bfa_itnim_delete(struct bfa_itnim_s *itnim);
0327 void bfa_itnim_online(struct bfa_itnim_s *itnim, bfa_boolean_t seq_rec);
0328 void bfa_itnim_offline(struct bfa_itnim_s *itnim);
0329 void bfa_itnim_clear_stats(struct bfa_itnim_s *itnim);
0330 bfa_status_t bfa_itnim_get_ioprofile(struct bfa_itnim_s *itnim,
0331 struct bfa_itnim_ioprofile_s *ioprofile);
0332
0333 #define bfa_itnim_get_reqq(__ioim) (((struct bfa_ioim_s *)__ioim)->itnim->reqq)
0334
0335
0336
0337
0338 void bfa_cb_itnim_online(void *itnim);
0339
0340
0341
0342
0343 void bfa_cb_itnim_offline(void *itnim);
0344 void bfa_cb_itnim_tov_begin(void *itnim);
0345 void bfa_cb_itnim_tov(void *itnim);
0346
0347
0348
0349
0350
0351
0352
0353 void bfa_cb_itnim_sler(void *itnim);
0354
0355
0356
0357
0358 struct bfa_ioim_s *bfa_ioim_alloc(struct bfa_s *bfa,
0359 struct bfad_ioim_s *dio,
0360 struct bfa_itnim_s *itnim,
0361 u16 nsgles);
0362
0363 void bfa_ioim_free(struct bfa_ioim_s *ioim);
0364 void bfa_ioim_start(struct bfa_ioim_s *ioim);
0365 bfa_status_t bfa_ioim_abort(struct bfa_ioim_s *ioim);
0366 void bfa_ioim_delayed_comp(struct bfa_ioim_s *ioim,
0367 bfa_boolean_t iotov);
0368
0369
0370
0371
0372
0373
0374
0375
0376
0377
0378
0379
0380 void bfa_cb_ioim_done(void *bfad, struct bfad_ioim_s *dio,
0381 enum bfi_ioim_status io_status,
0382 u8 scsi_status, int sns_len,
0383 u8 *sns_info, s32 residue);
0384
0385
0386
0387
0388 void bfa_cb_ioim_good_comp(void *bfad, struct bfad_ioim_s *dio);
0389
0390
0391
0392
0393 void bfa_cb_ioim_abort(void *bfad, struct bfad_ioim_s *dio);
0394
0395
0396
0397
0398 struct bfa_tskim_s *bfa_tskim_alloc(struct bfa_s *bfa,
0399 struct bfad_tskim_s *dtsk);
0400 void bfa_tskim_free(struct bfa_tskim_s *tskim);
0401 void bfa_tskim_start(struct bfa_tskim_s *tskim,
0402 struct bfa_itnim_s *itnim, struct scsi_lun lun,
0403 enum fcp_tm_cmnd tm, u8 t_secs);
0404 void bfa_cb_tskim_done(void *bfad, struct bfad_tskim_s *dtsk,
0405 enum bfi_tskim_status tsk_status);
0406
0407 void bfa_fcpim_lunmask_rp_update(struct bfa_s *bfa, wwn_t lp_wwn,
0408 wwn_t rp_wwn, u16 rp_tag, u8 lp_tag);
0409 bfa_status_t bfa_fcpim_lunmask_update(struct bfa_s *bfa, u32 on_off);
0410 bfa_status_t bfa_fcpim_lunmask_query(struct bfa_s *bfa, void *buf);
0411 bfa_status_t bfa_fcpim_lunmask_delete(struct bfa_s *bfa, u16 vf_id,
0412 wwn_t *pwwn, wwn_t rpwwn, struct scsi_lun lun);
0413 bfa_status_t bfa_fcpim_lunmask_add(struct bfa_s *bfa, u16 vf_id,
0414 wwn_t *pwwn, wwn_t rpwwn, struct scsi_lun lun);
0415 bfa_status_t bfa_fcpim_lunmask_clear(struct bfa_s *bfa);
0416 u16 bfa_fcpim_read_throttle(struct bfa_s *bfa);
0417 bfa_status_t bfa_fcpim_write_throttle(struct bfa_s *bfa, u16 value);
0418 bfa_status_t bfa_fcpim_throttle_set(struct bfa_s *bfa, u16 value);
0419 bfa_status_t bfa_fcpim_throttle_get(struct bfa_s *bfa, void *buf);
0420 u16 bfa_fcpim_get_throttle_cfg(struct bfa_s *bfa, u16 drv_cfg_param);
0421
0422 #endif