Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    1) // SPDX-License-Identifier: GPL-2.0-only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    3)  * Copyright (c) 2005-2014 Brocade Communications Systems, Inc.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    4)  * Copyright (c) 2014- QLogic Corporation.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    5)  * All rights reserved
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    6)  * www.qlogic.com
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    7)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    8)  * Linux driver for QLogic BR-series Fibre Channel Host Bus Adapter.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    9)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   10) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   11) #include "bfad_drv.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   12) #include "bfa_modules.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   13) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   14) BFA_TRC_FILE(HAL, FCPIM);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   15) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   16) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   17)  *  BFA ITNIM Related definitions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   18)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   19) static void bfa_itnim_update_del_itn_stats(struct bfa_itnim_s *itnim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   20) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   21) #define BFA_ITNIM_FROM_TAG(_fcpim, _tag)                                \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   22) 	(((_fcpim)->itnim_arr + ((_tag) & ((_fcpim)->num_itnims - 1))))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   23) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   24) #define bfa_fcpim_additn(__itnim)					\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   25) 	list_add_tail(&(__itnim)->qe, &(__itnim)->fcpim->itnim_q)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   26) #define bfa_fcpim_delitn(__itnim)	do {				\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   27) 	WARN_ON(!bfa_q_is_on_q(&(__itnim)->fcpim->itnim_q, __itnim));   \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   28) 	bfa_itnim_update_del_itn_stats(__itnim);      \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   29) 	list_del(&(__itnim)->qe);      \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   30) 	WARN_ON(!list_empty(&(__itnim)->io_q));				\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   31) 	WARN_ON(!list_empty(&(__itnim)->io_cleanup_q));			\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   32) 	WARN_ON(!list_empty(&(__itnim)->pending_q));			\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   33) } while (0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   34) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   35) #define bfa_itnim_online_cb(__itnim) do {				\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   36) 	if ((__itnim)->bfa->fcs)					\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   37) 		bfa_cb_itnim_online((__itnim)->ditn);      \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   38) 	else {								\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   39) 		bfa_cb_queue((__itnim)->bfa, &(__itnim)->hcb_qe,	\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   40) 		__bfa_cb_itnim_online, (__itnim));      \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   41) 	}								\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   42) } while (0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   43) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   44) #define bfa_itnim_offline_cb(__itnim) do {				\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   45) 	if ((__itnim)->bfa->fcs)					\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   46) 		bfa_cb_itnim_offline((__itnim)->ditn);      \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   47) 	else {								\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   48) 		bfa_cb_queue((__itnim)->bfa, &(__itnim)->hcb_qe,	\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   49) 		__bfa_cb_itnim_offline, (__itnim));      \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   50) 	}								\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   51) } while (0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   52) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   53) #define bfa_itnim_sler_cb(__itnim) do {					\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   54) 	if ((__itnim)->bfa->fcs)					\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   55) 		bfa_cb_itnim_sler((__itnim)->ditn);      \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   56) 	else {								\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   57) 		bfa_cb_queue((__itnim)->bfa, &(__itnim)->hcb_qe,	\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   58) 		__bfa_cb_itnim_sler, (__itnim));      \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   59) 	}								\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   60) } while (0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   61) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   62) enum bfa_ioim_lm_ua_status {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   63) 	BFA_IOIM_LM_UA_RESET = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   64) 	BFA_IOIM_LM_UA_SET = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   65) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   66) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   67) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   68)  *  itnim state machine event
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   69)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   70) enum bfa_itnim_event {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   71) 	BFA_ITNIM_SM_CREATE = 1,	/*  itnim is created */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   72) 	BFA_ITNIM_SM_ONLINE = 2,	/*  itnim is online */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   73) 	BFA_ITNIM_SM_OFFLINE = 3,	/*  itnim is offline */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   74) 	BFA_ITNIM_SM_FWRSP = 4,		/*  firmware response */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   75) 	BFA_ITNIM_SM_DELETE = 5,	/*  deleting an existing itnim */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   76) 	BFA_ITNIM_SM_CLEANUP = 6,	/*  IO cleanup completion */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   77) 	BFA_ITNIM_SM_SLER = 7,		/*  second level error recovery */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   78) 	BFA_ITNIM_SM_HWFAIL = 8,	/*  IOC h/w failure event */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   79) 	BFA_ITNIM_SM_QRESUME = 9,	/*  queue space available */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   80) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   81) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   82) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   83)  *  BFA IOIM related definitions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   84)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   85) #define bfa_ioim_move_to_comp_q(__ioim) do {				\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   86) 	list_del(&(__ioim)->qe);					\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   87) 	list_add_tail(&(__ioim)->qe, &(__ioim)->fcpim->ioim_comp_q);	\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   88) } while (0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   89) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   90) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   91) #define bfa_ioim_cb_profile_comp(__fcpim, __ioim) do {			\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   92) 	if ((__fcpim)->profile_comp)					\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   93) 		(__fcpim)->profile_comp(__ioim);			\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   94) } while (0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   95) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   96) #define bfa_ioim_cb_profile_start(__fcpim, __ioim) do {			\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   97) 	if ((__fcpim)->profile_start)					\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   98) 		(__fcpim)->profile_start(__ioim);			\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   99) } while (0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  100) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  101) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  102)  * IO state machine events
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  103)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  104) enum bfa_ioim_event {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  105) 	BFA_IOIM_SM_START	= 1,	/*  io start request from host */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  106) 	BFA_IOIM_SM_COMP_GOOD	= 2,	/*  io good comp, resource free */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  107) 	BFA_IOIM_SM_COMP	= 3,	/*  io comp, resource is free */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  108) 	BFA_IOIM_SM_COMP_UTAG	= 4,	/*  io comp, resource is free */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  109) 	BFA_IOIM_SM_DONE	= 5,	/*  io comp, resource not free */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  110) 	BFA_IOIM_SM_FREE	= 6,	/*  io resource is freed */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  111) 	BFA_IOIM_SM_ABORT	= 7,	/*  abort request from scsi stack */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  112) 	BFA_IOIM_SM_ABORT_COMP	= 8,	/*  abort from f/w */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  113) 	BFA_IOIM_SM_ABORT_DONE	= 9,	/*  abort completion from f/w */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  114) 	BFA_IOIM_SM_QRESUME	= 10,	/*  CQ space available to queue IO */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  115) 	BFA_IOIM_SM_SGALLOCED	= 11,	/*  SG page allocation successful */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  116) 	BFA_IOIM_SM_SQRETRY	= 12,	/*  sequence recovery retry */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  117) 	BFA_IOIM_SM_HCB		= 13,	/*  bfa callback complete */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  118) 	BFA_IOIM_SM_CLEANUP	= 14,	/*  IO cleanup from itnim */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  119) 	BFA_IOIM_SM_TMSTART	= 15,	/*  IO cleanup from tskim */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  120) 	BFA_IOIM_SM_TMDONE	= 16,	/*  IO cleanup from tskim */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  121) 	BFA_IOIM_SM_HWFAIL	= 17,	/*  IOC h/w failure event */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  122) 	BFA_IOIM_SM_IOTOV	= 18,	/*  ITN offline TOV */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  123) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  124) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  125) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  126) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  127)  *  BFA TSKIM related definitions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  128)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  129) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  130) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  131)  * task management completion handling
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  132)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  133) #define bfa_tskim_qcomp(__tskim, __cbfn) do {				\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  134) 	bfa_cb_queue((__tskim)->bfa, &(__tskim)->hcb_qe, __cbfn, (__tskim));\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  135) 	bfa_tskim_notify_comp(__tskim);      \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  136) } while (0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  137) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  138) #define bfa_tskim_notify_comp(__tskim) do {				\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  139) 	if ((__tskim)->notify)						\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  140) 		bfa_itnim_tskdone((__tskim)->itnim);      \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  141) } while (0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  142) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  143) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  144) enum bfa_tskim_event {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  145) 	BFA_TSKIM_SM_START	= 1,	/*  TM command start		*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  146) 	BFA_TSKIM_SM_DONE	= 2,	/*  TM completion		*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  147) 	BFA_TSKIM_SM_QRESUME	= 3,	/*  resume after qfull		*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  148) 	BFA_TSKIM_SM_HWFAIL	= 5,	/*  IOC h/w failure event	*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  149) 	BFA_TSKIM_SM_HCB	= 6,	/*  BFA callback completion	*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  150) 	BFA_TSKIM_SM_IOS_DONE	= 7,	/*  IO and sub TM completions	*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  151) 	BFA_TSKIM_SM_CLEANUP	= 8,	/*  TM cleanup on ITN offline	*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  152) 	BFA_TSKIM_SM_CLEANUP_DONE = 9,	/*  TM abort completion	*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  153) 	BFA_TSKIM_SM_UTAG	= 10,	/*  TM completion unknown tag  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  154) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  155) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  156) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  157)  * forward declaration for BFA ITNIM functions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  158)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  159) static void     bfa_itnim_iocdisable_cleanup(struct bfa_itnim_s *itnim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  160) static bfa_boolean_t bfa_itnim_send_fwcreate(struct bfa_itnim_s *itnim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  161) static bfa_boolean_t bfa_itnim_send_fwdelete(struct bfa_itnim_s *itnim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  162) static void     bfa_itnim_cleanp_comp(void *itnim_cbarg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  163) static void     bfa_itnim_cleanup(struct bfa_itnim_s *itnim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  164) static void     __bfa_cb_itnim_online(void *cbarg, bfa_boolean_t complete);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  165) static void     __bfa_cb_itnim_offline(void *cbarg, bfa_boolean_t complete);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  166) static void     __bfa_cb_itnim_sler(void *cbarg, bfa_boolean_t complete);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  167) static void     bfa_itnim_iotov_online(struct bfa_itnim_s *itnim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  168) static void     bfa_itnim_iotov_cleanup(struct bfa_itnim_s *itnim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  169) static void     bfa_itnim_iotov(void *itnim_arg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  170) static void     bfa_itnim_iotov_start(struct bfa_itnim_s *itnim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  171) static void     bfa_itnim_iotov_stop(struct bfa_itnim_s *itnim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  172) static void     bfa_itnim_iotov_delete(struct bfa_itnim_s *itnim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  173) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  174) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  175)  * forward declaration of ITNIM state machine
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  176)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  177) static void     bfa_itnim_sm_uninit(struct bfa_itnim_s *itnim,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  178) 					enum bfa_itnim_event event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  179) static void     bfa_itnim_sm_created(struct bfa_itnim_s *itnim,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  180) 					enum bfa_itnim_event event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  181) static void     bfa_itnim_sm_fwcreate(struct bfa_itnim_s *itnim,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  182) 					enum bfa_itnim_event event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  183) static void     bfa_itnim_sm_delete_pending(struct bfa_itnim_s *itnim,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  184) 					enum bfa_itnim_event event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  185) static void     bfa_itnim_sm_online(struct bfa_itnim_s *itnim,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  186) 					enum bfa_itnim_event event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  187) static void     bfa_itnim_sm_sler(struct bfa_itnim_s *itnim,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  188) 					enum bfa_itnim_event event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  189) static void     bfa_itnim_sm_cleanup_offline(struct bfa_itnim_s *itnim,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  190) 					enum bfa_itnim_event event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  191) static void     bfa_itnim_sm_cleanup_delete(struct bfa_itnim_s *itnim,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  192) 					enum bfa_itnim_event event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  193) static void     bfa_itnim_sm_fwdelete(struct bfa_itnim_s *itnim,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  194) 					enum bfa_itnim_event event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  195) static void     bfa_itnim_sm_offline(struct bfa_itnim_s *itnim,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  196) 					enum bfa_itnim_event event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  197) static void     bfa_itnim_sm_iocdisable(struct bfa_itnim_s *itnim,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  198) 					enum bfa_itnim_event event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  199) static void     bfa_itnim_sm_deleting(struct bfa_itnim_s *itnim,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  200) 					enum bfa_itnim_event event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  201) static void     bfa_itnim_sm_fwcreate_qfull(struct bfa_itnim_s *itnim,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  202) 					enum bfa_itnim_event event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  203) static void     bfa_itnim_sm_fwdelete_qfull(struct bfa_itnim_s *itnim,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  204) 					enum bfa_itnim_event event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  205) static void     bfa_itnim_sm_deleting_qfull(struct bfa_itnim_s *itnim,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  206) 					enum bfa_itnim_event event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  207) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  208) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  209)  * forward declaration for BFA IOIM functions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  210)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  211) static bfa_boolean_t	bfa_ioim_send_ioreq(struct bfa_ioim_s *ioim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  212) static bfa_boolean_t	bfa_ioim_sgpg_alloc(struct bfa_ioim_s *ioim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  213) static bfa_boolean_t	bfa_ioim_send_abort(struct bfa_ioim_s *ioim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  214) static void		bfa_ioim_notify_cleanup(struct bfa_ioim_s *ioim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  215) static void __bfa_cb_ioim_good_comp(void *cbarg, bfa_boolean_t complete);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  216) static void __bfa_cb_ioim_comp(void *cbarg, bfa_boolean_t complete);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  217) static void __bfa_cb_ioim_abort(void *cbarg, bfa_boolean_t complete);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  218) static void __bfa_cb_ioim_failed(void *cbarg, bfa_boolean_t complete);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  219) static void __bfa_cb_ioim_pathtov(void *cbarg, bfa_boolean_t complete);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  220) static bfa_boolean_t    bfa_ioim_is_abortable(struct bfa_ioim_s *ioim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  221) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  222) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  223)  * forward declaration of BFA IO state machine
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  224)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  225) static void     bfa_ioim_sm_uninit(struct bfa_ioim_s *ioim,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  226) 					enum bfa_ioim_event event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  227) static void     bfa_ioim_sm_sgalloc(struct bfa_ioim_s *ioim,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  228) 					enum bfa_ioim_event event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  229) static void     bfa_ioim_sm_active(struct bfa_ioim_s *ioim,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  230) 					enum bfa_ioim_event event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  231) static void     bfa_ioim_sm_abort(struct bfa_ioim_s *ioim,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  232) 					enum bfa_ioim_event event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  233) static void     bfa_ioim_sm_cleanup(struct bfa_ioim_s *ioim,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  234) 					enum bfa_ioim_event event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  235) static void     bfa_ioim_sm_qfull(struct bfa_ioim_s *ioim,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  236) 					enum bfa_ioim_event event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  237) static void     bfa_ioim_sm_abort_qfull(struct bfa_ioim_s *ioim,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  238) 					enum bfa_ioim_event event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  239) static void     bfa_ioim_sm_cleanup_qfull(struct bfa_ioim_s *ioim,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  240) 					enum bfa_ioim_event event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  241) static void     bfa_ioim_sm_hcb(struct bfa_ioim_s *ioim,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  242) 					enum bfa_ioim_event event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  243) static void     bfa_ioim_sm_hcb_free(struct bfa_ioim_s *ioim,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  244) 					enum bfa_ioim_event event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  245) static void     bfa_ioim_sm_resfree(struct bfa_ioim_s *ioim,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  246) 					enum bfa_ioim_event event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  247) static void	bfa_ioim_sm_cmnd_retry(struct bfa_ioim_s *ioim,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  248) 					enum bfa_ioim_event event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  249) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  250)  * forward declaration for BFA TSKIM functions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  251)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  252) static void     __bfa_cb_tskim_done(void *cbarg, bfa_boolean_t complete);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  253) static void     __bfa_cb_tskim_failed(void *cbarg, bfa_boolean_t complete);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  254) static bfa_boolean_t bfa_tskim_match_scope(struct bfa_tskim_s *tskim,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  255) 					struct scsi_lun lun);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  256) static void     bfa_tskim_gather_ios(struct bfa_tskim_s *tskim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  257) static void     bfa_tskim_cleanp_comp(void *tskim_cbarg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  258) static void     bfa_tskim_cleanup_ios(struct bfa_tskim_s *tskim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  259) static bfa_boolean_t bfa_tskim_send(struct bfa_tskim_s *tskim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  260) static bfa_boolean_t bfa_tskim_send_abort(struct bfa_tskim_s *tskim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  261) static void     bfa_tskim_iocdisable_ios(struct bfa_tskim_s *tskim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  262) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  263) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  264)  * forward declaration of BFA TSKIM state machine
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  265)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  266) static void     bfa_tskim_sm_uninit(struct bfa_tskim_s *tskim,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  267) 					enum bfa_tskim_event event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  268) static void     bfa_tskim_sm_active(struct bfa_tskim_s *tskim,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  269) 					enum bfa_tskim_event event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  270) static void     bfa_tskim_sm_cleanup(struct bfa_tskim_s *tskim,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  271) 					enum bfa_tskim_event event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  272) static void     bfa_tskim_sm_iocleanup(struct bfa_tskim_s *tskim,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  273) 					enum bfa_tskim_event event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  274) static void     bfa_tskim_sm_qfull(struct bfa_tskim_s *tskim,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  275) 					enum bfa_tskim_event event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  276) static void     bfa_tskim_sm_cleanup_qfull(struct bfa_tskim_s *tskim,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  277) 					enum bfa_tskim_event event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  278) static void     bfa_tskim_sm_hcb(struct bfa_tskim_s *tskim,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  279) 					enum bfa_tskim_event event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  280) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  281)  *  BFA FCP Initiator Mode module
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  282)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  283) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  284) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  285)  * Compute and return memory needed by FCP(im) module.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  286)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  287) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  288) bfa_fcpim_meminfo(struct bfa_iocfc_cfg_s *cfg, u32 *km_len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  289) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  290) 	bfa_itnim_meminfo(cfg, km_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  291) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  292) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  293) 	 * IO memory
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  294) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  295) 	*km_len += cfg->fwcfg.num_ioim_reqs *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  296) 	  (sizeof(struct bfa_ioim_s) + sizeof(struct bfa_ioim_sp_s));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  297) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  298) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  299) 	 * task management command memory
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  300) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  301) 	if (cfg->fwcfg.num_tskim_reqs < BFA_TSKIM_MIN)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  302) 		cfg->fwcfg.num_tskim_reqs = BFA_TSKIM_MIN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  303) 	*km_len += cfg->fwcfg.num_tskim_reqs * sizeof(struct bfa_tskim_s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  304) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  305) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  306) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  307) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  308) bfa_fcpim_attach(struct bfa_fcp_mod_s *fcp, void *bfad,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  309) 		struct bfa_iocfc_cfg_s *cfg, struct bfa_pcidev_s *pcidev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  310) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  311) 	struct bfa_fcpim_s *fcpim = &fcp->fcpim;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  312) 	struct bfa_s *bfa = fcp->bfa;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  313) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  314) 	bfa_trc(bfa, cfg->drvcfg.path_tov);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  315) 	bfa_trc(bfa, cfg->fwcfg.num_rports);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  316) 	bfa_trc(bfa, cfg->fwcfg.num_ioim_reqs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  317) 	bfa_trc(bfa, cfg->fwcfg.num_tskim_reqs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  318) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  319) 	fcpim->fcp		= fcp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  320) 	fcpim->bfa		= bfa;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  321) 	fcpim->num_itnims	= cfg->fwcfg.num_rports;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  322) 	fcpim->num_tskim_reqs = cfg->fwcfg.num_tskim_reqs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  323) 	fcpim->path_tov		= cfg->drvcfg.path_tov;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  324) 	fcpim->delay_comp	= cfg->drvcfg.delay_comp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  325) 	fcpim->profile_comp = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  326) 	fcpim->profile_start = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  327) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  328) 	bfa_itnim_attach(fcpim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  329) 	bfa_tskim_attach(fcpim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  330) 	bfa_ioim_attach(fcpim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  331) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  332) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  333) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  334) bfa_fcpim_iocdisable(struct bfa_fcp_mod_s *fcp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  335) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  336) 	struct bfa_fcpim_s *fcpim = &fcp->fcpim;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  337) 	struct bfa_itnim_s *itnim;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  338) 	struct list_head *qe, *qen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  339) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  340) 	/* Enqueue unused ioim resources to free_q */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  341) 	list_splice_tail_init(&fcpim->tskim_unused_q, &fcpim->tskim_free_q);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  342) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  343) 	list_for_each_safe(qe, qen, &fcpim->itnim_q) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  344) 		itnim = (struct bfa_itnim_s *) qe;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  345) 		bfa_itnim_iocdisable(itnim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  346) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  347) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  348) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  349) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  350) bfa_fcpim_path_tov_set(struct bfa_s *bfa, u16 path_tov)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  351) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  352) 	struct bfa_fcpim_s *fcpim = BFA_FCPIM(bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  353) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  354) 	fcpim->path_tov = path_tov * 1000;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  355) 	if (fcpim->path_tov > BFA_FCPIM_PATHTOV_MAX)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  356) 		fcpim->path_tov = BFA_FCPIM_PATHTOV_MAX;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  357) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  358) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  359) u16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  360) bfa_fcpim_path_tov_get(struct bfa_s *bfa)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  361) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  362) 	struct bfa_fcpim_s *fcpim = BFA_FCPIM(bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  363) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  364) 	return fcpim->path_tov / 1000;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  365) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  366) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  367) #define bfa_fcpim_add_iostats(__l, __r, __stats)	\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  368) 	(__l->__stats += __r->__stats)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  369) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  370) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  371) bfa_fcpim_add_stats(struct bfa_itnim_iostats_s *lstats,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  372) 		struct bfa_itnim_iostats_s *rstats)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  373) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  374) 	bfa_fcpim_add_iostats(lstats, rstats, total_ios);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  375) 	bfa_fcpim_add_iostats(lstats, rstats, qresumes);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  376) 	bfa_fcpim_add_iostats(lstats, rstats, no_iotags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  377) 	bfa_fcpim_add_iostats(lstats, rstats, io_aborts);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  378) 	bfa_fcpim_add_iostats(lstats, rstats, no_tskims);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  379) 	bfa_fcpim_add_iostats(lstats, rstats, iocomp_ok);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  380) 	bfa_fcpim_add_iostats(lstats, rstats, iocomp_underrun);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  381) 	bfa_fcpim_add_iostats(lstats, rstats, iocomp_overrun);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  382) 	bfa_fcpim_add_iostats(lstats, rstats, iocomp_aborted);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  383) 	bfa_fcpim_add_iostats(lstats, rstats, iocomp_timedout);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  384) 	bfa_fcpim_add_iostats(lstats, rstats, iocom_nexus_abort);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  385) 	bfa_fcpim_add_iostats(lstats, rstats, iocom_proto_err);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  386) 	bfa_fcpim_add_iostats(lstats, rstats, iocom_dif_err);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  387) 	bfa_fcpim_add_iostats(lstats, rstats, iocom_sqer_needed);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  388) 	bfa_fcpim_add_iostats(lstats, rstats, iocom_res_free);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  389) 	bfa_fcpim_add_iostats(lstats, rstats, iocom_hostabrts);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  390) 	bfa_fcpim_add_iostats(lstats, rstats, iocom_utags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  391) 	bfa_fcpim_add_iostats(lstats, rstats, io_cleanups);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  392) 	bfa_fcpim_add_iostats(lstats, rstats, io_tmaborts);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  393) 	bfa_fcpim_add_iostats(lstats, rstats, onlines);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  394) 	bfa_fcpim_add_iostats(lstats, rstats, offlines);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  395) 	bfa_fcpim_add_iostats(lstats, rstats, creates);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  396) 	bfa_fcpim_add_iostats(lstats, rstats, deletes);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  397) 	bfa_fcpim_add_iostats(lstats, rstats, create_comps);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  398) 	bfa_fcpim_add_iostats(lstats, rstats, delete_comps);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  399) 	bfa_fcpim_add_iostats(lstats, rstats, sler_events);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  400) 	bfa_fcpim_add_iostats(lstats, rstats, fw_create);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  401) 	bfa_fcpim_add_iostats(lstats, rstats, fw_delete);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  402) 	bfa_fcpim_add_iostats(lstats, rstats, ioc_disabled);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  403) 	bfa_fcpim_add_iostats(lstats, rstats, cleanup_comps);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  404) 	bfa_fcpim_add_iostats(lstats, rstats, tm_cmnds);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  405) 	bfa_fcpim_add_iostats(lstats, rstats, tm_fw_rsps);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  406) 	bfa_fcpim_add_iostats(lstats, rstats, tm_success);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  407) 	bfa_fcpim_add_iostats(lstats, rstats, tm_failures);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  408) 	bfa_fcpim_add_iostats(lstats, rstats, tm_io_comps);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  409) 	bfa_fcpim_add_iostats(lstats, rstats, tm_qresumes);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  410) 	bfa_fcpim_add_iostats(lstats, rstats, tm_iocdowns);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  411) 	bfa_fcpim_add_iostats(lstats, rstats, tm_cleanups);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  412) 	bfa_fcpim_add_iostats(lstats, rstats, tm_cleanup_comps);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  413) 	bfa_fcpim_add_iostats(lstats, rstats, io_comps);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  414) 	bfa_fcpim_add_iostats(lstats, rstats, input_reqs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  415) 	bfa_fcpim_add_iostats(lstats, rstats, output_reqs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  416) 	bfa_fcpim_add_iostats(lstats, rstats, rd_throughput);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  417) 	bfa_fcpim_add_iostats(lstats, rstats, wr_throughput);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  418) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  419) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  420) bfa_status_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  421) bfa_fcpim_port_iostats(struct bfa_s *bfa,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  422) 		struct bfa_itnim_iostats_s *stats, u8 lp_tag)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  423) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  424) 	struct bfa_fcpim_s *fcpim = BFA_FCPIM(bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  425) 	struct list_head *qe, *qen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  426) 	struct bfa_itnim_s *itnim;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  427) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  428) 	/* accumulate IO stats from itnim */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  429) 	memset(stats, 0, sizeof(struct bfa_itnim_iostats_s));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  430) 	list_for_each_safe(qe, qen, &fcpim->itnim_q) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  431) 		itnim = (struct bfa_itnim_s *) qe;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  432) 		if (itnim->rport->rport_info.lp_tag != lp_tag)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  433) 			continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  434) 		bfa_fcpim_add_stats(stats, &(itnim->stats));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  435) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  436) 	return BFA_STATUS_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  437) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  438) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  439) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  440) bfa_ioim_profile_comp(struct bfa_ioim_s *ioim)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  441) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  442) 	struct bfa_itnim_latency_s *io_lat =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  443) 			&(ioim->itnim->ioprofile.io_latency);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  444) 	u32 val, idx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  445) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  446) 	val = (u32)(jiffies - ioim->start_time);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  447) 	idx = bfa_ioim_get_index(scsi_bufflen((struct scsi_cmnd *)ioim->dio));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  448) 	bfa_itnim_ioprofile_update(ioim->itnim, idx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  449) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  450) 	io_lat->count[idx]++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  451) 	io_lat->min[idx] = (io_lat->min[idx] < val) ? io_lat->min[idx] : val;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  452) 	io_lat->max[idx] = (io_lat->max[idx] > val) ? io_lat->max[idx] : val;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  453) 	io_lat->avg[idx] += val;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  454) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  455) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  456) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  457) bfa_ioim_profile_start(struct bfa_ioim_s *ioim)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  458) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  459) 	ioim->start_time = jiffies;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  460) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  461) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  462) bfa_status_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  463) bfa_fcpim_profile_on(struct bfa_s *bfa, time64_t time)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  464) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  465) 	struct bfa_itnim_s *itnim;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  466) 	struct bfa_fcpim_s *fcpim = BFA_FCPIM(bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  467) 	struct list_head *qe, *qen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  468) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  469) 	/* accumulate IO stats from itnim */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  470) 	list_for_each_safe(qe, qen, &fcpim->itnim_q) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  471) 		itnim = (struct bfa_itnim_s *) qe;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  472) 		bfa_itnim_clear_stats(itnim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  473) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  474) 	fcpim->io_profile = BFA_TRUE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  475) 	fcpim->io_profile_start_time = time;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  476) 	fcpim->profile_comp = bfa_ioim_profile_comp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  477) 	fcpim->profile_start = bfa_ioim_profile_start;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  478) 	return BFA_STATUS_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  479) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  480) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  481) bfa_status_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  482) bfa_fcpim_profile_off(struct bfa_s *bfa)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  483) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  484) 	struct bfa_fcpim_s *fcpim = BFA_FCPIM(bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  485) 	fcpim->io_profile = BFA_FALSE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  486) 	fcpim->io_profile_start_time = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  487) 	fcpim->profile_comp = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  488) 	fcpim->profile_start = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  489) 	return BFA_STATUS_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  490) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  491) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  492) u16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  493) bfa_fcpim_qdepth_get(struct bfa_s *bfa)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  494) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  495) 	struct bfa_fcpim_s *fcpim = BFA_FCPIM(bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  496) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  497) 	return fcpim->q_depth;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  498) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  499) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  500) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  501)  *  BFA ITNIM module state machine functions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  502)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  503) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  504) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  505)  * Beginning/unallocated state - no events expected.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  506)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  507) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  508) bfa_itnim_sm_uninit(struct bfa_itnim_s *itnim, enum bfa_itnim_event event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  509) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  510) 	bfa_trc(itnim->bfa, itnim->rport->rport_tag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  511) 	bfa_trc(itnim->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  512) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  513) 	switch (event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  514) 	case BFA_ITNIM_SM_CREATE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  515) 		bfa_sm_set_state(itnim, bfa_itnim_sm_created);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  516) 		itnim->is_online = BFA_FALSE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  517) 		bfa_fcpim_additn(itnim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  518) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  519) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  520) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  521) 		bfa_sm_fault(itnim->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  522) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  523) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  524) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  525) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  526)  * Beginning state, only online event expected.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  527)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  528) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  529) bfa_itnim_sm_created(struct bfa_itnim_s *itnim, enum bfa_itnim_event event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  530) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  531) 	bfa_trc(itnim->bfa, itnim->rport->rport_tag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  532) 	bfa_trc(itnim->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  533) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  534) 	switch (event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  535) 	case BFA_ITNIM_SM_ONLINE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  536) 		if (bfa_itnim_send_fwcreate(itnim))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  537) 			bfa_sm_set_state(itnim, bfa_itnim_sm_fwcreate);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  538) 		else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  539) 			bfa_sm_set_state(itnim, bfa_itnim_sm_fwcreate_qfull);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  540) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  541) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  542) 	case BFA_ITNIM_SM_DELETE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  543) 		bfa_sm_set_state(itnim, bfa_itnim_sm_uninit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  544) 		bfa_fcpim_delitn(itnim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  545) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  546) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  547) 	case BFA_ITNIM_SM_HWFAIL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  548) 		bfa_sm_set_state(itnim, bfa_itnim_sm_iocdisable);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  549) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  550) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  551) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  552) 		bfa_sm_fault(itnim->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  553) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  554) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  555) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  556) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  557)  *	Waiting for itnim create response from firmware.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  558)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  559) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  560) bfa_itnim_sm_fwcreate(struct bfa_itnim_s *itnim, enum bfa_itnim_event event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  561) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  562) 	bfa_trc(itnim->bfa, itnim->rport->rport_tag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  563) 	bfa_trc(itnim->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  564) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  565) 	switch (event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  566) 	case BFA_ITNIM_SM_FWRSP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  567) 		bfa_sm_set_state(itnim, bfa_itnim_sm_online);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  568) 		itnim->is_online = BFA_TRUE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  569) 		bfa_itnim_iotov_online(itnim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  570) 		bfa_itnim_online_cb(itnim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  571) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  572) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  573) 	case BFA_ITNIM_SM_DELETE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  574) 		bfa_sm_set_state(itnim, bfa_itnim_sm_delete_pending);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  575) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  576) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  577) 	case BFA_ITNIM_SM_OFFLINE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  578) 		if (bfa_itnim_send_fwdelete(itnim))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  579) 			bfa_sm_set_state(itnim, bfa_itnim_sm_fwdelete);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  580) 		else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  581) 			bfa_sm_set_state(itnim, bfa_itnim_sm_fwdelete_qfull);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  582) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  583) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  584) 	case BFA_ITNIM_SM_HWFAIL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  585) 		bfa_sm_set_state(itnim, bfa_itnim_sm_iocdisable);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  586) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  587) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  588) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  589) 		bfa_sm_fault(itnim->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  590) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  591) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  592) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  593) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  594) bfa_itnim_sm_fwcreate_qfull(struct bfa_itnim_s *itnim,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  595) 			enum bfa_itnim_event event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  596) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  597) 	bfa_trc(itnim->bfa, itnim->rport->rport_tag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  598) 	bfa_trc(itnim->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  599) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  600) 	switch (event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  601) 	case BFA_ITNIM_SM_QRESUME:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  602) 		bfa_sm_set_state(itnim, bfa_itnim_sm_fwcreate);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  603) 		bfa_itnim_send_fwcreate(itnim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  604) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  605) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  606) 	case BFA_ITNIM_SM_DELETE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  607) 		bfa_sm_set_state(itnim, bfa_itnim_sm_uninit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  608) 		bfa_reqq_wcancel(&itnim->reqq_wait);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  609) 		bfa_fcpim_delitn(itnim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  610) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  611) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  612) 	case BFA_ITNIM_SM_OFFLINE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  613) 		bfa_sm_set_state(itnim, bfa_itnim_sm_offline);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  614) 		bfa_reqq_wcancel(&itnim->reqq_wait);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  615) 		bfa_itnim_offline_cb(itnim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  616) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  617) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  618) 	case BFA_ITNIM_SM_HWFAIL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  619) 		bfa_sm_set_state(itnim, bfa_itnim_sm_iocdisable);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  620) 		bfa_reqq_wcancel(&itnim->reqq_wait);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  621) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  622) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  623) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  624) 		bfa_sm_fault(itnim->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  625) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  626) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  627) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  628) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  629)  * Waiting for itnim create response from firmware, a delete is pending.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  630)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  631) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  632) bfa_itnim_sm_delete_pending(struct bfa_itnim_s *itnim,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  633) 				enum bfa_itnim_event event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  634) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  635) 	bfa_trc(itnim->bfa, itnim->rport->rport_tag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  636) 	bfa_trc(itnim->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  637) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  638) 	switch (event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  639) 	case BFA_ITNIM_SM_FWRSP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  640) 		if (bfa_itnim_send_fwdelete(itnim))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  641) 			bfa_sm_set_state(itnim, bfa_itnim_sm_deleting);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  642) 		else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  643) 			bfa_sm_set_state(itnim, bfa_itnim_sm_deleting_qfull);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  644) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  645) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  646) 	case BFA_ITNIM_SM_HWFAIL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  647) 		bfa_sm_set_state(itnim, bfa_itnim_sm_uninit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  648) 		bfa_fcpim_delitn(itnim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  649) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  650) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  651) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  652) 		bfa_sm_fault(itnim->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  653) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  654) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  655) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  656) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  657)  * Online state - normal parking state.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  658)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  659) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  660) bfa_itnim_sm_online(struct bfa_itnim_s *itnim, enum bfa_itnim_event event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  661) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  662) 	bfa_trc(itnim->bfa, itnim->rport->rport_tag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  663) 	bfa_trc(itnim->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  664) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  665) 	switch (event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  666) 	case BFA_ITNIM_SM_OFFLINE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  667) 		bfa_sm_set_state(itnim, bfa_itnim_sm_cleanup_offline);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  668) 		itnim->is_online = BFA_FALSE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  669) 		bfa_itnim_iotov_start(itnim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  670) 		bfa_itnim_cleanup(itnim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  671) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  672) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  673) 	case BFA_ITNIM_SM_DELETE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  674) 		bfa_sm_set_state(itnim, bfa_itnim_sm_cleanup_delete);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  675) 		itnim->is_online = BFA_FALSE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  676) 		bfa_itnim_cleanup(itnim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  677) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  678) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  679) 	case BFA_ITNIM_SM_SLER:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  680) 		bfa_sm_set_state(itnim, bfa_itnim_sm_sler);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  681) 		itnim->is_online = BFA_FALSE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  682) 		bfa_itnim_iotov_start(itnim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  683) 		bfa_itnim_sler_cb(itnim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  684) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  685) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  686) 	case BFA_ITNIM_SM_HWFAIL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  687) 		bfa_sm_set_state(itnim, bfa_itnim_sm_iocdisable);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  688) 		itnim->is_online = BFA_FALSE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  689) 		bfa_itnim_iotov_start(itnim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  690) 		bfa_itnim_iocdisable_cleanup(itnim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  691) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  692) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  693) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  694) 		bfa_sm_fault(itnim->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  695) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  696) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  697) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  698) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  699)  * Second level error recovery need.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  700)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  701) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  702) bfa_itnim_sm_sler(struct bfa_itnim_s *itnim, enum bfa_itnim_event event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  703) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  704) 	bfa_trc(itnim->bfa, itnim->rport->rport_tag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  705) 	bfa_trc(itnim->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  706) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  707) 	switch (event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  708) 	case BFA_ITNIM_SM_OFFLINE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  709) 		bfa_sm_set_state(itnim, bfa_itnim_sm_cleanup_offline);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  710) 		bfa_itnim_cleanup(itnim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  711) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  712) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  713) 	case BFA_ITNIM_SM_DELETE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  714) 		bfa_sm_set_state(itnim, bfa_itnim_sm_cleanup_delete);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  715) 		bfa_itnim_cleanup(itnim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  716) 		bfa_itnim_iotov_delete(itnim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  717) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  718) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  719) 	case BFA_ITNIM_SM_HWFAIL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  720) 		bfa_sm_set_state(itnim, bfa_itnim_sm_iocdisable);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  721) 		bfa_itnim_iocdisable_cleanup(itnim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  722) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  723) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  724) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  725) 		bfa_sm_fault(itnim->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  726) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  727) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  728) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  729) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  730)  * Going offline. Waiting for active IO cleanup.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  731)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  732) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  733) bfa_itnim_sm_cleanup_offline(struct bfa_itnim_s *itnim,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  734) 				 enum bfa_itnim_event event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  735) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  736) 	bfa_trc(itnim->bfa, itnim->rport->rport_tag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  737) 	bfa_trc(itnim->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  738) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  739) 	switch (event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  740) 	case BFA_ITNIM_SM_CLEANUP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  741) 		if (bfa_itnim_send_fwdelete(itnim))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  742) 			bfa_sm_set_state(itnim, bfa_itnim_sm_fwdelete);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  743) 		else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  744) 			bfa_sm_set_state(itnim, bfa_itnim_sm_fwdelete_qfull);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  745) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  746) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  747) 	case BFA_ITNIM_SM_DELETE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  748) 		bfa_sm_set_state(itnim, bfa_itnim_sm_cleanup_delete);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  749) 		bfa_itnim_iotov_delete(itnim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  750) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  751) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  752) 	case BFA_ITNIM_SM_HWFAIL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  753) 		bfa_sm_set_state(itnim, bfa_itnim_sm_iocdisable);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  754) 		bfa_itnim_iocdisable_cleanup(itnim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  755) 		bfa_itnim_offline_cb(itnim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  756) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  757) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  758) 	case BFA_ITNIM_SM_SLER:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  759) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  760) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  761) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  762) 		bfa_sm_fault(itnim->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  763) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  764) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  765) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  766) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  767)  * Deleting itnim. Waiting for active IO cleanup.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  768)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  769) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  770) bfa_itnim_sm_cleanup_delete(struct bfa_itnim_s *itnim,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  771) 				enum bfa_itnim_event event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  772) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  773) 	bfa_trc(itnim->bfa, itnim->rport->rport_tag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  774) 	bfa_trc(itnim->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  775) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  776) 	switch (event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  777) 	case BFA_ITNIM_SM_CLEANUP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  778) 		if (bfa_itnim_send_fwdelete(itnim))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  779) 			bfa_sm_set_state(itnim, bfa_itnim_sm_deleting);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  780) 		else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  781) 			bfa_sm_set_state(itnim, bfa_itnim_sm_deleting_qfull);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  782) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  783) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  784) 	case BFA_ITNIM_SM_HWFAIL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  785) 		bfa_sm_set_state(itnim, bfa_itnim_sm_iocdisable);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  786) 		bfa_itnim_iocdisable_cleanup(itnim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  787) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  788) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  789) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  790) 		bfa_sm_fault(itnim->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  791) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  792) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  793) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  794) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  795)  * Rport offline. Fimrware itnim is being deleted - awaiting f/w response.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  796)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  797) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  798) bfa_itnim_sm_fwdelete(struct bfa_itnim_s *itnim, enum bfa_itnim_event event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  799) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  800) 	bfa_trc(itnim->bfa, itnim->rport->rport_tag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  801) 	bfa_trc(itnim->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  802) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  803) 	switch (event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  804) 	case BFA_ITNIM_SM_FWRSP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  805) 		bfa_sm_set_state(itnim, bfa_itnim_sm_offline);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  806) 		bfa_itnim_offline_cb(itnim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  807) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  808) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  809) 	case BFA_ITNIM_SM_DELETE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  810) 		bfa_sm_set_state(itnim, bfa_itnim_sm_deleting);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  811) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  812) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  813) 	case BFA_ITNIM_SM_HWFAIL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  814) 		bfa_sm_set_state(itnim, bfa_itnim_sm_iocdisable);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  815) 		bfa_itnim_offline_cb(itnim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  816) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  817) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  818) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  819) 		bfa_sm_fault(itnim->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  820) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  821) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  822) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  823) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  824) bfa_itnim_sm_fwdelete_qfull(struct bfa_itnim_s *itnim,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  825) 			enum bfa_itnim_event event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  826) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  827) 	bfa_trc(itnim->bfa, itnim->rport->rport_tag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  828) 	bfa_trc(itnim->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  829) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  830) 	switch (event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  831) 	case BFA_ITNIM_SM_QRESUME:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  832) 		bfa_sm_set_state(itnim, bfa_itnim_sm_fwdelete);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  833) 		bfa_itnim_send_fwdelete(itnim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  834) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  835) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  836) 	case BFA_ITNIM_SM_DELETE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  837) 		bfa_sm_set_state(itnim, bfa_itnim_sm_deleting_qfull);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  838) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  839) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  840) 	case BFA_ITNIM_SM_HWFAIL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  841) 		bfa_sm_set_state(itnim, bfa_itnim_sm_iocdisable);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  842) 		bfa_reqq_wcancel(&itnim->reqq_wait);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  843) 		bfa_itnim_offline_cb(itnim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  844) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  845) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  846) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  847) 		bfa_sm_fault(itnim->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  848) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  849) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  850) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  851) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  852)  * Offline state.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  853)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  854) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  855) bfa_itnim_sm_offline(struct bfa_itnim_s *itnim, enum bfa_itnim_event event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  856) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  857) 	bfa_trc(itnim->bfa, itnim->rport->rport_tag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  858) 	bfa_trc(itnim->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  859) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  860) 	switch (event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  861) 	case BFA_ITNIM_SM_DELETE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  862) 		bfa_sm_set_state(itnim, bfa_itnim_sm_uninit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  863) 		bfa_itnim_iotov_delete(itnim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  864) 		bfa_fcpim_delitn(itnim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  865) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  866) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  867) 	case BFA_ITNIM_SM_ONLINE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  868) 		if (bfa_itnim_send_fwcreate(itnim))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  869) 			bfa_sm_set_state(itnim, bfa_itnim_sm_fwcreate);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  870) 		else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  871) 			bfa_sm_set_state(itnim, bfa_itnim_sm_fwcreate_qfull);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  872) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  873) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  874) 	case BFA_ITNIM_SM_HWFAIL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  875) 		bfa_sm_set_state(itnim, bfa_itnim_sm_iocdisable);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  876) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  877) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  878) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  879) 		bfa_sm_fault(itnim->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  880) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  881) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  882) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  883) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  884) bfa_itnim_sm_iocdisable(struct bfa_itnim_s *itnim,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  885) 				enum bfa_itnim_event event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  886) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  887) 	bfa_trc(itnim->bfa, itnim->rport->rport_tag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  888) 	bfa_trc(itnim->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  889) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  890) 	switch (event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  891) 	case BFA_ITNIM_SM_DELETE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  892) 		bfa_sm_set_state(itnim, bfa_itnim_sm_uninit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  893) 		bfa_itnim_iotov_delete(itnim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  894) 		bfa_fcpim_delitn(itnim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  895) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  896) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  897) 	case BFA_ITNIM_SM_OFFLINE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  898) 		bfa_itnim_offline_cb(itnim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  899) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  900) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  901) 	case BFA_ITNIM_SM_ONLINE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  902) 		if (bfa_itnim_send_fwcreate(itnim))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  903) 			bfa_sm_set_state(itnim, bfa_itnim_sm_fwcreate);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  904) 		else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  905) 			bfa_sm_set_state(itnim, bfa_itnim_sm_fwcreate_qfull);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  906) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  907) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  908) 	case BFA_ITNIM_SM_HWFAIL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  909) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  910) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  911) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  912) 		bfa_sm_fault(itnim->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  913) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  914) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  915) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  916) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  917)  * Itnim is deleted, waiting for firmware response to delete.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  918)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  919) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  920) bfa_itnim_sm_deleting(struct bfa_itnim_s *itnim, enum bfa_itnim_event event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  921) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  922) 	bfa_trc(itnim->bfa, itnim->rport->rport_tag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  923) 	bfa_trc(itnim->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  924) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  925) 	switch (event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  926) 	case BFA_ITNIM_SM_FWRSP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  927) 	case BFA_ITNIM_SM_HWFAIL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  928) 		bfa_sm_set_state(itnim, bfa_itnim_sm_uninit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  929) 		bfa_fcpim_delitn(itnim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  930) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  931) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  932) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  933) 		bfa_sm_fault(itnim->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  934) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  935) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  936) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  937) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  938) bfa_itnim_sm_deleting_qfull(struct bfa_itnim_s *itnim,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  939) 		enum bfa_itnim_event event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  940) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  941) 	bfa_trc(itnim->bfa, itnim->rport->rport_tag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  942) 	bfa_trc(itnim->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  943) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  944) 	switch (event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  945) 	case BFA_ITNIM_SM_QRESUME:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  946) 		bfa_sm_set_state(itnim, bfa_itnim_sm_deleting);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  947) 		bfa_itnim_send_fwdelete(itnim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  948) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  949) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  950) 	case BFA_ITNIM_SM_HWFAIL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  951) 		bfa_sm_set_state(itnim, bfa_itnim_sm_uninit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  952) 		bfa_reqq_wcancel(&itnim->reqq_wait);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  953) 		bfa_fcpim_delitn(itnim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  954) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  955) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  956) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  957) 		bfa_sm_fault(itnim->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  958) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  959) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  960) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  961) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  962)  * Initiate cleanup of all IOs on an IOC failure.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  963)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  964) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  965) bfa_itnim_iocdisable_cleanup(struct bfa_itnim_s *itnim)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  966) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  967) 	struct bfa_tskim_s *tskim;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  968) 	struct bfa_ioim_s *ioim;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  969) 	struct list_head	*qe, *qen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  970) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  971) 	list_for_each_safe(qe, qen, &itnim->tsk_q) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  972) 		tskim = (struct bfa_tskim_s *) qe;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  973) 		bfa_tskim_iocdisable(tskim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  974) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  975) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  976) 	list_for_each_safe(qe, qen, &itnim->io_q) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  977) 		ioim = (struct bfa_ioim_s *) qe;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  978) 		bfa_ioim_iocdisable(ioim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  979) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  980) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  981) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  982) 	 * For IO request in pending queue, we pretend an early timeout.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  983) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  984) 	list_for_each_safe(qe, qen, &itnim->pending_q) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  985) 		ioim = (struct bfa_ioim_s *) qe;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  986) 		bfa_ioim_tov(ioim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  987) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  988) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  989) 	list_for_each_safe(qe, qen, &itnim->io_cleanup_q) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  990) 		ioim = (struct bfa_ioim_s *) qe;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  991) 		bfa_ioim_iocdisable(ioim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  992) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  993) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  994) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  995) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  996)  * IO cleanup completion
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  997)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  998) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  999) bfa_itnim_cleanp_comp(void *itnim_cbarg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1000) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1001) 	struct bfa_itnim_s *itnim = itnim_cbarg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1002) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1003) 	bfa_stats(itnim, cleanup_comps);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1004) 	bfa_sm_send_event(itnim, BFA_ITNIM_SM_CLEANUP);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1005) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1006) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1007) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1008)  * Initiate cleanup of all IOs.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1009)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1010) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1011) bfa_itnim_cleanup(struct bfa_itnim_s *itnim)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1012) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1013) 	struct bfa_ioim_s  *ioim;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1014) 	struct bfa_tskim_s *tskim;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1015) 	struct list_head	*qe, *qen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1016) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1017) 	bfa_wc_init(&itnim->wc, bfa_itnim_cleanp_comp, itnim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1018) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1019) 	list_for_each_safe(qe, qen, &itnim->io_q) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1020) 		ioim = (struct bfa_ioim_s *) qe;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1021) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1022) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1023) 		 * Move IO to a cleanup queue from active queue so that a later
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1024) 		 * TM will not pickup this IO.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1025) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1026) 		list_del(&ioim->qe);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1027) 		list_add_tail(&ioim->qe, &itnim->io_cleanup_q);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1028) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1029) 		bfa_wc_up(&itnim->wc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1030) 		bfa_ioim_cleanup(ioim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1031) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1032) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1033) 	list_for_each_safe(qe, qen, &itnim->tsk_q) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1034) 		tskim = (struct bfa_tskim_s *) qe;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1035) 		bfa_wc_up(&itnim->wc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1036) 		bfa_tskim_cleanup(tskim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1037) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1038) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1039) 	bfa_wc_wait(&itnim->wc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1040) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1041) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1042) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1043) __bfa_cb_itnim_online(void *cbarg, bfa_boolean_t complete)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1044) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1045) 	struct bfa_itnim_s *itnim = cbarg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1046) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1047) 	if (complete)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1048) 		bfa_cb_itnim_online(itnim->ditn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1049) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1050) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1051) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1052) __bfa_cb_itnim_offline(void *cbarg, bfa_boolean_t complete)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1053) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1054) 	struct bfa_itnim_s *itnim = cbarg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1055) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1056) 	if (complete)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1057) 		bfa_cb_itnim_offline(itnim->ditn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1058) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1059) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1060) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1061) __bfa_cb_itnim_sler(void *cbarg, bfa_boolean_t complete)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1062) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1063) 	struct bfa_itnim_s *itnim = cbarg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1064) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1065) 	if (complete)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1066) 		bfa_cb_itnim_sler(itnim->ditn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1067) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1068) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1069) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1070)  * Call to resume any I/O requests waiting for room in request queue.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1071)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1072) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1073) bfa_itnim_qresume(void *cbarg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1074) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1075) 	struct bfa_itnim_s *itnim = cbarg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1076) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1077) 	bfa_sm_send_event(itnim, BFA_ITNIM_SM_QRESUME);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1078) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1079) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1080) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1081)  *  bfa_itnim_public
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1082)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1083) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1084) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1085) bfa_itnim_iodone(struct bfa_itnim_s *itnim)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1086) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1087) 	bfa_wc_down(&itnim->wc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1088) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1089) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1090) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1091) bfa_itnim_tskdone(struct bfa_itnim_s *itnim)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1092) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1093) 	bfa_wc_down(&itnim->wc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1094) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1095) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1096) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1097) bfa_itnim_meminfo(struct bfa_iocfc_cfg_s *cfg, u32 *km_len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1098) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1099) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1100) 	 * ITN memory
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1101) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1102) 	*km_len += cfg->fwcfg.num_rports * sizeof(struct bfa_itnim_s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1103) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1104) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1105) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1106) bfa_itnim_attach(struct bfa_fcpim_s *fcpim)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1107) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1108) 	struct bfa_s	*bfa = fcpim->bfa;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1109) 	struct bfa_fcp_mod_s	*fcp = fcpim->fcp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1110) 	struct bfa_itnim_s *itnim;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1111) 	int	i, j;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1112) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1113) 	INIT_LIST_HEAD(&fcpim->itnim_q);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1114) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1115) 	itnim = (struct bfa_itnim_s *) bfa_mem_kva_curp(fcp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1116) 	fcpim->itnim_arr = itnim;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1117) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1118) 	for (i = 0; i < fcpim->num_itnims; i++, itnim++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1119) 		memset(itnim, 0, sizeof(struct bfa_itnim_s));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1120) 		itnim->bfa = bfa;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1121) 		itnim->fcpim = fcpim;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1122) 		itnim->reqq = BFA_REQQ_QOS_LO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1123) 		itnim->rport = BFA_RPORT_FROM_TAG(bfa, i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1124) 		itnim->iotov_active = BFA_FALSE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1125) 		bfa_reqq_winit(&itnim->reqq_wait, bfa_itnim_qresume, itnim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1126) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1127) 		INIT_LIST_HEAD(&itnim->io_q);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1128) 		INIT_LIST_HEAD(&itnim->io_cleanup_q);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1129) 		INIT_LIST_HEAD(&itnim->pending_q);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1130) 		INIT_LIST_HEAD(&itnim->tsk_q);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1131) 		INIT_LIST_HEAD(&itnim->delay_comp_q);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1132) 		for (j = 0; j < BFA_IOBUCKET_MAX; j++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1133) 			itnim->ioprofile.io_latency.min[j] = ~0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1134) 		bfa_sm_set_state(itnim, bfa_itnim_sm_uninit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1135) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1136) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1137) 	bfa_mem_kva_curp(fcp) = (u8 *) itnim;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1138) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1139) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1140) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1141) bfa_itnim_iocdisable(struct bfa_itnim_s *itnim)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1142) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1143) 	bfa_stats(itnim, ioc_disabled);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1144) 	bfa_sm_send_event(itnim, BFA_ITNIM_SM_HWFAIL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1145) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1146) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1147) static bfa_boolean_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1148) bfa_itnim_send_fwcreate(struct bfa_itnim_s *itnim)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1149) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1150) 	struct bfi_itn_create_req_s *m;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1151) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1152) 	itnim->msg_no++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1153) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1154) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1155) 	 * check for room in queue to send request now
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1156) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1157) 	m = bfa_reqq_next(itnim->bfa, itnim->reqq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1158) 	if (!m) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1159) 		bfa_reqq_wait(itnim->bfa, itnim->reqq, &itnim->reqq_wait);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1160) 		return BFA_FALSE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1161) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1162) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1163) 	bfi_h2i_set(m->mh, BFI_MC_ITN, BFI_ITN_H2I_CREATE_REQ,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1164) 			bfa_fn_lpu(itnim->bfa));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1165) 	m->fw_handle = itnim->rport->fw_handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1166) 	m->class = FC_CLASS_3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1167) 	m->seq_rec = itnim->seq_rec;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1168) 	m->msg_no = itnim->msg_no;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1169) 	bfa_stats(itnim, fw_create);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1170) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1171) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1172) 	 * queue I/O message to firmware
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1173) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1174) 	bfa_reqq_produce(itnim->bfa, itnim->reqq, m->mh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1175) 	return BFA_TRUE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1176) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1177) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1178) static bfa_boolean_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1179) bfa_itnim_send_fwdelete(struct bfa_itnim_s *itnim)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1180) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1181) 	struct bfi_itn_delete_req_s *m;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1182) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1183) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1184) 	 * check for room in queue to send request now
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1185) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1186) 	m = bfa_reqq_next(itnim->bfa, itnim->reqq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1187) 	if (!m) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1188) 		bfa_reqq_wait(itnim->bfa, itnim->reqq, &itnim->reqq_wait);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1189) 		return BFA_FALSE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1190) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1191) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1192) 	bfi_h2i_set(m->mh, BFI_MC_ITN, BFI_ITN_H2I_DELETE_REQ,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1193) 			bfa_fn_lpu(itnim->bfa));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1194) 	m->fw_handle = itnim->rport->fw_handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1195) 	bfa_stats(itnim, fw_delete);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1196) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1197) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1198) 	 * queue I/O message to firmware
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1199) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1200) 	bfa_reqq_produce(itnim->bfa, itnim->reqq, m->mh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1201) 	return BFA_TRUE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1202) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1203) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1204) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1205)  * Cleanup all pending failed inflight requests.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1206)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1207) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1208) bfa_itnim_delayed_comp(struct bfa_itnim_s *itnim, bfa_boolean_t iotov)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1209) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1210) 	struct bfa_ioim_s *ioim;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1211) 	struct list_head *qe, *qen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1212) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1213) 	list_for_each_safe(qe, qen, &itnim->delay_comp_q) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1214) 		ioim = (struct bfa_ioim_s *)qe;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1215) 		bfa_ioim_delayed_comp(ioim, iotov);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1216) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1217) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1218) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1219) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1220)  * Start all pending IO requests.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1221)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1222) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1223) bfa_itnim_iotov_online(struct bfa_itnim_s *itnim)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1224) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1225) 	struct bfa_ioim_s *ioim;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1226) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1227) 	bfa_itnim_iotov_stop(itnim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1228) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1229) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1230) 	 * Abort all inflight IO requests in the queue
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1231) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1232) 	bfa_itnim_delayed_comp(itnim, BFA_FALSE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1233) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1234) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1235) 	 * Start all pending IO requests.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1236) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1237) 	while (!list_empty(&itnim->pending_q)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1238) 		bfa_q_deq(&itnim->pending_q, &ioim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1239) 		list_add_tail(&ioim->qe, &itnim->io_q);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1240) 		bfa_ioim_start(ioim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1241) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1242) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1243) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1244) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1245)  * Fail all pending IO requests
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1246)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1247) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1248) bfa_itnim_iotov_cleanup(struct bfa_itnim_s *itnim)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1249) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1250) 	struct bfa_ioim_s *ioim;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1251) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1252) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1253) 	 * Fail all inflight IO requests in the queue
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1254) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1255) 	bfa_itnim_delayed_comp(itnim, BFA_TRUE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1256) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1257) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1258) 	 * Fail any pending IO requests.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1259) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1260) 	while (!list_empty(&itnim->pending_q)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1261) 		bfa_q_deq(&itnim->pending_q, &ioim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1262) 		list_add_tail(&ioim->qe, &ioim->fcpim->ioim_comp_q);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1263) 		bfa_ioim_tov(ioim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1264) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1265) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1266) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1267) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1268)  * IO TOV timer callback. Fail any pending IO requests.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1269)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1270) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1271) bfa_itnim_iotov(void *itnim_arg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1272) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1273) 	struct bfa_itnim_s *itnim = itnim_arg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1274) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1275) 	itnim->iotov_active = BFA_FALSE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1276) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1277) 	bfa_cb_itnim_tov_begin(itnim->ditn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1278) 	bfa_itnim_iotov_cleanup(itnim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1279) 	bfa_cb_itnim_tov(itnim->ditn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1280) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1281) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1282) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1283)  * Start IO TOV timer for failing back pending IO requests in offline state.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1284)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1285) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1286) bfa_itnim_iotov_start(struct bfa_itnim_s *itnim)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1287) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1288) 	if (itnim->fcpim->path_tov > 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1289) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1290) 		itnim->iotov_active = BFA_TRUE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1291) 		WARN_ON(!bfa_itnim_hold_io(itnim));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1292) 		bfa_timer_start(itnim->bfa, &itnim->timer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1293) 			bfa_itnim_iotov, itnim, itnim->fcpim->path_tov);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1294) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1295) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1296) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1297) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1298)  * Stop IO TOV timer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1299)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1300) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1301) bfa_itnim_iotov_stop(struct bfa_itnim_s *itnim)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1302) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1303) 	if (itnim->iotov_active) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1304) 		itnim->iotov_active = BFA_FALSE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1305) 		bfa_timer_stop(&itnim->timer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1306) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1307) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1308) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1309) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1310)  * Stop IO TOV timer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1311)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1312) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1313) bfa_itnim_iotov_delete(struct bfa_itnim_s *itnim)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1314) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1315) 	bfa_boolean_t pathtov_active = BFA_FALSE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1316) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1317) 	if (itnim->iotov_active)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1318) 		pathtov_active = BFA_TRUE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1319) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1320) 	bfa_itnim_iotov_stop(itnim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1321) 	if (pathtov_active)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1322) 		bfa_cb_itnim_tov_begin(itnim->ditn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1323) 	bfa_itnim_iotov_cleanup(itnim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1324) 	if (pathtov_active)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1325) 		bfa_cb_itnim_tov(itnim->ditn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1326) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1327) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1328) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1329) bfa_itnim_update_del_itn_stats(struct bfa_itnim_s *itnim)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1330) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1331) 	struct bfa_fcpim_s *fcpim = BFA_FCPIM(itnim->bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1332) 	fcpim->del_itn_stats.del_itn_iocomp_aborted +=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1333) 		itnim->stats.iocomp_aborted;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1334) 	fcpim->del_itn_stats.del_itn_iocomp_timedout +=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1335) 		itnim->stats.iocomp_timedout;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1336) 	fcpim->del_itn_stats.del_itn_iocom_sqer_needed +=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1337) 		itnim->stats.iocom_sqer_needed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1338) 	fcpim->del_itn_stats.del_itn_iocom_res_free +=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1339) 		itnim->stats.iocom_res_free;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1340) 	fcpim->del_itn_stats.del_itn_iocom_hostabrts +=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1341) 		itnim->stats.iocom_hostabrts;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1342) 	fcpim->del_itn_stats.del_itn_total_ios += itnim->stats.total_ios;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1343) 	fcpim->del_itn_stats.del_io_iocdowns += itnim->stats.io_iocdowns;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1344) 	fcpim->del_itn_stats.del_tm_iocdowns += itnim->stats.tm_iocdowns;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1345) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1346) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1347) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1348)  * bfa_itnim_public
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1349)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1350) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1351) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1352)  * Itnim interrupt processing.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1353)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1354) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1355) bfa_itnim_isr(struct bfa_s *bfa, struct bfi_msg_s *m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1356) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1357) 	struct bfa_fcpim_s *fcpim = BFA_FCPIM(bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1358) 	union bfi_itn_i2h_msg_u msg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1359) 	struct bfa_itnim_s *itnim;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1360) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1361) 	bfa_trc(bfa, m->mhdr.msg_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1362) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1363) 	msg.msg = m;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1364) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1365) 	switch (m->mhdr.msg_id) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1366) 	case BFI_ITN_I2H_CREATE_RSP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1367) 		itnim = BFA_ITNIM_FROM_TAG(fcpim,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1368) 						msg.create_rsp->bfa_handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1369) 		WARN_ON(msg.create_rsp->status != BFA_STATUS_OK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1370) 		bfa_stats(itnim, create_comps);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1371) 		bfa_sm_send_event(itnim, BFA_ITNIM_SM_FWRSP);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1372) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1373) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1374) 	case BFI_ITN_I2H_DELETE_RSP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1375) 		itnim = BFA_ITNIM_FROM_TAG(fcpim,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1376) 						msg.delete_rsp->bfa_handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1377) 		WARN_ON(msg.delete_rsp->status != BFA_STATUS_OK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1378) 		bfa_stats(itnim, delete_comps);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1379) 		bfa_sm_send_event(itnim, BFA_ITNIM_SM_FWRSP);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1380) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1381) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1382) 	case BFI_ITN_I2H_SLER_EVENT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1383) 		itnim = BFA_ITNIM_FROM_TAG(fcpim,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1384) 						msg.sler_event->bfa_handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1385) 		bfa_stats(itnim, sler_events);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1386) 		bfa_sm_send_event(itnim, BFA_ITNIM_SM_SLER);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1387) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1388) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1389) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1390) 		bfa_trc(bfa, m->mhdr.msg_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1391) 		WARN_ON(1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1392) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1393) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1394) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1395) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1396)  * bfa_itnim_api
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1397)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1398) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1399) struct bfa_itnim_s *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1400) bfa_itnim_create(struct bfa_s *bfa, struct bfa_rport_s *rport, void *ditn)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1401) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1402) 	struct bfa_fcpim_s *fcpim = BFA_FCPIM(bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1403) 	struct bfa_itnim_s *itnim;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1404) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1405) 	bfa_itn_create(bfa, rport, bfa_itnim_isr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1406) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1407) 	itnim = BFA_ITNIM_FROM_TAG(fcpim, rport->rport_tag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1408) 	WARN_ON(itnim->rport != rport);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1409) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1410) 	itnim->ditn = ditn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1411) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1412) 	bfa_stats(itnim, creates);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1413) 	bfa_sm_send_event(itnim, BFA_ITNIM_SM_CREATE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1414) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1415) 	return itnim;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1416) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1417) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1418) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1419) bfa_itnim_delete(struct bfa_itnim_s *itnim)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1420) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1421) 	bfa_stats(itnim, deletes);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1422) 	bfa_sm_send_event(itnim, BFA_ITNIM_SM_DELETE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1423) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1424) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1425) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1426) bfa_itnim_online(struct bfa_itnim_s *itnim, bfa_boolean_t seq_rec)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1427) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1428) 	itnim->seq_rec = seq_rec;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1429) 	bfa_stats(itnim, onlines);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1430) 	bfa_sm_send_event(itnim, BFA_ITNIM_SM_ONLINE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1431) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1432) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1433) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1434) bfa_itnim_offline(struct bfa_itnim_s *itnim)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1435) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1436) 	bfa_stats(itnim, offlines);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1437) 	bfa_sm_send_event(itnim, BFA_ITNIM_SM_OFFLINE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1438) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1439) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1440) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1441)  * Return true if itnim is considered offline for holding off IO request.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1442)  * IO is not held if itnim is being deleted.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1443)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1444) bfa_boolean_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1445) bfa_itnim_hold_io(struct bfa_itnim_s *itnim)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1446) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1447) 	return itnim->fcpim->path_tov && itnim->iotov_active &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1448) 		(bfa_sm_cmp_state(itnim, bfa_itnim_sm_fwcreate) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1449) 		 bfa_sm_cmp_state(itnim, bfa_itnim_sm_sler) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1450) 		 bfa_sm_cmp_state(itnim, bfa_itnim_sm_cleanup_offline) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1451) 		 bfa_sm_cmp_state(itnim, bfa_itnim_sm_fwdelete) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1452) 		 bfa_sm_cmp_state(itnim, bfa_itnim_sm_offline) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1453) 		 bfa_sm_cmp_state(itnim, bfa_itnim_sm_iocdisable));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1454) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1455) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1456) #define bfa_io_lat_clock_res_div	HZ
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1457) #define bfa_io_lat_clock_res_mul	1000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1458) bfa_status_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1459) bfa_itnim_get_ioprofile(struct bfa_itnim_s *itnim,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1460) 			struct bfa_itnim_ioprofile_s *ioprofile)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1461) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1462) 	struct bfa_fcpim_s *fcpim;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1463) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1464) 	if (!itnim)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1465) 		return BFA_STATUS_NO_FCPIM_NEXUS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1466) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1467) 	fcpim = BFA_FCPIM(itnim->bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1468) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1469) 	if (!fcpim->io_profile)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1470) 		return BFA_STATUS_IOPROFILE_OFF;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1471) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1472) 	itnim->ioprofile.index = BFA_IOBUCKET_MAX;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1473) 	/* unsigned 32-bit time_t overflow here in y2106 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1474) 	itnim->ioprofile.io_profile_start_time =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1475) 				bfa_io_profile_start_time(itnim->bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1476) 	itnim->ioprofile.clock_res_mul = bfa_io_lat_clock_res_mul;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1477) 	itnim->ioprofile.clock_res_div = bfa_io_lat_clock_res_div;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1478) 	*ioprofile = itnim->ioprofile;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1479) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1480) 	return BFA_STATUS_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1481) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1482) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1483) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1484) bfa_itnim_clear_stats(struct bfa_itnim_s *itnim)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1485) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1486) 	int j;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1487) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1488) 	if (!itnim)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1489) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1490) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1491) 	memset(&itnim->stats, 0, sizeof(itnim->stats));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1492) 	memset(&itnim->ioprofile, 0, sizeof(itnim->ioprofile));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1493) 	for (j = 0; j < BFA_IOBUCKET_MAX; j++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1494) 		itnim->ioprofile.io_latency.min[j] = ~0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1495) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1496) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1497) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1498)  *  BFA IO module state machine functions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1499)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1500) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1501) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1502)  * IO is not started (unallocated).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1503)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1504) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1505) bfa_ioim_sm_uninit(struct bfa_ioim_s *ioim, enum bfa_ioim_event event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1506) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1507) 	switch (event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1508) 	case BFA_IOIM_SM_START:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1509) 		if (!bfa_itnim_is_online(ioim->itnim)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1510) 			if (!bfa_itnim_hold_io(ioim->itnim)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1511) 				bfa_sm_set_state(ioim, bfa_ioim_sm_hcb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1512) 				list_del(&ioim->qe);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1513) 				list_add_tail(&ioim->qe,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1514) 					&ioim->fcpim->ioim_comp_q);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1515) 				bfa_cb_queue(ioim->bfa, &ioim->hcb_qe,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1516) 						__bfa_cb_ioim_pathtov, ioim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1517) 			} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1518) 				list_del(&ioim->qe);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1519) 				list_add_tail(&ioim->qe,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1520) 					&ioim->itnim->pending_q);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1521) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1522) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1523) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1524) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1525) 		if (ioim->nsges > BFI_SGE_INLINE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1526) 			if (!bfa_ioim_sgpg_alloc(ioim)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1527) 				bfa_sm_set_state(ioim, bfa_ioim_sm_sgalloc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1528) 				return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1529) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1530) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1531) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1532) 		if (!bfa_ioim_send_ioreq(ioim)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1533) 			bfa_sm_set_state(ioim, bfa_ioim_sm_qfull);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1534) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1535) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1536) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1537) 		bfa_sm_set_state(ioim, bfa_ioim_sm_active);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1538) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1539) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1540) 	case BFA_IOIM_SM_IOTOV:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1541) 		bfa_sm_set_state(ioim, bfa_ioim_sm_hcb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1542) 		bfa_ioim_move_to_comp_q(ioim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1543) 		bfa_cb_queue(ioim->bfa, &ioim->hcb_qe,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1544) 				__bfa_cb_ioim_pathtov, ioim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1545) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1546) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1547) 	case BFA_IOIM_SM_ABORT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1548) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1549) 		 * IO in pending queue can get abort requests. Complete abort
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1550) 		 * requests immediately.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1551) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1552) 		bfa_sm_set_state(ioim, bfa_ioim_sm_hcb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1553) 		WARN_ON(!bfa_q_is_on_q(&ioim->itnim->pending_q, ioim));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1554) 		bfa_cb_queue(ioim->bfa, &ioim->hcb_qe,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1555) 			__bfa_cb_ioim_abort, ioim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1556) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1557) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1558) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1559) 		bfa_sm_fault(ioim->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1560) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1561) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1562) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1563) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1564)  * IO is waiting for SG pages.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1565)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1566) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1567) bfa_ioim_sm_sgalloc(struct bfa_ioim_s *ioim, enum bfa_ioim_event event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1568) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1569) 	bfa_trc(ioim->bfa, ioim->iotag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1570) 	bfa_trc(ioim->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1571) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1572) 	switch (event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1573) 	case BFA_IOIM_SM_SGALLOCED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1574) 		if (!bfa_ioim_send_ioreq(ioim)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1575) 			bfa_sm_set_state(ioim, bfa_ioim_sm_qfull);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1576) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1577) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1578) 		bfa_sm_set_state(ioim, bfa_ioim_sm_active);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1579) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1580) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1581) 	case BFA_IOIM_SM_CLEANUP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1582) 		bfa_sm_set_state(ioim, bfa_ioim_sm_hcb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1583) 		bfa_sgpg_wcancel(ioim->bfa, &ioim->iosp->sgpg_wqe);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1584) 		bfa_cb_queue(ioim->bfa, &ioim->hcb_qe, __bfa_cb_ioim_failed,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1585) 			      ioim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1586) 		bfa_ioim_notify_cleanup(ioim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1587) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1588) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1589) 	case BFA_IOIM_SM_ABORT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1590) 		bfa_sm_set_state(ioim, bfa_ioim_sm_hcb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1591) 		bfa_sgpg_wcancel(ioim->bfa, &ioim->iosp->sgpg_wqe);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1592) 		bfa_ioim_move_to_comp_q(ioim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1593) 		bfa_cb_queue(ioim->bfa, &ioim->hcb_qe, __bfa_cb_ioim_abort,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1594) 			      ioim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1595) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1596) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1597) 	case BFA_IOIM_SM_HWFAIL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1598) 		bfa_sm_set_state(ioim, bfa_ioim_sm_hcb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1599) 		bfa_sgpg_wcancel(ioim->bfa, &ioim->iosp->sgpg_wqe);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1600) 		bfa_ioim_move_to_comp_q(ioim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1601) 		bfa_cb_queue(ioim->bfa, &ioim->hcb_qe, __bfa_cb_ioim_failed,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1602) 			      ioim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1603) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1604) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1605) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1606) 		bfa_sm_fault(ioim->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1607) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1608) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1609) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1610) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1611)  * IO is active.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1612)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1613) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1614) bfa_ioim_sm_active(struct bfa_ioim_s *ioim, enum bfa_ioim_event event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1615) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1616) 	switch (event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1617) 	case BFA_IOIM_SM_COMP_GOOD:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1618) 		bfa_sm_set_state(ioim, bfa_ioim_sm_hcb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1619) 		bfa_ioim_move_to_comp_q(ioim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1620) 		bfa_cb_queue(ioim->bfa, &ioim->hcb_qe,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1621) 			      __bfa_cb_ioim_good_comp, ioim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1622) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1623) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1624) 	case BFA_IOIM_SM_COMP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1625) 		bfa_sm_set_state(ioim, bfa_ioim_sm_hcb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1626) 		bfa_ioim_move_to_comp_q(ioim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1627) 		bfa_cb_queue(ioim->bfa, &ioim->hcb_qe, __bfa_cb_ioim_comp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1628) 			      ioim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1629) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1630) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1631) 	case BFA_IOIM_SM_DONE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1632) 		bfa_sm_set_state(ioim, bfa_ioim_sm_hcb_free);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1633) 		bfa_ioim_move_to_comp_q(ioim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1634) 		bfa_cb_queue(ioim->bfa, &ioim->hcb_qe, __bfa_cb_ioim_comp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1635) 			      ioim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1636) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1637) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1638) 	case BFA_IOIM_SM_ABORT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1639) 		ioim->iosp->abort_explicit = BFA_TRUE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1640) 		ioim->io_cbfn = __bfa_cb_ioim_abort;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1641) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1642) 		if (bfa_ioim_send_abort(ioim))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1643) 			bfa_sm_set_state(ioim, bfa_ioim_sm_abort);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1644) 		else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1645) 			bfa_sm_set_state(ioim, bfa_ioim_sm_abort_qfull);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1646) 			bfa_stats(ioim->itnim, qwait);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1647) 			bfa_reqq_wait(ioim->bfa, ioim->reqq,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1648) 					  &ioim->iosp->reqq_wait);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1649) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1650) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1651) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1652) 	case BFA_IOIM_SM_CLEANUP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1653) 		ioim->iosp->abort_explicit = BFA_FALSE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1654) 		ioim->io_cbfn = __bfa_cb_ioim_failed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1655) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1656) 		if (bfa_ioim_send_abort(ioim))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1657) 			bfa_sm_set_state(ioim, bfa_ioim_sm_cleanup);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1658) 		else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1659) 			bfa_sm_set_state(ioim, bfa_ioim_sm_cleanup_qfull);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1660) 			bfa_stats(ioim->itnim, qwait);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1661) 			bfa_reqq_wait(ioim->bfa, ioim->reqq,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1662) 					  &ioim->iosp->reqq_wait);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1663) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1664) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1665) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1666) 	case BFA_IOIM_SM_HWFAIL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1667) 		bfa_sm_set_state(ioim, bfa_ioim_sm_hcb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1668) 		bfa_ioim_move_to_comp_q(ioim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1669) 		bfa_cb_queue(ioim->bfa, &ioim->hcb_qe, __bfa_cb_ioim_failed,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1670) 			      ioim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1671) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1672) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1673) 	case BFA_IOIM_SM_SQRETRY:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1674) 		if (bfa_ioim_maxretry_reached(ioim)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1675) 			/* max retry reached, free IO */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1676) 			bfa_sm_set_state(ioim, bfa_ioim_sm_hcb_free);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1677) 			bfa_ioim_move_to_comp_q(ioim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1678) 			bfa_cb_queue(ioim->bfa, &ioim->hcb_qe,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1679) 					__bfa_cb_ioim_failed, ioim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1680) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1681) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1682) 		/* waiting for IO tag resource free */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1683) 		bfa_sm_set_state(ioim, bfa_ioim_sm_cmnd_retry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1684) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1685) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1686) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1687) 		bfa_sm_fault(ioim->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1688) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1689) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1690) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1691) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1692)  * IO is retried with new tag.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1693)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1694) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1695) bfa_ioim_sm_cmnd_retry(struct bfa_ioim_s *ioim, enum bfa_ioim_event event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1696) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1697) 	switch (event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1698) 	case BFA_IOIM_SM_FREE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1699) 		/* abts and rrq done. Now retry the IO with new tag */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1700) 		bfa_ioim_update_iotag(ioim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1701) 		if (!bfa_ioim_send_ioreq(ioim)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1702) 			bfa_sm_set_state(ioim, bfa_ioim_sm_qfull);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1703) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1704) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1705) 		bfa_sm_set_state(ioim, bfa_ioim_sm_active);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1706) 	break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1707) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1708) 	case BFA_IOIM_SM_CLEANUP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1709) 		ioim->iosp->abort_explicit = BFA_FALSE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1710) 		ioim->io_cbfn = __bfa_cb_ioim_failed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1711) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1712) 		if (bfa_ioim_send_abort(ioim))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1713) 			bfa_sm_set_state(ioim, bfa_ioim_sm_cleanup);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1714) 		else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1715) 			bfa_sm_set_state(ioim, bfa_ioim_sm_cleanup_qfull);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1716) 			bfa_stats(ioim->itnim, qwait);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1717) 			bfa_reqq_wait(ioim->bfa, ioim->reqq,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1718) 					  &ioim->iosp->reqq_wait);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1719) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1720) 	break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1721) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1722) 	case BFA_IOIM_SM_HWFAIL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1723) 		bfa_sm_set_state(ioim, bfa_ioim_sm_hcb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1724) 		bfa_ioim_move_to_comp_q(ioim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1725) 		bfa_cb_queue(ioim->bfa, &ioim->hcb_qe,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1726) 			 __bfa_cb_ioim_failed, ioim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1727) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1728) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1729) 	case BFA_IOIM_SM_ABORT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1730) 		/* in this state IO abort is done.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1731) 		 * Waiting for IO tag resource free.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1732) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1733) 		bfa_sm_set_state(ioim, bfa_ioim_sm_hcb_free);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1734) 		bfa_cb_queue(ioim->bfa, &ioim->hcb_qe, __bfa_cb_ioim_abort,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1735) 			      ioim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1736) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1737) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1738) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1739) 		bfa_sm_fault(ioim->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1740) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1741) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1742) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1743) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1744)  * IO is being aborted, waiting for completion from firmware.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1745)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1746) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1747) bfa_ioim_sm_abort(struct bfa_ioim_s *ioim, enum bfa_ioim_event event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1748) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1749) 	bfa_trc(ioim->bfa, ioim->iotag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1750) 	bfa_trc(ioim->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1751) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1752) 	switch (event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1753) 	case BFA_IOIM_SM_COMP_GOOD:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1754) 	case BFA_IOIM_SM_COMP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1755) 	case BFA_IOIM_SM_DONE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1756) 	case BFA_IOIM_SM_FREE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1757) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1758) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1759) 	case BFA_IOIM_SM_ABORT_DONE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1760) 		bfa_sm_set_state(ioim, bfa_ioim_sm_hcb_free);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1761) 		bfa_cb_queue(ioim->bfa, &ioim->hcb_qe, __bfa_cb_ioim_abort,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1762) 			      ioim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1763) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1764) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1765) 	case BFA_IOIM_SM_ABORT_COMP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1766) 		bfa_sm_set_state(ioim, bfa_ioim_sm_hcb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1767) 		bfa_ioim_move_to_comp_q(ioim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1768) 		bfa_cb_queue(ioim->bfa, &ioim->hcb_qe, __bfa_cb_ioim_abort,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1769) 			      ioim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1770) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1771) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1772) 	case BFA_IOIM_SM_COMP_UTAG:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1773) 		bfa_sm_set_state(ioim, bfa_ioim_sm_hcb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1774) 		bfa_ioim_move_to_comp_q(ioim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1775) 		bfa_cb_queue(ioim->bfa, &ioim->hcb_qe, __bfa_cb_ioim_abort,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1776) 			      ioim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1777) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1778) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1779) 	case BFA_IOIM_SM_CLEANUP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1780) 		WARN_ON(ioim->iosp->abort_explicit != BFA_TRUE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1781) 		ioim->iosp->abort_explicit = BFA_FALSE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1782) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1783) 		if (bfa_ioim_send_abort(ioim))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1784) 			bfa_sm_set_state(ioim, bfa_ioim_sm_cleanup);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1785) 		else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1786) 			bfa_sm_set_state(ioim, bfa_ioim_sm_cleanup_qfull);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1787) 			bfa_stats(ioim->itnim, qwait);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1788) 			bfa_reqq_wait(ioim->bfa, ioim->reqq,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1789) 					  &ioim->iosp->reqq_wait);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1790) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1791) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1792) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1793) 	case BFA_IOIM_SM_HWFAIL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1794) 		bfa_sm_set_state(ioim, bfa_ioim_sm_hcb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1795) 		bfa_ioim_move_to_comp_q(ioim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1796) 		bfa_cb_queue(ioim->bfa, &ioim->hcb_qe, __bfa_cb_ioim_failed,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1797) 			      ioim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1798) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1799) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1800) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1801) 		bfa_sm_fault(ioim->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1802) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1803) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1804) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1805) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1806)  * IO is being cleaned up (implicit abort), waiting for completion from
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1807)  * firmware.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1808)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1809) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1810) bfa_ioim_sm_cleanup(struct bfa_ioim_s *ioim, enum bfa_ioim_event event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1811) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1812) 	bfa_trc(ioim->bfa, ioim->iotag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1813) 	bfa_trc(ioim->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1814) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1815) 	switch (event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1816) 	case BFA_IOIM_SM_COMP_GOOD:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1817) 	case BFA_IOIM_SM_COMP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1818) 	case BFA_IOIM_SM_DONE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1819) 	case BFA_IOIM_SM_FREE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1820) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1821) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1822) 	case BFA_IOIM_SM_ABORT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1823) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1824) 		 * IO is already being aborted implicitly
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1825) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1826) 		ioim->io_cbfn = __bfa_cb_ioim_abort;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1827) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1828) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1829) 	case BFA_IOIM_SM_ABORT_DONE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1830) 		bfa_sm_set_state(ioim, bfa_ioim_sm_hcb_free);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1831) 		bfa_cb_queue(ioim->bfa, &ioim->hcb_qe, ioim->io_cbfn, ioim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1832) 		bfa_ioim_notify_cleanup(ioim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1833) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1834) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1835) 	case BFA_IOIM_SM_ABORT_COMP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1836) 		bfa_sm_set_state(ioim, bfa_ioim_sm_hcb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1837) 		bfa_cb_queue(ioim->bfa, &ioim->hcb_qe, ioim->io_cbfn, ioim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1838) 		bfa_ioim_notify_cleanup(ioim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1839) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1840) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1841) 	case BFA_IOIM_SM_COMP_UTAG:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1842) 		bfa_sm_set_state(ioim, bfa_ioim_sm_hcb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1843) 		bfa_cb_queue(ioim->bfa, &ioim->hcb_qe, ioim->io_cbfn, ioim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1844) 		bfa_ioim_notify_cleanup(ioim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1845) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1846) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1847) 	case BFA_IOIM_SM_HWFAIL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1848) 		bfa_sm_set_state(ioim, bfa_ioim_sm_hcb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1849) 		bfa_ioim_move_to_comp_q(ioim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1850) 		bfa_cb_queue(ioim->bfa, &ioim->hcb_qe, __bfa_cb_ioim_failed,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1851) 			      ioim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1852) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1853) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1854) 	case BFA_IOIM_SM_CLEANUP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1855) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1856) 		 * IO can be in cleanup state already due to TM command.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1857) 		 * 2nd cleanup request comes from ITN offline event.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1858) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1859) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1860) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1861) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1862) 		bfa_sm_fault(ioim->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1863) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1864) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1865) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1866) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1867)  * IO is waiting for room in request CQ
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1868)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1869) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1870) bfa_ioim_sm_qfull(struct bfa_ioim_s *ioim, enum bfa_ioim_event event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1871) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1872) 	bfa_trc(ioim->bfa, ioim->iotag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1873) 	bfa_trc(ioim->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1874) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1875) 	switch (event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1876) 	case BFA_IOIM_SM_QRESUME:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1877) 		bfa_sm_set_state(ioim, bfa_ioim_sm_active);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1878) 		bfa_ioim_send_ioreq(ioim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1879) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1880) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1881) 	case BFA_IOIM_SM_ABORT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1882) 		bfa_sm_set_state(ioim, bfa_ioim_sm_hcb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1883) 		bfa_reqq_wcancel(&ioim->iosp->reqq_wait);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1884) 		bfa_ioim_move_to_comp_q(ioim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1885) 		bfa_cb_queue(ioim->bfa, &ioim->hcb_qe, __bfa_cb_ioim_abort,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1886) 			      ioim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1887) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1888) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1889) 	case BFA_IOIM_SM_CLEANUP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1890) 		bfa_sm_set_state(ioim, bfa_ioim_sm_hcb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1891) 		bfa_reqq_wcancel(&ioim->iosp->reqq_wait);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1892) 		bfa_cb_queue(ioim->bfa, &ioim->hcb_qe, __bfa_cb_ioim_failed,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1893) 			      ioim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1894) 		bfa_ioim_notify_cleanup(ioim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1895) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1896) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1897) 	case BFA_IOIM_SM_HWFAIL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1898) 		bfa_sm_set_state(ioim, bfa_ioim_sm_hcb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1899) 		bfa_reqq_wcancel(&ioim->iosp->reqq_wait);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1900) 		bfa_ioim_move_to_comp_q(ioim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1901) 		bfa_cb_queue(ioim->bfa, &ioim->hcb_qe, __bfa_cb_ioim_failed,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1902) 			      ioim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1903) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1904) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1905) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1906) 		bfa_sm_fault(ioim->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1907) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1908) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1909) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1910) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1911)  * Active IO is being aborted, waiting for room in request CQ.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1912)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1913) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1914) bfa_ioim_sm_abort_qfull(struct bfa_ioim_s *ioim, enum bfa_ioim_event event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1915) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1916) 	bfa_trc(ioim->bfa, ioim->iotag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1917) 	bfa_trc(ioim->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1918) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1919) 	switch (event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1920) 	case BFA_IOIM_SM_QRESUME:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1921) 		bfa_sm_set_state(ioim, bfa_ioim_sm_abort);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1922) 		bfa_ioim_send_abort(ioim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1923) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1924) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1925) 	case BFA_IOIM_SM_CLEANUP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1926) 		WARN_ON(ioim->iosp->abort_explicit != BFA_TRUE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1927) 		ioim->iosp->abort_explicit = BFA_FALSE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1928) 		bfa_sm_set_state(ioim, bfa_ioim_sm_cleanup_qfull);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1929) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1930) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1931) 	case BFA_IOIM_SM_COMP_GOOD:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1932) 	case BFA_IOIM_SM_COMP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1933) 		bfa_sm_set_state(ioim, bfa_ioim_sm_hcb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1934) 		bfa_reqq_wcancel(&ioim->iosp->reqq_wait);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1935) 		bfa_ioim_move_to_comp_q(ioim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1936) 		bfa_cb_queue(ioim->bfa, &ioim->hcb_qe, __bfa_cb_ioim_abort,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1937) 			      ioim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1938) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1939) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1940) 	case BFA_IOIM_SM_DONE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1941) 		bfa_sm_set_state(ioim, bfa_ioim_sm_hcb_free);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1942) 		bfa_reqq_wcancel(&ioim->iosp->reqq_wait);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1943) 		bfa_ioim_move_to_comp_q(ioim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1944) 		bfa_cb_queue(ioim->bfa, &ioim->hcb_qe, __bfa_cb_ioim_abort,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1945) 			      ioim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1946) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1947) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1948) 	case BFA_IOIM_SM_HWFAIL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1949) 		bfa_sm_set_state(ioim, bfa_ioim_sm_hcb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1950) 		bfa_reqq_wcancel(&ioim->iosp->reqq_wait);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1951) 		bfa_ioim_move_to_comp_q(ioim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1952) 		bfa_cb_queue(ioim->bfa, &ioim->hcb_qe, __bfa_cb_ioim_failed,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1953) 			      ioim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1954) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1955) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1956) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1957) 		bfa_sm_fault(ioim->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1958) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1959) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1960) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1961) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1962)  * Active IO is being cleaned up, waiting for room in request CQ.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1963)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1964) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1965) bfa_ioim_sm_cleanup_qfull(struct bfa_ioim_s *ioim, enum bfa_ioim_event event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1966) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1967) 	bfa_trc(ioim->bfa, ioim->iotag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1968) 	bfa_trc(ioim->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1969) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1970) 	switch (event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1971) 	case BFA_IOIM_SM_QRESUME:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1972) 		bfa_sm_set_state(ioim, bfa_ioim_sm_cleanup);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1973) 		bfa_ioim_send_abort(ioim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1974) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1975) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1976) 	case BFA_IOIM_SM_ABORT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1977) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1978) 		 * IO is already being cleaned up implicitly
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1979) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1980) 		ioim->io_cbfn = __bfa_cb_ioim_abort;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1981) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1982) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1983) 	case BFA_IOIM_SM_COMP_GOOD:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1984) 	case BFA_IOIM_SM_COMP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1985) 		bfa_sm_set_state(ioim, bfa_ioim_sm_hcb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1986) 		bfa_reqq_wcancel(&ioim->iosp->reqq_wait);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1987) 		bfa_cb_queue(ioim->bfa, &ioim->hcb_qe, ioim->io_cbfn, ioim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1988) 		bfa_ioim_notify_cleanup(ioim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1989) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1990) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1991) 	case BFA_IOIM_SM_DONE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1992) 		bfa_sm_set_state(ioim, bfa_ioim_sm_hcb_free);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1993) 		bfa_reqq_wcancel(&ioim->iosp->reqq_wait);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1994) 		bfa_cb_queue(ioim->bfa, &ioim->hcb_qe, ioim->io_cbfn, ioim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1995) 		bfa_ioim_notify_cleanup(ioim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1996) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1997) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1998) 	case BFA_IOIM_SM_HWFAIL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1999) 		bfa_sm_set_state(ioim, bfa_ioim_sm_hcb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2000) 		bfa_reqq_wcancel(&ioim->iosp->reqq_wait);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2001) 		bfa_ioim_move_to_comp_q(ioim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2002) 		bfa_cb_queue(ioim->bfa, &ioim->hcb_qe, __bfa_cb_ioim_failed,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2003) 			      ioim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2004) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2005) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2006) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2007) 		bfa_sm_fault(ioim->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2008) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2009) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2010) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2011) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2012)  * IO bfa callback is pending.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2013)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2014) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2015) bfa_ioim_sm_hcb(struct bfa_ioim_s *ioim, enum bfa_ioim_event event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2016) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2017) 	switch (event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2018) 	case BFA_IOIM_SM_HCB:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2019) 		bfa_sm_set_state(ioim, bfa_ioim_sm_uninit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2020) 		bfa_ioim_free(ioim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2021) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2022) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2023) 	case BFA_IOIM_SM_CLEANUP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2024) 		bfa_ioim_notify_cleanup(ioim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2025) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2026) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2027) 	case BFA_IOIM_SM_HWFAIL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2028) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2029) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2030) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2031) 		bfa_sm_fault(ioim->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2032) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2033) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2034) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2035) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2036)  * IO bfa callback is pending. IO resource cannot be freed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2037)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2038) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2039) bfa_ioim_sm_hcb_free(struct bfa_ioim_s *ioim, enum bfa_ioim_event event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2040) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2041) 	bfa_trc(ioim->bfa, ioim->iotag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2042) 	bfa_trc(ioim->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2043) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2044) 	switch (event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2045) 	case BFA_IOIM_SM_HCB:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2046) 		bfa_sm_set_state(ioim, bfa_ioim_sm_resfree);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2047) 		list_del(&ioim->qe);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2048) 		list_add_tail(&ioim->qe, &ioim->fcpim->ioim_resfree_q);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2049) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2050) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2051) 	case BFA_IOIM_SM_FREE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2052) 		bfa_sm_set_state(ioim, bfa_ioim_sm_hcb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2053) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2054) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2055) 	case BFA_IOIM_SM_CLEANUP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2056) 		bfa_ioim_notify_cleanup(ioim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2057) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2058) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2059) 	case BFA_IOIM_SM_HWFAIL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2060) 		bfa_sm_set_state(ioim, bfa_ioim_sm_hcb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2061) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2062) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2063) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2064) 		bfa_sm_fault(ioim->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2065) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2066) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2067) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2068) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2069)  * IO is completed, waiting resource free from firmware.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2070)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2071) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2072) bfa_ioim_sm_resfree(struct bfa_ioim_s *ioim, enum bfa_ioim_event event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2073) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2074) 	bfa_trc(ioim->bfa, ioim->iotag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2075) 	bfa_trc(ioim->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2076) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2077) 	switch (event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2078) 	case BFA_IOIM_SM_FREE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2079) 		bfa_sm_set_state(ioim, bfa_ioim_sm_uninit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2080) 		bfa_ioim_free(ioim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2081) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2082) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2083) 	case BFA_IOIM_SM_CLEANUP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2084) 		bfa_ioim_notify_cleanup(ioim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2085) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2086) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2087) 	case BFA_IOIM_SM_HWFAIL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2088) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2089) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2090) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2091) 		bfa_sm_fault(ioim->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2092) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2093) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2094) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2095) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2096)  * This is called from bfa_fcpim_start after the bfa_init() with flash read
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2097)  * is complete by driver. now invalidate the stale content of lun mask
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2098)  * like unit attention, rp tag and lp tag.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2099)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2100) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2101) bfa_ioim_lm_init(struct bfa_s *bfa)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2102) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2103) 	struct bfa_lun_mask_s *lunm_list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2104) 	int	i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2105) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2106) 	if (bfa_get_lun_mask_status(bfa) == BFA_LUNMASK_MINCFG)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2107) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2108) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2109) 	lunm_list = bfa_get_lun_mask_list(bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2110) 	for (i = 0; i < MAX_LUN_MASK_CFG; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2111) 		lunm_list[i].ua = BFA_IOIM_LM_UA_RESET;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2112) 		lunm_list[i].lp_tag = BFA_LP_TAG_INVALID;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2113) 		lunm_list[i].rp_tag = BFA_RPORT_TAG_INVALID;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2114) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2115) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2116) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2117) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2118) __bfa_cb_ioim_good_comp(void *cbarg, bfa_boolean_t complete)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2119) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2120) 	struct bfa_ioim_s *ioim = cbarg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2121) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2122) 	if (!complete) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2123) 		bfa_sm_send_event(ioim, BFA_IOIM_SM_HCB);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2124) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2125) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2126) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2127) 	bfa_cb_ioim_good_comp(ioim->bfa->bfad, ioim->dio);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2128) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2129) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2130) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2131) __bfa_cb_ioim_comp(void *cbarg, bfa_boolean_t complete)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2132) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2133) 	struct bfa_ioim_s	*ioim = cbarg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2134) 	struct bfi_ioim_rsp_s *m;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2135) 	u8	*snsinfo = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2136) 	u8	sns_len = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2137) 	s32	residue = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2138) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2139) 	if (!complete) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2140) 		bfa_sm_send_event(ioim, BFA_IOIM_SM_HCB);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2141) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2142) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2143) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2144) 	m = (struct bfi_ioim_rsp_s *) &ioim->iosp->comp_rspmsg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2145) 	if (m->io_status == BFI_IOIM_STS_OK) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2146) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2147) 		 * setup sense information, if present
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2148) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2149) 		if ((m->scsi_status == SCSI_STATUS_CHECK_CONDITION) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2150) 					m->sns_len) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2151) 			sns_len = m->sns_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2152) 			snsinfo = BFA_SNSINFO_FROM_TAG(ioim->fcpim->fcp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2153) 						ioim->iotag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2154) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2155) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2156) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2157) 		 * setup residue value correctly for normal completions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2158) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2159) 		if (m->resid_flags == FCP_RESID_UNDER) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2160) 			residue = be32_to_cpu(m->residue);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2161) 			bfa_stats(ioim->itnim, iocomp_underrun);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2162) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2163) 		if (m->resid_flags == FCP_RESID_OVER) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2164) 			residue = be32_to_cpu(m->residue);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2165) 			residue = -residue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2166) 			bfa_stats(ioim->itnim, iocomp_overrun);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2167) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2168) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2169) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2170) 	bfa_cb_ioim_done(ioim->bfa->bfad, ioim->dio, m->io_status,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2171) 			  m->scsi_status, sns_len, snsinfo, residue);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2172) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2173) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2174) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2175) bfa_fcpim_lunmask_rp_update(struct bfa_s *bfa, wwn_t lp_wwn, wwn_t rp_wwn,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2176) 			u16 rp_tag, u8 lp_tag)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2177) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2178) 	struct bfa_lun_mask_s *lun_list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2179) 	u8	i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2180) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2181) 	if (bfa_get_lun_mask_status(bfa) == BFA_LUNMASK_MINCFG)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2182) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2183) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2184) 	lun_list = bfa_get_lun_mask_list(bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2185) 	for (i = 0; i < MAX_LUN_MASK_CFG; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2186) 		if (lun_list[i].state == BFA_IOIM_LUN_MASK_ACTIVE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2187) 			if ((lun_list[i].lp_wwn == lp_wwn) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2188) 			    (lun_list[i].rp_wwn == rp_wwn)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2189) 				lun_list[i].rp_tag = rp_tag;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2190) 				lun_list[i].lp_tag = lp_tag;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2191) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2192) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2193) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2194) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2195) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2196) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2197)  * set UA for all active luns in LM DB
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2198)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2199) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2200) bfa_ioim_lm_set_ua(struct bfa_s *bfa)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2201) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2202) 	struct bfa_lun_mask_s	*lunm_list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2203) 	int	i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2204) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2205) 	lunm_list = bfa_get_lun_mask_list(bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2206) 	for (i = 0; i < MAX_LUN_MASK_CFG; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2207) 		if (lunm_list[i].state != BFA_IOIM_LUN_MASK_ACTIVE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2208) 			continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2209) 		lunm_list[i].ua = BFA_IOIM_LM_UA_SET;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2210) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2211) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2212) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2213) bfa_status_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2214) bfa_fcpim_lunmask_update(struct bfa_s *bfa, u32 update)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2215) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2216) 	struct bfa_lunmask_cfg_s	*lun_mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2217) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2218) 	bfa_trc(bfa, bfa_get_lun_mask_status(bfa));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2219) 	if (bfa_get_lun_mask_status(bfa) == BFA_LUNMASK_MINCFG)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2220) 		return BFA_STATUS_FAILED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2221) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2222) 	if (bfa_get_lun_mask_status(bfa) == update)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2223) 		return BFA_STATUS_NO_CHANGE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2224) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2225) 	lun_mask = bfa_get_lun_mask(bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2226) 	lun_mask->status = update;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2227) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2228) 	if (bfa_get_lun_mask_status(bfa) == BFA_LUNMASK_ENABLED)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2229) 		bfa_ioim_lm_set_ua(bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2230) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2231) 	return  bfa_dconf_update(bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2232) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2233) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2234) bfa_status_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2235) bfa_fcpim_lunmask_clear(struct bfa_s *bfa)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2236) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2237) 	int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2238) 	struct bfa_lun_mask_s	*lunm_list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2239) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2240) 	bfa_trc(bfa, bfa_get_lun_mask_status(bfa));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2241) 	if (bfa_get_lun_mask_status(bfa) == BFA_LUNMASK_MINCFG)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2242) 		return BFA_STATUS_FAILED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2243) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2244) 	lunm_list = bfa_get_lun_mask_list(bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2245) 	for (i = 0; i < MAX_LUN_MASK_CFG; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2246) 		if (lunm_list[i].state == BFA_IOIM_LUN_MASK_ACTIVE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2247) 			if (lunm_list[i].rp_tag != BFA_RPORT_TAG_INVALID)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2248) 				bfa_rport_unset_lunmask(bfa,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2249) 				  BFA_RPORT_FROM_TAG(bfa, lunm_list[i].rp_tag));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2250) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2251) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2252) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2253) 	memset(lunm_list, 0, sizeof(struct bfa_lun_mask_s) * MAX_LUN_MASK_CFG);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2254) 	return bfa_dconf_update(bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2255) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2256) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2257) bfa_status_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2258) bfa_fcpim_lunmask_query(struct bfa_s *bfa, void *buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2259) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2260) 	struct bfa_lunmask_cfg_s *lun_mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2261) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2262) 	bfa_trc(bfa, bfa_get_lun_mask_status(bfa));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2263) 	if (bfa_get_lun_mask_status(bfa) == BFA_LUNMASK_MINCFG)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2264) 		return BFA_STATUS_FAILED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2265) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2266) 	lun_mask = bfa_get_lun_mask(bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2267) 	memcpy(buf, lun_mask, sizeof(struct bfa_lunmask_cfg_s));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2268) 	return BFA_STATUS_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2269) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2270) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2271) bfa_status_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2272) bfa_fcpim_lunmask_add(struct bfa_s *bfa, u16 vf_id, wwn_t *pwwn,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2273) 		      wwn_t rpwwn, struct scsi_lun lun)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2274) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2275) 	struct bfa_lun_mask_s *lunm_list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2276) 	struct bfa_rport_s *rp = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2277) 	int i, free_index = MAX_LUN_MASK_CFG + 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2278) 	struct bfa_fcs_lport_s *port = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2279) 	struct bfa_fcs_rport_s *rp_fcs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2280) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2281) 	bfa_trc(bfa, bfa_get_lun_mask_status(bfa));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2282) 	if (bfa_get_lun_mask_status(bfa) == BFA_LUNMASK_MINCFG)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2283) 		return BFA_STATUS_FAILED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2284) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2285) 	port = bfa_fcs_lookup_port(&((struct bfad_s *)bfa->bfad)->bfa_fcs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2286) 				   vf_id, *pwwn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2287) 	if (port) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2288) 		*pwwn = port->port_cfg.pwwn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2289) 		rp_fcs = bfa_fcs_lport_get_rport_by_pwwn(port, rpwwn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2290) 		if (rp_fcs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2291) 			rp = rp_fcs->bfa_rport;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2292) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2293) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2294) 	lunm_list = bfa_get_lun_mask_list(bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2295) 	/* if entry exists */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2296) 	for (i = 0; i < MAX_LUN_MASK_CFG; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2297) 		if (lunm_list[i].state != BFA_IOIM_LUN_MASK_ACTIVE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2298) 			free_index = i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2299) 		if ((lunm_list[i].lp_wwn == *pwwn) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2300) 		    (lunm_list[i].rp_wwn == rpwwn) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2301) 		    (scsilun_to_int((struct scsi_lun *)&lunm_list[i].lun) ==
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2302) 		     scsilun_to_int((struct scsi_lun *)&lun)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2303) 			return  BFA_STATUS_ENTRY_EXISTS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2304) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2305) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2306) 	if (free_index > MAX_LUN_MASK_CFG)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2307) 		return BFA_STATUS_MAX_ENTRY_REACHED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2308) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2309) 	if (rp) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2310) 		lunm_list[free_index].lp_tag = bfa_lps_get_tag_from_pid(bfa,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2311) 						   rp->rport_info.local_pid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2312) 		lunm_list[free_index].rp_tag = rp->rport_tag;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2313) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2314) 		lunm_list[free_index].lp_tag = BFA_LP_TAG_INVALID;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2315) 		lunm_list[free_index].rp_tag = BFA_RPORT_TAG_INVALID;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2316) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2317) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2318) 	lunm_list[free_index].lp_wwn = *pwwn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2319) 	lunm_list[free_index].rp_wwn = rpwwn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2320) 	lunm_list[free_index].lun = lun;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2321) 	lunm_list[free_index].state = BFA_IOIM_LUN_MASK_ACTIVE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2322) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2323) 	/* set for all luns in this rp */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2324) 	for (i = 0; i < MAX_LUN_MASK_CFG; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2325) 		if ((lunm_list[i].lp_wwn == *pwwn) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2326) 		    (lunm_list[i].rp_wwn == rpwwn))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2327) 			lunm_list[i].ua = BFA_IOIM_LM_UA_SET;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2328) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2329) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2330) 	return bfa_dconf_update(bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2331) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2332) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2333) bfa_status_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2334) bfa_fcpim_lunmask_delete(struct bfa_s *bfa, u16 vf_id, wwn_t *pwwn,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2335) 			 wwn_t rpwwn, struct scsi_lun lun)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2336) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2337) 	struct bfa_lun_mask_s	*lunm_list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2338) 	struct bfa_fcs_lport_s *port = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2339) 	int	i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2340) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2341) 	/* in min cfg lunm_list could be NULL but  no commands should run. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2342) 	if (bfa_get_lun_mask_status(bfa) == BFA_LUNMASK_MINCFG)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2343) 		return BFA_STATUS_FAILED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2344) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2345) 	bfa_trc(bfa, bfa_get_lun_mask_status(bfa));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2346) 	bfa_trc(bfa, *pwwn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2347) 	bfa_trc(bfa, rpwwn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2348) 	bfa_trc(bfa, scsilun_to_int((struct scsi_lun *)&lun));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2349) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2350) 	if (*pwwn == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2351) 		port = bfa_fcs_lookup_port(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2352) 				&((struct bfad_s *)bfa->bfad)->bfa_fcs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2353) 				vf_id, *pwwn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2354) 		if (port)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2355) 			*pwwn = port->port_cfg.pwwn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2356) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2357) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2358) 	lunm_list = bfa_get_lun_mask_list(bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2359) 	for (i = 0; i < MAX_LUN_MASK_CFG; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2360) 		if ((lunm_list[i].lp_wwn == *pwwn) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2361) 		    (lunm_list[i].rp_wwn == rpwwn) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2362) 		    (scsilun_to_int((struct scsi_lun *)&lunm_list[i].lun) ==
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2363) 		     scsilun_to_int((struct scsi_lun *)&lun))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2364) 			lunm_list[i].lp_wwn = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2365) 			lunm_list[i].rp_wwn = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2366) 			int_to_scsilun(0, &lunm_list[i].lun);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2367) 			lunm_list[i].state = BFA_IOIM_LUN_MASK_INACTIVE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2368) 			if (lunm_list[i].rp_tag != BFA_RPORT_TAG_INVALID) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2369) 				lunm_list[i].rp_tag = BFA_RPORT_TAG_INVALID;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2370) 				lunm_list[i].lp_tag = BFA_LP_TAG_INVALID;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2371) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2372) 			return bfa_dconf_update(bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2373) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2374) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2375) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2376) 	/* set for all luns in this rp */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2377) 	for (i = 0; i < MAX_LUN_MASK_CFG; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2378) 		if ((lunm_list[i].lp_wwn == *pwwn) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2379) 		    (lunm_list[i].rp_wwn == rpwwn))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2380) 			lunm_list[i].ua = BFA_IOIM_LM_UA_SET;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2381) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2382) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2383) 	return BFA_STATUS_ENTRY_NOT_EXISTS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2384) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2385) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2386) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2387) __bfa_cb_ioim_failed(void *cbarg, bfa_boolean_t complete)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2388) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2389) 	struct bfa_ioim_s *ioim = cbarg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2390) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2391) 	if (!complete) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2392) 		bfa_sm_send_event(ioim, BFA_IOIM_SM_HCB);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2393) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2394) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2395) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2396) 	bfa_cb_ioim_done(ioim->bfa->bfad, ioim->dio, BFI_IOIM_STS_ABORTED,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2397) 			  0, 0, NULL, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2398) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2399) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2400) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2401) __bfa_cb_ioim_pathtov(void *cbarg, bfa_boolean_t complete)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2402) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2403) 	struct bfa_ioim_s *ioim = cbarg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2404) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2405) 	bfa_stats(ioim->itnim, path_tov_expired);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2406) 	if (!complete) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2407) 		bfa_sm_send_event(ioim, BFA_IOIM_SM_HCB);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2408) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2409) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2410) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2411) 	bfa_cb_ioim_done(ioim->bfa->bfad, ioim->dio, BFI_IOIM_STS_PATHTOV,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2412) 			  0, 0, NULL, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2413) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2414) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2415) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2416) __bfa_cb_ioim_abort(void *cbarg, bfa_boolean_t complete)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2417) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2418) 	struct bfa_ioim_s *ioim = cbarg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2419) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2420) 	if (!complete) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2421) 		bfa_sm_send_event(ioim, BFA_IOIM_SM_HCB);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2422) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2423) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2424) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2425) 	bfa_cb_ioim_abort(ioim->bfa->bfad, ioim->dio);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2426) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2427) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2428) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2429) bfa_ioim_sgpg_alloced(void *cbarg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2430) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2431) 	struct bfa_ioim_s *ioim = cbarg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2432) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2433) 	ioim->nsgpgs = BFA_SGPG_NPAGE(ioim->nsges);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2434) 	list_splice_tail_init(&ioim->iosp->sgpg_wqe.sgpg_q, &ioim->sgpg_q);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2435) 	ioim->sgpg = bfa_q_first(&ioim->sgpg_q);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2436) 	bfa_sm_send_event(ioim, BFA_IOIM_SM_SGALLOCED);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2437) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2438) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2439) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2440)  * Send I/O request to firmware.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2441)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2442) static	bfa_boolean_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2443) bfa_ioim_send_ioreq(struct bfa_ioim_s *ioim)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2444) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2445) 	struct bfa_itnim_s *itnim = ioim->itnim;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2446) 	struct bfi_ioim_req_s *m;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2447) 	static struct fcp_cmnd_s cmnd_z0 = { { { 0 } } };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2448) 	struct bfi_sge_s *sge, *sgpge;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2449) 	u32	pgdlen = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2450) 	u32	fcp_dl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2451) 	u64 addr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2452) 	struct scatterlist *sg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2453) 	struct bfa_sgpg_s *sgpg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2454) 	struct scsi_cmnd *cmnd = (struct scsi_cmnd *) ioim->dio;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2455) 	u32 i, sge_id, pgcumsz;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2456) 	enum dma_data_direction dmadir;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2457) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2458) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2459) 	 * check for room in queue to send request now
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2460) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2461) 	m = bfa_reqq_next(ioim->bfa, ioim->reqq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2462) 	if (!m) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2463) 		bfa_stats(ioim->itnim, qwait);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2464) 		bfa_reqq_wait(ioim->bfa, ioim->reqq,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2465) 				  &ioim->iosp->reqq_wait);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2466) 		return BFA_FALSE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2467) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2468) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2469) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2470) 	 * build i/o request message next
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2471) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2472) 	m->io_tag = cpu_to_be16(ioim->iotag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2473) 	m->rport_hdl = ioim->itnim->rport->fw_handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2474) 	m->io_timeout = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2475) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2476) 	sge = &m->sges[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2477) 	sgpg = ioim->sgpg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2478) 	sge_id = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2479) 	sgpge = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2480) 	pgcumsz = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2481) 	scsi_for_each_sg(cmnd, sg, ioim->nsges, i) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2482) 		if (i == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2483) 			/* build inline IO SG element */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2484) 			addr = bfa_sgaddr_le(sg_dma_address(sg));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2485) 			sge->sga = *(union bfi_addr_u *) &addr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2486) 			pgdlen = sg_dma_len(sg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2487) 			sge->sg_len = pgdlen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2488) 			sge->flags = (ioim->nsges > BFI_SGE_INLINE) ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2489) 					BFI_SGE_DATA_CPL : BFI_SGE_DATA_LAST;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2490) 			bfa_sge_to_be(sge);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2491) 			sge++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2492) 		} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2493) 			if (sge_id == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2494) 				sgpge = sgpg->sgpg->sges;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2495) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2496) 			addr = bfa_sgaddr_le(sg_dma_address(sg));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2497) 			sgpge->sga = *(union bfi_addr_u *) &addr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2498) 			sgpge->sg_len = sg_dma_len(sg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2499) 			pgcumsz += sgpge->sg_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2500) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2501) 			/* set flags */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2502) 			if (i < (ioim->nsges - 1) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2503) 					sge_id < (BFI_SGPG_DATA_SGES - 1))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2504) 				sgpge->flags = BFI_SGE_DATA;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2505) 			else if (i < (ioim->nsges - 1))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2506) 				sgpge->flags = BFI_SGE_DATA_CPL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2507) 			else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2508) 				sgpge->flags = BFI_SGE_DATA_LAST;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2509) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2510) 			bfa_sge_to_le(sgpge);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2511) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2512) 			sgpge++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2513) 			if (i == (ioim->nsges - 1)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2514) 				sgpge->flags = BFI_SGE_PGDLEN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2515) 				sgpge->sga.a32.addr_lo = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2516) 				sgpge->sga.a32.addr_hi = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2517) 				sgpge->sg_len = pgcumsz;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2518) 				bfa_sge_to_le(sgpge);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2519) 			} else if (++sge_id == BFI_SGPG_DATA_SGES) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2520) 				sgpg = (struct bfa_sgpg_s *) bfa_q_next(sgpg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2521) 				sgpge->flags = BFI_SGE_LINK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2522) 				sgpge->sga = sgpg->sgpg_pa;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2523) 				sgpge->sg_len = pgcumsz;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2524) 				bfa_sge_to_le(sgpge);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2525) 				sge_id = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2526) 				pgcumsz = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2527) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2528) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2529) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2530) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2531) 	if (ioim->nsges > BFI_SGE_INLINE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2532) 		sge->sga = ioim->sgpg->sgpg_pa;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2533) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2534) 		sge->sga.a32.addr_lo = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2535) 		sge->sga.a32.addr_hi = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2536) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2537) 	sge->sg_len = pgdlen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2538) 	sge->flags = BFI_SGE_PGDLEN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2539) 	bfa_sge_to_be(sge);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2540) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2541) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2542) 	 * set up I/O command parameters
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2543) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2544) 	m->cmnd = cmnd_z0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2545) 	int_to_scsilun(cmnd->device->lun, &m->cmnd.lun);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2546) 	dmadir = cmnd->sc_data_direction;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2547) 	if (dmadir == DMA_TO_DEVICE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2548) 		m->cmnd.iodir = FCP_IODIR_WRITE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2549) 	else if (dmadir == DMA_FROM_DEVICE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2550) 		m->cmnd.iodir = FCP_IODIR_READ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2551) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2552) 		m->cmnd.iodir = FCP_IODIR_NONE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2553) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2554) 	m->cmnd.cdb = *(struct scsi_cdb_s *) cmnd->cmnd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2555) 	fcp_dl = scsi_bufflen(cmnd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2556) 	m->cmnd.fcp_dl = cpu_to_be32(fcp_dl);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2557) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2558) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2559) 	 * set up I/O message header
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2560) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2561) 	switch (m->cmnd.iodir) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2562) 	case FCP_IODIR_READ:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2563) 		bfi_h2i_set(m->mh, BFI_MC_IOIM_READ, 0, bfa_fn_lpu(ioim->bfa));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2564) 		bfa_stats(itnim, input_reqs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2565) 		ioim->itnim->stats.rd_throughput += fcp_dl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2566) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2567) 	case FCP_IODIR_WRITE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2568) 		bfi_h2i_set(m->mh, BFI_MC_IOIM_WRITE, 0, bfa_fn_lpu(ioim->bfa));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2569) 		bfa_stats(itnim, output_reqs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2570) 		ioim->itnim->stats.wr_throughput += fcp_dl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2571) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2572) 	case FCP_IODIR_RW:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2573) 		bfa_stats(itnim, input_reqs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2574) 		bfa_stats(itnim, output_reqs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2575) 		fallthrough;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2576) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2577) 		bfi_h2i_set(m->mh, BFI_MC_IOIM_IO, 0, bfa_fn_lpu(ioim->bfa));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2578) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2579) 	if (itnim->seq_rec ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2580) 	    (scsi_bufflen(cmnd) & (sizeof(u32) - 1)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2581) 		bfi_h2i_set(m->mh, BFI_MC_IOIM_IO, 0, bfa_fn_lpu(ioim->bfa));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2582) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2583) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2584) 	 * queue I/O message to firmware
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2585) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2586) 	bfa_reqq_produce(ioim->bfa, ioim->reqq, m->mh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2587) 	return BFA_TRUE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2588) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2589) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2590) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2591)  * Setup any additional SG pages needed.Inline SG element is setup
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2592)  * at queuing time.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2593)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2594) static bfa_boolean_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2595) bfa_ioim_sgpg_alloc(struct bfa_ioim_s *ioim)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2596) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2597) 	u16	nsgpgs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2598) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2599) 	WARN_ON(ioim->nsges <= BFI_SGE_INLINE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2600) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2601) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2602) 	 * allocate SG pages needed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2603) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2604) 	nsgpgs = BFA_SGPG_NPAGE(ioim->nsges);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2605) 	if (!nsgpgs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2606) 		return BFA_TRUE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2607) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2608) 	if (bfa_sgpg_malloc(ioim->bfa, &ioim->sgpg_q, nsgpgs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2609) 	    != BFA_STATUS_OK) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2610) 		bfa_sgpg_wait(ioim->bfa, &ioim->iosp->sgpg_wqe, nsgpgs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2611) 		return BFA_FALSE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2612) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2613) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2614) 	ioim->nsgpgs = nsgpgs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2615) 	ioim->sgpg = bfa_q_first(&ioim->sgpg_q);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2616) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2617) 	return BFA_TRUE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2618) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2619) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2620) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2621)  * Send I/O abort request to firmware.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2622)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2623) static	bfa_boolean_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2624) bfa_ioim_send_abort(struct bfa_ioim_s *ioim)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2625) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2626) 	struct bfi_ioim_abort_req_s *m;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2627) 	enum bfi_ioim_h2i	msgop;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2628) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2629) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2630) 	 * check for room in queue to send request now
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2631) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2632) 	m = bfa_reqq_next(ioim->bfa, ioim->reqq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2633) 	if (!m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2634) 		return BFA_FALSE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2635) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2636) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2637) 	 * build i/o request message next
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2638) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2639) 	if (ioim->iosp->abort_explicit)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2640) 		msgop = BFI_IOIM_H2I_IOABORT_REQ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2641) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2642) 		msgop = BFI_IOIM_H2I_IOCLEANUP_REQ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2643) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2644) 	bfi_h2i_set(m->mh, BFI_MC_IOIM, msgop, bfa_fn_lpu(ioim->bfa));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2645) 	m->io_tag    = cpu_to_be16(ioim->iotag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2646) 	m->abort_tag = ++ioim->abort_tag;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2647) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2648) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2649) 	 * queue I/O message to firmware
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2650) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2651) 	bfa_reqq_produce(ioim->bfa, ioim->reqq, m->mh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2652) 	return BFA_TRUE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2653) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2654) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2655) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2656)  * Call to resume any I/O requests waiting for room in request queue.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2657)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2658) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2659) bfa_ioim_qresume(void *cbarg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2660) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2661) 	struct bfa_ioim_s *ioim = cbarg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2662) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2663) 	bfa_stats(ioim->itnim, qresumes);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2664) 	bfa_sm_send_event(ioim, BFA_IOIM_SM_QRESUME);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2665) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2666) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2667) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2668) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2669) bfa_ioim_notify_cleanup(struct bfa_ioim_s *ioim)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2670) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2671) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2672) 	 * Move IO from itnim queue to fcpim global queue since itnim will be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2673) 	 * freed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2674) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2675) 	list_del(&ioim->qe);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2676) 	list_add_tail(&ioim->qe, &ioim->fcpim->ioim_comp_q);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2677) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2678) 	if (!ioim->iosp->tskim) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2679) 		if (ioim->fcpim->delay_comp && ioim->itnim->iotov_active) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2680) 			bfa_cb_dequeue(&ioim->hcb_qe);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2681) 			list_del(&ioim->qe);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2682) 			list_add_tail(&ioim->qe, &ioim->itnim->delay_comp_q);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2683) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2684) 		bfa_itnim_iodone(ioim->itnim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2685) 	} else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2686) 		bfa_wc_down(&ioim->iosp->tskim->wc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2687) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2688) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2689) static bfa_boolean_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2690) bfa_ioim_is_abortable(struct bfa_ioim_s *ioim)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2691) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2692) 	if ((bfa_sm_cmp_state(ioim, bfa_ioim_sm_uninit) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2693) 	    (!bfa_q_is_on_q(&ioim->itnim->pending_q, ioim)))	||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2694) 	    (bfa_sm_cmp_state(ioim, bfa_ioim_sm_abort))		||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2695) 	    (bfa_sm_cmp_state(ioim, bfa_ioim_sm_abort_qfull))	||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2696) 	    (bfa_sm_cmp_state(ioim, bfa_ioim_sm_hcb))		||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2697) 	    (bfa_sm_cmp_state(ioim, bfa_ioim_sm_hcb_free))	||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2698) 	    (bfa_sm_cmp_state(ioim, bfa_ioim_sm_resfree)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2699) 		return BFA_FALSE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2700) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2701) 	return BFA_TRUE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2702) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2703) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2704) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2705) bfa_ioim_delayed_comp(struct bfa_ioim_s *ioim, bfa_boolean_t iotov)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2706) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2707) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2708) 	 * If path tov timer expired, failback with PATHTOV status - these
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2709) 	 * IO requests are not normally retried by IO stack.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2710) 	 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2711) 	 * Otherwise device cameback online and fail it with normal failed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2712) 	 * status so that IO stack retries these failed IO requests.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2713) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2714) 	if (iotov)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2715) 		ioim->io_cbfn = __bfa_cb_ioim_pathtov;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2716) 	else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2717) 		ioim->io_cbfn = __bfa_cb_ioim_failed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2718) 		bfa_stats(ioim->itnim, iocom_nexus_abort);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2719) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2720) 	bfa_cb_queue(ioim->bfa, &ioim->hcb_qe, ioim->io_cbfn, ioim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2721) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2722) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2723) 	 * Move IO to fcpim global queue since itnim will be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2724) 	 * freed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2725) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2726) 	list_del(&ioim->qe);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2727) 	list_add_tail(&ioim->qe, &ioim->fcpim->ioim_comp_q);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2728) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2729) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2730) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2731) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2732)  * Memory allocation and initialization.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2733)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2734) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2735) bfa_ioim_attach(struct bfa_fcpim_s *fcpim)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2736) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2737) 	struct bfa_ioim_s		*ioim;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2738) 	struct bfa_fcp_mod_s	*fcp = fcpim->fcp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2739) 	struct bfa_ioim_sp_s	*iosp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2740) 	u16		i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2741) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2742) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2743) 	 * claim memory first
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2744) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2745) 	ioim = (struct bfa_ioim_s *) bfa_mem_kva_curp(fcp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2746) 	fcpim->ioim_arr = ioim;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2747) 	bfa_mem_kva_curp(fcp) = (u8 *) (ioim + fcpim->fcp->num_ioim_reqs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2748) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2749) 	iosp = (struct bfa_ioim_sp_s *) bfa_mem_kva_curp(fcp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2750) 	fcpim->ioim_sp_arr = iosp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2751) 	bfa_mem_kva_curp(fcp) = (u8 *) (iosp + fcpim->fcp->num_ioim_reqs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2752) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2753) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2754) 	 * Initialize ioim free queues
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2755) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2756) 	INIT_LIST_HEAD(&fcpim->ioim_resfree_q);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2757) 	INIT_LIST_HEAD(&fcpim->ioim_comp_q);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2758) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2759) 	for (i = 0; i < fcpim->fcp->num_ioim_reqs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2760) 	     i++, ioim++, iosp++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2761) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2762) 		 * initialize IOIM
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2763) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2764) 		memset(ioim, 0, sizeof(struct bfa_ioim_s));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2765) 		ioim->iotag   = i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2766) 		ioim->bfa     = fcpim->bfa;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2767) 		ioim->fcpim   = fcpim;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2768) 		ioim->iosp    = iosp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2769) 		INIT_LIST_HEAD(&ioim->sgpg_q);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2770) 		bfa_reqq_winit(&ioim->iosp->reqq_wait,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2771) 				   bfa_ioim_qresume, ioim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2772) 		bfa_sgpg_winit(&ioim->iosp->sgpg_wqe,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2773) 				   bfa_ioim_sgpg_alloced, ioim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2774) 		bfa_sm_set_state(ioim, bfa_ioim_sm_uninit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2775) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2776) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2777) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2778) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2779) bfa_ioim_isr(struct bfa_s *bfa, struct bfi_msg_s *m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2780) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2781) 	struct bfa_fcpim_s *fcpim = BFA_FCPIM(bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2782) 	struct bfi_ioim_rsp_s *rsp = (struct bfi_ioim_rsp_s *) m;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2783) 	struct bfa_ioim_s *ioim;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2784) 	u16	iotag;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2785) 	enum bfa_ioim_event evt = BFA_IOIM_SM_COMP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2786) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2787) 	iotag = be16_to_cpu(rsp->io_tag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2788) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2789) 	ioim = BFA_IOIM_FROM_TAG(fcpim, iotag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2790) 	WARN_ON(ioim->iotag != iotag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2791) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2792) 	bfa_trc(ioim->bfa, ioim->iotag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2793) 	bfa_trc(ioim->bfa, rsp->io_status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2794) 	bfa_trc(ioim->bfa, rsp->reuse_io_tag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2795) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2796) 	if (bfa_sm_cmp_state(ioim, bfa_ioim_sm_active))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2797) 		ioim->iosp->comp_rspmsg = *m;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2798) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2799) 	switch (rsp->io_status) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2800) 	case BFI_IOIM_STS_OK:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2801) 		bfa_stats(ioim->itnim, iocomp_ok);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2802) 		if (rsp->reuse_io_tag == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2803) 			evt = BFA_IOIM_SM_DONE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2804) 		else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2805) 			evt = BFA_IOIM_SM_COMP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2806) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2807) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2808) 	case BFI_IOIM_STS_TIMEDOUT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2809) 		bfa_stats(ioim->itnim, iocomp_timedout);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2810) 		fallthrough;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2811) 	case BFI_IOIM_STS_ABORTED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2812) 		rsp->io_status = BFI_IOIM_STS_ABORTED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2813) 		bfa_stats(ioim->itnim, iocomp_aborted);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2814) 		if (rsp->reuse_io_tag == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2815) 			evt = BFA_IOIM_SM_DONE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2816) 		else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2817) 			evt = BFA_IOIM_SM_COMP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2818) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2819) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2820) 	case BFI_IOIM_STS_PROTO_ERR:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2821) 		bfa_stats(ioim->itnim, iocom_proto_err);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2822) 		WARN_ON(!rsp->reuse_io_tag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2823) 		evt = BFA_IOIM_SM_COMP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2824) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2825) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2826) 	case BFI_IOIM_STS_SQER_NEEDED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2827) 		bfa_stats(ioim->itnim, iocom_sqer_needed);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2828) 		WARN_ON(rsp->reuse_io_tag != 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2829) 		evt = BFA_IOIM_SM_SQRETRY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2830) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2831) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2832) 	case BFI_IOIM_STS_RES_FREE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2833) 		bfa_stats(ioim->itnim, iocom_res_free);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2834) 		evt = BFA_IOIM_SM_FREE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2835) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2836) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2837) 	case BFI_IOIM_STS_HOST_ABORTED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2838) 		bfa_stats(ioim->itnim, iocom_hostabrts);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2839) 		if (rsp->abort_tag != ioim->abort_tag) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2840) 			bfa_trc(ioim->bfa, rsp->abort_tag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2841) 			bfa_trc(ioim->bfa, ioim->abort_tag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2842) 			return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2843) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2844) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2845) 		if (rsp->reuse_io_tag)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2846) 			evt = BFA_IOIM_SM_ABORT_COMP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2847) 		else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2848) 			evt = BFA_IOIM_SM_ABORT_DONE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2849) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2850) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2851) 	case BFI_IOIM_STS_UTAG:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2852) 		bfa_stats(ioim->itnim, iocom_utags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2853) 		evt = BFA_IOIM_SM_COMP_UTAG;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2854) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2855) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2856) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2857) 		WARN_ON(1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2858) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2859) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2860) 	bfa_sm_send_event(ioim, evt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2861) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2862) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2863) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2864) bfa_ioim_good_comp_isr(struct bfa_s *bfa, struct bfi_msg_s *m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2865) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2866) 	struct bfa_fcpim_s *fcpim = BFA_FCPIM(bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2867) 	struct bfi_ioim_rsp_s *rsp = (struct bfi_ioim_rsp_s *) m;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2868) 	struct bfa_ioim_s *ioim;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2869) 	u16	iotag;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2870) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2871) 	iotag = be16_to_cpu(rsp->io_tag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2872) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2873) 	ioim = BFA_IOIM_FROM_TAG(fcpim, iotag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2874) 	WARN_ON(ioim->iotag != iotag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2875) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2876) 	bfa_ioim_cb_profile_comp(fcpim, ioim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2877) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2878) 	bfa_sm_send_event(ioim, BFA_IOIM_SM_COMP_GOOD);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2879) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2880) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2881) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2882)  * Called by itnim to clean up IO while going offline.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2883)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2884) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2885) bfa_ioim_cleanup(struct bfa_ioim_s *ioim)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2886) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2887) 	bfa_trc(ioim->bfa, ioim->iotag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2888) 	bfa_stats(ioim->itnim, io_cleanups);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2889) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2890) 	ioim->iosp->tskim = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2891) 	bfa_sm_send_event(ioim, BFA_IOIM_SM_CLEANUP);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2892) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2893) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2894) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2895) bfa_ioim_cleanup_tm(struct bfa_ioim_s *ioim, struct bfa_tskim_s *tskim)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2896) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2897) 	bfa_trc(ioim->bfa, ioim->iotag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2898) 	bfa_stats(ioim->itnim, io_tmaborts);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2899) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2900) 	ioim->iosp->tskim = tskim;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2901) 	bfa_sm_send_event(ioim, BFA_IOIM_SM_CLEANUP);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2902) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2903) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2904) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2905)  * IOC failure handling.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2906)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2907) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2908) bfa_ioim_iocdisable(struct bfa_ioim_s *ioim)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2909) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2910) 	bfa_trc(ioim->bfa, ioim->iotag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2911) 	bfa_stats(ioim->itnim, io_iocdowns);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2912) 	bfa_sm_send_event(ioim, BFA_IOIM_SM_HWFAIL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2913) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2914) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2915) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2916)  * IO offline TOV popped. Fail the pending IO.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2917)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2918) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2919) bfa_ioim_tov(struct bfa_ioim_s *ioim)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2920) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2921) 	bfa_trc(ioim->bfa, ioim->iotag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2922) 	bfa_sm_send_event(ioim, BFA_IOIM_SM_IOTOV);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2923) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2924) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2925) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2926) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2927)  * Allocate IOIM resource for initiator mode I/O request.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2928)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2929) struct bfa_ioim_s *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2930) bfa_ioim_alloc(struct bfa_s *bfa, struct bfad_ioim_s *dio,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2931) 		struct bfa_itnim_s *itnim, u16 nsges)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2932) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2933) 	struct bfa_fcpim_s *fcpim = BFA_FCPIM(bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2934) 	struct bfa_ioim_s *ioim;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2935) 	struct bfa_iotag_s *iotag = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2936) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2937) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2938) 	 * alocate IOIM resource
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2939) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2940) 	bfa_q_deq(&fcpim->fcp->iotag_ioim_free_q, &iotag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2941) 	if (!iotag) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2942) 		bfa_stats(itnim, no_iotags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2943) 		return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2944) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2945) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2946) 	ioim = BFA_IOIM_FROM_TAG(fcpim, iotag->tag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2947) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2948) 	ioim->dio = dio;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2949) 	ioim->itnim = itnim;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2950) 	ioim->nsges = nsges;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2951) 	ioim->nsgpgs = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2952) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2953) 	bfa_stats(itnim, total_ios);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2954) 	fcpim->ios_active++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2955) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2956) 	list_add_tail(&ioim->qe, &itnim->io_q);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2957) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2958) 	return ioim;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2959) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2960) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2961) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2962) bfa_ioim_free(struct bfa_ioim_s *ioim)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2963) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2964) 	struct bfa_fcpim_s *fcpim = ioim->fcpim;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2965) 	struct bfa_iotag_s *iotag;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2966) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2967) 	if (ioim->nsgpgs > 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2968) 		bfa_sgpg_mfree(ioim->bfa, &ioim->sgpg_q, ioim->nsgpgs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2969) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2970) 	bfa_stats(ioim->itnim, io_comps);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2971) 	fcpim->ios_active--;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2972) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2973) 	ioim->iotag &= BFA_IOIM_IOTAG_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2974) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2975) 	WARN_ON(!(ioim->iotag <
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2976) 		(fcpim->fcp->num_ioim_reqs + fcpim->fcp->num_fwtio_reqs)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2977) 	iotag = BFA_IOTAG_FROM_TAG(fcpim->fcp, ioim->iotag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2978) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2979) 	if (ioim->iotag < fcpim->fcp->num_ioim_reqs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2980) 		list_add_tail(&iotag->qe, &fcpim->fcp->iotag_ioim_free_q);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2981) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2982) 		list_add_tail(&iotag->qe, &fcpim->fcp->iotag_tio_free_q);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2983) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2984) 	list_del(&ioim->qe);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2985) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2986) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2987) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2988) bfa_ioim_start(struct bfa_ioim_s *ioim)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2989) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2990) 	bfa_ioim_cb_profile_start(ioim->fcpim, ioim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2991) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2992) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2993) 	 * Obtain the queue over which this request has to be issued
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2994) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2995) 	ioim->reqq = bfa_fcpim_ioredirect_enabled(ioim->bfa) ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2996) 			BFA_FALSE : bfa_itnim_get_reqq(ioim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2997) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2998) 	bfa_sm_send_event(ioim, BFA_IOIM_SM_START);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2999) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3000) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3001) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3002)  * Driver I/O abort request.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3003)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3004) bfa_status_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3005) bfa_ioim_abort(struct bfa_ioim_s *ioim)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3006) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3007) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3008) 	bfa_trc(ioim->bfa, ioim->iotag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3009) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3010) 	if (!bfa_ioim_is_abortable(ioim))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3011) 		return BFA_STATUS_FAILED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3012) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3013) 	bfa_stats(ioim->itnim, io_aborts);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3014) 	bfa_sm_send_event(ioim, BFA_IOIM_SM_ABORT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3015) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3016) 	return BFA_STATUS_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3017) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3018) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3019) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3020)  *  BFA TSKIM state machine functions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3021)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3022) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3023) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3024)  * Task management command beginning state.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3025)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3026) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3027) bfa_tskim_sm_uninit(struct bfa_tskim_s *tskim, enum bfa_tskim_event event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3028) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3029) 	bfa_trc(tskim->bfa, tskim->tsk_tag << 16 | event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3030) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3031) 	switch (event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3032) 	case BFA_TSKIM_SM_START:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3033) 		bfa_sm_set_state(tskim, bfa_tskim_sm_active);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3034) 		bfa_tskim_gather_ios(tskim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3035) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3036) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3037) 		 * If device is offline, do not send TM on wire. Just cleanup
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3038) 		 * any pending IO requests and complete TM request.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3039) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3040) 		if (!bfa_itnim_is_online(tskim->itnim)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3041) 			bfa_sm_set_state(tskim, bfa_tskim_sm_iocleanup);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3042) 			tskim->tsk_status = BFI_TSKIM_STS_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3043) 			bfa_tskim_cleanup_ios(tskim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3044) 			return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3045) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3046) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3047) 		if (!bfa_tskim_send(tskim)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3048) 			bfa_sm_set_state(tskim, bfa_tskim_sm_qfull);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3049) 			bfa_stats(tskim->itnim, tm_qwait);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3050) 			bfa_reqq_wait(tskim->bfa, tskim->itnim->reqq,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3051) 					  &tskim->reqq_wait);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3052) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3053) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3054) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3055) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3056) 		bfa_sm_fault(tskim->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3057) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3058) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3059) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3060) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3061)  * TM command is active, awaiting completion from firmware to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3062)  * cleanup IO requests in TM scope.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3063)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3064) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3065) bfa_tskim_sm_active(struct bfa_tskim_s *tskim, enum bfa_tskim_event event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3066) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3067) 	bfa_trc(tskim->bfa, tskim->tsk_tag << 16 | event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3068) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3069) 	switch (event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3070) 	case BFA_TSKIM_SM_DONE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3071) 		bfa_sm_set_state(tskim, bfa_tskim_sm_iocleanup);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3072) 		bfa_tskim_cleanup_ios(tskim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3073) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3074) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3075) 	case BFA_TSKIM_SM_CLEANUP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3076) 		bfa_sm_set_state(tskim, bfa_tskim_sm_cleanup);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3077) 		if (!bfa_tskim_send_abort(tskim)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3078) 			bfa_sm_set_state(tskim, bfa_tskim_sm_cleanup_qfull);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3079) 			bfa_stats(tskim->itnim, tm_qwait);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3080) 			bfa_reqq_wait(tskim->bfa, tskim->itnim->reqq,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3081) 				&tskim->reqq_wait);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3082) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3083) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3084) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3085) 	case BFA_TSKIM_SM_HWFAIL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3086) 		bfa_sm_set_state(tskim, bfa_tskim_sm_hcb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3087) 		bfa_tskim_iocdisable_ios(tskim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3088) 		bfa_tskim_qcomp(tskim, __bfa_cb_tskim_failed);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3089) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3090) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3091) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3092) 		bfa_sm_fault(tskim->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3093) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3094) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3095) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3096) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3097)  * An active TM is being cleaned up since ITN is offline. Awaiting cleanup
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3098)  * completion event from firmware.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3099)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3100) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3101) bfa_tskim_sm_cleanup(struct bfa_tskim_s *tskim, enum bfa_tskim_event event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3102) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3103) 	bfa_trc(tskim->bfa, tskim->tsk_tag << 16 | event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3104) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3105) 	switch (event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3106) 	case BFA_TSKIM_SM_DONE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3107) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3108) 		 * Ignore and wait for ABORT completion from firmware.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3109) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3110) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3111) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3112) 	case BFA_TSKIM_SM_UTAG:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3113) 	case BFA_TSKIM_SM_CLEANUP_DONE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3114) 		bfa_sm_set_state(tskim, bfa_tskim_sm_iocleanup);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3115) 		bfa_tskim_cleanup_ios(tskim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3116) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3117) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3118) 	case BFA_TSKIM_SM_HWFAIL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3119) 		bfa_sm_set_state(tskim, bfa_tskim_sm_hcb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3120) 		bfa_tskim_iocdisable_ios(tskim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3121) 		bfa_tskim_qcomp(tskim, __bfa_cb_tskim_failed);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3122) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3123) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3124) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3125) 		bfa_sm_fault(tskim->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3126) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3127) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3128) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3129) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3130) bfa_tskim_sm_iocleanup(struct bfa_tskim_s *tskim, enum bfa_tskim_event event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3131) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3132) 	bfa_trc(tskim->bfa, tskim->tsk_tag << 16 | event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3133) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3134) 	switch (event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3135) 	case BFA_TSKIM_SM_IOS_DONE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3136) 		bfa_sm_set_state(tskim, bfa_tskim_sm_hcb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3137) 		bfa_tskim_qcomp(tskim, __bfa_cb_tskim_done);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3138) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3139) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3140) 	case BFA_TSKIM_SM_CLEANUP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3141) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3142) 		 * Ignore, TM command completed on wire.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3143) 		 * Notify TM conmpletion on IO cleanup completion.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3144) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3145) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3146) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3147) 	case BFA_TSKIM_SM_HWFAIL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3148) 		bfa_sm_set_state(tskim, bfa_tskim_sm_hcb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3149) 		bfa_tskim_iocdisable_ios(tskim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3150) 		bfa_tskim_qcomp(tskim, __bfa_cb_tskim_failed);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3151) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3152) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3153) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3154) 		bfa_sm_fault(tskim->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3155) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3156) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3157) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3158) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3159)  * Task management command is waiting for room in request CQ
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3160)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3161) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3162) bfa_tskim_sm_qfull(struct bfa_tskim_s *tskim, enum bfa_tskim_event event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3163) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3164) 	bfa_trc(tskim->bfa, tskim->tsk_tag << 16 | event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3165) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3166) 	switch (event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3167) 	case BFA_TSKIM_SM_QRESUME:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3168) 		bfa_sm_set_state(tskim, bfa_tskim_sm_active);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3169) 		bfa_tskim_send(tskim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3170) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3171) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3172) 	case BFA_TSKIM_SM_CLEANUP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3173) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3174) 		 * No need to send TM on wire since ITN is offline.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3175) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3176) 		bfa_sm_set_state(tskim, bfa_tskim_sm_iocleanup);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3177) 		bfa_reqq_wcancel(&tskim->reqq_wait);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3178) 		bfa_tskim_cleanup_ios(tskim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3179) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3180) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3181) 	case BFA_TSKIM_SM_HWFAIL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3182) 		bfa_sm_set_state(tskim, bfa_tskim_sm_hcb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3183) 		bfa_reqq_wcancel(&tskim->reqq_wait);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3184) 		bfa_tskim_iocdisable_ios(tskim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3185) 		bfa_tskim_qcomp(tskim, __bfa_cb_tskim_failed);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3186) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3187) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3188) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3189) 		bfa_sm_fault(tskim->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3190) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3191) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3192) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3193) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3194)  * Task management command is active, awaiting for room in request CQ
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3195)  * to send clean up request.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3196)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3197) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3198) bfa_tskim_sm_cleanup_qfull(struct bfa_tskim_s *tskim,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3199) 		enum bfa_tskim_event event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3200) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3201) 	bfa_trc(tskim->bfa, tskim->tsk_tag << 16 | event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3202) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3203) 	switch (event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3204) 	case BFA_TSKIM_SM_DONE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3205) 		bfa_reqq_wcancel(&tskim->reqq_wait);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3206) 		fallthrough;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3207) 	case BFA_TSKIM_SM_QRESUME:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3208) 		bfa_sm_set_state(tskim, bfa_tskim_sm_cleanup);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3209) 		bfa_tskim_send_abort(tskim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3210) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3211) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3212) 	case BFA_TSKIM_SM_HWFAIL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3213) 		bfa_sm_set_state(tskim, bfa_tskim_sm_hcb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3214) 		bfa_reqq_wcancel(&tskim->reqq_wait);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3215) 		bfa_tskim_iocdisable_ios(tskim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3216) 		bfa_tskim_qcomp(tskim, __bfa_cb_tskim_failed);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3217) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3218) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3219) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3220) 		bfa_sm_fault(tskim->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3221) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3222) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3223) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3224) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3225)  * BFA callback is pending
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3226)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3227) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3228) bfa_tskim_sm_hcb(struct bfa_tskim_s *tskim, enum bfa_tskim_event event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3229) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3230) 	bfa_trc(tskim->bfa, tskim->tsk_tag << 16 | event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3231) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3232) 	switch (event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3233) 	case BFA_TSKIM_SM_HCB:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3234) 		bfa_sm_set_state(tskim, bfa_tskim_sm_uninit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3235) 		bfa_tskim_free(tskim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3236) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3237) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3238) 	case BFA_TSKIM_SM_CLEANUP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3239) 		bfa_tskim_notify_comp(tskim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3240) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3241) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3242) 	case BFA_TSKIM_SM_HWFAIL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3243) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3244) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3245) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3246) 		bfa_sm_fault(tskim->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3247) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3248) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3249) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3250) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3251) __bfa_cb_tskim_done(void *cbarg, bfa_boolean_t complete)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3252) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3253) 	struct bfa_tskim_s *tskim = cbarg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3254) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3255) 	if (!complete) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3256) 		bfa_sm_send_event(tskim, BFA_TSKIM_SM_HCB);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3257) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3258) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3259) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3260) 	bfa_stats(tskim->itnim, tm_success);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3261) 	bfa_cb_tskim_done(tskim->bfa->bfad, tskim->dtsk, tskim->tsk_status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3262) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3263) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3264) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3265) __bfa_cb_tskim_failed(void *cbarg, bfa_boolean_t complete)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3266) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3267) 	struct bfa_tskim_s *tskim = cbarg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3268) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3269) 	if (!complete) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3270) 		bfa_sm_send_event(tskim, BFA_TSKIM_SM_HCB);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3271) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3272) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3273) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3274) 	bfa_stats(tskim->itnim, tm_failures);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3275) 	bfa_cb_tskim_done(tskim->bfa->bfad, tskim->dtsk,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3276) 				BFI_TSKIM_STS_FAILED);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3277) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3278) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3279) static bfa_boolean_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3280) bfa_tskim_match_scope(struct bfa_tskim_s *tskim, struct scsi_lun lun)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3281) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3282) 	switch (tskim->tm_cmnd) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3283) 	case FCP_TM_TARGET_RESET:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3284) 		return BFA_TRUE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3285) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3286) 	case FCP_TM_ABORT_TASK_SET:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3287) 	case FCP_TM_CLEAR_TASK_SET:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3288) 	case FCP_TM_LUN_RESET:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3289) 	case FCP_TM_CLEAR_ACA:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3290) 		return !memcmp(&tskim->lun, &lun, sizeof(lun));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3291) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3292) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3293) 		WARN_ON(1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3294) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3295) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3296) 	return BFA_FALSE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3297) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3298) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3299) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3300)  * Gather affected IO requests and task management commands.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3301)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3302) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3303) bfa_tskim_gather_ios(struct bfa_tskim_s *tskim)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3304) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3305) 	struct bfa_itnim_s *itnim = tskim->itnim;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3306) 	struct bfa_ioim_s *ioim;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3307) 	struct list_head *qe, *qen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3308) 	struct scsi_cmnd *cmnd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3309) 	struct scsi_lun scsilun;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3310) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3311) 	INIT_LIST_HEAD(&tskim->io_q);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3312) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3313) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3314) 	 * Gather any active IO requests first.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3315) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3316) 	list_for_each_safe(qe, qen, &itnim->io_q) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3317) 		ioim = (struct bfa_ioim_s *) qe;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3318) 		cmnd = (struct scsi_cmnd *) ioim->dio;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3319) 		int_to_scsilun(cmnd->device->lun, &scsilun);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3320) 		if (bfa_tskim_match_scope(tskim, scsilun)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3321) 			list_del(&ioim->qe);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3322) 			list_add_tail(&ioim->qe, &tskim->io_q);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3323) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3324) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3325) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3326) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3327) 	 * Failback any pending IO requests immediately.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3328) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3329) 	list_for_each_safe(qe, qen, &itnim->pending_q) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3330) 		ioim = (struct bfa_ioim_s *) qe;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3331) 		cmnd = (struct scsi_cmnd *) ioim->dio;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3332) 		int_to_scsilun(cmnd->device->lun, &scsilun);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3333) 		if (bfa_tskim_match_scope(tskim, scsilun)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3334) 			list_del(&ioim->qe);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3335) 			list_add_tail(&ioim->qe, &ioim->fcpim->ioim_comp_q);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3336) 			bfa_ioim_tov(ioim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3337) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3338) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3339) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3340) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3341) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3342)  * IO cleanup completion
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3343)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3344) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3345) bfa_tskim_cleanp_comp(void *tskim_cbarg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3346) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3347) 	struct bfa_tskim_s *tskim = tskim_cbarg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3348) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3349) 	bfa_stats(tskim->itnim, tm_io_comps);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3350) 	bfa_sm_send_event(tskim, BFA_TSKIM_SM_IOS_DONE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3351) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3352) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3353) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3354)  * Gather affected IO requests and task management commands.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3355)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3356) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3357) bfa_tskim_cleanup_ios(struct bfa_tskim_s *tskim)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3358) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3359) 	struct bfa_ioim_s *ioim;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3360) 	struct list_head	*qe, *qen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3361) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3362) 	bfa_wc_init(&tskim->wc, bfa_tskim_cleanp_comp, tskim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3363) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3364) 	list_for_each_safe(qe, qen, &tskim->io_q) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3365) 		ioim = (struct bfa_ioim_s *) qe;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3366) 		bfa_wc_up(&tskim->wc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3367) 		bfa_ioim_cleanup_tm(ioim, tskim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3368) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3369) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3370) 	bfa_wc_wait(&tskim->wc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3371) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3372) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3373) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3374)  * Send task management request to firmware.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3375)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3376) static bfa_boolean_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3377) bfa_tskim_send(struct bfa_tskim_s *tskim)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3378) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3379) 	struct bfa_itnim_s *itnim = tskim->itnim;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3380) 	struct bfi_tskim_req_s *m;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3381) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3382) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3383) 	 * check for room in queue to send request now
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3384) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3385) 	m = bfa_reqq_next(tskim->bfa, itnim->reqq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3386) 	if (!m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3387) 		return BFA_FALSE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3388) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3389) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3390) 	 * build i/o request message next
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3391) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3392) 	bfi_h2i_set(m->mh, BFI_MC_TSKIM, BFI_TSKIM_H2I_TM_REQ,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3393) 			bfa_fn_lpu(tskim->bfa));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3394) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3395) 	m->tsk_tag = cpu_to_be16(tskim->tsk_tag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3396) 	m->itn_fhdl = tskim->itnim->rport->fw_handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3397) 	m->t_secs = tskim->tsecs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3398) 	m->lun = tskim->lun;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3399) 	m->tm_flags = tskim->tm_cmnd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3400) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3401) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3402) 	 * queue I/O message to firmware
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3403) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3404) 	bfa_reqq_produce(tskim->bfa, itnim->reqq, m->mh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3405) 	return BFA_TRUE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3406) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3407) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3408) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3409)  * Send abort request to cleanup an active TM to firmware.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3410)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3411) static bfa_boolean_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3412) bfa_tskim_send_abort(struct bfa_tskim_s *tskim)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3413) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3414) 	struct bfa_itnim_s	*itnim = tskim->itnim;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3415) 	struct bfi_tskim_abortreq_s	*m;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3416) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3417) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3418) 	 * check for room in queue to send request now
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3419) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3420) 	m = bfa_reqq_next(tskim->bfa, itnim->reqq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3421) 	if (!m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3422) 		return BFA_FALSE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3423) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3424) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3425) 	 * build i/o request message next
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3426) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3427) 	bfi_h2i_set(m->mh, BFI_MC_TSKIM, BFI_TSKIM_H2I_ABORT_REQ,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3428) 			bfa_fn_lpu(tskim->bfa));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3429) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3430) 	m->tsk_tag  = cpu_to_be16(tskim->tsk_tag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3431) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3432) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3433) 	 * queue I/O message to firmware
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3434) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3435) 	bfa_reqq_produce(tskim->bfa, itnim->reqq, m->mh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3436) 	return BFA_TRUE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3437) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3438) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3439) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3440)  * Call to resume task management cmnd waiting for room in request queue.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3441)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3442) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3443) bfa_tskim_qresume(void *cbarg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3444) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3445) 	struct bfa_tskim_s *tskim = cbarg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3446) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3447) 	bfa_stats(tskim->itnim, tm_qresumes);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3448) 	bfa_sm_send_event(tskim, BFA_TSKIM_SM_QRESUME);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3449) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3450) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3451) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3452)  * Cleanup IOs associated with a task mangement command on IOC failures.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3453)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3454) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3455) bfa_tskim_iocdisable_ios(struct bfa_tskim_s *tskim)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3456) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3457) 	struct bfa_ioim_s *ioim;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3458) 	struct list_head	*qe, *qen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3459) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3460) 	list_for_each_safe(qe, qen, &tskim->io_q) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3461) 		ioim = (struct bfa_ioim_s *) qe;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3462) 		bfa_ioim_iocdisable(ioim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3463) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3464) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3465) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3466) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3467)  * Notification on completions from related ioim.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3468)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3469) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3470) bfa_tskim_iodone(struct bfa_tskim_s *tskim)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3471) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3472) 	bfa_wc_down(&tskim->wc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3473) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3474) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3475) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3476)  * Handle IOC h/w failure notification from itnim.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3477)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3478) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3479) bfa_tskim_iocdisable(struct bfa_tskim_s *tskim)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3480) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3481) 	tskim->notify = BFA_FALSE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3482) 	bfa_stats(tskim->itnim, tm_iocdowns);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3483) 	bfa_sm_send_event(tskim, BFA_TSKIM_SM_HWFAIL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3484) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3485) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3486) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3487)  * Cleanup TM command and associated IOs as part of ITNIM offline.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3488)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3489) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3490) bfa_tskim_cleanup(struct bfa_tskim_s *tskim)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3491) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3492) 	tskim->notify = BFA_TRUE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3493) 	bfa_stats(tskim->itnim, tm_cleanups);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3494) 	bfa_sm_send_event(tskim, BFA_TSKIM_SM_CLEANUP);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3495) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3496) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3497) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3498)  * Memory allocation and initialization.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3499)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3500) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3501) bfa_tskim_attach(struct bfa_fcpim_s *fcpim)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3502) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3503) 	struct bfa_tskim_s *tskim;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3504) 	struct bfa_fcp_mod_s	*fcp = fcpim->fcp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3505) 	u16	i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3506) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3507) 	INIT_LIST_HEAD(&fcpim->tskim_free_q);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3508) 	INIT_LIST_HEAD(&fcpim->tskim_unused_q);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3509) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3510) 	tskim = (struct bfa_tskim_s *) bfa_mem_kva_curp(fcp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3511) 	fcpim->tskim_arr = tskim;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3512) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3513) 	for (i = 0; i < fcpim->num_tskim_reqs; i++, tskim++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3514) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3515) 		 * initialize TSKIM
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3516) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3517) 		memset(tskim, 0, sizeof(struct bfa_tskim_s));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3518) 		tskim->tsk_tag = i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3519) 		tskim->bfa	= fcpim->bfa;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3520) 		tskim->fcpim	= fcpim;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3521) 		tskim->notify  = BFA_FALSE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3522) 		bfa_reqq_winit(&tskim->reqq_wait, bfa_tskim_qresume,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3523) 					tskim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3524) 		bfa_sm_set_state(tskim, bfa_tskim_sm_uninit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3525) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3526) 		list_add_tail(&tskim->qe, &fcpim->tskim_free_q);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3527) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3528) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3529) 	bfa_mem_kva_curp(fcp) = (u8 *) tskim;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3530) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3531) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3532) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3533) bfa_tskim_isr(struct bfa_s *bfa, struct bfi_msg_s *m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3534) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3535) 	struct bfa_fcpim_s *fcpim = BFA_FCPIM(bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3536) 	struct bfi_tskim_rsp_s *rsp = (struct bfi_tskim_rsp_s *) m;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3537) 	struct bfa_tskim_s *tskim;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3538) 	u16	tsk_tag = be16_to_cpu(rsp->tsk_tag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3539) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3540) 	tskim = BFA_TSKIM_FROM_TAG(fcpim, tsk_tag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3541) 	WARN_ON(tskim->tsk_tag != tsk_tag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3542) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3543) 	tskim->tsk_status = rsp->tsk_status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3544) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3545) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3546) 	 * Firmware sends BFI_TSKIM_STS_ABORTED status for abort
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3547) 	 * requests. All other statuses are for normal completions.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3548) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3549) 	if (rsp->tsk_status == BFI_TSKIM_STS_ABORTED) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3550) 		bfa_stats(tskim->itnim, tm_cleanup_comps);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3551) 		bfa_sm_send_event(tskim, BFA_TSKIM_SM_CLEANUP_DONE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3552) 	} else if (rsp->tsk_status == BFI_TSKIM_STS_UTAG) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3553) 		bfa_sm_send_event(tskim, BFA_TSKIM_SM_UTAG);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3554) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3555) 		bfa_stats(tskim->itnim, tm_fw_rsps);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3556) 		bfa_sm_send_event(tskim, BFA_TSKIM_SM_DONE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3557) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3558) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3559) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3560) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3561) struct bfa_tskim_s *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3562) bfa_tskim_alloc(struct bfa_s *bfa, struct bfad_tskim_s *dtsk)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3563) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3564) 	struct bfa_fcpim_s *fcpim = BFA_FCPIM(bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3565) 	struct bfa_tskim_s *tskim;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3566) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3567) 	bfa_q_deq(&fcpim->tskim_free_q, &tskim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3568) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3569) 	if (tskim)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3570) 		tskim->dtsk = dtsk;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3571) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3572) 	return tskim;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3573) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3574) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3575) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3576) bfa_tskim_free(struct bfa_tskim_s *tskim)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3577) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3578) 	WARN_ON(!bfa_q_is_on_q_func(&tskim->itnim->tsk_q, &tskim->qe));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3579) 	list_del(&tskim->qe);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3580) 	list_add_tail(&tskim->qe, &tskim->fcpim->tskim_free_q);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3581) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3582) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3583) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3584)  * Start a task management command.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3585)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3586)  * @param[in]	tskim	BFA task management command instance
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3587)  * @param[in]	itnim	i-t nexus for the task management command
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3588)  * @param[in]	lun	lun, if applicable
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3589)  * @param[in]	tm_cmnd	Task management command code.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3590)  * @param[in]	t_secs	Timeout in seconds
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3591)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3592)  * @return None.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3593)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3594) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3595) bfa_tskim_start(struct bfa_tskim_s *tskim, struct bfa_itnim_s *itnim,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3596) 			struct scsi_lun lun,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3597) 			enum fcp_tm_cmnd tm_cmnd, u8 tsecs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3598) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3599) 	tskim->itnim	= itnim;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3600) 	tskim->lun	= lun;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3601) 	tskim->tm_cmnd = tm_cmnd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3602) 	tskim->tsecs	= tsecs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3603) 	tskim->notify  = BFA_FALSE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3604) 	bfa_stats(itnim, tm_cmnds);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3605) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3606) 	list_add_tail(&tskim->qe, &itnim->tsk_q);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3607) 	bfa_sm_send_event(tskim, BFA_TSKIM_SM_START);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3608) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3609) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3610) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3611) bfa_tskim_res_recfg(struct bfa_s *bfa, u16 num_tskim_fw)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3612) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3613) 	struct bfa_fcpim_s	*fcpim = BFA_FCPIM(bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3614) 	struct list_head	*qe;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3615) 	int	i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3616) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3617) 	for (i = 0; i < (fcpim->num_tskim_reqs - num_tskim_fw); i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3618) 		bfa_q_deq_tail(&fcpim->tskim_free_q, &qe);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3619) 		list_add_tail(qe, &fcpim->tskim_unused_q);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3620) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3621) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3622) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3623) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3624) bfa_fcp_meminfo(struct bfa_iocfc_cfg_s *cfg, struct bfa_meminfo_s *minfo,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3625) 		struct bfa_s *bfa)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3626) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3627) 	struct bfa_fcp_mod_s *fcp = BFA_FCP_MOD(bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3628) 	struct bfa_mem_kva_s *fcp_kva = BFA_MEM_FCP_KVA(bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3629) 	struct bfa_mem_dma_s *seg_ptr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3630) 	u16	nsegs, idx, per_seg_ios, num_io_req;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3631) 	u32	km_len = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3632) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3633) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3634) 	 * ZERO for num_ioim_reqs and num_fwtio_reqs is allowed config value.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3635) 	 * So if the values are non zero, adjust them appropriately.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3636) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3637) 	if (cfg->fwcfg.num_ioim_reqs &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3638) 	    cfg->fwcfg.num_ioim_reqs < BFA_IOIM_MIN)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3639) 		cfg->fwcfg.num_ioim_reqs = BFA_IOIM_MIN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3640) 	else if (cfg->fwcfg.num_ioim_reqs > BFA_IOIM_MAX)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3641) 		cfg->fwcfg.num_ioim_reqs = BFA_IOIM_MAX;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3642) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3643) 	if (cfg->fwcfg.num_fwtio_reqs > BFA_FWTIO_MAX)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3644) 		cfg->fwcfg.num_fwtio_reqs = BFA_FWTIO_MAX;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3645) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3646) 	num_io_req = (cfg->fwcfg.num_ioim_reqs + cfg->fwcfg.num_fwtio_reqs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3647) 	if (num_io_req > BFA_IO_MAX) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3648) 		if (cfg->fwcfg.num_ioim_reqs && cfg->fwcfg.num_fwtio_reqs) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3649) 			cfg->fwcfg.num_ioim_reqs = BFA_IO_MAX/2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3650) 			cfg->fwcfg.num_fwtio_reqs = BFA_IO_MAX/2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3651) 		} else if (cfg->fwcfg.num_fwtio_reqs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3652) 			cfg->fwcfg.num_fwtio_reqs = BFA_FWTIO_MAX;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3653) 		else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3654) 			cfg->fwcfg.num_ioim_reqs = BFA_IOIM_MAX;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3655) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3656) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3657) 	bfa_fcpim_meminfo(cfg, &km_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3658) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3659) 	num_io_req = (cfg->fwcfg.num_ioim_reqs + cfg->fwcfg.num_fwtio_reqs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3660) 	km_len += num_io_req * sizeof(struct bfa_iotag_s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3661) 	km_len += cfg->fwcfg.num_rports * sizeof(struct bfa_itn_s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3662) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3663) 	/* dma memory */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3664) 	nsegs = BFI_MEM_DMA_NSEGS(num_io_req, BFI_IOIM_SNSLEN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3665) 	per_seg_ios = BFI_MEM_NREQS_SEG(BFI_IOIM_SNSLEN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3666) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3667) 	bfa_mem_dma_seg_iter(fcp, seg_ptr, nsegs, idx) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3668) 		if (num_io_req >= per_seg_ios) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3669) 			num_io_req -= per_seg_ios;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3670) 			bfa_mem_dma_setup(minfo, seg_ptr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3671) 				per_seg_ios * BFI_IOIM_SNSLEN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3672) 		} else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3673) 			bfa_mem_dma_setup(minfo, seg_ptr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3674) 				num_io_req * BFI_IOIM_SNSLEN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3675) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3676) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3677) 	/* kva memory */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3678) 	bfa_mem_kva_setup(minfo, fcp_kva, km_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3679) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3680) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3681) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3682) bfa_fcp_attach(struct bfa_s *bfa, void *bfad, struct bfa_iocfc_cfg_s *cfg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3683) 		struct bfa_pcidev_s *pcidev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3684) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3685) 	struct bfa_fcp_mod_s *fcp = BFA_FCP_MOD(bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3686) 	struct bfa_mem_dma_s *seg_ptr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3687) 	u16	idx, nsegs, num_io_req;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3688) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3689) 	fcp->max_ioim_reqs = cfg->fwcfg.num_ioim_reqs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3690) 	fcp->num_ioim_reqs = cfg->fwcfg.num_ioim_reqs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3691) 	fcp->num_fwtio_reqs  = cfg->fwcfg.num_fwtio_reqs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3692) 	fcp->num_itns   = cfg->fwcfg.num_rports;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3693) 	fcp->bfa = bfa;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3694) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3695) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3696) 	 * Setup the pool of snsbase addr's, that is passed to fw as
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3697) 	 * part of bfi_iocfc_cfg_s.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3698) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3699) 	num_io_req = (cfg->fwcfg.num_ioim_reqs + cfg->fwcfg.num_fwtio_reqs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3700) 	nsegs = BFI_MEM_DMA_NSEGS(num_io_req, BFI_IOIM_SNSLEN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3701) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3702) 	bfa_mem_dma_seg_iter(fcp, seg_ptr, nsegs, idx) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3703) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3704) 		if (!bfa_mem_dma_virt(seg_ptr))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3705) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3706) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3707) 		fcp->snsbase[idx].pa = bfa_mem_dma_phys(seg_ptr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3708) 		fcp->snsbase[idx].kva = bfa_mem_dma_virt(seg_ptr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3709) 		bfa_iocfc_set_snsbase(bfa, idx, fcp->snsbase[idx].pa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3710) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3711) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3712) 	fcp->throttle_update_required = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3713) 	bfa_fcpim_attach(fcp, bfad, cfg, pcidev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3714) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3715) 	bfa_iotag_attach(fcp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3716) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3717) 	fcp->itn_arr = (struct bfa_itn_s *) bfa_mem_kva_curp(fcp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3718) 	bfa_mem_kva_curp(fcp) = (u8 *)fcp->itn_arr +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3719) 			(fcp->num_itns * sizeof(struct bfa_itn_s));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3720) 	memset(fcp->itn_arr, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3721) 			(fcp->num_itns * sizeof(struct bfa_itn_s)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3722) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3723) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3724) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3725) bfa_fcp_iocdisable(struct bfa_s *bfa)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3726) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3727) 	struct bfa_fcp_mod_s *fcp = BFA_FCP_MOD(bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3728) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3729) 	bfa_fcpim_iocdisable(fcp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3730) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3731) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3732) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3733) bfa_fcp_res_recfg(struct bfa_s *bfa, u16 num_ioim_fw, u16 max_ioim_fw)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3734) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3735) 	struct bfa_fcp_mod_s	*mod = BFA_FCP_MOD(bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3736) 	struct list_head	*qe;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3737) 	int	i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3738) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3739) 	/* Update io throttle value only once during driver load time */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3740) 	if (!mod->throttle_update_required)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3741) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3742) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3743) 	for (i = 0; i < (mod->num_ioim_reqs - num_ioim_fw); i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3744) 		bfa_q_deq_tail(&mod->iotag_ioim_free_q, &qe);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3745) 		list_add_tail(qe, &mod->iotag_unused_q);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3746) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3747) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3748) 	if (mod->num_ioim_reqs != num_ioim_fw) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3749) 		bfa_trc(bfa, mod->num_ioim_reqs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3750) 		bfa_trc(bfa, num_ioim_fw);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3751) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3752) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3753) 	mod->max_ioim_reqs = max_ioim_fw;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3754) 	mod->num_ioim_reqs = num_ioim_fw;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3755) 	mod->throttle_update_required = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3756) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3757) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3758) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3759) bfa_itn_create(struct bfa_s *bfa, struct bfa_rport_s *rport,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3760) 		void (*isr)(struct bfa_s *bfa, struct bfi_msg_s *m))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3761) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3762) 	struct bfa_fcp_mod_s *fcp = BFA_FCP_MOD(bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3763) 	struct bfa_itn_s *itn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3764) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3765) 	itn =  BFA_ITN_FROM_TAG(fcp, rport->rport_tag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3766) 	itn->isr = isr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3767) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3768) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3769) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3770)  * Itn interrupt processing.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3771)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3772) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3773) bfa_itn_isr(struct bfa_s *bfa, struct bfi_msg_s *m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3774) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3775) 	struct bfa_fcp_mod_s *fcp = BFA_FCP_MOD(bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3776) 	union bfi_itn_i2h_msg_u msg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3777) 	struct bfa_itn_s *itn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3778) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3779) 	msg.msg = m;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3780) 	itn =  BFA_ITN_FROM_TAG(fcp, msg.create_rsp->bfa_handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3781) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3782) 	if (itn->isr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3783) 		itn->isr(bfa, m);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3784) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3785) 		WARN_ON(1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3786) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3787) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3788) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3789) bfa_iotag_attach(struct bfa_fcp_mod_s *fcp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3790) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3791) 	struct bfa_iotag_s *iotag;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3792) 	u16	num_io_req, i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3793) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3794) 	iotag = (struct bfa_iotag_s *) bfa_mem_kva_curp(fcp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3795) 	fcp->iotag_arr = iotag;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3796) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3797) 	INIT_LIST_HEAD(&fcp->iotag_ioim_free_q);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3798) 	INIT_LIST_HEAD(&fcp->iotag_tio_free_q);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3799) 	INIT_LIST_HEAD(&fcp->iotag_unused_q);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3800) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3801) 	num_io_req = fcp->num_ioim_reqs + fcp->num_fwtio_reqs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3802) 	for (i = 0; i < num_io_req; i++, iotag++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3803) 		memset(iotag, 0, sizeof(struct bfa_iotag_s));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3804) 		iotag->tag = i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3805) 		if (i < fcp->num_ioim_reqs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3806) 			list_add_tail(&iotag->qe, &fcp->iotag_ioim_free_q);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3807) 		else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3808) 			list_add_tail(&iotag->qe, &fcp->iotag_tio_free_q);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3809) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3810) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3811) 	bfa_mem_kva_curp(fcp) = (u8 *) iotag;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3812) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3813) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3814) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3815) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3816)  * To send config req, first try to use throttle value from flash
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3817)  * If 0, then use driver parameter
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3818)  * We need to use min(flash_val, drv_val) because
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3819)  * memory allocation was done based on this cfg'd value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3820)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3821) u16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3822) bfa_fcpim_get_throttle_cfg(struct bfa_s *bfa, u16 drv_cfg_param)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3823) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3824) 	u16 tmp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3825) 	struct bfa_fcp_mod_s *fcp = BFA_FCP_MOD(bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3826) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3827) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3828) 	 * If throttle value from flash is already in effect after driver is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3829) 	 * loaded then until next load, always return current value instead
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3830) 	 * of actual flash value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3831) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3832) 	if (!fcp->throttle_update_required)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3833) 		return (u16)fcp->num_ioim_reqs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3834) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3835) 	tmp = bfa_dconf_read_data_valid(bfa) ? bfa_fcpim_read_throttle(bfa) : 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3836) 	if (!tmp || (tmp > drv_cfg_param))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3837) 		tmp = drv_cfg_param;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3838) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3839) 	return tmp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3840) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3841) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3842) bfa_status_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3843) bfa_fcpim_write_throttle(struct bfa_s *bfa, u16 value)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3844) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3845) 	if (!bfa_dconf_get_min_cfg(bfa)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3846) 		BFA_DCONF_MOD(bfa)->dconf->throttle_cfg.value = value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3847) 		BFA_DCONF_MOD(bfa)->dconf->throttle_cfg.is_valid = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3848) 		return BFA_STATUS_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3849) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3850) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3851) 	return BFA_STATUS_FAILED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3852) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3853) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3854) u16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3855) bfa_fcpim_read_throttle(struct bfa_s *bfa)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3856) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3857) 	struct bfa_throttle_cfg_s *throttle_cfg =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3858) 			&(BFA_DCONF_MOD(bfa)->dconf->throttle_cfg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3859) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3860) 	return ((!bfa_dconf_get_min_cfg(bfa)) ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3861) 	       ((throttle_cfg->is_valid == 1) ? (throttle_cfg->value) : 0) : 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3862) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3863) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3864) bfa_status_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3865) bfa_fcpim_throttle_set(struct bfa_s *bfa, u16 value)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3866) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3867) 	/* in min cfg no commands should run. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3868) 	if ((bfa_dconf_get_min_cfg(bfa) == BFA_TRUE) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3869) 	    (!bfa_dconf_read_data_valid(bfa)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3870) 		return BFA_STATUS_FAILED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3871) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3872) 	bfa_fcpim_write_throttle(bfa, value);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3873) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3874) 	return bfa_dconf_update(bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3875) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3876) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3877) bfa_status_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3878) bfa_fcpim_throttle_get(struct bfa_s *bfa, void *buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3879) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3880) 	struct bfa_fcpim_s *fcpim = BFA_FCPIM(bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3881) 	struct bfa_defs_fcpim_throttle_s throttle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3882) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3883) 	if ((bfa_dconf_get_min_cfg(bfa) == BFA_TRUE) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3884) 	    (!bfa_dconf_read_data_valid(bfa)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3885) 		return BFA_STATUS_FAILED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3886) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3887) 	memset(&throttle, 0, sizeof(struct bfa_defs_fcpim_throttle_s));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3888) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3889) 	throttle.cur_value = (u16)(fcpim->fcp->num_ioim_reqs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3890) 	throttle.cfg_value = bfa_fcpim_read_throttle(bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3891) 	if (!throttle.cfg_value)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3892) 		throttle.cfg_value = throttle.cur_value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3893) 	throttle.max_value = (u16)(fcpim->fcp->max_ioim_reqs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3894) 	memcpy(buf, &throttle, sizeof(struct bfa_defs_fcpim_throttle_s));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3895) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3896) 	return BFA_STATUS_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3897) }