27 #define bfa_ioc_firmware_lock(__ioc) \
28 ((__ioc)->ioc_hwif->ioc_firmware_lock(__ioc))
29 #define bfa_ioc_firmware_unlock(__ioc) \
30 ((__ioc)->ioc_hwif->ioc_firmware_unlock(__ioc))
31 #define bfa_ioc_reg_init(__ioc) ((__ioc)->ioc_hwif->ioc_reg_init(__ioc))
32 #define bfa_ioc_map_port(__ioc) ((__ioc)->ioc_hwif->ioc_map_port(__ioc))
33 #define bfa_ioc_notify_fail(__ioc) \
34 ((__ioc)->ioc_hwif->ioc_notify_fail(__ioc))
35 #define bfa_ioc_sync_start(__ioc) \
36 ((__ioc)->ioc_hwif->ioc_sync_start(__ioc))
37 #define bfa_ioc_sync_join(__ioc) \
38 ((__ioc)->ioc_hwif->ioc_sync_join(__ioc))
39 #define bfa_ioc_sync_leave(__ioc) \
40 ((__ioc)->ioc_hwif->ioc_sync_leave(__ioc))
41 #define bfa_ioc_sync_ack(__ioc) \
42 ((__ioc)->ioc_hwif->ioc_sync_ack(__ioc))
43 #define bfa_ioc_sync_complete(__ioc) \
44 ((__ioc)->ioc_hwif->ioc_sync_complete(__ioc))
46 #define bfa_ioc_mbox_cmd_pending(__ioc) \
47 (!list_empty(&((__ioc)->mbox_mod.cmd_q)) || \
48 readl((__ioc)->ioc_regs.hfn_mbox_cmd))
50 static bool bfa_nw_auto_recover =
true;
55 static void bfa_ioc_hw_sem_init(
struct bfa_ioc *
ioc);
56 static void bfa_ioc_hw_sem_get(
struct bfa_ioc *
ioc);
57 static void bfa_ioc_hw_sem_get_cancel(
struct bfa_ioc *
ioc);
59 static void bfa_ioc_poll_fwinit(
struct bfa_ioc *
ioc);
60 static void bfa_ioc_send_enable(
struct bfa_ioc *
ioc);
61 static void bfa_ioc_send_disable(
struct bfa_ioc *
ioc);
62 static void bfa_ioc_send_getattr(
struct bfa_ioc *
ioc);
63 static void bfa_ioc_hb_monitor(
struct bfa_ioc *
ioc);
64 static void bfa_ioc_hb_stop(
struct bfa_ioc *
ioc);
66 static void bfa_ioc_mbox_poll(
struct bfa_ioc *
ioc);
67 static void bfa_ioc_mbox_flush(
struct bfa_ioc *
ioc);
68 static void bfa_ioc_recover(
struct bfa_ioc *
ioc);
70 static void bfa_ioc_disable_comp(
struct bfa_ioc *
ioc);
71 static void bfa_ioc_lpu_stop(
struct bfa_ioc *
ioc);
72 static void bfa_nw_ioc_debug_save_ftrc(
struct bfa_ioc *
ioc);
73 static void bfa_ioc_fail_notify(
struct bfa_ioc *
ioc);
74 static void bfa_ioc_pf_enabled(
struct bfa_ioc *
ioc);
75 static void bfa_ioc_pf_disabled(
struct bfa_ioc *
ioc);
76 static void bfa_ioc_pf_failed(
struct bfa_ioc *
ioc);
77 static void bfa_ioc_pf_hwfailed(
struct bfa_ioc *
ioc);
78 static void bfa_ioc_pf_fwmismatch(
struct bfa_ioc *
ioc);
82 static void bfa_ioc_get_adapter_serial_num(
struct bfa_ioc *
ioc,
84 static void bfa_ioc_get_adapter_fw_ver(
struct bfa_ioc *
ioc,
86 static void bfa_ioc_get_pci_chip_rev(
struct bfa_ioc *
ioc,
88 static void bfa_ioc_get_adapter_optrom_ver(
struct bfa_ioc *
ioc,
90 static void bfa_ioc_get_adapter_manufacturer(
struct bfa_ioc *
ioc,
92 static void bfa_ioc_get_adapter_model(
struct bfa_ioc *
ioc,
char *model);
138 static void bfa_iocpf_enable(
struct bfa_ioc *
ioc);
139 static void bfa_iocpf_disable(
struct bfa_ioc *
ioc);
140 static void bfa_iocpf_fail(
struct bfa_ioc *
ioc);
141 static void bfa_iocpf_initfail(
struct bfa_ioc *
ioc);
142 static void bfa_iocpf_getattrfail(
struct bfa_ioc *
ioc);
143 static void bfa_iocpf_stop(
struct bfa_ioc *
ioc);
232 bfa_ioc_sm_reset_entry(
struct bfa_ioc *ioc)
247 bfa_ioc_disable_comp(ioc);
260 bfa_ioc_sm_enabling_entry(
struct bfa_ioc *ioc)
262 bfa_iocpf_enable(ioc);
282 bfa_iocpf_initfail(ioc);
309 bfa_ioc_sm_getattr_entry(
struct bfa_ioc *ioc)
313 bfa_ioc_send_getattr(ioc);
334 bfa_iocpf_getattrfail(ioc);
351 bfa_ioc_sm_op_entry(
struct bfa_ioc *ioc)
355 bfa_ioc_hb_monitor(ioc);
366 bfa_ioc_hb_stop(ioc);
372 bfa_ioc_hb_stop(ioc);
375 if (ioc->
iocpf.auto_recover)
380 bfa_ioc_fail_notify(ioc);
392 bfa_ioc_sm_disabling_entry(
struct bfa_ioc *ioc)
394 bfa_iocpf_disable(ioc);
417 bfa_ioc_disable_comp(ioc);
427 bfa_ioc_sm_disabled_entry(
struct bfa_ioc *ioc)
429 bfa_ioc_disable_comp(ioc);
441 ioc->
cbfn->disable_cbfn(ioc->
bfa);
455 bfa_ioc_sm_fail_retry_entry(
struct bfa_ioc *ioc)
476 bfa_iocpf_initfail(ioc);
502 bfa_ioc_sm_fail_entry(
struct bfa_ioc *ioc)
534 bfa_ioc_sm_hwfail_entry(
struct bfa_ioc *ioc)
549 ioc->
cbfn->disable_cbfn(ioc->
bfa);
565 bfa_iocpf_sm_reset_entry(
struct bfa_iocpf *iocpf)
590 bfa_iocpf_sm_fwcheck_entry(
struct bfa_iocpf *iocpf)
592 bfa_ioc_hw_sem_init(iocpf->
ioc);
593 bfa_ioc_hw_sem_get(iocpf->
ioc);
622 bfa_ioc_pf_hwfailed(ioc);
626 bfa_ioc_hw_sem_get_cancel(ioc);
628 bfa_ioc_pf_disabled(ioc);
632 bfa_ioc_hw_sem_get_cancel(ioc);
643 bfa_iocpf_sm_mismatch_entry(
struct bfa_iocpf *iocpf)
647 bfa_ioc_pf_fwmismatch(iocpf->
ioc);
668 bfa_ioc_pf_disabled(ioc);
683 bfa_iocpf_sm_semwait_entry(
struct bfa_iocpf *iocpf)
685 bfa_ioc_hw_sem_get(iocpf->
ioc);
708 bfa_ioc_pf_hwfailed(ioc);
712 bfa_ioc_hw_sem_get_cancel(ioc);
722 bfa_iocpf_sm_hwinit_entry(
struct bfa_iocpf *iocpf)
725 bfa_ioc_reset(iocpf->
ioc,
false);
743 bfa_ioc_pf_failed(ioc);
760 bfa_iocpf_sm_enabling_entry(
struct bfa_iocpf *iocpf)
767 iocpf->
ioc->cbfn->reset_cbfn(iocpf->
ioc->bfa);
768 bfa_ioc_send_enable(iocpf->
ioc);
794 bfa_ioc_pf_failed(ioc);
810 bfa_iocpf_sm_ready_entry(
struct bfa_iocpf *iocpf)
812 bfa_ioc_pf_enabled(iocpf->
ioc);
837 bfa_iocpf_sm_disabling_entry(
struct bfa_iocpf *iocpf)
841 bfa_ioc_send_disable(iocpf->
ioc);
876 bfa_iocpf_sm_disabling_sync_entry(
struct bfa_iocpf *iocpf)
878 bfa_ioc_hw_sem_get(iocpf->
ioc);
896 bfa_ioc_pf_hwfailed(ioc);
909 bfa_iocpf_sm_disabled_entry(
struct bfa_iocpf *iocpf)
911 bfa_ioc_mbox_flush(iocpf->
ioc);
912 bfa_ioc_pf_disabled(iocpf->
ioc);
936 bfa_iocpf_sm_initfail_sync_entry(
struct bfa_iocpf *iocpf)
938 bfa_nw_ioc_debug_save_ftrc(iocpf->
ioc);
939 bfa_ioc_hw_sem_get(iocpf->
ioc);
959 bfa_ioc_pf_hwfailed(ioc);
963 bfa_ioc_hw_sem_get_cancel(ioc);
968 bfa_ioc_hw_sem_get_cancel(ioc);
982 bfa_iocpf_sm_initfail_entry(
struct bfa_iocpf *iocpf)
1008 bfa_iocpf_sm_fail_sync_entry(
struct bfa_iocpf *iocpf)
1013 bfa_ioc_lpu_stop(iocpf->
ioc);
1018 bfa_ioc_mbox_flush(iocpf->
ioc);
1019 bfa_ioc_hw_sem_get(iocpf->
ioc);
1049 bfa_ioc_pf_hwfailed(ioc);
1053 bfa_ioc_hw_sem_get_cancel(ioc);
1066 bfa_iocpf_sm_fail_entry(
struct bfa_iocpf *iocpf)
1100 bfa_ioc_disable_comp(
struct bfa_ioc *ioc)
1102 ioc->
cbfn->disable_cbfn(ioc->
bfa);
1111 #define BFA_SEM_SPINCNT 3000
1113 r32 =
readl(sem_reg);
1118 r32 =
readl(sem_reg);
1136 bfa_ioc_fwver_clear(
struct bfa_ioc *ioc)
1138 u32 pgnum, pgoff, loff = 0;
1147 loff +=
sizeof(
u32);
1153 bfa_ioc_hw_sem_init(
struct bfa_ioc *ioc)
1178 bfa_ioc_fwver_clear(ioc);
1193 bfa_ioc_hw_sem_get(
struct bfa_ioc *ioc)
1222 bfa_ioc_hw_sem_get_cancel(
struct bfa_ioc *ioc)
1229 bfa_ioc_lmem_init(
struct bfa_ioc *ioc)
1233 #define PSS_LMEM_INIT_TIME 10000
1258 BUG_ON(!(pss_ctl & __PSS_LMEM_INIT_DONE));
1265 bfa_ioc_lpu_start(
struct bfa_ioc *ioc)
1279 bfa_ioc_lpu_stop(
struct bfa_ioc *ioc)
1299 u32 *fwsig = (
u32 *) fwhdr;
1301 pgnum = bfa_ioc_smem_pgnum(ioc, loff);
1308 loff +=
sizeof(
u32);
1334 bfa_ioc_fwver_valid(
struct bfa_ioc *ioc,
u32 boot_env)
1342 if (fwhdr.signature != drv_fwhdr->
signature)
1345 if (
swab32(fwhdr.bootenv) != boot_env)
1353 bfa_ioc_msgflush(
struct bfa_ioc *ioc)
1380 false : bfa_ioc_fwver_valid(ioc, boot_env);
1384 bfa_ioc_poll_fwinit(ioc);
1393 bfa_ioc_poll_fwinit(ioc);
1406 bfa_ioc_msgflush(ioc);
1415 bfa_ioc_poll_fwinit(ioc);
1427 bfa_ioc_mbox_send(
struct bfa_ioc *ioc,
void *ioc_msg,
int len)
1429 u32 *msgp = (
u32 *) ioc_msg;
1437 for (i = 0; i < len /
sizeof(
u32); i++)
1452 bfa_ioc_send_enable(
struct bfa_ioc *ioc)
1461 enable_req.tv_sec =
ntohl(tv.tv_sec);
1466 bfa_ioc_send_disable(
struct bfa_ioc *ioc)
1476 bfa_ioc_send_getattr(
struct bfa_ioc *ioc)
1483 bfa_ioc_mbox_send(ioc, &attr_req,
sizeof(attr_req));
1494 bfa_ioc_recover(ioc);
1500 bfa_ioc_mbox_poll(ioc);
1506 bfa_ioc_hb_monitor(
struct bfa_ioc *ioc)
1514 bfa_ioc_hb_stop(
struct bfa_ioc *ioc)
1521 bfa_ioc_download_fw(
struct bfa_ioc *ioc,
u32 boot_type,
1533 pgnum = bfa_ioc_smem_pgnum(ioc, loff);
1548 ((ioc->
ioc_regs.smem_page_start) + (loff)));
1550 loff +=
sizeof(
u32);
1563 writel(bfa_ioc_smem_pgnum(ioc, 0),
1580 bfa_ioc_reset(
struct bfa_ioc *ioc,
bool force)
1582 bfa_ioc_hwinit(ioc, force);
1599 bfa_ioc_getattr_reply(
struct bfa_ioc *ioc)
1612 bfa_ioc_mbox_attach(
struct bfa_ioc *ioc)
1617 INIT_LIST_HEAD(&mod->
cmd_q);
1626 bfa_ioc_mbox_poll(
struct bfa_ioc *ioc)
1637 if (list_empty(&mod->
cmd_q))
1651 bfa_ioc_mbox_send(ioc, cmd->
msg,
sizeof(cmd->
msg));
1666 bfa_ioc_mbox_flush(
struct bfa_ioc *ioc)
1671 while (!list_empty(&mod->
cmd_q))
1684 bfa_nw_ioc_smem_read(
struct bfa_ioc *ioc,
void *tbuf,
u32 soff,
u32 sz)
1686 u32 pgnum, loff, r32;
1701 len = sz/
sizeof(
u32);
1702 for (i = 0; i < len; i++) {
1705 loff +=
sizeof(
u32);
1739 status = bfa_nw_ioc_smem_read(ioc, trcdata, loff, tlen);
1746 bfa_nw_ioc_debug_save_ftrc(
struct bfa_ioc *ioc)
1778 bfa_ioc_fail_notify(
struct bfa_ioc *ioc)
1783 ioc->
cbfn->hbfail_cbfn(ioc->
bfa);
1785 bfa_nw_ioc_debug_save_ftrc(ioc);
1790 bfa_ioc_pf_enabled(
struct bfa_ioc *ioc)
1796 bfa_ioc_pf_disabled(
struct bfa_ioc *ioc)
1802 bfa_ioc_pf_failed(
struct bfa_ioc *ioc)
1808 bfa_ioc_pf_hwfailed(
struct bfa_ioc *ioc)
1814 bfa_ioc_pf_fwmismatch(
struct bfa_ioc *ioc)
1824 bfa_ioc_pll_init(
struct bfa_ioc *ioc)
1836 bfa_ioc_lmem_init(ioc);
1869 bfa_ioc_msgflush(ioc);
1870 bfa_ioc_download_fw(ioc, boot_type, boot_env);
1871 bfa_ioc_lpu_start(ioc);
1878 bfa_nw_auto_recover = auto_recover;
1882 bfa_ioc_msgget(
struct bfa_ioc *ioc,
void *mbmsg)
1921 switch (msg->
mh.msg_id) {
1926 bfa_ioc_enable_reply(ioc,
1936 bfa_ioc_getattr_reply(ioc);
1958 ioc->
iocpf.ioc = ioc;
1960 bfa_ioc_mbox_attach(ioc);
2095 bfa_ioc_smem_pgnum(
struct bfa_ioc *ioc,
u32 fmaddr)
2132 if (!list_empty(&mod->
cmd_q)) {
2149 bfa_ioc_mbox_send(ioc, cmd->
msg,
sizeof(cmd->
msg));
2162 if (bfa_ioc_msgget(ioc, &m)) {
2166 mc = m.
mh.msg_class;
2168 bfa_ioc_isr(ioc, &m);
2183 bfa_ioc_mbox_poll(ioc);
2219 #define BFA_MFG_NAME "Brocade"
2221 bfa_ioc_get_adapter_attr(
struct bfa_ioc *ioc,
2226 ioc_attr = ioc->
attr;
2228 bfa_ioc_get_adapter_serial_num(ioc, ad_attr->
serial_num);
2229 bfa_ioc_get_adapter_fw_ver(ioc, ad_attr->
fw_ver);
2230 bfa_ioc_get_adapter_optrom_ver(ioc, ad_attr->
optrom_ver);
2231 bfa_ioc_get_adapter_manufacturer(ioc, ad_attr->
manufacturer);
2238 bfa_ioc_get_adapter_model(ioc, ad_attr->
model);
2240 bfa_ioc_get_adapter_model(ioc, ad_attr->
model_descr);
2250 ad_attr->
pwwn = bfa_ioc_get_pwwn(ioc);
2258 bfa_ioc_get_pci_chip_rev(ioc, ad_attr->
hw_ver);
2262 bfa_ioc_get_type(
struct bfa_ioc *ioc)
2278 (
void *)ioc->
attr->brcd_serialnum,
2283 bfa_ioc_get_adapter_fw_ver(
struct bfa_ioc *ioc,
char *fw_ver)
2290 bfa_ioc_get_pci_chip_rev(
struct bfa_ioc *ioc,
char *chip_rev)
2300 chip_rev[4] = ioc->
attr->asic_rev;
2305 bfa_ioc_get_adapter_optrom_ver(
struct bfa_ioc *ioc,
char *optrom_ver)
2308 memcpy(optrom_ver, ioc->
attr->optrom_version,
2320 bfa_ioc_get_adapter_model(
struct bfa_ioc *ioc,
char *model)
2327 ioc_attr = ioc->
attr;
2334 bfa_ioc_get_state(
struct bfa_ioc *ioc)
2342 iocpf_st = bfa_sm_to_state(iocpf_sm_table, ioc->
iocpf.fsm);
2377 ioc_attr->
state = bfa_ioc_get_state(ioc);
2384 ioc_attr->
ioc_type = bfa_ioc_get_type(ioc);
2386 bfa_ioc_get_adapter_attr(ioc, &ioc_attr->
adapter_attr);
2390 bfa_ioc_get_pci_chip_rev(ioc, ioc_attr->
pci_attr.chip_rev);
2395 bfa_ioc_get_pwwn(
struct bfa_ioc *ioc)
2397 return ioc->
attr->pwwn;
2403 return ioc->
attr->mac;
2408 bfa_ioc_recover(
struct bfa_ioc *ioc)
2410 pr_crit(
"Heart Beat of IOC has failed\n");
2419 bfa_iocpf_enable(
struct bfa_ioc *ioc)
2425 bfa_iocpf_disable(
struct bfa_ioc *ioc)
2431 bfa_iocpf_fail(
struct bfa_ioc *ioc)
2437 bfa_iocpf_initfail(
struct bfa_ioc *ioc)
2443 bfa_iocpf_getattrfail(
struct bfa_ioc *ioc)
2449 bfa_iocpf_stop(
struct bfa_ioc *ioc)
2460 iocpf_st = bfa_sm_to_state(iocpf_sm_table, ioc->
iocpf.fsm);
2463 bfa_ioc_poll_fwinit(ioc);
2473 bfa_ioc_hw_sem_get(ioc);
2477 bfa_ioc_poll_fwinit(
struct bfa_ioc *ioc)
2504 #define BFA_FLASH_SEG_SZ 2048
2505 #define BFA_FLASH_DMA_BUF_SZ \
2506 roundup(0x010000 + sizeof(struct bfa_mfg_block), BFA_FLASH_SEG_SZ)
2539 bfa_flash_write_send(
struct bfa_flash *flash)
2571 bfa_flash_read_send(
void *cbarg)
2597 bfa_flash_intr(
void *flasharg,
struct bfi_mbmsg *msg)
2615 switch (msg->
mh.msg_id) {
2626 for (i = 0; i < attr->
npart; i++) {
2627 attr->
part[
i].part_type =
2629 attr->
part[
i].part_instance =
2631 attr->
part[
i].part_off =
2633 attr->
part[
i].part_size =
2635 attr->
part[
i].part_len =
2637 attr->
part[
i].part_status =
2642 bfa_flash_cb(flash);
2648 bfa_flash_cb(flash);
2650 bfa_flash_write_send(flash);
2656 bfa_flash_cb(flash);
2665 bfa_flash_cb(flash);
2667 bfa_flash_read_send(flash);
2750 flash->
cbarg = cbarg;
2751 flash->
ubuf = (
u8 *) attr;
2786 if (!len || (len & 0x03))
2797 flash->
cbarg = cbarg;
2805 bfa_flash_write_send(flash);
2835 if (!len || (len & 0x03))
2843 flash->
cbarg = cbarg;
2851 bfa_flash_read_send(flash);