Lines Matching refs:bp
308 static void bnxt_db_nq(struct bnxt *bp, struct bnxt_db_info *db, u32 idx) in bnxt_db_nq() argument
310 if (bp->flags & BNXT_FLAG_CHIP_P5) in bnxt_db_nq()
316 static void bnxt_db_nq_arm(struct bnxt *bp, struct bnxt_db_info *db, u32 idx) in bnxt_db_nq_arm() argument
318 if (bp->flags & BNXT_FLAG_CHIP_P5) in bnxt_db_nq_arm()
324 static void bnxt_db_cq(struct bnxt *bp, struct bnxt_db_info *db, u32 idx) in bnxt_db_cq() argument
326 if (bp->flags & BNXT_FLAG_CHIP_P5) in bnxt_db_cq()
365 static void bnxt_txr_db_kick(struct bnxt *bp, struct bnxt_tx_ring_info *txr, in bnxt_txr_db_kick() argument
368 bnxt_db_write(bp, &txr->tx_db, prod); in bnxt_txr_db_kick()
372 static bool bnxt_txr_netif_try_stop_queue(struct bnxt *bp, in bnxt_txr_netif_try_stop_queue() argument
384 if (bnxt_tx_avail(bp, txr) >= bp->tx_wake_thresh) { in bnxt_txr_netif_try_stop_queue()
394 struct bnxt *bp = netdev_priv(dev); in bnxt_start_xmit() local
403 struct pci_dev *pdev = bp->pdev; in bnxt_start_xmit()
408 if (unlikely(i >= bp->tx_nr_rings)) { in bnxt_start_xmit()
415 txr = &bp->tx_ring[bp->tx_ring_map[i]]; in bnxt_start_xmit()
418 free_size = bnxt_tx_avail(bp, txr); in bnxt_start_xmit()
422 netif_warn(bp, tx_err, dev, in bnxt_start_xmit()
424 if (bnxt_txr_netif_try_stop_queue(bp, txr, txq)) in bnxt_start_xmit()
452 if (free_size == bp->tx_ring_size && length <= bp->tx_push_thresh) { in bnxt_start_xmit()
621 bnxt_txr_db_kick(bp, txr, prod); in bnxt_start_xmit()
627 if (unlikely(bnxt_tx_avail(bp, txr) <= MAX_SKB_FRAGS + 1)) { in bnxt_start_xmit()
629 bnxt_txr_db_kick(bp, txr, prod); in bnxt_start_xmit()
631 bnxt_txr_netif_try_stop_queue(bp, txr, txq); in bnxt_start_xmit()
658 bnxt_txr_db_kick(bp, txr, txr->tx_prod); in bnxt_start_xmit()
664 static void bnxt_tx_int(struct bnxt *bp, struct bnxt_napi *bnapi, int nr_pkts) in bnxt_tx_int() argument
667 struct netdev_queue *txq = netdev_get_tx_queue(bp->dev, txr->txq_index); in bnxt_tx_int()
669 struct pci_dev *pdev = bp->pdev; in bnxt_tx_int()
720 bnxt_tx_avail(bp, txr) >= bp->tx_wake_thresh && in bnxt_tx_int()
725 static struct page *__bnxt_alloc_rx_page(struct bnxt *bp, dma_addr_t *mapping, in __bnxt_alloc_rx_page() argument
729 struct device *dev = &bp->pdev->dev; in __bnxt_alloc_rx_page()
736 *mapping = dma_map_page_attrs(dev, page, 0, PAGE_SIZE, bp->rx_dir, in __bnxt_alloc_rx_page()
742 *mapping += bp->rx_dma_offset; in __bnxt_alloc_rx_page()
746 static inline u8 *__bnxt_alloc_rx_data(struct bnxt *bp, dma_addr_t *mapping, in __bnxt_alloc_rx_data() argument
750 struct pci_dev *pdev = bp->pdev; in __bnxt_alloc_rx_data()
752 data = kmalloc(bp->rx_buf_size, gfp); in __bnxt_alloc_rx_data()
756 *mapping = dma_map_single_attrs(&pdev->dev, data + bp->rx_dma_offset, in __bnxt_alloc_rx_data()
757 bp->rx_buf_use_size, bp->rx_dir, in __bnxt_alloc_rx_data()
767 int bnxt_alloc_rx_data(struct bnxt *bp, struct bnxt_rx_ring_info *rxr, in bnxt_alloc_rx_data() argument
774 if (BNXT_RX_PAGE_MODE(bp)) { in bnxt_alloc_rx_data()
776 __bnxt_alloc_rx_page(bp, &mapping, rxr, gfp); in bnxt_alloc_rx_data()
782 rx_buf->data_ptr = page_address(page) + bp->rx_offset; in bnxt_alloc_rx_data()
784 u8 *data = __bnxt_alloc_rx_data(bp, &mapping, gfp); in bnxt_alloc_rx_data()
790 rx_buf->data_ptr = data + bp->rx_offset; in bnxt_alloc_rx_data()
828 static inline int bnxt_alloc_rx_page(struct bnxt *bp, in bnxt_alloc_rx_page() argument
835 struct pci_dev *pdev = bp->pdev; in bnxt_alloc_rx_page()
885 static struct rx_agg_cmp *bnxt_get_agg(struct bnxt *bp, in bnxt_get_agg() argument
897 static struct rx_agg_cmp *bnxt_get_tpa_agg_p5(struct bnxt *bp, in bnxt_get_tpa_agg_p5() argument
910 struct bnxt *bp = bnapi->bp; in bnxt_reuse_rx_agg_bufs() local
917 if ((bp->flags & BNXT_FLAG_CHIP_P5) && tpa) in bnxt_reuse_rx_agg_bufs()
928 agg = bnxt_get_tpa_agg_p5(bp, rxr, idx, start + i); in bnxt_reuse_rx_agg_bufs()
930 agg = bnxt_get_agg(bp, cpr, idx, start + i); in bnxt_reuse_rx_agg_bufs()
963 static struct sk_buff *bnxt_rx_page_skb(struct bnxt *bp, in bnxt_rx_page_skb() argument
977 err = bnxt_alloc_rx_data(bp, rxr, prod, GFP_ATOMIC); in bnxt_rx_page_skb()
982 dma_addr -= bp->rx_dma_offset; in bnxt_rx_page_skb()
983 dma_unmap_page_attrs(&bp->pdev->dev, dma_addr, PAGE_SIZE, bp->rx_dir, in bnxt_rx_page_skb()
988 payload = eth_get_headlen(bp->dev, data_ptr, len); in bnxt_rx_page_skb()
1010 static struct sk_buff *bnxt_rx_skb(struct bnxt *bp, in bnxt_rx_skb() argument
1020 err = bnxt_alloc_rx_data(bp, rxr, prod, GFP_ATOMIC); in bnxt_rx_skb()
1027 dma_unmap_single_attrs(&bp->pdev->dev, dma_addr, bp->rx_buf_use_size, in bnxt_rx_skb()
1028 bp->rx_dir, DMA_ATTR_WEAK_ORDERING); in bnxt_rx_skb()
1034 skb_reserve(skb, bp->rx_offset); in bnxt_rx_skb()
1039 static struct sk_buff *bnxt_rx_pages(struct bnxt *bp, in bnxt_rx_pages() argument
1045 struct pci_dev *pdev = bp->pdev; in bnxt_rx_pages()
1051 if ((bp->flags & BNXT_FLAG_CHIP_P5) && tpa) in bnxt_rx_pages()
1062 agg = bnxt_get_tpa_agg_p5(bp, rxr, idx, i); in bnxt_rx_pages()
1064 agg = bnxt_get_agg(bp, cpr, idx, i); in bnxt_rx_pages()
1082 if (bnxt_alloc_rx_page(bp, rxr, prod, GFP_ATOMIC) != 0) { in bnxt_rx_pages()
1116 static int bnxt_agg_bufs_valid(struct bnxt *bp, struct bnxt_cp_ring_info *cpr, in bnxt_agg_bufs_valid() argument
1133 struct bnxt *bp = bnapi->bp; in bnxt_copy_skb() local
1134 struct pci_dev *pdev = bp->pdev; in bnxt_copy_skb()
1141 dma_sync_single_for_cpu(&pdev->dev, mapping, bp->rx_copy_thresh, in bnxt_copy_skb()
1142 bp->rx_dir); in bnxt_copy_skb()
1147 dma_sync_single_for_device(&pdev->dev, mapping, bp->rx_copy_thresh, in bnxt_copy_skb()
1148 bp->rx_dir); in bnxt_copy_skb()
1154 static int bnxt_discard_rx(struct bnxt *bp, struct bnxt_cp_ring_info *cpr, in bnxt_discard_rx() argument
1170 if (bp->flags & BNXT_FLAG_CHIP_P5) in bnxt_discard_rx()
1177 if (!bnxt_agg_bufs_valid(bp, cpr, agg_bufs, &tmp_raw_cons)) in bnxt_discard_rx()
1184 static void bnxt_queue_fw_reset_work(struct bnxt *bp, unsigned long delay) in bnxt_queue_fw_reset_work() argument
1186 if (!(test_bit(BNXT_STATE_IN_FW_RESET, &bp->state))) in bnxt_queue_fw_reset_work()
1189 if (BNXT_PF(bp)) in bnxt_queue_fw_reset_work()
1190 queue_delayed_work(bnxt_pf_wq, &bp->fw_reset_task, delay); in bnxt_queue_fw_reset_work()
1192 schedule_delayed_work(&bp->fw_reset_task, delay); in bnxt_queue_fw_reset_work()
1195 static void bnxt_queue_sp_work(struct bnxt *bp) in bnxt_queue_sp_work() argument
1197 if (BNXT_PF(bp)) in bnxt_queue_sp_work()
1198 queue_work(bnxt_pf_wq, &bp->sp_task); in bnxt_queue_sp_work()
1200 schedule_work(&bp->sp_task); in bnxt_queue_sp_work()
1203 static void bnxt_sched_reset(struct bnxt *bp, struct bnxt_rx_ring_info *rxr) in bnxt_sched_reset() argument
1207 if (bp->flags & BNXT_FLAG_CHIP_P5) in bnxt_sched_reset()
1208 set_bit(BNXT_RESET_TASK_SP_EVENT, &bp->sp_event); in bnxt_sched_reset()
1210 set_bit(BNXT_RST_RING_SP_EVENT, &bp->sp_event); in bnxt_sched_reset()
1211 bnxt_queue_sp_work(bp); in bnxt_sched_reset()
1243 static void bnxt_tpa_start(struct bnxt *bp, struct bnxt_rx_ring_info *rxr, in bnxt_tpa_start() argument
1253 if (bp->flags & BNXT_FLAG_CHIP_P5) { in bnxt_tpa_start()
1267 netdev_warn(bp->dev, "TPA cons %x, expected cons %x, error code %x\n", in bnxt_tpa_start()
1270 bnxt_sched_reset(bp, rxr); in bnxt_tpa_start()
1308 netif_warn(bp, rx_err, bp->dev, "TPA packet without valid hash\n"); in bnxt_tpa_start()
1498 static inline struct sk_buff *bnxt_gro_skb(struct bnxt *bp, in bnxt_gro_skb() argument
1516 if (bp->flags & BNXT_FLAG_CHIP_P5) in bnxt_gro_skb()
1520 skb = bp->gro_func(tpa_info, payload_off, TPA_END_GRO_TS(tpa_end), skb); in bnxt_gro_skb()
1530 static struct net_device *bnxt_get_pkt_dev(struct bnxt *bp, u16 cfa_code) in bnxt_get_pkt_dev() argument
1532 struct net_device *dev = bnxt_get_vf_rep(bp, cfa_code); in bnxt_get_pkt_dev()
1535 return dev ? dev : bp->dev; in bnxt_get_pkt_dev()
1538 static inline struct sk_buff *bnxt_tpa_end(struct bnxt *bp, in bnxt_tpa_end() argument
1557 int rc = bnxt_discard_rx(bp, cpr, raw_cons, tpa_end); in bnxt_tpa_end()
1564 if (bp->flags & BNXT_FLAG_CHIP_P5) { in bnxt_tpa_end()
1570 netdev_warn(bp->dev, "TPA end agg_buf %d != expected agg_bufs %d\n", in bnxt_tpa_end()
1578 gro = !!(bp->flags & BNXT_FLAG_GRO); in bnxt_tpa_end()
1585 if (!bnxt_agg_bufs_valid(bp, cpr, agg_bufs, raw_cons)) in bnxt_tpa_end()
1602 netdev_warn(bp->dev, "TPA frags %d exceeded MAX_SKB_FRAGS %d\n", in bnxt_tpa_end()
1607 if (len <= bp->rx_copy_thresh) { in bnxt_tpa_end()
1617 new_data = __bnxt_alloc_rx_data(bp, &new_mapping, GFP_ATOMIC); in bnxt_tpa_end()
1624 tpa_info->data_ptr = new_data + bp->rx_offset; in bnxt_tpa_end()
1628 dma_unmap_single_attrs(&bp->pdev->dev, mapping, in bnxt_tpa_end()
1629 bp->rx_buf_use_size, bp->rx_dir, in bnxt_tpa_end()
1637 skb_reserve(skb, bp->rx_offset); in bnxt_tpa_end()
1642 skb = bnxt_rx_pages(bp, cpr, skb, idx, agg_bufs, true); in bnxt_tpa_end()
1650 eth_type_trans(skb, bnxt_get_pkt_dev(bp, tpa_info->cfa_code)); in bnxt_tpa_end()
1677 skb = bnxt_gro_skb(bp, tpa_info, tpa_end, tpa_end1, skb); in bnxt_tpa_end()
1682 static void bnxt_tpa_agg(struct bnxt *bp, struct bnxt_rx_ring_info *rxr, in bnxt_tpa_agg() argument
1694 static void bnxt_deliver_skb(struct bnxt *bp, struct bnxt_napi *bnapi, in bnxt_deliver_skb() argument
1697 if (skb->dev != bp->dev) { in bnxt_deliver_skb()
1699 bnxt_vf_rep_rx(bp, skb); in bnxt_deliver_skb()
1713 static int bnxt_rx_pkt(struct bnxt *bp, struct bnxt_cp_ring_info *cpr, in bnxt_rx_pkt() argument
1718 struct net_device *dev = bp->dev; in bnxt_rx_pkt()
1738 bnxt_tpa_agg(bp, rxr, (struct rx_agg_cmp *)rxcmp); in bnxt_rx_pkt()
1757 bnxt_tpa_start(bp, rxr, (struct rx_tpa_start_cmp *)rxcmp, in bnxt_rx_pkt()
1764 skb = bnxt_tpa_end(bp, cpr, &tmp_raw_cons, in bnxt_rx_pkt()
1773 bnxt_deliver_skb(bp, bnapi, skb); in bnxt_rx_pkt()
1782 int rc1 = bnxt_discard_rx(bp, cpr, &tmp_raw_cons, rxcmp); in bnxt_rx_pkt()
1786 netdev_warn(bp->dev, "RX cons %x != expected cons %x\n", in bnxt_rx_pkt()
1788 bnxt_sched_reset(bp, rxr); in bnxt_rx_pkt()
1802 if (!bnxt_agg_bufs_valid(bp, cpr, agg_bufs, &tmp_raw_cons)) in bnxt_rx_pkt()
1822 if (!(bp->flags & BNXT_FLAG_CHIP_P5) && in bnxt_rx_pkt()
1823 !(bp->fw_cap & BNXT_FW_CAP_RING_MONITOR)) { in bnxt_rx_pkt()
1824 netdev_warn_once(bp->dev, "RX buffer error %x\n", in bnxt_rx_pkt()
1826 bnxt_sched_reset(bp, rxr); in bnxt_rx_pkt()
1835 if (bnxt_rx_xdp(bp, rxr, cons, data, &data_ptr, &len, event)) { in bnxt_rx_pkt()
1840 if (len <= bp->rx_copy_thresh) { in bnxt_rx_pkt()
1857 skb = bp->rx_skb_func(bp, rxr, cons, data, data_ptr, dma_addr, in bnxt_rx_pkt()
1866 skb = bnxt_rx_pages(bp, cpr, skb, cp_cons, agg_bufs, false); in bnxt_rx_pkt()
1884 skb->protocol = eth_type_trans(skb, bnxt_get_pkt_dev(bp, cfa_code)); in bnxt_rx_pkt()
1915 bnxt_deliver_skb(bp, bnapi, skb); in bnxt_rx_pkt()
1935 static int bnxt_force_rx_discard(struct bnxt *bp, in bnxt_force_rx_discard() argument
1972 return bnxt_rx_pkt(bp, cpr, raw_cons, event); in bnxt_force_rx_discard()
1975 u32 bnxt_fw_health_readl(struct bnxt *bp, int reg_idx) in bnxt_fw_health_readl() argument
1977 struct bnxt_fw_health *fw_health = bp->fw_health; in bnxt_fw_health_readl()
1985 pci_read_config_dword(bp->pdev, reg_off, &val); in bnxt_fw_health_readl()
1991 val = readl(bp->bar0 + reg_off); in bnxt_fw_health_readl()
1994 val = readl(bp->bar1 + reg_off); in bnxt_fw_health_readl()
2002 static u16 bnxt_agg_ring_id_to_grp_idx(struct bnxt *bp, u16 ring_id) in bnxt_agg_ring_id_to_grp_idx() argument
2006 for (i = 0; i < bp->rx_nr_rings; i++) { in bnxt_agg_ring_id_to_grp_idx()
2007 u16 grp_idx = bp->rx_ring[i].bnapi->index; in bnxt_agg_ring_id_to_grp_idx()
2010 grp_info = &bp->grp_info[grp_idx]; in bnxt_agg_ring_id_to_grp_idx()
2029 static int bnxt_async_event_process(struct bnxt *bp, in bnxt_async_event_process() argument
2039 struct bnxt_link_info *link_info = &bp->link_info; in bnxt_async_event_process()
2041 if (BNXT_VF(bp)) in bnxt_async_event_process()
2051 netdev_warn(bp->dev, "Link speed %d no longer supported\n", in bnxt_async_event_process()
2054 set_bit(BNXT_LINK_SPEED_CHNG_SP_EVENT, &bp->sp_event); in bnxt_async_event_process()
2059 set_bit(BNXT_LINK_CFG_CHANGE_SP_EVENT, &bp->sp_event); in bnxt_async_event_process()
2062 set_bit(BNXT_LINK_CHNG_SP_EVENT, &bp->sp_event); in bnxt_async_event_process()
2065 set_bit(BNXT_HWRM_PF_UNLOAD_SP_EVENT, &bp->sp_event); in bnxt_async_event_process()
2070 if (BNXT_VF(bp)) in bnxt_async_event_process()
2073 if (bp->pf.port_id != port_id) in bnxt_async_event_process()
2076 set_bit(BNXT_HWRM_PORT_MODULE_SP_EVENT, &bp->sp_event); in bnxt_async_event_process()
2080 if (BNXT_PF(bp)) in bnxt_async_event_process()
2082 set_bit(BNXT_RESET_TASK_SILENT_SP_EVENT, &bp->sp_event); in bnxt_async_event_process()
2087 if (!bp->fw_health) in bnxt_async_event_process()
2090 bp->fw_reset_timestamp = jiffies; in bnxt_async_event_process()
2091 bp->fw_reset_min_dsecs = cmpl->timestamp_lo; in bnxt_async_event_process()
2092 if (!bp->fw_reset_min_dsecs) in bnxt_async_event_process()
2093 bp->fw_reset_min_dsecs = BNXT_DFLT_FW_RST_MIN_DSECS; in bnxt_async_event_process()
2094 bp->fw_reset_max_dsecs = le16_to_cpu(cmpl->timestamp_hi); in bnxt_async_event_process()
2095 if (!bp->fw_reset_max_dsecs) in bnxt_async_event_process()
2096 bp->fw_reset_max_dsecs = BNXT_DFLT_FW_RST_MAX_DSECS; in bnxt_async_event_process()
2099 set_bit(BNXT_STATE_FW_FATAL_COND, &bp->state); in bnxt_async_event_process()
2101 netif_warn(bp, hw, bp->dev, in bnxt_async_event_process()
2104 bp->fw_reset_min_dsecs * 100, in bnxt_async_event_process()
2105 bp->fw_reset_max_dsecs * 100); in bnxt_async_event_process()
2106 set_bit(BNXT_FW_RESET_NOTIFY_SP_EVENT, &bp->sp_event); in bnxt_async_event_process()
2110 struct bnxt_fw_health *fw_health = bp->fw_health; in bnxt_async_event_process()
2117 netif_info(bp, drv, bp->dev, in bnxt_async_event_process()
2124 bp->current_interval * 10); in bnxt_async_event_process()
2128 bnxt_fw_health_readl(bp, BNXT_FW_HEARTBEAT_REG); in bnxt_async_event_process()
2130 bnxt_fw_health_readl(bp, BNXT_FW_RESET_CNT_REG); in bnxt_async_event_process()
2131 netif_info(bp, drv, bp->dev, in bnxt_async_event_process()
2134 bnxt_fw_health_readl(bp, BNXT_FW_HEALTH_REG)); in bnxt_async_event_process()
2145 netif_notice(bp, hw, bp->dev, in bnxt_async_event_process()
2153 if (bp->flags & BNXT_FLAG_CHIP_P5) in bnxt_async_event_process()
2156 netdev_warn(bp->dev, "Ring monitor event, ring type %lu id 0x%x\n", in bnxt_async_event_process()
2161 grp_idx = bnxt_agg_ring_id_to_grp_idx(bp, data1); in bnxt_async_event_process()
2163 netdev_warn(bp->dev, "Unknown RX agg ring id 0x%x\n", in bnxt_async_event_process()
2167 rxr = bp->bnapi[grp_idx]->rx_ring; in bnxt_async_event_process()
2168 bnxt_sched_reset(bp, rxr); in bnxt_async_event_process()
2174 bnxt_queue_sp_work(bp); in bnxt_async_event_process()
2176 bnxt_ulp_async_events(bp, cmpl); in bnxt_async_event_process()
2180 static int bnxt_hwrm_handler(struct bnxt *bp, struct tx_cmp *txcmp) in bnxt_hwrm_handler() argument
2190 if (seq_id == bp->hwrm_intr_seq_id) in bnxt_hwrm_handler()
2191 bp->hwrm_intr_seq_id = (u16)~bp->hwrm_intr_seq_id; in bnxt_hwrm_handler()
2193 netdev_err(bp->dev, "Invalid hwrm seq id %d\n", seq_id); in bnxt_hwrm_handler()
2199 if ((vf_id < bp->pf.first_vf_id) || in bnxt_hwrm_handler()
2200 (vf_id >= bp->pf.first_vf_id + bp->pf.active_vfs)) { in bnxt_hwrm_handler()
2201 netdev_err(bp->dev, "Msg contains invalid VF id %x\n", in bnxt_hwrm_handler()
2206 set_bit(vf_id - bp->pf.first_vf_id, bp->pf.vf_event_bmap); in bnxt_hwrm_handler()
2207 set_bit(BNXT_HWRM_EXEC_FWD_REQ_SP_EVENT, &bp->sp_event); in bnxt_hwrm_handler()
2208 bnxt_queue_sp_work(bp); in bnxt_hwrm_handler()
2212 bnxt_async_event_process(bp, in bnxt_hwrm_handler()
2225 struct bnxt *bp = bnapi->bp; in bnxt_msix() local
2235 static inline int bnxt_has_work(struct bnxt *bp, struct bnxt_cp_ring_info *cpr) in bnxt_has_work() argument
2249 struct bnxt *bp = bnapi->bp; in bnxt_inta() local
2256 if (!bnxt_has_work(bp, cpr)) { in bnxt_inta()
2257 int_status = readl(bp->bar0 + BNXT_CAG_REG_LEGACY_INT_STATUS); in bnxt_inta()
2267 if (unlikely(atomic_read(&bp->intr_sem) != 0)) in bnxt_inta()
2274 static int __bnxt_poll_work(struct bnxt *bp, struct bnxt_cp_ring_info *cpr, in __bnxt_poll_work() argument
2303 if (unlikely(tx_pkts >= bp->tx_wake_thresh)) { in __bnxt_poll_work()
2312 rc = bnxt_rx_pkt(bp, cpr, &raw_cons, &event); in __bnxt_poll_work()
2314 rc = bnxt_force_rx_discard(bp, cpr, &raw_cons, in __bnxt_poll_work()
2333 bnxt_hwrm_handler(bp, txcmp); in __bnxt_poll_work()
2353 bnxt_db_write_relaxed(bp, &txr->tx_db, prod); in __bnxt_poll_work()
2362 static void __bnxt_poll_work_done(struct bnxt *bp, struct bnxt_napi *bnapi) in __bnxt_poll_work_done() argument
2365 bnapi->tx_int(bp, bnapi, bnapi->tx_pkts); in __bnxt_poll_work_done()
2373 bnxt_db_write(bp, &rxr->rx_agg_db, rxr->rx_agg_prod); in __bnxt_poll_work_done()
2374 bnxt_db_write(bp, &rxr->rx_db, rxr->rx_prod); in __bnxt_poll_work_done()
2379 static int bnxt_poll_work(struct bnxt *bp, struct bnxt_cp_ring_info *cpr, in bnxt_poll_work() argument
2385 rx_pkts = __bnxt_poll_work(bp, cpr, budget); in bnxt_poll_work()
2391 bnxt_db_cq(bp, &cpr->cp_db, cpr->cp_raw_cons); in bnxt_poll_work()
2393 __bnxt_poll_work_done(bp, bnapi); in bnxt_poll_work()
2400 struct bnxt *bp = bnapi->bp; in bnxt_poll_nitroa0() local
2436 rc = bnxt_rx_pkt(bp, cpr, &raw_cons, &event); in bnxt_poll_nitroa0()
2443 bnxt_hwrm_handler(bp, txcmp); in bnxt_poll_nitroa0()
2445 netdev_err(bp->dev, in bnxt_poll_nitroa0()
2456 bnxt_db_write(bp, &rxr->rx_db, rxr->rx_prod); in bnxt_poll_nitroa0()
2459 bnxt_db_write(bp, &rxr->rx_agg_db, rxr->rx_agg_prod); in bnxt_poll_nitroa0()
2461 if (!bnxt_has_work(bp, cpr) && rx_pkts < budget) { in bnxt_poll_nitroa0()
2471 struct bnxt *bp = bnapi->bp; in bnxt_poll() local
2476 work_done += bnxt_poll_work(bp, cpr, budget - work_done); in bnxt_poll()
2484 if (!bnxt_has_work(bp, cpr)) { in bnxt_poll()
2490 if (bp->flags & BNXT_FLAG_DIM) { in bnxt_poll()
2502 static int __bnxt_poll_cqs(struct bnxt *bp, struct bnxt_napi *bnapi, int budget) in __bnxt_poll_cqs() argument
2511 work_done += __bnxt_poll_work(bp, cpr2, in __bnxt_poll_cqs()
2519 static void __bnxt_poll_cqs_done(struct bnxt *bp, struct bnxt_napi *bnapi, in __bnxt_poll_cqs_done() argument
2536 __bnxt_poll_work_done(bp, bnapi); in __bnxt_poll_cqs_done()
2544 struct bnxt *bp = bnapi->bp; in bnxt_poll_p5() local
2551 work_done = __bnxt_poll_cqs(bp, bnapi, budget); in bnxt_poll_p5()
2561 __bnxt_poll_cqs_done(bp, bnapi, DBR_TYPE_CQ_ARMALL); in bnxt_poll_p5()
2583 work_done += __bnxt_poll_work(bp, cpr2, in bnxt_poll_p5()
2587 bnxt_hwrm_handler(bp, (struct tx_cmp *)nqcmp); in bnxt_poll_p5()
2591 __bnxt_poll_cqs_done(bp, bnapi, DBR_TYPE_CQ); in bnxt_poll_p5()
2599 static void bnxt_free_tx_skbs(struct bnxt *bp) in bnxt_free_tx_skbs() argument
2602 struct pci_dev *pdev = bp->pdev; in bnxt_free_tx_skbs()
2604 if (!bp->tx_ring) in bnxt_free_tx_skbs()
2607 max_idx = bp->tx_nr_pages * TX_DESC_CNT; in bnxt_free_tx_skbs()
2608 for (i = 0; i < bp->tx_nr_rings; i++) { in bnxt_free_tx_skbs()
2609 struct bnxt_tx_ring_info *txr = &bp->tx_ring[i]; in bnxt_free_tx_skbs()
2620 if (i < bp->tx_nr_rings_xdp && in bnxt_free_tx_skbs()
2655 int ring_idx = j & bp->tx_ring_mask; in bnxt_free_tx_skbs()
2666 netdev_tx_reset_queue(netdev_get_tx_queue(bp->dev, i)); in bnxt_free_tx_skbs()
2670 static void bnxt_free_one_rx_ring_skbs(struct bnxt *bp, int ring_nr) in bnxt_free_one_rx_ring_skbs() argument
2672 struct bnxt_rx_ring_info *rxr = &bp->rx_ring[ring_nr]; in bnxt_free_one_rx_ring_skbs()
2673 struct pci_dev *pdev = bp->pdev; in bnxt_free_one_rx_ring_skbs()
2677 max_idx = bp->rx_nr_pages * RX_DESC_CNT; in bnxt_free_one_rx_ring_skbs()
2678 max_agg_idx = bp->rx_agg_nr_pages * RX_DESC_CNT; in bnxt_free_one_rx_ring_skbs()
2682 for (i = 0; i < bp->max_tpa; i++) { in bnxt_free_one_rx_ring_skbs()
2690 bp->rx_buf_use_size, bp->rx_dir, in bnxt_free_one_rx_ring_skbs()
2711 if (BNXT_RX_PAGE_MODE(bp)) { in bnxt_free_one_rx_ring_skbs()
2712 mapping -= bp->rx_dma_offset; in bnxt_free_one_rx_ring_skbs()
2714 bp->rx_dir, in bnxt_free_one_rx_ring_skbs()
2719 bp->rx_buf_use_size, bp->rx_dir, in bnxt_free_one_rx_ring_skbs()
2756 static void bnxt_free_rx_skbs(struct bnxt *bp) in bnxt_free_rx_skbs() argument
2760 if (!bp->rx_ring) in bnxt_free_rx_skbs()
2763 for (i = 0; i < bp->rx_nr_rings; i++) in bnxt_free_rx_skbs()
2764 bnxt_free_one_rx_ring_skbs(bp, i); in bnxt_free_rx_skbs()
2767 static void bnxt_free_skbs(struct bnxt *bp) in bnxt_free_skbs() argument
2769 bnxt_free_tx_skbs(bp); in bnxt_free_skbs()
2770 bnxt_free_rx_skbs(bp); in bnxt_free_skbs()
2773 static void bnxt_free_ring(struct bnxt *bp, struct bnxt_ring_mem_info *rmem) in bnxt_free_ring() argument
2775 struct pci_dev *pdev = bp->pdev; in bnxt_free_ring()
2802 static int bnxt_alloc_ring(struct bnxt *bp, struct bnxt_ring_mem_info *rmem) in bnxt_alloc_ring() argument
2804 struct pci_dev *pdev = bp->pdev; in bnxt_alloc_ring()
2855 static void bnxt_free_tpa_info(struct bnxt *bp) in bnxt_free_tpa_info() argument
2859 for (i = 0; i < bp->rx_nr_rings; i++) { in bnxt_free_tpa_info()
2860 struct bnxt_rx_ring_info *rxr = &bp->rx_ring[i]; in bnxt_free_tpa_info()
2873 static int bnxt_alloc_tpa_info(struct bnxt *bp) in bnxt_alloc_tpa_info() argument
2877 bp->max_tpa = MAX_TPA; in bnxt_alloc_tpa_info()
2878 if (bp->flags & BNXT_FLAG_CHIP_P5) { in bnxt_alloc_tpa_info()
2879 if (!bp->max_tpa_v2) in bnxt_alloc_tpa_info()
2881 bp->max_tpa = max_t(u16, bp->max_tpa_v2, MAX_TPA_P5); in bnxt_alloc_tpa_info()
2882 total_aggs = bp->max_tpa * MAX_SKB_FRAGS; in bnxt_alloc_tpa_info()
2885 for (i = 0; i < bp->rx_nr_rings; i++) { in bnxt_alloc_tpa_info()
2886 struct bnxt_rx_ring_info *rxr = &bp->rx_ring[i]; in bnxt_alloc_tpa_info()
2889 rxr->rx_tpa = kcalloc(bp->max_tpa, sizeof(struct bnxt_tpa_info), in bnxt_alloc_tpa_info()
2894 if (!(bp->flags & BNXT_FLAG_CHIP_P5)) in bnxt_alloc_tpa_info()
2900 for (j = 1; j < bp->max_tpa; j++) in bnxt_alloc_tpa_info()
2910 static void bnxt_free_rx_rings(struct bnxt *bp) in bnxt_free_rx_rings() argument
2914 if (!bp->rx_ring) in bnxt_free_rx_rings()
2917 bnxt_free_tpa_info(bp); in bnxt_free_rx_rings()
2918 for (i = 0; i < bp->rx_nr_rings; i++) { in bnxt_free_rx_rings()
2919 struct bnxt_rx_ring_info *rxr = &bp->rx_ring[i]; in bnxt_free_rx_rings()
2935 bnxt_free_ring(bp, &ring->ring_mem); in bnxt_free_rx_rings()
2938 bnxt_free_ring(bp, &ring->ring_mem); in bnxt_free_rx_rings()
2942 static int bnxt_alloc_rx_page_pool(struct bnxt *bp, in bnxt_alloc_rx_page_pool() argument
2947 pp.pool_size = bp->rx_ring_size; in bnxt_alloc_rx_page_pool()
2948 pp.nid = dev_to_node(&bp->pdev->dev); in bnxt_alloc_rx_page_pool()
2949 pp.dev = &bp->pdev->dev; in bnxt_alloc_rx_page_pool()
2962 static int bnxt_alloc_rx_rings(struct bnxt *bp) in bnxt_alloc_rx_rings() argument
2966 if (!bp->rx_ring) in bnxt_alloc_rx_rings()
2969 if (bp->flags & BNXT_FLAG_AGG_RINGS) in bnxt_alloc_rx_rings()
2972 for (i = 0; i < bp->rx_nr_rings; i++) { in bnxt_alloc_rx_rings()
2973 struct bnxt_rx_ring_info *rxr = &bp->rx_ring[i]; in bnxt_alloc_rx_rings()
2978 rc = bnxt_alloc_rx_page_pool(bp, rxr); in bnxt_alloc_rx_rings()
2982 rc = xdp_rxq_info_reg(&rxr->xdp_rxq, bp->dev, i); in bnxt_alloc_rx_rings()
2994 rc = bnxt_alloc_ring(bp, &ring->ring_mem); in bnxt_alloc_rx_rings()
3003 rc = bnxt_alloc_ring(bp, &ring->ring_mem); in bnxt_alloc_rx_rings()
3008 rxr->rx_agg_bmap_size = bp->rx_agg_ring_mask + 1; in bnxt_alloc_rx_rings()
3015 if (bp->flags & BNXT_FLAG_TPA) in bnxt_alloc_rx_rings()
3016 rc = bnxt_alloc_tpa_info(bp); in bnxt_alloc_rx_rings()
3020 static void bnxt_free_tx_rings(struct bnxt *bp) in bnxt_free_tx_rings() argument
3023 struct pci_dev *pdev = bp->pdev; in bnxt_free_tx_rings()
3025 if (!bp->tx_ring) in bnxt_free_tx_rings()
3028 for (i = 0; i < bp->tx_nr_rings; i++) { in bnxt_free_tx_rings()
3029 struct bnxt_tx_ring_info *txr = &bp->tx_ring[i]; in bnxt_free_tx_rings()
3033 dma_free_coherent(&pdev->dev, bp->tx_push_size, in bnxt_free_tx_rings()
3040 bnxt_free_ring(bp, &ring->ring_mem); in bnxt_free_tx_rings()
3044 static int bnxt_alloc_tx_rings(struct bnxt *bp) in bnxt_alloc_tx_rings() argument
3047 struct pci_dev *pdev = bp->pdev; in bnxt_alloc_tx_rings()
3049 bp->tx_push_size = 0; in bnxt_alloc_tx_rings()
3050 if (bp->tx_push_thresh) { in bnxt_alloc_tx_rings()
3054 bp->tx_push_thresh); in bnxt_alloc_tx_rings()
3058 bp->tx_push_thresh = 0; in bnxt_alloc_tx_rings()
3061 bp->tx_push_size = push_size; in bnxt_alloc_tx_rings()
3064 for (i = 0, j = 0; i < bp->tx_nr_rings; i++) { in bnxt_alloc_tx_rings()
3065 struct bnxt_tx_ring_info *txr = &bp->tx_ring[i]; in bnxt_alloc_tx_rings()
3071 rc = bnxt_alloc_ring(bp, &ring->ring_mem); in bnxt_alloc_tx_rings()
3076 if (bp->tx_push_size) { in bnxt_alloc_tx_rings()
3083 bp->tx_push_size, in bnxt_alloc_tx_rings()
3094 qidx = bp->tc_to_qidx[j]; in bnxt_alloc_tx_rings()
3095 ring->queue_id = bp->q_info[qidx].queue_id; in bnxt_alloc_tx_rings()
3096 if (i < bp->tx_nr_rings_xdp) in bnxt_alloc_tx_rings()
3098 if (i % bp->tx_nr_rings_per_tc == (bp->tx_nr_rings_per_tc - 1)) in bnxt_alloc_tx_rings()
3104 static void bnxt_free_cp_rings(struct bnxt *bp) in bnxt_free_cp_rings() argument
3108 if (!bp->bnapi) in bnxt_free_cp_rings()
3111 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_free_cp_rings()
3112 struct bnxt_napi *bnapi = bp->bnapi[i]; in bnxt_free_cp_rings()
3123 bnxt_free_ring(bp, &ring->ring_mem); in bnxt_free_cp_rings()
3130 bnxt_free_ring(bp, &ring->ring_mem); in bnxt_free_cp_rings()
3138 static struct bnxt_cp_ring_info *bnxt_alloc_cp_sub_ring(struct bnxt *bp) in bnxt_alloc_cp_sub_ring() argument
3151 rmem->nr_pages = bp->cp_nr_pages; in bnxt_alloc_cp_sub_ring()
3156 rc = bnxt_alloc_ring(bp, rmem); in bnxt_alloc_cp_sub_ring()
3158 bnxt_free_ring(bp, rmem); in bnxt_alloc_cp_sub_ring()
3165 static int bnxt_alloc_cp_rings(struct bnxt *bp) in bnxt_alloc_cp_rings() argument
3167 bool sh = !!(bp->flags & BNXT_FLAG_SHARED_RINGS); in bnxt_alloc_cp_rings()
3170 ulp_msix = bnxt_get_ulp_msix_num(bp); in bnxt_alloc_cp_rings()
3171 ulp_base_vec = bnxt_get_ulp_msix_base(bp); in bnxt_alloc_cp_rings()
3172 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_alloc_cp_rings()
3173 struct bnxt_napi *bnapi = bp->bnapi[i]; in bnxt_alloc_cp_rings()
3184 rc = bnxt_alloc_ring(bp, &ring->ring_mem); in bnxt_alloc_cp_rings()
3193 if (!(bp->flags & BNXT_FLAG_CHIP_P5)) in bnxt_alloc_cp_rings()
3196 if (i < bp->rx_nr_rings) { in bnxt_alloc_cp_rings()
3198 bnxt_alloc_cp_sub_ring(bp); in bnxt_alloc_cp_rings()
3205 if ((sh && i < bp->tx_nr_rings) || in bnxt_alloc_cp_rings()
3206 (!sh && i >= bp->rx_nr_rings)) { in bnxt_alloc_cp_rings()
3208 bnxt_alloc_cp_sub_ring(bp); in bnxt_alloc_cp_rings()
3219 static void bnxt_init_ring_struct(struct bnxt *bp) in bnxt_init_ring_struct() argument
3223 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_init_ring_struct()
3224 struct bnxt_napi *bnapi = bp->bnapi[i]; in bnxt_init_ring_struct()
3237 rmem->nr_pages = bp->cp_nr_pages; in bnxt_init_ring_struct()
3249 rmem->nr_pages = bp->rx_nr_pages; in bnxt_init_ring_struct()
3253 rmem->vmem_size = SW_RXBD_RING_SIZE * bp->rx_nr_pages; in bnxt_init_ring_struct()
3258 rmem->nr_pages = bp->rx_agg_nr_pages; in bnxt_init_ring_struct()
3262 rmem->vmem_size = SW_RXBD_AGG_RING_SIZE * bp->rx_agg_nr_pages; in bnxt_init_ring_struct()
3272 rmem->nr_pages = bp->tx_nr_pages; in bnxt_init_ring_struct()
3276 rmem->vmem_size = SW_TXBD_RING_SIZE * bp->tx_nr_pages; in bnxt_init_ring_struct()
3303 static int bnxt_alloc_one_rx_ring(struct bnxt *bp, int ring_nr) in bnxt_alloc_one_rx_ring() argument
3305 struct bnxt_rx_ring_info *rxr = &bp->rx_ring[ring_nr]; in bnxt_alloc_one_rx_ring()
3306 struct net_device *dev = bp->dev; in bnxt_alloc_one_rx_ring()
3311 for (i = 0; i < bp->rx_ring_size; i++) { in bnxt_alloc_one_rx_ring()
3312 if (bnxt_alloc_rx_data(bp, rxr, prod, GFP_KERNEL)) { in bnxt_alloc_one_rx_ring()
3314 ring_nr, i, bp->rx_ring_size); in bnxt_alloc_one_rx_ring()
3321 if (!(bp->flags & BNXT_FLAG_AGG_RINGS)) in bnxt_alloc_one_rx_ring()
3325 for (i = 0; i < bp->rx_agg_ring_size; i++) { in bnxt_alloc_one_rx_ring()
3326 if (bnxt_alloc_rx_page(bp, rxr, prod, GFP_KERNEL)) { in bnxt_alloc_one_rx_ring()
3328 ring_nr, i, bp->rx_ring_size); in bnxt_alloc_one_rx_ring()
3339 for (i = 0; i < bp->max_tpa; i++) { in bnxt_alloc_one_rx_ring()
3340 data = __bnxt_alloc_rx_data(bp, &mapping, GFP_KERNEL); in bnxt_alloc_one_rx_ring()
3345 rxr->rx_tpa[i].data_ptr = data + bp->rx_offset; in bnxt_alloc_one_rx_ring()
3352 static int bnxt_init_one_rx_ring(struct bnxt *bp, int ring_nr) in bnxt_init_one_rx_ring() argument
3358 type = (bp->rx_buf_use_size << RX_BD_LEN_SHIFT) | in bnxt_init_one_rx_ring()
3364 rxr = &bp->rx_ring[ring_nr]; in bnxt_init_one_rx_ring()
3368 if (BNXT_RX_PAGE_MODE(bp) && bp->xdp_prog) { in bnxt_init_one_rx_ring()
3369 bpf_prog_add(bp->xdp_prog, 1); in bnxt_init_one_rx_ring()
3370 rxr->xdp_prog = bp->xdp_prog; in bnxt_init_one_rx_ring()
3377 if ((bp->flags & BNXT_FLAG_AGG_RINGS)) { in bnxt_init_one_rx_ring()
3384 return bnxt_alloc_one_rx_ring(bp, ring_nr); in bnxt_init_one_rx_ring()
3387 static void bnxt_init_cp_rings(struct bnxt *bp) in bnxt_init_cp_rings() argument
3391 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_init_cp_rings()
3392 struct bnxt_cp_ring_info *cpr = &bp->bnapi[i]->cp_ring; in bnxt_init_cp_rings()
3396 cpr->rx_ring_coal.coal_ticks = bp->rx_coal.coal_ticks; in bnxt_init_cp_rings()
3397 cpr->rx_ring_coal.coal_bufs = bp->rx_coal.coal_bufs; in bnxt_init_cp_rings()
3406 cpr2->rx_ring_coal.coal_ticks = bp->rx_coal.coal_ticks; in bnxt_init_cp_rings()
3407 cpr2->rx_ring_coal.coal_bufs = bp->rx_coal.coal_bufs; in bnxt_init_cp_rings()
3412 static int bnxt_init_rx_rings(struct bnxt *bp) in bnxt_init_rx_rings() argument
3416 if (BNXT_RX_PAGE_MODE(bp)) { in bnxt_init_rx_rings()
3417 bp->rx_offset = NET_IP_ALIGN + XDP_PACKET_HEADROOM; in bnxt_init_rx_rings()
3418 bp->rx_dma_offset = XDP_PACKET_HEADROOM; in bnxt_init_rx_rings()
3420 bp->rx_offset = BNXT_RX_OFFSET; in bnxt_init_rx_rings()
3421 bp->rx_dma_offset = BNXT_RX_DMA_OFFSET; in bnxt_init_rx_rings()
3424 for (i = 0; i < bp->rx_nr_rings; i++) { in bnxt_init_rx_rings()
3425 rc = bnxt_init_one_rx_ring(bp, i); in bnxt_init_rx_rings()
3433 static int bnxt_init_tx_rings(struct bnxt *bp) in bnxt_init_tx_rings() argument
3437 bp->tx_wake_thresh = max_t(int, bp->tx_ring_size / 2, in bnxt_init_tx_rings()
3440 for (i = 0; i < bp->tx_nr_rings; i++) { in bnxt_init_tx_rings()
3441 struct bnxt_tx_ring_info *txr = &bp->tx_ring[i]; in bnxt_init_tx_rings()
3450 static void bnxt_free_ring_grps(struct bnxt *bp) in bnxt_free_ring_grps() argument
3452 kfree(bp->grp_info); in bnxt_free_ring_grps()
3453 bp->grp_info = NULL; in bnxt_free_ring_grps()
3456 static int bnxt_init_ring_grps(struct bnxt *bp, bool irq_re_init) in bnxt_init_ring_grps() argument
3461 bp->grp_info = kcalloc(bp->cp_nr_rings, in bnxt_init_ring_grps()
3464 if (!bp->grp_info) in bnxt_init_ring_grps()
3467 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_init_ring_grps()
3469 bp->grp_info[i].fw_stats_ctx = INVALID_HW_RING_ID; in bnxt_init_ring_grps()
3470 bp->grp_info[i].fw_grp_id = INVALID_HW_RING_ID; in bnxt_init_ring_grps()
3471 bp->grp_info[i].rx_fw_ring_id = INVALID_HW_RING_ID; in bnxt_init_ring_grps()
3472 bp->grp_info[i].agg_fw_ring_id = INVALID_HW_RING_ID; in bnxt_init_ring_grps()
3473 bp->grp_info[i].cp_fw_ring_id = INVALID_HW_RING_ID; in bnxt_init_ring_grps()
3478 static void bnxt_free_vnics(struct bnxt *bp) in bnxt_free_vnics() argument
3480 kfree(bp->vnic_info); in bnxt_free_vnics()
3481 bp->vnic_info = NULL; in bnxt_free_vnics()
3482 bp->nr_vnics = 0; in bnxt_free_vnics()
3485 static int bnxt_alloc_vnics(struct bnxt *bp) in bnxt_alloc_vnics() argument
3490 if ((bp->flags & (BNXT_FLAG_RFS | BNXT_FLAG_CHIP_P5)) == BNXT_FLAG_RFS) in bnxt_alloc_vnics()
3491 num_vnics += bp->rx_nr_rings; in bnxt_alloc_vnics()
3494 if (BNXT_CHIP_TYPE_NITRO_A0(bp)) in bnxt_alloc_vnics()
3497 bp->vnic_info = kcalloc(num_vnics, sizeof(struct bnxt_vnic_info), in bnxt_alloc_vnics()
3499 if (!bp->vnic_info) in bnxt_alloc_vnics()
3502 bp->nr_vnics = num_vnics; in bnxt_alloc_vnics()
3506 static void bnxt_init_vnics(struct bnxt *bp) in bnxt_init_vnics() argument
3510 for (i = 0; i < bp->nr_vnics; i++) { in bnxt_init_vnics()
3511 struct bnxt_vnic_info *vnic = &bp->vnic_info[i]; in bnxt_init_vnics()
3520 if (bp->vnic_info[i].rss_hash_key) { in bnxt_init_vnics()
3526 bp->vnic_info[0].rss_hash_key, in bnxt_init_vnics()
3549 void bnxt_set_tpa_flags(struct bnxt *bp) in bnxt_set_tpa_flags() argument
3551 bp->flags &= ~BNXT_FLAG_TPA; in bnxt_set_tpa_flags()
3552 if (bp->flags & BNXT_FLAG_NO_AGG_RINGS) in bnxt_set_tpa_flags()
3554 if (bp->dev->features & NETIF_F_LRO) in bnxt_set_tpa_flags()
3555 bp->flags |= BNXT_FLAG_LRO; in bnxt_set_tpa_flags()
3556 else if (bp->dev->features & NETIF_F_GRO_HW) in bnxt_set_tpa_flags()
3557 bp->flags |= BNXT_FLAG_GRO; in bnxt_set_tpa_flags()
3563 void bnxt_set_ring_params(struct bnxt *bp) in bnxt_set_ring_params() argument
3569 rx_size = SKB_DATA_ALIGN(bp->dev->mtu + ETH_HLEN + NET_IP_ALIGN + 8); in bnxt_set_ring_params()
3574 bp->rx_copy_thresh = BNXT_RX_COPY_THRESH; in bnxt_set_ring_params()
3575 ring_size = bp->rx_ring_size; in bnxt_set_ring_params()
3576 bp->rx_agg_ring_size = 0; in bnxt_set_ring_params()
3577 bp->rx_agg_nr_pages = 0; in bnxt_set_ring_params()
3579 if (bp->flags & BNXT_FLAG_TPA) in bnxt_set_ring_params()
3582 bp->flags &= ~BNXT_FLAG_JUMBO; in bnxt_set_ring_params()
3583 if (rx_space > PAGE_SIZE && !(bp->flags & BNXT_FLAG_NO_AGG_RINGS)) { in bnxt_set_ring_params()
3586 bp->flags |= BNXT_FLAG_JUMBO; in bnxt_set_ring_params()
3587 jumbo_factor = PAGE_ALIGN(bp->dev->mtu - 40) >> PAGE_SHIFT; in bnxt_set_ring_params()
3594 bp->rx_agg_nr_pages = bnxt_calc_nr_ring_pages(agg_ring_size, in bnxt_set_ring_params()
3596 if (bp->rx_agg_nr_pages > MAX_RX_AGG_PAGES) { in bnxt_set_ring_params()
3599 bp->rx_agg_nr_pages = MAX_RX_AGG_PAGES; in bnxt_set_ring_params()
3601 netdev_warn(bp->dev, "rx agg ring size %d reduced to %d.\n", in bnxt_set_ring_params()
3604 bp->rx_agg_ring_size = agg_ring_size; in bnxt_set_ring_params()
3605 bp->rx_agg_ring_mask = (bp->rx_agg_nr_pages * RX_DESC_CNT) - 1; in bnxt_set_ring_params()
3611 bp->rx_buf_use_size = rx_size; in bnxt_set_ring_params()
3612 bp->rx_buf_size = rx_space; in bnxt_set_ring_params()
3614 bp->rx_nr_pages = bnxt_calc_nr_ring_pages(ring_size, RX_DESC_CNT); in bnxt_set_ring_params()
3615 bp->rx_ring_mask = (bp->rx_nr_pages * RX_DESC_CNT) - 1; in bnxt_set_ring_params()
3617 ring_size = bp->tx_ring_size; in bnxt_set_ring_params()
3618 bp->tx_nr_pages = bnxt_calc_nr_ring_pages(ring_size, TX_DESC_CNT); in bnxt_set_ring_params()
3619 bp->tx_ring_mask = (bp->tx_nr_pages * TX_DESC_CNT) - 1; in bnxt_set_ring_params()
3621 max_rx_cmpl = bp->rx_ring_size; in bnxt_set_ring_params()
3626 if (bp->flags & BNXT_FLAG_TPA) in bnxt_set_ring_params()
3627 max_rx_cmpl += bp->max_tpa; in bnxt_set_ring_params()
3629 ring_size = max_rx_cmpl * 2 + agg_ring_size + bp->tx_ring_size; in bnxt_set_ring_params()
3630 bp->cp_ring_size = ring_size; in bnxt_set_ring_params()
3632 bp->cp_nr_pages = bnxt_calc_nr_ring_pages(ring_size, CP_DESC_CNT); in bnxt_set_ring_params()
3633 if (bp->cp_nr_pages > MAX_CP_PAGES) { in bnxt_set_ring_params()
3634 bp->cp_nr_pages = MAX_CP_PAGES; in bnxt_set_ring_params()
3635 bp->cp_ring_size = MAX_CP_PAGES * CP_DESC_CNT - 1; in bnxt_set_ring_params()
3636 netdev_warn(bp->dev, "completion ring size %d reduced to %d.\n", in bnxt_set_ring_params()
3637 ring_size, bp->cp_ring_size); in bnxt_set_ring_params()
3639 bp->cp_bit = bp->cp_nr_pages * CP_DESC_CNT; in bnxt_set_ring_params()
3640 bp->cp_ring_mask = bp->cp_bit - 1; in bnxt_set_ring_params()
3646 int bnxt_set_rx_skb_mode(struct bnxt *bp, bool page_mode) in bnxt_set_rx_skb_mode() argument
3649 if (bp->dev->mtu > BNXT_MAX_PAGE_MODE_MTU) in bnxt_set_rx_skb_mode()
3651 bp->dev->max_mtu = in bnxt_set_rx_skb_mode()
3652 min_t(u16, bp->max_mtu, BNXT_MAX_PAGE_MODE_MTU); in bnxt_set_rx_skb_mode()
3653 bp->flags &= ~BNXT_FLAG_AGG_RINGS; in bnxt_set_rx_skb_mode()
3654 bp->flags |= BNXT_FLAG_NO_AGG_RINGS | BNXT_FLAG_RX_PAGE_MODE; in bnxt_set_rx_skb_mode()
3655 bp->rx_dir = DMA_BIDIRECTIONAL; in bnxt_set_rx_skb_mode()
3656 bp->rx_skb_func = bnxt_rx_page_skb; in bnxt_set_rx_skb_mode()
3658 netdev_update_features(bp->dev); in bnxt_set_rx_skb_mode()
3660 bp->dev->max_mtu = bp->max_mtu; in bnxt_set_rx_skb_mode()
3661 bp->flags &= ~BNXT_FLAG_RX_PAGE_MODE; in bnxt_set_rx_skb_mode()
3662 bp->rx_dir = DMA_FROM_DEVICE; in bnxt_set_rx_skb_mode()
3663 bp->rx_skb_func = bnxt_rx_skb; in bnxt_set_rx_skb_mode()
3668 static void bnxt_free_vnic_attributes(struct bnxt *bp) in bnxt_free_vnic_attributes() argument
3672 struct pci_dev *pdev = bp->pdev; in bnxt_free_vnic_attributes()
3674 if (!bp->vnic_info) in bnxt_free_vnic_attributes()
3677 for (i = 0; i < bp->nr_vnics; i++) { in bnxt_free_vnic_attributes()
3678 vnic = &bp->vnic_info[i]; in bnxt_free_vnic_attributes()
3704 static int bnxt_alloc_vnic_attributes(struct bnxt *bp) in bnxt_alloc_vnic_attributes() argument
3708 struct pci_dev *pdev = bp->pdev; in bnxt_alloc_vnic_attributes()
3711 for (i = 0; i < bp->nr_vnics; i++) { in bnxt_alloc_vnic_attributes()
3712 vnic = &bp->vnic_info[i]; in bnxt_alloc_vnic_attributes()
3739 if (bp->flags & BNXT_FLAG_CHIP_P5) in bnxt_alloc_vnic_attributes()
3743 max_rings = bp->rx_nr_rings; in bnxt_alloc_vnic_attributes()
3753 if ((bp->flags & BNXT_FLAG_NEW_RSS_CAP) && in bnxt_alloc_vnic_attributes()
3759 if (bp->flags & BNXT_FLAG_CHIP_P5) in bnxt_alloc_vnic_attributes()
3781 static void bnxt_free_hwrm_resources(struct bnxt *bp) in bnxt_free_hwrm_resources() argument
3783 struct pci_dev *pdev = bp->pdev; in bnxt_free_hwrm_resources()
3785 if (bp->hwrm_cmd_resp_addr) { in bnxt_free_hwrm_resources()
3786 dma_free_coherent(&pdev->dev, PAGE_SIZE, bp->hwrm_cmd_resp_addr, in bnxt_free_hwrm_resources()
3787 bp->hwrm_cmd_resp_dma_addr); in bnxt_free_hwrm_resources()
3788 bp->hwrm_cmd_resp_addr = NULL; in bnxt_free_hwrm_resources()
3791 if (bp->hwrm_cmd_kong_resp_addr) { in bnxt_free_hwrm_resources()
3793 bp->hwrm_cmd_kong_resp_addr, in bnxt_free_hwrm_resources()
3794 bp->hwrm_cmd_kong_resp_dma_addr); in bnxt_free_hwrm_resources()
3795 bp->hwrm_cmd_kong_resp_addr = NULL; in bnxt_free_hwrm_resources()
3799 static int bnxt_alloc_kong_hwrm_resources(struct bnxt *bp) in bnxt_alloc_kong_hwrm_resources() argument
3801 struct pci_dev *pdev = bp->pdev; in bnxt_alloc_kong_hwrm_resources()
3803 if (bp->hwrm_cmd_kong_resp_addr) in bnxt_alloc_kong_hwrm_resources()
3806 bp->hwrm_cmd_kong_resp_addr = in bnxt_alloc_kong_hwrm_resources()
3808 &bp->hwrm_cmd_kong_resp_dma_addr, in bnxt_alloc_kong_hwrm_resources()
3810 if (!bp->hwrm_cmd_kong_resp_addr) in bnxt_alloc_kong_hwrm_resources()
3816 static int bnxt_alloc_hwrm_resources(struct bnxt *bp) in bnxt_alloc_hwrm_resources() argument
3818 struct pci_dev *pdev = bp->pdev; in bnxt_alloc_hwrm_resources()
3820 bp->hwrm_cmd_resp_addr = dma_alloc_coherent(&pdev->dev, PAGE_SIZE, in bnxt_alloc_hwrm_resources()
3821 &bp->hwrm_cmd_resp_dma_addr, in bnxt_alloc_hwrm_resources()
3823 if (!bp->hwrm_cmd_resp_addr) in bnxt_alloc_hwrm_resources()
3829 static void bnxt_free_hwrm_short_cmd_req(struct bnxt *bp) in bnxt_free_hwrm_short_cmd_req() argument
3831 if (bp->hwrm_short_cmd_req_addr) { in bnxt_free_hwrm_short_cmd_req()
3832 struct pci_dev *pdev = bp->pdev; in bnxt_free_hwrm_short_cmd_req()
3834 dma_free_coherent(&pdev->dev, bp->hwrm_max_ext_req_len, in bnxt_free_hwrm_short_cmd_req()
3835 bp->hwrm_short_cmd_req_addr, in bnxt_free_hwrm_short_cmd_req()
3836 bp->hwrm_short_cmd_req_dma_addr); in bnxt_free_hwrm_short_cmd_req()
3837 bp->hwrm_short_cmd_req_addr = NULL; in bnxt_free_hwrm_short_cmd_req()
3841 static int bnxt_alloc_hwrm_short_cmd_req(struct bnxt *bp) in bnxt_alloc_hwrm_short_cmd_req() argument
3843 struct pci_dev *pdev = bp->pdev; in bnxt_alloc_hwrm_short_cmd_req()
3845 if (bp->hwrm_short_cmd_req_addr) in bnxt_alloc_hwrm_short_cmd_req()
3848 bp->hwrm_short_cmd_req_addr = in bnxt_alloc_hwrm_short_cmd_req()
3849 dma_alloc_coherent(&pdev->dev, bp->hwrm_max_ext_req_len, in bnxt_alloc_hwrm_short_cmd_req()
3850 &bp->hwrm_short_cmd_req_dma_addr, in bnxt_alloc_hwrm_short_cmd_req()
3852 if (!bp->hwrm_short_cmd_req_addr) in bnxt_alloc_hwrm_short_cmd_req()
3858 static void bnxt_free_stats_mem(struct bnxt *bp, struct bnxt_stats_mem *stats) in bnxt_free_stats_mem() argument
3865 dma_free_coherent(&bp->pdev->dev, stats->len, stats->hw_stats, in bnxt_free_stats_mem()
3871 static int bnxt_alloc_stats_mem(struct bnxt *bp, struct bnxt_stats_mem *stats, in bnxt_alloc_stats_mem() argument
3874 stats->hw_stats = dma_alloc_coherent(&bp->pdev->dev, stats->len, in bnxt_alloc_stats_mem()
3891 bnxt_free_stats_mem(bp, stats); in bnxt_alloc_stats_mem()
3911 static int bnxt_hwrm_func_qstat_ext(struct bnxt *bp, in bnxt_hwrm_func_qstat_ext() argument
3914 struct hwrm_func_qstats_ext_output *resp = bp->hwrm_cmd_resp_addr; in bnxt_hwrm_func_qstat_ext()
3919 if (!(bp->fw_cap & BNXT_FW_CAP_EXT_HW_STATS_SUPPORTED) || in bnxt_hwrm_func_qstat_ext()
3920 !(bp->flags & BNXT_FLAG_CHIP_P5)) in bnxt_hwrm_func_qstat_ext()
3923 bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_FUNC_QSTATS_EXT, -1, -1); in bnxt_hwrm_func_qstat_ext()
3926 mutex_lock(&bp->hwrm_cmd_lock); in bnxt_hwrm_func_qstat_ext()
3927 rc = _hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT); in bnxt_hwrm_func_qstat_ext()
3935 mutex_unlock(&bp->hwrm_cmd_lock); in bnxt_hwrm_func_qstat_ext()
3939 static int bnxt_hwrm_port_qstats(struct bnxt *bp, u8 flags);
3940 static int bnxt_hwrm_port_qstats_ext(struct bnxt *bp, u8 flags);
3942 static void bnxt_init_stats(struct bnxt *bp) in bnxt_init_stats() argument
3944 struct bnxt_napi *bnapi = bp->bnapi[0]; in bnxt_init_stats()
3955 rc = bnxt_hwrm_func_qstat_ext(bp, stats); in bnxt_init_stats()
3957 if (bp->flags & BNXT_FLAG_CHIP_P5) in bnxt_init_stats()
3963 if (bp->flags & BNXT_FLAG_PORT_STATS) { in bnxt_init_stats()
3964 stats = &bp->port_stats; in bnxt_init_stats()
3973 rc = bnxt_hwrm_port_qstats(bp, flags); in bnxt_init_stats()
3982 bnxt_hwrm_port_qstats(bp, 0); in bnxt_init_stats()
3985 if (bp->flags & BNXT_FLAG_PORT_STATS_EXT) { in bnxt_init_stats()
3986 stats = &bp->rx_port_stats_ext; in bnxt_init_stats()
3990 stats = &bp->tx_port_stats_ext; in bnxt_init_stats()
3996 rc = bnxt_hwrm_port_qstats_ext(bp, flags); in bnxt_init_stats()
4008 bnxt_hwrm_port_qstats_ext(bp, 0); in bnxt_init_stats()
4013 static void bnxt_free_port_stats(struct bnxt *bp) in bnxt_free_port_stats() argument
4015 bp->flags &= ~BNXT_FLAG_PORT_STATS; in bnxt_free_port_stats()
4016 bp->flags &= ~BNXT_FLAG_PORT_STATS_EXT; in bnxt_free_port_stats()
4018 bnxt_free_stats_mem(bp, &bp->port_stats); in bnxt_free_port_stats()
4019 bnxt_free_stats_mem(bp, &bp->rx_port_stats_ext); in bnxt_free_port_stats()
4020 bnxt_free_stats_mem(bp, &bp->tx_port_stats_ext); in bnxt_free_port_stats()
4023 static void bnxt_free_ring_stats(struct bnxt *bp) in bnxt_free_ring_stats() argument
4027 if (!bp->bnapi) in bnxt_free_ring_stats()
4030 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_free_ring_stats()
4031 struct bnxt_napi *bnapi = bp->bnapi[i]; in bnxt_free_ring_stats()
4034 bnxt_free_stats_mem(bp, &cpr->stats); in bnxt_free_ring_stats()
4038 static int bnxt_alloc_stats(struct bnxt *bp) in bnxt_alloc_stats() argument
4043 size = bp->hw_ring_stats_size; in bnxt_alloc_stats()
4045 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_alloc_stats()
4046 struct bnxt_napi *bnapi = bp->bnapi[i]; in bnxt_alloc_stats()
4050 rc = bnxt_alloc_stats_mem(bp, &cpr->stats, !i); in bnxt_alloc_stats()
4057 if (BNXT_VF(bp) || bp->chip_num == CHIP_NUM_58700) in bnxt_alloc_stats()
4060 if (bp->port_stats.hw_stats) in bnxt_alloc_stats()
4063 bp->port_stats.len = BNXT_PORT_STATS_SIZE; in bnxt_alloc_stats()
4064 rc = bnxt_alloc_stats_mem(bp, &bp->port_stats, true); in bnxt_alloc_stats()
4068 bp->flags |= BNXT_FLAG_PORT_STATS; in bnxt_alloc_stats()
4072 if (bp->hwrm_spec_code < 0x10804 || bp->hwrm_spec_code == 0x10900) in bnxt_alloc_stats()
4073 if (!(bp->fw_cap & BNXT_FW_CAP_EXT_STATS_SUPPORTED)) in bnxt_alloc_stats()
4076 if (bp->rx_port_stats_ext.hw_stats) in bnxt_alloc_stats()
4079 bp->rx_port_stats_ext.len = sizeof(struct rx_port_stats_ext); in bnxt_alloc_stats()
4080 rc = bnxt_alloc_stats_mem(bp, &bp->rx_port_stats_ext, true); in bnxt_alloc_stats()
4086 if (bp->tx_port_stats_ext.hw_stats) in bnxt_alloc_stats()
4089 if (bp->hwrm_spec_code >= 0x10902 || in bnxt_alloc_stats()
4090 (bp->fw_cap & BNXT_FW_CAP_EXT_STATS_SUPPORTED)) { in bnxt_alloc_stats()
4091 bp->tx_port_stats_ext.len = sizeof(struct tx_port_stats_ext); in bnxt_alloc_stats()
4092 rc = bnxt_alloc_stats_mem(bp, &bp->tx_port_stats_ext, true); in bnxt_alloc_stats()
4097 bp->flags |= BNXT_FLAG_PORT_STATS_EXT; in bnxt_alloc_stats()
4101 static void bnxt_clear_ring_indices(struct bnxt *bp) in bnxt_clear_ring_indices() argument
4105 if (!bp->bnapi) in bnxt_clear_ring_indices()
4108 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_clear_ring_indices()
4109 struct bnxt_napi *bnapi = bp->bnapi[i]; in bnxt_clear_ring_indices()
4136 static void bnxt_free_ntp_fltrs(struct bnxt *bp, bool irq_reinit) in bnxt_free_ntp_fltrs() argument
4149 head = &bp->ntp_fltr_hash_tbl[i]; in bnxt_free_ntp_fltrs()
4156 kfree(bp->ntp_fltr_bmap); in bnxt_free_ntp_fltrs()
4157 bp->ntp_fltr_bmap = NULL; in bnxt_free_ntp_fltrs()
4159 bp->ntp_fltr_count = 0; in bnxt_free_ntp_fltrs()
4163 static int bnxt_alloc_ntp_fltrs(struct bnxt *bp) in bnxt_alloc_ntp_fltrs() argument
4168 if (!(bp->flags & BNXT_FLAG_RFS)) in bnxt_alloc_ntp_fltrs()
4172 INIT_HLIST_HEAD(&bp->ntp_fltr_hash_tbl[i]); in bnxt_alloc_ntp_fltrs()
4174 bp->ntp_fltr_count = 0; in bnxt_alloc_ntp_fltrs()
4175 bp->ntp_fltr_bmap = kcalloc(BITS_TO_LONGS(BNXT_NTP_FLTR_MAX_FLTR), in bnxt_alloc_ntp_fltrs()
4179 if (!bp->ntp_fltr_bmap) in bnxt_alloc_ntp_fltrs()
4188 static void bnxt_free_mem(struct bnxt *bp, bool irq_re_init) in bnxt_free_mem() argument
4190 bnxt_free_vnic_attributes(bp); in bnxt_free_mem()
4191 bnxt_free_tx_rings(bp); in bnxt_free_mem()
4192 bnxt_free_rx_rings(bp); in bnxt_free_mem()
4193 bnxt_free_cp_rings(bp); in bnxt_free_mem()
4194 bnxt_free_ntp_fltrs(bp, irq_re_init); in bnxt_free_mem()
4196 bnxt_free_ring_stats(bp); in bnxt_free_mem()
4197 if (!(bp->fw_cap & BNXT_FW_CAP_PORT_STATS_NO_RESET) || in bnxt_free_mem()
4198 test_bit(BNXT_STATE_IN_FW_RESET, &bp->state)) in bnxt_free_mem()
4199 bnxt_free_port_stats(bp); in bnxt_free_mem()
4200 bnxt_free_ring_grps(bp); in bnxt_free_mem()
4201 bnxt_free_vnics(bp); in bnxt_free_mem()
4202 kfree(bp->tx_ring_map); in bnxt_free_mem()
4203 bp->tx_ring_map = NULL; in bnxt_free_mem()
4204 kfree(bp->tx_ring); in bnxt_free_mem()
4205 bp->tx_ring = NULL; in bnxt_free_mem()
4206 kfree(bp->rx_ring); in bnxt_free_mem()
4207 bp->rx_ring = NULL; in bnxt_free_mem()
4208 kfree(bp->bnapi); in bnxt_free_mem()
4209 bp->bnapi = NULL; in bnxt_free_mem()
4211 bnxt_clear_ring_indices(bp); in bnxt_free_mem()
4215 static int bnxt_alloc_mem(struct bnxt *bp, bool irq_re_init) in bnxt_alloc_mem() argument
4225 bp->cp_nr_rings); in bnxt_alloc_mem()
4227 bnapi = kzalloc(arr_size + size * bp->cp_nr_rings, GFP_KERNEL); in bnxt_alloc_mem()
4231 bp->bnapi = bnapi; in bnxt_alloc_mem()
4233 for (i = 0; i < bp->cp_nr_rings; i++, bnapi += size) { in bnxt_alloc_mem()
4234 bp->bnapi[i] = bnapi; in bnxt_alloc_mem()
4235 bp->bnapi[i]->index = i; in bnxt_alloc_mem()
4236 bp->bnapi[i]->bp = bp; in bnxt_alloc_mem()
4237 if (bp->flags & BNXT_FLAG_CHIP_P5) { in bnxt_alloc_mem()
4239 &bp->bnapi[i]->cp_ring; in bnxt_alloc_mem()
4246 bp->rx_ring = kcalloc(bp->rx_nr_rings, in bnxt_alloc_mem()
4249 if (!bp->rx_ring) in bnxt_alloc_mem()
4252 for (i = 0; i < bp->rx_nr_rings; i++) { in bnxt_alloc_mem()
4253 struct bnxt_rx_ring_info *rxr = &bp->rx_ring[i]; in bnxt_alloc_mem()
4255 if (bp->flags & BNXT_FLAG_CHIP_P5) { in bnxt_alloc_mem()
4261 rxr->bnapi = bp->bnapi[i]; in bnxt_alloc_mem()
4262 bp->bnapi[i]->rx_ring = &bp->rx_ring[i]; in bnxt_alloc_mem()
4265 bp->tx_ring = kcalloc(bp->tx_nr_rings, in bnxt_alloc_mem()
4268 if (!bp->tx_ring) in bnxt_alloc_mem()
4271 bp->tx_ring_map = kcalloc(bp->tx_nr_rings, sizeof(u16), in bnxt_alloc_mem()
4274 if (!bp->tx_ring_map) in bnxt_alloc_mem()
4277 if (bp->flags & BNXT_FLAG_SHARED_RINGS) in bnxt_alloc_mem()
4280 j = bp->rx_nr_rings; in bnxt_alloc_mem()
4282 for (i = 0; i < bp->tx_nr_rings; i++, j++) { in bnxt_alloc_mem()
4283 struct bnxt_tx_ring_info *txr = &bp->tx_ring[i]; in bnxt_alloc_mem()
4285 if (bp->flags & BNXT_FLAG_CHIP_P5) in bnxt_alloc_mem()
4288 txr->bnapi = bp->bnapi[j]; in bnxt_alloc_mem()
4289 bp->bnapi[j]->tx_ring = txr; in bnxt_alloc_mem()
4290 bp->tx_ring_map[i] = bp->tx_nr_rings_xdp + i; in bnxt_alloc_mem()
4291 if (i >= bp->tx_nr_rings_xdp) { in bnxt_alloc_mem()
4292 txr->txq_index = i - bp->tx_nr_rings_xdp; in bnxt_alloc_mem()
4293 bp->bnapi[j]->tx_int = bnxt_tx_int; in bnxt_alloc_mem()
4295 bp->bnapi[j]->flags |= BNXT_NAPI_FLAG_XDP; in bnxt_alloc_mem()
4296 bp->bnapi[j]->tx_int = bnxt_tx_int_xdp; in bnxt_alloc_mem()
4300 rc = bnxt_alloc_stats(bp); in bnxt_alloc_mem()
4303 bnxt_init_stats(bp); in bnxt_alloc_mem()
4305 rc = bnxt_alloc_ntp_fltrs(bp); in bnxt_alloc_mem()
4309 rc = bnxt_alloc_vnics(bp); in bnxt_alloc_mem()
4314 bnxt_init_ring_struct(bp); in bnxt_alloc_mem()
4316 rc = bnxt_alloc_rx_rings(bp); in bnxt_alloc_mem()
4320 rc = bnxt_alloc_tx_rings(bp); in bnxt_alloc_mem()
4324 rc = bnxt_alloc_cp_rings(bp); in bnxt_alloc_mem()
4328 bp->vnic_info[0].flags |= BNXT_VNIC_RSS_FLAG | BNXT_VNIC_MCAST_FLAG | in bnxt_alloc_mem()
4330 rc = bnxt_alloc_vnic_attributes(bp); in bnxt_alloc_mem()
4336 bnxt_free_mem(bp, true); in bnxt_alloc_mem()
4340 static void bnxt_disable_int(struct bnxt *bp) in bnxt_disable_int() argument
4344 if (!bp->bnapi) in bnxt_disable_int()
4347 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_disable_int()
4348 struct bnxt_napi *bnapi = bp->bnapi[i]; in bnxt_disable_int()
4353 bnxt_db_nq(bp, &cpr->cp_db, cpr->cp_raw_cons); in bnxt_disable_int()
4357 static int bnxt_cp_num_to_irq_num(struct bnxt *bp, int n) in bnxt_cp_num_to_irq_num() argument
4359 struct bnxt_napi *bnapi = bp->bnapi[n]; in bnxt_cp_num_to_irq_num()
4366 static void bnxt_disable_int_sync(struct bnxt *bp) in bnxt_disable_int_sync() argument
4370 atomic_inc(&bp->intr_sem); in bnxt_disable_int_sync()
4372 bnxt_disable_int(bp); in bnxt_disable_int_sync()
4373 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_disable_int_sync()
4374 int map_idx = bnxt_cp_num_to_irq_num(bp, i); in bnxt_disable_int_sync()
4376 synchronize_irq(bp->irq_tbl[map_idx].vector); in bnxt_disable_int_sync()
4380 static void bnxt_enable_int(struct bnxt *bp) in bnxt_enable_int() argument
4384 atomic_set(&bp->intr_sem, 0); in bnxt_enable_int()
4385 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_enable_int()
4386 struct bnxt_napi *bnapi = bp->bnapi[i]; in bnxt_enable_int()
4389 bnxt_db_nq_arm(bp, &cpr->cp_db, cpr->cp_raw_cons); in bnxt_enable_int()
4393 void bnxt_hwrm_cmd_hdr_init(struct bnxt *bp, void *request, u16 req_type, in bnxt_hwrm_cmd_hdr_init() argument
4401 if (bnxt_kong_hwrm_message(bp, req)) in bnxt_hwrm_cmd_hdr_init()
4402 req->resp_addr = cpu_to_le64(bp->hwrm_cmd_kong_resp_dma_addr); in bnxt_hwrm_cmd_hdr_init()
4404 req->resp_addr = cpu_to_le64(bp->hwrm_cmd_resp_dma_addr); in bnxt_hwrm_cmd_hdr_init()
4436 static int bnxt_hwrm_do_send_msg(struct bnxt *bp, void *msg, u32 msg_len, in bnxt_hwrm_do_send_msg() argument
4444 struct hwrm_err_output *resp = bp->hwrm_cmd_resp_addr; in bnxt_hwrm_do_send_msg()
4451 if (BNXT_NO_FW_ACCESS(bp) && in bnxt_hwrm_do_send_msg()
4456 if (msg_len > bp->hwrm_max_ext_req_len || in bnxt_hwrm_do_send_msg()
4457 !bp->hwrm_short_cmd_req_addr) in bnxt_hwrm_do_send_msg()
4461 if (bnxt_hwrm_kong_chnl(bp, req)) { in bnxt_hwrm_do_send_msg()
4465 resp = bp->hwrm_cmd_kong_resp_addr; in bnxt_hwrm_do_send_msg()
4472 req->seq_id = cpu_to_le16(bnxt_get_hwrm_seq_id(bp, dst)); in bnxt_hwrm_do_send_msg()
4475 bp->hwrm_intr_seq_id = le16_to_cpu(req->seq_id); in bnxt_hwrm_do_send_msg()
4477 if ((bp->fw_cap & BNXT_FW_CAP_SHORT_CMD) || in bnxt_hwrm_do_send_msg()
4479 void *short_cmd_req = bp->hwrm_short_cmd_req_addr; in bnxt_hwrm_do_send_msg()
4486 max_msg_len = bp->hwrm_max_ext_req_len; in bnxt_hwrm_do_send_msg()
4498 cpu_to_le64(bp->hwrm_short_cmd_req_dma_addr); in bnxt_hwrm_do_send_msg()
4510 __iowrite32_copy(bp->bar0 + bar_offset, data, msg_len / 4); in bnxt_hwrm_do_send_msg()
4513 writel(0, bp->bar0 + bar_offset + i); in bnxt_hwrm_do_send_msg()
4516 writel(1, bp->bar0 + doorbell_offset); in bnxt_hwrm_do_send_msg()
4518 if (!pci_is_enabled(bp->pdev)) in bnxt_hwrm_do_send_msg()
4536 u16 seq_id = bp->hwrm_intr_seq_id; in bnxt_hwrm_do_send_msg()
4539 while (bp->hwrm_intr_seq_id != (u16)~seq_id && in bnxt_hwrm_do_send_msg()
4544 if (test_bit(BNXT_STATE_FW_FATAL_COND, &bp->state)) in bnxt_hwrm_do_send_msg()
4555 if (bp->hwrm_intr_seq_id != (u16)~seq_id) { in bnxt_hwrm_do_send_msg()
4557 netdev_err(bp->dev, "Resp cmpl intr err msg: 0x%x\n", in bnxt_hwrm_do_send_msg()
4571 if (test_bit(BNXT_STATE_FW_FATAL_COND, &bp->state)) in bnxt_hwrm_do_send_msg()
4587 netdev_err(bp->dev, "Error (timeout: %d) msg {0x%x 0x%x} len:%d\n", in bnxt_hwrm_do_send_msg()
4606 netdev_err(bp->dev, "Error (timeout: %d) msg {0x%x 0x%x} len:%d v:%d\n", in bnxt_hwrm_do_send_msg()
4622 netdev_err(bp->dev, "hwrm req_type 0x%x seq id 0x%x error 0x%x\n", in bnxt_hwrm_do_send_msg()
4628 int _hwrm_send_message(struct bnxt *bp, void *msg, u32 msg_len, int timeout) in _hwrm_send_message() argument
4630 return bnxt_hwrm_do_send_msg(bp, msg, msg_len, timeout, false); in _hwrm_send_message()
4633 int _hwrm_send_message_silent(struct bnxt *bp, void *msg, u32 msg_len, in _hwrm_send_message_silent() argument
4636 return bnxt_hwrm_do_send_msg(bp, msg, msg_len, timeout, true); in _hwrm_send_message_silent()
4639 int hwrm_send_message(struct bnxt *bp, void *msg, u32 msg_len, int timeout) in hwrm_send_message() argument
4643 mutex_lock(&bp->hwrm_cmd_lock); in hwrm_send_message()
4644 rc = _hwrm_send_message(bp, msg, msg_len, timeout); in hwrm_send_message()
4645 mutex_unlock(&bp->hwrm_cmd_lock); in hwrm_send_message()
4649 int hwrm_send_message_silent(struct bnxt *bp, void *msg, u32 msg_len, in hwrm_send_message_silent() argument
4654 mutex_lock(&bp->hwrm_cmd_lock); in hwrm_send_message_silent()
4655 rc = bnxt_hwrm_do_send_msg(bp, msg, msg_len, timeout, true); in hwrm_send_message_silent()
4656 mutex_unlock(&bp->hwrm_cmd_lock); in hwrm_send_message_silent()
4660 int bnxt_hwrm_func_drv_rgtr(struct bnxt *bp, unsigned long *bmap, int bmap_size, in bnxt_hwrm_func_drv_rgtr() argument
4663 struct hwrm_func_drv_rgtr_output *resp = bp->hwrm_cmd_resp_addr; in bnxt_hwrm_func_drv_rgtr()
4670 bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_FUNC_DRV_RGTR, -1, -1); in bnxt_hwrm_func_drv_rgtr()
4679 if (bp->fw_cap & BNXT_FW_CAP_HOT_RESET) in bnxt_hwrm_func_drv_rgtr()
4681 if (bp->fw_cap & BNXT_FW_CAP_ERROR_RECOVERY) in bnxt_hwrm_func_drv_rgtr()
4692 if (BNXT_PF(bp)) { in bnxt_hwrm_func_drv_rgtr()
4713 if (bp->fw_cap & BNXT_FW_CAP_OVS_64BIT_HANDLE) in bnxt_hwrm_func_drv_rgtr()
4722 !(bp->fw_cap & BNXT_FW_CAP_ERROR_RECOVERY)) in bnxt_hwrm_func_drv_rgtr()
4739 mutex_lock(&bp->hwrm_cmd_lock); in bnxt_hwrm_func_drv_rgtr()
4740 rc = _hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT); in bnxt_hwrm_func_drv_rgtr()
4742 set_bit(BNXT_STATE_DRV_REGISTERED, &bp->state); in bnxt_hwrm_func_drv_rgtr()
4745 bp->fw_cap |= BNXT_FW_CAP_IF_CHANGE; in bnxt_hwrm_func_drv_rgtr()
4747 mutex_unlock(&bp->hwrm_cmd_lock); in bnxt_hwrm_func_drv_rgtr()
4751 static int bnxt_hwrm_func_drv_unrgtr(struct bnxt *bp) in bnxt_hwrm_func_drv_unrgtr() argument
4755 if (!test_and_clear_bit(BNXT_STATE_DRV_REGISTERED, &bp->state)) in bnxt_hwrm_func_drv_unrgtr()
4758 bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_FUNC_DRV_UNRGTR, -1, -1); in bnxt_hwrm_func_drv_unrgtr()
4759 return hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT); in bnxt_hwrm_func_drv_unrgtr()
4762 static int bnxt_hwrm_tunnel_dst_port_free(struct bnxt *bp, u8 tunnel_type) in bnxt_hwrm_tunnel_dst_port_free() argument
4767 bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_TUNNEL_DST_PORT_FREE, -1, -1); in bnxt_hwrm_tunnel_dst_port_free()
4772 req.tunnel_dst_port_id = cpu_to_le16(bp->vxlan_fw_dst_port_id); in bnxt_hwrm_tunnel_dst_port_free()
4773 bp->vxlan_fw_dst_port_id = INVALID_HW_RING_ID; in bnxt_hwrm_tunnel_dst_port_free()
4776 req.tunnel_dst_port_id = cpu_to_le16(bp->nge_fw_dst_port_id); in bnxt_hwrm_tunnel_dst_port_free()
4777 bp->nge_fw_dst_port_id = INVALID_HW_RING_ID; in bnxt_hwrm_tunnel_dst_port_free()
4783 rc = hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT); in bnxt_hwrm_tunnel_dst_port_free()
4785 netdev_err(bp->dev, "hwrm_tunnel_dst_port_free failed. rc:%d\n", in bnxt_hwrm_tunnel_dst_port_free()
4790 static int bnxt_hwrm_tunnel_dst_port_alloc(struct bnxt *bp, __be16 port, in bnxt_hwrm_tunnel_dst_port_alloc() argument
4795 struct hwrm_tunnel_dst_port_alloc_output *resp = bp->hwrm_cmd_resp_addr; in bnxt_hwrm_tunnel_dst_port_alloc()
4797 bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_TUNNEL_DST_PORT_ALLOC, -1, -1); in bnxt_hwrm_tunnel_dst_port_alloc()
4802 mutex_lock(&bp->hwrm_cmd_lock); in bnxt_hwrm_tunnel_dst_port_alloc()
4803 rc = _hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT); in bnxt_hwrm_tunnel_dst_port_alloc()
4805 netdev_err(bp->dev, "hwrm_tunnel_dst_port_alloc failed. rc:%d\n", in bnxt_hwrm_tunnel_dst_port_alloc()
4812 bp->vxlan_fw_dst_port_id = in bnxt_hwrm_tunnel_dst_port_alloc()
4816 bp->nge_fw_dst_port_id = le16_to_cpu(resp->tunnel_dst_port_id); in bnxt_hwrm_tunnel_dst_port_alloc()
4823 mutex_unlock(&bp->hwrm_cmd_lock); in bnxt_hwrm_tunnel_dst_port_alloc()
4827 static int bnxt_hwrm_cfa_l2_set_rx_mask(struct bnxt *bp, u16 vnic_id) in bnxt_hwrm_cfa_l2_set_rx_mask() argument
4830 struct bnxt_vnic_info *vnic = &bp->vnic_info[vnic_id]; in bnxt_hwrm_cfa_l2_set_rx_mask()
4832 bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_CFA_L2_SET_RX_MASK, -1, -1); in bnxt_hwrm_cfa_l2_set_rx_mask()
4838 return hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT); in bnxt_hwrm_cfa_l2_set_rx_mask()
4842 static int bnxt_hwrm_cfa_ntuple_filter_free(struct bnxt *bp, in bnxt_hwrm_cfa_ntuple_filter_free() argument
4847 bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_CFA_NTUPLE_FILTER_FREE, -1, -1); in bnxt_hwrm_cfa_ntuple_filter_free()
4849 return hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT); in bnxt_hwrm_cfa_ntuple_filter_free()
4871 static int bnxt_hwrm_cfa_ntuple_filter_alloc(struct bnxt *bp, in bnxt_hwrm_cfa_ntuple_filter_alloc() argument
4881 bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_CFA_NTUPLE_FILTER_ALLOC, -1, -1); in bnxt_hwrm_cfa_ntuple_filter_alloc()
4882 req.l2_filter_id = bp->vnic_info[0].fw_l2_filter_id[fltr->l2_fltr_idx]; in bnxt_hwrm_cfa_ntuple_filter_alloc()
4884 if (bp->fw_cap & BNXT_FW_CAP_CFA_RFS_RING_TBL_IDX_V2) { in bnxt_hwrm_cfa_ntuple_filter_alloc()
4888 vnic = &bp->vnic_info[fltr->rxq + 1]; in bnxt_hwrm_cfa_ntuple_filter_alloc()
4930 mutex_lock(&bp->hwrm_cmd_lock); in bnxt_hwrm_cfa_ntuple_filter_alloc()
4931 rc = _hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT); in bnxt_hwrm_cfa_ntuple_filter_alloc()
4933 resp = bnxt_get_hwrm_resp_addr(bp, &req); in bnxt_hwrm_cfa_ntuple_filter_alloc()
4936 mutex_unlock(&bp->hwrm_cmd_lock); in bnxt_hwrm_cfa_ntuple_filter_alloc()
4941 static int bnxt_hwrm_set_vnic_filter(struct bnxt *bp, u16 vnic_id, u16 idx, in bnxt_hwrm_set_vnic_filter() argument
4946 struct hwrm_cfa_l2_filter_alloc_output *resp = bp->hwrm_cmd_resp_addr; in bnxt_hwrm_set_vnic_filter()
4948 bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_CFA_L2_FILTER_ALLOC, -1, -1); in bnxt_hwrm_set_vnic_filter()
4950 if (!BNXT_CHIP_TYPE_NITRO_A0(bp)) in bnxt_hwrm_set_vnic_filter()
4953 req.dst_id = cpu_to_le16(bp->vnic_info[vnic_id].fw_vnic_id); in bnxt_hwrm_set_vnic_filter()
4966 mutex_lock(&bp->hwrm_cmd_lock); in bnxt_hwrm_set_vnic_filter()
4967 rc = _hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT); in bnxt_hwrm_set_vnic_filter()
4969 bp->vnic_info[vnic_id].fw_l2_filter_id[idx] = in bnxt_hwrm_set_vnic_filter()
4971 mutex_unlock(&bp->hwrm_cmd_lock); in bnxt_hwrm_set_vnic_filter()
4975 static int bnxt_hwrm_clear_vnic_filter(struct bnxt *bp) in bnxt_hwrm_clear_vnic_filter() argument
4981 mutex_lock(&bp->hwrm_cmd_lock); in bnxt_hwrm_clear_vnic_filter()
4983 struct bnxt_vnic_info *vnic = &bp->vnic_info[i]; in bnxt_hwrm_clear_vnic_filter()
4988 bnxt_hwrm_cmd_hdr_init(bp, &req, in bnxt_hwrm_clear_vnic_filter()
4993 rc = _hwrm_send_message(bp, &req, sizeof(req), in bnxt_hwrm_clear_vnic_filter()
4998 mutex_unlock(&bp->hwrm_cmd_lock); in bnxt_hwrm_clear_vnic_filter()
5003 static int bnxt_hwrm_vnic_set_tpa(struct bnxt *bp, u16 vnic_id, u32 tpa_flags) in bnxt_hwrm_vnic_set_tpa() argument
5005 struct bnxt_vnic_info *vnic = &bp->vnic_info[vnic_id]; in bnxt_hwrm_vnic_set_tpa()
5012 bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_VNIC_TPA_CFG, -1, -1); in bnxt_hwrm_vnic_set_tpa()
5015 u16 mss = bp->dev->mtu - 40; in bnxt_hwrm_vnic_set_tpa()
5046 if (bp->flags & BNXT_FLAG_CHIP_P5) { in bnxt_hwrm_vnic_set_tpa()
5048 max_aggs = bp->max_tpa; in bnxt_hwrm_vnic_set_tpa()
5059 return hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT); in bnxt_hwrm_vnic_set_tpa()
5062 static u16 bnxt_cp_ring_from_grp(struct bnxt *bp, struct bnxt_ring_struct *ring) in bnxt_cp_ring_from_grp() argument
5066 grp_info = &bp->grp_info[ring->grp_idx]; in bnxt_cp_ring_from_grp()
5070 static u16 bnxt_cp_ring_for_rx(struct bnxt *bp, struct bnxt_rx_ring_info *rxr) in bnxt_cp_ring_for_rx() argument
5072 if (bp->flags & BNXT_FLAG_CHIP_P5) { in bnxt_cp_ring_for_rx()
5079 return bnxt_cp_ring_from_grp(bp, &rxr->rx_ring_struct); in bnxt_cp_ring_for_rx()
5083 static u16 bnxt_cp_ring_for_tx(struct bnxt *bp, struct bnxt_tx_ring_info *txr) in bnxt_cp_ring_for_tx() argument
5085 if (bp->flags & BNXT_FLAG_CHIP_P5) { in bnxt_cp_ring_for_tx()
5092 return bnxt_cp_ring_from_grp(bp, &txr->tx_ring_struct); in bnxt_cp_ring_for_tx()
5096 static int bnxt_alloc_rss_indir_tbl(struct bnxt *bp) in bnxt_alloc_rss_indir_tbl() argument
5100 if (bp->flags & BNXT_FLAG_CHIP_P5) in bnxt_alloc_rss_indir_tbl()
5105 bp->rss_indir_tbl_entries = entries; in bnxt_alloc_rss_indir_tbl()
5106 bp->rss_indir_tbl = kmalloc_array(entries, sizeof(*bp->rss_indir_tbl), in bnxt_alloc_rss_indir_tbl()
5108 if (!bp->rss_indir_tbl) in bnxt_alloc_rss_indir_tbl()
5113 static void bnxt_set_dflt_rss_indir_tbl(struct bnxt *bp) in bnxt_set_dflt_rss_indir_tbl() argument
5117 if (!bp->rx_nr_rings) in bnxt_set_dflt_rss_indir_tbl()
5120 if (BNXT_CHIP_TYPE_NITRO_A0(bp)) in bnxt_set_dflt_rss_indir_tbl()
5121 max_rings = bp->rx_nr_rings - 1; in bnxt_set_dflt_rss_indir_tbl()
5123 max_rings = bp->rx_nr_rings; in bnxt_set_dflt_rss_indir_tbl()
5125 max_entries = bnxt_get_rxfh_indir_size(bp->dev); in bnxt_set_dflt_rss_indir_tbl()
5128 bp->rss_indir_tbl[i] = ethtool_rxfh_indir_default(i, max_rings); in bnxt_set_dflt_rss_indir_tbl()
5130 pad = bp->rss_indir_tbl_entries - max_entries; in bnxt_set_dflt_rss_indir_tbl()
5132 memset(&bp->rss_indir_tbl[i], 0, pad * sizeof(u16)); in bnxt_set_dflt_rss_indir_tbl()
5135 static u16 bnxt_get_max_rss_ring(struct bnxt *bp) in bnxt_get_max_rss_ring() argument
5139 if (!bp->rss_indir_tbl) in bnxt_get_max_rss_ring()
5142 tbl_size = bnxt_get_rxfh_indir_size(bp->dev); in bnxt_get_max_rss_ring()
5144 max_ring = max(max_ring, bp->rss_indir_tbl[i]); in bnxt_get_max_rss_ring()
5148 int bnxt_get_nr_rss_ctxs(struct bnxt *bp, int rx_rings) in bnxt_get_nr_rss_ctxs() argument
5150 if (bp->flags & BNXT_FLAG_CHIP_P5) in bnxt_get_nr_rss_ctxs()
5152 if (BNXT_CHIP_TYPE_NITRO_A0(bp)) in bnxt_get_nr_rss_ctxs()
5157 static void __bnxt_fill_hw_rss_tbl(struct bnxt *bp, struct bnxt_vnic_info *vnic) in __bnxt_fill_hw_rss_tbl() argument
5165 j = bp->rss_indir_tbl[i]; in __bnxt_fill_hw_rss_tbl()
5170 static void __bnxt_fill_hw_rss_tbl_p5(struct bnxt *bp, in __bnxt_fill_hw_rss_tbl_p5() argument
5177 tbl_size = bnxt_get_rxfh_indir_size(bp->dev); in __bnxt_fill_hw_rss_tbl_p5()
5182 j = bp->rss_indir_tbl[i]; in __bnxt_fill_hw_rss_tbl_p5()
5183 rxr = &bp->rx_ring[j]; in __bnxt_fill_hw_rss_tbl_p5()
5187 ring_id = bnxt_cp_ring_for_rx(bp, rxr); in __bnxt_fill_hw_rss_tbl_p5()
5192 static void bnxt_fill_hw_rss_tbl(struct bnxt *bp, struct bnxt_vnic_info *vnic) in bnxt_fill_hw_rss_tbl() argument
5194 if (bp->flags & BNXT_FLAG_CHIP_P5) in bnxt_fill_hw_rss_tbl()
5195 __bnxt_fill_hw_rss_tbl_p5(bp, vnic); in bnxt_fill_hw_rss_tbl()
5197 __bnxt_fill_hw_rss_tbl(bp, vnic); in bnxt_fill_hw_rss_tbl()
5200 static int bnxt_hwrm_vnic_set_rss(struct bnxt *bp, u16 vnic_id, bool set_rss) in bnxt_hwrm_vnic_set_rss() argument
5202 struct bnxt_vnic_info *vnic = &bp->vnic_info[vnic_id]; in bnxt_hwrm_vnic_set_rss()
5205 if ((bp->flags & BNXT_FLAG_CHIP_P5) || in bnxt_hwrm_vnic_set_rss()
5209 bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_VNIC_RSS_CFG, -1, -1); in bnxt_hwrm_vnic_set_rss()
5211 bnxt_fill_hw_rss_tbl(bp, vnic); in bnxt_hwrm_vnic_set_rss()
5212 req.hash_type = cpu_to_le32(bp->rss_hash_cfg); in bnxt_hwrm_vnic_set_rss()
5219 return hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT); in bnxt_hwrm_vnic_set_rss()
5222 static int bnxt_hwrm_vnic_set_rss_p5(struct bnxt *bp, u16 vnic_id, bool set_rss) in bnxt_hwrm_vnic_set_rss_p5() argument
5224 struct bnxt_vnic_info *vnic = &bp->vnic_info[vnic_id]; in bnxt_hwrm_vnic_set_rss_p5()
5229 bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_VNIC_RSS_CFG, -1, -1); in bnxt_hwrm_vnic_set_rss_p5()
5232 hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT); in bnxt_hwrm_vnic_set_rss_p5()
5235 bnxt_fill_hw_rss_tbl(bp, vnic); in bnxt_hwrm_vnic_set_rss_p5()
5236 req.hash_type = cpu_to_le32(bp->rss_hash_cfg); in bnxt_hwrm_vnic_set_rss_p5()
5240 nr_ctxs = bnxt_get_nr_rss_ctxs(bp, bp->rx_nr_rings); in bnxt_hwrm_vnic_set_rss_p5()
5247 rc = hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT); in bnxt_hwrm_vnic_set_rss_p5()
5254 static int bnxt_hwrm_vnic_set_hds(struct bnxt *bp, u16 vnic_id) in bnxt_hwrm_vnic_set_hds() argument
5256 struct bnxt_vnic_info *vnic = &bp->vnic_info[vnic_id]; in bnxt_hwrm_vnic_set_hds()
5259 bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_VNIC_PLCMODES_CFG, -1, -1); in bnxt_hwrm_vnic_set_hds()
5267 req.jumbo_thresh = cpu_to_le16(bp->rx_copy_thresh); in bnxt_hwrm_vnic_set_hds()
5268 req.hds_threshold = cpu_to_le16(bp->rx_copy_thresh); in bnxt_hwrm_vnic_set_hds()
5270 return hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT); in bnxt_hwrm_vnic_set_hds()
5273 static void bnxt_hwrm_vnic_ctx_free_one(struct bnxt *bp, u16 vnic_id, in bnxt_hwrm_vnic_ctx_free_one() argument
5278 bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_VNIC_RSS_COS_LB_CTX_FREE, -1, -1); in bnxt_hwrm_vnic_ctx_free_one()
5280 cpu_to_le16(bp->vnic_info[vnic_id].fw_rss_cos_lb_ctx[ctx_idx]); in bnxt_hwrm_vnic_ctx_free_one()
5282 hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT); in bnxt_hwrm_vnic_ctx_free_one()
5283 bp->vnic_info[vnic_id].fw_rss_cos_lb_ctx[ctx_idx] = INVALID_HW_RING_ID; in bnxt_hwrm_vnic_ctx_free_one()
5286 static void bnxt_hwrm_vnic_ctx_free(struct bnxt *bp) in bnxt_hwrm_vnic_ctx_free() argument
5290 for (i = 0; i < bp->nr_vnics; i++) { in bnxt_hwrm_vnic_ctx_free()
5291 struct bnxt_vnic_info *vnic = &bp->vnic_info[i]; in bnxt_hwrm_vnic_ctx_free()
5295 bnxt_hwrm_vnic_ctx_free_one(bp, i, j); in bnxt_hwrm_vnic_ctx_free()
5298 bp->rsscos_nr_ctxs = 0; in bnxt_hwrm_vnic_ctx_free()
5301 static int bnxt_hwrm_vnic_ctx_alloc(struct bnxt *bp, u16 vnic_id, u16 ctx_idx) in bnxt_hwrm_vnic_ctx_alloc() argument
5306 bp->hwrm_cmd_resp_addr; in bnxt_hwrm_vnic_ctx_alloc()
5308 bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_VNIC_RSS_COS_LB_CTX_ALLOC, -1, in bnxt_hwrm_vnic_ctx_alloc()
5311 mutex_lock(&bp->hwrm_cmd_lock); in bnxt_hwrm_vnic_ctx_alloc()
5312 rc = _hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT); in bnxt_hwrm_vnic_ctx_alloc()
5314 bp->vnic_info[vnic_id].fw_rss_cos_lb_ctx[ctx_idx] = in bnxt_hwrm_vnic_ctx_alloc()
5316 mutex_unlock(&bp->hwrm_cmd_lock); in bnxt_hwrm_vnic_ctx_alloc()
5321 static u32 bnxt_get_roce_vnic_mode(struct bnxt *bp) in bnxt_get_roce_vnic_mode() argument
5323 if (bp->flags & BNXT_FLAG_ROCE_MIRROR_CAP) in bnxt_get_roce_vnic_mode()
5328 int bnxt_hwrm_vnic_cfg(struct bnxt *bp, u16 vnic_id) in bnxt_hwrm_vnic_cfg() argument
5331 struct bnxt_vnic_info *vnic = &bp->vnic_info[vnic_id]; in bnxt_hwrm_vnic_cfg()
5335 bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_VNIC_CFG, -1, -1); in bnxt_hwrm_vnic_cfg()
5337 if (bp->flags & BNXT_FLAG_CHIP_P5) { in bnxt_hwrm_vnic_cfg()
5338 struct bnxt_rx_ring_info *rxr = &bp->rx_ring[0]; in bnxt_hwrm_vnic_cfg()
5343 cpu_to_le16(bnxt_cp_ring_for_rx(bp, rxr)); in bnxt_hwrm_vnic_cfg()
5357 cpu_to_le16(bp->vnic_info[0].fw_rss_cos_lb_ctx[0]); in bnxt_hwrm_vnic_cfg()
5365 if (BNXT_CHIP_TYPE_NITRO_A0(bp) && in bnxt_hwrm_vnic_cfg()
5377 else if ((vnic_id == 1) && BNXT_CHIP_TYPE_NITRO_A0(bp)) in bnxt_hwrm_vnic_cfg()
5378 ring = bp->rx_nr_rings - 1; in bnxt_hwrm_vnic_cfg()
5380 grp_idx = bp->rx_ring[ring].bnapi->index; in bnxt_hwrm_vnic_cfg()
5381 req.dflt_ring_grp = cpu_to_le16(bp->grp_info[grp_idx].fw_grp_id); in bnxt_hwrm_vnic_cfg()
5384 req.mru = cpu_to_le16(bp->dev->mtu + ETH_HLEN + VLAN_HLEN); in bnxt_hwrm_vnic_cfg()
5388 if (BNXT_VF(bp)) in bnxt_hwrm_vnic_cfg()
5389 def_vlan = bp->vf.vlan; in bnxt_hwrm_vnic_cfg()
5391 if ((bp->flags & BNXT_FLAG_STRIP_VLAN) || def_vlan) in bnxt_hwrm_vnic_cfg()
5393 if (!vnic_id && bnxt_ulp_registered(bp->edev, BNXT_ROCE_ULP)) in bnxt_hwrm_vnic_cfg()
5394 req.flags |= cpu_to_le32(bnxt_get_roce_vnic_mode(bp)); in bnxt_hwrm_vnic_cfg()
5396 return hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT); in bnxt_hwrm_vnic_cfg()
5399 static void bnxt_hwrm_vnic_free_one(struct bnxt *bp, u16 vnic_id) in bnxt_hwrm_vnic_free_one() argument
5401 if (bp->vnic_info[vnic_id].fw_vnic_id != INVALID_HW_RING_ID) { in bnxt_hwrm_vnic_free_one()
5404 bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_VNIC_FREE, -1, -1); in bnxt_hwrm_vnic_free_one()
5406 cpu_to_le32(bp->vnic_info[vnic_id].fw_vnic_id); in bnxt_hwrm_vnic_free_one()
5408 hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT); in bnxt_hwrm_vnic_free_one()
5409 bp->vnic_info[vnic_id].fw_vnic_id = INVALID_HW_RING_ID; in bnxt_hwrm_vnic_free_one()
5413 static void bnxt_hwrm_vnic_free(struct bnxt *bp) in bnxt_hwrm_vnic_free() argument
5417 for (i = 0; i < bp->nr_vnics; i++) in bnxt_hwrm_vnic_free()
5418 bnxt_hwrm_vnic_free_one(bp, i); in bnxt_hwrm_vnic_free()
5421 static int bnxt_hwrm_vnic_alloc(struct bnxt *bp, u16 vnic_id, in bnxt_hwrm_vnic_alloc() argument
5428 struct hwrm_vnic_alloc_output *resp = bp->hwrm_cmd_resp_addr; in bnxt_hwrm_vnic_alloc()
5429 struct bnxt_vnic_info *vnic = &bp->vnic_info[vnic_id]; in bnxt_hwrm_vnic_alloc()
5431 if (bp->flags & BNXT_FLAG_CHIP_P5) in bnxt_hwrm_vnic_alloc()
5436 grp_idx = bp->rx_ring[i].bnapi->index; in bnxt_hwrm_vnic_alloc()
5437 if (bp->grp_info[grp_idx].fw_grp_id == INVALID_HW_RING_ID) { in bnxt_hwrm_vnic_alloc()
5438 netdev_err(bp->dev, "Not enough ring groups avail:%x req:%x\n", in bnxt_hwrm_vnic_alloc()
5442 vnic->fw_grp_ids[j] = bp->grp_info[grp_idx].fw_grp_id; in bnxt_hwrm_vnic_alloc()
5451 bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_VNIC_ALLOC, -1, -1); in bnxt_hwrm_vnic_alloc()
5453 mutex_lock(&bp->hwrm_cmd_lock); in bnxt_hwrm_vnic_alloc()
5454 rc = _hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT); in bnxt_hwrm_vnic_alloc()
5457 mutex_unlock(&bp->hwrm_cmd_lock); in bnxt_hwrm_vnic_alloc()
5461 static int bnxt_hwrm_vnic_qcaps(struct bnxt *bp) in bnxt_hwrm_vnic_qcaps() argument
5463 struct hwrm_vnic_qcaps_output *resp = bp->hwrm_cmd_resp_addr; in bnxt_hwrm_vnic_qcaps()
5467 bp->hw_ring_stats_size = sizeof(struct ctx_hw_stats); in bnxt_hwrm_vnic_qcaps()
5468 bp->flags &= ~(BNXT_FLAG_NEW_RSS_CAP | BNXT_FLAG_ROCE_MIRROR_CAP); in bnxt_hwrm_vnic_qcaps()
5469 if (bp->hwrm_spec_code < 0x10600) in bnxt_hwrm_vnic_qcaps()
5472 bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_VNIC_QCAPS, -1, -1); in bnxt_hwrm_vnic_qcaps()
5473 mutex_lock(&bp->hwrm_cmd_lock); in bnxt_hwrm_vnic_qcaps()
5474 rc = _hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT); in bnxt_hwrm_vnic_qcaps()
5478 if (!(bp->flags & BNXT_FLAG_CHIP_P5) && in bnxt_hwrm_vnic_qcaps()
5480 bp->flags |= BNXT_FLAG_NEW_RSS_CAP; in bnxt_hwrm_vnic_qcaps()
5483 bp->flags |= BNXT_FLAG_ROCE_MIRROR_CAP; in bnxt_hwrm_vnic_qcaps()
5489 (BNXT_CHIP_P5_THOR(bp) && in bnxt_hwrm_vnic_qcaps()
5490 !(bp->fw_cap & BNXT_FW_CAP_EXT_HW_STATS_SUPPORTED))) in bnxt_hwrm_vnic_qcaps()
5491 bp->fw_cap |= BNXT_FW_CAP_VLAN_RX_STRIP; in bnxt_hwrm_vnic_qcaps()
5492 bp->max_tpa_v2 = le16_to_cpu(resp->max_aggs_supported); in bnxt_hwrm_vnic_qcaps()
5493 if (bp->max_tpa_v2) { in bnxt_hwrm_vnic_qcaps()
5494 if (BNXT_CHIP_P5_THOR(bp)) in bnxt_hwrm_vnic_qcaps()
5495 bp->hw_ring_stats_size = BNXT_RING_STATS_SIZE_P5; in bnxt_hwrm_vnic_qcaps()
5497 bp->hw_ring_stats_size = BNXT_RING_STATS_SIZE_P5_SR2; in bnxt_hwrm_vnic_qcaps()
5500 mutex_unlock(&bp->hwrm_cmd_lock); in bnxt_hwrm_vnic_qcaps()
5504 static int bnxt_hwrm_ring_grp_alloc(struct bnxt *bp) in bnxt_hwrm_ring_grp_alloc() argument
5509 if (bp->flags & BNXT_FLAG_CHIP_P5) in bnxt_hwrm_ring_grp_alloc()
5512 mutex_lock(&bp->hwrm_cmd_lock); in bnxt_hwrm_ring_grp_alloc()
5513 for (i = 0; i < bp->rx_nr_rings; i++) { in bnxt_hwrm_ring_grp_alloc()
5516 bp->hwrm_cmd_resp_addr; in bnxt_hwrm_ring_grp_alloc()
5517 unsigned int grp_idx = bp->rx_ring[i].bnapi->index; in bnxt_hwrm_ring_grp_alloc()
5519 bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_RING_GRP_ALLOC, -1, -1); in bnxt_hwrm_ring_grp_alloc()
5521 req.cr = cpu_to_le16(bp->grp_info[grp_idx].cp_fw_ring_id); in bnxt_hwrm_ring_grp_alloc()
5522 req.rr = cpu_to_le16(bp->grp_info[grp_idx].rx_fw_ring_id); in bnxt_hwrm_ring_grp_alloc()
5523 req.ar = cpu_to_le16(bp->grp_info[grp_idx].agg_fw_ring_id); in bnxt_hwrm_ring_grp_alloc()
5524 req.sc = cpu_to_le16(bp->grp_info[grp_idx].fw_stats_ctx); in bnxt_hwrm_ring_grp_alloc()
5526 rc = _hwrm_send_message(bp, &req, sizeof(req), in bnxt_hwrm_ring_grp_alloc()
5531 bp->grp_info[grp_idx].fw_grp_id = in bnxt_hwrm_ring_grp_alloc()
5534 mutex_unlock(&bp->hwrm_cmd_lock); in bnxt_hwrm_ring_grp_alloc()
5538 static void bnxt_hwrm_ring_grp_free(struct bnxt *bp) in bnxt_hwrm_ring_grp_free() argument
5543 if (!bp->grp_info || (bp->flags & BNXT_FLAG_CHIP_P5)) in bnxt_hwrm_ring_grp_free()
5546 bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_RING_GRP_FREE, -1, -1); in bnxt_hwrm_ring_grp_free()
5548 mutex_lock(&bp->hwrm_cmd_lock); in bnxt_hwrm_ring_grp_free()
5549 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_hwrm_ring_grp_free()
5550 if (bp->grp_info[i].fw_grp_id == INVALID_HW_RING_ID) in bnxt_hwrm_ring_grp_free()
5553 cpu_to_le32(bp->grp_info[i].fw_grp_id); in bnxt_hwrm_ring_grp_free()
5555 _hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT); in bnxt_hwrm_ring_grp_free()
5556 bp->grp_info[i].fw_grp_id = INVALID_HW_RING_ID; in bnxt_hwrm_ring_grp_free()
5558 mutex_unlock(&bp->hwrm_cmd_lock); in bnxt_hwrm_ring_grp_free()
5561 static int hwrm_ring_alloc_send_msg(struct bnxt *bp, in hwrm_ring_alloc_send_msg() argument
5567 struct hwrm_ring_alloc_output *resp = bp->hwrm_cmd_resp_addr; in hwrm_ring_alloc_send_msg()
5572 bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_RING_ALLOC, -1, -1); in hwrm_ring_alloc_send_msg()
5595 grp_info = &bp->grp_info[ring->grp_idx]; in hwrm_ring_alloc_send_msg()
5596 req.cmpl_ring_id = cpu_to_le16(bnxt_cp_ring_for_tx(bp, txr)); in hwrm_ring_alloc_send_msg()
5597 req.length = cpu_to_le32(bp->tx_ring_mask + 1); in hwrm_ring_alloc_send_msg()
5604 req.length = cpu_to_le32(bp->rx_ring_mask + 1); in hwrm_ring_alloc_send_msg()
5605 if (bp->flags & BNXT_FLAG_CHIP_P5) { in hwrm_ring_alloc_send_msg()
5609 grp_info = &bp->grp_info[ring->grp_idx]; in hwrm_ring_alloc_send_msg()
5610 req.rx_buf_size = cpu_to_le16(bp->rx_buf_use_size); in hwrm_ring_alloc_send_msg()
5620 if (bp->flags & BNXT_FLAG_CHIP_P5) { in hwrm_ring_alloc_send_msg()
5623 grp_info = &bp->grp_info[ring->grp_idx]; in hwrm_ring_alloc_send_msg()
5633 req.length = cpu_to_le32(bp->rx_agg_ring_mask + 1); in hwrm_ring_alloc_send_msg()
5637 req.length = cpu_to_le32(bp->cp_ring_mask + 1); in hwrm_ring_alloc_send_msg()
5638 if (bp->flags & BNXT_FLAG_CHIP_P5) { in hwrm_ring_alloc_send_msg()
5640 grp_info = &bp->grp_info[map_index]; in hwrm_ring_alloc_send_msg()
5645 } else if (bp->flags & BNXT_FLAG_USING_MSIX) { in hwrm_ring_alloc_send_msg()
5651 req.length = cpu_to_le32(bp->cp_ring_mask + 1); in hwrm_ring_alloc_send_msg()
5652 if (bp->flags & BNXT_FLAG_USING_MSIX) in hwrm_ring_alloc_send_msg()
5656 netdev_err(bp->dev, "hwrm alloc invalid ring type %d\n", in hwrm_ring_alloc_send_msg()
5661 mutex_lock(&bp->hwrm_cmd_lock); in hwrm_ring_alloc_send_msg()
5662 rc = _hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT); in hwrm_ring_alloc_send_msg()
5665 mutex_unlock(&bp->hwrm_cmd_lock); in hwrm_ring_alloc_send_msg()
5668 netdev_err(bp->dev, "hwrm_ring_alloc type %d failed. rc:%x err:%x\n", in hwrm_ring_alloc_send_msg()
5676 static int bnxt_hwrm_set_async_event_cr(struct bnxt *bp, int idx) in bnxt_hwrm_set_async_event_cr() argument
5680 if (BNXT_PF(bp)) { in bnxt_hwrm_set_async_event_cr()
5683 bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_FUNC_CFG, -1, -1); in bnxt_hwrm_set_async_event_cr()
5687 rc = hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT); in bnxt_hwrm_set_async_event_cr()
5691 bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_FUNC_VF_CFG, -1, -1); in bnxt_hwrm_set_async_event_cr()
5695 rc = hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT); in bnxt_hwrm_set_async_event_cr()
5700 static void bnxt_set_db(struct bnxt *bp, struct bnxt_db_info *db, u32 ring_type, in bnxt_set_db() argument
5703 if (bp->flags & BNXT_FLAG_CHIP_P5) { in bnxt_set_db()
5704 if (BNXT_PF(bp)) in bnxt_set_db()
5705 db->doorbell = bp->bar1 + DB_PF_OFFSET_P5; in bnxt_set_db()
5707 db->doorbell = bp->bar1 + DB_VF_OFFSET_P5; in bnxt_set_db()
5725 db->doorbell = bp->bar1 + map_idx * 0x80; in bnxt_set_db()
5741 static int bnxt_hwrm_ring_alloc(struct bnxt *bp) in bnxt_hwrm_ring_alloc() argument
5743 bool agg_rings = !!(bp->flags & BNXT_FLAG_AGG_RINGS); in bnxt_hwrm_ring_alloc()
5747 if (bp->flags & BNXT_FLAG_CHIP_P5) in bnxt_hwrm_ring_alloc()
5751 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_hwrm_ring_alloc()
5752 struct bnxt_napi *bnapi = bp->bnapi[i]; in bnxt_hwrm_ring_alloc()
5758 vector = bp->irq_tbl[map_idx].vector; in bnxt_hwrm_ring_alloc()
5760 rc = hwrm_ring_alloc_send_msg(bp, ring, type, map_idx); in bnxt_hwrm_ring_alloc()
5765 bnxt_set_db(bp, &cpr->cp_db, type, map_idx, ring->fw_ring_id); in bnxt_hwrm_ring_alloc()
5766 bnxt_db_nq(bp, &cpr->cp_db, cpr->cp_raw_cons); in bnxt_hwrm_ring_alloc()
5768 bp->grp_info[i].cp_fw_ring_id = ring->fw_ring_id; in bnxt_hwrm_ring_alloc()
5771 rc = bnxt_hwrm_set_async_event_cr(bp, ring->fw_ring_id); in bnxt_hwrm_ring_alloc()
5773 netdev_warn(bp->dev, "Failed to set async event completion ring.\n"); in bnxt_hwrm_ring_alloc()
5778 for (i = 0; i < bp->tx_nr_rings; i++) { in bnxt_hwrm_ring_alloc()
5779 struct bnxt_tx_ring_info *txr = &bp->tx_ring[i]; in bnxt_hwrm_ring_alloc()
5783 if (bp->flags & BNXT_FLAG_CHIP_P5) { in bnxt_hwrm_ring_alloc()
5793 rc = hwrm_ring_alloc_send_msg(bp, ring, type2, map_idx); in bnxt_hwrm_ring_alloc()
5796 bnxt_set_db(bp, &cpr2->cp_db, type2, map_idx, in bnxt_hwrm_ring_alloc()
5798 bnxt_db_cq(bp, &cpr2->cp_db, cpr2->cp_raw_cons); in bnxt_hwrm_ring_alloc()
5802 rc = hwrm_ring_alloc_send_msg(bp, ring, type, map_idx); in bnxt_hwrm_ring_alloc()
5805 bnxt_set_db(bp, &txr->tx_db, type, map_idx, ring->fw_ring_id); in bnxt_hwrm_ring_alloc()
5809 for (i = 0; i < bp->rx_nr_rings; i++) { in bnxt_hwrm_ring_alloc()
5810 struct bnxt_rx_ring_info *rxr = &bp->rx_ring[i]; in bnxt_hwrm_ring_alloc()
5815 rc = hwrm_ring_alloc_send_msg(bp, ring, type, map_idx); in bnxt_hwrm_ring_alloc()
5818 bnxt_set_db(bp, &rxr->rx_db, type, map_idx, ring->fw_ring_id); in bnxt_hwrm_ring_alloc()
5821 bnxt_db_write(bp, &rxr->rx_db, rxr->rx_prod); in bnxt_hwrm_ring_alloc()
5822 bp->grp_info[map_idx].rx_fw_ring_id = ring->fw_ring_id; in bnxt_hwrm_ring_alloc()
5823 if (bp->flags & BNXT_FLAG_CHIP_P5) { in bnxt_hwrm_ring_alloc()
5831 rc = hwrm_ring_alloc_send_msg(bp, ring, type2, map_idx); in bnxt_hwrm_ring_alloc()
5834 bnxt_set_db(bp, &cpr2->cp_db, type2, map_idx, in bnxt_hwrm_ring_alloc()
5836 bnxt_db_cq(bp, &cpr2->cp_db, cpr2->cp_raw_cons); in bnxt_hwrm_ring_alloc()
5842 for (i = 0; i < bp->rx_nr_rings; i++) { in bnxt_hwrm_ring_alloc()
5843 struct bnxt_rx_ring_info *rxr = &bp->rx_ring[i]; in bnxt_hwrm_ring_alloc()
5847 u32 map_idx = grp_idx + bp->rx_nr_rings; in bnxt_hwrm_ring_alloc()
5849 rc = hwrm_ring_alloc_send_msg(bp, ring, type, map_idx); in bnxt_hwrm_ring_alloc()
5853 bnxt_set_db(bp, &rxr->rx_agg_db, type, map_idx, in bnxt_hwrm_ring_alloc()
5855 bnxt_db_write(bp, &rxr->rx_agg_db, rxr->rx_agg_prod); in bnxt_hwrm_ring_alloc()
5856 bnxt_db_write(bp, &rxr->rx_db, rxr->rx_prod); in bnxt_hwrm_ring_alloc()
5857 bp->grp_info[grp_idx].agg_fw_ring_id = ring->fw_ring_id; in bnxt_hwrm_ring_alloc()
5864 static int hwrm_ring_free_send_msg(struct bnxt *bp, in hwrm_ring_free_send_msg() argument
5870 struct hwrm_ring_free_output *resp = bp->hwrm_cmd_resp_addr; in hwrm_ring_free_send_msg()
5873 if (BNXT_NO_FW_ACCESS(bp)) in hwrm_ring_free_send_msg()
5876 bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_RING_FREE, cmpl_ring_id, -1); in hwrm_ring_free_send_msg()
5880 mutex_lock(&bp->hwrm_cmd_lock); in hwrm_ring_free_send_msg()
5881 rc = _hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT); in hwrm_ring_free_send_msg()
5883 mutex_unlock(&bp->hwrm_cmd_lock); in hwrm_ring_free_send_msg()
5886 netdev_err(bp->dev, "hwrm_ring_free type %d failed. rc:%x err:%x\n", in hwrm_ring_free_send_msg()
5893 static void bnxt_hwrm_ring_free(struct bnxt *bp, bool close_path) in bnxt_hwrm_ring_free() argument
5898 if (!bp->bnapi) in bnxt_hwrm_ring_free()
5901 for (i = 0; i < bp->tx_nr_rings; i++) { in bnxt_hwrm_ring_free()
5902 struct bnxt_tx_ring_info *txr = &bp->tx_ring[i]; in bnxt_hwrm_ring_free()
5906 u32 cmpl_ring_id = bnxt_cp_ring_for_tx(bp, txr); in bnxt_hwrm_ring_free()
5908 hwrm_ring_free_send_msg(bp, ring, in bnxt_hwrm_ring_free()
5916 for (i = 0; i < bp->rx_nr_rings; i++) { in bnxt_hwrm_ring_free()
5917 struct bnxt_rx_ring_info *rxr = &bp->rx_ring[i]; in bnxt_hwrm_ring_free()
5922 u32 cmpl_ring_id = bnxt_cp_ring_for_rx(bp, rxr); in bnxt_hwrm_ring_free()
5924 hwrm_ring_free_send_msg(bp, ring, in bnxt_hwrm_ring_free()
5929 bp->grp_info[grp_idx].rx_fw_ring_id = in bnxt_hwrm_ring_free()
5934 if (bp->flags & BNXT_FLAG_CHIP_P5) in bnxt_hwrm_ring_free()
5938 for (i = 0; i < bp->rx_nr_rings; i++) { in bnxt_hwrm_ring_free()
5939 struct bnxt_rx_ring_info *rxr = &bp->rx_ring[i]; in bnxt_hwrm_ring_free()
5944 u32 cmpl_ring_id = bnxt_cp_ring_for_rx(bp, rxr); in bnxt_hwrm_ring_free()
5946 hwrm_ring_free_send_msg(bp, ring, type, in bnxt_hwrm_ring_free()
5950 bp->grp_info[grp_idx].agg_fw_ring_id = in bnxt_hwrm_ring_free()
5959 bnxt_disable_int_sync(bp); in bnxt_hwrm_ring_free()
5961 if (bp->flags & BNXT_FLAG_CHIP_P5) in bnxt_hwrm_ring_free()
5965 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_hwrm_ring_free()
5966 struct bnxt_napi *bnapi = bp->bnapi[i]; in bnxt_hwrm_ring_free()
5978 hwrm_ring_free_send_msg(bp, ring, in bnxt_hwrm_ring_free()
5986 hwrm_ring_free_send_msg(bp, ring, type, in bnxt_hwrm_ring_free()
5989 bp->grp_info[i].cp_fw_ring_id = INVALID_HW_RING_ID; in bnxt_hwrm_ring_free()
5994 static int bnxt_trim_rings(struct bnxt *bp, int *rx, int *tx, int max,
5997 static int bnxt_hwrm_get_rings(struct bnxt *bp) in bnxt_hwrm_get_rings() argument
5999 struct hwrm_func_qcfg_output *resp = bp->hwrm_cmd_resp_addr; in bnxt_hwrm_get_rings()
6000 struct bnxt_hw_resc *hw_resc = &bp->hw_resc; in bnxt_hwrm_get_rings()
6004 if (bp->hwrm_spec_code < 0x10601) in bnxt_hwrm_get_rings()
6007 bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_FUNC_QCFG, -1, -1); in bnxt_hwrm_get_rings()
6009 mutex_lock(&bp->hwrm_cmd_lock); in bnxt_hwrm_get_rings()
6010 rc = _hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT); in bnxt_hwrm_get_rings()
6012 mutex_unlock(&bp->hwrm_cmd_lock); in bnxt_hwrm_get_rings()
6017 if (BNXT_NEW_RM(bp)) { in bnxt_hwrm_get_rings()
6027 if (bp->flags & BNXT_FLAG_CHIP_P5) { in bnxt_hwrm_get_rings()
6031 if (bp->flags & BNXT_FLAG_AGG_RINGS) in bnxt_hwrm_get_rings()
6034 bnxt_trim_rings(bp, &rx, &tx, cp, false); in bnxt_hwrm_get_rings()
6035 if (bp->flags & BNXT_FLAG_AGG_RINGS) in bnxt_hwrm_get_rings()
6046 mutex_unlock(&bp->hwrm_cmd_lock); in bnxt_hwrm_get_rings()
6051 int __bnxt_hwrm_get_tx_rings(struct bnxt *bp, u16 fid, int *tx_rings) in __bnxt_hwrm_get_tx_rings() argument
6053 struct hwrm_func_qcfg_output *resp = bp->hwrm_cmd_resp_addr; in __bnxt_hwrm_get_tx_rings()
6057 if (bp->hwrm_spec_code < 0x10601) in __bnxt_hwrm_get_tx_rings()
6060 bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_FUNC_QCFG, -1, -1); in __bnxt_hwrm_get_tx_rings()
6062 rc = _hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT); in __bnxt_hwrm_get_tx_rings()
6069 static bool bnxt_rfs_supported(struct bnxt *bp);
6072 __bnxt_hwrm_reserve_pf_rings(struct bnxt *bp, struct hwrm_func_cfg_input *req, in __bnxt_hwrm_reserve_pf_rings() argument
6078 bnxt_hwrm_cmd_hdr_init(bp, req, HWRM_FUNC_CFG, -1, -1); in __bnxt_hwrm_reserve_pf_rings()
6082 if (BNXT_NEW_RM(bp)) { in __bnxt_hwrm_reserve_pf_rings()
6085 if (bp->flags & BNXT_FLAG_CHIP_P5) { in __bnxt_hwrm_reserve_pf_rings()
6101 if (bp->flags & BNXT_FLAG_CHIP_P5) { in __bnxt_hwrm_reserve_pf_rings()
6110 if (!(bp->flags & BNXT_FLAG_NEW_RSS_CAP) && in __bnxt_hwrm_reserve_pf_rings()
6111 bnxt_rfs_supported(bp)) in __bnxt_hwrm_reserve_pf_rings()
6122 __bnxt_hwrm_reserve_vf_rings(struct bnxt *bp, in __bnxt_hwrm_reserve_vf_rings() argument
6129 bnxt_hwrm_cmd_hdr_init(bp, req, HWRM_FUNC_VF_CFG, -1, -1); in __bnxt_hwrm_reserve_vf_rings()
6134 if (bp->flags & BNXT_FLAG_CHIP_P5) { in __bnxt_hwrm_reserve_vf_rings()
6149 if (bp->flags & BNXT_FLAG_CHIP_P5) { in __bnxt_hwrm_reserve_vf_rings()
6164 bnxt_hwrm_reserve_pf_rings(struct bnxt *bp, int tx_rings, int rx_rings, in bnxt_hwrm_reserve_pf_rings() argument
6170 __bnxt_hwrm_reserve_pf_rings(bp, &req, tx_rings, rx_rings, ring_grps, in bnxt_hwrm_reserve_pf_rings()
6175 rc = hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT); in bnxt_hwrm_reserve_pf_rings()
6179 if (bp->hwrm_spec_code < 0x10601) in bnxt_hwrm_reserve_pf_rings()
6180 bp->hw_resc.resv_tx_rings = tx_rings; in bnxt_hwrm_reserve_pf_rings()
6182 return bnxt_hwrm_get_rings(bp); in bnxt_hwrm_reserve_pf_rings()
6186 bnxt_hwrm_reserve_vf_rings(struct bnxt *bp, int tx_rings, int rx_rings, in bnxt_hwrm_reserve_vf_rings() argument
6192 if (!BNXT_NEW_RM(bp)) { in bnxt_hwrm_reserve_vf_rings()
6193 bp->hw_resc.resv_tx_rings = tx_rings; in bnxt_hwrm_reserve_vf_rings()
6197 __bnxt_hwrm_reserve_vf_rings(bp, &req, tx_rings, rx_rings, ring_grps, in bnxt_hwrm_reserve_vf_rings()
6199 rc = hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT); in bnxt_hwrm_reserve_vf_rings()
6203 return bnxt_hwrm_get_rings(bp); in bnxt_hwrm_reserve_vf_rings()
6206 static int bnxt_hwrm_reserve_rings(struct bnxt *bp, int tx, int rx, int grp, in bnxt_hwrm_reserve_rings() argument
6209 if (BNXT_PF(bp)) in bnxt_hwrm_reserve_rings()
6210 return bnxt_hwrm_reserve_pf_rings(bp, tx, rx, grp, cp, stat, in bnxt_hwrm_reserve_rings()
6213 return bnxt_hwrm_reserve_vf_rings(bp, tx, rx, grp, cp, stat, in bnxt_hwrm_reserve_rings()
6217 int bnxt_nq_rings_in_use(struct bnxt *bp) in bnxt_nq_rings_in_use() argument
6219 int cp = bp->cp_nr_rings; in bnxt_nq_rings_in_use()
6222 ulp_msix = bnxt_get_ulp_msix_num(bp); in bnxt_nq_rings_in_use()
6224 ulp_base = bnxt_get_ulp_msix_base(bp); in bnxt_nq_rings_in_use()
6232 static int bnxt_cp_rings_in_use(struct bnxt *bp) in bnxt_cp_rings_in_use() argument
6236 if (!(bp->flags & BNXT_FLAG_CHIP_P5)) in bnxt_cp_rings_in_use()
6237 return bnxt_nq_rings_in_use(bp); in bnxt_cp_rings_in_use()
6239 cp = bp->tx_nr_rings + bp->rx_nr_rings; in bnxt_cp_rings_in_use()
6243 static int bnxt_get_func_stat_ctxs(struct bnxt *bp) in bnxt_get_func_stat_ctxs() argument
6245 int ulp_stat = bnxt_get_ulp_stat_ctxs(bp); in bnxt_get_func_stat_ctxs()
6246 int cp = bp->cp_nr_rings; in bnxt_get_func_stat_ctxs()
6251 if (bnxt_nq_rings_in_use(bp) > cp + bnxt_get_ulp_msix_num(bp)) in bnxt_get_func_stat_ctxs()
6252 return bnxt_get_ulp_msix_base(bp) + ulp_stat; in bnxt_get_func_stat_ctxs()
6260 static void bnxt_check_rss_tbl_no_rmgr(struct bnxt *bp) in bnxt_check_rss_tbl_no_rmgr() argument
6262 struct bnxt_hw_resc *hw_resc = &bp->hw_resc; in bnxt_check_rss_tbl_no_rmgr()
6265 if (hw_resc->resv_rx_rings != bp->rx_nr_rings) { in bnxt_check_rss_tbl_no_rmgr()
6266 hw_resc->resv_rx_rings = bp->rx_nr_rings; in bnxt_check_rss_tbl_no_rmgr()
6267 if (!netif_is_rxfh_configured(bp->dev)) in bnxt_check_rss_tbl_no_rmgr()
6268 bnxt_set_dflt_rss_indir_tbl(bp); in bnxt_check_rss_tbl_no_rmgr()
6272 static bool bnxt_need_reserve_rings(struct bnxt *bp) in bnxt_need_reserve_rings() argument
6274 struct bnxt_hw_resc *hw_resc = &bp->hw_resc; in bnxt_need_reserve_rings()
6275 int cp = bnxt_cp_rings_in_use(bp); in bnxt_need_reserve_rings()
6276 int nq = bnxt_nq_rings_in_use(bp); in bnxt_need_reserve_rings()
6277 int rx = bp->rx_nr_rings, stat; in bnxt_need_reserve_rings()
6280 if (hw_resc->resv_tx_rings != bp->tx_nr_rings && in bnxt_need_reserve_rings()
6281 bp->hwrm_spec_code >= 0x10601) in bnxt_need_reserve_rings()
6289 if (!BNXT_NEW_RM(bp)) { in bnxt_need_reserve_rings()
6290 bnxt_check_rss_tbl_no_rmgr(bp); in bnxt_need_reserve_rings()
6293 if ((bp->flags & BNXT_FLAG_RFS) && !(bp->flags & BNXT_FLAG_CHIP_P5)) in bnxt_need_reserve_rings()
6295 if (bp->flags & BNXT_FLAG_AGG_RINGS) in bnxt_need_reserve_rings()
6297 stat = bnxt_get_func_stat_ctxs(bp); in bnxt_need_reserve_rings()
6301 !(bp->flags & BNXT_FLAG_CHIP_P5))) in bnxt_need_reserve_rings()
6303 if ((bp->flags & BNXT_FLAG_CHIP_P5) && BNXT_PF(bp) && in bnxt_need_reserve_rings()
6309 static int __bnxt_reserve_rings(struct bnxt *bp) in __bnxt_reserve_rings() argument
6311 struct bnxt_hw_resc *hw_resc = &bp->hw_resc; in __bnxt_reserve_rings()
6312 int cp = bnxt_nq_rings_in_use(bp); in __bnxt_reserve_rings()
6313 int tx = bp->tx_nr_rings; in __bnxt_reserve_rings()
6314 int rx = bp->rx_nr_rings; in __bnxt_reserve_rings()
6319 if (!bnxt_need_reserve_rings(bp)) in __bnxt_reserve_rings()
6322 if (bp->flags & BNXT_FLAG_SHARED_RINGS) in __bnxt_reserve_rings()
6324 if ((bp->flags & BNXT_FLAG_RFS) && !(bp->flags & BNXT_FLAG_CHIP_P5)) in __bnxt_reserve_rings()
6326 if (bp->flags & BNXT_FLAG_AGG_RINGS) in __bnxt_reserve_rings()
6328 grp = bp->rx_nr_rings; in __bnxt_reserve_rings()
6329 stat = bnxt_get_func_stat_ctxs(bp); in __bnxt_reserve_rings()
6331 rc = bnxt_hwrm_reserve_rings(bp, tx, rx, grp, cp, stat, vnic); in __bnxt_reserve_rings()
6336 if (BNXT_NEW_RM(bp)) { in __bnxt_reserve_rings()
6345 if (bp->flags & BNXT_FLAG_AGG_RINGS) { in __bnxt_reserve_rings()
6349 if (netif_running(bp->dev)) in __bnxt_reserve_rings()
6352 bp->flags &= ~BNXT_FLAG_AGG_RINGS; in __bnxt_reserve_rings()
6353 bp->flags |= BNXT_FLAG_NO_AGG_RINGS; in __bnxt_reserve_rings()
6354 bp->dev->hw_features &= ~NETIF_F_LRO; in __bnxt_reserve_rings()
6355 bp->dev->features &= ~NETIF_F_LRO; in __bnxt_reserve_rings()
6356 bnxt_set_ring_params(bp); in __bnxt_reserve_rings()
6360 cp = min_t(int, cp, bp->cp_nr_rings); in __bnxt_reserve_rings()
6361 if (stat > bnxt_get_ulp_stat_ctxs(bp)) in __bnxt_reserve_rings()
6362 stat -= bnxt_get_ulp_stat_ctxs(bp); in __bnxt_reserve_rings()
6364 rc = bnxt_trim_rings(bp, &rx_rings, &tx, cp, sh); in __bnxt_reserve_rings()
6365 if (bp->flags & BNXT_FLAG_AGG_RINGS) in __bnxt_reserve_rings()
6368 bp->tx_nr_rings = tx; in __bnxt_reserve_rings()
6373 if (rx_rings != bp->rx_nr_rings) { in __bnxt_reserve_rings()
6374 netdev_warn(bp->dev, "Able to reserve only %d out of %d requested RX rings\n", in __bnxt_reserve_rings()
6375 rx_rings, bp->rx_nr_rings); in __bnxt_reserve_rings()
6376 if ((bp->dev->priv_flags & IFF_RXFH_CONFIGURED) && in __bnxt_reserve_rings()
6377 (bnxt_get_nr_rss_ctxs(bp, bp->rx_nr_rings) != in __bnxt_reserve_rings()
6378 bnxt_get_nr_rss_ctxs(bp, rx_rings) || in __bnxt_reserve_rings()
6379 bnxt_get_max_rss_ring(bp) >= rx_rings)) { in __bnxt_reserve_rings()
6380 netdev_warn(bp->dev, "RSS table entries reverting to default\n"); in __bnxt_reserve_rings()
6381 bp->dev->priv_flags &= ~IFF_RXFH_CONFIGURED; in __bnxt_reserve_rings()
6384 bp->rx_nr_rings = rx_rings; in __bnxt_reserve_rings()
6385 bp->cp_nr_rings = cp; in __bnxt_reserve_rings()
6390 if (!netif_is_rxfh_configured(bp->dev)) in __bnxt_reserve_rings()
6391 bnxt_set_dflt_rss_indir_tbl(bp); in __bnxt_reserve_rings()
6396 static int bnxt_hwrm_check_vf_rings(struct bnxt *bp, int tx_rings, int rx_rings, in bnxt_hwrm_check_vf_rings() argument
6403 if (!BNXT_NEW_RM(bp)) in bnxt_hwrm_check_vf_rings()
6406 __bnxt_hwrm_reserve_vf_rings(bp, &req, tx_rings, rx_rings, ring_grps, in bnxt_hwrm_check_vf_rings()
6414 if (!(bp->flags & BNXT_FLAG_CHIP_P5)) in bnxt_hwrm_check_vf_rings()
6418 return hwrm_send_message_silent(bp, &req, sizeof(req), in bnxt_hwrm_check_vf_rings()
6422 static int bnxt_hwrm_check_pf_rings(struct bnxt *bp, int tx_rings, int rx_rings, in bnxt_hwrm_check_pf_rings() argument
6429 __bnxt_hwrm_reserve_pf_rings(bp, &req, tx_rings, rx_rings, ring_grps, in bnxt_hwrm_check_pf_rings()
6432 if (BNXT_NEW_RM(bp)) { in bnxt_hwrm_check_pf_rings()
6437 if (bp->flags & BNXT_FLAG_CHIP_P5) in bnxt_hwrm_check_pf_rings()
6445 return hwrm_send_message_silent(bp, &req, sizeof(req), in bnxt_hwrm_check_pf_rings()
6449 static int bnxt_hwrm_check_rings(struct bnxt *bp, int tx_rings, int rx_rings, in bnxt_hwrm_check_rings() argument
6453 if (bp->hwrm_spec_code < 0x10801) in bnxt_hwrm_check_rings()
6456 if (BNXT_PF(bp)) in bnxt_hwrm_check_rings()
6457 return bnxt_hwrm_check_pf_rings(bp, tx_rings, rx_rings, in bnxt_hwrm_check_rings()
6461 return bnxt_hwrm_check_vf_rings(bp, tx_rings, rx_rings, ring_grps, in bnxt_hwrm_check_rings()
6465 static void bnxt_hwrm_coal_params_qcaps(struct bnxt *bp) in bnxt_hwrm_coal_params_qcaps() argument
6467 struct hwrm_ring_aggint_qcaps_output *resp = bp->hwrm_cmd_resp_addr; in bnxt_hwrm_coal_params_qcaps()
6468 struct bnxt_coal_cap *coal_cap = &bp->coal_cap; in bnxt_hwrm_coal_params_qcaps()
6482 if (bp->hwrm_spec_code < 0x10902) in bnxt_hwrm_coal_params_qcaps()
6485 bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_RING_AGGINT_QCAPS, -1, -1); in bnxt_hwrm_coal_params_qcaps()
6486 mutex_lock(&bp->hwrm_cmd_lock); in bnxt_hwrm_coal_params_qcaps()
6487 rc = _hwrm_send_message_silent(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT); in bnxt_hwrm_coal_params_qcaps()
6507 mutex_unlock(&bp->hwrm_cmd_lock); in bnxt_hwrm_coal_params_qcaps()
6510 static u16 bnxt_usec_to_coal_tmr(struct bnxt *bp, u16 usec) in bnxt_usec_to_coal_tmr() argument
6512 struct bnxt_coal_cap *coal_cap = &bp->coal_cap; in bnxt_usec_to_coal_tmr()
6517 static void bnxt_hwrm_set_coal_params(struct bnxt *bp, in bnxt_hwrm_set_coal_params() argument
6521 struct bnxt_coal_cap *coal_cap = &bp->coal_cap; in bnxt_hwrm_set_coal_params()
6540 tmr = bnxt_usec_to_coal_tmr(bp, hw_coal->coal_ticks); in bnxt_hwrm_set_coal_params()
6558 tmr = bnxt_usec_to_coal_tmr(bp, hw_coal->coal_ticks_irq); in bnxt_hwrm_set_coal_params()
6576 static int __bnxt_hwrm_set_coal_nq(struct bnxt *bp, struct bnxt_napi *bnapi, in __bnxt_hwrm_set_coal_nq() argument
6581 struct bnxt_coal_cap *coal_cap = &bp->coal_cap; in __bnxt_hwrm_set_coal_nq()
6588 bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_RING_CMPL_RING_CFG_AGGINT_PARAMS, in __bnxt_hwrm_set_coal_nq()
6594 tmr = bnxt_usec_to_coal_tmr(bp, hw_coal->coal_ticks) / 2; in __bnxt_hwrm_set_coal_nq()
6598 return _hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT); in __bnxt_hwrm_set_coal_nq()
6601 int bnxt_hwrm_set_ring_coal(struct bnxt *bp, struct bnxt_napi *bnapi) in bnxt_hwrm_set_ring_coal() argument
6610 memcpy(&coal, &bp->rx_coal, sizeof(struct bnxt_coal)); in bnxt_hwrm_set_ring_coal()
6618 bnxt_hwrm_cmd_hdr_init(bp, &req_rx, in bnxt_hwrm_set_ring_coal()
6621 bnxt_hwrm_set_coal_params(bp, &coal, &req_rx); in bnxt_hwrm_set_ring_coal()
6623 req_rx.ring_id = cpu_to_le16(bnxt_cp_ring_for_rx(bp, bnapi->rx_ring)); in bnxt_hwrm_set_ring_coal()
6625 return hwrm_send_message(bp, &req_rx, sizeof(req_rx), in bnxt_hwrm_set_ring_coal()
6629 int bnxt_hwrm_set_coal(struct bnxt *bp) in bnxt_hwrm_set_coal() argument
6635 bnxt_hwrm_cmd_hdr_init(bp, &req_rx, in bnxt_hwrm_set_coal()
6637 bnxt_hwrm_cmd_hdr_init(bp, &req_tx, in bnxt_hwrm_set_coal()
6640 bnxt_hwrm_set_coal_params(bp, &bp->rx_coal, &req_rx); in bnxt_hwrm_set_coal()
6641 bnxt_hwrm_set_coal_params(bp, &bp->tx_coal, &req_tx); in bnxt_hwrm_set_coal()
6643 mutex_lock(&bp->hwrm_cmd_lock); in bnxt_hwrm_set_coal()
6644 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_hwrm_set_coal()
6645 struct bnxt_napi *bnapi = bp->bnapi[i]; in bnxt_hwrm_set_coal()
6651 ring_id = bnxt_cp_ring_for_tx(bp, bnapi->tx_ring); in bnxt_hwrm_set_coal()
6654 ring_id = bnxt_cp_ring_for_rx(bp, bnapi->rx_ring); in bnxt_hwrm_set_coal()
6658 rc = _hwrm_send_message(bp, req, sizeof(*req), in bnxt_hwrm_set_coal()
6663 if (!(bp->flags & BNXT_FLAG_CHIP_P5)) in bnxt_hwrm_set_coal()
6668 ring_id = bnxt_cp_ring_for_tx(bp, bnapi->tx_ring); in bnxt_hwrm_set_coal()
6670 rc = _hwrm_send_message(bp, req, sizeof(*req), in bnxt_hwrm_set_coal()
6676 hw_coal = &bp->rx_coal; in bnxt_hwrm_set_coal()
6678 hw_coal = &bp->tx_coal; in bnxt_hwrm_set_coal()
6679 __bnxt_hwrm_set_coal_nq(bp, bnapi, hw_coal); in bnxt_hwrm_set_coal()
6681 mutex_unlock(&bp->hwrm_cmd_lock); in bnxt_hwrm_set_coal()
6685 static void bnxt_hwrm_stat_ctx_free(struct bnxt *bp) in bnxt_hwrm_stat_ctx_free() argument
6691 if (!bp->bnapi) in bnxt_hwrm_stat_ctx_free()
6694 if (BNXT_CHIP_TYPE_NITRO_A0(bp)) in bnxt_hwrm_stat_ctx_free()
6697 bnxt_hwrm_cmd_hdr_init(bp, &req0, HWRM_STAT_CTX_CLR_STATS, -1, -1); in bnxt_hwrm_stat_ctx_free()
6698 bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_STAT_CTX_FREE, -1, -1); in bnxt_hwrm_stat_ctx_free()
6700 mutex_lock(&bp->hwrm_cmd_lock); in bnxt_hwrm_stat_ctx_free()
6701 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_hwrm_stat_ctx_free()
6702 struct bnxt_napi *bnapi = bp->bnapi[i]; in bnxt_hwrm_stat_ctx_free()
6707 if (BNXT_FW_MAJ(bp) <= 20) { in bnxt_hwrm_stat_ctx_free()
6709 _hwrm_send_message(bp, &req0, sizeof(req0), in bnxt_hwrm_stat_ctx_free()
6712 _hwrm_send_message(bp, &req, sizeof(req), in bnxt_hwrm_stat_ctx_free()
6718 mutex_unlock(&bp->hwrm_cmd_lock); in bnxt_hwrm_stat_ctx_free()
6721 static int bnxt_hwrm_stat_ctx_alloc(struct bnxt *bp) in bnxt_hwrm_stat_ctx_alloc() argument
6725 struct hwrm_stat_ctx_alloc_output *resp = bp->hwrm_cmd_resp_addr; in bnxt_hwrm_stat_ctx_alloc()
6727 if (BNXT_CHIP_TYPE_NITRO_A0(bp)) in bnxt_hwrm_stat_ctx_alloc()
6730 bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_STAT_CTX_ALLOC, -1, -1); in bnxt_hwrm_stat_ctx_alloc()
6732 req.stats_dma_length = cpu_to_le16(bp->hw_ring_stats_size); in bnxt_hwrm_stat_ctx_alloc()
6733 req.update_period_ms = cpu_to_le32(bp->stats_coal_ticks / 1000); in bnxt_hwrm_stat_ctx_alloc()
6735 mutex_lock(&bp->hwrm_cmd_lock); in bnxt_hwrm_stat_ctx_alloc()
6736 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_hwrm_stat_ctx_alloc()
6737 struct bnxt_napi *bnapi = bp->bnapi[i]; in bnxt_hwrm_stat_ctx_alloc()
6742 rc = _hwrm_send_message(bp, &req, sizeof(req), in bnxt_hwrm_stat_ctx_alloc()
6749 bp->grp_info[i].fw_stats_ctx = cpr->hw_stats_ctx_id; in bnxt_hwrm_stat_ctx_alloc()
6751 mutex_unlock(&bp->hwrm_cmd_lock); in bnxt_hwrm_stat_ctx_alloc()
6755 static int bnxt_hwrm_func_qcfg(struct bnxt *bp) in bnxt_hwrm_func_qcfg() argument
6758 struct hwrm_func_qcfg_output *resp = bp->hwrm_cmd_resp_addr; in bnxt_hwrm_func_qcfg()
6763 bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_FUNC_QCFG, -1, -1); in bnxt_hwrm_func_qcfg()
6765 mutex_lock(&bp->hwrm_cmd_lock); in bnxt_hwrm_func_qcfg()
6766 rc = _hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT); in bnxt_hwrm_func_qcfg()
6771 if (BNXT_VF(bp)) { in bnxt_hwrm_func_qcfg()
6772 struct bnxt_vf_info *vf = &bp->vf; in bnxt_hwrm_func_qcfg()
6776 bp->pf.registered_vfs = le16_to_cpu(resp->registered_vfs); in bnxt_hwrm_func_qcfg()
6782 bp->fw_cap |= BNXT_FW_CAP_LLDP_AGENT; in bnxt_hwrm_func_qcfg()
6784 bp->fw_cap |= BNXT_FW_CAP_DCBX_AGENT; in bnxt_hwrm_func_qcfg()
6786 if (BNXT_PF(bp) && (flags & FUNC_QCFG_RESP_FLAGS_MULTI_HOST)) in bnxt_hwrm_func_qcfg()
6787 bp->flags |= BNXT_FLAG_MULTI_HOST; in bnxt_hwrm_func_qcfg()
6789 bp->fw_cap |= BNXT_FW_CAP_RING_MONITOR; in bnxt_hwrm_func_qcfg()
6795 bp->port_partition_type = resp->port_partition_type; in bnxt_hwrm_func_qcfg()
6798 if (bp->hwrm_spec_code < 0x10707 || in bnxt_hwrm_func_qcfg()
6800 bp->br_mode = BRIDGE_MODE_VEB; in bnxt_hwrm_func_qcfg()
6802 bp->br_mode = BRIDGE_MODE_VEPA; in bnxt_hwrm_func_qcfg()
6804 bp->br_mode = BRIDGE_MODE_UNDEF; in bnxt_hwrm_func_qcfg()
6806 bp->max_mtu = le16_to_cpu(resp->max_mtu_configured); in bnxt_hwrm_func_qcfg()
6807 if (!bp->max_mtu) in bnxt_hwrm_func_qcfg()
6808 bp->max_mtu = BNXT_MAX_MTU; in bnxt_hwrm_func_qcfg()
6810 if (bp->db_size) in bnxt_hwrm_func_qcfg()
6813 if (bp->flags & BNXT_FLAG_CHIP_P5) { in bnxt_hwrm_func_qcfg()
6814 if (BNXT_PF(bp)) in bnxt_hwrm_func_qcfg()
6819 bp->db_size = PAGE_ALIGN(le16_to_cpu(resp->l2_doorbell_bar_size_kb) * in bnxt_hwrm_func_qcfg()
6821 if (!bp->db_size || bp->db_size > pci_resource_len(bp->pdev, 2) || in bnxt_hwrm_func_qcfg()
6822 bp->db_size <= min_db_offset) in bnxt_hwrm_func_qcfg()
6823 bp->db_size = pci_resource_len(bp->pdev, 2); in bnxt_hwrm_func_qcfg()
6826 mutex_unlock(&bp->hwrm_cmd_lock); in bnxt_hwrm_func_qcfg()
6830 static int bnxt_hwrm_func_backing_store_qcaps(struct bnxt *bp) in bnxt_hwrm_func_backing_store_qcaps() argument
6834 bp->hwrm_cmd_resp_addr; in bnxt_hwrm_func_backing_store_qcaps()
6837 if (bp->hwrm_spec_code < 0x10902 || BNXT_VF(bp) || bp->ctx) in bnxt_hwrm_func_backing_store_qcaps()
6840 bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_FUNC_BACKING_STORE_QCAPS, -1, -1); in bnxt_hwrm_func_backing_store_qcaps()
6841 mutex_lock(&bp->hwrm_cmd_lock); in bnxt_hwrm_func_backing_store_qcaps()
6842 rc = _hwrm_send_message_silent(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT); in bnxt_hwrm_func_backing_store_qcaps()
6887 ctx->tqm_fp_rings_count = bp->max_q; in bnxt_hwrm_func_backing_store_qcaps()
6900 bp->ctx = ctx; in bnxt_hwrm_func_backing_store_qcaps()
6905 mutex_unlock(&bp->hwrm_cmd_lock); in bnxt_hwrm_func_backing_store_qcaps()
6931 static int bnxt_hwrm_func_backing_store_cfg(struct bnxt *bp, u32 enables) in bnxt_hwrm_func_backing_store_cfg() argument
6934 struct bnxt_ctx_mem_info *ctx = bp->ctx; in bnxt_hwrm_func_backing_store_cfg()
6946 bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_FUNC_BACKING_STORE_CFG, -1, -1); in bnxt_hwrm_func_backing_store_cfg()
7029 return hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT); in bnxt_hwrm_func_backing_store_cfg()
7032 static int bnxt_alloc_ctx_mem_blk(struct bnxt *bp, in bnxt_alloc_ctx_mem_blk() argument
7043 return bnxt_alloc_ring(bp, rmem); in bnxt_alloc_ctx_mem_blk()
7046 static int bnxt_alloc_ctx_pg_tbls(struct bnxt *bp, in bnxt_alloc_ctx_pg_tbls() argument
7071 rc = bnxt_alloc_ctx_mem_blk(bp, ctx_pg); in bnxt_alloc_ctx_pg_tbls()
7087 rmem->init_val = bp->ctx->ctx_kind_initializer; in bnxt_alloc_ctx_pg_tbls()
7094 rc = bnxt_alloc_ctx_mem_blk(bp, pg_tbl); in bnxt_alloc_ctx_pg_tbls()
7103 rmem->init_val = bp->ctx->ctx_kind_initializer; in bnxt_alloc_ctx_pg_tbls()
7104 rc = bnxt_alloc_ctx_mem_blk(bp, ctx_pg); in bnxt_alloc_ctx_pg_tbls()
7109 static void bnxt_free_ctx_pg_tbls(struct bnxt *bp, in bnxt_free_ctx_pg_tbls() argument
7126 bnxt_free_ring(bp, rmem2); in bnxt_free_ctx_pg_tbls()
7134 bnxt_free_ring(bp, rmem); in bnxt_free_ctx_pg_tbls()
7138 static void bnxt_free_ctx_mem(struct bnxt *bp) in bnxt_free_ctx_mem() argument
7140 struct bnxt_ctx_mem_info *ctx = bp->ctx; in bnxt_free_ctx_mem()
7148 bnxt_free_ctx_pg_tbls(bp, ctx->tqm_mem[i]); in bnxt_free_ctx_mem()
7153 bnxt_free_ctx_pg_tbls(bp, &ctx->tim_mem); in bnxt_free_ctx_mem()
7154 bnxt_free_ctx_pg_tbls(bp, &ctx->mrav_mem); in bnxt_free_ctx_mem()
7155 bnxt_free_ctx_pg_tbls(bp, &ctx->stat_mem); in bnxt_free_ctx_mem()
7156 bnxt_free_ctx_pg_tbls(bp, &ctx->vnic_mem); in bnxt_free_ctx_mem()
7157 bnxt_free_ctx_pg_tbls(bp, &ctx->cq_mem); in bnxt_free_ctx_mem()
7158 bnxt_free_ctx_pg_tbls(bp, &ctx->srq_mem); in bnxt_free_ctx_mem()
7159 bnxt_free_ctx_pg_tbls(bp, &ctx->qp_mem); in bnxt_free_ctx_mem()
7163 static int bnxt_alloc_ctx_mem(struct bnxt *bp) in bnxt_alloc_ctx_mem() argument
7175 rc = bnxt_hwrm_func_backing_store_qcaps(bp); in bnxt_alloc_ctx_mem()
7177 netdev_err(bp->dev, "Failed querying context mem capability, rc = %d.\n", in bnxt_alloc_ctx_mem()
7181 ctx = bp->ctx; in bnxt_alloc_ctx_mem()
7185 if ((bp->flags & BNXT_FLAG_ROCE_CAP) && !is_kdump_kernel()) { in bnxt_alloc_ctx_mem()
7195 rc = bnxt_alloc_ctx_pg_tbls(bp, ctx_pg, mem_size, pg_lvl, true); in bnxt_alloc_ctx_mem()
7202 rc = bnxt_alloc_ctx_pg_tbls(bp, ctx_pg, mem_size, pg_lvl, true); in bnxt_alloc_ctx_mem()
7209 rc = bnxt_alloc_ctx_pg_tbls(bp, ctx_pg, mem_size, pg_lvl, true); in bnxt_alloc_ctx_mem()
7217 rc = bnxt_alloc_ctx_pg_tbls(bp, ctx_pg, mem_size, 1, true); in bnxt_alloc_ctx_mem()
7224 rc = bnxt_alloc_ctx_pg_tbls(bp, ctx_pg, mem_size, 1, true); in bnxt_alloc_ctx_mem()
7229 if (!(bp->flags & BNXT_FLAG_ROCE_CAP)) in bnxt_alloc_ctx_mem()
7240 rc = bnxt_alloc_ctx_pg_tbls(bp, ctx_pg, mem_size, 2, true); in bnxt_alloc_ctx_mem()
7252 rc = bnxt_alloc_ctx_pg_tbls(bp, ctx_pg, mem_size, 1, false); in bnxt_alloc_ctx_mem()
7269 rc = bnxt_alloc_ctx_pg_tbls(bp, ctx_pg, mem_size, 1, false); in bnxt_alloc_ctx_mem()
7275 rc = bnxt_hwrm_func_backing_store_cfg(bp, ena); in bnxt_alloc_ctx_mem()
7277 netdev_err(bp->dev, "Failed configuring context mem, rc = %d.\n", in bnxt_alloc_ctx_mem()
7285 int bnxt_hwrm_func_resc_qcaps(struct bnxt *bp, bool all) in bnxt_hwrm_func_resc_qcaps() argument
7287 struct hwrm_func_resource_qcaps_output *resp = bp->hwrm_cmd_resp_addr; in bnxt_hwrm_func_resc_qcaps()
7289 struct bnxt_hw_resc *hw_resc = &bp->hw_resc; in bnxt_hwrm_func_resc_qcaps()
7292 bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_FUNC_RESOURCE_QCAPS, -1, -1); in bnxt_hwrm_func_resc_qcaps()
7295 mutex_lock(&bp->hwrm_cmd_lock); in bnxt_hwrm_func_resc_qcaps()
7296 rc = _hwrm_send_message_silent(bp, &req, sizeof(req), in bnxt_hwrm_func_resc_qcaps()
7322 if (bp->flags & BNXT_FLAG_CHIP_P5) { in bnxt_hwrm_func_resc_qcaps()
7329 if (BNXT_PF(bp)) { in bnxt_hwrm_func_resc_qcaps()
7330 struct bnxt_pf_info *pf = &bp->pf; in bnxt_hwrm_func_resc_qcaps()
7338 mutex_unlock(&bp->hwrm_cmd_lock); in bnxt_hwrm_func_resc_qcaps()
7342 static int __bnxt_hwrm_func_qcaps(struct bnxt *bp) in __bnxt_hwrm_func_qcaps() argument
7346 struct hwrm_func_qcaps_output *resp = bp->hwrm_cmd_resp_addr; in __bnxt_hwrm_func_qcaps()
7347 struct bnxt_hw_resc *hw_resc = &bp->hw_resc; in __bnxt_hwrm_func_qcaps()
7350 bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_FUNC_QCAPS, -1, -1); in __bnxt_hwrm_func_qcaps()
7353 mutex_lock(&bp->hwrm_cmd_lock); in __bnxt_hwrm_func_qcaps()
7354 rc = _hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT); in __bnxt_hwrm_func_qcaps()
7360 bp->flags |= BNXT_FLAG_ROCEV1_CAP; in __bnxt_hwrm_func_qcaps()
7362 bp->flags |= BNXT_FLAG_ROCEV2_CAP; in __bnxt_hwrm_func_qcaps()
7364 bp->fw_cap |= BNXT_FW_CAP_PCIE_STATS_SUPPORTED; in __bnxt_hwrm_func_qcaps()
7366 bp->fw_cap |= BNXT_FW_CAP_HOT_RESET; in __bnxt_hwrm_func_qcaps()
7368 bp->fw_cap |= BNXT_FW_CAP_EXT_STATS_SUPPORTED; in __bnxt_hwrm_func_qcaps()
7370 bp->fw_cap |= BNXT_FW_CAP_ERROR_RECOVERY; in __bnxt_hwrm_func_qcaps()
7372 bp->fw_cap |= BNXT_FW_CAP_ERR_RECOVER_RELOAD; in __bnxt_hwrm_func_qcaps()
7374 bp->fw_cap |= BNXT_FW_CAP_VLAN_TX_INSERT; in __bnxt_hwrm_func_qcaps()
7378 bp->fw_cap |= BNXT_FW_CAP_EXT_HW_STATS_SUPPORTED; in __bnxt_hwrm_func_qcaps()
7380 bp->tx_push_thresh = 0; in __bnxt_hwrm_func_qcaps()
7382 BNXT_FW_MAJ(bp) > 217) in __bnxt_hwrm_func_qcaps()
7383 bp->tx_push_thresh = BNXT_TX_PUSH_THRESH; in __bnxt_hwrm_func_qcaps()
7396 if (BNXT_PF(bp)) { in __bnxt_hwrm_func_qcaps()
7397 struct bnxt_pf_info *pf = &bp->pf; in __bnxt_hwrm_func_qcaps()
7410 bp->flags &= ~BNXT_FLAG_WOL_CAP; in __bnxt_hwrm_func_qcaps()
7412 bp->flags |= BNXT_FLAG_WOL_CAP; in __bnxt_hwrm_func_qcaps()
7415 struct bnxt_vf_info *vf = &bp->vf; in __bnxt_hwrm_func_qcaps()
7423 mutex_unlock(&bp->hwrm_cmd_lock); in __bnxt_hwrm_func_qcaps()
7427 static int bnxt_hwrm_queue_qportcfg(struct bnxt *bp);
7429 static int bnxt_hwrm_func_qcaps(struct bnxt *bp) in bnxt_hwrm_func_qcaps() argument
7433 rc = __bnxt_hwrm_func_qcaps(bp); in bnxt_hwrm_func_qcaps()
7436 rc = bnxt_hwrm_queue_qportcfg(bp); in bnxt_hwrm_func_qcaps()
7438 netdev_err(bp->dev, "hwrm query qportcfg failure rc: %d\n", rc); in bnxt_hwrm_func_qcaps()
7441 if (bp->hwrm_spec_code >= 0x10803) { in bnxt_hwrm_func_qcaps()
7442 rc = bnxt_alloc_ctx_mem(bp); in bnxt_hwrm_func_qcaps()
7445 rc = bnxt_hwrm_func_resc_qcaps(bp, true); in bnxt_hwrm_func_qcaps()
7447 bp->fw_cap |= BNXT_FW_CAP_NEW_RM; in bnxt_hwrm_func_qcaps()
7452 static int bnxt_hwrm_cfa_adv_flow_mgnt_qcaps(struct bnxt *bp) in bnxt_hwrm_cfa_adv_flow_mgnt_qcaps() argument
7459 if (!(bp->fw_cap & BNXT_FW_CAP_CFA_ADV_FLOW)) in bnxt_hwrm_cfa_adv_flow_mgnt_qcaps()
7462 resp = bp->hwrm_cmd_resp_addr; in bnxt_hwrm_cfa_adv_flow_mgnt_qcaps()
7463 bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_CFA_ADV_FLOW_MGNT_QCAPS, -1, -1); in bnxt_hwrm_cfa_adv_flow_mgnt_qcaps()
7465 mutex_lock(&bp->hwrm_cmd_lock); in bnxt_hwrm_cfa_adv_flow_mgnt_qcaps()
7466 rc = _hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT); in bnxt_hwrm_cfa_adv_flow_mgnt_qcaps()
7473 bp->fw_cap |= BNXT_FW_CAP_CFA_RFS_RING_TBL_IDX_V2; in bnxt_hwrm_cfa_adv_flow_mgnt_qcaps()
7476 mutex_unlock(&bp->hwrm_cmd_lock); in bnxt_hwrm_cfa_adv_flow_mgnt_qcaps()
7480 static int __bnxt_alloc_fw_health(struct bnxt *bp) in __bnxt_alloc_fw_health() argument
7482 if (bp->fw_health) in __bnxt_alloc_fw_health()
7485 bp->fw_health = kzalloc(sizeof(*bp->fw_health), GFP_KERNEL); in __bnxt_alloc_fw_health()
7486 if (!bp->fw_health) in __bnxt_alloc_fw_health()
7492 static int bnxt_alloc_fw_health(struct bnxt *bp) in bnxt_alloc_fw_health() argument
7496 if (!(bp->fw_cap & BNXT_FW_CAP_HOT_RESET) && in bnxt_alloc_fw_health()
7497 !(bp->fw_cap & BNXT_FW_CAP_ERROR_RECOVERY)) in bnxt_alloc_fw_health()
7500 rc = __bnxt_alloc_fw_health(bp); in bnxt_alloc_fw_health()
7502 bp->fw_cap &= ~BNXT_FW_CAP_HOT_RESET; in bnxt_alloc_fw_health()
7503 bp->fw_cap &= ~BNXT_FW_CAP_ERROR_RECOVERY; in bnxt_alloc_fw_health()
7510 static void __bnxt_map_fw_health_reg(struct bnxt *bp, u32 reg) in __bnxt_map_fw_health_reg() argument
7512 writel(reg & BNXT_GRC_BASE_MASK, bp->bar0 + in __bnxt_map_fw_health_reg()
7517 static void bnxt_try_map_fw_health_reg(struct bnxt *bp) in bnxt_try_map_fw_health_reg() argument
7524 __bnxt_map_fw_health_reg(bp, HCOMM_STATUS_STRUCT_LOC); in bnxt_try_map_fw_health_reg()
7525 hs = bp->bar0 + BNXT_FW_HEALTH_WIN_OFF(HCOMM_STATUS_STRUCT_LOC); in bnxt_try_map_fw_health_reg()
7529 if (bp->fw_health) in bnxt_try_map_fw_health_reg()
7530 bp->fw_health->status_reliable = false; in bnxt_try_map_fw_health_reg()
7534 if (__bnxt_alloc_fw_health(bp)) { in bnxt_try_map_fw_health_reg()
7535 netdev_warn(bp->dev, "no memory for firmware status checks\n"); in bnxt_try_map_fw_health_reg()
7540 bp->fw_health->regs[BNXT_FW_HEALTH_REG] = status_loc; in bnxt_try_map_fw_health_reg()
7543 __bnxt_map_fw_health_reg(bp, status_loc); in bnxt_try_map_fw_health_reg()
7544 bp->fw_health->mapped_regs[BNXT_FW_HEALTH_REG] = in bnxt_try_map_fw_health_reg()
7548 bp->fw_health->status_reliable = true; in bnxt_try_map_fw_health_reg()
7551 static int bnxt_map_fw_health_regs(struct bnxt *bp) in bnxt_map_fw_health_regs() argument
7553 struct bnxt_fw_health *fw_health = bp->fw_health; in bnxt_map_fw_health_regs()
7572 __bnxt_map_fw_health_reg(bp, reg_base); in bnxt_map_fw_health_regs()
7576 static int bnxt_hwrm_error_recovery_qcfg(struct bnxt *bp) in bnxt_hwrm_error_recovery_qcfg() argument
7578 struct hwrm_error_recovery_qcfg_output *resp = bp->hwrm_cmd_resp_addr; in bnxt_hwrm_error_recovery_qcfg()
7579 struct bnxt_fw_health *fw_health = bp->fw_health; in bnxt_hwrm_error_recovery_qcfg()
7583 if (!(bp->fw_cap & BNXT_FW_CAP_ERROR_RECOVERY)) in bnxt_hwrm_error_recovery_qcfg()
7586 bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_ERROR_RECOVERY_QCFG, -1, -1); in bnxt_hwrm_error_recovery_qcfg()
7587 mutex_lock(&bp->hwrm_cmd_lock); in bnxt_hwrm_error_recovery_qcfg()
7588 rc = _hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT); in bnxt_hwrm_error_recovery_qcfg()
7593 !(bp->fw_cap & BNXT_FW_CAP_KONG_MB_CHNL)) { in bnxt_hwrm_error_recovery_qcfg()
7630 mutex_unlock(&bp->hwrm_cmd_lock); in bnxt_hwrm_error_recovery_qcfg()
7632 rc = bnxt_map_fw_health_regs(bp); in bnxt_hwrm_error_recovery_qcfg()
7634 bp->fw_cap &= ~BNXT_FW_CAP_ERROR_RECOVERY; in bnxt_hwrm_error_recovery_qcfg()
7638 static int bnxt_hwrm_func_reset(struct bnxt *bp) in bnxt_hwrm_func_reset() argument
7642 bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_FUNC_RESET, -1, -1); in bnxt_hwrm_func_reset()
7645 return hwrm_send_message(bp, &req, sizeof(req), HWRM_RESET_TIMEOUT); in bnxt_hwrm_func_reset()
7648 static void bnxt_nvm_cfg_ver_get(struct bnxt *bp) in bnxt_nvm_cfg_ver_get() argument
7652 if (!bnxt_hwrm_nvm_get_dev_info(bp, &nvm_info)) in bnxt_nvm_cfg_ver_get()
7653 snprintf(bp->nvm_cfg_ver, FW_VER_STR_LEN, "%d.%d.%d", in bnxt_nvm_cfg_ver_get()
7658 static int bnxt_hwrm_queue_qportcfg(struct bnxt *bp) in bnxt_hwrm_queue_qportcfg() argument
7662 struct hwrm_queue_qportcfg_output *resp = bp->hwrm_cmd_resp_addr; in bnxt_hwrm_queue_qportcfg()
7666 bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_QUEUE_QPORTCFG, -1, -1); in bnxt_hwrm_queue_qportcfg()
7668 mutex_lock(&bp->hwrm_cmd_lock); in bnxt_hwrm_queue_qportcfg()
7669 rc = _hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT); in bnxt_hwrm_queue_qportcfg()
7677 bp->max_tc = resp->max_configurable_queues; in bnxt_hwrm_queue_qportcfg()
7678 bp->max_lltc = resp->max_configurable_lossless_queues; in bnxt_hwrm_queue_qportcfg()
7679 if (bp->max_tc > BNXT_MAX_QUEUE) in bnxt_hwrm_queue_qportcfg()
7680 bp->max_tc = BNXT_MAX_QUEUE; in bnxt_hwrm_queue_qportcfg()
7682 no_rdma = !(bp->flags & BNXT_FLAG_ROCE_CAP); in bnxt_hwrm_queue_qportcfg()
7684 for (i = 0, j = 0; i < bp->max_tc; i++) { in bnxt_hwrm_queue_qportcfg()
7685 bp->q_info[j].queue_id = *qptr; in bnxt_hwrm_queue_qportcfg()
7686 bp->q_ids[i] = *qptr++; in bnxt_hwrm_queue_qportcfg()
7687 bp->q_info[j].queue_profile = *qptr++; in bnxt_hwrm_queue_qportcfg()
7688 bp->tc_to_qidx[j] = j; in bnxt_hwrm_queue_qportcfg()
7689 if (!BNXT_CNPQ(bp->q_info[j].queue_profile) || in bnxt_hwrm_queue_qportcfg()
7690 (no_rdma && BNXT_PF(bp))) in bnxt_hwrm_queue_qportcfg()
7693 bp->max_q = bp->max_tc; in bnxt_hwrm_queue_qportcfg()
7694 bp->max_tc = max_t(u8, j, 1); in bnxt_hwrm_queue_qportcfg()
7697 bp->max_tc = 1; in bnxt_hwrm_queue_qportcfg()
7699 if (bp->max_lltc > bp->max_tc) in bnxt_hwrm_queue_qportcfg()
7700 bp->max_lltc = bp->max_tc; in bnxt_hwrm_queue_qportcfg()
7703 mutex_unlock(&bp->hwrm_cmd_lock); in bnxt_hwrm_queue_qportcfg()
7707 static int __bnxt_hwrm_ver_get(struct bnxt *bp, bool silent) in __bnxt_hwrm_ver_get() argument
7712 bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_VER_GET, -1, -1); in __bnxt_hwrm_ver_get()
7717 rc = bnxt_hwrm_do_send_msg(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT, in __bnxt_hwrm_ver_get()
7722 static int bnxt_hwrm_ver_get(struct bnxt *bp) in bnxt_hwrm_ver_get() argument
7724 struct hwrm_ver_get_output *resp = bp->hwrm_cmd_resp_addr; in bnxt_hwrm_ver_get()
7729 bp->hwrm_max_req_len = HWRM_MAX_REQ_LEN; in bnxt_hwrm_ver_get()
7730 mutex_lock(&bp->hwrm_cmd_lock); in bnxt_hwrm_ver_get()
7731 rc = __bnxt_hwrm_ver_get(bp, false); in bnxt_hwrm_ver_get()
7735 memcpy(&bp->ver_resp, resp, sizeof(struct hwrm_ver_get_output)); in bnxt_hwrm_ver_get()
7737 bp->hwrm_spec_code = resp->hwrm_intf_maj_8b << 16 | in bnxt_hwrm_ver_get()
7741 netdev_warn(bp->dev, "HWRM interface %d.%d.%d is older than 1.0.0.\n", in bnxt_hwrm_ver_get()
7744 netdev_warn(bp->dev, "Please update firmware with HWRM interface 1.0.0 or newer.\n"); in bnxt_hwrm_ver_get()
7750 if (bp->hwrm_spec_code > hwrm_ver) in bnxt_hwrm_ver_get()
7751 snprintf(bp->hwrm_ver_supp, FW_VER_STR_LEN, "%d.%d.%d", in bnxt_hwrm_ver_get()
7755 snprintf(bp->hwrm_ver_supp, FW_VER_STR_LEN, "%d.%d.%d", in bnxt_hwrm_ver_get()
7760 if (bp->hwrm_spec_code > 0x10803 && fw_maj) { in bnxt_hwrm_ver_get()
7772 bp->fw_ver_code = BNXT_FW_VER_CODE(fw_maj, fw_min, fw_bld, fw_rsv); in bnxt_hwrm_ver_get()
7773 snprintf(bp->fw_ver_str, len, "%d.%d.%d.%d", fw_maj, fw_min, fw_bld, in bnxt_hwrm_ver_get()
7777 int fw_ver_len = strlen(bp->fw_ver_str); in bnxt_hwrm_ver_get()
7779 snprintf(bp->fw_ver_str + fw_ver_len, in bnxt_hwrm_ver_get()
7782 bp->fw_cap |= BNXT_FW_CAP_PKG_VER; in bnxt_hwrm_ver_get()
7785 bp->hwrm_cmd_timeout = le16_to_cpu(resp->def_req_timeout); in bnxt_hwrm_ver_get()
7786 if (!bp->hwrm_cmd_timeout) in bnxt_hwrm_ver_get()
7787 bp->hwrm_cmd_timeout = DFLT_HWRM_CMD_TIMEOUT; in bnxt_hwrm_ver_get()
7790 bp->hwrm_max_req_len = le16_to_cpu(resp->max_req_win_len); in bnxt_hwrm_ver_get()
7791 bp->hwrm_max_ext_req_len = le16_to_cpu(resp->max_ext_req_len); in bnxt_hwrm_ver_get()
7793 if (bp->hwrm_max_ext_req_len < HWRM_MAX_REQ_LEN) in bnxt_hwrm_ver_get()
7794 bp->hwrm_max_ext_req_len = HWRM_MAX_REQ_LEN; in bnxt_hwrm_ver_get()
7796 bp->chip_num = le16_to_cpu(resp->chip_num); in bnxt_hwrm_ver_get()
7797 bp->chip_rev = resp->chip_rev; in bnxt_hwrm_ver_get()
7798 if (bp->chip_num == CHIP_NUM_58700 && !resp->chip_rev && in bnxt_hwrm_ver_get()
7800 bp->flags |= BNXT_FLAG_CHIP_NITRO_A0; in bnxt_hwrm_ver_get()
7805 bp->fw_cap |= BNXT_FW_CAP_SHORT_CMD; in bnxt_hwrm_ver_get()
7808 bp->fw_cap |= BNXT_FW_CAP_KONG_MB_CHNL; in bnxt_hwrm_ver_get()
7812 bp->fw_cap |= BNXT_FW_CAP_OVS_64BIT_HANDLE; in bnxt_hwrm_ver_get()
7816 bp->fw_cap |= BNXT_FW_CAP_TRUSTED_VF; in bnxt_hwrm_ver_get()
7820 bp->fw_cap |= BNXT_FW_CAP_CFA_ADV_FLOW; in bnxt_hwrm_ver_get()
7823 mutex_unlock(&bp->hwrm_cmd_lock); in bnxt_hwrm_ver_get()
7827 int bnxt_hwrm_fw_set_time(struct bnxt *bp) in bnxt_hwrm_fw_set_time() argument
7833 if ((BNXT_VF(bp) && bp->hwrm_spec_code < 0x10901) || in bnxt_hwrm_fw_set_time()
7834 bp->hwrm_spec_code < 0x10400) in bnxt_hwrm_fw_set_time()
7838 bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_FW_SET_TIME, -1, -1); in bnxt_hwrm_fw_set_time()
7845 return hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT); in bnxt_hwrm_fw_set_time()
7886 static void bnxt_accumulate_all_stats(struct bnxt *bp) in bnxt_accumulate_all_stats() argument
7893 if (bp->flags & BNXT_FLAG_CHIP_P5) in bnxt_accumulate_all_stats()
7896 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_accumulate_all_stats()
7897 struct bnxt_napi *bnapi = bp->bnapi[i]; in bnxt_accumulate_all_stats()
7909 if (bp->flags & BNXT_FLAG_PORT_STATS) { in bnxt_accumulate_all_stats()
7910 struct bnxt_stats_mem *stats = &bp->port_stats; in bnxt_accumulate_all_stats()
7925 if (bp->flags & BNXT_FLAG_PORT_STATS_EXT) { in bnxt_accumulate_all_stats()
7926 bnxt_accumulate_stats(&bp->rx_port_stats_ext); in bnxt_accumulate_all_stats()
7927 bnxt_accumulate_stats(&bp->tx_port_stats_ext); in bnxt_accumulate_all_stats()
7931 static int bnxt_hwrm_port_qstats(struct bnxt *bp, u8 flags) in bnxt_hwrm_port_qstats() argument
7933 struct bnxt_pf_info *pf = &bp->pf; in bnxt_hwrm_port_qstats()
7936 if (!(bp->flags & BNXT_FLAG_PORT_STATS)) in bnxt_hwrm_port_qstats()
7939 if (flags && !(bp->fw_cap & BNXT_FW_CAP_EXT_HW_STATS_SUPPORTED)) in bnxt_hwrm_port_qstats()
7943 bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_PORT_QSTATS, -1, -1); in bnxt_hwrm_port_qstats()
7945 req.tx_stat_host_addr = cpu_to_le64(bp->port_stats.hw_stats_map + in bnxt_hwrm_port_qstats()
7947 req.rx_stat_host_addr = cpu_to_le64(bp->port_stats.hw_stats_map); in bnxt_hwrm_port_qstats()
7948 return hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT); in bnxt_hwrm_port_qstats()
7951 static int bnxt_hwrm_port_qstats_ext(struct bnxt *bp, u8 flags) in bnxt_hwrm_port_qstats_ext() argument
7953 struct hwrm_port_qstats_ext_output *resp = bp->hwrm_cmd_resp_addr; in bnxt_hwrm_port_qstats_ext()
7956 struct bnxt_pf_info *pf = &bp->pf; in bnxt_hwrm_port_qstats_ext()
7960 if (!(bp->flags & BNXT_FLAG_PORT_STATS_EXT)) in bnxt_hwrm_port_qstats_ext()
7963 if (flags && !(bp->fw_cap & BNXT_FW_CAP_EXT_HW_STATS_SUPPORTED)) in bnxt_hwrm_port_qstats_ext()
7966 bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_PORT_QSTATS_EXT, -1, -1); in bnxt_hwrm_port_qstats_ext()
7970 req.rx_stat_host_addr = cpu_to_le64(bp->rx_port_stats_ext.hw_stats_map); in bnxt_hwrm_port_qstats_ext()
7971 tx_stat_size = bp->tx_port_stats_ext.hw_stats ? in bnxt_hwrm_port_qstats_ext()
7974 req.tx_stat_host_addr = cpu_to_le64(bp->tx_port_stats_ext.hw_stats_map); in bnxt_hwrm_port_qstats_ext()
7975 mutex_lock(&bp->hwrm_cmd_lock); in bnxt_hwrm_port_qstats_ext()
7976 rc = _hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT); in bnxt_hwrm_port_qstats_ext()
7978 bp->fw_rx_stats_ext_size = le16_to_cpu(resp->rx_stat_size) / 8; in bnxt_hwrm_port_qstats_ext()
7979 bp->fw_tx_stats_ext_size = tx_stat_size ? in bnxt_hwrm_port_qstats_ext()
7982 bp->fw_rx_stats_ext_size = 0; in bnxt_hwrm_port_qstats_ext()
7983 bp->fw_tx_stats_ext_size = 0; in bnxt_hwrm_port_qstats_ext()
7988 if (bp->fw_tx_stats_ext_size <= in bnxt_hwrm_port_qstats_ext()
7990 mutex_unlock(&bp->hwrm_cmd_lock); in bnxt_hwrm_port_qstats_ext()
7991 bp->pri2cos_valid = 0; in bnxt_hwrm_port_qstats_ext()
7995 bnxt_hwrm_cmd_hdr_init(bp, &req2, HWRM_QUEUE_PRI2COS_QCFG, -1, -1); in bnxt_hwrm_port_qstats_ext()
7998 rc = _hwrm_send_message(bp, &req2, sizeof(req2), HWRM_CMD_TIMEOUT); in bnxt_hwrm_port_qstats_ext()
8004 resp2 = bp->hwrm_cmd_resp_addr; in bnxt_hwrm_port_qstats_ext()
8013 bp->pri2cos_valid = false; in bnxt_hwrm_port_qstats_ext()
8016 for (j = 0; j < bp->max_q; j++) { in bnxt_hwrm_port_qstats_ext()
8017 if (bp->q_ids[j] == queue_id) in bnxt_hwrm_port_qstats_ext()
8018 bp->pri2cos_idx[i] = queue_idx; in bnxt_hwrm_port_qstats_ext()
8021 bp->pri2cos_valid = 1; in bnxt_hwrm_port_qstats_ext()
8024 mutex_unlock(&bp->hwrm_cmd_lock); in bnxt_hwrm_port_qstats_ext()
8028 static void bnxt_hwrm_free_tunnel_ports(struct bnxt *bp) in bnxt_hwrm_free_tunnel_ports() argument
8030 if (bp->vxlan_fw_dst_port_id != INVALID_HW_RING_ID) in bnxt_hwrm_free_tunnel_ports()
8032 bp, TUNNEL_DST_PORT_FREE_REQ_TUNNEL_TYPE_VXLAN); in bnxt_hwrm_free_tunnel_ports()
8033 if (bp->nge_fw_dst_port_id != INVALID_HW_RING_ID) in bnxt_hwrm_free_tunnel_ports()
8035 bp, TUNNEL_DST_PORT_FREE_REQ_TUNNEL_TYPE_GENEVE); in bnxt_hwrm_free_tunnel_ports()
8038 static int bnxt_set_tpa(struct bnxt *bp, bool set_tpa) in bnxt_set_tpa() argument
8044 tpa_flags = bp->flags & BNXT_FLAG_TPA; in bnxt_set_tpa()
8045 else if (BNXT_NO_FW_ACCESS(bp)) in bnxt_set_tpa()
8047 for (i = 0; i < bp->nr_vnics; i++) { in bnxt_set_tpa()
8048 rc = bnxt_hwrm_vnic_set_tpa(bp, i, tpa_flags); in bnxt_set_tpa()
8050 netdev_err(bp->dev, "hwrm vnic set tpa failure rc for vnic %d: %x\n", in bnxt_set_tpa()
8058 static void bnxt_hwrm_clear_vnic_rss(struct bnxt *bp) in bnxt_hwrm_clear_vnic_rss() argument
8062 for (i = 0; i < bp->nr_vnics; i++) in bnxt_hwrm_clear_vnic_rss()
8063 bnxt_hwrm_vnic_set_rss(bp, i, false); in bnxt_hwrm_clear_vnic_rss()
8066 static void bnxt_clear_vnic(struct bnxt *bp) in bnxt_clear_vnic() argument
8068 if (!bp->vnic_info) in bnxt_clear_vnic()
8071 bnxt_hwrm_clear_vnic_filter(bp); in bnxt_clear_vnic()
8072 if (!(bp->flags & BNXT_FLAG_CHIP_P5)) { in bnxt_clear_vnic()
8074 bnxt_hwrm_clear_vnic_rss(bp); in bnxt_clear_vnic()
8075 bnxt_hwrm_vnic_ctx_free(bp); in bnxt_clear_vnic()
8078 if (bp->flags & BNXT_FLAG_TPA) in bnxt_clear_vnic()
8079 bnxt_set_tpa(bp, false); in bnxt_clear_vnic()
8080 bnxt_hwrm_vnic_free(bp); in bnxt_clear_vnic()
8081 if (bp->flags & BNXT_FLAG_CHIP_P5) in bnxt_clear_vnic()
8082 bnxt_hwrm_vnic_ctx_free(bp); in bnxt_clear_vnic()
8085 static void bnxt_hwrm_resource_free(struct bnxt *bp, bool close_path, in bnxt_hwrm_resource_free() argument
8088 bnxt_clear_vnic(bp); in bnxt_hwrm_resource_free()
8089 bnxt_hwrm_ring_free(bp, close_path); in bnxt_hwrm_resource_free()
8090 bnxt_hwrm_ring_grp_free(bp); in bnxt_hwrm_resource_free()
8092 bnxt_hwrm_stat_ctx_free(bp); in bnxt_hwrm_resource_free()
8093 bnxt_hwrm_free_tunnel_ports(bp); in bnxt_hwrm_resource_free()
8097 static int bnxt_hwrm_set_br_mode(struct bnxt *bp, u16 br_mode) in bnxt_hwrm_set_br_mode() argument
8101 bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_FUNC_CFG, -1, -1); in bnxt_hwrm_set_br_mode()
8110 return hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT); in bnxt_hwrm_set_br_mode()
8113 static int bnxt_hwrm_set_cache_line_size(struct bnxt *bp, int size) in bnxt_hwrm_set_cache_line_size() argument
8117 if (BNXT_VF(bp) || bp->hwrm_spec_code < 0x10803) in bnxt_hwrm_set_cache_line_size()
8120 bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_FUNC_CFG, -1, -1); in bnxt_hwrm_set_cache_line_size()
8127 return hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT); in bnxt_hwrm_set_cache_line_size()
8130 static int __bnxt_setup_vnic(struct bnxt *bp, u16 vnic_id) in __bnxt_setup_vnic() argument
8132 struct bnxt_vnic_info *vnic = &bp->vnic_info[vnic_id]; in __bnxt_setup_vnic()
8139 rc = bnxt_hwrm_vnic_ctx_alloc(bp, vnic_id, 0); in __bnxt_setup_vnic()
8141 netdev_err(bp->dev, "hwrm vnic %d alloc failure rc: %x\n", in __bnxt_setup_vnic()
8145 bp->rsscos_nr_ctxs++; in __bnxt_setup_vnic()
8147 if (BNXT_CHIP_TYPE_NITRO_A0(bp)) { in __bnxt_setup_vnic()
8148 rc = bnxt_hwrm_vnic_ctx_alloc(bp, vnic_id, 1); in __bnxt_setup_vnic()
8150 netdev_err(bp->dev, "hwrm vnic %d cos ctx alloc failure rc: %x\n", in __bnxt_setup_vnic()
8154 bp->rsscos_nr_ctxs++; in __bnxt_setup_vnic()
8159 rc = bnxt_hwrm_vnic_cfg(bp, vnic_id); in __bnxt_setup_vnic()
8161 netdev_err(bp->dev, "hwrm vnic %d cfg failure rc: %x\n", in __bnxt_setup_vnic()
8167 rc = bnxt_hwrm_vnic_set_rss(bp, vnic_id, true); in __bnxt_setup_vnic()
8169 netdev_err(bp->dev, "hwrm vnic %d set rss failure rc: %x\n", in __bnxt_setup_vnic()
8174 if (bp->flags & BNXT_FLAG_AGG_RINGS) { in __bnxt_setup_vnic()
8175 rc = bnxt_hwrm_vnic_set_hds(bp, vnic_id); in __bnxt_setup_vnic()
8177 netdev_err(bp->dev, "hwrm vnic %d set hds failure rc: %x\n", in __bnxt_setup_vnic()
8186 static int __bnxt_setup_vnic_p5(struct bnxt *bp, u16 vnic_id) in __bnxt_setup_vnic_p5() argument
8190 nr_ctxs = bnxt_get_nr_rss_ctxs(bp, bp->rx_nr_rings); in __bnxt_setup_vnic_p5()
8192 rc = bnxt_hwrm_vnic_ctx_alloc(bp, vnic_id, i); in __bnxt_setup_vnic_p5()
8194 netdev_err(bp->dev, "hwrm vnic %d ctx %d alloc failure rc: %x\n", in __bnxt_setup_vnic_p5()
8198 bp->rsscos_nr_ctxs++; in __bnxt_setup_vnic_p5()
8203 rc = bnxt_hwrm_vnic_set_rss_p5(bp, vnic_id, true); in __bnxt_setup_vnic_p5()
8205 netdev_err(bp->dev, "hwrm vnic %d set rss failure rc: %d\n", in __bnxt_setup_vnic_p5()
8209 rc = bnxt_hwrm_vnic_cfg(bp, vnic_id); in __bnxt_setup_vnic_p5()
8211 netdev_err(bp->dev, "hwrm vnic %d cfg failure rc: %x\n", in __bnxt_setup_vnic_p5()
8215 if (bp->flags & BNXT_FLAG_AGG_RINGS) { in __bnxt_setup_vnic_p5()
8216 rc = bnxt_hwrm_vnic_set_hds(bp, vnic_id); in __bnxt_setup_vnic_p5()
8218 netdev_err(bp->dev, "hwrm vnic %d set hds failure rc: %x\n", in __bnxt_setup_vnic_p5()
8225 static int bnxt_setup_vnic(struct bnxt *bp, u16 vnic_id) in bnxt_setup_vnic() argument
8227 if (bp->flags & BNXT_FLAG_CHIP_P5) in bnxt_setup_vnic()
8228 return __bnxt_setup_vnic_p5(bp, vnic_id); in bnxt_setup_vnic()
8230 return __bnxt_setup_vnic(bp, vnic_id); in bnxt_setup_vnic()
8233 static int bnxt_alloc_rfs_vnics(struct bnxt *bp) in bnxt_alloc_rfs_vnics() argument
8238 if (bp->flags & BNXT_FLAG_CHIP_P5) in bnxt_alloc_rfs_vnics()
8241 for (i = 0; i < bp->rx_nr_rings; i++) { in bnxt_alloc_rfs_vnics()
8246 if (vnic_id >= bp->nr_vnics) in bnxt_alloc_rfs_vnics()
8249 vnic = &bp->vnic_info[vnic_id]; in bnxt_alloc_rfs_vnics()
8251 if (bp->flags & BNXT_FLAG_NEW_RSS_CAP) in bnxt_alloc_rfs_vnics()
8253 rc = bnxt_hwrm_vnic_alloc(bp, vnic_id, ring_id, 1); in bnxt_alloc_rfs_vnics()
8255 netdev_err(bp->dev, "hwrm vnic %d alloc failure rc: %x\n", in bnxt_alloc_rfs_vnics()
8259 rc = bnxt_setup_vnic(bp, vnic_id); in bnxt_alloc_rfs_vnics()
8270 static bool bnxt_promisc_ok(struct bnxt *bp) in bnxt_promisc_ok() argument
8273 if (BNXT_VF(bp) && !bp->vf.vlan) in bnxt_promisc_ok()
8279 static int bnxt_setup_nitroa0_vnic(struct bnxt *bp) in bnxt_setup_nitroa0_vnic() argument
8283 rc = bnxt_hwrm_vnic_alloc(bp, 1, bp->rx_nr_rings - 1, 1); in bnxt_setup_nitroa0_vnic()
8285 netdev_err(bp->dev, "Cannot allocate special vnic for NS2 A0: %x\n", in bnxt_setup_nitroa0_vnic()
8290 rc = bnxt_hwrm_vnic_cfg(bp, 1); in bnxt_setup_nitroa0_vnic()
8292 netdev_err(bp->dev, "Cannot allocate special vnic for NS2 A0: %x\n", in bnxt_setup_nitroa0_vnic()
8302 static int bnxt_init_chip(struct bnxt *bp, bool irq_re_init) in bnxt_init_chip() argument
8304 struct bnxt_vnic_info *vnic = &bp->vnic_info[0]; in bnxt_init_chip()
8306 unsigned int rx_nr_rings = bp->rx_nr_rings; in bnxt_init_chip()
8309 rc = bnxt_hwrm_stat_ctx_alloc(bp); in bnxt_init_chip()
8311 netdev_err(bp->dev, "hwrm stat ctx alloc failure rc: %x\n", in bnxt_init_chip()
8317 rc = bnxt_hwrm_ring_alloc(bp); in bnxt_init_chip()
8319 netdev_err(bp->dev, "hwrm ring alloc failure rc: %x\n", rc); in bnxt_init_chip()
8323 rc = bnxt_hwrm_ring_grp_alloc(bp); in bnxt_init_chip()
8325 netdev_err(bp->dev, "hwrm_ring_grp alloc failure: %x\n", rc); in bnxt_init_chip()
8329 if (BNXT_CHIP_TYPE_NITRO_A0(bp)) in bnxt_init_chip()
8333 rc = bnxt_hwrm_vnic_alloc(bp, 0, 0, rx_nr_rings); in bnxt_init_chip()
8335 netdev_err(bp->dev, "hwrm vnic alloc failure rc: %x\n", rc); in bnxt_init_chip()
8339 rc = bnxt_setup_vnic(bp, 0); in bnxt_init_chip()
8343 if (bp->flags & BNXT_FLAG_RFS) { in bnxt_init_chip()
8344 rc = bnxt_alloc_rfs_vnics(bp); in bnxt_init_chip()
8349 if (bp->flags & BNXT_FLAG_TPA) { in bnxt_init_chip()
8350 rc = bnxt_set_tpa(bp, true); in bnxt_init_chip()
8355 if (BNXT_VF(bp)) in bnxt_init_chip()
8356 bnxt_update_vf_mac(bp); in bnxt_init_chip()
8359 rc = bnxt_hwrm_set_vnic_filter(bp, 0, 0, bp->dev->dev_addr); in bnxt_init_chip()
8361 netdev_err(bp->dev, "HWRM vnic filter failure rc: %x\n", rc); in bnxt_init_chip()
8367 if (bp->dev->flags & IFF_BROADCAST) in bnxt_init_chip()
8370 if ((bp->dev->flags & IFF_PROMISC) && bnxt_promisc_ok(bp)) in bnxt_init_chip()
8373 if (bp->dev->flags & IFF_ALLMULTI) { in bnxt_init_chip()
8379 bnxt_mc_list_updated(bp, &mask); in bnxt_init_chip()
8383 rc = bnxt_cfg_rx_mode(bp); in bnxt_init_chip()
8387 rc = bnxt_hwrm_set_coal(bp); in bnxt_init_chip()
8389 netdev_warn(bp->dev, "HWRM set coalescing failure rc: %x\n", in bnxt_init_chip()
8392 if (BNXT_CHIP_TYPE_NITRO_A0(bp)) { in bnxt_init_chip()
8393 rc = bnxt_setup_nitroa0_vnic(bp); in bnxt_init_chip()
8395 netdev_err(bp->dev, "Special vnic setup failure for NS2 A0 rc: %x\n", in bnxt_init_chip()
8399 if (BNXT_VF(bp)) { in bnxt_init_chip()
8400 bnxt_hwrm_func_qcfg(bp); in bnxt_init_chip()
8401 netdev_update_features(bp->dev); in bnxt_init_chip()
8407 bnxt_hwrm_resource_free(bp, 0, true); in bnxt_init_chip()
8412 static int bnxt_shutdown_nic(struct bnxt *bp, bool irq_re_init) in bnxt_shutdown_nic() argument
8414 bnxt_hwrm_resource_free(bp, 1, irq_re_init); in bnxt_shutdown_nic()
8418 static int bnxt_init_nic(struct bnxt *bp, bool irq_re_init) in bnxt_init_nic() argument
8420 bnxt_init_cp_rings(bp); in bnxt_init_nic()
8421 bnxt_init_rx_rings(bp); in bnxt_init_nic()
8422 bnxt_init_tx_rings(bp); in bnxt_init_nic()
8423 bnxt_init_ring_grps(bp, irq_re_init); in bnxt_init_nic()
8424 bnxt_init_vnics(bp); in bnxt_init_nic()
8426 return bnxt_init_chip(bp, irq_re_init); in bnxt_init_nic()
8429 static int bnxt_set_real_num_queues(struct bnxt *bp) in bnxt_set_real_num_queues() argument
8432 struct net_device *dev = bp->dev; in bnxt_set_real_num_queues()
8434 rc = netif_set_real_num_tx_queues(dev, bp->tx_nr_rings - in bnxt_set_real_num_queues()
8435 bp->tx_nr_rings_xdp); in bnxt_set_real_num_queues()
8439 rc = netif_set_real_num_rx_queues(dev, bp->rx_nr_rings); in bnxt_set_real_num_queues()
8444 if (bp->flags & BNXT_FLAG_RFS) in bnxt_set_real_num_queues()
8445 dev->rx_cpu_rmap = alloc_irq_cpu_rmap(bp->rx_nr_rings); in bnxt_set_real_num_queues()
8451 static int bnxt_trim_rings(struct bnxt *bp, int *rx, int *tx, int max, in bnxt_trim_rings() argument
8475 static void bnxt_setup_msix(struct bnxt *bp) in bnxt_setup_msix() argument
8477 const int len = sizeof(bp->irq_tbl[0].name); in bnxt_setup_msix()
8478 struct net_device *dev = bp->dev; in bnxt_setup_msix()
8486 count = bp->tx_nr_rings_per_tc; in bnxt_setup_msix()
8492 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_setup_msix()
8493 int map_idx = bnxt_cp_num_to_irq_num(bp, i); in bnxt_setup_msix()
8496 if (bp->flags & BNXT_FLAG_SHARED_RINGS) in bnxt_setup_msix()
8498 else if (i < bp->rx_nr_rings) in bnxt_setup_msix()
8503 snprintf(bp->irq_tbl[map_idx].name, len, "%s-%s-%d", dev->name, in bnxt_setup_msix()
8505 bp->irq_tbl[map_idx].handler = bnxt_msix; in bnxt_setup_msix()
8509 static void bnxt_setup_inta(struct bnxt *bp) in bnxt_setup_inta() argument
8511 const int len = sizeof(bp->irq_tbl[0].name); in bnxt_setup_inta()
8513 if (netdev_get_num_tc(bp->dev)) in bnxt_setup_inta()
8514 netdev_reset_tc(bp->dev); in bnxt_setup_inta()
8516 snprintf(bp->irq_tbl[0].name, len, "%s-%s-%d", bp->dev->name, "TxRx", in bnxt_setup_inta()
8518 bp->irq_tbl[0].handler = bnxt_inta; in bnxt_setup_inta()
8521 static int bnxt_init_int_mode(struct bnxt *bp);
8523 static int bnxt_setup_int_mode(struct bnxt *bp) in bnxt_setup_int_mode() argument
8527 if (!bp->irq_tbl) { in bnxt_setup_int_mode()
8528 rc = bnxt_init_int_mode(bp); in bnxt_setup_int_mode()
8529 if (rc || !bp->irq_tbl) in bnxt_setup_int_mode()
8533 if (bp->flags & BNXT_FLAG_USING_MSIX) in bnxt_setup_int_mode()
8534 bnxt_setup_msix(bp); in bnxt_setup_int_mode()
8536 bnxt_setup_inta(bp); in bnxt_setup_int_mode()
8538 rc = bnxt_set_real_num_queues(bp); in bnxt_setup_int_mode()
8543 static unsigned int bnxt_get_max_func_rss_ctxs(struct bnxt *bp) in bnxt_get_max_func_rss_ctxs() argument
8545 return bp->hw_resc.max_rsscos_ctxs; in bnxt_get_max_func_rss_ctxs()
8548 static unsigned int bnxt_get_max_func_vnics(struct bnxt *bp) in bnxt_get_max_func_vnics() argument
8550 return bp->hw_resc.max_vnics; in bnxt_get_max_func_vnics()
8554 unsigned int bnxt_get_max_func_stat_ctxs(struct bnxt *bp) in bnxt_get_max_func_stat_ctxs() argument
8556 return bp->hw_resc.max_stat_ctxs; in bnxt_get_max_func_stat_ctxs()
8559 unsigned int bnxt_get_max_func_cp_rings(struct bnxt *bp) in bnxt_get_max_func_cp_rings() argument
8561 return bp->hw_resc.max_cp_rings; in bnxt_get_max_func_cp_rings()
8564 static unsigned int bnxt_get_max_func_cp_rings_for_en(struct bnxt *bp) in bnxt_get_max_func_cp_rings_for_en() argument
8566 unsigned int cp = bp->hw_resc.max_cp_rings; in bnxt_get_max_func_cp_rings_for_en()
8568 if (!(bp->flags & BNXT_FLAG_CHIP_P5)) in bnxt_get_max_func_cp_rings_for_en()
8569 cp -= bnxt_get_ulp_msix_num(bp); in bnxt_get_max_func_cp_rings_for_en()
8574 static unsigned int bnxt_get_max_func_irqs(struct bnxt *bp) in bnxt_get_max_func_irqs() argument
8576 struct bnxt_hw_resc *hw_resc = &bp->hw_resc; in bnxt_get_max_func_irqs()
8578 if (bp->flags & BNXT_FLAG_CHIP_P5) in bnxt_get_max_func_irqs()
8584 static void bnxt_set_max_func_irqs(struct bnxt *bp, unsigned int max_irqs) in bnxt_set_max_func_irqs() argument
8586 bp->hw_resc.max_irqs = max_irqs; in bnxt_set_max_func_irqs()
8589 unsigned int bnxt_get_avail_cp_rings_for_en(struct bnxt *bp) in bnxt_get_avail_cp_rings_for_en() argument
8593 cp = bnxt_get_max_func_cp_rings_for_en(bp); in bnxt_get_avail_cp_rings_for_en()
8594 if (bp->flags & BNXT_FLAG_CHIP_P5) in bnxt_get_avail_cp_rings_for_en()
8595 return cp - bp->rx_nr_rings - bp->tx_nr_rings; in bnxt_get_avail_cp_rings_for_en()
8597 return cp - bp->cp_nr_rings; in bnxt_get_avail_cp_rings_for_en()
8600 unsigned int bnxt_get_avail_stat_ctxs_for_en(struct bnxt *bp) in bnxt_get_avail_stat_ctxs_for_en() argument
8602 return bnxt_get_max_func_stat_ctxs(bp) - bnxt_get_func_stat_ctxs(bp); in bnxt_get_avail_stat_ctxs_for_en()
8605 int bnxt_get_avail_msix(struct bnxt *bp, int num) in bnxt_get_avail_msix() argument
8607 int max_cp = bnxt_get_max_func_cp_rings(bp); in bnxt_get_avail_msix()
8608 int max_irq = bnxt_get_max_func_irqs(bp); in bnxt_get_avail_msix()
8609 int total_req = bp->cp_nr_rings + num; in bnxt_get_avail_msix()
8612 max_idx = bp->total_irqs; in bnxt_get_avail_msix()
8613 if (!(bp->flags & BNXT_FLAG_CHIP_P5)) in bnxt_get_avail_msix()
8614 max_idx = min_t(int, bp->total_irqs, max_cp); in bnxt_get_avail_msix()
8615 avail_msix = max_idx - bp->cp_nr_rings; in bnxt_get_avail_msix()
8616 if (!BNXT_NEW_RM(bp) || avail_msix >= num) in bnxt_get_avail_msix()
8620 num = max_irq - bp->cp_nr_rings; in bnxt_get_avail_msix()
8627 static int bnxt_get_num_msix(struct bnxt *bp) in bnxt_get_num_msix() argument
8629 if (!BNXT_NEW_RM(bp)) in bnxt_get_num_msix()
8630 return bnxt_get_max_func_irqs(bp); in bnxt_get_num_msix()
8632 return bnxt_nq_rings_in_use(bp); in bnxt_get_num_msix()
8635 static int bnxt_init_msix(struct bnxt *bp) in bnxt_init_msix() argument
8640 total_vecs = bnxt_get_num_msix(bp); in bnxt_init_msix()
8641 max = bnxt_get_max_func_irqs(bp); in bnxt_init_msix()
8657 if (!(bp->flags & BNXT_FLAG_SHARED_RINGS)) in bnxt_init_msix()
8660 total_vecs = pci_enable_msix_range(bp->pdev, msix_ent, min, total_vecs); in bnxt_init_msix()
8661 ulp_msix = bnxt_get_ulp_msix_num(bp); in bnxt_init_msix()
8667 bp->irq_tbl = kcalloc(total_vecs, sizeof(struct bnxt_irq), GFP_KERNEL); in bnxt_init_msix()
8668 if (bp->irq_tbl) { in bnxt_init_msix()
8670 bp->irq_tbl[i].vector = msix_ent[i].vector; in bnxt_init_msix()
8672 bp->total_irqs = total_vecs; in bnxt_init_msix()
8674 rc = bnxt_trim_rings(bp, &bp->rx_nr_rings, &bp->tx_nr_rings, in bnxt_init_msix()
8679 bp->cp_nr_rings = (min == 1) ? in bnxt_init_msix()
8680 max_t(int, bp->tx_nr_rings, bp->rx_nr_rings) : in bnxt_init_msix()
8681 bp->tx_nr_rings + bp->rx_nr_rings; in bnxt_init_msix()
8687 bp->flags |= BNXT_FLAG_USING_MSIX; in bnxt_init_msix()
8692 netdev_err(bp->dev, "bnxt_init_msix err: %x\n", rc); in bnxt_init_msix()
8693 kfree(bp->irq_tbl); in bnxt_init_msix()
8694 bp->irq_tbl = NULL; in bnxt_init_msix()
8695 pci_disable_msix(bp->pdev); in bnxt_init_msix()
8700 static int bnxt_init_inta(struct bnxt *bp) in bnxt_init_inta() argument
8702 bp->irq_tbl = kcalloc(1, sizeof(struct bnxt_irq), GFP_KERNEL); in bnxt_init_inta()
8703 if (!bp->irq_tbl) in bnxt_init_inta()
8706 bp->total_irqs = 1; in bnxt_init_inta()
8707 bp->rx_nr_rings = 1; in bnxt_init_inta()
8708 bp->tx_nr_rings = 1; in bnxt_init_inta()
8709 bp->cp_nr_rings = 1; in bnxt_init_inta()
8710 bp->flags |= BNXT_FLAG_SHARED_RINGS; in bnxt_init_inta()
8711 bp->irq_tbl[0].vector = bp->pdev->irq; in bnxt_init_inta()
8715 static int bnxt_init_int_mode(struct bnxt *bp) in bnxt_init_int_mode() argument
8719 if (bp->flags & BNXT_FLAG_MSIX_CAP) in bnxt_init_int_mode()
8720 rc = bnxt_init_msix(bp); in bnxt_init_int_mode()
8722 if (!(bp->flags & BNXT_FLAG_USING_MSIX) && BNXT_PF(bp)) { in bnxt_init_int_mode()
8724 rc = bnxt_init_inta(bp); in bnxt_init_int_mode()
8729 static void bnxt_clear_int_mode(struct bnxt *bp) in bnxt_clear_int_mode() argument
8731 if (bp->flags & BNXT_FLAG_USING_MSIX) in bnxt_clear_int_mode()
8732 pci_disable_msix(bp->pdev); in bnxt_clear_int_mode()
8734 kfree(bp->irq_tbl); in bnxt_clear_int_mode()
8735 bp->irq_tbl = NULL; in bnxt_clear_int_mode()
8736 bp->flags &= ~BNXT_FLAG_USING_MSIX; in bnxt_clear_int_mode()
8739 int bnxt_reserve_rings(struct bnxt *bp, bool irq_re_init) in bnxt_reserve_rings() argument
8741 int tcs = netdev_get_num_tc(bp->dev); in bnxt_reserve_rings()
8745 if (!bnxt_need_reserve_rings(bp)) in bnxt_reserve_rings()
8748 if (irq_re_init && BNXT_NEW_RM(bp) && in bnxt_reserve_rings()
8749 bnxt_get_num_msix(bp) != bp->total_irqs) { in bnxt_reserve_rings()
8750 bnxt_ulp_irq_stop(bp); in bnxt_reserve_rings()
8751 bnxt_clear_int_mode(bp); in bnxt_reserve_rings()
8754 rc = __bnxt_reserve_rings(bp); in bnxt_reserve_rings()
8757 rc = bnxt_init_int_mode(bp); in bnxt_reserve_rings()
8758 bnxt_ulp_irq_restart(bp, rc); in bnxt_reserve_rings()
8761 netdev_err(bp->dev, "ring reservation/IRQ init failure rc: %d\n", rc); in bnxt_reserve_rings()
8764 if (tcs && (bp->tx_nr_rings_per_tc * tcs != bp->tx_nr_rings)) { in bnxt_reserve_rings()
8765 netdev_err(bp->dev, "tx ring reservation failure\n"); in bnxt_reserve_rings()
8766 netdev_reset_tc(bp->dev); in bnxt_reserve_rings()
8767 bp->tx_nr_rings_per_tc = bp->tx_nr_rings; in bnxt_reserve_rings()
8773 static void bnxt_free_irq(struct bnxt *bp) in bnxt_free_irq() argument
8779 free_irq_cpu_rmap(bp->dev->rx_cpu_rmap); in bnxt_free_irq()
8780 bp->dev->rx_cpu_rmap = NULL; in bnxt_free_irq()
8782 if (!bp->irq_tbl || !bp->bnapi) in bnxt_free_irq()
8785 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_free_irq()
8786 int map_idx = bnxt_cp_num_to_irq_num(bp, i); in bnxt_free_irq()
8788 irq = &bp->irq_tbl[map_idx]; in bnxt_free_irq()
8795 free_irq(irq->vector, bp->bnapi[i]); in bnxt_free_irq()
8802 static int bnxt_request_irq(struct bnxt *bp) in bnxt_request_irq() argument
8810 rc = bnxt_setup_int_mode(bp); in bnxt_request_irq()
8812 netdev_err(bp->dev, "bnxt_setup_int_mode err: %x\n", in bnxt_request_irq()
8817 rmap = bp->dev->rx_cpu_rmap; in bnxt_request_irq()
8819 if (!(bp->flags & BNXT_FLAG_USING_MSIX)) in bnxt_request_irq()
8822 for (i = 0, j = 0; i < bp->cp_nr_rings; i++) { in bnxt_request_irq()
8823 int map_idx = bnxt_cp_num_to_irq_num(bp, i); in bnxt_request_irq()
8824 struct bnxt_irq *irq = &bp->irq_tbl[map_idx]; in bnxt_request_irq()
8827 if (rmap && bp->bnapi[i]->rx_ring) { in bnxt_request_irq()
8830 netdev_warn(bp->dev, "failed adding irq rmap for ring %d\n", in bnxt_request_irq()
8836 bp->bnapi[i]); in bnxt_request_irq()
8843 int numa_node = dev_to_node(&bp->pdev->dev); in bnxt_request_irq()
8850 netdev_warn(bp->dev, in bnxt_request_irq()
8860 static void bnxt_del_napi(struct bnxt *bp) in bnxt_del_napi() argument
8864 if (!bp->bnapi) in bnxt_del_napi()
8867 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_del_napi()
8868 struct bnxt_napi *bnapi = bp->bnapi[i]; in bnxt_del_napi()
8878 static void bnxt_init_napi(struct bnxt *bp) in bnxt_init_napi() argument
8881 unsigned int cp_nr_rings = bp->cp_nr_rings; in bnxt_init_napi()
8884 if (bp->flags & BNXT_FLAG_USING_MSIX) { in bnxt_init_napi()
8887 if (bp->flags & BNXT_FLAG_CHIP_P5) in bnxt_init_napi()
8889 else if (BNXT_CHIP_TYPE_NITRO_A0(bp)) in bnxt_init_napi()
8892 bnapi = bp->bnapi[i]; in bnxt_init_napi()
8893 netif_napi_add(bp->dev, &bnapi->napi, poll_fn, 64); in bnxt_init_napi()
8895 if (BNXT_CHIP_TYPE_NITRO_A0(bp)) { in bnxt_init_napi()
8896 bnapi = bp->bnapi[cp_nr_rings]; in bnxt_init_napi()
8897 netif_napi_add(bp->dev, &bnapi->napi, in bnxt_init_napi()
8901 bnapi = bp->bnapi[0]; in bnxt_init_napi()
8902 netif_napi_add(bp->dev, &bnapi->napi, bnxt_poll, 64); in bnxt_init_napi()
8906 static void bnxt_disable_napi(struct bnxt *bp) in bnxt_disable_napi() argument
8910 if (!bp->bnapi) in bnxt_disable_napi()
8913 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_disable_napi()
8914 struct bnxt_cp_ring_info *cpr = &bp->bnapi[i]->cp_ring; in bnxt_disable_napi()
8916 napi_disable(&bp->bnapi[i]->napi); in bnxt_disable_napi()
8917 if (bp->bnapi[i]->rx_ring) in bnxt_disable_napi()
8922 static void bnxt_enable_napi(struct bnxt *bp) in bnxt_enable_napi() argument
8926 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_enable_napi()
8927 struct bnxt_napi *bnapi = bp->bnapi[i]; in bnxt_enable_napi()
8943 void bnxt_tx_disable(struct bnxt *bp) in bnxt_tx_disable() argument
8948 if (bp->tx_ring) { in bnxt_tx_disable()
8949 for (i = 0; i < bp->tx_nr_rings; i++) { in bnxt_tx_disable()
8950 txr = &bp->tx_ring[i]; in bnxt_tx_disable()
8957 netif_carrier_off(bp->dev); in bnxt_tx_disable()
8959 netif_tx_disable(bp->dev); in bnxt_tx_disable()
8962 void bnxt_tx_enable(struct bnxt *bp) in bnxt_tx_enable() argument
8967 for (i = 0; i < bp->tx_nr_rings; i++) { in bnxt_tx_enable()
8968 txr = &bp->tx_ring[i]; in bnxt_tx_enable()
8973 netif_tx_wake_all_queues(bp->dev); in bnxt_tx_enable()
8974 if (bp->link_info.link_up) in bnxt_tx_enable()
8975 netif_carrier_on(bp->dev); in bnxt_tx_enable()
9002 static void bnxt_report_link(struct bnxt *bp) in bnxt_report_link() argument
9004 if (bp->link_info.link_up) { in bnxt_report_link()
9010 netif_carrier_on(bp->dev); in bnxt_report_link()
9011 speed = bnxt_fw_to_ethtool_speed(bp->link_info.link_speed); in bnxt_report_link()
9013 netdev_info(bp->dev, "NIC Link is Up, speed unknown\n"); in bnxt_report_link()
9016 if (bp->link_info.duplex == BNXT_LINK_DUPLEX_FULL) in bnxt_report_link()
9020 if (bp->link_info.pause == BNXT_LINK_PAUSE_BOTH) in bnxt_report_link()
9022 else if (bp->link_info.pause == BNXT_LINK_PAUSE_TX) in bnxt_report_link()
9024 else if (bp->link_info.pause == BNXT_LINK_PAUSE_RX) in bnxt_report_link()
9028 netdev_info(bp->dev, "NIC Link is Up, %u Mbps %s duplex, Flow control: %s\n", in bnxt_report_link()
9030 if (bp->flags & BNXT_FLAG_EEE_CAP) in bnxt_report_link()
9031 netdev_info(bp->dev, "EEE is %s\n", in bnxt_report_link()
9032 bp->eee.eee_active ? "active" : in bnxt_report_link()
9034 fec = bp->link_info.fec_cfg; in bnxt_report_link()
9036 netdev_info(bp->dev, "FEC autoneg %s encoding: %s\n", in bnxt_report_link()
9038 bnxt_report_fec(&bp->link_info)); in bnxt_report_link()
9040 netif_carrier_off(bp->dev); in bnxt_report_link()
9041 netdev_err(bp->dev, "NIC Link is Down\n"); in bnxt_report_link()
9055 static int bnxt_hwrm_phy_qcaps(struct bnxt *bp) in bnxt_hwrm_phy_qcaps() argument
9059 struct hwrm_port_phy_qcaps_output *resp = bp->hwrm_cmd_resp_addr; in bnxt_hwrm_phy_qcaps()
9060 struct bnxt_link_info *link_info = &bp->link_info; in bnxt_hwrm_phy_qcaps()
9062 bp->flags &= ~BNXT_FLAG_EEE_CAP; in bnxt_hwrm_phy_qcaps()
9063 if (bp->test_info) in bnxt_hwrm_phy_qcaps()
9064 bp->test_info->flags &= ~(BNXT_TEST_FL_EXT_LPBK | in bnxt_hwrm_phy_qcaps()
9066 if (bp->hwrm_spec_code < 0x10201) in bnxt_hwrm_phy_qcaps()
9069 bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_PORT_PHY_QCAPS, -1, -1); in bnxt_hwrm_phy_qcaps()
9071 mutex_lock(&bp->hwrm_cmd_lock); in bnxt_hwrm_phy_qcaps()
9072 rc = _hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT); in bnxt_hwrm_phy_qcaps()
9077 struct ethtool_eee *eee = &bp->eee; in bnxt_hwrm_phy_qcaps()
9080 bp->flags |= BNXT_FLAG_EEE_CAP; in bnxt_hwrm_phy_qcaps()
9082 bp->lpi_tmr_lo = le32_to_cpu(resp->tx_lpi_timer_low) & in bnxt_hwrm_phy_qcaps()
9084 bp->lpi_tmr_hi = le32_to_cpu(resp->valid_tx_lpi_timer_high) & in bnxt_hwrm_phy_qcaps()
9088 if (bp->test_info) in bnxt_hwrm_phy_qcaps()
9089 bp->test_info->flags |= BNXT_TEST_FL_EXT_LPBK; in bnxt_hwrm_phy_qcaps()
9092 if (bp->test_info) in bnxt_hwrm_phy_qcaps()
9093 bp->test_info->flags |= BNXT_TEST_FL_AN_PHY_LPBK; in bnxt_hwrm_phy_qcaps()
9096 if (BNXT_PF(bp)) in bnxt_hwrm_phy_qcaps()
9097 bp->fw_cap |= BNXT_FW_CAP_SHARED_PORT_CFG; in bnxt_hwrm_phy_qcaps()
9100 bp->fw_cap |= BNXT_FW_CAP_PORT_STATS_NO_RESET; in bnxt_hwrm_phy_qcaps()
9102 if (bp->hwrm_spec_code >= 0x10a01) { in bnxt_hwrm_phy_qcaps()
9105 netdev_warn(bp->dev, "Ethernet link disabled\n"); in bnxt_hwrm_phy_qcaps()
9108 netdev_info(bp->dev, "Ethernet link enabled\n"); in bnxt_hwrm_phy_qcaps()
9121 bp->port_count = resp->port_cnt; in bnxt_hwrm_phy_qcaps()
9124 mutex_unlock(&bp->hwrm_cmd_lock); in bnxt_hwrm_phy_qcaps()
9135 int bnxt_update_link(struct bnxt *bp, bool chng_link_state) in bnxt_update_link() argument
9138 struct bnxt_link_info *link_info = &bp->link_info; in bnxt_update_link()
9140 struct hwrm_port_phy_qcfg_output *resp = bp->hwrm_cmd_resp_addr; in bnxt_update_link()
9144 bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_PORT_PHY_QCFG, -1, -1); in bnxt_update_link()
9146 mutex_lock(&bp->hwrm_cmd_lock); in bnxt_update_link()
9147 rc = _hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT); in bnxt_update_link()
9149 mutex_unlock(&bp->hwrm_cmd_lock); in bnxt_update_link()
9156 if (bp->hwrm_spec_code >= 0x10800) in bnxt_update_link()
9191 if (bp->flags & BNXT_FLAG_EEE_CAP) { in bnxt_update_link()
9192 struct ethtool_eee *eee = &bp->eee; in bnxt_update_link()
9228 if (bp->hwrm_spec_code >= 0x10504) { in bnxt_update_link()
9239 bnxt_report_link(bp); in bnxt_update_link()
9244 mutex_unlock(&bp->hwrm_cmd_lock); in bnxt_update_link()
9246 if (!BNXT_PHY_CFG_ABLE(bp)) in bnxt_update_link()
9263 bnxt_hwrm_set_link_setting(bp, true, false); in bnxt_update_link()
9267 static void bnxt_get_port_module_status(struct bnxt *bp) in bnxt_get_port_module_status() argument
9269 struct bnxt_link_info *link_info = &bp->link_info; in bnxt_get_port_module_status()
9273 if (bnxt_update_link(bp, true)) in bnxt_get_port_module_status()
9281 netdev_warn(bp->dev, "Unqualified SFP+ module detected on port %d\n", in bnxt_get_port_module_status()
9282 bp->pf.port_id); in bnxt_get_port_module_status()
9283 if (bp->hwrm_spec_code >= 0x10201) { in bnxt_get_port_module_status()
9284 netdev_warn(bp->dev, "Module part number %s\n", in bnxt_get_port_module_status()
9288 netdev_warn(bp->dev, "TX is disabled\n"); in bnxt_get_port_module_status()
9290 netdev_warn(bp->dev, "SFP+ module is shutdown\n"); in bnxt_get_port_module_status()
9295 bnxt_hwrm_set_pause_common(struct bnxt *bp, struct hwrm_port_phy_cfg_input *req) in bnxt_hwrm_set_pause_common() argument
9297 if (bp->link_info.autoneg & BNXT_AUTONEG_FLOW_CTRL) { in bnxt_hwrm_set_pause_common()
9298 if (bp->hwrm_spec_code >= 0x10201) in bnxt_hwrm_set_pause_common()
9301 if (bp->link_info.req_flow_ctrl & BNXT_LINK_PAUSE_RX) in bnxt_hwrm_set_pause_common()
9303 if (bp->link_info.req_flow_ctrl & BNXT_LINK_PAUSE_TX) in bnxt_hwrm_set_pause_common()
9308 if (bp->link_info.req_flow_ctrl & BNXT_LINK_PAUSE_RX) in bnxt_hwrm_set_pause_common()
9310 if (bp->link_info.req_flow_ctrl & BNXT_LINK_PAUSE_TX) in bnxt_hwrm_set_pause_common()
9314 if (bp->hwrm_spec_code >= 0x10201) { in bnxt_hwrm_set_pause_common()
9322 static void bnxt_hwrm_set_link_common(struct bnxt *bp, struct hwrm_port_phy_cfg_input *req) in bnxt_hwrm_set_link_common() argument
9324 if (bp->link_info.autoneg & BNXT_AUTONEG_SPEED) { in bnxt_hwrm_set_link_common()
9326 if (bp->link_info.advertising) { in bnxt_hwrm_set_link_common()
9328 req->auto_link_speed_mask = cpu_to_le16(bp->link_info.advertising); in bnxt_hwrm_set_link_common()
9330 if (bp->link_info.advertising_pam4) { in bnxt_hwrm_set_link_common()
9334 cpu_to_le16(bp->link_info.advertising_pam4); in bnxt_hwrm_set_link_common()
9340 if (bp->link_info.req_signal_mode == BNXT_SIG_MODE_PAM4) { in bnxt_hwrm_set_link_common()
9341 req->force_pam4_link_speed = cpu_to_le16(bp->link_info.req_link_speed); in bnxt_hwrm_set_link_common()
9344 req->force_link_speed = cpu_to_le16(bp->link_info.req_link_speed); in bnxt_hwrm_set_link_common()
9352 int bnxt_hwrm_set_pause(struct bnxt *bp) in bnxt_hwrm_set_pause() argument
9357 bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_PORT_PHY_CFG, -1, -1); in bnxt_hwrm_set_pause()
9358 bnxt_hwrm_set_pause_common(bp, &req); in bnxt_hwrm_set_pause()
9360 if ((bp->link_info.autoneg & BNXT_AUTONEG_FLOW_CTRL) || in bnxt_hwrm_set_pause()
9361 bp->link_info.force_link_chng) in bnxt_hwrm_set_pause()
9362 bnxt_hwrm_set_link_common(bp, &req); in bnxt_hwrm_set_pause()
9364 mutex_lock(&bp->hwrm_cmd_lock); in bnxt_hwrm_set_pause()
9365 rc = _hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT); in bnxt_hwrm_set_pause()
9366 if (!rc && !(bp->link_info.autoneg & BNXT_AUTONEG_FLOW_CTRL)) { in bnxt_hwrm_set_pause()
9371 bp->link_info.pause = in bnxt_hwrm_set_pause()
9372 bp->link_info.force_pause_setting = bp->link_info.req_flow_ctrl; in bnxt_hwrm_set_pause()
9373 bp->link_info.auto_pause_setting = 0; in bnxt_hwrm_set_pause()
9374 if (!bp->link_info.force_link_chng) in bnxt_hwrm_set_pause()
9375 bnxt_report_link(bp); in bnxt_hwrm_set_pause()
9377 bp->link_info.force_link_chng = false; in bnxt_hwrm_set_pause()
9378 mutex_unlock(&bp->hwrm_cmd_lock); in bnxt_hwrm_set_pause()
9382 static void bnxt_hwrm_set_eee(struct bnxt *bp, in bnxt_hwrm_set_eee() argument
9385 struct ethtool_eee *eee = &bp->eee; in bnxt_hwrm_set_eee()
9405 int bnxt_hwrm_set_link_setting(struct bnxt *bp, bool set_pause, bool set_eee) in bnxt_hwrm_set_link_setting() argument
9409 bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_PORT_PHY_CFG, -1, -1); in bnxt_hwrm_set_link_setting()
9411 bnxt_hwrm_set_pause_common(bp, &req); in bnxt_hwrm_set_link_setting()
9413 bnxt_hwrm_set_link_common(bp, &req); in bnxt_hwrm_set_link_setting()
9416 bnxt_hwrm_set_eee(bp, &req); in bnxt_hwrm_set_link_setting()
9417 return hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT); in bnxt_hwrm_set_link_setting()
9420 static int bnxt_hwrm_shutdown_link(struct bnxt *bp) in bnxt_hwrm_shutdown_link() argument
9424 if (!BNXT_SINGLE_PF(bp)) in bnxt_hwrm_shutdown_link()
9427 if (pci_num_vf(bp->pdev)) in bnxt_hwrm_shutdown_link()
9430 bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_PORT_PHY_CFG, -1, -1); in bnxt_hwrm_shutdown_link()
9432 return hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT); in bnxt_hwrm_shutdown_link()
9435 static int bnxt_fw_init_one(struct bnxt *bp);
9437 static int bnxt_hwrm_if_change(struct bnxt *bp, bool up) in bnxt_hwrm_if_change() argument
9439 struct hwrm_func_drv_if_change_output *resp = bp->hwrm_cmd_resp_addr; in bnxt_hwrm_if_change()
9441 bool fw_reset = !bp->irq_tbl; in bnxt_hwrm_if_change()
9446 if (!(bp->fw_cap & BNXT_FW_CAP_IF_CHANGE)) in bnxt_hwrm_if_change()
9449 bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_FUNC_DRV_IF_CHANGE, -1, -1); in bnxt_hwrm_if_change()
9452 mutex_lock(&bp->hwrm_cmd_lock); in bnxt_hwrm_if_change()
9453 rc = _hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT); in bnxt_hwrm_if_change()
9456 mutex_unlock(&bp->hwrm_cmd_lock); in bnxt_hwrm_if_change()
9468 if (test_bit(BNXT_STATE_IN_FW_RESET, &bp->state) && !fw_reset) { in bnxt_hwrm_if_change()
9469 netdev_err(bp->dev, "RESET_DONE not set during FW reset.\n"); in bnxt_hwrm_if_change()
9470 set_bit(BNXT_STATE_ABORT_ERR, &bp->state); in bnxt_hwrm_if_change()
9475 if (!test_bit(BNXT_STATE_IN_FW_RESET, &bp->state)) in bnxt_hwrm_if_change()
9476 bnxt_ulp_stop(bp); in bnxt_hwrm_if_change()
9477 bnxt_free_ctx_mem(bp); in bnxt_hwrm_if_change()
9478 kfree(bp->ctx); in bnxt_hwrm_if_change()
9479 bp->ctx = NULL; in bnxt_hwrm_if_change()
9480 bnxt_dcb_free(bp); in bnxt_hwrm_if_change()
9481 rc = bnxt_fw_init_one(bp); in bnxt_hwrm_if_change()
9483 set_bit(BNXT_STATE_ABORT_ERR, &bp->state); in bnxt_hwrm_if_change()
9486 bnxt_clear_int_mode(bp); in bnxt_hwrm_if_change()
9487 rc = bnxt_init_int_mode(bp); in bnxt_hwrm_if_change()
9489 netdev_err(bp->dev, "init int mode failed\n"); in bnxt_hwrm_if_change()
9492 set_bit(BNXT_STATE_FW_RESET_DET, &bp->state); in bnxt_hwrm_if_change()
9494 if (BNXT_NEW_RM(bp)) { in bnxt_hwrm_if_change()
9495 struct bnxt_hw_resc *hw_resc = &bp->hw_resc; in bnxt_hwrm_if_change()
9497 rc = bnxt_hwrm_func_resc_qcaps(bp, true); in bnxt_hwrm_if_change()
9506 bp->tx_nr_rings = 0; in bnxt_hwrm_if_change()
9507 bp->rx_nr_rings = 0; in bnxt_hwrm_if_change()
9514 static int bnxt_hwrm_port_led_qcaps(struct bnxt *bp) in bnxt_hwrm_port_led_qcaps() argument
9516 struct hwrm_port_led_qcaps_output *resp = bp->hwrm_cmd_resp_addr; in bnxt_hwrm_port_led_qcaps()
9518 struct bnxt_pf_info *pf = &bp->pf; in bnxt_hwrm_port_led_qcaps()
9521 bp->num_leds = 0; in bnxt_hwrm_port_led_qcaps()
9522 if (BNXT_VF(bp) || bp->hwrm_spec_code < 0x10601) in bnxt_hwrm_port_led_qcaps()
9525 bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_PORT_LED_QCAPS, -1, -1); in bnxt_hwrm_port_led_qcaps()
9527 mutex_lock(&bp->hwrm_cmd_lock); in bnxt_hwrm_port_led_qcaps()
9528 rc = _hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT); in bnxt_hwrm_port_led_qcaps()
9530 mutex_unlock(&bp->hwrm_cmd_lock); in bnxt_hwrm_port_led_qcaps()
9536 bp->num_leds = resp->num_leds; in bnxt_hwrm_port_led_qcaps()
9537 memcpy(bp->leds, &resp->led0_id, sizeof(bp->leds[0]) * in bnxt_hwrm_port_led_qcaps()
9538 bp->num_leds); in bnxt_hwrm_port_led_qcaps()
9539 for (i = 0; i < bp->num_leds; i++) { in bnxt_hwrm_port_led_qcaps()
9540 struct bnxt_led_info *led = &bp->leds[i]; in bnxt_hwrm_port_led_qcaps()
9545 bp->num_leds = 0; in bnxt_hwrm_port_led_qcaps()
9550 mutex_unlock(&bp->hwrm_cmd_lock); in bnxt_hwrm_port_led_qcaps()
9554 int bnxt_hwrm_alloc_wol_fltr(struct bnxt *bp) in bnxt_hwrm_alloc_wol_fltr() argument
9557 struct hwrm_wol_filter_alloc_output *resp = bp->hwrm_cmd_resp_addr; in bnxt_hwrm_alloc_wol_fltr()
9560 bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_WOL_FILTER_ALLOC, -1, -1); in bnxt_hwrm_alloc_wol_fltr()
9561 req.port_id = cpu_to_le16(bp->pf.port_id); in bnxt_hwrm_alloc_wol_fltr()
9564 memcpy(req.mac_address, bp->dev->dev_addr, ETH_ALEN); in bnxt_hwrm_alloc_wol_fltr()
9565 mutex_lock(&bp->hwrm_cmd_lock); in bnxt_hwrm_alloc_wol_fltr()
9566 rc = _hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT); in bnxt_hwrm_alloc_wol_fltr()
9568 bp->wol_filter_id = resp->wol_filter_id; in bnxt_hwrm_alloc_wol_fltr()
9569 mutex_unlock(&bp->hwrm_cmd_lock); in bnxt_hwrm_alloc_wol_fltr()
9573 int bnxt_hwrm_free_wol_fltr(struct bnxt *bp) in bnxt_hwrm_free_wol_fltr() argument
9577 bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_WOL_FILTER_FREE, -1, -1); in bnxt_hwrm_free_wol_fltr()
9578 req.port_id = cpu_to_le16(bp->pf.port_id); in bnxt_hwrm_free_wol_fltr()
9580 req.wol_filter_id = bp->wol_filter_id; in bnxt_hwrm_free_wol_fltr()
9581 return hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT); in bnxt_hwrm_free_wol_fltr()
9584 static u16 bnxt_hwrm_get_wol_fltrs(struct bnxt *bp, u16 handle) in bnxt_hwrm_get_wol_fltrs() argument
9587 struct hwrm_wol_filter_qcfg_output *resp = bp->hwrm_cmd_resp_addr; in bnxt_hwrm_get_wol_fltrs()
9591 bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_WOL_FILTER_QCFG, -1, -1); in bnxt_hwrm_get_wol_fltrs()
9592 req.port_id = cpu_to_le16(bp->pf.port_id); in bnxt_hwrm_get_wol_fltrs()
9594 mutex_lock(&bp->hwrm_cmd_lock); in bnxt_hwrm_get_wol_fltrs()
9595 rc = _hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT); in bnxt_hwrm_get_wol_fltrs()
9601 bp->wol = 1; in bnxt_hwrm_get_wol_fltrs()
9602 bp->wol_filter_id = resp->wol_filter_id; in bnxt_hwrm_get_wol_fltrs()
9606 mutex_unlock(&bp->hwrm_cmd_lock); in bnxt_hwrm_get_wol_fltrs()
9610 static void bnxt_get_wol_settings(struct bnxt *bp) in bnxt_get_wol_settings() argument
9614 bp->wol = 0; in bnxt_get_wol_settings()
9615 if (!BNXT_PF(bp) || !(bp->flags & BNXT_FLAG_WOL_CAP)) in bnxt_get_wol_settings()
9619 handle = bnxt_hwrm_get_wol_fltrs(bp, handle); in bnxt_get_wol_settings()
9629 struct bnxt *bp = dev_get_drvdata(dev); in bnxt_show_temp() local
9633 resp = bp->hwrm_cmd_resp_addr; in bnxt_show_temp()
9634 bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_TEMP_MONITOR_QUERY, -1, -1); in bnxt_show_temp()
9635 mutex_lock(&bp->hwrm_cmd_lock); in bnxt_show_temp()
9636 rc = _hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT); in bnxt_show_temp()
9639 mutex_unlock(&bp->hwrm_cmd_lock); in bnxt_show_temp()
9652 static void bnxt_hwmon_close(struct bnxt *bp) in bnxt_hwmon_close() argument
9654 if (bp->hwmon_dev) { in bnxt_hwmon_close()
9655 hwmon_device_unregister(bp->hwmon_dev); in bnxt_hwmon_close()
9656 bp->hwmon_dev = NULL; in bnxt_hwmon_close()
9660 static void bnxt_hwmon_open(struct bnxt *bp) in bnxt_hwmon_open() argument
9663 struct pci_dev *pdev = bp->pdev; in bnxt_hwmon_open()
9666 bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_TEMP_MONITOR_QUERY, -1, -1); in bnxt_hwmon_open()
9667 rc = hwrm_send_message_silent(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT); in bnxt_hwmon_open()
9669 bnxt_hwmon_close(bp); in bnxt_hwmon_open()
9673 if (bp->hwmon_dev) in bnxt_hwmon_open()
9676 bp->hwmon_dev = hwmon_device_register_with_groups(&pdev->dev, in bnxt_hwmon_open()
9677 DRV_MODULE_NAME, bp, in bnxt_hwmon_open()
9679 if (IS_ERR(bp->hwmon_dev)) { in bnxt_hwmon_open()
9680 bp->hwmon_dev = NULL; in bnxt_hwmon_open()
9685 static void bnxt_hwmon_close(struct bnxt *bp) in bnxt_hwmon_close() argument
9689 static void bnxt_hwmon_open(struct bnxt *bp) in bnxt_hwmon_open() argument
9694 static bool bnxt_eee_config_ok(struct bnxt *bp) in bnxt_eee_config_ok() argument
9696 struct ethtool_eee *eee = &bp->eee; in bnxt_eee_config_ok()
9697 struct bnxt_link_info *link_info = &bp->link_info; in bnxt_eee_config_ok()
9699 if (!(bp->flags & BNXT_FLAG_EEE_CAP)) in bnxt_eee_config_ok()
9718 static int bnxt_update_phy_setting(struct bnxt *bp) in bnxt_update_phy_setting() argument
9724 struct bnxt_link_info *link_info = &bp->link_info; in bnxt_update_phy_setting()
9726 rc = bnxt_update_link(bp, true); in bnxt_update_phy_setting()
9728 netdev_err(bp->dev, "failed to update link (rc: %x)\n", in bnxt_update_phy_setting()
9732 if (!BNXT_SINGLE_PF(bp)) in bnxt_update_phy_setting()
9764 if (!bp->link_info.link_up) in bnxt_update_phy_setting()
9767 if (!bnxt_eee_config_ok(bp)) in bnxt_update_phy_setting()
9771 rc = bnxt_hwrm_set_link_setting(bp, update_pause, update_eee); in bnxt_update_phy_setting()
9773 rc = bnxt_hwrm_set_pause(bp); in bnxt_update_phy_setting()
9775 netdev_err(bp->dev, "failed to update phy setting (rc: %x)\n", in bnxt_update_phy_setting()
9788 static void bnxt_preset_reg_win(struct bnxt *bp) in bnxt_preset_reg_win() argument
9790 if (BNXT_PF(bp)) { in bnxt_preset_reg_win()
9793 bp->bar0 + BNXT_GRCPF_REG_WINDOW_BASE_OUT + 12); in bnxt_preset_reg_win()
9797 static int bnxt_init_dflt_ring_mode(struct bnxt *bp);
9799 static int __bnxt_open_nic(struct bnxt *bp, bool irq_re_init, bool link_re_init) in __bnxt_open_nic() argument
9803 bnxt_preset_reg_win(bp); in __bnxt_open_nic()
9804 netif_carrier_off(bp->dev); in __bnxt_open_nic()
9807 rc = bnxt_init_dflt_ring_mode(bp); in __bnxt_open_nic()
9809 netdev_err(bp->dev, "Failed to reserve default rings at open\n"); in __bnxt_open_nic()
9813 rc = bnxt_reserve_rings(bp, irq_re_init); in __bnxt_open_nic()
9816 if ((bp->flags & BNXT_FLAG_RFS) && in __bnxt_open_nic()
9817 !(bp->flags & BNXT_FLAG_USING_MSIX)) { in __bnxt_open_nic()
9819 bp->dev->hw_features &= ~NETIF_F_NTUPLE; in __bnxt_open_nic()
9820 bp->flags &= ~BNXT_FLAG_RFS; in __bnxt_open_nic()
9823 rc = bnxt_alloc_mem(bp, irq_re_init); in __bnxt_open_nic()
9825 netdev_err(bp->dev, "bnxt_alloc_mem err: %x\n", rc); in __bnxt_open_nic()
9830 bnxt_init_napi(bp); in __bnxt_open_nic()
9831 rc = bnxt_request_irq(bp); in __bnxt_open_nic()
9833 netdev_err(bp->dev, "bnxt_request_irq err: %x\n", rc); in __bnxt_open_nic()
9838 rc = bnxt_init_nic(bp, irq_re_init); in __bnxt_open_nic()
9840 netdev_err(bp->dev, "bnxt_init_nic err: %x\n", rc); in __bnxt_open_nic()
9844 bnxt_enable_napi(bp); in __bnxt_open_nic()
9845 bnxt_debug_dev_init(bp); in __bnxt_open_nic()
9848 mutex_lock(&bp->link_lock); in __bnxt_open_nic()
9849 rc = bnxt_update_phy_setting(bp); in __bnxt_open_nic()
9850 mutex_unlock(&bp->link_lock); in __bnxt_open_nic()
9852 netdev_warn(bp->dev, "failed to update phy settings\n"); in __bnxt_open_nic()
9853 if (BNXT_SINGLE_PF(bp)) { in __bnxt_open_nic()
9854 bp->link_info.phy_retry = true; in __bnxt_open_nic()
9855 bp->link_info.phy_retry_expires = in __bnxt_open_nic()
9862 udp_tunnel_nic_reset_ntf(bp->dev); in __bnxt_open_nic()
9864 set_bit(BNXT_STATE_OPEN, &bp->state); in __bnxt_open_nic()
9865 bnxt_enable_int(bp); in __bnxt_open_nic()
9867 bnxt_tx_enable(bp); in __bnxt_open_nic()
9868 mod_timer(&bp->timer, jiffies + bp->current_interval); in __bnxt_open_nic()
9870 bnxt_get_port_module_status(bp); in __bnxt_open_nic()
9873 if (BNXT_PF(bp)) in __bnxt_open_nic()
9874 bnxt_vf_reps_open(bp); in __bnxt_open_nic()
9878 bnxt_del_napi(bp); in __bnxt_open_nic()
9881 bnxt_free_skbs(bp); in __bnxt_open_nic()
9882 bnxt_free_irq(bp); in __bnxt_open_nic()
9883 bnxt_free_mem(bp, true); in __bnxt_open_nic()
9888 int bnxt_open_nic(struct bnxt *bp, bool irq_re_init, bool link_re_init) in bnxt_open_nic() argument
9892 if (test_bit(BNXT_STATE_ABORT_ERR, &bp->state)) in bnxt_open_nic()
9895 rc = __bnxt_open_nic(bp, irq_re_init, link_re_init); in bnxt_open_nic()
9897 netdev_err(bp->dev, "nic open fail (rc: %x)\n", rc); in bnxt_open_nic()
9898 dev_close(bp->dev); in bnxt_open_nic()
9907 int bnxt_half_open_nic(struct bnxt *bp) in bnxt_half_open_nic() argument
9911 if (test_bit(BNXT_STATE_ABORT_ERR, &bp->state)) { in bnxt_half_open_nic()
9912 netdev_err(bp->dev, "A previous firmware reset has not completed, aborting half open\n"); in bnxt_half_open_nic()
9917 rc = bnxt_alloc_mem(bp, false); in bnxt_half_open_nic()
9919 netdev_err(bp->dev, "bnxt_alloc_mem err: %x\n", rc); in bnxt_half_open_nic()
9922 rc = bnxt_init_nic(bp, false); in bnxt_half_open_nic()
9924 netdev_err(bp->dev, "bnxt_init_nic err: %x\n", rc); in bnxt_half_open_nic()
9930 bnxt_free_skbs(bp); in bnxt_half_open_nic()
9931 bnxt_free_mem(bp, false); in bnxt_half_open_nic()
9932 dev_close(bp->dev); in bnxt_half_open_nic()
9939 void bnxt_half_close_nic(struct bnxt *bp) in bnxt_half_close_nic() argument
9941 bnxt_hwrm_resource_free(bp, false, false); in bnxt_half_close_nic()
9942 bnxt_free_skbs(bp); in bnxt_half_close_nic()
9943 bnxt_free_mem(bp, false); in bnxt_half_close_nic()
9946 static void bnxt_reenable_sriov(struct bnxt *bp) in bnxt_reenable_sriov() argument
9948 if (BNXT_PF(bp)) { in bnxt_reenable_sriov()
9949 struct bnxt_pf_info *pf = &bp->pf; in bnxt_reenable_sriov()
9953 bnxt_cfg_hw_sriov(bp, &n, true); in bnxt_reenable_sriov()
9959 struct bnxt *bp = netdev_priv(dev); in bnxt_open() local
9962 if (test_bit(BNXT_STATE_ABORT_ERR, &bp->state)) { in bnxt_open()
9963 netdev_err(bp->dev, "A previous firmware reset did not complete, aborting\n"); in bnxt_open()
9967 rc = bnxt_hwrm_if_change(bp, true); in bnxt_open()
9970 rc = __bnxt_open_nic(bp, true, true); in bnxt_open()
9972 bnxt_hwrm_if_change(bp, false); in bnxt_open()
9974 if (test_and_clear_bit(BNXT_STATE_FW_RESET_DET, &bp->state)) { in bnxt_open()
9975 if (!test_bit(BNXT_STATE_IN_FW_RESET, &bp->state)) { in bnxt_open()
9976 bnxt_ulp_start(bp, 0); in bnxt_open()
9977 bnxt_reenable_sriov(bp); in bnxt_open()
9980 bnxt_hwmon_open(bp); in bnxt_open()
9986 static bool bnxt_drv_busy(struct bnxt *bp) in bnxt_drv_busy() argument
9988 return (test_bit(BNXT_STATE_IN_SP_TASK, &bp->state) || in bnxt_drv_busy()
9989 test_bit(BNXT_STATE_READ_STATS, &bp->state)); in bnxt_drv_busy()
9992 static void bnxt_get_ring_stats(struct bnxt *bp,
9995 static void __bnxt_close_nic(struct bnxt *bp, bool irq_re_init, in __bnxt_close_nic() argument
9999 if (BNXT_PF(bp)) in __bnxt_close_nic()
10000 bnxt_vf_reps_close(bp); in __bnxt_close_nic()
10003 bnxt_tx_disable(bp); in __bnxt_close_nic()
10005 clear_bit(BNXT_STATE_OPEN, &bp->state); in __bnxt_close_nic()
10007 while (bnxt_drv_busy(bp)) in __bnxt_close_nic()
10011 bnxt_shutdown_nic(bp, irq_re_init); in __bnxt_close_nic()
10015 bnxt_debug_dev_exit(bp); in __bnxt_close_nic()
10016 bnxt_disable_napi(bp); in __bnxt_close_nic()
10017 del_timer_sync(&bp->timer); in __bnxt_close_nic()
10018 bnxt_free_skbs(bp); in __bnxt_close_nic()
10021 if (bp->bnapi && irq_re_init) in __bnxt_close_nic()
10022 bnxt_get_ring_stats(bp, &bp->net_stats_prev); in __bnxt_close_nic()
10024 bnxt_free_irq(bp); in __bnxt_close_nic()
10025 bnxt_del_napi(bp); in __bnxt_close_nic()
10027 bnxt_free_mem(bp, irq_re_init); in __bnxt_close_nic()
10030 int bnxt_close_nic(struct bnxt *bp, bool irq_re_init, bool link_re_init) in bnxt_close_nic() argument
10034 if (test_bit(BNXT_STATE_IN_FW_RESET, &bp->state)) { in bnxt_close_nic()
10042 netdev_warn(bp->dev, "FW reset in progress during close, FW reset will be aborted\n"); in bnxt_close_nic()
10043 set_bit(BNXT_STATE_ABORT_ERR, &bp->state); in bnxt_close_nic()
10047 if (bp->sriov_cfg) { in bnxt_close_nic()
10048 rc = wait_event_interruptible_timeout(bp->sriov_cfg_wait, in bnxt_close_nic()
10049 !bp->sriov_cfg, in bnxt_close_nic()
10052 netdev_warn(bp->dev, "timeout waiting for SRIOV config operation to complete!\n"); in bnxt_close_nic()
10055 __bnxt_close_nic(bp, irq_re_init, link_re_init); in bnxt_close_nic()
10061 struct bnxt *bp = netdev_priv(dev); in bnxt_close() local
10063 bnxt_hwmon_close(bp); in bnxt_close()
10064 bnxt_close_nic(bp, true, true); in bnxt_close()
10065 bnxt_hwrm_shutdown_link(bp); in bnxt_close()
10066 bnxt_hwrm_if_change(bp, false); in bnxt_close()
10070 static int bnxt_hwrm_port_phy_read(struct bnxt *bp, u16 phy_addr, u16 reg, in bnxt_hwrm_port_phy_read() argument
10073 struct hwrm_port_phy_mdio_read_output *resp = bp->hwrm_cmd_resp_addr; in bnxt_hwrm_port_phy_read()
10077 if (bp->hwrm_spec_code < 0x10a00) in bnxt_hwrm_port_phy_read()
10080 bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_PORT_PHY_MDIO_READ, -1, -1); in bnxt_hwrm_port_phy_read()
10081 req.port_id = cpu_to_le16(bp->pf.port_id); in bnxt_hwrm_port_phy_read()
10091 mutex_lock(&bp->hwrm_cmd_lock); in bnxt_hwrm_port_phy_read()
10092 rc = _hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT); in bnxt_hwrm_port_phy_read()
10095 mutex_unlock(&bp->hwrm_cmd_lock); in bnxt_hwrm_port_phy_read()
10099 static int bnxt_hwrm_port_phy_write(struct bnxt *bp, u16 phy_addr, u16 reg, in bnxt_hwrm_port_phy_write() argument
10104 if (bp->hwrm_spec_code < 0x10a00) in bnxt_hwrm_port_phy_write()
10107 bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_PORT_PHY_MDIO_WRITE, -1, -1); in bnxt_hwrm_port_phy_write()
10108 req.port_id = cpu_to_le16(bp->pf.port_id); in bnxt_hwrm_port_phy_write()
10119 return hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT); in bnxt_hwrm_port_phy_write()
10126 struct bnxt *bp = netdev_priv(dev); in bnxt_ioctl() local
10131 mdio->phy_id = bp->link_info.phy_addr; in bnxt_ioctl()
10140 rc = bnxt_hwrm_port_phy_read(bp, mdio->phy_id, mdio->reg_num, in bnxt_ioctl()
10150 return bnxt_hwrm_port_phy_write(bp, mdio->phy_id, mdio->reg_num, in bnxt_ioctl()
10160 static void bnxt_get_ring_stats(struct bnxt *bp, in bnxt_get_ring_stats() argument
10165 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_get_ring_stats()
10166 struct bnxt_napi *bnapi = bp->bnapi[i]; in bnxt_get_ring_stats()
10195 static void bnxt_add_prev_stats(struct bnxt *bp, in bnxt_add_prev_stats() argument
10198 struct rtnl_link_stats64 *prev_stats = &bp->net_stats_prev; in bnxt_add_prev_stats()
10212 struct bnxt *bp = netdev_priv(dev); in bnxt_get_stats64() local
10214 set_bit(BNXT_STATE_READ_STATS, &bp->state); in bnxt_get_stats64()
10219 if (!test_bit(BNXT_STATE_OPEN, &bp->state)) { in bnxt_get_stats64()
10220 clear_bit(BNXT_STATE_READ_STATS, &bp->state); in bnxt_get_stats64()
10221 *stats = bp->net_stats_prev; in bnxt_get_stats64()
10225 bnxt_get_ring_stats(bp, stats); in bnxt_get_stats64()
10226 bnxt_add_prev_stats(bp, stats); in bnxt_get_stats64()
10228 if (bp->flags & BNXT_FLAG_PORT_STATS) { in bnxt_get_stats64()
10229 u64 *rx = bp->port_stats.sw_stats; in bnxt_get_stats64()
10230 u64 *tx = bp->port_stats.sw_stats + in bnxt_get_stats64()
10250 clear_bit(BNXT_STATE_READ_STATS, &bp->state); in bnxt_get_stats64()
10253 static bool bnxt_mc_list_updated(struct bnxt *bp, u32 *rx_mask) in bnxt_mc_list_updated() argument
10255 struct net_device *dev = bp->dev; in bnxt_mc_list_updated()
10256 struct bnxt_vnic_info *vnic = &bp->vnic_info[0]; in bnxt_mc_list_updated()
10287 static bool bnxt_uc_list_updated(struct bnxt *bp) in bnxt_uc_list_updated() argument
10289 struct net_device *dev = bp->dev; in bnxt_uc_list_updated()
10290 struct bnxt_vnic_info *vnic = &bp->vnic_info[0]; in bnxt_uc_list_updated()
10308 struct bnxt *bp = netdev_priv(dev); in bnxt_set_rx_mode() local
10314 if (!test_bit(BNXT_STATE_OPEN, &bp->state)) in bnxt_set_rx_mode()
10317 vnic = &bp->vnic_info[0]; in bnxt_set_rx_mode()
10324 if ((dev->flags & IFF_PROMISC) && bnxt_promisc_ok(bp)) in bnxt_set_rx_mode()
10327 uc_update = bnxt_uc_list_updated(bp); in bnxt_set_rx_mode()
10335 mc_update = bnxt_mc_list_updated(bp, &mask); in bnxt_set_rx_mode()
10341 set_bit(BNXT_RX_MASK_SP_EVENT, &bp->sp_event); in bnxt_set_rx_mode()
10342 bnxt_queue_sp_work(bp); in bnxt_set_rx_mode()
10346 static int bnxt_cfg_rx_mode(struct bnxt *bp) in bnxt_cfg_rx_mode() argument
10348 struct net_device *dev = bp->dev; in bnxt_cfg_rx_mode()
10349 struct bnxt_vnic_info *vnic = &bp->vnic_info[0]; in bnxt_cfg_rx_mode()
10355 uc_update = bnxt_uc_list_updated(bp); in bnxt_cfg_rx_mode()
10361 mutex_lock(&bp->hwrm_cmd_lock); in bnxt_cfg_rx_mode()
10365 bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_CFA_L2_FILTER_FREE, -1, in bnxt_cfg_rx_mode()
10370 rc = _hwrm_send_message(bp, &req, sizeof(req), in bnxt_cfg_rx_mode()
10373 mutex_unlock(&bp->hwrm_cmd_lock); in bnxt_cfg_rx_mode()
10390 rc = bnxt_hwrm_set_vnic_filter(bp, 0, i, vnic->uc_list + off); in bnxt_cfg_rx_mode()
10392 netdev_err(bp->dev, "HWRM vnic filter failure rc: %x\n", in bnxt_cfg_rx_mode()
10400 rc = bnxt_hwrm_cfa_l2_set_rx_mask(bp, 0); in bnxt_cfg_rx_mode()
10402 netdev_info(bp->dev, "Failed setting MC filters rc: %d, turning on ALL_MCAST mode\n", in bnxt_cfg_rx_mode()
10406 rc = bnxt_hwrm_cfa_l2_set_rx_mask(bp, 0); in bnxt_cfg_rx_mode()
10409 netdev_err(bp->dev, "HWRM cfa l2 rx mask failure rc: %d\n", in bnxt_cfg_rx_mode()
10415 static bool bnxt_can_reserve_rings(struct bnxt *bp) in bnxt_can_reserve_rings() argument
10418 if (BNXT_NEW_RM(bp) && BNXT_VF(bp)) { in bnxt_can_reserve_rings()
10419 struct bnxt_hw_resc *hw_resc = &bp->hw_resc; in bnxt_can_reserve_rings()
10427 if (!netif_running(bp->dev)) in bnxt_can_reserve_rings()
10435 static bool bnxt_rfs_supported(struct bnxt *bp) in bnxt_rfs_supported() argument
10437 if (bp->flags & BNXT_FLAG_CHIP_P5) { in bnxt_rfs_supported()
10438 if (bp->fw_cap & BNXT_FW_CAP_CFA_RFS_RING_TBL_IDX_V2) in bnxt_rfs_supported()
10443 if (BNXT_FW_MAJ(bp) == 212) in bnxt_rfs_supported()
10445 if (BNXT_PF(bp) && !BNXT_CHIP_TYPE_NITRO_A0(bp)) in bnxt_rfs_supported()
10447 if (bp->flags & BNXT_FLAG_NEW_RSS_CAP) in bnxt_rfs_supported()
10453 static bool bnxt_rfs_capable(struct bnxt *bp) in bnxt_rfs_capable() argument
10458 if (bp->flags & BNXT_FLAG_CHIP_P5) in bnxt_rfs_capable()
10459 return bnxt_rfs_supported(bp); in bnxt_rfs_capable()
10460 if (!(bp->flags & BNXT_FLAG_MSIX_CAP) || !bnxt_can_reserve_rings(bp) || !bp->rx_nr_rings) in bnxt_rfs_capable()
10463 vnics = 1 + bp->rx_nr_rings; in bnxt_rfs_capable()
10464 max_vnics = bnxt_get_max_func_vnics(bp); in bnxt_rfs_capable()
10465 max_rss_ctxs = bnxt_get_max_func_rss_ctxs(bp); in bnxt_rfs_capable()
10468 if (bp->flags & BNXT_FLAG_NEW_RSS_CAP) in bnxt_rfs_capable()
10471 if (bp->rx_nr_rings > 1) in bnxt_rfs_capable()
10472 netdev_warn(bp->dev, in bnxt_rfs_capable()
10478 if (!BNXT_NEW_RM(bp)) in bnxt_rfs_capable()
10481 if (vnics == bp->hw_resc.resv_vnics) in bnxt_rfs_capable()
10484 bnxt_hwrm_reserve_rings(bp, 0, 0, 0, 0, 0, vnics); in bnxt_rfs_capable()
10485 if (vnics <= bp->hw_resc.resv_vnics) in bnxt_rfs_capable()
10488 netdev_warn(bp->dev, "Unable to reserve resources to support NTUPLE filters.\n"); in bnxt_rfs_capable()
10489 bnxt_hwrm_reserve_rings(bp, 0, 0, 0, 0, 0, 1); in bnxt_rfs_capable()
10499 struct bnxt *bp = netdev_priv(dev); in bnxt_fix_features() local
10502 if ((features & NETIF_F_NTUPLE) && !bnxt_rfs_capable(bp)) in bnxt_fix_features()
10505 if (bp->flags & BNXT_FLAG_NO_AGG_RINGS) in bnxt_fix_features()
10525 if (BNXT_VF(bp) && bp->vf.vlan) in bnxt_fix_features()
10533 struct bnxt *bp = netdev_priv(dev); in bnxt_set_features() local
10534 u32 flags = bp->flags; in bnxt_set_features()
10546 if (bp->flags & BNXT_FLAG_NO_AGG_RINGS) in bnxt_set_features()
10555 changes = flags ^ bp->flags; in bnxt_set_features()
10558 if ((bp->flags & BNXT_FLAG_TPA) == 0 || in bnxt_set_features()
10560 (bp->flags & BNXT_FLAG_CHIP_P5)) in bnxt_set_features()
10567 if (flags != bp->flags) { in bnxt_set_features()
10568 u32 old_flags = bp->flags; in bnxt_set_features()
10570 if (!test_bit(BNXT_STATE_OPEN, &bp->state)) { in bnxt_set_features()
10571 bp->flags = flags; in bnxt_set_features()
10573 bnxt_set_ring_params(bp); in bnxt_set_features()
10578 bnxt_close_nic(bp, false, false); in bnxt_set_features()
10579 bp->flags = flags; in bnxt_set_features()
10581 bnxt_set_ring_params(bp); in bnxt_set_features()
10583 return bnxt_open_nic(bp, false, false); in bnxt_set_features()
10586 bp->flags = flags; in bnxt_set_features()
10587 rc = bnxt_set_tpa(bp, in bnxt_set_features()
10591 bp->flags = old_flags; in bnxt_set_features()
10597 int bnxt_dbg_hwrm_rd_reg(struct bnxt *bp, u32 reg_off, u16 num_words, in bnxt_dbg_hwrm_rd_reg() argument
10600 struct hwrm_dbg_read_direct_output *resp = bp->hwrm_cmd_resp_addr; in bnxt_dbg_hwrm_rd_reg()
10606 dbg_reg_buf = dma_alloc_coherent(&bp->pdev->dev, num_words * 4, in bnxt_dbg_hwrm_rd_reg()
10610 bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_DBG_READ_DIRECT, -1, -1); in bnxt_dbg_hwrm_rd_reg()
10614 mutex_lock(&bp->hwrm_cmd_lock); in bnxt_dbg_hwrm_rd_reg()
10615 rc = _hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT); in bnxt_dbg_hwrm_rd_reg()
10624 mutex_unlock(&bp->hwrm_cmd_lock); in bnxt_dbg_hwrm_rd_reg()
10625 dma_free_coherent(&bp->pdev->dev, num_words * 4, dbg_reg_buf, mapping); in bnxt_dbg_hwrm_rd_reg()
10629 static int bnxt_dbg_hwrm_ring_info_get(struct bnxt *bp, u8 ring_type, in bnxt_dbg_hwrm_ring_info_get() argument
10632 struct hwrm_dbg_ring_info_get_output *resp = bp->hwrm_cmd_resp_addr; in bnxt_dbg_hwrm_ring_info_get()
10636 bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_DBG_RING_INFO_GET, -1, -1); in bnxt_dbg_hwrm_ring_info_get()
10639 mutex_lock(&bp->hwrm_cmd_lock); in bnxt_dbg_hwrm_ring_info_get()
10640 rc = _hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT); in bnxt_dbg_hwrm_ring_info_get()
10645 mutex_unlock(&bp->hwrm_cmd_lock); in bnxt_dbg_hwrm_ring_info_get()
10657 netdev_info(bnapi->bp->dev, "[%d]: tx{fw_ring: %d prod: %x cons: %x}\n", in bnxt_dump_tx_sw_state()
10670 …netdev_info(bnapi->bp->dev, "[%d]: rx{fw_ring: %d prod: %x} rx_agg{fw_ring: %d agg_prod: %x sw_agg… in bnxt_dump_rx_sw_state()
10681 netdev_info(bnapi->bp->dev, "[%d]: cp{fw_ring: %d raw_cons: %x}\n", in bnxt_dump_cp_sw_state()
10685 static void bnxt_dbg_dump_states(struct bnxt *bp) in bnxt_dbg_dump_states() argument
10690 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_dbg_dump_states()
10691 bnapi = bp->bnapi[i]; in bnxt_dbg_dump_states()
10692 if (netif_msg_drv(bp)) { in bnxt_dbg_dump_states()
10700 static int bnxt_hwrm_rx_ring_reset(struct bnxt *bp, int ring_nr) in bnxt_hwrm_rx_ring_reset() argument
10702 struct bnxt_rx_ring_info *rxr = &bp->rx_ring[ring_nr]; in bnxt_hwrm_rx_ring_reset()
10710 bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_RING_RESET, cp_ring_id, -1); in bnxt_hwrm_rx_ring_reset()
10712 req.ring_id = cpu_to_le16(bp->grp_info[bnapi->index].fw_grp_id); in bnxt_hwrm_rx_ring_reset()
10713 return hwrm_send_message_silent(bp, &req, sizeof(req), in bnxt_hwrm_rx_ring_reset()
10717 static void bnxt_reset_task(struct bnxt *bp, bool silent) in bnxt_reset_task() argument
10720 bnxt_dbg_dump_states(bp); in bnxt_reset_task()
10721 if (netif_running(bp->dev)) { in bnxt_reset_task()
10725 bnxt_close_nic(bp, false, false); in bnxt_reset_task()
10726 bnxt_open_nic(bp, false, false); in bnxt_reset_task()
10728 bnxt_ulp_stop(bp); in bnxt_reset_task()
10729 bnxt_close_nic(bp, true, false); in bnxt_reset_task()
10730 rc = bnxt_open_nic(bp, true, false); in bnxt_reset_task()
10731 bnxt_ulp_start(bp, rc); in bnxt_reset_task()
10738 struct bnxt *bp = netdev_priv(dev); in bnxt_tx_timeout() local
10740 netdev_err(bp->dev, "TX timeout detected, starting reset task!\n"); in bnxt_tx_timeout()
10741 set_bit(BNXT_RESET_TASK_SP_EVENT, &bp->sp_event); in bnxt_tx_timeout()
10742 bnxt_queue_sp_work(bp); in bnxt_tx_timeout()
10745 static void bnxt_fw_health_check(struct bnxt *bp) in bnxt_fw_health_check() argument
10747 struct bnxt_fw_health *fw_health = bp->fw_health; in bnxt_fw_health_check()
10750 if (!fw_health->enabled || test_bit(BNXT_STATE_IN_FW_RESET, &bp->state)) in bnxt_fw_health_check()
10760 val = bnxt_fw_health_readl(bp, BNXT_FW_HEARTBEAT_REG); in bnxt_fw_health_check()
10766 val = bnxt_fw_health_readl(bp, BNXT_FW_RESET_CNT_REG); in bnxt_fw_health_check()
10774 set_bit(BNXT_FW_EXCEPTION_SP_EVENT, &bp->sp_event); in bnxt_fw_health_check()
10775 bnxt_queue_sp_work(bp); in bnxt_fw_health_check()
10780 struct bnxt *bp = from_timer(bp, t, timer); in bnxt_timer() local
10781 struct net_device *dev = bp->dev; in bnxt_timer()
10783 if (!netif_running(dev) || !test_bit(BNXT_STATE_OPEN, &bp->state)) in bnxt_timer()
10786 if (atomic_read(&bp->intr_sem) != 0) in bnxt_timer()
10789 if (bp->fw_cap & BNXT_FW_CAP_ERROR_RECOVERY) in bnxt_timer()
10790 bnxt_fw_health_check(bp); in bnxt_timer()
10792 if (bp->link_info.link_up && bp->stats_coal_ticks) { in bnxt_timer()
10793 set_bit(BNXT_PERIODIC_STATS_SP_EVENT, &bp->sp_event); in bnxt_timer()
10794 bnxt_queue_sp_work(bp); in bnxt_timer()
10797 if (bnxt_tc_flower_enabled(bp)) { in bnxt_timer()
10798 set_bit(BNXT_FLOW_STATS_SP_EVENT, &bp->sp_event); in bnxt_timer()
10799 bnxt_queue_sp_work(bp); in bnxt_timer()
10803 if ((bp->flags & BNXT_FLAG_RFS) && bp->ntp_fltr_count) { in bnxt_timer()
10804 set_bit(BNXT_RX_NTP_FLTR_SP_EVENT, &bp->sp_event); in bnxt_timer()
10805 bnxt_queue_sp_work(bp); in bnxt_timer()
10809 if (bp->link_info.phy_retry) { in bnxt_timer()
10810 if (time_after(jiffies, bp->link_info.phy_retry_expires)) { in bnxt_timer()
10811 bp->link_info.phy_retry = false; in bnxt_timer()
10812 netdev_warn(bp->dev, "failed to update phy settings after maximum retries.\n"); in bnxt_timer()
10814 set_bit(BNXT_UPDATE_PHY_SP_EVENT, &bp->sp_event); in bnxt_timer()
10815 bnxt_queue_sp_work(bp); in bnxt_timer()
10819 if ((bp->flags & BNXT_FLAG_CHIP_P5) && !bp->chip_rev && in bnxt_timer()
10821 set_bit(BNXT_RING_COAL_NOW_SP_EVENT, &bp->sp_event); in bnxt_timer()
10822 bnxt_queue_sp_work(bp); in bnxt_timer()
10825 mod_timer(&bp->timer, jiffies + bp->current_interval); in bnxt_timer()
10828 static void bnxt_rtnl_lock_sp(struct bnxt *bp) in bnxt_rtnl_lock_sp() argument
10835 clear_bit(BNXT_STATE_IN_SP_TASK, &bp->state); in bnxt_rtnl_lock_sp()
10839 static void bnxt_rtnl_unlock_sp(struct bnxt *bp) in bnxt_rtnl_unlock_sp() argument
10841 set_bit(BNXT_STATE_IN_SP_TASK, &bp->state); in bnxt_rtnl_unlock_sp()
10846 static void bnxt_reset(struct bnxt *bp, bool silent) in bnxt_reset() argument
10848 bnxt_rtnl_lock_sp(bp); in bnxt_reset()
10849 if (test_bit(BNXT_STATE_OPEN, &bp->state)) in bnxt_reset()
10850 bnxt_reset_task(bp, silent); in bnxt_reset()
10851 bnxt_rtnl_unlock_sp(bp); in bnxt_reset()
10855 static void bnxt_rx_ring_reset(struct bnxt *bp) in bnxt_rx_ring_reset() argument
10859 bnxt_rtnl_lock_sp(bp); in bnxt_rx_ring_reset()
10860 if (!test_bit(BNXT_STATE_OPEN, &bp->state)) { in bnxt_rx_ring_reset()
10861 bnxt_rtnl_unlock_sp(bp); in bnxt_rx_ring_reset()
10865 if (bp->flags & BNXT_FLAG_TPA) in bnxt_rx_ring_reset()
10866 bnxt_set_tpa(bp, false); in bnxt_rx_ring_reset()
10867 for (i = 0; i < bp->rx_nr_rings; i++) { in bnxt_rx_ring_reset()
10868 struct bnxt_rx_ring_info *rxr = &bp->rx_ring[i]; in bnxt_rx_ring_reset()
10875 rc = bnxt_hwrm_rx_ring_reset(bp, i); in bnxt_rx_ring_reset()
10878 …netdev_info_once(bp->dev, "RX ring reset not supported by firmware, falling back to global reset\n… in bnxt_rx_ring_reset()
10880 netdev_warn(bp->dev, "RX ring reset failed, rc = %d, falling back to global reset\n", in bnxt_rx_ring_reset()
10882 bnxt_reset_task(bp, true); in bnxt_rx_ring_reset()
10885 bnxt_free_one_rx_ring_skbs(bp, i); in bnxt_rx_ring_reset()
10891 bnxt_alloc_one_rx_ring(bp, i); in bnxt_rx_ring_reset()
10894 if (bp->flags & BNXT_FLAG_AGG_RINGS) in bnxt_rx_ring_reset()
10895 bnxt_db_write(bp, &rxr->rx_agg_db, rxr->rx_agg_prod); in bnxt_rx_ring_reset()
10896 bnxt_db_write(bp, &rxr->rx_db, rxr->rx_prod); in bnxt_rx_ring_reset()
10898 if (bp->flags & BNXT_FLAG_TPA) in bnxt_rx_ring_reset()
10899 bnxt_set_tpa(bp, true); in bnxt_rx_ring_reset()
10900 bnxt_rtnl_unlock_sp(bp); in bnxt_rx_ring_reset()
10903 static void bnxt_fw_reset_close(struct bnxt *bp) in bnxt_fw_reset_close() argument
10905 bnxt_ulp_stop(bp); in bnxt_fw_reset_close()
10909 if (test_bit(BNXT_STATE_FW_FATAL_COND, &bp->state)) in bnxt_fw_reset_close()
10910 pci_disable_device(bp->pdev); in bnxt_fw_reset_close()
10911 __bnxt_close_nic(bp, true, false); in bnxt_fw_reset_close()
10912 bnxt_clear_int_mode(bp); in bnxt_fw_reset_close()
10913 bnxt_hwrm_func_drv_unrgtr(bp); in bnxt_fw_reset_close()
10914 if (pci_is_enabled(bp->pdev)) in bnxt_fw_reset_close()
10915 pci_disable_device(bp->pdev); in bnxt_fw_reset_close()
10916 bnxt_free_ctx_mem(bp); in bnxt_fw_reset_close()
10917 kfree(bp->ctx); in bnxt_fw_reset_close()
10918 bp->ctx = NULL; in bnxt_fw_reset_close()
10921 static bool is_bnxt_fw_ok(struct bnxt *bp) in is_bnxt_fw_ok() argument
10923 struct bnxt_fw_health *fw_health = bp->fw_health; in is_bnxt_fw_ok()
10927 val = bnxt_fw_health_readl(bp, BNXT_FW_HEARTBEAT_REG); in is_bnxt_fw_ok()
10931 val = bnxt_fw_health_readl(bp, BNXT_FW_RESET_CNT_REG); in is_bnxt_fw_ok()
10942 static void bnxt_force_fw_reset(struct bnxt *bp) in bnxt_force_fw_reset() argument
10944 struct bnxt_fw_health *fw_health = bp->fw_health; in bnxt_force_fw_reset()
10947 if (!test_bit(BNXT_STATE_OPEN, &bp->state) || in bnxt_force_fw_reset()
10948 test_bit(BNXT_STATE_IN_FW_RESET, &bp->state)) in bnxt_force_fw_reset()
10951 set_bit(BNXT_STATE_IN_FW_RESET, &bp->state); in bnxt_force_fw_reset()
10952 bnxt_fw_reset_close(bp); in bnxt_force_fw_reset()
10957 bp->fw_reset_state = BNXT_FW_RESET_STATE_RESET_FW; in bnxt_force_fw_reset()
10959 bp->fw_reset_timestamp = jiffies + wait_dsecs * HZ / 10; in bnxt_force_fw_reset()
10961 bp->fw_reset_state = BNXT_FW_RESET_STATE_ENABLE_DEV; in bnxt_force_fw_reset()
10964 bp->fw_reset_min_dsecs = fw_health->post_reset_wait_dsecs; in bnxt_force_fw_reset()
10965 bp->fw_reset_max_dsecs = fw_health->post_reset_max_wait_dsecs; in bnxt_force_fw_reset()
10966 bnxt_queue_fw_reset_work(bp, wait_dsecs * HZ / 10); in bnxt_force_fw_reset()
10969 void bnxt_fw_exception(struct bnxt *bp) in bnxt_fw_exception() argument
10971 netdev_warn(bp->dev, "Detected firmware fatal condition, initiating reset\n"); in bnxt_fw_exception()
10972 set_bit(BNXT_STATE_FW_FATAL_COND, &bp->state); in bnxt_fw_exception()
10973 bnxt_rtnl_lock_sp(bp); in bnxt_fw_exception()
10974 bnxt_force_fw_reset(bp); in bnxt_fw_exception()
10975 bnxt_rtnl_unlock_sp(bp); in bnxt_fw_exception()
10981 static int bnxt_get_registered_vfs(struct bnxt *bp) in bnxt_get_registered_vfs() argument
10986 if (!BNXT_PF(bp)) in bnxt_get_registered_vfs()
10989 rc = bnxt_hwrm_func_qcfg(bp); in bnxt_get_registered_vfs()
10991 netdev_err(bp->dev, "func_qcfg cmd failed, rc = %d\n", rc); in bnxt_get_registered_vfs()
10994 if (bp->pf.registered_vfs) in bnxt_get_registered_vfs()
10995 return bp->pf.registered_vfs; in bnxt_get_registered_vfs()
10996 if (bp->sriov_cfg) in bnxt_get_registered_vfs()
11002 void bnxt_fw_reset(struct bnxt *bp) in bnxt_fw_reset() argument
11004 bnxt_rtnl_lock_sp(bp); in bnxt_fw_reset()
11005 if (test_bit(BNXT_STATE_OPEN, &bp->state) && in bnxt_fw_reset()
11006 !test_bit(BNXT_STATE_IN_FW_RESET, &bp->state)) { in bnxt_fw_reset()
11009 set_bit(BNXT_STATE_IN_FW_RESET, &bp->state); in bnxt_fw_reset()
11010 if (bp->pf.active_vfs && in bnxt_fw_reset()
11011 !test_bit(BNXT_STATE_FW_FATAL_COND, &bp->state)) in bnxt_fw_reset()
11012 n = bnxt_get_registered_vfs(bp); in bnxt_fw_reset()
11014 netdev_err(bp->dev, "Firmware reset aborted, rc = %d\n", in bnxt_fw_reset()
11016 clear_bit(BNXT_STATE_IN_FW_RESET, &bp->state); in bnxt_fw_reset()
11017 dev_close(bp->dev); in bnxt_fw_reset()
11022 if (bp->fw_reset_max_dsecs < vf_tmo_dsecs) in bnxt_fw_reset()
11023 bp->fw_reset_max_dsecs = vf_tmo_dsecs; in bnxt_fw_reset()
11024 bp->fw_reset_state = in bnxt_fw_reset()
11026 bnxt_queue_fw_reset_work(bp, HZ / 10); in bnxt_fw_reset()
11029 bnxt_fw_reset_close(bp); in bnxt_fw_reset()
11030 if (bp->fw_cap & BNXT_FW_CAP_ERR_RECOVER_RELOAD) { in bnxt_fw_reset()
11031 bp->fw_reset_state = BNXT_FW_RESET_STATE_POLL_FW_DOWN; in bnxt_fw_reset()
11034 bp->fw_reset_state = BNXT_FW_RESET_STATE_ENABLE_DEV; in bnxt_fw_reset()
11035 tmo = bp->fw_reset_min_dsecs * HZ / 10; in bnxt_fw_reset()
11037 bnxt_queue_fw_reset_work(bp, tmo); in bnxt_fw_reset()
11040 bnxt_rtnl_unlock_sp(bp); in bnxt_fw_reset()
11043 static void bnxt_chk_missed_irq(struct bnxt *bp) in bnxt_chk_missed_irq() argument
11047 if (!(bp->flags & BNXT_FLAG_CHIP_P5)) in bnxt_chk_missed_irq()
11050 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_chk_missed_irq()
11051 struct bnxt_napi *bnapi = bp->bnapi[i]; in bnxt_chk_missed_irq()
11065 !bnxt_has_work(bp, cpr2)) in bnxt_chk_missed_irq()
11073 bnxt_dbg_hwrm_ring_info_get(bp, in bnxt_chk_missed_irq()
11083 static void bnxt_init_ethtool_link_settings(struct bnxt *bp) in bnxt_init_ethtool_link_settings() argument
11085 struct bnxt_link_info *link_info = &bp->link_info; in bnxt_init_ethtool_link_settings()
11089 if (bp->hwrm_spec_code >= 0x10201) { in bnxt_init_ethtool_link_settings()
11117 struct bnxt *bp = container_of(work, struct bnxt, sp_task); in bnxt_sp_task() local
11119 set_bit(BNXT_STATE_IN_SP_TASK, &bp->state); in bnxt_sp_task()
11121 if (!test_bit(BNXT_STATE_OPEN, &bp->state)) { in bnxt_sp_task()
11122 clear_bit(BNXT_STATE_IN_SP_TASK, &bp->state); in bnxt_sp_task()
11126 if (test_and_clear_bit(BNXT_RX_MASK_SP_EVENT, &bp->sp_event)) in bnxt_sp_task()
11127 bnxt_cfg_rx_mode(bp); in bnxt_sp_task()
11129 if (test_and_clear_bit(BNXT_RX_NTP_FLTR_SP_EVENT, &bp->sp_event)) in bnxt_sp_task()
11130 bnxt_cfg_ntp_filters(bp); in bnxt_sp_task()
11131 if (test_and_clear_bit(BNXT_HWRM_EXEC_FWD_REQ_SP_EVENT, &bp->sp_event)) in bnxt_sp_task()
11132 bnxt_hwrm_exec_fwd_req(bp); in bnxt_sp_task()
11133 if (test_and_clear_bit(BNXT_PERIODIC_STATS_SP_EVENT, &bp->sp_event)) { in bnxt_sp_task()
11134 bnxt_hwrm_port_qstats(bp, 0); in bnxt_sp_task()
11135 bnxt_hwrm_port_qstats_ext(bp, 0); in bnxt_sp_task()
11136 bnxt_accumulate_all_stats(bp); in bnxt_sp_task()
11139 if (test_and_clear_bit(BNXT_LINK_CHNG_SP_EVENT, &bp->sp_event)) { in bnxt_sp_task()
11142 mutex_lock(&bp->link_lock); in bnxt_sp_task()
11144 &bp->sp_event)) in bnxt_sp_task()
11145 bnxt_hwrm_phy_qcaps(bp); in bnxt_sp_task()
11147 rc = bnxt_update_link(bp, true); in bnxt_sp_task()
11149 netdev_err(bp->dev, "SP task can't update link (rc: %x)\n", in bnxt_sp_task()
11153 &bp->sp_event)) in bnxt_sp_task()
11154 bnxt_init_ethtool_link_settings(bp); in bnxt_sp_task()
11155 mutex_unlock(&bp->link_lock); in bnxt_sp_task()
11157 if (test_and_clear_bit(BNXT_UPDATE_PHY_SP_EVENT, &bp->sp_event)) { in bnxt_sp_task()
11160 mutex_lock(&bp->link_lock); in bnxt_sp_task()
11161 rc = bnxt_update_phy_setting(bp); in bnxt_sp_task()
11162 mutex_unlock(&bp->link_lock); in bnxt_sp_task()
11164 netdev_warn(bp->dev, "update phy settings retry failed\n"); in bnxt_sp_task()
11166 bp->link_info.phy_retry = false; in bnxt_sp_task()
11167 netdev_info(bp->dev, "update phy settings retry succeeded\n"); in bnxt_sp_task()
11170 if (test_and_clear_bit(BNXT_HWRM_PORT_MODULE_SP_EVENT, &bp->sp_event)) { in bnxt_sp_task()
11171 mutex_lock(&bp->link_lock); in bnxt_sp_task()
11172 bnxt_get_port_module_status(bp); in bnxt_sp_task()
11173 mutex_unlock(&bp->link_lock); in bnxt_sp_task()
11176 if (test_and_clear_bit(BNXT_FLOW_STATS_SP_EVENT, &bp->sp_event)) in bnxt_sp_task()
11177 bnxt_tc_flow_stats_work(bp); in bnxt_sp_task()
11179 if (test_and_clear_bit(BNXT_RING_COAL_NOW_SP_EVENT, &bp->sp_event)) in bnxt_sp_task()
11180 bnxt_chk_missed_irq(bp); in bnxt_sp_task()
11185 if (test_and_clear_bit(BNXT_RESET_TASK_SP_EVENT, &bp->sp_event)) in bnxt_sp_task()
11186 bnxt_reset(bp, false); in bnxt_sp_task()
11188 if (test_and_clear_bit(BNXT_RESET_TASK_SILENT_SP_EVENT, &bp->sp_event)) in bnxt_sp_task()
11189 bnxt_reset(bp, true); in bnxt_sp_task()
11191 if (test_and_clear_bit(BNXT_RST_RING_SP_EVENT, &bp->sp_event)) in bnxt_sp_task()
11192 bnxt_rx_ring_reset(bp); in bnxt_sp_task()
11194 if (test_and_clear_bit(BNXT_FW_RESET_NOTIFY_SP_EVENT, &bp->sp_event)) in bnxt_sp_task()
11195 bnxt_devlink_health_report(bp, BNXT_FW_RESET_NOTIFY_SP_EVENT); in bnxt_sp_task()
11197 if (test_and_clear_bit(BNXT_FW_EXCEPTION_SP_EVENT, &bp->sp_event)) { in bnxt_sp_task()
11198 if (!is_bnxt_fw_ok(bp)) in bnxt_sp_task()
11199 bnxt_devlink_health_report(bp, in bnxt_sp_task()
11204 clear_bit(BNXT_STATE_IN_SP_TASK, &bp->state); in bnxt_sp_task()
11208 int bnxt_check_rings(struct bnxt *bp, int tx, int rx, bool sh, int tcs, in bnxt_check_rings() argument
11219 rc = bnxt_get_max_rings(bp, &max_rx, &max_tx, sh); in bnxt_check_rings()
11231 if ((bp->flags & (BNXT_FLAG_RFS | BNXT_FLAG_CHIP_P5)) == BNXT_FLAG_RFS) in bnxt_check_rings()
11234 if (bp->flags & BNXT_FLAG_AGG_RINGS) in bnxt_check_rings()
11238 if (BNXT_NEW_RM(bp)) { in bnxt_check_rings()
11239 cp += bnxt_get_ulp_msix_num(bp); in bnxt_check_rings()
11240 stats += bnxt_get_ulp_stat_ctxs(bp); in bnxt_check_rings()
11242 return bnxt_hwrm_check_rings(bp, tx_rings_needed, rx_rings, rx, cp, in bnxt_check_rings()
11246 static void bnxt_unmap_bars(struct bnxt *bp, struct pci_dev *pdev) in bnxt_unmap_bars() argument
11248 if (bp->bar2) { in bnxt_unmap_bars()
11249 pci_iounmap(pdev, bp->bar2); in bnxt_unmap_bars()
11250 bp->bar2 = NULL; in bnxt_unmap_bars()
11253 if (bp->bar1) { in bnxt_unmap_bars()
11254 pci_iounmap(pdev, bp->bar1); in bnxt_unmap_bars()
11255 bp->bar1 = NULL; in bnxt_unmap_bars()
11258 if (bp->bar0) { in bnxt_unmap_bars()
11259 pci_iounmap(pdev, bp->bar0); in bnxt_unmap_bars()
11260 bp->bar0 = NULL; in bnxt_unmap_bars()
11264 static void bnxt_cleanup_pci(struct bnxt *bp) in bnxt_cleanup_pci() argument
11266 bnxt_unmap_bars(bp, bp->pdev); in bnxt_cleanup_pci()
11267 pci_release_regions(bp->pdev); in bnxt_cleanup_pci()
11268 if (pci_is_enabled(bp->pdev)) in bnxt_cleanup_pci()
11269 pci_disable_device(bp->pdev); in bnxt_cleanup_pci()
11272 static void bnxt_init_dflt_coal(struct bnxt *bp) in bnxt_init_dflt_coal() argument
11279 coal = &bp->rx_coal; in bnxt_init_dflt_coal()
11288 coal = &bp->tx_coal; in bnxt_init_dflt_coal()
11295 bp->stats_coal_ticks = BNXT_DEF_STATS_COAL_TICKS; in bnxt_init_dflt_coal()
11298 static int bnxt_fw_reset_via_optee(struct bnxt *bp) in bnxt_fw_reset_via_optee() argument
11304 netdev_err(bp->dev, "Failed FW reset via OP-TEE, rc=%d\n", rc); in bnxt_fw_reset_via_optee()
11308 netdev_err(bp->dev, "OP-TEE not supported\n"); in bnxt_fw_reset_via_optee()
11313 static int bnxt_fw_init_one_p1(struct bnxt *bp) in bnxt_fw_init_one_p1() argument
11317 bp->fw_cap = 0; in bnxt_fw_init_one_p1()
11318 rc = bnxt_hwrm_ver_get(bp); in bnxt_fw_init_one_p1()
11319 bnxt_try_map_fw_health_reg(bp); in bnxt_fw_init_one_p1()
11321 if (bp->fw_health && bp->fw_health->status_reliable) { in bnxt_fw_init_one_p1()
11322 u32 sts = bnxt_fw_health_readl(bp, BNXT_FW_HEALTH_REG); in bnxt_fw_init_one_p1()
11324 netdev_err(bp->dev, in bnxt_fw_init_one_p1()
11328 netdev_warn(bp->dev, "Firmware recover via OP-TEE requested\n"); in bnxt_fw_init_one_p1()
11329 rc = bnxt_fw_reset_via_optee(bp); in bnxt_fw_init_one_p1()
11331 rc = bnxt_hwrm_ver_get(bp); in bnxt_fw_init_one_p1()
11338 if (bp->fw_cap & BNXT_FW_CAP_KONG_MB_CHNL) { in bnxt_fw_init_one_p1()
11339 rc = bnxt_alloc_kong_hwrm_resources(bp); in bnxt_fw_init_one_p1()
11341 bp->fw_cap &= ~BNXT_FW_CAP_KONG_MB_CHNL; in bnxt_fw_init_one_p1()
11344 if ((bp->fw_cap & BNXT_FW_CAP_SHORT_CMD) || in bnxt_fw_init_one_p1()
11345 bp->hwrm_max_ext_req_len > BNXT_HWRM_MAX_REQ_LEN) { in bnxt_fw_init_one_p1()
11346 rc = bnxt_alloc_hwrm_short_cmd_req(bp); in bnxt_fw_init_one_p1()
11350 bnxt_nvm_cfg_ver_get(bp); in bnxt_fw_init_one_p1()
11352 rc = bnxt_hwrm_func_reset(bp); in bnxt_fw_init_one_p1()
11356 bnxt_hwrm_fw_set_time(bp); in bnxt_fw_init_one_p1()
11360 static int bnxt_fw_init_one_p2(struct bnxt *bp) in bnxt_fw_init_one_p2() argument
11365 rc = bnxt_hwrm_func_qcaps(bp); in bnxt_fw_init_one_p2()
11367 netdev_err(bp->dev, "hwrm query capability failure rc: %x\n", in bnxt_fw_init_one_p2()
11372 rc = bnxt_hwrm_cfa_adv_flow_mgnt_qcaps(bp); in bnxt_fw_init_one_p2()
11374 netdev_warn(bp->dev, "hwrm query adv flow mgnt failure rc: %d\n", in bnxt_fw_init_one_p2()
11377 if (bnxt_alloc_fw_health(bp)) { in bnxt_fw_init_one_p2()
11378 netdev_warn(bp->dev, "no memory for firmware error recovery\n"); in bnxt_fw_init_one_p2()
11380 rc = bnxt_hwrm_error_recovery_qcfg(bp); in bnxt_fw_init_one_p2()
11382 netdev_warn(bp->dev, "hwrm query error recovery failure rc: %d\n", in bnxt_fw_init_one_p2()
11386 rc = bnxt_hwrm_func_drv_rgtr(bp, NULL, 0, false); in bnxt_fw_init_one_p2()
11390 bnxt_hwrm_func_qcfg(bp); in bnxt_fw_init_one_p2()
11391 bnxt_hwrm_vnic_qcaps(bp); in bnxt_fw_init_one_p2()
11392 bnxt_hwrm_port_led_qcaps(bp); in bnxt_fw_init_one_p2()
11393 bnxt_ethtool_init(bp); in bnxt_fw_init_one_p2()
11394 bnxt_dcb_init(bp); in bnxt_fw_init_one_p2()
11398 static void bnxt_set_dflt_rss_hash_type(struct bnxt *bp) in bnxt_set_dflt_rss_hash_type() argument
11400 bp->flags &= ~BNXT_FLAG_UDP_RSS_CAP; in bnxt_set_dflt_rss_hash_type()
11401 bp->rss_hash_cfg = VNIC_RSS_CFG_REQ_HASH_TYPE_IPV4 | in bnxt_set_dflt_rss_hash_type()
11405 if (BNXT_CHIP_P4_PLUS(bp) && bp->hwrm_spec_code >= 0x10501) { in bnxt_set_dflt_rss_hash_type()
11406 bp->flags |= BNXT_FLAG_UDP_RSS_CAP; in bnxt_set_dflt_rss_hash_type()
11407 bp->rss_hash_cfg |= VNIC_RSS_CFG_REQ_HASH_TYPE_UDP_IPV4 | in bnxt_set_dflt_rss_hash_type()
11412 static void bnxt_set_dflt_rfs(struct bnxt *bp) in bnxt_set_dflt_rfs() argument
11414 struct net_device *dev = bp->dev; in bnxt_set_dflt_rfs()
11418 bp->flags &= ~BNXT_FLAG_RFS; in bnxt_set_dflt_rfs()
11419 if (bnxt_rfs_supported(bp)) { in bnxt_set_dflt_rfs()
11421 if (bnxt_rfs_capable(bp)) { in bnxt_set_dflt_rfs()
11422 bp->flags |= BNXT_FLAG_RFS; in bnxt_set_dflt_rfs()
11428 static void bnxt_fw_init_one_p3(struct bnxt *bp) in bnxt_fw_init_one_p3() argument
11430 struct pci_dev *pdev = bp->pdev; in bnxt_fw_init_one_p3()
11432 bnxt_set_dflt_rss_hash_type(bp); in bnxt_fw_init_one_p3()
11433 bnxt_set_dflt_rfs(bp); in bnxt_fw_init_one_p3()
11435 bnxt_get_wol_settings(bp); in bnxt_fw_init_one_p3()
11436 if (bp->flags & BNXT_FLAG_WOL_CAP) in bnxt_fw_init_one_p3()
11437 device_set_wakeup_enable(&pdev->dev, bp->wol); in bnxt_fw_init_one_p3()
11441 bnxt_hwrm_set_cache_line_size(bp, cache_line_size()); in bnxt_fw_init_one_p3()
11442 bnxt_hwrm_coal_params_qcaps(bp); in bnxt_fw_init_one_p3()
11445 static int bnxt_probe_phy(struct bnxt *bp, bool fw_dflt);
11447 static int bnxt_fw_init_one(struct bnxt *bp) in bnxt_fw_init_one() argument
11451 rc = bnxt_fw_init_one_p1(bp); in bnxt_fw_init_one()
11453 netdev_err(bp->dev, "Firmware init phase 1 failed\n"); in bnxt_fw_init_one()
11456 rc = bnxt_fw_init_one_p2(bp); in bnxt_fw_init_one()
11458 netdev_err(bp->dev, "Firmware init phase 2 failed\n"); in bnxt_fw_init_one()
11461 rc = bnxt_probe_phy(bp, false); in bnxt_fw_init_one()
11464 rc = bnxt_approve_mac(bp, bp->dev->dev_addr, false); in bnxt_fw_init_one()
11471 bnxt_dl_fw_reporters_destroy(bp, false); in bnxt_fw_init_one()
11472 bnxt_dl_fw_reporters_create(bp); in bnxt_fw_init_one()
11473 bnxt_fw_init_one_p3(bp); in bnxt_fw_init_one()
11477 static void bnxt_fw_reset_writel(struct bnxt *bp, int reg_idx) in bnxt_fw_reset_writel() argument
11479 struct bnxt_fw_health *fw_health = bp->fw_health; in bnxt_fw_reset_writel()
11489 pci_write_config_dword(bp->pdev, reg_off, val); in bnxt_fw_reset_writel()
11493 bp->bar0 + BNXT_GRCPF_REG_WINDOW_BASE_OUT + 4); in bnxt_fw_reset_writel()
11497 writel(val, bp->bar0 + reg_off); in bnxt_fw_reset_writel()
11500 writel(val, bp->bar1 + reg_off); in bnxt_fw_reset_writel()
11504 pci_read_config_dword(bp->pdev, 0, &val); in bnxt_fw_reset_writel()
11509 static void bnxt_reset_all(struct bnxt *bp) in bnxt_reset_all() argument
11511 struct bnxt_fw_health *fw_health = bp->fw_health; in bnxt_reset_all()
11514 if (bp->fw_cap & BNXT_FW_CAP_ERR_RECOVER_RELOAD) { in bnxt_reset_all()
11515 bnxt_fw_reset_via_optee(bp); in bnxt_reset_all()
11516 bp->fw_reset_timestamp = jiffies; in bnxt_reset_all()
11522 bnxt_fw_reset_writel(bp, i); in bnxt_reset_all()
11526 bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_FW_RESET, -1, -1); in bnxt_reset_all()
11527 req.resp_addr = cpu_to_le64(bp->hwrm_cmd_kong_resp_dma_addr); in bnxt_reset_all()
11531 rc = hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT); in bnxt_reset_all()
11533 netdev_warn(bp->dev, "Unable to reset FW rc=%d\n", rc); in bnxt_reset_all()
11535 bp->fw_reset_timestamp = jiffies; in bnxt_reset_all()
11540 struct bnxt *bp = container_of(work, struct bnxt, fw_reset_task.work); in bnxt_fw_reset_task() local
11543 if (!test_bit(BNXT_STATE_IN_FW_RESET, &bp->state)) { in bnxt_fw_reset_task()
11544 netdev_err(bp->dev, "bnxt_fw_reset_task() called when not in fw reset mode!\n"); in bnxt_fw_reset_task()
11548 switch (bp->fw_reset_state) { in bnxt_fw_reset_task()
11550 int n = bnxt_get_registered_vfs(bp); in bnxt_fw_reset_task()
11554 …netdev_err(bp->dev, "Firmware reset aborted, subsequent func_qcfg cmd failed, rc = %d, %d msecs si… in bnxt_fw_reset_task()
11556 bp->fw_reset_timestamp)); in bnxt_fw_reset_task()
11559 if (time_after(jiffies, bp->fw_reset_timestamp + in bnxt_fw_reset_task()
11560 (bp->fw_reset_max_dsecs * HZ / 10))) { in bnxt_fw_reset_task()
11561 clear_bit(BNXT_STATE_IN_FW_RESET, &bp->state); in bnxt_fw_reset_task()
11562 bp->fw_reset_state = 0; in bnxt_fw_reset_task()
11563 netdev_err(bp->dev, "Firmware reset aborted, bnxt_get_registered_vfs() returns %d\n", in bnxt_fw_reset_task()
11567 bnxt_queue_fw_reset_work(bp, HZ / 10); in bnxt_fw_reset_task()
11570 bp->fw_reset_timestamp = jiffies; in bnxt_fw_reset_task()
11572 if (test_bit(BNXT_STATE_ABORT_ERR, &bp->state)) { in bnxt_fw_reset_task()
11576 bnxt_fw_reset_close(bp); in bnxt_fw_reset_task()
11577 if (bp->fw_cap & BNXT_FW_CAP_ERR_RECOVER_RELOAD) { in bnxt_fw_reset_task()
11578 bp->fw_reset_state = BNXT_FW_RESET_STATE_POLL_FW_DOWN; in bnxt_fw_reset_task()
11581 bp->fw_reset_state = BNXT_FW_RESET_STATE_ENABLE_DEV; in bnxt_fw_reset_task()
11582 tmo = bp->fw_reset_min_dsecs * HZ / 10; in bnxt_fw_reset_task()
11585 bnxt_queue_fw_reset_work(bp, tmo); in bnxt_fw_reset_task()
11591 val = bnxt_fw_health_readl(bp, BNXT_FW_HEALTH_REG); in bnxt_fw_reset_task()
11593 !time_after(jiffies, bp->fw_reset_timestamp + in bnxt_fw_reset_task()
11594 (bp->fw_reset_max_dsecs * HZ / 10))) { in bnxt_fw_reset_task()
11595 bnxt_queue_fw_reset_work(bp, HZ / 5); in bnxt_fw_reset_task()
11599 if (!bp->fw_health->master) { in bnxt_fw_reset_task()
11600 u32 wait_dsecs = bp->fw_health->normal_func_wait_dsecs; in bnxt_fw_reset_task()
11602 bp->fw_reset_state = BNXT_FW_RESET_STATE_ENABLE_DEV; in bnxt_fw_reset_task()
11603 bnxt_queue_fw_reset_work(bp, wait_dsecs * HZ / 10); in bnxt_fw_reset_task()
11606 bp->fw_reset_state = BNXT_FW_RESET_STATE_RESET_FW; in bnxt_fw_reset_task()
11610 bnxt_reset_all(bp); in bnxt_fw_reset_task()
11611 bp->fw_reset_state = BNXT_FW_RESET_STATE_ENABLE_DEV; in bnxt_fw_reset_task()
11612 bnxt_queue_fw_reset_work(bp, bp->fw_reset_min_dsecs * HZ / 10); in bnxt_fw_reset_task()
11615 if (test_bit(BNXT_STATE_FW_FATAL_COND, &bp->state)) { in bnxt_fw_reset_task()
11618 val = bnxt_fw_health_readl(bp, in bnxt_fw_reset_task()
11621 netdev_warn(bp->dev, "FW reset inprog %x after min wait time.\n", in bnxt_fw_reset_task()
11624 clear_bit(BNXT_STATE_FW_FATAL_COND, &bp->state); in bnxt_fw_reset_task()
11625 if (pci_enable_device(bp->pdev)) { in bnxt_fw_reset_task()
11626 netdev_err(bp->dev, "Cannot re-enable PCI device\n"); in bnxt_fw_reset_task()
11629 pci_set_master(bp->pdev); in bnxt_fw_reset_task()
11630 bp->fw_reset_state = BNXT_FW_RESET_STATE_POLL_FW; in bnxt_fw_reset_task()
11633 bp->hwrm_cmd_timeout = SHORT_HWRM_CMD_TIMEOUT; in bnxt_fw_reset_task()
11634 rc = __bnxt_hwrm_ver_get(bp, true); in bnxt_fw_reset_task()
11636 if (time_after(jiffies, bp->fw_reset_timestamp + in bnxt_fw_reset_task()
11637 (bp->fw_reset_max_dsecs * HZ / 10))) { in bnxt_fw_reset_task()
11638 netdev_err(bp->dev, "Firmware reset aborted\n"); in bnxt_fw_reset_task()
11641 bnxt_queue_fw_reset_work(bp, HZ / 5); in bnxt_fw_reset_task()
11644 bp->hwrm_cmd_timeout = DFLT_HWRM_CMD_TIMEOUT; in bnxt_fw_reset_task()
11645 bp->fw_reset_state = BNXT_FW_RESET_STATE_OPENING; in bnxt_fw_reset_task()
11649 bnxt_queue_fw_reset_work(bp, HZ / 10); in bnxt_fw_reset_task()
11652 rc = bnxt_open(bp->dev); in bnxt_fw_reset_task()
11654 netdev_err(bp->dev, "bnxt_open_nic() failed\n"); in bnxt_fw_reset_task()
11655 clear_bit(BNXT_STATE_IN_FW_RESET, &bp->state); in bnxt_fw_reset_task()
11656 dev_close(bp->dev); in bnxt_fw_reset_task()
11659 if ((bp->fw_cap & BNXT_FW_CAP_ERROR_RECOVERY) && in bnxt_fw_reset_task()
11660 bp->fw_health->enabled) { in bnxt_fw_reset_task()
11661 bp->fw_health->last_fw_reset_cnt = in bnxt_fw_reset_task()
11662 bnxt_fw_health_readl(bp, BNXT_FW_RESET_CNT_REG); in bnxt_fw_reset_task()
11664 bp->fw_reset_state = 0; in bnxt_fw_reset_task()
11667 clear_bit(BNXT_STATE_IN_FW_RESET, &bp->state); in bnxt_fw_reset_task()
11668 bnxt_ulp_start(bp, rc); in bnxt_fw_reset_task()
11670 bnxt_reenable_sriov(bp); in bnxt_fw_reset_task()
11671 bnxt_dl_health_recovery_done(bp); in bnxt_fw_reset_task()
11672 bnxt_dl_health_status_update(bp, true); in bnxt_fw_reset_task()
11679 if (bp->fw_health->status_reliable || in bnxt_fw_reset_task()
11680 (bp->fw_cap & BNXT_FW_CAP_ERROR_RECOVERY)) { in bnxt_fw_reset_task()
11681 u32 sts = bnxt_fw_health_readl(bp, BNXT_FW_HEALTH_REG); in bnxt_fw_reset_task()
11683 netdev_err(bp->dev, "fw_health_status 0x%x\n", sts); in bnxt_fw_reset_task()
11686 clear_bit(BNXT_STATE_IN_FW_RESET, &bp->state); in bnxt_fw_reset_task()
11687 if (bp->fw_reset_state != BNXT_FW_RESET_STATE_POLL_VF) in bnxt_fw_reset_task()
11688 bnxt_dl_health_status_update(bp, false); in bnxt_fw_reset_task()
11689 bp->fw_reset_state = 0; in bnxt_fw_reset_task()
11691 dev_close(bp->dev); in bnxt_fw_reset_task()
11698 struct bnxt *bp = netdev_priv(dev); in bnxt_init_board() local
11731 bp->dev = dev; in bnxt_init_board()
11732 bp->pdev = pdev; in bnxt_init_board()
11737 bp->bar0 = pci_ioremap_bar(pdev, 0); in bnxt_init_board()
11738 if (!bp->bar0) { in bnxt_init_board()
11744 bp->bar2 = pci_ioremap_bar(pdev, 4); in bnxt_init_board()
11745 if (!bp->bar2) { in bnxt_init_board()
11753 INIT_WORK(&bp->sp_task, bnxt_sp_task); in bnxt_init_board()
11754 INIT_DELAYED_WORK(&bp->fw_reset_task, bnxt_fw_reset_task); in bnxt_init_board()
11756 spin_lock_init(&bp->ntp_fltr_lock); in bnxt_init_board()
11758 spin_lock_init(&bp->db_lock); in bnxt_init_board()
11761 bp->rx_ring_size = BNXT_DEFAULT_RX_RING_SIZE; in bnxt_init_board()
11762 bp->tx_ring_size = BNXT_DEFAULT_TX_RING_SIZE; in bnxt_init_board()
11764 bnxt_init_dflt_coal(bp); in bnxt_init_board()
11766 timer_setup(&bp->timer, bnxt_timer, 0); in bnxt_init_board()
11767 bp->current_interval = BNXT_TIMER_INTERVAL; in bnxt_init_board()
11769 bp->vxlan_fw_dst_port_id = INVALID_HW_RING_ID; in bnxt_init_board()
11770 bp->nge_fw_dst_port_id = INVALID_HW_RING_ID; in bnxt_init_board()
11772 clear_bit(BNXT_STATE_OPEN, &bp->state); in bnxt_init_board()
11776 bnxt_unmap_bars(bp, pdev); in bnxt_init_board()
11790 struct bnxt *bp = netdev_priv(dev); in bnxt_change_mac_addr() local
11799 rc = bnxt_approve_mac(bp, addr->sa_data, true); in bnxt_change_mac_addr()
11805 bnxt_close_nic(bp, false, false); in bnxt_change_mac_addr()
11806 rc = bnxt_open_nic(bp, false, false); in bnxt_change_mac_addr()
11815 struct bnxt *bp = netdev_priv(dev); in bnxt_change_mtu() local
11818 bnxt_close_nic(bp, true, false); in bnxt_change_mtu()
11821 bnxt_set_ring_params(bp); in bnxt_change_mtu()
11824 return bnxt_open_nic(bp, true, false); in bnxt_change_mtu()
11831 struct bnxt *bp = netdev_priv(dev); in bnxt_setup_mq_tc() local
11835 if (tc > bp->max_tc) { in bnxt_setup_mq_tc()
11837 tc, bp->max_tc); in bnxt_setup_mq_tc()
11844 if (bp->flags & BNXT_FLAG_SHARED_RINGS) in bnxt_setup_mq_tc()
11847 rc = bnxt_check_rings(bp, bp->tx_nr_rings_per_tc, bp->rx_nr_rings, in bnxt_setup_mq_tc()
11848 sh, tc, bp->tx_nr_rings_xdp); in bnxt_setup_mq_tc()
11853 if (netif_running(bp->dev)) in bnxt_setup_mq_tc()
11854 bnxt_close_nic(bp, true, false); in bnxt_setup_mq_tc()
11857 bp->tx_nr_rings = bp->tx_nr_rings_per_tc * tc; in bnxt_setup_mq_tc()
11860 bp->tx_nr_rings = bp->tx_nr_rings_per_tc; in bnxt_setup_mq_tc()
11863 bp->tx_nr_rings += bp->tx_nr_rings_xdp; in bnxt_setup_mq_tc()
11864 bp->cp_nr_rings = sh ? max_t(int, bp->tx_nr_rings, bp->rx_nr_rings) : in bnxt_setup_mq_tc()
11865 bp->tx_nr_rings + bp->rx_nr_rings; in bnxt_setup_mq_tc()
11867 if (netif_running(bp->dev)) in bnxt_setup_mq_tc()
11868 return bnxt_open_nic(bp, true, false); in bnxt_setup_mq_tc()
11876 struct bnxt *bp = cb_priv; in bnxt_setup_tc_block_cb() local
11878 if (!bnxt_tc_flower_enabled(bp) || in bnxt_setup_tc_block_cb()
11879 !tc_cls_can_offload_and_chain0(bp->dev, type_data)) in bnxt_setup_tc_block_cb()
11884 return bnxt_tc_setup_flower(bp, bp->pf.fw_fid, type_data); in bnxt_setup_tc_block_cb()
11895 struct bnxt *bp = netdev_priv(dev); in bnxt_setup_tc() local
11902 bp, bp, true); in bnxt_setup_tc()
11950 struct bnxt *bp = netdev_priv(dev); in bnxt_rx_flow_steer() local
11959 struct bnxt_vnic_info *vnic = &bp->vnic_info[0]; in bnxt_rx_flow_steer()
11992 bp->hwrm_spec_code < 0x10601) { in bnxt_rx_flow_steer()
11998 bp->hwrm_spec_code < 0x10601) || (flags & FLOW_DIS_IS_FRAGMENT)) { in bnxt_rx_flow_steer()
12007 head = &bp->ntp_fltr_hash_tbl[idx]; in bnxt_rx_flow_steer()
12018 spin_lock_bh(&bp->ntp_fltr_lock); in bnxt_rx_flow_steer()
12019 bit_id = bitmap_find_free_region(bp->ntp_fltr_bmap, in bnxt_rx_flow_steer()
12022 spin_unlock_bh(&bp->ntp_fltr_lock); in bnxt_rx_flow_steer()
12032 bp->ntp_fltr_count++; in bnxt_rx_flow_steer()
12033 spin_unlock_bh(&bp->ntp_fltr_lock); in bnxt_rx_flow_steer()
12035 set_bit(BNXT_RX_NTP_FLTR_SP_EVENT, &bp->sp_event); in bnxt_rx_flow_steer()
12036 bnxt_queue_sp_work(bp); in bnxt_rx_flow_steer()
12045 static void bnxt_cfg_ntp_filters(struct bnxt *bp) in bnxt_cfg_ntp_filters() argument
12055 head = &bp->ntp_fltr_hash_tbl[i]; in bnxt_cfg_ntp_filters()
12060 if (rps_may_expire_flow(bp->dev, fltr->rxq, in bnxt_cfg_ntp_filters()
12063 bnxt_hwrm_cfa_ntuple_filter_free(bp, in bnxt_cfg_ntp_filters()
12068 rc = bnxt_hwrm_cfa_ntuple_filter_alloc(bp, in bnxt_cfg_ntp_filters()
12077 spin_lock_bh(&bp->ntp_fltr_lock); in bnxt_cfg_ntp_filters()
12079 bp->ntp_fltr_count--; in bnxt_cfg_ntp_filters()
12080 spin_unlock_bh(&bp->ntp_fltr_lock); in bnxt_cfg_ntp_filters()
12082 clear_bit(fltr->sw_id, bp->ntp_fltr_bmap); in bnxt_cfg_ntp_filters()
12087 if (test_and_clear_bit(BNXT_HWRM_PF_UNLOAD_SP_EVENT, &bp->sp_event)) in bnxt_cfg_ntp_filters()
12088 netdev_info(bp->dev, "Receive PF driver unload event!\n"); in bnxt_cfg_ntp_filters()
12093 static void bnxt_cfg_ntp_filters(struct bnxt *bp) in bnxt_cfg_ntp_filters() argument
12101 struct bnxt *bp = netdev_priv(netdev); in bnxt_udp_tunnel_sync() local
12112 return bnxt_hwrm_tunnel_dst_port_alloc(bp, ti.port, cmd); in bnxt_udp_tunnel_sync()
12114 return bnxt_hwrm_tunnel_dst_port_free(bp, cmd); in bnxt_udp_tunnel_sync()
12131 struct bnxt *bp = netdev_priv(dev); in bnxt_bridge_getlink() local
12133 return ndo_dflt_bridge_getlink(skb, pid, seq, dev, bp->br_mode, 0, 0, in bnxt_bridge_getlink()
12140 struct bnxt *bp = netdev_priv(dev); in bnxt_bridge_setlink() local
12144 if (bp->hwrm_spec_code < 0x10708 || !BNXT_SINGLE_PF(bp)) in bnxt_bridge_setlink()
12161 if (mode == bp->br_mode) in bnxt_bridge_setlink()
12164 rc = bnxt_hwrm_set_br_mode(bp, mode); in bnxt_bridge_setlink()
12166 bp->br_mode = mode; in bnxt_bridge_setlink()
12175 struct bnxt *bp = netdev_priv(dev); in bnxt_get_port_parent_id() local
12177 if (bp->eswitch_mode != DEVLINK_ESWITCH_MODE_SWITCHDEV) in bnxt_get_port_parent_id()
12181 if (!BNXT_PF(bp) || !(bp->flags & BNXT_FLAG_DSN_VALID)) in bnxt_get_port_parent_id()
12184 ppid->id_len = sizeof(bp->dsn); in bnxt_get_port_parent_id()
12185 memcpy(ppid->id, bp->dsn, ppid->id_len); in bnxt_get_port_parent_id()
12192 struct bnxt *bp = netdev_priv(dev); in bnxt_get_devlink_port() local
12194 return &bp->dl_port; in bnxt_get_devlink_port()
12235 struct bnxt *bp = netdev_priv(dev); in bnxt_remove_one() local
12237 if (BNXT_PF(bp)) in bnxt_remove_one()
12238 bnxt_sriov_disable(bp); in bnxt_remove_one()
12240 if (BNXT_PF(bp)) in bnxt_remove_one()
12241 devlink_port_type_clear(&bp->dl_port); in bnxt_remove_one()
12244 clear_bit(BNXT_STATE_IN_FW_RESET, &bp->state); in bnxt_remove_one()
12246 cancel_work_sync(&bp->sp_task); in bnxt_remove_one()
12247 cancel_delayed_work_sync(&bp->fw_reset_task); in bnxt_remove_one()
12248 bp->sp_event = 0; in bnxt_remove_one()
12250 bnxt_dl_fw_reporters_destroy(bp, true); in bnxt_remove_one()
12251 bnxt_dl_unregister(bp); in bnxt_remove_one()
12252 bnxt_shutdown_tc(bp); in bnxt_remove_one()
12254 bnxt_clear_int_mode(bp); in bnxt_remove_one()
12255 bnxt_hwrm_func_drv_unrgtr(bp); in bnxt_remove_one()
12256 bnxt_free_hwrm_resources(bp); in bnxt_remove_one()
12257 bnxt_free_hwrm_short_cmd_req(bp); in bnxt_remove_one()
12258 bnxt_ethtool_free(bp); in bnxt_remove_one()
12259 bnxt_dcb_free(bp); in bnxt_remove_one()
12260 kfree(bp->edev); in bnxt_remove_one()
12261 bp->edev = NULL; in bnxt_remove_one()
12262 kfree(bp->fw_health); in bnxt_remove_one()
12263 bp->fw_health = NULL; in bnxt_remove_one()
12264 bnxt_cleanup_pci(bp); in bnxt_remove_one()
12265 bnxt_free_ctx_mem(bp); in bnxt_remove_one()
12266 kfree(bp->ctx); in bnxt_remove_one()
12267 bp->ctx = NULL; in bnxt_remove_one()
12268 kfree(bp->rss_indir_tbl); in bnxt_remove_one()
12269 bp->rss_indir_tbl = NULL; in bnxt_remove_one()
12270 bnxt_free_port_stats(bp); in bnxt_remove_one()
12274 static int bnxt_probe_phy(struct bnxt *bp, bool fw_dflt) in bnxt_probe_phy() argument
12277 struct bnxt_link_info *link_info = &bp->link_info; in bnxt_probe_phy()
12279 rc = bnxt_hwrm_phy_qcaps(bp); in bnxt_probe_phy()
12281 netdev_err(bp->dev, "Probe phy can't get phy capabilities (rc: %x)\n", in bnxt_probe_phy()
12288 rc = bnxt_update_link(bp, false); in bnxt_probe_phy()
12290 netdev_err(bp->dev, "Probe phy can't update link (rc: %x)\n", in bnxt_probe_phy()
12301 bnxt_init_ethtool_link_settings(bp); in bnxt_probe_phy()
12316 static void _bnxt_get_max_rings(struct bnxt *bp, int *max_rx, int *max_tx, in _bnxt_get_max_rings() argument
12319 struct bnxt_hw_resc *hw_resc = &bp->hw_resc; in _bnxt_get_max_rings()
12324 *max_cp = bnxt_get_max_func_cp_rings_for_en(bp); in _bnxt_get_max_rings()
12325 max_irq = min_t(int, bnxt_get_max_func_irqs(bp) - in _bnxt_get_max_rings()
12326 bnxt_get_ulp_msix_num(bp), in _bnxt_get_max_rings()
12327 hw_resc->max_stat_ctxs - bnxt_get_ulp_stat_ctxs(bp)); in _bnxt_get_max_rings()
12328 if (!(bp->flags & BNXT_FLAG_CHIP_P5)) in _bnxt_get_max_rings()
12331 if (BNXT_CHIP_TYPE_NITRO_A0(bp) && BNXT_PF(bp)) { in _bnxt_get_max_rings()
12335 if (bp->flags & BNXT_FLAG_AGG_RINGS) in _bnxt_get_max_rings()
12337 if (bp->flags & BNXT_FLAG_CHIP_P5) { in _bnxt_get_max_rings()
12338 bnxt_trim_rings(bp, max_rx, max_tx, *max_cp, false); in _bnxt_get_max_rings()
12345 int bnxt_get_max_rings(struct bnxt *bp, int *max_rx, int *max_tx, bool shared) in bnxt_get_max_rings() argument
12349 _bnxt_get_max_rings(bp, &rx, &tx, &cp); in bnxt_get_max_rings()
12355 return bnxt_trim_rings(bp, max_rx, max_tx, cp, shared); in bnxt_get_max_rings()
12358 static int bnxt_get_dflt_rings(struct bnxt *bp, int *max_rx, int *max_tx, in bnxt_get_dflt_rings() argument
12363 rc = bnxt_get_max_rings(bp, max_rx, max_tx, shared); in bnxt_get_dflt_rings()
12364 if (rc && (bp->flags & BNXT_FLAG_AGG_RINGS)) { in bnxt_get_dflt_rings()
12366 bp->flags &= ~BNXT_FLAG_AGG_RINGS; in bnxt_get_dflt_rings()
12367 rc = bnxt_get_max_rings(bp, max_rx, max_tx, shared); in bnxt_get_dflt_rings()
12370 bp->flags |= BNXT_FLAG_AGG_RINGS; in bnxt_get_dflt_rings()
12373 bp->flags |= BNXT_FLAG_NO_AGG_RINGS; in bnxt_get_dflt_rings()
12374 bp->dev->hw_features &= ~(NETIF_F_LRO | NETIF_F_GRO_HW); in bnxt_get_dflt_rings()
12375 bp->dev->features &= ~(NETIF_F_LRO | NETIF_F_GRO_HW); in bnxt_get_dflt_rings()
12376 bnxt_set_ring_params(bp); in bnxt_get_dflt_rings()
12379 if (bp->flags & BNXT_FLAG_ROCE_CAP) { in bnxt_get_dflt_rings()
12383 max_cp = bnxt_get_max_func_cp_rings(bp); in bnxt_get_dflt_rings()
12384 max_stat = bnxt_get_max_func_stat_ctxs(bp); in bnxt_get_dflt_rings()
12385 max_irq = bnxt_get_max_func_irqs(bp); in bnxt_get_dflt_rings()
12396 rc = bnxt_trim_rings(bp, max_rx, max_tx, max_cp, shared); in bnxt_get_dflt_rings()
12406 static void bnxt_trim_dflt_sh_rings(struct bnxt *bp) in bnxt_trim_dflt_sh_rings() argument
12408 bp->cp_nr_rings = min_t(int, bp->tx_nr_rings_per_tc, bp->rx_nr_rings); in bnxt_trim_dflt_sh_rings()
12409 bp->rx_nr_rings = bp->cp_nr_rings; in bnxt_trim_dflt_sh_rings()
12410 bp->tx_nr_rings_per_tc = bp->cp_nr_rings; in bnxt_trim_dflt_sh_rings()
12411 bp->tx_nr_rings = bp->tx_nr_rings_per_tc; in bnxt_trim_dflt_sh_rings()
12414 static int bnxt_set_dflt_rings(struct bnxt *bp, bool sh) in bnxt_set_dflt_rings() argument
12418 if (!bnxt_can_reserve_rings(bp)) in bnxt_set_dflt_rings()
12422 bp->flags |= BNXT_FLAG_SHARED_RINGS; in bnxt_set_dflt_rings()
12427 if (bp->port_count > 1) { in bnxt_set_dflt_rings()
12429 max_t(int, num_online_cpus() / bp->port_count, 1); in bnxt_set_dflt_rings()
12433 rc = bnxt_get_dflt_rings(bp, &max_rx_rings, &max_tx_rings, sh); in bnxt_set_dflt_rings()
12436 bp->rx_nr_rings = min_t(int, dflt_rings, max_rx_rings); in bnxt_set_dflt_rings()
12437 bp->tx_nr_rings_per_tc = min_t(int, dflt_rings, max_tx_rings); in bnxt_set_dflt_rings()
12439 bnxt_trim_dflt_sh_rings(bp); in bnxt_set_dflt_rings()
12441 bp->cp_nr_rings = bp->tx_nr_rings_per_tc + bp->rx_nr_rings; in bnxt_set_dflt_rings()
12442 bp->tx_nr_rings = bp->tx_nr_rings_per_tc; in bnxt_set_dflt_rings()
12444 rc = __bnxt_reserve_rings(bp); in bnxt_set_dflt_rings()
12446 netdev_warn(bp->dev, "Unable to reserve tx rings\n"); in bnxt_set_dflt_rings()
12447 bp->tx_nr_rings_per_tc = bp->tx_nr_rings; in bnxt_set_dflt_rings()
12449 bnxt_trim_dflt_sh_rings(bp); in bnxt_set_dflt_rings()
12452 if (bnxt_need_reserve_rings(bp)) { in bnxt_set_dflt_rings()
12453 rc = __bnxt_reserve_rings(bp); in bnxt_set_dflt_rings()
12455 netdev_warn(bp->dev, "2nd rings reservation failed.\n"); in bnxt_set_dflt_rings()
12456 bp->tx_nr_rings_per_tc = bp->tx_nr_rings; in bnxt_set_dflt_rings()
12458 if (BNXT_CHIP_TYPE_NITRO_A0(bp)) { in bnxt_set_dflt_rings()
12459 bp->rx_nr_rings++; in bnxt_set_dflt_rings()
12460 bp->cp_nr_rings++; in bnxt_set_dflt_rings()
12463 bp->tx_nr_rings = 0; in bnxt_set_dflt_rings()
12464 bp->rx_nr_rings = 0; in bnxt_set_dflt_rings()
12469 static int bnxt_init_dflt_ring_mode(struct bnxt *bp) in bnxt_init_dflt_ring_mode() argument
12473 if (bp->tx_nr_rings) in bnxt_init_dflt_ring_mode()
12476 bnxt_ulp_irq_stop(bp); in bnxt_init_dflt_ring_mode()
12477 bnxt_clear_int_mode(bp); in bnxt_init_dflt_ring_mode()
12478 rc = bnxt_set_dflt_rings(bp, true); in bnxt_init_dflt_ring_mode()
12480 netdev_err(bp->dev, "Not enough rings available.\n"); in bnxt_init_dflt_ring_mode()
12483 rc = bnxt_init_int_mode(bp); in bnxt_init_dflt_ring_mode()
12487 bp->tx_nr_rings_per_tc = bp->tx_nr_rings; in bnxt_init_dflt_ring_mode()
12489 bnxt_set_dflt_rfs(bp); in bnxt_init_dflt_ring_mode()
12492 bnxt_ulp_irq_restart(bp, rc); in bnxt_init_dflt_ring_mode()
12496 int bnxt_restore_pf_fw_resources(struct bnxt *bp) in bnxt_restore_pf_fw_resources() argument
12501 bnxt_hwrm_func_qcaps(bp); in bnxt_restore_pf_fw_resources()
12503 if (netif_running(bp->dev)) in bnxt_restore_pf_fw_resources()
12504 __bnxt_close_nic(bp, true, false); in bnxt_restore_pf_fw_resources()
12506 bnxt_ulp_irq_stop(bp); in bnxt_restore_pf_fw_resources()
12507 bnxt_clear_int_mode(bp); in bnxt_restore_pf_fw_resources()
12508 rc = bnxt_init_int_mode(bp); in bnxt_restore_pf_fw_resources()
12509 bnxt_ulp_irq_restart(bp, rc); in bnxt_restore_pf_fw_resources()
12511 if (netif_running(bp->dev)) { in bnxt_restore_pf_fw_resources()
12513 dev_close(bp->dev); in bnxt_restore_pf_fw_resources()
12515 rc = bnxt_open_nic(bp, true, false); in bnxt_restore_pf_fw_resources()
12521 static int bnxt_init_mac_addr(struct bnxt *bp) in bnxt_init_mac_addr() argument
12525 if (BNXT_PF(bp)) { in bnxt_init_mac_addr()
12526 memcpy(bp->dev->dev_addr, bp->pf.mac_addr, ETH_ALEN); in bnxt_init_mac_addr()
12529 struct bnxt_vf_info *vf = &bp->vf; in bnxt_init_mac_addr()
12534 memcpy(bp->dev->dev_addr, vf->mac_addr, ETH_ALEN); in bnxt_init_mac_addr()
12540 eth_hw_addr_random(bp->dev); in bnxt_init_mac_addr()
12542 rc = bnxt_approve_mac(bp, bp->dev->dev_addr, strict_approval); in bnxt_init_mac_addr()
12549 static void bnxt_vpd_read_info(struct bnxt *bp) in bnxt_vpd_read_info() argument
12551 struct pci_dev *pdev = bp->pdev; in bnxt_vpd_read_info()
12562 netdev_err(bp->dev, "Unable to read VPD\n"); in bnxt_vpd_read_info()
12568 netdev_err(bp->dev, "VPD READ-Only not found\n"); in bnxt_vpd_read_info()
12588 memcpy(bp->board_partno, &vpd_data[pos], size); in bnxt_vpd_read_info()
12602 memcpy(bp->board_serialno, &vpd_data[pos], size); in bnxt_vpd_read_info()
12607 static int bnxt_pcie_dsn_get(struct bnxt *bp, u8 dsn[]) in bnxt_pcie_dsn_get() argument
12609 struct pci_dev *pdev = bp->pdev; in bnxt_pcie_dsn_get()
12614 netdev_info(bp->dev, "Unable to read adapter's DSN\n"); in bnxt_pcie_dsn_get()
12620 bp->flags |= BNXT_FLAG_DSN_VALID; in bnxt_pcie_dsn_get()
12624 static int bnxt_map_db_bar(struct bnxt *bp) in bnxt_map_db_bar() argument
12626 if (!bp->db_size) in bnxt_map_db_bar()
12628 bp->bar1 = pci_iomap(bp->pdev, 2, bp->db_size); in bnxt_map_db_bar()
12629 if (!bp->bar1) in bnxt_map_db_bar()
12637 struct bnxt *bp; in bnxt_init_one() local
12652 dev = alloc_etherdev_mq(sizeof(*bp), max_irqs); in bnxt_init_one()
12656 bp = netdev_priv(dev); in bnxt_init_one()
12657 bp->msg_enable = BNXT_DEF_MSG_ENABLE; in bnxt_init_one()
12658 bnxt_set_max_func_irqs(bp, max_irqs); in bnxt_init_one()
12661 bp->flags |= BNXT_FLAG_VF; in bnxt_init_one()
12664 bp->flags |= BNXT_FLAG_MSIX_CAP; in bnxt_init_one()
12675 if (BNXT_PF(bp)) in bnxt_init_one()
12676 bnxt_vpd_read_info(bp); in bnxt_init_one()
12678 rc = bnxt_alloc_hwrm_resources(bp); in bnxt_init_one()
12682 mutex_init(&bp->hwrm_cmd_lock); in bnxt_init_one()
12683 mutex_init(&bp->link_lock); in bnxt_init_one()
12685 rc = bnxt_fw_init_one_p1(bp); in bnxt_init_one()
12689 if (BNXT_CHIP_P5(bp)) { in bnxt_init_one()
12690 bp->flags |= BNXT_FLAG_CHIP_P5; in bnxt_init_one()
12691 if (BNXT_CHIP_SR2(bp)) in bnxt_init_one()
12692 bp->flags |= BNXT_FLAG_CHIP_SR2; in bnxt_init_one()
12695 rc = bnxt_alloc_rss_indir_tbl(bp); in bnxt_init_one()
12699 rc = bnxt_fw_init_one_p2(bp); in bnxt_init_one()
12703 rc = bnxt_map_db_bar(bp); in bnxt_init_one()
12718 if (BNXT_SUPPORTS_TPA(bp)) in bnxt_init_one()
12732 if (bp->fw_cap & BNXT_FW_CAP_VLAN_RX_STRIP) in bnxt_init_one()
12734 if (bp->fw_cap & BNXT_FW_CAP_VLAN_TX_INSERT) in bnxt_init_one()
12736 if (BNXT_SUPPORTS_TPA(bp)) in bnxt_init_one()
12744 init_waitqueue_head(&bp->sriov_cfg_wait); in bnxt_init_one()
12745 mutex_init(&bp->sriov_lock); in bnxt_init_one()
12747 if (BNXT_SUPPORTS_TPA(bp)) { in bnxt_init_one()
12748 bp->gro_func = bnxt_gro_func_5730x; in bnxt_init_one()
12749 if (BNXT_CHIP_P4(bp)) in bnxt_init_one()
12750 bp->gro_func = bnxt_gro_func_5731x; in bnxt_init_one()
12751 else if (BNXT_CHIP_P5(bp)) in bnxt_init_one()
12752 bp->gro_func = bnxt_gro_func_5750x; in bnxt_init_one()
12754 if (!BNXT_CHIP_P4_PLUS(bp)) in bnxt_init_one()
12755 bp->flags |= BNXT_FLAG_DOUBLE_DB; in bnxt_init_one()
12757 bp->ulp_probe = bnxt_ulp_probe; in bnxt_init_one()
12759 rc = bnxt_init_mac_addr(bp); in bnxt_init_one()
12766 if (BNXT_PF(bp)) { in bnxt_init_one()
12768 rc = bnxt_pcie_dsn_get(bp, bp->dsn); in bnxt_init_one()
12773 dev->max_mtu = bp->max_mtu; in bnxt_init_one()
12775 rc = bnxt_probe_phy(bp, true); in bnxt_init_one()
12779 bnxt_set_rx_skb_mode(bp, false); in bnxt_init_one()
12780 bnxt_set_tpa_flags(bp); in bnxt_init_one()
12781 bnxt_set_ring_params(bp); in bnxt_init_one()
12782 rc = bnxt_set_dflt_rings(bp, true); in bnxt_init_one()
12784 netdev_err(bp->dev, "Not enough rings available.\n"); in bnxt_init_one()
12789 bnxt_fw_init_one_p3(bp); in bnxt_init_one()
12792 bp->flags |= BNXT_FLAG_STRIP_VLAN; in bnxt_init_one()
12794 rc = bnxt_init_int_mode(bp); in bnxt_init_one()
12801 bp->tx_nr_rings_per_tc = bp->tx_nr_rings; in bnxt_init_one()
12803 if (BNXT_PF(bp)) { in bnxt_init_one()
12813 rc = bnxt_init_tc(bp); in bnxt_init_one()
12819 bnxt_dl_register(bp); in bnxt_init_one()
12825 if (BNXT_PF(bp)) in bnxt_init_one()
12826 devlink_port_type_eth_set(&bp->dl_port, bp->dev); in bnxt_init_one()
12827 bnxt_dl_fw_reporters_create(bp); in bnxt_init_one()
12838 bnxt_dl_unregister(bp); in bnxt_init_one()
12839 bnxt_shutdown_tc(bp); in bnxt_init_one()
12840 bnxt_clear_int_mode(bp); in bnxt_init_one()
12843 bnxt_hwrm_func_drv_unrgtr(bp); in bnxt_init_one()
12844 bnxt_free_hwrm_short_cmd_req(bp); in bnxt_init_one()
12845 bnxt_free_hwrm_resources(bp); in bnxt_init_one()
12846 bnxt_ethtool_free(bp); in bnxt_init_one()
12847 kfree(bp->fw_health); in bnxt_init_one()
12848 bp->fw_health = NULL; in bnxt_init_one()
12849 bnxt_cleanup_pci(bp); in bnxt_init_one()
12850 bnxt_free_ctx_mem(bp); in bnxt_init_one()
12851 kfree(bp->ctx); in bnxt_init_one()
12852 bp->ctx = NULL; in bnxt_init_one()
12853 kfree(bp->rss_indir_tbl); in bnxt_init_one()
12854 bp->rss_indir_tbl = NULL; in bnxt_init_one()
12864 struct bnxt *bp; in bnxt_shutdown() local
12870 bp = netdev_priv(dev); in bnxt_shutdown()
12871 if (!bp) in bnxt_shutdown()
12877 bnxt_ulp_shutdown(bp); in bnxt_shutdown()
12878 bnxt_clear_int_mode(bp); in bnxt_shutdown()
12882 pci_wake_from_d3(pdev, bp->wol); in bnxt_shutdown()
12894 struct bnxt *bp = netdev_priv(dev); in bnxt_suspend() local
12898 bnxt_ulp_stop(bp); in bnxt_suspend()
12903 bnxt_hwrm_func_drv_unrgtr(bp); in bnxt_suspend()
12904 pci_disable_device(bp->pdev); in bnxt_suspend()
12905 bnxt_free_ctx_mem(bp); in bnxt_suspend()
12906 kfree(bp->ctx); in bnxt_suspend()
12907 bp->ctx = NULL; in bnxt_suspend()
12915 struct bnxt *bp = netdev_priv(dev); in bnxt_resume() local
12919 rc = pci_enable_device(bp->pdev); in bnxt_resume()
12925 pci_set_master(bp->pdev); in bnxt_resume()
12926 if (bnxt_hwrm_ver_get(bp)) { in bnxt_resume()
12930 rc = bnxt_hwrm_func_reset(bp); in bnxt_resume()
12936 rc = bnxt_hwrm_func_qcaps(bp); in bnxt_resume()
12940 if (bnxt_hwrm_func_drv_rgtr(bp, NULL, 0, false)) { in bnxt_resume()
12945 bnxt_get_wol_settings(bp); in bnxt_resume()
12953 bnxt_ulp_start(bp, rc); in bnxt_resume()
12955 bnxt_reenable_sriov(bp); in bnxt_resume()
12981 struct bnxt *bp = netdev_priv(netdev); in bnxt_io_error_detected() local
12988 bnxt_ulp_stop(bp); in bnxt_io_error_detected()
12996 set_bit(BNXT_STATE_PCI_CHANNEL_IO_FROZEN, &bp->state); in bnxt_io_error_detected()
13003 bnxt_free_ctx_mem(bp); in bnxt_io_error_detected()
13004 kfree(bp->ctx); in bnxt_io_error_detected()
13005 bp->ctx = NULL; in bnxt_io_error_detected()
13025 struct bnxt *bp = netdev_priv(netdev); in bnxt_io_slot_reset() local
13028 netdev_info(bp->dev, "PCI Slot Reset\n"); in bnxt_io_slot_reset()
13046 &bp->state)) { in bnxt_io_slot_reset()
13049 pci_write_config_dword(bp->pdev, off, 0); in bnxt_io_slot_reset()
13054 err = bnxt_hwrm_func_reset(bp); in bnxt_io_slot_reset()
13074 struct bnxt *bp = netdev_priv(netdev); in bnxt_io_resume() local
13077 netdev_info(bp->dev, "PCI Slot Resume\n"); in bnxt_io_resume()
13080 err = bnxt_hwrm_func_qcaps(bp); in bnxt_io_resume()
13084 bnxt_ulp_start(bp, err); in bnxt_io_resume()
13086 bnxt_reenable_sriov(bp); in bnxt_io_resume()