diff options
Diffstat (limited to 'drivers/scsi/bfa/bfa_ioc.c')
-rw-r--r-- | drivers/scsi/bfa/bfa_ioc.c | 755 |
1 files changed, 330 insertions, 425 deletions
diff --git a/drivers/scsi/bfa/bfa_ioc.c b/drivers/scsi/bfa/bfa_ioc.c index 54475b53a5a..c1f72c49196 100644 --- a/drivers/scsi/bfa/bfa_ioc.c +++ b/drivers/scsi/bfa/bfa_ioc.c @@ -15,11 +15,11 @@ * General Public License for more details. */ +#include "bfad_drv.h" #include "bfa_ioc.h" #include "bfi_ctreg.h" #include "bfa_defs.h" #include "bfa_defs_svc.h" -#include "bfad_drv.h" BFA_TRC_FILE(CNA, IOC); @@ -29,7 +29,7 @@ BFA_TRC_FILE(CNA, IOC); #define BFA_IOC_TOV 3000 /* msecs */ #define BFA_IOC_HWSEM_TOV 500 /* msecs */ #define BFA_IOC_HB_TOV 500 /* msecs */ -#define BFA_IOC_HWINIT_MAX 2 +#define BFA_IOC_HWINIT_MAX 5 #define BFA_IOC_TOV_RECOVER BFA_IOC_HB_TOV #define bfa_ioc_timer_start(__ioc) \ @@ -42,11 +42,6 @@ BFA_TRC_FILE(CNA, IOC); bfa_ioc_hb_check, (__ioc), BFA_IOC_HB_TOV) #define bfa_hb_timer_stop(__ioc) bfa_timer_stop(&(__ioc)->hb_timer) -#define BFA_DBG_FWTRC_ENTS (BFI_IOC_TRC_ENTS) -#define BFA_DBG_FWTRC_LEN \ - (BFA_DBG_FWTRC_ENTS * sizeof(struct bfa_trc_s) + \ - (sizeof(struct bfa_trc_mod_s) - \ - BFA_TRC_MAX * sizeof(struct bfa_trc_s))) #define BFA_DBG_FWTRC_OFF(_fn) (BFI_IOC_TRC_OFF + BFA_DBG_FWTRC_LEN * (_fn)) /* @@ -59,17 +54,16 @@ BFA_TRC_FILE(CNA, IOC); ((__ioc)->ioc_hwif->ioc_firmware_unlock(__ioc)) #define bfa_ioc_reg_init(__ioc) ((__ioc)->ioc_hwif->ioc_reg_init(__ioc)) #define bfa_ioc_map_port(__ioc) ((__ioc)->ioc_hwif->ioc_map_port(__ioc)) -#define bfa_ioc_notify_hbfail(__ioc) \ - ((__ioc)->ioc_hwif->ioc_notify_hbfail(__ioc)) - -#ifdef BFA_IOC_IS_UEFI -#define bfa_ioc_is_bios_optrom(__ioc) (0) -#define bfa_ioc_is_uefi(__ioc) BFA_IOC_IS_UEFI -#else -#define bfa_ioc_is_bios_optrom(__ioc) \ - (bfa_cb_image_get_size(BFA_IOC_FWIMG_TYPE(__ioc)) < BFA_IOC_FWIMG_MINSZ) -#define bfa_ioc_is_uefi(__ioc) (0) -#endif +#define bfa_ioc_notify_fail(__ioc) \ + ((__ioc)->ioc_hwif->ioc_notify_fail(__ioc)) +#define bfa_ioc_sync_join(__ioc) \ + ((__ioc)->ioc_hwif->ioc_sync_join(__ioc)) +#define bfa_ioc_sync_leave(__ioc) \ + ((__ioc)->ioc_hwif->ioc_sync_leave(__ioc)) +#define bfa_ioc_sync_ack(__ioc) \ + ((__ioc)->ioc_hwif->ioc_sync_ack(__ioc)) +#define bfa_ioc_sync_complete(__ioc) \ + ((__ioc)->ioc_hwif->ioc_sync_complete(__ioc)) #define bfa_ioc_mbox_cmd_pending(__ioc) \ (!list_empty(&((__ioc)->mbox_mod.cmd_q)) || \ @@ -81,29 +75,22 @@ bfa_boolean_t bfa_auto_recover = BFA_TRUE; * forward declarations */ static void bfa_ioc_hw_sem_get(struct bfa_ioc_s *ioc); -static void bfa_ioc_hw_sem_get_cancel(struct bfa_ioc_s *ioc); static void bfa_ioc_hwinit(struct bfa_ioc_s *ioc, bfa_boolean_t force); static void bfa_ioc_timeout(void *ioc); static void bfa_ioc_send_enable(struct bfa_ioc_s *ioc); static void bfa_ioc_send_disable(struct bfa_ioc_s *ioc); static void bfa_ioc_send_getattr(struct bfa_ioc_s *ioc); static void bfa_ioc_hb_monitor(struct bfa_ioc_s *ioc); -static void bfa_ioc_hb_stop(struct bfa_ioc_s *ioc); -static void bfa_ioc_reset(struct bfa_ioc_s *ioc, bfa_boolean_t force); static void bfa_ioc_mbox_poll(struct bfa_ioc_s *ioc); static void bfa_ioc_mbox_hbfail(struct bfa_ioc_s *ioc); static void bfa_ioc_recover(struct bfa_ioc_s *ioc); static void bfa_ioc_check_attr_wwns(struct bfa_ioc_s *ioc); static void bfa_ioc_disable_comp(struct bfa_ioc_s *ioc); static void bfa_ioc_lpu_stop(struct bfa_ioc_s *ioc); -static void bfa_ioc_pf_enabled(struct bfa_ioc_s *ioc); -static void bfa_ioc_pf_disabled(struct bfa_ioc_s *ioc); -static void bfa_ioc_pf_failed(struct bfa_ioc_s *ioc); +static void bfa_ioc_debug_save_ftrc(struct bfa_ioc_s *ioc); +static void bfa_ioc_fail_notify(struct bfa_ioc_s *ioc); static void bfa_ioc_pf_fwmismatch(struct bfa_ioc_s *ioc); -/* - * hal_ioc_sm - */ /* * IOC state machine definitions/declarations @@ -116,10 +103,11 @@ enum ioc_event { IOC_E_ENABLED = 5, /* f/w enabled */ IOC_E_FWRSP_GETATTR = 6, /* IOC get attribute response */ IOC_E_DISABLED = 7, /* f/w disabled */ - IOC_E_FAILED = 8, /* failure notice by iocpf sm */ - IOC_E_HBFAIL = 9, /* heartbeat failure */ - IOC_E_HWERROR = 10, /* hardware error interrupt */ - IOC_E_TIMEOUT = 11, /* timeout */ + IOC_E_INITFAILED = 8, /* failure notice by iocpf sm */ + IOC_E_PFFAILED = 9, /* failure notice by iocpf sm */ + IOC_E_HBFAIL = 10, /* heartbeat failure */ + IOC_E_HWERROR = 11, /* hardware error interrupt */ + IOC_E_TIMEOUT = 12, /* timeout */ }; bfa_fsm_state_decl(bfa_ioc, uninit, struct bfa_ioc_s, enum ioc_event); @@ -127,7 +115,7 @@ bfa_fsm_state_decl(bfa_ioc, reset, struct bfa_ioc_s, enum ioc_event); bfa_fsm_state_decl(bfa_ioc, enabling, struct bfa_ioc_s, enum ioc_event); bfa_fsm_state_decl(bfa_ioc, getattr, struct bfa_ioc_s, enum ioc_event); bfa_fsm_state_decl(bfa_ioc, op, struct bfa_ioc_s, enum ioc_event); -bfa_fsm_state_decl(bfa_ioc, initfail, struct bfa_ioc_s, enum ioc_event); +bfa_fsm_state_decl(bfa_ioc, fail_retry, struct bfa_ioc_s, enum ioc_event); bfa_fsm_state_decl(bfa_ioc, fail, struct bfa_ioc_s, enum ioc_event); bfa_fsm_state_decl(bfa_ioc, disabling, struct bfa_ioc_s, enum ioc_event); bfa_fsm_state_decl(bfa_ioc, disabled, struct bfa_ioc_s, enum ioc_event); @@ -138,7 +126,7 @@ static struct bfa_sm_table_s ioc_sm_table[] = { {BFA_SM(bfa_ioc_sm_enabling), BFA_IOC_ENABLING}, {BFA_SM(bfa_ioc_sm_getattr), BFA_IOC_GETATTR}, {BFA_SM(bfa_ioc_sm_op), BFA_IOC_OPERATIONAL}, - {BFA_SM(bfa_ioc_sm_initfail), BFA_IOC_INITFAIL}, + {BFA_SM(bfa_ioc_sm_fail_retry), BFA_IOC_INITFAIL}, {BFA_SM(bfa_ioc_sm_fail), BFA_IOC_FAIL}, {BFA_SM(bfa_ioc_sm_disabling), BFA_IOC_DISABLING}, {BFA_SM(bfa_ioc_sm_disabled), BFA_IOC_DISABLED}, @@ -165,12 +153,6 @@ static struct bfa_sm_table_s ioc_sm_table[] = { /* * Forward declareations for iocpf state machine */ -static void bfa_iocpf_enable(struct bfa_ioc_s *ioc); -static void bfa_iocpf_disable(struct bfa_ioc_s *ioc); -static void bfa_iocpf_fail(struct bfa_ioc_s *ioc); -static void bfa_iocpf_initfail(struct bfa_ioc_s *ioc); -static void bfa_iocpf_getattrfail(struct bfa_ioc_s *ioc); -static void bfa_iocpf_stop(struct bfa_ioc_s *ioc); static void bfa_iocpf_timeout(void *ioc_arg); static void bfa_iocpf_sem_timeout(void *ioc_arg); @@ -213,9 +195,14 @@ bfa_fsm_state_decl(bfa_iocpf, semwait, struct bfa_iocpf_s, enum iocpf_event); bfa_fsm_state_decl(bfa_iocpf, hwinit, struct bfa_iocpf_s, enum iocpf_event); bfa_fsm_state_decl(bfa_iocpf, enabling, struct bfa_iocpf_s, enum iocpf_event); bfa_fsm_state_decl(bfa_iocpf, ready, struct bfa_iocpf_s, enum iocpf_event); +bfa_fsm_state_decl(bfa_iocpf, initfail_sync, struct bfa_iocpf_s, + enum iocpf_event); bfa_fsm_state_decl(bfa_iocpf, initfail, struct bfa_iocpf_s, enum iocpf_event); +bfa_fsm_state_decl(bfa_iocpf, fail_sync, struct bfa_iocpf_s, enum iocpf_event); bfa_fsm_state_decl(bfa_iocpf, fail, struct bfa_iocpf_s, enum iocpf_event); bfa_fsm_state_decl(bfa_iocpf, disabling, struct bfa_iocpf_s, enum iocpf_event); +bfa_fsm_state_decl(bfa_iocpf, disabling_sync, struct bfa_iocpf_s, + enum iocpf_event); bfa_fsm_state_decl(bfa_iocpf, disabled, struct bfa_iocpf_s, enum iocpf_event); static struct bfa_sm_table_s iocpf_sm_table[] = { @@ -226,9 +213,12 @@ static struct bfa_sm_table_s iocpf_sm_table[] = { {BFA_SM(bfa_iocpf_sm_hwinit), BFA_IOCPF_HWINIT}, {BFA_SM(bfa_iocpf_sm_enabling), BFA_IOCPF_HWINIT}, {BFA_SM(bfa_iocpf_sm_ready), BFA_IOCPF_READY}, + {BFA_SM(bfa_iocpf_sm_initfail_sync), BFA_IOCPF_INITFAIL}, {BFA_SM(bfa_iocpf_sm_initfail), BFA_IOCPF_INITFAIL}, + {BFA_SM(bfa_iocpf_sm_fail_sync), BFA_IOCPF_FAIL}, {BFA_SM(bfa_iocpf_sm_fail), BFA_IOCPF_FAIL}, {BFA_SM(bfa_iocpf_sm_disabling), BFA_IOCPF_DISABLING}, + {BFA_SM(bfa_iocpf_sm_disabling_sync), BFA_IOCPF_DISABLING}, {BFA_SM(bfa_iocpf_sm_disabled), BFA_IOCPF_DISABLED}, }; @@ -301,7 +291,7 @@ bfa_ioc_sm_reset(struct bfa_ioc_s *ioc, enum ioc_event event) static void bfa_ioc_sm_enabling_entry(struct bfa_ioc_s *ioc) { - bfa_iocpf_enable(ioc); + bfa_fsm_send_event(&ioc->iocpf, IOCPF_E_ENABLE); } /* @@ -318,13 +308,13 @@ bfa_ioc_sm_enabling(struct bfa_ioc_s *ioc, enum ioc_event event) bfa_fsm_set_state(ioc, bfa_ioc_sm_getattr); break; - case IOC_E_FAILED: - bfa_fsm_set_state(ioc, bfa_ioc_sm_initfail); - break; - + case IOC_E_PFFAILED: + /* !!! fall through !!! */ case IOC_E_HWERROR: - bfa_fsm_set_state(ioc, bfa_ioc_sm_initfail); - bfa_iocpf_initfail(ioc); + ioc->cbfn->enable_cbfn(ioc->bfa, BFA_STATUS_IOC_FAILURE); + bfa_fsm_set_state(ioc, bfa_ioc_sm_fail_retry); + if (event != IOC_E_PFFAILED) + bfa_fsm_send_event(&ioc->iocpf, IOCPF_E_INITFAIL); break; case IOC_E_DISABLE: @@ -333,7 +323,7 @@ bfa_ioc_sm_enabling(struct bfa_ioc_s *ioc, enum ioc_event event) case IOC_E_DETACH: bfa_fsm_set_state(ioc, bfa_ioc_sm_uninit); - bfa_iocpf_stop(ioc); + bfa_fsm_send_event(&ioc->iocpf, IOCPF_E_STOP); break; case IOC_E_ENABLE: @@ -367,18 +357,16 @@ bfa_ioc_sm_getattr(struct bfa_ioc_s *ioc, enum ioc_event event) bfa_fsm_set_state(ioc, bfa_ioc_sm_op); break; - case IOC_E_FAILED: - bfa_ioc_timer_stop(ioc); - bfa_fsm_set_state(ioc, bfa_ioc_sm_initfail); break; - + case IOC_E_PFFAILED: case IOC_E_HWERROR: bfa_ioc_timer_stop(ioc); - /* fall through */ - + /* !!! fall through !!! */ case IOC_E_TIMEOUT: - bfa_fsm_set_state(ioc, bfa_ioc_sm_initfail); - bfa_iocpf_getattrfail(ioc); + ioc->cbfn->enable_cbfn(ioc->bfa, BFA_STATUS_IOC_FAILURE); + bfa_fsm_set_state(ioc, bfa_ioc_sm_fail_retry); + if (event != IOC_E_PFFAILED) + bfa_fsm_send_event(&ioc->iocpf, IOCPF_E_GETATTRFAIL); break; case IOC_E_DISABLE: @@ -402,7 +390,7 @@ bfa_ioc_sm_op_entry(struct bfa_ioc_s *ioc) ioc->cbfn->enable_cbfn(ioc->bfa, BFA_STATUS_OK); bfa_ioc_hb_monitor(ioc); - BFA_LOG(KERN_INFO, bfad, log_level, "IOC enabled\n"); + BFA_LOG(KERN_INFO, bfad, bfa_log_level, "IOC enabled\n"); } static void @@ -415,22 +403,24 @@ bfa_ioc_sm_op(struct bfa_ioc_s *ioc, enum ioc_event event) break; case IOC_E_DISABLE: - bfa_ioc_hb_stop(ioc); + bfa_hb_timer_stop(ioc); bfa_fsm_set_state(ioc, bfa_ioc_sm_disabling); break; - case IOC_E_FAILED: - bfa_ioc_hb_stop(ioc); - bfa_fsm_set_state(ioc, bfa_ioc_sm_fail); - break; - + case IOC_E_PFFAILED: case IOC_E_HWERROR: - bfa_ioc_hb_stop(ioc); + bfa_hb_timer_stop(ioc); /* !!! fall through !!! */ - case IOC_E_HBFAIL: - bfa_fsm_set_state(ioc, bfa_ioc_sm_fail); - bfa_iocpf_fail(ioc); + bfa_ioc_fail_notify(ioc); + + if (ioc->iocpf.auto_recover) + bfa_fsm_set_state(ioc, bfa_ioc_sm_fail_retry); + else + bfa_fsm_set_state(ioc, bfa_ioc_sm_fail); + + if (event != IOC_E_PFFAILED) + bfa_fsm_send_event(&ioc->iocpf, IOCPF_E_FAIL); break; default: @@ -443,8 +433,8 @@ static void bfa_ioc_sm_disabling_entry(struct bfa_ioc_s *ioc) { struct bfad_s *bfad = (struct bfad_s *)ioc->bfa->bfad; - bfa_iocpf_disable(ioc); - BFA_LOG(KERN_INFO, bfad, log_level, "IOC disabled\n"); + bfa_fsm_send_event(&ioc->iocpf, IOCPF_E_DISABLE); + BFA_LOG(KERN_INFO, bfad, bfa_log_level, "IOC disabled\n"); } /* @@ -466,7 +456,7 @@ bfa_ioc_sm_disabling(struct bfa_ioc_s *ioc, enum ioc_event event) * after iocpf sm completes failure processing and * moves to disabled state. */ - bfa_iocpf_fail(ioc); + bfa_fsm_send_event(&ioc->iocpf, IOCPF_E_FAIL); break; default: @@ -499,7 +489,7 @@ bfa_ioc_sm_disabled(struct bfa_ioc_s *ioc, enum ioc_event event) case IOC_E_DETACH: bfa_fsm_set_state(ioc, bfa_ioc_sm_uninit); - bfa_iocpf_stop(ioc); + bfa_fsm_send_event(&ioc->iocpf, IOCPF_E_STOP); break; default: @@ -509,16 +499,16 @@ bfa_ioc_sm_disabled(struct bfa_ioc_s *ioc, enum ioc_event event) static void -bfa_ioc_sm_initfail_entry(struct bfa_ioc_s *ioc) +bfa_ioc_sm_fail_retry_entry(struct bfa_ioc_s *ioc) { - ioc->cbfn->enable_cbfn(ioc->bfa, BFA_STATUS_IOC_FAILURE); + bfa_trc(ioc, 0); } /* - * Hardware initialization failed. + * Hardware initialization retry. */ static void -bfa_ioc_sm_initfail(struct bfa_ioc_s *ioc, enum ioc_event event) +bfa_ioc_sm_fail_retry(struct bfa_ioc_s *ioc, enum ioc_event event) { bfa_trc(ioc, event); @@ -527,11 +517,21 @@ bfa_ioc_sm_initfail(struct bfa_ioc_s *ioc, enum ioc_event event) bfa_fsm_set_state(ioc, bfa_ioc_sm_getattr); break; - case IOC_E_FAILED: + case IOC_E_PFFAILED: + case IOC_E_HWERROR: /* - * Initialization failure during iocpf init retry. + * Initialization retry failed. */ ioc->cbfn->enable_cbfn(ioc->bfa, BFA_STATUS_IOC_FAILURE); + if (event != IOC_E_PFFAILED) + bfa_fsm_send_event(&ioc->iocpf, IOCPF_E_INITFAIL); + break; + + case IOC_E_INITFAILED: + bfa_fsm_set_state(ioc, bfa_ioc_sm_fail); + break; + + case IOC_E_ENABLE: break; case IOC_E_DISABLE: @@ -540,7 +540,7 @@ bfa_ioc_sm_initfail(struct bfa_ioc_s *ioc, enum ioc_event event) case IOC_E_DETACH: bfa_fsm_set_state(ioc, bfa_ioc_sm_uninit); - bfa_iocpf_stop(ioc); + bfa_fsm_send_event(&ioc->iocpf, IOCPF_E_STOP); break; default: @@ -552,21 +552,7 @@ bfa_ioc_sm_initfail(struct bfa_ioc_s *ioc, enum ioc_event event) static void bfa_ioc_sm_fail_entry(struct bfa_ioc_s *ioc) { - struct list_head *qe; - struct bfa_ioc_hbfail_notify_s *notify; - struct bfad_s *bfad = (struct bfad_s *)ioc->bfa->bfad; - - /* - * Notify driver and common modules registered for notification. - */ - ioc->cbfn->hbfail_cbfn(ioc->bfa); - list_for_each(qe, &ioc->hb_notify_q) { - notify = (struct bfa_ioc_hbfail_notify_s *) qe; - notify->cbfn(notify->cbarg); - } - - BFA_LOG(KERN_CRIT, bfad, log_level, - "Heart Beat of IOC has failed\n"); + bfa_trc(ioc, 0); } /* @@ -579,23 +565,19 @@ bfa_ioc_sm_fail(struct bfa_ioc_s *ioc, enum ioc_event event) switch (event) { - case IOC_E_FAILED: - /* - * Initialization failure during iocpf recovery. - * !!! Fall through !!! - */ case IOC_E_ENABLE: ioc->cbfn->enable_cbfn(ioc->bfa, BFA_STATUS_IOC_FAILURE); break; - case IOC_E_ENABLED: - bfa_fsm_set_state(ioc, bfa_ioc_sm_getattr); - break; - case IOC_E_DISABLE: bfa_fsm_set_state(ioc, bfa_ioc_sm_disabling); break; + case IOC_E_DETACH: + bfa_fsm_set_state(ioc, bfa_ioc_sm_uninit); + bfa_fsm_send_event(&ioc->iocpf, IOCPF_E_STOP); + break; + case IOC_E_HWERROR: /* * HB failure notification, ignore. @@ -606,13 +588,10 @@ bfa_ioc_sm_fail(struct bfa_ioc_s *ioc, enum ioc_event event) } } - - /* * IOCPF State Machine */ - /* * Reset entry actions -- initialize state machine */ @@ -668,22 +647,29 @@ bfa_iocpf_sm_fwcheck(struct bfa_iocpf_s *iocpf, enum iocpf_event event) switch (event) { case IOCPF_E_SEMLOCKED: if (bfa_ioc_firmware_lock(ioc)) { - iocpf->retry_count = 0; - bfa_fsm_set_state(iocpf, bfa_iocpf_sm_hwinit); + if (bfa_ioc_sync_complete(ioc)) { + iocpf->retry_count = 0; + bfa_ioc_sync_join(ioc); + bfa_fsm_set_state(iocpf, bfa_iocpf_sm_hwinit); + } else { + bfa_ioc_firmware_unlock(ioc); + writel(1, ioc->ioc_regs.ioc_sem_reg); + bfa_sem_timer_start(ioc); + } } else { - bfa_ioc_hw_sem_release(ioc); + writel(1, ioc->ioc_regs.ioc_sem_reg); bfa_fsm_set_state(iocpf, bfa_iocpf_sm_mismatch); } break; case IOCPF_E_DISABLE: - bfa_ioc_hw_sem_get_cancel(ioc); + bfa_sem_timer_stop(ioc); bfa_fsm_set_state(iocpf, bfa_iocpf_sm_reset); - bfa_ioc_pf_disabled(ioc); + bfa_fsm_send_event(ioc, IOC_E_DISABLED); break; case IOCPF_E_STOP: - bfa_ioc_hw_sem_get_cancel(ioc); + bfa_sem_timer_stop(ioc); bfa_fsm_set_state(iocpf, bfa_iocpf_sm_reset); break; @@ -726,7 +712,7 @@ bfa_iocpf_sm_mismatch(struct bfa_iocpf_s *iocpf, enum iocpf_event event) case IOCPF_E_DISABLE: bfa_iocpf_timer_stop(ioc); bfa_fsm_set_state(iocpf, bfa_iocpf_sm_reset); - bfa_ioc_pf_disabled(ioc); + bfa_fsm_send_event(ioc, IOC_E_DISABLED); break; case IOCPF_E_STOP: @@ -760,13 +746,18 @@ bfa_iocpf_sm_semwait(struct bfa_iocpf_s *iocpf, enum iocpf_event event) switch (event) { case IOCPF_E_SEMLOCKED: - iocpf->retry_count = 0; - bfa_fsm_set_state(iocpf, bfa_iocpf_sm_hwinit); + if (bfa_ioc_sync_complete(ioc)) { + bfa_ioc_sync_join(ioc); + bfa_fsm_set_state(iocpf, bfa_iocpf_sm_hwinit); + } else { + writel(1, ioc->ioc_regs.ioc_sem_reg); + bfa_sem_timer_start(ioc); + } break; case IOCPF_E_DISABLE: - bfa_ioc_hw_sem_get_cancel(ioc); - bfa_fsm_set_state(iocpf, bfa_iocpf_sm_disabled); + bfa_sem_timer_stop(ioc); + bfa_fsm_set_state(iocpf, bfa_iocpf_sm_disabling_sync); break; default: @@ -774,12 +765,11 @@ bfa_iocpf_sm_semwait(struct bfa_iocpf_s *iocpf, enum iocpf_event event) } } - static void bfa_iocpf_sm_hwinit_entry(struct bfa_iocpf_s *iocpf) { bfa_iocpf_timer_start(iocpf->ioc); - bfa_ioc_reset(iocpf->ioc, BFA_FALSE); + bfa_ioc_hwinit(iocpf->ioc, BFA_FALSE); } /* @@ -806,23 +796,16 @@ bfa_iocpf_sm_hwinit(struct bfa_iocpf_s *iocpf, enum iocpf_event event) */ case IOCPF_E_TIMEOUT: - iocpf->retry_count++; - if (iocpf->retry_count < BFA_IOC_HWINIT_MAX) { - bfa_iocpf_timer_start(ioc); - bfa_ioc_reset(ioc, BFA_TRUE); - break; - } - - bfa_ioc_hw_sem_release(ioc); - bfa_fsm_set_state(iocpf, bfa_iocpf_sm_initfail); - + writel(1, ioc->ioc_regs.ioc_sem_reg); if (event == IOCPF_E_TIMEOUT) - bfa_ioc_pf_failed(ioc); + bfa_fsm_send_event(ioc, IOC_E_PFFAILED); + bfa_fsm_set_state(iocpf, bfa_iocpf_sm_initfail_sync); break; case IOCPF_E_DISABLE: - bfa_ioc_hw_sem_release(ioc); bfa_iocpf_timer_stop(ioc); + bfa_ioc_sync_leave(ioc); + writel(1, ioc->ioc_regs.ioc_sem_reg); bfa_fsm_set_state(iocpf, bfa_iocpf_sm_disabled); break; @@ -831,7 +814,6 @@ bfa_iocpf_sm_hwinit(struct bfa_iocpf_s *iocpf, enum iocpf_event event) } } - static void bfa_iocpf_sm_enabling_entry(struct bfa_iocpf_s *iocpf) { @@ -853,7 +835,7 @@ bfa_iocpf_sm_enabling(struct bfa_iocpf_s *iocpf, enum iocpf_event event) switch (event) { case IOCPF_E_FWRSP_ENABLE: bfa_iocpf_timer_stop(ioc); - bfa_ioc_hw_sem_release(ioc); + writel(1, ioc->ioc_regs.ioc_sem_reg); bfa_fsm_set_state(iocpf, bfa_iocpf_sm_ready); break; @@ -864,23 +846,15 @@ bfa_iocpf_sm_enabling(struct bfa_iocpf_s *iocpf, enum iocpf_event event) */ case IOCPF_E_TIMEOUT: - iocpf->retry_count++; - if (iocpf->retry_count < BFA_IOC_HWINIT_MAX) { - writel(BFI_IOC_UNINIT, ioc->ioc_regs.ioc_fwstate); - bfa_fsm_set_state(iocpf, bfa_iocpf_sm_hwinit); - break; - } - - bfa_ioc_hw_sem_release(ioc); - bfa_fsm_set_state(iocpf, bfa_iocpf_sm_initfail); - + writel(1, ioc->ioc_regs.ioc_sem_reg); if (event == IOCPF_E_TIMEOUT) - bfa_ioc_pf_failed(ioc); + bfa_fsm_send_event(ioc, IOC_E_PFFAILED); + bfa_fsm_set_state(iocpf, bfa_iocpf_sm_initfail_sync); break; case IOCPF_E_DISABLE: bfa_iocpf_timer_stop(ioc); - bfa_ioc_hw_sem_release(ioc); + writel(1, ioc->ioc_regs.ioc_sem_reg); bfa_fsm_set_state(iocpf, bfa_iocpf_sm_disabling); break; @@ -893,12 +867,10 @@ bfa_iocpf_sm_enabling(struct bfa_iocpf_s *iocpf, enum iocpf_event event) } } - - static void bfa_iocpf_sm_ready_entry(struct bfa_iocpf_s *iocpf) { - bfa_ioc_pf_enabled(iocpf->ioc); + bfa_fsm_send_event(iocpf->ioc, IOC_E_ENABLED); } static void @@ -914,20 +886,21 @@ bfa_iocpf_sm_ready(struct bfa_iocpf_s *iocpf, enum iocpf_event event) break; case IOCPF_E_GETATTRFAIL: - bfa_fsm_set_state(iocpf, bfa_iocpf_sm_initfail); + bfa_fsm_set_state(iocpf, bfa_iocpf_sm_initfail_sync); break; case IOCPF_E_FAIL: - bfa_fsm_set_state(iocpf, bfa_iocpf_sm_fail); + bfa_fsm_set_state(iocpf, bfa_iocpf_sm_fail_sync); break; case IOCPF_E_FWREADY: - if (bfa_ioc_is_operational(ioc)) - bfa_fsm_set_state(iocpf, bfa_iocpf_sm_fail); - else - bfa_fsm_set_state(iocpf, bfa_iocpf_sm_initfail); - - bfa_ioc_pf_failed(ioc); + if (bfa_ioc_is_operational(ioc)) { + bfa_fsm_send_event(ioc, IOC_E_PFFAILED); + bfa_fsm_set_state(iocpf, bfa_iocpf_sm_fail_sync); + } else { + bfa_fsm_send_event(ioc, IOC_E_PFFAILED); + bfa_fsm_set_state(iocpf, bfa_iocpf_sm_initfail_sync); + } break; default: @@ -935,7 +908,6 @@ bfa_iocpf_sm_ready(struct bfa_iocpf_s *iocpf, enum iocpf_event event) } } - static void bfa_iocpf_sm_disabling_entry(struct bfa_iocpf_s *iocpf) { @@ -957,7 +929,7 @@ bfa_iocpf_sm_disabling(struct bfa_iocpf_s *iocpf, enum iocpf_event event) case IOCPF_E_FWRSP_DISABLE: case IOCPF_E_FWREADY: bfa_iocpf_timer_stop(ioc); - bfa_fsm_set_state(iocpf, bfa_iocpf_sm_disabled); + bfa_fsm_set_state(iocpf, bfa_iocpf_sm_disabling_sync); break; case IOCPF_E_FAIL: @@ -968,7 +940,7 @@ bfa_iocpf_sm_disabling(struct bfa_iocpf_s *iocpf, enum iocpf_event event) case IOCPF_E_TIMEOUT: writel(BFI_IOC_FAIL, ioc->ioc_regs.ioc_fwstate); - bfa_fsm_set_state(iocpf, bfa_iocpf_sm_disabled); + bfa_fsm_set_state(iocpf, bfa_iocpf_sm_disabling_sync); break; case IOCPF_E_FWRSP_ENABLE: @@ -979,13 +951,44 @@ bfa_iocpf_sm_disabling(struct bfa_iocpf_s *iocpf, enum iocpf_event event) } } +static void +bfa_iocpf_sm_disabling_sync_entry(struct bfa_iocpf_s *iocpf) +{ + bfa_ioc_hw_sem_get(iocpf->ioc); +} + +/* + * IOC hb ack request is being removed. + */ +static void +bfa_iocpf_sm_disabling_sync(struct bfa_iocpf_s *iocpf, enum iocpf_event event) +{ + struct bfa_ioc_s *ioc = iocpf->ioc; + + bfa_trc(ioc, event); + + switch (event) { + case IOCPF_E_SEMLOCKED: + bfa_ioc_sync_leave(ioc); + writel(1, ioc->ioc_regs.ioc_sem_reg); + bfa_fsm_set_state(iocpf, bfa_iocpf_sm_disabled); + break; + + case IOCPF_E_FAIL: + break; + + default: + bfa_sm_fault(ioc, event); + } +} + /* * IOC disable completion entry. */ static void bfa_iocpf_sm_disabled_entry(struct bfa_iocpf_s *iocpf) { - bfa_ioc_pf_disabled(iocpf->ioc); + bfa_fsm_send_event(iocpf->ioc, IOC_E_DISABLED); } static void @@ -997,6 +1000,7 @@ bfa_iocpf_sm_disabled(struct bfa_iocpf_s *iocpf, enum iocpf_event event) switch (event) { case IOCPF_E_ENABLE: + iocpf->retry_count = 0; bfa_fsm_set_state(iocpf, bfa_iocpf_sm_semwait); break; @@ -1010,11 +1014,64 @@ bfa_iocpf_sm_disabled(struct bfa_iocpf_s *iocpf, enum iocpf_event event) } } +static void +bfa_iocpf_sm_initfail_sync_entry(struct bfa_iocpf_s *iocpf) +{ + bfa_ioc_hw_sem_get(iocpf->ioc); +} + +/* + * Hardware initialization failed. + */ +static void +bfa_iocpf_sm_initfail_sync(struct bfa_iocpf_s *iocpf, enum iocpf_event event) +{ + struct bfa_ioc_s *ioc = iocpf->ioc; + + bfa_trc(ioc, event); + + switch (event) { + case IOCPF_E_SEMLOCKED: + bfa_ioc_notify_fail(ioc); + bfa_ioc_sync_ack(ioc); + iocpf->retry_count++; + if (iocpf->retry_count >= BFA_IOC_HWINIT_MAX) { + bfa_ioc_sync_leave(ioc); + writel(1, ioc->ioc_regs.ioc_sem_reg); + bfa_fsm_set_state(iocpf, bfa_iocpf_sm_initfail); + } else { + if (bfa_ioc_sync_complete(ioc)) + bfa_fsm_set_state(iocpf, bfa_iocpf_sm_hwinit); + else { + writel(1, ioc->ioc_regs.ioc_sem_reg); + bfa_fsm_set_state(iocpf, bfa_iocpf_sm_semwait); + } + } + break; + + case IOCPF_E_DISABLE: + bfa_sem_timer_stop(ioc); + bfa_fsm_set_state(iocpf, bfa_iocpf_sm_disabling_sync); + break; + + case IOCPF_E_STOP: + bfa_sem_timer_stop(ioc); + bfa_ioc_firmware_unlock(ioc); + bfa_fsm_set_state(iocpf, bfa_iocpf_sm_reset); + break; + + case IOCPF_E_FAIL: + break; + + default: + bfa_sm_fault(ioc, event); + } +} static void bfa_iocpf_sm_initfail_entry(struct bfa_iocpf_s *iocpf) { - bfa_iocpf_timer_start(iocpf->ioc); + bfa_fsm_send_event(iocpf->ioc, IOC_E_INITFAILED); } /* @@ -1029,47 +1086,77 @@ bfa_iocpf_sm_initfail(struct bfa_iocpf_s *iocpf, enum iocpf_event event) switch (event) { case IOCPF_E_DISABLE: - bfa_iocpf_timer_stop(ioc); bfa_fsm_set_state(iocpf, bfa_iocpf_sm_disabled); break; case IOCPF_E_STOP: - bfa_iocpf_timer_stop(ioc); bfa_ioc_firmware_unlock(ioc); bfa_fsm_set_state(iocpf, bfa_iocpf_sm_reset); break; - case IOCPF_E_TIMEOUT: - bfa_fsm_set_state(iocpf, bfa_iocpf_sm_semwait); - break; - default: bfa_sm_fault(ioc, event); } } - static void -bfa_iocpf_sm_fail_entry(struct bfa_iocpf_s *iocpf) +bfa_iocpf_sm_fail_sync_entry(struct bfa_iocpf_s *iocpf) { /* * Mark IOC as failed in hardware and stop firmware. */ bfa_ioc_lpu_stop(iocpf->ioc); - writel(BFI_IOC_FAIL, iocpf->ioc->ioc_regs.ioc_fwstate); - - /* - * Notify other functions on HB failure. - */ - bfa_ioc_notify_hbfail(iocpf->ioc); /* * Flush any queued up mailbox requests. */ bfa_ioc_mbox_hbfail(iocpf->ioc); - if (iocpf->auto_recover) - bfa_iocpf_recovery_timer_start(iocpf->ioc); + bfa_ioc_hw_sem_get(iocpf->ioc); +} + +static void +bfa_iocpf_sm_fail_sync(struct bfa_iocpf_s *iocpf, enum iocpf_event event) +{ + struct bfa_ioc_s *ioc = iocpf->ioc; + + bfa_trc(ioc, event); + + switch (event) { + case IOCPF_E_SEMLOCKED: + iocpf->retry_count = 0; + bfa_ioc_sync_ack(ioc); + bfa_ioc_notify_fail(ioc); + if (!iocpf->auto_recover) { + bfa_ioc_sync_leave(ioc); + writel(1, ioc->ioc_regs.ioc_sem_reg); + bfa_fsm_set_state(iocpf, bfa_iocpf_sm_fail); + } else { + if (bfa_ioc_sync_complete(ioc)) + bfa_fsm_set_state(iocpf, bfa_iocpf_sm_hwinit); + else { + writel(1, ioc->ioc_regs.ioc_sem_reg); + bfa_fsm_set_state(iocpf, bfa_iocpf_sm_semwait); + } + } + break; + + case IOCPF_E_DISABLE: + bfa_sem_timer_stop(ioc); + bfa_fsm_set_state(iocpf, bfa_iocpf_sm_disabling_sync); + break; + + case IOCPF_E_FAIL: + break; + + default: + bfa_sm_fault(ioc, event); + } +} + +static void +bfa_iocpf_sm_fail_entry(struct bfa_iocpf_s *iocpf) +{ } /* @@ -1084,24 +1171,16 @@ bfa_iocpf_sm_fail(struct bfa_iocpf_s *iocpf, enum iocpf_event event) switch (event) { case IOCPF_E_DISABLE: - if (iocpf->auto_recover) - bfa_iocpf_timer_stop(ioc); bfa_fsm_set_state(iocpf, bfa_iocpf_sm_disabled); break; - case IOCPF_E_TIMEOUT: - bfa_fsm_set_state(iocpf, bfa_iocpf_sm_semwait); - break; - default: bfa_sm_fault(ioc, event); } } - - /* - * hal_ioc_pvt BFA IOC private functions + * BFA IOC private functions */ static void @@ -1139,16 +1218,10 @@ bfa_ioc_sem_get(void __iomem *sem_reg) if (r32 == 0) return BFA_TRUE; - bfa_assert(cnt < BFA_SEM_SPINCNT); + WARN_ON(cnt >= BFA_SEM_SPINCNT); return BFA_FALSE; } -void -bfa_ioc_sem_release(void __iomem *sem_reg) -{ - writel(1, sem_reg); -} - static void bfa_ioc_hw_sem_get(struct bfa_ioc_s *ioc) { @@ -1167,18 +1240,6 @@ bfa_ioc_hw_sem_get(struct bfa_ioc_s *ioc) bfa_sem_timer_start(ioc); } -void -bfa_ioc_hw_sem_release(struct bfa_ioc_s *ioc) -{ - writel(1, ioc->ioc_regs.ioc_sem_reg); -} - -static void -bfa_ioc_hw_sem_get_cancel(struct bfa_ioc_s *ioc) -{ - bfa_sem_timer_stop(ioc); -} - /* * Initialize LPU local memory (aka secondary memory / SRAM) */ @@ -1212,7 +1273,7 @@ bfa_ioc_lmem_init(struct bfa_ioc_s *ioc) * If memory initialization is not successful, IOC timeout will catch * such failures. */ - bfa_assert(pss_ctl & __PSS_LMEM_INIT_DONE); + WARN_ON(!(pss_ctl & __PSS_LMEM_INIT_DONE)); bfa_trc(ioc, pss_ctl); pss_ctl &= ~(__PSS_LMEM_INIT_DONE | __PSS_LMEM_INIT_EN); @@ -1258,8 +1319,8 @@ bfa_ioc_fwver_get(struct bfa_ioc_s *ioc, struct bfi_ioc_image_hdr_s *fwhdr) int i; u32 *fwsig = (u32 *) fwhdr; - pgnum = bfa_ioc_smem_pgnum(ioc, loff); - pgoff = bfa_ioc_smem_pgoff(ioc, loff); + pgnum = PSS_SMEM_PGNUM(ioc->ioc_regs.smem_pg0, loff); + pgoff = PSS_SMEM_PGOFF(loff); writel(pgnum, ioc->ioc_regs.host_page_num_fn); for (i = 0; i < (sizeof(struct bfi_ioc_image_hdr_s) / sizeof(u32)); @@ -1304,12 +1365,6 @@ bfa_ioc_fwver_valid(struct bfa_ioc_s *ioc, u32 boot_env) { struct bfi_ioc_image_hdr_s fwhdr, *drv_fwhdr; - /* - * If bios/efi boot (flash based) -- return true - */ - if (bfa_ioc_is_bios_optrom(ioc)) - return BFA_TRUE; - bfa_ioc_fwver_get(ioc, &fwhdr); drv_fwhdr = (struct bfi_ioc_image_hdr_s *) bfa_cb_image_get_chunk(BFA_IOC_FWIMG_TYPE(ioc), 0); @@ -1342,7 +1397,6 @@ bfa_ioc_msgflush(struct bfa_ioc_s *ioc) writel(1, ioc->ioc_regs.lpu_mbox_cmd); } - static void bfa_ioc_hwinit(struct bfa_ioc_s *ioc, bfa_boolean_t force) { @@ -1362,22 +1416,6 @@ bfa_ioc_hwinit(struct bfa_ioc_s *ioc, bfa_boolean_t force) boot_env = BFI_BOOT_LOADER_OS; /* - * Flash based firmware boot BIOS env. - */ - if (bfa_ioc_is_bios_optrom(ioc)) { - boot_type = BFI_BOOT_TYPE_FLASH; - boot_env = BFI_BOOT_LOADER_BIOS; - } - - /* - * Flash based firmware boot UEFI env. - */ - if (bfa_ioc_is_uefi(ioc)) { - boot_type = BFI_BOOT_TYPE_FLASH; - boot_env = BFI_BOOT_LOADER_UEFI; - } - - /* * check if firmware is valid */ fwvalid = (ioc_fwstate == BFI_IOC_UNINIT) ? @@ -1405,8 +1443,7 @@ bfa_ioc_hwinit(struct bfa_ioc_s *ioc, bfa_boolean_t force) * convergence, IOC will be in operational state when 2nd driver * is loaded. */ - if (ioc_fwstate == BFI_IOC_DISABLED || - (!bfa_ioc_is_bios_optrom(ioc) && ioc_fwstate == BFI_IOC_OP)) { + if (ioc_fwstate == BFI_IOC_DISABLED || ioc_fwstate == BFI_IOC_OP) { /* * When using MSI-X any pending firmware ready event should @@ -1442,7 +1479,7 @@ bfa_ioc_mbox_send(struct bfa_ioc_s *ioc, void *ioc_msg, int len) bfa_trc(ioc, msgp[0]); bfa_trc(ioc, len); - bfa_assert(len <= BFI_IOC_MSGLEN_MAX); + WARN_ON(len > BFI_IOC_MSGLEN_MAX); /* * first write msg to mailbox registers @@ -1465,12 +1502,12 @@ static void bfa_ioc_send_enable(struct bfa_ioc_s *ioc) { struct bfi_ioc_ctrl_req_s enable_req; - struct bfa_timeval_s tv; + struct timeval tv; bfi_h2i_set(enable_req.mh, BFI_MC_IOC, BFI_IOC_H2I_ENABLE_REQ, bfa_ioc_portid(ioc)); enable_req.ioc_class = ioc->ioc_mc; - bfa_os_gettimeofday(&tv); + do_gettimeofday(&tv); enable_req.tv_sec = be32_to_cpu(tv.tv_sec); bfa_ioc_mbox_send(ioc, &enable_req, sizeof(struct bfi_ioc_ctrl_req_s)); } @@ -1504,7 +1541,6 @@ bfa_ioc_hb_check(void *cbarg) hb_count = readl(ioc->ioc_regs.heartbeat); if (ioc->hb_count == hb_count) { - printk(KERN_CRIT "Firmware heartbeat failure at %d", hb_count); bfa_ioc_recover(ioc); return; } else { @@ -1522,13 +1558,6 @@ bfa_ioc_hb_monitor(struct bfa_ioc_s *ioc) bfa_hb_timer_start(ioc); } -static void -bfa_ioc_hb_stop(struct bfa_ioc_s *ioc) -{ - bfa_hb_timer_stop(ioc); -} - - /* * Initiate a full firmware download. */ @@ -1550,8 +1579,8 @@ bfa_ioc_download_fw(struct bfa_ioc_s *ioc, u32 boot_type, bfa_trc(ioc, bfa_cb_image_get_size(BFA_IOC_FWIMG_TYPE(ioc))); fwimg = bfa_cb_image_get_chunk(BFA_IOC_FWIMG_TYPE(ioc), chunkno); - pgnum = bfa_ioc_smem_pgnum(ioc, loff); - pgoff = bfa_ioc_smem_pgoff(ioc, loff); + pgnum = PSS_SMEM_PGNUM(ioc->ioc_regs.smem_pg0, loff); + pgoff = PSS_SMEM_PGOFF(loff); writel(pgnum, ioc->ioc_regs.host_page_num_fn); @@ -1581,7 +1610,8 @@ bfa_ioc_download_fw(struct bfa_ioc_s *ioc, u32 boot_type, } } - writel(bfa_ioc_smem_pgnum(ioc, 0), ioc->ioc_regs.host_page_num_fn); + writel(PSS_SMEM_PGNUM(ioc->ioc_regs.smem_pg0, 0), + ioc->ioc_regs.host_page_num_fn); /* * Set boot type and boot param at the end. @@ -1592,11 +1622,6 @@ bfa_ioc_download_fw(struct bfa_ioc_s *ioc, u32 boot_type, swab32(boot_env)); } -static void -bfa_ioc_reset(struct bfa_ioc_s *ioc, bfa_boolean_t force) -{ - bfa_ioc_hwinit(ioc, force); -} /* * Update BFA configuration from firmware configuration. @@ -1683,12 +1708,13 @@ bfa_ioc_mbox_hbfail(struct bfa_ioc_s *ioc) static bfa_status_t bfa_ioc_smem_read(struct bfa_ioc_s *ioc, void *tbuf, u32 soff, u32 sz) { - u32 pgnum, loff, r32; + u32 pgnum, loff; + __be32 r32; int i, len; u32 *buf = tbuf; - pgnum = bfa_ioc_smem_pgnum(ioc, soff); - loff = bfa_ioc_smem_pgoff(ioc, soff); + pgnum = PSS_SMEM_PGNUM(ioc->ioc_regs.smem_pg0, soff); + loff = PSS_SMEM_PGOFF(soff); bfa_trc(ioc, pgnum); bfa_trc(ioc, loff); bfa_trc(ioc, sz); @@ -1719,11 +1745,12 @@ bfa_ioc_smem_read(struct bfa_ioc_s *ioc, void *tbuf, u32 soff, u32 sz) writel(pgnum, ioc->ioc_regs.host_page_num_fn); } } - writel(bfa_ioc_smem_pgnum(ioc, 0), ioc->ioc_regs.host_page_num_fn); + writel(PSS_SMEM_PGNUM(ioc->ioc_regs.smem_pg0, 0), + ioc->ioc_regs.host_page_num_fn); /* * release semaphore. */ - bfa_ioc_sem_release(ioc->ioc_regs.ioc_init_sem_reg); + writel(1, ioc->ioc_regs.ioc_init_sem_reg); bfa_trc(ioc, pgnum); return BFA_STATUS_OK; @@ -1742,8 +1769,8 @@ bfa_ioc_smem_clr(struct bfa_ioc_s *ioc, u32 soff, u32 sz) int i, len; u32 pgnum, loff; - pgnum = bfa_ioc_smem_pgnum(ioc, soff); - loff = bfa_ioc_smem_pgoff(ioc, soff); + pgnum = PSS_SMEM_PGNUM(ioc->ioc_regs.smem_pg0, soff); + loff = PSS_SMEM_PGOFF(soff); bfa_trc(ioc, pgnum); bfa_trc(ioc, loff); bfa_trc(ioc, sz); @@ -1773,35 +1800,38 @@ bfa_ioc_smem_clr(struct bfa_ioc_s *ioc, u32 soff, u32 sz) writel(pgnum, ioc->ioc_regs.host_page_num_fn); } } - writel(bfa_ioc_smem_pgnum(ioc, 0), ioc->ioc_regs.host_page_num_fn); + writel(PSS_SMEM_PGNUM(ioc->ioc_regs.smem_pg0, 0), + ioc->ioc_regs.host_page_num_fn); /* * release semaphore. */ - bfa_ioc_sem_release(ioc->ioc_regs.ioc_init_sem_reg); + writel(1, ioc->ioc_regs.ioc_init_sem_reg); bfa_trc(ioc, pgnum); return BFA_STATUS_OK; } -/* - * hal iocpf to ioc interface - */ static void -bfa_ioc_pf_enabled(struct bfa_ioc_s *ioc) +bfa_ioc_fail_notify(struct bfa_ioc_s *ioc) { - bfa_fsm_send_event(ioc, IOC_E_ENABLED); -} + struct list_head *qe; + struct bfa_ioc_hbfail_notify_s *notify; + struct bfad_s *bfad = (struct bfad_s *)ioc->bfa->bfad; -static void -bfa_ioc_pf_disabled(struct bfa_ioc_s *ioc) -{ - bfa_fsm_send_event(ioc, IOC_E_DISABLED); -} + /* + * Notify driver and common modules registered for notification. + */ + ioc->cbfn->hbfail_cbfn(ioc->bfa); + list_for_each(qe, &ioc->hb_notify_q) { + notify = (struct bfa_ioc_hbfail_notify_s *) qe; + notify->cbfn(notify->cbarg); + } + + bfa_ioc_debug_save_ftrc(ioc); + + BFA_LOG(KERN_CRIT, bfad, bfa_log_level, + "Heart Beat of IOC has failed\n"); -static void -bfa_ioc_pf_failed(struct bfa_ioc_s *ioc) -{ - bfa_fsm_send_event(ioc, IOC_E_FAILED); } static void @@ -1812,17 +1842,11 @@ bfa_ioc_pf_fwmismatch(struct bfa_ioc_s *ioc) * Provide enable completion callback. */ ioc->cbfn->enable_cbfn(ioc->bfa, BFA_STATUS_IOC_FAILURE); - BFA_LOG(KERN_WARNING, bfad, log_level, + BFA_LOG(KERN_WARNING, bfad, bfa_log_level, "Running firmware version is incompatible " "with the driver version\n"); } - - -/* - * hal_ioc_public - */ - bfa_status_t bfa_ioc_pll_init(struct bfa_ioc_s *ioc) { @@ -1838,7 +1862,7 @@ bfa_ioc_pll_init(struct bfa_ioc_s *ioc) /* * release semaphore. */ - bfa_ioc_sem_release(ioc->ioc_regs.ioc_init_sem_reg); + writel(1, ioc->ioc_regs.ioc_init_sem_reg); return BFA_STATUS_OK; } @@ -1909,7 +1933,7 @@ bfa_ioc_is_initialized(struct bfa_ioc_s *ioc) void bfa_ioc_msgget(struct bfa_ioc_s *ioc, void *mbmsg) { - u32 *msgp = mbmsg; + __be32 *msgp = mbmsg; u32 r32; int i; @@ -1962,7 +1986,7 @@ bfa_ioc_isr(struct bfa_ioc_s *ioc, struct bfi_mbmsg_s *m) default: bfa_trc(ioc, msg->mh.msg_id); - bfa_assert(0); + WARN_ON(1); } } @@ -2043,15 +2067,6 @@ bfa_ioc_mem_claim(struct bfa_ioc_s *ioc, u8 *dm_kva, u64 dm_pa) ioc->attr = (struct bfi_ioc_attr_s *) dm_kva; } -/* - * Return size of dma memory required. - */ -u32 -bfa_ioc_meminfo(void) -{ - return BFA_ROUNDUP(sizeof(struct bfi_ioc_attr_s), BFA_DMA_ALIGN_SZ); -} - void bfa_ioc_enable(struct bfa_ioc_s *ioc) { @@ -2068,18 +2083,6 @@ bfa_ioc_disable(struct bfa_ioc_s *ioc) bfa_fsm_send_event(ioc, IOC_E_DISABLE); } -/* - * Returns memory required for saving firmware trace in case of crash. - * Driver must call this interface to allocate memory required for - * automatic saving of firmware trace. Driver should call - * bfa_ioc_debug_memclaim() right after bfa_ioc_attach() to setup this - * trace memory. - */ -int -bfa_ioc_debug_trcsz(bfa_boolean_t auto_recover) -{ - return (auto_recover) ? BFA_DBG_FWTRC_LEN : 0; -} /* * Initialize memory for saving firmware trace. Driver must initialize @@ -2089,19 +2092,7 @@ void bfa_ioc_debug_memclaim(struct bfa_ioc_s *ioc, void *dbg_fwsave) { ioc->dbg_fwsave = dbg_fwsave; - ioc->dbg_fwsave_len = bfa_ioc_debug_trcsz(ioc->iocpf.auto_recover); -} - -u32 -bfa_ioc_smem_pgnum(struct bfa_ioc_s *ioc, u32 fmaddr) -{ - return PSS_SMEM_PGNUM(ioc->ioc_regs.smem_pg0, fmaddr); -} - -u32 -bfa_ioc_smem_pgoff(struct bfa_ioc_s *ioc, u32 fmaddr) -{ - return PSS_SMEM_PGOFF(fmaddr); + ioc->dbg_fwsave_len = (ioc->iocpf.auto_recover) ? BFA_DBG_FWTRC_LEN : 0; } /* @@ -2265,14 +2256,13 @@ bfa_ioc_adapter_is_disabled(struct bfa_ioc_s *ioc) } /* - * Add to IOC heartbeat failure notification queue. To be used by common - * modules such as cee, port, diag. + * Reset IOC fwstate registers. */ void -bfa_ioc_hbfail_register(struct bfa_ioc_s *ioc, - struct bfa_ioc_hbfail_notify_s *notify) +bfa_ioc_reset_fwstate(struct bfa_ioc_s *ioc) { - list_add_tail(¬ify->qe, &ioc->hb_notify_q); + writel(BFI_IOC_UNINIT, ioc->ioc_regs.ioc_fwstate); + writel(BFI_IOC_UNINIT, ioc->ioc_regs.alt_ioc_fwstate); } #define BFA_MFG_NAME "Brocade" @@ -2306,7 +2296,7 @@ bfa_ioc_get_adapter_attr(struct bfa_ioc_s *ioc, else ad_attr->prototype = 0; - ad_attr->pwwn = bfa_ioc_get_pwwn(ioc); + ad_attr->pwwn = ioc->attr->pwwn; ad_attr->mac = bfa_ioc_get_mac(ioc); ad_attr->pcie_gen = ioc_attr->pcie_gen; @@ -2317,7 +2307,8 @@ bfa_ioc_get_adapter_attr(struct bfa_ioc_s *ioc, bfa_ioc_get_pci_chip_rev(ioc, ad_attr->hw_ver); ad_attr->cna_capable = ioc->cna; - ad_attr->trunk_capable = (ad_attr->nports > 1) && !ioc->cna; + ad_attr->trunk_capable = (ad_attr->nports > 1) && !ioc->cna && + !ad_attr->is_mezz; } enum bfa_ioc_type_e @@ -2330,7 +2321,7 @@ bfa_ioc_get_type(struct bfa_ioc_s *ioc) else if (ioc->ioc_mc == BFI_MC_LL) return BFA_IOC_TYPE_LL; else { - bfa_assert(ioc->ioc_mc == BFI_MC_LL); + WARN_ON(ioc->ioc_mc != BFI_MC_LL); return BFA_IOC_TYPE_LL; } } @@ -2354,7 +2345,7 @@ bfa_ioc_get_adapter_fw_ver(struct bfa_ioc_s *ioc, char *fw_ver) void bfa_ioc_get_pci_chip_rev(struct bfa_ioc_s *ioc, char *chip_rev) { - bfa_assert(chip_rev); + WARN_ON(!chip_rev); memset((void *)chip_rev, 0, BFA_IOC_CHIP_REV_LEN); @@ -2386,7 +2377,7 @@ bfa_ioc_get_adapter_model(struct bfa_ioc_s *ioc, char *model) { struct bfi_ioc_attr_s *ioc_attr; - bfa_assert(model); + WARN_ON(!model); memset((void *)model, 0, BFA_ADAPTER_MODEL_NAME_LEN); ioc_attr = ioc->attr; @@ -2455,27 +2446,6 @@ bfa_ioc_get_attr(struct bfa_ioc_s *ioc, struct bfa_ioc_attr_s *ioc_attr) bfa_ioc_get_pci_chip_rev(ioc, ioc_attr->pci_attr.chip_rev); } -/* - * hal_wwn_public - */ -wwn_t -bfa_ioc_get_pwwn(struct bfa_ioc_s *ioc) -{ - return ioc->attr->pwwn; -} - -wwn_t -bfa_ioc_get_nwwn(struct bfa_ioc_s *ioc) -{ - return ioc->attr->nwwn; -} - -u64 -bfa_ioc_get_adid(struct bfa_ioc_s *ioc) -{ - return ioc->attr->mfg_pwwn; -} - mac_t bfa_ioc_get_mac(struct bfa_ioc_s *ioc) { @@ -2488,18 +2458,6 @@ bfa_ioc_get_mac(struct bfa_ioc_s *ioc) return ioc->attr->mac; } -wwn_t -bfa_ioc_get_mfg_pwwn(struct bfa_ioc_s *ioc) -{ - return ioc->attr->mfg_pwwn; -} - -wwn_t -bfa_ioc_get_mfg_nwwn(struct bfa_ioc_s *ioc) -{ - return ioc->attr->mfg_nwwn; -} - mac_t bfa_ioc_get_mfg_mac(struct bfa_ioc_s *ioc) { @@ -2541,14 +2499,6 @@ bfa_ioc_debug_fwsave(struct bfa_ioc_s *ioc, void *trcdata, int *trclen) return BFA_STATUS_OK; } -/* - * Clear saved firmware trace - */ -void -bfa_ioc_debug_fwsave_clear(struct bfa_ioc_s *ioc) -{ - ioc->dbg_fwsave_once = BFA_TRUE; -} /* * Retrieve saved firmware trace from a prior IOC failure. @@ -2701,13 +2651,16 @@ bfa_ioc_fw_stats_clear(struct bfa_ioc_s *ioc) * Save firmware trace if configured. */ static void -bfa_ioc_debug_save(struct bfa_ioc_s *ioc) +bfa_ioc_debug_save_ftrc(struct bfa_ioc_s *ioc) { int tlen; - if (ioc->dbg_fwsave_len) { - tlen = ioc->dbg_fwsave_len; - bfa_ioc_debug_fwtrc(ioc, ioc->dbg_fwsave, &tlen); + if (ioc->dbg_fwsave_once) { + ioc->dbg_fwsave_once = BFA_FALSE; + if (ioc->dbg_fwsave_len) { + tlen = ioc->dbg_fwsave_len; + bfa_ioc_debug_fwtrc(ioc, ioc->dbg_fwsave, &tlen); + } } } @@ -2717,11 +2670,6 @@ bfa_ioc_debug_save(struct bfa_ioc_s *ioc) static void bfa_ioc_recover(struct bfa_ioc_s *ioc) { - if (ioc->dbg_fwsave_once) { - ioc->dbg_fwsave_once = BFA_FALSE; - bfa_ioc_debug_save(ioc); - } - bfa_ioc_stats(ioc, ioc_hbfails); bfa_fsm_send_event(ioc, IOC_E_HBFAIL); } @@ -2734,45 +2682,8 @@ bfa_ioc_check_attr_wwns(struct bfa_ioc_s *ioc) } /* - * hal_iocpf_pvt BFA IOC PF private functions + * BFA IOC PF private functions */ - -static void -bfa_iocpf_enable(struct bfa_ioc_s *ioc) -{ - bfa_fsm_send_event(&ioc->iocpf, IOCPF_E_ENABLE); -} - -static void -bfa_iocpf_disable(struct bfa_ioc_s *ioc) -{ - bfa_fsm_send_event(&ioc->iocpf, IOCPF_E_DISABLE); -} - -static void -bfa_iocpf_fail(struct bfa_ioc_s *ioc) -{ - bfa_fsm_send_event(&ioc->iocpf, IOCPF_E_FAIL); -} - -static void -bfa_iocpf_initfail(struct bfa_ioc_s *ioc) -{ - bfa_fsm_send_event(&ioc->iocpf, IOCPF_E_INITFAIL); -} - -static void -bfa_iocpf_getattrfail(struct bfa_ioc_s *ioc) -{ - bfa_fsm_send_event(&ioc->iocpf, IOCPF_E_GETATTRFAIL); -} - -static void -bfa_iocpf_stop(struct bfa_ioc_s *ioc) -{ - bfa_fsm_send_event(&ioc->iocpf, IOCPF_E_STOP); -} - static void bfa_iocpf_timeout(void *ioc_arg) { @@ -2794,12 +2705,6 @@ bfa_iocpf_sem_timeout(void *ioc_arg) * bfa timer function */ void -bfa_timer_init(struct bfa_timer_mod_s *mod) -{ - INIT_LIST_HEAD(&mod->timer_q); -} - -void bfa_timer_beat(struct bfa_timer_mod_s *mod) { struct list_head *qh = &mod->timer_q; @@ -2843,8 +2748,8 @@ bfa_timer_begin(struct bfa_timer_mod_s *mod, struct bfa_timer_s *timer, void (*timercb) (void *), void *arg, unsigned int timeout) { - bfa_assert(timercb != NULL); - bfa_assert(!bfa_q_is_on_q(&mod->timer_q, timer)); + WARN_ON(timercb == NULL); + WARN_ON(bfa_q_is_on_q(&mod->timer_q, timer)); timer->timeout = timeout; timer->timercb = timercb; @@ -2859,7 +2764,7 @@ bfa_timer_begin(struct bfa_timer_mod_s *mod, struct bfa_timer_s *timer, void bfa_timer_stop(struct bfa_timer_s *timer) { - bfa_assert(!list_empty(&timer->qe)); + WARN_ON(list_empty(&timer->qe)); list_del(&timer->qe); } |