@@ -112,6 +112,7 @@ enum ioc_event {
112112 IOC_E_HBFAIL = 9 , /* heartbeat failure */
113113 IOC_E_HWERROR = 10 , /* hardware error interrupt */
114114 IOC_E_TIMEOUT = 11 , /* timeout */
115+ IOC_E_HWFAILED = 12 , /* PCI mapping failure notice */
115116};
116117
117118bfa_fsm_state_decl (bfa_ioc , uninit , struct bfa_ioc_s , enum ioc_event );
@@ -123,6 +124,7 @@ bfa_fsm_state_decl(bfa_ioc, fail_retry, struct bfa_ioc_s, enum ioc_event);
123124bfa_fsm_state_decl (bfa_ioc , fail , struct bfa_ioc_s , enum ioc_event );
124125bfa_fsm_state_decl (bfa_ioc , disabling , struct bfa_ioc_s , enum ioc_event );
125126bfa_fsm_state_decl (bfa_ioc , disabled , struct bfa_ioc_s , enum ioc_event );
127+ bfa_fsm_state_decl (bfa_ioc , hwfail , struct bfa_ioc_s , enum ioc_event );
126128
127129static struct bfa_sm_table_s ioc_sm_table [] = {
128130 {BFA_SM (bfa_ioc_sm_uninit ), BFA_IOC_UNINIT },
@@ -134,6 +136,7 @@ static struct bfa_sm_table_s ioc_sm_table[] = {
134136 {BFA_SM (bfa_ioc_sm_fail ), BFA_IOC_FAIL },
135137 {BFA_SM (bfa_ioc_sm_disabling ), BFA_IOC_DISABLING },
136138 {BFA_SM (bfa_ioc_sm_disabled ), BFA_IOC_DISABLED },
139+ {BFA_SM (bfa_ioc_sm_hwfail ), BFA_IOC_HWFAIL },
137140};
138141
139142/*
@@ -176,6 +179,7 @@ enum iocpf_event {
176179 IOCPF_E_GETATTRFAIL = 9 , /* init fail notice by ioc sm */
177180 IOCPF_E_SEMLOCKED = 10 , /* h/w semaphore is locked */
178181 IOCPF_E_TIMEOUT = 11 , /* f/w response timeout */
182+ IOCPF_E_SEM_ERROR = 12 , /* h/w sem mapping error */
179183};
180184
181185/*
@@ -322,6 +326,11 @@ bfa_ioc_sm_enabling(struct bfa_ioc_s *ioc, enum ioc_event event)
322326 bfa_fsm_send_event (& ioc -> iocpf , IOCPF_E_INITFAIL );
323327 break ;
324328
329+ case IOC_E_HWFAILED :
330+ ioc -> cbfn -> enable_cbfn (ioc -> bfa , BFA_STATUS_IOC_FAILURE );
331+ bfa_fsm_set_state (ioc , bfa_ioc_sm_hwfail );
332+ break ;
333+
325334 case IOC_E_DISABLE :
326335 bfa_fsm_set_state (ioc , bfa_ioc_sm_disabling );
327336 break ;
@@ -465,6 +474,11 @@ bfa_ioc_sm_disabling(struct bfa_ioc_s *ioc, enum ioc_event event)
465474 bfa_fsm_send_event (& ioc -> iocpf , IOCPF_E_FAIL );
466475 break ;
467476
477+ case IOC_E_HWFAILED :
478+ bfa_fsm_set_state (ioc , bfa_ioc_sm_hwfail );
479+ bfa_ioc_disable_comp (ioc );
480+ break ;
481+
468482 default :
469483 bfa_sm_fault (ioc , event );
470484 }
@@ -534,6 +548,11 @@ bfa_ioc_sm_fail_retry(struct bfa_ioc_s *ioc, enum ioc_event event)
534548 bfa_fsm_send_event (& ioc -> iocpf , IOCPF_E_INITFAIL );
535549 break ;
536550
551+ case IOC_E_HWFAILED :
552+ ioc -> cbfn -> enable_cbfn (ioc -> bfa , BFA_STATUS_IOC_FAILURE );
553+ bfa_fsm_set_state (ioc , bfa_ioc_sm_hwfail );
554+ break ;
555+
537556 case IOC_E_ENABLE :
538557 break ;
539558
@@ -591,6 +610,35 @@ bfa_ioc_sm_fail(struct bfa_ioc_s *ioc, enum ioc_event event)
591610 }
592611}
593612
613+ static void
614+ bfa_ioc_sm_hwfail_entry (struct bfa_ioc_s * ioc )
615+ {
616+ bfa_trc (ioc , 0 );
617+ }
618+
619+ static void
620+ bfa_ioc_sm_hwfail (struct bfa_ioc_s * ioc , enum ioc_event event )
621+ {
622+ bfa_trc (ioc , event );
623+
624+ switch (event ) {
625+ case IOC_E_ENABLE :
626+ ioc -> cbfn -> enable_cbfn (ioc -> bfa , BFA_STATUS_IOC_FAILURE );
627+ break ;
628+
629+ case IOC_E_DISABLE :
630+ ioc -> cbfn -> disable_cbfn (ioc -> bfa );
631+ break ;
632+
633+ case IOC_E_DETACH :
634+ bfa_fsm_set_state (ioc , bfa_ioc_sm_uninit );
635+ break ;
636+
637+ default :
638+ bfa_sm_fault (ioc , event );
639+ }
640+ }
641+
594642/*
595643 * IOCPF State Machine
596644 */
@@ -634,6 +682,28 @@ bfa_iocpf_sm_reset(struct bfa_iocpf_s *iocpf, enum iocpf_event event)
634682static void
635683bfa_iocpf_sm_fwcheck_entry (struct bfa_iocpf_s * iocpf )
636684{
685+ struct bfi_ioc_image_hdr_s fwhdr ;
686+ u32 fwstate = readl (iocpf -> ioc -> ioc_regs .ioc_fwstate );
687+
688+ /* h/w sem init */
689+ if (fwstate == BFI_IOC_UNINIT )
690+ goto sem_get ;
691+
692+ bfa_ioc_fwver_get (iocpf -> ioc , & fwhdr );
693+
694+ if (swab32 (fwhdr .exec ) == BFI_FWBOOT_TYPE_NORMAL )
695+ goto sem_get ;
696+
697+ bfa_trc (iocpf -> ioc , fwstate );
698+ bfa_trc (iocpf -> ioc , fwhdr .exec );
699+ writel (BFI_IOC_UNINIT , iocpf -> ioc -> ioc_regs .ioc_fwstate );
700+
701+ /*
702+ * Try to lock and then unlock the semaphore.
703+ */
704+ readl (iocpf -> ioc -> ioc_regs .ioc_sem_reg );
705+ writel (1 , iocpf -> ioc -> ioc_regs .ioc_sem_reg );
706+ sem_get :
637707 bfa_ioc_hw_sem_get (iocpf -> ioc );
638708}
639709
@@ -664,6 +734,11 @@ bfa_iocpf_sm_fwcheck(struct bfa_iocpf_s *iocpf, enum iocpf_event event)
664734 }
665735 break ;
666736
737+ case IOCPF_E_SEM_ERROR :
738+ bfa_fsm_set_state (iocpf , bfa_iocpf_sm_fail );
739+ bfa_fsm_send_event (ioc , IOC_E_HWFAILED );
740+ break ;
741+
667742 case IOCPF_E_DISABLE :
668743 bfa_sem_timer_stop (ioc );
669744 bfa_fsm_set_state (iocpf , bfa_iocpf_sm_reset );
@@ -757,6 +832,11 @@ bfa_iocpf_sm_semwait(struct bfa_iocpf_s *iocpf, enum iocpf_event event)
757832 }
758833 break ;
759834
835+ case IOCPF_E_SEM_ERROR :
836+ bfa_fsm_set_state (iocpf , bfa_iocpf_sm_fail );
837+ bfa_fsm_send_event (ioc , IOC_E_HWFAILED );
838+ break ;
839+
760840 case IOCPF_E_DISABLE :
761841 bfa_sem_timer_stop (ioc );
762842 bfa_fsm_set_state (iocpf , bfa_iocpf_sm_disabling_sync );
@@ -957,6 +1037,11 @@ bfa_iocpf_sm_disabling_sync(struct bfa_iocpf_s *iocpf, enum iocpf_event event)
9571037 bfa_fsm_set_state (iocpf , bfa_iocpf_sm_disabled );
9581038 break ;
9591039
1040+ case IOCPF_E_SEM_ERROR :
1041+ bfa_fsm_set_state (iocpf , bfa_iocpf_sm_fail );
1042+ bfa_fsm_send_event (ioc , IOC_E_HWFAILED );
1043+ break ;
1044+
9601045 case IOCPF_E_FAIL :
9611046 break ;
9621047
@@ -1000,6 +1085,7 @@ bfa_iocpf_sm_disabled(struct bfa_iocpf_s *iocpf, enum iocpf_event event)
10001085static void
10011086bfa_iocpf_sm_initfail_sync_entry (struct bfa_iocpf_s * iocpf )
10021087{
1088+ bfa_ioc_debug_save_ftrc (iocpf -> ioc );
10031089 bfa_ioc_hw_sem_get (iocpf -> ioc );
10041090}
10051091
@@ -1022,6 +1108,11 @@ bfa_iocpf_sm_initfail_sync(struct bfa_iocpf_s *iocpf, enum iocpf_event event)
10221108 bfa_fsm_set_state (iocpf , bfa_iocpf_sm_initfail );
10231109 break ;
10241110
1111+ case IOCPF_E_SEM_ERROR :
1112+ bfa_fsm_set_state (iocpf , bfa_iocpf_sm_fail );
1113+ bfa_fsm_send_event (ioc , IOC_E_HWFAILED );
1114+ break ;
1115+
10251116 case IOCPF_E_DISABLE :
10261117 bfa_sem_timer_stop (ioc );
10271118 bfa_fsm_set_state (iocpf , bfa_iocpf_sm_disabling_sync );
@@ -1044,6 +1135,7 @@ bfa_iocpf_sm_initfail_sync(struct bfa_iocpf_s *iocpf, enum iocpf_event event)
10441135static void
10451136bfa_iocpf_sm_initfail_entry (struct bfa_iocpf_s * iocpf )
10461137{
1138+ bfa_trc (iocpf -> ioc , 0 );
10471139}
10481140
10491141/*
@@ -1113,6 +1205,11 @@ bfa_iocpf_sm_fail_sync(struct bfa_iocpf_s *iocpf, enum iocpf_event event)
11131205 }
11141206 break ;
11151207
1208+ case IOCPF_E_SEM_ERROR :
1209+ bfa_fsm_set_state (iocpf , bfa_iocpf_sm_fail );
1210+ bfa_fsm_send_event (ioc , IOC_E_HWFAILED );
1211+ break ;
1212+
11161213 case IOCPF_E_DISABLE :
11171214 bfa_sem_timer_stop (ioc );
11181215 bfa_fsm_set_state (iocpf , bfa_iocpf_sm_disabling_sync );
@@ -1129,6 +1226,7 @@ bfa_iocpf_sm_fail_sync(struct bfa_iocpf_s *iocpf, enum iocpf_event event)
11291226static void
11301227bfa_iocpf_sm_fail_entry (struct bfa_iocpf_s * iocpf )
11311228{
1229+ bfa_trc (iocpf -> ioc , 0 );
11321230}
11331231
11341232/*
@@ -1195,7 +1293,6 @@ bfa_ioc_sem_get(void __iomem *sem_reg)
11951293 if (!(r32 & 1 ))
11961294 return BFA_TRUE ;
11971295
1198- WARN_ON (cnt >= BFA_SEM_SPINCNT );
11991296 return BFA_FALSE ;
12001297}
12011298
@@ -1209,6 +1306,11 @@ bfa_ioc_hw_sem_get(struct bfa_ioc_s *ioc)
12091306 * will return 1. Semaphore is released by writing 1 to the register
12101307 */
12111308 r32 = readl (ioc -> ioc_regs .ioc_sem_reg );
1309+ if (r32 == ~0 ) {
1310+ WARN_ON (r32 == ~0 );
1311+ bfa_fsm_send_event (& ioc -> iocpf , IOCPF_E_SEM_ERROR );
1312+ return ;
1313+ }
12121314 if (!(r32 & 1 )) {
12131315 bfa_fsm_send_event (& ioc -> iocpf , IOCPF_E_SEMLOCKED );
12141316 return ;
@@ -1617,6 +1719,7 @@ bfa_ioc_getattr_reply(struct bfa_ioc_s *ioc)
16171719 attr -> adapter_prop = be32_to_cpu (attr -> adapter_prop );
16181720 attr -> card_type = be32_to_cpu (attr -> card_type );
16191721 attr -> maxfrsize = be16_to_cpu (attr -> maxfrsize );
1722+ ioc -> fcmode = (attr -> port_mode == BFI_PORT_MODE_FC );
16201723
16211724 bfa_fsm_send_event (ioc , IOC_E_FWRSP_GETATTR );
16221725}
@@ -1733,6 +1836,7 @@ bfa_ioc_smem_read(struct bfa_ioc_s *ioc, void *tbuf, u32 soff, u32 sz)
17331836 /*
17341837 * release semaphore.
17351838 */
1839+ readl (ioc -> ioc_regs .ioc_init_sem_reg );
17361840 writel (1 , ioc -> ioc_regs .ioc_init_sem_reg );
17371841
17381842 bfa_trc (ioc , pgnum );
@@ -1789,6 +1893,7 @@ bfa_ioc_smem_clr(struct bfa_ioc_s *ioc, u32 soff, u32 sz)
17891893 /*
17901894 * release semaphore.
17911895 */
1896+ readl (ioc -> ioc_regs .ioc_init_sem_reg );
17921897 writel (1 , ioc -> ioc_regs .ioc_init_sem_reg );
17931898 bfa_trc (ioc , pgnum );
17941899 return BFA_STATUS_OK ;
@@ -1840,6 +1945,7 @@ bfa_ioc_pll_init(struct bfa_ioc_s *ioc)
18401945 /*
18411946 * release semaphore.
18421947 */
1948+ readl (ioc -> ioc_regs .ioc_init_sem_reg );
18431949 writel (1 , ioc -> ioc_regs .ioc_init_sem_reg );
18441950
18451951 return BFA_STATUS_OK ;
@@ -2232,6 +2338,8 @@ bfa_ioc_mbox_isr(struct bfa_ioc_s *ioc)
22322338void
22332339bfa_ioc_error_isr (struct bfa_ioc_s * ioc )
22342340{
2341+ bfa_ioc_stats (ioc , ioc_hbfails );
2342+ ioc -> stats .hb_count = ioc -> hb_count ;
22352343 bfa_fsm_send_event (ioc , IOC_E_HWERROR );
22362344}
22372345
@@ -2354,15 +2462,12 @@ bfa_ioc_get_adapter_attr(struct bfa_ioc_s *ioc,
23542462enum bfa_ioc_type_e
23552463bfa_ioc_get_type (struct bfa_ioc_s * ioc )
23562464{
2357- enum bfi_port_mode mode ;
2358-
23592465 if (ioc -> clscode == BFI_PCIFN_CLASS_ETH )
23602466 return BFA_IOC_TYPE_LL ;
23612467
23622468 WARN_ON (ioc -> clscode != BFI_PCIFN_CLASS_FC );
23632469
2364- mode = (ioc -> port_id == 0 ) ? ioc -> port0_mode : ioc -> port1_mode ;
2365- return (mode == BFI_PORT_MODE_FC )
2470+ return (ioc -> attr -> port_mode == BFI_PORT_MODE_FC )
23662471 ? BFA_IOC_TYPE_FC : BFA_IOC_TYPE_FCoE ;
23672472}
23682473
@@ -2739,6 +2844,7 @@ static void
27392844bfa_ioc_recover (struct bfa_ioc_s * ioc )
27402845{
27412846 bfa_ioc_stats (ioc , ioc_hbfails );
2847+ ioc -> stats .hb_count = ioc -> hb_count ;
27422848 bfa_fsm_send_event (ioc , IOC_E_HBFAIL );
27432849}
27442850
0 commit comments