Lines Matching full:adapter
64 /* Workqueue used by all functions for defering cmd calls to the adapter */
144 static void be_queue_free(struct be_adapter *adapter, struct be_queue_info *q) in be_queue_free() argument
149 dma_free_coherent(&adapter->pdev->dev, mem->size, mem->va, in be_queue_free()
155 static int be_queue_alloc(struct be_adapter *adapter, struct be_queue_info *q, in be_queue_alloc() argument
164 mem->va = dma_alloc_coherent(&adapter->pdev->dev, mem->size, in be_queue_alloc()
171 static void be_reg_intr_set(struct be_adapter *adapter, bool enable) in be_reg_intr_set() argument
175 pci_read_config_dword(adapter->pdev, PCICFG_MEMBAR_CTRL_INT_CTRL_OFFSET, in be_reg_intr_set()
186 pci_write_config_dword(adapter->pdev, in be_reg_intr_set()
190 static void be_intr_set(struct be_adapter *adapter, bool enable) in be_intr_set() argument
195 if (lancer_chip(adapter)) in be_intr_set()
198 if (be_check_error(adapter, BE_ERROR_EEH)) in be_intr_set()
201 status = be_cmd_intr_set(adapter, enable); in be_intr_set()
203 be_reg_intr_set(adapter, enable); in be_intr_set()
206 static void be_rxq_notify(struct be_adapter *adapter, u16 qid, u16 posted) in be_rxq_notify() argument
210 if (be_check_error(adapter, BE_ERROR_HW)) in be_rxq_notify()
217 iowrite32(val, adapter->db + DB_RQ_OFFSET); in be_rxq_notify()
220 static void be_txq_notify(struct be_adapter *adapter, struct be_tx_obj *txo, in be_txq_notify() argument
225 if (be_check_error(adapter, BE_ERROR_HW)) in be_txq_notify()
232 iowrite32(val, adapter->db + txo->db_offset); in be_txq_notify()
235 static void be_eq_notify(struct be_adapter *adapter, u16 qid, in be_eq_notify() argument
244 if (be_check_error(adapter, BE_ERROR_HW)) in be_eq_notify()
254 iowrite32(val, adapter->db + DB_EQ_OFFSET); in be_eq_notify()
257 void be_cq_notify(struct be_adapter *adapter, u16 qid, bool arm, u16 num_popped) in be_cq_notify() argument
265 if (be_check_error(adapter, BE_ERROR_HW)) in be_cq_notify()
271 iowrite32(val, adapter->db + DB_CQ_OFFSET); in be_cq_notify()
274 static int be_dev_mac_add(struct be_adapter *adapter, const u8 *mac) in be_dev_mac_add() argument
279 for (i = 0; i < adapter->uc_macs; i++) { in be_dev_mac_add()
280 if (ether_addr_equal(adapter->uc_list[i].mac, mac)) { in be_dev_mac_add()
282 adapter->pmac_id[0] = adapter->pmac_id[i + 1]; in be_dev_mac_add()
287 return be_cmd_pmac_add(adapter, mac, adapter->if_handle, in be_dev_mac_add()
288 &adapter->pmac_id[0], 0); in be_dev_mac_add()
291 static void be_dev_mac_del(struct be_adapter *adapter, int pmac_id) in be_dev_mac_del() argument
298 for (i = 0; i < adapter->uc_macs; i++) { in be_dev_mac_del()
299 if (adapter->pmac_id[i + 1] == pmac_id) in be_dev_mac_del()
302 be_cmd_pmac_del(adapter, adapter->if_handle, pmac_id, 0); in be_dev_mac_del()
307 struct be_adapter *adapter = netdev_priv(netdev); in be_mac_addr_set() local
308 struct device *dev = &adapter->pdev->dev; in be_mac_addr_set()
312 u32 old_pmac_id = adapter->pmac_id[0]; in be_mac_addr_set()
320 if (ether_addr_equal(addr->sa_data, adapter->dev_mac)) in be_mac_addr_set()
326 if (BEx_chip(adapter) && be_virtfn(adapter) && in be_mac_addr_set()
327 !check_privilege(adapter, BE_PRIV_FILTMGMT)) in be_mac_addr_set()
340 mutex_lock(&adapter->rx_filter_lock); in be_mac_addr_set()
341 status = be_dev_mac_add(adapter, (u8 *)addr->sa_data); in be_mac_addr_set()
347 if (adapter->pmac_id[0] != old_pmac_id) in be_mac_addr_set()
348 be_dev_mac_del(adapter, old_pmac_id); in be_mac_addr_set()
351 mutex_unlock(&adapter->rx_filter_lock); in be_mac_addr_set()
355 status = be_cmd_get_active_mac(adapter, adapter->pmac_id[0], mac, in be_mac_addr_set()
356 adapter->if_handle, true, 0); in be_mac_addr_set()
369 ether_addr_copy(adapter->dev_mac, addr->sa_data); in be_mac_addr_set()
380 static void *hw_stats_from_cmd(struct be_adapter *adapter) in hw_stats_from_cmd() argument
382 if (BE2_chip(adapter)) { in hw_stats_from_cmd()
383 struct be_cmd_resp_get_stats_v0 *cmd = adapter->stats_cmd.va; in hw_stats_from_cmd()
386 } else if (BE3_chip(adapter)) { in hw_stats_from_cmd()
387 struct be_cmd_resp_get_stats_v1 *cmd = adapter->stats_cmd.va; in hw_stats_from_cmd()
391 struct be_cmd_resp_get_stats_v2 *cmd = adapter->stats_cmd.va; in hw_stats_from_cmd()
398 static void *be_erx_stats_from_cmd(struct be_adapter *adapter) in be_erx_stats_from_cmd() argument
400 if (BE2_chip(adapter)) { in be_erx_stats_from_cmd()
401 struct be_hw_stats_v0 *hw_stats = hw_stats_from_cmd(adapter); in be_erx_stats_from_cmd()
404 } else if (BE3_chip(adapter)) { in be_erx_stats_from_cmd()
405 struct be_hw_stats_v1 *hw_stats = hw_stats_from_cmd(adapter); in be_erx_stats_from_cmd()
409 struct be_hw_stats_v2 *hw_stats = hw_stats_from_cmd(adapter); in be_erx_stats_from_cmd()
415 static void populate_be_v0_stats(struct be_adapter *adapter) in populate_be_v0_stats() argument
417 struct be_hw_stats_v0 *hw_stats = hw_stats_from_cmd(adapter); in populate_be_v0_stats()
421 &rxf_stats->port[adapter->port_num]; in populate_be_v0_stats()
422 struct be_drv_stats *drvs = &adapter->drv_stats; in populate_be_v0_stats()
451 if (adapter->port_num) in populate_be_v0_stats()
461 adapter->drv_stats.eth_red_drops = pmem_sts->eth_red_drops; in populate_be_v0_stats()
464 static void populate_be_v1_stats(struct be_adapter *adapter) in populate_be_v1_stats() argument
466 struct be_hw_stats_v1 *hw_stats = hw_stats_from_cmd(adapter); in populate_be_v1_stats()
470 &rxf_stats->port[adapter->port_num]; in populate_be_v1_stats()
471 struct be_drv_stats *drvs = &adapter->drv_stats; in populate_be_v1_stats()
507 adapter->drv_stats.eth_red_drops = pmem_sts->eth_red_drops; in populate_be_v1_stats()
510 static void populate_be_v2_stats(struct be_adapter *adapter) in populate_be_v2_stats() argument
512 struct be_hw_stats_v2 *hw_stats = hw_stats_from_cmd(adapter); in populate_be_v2_stats()
516 &rxf_stats->port[adapter->port_num]; in populate_be_v2_stats()
517 struct be_drv_stats *drvs = &adapter->drv_stats; in populate_be_v2_stats()
553 adapter->drv_stats.eth_red_drops = pmem_sts->eth_red_drops; in populate_be_v2_stats()
554 if (be_roce_supported(adapter)) { in populate_be_v2_stats()
564 static void populate_lancer_stats(struct be_adapter *adapter) in populate_lancer_stats() argument
566 struct be_drv_stats *drvs = &adapter->drv_stats; in populate_lancer_stats()
567 struct lancer_pport_stats *pport_stats = pport_stats_from_cmd(adapter); in populate_lancer_stats()
613 static void populate_erx_stats(struct be_adapter *adapter, in populate_erx_stats() argument
616 if (!BEx_chip(adapter)) in populate_erx_stats()
626 void be_parse_stats(struct be_adapter *adapter) in be_parse_stats() argument
628 struct be_erx_stats_v2 *erx = be_erx_stats_from_cmd(adapter); in be_parse_stats()
633 if (lancer_chip(adapter)) { in be_parse_stats()
634 populate_lancer_stats(adapter); in be_parse_stats()
636 if (BE2_chip(adapter)) in be_parse_stats()
637 populate_be_v0_stats(adapter); in be_parse_stats()
638 else if (BE3_chip(adapter)) in be_parse_stats()
640 populate_be_v1_stats(adapter); in be_parse_stats()
642 populate_be_v2_stats(adapter); in be_parse_stats()
645 for_all_rx_queues(adapter, rxo, i) { in be_parse_stats()
647 populate_erx_stats(adapter, rxo, erx_stat); in be_parse_stats()
655 struct be_adapter *adapter = netdev_priv(netdev); in be_get_stats64() local
656 struct be_drv_stats *drvs = &adapter->drv_stats; in be_get_stats64()
663 for_all_rx_queues(adapter, rxo, i) { in be_get_stats64()
678 for_all_tx_queues(adapter, txo, i) { in be_get_stats64()
719 void be_link_status_update(struct be_adapter *adapter, u8 link_status) in be_link_status_update() argument
721 struct net_device *netdev = adapter->netdev; in be_link_status_update()
723 if (!(adapter->flags & BE_FLAGS_LINK_STATUS_INIT)) { in be_link_status_update()
725 adapter->flags |= BE_FLAGS_LINK_STATUS_INIT; in be_link_status_update()
786 static inline u16 be_get_tx_vlan_tag(struct be_adapter *adapter, in be_get_tx_vlan_tag() argument
795 if (!(adapter->vlan_prio_bmap & (1 << vlan_prio))) in be_get_tx_vlan_tag()
797 adapter->recommended_prio_bits; in be_get_tx_vlan_tag()
830 static void be_get_wrb_params_from_skb(struct be_adapter *adapter, in be_get_wrb_params_from_skb() argument
839 if (skb_is_gso_v6(skb) && !lancer_chip(adapter)) in be_get_wrb_params_from_skb()
856 wrb_params->vlan_tag = be_get_tx_vlan_tag(adapter, skb); in be_get_wrb_params_from_skb()
862 static void wrb_fill_hdr(struct be_adapter *adapter, in wrb_fill_hdr() argument
926 static void be_tx_setup_wrb_hdr(struct be_adapter *adapter, in be_tx_setup_wrb_hdr() argument
935 wrb_fill_hdr(adapter, hdr, wrb_params, skb); in be_tx_setup_wrb_hdr()
962 static void be_xmit_restore(struct be_adapter *adapter, in be_xmit_restore() argument
970 dev = &adapter->pdev->dev; in be_xmit_restore()
990 static u32 be_xmit_enqueue(struct be_adapter *adapter, struct be_tx_obj *txo, in be_xmit_enqueue() argument
995 struct device *dev = &adapter->pdev->dev; in be_xmit_enqueue()
1025 be_tx_setup_wrb_hdr(adapter, txo, wrb_params, skb, head); in be_xmit_enqueue()
1031 adapter->drv_stats.dma_map_errors++; in be_xmit_enqueue()
1032 be_xmit_restore(adapter, txo, head, map_single, copied); in be_xmit_enqueue()
1036 static inline int qnq_async_evt_rcvd(struct be_adapter *adapter) in qnq_async_evt_rcvd() argument
1038 return adapter->flags & BE_FLAGS_QNQ_ASYNC_EVT_RCVD; in qnq_async_evt_rcvd()
1041 static struct sk_buff *be_insert_vlan_in_pkt(struct be_adapter *adapter, in be_insert_vlan_in_pkt() argument
1054 vlan_tag = be_get_tx_vlan_tag(adapter, skb); in be_insert_vlan_in_pkt()
1058 if (qnq_async_evt_rcvd(adapter) && adapter->pvid) { in be_insert_vlan_in_pkt()
1060 vlan_tag = adapter->pvid; in be_insert_vlan_in_pkt()
1078 if (adapter->qnq_vid) { in be_insert_vlan_in_pkt()
1079 vlan_tag = adapter->qnq_vid; in be_insert_vlan_in_pkt()
1112 static int be_vlan_tag_tx_chk(struct be_adapter *adapter, struct sk_buff *skb) in be_vlan_tag_tx_chk() argument
1114 return skb_vlan_tag_present(skb) || adapter->pvid || adapter->qnq_vid; in be_vlan_tag_tx_chk()
1117 static int be_ipv6_tx_stall_chk(struct be_adapter *adapter, struct sk_buff *skb) in be_ipv6_tx_stall_chk() argument
1119 return BE3_chip(adapter) && be_ipv6_exthdr_check(skb); in be_ipv6_tx_stall_chk()
1122 static struct sk_buff *be_lancer_xmit_workarounds(struct be_adapter *adapter, in be_lancer_xmit_workarounds() argument
1138 (lancer_chip(adapter) || BE3_chip(adapter) || in be_lancer_xmit_workarounds()
1148 if (be_pvid_tagging_enabled(adapter) && in be_lancer_xmit_workarounds()
1158 skb = be_insert_vlan_in_pkt(adapter, skb, wrb_params); in be_lancer_xmit_workarounds()
1167 if (unlikely(be_ipv6_tx_stall_chk(adapter, skb) && in be_lancer_xmit_workarounds()
1168 (adapter->pvid || adapter->qnq_vid) && in be_lancer_xmit_workarounds()
1169 !qnq_async_evt_rcvd(adapter))) in be_lancer_xmit_workarounds()
1178 if (be_ipv6_tx_stall_chk(adapter, skb) && in be_lancer_xmit_workarounds()
1179 be_vlan_tag_tx_chk(adapter, skb)) { in be_lancer_xmit_workarounds()
1180 skb = be_insert_vlan_in_pkt(adapter, skb, wrb_params); in be_lancer_xmit_workarounds()
1192 static struct sk_buff *be_xmit_workarounds(struct be_adapter *adapter, in be_xmit_workarounds() argument
1208 if (BEx_chip(adapter) || lancer_chip(adapter)) { in be_xmit_workarounds()
1209 skb = be_lancer_xmit_workarounds(adapter, skb, wrb_params); in be_xmit_workarounds()
1224 static void be_xmit_flush(struct be_adapter *adapter, struct be_tx_obj *txo) in be_xmit_flush() argument
1234 if (!lancer_chip(adapter) && (txo->pend_wrb_cnt & 1)) { in be_xmit_flush()
1244 be_txq_notify(adapter, txo, txo->pend_wrb_cnt); in be_xmit_flush()
1256 #define is_mc_allowed_on_bmc(adapter, eh) \ argument
1257 (!is_multicast_filt_enabled(adapter) && \
1261 #define is_bc_allowed_on_bmc(adapter, eh) \ argument
1262 (!is_broadcast_filt_enabled(adapter) && \
1265 #define is_arp_allowed_on_bmc(adapter, skb) \ argument
1266 (is_arp(skb) && is_arp_filt_enabled(adapter))
1270 #define is_arp_filt_enabled(adapter) \ argument
1271 (adapter->bmc_filt_mask & (BMC_FILT_BROADCAST_ARP))
1273 #define is_dhcp_client_filt_enabled(adapter) \ argument
1274 (adapter->bmc_filt_mask & BMC_FILT_BROADCAST_DHCP_CLIENT)
1276 #define is_dhcp_srvr_filt_enabled(adapter) \ argument
1277 (adapter->bmc_filt_mask & BMC_FILT_BROADCAST_DHCP_SERVER)
1279 #define is_nbios_filt_enabled(adapter) \ argument
1280 (adapter->bmc_filt_mask & BMC_FILT_BROADCAST_NET_BIOS)
1282 #define is_ipv6_na_filt_enabled(adapter) \ argument
1283 (adapter->bmc_filt_mask & \
1286 #define is_ipv6_ra_filt_enabled(adapter) \ argument
1287 (adapter->bmc_filt_mask & BMC_FILT_MULTICAST_IPV6_RA)
1289 #define is_ipv6_ras_filt_enabled(adapter) \ argument
1290 (adapter->bmc_filt_mask & BMC_FILT_MULTICAST_IPV6_RAS)
1292 #define is_broadcast_filt_enabled(adapter) \ argument
1293 (adapter->bmc_filt_mask & BMC_FILT_BROADCAST)
1295 #define is_multicast_filt_enabled(adapter) \ argument
1296 (adapter->bmc_filt_mask & BMC_FILT_MULTICAST)
1298 static bool be_send_pkt_to_bmc(struct be_adapter *adapter, in be_send_pkt_to_bmc() argument
1304 if (!be_is_os2bmc_enabled(adapter)) in be_send_pkt_to_bmc()
1310 if (is_mc_allowed_on_bmc(adapter, eh) || in be_send_pkt_to_bmc()
1311 is_bc_allowed_on_bmc(adapter, eh) || in be_send_pkt_to_bmc()
1312 is_arp_allowed_on_bmc(adapter, (*skb))) { in be_send_pkt_to_bmc()
1326 os2bmc = is_ipv6_ra_filt_enabled(adapter); in be_send_pkt_to_bmc()
1329 os2bmc = is_ipv6_na_filt_enabled(adapter); in be_send_pkt_to_bmc()
1342 os2bmc = is_dhcp_client_filt_enabled(adapter); in be_send_pkt_to_bmc()
1345 os2bmc = is_dhcp_srvr_filt_enabled(adapter); in be_send_pkt_to_bmc()
1349 os2bmc = is_nbios_filt_enabled(adapter); in be_send_pkt_to_bmc()
1352 os2bmc = is_ipv6_ras_filt_enabled(adapter); in be_send_pkt_to_bmc()
1363 *skb = be_insert_vlan_in_pkt(adapter, *skb, NULL); in be_send_pkt_to_bmc()
1370 struct be_adapter *adapter = netdev_priv(netdev); in be_xmit() local
1372 struct be_tx_obj *txo = &adapter->tx_obj[q_idx]; in be_xmit()
1377 skb = be_xmit_workarounds(adapter, skb, &wrb_params); in be_xmit()
1381 be_get_wrb_params_from_skb(adapter, skb, &wrb_params); in be_xmit()
1383 wrb_cnt = be_xmit_enqueue(adapter, txo, skb, &wrb_params); in be_xmit()
1390 if (be_send_pkt_to_bmc(adapter, &skb)) { in be_xmit()
1392 wrb_cnt = be_xmit_enqueue(adapter, txo, skb, &wrb_params); in be_xmit()
1405 be_xmit_flush(adapter, txo); in be_xmit()
1414 be_xmit_flush(adapter, txo); in be_xmit()
1421 struct be_adapter *adapter = netdev_priv(netdev); in be_tx_timeout() local
1422 struct device *dev = &adapter->pdev->dev; in be_tx_timeout()
1431 for_all_tx_queues(adapter, txo, i) { in be_tx_timeout()
1486 if (lancer_chip(adapter)) { in be_tx_timeout()
1488 dev_info(dev, "Resetting adapter\n"); in be_tx_timeout()
1489 status = lancer_physdev_ctrl(adapter, in be_tx_timeout()
1496 static inline bool be_in_all_promisc(struct be_adapter *adapter) in be_in_all_promisc() argument
1498 return (adapter->if_flags & BE_IF_FLAGS_ALL_PROMISCUOUS) == in be_in_all_promisc()
1502 static int be_set_vlan_promisc(struct be_adapter *adapter) in be_set_vlan_promisc() argument
1504 struct device *dev = &adapter->pdev->dev; in be_set_vlan_promisc()
1507 if (adapter->if_flags & BE_IF_FLAGS_VLAN_PROMISCUOUS) in be_set_vlan_promisc()
1510 status = be_cmd_rx_filter(adapter, BE_IF_FLAGS_VLAN_PROMISCUOUS, ON); in be_set_vlan_promisc()
1513 adapter->if_flags |= BE_IF_FLAGS_VLAN_PROMISCUOUS; in be_set_vlan_promisc()
1520 static int be_clear_vlan_promisc(struct be_adapter *adapter) in be_clear_vlan_promisc() argument
1522 struct device *dev = &adapter->pdev->dev; in be_clear_vlan_promisc()
1525 status = be_cmd_rx_filter(adapter, BE_IF_FLAGS_VLAN_PROMISCUOUS, OFF); in be_clear_vlan_promisc()
1528 adapter->if_flags &= ~BE_IF_FLAGS_VLAN_PROMISCUOUS; in be_clear_vlan_promisc()
1537 static int be_vid_config(struct be_adapter *adapter) in be_vid_config() argument
1539 struct device *dev = &adapter->pdev->dev; in be_vid_config()
1545 if (adapter->netdev->flags & IFF_PROMISC) in be_vid_config()
1548 if (adapter->vlans_added > be_max_vlans(adapter)) in be_vid_config()
1549 return be_set_vlan_promisc(adapter); in be_vid_config()
1551 if (adapter->if_flags & BE_IF_FLAGS_VLAN_PROMISCUOUS) { in be_vid_config()
1552 status = be_clear_vlan_promisc(adapter); in be_vid_config()
1557 for_each_set_bit(i, adapter->vids, VLAN_N_VID) in be_vid_config()
1560 status = be_cmd_vlan_config(adapter, adapter->if_handle, vids, num, 0); in be_vid_config()
1567 return be_set_vlan_promisc(adapter); in be_vid_config()
1574 struct be_adapter *adapter = netdev_priv(netdev); in be_vlan_add_vid() local
1577 mutex_lock(&adapter->rx_filter_lock); in be_vlan_add_vid()
1580 if (lancer_chip(adapter) && vid == 0) in be_vlan_add_vid()
1583 if (test_bit(vid, adapter->vids)) in be_vlan_add_vid()
1586 set_bit(vid, adapter->vids); in be_vlan_add_vid()
1587 adapter->vlans_added++; in be_vlan_add_vid()
1589 status = be_vid_config(adapter); in be_vlan_add_vid()
1591 mutex_unlock(&adapter->rx_filter_lock); in be_vlan_add_vid()
1597 struct be_adapter *adapter = netdev_priv(netdev); in be_vlan_rem_vid() local
1600 mutex_lock(&adapter->rx_filter_lock); in be_vlan_rem_vid()
1603 if (lancer_chip(adapter) && vid == 0) in be_vlan_rem_vid()
1606 if (!test_bit(vid, adapter->vids)) in be_vlan_rem_vid()
1609 clear_bit(vid, adapter->vids); in be_vlan_rem_vid()
1610 adapter->vlans_added--; in be_vlan_rem_vid()
1612 status = be_vid_config(adapter); in be_vlan_rem_vid()
1614 mutex_unlock(&adapter->rx_filter_lock); in be_vlan_rem_vid()
1618 static void be_set_all_promisc(struct be_adapter *adapter) in be_set_all_promisc() argument
1620 be_cmd_rx_filter(adapter, BE_IF_FLAGS_ALL_PROMISCUOUS, ON); in be_set_all_promisc()
1621 adapter->if_flags |= BE_IF_FLAGS_ALL_PROMISCUOUS; in be_set_all_promisc()
1624 static void be_set_mc_promisc(struct be_adapter *adapter) in be_set_mc_promisc() argument
1628 if (adapter->if_flags & BE_IF_FLAGS_MCAST_PROMISCUOUS) in be_set_mc_promisc()
1631 status = be_cmd_rx_filter(adapter, BE_IF_FLAGS_MCAST_PROMISCUOUS, ON); in be_set_mc_promisc()
1633 adapter->if_flags |= BE_IF_FLAGS_MCAST_PROMISCUOUS; in be_set_mc_promisc()
1636 static void be_set_uc_promisc(struct be_adapter *adapter) in be_set_uc_promisc() argument
1640 if (adapter->if_flags & BE_IF_FLAGS_PROMISCUOUS) in be_set_uc_promisc()
1643 status = be_cmd_rx_filter(adapter, BE_IF_FLAGS_PROMISCUOUS, ON); in be_set_uc_promisc()
1645 adapter->if_flags |= BE_IF_FLAGS_PROMISCUOUS; in be_set_uc_promisc()
1648 static void be_clear_uc_promisc(struct be_adapter *adapter) in be_clear_uc_promisc() argument
1652 if (!(adapter->if_flags & BE_IF_FLAGS_PROMISCUOUS)) in be_clear_uc_promisc()
1655 status = be_cmd_rx_filter(adapter, BE_IF_FLAGS_PROMISCUOUS, OFF); in be_clear_uc_promisc()
1657 adapter->if_flags &= ~BE_IF_FLAGS_PROMISCUOUS; in be_clear_uc_promisc()
1668 struct be_adapter *adapter = netdev_priv(netdev); in be_uc_list_update() local
1670 adapter->update_uc_list = true; in be_uc_list_update()
1677 struct be_adapter *adapter = netdev_priv(netdev); in be_mc_list_update() local
1679 adapter->update_mc_list = true; in be_mc_list_update()
1683 static void be_set_mc_list(struct be_adapter *adapter) in be_set_mc_list() argument
1685 struct net_device *netdev = adapter->netdev; in be_set_mc_list()
1694 adapter->update_mc_list = false; in be_set_mc_list()
1696 netdev_mc_count(netdev) > be_max_mc(adapter)) { in be_set_mc_list()
1701 adapter->update_mc_list = false; in be_set_mc_list()
1702 } else if (adapter->if_flags & BE_IF_FLAGS_MCAST_PROMISCUOUS) { in be_set_mc_list()
1706 adapter->update_mc_list = true; in be_set_mc_list()
1709 if (adapter->update_mc_list) { in be_set_mc_list()
1712 /* cache the mc-list in adapter */ in be_set_mc_list()
1714 ether_addr_copy(adapter->mc_list[i].mac, ha->addr); in be_set_mc_list()
1717 adapter->mc_count = netdev_mc_count(netdev); in be_set_mc_list()
1722 be_set_mc_promisc(adapter); in be_set_mc_list()
1723 } else if (adapter->update_mc_list) { in be_set_mc_list()
1724 status = be_cmd_rx_filter(adapter, BE_IF_FLAGS_MULTICAST, ON); in be_set_mc_list()
1726 adapter->if_flags &= ~BE_IF_FLAGS_MCAST_PROMISCUOUS; in be_set_mc_list()
1728 be_set_mc_promisc(adapter); in be_set_mc_list()
1730 adapter->update_mc_list = false; in be_set_mc_list()
1734 static void be_clear_mc_list(struct be_adapter *adapter) in be_clear_mc_list() argument
1736 struct net_device *netdev = adapter->netdev; in be_clear_mc_list()
1739 be_cmd_rx_filter(adapter, BE_IF_FLAGS_MULTICAST, OFF); in be_clear_mc_list()
1740 adapter->mc_count = 0; in be_clear_mc_list()
1743 static int be_uc_mac_add(struct be_adapter *adapter, int uc_idx) in be_uc_mac_add() argument
1745 if (ether_addr_equal(adapter->uc_list[uc_idx].mac, adapter->dev_mac)) { in be_uc_mac_add()
1746 adapter->pmac_id[uc_idx + 1] = adapter->pmac_id[0]; in be_uc_mac_add()
1750 return be_cmd_pmac_add(adapter, adapter->uc_list[uc_idx].mac, in be_uc_mac_add()
1751 adapter->if_handle, in be_uc_mac_add()
1752 &adapter->pmac_id[uc_idx + 1], 0); in be_uc_mac_add()
1755 static void be_uc_mac_del(struct be_adapter *adapter, int pmac_id) in be_uc_mac_del() argument
1757 if (pmac_id == adapter->pmac_id[0]) in be_uc_mac_del()
1760 be_cmd_pmac_del(adapter, adapter->if_handle, pmac_id, 0); in be_uc_mac_del()
1763 static void be_set_uc_list(struct be_adapter *adapter) in be_set_uc_list() argument
1765 struct net_device *netdev = adapter->netdev; in be_set_uc_list()
1774 adapter->update_uc_list = false; in be_set_uc_list()
1775 } else if (netdev_uc_count(netdev) > (be_max_uc(adapter) - 1)) { in be_set_uc_list()
1777 adapter->update_uc_list = false; in be_set_uc_list()
1778 } else if (adapter->if_flags & BE_IF_FLAGS_PROMISCUOUS) { in be_set_uc_list()
1782 adapter->update_uc_list = true; in be_set_uc_list()
1785 if (adapter->update_uc_list) { in be_set_uc_list()
1786 /* cache the uc-list in adapter array */ in be_set_uc_list()
1789 ether_addr_copy(adapter->uc_list[i].mac, ha->addr); in be_set_uc_list()
1797 be_set_uc_promisc(adapter); in be_set_uc_list()
1798 } else if (adapter->update_uc_list) { in be_set_uc_list()
1799 be_clear_uc_promisc(adapter); in be_set_uc_list()
1801 for (i = 0; i < adapter->uc_macs; i++) in be_set_uc_list()
1802 be_uc_mac_del(adapter, adapter->pmac_id[i + 1]); in be_set_uc_list()
1805 be_uc_mac_add(adapter, i); in be_set_uc_list()
1806 adapter->uc_macs = curr_uc_macs; in be_set_uc_list()
1807 adapter->update_uc_list = false; in be_set_uc_list()
1811 static void be_clear_uc_list(struct be_adapter *adapter) in be_clear_uc_list() argument
1813 struct net_device *netdev = adapter->netdev; in be_clear_uc_list()
1817 for (i = 0; i < adapter->uc_macs; i++) in be_clear_uc_list()
1818 be_uc_mac_del(adapter, adapter->pmac_id[i + 1]); in be_clear_uc_list()
1820 adapter->uc_macs = 0; in be_clear_uc_list()
1823 static void __be_set_rx_mode(struct be_adapter *adapter) in __be_set_rx_mode() argument
1825 struct net_device *netdev = adapter->netdev; in __be_set_rx_mode()
1827 mutex_lock(&adapter->rx_filter_lock); in __be_set_rx_mode()
1830 if (!be_in_all_promisc(adapter)) in __be_set_rx_mode()
1831 be_set_all_promisc(adapter); in __be_set_rx_mode()
1832 } else if (be_in_all_promisc(adapter)) { in __be_set_rx_mode()
1837 be_vid_config(adapter); in __be_set_rx_mode()
1840 be_set_uc_list(adapter); in __be_set_rx_mode()
1841 be_set_mc_list(adapter); in __be_set_rx_mode()
1843 mutex_unlock(&adapter->rx_filter_lock); in __be_set_rx_mode()
1851 __be_set_rx_mode(cmd_work->adapter); in be_work_set_rx_mode()
1857 struct be_adapter *adapter = netdev_priv(netdev); in be_set_vf_mac() local
1858 struct be_vf_cfg *vf_cfg = &adapter->vf_cfg[vf]; in be_set_vf_mac()
1861 if (!sriov_enabled(adapter)) in be_set_vf_mac()
1864 if (!is_valid_ether_addr(mac) || vf >= adapter->num_vfs) in be_set_vf_mac()
1873 if (BEx_chip(adapter)) { in be_set_vf_mac()
1874 be_cmd_pmac_del(adapter, vf_cfg->if_handle, vf_cfg->pmac_id, in be_set_vf_mac()
1877 status = be_cmd_pmac_add(adapter, mac, vf_cfg->if_handle, in be_set_vf_mac()
1880 status = be_cmd_set_mac(adapter, mac, vf_cfg->if_handle, in be_set_vf_mac()
1885 dev_err(&adapter->pdev->dev, "MAC %pM set on VF %d Failed: %#x", in be_set_vf_mac()
1898 struct be_adapter *adapter = netdev_priv(netdev); in be_get_vf_config() local
1899 struct be_vf_cfg *vf_cfg = &adapter->vf_cfg[vf]; in be_get_vf_config()
1901 if (!sriov_enabled(adapter)) in be_get_vf_config()
1904 if (vf >= adapter->num_vfs) in be_get_vf_config()
1913 vi->linkstate = adapter->vf_cfg[vf].plink_tracking; in be_get_vf_config()
1914 vi->spoofchk = adapter->vf_cfg[vf].spoofchk; in be_get_vf_config()
1919 static int be_set_vf_tvt(struct be_adapter *adapter, int vf, u16 vlan) in be_set_vf_tvt() argument
1921 struct be_vf_cfg *vf_cfg = &adapter->vf_cfg[vf]; in be_set_vf_tvt()
1927 status = be_cmd_set_hsw_config(adapter, vlan, vf + 1, vf_if_id, 0, 0); in be_set_vf_tvt()
1933 status = be_cmd_vlan_config(adapter, vf_if_id, vids, 1, vf + 1); in be_set_vf_tvt()
1935 dev_info(&adapter->pdev->dev, in be_set_vf_tvt()
1940 status = be_cmd_set_fn_privileges(adapter, vf_cfg->privileges & in be_set_vf_tvt()
1948 static int be_clear_vf_tvt(struct be_adapter *adapter, int vf) in be_clear_vf_tvt() argument
1950 struct be_vf_cfg *vf_cfg = &adapter->vf_cfg[vf]; in be_clear_vf_tvt()
1951 struct device *dev = &adapter->pdev->dev; in be_clear_vf_tvt()
1955 status = be_cmd_set_hsw_config(adapter, BE_RESET_VLAN_TAG_ID, vf + 1, in be_clear_vf_tvt()
1962 status = be_cmd_set_fn_privileges(adapter, vf_cfg->privileges | in be_clear_vf_tvt()
1978 struct be_adapter *adapter = netdev_priv(netdev); in be_set_vf_vlan() local
1979 struct be_vf_cfg *vf_cfg = &adapter->vf_cfg[vf]; in be_set_vf_vlan()
1982 if (!sriov_enabled(adapter)) in be_set_vf_vlan()
1985 if (vf >= adapter->num_vfs || vlan > 4095 || qos > 7) in be_set_vf_vlan()
1993 status = be_set_vf_tvt(adapter, vf, vlan); in be_set_vf_vlan()
1995 status = be_clear_vf_tvt(adapter, vf); in be_set_vf_vlan()
1999 dev_err(&adapter->pdev->dev, in be_set_vf_vlan()
2012 struct be_adapter *adapter = netdev_priv(netdev); in be_set_vf_tx_rate() local
2013 struct device *dev = &adapter->pdev->dev; in be_set_vf_tx_rate()
2018 if (!sriov_enabled(adapter)) in be_set_vf_tx_rate()
2021 if (vf >= adapter->num_vfs) in be_set_vf_tx_rate()
2030 status = be_cmd_link_status_query(adapter, &link_speed, in be_set_vf_tx_rate()
2050 if (skyhawk_chip(adapter) && (max_tx_rate % percent_rate)) { in be_set_vf_tx_rate()
2058 status = be_cmd_config_qos(adapter, max_tx_rate, link_speed, vf + 1); in be_set_vf_tx_rate()
2062 adapter->vf_cfg[vf].tx_rate = max_tx_rate; in be_set_vf_tx_rate()
2074 struct be_adapter *adapter = netdev_priv(netdev); in be_set_vf_link_state() local
2077 if (!sriov_enabled(adapter)) in be_set_vf_link_state()
2080 if (vf >= adapter->num_vfs) in be_set_vf_link_state()
2083 status = be_cmd_set_logical_link_config(adapter, link_state, vf+1); in be_set_vf_link_state()
2085 dev_err(&adapter->pdev->dev, in be_set_vf_link_state()
2090 adapter->vf_cfg[vf].plink_tracking = link_state; in be_set_vf_link_state()
2097 struct be_adapter *adapter = netdev_priv(netdev); in be_set_vf_spoofchk() local
2098 struct be_vf_cfg *vf_cfg = &adapter->vf_cfg[vf]; in be_set_vf_spoofchk()
2102 if (!sriov_enabled(adapter)) in be_set_vf_spoofchk()
2105 if (vf >= adapter->num_vfs) in be_set_vf_spoofchk()
2108 if (BEx_chip(adapter)) in be_set_vf_spoofchk()
2116 status = be_cmd_set_hsw_config(adapter, 0, vf + 1, vf_cfg->if_handle, in be_set_vf_spoofchk()
2119 dev_err(&adapter->pdev->dev, in be_set_vf_spoofchk()
2138 struct be_adapter *adapter = eqo->adapter; in be_get_new_eqd() local
2148 aic = &adapter->aic_obj[eqo->idx]; in be_get_new_eqd()
2149 if (!adapter->aic_enabled) { in be_get_new_eqd()
2156 for_all_rx_queues_on_eq(adapter, eqo, rxo, i) { in be_get_new_eqd()
2163 for_all_tx_queues_on_eq(adapter, eqo, txo, i) { in be_get_new_eqd()
2200 struct be_adapter *adapter = eqo->adapter; in be_get_eq_delay_mult_enc() local
2201 struct be_aic_obj *aic = &adapter->aic_obj[eqo->idx]; in be_get_eq_delay_mult_enc()
2206 if (!adapter->aic_enabled) in be_get_eq_delay_mult_enc()
2228 void be_eqd_update(struct be_adapter *adapter, bool force_update) in be_eqd_update() argument
2235 for_all_evt_queues(adapter, eqo, i) { in be_eqd_update()
2236 aic = &adapter->aic_obj[eqo->idx]; in be_eqd_update()
2247 be_cmd_modify_eqd(adapter, set_eqd, num); in be_eqd_update()
2279 struct be_adapter *adapter = rxo->adapter; in get_rx_page_info() local
2288 dma_unmap_page(&adapter->pdev->dev, in get_rx_page_info()
2290 adapter->big_page_size, DMA_FROM_DEVICE); in get_rx_page_info()
2293 dma_sync_single_for_cpu(&adapter->pdev->dev, in get_rx_page_info()
2396 struct be_adapter *adapter = rxo->adapter; in be_rx_compl_process() local
2397 struct net_device *netdev = adapter->netdev; in be_rx_compl_process()
2415 skb_record_rx_queue(skb, rxo - &adapter->rx_obj[0]); in be_rx_compl_process()
2433 struct be_adapter *adapter = rxo->adapter; in be_rx_compl_process_gro() local
2475 skb_record_rx_queue(skb, rxo - &adapter->rx_obj[0]); in be_rx_compl_process_gro()
2476 if (adapter->netdev->features & NETIF_F_RXHASH) in be_rx_compl_process_gro()
2536 struct be_adapter *adapter = rxo->adapter; in be_rx_compl_get() local
2546 if (adapter->be3_native) in be_rx_compl_get()
2559 if (be_is_qnq_mode(adapter) && !rxcp->qnq) in be_rx_compl_get()
2562 if (!lancer_chip(adapter)) in be_rx_compl_get()
2565 if (adapter->pvid == (rxcp->vlan_tag & VLAN_VID_MASK) && in be_rx_compl_get()
2566 !test_bit(rxcp->vlan_tag, adapter->vids)) in be_rx_compl_get()
2592 struct be_adapter *adapter = rxo->adapter; in be_post_rx_frags() local
2596 struct device *dev = &adapter->pdev->dev; in be_post_rx_frags()
2604 pagep = be_alloc_pages(adapter->big_page_size, gfp); in be_post_rx_frags()
2610 adapter->big_page_size, in be_post_rx_frags()
2615 adapter->drv_stats.dma_map_errors++; in be_post_rx_frags()
2633 adapter->big_page_size) { in be_post_rx_frags()
2660 be_rxq_notify(adapter, rxq->id, notify); in be_post_rx_frags()
2709 static struct be_tx_compl_info *be_tx_compl_get(struct be_adapter *adapter, in be_tx_compl_get() argument
2727 if (lancer_chip(adapter)) { in be_tx_compl_get()
2729 /* Reset the adapter incase of TSO, in be_tx_compl_get()
2735 be_set_error(adapter, BE_ERROR_TX); in be_tx_compl_get()
2741 if (be_check_error(adapter, BE_ERROR_TX)) in be_tx_compl_get()
2749 static u16 be_tx_compl_process(struct be_adapter *adapter, in be_tx_compl_process() argument
2773 unmap_tx_frag(&adapter->pdev->dev, wrb, in be_tx_compl_process()
2809 be_eq_notify(eqo->adapter, eqo->q.id, false, true, num, 0); in be_eq_clean()
2832 struct be_adapter *adapter = rxo->adapter; in be_rx_cq_clean() local
2844 if (lancer_chip(adapter)) in be_rx_cq_clean()
2848 be_check_error(adapter, in be_rx_cq_clean()
2850 dev_warn(&adapter->pdev->dev, in be_rx_cq_clean()
2854 be_cq_notify(adapter, rx_cq->id, true, 0); in be_rx_cq_clean()
2858 be_cq_notify(adapter, rx_cq->id, false, 1); in be_rx_cq_clean()
2865 be_cq_notify(adapter, rx_cq->id, false, 0); in be_rx_cq_clean()
2868 static void be_tx_compl_clean(struct be_adapter *adapter) in be_tx_compl_clean() argument
2870 struct device *dev = &adapter->pdev->dev; in be_tx_compl_clean()
2880 pending_txqs = adapter->num_tx_qs; in be_tx_compl_clean()
2882 for_all_tx_queues(adapter, txo, i) { in be_tx_compl_clean()
2886 while ((txcp = be_tx_compl_get(adapter, txo))) { in be_tx_compl_clean()
2888 be_tx_compl_process(adapter, txo, in be_tx_compl_clean()
2893 be_cq_notify(adapter, txo->cq.id, false, cmpl); in be_tx_compl_clean()
2902 be_check_error(adapter, BE_ERROR_HW)) in be_tx_compl_clean()
2909 for_all_tx_queues(adapter, txo, i) { in be_tx_compl_clean()
2922 num_wrbs = be_tx_compl_process(adapter, txo, end_idx); in be_tx_compl_clean()
2935 static void be_evt_queues_destroy(struct be_adapter *adapter) in be_evt_queues_destroy() argument
2940 for_all_evt_queues(adapter, eqo, i) { in be_evt_queues_destroy()
2943 be_cmd_q_destroy(adapter, &eqo->q, QTYPE_EQ); in be_evt_queues_destroy()
2947 be_queue_free(adapter, &eqo->q); in be_evt_queues_destroy()
2951 static int be_evt_queues_create(struct be_adapter *adapter) in be_evt_queues_create() argument
2959 adapter->num_evt_qs = min_t(u16, num_irqs(adapter), in be_evt_queues_create()
2960 max(adapter->cfg_num_rx_irqs, in be_evt_queues_create()
2961 adapter->cfg_num_tx_irqs)); in be_evt_queues_create()
2963 adapter->aic_enabled = true; in be_evt_queues_create()
2965 for_all_evt_queues(adapter, eqo, i) { in be_evt_queues_create()
2966 int numa_node = dev_to_node(&adapter->pdev->dev); in be_evt_queues_create()
2968 aic = &adapter->aic_obj[i]; in be_evt_queues_create()
2969 eqo->adapter = adapter; in be_evt_queues_create()
2974 rc = be_queue_alloc(adapter, eq, EVNT_Q_LEN, in be_evt_queues_create()
2979 rc = be_cmd_eq_create(adapter, eqo); in be_evt_queues_create()
2987 netif_napi_add(adapter->netdev, &eqo->napi, be_poll); in be_evt_queues_create()
2992 static void be_mcc_queues_destroy(struct be_adapter *adapter) in be_mcc_queues_destroy() argument
2996 q = &adapter->mcc_obj.q; in be_mcc_queues_destroy()
2998 be_cmd_q_destroy(adapter, q, QTYPE_MCCQ); in be_mcc_queues_destroy()
2999 be_queue_free(adapter, q); in be_mcc_queues_destroy()
3001 q = &adapter->mcc_obj.cq; in be_mcc_queues_destroy()
3003 be_cmd_q_destroy(adapter, q, QTYPE_CQ); in be_mcc_queues_destroy()
3004 be_queue_free(adapter, q); in be_mcc_queues_destroy()
3008 static int be_mcc_queues_create(struct be_adapter *adapter) in be_mcc_queues_create() argument
3012 cq = &adapter->mcc_obj.cq; in be_mcc_queues_create()
3013 if (be_queue_alloc(adapter, cq, MCC_CQ_LEN, in be_mcc_queues_create()
3018 if (be_cmd_cq_create(adapter, cq, &mcc_eqo(adapter)->q, true, 0)) in be_mcc_queues_create()
3021 q = &adapter->mcc_obj.q; in be_mcc_queues_create()
3022 if (be_queue_alloc(adapter, q, MCC_Q_LEN, sizeof(struct be_mcc_wrb))) in be_mcc_queues_create()
3025 if (be_cmd_mccq_create(adapter, q, cq)) in be_mcc_queues_create()
3031 be_queue_free(adapter, q); in be_mcc_queues_create()
3033 be_cmd_q_destroy(adapter, cq, QTYPE_CQ); in be_mcc_queues_create()
3035 be_queue_free(adapter, cq); in be_mcc_queues_create()
3040 static void be_tx_queues_destroy(struct be_adapter *adapter) in be_tx_queues_destroy() argument
3046 for_all_tx_queues(adapter, txo, i) { in be_tx_queues_destroy()
3049 be_cmd_q_destroy(adapter, q, QTYPE_TXQ); in be_tx_queues_destroy()
3050 be_queue_free(adapter, q); in be_tx_queues_destroy()
3054 be_cmd_q_destroy(adapter, q, QTYPE_CQ); in be_tx_queues_destroy()
3055 be_queue_free(adapter, q); in be_tx_queues_destroy()
3059 static int be_tx_qs_create(struct be_adapter *adapter) in be_tx_qs_create() argument
3066 adapter->num_tx_qs = min(adapter->num_evt_qs, adapter->cfg_num_tx_irqs); in be_tx_qs_create()
3068 for_all_tx_queues(adapter, txo, i) { in be_tx_qs_create()
3070 status = be_queue_alloc(adapter, cq, TX_CQ_LEN, in be_tx_qs_create()
3081 eqo = &adapter->eq_obj[i % adapter->num_evt_qs]; in be_tx_qs_create()
3082 status = be_cmd_cq_create(adapter, cq, &eqo->q, false, 3); in be_tx_qs_create()
3086 status = be_queue_alloc(adapter, &txo->q, TX_Q_LEN, in be_tx_qs_create()
3091 status = be_cmd_txq_create(adapter, txo); in be_tx_qs_create()
3095 netif_set_xps_queue(adapter->netdev, eqo->affinity_mask, in be_tx_qs_create()
3099 dev_info(&adapter->pdev->dev, "created %d TX queue(s)\n", in be_tx_qs_create()
3100 adapter->num_tx_qs); in be_tx_qs_create()
3104 static void be_rx_cqs_destroy(struct be_adapter *adapter) in be_rx_cqs_destroy() argument
3110 for_all_rx_queues(adapter, rxo, i) { in be_rx_cqs_destroy()
3113 be_cmd_q_destroy(adapter, q, QTYPE_CQ); in be_rx_cqs_destroy()
3114 be_queue_free(adapter, q); in be_rx_cqs_destroy()
3118 static int be_rx_cqs_create(struct be_adapter *adapter) in be_rx_cqs_create() argument
3124 adapter->num_rss_qs = in be_rx_cqs_create()
3125 min(adapter->num_evt_qs, adapter->cfg_num_rx_irqs); in be_rx_cqs_create()
3128 if (adapter->num_rss_qs < 2) in be_rx_cqs_create()
3129 adapter->num_rss_qs = 0; in be_rx_cqs_create()
3131 adapter->num_rx_qs = adapter->num_rss_qs + adapter->need_def_rxq; in be_rx_cqs_create()
3136 if (adapter->num_rx_qs == 0) in be_rx_cqs_create()
3137 adapter->num_rx_qs = 1; in be_rx_cqs_create()
3139 adapter->big_page_size = (1 << get_order(rx_frag_size)) * PAGE_SIZE; in be_rx_cqs_create()
3140 for_all_rx_queues(adapter, rxo, i) { in be_rx_cqs_create()
3141 rxo->adapter = adapter; in be_rx_cqs_create()
3143 rc = be_queue_alloc(adapter, cq, RX_CQ_LEN, in be_rx_cqs_create()
3149 eq = &adapter->eq_obj[i % adapter->num_evt_qs].q; in be_rx_cqs_create()
3150 rc = be_cmd_cq_create(adapter, cq, eq, false, 3); in be_rx_cqs_create()
3155 dev_info(&adapter->pdev->dev, in be_rx_cqs_create()
3156 "created %d RX queue(s)\n", adapter->num_rx_qs); in be_rx_cqs_create()
3163 struct be_adapter *adapter = eqo->adapter; in be_intx() local
3180 be_eq_notify(adapter, eqo->q.id, false, true, num_evts, 0); in be_intx()
3196 be_eq_notify(eqo->adapter, eqo->q.id, false, true, 0, 0); in be_msix()
3209 struct be_adapter *adapter = rxo->adapter; in be_process_rx() local
3233 if (unlikely(rxcp->port != adapter->port_num && in be_process_rx()
3234 !lancer_chip(adapter))) { in be_process_rx()
3250 be_cq_notify(adapter, rx_cq->id, true, work_done); in be_process_rx()
3266 static void be_process_tx(struct be_adapter *adapter, struct be_tx_obj *txo, in be_process_tx() argument
3272 while ((txcp = be_tx_compl_get(adapter, txo))) { in be_process_tx()
3273 num_wrbs += be_tx_compl_process(adapter, txo, txcp->end_index); in be_process_tx()
3278 be_cq_notify(adapter, txo->cq.id, true, work_done); in be_process_tx()
3283 if (__netif_subqueue_stopped(adapter->netdev, idx) && in be_process_tx()
3285 netif_wake_subqueue(adapter->netdev, idx); in be_process_tx()
3297 struct be_adapter *adapter = eqo->adapter; in be_poll() local
3305 for_all_tx_queues_on_eq(adapter, eqo, txo, i) in be_poll()
3306 be_process_tx(adapter, txo, i); in be_poll()
3312 for_all_rx_queues_on_eq(adapter, eqo, rxo, i) { in be_poll()
3318 be_process_mcc(adapter); in be_poll()
3326 if (skyhawk_chip(adapter)) in be_poll()
3329 be_eq_notify(adapter, eqo->q.id, true, false, num_evts, in be_poll()
3333 be_eq_notify(adapter, eqo->q.id, false, false, num_evts, 0); in be_poll()
3338 void be_detect_error(struct be_adapter *adapter) in be_detect_error() argument
3342 struct device *dev = &adapter->pdev->dev; in be_detect_error()
3346 if (be_check_error(adapter, BE_ERROR_HW)) in be_detect_error()
3349 if (lancer_chip(adapter)) { in be_detect_error()
3350 sliport_status = ioread32(adapter->db + SLIPORT_STATUS_OFFSET); in be_detect_error()
3352 be_set_error(adapter, BE_ERROR_UE); in be_detect_error()
3353 sliport_err1 = ioread32(adapter->db + in be_detect_error()
3355 sliport_err2 = ioread32(adapter->db + in be_detect_error()
3372 ue_lo = ioread32(adapter->pcicfg + PCICFG_UE_STATUS_LOW); in be_detect_error()
3373 ue_hi = ioread32(adapter->pcicfg + PCICFG_UE_STATUS_HIGH); in be_detect_error()
3374 ue_lo_mask = ioread32(adapter->pcicfg + in be_detect_error()
3376 ue_hi_mask = ioread32(adapter->pcicfg + in be_detect_error()
3390 if (BE3_chip(adapter)) { in be_detect_error()
3391 val = be_POST_stage_get(adapter); in be_detect_error()
3401 dev_err(dev, "Error detected in the adapter"); in be_detect_error()
3402 be_set_error(adapter, BE_ERROR_UE); in be_detect_error()
3418 static void be_msix_disable(struct be_adapter *adapter) in be_msix_disable() argument
3420 if (msix_enabled(adapter)) { in be_msix_disable()
3421 pci_disable_msix(adapter->pdev); in be_msix_disable()
3422 adapter->num_msix_vec = 0; in be_msix_disable()
3423 adapter->num_msix_roce_vec = 0; in be_msix_disable()
3427 static int be_msix_enable(struct be_adapter *adapter) in be_msix_enable() argument
3430 struct device *dev = &adapter->pdev->dev; in be_msix_enable()
3437 if (be_roce_supported(adapter)) { in be_msix_enable()
3439 be_max_func_eqs(adapter) - be_max_nic_eqs(adapter); in be_msix_enable()
3441 num_vec = be_max_any_irqs(adapter) + max_roce_eqs; in be_msix_enable()
3443 num_vec = max(adapter->cfg_num_rx_irqs, in be_msix_enable()
3444 adapter->cfg_num_tx_irqs); in be_msix_enable()
3448 adapter->msix_entries[i].entry = i; in be_msix_enable()
3450 num_vec = pci_enable_msix_range(adapter->pdev, adapter->msix_entries, in be_msix_enable()
3455 if (be_roce_supported(adapter) && num_vec > MIN_MSIX_VECTORS) { in be_msix_enable()
3456 adapter->num_msix_roce_vec = num_vec / 2; in be_msix_enable()
3458 adapter->num_msix_roce_vec); in be_msix_enable()
3461 adapter->num_msix_vec = num_vec - adapter->num_msix_roce_vec; in be_msix_enable()
3464 adapter->num_msix_vec); in be_msix_enable()
3471 if (be_virtfn(adapter)) in be_msix_enable()
3476 static inline int be_msix_vec_get(struct be_adapter *adapter, in be_msix_vec_get() argument
3479 return adapter->msix_entries[eqo->msix_idx].vector; in be_msix_vec_get()
3482 static int be_msix_register(struct be_adapter *adapter) in be_msix_register() argument
3484 struct net_device *netdev = adapter->netdev; in be_msix_register()
3488 for_all_evt_queues(adapter, eqo, i) { in be_msix_register()
3490 vec = be_msix_vec_get(adapter, eqo); in be_msix_register()
3501 eqo = &adapter->eq_obj[i]; in be_msix_register()
3502 free_irq(be_msix_vec_get(adapter, eqo), eqo); in be_msix_register()
3504 dev_warn(&adapter->pdev->dev, "MSIX Request IRQ failed - err %d\n", in be_msix_register()
3506 be_msix_disable(adapter); in be_msix_register()
3510 static int be_irq_register(struct be_adapter *adapter) in be_irq_register() argument
3512 struct net_device *netdev = adapter->netdev; in be_irq_register()
3515 if (msix_enabled(adapter)) { in be_irq_register()
3516 status = be_msix_register(adapter); in be_irq_register()
3520 if (be_virtfn(adapter)) in be_irq_register()
3525 netdev->irq = adapter->pdev->irq; in be_irq_register()
3527 &adapter->eq_obj[0]); in be_irq_register()
3529 dev_err(&adapter->pdev->dev, in be_irq_register()
3534 adapter->isr_registered = true; in be_irq_register()
3538 static void be_irq_unregister(struct be_adapter *adapter) in be_irq_unregister() argument
3540 struct net_device *netdev = adapter->netdev; in be_irq_unregister()
3544 if (!adapter->isr_registered) in be_irq_unregister()
3548 if (!msix_enabled(adapter)) { in be_irq_unregister()
3549 free_irq(netdev->irq, &adapter->eq_obj[0]); in be_irq_unregister()
3554 for_all_evt_queues(adapter, eqo, i) { in be_irq_unregister()
3555 vec = be_msix_vec_get(adapter, eqo); in be_irq_unregister()
3561 adapter->isr_registered = false; in be_irq_unregister()
3564 static void be_rx_qs_destroy(struct be_adapter *adapter) in be_rx_qs_destroy() argument
3566 struct rss_info *rss = &adapter->rss_info; in be_rx_qs_destroy()
3571 for_all_rx_queues(adapter, rxo, i) { in be_rx_qs_destroy()
3580 if (lancer_chip(adapter)) { in be_rx_qs_destroy()
3587 be_cmd_rxq_destroy(adapter, q); in be_rx_qs_destroy()
3591 be_queue_free(adapter, q); in be_rx_qs_destroy()
3596 be_cmd_rss_config(adapter, rss->rsstable, rss->rss_flags, in be_rx_qs_destroy()
3601 static void be_disable_if_filters(struct be_adapter *adapter) in be_disable_if_filters() argument
3604 if (!BEx_chip(adapter) || !be_virtfn(adapter) || in be_disable_if_filters()
3605 check_privilege(adapter, BE_PRIV_FILTMGMT)) { in be_disable_if_filters()
3606 be_dev_mac_del(adapter, adapter->pmac_id[0]); in be_disable_if_filters()
3607 eth_zero_addr(adapter->dev_mac); in be_disable_if_filters()
3610 be_clear_uc_list(adapter); in be_disable_if_filters()
3611 be_clear_mc_list(adapter); in be_disable_if_filters()
3627 if (lancer_chip(adapter)) { in be_disable_if_filters()
3628 be_cmd_rx_filter(adapter, BE_IF_ALL_FILT_FLAGS, OFF); in be_disable_if_filters()
3629 adapter->if_flags &= ~BE_IF_ALL_FILT_FLAGS; in be_disable_if_filters()
3635 struct be_adapter *adapter = netdev_priv(netdev); in be_close() local
3640 * adapter is in cleared state (after eeh perm failure) in be_close()
3642 if (!(adapter->flags & BE_FLAGS_SETUP_DONE)) in be_close()
3650 be_disable_if_filters(adapter); in be_close()
3652 if (adapter->flags & BE_FLAGS_NAPI_ENABLED) { in be_close()
3653 for_all_evt_queues(adapter, eqo, i) { in be_close()
3656 adapter->flags &= ~BE_FLAGS_NAPI_ENABLED; in be_close()
3659 be_async_mcc_disable(adapter); in be_close()
3665 be_tx_compl_clean(adapter); in be_close()
3667 be_rx_qs_destroy(adapter); in be_close()
3669 for_all_evt_queues(adapter, eqo, i) { in be_close()
3670 if (msix_enabled(adapter)) in be_close()
3671 synchronize_irq(be_msix_vec_get(adapter, eqo)); in be_close()
3677 be_irq_unregister(adapter); in be_close()
3682 static int be_rx_qs_create(struct be_adapter *adapter) in be_rx_qs_create() argument
3684 struct rss_info *rss = &adapter->rss_info; in be_rx_qs_create()
3689 for_all_rx_queues(adapter, rxo, i) { in be_rx_qs_create()
3690 rc = be_queue_alloc(adapter, &rxo->q, RX_Q_LEN, in be_rx_qs_create()
3696 if (adapter->need_def_rxq || !adapter->num_rss_qs) { in be_rx_qs_create()
3697 rxo = default_rxo(adapter); in be_rx_qs_create()
3698 rc = be_cmd_rxq_create(adapter, &rxo->q, rxo->cq.id, in be_rx_qs_create()
3699 rx_frag_size, adapter->if_handle, in be_rx_qs_create()
3705 for_all_rss_queues(adapter, rxo, i) { in be_rx_qs_create()
3706 rc = be_cmd_rxq_create(adapter, &rxo->q, rxo->cq.id, in be_rx_qs_create()
3707 rx_frag_size, adapter->if_handle, in be_rx_qs_create()
3713 if (be_multi_rxq(adapter)) { in be_rx_qs_create()
3714 for (j = 0; j < RSS_INDIR_TABLE_LEN; j += adapter->num_rss_qs) { in be_rx_qs_create()
3715 for_all_rss_queues(adapter, rxo, i) { in be_rx_qs_create()
3725 if (!BEx_chip(adapter)) in be_rx_qs_create()
3730 rc = be_cmd_rss_config(adapter, rss->rsstable, rss->rss_flags, in be_rx_qs_create()
3747 for_all_rx_queues(adapter, rxo, i) in be_rx_qs_create()
3753 static int be_enable_if_filters(struct be_adapter *adapter) in be_enable_if_filters() argument
3757 status = be_cmd_rx_filter(adapter, BE_IF_FILT_FLAGS_BASIC, ON); in be_enable_if_filters()
3765 if (!ether_addr_equal(adapter->dev_mac, adapter->netdev->dev_addr)) { in be_enable_if_filters()
3769 if (!is_zero_ether_addr(adapter->dev_mac)) in be_enable_if_filters()
3770 old_pmac_id = adapter->pmac_id[0]; in be_enable_if_filters()
3772 status = be_dev_mac_add(adapter, adapter->netdev->dev_addr); in be_enable_if_filters()
3779 if (old_pmac_id >= 0 && old_pmac_id != adapter->pmac_id[0]) in be_enable_if_filters()
3780 be_dev_mac_del(adapter, old_pmac_id); in be_enable_if_filters()
3782 ether_addr_copy(adapter->dev_mac, adapter->netdev->dev_addr); in be_enable_if_filters()
3785 if (adapter->vlans_added) in be_enable_if_filters()
3786 be_vid_config(adapter); in be_enable_if_filters()
3788 __be_set_rx_mode(adapter); in be_enable_if_filters()
3795 struct be_adapter *adapter = netdev_priv(netdev); in be_open() local
3802 status = be_rx_qs_create(adapter); in be_open()
3806 status = be_enable_if_filters(adapter); in be_open()
3810 status = be_irq_register(adapter); in be_open()
3814 for_all_rx_queues(adapter, rxo, i) in be_open()
3815 be_cq_notify(adapter, rxo->cq.id, true, 0); in be_open()
3817 for_all_tx_queues(adapter, txo, i) in be_open()
3818 be_cq_notify(adapter, txo->cq.id, true, 0); in be_open()
3820 be_async_mcc_enable(adapter); in be_open()
3822 for_all_evt_queues(adapter, eqo, i) { in be_open()
3824 be_eq_notify(adapter, eqo->q.id, true, true, 0, 0); in be_open()
3826 adapter->flags |= BE_FLAGS_NAPI_ENABLED; in be_open()
3828 status = be_cmd_link_status_query(adapter, NULL, &link_status, 0); in be_open()
3830 be_link_status_update(adapter, link_status); in be_open()
3838 be_close(adapter->netdev); in be_open()
3842 static void be_vf_eth_addr_generate(struct be_adapter *adapter, u8 *mac) in be_vf_eth_addr_generate() argument
3846 addr = jhash(adapter->netdev->dev_addr, ETH_ALEN, 0); in be_vf_eth_addr_generate()
3852 memcpy(mac, adapter->netdev->dev_addr, 3); in be_vf_eth_addr_generate()
3861 static int be_vf_eth_addr_config(struct be_adapter *adapter) in be_vf_eth_addr_config() argument
3868 be_vf_eth_addr_generate(adapter, mac); in be_vf_eth_addr_config()
3870 for_all_vfs(adapter, vf_cfg, vf) { in be_vf_eth_addr_config()
3871 if (BEx_chip(adapter)) in be_vf_eth_addr_config()
3872 status = be_cmd_pmac_add(adapter, mac, in be_vf_eth_addr_config()
3876 status = be_cmd_set_mac(adapter, mac, vf_cfg->if_handle, in be_vf_eth_addr_config()
3880 dev_err(&adapter->pdev->dev, in be_vf_eth_addr_config()
3891 static int be_vfs_mac_query(struct be_adapter *adapter) in be_vfs_mac_query() argument
3897 for_all_vfs(adapter, vf_cfg, vf) { in be_vfs_mac_query()
3898 status = be_cmd_get_active_mac(adapter, vf_cfg->pmac_id, in be_vfs_mac_query()
3908 static void be_vf_clear(struct be_adapter *adapter) in be_vf_clear() argument
3913 if (pci_vfs_assigned(adapter->pdev)) { in be_vf_clear()
3914 dev_warn(&adapter->pdev->dev, in be_vf_clear()
3919 pci_disable_sriov(adapter->pdev); in be_vf_clear()
3921 for_all_vfs(adapter, vf_cfg, vf) { in be_vf_clear()
3922 if (BEx_chip(adapter)) in be_vf_clear()
3923 be_cmd_pmac_del(adapter, vf_cfg->if_handle, in be_vf_clear()
3926 be_cmd_set_mac(adapter, NULL, vf_cfg->if_handle, in be_vf_clear()
3929 be_cmd_if_destroy(adapter, vf_cfg->if_handle, vf + 1); in be_vf_clear()
3932 if (BE3_chip(adapter)) in be_vf_clear()
3933 be_cmd_set_hsw_config(adapter, 0, 0, in be_vf_clear()
3934 adapter->if_handle, in be_vf_clear()
3937 kfree(adapter->vf_cfg); in be_vf_clear()
3938 adapter->num_vfs = 0; in be_vf_clear()
3939 adapter->flags &= ~BE_FLAGS_SRIOV_ENABLED; in be_vf_clear()
3942 static void be_clear_queues(struct be_adapter *adapter) in be_clear_queues() argument
3944 be_mcc_queues_destroy(adapter); in be_clear_queues()
3945 be_rx_cqs_destroy(adapter); in be_clear_queues()
3946 be_tx_queues_destroy(adapter); in be_clear_queues()
3947 be_evt_queues_destroy(adapter); in be_clear_queues()
3950 static void be_cancel_worker(struct be_adapter *adapter) in be_cancel_worker() argument
3952 if (adapter->flags & BE_FLAGS_WORKER_SCHEDULED) { in be_cancel_worker()
3953 cancel_delayed_work_sync(&adapter->work); in be_cancel_worker()
3954 adapter->flags &= ~BE_FLAGS_WORKER_SCHEDULED; in be_cancel_worker()
3958 static void be_cancel_err_detection(struct be_adapter *adapter) in be_cancel_err_detection() argument
3960 struct be_error_recovery *err_rec = &adapter->error_recovery; in be_cancel_err_detection()
3965 if (adapter->flags & BE_FLAGS_ERR_DETECTION_SCHEDULED) { in be_cancel_err_detection()
3967 adapter->flags &= ~BE_FLAGS_ERR_DETECTION_SCHEDULED; in be_cancel_err_detection()
3984 struct be_adapter *adapter = netdev_priv(netdev); in be_vxlan_set_port() local
3985 struct device *dev = &adapter->pdev->dev; in be_vxlan_set_port()
3988 status = be_cmd_manage_iface(adapter, adapter->if_handle, in be_vxlan_set_port()
3994 adapter->flags |= BE_FLAGS_VXLAN_OFFLOADS; in be_vxlan_set_port()
3996 status = be_cmd_set_vxlan_port(adapter, ti->port); in be_vxlan_set_port()
4001 adapter->vxlan_port = ti->port; in be_vxlan_set_port()
4015 struct be_adapter *adapter = netdev_priv(netdev); in be_vxlan_unset_port() local
4017 if (adapter->flags & BE_FLAGS_VXLAN_OFFLOADS) in be_vxlan_unset_port()
4018 be_cmd_manage_iface(adapter, adapter->if_handle, in be_vxlan_unset_port()
4021 if (adapter->vxlan_port) in be_vxlan_unset_port()
4022 be_cmd_set_vxlan_port(adapter, 0); in be_vxlan_unset_port()
4024 adapter->flags &= ~BE_FLAGS_VXLAN_OFFLOADS; in be_vxlan_unset_port()
4025 adapter->vxlan_port = 0; in be_vxlan_unset_port()
4041 static void be_calculate_vf_res(struct be_adapter *adapter, u16 num_vfs, in be_calculate_vf_res() argument
4044 struct be_resources res = adapter->pool_res; in be_calculate_vf_res()
4061 if (num_vfs >= be_max_pf_pool_rss_tables(adapter)) in be_calculate_vf_res()
4068 be_cmd_get_profile_config(adapter, &res_mod, NULL, ACTIVE_PROFILE_TYPE, in be_calculate_vf_res()
4117 static void be_if_destroy(struct be_adapter *adapter) in be_if_destroy() argument
4119 be_cmd_if_destroy(adapter, adapter->if_handle, 0); in be_if_destroy()
4121 kfree(adapter->pmac_id); in be_if_destroy()
4122 adapter->pmac_id = NULL; in be_if_destroy()
4124 kfree(adapter->mc_list); in be_if_destroy()
4125 adapter->mc_list = NULL; in be_if_destroy()
4127 kfree(adapter->uc_list); in be_if_destroy()
4128 adapter->uc_list = NULL; in be_if_destroy()
4131 static int be_clear(struct be_adapter *adapter) in be_clear() argument
4133 struct pci_dev *pdev = adapter->pdev; in be_clear()
4136 be_cancel_worker(adapter); in be_clear()
4140 if (sriov_enabled(adapter)) in be_clear()
4141 be_vf_clear(adapter); in be_clear()
4146 if (skyhawk_chip(adapter) && be_physfn(adapter) && in be_clear()
4148 be_calculate_vf_res(adapter, in be_clear()
4151 be_cmd_set_sriov_config(adapter, adapter->pool_res, in be_clear()
4156 be_vxlan_unset_port(adapter->netdev, 0, 0, NULL); in be_clear()
4158 be_if_destroy(adapter); in be_clear()
4160 be_clear_queues(adapter); in be_clear()
4162 be_msix_disable(adapter); in be_clear()
4163 adapter->flags &= ~BE_FLAGS_SETUP_DONE; in be_clear()
4167 static int be_vfs_if_create(struct be_adapter *adapter) in be_vfs_if_create() argument
4177 for_all_vfs(adapter, vf_cfg, vf) { in be_vfs_if_create()
4178 if (!BE3_chip(adapter)) { in be_vfs_if_create()
4179 status = be_cmd_get_profile_config(adapter, &res, NULL, in be_vfs_if_create()
4194 status = be_cmd_if_create(adapter, cap_flags, en_flags, in be_vfs_if_create()
4203 static int be_vf_setup_init(struct be_adapter *adapter) in be_vf_setup_init() argument
4208 adapter->vf_cfg = kcalloc(adapter->num_vfs, sizeof(*vf_cfg), in be_vf_setup_init()
4210 if (!adapter->vf_cfg) in be_vf_setup_init()
4213 for_all_vfs(adapter, vf_cfg, vf) { in be_vf_setup_init()
4220 static int be_vf_setup(struct be_adapter *adapter) in be_vf_setup() argument
4222 struct device *dev = &adapter->pdev->dev; in be_vf_setup()
4227 old_vfs = pci_num_vf(adapter->pdev); in be_vf_setup()
4229 status = be_vf_setup_init(adapter); in be_vf_setup()
4234 for_all_vfs(adapter, vf_cfg, vf) { in be_vf_setup()
4235 status = be_cmd_get_if_id(adapter, vf_cfg, vf); in be_vf_setup()
4240 status = be_vfs_mac_query(adapter); in be_vf_setup()
4244 status = be_vfs_if_create(adapter); in be_vf_setup()
4248 status = be_vf_eth_addr_config(adapter); in be_vf_setup()
4253 for_all_vfs(adapter, vf_cfg, vf) { in be_vf_setup()
4255 status = be_cmd_get_fn_privileges(adapter, &vf_cfg->privileges, in be_vf_setup()
4258 status = be_cmd_set_fn_privileges(adapter, in be_vf_setup()
4271 be_cmd_config_qos(adapter, 0, 0, vf + 1); in be_vf_setup()
4273 status = be_cmd_get_hsw_config(adapter, NULL, vf + 1, in be_vf_setup()
4280 be_cmd_enable_vf(adapter, vf + 1); in be_vf_setup()
4281 be_cmd_set_logical_link_config(adapter, in be_vf_setup()
4288 status = pci_enable_sriov(adapter->pdev, adapter->num_vfs); in be_vf_setup()
4291 adapter->num_vfs = 0; in be_vf_setup()
4296 if (BE3_chip(adapter)) { in be_vf_setup()
4298 status = be_cmd_set_hsw_config(adapter, 0, 0, in be_vf_setup()
4299 adapter->if_handle, in be_vf_setup()
4305 adapter->flags |= BE_FLAGS_SRIOV_ENABLED; in be_vf_setup()
4309 be_vf_clear(adapter); in be_vf_setup()
4330 static void BEx_get_resources(struct be_adapter *adapter, in BEx_get_resources() argument
4333 bool use_sriov = adapter->num_vfs ? 1 : 0; in BEx_get_resources()
4335 if (be_physfn(adapter)) in BEx_get_resources()
4340 adapter->mc_type = be_convert_mc_type(adapter->function_mode); in BEx_get_resources()
4342 if (be_is_mc(adapter)) { in BEx_get_resources()
4346 if (be_is_qnq_mode(adapter)) in BEx_get_resources()
4363 if (BE2_chip(adapter) || use_sriov || (adapter->port_num > 1) || in BEx_get_resources()
4364 be_virtfn(adapter) || in BEx_get_resources()
4365 (be_is_mc(adapter) && in BEx_get_resources()
4366 !(adapter->function_caps & BE_FUNCTION_CAPS_RSS))) { in BEx_get_resources()
4368 } else if (adapter->function_caps & BE_FUNCTION_CAPS_SUPER_NIC) { in BEx_get_resources()
4374 be_cmd_get_profile_config(adapter, &super_nic_res, NULL, in BEx_get_resources()
4383 if ((adapter->function_caps & BE_FUNCTION_CAPS_RSS) && in BEx_get_resources()
4384 !use_sriov && be_physfn(adapter)) in BEx_get_resources()
4385 res->max_rss_qs = (adapter->be3_native) ? in BEx_get_resources()
4389 if (be_physfn(adapter)) in BEx_get_resources()
4390 res->max_evt_qs = (be_max_vfs(adapter) > 0) ? in BEx_get_resources()
4397 if (!(adapter->function_caps & BE_FUNCTION_CAPS_RSS)) in BEx_get_resources()
4401 static void be_setup_init(struct be_adapter *adapter) in be_setup_init() argument
4403 adapter->vlan_prio_bmap = 0xff; in be_setup_init()
4404 adapter->phy.link_speed = -1; in be_setup_init()
4405 adapter->if_handle = -1; in be_setup_init()
4406 adapter->be3_native = false; in be_setup_init()
4407 adapter->if_flags = 0; in be_setup_init()
4408 adapter->phy_state = BE_UNKNOWN_PHY_STATE; in be_setup_init()
4409 if (be_physfn(adapter)) in be_setup_init()
4410 adapter->cmd_privileges = MAX_PRIVILEGES; in be_setup_init()
4412 adapter->cmd_privileges = MIN_PRIVILEGES; in be_setup_init()
4422 static void be_calculate_pf_pool_rss_tables(struct be_adapter *adapter) in be_calculate_pf_pool_rss_tables() argument
4426 u16 max_vfs = be_max_vfs(adapter); in be_calculate_pf_pool_rss_tables()
4428 be_cmd_get_profile_config(adapter, NULL, &port_res, SAVED_PROFILE_TYPE, in be_calculate_pf_pool_rss_tables()
4436 adapter->pool_res.max_rss_tables = in be_calculate_pf_pool_rss_tables()
4440 static int be_get_sriov_config(struct be_adapter *adapter) in be_get_sriov_config() argument
4445 be_cmd_get_profile_config(adapter, &res, NULL, ACTIVE_PROFILE_TYPE, in be_get_sriov_config()
4449 if (BE3_chip(adapter) && !res.max_vfs) { in be_get_sriov_config()
4450 max_vfs = pci_sriov_get_totalvfs(adapter->pdev); in be_get_sriov_config()
4454 adapter->pool_res = res; in be_get_sriov_config()
4460 old_vfs = pci_num_vf(adapter->pdev); in be_get_sriov_config()
4462 dev_info(&adapter->pdev->dev, "%d VFs are already enabled\n", in be_get_sriov_config()
4465 adapter->pool_res.max_vfs = in be_get_sriov_config()
4466 pci_sriov_get_totalvfs(adapter->pdev); in be_get_sriov_config()
4467 adapter->num_vfs = old_vfs; in be_get_sriov_config()
4470 if (skyhawk_chip(adapter) && be_max_vfs(adapter) && !old_vfs) { in be_get_sriov_config()
4471 be_calculate_pf_pool_rss_tables(adapter); in be_get_sriov_config()
4472 dev_info(&adapter->pdev->dev, in be_get_sriov_config()
4474 be_max_pf_pool_rss_tables(adapter)); in be_get_sriov_config()
4479 static void be_alloc_sriov_res(struct be_adapter *adapter) in be_alloc_sriov_res() argument
4481 int old_vfs = pci_num_vf(adapter->pdev); in be_alloc_sriov_res()
4485 be_get_sriov_config(adapter); in be_alloc_sriov_res()
4488 pci_sriov_set_totalvfs(adapter->pdev, be_max_vfs(adapter)); in be_alloc_sriov_res()
4495 if (skyhawk_chip(adapter) && be_max_vfs(adapter) && !old_vfs) { in be_alloc_sriov_res()
4496 be_calculate_vf_res(adapter, 0, &vft_res); in be_alloc_sriov_res()
4497 status = be_cmd_set_sriov_config(adapter, adapter->pool_res, 0, in be_alloc_sriov_res()
4500 dev_err(&adapter->pdev->dev, in be_alloc_sriov_res()
4505 static int be_get_resources(struct be_adapter *adapter) in be_get_resources() argument
4507 struct device *dev = &adapter->pdev->dev; in be_get_resources()
4515 if (BEx_chip(adapter)) { in be_get_resources()
4516 BEx_get_resources(adapter, &res); in be_get_resources()
4518 status = be_cmd_get_func_config(adapter, &res); in be_get_resources()
4529 res.max_nic_evt_qs = be_roce_supported(adapter) ? in be_get_resources()
4531 adapter->res = res; in be_get_resources()
4536 adapter->need_def_rxq = (be_if_cap_flags(adapter) & in be_get_resources()
4540 be_max_txqs(adapter), be_max_rxqs(adapter), in be_get_resources()
4541 be_max_rss(adapter), be_max_nic_eqs(adapter), in be_get_resources()
4542 be_max_vfs(adapter)); in be_get_resources()
4544 be_max_uc(adapter), be_max_mc(adapter), in be_get_resources()
4545 be_max_vlans(adapter)); in be_get_resources()
4548 adapter->cfg_num_rx_irqs = in be_get_resources()
4550 be_max_qp_irqs(adapter)); in be_get_resources()
4551 adapter->cfg_num_tx_irqs = adapter->cfg_num_rx_irqs; in be_get_resources()
4555 static int be_get_config(struct be_adapter *adapter) in be_get_config() argument
4560 status = be_cmd_get_cntl_attributes(adapter); in be_get_config()
4564 status = be_cmd_query_fw_cfg(adapter); in be_get_config()
4568 if (!lancer_chip(adapter) && be_physfn(adapter)) in be_get_config()
4569 be_cmd_get_fat_dump_len(adapter, &adapter->fat_dump_len); in be_get_config()
4571 if (BEx_chip(adapter)) { in be_get_config()
4572 level = be_cmd_get_fw_log_level(adapter); in be_get_config()
4573 adapter->msg_enable = in be_get_config()
4577 be_cmd_get_acpi_wol_cap(adapter); in be_get_config()
4578 pci_enable_wake(adapter->pdev, PCI_D3hot, adapter->wol_en); in be_get_config()
4579 pci_enable_wake(adapter->pdev, PCI_D3cold, adapter->wol_en); in be_get_config()
4581 be_cmd_query_port_name(adapter); in be_get_config()
4583 if (be_physfn(adapter)) { in be_get_config()
4584 status = be_cmd_get_active_profile(adapter, &profile_id); in be_get_config()
4586 dev_info(&adapter->pdev->dev, in be_get_config()
4593 static int be_mac_setup(struct be_adapter *adapter) in be_mac_setup() argument
4598 if (is_zero_ether_addr(adapter->netdev->dev_addr)) { in be_mac_setup()
4599 status = be_cmd_get_perm_mac(adapter, mac); in be_mac_setup()
4603 eth_hw_addr_set(adapter->netdev, mac); in be_mac_setup()
4604 memcpy(adapter->netdev->perm_addr, mac, ETH_ALEN); in be_mac_setup()
4607 if (BEx_chip(adapter) && be_virtfn(adapter)) in be_mac_setup()
4608 memcpy(adapter->dev_mac, mac, ETH_ALEN); in be_mac_setup()
4614 static void be_schedule_worker(struct be_adapter *adapter) in be_schedule_worker() argument
4616 queue_delayed_work(be_wq, &adapter->work, msecs_to_jiffies(1000)); in be_schedule_worker()
4617 adapter->flags |= BE_FLAGS_WORKER_SCHEDULED; in be_schedule_worker()
4629 static void be_schedule_err_detection(struct be_adapter *adapter, u32 delay) in be_schedule_err_detection() argument
4631 struct be_error_recovery *err_rec = &adapter->error_recovery; in be_schedule_err_detection()
4638 adapter->flags |= BE_FLAGS_ERR_DETECTION_SCHEDULED; in be_schedule_err_detection()
4641 static int be_setup_queues(struct be_adapter *adapter) in be_setup_queues() argument
4643 struct net_device *netdev = adapter->netdev; in be_setup_queues()
4646 status = be_evt_queues_create(adapter); in be_setup_queues()
4650 status = be_tx_qs_create(adapter); in be_setup_queues()
4654 status = be_rx_cqs_create(adapter); in be_setup_queues()
4658 status = be_mcc_queues_create(adapter); in be_setup_queues()
4662 status = netif_set_real_num_rx_queues(netdev, adapter->num_rx_qs); in be_setup_queues()
4666 status = netif_set_real_num_tx_queues(netdev, adapter->num_tx_qs); in be_setup_queues()
4672 dev_err(&adapter->pdev->dev, "queue_setup failed\n"); in be_setup_queues()
4676 static int be_if_create(struct be_adapter *adapter) in be_if_create() argument
4679 u32 cap_flags = be_if_cap_flags(adapter); in be_if_create()
4682 adapter->pmac_id = kcalloc(be_max_uc(adapter), in be_if_create()
4683 sizeof(*adapter->pmac_id), GFP_KERNEL); in be_if_create()
4684 if (!adapter->pmac_id) in be_if_create()
4687 adapter->mc_list = kcalloc(be_max_mc(adapter), in be_if_create()
4688 sizeof(*adapter->mc_list), GFP_KERNEL); in be_if_create()
4689 if (!adapter->mc_list) in be_if_create()
4692 adapter->uc_list = kcalloc(be_max_uc(adapter), in be_if_create()
4693 sizeof(*adapter->uc_list), GFP_KERNEL); in be_if_create()
4694 if (!adapter->uc_list) in be_if_create()
4697 if (adapter->cfg_num_rx_irqs == 1) in be_if_create()
4702 return be_cmd_if_create(adapter, be_if_cap_flags(adapter), en_flags, in be_if_create()
4703 &adapter->if_handle, 0); in be_if_create()
4706 int be_update_queues(struct be_adapter *adapter) in be_update_queues() argument
4708 struct net_device *netdev = adapter->netdev; in be_update_queues()
4723 be_cancel_worker(adapter); in be_update_queues()
4728 if (!adapter->num_msix_roce_vec) in be_update_queues()
4729 be_msix_disable(adapter); in be_update_queues()
4731 be_clear_queues(adapter); in be_update_queues()
4732 status = be_cmd_if_destroy(adapter, adapter->if_handle, 0); in be_update_queues()
4736 if (!msix_enabled(adapter)) { in be_update_queues()
4737 status = be_msix_enable(adapter); in be_update_queues()
4742 status = be_if_create(adapter); in be_update_queues()
4746 status = be_setup_queues(adapter); in be_update_queues()
4750 be_schedule_worker(adapter); in be_update_queues()
4758 adapter->if_flags &= ~BE_IF_FLAGS_ALL_PROMISCUOUS; in be_update_queues()
4780 static bool be_reset_required(struct be_adapter *adapter) in be_reset_required() argument
4782 if (be_error_recovering(adapter)) in be_reset_required()
4785 return pci_num_vf(adapter->pdev) == 0; in be_reset_required()
4789 static int be_func_init(struct be_adapter *adapter) in be_func_init() argument
4793 status = be_fw_wait_ready(adapter); in be_func_init()
4798 be_clear_error(adapter, BE_CLEAR_ALL); in be_func_init()
4800 if (be_reset_required(adapter)) { in be_func_init()
4801 status = be_cmd_reset_function(adapter); in be_func_init()
4810 status = be_cmd_fw_init(adapter); in be_func_init()
4815 be_intr_set(adapter, true); in be_func_init()
4820 static int be_setup(struct be_adapter *adapter) in be_setup() argument
4822 struct device *dev = &adapter->pdev->dev; in be_setup()
4825 status = be_func_init(adapter); in be_setup()
4829 be_setup_init(adapter); in be_setup()
4831 if (!lancer_chip(adapter)) in be_setup()
4832 be_cmd_req_native_mode(adapter); in be_setup()
4837 if (!BEx_chip(adapter)) { in be_setup()
4838 status = be_cmd_get_func_config(adapter, NULL); in be_setup()
4843 status = be_get_config(adapter); in be_setup()
4847 if (!BE2_chip(adapter) && be_physfn(adapter)) in be_setup()
4848 be_alloc_sriov_res(adapter); in be_setup()
4850 status = be_get_resources(adapter); in be_setup()
4854 status = be_msix_enable(adapter); in be_setup()
4859 status = be_if_create(adapter); in be_setup()
4865 status = be_setup_queues(adapter); in be_setup()
4870 be_cmd_get_fn_privileges(adapter, &adapter->cmd_privileges, 0); in be_setup()
4872 status = be_mac_setup(adapter); in be_setup()
4876 be_cmd_get_fw_ver(adapter); in be_setup()
4877 dev_info(dev, "FW version is %s\n", adapter->fw_ver); in be_setup()
4879 if (BE2_chip(adapter) && fw_major_num(adapter->fw_ver) < 4) { in be_setup()
4881 adapter->fw_ver); in be_setup()
4885 status = be_cmd_set_flow_control(adapter, adapter->tx_fc, in be_setup()
4886 adapter->rx_fc); in be_setup()
4888 be_cmd_get_flow_control(adapter, &adapter->tx_fc, in be_setup()
4889 &adapter->rx_fc); in be_setup()
4891 dev_info(&adapter->pdev->dev, "HW Flow control - TX:%d RX:%d\n", in be_setup()
4892 adapter->tx_fc, adapter->rx_fc); in be_setup()
4894 if (be_physfn(adapter)) in be_setup()
4895 be_cmd_set_logical_link_config(adapter, in be_setup()
4903 if (BE3_chip(adapter)) in be_setup()
4904 be_cmd_set_hsw_config(adapter, 0, 0, adapter->if_handle, in be_setup()
4907 if (adapter->num_vfs) in be_setup()
4908 be_vf_setup(adapter); in be_setup()
4910 status = be_cmd_get_phy_info(adapter); in be_setup()
4911 if (!status && be_pause_supported(adapter)) in be_setup()
4912 adapter->phy.fc_autoneg = 1; in be_setup()
4914 if (be_physfn(adapter) && !lancer_chip(adapter)) in be_setup()
4915 be_cmd_set_features(adapter); in be_setup()
4917 be_schedule_worker(adapter); in be_setup()
4918 adapter->flags |= BE_FLAGS_SETUP_DONE; in be_setup()
4921 be_clear(adapter); in be_setup()
4928 struct be_adapter *adapter = netdev_priv(netdev); in be_netpoll() local
4932 for_all_evt_queues(adapter, eqo, i) { in be_netpoll()
4933 be_eq_notify(eqo->adapter, eqo->q.id, false, true, 0, 0); in be_netpoll()
4939 int be_load_fw(struct be_adapter *adapter, u8 *fw_file) in be_load_fw() argument
4944 if (!netif_running(adapter->netdev)) { in be_load_fw()
4945 dev_err(&adapter->pdev->dev, in be_load_fw()
4950 status = request_firmware(&fw, fw_file, &adapter->pdev->dev); in be_load_fw()
4954 dev_info(&adapter->pdev->dev, "Flashing firmware file %s\n", fw_file); in be_load_fw()
4956 if (lancer_chip(adapter)) in be_load_fw()
4957 status = lancer_fw_download(adapter, fw); in be_load_fw()
4959 status = be_fw_download(adapter, fw); in be_load_fw()
4962 be_cmd_get_fw_ver(adapter); in be_load_fw()
4972 struct be_adapter *adapter = netdev_priv(dev); in be_ndo_bridge_setlink() local
4978 if (!sriov_enabled(adapter)) in be_ndo_bridge_setlink()
4987 if (BE3_chip(adapter) && mode == BRIDGE_MODE_VEPA) in be_ndo_bridge_setlink()
4993 status = be_cmd_set_hsw_config(adapter, 0, 0, in be_ndo_bridge_setlink()
4994 adapter->if_handle, in be_ndo_bridge_setlink()
5001 dev_info(&adapter->pdev->dev, "enabled switch mode: %s\n", in be_ndo_bridge_setlink()
5007 dev_err(&adapter->pdev->dev, "Failed to set switch mode %s\n", in be_ndo_bridge_setlink()
5017 struct be_adapter *adapter = netdev_priv(dev); in be_ndo_bridge_getlink() local
5022 if (BEx_chip(adapter) || lancer_chip(adapter)) { in be_ndo_bridge_getlink()
5024 if (!pci_sriov_get_totalvfs(adapter->pdev)) in be_ndo_bridge_getlink()
5028 status = be_cmd_get_hsw_config(adapter, NULL, 0, in be_ndo_bridge_getlink()
5029 adapter->if_handle, &hsw_mode, in be_ndo_bridge_getlink()
5044 static struct be_cmd_work *be_alloc_work(struct be_adapter *adapter, in be_alloc_work() argument
5051 dev_err(&adapter->pdev->dev, in be_alloc_work()
5057 work->adapter = adapter; in be_alloc_work()
5065 struct be_adapter *adapter = netdev_priv(dev); in be_features_check() local
5072 if (!skyhawk_chip(adapter) && is_ipv6_ext_hdr(skb)) in be_features_check()
5079 if (lancer_chip(adapter) && in be_features_check()
5091 !(adapter->flags & BE_FLAGS_VXLAN_OFFLOADS)) in be_features_check()
5116 !adapter->vxlan_port || in be_features_check()
5117 udp_hdr(skb)->dest != adapter->vxlan_port) in be_features_check()
5127 struct be_adapter *adapter = netdev_priv(dev); in be_get_phys_port_id() local
5133 ppid->id[0] = adapter->hba_port_num + 1; in be_get_phys_port_id()
5137 memcpy(id, &adapter->serial_num[i], CNTL_SERIAL_NUM_WORD_SZ); in be_get_phys_port_id()
5146 struct be_adapter *adapter = netdev_priv(dev); in be_set_rx_mode() local
5149 work = be_alloc_work(adapter, be_work_set_rx_mode); in be_set_rx_mode()
5182 struct be_adapter *adapter = netdev_priv(netdev); in be_netdev_init() local
5188 if ((be_if_cap_flags(adapter) & BE_IF_FLAGS_RSS)) in be_netdev_init()
5208 if (!lancer_chip(adapter) && !BEx_chip(adapter) && !be_is_mc(adapter)) in be_netdev_init()
5216 static void be_cleanup(struct be_adapter *adapter) in be_cleanup() argument
5218 struct net_device *netdev = adapter->netdev; in be_cleanup()
5226 be_clear(adapter); in be_cleanup()
5229 static int be_resume(struct be_adapter *adapter) in be_resume() argument
5231 struct net_device *netdev = adapter->netdev; in be_resume()
5234 status = be_setup(adapter); in be_resume()
5251 static void be_soft_reset(struct be_adapter *adapter) in be_soft_reset() argument
5255 dev_info(&adapter->pdev->dev, "Initiating chip soft reset\n"); in be_soft_reset()
5256 val = ioread32(adapter->pcicfg + SLIPORT_SOFTRESET_OFFSET); in be_soft_reset()
5258 iowrite32(val, adapter->pcicfg + SLIPORT_SOFTRESET_OFFSET); in be_soft_reset()
5261 static bool be_err_is_recoverable(struct be_adapter *adapter) in be_err_is_recoverable() argument
5263 struct be_error_recovery *err_rec = &adapter->error_recovery; in be_err_is_recoverable()
5271 val = be_POST_stage_get(adapter); in be_err_is_recoverable()
5278 dev_err(&adapter->pdev->dev, "Recoverable HW error code: 0x%x\n", in be_err_is_recoverable()
5282 dev_err(&adapter->pdev->dev, in be_err_is_recoverable()
5290 dev_err(&adapter->pdev->dev, in be_err_is_recoverable()
5297 dev_err(&adapter->pdev->dev, in be_err_is_recoverable()
5307 static int be_tpe_recover(struct be_adapter *adapter) in be_tpe_recover() argument
5309 struct be_error_recovery *err_rec = &adapter->error_recovery; in be_tpe_recover()
5320 val = be_POST_stage_get(adapter); in be_tpe_recover()
5323 dev_err(&adapter->pdev->dev, in be_tpe_recover()
5330 dev_err(&adapter->pdev->dev, "Recoverable HW error detected\n"); in be_tpe_recover()
5337 if (adapter->pf_num == 0) { in be_tpe_recover()
5350 if (!be_err_is_recoverable(adapter)) { in be_tpe_recover()
5351 dev_err(&adapter->pdev->dev, in be_tpe_recover()
5357 be_soft_reset(adapter); in be_tpe_recover()
5378 static int be_err_recover(struct be_adapter *adapter) in be_err_recover() argument
5382 if (!lancer_chip(adapter)) { in be_err_recover()
5383 if (!adapter->error_recovery.recovery_supported || in be_err_recover()
5384 adapter->priv_flags & BE_DISABLE_TPE_RECOVERY) in be_err_recover()
5386 status = be_tpe_recover(adapter); in be_err_recover()
5391 /* Wait for adapter to reach quiescent state before in be_err_recover()
5394 status = be_fw_wait_ready(adapter); in be_err_recover()
5398 adapter->flags |= BE_FLAGS_TRY_RECOVERY; in be_err_recover()
5400 be_cleanup(adapter); in be_err_recover()
5402 status = be_resume(adapter); in be_err_recover()
5406 adapter->flags &= ~BE_FLAGS_TRY_RECOVERY; in be_err_recover()
5417 struct be_adapter *adapter = in be_err_detection_task() local
5421 struct device *dev = &adapter->pdev->dev; in be_err_detection_task()
5424 be_detect_error(adapter); in be_err_detection_task()
5425 if (!be_check_error(adapter, BE_ERROR_HW)) in be_err_detection_task()
5428 recovery_status = be_err_recover(adapter); in be_err_detection_task()
5432 dev_info(dev, "Adapter recovery successful\n"); in be_err_detection_task()
5434 } else if (!lancer_chip(adapter) && err_rec->resched_delay) { in be_err_detection_task()
5436 if (adapter->pf_num == 0 && in be_err_detection_task()
5438 dev_err(&adapter->pdev->dev, in be_err_detection_task()
5439 "Adapter recovery in progress\n"); in be_err_detection_task()
5442 } else if (lancer_chip(adapter) && be_virtfn(adapter)) { in be_err_detection_task()
5446 dev_err(dev, "Re-trying adapter recovery\n"); in be_err_detection_task()
5448 } else if (lancer_chip(adapter) && err_rec->recovery_retries++ < in be_err_detection_task()
5451 * for adapter to come out of error. Retry error recovery after in be_err_detection_task()
5454 dev_err(&adapter->pdev->dev, "Re-trying adapter recovery\n"); in be_err_detection_task()
5458 dev_err(dev, "Adapter recovery failed\n"); in be_err_detection_task()
5465 be_schedule_err_detection(adapter, resched_delay); in be_err_detection_task()
5468 static void be_log_sfp_info(struct be_adapter *adapter) in be_log_sfp_info() argument
5472 status = be_cmd_query_sfp_info(adapter); in be_log_sfp_info()
5474 dev_err(&adapter->pdev->dev, in be_log_sfp_info()
5476 adapter->port_name, in be_log_sfp_info()
5477 be_misconfig_evt_port_state[adapter->phy_state], in be_log_sfp_info()
5478 adapter->phy.vendor_name, in be_log_sfp_info()
5479 adapter->phy.vendor_pn); in be_log_sfp_info()
5481 adapter->flags &= ~BE_FLAGS_PHY_MISCONFIGURED; in be_log_sfp_info()
5486 struct be_adapter *adapter = in be_worker() local
5491 if (be_physfn(adapter) && in be_worker()
5492 MODULO(adapter->work_counter, adapter->be_get_temp_freq) == 0) in be_worker()
5493 be_cmd_get_die_temperature(adapter); in be_worker()
5498 if (!netif_running(adapter->netdev)) { in be_worker()
5500 be_process_mcc(adapter); in be_worker()
5505 if (!adapter->stats_cmd_sent) { in be_worker()
5506 if (lancer_chip(adapter)) in be_worker()
5507 lancer_cmd_get_pport_stats(adapter, in be_worker()
5508 &adapter->stats_cmd); in be_worker()
5510 be_cmd_get_stats(adapter, &adapter->stats_cmd); in be_worker()
5513 for_all_rx_queues(adapter, rxo, i) { in be_worker()
5522 if (!skyhawk_chip(adapter)) in be_worker()
5523 be_eqd_update(adapter, false); in be_worker()
5525 if (adapter->flags & BE_FLAGS_PHY_MISCONFIGURED) in be_worker()
5526 be_log_sfp_info(adapter); in be_worker()
5529 adapter->work_counter++; in be_worker()
5530 queue_delayed_work(be_wq, &adapter->work, msecs_to_jiffies(1000)); in be_worker()
5533 static void be_unmap_pci_bars(struct be_adapter *adapter) in be_unmap_pci_bars() argument
5535 if (adapter->csr) in be_unmap_pci_bars()
5536 pci_iounmap(adapter->pdev, adapter->csr); in be_unmap_pci_bars()
5537 if (adapter->db) in be_unmap_pci_bars()
5538 pci_iounmap(adapter->pdev, adapter->db); in be_unmap_pci_bars()
5539 if (adapter->pcicfg && adapter->pcicfg_mapped) in be_unmap_pci_bars()
5540 pci_iounmap(adapter->pdev, adapter->pcicfg); in be_unmap_pci_bars()
5543 static int db_bar(struct be_adapter *adapter) in db_bar() argument
5545 if (lancer_chip(adapter) || be_virtfn(adapter)) in db_bar()
5551 static int be_roce_map_pci_bars(struct be_adapter *adapter) in be_roce_map_pci_bars() argument
5553 if (skyhawk_chip(adapter)) { in be_roce_map_pci_bars()
5554 adapter->roce_db.size = 4096; in be_roce_map_pci_bars()
5555 adapter->roce_db.io_addr = pci_resource_start(adapter->pdev, in be_roce_map_pci_bars()
5556 db_bar(adapter)); in be_roce_map_pci_bars()
5557 adapter->roce_db.total_size = pci_resource_len(adapter->pdev, in be_roce_map_pci_bars()
5558 db_bar(adapter)); in be_roce_map_pci_bars()
5563 static int be_map_pci_bars(struct be_adapter *adapter) in be_map_pci_bars() argument
5565 struct pci_dev *pdev = adapter->pdev; in be_map_pci_bars()
5569 pci_read_config_dword(adapter->pdev, SLI_INTF_REG_OFFSET, &sli_intf); in be_map_pci_bars()
5570 adapter->sli_family = (sli_intf & SLI_INTF_FAMILY_MASK) >> in be_map_pci_bars()
5572 adapter->virtfn = (sli_intf & SLI_INTF_FT_MASK) ? 1 : 0; in be_map_pci_bars()
5574 if (BEx_chip(adapter) && be_physfn(adapter)) { in be_map_pci_bars()
5575 adapter->csr = pci_iomap(pdev, 2, 0); in be_map_pci_bars()
5576 if (!adapter->csr) in be_map_pci_bars()
5580 addr = pci_iomap(pdev, db_bar(adapter), 0); in be_map_pci_bars()
5583 adapter->db = addr; in be_map_pci_bars()
5585 if (skyhawk_chip(adapter) || BEx_chip(adapter)) { in be_map_pci_bars()
5586 if (be_physfn(adapter)) { in be_map_pci_bars()
5588 addr = pci_iomap(pdev, BE2_chip(adapter) ? 1 : 0, 0); in be_map_pci_bars()
5591 adapter->pcicfg = addr; in be_map_pci_bars()
5592 adapter->pcicfg_mapped = true; in be_map_pci_bars()
5594 adapter->pcicfg = adapter->db + SRIOV_VF_PCICFG_OFFSET; in be_map_pci_bars()
5595 adapter->pcicfg_mapped = false; in be_map_pci_bars()
5599 be_roce_map_pci_bars(adapter); in be_map_pci_bars()
5604 be_unmap_pci_bars(adapter); in be_map_pci_bars()
5608 static void be_drv_cleanup(struct be_adapter *adapter) in be_drv_cleanup() argument
5610 struct be_dma_mem *mem = &adapter->mbox_mem_alloced; in be_drv_cleanup()
5611 struct device *dev = &adapter->pdev->dev; in be_drv_cleanup()
5616 mem = &adapter->rx_filter; in be_drv_cleanup()
5620 mem = &adapter->stats_cmd; in be_drv_cleanup()
5626 static int be_drv_init(struct be_adapter *adapter) in be_drv_init() argument
5628 struct be_dma_mem *mbox_mem_alloc = &adapter->mbox_mem_alloced; in be_drv_init()
5629 struct be_dma_mem *mbox_mem_align = &adapter->mbox_mem; in be_drv_init()
5630 struct be_dma_mem *rx_filter = &adapter->rx_filter; in be_drv_init()
5631 struct be_dma_mem *stats_cmd = &adapter->stats_cmd; in be_drv_init()
5632 struct device *dev = &adapter->pdev->dev; in be_drv_init()
5654 if (lancer_chip(adapter)) in be_drv_init()
5656 else if (BE2_chip(adapter)) in be_drv_init()
5658 else if (BE3_chip(adapter)) in be_drv_init()
5669 mutex_init(&adapter->mbox_lock); in be_drv_init()
5670 mutex_init(&adapter->mcc_lock); in be_drv_init()
5671 mutex_init(&adapter->rx_filter_lock); in be_drv_init()
5672 spin_lock_init(&adapter->mcc_cq_lock); in be_drv_init()
5673 init_completion(&adapter->et_cmd_compl); in be_drv_init()
5675 pci_save_state(adapter->pdev); in be_drv_init()
5677 INIT_DELAYED_WORK(&adapter->work, be_worker); in be_drv_init()
5679 adapter->error_recovery.recovery_state = ERR_RECOVERY_ST_NONE; in be_drv_init()
5680 adapter->error_recovery.resched_delay = 0; in be_drv_init()
5681 INIT_DELAYED_WORK(&adapter->error_recovery.err_detection_work, in be_drv_init()
5684 adapter->rx_fc = true; in be_drv_init()
5685 adapter->tx_fc = true; in be_drv_init()
5688 adapter->be_get_temp_freq = 64; in be_drv_init()
5702 struct be_adapter *adapter = pci_get_drvdata(pdev); in be_remove() local
5704 if (!adapter) in be_remove()
5707 be_roce_dev_remove(adapter); in be_remove()
5708 be_intr_set(adapter, false); in be_remove()
5710 be_cancel_err_detection(adapter); in be_remove()
5712 unregister_netdev(adapter->netdev); in be_remove()
5714 be_clear(adapter); in be_remove()
5716 if (!pci_vfs_assigned(adapter->pdev)) in be_remove()
5717 be_cmd_reset_function(adapter); in be_remove()
5720 be_cmd_fw_clean(adapter); in be_remove()
5722 be_unmap_pci_bars(adapter); in be_remove()
5723 be_drv_cleanup(adapter); in be_remove()
5728 free_netdev(adapter->netdev); in be_remove()
5735 struct be_adapter *adapter = dev_get_drvdata(dev); in be_hwmon_show_temp() local
5738 if (adapter->hwmon_info.be_on_die_temp == BE_INVALID_DIE_TEMP) in be_hwmon_show_temp()
5742 adapter->hwmon_info.be_on_die_temp * 1000); in be_hwmon_show_temp()
5755 static char *mc_name(struct be_adapter *adapter) in mc_name() argument
5759 switch (adapter->mc_type) { in mc_name()
5785 static inline char *func_name(struct be_adapter *adapter) in func_name() argument
5787 return be_physfn(adapter) ? "PF" : "VF"; in func_name()
5812 struct be_adapter *adapter; in be_probe() local
5825 netdev = alloc_etherdev_mqs(sizeof(*adapter), MAX_TX_QS, MAX_RX_QS); in be_probe()
5830 adapter = netdev_priv(netdev); in be_probe()
5831 adapter->pdev = pdev; in be_probe()
5832 pci_set_drvdata(pdev, adapter); in be_probe()
5833 adapter->netdev = netdev; in be_probe()
5842 status = be_map_pci_bars(adapter); in be_probe()
5846 status = be_drv_init(adapter); in be_probe()
5850 status = be_setup(adapter); in be_probe()
5859 be_roce_dev_add(adapter); in be_probe()
5861 be_schedule_err_detection(adapter, ERR_DETECTION_DELAY); in be_probe()
5862 adapter->error_recovery.probe_time = jiffies; in be_probe()
5865 if (be_physfn(adapter) && IS_ENABLED(CONFIG_BE2NET_HWMON)) { in be_probe()
5866 adapter->hwmon_info.hwmon_dev = in be_probe()
5869 adapter, in be_probe()
5871 adapter->hwmon_info.be_on_die_temp = BE_INVALID_DIE_TEMP; in be_probe()
5875 func_name(adapter), mc_name(adapter), adapter->port_name); in be_probe()
5880 be_clear(adapter); in be_probe()
5882 be_drv_cleanup(adapter); in be_probe()
5884 be_unmap_pci_bars(adapter); in be_probe()
5898 struct be_adapter *adapter = dev_get_drvdata(dev_d); in be_suspend() local
5900 be_intr_set(adapter, false); in be_suspend()
5901 be_cancel_err_detection(adapter); in be_suspend()
5903 be_cleanup(adapter); in be_suspend()
5910 struct be_adapter *adapter = dev_get_drvdata(dev_d); in be_pci_resume() local
5913 status = be_resume(adapter); in be_pci_resume()
5917 be_schedule_err_detection(adapter, ERR_DETECTION_DELAY); in be_pci_resume()
5927 struct be_adapter *adapter = pci_get_drvdata(pdev); in be_shutdown() local
5929 if (!adapter) in be_shutdown()
5932 be_roce_dev_shutdown(adapter); in be_shutdown()
5933 cancel_delayed_work_sync(&adapter->work); in be_shutdown()
5934 be_cancel_err_detection(adapter); in be_shutdown()
5936 netif_device_detach(adapter->netdev); in be_shutdown()
5938 be_cmd_reset_function(adapter); in be_shutdown()
5946 struct be_adapter *adapter = pci_get_drvdata(pdev); in be_eeh_err_detected() local
5948 dev_err(&adapter->pdev->dev, "EEH error detected\n"); in be_eeh_err_detected()
5950 be_roce_dev_remove(adapter); in be_eeh_err_detected()
5952 if (!be_check_error(adapter, BE_ERROR_EEH)) { in be_eeh_err_detected()
5953 be_set_error(adapter, BE_ERROR_EEH); in be_eeh_err_detected()
5955 be_cancel_err_detection(adapter); in be_eeh_err_detected()
5957 be_cleanup(adapter); in be_eeh_err_detected()
5969 * adapter. in be_eeh_err_detected()
5979 struct be_adapter *adapter = pci_get_drvdata(pdev); in be_eeh_reset() local
5982 dev_info(&adapter->pdev->dev, "EEH reset\n"); in be_eeh_reset()
5992 dev_info(&adapter->pdev->dev, in be_eeh_reset()
5994 status = be_fw_wait_ready(adapter); in be_eeh_reset()
5998 be_clear_error(adapter, BE_CLEAR_ALL); in be_eeh_reset()
6005 struct be_adapter *adapter = pci_get_drvdata(pdev); in be_eeh_resume() local
6007 dev_info(&adapter->pdev->dev, "EEH resume\n"); in be_eeh_resume()
6011 status = be_resume(adapter); in be_eeh_resume()
6015 be_roce_dev_add(adapter); in be_eeh_resume()
6017 be_schedule_err_detection(adapter, ERR_DETECTION_DELAY); in be_eeh_resume()
6020 dev_err(&adapter->pdev->dev, "EEH resume failed\n"); in be_eeh_resume()
6025 struct be_adapter *adapter = pci_get_drvdata(pdev); in be_pci_sriov_configure() local
6030 be_vf_clear(adapter); in be_pci_sriov_configure()
6032 adapter->num_vfs = num_vfs; in be_pci_sriov_configure()
6034 if (adapter->num_vfs == 0 && pci_vfs_assigned(pdev)) { in be_pci_sriov_configure()
6048 if (skyhawk_chip(adapter) && !pci_num_vf(pdev)) { in be_pci_sriov_configure()
6049 be_calculate_vf_res(adapter, adapter->num_vfs, in be_pci_sriov_configure()
6051 status = be_cmd_set_sriov_config(adapter, adapter->pool_res, in be_pci_sriov_configure()
6052 adapter->num_vfs, &vft_res); in be_pci_sriov_configure()
6058 status = be_get_resources(adapter); in be_pci_sriov_configure()
6064 status = be_update_queues(adapter); in be_pci_sriov_configure()
6069 if (adapter->num_vfs) in be_pci_sriov_configure()
6070 status = be_vf_setup(adapter); in be_pci_sriov_configure()
6073 return adapter->num_vfs; in be_pci_sriov_configure()