1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright (c) 2005-2014 Brocade Communications Systems, Inc.
4 * Copyright (c) 2014- QLogic Corporation.
8 * Linux driver for QLogic BR-series Fibre Channel Host Bus Adapter.
12 #include "bfa_modules.h"
14 BFA_TRC_FILE(HAL
, FCPIM
);
17 * BFA ITNIM Related definitions
19 static void bfa_itnim_update_del_itn_stats(struct bfa_itnim_s
*itnim
);
21 #define BFA_ITNIM_FROM_TAG(_fcpim, _tag) \
22 (((_fcpim)->itnim_arr + ((_tag) & ((_fcpim)->num_itnims - 1))))
24 #define bfa_fcpim_additn(__itnim) \
25 list_add_tail(&(__itnim)->qe, &(__itnim)->fcpim->itnim_q)
26 #define bfa_fcpim_delitn(__itnim) do { \
27 WARN_ON(!bfa_q_is_on_q(&(__itnim)->fcpim->itnim_q, __itnim)); \
28 bfa_itnim_update_del_itn_stats(__itnim); \
29 list_del(&(__itnim)->qe); \
30 WARN_ON(!list_empty(&(__itnim)->io_q)); \
31 WARN_ON(!list_empty(&(__itnim)->io_cleanup_q)); \
32 WARN_ON(!list_empty(&(__itnim)->pending_q)); \
35 #define bfa_itnim_online_cb(__itnim) do { \
36 if ((__itnim)->bfa->fcs) \
37 bfa_cb_itnim_online((__itnim)->ditn); \
39 bfa_cb_queue((__itnim)->bfa, &(__itnim)->hcb_qe, \
40 __bfa_cb_itnim_online, (__itnim)); \
44 #define bfa_itnim_offline_cb(__itnim) do { \
45 if ((__itnim)->bfa->fcs) \
46 bfa_cb_itnim_offline((__itnim)->ditn); \
48 bfa_cb_queue((__itnim)->bfa, &(__itnim)->hcb_qe, \
49 __bfa_cb_itnim_offline, (__itnim)); \
53 #define bfa_itnim_sler_cb(__itnim) do { \
54 if ((__itnim)->bfa->fcs) \
55 bfa_cb_itnim_sler((__itnim)->ditn); \
57 bfa_cb_queue((__itnim)->bfa, &(__itnim)->hcb_qe, \
58 __bfa_cb_itnim_sler, (__itnim)); \
62 enum bfa_ioim_lm_ua_status
{
63 BFA_IOIM_LM_UA_RESET
= 0,
64 BFA_IOIM_LM_UA_SET
= 1,
68 * itnim state machine event
70 enum bfa_itnim_event
{
71 BFA_ITNIM_SM_CREATE
= 1, /* itnim is created */
72 BFA_ITNIM_SM_ONLINE
= 2, /* itnim is online */
73 BFA_ITNIM_SM_OFFLINE
= 3, /* itnim is offline */
74 BFA_ITNIM_SM_FWRSP
= 4, /* firmware response */
75 BFA_ITNIM_SM_DELETE
= 5, /* deleting an existing itnim */
76 BFA_ITNIM_SM_CLEANUP
= 6, /* IO cleanup completion */
77 BFA_ITNIM_SM_SLER
= 7, /* second level error recovery */
78 BFA_ITNIM_SM_HWFAIL
= 8, /* IOC h/w failure event */
79 BFA_ITNIM_SM_QRESUME
= 9, /* queue space available */
83 * BFA IOIM related definitions
85 #define bfa_ioim_move_to_comp_q(__ioim) do { \
86 list_del(&(__ioim)->qe); \
87 list_add_tail(&(__ioim)->qe, &(__ioim)->fcpim->ioim_comp_q); \
91 #define bfa_ioim_cb_profile_comp(__fcpim, __ioim) do { \
92 if ((__fcpim)->profile_comp) \
93 (__fcpim)->profile_comp(__ioim); \
96 #define bfa_ioim_cb_profile_start(__fcpim, __ioim) do { \
97 if ((__fcpim)->profile_start) \
98 (__fcpim)->profile_start(__ioim); \
102 * IO state machine events
104 enum bfa_ioim_event
{
105 BFA_IOIM_SM_START
= 1, /* io start request from host */
106 BFA_IOIM_SM_COMP_GOOD
= 2, /* io good comp, resource free */
107 BFA_IOIM_SM_COMP
= 3, /* io comp, resource is free */
108 BFA_IOIM_SM_COMP_UTAG
= 4, /* io comp, resource is free */
109 BFA_IOIM_SM_DONE
= 5, /* io comp, resource not free */
110 BFA_IOIM_SM_FREE
= 6, /* io resource is freed */
111 BFA_IOIM_SM_ABORT
= 7, /* abort request from scsi stack */
112 BFA_IOIM_SM_ABORT_COMP
= 8, /* abort from f/w */
113 BFA_IOIM_SM_ABORT_DONE
= 9, /* abort completion from f/w */
114 BFA_IOIM_SM_QRESUME
= 10, /* CQ space available to queue IO */
115 BFA_IOIM_SM_SGALLOCED
= 11, /* SG page allocation successful */
116 BFA_IOIM_SM_SQRETRY
= 12, /* sequence recovery retry */
117 BFA_IOIM_SM_HCB
= 13, /* bfa callback complete */
118 BFA_IOIM_SM_CLEANUP
= 14, /* IO cleanup from itnim */
119 BFA_IOIM_SM_TMSTART
= 15, /* IO cleanup from tskim */
120 BFA_IOIM_SM_TMDONE
= 16, /* IO cleanup from tskim */
121 BFA_IOIM_SM_HWFAIL
= 17, /* IOC h/w failure event */
122 BFA_IOIM_SM_IOTOV
= 18, /* ITN offline TOV */
127 * BFA TSKIM related definitions
131 * task management completion handling
133 #define bfa_tskim_qcomp(__tskim, __cbfn) do { \
134 bfa_cb_queue((__tskim)->bfa, &(__tskim)->hcb_qe, __cbfn, (__tskim));\
135 bfa_tskim_notify_comp(__tskim); \
138 #define bfa_tskim_notify_comp(__tskim) do { \
139 if ((__tskim)->notify) \
140 bfa_itnim_tskdone((__tskim)->itnim); \
144 enum bfa_tskim_event
{
145 BFA_TSKIM_SM_START
= 1, /* TM command start */
146 BFA_TSKIM_SM_DONE
= 2, /* TM completion */
147 BFA_TSKIM_SM_QRESUME
= 3, /* resume after qfull */
148 BFA_TSKIM_SM_HWFAIL
= 5, /* IOC h/w failure event */
149 BFA_TSKIM_SM_HCB
= 6, /* BFA callback completion */
150 BFA_TSKIM_SM_IOS_DONE
= 7, /* IO and sub TM completions */
151 BFA_TSKIM_SM_CLEANUP
= 8, /* TM cleanup on ITN offline */
152 BFA_TSKIM_SM_CLEANUP_DONE
= 9, /* TM abort completion */
153 BFA_TSKIM_SM_UTAG
= 10, /* TM completion unknown tag */
157 * forward declaration for BFA ITNIM functions
159 static void bfa_itnim_iocdisable_cleanup(struct bfa_itnim_s
*itnim
);
160 static bfa_boolean_t
bfa_itnim_send_fwcreate(struct bfa_itnim_s
*itnim
);
161 static bfa_boolean_t
bfa_itnim_send_fwdelete(struct bfa_itnim_s
*itnim
);
162 static void bfa_itnim_cleanp_comp(void *itnim_cbarg
);
163 static void bfa_itnim_cleanup(struct bfa_itnim_s
*itnim
);
164 static void __bfa_cb_itnim_online(void *cbarg
, bfa_boolean_t complete
);
165 static void __bfa_cb_itnim_offline(void *cbarg
, bfa_boolean_t complete
);
166 static void __bfa_cb_itnim_sler(void *cbarg
, bfa_boolean_t complete
);
167 static void bfa_itnim_iotov_online(struct bfa_itnim_s
*itnim
);
168 static void bfa_itnim_iotov_cleanup(struct bfa_itnim_s
*itnim
);
169 static void bfa_itnim_iotov(void *itnim_arg
);
170 static void bfa_itnim_iotov_start(struct bfa_itnim_s
*itnim
);
171 static void bfa_itnim_iotov_stop(struct bfa_itnim_s
*itnim
);
172 static void bfa_itnim_iotov_delete(struct bfa_itnim_s
*itnim
);
175 * forward declaration of ITNIM state machine
177 static void bfa_itnim_sm_uninit(struct bfa_itnim_s
*itnim
,
178 enum bfa_itnim_event event
);
179 static void bfa_itnim_sm_created(struct bfa_itnim_s
*itnim
,
180 enum bfa_itnim_event event
);
181 static void bfa_itnim_sm_fwcreate(struct bfa_itnim_s
*itnim
,
182 enum bfa_itnim_event event
);
183 static void bfa_itnim_sm_delete_pending(struct bfa_itnim_s
*itnim
,
184 enum bfa_itnim_event event
);
185 static void bfa_itnim_sm_online(struct bfa_itnim_s
*itnim
,
186 enum bfa_itnim_event event
);
187 static void bfa_itnim_sm_sler(struct bfa_itnim_s
*itnim
,
188 enum bfa_itnim_event event
);
189 static void bfa_itnim_sm_cleanup_offline(struct bfa_itnim_s
*itnim
,
190 enum bfa_itnim_event event
);
191 static void bfa_itnim_sm_cleanup_delete(struct bfa_itnim_s
*itnim
,
192 enum bfa_itnim_event event
);
193 static void bfa_itnim_sm_fwdelete(struct bfa_itnim_s
*itnim
,
194 enum bfa_itnim_event event
);
195 static void bfa_itnim_sm_offline(struct bfa_itnim_s
*itnim
,
196 enum bfa_itnim_event event
);
197 static void bfa_itnim_sm_iocdisable(struct bfa_itnim_s
*itnim
,
198 enum bfa_itnim_event event
);
199 static void bfa_itnim_sm_deleting(struct bfa_itnim_s
*itnim
,
200 enum bfa_itnim_event event
);
201 static void bfa_itnim_sm_fwcreate_qfull(struct bfa_itnim_s
*itnim
,
202 enum bfa_itnim_event event
);
203 static void bfa_itnim_sm_fwdelete_qfull(struct bfa_itnim_s
*itnim
,
204 enum bfa_itnim_event event
);
205 static void bfa_itnim_sm_deleting_qfull(struct bfa_itnim_s
*itnim
,
206 enum bfa_itnim_event event
);
209 * forward declaration for BFA IOIM functions
211 static bfa_boolean_t
bfa_ioim_send_ioreq(struct bfa_ioim_s
*ioim
);
212 static bfa_boolean_t
bfa_ioim_sgpg_alloc(struct bfa_ioim_s
*ioim
);
213 static bfa_boolean_t
bfa_ioim_send_abort(struct bfa_ioim_s
*ioim
);
214 static void bfa_ioim_notify_cleanup(struct bfa_ioim_s
*ioim
);
215 static void __bfa_cb_ioim_good_comp(void *cbarg
, bfa_boolean_t complete
);
216 static void __bfa_cb_ioim_comp(void *cbarg
, bfa_boolean_t complete
);
217 static void __bfa_cb_ioim_abort(void *cbarg
, bfa_boolean_t complete
);
218 static void __bfa_cb_ioim_failed(void *cbarg
, bfa_boolean_t complete
);
219 static void __bfa_cb_ioim_pathtov(void *cbarg
, bfa_boolean_t complete
);
220 static bfa_boolean_t
bfa_ioim_is_abortable(struct bfa_ioim_s
*ioim
);
223 * forward declaration of BFA IO state machine
225 static void bfa_ioim_sm_uninit(struct bfa_ioim_s
*ioim
,
226 enum bfa_ioim_event event
);
227 static void bfa_ioim_sm_sgalloc(struct bfa_ioim_s
*ioim
,
228 enum bfa_ioim_event event
);
229 static void bfa_ioim_sm_active(struct bfa_ioim_s
*ioim
,
230 enum bfa_ioim_event event
);
231 static void bfa_ioim_sm_abort(struct bfa_ioim_s
*ioim
,
232 enum bfa_ioim_event event
);
233 static void bfa_ioim_sm_cleanup(struct bfa_ioim_s
*ioim
,
234 enum bfa_ioim_event event
);
235 static void bfa_ioim_sm_qfull(struct bfa_ioim_s
*ioim
,
236 enum bfa_ioim_event event
);
237 static void bfa_ioim_sm_abort_qfull(struct bfa_ioim_s
*ioim
,
238 enum bfa_ioim_event event
);
239 static void bfa_ioim_sm_cleanup_qfull(struct bfa_ioim_s
*ioim
,
240 enum bfa_ioim_event event
);
241 static void bfa_ioim_sm_hcb(struct bfa_ioim_s
*ioim
,
242 enum bfa_ioim_event event
);
243 static void bfa_ioim_sm_hcb_free(struct bfa_ioim_s
*ioim
,
244 enum bfa_ioim_event event
);
245 static void bfa_ioim_sm_resfree(struct bfa_ioim_s
*ioim
,
246 enum bfa_ioim_event event
);
247 static void bfa_ioim_sm_cmnd_retry(struct bfa_ioim_s
*ioim
,
248 enum bfa_ioim_event event
);
250 * forward declaration for BFA TSKIM functions
252 static void __bfa_cb_tskim_done(void *cbarg
, bfa_boolean_t complete
);
253 static void __bfa_cb_tskim_failed(void *cbarg
, bfa_boolean_t complete
);
254 static bfa_boolean_t
bfa_tskim_match_scope(struct bfa_tskim_s
*tskim
,
255 struct scsi_lun lun
);
256 static void bfa_tskim_gather_ios(struct bfa_tskim_s
*tskim
);
257 static void bfa_tskim_cleanp_comp(void *tskim_cbarg
);
258 static void bfa_tskim_cleanup_ios(struct bfa_tskim_s
*tskim
);
259 static bfa_boolean_t
bfa_tskim_send(struct bfa_tskim_s
*tskim
);
260 static bfa_boolean_t
bfa_tskim_send_abort(struct bfa_tskim_s
*tskim
);
261 static void bfa_tskim_iocdisable_ios(struct bfa_tskim_s
*tskim
);
264 * forward declaration of BFA TSKIM state machine
266 static void bfa_tskim_sm_uninit(struct bfa_tskim_s
*tskim
,
267 enum bfa_tskim_event event
);
268 static void bfa_tskim_sm_active(struct bfa_tskim_s
*tskim
,
269 enum bfa_tskim_event event
);
270 static void bfa_tskim_sm_cleanup(struct bfa_tskim_s
*tskim
,
271 enum bfa_tskim_event event
);
272 static void bfa_tskim_sm_iocleanup(struct bfa_tskim_s
*tskim
,
273 enum bfa_tskim_event event
);
274 static void bfa_tskim_sm_qfull(struct bfa_tskim_s
*tskim
,
275 enum bfa_tskim_event event
);
276 static void bfa_tskim_sm_cleanup_qfull(struct bfa_tskim_s
*tskim
,
277 enum bfa_tskim_event event
);
278 static void bfa_tskim_sm_hcb(struct bfa_tskim_s
*tskim
,
279 enum bfa_tskim_event event
);
281 * BFA FCP Initiator Mode module
285 * Compute and return memory needed by FCP(im) module.
288 bfa_fcpim_meminfo(struct bfa_iocfc_cfg_s
*cfg
, u32
*km_len
)
290 bfa_itnim_meminfo(cfg
, km_len
);
295 *km_len
+= cfg
->fwcfg
.num_ioim_reqs
*
296 (sizeof(struct bfa_ioim_s
) + sizeof(struct bfa_ioim_sp_s
));
299 * task management command memory
301 if (cfg
->fwcfg
.num_tskim_reqs
< BFA_TSKIM_MIN
)
302 cfg
->fwcfg
.num_tskim_reqs
= BFA_TSKIM_MIN
;
303 *km_len
+= cfg
->fwcfg
.num_tskim_reqs
* sizeof(struct bfa_tskim_s
);
308 bfa_fcpim_attach(struct bfa_fcp_mod_s
*fcp
, void *bfad
,
309 struct bfa_iocfc_cfg_s
*cfg
, struct bfa_pcidev_s
*pcidev
)
311 struct bfa_fcpim_s
*fcpim
= &fcp
->fcpim
;
312 struct bfa_s
*bfa
= fcp
->bfa
;
314 bfa_trc(bfa
, cfg
->drvcfg
.path_tov
);
315 bfa_trc(bfa
, cfg
->fwcfg
.num_rports
);
316 bfa_trc(bfa
, cfg
->fwcfg
.num_ioim_reqs
);
317 bfa_trc(bfa
, cfg
->fwcfg
.num_tskim_reqs
);
321 fcpim
->num_itnims
= cfg
->fwcfg
.num_rports
;
322 fcpim
->num_tskim_reqs
= cfg
->fwcfg
.num_tskim_reqs
;
323 fcpim
->path_tov
= cfg
->drvcfg
.path_tov
;
324 fcpim
->delay_comp
= cfg
->drvcfg
.delay_comp
;
325 fcpim
->profile_comp
= NULL
;
326 fcpim
->profile_start
= NULL
;
328 bfa_itnim_attach(fcpim
);
329 bfa_tskim_attach(fcpim
);
330 bfa_ioim_attach(fcpim
);
334 bfa_fcpim_iocdisable(struct bfa_fcp_mod_s
*fcp
)
336 struct bfa_fcpim_s
*fcpim
= &fcp
->fcpim
;
337 struct bfa_itnim_s
*itnim
;
338 struct list_head
*qe
, *qen
;
340 /* Enqueue unused ioim resources to free_q */
341 list_splice_tail_init(&fcpim
->tskim_unused_q
, &fcpim
->tskim_free_q
);
343 list_for_each_safe(qe
, qen
, &fcpim
->itnim_q
) {
344 itnim
= (struct bfa_itnim_s
*) qe
;
345 bfa_itnim_iocdisable(itnim
);
350 bfa_fcpim_path_tov_set(struct bfa_s
*bfa
, u16 path_tov
)
352 struct bfa_fcpim_s
*fcpim
= BFA_FCPIM(bfa
);
354 fcpim
->path_tov
= path_tov
* 1000;
355 if (fcpim
->path_tov
> BFA_FCPIM_PATHTOV_MAX
)
356 fcpim
->path_tov
= BFA_FCPIM_PATHTOV_MAX
;
360 bfa_fcpim_path_tov_get(struct bfa_s
*bfa
)
362 struct bfa_fcpim_s
*fcpim
= BFA_FCPIM(bfa
);
364 return fcpim
->path_tov
/ 1000;
367 #define bfa_fcpim_add_iostats(__l, __r, __stats) \
368 (__l->__stats += __r->__stats)
371 bfa_fcpim_add_stats(struct bfa_itnim_iostats_s
*lstats
,
372 struct bfa_itnim_iostats_s
*rstats
)
374 bfa_fcpim_add_iostats(lstats
, rstats
, total_ios
);
375 bfa_fcpim_add_iostats(lstats
, rstats
, qresumes
);
376 bfa_fcpim_add_iostats(lstats
, rstats
, no_iotags
);
377 bfa_fcpim_add_iostats(lstats
, rstats
, io_aborts
);
378 bfa_fcpim_add_iostats(lstats
, rstats
, no_tskims
);
379 bfa_fcpim_add_iostats(lstats
, rstats
, iocomp_ok
);
380 bfa_fcpim_add_iostats(lstats
, rstats
, iocomp_underrun
);
381 bfa_fcpim_add_iostats(lstats
, rstats
, iocomp_overrun
);
382 bfa_fcpim_add_iostats(lstats
, rstats
, iocomp_aborted
);
383 bfa_fcpim_add_iostats(lstats
, rstats
, iocomp_timedout
);
384 bfa_fcpim_add_iostats(lstats
, rstats
, iocom_nexus_abort
);
385 bfa_fcpim_add_iostats(lstats
, rstats
, iocom_proto_err
);
386 bfa_fcpim_add_iostats(lstats
, rstats
, iocom_dif_err
);
387 bfa_fcpim_add_iostats(lstats
, rstats
, iocom_sqer_needed
);
388 bfa_fcpim_add_iostats(lstats
, rstats
, iocom_res_free
);
389 bfa_fcpim_add_iostats(lstats
, rstats
, iocom_hostabrts
);
390 bfa_fcpim_add_iostats(lstats
, rstats
, iocom_utags
);
391 bfa_fcpim_add_iostats(lstats
, rstats
, io_cleanups
);
392 bfa_fcpim_add_iostats(lstats
, rstats
, io_tmaborts
);
393 bfa_fcpim_add_iostats(lstats
, rstats
, onlines
);
394 bfa_fcpim_add_iostats(lstats
, rstats
, offlines
);
395 bfa_fcpim_add_iostats(lstats
, rstats
, creates
);
396 bfa_fcpim_add_iostats(lstats
, rstats
, deletes
);
397 bfa_fcpim_add_iostats(lstats
, rstats
, create_comps
);
398 bfa_fcpim_add_iostats(lstats
, rstats
, delete_comps
);
399 bfa_fcpim_add_iostats(lstats
, rstats
, sler_events
);
400 bfa_fcpim_add_iostats(lstats
, rstats
, fw_create
);
401 bfa_fcpim_add_iostats(lstats
, rstats
, fw_delete
);
402 bfa_fcpim_add_iostats(lstats
, rstats
, ioc_disabled
);
403 bfa_fcpim_add_iostats(lstats
, rstats
, cleanup_comps
);
404 bfa_fcpim_add_iostats(lstats
, rstats
, tm_cmnds
);
405 bfa_fcpim_add_iostats(lstats
, rstats
, tm_fw_rsps
);
406 bfa_fcpim_add_iostats(lstats
, rstats
, tm_success
);
407 bfa_fcpim_add_iostats(lstats
, rstats
, tm_failures
);
408 bfa_fcpim_add_iostats(lstats
, rstats
, tm_io_comps
);
409 bfa_fcpim_add_iostats(lstats
, rstats
, tm_qresumes
);
410 bfa_fcpim_add_iostats(lstats
, rstats
, tm_iocdowns
);
411 bfa_fcpim_add_iostats(lstats
, rstats
, tm_cleanups
);
412 bfa_fcpim_add_iostats(lstats
, rstats
, tm_cleanup_comps
);
413 bfa_fcpim_add_iostats(lstats
, rstats
, io_comps
);
414 bfa_fcpim_add_iostats(lstats
, rstats
, input_reqs
);
415 bfa_fcpim_add_iostats(lstats
, rstats
, output_reqs
);
416 bfa_fcpim_add_iostats(lstats
, rstats
, rd_throughput
);
417 bfa_fcpim_add_iostats(lstats
, rstats
, wr_throughput
);
421 bfa_fcpim_port_iostats(struct bfa_s
*bfa
,
422 struct bfa_itnim_iostats_s
*stats
, u8 lp_tag
)
424 struct bfa_fcpim_s
*fcpim
= BFA_FCPIM(bfa
);
425 struct list_head
*qe
, *qen
;
426 struct bfa_itnim_s
*itnim
;
428 /* accumulate IO stats from itnim */
429 memset(stats
, 0, sizeof(struct bfa_itnim_iostats_s
));
430 list_for_each_safe(qe
, qen
, &fcpim
->itnim_q
) {
431 itnim
= (struct bfa_itnim_s
*) qe
;
432 if (itnim
->rport
->rport_info
.lp_tag
!= lp_tag
)
434 bfa_fcpim_add_stats(stats
, &(itnim
->stats
));
436 return BFA_STATUS_OK
;
440 bfa_ioim_profile_comp(struct bfa_ioim_s
*ioim
)
442 struct bfa_itnim_latency_s
*io_lat
=
443 &(ioim
->itnim
->ioprofile
.io_latency
);
446 val
= (u32
)(jiffies
- ioim
->start_time
);
447 idx
= bfa_ioim_get_index(scsi_bufflen((struct scsi_cmnd
*)ioim
->dio
));
448 bfa_itnim_ioprofile_update(ioim
->itnim
, idx
);
450 io_lat
->count
[idx
]++;
451 io_lat
->min
[idx
] = (io_lat
->min
[idx
] < val
) ? io_lat
->min
[idx
] : val
;
452 io_lat
->max
[idx
] = (io_lat
->max
[idx
] > val
) ? io_lat
->max
[idx
] : val
;
453 io_lat
->avg
[idx
] += val
;
457 bfa_ioim_profile_start(struct bfa_ioim_s
*ioim
)
459 ioim
->start_time
= jiffies
;
463 bfa_fcpim_profile_on(struct bfa_s
*bfa
, time64_t time
)
465 struct bfa_itnim_s
*itnim
;
466 struct bfa_fcpim_s
*fcpim
= BFA_FCPIM(bfa
);
467 struct list_head
*qe
, *qen
;
469 /* accumulate IO stats from itnim */
470 list_for_each_safe(qe
, qen
, &fcpim
->itnim_q
) {
471 itnim
= (struct bfa_itnim_s
*) qe
;
472 bfa_itnim_clear_stats(itnim
);
474 fcpim
->io_profile
= BFA_TRUE
;
475 fcpim
->io_profile_start_time
= time
;
476 fcpim
->profile_comp
= bfa_ioim_profile_comp
;
477 fcpim
->profile_start
= bfa_ioim_profile_start
;
478 return BFA_STATUS_OK
;
482 bfa_fcpim_profile_off(struct bfa_s
*bfa
)
484 struct bfa_fcpim_s
*fcpim
= BFA_FCPIM(bfa
);
485 fcpim
->io_profile
= BFA_FALSE
;
486 fcpim
->io_profile_start_time
= 0;
487 fcpim
->profile_comp
= NULL
;
488 fcpim
->profile_start
= NULL
;
489 return BFA_STATUS_OK
;
493 bfa_fcpim_qdepth_get(struct bfa_s
*bfa
)
495 struct bfa_fcpim_s
*fcpim
= BFA_FCPIM(bfa
);
497 return fcpim
->q_depth
;
501 * BFA ITNIM module state machine functions
505 * Beginning/unallocated state - no events expected.
508 bfa_itnim_sm_uninit(struct bfa_itnim_s
*itnim
, enum bfa_itnim_event event
)
510 bfa_trc(itnim
->bfa
, itnim
->rport
->rport_tag
);
511 bfa_trc(itnim
->bfa
, event
);
514 case BFA_ITNIM_SM_CREATE
:
515 bfa_sm_set_state(itnim
, bfa_itnim_sm_created
);
516 itnim
->is_online
= BFA_FALSE
;
517 bfa_fcpim_additn(itnim
);
521 bfa_sm_fault(itnim
->bfa
, event
);
526 * Beginning state, only online event expected.
529 bfa_itnim_sm_created(struct bfa_itnim_s
*itnim
, enum bfa_itnim_event event
)
531 bfa_trc(itnim
->bfa
, itnim
->rport
->rport_tag
);
532 bfa_trc(itnim
->bfa
, event
);
535 case BFA_ITNIM_SM_ONLINE
:
536 if (bfa_itnim_send_fwcreate(itnim
))
537 bfa_sm_set_state(itnim
, bfa_itnim_sm_fwcreate
);
539 bfa_sm_set_state(itnim
, bfa_itnim_sm_fwcreate_qfull
);
542 case BFA_ITNIM_SM_DELETE
:
543 bfa_sm_set_state(itnim
, bfa_itnim_sm_uninit
);
544 bfa_fcpim_delitn(itnim
);
547 case BFA_ITNIM_SM_HWFAIL
:
548 bfa_sm_set_state(itnim
, bfa_itnim_sm_iocdisable
);
552 bfa_sm_fault(itnim
->bfa
, event
);
557 * Waiting for itnim create response from firmware.
560 bfa_itnim_sm_fwcreate(struct bfa_itnim_s
*itnim
, enum bfa_itnim_event event
)
562 bfa_trc(itnim
->bfa
, itnim
->rport
->rport_tag
);
563 bfa_trc(itnim
->bfa
, event
);
566 case BFA_ITNIM_SM_FWRSP
:
567 bfa_sm_set_state(itnim
, bfa_itnim_sm_online
);
568 itnim
->is_online
= BFA_TRUE
;
569 bfa_itnim_iotov_online(itnim
);
570 bfa_itnim_online_cb(itnim
);
573 case BFA_ITNIM_SM_DELETE
:
574 bfa_sm_set_state(itnim
, bfa_itnim_sm_delete_pending
);
577 case BFA_ITNIM_SM_OFFLINE
:
578 if (bfa_itnim_send_fwdelete(itnim
))
579 bfa_sm_set_state(itnim
, bfa_itnim_sm_fwdelete
);
581 bfa_sm_set_state(itnim
, bfa_itnim_sm_fwdelete_qfull
);
584 case BFA_ITNIM_SM_HWFAIL
:
585 bfa_sm_set_state(itnim
, bfa_itnim_sm_iocdisable
);
589 bfa_sm_fault(itnim
->bfa
, event
);
594 bfa_itnim_sm_fwcreate_qfull(struct bfa_itnim_s
*itnim
,
595 enum bfa_itnim_event event
)
597 bfa_trc(itnim
->bfa
, itnim
->rport
->rport_tag
);
598 bfa_trc(itnim
->bfa
, event
);
601 case BFA_ITNIM_SM_QRESUME
:
602 bfa_sm_set_state(itnim
, bfa_itnim_sm_fwcreate
);
603 bfa_itnim_send_fwcreate(itnim
);
606 case BFA_ITNIM_SM_DELETE
:
607 bfa_sm_set_state(itnim
, bfa_itnim_sm_uninit
);
608 bfa_reqq_wcancel(&itnim
->reqq_wait
);
609 bfa_fcpim_delitn(itnim
);
612 case BFA_ITNIM_SM_OFFLINE
:
613 bfa_sm_set_state(itnim
, bfa_itnim_sm_offline
);
614 bfa_reqq_wcancel(&itnim
->reqq_wait
);
615 bfa_itnim_offline_cb(itnim
);
618 case BFA_ITNIM_SM_HWFAIL
:
619 bfa_sm_set_state(itnim
, bfa_itnim_sm_iocdisable
);
620 bfa_reqq_wcancel(&itnim
->reqq_wait
);
624 bfa_sm_fault(itnim
->bfa
, event
);
629 * Waiting for itnim create response from firmware, a delete is pending.
632 bfa_itnim_sm_delete_pending(struct bfa_itnim_s
*itnim
,
633 enum bfa_itnim_event event
)
635 bfa_trc(itnim
->bfa
, itnim
->rport
->rport_tag
);
636 bfa_trc(itnim
->bfa
, event
);
639 case BFA_ITNIM_SM_FWRSP
:
640 if (bfa_itnim_send_fwdelete(itnim
))
641 bfa_sm_set_state(itnim
, bfa_itnim_sm_deleting
);
643 bfa_sm_set_state(itnim
, bfa_itnim_sm_deleting_qfull
);
646 case BFA_ITNIM_SM_HWFAIL
:
647 bfa_sm_set_state(itnim
, bfa_itnim_sm_uninit
);
648 bfa_fcpim_delitn(itnim
);
652 bfa_sm_fault(itnim
->bfa
, event
);
657 * Online state - normal parking state.
660 bfa_itnim_sm_online(struct bfa_itnim_s
*itnim
, enum bfa_itnim_event event
)
662 bfa_trc(itnim
->bfa
, itnim
->rport
->rport_tag
);
663 bfa_trc(itnim
->bfa
, event
);
666 case BFA_ITNIM_SM_OFFLINE
:
667 bfa_sm_set_state(itnim
, bfa_itnim_sm_cleanup_offline
);
668 itnim
->is_online
= BFA_FALSE
;
669 bfa_itnim_iotov_start(itnim
);
670 bfa_itnim_cleanup(itnim
);
673 case BFA_ITNIM_SM_DELETE
:
674 bfa_sm_set_state(itnim
, bfa_itnim_sm_cleanup_delete
);
675 itnim
->is_online
= BFA_FALSE
;
676 bfa_itnim_cleanup(itnim
);
679 case BFA_ITNIM_SM_SLER
:
680 bfa_sm_set_state(itnim
, bfa_itnim_sm_sler
);
681 itnim
->is_online
= BFA_FALSE
;
682 bfa_itnim_iotov_start(itnim
);
683 bfa_itnim_sler_cb(itnim
);
686 case BFA_ITNIM_SM_HWFAIL
:
687 bfa_sm_set_state(itnim
, bfa_itnim_sm_iocdisable
);
688 itnim
->is_online
= BFA_FALSE
;
689 bfa_itnim_iotov_start(itnim
);
690 bfa_itnim_iocdisable_cleanup(itnim
);
694 bfa_sm_fault(itnim
->bfa
, event
);
699 * Second level error recovery need.
702 bfa_itnim_sm_sler(struct bfa_itnim_s
*itnim
, enum bfa_itnim_event event
)
704 bfa_trc(itnim
->bfa
, itnim
->rport
->rport_tag
);
705 bfa_trc(itnim
->bfa
, event
);
708 case BFA_ITNIM_SM_OFFLINE
:
709 bfa_sm_set_state(itnim
, bfa_itnim_sm_cleanup_offline
);
710 bfa_itnim_cleanup(itnim
);
713 case BFA_ITNIM_SM_DELETE
:
714 bfa_sm_set_state(itnim
, bfa_itnim_sm_cleanup_delete
);
715 bfa_itnim_cleanup(itnim
);
716 bfa_itnim_iotov_delete(itnim
);
719 case BFA_ITNIM_SM_HWFAIL
:
720 bfa_sm_set_state(itnim
, bfa_itnim_sm_iocdisable
);
721 bfa_itnim_iocdisable_cleanup(itnim
);
725 bfa_sm_fault(itnim
->bfa
, event
);
730 * Going offline. Waiting for active IO cleanup.
733 bfa_itnim_sm_cleanup_offline(struct bfa_itnim_s
*itnim
,
734 enum bfa_itnim_event event
)
736 bfa_trc(itnim
->bfa
, itnim
->rport
->rport_tag
);
737 bfa_trc(itnim
->bfa
, event
);
740 case BFA_ITNIM_SM_CLEANUP
:
741 if (bfa_itnim_send_fwdelete(itnim
))
742 bfa_sm_set_state(itnim
, bfa_itnim_sm_fwdelete
);
744 bfa_sm_set_state(itnim
, bfa_itnim_sm_fwdelete_qfull
);
747 case BFA_ITNIM_SM_DELETE
:
748 bfa_sm_set_state(itnim
, bfa_itnim_sm_cleanup_delete
);
749 bfa_itnim_iotov_delete(itnim
);
752 case BFA_ITNIM_SM_HWFAIL
:
753 bfa_sm_set_state(itnim
, bfa_itnim_sm_iocdisable
);
754 bfa_itnim_iocdisable_cleanup(itnim
);
755 bfa_itnim_offline_cb(itnim
);
758 case BFA_ITNIM_SM_SLER
:
762 bfa_sm_fault(itnim
->bfa
, event
);
767 * Deleting itnim. Waiting for active IO cleanup.
770 bfa_itnim_sm_cleanup_delete(struct bfa_itnim_s
*itnim
,
771 enum bfa_itnim_event event
)
773 bfa_trc(itnim
->bfa
, itnim
->rport
->rport_tag
);
774 bfa_trc(itnim
->bfa
, event
);
777 case BFA_ITNIM_SM_CLEANUP
:
778 if (bfa_itnim_send_fwdelete(itnim
))
779 bfa_sm_set_state(itnim
, bfa_itnim_sm_deleting
);
781 bfa_sm_set_state(itnim
, bfa_itnim_sm_deleting_qfull
);
784 case BFA_ITNIM_SM_HWFAIL
:
785 bfa_sm_set_state(itnim
, bfa_itnim_sm_iocdisable
);
786 bfa_itnim_iocdisable_cleanup(itnim
);
790 bfa_sm_fault(itnim
->bfa
, event
);
795 * Rport offline. Fimrware itnim is being deleted - awaiting f/w response.
798 bfa_itnim_sm_fwdelete(struct bfa_itnim_s
*itnim
, enum bfa_itnim_event event
)
800 bfa_trc(itnim
->bfa
, itnim
->rport
->rport_tag
);
801 bfa_trc(itnim
->bfa
, event
);
804 case BFA_ITNIM_SM_FWRSP
:
805 bfa_sm_set_state(itnim
, bfa_itnim_sm_offline
);
806 bfa_itnim_offline_cb(itnim
);
809 case BFA_ITNIM_SM_DELETE
:
810 bfa_sm_set_state(itnim
, bfa_itnim_sm_deleting
);
813 case BFA_ITNIM_SM_HWFAIL
:
814 bfa_sm_set_state(itnim
, bfa_itnim_sm_iocdisable
);
815 bfa_itnim_offline_cb(itnim
);
819 bfa_sm_fault(itnim
->bfa
, event
);
824 bfa_itnim_sm_fwdelete_qfull(struct bfa_itnim_s
*itnim
,
825 enum bfa_itnim_event event
)
827 bfa_trc(itnim
->bfa
, itnim
->rport
->rport_tag
);
828 bfa_trc(itnim
->bfa
, event
);
831 case BFA_ITNIM_SM_QRESUME
:
832 bfa_sm_set_state(itnim
, bfa_itnim_sm_fwdelete
);
833 bfa_itnim_send_fwdelete(itnim
);
836 case BFA_ITNIM_SM_DELETE
:
837 bfa_sm_set_state(itnim
, bfa_itnim_sm_deleting_qfull
);
840 case BFA_ITNIM_SM_HWFAIL
:
841 bfa_sm_set_state(itnim
, bfa_itnim_sm_iocdisable
);
842 bfa_reqq_wcancel(&itnim
->reqq_wait
);
843 bfa_itnim_offline_cb(itnim
);
847 bfa_sm_fault(itnim
->bfa
, event
);
855 bfa_itnim_sm_offline(struct bfa_itnim_s
*itnim
, enum bfa_itnim_event event
)
857 bfa_trc(itnim
->bfa
, itnim
->rport
->rport_tag
);
858 bfa_trc(itnim
->bfa
, event
);
861 case BFA_ITNIM_SM_DELETE
:
862 bfa_sm_set_state(itnim
, bfa_itnim_sm_uninit
);
863 bfa_itnim_iotov_delete(itnim
);
864 bfa_fcpim_delitn(itnim
);
867 case BFA_ITNIM_SM_ONLINE
:
868 if (bfa_itnim_send_fwcreate(itnim
))
869 bfa_sm_set_state(itnim
, bfa_itnim_sm_fwcreate
);
871 bfa_sm_set_state(itnim
, bfa_itnim_sm_fwcreate_qfull
);
874 case BFA_ITNIM_SM_HWFAIL
:
875 bfa_sm_set_state(itnim
, bfa_itnim_sm_iocdisable
);
879 bfa_sm_fault(itnim
->bfa
, event
);
884 bfa_itnim_sm_iocdisable(struct bfa_itnim_s
*itnim
,
885 enum bfa_itnim_event event
)
887 bfa_trc(itnim
->bfa
, itnim
->rport
->rport_tag
);
888 bfa_trc(itnim
->bfa
, event
);
891 case BFA_ITNIM_SM_DELETE
:
892 bfa_sm_set_state(itnim
, bfa_itnim_sm_uninit
);
893 bfa_itnim_iotov_delete(itnim
);
894 bfa_fcpim_delitn(itnim
);
897 case BFA_ITNIM_SM_OFFLINE
:
898 bfa_itnim_offline_cb(itnim
);
901 case BFA_ITNIM_SM_ONLINE
:
902 if (bfa_itnim_send_fwcreate(itnim
))
903 bfa_sm_set_state(itnim
, bfa_itnim_sm_fwcreate
);
905 bfa_sm_set_state(itnim
, bfa_itnim_sm_fwcreate_qfull
);
908 case BFA_ITNIM_SM_HWFAIL
:
912 bfa_sm_fault(itnim
->bfa
, event
);
917 * Itnim is deleted, waiting for firmware response to delete.
920 bfa_itnim_sm_deleting(struct bfa_itnim_s
*itnim
, enum bfa_itnim_event event
)
922 bfa_trc(itnim
->bfa
, itnim
->rport
->rport_tag
);
923 bfa_trc(itnim
->bfa
, event
);
926 case BFA_ITNIM_SM_FWRSP
:
927 case BFA_ITNIM_SM_HWFAIL
:
928 bfa_sm_set_state(itnim
, bfa_itnim_sm_uninit
);
929 bfa_fcpim_delitn(itnim
);
933 bfa_sm_fault(itnim
->bfa
, event
);
938 bfa_itnim_sm_deleting_qfull(struct bfa_itnim_s
*itnim
,
939 enum bfa_itnim_event event
)
941 bfa_trc(itnim
->bfa
, itnim
->rport
->rport_tag
);
942 bfa_trc(itnim
->bfa
, event
);
945 case BFA_ITNIM_SM_QRESUME
:
946 bfa_sm_set_state(itnim
, bfa_itnim_sm_deleting
);
947 bfa_itnim_send_fwdelete(itnim
);
950 case BFA_ITNIM_SM_HWFAIL
:
951 bfa_sm_set_state(itnim
, bfa_itnim_sm_uninit
);
952 bfa_reqq_wcancel(&itnim
->reqq_wait
);
953 bfa_fcpim_delitn(itnim
);
957 bfa_sm_fault(itnim
->bfa
, event
);
962 * Initiate cleanup of all IOs on an IOC failure.
965 bfa_itnim_iocdisable_cleanup(struct bfa_itnim_s
*itnim
)
967 struct bfa_tskim_s
*tskim
;
968 struct bfa_ioim_s
*ioim
;
969 struct list_head
*qe
, *qen
;
971 list_for_each_safe(qe
, qen
, &itnim
->tsk_q
) {
972 tskim
= (struct bfa_tskim_s
*) qe
;
973 bfa_tskim_iocdisable(tskim
);
976 list_for_each_safe(qe
, qen
, &itnim
->io_q
) {
977 ioim
= (struct bfa_ioim_s
*) qe
;
978 bfa_ioim_iocdisable(ioim
);
982 * For IO request in pending queue, we pretend an early timeout.
984 list_for_each_safe(qe
, qen
, &itnim
->pending_q
) {
985 ioim
= (struct bfa_ioim_s
*) qe
;
989 list_for_each_safe(qe
, qen
, &itnim
->io_cleanup_q
) {
990 ioim
= (struct bfa_ioim_s
*) qe
;
991 bfa_ioim_iocdisable(ioim
);
996 * IO cleanup completion
999 bfa_itnim_cleanp_comp(void *itnim_cbarg
)
1001 struct bfa_itnim_s
*itnim
= itnim_cbarg
;
1003 bfa_stats(itnim
, cleanup_comps
);
1004 bfa_sm_send_event(itnim
, BFA_ITNIM_SM_CLEANUP
);
1008 * Initiate cleanup of all IOs.
1011 bfa_itnim_cleanup(struct bfa_itnim_s
*itnim
)
1013 struct bfa_ioim_s
*ioim
;
1014 struct bfa_tskim_s
*tskim
;
1015 struct list_head
*qe
, *qen
;
1017 bfa_wc_init(&itnim
->wc
, bfa_itnim_cleanp_comp
, itnim
);
1019 list_for_each_safe(qe
, qen
, &itnim
->io_q
) {
1020 ioim
= (struct bfa_ioim_s
*) qe
;
1023 * Move IO to a cleanup queue from active queue so that a later
1024 * TM will not pickup this IO.
1026 list_del(&ioim
->qe
);
1027 list_add_tail(&ioim
->qe
, &itnim
->io_cleanup_q
);
1029 bfa_wc_up(&itnim
->wc
);
1030 bfa_ioim_cleanup(ioim
);
1033 list_for_each_safe(qe
, qen
, &itnim
->tsk_q
) {
1034 tskim
= (struct bfa_tskim_s
*) qe
;
1035 bfa_wc_up(&itnim
->wc
);
1036 bfa_tskim_cleanup(tskim
);
1039 bfa_wc_wait(&itnim
->wc
);
1043 __bfa_cb_itnim_online(void *cbarg
, bfa_boolean_t complete
)
1045 struct bfa_itnim_s
*itnim
= cbarg
;
1048 bfa_cb_itnim_online(itnim
->ditn
);
1052 __bfa_cb_itnim_offline(void *cbarg
, bfa_boolean_t complete
)
1054 struct bfa_itnim_s
*itnim
= cbarg
;
1057 bfa_cb_itnim_offline(itnim
->ditn
);
1061 __bfa_cb_itnim_sler(void *cbarg
, bfa_boolean_t complete
)
1063 struct bfa_itnim_s
*itnim
= cbarg
;
1066 bfa_cb_itnim_sler(itnim
->ditn
);
1070 * Call to resume any I/O requests waiting for room in request queue.
1073 bfa_itnim_qresume(void *cbarg
)
1075 struct bfa_itnim_s
*itnim
= cbarg
;
1077 bfa_sm_send_event(itnim
, BFA_ITNIM_SM_QRESUME
);
1085 bfa_itnim_iodone(struct bfa_itnim_s
*itnim
)
1087 bfa_wc_down(&itnim
->wc
);
1091 bfa_itnim_tskdone(struct bfa_itnim_s
*itnim
)
1093 bfa_wc_down(&itnim
->wc
);
1097 bfa_itnim_meminfo(struct bfa_iocfc_cfg_s
*cfg
, u32
*km_len
)
1102 *km_len
+= cfg
->fwcfg
.num_rports
* sizeof(struct bfa_itnim_s
);
1106 bfa_itnim_attach(struct bfa_fcpim_s
*fcpim
)
1108 struct bfa_s
*bfa
= fcpim
->bfa
;
1109 struct bfa_fcp_mod_s
*fcp
= fcpim
->fcp
;
1110 struct bfa_itnim_s
*itnim
;
1113 INIT_LIST_HEAD(&fcpim
->itnim_q
);
1115 itnim
= (struct bfa_itnim_s
*) bfa_mem_kva_curp(fcp
);
1116 fcpim
->itnim_arr
= itnim
;
1118 for (i
= 0; i
< fcpim
->num_itnims
; i
++, itnim
++) {
1119 memset(itnim
, 0, sizeof(struct bfa_itnim_s
));
1121 itnim
->fcpim
= fcpim
;
1122 itnim
->reqq
= BFA_REQQ_QOS_LO
;
1123 itnim
->rport
= BFA_RPORT_FROM_TAG(bfa
, i
);
1124 itnim
->iotov_active
= BFA_FALSE
;
1125 bfa_reqq_winit(&itnim
->reqq_wait
, bfa_itnim_qresume
, itnim
);
1127 INIT_LIST_HEAD(&itnim
->io_q
);
1128 INIT_LIST_HEAD(&itnim
->io_cleanup_q
);
1129 INIT_LIST_HEAD(&itnim
->pending_q
);
1130 INIT_LIST_HEAD(&itnim
->tsk_q
);
1131 INIT_LIST_HEAD(&itnim
->delay_comp_q
);
1132 for (j
= 0; j
< BFA_IOBUCKET_MAX
; j
++)
1133 itnim
->ioprofile
.io_latency
.min
[j
] = ~0;
1134 bfa_sm_set_state(itnim
, bfa_itnim_sm_uninit
);
1137 bfa_mem_kva_curp(fcp
) = (u8
*) itnim
;
1141 bfa_itnim_iocdisable(struct bfa_itnim_s
*itnim
)
1143 bfa_stats(itnim
, ioc_disabled
);
1144 bfa_sm_send_event(itnim
, BFA_ITNIM_SM_HWFAIL
);
1147 static bfa_boolean_t
1148 bfa_itnim_send_fwcreate(struct bfa_itnim_s
*itnim
)
1150 struct bfi_itn_create_req_s
*m
;
1155 * check for room in queue to send request now
1157 m
= bfa_reqq_next(itnim
->bfa
, itnim
->reqq
);
1159 bfa_reqq_wait(itnim
->bfa
, itnim
->reqq
, &itnim
->reqq_wait
);
1163 bfi_h2i_set(m
->mh
, BFI_MC_ITN
, BFI_ITN_H2I_CREATE_REQ
,
1164 bfa_fn_lpu(itnim
->bfa
));
1165 m
->fw_handle
= itnim
->rport
->fw_handle
;
1166 m
->class = FC_CLASS_3
;
1167 m
->seq_rec
= itnim
->seq_rec
;
1168 m
->msg_no
= itnim
->msg_no
;
1169 bfa_stats(itnim
, fw_create
);
1172 * queue I/O message to firmware
1174 bfa_reqq_produce(itnim
->bfa
, itnim
->reqq
, m
->mh
);
1178 static bfa_boolean_t
1179 bfa_itnim_send_fwdelete(struct bfa_itnim_s
*itnim
)
1181 struct bfi_itn_delete_req_s
*m
;
1184 * check for room in queue to send request now
1186 m
= bfa_reqq_next(itnim
->bfa
, itnim
->reqq
);
1188 bfa_reqq_wait(itnim
->bfa
, itnim
->reqq
, &itnim
->reqq_wait
);
1192 bfi_h2i_set(m
->mh
, BFI_MC_ITN
, BFI_ITN_H2I_DELETE_REQ
,
1193 bfa_fn_lpu(itnim
->bfa
));
1194 m
->fw_handle
= itnim
->rport
->fw_handle
;
1195 bfa_stats(itnim
, fw_delete
);
1198 * queue I/O message to firmware
1200 bfa_reqq_produce(itnim
->bfa
, itnim
->reqq
, m
->mh
);
1205 * Cleanup all pending failed inflight requests.
1208 bfa_itnim_delayed_comp(struct bfa_itnim_s
*itnim
, bfa_boolean_t iotov
)
1210 struct bfa_ioim_s
*ioim
;
1211 struct list_head
*qe
, *qen
;
1213 list_for_each_safe(qe
, qen
, &itnim
->delay_comp_q
) {
1214 ioim
= (struct bfa_ioim_s
*)qe
;
1215 bfa_ioim_delayed_comp(ioim
, iotov
);
1220 * Start all pending IO requests.
1223 bfa_itnim_iotov_online(struct bfa_itnim_s
*itnim
)
1225 struct bfa_ioim_s
*ioim
;
1227 bfa_itnim_iotov_stop(itnim
);
1230 * Abort all inflight IO requests in the queue
1232 bfa_itnim_delayed_comp(itnim
, BFA_FALSE
);
1235 * Start all pending IO requests.
1237 while (!list_empty(&itnim
->pending_q
)) {
1238 bfa_q_deq(&itnim
->pending_q
, &ioim
);
1239 list_add_tail(&ioim
->qe
, &itnim
->io_q
);
1240 bfa_ioim_start(ioim
);
1245 * Fail all pending IO requests
1248 bfa_itnim_iotov_cleanup(struct bfa_itnim_s
*itnim
)
1250 struct bfa_ioim_s
*ioim
;
1253 * Fail all inflight IO requests in the queue
1255 bfa_itnim_delayed_comp(itnim
, BFA_TRUE
);
1258 * Fail any pending IO requests.
1260 while (!list_empty(&itnim
->pending_q
)) {
1261 bfa_q_deq(&itnim
->pending_q
, &ioim
);
1262 list_add_tail(&ioim
->qe
, &ioim
->fcpim
->ioim_comp_q
);
1268 * IO TOV timer callback. Fail any pending IO requests.
1271 bfa_itnim_iotov(void *itnim_arg
)
1273 struct bfa_itnim_s
*itnim
= itnim_arg
;
1275 itnim
->iotov_active
= BFA_FALSE
;
1277 bfa_cb_itnim_tov_begin(itnim
->ditn
);
1278 bfa_itnim_iotov_cleanup(itnim
);
1279 bfa_cb_itnim_tov(itnim
->ditn
);
1283 * Start IO TOV timer for failing back pending IO requests in offline state.
1286 bfa_itnim_iotov_start(struct bfa_itnim_s
*itnim
)
1288 if (itnim
->fcpim
->path_tov
> 0) {
1290 itnim
->iotov_active
= BFA_TRUE
;
1291 WARN_ON(!bfa_itnim_hold_io(itnim
));
1292 bfa_timer_start(itnim
->bfa
, &itnim
->timer
,
1293 bfa_itnim_iotov
, itnim
, itnim
->fcpim
->path_tov
);
1298 * Stop IO TOV timer.
1301 bfa_itnim_iotov_stop(struct bfa_itnim_s
*itnim
)
1303 if (itnim
->iotov_active
) {
1304 itnim
->iotov_active
= BFA_FALSE
;
1305 bfa_timer_stop(&itnim
->timer
);
1310 * Stop IO TOV timer.
1313 bfa_itnim_iotov_delete(struct bfa_itnim_s
*itnim
)
1315 bfa_boolean_t pathtov_active
= BFA_FALSE
;
1317 if (itnim
->iotov_active
)
1318 pathtov_active
= BFA_TRUE
;
1320 bfa_itnim_iotov_stop(itnim
);
1322 bfa_cb_itnim_tov_begin(itnim
->ditn
);
1323 bfa_itnim_iotov_cleanup(itnim
);
1325 bfa_cb_itnim_tov(itnim
->ditn
);
1329 bfa_itnim_update_del_itn_stats(struct bfa_itnim_s
*itnim
)
1331 struct bfa_fcpim_s
*fcpim
= BFA_FCPIM(itnim
->bfa
);
1332 fcpim
->del_itn_stats
.del_itn_iocomp_aborted
+=
1333 itnim
->stats
.iocomp_aborted
;
1334 fcpim
->del_itn_stats
.del_itn_iocomp_timedout
+=
1335 itnim
->stats
.iocomp_timedout
;
1336 fcpim
->del_itn_stats
.del_itn_iocom_sqer_needed
+=
1337 itnim
->stats
.iocom_sqer_needed
;
1338 fcpim
->del_itn_stats
.del_itn_iocom_res_free
+=
1339 itnim
->stats
.iocom_res_free
;
1340 fcpim
->del_itn_stats
.del_itn_iocom_hostabrts
+=
1341 itnim
->stats
.iocom_hostabrts
;
1342 fcpim
->del_itn_stats
.del_itn_total_ios
+= itnim
->stats
.total_ios
;
1343 fcpim
->del_itn_stats
.del_io_iocdowns
+= itnim
->stats
.io_iocdowns
;
1344 fcpim
->del_itn_stats
.del_tm_iocdowns
+= itnim
->stats
.tm_iocdowns
;
1352 * Itnim interrupt processing.
1355 bfa_itnim_isr(struct bfa_s
*bfa
, struct bfi_msg_s
*m
)
1357 struct bfa_fcpim_s
*fcpim
= BFA_FCPIM(bfa
);
1358 union bfi_itn_i2h_msg_u msg
;
1359 struct bfa_itnim_s
*itnim
;
1361 bfa_trc(bfa
, m
->mhdr
.msg_id
);
1365 switch (m
->mhdr
.msg_id
) {
1366 case BFI_ITN_I2H_CREATE_RSP
:
1367 itnim
= BFA_ITNIM_FROM_TAG(fcpim
,
1368 msg
.create_rsp
->bfa_handle
);
1369 WARN_ON(msg
.create_rsp
->status
!= BFA_STATUS_OK
);
1370 bfa_stats(itnim
, create_comps
);
1371 bfa_sm_send_event(itnim
, BFA_ITNIM_SM_FWRSP
);
1374 case BFI_ITN_I2H_DELETE_RSP
:
1375 itnim
= BFA_ITNIM_FROM_TAG(fcpim
,
1376 msg
.delete_rsp
->bfa_handle
);
1377 WARN_ON(msg
.delete_rsp
->status
!= BFA_STATUS_OK
);
1378 bfa_stats(itnim
, delete_comps
);
1379 bfa_sm_send_event(itnim
, BFA_ITNIM_SM_FWRSP
);
1382 case BFI_ITN_I2H_SLER_EVENT
:
1383 itnim
= BFA_ITNIM_FROM_TAG(fcpim
,
1384 msg
.sler_event
->bfa_handle
);
1385 bfa_stats(itnim
, sler_events
);
1386 bfa_sm_send_event(itnim
, BFA_ITNIM_SM_SLER
);
1390 bfa_trc(bfa
, m
->mhdr
.msg_id
);
1399 struct bfa_itnim_s
*
1400 bfa_itnim_create(struct bfa_s
*bfa
, struct bfa_rport_s
*rport
, void *ditn
)
1402 struct bfa_fcpim_s
*fcpim
= BFA_FCPIM(bfa
);
1403 struct bfa_itnim_s
*itnim
;
1405 bfa_itn_create(bfa
, rport
, bfa_itnim_isr
);
1407 itnim
= BFA_ITNIM_FROM_TAG(fcpim
, rport
->rport_tag
);
1408 WARN_ON(itnim
->rport
!= rport
);
1412 bfa_stats(itnim
, creates
);
1413 bfa_sm_send_event(itnim
, BFA_ITNIM_SM_CREATE
);
1419 bfa_itnim_delete(struct bfa_itnim_s
*itnim
)
1421 bfa_stats(itnim
, deletes
);
1422 bfa_sm_send_event(itnim
, BFA_ITNIM_SM_DELETE
);
1426 bfa_itnim_online(struct bfa_itnim_s
*itnim
, bfa_boolean_t seq_rec
)
1428 itnim
->seq_rec
= seq_rec
;
1429 bfa_stats(itnim
, onlines
);
1430 bfa_sm_send_event(itnim
, BFA_ITNIM_SM_ONLINE
);
1434 bfa_itnim_offline(struct bfa_itnim_s
*itnim
)
1436 bfa_stats(itnim
, offlines
);
1437 bfa_sm_send_event(itnim
, BFA_ITNIM_SM_OFFLINE
);
1441 * Return true if itnim is considered offline for holding off IO request.
1442 * IO is not held if itnim is being deleted.
1445 bfa_itnim_hold_io(struct bfa_itnim_s
*itnim
)
1447 return itnim
->fcpim
->path_tov
&& itnim
->iotov_active
&&
1448 (bfa_sm_cmp_state(itnim
, bfa_itnim_sm_fwcreate
) ||
1449 bfa_sm_cmp_state(itnim
, bfa_itnim_sm_sler
) ||
1450 bfa_sm_cmp_state(itnim
, bfa_itnim_sm_cleanup_offline
) ||
1451 bfa_sm_cmp_state(itnim
, bfa_itnim_sm_fwdelete
) ||
1452 bfa_sm_cmp_state(itnim
, bfa_itnim_sm_offline
) ||
1453 bfa_sm_cmp_state(itnim
, bfa_itnim_sm_iocdisable
));
1456 #define bfa_io_lat_clock_res_div HZ
1457 #define bfa_io_lat_clock_res_mul 1000
1459 bfa_itnim_get_ioprofile(struct bfa_itnim_s
*itnim
,
1460 struct bfa_itnim_ioprofile_s
*ioprofile
)
1462 struct bfa_fcpim_s
*fcpim
;
1465 return BFA_STATUS_NO_FCPIM_NEXUS
;
1467 fcpim
= BFA_FCPIM(itnim
->bfa
);
1469 if (!fcpim
->io_profile
)
1470 return BFA_STATUS_IOPROFILE_OFF
;
1472 itnim
->ioprofile
.index
= BFA_IOBUCKET_MAX
;
1473 /* unsigned 32-bit time_t overflow here in y2106 */
1474 itnim
->ioprofile
.io_profile_start_time
=
1475 bfa_io_profile_start_time(itnim
->bfa
);
1476 itnim
->ioprofile
.clock_res_mul
= bfa_io_lat_clock_res_mul
;
1477 itnim
->ioprofile
.clock_res_div
= bfa_io_lat_clock_res_div
;
1478 *ioprofile
= itnim
->ioprofile
;
1480 return BFA_STATUS_OK
;
1484 bfa_itnim_clear_stats(struct bfa_itnim_s
*itnim
)
1491 memset(&itnim
->stats
, 0, sizeof(itnim
->stats
));
1492 memset(&itnim
->ioprofile
, 0, sizeof(itnim
->ioprofile
));
1493 for (j
= 0; j
< BFA_IOBUCKET_MAX
; j
++)
1494 itnim
->ioprofile
.io_latency
.min
[j
] = ~0;
1498 * BFA IO module state machine functions
1502 * IO is not started (unallocated).
1505 bfa_ioim_sm_uninit(struct bfa_ioim_s
*ioim
, enum bfa_ioim_event event
)
1508 case BFA_IOIM_SM_START
:
1509 if (!bfa_itnim_is_online(ioim
->itnim
)) {
1510 if (!bfa_itnim_hold_io(ioim
->itnim
)) {
1511 bfa_sm_set_state(ioim
, bfa_ioim_sm_hcb
);
1512 list_del(&ioim
->qe
);
1513 list_add_tail(&ioim
->qe
,
1514 &ioim
->fcpim
->ioim_comp_q
);
1515 bfa_cb_queue(ioim
->bfa
, &ioim
->hcb_qe
,
1516 __bfa_cb_ioim_pathtov
, ioim
);
1518 list_del(&ioim
->qe
);
1519 list_add_tail(&ioim
->qe
,
1520 &ioim
->itnim
->pending_q
);
1525 if (ioim
->nsges
> BFI_SGE_INLINE
) {
1526 if (!bfa_ioim_sgpg_alloc(ioim
)) {
1527 bfa_sm_set_state(ioim
, bfa_ioim_sm_sgalloc
);
1532 if (!bfa_ioim_send_ioreq(ioim
)) {
1533 bfa_sm_set_state(ioim
, bfa_ioim_sm_qfull
);
1537 bfa_sm_set_state(ioim
, bfa_ioim_sm_active
);
1540 case BFA_IOIM_SM_IOTOV
:
1541 bfa_sm_set_state(ioim
, bfa_ioim_sm_hcb
);
1542 bfa_ioim_move_to_comp_q(ioim
);
1543 bfa_cb_queue(ioim
->bfa
, &ioim
->hcb_qe
,
1544 __bfa_cb_ioim_pathtov
, ioim
);
1547 case BFA_IOIM_SM_ABORT
:
1549 * IO in pending queue can get abort requests. Complete abort
1550 * requests immediately.
1552 bfa_sm_set_state(ioim
, bfa_ioim_sm_hcb
);
1553 WARN_ON(!bfa_q_is_on_q(&ioim
->itnim
->pending_q
, ioim
));
1554 bfa_cb_queue(ioim
->bfa
, &ioim
->hcb_qe
,
1555 __bfa_cb_ioim_abort
, ioim
);
1559 bfa_sm_fault(ioim
->bfa
, event
);
1564 * IO is waiting for SG pages.
1567 bfa_ioim_sm_sgalloc(struct bfa_ioim_s
*ioim
, enum bfa_ioim_event event
)
1569 bfa_trc(ioim
->bfa
, ioim
->iotag
);
1570 bfa_trc(ioim
->bfa
, event
);
1573 case BFA_IOIM_SM_SGALLOCED
:
1574 if (!bfa_ioim_send_ioreq(ioim
)) {
1575 bfa_sm_set_state(ioim
, bfa_ioim_sm_qfull
);
1578 bfa_sm_set_state(ioim
, bfa_ioim_sm_active
);
1581 case BFA_IOIM_SM_CLEANUP
:
1582 bfa_sm_set_state(ioim
, bfa_ioim_sm_hcb
);
1583 bfa_sgpg_wcancel(ioim
->bfa
, &ioim
->iosp
->sgpg_wqe
);
1584 bfa_cb_queue(ioim
->bfa
, &ioim
->hcb_qe
, __bfa_cb_ioim_failed
,
1586 bfa_ioim_notify_cleanup(ioim
);
1589 case BFA_IOIM_SM_ABORT
:
1590 bfa_sm_set_state(ioim
, bfa_ioim_sm_hcb
);
1591 bfa_sgpg_wcancel(ioim
->bfa
, &ioim
->iosp
->sgpg_wqe
);
1592 bfa_ioim_move_to_comp_q(ioim
);
1593 bfa_cb_queue(ioim
->bfa
, &ioim
->hcb_qe
, __bfa_cb_ioim_abort
,
1597 case BFA_IOIM_SM_HWFAIL
:
1598 bfa_sm_set_state(ioim
, bfa_ioim_sm_hcb
);
1599 bfa_sgpg_wcancel(ioim
->bfa
, &ioim
->iosp
->sgpg_wqe
);
1600 bfa_ioim_move_to_comp_q(ioim
);
1601 bfa_cb_queue(ioim
->bfa
, &ioim
->hcb_qe
, __bfa_cb_ioim_failed
,
1606 bfa_sm_fault(ioim
->bfa
, event
);
1614 bfa_ioim_sm_active(struct bfa_ioim_s
*ioim
, enum bfa_ioim_event event
)
1617 case BFA_IOIM_SM_COMP_GOOD
:
1618 bfa_sm_set_state(ioim
, bfa_ioim_sm_hcb
);
1619 bfa_ioim_move_to_comp_q(ioim
);
1620 bfa_cb_queue(ioim
->bfa
, &ioim
->hcb_qe
,
1621 __bfa_cb_ioim_good_comp
, ioim
);
1624 case BFA_IOIM_SM_COMP
:
1625 bfa_sm_set_state(ioim
, bfa_ioim_sm_hcb
);
1626 bfa_ioim_move_to_comp_q(ioim
);
1627 bfa_cb_queue(ioim
->bfa
, &ioim
->hcb_qe
, __bfa_cb_ioim_comp
,
1631 case BFA_IOIM_SM_DONE
:
1632 bfa_sm_set_state(ioim
, bfa_ioim_sm_hcb_free
);
1633 bfa_ioim_move_to_comp_q(ioim
);
1634 bfa_cb_queue(ioim
->bfa
, &ioim
->hcb_qe
, __bfa_cb_ioim_comp
,
1638 case BFA_IOIM_SM_ABORT
:
1639 ioim
->iosp
->abort_explicit
= BFA_TRUE
;
1640 ioim
->io_cbfn
= __bfa_cb_ioim_abort
;
1642 if (bfa_ioim_send_abort(ioim
))
1643 bfa_sm_set_state(ioim
, bfa_ioim_sm_abort
);
1645 bfa_sm_set_state(ioim
, bfa_ioim_sm_abort_qfull
);
1646 bfa_stats(ioim
->itnim
, qwait
);
1647 bfa_reqq_wait(ioim
->bfa
, ioim
->reqq
,
1648 &ioim
->iosp
->reqq_wait
);
1652 case BFA_IOIM_SM_CLEANUP
:
1653 ioim
->iosp
->abort_explicit
= BFA_FALSE
;
1654 ioim
->io_cbfn
= __bfa_cb_ioim_failed
;
1656 if (bfa_ioim_send_abort(ioim
))
1657 bfa_sm_set_state(ioim
, bfa_ioim_sm_cleanup
);
1659 bfa_sm_set_state(ioim
, bfa_ioim_sm_cleanup_qfull
);
1660 bfa_stats(ioim
->itnim
, qwait
);
1661 bfa_reqq_wait(ioim
->bfa
, ioim
->reqq
,
1662 &ioim
->iosp
->reqq_wait
);
1666 case BFA_IOIM_SM_HWFAIL
:
1667 bfa_sm_set_state(ioim
, bfa_ioim_sm_hcb
);
1668 bfa_ioim_move_to_comp_q(ioim
);
1669 bfa_cb_queue(ioim
->bfa
, &ioim
->hcb_qe
, __bfa_cb_ioim_failed
,
1673 case BFA_IOIM_SM_SQRETRY
:
1674 if (bfa_ioim_maxretry_reached(ioim
)) {
1675 /* max retry reached, free IO */
1676 bfa_sm_set_state(ioim
, bfa_ioim_sm_hcb_free
);
1677 bfa_ioim_move_to_comp_q(ioim
);
1678 bfa_cb_queue(ioim
->bfa
, &ioim
->hcb_qe
,
1679 __bfa_cb_ioim_failed
, ioim
);
1682 /* waiting for IO tag resource free */
1683 bfa_sm_set_state(ioim
, bfa_ioim_sm_cmnd_retry
);
1687 bfa_sm_fault(ioim
->bfa
, event
);
1692 * IO is retried with new tag.
1695 bfa_ioim_sm_cmnd_retry(struct bfa_ioim_s
*ioim
, enum bfa_ioim_event event
)
1698 case BFA_IOIM_SM_FREE
:
1699 /* abts and rrq done. Now retry the IO with new tag */
1700 bfa_ioim_update_iotag(ioim
);
1701 if (!bfa_ioim_send_ioreq(ioim
)) {
1702 bfa_sm_set_state(ioim
, bfa_ioim_sm_qfull
);
1705 bfa_sm_set_state(ioim
, bfa_ioim_sm_active
);
1708 case BFA_IOIM_SM_CLEANUP
:
1709 ioim
->iosp
->abort_explicit
= BFA_FALSE
;
1710 ioim
->io_cbfn
= __bfa_cb_ioim_failed
;
1712 if (bfa_ioim_send_abort(ioim
))
1713 bfa_sm_set_state(ioim
, bfa_ioim_sm_cleanup
);
1715 bfa_sm_set_state(ioim
, bfa_ioim_sm_cleanup_qfull
);
1716 bfa_stats(ioim
->itnim
, qwait
);
1717 bfa_reqq_wait(ioim
->bfa
, ioim
->reqq
,
1718 &ioim
->iosp
->reqq_wait
);
1722 case BFA_IOIM_SM_HWFAIL
:
1723 bfa_sm_set_state(ioim
, bfa_ioim_sm_hcb
);
1724 bfa_ioim_move_to_comp_q(ioim
);
1725 bfa_cb_queue(ioim
->bfa
, &ioim
->hcb_qe
,
1726 __bfa_cb_ioim_failed
, ioim
);
1729 case BFA_IOIM_SM_ABORT
:
1730 /* in this state IO abort is done.
1731 * Waiting for IO tag resource free.
1733 bfa_sm_set_state(ioim
, bfa_ioim_sm_hcb_free
);
1734 bfa_cb_queue(ioim
->bfa
, &ioim
->hcb_qe
, __bfa_cb_ioim_abort
,
1739 bfa_sm_fault(ioim
->bfa
, event
);
1744 * IO is being aborted, waiting for completion from firmware.
1747 bfa_ioim_sm_abort(struct bfa_ioim_s
*ioim
, enum bfa_ioim_event event
)
1749 bfa_trc(ioim
->bfa
, ioim
->iotag
);
1750 bfa_trc(ioim
->bfa
, event
);
1753 case BFA_IOIM_SM_COMP_GOOD
:
1754 case BFA_IOIM_SM_COMP
:
1755 case BFA_IOIM_SM_DONE
:
1756 case BFA_IOIM_SM_FREE
:
1759 case BFA_IOIM_SM_ABORT_DONE
:
1760 bfa_sm_set_state(ioim
, bfa_ioim_sm_hcb_free
);
1761 bfa_cb_queue(ioim
->bfa
, &ioim
->hcb_qe
, __bfa_cb_ioim_abort
,
1765 case BFA_IOIM_SM_ABORT_COMP
:
1766 bfa_sm_set_state(ioim
, bfa_ioim_sm_hcb
);
1767 bfa_ioim_move_to_comp_q(ioim
);
1768 bfa_cb_queue(ioim
->bfa
, &ioim
->hcb_qe
, __bfa_cb_ioim_abort
,
1772 case BFA_IOIM_SM_COMP_UTAG
:
1773 bfa_sm_set_state(ioim
, bfa_ioim_sm_hcb
);
1774 bfa_ioim_move_to_comp_q(ioim
);
1775 bfa_cb_queue(ioim
->bfa
, &ioim
->hcb_qe
, __bfa_cb_ioim_abort
,
1779 case BFA_IOIM_SM_CLEANUP
:
1780 WARN_ON(ioim
->iosp
->abort_explicit
!= BFA_TRUE
);
1781 ioim
->iosp
->abort_explicit
= BFA_FALSE
;
1783 if (bfa_ioim_send_abort(ioim
))
1784 bfa_sm_set_state(ioim
, bfa_ioim_sm_cleanup
);
1786 bfa_sm_set_state(ioim
, bfa_ioim_sm_cleanup_qfull
);
1787 bfa_stats(ioim
->itnim
, qwait
);
1788 bfa_reqq_wait(ioim
->bfa
, ioim
->reqq
,
1789 &ioim
->iosp
->reqq_wait
);
1793 case BFA_IOIM_SM_HWFAIL
:
1794 bfa_sm_set_state(ioim
, bfa_ioim_sm_hcb
);
1795 bfa_ioim_move_to_comp_q(ioim
);
1796 bfa_cb_queue(ioim
->bfa
, &ioim
->hcb_qe
, __bfa_cb_ioim_failed
,
1801 bfa_sm_fault(ioim
->bfa
, event
);
1806 * IO is being cleaned up (implicit abort), waiting for completion from
1810 bfa_ioim_sm_cleanup(struct bfa_ioim_s
*ioim
, enum bfa_ioim_event event
)
1812 bfa_trc(ioim
->bfa
, ioim
->iotag
);
1813 bfa_trc(ioim
->bfa
, event
);
1816 case BFA_IOIM_SM_COMP_GOOD
:
1817 case BFA_IOIM_SM_COMP
:
1818 case BFA_IOIM_SM_DONE
:
1819 case BFA_IOIM_SM_FREE
:
1822 case BFA_IOIM_SM_ABORT
:
1824 * IO is already being aborted implicitly
1826 ioim
->io_cbfn
= __bfa_cb_ioim_abort
;
1829 case BFA_IOIM_SM_ABORT_DONE
:
1830 bfa_sm_set_state(ioim
, bfa_ioim_sm_hcb_free
);
1831 bfa_cb_queue(ioim
->bfa
, &ioim
->hcb_qe
, ioim
->io_cbfn
, ioim
);
1832 bfa_ioim_notify_cleanup(ioim
);
1835 case BFA_IOIM_SM_ABORT_COMP
:
1836 bfa_sm_set_state(ioim
, bfa_ioim_sm_hcb
);
1837 bfa_cb_queue(ioim
->bfa
, &ioim
->hcb_qe
, ioim
->io_cbfn
, ioim
);
1838 bfa_ioim_notify_cleanup(ioim
);
1841 case BFA_IOIM_SM_COMP_UTAG
:
1842 bfa_sm_set_state(ioim
, bfa_ioim_sm_hcb
);
1843 bfa_cb_queue(ioim
->bfa
, &ioim
->hcb_qe
, ioim
->io_cbfn
, ioim
);
1844 bfa_ioim_notify_cleanup(ioim
);
1847 case BFA_IOIM_SM_HWFAIL
:
1848 bfa_sm_set_state(ioim
, bfa_ioim_sm_hcb
);
1849 bfa_ioim_move_to_comp_q(ioim
);
1850 bfa_cb_queue(ioim
->bfa
, &ioim
->hcb_qe
, __bfa_cb_ioim_failed
,
1854 case BFA_IOIM_SM_CLEANUP
:
1856 * IO can be in cleanup state already due to TM command.
1857 * 2nd cleanup request comes from ITN offline event.
1862 bfa_sm_fault(ioim
->bfa
, event
);
1867 * IO is waiting for room in request CQ
1870 bfa_ioim_sm_qfull(struct bfa_ioim_s
*ioim
, enum bfa_ioim_event event
)
1872 bfa_trc(ioim
->bfa
, ioim
->iotag
);
1873 bfa_trc(ioim
->bfa
, event
);
1876 case BFA_IOIM_SM_QRESUME
:
1877 bfa_sm_set_state(ioim
, bfa_ioim_sm_active
);
1878 bfa_ioim_send_ioreq(ioim
);
1881 case BFA_IOIM_SM_ABORT
:
1882 bfa_sm_set_state(ioim
, bfa_ioim_sm_hcb
);
1883 bfa_reqq_wcancel(&ioim
->iosp
->reqq_wait
);
1884 bfa_ioim_move_to_comp_q(ioim
);
1885 bfa_cb_queue(ioim
->bfa
, &ioim
->hcb_qe
, __bfa_cb_ioim_abort
,
1889 case BFA_IOIM_SM_CLEANUP
:
1890 bfa_sm_set_state(ioim
, bfa_ioim_sm_hcb
);
1891 bfa_reqq_wcancel(&ioim
->iosp
->reqq_wait
);
1892 bfa_cb_queue(ioim
->bfa
, &ioim
->hcb_qe
, __bfa_cb_ioim_failed
,
1894 bfa_ioim_notify_cleanup(ioim
);
1897 case BFA_IOIM_SM_HWFAIL
:
1898 bfa_sm_set_state(ioim
, bfa_ioim_sm_hcb
);
1899 bfa_reqq_wcancel(&ioim
->iosp
->reqq_wait
);
1900 bfa_ioim_move_to_comp_q(ioim
);
1901 bfa_cb_queue(ioim
->bfa
, &ioim
->hcb_qe
, __bfa_cb_ioim_failed
,
1906 bfa_sm_fault(ioim
->bfa
, event
);
1911 * Active IO is being aborted, waiting for room in request CQ.
1914 bfa_ioim_sm_abort_qfull(struct bfa_ioim_s
*ioim
, enum bfa_ioim_event event
)
1916 bfa_trc(ioim
->bfa
, ioim
->iotag
);
1917 bfa_trc(ioim
->bfa
, event
);
1920 case BFA_IOIM_SM_QRESUME
:
1921 bfa_sm_set_state(ioim
, bfa_ioim_sm_abort
);
1922 bfa_ioim_send_abort(ioim
);
1925 case BFA_IOIM_SM_CLEANUP
:
1926 WARN_ON(ioim
->iosp
->abort_explicit
!= BFA_TRUE
);
1927 ioim
->iosp
->abort_explicit
= BFA_FALSE
;
1928 bfa_sm_set_state(ioim
, bfa_ioim_sm_cleanup_qfull
);
1931 case BFA_IOIM_SM_COMP_GOOD
:
1932 case BFA_IOIM_SM_COMP
:
1933 bfa_sm_set_state(ioim
, bfa_ioim_sm_hcb
);
1934 bfa_reqq_wcancel(&ioim
->iosp
->reqq_wait
);
1935 bfa_ioim_move_to_comp_q(ioim
);
1936 bfa_cb_queue(ioim
->bfa
, &ioim
->hcb_qe
, __bfa_cb_ioim_abort
,
1940 case BFA_IOIM_SM_DONE
:
1941 bfa_sm_set_state(ioim
, bfa_ioim_sm_hcb_free
);
1942 bfa_reqq_wcancel(&ioim
->iosp
->reqq_wait
);
1943 bfa_ioim_move_to_comp_q(ioim
);
1944 bfa_cb_queue(ioim
->bfa
, &ioim
->hcb_qe
, __bfa_cb_ioim_abort
,
1948 case BFA_IOIM_SM_HWFAIL
:
1949 bfa_sm_set_state(ioim
, bfa_ioim_sm_hcb
);
1950 bfa_reqq_wcancel(&ioim
->iosp
->reqq_wait
);
1951 bfa_ioim_move_to_comp_q(ioim
);
1952 bfa_cb_queue(ioim
->bfa
, &ioim
->hcb_qe
, __bfa_cb_ioim_failed
,
1957 bfa_sm_fault(ioim
->bfa
, event
);
1962 * Active IO is being cleaned up, waiting for room in request CQ.
1965 bfa_ioim_sm_cleanup_qfull(struct bfa_ioim_s
*ioim
, enum bfa_ioim_event event
)
1967 bfa_trc(ioim
->bfa
, ioim
->iotag
);
1968 bfa_trc(ioim
->bfa
, event
);
1971 case BFA_IOIM_SM_QRESUME
:
1972 bfa_sm_set_state(ioim
, bfa_ioim_sm_cleanup
);
1973 bfa_ioim_send_abort(ioim
);
1976 case BFA_IOIM_SM_ABORT
:
1978 * IO is already being cleaned up implicitly
1980 ioim
->io_cbfn
= __bfa_cb_ioim_abort
;
1983 case BFA_IOIM_SM_COMP_GOOD
:
1984 case BFA_IOIM_SM_COMP
:
1985 bfa_sm_set_state(ioim
, bfa_ioim_sm_hcb
);
1986 bfa_reqq_wcancel(&ioim
->iosp
->reqq_wait
);
1987 bfa_cb_queue(ioim
->bfa
, &ioim
->hcb_qe
, ioim
->io_cbfn
, ioim
);
1988 bfa_ioim_notify_cleanup(ioim
);
1991 case BFA_IOIM_SM_DONE
:
1992 bfa_sm_set_state(ioim
, bfa_ioim_sm_hcb_free
);
1993 bfa_reqq_wcancel(&ioim
->iosp
->reqq_wait
);
1994 bfa_cb_queue(ioim
->bfa
, &ioim
->hcb_qe
, ioim
->io_cbfn
, ioim
);
1995 bfa_ioim_notify_cleanup(ioim
);
1998 case BFA_IOIM_SM_HWFAIL
:
1999 bfa_sm_set_state(ioim
, bfa_ioim_sm_hcb
);
2000 bfa_reqq_wcancel(&ioim
->iosp
->reqq_wait
);
2001 bfa_ioim_move_to_comp_q(ioim
);
2002 bfa_cb_queue(ioim
->bfa
, &ioim
->hcb_qe
, __bfa_cb_ioim_failed
,
2007 bfa_sm_fault(ioim
->bfa
, event
);
2012 * IO bfa callback is pending.
2015 bfa_ioim_sm_hcb(struct bfa_ioim_s
*ioim
, enum bfa_ioim_event event
)
2018 case BFA_IOIM_SM_HCB
:
2019 bfa_sm_set_state(ioim
, bfa_ioim_sm_uninit
);
2020 bfa_ioim_free(ioim
);
2023 case BFA_IOIM_SM_CLEANUP
:
2024 bfa_ioim_notify_cleanup(ioim
);
2027 case BFA_IOIM_SM_HWFAIL
:
2031 bfa_sm_fault(ioim
->bfa
, event
);
2036 * IO bfa callback is pending. IO resource cannot be freed.
2039 bfa_ioim_sm_hcb_free(struct bfa_ioim_s
*ioim
, enum bfa_ioim_event event
)
2041 bfa_trc(ioim
->bfa
, ioim
->iotag
);
2042 bfa_trc(ioim
->bfa
, event
);
2045 case BFA_IOIM_SM_HCB
:
2046 bfa_sm_set_state(ioim
, bfa_ioim_sm_resfree
);
2047 list_del(&ioim
->qe
);
2048 list_add_tail(&ioim
->qe
, &ioim
->fcpim
->ioim_resfree_q
);
2051 case BFA_IOIM_SM_FREE
:
2052 bfa_sm_set_state(ioim
, bfa_ioim_sm_hcb
);
2055 case BFA_IOIM_SM_CLEANUP
:
2056 bfa_ioim_notify_cleanup(ioim
);
2059 case BFA_IOIM_SM_HWFAIL
:
2060 bfa_sm_set_state(ioim
, bfa_ioim_sm_hcb
);
2064 bfa_sm_fault(ioim
->bfa
, event
);
2069 * IO is completed, waiting resource free from firmware.
2072 bfa_ioim_sm_resfree(struct bfa_ioim_s
*ioim
, enum bfa_ioim_event event
)
2074 bfa_trc(ioim
->bfa
, ioim
->iotag
);
2075 bfa_trc(ioim
->bfa
, event
);
2078 case BFA_IOIM_SM_FREE
:
2079 bfa_sm_set_state(ioim
, bfa_ioim_sm_uninit
);
2080 bfa_ioim_free(ioim
);
2083 case BFA_IOIM_SM_CLEANUP
:
2084 bfa_ioim_notify_cleanup(ioim
);
2087 case BFA_IOIM_SM_HWFAIL
:
2091 bfa_sm_fault(ioim
->bfa
, event
);
2096 * This is called from bfa_fcpim_start after the bfa_init() with flash read
2097 * is complete by driver. now invalidate the stale content of lun mask
2098 * like unit attention, rp tag and lp tag.
2101 bfa_ioim_lm_init(struct bfa_s
*bfa
)
2103 struct bfa_lun_mask_s
*lunm_list
;
2106 if (bfa_get_lun_mask_status(bfa
) == BFA_LUNMASK_MINCFG
)
2109 lunm_list
= bfa_get_lun_mask_list(bfa
);
2110 for (i
= 0; i
< MAX_LUN_MASK_CFG
; i
++) {
2111 lunm_list
[i
].ua
= BFA_IOIM_LM_UA_RESET
;
2112 lunm_list
[i
].lp_tag
= BFA_LP_TAG_INVALID
;
2113 lunm_list
[i
].rp_tag
= BFA_RPORT_TAG_INVALID
;
2118 __bfa_cb_ioim_good_comp(void *cbarg
, bfa_boolean_t complete
)
2120 struct bfa_ioim_s
*ioim
= cbarg
;
2123 bfa_sm_send_event(ioim
, BFA_IOIM_SM_HCB
);
2127 bfa_cb_ioim_good_comp(ioim
->bfa
->bfad
, ioim
->dio
);
2131 __bfa_cb_ioim_comp(void *cbarg
, bfa_boolean_t complete
)
2133 struct bfa_ioim_s
*ioim
= cbarg
;
2134 struct bfi_ioim_rsp_s
*m
;
2140 bfa_sm_send_event(ioim
, BFA_IOIM_SM_HCB
);
2144 m
= (struct bfi_ioim_rsp_s
*) &ioim
->iosp
->comp_rspmsg
;
2145 if (m
->io_status
== BFI_IOIM_STS_OK
) {
2147 * setup sense information, if present
2149 if ((m
->scsi_status
== SCSI_STATUS_CHECK_CONDITION
) &&
2151 sns_len
= m
->sns_len
;
2152 snsinfo
= BFA_SNSINFO_FROM_TAG(ioim
->fcpim
->fcp
,
2157 * setup residue value correctly for normal completions
2159 if (m
->resid_flags
== FCP_RESID_UNDER
) {
2160 residue
= be32_to_cpu(m
->residue
);
2161 bfa_stats(ioim
->itnim
, iocomp_underrun
);
2163 if (m
->resid_flags
== FCP_RESID_OVER
) {
2164 residue
= be32_to_cpu(m
->residue
);
2166 bfa_stats(ioim
->itnim
, iocomp_overrun
);
2170 bfa_cb_ioim_done(ioim
->bfa
->bfad
, ioim
->dio
, m
->io_status
,
2171 m
->scsi_status
, sns_len
, snsinfo
, residue
);
2175 bfa_fcpim_lunmask_rp_update(struct bfa_s
*bfa
, wwn_t lp_wwn
, wwn_t rp_wwn
,
2176 u16 rp_tag
, u8 lp_tag
)
2178 struct bfa_lun_mask_s
*lun_list
;
2181 if (bfa_get_lun_mask_status(bfa
) == BFA_LUNMASK_MINCFG
)
2184 lun_list
= bfa_get_lun_mask_list(bfa
);
2185 for (i
= 0; i
< MAX_LUN_MASK_CFG
; i
++) {
2186 if (lun_list
[i
].state
== BFA_IOIM_LUN_MASK_ACTIVE
) {
2187 if ((lun_list
[i
].lp_wwn
== lp_wwn
) &&
2188 (lun_list
[i
].rp_wwn
== rp_wwn
)) {
2189 lun_list
[i
].rp_tag
= rp_tag
;
2190 lun_list
[i
].lp_tag
= lp_tag
;
2197 * set UA for all active luns in LM DB
2200 bfa_ioim_lm_set_ua(struct bfa_s
*bfa
)
2202 struct bfa_lun_mask_s
*lunm_list
;
2205 lunm_list
= bfa_get_lun_mask_list(bfa
);
2206 for (i
= 0; i
< MAX_LUN_MASK_CFG
; i
++) {
2207 if (lunm_list
[i
].state
!= BFA_IOIM_LUN_MASK_ACTIVE
)
2209 lunm_list
[i
].ua
= BFA_IOIM_LM_UA_SET
;
2214 bfa_fcpim_lunmask_update(struct bfa_s
*bfa
, u32 update
)
2216 struct bfa_lunmask_cfg_s
*lun_mask
;
2218 bfa_trc(bfa
, bfa_get_lun_mask_status(bfa
));
2219 if (bfa_get_lun_mask_status(bfa
) == BFA_LUNMASK_MINCFG
)
2220 return BFA_STATUS_FAILED
;
2222 if (bfa_get_lun_mask_status(bfa
) == update
)
2223 return BFA_STATUS_NO_CHANGE
;
2225 lun_mask
= bfa_get_lun_mask(bfa
);
2226 lun_mask
->status
= update
;
2228 if (bfa_get_lun_mask_status(bfa
) == BFA_LUNMASK_ENABLED
)
2229 bfa_ioim_lm_set_ua(bfa
);
2231 return bfa_dconf_update(bfa
);
2235 bfa_fcpim_lunmask_clear(struct bfa_s
*bfa
)
2238 struct bfa_lun_mask_s
*lunm_list
;
2240 bfa_trc(bfa
, bfa_get_lun_mask_status(bfa
));
2241 if (bfa_get_lun_mask_status(bfa
) == BFA_LUNMASK_MINCFG
)
2242 return BFA_STATUS_FAILED
;
2244 lunm_list
= bfa_get_lun_mask_list(bfa
);
2245 for (i
= 0; i
< MAX_LUN_MASK_CFG
; i
++) {
2246 if (lunm_list
[i
].state
== BFA_IOIM_LUN_MASK_ACTIVE
) {
2247 if (lunm_list
[i
].rp_tag
!= BFA_RPORT_TAG_INVALID
)
2248 bfa_rport_unset_lunmask(bfa
,
2249 BFA_RPORT_FROM_TAG(bfa
, lunm_list
[i
].rp_tag
));
2253 memset(lunm_list
, 0, sizeof(struct bfa_lun_mask_s
) * MAX_LUN_MASK_CFG
);
2254 return bfa_dconf_update(bfa
);
2258 bfa_fcpim_lunmask_query(struct bfa_s
*bfa
, void *buf
)
2260 struct bfa_lunmask_cfg_s
*lun_mask
;
2262 bfa_trc(bfa
, bfa_get_lun_mask_status(bfa
));
2263 if (bfa_get_lun_mask_status(bfa
) == BFA_LUNMASK_MINCFG
)
2264 return BFA_STATUS_FAILED
;
2266 lun_mask
= bfa_get_lun_mask(bfa
);
2267 memcpy(buf
, lun_mask
, sizeof(struct bfa_lunmask_cfg_s
));
2268 return BFA_STATUS_OK
;
2272 bfa_fcpim_lunmask_add(struct bfa_s
*bfa
, u16 vf_id
, wwn_t
*pwwn
,
2273 wwn_t rpwwn
, struct scsi_lun lun
)
2275 struct bfa_lun_mask_s
*lunm_list
;
2276 struct bfa_rport_s
*rp
= NULL
;
2277 int i
, free_index
= MAX_LUN_MASK_CFG
+ 1;
2278 struct bfa_fcs_lport_s
*port
= NULL
;
2279 struct bfa_fcs_rport_s
*rp_fcs
;
2281 bfa_trc(bfa
, bfa_get_lun_mask_status(bfa
));
2282 if (bfa_get_lun_mask_status(bfa
) == BFA_LUNMASK_MINCFG
)
2283 return BFA_STATUS_FAILED
;
2285 port
= bfa_fcs_lookup_port(&((struct bfad_s
*)bfa
->bfad
)->bfa_fcs
,
2288 *pwwn
= port
->port_cfg
.pwwn
;
2289 rp_fcs
= bfa_fcs_lport_get_rport_by_pwwn(port
, rpwwn
);
2291 rp
= rp_fcs
->bfa_rport
;
2294 lunm_list
= bfa_get_lun_mask_list(bfa
);
2295 /* if entry exists */
2296 for (i
= 0; i
< MAX_LUN_MASK_CFG
; i
++) {
2297 if (lunm_list
[i
].state
!= BFA_IOIM_LUN_MASK_ACTIVE
)
2299 if ((lunm_list
[i
].lp_wwn
== *pwwn
) &&
2300 (lunm_list
[i
].rp_wwn
== rpwwn
) &&
2301 (scsilun_to_int((struct scsi_lun
*)&lunm_list
[i
].lun
) ==
2302 scsilun_to_int((struct scsi_lun
*)&lun
)))
2303 return BFA_STATUS_ENTRY_EXISTS
;
2306 if (free_index
> MAX_LUN_MASK_CFG
)
2307 return BFA_STATUS_MAX_ENTRY_REACHED
;
2310 lunm_list
[free_index
].lp_tag
= bfa_lps_get_tag_from_pid(bfa
,
2311 rp
->rport_info
.local_pid
);
2312 lunm_list
[free_index
].rp_tag
= rp
->rport_tag
;
2314 lunm_list
[free_index
].lp_tag
= BFA_LP_TAG_INVALID
;
2315 lunm_list
[free_index
].rp_tag
= BFA_RPORT_TAG_INVALID
;
2318 lunm_list
[free_index
].lp_wwn
= *pwwn
;
2319 lunm_list
[free_index
].rp_wwn
= rpwwn
;
2320 lunm_list
[free_index
].lun
= lun
;
2321 lunm_list
[free_index
].state
= BFA_IOIM_LUN_MASK_ACTIVE
;
2323 /* set for all luns in this rp */
2324 for (i
= 0; i
< MAX_LUN_MASK_CFG
; i
++) {
2325 if ((lunm_list
[i
].lp_wwn
== *pwwn
) &&
2326 (lunm_list
[i
].rp_wwn
== rpwwn
))
2327 lunm_list
[i
].ua
= BFA_IOIM_LM_UA_SET
;
2330 return bfa_dconf_update(bfa
);
2334 bfa_fcpim_lunmask_delete(struct bfa_s
*bfa
, u16 vf_id
, wwn_t
*pwwn
,
2335 wwn_t rpwwn
, struct scsi_lun lun
)
2337 struct bfa_lun_mask_s
*lunm_list
;
2338 struct bfa_rport_s
*rp
= NULL
;
2339 struct bfa_fcs_lport_s
*port
= NULL
;
2340 struct bfa_fcs_rport_s
*rp_fcs
;
2343 /* in min cfg lunm_list could be NULL but no commands should run. */
2344 if (bfa_get_lun_mask_status(bfa
) == BFA_LUNMASK_MINCFG
)
2345 return BFA_STATUS_FAILED
;
2347 bfa_trc(bfa
, bfa_get_lun_mask_status(bfa
));
2348 bfa_trc(bfa
, *pwwn
);
2349 bfa_trc(bfa
, rpwwn
);
2350 bfa_trc(bfa
, scsilun_to_int((struct scsi_lun
*)&lun
));
2353 port
= bfa_fcs_lookup_port(
2354 &((struct bfad_s
*)bfa
->bfad
)->bfa_fcs
,
2357 *pwwn
= port
->port_cfg
.pwwn
;
2358 rp_fcs
= bfa_fcs_lport_get_rport_by_pwwn(port
, rpwwn
);
2360 rp
= rp_fcs
->bfa_rport
;
2364 lunm_list
= bfa_get_lun_mask_list(bfa
);
2365 for (i
= 0; i
< MAX_LUN_MASK_CFG
; i
++) {
2366 if ((lunm_list
[i
].lp_wwn
== *pwwn
) &&
2367 (lunm_list
[i
].rp_wwn
== rpwwn
) &&
2368 (scsilun_to_int((struct scsi_lun
*)&lunm_list
[i
].lun
) ==
2369 scsilun_to_int((struct scsi_lun
*)&lun
))) {
2370 lunm_list
[i
].lp_wwn
= 0;
2371 lunm_list
[i
].rp_wwn
= 0;
2372 int_to_scsilun(0, &lunm_list
[i
].lun
);
2373 lunm_list
[i
].state
= BFA_IOIM_LUN_MASK_INACTIVE
;
2374 if (lunm_list
[i
].rp_tag
!= BFA_RPORT_TAG_INVALID
) {
2375 lunm_list
[i
].rp_tag
= BFA_RPORT_TAG_INVALID
;
2376 lunm_list
[i
].lp_tag
= BFA_LP_TAG_INVALID
;
2378 return bfa_dconf_update(bfa
);
2382 /* set for all luns in this rp */
2383 for (i
= 0; i
< MAX_LUN_MASK_CFG
; i
++) {
2384 if ((lunm_list
[i
].lp_wwn
== *pwwn
) &&
2385 (lunm_list
[i
].rp_wwn
== rpwwn
))
2386 lunm_list
[i
].ua
= BFA_IOIM_LM_UA_SET
;
2389 return BFA_STATUS_ENTRY_NOT_EXISTS
;
2393 __bfa_cb_ioim_failed(void *cbarg
, bfa_boolean_t complete
)
2395 struct bfa_ioim_s
*ioim
= cbarg
;
2398 bfa_sm_send_event(ioim
, BFA_IOIM_SM_HCB
);
2402 bfa_cb_ioim_done(ioim
->bfa
->bfad
, ioim
->dio
, BFI_IOIM_STS_ABORTED
,
2407 __bfa_cb_ioim_pathtov(void *cbarg
, bfa_boolean_t complete
)
2409 struct bfa_ioim_s
*ioim
= cbarg
;
2411 bfa_stats(ioim
->itnim
, path_tov_expired
);
2413 bfa_sm_send_event(ioim
, BFA_IOIM_SM_HCB
);
2417 bfa_cb_ioim_done(ioim
->bfa
->bfad
, ioim
->dio
, BFI_IOIM_STS_PATHTOV
,
2422 __bfa_cb_ioim_abort(void *cbarg
, bfa_boolean_t complete
)
2424 struct bfa_ioim_s
*ioim
= cbarg
;
2427 bfa_sm_send_event(ioim
, BFA_IOIM_SM_HCB
);
2431 bfa_cb_ioim_abort(ioim
->bfa
->bfad
, ioim
->dio
);
2435 bfa_ioim_sgpg_alloced(void *cbarg
)
2437 struct bfa_ioim_s
*ioim
= cbarg
;
2439 ioim
->nsgpgs
= BFA_SGPG_NPAGE(ioim
->nsges
);
2440 list_splice_tail_init(&ioim
->iosp
->sgpg_wqe
.sgpg_q
, &ioim
->sgpg_q
);
2441 ioim
->sgpg
= bfa_q_first(&ioim
->sgpg_q
);
2442 bfa_sm_send_event(ioim
, BFA_IOIM_SM_SGALLOCED
);
2446 * Send I/O request to firmware.
2448 static bfa_boolean_t
2449 bfa_ioim_send_ioreq(struct bfa_ioim_s
*ioim
)
2451 struct bfa_itnim_s
*itnim
= ioim
->itnim
;
2452 struct bfi_ioim_req_s
*m
;
2453 static struct fcp_cmnd_s cmnd_z0
= { { { 0 } } };
2454 struct bfi_sge_s
*sge
, *sgpge
;
2458 struct scatterlist
*sg
;
2459 struct bfa_sgpg_s
*sgpg
;
2460 struct scsi_cmnd
*cmnd
= (struct scsi_cmnd
*) ioim
->dio
;
2461 u32 i
, sge_id
, pgcumsz
;
2462 enum dma_data_direction dmadir
;
2465 * check for room in queue to send request now
2467 m
= bfa_reqq_next(ioim
->bfa
, ioim
->reqq
);
2469 bfa_stats(ioim
->itnim
, qwait
);
2470 bfa_reqq_wait(ioim
->bfa
, ioim
->reqq
,
2471 &ioim
->iosp
->reqq_wait
);
2476 * build i/o request message next
2478 m
->io_tag
= cpu_to_be16(ioim
->iotag
);
2479 m
->rport_hdl
= ioim
->itnim
->rport
->fw_handle
;
2487 scsi_for_each_sg(cmnd
, sg
, ioim
->nsges
, i
) {
2489 /* build inline IO SG element */
2490 addr
= bfa_sgaddr_le(sg_dma_address(sg
));
2491 sge
->sga
= *(union bfi_addr_u
*) &addr
;
2492 pgdlen
= sg_dma_len(sg
);
2493 sge
->sg_len
= pgdlen
;
2494 sge
->flags
= (ioim
->nsges
> BFI_SGE_INLINE
) ?
2495 BFI_SGE_DATA_CPL
: BFI_SGE_DATA_LAST
;
2500 sgpge
= sgpg
->sgpg
->sges
;
2502 addr
= bfa_sgaddr_le(sg_dma_address(sg
));
2503 sgpge
->sga
= *(union bfi_addr_u
*) &addr
;
2504 sgpge
->sg_len
= sg_dma_len(sg
);
2505 pgcumsz
+= sgpge
->sg_len
;
2508 if (i
< (ioim
->nsges
- 1) &&
2509 sge_id
< (BFI_SGPG_DATA_SGES
- 1))
2510 sgpge
->flags
= BFI_SGE_DATA
;
2511 else if (i
< (ioim
->nsges
- 1))
2512 sgpge
->flags
= BFI_SGE_DATA_CPL
;
2514 sgpge
->flags
= BFI_SGE_DATA_LAST
;
2516 bfa_sge_to_le(sgpge
);
2519 if (i
== (ioim
->nsges
- 1)) {
2520 sgpge
->flags
= BFI_SGE_PGDLEN
;
2521 sgpge
->sga
.a32
.addr_lo
= 0;
2522 sgpge
->sga
.a32
.addr_hi
= 0;
2523 sgpge
->sg_len
= pgcumsz
;
2524 bfa_sge_to_le(sgpge
);
2525 } else if (++sge_id
== BFI_SGPG_DATA_SGES
) {
2526 sgpg
= (struct bfa_sgpg_s
*) bfa_q_next(sgpg
);
2527 sgpge
->flags
= BFI_SGE_LINK
;
2528 sgpge
->sga
= sgpg
->sgpg_pa
;
2529 sgpge
->sg_len
= pgcumsz
;
2530 bfa_sge_to_le(sgpge
);
2537 if (ioim
->nsges
> BFI_SGE_INLINE
) {
2538 sge
->sga
= ioim
->sgpg
->sgpg_pa
;
2540 sge
->sga
.a32
.addr_lo
= 0;
2541 sge
->sga
.a32
.addr_hi
= 0;
2543 sge
->sg_len
= pgdlen
;
2544 sge
->flags
= BFI_SGE_PGDLEN
;
2548 * set up I/O command parameters
2551 int_to_scsilun(cmnd
->device
->lun
, &m
->cmnd
.lun
);
2552 dmadir
= cmnd
->sc_data_direction
;
2553 if (dmadir
== DMA_TO_DEVICE
)
2554 m
->cmnd
.iodir
= FCP_IODIR_WRITE
;
2555 else if (dmadir
== DMA_FROM_DEVICE
)
2556 m
->cmnd
.iodir
= FCP_IODIR_READ
;
2558 m
->cmnd
.iodir
= FCP_IODIR_NONE
;
2560 m
->cmnd
.cdb
= *(struct scsi_cdb_s
*) cmnd
->cmnd
;
2561 fcp_dl
= scsi_bufflen(cmnd
);
2562 m
->cmnd
.fcp_dl
= cpu_to_be32(fcp_dl
);
2565 * set up I/O message header
2567 switch (m
->cmnd
.iodir
) {
2568 case FCP_IODIR_READ
:
2569 bfi_h2i_set(m
->mh
, BFI_MC_IOIM_READ
, 0, bfa_fn_lpu(ioim
->bfa
));
2570 bfa_stats(itnim
, input_reqs
);
2571 ioim
->itnim
->stats
.rd_throughput
+= fcp_dl
;
2573 case FCP_IODIR_WRITE
:
2574 bfi_h2i_set(m
->mh
, BFI_MC_IOIM_WRITE
, 0, bfa_fn_lpu(ioim
->bfa
));
2575 bfa_stats(itnim
, output_reqs
);
2576 ioim
->itnim
->stats
.wr_throughput
+= fcp_dl
;
2579 bfa_stats(itnim
, input_reqs
);
2580 bfa_stats(itnim
, output_reqs
);
2583 bfi_h2i_set(m
->mh
, BFI_MC_IOIM_IO
, 0, bfa_fn_lpu(ioim
->bfa
));
2585 if (itnim
->seq_rec
||
2586 (scsi_bufflen(cmnd
) & (sizeof(u32
) - 1)))
2587 bfi_h2i_set(m
->mh
, BFI_MC_IOIM_IO
, 0, bfa_fn_lpu(ioim
->bfa
));
2590 * queue I/O message to firmware
2592 bfa_reqq_produce(ioim
->bfa
, ioim
->reqq
, m
->mh
);
2597 * Setup any additional SG pages needed.Inline SG element is setup
2600 static bfa_boolean_t
2601 bfa_ioim_sgpg_alloc(struct bfa_ioim_s
*ioim
)
2605 WARN_ON(ioim
->nsges
<= BFI_SGE_INLINE
);
2608 * allocate SG pages needed
2610 nsgpgs
= BFA_SGPG_NPAGE(ioim
->nsges
);
2614 if (bfa_sgpg_malloc(ioim
->bfa
, &ioim
->sgpg_q
, nsgpgs
)
2616 bfa_sgpg_wait(ioim
->bfa
, &ioim
->iosp
->sgpg_wqe
, nsgpgs
);
2620 ioim
->nsgpgs
= nsgpgs
;
2621 ioim
->sgpg
= bfa_q_first(&ioim
->sgpg_q
);
2627 * Send I/O abort request to firmware.
2629 static bfa_boolean_t
2630 bfa_ioim_send_abort(struct bfa_ioim_s
*ioim
)
2632 struct bfi_ioim_abort_req_s
*m
;
2633 enum bfi_ioim_h2i msgop
;
2636 * check for room in queue to send request now
2638 m
= bfa_reqq_next(ioim
->bfa
, ioim
->reqq
);
2643 * build i/o request message next
2645 if (ioim
->iosp
->abort_explicit
)
2646 msgop
= BFI_IOIM_H2I_IOABORT_REQ
;
2648 msgop
= BFI_IOIM_H2I_IOCLEANUP_REQ
;
2650 bfi_h2i_set(m
->mh
, BFI_MC_IOIM
, msgop
, bfa_fn_lpu(ioim
->bfa
));
2651 m
->io_tag
= cpu_to_be16(ioim
->iotag
);
2652 m
->abort_tag
= ++ioim
->abort_tag
;
2655 * queue I/O message to firmware
2657 bfa_reqq_produce(ioim
->bfa
, ioim
->reqq
, m
->mh
);
2662 * Call to resume any I/O requests waiting for room in request queue.
2665 bfa_ioim_qresume(void *cbarg
)
2667 struct bfa_ioim_s
*ioim
= cbarg
;
2669 bfa_stats(ioim
->itnim
, qresumes
);
2670 bfa_sm_send_event(ioim
, BFA_IOIM_SM_QRESUME
);
2675 bfa_ioim_notify_cleanup(struct bfa_ioim_s
*ioim
)
2678 * Move IO from itnim queue to fcpim global queue since itnim will be
2681 list_del(&ioim
->qe
);
2682 list_add_tail(&ioim
->qe
, &ioim
->fcpim
->ioim_comp_q
);
2684 if (!ioim
->iosp
->tskim
) {
2685 if (ioim
->fcpim
->delay_comp
&& ioim
->itnim
->iotov_active
) {
2686 bfa_cb_dequeue(&ioim
->hcb_qe
);
2687 list_del(&ioim
->qe
);
2688 list_add_tail(&ioim
->qe
, &ioim
->itnim
->delay_comp_q
);
2690 bfa_itnim_iodone(ioim
->itnim
);
2692 bfa_wc_down(&ioim
->iosp
->tskim
->wc
);
2695 static bfa_boolean_t
2696 bfa_ioim_is_abortable(struct bfa_ioim_s
*ioim
)
2698 if ((bfa_sm_cmp_state(ioim
, bfa_ioim_sm_uninit
) &&
2699 (!bfa_q_is_on_q(&ioim
->itnim
->pending_q
, ioim
))) ||
2700 (bfa_sm_cmp_state(ioim
, bfa_ioim_sm_abort
)) ||
2701 (bfa_sm_cmp_state(ioim
, bfa_ioim_sm_abort_qfull
)) ||
2702 (bfa_sm_cmp_state(ioim
, bfa_ioim_sm_hcb
)) ||
2703 (bfa_sm_cmp_state(ioim
, bfa_ioim_sm_hcb_free
)) ||
2704 (bfa_sm_cmp_state(ioim
, bfa_ioim_sm_resfree
)))
2711 bfa_ioim_delayed_comp(struct bfa_ioim_s
*ioim
, bfa_boolean_t iotov
)
2714 * If path tov timer expired, failback with PATHTOV status - these
2715 * IO requests are not normally retried by IO stack.
2717 * Otherwise device cameback online and fail it with normal failed
2718 * status so that IO stack retries these failed IO requests.
2721 ioim
->io_cbfn
= __bfa_cb_ioim_pathtov
;
2723 ioim
->io_cbfn
= __bfa_cb_ioim_failed
;
2724 bfa_stats(ioim
->itnim
, iocom_nexus_abort
);
2726 bfa_cb_queue(ioim
->bfa
, &ioim
->hcb_qe
, ioim
->io_cbfn
, ioim
);
2729 * Move IO to fcpim global queue since itnim will be
2732 list_del(&ioim
->qe
);
2733 list_add_tail(&ioim
->qe
, &ioim
->fcpim
->ioim_comp_q
);
2738 * Memory allocation and initialization.
2741 bfa_ioim_attach(struct bfa_fcpim_s
*fcpim
)
2743 struct bfa_ioim_s
*ioim
;
2744 struct bfa_fcp_mod_s
*fcp
= fcpim
->fcp
;
2745 struct bfa_ioim_sp_s
*iosp
;
2749 * claim memory first
2751 ioim
= (struct bfa_ioim_s
*) bfa_mem_kva_curp(fcp
);
2752 fcpim
->ioim_arr
= ioim
;
2753 bfa_mem_kva_curp(fcp
) = (u8
*) (ioim
+ fcpim
->fcp
->num_ioim_reqs
);
2755 iosp
= (struct bfa_ioim_sp_s
*) bfa_mem_kva_curp(fcp
);
2756 fcpim
->ioim_sp_arr
= iosp
;
2757 bfa_mem_kva_curp(fcp
) = (u8
*) (iosp
+ fcpim
->fcp
->num_ioim_reqs
);
2760 * Initialize ioim free queues
2762 INIT_LIST_HEAD(&fcpim
->ioim_resfree_q
);
2763 INIT_LIST_HEAD(&fcpim
->ioim_comp_q
);
2765 for (i
= 0; i
< fcpim
->fcp
->num_ioim_reqs
;
2766 i
++, ioim
++, iosp
++) {
2770 memset(ioim
, 0, sizeof(struct bfa_ioim_s
));
2772 ioim
->bfa
= fcpim
->bfa
;
2773 ioim
->fcpim
= fcpim
;
2775 INIT_LIST_HEAD(&ioim
->sgpg_q
);
2776 bfa_reqq_winit(&ioim
->iosp
->reqq_wait
,
2777 bfa_ioim_qresume
, ioim
);
2778 bfa_sgpg_winit(&ioim
->iosp
->sgpg_wqe
,
2779 bfa_ioim_sgpg_alloced
, ioim
);
2780 bfa_sm_set_state(ioim
, bfa_ioim_sm_uninit
);
2785 bfa_ioim_isr(struct bfa_s
*bfa
, struct bfi_msg_s
*m
)
2787 struct bfa_fcpim_s
*fcpim
= BFA_FCPIM(bfa
);
2788 struct bfi_ioim_rsp_s
*rsp
= (struct bfi_ioim_rsp_s
*) m
;
2789 struct bfa_ioim_s
*ioim
;
2791 enum bfa_ioim_event evt
= BFA_IOIM_SM_COMP
;
2793 iotag
= be16_to_cpu(rsp
->io_tag
);
2795 ioim
= BFA_IOIM_FROM_TAG(fcpim
, iotag
);
2796 WARN_ON(ioim
->iotag
!= iotag
);
2798 bfa_trc(ioim
->bfa
, ioim
->iotag
);
2799 bfa_trc(ioim
->bfa
, rsp
->io_status
);
2800 bfa_trc(ioim
->bfa
, rsp
->reuse_io_tag
);
2802 if (bfa_sm_cmp_state(ioim
, bfa_ioim_sm_active
))
2803 ioim
->iosp
->comp_rspmsg
= *m
;
2805 switch (rsp
->io_status
) {
2806 case BFI_IOIM_STS_OK
:
2807 bfa_stats(ioim
->itnim
, iocomp_ok
);
2808 if (rsp
->reuse_io_tag
== 0)
2809 evt
= BFA_IOIM_SM_DONE
;
2811 evt
= BFA_IOIM_SM_COMP
;
2814 case BFI_IOIM_STS_TIMEDOUT
:
2815 bfa_stats(ioim
->itnim
, iocomp_timedout
);
2817 case BFI_IOIM_STS_ABORTED
:
2818 rsp
->io_status
= BFI_IOIM_STS_ABORTED
;
2819 bfa_stats(ioim
->itnim
, iocomp_aborted
);
2820 if (rsp
->reuse_io_tag
== 0)
2821 evt
= BFA_IOIM_SM_DONE
;
2823 evt
= BFA_IOIM_SM_COMP
;
2826 case BFI_IOIM_STS_PROTO_ERR
:
2827 bfa_stats(ioim
->itnim
, iocom_proto_err
);
2828 WARN_ON(!rsp
->reuse_io_tag
);
2829 evt
= BFA_IOIM_SM_COMP
;
2832 case BFI_IOIM_STS_SQER_NEEDED
:
2833 bfa_stats(ioim
->itnim
, iocom_sqer_needed
);
2834 WARN_ON(rsp
->reuse_io_tag
!= 0);
2835 evt
= BFA_IOIM_SM_SQRETRY
;
2838 case BFI_IOIM_STS_RES_FREE
:
2839 bfa_stats(ioim
->itnim
, iocom_res_free
);
2840 evt
= BFA_IOIM_SM_FREE
;
2843 case BFI_IOIM_STS_HOST_ABORTED
:
2844 bfa_stats(ioim
->itnim
, iocom_hostabrts
);
2845 if (rsp
->abort_tag
!= ioim
->abort_tag
) {
2846 bfa_trc(ioim
->bfa
, rsp
->abort_tag
);
2847 bfa_trc(ioim
->bfa
, ioim
->abort_tag
);
2851 if (rsp
->reuse_io_tag
)
2852 evt
= BFA_IOIM_SM_ABORT_COMP
;
2854 evt
= BFA_IOIM_SM_ABORT_DONE
;
2857 case BFI_IOIM_STS_UTAG
:
2858 bfa_stats(ioim
->itnim
, iocom_utags
);
2859 evt
= BFA_IOIM_SM_COMP_UTAG
;
2866 bfa_sm_send_event(ioim
, evt
);
2870 bfa_ioim_good_comp_isr(struct bfa_s
*bfa
, struct bfi_msg_s
*m
)
2872 struct bfa_fcpim_s
*fcpim
= BFA_FCPIM(bfa
);
2873 struct bfi_ioim_rsp_s
*rsp
= (struct bfi_ioim_rsp_s
*) m
;
2874 struct bfa_ioim_s
*ioim
;
2877 iotag
= be16_to_cpu(rsp
->io_tag
);
2879 ioim
= BFA_IOIM_FROM_TAG(fcpim
, iotag
);
2880 WARN_ON(ioim
->iotag
!= iotag
);
2882 bfa_ioim_cb_profile_comp(fcpim
, ioim
);
2884 bfa_sm_send_event(ioim
, BFA_IOIM_SM_COMP_GOOD
);
2888 * Called by itnim to clean up IO while going offline.
2891 bfa_ioim_cleanup(struct bfa_ioim_s
*ioim
)
2893 bfa_trc(ioim
->bfa
, ioim
->iotag
);
2894 bfa_stats(ioim
->itnim
, io_cleanups
);
2896 ioim
->iosp
->tskim
= NULL
;
2897 bfa_sm_send_event(ioim
, BFA_IOIM_SM_CLEANUP
);
2901 bfa_ioim_cleanup_tm(struct bfa_ioim_s
*ioim
, struct bfa_tskim_s
*tskim
)
2903 bfa_trc(ioim
->bfa
, ioim
->iotag
);
2904 bfa_stats(ioim
->itnim
, io_tmaborts
);
2906 ioim
->iosp
->tskim
= tskim
;
2907 bfa_sm_send_event(ioim
, BFA_IOIM_SM_CLEANUP
);
2911 * IOC failure handling.
2914 bfa_ioim_iocdisable(struct bfa_ioim_s
*ioim
)
2916 bfa_trc(ioim
->bfa
, ioim
->iotag
);
2917 bfa_stats(ioim
->itnim
, io_iocdowns
);
2918 bfa_sm_send_event(ioim
, BFA_IOIM_SM_HWFAIL
);
2922 * IO offline TOV popped. Fail the pending IO.
2925 bfa_ioim_tov(struct bfa_ioim_s
*ioim
)
2927 bfa_trc(ioim
->bfa
, ioim
->iotag
);
2928 bfa_sm_send_event(ioim
, BFA_IOIM_SM_IOTOV
);
2933 * Allocate IOIM resource for initiator mode I/O request.
2936 bfa_ioim_alloc(struct bfa_s
*bfa
, struct bfad_ioim_s
*dio
,
2937 struct bfa_itnim_s
*itnim
, u16 nsges
)
2939 struct bfa_fcpim_s
*fcpim
= BFA_FCPIM(bfa
);
2940 struct bfa_ioim_s
*ioim
;
2941 struct bfa_iotag_s
*iotag
= NULL
;
2944 * alocate IOIM resource
2946 bfa_q_deq(&fcpim
->fcp
->iotag_ioim_free_q
, &iotag
);
2948 bfa_stats(itnim
, no_iotags
);
2952 ioim
= BFA_IOIM_FROM_TAG(fcpim
, iotag
->tag
);
2955 ioim
->itnim
= itnim
;
2956 ioim
->nsges
= nsges
;
2959 bfa_stats(itnim
, total_ios
);
2960 fcpim
->ios_active
++;
2962 list_add_tail(&ioim
->qe
, &itnim
->io_q
);
2968 bfa_ioim_free(struct bfa_ioim_s
*ioim
)
2970 struct bfa_fcpim_s
*fcpim
= ioim
->fcpim
;
2971 struct bfa_iotag_s
*iotag
;
2973 if (ioim
->nsgpgs
> 0)
2974 bfa_sgpg_mfree(ioim
->bfa
, &ioim
->sgpg_q
, ioim
->nsgpgs
);
2976 bfa_stats(ioim
->itnim
, io_comps
);
2977 fcpim
->ios_active
--;
2979 ioim
->iotag
&= BFA_IOIM_IOTAG_MASK
;
2981 WARN_ON(!(ioim
->iotag
<
2982 (fcpim
->fcp
->num_ioim_reqs
+ fcpim
->fcp
->num_fwtio_reqs
)));
2983 iotag
= BFA_IOTAG_FROM_TAG(fcpim
->fcp
, ioim
->iotag
);
2985 if (ioim
->iotag
< fcpim
->fcp
->num_ioim_reqs
)
2986 list_add_tail(&iotag
->qe
, &fcpim
->fcp
->iotag_ioim_free_q
);
2988 list_add_tail(&iotag
->qe
, &fcpim
->fcp
->iotag_tio_free_q
);
2990 list_del(&ioim
->qe
);
2994 bfa_ioim_start(struct bfa_ioim_s
*ioim
)
2996 bfa_ioim_cb_profile_start(ioim
->fcpim
, ioim
);
2999 * Obtain the queue over which this request has to be issued
3001 ioim
->reqq
= bfa_fcpim_ioredirect_enabled(ioim
->bfa
) ?
3002 BFA_FALSE
: bfa_itnim_get_reqq(ioim
);
3004 bfa_sm_send_event(ioim
, BFA_IOIM_SM_START
);
3008 * Driver I/O abort request.
3011 bfa_ioim_abort(struct bfa_ioim_s
*ioim
)
3014 bfa_trc(ioim
->bfa
, ioim
->iotag
);
3016 if (!bfa_ioim_is_abortable(ioim
))
3017 return BFA_STATUS_FAILED
;
3019 bfa_stats(ioim
->itnim
, io_aborts
);
3020 bfa_sm_send_event(ioim
, BFA_IOIM_SM_ABORT
);
3022 return BFA_STATUS_OK
;
3026 * BFA TSKIM state machine functions
3030 * Task management command beginning state.
3033 bfa_tskim_sm_uninit(struct bfa_tskim_s
*tskim
, enum bfa_tskim_event event
)
3035 bfa_trc(tskim
->bfa
, tskim
->tsk_tag
<< 16 | event
);
3038 case BFA_TSKIM_SM_START
:
3039 bfa_sm_set_state(tskim
, bfa_tskim_sm_active
);
3040 bfa_tskim_gather_ios(tskim
);
3043 * If device is offline, do not send TM on wire. Just cleanup
3044 * any pending IO requests and complete TM request.
3046 if (!bfa_itnim_is_online(tskim
->itnim
)) {
3047 bfa_sm_set_state(tskim
, bfa_tskim_sm_iocleanup
);
3048 tskim
->tsk_status
= BFI_TSKIM_STS_OK
;
3049 bfa_tskim_cleanup_ios(tskim
);
3053 if (!bfa_tskim_send(tskim
)) {
3054 bfa_sm_set_state(tskim
, bfa_tskim_sm_qfull
);
3055 bfa_stats(tskim
->itnim
, tm_qwait
);
3056 bfa_reqq_wait(tskim
->bfa
, tskim
->itnim
->reqq
,
3062 bfa_sm_fault(tskim
->bfa
, event
);
3067 * TM command is active, awaiting completion from firmware to
3068 * cleanup IO requests in TM scope.
3071 bfa_tskim_sm_active(struct bfa_tskim_s
*tskim
, enum bfa_tskim_event event
)
3073 bfa_trc(tskim
->bfa
, tskim
->tsk_tag
<< 16 | event
);
3076 case BFA_TSKIM_SM_DONE
:
3077 bfa_sm_set_state(tskim
, bfa_tskim_sm_iocleanup
);
3078 bfa_tskim_cleanup_ios(tskim
);
3081 case BFA_TSKIM_SM_CLEANUP
:
3082 bfa_sm_set_state(tskim
, bfa_tskim_sm_cleanup
);
3083 if (!bfa_tskim_send_abort(tskim
)) {
3084 bfa_sm_set_state(tskim
, bfa_tskim_sm_cleanup_qfull
);
3085 bfa_stats(tskim
->itnim
, tm_qwait
);
3086 bfa_reqq_wait(tskim
->bfa
, tskim
->itnim
->reqq
,
3091 case BFA_TSKIM_SM_HWFAIL
:
3092 bfa_sm_set_state(tskim
, bfa_tskim_sm_hcb
);
3093 bfa_tskim_iocdisable_ios(tskim
);
3094 bfa_tskim_qcomp(tskim
, __bfa_cb_tskim_failed
);
3098 bfa_sm_fault(tskim
->bfa
, event
);
3103 * An active TM is being cleaned up since ITN is offline. Awaiting cleanup
3104 * completion event from firmware.
3107 bfa_tskim_sm_cleanup(struct bfa_tskim_s
*tskim
, enum bfa_tskim_event event
)
3109 bfa_trc(tskim
->bfa
, tskim
->tsk_tag
<< 16 | event
);
3112 case BFA_TSKIM_SM_DONE
:
3114 * Ignore and wait for ABORT completion from firmware.
3118 case BFA_TSKIM_SM_UTAG
:
3119 case BFA_TSKIM_SM_CLEANUP_DONE
:
3120 bfa_sm_set_state(tskim
, bfa_tskim_sm_iocleanup
);
3121 bfa_tskim_cleanup_ios(tskim
);
3124 case BFA_TSKIM_SM_HWFAIL
:
3125 bfa_sm_set_state(tskim
, bfa_tskim_sm_hcb
);
3126 bfa_tskim_iocdisable_ios(tskim
);
3127 bfa_tskim_qcomp(tskim
, __bfa_cb_tskim_failed
);
3131 bfa_sm_fault(tskim
->bfa
, event
);
3136 bfa_tskim_sm_iocleanup(struct bfa_tskim_s
*tskim
, enum bfa_tskim_event event
)
3138 bfa_trc(tskim
->bfa
, tskim
->tsk_tag
<< 16 | event
);
3141 case BFA_TSKIM_SM_IOS_DONE
:
3142 bfa_sm_set_state(tskim
, bfa_tskim_sm_hcb
);
3143 bfa_tskim_qcomp(tskim
, __bfa_cb_tskim_done
);
3146 case BFA_TSKIM_SM_CLEANUP
:
3148 * Ignore, TM command completed on wire.
3149 * Notify TM conmpletion on IO cleanup completion.
3153 case BFA_TSKIM_SM_HWFAIL
:
3154 bfa_sm_set_state(tskim
, bfa_tskim_sm_hcb
);
3155 bfa_tskim_iocdisable_ios(tskim
);
3156 bfa_tskim_qcomp(tskim
, __bfa_cb_tskim_failed
);
3160 bfa_sm_fault(tskim
->bfa
, event
);
3165 * Task management command is waiting for room in request CQ
3168 bfa_tskim_sm_qfull(struct bfa_tskim_s
*tskim
, enum bfa_tskim_event event
)
3170 bfa_trc(tskim
->bfa
, tskim
->tsk_tag
<< 16 | event
);
3173 case BFA_TSKIM_SM_QRESUME
:
3174 bfa_sm_set_state(tskim
, bfa_tskim_sm_active
);
3175 bfa_tskim_send(tskim
);
3178 case BFA_TSKIM_SM_CLEANUP
:
3180 * No need to send TM on wire since ITN is offline.
3182 bfa_sm_set_state(tskim
, bfa_tskim_sm_iocleanup
);
3183 bfa_reqq_wcancel(&tskim
->reqq_wait
);
3184 bfa_tskim_cleanup_ios(tskim
);
3187 case BFA_TSKIM_SM_HWFAIL
:
3188 bfa_sm_set_state(tskim
, bfa_tskim_sm_hcb
);
3189 bfa_reqq_wcancel(&tskim
->reqq_wait
);
3190 bfa_tskim_iocdisable_ios(tskim
);
3191 bfa_tskim_qcomp(tskim
, __bfa_cb_tskim_failed
);
3195 bfa_sm_fault(tskim
->bfa
, event
);
3200 * Task management command is active, awaiting for room in request CQ
3201 * to send clean up request.
3204 bfa_tskim_sm_cleanup_qfull(struct bfa_tskim_s
*tskim
,
3205 enum bfa_tskim_event event
)
3207 bfa_trc(tskim
->bfa
, tskim
->tsk_tag
<< 16 | event
);
3210 case BFA_TSKIM_SM_DONE
:
3211 bfa_reqq_wcancel(&tskim
->reqq_wait
);
3213 case BFA_TSKIM_SM_QRESUME
:
3214 bfa_sm_set_state(tskim
, bfa_tskim_sm_cleanup
);
3215 bfa_tskim_send_abort(tskim
);
3218 case BFA_TSKIM_SM_HWFAIL
:
3219 bfa_sm_set_state(tskim
, bfa_tskim_sm_hcb
);
3220 bfa_reqq_wcancel(&tskim
->reqq_wait
);
3221 bfa_tskim_iocdisable_ios(tskim
);
3222 bfa_tskim_qcomp(tskim
, __bfa_cb_tskim_failed
);
3226 bfa_sm_fault(tskim
->bfa
, event
);
3231 * BFA callback is pending
3234 bfa_tskim_sm_hcb(struct bfa_tskim_s
*tskim
, enum bfa_tskim_event event
)
3236 bfa_trc(tskim
->bfa
, tskim
->tsk_tag
<< 16 | event
);
3239 case BFA_TSKIM_SM_HCB
:
3240 bfa_sm_set_state(tskim
, bfa_tskim_sm_uninit
);
3241 bfa_tskim_free(tskim
);
3244 case BFA_TSKIM_SM_CLEANUP
:
3245 bfa_tskim_notify_comp(tskim
);
3248 case BFA_TSKIM_SM_HWFAIL
:
3252 bfa_sm_fault(tskim
->bfa
, event
);
3257 __bfa_cb_tskim_done(void *cbarg
, bfa_boolean_t complete
)
3259 struct bfa_tskim_s
*tskim
= cbarg
;
3262 bfa_sm_send_event(tskim
, BFA_TSKIM_SM_HCB
);
3266 bfa_stats(tskim
->itnim
, tm_success
);
3267 bfa_cb_tskim_done(tskim
->bfa
->bfad
, tskim
->dtsk
, tskim
->tsk_status
);
3271 __bfa_cb_tskim_failed(void *cbarg
, bfa_boolean_t complete
)
3273 struct bfa_tskim_s
*tskim
= cbarg
;
3276 bfa_sm_send_event(tskim
, BFA_TSKIM_SM_HCB
);
3280 bfa_stats(tskim
->itnim
, tm_failures
);
3281 bfa_cb_tskim_done(tskim
->bfa
->bfad
, tskim
->dtsk
,
3282 BFI_TSKIM_STS_FAILED
);
3285 static bfa_boolean_t
3286 bfa_tskim_match_scope(struct bfa_tskim_s
*tskim
, struct scsi_lun lun
)
3288 switch (tskim
->tm_cmnd
) {
3289 case FCP_TM_TARGET_RESET
:
3292 case FCP_TM_ABORT_TASK_SET
:
3293 case FCP_TM_CLEAR_TASK_SET
:
3294 case FCP_TM_LUN_RESET
:
3295 case FCP_TM_CLEAR_ACA
:
3296 return !memcmp(&tskim
->lun
, &lun
, sizeof(lun
));
3306 * Gather affected IO requests and task management commands.
3309 bfa_tskim_gather_ios(struct bfa_tskim_s
*tskim
)
3311 struct bfa_itnim_s
*itnim
= tskim
->itnim
;
3312 struct bfa_ioim_s
*ioim
;
3313 struct list_head
*qe
, *qen
;
3314 struct scsi_cmnd
*cmnd
;
3315 struct scsi_lun scsilun
;
3317 INIT_LIST_HEAD(&tskim
->io_q
);
3320 * Gather any active IO requests first.
3322 list_for_each_safe(qe
, qen
, &itnim
->io_q
) {
3323 ioim
= (struct bfa_ioim_s
*) qe
;
3324 cmnd
= (struct scsi_cmnd
*) ioim
->dio
;
3325 int_to_scsilun(cmnd
->device
->lun
, &scsilun
);
3326 if (bfa_tskim_match_scope(tskim
, scsilun
)) {
3327 list_del(&ioim
->qe
);
3328 list_add_tail(&ioim
->qe
, &tskim
->io_q
);
3333 * Failback any pending IO requests immediately.
3335 list_for_each_safe(qe
, qen
, &itnim
->pending_q
) {
3336 ioim
= (struct bfa_ioim_s
*) qe
;
3337 cmnd
= (struct scsi_cmnd
*) ioim
->dio
;
3338 int_to_scsilun(cmnd
->device
->lun
, &scsilun
);
3339 if (bfa_tskim_match_scope(tskim
, scsilun
)) {
3340 list_del(&ioim
->qe
);
3341 list_add_tail(&ioim
->qe
, &ioim
->fcpim
->ioim_comp_q
);
3348 * IO cleanup completion
3351 bfa_tskim_cleanp_comp(void *tskim_cbarg
)
3353 struct bfa_tskim_s
*tskim
= tskim_cbarg
;
3355 bfa_stats(tskim
->itnim
, tm_io_comps
);
3356 bfa_sm_send_event(tskim
, BFA_TSKIM_SM_IOS_DONE
);
3360 * Gather affected IO requests and task management commands.
3363 bfa_tskim_cleanup_ios(struct bfa_tskim_s
*tskim
)
3365 struct bfa_ioim_s
*ioim
;
3366 struct list_head
*qe
, *qen
;
3368 bfa_wc_init(&tskim
->wc
, bfa_tskim_cleanp_comp
, tskim
);
3370 list_for_each_safe(qe
, qen
, &tskim
->io_q
) {
3371 ioim
= (struct bfa_ioim_s
*) qe
;
3372 bfa_wc_up(&tskim
->wc
);
3373 bfa_ioim_cleanup_tm(ioim
, tskim
);
3376 bfa_wc_wait(&tskim
->wc
);
3380 * Send task management request to firmware.
3382 static bfa_boolean_t
3383 bfa_tskim_send(struct bfa_tskim_s
*tskim
)
3385 struct bfa_itnim_s
*itnim
= tskim
->itnim
;
3386 struct bfi_tskim_req_s
*m
;
3389 * check for room in queue to send request now
3391 m
= bfa_reqq_next(tskim
->bfa
, itnim
->reqq
);
3396 * build i/o request message next
3398 bfi_h2i_set(m
->mh
, BFI_MC_TSKIM
, BFI_TSKIM_H2I_TM_REQ
,
3399 bfa_fn_lpu(tskim
->bfa
));
3401 m
->tsk_tag
= cpu_to_be16(tskim
->tsk_tag
);
3402 m
->itn_fhdl
= tskim
->itnim
->rport
->fw_handle
;
3403 m
->t_secs
= tskim
->tsecs
;
3404 m
->lun
= tskim
->lun
;
3405 m
->tm_flags
= tskim
->tm_cmnd
;
3408 * queue I/O message to firmware
3410 bfa_reqq_produce(tskim
->bfa
, itnim
->reqq
, m
->mh
);
3415 * Send abort request to cleanup an active TM to firmware.
3417 static bfa_boolean_t
3418 bfa_tskim_send_abort(struct bfa_tskim_s
*tskim
)
3420 struct bfa_itnim_s
*itnim
= tskim
->itnim
;
3421 struct bfi_tskim_abortreq_s
*m
;
3424 * check for room in queue to send request now
3426 m
= bfa_reqq_next(tskim
->bfa
, itnim
->reqq
);
3431 * build i/o request message next
3433 bfi_h2i_set(m
->mh
, BFI_MC_TSKIM
, BFI_TSKIM_H2I_ABORT_REQ
,
3434 bfa_fn_lpu(tskim
->bfa
));
3436 m
->tsk_tag
= cpu_to_be16(tskim
->tsk_tag
);
3439 * queue I/O message to firmware
3441 bfa_reqq_produce(tskim
->bfa
, itnim
->reqq
, m
->mh
);
3446 * Call to resume task management cmnd waiting for room in request queue.
3449 bfa_tskim_qresume(void *cbarg
)
3451 struct bfa_tskim_s
*tskim
= cbarg
;
3453 bfa_stats(tskim
->itnim
, tm_qresumes
);
3454 bfa_sm_send_event(tskim
, BFA_TSKIM_SM_QRESUME
);
3458 * Cleanup IOs associated with a task mangement command on IOC failures.
3461 bfa_tskim_iocdisable_ios(struct bfa_tskim_s
*tskim
)
3463 struct bfa_ioim_s
*ioim
;
3464 struct list_head
*qe
, *qen
;
3466 list_for_each_safe(qe
, qen
, &tskim
->io_q
) {
3467 ioim
= (struct bfa_ioim_s
*) qe
;
3468 bfa_ioim_iocdisable(ioim
);
3473 * Notification on completions from related ioim.
3476 bfa_tskim_iodone(struct bfa_tskim_s
*tskim
)
3478 bfa_wc_down(&tskim
->wc
);
3482 * Handle IOC h/w failure notification from itnim.
3485 bfa_tskim_iocdisable(struct bfa_tskim_s
*tskim
)
3487 tskim
->notify
= BFA_FALSE
;
3488 bfa_stats(tskim
->itnim
, tm_iocdowns
);
3489 bfa_sm_send_event(tskim
, BFA_TSKIM_SM_HWFAIL
);
3493 * Cleanup TM command and associated IOs as part of ITNIM offline.
3496 bfa_tskim_cleanup(struct bfa_tskim_s
*tskim
)
3498 tskim
->notify
= BFA_TRUE
;
3499 bfa_stats(tskim
->itnim
, tm_cleanups
);
3500 bfa_sm_send_event(tskim
, BFA_TSKIM_SM_CLEANUP
);
3504 * Memory allocation and initialization.
3507 bfa_tskim_attach(struct bfa_fcpim_s
*fcpim
)
3509 struct bfa_tskim_s
*tskim
;
3510 struct bfa_fcp_mod_s
*fcp
= fcpim
->fcp
;
3513 INIT_LIST_HEAD(&fcpim
->tskim_free_q
);
3514 INIT_LIST_HEAD(&fcpim
->tskim_unused_q
);
3516 tskim
= (struct bfa_tskim_s
*) bfa_mem_kva_curp(fcp
);
3517 fcpim
->tskim_arr
= tskim
;
3519 for (i
= 0; i
< fcpim
->num_tskim_reqs
; i
++, tskim
++) {
3523 memset(tskim
, 0, sizeof(struct bfa_tskim_s
));
3525 tskim
->bfa
= fcpim
->bfa
;
3526 tskim
->fcpim
= fcpim
;
3527 tskim
->notify
= BFA_FALSE
;
3528 bfa_reqq_winit(&tskim
->reqq_wait
, bfa_tskim_qresume
,
3530 bfa_sm_set_state(tskim
, bfa_tskim_sm_uninit
);
3532 list_add_tail(&tskim
->qe
, &fcpim
->tskim_free_q
);
3535 bfa_mem_kva_curp(fcp
) = (u8
*) tskim
;
3539 bfa_tskim_isr(struct bfa_s
*bfa
, struct bfi_msg_s
*m
)
3541 struct bfa_fcpim_s
*fcpim
= BFA_FCPIM(bfa
);
3542 struct bfi_tskim_rsp_s
*rsp
= (struct bfi_tskim_rsp_s
*) m
;
3543 struct bfa_tskim_s
*tskim
;
3544 u16 tsk_tag
= be16_to_cpu(rsp
->tsk_tag
);
3546 tskim
= BFA_TSKIM_FROM_TAG(fcpim
, tsk_tag
);
3547 WARN_ON(tskim
->tsk_tag
!= tsk_tag
);
3549 tskim
->tsk_status
= rsp
->tsk_status
;
3552 * Firmware sends BFI_TSKIM_STS_ABORTED status for abort
3553 * requests. All other statuses are for normal completions.
3555 if (rsp
->tsk_status
== BFI_TSKIM_STS_ABORTED
) {
3556 bfa_stats(tskim
->itnim
, tm_cleanup_comps
);
3557 bfa_sm_send_event(tskim
, BFA_TSKIM_SM_CLEANUP_DONE
);
3558 } else if (rsp
->tsk_status
== BFI_TSKIM_STS_UTAG
) {
3559 bfa_sm_send_event(tskim
, BFA_TSKIM_SM_UTAG
);
3561 bfa_stats(tskim
->itnim
, tm_fw_rsps
);
3562 bfa_sm_send_event(tskim
, BFA_TSKIM_SM_DONE
);
3567 struct bfa_tskim_s
*
3568 bfa_tskim_alloc(struct bfa_s
*bfa
, struct bfad_tskim_s
*dtsk
)
3570 struct bfa_fcpim_s
*fcpim
= BFA_FCPIM(bfa
);
3571 struct bfa_tskim_s
*tskim
;
3573 bfa_q_deq(&fcpim
->tskim_free_q
, &tskim
);
3582 bfa_tskim_free(struct bfa_tskim_s
*tskim
)
3584 WARN_ON(!bfa_q_is_on_q_func(&tskim
->itnim
->tsk_q
, &tskim
->qe
));
3585 list_del(&tskim
->qe
);
3586 list_add_tail(&tskim
->qe
, &tskim
->fcpim
->tskim_free_q
);
3590 * Start a task management command.
3592 * @param[in] tskim BFA task management command instance
3593 * @param[in] itnim i-t nexus for the task management command
3594 * @param[in] lun lun, if applicable
3595 * @param[in] tm_cmnd Task management command code.
3596 * @param[in] t_secs Timeout in seconds
3601 bfa_tskim_start(struct bfa_tskim_s
*tskim
, struct bfa_itnim_s
*itnim
,
3602 struct scsi_lun lun
,
3603 enum fcp_tm_cmnd tm_cmnd
, u8 tsecs
)
3605 tskim
->itnim
= itnim
;
3607 tskim
->tm_cmnd
= tm_cmnd
;
3608 tskim
->tsecs
= tsecs
;
3609 tskim
->notify
= BFA_FALSE
;
3610 bfa_stats(itnim
, tm_cmnds
);
3612 list_add_tail(&tskim
->qe
, &itnim
->tsk_q
);
3613 bfa_sm_send_event(tskim
, BFA_TSKIM_SM_START
);
3617 bfa_tskim_res_recfg(struct bfa_s
*bfa
, u16 num_tskim_fw
)
3619 struct bfa_fcpim_s
*fcpim
= BFA_FCPIM(bfa
);
3620 struct list_head
*qe
;
3623 for (i
= 0; i
< (fcpim
->num_tskim_reqs
- num_tskim_fw
); i
++) {
3624 bfa_q_deq_tail(&fcpim
->tskim_free_q
, &qe
);
3625 list_add_tail(qe
, &fcpim
->tskim_unused_q
);
3630 bfa_fcp_meminfo(struct bfa_iocfc_cfg_s
*cfg
, struct bfa_meminfo_s
*minfo
,
3633 struct bfa_fcp_mod_s
*fcp
= BFA_FCP_MOD(bfa
);
3634 struct bfa_mem_kva_s
*fcp_kva
= BFA_MEM_FCP_KVA(bfa
);
3635 struct bfa_mem_dma_s
*seg_ptr
;
3636 u16 nsegs
, idx
, per_seg_ios
, num_io_req
;
3640 * ZERO for num_ioim_reqs and num_fwtio_reqs is allowed config value.
3641 * So if the values are non zero, adjust them appropriately.
3643 if (cfg
->fwcfg
.num_ioim_reqs
&&
3644 cfg
->fwcfg
.num_ioim_reqs
< BFA_IOIM_MIN
)
3645 cfg
->fwcfg
.num_ioim_reqs
= BFA_IOIM_MIN
;
3646 else if (cfg
->fwcfg
.num_ioim_reqs
> BFA_IOIM_MAX
)
3647 cfg
->fwcfg
.num_ioim_reqs
= BFA_IOIM_MAX
;
3649 if (cfg
->fwcfg
.num_fwtio_reqs
> BFA_FWTIO_MAX
)
3650 cfg
->fwcfg
.num_fwtio_reqs
= BFA_FWTIO_MAX
;
3652 num_io_req
= (cfg
->fwcfg
.num_ioim_reqs
+ cfg
->fwcfg
.num_fwtio_reqs
);
3653 if (num_io_req
> BFA_IO_MAX
) {
3654 if (cfg
->fwcfg
.num_ioim_reqs
&& cfg
->fwcfg
.num_fwtio_reqs
) {
3655 cfg
->fwcfg
.num_ioim_reqs
= BFA_IO_MAX
/2;
3656 cfg
->fwcfg
.num_fwtio_reqs
= BFA_IO_MAX
/2;
3657 } else if (cfg
->fwcfg
.num_fwtio_reqs
)
3658 cfg
->fwcfg
.num_fwtio_reqs
= BFA_FWTIO_MAX
;
3660 cfg
->fwcfg
.num_ioim_reqs
= BFA_IOIM_MAX
;
3663 bfa_fcpim_meminfo(cfg
, &km_len
);
3665 num_io_req
= (cfg
->fwcfg
.num_ioim_reqs
+ cfg
->fwcfg
.num_fwtio_reqs
);
3666 km_len
+= num_io_req
* sizeof(struct bfa_iotag_s
);
3667 km_len
+= cfg
->fwcfg
.num_rports
* sizeof(struct bfa_itn_s
);
3670 nsegs
= BFI_MEM_DMA_NSEGS(num_io_req
, BFI_IOIM_SNSLEN
);
3671 per_seg_ios
= BFI_MEM_NREQS_SEG(BFI_IOIM_SNSLEN
);
3673 bfa_mem_dma_seg_iter(fcp
, seg_ptr
, nsegs
, idx
) {
3674 if (num_io_req
>= per_seg_ios
) {
3675 num_io_req
-= per_seg_ios
;
3676 bfa_mem_dma_setup(minfo
, seg_ptr
,
3677 per_seg_ios
* BFI_IOIM_SNSLEN
);
3679 bfa_mem_dma_setup(minfo
, seg_ptr
,
3680 num_io_req
* BFI_IOIM_SNSLEN
);
3684 bfa_mem_kva_setup(minfo
, fcp_kva
, km_len
);
3688 bfa_fcp_attach(struct bfa_s
*bfa
, void *bfad
, struct bfa_iocfc_cfg_s
*cfg
,
3689 struct bfa_pcidev_s
*pcidev
)
3691 struct bfa_fcp_mod_s
*fcp
= BFA_FCP_MOD(bfa
);
3692 struct bfa_mem_dma_s
*seg_ptr
;
3693 u16 idx
, nsegs
, num_io_req
;
3695 fcp
->max_ioim_reqs
= cfg
->fwcfg
.num_ioim_reqs
;
3696 fcp
->num_ioim_reqs
= cfg
->fwcfg
.num_ioim_reqs
;
3697 fcp
->num_fwtio_reqs
= cfg
->fwcfg
.num_fwtio_reqs
;
3698 fcp
->num_itns
= cfg
->fwcfg
.num_rports
;
3702 * Setup the pool of snsbase addr's, that is passed to fw as
3703 * part of bfi_iocfc_cfg_s.
3705 num_io_req
= (cfg
->fwcfg
.num_ioim_reqs
+ cfg
->fwcfg
.num_fwtio_reqs
);
3706 nsegs
= BFI_MEM_DMA_NSEGS(num_io_req
, BFI_IOIM_SNSLEN
);
3708 bfa_mem_dma_seg_iter(fcp
, seg_ptr
, nsegs
, idx
) {
3710 if (!bfa_mem_dma_virt(seg_ptr
))
3713 fcp
->snsbase
[idx
].pa
= bfa_mem_dma_phys(seg_ptr
);
3714 fcp
->snsbase
[idx
].kva
= bfa_mem_dma_virt(seg_ptr
);
3715 bfa_iocfc_set_snsbase(bfa
, idx
, fcp
->snsbase
[idx
].pa
);
3718 fcp
->throttle_update_required
= 1;
3719 bfa_fcpim_attach(fcp
, bfad
, cfg
, pcidev
);
3721 bfa_iotag_attach(fcp
);
3723 fcp
->itn_arr
= (struct bfa_itn_s
*) bfa_mem_kva_curp(fcp
);
3724 bfa_mem_kva_curp(fcp
) = (u8
*)fcp
->itn_arr
+
3725 (fcp
->num_itns
* sizeof(struct bfa_itn_s
));
3726 memset(fcp
->itn_arr
, 0,
3727 (fcp
->num_itns
* sizeof(struct bfa_itn_s
)));
3731 bfa_fcp_iocdisable(struct bfa_s
*bfa
)
3733 struct bfa_fcp_mod_s
*fcp
= BFA_FCP_MOD(bfa
);
3735 bfa_fcpim_iocdisable(fcp
);
3739 bfa_fcp_res_recfg(struct bfa_s
*bfa
, u16 num_ioim_fw
, u16 max_ioim_fw
)
3741 struct bfa_fcp_mod_s
*mod
= BFA_FCP_MOD(bfa
);
3742 struct list_head
*qe
;
3745 /* Update io throttle value only once during driver load time */
3746 if (!mod
->throttle_update_required
)
3749 for (i
= 0; i
< (mod
->num_ioim_reqs
- num_ioim_fw
); i
++) {
3750 bfa_q_deq_tail(&mod
->iotag_ioim_free_q
, &qe
);
3751 list_add_tail(qe
, &mod
->iotag_unused_q
);
3754 if (mod
->num_ioim_reqs
!= num_ioim_fw
) {
3755 bfa_trc(bfa
, mod
->num_ioim_reqs
);
3756 bfa_trc(bfa
, num_ioim_fw
);
3759 mod
->max_ioim_reqs
= max_ioim_fw
;
3760 mod
->num_ioim_reqs
= num_ioim_fw
;
3761 mod
->throttle_update_required
= 0;
3765 bfa_itn_create(struct bfa_s
*bfa
, struct bfa_rport_s
*rport
,
3766 void (*isr
)(struct bfa_s
*bfa
, struct bfi_msg_s
*m
))
3768 struct bfa_fcp_mod_s
*fcp
= BFA_FCP_MOD(bfa
);
3769 struct bfa_itn_s
*itn
;
3771 itn
= BFA_ITN_FROM_TAG(fcp
, rport
->rport_tag
);
3776 * Itn interrupt processing.
3779 bfa_itn_isr(struct bfa_s
*bfa
, struct bfi_msg_s
*m
)
3781 struct bfa_fcp_mod_s
*fcp
= BFA_FCP_MOD(bfa
);
3782 union bfi_itn_i2h_msg_u msg
;
3783 struct bfa_itn_s
*itn
;
3786 itn
= BFA_ITN_FROM_TAG(fcp
, msg
.create_rsp
->bfa_handle
);
3795 bfa_iotag_attach(struct bfa_fcp_mod_s
*fcp
)
3797 struct bfa_iotag_s
*iotag
;
3800 iotag
= (struct bfa_iotag_s
*) bfa_mem_kva_curp(fcp
);
3801 fcp
->iotag_arr
= iotag
;
3803 INIT_LIST_HEAD(&fcp
->iotag_ioim_free_q
);
3804 INIT_LIST_HEAD(&fcp
->iotag_tio_free_q
);
3805 INIT_LIST_HEAD(&fcp
->iotag_unused_q
);
3807 num_io_req
= fcp
->num_ioim_reqs
+ fcp
->num_fwtio_reqs
;
3808 for (i
= 0; i
< num_io_req
; i
++, iotag
++) {
3809 memset(iotag
, 0, sizeof(struct bfa_iotag_s
));
3811 if (i
< fcp
->num_ioim_reqs
)
3812 list_add_tail(&iotag
->qe
, &fcp
->iotag_ioim_free_q
);
3814 list_add_tail(&iotag
->qe
, &fcp
->iotag_tio_free_q
);
3817 bfa_mem_kva_curp(fcp
) = (u8
*) iotag
;
3822 * To send config req, first try to use throttle value from flash
3823 * If 0, then use driver parameter
3824 * We need to use min(flash_val, drv_val) because
3825 * memory allocation was done based on this cfg'd value
3828 bfa_fcpim_get_throttle_cfg(struct bfa_s
*bfa
, u16 drv_cfg_param
)
3831 struct bfa_fcp_mod_s
*fcp
= BFA_FCP_MOD(bfa
);
3834 * If throttle value from flash is already in effect after driver is
3835 * loaded then until next load, always return current value instead
3836 * of actual flash value
3838 if (!fcp
->throttle_update_required
)
3839 return (u16
)fcp
->num_ioim_reqs
;
3841 tmp
= bfa_dconf_read_data_valid(bfa
) ? bfa_fcpim_read_throttle(bfa
) : 0;
3842 if (!tmp
|| (tmp
> drv_cfg_param
))
3843 tmp
= drv_cfg_param
;
3849 bfa_fcpim_write_throttle(struct bfa_s
*bfa
, u16 value
)
3851 if (!bfa_dconf_get_min_cfg(bfa
)) {
3852 BFA_DCONF_MOD(bfa
)->dconf
->throttle_cfg
.value
= value
;
3853 BFA_DCONF_MOD(bfa
)->dconf
->throttle_cfg
.is_valid
= 1;
3854 return BFA_STATUS_OK
;
3857 return BFA_STATUS_FAILED
;
3861 bfa_fcpim_read_throttle(struct bfa_s
*bfa
)
3863 struct bfa_throttle_cfg_s
*throttle_cfg
=
3864 &(BFA_DCONF_MOD(bfa
)->dconf
->throttle_cfg
);
3866 return ((!bfa_dconf_get_min_cfg(bfa
)) ?
3867 ((throttle_cfg
->is_valid
== 1) ? (throttle_cfg
->value
) : 0) : 0);
3871 bfa_fcpim_throttle_set(struct bfa_s
*bfa
, u16 value
)
3873 /* in min cfg no commands should run. */
3874 if ((bfa_dconf_get_min_cfg(bfa
) == BFA_TRUE
) ||
3875 (!bfa_dconf_read_data_valid(bfa
)))
3876 return BFA_STATUS_FAILED
;
3878 bfa_fcpim_write_throttle(bfa
, value
);
3880 return bfa_dconf_update(bfa
);
3884 bfa_fcpim_throttle_get(struct bfa_s
*bfa
, void *buf
)
3886 struct bfa_fcpim_s
*fcpim
= BFA_FCPIM(bfa
);
3887 struct bfa_defs_fcpim_throttle_s throttle
;
3889 if ((bfa_dconf_get_min_cfg(bfa
) == BFA_TRUE
) ||
3890 (!bfa_dconf_read_data_valid(bfa
)))
3891 return BFA_STATUS_FAILED
;
3893 memset(&throttle
, 0, sizeof(struct bfa_defs_fcpim_throttle_s
));
3895 throttle
.cur_value
= (u16
)(fcpim
->fcp
->num_ioim_reqs
);
3896 throttle
.cfg_value
= bfa_fcpim_read_throttle(bfa
);
3897 if (!throttle
.cfg_value
)
3898 throttle
.cfg_value
= throttle
.cur_value
;
3899 throttle
.max_value
= (u16
)(fcpim
->fcp
->max_ioim_reqs
);
3900 memcpy(buf
, &throttle
, sizeof(struct bfa_defs_fcpim_throttle_s
));
3902 return BFA_STATUS_OK
;