aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/bfa/bfa_ioc.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/scsi/bfa/bfa_ioc.c')
-rw-r--r--drivers/scsi/bfa/bfa_ioc.c749
1 files changed, 327 insertions, 422 deletions
diff --git a/drivers/scsi/bfa/bfa_ioc.c b/drivers/scsi/bfa/bfa_ioc.c
index 9f4aa391ea9d..c1f72c49196f 100644
--- a/drivers/scsi/bfa/bfa_ioc.c
+++ b/drivers/scsi/bfa/bfa_ioc.c
@@ -15,11 +15,11 @@
15 * General Public License for more details. 15 * General Public License for more details.
16 */ 16 */
17 17
18#include "bfad_drv.h"
18#include "bfa_ioc.h" 19#include "bfa_ioc.h"
19#include "bfi_ctreg.h" 20#include "bfi_ctreg.h"
20#include "bfa_defs.h" 21#include "bfa_defs.h"
21#include "bfa_defs_svc.h" 22#include "bfa_defs_svc.h"
22#include "bfad_drv.h"
23 23
24BFA_TRC_FILE(CNA, IOC); 24BFA_TRC_FILE(CNA, IOC);
25 25
@@ -29,7 +29,7 @@ BFA_TRC_FILE(CNA, IOC);
29#define BFA_IOC_TOV 3000 /* msecs */ 29#define BFA_IOC_TOV 3000 /* msecs */
30#define BFA_IOC_HWSEM_TOV 500 /* msecs */ 30#define BFA_IOC_HWSEM_TOV 500 /* msecs */
31#define BFA_IOC_HB_TOV 500 /* msecs */ 31#define BFA_IOC_HB_TOV 500 /* msecs */
32#define BFA_IOC_HWINIT_MAX 2 32#define BFA_IOC_HWINIT_MAX 5
33#define BFA_IOC_TOV_RECOVER BFA_IOC_HB_TOV 33#define BFA_IOC_TOV_RECOVER BFA_IOC_HB_TOV
34 34
35#define bfa_ioc_timer_start(__ioc) \ 35#define bfa_ioc_timer_start(__ioc) \
@@ -42,11 +42,6 @@ BFA_TRC_FILE(CNA, IOC);
42 bfa_ioc_hb_check, (__ioc), BFA_IOC_HB_TOV) 42 bfa_ioc_hb_check, (__ioc), BFA_IOC_HB_TOV)
43#define bfa_hb_timer_stop(__ioc) bfa_timer_stop(&(__ioc)->hb_timer) 43#define bfa_hb_timer_stop(__ioc) bfa_timer_stop(&(__ioc)->hb_timer)
44 44
45#define BFA_DBG_FWTRC_ENTS (BFI_IOC_TRC_ENTS)
46#define BFA_DBG_FWTRC_LEN \
47 (BFA_DBG_FWTRC_ENTS * sizeof(struct bfa_trc_s) + \
48 (sizeof(struct bfa_trc_mod_s) - \
49 BFA_TRC_MAX * sizeof(struct bfa_trc_s)))
50#define BFA_DBG_FWTRC_OFF(_fn) (BFI_IOC_TRC_OFF + BFA_DBG_FWTRC_LEN * (_fn)) 45#define BFA_DBG_FWTRC_OFF(_fn) (BFI_IOC_TRC_OFF + BFA_DBG_FWTRC_LEN * (_fn))
51 46
52/* 47/*
@@ -59,17 +54,16 @@ BFA_TRC_FILE(CNA, IOC);
59 ((__ioc)->ioc_hwif->ioc_firmware_unlock(__ioc)) 54 ((__ioc)->ioc_hwif->ioc_firmware_unlock(__ioc))
60#define bfa_ioc_reg_init(__ioc) ((__ioc)->ioc_hwif->ioc_reg_init(__ioc)) 55#define bfa_ioc_reg_init(__ioc) ((__ioc)->ioc_hwif->ioc_reg_init(__ioc))
61#define bfa_ioc_map_port(__ioc) ((__ioc)->ioc_hwif->ioc_map_port(__ioc)) 56#define bfa_ioc_map_port(__ioc) ((__ioc)->ioc_hwif->ioc_map_port(__ioc))
62#define bfa_ioc_notify_hbfail(__ioc) \ 57#define bfa_ioc_notify_fail(__ioc) \
63 ((__ioc)->ioc_hwif->ioc_notify_hbfail(__ioc)) 58 ((__ioc)->ioc_hwif->ioc_notify_fail(__ioc))
64 59#define bfa_ioc_sync_join(__ioc) \
65#ifdef BFA_IOC_IS_UEFI 60 ((__ioc)->ioc_hwif->ioc_sync_join(__ioc))
66#define bfa_ioc_is_bios_optrom(__ioc) (0) 61#define bfa_ioc_sync_leave(__ioc) \
67#define bfa_ioc_is_uefi(__ioc) BFA_IOC_IS_UEFI 62 ((__ioc)->ioc_hwif->ioc_sync_leave(__ioc))
68#else 63#define bfa_ioc_sync_ack(__ioc) \
69#define bfa_ioc_is_bios_optrom(__ioc) \ 64 ((__ioc)->ioc_hwif->ioc_sync_ack(__ioc))
70 (bfa_cb_image_get_size(BFA_IOC_FWIMG_TYPE(__ioc)) < BFA_IOC_FWIMG_MINSZ) 65#define bfa_ioc_sync_complete(__ioc) \
71#define bfa_ioc_is_uefi(__ioc) (0) 66 ((__ioc)->ioc_hwif->ioc_sync_complete(__ioc))
72#endif
73 67
74#define bfa_ioc_mbox_cmd_pending(__ioc) \ 68#define bfa_ioc_mbox_cmd_pending(__ioc) \
75 (!list_empty(&((__ioc)->mbox_mod.cmd_q)) || \ 69 (!list_empty(&((__ioc)->mbox_mod.cmd_q)) || \
@@ -81,29 +75,22 @@ bfa_boolean_t bfa_auto_recover = BFA_TRUE;
81 * forward declarations 75 * forward declarations
82 */ 76 */
83static void bfa_ioc_hw_sem_get(struct bfa_ioc_s *ioc); 77static void bfa_ioc_hw_sem_get(struct bfa_ioc_s *ioc);
84static void bfa_ioc_hw_sem_get_cancel(struct bfa_ioc_s *ioc);
85static void bfa_ioc_hwinit(struct bfa_ioc_s *ioc, bfa_boolean_t force); 78static void bfa_ioc_hwinit(struct bfa_ioc_s *ioc, bfa_boolean_t force);
86static void bfa_ioc_timeout(void *ioc); 79static void bfa_ioc_timeout(void *ioc);
87static void bfa_ioc_send_enable(struct bfa_ioc_s *ioc); 80static void bfa_ioc_send_enable(struct bfa_ioc_s *ioc);
88static void bfa_ioc_send_disable(struct bfa_ioc_s *ioc); 81static void bfa_ioc_send_disable(struct bfa_ioc_s *ioc);
89static void bfa_ioc_send_getattr(struct bfa_ioc_s *ioc); 82static void bfa_ioc_send_getattr(struct bfa_ioc_s *ioc);
90static void bfa_ioc_hb_monitor(struct bfa_ioc_s *ioc); 83static void bfa_ioc_hb_monitor(struct bfa_ioc_s *ioc);
91static void bfa_ioc_hb_stop(struct bfa_ioc_s *ioc);
92static void bfa_ioc_reset(struct bfa_ioc_s *ioc, bfa_boolean_t force);
93static void bfa_ioc_mbox_poll(struct bfa_ioc_s *ioc); 84static void bfa_ioc_mbox_poll(struct bfa_ioc_s *ioc);
94static void bfa_ioc_mbox_hbfail(struct bfa_ioc_s *ioc); 85static void bfa_ioc_mbox_hbfail(struct bfa_ioc_s *ioc);
95static void bfa_ioc_recover(struct bfa_ioc_s *ioc); 86static void bfa_ioc_recover(struct bfa_ioc_s *ioc);
96static void bfa_ioc_check_attr_wwns(struct bfa_ioc_s *ioc); 87static void bfa_ioc_check_attr_wwns(struct bfa_ioc_s *ioc);
97static void bfa_ioc_disable_comp(struct bfa_ioc_s *ioc); 88static void bfa_ioc_disable_comp(struct bfa_ioc_s *ioc);
98static void bfa_ioc_lpu_stop(struct bfa_ioc_s *ioc); 89static void bfa_ioc_lpu_stop(struct bfa_ioc_s *ioc);
99static void bfa_ioc_pf_enabled(struct bfa_ioc_s *ioc); 90static void bfa_ioc_debug_save_ftrc(struct bfa_ioc_s *ioc);
100static void bfa_ioc_pf_disabled(struct bfa_ioc_s *ioc); 91static void bfa_ioc_fail_notify(struct bfa_ioc_s *ioc);
101static void bfa_ioc_pf_failed(struct bfa_ioc_s *ioc);
102static void bfa_ioc_pf_fwmismatch(struct bfa_ioc_s *ioc); 92static void bfa_ioc_pf_fwmismatch(struct bfa_ioc_s *ioc);
103 93
104/*
105 * hal_ioc_sm
106 */
107 94
108/* 95/*
109 * IOC state machine definitions/declarations 96 * IOC state machine definitions/declarations
@@ -116,10 +103,11 @@ enum ioc_event {
116 IOC_E_ENABLED = 5, /* f/w enabled */ 103 IOC_E_ENABLED = 5, /* f/w enabled */
117 IOC_E_FWRSP_GETATTR = 6, /* IOC get attribute response */ 104 IOC_E_FWRSP_GETATTR = 6, /* IOC get attribute response */
118 IOC_E_DISABLED = 7, /* f/w disabled */ 105 IOC_E_DISABLED = 7, /* f/w disabled */
119 IOC_E_FAILED = 8, /* failure notice by iocpf sm */ 106 IOC_E_INITFAILED = 8, /* failure notice by iocpf sm */
120 IOC_E_HBFAIL = 9, /* heartbeat failure */ 107 IOC_E_PFFAILED = 9, /* failure notice by iocpf sm */
121 IOC_E_HWERROR = 10, /* hardware error interrupt */ 108 IOC_E_HBFAIL = 10, /* heartbeat failure */
122 IOC_E_TIMEOUT = 11, /* timeout */ 109 IOC_E_HWERROR = 11, /* hardware error interrupt */
110 IOC_E_TIMEOUT = 12, /* timeout */
123}; 111};
124 112
125bfa_fsm_state_decl(bfa_ioc, uninit, struct bfa_ioc_s, enum ioc_event); 113bfa_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);
127bfa_fsm_state_decl(bfa_ioc, enabling, struct bfa_ioc_s, enum ioc_event); 115bfa_fsm_state_decl(bfa_ioc, enabling, struct bfa_ioc_s, enum ioc_event);
128bfa_fsm_state_decl(bfa_ioc, getattr, struct bfa_ioc_s, enum ioc_event); 116bfa_fsm_state_decl(bfa_ioc, getattr, struct bfa_ioc_s, enum ioc_event);
129bfa_fsm_state_decl(bfa_ioc, op, struct bfa_ioc_s, enum ioc_event); 117bfa_fsm_state_decl(bfa_ioc, op, struct bfa_ioc_s, enum ioc_event);
130bfa_fsm_state_decl(bfa_ioc, initfail, struct bfa_ioc_s, enum ioc_event); 118bfa_fsm_state_decl(bfa_ioc, fail_retry, struct bfa_ioc_s, enum ioc_event);
131bfa_fsm_state_decl(bfa_ioc, fail, struct bfa_ioc_s, enum ioc_event); 119bfa_fsm_state_decl(bfa_ioc, fail, struct bfa_ioc_s, enum ioc_event);
132bfa_fsm_state_decl(bfa_ioc, disabling, struct bfa_ioc_s, enum ioc_event); 120bfa_fsm_state_decl(bfa_ioc, disabling, struct bfa_ioc_s, enum ioc_event);
133bfa_fsm_state_decl(bfa_ioc, disabled, struct bfa_ioc_s, enum ioc_event); 121bfa_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[] = {
138 {BFA_SM(bfa_ioc_sm_enabling), BFA_IOC_ENABLING}, 126 {BFA_SM(bfa_ioc_sm_enabling), BFA_IOC_ENABLING},
139 {BFA_SM(bfa_ioc_sm_getattr), BFA_IOC_GETATTR}, 127 {BFA_SM(bfa_ioc_sm_getattr), BFA_IOC_GETATTR},
140 {BFA_SM(bfa_ioc_sm_op), BFA_IOC_OPERATIONAL}, 128 {BFA_SM(bfa_ioc_sm_op), BFA_IOC_OPERATIONAL},
141 {BFA_SM(bfa_ioc_sm_initfail), BFA_IOC_INITFAIL}, 129 {BFA_SM(bfa_ioc_sm_fail_retry), BFA_IOC_INITFAIL},
142 {BFA_SM(bfa_ioc_sm_fail), BFA_IOC_FAIL}, 130 {BFA_SM(bfa_ioc_sm_fail), BFA_IOC_FAIL},
143 {BFA_SM(bfa_ioc_sm_disabling), BFA_IOC_DISABLING}, 131 {BFA_SM(bfa_ioc_sm_disabling), BFA_IOC_DISABLING},
144 {BFA_SM(bfa_ioc_sm_disabled), BFA_IOC_DISABLED}, 132 {BFA_SM(bfa_ioc_sm_disabled), BFA_IOC_DISABLED},
@@ -165,12 +153,6 @@ static struct bfa_sm_table_s ioc_sm_table[] = {
165/* 153/*
166 * Forward declareations for iocpf state machine 154 * Forward declareations for iocpf state machine
167 */ 155 */
168static void bfa_iocpf_enable(struct bfa_ioc_s *ioc);
169static void bfa_iocpf_disable(struct bfa_ioc_s *ioc);
170static void bfa_iocpf_fail(struct bfa_ioc_s *ioc);
171static void bfa_iocpf_initfail(struct bfa_ioc_s *ioc);
172static void bfa_iocpf_getattrfail(struct bfa_ioc_s *ioc);
173static void bfa_iocpf_stop(struct bfa_ioc_s *ioc);
174static void bfa_iocpf_timeout(void *ioc_arg); 156static void bfa_iocpf_timeout(void *ioc_arg);
175static void bfa_iocpf_sem_timeout(void *ioc_arg); 157static void bfa_iocpf_sem_timeout(void *ioc_arg);
176 158
@@ -213,9 +195,14 @@ bfa_fsm_state_decl(bfa_iocpf, semwait, struct bfa_iocpf_s, enum iocpf_event);
213bfa_fsm_state_decl(bfa_iocpf, hwinit, struct bfa_iocpf_s, enum iocpf_event); 195bfa_fsm_state_decl(bfa_iocpf, hwinit, struct bfa_iocpf_s, enum iocpf_event);
214bfa_fsm_state_decl(bfa_iocpf, enabling, struct bfa_iocpf_s, enum iocpf_event); 196bfa_fsm_state_decl(bfa_iocpf, enabling, struct bfa_iocpf_s, enum iocpf_event);
215bfa_fsm_state_decl(bfa_iocpf, ready, struct bfa_iocpf_s, enum iocpf_event); 197bfa_fsm_state_decl(bfa_iocpf, ready, struct bfa_iocpf_s, enum iocpf_event);
198bfa_fsm_state_decl(bfa_iocpf, initfail_sync, struct bfa_iocpf_s,
199 enum iocpf_event);
216bfa_fsm_state_decl(bfa_iocpf, initfail, struct bfa_iocpf_s, enum iocpf_event); 200bfa_fsm_state_decl(bfa_iocpf, initfail, struct bfa_iocpf_s, enum iocpf_event);
201bfa_fsm_state_decl(bfa_iocpf, fail_sync, struct bfa_iocpf_s, enum iocpf_event);
217bfa_fsm_state_decl(bfa_iocpf, fail, struct bfa_iocpf_s, enum iocpf_event); 202bfa_fsm_state_decl(bfa_iocpf, fail, struct bfa_iocpf_s, enum iocpf_event);
218bfa_fsm_state_decl(bfa_iocpf, disabling, struct bfa_iocpf_s, enum iocpf_event); 203bfa_fsm_state_decl(bfa_iocpf, disabling, struct bfa_iocpf_s, enum iocpf_event);
204bfa_fsm_state_decl(bfa_iocpf, disabling_sync, struct bfa_iocpf_s,
205 enum iocpf_event);
219bfa_fsm_state_decl(bfa_iocpf, disabled, struct bfa_iocpf_s, enum iocpf_event); 206bfa_fsm_state_decl(bfa_iocpf, disabled, struct bfa_iocpf_s, enum iocpf_event);
220 207
221static struct bfa_sm_table_s iocpf_sm_table[] = { 208static struct bfa_sm_table_s iocpf_sm_table[] = {
@@ -226,9 +213,12 @@ static struct bfa_sm_table_s iocpf_sm_table[] = {
226 {BFA_SM(bfa_iocpf_sm_hwinit), BFA_IOCPF_HWINIT}, 213 {BFA_SM(bfa_iocpf_sm_hwinit), BFA_IOCPF_HWINIT},
227 {BFA_SM(bfa_iocpf_sm_enabling), BFA_IOCPF_HWINIT}, 214 {BFA_SM(bfa_iocpf_sm_enabling), BFA_IOCPF_HWINIT},
228 {BFA_SM(bfa_iocpf_sm_ready), BFA_IOCPF_READY}, 215 {BFA_SM(bfa_iocpf_sm_ready), BFA_IOCPF_READY},
216 {BFA_SM(bfa_iocpf_sm_initfail_sync), BFA_IOCPF_INITFAIL},
229 {BFA_SM(bfa_iocpf_sm_initfail), BFA_IOCPF_INITFAIL}, 217 {BFA_SM(bfa_iocpf_sm_initfail), BFA_IOCPF_INITFAIL},
218 {BFA_SM(bfa_iocpf_sm_fail_sync), BFA_IOCPF_FAIL},
230 {BFA_SM(bfa_iocpf_sm_fail), BFA_IOCPF_FAIL}, 219 {BFA_SM(bfa_iocpf_sm_fail), BFA_IOCPF_FAIL},
231 {BFA_SM(bfa_iocpf_sm_disabling), BFA_IOCPF_DISABLING}, 220 {BFA_SM(bfa_iocpf_sm_disabling), BFA_IOCPF_DISABLING},
221 {BFA_SM(bfa_iocpf_sm_disabling_sync), BFA_IOCPF_DISABLING},
232 {BFA_SM(bfa_iocpf_sm_disabled), BFA_IOCPF_DISABLED}, 222 {BFA_SM(bfa_iocpf_sm_disabled), BFA_IOCPF_DISABLED},
233}; 223};
234 224
@@ -301,7 +291,7 @@ bfa_ioc_sm_reset(struct bfa_ioc_s *ioc, enum ioc_event event)
301static void 291static void
302bfa_ioc_sm_enabling_entry(struct bfa_ioc_s *ioc) 292bfa_ioc_sm_enabling_entry(struct bfa_ioc_s *ioc)
303{ 293{
304 bfa_iocpf_enable(ioc); 294 bfa_fsm_send_event(&ioc->iocpf, IOCPF_E_ENABLE);
305} 295}
306 296
307/* 297/*
@@ -318,13 +308,13 @@ bfa_ioc_sm_enabling(struct bfa_ioc_s *ioc, enum ioc_event event)
318 bfa_fsm_set_state(ioc, bfa_ioc_sm_getattr); 308 bfa_fsm_set_state(ioc, bfa_ioc_sm_getattr);
319 break; 309 break;
320 310
321 case IOC_E_FAILED: 311 case IOC_E_PFFAILED:
322 bfa_fsm_set_state(ioc, bfa_ioc_sm_initfail); 312 /* !!! fall through !!! */
323 break;
324
325 case IOC_E_HWERROR: 313 case IOC_E_HWERROR:
326 bfa_fsm_set_state(ioc, bfa_ioc_sm_initfail); 314 ioc->cbfn->enable_cbfn(ioc->bfa, BFA_STATUS_IOC_FAILURE);
327 bfa_iocpf_initfail(ioc); 315 bfa_fsm_set_state(ioc, bfa_ioc_sm_fail_retry);
316 if (event != IOC_E_PFFAILED)
317 bfa_fsm_send_event(&ioc->iocpf, IOCPF_E_INITFAIL);
328 break; 318 break;
329 319
330 case IOC_E_DISABLE: 320 case IOC_E_DISABLE:
@@ -333,7 +323,7 @@ bfa_ioc_sm_enabling(struct bfa_ioc_s *ioc, enum ioc_event event)
333 323
334 case IOC_E_DETACH: 324 case IOC_E_DETACH:
335 bfa_fsm_set_state(ioc, bfa_ioc_sm_uninit); 325 bfa_fsm_set_state(ioc, bfa_ioc_sm_uninit);
336 bfa_iocpf_stop(ioc); 326 bfa_fsm_send_event(&ioc->iocpf, IOCPF_E_STOP);
337 break; 327 break;
338 328
339 case IOC_E_ENABLE: 329 case IOC_E_ENABLE:
@@ -367,18 +357,16 @@ bfa_ioc_sm_getattr(struct bfa_ioc_s *ioc, enum ioc_event event)
367 bfa_fsm_set_state(ioc, bfa_ioc_sm_op); 357 bfa_fsm_set_state(ioc, bfa_ioc_sm_op);
368 break; 358 break;
369 359
370 case IOC_E_FAILED:
371 bfa_ioc_timer_stop(ioc);
372 bfa_fsm_set_state(ioc, bfa_ioc_sm_initfail);
373 break; 360 break;
374 361 case IOC_E_PFFAILED:
375 case IOC_E_HWERROR: 362 case IOC_E_HWERROR:
376 bfa_ioc_timer_stop(ioc); 363 bfa_ioc_timer_stop(ioc);
377 /* fall through */ 364 /* !!! fall through !!! */
378
379 case IOC_E_TIMEOUT: 365 case IOC_E_TIMEOUT:
380 bfa_fsm_set_state(ioc, bfa_ioc_sm_initfail); 366 ioc->cbfn->enable_cbfn(ioc->bfa, BFA_STATUS_IOC_FAILURE);
381 bfa_iocpf_getattrfail(ioc); 367 bfa_fsm_set_state(ioc, bfa_ioc_sm_fail_retry);
368 if (event != IOC_E_PFFAILED)
369 bfa_fsm_send_event(&ioc->iocpf, IOCPF_E_GETATTRFAIL);
382 break; 370 break;
383 371
384 case IOC_E_DISABLE: 372 case IOC_E_DISABLE:
@@ -415,22 +403,24 @@ bfa_ioc_sm_op(struct bfa_ioc_s *ioc, enum ioc_event event)
415 break; 403 break;
416 404
417 case IOC_E_DISABLE: 405 case IOC_E_DISABLE:
418 bfa_ioc_hb_stop(ioc); 406 bfa_hb_timer_stop(ioc);
419 bfa_fsm_set_state(ioc, bfa_ioc_sm_disabling); 407 bfa_fsm_set_state(ioc, bfa_ioc_sm_disabling);
420 break; 408 break;
421 409
422 case IOC_E_FAILED: 410 case IOC_E_PFFAILED:
423 bfa_ioc_hb_stop(ioc);
424 bfa_fsm_set_state(ioc, bfa_ioc_sm_fail);
425 break;
426
427 case IOC_E_HWERROR: 411 case IOC_E_HWERROR:
428 bfa_ioc_hb_stop(ioc); 412 bfa_hb_timer_stop(ioc);
429 /* !!! fall through !!! */ 413 /* !!! fall through !!! */
430
431 case IOC_E_HBFAIL: 414 case IOC_E_HBFAIL:
432 bfa_fsm_set_state(ioc, bfa_ioc_sm_fail); 415 bfa_ioc_fail_notify(ioc);
433 bfa_iocpf_fail(ioc); 416
417 if (ioc->iocpf.auto_recover)
418 bfa_fsm_set_state(ioc, bfa_ioc_sm_fail_retry);
419 else
420 bfa_fsm_set_state(ioc, bfa_ioc_sm_fail);
421
422 if (event != IOC_E_PFFAILED)
423 bfa_fsm_send_event(&ioc->iocpf, IOCPF_E_FAIL);
434 break; 424 break;
435 425
436 default: 426 default:
@@ -443,7 +433,7 @@ static void
443bfa_ioc_sm_disabling_entry(struct bfa_ioc_s *ioc) 433bfa_ioc_sm_disabling_entry(struct bfa_ioc_s *ioc)
444{ 434{
445 struct bfad_s *bfad = (struct bfad_s *)ioc->bfa->bfad; 435 struct bfad_s *bfad = (struct bfad_s *)ioc->bfa->bfad;
446 bfa_iocpf_disable(ioc); 436 bfa_fsm_send_event(&ioc->iocpf, IOCPF_E_DISABLE);
447 BFA_LOG(KERN_INFO, bfad, bfa_log_level, "IOC disabled\n"); 437 BFA_LOG(KERN_INFO, bfad, bfa_log_level, "IOC disabled\n");
448} 438}
449 439
@@ -466,7 +456,7 @@ bfa_ioc_sm_disabling(struct bfa_ioc_s *ioc, enum ioc_event event)
466 * after iocpf sm completes failure processing and 456 * after iocpf sm completes failure processing and
467 * moves to disabled state. 457 * moves to disabled state.
468 */ 458 */
469 bfa_iocpf_fail(ioc); 459 bfa_fsm_send_event(&ioc->iocpf, IOCPF_E_FAIL);
470 break; 460 break;
471 461
472 default: 462 default:
@@ -499,7 +489,7 @@ bfa_ioc_sm_disabled(struct bfa_ioc_s *ioc, enum ioc_event event)
499 489
500 case IOC_E_DETACH: 490 case IOC_E_DETACH:
501 bfa_fsm_set_state(ioc, bfa_ioc_sm_uninit); 491 bfa_fsm_set_state(ioc, bfa_ioc_sm_uninit);
502 bfa_iocpf_stop(ioc); 492 bfa_fsm_send_event(&ioc->iocpf, IOCPF_E_STOP);
503 break; 493 break;
504 494
505 default: 495 default:
@@ -509,16 +499,16 @@ bfa_ioc_sm_disabled(struct bfa_ioc_s *ioc, enum ioc_event event)
509 499
510 500
511static void 501static void
512bfa_ioc_sm_initfail_entry(struct bfa_ioc_s *ioc) 502bfa_ioc_sm_fail_retry_entry(struct bfa_ioc_s *ioc)
513{ 503{
514 ioc->cbfn->enable_cbfn(ioc->bfa, BFA_STATUS_IOC_FAILURE); 504 bfa_trc(ioc, 0);
515} 505}
516 506
517/* 507/*
518 * Hardware initialization failed. 508 * Hardware initialization retry.
519 */ 509 */
520static void 510static void
521bfa_ioc_sm_initfail(struct bfa_ioc_s *ioc, enum ioc_event event) 511bfa_ioc_sm_fail_retry(struct bfa_ioc_s *ioc, enum ioc_event event)
522{ 512{
523 bfa_trc(ioc, event); 513 bfa_trc(ioc, event);
524 514
@@ -527,11 +517,21 @@ bfa_ioc_sm_initfail(struct bfa_ioc_s *ioc, enum ioc_event event)
527 bfa_fsm_set_state(ioc, bfa_ioc_sm_getattr); 517 bfa_fsm_set_state(ioc, bfa_ioc_sm_getattr);
528 break; 518 break;
529 519
530 case IOC_E_FAILED: 520 case IOC_E_PFFAILED:
521 case IOC_E_HWERROR:
531 /* 522 /*
532 * Initialization failure during iocpf init retry. 523 * Initialization retry failed.
533 */ 524 */
534 ioc->cbfn->enable_cbfn(ioc->bfa, BFA_STATUS_IOC_FAILURE); 525 ioc->cbfn->enable_cbfn(ioc->bfa, BFA_STATUS_IOC_FAILURE);
526 if (event != IOC_E_PFFAILED)
527 bfa_fsm_send_event(&ioc->iocpf, IOCPF_E_INITFAIL);
528 break;
529
530 case IOC_E_INITFAILED:
531 bfa_fsm_set_state(ioc, bfa_ioc_sm_fail);
532 break;
533
534 case IOC_E_ENABLE:
535 break; 535 break;
536 536
537 case IOC_E_DISABLE: 537 case IOC_E_DISABLE:
@@ -540,7 +540,7 @@ bfa_ioc_sm_initfail(struct bfa_ioc_s *ioc, enum ioc_event event)
540 540
541 case IOC_E_DETACH: 541 case IOC_E_DETACH:
542 bfa_fsm_set_state(ioc, bfa_ioc_sm_uninit); 542 bfa_fsm_set_state(ioc, bfa_ioc_sm_uninit);
543 bfa_iocpf_stop(ioc); 543 bfa_fsm_send_event(&ioc->iocpf, IOCPF_E_STOP);
544 break; 544 break;
545 545
546 default: 546 default:
@@ -552,21 +552,7 @@ bfa_ioc_sm_initfail(struct bfa_ioc_s *ioc, enum ioc_event event)
552static void 552static void
553bfa_ioc_sm_fail_entry(struct bfa_ioc_s *ioc) 553bfa_ioc_sm_fail_entry(struct bfa_ioc_s *ioc)
554{ 554{
555 struct list_head *qe; 555 bfa_trc(ioc, 0);
556 struct bfa_ioc_hbfail_notify_s *notify;
557 struct bfad_s *bfad = (struct bfad_s *)ioc->bfa->bfad;
558
559 /*
560 * Notify driver and common modules registered for notification.
561 */
562 ioc->cbfn->hbfail_cbfn(ioc->bfa);
563 list_for_each(qe, &ioc->hb_notify_q) {
564 notify = (struct bfa_ioc_hbfail_notify_s *) qe;
565 notify->cbfn(notify->cbarg);
566 }
567
568 BFA_LOG(KERN_CRIT, bfad, bfa_log_level,
569 "Heart Beat of IOC has failed\n");
570} 556}
571 557
572/* 558/*
@@ -579,23 +565,19 @@ bfa_ioc_sm_fail(struct bfa_ioc_s *ioc, enum ioc_event event)
579 565
580 switch (event) { 566 switch (event) {
581 567
582 case IOC_E_FAILED:
583 /*
584 * Initialization failure during iocpf recovery.
585 * !!! Fall through !!!
586 */
587 case IOC_E_ENABLE: 568 case IOC_E_ENABLE:
588 ioc->cbfn->enable_cbfn(ioc->bfa, BFA_STATUS_IOC_FAILURE); 569 ioc->cbfn->enable_cbfn(ioc->bfa, BFA_STATUS_IOC_FAILURE);
589 break; 570 break;
590 571
591 case IOC_E_ENABLED:
592 bfa_fsm_set_state(ioc, bfa_ioc_sm_getattr);
593 break;
594
595 case IOC_E_DISABLE: 572 case IOC_E_DISABLE:
596 bfa_fsm_set_state(ioc, bfa_ioc_sm_disabling); 573 bfa_fsm_set_state(ioc, bfa_ioc_sm_disabling);
597 break; 574 break;
598 575
576 case IOC_E_DETACH:
577 bfa_fsm_set_state(ioc, bfa_ioc_sm_uninit);
578 bfa_fsm_send_event(&ioc->iocpf, IOCPF_E_STOP);
579 break;
580
599 case IOC_E_HWERROR: 581 case IOC_E_HWERROR:
600 /* 582 /*
601 * HB failure notification, ignore. 583 * HB failure notification, ignore.
@@ -606,13 +588,10 @@ bfa_ioc_sm_fail(struct bfa_ioc_s *ioc, enum ioc_event event)
606 } 588 }
607} 589}
608 590
609
610
611/* 591/*
612 * IOCPF State Machine 592 * IOCPF State Machine
613 */ 593 */
614 594
615
616/* 595/*
617 * Reset entry actions -- initialize state machine 596 * Reset entry actions -- initialize state machine
618 */ 597 */
@@ -668,22 +647,29 @@ bfa_iocpf_sm_fwcheck(struct bfa_iocpf_s *iocpf, enum iocpf_event event)
668 switch (event) { 647 switch (event) {
669 case IOCPF_E_SEMLOCKED: 648 case IOCPF_E_SEMLOCKED:
670 if (bfa_ioc_firmware_lock(ioc)) { 649 if (bfa_ioc_firmware_lock(ioc)) {
671 iocpf->retry_count = 0; 650 if (bfa_ioc_sync_complete(ioc)) {
672 bfa_fsm_set_state(iocpf, bfa_iocpf_sm_hwinit); 651 iocpf->retry_count = 0;
652 bfa_ioc_sync_join(ioc);
653 bfa_fsm_set_state(iocpf, bfa_iocpf_sm_hwinit);
654 } else {
655 bfa_ioc_firmware_unlock(ioc);
656 writel(1, ioc->ioc_regs.ioc_sem_reg);
657 bfa_sem_timer_start(ioc);
658 }
673 } else { 659 } else {
674 bfa_ioc_hw_sem_release(ioc); 660 writel(1, ioc->ioc_regs.ioc_sem_reg);
675 bfa_fsm_set_state(iocpf, bfa_iocpf_sm_mismatch); 661 bfa_fsm_set_state(iocpf, bfa_iocpf_sm_mismatch);
676 } 662 }
677 break; 663 break;
678 664
679 case IOCPF_E_DISABLE: 665 case IOCPF_E_DISABLE:
680 bfa_ioc_hw_sem_get_cancel(ioc); 666 bfa_sem_timer_stop(ioc);
681 bfa_fsm_set_state(iocpf, bfa_iocpf_sm_reset); 667 bfa_fsm_set_state(iocpf, bfa_iocpf_sm_reset);
682 bfa_ioc_pf_disabled(ioc); 668 bfa_fsm_send_event(ioc, IOC_E_DISABLED);
683 break; 669 break;
684 670
685 case IOCPF_E_STOP: 671 case IOCPF_E_STOP:
686 bfa_ioc_hw_sem_get_cancel(ioc); 672 bfa_sem_timer_stop(ioc);
687 bfa_fsm_set_state(iocpf, bfa_iocpf_sm_reset); 673 bfa_fsm_set_state(iocpf, bfa_iocpf_sm_reset);
688 break; 674 break;
689 675
@@ -726,7 +712,7 @@ bfa_iocpf_sm_mismatch(struct bfa_iocpf_s *iocpf, enum iocpf_event event)
726 case IOCPF_E_DISABLE: 712 case IOCPF_E_DISABLE:
727 bfa_iocpf_timer_stop(ioc); 713 bfa_iocpf_timer_stop(ioc);
728 bfa_fsm_set_state(iocpf, bfa_iocpf_sm_reset); 714 bfa_fsm_set_state(iocpf, bfa_iocpf_sm_reset);
729 bfa_ioc_pf_disabled(ioc); 715 bfa_fsm_send_event(ioc, IOC_E_DISABLED);
730 break; 716 break;
731 717
732 case IOCPF_E_STOP: 718 case IOCPF_E_STOP:
@@ -760,13 +746,18 @@ bfa_iocpf_sm_semwait(struct bfa_iocpf_s *iocpf, enum iocpf_event event)
760 746
761 switch (event) { 747 switch (event) {
762 case IOCPF_E_SEMLOCKED: 748 case IOCPF_E_SEMLOCKED:
763 iocpf->retry_count = 0; 749 if (bfa_ioc_sync_complete(ioc)) {
764 bfa_fsm_set_state(iocpf, bfa_iocpf_sm_hwinit); 750 bfa_ioc_sync_join(ioc);
751 bfa_fsm_set_state(iocpf, bfa_iocpf_sm_hwinit);
752 } else {
753 writel(1, ioc->ioc_regs.ioc_sem_reg);
754 bfa_sem_timer_start(ioc);
755 }
765 break; 756 break;
766 757
767 case IOCPF_E_DISABLE: 758 case IOCPF_E_DISABLE:
768 bfa_ioc_hw_sem_get_cancel(ioc); 759 bfa_sem_timer_stop(ioc);
769 bfa_fsm_set_state(iocpf, bfa_iocpf_sm_disabled); 760 bfa_fsm_set_state(iocpf, bfa_iocpf_sm_disabling_sync);
770 break; 761 break;
771 762
772 default: 763 default:
@@ -774,12 +765,11 @@ bfa_iocpf_sm_semwait(struct bfa_iocpf_s *iocpf, enum iocpf_event event)
774 } 765 }
775} 766}
776 767
777
778static void 768static void
779bfa_iocpf_sm_hwinit_entry(struct bfa_iocpf_s *iocpf) 769bfa_iocpf_sm_hwinit_entry(struct bfa_iocpf_s *iocpf)
780{ 770{
781 bfa_iocpf_timer_start(iocpf->ioc); 771 bfa_iocpf_timer_start(iocpf->ioc);
782 bfa_ioc_reset(iocpf->ioc, BFA_FALSE); 772 bfa_ioc_hwinit(iocpf->ioc, BFA_FALSE);
783} 773}
784 774
785/* 775/*
@@ -806,23 +796,16 @@ bfa_iocpf_sm_hwinit(struct bfa_iocpf_s *iocpf, enum iocpf_event event)
806 */ 796 */
807 797
808 case IOCPF_E_TIMEOUT: 798 case IOCPF_E_TIMEOUT:
809 iocpf->retry_count++; 799 writel(1, ioc->ioc_regs.ioc_sem_reg);
810 if (iocpf->retry_count < BFA_IOC_HWINIT_MAX) {
811 bfa_iocpf_timer_start(ioc);
812 bfa_ioc_reset(ioc, BFA_TRUE);
813 break;
814 }
815
816 bfa_ioc_hw_sem_release(ioc);
817 bfa_fsm_set_state(iocpf, bfa_iocpf_sm_initfail);
818
819 if (event == IOCPF_E_TIMEOUT) 800 if (event == IOCPF_E_TIMEOUT)
820 bfa_ioc_pf_failed(ioc); 801 bfa_fsm_send_event(ioc, IOC_E_PFFAILED);
802 bfa_fsm_set_state(iocpf, bfa_iocpf_sm_initfail_sync);
821 break; 803 break;
822 804
823 case IOCPF_E_DISABLE: 805 case IOCPF_E_DISABLE:
824 bfa_ioc_hw_sem_release(ioc);
825 bfa_iocpf_timer_stop(ioc); 806 bfa_iocpf_timer_stop(ioc);
807 bfa_ioc_sync_leave(ioc);
808 writel(1, ioc->ioc_regs.ioc_sem_reg);
826 bfa_fsm_set_state(iocpf, bfa_iocpf_sm_disabled); 809 bfa_fsm_set_state(iocpf, bfa_iocpf_sm_disabled);
827 break; 810 break;
828 811
@@ -831,7 +814,6 @@ bfa_iocpf_sm_hwinit(struct bfa_iocpf_s *iocpf, enum iocpf_event event)
831 } 814 }
832} 815}
833 816
834
835static void 817static void
836bfa_iocpf_sm_enabling_entry(struct bfa_iocpf_s *iocpf) 818bfa_iocpf_sm_enabling_entry(struct bfa_iocpf_s *iocpf)
837{ 819{
@@ -853,7 +835,7 @@ bfa_iocpf_sm_enabling(struct bfa_iocpf_s *iocpf, enum iocpf_event event)
853 switch (event) { 835 switch (event) {
854 case IOCPF_E_FWRSP_ENABLE: 836 case IOCPF_E_FWRSP_ENABLE:
855 bfa_iocpf_timer_stop(ioc); 837 bfa_iocpf_timer_stop(ioc);
856 bfa_ioc_hw_sem_release(ioc); 838 writel(1, ioc->ioc_regs.ioc_sem_reg);
857 bfa_fsm_set_state(iocpf, bfa_iocpf_sm_ready); 839 bfa_fsm_set_state(iocpf, bfa_iocpf_sm_ready);
858 break; 840 break;
859 841
@@ -864,23 +846,15 @@ bfa_iocpf_sm_enabling(struct bfa_iocpf_s *iocpf, enum iocpf_event event)
864 */ 846 */
865 847
866 case IOCPF_E_TIMEOUT: 848 case IOCPF_E_TIMEOUT:
867 iocpf->retry_count++; 849 writel(1, ioc->ioc_regs.ioc_sem_reg);
868 if (iocpf->retry_count < BFA_IOC_HWINIT_MAX) {
869 writel(BFI_IOC_UNINIT, ioc->ioc_regs.ioc_fwstate);
870 bfa_fsm_set_state(iocpf, bfa_iocpf_sm_hwinit);
871 break;
872 }
873
874 bfa_ioc_hw_sem_release(ioc);
875 bfa_fsm_set_state(iocpf, bfa_iocpf_sm_initfail);
876
877 if (event == IOCPF_E_TIMEOUT) 850 if (event == IOCPF_E_TIMEOUT)
878 bfa_ioc_pf_failed(ioc); 851 bfa_fsm_send_event(ioc, IOC_E_PFFAILED);
852 bfa_fsm_set_state(iocpf, bfa_iocpf_sm_initfail_sync);
879 break; 853 break;
880 854
881 case IOCPF_E_DISABLE: 855 case IOCPF_E_DISABLE:
882 bfa_iocpf_timer_stop(ioc); 856 bfa_iocpf_timer_stop(ioc);
883 bfa_ioc_hw_sem_release(ioc); 857 writel(1, ioc->ioc_regs.ioc_sem_reg);
884 bfa_fsm_set_state(iocpf, bfa_iocpf_sm_disabling); 858 bfa_fsm_set_state(iocpf, bfa_iocpf_sm_disabling);
885 break; 859 break;
886 860
@@ -893,12 +867,10 @@ bfa_iocpf_sm_enabling(struct bfa_iocpf_s *iocpf, enum iocpf_event event)
893 } 867 }
894} 868}
895 869
896
897
898static void 870static void
899bfa_iocpf_sm_ready_entry(struct bfa_iocpf_s *iocpf) 871bfa_iocpf_sm_ready_entry(struct bfa_iocpf_s *iocpf)
900{ 872{
901 bfa_ioc_pf_enabled(iocpf->ioc); 873 bfa_fsm_send_event(iocpf->ioc, IOC_E_ENABLED);
902} 874}
903 875
904static void 876static void
@@ -914,20 +886,21 @@ bfa_iocpf_sm_ready(struct bfa_iocpf_s *iocpf, enum iocpf_event event)
914 break; 886 break;
915 887
916 case IOCPF_E_GETATTRFAIL: 888 case IOCPF_E_GETATTRFAIL:
917 bfa_fsm_set_state(iocpf, bfa_iocpf_sm_initfail); 889 bfa_fsm_set_state(iocpf, bfa_iocpf_sm_initfail_sync);
918 break; 890 break;
919 891
920 case IOCPF_E_FAIL: 892 case IOCPF_E_FAIL:
921 bfa_fsm_set_state(iocpf, bfa_iocpf_sm_fail); 893 bfa_fsm_set_state(iocpf, bfa_iocpf_sm_fail_sync);
922 break; 894 break;
923 895
924 case IOCPF_E_FWREADY: 896 case IOCPF_E_FWREADY:
925 if (bfa_ioc_is_operational(ioc)) 897 if (bfa_ioc_is_operational(ioc)) {
926 bfa_fsm_set_state(iocpf, bfa_iocpf_sm_fail); 898 bfa_fsm_send_event(ioc, IOC_E_PFFAILED);
927 else 899 bfa_fsm_set_state(iocpf, bfa_iocpf_sm_fail_sync);
928 bfa_fsm_set_state(iocpf, bfa_iocpf_sm_initfail); 900 } else {
929 901 bfa_fsm_send_event(ioc, IOC_E_PFFAILED);
930 bfa_ioc_pf_failed(ioc); 902 bfa_fsm_set_state(iocpf, bfa_iocpf_sm_initfail_sync);
903 }
931 break; 904 break;
932 905
933 default: 906 default:
@@ -935,7 +908,6 @@ bfa_iocpf_sm_ready(struct bfa_iocpf_s *iocpf, enum iocpf_event event)
935 } 908 }
936} 909}
937 910
938
939static void 911static void
940bfa_iocpf_sm_disabling_entry(struct bfa_iocpf_s *iocpf) 912bfa_iocpf_sm_disabling_entry(struct bfa_iocpf_s *iocpf)
941{ 913{
@@ -957,7 +929,7 @@ bfa_iocpf_sm_disabling(struct bfa_iocpf_s *iocpf, enum iocpf_event event)
957 case IOCPF_E_FWRSP_DISABLE: 929 case IOCPF_E_FWRSP_DISABLE:
958 case IOCPF_E_FWREADY: 930 case IOCPF_E_FWREADY:
959 bfa_iocpf_timer_stop(ioc); 931 bfa_iocpf_timer_stop(ioc);
960 bfa_fsm_set_state(iocpf, bfa_iocpf_sm_disabled); 932 bfa_fsm_set_state(iocpf, bfa_iocpf_sm_disabling_sync);
961 break; 933 break;
962 934
963 case IOCPF_E_FAIL: 935 case IOCPF_E_FAIL:
@@ -968,7 +940,7 @@ bfa_iocpf_sm_disabling(struct bfa_iocpf_s *iocpf, enum iocpf_event event)
968 940
969 case IOCPF_E_TIMEOUT: 941 case IOCPF_E_TIMEOUT:
970 writel(BFI_IOC_FAIL, ioc->ioc_regs.ioc_fwstate); 942 writel(BFI_IOC_FAIL, ioc->ioc_regs.ioc_fwstate);
971 bfa_fsm_set_state(iocpf, bfa_iocpf_sm_disabled); 943 bfa_fsm_set_state(iocpf, bfa_iocpf_sm_disabling_sync);
972 break; 944 break;
973 945
974 case IOCPF_E_FWRSP_ENABLE: 946 case IOCPF_E_FWRSP_ENABLE:
@@ -979,13 +951,44 @@ bfa_iocpf_sm_disabling(struct bfa_iocpf_s *iocpf, enum iocpf_event event)
979 } 951 }
980} 952}
981 953
954static void
955bfa_iocpf_sm_disabling_sync_entry(struct bfa_iocpf_s *iocpf)
956{
957 bfa_ioc_hw_sem_get(iocpf->ioc);
958}
959
960/*
961 * IOC hb ack request is being removed.
962 */
963static void
964bfa_iocpf_sm_disabling_sync(struct bfa_iocpf_s *iocpf, enum iocpf_event event)
965{
966 struct bfa_ioc_s *ioc = iocpf->ioc;
967
968 bfa_trc(ioc, event);
969
970 switch (event) {
971 case IOCPF_E_SEMLOCKED:
972 bfa_ioc_sync_leave(ioc);
973 writel(1, ioc->ioc_regs.ioc_sem_reg);
974 bfa_fsm_set_state(iocpf, bfa_iocpf_sm_disabled);
975 break;
976
977 case IOCPF_E_FAIL:
978 break;
979
980 default:
981 bfa_sm_fault(ioc, event);
982 }
983}
984
982/* 985/*
983 * IOC disable completion entry. 986 * IOC disable completion entry.
984 */ 987 */
985static void 988static void
986bfa_iocpf_sm_disabled_entry(struct bfa_iocpf_s *iocpf) 989bfa_iocpf_sm_disabled_entry(struct bfa_iocpf_s *iocpf)
987{ 990{
988 bfa_ioc_pf_disabled(iocpf->ioc); 991 bfa_fsm_send_event(iocpf->ioc, IOC_E_DISABLED);
989} 992}
990 993
991static void 994static void
@@ -997,6 +1000,7 @@ bfa_iocpf_sm_disabled(struct bfa_iocpf_s *iocpf, enum iocpf_event event)
997 1000
998 switch (event) { 1001 switch (event) {
999 case IOCPF_E_ENABLE: 1002 case IOCPF_E_ENABLE:
1003 iocpf->retry_count = 0;
1000 bfa_fsm_set_state(iocpf, bfa_iocpf_sm_semwait); 1004 bfa_fsm_set_state(iocpf, bfa_iocpf_sm_semwait);
1001 break; 1005 break;
1002 1006
@@ -1010,11 +1014,64 @@ bfa_iocpf_sm_disabled(struct bfa_iocpf_s *iocpf, enum iocpf_event event)
1010 } 1014 }
1011} 1015}
1012 1016
1017static void
1018bfa_iocpf_sm_initfail_sync_entry(struct bfa_iocpf_s *iocpf)
1019{
1020 bfa_ioc_hw_sem_get(iocpf->ioc);
1021}
1022
1023/*
1024 * Hardware initialization failed.
1025 */
1026static void
1027bfa_iocpf_sm_initfail_sync(struct bfa_iocpf_s *iocpf, enum iocpf_event event)
1028{
1029 struct bfa_ioc_s *ioc = iocpf->ioc;
1030
1031 bfa_trc(ioc, event);
1032
1033 switch (event) {
1034 case IOCPF_E_SEMLOCKED:
1035 bfa_ioc_notify_fail(ioc);
1036 bfa_ioc_sync_ack(ioc);
1037 iocpf->retry_count++;
1038 if (iocpf->retry_count >= BFA_IOC_HWINIT_MAX) {
1039 bfa_ioc_sync_leave(ioc);
1040 writel(1, ioc->ioc_regs.ioc_sem_reg);
1041 bfa_fsm_set_state(iocpf, bfa_iocpf_sm_initfail);
1042 } else {
1043 if (bfa_ioc_sync_complete(ioc))
1044 bfa_fsm_set_state(iocpf, bfa_iocpf_sm_hwinit);
1045 else {
1046 writel(1, ioc->ioc_regs.ioc_sem_reg);
1047 bfa_fsm_set_state(iocpf, bfa_iocpf_sm_semwait);
1048 }
1049 }
1050 break;
1051
1052 case IOCPF_E_DISABLE:
1053 bfa_sem_timer_stop(ioc);
1054 bfa_fsm_set_state(iocpf, bfa_iocpf_sm_disabling_sync);
1055 break;
1056
1057 case IOCPF_E_STOP:
1058 bfa_sem_timer_stop(ioc);
1059 bfa_ioc_firmware_unlock(ioc);
1060 bfa_fsm_set_state(iocpf, bfa_iocpf_sm_reset);
1061 break;
1062
1063 case IOCPF_E_FAIL:
1064 break;
1065
1066 default:
1067 bfa_sm_fault(ioc, event);
1068 }
1069}
1013 1070
1014static void 1071static void
1015bfa_iocpf_sm_initfail_entry(struct bfa_iocpf_s *iocpf) 1072bfa_iocpf_sm_initfail_entry(struct bfa_iocpf_s *iocpf)
1016{ 1073{
1017 bfa_iocpf_timer_start(iocpf->ioc); 1074 bfa_fsm_send_event(iocpf->ioc, IOC_E_INITFAILED);
1018} 1075}
1019 1076
1020/* 1077/*
@@ -1029,47 +1086,77 @@ bfa_iocpf_sm_initfail(struct bfa_iocpf_s *iocpf, enum iocpf_event event)
1029 1086
1030 switch (event) { 1087 switch (event) {
1031 case IOCPF_E_DISABLE: 1088 case IOCPF_E_DISABLE:
1032 bfa_iocpf_timer_stop(ioc);
1033 bfa_fsm_set_state(iocpf, bfa_iocpf_sm_disabled); 1089 bfa_fsm_set_state(iocpf, bfa_iocpf_sm_disabled);
1034 break; 1090 break;
1035 1091
1036 case IOCPF_E_STOP: 1092 case IOCPF_E_STOP:
1037 bfa_iocpf_timer_stop(ioc);
1038 bfa_ioc_firmware_unlock(ioc); 1093 bfa_ioc_firmware_unlock(ioc);
1039 bfa_fsm_set_state(iocpf, bfa_iocpf_sm_reset); 1094 bfa_fsm_set_state(iocpf, bfa_iocpf_sm_reset);
1040 break; 1095 break;
1041 1096
1042 case IOCPF_E_TIMEOUT:
1043 bfa_fsm_set_state(iocpf, bfa_iocpf_sm_semwait);
1044 break;
1045
1046 default: 1097 default:
1047 bfa_sm_fault(ioc, event); 1098 bfa_sm_fault(ioc, event);
1048 } 1099 }
1049} 1100}
1050 1101
1051
1052static void 1102static void
1053bfa_iocpf_sm_fail_entry(struct bfa_iocpf_s *iocpf) 1103bfa_iocpf_sm_fail_sync_entry(struct bfa_iocpf_s *iocpf)
1054{ 1104{
1055 /* 1105 /*
1056 * Mark IOC as failed in hardware and stop firmware. 1106 * Mark IOC as failed in hardware and stop firmware.
1057 */ 1107 */
1058 bfa_ioc_lpu_stop(iocpf->ioc); 1108 bfa_ioc_lpu_stop(iocpf->ioc);
1059 writel(BFI_IOC_FAIL, iocpf->ioc->ioc_regs.ioc_fwstate);
1060
1061 /*
1062 * Notify other functions on HB failure.
1063 */
1064 bfa_ioc_notify_hbfail(iocpf->ioc);
1065 1109
1066 /* 1110 /*
1067 * Flush any queued up mailbox requests. 1111 * Flush any queued up mailbox requests.
1068 */ 1112 */
1069 bfa_ioc_mbox_hbfail(iocpf->ioc); 1113 bfa_ioc_mbox_hbfail(iocpf->ioc);
1070 1114
1071 if (iocpf->auto_recover) 1115 bfa_ioc_hw_sem_get(iocpf->ioc);
1072 bfa_iocpf_recovery_timer_start(iocpf->ioc); 1116}
1117
1118static void
1119bfa_iocpf_sm_fail_sync(struct bfa_iocpf_s *iocpf, enum iocpf_event event)
1120{
1121 struct bfa_ioc_s *ioc = iocpf->ioc;
1122
1123 bfa_trc(ioc, event);
1124
1125 switch (event) {
1126 case IOCPF_E_SEMLOCKED:
1127 iocpf->retry_count = 0;
1128 bfa_ioc_sync_ack(ioc);
1129 bfa_ioc_notify_fail(ioc);
1130 if (!iocpf->auto_recover) {
1131 bfa_ioc_sync_leave(ioc);
1132 writel(1, ioc->ioc_regs.ioc_sem_reg);
1133 bfa_fsm_set_state(iocpf, bfa_iocpf_sm_fail);
1134 } else {
1135 if (bfa_ioc_sync_complete(ioc))
1136 bfa_fsm_set_state(iocpf, bfa_iocpf_sm_hwinit);
1137 else {
1138 writel(1, ioc->ioc_regs.ioc_sem_reg);
1139 bfa_fsm_set_state(iocpf, bfa_iocpf_sm_semwait);
1140 }
1141 }
1142 break;
1143
1144 case IOCPF_E_DISABLE:
1145 bfa_sem_timer_stop(ioc);
1146 bfa_fsm_set_state(iocpf, bfa_iocpf_sm_disabling_sync);
1147 break;
1148
1149 case IOCPF_E_FAIL:
1150 break;
1151
1152 default:
1153 bfa_sm_fault(ioc, event);
1154 }
1155}
1156
1157static void
1158bfa_iocpf_sm_fail_entry(struct bfa_iocpf_s *iocpf)
1159{
1073} 1160}
1074 1161
1075/* 1162/*
@@ -1084,24 +1171,16 @@ bfa_iocpf_sm_fail(struct bfa_iocpf_s *iocpf, enum iocpf_event event)
1084 1171
1085 switch (event) { 1172 switch (event) {
1086 case IOCPF_E_DISABLE: 1173 case IOCPF_E_DISABLE:
1087 if (iocpf->auto_recover)
1088 bfa_iocpf_timer_stop(ioc);
1089 bfa_fsm_set_state(iocpf, bfa_iocpf_sm_disabled); 1174 bfa_fsm_set_state(iocpf, bfa_iocpf_sm_disabled);
1090 break; 1175 break;
1091 1176
1092 case IOCPF_E_TIMEOUT:
1093 bfa_fsm_set_state(iocpf, bfa_iocpf_sm_semwait);
1094 break;
1095
1096 default: 1177 default:
1097 bfa_sm_fault(ioc, event); 1178 bfa_sm_fault(ioc, event);
1098 } 1179 }
1099} 1180}
1100 1181
1101
1102
1103/* 1182/*
1104 * hal_ioc_pvt BFA IOC private functions 1183 * BFA IOC private functions
1105 */ 1184 */
1106 1185
1107static void 1186static void
@@ -1139,16 +1218,10 @@ bfa_ioc_sem_get(void __iomem *sem_reg)
1139 if (r32 == 0) 1218 if (r32 == 0)
1140 return BFA_TRUE; 1219 return BFA_TRUE;
1141 1220
1142 bfa_assert(cnt < BFA_SEM_SPINCNT); 1221 WARN_ON(cnt >= BFA_SEM_SPINCNT);
1143 return BFA_FALSE; 1222 return BFA_FALSE;
1144} 1223}
1145 1224
1146void
1147bfa_ioc_sem_release(void __iomem *sem_reg)
1148{
1149 writel(1, sem_reg);
1150}
1151
1152static void 1225static void
1153bfa_ioc_hw_sem_get(struct bfa_ioc_s *ioc) 1226bfa_ioc_hw_sem_get(struct bfa_ioc_s *ioc)
1154{ 1227{
@@ -1167,18 +1240,6 @@ bfa_ioc_hw_sem_get(struct bfa_ioc_s *ioc)
1167 bfa_sem_timer_start(ioc); 1240 bfa_sem_timer_start(ioc);
1168} 1241}
1169 1242
1170void
1171bfa_ioc_hw_sem_release(struct bfa_ioc_s *ioc)
1172{
1173 writel(1, ioc->ioc_regs.ioc_sem_reg);
1174}
1175
1176static void
1177bfa_ioc_hw_sem_get_cancel(struct bfa_ioc_s *ioc)
1178{
1179 bfa_sem_timer_stop(ioc);
1180}
1181
1182/* 1243/*
1183 * Initialize LPU local memory (aka secondary memory / SRAM) 1244 * Initialize LPU local memory (aka secondary memory / SRAM)
1184 */ 1245 */
@@ -1212,7 +1273,7 @@ bfa_ioc_lmem_init(struct bfa_ioc_s *ioc)
1212 * If memory initialization is not successful, IOC timeout will catch 1273 * If memory initialization is not successful, IOC timeout will catch
1213 * such failures. 1274 * such failures.
1214 */ 1275 */
1215 bfa_assert(pss_ctl & __PSS_LMEM_INIT_DONE); 1276 WARN_ON(!(pss_ctl & __PSS_LMEM_INIT_DONE));
1216 bfa_trc(ioc, pss_ctl); 1277 bfa_trc(ioc, pss_ctl);
1217 1278
1218 pss_ctl &= ~(__PSS_LMEM_INIT_DONE | __PSS_LMEM_INIT_EN); 1279 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)
1258 int i; 1319 int i;
1259 u32 *fwsig = (u32 *) fwhdr; 1320 u32 *fwsig = (u32 *) fwhdr;
1260 1321
1261 pgnum = bfa_ioc_smem_pgnum(ioc, loff); 1322 pgnum = PSS_SMEM_PGNUM(ioc->ioc_regs.smem_pg0, loff);
1262 pgoff = bfa_ioc_smem_pgoff(ioc, loff); 1323 pgoff = PSS_SMEM_PGOFF(loff);
1263 writel(pgnum, ioc->ioc_regs.host_page_num_fn); 1324 writel(pgnum, ioc->ioc_regs.host_page_num_fn);
1264 1325
1265 for (i = 0; i < (sizeof(struct bfi_ioc_image_hdr_s) / sizeof(u32)); 1326 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)
1304{ 1365{
1305 struct bfi_ioc_image_hdr_s fwhdr, *drv_fwhdr; 1366 struct bfi_ioc_image_hdr_s fwhdr, *drv_fwhdr;
1306 1367
1307 /*
1308 * If bios/efi boot (flash based) -- return true
1309 */
1310 if (bfa_ioc_is_bios_optrom(ioc))
1311 return BFA_TRUE;
1312
1313 bfa_ioc_fwver_get(ioc, &fwhdr); 1368 bfa_ioc_fwver_get(ioc, &fwhdr);
1314 drv_fwhdr = (struct bfi_ioc_image_hdr_s *) 1369 drv_fwhdr = (struct bfi_ioc_image_hdr_s *)
1315 bfa_cb_image_get_chunk(BFA_IOC_FWIMG_TYPE(ioc), 0); 1370 bfa_cb_image_get_chunk(BFA_IOC_FWIMG_TYPE(ioc), 0);
@@ -1342,7 +1397,6 @@ bfa_ioc_msgflush(struct bfa_ioc_s *ioc)
1342 writel(1, ioc->ioc_regs.lpu_mbox_cmd); 1397 writel(1, ioc->ioc_regs.lpu_mbox_cmd);
1343} 1398}
1344 1399
1345
1346static void 1400static void
1347bfa_ioc_hwinit(struct bfa_ioc_s *ioc, bfa_boolean_t force) 1401bfa_ioc_hwinit(struct bfa_ioc_s *ioc, bfa_boolean_t force)
1348{ 1402{
@@ -1362,22 +1416,6 @@ bfa_ioc_hwinit(struct bfa_ioc_s *ioc, bfa_boolean_t force)
1362 boot_env = BFI_BOOT_LOADER_OS; 1416 boot_env = BFI_BOOT_LOADER_OS;
1363 1417
1364 /* 1418 /*
1365 * Flash based firmware boot BIOS env.
1366 */
1367 if (bfa_ioc_is_bios_optrom(ioc)) {
1368 boot_type = BFI_BOOT_TYPE_FLASH;
1369 boot_env = BFI_BOOT_LOADER_BIOS;
1370 }
1371
1372 /*
1373 * Flash based firmware boot UEFI env.
1374 */
1375 if (bfa_ioc_is_uefi(ioc)) {
1376 boot_type = BFI_BOOT_TYPE_FLASH;
1377 boot_env = BFI_BOOT_LOADER_UEFI;
1378 }
1379
1380 /*
1381 * check if firmware is valid 1419 * check if firmware is valid
1382 */ 1420 */
1383 fwvalid = (ioc_fwstate == BFI_IOC_UNINIT) ? 1421 fwvalid = (ioc_fwstate == BFI_IOC_UNINIT) ?
@@ -1405,8 +1443,7 @@ bfa_ioc_hwinit(struct bfa_ioc_s *ioc, bfa_boolean_t force)
1405 * convergence, IOC will be in operational state when 2nd driver 1443 * convergence, IOC will be in operational state when 2nd driver
1406 * is loaded. 1444 * is loaded.
1407 */ 1445 */
1408 if (ioc_fwstate == BFI_IOC_DISABLED || 1446 if (ioc_fwstate == BFI_IOC_DISABLED || ioc_fwstate == BFI_IOC_OP) {
1409 (!bfa_ioc_is_bios_optrom(ioc) && ioc_fwstate == BFI_IOC_OP)) {
1410 1447
1411 /* 1448 /*
1412 * When using MSI-X any pending firmware ready event should 1449 * 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)
1442 bfa_trc(ioc, msgp[0]); 1479 bfa_trc(ioc, msgp[0]);
1443 bfa_trc(ioc, len); 1480 bfa_trc(ioc, len);
1444 1481
1445 bfa_assert(len <= BFI_IOC_MSGLEN_MAX); 1482 WARN_ON(len > BFI_IOC_MSGLEN_MAX);
1446 1483
1447 /* 1484 /*
1448 * first write msg to mailbox registers 1485 * first write msg to mailbox registers
@@ -1465,12 +1502,12 @@ static void
1465bfa_ioc_send_enable(struct bfa_ioc_s *ioc) 1502bfa_ioc_send_enable(struct bfa_ioc_s *ioc)
1466{ 1503{
1467 struct bfi_ioc_ctrl_req_s enable_req; 1504 struct bfi_ioc_ctrl_req_s enable_req;
1468 struct bfa_timeval_s tv; 1505 struct timeval tv;
1469 1506
1470 bfi_h2i_set(enable_req.mh, BFI_MC_IOC, BFI_IOC_H2I_ENABLE_REQ, 1507 bfi_h2i_set(enable_req.mh, BFI_MC_IOC, BFI_IOC_H2I_ENABLE_REQ,
1471 bfa_ioc_portid(ioc)); 1508 bfa_ioc_portid(ioc));
1472 enable_req.ioc_class = ioc->ioc_mc; 1509 enable_req.ioc_class = ioc->ioc_mc;
1473 bfa_os_gettimeofday(&tv); 1510 do_gettimeofday(&tv);
1474 enable_req.tv_sec = be32_to_cpu(tv.tv_sec); 1511 enable_req.tv_sec = be32_to_cpu(tv.tv_sec);
1475 bfa_ioc_mbox_send(ioc, &enable_req, sizeof(struct bfi_ioc_ctrl_req_s)); 1512 bfa_ioc_mbox_send(ioc, &enable_req, sizeof(struct bfi_ioc_ctrl_req_s));
1476} 1513}
@@ -1504,7 +1541,6 @@ bfa_ioc_hb_check(void *cbarg)
1504 1541
1505 hb_count = readl(ioc->ioc_regs.heartbeat); 1542 hb_count = readl(ioc->ioc_regs.heartbeat);
1506 if (ioc->hb_count == hb_count) { 1543 if (ioc->hb_count == hb_count) {
1507 printk(KERN_CRIT "Firmware heartbeat failure at %d", hb_count);
1508 bfa_ioc_recover(ioc); 1544 bfa_ioc_recover(ioc);
1509 return; 1545 return;
1510 } else { 1546 } else {
@@ -1522,13 +1558,6 @@ bfa_ioc_hb_monitor(struct bfa_ioc_s *ioc)
1522 bfa_hb_timer_start(ioc); 1558 bfa_hb_timer_start(ioc);
1523} 1559}
1524 1560
1525static void
1526bfa_ioc_hb_stop(struct bfa_ioc_s *ioc)
1527{
1528 bfa_hb_timer_stop(ioc);
1529}
1530
1531
1532/* 1561/*
1533 * Initiate a full firmware download. 1562 * Initiate a full firmware download.
1534 */ 1563 */
@@ -1550,8 +1579,8 @@ bfa_ioc_download_fw(struct bfa_ioc_s *ioc, u32 boot_type,
1550 bfa_trc(ioc, bfa_cb_image_get_size(BFA_IOC_FWIMG_TYPE(ioc))); 1579 bfa_trc(ioc, bfa_cb_image_get_size(BFA_IOC_FWIMG_TYPE(ioc)));
1551 fwimg = bfa_cb_image_get_chunk(BFA_IOC_FWIMG_TYPE(ioc), chunkno); 1580 fwimg = bfa_cb_image_get_chunk(BFA_IOC_FWIMG_TYPE(ioc), chunkno);
1552 1581
1553 pgnum = bfa_ioc_smem_pgnum(ioc, loff); 1582 pgnum = PSS_SMEM_PGNUM(ioc->ioc_regs.smem_pg0, loff);
1554 pgoff = bfa_ioc_smem_pgoff(ioc, loff); 1583 pgoff = PSS_SMEM_PGOFF(loff);
1555 1584
1556 writel(pgnum, ioc->ioc_regs.host_page_num_fn); 1585 writel(pgnum, ioc->ioc_regs.host_page_num_fn);
1557 1586
@@ -1581,7 +1610,8 @@ bfa_ioc_download_fw(struct bfa_ioc_s *ioc, u32 boot_type,
1581 } 1610 }
1582 } 1611 }
1583 1612
1584 writel(bfa_ioc_smem_pgnum(ioc, 0), ioc->ioc_regs.host_page_num_fn); 1613 writel(PSS_SMEM_PGNUM(ioc->ioc_regs.smem_pg0, 0),
1614 ioc->ioc_regs.host_page_num_fn);
1585 1615
1586 /* 1616 /*
1587 * Set boot type and boot param at the end. 1617 * 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,
1592 swab32(boot_env)); 1622 swab32(boot_env));
1593} 1623}
1594 1624
1595static void
1596bfa_ioc_reset(struct bfa_ioc_s *ioc, bfa_boolean_t force)
1597{
1598 bfa_ioc_hwinit(ioc, force);
1599}
1600 1625
1601/* 1626/*
1602 * Update BFA configuration from firmware configuration. 1627 * Update BFA configuration from firmware configuration.
@@ -1683,12 +1708,13 @@ bfa_ioc_mbox_hbfail(struct bfa_ioc_s *ioc)
1683static bfa_status_t 1708static bfa_status_t
1684bfa_ioc_smem_read(struct bfa_ioc_s *ioc, void *tbuf, u32 soff, u32 sz) 1709bfa_ioc_smem_read(struct bfa_ioc_s *ioc, void *tbuf, u32 soff, u32 sz)
1685{ 1710{
1686 u32 pgnum, loff, r32; 1711 u32 pgnum, loff;
1712 __be32 r32;
1687 int i, len; 1713 int i, len;
1688 u32 *buf = tbuf; 1714 u32 *buf = tbuf;
1689 1715
1690 pgnum = bfa_ioc_smem_pgnum(ioc, soff); 1716 pgnum = PSS_SMEM_PGNUM(ioc->ioc_regs.smem_pg0, soff);
1691 loff = bfa_ioc_smem_pgoff(ioc, soff); 1717 loff = PSS_SMEM_PGOFF(soff);
1692 bfa_trc(ioc, pgnum); 1718 bfa_trc(ioc, pgnum);
1693 bfa_trc(ioc, loff); 1719 bfa_trc(ioc, loff);
1694 bfa_trc(ioc, sz); 1720 bfa_trc(ioc, sz);
@@ -1719,11 +1745,12 @@ bfa_ioc_smem_read(struct bfa_ioc_s *ioc, void *tbuf, u32 soff, u32 sz)
1719 writel(pgnum, ioc->ioc_regs.host_page_num_fn); 1745 writel(pgnum, ioc->ioc_regs.host_page_num_fn);
1720 } 1746 }
1721 } 1747 }
1722 writel(bfa_ioc_smem_pgnum(ioc, 0), ioc->ioc_regs.host_page_num_fn); 1748 writel(PSS_SMEM_PGNUM(ioc->ioc_regs.smem_pg0, 0),
1749 ioc->ioc_regs.host_page_num_fn);
1723 /* 1750 /*
1724 * release semaphore. 1751 * release semaphore.
1725 */ 1752 */
1726 bfa_ioc_sem_release(ioc->ioc_regs.ioc_init_sem_reg); 1753 writel(1, ioc->ioc_regs.ioc_init_sem_reg);
1727 1754
1728 bfa_trc(ioc, pgnum); 1755 bfa_trc(ioc, pgnum);
1729 return BFA_STATUS_OK; 1756 return BFA_STATUS_OK;
@@ -1742,8 +1769,8 @@ bfa_ioc_smem_clr(struct bfa_ioc_s *ioc, u32 soff, u32 sz)
1742 int i, len; 1769 int i, len;
1743 u32 pgnum, loff; 1770 u32 pgnum, loff;
1744 1771
1745 pgnum = bfa_ioc_smem_pgnum(ioc, soff); 1772 pgnum = PSS_SMEM_PGNUM(ioc->ioc_regs.smem_pg0, soff);
1746 loff = bfa_ioc_smem_pgoff(ioc, soff); 1773 loff = PSS_SMEM_PGOFF(soff);
1747 bfa_trc(ioc, pgnum); 1774 bfa_trc(ioc, pgnum);
1748 bfa_trc(ioc, loff); 1775 bfa_trc(ioc, loff);
1749 bfa_trc(ioc, sz); 1776 bfa_trc(ioc, sz);
@@ -1773,35 +1800,38 @@ bfa_ioc_smem_clr(struct bfa_ioc_s *ioc, u32 soff, u32 sz)
1773 writel(pgnum, ioc->ioc_regs.host_page_num_fn); 1800 writel(pgnum, ioc->ioc_regs.host_page_num_fn);
1774 } 1801 }
1775 } 1802 }
1776 writel(bfa_ioc_smem_pgnum(ioc, 0), ioc->ioc_regs.host_page_num_fn); 1803 writel(PSS_SMEM_PGNUM(ioc->ioc_regs.smem_pg0, 0),
1804 ioc->ioc_regs.host_page_num_fn);
1777 1805
1778 /* 1806 /*
1779 * release semaphore. 1807 * release semaphore.
1780 */ 1808 */
1781 bfa_ioc_sem_release(ioc->ioc_regs.ioc_init_sem_reg); 1809 writel(1, ioc->ioc_regs.ioc_init_sem_reg);
1782 bfa_trc(ioc, pgnum); 1810 bfa_trc(ioc, pgnum);
1783 return BFA_STATUS_OK; 1811 return BFA_STATUS_OK;
1784} 1812}
1785 1813
1786/*
1787 * hal iocpf to ioc interface
1788 */
1789static void 1814static void
1790bfa_ioc_pf_enabled(struct bfa_ioc_s *ioc) 1815bfa_ioc_fail_notify(struct bfa_ioc_s *ioc)
1791{ 1816{
1792 bfa_fsm_send_event(ioc, IOC_E_ENABLED); 1817 struct list_head *qe;
1793} 1818 struct bfa_ioc_hbfail_notify_s *notify;
1819 struct bfad_s *bfad = (struct bfad_s *)ioc->bfa->bfad;
1794 1820
1795static void 1821 /*
1796bfa_ioc_pf_disabled(struct bfa_ioc_s *ioc) 1822 * Notify driver and common modules registered for notification.
1797{ 1823 */
1798 bfa_fsm_send_event(ioc, IOC_E_DISABLED); 1824 ioc->cbfn->hbfail_cbfn(ioc->bfa);
1799} 1825 list_for_each(qe, &ioc->hb_notify_q) {
1826 notify = (struct bfa_ioc_hbfail_notify_s *) qe;
1827 notify->cbfn(notify->cbarg);
1828 }
1829
1830 bfa_ioc_debug_save_ftrc(ioc);
1831
1832 BFA_LOG(KERN_CRIT, bfad, bfa_log_level,
1833 "Heart Beat of IOC has failed\n");
1800 1834
1801static void
1802bfa_ioc_pf_failed(struct bfa_ioc_s *ioc)
1803{
1804 bfa_fsm_send_event(ioc, IOC_E_FAILED);
1805} 1835}
1806 1836
1807static void 1837static void
@@ -1817,12 +1847,6 @@ bfa_ioc_pf_fwmismatch(struct bfa_ioc_s *ioc)
1817 "with the driver version\n"); 1847 "with the driver version\n");
1818} 1848}
1819 1849
1820
1821
1822/*
1823 * hal_ioc_public
1824 */
1825
1826bfa_status_t 1850bfa_status_t
1827bfa_ioc_pll_init(struct bfa_ioc_s *ioc) 1851bfa_ioc_pll_init(struct bfa_ioc_s *ioc)
1828{ 1852{
@@ -1838,7 +1862,7 @@ bfa_ioc_pll_init(struct bfa_ioc_s *ioc)
1838 /* 1862 /*
1839 * release semaphore. 1863 * release semaphore.
1840 */ 1864 */
1841 bfa_ioc_sem_release(ioc->ioc_regs.ioc_init_sem_reg); 1865 writel(1, ioc->ioc_regs.ioc_init_sem_reg);
1842 1866
1843 return BFA_STATUS_OK; 1867 return BFA_STATUS_OK;
1844} 1868}
@@ -1909,7 +1933,7 @@ bfa_ioc_is_initialized(struct bfa_ioc_s *ioc)
1909void 1933void
1910bfa_ioc_msgget(struct bfa_ioc_s *ioc, void *mbmsg) 1934bfa_ioc_msgget(struct bfa_ioc_s *ioc, void *mbmsg)
1911{ 1935{
1912 u32 *msgp = mbmsg; 1936 __be32 *msgp = mbmsg;
1913 u32 r32; 1937 u32 r32;
1914 int i; 1938 int i;
1915 1939
@@ -1962,7 +1986,7 @@ bfa_ioc_isr(struct bfa_ioc_s *ioc, struct bfi_mbmsg_s *m)
1962 1986
1963 default: 1987 default:
1964 bfa_trc(ioc, msg->mh.msg_id); 1988 bfa_trc(ioc, msg->mh.msg_id);
1965 bfa_assert(0); 1989 WARN_ON(1);
1966 } 1990 }
1967} 1991}
1968 1992
@@ -2043,15 +2067,6 @@ bfa_ioc_mem_claim(struct bfa_ioc_s *ioc, u8 *dm_kva, u64 dm_pa)
2043 ioc->attr = (struct bfi_ioc_attr_s *) dm_kva; 2067 ioc->attr = (struct bfi_ioc_attr_s *) dm_kva;
2044} 2068}
2045 2069
2046/*
2047 * Return size of dma memory required.
2048 */
2049u32
2050bfa_ioc_meminfo(void)
2051{
2052 return BFA_ROUNDUP(sizeof(struct bfi_ioc_attr_s), BFA_DMA_ALIGN_SZ);
2053}
2054
2055void 2070void
2056bfa_ioc_enable(struct bfa_ioc_s *ioc) 2071bfa_ioc_enable(struct bfa_ioc_s *ioc)
2057{ 2072{
@@ -2068,18 +2083,6 @@ bfa_ioc_disable(struct bfa_ioc_s *ioc)
2068 bfa_fsm_send_event(ioc, IOC_E_DISABLE); 2083 bfa_fsm_send_event(ioc, IOC_E_DISABLE);
2069} 2084}
2070 2085
2071/*
2072 * Returns memory required for saving firmware trace in case of crash.
2073 * Driver must call this interface to allocate memory required for
2074 * automatic saving of firmware trace. Driver should call
2075 * bfa_ioc_debug_memclaim() right after bfa_ioc_attach() to setup this
2076 * trace memory.
2077 */
2078int
2079bfa_ioc_debug_trcsz(bfa_boolean_t auto_recover)
2080{
2081 return (auto_recover) ? BFA_DBG_FWTRC_LEN : 0;
2082}
2083 2086
2084/* 2087/*
2085 * Initialize memory for saving firmware trace. Driver must initialize 2088 * Initialize memory for saving firmware trace. Driver must initialize
@@ -2089,19 +2092,7 @@ void
2089bfa_ioc_debug_memclaim(struct bfa_ioc_s *ioc, void *dbg_fwsave) 2092bfa_ioc_debug_memclaim(struct bfa_ioc_s *ioc, void *dbg_fwsave)
2090{ 2093{
2091 ioc->dbg_fwsave = dbg_fwsave; 2094 ioc->dbg_fwsave = dbg_fwsave;
2092 ioc->dbg_fwsave_len = bfa_ioc_debug_trcsz(ioc->iocpf.auto_recover); 2095 ioc->dbg_fwsave_len = (ioc->iocpf.auto_recover) ? BFA_DBG_FWTRC_LEN : 0;
2093}
2094
2095u32
2096bfa_ioc_smem_pgnum(struct bfa_ioc_s *ioc, u32 fmaddr)
2097{
2098 return PSS_SMEM_PGNUM(ioc->ioc_regs.smem_pg0, fmaddr);
2099}
2100
2101u32
2102bfa_ioc_smem_pgoff(struct bfa_ioc_s *ioc, u32 fmaddr)
2103{
2104 return PSS_SMEM_PGOFF(fmaddr);
2105} 2096}
2106 2097
2107/* 2098/*
@@ -2265,14 +2256,13 @@ bfa_ioc_adapter_is_disabled(struct bfa_ioc_s *ioc)
2265} 2256}
2266 2257
2267/* 2258/*
2268 * Add to IOC heartbeat failure notification queue. To be used by common 2259 * Reset IOC fwstate registers.
2269 * modules such as cee, port, diag.
2270 */ 2260 */
2271void 2261void
2272bfa_ioc_hbfail_register(struct bfa_ioc_s *ioc, 2262bfa_ioc_reset_fwstate(struct bfa_ioc_s *ioc)
2273 struct bfa_ioc_hbfail_notify_s *notify)
2274{ 2263{
2275 list_add_tail(&notify->qe, &ioc->hb_notify_q); 2264 writel(BFI_IOC_UNINIT, ioc->ioc_regs.ioc_fwstate);
2265 writel(BFI_IOC_UNINIT, ioc->ioc_regs.alt_ioc_fwstate);
2276} 2266}
2277 2267
2278#define BFA_MFG_NAME "Brocade" 2268#define BFA_MFG_NAME "Brocade"
@@ -2306,7 +2296,7 @@ bfa_ioc_get_adapter_attr(struct bfa_ioc_s *ioc,
2306 else 2296 else
2307 ad_attr->prototype = 0; 2297 ad_attr->prototype = 0;
2308 2298
2309 ad_attr->pwwn = bfa_ioc_get_pwwn(ioc); 2299 ad_attr->pwwn = ioc->attr->pwwn;
2310 ad_attr->mac = bfa_ioc_get_mac(ioc); 2300 ad_attr->mac = bfa_ioc_get_mac(ioc);
2311 2301
2312 ad_attr->pcie_gen = ioc_attr->pcie_gen; 2302 ad_attr->pcie_gen = ioc_attr->pcie_gen;
@@ -2317,7 +2307,8 @@ bfa_ioc_get_adapter_attr(struct bfa_ioc_s *ioc,
2317 bfa_ioc_get_pci_chip_rev(ioc, ad_attr->hw_ver); 2307 bfa_ioc_get_pci_chip_rev(ioc, ad_attr->hw_ver);
2318 2308
2319 ad_attr->cna_capable = ioc->cna; 2309 ad_attr->cna_capable = ioc->cna;
2320 ad_attr->trunk_capable = (ad_attr->nports > 1) && !ioc->cna; 2310 ad_attr->trunk_capable = (ad_attr->nports > 1) && !ioc->cna &&
2311 !ad_attr->is_mezz;
2321} 2312}
2322 2313
2323enum bfa_ioc_type_e 2314enum bfa_ioc_type_e
@@ -2330,7 +2321,7 @@ bfa_ioc_get_type(struct bfa_ioc_s *ioc)
2330 else if (ioc->ioc_mc == BFI_MC_LL) 2321 else if (ioc->ioc_mc == BFI_MC_LL)
2331 return BFA_IOC_TYPE_LL; 2322 return BFA_IOC_TYPE_LL;
2332 else { 2323 else {
2333 bfa_assert(ioc->ioc_mc == BFI_MC_LL); 2324 WARN_ON(ioc->ioc_mc != BFI_MC_LL);
2334 return BFA_IOC_TYPE_LL; 2325 return BFA_IOC_TYPE_LL;
2335 } 2326 }
2336} 2327}
@@ -2354,7 +2345,7 @@ bfa_ioc_get_adapter_fw_ver(struct bfa_ioc_s *ioc, char *fw_ver)
2354void 2345void
2355bfa_ioc_get_pci_chip_rev(struct bfa_ioc_s *ioc, char *chip_rev) 2346bfa_ioc_get_pci_chip_rev(struct bfa_ioc_s *ioc, char *chip_rev)
2356{ 2347{
2357 bfa_assert(chip_rev); 2348 WARN_ON(!chip_rev);
2358 2349
2359 memset((void *)chip_rev, 0, BFA_IOC_CHIP_REV_LEN); 2350 memset((void *)chip_rev, 0, BFA_IOC_CHIP_REV_LEN);
2360 2351
@@ -2386,7 +2377,7 @@ bfa_ioc_get_adapter_model(struct bfa_ioc_s *ioc, char *model)
2386{ 2377{
2387 struct bfi_ioc_attr_s *ioc_attr; 2378 struct bfi_ioc_attr_s *ioc_attr;
2388 2379
2389 bfa_assert(model); 2380 WARN_ON(!model);
2390 memset((void *)model, 0, BFA_ADAPTER_MODEL_NAME_LEN); 2381 memset((void *)model, 0, BFA_ADAPTER_MODEL_NAME_LEN);
2391 2382
2392 ioc_attr = ioc->attr; 2383 ioc_attr = ioc->attr;
@@ -2455,27 +2446,6 @@ bfa_ioc_get_attr(struct bfa_ioc_s *ioc, struct bfa_ioc_attr_s *ioc_attr)
2455 bfa_ioc_get_pci_chip_rev(ioc, ioc_attr->pci_attr.chip_rev); 2446 bfa_ioc_get_pci_chip_rev(ioc, ioc_attr->pci_attr.chip_rev);
2456} 2447}
2457 2448
2458/*
2459 * hal_wwn_public
2460 */
2461wwn_t
2462bfa_ioc_get_pwwn(struct bfa_ioc_s *ioc)
2463{
2464 return ioc->attr->pwwn;
2465}
2466
2467wwn_t
2468bfa_ioc_get_nwwn(struct bfa_ioc_s *ioc)
2469{
2470 return ioc->attr->nwwn;
2471}
2472
2473u64
2474bfa_ioc_get_adid(struct bfa_ioc_s *ioc)
2475{
2476 return ioc->attr->mfg_pwwn;
2477}
2478
2479mac_t 2449mac_t
2480bfa_ioc_get_mac(struct bfa_ioc_s *ioc) 2450bfa_ioc_get_mac(struct bfa_ioc_s *ioc)
2481{ 2451{
@@ -2488,18 +2458,6 @@ bfa_ioc_get_mac(struct bfa_ioc_s *ioc)
2488 return ioc->attr->mac; 2458 return ioc->attr->mac;
2489} 2459}
2490 2460
2491wwn_t
2492bfa_ioc_get_mfg_pwwn(struct bfa_ioc_s *ioc)
2493{
2494 return ioc->attr->mfg_pwwn;
2495}
2496
2497wwn_t
2498bfa_ioc_get_mfg_nwwn(struct bfa_ioc_s *ioc)
2499{
2500 return ioc->attr->mfg_nwwn;
2501}
2502
2503mac_t 2461mac_t
2504bfa_ioc_get_mfg_mac(struct bfa_ioc_s *ioc) 2462bfa_ioc_get_mfg_mac(struct bfa_ioc_s *ioc)
2505{ 2463{
@@ -2541,14 +2499,6 @@ bfa_ioc_debug_fwsave(struct bfa_ioc_s *ioc, void *trcdata, int *trclen)
2541 return BFA_STATUS_OK; 2499 return BFA_STATUS_OK;
2542} 2500}
2543 2501
2544/*
2545 * Clear saved firmware trace
2546 */
2547void
2548bfa_ioc_debug_fwsave_clear(struct bfa_ioc_s *ioc)
2549{
2550 ioc->dbg_fwsave_once = BFA_TRUE;
2551}
2552 2502
2553/* 2503/*
2554 * Retrieve saved firmware trace from a prior IOC failure. 2504 * Retrieve saved firmware trace from a prior IOC failure.
@@ -2701,13 +2651,16 @@ bfa_ioc_fw_stats_clear(struct bfa_ioc_s *ioc)
2701 * Save firmware trace if configured. 2651 * Save firmware trace if configured.
2702 */ 2652 */
2703static void 2653static void
2704bfa_ioc_debug_save(struct bfa_ioc_s *ioc) 2654bfa_ioc_debug_save_ftrc(struct bfa_ioc_s *ioc)
2705{ 2655{
2706 int tlen; 2656 int tlen;
2707 2657
2708 if (ioc->dbg_fwsave_len) { 2658 if (ioc->dbg_fwsave_once) {
2709 tlen = ioc->dbg_fwsave_len; 2659 ioc->dbg_fwsave_once = BFA_FALSE;
2710 bfa_ioc_debug_fwtrc(ioc, ioc->dbg_fwsave, &tlen); 2660 if (ioc->dbg_fwsave_len) {
2661 tlen = ioc->dbg_fwsave_len;
2662 bfa_ioc_debug_fwtrc(ioc, ioc->dbg_fwsave, &tlen);
2663 }
2711 } 2664 }
2712} 2665}
2713 2666
@@ -2717,11 +2670,6 @@ bfa_ioc_debug_save(struct bfa_ioc_s *ioc)
2717static void 2670static void
2718bfa_ioc_recover(struct bfa_ioc_s *ioc) 2671bfa_ioc_recover(struct bfa_ioc_s *ioc)
2719{ 2672{
2720 if (ioc->dbg_fwsave_once) {
2721 ioc->dbg_fwsave_once = BFA_FALSE;
2722 bfa_ioc_debug_save(ioc);
2723 }
2724
2725 bfa_ioc_stats(ioc, ioc_hbfails); 2673 bfa_ioc_stats(ioc, ioc_hbfails);
2726 bfa_fsm_send_event(ioc, IOC_E_HBFAIL); 2674 bfa_fsm_send_event(ioc, IOC_E_HBFAIL);
2727} 2675}
@@ -2734,45 +2682,8 @@ bfa_ioc_check_attr_wwns(struct bfa_ioc_s *ioc)
2734} 2682}
2735 2683
2736/* 2684/*
2737 * hal_iocpf_pvt BFA IOC PF private functions 2685 * BFA IOC PF private functions
2738 */ 2686 */
2739
2740static void
2741bfa_iocpf_enable(struct bfa_ioc_s *ioc)
2742{
2743 bfa_fsm_send_event(&ioc->iocpf, IOCPF_E_ENABLE);
2744}
2745
2746static void
2747bfa_iocpf_disable(struct bfa_ioc_s *ioc)
2748{
2749 bfa_fsm_send_event(&ioc->iocpf, IOCPF_E_DISABLE);
2750}
2751
2752static void
2753bfa_iocpf_fail(struct bfa_ioc_s *ioc)
2754{
2755 bfa_fsm_send_event(&ioc->iocpf, IOCPF_E_FAIL);
2756}
2757
2758static void
2759bfa_iocpf_initfail(struct bfa_ioc_s *ioc)
2760{
2761 bfa_fsm_send_event(&ioc->iocpf, IOCPF_E_INITFAIL);
2762}
2763
2764static void
2765bfa_iocpf_getattrfail(struct bfa_ioc_s *ioc)
2766{
2767 bfa_fsm_send_event(&ioc->iocpf, IOCPF_E_GETATTRFAIL);
2768}
2769
2770static void
2771bfa_iocpf_stop(struct bfa_ioc_s *ioc)
2772{
2773 bfa_fsm_send_event(&ioc->iocpf, IOCPF_E_STOP);
2774}
2775
2776static void 2687static void
2777bfa_iocpf_timeout(void *ioc_arg) 2688bfa_iocpf_timeout(void *ioc_arg)
2778{ 2689{
@@ -2794,12 +2705,6 @@ bfa_iocpf_sem_timeout(void *ioc_arg)
2794 * bfa timer function 2705 * bfa timer function
2795 */ 2706 */
2796void 2707void
2797bfa_timer_init(struct bfa_timer_mod_s *mod)
2798{
2799 INIT_LIST_HEAD(&mod->timer_q);
2800}
2801
2802void
2803bfa_timer_beat(struct bfa_timer_mod_s *mod) 2708bfa_timer_beat(struct bfa_timer_mod_s *mod)
2804{ 2709{
2805 struct list_head *qh = &mod->timer_q; 2710 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,
2843 void (*timercb) (void *), void *arg, unsigned int timeout) 2748 void (*timercb) (void *), void *arg, unsigned int timeout)
2844{ 2749{
2845 2750
2846 bfa_assert(timercb != NULL); 2751 WARN_ON(timercb == NULL);
2847 bfa_assert(!bfa_q_is_on_q(&mod->timer_q, timer)); 2752 WARN_ON(bfa_q_is_on_q(&mod->timer_q, timer));
2848 2753
2849 timer->timeout = timeout; 2754 timer->timeout = timeout;
2850 timer->timercb = timercb; 2755 timer->timercb = timercb;
@@ -2859,7 +2764,7 @@ bfa_timer_begin(struct bfa_timer_mod_s *mod, struct bfa_timer_s *timer,
2859void 2764void
2860bfa_timer_stop(struct bfa_timer_s *timer) 2765bfa_timer_stop(struct bfa_timer_s *timer)
2861{ 2766{
2862 bfa_assert(!list_empty(&timer->qe)); 2767 WARN_ON(list_empty(&timer->qe));
2863 2768
2864 list_del(&timer->qe); 2769 list_del(&timer->qe);
2865} 2770}