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 * BFA IOIM related definitions
70 #define bfa_ioim_move_to_comp_q(__ioim) do { \
71 list_del(&(__ioim)->qe); \
72 list_add_tail(&(__ioim)->qe, &(__ioim)->fcpim->ioim_comp_q); \
76 #define bfa_ioim_cb_profile_comp(__fcpim, __ioim) do { \
77 if ((__fcpim)->profile_comp) \
78 (__fcpim)->profile_comp(__ioim); \
81 #define bfa_ioim_cb_profile_start(__fcpim, __ioim) do { \
82 if ((__fcpim)->profile_start) \
83 (__fcpim)->profile_start(__ioim); \
88 * BFA TSKIM related definitions
92 * task management completion handling
94 #define bfa_tskim_qcomp(__tskim, __cbfn) do { \
95 bfa_cb_queue((__tskim)->bfa, &(__tskim)->hcb_qe, __cbfn, (__tskim));\
96 bfa_tskim_notify_comp(__tskim); \
99 #define bfa_tskim_notify_comp(__tskim) do { \
100 if ((__tskim)->notify) \
101 bfa_itnim_tskdone((__tskim)->itnim); \
106 * forward declaration for BFA ITNIM functions
108 static void bfa_itnim_iocdisable_cleanup(struct bfa_itnim_s
*itnim
);
109 static bfa_boolean_t
bfa_itnim_send_fwcreate(struct bfa_itnim_s
*itnim
);
110 static bfa_boolean_t
bfa_itnim_send_fwdelete(struct bfa_itnim_s
*itnim
);
111 static void bfa_itnim_cleanp_comp(void *itnim_cbarg
);
112 static void bfa_itnim_cleanup(struct bfa_itnim_s
*itnim
);
113 static void __bfa_cb_itnim_online(void *cbarg
, bfa_boolean_t complete
);
114 static void __bfa_cb_itnim_offline(void *cbarg
, bfa_boolean_t complete
);
115 static void __bfa_cb_itnim_sler(void *cbarg
, bfa_boolean_t complete
);
116 static void bfa_itnim_iotov_online(struct bfa_itnim_s
*itnim
);
117 static void bfa_itnim_iotov_cleanup(struct bfa_itnim_s
*itnim
);
118 static void bfa_itnim_iotov(void *itnim_arg
);
119 static void bfa_itnim_iotov_start(struct bfa_itnim_s
*itnim
);
120 static void bfa_itnim_iotov_stop(struct bfa_itnim_s
*itnim
);
121 static void bfa_itnim_iotov_delete(struct bfa_itnim_s
*itnim
);
124 * forward declaration of ITNIM state machine
126 static void bfa_itnim_sm_uninit(struct bfa_itnim_s
*itnim
,
127 enum bfa_itnim_event event
);
128 static void bfa_itnim_sm_created(struct bfa_itnim_s
*itnim
,
129 enum bfa_itnim_event event
);
130 static void bfa_itnim_sm_fwcreate(struct bfa_itnim_s
*itnim
,
131 enum bfa_itnim_event event
);
132 static void bfa_itnim_sm_delete_pending(struct bfa_itnim_s
*itnim
,
133 enum bfa_itnim_event event
);
134 static void bfa_itnim_sm_online(struct bfa_itnim_s
*itnim
,
135 enum bfa_itnim_event event
);
136 static void bfa_itnim_sm_sler(struct bfa_itnim_s
*itnim
,
137 enum bfa_itnim_event event
);
138 static void bfa_itnim_sm_cleanup_offline(struct bfa_itnim_s
*itnim
,
139 enum bfa_itnim_event event
);
140 static void bfa_itnim_sm_cleanup_delete(struct bfa_itnim_s
*itnim
,
141 enum bfa_itnim_event event
);
142 static void bfa_itnim_sm_fwdelete(struct bfa_itnim_s
*itnim
,
143 enum bfa_itnim_event event
);
144 static void bfa_itnim_sm_offline(struct bfa_itnim_s
*itnim
,
145 enum bfa_itnim_event event
);
146 static void bfa_itnim_sm_iocdisable(struct bfa_itnim_s
*itnim
,
147 enum bfa_itnim_event event
);
148 static void bfa_itnim_sm_deleting(struct bfa_itnim_s
*itnim
,
149 enum bfa_itnim_event event
);
150 static void bfa_itnim_sm_fwcreate_qfull(struct bfa_itnim_s
*itnim
,
151 enum bfa_itnim_event event
);
152 static void bfa_itnim_sm_fwdelete_qfull(struct bfa_itnim_s
*itnim
,
153 enum bfa_itnim_event event
);
154 static void bfa_itnim_sm_deleting_qfull(struct bfa_itnim_s
*itnim
,
155 enum bfa_itnim_event event
);
158 * forward declaration for BFA IOIM functions
160 static bfa_boolean_t
bfa_ioim_send_ioreq(struct bfa_ioim_s
*ioim
);
161 static bfa_boolean_t
bfa_ioim_sgpg_alloc(struct bfa_ioim_s
*ioim
);
162 static bfa_boolean_t
bfa_ioim_send_abort(struct bfa_ioim_s
*ioim
);
163 static void bfa_ioim_notify_cleanup(struct bfa_ioim_s
*ioim
);
164 static void __bfa_cb_ioim_good_comp(void *cbarg
, bfa_boolean_t complete
);
165 static void __bfa_cb_ioim_comp(void *cbarg
, bfa_boolean_t complete
);
166 static void __bfa_cb_ioim_abort(void *cbarg
, bfa_boolean_t complete
);
167 static void __bfa_cb_ioim_failed(void *cbarg
, bfa_boolean_t complete
);
168 static void __bfa_cb_ioim_pathtov(void *cbarg
, bfa_boolean_t complete
);
169 static bfa_boolean_t
bfa_ioim_is_abortable(struct bfa_ioim_s
*ioim
);
172 * forward declaration of BFA IO state machine
174 static void bfa_ioim_sm_uninit(struct bfa_ioim_s
*ioim
,
175 enum bfa_ioim_event event
);
176 static void bfa_ioim_sm_sgalloc(struct bfa_ioim_s
*ioim
,
177 enum bfa_ioim_event event
);
178 static void bfa_ioim_sm_active(struct bfa_ioim_s
*ioim
,
179 enum bfa_ioim_event event
);
180 static void bfa_ioim_sm_abort(struct bfa_ioim_s
*ioim
,
181 enum bfa_ioim_event event
);
182 static void bfa_ioim_sm_cleanup(struct bfa_ioim_s
*ioim
,
183 enum bfa_ioim_event event
);
184 static void bfa_ioim_sm_qfull(struct bfa_ioim_s
*ioim
,
185 enum bfa_ioim_event event
);
186 static void bfa_ioim_sm_abort_qfull(struct bfa_ioim_s
*ioim
,
187 enum bfa_ioim_event event
);
188 static void bfa_ioim_sm_cleanup_qfull(struct bfa_ioim_s
*ioim
,
189 enum bfa_ioim_event event
);
190 static void bfa_ioim_sm_hcb(struct bfa_ioim_s
*ioim
,
191 enum bfa_ioim_event event
);
192 static void bfa_ioim_sm_hcb_free(struct bfa_ioim_s
*ioim
,
193 enum bfa_ioim_event event
);
194 static void bfa_ioim_sm_resfree(struct bfa_ioim_s
*ioim
,
195 enum bfa_ioim_event event
);
196 static void bfa_ioim_sm_cmnd_retry(struct bfa_ioim_s
*ioim
,
197 enum bfa_ioim_event event
);
199 * forward declaration for BFA TSKIM functions
201 static void __bfa_cb_tskim_done(void *cbarg
, bfa_boolean_t complete
);
202 static void __bfa_cb_tskim_failed(void *cbarg
, bfa_boolean_t complete
);
203 static bfa_boolean_t
bfa_tskim_match_scope(struct bfa_tskim_s
*tskim
,
204 struct scsi_lun lun
);
205 static void bfa_tskim_gather_ios(struct bfa_tskim_s
*tskim
);
206 static void bfa_tskim_cleanp_comp(void *tskim_cbarg
);
207 static void bfa_tskim_cleanup_ios(struct bfa_tskim_s
*tskim
);
208 static bfa_boolean_t
bfa_tskim_send(struct bfa_tskim_s
*tskim
);
209 static bfa_boolean_t
bfa_tskim_send_abort(struct bfa_tskim_s
*tskim
);
210 static void bfa_tskim_iocdisable_ios(struct bfa_tskim_s
*tskim
);
213 * forward declaration of BFA TSKIM state machine
215 static void bfa_tskim_sm_uninit(struct bfa_tskim_s
*tskim
,
216 enum bfa_tskim_event event
);
217 static void bfa_tskim_sm_active(struct bfa_tskim_s
*tskim
,
218 enum bfa_tskim_event event
);
219 static void bfa_tskim_sm_cleanup(struct bfa_tskim_s
*tskim
,
220 enum bfa_tskim_event event
);
221 static void bfa_tskim_sm_iocleanup(struct bfa_tskim_s
*tskim
,
222 enum bfa_tskim_event event
);
223 static void bfa_tskim_sm_qfull(struct bfa_tskim_s
*tskim
,
224 enum bfa_tskim_event event
);
225 static void bfa_tskim_sm_cleanup_qfull(struct bfa_tskim_s
*tskim
,
226 enum bfa_tskim_event event
);
227 static void bfa_tskim_sm_hcb(struct bfa_tskim_s
*tskim
,
228 enum bfa_tskim_event event
);
230 * BFA FCP Initiator Mode module
234 * Compute and return memory needed by FCP(im) module.
237 bfa_fcpim_meminfo(struct bfa_iocfc_cfg_s
*cfg
, u32
*km_len
)
239 bfa_itnim_meminfo(cfg
, km_len
);
244 *km_len
+= cfg
->fwcfg
.num_ioim_reqs
*
245 (sizeof(struct bfa_ioim_s
) + sizeof(struct bfa_ioim_sp_s
));
248 * task management command memory
250 if (cfg
->fwcfg
.num_tskim_reqs
< BFA_TSKIM_MIN
)
251 cfg
->fwcfg
.num_tskim_reqs
= BFA_TSKIM_MIN
;
252 *km_len
+= cfg
->fwcfg
.num_tskim_reqs
* sizeof(struct bfa_tskim_s
);
257 bfa_fcpim_attach(struct bfa_fcp_mod_s
*fcp
, void *bfad
,
258 struct bfa_iocfc_cfg_s
*cfg
, struct bfa_pcidev_s
*pcidev
)
260 struct bfa_fcpim_s
*fcpim
= &fcp
->fcpim
;
261 struct bfa_s
*bfa
= fcp
->bfa
;
263 bfa_trc(bfa
, cfg
->drvcfg
.path_tov
);
264 bfa_trc(bfa
, cfg
->fwcfg
.num_rports
);
265 bfa_trc(bfa
, cfg
->fwcfg
.num_ioim_reqs
);
266 bfa_trc(bfa
, cfg
->fwcfg
.num_tskim_reqs
);
270 fcpim
->num_itnims
= cfg
->fwcfg
.num_rports
;
271 fcpim
->num_tskim_reqs
= cfg
->fwcfg
.num_tskim_reqs
;
272 fcpim
->path_tov
= cfg
->drvcfg
.path_tov
;
273 fcpim
->delay_comp
= cfg
->drvcfg
.delay_comp
;
274 fcpim
->profile_comp
= NULL
;
275 fcpim
->profile_start
= NULL
;
277 bfa_itnim_attach(fcpim
);
278 bfa_tskim_attach(fcpim
);
279 bfa_ioim_attach(fcpim
);
283 bfa_fcpim_iocdisable(struct bfa_fcp_mod_s
*fcp
)
285 struct bfa_fcpim_s
*fcpim
= &fcp
->fcpim
;
286 struct bfa_itnim_s
*itnim
;
287 struct list_head
*qe
, *qen
;
289 /* Enqueue unused ioim resources to free_q */
290 list_splice_tail_init(&fcpim
->tskim_unused_q
, &fcpim
->tskim_free_q
);
292 list_for_each_safe(qe
, qen
, &fcpim
->itnim_q
) {
293 itnim
= (struct bfa_itnim_s
*) qe
;
294 bfa_itnim_iocdisable(itnim
);
299 bfa_fcpim_path_tov_set(struct bfa_s
*bfa
, u16 path_tov
)
301 struct bfa_fcpim_s
*fcpim
= BFA_FCPIM(bfa
);
303 fcpim
->path_tov
= path_tov
* 1000;
304 if (fcpim
->path_tov
> BFA_FCPIM_PATHTOV_MAX
)
305 fcpim
->path_tov
= BFA_FCPIM_PATHTOV_MAX
;
309 bfa_fcpim_path_tov_get(struct bfa_s
*bfa
)
311 struct bfa_fcpim_s
*fcpim
= BFA_FCPIM(bfa
);
313 return fcpim
->path_tov
/ 1000;
316 #define bfa_fcpim_add_iostats(__l, __r, __stats) \
317 (__l->__stats += __r->__stats)
320 bfa_fcpim_add_stats(struct bfa_itnim_iostats_s
*lstats
,
321 struct bfa_itnim_iostats_s
*rstats
)
323 bfa_fcpim_add_iostats(lstats
, rstats
, total_ios
);
324 bfa_fcpim_add_iostats(lstats
, rstats
, qresumes
);
325 bfa_fcpim_add_iostats(lstats
, rstats
, no_iotags
);
326 bfa_fcpim_add_iostats(lstats
, rstats
, io_aborts
);
327 bfa_fcpim_add_iostats(lstats
, rstats
, no_tskims
);
328 bfa_fcpim_add_iostats(lstats
, rstats
, iocomp_ok
);
329 bfa_fcpim_add_iostats(lstats
, rstats
, iocomp_underrun
);
330 bfa_fcpim_add_iostats(lstats
, rstats
, iocomp_overrun
);
331 bfa_fcpim_add_iostats(lstats
, rstats
, iocomp_aborted
);
332 bfa_fcpim_add_iostats(lstats
, rstats
, iocomp_timedout
);
333 bfa_fcpim_add_iostats(lstats
, rstats
, iocom_nexus_abort
);
334 bfa_fcpim_add_iostats(lstats
, rstats
, iocom_proto_err
);
335 bfa_fcpim_add_iostats(lstats
, rstats
, iocom_dif_err
);
336 bfa_fcpim_add_iostats(lstats
, rstats
, iocom_sqer_needed
);
337 bfa_fcpim_add_iostats(lstats
, rstats
, iocom_res_free
);
338 bfa_fcpim_add_iostats(lstats
, rstats
, iocom_hostabrts
);
339 bfa_fcpim_add_iostats(lstats
, rstats
, iocom_utags
);
340 bfa_fcpim_add_iostats(lstats
, rstats
, io_cleanups
);
341 bfa_fcpim_add_iostats(lstats
, rstats
, io_tmaborts
);
342 bfa_fcpim_add_iostats(lstats
, rstats
, onlines
);
343 bfa_fcpim_add_iostats(lstats
, rstats
, offlines
);
344 bfa_fcpim_add_iostats(lstats
, rstats
, creates
);
345 bfa_fcpim_add_iostats(lstats
, rstats
, deletes
);
346 bfa_fcpim_add_iostats(lstats
, rstats
, create_comps
);
347 bfa_fcpim_add_iostats(lstats
, rstats
, delete_comps
);
348 bfa_fcpim_add_iostats(lstats
, rstats
, sler_events
);
349 bfa_fcpim_add_iostats(lstats
, rstats
, fw_create
);
350 bfa_fcpim_add_iostats(lstats
, rstats
, fw_delete
);
351 bfa_fcpim_add_iostats(lstats
, rstats
, ioc_disabled
);
352 bfa_fcpim_add_iostats(lstats
, rstats
, cleanup_comps
);
353 bfa_fcpim_add_iostats(lstats
, rstats
, tm_cmnds
);
354 bfa_fcpim_add_iostats(lstats
, rstats
, tm_fw_rsps
);
355 bfa_fcpim_add_iostats(lstats
, rstats
, tm_success
);
356 bfa_fcpim_add_iostats(lstats
, rstats
, tm_failures
);
357 bfa_fcpim_add_iostats(lstats
, rstats
, tm_io_comps
);
358 bfa_fcpim_add_iostats(lstats
, rstats
, tm_qresumes
);
359 bfa_fcpim_add_iostats(lstats
, rstats
, tm_iocdowns
);
360 bfa_fcpim_add_iostats(lstats
, rstats
, tm_cleanups
);
361 bfa_fcpim_add_iostats(lstats
, rstats
, tm_cleanup_comps
);
362 bfa_fcpim_add_iostats(lstats
, rstats
, io_comps
);
363 bfa_fcpim_add_iostats(lstats
, rstats
, input_reqs
);
364 bfa_fcpim_add_iostats(lstats
, rstats
, output_reqs
);
365 bfa_fcpim_add_iostats(lstats
, rstats
, rd_throughput
);
366 bfa_fcpim_add_iostats(lstats
, rstats
, wr_throughput
);
370 bfa_fcpim_port_iostats(struct bfa_s
*bfa
,
371 struct bfa_itnim_iostats_s
*stats
, u8 lp_tag
)
373 struct bfa_fcpim_s
*fcpim
= BFA_FCPIM(bfa
);
374 struct list_head
*qe
, *qen
;
375 struct bfa_itnim_s
*itnim
;
377 /* accumulate IO stats from itnim */
378 memset(stats
, 0, sizeof(struct bfa_itnim_iostats_s
));
379 list_for_each_safe(qe
, qen
, &fcpim
->itnim_q
) {
380 itnim
= (struct bfa_itnim_s
*) qe
;
381 if (itnim
->rport
->rport_info
.lp_tag
!= lp_tag
)
383 bfa_fcpim_add_stats(stats
, &(itnim
->stats
));
385 return BFA_STATUS_OK
;
389 bfa_ioim_profile_comp(struct bfa_ioim_s
*ioim
)
391 struct bfa_itnim_latency_s
*io_lat
=
392 &(ioim
->itnim
->ioprofile
.io_latency
);
395 val
= (u32
)(jiffies
- ioim
->start_time
);
396 idx
= bfa_ioim_get_index(scsi_bufflen((struct scsi_cmnd
*)ioim
->dio
));
397 bfa_itnim_ioprofile_update(ioim
->itnim
, idx
);
399 io_lat
->count
[idx
]++;
400 io_lat
->min
[idx
] = (io_lat
->min
[idx
] < val
) ? io_lat
->min
[idx
] : val
;
401 io_lat
->max
[idx
] = (io_lat
->max
[idx
] > val
) ? io_lat
->max
[idx
] : val
;
402 io_lat
->avg
[idx
] += val
;
406 bfa_ioim_profile_start(struct bfa_ioim_s
*ioim
)
408 ioim
->start_time
= jiffies
;
412 bfa_fcpim_profile_on(struct bfa_s
*bfa
, time64_t time
)
414 struct bfa_itnim_s
*itnim
;
415 struct bfa_fcpim_s
*fcpim
= BFA_FCPIM(bfa
);
416 struct list_head
*qe
, *qen
;
418 /* accumulate IO stats from itnim */
419 list_for_each_safe(qe
, qen
, &fcpim
->itnim_q
) {
420 itnim
= (struct bfa_itnim_s
*) qe
;
421 bfa_itnim_clear_stats(itnim
);
423 fcpim
->io_profile
= BFA_TRUE
;
424 fcpim
->io_profile_start_time
= time
;
425 fcpim
->profile_comp
= bfa_ioim_profile_comp
;
426 fcpim
->profile_start
= bfa_ioim_profile_start
;
427 return BFA_STATUS_OK
;
431 bfa_fcpim_profile_off(struct bfa_s
*bfa
)
433 struct bfa_fcpim_s
*fcpim
= BFA_FCPIM(bfa
);
434 fcpim
->io_profile
= BFA_FALSE
;
435 fcpim
->io_profile_start_time
= 0;
436 fcpim
->profile_comp
= NULL
;
437 fcpim
->profile_start
= NULL
;
438 return BFA_STATUS_OK
;
442 bfa_fcpim_qdepth_get(struct bfa_s
*bfa
)
444 struct bfa_fcpim_s
*fcpim
= BFA_FCPIM(bfa
);
446 return fcpim
->q_depth
;
450 * BFA ITNIM module state machine functions
454 * Beginning/unallocated state - no events expected.
457 bfa_itnim_sm_uninit(struct bfa_itnim_s
*itnim
, enum bfa_itnim_event event
)
459 bfa_trc(itnim
->bfa
, itnim
->rport
->rport_tag
);
460 bfa_trc(itnim
->bfa
, event
);
463 case BFA_ITNIM_SM_CREATE
:
464 bfa_sm_set_state(itnim
, bfa_itnim_sm_created
);
465 itnim
->is_online
= BFA_FALSE
;
466 bfa_fcpim_additn(itnim
);
470 bfa_sm_fault(itnim
->bfa
, event
);
475 * Beginning state, only online event expected.
478 bfa_itnim_sm_created(struct bfa_itnim_s
*itnim
, enum bfa_itnim_event event
)
480 bfa_trc(itnim
->bfa
, itnim
->rport
->rport_tag
);
481 bfa_trc(itnim
->bfa
, event
);
484 case BFA_ITNIM_SM_ONLINE
:
485 if (bfa_itnim_send_fwcreate(itnim
))
486 bfa_sm_set_state(itnim
, bfa_itnim_sm_fwcreate
);
488 bfa_sm_set_state(itnim
, bfa_itnim_sm_fwcreate_qfull
);
491 case BFA_ITNIM_SM_DELETE
:
492 bfa_sm_set_state(itnim
, bfa_itnim_sm_uninit
);
493 bfa_fcpim_delitn(itnim
);
496 case BFA_ITNIM_SM_HWFAIL
:
497 bfa_sm_set_state(itnim
, bfa_itnim_sm_iocdisable
);
501 bfa_sm_fault(itnim
->bfa
, event
);
506 * Waiting for itnim create response from firmware.
509 bfa_itnim_sm_fwcreate(struct bfa_itnim_s
*itnim
, enum bfa_itnim_event event
)
511 bfa_trc(itnim
->bfa
, itnim
->rport
->rport_tag
);
512 bfa_trc(itnim
->bfa
, event
);
515 case BFA_ITNIM_SM_FWRSP
:
516 bfa_sm_set_state(itnim
, bfa_itnim_sm_online
);
517 itnim
->is_online
= BFA_TRUE
;
518 bfa_itnim_iotov_online(itnim
);
519 bfa_itnim_online_cb(itnim
);
522 case BFA_ITNIM_SM_DELETE
:
523 bfa_sm_set_state(itnim
, bfa_itnim_sm_delete_pending
);
526 case BFA_ITNIM_SM_OFFLINE
:
527 if (bfa_itnim_send_fwdelete(itnim
))
528 bfa_sm_set_state(itnim
, bfa_itnim_sm_fwdelete
);
530 bfa_sm_set_state(itnim
, bfa_itnim_sm_fwdelete_qfull
);
533 case BFA_ITNIM_SM_HWFAIL
:
534 bfa_sm_set_state(itnim
, bfa_itnim_sm_iocdisable
);
538 bfa_sm_fault(itnim
->bfa
, event
);
543 bfa_itnim_sm_fwcreate_qfull(struct bfa_itnim_s
*itnim
,
544 enum bfa_itnim_event event
)
546 bfa_trc(itnim
->bfa
, itnim
->rport
->rport_tag
);
547 bfa_trc(itnim
->bfa
, event
);
550 case BFA_ITNIM_SM_QRESUME
:
551 bfa_sm_set_state(itnim
, bfa_itnim_sm_fwcreate
);
552 bfa_itnim_send_fwcreate(itnim
);
555 case BFA_ITNIM_SM_DELETE
:
556 bfa_sm_set_state(itnim
, bfa_itnim_sm_uninit
);
557 bfa_reqq_wcancel(&itnim
->reqq_wait
);
558 bfa_fcpim_delitn(itnim
);
561 case BFA_ITNIM_SM_OFFLINE
:
562 bfa_sm_set_state(itnim
, bfa_itnim_sm_offline
);
563 bfa_reqq_wcancel(&itnim
->reqq_wait
);
564 bfa_itnim_offline_cb(itnim
);
567 case BFA_ITNIM_SM_HWFAIL
:
568 bfa_sm_set_state(itnim
, bfa_itnim_sm_iocdisable
);
569 bfa_reqq_wcancel(&itnim
->reqq_wait
);
573 bfa_sm_fault(itnim
->bfa
, event
);
578 * Waiting for itnim create response from firmware, a delete is pending.
581 bfa_itnim_sm_delete_pending(struct bfa_itnim_s
*itnim
,
582 enum bfa_itnim_event event
)
584 bfa_trc(itnim
->bfa
, itnim
->rport
->rport_tag
);
585 bfa_trc(itnim
->bfa
, event
);
588 case BFA_ITNIM_SM_FWRSP
:
589 if (bfa_itnim_send_fwdelete(itnim
))
590 bfa_sm_set_state(itnim
, bfa_itnim_sm_deleting
);
592 bfa_sm_set_state(itnim
, bfa_itnim_sm_deleting_qfull
);
595 case BFA_ITNIM_SM_HWFAIL
:
596 bfa_sm_set_state(itnim
, bfa_itnim_sm_uninit
);
597 bfa_fcpim_delitn(itnim
);
601 bfa_sm_fault(itnim
->bfa
, event
);
606 * Online state - normal parking state.
609 bfa_itnim_sm_online(struct bfa_itnim_s
*itnim
, enum bfa_itnim_event event
)
611 bfa_trc(itnim
->bfa
, itnim
->rport
->rport_tag
);
612 bfa_trc(itnim
->bfa
, event
);
615 case BFA_ITNIM_SM_OFFLINE
:
616 bfa_sm_set_state(itnim
, bfa_itnim_sm_cleanup_offline
);
617 itnim
->is_online
= BFA_FALSE
;
618 bfa_itnim_iotov_start(itnim
);
619 bfa_itnim_cleanup(itnim
);
622 case BFA_ITNIM_SM_DELETE
:
623 bfa_sm_set_state(itnim
, bfa_itnim_sm_cleanup_delete
);
624 itnim
->is_online
= BFA_FALSE
;
625 bfa_itnim_cleanup(itnim
);
628 case BFA_ITNIM_SM_SLER
:
629 bfa_sm_set_state(itnim
, bfa_itnim_sm_sler
);
630 itnim
->is_online
= BFA_FALSE
;
631 bfa_itnim_iotov_start(itnim
);
632 bfa_itnim_sler_cb(itnim
);
635 case BFA_ITNIM_SM_HWFAIL
:
636 bfa_sm_set_state(itnim
, bfa_itnim_sm_iocdisable
);
637 itnim
->is_online
= BFA_FALSE
;
638 bfa_itnim_iotov_start(itnim
);
639 bfa_itnim_iocdisable_cleanup(itnim
);
643 bfa_sm_fault(itnim
->bfa
, event
);
648 * Second level error recovery need.
651 bfa_itnim_sm_sler(struct bfa_itnim_s
*itnim
, enum bfa_itnim_event event
)
653 bfa_trc(itnim
->bfa
, itnim
->rport
->rport_tag
);
654 bfa_trc(itnim
->bfa
, event
);
657 case BFA_ITNIM_SM_OFFLINE
:
658 bfa_sm_set_state(itnim
, bfa_itnim_sm_cleanup_offline
);
659 bfa_itnim_cleanup(itnim
);
662 case BFA_ITNIM_SM_DELETE
:
663 bfa_sm_set_state(itnim
, bfa_itnim_sm_cleanup_delete
);
664 bfa_itnim_cleanup(itnim
);
665 bfa_itnim_iotov_delete(itnim
);
668 case BFA_ITNIM_SM_HWFAIL
:
669 bfa_sm_set_state(itnim
, bfa_itnim_sm_iocdisable
);
670 bfa_itnim_iocdisable_cleanup(itnim
);
674 bfa_sm_fault(itnim
->bfa
, event
);
679 * Going offline. Waiting for active IO cleanup.
682 bfa_itnim_sm_cleanup_offline(struct bfa_itnim_s
*itnim
,
683 enum bfa_itnim_event event
)
685 bfa_trc(itnim
->bfa
, itnim
->rport
->rport_tag
);
686 bfa_trc(itnim
->bfa
, event
);
689 case BFA_ITNIM_SM_CLEANUP
:
690 if (bfa_itnim_send_fwdelete(itnim
))
691 bfa_sm_set_state(itnim
, bfa_itnim_sm_fwdelete
);
693 bfa_sm_set_state(itnim
, bfa_itnim_sm_fwdelete_qfull
);
696 case BFA_ITNIM_SM_DELETE
:
697 bfa_sm_set_state(itnim
, bfa_itnim_sm_cleanup_delete
);
698 bfa_itnim_iotov_delete(itnim
);
701 case BFA_ITNIM_SM_HWFAIL
:
702 bfa_sm_set_state(itnim
, bfa_itnim_sm_iocdisable
);
703 bfa_itnim_iocdisable_cleanup(itnim
);
704 bfa_itnim_offline_cb(itnim
);
707 case BFA_ITNIM_SM_SLER
:
711 bfa_sm_fault(itnim
->bfa
, event
);
716 * Deleting itnim. Waiting for active IO cleanup.
719 bfa_itnim_sm_cleanup_delete(struct bfa_itnim_s
*itnim
,
720 enum bfa_itnim_event event
)
722 bfa_trc(itnim
->bfa
, itnim
->rport
->rport_tag
);
723 bfa_trc(itnim
->bfa
, event
);
726 case BFA_ITNIM_SM_CLEANUP
:
727 if (bfa_itnim_send_fwdelete(itnim
))
728 bfa_sm_set_state(itnim
, bfa_itnim_sm_deleting
);
730 bfa_sm_set_state(itnim
, bfa_itnim_sm_deleting_qfull
);
733 case BFA_ITNIM_SM_HWFAIL
:
734 bfa_sm_set_state(itnim
, bfa_itnim_sm_iocdisable
);
735 bfa_itnim_iocdisable_cleanup(itnim
);
739 bfa_sm_fault(itnim
->bfa
, event
);
744 * Rport offline. Fimrware itnim is being deleted - awaiting f/w response.
747 bfa_itnim_sm_fwdelete(struct bfa_itnim_s
*itnim
, enum bfa_itnim_event event
)
749 bfa_trc(itnim
->bfa
, itnim
->rport
->rport_tag
);
750 bfa_trc(itnim
->bfa
, event
);
753 case BFA_ITNIM_SM_FWRSP
:
754 bfa_sm_set_state(itnim
, bfa_itnim_sm_offline
);
755 bfa_itnim_offline_cb(itnim
);
758 case BFA_ITNIM_SM_DELETE
:
759 bfa_sm_set_state(itnim
, bfa_itnim_sm_deleting
);
762 case BFA_ITNIM_SM_HWFAIL
:
763 bfa_sm_set_state(itnim
, bfa_itnim_sm_iocdisable
);
764 bfa_itnim_offline_cb(itnim
);
768 bfa_sm_fault(itnim
->bfa
, event
);
773 bfa_itnim_sm_fwdelete_qfull(struct bfa_itnim_s
*itnim
,
774 enum bfa_itnim_event event
)
776 bfa_trc(itnim
->bfa
, itnim
->rport
->rport_tag
);
777 bfa_trc(itnim
->bfa
, event
);
780 case BFA_ITNIM_SM_QRESUME
:
781 bfa_sm_set_state(itnim
, bfa_itnim_sm_fwdelete
);
782 bfa_itnim_send_fwdelete(itnim
);
785 case BFA_ITNIM_SM_DELETE
:
786 bfa_sm_set_state(itnim
, bfa_itnim_sm_deleting_qfull
);
789 case BFA_ITNIM_SM_HWFAIL
:
790 bfa_sm_set_state(itnim
, bfa_itnim_sm_iocdisable
);
791 bfa_reqq_wcancel(&itnim
->reqq_wait
);
792 bfa_itnim_offline_cb(itnim
);
796 bfa_sm_fault(itnim
->bfa
, event
);
804 bfa_itnim_sm_offline(struct bfa_itnim_s
*itnim
, enum bfa_itnim_event event
)
806 bfa_trc(itnim
->bfa
, itnim
->rport
->rport_tag
);
807 bfa_trc(itnim
->bfa
, event
);
810 case BFA_ITNIM_SM_DELETE
:
811 bfa_sm_set_state(itnim
, bfa_itnim_sm_uninit
);
812 bfa_itnim_iotov_delete(itnim
);
813 bfa_fcpim_delitn(itnim
);
816 case BFA_ITNIM_SM_ONLINE
:
817 if (bfa_itnim_send_fwcreate(itnim
))
818 bfa_sm_set_state(itnim
, bfa_itnim_sm_fwcreate
);
820 bfa_sm_set_state(itnim
, bfa_itnim_sm_fwcreate_qfull
);
823 case BFA_ITNIM_SM_HWFAIL
:
824 bfa_sm_set_state(itnim
, bfa_itnim_sm_iocdisable
);
828 bfa_sm_fault(itnim
->bfa
, event
);
833 bfa_itnim_sm_iocdisable(struct bfa_itnim_s
*itnim
,
834 enum bfa_itnim_event event
)
836 bfa_trc(itnim
->bfa
, itnim
->rport
->rport_tag
);
837 bfa_trc(itnim
->bfa
, event
);
840 case BFA_ITNIM_SM_DELETE
:
841 bfa_sm_set_state(itnim
, bfa_itnim_sm_uninit
);
842 bfa_itnim_iotov_delete(itnim
);
843 bfa_fcpim_delitn(itnim
);
846 case BFA_ITNIM_SM_OFFLINE
:
847 bfa_itnim_offline_cb(itnim
);
850 case BFA_ITNIM_SM_ONLINE
:
851 if (bfa_itnim_send_fwcreate(itnim
))
852 bfa_sm_set_state(itnim
, bfa_itnim_sm_fwcreate
);
854 bfa_sm_set_state(itnim
, bfa_itnim_sm_fwcreate_qfull
);
857 case BFA_ITNIM_SM_HWFAIL
:
861 bfa_sm_fault(itnim
->bfa
, event
);
866 * Itnim is deleted, waiting for firmware response to delete.
869 bfa_itnim_sm_deleting(struct bfa_itnim_s
*itnim
, enum bfa_itnim_event event
)
871 bfa_trc(itnim
->bfa
, itnim
->rport
->rport_tag
);
872 bfa_trc(itnim
->bfa
, event
);
875 case BFA_ITNIM_SM_FWRSP
:
876 case BFA_ITNIM_SM_HWFAIL
:
877 bfa_sm_set_state(itnim
, bfa_itnim_sm_uninit
);
878 bfa_fcpim_delitn(itnim
);
882 bfa_sm_fault(itnim
->bfa
, event
);
887 bfa_itnim_sm_deleting_qfull(struct bfa_itnim_s
*itnim
,
888 enum bfa_itnim_event event
)
890 bfa_trc(itnim
->bfa
, itnim
->rport
->rport_tag
);
891 bfa_trc(itnim
->bfa
, event
);
894 case BFA_ITNIM_SM_QRESUME
:
895 bfa_sm_set_state(itnim
, bfa_itnim_sm_deleting
);
896 bfa_itnim_send_fwdelete(itnim
);
899 case BFA_ITNIM_SM_HWFAIL
:
900 bfa_sm_set_state(itnim
, bfa_itnim_sm_uninit
);
901 bfa_reqq_wcancel(&itnim
->reqq_wait
);
902 bfa_fcpim_delitn(itnim
);
906 bfa_sm_fault(itnim
->bfa
, event
);
911 * Initiate cleanup of all IOs on an IOC failure.
914 bfa_itnim_iocdisable_cleanup(struct bfa_itnim_s
*itnim
)
916 struct bfa_tskim_s
*tskim
;
917 struct bfa_ioim_s
*ioim
;
918 struct list_head
*qe
, *qen
;
920 list_for_each_safe(qe
, qen
, &itnim
->tsk_q
) {
921 tskim
= (struct bfa_tskim_s
*) qe
;
922 bfa_tskim_iocdisable(tskim
);
925 list_for_each_safe(qe
, qen
, &itnim
->io_q
) {
926 ioim
= (struct bfa_ioim_s
*) qe
;
927 bfa_ioim_iocdisable(ioim
);
931 * For IO request in pending queue, we pretend an early timeout.
933 list_for_each_safe(qe
, qen
, &itnim
->pending_q
) {
934 ioim
= (struct bfa_ioim_s
*) qe
;
938 list_for_each_safe(qe
, qen
, &itnim
->io_cleanup_q
) {
939 ioim
= (struct bfa_ioim_s
*) qe
;
940 bfa_ioim_iocdisable(ioim
);
945 * IO cleanup completion
948 bfa_itnim_cleanp_comp(void *itnim_cbarg
)
950 struct bfa_itnim_s
*itnim
= itnim_cbarg
;
952 bfa_stats(itnim
, cleanup_comps
);
953 bfa_sm_send_event(itnim
, BFA_ITNIM_SM_CLEANUP
);
957 * Initiate cleanup of all IOs.
960 bfa_itnim_cleanup(struct bfa_itnim_s
*itnim
)
962 struct bfa_ioim_s
*ioim
;
963 struct bfa_tskim_s
*tskim
;
964 struct list_head
*qe
, *qen
;
966 bfa_wc_init(&itnim
->wc
, bfa_itnim_cleanp_comp
, itnim
);
968 list_for_each_safe(qe
, qen
, &itnim
->io_q
) {
969 ioim
= (struct bfa_ioim_s
*) qe
;
972 * Move IO to a cleanup queue from active queue so that a later
973 * TM will not pickup this IO.
976 list_add_tail(&ioim
->qe
, &itnim
->io_cleanup_q
);
978 bfa_wc_up(&itnim
->wc
);
979 bfa_ioim_cleanup(ioim
);
982 list_for_each_safe(qe
, qen
, &itnim
->tsk_q
) {
983 tskim
= (struct bfa_tskim_s
*) qe
;
984 bfa_wc_up(&itnim
->wc
);
985 bfa_tskim_cleanup(tskim
);
988 bfa_wc_wait(&itnim
->wc
);
992 __bfa_cb_itnim_online(void *cbarg
, bfa_boolean_t complete
)
994 struct bfa_itnim_s
*itnim
= cbarg
;
997 bfa_cb_itnim_online(itnim
->ditn
);
1001 __bfa_cb_itnim_offline(void *cbarg
, bfa_boolean_t complete
)
1003 struct bfa_itnim_s
*itnim
= cbarg
;
1006 bfa_cb_itnim_offline(itnim
->ditn
);
1010 __bfa_cb_itnim_sler(void *cbarg
, bfa_boolean_t complete
)
1012 struct bfa_itnim_s
*itnim
= cbarg
;
1015 bfa_cb_itnim_sler(itnim
->ditn
);
1019 * Call to resume any I/O requests waiting for room in request queue.
1022 bfa_itnim_qresume(void *cbarg
)
1024 struct bfa_itnim_s
*itnim
= cbarg
;
1026 bfa_sm_send_event(itnim
, BFA_ITNIM_SM_QRESUME
);
1034 bfa_itnim_iodone(struct bfa_itnim_s
*itnim
)
1036 bfa_wc_down(&itnim
->wc
);
1040 bfa_itnim_tskdone(struct bfa_itnim_s
*itnim
)
1042 bfa_wc_down(&itnim
->wc
);
1046 bfa_itnim_meminfo(struct bfa_iocfc_cfg_s
*cfg
, u32
*km_len
)
1051 *km_len
+= cfg
->fwcfg
.num_rports
* sizeof(struct bfa_itnim_s
);
1055 bfa_itnim_attach(struct bfa_fcpim_s
*fcpim
)
1057 struct bfa_s
*bfa
= fcpim
->bfa
;
1058 struct bfa_fcp_mod_s
*fcp
= fcpim
->fcp
;
1059 struct bfa_itnim_s
*itnim
;
1062 INIT_LIST_HEAD(&fcpim
->itnim_q
);
1064 itnim
= (struct bfa_itnim_s
*) bfa_mem_kva_curp(fcp
);
1065 fcpim
->itnim_arr
= itnim
;
1067 for (i
= 0; i
< fcpim
->num_itnims
; i
++, itnim
++) {
1068 memset(itnim
, 0, sizeof(struct bfa_itnim_s
));
1070 itnim
->fcpim
= fcpim
;
1071 itnim
->reqq
= BFA_REQQ_QOS_LO
;
1072 itnim
->rport
= BFA_RPORT_FROM_TAG(bfa
, i
);
1073 itnim
->iotov_active
= BFA_FALSE
;
1074 bfa_reqq_winit(&itnim
->reqq_wait
, bfa_itnim_qresume
, itnim
);
1076 INIT_LIST_HEAD(&itnim
->io_q
);
1077 INIT_LIST_HEAD(&itnim
->io_cleanup_q
);
1078 INIT_LIST_HEAD(&itnim
->pending_q
);
1079 INIT_LIST_HEAD(&itnim
->tsk_q
);
1080 INIT_LIST_HEAD(&itnim
->delay_comp_q
);
1081 for (j
= 0; j
< BFA_IOBUCKET_MAX
; j
++)
1082 itnim
->ioprofile
.io_latency
.min
[j
] = ~0;
1083 bfa_sm_set_state(itnim
, bfa_itnim_sm_uninit
);
1086 bfa_mem_kva_curp(fcp
) = (u8
*) itnim
;
1090 bfa_itnim_iocdisable(struct bfa_itnim_s
*itnim
)
1092 bfa_stats(itnim
, ioc_disabled
);
1093 bfa_sm_send_event(itnim
, BFA_ITNIM_SM_HWFAIL
);
1096 static bfa_boolean_t
1097 bfa_itnim_send_fwcreate(struct bfa_itnim_s
*itnim
)
1099 struct bfi_itn_create_req_s
*m
;
1104 * check for room in queue to send request now
1106 m
= bfa_reqq_next(itnim
->bfa
, itnim
->reqq
);
1108 bfa_reqq_wait(itnim
->bfa
, itnim
->reqq
, &itnim
->reqq_wait
);
1112 bfi_h2i_set(m
->mh
, BFI_MC_ITN
, BFI_ITN_H2I_CREATE_REQ
,
1113 bfa_fn_lpu(itnim
->bfa
));
1114 m
->fw_handle
= itnim
->rport
->fw_handle
;
1115 m
->class = FC_CLASS_3
;
1116 m
->seq_rec
= itnim
->seq_rec
;
1117 m
->msg_no
= itnim
->msg_no
;
1118 bfa_stats(itnim
, fw_create
);
1121 * queue I/O message to firmware
1123 bfa_reqq_produce(itnim
->bfa
, itnim
->reqq
, m
->mh
);
1127 static bfa_boolean_t
1128 bfa_itnim_send_fwdelete(struct bfa_itnim_s
*itnim
)
1130 struct bfi_itn_delete_req_s
*m
;
1133 * check for room in queue to send request now
1135 m
= bfa_reqq_next(itnim
->bfa
, itnim
->reqq
);
1137 bfa_reqq_wait(itnim
->bfa
, itnim
->reqq
, &itnim
->reqq_wait
);
1141 bfi_h2i_set(m
->mh
, BFI_MC_ITN
, BFI_ITN_H2I_DELETE_REQ
,
1142 bfa_fn_lpu(itnim
->bfa
));
1143 m
->fw_handle
= itnim
->rport
->fw_handle
;
1144 bfa_stats(itnim
, fw_delete
);
1147 * queue I/O message to firmware
1149 bfa_reqq_produce(itnim
->bfa
, itnim
->reqq
, m
->mh
);
1154 * Cleanup all pending failed inflight requests.
1157 bfa_itnim_delayed_comp(struct bfa_itnim_s
*itnim
, bfa_boolean_t iotov
)
1159 struct bfa_ioim_s
*ioim
;
1160 struct list_head
*qe
, *qen
;
1162 list_for_each_safe(qe
, qen
, &itnim
->delay_comp_q
) {
1163 ioim
= (struct bfa_ioim_s
*)qe
;
1164 bfa_ioim_delayed_comp(ioim
, iotov
);
1169 * Start all pending IO requests.
1172 bfa_itnim_iotov_online(struct bfa_itnim_s
*itnim
)
1174 struct bfa_ioim_s
*ioim
;
1176 bfa_itnim_iotov_stop(itnim
);
1179 * Abort all inflight IO requests in the queue
1181 bfa_itnim_delayed_comp(itnim
, BFA_FALSE
);
1184 * Start all pending IO requests.
1186 while (!list_empty(&itnim
->pending_q
)) {
1187 bfa_q_deq(&itnim
->pending_q
, &ioim
);
1188 list_add_tail(&ioim
->qe
, &itnim
->io_q
);
1189 bfa_ioim_start(ioim
);
1194 * Fail all pending IO requests
1197 bfa_itnim_iotov_cleanup(struct bfa_itnim_s
*itnim
)
1199 struct bfa_ioim_s
*ioim
;
1202 * Fail all inflight IO requests in the queue
1204 bfa_itnim_delayed_comp(itnim
, BFA_TRUE
);
1207 * Fail any pending IO requests.
1209 while (!list_empty(&itnim
->pending_q
)) {
1210 bfa_q_deq(&itnim
->pending_q
, &ioim
);
1211 list_add_tail(&ioim
->qe
, &ioim
->fcpim
->ioim_comp_q
);
1217 * IO TOV timer callback. Fail any pending IO requests.
1220 bfa_itnim_iotov(void *itnim_arg
)
1222 struct bfa_itnim_s
*itnim
= itnim_arg
;
1224 itnim
->iotov_active
= BFA_FALSE
;
1226 bfa_cb_itnim_tov_begin(itnim
->ditn
);
1227 bfa_itnim_iotov_cleanup(itnim
);
1228 bfa_cb_itnim_tov(itnim
->ditn
);
1232 * Start IO TOV timer for failing back pending IO requests in offline state.
1235 bfa_itnim_iotov_start(struct bfa_itnim_s
*itnim
)
1237 if (itnim
->fcpim
->path_tov
> 0) {
1239 itnim
->iotov_active
= BFA_TRUE
;
1240 WARN_ON(!bfa_itnim_hold_io(itnim
));
1241 bfa_timer_start(itnim
->bfa
, &itnim
->timer
,
1242 bfa_itnim_iotov
, itnim
, itnim
->fcpim
->path_tov
);
1247 * Stop IO TOV timer.
1250 bfa_itnim_iotov_stop(struct bfa_itnim_s
*itnim
)
1252 if (itnim
->iotov_active
) {
1253 itnim
->iotov_active
= BFA_FALSE
;
1254 bfa_timer_stop(&itnim
->timer
);
1259 * Stop IO TOV timer.
1262 bfa_itnim_iotov_delete(struct bfa_itnim_s
*itnim
)
1264 bfa_boolean_t pathtov_active
= BFA_FALSE
;
1266 if (itnim
->iotov_active
)
1267 pathtov_active
= BFA_TRUE
;
1269 bfa_itnim_iotov_stop(itnim
);
1271 bfa_cb_itnim_tov_begin(itnim
->ditn
);
1272 bfa_itnim_iotov_cleanup(itnim
);
1274 bfa_cb_itnim_tov(itnim
->ditn
);
1278 bfa_itnim_update_del_itn_stats(struct bfa_itnim_s
*itnim
)
1280 struct bfa_fcpim_s
*fcpim
= BFA_FCPIM(itnim
->bfa
);
1281 fcpim
->del_itn_stats
.del_itn_iocomp_aborted
+=
1282 itnim
->stats
.iocomp_aborted
;
1283 fcpim
->del_itn_stats
.del_itn_iocomp_timedout
+=
1284 itnim
->stats
.iocomp_timedout
;
1285 fcpim
->del_itn_stats
.del_itn_iocom_sqer_needed
+=
1286 itnim
->stats
.iocom_sqer_needed
;
1287 fcpim
->del_itn_stats
.del_itn_iocom_res_free
+=
1288 itnim
->stats
.iocom_res_free
;
1289 fcpim
->del_itn_stats
.del_itn_iocom_hostabrts
+=
1290 itnim
->stats
.iocom_hostabrts
;
1291 fcpim
->del_itn_stats
.del_itn_total_ios
+= itnim
->stats
.total_ios
;
1292 fcpim
->del_itn_stats
.del_io_iocdowns
+= itnim
->stats
.io_iocdowns
;
1293 fcpim
->del_itn_stats
.del_tm_iocdowns
+= itnim
->stats
.tm_iocdowns
;
1301 * Itnim interrupt processing.
1304 bfa_itnim_isr(struct bfa_s
*bfa
, struct bfi_msg_s
*m
)
1306 struct bfa_fcpim_s
*fcpim
= BFA_FCPIM(bfa
);
1307 union bfi_itn_i2h_msg_u msg
;
1308 struct bfa_itnim_s
*itnim
;
1310 bfa_trc(bfa
, m
->mhdr
.msg_id
);
1314 switch (m
->mhdr
.msg_id
) {
1315 case BFI_ITN_I2H_CREATE_RSP
:
1316 itnim
= BFA_ITNIM_FROM_TAG(fcpim
,
1317 msg
.create_rsp
->bfa_handle
);
1318 WARN_ON(msg
.create_rsp
->status
!= BFA_STATUS_OK
);
1319 bfa_stats(itnim
, create_comps
);
1320 bfa_sm_send_event(itnim
, BFA_ITNIM_SM_FWRSP
);
1323 case BFI_ITN_I2H_DELETE_RSP
:
1324 itnim
= BFA_ITNIM_FROM_TAG(fcpim
,
1325 msg
.delete_rsp
->bfa_handle
);
1326 WARN_ON(msg
.delete_rsp
->status
!= BFA_STATUS_OK
);
1327 bfa_stats(itnim
, delete_comps
);
1328 bfa_sm_send_event(itnim
, BFA_ITNIM_SM_FWRSP
);
1331 case BFI_ITN_I2H_SLER_EVENT
:
1332 itnim
= BFA_ITNIM_FROM_TAG(fcpim
,
1333 msg
.sler_event
->bfa_handle
);
1334 bfa_stats(itnim
, sler_events
);
1335 bfa_sm_send_event(itnim
, BFA_ITNIM_SM_SLER
);
1339 bfa_trc(bfa
, m
->mhdr
.msg_id
);
1348 struct bfa_itnim_s
*
1349 bfa_itnim_create(struct bfa_s
*bfa
, struct bfa_rport_s
*rport
, void *ditn
)
1351 struct bfa_fcpim_s
*fcpim
= BFA_FCPIM(bfa
);
1352 struct bfa_itnim_s
*itnim
;
1354 bfa_itn_create(bfa
, rport
, bfa_itnim_isr
);
1356 itnim
= BFA_ITNIM_FROM_TAG(fcpim
, rport
->rport_tag
);
1357 WARN_ON(itnim
->rport
!= rport
);
1361 bfa_stats(itnim
, creates
);
1362 bfa_sm_send_event(itnim
, BFA_ITNIM_SM_CREATE
);
1368 bfa_itnim_delete(struct bfa_itnim_s
*itnim
)
1370 bfa_stats(itnim
, deletes
);
1371 bfa_sm_send_event(itnim
, BFA_ITNIM_SM_DELETE
);
1375 bfa_itnim_online(struct bfa_itnim_s
*itnim
, bfa_boolean_t seq_rec
)
1377 itnim
->seq_rec
= seq_rec
;
1378 bfa_stats(itnim
, onlines
);
1379 bfa_sm_send_event(itnim
, BFA_ITNIM_SM_ONLINE
);
1383 bfa_itnim_offline(struct bfa_itnim_s
*itnim
)
1385 bfa_stats(itnim
, offlines
);
1386 bfa_sm_send_event(itnim
, BFA_ITNIM_SM_OFFLINE
);
1390 * Return true if itnim is considered offline for holding off IO request.
1391 * IO is not held if itnim is being deleted.
1394 bfa_itnim_hold_io(struct bfa_itnim_s
*itnim
)
1396 return itnim
->fcpim
->path_tov
&& itnim
->iotov_active
&&
1397 (bfa_sm_cmp_state(itnim
, bfa_itnim_sm_fwcreate
) ||
1398 bfa_sm_cmp_state(itnim
, bfa_itnim_sm_sler
) ||
1399 bfa_sm_cmp_state(itnim
, bfa_itnim_sm_cleanup_offline
) ||
1400 bfa_sm_cmp_state(itnim
, bfa_itnim_sm_fwdelete
) ||
1401 bfa_sm_cmp_state(itnim
, bfa_itnim_sm_offline
) ||
1402 bfa_sm_cmp_state(itnim
, bfa_itnim_sm_iocdisable
));
1405 #define bfa_io_lat_clock_res_div HZ
1406 #define bfa_io_lat_clock_res_mul 1000
1408 bfa_itnim_get_ioprofile(struct bfa_itnim_s
*itnim
,
1409 struct bfa_itnim_ioprofile_s
*ioprofile
)
1411 struct bfa_fcpim_s
*fcpim
;
1414 return BFA_STATUS_NO_FCPIM_NEXUS
;
1416 fcpim
= BFA_FCPIM(itnim
->bfa
);
1418 if (!fcpim
->io_profile
)
1419 return BFA_STATUS_IOPROFILE_OFF
;
1421 itnim
->ioprofile
.index
= BFA_IOBUCKET_MAX
;
1422 /* unsigned 32-bit time_t overflow here in y2106 */
1423 itnim
->ioprofile
.io_profile_start_time
=
1424 bfa_io_profile_start_time(itnim
->bfa
);
1425 itnim
->ioprofile
.clock_res_mul
= bfa_io_lat_clock_res_mul
;
1426 itnim
->ioprofile
.clock_res_div
= bfa_io_lat_clock_res_div
;
1427 *ioprofile
= itnim
->ioprofile
;
1429 return BFA_STATUS_OK
;
1433 bfa_itnim_clear_stats(struct bfa_itnim_s
*itnim
)
1440 memset(&itnim
->stats
, 0, sizeof(itnim
->stats
));
1441 memset(&itnim
->ioprofile
, 0, sizeof(itnim
->ioprofile
));
1442 for (j
= 0; j
< BFA_IOBUCKET_MAX
; j
++)
1443 itnim
->ioprofile
.io_latency
.min
[j
] = ~0;
1447 * BFA IO module state machine functions
1451 * IO is not started (unallocated).
1454 bfa_ioim_sm_uninit(struct bfa_ioim_s
*ioim
, enum bfa_ioim_event event
)
1457 case BFA_IOIM_SM_START
:
1458 if (!bfa_itnim_is_online(ioim
->itnim
)) {
1459 if (!bfa_itnim_hold_io(ioim
->itnim
)) {
1460 bfa_sm_set_state(ioim
, bfa_ioim_sm_hcb
);
1461 list_del(&ioim
->qe
);
1462 list_add_tail(&ioim
->qe
,
1463 &ioim
->fcpim
->ioim_comp_q
);
1464 bfa_cb_queue(ioim
->bfa
, &ioim
->hcb_qe
,
1465 __bfa_cb_ioim_pathtov
, ioim
);
1467 list_del(&ioim
->qe
);
1468 list_add_tail(&ioim
->qe
,
1469 &ioim
->itnim
->pending_q
);
1474 if (ioim
->nsges
> BFI_SGE_INLINE
) {
1475 if (!bfa_ioim_sgpg_alloc(ioim
)) {
1476 bfa_sm_set_state(ioim
, bfa_ioim_sm_sgalloc
);
1481 if (!bfa_ioim_send_ioreq(ioim
)) {
1482 bfa_sm_set_state(ioim
, bfa_ioim_sm_qfull
);
1486 bfa_sm_set_state(ioim
, bfa_ioim_sm_active
);
1489 case BFA_IOIM_SM_IOTOV
:
1490 bfa_sm_set_state(ioim
, bfa_ioim_sm_hcb
);
1491 bfa_ioim_move_to_comp_q(ioim
);
1492 bfa_cb_queue(ioim
->bfa
, &ioim
->hcb_qe
,
1493 __bfa_cb_ioim_pathtov
, ioim
);
1496 case BFA_IOIM_SM_ABORT
:
1498 * IO in pending queue can get abort requests. Complete abort
1499 * requests immediately.
1501 bfa_sm_set_state(ioim
, bfa_ioim_sm_hcb
);
1502 WARN_ON(!bfa_q_is_on_q(&ioim
->itnim
->pending_q
, ioim
));
1503 bfa_cb_queue(ioim
->bfa
, &ioim
->hcb_qe
,
1504 __bfa_cb_ioim_abort
, ioim
);
1508 bfa_sm_fault(ioim
->bfa
, event
);
1513 * IO is waiting for SG pages.
1516 bfa_ioim_sm_sgalloc(struct bfa_ioim_s
*ioim
, enum bfa_ioim_event event
)
1518 bfa_trc(ioim
->bfa
, ioim
->iotag
);
1519 bfa_trc(ioim
->bfa
, event
);
1522 case BFA_IOIM_SM_SGALLOCED
:
1523 if (!bfa_ioim_send_ioreq(ioim
)) {
1524 bfa_sm_set_state(ioim
, bfa_ioim_sm_qfull
);
1527 bfa_sm_set_state(ioim
, bfa_ioim_sm_active
);
1530 case BFA_IOIM_SM_CLEANUP
:
1531 bfa_sm_set_state(ioim
, bfa_ioim_sm_hcb
);
1532 bfa_sgpg_wcancel(ioim
->bfa
, &ioim
->iosp
->sgpg_wqe
);
1533 bfa_cb_queue(ioim
->bfa
, &ioim
->hcb_qe
, __bfa_cb_ioim_failed
,
1535 bfa_ioim_notify_cleanup(ioim
);
1538 case BFA_IOIM_SM_ABORT
:
1539 bfa_sm_set_state(ioim
, bfa_ioim_sm_hcb
);
1540 bfa_sgpg_wcancel(ioim
->bfa
, &ioim
->iosp
->sgpg_wqe
);
1541 bfa_ioim_move_to_comp_q(ioim
);
1542 bfa_cb_queue(ioim
->bfa
, &ioim
->hcb_qe
, __bfa_cb_ioim_abort
,
1546 case BFA_IOIM_SM_HWFAIL
:
1547 bfa_sm_set_state(ioim
, bfa_ioim_sm_hcb
);
1548 bfa_sgpg_wcancel(ioim
->bfa
, &ioim
->iosp
->sgpg_wqe
);
1549 bfa_ioim_move_to_comp_q(ioim
);
1550 bfa_cb_queue(ioim
->bfa
, &ioim
->hcb_qe
, __bfa_cb_ioim_failed
,
1555 bfa_sm_fault(ioim
->bfa
, event
);
1563 bfa_ioim_sm_active(struct bfa_ioim_s
*ioim
, enum bfa_ioim_event event
)
1566 case BFA_IOIM_SM_COMP_GOOD
:
1567 bfa_sm_set_state(ioim
, bfa_ioim_sm_hcb
);
1568 bfa_ioim_move_to_comp_q(ioim
);
1569 bfa_cb_queue(ioim
->bfa
, &ioim
->hcb_qe
,
1570 __bfa_cb_ioim_good_comp
, ioim
);
1573 case BFA_IOIM_SM_COMP
:
1574 bfa_sm_set_state(ioim
, bfa_ioim_sm_hcb
);
1575 bfa_ioim_move_to_comp_q(ioim
);
1576 bfa_cb_queue(ioim
->bfa
, &ioim
->hcb_qe
, __bfa_cb_ioim_comp
,
1580 case BFA_IOIM_SM_DONE
:
1581 bfa_sm_set_state(ioim
, bfa_ioim_sm_hcb_free
);
1582 bfa_ioim_move_to_comp_q(ioim
);
1583 bfa_cb_queue(ioim
->bfa
, &ioim
->hcb_qe
, __bfa_cb_ioim_comp
,
1587 case BFA_IOIM_SM_ABORT
:
1588 ioim
->iosp
->abort_explicit
= BFA_TRUE
;
1589 ioim
->io_cbfn
= __bfa_cb_ioim_abort
;
1591 if (bfa_ioim_send_abort(ioim
))
1592 bfa_sm_set_state(ioim
, bfa_ioim_sm_abort
);
1594 bfa_sm_set_state(ioim
, bfa_ioim_sm_abort_qfull
);
1595 bfa_stats(ioim
->itnim
, qwait
);
1596 bfa_reqq_wait(ioim
->bfa
, ioim
->reqq
,
1597 &ioim
->iosp
->reqq_wait
);
1601 case BFA_IOIM_SM_CLEANUP
:
1602 ioim
->iosp
->abort_explicit
= BFA_FALSE
;
1603 ioim
->io_cbfn
= __bfa_cb_ioim_failed
;
1605 if (bfa_ioim_send_abort(ioim
))
1606 bfa_sm_set_state(ioim
, bfa_ioim_sm_cleanup
);
1608 bfa_sm_set_state(ioim
, bfa_ioim_sm_cleanup_qfull
);
1609 bfa_stats(ioim
->itnim
, qwait
);
1610 bfa_reqq_wait(ioim
->bfa
, ioim
->reqq
,
1611 &ioim
->iosp
->reqq_wait
);
1615 case BFA_IOIM_SM_HWFAIL
:
1616 bfa_sm_set_state(ioim
, bfa_ioim_sm_hcb
);
1617 bfa_ioim_move_to_comp_q(ioim
);
1618 bfa_cb_queue(ioim
->bfa
, &ioim
->hcb_qe
, __bfa_cb_ioim_failed
,
1622 case BFA_IOIM_SM_SQRETRY
:
1623 if (bfa_ioim_maxretry_reached(ioim
)) {
1624 /* max retry reached, free IO */
1625 bfa_sm_set_state(ioim
, bfa_ioim_sm_hcb_free
);
1626 bfa_ioim_move_to_comp_q(ioim
);
1627 bfa_cb_queue(ioim
->bfa
, &ioim
->hcb_qe
,
1628 __bfa_cb_ioim_failed
, ioim
);
1631 /* waiting for IO tag resource free */
1632 bfa_sm_set_state(ioim
, bfa_ioim_sm_cmnd_retry
);
1636 bfa_sm_fault(ioim
->bfa
, event
);
1641 * IO is retried with new tag.
1644 bfa_ioim_sm_cmnd_retry(struct bfa_ioim_s
*ioim
, enum bfa_ioim_event event
)
1647 case BFA_IOIM_SM_FREE
:
1648 /* abts and rrq done. Now retry the IO with new tag */
1649 bfa_ioim_update_iotag(ioim
);
1650 if (!bfa_ioim_send_ioreq(ioim
)) {
1651 bfa_sm_set_state(ioim
, bfa_ioim_sm_qfull
);
1654 bfa_sm_set_state(ioim
, bfa_ioim_sm_active
);
1657 case BFA_IOIM_SM_CLEANUP
:
1658 ioim
->iosp
->abort_explicit
= BFA_FALSE
;
1659 ioim
->io_cbfn
= __bfa_cb_ioim_failed
;
1661 if (bfa_ioim_send_abort(ioim
))
1662 bfa_sm_set_state(ioim
, bfa_ioim_sm_cleanup
);
1664 bfa_sm_set_state(ioim
, bfa_ioim_sm_cleanup_qfull
);
1665 bfa_stats(ioim
->itnim
, qwait
);
1666 bfa_reqq_wait(ioim
->bfa
, ioim
->reqq
,
1667 &ioim
->iosp
->reqq_wait
);
1671 case BFA_IOIM_SM_HWFAIL
:
1672 bfa_sm_set_state(ioim
, bfa_ioim_sm_hcb
);
1673 bfa_ioim_move_to_comp_q(ioim
);
1674 bfa_cb_queue(ioim
->bfa
, &ioim
->hcb_qe
,
1675 __bfa_cb_ioim_failed
, ioim
);
1678 case BFA_IOIM_SM_ABORT
:
1679 /* in this state IO abort is done.
1680 * Waiting for IO tag resource free.
1682 bfa_sm_set_state(ioim
, bfa_ioim_sm_hcb_free
);
1683 bfa_cb_queue(ioim
->bfa
, &ioim
->hcb_qe
, __bfa_cb_ioim_abort
,
1688 bfa_sm_fault(ioim
->bfa
, event
);
1693 * IO is being aborted, waiting for completion from firmware.
1696 bfa_ioim_sm_abort(struct bfa_ioim_s
*ioim
, enum bfa_ioim_event event
)
1698 bfa_trc(ioim
->bfa
, ioim
->iotag
);
1699 bfa_trc(ioim
->bfa
, event
);
1702 case BFA_IOIM_SM_COMP_GOOD
:
1703 case BFA_IOIM_SM_COMP
:
1704 case BFA_IOIM_SM_DONE
:
1705 case BFA_IOIM_SM_FREE
:
1708 case BFA_IOIM_SM_ABORT_DONE
:
1709 bfa_sm_set_state(ioim
, bfa_ioim_sm_hcb_free
);
1710 bfa_cb_queue(ioim
->bfa
, &ioim
->hcb_qe
, __bfa_cb_ioim_abort
,
1714 case BFA_IOIM_SM_ABORT_COMP
:
1715 bfa_sm_set_state(ioim
, bfa_ioim_sm_hcb
);
1716 bfa_ioim_move_to_comp_q(ioim
);
1717 bfa_cb_queue(ioim
->bfa
, &ioim
->hcb_qe
, __bfa_cb_ioim_abort
,
1721 case BFA_IOIM_SM_COMP_UTAG
:
1722 bfa_sm_set_state(ioim
, bfa_ioim_sm_hcb
);
1723 bfa_ioim_move_to_comp_q(ioim
);
1724 bfa_cb_queue(ioim
->bfa
, &ioim
->hcb_qe
, __bfa_cb_ioim_abort
,
1728 case BFA_IOIM_SM_CLEANUP
:
1729 WARN_ON(ioim
->iosp
->abort_explicit
!= BFA_TRUE
);
1730 ioim
->iosp
->abort_explicit
= BFA_FALSE
;
1732 if (bfa_ioim_send_abort(ioim
))
1733 bfa_sm_set_state(ioim
, bfa_ioim_sm_cleanup
);
1735 bfa_sm_set_state(ioim
, bfa_ioim_sm_cleanup_qfull
);
1736 bfa_stats(ioim
->itnim
, qwait
);
1737 bfa_reqq_wait(ioim
->bfa
, ioim
->reqq
,
1738 &ioim
->iosp
->reqq_wait
);
1742 case BFA_IOIM_SM_HWFAIL
:
1743 bfa_sm_set_state(ioim
, bfa_ioim_sm_hcb
);
1744 bfa_ioim_move_to_comp_q(ioim
);
1745 bfa_cb_queue(ioim
->bfa
, &ioim
->hcb_qe
, __bfa_cb_ioim_failed
,
1750 bfa_sm_fault(ioim
->bfa
, event
);
1755 * IO is being cleaned up (implicit abort), waiting for completion from
1759 bfa_ioim_sm_cleanup(struct bfa_ioim_s
*ioim
, enum bfa_ioim_event event
)
1761 bfa_trc(ioim
->bfa
, ioim
->iotag
);
1762 bfa_trc(ioim
->bfa
, event
);
1765 case BFA_IOIM_SM_COMP_GOOD
:
1766 case BFA_IOIM_SM_COMP
:
1767 case BFA_IOIM_SM_DONE
:
1768 case BFA_IOIM_SM_FREE
:
1771 case BFA_IOIM_SM_ABORT
:
1773 * IO is already being aborted implicitly
1775 ioim
->io_cbfn
= __bfa_cb_ioim_abort
;
1778 case BFA_IOIM_SM_ABORT_DONE
:
1779 bfa_sm_set_state(ioim
, bfa_ioim_sm_hcb_free
);
1780 bfa_cb_queue(ioim
->bfa
, &ioim
->hcb_qe
, ioim
->io_cbfn
, ioim
);
1781 bfa_ioim_notify_cleanup(ioim
);
1784 case BFA_IOIM_SM_ABORT_COMP
:
1785 bfa_sm_set_state(ioim
, bfa_ioim_sm_hcb
);
1786 bfa_cb_queue(ioim
->bfa
, &ioim
->hcb_qe
, ioim
->io_cbfn
, ioim
);
1787 bfa_ioim_notify_cleanup(ioim
);
1790 case BFA_IOIM_SM_COMP_UTAG
:
1791 bfa_sm_set_state(ioim
, bfa_ioim_sm_hcb
);
1792 bfa_cb_queue(ioim
->bfa
, &ioim
->hcb_qe
, ioim
->io_cbfn
, ioim
);
1793 bfa_ioim_notify_cleanup(ioim
);
1796 case BFA_IOIM_SM_HWFAIL
:
1797 bfa_sm_set_state(ioim
, bfa_ioim_sm_hcb
);
1798 bfa_ioim_move_to_comp_q(ioim
);
1799 bfa_cb_queue(ioim
->bfa
, &ioim
->hcb_qe
, __bfa_cb_ioim_failed
,
1803 case BFA_IOIM_SM_CLEANUP
:
1805 * IO can be in cleanup state already due to TM command.
1806 * 2nd cleanup request comes from ITN offline event.
1811 bfa_sm_fault(ioim
->bfa
, event
);
1816 * IO is waiting for room in request CQ
1819 bfa_ioim_sm_qfull(struct bfa_ioim_s
*ioim
, enum bfa_ioim_event event
)
1821 bfa_trc(ioim
->bfa
, ioim
->iotag
);
1822 bfa_trc(ioim
->bfa
, event
);
1825 case BFA_IOIM_SM_QRESUME
:
1826 bfa_sm_set_state(ioim
, bfa_ioim_sm_active
);
1827 bfa_ioim_send_ioreq(ioim
);
1830 case BFA_IOIM_SM_ABORT
:
1831 bfa_sm_set_state(ioim
, bfa_ioim_sm_hcb
);
1832 bfa_reqq_wcancel(&ioim
->iosp
->reqq_wait
);
1833 bfa_ioim_move_to_comp_q(ioim
);
1834 bfa_cb_queue(ioim
->bfa
, &ioim
->hcb_qe
, __bfa_cb_ioim_abort
,
1838 case BFA_IOIM_SM_CLEANUP
:
1839 bfa_sm_set_state(ioim
, bfa_ioim_sm_hcb
);
1840 bfa_reqq_wcancel(&ioim
->iosp
->reqq_wait
);
1841 bfa_cb_queue(ioim
->bfa
, &ioim
->hcb_qe
, __bfa_cb_ioim_failed
,
1843 bfa_ioim_notify_cleanup(ioim
);
1846 case BFA_IOIM_SM_HWFAIL
:
1847 bfa_sm_set_state(ioim
, bfa_ioim_sm_hcb
);
1848 bfa_reqq_wcancel(&ioim
->iosp
->reqq_wait
);
1849 bfa_ioim_move_to_comp_q(ioim
);
1850 bfa_cb_queue(ioim
->bfa
, &ioim
->hcb_qe
, __bfa_cb_ioim_failed
,
1855 bfa_sm_fault(ioim
->bfa
, event
);
1860 * Active IO is being aborted, waiting for room in request CQ.
1863 bfa_ioim_sm_abort_qfull(struct bfa_ioim_s
*ioim
, enum bfa_ioim_event event
)
1865 bfa_trc(ioim
->bfa
, ioim
->iotag
);
1866 bfa_trc(ioim
->bfa
, event
);
1869 case BFA_IOIM_SM_QRESUME
:
1870 bfa_sm_set_state(ioim
, bfa_ioim_sm_abort
);
1871 bfa_ioim_send_abort(ioim
);
1874 case BFA_IOIM_SM_CLEANUP
:
1875 WARN_ON(ioim
->iosp
->abort_explicit
!= BFA_TRUE
);
1876 ioim
->iosp
->abort_explicit
= BFA_FALSE
;
1877 bfa_sm_set_state(ioim
, bfa_ioim_sm_cleanup_qfull
);
1880 case BFA_IOIM_SM_COMP_GOOD
:
1881 case BFA_IOIM_SM_COMP
:
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_DONE
:
1890 bfa_sm_set_state(ioim
, bfa_ioim_sm_hcb_free
);
1891 bfa_reqq_wcancel(&ioim
->iosp
->reqq_wait
);
1892 bfa_ioim_move_to_comp_q(ioim
);
1893 bfa_cb_queue(ioim
->bfa
, &ioim
->hcb_qe
, __bfa_cb_ioim_abort
,
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 cleaned up, waiting for room in request CQ.
1914 bfa_ioim_sm_cleanup_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_cleanup
);
1922 bfa_ioim_send_abort(ioim
);
1925 case BFA_IOIM_SM_ABORT
:
1927 * IO is already being cleaned up implicitly
1929 ioim
->io_cbfn
= __bfa_cb_ioim_abort
;
1932 case BFA_IOIM_SM_COMP_GOOD
:
1933 case BFA_IOIM_SM_COMP
:
1934 bfa_sm_set_state(ioim
, bfa_ioim_sm_hcb
);
1935 bfa_reqq_wcancel(&ioim
->iosp
->reqq_wait
);
1936 bfa_cb_queue(ioim
->bfa
, &ioim
->hcb_qe
, ioim
->io_cbfn
, ioim
);
1937 bfa_ioim_notify_cleanup(ioim
);
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_cb_queue(ioim
->bfa
, &ioim
->hcb_qe
, ioim
->io_cbfn
, ioim
);
1944 bfa_ioim_notify_cleanup(ioim
);
1947 case BFA_IOIM_SM_HWFAIL
:
1948 bfa_sm_set_state(ioim
, bfa_ioim_sm_hcb
);
1949 bfa_reqq_wcancel(&ioim
->iosp
->reqq_wait
);
1950 bfa_ioim_move_to_comp_q(ioim
);
1951 bfa_cb_queue(ioim
->bfa
, &ioim
->hcb_qe
, __bfa_cb_ioim_failed
,
1956 bfa_sm_fault(ioim
->bfa
, event
);
1961 * IO bfa callback is pending.
1964 bfa_ioim_sm_hcb(struct bfa_ioim_s
*ioim
, enum bfa_ioim_event event
)
1967 case BFA_IOIM_SM_HCB
:
1968 bfa_sm_set_state(ioim
, bfa_ioim_sm_uninit
);
1969 bfa_ioim_free(ioim
);
1972 case BFA_IOIM_SM_CLEANUP
:
1973 bfa_ioim_notify_cleanup(ioim
);
1976 case BFA_IOIM_SM_HWFAIL
:
1980 bfa_sm_fault(ioim
->bfa
, event
);
1985 * IO bfa callback is pending. IO resource cannot be freed.
1988 bfa_ioim_sm_hcb_free(struct bfa_ioim_s
*ioim
, enum bfa_ioim_event event
)
1990 bfa_trc(ioim
->bfa
, ioim
->iotag
);
1991 bfa_trc(ioim
->bfa
, event
);
1994 case BFA_IOIM_SM_HCB
:
1995 bfa_sm_set_state(ioim
, bfa_ioim_sm_resfree
);
1996 list_del(&ioim
->qe
);
1997 list_add_tail(&ioim
->qe
, &ioim
->fcpim
->ioim_resfree_q
);
2000 case BFA_IOIM_SM_FREE
:
2001 bfa_sm_set_state(ioim
, bfa_ioim_sm_hcb
);
2004 case BFA_IOIM_SM_CLEANUP
:
2005 bfa_ioim_notify_cleanup(ioim
);
2008 case BFA_IOIM_SM_HWFAIL
:
2009 bfa_sm_set_state(ioim
, bfa_ioim_sm_hcb
);
2013 bfa_sm_fault(ioim
->bfa
, event
);
2018 * IO is completed, waiting resource free from firmware.
2021 bfa_ioim_sm_resfree(struct bfa_ioim_s
*ioim
, enum bfa_ioim_event event
)
2023 bfa_trc(ioim
->bfa
, ioim
->iotag
);
2024 bfa_trc(ioim
->bfa
, event
);
2027 case BFA_IOIM_SM_FREE
:
2028 bfa_sm_set_state(ioim
, bfa_ioim_sm_uninit
);
2029 bfa_ioim_free(ioim
);
2032 case BFA_IOIM_SM_CLEANUP
:
2033 bfa_ioim_notify_cleanup(ioim
);
2036 case BFA_IOIM_SM_HWFAIL
:
2040 bfa_sm_fault(ioim
->bfa
, event
);
2045 * This is called from bfa_fcpim_start after the bfa_init() with flash read
2046 * is complete by driver. now invalidate the stale content of lun mask
2047 * like unit attention, rp tag and lp tag.
2050 bfa_ioim_lm_init(struct bfa_s
*bfa
)
2052 struct bfa_lun_mask_s
*lunm_list
;
2055 if (bfa_get_lun_mask_status(bfa
) == BFA_LUNMASK_MINCFG
)
2058 lunm_list
= bfa_get_lun_mask_list(bfa
);
2059 for (i
= 0; i
< MAX_LUN_MASK_CFG
; i
++) {
2060 lunm_list
[i
].ua
= BFA_IOIM_LM_UA_RESET
;
2061 lunm_list
[i
].lp_tag
= BFA_LP_TAG_INVALID
;
2062 lunm_list
[i
].rp_tag
= BFA_RPORT_TAG_INVALID
;
2067 __bfa_cb_ioim_good_comp(void *cbarg
, bfa_boolean_t complete
)
2069 struct bfa_ioim_s
*ioim
= cbarg
;
2072 bfa_sm_send_event(ioim
, BFA_IOIM_SM_HCB
);
2076 bfa_cb_ioim_good_comp(ioim
->bfa
->bfad
, ioim
->dio
);
2080 __bfa_cb_ioim_comp(void *cbarg
, bfa_boolean_t complete
)
2082 struct bfa_ioim_s
*ioim
= cbarg
;
2083 struct bfi_ioim_rsp_s
*m
;
2089 bfa_sm_send_event(ioim
, BFA_IOIM_SM_HCB
);
2093 m
= (struct bfi_ioim_rsp_s
*) &ioim
->iosp
->comp_rspmsg
;
2094 if (m
->io_status
== BFI_IOIM_STS_OK
) {
2096 * setup sense information, if present
2098 if ((m
->scsi_status
== SAM_STAT_CHECK_CONDITION
) &&
2100 sns_len
= m
->sns_len
;
2101 snsinfo
= BFA_SNSINFO_FROM_TAG(ioim
->fcpim
->fcp
,
2106 * setup residue value correctly for normal completions
2108 if (m
->resid_flags
== FCP_RESID_UNDER
) {
2109 residue
= be32_to_cpu(m
->residue
);
2110 bfa_stats(ioim
->itnim
, iocomp_underrun
);
2112 if (m
->resid_flags
== FCP_RESID_OVER
) {
2113 residue
= be32_to_cpu(m
->residue
);
2115 bfa_stats(ioim
->itnim
, iocomp_overrun
);
2119 bfa_cb_ioim_done(ioim
->bfa
->bfad
, ioim
->dio
, m
->io_status
,
2120 m
->scsi_status
, sns_len
, snsinfo
, residue
);
2124 bfa_fcpim_lunmask_rp_update(struct bfa_s
*bfa
, wwn_t lp_wwn
, wwn_t rp_wwn
,
2125 u16 rp_tag
, u8 lp_tag
)
2127 struct bfa_lun_mask_s
*lun_list
;
2130 if (bfa_get_lun_mask_status(bfa
) == BFA_LUNMASK_MINCFG
)
2133 lun_list
= bfa_get_lun_mask_list(bfa
);
2134 for (i
= 0; i
< MAX_LUN_MASK_CFG
; i
++) {
2135 if (lun_list
[i
].state
== BFA_IOIM_LUN_MASK_ACTIVE
) {
2136 if ((lun_list
[i
].lp_wwn
== lp_wwn
) &&
2137 (lun_list
[i
].rp_wwn
== rp_wwn
)) {
2138 lun_list
[i
].rp_tag
= rp_tag
;
2139 lun_list
[i
].lp_tag
= lp_tag
;
2146 * set UA for all active luns in LM DB
2149 bfa_ioim_lm_set_ua(struct bfa_s
*bfa
)
2151 struct bfa_lun_mask_s
*lunm_list
;
2154 lunm_list
= bfa_get_lun_mask_list(bfa
);
2155 for (i
= 0; i
< MAX_LUN_MASK_CFG
; i
++) {
2156 if (lunm_list
[i
].state
!= BFA_IOIM_LUN_MASK_ACTIVE
)
2158 lunm_list
[i
].ua
= BFA_IOIM_LM_UA_SET
;
2163 bfa_fcpim_lunmask_update(struct bfa_s
*bfa
, u32 update
)
2165 struct bfa_lunmask_cfg_s
*lun_mask
;
2167 bfa_trc(bfa
, bfa_get_lun_mask_status(bfa
));
2168 if (bfa_get_lun_mask_status(bfa
) == BFA_LUNMASK_MINCFG
)
2169 return BFA_STATUS_FAILED
;
2171 if (bfa_get_lun_mask_status(bfa
) == update
)
2172 return BFA_STATUS_NO_CHANGE
;
2174 lun_mask
= bfa_get_lun_mask(bfa
);
2175 lun_mask
->status
= update
;
2177 if (bfa_get_lun_mask_status(bfa
) == BFA_LUNMASK_ENABLED
)
2178 bfa_ioim_lm_set_ua(bfa
);
2180 return bfa_dconf_update(bfa
);
2184 bfa_fcpim_lunmask_clear(struct bfa_s
*bfa
)
2187 struct bfa_lun_mask_s
*lunm_list
;
2189 bfa_trc(bfa
, bfa_get_lun_mask_status(bfa
));
2190 if (bfa_get_lun_mask_status(bfa
) == BFA_LUNMASK_MINCFG
)
2191 return BFA_STATUS_FAILED
;
2193 lunm_list
= bfa_get_lun_mask_list(bfa
);
2194 for (i
= 0; i
< MAX_LUN_MASK_CFG
; i
++) {
2195 if (lunm_list
[i
].state
== BFA_IOIM_LUN_MASK_ACTIVE
) {
2196 if (lunm_list
[i
].rp_tag
!= BFA_RPORT_TAG_INVALID
)
2197 bfa_rport_unset_lunmask(bfa
,
2198 BFA_RPORT_FROM_TAG(bfa
, lunm_list
[i
].rp_tag
));
2202 memset(lunm_list
, 0, sizeof(struct bfa_lun_mask_s
) * MAX_LUN_MASK_CFG
);
2203 return bfa_dconf_update(bfa
);
2207 bfa_fcpim_lunmask_query(struct bfa_s
*bfa
, void *buf
)
2209 struct bfa_lunmask_cfg_s
*lun_mask
;
2211 bfa_trc(bfa
, bfa_get_lun_mask_status(bfa
));
2212 if (bfa_get_lun_mask_status(bfa
) == BFA_LUNMASK_MINCFG
)
2213 return BFA_STATUS_FAILED
;
2215 lun_mask
= bfa_get_lun_mask(bfa
);
2216 memcpy(buf
, lun_mask
, sizeof(struct bfa_lunmask_cfg_s
));
2217 return BFA_STATUS_OK
;
2221 bfa_fcpim_lunmask_add(struct bfa_s
*bfa
, u16 vf_id
, wwn_t
*pwwn
,
2222 wwn_t rpwwn
, struct scsi_lun lun
)
2224 struct bfa_lun_mask_s
*lunm_list
;
2225 struct bfa_rport_s
*rp
= NULL
;
2226 int i
, free_index
= MAX_LUN_MASK_CFG
+ 1;
2227 struct bfa_fcs_lport_s
*port
= NULL
;
2228 struct bfa_fcs_rport_s
*rp_fcs
;
2230 bfa_trc(bfa
, bfa_get_lun_mask_status(bfa
));
2231 if (bfa_get_lun_mask_status(bfa
) == BFA_LUNMASK_MINCFG
)
2232 return BFA_STATUS_FAILED
;
2234 port
= bfa_fcs_lookup_port(&((struct bfad_s
*)bfa
->bfad
)->bfa_fcs
,
2237 *pwwn
= port
->port_cfg
.pwwn
;
2238 rp_fcs
= bfa_fcs_lport_get_rport_by_pwwn(port
, rpwwn
);
2240 rp
= rp_fcs
->bfa_rport
;
2243 lunm_list
= bfa_get_lun_mask_list(bfa
);
2244 /* if entry exists */
2245 for (i
= 0; i
< MAX_LUN_MASK_CFG
; i
++) {
2246 if (lunm_list
[i
].state
!= BFA_IOIM_LUN_MASK_ACTIVE
)
2248 if ((lunm_list
[i
].lp_wwn
== *pwwn
) &&
2249 (lunm_list
[i
].rp_wwn
== rpwwn
) &&
2250 (scsilun_to_int((struct scsi_lun
*)&lunm_list
[i
].lun
) ==
2251 scsilun_to_int((struct scsi_lun
*)&lun
)))
2252 return BFA_STATUS_ENTRY_EXISTS
;
2255 if (free_index
> MAX_LUN_MASK_CFG
)
2256 return BFA_STATUS_MAX_ENTRY_REACHED
;
2259 lunm_list
[free_index
].lp_tag
= bfa_lps_get_tag_from_pid(bfa
,
2260 rp
->rport_info
.local_pid
);
2261 lunm_list
[free_index
].rp_tag
= rp
->rport_tag
;
2263 lunm_list
[free_index
].lp_tag
= BFA_LP_TAG_INVALID
;
2264 lunm_list
[free_index
].rp_tag
= BFA_RPORT_TAG_INVALID
;
2267 lunm_list
[free_index
].lp_wwn
= *pwwn
;
2268 lunm_list
[free_index
].rp_wwn
= rpwwn
;
2269 lunm_list
[free_index
].lun
= lun
;
2270 lunm_list
[free_index
].state
= BFA_IOIM_LUN_MASK_ACTIVE
;
2272 /* set for all luns in this rp */
2273 for (i
= 0; i
< MAX_LUN_MASK_CFG
; i
++) {
2274 if ((lunm_list
[i
].lp_wwn
== *pwwn
) &&
2275 (lunm_list
[i
].rp_wwn
== rpwwn
))
2276 lunm_list
[i
].ua
= BFA_IOIM_LM_UA_SET
;
2279 return bfa_dconf_update(bfa
);
2283 bfa_fcpim_lunmask_delete(struct bfa_s
*bfa
, u16 vf_id
, wwn_t
*pwwn
,
2284 wwn_t rpwwn
, struct scsi_lun lun
)
2286 struct bfa_lun_mask_s
*lunm_list
;
2287 struct bfa_fcs_lport_s
*port
= NULL
;
2290 /* in min cfg lunm_list could be NULL but no commands should run. */
2291 if (bfa_get_lun_mask_status(bfa
) == BFA_LUNMASK_MINCFG
)
2292 return BFA_STATUS_FAILED
;
2294 bfa_trc(bfa
, bfa_get_lun_mask_status(bfa
));
2295 bfa_trc(bfa
, *pwwn
);
2296 bfa_trc(bfa
, rpwwn
);
2297 bfa_trc(bfa
, scsilun_to_int((struct scsi_lun
*)&lun
));
2300 port
= bfa_fcs_lookup_port(
2301 &((struct bfad_s
*)bfa
->bfad
)->bfa_fcs
,
2304 *pwwn
= port
->port_cfg
.pwwn
;
2307 lunm_list
= bfa_get_lun_mask_list(bfa
);
2308 for (i
= 0; i
< MAX_LUN_MASK_CFG
; i
++) {
2309 if ((lunm_list
[i
].lp_wwn
== *pwwn
) &&
2310 (lunm_list
[i
].rp_wwn
== rpwwn
) &&
2311 (scsilun_to_int((struct scsi_lun
*)&lunm_list
[i
].lun
) ==
2312 scsilun_to_int((struct scsi_lun
*)&lun
))) {
2313 lunm_list
[i
].lp_wwn
= 0;
2314 lunm_list
[i
].rp_wwn
= 0;
2315 int_to_scsilun(0, &lunm_list
[i
].lun
);
2316 lunm_list
[i
].state
= BFA_IOIM_LUN_MASK_INACTIVE
;
2317 if (lunm_list
[i
].rp_tag
!= BFA_RPORT_TAG_INVALID
) {
2318 lunm_list
[i
].rp_tag
= BFA_RPORT_TAG_INVALID
;
2319 lunm_list
[i
].lp_tag
= BFA_LP_TAG_INVALID
;
2321 return bfa_dconf_update(bfa
);
2325 /* set for all luns in this rp */
2326 for (i
= 0; i
< MAX_LUN_MASK_CFG
; i
++) {
2327 if ((lunm_list
[i
].lp_wwn
== *pwwn
) &&
2328 (lunm_list
[i
].rp_wwn
== rpwwn
))
2329 lunm_list
[i
].ua
= BFA_IOIM_LM_UA_SET
;
2332 return BFA_STATUS_ENTRY_NOT_EXISTS
;
2336 __bfa_cb_ioim_failed(void *cbarg
, bfa_boolean_t complete
)
2338 struct bfa_ioim_s
*ioim
= cbarg
;
2341 bfa_sm_send_event(ioim
, BFA_IOIM_SM_HCB
);
2345 bfa_cb_ioim_done(ioim
->bfa
->bfad
, ioim
->dio
, BFI_IOIM_STS_ABORTED
,
2350 __bfa_cb_ioim_pathtov(void *cbarg
, bfa_boolean_t complete
)
2352 struct bfa_ioim_s
*ioim
= cbarg
;
2354 bfa_stats(ioim
->itnim
, path_tov_expired
);
2356 bfa_sm_send_event(ioim
, BFA_IOIM_SM_HCB
);
2360 bfa_cb_ioim_done(ioim
->bfa
->bfad
, ioim
->dio
, BFI_IOIM_STS_PATHTOV
,
2365 __bfa_cb_ioim_abort(void *cbarg
, bfa_boolean_t complete
)
2367 struct bfa_ioim_s
*ioim
= cbarg
;
2370 bfa_sm_send_event(ioim
, BFA_IOIM_SM_HCB
);
2374 bfa_cb_ioim_abort(ioim
->bfa
->bfad
, ioim
->dio
);
2378 bfa_ioim_sgpg_alloced(void *cbarg
)
2380 struct bfa_ioim_s
*ioim
= cbarg
;
2382 ioim
->nsgpgs
= BFA_SGPG_NPAGE(ioim
->nsges
);
2383 list_splice_tail_init(&ioim
->iosp
->sgpg_wqe
.sgpg_q
, &ioim
->sgpg_q
);
2384 ioim
->sgpg
= bfa_q_first(&ioim
->sgpg_q
);
2385 bfa_sm_send_event(ioim
, BFA_IOIM_SM_SGALLOCED
);
2389 * Send I/O request to firmware.
2391 static bfa_boolean_t
2392 bfa_ioim_send_ioreq(struct bfa_ioim_s
*ioim
)
2394 struct bfa_itnim_s
*itnim
= ioim
->itnim
;
2395 struct bfi_ioim_req_s
*m
;
2396 static struct fcp_cmnd_s cmnd_z0
= { { { 0 } } };
2397 struct bfi_sge_s
*sge
, *sgpge
;
2401 struct scatterlist
*sg
;
2402 struct bfa_sgpg_s
*sgpg
;
2403 struct scsi_cmnd
*cmnd
= (struct scsi_cmnd
*) ioim
->dio
;
2404 u32 i
, sge_id
, pgcumsz
;
2405 enum dma_data_direction dmadir
;
2408 * check for room in queue to send request now
2410 m
= bfa_reqq_next(ioim
->bfa
, ioim
->reqq
);
2412 bfa_stats(ioim
->itnim
, qwait
);
2413 bfa_reqq_wait(ioim
->bfa
, ioim
->reqq
,
2414 &ioim
->iosp
->reqq_wait
);
2419 * build i/o request message next
2421 m
->io_tag
= cpu_to_be16(ioim
->iotag
);
2422 m
->rport_hdl
= ioim
->itnim
->rport
->fw_handle
;
2430 scsi_for_each_sg(cmnd
, sg
, ioim
->nsges
, i
) {
2432 /* build inline IO SG element */
2433 addr
= bfa_sgaddr_le(sg_dma_address(sg
));
2434 sge
->sga
= *(union bfi_addr_u
*) &addr
;
2435 pgdlen
= sg_dma_len(sg
);
2436 sge
->sg_len
= pgdlen
;
2437 sge
->flags
= (ioim
->nsges
> BFI_SGE_INLINE
) ?
2438 BFI_SGE_DATA_CPL
: BFI_SGE_DATA_LAST
;
2443 sgpge
= sgpg
->sgpg
->sges
;
2445 addr
= bfa_sgaddr_le(sg_dma_address(sg
));
2446 sgpge
->sga
= *(union bfi_addr_u
*) &addr
;
2447 sgpge
->sg_len
= sg_dma_len(sg
);
2448 pgcumsz
+= sgpge
->sg_len
;
2451 if (i
< (ioim
->nsges
- 1) &&
2452 sge_id
< (BFI_SGPG_DATA_SGES
- 1))
2453 sgpge
->flags
= BFI_SGE_DATA
;
2454 else if (i
< (ioim
->nsges
- 1))
2455 sgpge
->flags
= BFI_SGE_DATA_CPL
;
2457 sgpge
->flags
= BFI_SGE_DATA_LAST
;
2459 bfa_sge_to_le(sgpge
);
2462 if (i
== (ioim
->nsges
- 1)) {
2463 sgpge
->flags
= BFI_SGE_PGDLEN
;
2464 sgpge
->sga
.a32
.addr_lo
= 0;
2465 sgpge
->sga
.a32
.addr_hi
= 0;
2466 sgpge
->sg_len
= pgcumsz
;
2467 bfa_sge_to_le(sgpge
);
2468 } else if (++sge_id
== BFI_SGPG_DATA_SGES
) {
2469 sgpg
= (struct bfa_sgpg_s
*) bfa_q_next(sgpg
);
2470 sgpge
->flags
= BFI_SGE_LINK
;
2471 sgpge
->sga
= sgpg
->sgpg_pa
;
2472 sgpge
->sg_len
= pgcumsz
;
2473 bfa_sge_to_le(sgpge
);
2480 if (ioim
->nsges
> BFI_SGE_INLINE
) {
2481 sge
->sga
= ioim
->sgpg
->sgpg_pa
;
2483 sge
->sga
.a32
.addr_lo
= 0;
2484 sge
->sga
.a32
.addr_hi
= 0;
2486 sge
->sg_len
= pgdlen
;
2487 sge
->flags
= BFI_SGE_PGDLEN
;
2491 * set up I/O command parameters
2494 int_to_scsilun(cmnd
->device
->lun
, &m
->cmnd
.lun
);
2495 dmadir
= cmnd
->sc_data_direction
;
2496 if (dmadir
== DMA_TO_DEVICE
)
2497 m
->cmnd
.iodir
= FCP_IODIR_WRITE
;
2498 else if (dmadir
== DMA_FROM_DEVICE
)
2499 m
->cmnd
.iodir
= FCP_IODIR_READ
;
2501 m
->cmnd
.iodir
= FCP_IODIR_NONE
;
2503 m
->cmnd
.cdb
= *(struct scsi_cdb_s
*) cmnd
->cmnd
;
2504 fcp_dl
= scsi_bufflen(cmnd
);
2505 m
->cmnd
.fcp_dl
= cpu_to_be32(fcp_dl
);
2508 * set up I/O message header
2510 switch (m
->cmnd
.iodir
) {
2511 case FCP_IODIR_READ
:
2512 bfi_h2i_set(m
->mh
, BFI_MC_IOIM_READ
, 0, bfa_fn_lpu(ioim
->bfa
));
2513 bfa_stats(itnim
, input_reqs
);
2514 ioim
->itnim
->stats
.rd_throughput
+= fcp_dl
;
2516 case FCP_IODIR_WRITE
:
2517 bfi_h2i_set(m
->mh
, BFI_MC_IOIM_WRITE
, 0, bfa_fn_lpu(ioim
->bfa
));
2518 bfa_stats(itnim
, output_reqs
);
2519 ioim
->itnim
->stats
.wr_throughput
+= fcp_dl
;
2522 bfa_stats(itnim
, input_reqs
);
2523 bfa_stats(itnim
, output_reqs
);
2526 bfi_h2i_set(m
->mh
, BFI_MC_IOIM_IO
, 0, bfa_fn_lpu(ioim
->bfa
));
2528 if (itnim
->seq_rec
||
2529 (scsi_bufflen(cmnd
) & (sizeof(u32
) - 1)))
2530 bfi_h2i_set(m
->mh
, BFI_MC_IOIM_IO
, 0, bfa_fn_lpu(ioim
->bfa
));
2533 * queue I/O message to firmware
2535 bfa_reqq_produce(ioim
->bfa
, ioim
->reqq
, m
->mh
);
2540 * Setup any additional SG pages needed.Inline SG element is setup
2543 static bfa_boolean_t
2544 bfa_ioim_sgpg_alloc(struct bfa_ioim_s
*ioim
)
2548 WARN_ON(ioim
->nsges
<= BFI_SGE_INLINE
);
2551 * allocate SG pages needed
2553 nsgpgs
= BFA_SGPG_NPAGE(ioim
->nsges
);
2557 if (bfa_sgpg_malloc(ioim
->bfa
, &ioim
->sgpg_q
, nsgpgs
)
2559 bfa_sgpg_wait(ioim
->bfa
, &ioim
->iosp
->sgpg_wqe
, nsgpgs
);
2563 ioim
->nsgpgs
= nsgpgs
;
2564 ioim
->sgpg
= bfa_q_first(&ioim
->sgpg_q
);
2570 * Send I/O abort request to firmware.
2572 static bfa_boolean_t
2573 bfa_ioim_send_abort(struct bfa_ioim_s
*ioim
)
2575 struct bfi_ioim_abort_req_s
*m
;
2576 enum bfi_ioim_h2i msgop
;
2579 * check for room in queue to send request now
2581 m
= bfa_reqq_next(ioim
->bfa
, ioim
->reqq
);
2586 * build i/o request message next
2588 if (ioim
->iosp
->abort_explicit
)
2589 msgop
= BFI_IOIM_H2I_IOABORT_REQ
;
2591 msgop
= BFI_IOIM_H2I_IOCLEANUP_REQ
;
2593 bfi_h2i_set(m
->mh
, BFI_MC_IOIM
, msgop
, bfa_fn_lpu(ioim
->bfa
));
2594 m
->io_tag
= cpu_to_be16(ioim
->iotag
);
2595 m
->abort_tag
= ++ioim
->abort_tag
;
2598 * queue I/O message to firmware
2600 bfa_reqq_produce(ioim
->bfa
, ioim
->reqq
, m
->mh
);
2605 * Call to resume any I/O requests waiting for room in request queue.
2608 bfa_ioim_qresume(void *cbarg
)
2610 struct bfa_ioim_s
*ioim
= cbarg
;
2612 bfa_stats(ioim
->itnim
, qresumes
);
2613 bfa_sm_send_event(ioim
, BFA_IOIM_SM_QRESUME
);
2618 bfa_ioim_notify_cleanup(struct bfa_ioim_s
*ioim
)
2621 * Move IO from itnim queue to fcpim global queue since itnim will be
2624 list_del(&ioim
->qe
);
2625 list_add_tail(&ioim
->qe
, &ioim
->fcpim
->ioim_comp_q
);
2627 if (!ioim
->iosp
->tskim
) {
2628 if (ioim
->fcpim
->delay_comp
&& ioim
->itnim
->iotov_active
) {
2629 bfa_cb_dequeue(&ioim
->hcb_qe
);
2630 list_del(&ioim
->qe
);
2631 list_add_tail(&ioim
->qe
, &ioim
->itnim
->delay_comp_q
);
2633 bfa_itnim_iodone(ioim
->itnim
);
2635 bfa_wc_down(&ioim
->iosp
->tskim
->wc
);
2638 static bfa_boolean_t
2639 bfa_ioim_is_abortable(struct bfa_ioim_s
*ioim
)
2641 if ((bfa_sm_cmp_state(ioim
, bfa_ioim_sm_uninit
) &&
2642 (!bfa_q_is_on_q(&ioim
->itnim
->pending_q
, ioim
))) ||
2643 (bfa_sm_cmp_state(ioim
, bfa_ioim_sm_abort
)) ||
2644 (bfa_sm_cmp_state(ioim
, bfa_ioim_sm_abort_qfull
)) ||
2645 (bfa_sm_cmp_state(ioim
, bfa_ioim_sm_hcb
)) ||
2646 (bfa_sm_cmp_state(ioim
, bfa_ioim_sm_hcb_free
)) ||
2647 (bfa_sm_cmp_state(ioim
, bfa_ioim_sm_resfree
)))
2654 bfa_ioim_delayed_comp(struct bfa_ioim_s
*ioim
, bfa_boolean_t iotov
)
2657 * If path tov timer expired, failback with PATHTOV status - these
2658 * IO requests are not normally retried by IO stack.
2660 * Otherwise device cameback online and fail it with normal failed
2661 * status so that IO stack retries these failed IO requests.
2664 ioim
->io_cbfn
= __bfa_cb_ioim_pathtov
;
2666 ioim
->io_cbfn
= __bfa_cb_ioim_failed
;
2667 bfa_stats(ioim
->itnim
, iocom_nexus_abort
);
2669 bfa_cb_queue(ioim
->bfa
, &ioim
->hcb_qe
, ioim
->io_cbfn
, ioim
);
2672 * Move IO to fcpim global queue since itnim will be
2675 list_del(&ioim
->qe
);
2676 list_add_tail(&ioim
->qe
, &ioim
->fcpim
->ioim_comp_q
);
2681 * Memory allocation and initialization.
2684 bfa_ioim_attach(struct bfa_fcpim_s
*fcpim
)
2686 struct bfa_ioim_s
*ioim
;
2687 struct bfa_fcp_mod_s
*fcp
= fcpim
->fcp
;
2688 struct bfa_ioim_sp_s
*iosp
;
2692 * claim memory first
2694 ioim
= (struct bfa_ioim_s
*) bfa_mem_kva_curp(fcp
);
2695 fcpim
->ioim_arr
= ioim
;
2696 bfa_mem_kva_curp(fcp
) = (u8
*) (ioim
+ fcpim
->fcp
->num_ioim_reqs
);
2698 iosp
= (struct bfa_ioim_sp_s
*) bfa_mem_kva_curp(fcp
);
2699 fcpim
->ioim_sp_arr
= iosp
;
2700 bfa_mem_kva_curp(fcp
) = (u8
*) (iosp
+ fcpim
->fcp
->num_ioim_reqs
);
2703 * Initialize ioim free queues
2705 INIT_LIST_HEAD(&fcpim
->ioim_resfree_q
);
2706 INIT_LIST_HEAD(&fcpim
->ioim_comp_q
);
2708 for (i
= 0; i
< fcpim
->fcp
->num_ioim_reqs
;
2709 i
++, ioim
++, iosp
++) {
2713 memset(ioim
, 0, sizeof(struct bfa_ioim_s
));
2715 ioim
->bfa
= fcpim
->bfa
;
2716 ioim
->fcpim
= fcpim
;
2718 INIT_LIST_HEAD(&ioim
->sgpg_q
);
2719 bfa_reqq_winit(&ioim
->iosp
->reqq_wait
,
2720 bfa_ioim_qresume
, ioim
);
2721 bfa_sgpg_winit(&ioim
->iosp
->sgpg_wqe
,
2722 bfa_ioim_sgpg_alloced
, ioim
);
2723 bfa_sm_set_state(ioim
, bfa_ioim_sm_uninit
);
2728 bfa_ioim_isr(struct bfa_s
*bfa
, struct bfi_msg_s
*m
)
2730 struct bfa_fcpim_s
*fcpim
= BFA_FCPIM(bfa
);
2731 struct bfi_ioim_rsp_s
*rsp
= (struct bfi_ioim_rsp_s
*) m
;
2732 struct bfa_ioim_s
*ioim
;
2734 enum bfa_ioim_event evt
= BFA_IOIM_SM_COMP
;
2736 iotag
= be16_to_cpu(rsp
->io_tag
);
2738 ioim
= BFA_IOIM_FROM_TAG(fcpim
, iotag
);
2739 WARN_ON(ioim
->iotag
!= iotag
);
2741 bfa_trc(ioim
->bfa
, ioim
->iotag
);
2742 bfa_trc(ioim
->bfa
, rsp
->io_status
);
2743 bfa_trc(ioim
->bfa
, rsp
->reuse_io_tag
);
2745 if (bfa_sm_cmp_state(ioim
, bfa_ioim_sm_active
))
2746 ioim
->iosp
->comp_rspmsg
= *m
;
2748 switch (rsp
->io_status
) {
2749 case BFI_IOIM_STS_OK
:
2750 bfa_stats(ioim
->itnim
, iocomp_ok
);
2751 if (rsp
->reuse_io_tag
== 0)
2752 evt
= BFA_IOIM_SM_DONE
;
2754 evt
= BFA_IOIM_SM_COMP
;
2757 case BFI_IOIM_STS_TIMEDOUT
:
2758 bfa_stats(ioim
->itnim
, iocomp_timedout
);
2760 case BFI_IOIM_STS_ABORTED
:
2761 rsp
->io_status
= BFI_IOIM_STS_ABORTED
;
2762 bfa_stats(ioim
->itnim
, iocomp_aborted
);
2763 if (rsp
->reuse_io_tag
== 0)
2764 evt
= BFA_IOIM_SM_DONE
;
2766 evt
= BFA_IOIM_SM_COMP
;
2769 case BFI_IOIM_STS_PROTO_ERR
:
2770 bfa_stats(ioim
->itnim
, iocom_proto_err
);
2771 WARN_ON(!rsp
->reuse_io_tag
);
2772 evt
= BFA_IOIM_SM_COMP
;
2775 case BFI_IOIM_STS_SQER_NEEDED
:
2776 bfa_stats(ioim
->itnim
, iocom_sqer_needed
);
2777 WARN_ON(rsp
->reuse_io_tag
!= 0);
2778 evt
= BFA_IOIM_SM_SQRETRY
;
2781 case BFI_IOIM_STS_RES_FREE
:
2782 bfa_stats(ioim
->itnim
, iocom_res_free
);
2783 evt
= BFA_IOIM_SM_FREE
;
2786 case BFI_IOIM_STS_HOST_ABORTED
:
2787 bfa_stats(ioim
->itnim
, iocom_hostabrts
);
2788 if (rsp
->abort_tag
!= ioim
->abort_tag
) {
2789 bfa_trc(ioim
->bfa
, rsp
->abort_tag
);
2790 bfa_trc(ioim
->bfa
, ioim
->abort_tag
);
2794 if (rsp
->reuse_io_tag
)
2795 evt
= BFA_IOIM_SM_ABORT_COMP
;
2797 evt
= BFA_IOIM_SM_ABORT_DONE
;
2800 case BFI_IOIM_STS_UTAG
:
2801 bfa_stats(ioim
->itnim
, iocom_utags
);
2802 evt
= BFA_IOIM_SM_COMP_UTAG
;
2809 bfa_sm_send_event(ioim
, evt
);
2813 bfa_ioim_good_comp_isr(struct bfa_s
*bfa
, struct bfi_msg_s
*m
)
2815 struct bfa_fcpim_s
*fcpim
= BFA_FCPIM(bfa
);
2816 struct bfi_ioim_rsp_s
*rsp
= (struct bfi_ioim_rsp_s
*) m
;
2817 struct bfa_ioim_s
*ioim
;
2820 iotag
= be16_to_cpu(rsp
->io_tag
);
2822 ioim
= BFA_IOIM_FROM_TAG(fcpim
, iotag
);
2823 WARN_ON(ioim
->iotag
!= iotag
);
2825 bfa_ioim_cb_profile_comp(fcpim
, ioim
);
2827 bfa_sm_send_event(ioim
, BFA_IOIM_SM_COMP_GOOD
);
2831 * Called by itnim to clean up IO while going offline.
2834 bfa_ioim_cleanup(struct bfa_ioim_s
*ioim
)
2836 bfa_trc(ioim
->bfa
, ioim
->iotag
);
2837 bfa_stats(ioim
->itnim
, io_cleanups
);
2839 ioim
->iosp
->tskim
= NULL
;
2840 bfa_sm_send_event(ioim
, BFA_IOIM_SM_CLEANUP
);
2844 bfa_ioim_cleanup_tm(struct bfa_ioim_s
*ioim
, struct bfa_tskim_s
*tskim
)
2846 bfa_trc(ioim
->bfa
, ioim
->iotag
);
2847 bfa_stats(ioim
->itnim
, io_tmaborts
);
2849 ioim
->iosp
->tskim
= tskim
;
2850 bfa_sm_send_event(ioim
, BFA_IOIM_SM_CLEANUP
);
2854 * IOC failure handling.
2857 bfa_ioim_iocdisable(struct bfa_ioim_s
*ioim
)
2859 bfa_trc(ioim
->bfa
, ioim
->iotag
);
2860 bfa_stats(ioim
->itnim
, io_iocdowns
);
2861 bfa_sm_send_event(ioim
, BFA_IOIM_SM_HWFAIL
);
2865 * IO offline TOV popped. Fail the pending IO.
2868 bfa_ioim_tov(struct bfa_ioim_s
*ioim
)
2870 bfa_trc(ioim
->bfa
, ioim
->iotag
);
2871 bfa_sm_send_event(ioim
, BFA_IOIM_SM_IOTOV
);
2876 * Allocate IOIM resource for initiator mode I/O request.
2879 bfa_ioim_alloc(struct bfa_s
*bfa
, struct bfad_ioim_s
*dio
,
2880 struct bfa_itnim_s
*itnim
, u16 nsges
)
2882 struct bfa_fcpim_s
*fcpim
= BFA_FCPIM(bfa
);
2883 struct bfa_ioim_s
*ioim
;
2884 struct bfa_iotag_s
*iotag
= NULL
;
2887 * alocate IOIM resource
2889 bfa_q_deq(&fcpim
->fcp
->iotag_ioim_free_q
, &iotag
);
2891 bfa_stats(itnim
, no_iotags
);
2895 ioim
= BFA_IOIM_FROM_TAG(fcpim
, iotag
->tag
);
2898 ioim
->itnim
= itnim
;
2899 ioim
->nsges
= nsges
;
2902 bfa_stats(itnim
, total_ios
);
2903 fcpim
->ios_active
++;
2905 list_add_tail(&ioim
->qe
, &itnim
->io_q
);
2911 bfa_ioim_free(struct bfa_ioim_s
*ioim
)
2913 struct bfa_fcpim_s
*fcpim
= ioim
->fcpim
;
2914 struct bfa_iotag_s
*iotag
;
2916 if (ioim
->nsgpgs
> 0)
2917 bfa_sgpg_mfree(ioim
->bfa
, &ioim
->sgpg_q
, ioim
->nsgpgs
);
2919 bfa_stats(ioim
->itnim
, io_comps
);
2920 fcpim
->ios_active
--;
2922 ioim
->iotag
&= BFA_IOIM_IOTAG_MASK
;
2924 WARN_ON(!(ioim
->iotag
<
2925 (fcpim
->fcp
->num_ioim_reqs
+ fcpim
->fcp
->num_fwtio_reqs
)));
2926 iotag
= BFA_IOTAG_FROM_TAG(fcpim
->fcp
, ioim
->iotag
);
2928 if (ioim
->iotag
< fcpim
->fcp
->num_ioim_reqs
)
2929 list_add_tail(&iotag
->qe
, &fcpim
->fcp
->iotag_ioim_free_q
);
2931 list_add_tail(&iotag
->qe
, &fcpim
->fcp
->iotag_tio_free_q
);
2933 list_del(&ioim
->qe
);
2937 bfa_ioim_start(struct bfa_ioim_s
*ioim
)
2939 bfa_ioim_cb_profile_start(ioim
->fcpim
, ioim
);
2942 * Obtain the queue over which this request has to be issued
2944 ioim
->reqq
= bfa_fcpim_ioredirect_enabled(ioim
->bfa
) ?
2945 BFA_FALSE
: bfa_itnim_get_reqq(ioim
);
2947 bfa_sm_send_event(ioim
, BFA_IOIM_SM_START
);
2951 * Driver I/O abort request.
2954 bfa_ioim_abort(struct bfa_ioim_s
*ioim
)
2957 bfa_trc(ioim
->bfa
, ioim
->iotag
);
2959 if (!bfa_ioim_is_abortable(ioim
))
2960 return BFA_STATUS_FAILED
;
2962 bfa_stats(ioim
->itnim
, io_aborts
);
2963 bfa_sm_send_event(ioim
, BFA_IOIM_SM_ABORT
);
2965 return BFA_STATUS_OK
;
2969 * BFA TSKIM state machine functions
2973 * Task management command beginning state.
2976 bfa_tskim_sm_uninit(struct bfa_tskim_s
*tskim
, enum bfa_tskim_event event
)
2978 bfa_trc(tskim
->bfa
, tskim
->tsk_tag
<< 16 | event
);
2981 case BFA_TSKIM_SM_START
:
2982 bfa_sm_set_state(tskim
, bfa_tskim_sm_active
);
2983 bfa_tskim_gather_ios(tskim
);
2986 * If device is offline, do not send TM on wire. Just cleanup
2987 * any pending IO requests and complete TM request.
2989 if (!bfa_itnim_is_online(tskim
->itnim
)) {
2990 bfa_sm_set_state(tskim
, bfa_tskim_sm_iocleanup
);
2991 tskim
->tsk_status
= BFI_TSKIM_STS_OK
;
2992 bfa_tskim_cleanup_ios(tskim
);
2996 if (!bfa_tskim_send(tskim
)) {
2997 bfa_sm_set_state(tskim
, bfa_tskim_sm_qfull
);
2998 bfa_stats(tskim
->itnim
, tm_qwait
);
2999 bfa_reqq_wait(tskim
->bfa
, tskim
->itnim
->reqq
,
3005 bfa_sm_fault(tskim
->bfa
, event
);
3010 * TM command is active, awaiting completion from firmware to
3011 * cleanup IO requests in TM scope.
3014 bfa_tskim_sm_active(struct bfa_tskim_s
*tskim
, enum bfa_tskim_event event
)
3016 bfa_trc(tskim
->bfa
, tskim
->tsk_tag
<< 16 | event
);
3019 case BFA_TSKIM_SM_DONE
:
3020 bfa_sm_set_state(tskim
, bfa_tskim_sm_iocleanup
);
3021 bfa_tskim_cleanup_ios(tskim
);
3024 case BFA_TSKIM_SM_CLEANUP
:
3025 bfa_sm_set_state(tskim
, bfa_tskim_sm_cleanup
);
3026 if (!bfa_tskim_send_abort(tskim
)) {
3027 bfa_sm_set_state(tskim
, bfa_tskim_sm_cleanup_qfull
);
3028 bfa_stats(tskim
->itnim
, tm_qwait
);
3029 bfa_reqq_wait(tskim
->bfa
, tskim
->itnim
->reqq
,
3034 case BFA_TSKIM_SM_HWFAIL
:
3035 bfa_sm_set_state(tskim
, bfa_tskim_sm_hcb
);
3036 bfa_tskim_iocdisable_ios(tskim
);
3037 bfa_tskim_qcomp(tskim
, __bfa_cb_tskim_failed
);
3041 bfa_sm_fault(tskim
->bfa
, event
);
3046 * An active TM is being cleaned up since ITN is offline. Awaiting cleanup
3047 * completion event from firmware.
3050 bfa_tskim_sm_cleanup(struct bfa_tskim_s
*tskim
, enum bfa_tskim_event event
)
3052 bfa_trc(tskim
->bfa
, tskim
->tsk_tag
<< 16 | event
);
3055 case BFA_TSKIM_SM_DONE
:
3057 * Ignore and wait for ABORT completion from firmware.
3061 case BFA_TSKIM_SM_UTAG
:
3062 case BFA_TSKIM_SM_CLEANUP_DONE
:
3063 bfa_sm_set_state(tskim
, bfa_tskim_sm_iocleanup
);
3064 bfa_tskim_cleanup_ios(tskim
);
3067 case BFA_TSKIM_SM_HWFAIL
:
3068 bfa_sm_set_state(tskim
, bfa_tskim_sm_hcb
);
3069 bfa_tskim_iocdisable_ios(tskim
);
3070 bfa_tskim_qcomp(tskim
, __bfa_cb_tskim_failed
);
3074 bfa_sm_fault(tskim
->bfa
, event
);
3079 bfa_tskim_sm_iocleanup(struct bfa_tskim_s
*tskim
, enum bfa_tskim_event event
)
3081 bfa_trc(tskim
->bfa
, tskim
->tsk_tag
<< 16 | event
);
3084 case BFA_TSKIM_SM_IOS_DONE
:
3085 bfa_sm_set_state(tskim
, bfa_tskim_sm_hcb
);
3086 bfa_tskim_qcomp(tskim
, __bfa_cb_tskim_done
);
3089 case BFA_TSKIM_SM_CLEANUP
:
3091 * Ignore, TM command completed on wire.
3092 * Notify TM conmpletion on IO cleanup completion.
3096 case BFA_TSKIM_SM_HWFAIL
:
3097 bfa_sm_set_state(tskim
, bfa_tskim_sm_hcb
);
3098 bfa_tskim_iocdisable_ios(tskim
);
3099 bfa_tskim_qcomp(tskim
, __bfa_cb_tskim_failed
);
3103 bfa_sm_fault(tskim
->bfa
, event
);
3108 * Task management command is waiting for room in request CQ
3111 bfa_tskim_sm_qfull(struct bfa_tskim_s
*tskim
, enum bfa_tskim_event event
)
3113 bfa_trc(tskim
->bfa
, tskim
->tsk_tag
<< 16 | event
);
3116 case BFA_TSKIM_SM_QRESUME
:
3117 bfa_sm_set_state(tskim
, bfa_tskim_sm_active
);
3118 bfa_tskim_send(tskim
);
3121 case BFA_TSKIM_SM_CLEANUP
:
3123 * No need to send TM on wire since ITN is offline.
3125 bfa_sm_set_state(tskim
, bfa_tskim_sm_iocleanup
);
3126 bfa_reqq_wcancel(&tskim
->reqq_wait
);
3127 bfa_tskim_cleanup_ios(tskim
);
3130 case BFA_TSKIM_SM_HWFAIL
:
3131 bfa_sm_set_state(tskim
, bfa_tskim_sm_hcb
);
3132 bfa_reqq_wcancel(&tskim
->reqq_wait
);
3133 bfa_tskim_iocdisable_ios(tskim
);
3134 bfa_tskim_qcomp(tskim
, __bfa_cb_tskim_failed
);
3138 bfa_sm_fault(tskim
->bfa
, event
);
3143 * Task management command is active, awaiting for room in request CQ
3144 * to send clean up request.
3147 bfa_tskim_sm_cleanup_qfull(struct bfa_tskim_s
*tskim
,
3148 enum bfa_tskim_event event
)
3150 bfa_trc(tskim
->bfa
, tskim
->tsk_tag
<< 16 | event
);
3153 case BFA_TSKIM_SM_DONE
:
3154 bfa_reqq_wcancel(&tskim
->reqq_wait
);
3156 case BFA_TSKIM_SM_QRESUME
:
3157 bfa_sm_set_state(tskim
, bfa_tskim_sm_cleanup
);
3158 bfa_tskim_send_abort(tskim
);
3161 case BFA_TSKIM_SM_HWFAIL
:
3162 bfa_sm_set_state(tskim
, bfa_tskim_sm_hcb
);
3163 bfa_reqq_wcancel(&tskim
->reqq_wait
);
3164 bfa_tskim_iocdisable_ios(tskim
);
3165 bfa_tskim_qcomp(tskim
, __bfa_cb_tskim_failed
);
3169 bfa_sm_fault(tskim
->bfa
, event
);
3174 * BFA callback is pending
3177 bfa_tskim_sm_hcb(struct bfa_tskim_s
*tskim
, enum bfa_tskim_event event
)
3179 bfa_trc(tskim
->bfa
, tskim
->tsk_tag
<< 16 | event
);
3182 case BFA_TSKIM_SM_HCB
:
3183 bfa_sm_set_state(tskim
, bfa_tskim_sm_uninit
);
3184 bfa_tskim_free(tskim
);
3187 case BFA_TSKIM_SM_CLEANUP
:
3188 bfa_tskim_notify_comp(tskim
);
3191 case BFA_TSKIM_SM_HWFAIL
:
3195 bfa_sm_fault(tskim
->bfa
, event
);
3200 __bfa_cb_tskim_done(void *cbarg
, bfa_boolean_t complete
)
3202 struct bfa_tskim_s
*tskim
= cbarg
;
3205 bfa_sm_send_event(tskim
, BFA_TSKIM_SM_HCB
);
3209 bfa_stats(tskim
->itnim
, tm_success
);
3210 bfa_cb_tskim_done(tskim
->bfa
->bfad
, tskim
->dtsk
, tskim
->tsk_status
);
3214 __bfa_cb_tskim_failed(void *cbarg
, bfa_boolean_t complete
)
3216 struct bfa_tskim_s
*tskim
= cbarg
;
3219 bfa_sm_send_event(tskim
, BFA_TSKIM_SM_HCB
);
3223 bfa_stats(tskim
->itnim
, tm_failures
);
3224 bfa_cb_tskim_done(tskim
->bfa
->bfad
, tskim
->dtsk
,
3225 BFI_TSKIM_STS_FAILED
);
3228 static bfa_boolean_t
3229 bfa_tskim_match_scope(struct bfa_tskim_s
*tskim
, struct scsi_lun lun
)
3231 switch (tskim
->tm_cmnd
) {
3232 case FCP_TM_TARGET_RESET
:
3235 case FCP_TM_ABORT_TASK_SET
:
3236 case FCP_TM_CLEAR_TASK_SET
:
3237 case FCP_TM_LUN_RESET
:
3238 case FCP_TM_CLEAR_ACA
:
3239 return !memcmp(&tskim
->lun
, &lun
, sizeof(lun
));
3249 * Gather affected IO requests and task management commands.
3252 bfa_tskim_gather_ios(struct bfa_tskim_s
*tskim
)
3254 struct bfa_itnim_s
*itnim
= tskim
->itnim
;
3255 struct bfa_ioim_s
*ioim
;
3256 struct list_head
*qe
, *qen
;
3257 struct scsi_cmnd
*cmnd
;
3258 struct scsi_lun scsilun
;
3260 INIT_LIST_HEAD(&tskim
->io_q
);
3263 * Gather any active IO requests first.
3265 list_for_each_safe(qe
, qen
, &itnim
->io_q
) {
3266 ioim
= (struct bfa_ioim_s
*) qe
;
3267 cmnd
= (struct scsi_cmnd
*) ioim
->dio
;
3268 int_to_scsilun(cmnd
->device
->lun
, &scsilun
);
3269 if (bfa_tskim_match_scope(tskim
, scsilun
)) {
3270 list_del(&ioim
->qe
);
3271 list_add_tail(&ioim
->qe
, &tskim
->io_q
);
3276 * Failback any pending IO requests immediately.
3278 list_for_each_safe(qe
, qen
, &itnim
->pending_q
) {
3279 ioim
= (struct bfa_ioim_s
*) qe
;
3280 cmnd
= (struct scsi_cmnd
*) ioim
->dio
;
3281 int_to_scsilun(cmnd
->device
->lun
, &scsilun
);
3282 if (bfa_tskim_match_scope(tskim
, scsilun
)) {
3283 list_del(&ioim
->qe
);
3284 list_add_tail(&ioim
->qe
, &ioim
->fcpim
->ioim_comp_q
);
3291 * IO cleanup completion
3294 bfa_tskim_cleanp_comp(void *tskim_cbarg
)
3296 struct bfa_tskim_s
*tskim
= tskim_cbarg
;
3298 bfa_stats(tskim
->itnim
, tm_io_comps
);
3299 bfa_sm_send_event(tskim
, BFA_TSKIM_SM_IOS_DONE
);
3303 * Gather affected IO requests and task management commands.
3306 bfa_tskim_cleanup_ios(struct bfa_tskim_s
*tskim
)
3308 struct bfa_ioim_s
*ioim
;
3309 struct list_head
*qe
, *qen
;
3311 bfa_wc_init(&tskim
->wc
, bfa_tskim_cleanp_comp
, tskim
);
3313 list_for_each_safe(qe
, qen
, &tskim
->io_q
) {
3314 ioim
= (struct bfa_ioim_s
*) qe
;
3315 bfa_wc_up(&tskim
->wc
);
3316 bfa_ioim_cleanup_tm(ioim
, tskim
);
3319 bfa_wc_wait(&tskim
->wc
);
3323 * Send task management request to firmware.
3325 static bfa_boolean_t
3326 bfa_tskim_send(struct bfa_tskim_s
*tskim
)
3328 struct bfa_itnim_s
*itnim
= tskim
->itnim
;
3329 struct bfi_tskim_req_s
*m
;
3332 * check for room in queue to send request now
3334 m
= bfa_reqq_next(tskim
->bfa
, itnim
->reqq
);
3339 * build i/o request message next
3341 bfi_h2i_set(m
->mh
, BFI_MC_TSKIM
, BFI_TSKIM_H2I_TM_REQ
,
3342 bfa_fn_lpu(tskim
->bfa
));
3344 m
->tsk_tag
= cpu_to_be16(tskim
->tsk_tag
);
3345 m
->itn_fhdl
= tskim
->itnim
->rport
->fw_handle
;
3346 m
->t_secs
= tskim
->tsecs
;
3347 m
->lun
= tskim
->lun
;
3348 m
->tm_flags
= tskim
->tm_cmnd
;
3351 * queue I/O message to firmware
3353 bfa_reqq_produce(tskim
->bfa
, itnim
->reqq
, m
->mh
);
3358 * Send abort request to cleanup an active TM to firmware.
3360 static bfa_boolean_t
3361 bfa_tskim_send_abort(struct bfa_tskim_s
*tskim
)
3363 struct bfa_itnim_s
*itnim
= tskim
->itnim
;
3364 struct bfi_tskim_abortreq_s
*m
;
3367 * check for room in queue to send request now
3369 m
= bfa_reqq_next(tskim
->bfa
, itnim
->reqq
);
3374 * build i/o request message next
3376 bfi_h2i_set(m
->mh
, BFI_MC_TSKIM
, BFI_TSKIM_H2I_ABORT_REQ
,
3377 bfa_fn_lpu(tskim
->bfa
));
3379 m
->tsk_tag
= cpu_to_be16(tskim
->tsk_tag
);
3382 * queue I/O message to firmware
3384 bfa_reqq_produce(tskim
->bfa
, itnim
->reqq
, m
->mh
);
3389 * Call to resume task management cmnd waiting for room in request queue.
3392 bfa_tskim_qresume(void *cbarg
)
3394 struct bfa_tskim_s
*tskim
= cbarg
;
3396 bfa_stats(tskim
->itnim
, tm_qresumes
);
3397 bfa_sm_send_event(tskim
, BFA_TSKIM_SM_QRESUME
);
3401 * Cleanup IOs associated with a task mangement command on IOC failures.
3404 bfa_tskim_iocdisable_ios(struct bfa_tskim_s
*tskim
)
3406 struct bfa_ioim_s
*ioim
;
3407 struct list_head
*qe
, *qen
;
3409 list_for_each_safe(qe
, qen
, &tskim
->io_q
) {
3410 ioim
= (struct bfa_ioim_s
*) qe
;
3411 bfa_ioim_iocdisable(ioim
);
3416 * Handle IOC h/w failure notification from itnim.
3419 bfa_tskim_iocdisable(struct bfa_tskim_s
*tskim
)
3421 tskim
->notify
= BFA_FALSE
;
3422 bfa_stats(tskim
->itnim
, tm_iocdowns
);
3423 bfa_sm_send_event(tskim
, BFA_TSKIM_SM_HWFAIL
);
3427 * Cleanup TM command and associated IOs as part of ITNIM offline.
3430 bfa_tskim_cleanup(struct bfa_tskim_s
*tskim
)
3432 tskim
->notify
= BFA_TRUE
;
3433 bfa_stats(tskim
->itnim
, tm_cleanups
);
3434 bfa_sm_send_event(tskim
, BFA_TSKIM_SM_CLEANUP
);
3438 * Memory allocation and initialization.
3441 bfa_tskim_attach(struct bfa_fcpim_s
*fcpim
)
3443 struct bfa_tskim_s
*tskim
;
3444 struct bfa_fcp_mod_s
*fcp
= fcpim
->fcp
;
3447 INIT_LIST_HEAD(&fcpim
->tskim_free_q
);
3448 INIT_LIST_HEAD(&fcpim
->tskim_unused_q
);
3450 tskim
= (struct bfa_tskim_s
*) bfa_mem_kva_curp(fcp
);
3451 fcpim
->tskim_arr
= tskim
;
3453 for (i
= 0; i
< fcpim
->num_tskim_reqs
; i
++, tskim
++) {
3457 memset(tskim
, 0, sizeof(struct bfa_tskim_s
));
3459 tskim
->bfa
= fcpim
->bfa
;
3460 tskim
->fcpim
= fcpim
;
3461 tskim
->notify
= BFA_FALSE
;
3462 bfa_reqq_winit(&tskim
->reqq_wait
, bfa_tskim_qresume
,
3464 bfa_sm_set_state(tskim
, bfa_tskim_sm_uninit
);
3466 list_add_tail(&tskim
->qe
, &fcpim
->tskim_free_q
);
3469 bfa_mem_kva_curp(fcp
) = (u8
*) tskim
;
3473 bfa_tskim_isr(struct bfa_s
*bfa
, struct bfi_msg_s
*m
)
3475 struct bfa_fcpim_s
*fcpim
= BFA_FCPIM(bfa
);
3476 struct bfi_tskim_rsp_s
*rsp
= (struct bfi_tskim_rsp_s
*) m
;
3477 struct bfa_tskim_s
*tskim
;
3478 u16 tsk_tag
= be16_to_cpu(rsp
->tsk_tag
);
3480 tskim
= BFA_TSKIM_FROM_TAG(fcpim
, tsk_tag
);
3481 WARN_ON(tskim
->tsk_tag
!= tsk_tag
);
3483 tskim
->tsk_status
= rsp
->tsk_status
;
3486 * Firmware sends BFI_TSKIM_STS_ABORTED status for abort
3487 * requests. All other statuses are for normal completions.
3489 if (rsp
->tsk_status
== BFI_TSKIM_STS_ABORTED
) {
3490 bfa_stats(tskim
->itnim
, tm_cleanup_comps
);
3491 bfa_sm_send_event(tskim
, BFA_TSKIM_SM_CLEANUP_DONE
);
3492 } else if (rsp
->tsk_status
== BFI_TSKIM_STS_UTAG
) {
3493 bfa_sm_send_event(tskim
, BFA_TSKIM_SM_UTAG
);
3495 bfa_stats(tskim
->itnim
, tm_fw_rsps
);
3496 bfa_sm_send_event(tskim
, BFA_TSKIM_SM_DONE
);
3501 struct bfa_tskim_s
*
3502 bfa_tskim_alloc(struct bfa_s
*bfa
, struct bfad_tskim_s
*dtsk
)
3504 struct bfa_fcpim_s
*fcpim
= BFA_FCPIM(bfa
);
3505 struct bfa_tskim_s
*tskim
;
3507 bfa_q_deq(&fcpim
->tskim_free_q
, &tskim
);
3516 bfa_tskim_free(struct bfa_tskim_s
*tskim
)
3518 WARN_ON(!bfa_q_is_on_q_func(&tskim
->itnim
->tsk_q
, &tskim
->qe
));
3519 list_del(&tskim
->qe
);
3520 list_add_tail(&tskim
->qe
, &tskim
->fcpim
->tskim_free_q
);
3524 * Start a task management command.
3526 * @param[in] tskim BFA task management command instance
3527 * @param[in] itnim i-t nexus for the task management command
3528 * @param[in] lun lun, if applicable
3529 * @param[in] tm_cmnd Task management command code.
3530 * @param[in] t_secs Timeout in seconds
3535 bfa_tskim_start(struct bfa_tskim_s
*tskim
, struct bfa_itnim_s
*itnim
,
3536 struct scsi_lun lun
,
3537 enum fcp_tm_cmnd tm_cmnd
, u8 tsecs
)
3539 tskim
->itnim
= itnim
;
3541 tskim
->tm_cmnd
= tm_cmnd
;
3542 tskim
->tsecs
= tsecs
;
3543 tskim
->notify
= BFA_FALSE
;
3544 bfa_stats(itnim
, tm_cmnds
);
3546 list_add_tail(&tskim
->qe
, &itnim
->tsk_q
);
3547 bfa_sm_send_event(tskim
, BFA_TSKIM_SM_START
);
3551 bfa_tskim_res_recfg(struct bfa_s
*bfa
, u16 num_tskim_fw
)
3553 struct bfa_fcpim_s
*fcpim
= BFA_FCPIM(bfa
);
3554 struct list_head
*qe
;
3557 for (i
= 0; i
< (fcpim
->num_tskim_reqs
- num_tskim_fw
); i
++) {
3558 bfa_q_deq_tail(&fcpim
->tskim_free_q
, &qe
);
3559 list_add_tail(qe
, &fcpim
->tskim_unused_q
);
3564 bfa_fcp_meminfo(struct bfa_iocfc_cfg_s
*cfg
, struct bfa_meminfo_s
*minfo
,
3567 struct bfa_fcp_mod_s
*fcp
= BFA_FCP_MOD(bfa
);
3568 struct bfa_mem_kva_s
*fcp_kva
= BFA_MEM_FCP_KVA(bfa
);
3569 struct bfa_mem_dma_s
*seg_ptr
;
3570 u16 nsegs
, idx
, per_seg_ios
, num_io_req
;
3574 * ZERO for num_ioim_reqs and num_fwtio_reqs is allowed config value.
3575 * So if the values are non zero, adjust them appropriately.
3577 if (cfg
->fwcfg
.num_ioim_reqs
&&
3578 cfg
->fwcfg
.num_ioim_reqs
< BFA_IOIM_MIN
)
3579 cfg
->fwcfg
.num_ioim_reqs
= BFA_IOIM_MIN
;
3580 else if (cfg
->fwcfg
.num_ioim_reqs
> BFA_IOIM_MAX
)
3581 cfg
->fwcfg
.num_ioim_reqs
= BFA_IOIM_MAX
;
3583 if (cfg
->fwcfg
.num_fwtio_reqs
> BFA_FWTIO_MAX
)
3584 cfg
->fwcfg
.num_fwtio_reqs
= BFA_FWTIO_MAX
;
3586 num_io_req
= (cfg
->fwcfg
.num_ioim_reqs
+ cfg
->fwcfg
.num_fwtio_reqs
);
3587 if (num_io_req
> BFA_IO_MAX
) {
3588 if (cfg
->fwcfg
.num_ioim_reqs
&& cfg
->fwcfg
.num_fwtio_reqs
) {
3589 cfg
->fwcfg
.num_ioim_reqs
= BFA_IO_MAX
/2;
3590 cfg
->fwcfg
.num_fwtio_reqs
= BFA_IO_MAX
/2;
3591 } else if (cfg
->fwcfg
.num_fwtio_reqs
)
3592 cfg
->fwcfg
.num_fwtio_reqs
= BFA_FWTIO_MAX
;
3594 cfg
->fwcfg
.num_ioim_reqs
= BFA_IOIM_MAX
;
3597 bfa_fcpim_meminfo(cfg
, &km_len
);
3599 num_io_req
= (cfg
->fwcfg
.num_ioim_reqs
+ cfg
->fwcfg
.num_fwtio_reqs
);
3600 km_len
+= num_io_req
* sizeof(struct bfa_iotag_s
);
3601 km_len
+= cfg
->fwcfg
.num_rports
* sizeof(struct bfa_itn_s
);
3604 nsegs
= BFI_MEM_DMA_NSEGS(num_io_req
, BFI_IOIM_SNSLEN
);
3605 per_seg_ios
= BFI_MEM_NREQS_SEG(BFI_IOIM_SNSLEN
);
3607 bfa_mem_dma_seg_iter(fcp
, seg_ptr
, nsegs
, idx
) {
3608 if (num_io_req
>= per_seg_ios
) {
3609 num_io_req
-= per_seg_ios
;
3610 bfa_mem_dma_setup(minfo
, seg_ptr
,
3611 per_seg_ios
* BFI_IOIM_SNSLEN
);
3613 bfa_mem_dma_setup(minfo
, seg_ptr
,
3614 num_io_req
* BFI_IOIM_SNSLEN
);
3618 bfa_mem_kva_setup(minfo
, fcp_kva
, km_len
);
3622 bfa_fcp_attach(struct bfa_s
*bfa
, void *bfad
, struct bfa_iocfc_cfg_s
*cfg
,
3623 struct bfa_pcidev_s
*pcidev
)
3625 struct bfa_fcp_mod_s
*fcp
= BFA_FCP_MOD(bfa
);
3626 struct bfa_mem_dma_s
*seg_ptr
;
3627 u16 idx
, nsegs
, num_io_req
;
3629 fcp
->max_ioim_reqs
= cfg
->fwcfg
.num_ioim_reqs
;
3630 fcp
->num_ioim_reqs
= cfg
->fwcfg
.num_ioim_reqs
;
3631 fcp
->num_fwtio_reqs
= cfg
->fwcfg
.num_fwtio_reqs
;
3632 fcp
->num_itns
= cfg
->fwcfg
.num_rports
;
3636 * Setup the pool of snsbase addr's, that is passed to fw as
3637 * part of bfi_iocfc_cfg_s.
3639 num_io_req
= (cfg
->fwcfg
.num_ioim_reqs
+ cfg
->fwcfg
.num_fwtio_reqs
);
3640 nsegs
= BFI_MEM_DMA_NSEGS(num_io_req
, BFI_IOIM_SNSLEN
);
3642 bfa_mem_dma_seg_iter(fcp
, seg_ptr
, nsegs
, idx
) {
3644 if (!bfa_mem_dma_virt(seg_ptr
))
3647 fcp
->snsbase
[idx
].pa
= bfa_mem_dma_phys(seg_ptr
);
3648 fcp
->snsbase
[idx
].kva
= bfa_mem_dma_virt(seg_ptr
);
3649 bfa_iocfc_set_snsbase(bfa
, idx
, fcp
->snsbase
[idx
].pa
);
3652 fcp
->throttle_update_required
= 1;
3653 bfa_fcpim_attach(fcp
, bfad
, cfg
, pcidev
);
3655 bfa_iotag_attach(fcp
);
3657 fcp
->itn_arr
= (struct bfa_itn_s
*) bfa_mem_kva_curp(fcp
);
3658 bfa_mem_kva_curp(fcp
) = (u8
*)fcp
->itn_arr
+
3659 (fcp
->num_itns
* sizeof(struct bfa_itn_s
));
3660 memset(fcp
->itn_arr
, 0,
3661 (fcp
->num_itns
* sizeof(struct bfa_itn_s
)));
3665 bfa_fcp_iocdisable(struct bfa_s
*bfa
)
3667 struct bfa_fcp_mod_s
*fcp
= BFA_FCP_MOD(bfa
);
3669 bfa_fcpim_iocdisable(fcp
);
3673 bfa_fcp_res_recfg(struct bfa_s
*bfa
, u16 num_ioim_fw
, u16 max_ioim_fw
)
3675 struct bfa_fcp_mod_s
*mod
= BFA_FCP_MOD(bfa
);
3676 struct list_head
*qe
;
3679 /* Update io throttle value only once during driver load time */
3680 if (!mod
->throttle_update_required
)
3683 for (i
= 0; i
< (mod
->num_ioim_reqs
- num_ioim_fw
); i
++) {
3684 bfa_q_deq_tail(&mod
->iotag_ioim_free_q
, &qe
);
3685 list_add_tail(qe
, &mod
->iotag_unused_q
);
3688 if (mod
->num_ioim_reqs
!= num_ioim_fw
) {
3689 bfa_trc(bfa
, mod
->num_ioim_reqs
);
3690 bfa_trc(bfa
, num_ioim_fw
);
3693 mod
->max_ioim_reqs
= max_ioim_fw
;
3694 mod
->num_ioim_reqs
= num_ioim_fw
;
3695 mod
->throttle_update_required
= 0;
3699 bfa_itn_create(struct bfa_s
*bfa
, struct bfa_rport_s
*rport
,
3700 void (*isr
)(struct bfa_s
*bfa
, struct bfi_msg_s
*m
))
3702 struct bfa_fcp_mod_s
*fcp
= BFA_FCP_MOD(bfa
);
3703 struct bfa_itn_s
*itn
;
3705 itn
= BFA_ITN_FROM_TAG(fcp
, rport
->rport_tag
);
3710 * Itn interrupt processing.
3713 bfa_itn_isr(struct bfa_s
*bfa
, struct bfi_msg_s
*m
)
3715 struct bfa_fcp_mod_s
*fcp
= BFA_FCP_MOD(bfa
);
3716 union bfi_itn_i2h_msg_u msg
;
3717 struct bfa_itn_s
*itn
;
3720 itn
= BFA_ITN_FROM_TAG(fcp
, msg
.create_rsp
->bfa_handle
);
3729 bfa_iotag_attach(struct bfa_fcp_mod_s
*fcp
)
3731 struct bfa_iotag_s
*iotag
;
3734 iotag
= (struct bfa_iotag_s
*) bfa_mem_kva_curp(fcp
);
3735 fcp
->iotag_arr
= iotag
;
3737 INIT_LIST_HEAD(&fcp
->iotag_ioim_free_q
);
3738 INIT_LIST_HEAD(&fcp
->iotag_tio_free_q
);
3739 INIT_LIST_HEAD(&fcp
->iotag_unused_q
);
3741 num_io_req
= fcp
->num_ioim_reqs
+ fcp
->num_fwtio_reqs
;
3742 for (i
= 0; i
< num_io_req
; i
++, iotag
++) {
3743 memset(iotag
, 0, sizeof(struct bfa_iotag_s
));
3745 if (i
< fcp
->num_ioim_reqs
)
3746 list_add_tail(&iotag
->qe
, &fcp
->iotag_ioim_free_q
);
3748 list_add_tail(&iotag
->qe
, &fcp
->iotag_tio_free_q
);
3751 bfa_mem_kva_curp(fcp
) = (u8
*) iotag
;
3756 * To send config req, first try to use throttle value from flash
3757 * If 0, then use driver parameter
3758 * We need to use min(flash_val, drv_val) because
3759 * memory allocation was done based on this cfg'd value
3762 bfa_fcpim_get_throttle_cfg(struct bfa_s
*bfa
, u16 drv_cfg_param
)
3765 struct bfa_fcp_mod_s
*fcp
= BFA_FCP_MOD(bfa
);
3768 * If throttle value from flash is already in effect after driver is
3769 * loaded then until next load, always return current value instead
3770 * of actual flash value
3772 if (!fcp
->throttle_update_required
)
3773 return (u16
)fcp
->num_ioim_reqs
;
3775 tmp
= bfa_dconf_read_data_valid(bfa
) ? bfa_fcpim_read_throttle(bfa
) : 0;
3776 if (!tmp
|| (tmp
> drv_cfg_param
))
3777 tmp
= drv_cfg_param
;
3783 bfa_fcpim_write_throttle(struct bfa_s
*bfa
, u16 value
)
3785 if (!bfa_dconf_get_min_cfg(bfa
)) {
3786 BFA_DCONF_MOD(bfa
)->dconf
->throttle_cfg
.value
= value
;
3787 BFA_DCONF_MOD(bfa
)->dconf
->throttle_cfg
.is_valid
= 1;
3788 return BFA_STATUS_OK
;
3791 return BFA_STATUS_FAILED
;
3795 bfa_fcpim_read_throttle(struct bfa_s
*bfa
)
3797 struct bfa_throttle_cfg_s
*throttle_cfg
=
3798 &(BFA_DCONF_MOD(bfa
)->dconf
->throttle_cfg
);
3800 return ((!bfa_dconf_get_min_cfg(bfa
)) ?
3801 ((throttle_cfg
->is_valid
== 1) ? (throttle_cfg
->value
) : 0) : 0);
3805 bfa_fcpim_throttle_set(struct bfa_s
*bfa
, u16 value
)
3807 /* in min cfg no commands should run. */
3808 if ((bfa_dconf_get_min_cfg(bfa
) == BFA_TRUE
) ||
3809 (!bfa_dconf_read_data_valid(bfa
)))
3810 return BFA_STATUS_FAILED
;
3812 bfa_fcpim_write_throttle(bfa
, value
);
3814 return bfa_dconf_update(bfa
);
3818 bfa_fcpim_throttle_get(struct bfa_s
*bfa
, void *buf
)
3820 struct bfa_fcpim_s
*fcpim
= BFA_FCPIM(bfa
);
3821 struct bfa_defs_fcpim_throttle_s throttle
;
3823 if ((bfa_dconf_get_min_cfg(bfa
) == BFA_TRUE
) ||
3824 (!bfa_dconf_read_data_valid(bfa
)))
3825 return BFA_STATUS_FAILED
;
3827 memset(&throttle
, 0, sizeof(struct bfa_defs_fcpim_throttle_s
));
3829 throttle
.cur_value
= (u16
)(fcpim
->fcp
->num_ioim_reqs
);
3830 throttle
.cfg_value
= bfa_fcpim_read_throttle(bfa
);
3831 if (!throttle
.cfg_value
)
3832 throttle
.cfg_value
= throttle
.cur_value
;
3833 throttle
.max_value
= (u16
)(fcpim
->fcp
->max_ioim_reqs
);
3834 memcpy(buf
, &throttle
, sizeof(struct bfa_defs_fcpim_throttle_s
));
3836 return BFA_STATUS_OK
;