^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_ioc.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include "bfi_reg.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include "bfa_defs.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #include "bfa_defs_svc.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #include "bfi.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) BFA_TRC_FILE(CNA, IOC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) * IOC local definitions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) #define BFA_IOC_TOV 3000 /* msecs */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) #define BFA_IOC_HWSEM_TOV 500 /* msecs */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) #define BFA_IOC_HB_TOV 500 /* msecs */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) #define BFA_IOC_TOV_RECOVER BFA_IOC_HB_TOV
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) #define BFA_IOC_POLL_TOV BFA_TIMER_FREQ
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) #define bfa_ioc_timer_start(__ioc) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) bfa_timer_begin((__ioc)->timer_mod, &(__ioc)->ioc_timer, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) bfa_ioc_timeout, (__ioc), BFA_IOC_TOV)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) #define bfa_ioc_timer_stop(__ioc) bfa_timer_stop(&(__ioc)->ioc_timer)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) #define bfa_hb_timer_start(__ioc) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) bfa_timer_begin((__ioc)->timer_mod, &(__ioc)->hb_timer, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) bfa_ioc_hb_check, (__ioc), BFA_IOC_HB_TOV)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) #define bfa_hb_timer_stop(__ioc) bfa_timer_stop(&(__ioc)->hb_timer)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) #define BFA_DBG_FWTRC_OFF(_fn) (BFI_IOC_TRC_OFF + BFA_DBG_FWTRC_LEN * (_fn))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) #define bfa_ioc_state_disabled(__sm) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) (((__sm) == BFI_IOC_UNINIT) || \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) ((__sm) == BFI_IOC_INITING) || \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) ((__sm) == BFI_IOC_HWINIT) || \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) ((__sm) == BFI_IOC_DISABLED) || \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) ((__sm) == BFI_IOC_FAIL) || \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) ((__sm) == BFI_IOC_CFG_DISABLED))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) * Asic specific macros : see bfa_hw_cb.c and bfa_hw_ct.c for details.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) #define bfa_ioc_firmware_lock(__ioc) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) ((__ioc)->ioc_hwif->ioc_firmware_lock(__ioc))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) #define bfa_ioc_firmware_unlock(__ioc) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) ((__ioc)->ioc_hwif->ioc_firmware_unlock(__ioc))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) #define bfa_ioc_reg_init(__ioc) ((__ioc)->ioc_hwif->ioc_reg_init(__ioc))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) #define bfa_ioc_map_port(__ioc) ((__ioc)->ioc_hwif->ioc_map_port(__ioc))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) #define bfa_ioc_notify_fail(__ioc) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) ((__ioc)->ioc_hwif->ioc_notify_fail(__ioc))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) #define bfa_ioc_sync_start(__ioc) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) ((__ioc)->ioc_hwif->ioc_sync_start(__ioc))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) #define bfa_ioc_sync_join(__ioc) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) ((__ioc)->ioc_hwif->ioc_sync_join(__ioc))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) #define bfa_ioc_sync_leave(__ioc) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) ((__ioc)->ioc_hwif->ioc_sync_leave(__ioc))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) #define bfa_ioc_sync_ack(__ioc) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) ((__ioc)->ioc_hwif->ioc_sync_ack(__ioc))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) #define bfa_ioc_sync_complete(__ioc) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) ((__ioc)->ioc_hwif->ioc_sync_complete(__ioc))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) #define bfa_ioc_set_cur_ioc_fwstate(__ioc, __fwstate) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) ((__ioc)->ioc_hwif->ioc_set_fwstate(__ioc, __fwstate))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) #define bfa_ioc_get_cur_ioc_fwstate(__ioc) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) ((__ioc)->ioc_hwif->ioc_get_fwstate(__ioc))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) #define bfa_ioc_set_alt_ioc_fwstate(__ioc, __fwstate) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) ((__ioc)->ioc_hwif->ioc_set_alt_fwstate(__ioc, __fwstate))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) #define bfa_ioc_get_alt_ioc_fwstate(__ioc) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) ((__ioc)->ioc_hwif->ioc_get_alt_fwstate(__ioc))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) #define bfa_ioc_mbox_cmd_pending(__ioc) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) (!list_empty(&((__ioc)->mbox_mod.cmd_q)) || \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) readl((__ioc)->ioc_regs.hfn_mbox_cmd))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) bfa_boolean_t bfa_auto_recover = BFA_TRUE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) * forward declarations
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) static void bfa_ioc_hw_sem_get(struct bfa_ioc_s *ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) static void bfa_ioc_hwinit(struct bfa_ioc_s *ioc, bfa_boolean_t force);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) static void bfa_ioc_timeout(void *ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) static void bfa_ioc_poll_fwinit(struct bfa_ioc_s *ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) static void bfa_ioc_send_enable(struct bfa_ioc_s *ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) static void bfa_ioc_send_disable(struct bfa_ioc_s *ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) static void bfa_ioc_send_getattr(struct bfa_ioc_s *ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) static void bfa_ioc_hb_monitor(struct bfa_ioc_s *ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) static void bfa_ioc_mbox_poll(struct bfa_ioc_s *ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) static void bfa_ioc_mbox_flush(struct bfa_ioc_s *ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) static void bfa_ioc_recover(struct bfa_ioc_s *ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) static void bfa_ioc_event_notify(struct bfa_ioc_s *ioc ,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) enum bfa_ioc_event_e event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) static void bfa_ioc_disable_comp(struct bfa_ioc_s *ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) static void bfa_ioc_lpu_stop(struct bfa_ioc_s *ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) static void bfa_ioc_fail_notify(struct bfa_ioc_s *ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) static void bfa_ioc_pf_fwmismatch(struct bfa_ioc_s *ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) static enum bfi_ioc_img_ver_cmp_e bfa_ioc_fw_ver_patch_cmp(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) struct bfi_ioc_image_hdr_s *base_fwhdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) struct bfi_ioc_image_hdr_s *fwhdr_to_cmp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) static enum bfi_ioc_img_ver_cmp_e bfa_ioc_flash_fwver_cmp(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) struct bfa_ioc_s *ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) struct bfi_ioc_image_hdr_s *base_fwhdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) * IOC state machine definitions/declarations
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) enum ioc_event {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) IOC_E_RESET = 1, /* IOC reset request */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) IOC_E_ENABLE = 2, /* IOC enable request */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) IOC_E_DISABLE = 3, /* IOC disable request */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) IOC_E_DETACH = 4, /* driver detach cleanup */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) IOC_E_ENABLED = 5, /* f/w enabled */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) IOC_E_FWRSP_GETATTR = 6, /* IOC get attribute response */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) IOC_E_DISABLED = 7, /* f/w disabled */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) IOC_E_PFFAILED = 8, /* failure notice by iocpf sm */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) IOC_E_HBFAIL = 9, /* heartbeat failure */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) IOC_E_HWERROR = 10, /* hardware error interrupt */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) IOC_E_TIMEOUT = 11, /* timeout */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) IOC_E_HWFAILED = 12, /* PCI mapping failure notice */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) bfa_fsm_state_decl(bfa_ioc, uninit, struct bfa_ioc_s, enum ioc_event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) bfa_fsm_state_decl(bfa_ioc, reset, struct bfa_ioc_s, enum ioc_event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) bfa_fsm_state_decl(bfa_ioc, enabling, struct bfa_ioc_s, enum ioc_event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) bfa_fsm_state_decl(bfa_ioc, getattr, struct bfa_ioc_s, enum ioc_event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) bfa_fsm_state_decl(bfa_ioc, op, struct bfa_ioc_s, enum ioc_event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) bfa_fsm_state_decl(bfa_ioc, fail_retry, struct bfa_ioc_s, enum ioc_event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) bfa_fsm_state_decl(bfa_ioc, fail, struct bfa_ioc_s, enum ioc_event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) bfa_fsm_state_decl(bfa_ioc, disabling, struct bfa_ioc_s, enum ioc_event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) bfa_fsm_state_decl(bfa_ioc, disabled, struct bfa_ioc_s, enum ioc_event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) bfa_fsm_state_decl(bfa_ioc, hwfail, struct bfa_ioc_s, enum ioc_event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) static struct bfa_sm_table_s ioc_sm_table[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) {BFA_SM(bfa_ioc_sm_uninit), BFA_IOC_UNINIT},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) {BFA_SM(bfa_ioc_sm_reset), BFA_IOC_RESET},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) {BFA_SM(bfa_ioc_sm_enabling), BFA_IOC_ENABLING},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) {BFA_SM(bfa_ioc_sm_getattr), BFA_IOC_GETATTR},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) {BFA_SM(bfa_ioc_sm_op), BFA_IOC_OPERATIONAL},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) {BFA_SM(bfa_ioc_sm_fail_retry), BFA_IOC_INITFAIL},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) {BFA_SM(bfa_ioc_sm_fail), BFA_IOC_FAIL},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) {BFA_SM(bfa_ioc_sm_disabling), BFA_IOC_DISABLING},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) {BFA_SM(bfa_ioc_sm_disabled), BFA_IOC_DISABLED},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) {BFA_SM(bfa_ioc_sm_hwfail), BFA_IOC_HWFAIL},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) * IOCPF state machine definitions/declarations
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) #define bfa_iocpf_timer_start(__ioc) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) bfa_timer_begin((__ioc)->timer_mod, &(__ioc)->ioc_timer, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) bfa_iocpf_timeout, (__ioc), BFA_IOC_TOV)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) #define bfa_iocpf_timer_stop(__ioc) bfa_timer_stop(&(__ioc)->ioc_timer)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) #define bfa_iocpf_poll_timer_start(__ioc) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) bfa_timer_begin((__ioc)->timer_mod, &(__ioc)->ioc_timer, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) bfa_iocpf_poll_timeout, (__ioc), BFA_IOC_POLL_TOV)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) #define bfa_sem_timer_start(__ioc) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) bfa_timer_begin((__ioc)->timer_mod, &(__ioc)->sem_timer, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) bfa_iocpf_sem_timeout, (__ioc), BFA_IOC_HWSEM_TOV)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) #define bfa_sem_timer_stop(__ioc) bfa_timer_stop(&(__ioc)->sem_timer)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) * Forward declareations for iocpf state machine
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) static void bfa_iocpf_timeout(void *ioc_arg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) static void bfa_iocpf_sem_timeout(void *ioc_arg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) static void bfa_iocpf_poll_timeout(void *ioc_arg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) * IOCPF state machine events
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) enum iocpf_event {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) IOCPF_E_ENABLE = 1, /* IOCPF enable request */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) IOCPF_E_DISABLE = 2, /* IOCPF disable request */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) IOCPF_E_STOP = 3, /* stop on driver detach */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) IOCPF_E_FWREADY = 4, /* f/w initialization done */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) IOCPF_E_FWRSP_ENABLE = 5, /* enable f/w response */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) IOCPF_E_FWRSP_DISABLE = 6, /* disable f/w response */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) IOCPF_E_FAIL = 7, /* failure notice by ioc sm */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) IOCPF_E_INITFAIL = 8, /* init fail notice by ioc sm */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) IOCPF_E_GETATTRFAIL = 9, /* init fail notice by ioc sm */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) IOCPF_E_SEMLOCKED = 10, /* h/w semaphore is locked */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) IOCPF_E_TIMEOUT = 11, /* f/w response timeout */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) IOCPF_E_SEM_ERROR = 12, /* h/w sem mapping error */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) * IOCPF states
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) enum bfa_iocpf_state {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) BFA_IOCPF_RESET = 1, /* IOC is in reset state */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) BFA_IOCPF_SEMWAIT = 2, /* Waiting for IOC h/w semaphore */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) BFA_IOCPF_HWINIT = 3, /* IOC h/w is being initialized */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) BFA_IOCPF_READY = 4, /* IOCPF is initialized */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) BFA_IOCPF_INITFAIL = 5, /* IOCPF failed */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) BFA_IOCPF_FAIL = 6, /* IOCPF failed */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) BFA_IOCPF_DISABLING = 7, /* IOCPF is being disabled */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) BFA_IOCPF_DISABLED = 8, /* IOCPF is disabled */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) BFA_IOCPF_FWMISMATCH = 9, /* IOC f/w different from drivers */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) bfa_fsm_state_decl(bfa_iocpf, reset, struct bfa_iocpf_s, enum iocpf_event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) bfa_fsm_state_decl(bfa_iocpf, fwcheck, struct bfa_iocpf_s, enum iocpf_event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) bfa_fsm_state_decl(bfa_iocpf, mismatch, struct bfa_iocpf_s, enum iocpf_event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) bfa_fsm_state_decl(bfa_iocpf, semwait, struct bfa_iocpf_s, enum iocpf_event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) bfa_fsm_state_decl(bfa_iocpf, hwinit, struct bfa_iocpf_s, enum iocpf_event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) bfa_fsm_state_decl(bfa_iocpf, enabling, struct bfa_iocpf_s, enum iocpf_event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) bfa_fsm_state_decl(bfa_iocpf, ready, struct bfa_iocpf_s, enum iocpf_event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) bfa_fsm_state_decl(bfa_iocpf, initfail_sync, struct bfa_iocpf_s,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) enum iocpf_event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) bfa_fsm_state_decl(bfa_iocpf, initfail, struct bfa_iocpf_s, enum iocpf_event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) bfa_fsm_state_decl(bfa_iocpf, fail_sync, struct bfa_iocpf_s, enum iocpf_event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) bfa_fsm_state_decl(bfa_iocpf, fail, struct bfa_iocpf_s, enum iocpf_event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) bfa_fsm_state_decl(bfa_iocpf, disabling, struct bfa_iocpf_s, enum iocpf_event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) bfa_fsm_state_decl(bfa_iocpf, disabling_sync, struct bfa_iocpf_s,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) enum iocpf_event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) bfa_fsm_state_decl(bfa_iocpf, disabled, struct bfa_iocpf_s, enum iocpf_event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) static struct bfa_sm_table_s iocpf_sm_table[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) {BFA_SM(bfa_iocpf_sm_reset), BFA_IOCPF_RESET},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) {BFA_SM(bfa_iocpf_sm_fwcheck), BFA_IOCPF_FWMISMATCH},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) {BFA_SM(bfa_iocpf_sm_mismatch), BFA_IOCPF_FWMISMATCH},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) {BFA_SM(bfa_iocpf_sm_semwait), BFA_IOCPF_SEMWAIT},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) {BFA_SM(bfa_iocpf_sm_hwinit), BFA_IOCPF_HWINIT},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) {BFA_SM(bfa_iocpf_sm_enabling), BFA_IOCPF_HWINIT},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) {BFA_SM(bfa_iocpf_sm_ready), BFA_IOCPF_READY},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) {BFA_SM(bfa_iocpf_sm_initfail_sync), BFA_IOCPF_INITFAIL},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) {BFA_SM(bfa_iocpf_sm_initfail), BFA_IOCPF_INITFAIL},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) {BFA_SM(bfa_iocpf_sm_fail_sync), BFA_IOCPF_FAIL},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) {BFA_SM(bfa_iocpf_sm_fail), BFA_IOCPF_FAIL},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) {BFA_SM(bfa_iocpf_sm_disabling), BFA_IOCPF_DISABLING},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) {BFA_SM(bfa_iocpf_sm_disabling_sync), BFA_IOCPF_DISABLING},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) {BFA_SM(bfa_iocpf_sm_disabled), BFA_IOCPF_DISABLED},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) * IOC State Machine
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) * Beginning state. IOC uninit state.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) bfa_ioc_sm_uninit_entry(struct bfa_ioc_s *ioc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) * IOC is in uninit state.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) bfa_ioc_sm_uninit(struct bfa_ioc_s *ioc, enum ioc_event event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) bfa_trc(ioc, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) switch (event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) case IOC_E_RESET:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) bfa_fsm_set_state(ioc, bfa_ioc_sm_reset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) bfa_sm_fault(ioc, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) * Reset entry actions -- initialize state machine
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) bfa_ioc_sm_reset_entry(struct bfa_ioc_s *ioc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) bfa_fsm_set_state(&ioc->iocpf, bfa_iocpf_sm_reset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) * IOC is in reset state.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) bfa_ioc_sm_reset(struct bfa_ioc_s *ioc, enum ioc_event event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) bfa_trc(ioc, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) switch (event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) case IOC_E_ENABLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) bfa_fsm_set_state(ioc, bfa_ioc_sm_enabling);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) case IOC_E_DISABLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) bfa_ioc_disable_comp(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) case IOC_E_DETACH:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) bfa_fsm_set_state(ioc, bfa_ioc_sm_uninit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) bfa_sm_fault(ioc, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) bfa_ioc_sm_enabling_entry(struct bfa_ioc_s *ioc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) bfa_fsm_send_event(&ioc->iocpf, IOCPF_E_ENABLE);
^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) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) * Host IOC function is being enabled, awaiting response from firmware.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) * Semaphore is acquired.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) bfa_ioc_sm_enabling(struct bfa_ioc_s *ioc, enum ioc_event event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) bfa_trc(ioc, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) switch (event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) case IOC_E_ENABLED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) bfa_fsm_set_state(ioc, bfa_ioc_sm_getattr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) case IOC_E_PFFAILED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) /* !!! fall through !!! */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) case IOC_E_HWERROR:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) ioc->cbfn->enable_cbfn(ioc->bfa, BFA_STATUS_IOC_FAILURE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) bfa_fsm_set_state(ioc, bfa_ioc_sm_fail);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) if (event != IOC_E_PFFAILED)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) bfa_fsm_send_event(&ioc->iocpf, IOCPF_E_INITFAIL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) case IOC_E_HWFAILED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) ioc->cbfn->enable_cbfn(ioc->bfa, BFA_STATUS_IOC_FAILURE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) bfa_fsm_set_state(ioc, bfa_ioc_sm_hwfail);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) case IOC_E_DISABLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) bfa_fsm_set_state(ioc, bfa_ioc_sm_disabling);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) case IOC_E_DETACH:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) bfa_fsm_set_state(ioc, bfa_ioc_sm_uninit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) bfa_fsm_send_event(&ioc->iocpf, IOCPF_E_STOP);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) case IOC_E_ENABLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) bfa_sm_fault(ioc, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) }
^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) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) bfa_ioc_sm_getattr_entry(struct bfa_ioc_s *ioc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) bfa_ioc_timer_start(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) bfa_ioc_send_getattr(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) * IOC configuration in progress. Timer is active.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) bfa_ioc_sm_getattr(struct bfa_ioc_s *ioc, enum ioc_event event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) bfa_trc(ioc, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) switch (event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) case IOC_E_FWRSP_GETATTR:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) bfa_ioc_timer_stop(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) bfa_fsm_set_state(ioc, bfa_ioc_sm_op);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) case IOC_E_PFFAILED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) case IOC_E_HWERROR:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) bfa_ioc_timer_stop(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) /* !!! fall through !!! */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) case IOC_E_TIMEOUT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) ioc->cbfn->enable_cbfn(ioc->bfa, BFA_STATUS_IOC_FAILURE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) bfa_fsm_set_state(ioc, bfa_ioc_sm_fail);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) if (event != IOC_E_PFFAILED)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) bfa_fsm_send_event(&ioc->iocpf, IOCPF_E_GETATTRFAIL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) case IOC_E_DISABLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) bfa_ioc_timer_stop(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) bfa_fsm_set_state(ioc, bfa_ioc_sm_disabling);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) case IOC_E_ENABLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) bfa_sm_fault(ioc, event);
^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)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) bfa_ioc_sm_op_entry(struct bfa_ioc_s *ioc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) struct bfad_s *bfad = (struct bfad_s *)ioc->bfa->bfad;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) ioc->cbfn->enable_cbfn(ioc->bfa, BFA_STATUS_OK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) bfa_ioc_event_notify(ioc, BFA_IOC_E_ENABLED);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) bfa_ioc_hb_monitor(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) BFA_LOG(KERN_INFO, bfad, bfa_log_level, "IOC enabled\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) bfa_ioc_aen_post(ioc, BFA_IOC_AEN_ENABLE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) bfa_ioc_sm_op(struct bfa_ioc_s *ioc, enum ioc_event event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) bfa_trc(ioc, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) switch (event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) case IOC_E_ENABLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) case IOC_E_DISABLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) bfa_hb_timer_stop(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) bfa_fsm_set_state(ioc, bfa_ioc_sm_disabling);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) case IOC_E_PFFAILED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) case IOC_E_HWERROR:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) bfa_hb_timer_stop(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) /* !!! fall through !!! */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) case IOC_E_HBFAIL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) if (ioc->iocpf.auto_recover)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) bfa_fsm_set_state(ioc, bfa_ioc_sm_fail_retry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) bfa_fsm_set_state(ioc, bfa_ioc_sm_fail);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) bfa_ioc_fail_notify(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) if (event != IOC_E_PFFAILED)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) bfa_fsm_send_event(&ioc->iocpf, IOCPF_E_FAIL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) bfa_sm_fault(ioc, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) bfa_ioc_sm_disabling_entry(struct bfa_ioc_s *ioc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) struct bfad_s *bfad = (struct bfad_s *)ioc->bfa->bfad;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) bfa_fsm_send_event(&ioc->iocpf, IOCPF_E_DISABLE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) BFA_LOG(KERN_INFO, bfad, bfa_log_level, "IOC disabled\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) bfa_ioc_aen_post(ioc, BFA_IOC_AEN_DISABLE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) * IOC is being disabled
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) bfa_ioc_sm_disabling(struct bfa_ioc_s *ioc, enum ioc_event event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) bfa_trc(ioc, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) switch (event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) case IOC_E_DISABLED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) bfa_fsm_set_state(ioc, bfa_ioc_sm_disabled);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) case IOC_E_HWERROR:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) * No state change. Will move to disabled state
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) * after iocpf sm completes failure processing and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485) * moves to disabled state.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) bfa_fsm_send_event(&ioc->iocpf, IOCPF_E_FAIL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) case IOC_E_HWFAILED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) bfa_fsm_set_state(ioc, bfa_ioc_sm_hwfail);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) bfa_ioc_disable_comp(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) bfa_sm_fault(ioc, event);
^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)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) * IOC disable completion entry.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504) bfa_ioc_sm_disabled_entry(struct bfa_ioc_s *ioc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506) bfa_ioc_disable_comp(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510) bfa_ioc_sm_disabled(struct bfa_ioc_s *ioc, enum ioc_event event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512) bfa_trc(ioc, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514) switch (event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515) case IOC_E_ENABLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516) bfa_fsm_set_state(ioc, bfa_ioc_sm_enabling);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519) case IOC_E_DISABLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520) ioc->cbfn->disable_cbfn(ioc->bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523) case IOC_E_DETACH:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524) bfa_fsm_set_state(ioc, bfa_ioc_sm_uninit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525) bfa_fsm_send_event(&ioc->iocpf, IOCPF_E_STOP);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529) bfa_sm_fault(ioc, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 531) }
^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) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 535) bfa_ioc_sm_fail_retry_entry(struct bfa_ioc_s *ioc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 536) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 537) bfa_trc(ioc, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 538) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 539)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 540) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 541) * Hardware initialization retry.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 542) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 543) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 544) bfa_ioc_sm_fail_retry(struct bfa_ioc_s *ioc, enum ioc_event event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 545) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 546) bfa_trc(ioc, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 547)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 548) switch (event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 549) case IOC_E_ENABLED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 550) bfa_fsm_set_state(ioc, bfa_ioc_sm_getattr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 551) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 552)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 553) case IOC_E_PFFAILED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 554) case IOC_E_HWERROR:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 555) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 556) * Initialization retry failed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 557) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 558) ioc->cbfn->enable_cbfn(ioc->bfa, BFA_STATUS_IOC_FAILURE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 559) bfa_fsm_set_state(ioc, bfa_ioc_sm_fail);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 560) if (event != IOC_E_PFFAILED)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 561) bfa_fsm_send_event(&ioc->iocpf, IOCPF_E_INITFAIL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 562) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 563)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 564) case IOC_E_HWFAILED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 565) ioc->cbfn->enable_cbfn(ioc->bfa, BFA_STATUS_IOC_FAILURE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 566) bfa_fsm_set_state(ioc, bfa_ioc_sm_hwfail);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 567) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 568)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 569) case IOC_E_ENABLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 570) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 571)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 572) case IOC_E_DISABLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 573) bfa_fsm_set_state(ioc, bfa_ioc_sm_disabling);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 574) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 575)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 576) case IOC_E_DETACH:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 577) bfa_fsm_set_state(ioc, bfa_ioc_sm_uninit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 578) bfa_fsm_send_event(&ioc->iocpf, IOCPF_E_STOP);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 579) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 580)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 581) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 582) bfa_sm_fault(ioc, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 583) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 584) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 585)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 586)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 587) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 588) bfa_ioc_sm_fail_entry(struct bfa_ioc_s *ioc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 589) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 590) bfa_trc(ioc, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 591) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 592)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 593) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 594) * IOC failure.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 595) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 596) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 597) bfa_ioc_sm_fail(struct bfa_ioc_s *ioc, enum ioc_event event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 598) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 599) bfa_trc(ioc, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 600)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 601) switch (event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 602)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 603) case IOC_E_ENABLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 604) ioc->cbfn->enable_cbfn(ioc->bfa, BFA_STATUS_IOC_FAILURE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 605) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 606)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 607) case IOC_E_DISABLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 608) bfa_fsm_set_state(ioc, bfa_ioc_sm_disabling);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 609) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 610)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 611) case IOC_E_DETACH:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 612) bfa_fsm_set_state(ioc, bfa_ioc_sm_uninit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 613) bfa_fsm_send_event(&ioc->iocpf, IOCPF_E_STOP);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 614) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 615)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 616) case IOC_E_HWERROR:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 617) case IOC_E_HWFAILED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 618) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 619) * HB failure / HW error notification, ignore.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 620) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 621) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 622) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 623) bfa_sm_fault(ioc, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 624) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 625) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 626)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 627) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 628) bfa_ioc_sm_hwfail_entry(struct bfa_ioc_s *ioc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 629) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 630) bfa_trc(ioc, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 631) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 632)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 633) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 634) bfa_ioc_sm_hwfail(struct bfa_ioc_s *ioc, enum ioc_event event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 635) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 636) bfa_trc(ioc, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 637)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 638) switch (event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 639) case IOC_E_ENABLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 640) ioc->cbfn->enable_cbfn(ioc->bfa, BFA_STATUS_IOC_FAILURE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 641) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 642)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 643) case IOC_E_DISABLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 644) ioc->cbfn->disable_cbfn(ioc->bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 645) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 646)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 647) case IOC_E_DETACH:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 648) bfa_fsm_set_state(ioc, bfa_ioc_sm_uninit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 649) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 650)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 651) case IOC_E_HWERROR:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 652) /* Ignore - already in hwfail state */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 653) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 654)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 655) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 656) bfa_sm_fault(ioc, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 657) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 658) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 659)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 660) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 661) * IOCPF State Machine
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 662) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 663)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 664) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 665) * Reset entry actions -- initialize state machine
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 666) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 667) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 668) bfa_iocpf_sm_reset_entry(struct bfa_iocpf_s *iocpf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 669) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 670) iocpf->fw_mismatch_notified = BFA_FALSE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 671) iocpf->auto_recover = bfa_auto_recover;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 672) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 673)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 674) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 675) * Beginning state. IOC is in reset state.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 676) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 677) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 678) bfa_iocpf_sm_reset(struct bfa_iocpf_s *iocpf, enum iocpf_event event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 679) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 680) struct bfa_ioc_s *ioc = iocpf->ioc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 681)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 682) bfa_trc(ioc, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 683)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 684) switch (event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 685) case IOCPF_E_ENABLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 686) bfa_fsm_set_state(iocpf, bfa_iocpf_sm_fwcheck);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 687) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 688)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 689) case IOCPF_E_STOP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 690) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 691)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 692) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 693) bfa_sm_fault(ioc, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 694) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 695) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 696)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 697) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 698) * Semaphore should be acquired for version check.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 699) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 700) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 701) bfa_iocpf_sm_fwcheck_entry(struct bfa_iocpf_s *iocpf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 702) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 703) struct bfi_ioc_image_hdr_s fwhdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 704) u32 r32, fwstate, pgnum, loff = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 705) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 706)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 707) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 708) * Spin on init semaphore to serialize.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 709) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 710) r32 = readl(iocpf->ioc->ioc_regs.ioc_init_sem_reg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 711) while (r32 & 0x1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 712) udelay(20);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 713) r32 = readl(iocpf->ioc->ioc_regs.ioc_init_sem_reg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 714) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 715)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 716) /* h/w sem init */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 717) fwstate = bfa_ioc_get_cur_ioc_fwstate(iocpf->ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 718) if (fwstate == BFI_IOC_UNINIT) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 719) writel(1, iocpf->ioc->ioc_regs.ioc_init_sem_reg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 720) goto sem_get;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 721) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 722)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 723) bfa_ioc_fwver_get(iocpf->ioc, &fwhdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 724)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 725) if (swab32(fwhdr.exec) == BFI_FWBOOT_TYPE_NORMAL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 726) writel(1, iocpf->ioc->ioc_regs.ioc_init_sem_reg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 727) goto sem_get;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 728) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 729)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 730) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 731) * Clear fwver hdr
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 732) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 733) pgnum = PSS_SMEM_PGNUM(iocpf->ioc->ioc_regs.smem_pg0, loff);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 734) writel(pgnum, iocpf->ioc->ioc_regs.host_page_num_fn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 735)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 736) for (i = 0; i < sizeof(struct bfi_ioc_image_hdr_s) / sizeof(u32); i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 737) bfa_mem_write(iocpf->ioc->ioc_regs.smem_page_start, loff, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 738) loff += sizeof(u32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 739) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 740)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 741) bfa_trc(iocpf->ioc, fwstate);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 742) bfa_trc(iocpf->ioc, swab32(fwhdr.exec));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 743) bfa_ioc_set_cur_ioc_fwstate(iocpf->ioc, BFI_IOC_UNINIT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 744) bfa_ioc_set_alt_ioc_fwstate(iocpf->ioc, BFI_IOC_UNINIT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 745)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 746) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 747) * Unlock the hw semaphore. Should be here only once per boot.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 748) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 749) bfa_ioc_ownership_reset(iocpf->ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 750)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 751) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 752) * unlock init semaphore.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 753) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 754) writel(1, iocpf->ioc->ioc_regs.ioc_init_sem_reg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 755)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 756) sem_get:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 757) bfa_ioc_hw_sem_get(iocpf->ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 758) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 759)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 760) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 761) * Awaiting h/w semaphore to continue with version check.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 762) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 763) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 764) bfa_iocpf_sm_fwcheck(struct bfa_iocpf_s *iocpf, enum iocpf_event event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 765) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 766) struct bfa_ioc_s *ioc = iocpf->ioc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 767)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 768) bfa_trc(ioc, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 769)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 770) switch (event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 771) case IOCPF_E_SEMLOCKED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 772) if (bfa_ioc_firmware_lock(ioc)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 773) if (bfa_ioc_sync_start(ioc)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 774) bfa_ioc_sync_join(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 775) bfa_fsm_set_state(iocpf, bfa_iocpf_sm_hwinit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 776) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 777) bfa_ioc_firmware_unlock(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 778) writel(1, ioc->ioc_regs.ioc_sem_reg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 779) bfa_sem_timer_start(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 780) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 781) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 782) writel(1, ioc->ioc_regs.ioc_sem_reg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 783) bfa_fsm_set_state(iocpf, bfa_iocpf_sm_mismatch);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 784) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 785) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 786)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 787) case IOCPF_E_SEM_ERROR:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 788) bfa_fsm_set_state(iocpf, bfa_iocpf_sm_fail);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 789) bfa_fsm_send_event(ioc, IOC_E_HWFAILED);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 790) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 791)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 792) case IOCPF_E_DISABLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 793) bfa_sem_timer_stop(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 794) bfa_fsm_set_state(iocpf, bfa_iocpf_sm_reset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 795) bfa_fsm_send_event(ioc, IOC_E_DISABLED);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 796) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 797)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 798) case IOCPF_E_STOP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 799) bfa_sem_timer_stop(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 800) bfa_fsm_set_state(iocpf, bfa_iocpf_sm_reset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 801) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 802)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 803) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 804) bfa_sm_fault(ioc, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 805) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 806) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 807)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 808) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 809) * Notify enable completion callback.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 810) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 811) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 812) bfa_iocpf_sm_mismatch_entry(struct bfa_iocpf_s *iocpf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 813) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 814) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 815) * Call only the first time sm enters fwmismatch state.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 816) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 817) if (iocpf->fw_mismatch_notified == BFA_FALSE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 818) bfa_ioc_pf_fwmismatch(iocpf->ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 819)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 820) iocpf->fw_mismatch_notified = BFA_TRUE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 821) bfa_iocpf_timer_start(iocpf->ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 822) }
^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) * Awaiting firmware version match.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 826) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 827) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 828) bfa_iocpf_sm_mismatch(struct bfa_iocpf_s *iocpf, enum iocpf_event event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 829) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 830) struct bfa_ioc_s *ioc = iocpf->ioc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 831)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 832) bfa_trc(ioc, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 833)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 834) switch (event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 835) case IOCPF_E_TIMEOUT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 836) bfa_fsm_set_state(iocpf, bfa_iocpf_sm_fwcheck);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 837) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 838)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 839) case IOCPF_E_DISABLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 840) bfa_iocpf_timer_stop(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 841) bfa_fsm_set_state(iocpf, bfa_iocpf_sm_reset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 842) bfa_fsm_send_event(ioc, IOC_E_DISABLED);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 843) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 844)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 845) case IOCPF_E_STOP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 846) bfa_iocpf_timer_stop(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 847) bfa_fsm_set_state(iocpf, bfa_iocpf_sm_reset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 848) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 849)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 850) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 851) bfa_sm_fault(ioc, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 852) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 853) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 854)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 855) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 856) * Request for semaphore.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 857) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 858) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 859) bfa_iocpf_sm_semwait_entry(struct bfa_iocpf_s *iocpf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 860) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 861) bfa_ioc_hw_sem_get(iocpf->ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 862) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 863)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 864) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 865) * Awaiting semaphore for h/w initialzation.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 866) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 867) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 868) bfa_iocpf_sm_semwait(struct bfa_iocpf_s *iocpf, enum iocpf_event event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 869) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 870) struct bfa_ioc_s *ioc = iocpf->ioc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 871)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 872) bfa_trc(ioc, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 873)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 874) switch (event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 875) case IOCPF_E_SEMLOCKED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 876) if (bfa_ioc_sync_complete(ioc)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 877) bfa_ioc_sync_join(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 878) bfa_fsm_set_state(iocpf, bfa_iocpf_sm_hwinit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 879) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 880) writel(1, ioc->ioc_regs.ioc_sem_reg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 881) bfa_sem_timer_start(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 882) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 883) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 884)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 885) case IOCPF_E_SEM_ERROR:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 886) bfa_fsm_set_state(iocpf, bfa_iocpf_sm_fail);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 887) bfa_fsm_send_event(ioc, IOC_E_HWFAILED);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 888) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 889)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 890) case IOCPF_E_DISABLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 891) bfa_sem_timer_stop(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 892) bfa_fsm_set_state(iocpf, bfa_iocpf_sm_disabling_sync);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 893) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 894)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 895) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 896) bfa_sm_fault(ioc, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 897) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 898) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 899)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 900) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 901) bfa_iocpf_sm_hwinit_entry(struct bfa_iocpf_s *iocpf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 902) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 903) iocpf->poll_time = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 904) bfa_ioc_hwinit(iocpf->ioc, BFA_FALSE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 905) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 906)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 907) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 908) * Hardware is being initialized. Interrupts are enabled.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 909) * Holding hardware semaphore lock.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 910) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 911) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 912) bfa_iocpf_sm_hwinit(struct bfa_iocpf_s *iocpf, enum iocpf_event event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 913) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 914) struct bfa_ioc_s *ioc = iocpf->ioc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 915)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 916) bfa_trc(ioc, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 917)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 918) switch (event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 919) case IOCPF_E_FWREADY:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 920) bfa_fsm_set_state(iocpf, bfa_iocpf_sm_enabling);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 921) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 922)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 923) case IOCPF_E_TIMEOUT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 924) writel(1, ioc->ioc_regs.ioc_sem_reg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 925) bfa_fsm_send_event(ioc, IOC_E_PFFAILED);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 926) bfa_fsm_set_state(iocpf, bfa_iocpf_sm_initfail_sync);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 927) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 928)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 929) case IOCPF_E_DISABLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 930) bfa_iocpf_timer_stop(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 931) bfa_ioc_sync_leave(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 932) writel(1, ioc->ioc_regs.ioc_sem_reg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 933) bfa_fsm_set_state(iocpf, bfa_iocpf_sm_disabled);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 934) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 935)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 936) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 937) bfa_sm_fault(ioc, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 938) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 939) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 940)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 941) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 942) bfa_iocpf_sm_enabling_entry(struct bfa_iocpf_s *iocpf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 943) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 944) bfa_iocpf_timer_start(iocpf->ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 945) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 946) * Enable Interrupts before sending fw IOC ENABLE cmd.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 947) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 948) iocpf->ioc->cbfn->reset_cbfn(iocpf->ioc->bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 949) bfa_ioc_send_enable(iocpf->ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 950) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 951)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 952) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 953) * Host IOC function is being enabled, awaiting response from firmware.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 954) * Semaphore is acquired.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 955) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 956) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 957) bfa_iocpf_sm_enabling(struct bfa_iocpf_s *iocpf, enum iocpf_event event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 958) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 959) struct bfa_ioc_s *ioc = iocpf->ioc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 960)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 961) bfa_trc(ioc, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 962)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 963) switch (event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 964) case IOCPF_E_FWRSP_ENABLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 965) bfa_iocpf_timer_stop(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 966) writel(1, ioc->ioc_regs.ioc_sem_reg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 967) bfa_fsm_set_state(iocpf, bfa_iocpf_sm_ready);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 968) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 969)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 970) case IOCPF_E_INITFAIL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 971) bfa_iocpf_timer_stop(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 972) fallthrough;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 973)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 974) case IOCPF_E_TIMEOUT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 975) writel(1, ioc->ioc_regs.ioc_sem_reg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 976) if (event == IOCPF_E_TIMEOUT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 977) bfa_fsm_send_event(ioc, IOC_E_PFFAILED);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 978) bfa_fsm_set_state(iocpf, bfa_iocpf_sm_initfail_sync);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 979) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 980)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 981) case IOCPF_E_DISABLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 982) bfa_iocpf_timer_stop(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 983) writel(1, ioc->ioc_regs.ioc_sem_reg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 984) bfa_fsm_set_state(iocpf, bfa_iocpf_sm_disabling);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 985) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 986)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 987) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 988) bfa_sm_fault(ioc, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 989) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 990) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 991)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 992) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 993) bfa_iocpf_sm_ready_entry(struct bfa_iocpf_s *iocpf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 994) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 995) bfa_fsm_send_event(iocpf->ioc, IOC_E_ENABLED);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 996) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 997)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 998) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 999) bfa_iocpf_sm_ready(struct bfa_iocpf_s *iocpf, enum iocpf_event event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1000) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1001) struct bfa_ioc_s *ioc = iocpf->ioc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1002)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1003) bfa_trc(ioc, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1004)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1005) switch (event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1006) case IOCPF_E_DISABLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1007) bfa_fsm_set_state(iocpf, bfa_iocpf_sm_disabling);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1008) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1009)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1010) case IOCPF_E_GETATTRFAIL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1011) bfa_fsm_set_state(iocpf, bfa_iocpf_sm_initfail_sync);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1012) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1013)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1014) case IOCPF_E_FAIL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1015) bfa_fsm_set_state(iocpf, bfa_iocpf_sm_fail_sync);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1016) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1017)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1018) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1019) bfa_sm_fault(ioc, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1020) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1021) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1022)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1023) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1024) bfa_iocpf_sm_disabling_entry(struct bfa_iocpf_s *iocpf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1025) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1026) bfa_iocpf_timer_start(iocpf->ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1027) bfa_ioc_send_disable(iocpf->ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1028) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1029)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1030) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1031) * IOC is being disabled
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1032) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1033) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1034) bfa_iocpf_sm_disabling(struct bfa_iocpf_s *iocpf, enum iocpf_event event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1035) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1036) struct bfa_ioc_s *ioc = iocpf->ioc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1037)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1038) bfa_trc(ioc, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1039)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1040) switch (event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1041) case IOCPF_E_FWRSP_DISABLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1042) bfa_iocpf_timer_stop(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1043) bfa_fsm_set_state(iocpf, bfa_iocpf_sm_disabling_sync);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1044) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1045)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1046) case IOCPF_E_FAIL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1047) bfa_iocpf_timer_stop(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1048) fallthrough;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1049)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1050) case IOCPF_E_TIMEOUT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1051) bfa_ioc_set_cur_ioc_fwstate(ioc, BFI_IOC_FAIL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1052) bfa_fsm_set_state(iocpf, bfa_iocpf_sm_disabling_sync);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1053) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1054)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1055) case IOCPF_E_FWRSP_ENABLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1056) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1057)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1058) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1059) bfa_sm_fault(ioc, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1060) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1061) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1062)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1063) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1064) bfa_iocpf_sm_disabling_sync_entry(struct bfa_iocpf_s *iocpf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1065) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1066) bfa_ioc_hw_sem_get(iocpf->ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1067) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1068)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1069) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1070) * IOC hb ack request is being removed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1071) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1072) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1073) bfa_iocpf_sm_disabling_sync(struct bfa_iocpf_s *iocpf, enum iocpf_event event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1074) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1075) struct bfa_ioc_s *ioc = iocpf->ioc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1076)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1077) bfa_trc(ioc, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1078)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1079) switch (event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1080) case IOCPF_E_SEMLOCKED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1081) bfa_ioc_sync_leave(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1082) writel(1, ioc->ioc_regs.ioc_sem_reg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1083) bfa_fsm_set_state(iocpf, bfa_iocpf_sm_disabled);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1084) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1085)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1086) case IOCPF_E_SEM_ERROR:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1087) bfa_fsm_set_state(iocpf, bfa_iocpf_sm_fail);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1088) bfa_fsm_send_event(ioc, IOC_E_HWFAILED);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1089) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1090)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1091) case IOCPF_E_FAIL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1092) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1093)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1094) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1095) bfa_sm_fault(ioc, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1096) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1097) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1098)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1099) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1100) * IOC disable completion entry.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1101) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1102) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1103) bfa_iocpf_sm_disabled_entry(struct bfa_iocpf_s *iocpf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1104) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1105) bfa_ioc_mbox_flush(iocpf->ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1106) bfa_fsm_send_event(iocpf->ioc, IOC_E_DISABLED);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1107) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1108)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1109) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1110) bfa_iocpf_sm_disabled(struct bfa_iocpf_s *iocpf, enum iocpf_event event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1111) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1112) struct bfa_ioc_s *ioc = iocpf->ioc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1113)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1114) bfa_trc(ioc, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1115)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1116) switch (event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1117) case IOCPF_E_ENABLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1118) bfa_fsm_set_state(iocpf, bfa_iocpf_sm_semwait);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1119) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1120)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1121) case IOCPF_E_STOP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1122) bfa_ioc_firmware_unlock(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1123) bfa_fsm_set_state(iocpf, bfa_iocpf_sm_reset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1124) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1125)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1126) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1127) bfa_sm_fault(ioc, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1128) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1129) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1130)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1131) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1132) bfa_iocpf_sm_initfail_sync_entry(struct bfa_iocpf_s *iocpf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1133) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1134) bfa_ioc_debug_save_ftrc(iocpf->ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1135) bfa_ioc_hw_sem_get(iocpf->ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1136) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1137)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1138) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1139) * Hardware initialization failed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1140) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1141) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1142) bfa_iocpf_sm_initfail_sync(struct bfa_iocpf_s *iocpf, enum iocpf_event event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1143) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1144) struct bfa_ioc_s *ioc = iocpf->ioc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1145)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1146) bfa_trc(ioc, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1147)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1148) switch (event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1149) case IOCPF_E_SEMLOCKED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1150) bfa_ioc_notify_fail(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1151) bfa_ioc_sync_leave(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1152) bfa_ioc_set_cur_ioc_fwstate(ioc, BFI_IOC_FAIL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1153) writel(1, ioc->ioc_regs.ioc_sem_reg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1154) bfa_fsm_set_state(iocpf, bfa_iocpf_sm_initfail);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1155) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1156)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1157) case IOCPF_E_SEM_ERROR:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1158) bfa_fsm_set_state(iocpf, bfa_iocpf_sm_fail);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1159) bfa_fsm_send_event(ioc, IOC_E_HWFAILED);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1160) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1161)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1162) case IOCPF_E_DISABLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1163) bfa_sem_timer_stop(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1164) bfa_fsm_set_state(iocpf, bfa_iocpf_sm_disabling_sync);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1165) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1166)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1167) case IOCPF_E_STOP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1168) bfa_sem_timer_stop(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1169) bfa_ioc_firmware_unlock(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1170) bfa_fsm_set_state(iocpf, bfa_iocpf_sm_reset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1171) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1172)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1173) case IOCPF_E_FAIL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1174) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1175)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1176) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1177) bfa_sm_fault(ioc, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1178) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1179) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1180)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1181) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1182) bfa_iocpf_sm_initfail_entry(struct bfa_iocpf_s *iocpf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1183) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1184) bfa_trc(iocpf->ioc, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1185) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1186)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1187) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1188) * Hardware initialization failed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1189) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1190) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1191) bfa_iocpf_sm_initfail(struct bfa_iocpf_s *iocpf, enum iocpf_event event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1192) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1193) struct bfa_ioc_s *ioc = iocpf->ioc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1194)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1195) bfa_trc(ioc, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1196)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1197) switch (event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1198) case IOCPF_E_DISABLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1199) bfa_fsm_set_state(iocpf, bfa_iocpf_sm_disabled);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1200) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1201)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1202) case IOCPF_E_STOP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1203) bfa_ioc_firmware_unlock(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1204) bfa_fsm_set_state(iocpf, bfa_iocpf_sm_reset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1205) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1206)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1207) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1208) bfa_sm_fault(ioc, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1209) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1210) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1211)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1212) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1213) bfa_iocpf_sm_fail_sync_entry(struct bfa_iocpf_s *iocpf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1214) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1215) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1216) * Mark IOC as failed in hardware and stop firmware.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1217) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1218) bfa_ioc_lpu_stop(iocpf->ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1219)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1220) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1221) * Flush any queued up mailbox requests.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1222) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1223) bfa_ioc_mbox_flush(iocpf->ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1224)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1225) bfa_ioc_hw_sem_get(iocpf->ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1226) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1227)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1228) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1229) bfa_iocpf_sm_fail_sync(struct bfa_iocpf_s *iocpf, enum iocpf_event event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1230) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1231) struct bfa_ioc_s *ioc = iocpf->ioc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1232)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1233) bfa_trc(ioc, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1234)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1235) switch (event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1236) case IOCPF_E_SEMLOCKED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1237) bfa_ioc_sync_ack(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1238) bfa_ioc_notify_fail(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1239) if (!iocpf->auto_recover) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1240) bfa_ioc_sync_leave(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1241) bfa_ioc_set_cur_ioc_fwstate(ioc, BFI_IOC_FAIL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1242) writel(1, ioc->ioc_regs.ioc_sem_reg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1243) bfa_fsm_set_state(iocpf, bfa_iocpf_sm_fail);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1244) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1245) if (bfa_ioc_sync_complete(ioc))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1246) bfa_fsm_set_state(iocpf, bfa_iocpf_sm_hwinit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1247) else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1248) writel(1, ioc->ioc_regs.ioc_sem_reg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1249) bfa_fsm_set_state(iocpf, bfa_iocpf_sm_semwait);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1250) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1251) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1252) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1253)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1254) case IOCPF_E_SEM_ERROR:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1255) bfa_fsm_set_state(iocpf, bfa_iocpf_sm_fail);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1256) bfa_fsm_send_event(ioc, IOC_E_HWFAILED);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1257) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1258)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1259) case IOCPF_E_DISABLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1260) bfa_sem_timer_stop(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1261) bfa_fsm_set_state(iocpf, bfa_iocpf_sm_disabling_sync);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1262) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1263)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1264) case IOCPF_E_FAIL:
^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) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1268) bfa_sm_fault(ioc, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1269) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1270) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1271)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1272) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1273) bfa_iocpf_sm_fail_entry(struct bfa_iocpf_s *iocpf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1274) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1275) bfa_trc(iocpf->ioc, 0);
^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) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1279) * IOC is in failed state.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1280) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1281) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1282) bfa_iocpf_sm_fail(struct bfa_iocpf_s *iocpf, enum iocpf_event event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1283) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1284) struct bfa_ioc_s *ioc = iocpf->ioc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1285)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1286) bfa_trc(ioc, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1287)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1288) switch (event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1289) case IOCPF_E_DISABLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1290) bfa_fsm_set_state(iocpf, bfa_iocpf_sm_disabled);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1291) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1292)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1293) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1294) bfa_sm_fault(ioc, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1295) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1296) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1297)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1298) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1299) * BFA IOC private functions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1300) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1301)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1302) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1303) * Notify common modules registered for notification.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1304) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1305) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1306) bfa_ioc_event_notify(struct bfa_ioc_s *ioc, enum bfa_ioc_event_e event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1307) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1308) struct bfa_ioc_notify_s *notify;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1309) struct list_head *qe;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1310)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1311) list_for_each(qe, &ioc->notify_q) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1312) notify = (struct bfa_ioc_notify_s *)qe;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1313) notify->cbfn(notify->cbarg, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1314) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1315) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1316)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1317) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1318) bfa_ioc_disable_comp(struct bfa_ioc_s *ioc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1319) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1320) ioc->cbfn->disable_cbfn(ioc->bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1321) bfa_ioc_event_notify(ioc, BFA_IOC_E_DISABLED);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1322) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1323)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1324) bfa_boolean_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1325) bfa_ioc_sem_get(void __iomem *sem_reg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1326) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1327) u32 r32;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1328) int cnt = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1329) #define BFA_SEM_SPINCNT 3000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1330)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1331) r32 = readl(sem_reg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1332)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1333) while ((r32 & 1) && (cnt < BFA_SEM_SPINCNT)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1334) cnt++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1335) udelay(2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1336) r32 = readl(sem_reg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1337) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1338)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1339) if (!(r32 & 1))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1340) return BFA_TRUE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1341)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1342) return BFA_FALSE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1343) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1344)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1345) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1346) bfa_ioc_hw_sem_get(struct bfa_ioc_s *ioc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1347) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1348) u32 r32;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1349)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1350) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1351) * First read to the semaphore register will return 0, subsequent reads
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1352) * will return 1. Semaphore is released by writing 1 to the register
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1353) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1354) r32 = readl(ioc->ioc_regs.ioc_sem_reg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1355) if (r32 == ~0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1356) WARN_ON(r32 == ~0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1357) bfa_fsm_send_event(&ioc->iocpf, IOCPF_E_SEM_ERROR);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1358) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1359) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1360) if (!(r32 & 1)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1361) bfa_fsm_send_event(&ioc->iocpf, IOCPF_E_SEMLOCKED);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1362) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1363) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1364)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1365) bfa_sem_timer_start(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1366) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1367)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1368) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1369) * Initialize LPU local memory (aka secondary memory / SRAM)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1370) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1371) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1372) bfa_ioc_lmem_init(struct bfa_ioc_s *ioc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1373) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1374) u32 pss_ctl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1375) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1376) #define PSS_LMEM_INIT_TIME 10000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1377)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1378) pss_ctl = readl(ioc->ioc_regs.pss_ctl_reg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1379) pss_ctl &= ~__PSS_LMEM_RESET;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1380) pss_ctl |= __PSS_LMEM_INIT_EN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1381)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1382) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1383) * i2c workaround 12.5khz clock
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1384) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1385) pss_ctl |= __PSS_I2C_CLK_DIV(3UL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1386) writel(pss_ctl, ioc->ioc_regs.pss_ctl_reg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1387)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1388) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1389) * wait for memory initialization to be complete
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1390) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1391) i = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1392) do {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1393) pss_ctl = readl(ioc->ioc_regs.pss_ctl_reg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1394) i++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1395) } while (!(pss_ctl & __PSS_LMEM_INIT_DONE) && (i < PSS_LMEM_INIT_TIME));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1396)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1397) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1398) * If memory initialization is not successful, IOC timeout will catch
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1399) * such failures.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1400) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1401) WARN_ON(!(pss_ctl & __PSS_LMEM_INIT_DONE));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1402) bfa_trc(ioc, pss_ctl);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1403)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1404) pss_ctl &= ~(__PSS_LMEM_INIT_DONE | __PSS_LMEM_INIT_EN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1405) writel(pss_ctl, ioc->ioc_regs.pss_ctl_reg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1406) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1407)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1408) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1409) bfa_ioc_lpu_start(struct bfa_ioc_s *ioc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1410) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1411) u32 pss_ctl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1412)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1413) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1414) * Take processor out of reset.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1415) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1416) pss_ctl = readl(ioc->ioc_regs.pss_ctl_reg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1417) pss_ctl &= ~__PSS_LPU0_RESET;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1418)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1419) writel(pss_ctl, ioc->ioc_regs.pss_ctl_reg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1420) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1421)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1422) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1423) bfa_ioc_lpu_stop(struct bfa_ioc_s *ioc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1424) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1425) u32 pss_ctl;
^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) * Put processors in reset.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1429) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1430) pss_ctl = readl(ioc->ioc_regs.pss_ctl_reg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1431) pss_ctl |= (__PSS_LPU0_RESET | __PSS_LPU1_RESET);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1432)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1433) writel(pss_ctl, ioc->ioc_regs.pss_ctl_reg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1434) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1435)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1436) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1437) * Get driver and firmware versions.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1438) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1439) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1440) bfa_ioc_fwver_get(struct bfa_ioc_s *ioc, struct bfi_ioc_image_hdr_s *fwhdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1441) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1442) u32 pgnum;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1443) u32 loff = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1444) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1445) u32 *fwsig = (u32 *) fwhdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1446)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1447) pgnum = PSS_SMEM_PGNUM(ioc->ioc_regs.smem_pg0, loff);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1448) writel(pgnum, ioc->ioc_regs.host_page_num_fn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1449)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1450) for (i = 0; i < (sizeof(struct bfi_ioc_image_hdr_s) / sizeof(u32));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1451) i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1452) fwsig[i] =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1453) bfa_mem_read(ioc->ioc_regs.smem_page_start, loff);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1454) loff += sizeof(u32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1455) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1456) }
^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) * Returns TRUE if driver is willing to work with current smem f/w version.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1460) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1461) bfa_boolean_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1462) bfa_ioc_fwver_cmp(struct bfa_ioc_s *ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1463) struct bfi_ioc_image_hdr_s *smem_fwhdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1464) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1465) struct bfi_ioc_image_hdr_s *drv_fwhdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1466) enum bfi_ioc_img_ver_cmp_e smem_flash_cmp, drv_smem_cmp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1467)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1468) drv_fwhdr = (struct bfi_ioc_image_hdr_s *)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1469) bfa_cb_image_get_chunk(bfa_ioc_asic_gen(ioc), 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1470)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1471) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1472) * If smem is incompatible or old, driver should not work with it.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1473) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1474) drv_smem_cmp = bfa_ioc_fw_ver_patch_cmp(drv_fwhdr, smem_fwhdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1475) if (drv_smem_cmp == BFI_IOC_IMG_VER_INCOMP ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1476) drv_smem_cmp == BFI_IOC_IMG_VER_OLD) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1477) return BFA_FALSE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1478) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1479)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1480) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1481) * IF Flash has a better F/W than smem do not work with smem.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1482) * If smem f/w == flash f/w, as smem f/w not old | incmp, work with it.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1483) * If Flash is old or incomp work with smem iff smem f/w == drv f/w.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1484) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1485) smem_flash_cmp = bfa_ioc_flash_fwver_cmp(ioc, smem_fwhdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1486)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1487) if (smem_flash_cmp == BFI_IOC_IMG_VER_BETTER) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1488) return BFA_FALSE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1489) } else if (smem_flash_cmp == BFI_IOC_IMG_VER_SAME) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1490) return BFA_TRUE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1491) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1492) return (drv_smem_cmp == BFI_IOC_IMG_VER_SAME) ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1493) BFA_TRUE : BFA_FALSE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1494) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1495) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1496)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1497) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1498) * Return true if current running version is valid. Firmware signature and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1499) * execution context (driver/bios) must match.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1500) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1501) static bfa_boolean_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1502) bfa_ioc_fwver_valid(struct bfa_ioc_s *ioc, u32 boot_env)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1503) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1504) struct bfi_ioc_image_hdr_s fwhdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1505)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1506) bfa_ioc_fwver_get(ioc, &fwhdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1507)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1508) if (swab32(fwhdr.bootenv) != boot_env) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1509) bfa_trc(ioc, fwhdr.bootenv);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1510) bfa_trc(ioc, boot_env);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1511) return BFA_FALSE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1512) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1513)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1514) return bfa_ioc_fwver_cmp(ioc, &fwhdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1515) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1516)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1517) static bfa_boolean_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1518) bfa_ioc_fwver_md5_check(struct bfi_ioc_image_hdr_s *fwhdr_1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1519) struct bfi_ioc_image_hdr_s *fwhdr_2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1520) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1521) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1522)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1523) for (i = 0; i < BFI_IOC_MD5SUM_SZ; i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1524) if (fwhdr_1->md5sum[i] != fwhdr_2->md5sum[i])
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1525) return BFA_FALSE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1526)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1527) return BFA_TRUE;
^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) * Returns TRUE if major minor and maintainence are same.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1532) * If patch versions are same, check for MD5 Checksum to be same.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1533) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1534) static bfa_boolean_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1535) bfa_ioc_fw_ver_compatible(struct bfi_ioc_image_hdr_s *drv_fwhdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1536) struct bfi_ioc_image_hdr_s *fwhdr_to_cmp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1537) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1538) if (drv_fwhdr->signature != fwhdr_to_cmp->signature)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1539) return BFA_FALSE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1540)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1541) if (drv_fwhdr->fwver.major != fwhdr_to_cmp->fwver.major)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1542) return BFA_FALSE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1543)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1544) if (drv_fwhdr->fwver.minor != fwhdr_to_cmp->fwver.minor)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1545) return BFA_FALSE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1546)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1547) if (drv_fwhdr->fwver.maint != fwhdr_to_cmp->fwver.maint)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1548) return BFA_FALSE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1549)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1550) if (drv_fwhdr->fwver.patch == fwhdr_to_cmp->fwver.patch &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1551) drv_fwhdr->fwver.phase == fwhdr_to_cmp->fwver.phase &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1552) drv_fwhdr->fwver.build == fwhdr_to_cmp->fwver.build) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1553) return bfa_ioc_fwver_md5_check(drv_fwhdr, fwhdr_to_cmp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1554) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1555)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1556) return BFA_TRUE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1557) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1558)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1559) static bfa_boolean_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1560) bfa_ioc_flash_fwver_valid(struct bfi_ioc_image_hdr_s *flash_fwhdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1561) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1562) if (flash_fwhdr->fwver.major == 0 || flash_fwhdr->fwver.major == 0xFF)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1563) return BFA_FALSE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1564)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1565) return BFA_TRUE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1566) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1567)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1568) static bfa_boolean_t fwhdr_is_ga(struct bfi_ioc_image_hdr_s *fwhdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1569) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1570) if (fwhdr->fwver.phase == 0 &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1571) fwhdr->fwver.build == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1572) return BFA_TRUE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1573)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1574) return BFA_FALSE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1575) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1576)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1577) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1578) * Returns TRUE if both are compatible and patch of fwhdr_to_cmp is better.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1579) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1580) static enum bfi_ioc_img_ver_cmp_e
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1581) bfa_ioc_fw_ver_patch_cmp(struct bfi_ioc_image_hdr_s *base_fwhdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1582) struct bfi_ioc_image_hdr_s *fwhdr_to_cmp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1583) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1584) if (bfa_ioc_fw_ver_compatible(base_fwhdr, fwhdr_to_cmp) == BFA_FALSE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1585) return BFI_IOC_IMG_VER_INCOMP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1586)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1587) if (fwhdr_to_cmp->fwver.patch > base_fwhdr->fwver.patch)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1588) return BFI_IOC_IMG_VER_BETTER;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1589)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1590) else if (fwhdr_to_cmp->fwver.patch < base_fwhdr->fwver.patch)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1591) return BFI_IOC_IMG_VER_OLD;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1592)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1593) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1594) * GA takes priority over internal builds of the same patch stream.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1595) * At this point major minor maint and patch numbers are same.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1596) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1597)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1598) if (fwhdr_is_ga(base_fwhdr) == BFA_TRUE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1599) if (fwhdr_is_ga(fwhdr_to_cmp))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1600) return BFI_IOC_IMG_VER_SAME;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1601) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1602) return BFI_IOC_IMG_VER_OLD;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1603) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1604) if (fwhdr_is_ga(fwhdr_to_cmp))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1605) return BFI_IOC_IMG_VER_BETTER;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1606) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1607)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1608) if (fwhdr_to_cmp->fwver.phase > base_fwhdr->fwver.phase)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1609) return BFI_IOC_IMG_VER_BETTER;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1610) else if (fwhdr_to_cmp->fwver.phase < base_fwhdr->fwver.phase)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1611) return BFI_IOC_IMG_VER_OLD;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1612)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1613) if (fwhdr_to_cmp->fwver.build > base_fwhdr->fwver.build)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1614) return BFI_IOC_IMG_VER_BETTER;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1615) else if (fwhdr_to_cmp->fwver.build < base_fwhdr->fwver.build)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1616) return BFI_IOC_IMG_VER_OLD;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1617)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1618) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1619) * All Version Numbers are equal.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1620) * Md5 check to be done as a part of compatibility check.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1621) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1622) return BFI_IOC_IMG_VER_SAME;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1623) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1624)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1625) #define BFA_FLASH_PART_FWIMG_ADDR 0x100000 /* fw image address */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1626)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1627) bfa_status_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1628) bfa_ioc_flash_img_get_chnk(struct bfa_ioc_s *ioc, u32 off,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1629) u32 *fwimg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1630) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1631) return bfa_flash_raw_read(ioc->pcidev.pci_bar_kva,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1632) BFA_FLASH_PART_FWIMG_ADDR + (off * sizeof(u32)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1633) (char *)fwimg, BFI_FLASH_CHUNK_SZ);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1634) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1635)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1636) static enum bfi_ioc_img_ver_cmp_e
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1637) bfa_ioc_flash_fwver_cmp(struct bfa_ioc_s *ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1638) struct bfi_ioc_image_hdr_s *base_fwhdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1639) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1640) struct bfi_ioc_image_hdr_s *flash_fwhdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1641) bfa_status_t status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1642) u32 fwimg[BFI_FLASH_CHUNK_SZ_WORDS];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1643)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1644) status = bfa_ioc_flash_img_get_chnk(ioc, 0, fwimg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1645) if (status != BFA_STATUS_OK)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1646) return BFI_IOC_IMG_VER_INCOMP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1647)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1648) flash_fwhdr = (struct bfi_ioc_image_hdr_s *) fwimg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1649) if (bfa_ioc_flash_fwver_valid(flash_fwhdr) == BFA_TRUE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1650) return bfa_ioc_fw_ver_patch_cmp(base_fwhdr, flash_fwhdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1651) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1652) return BFI_IOC_IMG_VER_INCOMP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1653) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1654)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1655)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1656) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1657) * Invalidate fwver signature
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1658) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1659) bfa_status_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1660) bfa_ioc_fwsig_invalidate(struct bfa_ioc_s *ioc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1661) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1662)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1663) u32 pgnum;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1664) u32 loff = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1665) enum bfi_ioc_state ioc_fwstate;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1666)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1667) ioc_fwstate = bfa_ioc_get_cur_ioc_fwstate(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1668) if (!bfa_ioc_state_disabled(ioc_fwstate))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1669) return BFA_STATUS_ADAPTER_ENABLED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1670)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1671) pgnum = PSS_SMEM_PGNUM(ioc->ioc_regs.smem_pg0, loff);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1672) writel(pgnum, ioc->ioc_regs.host_page_num_fn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1673) bfa_mem_write(ioc->ioc_regs.smem_page_start, loff, BFA_IOC_FW_INV_SIGN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1674)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1675) return BFA_STATUS_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1676) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1677)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1678) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1679) * Conditionally flush any pending message from firmware at start.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1680) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1681) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1682) bfa_ioc_msgflush(struct bfa_ioc_s *ioc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1683) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1684) u32 r32;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1685)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1686) r32 = readl(ioc->ioc_regs.lpu_mbox_cmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1687) if (r32)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1688) writel(1, ioc->ioc_regs.lpu_mbox_cmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1689) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1690)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1691) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1692) bfa_ioc_hwinit(struct bfa_ioc_s *ioc, bfa_boolean_t force)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1693) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1694) enum bfi_ioc_state ioc_fwstate;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1695) bfa_boolean_t fwvalid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1696) u32 boot_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1697) u32 boot_env;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1698)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1699) ioc_fwstate = bfa_ioc_get_cur_ioc_fwstate(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1700)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1701) if (force)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1702) ioc_fwstate = BFI_IOC_UNINIT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1703)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1704) bfa_trc(ioc, ioc_fwstate);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1705)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1706) boot_type = BFI_FWBOOT_TYPE_NORMAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1707) boot_env = BFI_FWBOOT_ENV_OS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1708)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1709) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1710) * check if firmware is valid
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1711) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1712) fwvalid = (ioc_fwstate == BFI_IOC_UNINIT) ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1713) BFA_FALSE : bfa_ioc_fwver_valid(ioc, boot_env);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1714)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1715) if (!fwvalid) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1716) if (bfa_ioc_boot(ioc, boot_type, boot_env) == BFA_STATUS_OK)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1717) bfa_ioc_poll_fwinit(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1718) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1719) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1720)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1721) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1722) * If hardware initialization is in progress (initialized by other IOC),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1723) * just wait for an initialization completion interrupt.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1724) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1725) if (ioc_fwstate == BFI_IOC_INITING) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1726) bfa_ioc_poll_fwinit(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1727) return;
^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) * If IOC function is disabled and firmware version is same,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1732) * just re-enable IOC.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1733) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1734) * If option rom, IOC must not be in operational state. With
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1735) * convergence, IOC will be in operational state when 2nd driver
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1736) * is loaded.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1737) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1738) if (ioc_fwstate == BFI_IOC_DISABLED || ioc_fwstate == BFI_IOC_OP) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1739)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1740) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1741) * When using MSI-X any pending firmware ready event should
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1742) * be flushed. Otherwise MSI-X interrupts are not delivered.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1743) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1744) bfa_ioc_msgflush(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1745) bfa_fsm_send_event(&ioc->iocpf, IOCPF_E_FWREADY);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1746) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1747) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1748)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1749) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1750) * Initialize the h/w for any other states.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1751) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1752) if (bfa_ioc_boot(ioc, boot_type, boot_env) == BFA_STATUS_OK)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1753) bfa_ioc_poll_fwinit(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1754) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1755)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1756) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1757) bfa_ioc_timeout(void *ioc_arg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1758) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1759) struct bfa_ioc_s *ioc = (struct bfa_ioc_s *) ioc_arg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1760)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1761) bfa_trc(ioc, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1762) bfa_fsm_send_event(ioc, IOC_E_TIMEOUT);
^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) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1766) bfa_ioc_mbox_send(struct bfa_ioc_s *ioc, void *ioc_msg, int len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1767) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1768) u32 *msgp = (u32 *) ioc_msg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1769) u32 i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1770)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1771) bfa_trc(ioc, msgp[0]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1772) bfa_trc(ioc, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1773)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1774) WARN_ON(len > BFI_IOC_MSGLEN_MAX);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1775)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1776) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1777) * first write msg to mailbox registers
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1778) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1779) for (i = 0; i < len / sizeof(u32); i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1780) writel(cpu_to_le32(msgp[i]),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1781) ioc->ioc_regs.hfn_mbox + i * sizeof(u32));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1782)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1783) for (; i < BFI_IOC_MSGLEN_MAX / sizeof(u32); i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1784) writel(0, ioc->ioc_regs.hfn_mbox + i * sizeof(u32));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1785)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1786) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1787) * write 1 to mailbox CMD to trigger LPU event
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1788) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1789) writel(1, ioc->ioc_regs.hfn_mbox_cmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1790) (void) readl(ioc->ioc_regs.hfn_mbox_cmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1791) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1792)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1793) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1794) bfa_ioc_send_enable(struct bfa_ioc_s *ioc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1795) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1796) struct bfi_ioc_ctrl_req_s enable_req;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1797)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1798) bfi_h2i_set(enable_req.mh, BFI_MC_IOC, BFI_IOC_H2I_ENABLE_REQ,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1799) bfa_ioc_portid(ioc));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1800) enable_req.clscode = cpu_to_be16(ioc->clscode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1801) /* unsigned 32-bit time_t overflow in y2106 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1802) enable_req.tv_sec = be32_to_cpu(ktime_get_real_seconds());
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1803) bfa_ioc_mbox_send(ioc, &enable_req, sizeof(struct bfi_ioc_ctrl_req_s));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1804) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1805)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1806) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1807) bfa_ioc_send_disable(struct bfa_ioc_s *ioc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1808) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1809) struct bfi_ioc_ctrl_req_s disable_req;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1810)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1811) bfi_h2i_set(disable_req.mh, BFI_MC_IOC, BFI_IOC_H2I_DISABLE_REQ,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1812) bfa_ioc_portid(ioc));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1813) disable_req.clscode = cpu_to_be16(ioc->clscode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1814) /* unsigned 32-bit time_t overflow in y2106 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1815) disable_req.tv_sec = be32_to_cpu(ktime_get_real_seconds());
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1816) bfa_ioc_mbox_send(ioc, &disable_req, sizeof(struct bfi_ioc_ctrl_req_s));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1817) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1818)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1819) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1820) bfa_ioc_send_getattr(struct bfa_ioc_s *ioc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1821) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1822) struct bfi_ioc_getattr_req_s attr_req;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1823)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1824) bfi_h2i_set(attr_req.mh, BFI_MC_IOC, BFI_IOC_H2I_GETATTR_REQ,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1825) bfa_ioc_portid(ioc));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1826) bfa_dma_be_addr_set(attr_req.attr_addr, ioc->attr_dma.pa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1827) bfa_ioc_mbox_send(ioc, &attr_req, sizeof(attr_req));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1828) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1829)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1830) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1831) bfa_ioc_hb_check(void *cbarg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1832) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1833) struct bfa_ioc_s *ioc = cbarg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1834) u32 hb_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1835)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1836) hb_count = readl(ioc->ioc_regs.heartbeat);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1837) if (ioc->hb_count == hb_count) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1838) bfa_ioc_recover(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1839) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1840) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1841) ioc->hb_count = hb_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1842) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1843)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1844) bfa_ioc_mbox_poll(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1845) bfa_hb_timer_start(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1846) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1847)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1848) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1849) bfa_ioc_hb_monitor(struct bfa_ioc_s *ioc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1850) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1851) ioc->hb_count = readl(ioc->ioc_regs.heartbeat);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1852) bfa_hb_timer_start(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1853) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1854)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1855) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1856) * Initiate a full firmware download.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1857) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1858) static bfa_status_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1859) bfa_ioc_download_fw(struct bfa_ioc_s *ioc, u32 boot_type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1860) u32 boot_env)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1861) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1862) u32 *fwimg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1863) u32 pgnum;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1864) u32 loff = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1865) u32 chunkno = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1866) u32 i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1867) u32 asicmode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1868) u32 fwimg_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1869) u32 fwimg_buf[BFI_FLASH_CHUNK_SZ_WORDS];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1870) bfa_status_t status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1871)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1872) if (boot_env == BFI_FWBOOT_ENV_OS &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1873) boot_type == BFI_FWBOOT_TYPE_FLASH) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1874) fwimg_size = BFI_FLASH_IMAGE_SZ/sizeof(u32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1875)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1876) status = bfa_ioc_flash_img_get_chnk(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1877) BFA_IOC_FLASH_CHUNK_ADDR(chunkno), fwimg_buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1878) if (status != BFA_STATUS_OK)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1879) return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1880)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1881) fwimg = fwimg_buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1882) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1883) fwimg_size = bfa_cb_image_get_size(bfa_ioc_asic_gen(ioc));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1884) fwimg = bfa_cb_image_get_chunk(bfa_ioc_asic_gen(ioc),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1885) BFA_IOC_FLASH_CHUNK_ADDR(chunkno));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1886) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1887)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1888) bfa_trc(ioc, fwimg_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1889)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1890)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1891) pgnum = PSS_SMEM_PGNUM(ioc->ioc_regs.smem_pg0, loff);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1892) writel(pgnum, ioc->ioc_regs.host_page_num_fn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1893)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1894) for (i = 0; i < fwimg_size; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1895)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1896) if (BFA_IOC_FLASH_CHUNK_NO(i) != chunkno) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1897) chunkno = BFA_IOC_FLASH_CHUNK_NO(i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1898)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1899) if (boot_env == BFI_FWBOOT_ENV_OS &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1900) boot_type == BFI_FWBOOT_TYPE_FLASH) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1901) status = bfa_ioc_flash_img_get_chnk(ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1902) BFA_IOC_FLASH_CHUNK_ADDR(chunkno),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1903) fwimg_buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1904) if (status != BFA_STATUS_OK)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1905) return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1906)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1907) fwimg = fwimg_buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1908) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1909) fwimg = bfa_cb_image_get_chunk(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1910) bfa_ioc_asic_gen(ioc),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1911) BFA_IOC_FLASH_CHUNK_ADDR(chunkno));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1912) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1913) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1914)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1915) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1916) * write smem
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1917) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1918) bfa_mem_write(ioc->ioc_regs.smem_page_start, loff,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1919) fwimg[BFA_IOC_FLASH_OFFSET_IN_CHUNK(i)]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1920)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1921) loff += sizeof(u32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1922)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1923) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1924) * handle page offset wrap around
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1925) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1926) loff = PSS_SMEM_PGOFF(loff);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1927) if (loff == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1928) pgnum++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1929) writel(pgnum, ioc->ioc_regs.host_page_num_fn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1930) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1931) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1932)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1933) writel(PSS_SMEM_PGNUM(ioc->ioc_regs.smem_pg0, 0),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1934) ioc->ioc_regs.host_page_num_fn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1935)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1936) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1937) * Set boot type, env and device mode at the end.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1938) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1939) if (boot_env == BFI_FWBOOT_ENV_OS &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1940) boot_type == BFI_FWBOOT_TYPE_FLASH) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1941) boot_type = BFI_FWBOOT_TYPE_NORMAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1942) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1943) asicmode = BFI_FWBOOT_DEVMODE(ioc->asic_gen, ioc->asic_mode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1944) ioc->port0_mode, ioc->port1_mode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1945) bfa_mem_write(ioc->ioc_regs.smem_page_start, BFI_FWBOOT_DEVMODE_OFF,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1946) swab32(asicmode));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1947) bfa_mem_write(ioc->ioc_regs.smem_page_start, BFI_FWBOOT_TYPE_OFF,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1948) swab32(boot_type));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1949) bfa_mem_write(ioc->ioc_regs.smem_page_start, BFI_FWBOOT_ENV_OFF,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1950) swab32(boot_env));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1951) return BFA_STATUS_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1952) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1953)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1954)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1955) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1956) * Update BFA configuration from firmware configuration.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1957) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1958) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1959) bfa_ioc_getattr_reply(struct bfa_ioc_s *ioc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1960) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1961) struct bfi_ioc_attr_s *attr = ioc->attr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1962)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1963) attr->adapter_prop = be32_to_cpu(attr->adapter_prop);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1964) attr->card_type = be32_to_cpu(attr->card_type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1965) attr->maxfrsize = be16_to_cpu(attr->maxfrsize);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1966) ioc->fcmode = (attr->port_mode == BFI_PORT_MODE_FC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1967) attr->mfg_year = be16_to_cpu(attr->mfg_year);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1968)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1969) bfa_fsm_send_event(ioc, IOC_E_FWRSP_GETATTR);
^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) * Attach time initialization of mbox logic.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1974) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1975) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1976) bfa_ioc_mbox_attach(struct bfa_ioc_s *ioc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1977) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1978) struct bfa_ioc_mbox_mod_s *mod = &ioc->mbox_mod;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1979) int mc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1980)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1981) INIT_LIST_HEAD(&mod->cmd_q);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1982) for (mc = 0; mc < BFI_MC_MAX; mc++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1983) mod->mbhdlr[mc].cbfn = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1984) mod->mbhdlr[mc].cbarg = ioc->bfa;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1985) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1986) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1987)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1988) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1989) * Mbox poll timer -- restarts any pending mailbox requests.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1990) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1991) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1992) bfa_ioc_mbox_poll(struct bfa_ioc_s *ioc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1993) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1994) struct bfa_ioc_mbox_mod_s *mod = &ioc->mbox_mod;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1995) struct bfa_mbox_cmd_s *cmd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1996) u32 stat;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1997)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1998) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1999) * If no command pending, do nothing
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2000) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2001) if (list_empty(&mod->cmd_q))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2002) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2003)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2004) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2005) * If previous command is not yet fetched by firmware, do nothing
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2006) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2007) stat = readl(ioc->ioc_regs.hfn_mbox_cmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2008) if (stat)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2009) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2010)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2011) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2012) * Enqueue command to firmware.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2013) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2014) bfa_q_deq(&mod->cmd_q, &cmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2015) bfa_ioc_mbox_send(ioc, cmd->msg, sizeof(cmd->msg));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2016) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2017)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2018) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2019) * Cleanup any pending requests.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2020) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2021) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2022) bfa_ioc_mbox_flush(struct bfa_ioc_s *ioc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2023) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2024) struct bfa_ioc_mbox_mod_s *mod = &ioc->mbox_mod;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2025) struct bfa_mbox_cmd_s *cmd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2026)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2027) while (!list_empty(&mod->cmd_q))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2028) bfa_q_deq(&mod->cmd_q, &cmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2029) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2030)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2031) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2032) * Read data from SMEM to host through PCI memmap
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2033) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2034) * @param[in] ioc memory for IOC
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2035) * @param[in] tbuf app memory to store data from smem
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2036) * @param[in] soff smem offset
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2037) * @param[in] sz size of smem in bytes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2038) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2039) static bfa_status_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2040) bfa_ioc_smem_read(struct bfa_ioc_s *ioc, void *tbuf, u32 soff, u32 sz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2041) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2042) u32 pgnum, loff;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2043) __be32 r32;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2044) int i, len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2045) u32 *buf = tbuf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2046)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2047) pgnum = PSS_SMEM_PGNUM(ioc->ioc_regs.smem_pg0, soff);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2048) loff = PSS_SMEM_PGOFF(soff);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2049) bfa_trc(ioc, pgnum);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2050) bfa_trc(ioc, loff);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2051) bfa_trc(ioc, sz);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2052)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2053) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2054) * Hold semaphore to serialize pll init and fwtrc.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2055) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2056) if (BFA_FALSE == bfa_ioc_sem_get(ioc->ioc_regs.ioc_init_sem_reg)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2057) bfa_trc(ioc, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2058) return BFA_STATUS_FAILED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2059) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2060)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2061) writel(pgnum, ioc->ioc_regs.host_page_num_fn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2062)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2063) len = sz/sizeof(u32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2064) bfa_trc(ioc, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2065) for (i = 0; i < len; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2066) r32 = bfa_mem_read(ioc->ioc_regs.smem_page_start, loff);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2067) buf[i] = swab32(r32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2068) loff += sizeof(u32);
^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) * handle page offset wrap around
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2072) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2073) loff = PSS_SMEM_PGOFF(loff);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2074) if (loff == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2075) pgnum++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2076) writel(pgnum, ioc->ioc_regs.host_page_num_fn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2077) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2078) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2079) writel(PSS_SMEM_PGNUM(ioc->ioc_regs.smem_pg0, 0),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2080) ioc->ioc_regs.host_page_num_fn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2081) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2082) * release semaphore.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2083) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2084) readl(ioc->ioc_regs.ioc_init_sem_reg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2085) writel(1, ioc->ioc_regs.ioc_init_sem_reg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2086)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2087) bfa_trc(ioc, pgnum);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2088) return BFA_STATUS_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2089) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2090)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2091) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2092) * Clear SMEM data from host through PCI memmap
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2093) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2094) * @param[in] ioc memory for IOC
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2095) * @param[in] soff smem offset
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2096) * @param[in] sz size of smem in bytes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2097) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2098) static bfa_status_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2099) bfa_ioc_smem_clr(struct bfa_ioc_s *ioc, u32 soff, u32 sz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2100) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2101) int i, len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2102) u32 pgnum, loff;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2103)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2104) pgnum = PSS_SMEM_PGNUM(ioc->ioc_regs.smem_pg0, soff);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2105) loff = PSS_SMEM_PGOFF(soff);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2106) bfa_trc(ioc, pgnum);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2107) bfa_trc(ioc, loff);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2108) bfa_trc(ioc, sz);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2109)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2110) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2111) * Hold semaphore to serialize pll init and fwtrc.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2112) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2113) if (BFA_FALSE == bfa_ioc_sem_get(ioc->ioc_regs.ioc_init_sem_reg)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2114) bfa_trc(ioc, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2115) return BFA_STATUS_FAILED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2116) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2117)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2118) writel(pgnum, ioc->ioc_regs.host_page_num_fn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2119)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2120) len = sz/sizeof(u32); /* len in words */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2121) bfa_trc(ioc, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2122) for (i = 0; i < len; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2123) bfa_mem_write(ioc->ioc_regs.smem_page_start, loff, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2124) loff += sizeof(u32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2125)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2126) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2127) * handle page offset wrap around
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2128) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2129) loff = PSS_SMEM_PGOFF(loff);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2130) if (loff == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2131) pgnum++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2132) writel(pgnum, ioc->ioc_regs.host_page_num_fn);
^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) writel(PSS_SMEM_PGNUM(ioc->ioc_regs.smem_pg0, 0),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2136) ioc->ioc_regs.host_page_num_fn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2137)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2138) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2139) * release semaphore.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2140) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2141) readl(ioc->ioc_regs.ioc_init_sem_reg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2142) writel(1, ioc->ioc_regs.ioc_init_sem_reg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2143) bfa_trc(ioc, pgnum);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2144) return BFA_STATUS_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2145) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2146)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2147) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2148) bfa_ioc_fail_notify(struct bfa_ioc_s *ioc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2149) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2150) struct bfad_s *bfad = (struct bfad_s *)ioc->bfa->bfad;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2151)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2152) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2153) * Notify driver and common modules registered for notification.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2154) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2155) ioc->cbfn->hbfail_cbfn(ioc->bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2156) bfa_ioc_event_notify(ioc, BFA_IOC_E_FAILED);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2157)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2158) bfa_ioc_debug_save_ftrc(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2159)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2160) BFA_LOG(KERN_CRIT, bfad, bfa_log_level,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2161) "Heart Beat of IOC has failed\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2162) bfa_ioc_aen_post(ioc, BFA_IOC_AEN_HBFAIL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2163)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2164) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2165)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2166) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2167) bfa_ioc_pf_fwmismatch(struct bfa_ioc_s *ioc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2168) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2169) struct bfad_s *bfad = (struct bfad_s *)ioc->bfa->bfad;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2170) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2171) * Provide enable completion callback.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2172) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2173) ioc->cbfn->enable_cbfn(ioc->bfa, BFA_STATUS_IOC_FAILURE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2174) BFA_LOG(KERN_WARNING, bfad, bfa_log_level,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2175) "Running firmware version is incompatible "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2176) "with the driver version\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2177) bfa_ioc_aen_post(ioc, BFA_IOC_AEN_FWMISMATCH);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2178) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2179)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2180) bfa_status_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2181) bfa_ioc_pll_init(struct bfa_ioc_s *ioc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2182) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2183)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2184) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2185) * Hold semaphore so that nobody can access the chip during init.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2186) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2187) bfa_ioc_sem_get(ioc->ioc_regs.ioc_init_sem_reg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2188)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2189) bfa_ioc_pll_init_asic(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2190)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2191) ioc->pllinit = BFA_TRUE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2192)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2193) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2194) * Initialize LMEM
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2195) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2196) bfa_ioc_lmem_init(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2197)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2198) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2199) * release semaphore.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2200) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2201) readl(ioc->ioc_regs.ioc_init_sem_reg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2202) writel(1, ioc->ioc_regs.ioc_init_sem_reg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2203)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2204) return BFA_STATUS_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2205) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2206)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2207) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2208) * Interface used by diag module to do firmware boot with memory test
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2209) * as the entry vector.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2210) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2211) bfa_status_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2212) bfa_ioc_boot(struct bfa_ioc_s *ioc, u32 boot_type, u32 boot_env)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2213) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2214) struct bfi_ioc_image_hdr_s *drv_fwhdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2215) bfa_status_t status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2216) bfa_ioc_stats(ioc, ioc_boots);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2217)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2218) if (bfa_ioc_pll_init(ioc) != BFA_STATUS_OK)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2219) return BFA_STATUS_FAILED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2220)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2221) if (boot_env == BFI_FWBOOT_ENV_OS &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2222) boot_type == BFI_FWBOOT_TYPE_NORMAL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2223)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2224) drv_fwhdr = (struct bfi_ioc_image_hdr_s *)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2225) bfa_cb_image_get_chunk(bfa_ioc_asic_gen(ioc), 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2226)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2227) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2228) * Work with Flash iff flash f/w is better than driver f/w.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2229) * Otherwise push drivers firmware.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2230) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2231) if (bfa_ioc_flash_fwver_cmp(ioc, drv_fwhdr) ==
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2232) BFI_IOC_IMG_VER_BETTER)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2233) boot_type = BFI_FWBOOT_TYPE_FLASH;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2234) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2235)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2236) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2237) * Initialize IOC state of all functions on a chip reset.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2238) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2239) if (boot_type == BFI_FWBOOT_TYPE_MEMTEST) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2240) bfa_ioc_set_cur_ioc_fwstate(ioc, BFI_IOC_MEMTEST);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2241) bfa_ioc_set_alt_ioc_fwstate(ioc, BFI_IOC_MEMTEST);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2242) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2243) bfa_ioc_set_cur_ioc_fwstate(ioc, BFI_IOC_INITING);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2244) bfa_ioc_set_alt_ioc_fwstate(ioc, BFI_IOC_INITING);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2245) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2246)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2247) bfa_ioc_msgflush(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2248) status = bfa_ioc_download_fw(ioc, boot_type, boot_env);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2249) if (status == BFA_STATUS_OK)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2250) bfa_ioc_lpu_start(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2251) else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2252) WARN_ON(boot_type == BFI_FWBOOT_TYPE_MEMTEST);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2253) bfa_iocpf_timeout(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2254) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2255) return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2256) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2257)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2258) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2259) * Enable/disable IOC failure auto recovery.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2260) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2261) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2262) bfa_ioc_auto_recover(bfa_boolean_t auto_recover)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2263) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2264) bfa_auto_recover = auto_recover;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2265) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2266)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2267)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2268)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2269) bfa_boolean_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2270) bfa_ioc_is_operational(struct bfa_ioc_s *ioc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2271) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2272) return bfa_fsm_cmp_state(ioc, bfa_ioc_sm_op);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2273) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2274)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2275) bfa_boolean_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2276) bfa_ioc_is_initialized(struct bfa_ioc_s *ioc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2277) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2278) u32 r32 = bfa_ioc_get_cur_ioc_fwstate(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2279)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2280) return ((r32 != BFI_IOC_UNINIT) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2281) (r32 != BFI_IOC_INITING) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2282) (r32 != BFI_IOC_MEMTEST));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2283) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2284)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2285) bfa_boolean_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2286) bfa_ioc_msgget(struct bfa_ioc_s *ioc, void *mbmsg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2287) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2288) __be32 *msgp = mbmsg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2289) u32 r32;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2290) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2291)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2292) r32 = readl(ioc->ioc_regs.lpu_mbox_cmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2293) if ((r32 & 1) == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2294) return BFA_FALSE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2295)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2296) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2297) * read the MBOX msg
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2298) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2299) for (i = 0; i < (sizeof(union bfi_ioc_i2h_msg_u) / sizeof(u32));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2300) i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2301) r32 = readl(ioc->ioc_regs.lpu_mbox +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2302) i * sizeof(u32));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2303) msgp[i] = cpu_to_be32(r32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2304) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2305)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2306) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2307) * turn off mailbox interrupt by clearing mailbox status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2308) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2309) writel(1, ioc->ioc_regs.lpu_mbox_cmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2310) readl(ioc->ioc_regs.lpu_mbox_cmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2311)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2312) return BFA_TRUE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2313) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2314)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2315) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2316) bfa_ioc_isr(struct bfa_ioc_s *ioc, struct bfi_mbmsg_s *m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2317) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2318) union bfi_ioc_i2h_msg_u *msg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2319) struct bfa_iocpf_s *iocpf = &ioc->iocpf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2320)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2321) msg = (union bfi_ioc_i2h_msg_u *) m;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2322)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2323) bfa_ioc_stats(ioc, ioc_isrs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2324)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2325) switch (msg->mh.msg_id) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2326) case BFI_IOC_I2H_HBEAT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2327) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2328)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2329) case BFI_IOC_I2H_ENABLE_REPLY:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2330) ioc->port_mode = ioc->port_mode_cfg =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2331) (enum bfa_mode_s)msg->fw_event.port_mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2332) ioc->ad_cap_bm = msg->fw_event.cap_bm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2333) bfa_fsm_send_event(iocpf, IOCPF_E_FWRSP_ENABLE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2334) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2335)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2336) case BFI_IOC_I2H_DISABLE_REPLY:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2337) bfa_fsm_send_event(iocpf, IOCPF_E_FWRSP_DISABLE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2338) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2339)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2340) case BFI_IOC_I2H_GETATTR_REPLY:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2341) bfa_ioc_getattr_reply(ioc);
^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) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2345) bfa_trc(ioc, msg->mh.msg_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2346) WARN_ON(1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2347) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2348) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2349)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2350) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2351) * IOC attach time initialization and setup.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2352) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2353) * @param[in] ioc memory for IOC
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2354) * @param[in] bfa driver instance structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2355) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2356) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2357) bfa_ioc_attach(struct bfa_ioc_s *ioc, void *bfa, struct bfa_ioc_cbfn_s *cbfn,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2358) struct bfa_timer_mod_s *timer_mod)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2359) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2360) ioc->bfa = bfa;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2361) ioc->cbfn = cbfn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2362) ioc->timer_mod = timer_mod;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2363) ioc->fcmode = BFA_FALSE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2364) ioc->pllinit = BFA_FALSE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2365) ioc->dbg_fwsave_once = BFA_TRUE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2366) ioc->iocpf.ioc = ioc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2367)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2368) bfa_ioc_mbox_attach(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2369) INIT_LIST_HEAD(&ioc->notify_q);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2370)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2371) bfa_fsm_set_state(ioc, bfa_ioc_sm_uninit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2372) bfa_fsm_send_event(ioc, IOC_E_RESET);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2373) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2374)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2375) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2376) * Driver detach time IOC cleanup.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2377) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2378) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2379) bfa_ioc_detach(struct bfa_ioc_s *ioc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2380) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2381) bfa_fsm_send_event(ioc, IOC_E_DETACH);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2382) INIT_LIST_HEAD(&ioc->notify_q);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2383) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2384)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2385) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2386) * Setup IOC PCI properties.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2387) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2388) * @param[in] pcidev PCI device information for this IOC
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2389) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2390) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2391) bfa_ioc_pci_init(struct bfa_ioc_s *ioc, struct bfa_pcidev_s *pcidev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2392) enum bfi_pcifn_class clscode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2393) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2394) ioc->clscode = clscode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2395) ioc->pcidev = *pcidev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2396)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2397) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2398) * Initialize IOC and device personality
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2399) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2400) ioc->port0_mode = ioc->port1_mode = BFI_PORT_MODE_FC;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2401) ioc->asic_mode = BFI_ASIC_MODE_FC;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2402)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2403) switch (pcidev->device_id) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2404) case BFA_PCI_DEVICE_ID_FC_8G1P:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2405) case BFA_PCI_DEVICE_ID_FC_8G2P:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2406) ioc->asic_gen = BFI_ASIC_GEN_CB;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2407) ioc->fcmode = BFA_TRUE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2408) ioc->port_mode = ioc->port_mode_cfg = BFA_MODE_HBA;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2409) ioc->ad_cap_bm = BFA_CM_HBA;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2410) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2411)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2412) case BFA_PCI_DEVICE_ID_CT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2413) ioc->asic_gen = BFI_ASIC_GEN_CT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2414) ioc->port0_mode = ioc->port1_mode = BFI_PORT_MODE_ETH;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2415) ioc->asic_mode = BFI_ASIC_MODE_ETH;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2416) ioc->port_mode = ioc->port_mode_cfg = BFA_MODE_CNA;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2417) ioc->ad_cap_bm = BFA_CM_CNA;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2418) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2419)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2420) case BFA_PCI_DEVICE_ID_CT_FC:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2421) ioc->asic_gen = BFI_ASIC_GEN_CT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2422) ioc->fcmode = BFA_TRUE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2423) ioc->port_mode = ioc->port_mode_cfg = BFA_MODE_HBA;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2424) ioc->ad_cap_bm = BFA_CM_HBA;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2425) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2426)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2427) case BFA_PCI_DEVICE_ID_CT2:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2428) case BFA_PCI_DEVICE_ID_CT2_QUAD:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2429) ioc->asic_gen = BFI_ASIC_GEN_CT2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2430) if (clscode == BFI_PCIFN_CLASS_FC &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2431) pcidev->ssid == BFA_PCI_CT2_SSID_FC) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2432) ioc->asic_mode = BFI_ASIC_MODE_FC16;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2433) ioc->fcmode = BFA_TRUE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2434) ioc->port_mode = ioc->port_mode_cfg = BFA_MODE_HBA;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2435) ioc->ad_cap_bm = BFA_CM_HBA;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2436) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2437) ioc->port0_mode = ioc->port1_mode = BFI_PORT_MODE_ETH;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2438) ioc->asic_mode = BFI_ASIC_MODE_ETH;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2439) if (pcidev->ssid == BFA_PCI_CT2_SSID_FCoE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2440) ioc->port_mode =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2441) ioc->port_mode_cfg = BFA_MODE_CNA;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2442) ioc->ad_cap_bm = BFA_CM_CNA;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2443) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2444) ioc->port_mode =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2445) ioc->port_mode_cfg = BFA_MODE_NIC;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2446) ioc->ad_cap_bm = BFA_CM_NIC;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2447) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2448) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2449) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2450)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2451) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2452) WARN_ON(1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2453) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2454)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2455) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2456) * Set asic specific interfaces. See bfa_ioc_cb.c and bfa_ioc_ct.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2457) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2458) if (ioc->asic_gen == BFI_ASIC_GEN_CB)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2459) bfa_ioc_set_cb_hwif(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2460) else if (ioc->asic_gen == BFI_ASIC_GEN_CT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2461) bfa_ioc_set_ct_hwif(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2462) else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2463) WARN_ON(ioc->asic_gen != BFI_ASIC_GEN_CT2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2464) bfa_ioc_set_ct2_hwif(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2465) bfa_ioc_ct2_poweron(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2466) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2467)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2468) bfa_ioc_map_port(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2469) bfa_ioc_reg_init(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2470) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2471)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2472) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2473) * Initialize IOC dma memory
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2474) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2475) * @param[in] dm_kva kernel virtual address of IOC dma memory
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2476) * @param[in] dm_pa physical address of IOC dma memory
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2477) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2478) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2479) bfa_ioc_mem_claim(struct bfa_ioc_s *ioc, u8 *dm_kva, u64 dm_pa)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2480) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2481) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2482) * dma memory for firmware attribute
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2483) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2484) ioc->attr_dma.kva = dm_kva;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2485) ioc->attr_dma.pa = dm_pa;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2486) ioc->attr = (struct bfi_ioc_attr_s *) dm_kva;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2487) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2488)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2489) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2490) bfa_ioc_enable(struct bfa_ioc_s *ioc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2491) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2492) bfa_ioc_stats(ioc, ioc_enables);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2493) ioc->dbg_fwsave_once = BFA_TRUE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2494)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2495) bfa_fsm_send_event(ioc, IOC_E_ENABLE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2496) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2497)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2498) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2499) bfa_ioc_disable(struct bfa_ioc_s *ioc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2500) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2501) bfa_ioc_stats(ioc, ioc_disables);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2502) bfa_fsm_send_event(ioc, IOC_E_DISABLE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2503) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2504)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2505) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2506) bfa_ioc_suspend(struct bfa_ioc_s *ioc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2507) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2508) ioc->dbg_fwsave_once = BFA_TRUE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2509) bfa_fsm_send_event(ioc, IOC_E_HWERROR);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2510) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2511)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2512) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2513) * Initialize memory for saving firmware trace. Driver must initialize
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2514) * trace memory before call bfa_ioc_enable().
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2515) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2516) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2517) bfa_ioc_debug_memclaim(struct bfa_ioc_s *ioc, void *dbg_fwsave)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2518) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2519) ioc->dbg_fwsave = dbg_fwsave;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2520) ioc->dbg_fwsave_len = BFA_DBG_FWTRC_LEN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2521) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2522)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2523) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2524) * Register mailbox message handler functions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2525) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2526) * @param[in] ioc IOC instance
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2527) * @param[in] mcfuncs message class handler functions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2528) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2529) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2530) bfa_ioc_mbox_register(struct bfa_ioc_s *ioc, bfa_ioc_mbox_mcfunc_t *mcfuncs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2531) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2532) struct bfa_ioc_mbox_mod_s *mod = &ioc->mbox_mod;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2533) int mc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2534)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2535) for (mc = 0; mc < BFI_MC_MAX; mc++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2536) mod->mbhdlr[mc].cbfn = mcfuncs[mc];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2537) }
^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) * Register mailbox message handler function, to be called by common modules
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2541) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2542) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2543) bfa_ioc_mbox_regisr(struct bfa_ioc_s *ioc, enum bfi_mclass mc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2544) bfa_ioc_mbox_mcfunc_t cbfn, void *cbarg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2545) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2546) struct bfa_ioc_mbox_mod_s *mod = &ioc->mbox_mod;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2547)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2548) mod->mbhdlr[mc].cbfn = cbfn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2549) mod->mbhdlr[mc].cbarg = cbarg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2550) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2551)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2552) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2553) * Queue a mailbox command request to firmware. Waits if mailbox is busy.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2554) * Responsibility of caller to serialize
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2555) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2556) * @param[in] ioc IOC instance
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2557) * @param[i] cmd Mailbox command
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2558) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2559) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2560) bfa_ioc_mbox_queue(struct bfa_ioc_s *ioc, struct bfa_mbox_cmd_s *cmd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2561) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2562) struct bfa_ioc_mbox_mod_s *mod = &ioc->mbox_mod;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2563) u32 stat;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2564)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2565) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2566) * If a previous command is pending, queue new command
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2567) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2568) if (!list_empty(&mod->cmd_q)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2569) list_add_tail(&cmd->qe, &mod->cmd_q);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2570) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2571) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2572)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2573) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2574) * If mailbox is busy, queue command for poll timer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2575) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2576) stat = readl(ioc->ioc_regs.hfn_mbox_cmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2577) if (stat) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2578) list_add_tail(&cmd->qe, &mod->cmd_q);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2579) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2580) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2581)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2582) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2583) * mailbox is free -- queue command to firmware
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2584) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2585) bfa_ioc_mbox_send(ioc, cmd->msg, sizeof(cmd->msg));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2586) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2587)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2588) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2589) * Handle mailbox interrupts
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2590) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2591) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2592) bfa_ioc_mbox_isr(struct bfa_ioc_s *ioc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2593) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2594) struct bfa_ioc_mbox_mod_s *mod = &ioc->mbox_mod;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2595) struct bfi_mbmsg_s m;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2596) int mc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2597)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2598) if (bfa_ioc_msgget(ioc, &m)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2599) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2600) * Treat IOC message class as special.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2601) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2602) mc = m.mh.msg_class;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2603) if (mc == BFI_MC_IOC) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2604) bfa_ioc_isr(ioc, &m);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2605) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2606) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2607)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2608) if ((mc >= BFI_MC_MAX) || (mod->mbhdlr[mc].cbfn == NULL))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2609) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2610)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2611) mod->mbhdlr[mc].cbfn(mod->mbhdlr[mc].cbarg, &m);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2612) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2613)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2614) bfa_ioc_lpu_read_stat(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2615)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2616) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2617) * Try to send pending mailbox commands
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2618) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2619) bfa_ioc_mbox_poll(ioc);
^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) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2623) bfa_ioc_error_isr(struct bfa_ioc_s *ioc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2624) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2625) bfa_ioc_stats(ioc, ioc_hbfails);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2626) ioc->stats.hb_count = ioc->hb_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2627) bfa_fsm_send_event(ioc, IOC_E_HWERROR);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2628) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2629)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2630) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2631) * return true if IOC is disabled
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2632) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2633) bfa_boolean_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2634) bfa_ioc_is_disabled(struct bfa_ioc_s *ioc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2635) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2636) return bfa_fsm_cmp_state(ioc, bfa_ioc_sm_disabling) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2637) bfa_fsm_cmp_state(ioc, bfa_ioc_sm_disabled);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2638) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2639)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2640) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2641) * return true if IOC firmware is different.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2642) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2643) bfa_boolean_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2644) bfa_ioc_fw_mismatch(struct bfa_ioc_s *ioc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2645) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2646) return bfa_fsm_cmp_state(ioc, bfa_ioc_sm_reset) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2647) bfa_fsm_cmp_state(&ioc->iocpf, bfa_iocpf_sm_fwcheck) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2648) bfa_fsm_cmp_state(&ioc->iocpf, bfa_iocpf_sm_mismatch);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2649) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2650)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2651) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2652) * Check if adapter is disabled -- both IOCs should be in a disabled
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2653) * state.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2654) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2655) bfa_boolean_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2656) bfa_ioc_adapter_is_disabled(struct bfa_ioc_s *ioc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2657) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2658) u32 ioc_state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2659)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2660) if (!bfa_fsm_cmp_state(ioc, bfa_ioc_sm_disabled))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2661) return BFA_FALSE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2662)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2663) ioc_state = bfa_ioc_get_cur_ioc_fwstate(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2664) if (!bfa_ioc_state_disabled(ioc_state))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2665) return BFA_FALSE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2666)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2667) if (ioc->pcidev.device_id != BFA_PCI_DEVICE_ID_FC_8G1P) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2668) ioc_state = bfa_ioc_get_cur_ioc_fwstate(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2669) if (!bfa_ioc_state_disabled(ioc_state))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2670) return BFA_FALSE;
^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) return BFA_TRUE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2674) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2675)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2676) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2677) * Reset IOC fwstate registers.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2678) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2679) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2680) bfa_ioc_reset_fwstate(struct bfa_ioc_s *ioc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2681) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2682) bfa_ioc_set_cur_ioc_fwstate(ioc, BFI_IOC_UNINIT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2683) bfa_ioc_set_alt_ioc_fwstate(ioc, BFI_IOC_UNINIT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2684) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2685)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2686) #define BFA_MFG_NAME "QLogic"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2687) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2688) bfa_ioc_get_adapter_attr(struct bfa_ioc_s *ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2689) struct bfa_adapter_attr_s *ad_attr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2690) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2691) struct bfi_ioc_attr_s *ioc_attr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2692)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2693) ioc_attr = ioc->attr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2694)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2695) bfa_ioc_get_adapter_serial_num(ioc, ad_attr->serial_num);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2696) bfa_ioc_get_adapter_fw_ver(ioc, ad_attr->fw_ver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2697) bfa_ioc_get_adapter_optrom_ver(ioc, ad_attr->optrom_ver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2698) bfa_ioc_get_adapter_manufacturer(ioc, ad_attr->manufacturer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2699) memcpy(&ad_attr->vpd, &ioc_attr->vpd,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2700) sizeof(struct bfa_mfg_vpd_s));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2701)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2702) ad_attr->nports = bfa_ioc_get_nports(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2703) ad_attr->max_speed = bfa_ioc_speed_sup(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2704)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2705) bfa_ioc_get_adapter_model(ioc, ad_attr->model);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2706) /* For now, model descr uses same model string */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2707) bfa_ioc_get_adapter_model(ioc, ad_attr->model_descr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2708)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2709) ad_attr->card_type = ioc_attr->card_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2710) ad_attr->is_mezz = bfa_mfg_is_mezz(ioc_attr->card_type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2711)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2712) if (BFI_ADAPTER_IS_SPECIAL(ioc_attr->adapter_prop))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2713) ad_attr->prototype = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2714) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2715) ad_attr->prototype = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2716)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2717) ad_attr->pwwn = ioc->attr->pwwn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2718) ad_attr->mac = bfa_ioc_get_mac(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2719)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2720) ad_attr->pcie_gen = ioc_attr->pcie_gen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2721) ad_attr->pcie_lanes = ioc_attr->pcie_lanes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2722) ad_attr->pcie_lanes_orig = ioc_attr->pcie_lanes_orig;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2723) ad_attr->asic_rev = ioc_attr->asic_rev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2724)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2725) bfa_ioc_get_pci_chip_rev(ioc, ad_attr->hw_ver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2726)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2727) ad_attr->cna_capable = bfa_ioc_is_cna(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2728) ad_attr->trunk_capable = (ad_attr->nports > 1) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2729) !bfa_ioc_is_cna(ioc) && !ad_attr->is_mezz;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2730) ad_attr->mfg_day = ioc_attr->mfg_day;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2731) ad_attr->mfg_month = ioc_attr->mfg_month;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2732) ad_attr->mfg_year = ioc_attr->mfg_year;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2733) memcpy(ad_attr->uuid, ioc_attr->uuid, BFA_ADAPTER_UUID_LEN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2734) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2735)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2736) enum bfa_ioc_type_e
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2737) bfa_ioc_get_type(struct bfa_ioc_s *ioc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2738) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2739) if (ioc->clscode == BFI_PCIFN_CLASS_ETH)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2740) return BFA_IOC_TYPE_LL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2741)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2742) WARN_ON(ioc->clscode != BFI_PCIFN_CLASS_FC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2743)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2744) return (ioc->attr->port_mode == BFI_PORT_MODE_FC)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2745) ? BFA_IOC_TYPE_FC : BFA_IOC_TYPE_FCoE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2746) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2747)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2748) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2749) bfa_ioc_get_adapter_serial_num(struct bfa_ioc_s *ioc, char *serial_num)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2750) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2751) memset((void *)serial_num, 0, BFA_ADAPTER_SERIAL_NUM_LEN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2752) memcpy((void *)serial_num,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2753) (void *)ioc->attr->brcd_serialnum,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2754) BFA_ADAPTER_SERIAL_NUM_LEN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2755) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2756)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2757) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2758) bfa_ioc_get_adapter_fw_ver(struct bfa_ioc_s *ioc, char *fw_ver)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2759) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2760) memset((void *)fw_ver, 0, BFA_VERSION_LEN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2761) memcpy(fw_ver, ioc->attr->fw_version, BFA_VERSION_LEN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2762) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2763)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2764) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2765) bfa_ioc_get_pci_chip_rev(struct bfa_ioc_s *ioc, char *chip_rev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2766) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2767) WARN_ON(!chip_rev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2768)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2769) memset((void *)chip_rev, 0, BFA_IOC_CHIP_REV_LEN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2770)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2771) chip_rev[0] = 'R';
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2772) chip_rev[1] = 'e';
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2773) chip_rev[2] = 'v';
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2774) chip_rev[3] = '-';
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2775) chip_rev[4] = ioc->attr->asic_rev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2776) chip_rev[5] = '\0';
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2777) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2778)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2779) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2780) bfa_ioc_get_adapter_optrom_ver(struct bfa_ioc_s *ioc, char *optrom_ver)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2781) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2782) memset((void *)optrom_ver, 0, BFA_VERSION_LEN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2783) memcpy(optrom_ver, ioc->attr->optrom_version,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2784) BFA_VERSION_LEN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2785) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2786)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2787) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2788) bfa_ioc_get_adapter_manufacturer(struct bfa_ioc_s *ioc, char *manufacturer)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2789) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2790) memset((void *)manufacturer, 0, BFA_ADAPTER_MFG_NAME_LEN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2791) strlcpy(manufacturer, BFA_MFG_NAME, BFA_ADAPTER_MFG_NAME_LEN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2792) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2793)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2794) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2795) bfa_ioc_get_adapter_model(struct bfa_ioc_s *ioc, char *model)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2796) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2797) struct bfi_ioc_attr_s *ioc_attr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2798) u8 nports = bfa_ioc_get_nports(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2799)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2800) WARN_ON(!model);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2801) memset((void *)model, 0, BFA_ADAPTER_MODEL_NAME_LEN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2802)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2803) ioc_attr = ioc->attr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2804)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2805) if (bfa_asic_id_ct2(ioc->pcidev.device_id) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2806) (!bfa_mfg_is_mezz(ioc_attr->card_type)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2807) snprintf(model, BFA_ADAPTER_MODEL_NAME_LEN, "%s-%u-%u%s",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2808) BFA_MFG_NAME, ioc_attr->card_type, nports, "p");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2809) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2810) snprintf(model, BFA_ADAPTER_MODEL_NAME_LEN, "%s-%u",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2811) BFA_MFG_NAME, ioc_attr->card_type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2812) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2813)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2814) enum bfa_ioc_state
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2815) bfa_ioc_get_state(struct bfa_ioc_s *ioc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2816) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2817) enum bfa_iocpf_state iocpf_st;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2818) enum bfa_ioc_state ioc_st = bfa_sm_to_state(ioc_sm_table, ioc->fsm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2819)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2820) if (ioc_st == BFA_IOC_ENABLING ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2821) ioc_st == BFA_IOC_FAIL || ioc_st == BFA_IOC_INITFAIL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2822)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2823) iocpf_st = bfa_sm_to_state(iocpf_sm_table, ioc->iocpf.fsm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2824)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2825) switch (iocpf_st) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2826) case BFA_IOCPF_SEMWAIT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2827) ioc_st = BFA_IOC_SEMWAIT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2828) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2829)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2830) case BFA_IOCPF_HWINIT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2831) ioc_st = BFA_IOC_HWINIT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2832) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2833)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2834) case BFA_IOCPF_FWMISMATCH:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2835) ioc_st = BFA_IOC_FWMISMATCH;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2836) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2837)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2838) case BFA_IOCPF_FAIL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2839) ioc_st = BFA_IOC_FAIL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2840) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2841)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2842) case BFA_IOCPF_INITFAIL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2843) ioc_st = BFA_IOC_INITFAIL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2844) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2845)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2846) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2847) break;
^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)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2851) return ioc_st;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2852) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2853)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2854) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2855) bfa_ioc_get_attr(struct bfa_ioc_s *ioc, struct bfa_ioc_attr_s *ioc_attr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2856) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2857) memset((void *)ioc_attr, 0, sizeof(struct bfa_ioc_attr_s));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2858)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2859) ioc_attr->state = bfa_ioc_get_state(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2860) ioc_attr->port_id = bfa_ioc_portid(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2861) ioc_attr->port_mode = ioc->port_mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2862) ioc_attr->port_mode_cfg = ioc->port_mode_cfg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2863) ioc_attr->cap_bm = ioc->ad_cap_bm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2864)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2865) ioc_attr->ioc_type = bfa_ioc_get_type(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2866)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2867) bfa_ioc_get_adapter_attr(ioc, &ioc_attr->adapter_attr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2868)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2869) ioc_attr->pci_attr.device_id = bfa_ioc_devid(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2870) ioc_attr->pci_attr.pcifn = bfa_ioc_pcifn(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2871) ioc_attr->def_fn = (bfa_ioc_pcifn(ioc) == bfa_ioc_portid(ioc));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2872) bfa_ioc_get_pci_chip_rev(ioc, ioc_attr->pci_attr.chip_rev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2873) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2874)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2875) mac_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2876) bfa_ioc_get_mac(struct bfa_ioc_s *ioc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2877) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2878) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2879) * Check the IOC type and return the appropriate MAC
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2880) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2881) if (bfa_ioc_get_type(ioc) == BFA_IOC_TYPE_FCoE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2882) return ioc->attr->fcoe_mac;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2883) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2884) return ioc->attr->mac;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2885) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2886)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2887) mac_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2888) bfa_ioc_get_mfg_mac(struct bfa_ioc_s *ioc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2889) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2890) mac_t m;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2891)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2892) m = ioc->attr->mfg_mac;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2893) if (bfa_mfg_is_old_wwn_mac_model(ioc->attr->card_type))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2894) m.mac[MAC_ADDRLEN - 1] += bfa_ioc_pcifn(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2895) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2896) bfa_mfg_increment_wwn_mac(&(m.mac[MAC_ADDRLEN-3]),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2897) bfa_ioc_pcifn(ioc));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2898)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2899) return m;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2900) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2901)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2902) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2903) * Send AEN notification
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2904) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2905) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2906) bfa_ioc_aen_post(struct bfa_ioc_s *ioc, enum bfa_ioc_aen_event event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2907) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2908) struct bfad_s *bfad = (struct bfad_s *)ioc->bfa->bfad;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2909) struct bfa_aen_entry_s *aen_entry;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2910) enum bfa_ioc_type_e ioc_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2911)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2912) bfad_get_aen_entry(bfad, aen_entry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2913) if (!aen_entry)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2914) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2915)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2916) ioc_type = bfa_ioc_get_type(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2917) switch (ioc_type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2918) case BFA_IOC_TYPE_FC:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2919) aen_entry->aen_data.ioc.pwwn = ioc->attr->pwwn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2920) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2921) case BFA_IOC_TYPE_FCoE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2922) aen_entry->aen_data.ioc.pwwn = ioc->attr->pwwn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2923) aen_entry->aen_data.ioc.mac = bfa_ioc_get_mac(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2924) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2925) case BFA_IOC_TYPE_LL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2926) aen_entry->aen_data.ioc.mac = bfa_ioc_get_mac(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2927) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2928) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2929) WARN_ON(ioc_type != BFA_IOC_TYPE_FC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2930) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2931) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2932)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2933) /* Send the AEN notification */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2934) aen_entry->aen_data.ioc.ioc_type = ioc_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2935) bfad_im_post_vendor_event(aen_entry, bfad, ++ioc->ioc_aen_seq,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2936) BFA_AEN_CAT_IOC, 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) * Retrieve saved firmware trace from a prior IOC failure.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2941) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2942) bfa_status_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2943) bfa_ioc_debug_fwsave(struct bfa_ioc_s *ioc, void *trcdata, int *trclen)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2944) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2945) int tlen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2946)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2947) if (ioc->dbg_fwsave_len == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2948) return BFA_STATUS_ENOFSAVE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2949)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2950) tlen = *trclen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2951) if (tlen > ioc->dbg_fwsave_len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2952) tlen = ioc->dbg_fwsave_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2953)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2954) memcpy(trcdata, ioc->dbg_fwsave, tlen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2955) *trclen = tlen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2956) return BFA_STATUS_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2957) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2958)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2959)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2960) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2961) * Retrieve saved firmware trace from a prior IOC failure.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2962) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2963) bfa_status_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2964) bfa_ioc_debug_fwtrc(struct bfa_ioc_s *ioc, void *trcdata, int *trclen)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2965) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2966) u32 loff = BFA_DBG_FWTRC_OFF(bfa_ioc_portid(ioc));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2967) int tlen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2968) bfa_status_t status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2969)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2970) bfa_trc(ioc, *trclen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2971)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2972) tlen = *trclen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2973) if (tlen > BFA_DBG_FWTRC_LEN)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2974) tlen = BFA_DBG_FWTRC_LEN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2975)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2976) status = bfa_ioc_smem_read(ioc, trcdata, loff, tlen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2977) *trclen = tlen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2978) return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2979) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2980)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2981) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2982) bfa_ioc_send_fwsync(struct bfa_ioc_s *ioc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2983) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2984) struct bfa_mbox_cmd_s cmd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2985) struct bfi_ioc_ctrl_req_s *req = (struct bfi_ioc_ctrl_req_s *) cmd.msg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2986)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2987) bfi_h2i_set(req->mh, BFI_MC_IOC, BFI_IOC_H2I_DBG_SYNC,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2988) bfa_ioc_portid(ioc));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2989) req->clscode = cpu_to_be16(ioc->clscode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2990) bfa_ioc_mbox_queue(ioc, &cmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2991) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2992)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2993) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2994) bfa_ioc_fwsync(struct bfa_ioc_s *ioc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2995) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2996) u32 fwsync_iter = 1000;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2997)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2998) bfa_ioc_send_fwsync(ioc);
^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) * After sending a fw sync mbox command wait for it to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3002) * take effect. We will not wait for a response because
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3003) * 1. fw_sync mbox cmd doesn't have a response.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3004) * 2. Even if we implement that, interrupts might not
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3005) * be enabled when we call this function.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3006) * So, just keep checking if any mbox cmd is pending, and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3007) * after waiting for a reasonable amount of time, go ahead.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3008) * It is possible that fw has crashed and the mbox command
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3009) * is never acknowledged.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3010) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3011) while (bfa_ioc_mbox_cmd_pending(ioc) && fwsync_iter > 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3012) fwsync_iter--;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3013) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3014)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3015) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3016) * Dump firmware smem
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3017) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3018) bfa_status_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3019) bfa_ioc_debug_fwcore(struct bfa_ioc_s *ioc, void *buf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3020) u32 *offset, int *buflen)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3021) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3022) u32 loff;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3023) int dlen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3024) bfa_status_t status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3025) u32 smem_len = BFA_IOC_FW_SMEM_SIZE(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3026)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3027) if (*offset >= smem_len) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3028) *offset = *buflen = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3029) return BFA_STATUS_EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3030) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3031)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3032) loff = *offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3033) dlen = *buflen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3034)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3035) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3036) * First smem read, sync smem before proceeding
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3037) * No need to sync before reading every chunk.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3038) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3039) if (loff == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3040) bfa_ioc_fwsync(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3041)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3042) if ((loff + dlen) >= smem_len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3043) dlen = smem_len - loff;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3044)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3045) status = bfa_ioc_smem_read(ioc, buf, loff, dlen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3046)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3047) if (status != BFA_STATUS_OK) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3048) *offset = *buflen = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3049) return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3050) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3051)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3052) *offset += dlen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3053)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3054) if (*offset >= smem_len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3055) *offset = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3056)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3057) *buflen = dlen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3058)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3059) return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3060) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3061)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3062) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3063) * Firmware statistics
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3064) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3065) bfa_status_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3066) bfa_ioc_fw_stats_get(struct bfa_ioc_s *ioc, void *stats)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3067) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3068) u32 loff = BFI_IOC_FWSTATS_OFF + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3069) BFI_IOC_FWSTATS_SZ * (bfa_ioc_portid(ioc));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3070) int tlen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3071) bfa_status_t status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3072)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3073) if (ioc->stats_busy) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3074) bfa_trc(ioc, ioc->stats_busy);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3075) return BFA_STATUS_DEVBUSY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3076) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3077) ioc->stats_busy = BFA_TRUE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3078)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3079) tlen = sizeof(struct bfa_fw_stats_s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3080) status = bfa_ioc_smem_read(ioc, stats, loff, tlen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3081)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3082) ioc->stats_busy = BFA_FALSE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3083) return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3084) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3085)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3086) bfa_status_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3087) bfa_ioc_fw_stats_clear(struct bfa_ioc_s *ioc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3088) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3089) u32 loff = BFI_IOC_FWSTATS_OFF + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3090) BFI_IOC_FWSTATS_SZ * (bfa_ioc_portid(ioc));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3091) int tlen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3092) bfa_status_t status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3093)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3094) if (ioc->stats_busy) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3095) bfa_trc(ioc, ioc->stats_busy);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3096) return BFA_STATUS_DEVBUSY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3097) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3098) ioc->stats_busy = BFA_TRUE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3099)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3100) tlen = sizeof(struct bfa_fw_stats_s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3101) status = bfa_ioc_smem_clr(ioc, loff, tlen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3102)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3103) ioc->stats_busy = BFA_FALSE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3104) return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3105) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3106)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3107) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3108) * Save firmware trace if configured.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3109) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3110) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3111) bfa_ioc_debug_save_ftrc(struct bfa_ioc_s *ioc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3112) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3113) int tlen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3114)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3115) if (ioc->dbg_fwsave_once) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3116) ioc->dbg_fwsave_once = BFA_FALSE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3117) if (ioc->dbg_fwsave_len) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3118) tlen = ioc->dbg_fwsave_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3119) bfa_ioc_debug_fwtrc(ioc, ioc->dbg_fwsave, &tlen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3120) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3121) }
^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) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3125) * Firmware failure detected. Start recovery actions.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3126) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3127) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3128) bfa_ioc_recover(struct bfa_ioc_s *ioc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3129) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3130) bfa_ioc_stats(ioc, ioc_hbfails);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3131) ioc->stats.hb_count = ioc->hb_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3132) bfa_fsm_send_event(ioc, IOC_E_HBFAIL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3133) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3134)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3135) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3136) * BFA IOC PF private functions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3137) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3138) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3139) bfa_iocpf_timeout(void *ioc_arg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3140) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3141) struct bfa_ioc_s *ioc = (struct bfa_ioc_s *) ioc_arg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3142)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3143) bfa_trc(ioc, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3144) bfa_fsm_send_event(&ioc->iocpf, IOCPF_E_TIMEOUT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3145) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3146)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3147) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3148) bfa_iocpf_sem_timeout(void *ioc_arg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3149) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3150) struct bfa_ioc_s *ioc = (struct bfa_ioc_s *) ioc_arg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3151)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3152) bfa_ioc_hw_sem_get(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3153) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3154)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3155) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3156) bfa_ioc_poll_fwinit(struct bfa_ioc_s *ioc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3157) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3158) u32 fwstate = bfa_ioc_get_cur_ioc_fwstate(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3159)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3160) bfa_trc(ioc, fwstate);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3161)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3162) if (fwstate == BFI_IOC_DISABLED) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3163) bfa_fsm_send_event(&ioc->iocpf, IOCPF_E_FWREADY);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3164) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3165) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3166)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3167) if (ioc->iocpf.poll_time >= (3 * BFA_IOC_TOV))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3168) bfa_iocpf_timeout(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3169) else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3170) ioc->iocpf.poll_time += BFA_IOC_POLL_TOV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3171) bfa_iocpf_poll_timer_start(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3172) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3173) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3174)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3175) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3176) bfa_iocpf_poll_timeout(void *ioc_arg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3177) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3178) struct bfa_ioc_s *ioc = (struct bfa_ioc_s *) ioc_arg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3179)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3180) bfa_ioc_poll_fwinit(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3181) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3182)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3183) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3184) * bfa timer function
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3185) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3186) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3187) bfa_timer_beat(struct bfa_timer_mod_s *mod)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3188) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3189) struct list_head *qh = &mod->timer_q;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3190) struct list_head *qe, *qe_next;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3191) struct bfa_timer_s *elem;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3192) struct list_head timedout_q;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3193)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3194) INIT_LIST_HEAD(&timedout_q);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3195)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3196) qe = bfa_q_next(qh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3197)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3198) while (qe != qh) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3199) qe_next = bfa_q_next(qe);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3200)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3201) elem = (struct bfa_timer_s *) qe;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3202) if (elem->timeout <= BFA_TIMER_FREQ) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3203) elem->timeout = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3204) list_del(&elem->qe);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3205) list_add_tail(&elem->qe, &timedout_q);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3206) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3207) elem->timeout -= BFA_TIMER_FREQ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3208) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3209)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3210) qe = qe_next; /* go to next elem */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3211) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3212)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3213) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3214) * Pop all the timeout entries
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3215) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3216) while (!list_empty(&timedout_q)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3217) bfa_q_deq(&timedout_q, &elem);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3218) elem->timercb(elem->arg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3219) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3220) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3221)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3222) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3223) * Should be called with lock protection
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3224) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3225) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3226) bfa_timer_begin(struct bfa_timer_mod_s *mod, struct bfa_timer_s *timer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3227) void (*timercb) (void *), void *arg, unsigned int timeout)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3228) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3229)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3230) WARN_ON(timercb == NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3231) WARN_ON(bfa_q_is_on_q(&mod->timer_q, timer));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3232)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3233) timer->timeout = timeout;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3234) timer->timercb = timercb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3235) timer->arg = arg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3236)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3237) list_add_tail(&timer->qe, &mod->timer_q);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3238) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3239)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3240) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3241) * Should be called with lock protection
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3242) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3243) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3244) bfa_timer_stop(struct bfa_timer_s *timer)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3245) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3246) WARN_ON(list_empty(&timer->qe));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3247)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3248) list_del(&timer->qe);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3249) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3250)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3251) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3252) * ASIC block related
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3253) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3254) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3255) bfa_ablk_config_swap(struct bfa_ablk_cfg_s *cfg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3256) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3257) struct bfa_ablk_cfg_inst_s *cfg_inst;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3258) int i, j;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3259) u16 be16;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3260)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3261) for (i = 0; i < BFA_ABLK_MAX; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3262) cfg_inst = &cfg->inst[i];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3263) for (j = 0; j < BFA_ABLK_MAX_PFS; j++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3264) be16 = cfg_inst->pf_cfg[j].pers;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3265) cfg_inst->pf_cfg[j].pers = be16_to_cpu(be16);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3266) be16 = cfg_inst->pf_cfg[j].num_qpairs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3267) cfg_inst->pf_cfg[j].num_qpairs = be16_to_cpu(be16);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3268) be16 = cfg_inst->pf_cfg[j].num_vectors;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3269) cfg_inst->pf_cfg[j].num_vectors = be16_to_cpu(be16);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3270) be16 = cfg_inst->pf_cfg[j].bw_min;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3271) cfg_inst->pf_cfg[j].bw_min = be16_to_cpu(be16);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3272) be16 = cfg_inst->pf_cfg[j].bw_max;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3273) cfg_inst->pf_cfg[j].bw_max = be16_to_cpu(be16);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3274) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3275) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3276) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3277)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3278) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3279) bfa_ablk_isr(void *cbarg, struct bfi_mbmsg_s *msg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3280) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3281) struct bfa_ablk_s *ablk = (struct bfa_ablk_s *)cbarg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3282) struct bfi_ablk_i2h_rsp_s *rsp = (struct bfi_ablk_i2h_rsp_s *)msg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3283) bfa_ablk_cbfn_t cbfn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3284)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3285) WARN_ON(msg->mh.msg_class != BFI_MC_ABLK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3286) bfa_trc(ablk->ioc, msg->mh.msg_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3287)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3288) switch (msg->mh.msg_id) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3289) case BFI_ABLK_I2H_QUERY:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3290) if (rsp->status == BFA_STATUS_OK) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3291) memcpy(ablk->cfg, ablk->dma_addr.kva,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3292) sizeof(struct bfa_ablk_cfg_s));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3293) bfa_ablk_config_swap(ablk->cfg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3294) ablk->cfg = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3295) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3296) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3297)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3298) case BFI_ABLK_I2H_ADPT_CONFIG:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3299) case BFI_ABLK_I2H_PORT_CONFIG:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3300) /* update config port mode */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3301) ablk->ioc->port_mode_cfg = rsp->port_mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3302)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3303) case BFI_ABLK_I2H_PF_DELETE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3304) case BFI_ABLK_I2H_PF_UPDATE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3305) case BFI_ABLK_I2H_OPTROM_ENABLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3306) case BFI_ABLK_I2H_OPTROM_DISABLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3307) /* No-op */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3308) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3309)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3310) case BFI_ABLK_I2H_PF_CREATE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3311) *(ablk->pcifn) = rsp->pcifn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3312) ablk->pcifn = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3313) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3314)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3315) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3316) WARN_ON(1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3317) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3318)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3319) ablk->busy = BFA_FALSE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3320) if (ablk->cbfn) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3321) cbfn = ablk->cbfn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3322) ablk->cbfn = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3323) cbfn(ablk->cbarg, rsp->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3324) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3325) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3326)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3327) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3328) bfa_ablk_notify(void *cbarg, enum bfa_ioc_event_e event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3329) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3330) struct bfa_ablk_s *ablk = (struct bfa_ablk_s *)cbarg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3331)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3332) bfa_trc(ablk->ioc, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3333)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3334) switch (event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3335) case BFA_IOC_E_ENABLED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3336) WARN_ON(ablk->busy != BFA_FALSE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3337) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3338)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3339) case BFA_IOC_E_DISABLED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3340) case BFA_IOC_E_FAILED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3341) /* Fail any pending requests */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3342) ablk->pcifn = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3343) if (ablk->busy) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3344) if (ablk->cbfn)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3345) ablk->cbfn(ablk->cbarg, BFA_STATUS_FAILED);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3346) ablk->cbfn = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3347) ablk->busy = BFA_FALSE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3348) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3349) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3350)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3351) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3352) WARN_ON(1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3353) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3354) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3355) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3356)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3357) u32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3358) bfa_ablk_meminfo(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3359) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3360) return BFA_ROUNDUP(sizeof(struct bfa_ablk_cfg_s), BFA_DMA_ALIGN_SZ);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3361) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3362)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3363) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3364) bfa_ablk_memclaim(struct bfa_ablk_s *ablk, u8 *dma_kva, u64 dma_pa)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3365) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3366) ablk->dma_addr.kva = dma_kva;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3367) ablk->dma_addr.pa = dma_pa;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3368) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3369)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3370) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3371) bfa_ablk_attach(struct bfa_ablk_s *ablk, struct bfa_ioc_s *ioc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3372) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3373) ablk->ioc = ioc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3374)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3375) bfa_ioc_mbox_regisr(ablk->ioc, BFI_MC_ABLK, bfa_ablk_isr, ablk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3376) bfa_q_qe_init(&ablk->ioc_notify);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3377) bfa_ioc_notify_init(&ablk->ioc_notify, bfa_ablk_notify, ablk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3378) list_add_tail(&ablk->ioc_notify.qe, &ablk->ioc->notify_q);
^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) bfa_status_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3382) bfa_ablk_query(struct bfa_ablk_s *ablk, struct bfa_ablk_cfg_s *ablk_cfg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3383) bfa_ablk_cbfn_t cbfn, void *cbarg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3384) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3385) struct bfi_ablk_h2i_query_s *m;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3386)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3387) WARN_ON(!ablk_cfg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3388)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3389) if (!bfa_ioc_is_operational(ablk->ioc)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3390) bfa_trc(ablk->ioc, BFA_STATUS_IOC_FAILURE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3391) return BFA_STATUS_IOC_FAILURE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3392) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3393)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3394) if (ablk->busy) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3395) bfa_trc(ablk->ioc, BFA_STATUS_DEVBUSY);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3396) return BFA_STATUS_DEVBUSY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3397) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3398)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3399) ablk->cfg = ablk_cfg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3400) ablk->cbfn = cbfn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3401) ablk->cbarg = cbarg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3402) ablk->busy = BFA_TRUE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3403)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3404) m = (struct bfi_ablk_h2i_query_s *)ablk->mb.msg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3405) bfi_h2i_set(m->mh, BFI_MC_ABLK, BFI_ABLK_H2I_QUERY,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3406) bfa_ioc_portid(ablk->ioc));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3407) bfa_dma_be_addr_set(m->addr, ablk->dma_addr.pa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3408) bfa_ioc_mbox_queue(ablk->ioc, &ablk->mb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3409)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3410) return BFA_STATUS_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3411) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3412)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3413) bfa_status_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3414) bfa_ablk_pf_create(struct bfa_ablk_s *ablk, u16 *pcifn,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3415) u8 port, enum bfi_pcifn_class personality,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3416) u16 bw_min, u16 bw_max,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3417) bfa_ablk_cbfn_t cbfn, void *cbarg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3418) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3419) struct bfi_ablk_h2i_pf_req_s *m;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3420)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3421) if (!bfa_ioc_is_operational(ablk->ioc)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3422) bfa_trc(ablk->ioc, BFA_STATUS_IOC_FAILURE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3423) return BFA_STATUS_IOC_FAILURE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3424) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3425)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3426) if (ablk->busy) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3427) bfa_trc(ablk->ioc, BFA_STATUS_DEVBUSY);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3428) return BFA_STATUS_DEVBUSY;
^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) ablk->pcifn = pcifn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3432) ablk->cbfn = cbfn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3433) ablk->cbarg = cbarg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3434) ablk->busy = BFA_TRUE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3435)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3436) m = (struct bfi_ablk_h2i_pf_req_s *)ablk->mb.msg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3437) bfi_h2i_set(m->mh, BFI_MC_ABLK, BFI_ABLK_H2I_PF_CREATE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3438) bfa_ioc_portid(ablk->ioc));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3439) m->pers = cpu_to_be16((u16)personality);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3440) m->bw_min = cpu_to_be16(bw_min);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3441) m->bw_max = cpu_to_be16(bw_max);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3442) m->port = port;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3443) bfa_ioc_mbox_queue(ablk->ioc, &ablk->mb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3444)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3445) return BFA_STATUS_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3446) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3447)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3448) bfa_status_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3449) bfa_ablk_pf_delete(struct bfa_ablk_s *ablk, int pcifn,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3450) bfa_ablk_cbfn_t cbfn, void *cbarg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3451) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3452) struct bfi_ablk_h2i_pf_req_s *m;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3453)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3454) if (!bfa_ioc_is_operational(ablk->ioc)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3455) bfa_trc(ablk->ioc, BFA_STATUS_IOC_FAILURE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3456) return BFA_STATUS_IOC_FAILURE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3457) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3458)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3459) if (ablk->busy) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3460) bfa_trc(ablk->ioc, BFA_STATUS_DEVBUSY);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3461) return BFA_STATUS_DEVBUSY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3462) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3463)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3464) ablk->cbfn = cbfn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3465) ablk->cbarg = cbarg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3466) ablk->busy = BFA_TRUE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3467)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3468) m = (struct bfi_ablk_h2i_pf_req_s *)ablk->mb.msg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3469) bfi_h2i_set(m->mh, BFI_MC_ABLK, BFI_ABLK_H2I_PF_DELETE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3470) bfa_ioc_portid(ablk->ioc));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3471) m->pcifn = (u8)pcifn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3472) bfa_ioc_mbox_queue(ablk->ioc, &ablk->mb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3473)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3474) return BFA_STATUS_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3475) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3476)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3477) bfa_status_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3478) bfa_ablk_adapter_config(struct bfa_ablk_s *ablk, enum bfa_mode_s mode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3479) int max_pf, int max_vf, bfa_ablk_cbfn_t cbfn, void *cbarg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3480) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3481) struct bfi_ablk_h2i_cfg_req_s *m;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3482)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3483) if (!bfa_ioc_is_operational(ablk->ioc)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3484) bfa_trc(ablk->ioc, BFA_STATUS_IOC_FAILURE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3485) return BFA_STATUS_IOC_FAILURE;
^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) if (ablk->busy) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3489) bfa_trc(ablk->ioc, BFA_STATUS_DEVBUSY);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3490) return BFA_STATUS_DEVBUSY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3491) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3492)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3493) ablk->cbfn = cbfn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3494) ablk->cbarg = cbarg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3495) ablk->busy = BFA_TRUE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3496)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3497) m = (struct bfi_ablk_h2i_cfg_req_s *)ablk->mb.msg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3498) bfi_h2i_set(m->mh, BFI_MC_ABLK, BFI_ABLK_H2I_ADPT_CONFIG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3499) bfa_ioc_portid(ablk->ioc));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3500) m->mode = (u8)mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3501) m->max_pf = (u8)max_pf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3502) m->max_vf = (u8)max_vf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3503) bfa_ioc_mbox_queue(ablk->ioc, &ablk->mb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3504)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3505) return BFA_STATUS_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3506) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3507)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3508) bfa_status_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3509) bfa_ablk_port_config(struct bfa_ablk_s *ablk, int port, enum bfa_mode_s mode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3510) int max_pf, int max_vf, bfa_ablk_cbfn_t cbfn, void *cbarg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3511) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3512) struct bfi_ablk_h2i_cfg_req_s *m;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3513)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3514) if (!bfa_ioc_is_operational(ablk->ioc)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3515) bfa_trc(ablk->ioc, BFA_STATUS_IOC_FAILURE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3516) return BFA_STATUS_IOC_FAILURE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3517) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3518)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3519) if (ablk->busy) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3520) bfa_trc(ablk->ioc, BFA_STATUS_DEVBUSY);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3521) return BFA_STATUS_DEVBUSY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3522) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3523)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3524) ablk->cbfn = cbfn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3525) ablk->cbarg = cbarg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3526) ablk->busy = BFA_TRUE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3527)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3528) m = (struct bfi_ablk_h2i_cfg_req_s *)ablk->mb.msg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3529) bfi_h2i_set(m->mh, BFI_MC_ABLK, BFI_ABLK_H2I_PORT_CONFIG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3530) bfa_ioc_portid(ablk->ioc));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3531) m->port = (u8)port;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3532) m->mode = (u8)mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3533) m->max_pf = (u8)max_pf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3534) m->max_vf = (u8)max_vf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3535) bfa_ioc_mbox_queue(ablk->ioc, &ablk->mb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3536)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3537) return BFA_STATUS_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3538) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3539)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3540) bfa_status_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3541) bfa_ablk_pf_update(struct bfa_ablk_s *ablk, int pcifn, u16 bw_min,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3542) u16 bw_max, bfa_ablk_cbfn_t cbfn, void *cbarg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3543) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3544) struct bfi_ablk_h2i_pf_req_s *m;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3545)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3546) if (!bfa_ioc_is_operational(ablk->ioc)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3547) bfa_trc(ablk->ioc, BFA_STATUS_IOC_FAILURE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3548) return BFA_STATUS_IOC_FAILURE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3549) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3550)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3551) if (ablk->busy) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3552) bfa_trc(ablk->ioc, BFA_STATUS_DEVBUSY);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3553) return BFA_STATUS_DEVBUSY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3554) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3555)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3556) ablk->cbfn = cbfn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3557) ablk->cbarg = cbarg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3558) ablk->busy = BFA_TRUE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3559)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3560) m = (struct bfi_ablk_h2i_pf_req_s *)ablk->mb.msg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3561) bfi_h2i_set(m->mh, BFI_MC_ABLK, BFI_ABLK_H2I_PF_UPDATE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3562) bfa_ioc_portid(ablk->ioc));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3563) m->pcifn = (u8)pcifn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3564) m->bw_min = cpu_to_be16(bw_min);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3565) m->bw_max = cpu_to_be16(bw_max);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3566) bfa_ioc_mbox_queue(ablk->ioc, &ablk->mb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3567)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3568) return BFA_STATUS_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3569) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3570)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3571) bfa_status_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3572) bfa_ablk_optrom_en(struct bfa_ablk_s *ablk, bfa_ablk_cbfn_t cbfn, void *cbarg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3573) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3574) struct bfi_ablk_h2i_optrom_s *m;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3575)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3576) if (!bfa_ioc_is_operational(ablk->ioc)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3577) bfa_trc(ablk->ioc, BFA_STATUS_IOC_FAILURE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3578) return BFA_STATUS_IOC_FAILURE;
^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 (ablk->busy) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3582) bfa_trc(ablk->ioc, BFA_STATUS_DEVBUSY);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3583) return BFA_STATUS_DEVBUSY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3584) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3585)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3586) ablk->cbfn = cbfn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3587) ablk->cbarg = cbarg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3588) ablk->busy = BFA_TRUE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3589)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3590) m = (struct bfi_ablk_h2i_optrom_s *)ablk->mb.msg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3591) bfi_h2i_set(m->mh, BFI_MC_ABLK, BFI_ABLK_H2I_OPTROM_ENABLE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3592) bfa_ioc_portid(ablk->ioc));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3593) bfa_ioc_mbox_queue(ablk->ioc, &ablk->mb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3594)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3595) return BFA_STATUS_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3596) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3597)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3598) bfa_status_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3599) bfa_ablk_optrom_dis(struct bfa_ablk_s *ablk, bfa_ablk_cbfn_t cbfn, void *cbarg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3600) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3601) struct bfi_ablk_h2i_optrom_s *m;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3602)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3603) if (!bfa_ioc_is_operational(ablk->ioc)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3604) bfa_trc(ablk->ioc, BFA_STATUS_IOC_FAILURE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3605) return BFA_STATUS_IOC_FAILURE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3606) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3607)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3608) if (ablk->busy) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3609) bfa_trc(ablk->ioc, BFA_STATUS_DEVBUSY);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3610) return BFA_STATUS_DEVBUSY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3611) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3612)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3613) ablk->cbfn = cbfn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3614) ablk->cbarg = cbarg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3615) ablk->busy = BFA_TRUE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3616)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3617) m = (struct bfi_ablk_h2i_optrom_s *)ablk->mb.msg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3618) bfi_h2i_set(m->mh, BFI_MC_ABLK, BFI_ABLK_H2I_OPTROM_DISABLE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3619) bfa_ioc_portid(ablk->ioc));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3620) bfa_ioc_mbox_queue(ablk->ioc, &ablk->mb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3621)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3622) return BFA_STATUS_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3623) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3624)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3625) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3626) * SFP module specific
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3627) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3628)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3629) /* forward declarations */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3630) static void bfa_sfp_getdata_send(struct bfa_sfp_s *sfp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3631) static void bfa_sfp_media_get(struct bfa_sfp_s *sfp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3632) static bfa_status_t bfa_sfp_speed_valid(struct bfa_sfp_s *sfp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3633) enum bfa_port_speed portspeed);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3634)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3635) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3636) bfa_cb_sfp_show(struct bfa_sfp_s *sfp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3637) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3638) bfa_trc(sfp, sfp->lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3639) if (sfp->cbfn)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3640) sfp->cbfn(sfp->cbarg, sfp->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3641) sfp->lock = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3642) sfp->cbfn = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3643) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3644)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3645) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3646) bfa_cb_sfp_state_query(struct bfa_sfp_s *sfp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3647) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3648) bfa_trc(sfp, sfp->portspeed);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3649) if (sfp->media) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3650) bfa_sfp_media_get(sfp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3651) if (sfp->state_query_cbfn)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3652) sfp->state_query_cbfn(sfp->state_query_cbarg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3653) sfp->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3654) sfp->media = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3655) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3656)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3657) if (sfp->portspeed) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3658) sfp->status = bfa_sfp_speed_valid(sfp, sfp->portspeed);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3659) if (sfp->state_query_cbfn)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3660) sfp->state_query_cbfn(sfp->state_query_cbarg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3661) sfp->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3662) sfp->portspeed = BFA_PORT_SPEED_UNKNOWN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3663) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3664)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3665) sfp->state_query_lock = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3666) sfp->state_query_cbfn = NULL;
^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) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3670) * IOC event handler.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3671) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3672) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3673) bfa_sfp_notify(void *sfp_arg, enum bfa_ioc_event_e event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3674) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3675) struct bfa_sfp_s *sfp = sfp_arg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3676)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3677) bfa_trc(sfp, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3678) bfa_trc(sfp, sfp->lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3679) bfa_trc(sfp, sfp->state_query_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3680)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3681) switch (event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3682) case BFA_IOC_E_DISABLED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3683) case BFA_IOC_E_FAILED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3684) if (sfp->lock) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3685) sfp->status = BFA_STATUS_IOC_FAILURE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3686) bfa_cb_sfp_show(sfp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3687) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3688)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3689) if (sfp->state_query_lock) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3690) sfp->status = BFA_STATUS_IOC_FAILURE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3691) bfa_cb_sfp_state_query(sfp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3692) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3693) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3694)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3695) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3696) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3697) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3698) }
^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) * SFP's State Change Notification post to AEN
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3702) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3703) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3704) bfa_sfp_scn_aen_post(struct bfa_sfp_s *sfp, struct bfi_sfp_scn_s *rsp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3705) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3706) struct bfad_s *bfad = (struct bfad_s *)sfp->ioc->bfa->bfad;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3707) struct bfa_aen_entry_s *aen_entry;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3708) enum bfa_port_aen_event aen_evt = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3709)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3710) bfa_trc(sfp, (((u64)rsp->pomlvl) << 16) | (((u64)rsp->sfpid) << 8) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3711) ((u64)rsp->event));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3712)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3713) bfad_get_aen_entry(bfad, aen_entry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3714) if (!aen_entry)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3715) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3716)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3717) aen_entry->aen_data.port.ioc_type = bfa_ioc_get_type(sfp->ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3718) aen_entry->aen_data.port.pwwn = sfp->ioc->attr->pwwn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3719) aen_entry->aen_data.port.mac = bfa_ioc_get_mac(sfp->ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3720)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3721) switch (rsp->event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3722) case BFA_SFP_SCN_INSERTED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3723) aen_evt = BFA_PORT_AEN_SFP_INSERT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3724) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3725) case BFA_SFP_SCN_REMOVED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3726) aen_evt = BFA_PORT_AEN_SFP_REMOVE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3727) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3728) case BFA_SFP_SCN_FAILED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3729) aen_evt = BFA_PORT_AEN_SFP_ACCESS_ERROR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3730) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3731) case BFA_SFP_SCN_UNSUPPORT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3732) aen_evt = BFA_PORT_AEN_SFP_UNSUPPORT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3733) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3734) case BFA_SFP_SCN_POM:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3735) aen_evt = BFA_PORT_AEN_SFP_POM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3736) aen_entry->aen_data.port.level = rsp->pomlvl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3737) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3738) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3739) bfa_trc(sfp, rsp->event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3740) WARN_ON(1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3741) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3742)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3743) /* Send the AEN notification */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3744) bfad_im_post_vendor_event(aen_entry, bfad, ++sfp->ioc->ioc_aen_seq,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3745) BFA_AEN_CAT_PORT, aen_evt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3746) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3747)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3748) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3749) * SFP get data send
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3750) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3751) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3752) bfa_sfp_getdata_send(struct bfa_sfp_s *sfp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3753) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3754) struct bfi_sfp_req_s *req = (struct bfi_sfp_req_s *)sfp->mbcmd.msg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3755)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3756) bfa_trc(sfp, req->memtype);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3757)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3758) /* build host command */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3759) bfi_h2i_set(req->mh, BFI_MC_SFP, BFI_SFP_H2I_SHOW,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3760) bfa_ioc_portid(sfp->ioc));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3761)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3762) /* send mbox cmd */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3763) bfa_ioc_mbox_queue(sfp->ioc, &sfp->mbcmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3764) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3765)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3766) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3767) * SFP is valid, read sfp data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3768) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3769) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3770) bfa_sfp_getdata(struct bfa_sfp_s *sfp, enum bfi_sfp_mem_e memtype)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3771) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3772) struct bfi_sfp_req_s *req = (struct bfi_sfp_req_s *)sfp->mbcmd.msg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3773)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3774) WARN_ON(sfp->lock != 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3775) bfa_trc(sfp, sfp->state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3776)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3777) sfp->lock = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3778) sfp->memtype = memtype;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3779) req->memtype = memtype;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3780)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3781) /* Setup SG list */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3782) bfa_alen_set(&req->alen, sizeof(struct sfp_mem_s), sfp->dbuf_pa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3783)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3784) bfa_sfp_getdata_send(sfp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3785) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3786)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3787) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3788) * SFP scn handler
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3789) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3790) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3791) bfa_sfp_scn(struct bfa_sfp_s *sfp, struct bfi_mbmsg_s *msg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3792) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3793) struct bfi_sfp_scn_s *rsp = (struct bfi_sfp_scn_s *) msg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3794)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3795) switch (rsp->event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3796) case BFA_SFP_SCN_INSERTED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3797) sfp->state = BFA_SFP_STATE_INSERTED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3798) sfp->data_valid = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3799) bfa_sfp_scn_aen_post(sfp, rsp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3800) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3801) case BFA_SFP_SCN_REMOVED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3802) sfp->state = BFA_SFP_STATE_REMOVED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3803) sfp->data_valid = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3804) bfa_sfp_scn_aen_post(sfp, rsp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3805) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3806) case BFA_SFP_SCN_FAILED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3807) sfp->state = BFA_SFP_STATE_FAILED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3808) sfp->data_valid = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3809) bfa_sfp_scn_aen_post(sfp, rsp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3810) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3811) case BFA_SFP_SCN_UNSUPPORT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3812) sfp->state = BFA_SFP_STATE_UNSUPPORT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3813) bfa_sfp_scn_aen_post(sfp, rsp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3814) if (!sfp->lock)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3815) bfa_sfp_getdata(sfp, BFI_SFP_MEM_ALL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3816) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3817) case BFA_SFP_SCN_POM:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3818) bfa_sfp_scn_aen_post(sfp, rsp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3819) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3820) case BFA_SFP_SCN_VALID:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3821) sfp->state = BFA_SFP_STATE_VALID;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3822) if (!sfp->lock)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3823) bfa_sfp_getdata(sfp, BFI_SFP_MEM_ALL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3824) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3825) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3826) bfa_trc(sfp, rsp->event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3827) WARN_ON(1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3828) }
^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) * SFP show complete
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3833) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3834) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3835) bfa_sfp_show_comp(struct bfa_sfp_s *sfp, struct bfi_mbmsg_s *msg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3836) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3837) struct bfi_sfp_rsp_s *rsp = (struct bfi_sfp_rsp_s *) msg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3838)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3839) if (!sfp->lock) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3840) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3841) * receiving response after ioc failure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3842) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3843) bfa_trc(sfp, sfp->lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3844) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3845) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3846)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3847) bfa_trc(sfp, rsp->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3848) if (rsp->status == BFA_STATUS_OK) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3849) sfp->data_valid = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3850) if (sfp->state == BFA_SFP_STATE_VALID)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3851) sfp->status = BFA_STATUS_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3852) else if (sfp->state == BFA_SFP_STATE_UNSUPPORT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3853) sfp->status = BFA_STATUS_SFP_UNSUPP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3854) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3855) bfa_trc(sfp, sfp->state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3856) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3857) sfp->data_valid = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3858) sfp->status = rsp->status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3859) /* sfpshow shouldn't change sfp state */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3860) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3861)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3862) bfa_trc(sfp, sfp->memtype);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3863) if (sfp->memtype == BFI_SFP_MEM_DIAGEXT) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3864) bfa_trc(sfp, sfp->data_valid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3865) if (sfp->data_valid) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3866) u32 size = sizeof(struct sfp_mem_s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3867) u8 *des = (u8 *)(sfp->sfpmem);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3868) memcpy(des, sfp->dbuf_kva, size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3869) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3870) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3871) * Queue completion callback.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3872) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3873) bfa_cb_sfp_show(sfp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3874) } else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3875) sfp->lock = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3876)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3877) bfa_trc(sfp, sfp->state_query_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3878) if (sfp->state_query_lock) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3879) sfp->state = rsp->state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3880) /* Complete callback */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3881) bfa_cb_sfp_state_query(sfp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3882) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3883) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3884)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3885) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3886) * SFP query fw sfp state
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3887) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3888) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3889) bfa_sfp_state_query(struct bfa_sfp_s *sfp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3890) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3891) struct bfi_sfp_req_s *req = (struct bfi_sfp_req_s *)sfp->mbcmd.msg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3892)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3893) /* Should not be doing query if not in _INIT state */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3894) WARN_ON(sfp->state != BFA_SFP_STATE_INIT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3895) WARN_ON(sfp->state_query_lock != 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3896) bfa_trc(sfp, sfp->state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3897)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3898) sfp->state_query_lock = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3899) req->memtype = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3900)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3901) if (!sfp->lock)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3902) bfa_sfp_getdata(sfp, BFI_SFP_MEM_ALL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3903) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3904)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3905) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3906) bfa_sfp_media_get(struct bfa_sfp_s *sfp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3907) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3908) enum bfa_defs_sfp_media_e *media = sfp->media;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3909)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3910) *media = BFA_SFP_MEDIA_UNKNOWN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3911)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3912) if (sfp->state == BFA_SFP_STATE_UNSUPPORT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3913) *media = BFA_SFP_MEDIA_UNSUPPORT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3914) else if (sfp->state == BFA_SFP_STATE_VALID) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3915) union sfp_xcvr_e10g_code_u e10g;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3916) struct sfp_mem_s *sfpmem = (struct sfp_mem_s *)sfp->dbuf_kva;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3917) u16 xmtr_tech = (sfpmem->srlid_base.xcvr[4] & 0x3) << 7 |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3918) (sfpmem->srlid_base.xcvr[5] >> 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3919)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3920) e10g.b = sfpmem->srlid_base.xcvr[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3921) bfa_trc(sfp, e10g.b);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3922) bfa_trc(sfp, xmtr_tech);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3923) /* check fc transmitter tech */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3924) if ((xmtr_tech & SFP_XMTR_TECH_CU) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3925) (xmtr_tech & SFP_XMTR_TECH_CP) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3926) (xmtr_tech & SFP_XMTR_TECH_CA))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3927) *media = BFA_SFP_MEDIA_CU;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3928) else if ((xmtr_tech & SFP_XMTR_TECH_EL_INTRA) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3929) (xmtr_tech & SFP_XMTR_TECH_EL_INTER))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3930) *media = BFA_SFP_MEDIA_EL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3931) else if ((xmtr_tech & SFP_XMTR_TECH_LL) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3932) (xmtr_tech & SFP_XMTR_TECH_LC))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3933) *media = BFA_SFP_MEDIA_LW;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3934) else if ((xmtr_tech & SFP_XMTR_TECH_SL) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3935) (xmtr_tech & SFP_XMTR_TECH_SN) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3936) (xmtr_tech & SFP_XMTR_TECH_SA))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3937) *media = BFA_SFP_MEDIA_SW;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3938) /* Check 10G Ethernet Compilance code */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3939) else if (e10g.r.e10g_sr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3940) *media = BFA_SFP_MEDIA_SW;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3941) else if (e10g.r.e10g_lrm && e10g.r.e10g_lr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3942) *media = BFA_SFP_MEDIA_LW;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3943) else if (e10g.r.e10g_unall)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3944) *media = BFA_SFP_MEDIA_UNKNOWN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3945) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3946) bfa_trc(sfp, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3947) } else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3948) bfa_trc(sfp, sfp->state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3949) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3950)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3951) static bfa_status_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3952) bfa_sfp_speed_valid(struct bfa_sfp_s *sfp, enum bfa_port_speed portspeed)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3953) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3954) struct sfp_mem_s *sfpmem = (struct sfp_mem_s *)sfp->dbuf_kva;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3955) struct sfp_xcvr_s *xcvr = (struct sfp_xcvr_s *) sfpmem->srlid_base.xcvr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3956) union sfp_xcvr_fc3_code_u fc3 = xcvr->fc3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3957) union sfp_xcvr_e10g_code_u e10g = xcvr->e10g;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3958)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3959) if (portspeed == BFA_PORT_SPEED_10GBPS) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3960) if (e10g.r.e10g_sr || e10g.r.e10g_lr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3961) return BFA_STATUS_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3962) else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3963) bfa_trc(sfp, e10g.b);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3964) return BFA_STATUS_UNSUPP_SPEED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3965) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3966) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3967) if (((portspeed & BFA_PORT_SPEED_16GBPS) && fc3.r.mb1600) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3968) ((portspeed & BFA_PORT_SPEED_8GBPS) && fc3.r.mb800) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3969) ((portspeed & BFA_PORT_SPEED_4GBPS) && fc3.r.mb400) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3970) ((portspeed & BFA_PORT_SPEED_2GBPS) && fc3.r.mb200) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3971) ((portspeed & BFA_PORT_SPEED_1GBPS) && fc3.r.mb100))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3972) return BFA_STATUS_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3973) else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3974) bfa_trc(sfp, portspeed);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3975) bfa_trc(sfp, fc3.b);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3976) bfa_trc(sfp, e10g.b);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3977) return BFA_STATUS_UNSUPP_SPEED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3978) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3979) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3980)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3981) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3982) * SFP hmbox handler
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3983) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3984) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3985) bfa_sfp_intr(void *sfparg, struct bfi_mbmsg_s *msg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3986) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3987) struct bfa_sfp_s *sfp = sfparg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3988)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3989) switch (msg->mh.msg_id) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3990) case BFI_SFP_I2H_SHOW:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3991) bfa_sfp_show_comp(sfp, msg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3992) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3993)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3994) case BFI_SFP_I2H_SCN:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3995) bfa_sfp_scn(sfp, msg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3996) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3997)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3998) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3999) bfa_trc(sfp, msg->mh.msg_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4000) WARN_ON(1);
^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)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4004) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4005) * Return DMA memory needed by sfp module.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4006) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4007) u32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4008) bfa_sfp_meminfo(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4009) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4010) return BFA_ROUNDUP(sizeof(struct sfp_mem_s), BFA_DMA_ALIGN_SZ);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4011) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4012)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4013) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4014) * Attach virtual and physical memory for SFP.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4015) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4016) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4017) bfa_sfp_attach(struct bfa_sfp_s *sfp, struct bfa_ioc_s *ioc, void *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4018) struct bfa_trc_mod_s *trcmod)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4019) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4020) sfp->dev = dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4021) sfp->ioc = ioc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4022) sfp->trcmod = trcmod;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4023)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4024) sfp->cbfn = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4025) sfp->cbarg = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4026) sfp->sfpmem = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4027) sfp->lock = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4028) sfp->data_valid = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4029) sfp->state = BFA_SFP_STATE_INIT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4030) sfp->state_query_lock = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4031) sfp->state_query_cbfn = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4032) sfp->state_query_cbarg = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4033) sfp->media = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4034) sfp->portspeed = BFA_PORT_SPEED_UNKNOWN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4035) sfp->is_elb = BFA_FALSE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4036)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4037) bfa_ioc_mbox_regisr(sfp->ioc, BFI_MC_SFP, bfa_sfp_intr, sfp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4038) bfa_q_qe_init(&sfp->ioc_notify);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4039) bfa_ioc_notify_init(&sfp->ioc_notify, bfa_sfp_notify, sfp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4040) list_add_tail(&sfp->ioc_notify.qe, &sfp->ioc->notify_q);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4041) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4042)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4043) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4044) * Claim Memory for SFP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4045) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4046) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4047) bfa_sfp_memclaim(struct bfa_sfp_s *sfp, u8 *dm_kva, u64 dm_pa)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4048) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4049) sfp->dbuf_kva = dm_kva;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4050) sfp->dbuf_pa = dm_pa;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4051) memset(sfp->dbuf_kva, 0, sizeof(struct sfp_mem_s));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4052)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4053) dm_kva += BFA_ROUNDUP(sizeof(struct sfp_mem_s), BFA_DMA_ALIGN_SZ);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4054) dm_pa += BFA_ROUNDUP(sizeof(struct sfp_mem_s), BFA_DMA_ALIGN_SZ);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4055) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4056)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4057) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4058) * Show SFP eeprom content
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4059) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4060) * @param[in] sfp - bfa sfp module
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4061) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4062) * @param[out] sfpmem - sfp eeprom data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4063) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4064) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4065) bfa_status_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4066) bfa_sfp_show(struct bfa_sfp_s *sfp, struct sfp_mem_s *sfpmem,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4067) bfa_cb_sfp_t cbfn, void *cbarg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4068) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4069)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4070) if (!bfa_ioc_is_operational(sfp->ioc)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4071) bfa_trc(sfp, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4072) return BFA_STATUS_IOC_NON_OP;
^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) if (sfp->lock) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4076) bfa_trc(sfp, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4077) return BFA_STATUS_DEVBUSY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4078) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4079)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4080) sfp->cbfn = cbfn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4081) sfp->cbarg = cbarg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4082) sfp->sfpmem = sfpmem;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4083)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4084) bfa_sfp_getdata(sfp, BFI_SFP_MEM_DIAGEXT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4085) return BFA_STATUS_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4086) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4087)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4088) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4089) * Return SFP Media type
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4090) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4091) * @param[in] sfp - bfa sfp module
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4092) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4093) * @param[out] media - port speed from user
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4094) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4095) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4096) bfa_status_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4097) bfa_sfp_media(struct bfa_sfp_s *sfp, enum bfa_defs_sfp_media_e *media,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4098) bfa_cb_sfp_t cbfn, void *cbarg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4099) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4100) if (!bfa_ioc_is_operational(sfp->ioc)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4101) bfa_trc(sfp, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4102) return BFA_STATUS_IOC_NON_OP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4103) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4104)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4105) sfp->media = media;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4106) if (sfp->state == BFA_SFP_STATE_INIT) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4107) if (sfp->state_query_lock) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4108) bfa_trc(sfp, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4109) return BFA_STATUS_DEVBUSY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4110) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4111) sfp->state_query_cbfn = cbfn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4112) sfp->state_query_cbarg = cbarg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4113) bfa_sfp_state_query(sfp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4114) return BFA_STATUS_SFP_NOT_READY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4115) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4116) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4117)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4118) bfa_sfp_media_get(sfp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4119) return BFA_STATUS_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4120) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4121)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4122) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4123) * Check if user set port speed is allowed by the SFP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4124) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4125) * @param[in] sfp - bfa sfp module
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4126) * @param[in] portspeed - port speed from user
^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) bfa_status_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4130) bfa_sfp_speed(struct bfa_sfp_s *sfp, enum bfa_port_speed portspeed,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4131) bfa_cb_sfp_t cbfn, void *cbarg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4132) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4133) WARN_ON(portspeed == BFA_PORT_SPEED_UNKNOWN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4134)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4135) if (!bfa_ioc_is_operational(sfp->ioc))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4136) return BFA_STATUS_IOC_NON_OP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4137)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4138) /* For Mezz card, all speed is allowed */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4139) if (bfa_mfg_is_mezz(sfp->ioc->attr->card_type))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4140) return BFA_STATUS_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4141)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4142) /* Check SFP state */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4143) sfp->portspeed = portspeed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4144) if (sfp->state == BFA_SFP_STATE_INIT) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4145) if (sfp->state_query_lock) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4146) bfa_trc(sfp, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4147) return BFA_STATUS_DEVBUSY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4148) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4149) sfp->state_query_cbfn = cbfn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4150) sfp->state_query_cbarg = cbarg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4151) bfa_sfp_state_query(sfp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4152) return BFA_STATUS_SFP_NOT_READY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4153) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4154) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4155)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4156) if (sfp->state == BFA_SFP_STATE_REMOVED ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4157) sfp->state == BFA_SFP_STATE_FAILED) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4158) bfa_trc(sfp, sfp->state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4159) return BFA_STATUS_NO_SFP_DEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4160) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4161)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4162) if (sfp->state == BFA_SFP_STATE_INSERTED) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4163) bfa_trc(sfp, sfp->state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4164) return BFA_STATUS_DEVBUSY; /* sfp is reading data */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4165) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4166)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4167) /* For eloopback, all speed is allowed */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4168) if (sfp->is_elb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4169) return BFA_STATUS_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4170)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4171) return bfa_sfp_speed_valid(sfp, portspeed);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4172) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4173)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4174) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4175) * Flash module specific
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4176) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4177)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4178) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4179) * FLASH DMA buffer should be big enough to hold both MFG block and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4180) * asic block(64k) at the same time and also should be 2k aligned to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4181) * avoid write segement to cross sector boundary.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4182) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4183) #define BFA_FLASH_SEG_SZ 2048
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4184) #define BFA_FLASH_DMA_BUF_SZ \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4185) BFA_ROUNDUP(0x010000 + sizeof(struct bfa_mfg_block_s), BFA_FLASH_SEG_SZ)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4186)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4187) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4188) bfa_flash_aen_audit_post(struct bfa_ioc_s *ioc, enum bfa_audit_aen_event event,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4189) int inst, int type)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4190) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4191) struct bfad_s *bfad = (struct bfad_s *)ioc->bfa->bfad;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4192) struct bfa_aen_entry_s *aen_entry;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4193)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4194) bfad_get_aen_entry(bfad, aen_entry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4195) if (!aen_entry)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4196) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4197)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4198) aen_entry->aen_data.audit.pwwn = ioc->attr->pwwn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4199) aen_entry->aen_data.audit.partition_inst = inst;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4200) aen_entry->aen_data.audit.partition_type = type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4201)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4202) /* Send the AEN notification */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4203) bfad_im_post_vendor_event(aen_entry, bfad, ++ioc->ioc_aen_seq,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4204) BFA_AEN_CAT_AUDIT, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4205) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4206)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4207) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4208) bfa_flash_cb(struct bfa_flash_s *flash)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4209) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4210) flash->op_busy = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4211) if (flash->cbfn)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4212) flash->cbfn(flash->cbarg, flash->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4213) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4214)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4215) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4216) bfa_flash_notify(void *cbarg, enum bfa_ioc_event_e event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4217) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4218) struct bfa_flash_s *flash = cbarg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4219)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4220) bfa_trc(flash, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4221) switch (event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4222) case BFA_IOC_E_DISABLED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4223) case BFA_IOC_E_FAILED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4224) if (flash->op_busy) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4225) flash->status = BFA_STATUS_IOC_FAILURE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4226) flash->cbfn(flash->cbarg, flash->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4227) flash->op_busy = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4228) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4229) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4230)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4231) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4232) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4233) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4234) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4235)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4236) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4237) * Send flash attribute query request.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4238) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4239) * @param[in] cbarg - callback argument
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4240) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4241) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4242) bfa_flash_query_send(void *cbarg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4243) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4244) struct bfa_flash_s *flash = cbarg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4245) struct bfi_flash_query_req_s *msg =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4246) (struct bfi_flash_query_req_s *) flash->mb.msg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4247)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4248) bfi_h2i_set(msg->mh, BFI_MC_FLASH, BFI_FLASH_H2I_QUERY_REQ,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4249) bfa_ioc_portid(flash->ioc));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4250) bfa_alen_set(&msg->alen, sizeof(struct bfa_flash_attr_s),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4251) flash->dbuf_pa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4252) bfa_ioc_mbox_queue(flash->ioc, &flash->mb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4253) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4254)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4255) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4256) * Send flash write request.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4257) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4258) * @param[in] cbarg - callback argument
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4259) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4260) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4261) bfa_flash_write_send(struct bfa_flash_s *flash)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4262) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4263) struct bfi_flash_write_req_s *msg =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4264) (struct bfi_flash_write_req_s *) flash->mb.msg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4265) u32 len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4266)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4267) msg->type = be32_to_cpu(flash->type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4268) msg->instance = flash->instance;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4269) msg->offset = be32_to_cpu(flash->addr_off + flash->offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4270) len = (flash->residue < BFA_FLASH_DMA_BUF_SZ) ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4271) flash->residue : BFA_FLASH_DMA_BUF_SZ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4272) msg->length = be32_to_cpu(len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4273)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4274) /* indicate if it's the last msg of the whole write operation */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4275) msg->last = (len == flash->residue) ? 1 : 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4276)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4277) bfi_h2i_set(msg->mh, BFI_MC_FLASH, BFI_FLASH_H2I_WRITE_REQ,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4278) bfa_ioc_portid(flash->ioc));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4279) bfa_alen_set(&msg->alen, len, flash->dbuf_pa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4280) memcpy(flash->dbuf_kva, flash->ubuf + flash->offset, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4281) bfa_ioc_mbox_queue(flash->ioc, &flash->mb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4282)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4283) flash->residue -= len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4284) flash->offset += len;
^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) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4288) * Send flash read request.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4289) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4290) * @param[in] cbarg - callback argument
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4291) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4292) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4293) bfa_flash_read_send(void *cbarg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4294) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4295) struct bfa_flash_s *flash = cbarg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4296) struct bfi_flash_read_req_s *msg =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4297) (struct bfi_flash_read_req_s *) flash->mb.msg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4298) u32 len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4299)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4300) msg->type = be32_to_cpu(flash->type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4301) msg->instance = flash->instance;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4302) msg->offset = be32_to_cpu(flash->addr_off + flash->offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4303) len = (flash->residue < BFA_FLASH_DMA_BUF_SZ) ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4304) flash->residue : BFA_FLASH_DMA_BUF_SZ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4305) msg->length = be32_to_cpu(len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4306) bfi_h2i_set(msg->mh, BFI_MC_FLASH, BFI_FLASH_H2I_READ_REQ,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4307) bfa_ioc_portid(flash->ioc));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4308) bfa_alen_set(&msg->alen, len, flash->dbuf_pa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4309) bfa_ioc_mbox_queue(flash->ioc, &flash->mb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4310) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4311)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4312) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4313) * Send flash erase request.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4314) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4315) * @param[in] cbarg - callback argument
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4316) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4317) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4318) bfa_flash_erase_send(void *cbarg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4319) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4320) struct bfa_flash_s *flash = cbarg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4321) struct bfi_flash_erase_req_s *msg =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4322) (struct bfi_flash_erase_req_s *) flash->mb.msg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4323)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4324) msg->type = be32_to_cpu(flash->type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4325) msg->instance = flash->instance;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4326) bfi_h2i_set(msg->mh, BFI_MC_FLASH, BFI_FLASH_H2I_ERASE_REQ,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4327) bfa_ioc_portid(flash->ioc));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4328) bfa_ioc_mbox_queue(flash->ioc, &flash->mb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4329) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4330)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4331) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4332) * Process flash response messages upon receiving interrupts.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4333) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4334) * @param[in] flasharg - flash structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4335) * @param[in] msg - message structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4336) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4337) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4338) bfa_flash_intr(void *flasharg, struct bfi_mbmsg_s *msg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4339) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4340) struct bfa_flash_s *flash = flasharg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4341) u32 status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4342)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4343) union {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4344) struct bfi_flash_query_rsp_s *query;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4345) struct bfi_flash_erase_rsp_s *erase;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4346) struct bfi_flash_write_rsp_s *write;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4347) struct bfi_flash_read_rsp_s *read;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4348) struct bfi_flash_event_s *event;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4349) struct bfi_mbmsg_s *msg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4350) } m;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4351)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4352) m.msg = msg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4353) bfa_trc(flash, msg->mh.msg_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4354)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4355) if (!flash->op_busy && msg->mh.msg_id != BFI_FLASH_I2H_EVENT) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4356) /* receiving response after ioc failure */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4357) bfa_trc(flash, 0x9999);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4358) return;
^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) switch (msg->mh.msg_id) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4362) case BFI_FLASH_I2H_QUERY_RSP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4363) status = be32_to_cpu(m.query->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4364) bfa_trc(flash, status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4365) if (status == BFA_STATUS_OK) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4366) u32 i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4367) struct bfa_flash_attr_s *attr, *f;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4368)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4369) attr = (struct bfa_flash_attr_s *) flash->ubuf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4370) f = (struct bfa_flash_attr_s *) flash->dbuf_kva;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4371) attr->status = be32_to_cpu(f->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4372) attr->npart = be32_to_cpu(f->npart);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4373) bfa_trc(flash, attr->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4374) bfa_trc(flash, attr->npart);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4375) for (i = 0; i < attr->npart; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4376) attr->part[i].part_type =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4377) be32_to_cpu(f->part[i].part_type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4378) attr->part[i].part_instance =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4379) be32_to_cpu(f->part[i].part_instance);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4380) attr->part[i].part_off =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4381) be32_to_cpu(f->part[i].part_off);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4382) attr->part[i].part_size =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4383) be32_to_cpu(f->part[i].part_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4384) attr->part[i].part_len =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4385) be32_to_cpu(f->part[i].part_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4386) attr->part[i].part_status =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4387) be32_to_cpu(f->part[i].part_status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4388) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4389) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4390) flash->status = status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4391) bfa_flash_cb(flash);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4392) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4393) case BFI_FLASH_I2H_ERASE_RSP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4394) status = be32_to_cpu(m.erase->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4395) bfa_trc(flash, status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4396) flash->status = status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4397) bfa_flash_cb(flash);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4398) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4399) case BFI_FLASH_I2H_WRITE_RSP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4400) status = be32_to_cpu(m.write->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4401) bfa_trc(flash, status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4402) if (status != BFA_STATUS_OK || flash->residue == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4403) flash->status = status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4404) bfa_flash_cb(flash);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4405) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4406) bfa_trc(flash, flash->offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4407) bfa_flash_write_send(flash);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4408) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4409) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4410) case BFI_FLASH_I2H_READ_RSP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4411) status = be32_to_cpu(m.read->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4412) bfa_trc(flash, status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4413) if (status != BFA_STATUS_OK) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4414) flash->status = status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4415) bfa_flash_cb(flash);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4416) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4417) u32 len = be32_to_cpu(m.read->length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4418) bfa_trc(flash, flash->offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4419) bfa_trc(flash, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4420) memcpy(flash->ubuf + flash->offset,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4421) flash->dbuf_kva, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4422) flash->residue -= len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4423) flash->offset += len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4424) if (flash->residue == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4425) flash->status = status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4426) bfa_flash_cb(flash);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4427) } else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4428) bfa_flash_read_send(flash);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4429) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4430) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4431) case BFI_FLASH_I2H_BOOT_VER_RSP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4432) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4433) case BFI_FLASH_I2H_EVENT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4434) status = be32_to_cpu(m.event->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4435) bfa_trc(flash, status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4436) if (status == BFA_STATUS_BAD_FWCFG)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4437) bfa_ioc_aen_post(flash->ioc, BFA_IOC_AEN_FWCFG_ERROR);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4438) else if (status == BFA_STATUS_INVALID_VENDOR) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4439) u32 param;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4440) param = be32_to_cpu(m.event->param);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4441) bfa_trc(flash, param);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4442) bfa_ioc_aen_post(flash->ioc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4443) BFA_IOC_AEN_INVALID_VENDOR);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4444) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4445) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4446)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4447) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4448) WARN_ON(1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4449) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4450) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4451)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4452) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4453) * Flash memory info API.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4454) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4455) * @param[in] mincfg - minimal cfg variable
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4456) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4457) u32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4458) bfa_flash_meminfo(bfa_boolean_t mincfg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4459) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4460) /* min driver doesn't need flash */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4461) if (mincfg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4462) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4463) return BFA_ROUNDUP(BFA_FLASH_DMA_BUF_SZ, BFA_DMA_ALIGN_SZ);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4464) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4465)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4466) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4467) * Flash attach API.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4468) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4469) * @param[in] flash - flash structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4470) * @param[in] ioc - ioc structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4471) * @param[in] dev - device structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4472) * @param[in] trcmod - trace module
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4473) * @param[in] logmod - log module
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4474) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4475) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4476) bfa_flash_attach(struct bfa_flash_s *flash, struct bfa_ioc_s *ioc, void *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4477) struct bfa_trc_mod_s *trcmod, bfa_boolean_t mincfg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4478) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4479) flash->ioc = ioc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4480) flash->trcmod = trcmod;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4481) flash->cbfn = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4482) flash->cbarg = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4483) flash->op_busy = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4484)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4485) bfa_ioc_mbox_regisr(flash->ioc, BFI_MC_FLASH, bfa_flash_intr, flash);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4486) bfa_q_qe_init(&flash->ioc_notify);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4487) bfa_ioc_notify_init(&flash->ioc_notify, bfa_flash_notify, flash);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4488) list_add_tail(&flash->ioc_notify.qe, &flash->ioc->notify_q);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4489)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4490) /* min driver doesn't need flash */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4491) if (mincfg) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4492) flash->dbuf_kva = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4493) flash->dbuf_pa = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4494) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4495) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4496)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4497) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4498) * Claim memory for flash
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4499) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4500) * @param[in] flash - flash structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4501) * @param[in] dm_kva - pointer to virtual memory address
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4502) * @param[in] dm_pa - physical memory address
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4503) * @param[in] mincfg - minimal cfg variable
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4504) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4505) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4506) bfa_flash_memclaim(struct bfa_flash_s *flash, u8 *dm_kva, u64 dm_pa,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4507) bfa_boolean_t mincfg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4508) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4509) if (mincfg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4510) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4511)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4512) flash->dbuf_kva = dm_kva;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4513) flash->dbuf_pa = dm_pa;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4514) memset(flash->dbuf_kva, 0, BFA_FLASH_DMA_BUF_SZ);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4515) dm_kva += BFA_ROUNDUP(BFA_FLASH_DMA_BUF_SZ, BFA_DMA_ALIGN_SZ);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4516) dm_pa += BFA_ROUNDUP(BFA_FLASH_DMA_BUF_SZ, BFA_DMA_ALIGN_SZ);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4517) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4518)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4519) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4520) * Get flash attribute.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4521) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4522) * @param[in] flash - flash structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4523) * @param[in] attr - flash attribute structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4524) * @param[in] cbfn - callback function
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4525) * @param[in] cbarg - callback argument
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4526) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4527) * Return status.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4528) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4529) bfa_status_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4530) bfa_flash_get_attr(struct bfa_flash_s *flash, struct bfa_flash_attr_s *attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4531) bfa_cb_flash_t cbfn, void *cbarg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4532) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4533) bfa_trc(flash, BFI_FLASH_H2I_QUERY_REQ);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4534)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4535) if (!bfa_ioc_is_operational(flash->ioc))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4536) return BFA_STATUS_IOC_NON_OP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4537)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4538) if (flash->op_busy) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4539) bfa_trc(flash, flash->op_busy);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4540) return BFA_STATUS_DEVBUSY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4541) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4542)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4543) flash->op_busy = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4544) flash->cbfn = cbfn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4545) flash->cbarg = cbarg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4546) flash->ubuf = (u8 *) attr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4547) bfa_flash_query_send(flash);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4548)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4549) return BFA_STATUS_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4550) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4551)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4552) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4553) * Erase flash partition.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4554) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4555) * @param[in] flash - flash structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4556) * @param[in] type - flash partition type
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4557) * @param[in] instance - flash partition instance
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4558) * @param[in] cbfn - callback function
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4559) * @param[in] cbarg - callback argument
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4560) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4561) * Return status.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4562) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4563) bfa_status_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4564) bfa_flash_erase_part(struct bfa_flash_s *flash, enum bfa_flash_part_type type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4565) u8 instance, bfa_cb_flash_t cbfn, void *cbarg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4566) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4567) bfa_trc(flash, BFI_FLASH_H2I_ERASE_REQ);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4568) bfa_trc(flash, type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4569) bfa_trc(flash, instance);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4570)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4571) if (!bfa_ioc_is_operational(flash->ioc))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4572) return BFA_STATUS_IOC_NON_OP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4573)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4574) if (flash->op_busy) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4575) bfa_trc(flash, flash->op_busy);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4576) return BFA_STATUS_DEVBUSY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4577) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4578)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4579) flash->op_busy = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4580) flash->cbfn = cbfn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4581) flash->cbarg = cbarg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4582) flash->type = type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4583) flash->instance = instance;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4584)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4585) bfa_flash_erase_send(flash);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4586) bfa_flash_aen_audit_post(flash->ioc, BFA_AUDIT_AEN_FLASH_ERASE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4587) instance, type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4588) return BFA_STATUS_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4589) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4590)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4591) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4592) * Update flash partition.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4593) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4594) * @param[in] flash - flash structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4595) * @param[in] type - flash partition type
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4596) * @param[in] instance - flash partition instance
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4597) * @param[in] buf - update data buffer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4598) * @param[in] len - data buffer length
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4599) * @param[in] offset - offset relative to the partition starting address
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4600) * @param[in] cbfn - callback function
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4601) * @param[in] cbarg - callback argument
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4602) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4603) * Return status.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4604) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4605) bfa_status_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4606) bfa_flash_update_part(struct bfa_flash_s *flash, enum bfa_flash_part_type type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4607) u8 instance, void *buf, u32 len, u32 offset,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4608) bfa_cb_flash_t cbfn, void *cbarg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4609) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4610) bfa_trc(flash, BFI_FLASH_H2I_WRITE_REQ);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4611) bfa_trc(flash, type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4612) bfa_trc(flash, instance);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4613) bfa_trc(flash, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4614) bfa_trc(flash, offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4615)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4616) if (!bfa_ioc_is_operational(flash->ioc))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4617) return BFA_STATUS_IOC_NON_OP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4618)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4619) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4620) * 'len' must be in word (4-byte) boundary
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4621) * 'offset' must be in sector (16kb) boundary
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4622) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4623) if (!len || (len & 0x03) || (offset & 0x00003FFF))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4624) return BFA_STATUS_FLASH_BAD_LEN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4625)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4626) if (type == BFA_FLASH_PART_MFG)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4627) return BFA_STATUS_EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4628)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4629) if (flash->op_busy) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4630) bfa_trc(flash, flash->op_busy);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4631) return BFA_STATUS_DEVBUSY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4632) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4633)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4634) flash->op_busy = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4635) flash->cbfn = cbfn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4636) flash->cbarg = cbarg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4637) flash->type = type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4638) flash->instance = instance;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4639) flash->residue = len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4640) flash->offset = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4641) flash->addr_off = offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4642) flash->ubuf = buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4643)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4644) bfa_flash_write_send(flash);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4645) return BFA_STATUS_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4646) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4647)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4648) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4649) * Read flash partition.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4650) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4651) * @param[in] flash - flash structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4652) * @param[in] type - flash partition type
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4653) * @param[in] instance - flash partition instance
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4654) * @param[in] buf - read data buffer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4655) * @param[in] len - data buffer length
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4656) * @param[in] offset - offset relative to the partition starting address
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4657) * @param[in] cbfn - callback function
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4658) * @param[in] cbarg - callback argument
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4659) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4660) * Return status.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4661) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4662) bfa_status_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4663) bfa_flash_read_part(struct bfa_flash_s *flash, enum bfa_flash_part_type type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4664) u8 instance, void *buf, u32 len, u32 offset,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4665) bfa_cb_flash_t cbfn, void *cbarg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4666) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4667) bfa_trc(flash, BFI_FLASH_H2I_READ_REQ);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4668) bfa_trc(flash, type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4669) bfa_trc(flash, instance);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4670) bfa_trc(flash, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4671) bfa_trc(flash, offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4672)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4673) if (!bfa_ioc_is_operational(flash->ioc))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4674) return BFA_STATUS_IOC_NON_OP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4675)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4676) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4677) * 'len' must be in word (4-byte) boundary
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4678) * 'offset' must be in sector (16kb) boundary
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4679) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4680) if (!len || (len & 0x03) || (offset & 0x00003FFF))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4681) return BFA_STATUS_FLASH_BAD_LEN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4682)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4683) if (flash->op_busy) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4684) bfa_trc(flash, flash->op_busy);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4685) return BFA_STATUS_DEVBUSY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4686) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4687)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4688) flash->op_busy = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4689) flash->cbfn = cbfn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4690) flash->cbarg = cbarg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4691) flash->type = type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4692) flash->instance = instance;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4693) flash->residue = len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4694) flash->offset = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4695) flash->addr_off = offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4696) flash->ubuf = buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4697) bfa_flash_read_send(flash);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4698)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4699) return BFA_STATUS_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4700) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4701)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4702) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4703) * DIAG module specific
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4704) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4705)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4706) #define BFA_DIAG_MEMTEST_TOV 50000 /* memtest timeout in msec */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4707) #define CT2_BFA_DIAG_MEMTEST_TOV (9*30*1000) /* 4.5 min */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4708)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4709) /* IOC event handler */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4710) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4711) bfa_diag_notify(void *diag_arg, enum bfa_ioc_event_e event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4712) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4713) struct bfa_diag_s *diag = diag_arg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4714)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4715) bfa_trc(diag, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4716) bfa_trc(diag, diag->block);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4717) bfa_trc(diag, diag->fwping.lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4718) bfa_trc(diag, diag->tsensor.lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4719)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4720) switch (event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4721) case BFA_IOC_E_DISABLED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4722) case BFA_IOC_E_FAILED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4723) if (diag->fwping.lock) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4724) diag->fwping.status = BFA_STATUS_IOC_FAILURE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4725) diag->fwping.cbfn(diag->fwping.cbarg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4726) diag->fwping.status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4727) diag->fwping.lock = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4728) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4729)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4730) if (diag->tsensor.lock) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4731) diag->tsensor.status = BFA_STATUS_IOC_FAILURE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4732) diag->tsensor.cbfn(diag->tsensor.cbarg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4733) diag->tsensor.status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4734) diag->tsensor.lock = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4735) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4736)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4737) if (diag->block) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4738) if (diag->timer_active) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4739) bfa_timer_stop(&diag->timer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4740) diag->timer_active = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4741) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4742)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4743) diag->status = BFA_STATUS_IOC_FAILURE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4744) diag->cbfn(diag->cbarg, diag->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4745) diag->block = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4746) }
^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) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4750) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4751) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4752) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4753)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4754) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4755) bfa_diag_memtest_done(void *cbarg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4756) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4757) struct bfa_diag_s *diag = cbarg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4758) struct bfa_ioc_s *ioc = diag->ioc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4759) struct bfa_diag_memtest_result *res = diag->result;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4760) u32 loff = BFI_BOOT_MEMTEST_RES_ADDR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4761) u32 pgnum, i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4762)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4763) pgnum = PSS_SMEM_PGNUM(ioc->ioc_regs.smem_pg0, loff);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4764) writel(pgnum, ioc->ioc_regs.host_page_num_fn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4765)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4766) for (i = 0; i < (sizeof(struct bfa_diag_memtest_result) /
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4767) sizeof(u32)); i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4768) /* read test result from smem */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4769) *((u32 *) res + i) =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4770) bfa_mem_read(ioc->ioc_regs.smem_page_start, loff);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4771) loff += sizeof(u32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4772) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4773)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4774) /* Reset IOC fwstates to BFI_IOC_UNINIT */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4775) bfa_ioc_reset_fwstate(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4776)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4777) res->status = swab32(res->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4778) bfa_trc(diag, res->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4779)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4780) if (res->status == BFI_BOOT_MEMTEST_RES_SIG)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4781) diag->status = BFA_STATUS_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4782) else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4783) diag->status = BFA_STATUS_MEMTEST_FAILED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4784) res->addr = swab32(res->addr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4785) res->exp = swab32(res->exp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4786) res->act = swab32(res->act);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4787) res->err_status = swab32(res->err_status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4788) res->err_status1 = swab32(res->err_status1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4789) res->err_addr = swab32(res->err_addr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4790) bfa_trc(diag, res->addr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4791) bfa_trc(diag, res->exp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4792) bfa_trc(diag, res->act);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4793) bfa_trc(diag, res->err_status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4794) bfa_trc(diag, res->err_status1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4795) bfa_trc(diag, res->err_addr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4796) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4797) diag->timer_active = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4798) diag->cbfn(diag->cbarg, diag->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4799) diag->block = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4800) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4801)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4802) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4803) * Firmware ping
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4804) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4805)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4806) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4807) * Perform DMA test directly
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4808) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4809) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4810) diag_fwping_send(struct bfa_diag_s *diag)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4811) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4812) struct bfi_diag_fwping_req_s *fwping_req;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4813) u32 i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4814)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4815) bfa_trc(diag, diag->fwping.dbuf_pa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4816)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4817) /* fill DMA area with pattern */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4818) for (i = 0; i < (BFI_DIAG_DMA_BUF_SZ >> 2); i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4819) *((u32 *)diag->fwping.dbuf_kva + i) = diag->fwping.data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4820)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4821) /* Fill mbox msg */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4822) fwping_req = (struct bfi_diag_fwping_req_s *)diag->fwping.mbcmd.msg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4823)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4824) /* Setup SG list */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4825) bfa_alen_set(&fwping_req->alen, BFI_DIAG_DMA_BUF_SZ,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4826) diag->fwping.dbuf_pa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4827) /* Set up dma count */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4828) fwping_req->count = cpu_to_be32(diag->fwping.count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4829) /* Set up data pattern */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4830) fwping_req->data = diag->fwping.data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4831)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4832) /* build host command */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4833) bfi_h2i_set(fwping_req->mh, BFI_MC_DIAG, BFI_DIAG_H2I_FWPING,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4834) bfa_ioc_portid(diag->ioc));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4835)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4836) /* send mbox cmd */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4837) bfa_ioc_mbox_queue(diag->ioc, &diag->fwping.mbcmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4838) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4839)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4840) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4841) diag_fwping_comp(struct bfa_diag_s *diag,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4842) struct bfi_diag_fwping_rsp_s *diag_rsp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4843) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4844) u32 rsp_data = diag_rsp->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4845) u8 rsp_dma_status = diag_rsp->dma_status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4846)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4847) bfa_trc(diag, rsp_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4848) bfa_trc(diag, rsp_dma_status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4849)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4850) if (rsp_dma_status == BFA_STATUS_OK) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4851) u32 i, pat;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4852) pat = (diag->fwping.count & 0x1) ? ~(diag->fwping.data) :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4853) diag->fwping.data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4854) /* Check mbox data */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4855) if (diag->fwping.data != rsp_data) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4856) bfa_trc(diag, rsp_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4857) diag->fwping.result->dmastatus =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4858) BFA_STATUS_DATACORRUPTED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4859) diag->fwping.status = BFA_STATUS_DATACORRUPTED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4860) diag->fwping.cbfn(diag->fwping.cbarg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4861) diag->fwping.status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4862) diag->fwping.lock = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4863) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4864) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4865) /* Check dma pattern */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4866) for (i = 0; i < (BFI_DIAG_DMA_BUF_SZ >> 2); i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4867) if (*((u32 *)diag->fwping.dbuf_kva + i) != pat) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4868) bfa_trc(diag, i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4869) bfa_trc(diag, pat);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4870) bfa_trc(diag,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4871) *((u32 *)diag->fwping.dbuf_kva + i));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4872) diag->fwping.result->dmastatus =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4873) BFA_STATUS_DATACORRUPTED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4874) diag->fwping.status = BFA_STATUS_DATACORRUPTED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4875) diag->fwping.cbfn(diag->fwping.cbarg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4876) diag->fwping.status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4877) diag->fwping.lock = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4878) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4879) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4880) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4881) diag->fwping.result->dmastatus = BFA_STATUS_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4882) diag->fwping.status = BFA_STATUS_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4883) diag->fwping.cbfn(diag->fwping.cbarg, diag->fwping.status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4884) diag->fwping.lock = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4885) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4886) diag->fwping.status = BFA_STATUS_HDMA_FAILED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4887) diag->fwping.cbfn(diag->fwping.cbarg, diag->fwping.status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4888) diag->fwping.lock = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4889) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4890) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4891)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4892) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4893) * Temperature Sensor
^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) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4897) diag_tempsensor_send(struct bfa_diag_s *diag)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4898) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4899) struct bfi_diag_ts_req_s *msg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4900)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4901) msg = (struct bfi_diag_ts_req_s *)diag->tsensor.mbcmd.msg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4902) bfa_trc(diag, msg->temp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4903) /* build host command */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4904) bfi_h2i_set(msg->mh, BFI_MC_DIAG, BFI_DIAG_H2I_TEMPSENSOR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4905) bfa_ioc_portid(diag->ioc));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4906) /* send mbox cmd */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4907) bfa_ioc_mbox_queue(diag->ioc, &diag->tsensor.mbcmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4908) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4909)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4910) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4911) diag_tempsensor_comp(struct bfa_diag_s *diag, bfi_diag_ts_rsp_t *rsp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4912) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4913) if (!diag->tsensor.lock) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4914) /* receiving response after ioc failure */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4915) bfa_trc(diag, diag->tsensor.lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4916) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4917) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4918)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4919) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4920) * ASIC junction tempsensor is a reg read operation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4921) * it will always return OK
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4922) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4923) diag->tsensor.temp->temp = be16_to_cpu(rsp->temp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4924) diag->tsensor.temp->ts_junc = rsp->ts_junc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4925) diag->tsensor.temp->ts_brd = rsp->ts_brd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4926)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4927) if (rsp->ts_brd) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4928) /* tsensor.temp->status is brd_temp status */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4929) diag->tsensor.temp->status = rsp->status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4930) if (rsp->status == BFA_STATUS_OK) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4931) diag->tsensor.temp->brd_temp =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4932) be16_to_cpu(rsp->brd_temp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4933) } else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4934) diag->tsensor.temp->brd_temp = 0;
^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) bfa_trc(diag, rsp->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4938) bfa_trc(diag, rsp->ts_junc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4939) bfa_trc(diag, rsp->temp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4940) bfa_trc(diag, rsp->ts_brd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4941) bfa_trc(diag, rsp->brd_temp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4942)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4943) /* tsensor status is always good bcos we always have junction temp */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4944) diag->tsensor.status = BFA_STATUS_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4945) diag->tsensor.cbfn(diag->tsensor.cbarg, diag->tsensor.status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4946) diag->tsensor.lock = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4947) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4948)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4949) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4950) * LED Test command
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4951) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4952) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4953) diag_ledtest_send(struct bfa_diag_s *diag, struct bfa_diag_ledtest_s *ledtest)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4954) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4955) struct bfi_diag_ledtest_req_s *msg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4956)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4957) msg = (struct bfi_diag_ledtest_req_s *)diag->ledtest.mbcmd.msg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4958) /* build host command */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4959) bfi_h2i_set(msg->mh, BFI_MC_DIAG, BFI_DIAG_H2I_LEDTEST,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4960) bfa_ioc_portid(diag->ioc));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4961)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4962) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4963) * convert the freq from N blinks per 10 sec to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4964) * crossbow ontime value. We do it here because division is need
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4965) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4966) if (ledtest->freq)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4967) ledtest->freq = 500 / ledtest->freq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4968)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4969) if (ledtest->freq == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4970) ledtest->freq = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4971)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4972) bfa_trc(diag, ledtest->freq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4973) /* mcpy(&ledtest_req->req, ledtest, sizeof(bfa_diag_ledtest_t)); */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4974) msg->cmd = (u8) ledtest->cmd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4975) msg->color = (u8) ledtest->color;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4976) msg->portid = bfa_ioc_portid(diag->ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4977) msg->led = ledtest->led;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4978) msg->freq = cpu_to_be16(ledtest->freq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4979)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4980) /* send mbox cmd */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4981) bfa_ioc_mbox_queue(diag->ioc, &diag->ledtest.mbcmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4982) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4983)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4984) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4985) diag_ledtest_comp(struct bfa_diag_s *diag, struct bfi_diag_ledtest_rsp_s *msg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4986) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4987) bfa_trc(diag, diag->ledtest.lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4988) diag->ledtest.lock = BFA_FALSE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4989) /* no bfa_cb_queue is needed because driver is not waiting */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4990) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4991)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4992) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4993) * Port beaconing
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4994) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4995) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4996) diag_portbeacon_send(struct bfa_diag_s *diag, bfa_boolean_t beacon, u32 sec)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4997) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4998) struct bfi_diag_portbeacon_req_s *msg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4999)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5000) msg = (struct bfi_diag_portbeacon_req_s *)diag->beacon.mbcmd.msg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5001) /* build host command */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5002) bfi_h2i_set(msg->mh, BFI_MC_DIAG, BFI_DIAG_H2I_PORTBEACON,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5003) bfa_ioc_portid(diag->ioc));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5004) msg->beacon = beacon;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5005) msg->period = cpu_to_be32(sec);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5006) /* send mbox cmd */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5007) bfa_ioc_mbox_queue(diag->ioc, &diag->beacon.mbcmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5008) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5009)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5010) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5011) diag_portbeacon_comp(struct bfa_diag_s *diag)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5012) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5013) bfa_trc(diag, diag->beacon.state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5014) diag->beacon.state = BFA_FALSE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5015) if (diag->cbfn_beacon)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5016) diag->cbfn_beacon(diag->dev, BFA_FALSE, diag->beacon.link_e2e);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5017) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5018)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5019) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5020) * Diag hmbox handler
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5021) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5022) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5023) bfa_diag_intr(void *diagarg, struct bfi_mbmsg_s *msg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5024) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5025) struct bfa_diag_s *diag = diagarg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5026)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5027) switch (msg->mh.msg_id) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5028) case BFI_DIAG_I2H_PORTBEACON:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5029) diag_portbeacon_comp(diag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5030) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5031) case BFI_DIAG_I2H_FWPING:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5032) diag_fwping_comp(diag, (struct bfi_diag_fwping_rsp_s *) msg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5033) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5034) case BFI_DIAG_I2H_TEMPSENSOR:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5035) diag_tempsensor_comp(diag, (bfi_diag_ts_rsp_t *) msg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5036) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5037) case BFI_DIAG_I2H_LEDTEST:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5038) diag_ledtest_comp(diag, (struct bfi_diag_ledtest_rsp_s *) msg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5039) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5040) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5041) bfa_trc(diag, msg->mh.msg_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5042) WARN_ON(1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5043) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5044) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5045)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5046) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5047) * Gen RAM Test
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5048) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5049) * @param[in] *diag - diag data struct
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5050) * @param[in] *memtest - mem test params input from upper layer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5051) * @param[in] pattern - mem test pattern
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5052) * @param[in] *result - mem test result
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5053) * @param[in] cbfn - mem test callback functioin
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5054) * @param[in] cbarg - callback functioin arg
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5055) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5056) * @param[out]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5057) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5058) bfa_status_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5059) bfa_diag_memtest(struct bfa_diag_s *diag, struct bfa_diag_memtest_s *memtest,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5060) u32 pattern, struct bfa_diag_memtest_result *result,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5061) bfa_cb_diag_t cbfn, void *cbarg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5062) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5063) u32 memtest_tov;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5064)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5065) bfa_trc(diag, pattern);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5066)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5067) if (!bfa_ioc_adapter_is_disabled(diag->ioc))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5068) return BFA_STATUS_ADAPTER_ENABLED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5069)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5070) /* check to see if there is another destructive diag cmd running */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5071) if (diag->block) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5072) bfa_trc(diag, diag->block);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5073) return BFA_STATUS_DEVBUSY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5074) } else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5075) diag->block = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5076)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5077) diag->result = result;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5078) diag->cbfn = cbfn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5079) diag->cbarg = cbarg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5080)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5081) /* download memtest code and take LPU0 out of reset */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5082) bfa_ioc_boot(diag->ioc, BFI_FWBOOT_TYPE_MEMTEST, BFI_FWBOOT_ENV_OS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5083)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5084) memtest_tov = (bfa_ioc_asic_gen(diag->ioc) == BFI_ASIC_GEN_CT2) ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5085) CT2_BFA_DIAG_MEMTEST_TOV : BFA_DIAG_MEMTEST_TOV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5086) bfa_timer_begin(diag->ioc->timer_mod, &diag->timer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5087) bfa_diag_memtest_done, diag, memtest_tov);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5088) diag->timer_active = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5089) return BFA_STATUS_OK;
^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) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5093) * DIAG firmware ping command
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5094) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5095) * @param[in] *diag - diag data struct
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5096) * @param[in] cnt - dma loop count for testing PCIE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5097) * @param[in] data - data pattern to pass in fw
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5098) * @param[in] *result - pt to bfa_diag_fwping_result_t data struct
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5099) * @param[in] cbfn - callback function
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5100) * @param[in] *cbarg - callback functioin arg
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5101) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5102) * @param[out]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5103) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5104) bfa_status_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5105) bfa_diag_fwping(struct bfa_diag_s *diag, u32 cnt, u32 data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5106) struct bfa_diag_results_fwping *result, bfa_cb_diag_t cbfn,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5107) void *cbarg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5108) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5109) bfa_trc(diag, cnt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5110) bfa_trc(diag, data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5111)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5112) if (!bfa_ioc_is_operational(diag->ioc))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5113) return BFA_STATUS_IOC_NON_OP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5114)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5115) if (bfa_asic_id_ct2(bfa_ioc_devid((diag->ioc))) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5116) ((diag->ioc)->clscode == BFI_PCIFN_CLASS_ETH))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5117) return BFA_STATUS_CMD_NOTSUPP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5118)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5119) /* check to see if there is another destructive diag cmd running */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5120) if (diag->block || diag->fwping.lock) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5121) bfa_trc(diag, diag->block);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5122) bfa_trc(diag, diag->fwping.lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5123) return BFA_STATUS_DEVBUSY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5124) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5125)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5126) /* Initialization */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5127) diag->fwping.lock = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5128) diag->fwping.cbfn = cbfn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5129) diag->fwping.cbarg = cbarg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5130) diag->fwping.result = result;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5131) diag->fwping.data = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5132) diag->fwping.count = cnt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5133)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5134) /* Init test results */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5135) diag->fwping.result->data = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5136) diag->fwping.result->status = BFA_STATUS_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5137)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5138) /* kick off the first ping */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5139) diag_fwping_send(diag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5140) return BFA_STATUS_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5141) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5142)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5143) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5144) * Read Temperature Sensor
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5145) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5146) * @param[in] *diag - diag data struct
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5147) * @param[in] *result - pt to bfa_diag_temp_t data struct
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5148) * @param[in] cbfn - callback function
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5149) * @param[in] *cbarg - callback functioin arg
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5150) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5151) * @param[out]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5152) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5153) bfa_status_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5154) bfa_diag_tsensor_query(struct bfa_diag_s *diag,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5155) struct bfa_diag_results_tempsensor_s *result,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5156) bfa_cb_diag_t cbfn, void *cbarg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5157) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5158) /* check to see if there is a destructive diag cmd running */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5159) if (diag->block || diag->tsensor.lock) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5160) bfa_trc(diag, diag->block);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5161) bfa_trc(diag, diag->tsensor.lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5162) return BFA_STATUS_DEVBUSY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5163) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5164)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5165) if (!bfa_ioc_is_operational(diag->ioc))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5166) return BFA_STATUS_IOC_NON_OP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5167)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5168) /* Init diag mod params */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5169) diag->tsensor.lock = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5170) diag->tsensor.temp = result;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5171) diag->tsensor.cbfn = cbfn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5172) diag->tsensor.cbarg = cbarg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5173) diag->tsensor.status = BFA_STATUS_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5174)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5175) /* Send msg to fw */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5176) diag_tempsensor_send(diag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5177)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5178) return BFA_STATUS_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5179) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5180)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5181) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5182) * LED Test command
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5183) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5184) * @param[in] *diag - diag data struct
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5185) * @param[in] *ledtest - pt to ledtest data structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5186) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5187) * @param[out]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5188) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5189) bfa_status_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5190) bfa_diag_ledtest(struct bfa_diag_s *diag, struct bfa_diag_ledtest_s *ledtest)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5191) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5192) bfa_trc(diag, ledtest->cmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5193)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5194) if (!bfa_ioc_is_operational(diag->ioc))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5195) return BFA_STATUS_IOC_NON_OP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5196)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5197) if (diag->beacon.state)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5198) return BFA_STATUS_BEACON_ON;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5199)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5200) if (diag->ledtest.lock)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5201) return BFA_STATUS_LEDTEST_OP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5202)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5203) /* Send msg to fw */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5204) diag->ledtest.lock = BFA_TRUE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5205) diag_ledtest_send(diag, ledtest);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5206)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5207) return BFA_STATUS_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5208) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5209)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5210) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5211) * Port beaconing command
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5212) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5213) * @param[in] *diag - diag data struct
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5214) * @param[in] beacon - port beaconing 1:ON 0:OFF
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5215) * @param[in] link_e2e_beacon - link beaconing 1:ON 0:OFF
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5216) * @param[in] sec - beaconing duration in seconds
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5217) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5218) * @param[out]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5219) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5220) bfa_status_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5221) bfa_diag_beacon_port(struct bfa_diag_s *diag, bfa_boolean_t beacon,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5222) bfa_boolean_t link_e2e_beacon, uint32_t sec)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5223) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5224) bfa_trc(diag, beacon);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5225) bfa_trc(diag, link_e2e_beacon);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5226) bfa_trc(diag, sec);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5227)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5228) if (!bfa_ioc_is_operational(diag->ioc))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5229) return BFA_STATUS_IOC_NON_OP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5230)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5231) if (diag->ledtest.lock)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5232) return BFA_STATUS_LEDTEST_OP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5233)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5234) if (diag->beacon.state && beacon) /* beacon alread on */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5235) return BFA_STATUS_BEACON_ON;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5236)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5237) diag->beacon.state = beacon;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5238) diag->beacon.link_e2e = link_e2e_beacon;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5239) if (diag->cbfn_beacon)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5240) diag->cbfn_beacon(diag->dev, beacon, link_e2e_beacon);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5241)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5242) /* Send msg to fw */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5243) diag_portbeacon_send(diag, beacon, sec);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5244)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5245) return BFA_STATUS_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5246) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5247)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5248) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5249) * Return DMA memory needed by diag module.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5250) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5251) u32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5252) bfa_diag_meminfo(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5253) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5254) return BFA_ROUNDUP(BFI_DIAG_DMA_BUF_SZ, BFA_DMA_ALIGN_SZ);
^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) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5258) * Attach virtual and physical memory for Diag.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5259) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5260) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5261) bfa_diag_attach(struct bfa_diag_s *diag, struct bfa_ioc_s *ioc, void *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5262) bfa_cb_diag_beacon_t cbfn_beacon, struct bfa_trc_mod_s *trcmod)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5263) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5264) diag->dev = dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5265) diag->ioc = ioc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5266) diag->trcmod = trcmod;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5267)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5268) diag->block = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5269) diag->cbfn = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5270) diag->cbarg = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5271) diag->result = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5272) diag->cbfn_beacon = cbfn_beacon;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5273)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5274) bfa_ioc_mbox_regisr(diag->ioc, BFI_MC_DIAG, bfa_diag_intr, diag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5275) bfa_q_qe_init(&diag->ioc_notify);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5276) bfa_ioc_notify_init(&diag->ioc_notify, bfa_diag_notify, diag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5277) list_add_tail(&diag->ioc_notify.qe, &diag->ioc->notify_q);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5278) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5279)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5280) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5281) bfa_diag_memclaim(struct bfa_diag_s *diag, u8 *dm_kva, u64 dm_pa)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5282) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5283) diag->fwping.dbuf_kva = dm_kva;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5284) diag->fwping.dbuf_pa = dm_pa;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5285) memset(diag->fwping.dbuf_kva, 0, BFI_DIAG_DMA_BUF_SZ);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5286) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5287)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5288) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5289) * PHY module specific
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5290) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5291) #define BFA_PHY_DMA_BUF_SZ 0x02000 /* 8k dma buffer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5292) #define BFA_PHY_LOCK_STATUS 0x018878 /* phy semaphore status reg */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5293)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5294) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5295) bfa_phy_ntoh32(u32 *obuf, u32 *ibuf, int sz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5296) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5297) int i, m = sz >> 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5298)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5299) for (i = 0; i < m; i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5300) obuf[i] = be32_to_cpu(ibuf[i]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5301) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5302)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5303) static bfa_boolean_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5304) bfa_phy_present(struct bfa_phy_s *phy)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5305) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5306) return (phy->ioc->attr->card_type == BFA_MFG_TYPE_LIGHTNING);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5307) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5308)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5309) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5310) bfa_phy_notify(void *cbarg, enum bfa_ioc_event_e event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5311) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5312) struct bfa_phy_s *phy = cbarg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5313)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5314) bfa_trc(phy, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5315)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5316) switch (event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5317) case BFA_IOC_E_DISABLED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5318) case BFA_IOC_E_FAILED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5319) if (phy->op_busy) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5320) phy->status = BFA_STATUS_IOC_FAILURE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5321) phy->cbfn(phy->cbarg, phy->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5322) phy->op_busy = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5323) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5324) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5325)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5326) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5327) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5328) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5329) }
^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) * Send phy attribute query request.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5333) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5334) * @param[in] cbarg - callback argument
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5335) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5336) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5337) bfa_phy_query_send(void *cbarg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5338) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5339) struct bfa_phy_s *phy = cbarg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5340) struct bfi_phy_query_req_s *msg =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5341) (struct bfi_phy_query_req_s *) phy->mb.msg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5342)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5343) msg->instance = phy->instance;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5344) bfi_h2i_set(msg->mh, BFI_MC_PHY, BFI_PHY_H2I_QUERY_REQ,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5345) bfa_ioc_portid(phy->ioc));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5346) bfa_alen_set(&msg->alen, sizeof(struct bfa_phy_attr_s), phy->dbuf_pa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5347) bfa_ioc_mbox_queue(phy->ioc, &phy->mb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5348) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5349)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5350) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5351) * Send phy write request.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5352) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5353) * @param[in] cbarg - callback argument
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5354) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5355) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5356) bfa_phy_write_send(void *cbarg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5357) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5358) struct bfa_phy_s *phy = cbarg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5359) struct bfi_phy_write_req_s *msg =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5360) (struct bfi_phy_write_req_s *) phy->mb.msg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5361) u32 len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5362) u16 *buf, *dbuf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5363) int i, sz;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5364)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5365) msg->instance = phy->instance;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5366) msg->offset = cpu_to_be32(phy->addr_off + phy->offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5367) len = (phy->residue < BFA_PHY_DMA_BUF_SZ) ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5368) phy->residue : BFA_PHY_DMA_BUF_SZ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5369) msg->length = cpu_to_be32(len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5370)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5371) /* indicate if it's the last msg of the whole write operation */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5372) msg->last = (len == phy->residue) ? 1 : 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5373)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5374) bfi_h2i_set(msg->mh, BFI_MC_PHY, BFI_PHY_H2I_WRITE_REQ,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5375) bfa_ioc_portid(phy->ioc));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5376) bfa_alen_set(&msg->alen, len, phy->dbuf_pa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5377)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5378) buf = (u16 *) (phy->ubuf + phy->offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5379) dbuf = (u16 *)phy->dbuf_kva;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5380) sz = len >> 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5381) for (i = 0; i < sz; i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5382) buf[i] = cpu_to_be16(dbuf[i]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5383)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5384) bfa_ioc_mbox_queue(phy->ioc, &phy->mb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5385)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5386) phy->residue -= len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5387) phy->offset += len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5388) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5389)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5390) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5391) * Send phy read request.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5392) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5393) * @param[in] cbarg - callback argument
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5394) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5395) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5396) bfa_phy_read_send(void *cbarg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5397) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5398) struct bfa_phy_s *phy = cbarg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5399) struct bfi_phy_read_req_s *msg =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5400) (struct bfi_phy_read_req_s *) phy->mb.msg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5401) u32 len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5402)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5403) msg->instance = phy->instance;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5404) msg->offset = cpu_to_be32(phy->addr_off + phy->offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5405) len = (phy->residue < BFA_PHY_DMA_BUF_SZ) ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5406) phy->residue : BFA_PHY_DMA_BUF_SZ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5407) msg->length = cpu_to_be32(len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5408) bfi_h2i_set(msg->mh, BFI_MC_PHY, BFI_PHY_H2I_READ_REQ,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5409) bfa_ioc_portid(phy->ioc));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5410) bfa_alen_set(&msg->alen, len, phy->dbuf_pa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5411) bfa_ioc_mbox_queue(phy->ioc, &phy->mb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5412) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5413)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5414) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5415) * Send phy stats request.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5416) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5417) * @param[in] cbarg - callback argument
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5418) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5419) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5420) bfa_phy_stats_send(void *cbarg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5421) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5422) struct bfa_phy_s *phy = cbarg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5423) struct bfi_phy_stats_req_s *msg =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5424) (struct bfi_phy_stats_req_s *) phy->mb.msg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5425)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5426) msg->instance = phy->instance;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5427) bfi_h2i_set(msg->mh, BFI_MC_PHY, BFI_PHY_H2I_STATS_REQ,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5428) bfa_ioc_portid(phy->ioc));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5429) bfa_alen_set(&msg->alen, sizeof(struct bfa_phy_stats_s), phy->dbuf_pa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5430) bfa_ioc_mbox_queue(phy->ioc, &phy->mb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5431) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5432)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5433) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5434) * Flash memory info API.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5435) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5436) * @param[in] mincfg - minimal cfg variable
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5437) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5438) u32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5439) bfa_phy_meminfo(bfa_boolean_t mincfg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5440) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5441) /* min driver doesn't need phy */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5442) if (mincfg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5443) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5444)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5445) return BFA_ROUNDUP(BFA_PHY_DMA_BUF_SZ, BFA_DMA_ALIGN_SZ);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5446) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5447)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5448) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5449) * Flash attach API.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5450) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5451) * @param[in] phy - phy structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5452) * @param[in] ioc - ioc structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5453) * @param[in] dev - device structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5454) * @param[in] trcmod - trace module
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5455) * @param[in] logmod - log module
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5456) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5457) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5458) bfa_phy_attach(struct bfa_phy_s *phy, struct bfa_ioc_s *ioc, void *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5459) struct bfa_trc_mod_s *trcmod, bfa_boolean_t mincfg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5460) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5461) phy->ioc = ioc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5462) phy->trcmod = trcmod;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5463) phy->cbfn = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5464) phy->cbarg = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5465) phy->op_busy = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5466)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5467) bfa_ioc_mbox_regisr(phy->ioc, BFI_MC_PHY, bfa_phy_intr, phy);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5468) bfa_q_qe_init(&phy->ioc_notify);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5469) bfa_ioc_notify_init(&phy->ioc_notify, bfa_phy_notify, phy);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5470) list_add_tail(&phy->ioc_notify.qe, &phy->ioc->notify_q);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5471)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5472) /* min driver doesn't need phy */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5473) if (mincfg) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5474) phy->dbuf_kva = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5475) phy->dbuf_pa = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5476) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5477) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5478)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5479) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5480) * Claim memory for phy
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5481) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5482) * @param[in] phy - phy structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5483) * @param[in] dm_kva - pointer to virtual memory address
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5484) * @param[in] dm_pa - physical memory address
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5485) * @param[in] mincfg - minimal cfg variable
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5486) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5487) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5488) bfa_phy_memclaim(struct bfa_phy_s *phy, u8 *dm_kva, u64 dm_pa,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5489) bfa_boolean_t mincfg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5490) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5491) if (mincfg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5492) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5493)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5494) phy->dbuf_kva = dm_kva;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5495) phy->dbuf_pa = dm_pa;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5496) memset(phy->dbuf_kva, 0, BFA_PHY_DMA_BUF_SZ);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5497) dm_kva += BFA_ROUNDUP(BFA_PHY_DMA_BUF_SZ, BFA_DMA_ALIGN_SZ);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5498) dm_pa += BFA_ROUNDUP(BFA_PHY_DMA_BUF_SZ, BFA_DMA_ALIGN_SZ);
^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) bfa_boolean_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5502) bfa_phy_busy(struct bfa_ioc_s *ioc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5503) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5504) void __iomem *rb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5505)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5506) rb = bfa_ioc_bar0(ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5507) return readl(rb + BFA_PHY_LOCK_STATUS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5508) }
^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) * Get phy attribute.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5512) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5513) * @param[in] phy - phy structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5514) * @param[in] attr - phy attribute structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5515) * @param[in] cbfn - callback function
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5516) * @param[in] cbarg - callback argument
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5517) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5518) * Return status.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5519) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5520) bfa_status_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5521) bfa_phy_get_attr(struct bfa_phy_s *phy, u8 instance,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5522) struct bfa_phy_attr_s *attr, bfa_cb_phy_t cbfn, void *cbarg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5523) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5524) bfa_trc(phy, BFI_PHY_H2I_QUERY_REQ);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5525) bfa_trc(phy, instance);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5526)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5527) if (!bfa_phy_present(phy))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5528) return BFA_STATUS_PHY_NOT_PRESENT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5529)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5530) if (!bfa_ioc_is_operational(phy->ioc))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5531) return BFA_STATUS_IOC_NON_OP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5532)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5533) if (phy->op_busy || bfa_phy_busy(phy->ioc)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5534) bfa_trc(phy, phy->op_busy);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5535) return BFA_STATUS_DEVBUSY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5536) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5537)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5538) phy->op_busy = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5539) phy->cbfn = cbfn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5540) phy->cbarg = cbarg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5541) phy->instance = instance;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5542) phy->ubuf = (uint8_t *) attr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5543) bfa_phy_query_send(phy);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5544)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5545) return BFA_STATUS_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5546) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5547)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5548) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5549) * Get phy stats.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5550) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5551) * @param[in] phy - phy structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5552) * @param[in] instance - phy image instance
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5553) * @param[in] stats - pointer to phy stats
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5554) * @param[in] cbfn - callback function
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5555) * @param[in] cbarg - callback argument
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5556) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5557) * Return status.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5558) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5559) bfa_status_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5560) bfa_phy_get_stats(struct bfa_phy_s *phy, u8 instance,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5561) struct bfa_phy_stats_s *stats,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5562) bfa_cb_phy_t cbfn, void *cbarg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5563) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5564) bfa_trc(phy, BFI_PHY_H2I_STATS_REQ);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5565) bfa_trc(phy, instance);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5566)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5567) if (!bfa_phy_present(phy))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5568) return BFA_STATUS_PHY_NOT_PRESENT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5569)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5570) if (!bfa_ioc_is_operational(phy->ioc))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5571) return BFA_STATUS_IOC_NON_OP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5572)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5573) if (phy->op_busy || bfa_phy_busy(phy->ioc)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5574) bfa_trc(phy, phy->op_busy);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5575) return BFA_STATUS_DEVBUSY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5576) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5577)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5578) phy->op_busy = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5579) phy->cbfn = cbfn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5580) phy->cbarg = cbarg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5581) phy->instance = instance;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5582) phy->ubuf = (u8 *) stats;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5583) bfa_phy_stats_send(phy);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5584)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5585) return BFA_STATUS_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5586) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5587)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5588) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5589) * Update phy image.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5590) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5591) * @param[in] phy - phy structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5592) * @param[in] instance - phy image instance
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5593) * @param[in] buf - update data buffer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5594) * @param[in] len - data buffer length
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5595) * @param[in] offset - offset relative to starting address
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5596) * @param[in] cbfn - callback function
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5597) * @param[in] cbarg - callback argument
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5598) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5599) * Return status.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5600) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5601) bfa_status_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5602) bfa_phy_update(struct bfa_phy_s *phy, u8 instance,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5603) void *buf, u32 len, u32 offset,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5604) bfa_cb_phy_t cbfn, void *cbarg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5605) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5606) bfa_trc(phy, BFI_PHY_H2I_WRITE_REQ);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5607) bfa_trc(phy, instance);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5608) bfa_trc(phy, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5609) bfa_trc(phy, offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5610)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5611) if (!bfa_phy_present(phy))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5612) return BFA_STATUS_PHY_NOT_PRESENT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5613)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5614) if (!bfa_ioc_is_operational(phy->ioc))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5615) return BFA_STATUS_IOC_NON_OP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5616)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5617) /* 'len' must be in word (4-byte) boundary */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5618) if (!len || (len & 0x03))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5619) return BFA_STATUS_FAILED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5620)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5621) if (phy->op_busy || bfa_phy_busy(phy->ioc)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5622) bfa_trc(phy, phy->op_busy);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5623) return BFA_STATUS_DEVBUSY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5624) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5625)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5626) phy->op_busy = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5627) phy->cbfn = cbfn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5628) phy->cbarg = cbarg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5629) phy->instance = instance;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5630) phy->residue = len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5631) phy->offset = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5632) phy->addr_off = offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5633) phy->ubuf = buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5634)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5635) bfa_phy_write_send(phy);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5636) return BFA_STATUS_OK;
^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) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5640) * Read phy image.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5641) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5642) * @param[in] phy - phy structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5643) * @param[in] instance - phy image instance
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5644) * @param[in] buf - read data buffer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5645) * @param[in] len - data buffer length
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5646) * @param[in] offset - offset relative to starting address
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5647) * @param[in] cbfn - callback function
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5648) * @param[in] cbarg - callback argument
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5649) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5650) * Return status.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5651) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5652) bfa_status_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5653) bfa_phy_read(struct bfa_phy_s *phy, u8 instance,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5654) void *buf, u32 len, u32 offset,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5655) bfa_cb_phy_t cbfn, void *cbarg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5656) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5657) bfa_trc(phy, BFI_PHY_H2I_READ_REQ);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5658) bfa_trc(phy, instance);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5659) bfa_trc(phy, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5660) bfa_trc(phy, offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5661)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5662) if (!bfa_phy_present(phy))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5663) return BFA_STATUS_PHY_NOT_PRESENT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5664)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5665) if (!bfa_ioc_is_operational(phy->ioc))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5666) return BFA_STATUS_IOC_NON_OP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5667)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5668) /* 'len' must be in word (4-byte) boundary */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5669) if (!len || (len & 0x03))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5670) return BFA_STATUS_FAILED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5671)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5672) if (phy->op_busy || bfa_phy_busy(phy->ioc)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5673) bfa_trc(phy, phy->op_busy);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5674) return BFA_STATUS_DEVBUSY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5675) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5676)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5677) phy->op_busy = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5678) phy->cbfn = cbfn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5679) phy->cbarg = cbarg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5680) phy->instance = instance;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5681) phy->residue = len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5682) phy->offset = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5683) phy->addr_off = offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5684) phy->ubuf = buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5685) bfa_phy_read_send(phy);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5686)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5687) return BFA_STATUS_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5688) }
^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) * Process phy response messages upon receiving interrupts.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5692) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5693) * @param[in] phyarg - phy structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5694) * @param[in] msg - message structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5695) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5696) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5697) bfa_phy_intr(void *phyarg, struct bfi_mbmsg_s *msg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5698) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5699) struct bfa_phy_s *phy = phyarg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5700) u32 status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5701)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5702) union {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5703) struct bfi_phy_query_rsp_s *query;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5704) struct bfi_phy_stats_rsp_s *stats;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5705) struct bfi_phy_write_rsp_s *write;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5706) struct bfi_phy_read_rsp_s *read;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5707) struct bfi_mbmsg_s *msg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5708) } m;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5709)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5710) m.msg = msg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5711) bfa_trc(phy, msg->mh.msg_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5712)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5713) if (!phy->op_busy) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5714) /* receiving response after ioc failure */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5715) bfa_trc(phy, 0x9999);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5716) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5717) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5718)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5719) switch (msg->mh.msg_id) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5720) case BFI_PHY_I2H_QUERY_RSP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5721) status = be32_to_cpu(m.query->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5722) bfa_trc(phy, status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5723)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5724) if (status == BFA_STATUS_OK) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5725) struct bfa_phy_attr_s *attr =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5726) (struct bfa_phy_attr_s *) phy->ubuf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5727) bfa_phy_ntoh32((u32 *)attr, (u32 *)phy->dbuf_kva,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5728) sizeof(struct bfa_phy_attr_s));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5729) bfa_trc(phy, attr->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5730) bfa_trc(phy, attr->length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5731) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5732)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5733) phy->status = status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5734) phy->op_busy = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5735) if (phy->cbfn)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5736) phy->cbfn(phy->cbarg, phy->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5737) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5738) case BFI_PHY_I2H_STATS_RSP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5739) status = be32_to_cpu(m.stats->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5740) bfa_trc(phy, status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5741)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5742) if (status == BFA_STATUS_OK) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5743) struct bfa_phy_stats_s *stats =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5744) (struct bfa_phy_stats_s *) phy->ubuf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5745) bfa_phy_ntoh32((u32 *)stats, (u32 *)phy->dbuf_kva,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5746) sizeof(struct bfa_phy_stats_s));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5747) bfa_trc(phy, stats->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5748) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5749)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5750) phy->status = status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5751) phy->op_busy = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5752) if (phy->cbfn)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5753) phy->cbfn(phy->cbarg, phy->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5754) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5755) case BFI_PHY_I2H_WRITE_RSP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5756) status = be32_to_cpu(m.write->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5757) bfa_trc(phy, status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5758)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5759) if (status != BFA_STATUS_OK || phy->residue == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5760) phy->status = status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5761) phy->op_busy = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5762) if (phy->cbfn)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5763) phy->cbfn(phy->cbarg, phy->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5764) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5765) bfa_trc(phy, phy->offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5766) bfa_phy_write_send(phy);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5767) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5768) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5769) case BFI_PHY_I2H_READ_RSP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5770) status = be32_to_cpu(m.read->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5771) bfa_trc(phy, status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5772)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5773) if (status != BFA_STATUS_OK) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5774) phy->status = status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5775) phy->op_busy = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5776) if (phy->cbfn)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5777) phy->cbfn(phy->cbarg, phy->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5778) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5779) u32 len = be32_to_cpu(m.read->length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5780) u16 *buf = (u16 *)(phy->ubuf + phy->offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5781) u16 *dbuf = (u16 *)phy->dbuf_kva;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5782) int i, sz = len >> 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5783)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5784) bfa_trc(phy, phy->offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5785) bfa_trc(phy, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5786)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5787) for (i = 0; i < sz; i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5788) buf[i] = be16_to_cpu(dbuf[i]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5789)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5790) phy->residue -= len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5791) phy->offset += len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5792)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5793) if (phy->residue == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5794) phy->status = status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5795) phy->op_busy = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5796) if (phy->cbfn)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5797) phy->cbfn(phy->cbarg, phy->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5798) } else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5799) bfa_phy_read_send(phy);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5800) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5801) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5802) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5803) WARN_ON(1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5804) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5805) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5806)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5807) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5808) * DCONF state machine events
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5809) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5810) enum bfa_dconf_event {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5811) BFA_DCONF_SM_INIT = 1, /* dconf Init */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5812) BFA_DCONF_SM_FLASH_COMP = 2, /* read/write to flash */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5813) BFA_DCONF_SM_WR = 3, /* binding change, map */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5814) BFA_DCONF_SM_TIMEOUT = 4, /* Start timer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5815) BFA_DCONF_SM_EXIT = 5, /* exit dconf module */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5816) BFA_DCONF_SM_IOCDISABLE = 6, /* IOC disable event */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5817) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5818)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5819) /* forward declaration of DCONF state machine */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5820) static void bfa_dconf_sm_uninit(struct bfa_dconf_mod_s *dconf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5821) enum bfa_dconf_event event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5822) static void bfa_dconf_sm_flash_read(struct bfa_dconf_mod_s *dconf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5823) enum bfa_dconf_event event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5824) static void bfa_dconf_sm_ready(struct bfa_dconf_mod_s *dconf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5825) enum bfa_dconf_event event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5826) static void bfa_dconf_sm_dirty(struct bfa_dconf_mod_s *dconf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5827) enum bfa_dconf_event event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5828) static void bfa_dconf_sm_sync(struct bfa_dconf_mod_s *dconf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5829) enum bfa_dconf_event event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5830) static void bfa_dconf_sm_final_sync(struct bfa_dconf_mod_s *dconf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5831) enum bfa_dconf_event event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5832) static void bfa_dconf_sm_iocdown_dirty(struct bfa_dconf_mod_s *dconf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5833) enum bfa_dconf_event event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5834)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5835) static void bfa_dconf_cbfn(void *dconf, bfa_status_t status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5836) static void bfa_dconf_timer(void *cbarg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5837) static bfa_status_t bfa_dconf_flash_write(struct bfa_dconf_mod_s *dconf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5838) static void bfa_dconf_init_cb(void *arg, bfa_status_t status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5839)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5840) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5841) * Beginning state of dconf module. Waiting for an event to start.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5842) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5843) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5844) bfa_dconf_sm_uninit(struct bfa_dconf_mod_s *dconf, enum bfa_dconf_event event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5845) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5846) bfa_status_t bfa_status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5847) bfa_trc(dconf->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5848)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5849) switch (event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5850) case BFA_DCONF_SM_INIT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5851) if (dconf->min_cfg) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5852) bfa_trc(dconf->bfa, dconf->min_cfg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5853) bfa_fsm_send_event(&dconf->bfa->iocfc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5854) IOCFC_E_DCONF_DONE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5855) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5856) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5857) bfa_sm_set_state(dconf, bfa_dconf_sm_flash_read);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5858) bfa_timer_start(dconf->bfa, &dconf->timer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5859) bfa_dconf_timer, dconf, 2 * BFA_DCONF_UPDATE_TOV);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5860) bfa_status = bfa_flash_read_part(BFA_FLASH(dconf->bfa),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5861) BFA_FLASH_PART_DRV, dconf->instance,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5862) dconf->dconf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5863) sizeof(struct bfa_dconf_s), 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5864) bfa_dconf_init_cb, dconf->bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5865) if (bfa_status != BFA_STATUS_OK) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5866) bfa_timer_stop(&dconf->timer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5867) bfa_dconf_init_cb(dconf->bfa, BFA_STATUS_FAILED);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5868) bfa_sm_set_state(dconf, bfa_dconf_sm_uninit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5869) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5870) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5871) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5872) case BFA_DCONF_SM_EXIT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5873) bfa_fsm_send_event(&dconf->bfa->iocfc, IOCFC_E_DCONF_DONE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5874) case BFA_DCONF_SM_IOCDISABLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5875) case BFA_DCONF_SM_WR:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5876) case BFA_DCONF_SM_FLASH_COMP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5877) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5878) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5879) bfa_sm_fault(dconf->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5880) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5881) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5882)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5883) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5884) * Read flash for dconf entries and make a call back to the driver once done.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5885) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5886) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5887) bfa_dconf_sm_flash_read(struct bfa_dconf_mod_s *dconf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5888) enum bfa_dconf_event event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5889) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5890) bfa_trc(dconf->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5891)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5892) switch (event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5893) case BFA_DCONF_SM_FLASH_COMP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5894) bfa_timer_stop(&dconf->timer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5895) bfa_sm_set_state(dconf, bfa_dconf_sm_ready);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5896) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5897) case BFA_DCONF_SM_TIMEOUT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5898) bfa_sm_set_state(dconf, bfa_dconf_sm_ready);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5899) bfa_ioc_suspend(&dconf->bfa->ioc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5900) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5901) case BFA_DCONF_SM_EXIT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5902) bfa_timer_stop(&dconf->timer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5903) bfa_sm_set_state(dconf, bfa_dconf_sm_uninit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5904) bfa_fsm_send_event(&dconf->bfa->iocfc, IOCFC_E_DCONF_DONE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5905) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5906) case BFA_DCONF_SM_IOCDISABLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5907) bfa_timer_stop(&dconf->timer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5908) bfa_sm_set_state(dconf, bfa_dconf_sm_uninit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5909) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5910) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5911) bfa_sm_fault(dconf->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5912) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5913) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5914)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5915) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5916) * DCONF Module is in ready state. Has completed the initialization.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5917) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5918) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5919) bfa_dconf_sm_ready(struct bfa_dconf_mod_s *dconf, enum bfa_dconf_event event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5920) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5921) bfa_trc(dconf->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5922)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5923) switch (event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5924) case BFA_DCONF_SM_WR:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5925) bfa_timer_start(dconf->bfa, &dconf->timer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5926) bfa_dconf_timer, dconf, BFA_DCONF_UPDATE_TOV);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5927) bfa_sm_set_state(dconf, bfa_dconf_sm_dirty);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5928) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5929) case BFA_DCONF_SM_EXIT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5930) bfa_sm_set_state(dconf, bfa_dconf_sm_uninit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5931) bfa_fsm_send_event(&dconf->bfa->iocfc, IOCFC_E_DCONF_DONE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5932) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5933) case BFA_DCONF_SM_INIT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5934) case BFA_DCONF_SM_IOCDISABLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5935) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5936) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5937) bfa_sm_fault(dconf->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5938) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5939) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5940)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5941) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5942) * entries are dirty, write back to the flash.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5943) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5944)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5945) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5946) bfa_dconf_sm_dirty(struct bfa_dconf_mod_s *dconf, enum bfa_dconf_event event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5947) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5948) bfa_trc(dconf->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5949)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5950) switch (event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5951) case BFA_DCONF_SM_TIMEOUT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5952) bfa_sm_set_state(dconf, bfa_dconf_sm_sync);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5953) bfa_dconf_flash_write(dconf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5954) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5955) case BFA_DCONF_SM_WR:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5956) bfa_timer_stop(&dconf->timer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5957) bfa_timer_start(dconf->bfa, &dconf->timer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5958) bfa_dconf_timer, dconf, BFA_DCONF_UPDATE_TOV);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5959) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5960) case BFA_DCONF_SM_EXIT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5961) bfa_timer_stop(&dconf->timer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5962) bfa_timer_start(dconf->bfa, &dconf->timer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5963) bfa_dconf_timer, dconf, BFA_DCONF_UPDATE_TOV);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5964) bfa_sm_set_state(dconf, bfa_dconf_sm_final_sync);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5965) bfa_dconf_flash_write(dconf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5966) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5967) case BFA_DCONF_SM_FLASH_COMP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5968) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5969) case BFA_DCONF_SM_IOCDISABLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5970) bfa_timer_stop(&dconf->timer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5971) bfa_sm_set_state(dconf, bfa_dconf_sm_iocdown_dirty);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5972) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5973) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5974) bfa_sm_fault(dconf->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5975) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5976) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5977)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5978) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5979) * Sync the dconf entries to the flash.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5980) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5981) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5982) bfa_dconf_sm_final_sync(struct bfa_dconf_mod_s *dconf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5983) enum bfa_dconf_event event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5984) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5985) bfa_trc(dconf->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5986)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5987) switch (event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5988) case BFA_DCONF_SM_IOCDISABLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5989) case BFA_DCONF_SM_FLASH_COMP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5990) bfa_timer_stop(&dconf->timer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5991) fallthrough;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5992) case BFA_DCONF_SM_TIMEOUT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5993) bfa_sm_set_state(dconf, bfa_dconf_sm_uninit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5994) bfa_fsm_send_event(&dconf->bfa->iocfc, IOCFC_E_DCONF_DONE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5995) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5996) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5997) bfa_sm_fault(dconf->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5998) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5999) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6000)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6001) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6002) bfa_dconf_sm_sync(struct bfa_dconf_mod_s *dconf, enum bfa_dconf_event event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6003) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6004) bfa_trc(dconf->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6005)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6006) switch (event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6007) case BFA_DCONF_SM_FLASH_COMP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6008) bfa_sm_set_state(dconf, bfa_dconf_sm_ready);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6009) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6010) case BFA_DCONF_SM_WR:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6011) bfa_timer_start(dconf->bfa, &dconf->timer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6012) bfa_dconf_timer, dconf, BFA_DCONF_UPDATE_TOV);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6013) bfa_sm_set_state(dconf, bfa_dconf_sm_dirty);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6014) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6015) case BFA_DCONF_SM_EXIT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6016) bfa_timer_start(dconf->bfa, &dconf->timer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6017) bfa_dconf_timer, dconf, BFA_DCONF_UPDATE_TOV);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6018) bfa_sm_set_state(dconf, bfa_dconf_sm_final_sync);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6019) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6020) case BFA_DCONF_SM_IOCDISABLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6021) bfa_sm_set_state(dconf, bfa_dconf_sm_iocdown_dirty);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6022) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6023) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6024) bfa_sm_fault(dconf->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6025) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6026) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6027)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6028) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6029) bfa_dconf_sm_iocdown_dirty(struct bfa_dconf_mod_s *dconf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6030) enum bfa_dconf_event event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6031) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6032) bfa_trc(dconf->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6033)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6034) switch (event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6035) case BFA_DCONF_SM_INIT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6036) bfa_timer_start(dconf->bfa, &dconf->timer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6037) bfa_dconf_timer, dconf, BFA_DCONF_UPDATE_TOV);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6038) bfa_sm_set_state(dconf, bfa_dconf_sm_dirty);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6039) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6040) case BFA_DCONF_SM_EXIT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6041) bfa_sm_set_state(dconf, bfa_dconf_sm_uninit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6042) bfa_fsm_send_event(&dconf->bfa->iocfc, IOCFC_E_DCONF_DONE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6043) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6044) case BFA_DCONF_SM_IOCDISABLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6045) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6046) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6047) bfa_sm_fault(dconf->bfa, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6048) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6049) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6050)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6051) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6052) * Compute and return memory needed by DRV_CFG module.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6053) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6054) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6055) bfa_dconf_meminfo(struct bfa_iocfc_cfg_s *cfg, struct bfa_meminfo_s *meminfo,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6056) struct bfa_s *bfa)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6057) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6058) struct bfa_mem_kva_s *dconf_kva = BFA_MEM_DCONF_KVA(bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6059)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6060) if (cfg->drvcfg.min_cfg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6061) bfa_mem_kva_setup(meminfo, dconf_kva,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6062) sizeof(struct bfa_dconf_hdr_s));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6063) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6064) bfa_mem_kva_setup(meminfo, dconf_kva,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6065) sizeof(struct bfa_dconf_s));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6066) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6067)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6068) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6069) bfa_dconf_attach(struct bfa_s *bfa, void *bfad, struct bfa_iocfc_cfg_s *cfg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6070) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6071) struct bfa_dconf_mod_s *dconf = BFA_DCONF_MOD(bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6072)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6073) dconf->bfad = bfad;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6074) dconf->bfa = bfa;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6075) dconf->instance = bfa->ioc.port_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6076) bfa_trc(bfa, dconf->instance);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6077)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6078) dconf->dconf = (struct bfa_dconf_s *) bfa_mem_kva_curp(dconf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6079) if (cfg->drvcfg.min_cfg) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6080) bfa_mem_kva_curp(dconf) += sizeof(struct bfa_dconf_hdr_s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6081) dconf->min_cfg = BFA_TRUE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6082) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6083) dconf->min_cfg = BFA_FALSE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6084) bfa_mem_kva_curp(dconf) += sizeof(struct bfa_dconf_s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6085) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6086)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6087) bfa_dconf_read_data_valid(bfa) = BFA_FALSE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6088) bfa_sm_set_state(dconf, bfa_dconf_sm_uninit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6089) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6090)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6091) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6092) bfa_dconf_init_cb(void *arg, bfa_status_t status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6093) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6094) struct bfa_s *bfa = arg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6095) struct bfa_dconf_mod_s *dconf = BFA_DCONF_MOD(bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6096)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6097) if (status == BFA_STATUS_OK) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6098) bfa_dconf_read_data_valid(bfa) = BFA_TRUE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6099) if (dconf->dconf->hdr.signature != BFI_DCONF_SIGNATURE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6100) dconf->dconf->hdr.signature = BFI_DCONF_SIGNATURE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6101) if (dconf->dconf->hdr.version != BFI_DCONF_VERSION)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6102) dconf->dconf->hdr.version = BFI_DCONF_VERSION;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6103) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6104) bfa_sm_send_event(dconf, BFA_DCONF_SM_FLASH_COMP);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6105) bfa_fsm_send_event(&bfa->iocfc, IOCFC_E_DCONF_DONE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6106) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6107)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6108) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6109) bfa_dconf_modinit(struct bfa_s *bfa)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6110) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6111) struct bfa_dconf_mod_s *dconf = BFA_DCONF_MOD(bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6112) bfa_sm_send_event(dconf, BFA_DCONF_SM_INIT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6113) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6114)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6115) static void bfa_dconf_timer(void *cbarg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6116) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6117) struct bfa_dconf_mod_s *dconf = cbarg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6118) bfa_sm_send_event(dconf, BFA_DCONF_SM_TIMEOUT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6119) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6120)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6121) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6122) bfa_dconf_iocdisable(struct bfa_s *bfa)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6123) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6124) struct bfa_dconf_mod_s *dconf = BFA_DCONF_MOD(bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6125) bfa_sm_send_event(dconf, BFA_DCONF_SM_IOCDISABLE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6126) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6127)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6128) static bfa_status_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6129) bfa_dconf_flash_write(struct bfa_dconf_mod_s *dconf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6130) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6131) bfa_status_t bfa_status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6132) bfa_trc(dconf->bfa, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6133)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6134) bfa_status = bfa_flash_update_part(BFA_FLASH(dconf->bfa),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6135) BFA_FLASH_PART_DRV, dconf->instance,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6136) dconf->dconf, sizeof(struct bfa_dconf_s), 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6137) bfa_dconf_cbfn, dconf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6138) if (bfa_status != BFA_STATUS_OK)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6139) WARN_ON(bfa_status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6140) bfa_trc(dconf->bfa, bfa_status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6141)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6142) return bfa_status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6143) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6144)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6145) bfa_status_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6146) bfa_dconf_update(struct bfa_s *bfa)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6147) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6148) struct bfa_dconf_mod_s *dconf = BFA_DCONF_MOD(bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6149) bfa_trc(dconf->bfa, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6150) if (bfa_sm_cmp_state(dconf, bfa_dconf_sm_iocdown_dirty))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6151) return BFA_STATUS_FAILED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6152)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6153) if (dconf->min_cfg) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6154) bfa_trc(dconf->bfa, dconf->min_cfg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6155) return BFA_STATUS_FAILED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6156) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6157)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6158) bfa_sm_send_event(dconf, BFA_DCONF_SM_WR);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6159) return BFA_STATUS_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6160) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6161)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6162) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6163) bfa_dconf_cbfn(void *arg, bfa_status_t status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6164) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6165) struct bfa_dconf_mod_s *dconf = arg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6166) WARN_ON(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6167) bfa_sm_send_event(dconf, BFA_DCONF_SM_FLASH_COMP);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6168) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6169)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6170) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6171) bfa_dconf_modexit(struct bfa_s *bfa)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6172) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6173) struct bfa_dconf_mod_s *dconf = BFA_DCONF_MOD(bfa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6174) bfa_sm_send_event(dconf, BFA_DCONF_SM_EXIT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6175) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6176)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6177) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6178) * FRU specific functions
^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) #define BFA_FRU_DMA_BUF_SZ 0x02000 /* 8k dma buffer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6182) #define BFA_FRU_CHINOOK_MAX_SIZE 0x10000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6183) #define BFA_FRU_LIGHTNING_MAX_SIZE 0x200
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6184)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6185) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6186) bfa_fru_notify(void *cbarg, enum bfa_ioc_event_e event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6187) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6188) struct bfa_fru_s *fru = cbarg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6189)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6190) bfa_trc(fru, event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6191)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6192) switch (event) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6193) case BFA_IOC_E_DISABLED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6194) case BFA_IOC_E_FAILED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6195) if (fru->op_busy) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6196) fru->status = BFA_STATUS_IOC_FAILURE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6197) fru->cbfn(fru->cbarg, fru->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6198) fru->op_busy = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6199) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6200) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6201)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6202) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6203) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6204) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6205) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6206)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6207) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6208) * Send fru write request.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6209) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6210) * @param[in] cbarg - callback argument
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6211) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6212) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6213) bfa_fru_write_send(void *cbarg, enum bfi_fru_h2i_msgs msg_type)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6214) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6215) struct bfa_fru_s *fru = cbarg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6216) struct bfi_fru_write_req_s *msg =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6217) (struct bfi_fru_write_req_s *) fru->mb.msg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6218) u32 len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6219)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6220) msg->offset = cpu_to_be32(fru->addr_off + fru->offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6221) len = (fru->residue < BFA_FRU_DMA_BUF_SZ) ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6222) fru->residue : BFA_FRU_DMA_BUF_SZ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6223) msg->length = cpu_to_be32(len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6224)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6225) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6226) * indicate if it's the last msg of the whole write operation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6227) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6228) msg->last = (len == fru->residue) ? 1 : 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6229)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6230) msg->trfr_cmpl = (len == fru->residue) ? fru->trfr_cmpl : 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6231) bfi_h2i_set(msg->mh, BFI_MC_FRU, msg_type, bfa_ioc_portid(fru->ioc));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6232) bfa_alen_set(&msg->alen, len, fru->dbuf_pa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6233)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6234) memcpy(fru->dbuf_kva, fru->ubuf + fru->offset, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6235) bfa_ioc_mbox_queue(fru->ioc, &fru->mb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6236)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6237) fru->residue -= len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6238) fru->offset += len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6239) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6240)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6241) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6242) * Send fru read request.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6243) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6244) * @param[in] cbarg - callback argument
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6245) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6246) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6247) bfa_fru_read_send(void *cbarg, enum bfi_fru_h2i_msgs msg_type)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6248) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6249) struct bfa_fru_s *fru = cbarg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6250) struct bfi_fru_read_req_s *msg =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6251) (struct bfi_fru_read_req_s *) fru->mb.msg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6252) u32 len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6253)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6254) msg->offset = cpu_to_be32(fru->addr_off + fru->offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6255) len = (fru->residue < BFA_FRU_DMA_BUF_SZ) ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6256) fru->residue : BFA_FRU_DMA_BUF_SZ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6257) msg->length = cpu_to_be32(len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6258) bfi_h2i_set(msg->mh, BFI_MC_FRU, msg_type, bfa_ioc_portid(fru->ioc));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6259) bfa_alen_set(&msg->alen, len, fru->dbuf_pa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6260) bfa_ioc_mbox_queue(fru->ioc, &fru->mb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6261) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6262)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6263) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6264) * Flash memory info API.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6265) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6266) * @param[in] mincfg - minimal cfg variable
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6267) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6268) u32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6269) bfa_fru_meminfo(bfa_boolean_t mincfg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6270) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6271) /* min driver doesn't need fru */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6272) if (mincfg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6273) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6274)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6275) return BFA_ROUNDUP(BFA_FRU_DMA_BUF_SZ, BFA_DMA_ALIGN_SZ);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6276) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6277)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6278) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6279) * Flash attach API.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6280) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6281) * @param[in] fru - fru structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6282) * @param[in] ioc - ioc structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6283) * @param[in] dev - device structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6284) * @param[in] trcmod - trace module
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6285) * @param[in] logmod - log module
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6286) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6287) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6288) bfa_fru_attach(struct bfa_fru_s *fru, struct bfa_ioc_s *ioc, void *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6289) struct bfa_trc_mod_s *trcmod, bfa_boolean_t mincfg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6290) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6291) fru->ioc = ioc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6292) fru->trcmod = trcmod;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6293) fru->cbfn = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6294) fru->cbarg = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6295) fru->op_busy = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6296)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6297) bfa_ioc_mbox_regisr(fru->ioc, BFI_MC_FRU, bfa_fru_intr, fru);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6298) bfa_q_qe_init(&fru->ioc_notify);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6299) bfa_ioc_notify_init(&fru->ioc_notify, bfa_fru_notify, fru);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6300) list_add_tail(&fru->ioc_notify.qe, &fru->ioc->notify_q);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6301)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6302) /* min driver doesn't need fru */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6303) if (mincfg) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6304) fru->dbuf_kva = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6305) fru->dbuf_pa = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6306) }
^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) * Claim memory for fru
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6311) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6312) * @param[in] fru - fru structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6313) * @param[in] dm_kva - pointer to virtual memory address
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6314) * @param[in] dm_pa - frusical memory address
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6315) * @param[in] mincfg - minimal cfg variable
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6316) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6317) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6318) bfa_fru_memclaim(struct bfa_fru_s *fru, u8 *dm_kva, u64 dm_pa,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6319) bfa_boolean_t mincfg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6320) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6321) if (mincfg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6322) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6323)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6324) fru->dbuf_kva = dm_kva;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6325) fru->dbuf_pa = dm_pa;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6326) memset(fru->dbuf_kva, 0, BFA_FRU_DMA_BUF_SZ);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6327) dm_kva += BFA_ROUNDUP(BFA_FRU_DMA_BUF_SZ, BFA_DMA_ALIGN_SZ);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6328) dm_pa += BFA_ROUNDUP(BFA_FRU_DMA_BUF_SZ, BFA_DMA_ALIGN_SZ);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6329) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6330)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6331) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6332) * Update fru vpd image.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6333) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6334) * @param[in] fru - fru structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6335) * @param[in] buf - update data buffer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6336) * @param[in] len - data buffer length
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6337) * @param[in] offset - offset relative to starting address
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6338) * @param[in] cbfn - callback function
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6339) * @param[in] cbarg - callback argument
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6340) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6341) * Return status.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6342) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6343) bfa_status_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6344) bfa_fruvpd_update(struct bfa_fru_s *fru, void *buf, u32 len, u32 offset,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6345) bfa_cb_fru_t cbfn, void *cbarg, u8 trfr_cmpl)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6346) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6347) bfa_trc(fru, BFI_FRUVPD_H2I_WRITE_REQ);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6348) bfa_trc(fru, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6349) bfa_trc(fru, offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6350)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6351) if (fru->ioc->asic_gen != BFI_ASIC_GEN_CT2 &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6352) fru->ioc->attr->card_type != BFA_MFG_TYPE_CHINOOK2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6353) return BFA_STATUS_FRU_NOT_PRESENT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6354)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6355) if (fru->ioc->attr->card_type != BFA_MFG_TYPE_CHINOOK)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6356) return BFA_STATUS_CMD_NOTSUPP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6357)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6358) if (!bfa_ioc_is_operational(fru->ioc))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6359) return BFA_STATUS_IOC_NON_OP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6360)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6361) if (fru->op_busy) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6362) bfa_trc(fru, fru->op_busy);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6363) return BFA_STATUS_DEVBUSY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6364) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6365)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6366) fru->op_busy = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6367)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6368) fru->cbfn = cbfn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6369) fru->cbarg = cbarg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6370) fru->residue = len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6371) fru->offset = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6372) fru->addr_off = offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6373) fru->ubuf = buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6374) fru->trfr_cmpl = trfr_cmpl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6375)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6376) bfa_fru_write_send(fru, BFI_FRUVPD_H2I_WRITE_REQ);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6377)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6378) return BFA_STATUS_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6379) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6380)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6381) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6382) * Read fru vpd image.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6383) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6384) * @param[in] fru - fru structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6385) * @param[in] buf - read data buffer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6386) * @param[in] len - data buffer length
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6387) * @param[in] offset - offset relative to starting address
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6388) * @param[in] cbfn - callback function
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6389) * @param[in] cbarg - callback argument
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6390) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6391) * Return status.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6392) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6393) bfa_status_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6394) bfa_fruvpd_read(struct bfa_fru_s *fru, void *buf, u32 len, u32 offset,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6395) bfa_cb_fru_t cbfn, void *cbarg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6396) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6397) bfa_trc(fru, BFI_FRUVPD_H2I_READ_REQ);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6398) bfa_trc(fru, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6399) bfa_trc(fru, offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6400)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6401) if (fru->ioc->asic_gen != BFI_ASIC_GEN_CT2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6402) return BFA_STATUS_FRU_NOT_PRESENT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6403)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6404) if (fru->ioc->attr->card_type != BFA_MFG_TYPE_CHINOOK &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6405) fru->ioc->attr->card_type != BFA_MFG_TYPE_CHINOOK2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6406) return BFA_STATUS_CMD_NOTSUPP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6407)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6408) if (!bfa_ioc_is_operational(fru->ioc))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6409) return BFA_STATUS_IOC_NON_OP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6410)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6411) if (fru->op_busy) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6412) bfa_trc(fru, fru->op_busy);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6413) return BFA_STATUS_DEVBUSY;
^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) fru->op_busy = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6417)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6418) fru->cbfn = cbfn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6419) fru->cbarg = cbarg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6420) fru->residue = len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6421) fru->offset = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6422) fru->addr_off = offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6423) fru->ubuf = buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6424) bfa_fru_read_send(fru, BFI_FRUVPD_H2I_READ_REQ);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6425)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6426) return BFA_STATUS_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6427) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6428)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6429) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6430) * Get maximum size fru vpd image.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6431) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6432) * @param[in] fru - fru structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6433) * @param[out] size - maximum size of fru vpd data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6434) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6435) * Return status.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6436) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6437) bfa_status_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6438) bfa_fruvpd_get_max_size(struct bfa_fru_s *fru, u32 *max_size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6439) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6440) if (fru->ioc->asic_gen != BFI_ASIC_GEN_CT2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6441) return BFA_STATUS_FRU_NOT_PRESENT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6442)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6443) if (!bfa_ioc_is_operational(fru->ioc))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6444) return BFA_STATUS_IOC_NON_OP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6445)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6446) if (fru->ioc->attr->card_type == BFA_MFG_TYPE_CHINOOK ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6447) fru->ioc->attr->card_type == BFA_MFG_TYPE_CHINOOK2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6448) *max_size = BFA_FRU_CHINOOK_MAX_SIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6449) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6450) return BFA_STATUS_CMD_NOTSUPP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6451) return BFA_STATUS_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6452) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6453) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6454) * tfru write.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6455) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6456) * @param[in] fru - fru structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6457) * @param[in] buf - update data buffer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6458) * @param[in] len - data buffer length
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6459) * @param[in] offset - offset relative to starting address
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6460) * @param[in] cbfn - callback function
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6461) * @param[in] cbarg - callback argument
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6462) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6463) * Return status.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6464) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6465) bfa_status_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6466) bfa_tfru_write(struct bfa_fru_s *fru, void *buf, u32 len, u32 offset,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6467) bfa_cb_fru_t cbfn, void *cbarg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6468) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6469) bfa_trc(fru, BFI_TFRU_H2I_WRITE_REQ);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6470) bfa_trc(fru, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6471) bfa_trc(fru, offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6472) bfa_trc(fru, *((u8 *) buf));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6473)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6474) if (fru->ioc->asic_gen != BFI_ASIC_GEN_CT2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6475) return BFA_STATUS_FRU_NOT_PRESENT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6476)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6477) if (!bfa_ioc_is_operational(fru->ioc))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6478) return BFA_STATUS_IOC_NON_OP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6479)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6480) if (fru->op_busy) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6481) bfa_trc(fru, fru->op_busy);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6482) return BFA_STATUS_DEVBUSY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6483) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6484)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6485) fru->op_busy = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6486)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6487) fru->cbfn = cbfn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6488) fru->cbarg = cbarg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6489) fru->residue = len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6490) fru->offset = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6491) fru->addr_off = offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6492) fru->ubuf = buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6493)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6494) bfa_fru_write_send(fru, BFI_TFRU_H2I_WRITE_REQ);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6495)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6496) return BFA_STATUS_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6497) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6498)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6499) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6500) * tfru read.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6501) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6502) * @param[in] fru - fru structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6503) * @param[in] buf - read data buffer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6504) * @param[in] len - data buffer length
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6505) * @param[in] offset - offset relative to starting address
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6506) * @param[in] cbfn - callback function
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6507) * @param[in] cbarg - callback argument
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6508) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6509) * Return status.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6510) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6511) bfa_status_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6512) bfa_tfru_read(struct bfa_fru_s *fru, void *buf, u32 len, u32 offset,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6513) bfa_cb_fru_t cbfn, void *cbarg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6514) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6515) bfa_trc(fru, BFI_TFRU_H2I_READ_REQ);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6516) bfa_trc(fru, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6517) bfa_trc(fru, offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6518)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6519) if (fru->ioc->asic_gen != BFI_ASIC_GEN_CT2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6520) return BFA_STATUS_FRU_NOT_PRESENT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6521)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6522) if (!bfa_ioc_is_operational(fru->ioc))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6523) return BFA_STATUS_IOC_NON_OP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6524)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6525) if (fru->op_busy) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6526) bfa_trc(fru, fru->op_busy);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6527) return BFA_STATUS_DEVBUSY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6528) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6529)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6530) fru->op_busy = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6531)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6532) fru->cbfn = cbfn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6533) fru->cbarg = cbarg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6534) fru->residue = len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6535) fru->offset = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6536) fru->addr_off = offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6537) fru->ubuf = buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6538) bfa_fru_read_send(fru, BFI_TFRU_H2I_READ_REQ);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6539)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6540) return BFA_STATUS_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6541) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6542)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6543) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6544) * Process fru response messages upon receiving interrupts.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6545) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6546) * @param[in] fruarg - fru structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6547) * @param[in] msg - message structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6548) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6549) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6550) bfa_fru_intr(void *fruarg, struct bfi_mbmsg_s *msg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6551) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6552) struct bfa_fru_s *fru = fruarg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6553) struct bfi_fru_rsp_s *rsp = (struct bfi_fru_rsp_s *)msg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6554) u32 status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6555)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6556) bfa_trc(fru, msg->mh.msg_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6557)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6558) if (!fru->op_busy) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6559) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6560) * receiving response after ioc failure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6561) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6562) bfa_trc(fru, 0x9999);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6563) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6564) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6565)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6566) switch (msg->mh.msg_id) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6567) case BFI_FRUVPD_I2H_WRITE_RSP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6568) case BFI_TFRU_I2H_WRITE_RSP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6569) status = be32_to_cpu(rsp->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6570) bfa_trc(fru, status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6571)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6572) if (status != BFA_STATUS_OK || fru->residue == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6573) fru->status = status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6574) fru->op_busy = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6575) if (fru->cbfn)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6576) fru->cbfn(fru->cbarg, fru->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6577) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6578) bfa_trc(fru, fru->offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6579) if (msg->mh.msg_id == BFI_FRUVPD_I2H_WRITE_RSP)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6580) bfa_fru_write_send(fru,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6581) BFI_FRUVPD_H2I_WRITE_REQ);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6582) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6583) bfa_fru_write_send(fru,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6584) BFI_TFRU_H2I_WRITE_REQ);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6585) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6586) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6587) case BFI_FRUVPD_I2H_READ_RSP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6588) case BFI_TFRU_I2H_READ_RSP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6589) status = be32_to_cpu(rsp->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6590) bfa_trc(fru, status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6591)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6592) if (status != BFA_STATUS_OK) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6593) fru->status = status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6594) fru->op_busy = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6595) if (fru->cbfn)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6596) fru->cbfn(fru->cbarg, fru->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6597) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6598) u32 len = be32_to_cpu(rsp->length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6599)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6600) bfa_trc(fru, fru->offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6601) bfa_trc(fru, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6602)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6603) memcpy(fru->ubuf + fru->offset, fru->dbuf_kva, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6604) fru->residue -= len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6605) fru->offset += len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6606)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6607) if (fru->residue == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6608) fru->status = status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6609) fru->op_busy = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6610) if (fru->cbfn)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6611) fru->cbfn(fru->cbarg, fru->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6612) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6613) if (msg->mh.msg_id == BFI_FRUVPD_I2H_READ_RSP)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6614) bfa_fru_read_send(fru,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6615) BFI_FRUVPD_H2I_READ_REQ);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6616) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6617) bfa_fru_read_send(fru,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6618) BFI_TFRU_H2I_READ_REQ);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6619) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6620) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6621) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6622) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6623) WARN_ON(1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6624) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6625) }
^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) * register definitions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6629) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6630) #define FLI_CMD_REG 0x0001d000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6631) #define FLI_RDDATA_REG 0x0001d010
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6632) #define FLI_ADDR_REG 0x0001d004
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6633) #define FLI_DEV_STATUS_REG 0x0001d014
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6634)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6635) #define BFA_FLASH_FIFO_SIZE 128 /* fifo size */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6636) #define BFA_FLASH_CHECK_MAX 10000 /* max # of status check */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6637) #define BFA_FLASH_BLOCKING_OP_MAX 1000000 /* max # of blocking op check */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6638) #define BFA_FLASH_WIP_MASK 0x01 /* write in progress bit mask */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6639)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6640) enum bfa_flash_cmd {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6641) BFA_FLASH_FAST_READ = 0x0b, /* fast read */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6642) BFA_FLASH_READ_STATUS = 0x05, /* read status */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6643) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6644)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6645) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6646) * Hardware error definition
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6647) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6648) enum bfa_flash_err {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6649) BFA_FLASH_NOT_PRESENT = -1, /*!< flash not present */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6650) BFA_FLASH_UNINIT = -2, /*!< flash not initialized */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6651) BFA_FLASH_BAD = -3, /*!< flash bad */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6652) BFA_FLASH_BUSY = -4, /*!< flash busy */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6653) BFA_FLASH_ERR_CMD_ACT = -5, /*!< command active never cleared */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6654) BFA_FLASH_ERR_FIFO_CNT = -6, /*!< fifo count never cleared */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6655) BFA_FLASH_ERR_WIP = -7, /*!< write-in-progress never cleared */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6656) BFA_FLASH_ERR_TIMEOUT = -8, /*!< fli timeout */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6657) BFA_FLASH_ERR_LEN = -9, /*!< invalid length */
^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) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6661) * Flash command register data structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6662) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6663) union bfa_flash_cmd_reg_u {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6664) struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6665) #ifdef __BIG_ENDIAN
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6666) u32 act:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6667) u32 rsv:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6668) u32 write_cnt:9;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6669) u32 read_cnt:9;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6670) u32 addr_cnt:4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6671) u32 cmd:8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6672) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6673) u32 cmd:8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6674) u32 addr_cnt:4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6675) u32 read_cnt:9;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6676) u32 write_cnt:9;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6677) u32 rsv:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6678) u32 act:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6679) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6680) } r;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6681) u32 i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6682) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6683)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6684) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6685) * Flash device status register data structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6686) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6687) union bfa_flash_dev_status_reg_u {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6688) struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6689) #ifdef __BIG_ENDIAN
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6690) u32 rsv:21;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6691) u32 fifo_cnt:6;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6692) u32 busy:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6693) u32 init_status:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6694) u32 present:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6695) u32 bad:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6696) u32 good:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6697) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6698) u32 good:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6699) u32 bad:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6700) u32 present:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6701) u32 init_status:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6702) u32 busy:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6703) u32 fifo_cnt:6;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6704) u32 rsv:21;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6705) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6706) } r;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6707) u32 i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6708) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6709)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6710) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6711) * Flash address register data structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6712) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6713) union bfa_flash_addr_reg_u {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6714) struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6715) #ifdef __BIG_ENDIAN
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6716) u32 addr:24;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6717) u32 dummy:8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6718) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6719) u32 dummy:8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6720) u32 addr:24;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6721) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6722) } r;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6723) u32 i;
^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) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6727) * dg flash_raw_private Flash raw private functions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6728) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6729) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6730) bfa_flash_set_cmd(void __iomem *pci_bar, u8 wr_cnt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6731) u8 rd_cnt, u8 ad_cnt, u8 op)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6732) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6733) union bfa_flash_cmd_reg_u cmd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6734)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6735) cmd.i = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6736) cmd.r.act = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6737) cmd.r.write_cnt = wr_cnt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6738) cmd.r.read_cnt = rd_cnt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6739) cmd.r.addr_cnt = ad_cnt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6740) cmd.r.cmd = op;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6741) writel(cmd.i, (pci_bar + FLI_CMD_REG));
^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) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6745) bfa_flash_set_addr(void __iomem *pci_bar, u32 address)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6746) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6747) union bfa_flash_addr_reg_u addr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6748)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6749) addr.r.addr = address & 0x00ffffff;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6750) addr.r.dummy = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6751) writel(addr.i, (pci_bar + FLI_ADDR_REG));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6752) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6753)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6754) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6755) bfa_flash_cmd_act_check(void __iomem *pci_bar)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6756) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6757) union bfa_flash_cmd_reg_u cmd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6758)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6759) cmd.i = readl(pci_bar + FLI_CMD_REG);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6760)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6761) if (cmd.r.act)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6762) return BFA_FLASH_ERR_CMD_ACT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6763)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6764) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6765) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6766)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6767) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6768) * @brief
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6769) * Flush FLI data fifo.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6770) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6771) * @param[in] pci_bar - pci bar address
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6772) * @param[in] dev_status - device status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6773) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6774) * Return 0 on success, negative error number on error.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6775) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6776) static u32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6777) bfa_flash_fifo_flush(void __iomem *pci_bar)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6778) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6779) u32 i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6780) union bfa_flash_dev_status_reg_u dev_status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6781)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6782) dev_status.i = readl(pci_bar + FLI_DEV_STATUS_REG);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6783)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6784) if (!dev_status.r.fifo_cnt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6785) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6786)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6787) /* fifo counter in terms of words */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6788) for (i = 0; i < dev_status.r.fifo_cnt; i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6789) readl(pci_bar + FLI_RDDATA_REG);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6790)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6791) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6792) * Check the device status. It may take some time.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6793) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6794) for (i = 0; i < BFA_FLASH_CHECK_MAX; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6795) dev_status.i = readl(pci_bar + FLI_DEV_STATUS_REG);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6796) if (!dev_status.r.fifo_cnt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6797) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6798) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6799)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6800) if (dev_status.r.fifo_cnt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6801) return BFA_FLASH_ERR_FIFO_CNT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6802)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6803) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6804) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6805)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6806) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6807) * @brief
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6808) * Read flash status.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6809) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6810) * @param[in] pci_bar - pci bar address
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6811) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6812) * Return 0 on success, negative error number on error.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6813) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6814) static u32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6815) bfa_flash_status_read(void __iomem *pci_bar)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6816) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6817) union bfa_flash_dev_status_reg_u dev_status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6818) int status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6819) u32 ret_status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6820) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6821)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6822) status = bfa_flash_fifo_flush(pci_bar);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6823) if (status < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6824) return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6825)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6826) bfa_flash_set_cmd(pci_bar, 0, 4, 0, BFA_FLASH_READ_STATUS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6827)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6828) for (i = 0; i < BFA_FLASH_CHECK_MAX; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6829) status = bfa_flash_cmd_act_check(pci_bar);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6830) if (!status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6831) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6832) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6833)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6834) if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6835) return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6836)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6837) dev_status.i = readl(pci_bar + FLI_DEV_STATUS_REG);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6838) if (!dev_status.r.fifo_cnt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6839) return BFA_FLASH_BUSY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6840)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6841) ret_status = readl(pci_bar + FLI_RDDATA_REG);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6842) ret_status >>= 24;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6843)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6844) status = bfa_flash_fifo_flush(pci_bar);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6845) if (status < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6846) return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6847)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6848) return ret_status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6849) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6850)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6851) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6852) * @brief
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6853) * Start flash read operation.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6854) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6855) * @param[in] pci_bar - pci bar address
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6856) * @param[in] offset - flash address offset
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6857) * @param[in] len - read data length
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6858) * @param[in] buf - read data buffer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6859) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6860) * Return 0 on success, negative error number on error.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6861) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6862) static u32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6863) bfa_flash_read_start(void __iomem *pci_bar, u32 offset, u32 len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6864) char *buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6865) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6866) int status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6867)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6868) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6869) * len must be mutiple of 4 and not exceeding fifo size
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6870) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6871) if (len == 0 || len > BFA_FLASH_FIFO_SIZE || (len & 0x03) != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6872) return BFA_FLASH_ERR_LEN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6873)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6874) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6875) * check status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6876) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6877) status = bfa_flash_status_read(pci_bar);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6878) if (status == BFA_FLASH_BUSY)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6879) status = bfa_flash_status_read(pci_bar);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6880)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6881) if (status < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6882) return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6883)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6884) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6885) * check if write-in-progress bit is cleared
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6886) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6887) if (status & BFA_FLASH_WIP_MASK)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6888) return BFA_FLASH_ERR_WIP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6889)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6890) bfa_flash_set_addr(pci_bar, offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6891)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6892) bfa_flash_set_cmd(pci_bar, 0, (u8)len, 4, BFA_FLASH_FAST_READ);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6893)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6894) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6895) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6896)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6897) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6898) * @brief
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6899) * Check flash read operation.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6900) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6901) * @param[in] pci_bar - pci bar address
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6902) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6903) * Return flash device status, 1 if busy, 0 if not.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6904) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6905) static u32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6906) bfa_flash_read_check(void __iomem *pci_bar)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6907) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6908) if (bfa_flash_cmd_act_check(pci_bar))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6909) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6910)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6911) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6912) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6913)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6914) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6915) * @brief
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6916) * End flash read operation.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6917) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6918) * @param[in] pci_bar - pci bar address
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6919) * @param[in] len - read data length
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6920) * @param[in] buf - read data buffer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6921) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6922) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6923) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6924) bfa_flash_read_end(void __iomem *pci_bar, u32 len, char *buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6925) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6926)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6927) u32 i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6928)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6929) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6930) * read data fifo up to 32 words
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6931) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6932) for (i = 0; i < len; i += 4) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6933) u32 w = readl(pci_bar + FLI_RDDATA_REG);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6934) *((u32 *) (buf + i)) = swab32(w);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6935) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6936)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6937) bfa_flash_fifo_flush(pci_bar);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6938) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6939)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6940) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6941) * @brief
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6942) * Perform flash raw read.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6943) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6944) * @param[in] pci_bar - pci bar address
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6945) * @param[in] offset - flash partition address offset
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6946) * @param[in] buf - read data buffer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6947) * @param[in] len - read data length
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6948) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6949) * Return status.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6950) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6951)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6952)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6953) #define FLASH_BLOCKING_OP_MAX 500
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6954) #define FLASH_SEM_LOCK_REG 0x18820
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6955)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6956) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6957) bfa_raw_sem_get(void __iomem *bar)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6958) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6959) int locked;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6960)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6961) locked = readl((bar + FLASH_SEM_LOCK_REG));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6962) return !locked;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6963)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6964) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6965)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6966) static bfa_status_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6967) bfa_flash_sem_get(void __iomem *bar)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6968) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6969) u32 n = FLASH_BLOCKING_OP_MAX;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6970)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6971) while (!bfa_raw_sem_get(bar)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6972) if (--n <= 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6973) return BFA_STATUS_BADFLASH;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6974) mdelay(10);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6975) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6976) return BFA_STATUS_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6977) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6978)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6979) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6980) bfa_flash_sem_put(void __iomem *bar)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6981) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6982) writel(0, (bar + FLASH_SEM_LOCK_REG));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6983) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6984)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6985) bfa_status_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6986) bfa_flash_raw_read(void __iomem *pci_bar, u32 offset, char *buf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6987) u32 len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6988) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6989) u32 n;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6990) int status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6991) u32 off, l, s, residue, fifo_sz;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6992)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6993) residue = len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6994) off = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6995) fifo_sz = BFA_FLASH_FIFO_SIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6996) status = bfa_flash_sem_get(pci_bar);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6997) if (status != BFA_STATUS_OK)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6998) return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6999)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7000) while (residue) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7001) s = offset + off;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7002) n = s / fifo_sz;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7003) l = (n + 1) * fifo_sz - s;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7004) if (l > residue)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7005) l = residue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7006)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7007) status = bfa_flash_read_start(pci_bar, offset + off, l,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7008) &buf[off]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7009) if (status < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7010) bfa_flash_sem_put(pci_bar);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7011) return BFA_STATUS_FAILED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7012) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7013)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7014) n = BFA_FLASH_BLOCKING_OP_MAX;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7015) while (bfa_flash_read_check(pci_bar)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7016) if (--n <= 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7017) bfa_flash_sem_put(pci_bar);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7018) return BFA_STATUS_FAILED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7019) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7020) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7021)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7022) bfa_flash_read_end(pci_bar, l, &buf[off]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7023)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7024) residue -= l;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7025) off += l;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7026) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7027) bfa_flash_sem_put(pci_bar);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7028)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7029) return BFA_STATUS_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7030) }