35 #define ethport_is_up ethport_can_be_up
69 #define bna_stats_copy(_name, _type) \
71 count = sizeof(struct bfi_enet_stats_ ## _type) / sizeof(u64); \
72 stats_src = (u64 *)&bna->stats.hw_stats_kva->_name ## _stats; \
73 stats_dst = (u64 *)&bna->stats.hw_stats._name ## _stats; \
74 for (i = 0; i < count; i++) \
75 stats_dst[i] = be64_to_cpu(stats_src[i]); \
83 bna_bfi_ethport_enable_aen(
struct bna_ethport *ethport,
88 if (ethport_can_be_up(ethport))
93 bna_bfi_ethport_disable_aen(
struct bna_ethport *ethport,
105 bna_bfi_ethport_admin_rsp(
struct bna_ethport *ethport,
112 switch (admin_req->
enable) {
131 bna_bfi_ethport_lpbk_rsp(
struct bna_ethport *ethport,
138 switch (diag_lb_req->
enable) {
161 bna_bfi_attr_get_rsp(
struct bna_ioceth *ioceth,
170 if (!ioceth->
attr.fw_query_complete) {
176 ioceth->
attr.fw_query_complete =
true;
200 stats_src = (
u64 *)&(bna->
stats.hw_stats_kva->rxf_stats[0]);
204 stats_dst = (
u64 *)&(bna->
stats.hw_stats.rxf_stats[i]);
206 if (rx_enet_mask & ((
u32)(1 << i))) {
210 for (k = 0; k <
count; k++) {
219 stats_dst = (
u64 *)&(bna->
stats.hw_stats.txf_stats[i]);
221 if (tx_enet_mask & ((
u32)(1 << i))) {
225 for (k = 0; k <
count; k++) {
237 bna_bfi_ethport_linkup_aen(
struct bna_ethport *ethport,
247 bna_bfi_ethport_linkdown_aen(
struct bna_ethport *ethport,
257 bna_err_handler(
struct bna *bna,
u32 intr_status)
269 bna_err_handler(bna, intr_status);
279 struct bna *bna = (
struct bna *)arg;
333 bna_bfi_ethport_admin_rsp(&bna->
ethport, msghdr);
337 bna_bfi_ethport_lpbk_rsp(&bna->
ethport, msghdr);
341 bna_bfi_pause_set_rsp(&bna->
enet, msghdr);
345 bna_bfi_attr_get_rsp(&bna->
ioceth, msghdr);
349 bna_bfi_stats_get_rsp(bna, msghdr);
357 bna_bfi_ethport_linkup_aen(&bna->
ethport, msghdr);
361 bna_bfi_ethport_linkdown_aen(&bna->
ethport, msghdr);
365 bna_bfi_ethport_enable_aen(&bna->
ethport, msghdr);
369 bna_bfi_ethport_disable_aen(&bna->
ethport, msghdr);
383 #define call_ethport_stop_cbfn(_ethport) \
385 if ((_ethport)->stop_cbfn) { \
386 void (*cbfn)(struct bna_enet *); \
387 cbfn = (_ethport)->stop_cbfn; \
388 (_ethport)->stop_cbfn = NULL; \
389 cbfn(&(_ethport)->bna->enet); \
393 #define call_ethport_adminup_cbfn(ethport, status) \
395 if ((ethport)->adminup_cbfn) { \
396 void (*cbfn)(struct bnad *, enum bna_cb_status); \
397 cbfn = (ethport)->adminup_cbfn; \
398 (ethport)->adminup_cbfn = NULL; \
399 cbfn((ethport)->bna->bnad, status); \
404 bna_bfi_ethport_admin_up(
struct bna_ethport *ethport)
411 admin_up_req->
mh.num_entries =
htons(
421 bna_bfi_ethport_admin_down(
struct bna_ethport *ethport)
428 admin_down_req->
mh.num_entries =
htons(
438 bna_bfi_ethport_lpbk_up(
struct bna_ethport *ethport)
445 lpbk_up_req->
mh.num_entries =
htons(
447 lpbk_up_req->
mode = (ethport->
bna->enet.type ==
459 bna_bfi_ethport_lpbk_down(
struct bna_ethport *ethport)
466 lpbk_down_req->
mh.num_entries =
htons(
479 bna_bfi_ethport_admin_up(ethport);
481 bna_bfi_ethport_lpbk_up(ethport);
488 bna_bfi_ethport_admin_down(ethport);
490 bna_bfi_ethport_lpbk_down(ethport);
507 bna_ethport_sm_stopped_entry(
struct bna_ethport *ethport)
513 bna_ethport_sm_stopped(
struct bna_ethport *ethport,
540 bna_ethport_sm_down_entry(
struct bna_ethport *ethport)
559 bna_bfi_ethport_up(ethport);
568 bna_ethport_sm_up_resp_wait_entry(
struct bna_ethport *ethport)
573 bna_ethport_sm_up_resp_wait(
struct bna_ethport *ethport,
603 bna_bfi_ethport_up(ethport);
612 bna_ethport_sm_down_resp_wait_entry(
struct bna_ethport *ethport)
622 bna_ethport_sm_down_resp_wait(
struct bna_ethport *ethport,
640 bna_bfi_ethport_down(ethport);
654 bna_ethport_sm_up_entry(
struct bna_ethport *ethport)
665 bna_bfi_ethport_down(ethport);
674 bna_bfi_ethport_down(ethport);
683 bna_ethport_sm_last_resp_wait_entry(
struct bna_ethport *ethport)
688 bna_ethport_sm_last_resp_wait(
struct bna_ethport *ethport,
706 bna_bfi_ethport_down(ethport);
720 bna_ethport_init(
struct bna_ethport *ethport,
struct bna *bna)
760 ethport->
stop_cbfn = bna_enet_cb_ethport_stopped;
786 if (ethport_can_be_up(ethport))
808 #define bna_enet_chld_start(enet) \
810 enum bna_tx_type tx_type = \
811 ((enet)->type == BNA_ENET_T_REGULAR) ? \
812 BNA_TX_T_REGULAR : BNA_TX_T_LOOPBACK; \
813 enum bna_rx_type rx_type = \
814 ((enet)->type == BNA_ENET_T_REGULAR) ? \
815 BNA_RX_T_REGULAR : BNA_RX_T_LOOPBACK; \
816 bna_ethport_start(&(enet)->bna->ethport); \
817 bna_tx_mod_start(&(enet)->bna->tx_mod, tx_type); \
818 bna_rx_mod_start(&(enet)->bna->rx_mod, rx_type); \
821 #define bna_enet_chld_stop(enet) \
823 enum bna_tx_type tx_type = \
824 ((enet)->type == BNA_ENET_T_REGULAR) ? \
825 BNA_TX_T_REGULAR : BNA_TX_T_LOOPBACK; \
826 enum bna_rx_type rx_type = \
827 ((enet)->type == BNA_ENET_T_REGULAR) ? \
828 BNA_RX_T_REGULAR : BNA_RX_T_LOOPBACK; \
829 bfa_wc_init(&(enet)->chld_stop_wc, bna_enet_cb_chld_stopped, (enet));\
830 bfa_wc_up(&(enet)->chld_stop_wc); \
831 bna_ethport_stop(&(enet)->bna->ethport); \
832 bfa_wc_up(&(enet)->chld_stop_wc); \
833 bna_tx_mod_stop(&(enet)->bna->tx_mod, tx_type); \
834 bfa_wc_up(&(enet)->chld_stop_wc); \
835 bna_rx_mod_stop(&(enet)->bna->rx_mod, rx_type); \
836 bfa_wc_wait(&(enet)->chld_stop_wc); \
839 #define bna_enet_chld_fail(enet) \
841 bna_ethport_fail(&(enet)->bna->ethport); \
842 bna_tx_mod_fail(&(enet)->bna->tx_mod); \
843 bna_rx_mod_fail(&(enet)->bna->rx_mod); \
846 #define bna_enet_rx_start(enet) \
848 enum bna_rx_type rx_type = \
849 ((enet)->type == BNA_ENET_T_REGULAR) ? \
850 BNA_RX_T_REGULAR : BNA_RX_T_LOOPBACK; \
851 bna_rx_mod_start(&(enet)->bna->rx_mod, rx_type); \
854 #define bna_enet_rx_stop(enet) \
856 enum bna_rx_type rx_type = \
857 ((enet)->type == BNA_ENET_T_REGULAR) ? \
858 BNA_RX_T_REGULAR : BNA_RX_T_LOOPBACK; \
859 bfa_wc_init(&(enet)->chld_stop_wc, bna_enet_cb_chld_stopped, (enet));\
860 bfa_wc_up(&(enet)->chld_stop_wc); \
861 bna_rx_mod_stop(&(enet)->bna->rx_mod, rx_type); \
862 bfa_wc_wait(&(enet)->chld_stop_wc); \
865 #define call_enet_stop_cbfn(enet) \
867 if ((enet)->stop_cbfn) { \
868 void (*cbfn)(void *); \
870 cbfn = (enet)->stop_cbfn; \
871 cbarg = (enet)->stop_cbarg; \
872 (enet)->stop_cbfn = NULL; \
873 (enet)->stop_cbarg = NULL; \
878 #define call_enet_pause_cbfn(enet) \
880 if ((enet)->pause_cbfn) { \
881 void (*cbfn)(struct bnad *); \
882 cbfn = (enet)->pause_cbfn; \
883 (enet)->pause_cbfn = NULL; \
884 cbfn((enet)->bna->bnad); \
888 #define call_enet_mtu_cbfn(enet) \
890 if ((enet)->mtu_cbfn) { \
891 void (*cbfn)(struct bnad *); \
892 cbfn = (enet)->mtu_cbfn; \
893 (enet)->mtu_cbfn = NULL; \
894 cbfn((enet)->bna->bnad); \
898 static void bna_enet_cb_chld_stopped(
void *arg);
962 bna_enet_sm_pause_init_wait_entry(
struct bna_enet *enet)
964 bna_bfi_pause_set(enet);
968 bna_enet_sm_pause_init_wait(
struct bna_enet *enet,
993 bna_bfi_pause_set(enet);
1006 bna_enet_sm_last_resp_wait_entry(
struct bna_enet *enet)
1012 bna_enet_sm_last_resp_wait(
struct bna_enet *enet,
1027 bna_enet_sm_started_entry(
struct bna_enet *enet)
1038 bna_enet_sm_started(
struct bna_enet *enet,
1053 bna_bfi_pause_set(enet);
1067 bna_enet_sm_cfg_wait_entry(
struct bna_enet *enet)
1072 bna_enet_sm_cfg_wait(
struct bna_enet *enet,
1103 bna_bfi_pause_set(enet);
1118 bna_enet_sm_cfg_stop_wait_entry(
struct bna_enet *enet)
1125 bna_enet_sm_cfg_stop_wait(
struct bna_enet *enet,
1145 bna_enet_sm_chld_stop_wait_entry(
struct bna_enet *enet)
1151 bna_enet_sm_chld_stop_wait(
struct bna_enet *enet,
1170 bna_bfi_pause_set(
struct bna_enet *enet)
1176 pause_req->
mh.num_entries =
htons(
1187 bna_enet_cb_chld_stopped(
void *arg)
1195 bna_enet_init(
struct bna_enet *enet,
struct bna *bna)
1213 bna_enet_uninit(
struct bna_enet *enet)
1221 bna_enet_start(
struct bna_enet *enet)
1229 bna_ioceth_cb_enet_stopped(
void *arg)
1237 bna_enet_stop(
struct bna_enet *enet)
1239 enet->
stop_cbfn = bna_ioceth_cb_enet_stopped;
1247 bna_enet_fail(
struct bna_enet *enet)
1285 void (*cbfn)(
void *))
1288 (*cbfn)(enet->
bna->bnad);
1303 void (*cbfn)(
struct bnad *))
1314 void (*cbfn)(
struct bnad *))
1331 #define enable_mbox_intr(_ioceth) \
1334 bna_intr_status_get((_ioceth)->bna, intr_status); \
1335 bnad_cb_mbox_intr_enable((_ioceth)->bna->bnad); \
1336 bna_mbox_intr_enable((_ioceth)->bna); \
1339 #define disable_mbox_intr(_ioceth) \
1341 bna_mbox_intr_disable((_ioceth)->bna); \
1342 bnad_cb_mbox_intr_disable((_ioceth)->bna->bnad); \
1345 #define call_ioceth_stop_cbfn(_ioceth) \
1347 if ((_ioceth)->stop_cbfn) { \
1348 void (*cbfn)(struct bnad *); \
1349 struct bnad *cbarg; \
1350 cbfn = (_ioceth)->stop_cbfn; \
1351 cbarg = (_ioceth)->stop_cbarg; \
1352 (_ioceth)->stop_cbfn = NULL; \
1353 (_ioceth)->stop_cbarg = NULL; \
1358 #define bna_stats_mod_uninit(_stats_mod) \
1362 #define bna_stats_mod_start(_stats_mod) \
1364 (_stats_mod)->ioc_ready = true; \
1367 #define bna_stats_mod_stop(_stats_mod) \
1369 (_stats_mod)->ioc_ready = false; \
1372 #define bna_stats_mod_fail(_stats_mod) \
1374 (_stats_mod)->ioc_ready = false; \
1375 (_stats_mod)->stats_get_busy = false; \
1376 (_stats_mod)->stats_clr_busy = false; \
1379 static void bna_bfi_attr_get(
struct bna_ioceth *ioceth);
1399 bna_ioceth_sm_stopped_entry(
struct bna_ioceth *ioceth)
1405 bna_ioceth_sm_stopped(
struct bna_ioceth *ioceth,
1433 bna_ioceth_sm_ioc_ready_wait_entry(
struct bna_ioceth *ioceth)
1442 bna_ioceth_sm_ioc_ready_wait(
struct bna_ioceth *ioceth,
1470 bna_ioceth_sm_enet_attr_wait_entry(
struct bna_ioceth *ioceth)
1472 bna_bfi_attr_get(ioceth);
1476 bna_ioceth_sm_enet_attr_wait(
struct bna_ioceth *ioceth,
1499 bna_ioceth_sm_ready_entry(
struct bna_ioceth *ioceth)
1501 bna_enet_start(&ioceth->
bna->enet);
1516 bna_enet_fail(&ioceth->
bna->enet);
1527 bna_ioceth_sm_last_resp_wait_entry(
struct bna_ioceth *ioceth)
1532 bna_ioceth_sm_last_resp_wait(
struct bna_ioceth *ioceth,
1553 bna_ioceth_sm_enet_stop_wait_entry(
struct bna_ioceth *ioceth)
1556 bna_enet_stop(&ioceth->
bna->enet);
1560 bna_ioceth_sm_enet_stop_wait(
struct bna_ioceth *ioceth,
1567 bna_enet_fail(&ioceth->
bna->enet);
1583 bna_ioceth_sm_ioc_disable_wait_entry(
struct bna_ioceth *ioceth)
1588 bna_ioceth_sm_ioc_disable_wait(
struct bna_ioceth *ioceth,
1608 bna_ioceth_sm_failed_entry(
struct bna_ioceth *ioceth)
1614 bna_ioceth_sm_failed(
struct bna_ioceth *ioceth,
1643 attr_req->
mh.num_entries =
htons(
1664 bna_cb_ioceth_disable(
void *arg)
1672 bna_cb_ioceth_hbfail(
void *arg)
1680 bna_cb_ioceth_reset(
void *arg)
1688 bna_cb_ioceth_enable,
1689 bna_cb_ioceth_disable,
1690 bna_cb_ioceth_hbfail,
1694 static void bna_attr_init(
struct bna_ioceth *ioceth)
1701 ioceth->
attr.fw_query_complete =
false;
1705 bna_ioceth_init(
struct bna_ioceth *ioceth,
struct bna *bna,
1755 bna_attr_init(ioceth);
1795 bna_ucam_mod_init(
struct bna_ucam_mod *ucam_mod,
struct bna *bna,
1803 INIT_LIST_HEAD(&ucam_mod->
free_q);
1804 for (i = 0; i < bna->
ioceth.attr.num_ucmac; i++) {
1809 ucam_mod->
bna = bna;
1821 ucam_mod->bna =
NULL;
1830 mcam_mod->mcmac = (
struct bna_mac *)
1833 INIT_LIST_HEAD(&mcam_mod->free_q);
1834 for (i = 0; i < bna->ioceth.attr.num_mcmac; i++) {
1842 INIT_LIST_HEAD(&mcam_mod->free_handle_q);
1843 for (i = 0; i < bna->ioceth.attr.num_mcmac; i++) {
1846 &mcam_mod->free_handle_q);
1849 mcam_mod->bna = bna;
1864 mcam_mod->bna = NULL;
1868 bna_bfi_stats_get(
struct bna *bna)
1872 bna->stats_mod.stats_get_busy =
true;
1876 stats_req->
mh.num_entries =
htons(
1881 stats_req->
host_buffer.
a32.addr_hi = bna->stats.hw_stats_dma.msb;
1882 stats_req->
host_buffer.
a32.addr_lo = bna->stats.hw_stats_dma.lsb;
2002 bna->
stats.hw_stats_dma.msb =
2004 bna->
stats.hw_stats_dma.lsb =
2010 bna_ioceth_init(&bna->
ioceth, bna, res_info);
2012 bna_enet_init(&bna->
enet, bna);
2013 bna_ethport_init(&bna->
ethport, bna);
2023 bna_ucam_mod_init(&bna->
ucam_mod, bna, res_info);
2025 bna_mcam_mod_init(&bna->
mcam_mod, bna, res_info);
2037 bna_mcam_mod_uninit(&bna->
mcam_mod);
2038 bna_ucam_mod_uninit(&bna->
ucam_mod);
2045 bna_ethport_uninit(&bna->
ethport);
2046 bna_enet_uninit(&bna->
enet);
2048 bna_ioceth_uninit(&bna->
ioceth);
2056 if (bna->
ioceth.attr.fw_query_complete &&
2057 (num_txq <= bna->ioceth.
attr.num_txq)) {
2058 bna->
ioceth.attr.num_txq = num_txq;
2068 if (bna->
ioceth.attr.fw_query_complete &&
2069 (num_rxp <= bna->ioceth.
attr.num_rxp)) {
2070 bna->
ioceth.attr.num_rxp = num_rxp;
2082 if (list_empty(&ucam_mod->
free_q))
2101 if (list_empty(&mcam_mod->
free_q))
2147 bna_bfi_stats_get(bna);