^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 "bfad_im.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include "bfa_plog.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include "bfa_cs.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include "bfa_modules.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) BFA_TRC_FILE(HAL, FCXP);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) * LPS related definitions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) #define BFA_LPS_MIN_LPORTS (1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) #define BFA_LPS_MAX_LPORTS (256)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) * Maximum Vports supported per physical port or vf.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) #define BFA_LPS_MAX_VPORTS_SUPP_CB 255
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) #define BFA_LPS_MAX_VPORTS_SUPP_CT 190
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) * FC PORT related definitions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) * The port is considered disabled if corresponding physical port or IOC are
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) * disabled explicitly
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) #define BFA_PORT_IS_DISABLED(bfa) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) ((bfa_fcport_is_disabled(bfa) == BFA_TRUE) || \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) (bfa_ioc_is_disabled(&bfa->ioc) == BFA_TRUE))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) * BFA port state machine events
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) enum bfa_fcport_sm_event {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) BFA_FCPORT_SM_START = 1, /* start port state machine */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) BFA_FCPORT_SM_STOP = 2, /* stop port state machine */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) BFA_FCPORT_SM_ENABLE = 3, /* enable port */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) BFA_FCPORT_SM_DISABLE = 4, /* disable port state machine */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) BFA_FCPORT_SM_FWRSP = 5, /* firmware enable/disable rsp */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) BFA_FCPORT_SM_LINKUP = 6, /* firmware linkup event */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) BFA_FCPORT_SM_LINKDOWN = 7, /* firmware linkup down */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) BFA_FCPORT_SM_QRESUME = 8, /* CQ space available */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) BFA_FCPORT_SM_HWFAIL = 9, /* IOC h/w failure */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) BFA_FCPORT_SM_DPORTENABLE = 10, /* enable dport */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) BFA_FCPORT_SM_DPORTDISABLE = 11,/* disable dport */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) BFA_FCPORT_SM_FAA_MISCONFIG = 12, /* FAA misconfiguratin */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) BFA_FCPORT_SM_DDPORTENABLE = 13, /* enable ddport */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) BFA_FCPORT_SM_DDPORTDISABLE = 14, /* disable ddport */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) * BFA port link notification state machine events
^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) enum bfa_fcport_ln_sm_event {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) BFA_FCPORT_LN_SM_LINKUP = 1, /* linkup event */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) BFA_FCPORT_LN_SM_LINKDOWN = 2, /* linkdown event */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) BFA_FCPORT_LN_SM_NOTIFICATION = 3 /* done notification */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) * RPORT related definitions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) #define bfa_rport_offline_cb(__rp) do { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) if ((__rp)->bfa->fcs) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) bfa_cb_rport_offline((__rp)->rport_drv); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) else { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) bfa_cb_queue((__rp)->bfa, &(__rp)->hcb_qe, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) __bfa_cb_rport_offline, (__rp)); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) } \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) } while (0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) #define bfa_rport_online_cb(__rp) do { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) if ((__rp)->bfa->fcs) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) bfa_cb_rport_online((__rp)->rport_drv); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) else { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) bfa_cb_queue((__rp)->bfa, &(__rp)->hcb_qe, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) __bfa_cb_rport_online, (__rp)); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) } \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) } while (0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) * forward declarations FCXP related functions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) static void __bfa_fcxp_send_cbfn(void *cbarg, bfa_boolean_t complete);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) static void hal_fcxp_rx_plog(struct bfa_s *bfa, struct bfa_fcxp_s *fcxp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) struct bfi_fcxp_send_rsp_s *fcxp_rsp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) static void hal_fcxp_tx_plog(struct bfa_s *bfa, u32 reqlen,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) struct bfa_fcxp_s *fcxp, struct fchs_s *fchs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) static void bfa_fcxp_qresume(void *cbarg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) static void bfa_fcxp_queue(struct bfa_fcxp_s *fcxp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) struct bfi_fcxp_send_req_s *send_req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) * forward declarations for LPS functions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) static void bfa_lps_login_rsp(struct bfa_s *bfa,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) struct bfi_lps_login_rsp_s *rsp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) static void bfa_lps_no_res(struct bfa_lps_s *first_lps, u8 count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) static void bfa_lps_logout_rsp(struct bfa_s *bfa,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) struct bfi_lps_logout_rsp_s *rsp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) static void bfa_lps_reqq_resume(void *lps_arg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) static void bfa_lps_free(struct bfa_lps_s *lps);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) static void bfa_lps_send_login(struct bfa_lps_s *lps);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) static void bfa_lps_send_logout(struct bfa_lps_s *lps);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) static void bfa_lps_send_set_n2n_pid(struct bfa_lps_s *lps);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) static void bfa_lps_login_comp(struct bfa_lps_s *lps);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) static void bfa_lps_logout_comp(struct bfa_lps_s *lps);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) static void bfa_lps_cvl_event(struct bfa_lps_s *lps);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) * forward declaration for LPS state machine
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) static void bfa_lps_sm_init(struct bfa_lps_s *lps, enum bfa_lps_event event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) static void bfa_lps_sm_login(struct bfa_lps_s *lps, enum bfa_lps_event event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) static void bfa_lps_sm_loginwait(struct bfa_lps_s *lps, enum bfa_lps_event
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) static void bfa_lps_sm_online(struct bfa_lps_s *lps, enum bfa_lps_event event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) static void bfa_lps_sm_online_n2n_pid_wait(struct bfa_lps_s *lps,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) enum bfa_lps_event event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) static void bfa_lps_sm_logout(struct bfa_lps_s *lps, enum bfa_lps_event event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) static void bfa_lps_sm_logowait(struct bfa_lps_s *lps, enum bfa_lps_event
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) * forward declaration for FC Port functions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) static bfa_boolean_t bfa_fcport_send_enable(struct bfa_fcport_s *fcport);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) static bfa_boolean_t bfa_fcport_send_disable(struct bfa_fcport_s *fcport);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) static void bfa_fcport_update_linkinfo(struct bfa_fcport_s *fcport);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) static void bfa_fcport_reset_linkinfo(struct bfa_fcport_s *fcport);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) static void bfa_fcport_set_wwns(struct bfa_fcport_s *fcport);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) static void __bfa_cb_fcport_event(void *cbarg, bfa_boolean_t complete);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) static void bfa_fcport_scn(struct bfa_fcport_s *fcport,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) enum bfa_port_linkstate event, bfa_boolean_t trunk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) static void bfa_fcport_queue_cb(struct bfa_fcport_ln_s *ln,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) enum bfa_port_linkstate event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) static void __bfa_cb_fcport_stats_clr(void *cbarg, bfa_boolean_t complete);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) static void bfa_fcport_stats_get_timeout(void *cbarg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) static void bfa_fcport_stats_clr_timeout(void *cbarg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) static void bfa_trunk_iocdisable(struct bfa_s *bfa);
^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) * forward declaration for FC PORT state machine
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) static void bfa_fcport_sm_uninit(struct bfa_fcport_s *fcport,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) enum bfa_fcport_sm_event event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) static void bfa_fcport_sm_enabling_qwait(struct bfa_fcport_s *fcport,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) enum bfa_fcport_sm_event event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) static void bfa_fcport_sm_enabling(struct bfa_fcport_s *fcport,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) enum bfa_fcport_sm_event event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) static void bfa_fcport_sm_linkdown(struct bfa_fcport_s *fcport,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) enum bfa_fcport_sm_event event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) static void bfa_fcport_sm_linkup(struct bfa_fcport_s *fcport,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) enum bfa_fcport_sm_event event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) static void bfa_fcport_sm_disabling(struct bfa_fcport_s *fcport,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) enum bfa_fcport_sm_event event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) static void bfa_fcport_sm_disabling_qwait(struct bfa_fcport_s *fcport,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) enum bfa_fcport_sm_event event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) static void bfa_fcport_sm_toggling_qwait(struct bfa_fcport_s *fcport,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) enum bfa_fcport_sm_event event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) static void bfa_fcport_sm_disabled(struct bfa_fcport_s *fcport,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) enum bfa_fcport_sm_event event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) static void bfa_fcport_sm_stopped(struct bfa_fcport_s *fcport,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) enum bfa_fcport_sm_event event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) static void bfa_fcport_sm_iocdown(struct bfa_fcport_s *fcport,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) enum bfa_fcport_sm_event event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) static void bfa_fcport_sm_iocfail(struct bfa_fcport_s *fcport,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) enum bfa_fcport_sm_event event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) static void bfa_fcport_sm_dport(struct bfa_fcport_s *fcport,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) enum bfa_fcport_sm_event event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) static void bfa_fcport_sm_ddport(struct bfa_fcport_s *fcport,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) enum bfa_fcport_sm_event event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) static void bfa_fcport_sm_faa_misconfig(struct bfa_fcport_s *fcport,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) enum bfa_fcport_sm_event event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) static void bfa_fcport_ln_sm_dn(struct bfa_fcport_ln_s *ln,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) enum bfa_fcport_ln_sm_event event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) static void bfa_fcport_ln_sm_dn_nf(struct bfa_fcport_ln_s *ln,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) enum bfa_fcport_ln_sm_event event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) static void bfa_fcport_ln_sm_dn_up_nf(struct bfa_fcport_ln_s *ln,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) enum bfa_fcport_ln_sm_event event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) static void bfa_fcport_ln_sm_up(struct bfa_fcport_ln_s *ln,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) enum bfa_fcport_ln_sm_event event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) static void bfa_fcport_ln_sm_up_nf(struct bfa_fcport_ln_s *ln,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) enum bfa_fcport_ln_sm_event event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) static void bfa_fcport_ln_sm_up_dn_nf(struct bfa_fcport_ln_s *ln,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) enum bfa_fcport_ln_sm_event event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) static void bfa_fcport_ln_sm_up_dn_up_nf(struct bfa_fcport_ln_s *ln,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) enum bfa_fcport_ln_sm_event event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) static struct bfa_sm_table_s hal_port_sm_table[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) {BFA_SM(bfa_fcport_sm_uninit), BFA_PORT_ST_UNINIT},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) {BFA_SM(bfa_fcport_sm_enabling_qwait), BFA_PORT_ST_ENABLING_QWAIT},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) {BFA_SM(bfa_fcport_sm_enabling), BFA_PORT_ST_ENABLING},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) {BFA_SM(bfa_fcport_sm_linkdown), BFA_PORT_ST_LINKDOWN},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) {BFA_SM(bfa_fcport_sm_linkup), BFA_PORT_ST_LINKUP},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) {BFA_SM(bfa_fcport_sm_disabling_qwait), BFA_PORT_ST_DISABLING_QWAIT},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) {BFA_SM(bfa_fcport_sm_toggling_qwait), BFA_PORT_ST_TOGGLING_QWAIT},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) {BFA_SM(bfa_fcport_sm_disabling), BFA_PORT_ST_DISABLING},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) {BFA_SM(bfa_fcport_sm_disabled), BFA_PORT_ST_DISABLED},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) {BFA_SM(bfa_fcport_sm_stopped), BFA_PORT_ST_STOPPED},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) {BFA_SM(bfa_fcport_sm_iocdown), BFA_PORT_ST_IOCDOWN},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) {BFA_SM(bfa_fcport_sm_iocfail), BFA_PORT_ST_IOCDOWN},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) {BFA_SM(bfa_fcport_sm_dport), BFA_PORT_ST_DPORT},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) {BFA_SM(bfa_fcport_sm_ddport), BFA_PORT_ST_DDPORT},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) {BFA_SM(bfa_fcport_sm_faa_misconfig), BFA_PORT_ST_FAA_MISCONFIG},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) };
^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) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) * forward declaration for RPORT related functions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) static struct bfa_rport_s *bfa_rport_alloc(struct bfa_rport_mod_s *rp_mod);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) static void bfa_rport_free(struct bfa_rport_s *rport);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) static bfa_boolean_t bfa_rport_send_fwcreate(struct bfa_rport_s *rp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) static bfa_boolean_t bfa_rport_send_fwdelete(struct bfa_rport_s *rp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) static bfa_boolean_t bfa_rport_send_fwspeed(struct bfa_rport_s *rp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) static void __bfa_cb_rport_online(void *cbarg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) bfa_boolean_t complete);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) static void __bfa_cb_rport_offline(void *cbarg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) bfa_boolean_t complete);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) * forward declaration for RPORT state machine
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) static void bfa_rport_sm_uninit(struct bfa_rport_s *rp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) enum bfa_rport_event event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) static void bfa_rport_sm_created(struct bfa_rport_s *rp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) enum bfa_rport_event event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) static void bfa_rport_sm_fwcreate(struct bfa_rport_s *rp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) enum bfa_rport_event event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) static void bfa_rport_sm_online(struct bfa_rport_s *rp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) enum bfa_rport_event event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) static void bfa_rport_sm_fwdelete(struct bfa_rport_s *rp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) enum bfa_rport_event event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) static void bfa_rport_sm_offline(struct bfa_rport_s *rp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) enum bfa_rport_event event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) static void bfa_rport_sm_deleting(struct bfa_rport_s *rp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) enum bfa_rport_event event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) static void bfa_rport_sm_offline_pending(struct bfa_rport_s *rp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) enum bfa_rport_event event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) static void bfa_rport_sm_delete_pending(struct bfa_rport_s *rp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) enum bfa_rport_event event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) static void bfa_rport_sm_iocdisable(struct bfa_rport_s *rp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) enum bfa_rport_event event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) static void bfa_rport_sm_fwcreate_qfull(struct bfa_rport_s *rp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) enum bfa_rport_event event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) static void bfa_rport_sm_fwdelete_qfull(struct bfa_rport_s *rp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) enum bfa_rport_event event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) static void bfa_rport_sm_deleting_qfull(struct bfa_rport_s *rp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) enum bfa_rport_event event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) * PLOG related definitions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) plkd_validate_logrec(struct bfa_plog_rec_s *pl_rec)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) if ((pl_rec->log_type != BFA_PL_LOG_TYPE_INT) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) (pl_rec->log_type != BFA_PL_LOG_TYPE_STRING))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) if ((pl_rec->log_type != BFA_PL_LOG_TYPE_INT) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) (pl_rec->log_num_ints > BFA_PL_INT_LOG_SZ))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) bfa_plog_add(struct bfa_plog_s *plog, struct bfa_plog_rec_s *pl_rec)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) u16 tail;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) struct bfa_plog_rec_s *pl_recp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) if (plog->plog_enabled == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) if (plkd_validate_logrec(pl_rec)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) WARN_ON(1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) tail = plog->tail;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) pl_recp = &(plog->plog_recs[tail]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) memcpy(pl_recp, pl_rec, sizeof(struct bfa_plog_rec_s));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) pl_recp->tv = ktime_get_real_seconds();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) BFA_PL_LOG_REC_INCR(plog->tail);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) if (plog->head == plog->tail)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) BFA_PL_LOG_REC_INCR(plog->head);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) bfa_plog_init(struct bfa_plog_s *plog)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) memset((char *)plog, 0, sizeof(struct bfa_plog_s));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) memcpy(plog->plog_sig, BFA_PL_SIG_STR, BFA_PL_SIG_LEN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) plog->head = plog->tail = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) plog->plog_enabled = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) bfa_plog_str(struct bfa_plog_s *plog, enum bfa_plog_mid mid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) enum bfa_plog_eid event,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) u16 misc, char *log_str)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) struct bfa_plog_rec_s lp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) if (plog->plog_enabled) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) memset(&lp, 0, sizeof(struct bfa_plog_rec_s));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) lp.mid = mid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) lp.eid = event;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) lp.log_type = BFA_PL_LOG_TYPE_STRING;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) lp.misc = misc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) strlcpy(lp.log_entry.string_log, log_str,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) BFA_PL_STRING_LOG_SZ);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) lp.log_entry.string_log[BFA_PL_STRING_LOG_SZ - 1] = '\0';
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) bfa_plog_add(plog, &lp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) bfa_plog_intarr(struct bfa_plog_s *plog, enum bfa_plog_mid mid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) enum bfa_plog_eid event,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) u16 misc, u32 *intarr, u32 num_ints)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) struct bfa_plog_rec_s lp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) u32 i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) if (num_ints > BFA_PL_INT_LOG_SZ)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) num_ints = BFA_PL_INT_LOG_SZ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) if (plog->plog_enabled) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) memset(&lp, 0, sizeof(struct bfa_plog_rec_s));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) lp.mid = mid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) lp.eid = event;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) lp.log_type = BFA_PL_LOG_TYPE_INT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) lp.misc = misc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) for (i = 0; i < num_ints; i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) lp.log_entry.int_log[i] = intarr[i];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) lp.log_num_ints = (u8) num_ints;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) bfa_plog_add(plog, &lp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) }
^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) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) bfa_plog_fchdr(struct bfa_plog_s *plog, enum bfa_plog_mid mid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) enum bfa_plog_eid event,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) u16 misc, struct fchs_s *fchdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) struct bfa_plog_rec_s lp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) u32 *tmp_int = (u32 *) fchdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) u32 ints[BFA_PL_INT_LOG_SZ];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) if (plog->plog_enabled) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) memset(&lp, 0, sizeof(struct bfa_plog_rec_s));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) ints[0] = tmp_int[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) ints[1] = tmp_int[1];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) ints[2] = tmp_int[4];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) bfa_plog_intarr(plog, mid, event, misc, ints, 3);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) bfa_plog_fchdr_and_pl(struct bfa_plog_s *plog, enum bfa_plog_mid mid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) enum bfa_plog_eid event, u16 misc, struct fchs_s *fchdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) u32 pld_w0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) struct bfa_plog_rec_s lp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) u32 *tmp_int = (u32 *) fchdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) u32 ints[BFA_PL_INT_LOG_SZ];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) if (plog->plog_enabled) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) memset(&lp, 0, sizeof(struct bfa_plog_rec_s));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) ints[0] = tmp_int[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) ints[1] = tmp_int[1];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) ints[2] = tmp_int[4];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) ints[3] = pld_w0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) bfa_plog_intarr(plog, mid, event, misc, ints, 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) * fcxp_pvt BFA FCXP private functions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) claim_fcxps_mem(struct bfa_fcxp_mod_s *mod)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) u16 i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) struct bfa_fcxp_s *fcxp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) fcxp = (struct bfa_fcxp_s *) bfa_mem_kva_curp(mod);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) memset(fcxp, 0, sizeof(struct bfa_fcxp_s) * mod->num_fcxps);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) INIT_LIST_HEAD(&mod->fcxp_req_free_q);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) INIT_LIST_HEAD(&mod->fcxp_rsp_free_q);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) INIT_LIST_HEAD(&mod->fcxp_active_q);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) INIT_LIST_HEAD(&mod->fcxp_req_unused_q);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) INIT_LIST_HEAD(&mod->fcxp_rsp_unused_q);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) mod->fcxp_list = fcxp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) for (i = 0; i < mod->num_fcxps; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) fcxp->fcxp_mod = mod;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) fcxp->fcxp_tag = i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) if (i < (mod->num_fcxps / 2)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) list_add_tail(&fcxp->qe, &mod->fcxp_req_free_q);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) fcxp->req_rsp = BFA_TRUE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) list_add_tail(&fcxp->qe, &mod->fcxp_rsp_free_q);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) fcxp->req_rsp = BFA_FALSE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) bfa_reqq_winit(&fcxp->reqq_wqe, bfa_fcxp_qresume, fcxp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) fcxp->reqq_waiting = BFA_FALSE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) fcxp = fcxp + 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) bfa_mem_kva_curp(mod) = (void *)fcxp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) bfa_fcxp_meminfo(struct bfa_iocfc_cfg_s *cfg, struct bfa_meminfo_s *minfo,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) struct bfa_s *bfa)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) struct bfa_fcxp_mod_s *fcxp_mod = BFA_FCXP_MOD(bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) struct bfa_mem_kva_s *fcxp_kva = BFA_MEM_FCXP_KVA(bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) struct bfa_mem_dma_s *seg_ptr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) u16 nsegs, idx, per_seg_fcxp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) u16 num_fcxps = cfg->fwcfg.num_fcxp_reqs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) u32 per_fcxp_sz;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) if (num_fcxps == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) if (cfg->drvcfg.min_cfg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) per_fcxp_sz = 2 * BFA_FCXP_MAX_IBUF_SZ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) per_fcxp_sz = BFA_FCXP_MAX_IBUF_SZ + BFA_FCXP_MAX_LBUF_SZ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) /* dma memory */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) nsegs = BFI_MEM_DMA_NSEGS(num_fcxps, per_fcxp_sz);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) per_seg_fcxp = BFI_MEM_NREQS_SEG(per_fcxp_sz);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) bfa_mem_dma_seg_iter(fcxp_mod, seg_ptr, nsegs, idx) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) if (num_fcxps >= per_seg_fcxp) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) num_fcxps -= per_seg_fcxp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) bfa_mem_dma_setup(minfo, seg_ptr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) per_seg_fcxp * per_fcxp_sz);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) } else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) bfa_mem_dma_setup(minfo, seg_ptr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) num_fcxps * per_fcxp_sz);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) /* kva memory */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485) bfa_mem_kva_setup(minfo, fcxp_kva,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) cfg->fwcfg.num_fcxp_reqs * sizeof(struct bfa_fcxp_s));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) bfa_fcxp_attach(struct bfa_s *bfa, void *bfad, struct bfa_iocfc_cfg_s *cfg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) struct bfa_pcidev_s *pcidev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) struct bfa_fcxp_mod_s *mod = BFA_FCXP_MOD(bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) mod->bfa = bfa;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) mod->num_fcxps = cfg->fwcfg.num_fcxp_reqs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) * Initialize FCXP request and response payload sizes.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) mod->req_pld_sz = mod->rsp_pld_sz = BFA_FCXP_MAX_IBUF_SZ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) if (!cfg->drvcfg.min_cfg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) mod->rsp_pld_sz = BFA_FCXP_MAX_LBUF_SZ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505) INIT_LIST_HEAD(&mod->req_wait_q);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506) INIT_LIST_HEAD(&mod->rsp_wait_q);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508) claim_fcxps_mem(mod);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512) bfa_fcxp_iocdisable(struct bfa_s *bfa)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514) struct bfa_fcxp_mod_s *mod = BFA_FCXP_MOD(bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515) struct bfa_fcxp_s *fcxp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516) struct list_head *qe, *qen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518) /* Enqueue unused fcxp resources to free_q */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519) list_splice_tail_init(&mod->fcxp_req_unused_q, &mod->fcxp_req_free_q);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520) list_splice_tail_init(&mod->fcxp_rsp_unused_q, &mod->fcxp_rsp_free_q);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522) list_for_each_safe(qe, qen, &mod->fcxp_active_q) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523) fcxp = (struct bfa_fcxp_s *) qe;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524) if (fcxp->caller == NULL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525) fcxp->send_cbfn(fcxp->caller, fcxp, fcxp->send_cbarg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526) BFA_STATUS_IOC_FAILURE, 0, 0, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527) bfa_fcxp_free(fcxp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529) fcxp->rsp_status = BFA_STATUS_IOC_FAILURE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530) bfa_cb_queue(bfa, &fcxp->hcb_qe,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 531) __bfa_fcxp_send_cbfn, fcxp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 532) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 533) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 534) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 535)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 536) static struct bfa_fcxp_s *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 537) bfa_fcxp_get(struct bfa_fcxp_mod_s *fm, bfa_boolean_t req)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 538) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 539) struct bfa_fcxp_s *fcxp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 540)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 541) if (req)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 542) bfa_q_deq(&fm->fcxp_req_free_q, &fcxp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 543) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 544) bfa_q_deq(&fm->fcxp_rsp_free_q, &fcxp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 545)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 546) if (fcxp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 547) list_add_tail(&fcxp->qe, &fm->fcxp_active_q);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 548)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 549) return fcxp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 550) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 551)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 552) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 553) bfa_fcxp_init_reqrsp(struct bfa_fcxp_s *fcxp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 554) struct bfa_s *bfa,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 555) u8 *use_ibuf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 556) u32 *nr_sgles,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 557) bfa_fcxp_get_sgaddr_t *r_sga_cbfn,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 558) bfa_fcxp_get_sglen_t *r_sglen_cbfn,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 559) struct list_head *r_sgpg_q,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 560) int n_sgles,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 561) bfa_fcxp_get_sgaddr_t sga_cbfn,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 562) bfa_fcxp_get_sglen_t sglen_cbfn)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 563) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 564)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 565) WARN_ON(bfa == NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 566)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 567) bfa_trc(bfa, fcxp->fcxp_tag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 568)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 569) if (n_sgles == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 570) *use_ibuf = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 571) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 572) WARN_ON(*sga_cbfn == NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 573) WARN_ON(*sglen_cbfn == NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 574)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 575) *use_ibuf = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 576) *r_sga_cbfn = sga_cbfn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 577) *r_sglen_cbfn = sglen_cbfn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 578)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 579) *nr_sgles = n_sgles;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 580)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 581) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 582) * alloc required sgpgs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 583) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 584) if (n_sgles > BFI_SGE_INLINE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 585) WARN_ON(1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 586) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 587)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 588) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 589)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 590) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 591) bfa_fcxp_init(struct bfa_fcxp_s *fcxp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 592) void *caller, struct bfa_s *bfa, int nreq_sgles,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 593) int nrsp_sgles, bfa_fcxp_get_sgaddr_t req_sga_cbfn,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 594) bfa_fcxp_get_sglen_t req_sglen_cbfn,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 595) bfa_fcxp_get_sgaddr_t rsp_sga_cbfn,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 596) bfa_fcxp_get_sglen_t rsp_sglen_cbfn)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 597) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 598)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 599) WARN_ON(bfa == NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 600)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 601) bfa_trc(bfa, fcxp->fcxp_tag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 602)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 603) fcxp->caller = caller;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 604)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 605) bfa_fcxp_init_reqrsp(fcxp, bfa,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 606) &fcxp->use_ireqbuf, &fcxp->nreq_sgles, &fcxp->req_sga_cbfn,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 607) &fcxp->req_sglen_cbfn, &fcxp->req_sgpg_q,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 608) nreq_sgles, req_sga_cbfn, req_sglen_cbfn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 609)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 610) bfa_fcxp_init_reqrsp(fcxp, bfa,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 611) &fcxp->use_irspbuf, &fcxp->nrsp_sgles, &fcxp->rsp_sga_cbfn,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 612) &fcxp->rsp_sglen_cbfn, &fcxp->rsp_sgpg_q,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 613) nrsp_sgles, rsp_sga_cbfn, rsp_sglen_cbfn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 614)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 615) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 616)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 617) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 618) bfa_fcxp_put(struct bfa_fcxp_s *fcxp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 619) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 620) struct bfa_fcxp_mod_s *mod = fcxp->fcxp_mod;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 621) struct bfa_fcxp_wqe_s *wqe;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 622)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 623) if (fcxp->req_rsp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 624) bfa_q_deq(&mod->req_wait_q, &wqe);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 625) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 626) bfa_q_deq(&mod->rsp_wait_q, &wqe);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 627)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 628) if (wqe) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 629) bfa_trc(mod->bfa, fcxp->fcxp_tag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 630)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 631) bfa_fcxp_init(fcxp, wqe->caller, wqe->bfa, wqe->nreq_sgles,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 632) wqe->nrsp_sgles, wqe->req_sga_cbfn,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 633) wqe->req_sglen_cbfn, wqe->rsp_sga_cbfn,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 634) wqe->rsp_sglen_cbfn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 635)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 636) wqe->alloc_cbfn(wqe->alloc_cbarg, fcxp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 637) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 638) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 639)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 640) WARN_ON(!bfa_q_is_on_q(&mod->fcxp_active_q, fcxp));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 641) list_del(&fcxp->qe);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 642)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 643) if (fcxp->req_rsp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 644) list_add_tail(&fcxp->qe, &mod->fcxp_req_free_q);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 645) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 646) list_add_tail(&fcxp->qe, &mod->fcxp_rsp_free_q);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 647) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 648)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 649) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 650) bfa_fcxp_null_comp(void *bfad_fcxp, struct bfa_fcxp_s *fcxp, void *cbarg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 651) bfa_status_t req_status, u32 rsp_len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 652) u32 resid_len, struct fchs_s *rsp_fchs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 653) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 654) /* discarded fcxp completion */
^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) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 658) __bfa_fcxp_send_cbfn(void *cbarg, bfa_boolean_t complete)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 659) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 660) struct bfa_fcxp_s *fcxp = cbarg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 661)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 662) if (complete) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 663) fcxp->send_cbfn(fcxp->caller, fcxp, fcxp->send_cbarg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 664) fcxp->rsp_status, fcxp->rsp_len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 665) fcxp->residue_len, &fcxp->rsp_fchs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 666) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 667) bfa_fcxp_free(fcxp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 668) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 669) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 670)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 671) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 672) hal_fcxp_send_comp(struct bfa_s *bfa, struct bfi_fcxp_send_rsp_s *fcxp_rsp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 673) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 674) struct bfa_fcxp_mod_s *mod = BFA_FCXP_MOD(bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 675) struct bfa_fcxp_s *fcxp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 676) u16 fcxp_tag = be16_to_cpu(fcxp_rsp->fcxp_tag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 677)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 678) bfa_trc(bfa, fcxp_tag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 679)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 680) fcxp_rsp->rsp_len = be32_to_cpu(fcxp_rsp->rsp_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 681)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 682) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 683) * @todo f/w should not set residue to non-0 when everything
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 684) * is received.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 685) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 686) if (fcxp_rsp->req_status == BFA_STATUS_OK)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 687) fcxp_rsp->residue_len = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 688) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 689) fcxp_rsp->residue_len = be32_to_cpu(fcxp_rsp->residue_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 690)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 691) fcxp = BFA_FCXP_FROM_TAG(mod, fcxp_tag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 692)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 693) WARN_ON(fcxp->send_cbfn == NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 694)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 695) hal_fcxp_rx_plog(mod->bfa, fcxp, fcxp_rsp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 696)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 697) if (fcxp->send_cbfn != NULL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 698) bfa_trc(mod->bfa, (NULL == fcxp->caller));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 699) if (fcxp->caller == NULL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 700) fcxp->send_cbfn(fcxp->caller, fcxp, fcxp->send_cbarg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 701) fcxp_rsp->req_status, fcxp_rsp->rsp_len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 702) fcxp_rsp->residue_len, &fcxp_rsp->fchs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 703) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 704) * fcxp automatically freed on return from the callback
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 705) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 706) bfa_fcxp_free(fcxp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 707) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 708) fcxp->rsp_status = fcxp_rsp->req_status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 709) fcxp->rsp_len = fcxp_rsp->rsp_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 710) fcxp->residue_len = fcxp_rsp->residue_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 711) fcxp->rsp_fchs = fcxp_rsp->fchs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 712)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 713) bfa_cb_queue(bfa, &fcxp->hcb_qe,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 714) __bfa_fcxp_send_cbfn, fcxp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 715) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 716) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 717) bfa_trc(bfa, (NULL == fcxp->send_cbfn));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 718) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 719) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 720)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 721) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 722) hal_fcxp_tx_plog(struct bfa_s *bfa, u32 reqlen, struct bfa_fcxp_s *fcxp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 723) struct fchs_s *fchs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 724) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 725) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 726) * TODO: TX ox_id
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 727) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 728) if (reqlen > 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 729) if (fcxp->use_ireqbuf) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 730) u32 pld_w0 =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 731) *((u32 *) BFA_FCXP_REQ_PLD(fcxp));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 732)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 733) bfa_plog_fchdr_and_pl(bfa->plog, BFA_PL_MID_HAL_FCXP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 734) BFA_PL_EID_TX,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 735) reqlen + sizeof(struct fchs_s), fchs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 736) pld_w0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 737) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 738) bfa_plog_fchdr(bfa->plog, BFA_PL_MID_HAL_FCXP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 739) BFA_PL_EID_TX,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 740) reqlen + sizeof(struct fchs_s),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 741) fchs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 742) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 743) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 744) bfa_plog_fchdr(bfa->plog, BFA_PL_MID_HAL_FCXP, BFA_PL_EID_TX,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 745) reqlen + sizeof(struct fchs_s), fchs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 746) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 747) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 748)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 749) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 750) hal_fcxp_rx_plog(struct bfa_s *bfa, struct bfa_fcxp_s *fcxp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 751) struct bfi_fcxp_send_rsp_s *fcxp_rsp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 752) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 753) if (fcxp_rsp->rsp_len > 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 754) if (fcxp->use_irspbuf) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 755) u32 pld_w0 =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 756) *((u32 *) BFA_FCXP_RSP_PLD(fcxp));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 757)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 758) bfa_plog_fchdr_and_pl(bfa->plog, BFA_PL_MID_HAL_FCXP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 759) BFA_PL_EID_RX,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 760) (u16) fcxp_rsp->rsp_len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 761) &fcxp_rsp->fchs, pld_w0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 762) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 763) bfa_plog_fchdr(bfa->plog, BFA_PL_MID_HAL_FCXP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 764) BFA_PL_EID_RX,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 765) (u16) fcxp_rsp->rsp_len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 766) &fcxp_rsp->fchs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 767) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 768) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 769) bfa_plog_fchdr(bfa->plog, BFA_PL_MID_HAL_FCXP, BFA_PL_EID_RX,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 770) (u16) fcxp_rsp->rsp_len, &fcxp_rsp->fchs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 771) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 772) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 773)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 774) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 775) * Handler to resume sending fcxp when space in available in cpe queue.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 776) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 777) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 778) bfa_fcxp_qresume(void *cbarg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 779) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 780) struct bfa_fcxp_s *fcxp = cbarg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 781) struct bfa_s *bfa = fcxp->fcxp_mod->bfa;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 782) struct bfi_fcxp_send_req_s *send_req;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 783)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 784) fcxp->reqq_waiting = BFA_FALSE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 785) send_req = bfa_reqq_next(bfa, BFA_REQQ_FCXP);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 786) bfa_fcxp_queue(fcxp, send_req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 787) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 788)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 789) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 790) * Queue fcxp send request to foimrware.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 791) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 792) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 793) bfa_fcxp_queue(struct bfa_fcxp_s *fcxp, struct bfi_fcxp_send_req_s *send_req)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 794) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 795) struct bfa_s *bfa = fcxp->fcxp_mod->bfa;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 796) struct bfa_fcxp_req_info_s *reqi = &fcxp->req_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 797) struct bfa_fcxp_rsp_info_s *rspi = &fcxp->rsp_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 798) struct bfa_rport_s *rport = reqi->bfa_rport;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 799)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 800) bfi_h2i_set(send_req->mh, BFI_MC_FCXP, BFI_FCXP_H2I_SEND_REQ,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 801) bfa_fn_lpu(bfa));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 802)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 803) send_req->fcxp_tag = cpu_to_be16(fcxp->fcxp_tag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 804) if (rport) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 805) send_req->rport_fw_hndl = rport->fw_handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 806) send_req->max_frmsz = cpu_to_be16(rport->rport_info.max_frmsz);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 807) if (send_req->max_frmsz == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 808) send_req->max_frmsz = cpu_to_be16(FC_MAX_PDUSZ);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 809) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 810) send_req->rport_fw_hndl = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 811) send_req->max_frmsz = cpu_to_be16(FC_MAX_PDUSZ);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 812) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 813)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 814) send_req->vf_id = cpu_to_be16(reqi->vf_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 815) send_req->lp_fwtag = bfa_lps_get_fwtag(bfa, reqi->lp_tag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 816) send_req->class = reqi->class;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 817) send_req->rsp_timeout = rspi->rsp_timeout;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 818) send_req->cts = reqi->cts;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 819) send_req->fchs = reqi->fchs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 820)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 821) send_req->req_len = cpu_to_be32(reqi->req_tot_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 822) send_req->rsp_maxlen = cpu_to_be32(rspi->rsp_maxlen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 823)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 824) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 825) * setup req sgles
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 826) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 827) if (fcxp->use_ireqbuf == 1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 828) bfa_alen_set(&send_req->req_alen, reqi->req_tot_len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 829) BFA_FCXP_REQ_PLD_PA(fcxp));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 830) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 831) if (fcxp->nreq_sgles > 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 832) WARN_ON(fcxp->nreq_sgles != 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 833) bfa_alen_set(&send_req->req_alen, reqi->req_tot_len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 834) fcxp->req_sga_cbfn(fcxp->caller, 0));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 835) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 836) WARN_ON(reqi->req_tot_len != 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 837) bfa_alen_set(&send_req->rsp_alen, 0, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 838) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 839) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 840)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 841) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 842) * setup rsp sgles
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 843) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 844) if (fcxp->use_irspbuf == 1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 845) WARN_ON(rspi->rsp_maxlen > BFA_FCXP_MAX_LBUF_SZ);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 846)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 847) bfa_alen_set(&send_req->rsp_alen, rspi->rsp_maxlen,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 848) BFA_FCXP_RSP_PLD_PA(fcxp));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 849) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 850) if (fcxp->nrsp_sgles > 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 851) WARN_ON(fcxp->nrsp_sgles != 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 852) bfa_alen_set(&send_req->rsp_alen, rspi->rsp_maxlen,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 853) fcxp->rsp_sga_cbfn(fcxp->caller, 0));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 854)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 855) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 856) WARN_ON(rspi->rsp_maxlen != 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 857) bfa_alen_set(&send_req->rsp_alen, 0, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 858) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 859) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 860)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 861) hal_fcxp_tx_plog(bfa, reqi->req_tot_len, fcxp, &reqi->fchs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 862)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 863) bfa_reqq_produce(bfa, BFA_REQQ_FCXP, send_req->mh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 864)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 865) bfa_trc(bfa, bfa_reqq_pi(bfa, BFA_REQQ_FCXP));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 866) bfa_trc(bfa, bfa_reqq_ci(bfa, BFA_REQQ_FCXP));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 867) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 868)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 869) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 870) * Allocate an FCXP instance to send a response or to send a request
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 871) * that has a response. Request/response buffers are allocated by caller.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 872) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 873) * @param[in] bfa BFA bfa instance
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 874) * @param[in] nreq_sgles Number of SG elements required for request
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 875) * buffer. 0, if fcxp internal buffers are used.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 876) * Use bfa_fcxp_get_reqbuf() to get the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 877) * internal req buffer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 878) * @param[in] req_sgles SG elements describing request buffer. Will be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 879) * copied in by BFA and hence can be freed on
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 880) * return from this function.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 881) * @param[in] get_req_sga function ptr to be called to get a request SG
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 882) * Address (given the sge index).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 883) * @param[in] get_req_sglen function ptr to be called to get a request SG
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 884) * len (given the sge index).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 885) * @param[in] get_rsp_sga function ptr to be called to get a response SG
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 886) * Address (given the sge index).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 887) * @param[in] get_rsp_sglen function ptr to be called to get a response SG
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 888) * len (given the sge index).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 889) * @param[in] req Allocated FCXP is used to send req or rsp?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 890) * request - BFA_TRUE, response - BFA_FALSE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 891) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 892) * @return FCXP instance. NULL on failure.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 893) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 894) struct bfa_fcxp_s *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 895) bfa_fcxp_req_rsp_alloc(void *caller, struct bfa_s *bfa, int nreq_sgles,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 896) int nrsp_sgles, bfa_fcxp_get_sgaddr_t req_sga_cbfn,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 897) bfa_fcxp_get_sglen_t req_sglen_cbfn,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 898) bfa_fcxp_get_sgaddr_t rsp_sga_cbfn,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 899) bfa_fcxp_get_sglen_t rsp_sglen_cbfn, bfa_boolean_t req)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 900) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 901) struct bfa_fcxp_s *fcxp = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 902)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 903) WARN_ON(bfa == NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 904)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 905) fcxp = bfa_fcxp_get(BFA_FCXP_MOD(bfa), req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 906) if (fcxp == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 907) return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 908)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 909) bfa_trc(bfa, fcxp->fcxp_tag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 910)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 911) bfa_fcxp_init(fcxp, caller, bfa, nreq_sgles, nrsp_sgles, req_sga_cbfn,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 912) req_sglen_cbfn, rsp_sga_cbfn, rsp_sglen_cbfn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 913)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 914) return fcxp;
^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) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 918) * Get the internal request buffer pointer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 919) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 920) * @param[in] fcxp BFA fcxp pointer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 921) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 922) * @return pointer to the internal request buffer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 923) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 924) void *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 925) bfa_fcxp_get_reqbuf(struct bfa_fcxp_s *fcxp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 926) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 927) struct bfa_fcxp_mod_s *mod = fcxp->fcxp_mod;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 928) void *reqbuf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 929)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 930) WARN_ON(fcxp->use_ireqbuf != 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 931) reqbuf = bfa_mem_get_dmabuf_kva(mod, fcxp->fcxp_tag,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 932) mod->req_pld_sz + mod->rsp_pld_sz);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 933) return reqbuf;
^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) u32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 937) bfa_fcxp_get_reqbufsz(struct bfa_fcxp_s *fcxp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 938) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 939) struct bfa_fcxp_mod_s *mod = fcxp->fcxp_mod;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 940)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 941) return mod->req_pld_sz;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 942) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 943)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 944) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 945) * Get the internal response buffer pointer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 946) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 947) * @param[in] fcxp BFA fcxp pointer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 948) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 949) * @return pointer to the internal request buffer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 950) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 951) void *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 952) bfa_fcxp_get_rspbuf(struct bfa_fcxp_s *fcxp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 953) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 954) struct bfa_fcxp_mod_s *mod = fcxp->fcxp_mod;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 955) void *fcxp_buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 956)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 957) WARN_ON(fcxp->use_irspbuf != 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 958)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 959) fcxp_buf = bfa_mem_get_dmabuf_kva(mod, fcxp->fcxp_tag,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 960) mod->req_pld_sz + mod->rsp_pld_sz);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 961)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 962) /* fcxp_buf = req_buf + rsp_buf :- add req_buf_sz to get to rsp_buf */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 963) return ((u8 *) fcxp_buf) + mod->req_pld_sz;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 964) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 965)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 966) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 967) * Free the BFA FCXP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 968) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 969) * @param[in] fcxp BFA fcxp pointer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 970) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 971) * @return void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 972) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 973) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 974) bfa_fcxp_free(struct bfa_fcxp_s *fcxp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 975) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 976) struct bfa_fcxp_mod_s *mod = fcxp->fcxp_mod;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 977)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 978) WARN_ON(fcxp == NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 979) bfa_trc(mod->bfa, fcxp->fcxp_tag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 980) bfa_fcxp_put(fcxp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 981) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 982)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 983) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 984) * Send a FCXP request
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 985) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 986) * @param[in] fcxp BFA fcxp pointer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 987) * @param[in] rport BFA rport pointer. Could be left NULL for WKA rports
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 988) * @param[in] vf_id virtual Fabric ID
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 989) * @param[in] lp_tag lport tag
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 990) * @param[in] cts use Continuous sequence
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 991) * @param[in] cos fc Class of Service
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 992) * @param[in] reqlen request length, does not include FCHS length
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 993) * @param[in] fchs fc Header Pointer. The header content will be copied
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 994) * in by BFA.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 995) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 996) * @param[in] cbfn call back function to be called on receiving
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 997) * the response
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 998) * @param[in] cbarg arg for cbfn
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 999) * @param[in] rsp_timeout
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1000) * response timeout
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1001) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1002) * @return bfa_status_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1003) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1004) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1005) bfa_fcxp_send(struct bfa_fcxp_s *fcxp, struct bfa_rport_s *rport,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1006) u16 vf_id, u8 lp_tag, bfa_boolean_t cts, enum fc_cos cos,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1007) u32 reqlen, struct fchs_s *fchs, bfa_cb_fcxp_send_t cbfn,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1008) void *cbarg, u32 rsp_maxlen, u8 rsp_timeout)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1009) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1010) struct bfa_s *bfa = fcxp->fcxp_mod->bfa;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1011) struct bfa_fcxp_req_info_s *reqi = &fcxp->req_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1012) struct bfa_fcxp_rsp_info_s *rspi = &fcxp->rsp_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1013) struct bfi_fcxp_send_req_s *send_req;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1014)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1015) bfa_trc(bfa, fcxp->fcxp_tag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1016)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1017) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1018) * setup request/response info
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1019) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1020) reqi->bfa_rport = rport;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1021) reqi->vf_id = vf_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1022) reqi->lp_tag = lp_tag;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1023) reqi->class = cos;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1024) rspi->rsp_timeout = rsp_timeout;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1025) reqi->cts = cts;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1026) reqi->fchs = *fchs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1027) reqi->req_tot_len = reqlen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1028) rspi->rsp_maxlen = rsp_maxlen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1029) fcxp->send_cbfn = cbfn ? cbfn : bfa_fcxp_null_comp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1030) fcxp->send_cbarg = cbarg;
^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) * If no room in CPE queue, wait for space in request queue
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1034) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1035) send_req = bfa_reqq_next(bfa, BFA_REQQ_FCXP);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1036) if (!send_req) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1037) bfa_trc(bfa, fcxp->fcxp_tag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1038) fcxp->reqq_waiting = BFA_TRUE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1039) bfa_reqq_wait(bfa, BFA_REQQ_FCXP, &fcxp->reqq_wqe);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1040) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1041) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1042)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1043) bfa_fcxp_queue(fcxp, send_req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1044) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1045)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1046) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1047) * Abort a BFA FCXP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1048) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1049) * @param[in] fcxp BFA fcxp pointer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1050) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1051) * @return void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1052) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1053) bfa_status_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1054) bfa_fcxp_abort(struct bfa_fcxp_s *fcxp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1055) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1056) bfa_trc(fcxp->fcxp_mod->bfa, fcxp->fcxp_tag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1057) WARN_ON(1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1058) return BFA_STATUS_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1059) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1060)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1061) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1062) bfa_fcxp_req_rsp_alloc_wait(struct bfa_s *bfa, struct bfa_fcxp_wqe_s *wqe,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1063) bfa_fcxp_alloc_cbfn_t alloc_cbfn, void *alloc_cbarg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1064) void *caller, int nreq_sgles,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1065) int nrsp_sgles, bfa_fcxp_get_sgaddr_t req_sga_cbfn,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1066) bfa_fcxp_get_sglen_t req_sglen_cbfn,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1067) bfa_fcxp_get_sgaddr_t rsp_sga_cbfn,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1068) bfa_fcxp_get_sglen_t rsp_sglen_cbfn, bfa_boolean_t req)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1069) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1070) struct bfa_fcxp_mod_s *mod = BFA_FCXP_MOD(bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1071)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1072) if (req)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1073) WARN_ON(!list_empty(&mod->fcxp_req_free_q));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1074) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1075) WARN_ON(!list_empty(&mod->fcxp_rsp_free_q));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1076)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1077) wqe->alloc_cbfn = alloc_cbfn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1078) wqe->alloc_cbarg = alloc_cbarg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1079) wqe->caller = caller;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1080) wqe->bfa = bfa;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1081) wqe->nreq_sgles = nreq_sgles;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1082) wqe->nrsp_sgles = nrsp_sgles;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1083) wqe->req_sga_cbfn = req_sga_cbfn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1084) wqe->req_sglen_cbfn = req_sglen_cbfn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1085) wqe->rsp_sga_cbfn = rsp_sga_cbfn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1086) wqe->rsp_sglen_cbfn = rsp_sglen_cbfn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1087)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1088) if (req)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1089) list_add_tail(&wqe->qe, &mod->req_wait_q);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1090) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1091) list_add_tail(&wqe->qe, &mod->rsp_wait_q);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1092) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1093)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1094) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1095) bfa_fcxp_walloc_cancel(struct bfa_s *bfa, struct bfa_fcxp_wqe_s *wqe)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1096) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1097) struct bfa_fcxp_mod_s *mod = BFA_FCXP_MOD(bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1098)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1099) WARN_ON(!bfa_q_is_on_q(&mod->req_wait_q, wqe) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1100) !bfa_q_is_on_q(&mod->rsp_wait_q, wqe));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1101) list_del(&wqe->qe);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1102) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1103)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1104) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1105) bfa_fcxp_discard(struct bfa_fcxp_s *fcxp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1106) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1107) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1108) * If waiting for room in request queue, cancel reqq wait
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1109) * and free fcxp.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1110) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1111) if (fcxp->reqq_waiting) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1112) fcxp->reqq_waiting = BFA_FALSE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1113) bfa_reqq_wcancel(&fcxp->reqq_wqe);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1114) bfa_fcxp_free(fcxp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1115) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1116) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1117)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1118) fcxp->send_cbfn = bfa_fcxp_null_comp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1119) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1120)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1121) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1122) bfa_fcxp_isr(struct bfa_s *bfa, struct bfi_msg_s *msg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1123) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1124) switch (msg->mhdr.msg_id) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1125) case BFI_FCXP_I2H_SEND_RSP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1126) hal_fcxp_send_comp(bfa, (struct bfi_fcxp_send_rsp_s *) msg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1127) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1128)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1129) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1130) bfa_trc(bfa, msg->mhdr.msg_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1131) WARN_ON(1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1132) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1133) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1134)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1135) u32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1136) bfa_fcxp_get_maxrsp(struct bfa_s *bfa)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1137) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1138) struct bfa_fcxp_mod_s *mod = BFA_FCXP_MOD(bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1139)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1140) return mod->rsp_pld_sz;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1141) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1142)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1143) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1144) bfa_fcxp_res_recfg(struct bfa_s *bfa, u16 num_fcxp_fw)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1145) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1146) struct bfa_fcxp_mod_s *mod = BFA_FCXP_MOD(bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1147) struct list_head *qe;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1148) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1149)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1150) for (i = 0; i < (mod->num_fcxps - num_fcxp_fw); i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1151) if (i < ((mod->num_fcxps - num_fcxp_fw) / 2)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1152) bfa_q_deq_tail(&mod->fcxp_req_free_q, &qe);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1153) list_add_tail(qe, &mod->fcxp_req_unused_q);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1154) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1155) bfa_q_deq_tail(&mod->fcxp_rsp_free_q, &qe);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1156) list_add_tail(qe, &mod->fcxp_rsp_unused_q);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1157) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1158) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1159) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1160)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1161) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1162) * BFA LPS state machine functions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1163) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1164)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1165) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1166) * Init state -- no login
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1167) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1168) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1169) bfa_lps_sm_init(struct bfa_lps_s *lps, enum bfa_lps_event event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1170) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1171) bfa_trc(lps->bfa, lps->bfa_tag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1172) bfa_trc(lps->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1173)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1174) switch (event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1175) case BFA_LPS_SM_LOGIN:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1176) if (bfa_reqq_full(lps->bfa, lps->reqq)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1177) bfa_sm_set_state(lps, bfa_lps_sm_loginwait);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1178) bfa_reqq_wait(lps->bfa, lps->reqq, &lps->wqe);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1179) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1180) bfa_sm_set_state(lps, bfa_lps_sm_login);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1181) bfa_lps_send_login(lps);
^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) if (lps->fdisc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1185) bfa_plog_str(lps->bfa->plog, BFA_PL_MID_LPS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1186) BFA_PL_EID_LOGIN, 0, "FDISC Request");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1187) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1188) bfa_plog_str(lps->bfa->plog, BFA_PL_MID_LPS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1189) BFA_PL_EID_LOGIN, 0, "FLOGI Request");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1190) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1191)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1192) case BFA_LPS_SM_LOGOUT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1193) bfa_lps_logout_comp(lps);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1194) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1195)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1196) case BFA_LPS_SM_DELETE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1197) bfa_lps_free(lps);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1198) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1199)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1200) case BFA_LPS_SM_RX_CVL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1201) case BFA_LPS_SM_OFFLINE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1202) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1203)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1204) case BFA_LPS_SM_FWRSP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1205) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1206) * Could happen when fabric detects loopback and discards
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1207) * the lps request. Fw will eventually sent out the timeout
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1208) * Just ignore
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1209) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1210) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1211) case BFA_LPS_SM_SET_N2N_PID:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1212) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1213) * When topology is set to loop, bfa_lps_set_n2n_pid() sends
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1214) * this event. Ignore this event.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1215) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1216) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1217)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1218) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1219) bfa_sm_fault(lps->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1220) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1221) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1222)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1223) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1224) * login is in progress -- awaiting response from firmware
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1225) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1226) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1227) bfa_lps_sm_login(struct bfa_lps_s *lps, enum bfa_lps_event event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1228) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1229) bfa_trc(lps->bfa, lps->bfa_tag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1230) bfa_trc(lps->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1231)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1232) switch (event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1233) case BFA_LPS_SM_FWRSP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1234) if (lps->status == BFA_STATUS_OK) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1235) bfa_sm_set_state(lps, bfa_lps_sm_online);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1236) if (lps->fdisc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1237) bfa_plog_str(lps->bfa->plog, BFA_PL_MID_LPS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1238) BFA_PL_EID_LOGIN, 0, "FDISC Accept");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1239) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1240) bfa_plog_str(lps->bfa->plog, BFA_PL_MID_LPS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1241) BFA_PL_EID_LOGIN, 0, "FLOGI Accept");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1242) /* If N2N, send the assigned PID to FW */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1243) bfa_trc(lps->bfa, lps->fport);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1244) bfa_trc(lps->bfa, lps->lp_pid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1245)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1246) if (!lps->fport && lps->lp_pid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1247) bfa_sm_send_event(lps, BFA_LPS_SM_SET_N2N_PID);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1248) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1249) bfa_sm_set_state(lps, bfa_lps_sm_init);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1250) if (lps->fdisc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1251) bfa_plog_str(lps->bfa->plog, BFA_PL_MID_LPS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1252) BFA_PL_EID_LOGIN, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1253) "FDISC Fail (RJT or timeout)");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1254) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1255) bfa_plog_str(lps->bfa->plog, BFA_PL_MID_LPS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1256) BFA_PL_EID_LOGIN, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1257) "FLOGI Fail (RJT or timeout)");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1258) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1259) bfa_lps_login_comp(lps);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1260) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1261)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1262) case BFA_LPS_SM_OFFLINE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1263) case BFA_LPS_SM_DELETE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1264) bfa_sm_set_state(lps, bfa_lps_sm_init);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1265) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1266)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1267) case BFA_LPS_SM_SET_N2N_PID:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1268) bfa_trc(lps->bfa, lps->fport);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1269) bfa_trc(lps->bfa, lps->lp_pid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1270) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1271)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1272) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1273) bfa_sm_fault(lps->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1274) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1275) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1276)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1277) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1278) * login pending - awaiting space in request queue
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1279) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1280) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1281) bfa_lps_sm_loginwait(struct bfa_lps_s *lps, enum bfa_lps_event event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1282) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1283) bfa_trc(lps->bfa, lps->bfa_tag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1284) bfa_trc(lps->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1285)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1286) switch (event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1287) case BFA_LPS_SM_RESUME:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1288) bfa_sm_set_state(lps, bfa_lps_sm_login);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1289) bfa_lps_send_login(lps);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1290) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1291)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1292) case BFA_LPS_SM_OFFLINE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1293) case BFA_LPS_SM_DELETE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1294) bfa_sm_set_state(lps, bfa_lps_sm_init);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1295) bfa_reqq_wcancel(&lps->wqe);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1296) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1297)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1298) case BFA_LPS_SM_RX_CVL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1299) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1300) * Login was not even sent out; so when getting out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1301) * of this state, it will appear like a login retry
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1302) * after Clear virtual link
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1303) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1304) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1305)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1306) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1307) bfa_sm_fault(lps->bfa, event);
^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)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1311) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1312) * login complete
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1313) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1314) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1315) bfa_lps_sm_online(struct bfa_lps_s *lps, enum bfa_lps_event event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1316) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1317) bfa_trc(lps->bfa, lps->bfa_tag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1318) bfa_trc(lps->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1319)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1320) switch (event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1321) case BFA_LPS_SM_LOGOUT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1322) if (bfa_reqq_full(lps->bfa, lps->reqq)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1323) bfa_sm_set_state(lps, bfa_lps_sm_logowait);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1324) bfa_reqq_wait(lps->bfa, lps->reqq, &lps->wqe);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1325) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1326) bfa_sm_set_state(lps, bfa_lps_sm_logout);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1327) bfa_lps_send_logout(lps);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1328) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1329) bfa_plog_str(lps->bfa->plog, BFA_PL_MID_LPS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1330) BFA_PL_EID_LOGO, 0, "Logout");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1331) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1332)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1333) case BFA_LPS_SM_RX_CVL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1334) bfa_sm_set_state(lps, bfa_lps_sm_init);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1335)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1336) /* Let the vport module know about this event */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1337) bfa_lps_cvl_event(lps);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1338) bfa_plog_str(lps->bfa->plog, BFA_PL_MID_LPS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1339) BFA_PL_EID_FIP_FCF_CVL, 0, "FCF Clear Virt. Link Rx");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1340) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1341)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1342) case BFA_LPS_SM_SET_N2N_PID:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1343) if (bfa_reqq_full(lps->bfa, lps->reqq)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1344) bfa_sm_set_state(lps, bfa_lps_sm_online_n2n_pid_wait);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1345) bfa_reqq_wait(lps->bfa, lps->reqq, &lps->wqe);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1346) } else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1347) bfa_lps_send_set_n2n_pid(lps);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1348) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1349)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1350) case BFA_LPS_SM_OFFLINE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1351) case BFA_LPS_SM_DELETE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1352) bfa_sm_set_state(lps, bfa_lps_sm_init);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1353) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1354)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1355) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1356) bfa_sm_fault(lps->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1357) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1358) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1359)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1360) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1361) * login complete
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1362) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1363) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1364) bfa_lps_sm_online_n2n_pid_wait(struct bfa_lps_s *lps, enum bfa_lps_event event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1365) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1366) bfa_trc(lps->bfa, lps->bfa_tag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1367) bfa_trc(lps->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1368)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1369) switch (event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1370) case BFA_LPS_SM_RESUME:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1371) bfa_sm_set_state(lps, bfa_lps_sm_online);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1372) bfa_lps_send_set_n2n_pid(lps);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1373) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1374)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1375) case BFA_LPS_SM_LOGOUT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1376) bfa_sm_set_state(lps, bfa_lps_sm_logowait);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1377) bfa_plog_str(lps->bfa->plog, BFA_PL_MID_LPS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1378) BFA_PL_EID_LOGO, 0, "Logout");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1379) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1380)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1381) case BFA_LPS_SM_RX_CVL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1382) bfa_sm_set_state(lps, bfa_lps_sm_init);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1383) bfa_reqq_wcancel(&lps->wqe);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1384)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1385) /* Let the vport module know about this event */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1386) bfa_lps_cvl_event(lps);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1387) bfa_plog_str(lps->bfa->plog, BFA_PL_MID_LPS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1388) BFA_PL_EID_FIP_FCF_CVL, 0, "FCF Clear Virt. Link Rx");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1389) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1390)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1391) case BFA_LPS_SM_OFFLINE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1392) case BFA_LPS_SM_DELETE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1393) bfa_sm_set_state(lps, bfa_lps_sm_init);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1394) bfa_reqq_wcancel(&lps->wqe);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1395) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1396)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1397) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1398) bfa_sm_fault(lps->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1399) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1400) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1401)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1402) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1403) * logout in progress - awaiting firmware response
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1404) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1405) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1406) bfa_lps_sm_logout(struct bfa_lps_s *lps, enum bfa_lps_event event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1407) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1408) bfa_trc(lps->bfa, lps->bfa_tag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1409) bfa_trc(lps->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1410)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1411) switch (event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1412) case BFA_LPS_SM_FWRSP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1413) case BFA_LPS_SM_OFFLINE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1414) bfa_sm_set_state(lps, bfa_lps_sm_init);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1415) bfa_lps_logout_comp(lps);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1416) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1417)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1418) case BFA_LPS_SM_DELETE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1419) bfa_sm_set_state(lps, bfa_lps_sm_init);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1420) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1421)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1422) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1423) bfa_sm_fault(lps->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1424) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1425) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1426)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1427) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1428) * logout pending -- awaiting space in request queue
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1429) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1430) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1431) bfa_lps_sm_logowait(struct bfa_lps_s *lps, enum bfa_lps_event event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1432) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1433) bfa_trc(lps->bfa, lps->bfa_tag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1434) bfa_trc(lps->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1435)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1436) switch (event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1437) case BFA_LPS_SM_RESUME:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1438) bfa_sm_set_state(lps, bfa_lps_sm_logout);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1439) bfa_lps_send_logout(lps);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1440) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1441)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1442) case BFA_LPS_SM_OFFLINE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1443) case BFA_LPS_SM_DELETE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1444) bfa_sm_set_state(lps, bfa_lps_sm_init);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1445) bfa_reqq_wcancel(&lps->wqe);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1446) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1447)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1448) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1449) bfa_sm_fault(lps->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1450) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1451) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1452)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1453)
^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) * lps_pvt BFA LPS private functions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1457) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1458)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1459) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1460) * return memory requirement
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1461) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1462) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1463) bfa_lps_meminfo(struct bfa_iocfc_cfg_s *cfg, struct bfa_meminfo_s *minfo,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1464) struct bfa_s *bfa)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1465) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1466) struct bfa_mem_kva_s *lps_kva = BFA_MEM_LPS_KVA(bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1467)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1468) if (cfg->drvcfg.min_cfg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1469) bfa_mem_kva_setup(minfo, lps_kva,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1470) sizeof(struct bfa_lps_s) * BFA_LPS_MIN_LPORTS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1471) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1472) bfa_mem_kva_setup(minfo, lps_kva,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1473) sizeof(struct bfa_lps_s) * BFA_LPS_MAX_LPORTS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1474) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1475)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1476) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1477) * bfa module attach at initialization time
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1478) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1479) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1480) bfa_lps_attach(struct bfa_s *bfa, void *bfad, struct bfa_iocfc_cfg_s *cfg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1481) struct bfa_pcidev_s *pcidev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1482) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1483) struct bfa_lps_mod_s *mod = BFA_LPS_MOD(bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1484) struct bfa_lps_s *lps;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1485) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1486)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1487) mod->num_lps = BFA_LPS_MAX_LPORTS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1488) if (cfg->drvcfg.min_cfg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1489) mod->num_lps = BFA_LPS_MIN_LPORTS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1490) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1491) mod->num_lps = BFA_LPS_MAX_LPORTS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1492) mod->lps_arr = lps = (struct bfa_lps_s *) bfa_mem_kva_curp(mod);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1493)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1494) bfa_mem_kva_curp(mod) += mod->num_lps * sizeof(struct bfa_lps_s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1495)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1496) INIT_LIST_HEAD(&mod->lps_free_q);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1497) INIT_LIST_HEAD(&mod->lps_active_q);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1498) INIT_LIST_HEAD(&mod->lps_login_q);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1499)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1500) for (i = 0; i < mod->num_lps; i++, lps++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1501) lps->bfa = bfa;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1502) lps->bfa_tag = (u8) i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1503) lps->reqq = BFA_REQQ_LPS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1504) bfa_reqq_winit(&lps->wqe, bfa_lps_reqq_resume, lps);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1505) list_add_tail(&lps->qe, &mod->lps_free_q);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1506) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1507) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1508)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1509) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1510) * IOC in disabled state -- consider all lps offline
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1511) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1512) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1513) bfa_lps_iocdisable(struct bfa_s *bfa)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1514) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1515) struct bfa_lps_mod_s *mod = BFA_LPS_MOD(bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1516) struct bfa_lps_s *lps;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1517) struct list_head *qe, *qen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1518)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1519) list_for_each_safe(qe, qen, &mod->lps_active_q) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1520) lps = (struct bfa_lps_s *) qe;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1521) bfa_sm_send_event(lps, BFA_LPS_SM_OFFLINE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1522) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1523) list_for_each_safe(qe, qen, &mod->lps_login_q) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1524) lps = (struct bfa_lps_s *) qe;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1525) bfa_sm_send_event(lps, BFA_LPS_SM_OFFLINE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1526) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1527) list_splice_tail_init(&mod->lps_login_q, &mod->lps_active_q);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1528) }
^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) * Firmware login response
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1532) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1533) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1534) bfa_lps_login_rsp(struct bfa_s *bfa, struct bfi_lps_login_rsp_s *rsp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1535) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1536) struct bfa_lps_mod_s *mod = BFA_LPS_MOD(bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1537) struct bfa_lps_s *lps;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1538)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1539) WARN_ON(rsp->bfa_tag >= mod->num_lps);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1540) lps = BFA_LPS_FROM_TAG(mod, rsp->bfa_tag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1541)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1542) lps->status = rsp->status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1543) switch (rsp->status) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1544) case BFA_STATUS_OK:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1545) lps->fw_tag = rsp->fw_tag;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1546) lps->fport = rsp->f_port;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1547) if (lps->fport)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1548) lps->lp_pid = rsp->lp_pid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1549) lps->npiv_en = rsp->npiv_en;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1550) lps->pr_bbcred = be16_to_cpu(rsp->bb_credit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1551) lps->pr_pwwn = rsp->port_name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1552) lps->pr_nwwn = rsp->node_name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1553) lps->auth_req = rsp->auth_req;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1554) lps->lp_mac = rsp->lp_mac;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1555) lps->brcd_switch = rsp->brcd_switch;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1556) lps->fcf_mac = rsp->fcf_mac;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1557)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1558) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1559)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1560) case BFA_STATUS_FABRIC_RJT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1561) lps->lsrjt_rsn = rsp->lsrjt_rsn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1562) lps->lsrjt_expl = rsp->lsrjt_expl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1563)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1564) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1565)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1566) case BFA_STATUS_EPROTOCOL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1567) lps->ext_status = rsp->ext_status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1568)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1569) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1570)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1571) case BFA_STATUS_VPORT_MAX:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1572) if (rsp->ext_status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1573) bfa_lps_no_res(lps, rsp->ext_status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1574) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1575)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1576) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1577) /* Nothing to do with other status */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1578) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1579) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1580)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1581) list_del(&lps->qe);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1582) list_add_tail(&lps->qe, &mod->lps_active_q);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1583) bfa_sm_send_event(lps, BFA_LPS_SM_FWRSP);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1584) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1585)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1586) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1587) bfa_lps_no_res(struct bfa_lps_s *first_lps, u8 count)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1588) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1589) struct bfa_s *bfa = first_lps->bfa;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1590) struct bfa_lps_mod_s *mod = BFA_LPS_MOD(bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1591) struct list_head *qe, *qe_next;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1592) struct bfa_lps_s *lps;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1593)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1594) bfa_trc(bfa, count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1595)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1596) qe = bfa_q_next(first_lps);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1597)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1598) while (count && qe) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1599) qe_next = bfa_q_next(qe);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1600) lps = (struct bfa_lps_s *)qe;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1601) bfa_trc(bfa, lps->bfa_tag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1602) lps->status = first_lps->status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1603) list_del(&lps->qe);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1604) list_add_tail(&lps->qe, &mod->lps_active_q);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1605) bfa_sm_send_event(lps, BFA_LPS_SM_FWRSP);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1606) qe = qe_next;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1607) count--;
^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) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1612) * Firmware logout response
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1613) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1614) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1615) bfa_lps_logout_rsp(struct bfa_s *bfa, struct bfi_lps_logout_rsp_s *rsp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1616) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1617) struct bfa_lps_mod_s *mod = BFA_LPS_MOD(bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1618) struct bfa_lps_s *lps;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1619)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1620) WARN_ON(rsp->bfa_tag >= mod->num_lps);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1621) lps = BFA_LPS_FROM_TAG(mod, rsp->bfa_tag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1622)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1623) bfa_sm_send_event(lps, BFA_LPS_SM_FWRSP);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1624) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1625)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1626) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1627) * Firmware received a Clear virtual link request (for FCoE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1628) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1629) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1630) bfa_lps_rx_cvl_event(struct bfa_s *bfa, struct bfi_lps_cvl_event_s *cvl)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1631) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1632) struct bfa_lps_mod_s *mod = BFA_LPS_MOD(bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1633) struct bfa_lps_s *lps;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1634)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1635) lps = BFA_LPS_FROM_TAG(mod, cvl->bfa_tag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1636)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1637) bfa_sm_send_event(lps, BFA_LPS_SM_RX_CVL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1638) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1639)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1640) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1641) * Space is available in request queue, resume queueing request to firmware.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1642) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1643) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1644) bfa_lps_reqq_resume(void *lps_arg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1645) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1646) struct bfa_lps_s *lps = lps_arg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1647)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1648) bfa_sm_send_event(lps, BFA_LPS_SM_RESUME);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1649) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1650)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1651) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1652) * lps is freed -- triggered by vport delete
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1653) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1654) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1655) bfa_lps_free(struct bfa_lps_s *lps)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1656) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1657) struct bfa_lps_mod_s *mod = BFA_LPS_MOD(lps->bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1658)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1659) lps->lp_pid = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1660) list_del(&lps->qe);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1661) list_add_tail(&lps->qe, &mod->lps_free_q);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1662) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1663)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1664) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1665) * send login request to firmware
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1666) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1667) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1668) bfa_lps_send_login(struct bfa_lps_s *lps)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1669) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1670) struct bfa_lps_mod_s *mod = BFA_LPS_MOD(lps->bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1671) struct bfi_lps_login_req_s *m;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1672)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1673) m = bfa_reqq_next(lps->bfa, lps->reqq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1674) WARN_ON(!m);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1675)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1676) bfi_h2i_set(m->mh, BFI_MC_LPS, BFI_LPS_H2I_LOGIN_REQ,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1677) bfa_fn_lpu(lps->bfa));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1678)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1679) m->bfa_tag = lps->bfa_tag;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1680) m->alpa = lps->alpa;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1681) m->pdu_size = cpu_to_be16(lps->pdusz);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1682) m->pwwn = lps->pwwn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1683) m->nwwn = lps->nwwn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1684) m->fdisc = lps->fdisc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1685) m->auth_en = lps->auth_en;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1686)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1687) bfa_reqq_produce(lps->bfa, lps->reqq, m->mh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1688) list_del(&lps->qe);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1689) list_add_tail(&lps->qe, &mod->lps_login_q);
^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) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1693) * send logout request to firmware
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1694) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1695) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1696) bfa_lps_send_logout(struct bfa_lps_s *lps)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1697) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1698) struct bfi_lps_logout_req_s *m;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1699)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1700) m = bfa_reqq_next(lps->bfa, lps->reqq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1701) WARN_ON(!m);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1702)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1703) bfi_h2i_set(m->mh, BFI_MC_LPS, BFI_LPS_H2I_LOGOUT_REQ,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1704) bfa_fn_lpu(lps->bfa));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1705)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1706) m->fw_tag = lps->fw_tag;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1707) m->port_name = lps->pwwn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1708) bfa_reqq_produce(lps->bfa, lps->reqq, m->mh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1709) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1710)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1711) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1712) * send n2n pid set request to firmware
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1713) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1714) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1715) bfa_lps_send_set_n2n_pid(struct bfa_lps_s *lps)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1716) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1717) struct bfi_lps_n2n_pid_req_s *m;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1718)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1719) m = bfa_reqq_next(lps->bfa, lps->reqq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1720) WARN_ON(!m);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1721)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1722) bfi_h2i_set(m->mh, BFI_MC_LPS, BFI_LPS_H2I_N2N_PID_REQ,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1723) bfa_fn_lpu(lps->bfa));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1724)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1725) m->fw_tag = lps->fw_tag;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1726) m->lp_pid = lps->lp_pid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1727) bfa_reqq_produce(lps->bfa, lps->reqq, m->mh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1728) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1729)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1730) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1731) * Indirect login completion handler for non-fcs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1732) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1733) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1734) bfa_lps_login_comp_cb(void *arg, bfa_boolean_t complete)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1735) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1736) struct bfa_lps_s *lps = arg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1737)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1738) if (!complete)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1739) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1740)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1741) if (lps->fdisc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1742) bfa_cb_lps_fdisc_comp(lps->bfa->bfad, lps->uarg, lps->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1743) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1744) bfa_cb_lps_flogi_comp(lps->bfa->bfad, lps->uarg, lps->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1745) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1746)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1747) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1748) * Login completion handler -- direct call for fcs, queue for others
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1749) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1750) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1751) bfa_lps_login_comp(struct bfa_lps_s *lps)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1752) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1753) if (!lps->bfa->fcs) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1754) bfa_cb_queue(lps->bfa, &lps->hcb_qe, bfa_lps_login_comp_cb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1755) lps);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1756) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1757) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1758)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1759) if (lps->fdisc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1760) bfa_cb_lps_fdisc_comp(lps->bfa->bfad, lps->uarg, lps->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1761) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1762) bfa_cb_lps_flogi_comp(lps->bfa->bfad, lps->uarg, lps->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1763) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1764)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1765) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1766) * Indirect logout completion handler for non-fcs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1767) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1768) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1769) bfa_lps_logout_comp_cb(void *arg, bfa_boolean_t complete)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1770) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1771) struct bfa_lps_s *lps = arg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1772)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1773) if (!complete)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1774) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1775)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1776) if (lps->fdisc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1777) bfa_cb_lps_fdisclogo_comp(lps->bfa->bfad, lps->uarg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1778) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1779) bfa_cb_lps_flogo_comp(lps->bfa->bfad, lps->uarg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1780) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1781)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1782) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1783) * Logout completion handler -- direct call for fcs, queue for others
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1784) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1785) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1786) bfa_lps_logout_comp(struct bfa_lps_s *lps)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1787) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1788) if (!lps->bfa->fcs) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1789) bfa_cb_queue(lps->bfa, &lps->hcb_qe, bfa_lps_logout_comp_cb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1790) lps);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1791) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1792) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1793) if (lps->fdisc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1794) bfa_cb_lps_fdisclogo_comp(lps->bfa->bfad, lps->uarg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1795) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1796)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1797) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1798) * Clear virtual link completion handler for non-fcs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1799) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1800) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1801) bfa_lps_cvl_event_cb(void *arg, bfa_boolean_t complete)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1802) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1803) struct bfa_lps_s *lps = arg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1804)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1805) if (!complete)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1806) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1807)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1808) /* Clear virtual link to base port will result in link down */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1809) if (lps->fdisc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1810) bfa_cb_lps_cvl_event(lps->bfa->bfad, lps->uarg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1811) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1812)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1813) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1814) * Received Clear virtual link event --direct call for fcs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1815) * queue for others
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1816) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1817) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1818) bfa_lps_cvl_event(struct bfa_lps_s *lps)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1819) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1820) if (!lps->bfa->fcs) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1821) bfa_cb_queue(lps->bfa, &lps->hcb_qe, bfa_lps_cvl_event_cb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1822) lps);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1823) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1824) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1825)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1826) /* Clear virtual link to base port will result in link down */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1827) if (lps->fdisc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1828) bfa_cb_lps_cvl_event(lps->bfa->bfad, lps->uarg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1829) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1830)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1831)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1832)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1833) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1834) * lps_public BFA LPS public functions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1835) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1836)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1837) u32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1838) bfa_lps_get_max_vport(struct bfa_s *bfa)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1839) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1840) if (bfa_ioc_devid(&bfa->ioc) == BFA_PCI_DEVICE_ID_CT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1841) return BFA_LPS_MAX_VPORTS_SUPP_CT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1842) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1843) return BFA_LPS_MAX_VPORTS_SUPP_CB;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1844) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1845)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1846) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1847) * Allocate a lport srvice tag.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1848) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1849) struct bfa_lps_s *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1850) bfa_lps_alloc(struct bfa_s *bfa)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1851) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1852) struct bfa_lps_mod_s *mod = BFA_LPS_MOD(bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1853) struct bfa_lps_s *lps = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1854)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1855) bfa_q_deq(&mod->lps_free_q, &lps);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1856)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1857) if (lps == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1858) return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1859)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1860) list_add_tail(&lps->qe, &mod->lps_active_q);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1861)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1862) bfa_sm_set_state(lps, bfa_lps_sm_init);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1863) return lps;
^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) * Free lport service tag. This can be called anytime after an alloc.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1868) * No need to wait for any pending login/logout completions.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1869) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1870) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1871) bfa_lps_delete(struct bfa_lps_s *lps)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1872) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1873) bfa_sm_send_event(lps, BFA_LPS_SM_DELETE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1874) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1875)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1876) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1877) * Initiate a lport login.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1878) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1879) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1880) bfa_lps_flogi(struct bfa_lps_s *lps, void *uarg, u8 alpa, u16 pdusz,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1881) wwn_t pwwn, wwn_t nwwn, bfa_boolean_t auth_en)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1882) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1883) lps->uarg = uarg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1884) lps->alpa = alpa;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1885) lps->pdusz = pdusz;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1886) lps->pwwn = pwwn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1887) lps->nwwn = nwwn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1888) lps->fdisc = BFA_FALSE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1889) lps->auth_en = auth_en;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1890) bfa_sm_send_event(lps, BFA_LPS_SM_LOGIN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1891) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1892)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1893) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1894) * Initiate a lport fdisc login.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1895) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1896) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1897) bfa_lps_fdisc(struct bfa_lps_s *lps, void *uarg, u16 pdusz, wwn_t pwwn,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1898) wwn_t nwwn)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1899) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1900) lps->uarg = uarg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1901) lps->alpa = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1902) lps->pdusz = pdusz;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1903) lps->pwwn = pwwn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1904) lps->nwwn = nwwn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1905) lps->fdisc = BFA_TRUE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1906) lps->auth_en = BFA_FALSE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1907) bfa_sm_send_event(lps, BFA_LPS_SM_LOGIN);
^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) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1912) * Initiate a lport FDSIC logout.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1913) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1914) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1915) bfa_lps_fdisclogo(struct bfa_lps_s *lps)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1916) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1917) bfa_sm_send_event(lps, BFA_LPS_SM_LOGOUT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1918) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1919)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1920) u8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1921) bfa_lps_get_fwtag(struct bfa_s *bfa, u8 lp_tag)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1922) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1923) struct bfa_lps_mod_s *mod = BFA_LPS_MOD(bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1924)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1925) return BFA_LPS_FROM_TAG(mod, lp_tag)->fw_tag;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1926) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1927)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1928) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1929) * Return lport services tag given the pid
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1930) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1931) u8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1932) bfa_lps_get_tag_from_pid(struct bfa_s *bfa, u32 pid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1933) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1934) struct bfa_lps_mod_s *mod = BFA_LPS_MOD(bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1935) struct bfa_lps_s *lps;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1936) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1937)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1938) for (i = 0, lps = mod->lps_arr; i < mod->num_lps; i++, lps++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1939) if (lps->lp_pid == pid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1940) return lps->bfa_tag;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1941) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1942)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1943) /* Return base port tag anyway */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1944) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1945) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1946)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1947)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1948) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1949) * return port id assigned to the base lport
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1950) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1951) u32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1952) bfa_lps_get_base_pid(struct bfa_s *bfa)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1953) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1954) struct bfa_lps_mod_s *mod = BFA_LPS_MOD(bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1955)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1956) return BFA_LPS_FROM_TAG(mod, 0)->lp_pid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1957) }
^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) * Set PID in case of n2n (which is assigned during PLOGI)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1961) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1962) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1963) bfa_lps_set_n2n_pid(struct bfa_lps_s *lps, uint32_t n2n_pid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1964) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1965) bfa_trc(lps->bfa, lps->bfa_tag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1966) bfa_trc(lps->bfa, n2n_pid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1967)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1968) lps->lp_pid = n2n_pid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1969) bfa_sm_send_event(lps, BFA_LPS_SM_SET_N2N_PID);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1970) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1971)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1972) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1973) * LPS firmware message class handler.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1974) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1975) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1976) bfa_lps_isr(struct bfa_s *bfa, struct bfi_msg_s *m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1977) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1978) union bfi_lps_i2h_msg_u msg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1979)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1980) bfa_trc(bfa, m->mhdr.msg_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1981) msg.msg = m;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1982)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1983) switch (m->mhdr.msg_id) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1984) case BFI_LPS_I2H_LOGIN_RSP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1985) bfa_lps_login_rsp(bfa, msg.login_rsp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1986) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1987)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1988) case BFI_LPS_I2H_LOGOUT_RSP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1989) bfa_lps_logout_rsp(bfa, msg.logout_rsp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1990) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1991)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1992) case BFI_LPS_I2H_CVL_EVENT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1993) bfa_lps_rx_cvl_event(bfa, msg.cvl_event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1994) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1995)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1996) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1997) bfa_trc(bfa, m->mhdr.msg_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1998) WARN_ON(1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1999) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2000) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2001)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2002) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2003) bfa_fcport_aen_post(struct bfa_fcport_s *fcport, enum bfa_port_aen_event event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2004) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2005) struct bfad_s *bfad = (struct bfad_s *)fcport->bfa->bfad;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2006) struct bfa_aen_entry_s *aen_entry;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2007)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2008) bfad_get_aen_entry(bfad, aen_entry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2009) if (!aen_entry)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2010) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2011)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2012) aen_entry->aen_data.port.ioc_type = bfa_get_type(fcport->bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2013) aen_entry->aen_data.port.pwwn = fcport->pwwn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2014)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2015) /* Send the AEN notification */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2016) bfad_im_post_vendor_event(aen_entry, bfad, ++fcport->bfa->bfa_aen_seq,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2017) BFA_AEN_CAT_PORT, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2018) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2019)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2020) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2021) * FC PORT state machine functions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2022) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2023) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2024) bfa_fcport_sm_uninit(struct bfa_fcport_s *fcport,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2025) enum bfa_fcport_sm_event event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2026) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2027) bfa_trc(fcport->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2028)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2029) switch (event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2030) case BFA_FCPORT_SM_START:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2031) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2032) * Start event after IOC is configured and BFA is started.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2033) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2034) fcport->use_flash_cfg = BFA_TRUE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2035)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2036) if (bfa_fcport_send_enable(fcport)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2037) bfa_trc(fcport->bfa, BFA_TRUE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2038) bfa_sm_set_state(fcport, bfa_fcport_sm_enabling);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2039) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2040) bfa_trc(fcport->bfa, BFA_FALSE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2041) bfa_sm_set_state(fcport,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2042) bfa_fcport_sm_enabling_qwait);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2043) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2044) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2045)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2046) case BFA_FCPORT_SM_ENABLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2047) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2048) * Port is persistently configured to be in enabled state. Do
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2049) * not change state. Port enabling is done when START event is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2050) * received.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2051) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2052) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2053)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2054) case BFA_FCPORT_SM_DISABLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2055) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2056) * If a port is persistently configured to be disabled, the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2057) * first event will a port disable request.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2058) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2059) bfa_sm_set_state(fcport, bfa_fcport_sm_disabled);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2060) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2061)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2062) case BFA_FCPORT_SM_HWFAIL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2063) bfa_sm_set_state(fcport, bfa_fcport_sm_iocdown);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2064) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2065)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2066) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2067) bfa_sm_fault(fcport->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2068) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2069) }
^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_fcport_sm_enabling_qwait(struct bfa_fcport_s *fcport,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2073) enum bfa_fcport_sm_event event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2074) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2075) char pwwn_buf[BFA_STRING_32];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2076) struct bfad_s *bfad = (struct bfad_s *)fcport->bfa->bfad;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2077) bfa_trc(fcport->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2078)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2079) switch (event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2080) case BFA_FCPORT_SM_QRESUME:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2081) bfa_sm_set_state(fcport, bfa_fcport_sm_enabling);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2082) bfa_fcport_send_enable(fcport);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2083) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2084)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2085) case BFA_FCPORT_SM_STOP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2086) bfa_reqq_wcancel(&fcport->reqq_wait);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2087) bfa_sm_set_state(fcport, bfa_fcport_sm_stopped);
^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) case BFA_FCPORT_SM_ENABLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2091) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2092) * Already enable is in progress.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2093) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2094) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2095)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2096) case BFA_FCPORT_SM_DISABLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2097) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2098) * Just send disable request to firmware when room becomes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2099) * available in request queue.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2100) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2101) bfa_sm_set_state(fcport, bfa_fcport_sm_disabled);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2102) bfa_reqq_wcancel(&fcport->reqq_wait);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2103) bfa_plog_str(fcport->bfa->plog, BFA_PL_MID_HAL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2104) BFA_PL_EID_PORT_DISABLE, 0, "Port Disable");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2105) wwn2str(pwwn_buf, fcport->pwwn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2106) BFA_LOG(KERN_INFO, bfad, bfa_log_level,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2107) "Base port disabled: WWN = %s\n", pwwn_buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2108) bfa_fcport_aen_post(fcport, BFA_PORT_AEN_DISABLE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2109) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2110)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2111) case BFA_FCPORT_SM_LINKUP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2112) case BFA_FCPORT_SM_LINKDOWN:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2113) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2114) * Possible to get link events when doing back-to-back
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2115) * enable/disables.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2116) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2117) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2118)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2119) case BFA_FCPORT_SM_HWFAIL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2120) bfa_reqq_wcancel(&fcport->reqq_wait);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2121) bfa_sm_set_state(fcport, bfa_fcport_sm_iocdown);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2122) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2123)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2124) case BFA_FCPORT_SM_FAA_MISCONFIG:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2125) bfa_fcport_reset_linkinfo(fcport);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2126) bfa_fcport_aen_post(fcport, BFA_PORT_AEN_DISCONNECT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2127) bfa_sm_set_state(fcport, bfa_fcport_sm_faa_misconfig);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2128) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2129)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2130) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2131) bfa_sm_fault(fcport->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2132) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2133) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2134)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2135) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2136) bfa_fcport_sm_enabling(struct bfa_fcport_s *fcport,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2137) enum bfa_fcport_sm_event event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2138) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2139) char pwwn_buf[BFA_STRING_32];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2140) struct bfad_s *bfad = (struct bfad_s *)fcport->bfa->bfad;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2141) bfa_trc(fcport->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2142)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2143) switch (event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2144) case BFA_FCPORT_SM_FWRSP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2145) case BFA_FCPORT_SM_LINKDOWN:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2146) bfa_sm_set_state(fcport, bfa_fcport_sm_linkdown);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2147) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2148)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2149) case BFA_FCPORT_SM_LINKUP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2150) bfa_fcport_update_linkinfo(fcport);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2151) bfa_sm_set_state(fcport, bfa_fcport_sm_linkup);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2152)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2153) WARN_ON(!fcport->event_cbfn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2154) bfa_fcport_scn(fcport, BFA_PORT_LINKUP, BFA_FALSE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2155) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2156)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2157) case BFA_FCPORT_SM_ENABLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2158) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2159) * Already being enabled.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2160) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2161) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2162)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2163) case BFA_FCPORT_SM_DISABLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2164) if (bfa_fcport_send_disable(fcport))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2165) bfa_sm_set_state(fcport, bfa_fcport_sm_disabling);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2166) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2167) bfa_sm_set_state(fcport,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2168) bfa_fcport_sm_disabling_qwait);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2169)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2170) bfa_plog_str(fcport->bfa->plog, BFA_PL_MID_HAL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2171) BFA_PL_EID_PORT_DISABLE, 0, "Port Disable");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2172) wwn2str(pwwn_buf, fcport->pwwn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2173) BFA_LOG(KERN_INFO, bfad, bfa_log_level,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2174) "Base port disabled: WWN = %s\n", pwwn_buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2175) bfa_fcport_aen_post(fcport, BFA_PORT_AEN_DISABLE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2176) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2177)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2178) case BFA_FCPORT_SM_STOP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2179) bfa_sm_set_state(fcport, bfa_fcport_sm_stopped);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2180) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2181)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2182) case BFA_FCPORT_SM_HWFAIL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2183) bfa_sm_set_state(fcport, bfa_fcport_sm_iocdown);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2184) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2185)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2186) case BFA_FCPORT_SM_FAA_MISCONFIG:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2187) bfa_fcport_reset_linkinfo(fcport);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2188) bfa_fcport_aen_post(fcport, BFA_PORT_AEN_DISCONNECT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2189) bfa_sm_set_state(fcport, bfa_fcport_sm_faa_misconfig);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2190) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2191)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2192) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2193) bfa_sm_fault(fcport->bfa, event);
^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) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2198) bfa_fcport_sm_linkdown(struct bfa_fcport_s *fcport,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2199) enum bfa_fcport_sm_event event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2200) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2201) struct bfi_fcport_event_s *pevent = fcport->event_arg.i2hmsg.event;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2202) char pwwn_buf[BFA_STRING_32];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2203) struct bfad_s *bfad = (struct bfad_s *)fcport->bfa->bfad;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2204)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2205) bfa_trc(fcport->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2206)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2207) switch (event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2208) case BFA_FCPORT_SM_LINKUP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2209) bfa_fcport_update_linkinfo(fcport);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2210) bfa_sm_set_state(fcport, bfa_fcport_sm_linkup);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2211) WARN_ON(!fcport->event_cbfn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2212) bfa_plog_str(fcport->bfa->plog, BFA_PL_MID_HAL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2213) BFA_PL_EID_PORT_ST_CHANGE, 0, "Port Linkup");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2214) if (!bfa_ioc_get_fcmode(&fcport->bfa->ioc)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2215)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2216) bfa_trc(fcport->bfa,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2217) pevent->link_state.attr.vc_fcf.fcf.fipenabled);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2218) bfa_trc(fcport->bfa,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2219) pevent->link_state.attr.vc_fcf.fcf.fipfailed);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2220)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2221) if (pevent->link_state.attr.vc_fcf.fcf.fipfailed)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2222) bfa_plog_str(fcport->bfa->plog, BFA_PL_MID_HAL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2223) BFA_PL_EID_FIP_FCF_DISC, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2224) "FIP FCF Discovery Failed");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2225) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2226) bfa_plog_str(fcport->bfa->plog, BFA_PL_MID_HAL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2227) BFA_PL_EID_FIP_FCF_DISC, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2228) "FIP FCF Discovered");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2229) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2230)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2231) bfa_fcport_scn(fcport, BFA_PORT_LINKUP, BFA_FALSE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2232) wwn2str(pwwn_buf, fcport->pwwn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2233) BFA_LOG(KERN_INFO, bfad, bfa_log_level,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2234) "Base port online: WWN = %s\n", pwwn_buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2235) bfa_fcport_aen_post(fcport, BFA_PORT_AEN_ONLINE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2236)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2237) /* If QoS is enabled and it is not online, send AEN */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2238) if (fcport->cfg.qos_enabled &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2239) fcport->qos_attr.state != BFA_QOS_ONLINE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2240) bfa_fcport_aen_post(fcport, BFA_PORT_AEN_QOS_NEG);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2241) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2242)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2243) case BFA_FCPORT_SM_LINKDOWN:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2244) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2245) * Possible to get link down event.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2246) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2247) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2248)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2249) case BFA_FCPORT_SM_ENABLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2250) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2251) * Already enabled.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2252) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2253) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2254)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2255) case BFA_FCPORT_SM_DISABLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2256) if (bfa_fcport_send_disable(fcport))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2257) bfa_sm_set_state(fcport, bfa_fcport_sm_disabling);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2258) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2259) bfa_sm_set_state(fcport,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2260) bfa_fcport_sm_disabling_qwait);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2261)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2262) bfa_plog_str(fcport->bfa->plog, BFA_PL_MID_HAL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2263) BFA_PL_EID_PORT_DISABLE, 0, "Port Disable");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2264) wwn2str(pwwn_buf, fcport->pwwn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2265) BFA_LOG(KERN_INFO, bfad, bfa_log_level,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2266) "Base port disabled: WWN = %s\n", pwwn_buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2267) bfa_fcport_aen_post(fcport, BFA_PORT_AEN_DISABLE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2268) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2269)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2270) case BFA_FCPORT_SM_STOP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2271) bfa_sm_set_state(fcport, bfa_fcport_sm_stopped);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2272) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2273)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2274) case BFA_FCPORT_SM_HWFAIL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2275) bfa_sm_set_state(fcport, bfa_fcport_sm_iocdown);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2276) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2277)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2278) case BFA_FCPORT_SM_FAA_MISCONFIG:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2279) bfa_fcport_reset_linkinfo(fcport);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2280) bfa_fcport_aen_post(fcport, BFA_PORT_AEN_DISCONNECT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2281) bfa_sm_set_state(fcport, bfa_fcport_sm_faa_misconfig);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2282) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2283)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2284) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2285) bfa_sm_fault(fcport->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2286) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2287) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2288)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2289) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2290) bfa_fcport_sm_linkup(struct bfa_fcport_s *fcport,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2291) enum bfa_fcport_sm_event event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2292) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2293) char pwwn_buf[BFA_STRING_32];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2294) struct bfad_s *bfad = (struct bfad_s *)fcport->bfa->bfad;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2295)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2296) bfa_trc(fcport->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2297)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2298) switch (event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2299) case BFA_FCPORT_SM_ENABLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2300) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2301) * Already enabled.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2302) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2303) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2304)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2305) case BFA_FCPORT_SM_DISABLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2306) if (bfa_fcport_send_disable(fcport))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2307) bfa_sm_set_state(fcport, bfa_fcport_sm_disabling);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2308) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2309) bfa_sm_set_state(fcport,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2310) bfa_fcport_sm_disabling_qwait);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2311)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2312) bfa_fcport_reset_linkinfo(fcport);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2313) bfa_fcport_scn(fcport, BFA_PORT_LINKDOWN, BFA_FALSE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2314) bfa_plog_str(fcport->bfa->plog, BFA_PL_MID_HAL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2315) BFA_PL_EID_PORT_DISABLE, 0, "Port Disable");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2316) wwn2str(pwwn_buf, fcport->pwwn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2317) BFA_LOG(KERN_INFO, bfad, bfa_log_level,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2318) "Base port offline: WWN = %s\n", pwwn_buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2319) bfa_fcport_aen_post(fcport, BFA_PORT_AEN_OFFLINE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2320) BFA_LOG(KERN_INFO, bfad, bfa_log_level,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2321) "Base port disabled: WWN = %s\n", pwwn_buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2322) bfa_fcport_aen_post(fcport, BFA_PORT_AEN_DISABLE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2323) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2324)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2325) case BFA_FCPORT_SM_LINKDOWN:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2326) bfa_sm_set_state(fcport, bfa_fcport_sm_linkdown);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2327) bfa_fcport_reset_linkinfo(fcport);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2328) bfa_fcport_scn(fcport, BFA_PORT_LINKDOWN, BFA_FALSE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2329) bfa_plog_str(fcport->bfa->plog, BFA_PL_MID_HAL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2330) BFA_PL_EID_PORT_ST_CHANGE, 0, "Port Linkdown");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2331) wwn2str(pwwn_buf, fcport->pwwn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2332) if (BFA_PORT_IS_DISABLED(fcport->bfa)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2333) BFA_LOG(KERN_INFO, bfad, bfa_log_level,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2334) "Base port offline: WWN = %s\n", pwwn_buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2335) bfa_fcport_aen_post(fcport, BFA_PORT_AEN_OFFLINE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2336) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2337) BFA_LOG(KERN_ERR, bfad, bfa_log_level,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2338) "Base port (WWN = %s) "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2339) "lost fabric connectivity\n", pwwn_buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2340) bfa_fcport_aen_post(fcport, BFA_PORT_AEN_DISCONNECT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2341) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2342) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2343)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2344) case BFA_FCPORT_SM_STOP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2345) bfa_sm_set_state(fcport, bfa_fcport_sm_stopped);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2346) bfa_fcport_reset_linkinfo(fcport);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2347) wwn2str(pwwn_buf, fcport->pwwn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2348) if (BFA_PORT_IS_DISABLED(fcport->bfa)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2349) BFA_LOG(KERN_INFO, bfad, bfa_log_level,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2350) "Base port offline: WWN = %s\n", pwwn_buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2351) bfa_fcport_aen_post(fcport, BFA_PORT_AEN_OFFLINE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2352) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2353) BFA_LOG(KERN_ERR, bfad, bfa_log_level,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2354) "Base port (WWN = %s) "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2355) "lost fabric connectivity\n", pwwn_buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2356) bfa_fcport_aen_post(fcport, BFA_PORT_AEN_DISCONNECT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2357) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2358) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2359)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2360) case BFA_FCPORT_SM_HWFAIL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2361) bfa_sm_set_state(fcport, bfa_fcport_sm_iocdown);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2362) bfa_fcport_reset_linkinfo(fcport);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2363) bfa_fcport_scn(fcport, BFA_PORT_LINKDOWN, BFA_FALSE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2364) wwn2str(pwwn_buf, fcport->pwwn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2365) if (BFA_PORT_IS_DISABLED(fcport->bfa)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2366) BFA_LOG(KERN_INFO, bfad, bfa_log_level,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2367) "Base port offline: WWN = %s\n", pwwn_buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2368) bfa_fcport_aen_post(fcport, BFA_PORT_AEN_OFFLINE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2369) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2370) BFA_LOG(KERN_ERR, bfad, bfa_log_level,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2371) "Base port (WWN = %s) "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2372) "lost fabric connectivity\n", pwwn_buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2373) bfa_fcport_aen_post(fcport, BFA_PORT_AEN_DISCONNECT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2374) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2375) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2376)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2377) case BFA_FCPORT_SM_FAA_MISCONFIG:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2378) bfa_fcport_reset_linkinfo(fcport);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2379) bfa_fcport_aen_post(fcport, BFA_PORT_AEN_DISCONNECT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2380) bfa_sm_set_state(fcport, bfa_fcport_sm_faa_misconfig);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2381) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2382)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2383) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2384) bfa_sm_fault(fcport->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2385) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2386) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2387)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2388) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2389) bfa_fcport_sm_disabling_qwait(struct bfa_fcport_s *fcport,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2390) enum bfa_fcport_sm_event event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2391) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2392) bfa_trc(fcport->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2393)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2394) switch (event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2395) case BFA_FCPORT_SM_QRESUME:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2396) bfa_sm_set_state(fcport, bfa_fcport_sm_disabling);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2397) bfa_fcport_send_disable(fcport);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2398) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2399)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2400) case BFA_FCPORT_SM_STOP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2401) bfa_sm_set_state(fcport, bfa_fcport_sm_stopped);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2402) bfa_reqq_wcancel(&fcport->reqq_wait);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2403) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2404)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2405) case BFA_FCPORT_SM_ENABLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2406) bfa_sm_set_state(fcport, bfa_fcport_sm_toggling_qwait);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2407) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2408)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2409) case BFA_FCPORT_SM_DISABLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2410) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2411) * Already being disabled.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2412) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2413) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2414)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2415) case BFA_FCPORT_SM_LINKUP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2416) case BFA_FCPORT_SM_LINKDOWN:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2417) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2418) * Possible to get link events when doing back-to-back
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2419) * enable/disables.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2420) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2421) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2422)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2423) case BFA_FCPORT_SM_HWFAIL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2424) bfa_sm_set_state(fcport, bfa_fcport_sm_iocfail);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2425) bfa_reqq_wcancel(&fcport->reqq_wait);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2426) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2427)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2428) case BFA_FCPORT_SM_FAA_MISCONFIG:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2429) bfa_fcport_reset_linkinfo(fcport);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2430) bfa_fcport_aen_post(fcport, BFA_PORT_AEN_DISCONNECT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2431) bfa_sm_set_state(fcport, bfa_fcport_sm_faa_misconfig);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2432) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2433)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2434) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2435) bfa_sm_fault(fcport->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2436) }
^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) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2440) bfa_fcport_sm_toggling_qwait(struct bfa_fcport_s *fcport,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2441) enum bfa_fcport_sm_event event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2442) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2443) bfa_trc(fcport->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2444)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2445) switch (event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2446) case BFA_FCPORT_SM_QRESUME:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2447) bfa_sm_set_state(fcport, bfa_fcport_sm_disabling);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2448) bfa_fcport_send_disable(fcport);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2449) if (bfa_fcport_send_enable(fcport))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2450) bfa_sm_set_state(fcport, bfa_fcport_sm_enabling);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2451) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2452) bfa_sm_set_state(fcport,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2453) bfa_fcport_sm_enabling_qwait);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2454) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2455)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2456) case BFA_FCPORT_SM_STOP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2457) bfa_sm_set_state(fcport, bfa_fcport_sm_stopped);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2458) bfa_reqq_wcancel(&fcport->reqq_wait);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2459) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2460)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2461) case BFA_FCPORT_SM_ENABLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2462) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2463)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2464) case BFA_FCPORT_SM_DISABLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2465) bfa_sm_set_state(fcport, bfa_fcport_sm_disabling_qwait);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2466) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2467)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2468) case BFA_FCPORT_SM_LINKUP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2469) case BFA_FCPORT_SM_LINKDOWN:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2470) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2471) * Possible to get link events when doing back-to-back
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2472) * enable/disables.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2473) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2474) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2475)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2476) case BFA_FCPORT_SM_HWFAIL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2477) bfa_sm_set_state(fcport, bfa_fcport_sm_iocfail);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2478) bfa_reqq_wcancel(&fcport->reqq_wait);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2479) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2480)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2481) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2482) bfa_sm_fault(fcport->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2483) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2484) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2485)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2486) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2487) bfa_fcport_sm_disabling(struct bfa_fcport_s *fcport,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2488) enum bfa_fcport_sm_event event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2489) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2490) char pwwn_buf[BFA_STRING_32];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2491) struct bfad_s *bfad = (struct bfad_s *)fcport->bfa->bfad;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2492) bfa_trc(fcport->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2493)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2494) switch (event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2495) case BFA_FCPORT_SM_FWRSP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2496) bfa_sm_set_state(fcport, bfa_fcport_sm_disabled);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2497) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2498)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2499) case BFA_FCPORT_SM_DISABLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2500) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2501) * Already being disabled.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2502) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2503) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2504)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2505) case BFA_FCPORT_SM_ENABLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2506) if (bfa_fcport_send_enable(fcport))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2507) bfa_sm_set_state(fcport, bfa_fcport_sm_enabling);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2508) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2509) bfa_sm_set_state(fcport,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2510) bfa_fcport_sm_enabling_qwait);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2511)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2512) bfa_plog_str(fcport->bfa->plog, BFA_PL_MID_HAL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2513) BFA_PL_EID_PORT_ENABLE, 0, "Port Enable");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2514) wwn2str(pwwn_buf, fcport->pwwn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2515) BFA_LOG(KERN_INFO, bfad, bfa_log_level,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2516) "Base port enabled: WWN = %s\n", pwwn_buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2517) bfa_fcport_aen_post(fcport, BFA_PORT_AEN_ENABLE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2518) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2519)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2520) case BFA_FCPORT_SM_STOP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2521) bfa_sm_set_state(fcport, bfa_fcport_sm_stopped);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2522) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2523)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2524) case BFA_FCPORT_SM_LINKUP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2525) case BFA_FCPORT_SM_LINKDOWN:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2526) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2527) * Possible to get link events when doing back-to-back
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2528) * enable/disables.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2529) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2530) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2531)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2532) case BFA_FCPORT_SM_HWFAIL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2533) bfa_sm_set_state(fcport, bfa_fcport_sm_iocfail);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2534) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2535)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2536) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2537) bfa_sm_fault(fcport->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2538) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2539) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2540)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2541) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2542) bfa_fcport_sm_disabled(struct bfa_fcport_s *fcport,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2543) enum bfa_fcport_sm_event event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2544) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2545) char pwwn_buf[BFA_STRING_32];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2546) struct bfad_s *bfad = (struct bfad_s *)fcport->bfa->bfad;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2547) bfa_trc(fcport->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2548)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2549) switch (event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2550) case BFA_FCPORT_SM_START:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2551) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2552) * Ignore start event for a port that is disabled.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2553) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2554) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2555)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2556) case BFA_FCPORT_SM_STOP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2557) bfa_sm_set_state(fcport, bfa_fcport_sm_stopped);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2558) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2559)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2560) case BFA_FCPORT_SM_ENABLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2561) if (bfa_fcport_send_enable(fcport))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2562) bfa_sm_set_state(fcport, bfa_fcport_sm_enabling);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2563) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2564) bfa_sm_set_state(fcport,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2565) bfa_fcport_sm_enabling_qwait);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2566)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2567) bfa_plog_str(fcport->bfa->plog, BFA_PL_MID_HAL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2568) BFA_PL_EID_PORT_ENABLE, 0, "Port Enable");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2569) wwn2str(pwwn_buf, fcport->pwwn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2570) BFA_LOG(KERN_INFO, bfad, bfa_log_level,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2571) "Base port enabled: WWN = %s\n", pwwn_buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2572) bfa_fcport_aen_post(fcport, BFA_PORT_AEN_ENABLE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2573) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2574)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2575) case BFA_FCPORT_SM_DISABLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2576) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2577) * Already disabled.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2578) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2579) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2580)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2581) case BFA_FCPORT_SM_HWFAIL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2582) bfa_sm_set_state(fcport, bfa_fcport_sm_iocfail);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2583) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2584)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2585) case BFA_FCPORT_SM_DPORTENABLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2586) bfa_sm_set_state(fcport, bfa_fcport_sm_dport);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2587) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2588)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2589) case BFA_FCPORT_SM_DDPORTENABLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2590) bfa_sm_set_state(fcport, bfa_fcport_sm_ddport);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2591) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2592)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2593) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2594) bfa_sm_fault(fcport->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2595) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2596) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2597)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2598) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2599) bfa_fcport_sm_stopped(struct bfa_fcport_s *fcport,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2600) enum bfa_fcport_sm_event event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2601) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2602) bfa_trc(fcport->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2603)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2604) switch (event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2605) case BFA_FCPORT_SM_START:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2606) if (bfa_fcport_send_enable(fcport))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2607) bfa_sm_set_state(fcport, bfa_fcport_sm_enabling);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2608) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2609) bfa_sm_set_state(fcport,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2610) bfa_fcport_sm_enabling_qwait);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2611) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2612)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2613) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2614) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2615) * Ignore all other events.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2616) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2617) ;
^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) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2622) * Port is enabled. IOC is down/failed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2623) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2624) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2625) bfa_fcport_sm_iocdown(struct bfa_fcport_s *fcport,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2626) enum bfa_fcport_sm_event event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2627) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2628) bfa_trc(fcport->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2629)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2630) switch (event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2631) case BFA_FCPORT_SM_START:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2632) if (bfa_fcport_send_enable(fcport))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2633) bfa_sm_set_state(fcport, bfa_fcport_sm_enabling);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2634) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2635) bfa_sm_set_state(fcport,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2636) bfa_fcport_sm_enabling_qwait);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2637) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2638)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2639) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2640) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2641) * Ignore all events.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2642) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2643) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2644) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2645) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2646)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2647) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2648) * Port is disabled. IOC is down/failed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2649) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2650) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2651) bfa_fcport_sm_iocfail(struct bfa_fcport_s *fcport,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2652) enum bfa_fcport_sm_event event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2653) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2654) bfa_trc(fcport->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2655)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2656) switch (event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2657) case BFA_FCPORT_SM_START:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2658) bfa_sm_set_state(fcport, bfa_fcport_sm_disabled);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2659) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2660)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2661) case BFA_FCPORT_SM_ENABLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2662) bfa_sm_set_state(fcport, bfa_fcport_sm_iocdown);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2663) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2664)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2665) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2666) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2667) * Ignore all events.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2668) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2669) ;
^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)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2673) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2674) bfa_fcport_sm_dport(struct bfa_fcport_s *fcport, enum bfa_fcport_sm_event event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2675) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2676) bfa_trc(fcport->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2677)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2678) switch (event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2679) case BFA_FCPORT_SM_DPORTENABLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2680) case BFA_FCPORT_SM_DISABLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2681) case BFA_FCPORT_SM_ENABLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2682) case BFA_FCPORT_SM_START:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2683) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2684) * Ignore event for a port that is dport
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2685) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2686) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2687)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2688) case BFA_FCPORT_SM_STOP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2689) bfa_sm_set_state(fcport, bfa_fcport_sm_stopped);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2690) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2691)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2692) case BFA_FCPORT_SM_HWFAIL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2693) bfa_sm_set_state(fcport, bfa_fcport_sm_iocfail);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2694) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2695)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2696) case BFA_FCPORT_SM_DPORTDISABLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2697) bfa_sm_set_state(fcport, bfa_fcport_sm_disabled);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2698) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2699)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2700) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2701) bfa_sm_fault(fcport->bfa, event);
^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)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2705) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2706) bfa_fcport_sm_ddport(struct bfa_fcport_s *fcport,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2707) enum bfa_fcport_sm_event event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2708) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2709) bfa_trc(fcport->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2710)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2711) switch (event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2712) case BFA_FCPORT_SM_DISABLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2713) case BFA_FCPORT_SM_DDPORTDISABLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2714) bfa_sm_set_state(fcport, bfa_fcport_sm_disabled);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2715) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2716)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2717) case BFA_FCPORT_SM_DPORTENABLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2718) case BFA_FCPORT_SM_DPORTDISABLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2719) case BFA_FCPORT_SM_ENABLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2720) case BFA_FCPORT_SM_START:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2721) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2722) * Ignore event for a port that is ddport
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2723) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2724) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2725)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2726) case BFA_FCPORT_SM_STOP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2727) bfa_sm_set_state(fcport, bfa_fcport_sm_stopped);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2728) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2729)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2730) case BFA_FCPORT_SM_HWFAIL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2731) bfa_sm_set_state(fcport, bfa_fcport_sm_iocfail);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2732) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2733)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2734) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2735) bfa_sm_fault(fcport->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2736) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2737) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2738)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2739) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2740) bfa_fcport_sm_faa_misconfig(struct bfa_fcport_s *fcport,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2741) enum bfa_fcport_sm_event event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2742) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2743) bfa_trc(fcport->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2744)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2745) switch (event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2746) case BFA_FCPORT_SM_DPORTENABLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2747) case BFA_FCPORT_SM_ENABLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2748) case BFA_FCPORT_SM_START:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2749) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2750) * Ignore event for a port as there is FAA misconfig
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2751) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2752) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2753)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2754) case BFA_FCPORT_SM_DISABLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2755) if (bfa_fcport_send_disable(fcport))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2756) bfa_sm_set_state(fcport, bfa_fcport_sm_disabling);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2757) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2758) bfa_sm_set_state(fcport, bfa_fcport_sm_disabling_qwait);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2759)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2760) bfa_fcport_reset_linkinfo(fcport);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2761) bfa_fcport_scn(fcport, BFA_PORT_LINKDOWN, BFA_FALSE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2762) bfa_plog_str(fcport->bfa->plog, BFA_PL_MID_HAL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2763) BFA_PL_EID_PORT_DISABLE, 0, "Port Disable");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2764) bfa_fcport_aen_post(fcport, BFA_PORT_AEN_DISABLE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2765) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2766)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2767) case BFA_FCPORT_SM_STOP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2768) bfa_sm_set_state(fcport, bfa_fcport_sm_stopped);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2769) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2770)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2771) case BFA_FCPORT_SM_HWFAIL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2772) bfa_fcport_reset_linkinfo(fcport);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2773) bfa_fcport_scn(fcport, BFA_PORT_LINKDOWN, BFA_FALSE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2774) bfa_sm_set_state(fcport, bfa_fcport_sm_iocdown);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2775) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2776)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2777) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2778) bfa_sm_fault(fcport->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2779) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2780) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2781)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2782) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2783) * Link state is down
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2784) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2785) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2786) bfa_fcport_ln_sm_dn(struct bfa_fcport_ln_s *ln,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2787) enum bfa_fcport_ln_sm_event event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2788) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2789) bfa_trc(ln->fcport->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2790)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2791) switch (event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2792) case BFA_FCPORT_LN_SM_LINKUP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2793) bfa_sm_set_state(ln, bfa_fcport_ln_sm_up_nf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2794) bfa_fcport_queue_cb(ln, BFA_PORT_LINKUP);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2795) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2796)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2797) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2798) bfa_sm_fault(ln->fcport->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2799) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2800) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2801)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2802) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2803) * Link state is waiting for down notification
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2804) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2805) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2806) bfa_fcport_ln_sm_dn_nf(struct bfa_fcport_ln_s *ln,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2807) enum bfa_fcport_ln_sm_event event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2808) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2809) bfa_trc(ln->fcport->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2810)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2811) switch (event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2812) case BFA_FCPORT_LN_SM_LINKUP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2813) bfa_sm_set_state(ln, bfa_fcport_ln_sm_dn_up_nf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2814) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2815)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2816) case BFA_FCPORT_LN_SM_NOTIFICATION:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2817) bfa_sm_set_state(ln, bfa_fcport_ln_sm_dn);
^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) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2821) bfa_sm_fault(ln->fcport->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2822) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2823) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2824)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2825) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2826) * Link state is waiting for down notification and there is a pending up
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2827) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2828) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2829) bfa_fcport_ln_sm_dn_up_nf(struct bfa_fcport_ln_s *ln,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2830) enum bfa_fcport_ln_sm_event event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2831) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2832) bfa_trc(ln->fcport->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2833)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2834) switch (event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2835) case BFA_FCPORT_LN_SM_LINKDOWN:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2836) bfa_sm_set_state(ln, bfa_fcport_ln_sm_dn_nf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2837) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2838)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2839) case BFA_FCPORT_LN_SM_NOTIFICATION:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2840) bfa_sm_set_state(ln, bfa_fcport_ln_sm_up_nf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2841) bfa_fcport_queue_cb(ln, BFA_PORT_LINKUP);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2842) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2843)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2844) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2845) bfa_sm_fault(ln->fcport->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2846) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2847) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2848)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2849) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2850) * Link state is up
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2851) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2852) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2853) bfa_fcport_ln_sm_up(struct bfa_fcport_ln_s *ln,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2854) enum bfa_fcport_ln_sm_event event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2855) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2856) bfa_trc(ln->fcport->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2857)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2858) switch (event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2859) case BFA_FCPORT_LN_SM_LINKDOWN:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2860) bfa_sm_set_state(ln, bfa_fcport_ln_sm_dn_nf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2861) bfa_fcport_queue_cb(ln, BFA_PORT_LINKDOWN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2862) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2863)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2864) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2865) bfa_sm_fault(ln->fcport->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2866) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2867) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2868)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2869) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2870) * Link state is waiting for up notification
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2871) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2872) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2873) bfa_fcport_ln_sm_up_nf(struct bfa_fcport_ln_s *ln,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2874) enum bfa_fcport_ln_sm_event event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2875) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2876) bfa_trc(ln->fcport->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2877)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2878) switch (event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2879) case BFA_FCPORT_LN_SM_LINKDOWN:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2880) bfa_sm_set_state(ln, bfa_fcport_ln_sm_up_dn_nf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2881) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2882)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2883) case BFA_FCPORT_LN_SM_NOTIFICATION:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2884) bfa_sm_set_state(ln, bfa_fcport_ln_sm_up);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2885) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2886)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2887) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2888) bfa_sm_fault(ln->fcport->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2889) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2890) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2891)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2892) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2893) * Link state is waiting for up notification and there is a pending down
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2894) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2895) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2896) bfa_fcport_ln_sm_up_dn_nf(struct bfa_fcport_ln_s *ln,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2897) enum bfa_fcport_ln_sm_event event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2898) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2899) bfa_trc(ln->fcport->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2900)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2901) switch (event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2902) case BFA_FCPORT_LN_SM_LINKUP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2903) bfa_sm_set_state(ln, bfa_fcport_ln_sm_up_dn_up_nf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2904) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2905)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2906) case BFA_FCPORT_LN_SM_NOTIFICATION:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2907) bfa_sm_set_state(ln, bfa_fcport_ln_sm_dn_nf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2908) bfa_fcport_queue_cb(ln, BFA_PORT_LINKDOWN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2909) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2910)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2911) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2912) bfa_sm_fault(ln->fcport->bfa, event);
^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) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2917) * Link state is waiting for up notification and there are pending down and up
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2918) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2919) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2920) bfa_fcport_ln_sm_up_dn_up_nf(struct bfa_fcport_ln_s *ln,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2921) enum bfa_fcport_ln_sm_event event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2922) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2923) bfa_trc(ln->fcport->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2924)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2925) switch (event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2926) case BFA_FCPORT_LN_SM_LINKDOWN:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2927) bfa_sm_set_state(ln, bfa_fcport_ln_sm_up_dn_nf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2928) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2929)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2930) case BFA_FCPORT_LN_SM_NOTIFICATION:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2931) bfa_sm_set_state(ln, bfa_fcport_ln_sm_dn_up_nf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2932) bfa_fcport_queue_cb(ln, BFA_PORT_LINKDOWN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2933) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2934)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2935) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2936) bfa_sm_fault(ln->fcport->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2937) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2938) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2939)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2940) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2941) __bfa_cb_fcport_event(void *cbarg, bfa_boolean_t complete)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2942) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2943) struct bfa_fcport_ln_s *ln = cbarg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2944)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2945) if (complete)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2946) ln->fcport->event_cbfn(ln->fcport->event_cbarg, ln->ln_event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2947) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2948) bfa_sm_send_event(ln, BFA_FCPORT_LN_SM_NOTIFICATION);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2949) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2950)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2951) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2952) * Send SCN notification to upper layers.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2953) * trunk - false if caller is fcport to ignore fcport event in trunked mode
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2954) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2955) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2956) bfa_fcport_scn(struct bfa_fcport_s *fcport, enum bfa_port_linkstate event,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2957) bfa_boolean_t trunk)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2958) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2959) if (fcport->cfg.trunked && !trunk)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2960) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2961)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2962) switch (event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2963) case BFA_PORT_LINKUP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2964) bfa_sm_send_event(&fcport->ln, BFA_FCPORT_LN_SM_LINKUP);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2965) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2966) case BFA_PORT_LINKDOWN:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2967) bfa_sm_send_event(&fcport->ln, BFA_FCPORT_LN_SM_LINKDOWN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2968) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2969) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2970) WARN_ON(1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2971) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2972) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2973)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2974) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2975) bfa_fcport_queue_cb(struct bfa_fcport_ln_s *ln, enum bfa_port_linkstate event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2976) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2977) struct bfa_fcport_s *fcport = ln->fcport;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2978)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2979) if (fcport->bfa->fcs) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2980) fcport->event_cbfn(fcport->event_cbarg, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2981) bfa_sm_send_event(ln, BFA_FCPORT_LN_SM_NOTIFICATION);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2982) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2983) ln->ln_event = event;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2984) bfa_cb_queue(fcport->bfa, &ln->ln_qe,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2985) __bfa_cb_fcport_event, ln);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2986) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2987) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2988)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2989) #define FCPORT_STATS_DMA_SZ (BFA_ROUNDUP(sizeof(union bfa_fcport_stats_u), \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2990) BFA_CACHELINE_SZ))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2991)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2992) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2993) bfa_fcport_meminfo(struct bfa_iocfc_cfg_s *cfg, struct bfa_meminfo_s *minfo,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2994) struct bfa_s *bfa)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2995) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2996) struct bfa_mem_dma_s *fcport_dma = BFA_MEM_FCPORT_DMA(bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2997)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2998) bfa_mem_dma_setup(minfo, fcport_dma, FCPORT_STATS_DMA_SZ);
^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) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3002) bfa_fcport_qresume(void *cbarg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3003) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3004) struct bfa_fcport_s *fcport = cbarg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3005)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3006) bfa_sm_send_event(fcport, BFA_FCPORT_SM_QRESUME);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3007) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3008)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3009) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3010) bfa_fcport_mem_claim(struct bfa_fcport_s *fcport)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3011) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3012) struct bfa_mem_dma_s *fcport_dma = &fcport->fcport_dma;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3013)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3014) fcport->stats_kva = bfa_mem_dma_virt(fcport_dma);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3015) fcport->stats_pa = bfa_mem_dma_phys(fcport_dma);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3016) fcport->stats = (union bfa_fcport_stats_u *)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3017) bfa_mem_dma_virt(fcport_dma);
^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) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3021) * Memory initialization.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3022) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3023) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3024) bfa_fcport_attach(struct bfa_s *bfa, void *bfad, struct bfa_iocfc_cfg_s *cfg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3025) struct bfa_pcidev_s *pcidev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3026) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3027) struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3028) struct bfa_port_cfg_s *port_cfg = &fcport->cfg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3029) struct bfa_fcport_ln_s *ln = &fcport->ln;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3030)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3031) fcport->bfa = bfa;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3032) ln->fcport = fcport;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3033)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3034) bfa_fcport_mem_claim(fcport);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3035)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3036) bfa_sm_set_state(fcport, bfa_fcport_sm_uninit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3037) bfa_sm_set_state(ln, bfa_fcport_ln_sm_dn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3038)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3039) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3040) * initialize time stamp for stats reset
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3041) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3042) fcport->stats_reset_time = ktime_get_seconds();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3043) fcport->stats_dma_ready = BFA_FALSE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3044)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3045) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3046) * initialize and set default configuration
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3047) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3048) port_cfg->topology = BFA_PORT_TOPOLOGY_P2P;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3049) port_cfg->speed = BFA_PORT_SPEED_AUTO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3050) port_cfg->trunked = BFA_FALSE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3051) port_cfg->maxfrsize = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3052)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3053) port_cfg->trl_def_speed = BFA_PORT_SPEED_1GBPS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3054) port_cfg->qos_bw.high = BFA_QOS_BW_HIGH;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3055) port_cfg->qos_bw.med = BFA_QOS_BW_MED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3056) port_cfg->qos_bw.low = BFA_QOS_BW_LOW;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3057)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3058) fcport->fec_state = BFA_FEC_OFFLINE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3059)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3060) INIT_LIST_HEAD(&fcport->stats_pending_q);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3061) INIT_LIST_HEAD(&fcport->statsclr_pending_q);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3062)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3063) bfa_reqq_winit(&fcport->reqq_wait, bfa_fcport_qresume, fcport);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3064) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3065)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3066) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3067) bfa_fcport_start(struct bfa_s *bfa)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3068) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3069) bfa_sm_send_event(BFA_FCPORT_MOD(bfa), BFA_FCPORT_SM_START);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3070) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3071)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3072) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3073) * Called when IOC failure is detected.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3074) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3075) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3076) bfa_fcport_iocdisable(struct bfa_s *bfa)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3077) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3078) struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3079)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3080) bfa_sm_send_event(fcport, BFA_FCPORT_SM_HWFAIL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3081) bfa_trunk_iocdisable(bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3082) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3083)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3084) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3085) * Update loop info in fcport for SCN online
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3086) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3087) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3088) bfa_fcport_update_loop_info(struct bfa_fcport_s *fcport,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3089) struct bfa_fcport_loop_info_s *loop_info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3090) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3091) fcport->myalpa = loop_info->myalpa;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3092) fcport->alpabm_valid =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3093) loop_info->alpabm_val;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3094) memcpy(fcport->alpabm.alpa_bm,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3095) loop_info->alpabm.alpa_bm,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3096) sizeof(struct fc_alpabm_s));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3097) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3098)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3099) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3100) bfa_fcport_update_linkinfo(struct bfa_fcport_s *fcport)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3101) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3102) struct bfi_fcport_event_s *pevent = fcport->event_arg.i2hmsg.event;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3103) struct bfa_fcport_trunk_s *trunk = &fcport->trunk;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3104)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3105) fcport->speed = pevent->link_state.speed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3106) fcport->topology = pevent->link_state.topology;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3107)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3108) if (fcport->topology == BFA_PORT_TOPOLOGY_LOOP) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3109) bfa_fcport_update_loop_info(fcport,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3110) &pevent->link_state.attr.loop_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3111) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3112) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3113)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3114) /* QoS Details */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3115) fcport->qos_attr = pevent->link_state.qos_attr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3116) fcport->qos_vc_attr = pevent->link_state.attr.vc_fcf.qos_vc_attr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3117)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3118) if (fcport->cfg.bb_cr_enabled)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3119) fcport->bbcr_attr = pevent->link_state.attr.bbcr_attr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3120)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3121) fcport->fec_state = pevent->link_state.fec_state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3122)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3123) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3124) * update trunk state if applicable
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3125) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3126) if (!fcport->cfg.trunked)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3127) trunk->attr.state = BFA_TRUNK_DISABLED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3128)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3129) /* update FCoE specific */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3130) fcport->fcoe_vlan =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3131) be16_to_cpu(pevent->link_state.attr.vc_fcf.fcf.vlan);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3132)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3133) bfa_trc(fcport->bfa, fcport->speed);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3134) bfa_trc(fcport->bfa, fcport->topology);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3135) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3136)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3137) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3138) bfa_fcport_reset_linkinfo(struct bfa_fcport_s *fcport)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3139) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3140) fcport->speed = BFA_PORT_SPEED_UNKNOWN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3141) fcport->topology = BFA_PORT_TOPOLOGY_NONE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3142) fcport->fec_state = BFA_FEC_OFFLINE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3143) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3144)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3145) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3146) * Send port enable message to firmware.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3147) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3148) static bfa_boolean_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3149) bfa_fcport_send_enable(struct bfa_fcport_s *fcport)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3150) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3151) struct bfi_fcport_enable_req_s *m;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3152)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3153) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3154) * Increment message tag before queue check, so that responses to old
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3155) * requests are discarded.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3156) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3157) fcport->msgtag++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3158)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3159) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3160) * check for room in queue to send request now
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3161) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3162) m = bfa_reqq_next(fcport->bfa, BFA_REQQ_PORT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3163) if (!m) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3164) bfa_reqq_wait(fcport->bfa, BFA_REQQ_PORT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3165) &fcport->reqq_wait);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3166) return BFA_FALSE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3167) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3168)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3169) bfi_h2i_set(m->mh, BFI_MC_FCPORT, BFI_FCPORT_H2I_ENABLE_REQ,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3170) bfa_fn_lpu(fcport->bfa));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3171) m->nwwn = fcport->nwwn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3172) m->pwwn = fcport->pwwn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3173) m->port_cfg = fcport->cfg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3174) m->msgtag = fcport->msgtag;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3175) m->port_cfg.maxfrsize = cpu_to_be16(fcport->cfg.maxfrsize);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3176) m->use_flash_cfg = fcport->use_flash_cfg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3177) bfa_dma_be_addr_set(m->stats_dma_addr, fcport->stats_pa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3178) bfa_trc(fcport->bfa, m->stats_dma_addr.a32.addr_lo);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3179) bfa_trc(fcport->bfa, m->stats_dma_addr.a32.addr_hi);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3180)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3181) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3182) * queue I/O message to firmware
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3183) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3184) bfa_reqq_produce(fcport->bfa, BFA_REQQ_PORT, m->mh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3185) return BFA_TRUE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3186) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3187)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3188) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3189) * Send port disable message to firmware.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3190) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3191) static bfa_boolean_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3192) bfa_fcport_send_disable(struct bfa_fcport_s *fcport)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3193) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3194) struct bfi_fcport_req_s *m;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3195)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3196) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3197) * Increment message tag before queue check, so that responses to old
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3198) * requests are discarded.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3199) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3200) fcport->msgtag++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3201)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3202) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3203) * check for room in queue to send request now
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3204) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3205) m = bfa_reqq_next(fcport->bfa, BFA_REQQ_PORT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3206) if (!m) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3207) bfa_reqq_wait(fcport->bfa, BFA_REQQ_PORT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3208) &fcport->reqq_wait);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3209) return BFA_FALSE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3210) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3211)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3212) bfi_h2i_set(m->mh, BFI_MC_FCPORT, BFI_FCPORT_H2I_DISABLE_REQ,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3213) bfa_fn_lpu(fcport->bfa));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3214) m->msgtag = fcport->msgtag;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3215)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3216) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3217) * queue I/O message to firmware
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3218) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3219) bfa_reqq_produce(fcport->bfa, BFA_REQQ_PORT, m->mh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3220)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3221) return BFA_TRUE;
^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) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3225) bfa_fcport_set_wwns(struct bfa_fcport_s *fcport)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3226) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3227) fcport->pwwn = fcport->bfa->ioc.attr->pwwn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3228) fcport->nwwn = fcport->bfa->ioc.attr->nwwn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3229)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3230) bfa_trc(fcport->bfa, fcport->pwwn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3231) bfa_trc(fcport->bfa, fcport->nwwn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3232) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3233)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3234) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3235) bfa_fcport_qos_stats_swap(struct bfa_qos_stats_s *d,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3236) struct bfa_qos_stats_s *s)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3237) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3238) u32 *dip = (u32 *) d;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3239) __be32 *sip = (__be32 *) s;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3240) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3241)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3242) /* Now swap the 32 bit fields */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3243) for (i = 0; i < (sizeof(struct bfa_qos_stats_s)/sizeof(u32)); ++i)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3244) dip[i] = be32_to_cpu(sip[i]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3245) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3246)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3247) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3248) bfa_fcport_fcoe_stats_swap(struct bfa_fcoe_stats_s *d,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3249) struct bfa_fcoe_stats_s *s)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3250) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3251) u32 *dip = (u32 *) d;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3252) __be32 *sip = (__be32 *) s;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3253) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3254)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3255) for (i = 0; i < ((sizeof(struct bfa_fcoe_stats_s))/sizeof(u32));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3256) i = i + 2) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3257) #ifdef __BIG_ENDIAN
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3258) dip[i] = be32_to_cpu(sip[i]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3259) dip[i + 1] = be32_to_cpu(sip[i + 1]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3260) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3261) dip[i] = be32_to_cpu(sip[i + 1]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3262) dip[i + 1] = be32_to_cpu(sip[i]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3263) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3264) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3265) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3266)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3267) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3268) __bfa_cb_fcport_stats_get(void *cbarg, bfa_boolean_t complete)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3269) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3270) struct bfa_fcport_s *fcport = (struct bfa_fcport_s *)cbarg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3271) struct bfa_cb_pending_q_s *cb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3272) struct list_head *qe, *qen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3273) union bfa_fcport_stats_u *ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3274)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3275) if (complete) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3276) time64_t time = ktime_get_seconds();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3277)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3278) list_for_each_safe(qe, qen, &fcport->stats_pending_q) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3279) bfa_q_deq(&fcport->stats_pending_q, &qe);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3280) cb = (struct bfa_cb_pending_q_s *)qe;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3281) if (fcport->stats_status == BFA_STATUS_OK) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3282) ret = (union bfa_fcport_stats_u *)cb->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3283) /* Swap FC QoS or FCoE stats */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3284) if (bfa_ioc_get_fcmode(&fcport->bfa->ioc))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3285) bfa_fcport_qos_stats_swap(&ret->fcqos,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3286) &fcport->stats->fcqos);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3287) else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3288) bfa_fcport_fcoe_stats_swap(&ret->fcoe,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3289) &fcport->stats->fcoe);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3290) ret->fcoe.secs_reset =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3291) time - fcport->stats_reset_time;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3292) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3293) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3294) bfa_cb_queue_status(fcport->bfa, &cb->hcb_qe,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3295) fcport->stats_status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3296) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3297) fcport->stats_status = BFA_STATUS_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3298) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3299) INIT_LIST_HEAD(&fcport->stats_pending_q);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3300) fcport->stats_status = BFA_STATUS_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3301) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3302) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3303)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3304) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3305) bfa_fcport_stats_get_timeout(void *cbarg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3306) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3307) struct bfa_fcport_s *fcport = (struct bfa_fcport_s *) cbarg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3308)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3309) bfa_trc(fcport->bfa, fcport->stats_qfull);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3310)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3311) if (fcport->stats_qfull) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3312) bfa_reqq_wcancel(&fcport->stats_reqq_wait);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3313) fcport->stats_qfull = BFA_FALSE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3314) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3315)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3316) fcport->stats_status = BFA_STATUS_ETIMER;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3317) __bfa_cb_fcport_stats_get(fcport, BFA_TRUE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3318) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3319)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3320) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3321) bfa_fcport_send_stats_get(void *cbarg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3322) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3323) struct bfa_fcport_s *fcport = (struct bfa_fcport_s *) cbarg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3324) struct bfi_fcport_req_s *msg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3325)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3326) msg = bfa_reqq_next(fcport->bfa, BFA_REQQ_PORT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3327)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3328) if (!msg) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3329) fcport->stats_qfull = BFA_TRUE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3330) bfa_reqq_winit(&fcport->stats_reqq_wait,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3331) bfa_fcport_send_stats_get, fcport);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3332) bfa_reqq_wait(fcport->bfa, BFA_REQQ_PORT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3333) &fcport->stats_reqq_wait);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3334) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3335) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3336) fcport->stats_qfull = BFA_FALSE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3337)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3338) memset(msg, 0, sizeof(struct bfi_fcport_req_s));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3339) bfi_h2i_set(msg->mh, BFI_MC_FCPORT, BFI_FCPORT_H2I_STATS_GET_REQ,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3340) bfa_fn_lpu(fcport->bfa));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3341) bfa_reqq_produce(fcport->bfa, BFA_REQQ_PORT, msg->mh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3342) }
^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_cb_fcport_stats_clr(void *cbarg, bfa_boolean_t complete)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3346) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3347) struct bfa_fcport_s *fcport = (struct bfa_fcport_s *) cbarg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3348) struct bfa_cb_pending_q_s *cb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3349) struct list_head *qe, *qen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3350)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3351) if (complete) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3352) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3353) * re-initialize time stamp for stats reset
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3354) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3355) fcport->stats_reset_time = ktime_get_seconds();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3356) list_for_each_safe(qe, qen, &fcport->statsclr_pending_q) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3357) bfa_q_deq(&fcport->statsclr_pending_q, &qe);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3358) cb = (struct bfa_cb_pending_q_s *)qe;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3359) bfa_cb_queue_status(fcport->bfa, &cb->hcb_qe,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3360) fcport->stats_status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3361) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3362) fcport->stats_status = BFA_STATUS_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3363) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3364) INIT_LIST_HEAD(&fcport->statsclr_pending_q);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3365) fcport->stats_status = BFA_STATUS_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3366) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3367) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3368)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3369) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3370) bfa_fcport_stats_clr_timeout(void *cbarg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3371) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3372) struct bfa_fcport_s *fcport = (struct bfa_fcport_s *) cbarg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3373)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3374) bfa_trc(fcport->bfa, fcport->stats_qfull);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3375)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3376) if (fcport->stats_qfull) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3377) bfa_reqq_wcancel(&fcport->stats_reqq_wait);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3378) fcport->stats_qfull = BFA_FALSE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3379) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3380)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3381) fcport->stats_status = BFA_STATUS_ETIMER;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3382) __bfa_cb_fcport_stats_clr(fcport, BFA_TRUE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3383) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3384)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3385) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3386) bfa_fcport_send_stats_clear(void *cbarg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3387) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3388) struct bfa_fcport_s *fcport = (struct bfa_fcport_s *) cbarg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3389) struct bfi_fcport_req_s *msg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3390)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3391) msg = bfa_reqq_next(fcport->bfa, BFA_REQQ_PORT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3392)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3393) if (!msg) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3394) fcport->stats_qfull = BFA_TRUE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3395) bfa_reqq_winit(&fcport->stats_reqq_wait,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3396) bfa_fcport_send_stats_clear, fcport);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3397) bfa_reqq_wait(fcport->bfa, BFA_REQQ_PORT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3398) &fcport->stats_reqq_wait);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3399) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3400) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3401) fcport->stats_qfull = BFA_FALSE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3402)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3403) memset(msg, 0, sizeof(struct bfi_fcport_req_s));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3404) bfi_h2i_set(msg->mh, BFI_MC_FCPORT, BFI_FCPORT_H2I_STATS_CLEAR_REQ,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3405) bfa_fn_lpu(fcport->bfa));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3406) bfa_reqq_produce(fcport->bfa, BFA_REQQ_PORT, msg->mh);
^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) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3410) * Handle trunk SCN event from firmware.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3411) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3412) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3413) bfa_trunk_scn(struct bfa_fcport_s *fcport, struct bfi_fcport_trunk_scn_s *scn)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3414) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3415) struct bfa_fcport_trunk_s *trunk = &fcport->trunk;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3416) struct bfi_fcport_trunk_link_s *tlink;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3417) struct bfa_trunk_link_attr_s *lattr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3418) enum bfa_trunk_state state_prev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3419) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3420) int link_bm = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3421)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3422) bfa_trc(fcport->bfa, fcport->cfg.trunked);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3423) WARN_ON(scn->trunk_state != BFA_TRUNK_ONLINE &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3424) scn->trunk_state != BFA_TRUNK_OFFLINE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3425)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3426) bfa_trc(fcport->bfa, trunk->attr.state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3427) bfa_trc(fcport->bfa, scn->trunk_state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3428) bfa_trc(fcport->bfa, scn->trunk_speed);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3429)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3430) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3431) * Save off new state for trunk attribute query
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3432) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3433) state_prev = trunk->attr.state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3434) if (fcport->cfg.trunked && (trunk->attr.state != BFA_TRUNK_DISABLED))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3435) trunk->attr.state = scn->trunk_state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3436) trunk->attr.speed = scn->trunk_speed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3437) for (i = 0; i < BFA_TRUNK_MAX_PORTS; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3438) lattr = &trunk->attr.link_attr[i];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3439) tlink = &scn->tlink[i];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3440)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3441) lattr->link_state = tlink->state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3442) lattr->trunk_wwn = tlink->trunk_wwn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3443) lattr->fctl = tlink->fctl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3444) lattr->speed = tlink->speed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3445) lattr->deskew = be32_to_cpu(tlink->deskew);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3446)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3447) if (tlink->state == BFA_TRUNK_LINK_STATE_UP) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3448) fcport->speed = tlink->speed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3449) fcport->topology = BFA_PORT_TOPOLOGY_P2P;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3450) link_bm |= 1 << i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3451) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3452)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3453) bfa_trc(fcport->bfa, lattr->link_state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3454) bfa_trc(fcport->bfa, lattr->trunk_wwn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3455) bfa_trc(fcport->bfa, lattr->fctl);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3456) bfa_trc(fcport->bfa, lattr->speed);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3457) bfa_trc(fcport->bfa, lattr->deskew);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3458) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3459)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3460) switch (link_bm) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3461) case 3:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3462) bfa_plog_str(fcport->bfa->plog, BFA_PL_MID_HAL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3463) BFA_PL_EID_TRUNK_SCN, 0, "Trunk up(0,1)");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3464) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3465) case 2:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3466) bfa_plog_str(fcport->bfa->plog, BFA_PL_MID_HAL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3467) BFA_PL_EID_TRUNK_SCN, 0, "Trunk up(-,1)");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3468) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3469) case 1:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3470) bfa_plog_str(fcport->bfa->plog, BFA_PL_MID_HAL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3471) BFA_PL_EID_TRUNK_SCN, 0, "Trunk up(0,-)");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3472) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3473) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3474) bfa_plog_str(fcport->bfa->plog, BFA_PL_MID_HAL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3475) BFA_PL_EID_TRUNK_SCN, 0, "Trunk down");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3476) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3477)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3478) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3479) * Notify upper layers if trunk state changed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3480) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3481) if ((state_prev != trunk->attr.state) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3482) (scn->trunk_state == BFA_TRUNK_OFFLINE)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3483) bfa_fcport_scn(fcport, (scn->trunk_state == BFA_TRUNK_ONLINE) ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3484) BFA_PORT_LINKUP : BFA_PORT_LINKDOWN, BFA_TRUE);
^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)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3488) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3489) bfa_trunk_iocdisable(struct bfa_s *bfa)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3490) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3491) struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3492) int i = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3493)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3494) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3495) * In trunked mode, notify upper layers that link is down
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3496) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3497) if (fcport->cfg.trunked) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3498) if (fcport->trunk.attr.state == BFA_TRUNK_ONLINE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3499) bfa_fcport_scn(fcport, BFA_PORT_LINKDOWN, BFA_TRUE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3500)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3501) fcport->trunk.attr.state = BFA_TRUNK_OFFLINE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3502) fcport->trunk.attr.speed = BFA_PORT_SPEED_UNKNOWN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3503) for (i = 0; i < BFA_TRUNK_MAX_PORTS; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3504) fcport->trunk.attr.link_attr[i].trunk_wwn = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3505) fcport->trunk.attr.link_attr[i].fctl =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3506) BFA_TRUNK_LINK_FCTL_NORMAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3507) fcport->trunk.attr.link_attr[i].link_state =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3508) BFA_TRUNK_LINK_STATE_DN_LINKDN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3509) fcport->trunk.attr.link_attr[i].speed =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3510) BFA_PORT_SPEED_UNKNOWN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3511) fcport->trunk.attr.link_attr[i].deskew = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3512) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3513) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3514) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3515)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3516) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3517) * Called to initialize port attributes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3518) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3519) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3520) bfa_fcport_init(struct bfa_s *bfa)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3521) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3522) struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3523)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3524) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3525) * Initialize port attributes from IOC hardware data.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3526) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3527) bfa_fcport_set_wwns(fcport);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3528) if (fcport->cfg.maxfrsize == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3529) fcport->cfg.maxfrsize = bfa_ioc_maxfrsize(&bfa->ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3530) fcport->cfg.rx_bbcredit = bfa_ioc_rx_bbcredit(&bfa->ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3531) fcport->speed_sup = bfa_ioc_speed_sup(&bfa->ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3532)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3533) if (bfa_fcport_is_pbcdisabled(bfa))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3534) bfa->modules.port.pbc_disabled = BFA_TRUE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3535)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3536) WARN_ON(!fcport->cfg.maxfrsize);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3537) WARN_ON(!fcport->cfg.rx_bbcredit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3538) WARN_ON(!fcport->speed_sup);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3539) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3540)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3541) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3542) * Firmware message handler.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3543) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3544) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3545) bfa_fcport_isr(struct bfa_s *bfa, struct bfi_msg_s *msg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3546) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3547) struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3548) union bfi_fcport_i2h_msg_u i2hmsg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3549)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3550) i2hmsg.msg = msg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3551) fcport->event_arg.i2hmsg = i2hmsg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3552)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3553) bfa_trc(bfa, msg->mhdr.msg_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3554) bfa_trc(bfa, bfa_sm_to_state(hal_port_sm_table, fcport->sm));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3555)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3556) switch (msg->mhdr.msg_id) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3557) case BFI_FCPORT_I2H_ENABLE_RSP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3558) if (fcport->msgtag == i2hmsg.penable_rsp->msgtag) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3559)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3560) fcport->stats_dma_ready = BFA_TRUE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3561) if (fcport->use_flash_cfg) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3562) fcport->cfg = i2hmsg.penable_rsp->port_cfg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3563) fcport->cfg.maxfrsize =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3564) cpu_to_be16(fcport->cfg.maxfrsize);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3565) fcport->cfg.path_tov =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3566) cpu_to_be16(fcport->cfg.path_tov);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3567) fcport->cfg.q_depth =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3568) cpu_to_be16(fcport->cfg.q_depth);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3569)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3570) if (fcport->cfg.trunked)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3571) fcport->trunk.attr.state =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3572) BFA_TRUNK_OFFLINE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3573) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3574) fcport->trunk.attr.state =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3575) BFA_TRUNK_DISABLED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3576) fcport->qos_attr.qos_bw =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3577) i2hmsg.penable_rsp->port_cfg.qos_bw;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3578) fcport->use_flash_cfg = BFA_FALSE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3579) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3580)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3581) if (fcport->cfg.qos_enabled)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3582) fcport->qos_attr.state = BFA_QOS_OFFLINE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3583) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3584) fcport->qos_attr.state = BFA_QOS_DISABLED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3585)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3586) fcport->qos_attr.qos_bw_op =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3587) i2hmsg.penable_rsp->port_cfg.qos_bw;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3588)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3589) if (fcport->cfg.bb_cr_enabled)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3590) fcport->bbcr_attr.state = BFA_BBCR_OFFLINE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3591) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3592) fcport->bbcr_attr.state = BFA_BBCR_DISABLED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3593)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3594) bfa_sm_send_event(fcport, BFA_FCPORT_SM_FWRSP);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3595) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3596) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3597)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3598) case BFI_FCPORT_I2H_DISABLE_RSP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3599) if (fcport->msgtag == i2hmsg.penable_rsp->msgtag)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3600) bfa_sm_send_event(fcport, BFA_FCPORT_SM_FWRSP);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3601) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3602)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3603) case BFI_FCPORT_I2H_EVENT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3604) if (fcport->cfg.bb_cr_enabled)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3605) fcport->bbcr_attr.state = BFA_BBCR_OFFLINE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3606) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3607) fcport->bbcr_attr.state = BFA_BBCR_DISABLED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3608)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3609) if (i2hmsg.event->link_state.linkstate == BFA_PORT_LINKUP)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3610) bfa_sm_send_event(fcport, BFA_FCPORT_SM_LINKUP);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3611) else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3612) if (i2hmsg.event->link_state.linkstate_rsn ==
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3613) BFA_PORT_LINKSTATE_RSN_FAA_MISCONFIG)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3614) bfa_sm_send_event(fcport,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3615) BFA_FCPORT_SM_FAA_MISCONFIG);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3616) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3617) bfa_sm_send_event(fcport,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3618) BFA_FCPORT_SM_LINKDOWN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3619) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3620) fcport->qos_attr.qos_bw_op =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3621) i2hmsg.event->link_state.qos_attr.qos_bw_op;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3622) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3623)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3624) case BFI_FCPORT_I2H_TRUNK_SCN:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3625) bfa_trunk_scn(fcport, i2hmsg.trunk_scn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3626) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3627)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3628) case BFI_FCPORT_I2H_STATS_GET_RSP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3629) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3630) * check for timer pop before processing the rsp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3631) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3632) if (list_empty(&fcport->stats_pending_q) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3633) (fcport->stats_status == BFA_STATUS_ETIMER))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3634) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3635)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3636) bfa_timer_stop(&fcport->timer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3637) fcport->stats_status = i2hmsg.pstatsget_rsp->status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3638) __bfa_cb_fcport_stats_get(fcport, BFA_TRUE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3639) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3640)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3641) case BFI_FCPORT_I2H_STATS_CLEAR_RSP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3642) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3643) * check for timer pop before processing the rsp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3644) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3645) if (list_empty(&fcport->statsclr_pending_q) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3646) (fcport->stats_status == BFA_STATUS_ETIMER))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3647) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3648)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3649) bfa_timer_stop(&fcport->timer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3650) fcport->stats_status = BFA_STATUS_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3651) __bfa_cb_fcport_stats_clr(fcport, BFA_TRUE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3652) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3653)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3654) case BFI_FCPORT_I2H_ENABLE_AEN:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3655) bfa_sm_send_event(fcport, BFA_FCPORT_SM_ENABLE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3656) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3657)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3658) case BFI_FCPORT_I2H_DISABLE_AEN:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3659) bfa_sm_send_event(fcport, BFA_FCPORT_SM_DISABLE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3660) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3661)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3662) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3663) WARN_ON(1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3664) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3665) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3666) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3667)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3668) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3669) * Registered callback for port events.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3670) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3671) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3672) bfa_fcport_event_register(struct bfa_s *bfa,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3673) void (*cbfn) (void *cbarg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3674) enum bfa_port_linkstate event),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3675) void *cbarg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3676) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3677) struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3678)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3679) fcport->event_cbfn = cbfn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3680) fcport->event_cbarg = cbarg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3681) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3682)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3683) bfa_status_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3684) bfa_fcport_enable(struct bfa_s *bfa)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3685) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3686) struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3687)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3688) if (bfa_fcport_is_pbcdisabled(bfa))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3689) return BFA_STATUS_PBC;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3690)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3691) if (bfa_ioc_is_disabled(&bfa->ioc))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3692) return BFA_STATUS_IOC_DISABLED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3693)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3694) if (fcport->diag_busy)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3695) return BFA_STATUS_DIAG_BUSY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3696)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3697) bfa_sm_send_event(BFA_FCPORT_MOD(bfa), BFA_FCPORT_SM_ENABLE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3698) return BFA_STATUS_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3699) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3700)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3701) bfa_status_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3702) bfa_fcport_disable(struct bfa_s *bfa)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3703) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3704) if (bfa_fcport_is_pbcdisabled(bfa))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3705) return BFA_STATUS_PBC;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3706)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3707) if (bfa_ioc_is_disabled(&bfa->ioc))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3708) return BFA_STATUS_IOC_DISABLED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3709)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3710) bfa_sm_send_event(BFA_FCPORT_MOD(bfa), BFA_FCPORT_SM_DISABLE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3711) return BFA_STATUS_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3712) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3713)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3714) /* If PBC is disabled on port, return error */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3715) bfa_status_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3716) bfa_fcport_is_pbcdisabled(struct bfa_s *bfa)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3717) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3718) struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3719) struct bfa_iocfc_s *iocfc = &bfa->iocfc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3720) struct bfi_iocfc_cfgrsp_s *cfgrsp = iocfc->cfgrsp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3721)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3722) if (cfgrsp->pbc_cfg.port_enabled == BFI_PBC_PORT_DISABLED) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3723) bfa_trc(bfa, fcport->pwwn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3724) return BFA_STATUS_PBC;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3725) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3726) return BFA_STATUS_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3727) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3728)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3729) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3730) * Configure port speed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3731) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3732) bfa_status_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3733) bfa_fcport_cfg_speed(struct bfa_s *bfa, enum bfa_port_speed speed)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3734) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3735) struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3736)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3737) bfa_trc(bfa, speed);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3738)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3739) if (fcport->cfg.trunked == BFA_TRUE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3740) return BFA_STATUS_TRUNK_ENABLED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3741) if ((fcport->cfg.topology == BFA_PORT_TOPOLOGY_LOOP) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3742) (speed == BFA_PORT_SPEED_16GBPS))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3743) return BFA_STATUS_UNSUPP_SPEED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3744) if ((speed != BFA_PORT_SPEED_AUTO) && (speed > fcport->speed_sup)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3745) bfa_trc(bfa, fcport->speed_sup);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3746) return BFA_STATUS_UNSUPP_SPEED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3747) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3748)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3749) /* Port speed entered needs to be checked */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3750) if (bfa_ioc_get_type(&fcport->bfa->ioc) == BFA_IOC_TYPE_FC) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3751) /* For CT2, 1G is not supported */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3752) if ((speed == BFA_PORT_SPEED_1GBPS) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3753) (bfa_asic_id_ct2(bfa->ioc.pcidev.device_id)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3754) return BFA_STATUS_UNSUPP_SPEED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3755)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3756) /* Already checked for Auto Speed and Max Speed supp */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3757) if (!(speed == BFA_PORT_SPEED_1GBPS ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3758) speed == BFA_PORT_SPEED_2GBPS ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3759) speed == BFA_PORT_SPEED_4GBPS ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3760) speed == BFA_PORT_SPEED_8GBPS ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3761) speed == BFA_PORT_SPEED_16GBPS ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3762) speed == BFA_PORT_SPEED_AUTO))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3763) return BFA_STATUS_UNSUPP_SPEED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3764) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3765) if (speed != BFA_PORT_SPEED_10GBPS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3766) return BFA_STATUS_UNSUPP_SPEED;
^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) fcport->cfg.speed = speed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3770)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3771) return BFA_STATUS_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3772) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3773)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3774) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3775) * Get current speed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3776) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3777) enum bfa_port_speed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3778) bfa_fcport_get_speed(struct bfa_s *bfa)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3779) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3780) struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3781)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3782) return fcport->speed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3783) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3784)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3785) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3786) * Configure port topology.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3787) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3788) bfa_status_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3789) bfa_fcport_cfg_topology(struct bfa_s *bfa, enum bfa_port_topology topology)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3790) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3791) struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3792)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3793) bfa_trc(bfa, topology);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3794) bfa_trc(bfa, fcport->cfg.topology);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3795)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3796) switch (topology) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3797) case BFA_PORT_TOPOLOGY_P2P:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3798) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3799)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3800) case BFA_PORT_TOPOLOGY_LOOP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3801) if ((bfa_fcport_is_qos_enabled(bfa) != BFA_FALSE) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3802) (fcport->qos_attr.state != BFA_QOS_DISABLED))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3803) return BFA_STATUS_ERROR_QOS_ENABLED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3804) if (fcport->cfg.ratelimit != BFA_FALSE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3805) return BFA_STATUS_ERROR_TRL_ENABLED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3806) if ((bfa_fcport_is_trunk_enabled(bfa) != BFA_FALSE) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3807) (fcport->trunk.attr.state != BFA_TRUNK_DISABLED))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3808) return BFA_STATUS_ERROR_TRUNK_ENABLED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3809) if ((bfa_fcport_get_speed(bfa) == BFA_PORT_SPEED_16GBPS) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3810) (fcport->cfg.speed == BFA_PORT_SPEED_16GBPS))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3811) return BFA_STATUS_UNSUPP_SPEED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3812) if (bfa_mfg_is_mezz(bfa->ioc.attr->card_type))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3813) return BFA_STATUS_LOOP_UNSUPP_MEZZ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3814) if (bfa_fcport_is_dport(bfa) != BFA_FALSE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3815) return BFA_STATUS_DPORT_ERR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3816) if (bfa_fcport_is_ddport(bfa) != BFA_FALSE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3817) return BFA_STATUS_DPORT_ERR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3818) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3819)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3820) case BFA_PORT_TOPOLOGY_AUTO:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3821) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3822)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3823) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3824) return BFA_STATUS_EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3825) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3826)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3827) fcport->cfg.topology = topology;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3828) return BFA_STATUS_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3829) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3830)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3831) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3832) * Get current topology.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3833) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3834) enum bfa_port_topology
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3835) bfa_fcport_get_topology(struct bfa_s *bfa)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3836) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3837) struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3838)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3839) return fcport->topology;
^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) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3843) * Get config topology.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3844) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3845) enum bfa_port_topology
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3846) bfa_fcport_get_cfg_topology(struct bfa_s *bfa)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3847) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3848) struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3849)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3850) return fcport->cfg.topology;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3851) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3852)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3853) bfa_status_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3854) bfa_fcport_cfg_hardalpa(struct bfa_s *bfa, u8 alpa)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3855) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3856) struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3857)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3858) bfa_trc(bfa, alpa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3859) bfa_trc(bfa, fcport->cfg.cfg_hardalpa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3860) bfa_trc(bfa, fcport->cfg.hardalpa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3861)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3862) fcport->cfg.cfg_hardalpa = BFA_TRUE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3863) fcport->cfg.hardalpa = alpa;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3864)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3865) return BFA_STATUS_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3866) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3867)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3868) bfa_status_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3869) bfa_fcport_clr_hardalpa(struct bfa_s *bfa)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3870) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3871) struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3872)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3873) bfa_trc(bfa, fcport->cfg.cfg_hardalpa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3874) bfa_trc(bfa, fcport->cfg.hardalpa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3875)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3876) fcport->cfg.cfg_hardalpa = BFA_FALSE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3877) return BFA_STATUS_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3878) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3879)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3880) bfa_boolean_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3881) bfa_fcport_get_hardalpa(struct bfa_s *bfa, u8 *alpa)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3882) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3883) struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3884)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3885) *alpa = fcport->cfg.hardalpa;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3886) return fcport->cfg.cfg_hardalpa;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3887) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3888)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3889) u8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3890) bfa_fcport_get_myalpa(struct bfa_s *bfa)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3891) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3892) struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3893)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3894) return fcport->myalpa;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3895) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3896)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3897) bfa_status_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3898) bfa_fcport_cfg_maxfrsize(struct bfa_s *bfa, u16 maxfrsize)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3899) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3900) struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3901)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3902) bfa_trc(bfa, maxfrsize);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3903) bfa_trc(bfa, fcport->cfg.maxfrsize);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3904)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3905) /* with in range */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3906) if ((maxfrsize > FC_MAX_PDUSZ) || (maxfrsize < FC_MIN_PDUSZ))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3907) return BFA_STATUS_INVLD_DFSZ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3908)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3909) /* power of 2, if not the max frame size of 2112 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3910) if ((maxfrsize != FC_MAX_PDUSZ) && (maxfrsize & (maxfrsize - 1)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3911) return BFA_STATUS_INVLD_DFSZ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3912)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3913) fcport->cfg.maxfrsize = maxfrsize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3914) return BFA_STATUS_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3915) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3916)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3917) u16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3918) bfa_fcport_get_maxfrsize(struct bfa_s *bfa)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3919) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3920) struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3921)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3922) return fcport->cfg.maxfrsize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3923) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3924)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3925) u8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3926) bfa_fcport_get_rx_bbcredit(struct bfa_s *bfa)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3927) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3928) if (bfa_fcport_get_topology(bfa) != BFA_PORT_TOPOLOGY_LOOP)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3929) return (BFA_FCPORT_MOD(bfa))->cfg.rx_bbcredit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3930)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3931) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3932) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3933) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3934)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3935) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3936) bfa_fcport_set_tx_bbcredit(struct bfa_s *bfa, u16 tx_bbcredit)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3937) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3938) struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3939)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3940) fcport->cfg.tx_bbcredit = (u8)tx_bbcredit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3941) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3942)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3943) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3944) * Get port attributes.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3945) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3946)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3947) wwn_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3948) bfa_fcport_get_wwn(struct bfa_s *bfa, bfa_boolean_t node)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3949) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3950) struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3951) if (node)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3952) return fcport->nwwn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3953) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3954) return fcport->pwwn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3955) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3956)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3957) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3958) bfa_fcport_get_attr(struct bfa_s *bfa, struct bfa_port_attr_s *attr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3959) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3960) struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3961)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3962) memset(attr, 0, sizeof(struct bfa_port_attr_s));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3963)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3964) attr->nwwn = fcport->nwwn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3965) attr->pwwn = fcport->pwwn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3966)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3967) attr->factorypwwn = bfa->ioc.attr->mfg_pwwn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3968) attr->factorynwwn = bfa->ioc.attr->mfg_nwwn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3969)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3970) memcpy(&attr->pport_cfg, &fcport->cfg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3971) sizeof(struct bfa_port_cfg_s));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3972) /* speed attributes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3973) attr->pport_cfg.speed = fcport->cfg.speed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3974) attr->speed_supported = fcport->speed_sup;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3975) attr->speed = fcport->speed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3976) attr->cos_supported = FC_CLASS_3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3977)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3978) /* topology attributes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3979) attr->pport_cfg.topology = fcport->cfg.topology;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3980) attr->topology = fcport->topology;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3981) attr->pport_cfg.trunked = fcport->cfg.trunked;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3982)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3983) /* beacon attributes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3984) attr->beacon = fcport->beacon;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3985) attr->link_e2e_beacon = fcport->link_e2e_beacon;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3986)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3987) attr->pport_cfg.path_tov = bfa_fcpim_path_tov_get(bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3988) attr->pport_cfg.q_depth = bfa_fcpim_qdepth_get(bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3989) attr->port_state = bfa_sm_to_state(hal_port_sm_table, fcport->sm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3990)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3991) attr->fec_state = fcport->fec_state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3992)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3993) /* PBC Disabled State */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3994) if (bfa_fcport_is_pbcdisabled(bfa))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3995) attr->port_state = BFA_PORT_ST_PREBOOT_DISABLED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3996) else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3997) if (bfa_ioc_is_disabled(&fcport->bfa->ioc))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3998) attr->port_state = BFA_PORT_ST_IOCDIS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3999) else if (bfa_ioc_fw_mismatch(&fcport->bfa->ioc))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4000) attr->port_state = BFA_PORT_ST_FWMISMATCH;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4001) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4002)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4003) /* FCoE vlan */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4004) attr->fcoe_vlan = fcport->fcoe_vlan;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4005) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4006)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4007) #define BFA_FCPORT_STATS_TOV 1000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4008)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4009) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4010) * Fetch port statistics (FCQoS or FCoE).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4011) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4012) bfa_status_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4013) bfa_fcport_get_stats(struct bfa_s *bfa, struct bfa_cb_pending_q_s *cb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4014) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4015) struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4016)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4017) if (!bfa_iocfc_is_operational(bfa) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4018) !fcport->stats_dma_ready)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4019) return BFA_STATUS_IOC_NON_OP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4020)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4021) if (!list_empty(&fcport->statsclr_pending_q))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4022) return BFA_STATUS_DEVBUSY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4023)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4024) if (list_empty(&fcport->stats_pending_q)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4025) list_add_tail(&cb->hcb_qe.qe, &fcport->stats_pending_q);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4026) bfa_fcport_send_stats_get(fcport);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4027) bfa_timer_start(bfa, &fcport->timer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4028) bfa_fcport_stats_get_timeout,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4029) fcport, BFA_FCPORT_STATS_TOV);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4030) } else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4031) list_add_tail(&cb->hcb_qe.qe, &fcport->stats_pending_q);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4032)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4033) return BFA_STATUS_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4034) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4035)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4036) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4037) * Reset port statistics (FCQoS or FCoE).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4038) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4039) bfa_status_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4040) bfa_fcport_clear_stats(struct bfa_s *bfa, struct bfa_cb_pending_q_s *cb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4041) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4042) struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4043)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4044) if (!bfa_iocfc_is_operational(bfa) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4045) !fcport->stats_dma_ready)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4046) return BFA_STATUS_IOC_NON_OP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4047)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4048) if (!list_empty(&fcport->stats_pending_q))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4049) return BFA_STATUS_DEVBUSY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4050)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4051) if (list_empty(&fcport->statsclr_pending_q)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4052) list_add_tail(&cb->hcb_qe.qe, &fcport->statsclr_pending_q);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4053) bfa_fcport_send_stats_clear(fcport);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4054) bfa_timer_start(bfa, &fcport->timer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4055) bfa_fcport_stats_clr_timeout,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4056) fcport, BFA_FCPORT_STATS_TOV);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4057) } else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4058) list_add_tail(&cb->hcb_qe.qe, &fcport->statsclr_pending_q);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4059)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4060) return BFA_STATUS_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4061) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4062)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4063) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4064) * Fetch port attributes.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4065) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4066) bfa_boolean_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4067) bfa_fcport_is_disabled(struct bfa_s *bfa)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4068) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4069) struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4070)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4071) return bfa_sm_to_state(hal_port_sm_table, fcport->sm) ==
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4072) BFA_PORT_ST_DISABLED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4073)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4074) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4075)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4076) bfa_boolean_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4077) bfa_fcport_is_dport(struct bfa_s *bfa)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4078) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4079) struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4080)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4081) return (bfa_sm_to_state(hal_port_sm_table, fcport->sm) ==
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4082) BFA_PORT_ST_DPORT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4083) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4084)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4085) bfa_boolean_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4086) bfa_fcport_is_ddport(struct bfa_s *bfa)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4087) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4088) struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4089)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4090) return (bfa_sm_to_state(hal_port_sm_table, fcport->sm) ==
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4091) BFA_PORT_ST_DDPORT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4092) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4093)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4094) bfa_status_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4095) bfa_fcport_set_qos_bw(struct bfa_s *bfa, struct bfa_qos_bw_s *qos_bw)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4096) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4097) struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4098) enum bfa_ioc_type_e ioc_type = bfa_get_type(bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4099)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4100) bfa_trc(bfa, ioc_type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4101)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4102) if ((qos_bw->high == 0) || (qos_bw->med == 0) || (qos_bw->low == 0))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4103) return BFA_STATUS_QOS_BW_INVALID;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4104)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4105) if ((qos_bw->high + qos_bw->med + qos_bw->low) != 100)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4106) return BFA_STATUS_QOS_BW_INVALID;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4107)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4108) if ((qos_bw->med > qos_bw->high) || (qos_bw->low > qos_bw->med) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4109) (qos_bw->low > qos_bw->high))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4110) return BFA_STATUS_QOS_BW_INVALID;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4111)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4112) if ((ioc_type == BFA_IOC_TYPE_FC) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4113) (fcport->cfg.topology != BFA_PORT_TOPOLOGY_LOOP))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4114) fcport->cfg.qos_bw = *qos_bw;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4115)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4116) return BFA_STATUS_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4117) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4118)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4119) bfa_boolean_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4120) bfa_fcport_is_ratelim(struct bfa_s *bfa)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4121) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4122) struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4123)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4124) return fcport->cfg.ratelimit ? BFA_TRUE : BFA_FALSE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4125)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4126) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4127)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4128) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4129) * Enable/Disable FAA feature in port config
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4130) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4131) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4132) bfa_fcport_cfg_faa(struct bfa_s *bfa, u8 state)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4133) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4134) struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4135)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4136) bfa_trc(bfa, state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4137) fcport->cfg.faa_state = state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4138) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4139)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4140) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4141) * Get default minimum ratelim speed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4142) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4143) enum bfa_port_speed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4144) bfa_fcport_get_ratelim_speed(struct bfa_s *bfa)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4145) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4146) struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4147)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4148) bfa_trc(bfa, fcport->cfg.trl_def_speed);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4149) return fcport->cfg.trl_def_speed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4150)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4151) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4152)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4153) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4154) bfa_fcport_beacon(void *dev, bfa_boolean_t beacon,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4155) bfa_boolean_t link_e2e_beacon)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4156) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4157) struct bfa_s *bfa = dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4158) struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4159)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4160) bfa_trc(bfa, beacon);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4161) bfa_trc(bfa, link_e2e_beacon);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4162) bfa_trc(bfa, fcport->beacon);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4163) bfa_trc(bfa, fcport->link_e2e_beacon);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4164)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4165) fcport->beacon = beacon;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4166) fcport->link_e2e_beacon = link_e2e_beacon;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4167) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4168)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4169) bfa_boolean_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4170) bfa_fcport_is_linkup(struct bfa_s *bfa)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4171) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4172) struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4173)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4174) return (!fcport->cfg.trunked &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4175) bfa_sm_cmp_state(fcport, bfa_fcport_sm_linkup)) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4176) (fcport->cfg.trunked &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4177) fcport->trunk.attr.state == BFA_TRUNK_ONLINE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4178) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4179)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4180) bfa_boolean_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4181) bfa_fcport_is_qos_enabled(struct bfa_s *bfa)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4182) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4183) struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4184)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4185) return fcport->cfg.qos_enabled;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4186) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4187)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4188) bfa_boolean_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4189) bfa_fcport_is_trunk_enabled(struct bfa_s *bfa)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4190) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4191) struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4192)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4193) return fcport->cfg.trunked;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4194) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4195)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4196) bfa_status_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4197) bfa_fcport_cfg_bbcr(struct bfa_s *bfa, bfa_boolean_t on_off, u8 bb_scn)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4198) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4199) struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4200)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4201) bfa_trc(bfa, on_off);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4202)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4203) if (bfa_ioc_get_type(&fcport->bfa->ioc) != BFA_IOC_TYPE_FC)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4204) return BFA_STATUS_BBCR_FC_ONLY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4205)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4206) if (bfa_mfg_is_mezz(bfa->ioc.attr->card_type) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4207) (bfa->ioc.attr->card_type != BFA_MFG_TYPE_CHINOOK))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4208) return BFA_STATUS_CMD_NOTSUPP_MEZZ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4209)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4210) if (on_off) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4211) if (fcport->cfg.topology == BFA_PORT_TOPOLOGY_LOOP)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4212) return BFA_STATUS_TOPOLOGY_LOOP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4213)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4214) if (fcport->cfg.qos_enabled)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4215) return BFA_STATUS_ERROR_QOS_ENABLED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4216)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4217) if (fcport->cfg.trunked)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4218) return BFA_STATUS_TRUNK_ENABLED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4219)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4220) if ((fcport->cfg.speed != BFA_PORT_SPEED_AUTO) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4221) (fcport->cfg.speed < bfa_ioc_speed_sup(&bfa->ioc)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4222) return BFA_STATUS_ERR_BBCR_SPEED_UNSUPPORT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4223)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4224) if (bfa_ioc_speed_sup(&bfa->ioc) < BFA_PORT_SPEED_8GBPS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4225) return BFA_STATUS_FEATURE_NOT_SUPPORTED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4226)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4227) if (fcport->cfg.bb_cr_enabled) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4228) if (bb_scn != fcport->cfg.bb_scn)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4229) return BFA_STATUS_BBCR_CFG_NO_CHANGE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4230) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4231) return BFA_STATUS_NO_CHANGE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4232) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4233)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4234) if ((bb_scn == 0) || (bb_scn > BFA_BB_SCN_MAX))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4235) bb_scn = BFA_BB_SCN_DEF;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4236)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4237) fcport->cfg.bb_cr_enabled = on_off;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4238) fcport->cfg.bb_scn = bb_scn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4239) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4240) if (!fcport->cfg.bb_cr_enabled)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4241) return BFA_STATUS_NO_CHANGE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4242)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4243) fcport->cfg.bb_cr_enabled = on_off;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4244) fcport->cfg.bb_scn = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4245) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4246)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4247) return BFA_STATUS_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4248) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4249)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4250) bfa_status_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4251) bfa_fcport_get_bbcr_attr(struct bfa_s *bfa,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4252) struct bfa_bbcr_attr_s *bbcr_attr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4253) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4254) struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4255)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4256) if (bfa_ioc_get_type(&fcport->bfa->ioc) != BFA_IOC_TYPE_FC)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4257) return BFA_STATUS_BBCR_FC_ONLY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4258)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4259) if (fcport->cfg.topology == BFA_PORT_TOPOLOGY_LOOP)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4260) return BFA_STATUS_TOPOLOGY_LOOP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4261)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4262) *bbcr_attr = fcport->bbcr_attr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4263)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4264) return BFA_STATUS_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4265) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4266)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4267) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4268) bfa_fcport_dportenable(struct bfa_s *bfa)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4269) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4270) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4271) * Assume caller check for port is in disable state
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4272) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4273) bfa_sm_send_event(BFA_FCPORT_MOD(bfa), BFA_FCPORT_SM_DPORTENABLE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4274) bfa_port_set_dportenabled(&bfa->modules.port, BFA_TRUE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4275) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4276)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4277) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4278) bfa_fcport_dportdisable(struct bfa_s *bfa)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4279) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4280) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4281) * Assume caller check for port is in disable state
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4282) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4283) bfa_sm_send_event(BFA_FCPORT_MOD(bfa), BFA_FCPORT_SM_DPORTDISABLE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4284) bfa_port_set_dportenabled(&bfa->modules.port, BFA_FALSE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4285) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4286)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4287) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4288) bfa_fcport_ddportenable(struct bfa_s *bfa)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4289) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4290) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4291) * Assume caller check for port is in disable state
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4292) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4293) bfa_sm_send_event(BFA_FCPORT_MOD(bfa), BFA_FCPORT_SM_DDPORTENABLE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4294) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4295)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4296) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4297) bfa_fcport_ddportdisable(struct bfa_s *bfa)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4298) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4299) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4300) * Assume caller check for port is in disable state
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4301) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4302) bfa_sm_send_event(BFA_FCPORT_MOD(bfa), BFA_FCPORT_SM_DDPORTDISABLE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4303) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4304)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4305) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4306) * Rport State machine functions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4307) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4308) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4309) * Beginning state, only online event expected.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4310) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4311) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4312) bfa_rport_sm_uninit(struct bfa_rport_s *rp, enum bfa_rport_event event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4313) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4314) bfa_trc(rp->bfa, rp->rport_tag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4315) bfa_trc(rp->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4316)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4317) switch (event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4318) case BFA_RPORT_SM_CREATE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4319) bfa_stats(rp, sm_un_cr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4320) bfa_sm_set_state(rp, bfa_rport_sm_created);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4321) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4322)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4323) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4324) bfa_stats(rp, sm_un_unexp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4325) bfa_sm_fault(rp->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4326) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4327) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4328)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4329) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4330) bfa_rport_sm_created(struct bfa_rport_s *rp, enum bfa_rport_event event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4331) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4332) bfa_trc(rp->bfa, rp->rport_tag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4333) bfa_trc(rp->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4334)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4335) switch (event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4336) case BFA_RPORT_SM_ONLINE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4337) bfa_stats(rp, sm_cr_on);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4338) if (bfa_rport_send_fwcreate(rp))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4339) bfa_sm_set_state(rp, bfa_rport_sm_fwcreate);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4340) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4341) bfa_sm_set_state(rp, bfa_rport_sm_fwcreate_qfull);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4342) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4343)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4344) case BFA_RPORT_SM_DELETE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4345) bfa_stats(rp, sm_cr_del);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4346) bfa_sm_set_state(rp, bfa_rport_sm_uninit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4347) bfa_rport_free(rp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4348) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4349)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4350) case BFA_RPORT_SM_HWFAIL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4351) bfa_stats(rp, sm_cr_hwf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4352) bfa_sm_set_state(rp, bfa_rport_sm_iocdisable);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4353) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4354)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4355) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4356) bfa_stats(rp, sm_cr_unexp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4357) bfa_sm_fault(rp->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4358) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4359) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4360)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4361) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4362) * Waiting for rport create response from firmware.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4363) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4364) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4365) bfa_rport_sm_fwcreate(struct bfa_rport_s *rp, enum bfa_rport_event event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4366) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4367) bfa_trc(rp->bfa, rp->rport_tag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4368) bfa_trc(rp->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4369)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4370) switch (event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4371) case BFA_RPORT_SM_FWRSP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4372) bfa_stats(rp, sm_fwc_rsp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4373) bfa_sm_set_state(rp, bfa_rport_sm_online);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4374) bfa_rport_online_cb(rp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4375) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4376)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4377) case BFA_RPORT_SM_DELETE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4378) bfa_stats(rp, sm_fwc_del);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4379) bfa_sm_set_state(rp, bfa_rport_sm_delete_pending);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4380) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4381)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4382) case BFA_RPORT_SM_OFFLINE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4383) bfa_stats(rp, sm_fwc_off);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4384) bfa_sm_set_state(rp, bfa_rport_sm_offline_pending);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4385) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4386)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4387) case BFA_RPORT_SM_HWFAIL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4388) bfa_stats(rp, sm_fwc_hwf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4389) bfa_sm_set_state(rp, bfa_rport_sm_iocdisable);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4390) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4391)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4392) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4393) bfa_stats(rp, sm_fwc_unexp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4394) bfa_sm_fault(rp->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4395) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4396) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4397)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4398) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4399) * Request queue is full, awaiting queue resume to send create request.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4400) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4401) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4402) bfa_rport_sm_fwcreate_qfull(struct bfa_rport_s *rp, enum bfa_rport_event event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4403) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4404) bfa_trc(rp->bfa, rp->rport_tag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4405) bfa_trc(rp->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4406)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4407) switch (event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4408) case BFA_RPORT_SM_QRESUME:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4409) bfa_sm_set_state(rp, bfa_rport_sm_fwcreate);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4410) bfa_rport_send_fwcreate(rp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4411) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4412)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4413) case BFA_RPORT_SM_DELETE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4414) bfa_stats(rp, sm_fwc_del);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4415) bfa_sm_set_state(rp, bfa_rport_sm_uninit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4416) bfa_reqq_wcancel(&rp->reqq_wait);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4417) bfa_rport_free(rp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4418) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4419)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4420) case BFA_RPORT_SM_OFFLINE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4421) bfa_stats(rp, sm_fwc_off);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4422) bfa_sm_set_state(rp, bfa_rport_sm_offline);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4423) bfa_reqq_wcancel(&rp->reqq_wait);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4424) bfa_rport_offline_cb(rp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4425) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4426)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4427) case BFA_RPORT_SM_HWFAIL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4428) bfa_stats(rp, sm_fwc_hwf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4429) bfa_sm_set_state(rp, bfa_rport_sm_iocdisable);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4430) bfa_reqq_wcancel(&rp->reqq_wait);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4431) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4432)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4433) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4434) bfa_stats(rp, sm_fwc_unexp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4435) bfa_sm_fault(rp->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4436) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4437) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4438)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4439) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4440) * Online state - normal parking state.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4441) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4442) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4443) bfa_rport_sm_online(struct bfa_rport_s *rp, enum bfa_rport_event event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4444) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4445) struct bfi_rport_qos_scn_s *qos_scn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4446)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4447) bfa_trc(rp->bfa, rp->rport_tag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4448) bfa_trc(rp->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4449)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4450) switch (event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4451) case BFA_RPORT_SM_OFFLINE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4452) bfa_stats(rp, sm_on_off);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4453) if (bfa_rport_send_fwdelete(rp))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4454) bfa_sm_set_state(rp, bfa_rport_sm_fwdelete);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4455) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4456) bfa_sm_set_state(rp, bfa_rport_sm_fwdelete_qfull);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4457) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4458)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4459) case BFA_RPORT_SM_DELETE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4460) bfa_stats(rp, sm_on_del);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4461) if (bfa_rport_send_fwdelete(rp))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4462) bfa_sm_set_state(rp, bfa_rport_sm_deleting);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4463) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4464) bfa_sm_set_state(rp, bfa_rport_sm_deleting_qfull);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4465) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4466)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4467) case BFA_RPORT_SM_HWFAIL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4468) bfa_stats(rp, sm_on_hwf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4469) bfa_sm_set_state(rp, bfa_rport_sm_iocdisable);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4470) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4471)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4472) case BFA_RPORT_SM_SET_SPEED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4473) bfa_rport_send_fwspeed(rp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4474) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4475)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4476) case BFA_RPORT_SM_QOS_SCN:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4477) qos_scn = (struct bfi_rport_qos_scn_s *) rp->event_arg.fw_msg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4478) rp->qos_attr = qos_scn->new_qos_attr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4479) bfa_trc(rp->bfa, qos_scn->old_qos_attr.qos_flow_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4480) bfa_trc(rp->bfa, qos_scn->new_qos_attr.qos_flow_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4481) bfa_trc(rp->bfa, qos_scn->old_qos_attr.qos_priority);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4482) bfa_trc(rp->bfa, qos_scn->new_qos_attr.qos_priority);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4483)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4484) qos_scn->old_qos_attr.qos_flow_id =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4485) be32_to_cpu(qos_scn->old_qos_attr.qos_flow_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4486) qos_scn->new_qos_attr.qos_flow_id =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4487) be32_to_cpu(qos_scn->new_qos_attr.qos_flow_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4488)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4489) if (qos_scn->old_qos_attr.qos_flow_id !=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4490) qos_scn->new_qos_attr.qos_flow_id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4491) bfa_cb_rport_qos_scn_flowid(rp->rport_drv,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4492) qos_scn->old_qos_attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4493) qos_scn->new_qos_attr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4494) if (qos_scn->old_qos_attr.qos_priority !=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4495) qos_scn->new_qos_attr.qos_priority)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4496) bfa_cb_rport_qos_scn_prio(rp->rport_drv,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4497) qos_scn->old_qos_attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4498) qos_scn->new_qos_attr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4499) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4500)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4501) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4502) bfa_stats(rp, sm_on_unexp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4503) bfa_sm_fault(rp->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4504) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4505) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4506)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4507) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4508) * Firmware rport is being deleted - awaiting f/w response.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4509) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4510) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4511) bfa_rport_sm_fwdelete(struct bfa_rport_s *rp, enum bfa_rport_event event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4512) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4513) bfa_trc(rp->bfa, rp->rport_tag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4514) bfa_trc(rp->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4515)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4516) switch (event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4517) case BFA_RPORT_SM_FWRSP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4518) bfa_stats(rp, sm_fwd_rsp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4519) bfa_sm_set_state(rp, bfa_rport_sm_offline);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4520) bfa_rport_offline_cb(rp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4521) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4522)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4523) case BFA_RPORT_SM_DELETE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4524) bfa_stats(rp, sm_fwd_del);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4525) bfa_sm_set_state(rp, bfa_rport_sm_deleting);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4526) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4527)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4528) case BFA_RPORT_SM_HWFAIL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4529) bfa_stats(rp, sm_fwd_hwf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4530) bfa_sm_set_state(rp, bfa_rport_sm_iocdisable);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4531) bfa_rport_offline_cb(rp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4532) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4533)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4534) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4535) bfa_stats(rp, sm_fwd_unexp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4536) bfa_sm_fault(rp->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4537) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4538) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4539)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4540) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4541) bfa_rport_sm_fwdelete_qfull(struct bfa_rport_s *rp, enum bfa_rport_event event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4542) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4543) bfa_trc(rp->bfa, rp->rport_tag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4544) bfa_trc(rp->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4545)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4546) switch (event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4547) case BFA_RPORT_SM_QRESUME:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4548) bfa_sm_set_state(rp, bfa_rport_sm_fwdelete);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4549) bfa_rport_send_fwdelete(rp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4550) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4551)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4552) case BFA_RPORT_SM_DELETE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4553) bfa_stats(rp, sm_fwd_del);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4554) bfa_sm_set_state(rp, bfa_rport_sm_deleting_qfull);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4555) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4556)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4557) case BFA_RPORT_SM_HWFAIL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4558) bfa_stats(rp, sm_fwd_hwf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4559) bfa_sm_set_state(rp, bfa_rport_sm_iocdisable);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4560) bfa_reqq_wcancel(&rp->reqq_wait);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4561) bfa_rport_offline_cb(rp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4562) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4563)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4564) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4565) bfa_stats(rp, sm_fwd_unexp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4566) bfa_sm_fault(rp->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4567) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4568) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4569)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4570) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4571) * Offline state.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4572) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4573) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4574) bfa_rport_sm_offline(struct bfa_rport_s *rp, enum bfa_rport_event event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4575) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4576) bfa_trc(rp->bfa, rp->rport_tag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4577) bfa_trc(rp->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4578)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4579) switch (event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4580) case BFA_RPORT_SM_DELETE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4581) bfa_stats(rp, sm_off_del);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4582) bfa_sm_set_state(rp, bfa_rport_sm_uninit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4583) bfa_rport_free(rp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4584) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4585)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4586) case BFA_RPORT_SM_ONLINE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4587) bfa_stats(rp, sm_off_on);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4588) if (bfa_rport_send_fwcreate(rp))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4589) bfa_sm_set_state(rp, bfa_rport_sm_fwcreate);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4590) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4591) bfa_sm_set_state(rp, bfa_rport_sm_fwcreate_qfull);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4592) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4593)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4594) case BFA_RPORT_SM_HWFAIL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4595) bfa_stats(rp, sm_off_hwf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4596) bfa_sm_set_state(rp, bfa_rport_sm_iocdisable);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4597) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4598)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4599) case BFA_RPORT_SM_OFFLINE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4600) bfa_rport_offline_cb(rp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4601) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4602)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4603) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4604) bfa_stats(rp, sm_off_unexp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4605) bfa_sm_fault(rp->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4606) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4607) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4608)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4609) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4610) * Rport is deleted, waiting for firmware response to delete.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4611) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4612) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4613) bfa_rport_sm_deleting(struct bfa_rport_s *rp, enum bfa_rport_event event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4614) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4615) bfa_trc(rp->bfa, rp->rport_tag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4616) bfa_trc(rp->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4617)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4618) switch (event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4619) case BFA_RPORT_SM_FWRSP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4620) bfa_stats(rp, sm_del_fwrsp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4621) bfa_sm_set_state(rp, bfa_rport_sm_uninit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4622) bfa_rport_free(rp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4623) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4624)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4625) case BFA_RPORT_SM_HWFAIL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4626) bfa_stats(rp, sm_del_hwf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4627) bfa_sm_set_state(rp, bfa_rport_sm_uninit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4628) bfa_rport_free(rp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4629) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4630)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4631) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4632) bfa_sm_fault(rp->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4633) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4634) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4635)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4636) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4637) bfa_rport_sm_deleting_qfull(struct bfa_rport_s *rp, enum bfa_rport_event event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4638) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4639) bfa_trc(rp->bfa, rp->rport_tag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4640) bfa_trc(rp->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4641)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4642) switch (event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4643) case BFA_RPORT_SM_QRESUME:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4644) bfa_stats(rp, sm_del_fwrsp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4645) bfa_sm_set_state(rp, bfa_rport_sm_deleting);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4646) bfa_rport_send_fwdelete(rp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4647) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4648)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4649) case BFA_RPORT_SM_HWFAIL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4650) bfa_stats(rp, sm_del_hwf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4651) bfa_sm_set_state(rp, bfa_rport_sm_uninit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4652) bfa_reqq_wcancel(&rp->reqq_wait);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4653) bfa_rport_free(rp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4654) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4655)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4656) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4657) bfa_sm_fault(rp->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4658) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4659) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4660)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4661) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4662) * Waiting for rport create response from firmware. A delete is pending.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4663) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4664) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4665) bfa_rport_sm_delete_pending(struct bfa_rport_s *rp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4666) enum bfa_rport_event event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4667) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4668) bfa_trc(rp->bfa, rp->rport_tag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4669) bfa_trc(rp->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4670)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4671) switch (event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4672) case BFA_RPORT_SM_FWRSP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4673) bfa_stats(rp, sm_delp_fwrsp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4674) if (bfa_rport_send_fwdelete(rp))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4675) bfa_sm_set_state(rp, bfa_rport_sm_deleting);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4676) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4677) bfa_sm_set_state(rp, bfa_rport_sm_deleting_qfull);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4678) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4679)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4680) case BFA_RPORT_SM_HWFAIL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4681) bfa_stats(rp, sm_delp_hwf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4682) bfa_sm_set_state(rp, bfa_rport_sm_uninit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4683) bfa_rport_free(rp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4684) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4685)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4686) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4687) bfa_stats(rp, sm_delp_unexp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4688) bfa_sm_fault(rp->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4689) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4690) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4691)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4692) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4693) * Waiting for rport create response from firmware. Rport offline is pending.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4694) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4695) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4696) bfa_rport_sm_offline_pending(struct bfa_rport_s *rp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4697) enum bfa_rport_event event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4698) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4699) bfa_trc(rp->bfa, rp->rport_tag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4700) bfa_trc(rp->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4701)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4702) switch (event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4703) case BFA_RPORT_SM_FWRSP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4704) bfa_stats(rp, sm_offp_fwrsp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4705) if (bfa_rport_send_fwdelete(rp))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4706) bfa_sm_set_state(rp, bfa_rport_sm_fwdelete);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4707) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4708) bfa_sm_set_state(rp, bfa_rport_sm_fwdelete_qfull);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4709) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4710)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4711) case BFA_RPORT_SM_DELETE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4712) bfa_stats(rp, sm_offp_del);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4713) bfa_sm_set_state(rp, bfa_rport_sm_delete_pending);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4714) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4715)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4716) case BFA_RPORT_SM_HWFAIL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4717) bfa_stats(rp, sm_offp_hwf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4718) bfa_sm_set_state(rp, bfa_rport_sm_iocdisable);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4719) bfa_rport_offline_cb(rp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4720) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4721)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4722) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4723) bfa_stats(rp, sm_offp_unexp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4724) bfa_sm_fault(rp->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4725) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4726) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4727)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4728) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4729) * IOC h/w failed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4730) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4731) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4732) bfa_rport_sm_iocdisable(struct bfa_rport_s *rp, enum bfa_rport_event event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4733) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4734) bfa_trc(rp->bfa, rp->rport_tag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4735) bfa_trc(rp->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4736)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4737) switch (event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4738) case BFA_RPORT_SM_OFFLINE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4739) bfa_stats(rp, sm_iocd_off);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4740) bfa_rport_offline_cb(rp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4741) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4742)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4743) case BFA_RPORT_SM_DELETE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4744) bfa_stats(rp, sm_iocd_del);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4745) bfa_sm_set_state(rp, bfa_rport_sm_uninit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4746) bfa_rport_free(rp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4747) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4748)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4749) case BFA_RPORT_SM_ONLINE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4750) bfa_stats(rp, sm_iocd_on);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4751) if (bfa_rport_send_fwcreate(rp))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4752) bfa_sm_set_state(rp, bfa_rport_sm_fwcreate);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4753) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4754) bfa_sm_set_state(rp, bfa_rport_sm_fwcreate_qfull);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4755) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4756)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4757) case BFA_RPORT_SM_HWFAIL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4758) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4759)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4760) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4761) bfa_stats(rp, sm_iocd_unexp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4762) bfa_sm_fault(rp->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4763) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4764) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4765)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4766)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4767)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4768) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4769) * bfa_rport_private BFA rport private functions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4770) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4771)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4772) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4773) __bfa_cb_rport_online(void *cbarg, bfa_boolean_t complete)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4774) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4775) struct bfa_rport_s *rp = cbarg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4776)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4777) if (complete)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4778) bfa_cb_rport_online(rp->rport_drv);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4779) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4780)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4781) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4782) __bfa_cb_rport_offline(void *cbarg, bfa_boolean_t complete)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4783) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4784) struct bfa_rport_s *rp = cbarg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4785)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4786) if (complete)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4787) bfa_cb_rport_offline(rp->rport_drv);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4788) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4789)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4790) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4791) bfa_rport_qresume(void *cbarg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4792) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4793) struct bfa_rport_s *rp = cbarg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4794)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4795) bfa_sm_send_event(rp, BFA_RPORT_SM_QRESUME);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4796) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4797)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4798) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4799) bfa_rport_meminfo(struct bfa_iocfc_cfg_s *cfg, struct bfa_meminfo_s *minfo,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4800) struct bfa_s *bfa)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4801) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4802) struct bfa_mem_kva_s *rport_kva = BFA_MEM_RPORT_KVA(bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4803)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4804) if (cfg->fwcfg.num_rports < BFA_RPORT_MIN)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4805) cfg->fwcfg.num_rports = BFA_RPORT_MIN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4806)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4807) /* kva memory */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4808) bfa_mem_kva_setup(minfo, rport_kva,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4809) cfg->fwcfg.num_rports * sizeof(struct bfa_rport_s));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4810) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4811)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4812) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4813) bfa_rport_attach(struct bfa_s *bfa, void *bfad, struct bfa_iocfc_cfg_s *cfg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4814) struct bfa_pcidev_s *pcidev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4815) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4816) struct bfa_rport_mod_s *mod = BFA_RPORT_MOD(bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4817) struct bfa_rport_s *rp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4818) u16 i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4819)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4820) INIT_LIST_HEAD(&mod->rp_free_q);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4821) INIT_LIST_HEAD(&mod->rp_active_q);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4822) INIT_LIST_HEAD(&mod->rp_unused_q);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4823)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4824) rp = (struct bfa_rport_s *) bfa_mem_kva_curp(mod);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4825) mod->rps_list = rp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4826) mod->num_rports = cfg->fwcfg.num_rports;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4827)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4828) WARN_ON(!mod->num_rports ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4829) (mod->num_rports & (mod->num_rports - 1)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4830)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4831) for (i = 0; i < mod->num_rports; i++, rp++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4832) memset(rp, 0, sizeof(struct bfa_rport_s));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4833) rp->bfa = bfa;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4834) rp->rport_tag = i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4835) bfa_sm_set_state(rp, bfa_rport_sm_uninit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4836)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4837) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4838) * - is unused
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4839) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4840) if (i)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4841) list_add_tail(&rp->qe, &mod->rp_free_q);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4842)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4843) bfa_reqq_winit(&rp->reqq_wait, bfa_rport_qresume, rp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4844) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4845)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4846) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4847) * consume memory
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4848) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4849) bfa_mem_kva_curp(mod) = (u8 *) rp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4850) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4851)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4852) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4853) bfa_rport_iocdisable(struct bfa_s *bfa)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4854) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4855) struct bfa_rport_mod_s *mod = BFA_RPORT_MOD(bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4856) struct bfa_rport_s *rport;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4857) struct list_head *qe, *qen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4858)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4859) /* Enqueue unused rport resources to free_q */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4860) list_splice_tail_init(&mod->rp_unused_q, &mod->rp_free_q);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4861)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4862) list_for_each_safe(qe, qen, &mod->rp_active_q) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4863) rport = (struct bfa_rport_s *) qe;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4864) bfa_sm_send_event(rport, BFA_RPORT_SM_HWFAIL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4865) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4866) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4867)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4868) static struct bfa_rport_s *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4869) bfa_rport_alloc(struct bfa_rport_mod_s *mod)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4870) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4871) struct bfa_rport_s *rport;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4872)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4873) bfa_q_deq(&mod->rp_free_q, &rport);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4874) if (rport)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4875) list_add_tail(&rport->qe, &mod->rp_active_q);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4876)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4877) return rport;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4878) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4879)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4880) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4881) bfa_rport_free(struct bfa_rport_s *rport)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4882) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4883) struct bfa_rport_mod_s *mod = BFA_RPORT_MOD(rport->bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4884)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4885) WARN_ON(!bfa_q_is_on_q(&mod->rp_active_q, rport));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4886) list_del(&rport->qe);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4887) list_add_tail(&rport->qe, &mod->rp_free_q);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4888) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4889)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4890) static bfa_boolean_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4891) bfa_rport_send_fwcreate(struct bfa_rport_s *rp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4892) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4893) struct bfi_rport_create_req_s *m;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4894)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4895) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4896) * check for room in queue to send request now
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4897) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4898) m = bfa_reqq_next(rp->bfa, BFA_REQQ_RPORT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4899) if (!m) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4900) bfa_reqq_wait(rp->bfa, BFA_REQQ_RPORT, &rp->reqq_wait);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4901) return BFA_FALSE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4902) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4903)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4904) bfi_h2i_set(m->mh, BFI_MC_RPORT, BFI_RPORT_H2I_CREATE_REQ,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4905) bfa_fn_lpu(rp->bfa));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4906) m->bfa_handle = rp->rport_tag;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4907) m->max_frmsz = cpu_to_be16(rp->rport_info.max_frmsz);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4908) m->pid = rp->rport_info.pid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4909) m->lp_fwtag = bfa_lps_get_fwtag(rp->bfa, (u8)rp->rport_info.lp_tag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4910) m->local_pid = rp->rport_info.local_pid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4911) m->fc_class = rp->rport_info.fc_class;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4912) m->vf_en = rp->rport_info.vf_en;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4913) m->vf_id = rp->rport_info.vf_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4914) m->cisc = rp->rport_info.cisc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4915)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4916) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4917) * queue I/O message to firmware
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4918) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4919) bfa_reqq_produce(rp->bfa, BFA_REQQ_RPORT, m->mh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4920) return BFA_TRUE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4921) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4922)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4923) static bfa_boolean_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4924) bfa_rport_send_fwdelete(struct bfa_rport_s *rp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4925) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4926) struct bfi_rport_delete_req_s *m;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4927)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4928) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4929) * check for room in queue to send request now
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4930) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4931) m = bfa_reqq_next(rp->bfa, BFA_REQQ_RPORT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4932) if (!m) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4933) bfa_reqq_wait(rp->bfa, BFA_REQQ_RPORT, &rp->reqq_wait);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4934) return BFA_FALSE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4935) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4936)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4937) bfi_h2i_set(m->mh, BFI_MC_RPORT, BFI_RPORT_H2I_DELETE_REQ,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4938) bfa_fn_lpu(rp->bfa));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4939) m->fw_handle = rp->fw_handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4940)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4941) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4942) * queue I/O message to firmware
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4943) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4944) bfa_reqq_produce(rp->bfa, BFA_REQQ_RPORT, m->mh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4945) return BFA_TRUE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4946) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4947)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4948) static bfa_boolean_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4949) bfa_rport_send_fwspeed(struct bfa_rport_s *rp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4950) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4951) struct bfa_rport_speed_req_s *m;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4952)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4953) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4954) * check for room in queue to send request now
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4955) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4956) m = bfa_reqq_next(rp->bfa, BFA_REQQ_RPORT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4957) if (!m) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4958) bfa_trc(rp->bfa, rp->rport_info.speed);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4959) return BFA_FALSE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4960) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4961)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4962) bfi_h2i_set(m->mh, BFI_MC_RPORT, BFI_RPORT_H2I_SET_SPEED_REQ,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4963) bfa_fn_lpu(rp->bfa));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4964) m->fw_handle = rp->fw_handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4965) m->speed = (u8)rp->rport_info.speed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4966)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4967) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4968) * queue I/O message to firmware
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4969) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4970) bfa_reqq_produce(rp->bfa, BFA_REQQ_RPORT, m->mh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4971) return BFA_TRUE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4972) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4973)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4974)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4975)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4976) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4977) * bfa_rport_public
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4978) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4979)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4980) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4981) * Rport interrupt processing.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4982) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4983) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4984) bfa_rport_isr(struct bfa_s *bfa, struct bfi_msg_s *m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4985) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4986) union bfi_rport_i2h_msg_u msg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4987) struct bfa_rport_s *rp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4988)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4989) bfa_trc(bfa, m->mhdr.msg_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4990)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4991) msg.msg = m;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4992)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4993) switch (m->mhdr.msg_id) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4994) case BFI_RPORT_I2H_CREATE_RSP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4995) rp = BFA_RPORT_FROM_TAG(bfa, msg.create_rsp->bfa_handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4996) rp->fw_handle = msg.create_rsp->fw_handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4997) rp->qos_attr = msg.create_rsp->qos_attr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4998) bfa_rport_set_lunmask(bfa, rp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4999) WARN_ON(msg.create_rsp->status != BFA_STATUS_OK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5000) bfa_sm_send_event(rp, BFA_RPORT_SM_FWRSP);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5001) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5002)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5003) case BFI_RPORT_I2H_DELETE_RSP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5004) rp = BFA_RPORT_FROM_TAG(bfa, msg.delete_rsp->bfa_handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5005) WARN_ON(msg.delete_rsp->status != BFA_STATUS_OK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5006) bfa_rport_unset_lunmask(bfa, rp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5007) bfa_sm_send_event(rp, BFA_RPORT_SM_FWRSP);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5008) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5009)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5010) case BFI_RPORT_I2H_QOS_SCN:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5011) rp = BFA_RPORT_FROM_TAG(bfa, msg.qos_scn_evt->bfa_handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5012) rp->event_arg.fw_msg = msg.qos_scn_evt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5013) bfa_sm_send_event(rp, BFA_RPORT_SM_QOS_SCN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5014) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5015)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5016) case BFI_RPORT_I2H_LIP_SCN_ONLINE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5017) bfa_fcport_update_loop_info(BFA_FCPORT_MOD(bfa),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5018) &msg.lip_scn->loop_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5019) bfa_cb_rport_scn_online(bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5020) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5021)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5022) case BFI_RPORT_I2H_LIP_SCN_OFFLINE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5023) bfa_cb_rport_scn_offline(bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5024) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5025)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5026) case BFI_RPORT_I2H_NO_DEV:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5027) rp = BFA_RPORT_FROM_TAG(bfa, msg.lip_scn->bfa_handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5028) bfa_cb_rport_scn_no_dev(rp->rport_drv);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5029) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5030)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5031) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5032) bfa_trc(bfa, m->mhdr.msg_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5033) WARN_ON(1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5034) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5035) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5036)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5037) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5038) bfa_rport_res_recfg(struct bfa_s *bfa, u16 num_rport_fw)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5039) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5040) struct bfa_rport_mod_s *mod = BFA_RPORT_MOD(bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5041) struct list_head *qe;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5042) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5043)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5044) for (i = 0; i < (mod->num_rports - num_rport_fw); i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5045) bfa_q_deq_tail(&mod->rp_free_q, &qe);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5046) list_add_tail(qe, &mod->rp_unused_q);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5047) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5048) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5049)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5050) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5051) * bfa_rport_api
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5052) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5053)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5054) struct bfa_rport_s *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5055) bfa_rport_create(struct bfa_s *bfa, void *rport_drv)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5056) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5057) struct bfa_rport_s *rp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5058)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5059) rp = bfa_rport_alloc(BFA_RPORT_MOD(bfa));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5060)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5061) if (rp == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5062) return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5063)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5064) rp->bfa = bfa;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5065) rp->rport_drv = rport_drv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5066) memset(&rp->stats, 0, sizeof(rp->stats));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5067)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5068) WARN_ON(!bfa_sm_cmp_state(rp, bfa_rport_sm_uninit));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5069) bfa_sm_send_event(rp, BFA_RPORT_SM_CREATE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5070)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5071) return rp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5072) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5073)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5074) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5075) bfa_rport_online(struct bfa_rport_s *rport, struct bfa_rport_info_s *rport_info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5076) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5077) WARN_ON(rport_info->max_frmsz == 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5078)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5079) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5080) * Some JBODs are seen to be not setting PDU size correctly in PLOGI
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5081) * responses. Default to minimum size.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5082) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5083) if (rport_info->max_frmsz == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5084) bfa_trc(rport->bfa, rport->rport_tag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5085) rport_info->max_frmsz = FC_MIN_PDUSZ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5086) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5087)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5088) rport->rport_info = *rport_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5089) bfa_sm_send_event(rport, BFA_RPORT_SM_ONLINE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5090) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5091)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5092) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5093) bfa_rport_speed(struct bfa_rport_s *rport, enum bfa_port_speed speed)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5094) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5095) WARN_ON(speed == 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5096) WARN_ON(speed == BFA_PORT_SPEED_AUTO);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5097)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5098) if (rport) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5099) rport->rport_info.speed = speed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5100) bfa_sm_send_event(rport, BFA_RPORT_SM_SET_SPEED);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5101) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5102) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5103)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5104) /* Set Rport LUN Mask */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5105) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5106) bfa_rport_set_lunmask(struct bfa_s *bfa, struct bfa_rport_s *rp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5107) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5108) struct bfa_lps_mod_s *lps_mod = BFA_LPS_MOD(bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5109) wwn_t lp_wwn, rp_wwn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5110) u8 lp_tag = (u8)rp->rport_info.lp_tag;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5111)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5112) rp_wwn = ((struct bfa_fcs_rport_s *)rp->rport_drv)->pwwn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5113) lp_wwn = (BFA_LPS_FROM_TAG(lps_mod, rp->rport_info.lp_tag))->pwwn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5114)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5115) BFA_LPS_FROM_TAG(lps_mod, rp->rport_info.lp_tag)->lun_mask =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5116) rp->lun_mask = BFA_TRUE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5117) bfa_fcpim_lunmask_rp_update(bfa, lp_wwn, rp_wwn, rp->rport_tag, lp_tag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5118) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5119)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5120) /* Unset Rport LUN mask */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5121) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5122) bfa_rport_unset_lunmask(struct bfa_s *bfa, struct bfa_rport_s *rp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5123) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5124) struct bfa_lps_mod_s *lps_mod = BFA_LPS_MOD(bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5125) wwn_t lp_wwn, rp_wwn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5126)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5127) rp_wwn = ((struct bfa_fcs_rport_s *)rp->rport_drv)->pwwn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5128) lp_wwn = (BFA_LPS_FROM_TAG(lps_mod, rp->rport_info.lp_tag))->pwwn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5129)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5130) BFA_LPS_FROM_TAG(lps_mod, rp->rport_info.lp_tag)->lun_mask =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5131) rp->lun_mask = BFA_FALSE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5132) bfa_fcpim_lunmask_rp_update(bfa, lp_wwn, rp_wwn,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5133) BFA_RPORT_TAG_INVALID, BFA_LP_TAG_INVALID);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5134) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5135)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5136) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5137) * SGPG related functions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5138) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5139)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5140) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5141) * Compute and return memory needed by FCP(im) module.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5142) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5143) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5144) bfa_sgpg_meminfo(struct bfa_iocfc_cfg_s *cfg, struct bfa_meminfo_s *minfo,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5145) struct bfa_s *bfa)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5146) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5147) struct bfa_sgpg_mod_s *sgpg_mod = BFA_SGPG_MOD(bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5148) struct bfa_mem_kva_s *sgpg_kva = BFA_MEM_SGPG_KVA(bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5149) struct bfa_mem_dma_s *seg_ptr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5150) u16 nsegs, idx, per_seg_sgpg, num_sgpg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5151) u32 sgpg_sz = sizeof(struct bfi_sgpg_s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5152)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5153) if (cfg->drvcfg.num_sgpgs < BFA_SGPG_MIN)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5154) cfg->drvcfg.num_sgpgs = BFA_SGPG_MIN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5155) else if (cfg->drvcfg.num_sgpgs > BFA_SGPG_MAX)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5156) cfg->drvcfg.num_sgpgs = BFA_SGPG_MAX;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5157)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5158) num_sgpg = cfg->drvcfg.num_sgpgs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5159)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5160) nsegs = BFI_MEM_DMA_NSEGS(num_sgpg, sgpg_sz);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5161) per_seg_sgpg = BFI_MEM_NREQS_SEG(sgpg_sz);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5162)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5163) bfa_mem_dma_seg_iter(sgpg_mod, seg_ptr, nsegs, idx) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5164) if (num_sgpg >= per_seg_sgpg) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5165) num_sgpg -= per_seg_sgpg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5166) bfa_mem_dma_setup(minfo, seg_ptr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5167) per_seg_sgpg * sgpg_sz);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5168) } else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5169) bfa_mem_dma_setup(minfo, seg_ptr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5170) num_sgpg * sgpg_sz);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5171) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5172)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5173) /* kva memory */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5174) bfa_mem_kva_setup(minfo, sgpg_kva,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5175) cfg->drvcfg.num_sgpgs * sizeof(struct bfa_sgpg_s));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5176) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5177)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5178) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5179) bfa_sgpg_attach(struct bfa_s *bfa, void *bfad, struct bfa_iocfc_cfg_s *cfg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5180) struct bfa_pcidev_s *pcidev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5181) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5182) struct bfa_sgpg_mod_s *mod = BFA_SGPG_MOD(bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5183) struct bfa_sgpg_s *hsgpg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5184) struct bfi_sgpg_s *sgpg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5185) u64 align_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5186) struct bfa_mem_dma_s *seg_ptr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5187) u32 sgpg_sz = sizeof(struct bfi_sgpg_s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5188) u16 i, idx, nsegs, per_seg_sgpg, num_sgpg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5189)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5190) union {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5191) u64 pa;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5192) union bfi_addr_u addr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5193) } sgpg_pa, sgpg_pa_tmp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5194)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5195) INIT_LIST_HEAD(&mod->sgpg_q);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5196) INIT_LIST_HEAD(&mod->sgpg_wait_q);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5197)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5198) bfa_trc(bfa, cfg->drvcfg.num_sgpgs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5199)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5200) mod->free_sgpgs = mod->num_sgpgs = cfg->drvcfg.num_sgpgs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5201)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5202) num_sgpg = cfg->drvcfg.num_sgpgs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5203) nsegs = BFI_MEM_DMA_NSEGS(num_sgpg, sgpg_sz);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5204)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5205) /* dma/kva mem claim */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5206) hsgpg = (struct bfa_sgpg_s *) bfa_mem_kva_curp(mod);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5207)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5208) bfa_mem_dma_seg_iter(mod, seg_ptr, nsegs, idx) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5209)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5210) if (!bfa_mem_dma_virt(seg_ptr))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5211) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5212)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5213) align_len = BFA_SGPG_ROUNDUP(bfa_mem_dma_phys(seg_ptr)) -
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5214) bfa_mem_dma_phys(seg_ptr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5215)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5216) sgpg = (struct bfi_sgpg_s *)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5217) (((u8 *) bfa_mem_dma_virt(seg_ptr)) + align_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5218) sgpg_pa.pa = bfa_mem_dma_phys(seg_ptr) + align_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5219) WARN_ON(sgpg_pa.pa & (sgpg_sz - 1));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5220)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5221) per_seg_sgpg = (seg_ptr->mem_len - (u32)align_len) / sgpg_sz;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5222)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5223) for (i = 0; num_sgpg > 0 && i < per_seg_sgpg; i++, num_sgpg--) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5224) memset(hsgpg, 0, sizeof(*hsgpg));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5225) memset(sgpg, 0, sizeof(*sgpg));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5226)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5227) hsgpg->sgpg = sgpg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5228) sgpg_pa_tmp.pa = bfa_sgaddr_le(sgpg_pa.pa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5229) hsgpg->sgpg_pa = sgpg_pa_tmp.addr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5230) list_add_tail(&hsgpg->qe, &mod->sgpg_q);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5231)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5232) sgpg++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5233) hsgpg++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5234) sgpg_pa.pa += sgpg_sz;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5235) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5236) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5237)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5238) bfa_mem_kva_curp(mod) = (u8 *) hsgpg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5239) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5240)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5241) bfa_status_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5242) bfa_sgpg_malloc(struct bfa_s *bfa, struct list_head *sgpg_q, int nsgpgs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5243) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5244) struct bfa_sgpg_mod_s *mod = BFA_SGPG_MOD(bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5245) struct bfa_sgpg_s *hsgpg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5246) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5247)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5248) if (mod->free_sgpgs < nsgpgs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5249) return BFA_STATUS_ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5250)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5251) for (i = 0; i < nsgpgs; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5252) bfa_q_deq(&mod->sgpg_q, &hsgpg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5253) WARN_ON(!hsgpg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5254) list_add_tail(&hsgpg->qe, sgpg_q);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5255) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5256)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5257) mod->free_sgpgs -= nsgpgs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5258) return BFA_STATUS_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5259) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5260)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5261) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5262) bfa_sgpg_mfree(struct bfa_s *bfa, struct list_head *sgpg_q, int nsgpg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5263) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5264) struct bfa_sgpg_mod_s *mod = BFA_SGPG_MOD(bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5265) struct bfa_sgpg_wqe_s *wqe;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5266)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5267) mod->free_sgpgs += nsgpg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5268) WARN_ON(mod->free_sgpgs > mod->num_sgpgs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5269)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5270) list_splice_tail_init(sgpg_q, &mod->sgpg_q);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5271)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5272) if (list_empty(&mod->sgpg_wait_q))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5273) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5274)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5275) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5276) * satisfy as many waiting requests as possible
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5277) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5278) do {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5279) wqe = bfa_q_first(&mod->sgpg_wait_q);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5280) if (mod->free_sgpgs < wqe->nsgpg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5281) nsgpg = mod->free_sgpgs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5282) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5283) nsgpg = wqe->nsgpg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5284) bfa_sgpg_malloc(bfa, &wqe->sgpg_q, nsgpg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5285) wqe->nsgpg -= nsgpg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5286) if (wqe->nsgpg == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5287) list_del(&wqe->qe);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5288) wqe->cbfn(wqe->cbarg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5289) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5290) } while (mod->free_sgpgs && !list_empty(&mod->sgpg_wait_q));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5291) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5292)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5293) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5294) bfa_sgpg_wait(struct bfa_s *bfa, struct bfa_sgpg_wqe_s *wqe, int nsgpg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5295) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5296) struct bfa_sgpg_mod_s *mod = BFA_SGPG_MOD(bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5297)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5298) WARN_ON(nsgpg <= 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5299) WARN_ON(nsgpg <= mod->free_sgpgs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5300)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5301) wqe->nsgpg_total = wqe->nsgpg = nsgpg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5302)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5303) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5304) * allocate any left to this one first
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5305) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5306) if (mod->free_sgpgs) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5307) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5308) * no one else is waiting for SGPG
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5309) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5310) WARN_ON(!list_empty(&mod->sgpg_wait_q));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5311) list_splice_tail_init(&mod->sgpg_q, &wqe->sgpg_q);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5312) wqe->nsgpg -= mod->free_sgpgs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5313) mod->free_sgpgs = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5314) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5315)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5316) list_add_tail(&wqe->qe, &mod->sgpg_wait_q);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5317) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5318)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5319) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5320) bfa_sgpg_wcancel(struct bfa_s *bfa, struct bfa_sgpg_wqe_s *wqe)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5321) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5322) struct bfa_sgpg_mod_s *mod = BFA_SGPG_MOD(bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5323)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5324) WARN_ON(!bfa_q_is_on_q(&mod->sgpg_wait_q, wqe));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5325) list_del(&wqe->qe);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5326)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5327) if (wqe->nsgpg_total != wqe->nsgpg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5328) bfa_sgpg_mfree(bfa, &wqe->sgpg_q,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5329) wqe->nsgpg_total - wqe->nsgpg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5330) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5331)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5332) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5333) bfa_sgpg_winit(struct bfa_sgpg_wqe_s *wqe, void (*cbfn) (void *cbarg),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5334) void *cbarg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5335) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5336) INIT_LIST_HEAD(&wqe->sgpg_q);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5337) wqe->cbfn = cbfn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5338) wqe->cbarg = cbarg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5339) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5340)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5341) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5342) * UF related functions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5343) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5344) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5345) *****************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5346) * Internal functions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5347) *****************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5348) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5349) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5350) __bfa_cb_uf_recv(void *cbarg, bfa_boolean_t complete)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5351) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5352) struct bfa_uf_s *uf = cbarg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5353) struct bfa_uf_mod_s *ufm = BFA_UF_MOD(uf->bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5354)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5355) if (complete)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5356) ufm->ufrecv(ufm->cbarg, uf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5357) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5358)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5359) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5360) claim_uf_post_msgs(struct bfa_uf_mod_s *ufm)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5361) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5362) struct bfi_uf_buf_post_s *uf_bp_msg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5363) u16 i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5364) u16 buf_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5365)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5366) ufm->uf_buf_posts = (struct bfi_uf_buf_post_s *) bfa_mem_kva_curp(ufm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5367) uf_bp_msg = ufm->uf_buf_posts;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5368)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5369) for (i = 0, uf_bp_msg = ufm->uf_buf_posts; i < ufm->num_ufs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5370) i++, uf_bp_msg++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5371) memset(uf_bp_msg, 0, sizeof(struct bfi_uf_buf_post_s));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5372)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5373) uf_bp_msg->buf_tag = i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5374) buf_len = sizeof(struct bfa_uf_buf_s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5375) uf_bp_msg->buf_len = cpu_to_be16(buf_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5376) bfi_h2i_set(uf_bp_msg->mh, BFI_MC_UF, BFI_UF_H2I_BUF_POST,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5377) bfa_fn_lpu(ufm->bfa));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5378) bfa_alen_set(&uf_bp_msg->alen, buf_len, ufm_pbs_pa(ufm, i));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5379) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5380)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5381) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5382) * advance pointer beyond consumed memory
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5383) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5384) bfa_mem_kva_curp(ufm) = (u8 *) uf_bp_msg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5385) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5386)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5387) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5388) claim_ufs(struct bfa_uf_mod_s *ufm)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5389) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5390) u16 i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5391) struct bfa_uf_s *uf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5392)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5393) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5394) * Claim block of memory for UF list
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5395) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5396) ufm->uf_list = (struct bfa_uf_s *) bfa_mem_kva_curp(ufm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5397)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5398) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5399) * Initialize UFs and queue it in UF free queue
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5400) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5401) for (i = 0, uf = ufm->uf_list; i < ufm->num_ufs; i++, uf++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5402) memset(uf, 0, sizeof(struct bfa_uf_s));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5403) uf->bfa = ufm->bfa;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5404) uf->uf_tag = i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5405) uf->pb_len = BFA_PER_UF_DMA_SZ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5406) uf->buf_kva = bfa_mem_get_dmabuf_kva(ufm, i, BFA_PER_UF_DMA_SZ);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5407) uf->buf_pa = ufm_pbs_pa(ufm, i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5408) list_add_tail(&uf->qe, &ufm->uf_free_q);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5409) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5410)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5411) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5412) * advance memory pointer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5413) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5414) bfa_mem_kva_curp(ufm) = (u8 *) uf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5415) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5416)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5417) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5418) uf_mem_claim(struct bfa_uf_mod_s *ufm)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5419) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5420) claim_ufs(ufm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5421) claim_uf_post_msgs(ufm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5422) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5423)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5424) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5425) bfa_uf_meminfo(struct bfa_iocfc_cfg_s *cfg, struct bfa_meminfo_s *minfo,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5426) struct bfa_s *bfa)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5427) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5428) struct bfa_uf_mod_s *ufm = BFA_UF_MOD(bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5429) struct bfa_mem_kva_s *uf_kva = BFA_MEM_UF_KVA(bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5430) u32 num_ufs = cfg->fwcfg.num_uf_bufs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5431) struct bfa_mem_dma_s *seg_ptr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5432) u16 nsegs, idx, per_seg_uf = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5433)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5434) nsegs = BFI_MEM_DMA_NSEGS(num_ufs, BFA_PER_UF_DMA_SZ);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5435) per_seg_uf = BFI_MEM_NREQS_SEG(BFA_PER_UF_DMA_SZ);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5436)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5437) bfa_mem_dma_seg_iter(ufm, seg_ptr, nsegs, idx) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5438) if (num_ufs >= per_seg_uf) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5439) num_ufs -= per_seg_uf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5440) bfa_mem_dma_setup(minfo, seg_ptr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5441) per_seg_uf * BFA_PER_UF_DMA_SZ);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5442) } else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5443) bfa_mem_dma_setup(minfo, seg_ptr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5444) num_ufs * BFA_PER_UF_DMA_SZ);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5445) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5446)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5447) /* kva memory */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5448) bfa_mem_kva_setup(minfo, uf_kva, cfg->fwcfg.num_uf_bufs *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5449) (sizeof(struct bfa_uf_s) + sizeof(struct bfi_uf_buf_post_s)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5450) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5451)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5452) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5453) bfa_uf_attach(struct bfa_s *bfa, void *bfad, struct bfa_iocfc_cfg_s *cfg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5454) struct bfa_pcidev_s *pcidev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5455) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5456) struct bfa_uf_mod_s *ufm = BFA_UF_MOD(bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5457)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5458) ufm->bfa = bfa;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5459) ufm->num_ufs = cfg->fwcfg.num_uf_bufs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5460) INIT_LIST_HEAD(&ufm->uf_free_q);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5461) INIT_LIST_HEAD(&ufm->uf_posted_q);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5462) INIT_LIST_HEAD(&ufm->uf_unused_q);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5463)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5464) uf_mem_claim(ufm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5465) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5466)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5467) static struct bfa_uf_s *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5468) bfa_uf_get(struct bfa_uf_mod_s *uf_mod)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5469) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5470) struct bfa_uf_s *uf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5471)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5472) bfa_q_deq(&uf_mod->uf_free_q, &uf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5473) return uf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5474) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5475)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5476) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5477) bfa_uf_put(struct bfa_uf_mod_s *uf_mod, struct bfa_uf_s *uf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5478) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5479) list_add_tail(&uf->qe, &uf_mod->uf_free_q);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5480) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5481)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5482) static bfa_status_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5483) bfa_uf_post(struct bfa_uf_mod_s *ufm, struct bfa_uf_s *uf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5484) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5485) struct bfi_uf_buf_post_s *uf_post_msg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5486)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5487) uf_post_msg = bfa_reqq_next(ufm->bfa, BFA_REQQ_FCXP);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5488) if (!uf_post_msg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5489) return BFA_STATUS_FAILED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5490)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5491) memcpy(uf_post_msg, &ufm->uf_buf_posts[uf->uf_tag],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5492) sizeof(struct bfi_uf_buf_post_s));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5493) bfa_reqq_produce(ufm->bfa, BFA_REQQ_FCXP, uf_post_msg->mh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5494)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5495) bfa_trc(ufm->bfa, uf->uf_tag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5496)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5497) list_add_tail(&uf->qe, &ufm->uf_posted_q);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5498) return BFA_STATUS_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5499) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5500)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5501) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5502) bfa_uf_post_all(struct bfa_uf_mod_s *uf_mod)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5503) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5504) struct bfa_uf_s *uf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5505)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5506) while ((uf = bfa_uf_get(uf_mod)) != NULL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5507) if (bfa_uf_post(uf_mod, uf) != BFA_STATUS_OK)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5508) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5509) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5510) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5511)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5512) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5513) uf_recv(struct bfa_s *bfa, struct bfi_uf_frm_rcvd_s *m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5514) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5515) struct bfa_uf_mod_s *ufm = BFA_UF_MOD(bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5516) u16 uf_tag = m->buf_tag;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5517) struct bfa_uf_s *uf = &ufm->uf_list[uf_tag];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5518) struct bfa_uf_buf_s *uf_buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5519) uint8_t *buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5520)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5521) uf_buf = (struct bfa_uf_buf_s *)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5522) bfa_mem_get_dmabuf_kva(ufm, uf_tag, uf->pb_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5523) buf = &uf_buf->d[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5524)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5525) m->frm_len = be16_to_cpu(m->frm_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5526) m->xfr_len = be16_to_cpu(m->xfr_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5527)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5528) list_del(&uf->qe); /* dequeue from posted queue */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5529)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5530) uf->data_ptr = buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5531) uf->data_len = m->xfr_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5532)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5533) WARN_ON(uf->data_len < sizeof(struct fchs_s));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5534)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5535) if (uf->data_len == sizeof(struct fchs_s)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5536) bfa_plog_fchdr(bfa->plog, BFA_PL_MID_HAL_UF, BFA_PL_EID_RX,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5537) uf->data_len, (struct fchs_s *)buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5538) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5539) u32 pld_w0 = *((u32 *) (buf + sizeof(struct fchs_s)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5540) bfa_plog_fchdr_and_pl(bfa->plog, BFA_PL_MID_HAL_UF,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5541) BFA_PL_EID_RX, uf->data_len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5542) (struct fchs_s *)buf, pld_w0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5543) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5544)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5545) if (bfa->fcs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5546) __bfa_cb_uf_recv(uf, BFA_TRUE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5547) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5548) bfa_cb_queue(bfa, &uf->hcb_qe, __bfa_cb_uf_recv, uf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5549) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5550)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5551) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5552) bfa_uf_iocdisable(struct bfa_s *bfa)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5553) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5554) struct bfa_uf_mod_s *ufm = BFA_UF_MOD(bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5555) struct bfa_uf_s *uf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5556) struct list_head *qe, *qen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5557)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5558) /* Enqueue unused uf resources to free_q */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5559) list_splice_tail_init(&ufm->uf_unused_q, &ufm->uf_free_q);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5560)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5561) list_for_each_safe(qe, qen, &ufm->uf_posted_q) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5562) uf = (struct bfa_uf_s *) qe;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5563) list_del(&uf->qe);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5564) bfa_uf_put(ufm, uf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5565) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5566) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5567)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5568) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5569) bfa_uf_start(struct bfa_s *bfa)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5570) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5571) bfa_uf_post_all(BFA_UF_MOD(bfa));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5572) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5573)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5574) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5575) * Register handler for all unsolicted receive frames.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5576) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5577) * @param[in] bfa BFA instance
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5578) * @param[in] ufrecv receive handler function
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5579) * @param[in] cbarg receive handler arg
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5580) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5581) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5582) bfa_uf_recv_register(struct bfa_s *bfa, bfa_cb_uf_recv_t ufrecv, void *cbarg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5583) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5584) struct bfa_uf_mod_s *ufm = BFA_UF_MOD(bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5585)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5586) ufm->ufrecv = ufrecv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5587) ufm->cbarg = cbarg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5588) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5589)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5590) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5591) * Free an unsolicited frame back to BFA.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5592) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5593) * @param[in] uf unsolicited frame to be freed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5594) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5595) * @return None
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5596) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5597) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5598) bfa_uf_free(struct bfa_uf_s *uf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5599) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5600) bfa_uf_put(BFA_UF_MOD(uf->bfa), uf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5601) bfa_uf_post_all(BFA_UF_MOD(uf->bfa));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5602) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5603)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5604)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5605)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5606) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5607) * uf_pub BFA uf module public functions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5608) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5609) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5610) bfa_uf_isr(struct bfa_s *bfa, struct bfi_msg_s *msg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5611) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5612) bfa_trc(bfa, msg->mhdr.msg_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5613)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5614) switch (msg->mhdr.msg_id) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5615) case BFI_UF_I2H_FRM_RCVD:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5616) uf_recv(bfa, (struct bfi_uf_frm_rcvd_s *) msg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5617) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5618)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5619) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5620) bfa_trc(bfa, msg->mhdr.msg_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5621) WARN_ON(1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5622) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5623) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5624)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5625) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5626) bfa_uf_res_recfg(struct bfa_s *bfa, u16 num_uf_fw)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5627) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5628) struct bfa_uf_mod_s *mod = BFA_UF_MOD(bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5629) struct list_head *qe;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5630) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5631)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5632) for (i = 0; i < (mod->num_ufs - num_uf_fw); i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5633) bfa_q_deq_tail(&mod->uf_free_q, &qe);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5634) list_add_tail(qe, &mod->uf_unused_q);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5635) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5636) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5637)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5638) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5639) * Dport forward declaration
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5640) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5641)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5642) enum bfa_dport_test_state_e {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5643) BFA_DPORT_ST_DISABLED = 0, /*!< dport is disabled */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5644) BFA_DPORT_ST_INP = 1, /*!< test in progress */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5645) BFA_DPORT_ST_COMP = 2, /*!< test complete successfully */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5646) BFA_DPORT_ST_NO_SFP = 3, /*!< sfp is not present */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5647) BFA_DPORT_ST_NOTSTART = 4, /*!< test not start dport is enabled */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5648) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5649)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5650) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5651) * BFA DPORT state machine events
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5652) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5653) enum bfa_dport_sm_event {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5654) BFA_DPORT_SM_ENABLE = 1, /* dport enable event */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5655) BFA_DPORT_SM_DISABLE = 2, /* dport disable event */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5656) BFA_DPORT_SM_FWRSP = 3, /* fw enable/disable rsp */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5657) BFA_DPORT_SM_QRESUME = 4, /* CQ space available */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5658) BFA_DPORT_SM_HWFAIL = 5, /* IOC h/w failure */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5659) BFA_DPORT_SM_START = 6, /* re-start dport test */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5660) BFA_DPORT_SM_REQFAIL = 7, /* request failure */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5661) BFA_DPORT_SM_SCN = 8, /* state change notify frm fw */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5662) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5663)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5664) static void bfa_dport_sm_disabled(struct bfa_dport_s *dport,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5665) enum bfa_dport_sm_event event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5666) static void bfa_dport_sm_enabling_qwait(struct bfa_dport_s *dport,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5667) enum bfa_dport_sm_event event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5668) static void bfa_dport_sm_enabling(struct bfa_dport_s *dport,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5669) enum bfa_dport_sm_event event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5670) static void bfa_dport_sm_enabled(struct bfa_dport_s *dport,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5671) enum bfa_dport_sm_event event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5672) static void bfa_dport_sm_disabling_qwait(struct bfa_dport_s *dport,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5673) enum bfa_dport_sm_event event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5674) static void bfa_dport_sm_disabling(struct bfa_dport_s *dport,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5675) enum bfa_dport_sm_event event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5676) static void bfa_dport_sm_starting_qwait(struct bfa_dport_s *dport,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5677) enum bfa_dport_sm_event event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5678) static void bfa_dport_sm_starting(struct bfa_dport_s *dport,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5679) enum bfa_dport_sm_event event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5680) static void bfa_dport_sm_dynamic_disabling(struct bfa_dport_s *dport,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5681) enum bfa_dport_sm_event event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5682) static void bfa_dport_sm_dynamic_disabling_qwait(struct bfa_dport_s *dport,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5683) enum bfa_dport_sm_event event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5684) static void bfa_dport_qresume(void *cbarg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5685) static void bfa_dport_req_comp(struct bfa_dport_s *dport,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5686) struct bfi_diag_dport_rsp_s *msg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5687) static void bfa_dport_scn(struct bfa_dport_s *dport,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5688) struct bfi_diag_dport_scn_s *msg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5689)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5690) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5691) * BFA fcdiag module
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5692) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5693) #define BFA_DIAG_QTEST_TOV 1000 /* msec */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5694)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5695) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5696) * Set port status to busy
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5697) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5698) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5699) bfa_fcdiag_set_busy_status(struct bfa_fcdiag_s *fcdiag)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5700) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5701) struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(fcdiag->bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5702)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5703) if (fcdiag->lb.lock)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5704) fcport->diag_busy = BFA_TRUE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5705) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5706) fcport->diag_busy = BFA_FALSE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5707) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5708)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5709) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5710) bfa_fcdiag_attach(struct bfa_s *bfa, void *bfad, struct bfa_iocfc_cfg_s *cfg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5711) struct bfa_pcidev_s *pcidev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5712) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5713) struct bfa_fcdiag_s *fcdiag = BFA_FCDIAG_MOD(bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5714) struct bfa_dport_s *dport = &fcdiag->dport;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5715)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5716) fcdiag->bfa = bfa;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5717) fcdiag->trcmod = bfa->trcmod;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5718) /* The common DIAG attach bfa_diag_attach() will do all memory claim */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5719) dport->bfa = bfa;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5720) bfa_sm_set_state(dport, bfa_dport_sm_disabled);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5721) bfa_reqq_winit(&dport->reqq_wait, bfa_dport_qresume, dport);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5722) dport->cbfn = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5723) dport->cbarg = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5724) dport->test_state = BFA_DPORT_ST_DISABLED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5725) memset(&dport->result, 0, sizeof(struct bfa_diag_dport_result_s));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5726) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5727)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5728) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5729) bfa_fcdiag_iocdisable(struct bfa_s *bfa)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5730) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5731) struct bfa_fcdiag_s *fcdiag = BFA_FCDIAG_MOD(bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5732) struct bfa_dport_s *dport = &fcdiag->dport;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5733)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5734) bfa_trc(fcdiag, fcdiag->lb.lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5735) if (fcdiag->lb.lock) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5736) fcdiag->lb.status = BFA_STATUS_IOC_FAILURE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5737) fcdiag->lb.cbfn(fcdiag->lb.cbarg, fcdiag->lb.status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5738) fcdiag->lb.lock = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5739) bfa_fcdiag_set_busy_status(fcdiag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5740) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5741)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5742) bfa_sm_send_event(dport, BFA_DPORT_SM_HWFAIL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5743) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5744)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5745) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5746) bfa_fcdiag_queuetest_timeout(void *cbarg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5747) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5748) struct bfa_fcdiag_s *fcdiag = cbarg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5749) struct bfa_diag_qtest_result_s *res = fcdiag->qtest.result;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5750)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5751) bfa_trc(fcdiag, fcdiag->qtest.all);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5752) bfa_trc(fcdiag, fcdiag->qtest.count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5753)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5754) fcdiag->qtest.timer_active = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5755)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5756) res->status = BFA_STATUS_ETIMER;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5757) res->count = QTEST_CNT_DEFAULT - fcdiag->qtest.count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5758) if (fcdiag->qtest.all)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5759) res->queue = fcdiag->qtest.all;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5760)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5761) bfa_trc(fcdiag, BFA_STATUS_ETIMER);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5762) fcdiag->qtest.status = BFA_STATUS_ETIMER;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5763) fcdiag->qtest.cbfn(fcdiag->qtest.cbarg, fcdiag->qtest.status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5764) fcdiag->qtest.lock = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5765) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5766)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5767) static bfa_status_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5768) bfa_fcdiag_queuetest_send(struct bfa_fcdiag_s *fcdiag)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5769) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5770) u32 i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5771) struct bfi_diag_qtest_req_s *req;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5772)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5773) req = bfa_reqq_next(fcdiag->bfa, fcdiag->qtest.queue);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5774) if (!req)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5775) return BFA_STATUS_DEVBUSY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5776)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5777) /* build host command */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5778) bfi_h2i_set(req->mh, BFI_MC_DIAG, BFI_DIAG_H2I_QTEST,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5779) bfa_fn_lpu(fcdiag->bfa));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5780)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5781) for (i = 0; i < BFI_LMSG_PL_WSZ; i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5782) req->data[i] = QTEST_PAT_DEFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5783)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5784) bfa_trc(fcdiag, fcdiag->qtest.queue);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5785) /* ring door bell */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5786) bfa_reqq_produce(fcdiag->bfa, fcdiag->qtest.queue, req->mh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5787) return BFA_STATUS_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5788) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5789)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5790) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5791) bfa_fcdiag_queuetest_comp(struct bfa_fcdiag_s *fcdiag,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5792) bfi_diag_qtest_rsp_t *rsp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5793) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5794) struct bfa_diag_qtest_result_s *res = fcdiag->qtest.result;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5795) bfa_status_t status = BFA_STATUS_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5796) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5797)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5798) /* Check timer, should still be active */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5799) if (!fcdiag->qtest.timer_active) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5800) bfa_trc(fcdiag, fcdiag->qtest.timer_active);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5801) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5802) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5803)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5804) /* update count */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5805) fcdiag->qtest.count--;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5806)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5807) /* Check result */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5808) for (i = 0; i < BFI_LMSG_PL_WSZ; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5809) if (rsp->data[i] != ~(QTEST_PAT_DEFAULT)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5810) res->status = BFA_STATUS_DATACORRUPTED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5811) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5812) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5813) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5814)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5815) if (res->status == BFA_STATUS_OK) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5816) if (fcdiag->qtest.count > 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5817) status = bfa_fcdiag_queuetest_send(fcdiag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5818) if (status == BFA_STATUS_OK)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5819) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5820) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5821) res->status = status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5822) } else if (fcdiag->qtest.all > 0 &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5823) fcdiag->qtest.queue < (BFI_IOC_MAX_CQS - 1)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5824) fcdiag->qtest.count = QTEST_CNT_DEFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5825) fcdiag->qtest.queue++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5826) status = bfa_fcdiag_queuetest_send(fcdiag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5827) if (status == BFA_STATUS_OK)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5828) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5829) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5830) res->status = status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5831) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5832) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5833)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5834) /* Stop timer when we comp all queue */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5835) if (fcdiag->qtest.timer_active) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5836) bfa_timer_stop(&fcdiag->qtest.timer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5837) fcdiag->qtest.timer_active = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5838) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5839) res->queue = fcdiag->qtest.queue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5840) res->count = QTEST_CNT_DEFAULT - fcdiag->qtest.count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5841) bfa_trc(fcdiag, res->count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5842) bfa_trc(fcdiag, res->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5843) fcdiag->qtest.status = res->status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5844) fcdiag->qtest.cbfn(fcdiag->qtest.cbarg, fcdiag->qtest.status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5845) fcdiag->qtest.lock = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5846) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5847)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5848) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5849) bfa_fcdiag_loopback_comp(struct bfa_fcdiag_s *fcdiag,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5850) struct bfi_diag_lb_rsp_s *rsp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5851) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5852) struct bfa_diag_loopback_result_s *res = fcdiag->lb.result;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5853)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5854) res->numtxmfrm = be32_to_cpu(rsp->res.numtxmfrm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5855) res->numosffrm = be32_to_cpu(rsp->res.numosffrm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5856) res->numrcvfrm = be32_to_cpu(rsp->res.numrcvfrm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5857) res->badfrminf = be32_to_cpu(rsp->res.badfrminf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5858) res->badfrmnum = be32_to_cpu(rsp->res.badfrmnum);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5859) res->status = rsp->res.status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5860) fcdiag->lb.status = rsp->res.status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5861) bfa_trc(fcdiag, fcdiag->lb.status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5862) fcdiag->lb.cbfn(fcdiag->lb.cbarg, fcdiag->lb.status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5863) fcdiag->lb.lock = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5864) bfa_fcdiag_set_busy_status(fcdiag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5865) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5866)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5867) static bfa_status_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5868) bfa_fcdiag_loopback_send(struct bfa_fcdiag_s *fcdiag,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5869) struct bfa_diag_loopback_s *loopback)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5870) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5871) struct bfi_diag_lb_req_s *lb_req;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5872)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5873) lb_req = bfa_reqq_next(fcdiag->bfa, BFA_REQQ_DIAG);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5874) if (!lb_req)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5875) return BFA_STATUS_DEVBUSY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5876)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5877) /* build host command */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5878) bfi_h2i_set(lb_req->mh, BFI_MC_DIAG, BFI_DIAG_H2I_LOOPBACK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5879) bfa_fn_lpu(fcdiag->bfa));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5880)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5881) lb_req->lb_mode = loopback->lb_mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5882) lb_req->speed = loopback->speed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5883) lb_req->loopcnt = loopback->loopcnt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5884) lb_req->pattern = loopback->pattern;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5885)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5886) /* ring door bell */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5887) bfa_reqq_produce(fcdiag->bfa, BFA_REQQ_DIAG, lb_req->mh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5888)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5889) bfa_trc(fcdiag, loopback->lb_mode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5890) bfa_trc(fcdiag, loopback->speed);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5891) bfa_trc(fcdiag, loopback->loopcnt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5892) bfa_trc(fcdiag, loopback->pattern);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5893) return BFA_STATUS_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5894) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5895)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5896) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5897) * cpe/rme intr handler
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5898) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5899) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5900) bfa_fcdiag_intr(struct bfa_s *bfa, struct bfi_msg_s *msg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5901) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5902) struct bfa_fcdiag_s *fcdiag = BFA_FCDIAG_MOD(bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5903)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5904) switch (msg->mhdr.msg_id) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5905) case BFI_DIAG_I2H_LOOPBACK:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5906) bfa_fcdiag_loopback_comp(fcdiag,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5907) (struct bfi_diag_lb_rsp_s *) msg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5908) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5909) case BFI_DIAG_I2H_QTEST:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5910) bfa_fcdiag_queuetest_comp(fcdiag, (bfi_diag_qtest_rsp_t *)msg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5911) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5912) case BFI_DIAG_I2H_DPORT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5913) bfa_dport_req_comp(&fcdiag->dport,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5914) (struct bfi_diag_dport_rsp_s *)msg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5915) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5916) case BFI_DIAG_I2H_DPORT_SCN:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5917) bfa_dport_scn(&fcdiag->dport,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5918) (struct bfi_diag_dport_scn_s *)msg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5919) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5920) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5921) bfa_trc(fcdiag, msg->mhdr.msg_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5922) WARN_ON(1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5923) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5924) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5925)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5926) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5927) * Loopback test
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5928) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5929) * @param[in] *bfa - bfa data struct
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5930) * @param[in] opmode - port operation mode
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5931) * @param[in] speed - port speed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5932) * @param[in] lpcnt - loop count
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5933) * @param[in] pat - pattern to build packet
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5934) * @param[in] *result - pt to bfa_diag_loopback_result_t data struct
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5935) * @param[in] cbfn - callback function
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5936) * @param[in] cbarg - callback functioin arg
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5937) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5938) * @param[out]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5939) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5940) bfa_status_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5941) bfa_fcdiag_loopback(struct bfa_s *bfa, enum bfa_port_opmode opmode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5942) enum bfa_port_speed speed, u32 lpcnt, u32 pat,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5943) struct bfa_diag_loopback_result_s *result, bfa_cb_diag_t cbfn,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5944) void *cbarg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5945) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5946) struct bfa_diag_loopback_s loopback;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5947) struct bfa_port_attr_s attr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5948) bfa_status_t status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5949) struct bfa_fcdiag_s *fcdiag = BFA_FCDIAG_MOD(bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5950)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5951) if (!bfa_iocfc_is_operational(bfa))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5952) return BFA_STATUS_IOC_NON_OP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5953)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5954) /* if port is PBC disabled, return error */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5955) if (bfa_fcport_is_pbcdisabled(bfa)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5956) bfa_trc(fcdiag, BFA_STATUS_PBC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5957) return BFA_STATUS_PBC;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5958) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5959)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5960) if (bfa_fcport_is_disabled(bfa) == BFA_FALSE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5961) bfa_trc(fcdiag, opmode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5962) return BFA_STATUS_PORT_NOT_DISABLED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5963) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5964)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5965) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5966) * Check if input speed is supported by the port mode
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5967) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5968) if (bfa_ioc_get_type(&bfa->ioc) == BFA_IOC_TYPE_FC) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5969) if (!(speed == BFA_PORT_SPEED_1GBPS ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5970) speed == BFA_PORT_SPEED_2GBPS ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5971) speed == BFA_PORT_SPEED_4GBPS ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5972) speed == BFA_PORT_SPEED_8GBPS ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5973) speed == BFA_PORT_SPEED_16GBPS ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5974) speed == BFA_PORT_SPEED_AUTO)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5975) bfa_trc(fcdiag, speed);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5976) return BFA_STATUS_UNSUPP_SPEED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5977) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5978) bfa_fcport_get_attr(bfa, &attr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5979) bfa_trc(fcdiag, attr.speed_supported);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5980) if (speed > attr.speed_supported)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5981) return BFA_STATUS_UNSUPP_SPEED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5982) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5983) if (speed != BFA_PORT_SPEED_10GBPS) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5984) bfa_trc(fcdiag, speed);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5985) return BFA_STATUS_UNSUPP_SPEED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5986) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5987) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5988)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5989) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5990) * For CT2, 1G is not supported
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5991) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5992) if ((speed == BFA_PORT_SPEED_1GBPS) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5993) (bfa_asic_id_ct2(bfa->ioc.pcidev.device_id))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5994) bfa_trc(fcdiag, speed);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5995) return BFA_STATUS_UNSUPP_SPEED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5996) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5997)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5998) /* For Mezz card, port speed entered needs to be checked */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5999) if (bfa_mfg_is_mezz(bfa->ioc.attr->card_type)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6000) if (bfa_ioc_get_type(&bfa->ioc) == BFA_IOC_TYPE_FC) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6001) if (!(speed == BFA_PORT_SPEED_1GBPS ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6002) speed == BFA_PORT_SPEED_2GBPS ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6003) speed == BFA_PORT_SPEED_4GBPS ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6004) speed == BFA_PORT_SPEED_8GBPS ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6005) speed == BFA_PORT_SPEED_16GBPS ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6006) speed == BFA_PORT_SPEED_AUTO))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6007) return BFA_STATUS_UNSUPP_SPEED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6008) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6009) if (speed != BFA_PORT_SPEED_10GBPS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6010) return BFA_STATUS_UNSUPP_SPEED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6011) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6012) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6013) /* check to see if fcport is dport */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6014) if (bfa_fcport_is_dport(bfa)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6015) bfa_trc(fcdiag, fcdiag->lb.lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6016) return BFA_STATUS_DPORT_ENABLED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6017) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6018) /* check to see if there is another destructive diag cmd running */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6019) if (fcdiag->lb.lock) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6020) bfa_trc(fcdiag, fcdiag->lb.lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6021) return BFA_STATUS_DEVBUSY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6022) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6023)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6024) fcdiag->lb.lock = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6025) loopback.lb_mode = opmode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6026) loopback.speed = speed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6027) loopback.loopcnt = lpcnt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6028) loopback.pattern = pat;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6029) fcdiag->lb.result = result;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6030) fcdiag->lb.cbfn = cbfn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6031) fcdiag->lb.cbarg = cbarg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6032) memset(result, 0, sizeof(struct bfa_diag_loopback_result_s));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6033) bfa_fcdiag_set_busy_status(fcdiag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6034)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6035) /* Send msg to fw */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6036) status = bfa_fcdiag_loopback_send(fcdiag, &loopback);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6037) return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6038) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6039)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6040) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6041) * DIAG queue test command
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6042) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6043) * @param[in] *bfa - bfa data struct
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6044) * @param[in] force - 1: don't do ioc op checking
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6045) * @param[in] queue - queue no. to test
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6046) * @param[in] *result - pt to bfa_diag_qtest_result_t data struct
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6047) * @param[in] cbfn - callback function
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6048) * @param[in] *cbarg - callback functioin arg
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6049) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6050) * @param[out]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6051) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6052) bfa_status_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6053) bfa_fcdiag_queuetest(struct bfa_s *bfa, u32 force, u32 queue,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6054) struct bfa_diag_qtest_result_s *result, bfa_cb_diag_t cbfn,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6055) void *cbarg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6056) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6057) struct bfa_fcdiag_s *fcdiag = BFA_FCDIAG_MOD(bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6058) bfa_status_t status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6059) bfa_trc(fcdiag, force);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6060) bfa_trc(fcdiag, queue);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6061)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6062) if (!force && !bfa_iocfc_is_operational(bfa))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6063) return BFA_STATUS_IOC_NON_OP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6064)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6065) /* check to see if there is another destructive diag cmd running */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6066) if (fcdiag->qtest.lock) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6067) bfa_trc(fcdiag, fcdiag->qtest.lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6068) return BFA_STATUS_DEVBUSY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6069) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6070)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6071) /* Initialization */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6072) fcdiag->qtest.lock = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6073) fcdiag->qtest.cbfn = cbfn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6074) fcdiag->qtest.cbarg = cbarg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6075) fcdiag->qtest.result = result;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6076) fcdiag->qtest.count = QTEST_CNT_DEFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6077)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6078) /* Init test results */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6079) fcdiag->qtest.result->status = BFA_STATUS_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6080) fcdiag->qtest.result->count = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6081)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6082) /* send */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6083) if (queue < BFI_IOC_MAX_CQS) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6084) fcdiag->qtest.result->queue = (u8)queue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6085) fcdiag->qtest.queue = (u8)queue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6086) fcdiag->qtest.all = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6087) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6088) fcdiag->qtest.result->queue = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6089) fcdiag->qtest.queue = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6090) fcdiag->qtest.all = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6091) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6092) status = bfa_fcdiag_queuetest_send(fcdiag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6093)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6094) /* Start a timer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6095) if (status == BFA_STATUS_OK) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6096) bfa_timer_start(bfa, &fcdiag->qtest.timer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6097) bfa_fcdiag_queuetest_timeout, fcdiag,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6098) BFA_DIAG_QTEST_TOV);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6099) fcdiag->qtest.timer_active = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6100) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6101) return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6102) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6103)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6104) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6105) * DIAG PLB is running
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6106) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6107) * @param[in] *bfa - bfa data struct
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6108) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6109) * @param[out]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6110) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6111) bfa_status_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6112) bfa_fcdiag_lb_is_running(struct bfa_s *bfa)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6113) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6114) struct bfa_fcdiag_s *fcdiag = BFA_FCDIAG_MOD(bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6115) return fcdiag->lb.lock ? BFA_STATUS_DIAG_BUSY : BFA_STATUS_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6116) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6117)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6118) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6119) * D-port
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6120) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6121) #define bfa_dport_result_start(__dport, __mode) do { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6122) (__dport)->result.start_time = ktime_get_real_seconds(); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6123) (__dport)->result.status = DPORT_TEST_ST_INPRG; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6124) (__dport)->result.mode = (__mode); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6125) (__dport)->result.rp_pwwn = (__dport)->rp_pwwn; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6126) (__dport)->result.rp_nwwn = (__dport)->rp_nwwn; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6127) (__dport)->result.lpcnt = (__dport)->lpcnt; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6128) } while (0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6129)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6130) static bfa_boolean_t bfa_dport_send_req(struct bfa_dport_s *dport,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6131) enum bfi_dport_req req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6132) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6133) bfa_cb_fcdiag_dport(struct bfa_dport_s *dport, bfa_status_t bfa_status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6134) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6135) if (dport->cbfn != NULL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6136) dport->cbfn(dport->cbarg, bfa_status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6137) dport->cbfn = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6138) dport->cbarg = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6139) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6140) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6141)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6142) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6143) bfa_dport_sm_disabled(struct bfa_dport_s *dport, enum bfa_dport_sm_event event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6144) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6145) bfa_trc(dport->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6146)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6147) switch (event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6148) case BFA_DPORT_SM_ENABLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6149) bfa_fcport_dportenable(dport->bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6150) if (bfa_dport_send_req(dport, BFI_DPORT_ENABLE))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6151) bfa_sm_set_state(dport, bfa_dport_sm_enabling);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6152) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6153) bfa_sm_set_state(dport, bfa_dport_sm_enabling_qwait);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6154) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6155)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6156) case BFA_DPORT_SM_DISABLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6157) /* Already disabled */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6158) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6159)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6160) case BFA_DPORT_SM_HWFAIL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6161) /* ignore */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6162) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6163)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6164) case BFA_DPORT_SM_SCN:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6165) if (dport->i2hmsg.scn.state == BFI_DPORT_SCN_DDPORT_ENABLE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6166) bfa_fcport_ddportenable(dport->bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6167) dport->dynamic = BFA_TRUE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6168) dport->test_state = BFA_DPORT_ST_NOTSTART;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6169) bfa_sm_set_state(dport, bfa_dport_sm_enabled);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6170) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6171) bfa_trc(dport->bfa, dport->i2hmsg.scn.state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6172) WARN_ON(1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6173) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6174) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6175)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6176) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6177) bfa_sm_fault(dport->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6178) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6179) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6180)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6181) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6182) bfa_dport_sm_enabling_qwait(struct bfa_dport_s *dport,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6183) enum bfa_dport_sm_event event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6184) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6185) bfa_trc(dport->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6186)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6187) switch (event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6188) case BFA_DPORT_SM_QRESUME:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6189) bfa_sm_set_state(dport, bfa_dport_sm_enabling);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6190) bfa_dport_send_req(dport, BFI_DPORT_ENABLE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6191) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6192)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6193) case BFA_DPORT_SM_HWFAIL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6194) bfa_reqq_wcancel(&dport->reqq_wait);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6195) bfa_sm_set_state(dport, bfa_dport_sm_disabled);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6196) bfa_cb_fcdiag_dport(dport, BFA_STATUS_FAILED);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6197) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6198)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6199) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6200) bfa_sm_fault(dport->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6201) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6202) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6203)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6204) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6205) bfa_dport_sm_enabling(struct bfa_dport_s *dport, enum bfa_dport_sm_event event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6206) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6207) bfa_trc(dport->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6208)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6209) switch (event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6210) case BFA_DPORT_SM_FWRSP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6211) memset(&dport->result, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6212) sizeof(struct bfa_diag_dport_result_s));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6213) if (dport->i2hmsg.rsp.status == BFA_STATUS_DPORT_INV_SFP) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6214) dport->test_state = BFA_DPORT_ST_NO_SFP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6215) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6216) dport->test_state = BFA_DPORT_ST_INP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6217) bfa_dport_result_start(dport, BFA_DPORT_OPMODE_AUTO);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6218) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6219) bfa_sm_set_state(dport, bfa_dport_sm_enabled);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6220) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6221)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6222) case BFA_DPORT_SM_REQFAIL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6223) dport->test_state = BFA_DPORT_ST_DISABLED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6224) bfa_fcport_dportdisable(dport->bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6225) bfa_sm_set_state(dport, bfa_dport_sm_disabled);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6226) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6227)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6228) case BFA_DPORT_SM_HWFAIL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6229) bfa_sm_set_state(dport, bfa_dport_sm_disabled);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6230) bfa_cb_fcdiag_dport(dport, BFA_STATUS_FAILED);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6231) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6232)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6233) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6234) bfa_sm_fault(dport->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6235) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6236) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6237)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6238) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6239) bfa_dport_sm_enabled(struct bfa_dport_s *dport, enum bfa_dport_sm_event event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6240) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6241) bfa_trc(dport->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6242)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6243) switch (event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6244) case BFA_DPORT_SM_START:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6245) if (bfa_dport_send_req(dport, BFI_DPORT_START))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6246) bfa_sm_set_state(dport, bfa_dport_sm_starting);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6247) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6248) bfa_sm_set_state(dport, bfa_dport_sm_starting_qwait);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6249) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6250)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6251) case BFA_DPORT_SM_DISABLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6252) bfa_fcport_dportdisable(dport->bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6253) if (bfa_dport_send_req(dport, BFI_DPORT_DISABLE))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6254) bfa_sm_set_state(dport, bfa_dport_sm_disabling);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6255) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6256) bfa_sm_set_state(dport, bfa_dport_sm_disabling_qwait);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6257) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6258)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6259) case BFA_DPORT_SM_HWFAIL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6260) bfa_sm_set_state(dport, bfa_dport_sm_disabled);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6261) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6262)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6263) case BFA_DPORT_SM_SCN:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6264) switch (dport->i2hmsg.scn.state) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6265) case BFI_DPORT_SCN_TESTCOMP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6266) dport->test_state = BFA_DPORT_ST_COMP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6267) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6268)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6269) case BFI_DPORT_SCN_TESTSTART:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6270) dport->test_state = BFA_DPORT_ST_INP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6271) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6272)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6273) case BFI_DPORT_SCN_TESTSKIP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6274) case BFI_DPORT_SCN_SUBTESTSTART:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6275) /* no state change */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6276) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6277)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6278) case BFI_DPORT_SCN_SFP_REMOVED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6279) dport->test_state = BFA_DPORT_ST_NO_SFP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6280) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6281)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6282) case BFI_DPORT_SCN_DDPORT_DISABLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6283) bfa_fcport_ddportdisable(dport->bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6284)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6285) if (bfa_dport_send_req(dport, BFI_DPORT_DYN_DISABLE))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6286) bfa_sm_set_state(dport,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6287) bfa_dport_sm_dynamic_disabling);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6288) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6289) bfa_sm_set_state(dport,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6290) bfa_dport_sm_dynamic_disabling_qwait);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6291) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6292)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6293) case BFI_DPORT_SCN_FCPORT_DISABLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6294) bfa_fcport_ddportdisable(dport->bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6295)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6296) bfa_sm_set_state(dport, bfa_dport_sm_disabled);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6297) dport->dynamic = BFA_FALSE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6298) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6299)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6300) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6301) bfa_trc(dport->bfa, dport->i2hmsg.scn.state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6302) bfa_sm_fault(dport->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6303) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6304) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6305) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6306) bfa_sm_fault(dport->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6307) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6308) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6309)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6310) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6311) bfa_dport_sm_disabling_qwait(struct bfa_dport_s *dport,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6312) enum bfa_dport_sm_event event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6313) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6314) bfa_trc(dport->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6315)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6316) switch (event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6317) case BFA_DPORT_SM_QRESUME:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6318) bfa_sm_set_state(dport, bfa_dport_sm_disabling);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6319) bfa_dport_send_req(dport, BFI_DPORT_DISABLE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6320) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6321)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6322) case BFA_DPORT_SM_HWFAIL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6323) bfa_sm_set_state(dport, bfa_dport_sm_disabled);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6324) bfa_reqq_wcancel(&dport->reqq_wait);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6325) bfa_cb_fcdiag_dport(dport, BFA_STATUS_OK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6326) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6327)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6328) case BFA_DPORT_SM_SCN:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6329) /* ignore */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6330) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6331)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6332) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6333) bfa_sm_fault(dport->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6334) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6335) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6336)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6337) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6338) bfa_dport_sm_disabling(struct bfa_dport_s *dport, enum bfa_dport_sm_event event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6339) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6340) bfa_trc(dport->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6341)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6342) switch (event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6343) case BFA_DPORT_SM_FWRSP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6344) dport->test_state = BFA_DPORT_ST_DISABLED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6345) bfa_sm_set_state(dport, bfa_dport_sm_disabled);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6346) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6347)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6348) case BFA_DPORT_SM_HWFAIL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6349) bfa_sm_set_state(dport, bfa_dport_sm_disabled);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6350) bfa_cb_fcdiag_dport(dport, BFA_STATUS_OK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6351) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6352)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6353) case BFA_DPORT_SM_SCN:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6354) /* no state change */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6355) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6356)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6357) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6358) bfa_sm_fault(dport->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6359) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6360) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6361)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6362) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6363) bfa_dport_sm_starting_qwait(struct bfa_dport_s *dport,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6364) enum bfa_dport_sm_event event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6365) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6366) bfa_trc(dport->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6367)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6368) switch (event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6369) case BFA_DPORT_SM_QRESUME:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6370) bfa_sm_set_state(dport, bfa_dport_sm_starting);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6371) bfa_dport_send_req(dport, BFI_DPORT_START);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6372) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6373)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6374) case BFA_DPORT_SM_HWFAIL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6375) bfa_reqq_wcancel(&dport->reqq_wait);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6376) bfa_sm_set_state(dport, bfa_dport_sm_disabled);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6377) bfa_cb_fcdiag_dport(dport, BFA_STATUS_FAILED);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6378) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6379)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6380) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6381) bfa_sm_fault(dport->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6382) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6383) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6384)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6385) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6386) bfa_dport_sm_starting(struct bfa_dport_s *dport, enum bfa_dport_sm_event event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6387) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6388) bfa_trc(dport->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6389)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6390) switch (event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6391) case BFA_DPORT_SM_FWRSP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6392) memset(&dport->result, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6393) sizeof(struct bfa_diag_dport_result_s));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6394) if (dport->i2hmsg.rsp.status == BFA_STATUS_DPORT_INV_SFP) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6395) dport->test_state = BFA_DPORT_ST_NO_SFP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6396) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6397) dport->test_state = BFA_DPORT_ST_INP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6398) bfa_dport_result_start(dport, BFA_DPORT_OPMODE_MANU);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6399) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6400) fallthrough;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6401)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6402) case BFA_DPORT_SM_REQFAIL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6403) bfa_sm_set_state(dport, bfa_dport_sm_enabled);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6404) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6405)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6406) case BFA_DPORT_SM_HWFAIL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6407) bfa_sm_set_state(dport, bfa_dport_sm_disabled);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6408) bfa_cb_fcdiag_dport(dport, BFA_STATUS_FAILED);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6409) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6410)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6411) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6412) bfa_sm_fault(dport->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6413) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6414) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6415)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6416) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6417) bfa_dport_sm_dynamic_disabling(struct bfa_dport_s *dport,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6418) enum bfa_dport_sm_event event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6419) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6420) bfa_trc(dport->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6421)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6422) switch (event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6423) case BFA_DPORT_SM_SCN:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6424) switch (dport->i2hmsg.scn.state) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6425) case BFI_DPORT_SCN_DDPORT_DISABLED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6426) bfa_sm_set_state(dport, bfa_dport_sm_disabled);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6427) dport->dynamic = BFA_FALSE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6428) bfa_fcport_enable(dport->bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6429) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6430)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6431) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6432) bfa_trc(dport->bfa, dport->i2hmsg.scn.state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6433) bfa_sm_fault(dport->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6434)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6435) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6436) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6437)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6438) case BFA_DPORT_SM_HWFAIL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6439) bfa_sm_set_state(dport, bfa_dport_sm_disabled);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6440) bfa_cb_fcdiag_dport(dport, BFA_STATUS_OK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6441) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6442)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6443) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6444) bfa_sm_fault(dport->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6445) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6446) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6447)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6448) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6449) bfa_dport_sm_dynamic_disabling_qwait(struct bfa_dport_s *dport,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6450) enum bfa_dport_sm_event event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6451) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6452) bfa_trc(dport->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6453)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6454) switch (event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6455) case BFA_DPORT_SM_QRESUME:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6456) bfa_sm_set_state(dport, bfa_dport_sm_dynamic_disabling);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6457) bfa_dport_send_req(dport, BFI_DPORT_DYN_DISABLE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6458) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6459)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6460) case BFA_DPORT_SM_HWFAIL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6461) bfa_sm_set_state(dport, bfa_dport_sm_disabled);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6462) bfa_reqq_wcancel(&dport->reqq_wait);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6463) bfa_cb_fcdiag_dport(dport, BFA_STATUS_OK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6464) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6465)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6466) case BFA_DPORT_SM_SCN:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6467) /* ignore */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6468) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6469)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6470) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6471) bfa_sm_fault(dport->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6472) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6473) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6474)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6475) static bfa_boolean_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6476) bfa_dport_send_req(struct bfa_dport_s *dport, enum bfi_dport_req req)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6477) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6478) struct bfi_diag_dport_req_s *m;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6479)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6480) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6481) * check for room in queue to send request now
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6482) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6483) m = bfa_reqq_next(dport->bfa, BFA_REQQ_DIAG);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6484) if (!m) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6485) bfa_reqq_wait(dport->bfa, BFA_REQQ_PORT, &dport->reqq_wait);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6486) return BFA_FALSE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6487) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6488)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6489) bfi_h2i_set(m->mh, BFI_MC_DIAG, BFI_DIAG_H2I_DPORT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6490) bfa_fn_lpu(dport->bfa));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6491) m->req = req;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6492) if ((req == BFI_DPORT_ENABLE) || (req == BFI_DPORT_START)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6493) m->lpcnt = cpu_to_be32(dport->lpcnt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6494) m->payload = cpu_to_be32(dport->payload);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6495) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6496)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6497) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6498) * queue I/O message to firmware
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6499) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6500) bfa_reqq_produce(dport->bfa, BFA_REQQ_DIAG, m->mh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6501)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6502) return BFA_TRUE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6503) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6504)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6505) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6506) bfa_dport_qresume(void *cbarg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6507) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6508) struct bfa_dport_s *dport = cbarg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6509)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6510) bfa_sm_send_event(dport, BFA_DPORT_SM_QRESUME);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6511) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6512)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6513) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6514) bfa_dport_req_comp(struct bfa_dport_s *dport, struct bfi_diag_dport_rsp_s *msg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6515) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6516) msg->status = cpu_to_be32(msg->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6517) dport->i2hmsg.rsp.status = msg->status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6518) dport->rp_pwwn = msg->pwwn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6519) dport->rp_nwwn = msg->nwwn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6520)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6521) if ((msg->status == BFA_STATUS_OK) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6522) (msg->status == BFA_STATUS_DPORT_NO_SFP)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6523) bfa_trc(dport->bfa, msg->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6524) bfa_trc(dport->bfa, dport->rp_pwwn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6525) bfa_trc(dport->bfa, dport->rp_nwwn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6526) bfa_sm_send_event(dport, BFA_DPORT_SM_FWRSP);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6527)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6528) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6529) bfa_trc(dport->bfa, msg->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6530) bfa_sm_send_event(dport, BFA_DPORT_SM_REQFAIL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6531) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6532) bfa_cb_fcdiag_dport(dport, msg->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6533) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6534)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6535) static bfa_boolean_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6536) bfa_dport_is_sending_req(struct bfa_dport_s *dport)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6537) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6538) if (bfa_sm_cmp_state(dport, bfa_dport_sm_enabling) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6539) bfa_sm_cmp_state(dport, bfa_dport_sm_enabling_qwait) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6540) bfa_sm_cmp_state(dport, bfa_dport_sm_disabling) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6541) bfa_sm_cmp_state(dport, bfa_dport_sm_disabling_qwait) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6542) bfa_sm_cmp_state(dport, bfa_dport_sm_starting) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6543) bfa_sm_cmp_state(dport, bfa_dport_sm_starting_qwait)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6544) return BFA_TRUE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6545) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6546) return BFA_FALSE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6547) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6548) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6549)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6550) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6551) bfa_dport_scn(struct bfa_dport_s *dport, struct bfi_diag_dport_scn_s *msg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6552) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6553) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6554) uint8_t subtesttype;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6555)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6556) bfa_trc(dport->bfa, msg->state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6557) dport->i2hmsg.scn.state = msg->state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6558)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6559) switch (dport->i2hmsg.scn.state) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6560) case BFI_DPORT_SCN_TESTCOMP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6561) dport->result.end_time = ktime_get_real_seconds();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6562) bfa_trc(dport->bfa, dport->result.end_time);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6563)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6564) dport->result.status = msg->info.testcomp.status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6565) bfa_trc(dport->bfa, dport->result.status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6566)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6567) dport->result.roundtrip_latency =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6568) cpu_to_be32(msg->info.testcomp.latency);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6569) dport->result.est_cable_distance =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6570) cpu_to_be32(msg->info.testcomp.distance);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6571) dport->result.buffer_required =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6572) be16_to_cpu(msg->info.testcomp.numbuffer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6573)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6574) dport->result.frmsz = be16_to_cpu(msg->info.testcomp.frm_sz);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6575) dport->result.speed = msg->info.testcomp.speed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6576)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6577) bfa_trc(dport->bfa, dport->result.roundtrip_latency);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6578) bfa_trc(dport->bfa, dport->result.est_cable_distance);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6579) bfa_trc(dport->bfa, dport->result.buffer_required);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6580) bfa_trc(dport->bfa, dport->result.frmsz);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6581) bfa_trc(dport->bfa, dport->result.speed);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6582)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6583) for (i = DPORT_TEST_ELOOP; i < DPORT_TEST_MAX; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6584) dport->result.subtest[i].status =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6585) msg->info.testcomp.subtest_status[i];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6586) bfa_trc(dport->bfa, dport->result.subtest[i].status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6587) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6588) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6589)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6590) case BFI_DPORT_SCN_TESTSKIP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6591) case BFI_DPORT_SCN_DDPORT_ENABLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6592) memset(&dport->result, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6593) sizeof(struct bfa_diag_dport_result_s));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6594) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6595)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6596) case BFI_DPORT_SCN_TESTSTART:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6597) memset(&dport->result, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6598) sizeof(struct bfa_diag_dport_result_s));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6599) dport->rp_pwwn = msg->info.teststart.pwwn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6600) dport->rp_nwwn = msg->info.teststart.nwwn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6601) dport->lpcnt = cpu_to_be32(msg->info.teststart.numfrm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6602) bfa_dport_result_start(dport, msg->info.teststart.mode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6603) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6604)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6605) case BFI_DPORT_SCN_SUBTESTSTART:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6606) subtesttype = msg->info.teststart.type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6607) dport->result.subtest[subtesttype].start_time =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6608) ktime_get_real_seconds();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6609) dport->result.subtest[subtesttype].status =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6610) DPORT_TEST_ST_INPRG;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6611)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6612) bfa_trc(dport->bfa, subtesttype);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6613) bfa_trc(dport->bfa,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6614) dport->result.subtest[subtesttype].start_time);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6615) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6616)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6617) case BFI_DPORT_SCN_SFP_REMOVED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6618) case BFI_DPORT_SCN_DDPORT_DISABLED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6619) case BFI_DPORT_SCN_DDPORT_DISABLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6620) case BFI_DPORT_SCN_FCPORT_DISABLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6621) dport->result.status = DPORT_TEST_ST_IDLE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6622) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6623)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6624) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6625) bfa_sm_fault(dport->bfa, msg->state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6626) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6627)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6628) bfa_sm_send_event(dport, BFA_DPORT_SM_SCN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6629) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6630)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6631) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6632) * Dport enable
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6633) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6634) * @param[in] *bfa - bfa data struct
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6635) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6636) bfa_status_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6637) bfa_dport_enable(struct bfa_s *bfa, u32 lpcnt, u32 pat,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6638) bfa_cb_diag_t cbfn, void *cbarg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6639) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6640) struct bfa_fcdiag_s *fcdiag = BFA_FCDIAG_MOD(bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6641) struct bfa_dport_s *dport = &fcdiag->dport;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6642)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6643) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6644) * Dport is not support in MEZZ card
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6645) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6646) if (bfa_mfg_is_mezz(dport->bfa->ioc.attr->card_type)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6647) bfa_trc(dport->bfa, BFA_STATUS_PBC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6648) return BFA_STATUS_CMD_NOTSUPP_MEZZ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6649) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6650)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6651) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6652) * Dport is supported in CT2 or above
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6653) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6654) if (!(bfa_asic_id_ct2(dport->bfa->ioc.pcidev.device_id))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6655) bfa_trc(dport->bfa, dport->bfa->ioc.pcidev.device_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6656) return BFA_STATUS_FEATURE_NOT_SUPPORTED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6657) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6658)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6659) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6660) * Check to see if IOC is down
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6661) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6662) if (!bfa_iocfc_is_operational(bfa))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6663) return BFA_STATUS_IOC_NON_OP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6664)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6665) /* if port is PBC disabled, return error */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6666) if (bfa_fcport_is_pbcdisabled(bfa)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6667) bfa_trc(dport->bfa, BFA_STATUS_PBC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6668) return BFA_STATUS_PBC;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6669) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6670)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6671) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6672) * Check if port mode is FC port
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6673) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6674) if (bfa_ioc_get_type(&bfa->ioc) != BFA_IOC_TYPE_FC) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6675) bfa_trc(dport->bfa, bfa_ioc_get_type(&bfa->ioc));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6676) return BFA_STATUS_CMD_NOTSUPP_CNA;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6677) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6678)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6679) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6680) * Check if port is in LOOP mode
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6681) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6682) if ((bfa_fcport_get_cfg_topology(bfa) == BFA_PORT_TOPOLOGY_LOOP) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6683) (bfa_fcport_get_topology(bfa) == BFA_PORT_TOPOLOGY_LOOP)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6684) bfa_trc(dport->bfa, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6685) return BFA_STATUS_TOPOLOGY_LOOP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6686) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6687)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6688) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6689) * Check if port is TRUNK mode
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6690) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6691) if (bfa_fcport_is_trunk_enabled(bfa)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6692) bfa_trc(dport->bfa, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6693) return BFA_STATUS_ERROR_TRUNK_ENABLED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6694) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6695)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6696) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6697) * Check if diag loopback is running
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6698) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6699) if (bfa_fcdiag_lb_is_running(bfa)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6700) bfa_trc(dport->bfa, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6701) return BFA_STATUS_DIAG_BUSY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6702) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6703)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6704) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6705) * Check to see if port is disable or in dport state
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6706) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6707) if ((bfa_fcport_is_disabled(bfa) == BFA_FALSE) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6708) (bfa_fcport_is_dport(bfa) == BFA_FALSE)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6709) bfa_trc(dport->bfa, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6710) return BFA_STATUS_PORT_NOT_DISABLED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6711) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6712)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6713) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6714) * Check if dport is in dynamic mode
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6715) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6716) if (dport->dynamic)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6717) return BFA_STATUS_DDPORT_ERR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6718)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6719) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6720) * Check if dport is busy
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6721) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6722) if (bfa_dport_is_sending_req(dport))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6723) return BFA_STATUS_DEVBUSY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6724)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6725) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6726) * Check if dport is already enabled
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6727) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6728) if (bfa_sm_cmp_state(dport, bfa_dport_sm_enabled)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6729) bfa_trc(dport->bfa, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6730) return BFA_STATUS_DPORT_ENABLED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6731) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6732)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6733) bfa_trc(dport->bfa, lpcnt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6734) bfa_trc(dport->bfa, pat);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6735) dport->lpcnt = (lpcnt) ? lpcnt : DPORT_ENABLE_LOOPCNT_DEFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6736) dport->payload = (pat) ? pat : LB_PATTERN_DEFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6737) dport->cbfn = cbfn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6738) dport->cbarg = cbarg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6739)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6740) bfa_sm_send_event(dport, BFA_DPORT_SM_ENABLE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6741) return BFA_STATUS_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6742) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6743)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6744) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6745) * Dport disable
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6746) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6747) * @param[in] *bfa - bfa data struct
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6748) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6749) bfa_status_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6750) bfa_dport_disable(struct bfa_s *bfa, bfa_cb_diag_t cbfn, void *cbarg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6751) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6752) struct bfa_fcdiag_s *fcdiag = BFA_FCDIAG_MOD(bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6753) struct bfa_dport_s *dport = &fcdiag->dport;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6754)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6755) if (bfa_ioc_is_disabled(&bfa->ioc))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6756) return BFA_STATUS_IOC_DISABLED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6757)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6758) /* if port is PBC disabled, return error */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6759) if (bfa_fcport_is_pbcdisabled(bfa)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6760) bfa_trc(dport->bfa, BFA_STATUS_PBC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6761) return BFA_STATUS_PBC;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6762) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6763)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6764) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6765) * Check if dport is in dynamic mode
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6766) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6767) if (dport->dynamic) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6768) return BFA_STATUS_DDPORT_ERR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6769) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6770)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6771) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6772) * Check to see if port is disable or in dport state
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6773) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6774) if ((bfa_fcport_is_disabled(bfa) == BFA_FALSE) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6775) (bfa_fcport_is_dport(bfa) == BFA_FALSE)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6776) bfa_trc(dport->bfa, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6777) return BFA_STATUS_PORT_NOT_DISABLED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6778) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6779)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6780) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6781) * Check if dport is busy
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6782) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6783) if (bfa_dport_is_sending_req(dport))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6784) return BFA_STATUS_DEVBUSY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6785)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6786) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6787) * Check if dport is already disabled
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6788) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6789) if (bfa_sm_cmp_state(dport, bfa_dport_sm_disabled)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6790) bfa_trc(dport->bfa, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6791) return BFA_STATUS_DPORT_DISABLED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6792) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6793)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6794) dport->cbfn = cbfn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6795) dport->cbarg = cbarg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6796)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6797) bfa_sm_send_event(dport, BFA_DPORT_SM_DISABLE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6798) return BFA_STATUS_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6799) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6800)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6801) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6802) * Dport start -- restart dport test
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6803) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6804) * @param[in] *bfa - bfa data struct
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6805) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6806) bfa_status_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6807) bfa_dport_start(struct bfa_s *bfa, u32 lpcnt, u32 pat,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6808) bfa_cb_diag_t cbfn, void *cbarg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6809) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6810) struct bfa_fcdiag_s *fcdiag = BFA_FCDIAG_MOD(bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6811) struct bfa_dport_s *dport = &fcdiag->dport;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6812)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6813) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6814) * Check to see if IOC is down
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6815) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6816) if (!bfa_iocfc_is_operational(bfa))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6817) return BFA_STATUS_IOC_NON_OP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6818)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6819) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6820) * Check if dport is in dynamic mode
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6821) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6822) if (dport->dynamic)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6823) return BFA_STATUS_DDPORT_ERR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6824)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6825) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6826) * Check if dport is busy
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6827) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6828) if (bfa_dport_is_sending_req(dport))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6829) return BFA_STATUS_DEVBUSY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6830)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6831) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6832) * Check if dport is in enabled state.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6833) * Test can only be restart when previous test has completed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6834) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6835) if (!bfa_sm_cmp_state(dport, bfa_dport_sm_enabled)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6836) bfa_trc(dport->bfa, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6837) return BFA_STATUS_DPORT_DISABLED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6838)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6839) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6840) if (dport->test_state == BFA_DPORT_ST_NO_SFP)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6841) return BFA_STATUS_DPORT_INV_SFP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6842)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6843) if (dport->test_state == BFA_DPORT_ST_INP)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6844) return BFA_STATUS_DEVBUSY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6845)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6846) WARN_ON(dport->test_state != BFA_DPORT_ST_COMP);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6847) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6848)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6849) bfa_trc(dport->bfa, lpcnt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6850) bfa_trc(dport->bfa, pat);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6851)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6852) dport->lpcnt = (lpcnt) ? lpcnt : DPORT_ENABLE_LOOPCNT_DEFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6853) dport->payload = (pat) ? pat : LB_PATTERN_DEFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6854)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6855) dport->cbfn = cbfn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6856) dport->cbarg = cbarg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6857)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6858) bfa_sm_send_event(dport, BFA_DPORT_SM_START);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6859) return BFA_STATUS_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6860) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6861)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6862) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6863) * Dport show -- return dport test result
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6864) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6865) * @param[in] *bfa - bfa data struct
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6866) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6867) bfa_status_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6868) bfa_dport_show(struct bfa_s *bfa, struct bfa_diag_dport_result_s *result)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6869) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6870) struct bfa_fcdiag_s *fcdiag = BFA_FCDIAG_MOD(bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6871) struct bfa_dport_s *dport = &fcdiag->dport;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6872)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6873) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6874) * Check to see if IOC is down
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6875) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6876) if (!bfa_iocfc_is_operational(bfa))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6877) return BFA_STATUS_IOC_NON_OP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6878)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6879) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6880) * Check if dport is busy
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6881) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6882) if (bfa_dport_is_sending_req(dport))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6883) return BFA_STATUS_DEVBUSY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6884)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6885) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6886) * Check if dport is in enabled state.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6887) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6888) if (!bfa_sm_cmp_state(dport, bfa_dport_sm_enabled)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6889) bfa_trc(dport->bfa, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6890) return BFA_STATUS_DPORT_DISABLED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6891)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6892) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6893)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6894) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6895) * Check if there is SFP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6896) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6897) if (dport->test_state == BFA_DPORT_ST_NO_SFP)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6898) return BFA_STATUS_DPORT_INV_SFP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6899)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6900) memcpy(result, &dport->result, sizeof(struct bfa_diag_dport_result_s));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6901)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6902) return BFA_STATUS_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6903) }