Lines Matching +full:pull +full:- +full:up +full:- +full:adv

1 /* Broadcom NetXtreme-C/E network driver.
3 * Copyright (c) 2014-2016 Broadcom Corporation
4 * Copyright (c) 2016-2019 Broadcom Limited
25 #include <linux/dma-mapping.h>
56 #include <linux/hwmon-sysfs.h>
92 [BCM57301] = { "Broadcom BCM57301 NetXtreme-C 10Gb Ethernet" },
93 [BCM57302] = { "Broadcom BCM57302 NetXtreme-C 10Gb/25Gb Ethernet" },
94 [BCM57304] = { "Broadcom BCM57304 NetXtreme-C 10Gb/25Gb/40Gb/50Gb Ethernet" },
95 [BCM57417_NPAR] = { "Broadcom BCM57417 NetXtreme-E Ethernet Partition" },
97 [BCM57311] = { "Broadcom BCM57311 NetXtreme-C 10Gb Ethernet" },
98 [BCM57312] = { "Broadcom BCM57312 NetXtreme-C 10Gb/25Gb Ethernet" },
99 [BCM57402] = { "Broadcom BCM57402 NetXtreme-E 10Gb Ethernet" },
100 [BCM57404] = { "Broadcom BCM57404 NetXtreme-E 10Gb/25Gb Ethernet" },
101 [BCM57406] = { "Broadcom BCM57406 NetXtreme-E 10GBase-T Ethernet" },
102 [BCM57402_NPAR] = { "Broadcom BCM57402 NetXtreme-E Ethernet Partition" },
103 [BCM57407] = { "Broadcom BCM57407 NetXtreme-E 10GBase-T Ethernet" },
104 [BCM57412] = { "Broadcom BCM57412 NetXtreme-E 10Gb Ethernet" },
105 [BCM57414] = { "Broadcom BCM57414 NetXtreme-E 10Gb/25Gb Ethernet" },
106 [BCM57416] = { "Broadcom BCM57416 NetXtreme-E 10GBase-T Ethernet" },
107 [BCM57417] = { "Broadcom BCM57417 NetXtreme-E 10GBase-T Ethernet" },
108 [BCM57412_NPAR] = { "Broadcom BCM57412 NetXtreme-E Ethernet Partition" },
109 [BCM57314] = { "Broadcom BCM57314 NetXtreme-C 10Gb/25Gb/40Gb/50Gb Ethernet" },
110 [BCM57417_SFP] = { "Broadcom BCM57417 NetXtreme-E 10Gb/25Gb Ethernet" },
111 [BCM57416_SFP] = { "Broadcom BCM57416 NetXtreme-E 10Gb Ethernet" },
112 [BCM57404_NPAR] = { "Broadcom BCM57404 NetXtreme-E Ethernet Partition" },
113 [BCM57406_NPAR] = { "Broadcom BCM57406 NetXtreme-E Ethernet Partition" },
114 [BCM57407_SFP] = { "Broadcom BCM57407 NetXtreme-E 25Gb Ethernet" },
115 [BCM57407_NPAR] = { "Broadcom BCM57407 NetXtreme-E Ethernet Partition" },
116 [BCM57414_NPAR] = { "Broadcom BCM57414 NetXtreme-E Ethernet Partition" },
117 [BCM57416_NPAR] = { "Broadcom BCM57416 NetXtreme-E Ethernet Partition" },
118 [BCM57452] = { "Broadcom BCM57452 NetXtreme-E 10Gb/25Gb/40Gb/50Gb Ethernet" },
119 [BCM57454] = { "Broadcom BCM57454 NetXtreme-E 10Gb/25Gb/40Gb/50Gb/100Gb Ethernet" },
120 [BCM5745x_NPAR] = { "Broadcom BCM5745x NetXtreme-E Ethernet Partition" },
121 [BCM57508] = { "Broadcom BCM57508 NetXtreme-E 10Gb/25Gb/50Gb/100Gb/200Gb Ethernet" },
122 [BCM57504] = { "Broadcom BCM57504 NetXtreme-E 10Gb/25Gb/50Gb/100Gb/200Gb Ethernet" },
123 [BCM57502] = { "Broadcom BCM57502 NetXtreme-E 10Gb/25Gb/50Gb Ethernet" },
124 [BCM57508_NPAR] = { "Broadcom BCM57508 NetXtreme-E Ethernet Partition" },
125 [BCM57504_NPAR] = { "Broadcom BCM57504 NetXtreme-E Ethernet Partition" },
126 [BCM57502_NPAR] = { "Broadcom BCM57502 NetXtreme-E Ethernet Partition" },
127 [BCM58802] = { "Broadcom BCM58802 NetXtreme-S 10Gb/25Gb/40Gb/50Gb Ethernet" },
128 [BCM58804] = { "Broadcom BCM58804 NetXtreme-S 10Gb/25Gb/40Gb/50Gb/100Gb Ethernet" },
129 [BCM58808] = { "Broadcom BCM58808 NetXtreme-S 10Gb/25Gb/40Gb/50Gb/100Gb Ethernet" },
130 [NETXTREME_E_VF] = { "Broadcom NetXtreme-E Ethernet Virtual Function" },
131 [NETXTREME_C_VF] = { "Broadcom NetXtreme-C Ethernet Virtual Function" },
132 [NETXTREME_S_VF] = { "Broadcom NetXtreme-S Ethernet Virtual Function" },
133 [NETXTREME_C_VF_HV] = { "Broadcom NetXtreme-C Virtual Function for Hyper-V" },
134 [NETXTREME_E_VF_HV] = { "Broadcom NetXtreme-E Virtual Function for Hyper-V" },
135 [NETXTREME_E_P5_VF] = { "Broadcom BCM5750X NetXtreme-E Ethernet Virtual Function" },
136 [NETXTREME_E_P5_VF_HV] = { "Broadcom BCM5750X NetXtreme-E Virtual Function for Hyper-V" },
258 writel(DB_CP_FLAGS | RING_CMP(idx), (db)->doorbell)
261 bnxt_writeq(bp, (db)->db_key64 | DBR_TYPE_NQ | RING_CMP(idx), \
262 (db)->doorbell)
265 writel(DB_CP_REARM_FLAGS | RING_CMP(idx), (db)->doorbell)
268 bnxt_writeq(bp, (db)->db_key64 | DBR_TYPE_NQ_ARM | RING_CMP(idx),\
269 (db)->doorbell)
273 if (bp->flags & BNXT_FLAG_CHIP_P5) in bnxt_db_nq()
281 if (bp->flags & BNXT_FLAG_CHIP_P5) in bnxt_db_nq_arm()
289 if (bp->flags & BNXT_FLAG_CHIP_P5) in bnxt_db_cq()
290 bnxt_writeq(bp, db->db_key64 | DBR_TYPE_CQ_ARMALL | in bnxt_db_cq()
291 RING_CMP(idx), db->doorbell); in bnxt_db_cq()
298 if (!(test_bit(BNXT_STATE_IN_FW_RESET, &bp->state))) in bnxt_queue_fw_reset_work()
302 queue_delayed_work(bnxt_pf_wq, &bp->fw_reset_task, delay); in bnxt_queue_fw_reset_work()
304 schedule_delayed_work(&bp->fw_reset_task, delay); in bnxt_queue_fw_reset_work()
310 queue_work(bnxt_pf_wq, &bp->sp_task); in __bnxt_queue_sp_work()
312 schedule_work(&bp->sp_task); in __bnxt_queue_sp_work()
317 set_bit(event, &bp->sp_event); in bnxt_queue_sp_work()
323 if (!rxr->bnapi->in_reset) { in bnxt_sched_reset_rxr()
324 rxr->bnapi->in_reset = true; in bnxt_sched_reset_rxr()
325 if (bp->flags & BNXT_FLAG_CHIP_P5) in bnxt_sched_reset_rxr()
326 set_bit(BNXT_RESET_TASK_SP_EVENT, &bp->sp_event); in bnxt_sched_reset_rxr()
328 set_bit(BNXT_RST_RING_SP_EVENT, &bp->sp_event); in bnxt_sched_reset_rxr()
331 rxr->rx_next_cons = 0xffff; in bnxt_sched_reset_rxr()
337 struct bnxt_napi *bnapi = txr->bnapi; in bnxt_sched_reset_txr()
339 if (bnapi->tx_fault) in bnxt_sched_reset_txr()
342 netdev_err(bp->dev, "Invalid Tx completion (ring:%d tx_pkts:%d cons:%u prod:%u i:%d)", in bnxt_sched_reset_txr()
343 txr->txq_index, bnapi->tx_pkts, in bnxt_sched_reset_txr()
344 txr->tx_cons, txr->tx_prod, idx); in bnxt_sched_reset_txr()
346 bnapi->tx_fault = 1; in bnxt_sched_reset_txr()
376 if (!md_dst || md_dst->type != METADATA_HW_PORT_MUX) in bnxt_xmit_get_cfa_action()
379 return md_dst->u.port_info.port_id; in bnxt_xmit_get_cfa_action()
385 bnxt_db_write(bp, &txr->tx_db, prod); in bnxt_txr_db_kick()
386 txr->kick_pending = 0; in bnxt_txr_db_kick()
400 struct pci_dev *pdev = bp->pdev; in bnxt_start_xmit()
406 if (unlikely(i >= bp->tx_nr_rings)) { in bnxt_start_xmit()
413 txr = &bp->tx_ring[bp->tx_ring_map[i]]; in bnxt_start_xmit()
414 prod = txr->tx_prod; in bnxt_start_xmit()
417 if (unlikely(free_size < skb_shinfo(skb)->nr_frags + 2)) { in bnxt_start_xmit()
419 if (net_ratelimit() && txr->kick_pending) in bnxt_start_xmit()
423 bp->tx_wake_thresh)) in bnxt_start_xmit()
430 length = skb->len; in bnxt_start_xmit()
432 last_frag = skb_shinfo(skb)->nr_frags; in bnxt_start_xmit()
434 txbd = &txr->tx_desc_ring[TX_RING(prod)][TX_IDX(prod)]; in bnxt_start_xmit()
436 txbd->tx_bd_opaque = prod; in bnxt_start_xmit()
438 tx_buf = &txr->tx_buf_ring[prod]; in bnxt_start_xmit()
439 tx_buf->skb = skb; in bnxt_start_xmit()
440 tx_buf->nr_frags = last_frag; in bnxt_start_xmit()
450 if (skb->vlan_proto == htons(ETH_P_8021Q)) in bnxt_start_xmit()
454 if (unlikely(skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP)) { in bnxt_start_xmit()
455 struct bnxt_ptp_cfg *ptp = bp->ptp_cfg; in bnxt_start_xmit()
457 if (ptp && ptp->tx_tstamp_en && !skb_is_gso(skb) && in bnxt_start_xmit()
458 atomic_dec_if_positive(&ptp->tx_avail) >= 0) { in bnxt_start_xmit()
459 if (!bnxt_ptp_parse(skb, &ptp->tx_seqid, in bnxt_start_xmit()
460 &ptp->tx_hdr_off)) { in bnxt_start_xmit()
462 ptp->tx_hdr_off += VLAN_HLEN; in bnxt_start_xmit()
464 skb_shinfo(skb)->tx_flags |= SKBTX_IN_PROGRESS; in bnxt_start_xmit()
466 atomic_inc(&bp->ptp_cfg->tx_avail); in bnxt_start_xmit()
471 if (unlikely(skb->no_fcs)) in bnxt_start_xmit()
474 if (free_size == bp->tx_ring_size && length <= bp->tx_push_thresh && in bnxt_start_xmit()
476 struct tx_push_buffer *tx_push_buf = txr->tx_push; in bnxt_start_xmit()
477 struct tx_push_bd *tx_push = &tx_push_buf->push_bd; in bnxt_start_xmit()
478 struct tx_bd_ext *tx_push1 = &tx_push->txbd2; in bnxt_start_xmit()
479 void __iomem *db = txr->tx_db.doorbell; in bnxt_start_xmit()
480 void *pdata = tx_push_buf->data; in bnxt_start_xmit()
485 tx_push->tx_bd_len_flags_type = in bnxt_start_xmit()
493 if (skb->ip_summed == CHECKSUM_PARTIAL) in bnxt_start_xmit()
494 tx_push1->tx_bd_hsize_lflags = in bnxt_start_xmit()
497 tx_push1->tx_bd_hsize_lflags = 0; in bnxt_start_xmit()
499 tx_push1->tx_bd_cfa_meta = cpu_to_le32(vlan_tag_flags); in bnxt_start_xmit()
500 tx_push1->tx_bd_cfa_action = in bnxt_start_xmit()
504 end = PTR_ALIGN(end, 8) - 1; in bnxt_start_xmit()
510 skb_frag_t *frag = &skb_shinfo(skb)->frags[j]; in bnxt_start_xmit()
521 txbd->tx_bd_len_flags_type = tx_push->tx_bd_len_flags_type; in bnxt_start_xmit()
522 txbd->tx_bd_haddr = txr->data_mapping; in bnxt_start_xmit()
524 txbd = &txr->tx_desc_ring[TX_RING(prod)][TX_IDX(prod)]; in bnxt_start_xmit()
527 tx_push->doorbell = in bnxt_start_xmit()
529 WRITE_ONCE(txr->tx_prod, prod); in bnxt_start_xmit()
531 tx_buf->is_push = 1; in bnxt_start_xmit()
532 netdev_tx_sent_queue(txq, skb->len); in bnxt_start_xmit()
539 (push_len - 16) << 1); in bnxt_start_xmit()
549 pad = BNXT_MIN_PKT_SIZE - length; in bnxt_start_xmit()
556 mapping = dma_map_single(&pdev->dev, skb->data, len, DMA_TO_DEVICE); in bnxt_start_xmit()
558 if (unlikely(dma_mapping_error(&pdev->dev, mapping))) in bnxt_start_xmit()
565 txbd->tx_bd_haddr = cpu_to_le64(mapping); in bnxt_start_xmit()
569 &txr->tx_desc_ring[TX_RING(prod)][TX_IDX(prod)]; in bnxt_start_xmit()
571 txbd1->tx_bd_hsize_lflags = lflags; in bnxt_start_xmit()
575 if (skb->encapsulation) in bnxt_start_xmit()
580 txbd1->tx_bd_hsize_lflags |= cpu_to_le32(TX_BD_FLAGS_LSO | in bnxt_start_xmit()
582 (hdr_len << (TX_BD_HSIZE_SHIFT - 1))); in bnxt_start_xmit()
583 length = skb_shinfo(skb)->gso_size; in bnxt_start_xmit()
584 txbd1->tx_bd_mss = cpu_to_le32(length); in bnxt_start_xmit()
586 } else if (skb->ip_summed == CHECKSUM_PARTIAL) { in bnxt_start_xmit()
587 txbd1->tx_bd_hsize_lflags |= in bnxt_start_xmit()
589 txbd1->tx_bd_mss = 0; in bnxt_start_xmit()
594 dev_warn_ratelimited(&pdev->dev, "Dropped oversize %d bytes TX packet.\n", in bnxt_start_xmit()
595 skb->len); in bnxt_start_xmit()
600 txbd->tx_bd_len_flags_type = cpu_to_le32(flags); in bnxt_start_xmit()
602 txbd1->tx_bd_cfa_meta = cpu_to_le32(vlan_tag_flags); in bnxt_start_xmit()
603 txbd1->tx_bd_cfa_action = in bnxt_start_xmit()
606 skb_frag_t *frag = &skb_shinfo(skb)->frags[i]; in bnxt_start_xmit()
609 txbd = &txr->tx_desc_ring[TX_RING(prod)][TX_IDX(prod)]; in bnxt_start_xmit()
612 mapping = skb_frag_dma_map(&pdev->dev, frag, 0, len, in bnxt_start_xmit()
615 if (unlikely(dma_mapping_error(&pdev->dev, mapping))) in bnxt_start_xmit()
618 tx_buf = &txr->tx_buf_ring[prod]; in bnxt_start_xmit()
621 txbd->tx_bd_haddr = cpu_to_le64(mapping); in bnxt_start_xmit()
624 txbd->tx_bd_len_flags_type = cpu_to_le32(flags); in bnxt_start_xmit()
628 txbd->tx_bd_len_flags_type = in bnxt_start_xmit()
632 netdev_tx_sent_queue(txq, skb->len); in bnxt_start_xmit()
640 WRITE_ONCE(txr->tx_prod, prod); in bnxt_start_xmit()
645 txr->kick_pending = 1; in bnxt_start_xmit()
650 if (netdev_xmit_more() && !tx_buf->is_push) in bnxt_start_xmit()
654 bp->tx_wake_thresh); in bnxt_start_xmit()
662 prod = txr->tx_prod; in bnxt_start_xmit()
663 tx_buf = &txr->tx_buf_ring[prod]; in bnxt_start_xmit()
664 dma_unmap_single(&pdev->dev, dma_unmap_addr(tx_buf, mapping), in bnxt_start_xmit()
671 tx_buf = &txr->tx_buf_ring[prod]; in bnxt_start_xmit()
672 dma_unmap_page(&pdev->dev, dma_unmap_addr(tx_buf, mapping), in bnxt_start_xmit()
673 skb_frag_size(&skb_shinfo(skb)->frags[i]), in bnxt_start_xmit()
681 atomic_inc(&bp->ptp_cfg->tx_avail); in bnxt_start_xmit()
682 if (txr->kick_pending) in bnxt_start_xmit()
683 bnxt_txr_db_kick(bp, txr, txr->tx_prod); in bnxt_start_xmit()
684 txr->tx_buf_ring[txr->tx_prod].skb = NULL; in bnxt_start_xmit()
691 struct bnxt_tx_ring_info *txr = bnapi->tx_ring; in bnxt_tx_int()
692 struct netdev_queue *txq = netdev_get_tx_queue(bp->dev, txr->txq_index); in bnxt_tx_int()
693 u16 cons = txr->tx_cons; in bnxt_tx_int()
694 struct pci_dev *pdev = bp->pdev; in bnxt_tx_int()
695 int nr_pkts = bnapi->tx_pkts; in bnxt_tx_int()
704 tx_buf = &txr->tx_buf_ring[cons]; in bnxt_tx_int()
706 skb = tx_buf->skb; in bnxt_tx_int()
707 tx_buf->skb = NULL; in bnxt_tx_int()
714 tx_bytes += skb->len; in bnxt_tx_int()
716 if (tx_buf->is_push) { in bnxt_tx_int()
717 tx_buf->is_push = 0; in bnxt_tx_int()
721 dma_unmap_single(&pdev->dev, dma_unmap_addr(tx_buf, mapping), in bnxt_tx_int()
723 last = tx_buf->nr_frags; in bnxt_tx_int()
727 tx_buf = &txr->tx_buf_ring[cons]; in bnxt_tx_int()
729 &pdev->dev, in bnxt_tx_int()
731 skb_frag_size(&skb_shinfo(skb)->frags[j]), in bnxt_tx_int()
734 if (unlikely(skb_shinfo(skb)->tx_flags & SKBTX_IN_PROGRESS)) { in bnxt_tx_int()
735 if (bp->flags & BNXT_FLAG_CHIP_P5) { in bnxt_tx_int()
740 atomic_inc(&bp->ptp_cfg->tx_avail); in bnxt_tx_int()
750 bnapi->tx_pkts = 0; in bnxt_tx_int()
751 WRITE_ONCE(txr->tx_cons, cons); in bnxt_tx_int()
754 bnxt_tx_avail(bp, txr), bp->tx_wake_thresh, in bnxt_tx_int()
755 READ_ONCE(txr->dev_state) == BNXT_DEV_STATE_CLOSING); in bnxt_tx_int()
766 page = page_pool_dev_alloc_frag(rxr->page_pool, offset, in __bnxt_alloc_rx_page()
769 page = page_pool_dev_alloc_pages(rxr->page_pool); in __bnxt_alloc_rx_page()
783 struct pci_dev *pdev = bp->pdev; in __bnxt_alloc_rx_frag()
786 data = napi_alloc_frag(bp->rx_buf_size); in __bnxt_alloc_rx_frag()
788 data = netdev_alloc_frag(bp->rx_buf_size); in __bnxt_alloc_rx_frag()
792 *mapping = dma_map_single_attrs(&pdev->dev, data + bp->rx_dma_offset, in __bnxt_alloc_rx_frag()
793 bp->rx_buf_use_size, bp->rx_dir, in __bnxt_alloc_rx_frag()
796 if (dma_mapping_error(&pdev->dev, *mapping)) { in __bnxt_alloc_rx_frag()
806 struct rx_bd *rxbd = &rxr->rx_desc_ring[RX_RING(prod)][RX_IDX(prod)]; in bnxt_alloc_rx_data()
807 struct bnxt_sw_rx_bd *rx_buf = &rxr->rx_buf_ring[prod]; in bnxt_alloc_rx_data()
816 return -ENOMEM; in bnxt_alloc_rx_data()
818 mapping += bp->rx_dma_offset; in bnxt_alloc_rx_data()
819 rx_buf->data = page; in bnxt_alloc_rx_data()
820 rx_buf->data_ptr = page_address(page) + offset + bp->rx_offset; in bnxt_alloc_rx_data()
825 return -ENOMEM; in bnxt_alloc_rx_data()
827 rx_buf->data = data; in bnxt_alloc_rx_data()
828 rx_buf->data_ptr = data + bp->rx_offset; in bnxt_alloc_rx_data()
830 rx_buf->mapping = mapping; in bnxt_alloc_rx_data()
832 rxbd->rx_bd_haddr = cpu_to_le64(mapping); in bnxt_alloc_rx_data()
838 u16 prod = rxr->rx_prod; in bnxt_reuse_rx_data()
842 prod_rx_buf = &rxr->rx_buf_ring[prod]; in bnxt_reuse_rx_data()
843 cons_rx_buf = &rxr->rx_buf_ring[cons]; in bnxt_reuse_rx_data()
845 prod_rx_buf->data = data; in bnxt_reuse_rx_data()
846 prod_rx_buf->data_ptr = cons_rx_buf->data_ptr; in bnxt_reuse_rx_data()
848 prod_rx_buf->mapping = cons_rx_buf->mapping; in bnxt_reuse_rx_data()
850 prod_bd = &rxr->rx_desc_ring[RX_RING(prod)][RX_IDX(prod)]; in bnxt_reuse_rx_data()
851 cons_bd = &rxr->rx_desc_ring[RX_RING(cons)][RX_IDX(cons)]; in bnxt_reuse_rx_data()
853 prod_bd->rx_bd_haddr = cons_bd->rx_bd_haddr; in bnxt_reuse_rx_data()
858 u16 next, max = rxr->rx_agg_bmap_size; in bnxt_find_next_agg_idx()
860 next = find_next_zero_bit(rxr->rx_agg_bmap, max, idx); in bnxt_find_next_agg_idx()
862 next = find_first_zero_bit(rxr->rx_agg_bmap, max); in bnxt_find_next_agg_idx()
871 &rxr->rx_agg_desc_ring[RX_RING(prod)][RX_IDX(prod)]; in bnxt_alloc_rx_page()
875 u16 sw_prod = rxr->rx_sw_agg_prod; in bnxt_alloc_rx_page()
881 return -ENOMEM; in bnxt_alloc_rx_page()
883 if (unlikely(test_bit(sw_prod, rxr->rx_agg_bmap))) in bnxt_alloc_rx_page()
886 __set_bit(sw_prod, rxr->rx_agg_bmap); in bnxt_alloc_rx_page()
887 rx_agg_buf = &rxr->rx_agg_ring[sw_prod]; in bnxt_alloc_rx_page()
888 rxr->rx_sw_agg_prod = NEXT_RX_AGG(sw_prod); in bnxt_alloc_rx_page()
890 rx_agg_buf->page = page; in bnxt_alloc_rx_page()
891 rx_agg_buf->offset = offset; in bnxt_alloc_rx_page()
892 rx_agg_buf->mapping = mapping; in bnxt_alloc_rx_page()
893 rxbd->rx_bd_haddr = cpu_to_le64(mapping); in bnxt_alloc_rx_page()
894 rxbd->rx_bd_opaque = sw_prod; in bnxt_alloc_rx_page()
906 &cpr->cp_desc_ring[CP_RING(cp_cons)][CP_IDX(cp_cons)]; in bnxt_get_agg()
914 struct bnxt_tpa_info *tpa_info = &rxr->rx_tpa[agg_id]; in bnxt_get_tpa_agg_p5()
916 return &tpa_info->agg_arr[curr]; in bnxt_get_tpa_agg_p5()
922 struct bnxt_napi *bnapi = cpr->bnapi; in bnxt_reuse_rx_agg_bufs()
923 struct bnxt *bp = bnapi->bp; in bnxt_reuse_rx_agg_bufs()
924 struct bnxt_rx_ring_info *rxr = bnapi->rx_ring; in bnxt_reuse_rx_agg_bufs()
925 u16 prod = rxr->rx_agg_prod; in bnxt_reuse_rx_agg_bufs()
926 u16 sw_prod = rxr->rx_sw_agg_prod; in bnxt_reuse_rx_agg_bufs()
930 if ((bp->flags & BNXT_FLAG_CHIP_P5) && tpa) in bnxt_reuse_rx_agg_bufs()
944 cons = agg->rx_agg_cmp_opaque; in bnxt_reuse_rx_agg_bufs()
945 __clear_bit(cons, rxr->rx_agg_bmap); in bnxt_reuse_rx_agg_bufs()
947 if (unlikely(test_bit(sw_prod, rxr->rx_agg_bmap))) in bnxt_reuse_rx_agg_bufs()
950 __set_bit(sw_prod, rxr->rx_agg_bmap); in bnxt_reuse_rx_agg_bufs()
951 prod_rx_buf = &rxr->rx_agg_ring[sw_prod]; in bnxt_reuse_rx_agg_bufs()
952 cons_rx_buf = &rxr->rx_agg_ring[cons]; in bnxt_reuse_rx_agg_bufs()
955 * set cons_rx_buf->page to NULL first. in bnxt_reuse_rx_agg_bufs()
957 page = cons_rx_buf->page; in bnxt_reuse_rx_agg_bufs()
958 cons_rx_buf->page = NULL; in bnxt_reuse_rx_agg_bufs()
959 prod_rx_buf->page = page; in bnxt_reuse_rx_agg_bufs()
960 prod_rx_buf->offset = cons_rx_buf->offset; in bnxt_reuse_rx_agg_bufs()
962 prod_rx_buf->mapping = cons_rx_buf->mapping; in bnxt_reuse_rx_agg_bufs()
964 prod_bd = &rxr->rx_agg_desc_ring[RX_RING(prod)][RX_IDX(prod)]; in bnxt_reuse_rx_agg_bufs()
966 prod_bd->rx_bd_haddr = cpu_to_le64(cons_rx_buf->mapping); in bnxt_reuse_rx_agg_bufs()
967 prod_bd->rx_bd_opaque = sw_prod; in bnxt_reuse_rx_agg_bufs()
972 rxr->rx_agg_prod = prod; in bnxt_reuse_rx_agg_bufs()
973 rxr->rx_sw_agg_prod = sw_prod; in bnxt_reuse_rx_agg_bufs()
984 u16 prod = rxr->rx_prod; in bnxt_rx_multi_page_skb()
993 dma_addr -= bp->rx_dma_offset; in bnxt_rx_multi_page_skb()
994 dma_sync_single_for_cpu(&bp->pdev->dev, dma_addr, BNXT_RX_PAGE_SIZE, in bnxt_rx_multi_page_skb()
995 bp->rx_dir); in bnxt_rx_multi_page_skb()
996 skb = napi_build_skb(data_ptr - bp->rx_offset, BNXT_RX_PAGE_SIZE); in bnxt_rx_multi_page_skb()
998 page_pool_recycle_direct(rxr->page_pool, page); in bnxt_rx_multi_page_skb()
1002 skb_reserve(skb, bp->rx_offset); in bnxt_rx_multi_page_skb()
1018 u16 prod = rxr->rx_prod; in bnxt_rx_page_skb()
1027 dma_addr -= bp->rx_dma_offset; in bnxt_rx_page_skb()
1028 dma_sync_single_for_cpu(&bp->pdev->dev, dma_addr, BNXT_RX_PAGE_SIZE, in bnxt_rx_page_skb()
1029 bp->rx_dir); in bnxt_rx_page_skb()
1032 payload = eth_get_headlen(bp->dev, data_ptr, len); in bnxt_rx_page_skb()
1034 skb = napi_alloc_skb(&rxr->bnapi->napi, payload); in bnxt_rx_page_skb()
1036 page_pool_recycle_direct(rxr->page_pool, page); in bnxt_rx_page_skb()
1041 off = (void *)data_ptr - page_address(page); in bnxt_rx_page_skb()
1043 memcpy(skb->data - NET_IP_ALIGN, data_ptr - NET_IP_ALIGN, in bnxt_rx_page_skb()
1046 frag = &skb_shinfo(skb)->frags[0]; in bnxt_rx_page_skb()
1049 skb->data_len -= payload; in bnxt_rx_page_skb()
1050 skb->tail += payload; in bnxt_rx_page_skb()
1061 u16 prod = rxr->rx_prod; in bnxt_rx_skb()
1071 skb = napi_build_skb(data, bp->rx_buf_size); in bnxt_rx_skb()
1072 dma_unmap_single_attrs(&bp->pdev->dev, dma_addr, bp->rx_buf_use_size, in bnxt_rx_skb()
1073 bp->rx_dir, DMA_ATTR_WEAK_ORDERING); in bnxt_rx_skb()
1079 skb_reserve(skb, bp->rx_offset); in bnxt_rx_skb()
1090 struct bnxt_napi *bnapi = cpr->bnapi; in __bnxt_rx_agg_pages()
1091 struct pci_dev *pdev = bp->pdev; in __bnxt_rx_agg_pages()
1092 struct bnxt_rx_ring_info *rxr = bnapi->rx_ring; in __bnxt_rx_agg_pages()
1093 u16 prod = rxr->rx_agg_prod; in __bnxt_rx_agg_pages()
1097 if ((bp->flags & BNXT_FLAG_CHIP_P5) && tpa) in __bnxt_rx_agg_pages()
1101 skb_frag_t *frag = &shinfo->frags[i]; in __bnxt_rx_agg_pages()
1112 cons = agg->rx_agg_cmp_opaque; in __bnxt_rx_agg_pages()
1113 frag_len = (le32_to_cpu(agg->rx_agg_cmp_len_flags_type) & in __bnxt_rx_agg_pages()
1116 cons_rx_buf = &rxr->rx_agg_ring[cons]; in __bnxt_rx_agg_pages()
1117 skb_frag_fill_page_desc(frag, cons_rx_buf->page, in __bnxt_rx_agg_pages()
1118 cons_rx_buf->offset, frag_len); in __bnxt_rx_agg_pages()
1119 shinfo->nr_frags = i + 1; in __bnxt_rx_agg_pages()
1120 __clear_bit(cons, rxr->rx_agg_bmap); in __bnxt_rx_agg_pages()
1126 mapping = cons_rx_buf->mapping; in __bnxt_rx_agg_pages()
1127 page = cons_rx_buf->page; in __bnxt_rx_agg_pages()
1128 cons_rx_buf->page = NULL; in __bnxt_rx_agg_pages()
1134 --shinfo->nr_frags; in __bnxt_rx_agg_pages()
1135 cons_rx_buf->page = page; in __bnxt_rx_agg_pages()
1140 rxr->rx_agg_prod = prod; in __bnxt_rx_agg_pages()
1141 bnxt_reuse_rx_agg_bufs(cpr, idx, i, agg_bufs - i, tpa); in __bnxt_rx_agg_pages()
1145 dma_sync_single_for_cpu(&pdev->dev, mapping, BNXT_RX_PAGE_SIZE, in __bnxt_rx_agg_pages()
1146 bp->rx_dir); in __bnxt_rx_agg_pages()
1151 rxr->rx_agg_prod = prod; in __bnxt_rx_agg_pages()
1171 skb->data_len += total_frag_len; in bnxt_rx_agg_pages_skb()
1172 skb->len += total_frag_len; in bnxt_rx_agg_pages_skb()
1173 skb->truesize += BNXT_RX_PAGE_SIZE * agg_bufs; in bnxt_rx_agg_pages_skb()
1186 shinfo->nr_frags = 0; in bnxt_rx_agg_pages_xdp()
1192 shinfo->nr_frags = agg_bufs; in bnxt_rx_agg_pages_xdp()
1193 shinfo->xdp_frags_size = total_frag_len; in bnxt_rx_agg_pages_xdp()
1207 &cpr->cp_desc_ring[CP_RING(last)][CP_IDX(last)]; in bnxt_agg_bufs_valid()
1215 struct bnxt *bp = bnapi->bp; in bnxt_copy_skb()
1216 struct pci_dev *pdev = bp->pdev; in bnxt_copy_skb()
1219 skb = napi_alloc_skb(&bnapi->napi, len); in bnxt_copy_skb()
1223 dma_sync_single_for_cpu(&pdev->dev, mapping, bp->rx_copy_thresh, in bnxt_copy_skb()
1224 bp->rx_dir); in bnxt_copy_skb()
1226 memcpy(skb->data - NET_IP_ALIGN, data - NET_IP_ALIGN, in bnxt_copy_skb()
1229 dma_sync_single_for_device(&pdev->dev, mapping, bp->rx_copy_thresh, in bnxt_copy_skb()
1230 bp->rx_dir); in bnxt_copy_skb()
1246 agg_bufs = (le32_to_cpu(rxcmp->rx_cmp_misc_v1) & in bnxt_discard_rx()
1252 if (bp->flags & BNXT_FLAG_CHIP_P5) in bnxt_discard_rx()
1260 return -EBUSY; in bnxt_discard_rx()
1268 struct bnxt_tpa_idx_map *map = rxr->rx_tpa_idx_map; in bnxt_alloc_agg_idx()
1271 if (test_bit(idx, map->agg_idx_bmap)) in bnxt_alloc_agg_idx()
1272 idx = find_first_zero_bit(map->agg_idx_bmap, in bnxt_alloc_agg_idx()
1274 __set_bit(idx, map->agg_idx_bmap); in bnxt_alloc_agg_idx()
1275 map->agg_id_tbl[agg_id] = idx; in bnxt_alloc_agg_idx()
1281 struct bnxt_tpa_idx_map *map = rxr->rx_tpa_idx_map; in bnxt_free_agg_idx()
1283 __clear_bit(idx, map->agg_idx_bmap); in bnxt_free_agg_idx()
1288 struct bnxt_tpa_idx_map *map = rxr->rx_tpa_idx_map; in bnxt_lookup_agg_idx()
1290 return map->agg_id_tbl[agg_id]; in bnxt_lookup_agg_idx()
1303 if (bp->flags & BNXT_FLAG_CHIP_P5) { in bnxt_tpa_start()
1309 cons = tpa_start->rx_tpa_start_cmp_opaque; in bnxt_tpa_start()
1310 prod = rxr->rx_prod; in bnxt_tpa_start()
1311 cons_rx_buf = &rxr->rx_buf_ring[cons]; in bnxt_tpa_start()
1312 prod_rx_buf = &rxr->rx_buf_ring[prod]; in bnxt_tpa_start()
1313 tpa_info = &rxr->rx_tpa[agg_id]; in bnxt_tpa_start()
1315 if (unlikely(cons != rxr->rx_next_cons || in bnxt_tpa_start()
1317 netdev_warn(bp->dev, "TPA cons %x, expected cons %x, error code %x\n", in bnxt_tpa_start()
1318 cons, rxr->rx_next_cons, in bnxt_tpa_start()
1326 tpa_info->cfa_code = TPA_START_CFA_CODE(tpa_start1); in bnxt_tpa_start()
1327 prod_rx_buf->data = tpa_info->data; in bnxt_tpa_start()
1328 prod_rx_buf->data_ptr = tpa_info->data_ptr; in bnxt_tpa_start()
1330 mapping = tpa_info->mapping; in bnxt_tpa_start()
1331 prod_rx_buf->mapping = mapping; in bnxt_tpa_start()
1333 prod_bd = &rxr->rx_desc_ring[RX_RING(prod)][RX_IDX(prod)]; in bnxt_tpa_start()
1335 prod_bd->rx_bd_haddr = cpu_to_le64(mapping); in bnxt_tpa_start()
1337 tpa_info->data = cons_rx_buf->data; in bnxt_tpa_start()
1338 tpa_info->data_ptr = cons_rx_buf->data_ptr; in bnxt_tpa_start()
1339 cons_rx_buf->data = NULL; in bnxt_tpa_start()
1340 tpa_info->mapping = cons_rx_buf->mapping; in bnxt_tpa_start()
1342 tpa_info->len = in bnxt_tpa_start()
1343 le32_to_cpu(tpa_start->rx_tpa_start_cmp_len_flags_type) >> in bnxt_tpa_start()
1348 tpa_info->hash_type = PKT_HASH_TYPE_L4; in bnxt_tpa_start()
1349 tpa_info->gso_type = SKB_GSO_TCPV4; in bnxt_tpa_start()
1350 /* RSS profiles 1 and 3 with extract code 0 for inner 4-tuple */ in bnxt_tpa_start()
1352 tpa_info->gso_type = SKB_GSO_TCPV6; in bnxt_tpa_start()
1353 tpa_info->rss_hash = in bnxt_tpa_start()
1354 le32_to_cpu(tpa_start->rx_tpa_start_cmp_rss_hash); in bnxt_tpa_start()
1356 tpa_info->hash_type = PKT_HASH_TYPE_NONE; in bnxt_tpa_start()
1357 tpa_info->gso_type = 0; in bnxt_tpa_start()
1358 netif_warn(bp, rx_err, bp->dev, "TPA packet without valid hash\n"); in bnxt_tpa_start()
1360 tpa_info->flags2 = le32_to_cpu(tpa_start1->rx_tpa_start_cmp_flags2); in bnxt_tpa_start()
1361 tpa_info->metadata = le32_to_cpu(tpa_start1->rx_tpa_start_cmp_metadata); in bnxt_tpa_start()
1362 tpa_info->hdr_info = le32_to_cpu(tpa_start1->rx_tpa_start_cmp_hdr_info); in bnxt_tpa_start()
1363 tpa_info->agg_count = 0; in bnxt_tpa_start()
1365 rxr->rx_prod = NEXT_RX(prod); in bnxt_tpa_start()
1367 rxr->rx_next_cons = NEXT_RX(cons); in bnxt_tpa_start()
1368 cons_rx_buf = &rxr->rx_buf_ring[cons]; in bnxt_tpa_start()
1370 bnxt_reuse_rx_data(rxr, cons, cons_rx_buf->data); in bnxt_tpa_start()
1371 rxr->rx_prod = NEXT_RX(rxr->rx_prod); in bnxt_tpa_start()
1372 cons_rx_buf->data = NULL; in bnxt_tpa_start()
1387 struct iphdr *iph = (struct iphdr *)skb->data; in bnxt_gro_tunnel()
1389 if (iph->protocol == IPPROTO_UDP) in bnxt_gro_tunnel()
1392 struct ipv6hdr *iph = (struct ipv6hdr *)skb->data; in bnxt_gro_tunnel()
1394 if (iph->nexthdr == IPPROTO_UDP) in bnxt_gro_tunnel()
1398 if (uh->check) in bnxt_gro_tunnel()
1399 skb_shinfo(skb)->gso_type |= SKB_GSO_UDP_TUNNEL_CSUM; in bnxt_gro_tunnel()
1401 skb_shinfo(skb)->gso_type |= SKB_GSO_UDP_TUNNEL; in bnxt_gro_tunnel()
1414 u32 hdr_info = tpa_info->hdr_info; in bnxt_gro_func_5731x()
1427 __be16 proto = *((__be16 *)(skb->data + inner_ip_off - in bnxt_gro_func_5731x()
1428 ETH_HLEN - 2)); in bnxt_gro_func_5731x()
1439 inner_ip_off -= 4; in bnxt_gro_func_5731x()
1440 inner_mac_off -= 4; in bnxt_gro_func_5731x()
1441 outer_ip_off -= 4; in bnxt_gro_func_5731x()
1444 nw_off = inner_ip_off - ETH_HLEN; in bnxt_gro_func_5731x()
1446 if (tpa_info->flags2 & RX_TPA_START_CMP_FLAGS2_IP_TYPE) { in bnxt_gro_func_5731x()
1450 len = skb->len - skb_transport_offset(skb); in bnxt_gro_func_5731x()
1452 th->check = ~tcp_v6_check(len, &iph->saddr, &iph->daddr, 0); in bnxt_gro_func_5731x()
1457 len = skb->len - skb_transport_offset(skb); in bnxt_gro_func_5731x()
1459 th->check = ~tcp_v4_check(len, iph->saddr, iph->daddr, 0); in bnxt_gro_func_5731x()
1463 __be16 proto = *((__be16 *)(skb->data + outer_ip_off - in bnxt_gro_func_5731x()
1464 ETH_HLEN - 2)); in bnxt_gro_func_5731x()
1478 u32 hdr_info = tpa_info->hdr_info; in bnxt_gro_func_5750x()
1485 nw_off = inner_ip_off - ETH_HLEN; in bnxt_gro_func_5750x()
1487 iphdr_len = (tpa_info->flags2 & RX_TPA_START_CMP_FLAGS2_IP_TYPE) ? in bnxt_gro_func_5750x()
1492 __be16 proto = *((__be16 *)(skb->data + outer_ip_off - in bnxt_gro_func_5750x()
1493 ETH_HLEN - 2)); in bnxt_gro_func_5750x()
1515 if (tpa_info->gso_type == SKB_GSO_TCPV4) { in bnxt_gro_func_5730x()
1518 nw_off = payload_off - BNXT_IPV4_HDR_SIZE - tcp_opt_len - in bnxt_gro_func_5730x()
1523 len = skb->len - skb_transport_offset(skb); in bnxt_gro_func_5730x()
1525 th->check = ~tcp_v4_check(len, iph->saddr, iph->daddr, 0); in bnxt_gro_func_5730x()
1526 } else if (tpa_info->gso_type == SKB_GSO_TCPV6) { in bnxt_gro_func_5730x()
1529 nw_off = payload_off - BNXT_IPV6_HDR_SIZE - tcp_opt_len - in bnxt_gro_func_5730x()
1534 len = skb->len - skb_transport_offset(skb); in bnxt_gro_func_5730x()
1536 th->check = ~tcp_v6_check(len, &iph->saddr, &iph->daddr, 0); in bnxt_gro_func_5730x()
1543 bnxt_gro_tunnel(skb, skb->protocol); in bnxt_gro_func_5730x()
1562 NAPI_GRO_CB(skb)->count = segs; in bnxt_gro_skb()
1563 skb_shinfo(skb)->gso_size = in bnxt_gro_skb()
1564 le32_to_cpu(tpa_end1->rx_tpa_end_cmp_seg_len); in bnxt_gro_skb()
1565 skb_shinfo(skb)->gso_type = tpa_info->gso_type; in bnxt_gro_skb()
1566 if (bp->flags & BNXT_FLAG_CHIP_P5) in bnxt_gro_skb()
1570 skb = bp->gro_func(tpa_info, payload_off, TPA_END_GRO_TS(tpa_end), skb); in bnxt_gro_skb()
1578 * netdev (vf-rep or PF) the packet is destined to.
1584 /* if vf-rep dev is NULL, the must belongs to the PF */ in bnxt_get_pkt_dev()
1585 return dev ? dev : bp->dev; in bnxt_get_pkt_dev()
1595 struct bnxt_napi *bnapi = cpr->bnapi; in bnxt_tpa_end()
1596 struct bnxt_rx_ring_info *rxr = bnapi->rx_ring; in bnxt_tpa_end()
1606 if (unlikely(bnapi->in_reset)) { in bnxt_tpa_end()
1610 return ERR_PTR(-EBUSY); in bnxt_tpa_end()
1614 if (bp->flags & BNXT_FLAG_CHIP_P5) { in bnxt_tpa_end()
1618 tpa_info = &rxr->rx_tpa[agg_id]; in bnxt_tpa_end()
1619 if (unlikely(agg_bufs != tpa_info->agg_count)) { in bnxt_tpa_end()
1620 netdev_warn(bp->dev, "TPA end agg_buf %d != expected agg_bufs %d\n", in bnxt_tpa_end()
1621 agg_bufs, tpa_info->agg_count); in bnxt_tpa_end()
1622 agg_bufs = tpa_info->agg_count; in bnxt_tpa_end()
1624 tpa_info->agg_count = 0; in bnxt_tpa_end()
1628 gro = !!(bp->flags & BNXT_FLAG_GRO); in bnxt_tpa_end()
1632 tpa_info = &rxr->rx_tpa[agg_id]; in bnxt_tpa_end()
1636 return ERR_PTR(-EBUSY); in bnxt_tpa_end()
1643 data = tpa_info->data; in bnxt_tpa_end()
1644 data_ptr = tpa_info->data_ptr; in bnxt_tpa_end()
1646 len = tpa_info->len; in bnxt_tpa_end()
1647 mapping = tpa_info->mapping; in bnxt_tpa_end()
1652 netdev_warn(bp->dev, "TPA frags %d exceeded MAX_SKB_FRAGS %d\n", in bnxt_tpa_end()
1657 if (len <= bp->rx_copy_thresh) { in bnxt_tpa_end()
1661 cpr->bnapi->cp_ring.sw_stats.rx.rx_oom_discards += 1; in bnxt_tpa_end()
1671 cpr->bnapi->cp_ring.sw_stats.rx.rx_oom_discards += 1; in bnxt_tpa_end()
1675 tpa_info->data = new_data; in bnxt_tpa_end()
1676 tpa_info->data_ptr = new_data + bp->rx_offset; in bnxt_tpa_end()
1677 tpa_info->mapping = new_mapping; in bnxt_tpa_end()
1679 skb = napi_build_skb(data, bp->rx_buf_size); in bnxt_tpa_end()
1680 dma_unmap_single_attrs(&bp->pdev->dev, mapping, in bnxt_tpa_end()
1681 bp->rx_buf_use_size, bp->rx_dir, in bnxt_tpa_end()
1687 cpr->bnapi->cp_ring.sw_stats.rx.rx_oom_discards += 1; in bnxt_tpa_end()
1690 skb_reserve(skb, bp->rx_offset); in bnxt_tpa_end()
1698 cpr->bnapi->cp_ring.sw_stats.rx.rx_oom_discards += 1; in bnxt_tpa_end()
1703 skb->protocol = in bnxt_tpa_end()
1704 eth_type_trans(skb, bnxt_get_pkt_dev(bp, tpa_info->cfa_code)); in bnxt_tpa_end()
1706 if (tpa_info->hash_type != PKT_HASH_TYPE_NONE) in bnxt_tpa_end()
1707 skb_set_hash(skb, tpa_info->rss_hash, tpa_info->hash_type); in bnxt_tpa_end()
1709 if ((tpa_info->flags2 & RX_CMP_FLAGS2_META_FORMAT_VLAN) && in bnxt_tpa_end()
1710 (skb->dev->features & BNXT_HW_FEATURE_VLAN_ALL_RX)) { in bnxt_tpa_end()
1711 __be16 vlan_proto = htons(tpa_info->metadata >> in bnxt_tpa_end()
1713 u16 vtag = tpa_info->metadata & RX_CMP_FLAGS2_METADATA_TCI_MASK; in bnxt_tpa_end()
1724 if (likely(tpa_info->flags2 & RX_TPA_START_CMP_FLAGS2_L4_CS_CALC)) { in bnxt_tpa_end()
1725 skb->ip_summed = CHECKSUM_UNNECESSARY; in bnxt_tpa_end()
1726 skb->csum_level = in bnxt_tpa_end()
1727 (tpa_info->flags2 & RX_CMP_FLAGS2_T_L4_CS_CALC) >> 3; in bnxt_tpa_end()
1743 tpa_info = &rxr->rx_tpa[agg_id]; in bnxt_tpa_agg()
1744 BUG_ON(tpa_info->agg_count >= MAX_SKB_FRAGS); in bnxt_tpa_agg()
1745 tpa_info->agg_arr[tpa_info->agg_count++] = *rx_agg; in bnxt_tpa_agg()
1753 if (skb->dev != bp->dev) { in bnxt_deliver_skb()
1754 /* this packet belongs to a vf-rep */ in bnxt_deliver_skb()
1758 skb_record_rx_queue(skb, bnapi->index); in bnxt_deliver_skb()
1759 napi_gro_receive(&bnapi->napi, skb); in bnxt_deliver_skb()
1765 u32 ts = le32_to_cpu(rxcmp1->rx_cmp_timestamp); in bnxt_rx_ts_valid()
1769 if (!bp->ptp_all_rx_tstamp || !ts || !BNXT_ALL_RX_TS_VALID(flags)) in bnxt_rx_ts_valid()
1778 * 1 - 1 packet successfully received
1779 * 0 - successful TPA_START, packet not completed yet
1780 * -EBUSY - completion ring does not have all the agg buffers yet
1781 * -ENOMEM - packet aborted due to out of memory
1782 * -EIO - packet aborted due to hw error indicated in BD
1787 struct bnxt_napi *bnapi = cpr->bnapi; in bnxt_rx_pkt()
1788 struct bnxt_rx_ring_info *rxr = bnapi->rx_ring; in bnxt_rx_pkt()
1789 struct net_device *dev = bp->dev; in bnxt_rx_pkt()
1807 &cpr->cp_desc_ring[CP_RING(cp_cons)][CP_IDX(cp_cons)]; in bnxt_rx_pkt()
1819 &cpr->cp_desc_ring[CP_RING(cp_cons)][CP_IDX(cp_cons)]; in bnxt_rx_pkt()
1822 return -EBUSY; in bnxt_rx_pkt()
1828 prod = rxr->rx_prod; in bnxt_rx_pkt()
1843 return -EBUSY; in bnxt_rx_pkt()
1845 rc = -ENOMEM; in bnxt_rx_pkt()
1854 cons = rxcmp->rx_cmp_opaque; in bnxt_rx_pkt()
1855 if (unlikely(cons != rxr->rx_next_cons)) { in bnxt_rx_pkt()
1859 if (rxr->rx_next_cons != 0xffff) in bnxt_rx_pkt()
1860 netdev_warn(bp->dev, "RX cons %x != expected cons %x\n", in bnxt_rx_pkt()
1861 cons, rxr->rx_next_cons); in bnxt_rx_pkt()
1867 rx_buf = &rxr->rx_buf_ring[cons]; in bnxt_rx_pkt()
1868 data = rx_buf->data; in bnxt_rx_pkt()
1869 data_ptr = rx_buf->data_ptr; in bnxt_rx_pkt()
1872 misc = le32_to_cpu(rxcmp->rx_cmp_misc_v1); in bnxt_rx_pkt()
1877 return -EBUSY; in bnxt_rx_pkt()
1884 rx_buf->data = NULL; in bnxt_rx_pkt()
1885 if (rxcmp1->rx_cmp_cfa_code_errors_v2 & RX_CMP_L2_ERRORS) { in bnxt_rx_pkt()
1886 u32 rx_err = le32_to_cpu(rxcmp1->rx_cmp_cfa_code_errors_v2); in bnxt_rx_pkt()
1893 rc = -EIO; in bnxt_rx_pkt()
1895 bnapi->cp_ring.sw_stats.rx.rx_buf_errors++; in bnxt_rx_pkt()
1896 if (!(bp->flags & BNXT_FLAG_CHIP_P5) && in bnxt_rx_pkt()
1897 !(bp->fw_cap & BNXT_FW_CAP_RING_MONITOR)) { in bnxt_rx_pkt()
1898 netdev_warn_once(bp->dev, "RX buffer error %x\n", in bnxt_rx_pkt()
1906 flags = le32_to_cpu(rxcmp->rx_cmp_len_flags_type); in bnxt_rx_pkt()
1908 dma_addr = rx_buf->mapping; in bnxt_rx_pkt()
1929 if (len <= bp->rx_copy_thresh) { in bnxt_rx_pkt()
1945 if (rx_buf->data_ptr == data_ptr) in bnxt_rx_pkt()
1949 skb = bp->rx_skb_func(bp, rxr, cons, data, data_ptr, dma_addr, in bnxt_rx_pkt()
1961 skb = bnxt_xdp_build_skb(bp, skb, agg_bufs, rxr->page_pool, &xdp, rxcmp1); in bnxt_rx_pkt()
1974 /* RSS profiles 1 and 3 with extract code 0 for inner 4-tuple */ in bnxt_rx_pkt()
1977 skb_set_hash(skb, le32_to_cpu(rxcmp->rx_cmp_rss_hash), type); in bnxt_rx_pkt()
1981 skb->protocol = eth_type_trans(skb, bnxt_get_pkt_dev(bp, cfa_code)); in bnxt_rx_pkt()
1983 if ((rxcmp1->rx_cmp_flags2 & in bnxt_rx_pkt()
1985 (skb->dev->features & BNXT_HW_FEATURE_VLAN_ALL_RX)) { in bnxt_rx_pkt()
1986 u32 meta_data = le32_to_cpu(rxcmp1->rx_cmp_meta_data); in bnxt_rx_pkt()
2001 if (dev->features & NETIF_F_RXCSUM) { in bnxt_rx_pkt()
2002 skb->ip_summed = CHECKSUM_UNNECESSARY; in bnxt_rx_pkt()
2003 skb->csum_level = RX_CMP_ENCAP(rxcmp1); in bnxt_rx_pkt()
2006 if (rxcmp1->rx_cmp_cfa_code_errors_v2 & RX_CMP_L4_CS_ERR_BITS) { in bnxt_rx_pkt()
2007 if (dev->features & NETIF_F_RXCSUM) in bnxt_rx_pkt()
2008 bnapi->cp_ring.sw_stats.rx.rx_l4_csum_errors++; in bnxt_rx_pkt()
2013 if (bp->flags & BNXT_FLAG_CHIP_P5) { in bnxt_rx_pkt()
2017 struct bnxt_ptp_cfg *ptp = bp->ptp_cfg; in bnxt_rx_pkt()
2019 spin_lock_bh(&ptp->ptp_lock); in bnxt_rx_pkt()
2020 ns = timecounter_cyc2time(&ptp->tc, ts); in bnxt_rx_pkt()
2021 spin_unlock_bh(&ptp->ptp_lock); in bnxt_rx_pkt()
2024 skb_hwtstamps(skb)->hwtstamp = ns_to_ktime(ns); in bnxt_rx_pkt()
2032 cpr->rx_packets += 1; in bnxt_rx_pkt()
2033 cpr->rx_bytes += len; in bnxt_rx_pkt()
2036 rxr->rx_prod = NEXT_RX(prod); in bnxt_rx_pkt()
2037 rxr->rx_next_cons = NEXT_RX(cons); in bnxt_rx_pkt()
2045 cpr->bnapi->cp_ring.sw_stats.rx.rx_oom_discards += 1; in bnxt_rx_pkt()
2046 rc = -ENOMEM; in bnxt_rx_pkt()
2066 &cpr->cp_desc_ring[CP_RING(cp_cons)][CP_IDX(cp_cons)]; in bnxt_force_rx_discard()
2071 &cpr->cp_desc_ring[CP_RING(cp_cons)][CP_IDX(cp_cons)]; in bnxt_force_rx_discard()
2074 return -EBUSY; in bnxt_force_rx_discard()
2082 rxcmp1->rx_cmp_cfa_code_errors_v2 |= in bnxt_force_rx_discard()
2088 tpa_end1->rx_tpa_end_cmp_errors_v2 |= in bnxt_force_rx_discard()
2092 if (rc && rc != -EBUSY) in bnxt_force_rx_discard()
2093 cpr->bnapi->cp_ring.sw_stats.rx.rx_netpoll_discards += 1; in bnxt_force_rx_discard()
2099 struct bnxt_fw_health *fw_health = bp->fw_health; in bnxt_fw_health_readl()
2100 u32 reg = fw_health->regs[reg_idx]; in bnxt_fw_health_readl()
2107 pci_read_config_dword(bp->pdev, reg_off, &val); in bnxt_fw_health_readl()
2110 reg_off = fw_health->mapped_regs[reg_idx]; in bnxt_fw_health_readl()
2113 val = readl(bp->bar0 + reg_off); in bnxt_fw_health_readl()
2116 val = readl(bp->bar1 + reg_off); in bnxt_fw_health_readl()
2120 val &= fw_health->fw_reset_inprog_reg_mask; in bnxt_fw_health_readl()
2128 for (i = 0; i < bp->rx_nr_rings; i++) { in bnxt_agg_ring_id_to_grp_idx()
2129 u16 grp_idx = bp->rx_ring[i].bnapi->index; in bnxt_agg_ring_id_to_grp_idx()
2132 grp_info = &bp->grp_info[grp_idx]; in bnxt_agg_ring_id_to_grp_idx()
2133 if (grp_info->agg_fw_ring_id == ring_id) in bnxt_agg_ring_id_to_grp_idx()
2145 …netdev_err(bp->dev, "1PPS: Received invalid signal on pin%lu from the external source. Please fix … in bnxt_event_error_report()
2149 netdev_warn(bp->dev, "Pause Storm detected!\n"); in bnxt_event_error_report()
2152 netdev_warn(bp->dev, "One or more MMIO doorbells dropped by the device!\n"); in bnxt_event_error_report()
2155 netdev_err(bp->dev, "FW reported unknown error type %u\n", in bnxt_event_error_report()
2186 u16 event_id = le16_to_cpu(cmpl->event_id); in bnxt_async_event_process()
2187 u32 data1 = le32_to_cpu(cmpl->event_data1); in bnxt_async_event_process()
2188 u32 data2 = le32_to_cpu(cmpl->event_data2); in bnxt_async_event_process()
2190 netdev_dbg(bp->dev, "hwrm event 0x%x {0x%x, 0x%x}\n", in bnxt_async_event_process()
2196 struct bnxt_link_info *link_info = &bp->link_info; in bnxt_async_event_process()
2202 if (!(link_info->autoneg & BNXT_AUTONEG_SPEED) && in bnxt_async_event_process()
2204 u16 fw_speed = link_info->force_link_speed; in bnxt_async_event_process()
2208 netdev_warn(bp->dev, "Link speed %d no longer supported\n", in bnxt_async_event_process()
2211 set_bit(BNXT_LINK_SPEED_CHNG_SP_EVENT, &bp->sp_event); in bnxt_async_event_process()
2216 set_bit(BNXT_LINK_CFG_CHANGE_SP_EVENT, &bp->sp_event); in bnxt_async_event_process()
2219 set_bit(BNXT_LINK_CHNG_SP_EVENT, &bp->sp_event); in bnxt_async_event_process()
2222 set_bit(BNXT_HWRM_PF_UNLOAD_SP_EVENT, &bp->sp_event); in bnxt_async_event_process()
2230 if (bp->pf.port_id != port_id) in bnxt_async_event_process()
2233 set_bit(BNXT_HWRM_PORT_MODULE_SP_EVENT, &bp->sp_event); in bnxt_async_event_process()
2239 set_bit(BNXT_RESET_TASK_SILENT_SP_EVENT, &bp->sp_event); in bnxt_async_event_process()
2244 if (!bp->fw_health) in bnxt_async_event_process()
2247 bp->fw_reset_timestamp = jiffies; in bnxt_async_event_process()
2248 bp->fw_reset_min_dsecs = cmpl->timestamp_lo; in bnxt_async_event_process()
2249 if (!bp->fw_reset_min_dsecs) in bnxt_async_event_process()
2250 bp->fw_reset_min_dsecs = BNXT_DFLT_FW_RST_MIN_DSECS; in bnxt_async_event_process()
2251 bp->fw_reset_max_dsecs = le16_to_cpu(cmpl->timestamp_hi); in bnxt_async_event_process()
2252 if (!bp->fw_reset_max_dsecs) in bnxt_async_event_process()
2253 bp->fw_reset_max_dsecs = BNXT_DFLT_FW_RST_MAX_DSECS; in bnxt_async_event_process()
2255 set_bit(BNXT_STATE_FW_ACTIVATE_RESET, &bp->state); in bnxt_async_event_process()
2258 bp->fw_health->fatalities++; in bnxt_async_event_process()
2259 set_bit(BNXT_STATE_FW_FATAL_COND, &bp->state); in bnxt_async_event_process()
2262 type_str = "Non-fatal"; in bnxt_async_event_process()
2263 bp->fw_health->survivals++; in bnxt_async_event_process()
2264 set_bit(BNXT_STATE_FW_NON_FATAL_COND, &bp->state); in bnxt_async_event_process()
2266 netif_warn(bp, hw, bp->dev, in bnxt_async_event_process()
2269 bp->fw_reset_min_dsecs * 100, in bnxt_async_event_process()
2270 bp->fw_reset_max_dsecs * 100); in bnxt_async_event_process()
2271 set_bit(BNXT_FW_RESET_NOTIFY_SP_EVENT, &bp->sp_event); in bnxt_async_event_process()
2275 struct bnxt_fw_health *fw_health = bp->fw_health; in bnxt_async_event_process()
2283 fw_health->enabled = false; in bnxt_async_event_process()
2284 netif_info(bp, drv, bp->dev, "Driver recovery watchdog is disabled\n"); in bnxt_async_event_process()
2287 fw_health->primary = EVENT_DATA1_RECOVERY_MASTER_FUNC(data1); in bnxt_async_event_process()
2288 fw_health->tmr_multiplier = in bnxt_async_event_process()
2289 DIV_ROUND_UP(fw_health->polling_dsecs * HZ, in bnxt_async_event_process()
2290 bp->current_interval * 10); in bnxt_async_event_process()
2291 fw_health->tmr_counter = fw_health->tmr_multiplier; in bnxt_async_event_process()
2292 if (!fw_health->enabled) in bnxt_async_event_process()
2293 fw_health->last_fw_heartbeat = in bnxt_async_event_process()
2295 fw_health->last_fw_reset_cnt = in bnxt_async_event_process()
2300 netif_info(bp, drv, bp->dev, in bnxt_async_event_process()
2302 fw_health->primary ? "primary" : "backup", status, in bnxt_async_event_process()
2303 status_desc, fw_health->last_fw_reset_cnt); in bnxt_async_event_process()
2304 if (!fw_health->enabled) { in bnxt_async_event_process()
2309 fw_health->enabled = true; in bnxt_async_event_process()
2314 netif_notice(bp, hw, bp->dev, in bnxt_async_event_process()
2322 if (bp->flags & BNXT_FLAG_CHIP_P5) in bnxt_async_event_process()
2325 netdev_warn(bp->dev, "Ring monitor event, ring type %lu id 0x%x\n", in bnxt_async_event_process()
2332 netdev_warn(bp->dev, "Unknown RX agg ring id 0x%x\n", in bnxt_async_event_process()
2336 rxr = bp->bnapi[grp_idx]->rx_ring; in bnxt_async_event_process()
2341 struct bnxt_fw_health *fw_health = bp->fw_health; in bnxt_async_event_process()
2343 netif_notice(bp, hw, bp->dev, in bnxt_async_event_process()
2347 fw_health->echo_req_data1 = data1; in bnxt_async_event_process()
2348 fw_health->echo_req_data2 = data2; in bnxt_async_event_process()
2349 set_bit(BNXT_FW_ECHO_REQUEST_SP_EVENT, &bp->sp_event); in bnxt_async_event_process()
2366 struct bnxt_ptp_cfg *ptp = bp->ptp_cfg; in bnxt_async_event_process()
2372 spin_lock_bh(&ptp->ptp_lock); in bnxt_async_event_process()
2375 BNXT_PHC_BITS) | ptp->current_time); in bnxt_async_event_process()
2377 spin_unlock_bh(&ptp->ptp_lock); in bnxt_async_event_process()
2384 u16 seq_id = le32_to_cpu(cmpl->event_data2) & 0xffff; in bnxt_async_event_process()
2406 seq_id = le16_to_cpu(h_cmpl->sequence_id); in bnxt_hwrm_handler()
2411 vf_id = le16_to_cpu(fwd_req_cmpl->source_id); in bnxt_hwrm_handler()
2413 if ((vf_id < bp->pf.first_vf_id) || in bnxt_hwrm_handler()
2414 (vf_id >= bp->pf.first_vf_id + bp->pf.active_vfs)) { in bnxt_hwrm_handler()
2415 netdev_err(bp->dev, "Msg contains invalid VF id %x\n", in bnxt_hwrm_handler()
2417 return -EINVAL; in bnxt_hwrm_handler()
2420 set_bit(vf_id - bp->pf.first_vf_id, bp->pf.vf_event_bmap); in bnxt_hwrm_handler()
2439 struct bnxt *bp = bnapi->bp; in bnxt_msix()
2440 struct bnxt_cp_ring_info *cpr = &bnapi->cp_ring; in bnxt_msix()
2441 u32 cons = RING_CMP(cpr->cp_raw_cons); in bnxt_msix()
2443 cpr->event_ctr++; in bnxt_msix()
2444 prefetch(&cpr->cp_desc_ring[CP_RING(cons)][CP_IDX(cons)]); in bnxt_msix()
2445 napi_schedule(&bnapi->napi); in bnxt_msix()
2451 u32 raw_cons = cpr->cp_raw_cons; in bnxt_has_work()
2455 txcmp = &cpr->cp_desc_ring[CP_RING(cons)][CP_IDX(cons)]; in bnxt_has_work()
2463 struct bnxt *bp = bnapi->bp; in bnxt_inta()
2464 struct bnxt_cp_ring_info *cpr = &bnapi->cp_ring; in bnxt_inta()
2465 u32 cons = RING_CMP(cpr->cp_raw_cons); in bnxt_inta()
2468 prefetch(&cpr->cp_desc_ring[CP_RING(cons)][CP_IDX(cons)]); in bnxt_inta()
2471 int_status = readl(bp->bar0 + BNXT_CAG_REG_LEGACY_INT_STATUS); in bnxt_inta()
2473 if (!(int_status & (0x10000 << cpr->cp_ring_struct.fw_ring_id))) in bnxt_inta()
2478 BNXT_CP_DB_IRQ_DIS(cpr->cp_db.doorbell); in bnxt_inta()
2481 if (unlikely(atomic_read(&bp->intr_sem) != 0)) in bnxt_inta()
2484 napi_schedule(&bnapi->napi); in bnxt_inta()
2491 struct bnxt_napi *bnapi = cpr->bnapi; in __bnxt_poll_work()
2492 u32 raw_cons = cpr->cp_raw_cons; in __bnxt_poll_work()
2499 cpr->has_more_work = 0; in __bnxt_poll_work()
2500 cpr->had_work_done = 1; in __bnxt_poll_work()
2505 txcmp = &cpr->cp_desc_ring[CP_RING(cons)][CP_IDX(cons)]; in __bnxt_poll_work()
2517 if (unlikely(tx_pkts >= bp->tx_wake_thresh)) { in __bnxt_poll_work()
2521 cpr->has_more_work = 1; in __bnxt_poll_work()
2532 /* Increment rx_pkts when rc is -ENOMEM to count towards in __bnxt_poll_work()
2537 else if (rc == -ENOMEM && budget) in __bnxt_poll_work()
2539 else if (rc == -EBUSY) /* partial completion */ in __bnxt_poll_work()
2552 cpr->has_more_work = 1; in __bnxt_poll_work()
2561 struct bnxt_tx_ring_info *txr = bnapi->tx_ring; in __bnxt_poll_work()
2562 u16 prod = txr->tx_prod; in __bnxt_poll_work()
2567 bnxt_db_write_relaxed(bp, &txr->tx_db, prod); in __bnxt_poll_work()
2570 cpr->cp_raw_cons = raw_cons; in __bnxt_poll_work()
2571 bnapi->tx_pkts += tx_pkts; in __bnxt_poll_work()
2572 bnapi->events |= event; in __bnxt_poll_work()
2579 if (bnapi->tx_pkts && !bnapi->tx_fault) in __bnxt_poll_work_done()
2580 bnapi->tx_int(bp, bnapi, budget); in __bnxt_poll_work_done()
2582 if ((bnapi->events & BNXT_RX_EVENT) && !(bnapi->in_reset)) { in __bnxt_poll_work_done()
2583 struct bnxt_rx_ring_info *rxr = bnapi->rx_ring; in __bnxt_poll_work_done()
2585 bnxt_db_write(bp, &rxr->rx_db, rxr->rx_prod); in __bnxt_poll_work_done()
2587 if (bnapi->events & BNXT_AGG_EVENT) { in __bnxt_poll_work_done()
2588 struct bnxt_rx_ring_info *rxr = bnapi->rx_ring; in __bnxt_poll_work_done()
2590 bnxt_db_write(bp, &rxr->rx_agg_db, rxr->rx_agg_prod); in __bnxt_poll_work_done()
2592 bnapi->events = 0; in __bnxt_poll_work_done()
2598 struct bnxt_napi *bnapi = cpr->bnapi; in bnxt_poll_work()
2607 bnxt_db_cq(bp, &cpr->cp_db, cpr->cp_raw_cons); in bnxt_poll_work()
2616 struct bnxt *bp = bnapi->bp; in bnxt_poll_nitroa0()
2617 struct bnxt_cp_ring_info *cpr = &bnapi->cp_ring; in bnxt_poll_nitroa0()
2618 struct bnxt_rx_ring_info *rxr = bnapi->rx_ring; in bnxt_poll_nitroa0()
2622 u32 raw_cons = cpr->cp_raw_cons; in bnxt_poll_nitroa0()
2631 txcmp = &cpr->cp_desc_ring[CP_RING(cp_cons)][CP_IDX(cp_cons)]; in bnxt_poll_nitroa0()
2644 &cpr->cp_desc_ring[CP_RING(cp_cons)][CP_IDX(cp_cons)]; in bnxt_poll_nitroa0()
2650 rxcmp1->rx_cmp_cfa_code_errors_v2 |= in bnxt_poll_nitroa0()
2654 if (likely(rc == -EIO) && budget) in bnxt_poll_nitroa0()
2656 else if (rc == -EBUSY) /* partial completion */ in bnxt_poll_nitroa0()
2664 netdev_err(bp->dev, in bnxt_poll_nitroa0()
2673 cpr->cp_raw_cons = raw_cons; in bnxt_poll_nitroa0()
2674 BNXT_DB_CQ(&cpr->cp_db, cpr->cp_raw_cons); in bnxt_poll_nitroa0()
2675 bnxt_db_write(bp, &rxr->rx_db, rxr->rx_prod); in bnxt_poll_nitroa0()
2678 bnxt_db_write(bp, &rxr->rx_agg_db, rxr->rx_agg_prod); in bnxt_poll_nitroa0()
2684 BNXT_DB_CQ_ARM(&cpr->cp_db, cpr->cp_raw_cons); in bnxt_poll_nitroa0()
2692 struct bnxt *bp = bnapi->bp; in bnxt_poll()
2693 struct bnxt_cp_ring_info *cpr = &bnapi->cp_ring; in bnxt_poll()
2696 if (unlikely(test_bit(BNXT_STATE_FW_FATAL_COND, &bp->state))) { in bnxt_poll()
2701 work_done += bnxt_poll_work(bp, cpr, budget - work_done); in bnxt_poll()
2705 BNXT_DB_CQ_ARM(&cpr->cp_db, cpr->cp_raw_cons); in bnxt_poll()
2711 BNXT_DB_CQ_ARM(&cpr->cp_db, cpr->cp_raw_cons); in bnxt_poll()
2715 if (bp->flags & BNXT_FLAG_DIM) { in bnxt_poll()
2718 dim_update_sample(cpr->event_ctr, in bnxt_poll()
2719 cpr->rx_packets, in bnxt_poll()
2720 cpr->rx_bytes, in bnxt_poll()
2722 net_dim(&cpr->dim, dim_sample); in bnxt_poll()
2729 struct bnxt_cp_ring_info *cpr = &bnapi->cp_ring; in __bnxt_poll_cqs()
2733 struct bnxt_cp_ring_info *cpr2 = cpr->cp_ring_arr[i]; in __bnxt_poll_cqs()
2737 budget - work_done); in __bnxt_poll_cqs()
2738 cpr->has_more_work |= cpr2->has_more_work; in __bnxt_poll_cqs()
2747 struct bnxt_cp_ring_info *cpr = &bnapi->cp_ring; in __bnxt_poll_cqs_done()
2751 struct bnxt_cp_ring_info *cpr2 = cpr->cp_ring_arr[i]; in __bnxt_poll_cqs_done()
2754 if (cpr2 && cpr2->had_work_done) { in __bnxt_poll_cqs_done()
2755 db = &cpr2->cp_db; in __bnxt_poll_cqs_done()
2756 bnxt_writeq(bp, db->db_key64 | dbr_type | in __bnxt_poll_cqs_done()
2757 RING_CMP(cpr2->cp_raw_cons), db->doorbell); in __bnxt_poll_cqs_done()
2758 cpr2->had_work_done = 0; in __bnxt_poll_cqs_done()
2767 struct bnxt_cp_ring_info *cpr = &bnapi->cp_ring; in bnxt_poll_p5()
2769 u32 raw_cons = cpr->cp_raw_cons; in bnxt_poll_p5()
2770 struct bnxt *bp = bnapi->bp; in bnxt_poll_p5()
2775 if (unlikely(test_bit(BNXT_STATE_FW_FATAL_COND, &bp->state))) { in bnxt_poll_p5()
2779 if (cpr->has_more_work) { in bnxt_poll_p5()
2780 cpr->has_more_work = 0; in bnxt_poll_p5()
2785 nqcmp = &cpr->nq_desc_ring[CP_RING(cons)][CP_IDX(cons)]; in bnxt_poll_p5()
2788 if (cpr->has_more_work) in bnxt_poll_p5()
2793 cpr->cp_raw_cons = raw_cons; in bnxt_poll_p5()
2795 BNXT_DB_NQ_ARM_P5(&cpr->cp_db, in bnxt_poll_p5()
2796 cpr->cp_raw_cons); in bnxt_poll_p5()
2805 if (nqcmp->type == cpu_to_le16(NQ_CN_TYPE_CQ_NOTIFICATION)) { in bnxt_poll_p5()
2806 u32 idx = le32_to_cpu(nqcmp->cq_handle_low); in bnxt_poll_p5()
2813 cpr2 = cpr->cp_ring_arr[idx]; in bnxt_poll_p5()
2815 budget - work_done); in bnxt_poll_p5()
2816 cpr->has_more_work |= cpr2->has_more_work; in bnxt_poll_p5()
2823 if (raw_cons != cpr->cp_raw_cons) { in bnxt_poll_p5()
2824 cpr->cp_raw_cons = raw_cons; in bnxt_poll_p5()
2825 BNXT_DB_NQ_P5(&cpr->cp_db, raw_cons); in bnxt_poll_p5()
2828 cpr_rx = cpr->cp_ring_arr[BNXT_RX_HDL]; in bnxt_poll_p5()
2829 if (cpr_rx && (bp->flags & BNXT_FLAG_DIM)) { in bnxt_poll_p5()
2832 dim_update_sample(cpr->event_ctr, in bnxt_poll_p5()
2833 cpr_rx->rx_packets, in bnxt_poll_p5()
2834 cpr_rx->rx_bytes, in bnxt_poll_p5()
2836 net_dim(&cpr->dim, dim_sample); in bnxt_poll_p5()
2844 struct pci_dev *pdev = bp->pdev; in bnxt_free_tx_skbs()
2846 if (!bp->tx_ring) in bnxt_free_tx_skbs()
2849 max_idx = bp->tx_nr_pages * TX_DESC_CNT; in bnxt_free_tx_skbs()
2850 for (i = 0; i < bp->tx_nr_rings; i++) { in bnxt_free_tx_skbs()
2851 struct bnxt_tx_ring_info *txr = &bp->tx_ring[i]; in bnxt_free_tx_skbs()
2854 if (!txr->tx_buf_ring) in bnxt_free_tx_skbs()
2858 struct bnxt_sw_tx_bd *tx_buf = &txr->tx_buf_ring[j]; in bnxt_free_tx_skbs()
2862 if (i < bp->tx_nr_rings_xdp && in bnxt_free_tx_skbs()
2863 tx_buf->action == XDP_REDIRECT) { in bnxt_free_tx_skbs()
2864 dma_unmap_single(&pdev->dev, in bnxt_free_tx_skbs()
2868 xdp_return_frame(tx_buf->xdpf); in bnxt_free_tx_skbs()
2869 tx_buf->action = 0; in bnxt_free_tx_skbs()
2870 tx_buf->xdpf = NULL; in bnxt_free_tx_skbs()
2875 skb = tx_buf->skb; in bnxt_free_tx_skbs()
2881 tx_buf->skb = NULL; in bnxt_free_tx_skbs()
2883 if (tx_buf->is_push) { in bnxt_free_tx_skbs()
2889 dma_unmap_single(&pdev->dev, in bnxt_free_tx_skbs()
2894 last = tx_buf->nr_frags; in bnxt_free_tx_skbs()
2897 int ring_idx = j & bp->tx_ring_mask; in bnxt_free_tx_skbs()
2898 skb_frag_t *frag = &skb_shinfo(skb)->frags[k]; in bnxt_free_tx_skbs()
2900 tx_buf = &txr->tx_buf_ring[ring_idx]; in bnxt_free_tx_skbs()
2902 &pdev->dev, in bnxt_free_tx_skbs()
2908 netdev_tx_reset_queue(netdev_get_tx_queue(bp->dev, i)); in bnxt_free_tx_skbs()
2914 struct bnxt_rx_ring_info *rxr = &bp->rx_ring[ring_nr]; in bnxt_free_one_rx_ring_skbs()
2915 struct pci_dev *pdev = bp->pdev; in bnxt_free_one_rx_ring_skbs()
2919 max_idx = bp->rx_nr_pages * RX_DESC_CNT; in bnxt_free_one_rx_ring_skbs()
2920 max_agg_idx = bp->rx_agg_nr_pages * RX_DESC_CNT; in bnxt_free_one_rx_ring_skbs()
2921 if (!rxr->rx_tpa) in bnxt_free_one_rx_ring_skbs()
2924 for (i = 0; i < bp->max_tpa; i++) { in bnxt_free_one_rx_ring_skbs()
2925 struct bnxt_tpa_info *tpa_info = &rxr->rx_tpa[i]; in bnxt_free_one_rx_ring_skbs()
2926 u8 *data = tpa_info->data; in bnxt_free_one_rx_ring_skbs()
2931 dma_unmap_single_attrs(&pdev->dev, tpa_info->mapping, in bnxt_free_one_rx_ring_skbs()
2932 bp->rx_buf_use_size, bp->rx_dir, in bnxt_free_one_rx_ring_skbs()
2935 tpa_info->data = NULL; in bnxt_free_one_rx_ring_skbs()
2941 if (!rxr->rx_buf_ring) in bnxt_free_one_rx_ring_skbs()
2945 struct bnxt_sw_rx_bd *rx_buf = &rxr->rx_buf_ring[i]; in bnxt_free_one_rx_ring_skbs()
2946 dma_addr_t mapping = rx_buf->mapping; in bnxt_free_one_rx_ring_skbs()
2947 void *data = rx_buf->data; in bnxt_free_one_rx_ring_skbs()
2952 rx_buf->data = NULL; in bnxt_free_one_rx_ring_skbs()
2954 page_pool_recycle_direct(rxr->page_pool, data); in bnxt_free_one_rx_ring_skbs()
2956 dma_unmap_single_attrs(&pdev->dev, mapping, in bnxt_free_one_rx_ring_skbs()
2957 bp->rx_buf_use_size, bp->rx_dir, in bnxt_free_one_rx_ring_skbs()
2964 if (!rxr->rx_agg_ring) in bnxt_free_one_rx_ring_skbs()
2968 struct bnxt_sw_rx_agg_bd *rx_agg_buf = &rxr->rx_agg_ring[i]; in bnxt_free_one_rx_ring_skbs()
2969 struct page *page = rx_agg_buf->page; in bnxt_free_one_rx_ring_skbs()
2974 rx_agg_buf->page = NULL; in bnxt_free_one_rx_ring_skbs()
2975 __clear_bit(i, rxr->rx_agg_bmap); in bnxt_free_one_rx_ring_skbs()
2977 page_pool_recycle_direct(rxr->page_pool, page); in bnxt_free_one_rx_ring_skbs()
2981 map = rxr->rx_tpa_idx_map; in bnxt_free_one_rx_ring_skbs()
2983 memset(map->agg_idx_bmap, 0, sizeof(map->agg_idx_bmap)); in bnxt_free_one_rx_ring_skbs()
2990 if (!bp->rx_ring) in bnxt_free_rx_skbs()
2993 for (i = 0; i < bp->rx_nr_rings; i++) in bnxt_free_rx_skbs()
3005 u8 init_val = mem_init->init_val; in bnxt_init_ctx_mem()
3006 u16 offset = mem_init->offset; in bnxt_init_ctx_mem()
3016 for (i = 0; i < len; i += mem_init->size) in bnxt_init_ctx_mem()
3022 struct pci_dev *pdev = bp->pdev; in bnxt_free_ring()
3025 if (!rmem->pg_arr) in bnxt_free_ring()
3028 for (i = 0; i < rmem->nr_pages; i++) { in bnxt_free_ring()
3029 if (!rmem->pg_arr[i]) in bnxt_free_ring()
3032 dma_free_coherent(&pdev->dev, rmem->page_size, in bnxt_free_ring()
3033 rmem->pg_arr[i], rmem->dma_arr[i]); in bnxt_free_ring()
3035 rmem->pg_arr[i] = NULL; in bnxt_free_ring()
3038 if (rmem->pg_tbl) { in bnxt_free_ring()
3039 size_t pg_tbl_size = rmem->nr_pages * 8; in bnxt_free_ring()
3041 if (rmem->flags & BNXT_RMEM_USE_FULL_PAGE_FLAG) in bnxt_free_ring()
3042 pg_tbl_size = rmem->page_size; in bnxt_free_ring()
3043 dma_free_coherent(&pdev->dev, pg_tbl_size, in bnxt_free_ring()
3044 rmem->pg_tbl, rmem->pg_tbl_map); in bnxt_free_ring()
3045 rmem->pg_tbl = NULL; in bnxt_free_ring()
3047 if (rmem->vmem_size && *rmem->vmem) { in bnxt_free_ring()
3048 vfree(*rmem->vmem); in bnxt_free_ring()
3049 *rmem->vmem = NULL; in bnxt_free_ring()
3055 struct pci_dev *pdev = bp->pdev; in bnxt_alloc_ring()
3059 if (rmem->flags & (BNXT_RMEM_VALID_PTE_FLAG | BNXT_RMEM_RING_PTE_FLAG)) in bnxt_alloc_ring()
3061 if ((rmem->nr_pages > 1 || rmem->depth > 0) && !rmem->pg_tbl) { in bnxt_alloc_ring()
3062 size_t pg_tbl_size = rmem->nr_pages * 8; in bnxt_alloc_ring()
3064 if (rmem->flags & BNXT_RMEM_USE_FULL_PAGE_FLAG) in bnxt_alloc_ring()
3065 pg_tbl_size = rmem->page_size; in bnxt_alloc_ring()
3066 rmem->pg_tbl = dma_alloc_coherent(&pdev->dev, pg_tbl_size, in bnxt_alloc_ring()
3067 &rmem->pg_tbl_map, in bnxt_alloc_ring()
3069 if (!rmem->pg_tbl) in bnxt_alloc_ring()
3070 return -ENOMEM; in bnxt_alloc_ring()
3073 for (i = 0; i < rmem->nr_pages; i++) { in bnxt_alloc_ring()
3076 rmem->pg_arr[i] = dma_alloc_coherent(&pdev->dev, in bnxt_alloc_ring()
3077 rmem->page_size, in bnxt_alloc_ring()
3078 &rmem->dma_arr[i], in bnxt_alloc_ring()
3080 if (!rmem->pg_arr[i]) in bnxt_alloc_ring()
3081 return -ENOMEM; in bnxt_alloc_ring()
3083 if (rmem->mem_init) in bnxt_alloc_ring()
3084 bnxt_init_ctx_mem(rmem->mem_init, rmem->pg_arr[i], in bnxt_alloc_ring()
3085 rmem->page_size); in bnxt_alloc_ring()
3086 if (rmem->nr_pages > 1 || rmem->depth > 0) { in bnxt_alloc_ring()
3087 if (i == rmem->nr_pages - 2 && in bnxt_alloc_ring()
3088 (rmem->flags & BNXT_RMEM_RING_PTE_FLAG)) in bnxt_alloc_ring()
3090 else if (i == rmem->nr_pages - 1 && in bnxt_alloc_ring()
3091 (rmem->flags & BNXT_RMEM_RING_PTE_FLAG)) in bnxt_alloc_ring()
3093 rmem->pg_tbl[i] = in bnxt_alloc_ring()
3094 cpu_to_le64(rmem->dma_arr[i] | extra_bits); in bnxt_alloc_ring()
3098 if (rmem->vmem_size) { in bnxt_alloc_ring()
3099 *rmem->vmem = vzalloc(rmem->vmem_size); in bnxt_alloc_ring()
3100 if (!(*rmem->vmem)) in bnxt_alloc_ring()
3101 return -ENOMEM; in bnxt_alloc_ring()
3110 for (i = 0; i < bp->rx_nr_rings; i++) { in bnxt_free_tpa_info()
3111 struct bnxt_rx_ring_info *rxr = &bp->rx_ring[i]; in bnxt_free_tpa_info()
3113 kfree(rxr->rx_tpa_idx_map); in bnxt_free_tpa_info()
3114 rxr->rx_tpa_idx_map = NULL; in bnxt_free_tpa_info()
3115 if (rxr->rx_tpa) { in bnxt_free_tpa_info()
3116 for (j = 0; j < bp->max_tpa; j++) { in bnxt_free_tpa_info()
3117 kfree(rxr->rx_tpa[j].agg_arr); in bnxt_free_tpa_info()
3118 rxr->rx_tpa[j].agg_arr = NULL; in bnxt_free_tpa_info()
3121 kfree(rxr->rx_tpa); in bnxt_free_tpa_info()
3122 rxr->rx_tpa = NULL; in bnxt_free_tpa_info()
3130 bp->max_tpa = MAX_TPA; in bnxt_alloc_tpa_info()
3131 if (bp->flags & BNXT_FLAG_CHIP_P5) { in bnxt_alloc_tpa_info()
3132 if (!bp->max_tpa_v2) in bnxt_alloc_tpa_info()
3134 bp->max_tpa = max_t(u16, bp->max_tpa_v2, MAX_TPA_P5); in bnxt_alloc_tpa_info()
3137 for (i = 0; i < bp->rx_nr_rings; i++) { in bnxt_alloc_tpa_info()
3138 struct bnxt_rx_ring_info *rxr = &bp->rx_ring[i]; in bnxt_alloc_tpa_info()
3141 rxr->rx_tpa = kcalloc(bp->max_tpa, sizeof(struct bnxt_tpa_info), in bnxt_alloc_tpa_info()
3143 if (!rxr->rx_tpa) in bnxt_alloc_tpa_info()
3144 return -ENOMEM; in bnxt_alloc_tpa_info()
3146 if (!(bp->flags & BNXT_FLAG_CHIP_P5)) in bnxt_alloc_tpa_info()
3148 for (j = 0; j < bp->max_tpa; j++) { in bnxt_alloc_tpa_info()
3151 return -ENOMEM; in bnxt_alloc_tpa_info()
3152 rxr->rx_tpa[j].agg_arr = agg; in bnxt_alloc_tpa_info()
3154 rxr->rx_tpa_idx_map = kzalloc(sizeof(*rxr->rx_tpa_idx_map), in bnxt_alloc_tpa_info()
3156 if (!rxr->rx_tpa_idx_map) in bnxt_alloc_tpa_info()
3157 return -ENOMEM; in bnxt_alloc_tpa_info()
3166 if (!bp->rx_ring) in bnxt_free_rx_rings()
3170 for (i = 0; i < bp->rx_nr_rings; i++) { in bnxt_free_rx_rings()
3171 struct bnxt_rx_ring_info *rxr = &bp->rx_ring[i]; in bnxt_free_rx_rings()
3174 if (rxr->xdp_prog) in bnxt_free_rx_rings()
3175 bpf_prog_put(rxr->xdp_prog); in bnxt_free_rx_rings()
3177 if (xdp_rxq_info_is_reg(&rxr->xdp_rxq)) in bnxt_free_rx_rings()
3178 xdp_rxq_info_unreg(&rxr->xdp_rxq); in bnxt_free_rx_rings()
3180 page_pool_destroy(rxr->page_pool); in bnxt_free_rx_rings()
3181 rxr->page_pool = NULL; in bnxt_free_rx_rings()
3183 kfree(rxr->rx_agg_bmap); in bnxt_free_rx_rings()
3184 rxr->rx_agg_bmap = NULL; in bnxt_free_rx_rings()
3186 ring = &rxr->rx_ring_struct; in bnxt_free_rx_rings()
3187 bnxt_free_ring(bp, &ring->ring_mem); in bnxt_free_rx_rings()
3189 ring = &rxr->rx_agg_ring_struct; in bnxt_free_rx_rings()
3190 bnxt_free_ring(bp, &ring->ring_mem); in bnxt_free_rx_rings()
3199 pp.pool_size = bp->rx_agg_ring_size; in bnxt_alloc_rx_page_pool()
3201 pp.pool_size += bp->rx_ring_size; in bnxt_alloc_rx_page_pool()
3202 pp.nid = dev_to_node(&bp->pdev->dev); in bnxt_alloc_rx_page_pool()
3203 pp.napi = &rxr->bnapi->napi; in bnxt_alloc_rx_page_pool()
3204 pp.dev = &bp->pdev->dev; in bnxt_alloc_rx_page_pool()
3205 pp.dma_dir = bp->rx_dir; in bnxt_alloc_rx_page_pool()
3211 rxr->page_pool = page_pool_create(&pp); in bnxt_alloc_rx_page_pool()
3212 if (IS_ERR(rxr->page_pool)) { in bnxt_alloc_rx_page_pool()
3213 int err = PTR_ERR(rxr->page_pool); in bnxt_alloc_rx_page_pool()
3215 rxr->page_pool = NULL; in bnxt_alloc_rx_page_pool()
3225 if (!bp->rx_ring) in bnxt_alloc_rx_rings()
3226 return -ENOMEM; in bnxt_alloc_rx_rings()
3228 if (bp->flags & BNXT_FLAG_AGG_RINGS) in bnxt_alloc_rx_rings()
3231 for (i = 0; i < bp->rx_nr_rings; i++) { in bnxt_alloc_rx_rings()
3232 struct bnxt_rx_ring_info *rxr = &bp->rx_ring[i]; in bnxt_alloc_rx_rings()
3235 ring = &rxr->rx_ring_struct; in bnxt_alloc_rx_rings()
3241 rc = xdp_rxq_info_reg(&rxr->xdp_rxq, bp->dev, i, 0); in bnxt_alloc_rx_rings()
3245 rc = xdp_rxq_info_reg_mem_model(&rxr->xdp_rxq, in bnxt_alloc_rx_rings()
3247 rxr->page_pool); in bnxt_alloc_rx_rings()
3249 xdp_rxq_info_unreg(&rxr->xdp_rxq); in bnxt_alloc_rx_rings()
3253 rc = bnxt_alloc_ring(bp, &ring->ring_mem); in bnxt_alloc_rx_rings()
3257 ring->grp_idx = i; in bnxt_alloc_rx_rings()
3261 ring = &rxr->rx_agg_ring_struct; in bnxt_alloc_rx_rings()
3262 rc = bnxt_alloc_ring(bp, &ring->ring_mem); in bnxt_alloc_rx_rings()
3266 ring->grp_idx = i; in bnxt_alloc_rx_rings()
3267 rxr->rx_agg_bmap_size = bp->rx_agg_ring_mask + 1; in bnxt_alloc_rx_rings()
3268 mem_size = rxr->rx_agg_bmap_size / 8; in bnxt_alloc_rx_rings()
3269 rxr->rx_agg_bmap = kzalloc(mem_size, GFP_KERNEL); in bnxt_alloc_rx_rings()
3270 if (!rxr->rx_agg_bmap) in bnxt_alloc_rx_rings()
3271 return -ENOMEM; in bnxt_alloc_rx_rings()
3274 if (bp->flags & BNXT_FLAG_TPA) in bnxt_alloc_rx_rings()
3282 struct pci_dev *pdev = bp->pdev; in bnxt_free_tx_rings()
3284 if (!bp->tx_ring) in bnxt_free_tx_rings()
3287 for (i = 0; i < bp->tx_nr_rings; i++) { in bnxt_free_tx_rings()
3288 struct bnxt_tx_ring_info *txr = &bp->tx_ring[i]; in bnxt_free_tx_rings()
3291 if (txr->tx_push) { in bnxt_free_tx_rings()
3292 dma_free_coherent(&pdev->dev, bp->tx_push_size, in bnxt_free_tx_rings()
3293 txr->tx_push, txr->tx_push_mapping); in bnxt_free_tx_rings()
3294 txr->tx_push = NULL; in bnxt_free_tx_rings()
3297 ring = &txr->tx_ring_struct; in bnxt_free_tx_rings()
3299 bnxt_free_ring(bp, &ring->ring_mem); in bnxt_free_tx_rings()
3306 struct pci_dev *pdev = bp->pdev; in bnxt_alloc_tx_rings()
3308 bp->tx_push_size = 0; in bnxt_alloc_tx_rings()
3309 if (bp->tx_push_thresh) { in bnxt_alloc_tx_rings()
3313 bp->tx_push_thresh); in bnxt_alloc_tx_rings()
3317 bp->tx_push_thresh = 0; in bnxt_alloc_tx_rings()
3320 bp->tx_push_size = push_size; in bnxt_alloc_tx_rings()
3323 for (i = 0, j = 0; i < bp->tx_nr_rings; i++) { in bnxt_alloc_tx_rings()
3324 struct bnxt_tx_ring_info *txr = &bp->tx_ring[i]; in bnxt_alloc_tx_rings()
3328 ring = &txr->tx_ring_struct; in bnxt_alloc_tx_rings()
3330 rc = bnxt_alloc_ring(bp, &ring->ring_mem); in bnxt_alloc_tx_rings()
3334 ring->grp_idx = txr->bnapi->index; in bnxt_alloc_tx_rings()
3335 if (bp->tx_push_size) { in bnxt_alloc_tx_rings()
3338 /* One pre-allocated DMA buffer to backup in bnxt_alloc_tx_rings()
3341 txr->tx_push = dma_alloc_coherent(&pdev->dev, in bnxt_alloc_tx_rings()
3342 bp->tx_push_size, in bnxt_alloc_tx_rings()
3343 &txr->tx_push_mapping, in bnxt_alloc_tx_rings()
3346 if (!txr->tx_push) in bnxt_alloc_tx_rings()
3347 return -ENOMEM; in bnxt_alloc_tx_rings()
3349 mapping = txr->tx_push_mapping + in bnxt_alloc_tx_rings()
3351 txr->data_mapping = cpu_to_le64(mapping); in bnxt_alloc_tx_rings()
3353 qidx = bp->tc_to_qidx[j]; in bnxt_alloc_tx_rings()
3354 ring->queue_id = bp->q_info[qidx].queue_id; in bnxt_alloc_tx_rings()
3355 spin_lock_init(&txr->xdp_tx_lock); in bnxt_alloc_tx_rings()
3356 if (i < bp->tx_nr_rings_xdp) in bnxt_alloc_tx_rings()
3358 if (i % bp->tx_nr_rings_per_tc == (bp->tx_nr_rings_per_tc - 1)) in bnxt_alloc_tx_rings()
3366 struct bnxt_ring_struct *ring = &cpr->cp_ring_struct; in bnxt_free_cp_arrays()
3368 kfree(cpr->cp_desc_ring); in bnxt_free_cp_arrays()
3369 cpr->cp_desc_ring = NULL; in bnxt_free_cp_arrays()
3370 ring->ring_mem.pg_arr = NULL; in bnxt_free_cp_arrays()
3371 kfree(cpr->cp_desc_mapping); in bnxt_free_cp_arrays()
3372 cpr->cp_desc_mapping = NULL; in bnxt_free_cp_arrays()
3373 ring->ring_mem.dma_arr = NULL; in bnxt_free_cp_arrays()
3378 cpr->cp_desc_ring = kcalloc(n, sizeof(*cpr->cp_desc_ring), GFP_KERNEL); in bnxt_alloc_cp_arrays()
3379 if (!cpr->cp_desc_ring) in bnxt_alloc_cp_arrays()
3380 return -ENOMEM; in bnxt_alloc_cp_arrays()
3381 cpr->cp_desc_mapping = kcalloc(n, sizeof(*cpr->cp_desc_mapping), in bnxt_alloc_cp_arrays()
3383 if (!cpr->cp_desc_mapping) in bnxt_alloc_cp_arrays()
3384 return -ENOMEM; in bnxt_alloc_cp_arrays()
3392 if (!bp->bnapi) in bnxt_free_all_cp_arrays()
3394 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_free_all_cp_arrays()
3395 struct bnxt_napi *bnapi = bp->bnapi[i]; in bnxt_free_all_cp_arrays()
3399 bnxt_free_cp_arrays(&bnapi->cp_ring); in bnxt_free_all_cp_arrays()
3405 int i, n = bp->cp_nr_pages; in bnxt_alloc_all_cp_arrays()
3407 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_alloc_all_cp_arrays()
3408 struct bnxt_napi *bnapi = bp->bnapi[i]; in bnxt_alloc_all_cp_arrays()
3413 rc = bnxt_alloc_cp_arrays(&bnapi->cp_ring, n); in bnxt_alloc_all_cp_arrays()
3424 if (!bp->bnapi) in bnxt_free_cp_rings()
3427 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_free_cp_rings()
3428 struct bnxt_napi *bnapi = bp->bnapi[i]; in bnxt_free_cp_rings()
3436 cpr = &bnapi->cp_ring; in bnxt_free_cp_rings()
3437 ring = &cpr->cp_ring_struct; in bnxt_free_cp_rings()
3439 bnxt_free_ring(bp, &ring->ring_mem); in bnxt_free_cp_rings()
3442 struct bnxt_cp_ring_info *cpr2 = cpr->cp_ring_arr[j]; in bnxt_free_cp_rings()
3445 ring = &cpr2->cp_ring_struct; in bnxt_free_cp_rings()
3446 bnxt_free_ring(bp, &ring->ring_mem); in bnxt_free_cp_rings()
3449 cpr->cp_ring_arr[j] = NULL; in bnxt_free_cp_rings()
3466 rc = bnxt_alloc_cp_arrays(cpr, bp->cp_nr_pages); in bnxt_alloc_cp_sub_ring()
3472 ring = &cpr->cp_ring_struct; in bnxt_alloc_cp_sub_ring()
3473 rmem = &ring->ring_mem; in bnxt_alloc_cp_sub_ring()
3474 rmem->nr_pages = bp->cp_nr_pages; in bnxt_alloc_cp_sub_ring()
3475 rmem->page_size = HW_CMPD_RING_SIZE; in bnxt_alloc_cp_sub_ring()
3476 rmem->pg_arr = (void **)cpr->cp_desc_ring; in bnxt_alloc_cp_sub_ring()
3477 rmem->dma_arr = cpr->cp_desc_mapping; in bnxt_alloc_cp_sub_ring()
3478 rmem->flags = BNXT_RMEM_RING_PTE_FLAG; in bnxt_alloc_cp_sub_ring()
3491 bool sh = !!(bp->flags & BNXT_FLAG_SHARED_RINGS); in bnxt_alloc_cp_rings()
3496 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_alloc_cp_rings()
3497 struct bnxt_napi *bnapi = bp->bnapi[i]; in bnxt_alloc_cp_rings()
3504 cpr = &bnapi->cp_ring; in bnxt_alloc_cp_rings()
3505 cpr->bnapi = bnapi; in bnxt_alloc_cp_rings()
3506 ring = &cpr->cp_ring_struct; in bnxt_alloc_cp_rings()
3508 rc = bnxt_alloc_ring(bp, &ring->ring_mem); in bnxt_alloc_cp_rings()
3513 ring->map_idx = i + ulp_msix; in bnxt_alloc_cp_rings()
3515 ring->map_idx = i; in bnxt_alloc_cp_rings()
3517 if (!(bp->flags & BNXT_FLAG_CHIP_P5)) in bnxt_alloc_cp_rings()
3520 if (i < bp->rx_nr_rings) { in bnxt_alloc_cp_rings()
3524 cpr->cp_ring_arr[BNXT_RX_HDL] = cpr2; in bnxt_alloc_cp_rings()
3526 return -ENOMEM; in bnxt_alloc_cp_rings()
3527 cpr2->bnapi = bnapi; in bnxt_alloc_cp_rings()
3529 if ((sh && i < bp->tx_nr_rings) || in bnxt_alloc_cp_rings()
3530 (!sh && i >= bp->rx_nr_rings)) { in bnxt_alloc_cp_rings()
3534 cpr->cp_ring_arr[BNXT_TX_HDL] = cpr2; in bnxt_alloc_cp_rings()
3536 return -ENOMEM; in bnxt_alloc_cp_rings()
3537 cpr2->bnapi = bnapi; in bnxt_alloc_cp_rings()
3547 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_init_ring_struct()
3548 struct bnxt_napi *bnapi = bp->bnapi[i]; in bnxt_init_ring_struct()
3558 cpr = &bnapi->cp_ring; in bnxt_init_ring_struct()
3559 ring = &cpr->cp_ring_struct; in bnxt_init_ring_struct()
3560 rmem = &ring->ring_mem; in bnxt_init_ring_struct()
3561 rmem->nr_pages = bp->cp_nr_pages; in bnxt_init_ring_struct()
3562 rmem->page_size = HW_CMPD_RING_SIZE; in bnxt_init_ring_struct()
3563 rmem->pg_arr = (void **)cpr->cp_desc_ring; in bnxt_init_ring_struct()
3564 rmem->dma_arr = cpr->cp_desc_mapping; in bnxt_init_ring_struct()
3565 rmem->vmem_size = 0; in bnxt_init_ring_struct()
3567 rxr = bnapi->rx_ring; in bnxt_init_ring_struct()
3571 ring = &rxr->rx_ring_struct; in bnxt_init_ring_struct()
3572 rmem = &ring->ring_mem; in bnxt_init_ring_struct()
3573 rmem->nr_pages = bp->rx_nr_pages; in bnxt_init_ring_struct()
3574 rmem->page_size = HW_RXBD_RING_SIZE; in bnxt_init_ring_struct()
3575 rmem->pg_arr = (void **)rxr->rx_desc_ring; in bnxt_init_ring_struct()
3576 rmem->dma_arr = rxr->rx_desc_mapping; in bnxt_init_ring_struct()
3577 rmem->vmem_size = SW_RXBD_RING_SIZE * bp->rx_nr_pages; in bnxt_init_ring_struct()
3578 rmem->vmem = (void **)&rxr->rx_buf_ring; in bnxt_init_ring_struct()
3580 ring = &rxr->rx_agg_ring_struct; in bnxt_init_ring_struct()
3581 rmem = &ring->ring_mem; in bnxt_init_ring_struct()
3582 rmem->nr_pages = bp->rx_agg_nr_pages; in bnxt_init_ring_struct()
3583 rmem->page_size = HW_RXBD_RING_SIZE; in bnxt_init_ring_struct()
3584 rmem->pg_arr = (void **)rxr->rx_agg_desc_ring; in bnxt_init_ring_struct()
3585 rmem->dma_arr = rxr->rx_agg_desc_mapping; in bnxt_init_ring_struct()
3586 rmem->vmem_size = SW_RXBD_AGG_RING_SIZE * bp->rx_agg_nr_pages; in bnxt_init_ring_struct()
3587 rmem->vmem = (void **)&rxr->rx_agg_ring; in bnxt_init_ring_struct()
3590 txr = bnapi->tx_ring; in bnxt_init_ring_struct()
3594 ring = &txr->tx_ring_struct; in bnxt_init_ring_struct()
3595 rmem = &ring->ring_mem; in bnxt_init_ring_struct()
3596 rmem->nr_pages = bp->tx_nr_pages; in bnxt_init_ring_struct()
3597 rmem->page_size = HW_RXBD_RING_SIZE; in bnxt_init_ring_struct()
3598 rmem->pg_arr = (void **)txr->tx_desc_ring; in bnxt_init_ring_struct()
3599 rmem->dma_arr = txr->tx_desc_mapping; in bnxt_init_ring_struct()
3600 rmem->vmem_size = SW_TXBD_RING_SIZE * bp->tx_nr_pages; in bnxt_init_ring_struct()
3601 rmem->vmem = (void **)&txr->tx_buf_ring; in bnxt_init_ring_struct()
3611 rx_buf_ring = (struct rx_bd **)ring->ring_mem.pg_arr; in bnxt_init_rxbd_pages()
3612 for (i = 0, prod = 0; i < ring->ring_mem.nr_pages; i++) { in bnxt_init_rxbd_pages()
3621 rxbd->rx_bd_len_flags_type = cpu_to_le32(type); in bnxt_init_rxbd_pages()
3622 rxbd->rx_bd_opaque = prod; in bnxt_init_rxbd_pages()
3629 struct bnxt_rx_ring_info *rxr = &bp->rx_ring[ring_nr]; in bnxt_alloc_one_rx_ring()
3630 struct net_device *dev = bp->dev; in bnxt_alloc_one_rx_ring()
3634 prod = rxr->rx_prod; in bnxt_alloc_one_rx_ring()
3635 for (i = 0; i < bp->rx_ring_size; i++) { in bnxt_alloc_one_rx_ring()
3638 ring_nr, i, bp->rx_ring_size); in bnxt_alloc_one_rx_ring()
3643 rxr->rx_prod = prod; in bnxt_alloc_one_rx_ring()
3645 if (!(bp->flags & BNXT_FLAG_AGG_RINGS)) in bnxt_alloc_one_rx_ring()
3648 prod = rxr->rx_agg_prod; in bnxt_alloc_one_rx_ring()
3649 for (i = 0; i < bp->rx_agg_ring_size; i++) { in bnxt_alloc_one_rx_ring()
3652 ring_nr, i, bp->rx_ring_size); in bnxt_alloc_one_rx_ring()
3657 rxr->rx_agg_prod = prod; in bnxt_alloc_one_rx_ring()
3659 if (rxr->rx_tpa) { in bnxt_alloc_one_rx_ring()
3663 for (i = 0; i < bp->max_tpa; i++) { in bnxt_alloc_one_rx_ring()
3666 return -ENOMEM; in bnxt_alloc_one_rx_ring()
3668 rxr->rx_tpa[i].data = data; in bnxt_alloc_one_rx_ring()
3669 rxr->rx_tpa[i].data_ptr = data + bp->rx_offset; in bnxt_alloc_one_rx_ring()
3670 rxr->rx_tpa[i].mapping = mapping; in bnxt_alloc_one_rx_ring()
3682 type = (bp->rx_buf_use_size << RX_BD_LEN_SHIFT) | in bnxt_init_one_rx_ring()
3688 rxr = &bp->rx_ring[ring_nr]; in bnxt_init_one_rx_ring()
3689 ring = &rxr->rx_ring_struct; in bnxt_init_one_rx_ring()
3692 if (BNXT_RX_PAGE_MODE(bp) && bp->xdp_prog) { in bnxt_init_one_rx_ring()
3693 bpf_prog_add(bp->xdp_prog, 1); in bnxt_init_one_rx_ring()
3694 rxr->xdp_prog = bp->xdp_prog; in bnxt_init_one_rx_ring()
3696 ring->fw_ring_id = INVALID_HW_RING_ID; in bnxt_init_one_rx_ring()
3698 ring = &rxr->rx_agg_ring_struct; in bnxt_init_one_rx_ring()
3699 ring->fw_ring_id = INVALID_HW_RING_ID; in bnxt_init_one_rx_ring()
3701 if ((bp->flags & BNXT_FLAG_AGG_RINGS)) { in bnxt_init_one_rx_ring()
3715 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_init_cp_rings()
3716 struct bnxt_cp_ring_info *cpr = &bp->bnapi[i]->cp_ring; in bnxt_init_cp_rings()
3717 struct bnxt_ring_struct *ring = &cpr->cp_ring_struct; in bnxt_init_cp_rings()
3719 ring->fw_ring_id = INVALID_HW_RING_ID; in bnxt_init_cp_rings()
3720 cpr->rx_ring_coal.coal_ticks = bp->rx_coal.coal_ticks; in bnxt_init_cp_rings()
3721 cpr->rx_ring_coal.coal_bufs = bp->rx_coal.coal_bufs; in bnxt_init_cp_rings()
3723 struct bnxt_cp_ring_info *cpr2 = cpr->cp_ring_arr[j]; in bnxt_init_cp_rings()
3728 ring = &cpr2->cp_ring_struct; in bnxt_init_cp_rings()
3729 ring->fw_ring_id = INVALID_HW_RING_ID; in bnxt_init_cp_rings()
3730 cpr2->rx_ring_coal.coal_ticks = bp->rx_coal.coal_ticks; in bnxt_init_cp_rings()
3731 cpr2->rx_ring_coal.coal_bufs = bp->rx_coal.coal_bufs; in bnxt_init_cp_rings()
3741 bp->rx_offset = NET_IP_ALIGN + XDP_PACKET_HEADROOM; in bnxt_init_rx_rings()
3742 bp->rx_dma_offset = XDP_PACKET_HEADROOM; in bnxt_init_rx_rings()
3744 bp->rx_offset = BNXT_RX_OFFSET; in bnxt_init_rx_rings()
3745 bp->rx_dma_offset = BNXT_RX_DMA_OFFSET; in bnxt_init_rx_rings()
3748 for (i = 0; i < bp->rx_nr_rings; i++) { in bnxt_init_rx_rings()
3761 bp->tx_wake_thresh = max_t(int, bp->tx_ring_size / 2, in bnxt_init_tx_rings()
3764 for (i = 0; i < bp->tx_nr_rings; i++) { in bnxt_init_tx_rings()
3765 struct bnxt_tx_ring_info *txr = &bp->tx_ring[i]; in bnxt_init_tx_rings()
3766 struct bnxt_ring_struct *ring = &txr->tx_ring_struct; in bnxt_init_tx_rings()
3768 ring->fw_ring_id = INVALID_HW_RING_ID; in bnxt_init_tx_rings()
3776 kfree(bp->grp_info); in bnxt_free_ring_grps()
3777 bp->grp_info = NULL; in bnxt_free_ring_grps()
3785 bp->grp_info = kcalloc(bp->cp_nr_rings, in bnxt_init_ring_grps()
3788 if (!bp->grp_info) in bnxt_init_ring_grps()
3789 return -ENOMEM; in bnxt_init_ring_grps()
3791 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_init_ring_grps()
3793 bp->grp_info[i].fw_stats_ctx = INVALID_HW_RING_ID; in bnxt_init_ring_grps()
3794 bp->grp_info[i].fw_grp_id = INVALID_HW_RING_ID; in bnxt_init_ring_grps()
3795 bp->grp_info[i].rx_fw_ring_id = INVALID_HW_RING_ID; in bnxt_init_ring_grps()
3796 bp->grp_info[i].agg_fw_ring_id = INVALID_HW_RING_ID; in bnxt_init_ring_grps()
3797 bp->grp_info[i].cp_fw_ring_id = INVALID_HW_RING_ID; in bnxt_init_ring_grps()
3804 kfree(bp->vnic_info); in bnxt_free_vnics()
3805 bp->vnic_info = NULL; in bnxt_free_vnics()
3806 bp->nr_vnics = 0; in bnxt_free_vnics()
3814 if ((bp->flags & (BNXT_FLAG_RFS | BNXT_FLAG_CHIP_P5)) == BNXT_FLAG_RFS) in bnxt_alloc_vnics()
3815 num_vnics += bp->rx_nr_rings; in bnxt_alloc_vnics()
3821 bp->vnic_info = kcalloc(num_vnics, sizeof(struct bnxt_vnic_info), in bnxt_alloc_vnics()
3823 if (!bp->vnic_info) in bnxt_alloc_vnics()
3824 return -ENOMEM; in bnxt_alloc_vnics()
3826 bp->nr_vnics = num_vnics; in bnxt_alloc_vnics()
3834 for (i = 0; i < bp->nr_vnics; i++) { in bnxt_init_vnics()
3835 struct bnxt_vnic_info *vnic = &bp->vnic_info[i]; in bnxt_init_vnics()
3838 vnic->fw_vnic_id = INVALID_HW_RING_ID; in bnxt_init_vnics()
3840 vnic->fw_rss_cos_lb_ctx[j] = INVALID_HW_RING_ID; in bnxt_init_vnics()
3842 vnic->fw_l2_ctx_id = INVALID_HW_RING_ID; in bnxt_init_vnics()
3844 if (bp->vnic_info[i].rss_hash_key) { in bnxt_init_vnics()
3846 get_random_bytes(vnic->rss_hash_key, in bnxt_init_vnics()
3849 memcpy(vnic->rss_hash_key, in bnxt_init_vnics()
3850 bp->vnic_info[0].rss_hash_key, in bnxt_init_vnics()
3867 while (pages & (pages - 1)) in bnxt_calc_nr_ring_pages()
3875 bp->flags &= ~BNXT_FLAG_TPA; in bnxt_set_tpa_flags()
3876 if (bp->flags & BNXT_FLAG_NO_AGG_RINGS) in bnxt_set_tpa_flags()
3878 if (bp->dev->features & NETIF_F_LRO) in bnxt_set_tpa_flags()
3879 bp->flags |= BNXT_FLAG_LRO; in bnxt_set_tpa_flags()
3880 else if (bp->dev->features & NETIF_F_GRO_HW) in bnxt_set_tpa_flags()
3881 bp->flags |= BNXT_FLAG_GRO; in bnxt_set_tpa_flags()
3884 /* bp->rx_ring_size, bp->tx_ring_size, dev->mtu, BNXT_FLAG_{G|L}RO flags must
3893 rx_size = SKB_DATA_ALIGN(bp->dev->mtu + ETH_HLEN + NET_IP_ALIGN + 8); in bnxt_set_ring_params()
3898 bp->rx_copy_thresh = BNXT_RX_COPY_THRESH; in bnxt_set_ring_params()
3899 ring_size = bp->rx_ring_size; in bnxt_set_ring_params()
3900 bp->rx_agg_ring_size = 0; in bnxt_set_ring_params()
3901 bp->rx_agg_nr_pages = 0; in bnxt_set_ring_params()
3903 if (bp->flags & BNXT_FLAG_TPA) in bnxt_set_ring_params()
3906 bp->flags &= ~BNXT_FLAG_JUMBO; in bnxt_set_ring_params()
3907 if (rx_space > PAGE_SIZE && !(bp->flags & BNXT_FLAG_NO_AGG_RINGS)) { in bnxt_set_ring_params()
3910 bp->flags |= BNXT_FLAG_JUMBO; in bnxt_set_ring_params()
3911 jumbo_factor = PAGE_ALIGN(bp->dev->mtu - 40) >> PAGE_SHIFT; in bnxt_set_ring_params()
3918 … netdev_warn(bp->dev, "RX ring size reduced from %d to %d because the jumbo ring is now enabled\n", in bnxt_set_ring_params()
3919 bp->rx_ring_size, ring_size); in bnxt_set_ring_params()
3920 bp->rx_ring_size = ring_size; in bnxt_set_ring_params()
3924 bp->rx_agg_nr_pages = bnxt_calc_nr_ring_pages(agg_ring_size, in bnxt_set_ring_params()
3926 if (bp->rx_agg_nr_pages > MAX_RX_AGG_PAGES) { in bnxt_set_ring_params()
3929 bp->rx_agg_nr_pages = MAX_RX_AGG_PAGES; in bnxt_set_ring_params()
3930 agg_ring_size = MAX_RX_AGG_PAGES * RX_DESC_CNT - 1; in bnxt_set_ring_params()
3931 netdev_warn(bp->dev, "rx agg ring size %d reduced to %d.\n", in bnxt_set_ring_params()
3934 bp->rx_agg_ring_size = agg_ring_size; in bnxt_set_ring_params()
3935 bp->rx_agg_ring_mask = (bp->rx_agg_nr_pages * RX_DESC_CNT) - 1; in bnxt_set_ring_params()
3939 rx_size = PAGE_SIZE - in bnxt_set_ring_params()
3940 ALIGN(max(NET_SKB_PAD, XDP_PACKET_HEADROOM), 8) - in bnxt_set_ring_params()
3949 bp->rx_buf_use_size = rx_size; in bnxt_set_ring_params()
3950 bp->rx_buf_size = rx_space; in bnxt_set_ring_params()
3952 bp->rx_nr_pages = bnxt_calc_nr_ring_pages(ring_size, RX_DESC_CNT); in bnxt_set_ring_params()
3953 bp->rx_ring_mask = (bp->rx_nr_pages * RX_DESC_CNT) - 1; in bnxt_set_ring_params()
3955 ring_size = bp->tx_ring_size; in bnxt_set_ring_params()
3956 bp->tx_nr_pages = bnxt_calc_nr_ring_pages(ring_size, TX_DESC_CNT); in bnxt_set_ring_params()
3957 bp->tx_ring_mask = (bp->tx_nr_pages * TX_DESC_CNT) - 1; in bnxt_set_ring_params()
3959 max_rx_cmpl = bp->rx_ring_size; in bnxt_set_ring_params()
3964 if (bp->flags & BNXT_FLAG_TPA) in bnxt_set_ring_params()
3965 max_rx_cmpl += bp->max_tpa; in bnxt_set_ring_params()
3966 /* RX and TPA completions are 32-byte, all others are 16-byte */ in bnxt_set_ring_params()
3967 ring_size = max_rx_cmpl * 2 + agg_ring_size + bp->tx_ring_size; in bnxt_set_ring_params()
3968 bp->cp_ring_size = ring_size; in bnxt_set_ring_params()
3970 bp->cp_nr_pages = bnxt_calc_nr_ring_pages(ring_size, CP_DESC_CNT); in bnxt_set_ring_params()
3971 if (bp->cp_nr_pages > MAX_CP_PAGES) { in bnxt_set_ring_params()
3972 bp->cp_nr_pages = MAX_CP_PAGES; in bnxt_set_ring_params()
3973 bp->cp_ring_size = MAX_CP_PAGES * CP_DESC_CNT - 1; in bnxt_set_ring_params()
3974 netdev_warn(bp->dev, "completion ring size %d reduced to %d.\n", in bnxt_set_ring_params()
3975 ring_size, bp->cp_ring_size); in bnxt_set_ring_params()
3977 bp->cp_bit = bp->cp_nr_pages * CP_DESC_CNT; in bnxt_set_ring_params()
3978 bp->cp_ring_mask = bp->cp_bit - 1; in bnxt_set_ring_params()
3986 struct net_device *dev = bp->dev; in bnxt_set_rx_skb_mode()
3989 bp->flags &= ~BNXT_FLAG_AGG_RINGS; in bnxt_set_rx_skb_mode()
3990 bp->flags |= BNXT_FLAG_RX_PAGE_MODE; in bnxt_set_rx_skb_mode()
3992 if (bp->xdp_prog->aux->xdp_has_frags) in bnxt_set_rx_skb_mode()
3993 dev->max_mtu = min_t(u16, bp->max_mtu, BNXT_MAX_MTU); in bnxt_set_rx_skb_mode()
3995 dev->max_mtu = in bnxt_set_rx_skb_mode()
3996 min_t(u16, bp->max_mtu, BNXT_MAX_PAGE_MODE_MTU); in bnxt_set_rx_skb_mode()
3997 if (dev->mtu > BNXT_MAX_PAGE_MODE_MTU) { in bnxt_set_rx_skb_mode()
3998 bp->flags |= BNXT_FLAG_JUMBO; in bnxt_set_rx_skb_mode()
3999 bp->rx_skb_func = bnxt_rx_multi_page_skb; in bnxt_set_rx_skb_mode()
4001 bp->flags |= BNXT_FLAG_NO_AGG_RINGS; in bnxt_set_rx_skb_mode()
4002 bp->rx_skb_func = bnxt_rx_page_skb; in bnxt_set_rx_skb_mode()
4004 bp->rx_dir = DMA_BIDIRECTIONAL; in bnxt_set_rx_skb_mode()
4008 dev->max_mtu = bp->max_mtu; in bnxt_set_rx_skb_mode()
4009 bp->flags &= ~BNXT_FLAG_RX_PAGE_MODE; in bnxt_set_rx_skb_mode()
4010 bp->rx_dir = DMA_FROM_DEVICE; in bnxt_set_rx_skb_mode()
4011 bp->rx_skb_func = bnxt_rx_skb; in bnxt_set_rx_skb_mode()
4020 struct pci_dev *pdev = bp->pdev; in bnxt_free_vnic_attributes()
4022 if (!bp->vnic_info) in bnxt_free_vnic_attributes()
4025 for (i = 0; i < bp->nr_vnics; i++) { in bnxt_free_vnic_attributes()
4026 vnic = &bp->vnic_info[i]; in bnxt_free_vnic_attributes()
4028 kfree(vnic->fw_grp_ids); in bnxt_free_vnic_attributes()
4029 vnic->fw_grp_ids = NULL; in bnxt_free_vnic_attributes()
4031 kfree(vnic->uc_list); in bnxt_free_vnic_attributes()
4032 vnic->uc_list = NULL; in bnxt_free_vnic_attributes()
4034 if (vnic->mc_list) { in bnxt_free_vnic_attributes()
4035 dma_free_coherent(&pdev->dev, vnic->mc_list_size, in bnxt_free_vnic_attributes()
4036 vnic->mc_list, vnic->mc_list_mapping); in bnxt_free_vnic_attributes()
4037 vnic->mc_list = NULL; in bnxt_free_vnic_attributes()
4040 if (vnic->rss_table) { in bnxt_free_vnic_attributes()
4041 dma_free_coherent(&pdev->dev, vnic->rss_table_size, in bnxt_free_vnic_attributes()
4042 vnic->rss_table, in bnxt_free_vnic_attributes()
4043 vnic->rss_table_dma_addr); in bnxt_free_vnic_attributes()
4044 vnic->rss_table = NULL; in bnxt_free_vnic_attributes()
4047 vnic->rss_hash_key = NULL; in bnxt_free_vnic_attributes()
4048 vnic->flags = 0; in bnxt_free_vnic_attributes()
4056 struct pci_dev *pdev = bp->pdev; in bnxt_alloc_vnic_attributes()
4059 for (i = 0; i < bp->nr_vnics; i++) { in bnxt_alloc_vnic_attributes()
4060 vnic = &bp->vnic_info[i]; in bnxt_alloc_vnic_attributes()
4062 if (vnic->flags & BNXT_VNIC_UCAST_FLAG) { in bnxt_alloc_vnic_attributes()
4063 int mem_size = (BNXT_MAX_UC_ADDRS - 1) * ETH_ALEN; in bnxt_alloc_vnic_attributes()
4066 vnic->uc_list = kmalloc(mem_size, GFP_KERNEL); in bnxt_alloc_vnic_attributes()
4067 if (!vnic->uc_list) { in bnxt_alloc_vnic_attributes()
4068 rc = -ENOMEM; in bnxt_alloc_vnic_attributes()
4074 if (vnic->flags & BNXT_VNIC_MCAST_FLAG) { in bnxt_alloc_vnic_attributes()
4075 vnic->mc_list_size = BNXT_MAX_MC_ADDRS * ETH_ALEN; in bnxt_alloc_vnic_attributes()
4076 vnic->mc_list = in bnxt_alloc_vnic_attributes()
4077 dma_alloc_coherent(&pdev->dev, in bnxt_alloc_vnic_attributes()
4078 vnic->mc_list_size, in bnxt_alloc_vnic_attributes()
4079 &vnic->mc_list_mapping, in bnxt_alloc_vnic_attributes()
4081 if (!vnic->mc_list) { in bnxt_alloc_vnic_attributes()
4082 rc = -ENOMEM; in bnxt_alloc_vnic_attributes()
4087 if (bp->flags & BNXT_FLAG_CHIP_P5) in bnxt_alloc_vnic_attributes()
4090 if (vnic->flags & BNXT_VNIC_RSS_FLAG) in bnxt_alloc_vnic_attributes()
4091 max_rings = bp->rx_nr_rings; in bnxt_alloc_vnic_attributes()
4095 vnic->fw_grp_ids = kcalloc(max_rings, sizeof(u16), GFP_KERNEL); in bnxt_alloc_vnic_attributes()
4096 if (!vnic->fw_grp_ids) { in bnxt_alloc_vnic_attributes()
4097 rc = -ENOMEM; in bnxt_alloc_vnic_attributes()
4101 if ((bp->flags & BNXT_FLAG_NEW_RSS_CAP) && in bnxt_alloc_vnic_attributes()
4102 !(vnic->flags & BNXT_VNIC_RSS_FLAG)) in bnxt_alloc_vnic_attributes()
4107 if (bp->flags & BNXT_FLAG_CHIP_P5) in bnxt_alloc_vnic_attributes()
4110 vnic->rss_table_size = size + HW_HASH_KEY_SIZE; in bnxt_alloc_vnic_attributes()
4111 vnic->rss_table = dma_alloc_coherent(&pdev->dev, in bnxt_alloc_vnic_attributes()
4112 vnic->rss_table_size, in bnxt_alloc_vnic_attributes()
4113 &vnic->rss_table_dma_addr, in bnxt_alloc_vnic_attributes()
4115 if (!vnic->rss_table) { in bnxt_alloc_vnic_attributes()
4116 rc = -ENOMEM; in bnxt_alloc_vnic_attributes()
4120 vnic->rss_hash_key = ((void *)vnic->rss_table) + size; in bnxt_alloc_vnic_attributes()
4121 vnic->rss_hash_key_dma_addr = vnic->rss_table_dma_addr + size; in bnxt_alloc_vnic_attributes()
4133 dma_pool_destroy(bp->hwrm_dma_pool); in bnxt_free_hwrm_resources()
4134 bp->hwrm_dma_pool = NULL; in bnxt_free_hwrm_resources()
4137 hlist_for_each_entry_rcu(token, &bp->hwrm_pending_list, node) in bnxt_free_hwrm_resources()
4138 WRITE_ONCE(token->state, BNXT_HWRM_CANCELLED); in bnxt_free_hwrm_resources()
4144 bp->hwrm_dma_pool = dma_pool_create("bnxt_hwrm", &bp->pdev->dev, in bnxt_alloc_hwrm_resources()
4147 if (!bp->hwrm_dma_pool) in bnxt_alloc_hwrm_resources()
4148 return -ENOMEM; in bnxt_alloc_hwrm_resources()
4150 INIT_HLIST_HEAD(&bp->hwrm_pending_list); in bnxt_alloc_hwrm_resources()
4157 kfree(stats->hw_masks); in bnxt_free_stats_mem()
4158 stats->hw_masks = NULL; in bnxt_free_stats_mem()
4159 kfree(stats->sw_stats); in bnxt_free_stats_mem()
4160 stats->sw_stats = NULL; in bnxt_free_stats_mem()
4161 if (stats->hw_stats) { in bnxt_free_stats_mem()
4162 dma_free_coherent(&bp->pdev->dev, stats->len, stats->hw_stats, in bnxt_free_stats_mem()
4163 stats->hw_stats_map); in bnxt_free_stats_mem()
4164 stats->hw_stats = NULL; in bnxt_free_stats_mem()
4171 stats->hw_stats = dma_alloc_coherent(&bp->pdev->dev, stats->len, in bnxt_alloc_stats_mem()
4172 &stats->hw_stats_map, GFP_KERNEL); in bnxt_alloc_stats_mem()
4173 if (!stats->hw_stats) in bnxt_alloc_stats_mem()
4174 return -ENOMEM; in bnxt_alloc_stats_mem()
4176 stats->sw_stats = kzalloc(stats->len, GFP_KERNEL); in bnxt_alloc_stats_mem()
4177 if (!stats->sw_stats) in bnxt_alloc_stats_mem()
4181 stats->hw_masks = kzalloc(stats->len, GFP_KERNEL); in bnxt_alloc_stats_mem()
4182 if (!stats->hw_masks) in bnxt_alloc_stats_mem()
4189 return -ENOMEM; in bnxt_alloc_stats_mem()
4216 if (!(bp->fw_cap & BNXT_FW_CAP_EXT_HW_STATS_SUPPORTED) || in bnxt_hwrm_func_qstat_ext()
4217 !(bp->flags & BNXT_FLAG_CHIP_P5)) in bnxt_hwrm_func_qstat_ext()
4218 return -EOPNOTSUPP; in bnxt_hwrm_func_qstat_ext()
4224 req->fid = cpu_to_le16(0xffff); in bnxt_hwrm_func_qstat_ext()
4225 req->flags = FUNC_QSTATS_EXT_REQ_FLAGS_COUNTER_MASK; in bnxt_hwrm_func_qstat_ext()
4230 hw_masks = &resp->rx_ucast_pkts; in bnxt_hwrm_func_qstat_ext()
4231 bnxt_copy_hw_masks(stats->hw_masks, hw_masks, stats->len / 8); in bnxt_hwrm_func_qstat_ext()
4242 struct bnxt_napi *bnapi = bp->bnapi[0]; in bnxt_init_stats()
4251 cpr = &bnapi->cp_ring; in bnxt_init_stats()
4252 stats = &cpr->stats; in bnxt_init_stats()
4255 if (bp->flags & BNXT_FLAG_CHIP_P5) in bnxt_init_stats()
4256 mask = (1ULL << 48) - 1; in bnxt_init_stats()
4258 mask = -1ULL; in bnxt_init_stats()
4259 bnxt_fill_masks(stats->hw_masks, mask, stats->len / 8); in bnxt_init_stats()
4261 if (bp->flags & BNXT_FLAG_PORT_STATS) { in bnxt_init_stats()
4262 stats = &bp->port_stats; in bnxt_init_stats()
4263 rx_stats = stats->hw_stats; in bnxt_init_stats()
4264 rx_masks = stats->hw_masks; in bnxt_init_stats()
4273 mask = (1ULL << 40) - 1; in bnxt_init_stats()
4283 if (bp->flags & BNXT_FLAG_PORT_STATS_EXT) { in bnxt_init_stats()
4284 stats = &bp->rx_port_stats_ext; in bnxt_init_stats()
4285 rx_stats = stats->hw_stats; in bnxt_init_stats()
4286 rx_masks = stats->hw_masks; in bnxt_init_stats()
4288 stats = &bp->tx_port_stats_ext; in bnxt_init_stats()
4289 tx_stats = stats->hw_stats; in bnxt_init_stats()
4290 tx_masks = stats->hw_masks; in bnxt_init_stats()
4296 mask = (1ULL << 40) - 1; in bnxt_init_stats()
4313 bp->flags &= ~BNXT_FLAG_PORT_STATS; in bnxt_free_port_stats()
4314 bp->flags &= ~BNXT_FLAG_PORT_STATS_EXT; in bnxt_free_port_stats()
4316 bnxt_free_stats_mem(bp, &bp->port_stats); in bnxt_free_port_stats()
4317 bnxt_free_stats_mem(bp, &bp->rx_port_stats_ext); in bnxt_free_port_stats()
4318 bnxt_free_stats_mem(bp, &bp->tx_port_stats_ext); in bnxt_free_port_stats()
4325 if (!bp->bnapi) in bnxt_free_ring_stats()
4328 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_free_ring_stats()
4329 struct bnxt_napi *bnapi = bp->bnapi[i]; in bnxt_free_ring_stats()
4330 struct bnxt_cp_ring_info *cpr = &bnapi->cp_ring; in bnxt_free_ring_stats()
4332 bnxt_free_stats_mem(bp, &cpr->stats); in bnxt_free_ring_stats()
4341 size = bp->hw_ring_stats_size; in bnxt_alloc_stats()
4343 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_alloc_stats()
4344 struct bnxt_napi *bnapi = bp->bnapi[i]; in bnxt_alloc_stats()
4345 struct bnxt_cp_ring_info *cpr = &bnapi->cp_ring; in bnxt_alloc_stats()
4347 cpr->stats.len = size; in bnxt_alloc_stats()
4348 rc = bnxt_alloc_stats_mem(bp, &cpr->stats, !i); in bnxt_alloc_stats()
4352 cpr->hw_stats_ctx_id = INVALID_STATS_CTX_ID; in bnxt_alloc_stats()
4355 if (BNXT_VF(bp) || bp->chip_num == CHIP_NUM_58700) in bnxt_alloc_stats()
4358 if (bp->port_stats.hw_stats) in bnxt_alloc_stats()
4361 bp->port_stats.len = BNXT_PORT_STATS_SIZE; in bnxt_alloc_stats()
4362 rc = bnxt_alloc_stats_mem(bp, &bp->port_stats, true); in bnxt_alloc_stats()
4366 bp->flags |= BNXT_FLAG_PORT_STATS; in bnxt_alloc_stats()
4370 if (bp->hwrm_spec_code < 0x10804 || bp->hwrm_spec_code == 0x10900) in bnxt_alloc_stats()
4371 if (!(bp->fw_cap & BNXT_FW_CAP_EXT_STATS_SUPPORTED)) in bnxt_alloc_stats()
4374 if (bp->rx_port_stats_ext.hw_stats) in bnxt_alloc_stats()
4377 bp->rx_port_stats_ext.len = sizeof(struct rx_port_stats_ext); in bnxt_alloc_stats()
4378 rc = bnxt_alloc_stats_mem(bp, &bp->rx_port_stats_ext, true); in bnxt_alloc_stats()
4384 if (bp->tx_port_stats_ext.hw_stats) in bnxt_alloc_stats()
4387 if (bp->hwrm_spec_code >= 0x10902 || in bnxt_alloc_stats()
4388 (bp->fw_cap & BNXT_FW_CAP_EXT_STATS_SUPPORTED)) { in bnxt_alloc_stats()
4389 bp->tx_port_stats_ext.len = sizeof(struct tx_port_stats_ext); in bnxt_alloc_stats()
4390 rc = bnxt_alloc_stats_mem(bp, &bp->tx_port_stats_ext, true); in bnxt_alloc_stats()
4395 bp->flags |= BNXT_FLAG_PORT_STATS_EXT; in bnxt_alloc_stats()
4403 if (!bp->bnapi) in bnxt_clear_ring_indices()
4406 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_clear_ring_indices()
4407 struct bnxt_napi *bnapi = bp->bnapi[i]; in bnxt_clear_ring_indices()
4415 cpr = &bnapi->cp_ring; in bnxt_clear_ring_indices()
4416 cpr->cp_raw_cons = 0; in bnxt_clear_ring_indices()
4418 txr = bnapi->tx_ring; in bnxt_clear_ring_indices()
4420 txr->tx_prod = 0; in bnxt_clear_ring_indices()
4421 txr->tx_cons = 0; in bnxt_clear_ring_indices()
4424 rxr = bnapi->rx_ring; in bnxt_clear_ring_indices()
4426 rxr->rx_prod = 0; in bnxt_clear_ring_indices()
4427 rxr->rx_agg_prod = 0; in bnxt_clear_ring_indices()
4428 rxr->rx_sw_agg_prod = 0; in bnxt_clear_ring_indices()
4429 rxr->rx_next_cons = 0; in bnxt_clear_ring_indices()
4447 head = &bp->ntp_fltr_hash_tbl[i]; in bnxt_free_ntp_fltrs()
4449 hlist_del(&fltr->hash); in bnxt_free_ntp_fltrs()
4454 bitmap_free(bp->ntp_fltr_bmap); in bnxt_free_ntp_fltrs()
4455 bp->ntp_fltr_bmap = NULL; in bnxt_free_ntp_fltrs()
4457 bp->ntp_fltr_count = 0; in bnxt_free_ntp_fltrs()
4466 if (!(bp->flags & BNXT_FLAG_RFS)) in bnxt_alloc_ntp_fltrs()
4470 INIT_HLIST_HEAD(&bp->ntp_fltr_hash_tbl[i]); in bnxt_alloc_ntp_fltrs()
4472 bp->ntp_fltr_count = 0; in bnxt_alloc_ntp_fltrs()
4473 bp->ntp_fltr_bmap = bitmap_zalloc(BNXT_NTP_FLTR_MAX_FLTR, GFP_KERNEL); in bnxt_alloc_ntp_fltrs()
4475 if (!bp->ntp_fltr_bmap) in bnxt_alloc_ntp_fltrs()
4476 rc = -ENOMEM; in bnxt_alloc_ntp_fltrs()
4494 if (!(bp->phy_flags & BNXT_PHY_FL_PORT_STATS_NO_RESET) || in bnxt_free_mem()
4495 test_bit(BNXT_STATE_IN_FW_RESET, &bp->state)) in bnxt_free_mem()
4499 kfree(bp->tx_ring_map); in bnxt_free_mem()
4500 bp->tx_ring_map = NULL; in bnxt_free_mem()
4501 kfree(bp->tx_ring); in bnxt_free_mem()
4502 bp->tx_ring = NULL; in bnxt_free_mem()
4503 kfree(bp->rx_ring); in bnxt_free_mem()
4504 bp->rx_ring = NULL; in bnxt_free_mem()
4505 kfree(bp->bnapi); in bnxt_free_mem()
4506 bp->bnapi = NULL; in bnxt_free_mem()
4522 bp->cp_nr_rings); in bnxt_alloc_mem()
4524 bnapi = kzalloc(arr_size + size * bp->cp_nr_rings, GFP_KERNEL); in bnxt_alloc_mem()
4526 return -ENOMEM; in bnxt_alloc_mem()
4528 bp->bnapi = bnapi; in bnxt_alloc_mem()
4530 for (i = 0; i < bp->cp_nr_rings; i++, bnapi += size) { in bnxt_alloc_mem()
4531 bp->bnapi[i] = bnapi; in bnxt_alloc_mem()
4532 bp->bnapi[i]->index = i; in bnxt_alloc_mem()
4533 bp->bnapi[i]->bp = bp; in bnxt_alloc_mem()
4534 if (bp->flags & BNXT_FLAG_CHIP_P5) { in bnxt_alloc_mem()
4536 &bp->bnapi[i]->cp_ring; in bnxt_alloc_mem()
4538 cpr->cp_ring_struct.ring_mem.flags = in bnxt_alloc_mem()
4543 bp->rx_ring = kcalloc(bp->rx_nr_rings, in bnxt_alloc_mem()
4546 if (!bp->rx_ring) in bnxt_alloc_mem()
4547 return -ENOMEM; in bnxt_alloc_mem()
4549 for (i = 0; i < bp->rx_nr_rings; i++) { in bnxt_alloc_mem()
4550 struct bnxt_rx_ring_info *rxr = &bp->rx_ring[i]; in bnxt_alloc_mem()
4552 if (bp->flags & BNXT_FLAG_CHIP_P5) { in bnxt_alloc_mem()
4553 rxr->rx_ring_struct.ring_mem.flags = in bnxt_alloc_mem()
4555 rxr->rx_agg_ring_struct.ring_mem.flags = in bnxt_alloc_mem()
4558 rxr->bnapi = bp->bnapi[i]; in bnxt_alloc_mem()
4559 bp->bnapi[i]->rx_ring = &bp->rx_ring[i]; in bnxt_alloc_mem()
4562 bp->tx_ring = kcalloc(bp->tx_nr_rings, in bnxt_alloc_mem()
4565 if (!bp->tx_ring) in bnxt_alloc_mem()
4566 return -ENOMEM; in bnxt_alloc_mem()
4568 bp->tx_ring_map = kcalloc(bp->tx_nr_rings, sizeof(u16), in bnxt_alloc_mem()
4571 if (!bp->tx_ring_map) in bnxt_alloc_mem()
4572 return -ENOMEM; in bnxt_alloc_mem()
4574 if (bp->flags & BNXT_FLAG_SHARED_RINGS) in bnxt_alloc_mem()
4577 j = bp->rx_nr_rings; in bnxt_alloc_mem()
4579 for (i = 0; i < bp->tx_nr_rings; i++, j++) { in bnxt_alloc_mem()
4580 struct bnxt_tx_ring_info *txr = &bp->tx_ring[i]; in bnxt_alloc_mem()
4582 if (bp->flags & BNXT_FLAG_CHIP_P5) in bnxt_alloc_mem()
4583 txr->tx_ring_struct.ring_mem.flags = in bnxt_alloc_mem()
4585 txr->bnapi = bp->bnapi[j]; in bnxt_alloc_mem()
4586 bp->bnapi[j]->tx_ring = txr; in bnxt_alloc_mem()
4587 bp->tx_ring_map[i] = bp->tx_nr_rings_xdp + i; in bnxt_alloc_mem()
4588 if (i >= bp->tx_nr_rings_xdp) { in bnxt_alloc_mem()
4589 txr->txq_index = i - bp->tx_nr_rings_xdp; in bnxt_alloc_mem()
4590 bp->bnapi[j]->tx_int = bnxt_tx_int; in bnxt_alloc_mem()
4592 bp->bnapi[j]->flags |= BNXT_NAPI_FLAG_XDP; in bnxt_alloc_mem()
4593 bp->bnapi[j]->tx_int = bnxt_tx_int_xdp; in bnxt_alloc_mem()
4629 bp->vnic_info[0].flags |= BNXT_VNIC_RSS_FLAG | BNXT_VNIC_MCAST_FLAG | in bnxt_alloc_mem()
4645 if (!bp->bnapi) in bnxt_disable_int()
4648 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_disable_int()
4649 struct bnxt_napi *bnapi = bp->bnapi[i]; in bnxt_disable_int()
4650 struct bnxt_cp_ring_info *cpr = &bnapi->cp_ring; in bnxt_disable_int()
4651 struct bnxt_ring_struct *ring = &cpr->cp_ring_struct; in bnxt_disable_int()
4653 if (ring->fw_ring_id != INVALID_HW_RING_ID) in bnxt_disable_int()
4654 bnxt_db_nq(bp, &cpr->cp_db, cpr->cp_raw_cons); in bnxt_disable_int()
4660 struct bnxt_napi *bnapi = bp->bnapi[n]; in bnxt_cp_num_to_irq_num()
4663 cpr = &bnapi->cp_ring; in bnxt_cp_num_to_irq_num()
4664 return cpr->cp_ring_struct.map_idx; in bnxt_cp_num_to_irq_num()
4671 if (!bp->irq_tbl) in bnxt_disable_int_sync()
4674 atomic_inc(&bp->intr_sem); in bnxt_disable_int_sync()
4677 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_disable_int_sync()
4680 synchronize_irq(bp->irq_tbl[map_idx].vector); in bnxt_disable_int_sync()
4688 atomic_set(&bp->intr_sem, 0); in bnxt_enable_int()
4689 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_enable_int()
4690 struct bnxt_napi *bnapi = bp->bnapi[i]; in bnxt_enable_int()
4691 struct bnxt_cp_ring_info *cpr = &bnapi->cp_ring; in bnxt_enable_int()
4693 bnxt_db_nq_arm(bp, &cpr->cp_db, cpr->cp_raw_cons); in bnxt_enable_int()
4711 req->enables = cpu_to_le32(FUNC_DRV_RGTR_REQ_ENABLES_OS_TYPE | in bnxt_hwrm_func_drv_rgtr()
4715 req->os_type = cpu_to_le16(FUNC_DRV_RGTR_REQ_OS_TYPE_LINUX); in bnxt_hwrm_func_drv_rgtr()
4717 if (bp->fw_cap & BNXT_FW_CAP_HOT_RESET) in bnxt_hwrm_func_drv_rgtr()
4719 if (bp->fw_cap & BNXT_FW_CAP_ERROR_RECOVERY) in bnxt_hwrm_func_drv_rgtr()
4722 req->flags = cpu_to_le32(flags); in bnxt_hwrm_func_drv_rgtr()
4723 req->ver_maj_8b = DRV_VER_MAJ; in bnxt_hwrm_func_drv_rgtr()
4724 req->ver_min_8b = DRV_VER_MIN; in bnxt_hwrm_func_drv_rgtr()
4725 req->ver_upd_8b = DRV_VER_UPD; in bnxt_hwrm_func_drv_rgtr()
4726 req->ver_maj = cpu_to_le16(DRV_VER_MAJ); in bnxt_hwrm_func_drv_rgtr()
4727 req->ver_min = cpu_to_le16(DRV_VER_MIN); in bnxt_hwrm_func_drv_rgtr()
4728 req->ver_upd = cpu_to_le16(DRV_VER_UPD); in bnxt_hwrm_func_drv_rgtr()
4745 req->vf_req_fwd[i] = cpu_to_le32(data[i]); in bnxt_hwrm_func_drv_rgtr()
4747 req->enables |= in bnxt_hwrm_func_drv_rgtr()
4751 if (bp->fw_cap & BNXT_FW_CAP_OVS_64BIT_HANDLE) in bnxt_hwrm_func_drv_rgtr()
4752 req->flags |= cpu_to_le32( in bnxt_hwrm_func_drv_rgtr()
4760 !(bp->fw_cap & BNXT_FW_CAP_ERROR_RECOVERY)) in bnxt_hwrm_func_drv_rgtr()
4763 !bp->ptp_cfg) in bnxt_hwrm_func_drv_rgtr()
4774 req->async_event_fwd[i] |= cpu_to_le32(events[i]); in bnxt_hwrm_func_drv_rgtr()
4777 req->enables = in bnxt_hwrm_func_drv_rgtr()
4783 set_bit(BNXT_STATE_DRV_REGISTERED, &bp->state); in bnxt_hwrm_func_drv_rgtr()
4784 if (resp->flags & in bnxt_hwrm_func_drv_rgtr()
4786 bp->fw_cap |= BNXT_FW_CAP_IF_CHANGE; in bnxt_hwrm_func_drv_rgtr()
4797 if (!test_and_clear_bit(BNXT_STATE_DRV_REGISTERED, &bp->state)) in bnxt_hwrm_func_drv_unrgtr()
4812 bp->vxlan_fw_dst_port_id == INVALID_HW_RING_ID) in bnxt_hwrm_tunnel_dst_port_free()
4815 bp->nge_fw_dst_port_id == INVALID_HW_RING_ID) in bnxt_hwrm_tunnel_dst_port_free()
4822 req->tunnel_type = tunnel_type; in bnxt_hwrm_tunnel_dst_port_free()
4826 req->tunnel_dst_port_id = cpu_to_le16(bp->vxlan_fw_dst_port_id); in bnxt_hwrm_tunnel_dst_port_free()
4827 bp->vxlan_port = 0; in bnxt_hwrm_tunnel_dst_port_free()
4828 bp->vxlan_fw_dst_port_id = INVALID_HW_RING_ID; in bnxt_hwrm_tunnel_dst_port_free()
4831 req->tunnel_dst_port_id = cpu_to_le16(bp->nge_fw_dst_port_id); in bnxt_hwrm_tunnel_dst_port_free()
4832 bp->nge_port = 0; in bnxt_hwrm_tunnel_dst_port_free()
4833 bp->nge_fw_dst_port_id = INVALID_HW_RING_ID; in bnxt_hwrm_tunnel_dst_port_free()
4841 netdev_err(bp->dev, "hwrm_tunnel_dst_port_free failed. rc:%d\n", in bnxt_hwrm_tunnel_dst_port_free()
4857 req->tunnel_type = tunnel_type; in bnxt_hwrm_tunnel_dst_port_alloc()
4858 req->tunnel_dst_port_val = port; in bnxt_hwrm_tunnel_dst_port_alloc()
4863 netdev_err(bp->dev, "hwrm_tunnel_dst_port_alloc failed. rc:%d\n", in bnxt_hwrm_tunnel_dst_port_alloc()
4870 bp->vxlan_port = port; in bnxt_hwrm_tunnel_dst_port_alloc()
4871 bp->vxlan_fw_dst_port_id = in bnxt_hwrm_tunnel_dst_port_alloc()
4872 le16_to_cpu(resp->tunnel_dst_port_id); in bnxt_hwrm_tunnel_dst_port_alloc()
4875 bp->nge_port = port; in bnxt_hwrm_tunnel_dst_port_alloc()
4876 bp->nge_fw_dst_port_id = le16_to_cpu(resp->tunnel_dst_port_id); in bnxt_hwrm_tunnel_dst_port_alloc()
4890 struct bnxt_vnic_info *vnic = &bp->vnic_info[vnic_id]; in bnxt_hwrm_cfa_l2_set_rx_mask()
4897 req->vnic_id = cpu_to_le32(vnic->fw_vnic_id); in bnxt_hwrm_cfa_l2_set_rx_mask()
4898 if (vnic->rx_mask & CFA_L2_SET_RX_MASK_REQ_MASK_MCAST) { in bnxt_hwrm_cfa_l2_set_rx_mask()
4899 req->num_mc_entries = cpu_to_le32(vnic->mc_list_count); in bnxt_hwrm_cfa_l2_set_rx_mask()
4900 req->mc_tbl_addr = cpu_to_le64(vnic->mc_list_mapping); in bnxt_hwrm_cfa_l2_set_rx_mask()
4902 req->mask = cpu_to_le32(vnic->rx_mask); in bnxt_hwrm_cfa_l2_set_rx_mask()
4917 req->ntuple_filter_id = fltr->filter_id; in bnxt_hwrm_cfa_ntuple_filter_free()
4945 struct flow_keys *keys = &fltr->fkeys; in bnxt_hwrm_cfa_ntuple_filter_alloc()
4954 req->l2_filter_id = bp->vnic_info[0].fw_l2_filter_id[fltr->l2_fltr_idx]; in bnxt_hwrm_cfa_ntuple_filter_alloc()
4956 if (bp->fw_cap & BNXT_FW_CAP_CFA_RFS_RING_TBL_IDX_V2) { in bnxt_hwrm_cfa_ntuple_filter_alloc()
4958 req->dst_id = cpu_to_le16(fltr->rxq); in bnxt_hwrm_cfa_ntuple_filter_alloc()
4960 vnic = &bp->vnic_info[fltr->rxq + 1]; in bnxt_hwrm_cfa_ntuple_filter_alloc()
4961 req->dst_id = cpu_to_le16(vnic->fw_vnic_id); in bnxt_hwrm_cfa_ntuple_filter_alloc()
4963 req->flags = cpu_to_le32(flags); in bnxt_hwrm_cfa_ntuple_filter_alloc()
4964 req->enables = cpu_to_le32(BNXT_NTP_FLTR_FLAGS); in bnxt_hwrm_cfa_ntuple_filter_alloc()
4966 req->ethertype = htons(ETH_P_IP); in bnxt_hwrm_cfa_ntuple_filter_alloc()
4967 memcpy(req->src_macaddr, fltr->src_mac_addr, ETH_ALEN); in bnxt_hwrm_cfa_ntuple_filter_alloc()
4968 req->ip_addr_type = CFA_NTUPLE_FILTER_ALLOC_REQ_IP_ADDR_TYPE_IPV4; in bnxt_hwrm_cfa_ntuple_filter_alloc()
4969 req->ip_protocol = keys->basic.ip_proto; in bnxt_hwrm_cfa_ntuple_filter_alloc()
4971 if (keys->basic.n_proto == htons(ETH_P_IPV6)) { in bnxt_hwrm_cfa_ntuple_filter_alloc()
4974 req->ethertype = htons(ETH_P_IPV6); in bnxt_hwrm_cfa_ntuple_filter_alloc()
4975 req->ip_addr_type = in bnxt_hwrm_cfa_ntuple_filter_alloc()
4977 *(struct in6_addr *)&req->src_ipaddr[0] = in bnxt_hwrm_cfa_ntuple_filter_alloc()
4978 keys->addrs.v6addrs.src; in bnxt_hwrm_cfa_ntuple_filter_alloc()
4979 *(struct in6_addr *)&req->dst_ipaddr[0] = in bnxt_hwrm_cfa_ntuple_filter_alloc()
4980 keys->addrs.v6addrs.dst; in bnxt_hwrm_cfa_ntuple_filter_alloc()
4982 req->src_ipaddr_mask[i] = cpu_to_be32(0xffffffff); in bnxt_hwrm_cfa_ntuple_filter_alloc()
4983 req->dst_ipaddr_mask[i] = cpu_to_be32(0xffffffff); in bnxt_hwrm_cfa_ntuple_filter_alloc()
4986 req->src_ipaddr[0] = keys->addrs.v4addrs.src; in bnxt_hwrm_cfa_ntuple_filter_alloc()
4987 req->src_ipaddr_mask[0] = cpu_to_be32(0xffffffff); in bnxt_hwrm_cfa_ntuple_filter_alloc()
4988 req->dst_ipaddr[0] = keys->addrs.v4addrs.dst; in bnxt_hwrm_cfa_ntuple_filter_alloc()
4989 req->dst_ipaddr_mask[0] = cpu_to_be32(0xffffffff); in bnxt_hwrm_cfa_ntuple_filter_alloc()
4991 if (keys->control.flags & FLOW_DIS_ENCAPSULATION) { in bnxt_hwrm_cfa_ntuple_filter_alloc()
4992 req->enables |= cpu_to_le32(BNXT_NTP_TUNNEL_FLTR_FLAG); in bnxt_hwrm_cfa_ntuple_filter_alloc()
4993 req->tunnel_type = in bnxt_hwrm_cfa_ntuple_filter_alloc()
4997 req->src_port = keys->ports.src; in bnxt_hwrm_cfa_ntuple_filter_alloc()
4998 req->src_port_mask = cpu_to_be16(0xffff); in bnxt_hwrm_cfa_ntuple_filter_alloc()
4999 req->dst_port = keys->ports.dst; in bnxt_hwrm_cfa_ntuple_filter_alloc()
5000 req->dst_port_mask = cpu_to_be16(0xffff); in bnxt_hwrm_cfa_ntuple_filter_alloc()
5005 fltr->filter_id = resp->ntuple_filter_id; in bnxt_hwrm_cfa_ntuple_filter_alloc()
5022 req->flags = cpu_to_le32(CFA_L2_FILTER_ALLOC_REQ_FLAGS_PATH_RX); in bnxt_hwrm_set_vnic_filter()
5024 req->flags |= in bnxt_hwrm_set_vnic_filter()
5026 req->dst_id = cpu_to_le16(bp->vnic_info[vnic_id].fw_vnic_id); in bnxt_hwrm_set_vnic_filter()
5027 req->enables = in bnxt_hwrm_set_vnic_filter()
5031 memcpy(req->l2_addr, mac_addr, ETH_ALEN); in bnxt_hwrm_set_vnic_filter()
5032 req->l2_addr_mask[0] = 0xff; in bnxt_hwrm_set_vnic_filter()
5033 req->l2_addr_mask[1] = 0xff; in bnxt_hwrm_set_vnic_filter()
5034 req->l2_addr_mask[2] = 0xff; in bnxt_hwrm_set_vnic_filter()
5035 req->l2_addr_mask[3] = 0xff; in bnxt_hwrm_set_vnic_filter()
5036 req->l2_addr_mask[4] = 0xff; in bnxt_hwrm_set_vnic_filter()
5037 req->l2_addr_mask[5] = 0xff; in bnxt_hwrm_set_vnic_filter()
5042 bp->vnic_info[vnic_id].fw_l2_filter_id[idx] = in bnxt_hwrm_set_vnic_filter()
5043 resp->l2_filter_id; in bnxt_hwrm_set_vnic_filter()
5060 struct bnxt_vnic_info *vnic = &bp->vnic_info[i]; in bnxt_hwrm_clear_vnic_filter()
5062 for (j = 0; j < vnic->uc_filter_count; j++) { in bnxt_hwrm_clear_vnic_filter()
5063 req->l2_filter_id = vnic->fw_l2_filter_id[j]; in bnxt_hwrm_clear_vnic_filter()
5067 vnic->uc_filter_count = 0; in bnxt_hwrm_clear_vnic_filter()
5075 struct bnxt_vnic_info *vnic = &bp->vnic_info[vnic_id]; in bnxt_hwrm_vnic_set_tpa()
5080 if (vnic->fw_vnic_id == INVALID_HW_RING_ID) in bnxt_hwrm_vnic_set_tpa()
5088 u16 mss = bp->dev->mtu - 40; in bnxt_hwrm_vnic_set_tpa()
5099 req->flags = cpu_to_le32(flags); in bnxt_hwrm_vnic_set_tpa()
5101 req->enables = in bnxt_hwrm_vnic_set_tpa()
5111 nsegs = (MAX_SKB_FRAGS - 1) * n; in bnxt_hwrm_vnic_set_tpa()
5114 if (mss & (BNXT_RX_PAGE_SIZE - 1)) in bnxt_hwrm_vnic_set_tpa()
5116 nsegs = (MAX_SKB_FRAGS - n) / n; in bnxt_hwrm_vnic_set_tpa()
5119 if (bp->flags & BNXT_FLAG_CHIP_P5) { in bnxt_hwrm_vnic_set_tpa()
5121 max_aggs = bp->max_tpa; in bnxt_hwrm_vnic_set_tpa()
5125 req->max_agg_segs = cpu_to_le16(segs); in bnxt_hwrm_vnic_set_tpa()
5126 req->max_aggs = cpu_to_le16(max_aggs); in bnxt_hwrm_vnic_set_tpa()
5128 req->min_agg_len = cpu_to_le32(512); in bnxt_hwrm_vnic_set_tpa()
5130 req->vnic_id = cpu_to_le16(vnic->fw_vnic_id); in bnxt_hwrm_vnic_set_tpa()
5139 grp_info = &bp->grp_info[ring->grp_idx]; in bnxt_cp_ring_from_grp()
5140 return grp_info->cp_fw_ring_id; in bnxt_cp_ring_from_grp()
5145 if (bp->flags & BNXT_FLAG_CHIP_P5) { in bnxt_cp_ring_for_rx()
5146 struct bnxt_napi *bnapi = rxr->bnapi; in bnxt_cp_ring_for_rx()
5149 cpr = bnapi->cp_ring.cp_ring_arr[BNXT_RX_HDL]; in bnxt_cp_ring_for_rx()
5150 return cpr->cp_ring_struct.fw_ring_id; in bnxt_cp_ring_for_rx()
5152 return bnxt_cp_ring_from_grp(bp, &rxr->rx_ring_struct); in bnxt_cp_ring_for_rx()
5158 if (bp->flags & BNXT_FLAG_CHIP_P5) { in bnxt_cp_ring_for_tx()
5159 struct bnxt_napi *bnapi = txr->bnapi; in bnxt_cp_ring_for_tx()
5162 cpr = bnapi->cp_ring.cp_ring_arr[BNXT_TX_HDL]; in bnxt_cp_ring_for_tx()
5163 return cpr->cp_ring_struct.fw_ring_id; in bnxt_cp_ring_for_tx()
5165 return bnxt_cp_ring_from_grp(bp, &txr->tx_ring_struct); in bnxt_cp_ring_for_tx()
5173 if (bp->flags & BNXT_FLAG_CHIP_P5) in bnxt_alloc_rss_indir_tbl()
5178 bp->rss_indir_tbl_entries = entries; in bnxt_alloc_rss_indir_tbl()
5179 bp->rss_indir_tbl = kmalloc_array(entries, sizeof(*bp->rss_indir_tbl), in bnxt_alloc_rss_indir_tbl()
5181 if (!bp->rss_indir_tbl) in bnxt_alloc_rss_indir_tbl()
5182 return -ENOMEM; in bnxt_alloc_rss_indir_tbl()
5190 if (!bp->rx_nr_rings) in bnxt_set_dflt_rss_indir_tbl()
5194 max_rings = bp->rx_nr_rings - 1; in bnxt_set_dflt_rss_indir_tbl()
5196 max_rings = bp->rx_nr_rings; in bnxt_set_dflt_rss_indir_tbl()
5198 max_entries = bnxt_get_rxfh_indir_size(bp->dev); in bnxt_set_dflt_rss_indir_tbl()
5201 bp->rss_indir_tbl[i] = ethtool_rxfh_indir_default(i, max_rings); in bnxt_set_dflt_rss_indir_tbl()
5203 pad = bp->rss_indir_tbl_entries - max_entries; in bnxt_set_dflt_rss_indir_tbl()
5205 memset(&bp->rss_indir_tbl[i], 0, pad * sizeof(u16)); in bnxt_set_dflt_rss_indir_tbl()
5212 if (!bp->rss_indir_tbl) in bnxt_get_max_rss_ring()
5215 tbl_size = bnxt_get_rxfh_indir_size(bp->dev); in bnxt_get_max_rss_ring()
5217 max_ring = max(max_ring, bp->rss_indir_tbl[i]); in bnxt_get_max_rss_ring()
5223 if (bp->flags & BNXT_FLAG_CHIP_P5) in bnxt_get_nr_rss_ctxs()
5232 bool no_rss = !(vnic->flags & BNXT_VNIC_RSS_FLAG); in bnxt_fill_hw_rss_tbl()
5238 j = bp->rss_indir_tbl[i]; in bnxt_fill_hw_rss_tbl()
5239 vnic->rss_table[i] = cpu_to_le16(vnic->fw_grp_ids[j]); in bnxt_fill_hw_rss_tbl()
5246 __le16 *ring_tbl = vnic->rss_table; in bnxt_fill_hw_rss_tbl_p5()
5250 tbl_size = bnxt_get_rxfh_indir_size(bp->dev); in bnxt_fill_hw_rss_tbl_p5()
5255 j = bp->rss_indir_tbl[i]; in bnxt_fill_hw_rss_tbl_p5()
5256 rxr = &bp->rx_ring[j]; in bnxt_fill_hw_rss_tbl_p5()
5258 ring_id = rxr->rx_ring_struct.fw_ring_id; in bnxt_fill_hw_rss_tbl_p5()
5269 if (bp->flags & BNXT_FLAG_CHIP_P5) in __bnxt_hwrm_vnic_set_rss()
5274 if (bp->rss_hash_delta) { in __bnxt_hwrm_vnic_set_rss()
5275 req->hash_type = cpu_to_le32(bp->rss_hash_delta); in __bnxt_hwrm_vnic_set_rss()
5276 if (bp->rss_hash_cfg & bp->rss_hash_delta) in __bnxt_hwrm_vnic_set_rss()
5277 req->flags |= VNIC_RSS_CFG_REQ_FLAGS_HASH_TYPE_INCLUDE; in __bnxt_hwrm_vnic_set_rss()
5279 req->flags |= VNIC_RSS_CFG_REQ_FLAGS_HASH_TYPE_EXCLUDE; in __bnxt_hwrm_vnic_set_rss()
5281 req->hash_type = cpu_to_le32(bp->rss_hash_cfg); in __bnxt_hwrm_vnic_set_rss()
5283 req->hash_mode_flags = VNIC_RSS_CFG_REQ_HASH_MODE_FLAGS_DEFAULT; in __bnxt_hwrm_vnic_set_rss()
5284 req->ring_grp_tbl_addr = cpu_to_le64(vnic->rss_table_dma_addr); in __bnxt_hwrm_vnic_set_rss()
5285 req->hash_key_tbl_addr = cpu_to_le64(vnic->rss_hash_key_dma_addr); in __bnxt_hwrm_vnic_set_rss()
5290 struct bnxt_vnic_info *vnic = &bp->vnic_info[vnic_id]; in bnxt_hwrm_vnic_set_rss()
5294 if ((bp->flags & BNXT_FLAG_CHIP_P5) || in bnxt_hwrm_vnic_set_rss()
5295 vnic->fw_rss_cos_lb_ctx[0] == INVALID_HW_RING_ID) in bnxt_hwrm_vnic_set_rss()
5304 req->rss_ctx_idx = cpu_to_le16(vnic->fw_rss_cos_lb_ctx[0]); in bnxt_hwrm_vnic_set_rss()
5310 struct bnxt_vnic_info *vnic = &bp->vnic_info[vnic_id]; in bnxt_hwrm_vnic_set_rss_p5()
5320 req->vnic_id = cpu_to_le16(vnic->fw_vnic_id); in bnxt_hwrm_vnic_set_rss_p5()
5325 ring_tbl_map = vnic->rss_table_dma_addr; in bnxt_hwrm_vnic_set_rss_p5()
5326 nr_ctxs = bnxt_get_nr_rss_ctxs(bp, bp->rx_nr_rings); in bnxt_hwrm_vnic_set_rss_p5()
5330 req->ring_grp_tbl_addr = cpu_to_le64(ring_tbl_map); in bnxt_hwrm_vnic_set_rss_p5()
5331 req->ring_table_pair_index = i; in bnxt_hwrm_vnic_set_rss_p5()
5332 req->rss_ctx_idx = cpu_to_le16(vnic->fw_rss_cos_lb_ctx[i]); in bnxt_hwrm_vnic_set_rss_p5()
5345 struct bnxt_vnic_info *vnic = &bp->vnic_info[0]; in bnxt_hwrm_update_rss_hash_cfg()
5352 req->vnic_id = cpu_to_le16(vnic->fw_vnic_id); in bnxt_hwrm_update_rss_hash_cfg()
5354 req->rss_ctx_idx = cpu_to_le16(vnic->fw_rss_cos_lb_ctx[0]); in bnxt_hwrm_update_rss_hash_cfg()
5357 bp->rss_hash_cfg = le32_to_cpu(resp->hash_type) ?: bp->rss_hash_cfg; in bnxt_hwrm_update_rss_hash_cfg()
5358 bp->rss_hash_delta = 0; in bnxt_hwrm_update_rss_hash_cfg()
5365 struct bnxt_vnic_info *vnic = &bp->vnic_info[vnic_id]; in bnxt_hwrm_vnic_set_hds()
5373 req->flags = cpu_to_le32(VNIC_PLCMODES_CFG_REQ_FLAGS_JUMBO_PLACEMENT); in bnxt_hwrm_vnic_set_hds()
5374 req->enables = cpu_to_le32(VNIC_PLCMODES_CFG_REQ_ENABLES_JUMBO_THRESH_VALID); in bnxt_hwrm_vnic_set_hds()
5377 req->jumbo_thresh = cpu_to_le16(bp->rx_buf_use_size); in bnxt_hwrm_vnic_set_hds()
5379 req->flags |= cpu_to_le32(VNIC_PLCMODES_CFG_REQ_FLAGS_HDS_IPV4 | in bnxt_hwrm_vnic_set_hds()
5381 req->enables |= in bnxt_hwrm_vnic_set_hds()
5383 req->jumbo_thresh = cpu_to_le16(bp->rx_copy_thresh); in bnxt_hwrm_vnic_set_hds()
5384 req->hds_threshold = cpu_to_le16(bp->rx_copy_thresh); in bnxt_hwrm_vnic_set_hds()
5386 req->vnic_id = cpu_to_le32(vnic->fw_vnic_id); in bnxt_hwrm_vnic_set_hds()
5398 req->rss_cos_lb_ctx_id = in bnxt_hwrm_vnic_ctx_free_one()
5399 cpu_to_le16(bp->vnic_info[vnic_id].fw_rss_cos_lb_ctx[ctx_idx]); in bnxt_hwrm_vnic_ctx_free_one()
5402 bp->vnic_info[vnic_id].fw_rss_cos_lb_ctx[ctx_idx] = INVALID_HW_RING_ID; in bnxt_hwrm_vnic_ctx_free_one()
5409 for (i = 0; i < bp->nr_vnics; i++) { in bnxt_hwrm_vnic_ctx_free()
5410 struct bnxt_vnic_info *vnic = &bp->vnic_info[i]; in bnxt_hwrm_vnic_ctx_free()
5413 if (vnic->fw_rss_cos_lb_ctx[j] != INVALID_HW_RING_ID) in bnxt_hwrm_vnic_ctx_free()
5417 bp->rsscos_nr_ctxs = 0; in bnxt_hwrm_vnic_ctx_free()
5433 bp->vnic_info[vnic_id].fw_rss_cos_lb_ctx[ctx_idx] = in bnxt_hwrm_vnic_ctx_alloc()
5434 le16_to_cpu(resp->rss_cos_lb_ctx_id); in bnxt_hwrm_vnic_ctx_alloc()
5442 if (bp->flags & BNXT_FLAG_ROCE_MIRROR_CAP) in bnxt_get_roce_vnic_mode()
5449 struct bnxt_vnic_info *vnic = &bp->vnic_info[vnic_id]; in bnxt_hwrm_vnic_cfg()
5459 if (bp->flags & BNXT_FLAG_CHIP_P5) { in bnxt_hwrm_vnic_cfg()
5460 struct bnxt_rx_ring_info *rxr = &bp->rx_ring[0]; in bnxt_hwrm_vnic_cfg()
5462 req->default_rx_ring_id = in bnxt_hwrm_vnic_cfg()
5463 cpu_to_le16(rxr->rx_ring_struct.fw_ring_id); in bnxt_hwrm_vnic_cfg()
5464 req->default_cmpl_ring_id = in bnxt_hwrm_vnic_cfg()
5466 req->enables = in bnxt_hwrm_vnic_cfg()
5471 req->enables = cpu_to_le32(VNIC_CFG_REQ_ENABLES_DFLT_RING_GRP); in bnxt_hwrm_vnic_cfg()
5473 if (vnic->fw_rss_cos_lb_ctx[0] != INVALID_HW_RING_ID) { in bnxt_hwrm_vnic_cfg()
5474 req->rss_rule = cpu_to_le16(vnic->fw_rss_cos_lb_ctx[0]); in bnxt_hwrm_vnic_cfg()
5475 req->enables |= cpu_to_le32(VNIC_CFG_REQ_ENABLES_RSS_RULE | in bnxt_hwrm_vnic_cfg()
5477 } else if (vnic->flags & BNXT_VNIC_RFS_NEW_RSS_FLAG) { in bnxt_hwrm_vnic_cfg()
5478 req->rss_rule = in bnxt_hwrm_vnic_cfg()
5479 cpu_to_le16(bp->vnic_info[0].fw_rss_cos_lb_ctx[0]); in bnxt_hwrm_vnic_cfg()
5480 req->enables |= cpu_to_le32(VNIC_CFG_REQ_ENABLES_RSS_RULE | in bnxt_hwrm_vnic_cfg()
5482 req->flags |= cpu_to_le32(VNIC_CFG_REQ_FLAGS_RSS_DFLT_CR_MODE); in bnxt_hwrm_vnic_cfg()
5484 req->rss_rule = cpu_to_le16(0xffff); in bnxt_hwrm_vnic_cfg()
5488 (vnic->fw_rss_cos_lb_ctx[0] != INVALID_HW_RING_ID)) { in bnxt_hwrm_vnic_cfg()
5489 req->cos_rule = cpu_to_le16(vnic->fw_rss_cos_lb_ctx[1]); in bnxt_hwrm_vnic_cfg()
5490 req->enables |= cpu_to_le32(VNIC_CFG_REQ_ENABLES_COS_RULE); in bnxt_hwrm_vnic_cfg()
5492 req->cos_rule = cpu_to_le16(0xffff); in bnxt_hwrm_vnic_cfg()
5495 if (vnic->flags & BNXT_VNIC_RSS_FLAG) in bnxt_hwrm_vnic_cfg()
5497 else if (vnic->flags & BNXT_VNIC_RFS_FLAG) in bnxt_hwrm_vnic_cfg()
5498 ring = vnic_id - 1; in bnxt_hwrm_vnic_cfg()
5500 ring = bp->rx_nr_rings - 1; in bnxt_hwrm_vnic_cfg()
5502 grp_idx = bp->rx_ring[ring].bnapi->index; in bnxt_hwrm_vnic_cfg()
5503 req->dflt_ring_grp = cpu_to_le16(bp->grp_info[grp_idx].fw_grp_id); in bnxt_hwrm_vnic_cfg()
5504 req->lb_rule = cpu_to_le16(0xffff); in bnxt_hwrm_vnic_cfg()
5506 req->mru = cpu_to_le16(bp->dev->mtu + ETH_HLEN + VLAN_HLEN); in bnxt_hwrm_vnic_cfg()
5508 req->vnic_id = cpu_to_le16(vnic->fw_vnic_id); in bnxt_hwrm_vnic_cfg()
5511 def_vlan = bp->vf.vlan; in bnxt_hwrm_vnic_cfg()
5513 if ((bp->flags & BNXT_FLAG_STRIP_VLAN) || def_vlan) in bnxt_hwrm_vnic_cfg()
5514 req->flags |= cpu_to_le32(VNIC_CFG_REQ_FLAGS_VLAN_STRIP_MODE); in bnxt_hwrm_vnic_cfg()
5515 if (!vnic_id && bnxt_ulp_registered(bp->edev)) in bnxt_hwrm_vnic_cfg()
5516 req->flags |= cpu_to_le32(bnxt_get_roce_vnic_mode(bp)); in bnxt_hwrm_vnic_cfg()
5523 if (bp->vnic_info[vnic_id].fw_vnic_id != INVALID_HW_RING_ID) { in bnxt_hwrm_vnic_free_one()
5529 req->vnic_id = in bnxt_hwrm_vnic_free_one()
5530 cpu_to_le32(bp->vnic_info[vnic_id].fw_vnic_id); in bnxt_hwrm_vnic_free_one()
5533 bp->vnic_info[vnic_id].fw_vnic_id = INVALID_HW_RING_ID; in bnxt_hwrm_vnic_free_one()
5541 for (i = 0; i < bp->nr_vnics; i++) in bnxt_hwrm_vnic_free()
5550 struct bnxt_vnic_info *vnic = &bp->vnic_info[vnic_id]; in bnxt_hwrm_vnic_alloc()
5559 if (bp->flags & BNXT_FLAG_CHIP_P5) in bnxt_hwrm_vnic_alloc()
5564 grp_idx = bp->rx_ring[i].bnapi->index; in bnxt_hwrm_vnic_alloc()
5565 if (bp->grp_info[grp_idx].fw_grp_id == INVALID_HW_RING_ID) { in bnxt_hwrm_vnic_alloc()
5566 netdev_err(bp->dev, "Not enough ring groups avail:%x req:%x\n", in bnxt_hwrm_vnic_alloc()
5570 vnic->fw_grp_ids[j] = bp->grp_info[grp_idx].fw_grp_id; in bnxt_hwrm_vnic_alloc()
5575 vnic->fw_rss_cos_lb_ctx[i] = INVALID_HW_RING_ID; in bnxt_hwrm_vnic_alloc()
5577 req->flags = cpu_to_le32(VNIC_ALLOC_REQ_FLAGS_DEFAULT); in bnxt_hwrm_vnic_alloc()
5582 vnic->fw_vnic_id = le32_to_cpu(resp->vnic_id); in bnxt_hwrm_vnic_alloc()
5593 bp->hw_ring_stats_size = sizeof(struct ctx_hw_stats); in bnxt_hwrm_vnic_qcaps()
5594 bp->flags &= ~(BNXT_FLAG_NEW_RSS_CAP | BNXT_FLAG_ROCE_MIRROR_CAP); in bnxt_hwrm_vnic_qcaps()
5595 if (bp->hwrm_spec_code < 0x10600) in bnxt_hwrm_vnic_qcaps()
5605 u32 flags = le32_to_cpu(resp->flags); in bnxt_hwrm_vnic_qcaps()
5607 if (!(bp->flags & BNXT_FLAG_CHIP_P5) && in bnxt_hwrm_vnic_qcaps()
5609 bp->flags |= BNXT_FLAG_NEW_RSS_CAP; in bnxt_hwrm_vnic_qcaps()
5612 bp->flags |= BNXT_FLAG_ROCE_MIRROR_CAP; in bnxt_hwrm_vnic_qcaps()
5619 !(bp->fw_cap & BNXT_FW_CAP_EXT_HW_STATS_SUPPORTED))) in bnxt_hwrm_vnic_qcaps()
5620 bp->fw_cap |= BNXT_FW_CAP_VLAN_RX_STRIP; in bnxt_hwrm_vnic_qcaps()
5622 bp->fw_cap |= BNXT_FW_CAP_RSS_HASH_TYPE_DELTA; in bnxt_hwrm_vnic_qcaps()
5623 bp->max_tpa_v2 = le16_to_cpu(resp->max_aggs_supported); in bnxt_hwrm_vnic_qcaps()
5624 if (bp->max_tpa_v2) { in bnxt_hwrm_vnic_qcaps()
5626 bp->hw_ring_stats_size = BNXT_RING_STATS_SIZE_P5; in bnxt_hwrm_vnic_qcaps()
5628 bp->hw_ring_stats_size = BNXT_RING_STATS_SIZE_P5_SR2; in bnxt_hwrm_vnic_qcaps()
5642 if (bp->flags & BNXT_FLAG_CHIP_P5) in bnxt_hwrm_ring_grp_alloc()
5650 for (i = 0; i < bp->rx_nr_rings; i++) { in bnxt_hwrm_ring_grp_alloc()
5651 unsigned int grp_idx = bp->rx_ring[i].bnapi->index; in bnxt_hwrm_ring_grp_alloc()
5653 req->cr = cpu_to_le16(bp->grp_info[grp_idx].cp_fw_ring_id); in bnxt_hwrm_ring_grp_alloc()
5654 req->rr = cpu_to_le16(bp->grp_info[grp_idx].rx_fw_ring_id); in bnxt_hwrm_ring_grp_alloc()
5655 req->ar = cpu_to_le16(bp->grp_info[grp_idx].agg_fw_ring_id); in bnxt_hwrm_ring_grp_alloc()
5656 req->sc = cpu_to_le16(bp->grp_info[grp_idx].fw_stats_ctx); in bnxt_hwrm_ring_grp_alloc()
5663 bp->grp_info[grp_idx].fw_grp_id = in bnxt_hwrm_ring_grp_alloc()
5664 le32_to_cpu(resp->ring_group_id); in bnxt_hwrm_ring_grp_alloc()
5675 if (!bp->grp_info || (bp->flags & BNXT_FLAG_CHIP_P5)) in bnxt_hwrm_ring_grp_free()
5682 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_hwrm_ring_grp_free()
5683 if (bp->grp_info[i].fw_grp_id == INVALID_HW_RING_ID) in bnxt_hwrm_ring_grp_free()
5685 req->ring_group_id = in bnxt_hwrm_ring_grp_free()
5686 cpu_to_le32(bp->grp_info[i].fw_grp_id); in bnxt_hwrm_ring_grp_free()
5689 bp->grp_info[i].fw_grp_id = INVALID_HW_RING_ID; in bnxt_hwrm_ring_grp_free()
5700 struct bnxt_ring_mem_info *rmem = &ring->ring_mem; in hwrm_ring_alloc_send_msg()
5709 req->enables = 0; in hwrm_ring_alloc_send_msg()
5710 if (rmem->nr_pages > 1) { in hwrm_ring_alloc_send_msg()
5711 req->page_tbl_addr = cpu_to_le64(rmem->pg_tbl_map); in hwrm_ring_alloc_send_msg()
5713 req->page_size = BNXT_PAGE_SHIFT; in hwrm_ring_alloc_send_msg()
5714 req->page_tbl_depth = 1; in hwrm_ring_alloc_send_msg()
5716 req->page_tbl_addr = cpu_to_le64(rmem->dma_arr[0]); in hwrm_ring_alloc_send_msg()
5718 req->fbo = 0; in hwrm_ring_alloc_send_msg()
5720 req->logical_id = cpu_to_le16(map_index); in hwrm_ring_alloc_send_msg()
5728 req->ring_type = RING_ALLOC_REQ_RING_TYPE_TX; in hwrm_ring_alloc_send_msg()
5730 grp_info = &bp->grp_info[ring->grp_idx]; in hwrm_ring_alloc_send_msg()
5731 req->cmpl_ring_id = cpu_to_le16(bnxt_cp_ring_for_tx(bp, txr)); in hwrm_ring_alloc_send_msg()
5732 req->length = cpu_to_le32(bp->tx_ring_mask + 1); in hwrm_ring_alloc_send_msg()
5733 req->stat_ctx_id = cpu_to_le32(grp_info->fw_stats_ctx); in hwrm_ring_alloc_send_msg()
5734 req->queue_id = cpu_to_le16(ring->queue_id); in hwrm_ring_alloc_send_msg()
5738 req->ring_type = RING_ALLOC_REQ_RING_TYPE_RX; in hwrm_ring_alloc_send_msg()
5739 req->length = cpu_to_le32(bp->rx_ring_mask + 1); in hwrm_ring_alloc_send_msg()
5740 if (bp->flags & BNXT_FLAG_CHIP_P5) { in hwrm_ring_alloc_send_msg()
5744 grp_info = &bp->grp_info[ring->grp_idx]; in hwrm_ring_alloc_send_msg()
5745 req->rx_buf_size = cpu_to_le16(bp->rx_buf_use_size); in hwrm_ring_alloc_send_msg()
5746 req->stat_ctx_id = cpu_to_le32(grp_info->fw_stats_ctx); in hwrm_ring_alloc_send_msg()
5747 req->enables |= cpu_to_le32( in hwrm_ring_alloc_send_msg()
5751 req->flags = cpu_to_le16(flags); in hwrm_ring_alloc_send_msg()
5755 if (bp->flags & BNXT_FLAG_CHIP_P5) { in hwrm_ring_alloc_send_msg()
5756 req->ring_type = RING_ALLOC_REQ_RING_TYPE_RX_AGG; in hwrm_ring_alloc_send_msg()
5758 grp_info = &bp->grp_info[ring->grp_idx]; in hwrm_ring_alloc_send_msg()
5759 req->rx_ring_id = cpu_to_le16(grp_info->rx_fw_ring_id); in hwrm_ring_alloc_send_msg()
5760 req->rx_buf_size = cpu_to_le16(BNXT_RX_PAGE_SIZE); in hwrm_ring_alloc_send_msg()
5761 req->stat_ctx_id = cpu_to_le32(grp_info->fw_stats_ctx); in hwrm_ring_alloc_send_msg()
5762 req->enables |= cpu_to_le32( in hwrm_ring_alloc_send_msg()
5766 req->ring_type = RING_ALLOC_REQ_RING_TYPE_RX; in hwrm_ring_alloc_send_msg()
5768 req->length = cpu_to_le32(bp->rx_agg_ring_mask + 1); in hwrm_ring_alloc_send_msg()
5771 req->ring_type = RING_ALLOC_REQ_RING_TYPE_L2_CMPL; in hwrm_ring_alloc_send_msg()
5772 req->length = cpu_to_le32(bp->cp_ring_mask + 1); in hwrm_ring_alloc_send_msg()
5773 if (bp->flags & BNXT_FLAG_CHIP_P5) { in hwrm_ring_alloc_send_msg()
5775 grp_info = &bp->grp_info[map_index]; in hwrm_ring_alloc_send_msg()
5776 req->nq_ring_id = cpu_to_le16(grp_info->cp_fw_ring_id); in hwrm_ring_alloc_send_msg()
5777 req->cq_handle = cpu_to_le64(ring->handle); in hwrm_ring_alloc_send_msg()
5778 req->enables |= cpu_to_le32( in hwrm_ring_alloc_send_msg()
5780 } else if (bp->flags & BNXT_FLAG_USING_MSIX) { in hwrm_ring_alloc_send_msg()
5781 req->int_mode = RING_ALLOC_REQ_INT_MODE_MSIX; in hwrm_ring_alloc_send_msg()
5785 req->ring_type = RING_ALLOC_REQ_RING_TYPE_NQ; in hwrm_ring_alloc_send_msg()
5786 req->length = cpu_to_le32(bp->cp_ring_mask + 1); in hwrm_ring_alloc_send_msg()
5787 if (bp->flags & BNXT_FLAG_USING_MSIX) in hwrm_ring_alloc_send_msg()
5788 req->int_mode = RING_ALLOC_REQ_INT_MODE_MSIX; in hwrm_ring_alloc_send_msg()
5791 netdev_err(bp->dev, "hwrm alloc invalid ring type %d\n", in hwrm_ring_alloc_send_msg()
5793 return -1; in hwrm_ring_alloc_send_msg()
5798 err = le16_to_cpu(resp->error_code); in hwrm_ring_alloc_send_msg()
5799 ring_id = le16_to_cpu(resp->ring_id); in hwrm_ring_alloc_send_msg()
5804 netdev_err(bp->dev, "hwrm_ring_alloc type %d failed. rc:%x err:%x\n", in hwrm_ring_alloc_send_msg()
5806 return -EIO; in hwrm_ring_alloc_send_msg()
5808 ring->fw_ring_id = ring_id; in hwrm_ring_alloc_send_msg()
5823 req->fid = cpu_to_le16(0xffff); in bnxt_hwrm_set_async_event_cr()
5824 req->enables = cpu_to_le32(FUNC_CFG_REQ_ENABLES_ASYNC_EVENT_CR); in bnxt_hwrm_set_async_event_cr()
5825 req->async_event_cr = cpu_to_le16(idx); in bnxt_hwrm_set_async_event_cr()
5834 req->enables = in bnxt_hwrm_set_async_event_cr()
5836 req->async_event_cr = cpu_to_le16(idx); in bnxt_hwrm_set_async_event_cr()
5844 if (bp->flags & BNXT_FLAG_CHIP_P5) { in bnxt_set_db()
5846 db->doorbell = bp->bar1 + DB_PF_OFFSET_P5; in bnxt_set_db()
5848 db->doorbell = bp->bar1 + DB_VF_OFFSET_P5; in bnxt_set_db()
5851 db->db_key64 = DBR_PATH_L2 | DBR_TYPE_SQ; in bnxt_set_db()
5855 db->db_key64 = DBR_PATH_L2 | DBR_TYPE_SRQ; in bnxt_set_db()
5858 db->db_key64 = DBR_PATH_L2; in bnxt_set_db()
5861 db->db_key64 = DBR_PATH_L2; in bnxt_set_db()
5864 db->db_key64 |= (u64)xid << DBR_XID_SFT; in bnxt_set_db()
5866 db->doorbell = bp->bar1 + map_idx * 0x80; in bnxt_set_db()
5869 db->db_key32 = DB_KEY_TX; in bnxt_set_db()
5873 db->db_key32 = DB_KEY_RX; in bnxt_set_db()
5876 db->db_key32 = DB_KEY_CP; in bnxt_set_db()
5884 bool agg_rings = !!(bp->flags & BNXT_FLAG_AGG_RINGS); in bnxt_hwrm_ring_alloc()
5888 if (bp->flags & BNXT_FLAG_CHIP_P5) in bnxt_hwrm_ring_alloc()
5892 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_hwrm_ring_alloc()
5893 struct bnxt_napi *bnapi = bp->bnapi[i]; in bnxt_hwrm_ring_alloc()
5894 struct bnxt_cp_ring_info *cpr = &bnapi->cp_ring; in bnxt_hwrm_ring_alloc()
5895 struct bnxt_ring_struct *ring = &cpr->cp_ring_struct; in bnxt_hwrm_ring_alloc()
5896 u32 map_idx = ring->map_idx; in bnxt_hwrm_ring_alloc()
5899 vector = bp->irq_tbl[map_idx].vector; in bnxt_hwrm_ring_alloc()
5906 bnxt_set_db(bp, &cpr->cp_db, type, map_idx, ring->fw_ring_id); in bnxt_hwrm_ring_alloc()
5907 bnxt_db_nq(bp, &cpr->cp_db, cpr->cp_raw_cons); in bnxt_hwrm_ring_alloc()
5909 bp->grp_info[i].cp_fw_ring_id = ring->fw_ring_id; in bnxt_hwrm_ring_alloc()
5912 rc = bnxt_hwrm_set_async_event_cr(bp, ring->fw_ring_id); in bnxt_hwrm_ring_alloc()
5914 netdev_warn(bp->dev, "Failed to set async event completion ring.\n"); in bnxt_hwrm_ring_alloc()
5919 for (i = 0; i < bp->tx_nr_rings; i++) { in bnxt_hwrm_ring_alloc()
5920 struct bnxt_tx_ring_info *txr = &bp->tx_ring[i]; in bnxt_hwrm_ring_alloc()
5924 if (bp->flags & BNXT_FLAG_CHIP_P5) { in bnxt_hwrm_ring_alloc()
5925 struct bnxt_napi *bnapi = txr->bnapi; in bnxt_hwrm_ring_alloc()
5929 cpr = &bnapi->cp_ring; in bnxt_hwrm_ring_alloc()
5930 cpr2 = cpr->cp_ring_arr[BNXT_TX_HDL]; in bnxt_hwrm_ring_alloc()
5931 ring = &cpr2->cp_ring_struct; in bnxt_hwrm_ring_alloc()
5932 ring->handle = BNXT_TX_HDL; in bnxt_hwrm_ring_alloc()
5933 map_idx = bnapi->index; in bnxt_hwrm_ring_alloc()
5937 bnxt_set_db(bp, &cpr2->cp_db, type2, map_idx, in bnxt_hwrm_ring_alloc()
5938 ring->fw_ring_id); in bnxt_hwrm_ring_alloc()
5939 bnxt_db_cq(bp, &cpr2->cp_db, cpr2->cp_raw_cons); in bnxt_hwrm_ring_alloc()
5941 ring = &txr->tx_ring_struct; in bnxt_hwrm_ring_alloc()
5946 bnxt_set_db(bp, &txr->tx_db, type, map_idx, ring->fw_ring_id); in bnxt_hwrm_ring_alloc()
5950 for (i = 0; i < bp->rx_nr_rings; i++) { in bnxt_hwrm_ring_alloc()
5951 struct bnxt_rx_ring_info *rxr = &bp->rx_ring[i]; in bnxt_hwrm_ring_alloc()
5952 struct bnxt_ring_struct *ring = &rxr->rx_ring_struct; in bnxt_hwrm_ring_alloc()
5953 struct bnxt_napi *bnapi = rxr->bnapi; in bnxt_hwrm_ring_alloc()
5954 u32 map_idx = bnapi->index; in bnxt_hwrm_ring_alloc()
5959 bnxt_set_db(bp, &rxr->rx_db, type, map_idx, ring->fw_ring_id); in bnxt_hwrm_ring_alloc()
5962 bnxt_db_write(bp, &rxr->rx_db, rxr->rx_prod); in bnxt_hwrm_ring_alloc()
5963 bp->grp_info[map_idx].rx_fw_ring_id = ring->fw_ring_id; in bnxt_hwrm_ring_alloc()
5964 if (bp->flags & BNXT_FLAG_CHIP_P5) { in bnxt_hwrm_ring_alloc()
5965 struct bnxt_cp_ring_info *cpr = &bnapi->cp_ring; in bnxt_hwrm_ring_alloc()
5969 cpr2 = cpr->cp_ring_arr[BNXT_RX_HDL]; in bnxt_hwrm_ring_alloc()
5970 ring = &cpr2->cp_ring_struct; in bnxt_hwrm_ring_alloc()
5971 ring->handle = BNXT_RX_HDL; in bnxt_hwrm_ring_alloc()
5975 bnxt_set_db(bp, &cpr2->cp_db, type2, map_idx, in bnxt_hwrm_ring_alloc()
5976 ring->fw_ring_id); in bnxt_hwrm_ring_alloc()
5977 bnxt_db_cq(bp, &cpr2->cp_db, cpr2->cp_raw_cons); in bnxt_hwrm_ring_alloc()
5983 for (i = 0; i < bp->rx_nr_rings; i++) { in bnxt_hwrm_ring_alloc()
5984 struct bnxt_rx_ring_info *rxr = &bp->rx_ring[i]; in bnxt_hwrm_ring_alloc()
5986 &rxr->rx_agg_ring_struct; in bnxt_hwrm_ring_alloc()
5987 u32 grp_idx = ring->grp_idx; in bnxt_hwrm_ring_alloc()
5988 u32 map_idx = grp_idx + bp->rx_nr_rings; in bnxt_hwrm_ring_alloc()
5994 bnxt_set_db(bp, &rxr->rx_agg_db, type, map_idx, in bnxt_hwrm_ring_alloc()
5995 ring->fw_ring_id); in bnxt_hwrm_ring_alloc()
5996 bnxt_db_write(bp, &rxr->rx_agg_db, rxr->rx_agg_prod); in bnxt_hwrm_ring_alloc()
5997 bnxt_db_write(bp, &rxr->rx_db, rxr->rx_prod); in bnxt_hwrm_ring_alloc()
5998 bp->grp_info[grp_idx].agg_fw_ring_id = ring->fw_ring_id; in bnxt_hwrm_ring_alloc()
6021 req->cmpl_ring = cpu_to_le16(cmpl_ring_id); in hwrm_ring_free_send_msg()
6022 req->ring_type = ring_type; in hwrm_ring_free_send_msg()
6023 req->ring_id = cpu_to_le16(ring->fw_ring_id); in hwrm_ring_free_send_msg()
6027 error_code = le16_to_cpu(resp->error_code); in hwrm_ring_free_send_msg()
6031 netdev_err(bp->dev, "hwrm_ring_free type %d failed. rc:%x err:%x\n", in hwrm_ring_free_send_msg()
6033 return -EIO; in hwrm_ring_free_send_msg()
6043 if (!bp->bnapi) in bnxt_hwrm_ring_free()
6046 for (i = 0; i < bp->tx_nr_rings; i++) { in bnxt_hwrm_ring_free()
6047 struct bnxt_tx_ring_info *txr = &bp->tx_ring[i]; in bnxt_hwrm_ring_free()
6048 struct bnxt_ring_struct *ring = &txr->tx_ring_struct; in bnxt_hwrm_ring_free()
6050 if (ring->fw_ring_id != INVALID_HW_RING_ID) { in bnxt_hwrm_ring_free()
6057 ring->fw_ring_id = INVALID_HW_RING_ID; in bnxt_hwrm_ring_free()
6061 for (i = 0; i < bp->rx_nr_rings; i++) { in bnxt_hwrm_ring_free()
6062 struct bnxt_rx_ring_info *rxr = &bp->rx_ring[i]; in bnxt_hwrm_ring_free()
6063 struct bnxt_ring_struct *ring = &rxr->rx_ring_struct; in bnxt_hwrm_ring_free()
6064 u32 grp_idx = rxr->bnapi->index; in bnxt_hwrm_ring_free()
6066 if (ring->fw_ring_id != INVALID_HW_RING_ID) { in bnxt_hwrm_ring_free()
6073 ring->fw_ring_id = INVALID_HW_RING_ID; in bnxt_hwrm_ring_free()
6074 bp->grp_info[grp_idx].rx_fw_ring_id = in bnxt_hwrm_ring_free()
6079 if (bp->flags & BNXT_FLAG_CHIP_P5) in bnxt_hwrm_ring_free()
6083 for (i = 0; i < bp->rx_nr_rings; i++) { in bnxt_hwrm_ring_free()
6084 struct bnxt_rx_ring_info *rxr = &bp->rx_ring[i]; in bnxt_hwrm_ring_free()
6085 struct bnxt_ring_struct *ring = &rxr->rx_agg_ring_struct; in bnxt_hwrm_ring_free()
6086 u32 grp_idx = rxr->bnapi->index; in bnxt_hwrm_ring_free()
6088 if (ring->fw_ring_id != INVALID_HW_RING_ID) { in bnxt_hwrm_ring_free()
6094 ring->fw_ring_id = INVALID_HW_RING_ID; in bnxt_hwrm_ring_free()
6095 bp->grp_info[grp_idx].agg_fw_ring_id = in bnxt_hwrm_ring_free()
6106 if (bp->flags & BNXT_FLAG_CHIP_P5) in bnxt_hwrm_ring_free()
6110 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_hwrm_ring_free()
6111 struct bnxt_napi *bnapi = bp->bnapi[i]; in bnxt_hwrm_ring_free()
6112 struct bnxt_cp_ring_info *cpr = &bnapi->cp_ring; in bnxt_hwrm_ring_free()
6117 struct bnxt_cp_ring_info *cpr2 = cpr->cp_ring_arr[j]; in bnxt_hwrm_ring_free()
6120 ring = &cpr2->cp_ring_struct; in bnxt_hwrm_ring_free()
6121 if (ring->fw_ring_id == INVALID_HW_RING_ID) in bnxt_hwrm_ring_free()
6126 ring->fw_ring_id = INVALID_HW_RING_ID; in bnxt_hwrm_ring_free()
6129 ring = &cpr->cp_ring_struct; in bnxt_hwrm_ring_free()
6130 if (ring->fw_ring_id != INVALID_HW_RING_ID) { in bnxt_hwrm_ring_free()
6133 ring->fw_ring_id = INVALID_HW_RING_ID; in bnxt_hwrm_ring_free()
6134 bp->grp_info[i].cp_fw_ring_id = INVALID_HW_RING_ID; in bnxt_hwrm_ring_free()
6144 struct bnxt_hw_resc *hw_resc = &bp->hw_resc; in bnxt_hwrm_get_rings()
6149 if (bp->hwrm_spec_code < 0x10601) in bnxt_hwrm_get_rings()
6156 req->fid = cpu_to_le16(0xffff); in bnxt_hwrm_get_rings()
6164 hw_resc->resv_tx_rings = le16_to_cpu(resp->alloc_tx_rings); in bnxt_hwrm_get_rings()
6168 hw_resc->resv_rx_rings = le16_to_cpu(resp->alloc_rx_rings); in bnxt_hwrm_get_rings()
6169 hw_resc->resv_hw_ring_grps = in bnxt_hwrm_get_rings()
6170 le32_to_cpu(resp->alloc_hw_ring_grps); in bnxt_hwrm_get_rings()
6171 hw_resc->resv_vnics = le16_to_cpu(resp->alloc_vnics); in bnxt_hwrm_get_rings()
6172 cp = le16_to_cpu(resp->alloc_cmpl_rings); in bnxt_hwrm_get_rings()
6173 stats = le16_to_cpu(resp->alloc_stat_ctx); in bnxt_hwrm_get_rings()
6174 hw_resc->resv_irqs = cp; in bnxt_hwrm_get_rings()
6175 if (bp->flags & BNXT_FLAG_CHIP_P5) { in bnxt_hwrm_get_rings()
6176 int rx = hw_resc->resv_rx_rings; in bnxt_hwrm_get_rings()
6177 int tx = hw_resc->resv_tx_rings; in bnxt_hwrm_get_rings()
6179 if (bp->flags & BNXT_FLAG_AGG_RINGS) in bnxt_hwrm_get_rings()
6183 if (bp->flags & BNXT_FLAG_AGG_RINGS) in bnxt_hwrm_get_rings()
6185 hw_resc->resv_rx_rings = rx; in bnxt_hwrm_get_rings()
6186 hw_resc->resv_tx_rings = tx; in bnxt_hwrm_get_rings()
6188 hw_resc->resv_irqs = le16_to_cpu(resp->alloc_msix); in bnxt_hwrm_get_rings()
6189 hw_resc->resv_hw_ring_grps = rx; in bnxt_hwrm_get_rings()
6191 hw_resc->resv_cp_rings = cp; in bnxt_hwrm_get_rings()
6192 hw_resc->resv_stat_ctxs = stats; in bnxt_hwrm_get_rings()
6204 if (bp->hwrm_spec_code < 0x10601) in __bnxt_hwrm_get_tx_rings()
6211 req->fid = cpu_to_le16(fid); in __bnxt_hwrm_get_tx_rings()
6215 *tx_rings = le16_to_cpu(resp->alloc_tx_rings); in __bnxt_hwrm_get_tx_rings()
6233 req->fid = cpu_to_le16(0xffff); in __bnxt_hwrm_reserve_pf_rings()
6235 req->num_tx_rings = cpu_to_le16(tx_rings); in __bnxt_hwrm_reserve_pf_rings()
6239 if (bp->flags & BNXT_FLAG_CHIP_P5) { in __bnxt_hwrm_reserve_pf_rings()
6254 req->num_rx_rings = cpu_to_le16(rx_rings); in __bnxt_hwrm_reserve_pf_rings()
6255 if (bp->flags & BNXT_FLAG_CHIP_P5) { in __bnxt_hwrm_reserve_pf_rings()
6256 req->num_cmpl_rings = cpu_to_le16(tx_rings + ring_grps); in __bnxt_hwrm_reserve_pf_rings()
6257 req->num_msix = cpu_to_le16(cp_rings); in __bnxt_hwrm_reserve_pf_rings()
6258 req->num_rsscos_ctxs = in __bnxt_hwrm_reserve_pf_rings()
6261 req->num_cmpl_rings = cpu_to_le16(cp_rings); in __bnxt_hwrm_reserve_pf_rings()
6262 req->num_hw_ring_grps = cpu_to_le16(ring_grps); in __bnxt_hwrm_reserve_pf_rings()
6263 req->num_rsscos_ctxs = cpu_to_le16(1); in __bnxt_hwrm_reserve_pf_rings()
6264 if (!(bp->flags & BNXT_FLAG_NEW_RSS_CAP) && in __bnxt_hwrm_reserve_pf_rings()
6266 req->num_rsscos_ctxs = in __bnxt_hwrm_reserve_pf_rings()
6269 req->num_stat_ctxs = cpu_to_le16(stats); in __bnxt_hwrm_reserve_pf_rings()
6270 req->num_vnics = cpu_to_le16(vnics); in __bnxt_hwrm_reserve_pf_rings()
6272 req->enables = cpu_to_le32(enables); in __bnxt_hwrm_reserve_pf_rings()
6290 if (bp->flags & BNXT_FLAG_CHIP_P5) { in __bnxt_hwrm_reserve_vf_rings()
6302 req->num_l2_ctxs = cpu_to_le16(BNXT_VF_MAX_L2_CTX); in __bnxt_hwrm_reserve_vf_rings()
6303 req->num_tx_rings = cpu_to_le16(tx_rings); in __bnxt_hwrm_reserve_vf_rings()
6304 req->num_rx_rings = cpu_to_le16(rx_rings); in __bnxt_hwrm_reserve_vf_rings()
6305 if (bp->flags & BNXT_FLAG_CHIP_P5) { in __bnxt_hwrm_reserve_vf_rings()
6306 req->num_cmpl_rings = cpu_to_le16(tx_rings + ring_grps); in __bnxt_hwrm_reserve_vf_rings()
6307 req->num_rsscos_ctxs = cpu_to_le16(DIV_ROUND_UP(ring_grps, 64)); in __bnxt_hwrm_reserve_vf_rings()
6309 req->num_cmpl_rings = cpu_to_le16(cp_rings); in __bnxt_hwrm_reserve_vf_rings()
6310 req->num_hw_ring_grps = cpu_to_le16(ring_grps); in __bnxt_hwrm_reserve_vf_rings()
6311 req->num_rsscos_ctxs = cpu_to_le16(BNXT_VF_MAX_RSS_CTX); in __bnxt_hwrm_reserve_vf_rings()
6313 req->num_stat_ctxs = cpu_to_le16(stats); in __bnxt_hwrm_reserve_vf_rings()
6314 req->num_vnics = cpu_to_le16(vnics); in __bnxt_hwrm_reserve_vf_rings()
6316 req->enables = cpu_to_le32(enables); in __bnxt_hwrm_reserve_vf_rings()
6330 return -ENOMEM; in bnxt_hwrm_reserve_pf_rings()
6332 if (!req->enables) { in bnxt_hwrm_reserve_pf_rings()
6341 if (bp->hwrm_spec_code < 0x10601) in bnxt_hwrm_reserve_pf_rings()
6342 bp->hw_resc.resv_tx_rings = tx_rings; in bnxt_hwrm_reserve_pf_rings()
6355 bp->hw_resc.resv_tx_rings = tx_rings; in bnxt_hwrm_reserve_vf_rings()
6362 return -ENOMEM; in bnxt_hwrm_reserve_vf_rings()
6384 int cp = bp->cp_nr_rings; in bnxt_nq_rings_in_use()
6401 if (!(bp->flags & BNXT_FLAG_CHIP_P5)) in bnxt_cp_rings_in_use()
6404 cp = bp->tx_nr_rings + bp->rx_nr_rings; in bnxt_cp_rings_in_use()
6411 int cp = bp->cp_nr_rings; in bnxt_get_func_stat_ctxs()
6427 struct bnxt_hw_resc *hw_resc = &bp->hw_resc; in bnxt_check_rss_tbl_no_rmgr()
6430 if (hw_resc->resv_rx_rings != bp->rx_nr_rings) { in bnxt_check_rss_tbl_no_rmgr()
6431 hw_resc->resv_rx_rings = bp->rx_nr_rings; in bnxt_check_rss_tbl_no_rmgr()
6432 if (!netif_is_rxfh_configured(bp->dev)) in bnxt_check_rss_tbl_no_rmgr()
6439 struct bnxt_hw_resc *hw_resc = &bp->hw_resc; in bnxt_need_reserve_rings()
6442 int rx = bp->rx_nr_rings, stat; in bnxt_need_reserve_rings()
6445 if (hw_resc->resv_tx_rings != bp->tx_nr_rings && in bnxt_need_reserve_rings()
6446 bp->hwrm_spec_code >= 0x10601) in bnxt_need_reserve_rings()
6451 * we go through RX ring reservations first and then set up the in bnxt_need_reserve_rings()
6458 if ((bp->flags & BNXT_FLAG_RFS) && !(bp->flags & BNXT_FLAG_CHIP_P5)) in bnxt_need_reserve_rings()
6460 if (bp->flags & BNXT_FLAG_AGG_RINGS) in bnxt_need_reserve_rings()
6463 if (hw_resc->resv_rx_rings != rx || hw_resc->resv_cp_rings != cp || in bnxt_need_reserve_rings()
6464 hw_resc->resv_vnics != vnic || hw_resc->resv_stat_ctxs != stat || in bnxt_need_reserve_rings()
6465 (hw_resc->resv_hw_ring_grps != grp && in bnxt_need_reserve_rings()
6466 !(bp->flags & BNXT_FLAG_CHIP_P5))) in bnxt_need_reserve_rings()
6468 if ((bp->flags & BNXT_FLAG_CHIP_P5) && BNXT_PF(bp) && in bnxt_need_reserve_rings()
6469 hw_resc->resv_irqs != nq) in bnxt_need_reserve_rings()
6476 struct bnxt_hw_resc *hw_resc = &bp->hw_resc; in __bnxt_reserve_rings()
6478 int tx = bp->tx_nr_rings; in __bnxt_reserve_rings()
6479 int rx = bp->rx_nr_rings; in __bnxt_reserve_rings()
6487 if (bp->flags & BNXT_FLAG_SHARED_RINGS) in __bnxt_reserve_rings()
6489 if ((bp->flags & BNXT_FLAG_RFS) && !(bp->flags & BNXT_FLAG_CHIP_P5)) in __bnxt_reserve_rings()
6491 if (bp->flags & BNXT_FLAG_AGG_RINGS) in __bnxt_reserve_rings()
6493 grp = bp->rx_nr_rings; in __bnxt_reserve_rings()
6500 tx = hw_resc->resv_tx_rings; in __bnxt_reserve_rings()
6502 rx = hw_resc->resv_rx_rings; in __bnxt_reserve_rings()
6503 cp = hw_resc->resv_irqs; in __bnxt_reserve_rings()
6504 grp = hw_resc->resv_hw_ring_grps; in __bnxt_reserve_rings()
6505 vnic = hw_resc->resv_vnics; in __bnxt_reserve_rings()
6506 stat = hw_resc->resv_stat_ctxs; in __bnxt_reserve_rings()
6510 if (bp->flags & BNXT_FLAG_AGG_RINGS) { in __bnxt_reserve_rings()
6514 if (netif_running(bp->dev)) in __bnxt_reserve_rings()
6515 return -ENOMEM; in __bnxt_reserve_rings()
6517 bp->flags &= ~BNXT_FLAG_AGG_RINGS; in __bnxt_reserve_rings()
6518 bp->flags |= BNXT_FLAG_NO_AGG_RINGS; in __bnxt_reserve_rings()
6519 bp->dev->hw_features &= ~NETIF_F_LRO; in __bnxt_reserve_rings()
6520 bp->dev->features &= ~NETIF_F_LRO; in __bnxt_reserve_rings()
6525 cp = min_t(int, cp, bp->cp_nr_rings); in __bnxt_reserve_rings()
6527 stat -= bnxt_get_ulp_stat_ctxs(bp); in __bnxt_reserve_rings()
6530 if (bp->flags & BNXT_FLAG_AGG_RINGS) in __bnxt_reserve_rings()
6533 bp->tx_nr_rings = tx; in __bnxt_reserve_rings()
6538 if (rx_rings != bp->rx_nr_rings) { in __bnxt_reserve_rings()
6539 netdev_warn(bp->dev, "Able to reserve only %d out of %d requested RX rings\n", in __bnxt_reserve_rings()
6540 rx_rings, bp->rx_nr_rings); in __bnxt_reserve_rings()
6541 if (netif_is_rxfh_configured(bp->dev) && in __bnxt_reserve_rings()
6542 (bnxt_get_nr_rss_ctxs(bp, bp->rx_nr_rings) != in __bnxt_reserve_rings()
6545 netdev_warn(bp->dev, "RSS table entries reverting to default\n"); in __bnxt_reserve_rings()
6546 bp->dev->priv_flags &= ~IFF_RXFH_CONFIGURED; in __bnxt_reserve_rings()
6549 bp->rx_nr_rings = rx_rings; in __bnxt_reserve_rings()
6550 bp->cp_nr_rings = cp; in __bnxt_reserve_rings()
6553 return -ENOMEM; in __bnxt_reserve_rings()
6555 if (!netif_is_rxfh_configured(bp->dev)) in __bnxt_reserve_rings()
6579 if (!(bp->flags & BNXT_FLAG_CHIP_P5)) in bnxt_hwrm_check_vf_rings()
6582 req->flags = cpu_to_le32(flags); in bnxt_hwrm_check_vf_rings()
6601 if (bp->flags & BNXT_FLAG_CHIP_P5) in bnxt_hwrm_check_pf_rings()
6608 req->flags = cpu_to_le32(flags); in bnxt_hwrm_check_pf_rings()
6616 if (bp->hwrm_spec_code < 0x10801) in bnxt_hwrm_check_rings()
6630 struct bnxt_coal_cap *coal_cap = &bp->coal_cap; in bnxt_hwrm_coal_params_qcaps()
6635 coal_cap->cmpl_params = BNXT_LEGACY_COAL_CMPL_PARAMS; in bnxt_hwrm_coal_params_qcaps()
6636 coal_cap->num_cmpl_dma_aggr_max = 63; in bnxt_hwrm_coal_params_qcaps()
6637 coal_cap->num_cmpl_dma_aggr_during_int_max = 63; in bnxt_hwrm_coal_params_qcaps()
6638 coal_cap->cmpl_aggr_dma_tmr_max = 65535; in bnxt_hwrm_coal_params_qcaps()
6639 coal_cap->cmpl_aggr_dma_tmr_during_int_max = 65535; in bnxt_hwrm_coal_params_qcaps()
6640 coal_cap->int_lat_tmr_min_max = 65535; in bnxt_hwrm_coal_params_qcaps()
6641 coal_cap->int_lat_tmr_max_max = 65535; in bnxt_hwrm_coal_params_qcaps()
6642 coal_cap->num_cmpl_aggr_int_max = 65535; in bnxt_hwrm_coal_params_qcaps()
6643 coal_cap->timer_units = 80; in bnxt_hwrm_coal_params_qcaps()
6645 if (bp->hwrm_spec_code < 0x10902) in bnxt_hwrm_coal_params_qcaps()
6654 coal_cap->cmpl_params = le32_to_cpu(resp->cmpl_params); in bnxt_hwrm_coal_params_qcaps()
6655 coal_cap->nq_params = le32_to_cpu(resp->nq_params); in bnxt_hwrm_coal_params_qcaps()
6656 coal_cap->num_cmpl_dma_aggr_max = in bnxt_hwrm_coal_params_qcaps()
6657 le16_to_cpu(resp->num_cmpl_dma_aggr_max); in bnxt_hwrm_coal_params_qcaps()
6658 coal_cap->num_cmpl_dma_aggr_during_int_max = in bnxt_hwrm_coal_params_qcaps()
6659 le16_to_cpu(resp->num_cmpl_dma_aggr_during_int_max); in bnxt_hwrm_coal_params_qcaps()
6660 coal_cap->cmpl_aggr_dma_tmr_max = in bnxt_hwrm_coal_params_qcaps()
6661 le16_to_cpu(resp->cmpl_aggr_dma_tmr_max); in bnxt_hwrm_coal_params_qcaps()
6662 coal_cap->cmpl_aggr_dma_tmr_during_int_max = in bnxt_hwrm_coal_params_qcaps()
6663 le16_to_cpu(resp->cmpl_aggr_dma_tmr_during_int_max); in bnxt_hwrm_coal_params_qcaps()
6664 coal_cap->int_lat_tmr_min_max = in bnxt_hwrm_coal_params_qcaps()
6665 le16_to_cpu(resp->int_lat_tmr_min_max); in bnxt_hwrm_coal_params_qcaps()
6666 coal_cap->int_lat_tmr_max_max = in bnxt_hwrm_coal_params_qcaps()
6667 le16_to_cpu(resp->int_lat_tmr_max_max); in bnxt_hwrm_coal_params_qcaps()
6668 coal_cap->num_cmpl_aggr_int_max = in bnxt_hwrm_coal_params_qcaps()
6669 le16_to_cpu(resp->num_cmpl_aggr_int_max); in bnxt_hwrm_coal_params_qcaps()
6670 coal_cap->timer_units = le16_to_cpu(resp->timer_units); in bnxt_hwrm_coal_params_qcaps()
6677 struct bnxt_coal_cap *coal_cap = &bp->coal_cap; in bnxt_usec_to_coal_tmr()
6679 return usec * 1000 / coal_cap->timer_units; in bnxt_usec_to_coal_tmr()
6686 struct bnxt_coal_cap *coal_cap = &bp->coal_cap; in bnxt_hwrm_set_coal_params()
6687 u16 val, tmr, max, flags = hw_coal->flags; in bnxt_hwrm_set_coal_params()
6688 u32 cmpl_params = coal_cap->cmpl_params; in bnxt_hwrm_set_coal_params()
6690 max = hw_coal->bufs_per_record * 128; in bnxt_hwrm_set_coal_params()
6691 if (hw_coal->budget) in bnxt_hwrm_set_coal_params()
6692 max = hw_coal->bufs_per_record * hw_coal->budget; in bnxt_hwrm_set_coal_params()
6693 max = min_t(u16, max, coal_cap->num_cmpl_aggr_int_max); in bnxt_hwrm_set_coal_params()
6695 val = clamp_t(u16, hw_coal->coal_bufs, 1, max); in bnxt_hwrm_set_coal_params()
6696 req->num_cmpl_aggr_int = cpu_to_le16(val); in bnxt_hwrm_set_coal_params()
6698 val = min_t(u16, val, coal_cap->num_cmpl_dma_aggr_max); in bnxt_hwrm_set_coal_params()
6699 req->num_cmpl_dma_aggr = cpu_to_le16(val); in bnxt_hwrm_set_coal_params()
6701 val = clamp_t(u16, hw_coal->coal_bufs_irq, 1, in bnxt_hwrm_set_coal_params()
6702 coal_cap->num_cmpl_dma_aggr_during_int_max); in bnxt_hwrm_set_coal_params()
6703 req->num_cmpl_dma_aggr_during_int = cpu_to_le16(val); in bnxt_hwrm_set_coal_params()
6705 tmr = bnxt_usec_to_coal_tmr(bp, hw_coal->coal_ticks); in bnxt_hwrm_set_coal_params()
6706 tmr = clamp_t(u16, tmr, 1, coal_cap->int_lat_tmr_max_max); in bnxt_hwrm_set_coal_params()
6707 req->int_lat_tmr_max = cpu_to_le16(tmr); in bnxt_hwrm_set_coal_params()
6712 val = clamp_t(u16, val, 1, coal_cap->int_lat_tmr_min_max); in bnxt_hwrm_set_coal_params()
6713 req->int_lat_tmr_min = cpu_to_le16(val); in bnxt_hwrm_set_coal_params()
6714 req->enables |= cpu_to_le16(BNXT_COAL_CMPL_MIN_TMR_ENABLE); in bnxt_hwrm_set_coal_params()
6718 val = clamp_t(u16, tmr / 4, 1, coal_cap->cmpl_aggr_dma_tmr_max); in bnxt_hwrm_set_coal_params()
6719 req->cmpl_aggr_dma_tmr = cpu_to_le16(val); in bnxt_hwrm_set_coal_params()
6723 tmr = bnxt_usec_to_coal_tmr(bp, hw_coal->coal_ticks_irq); in bnxt_hwrm_set_coal_params()
6725 coal_cap->cmpl_aggr_dma_tmr_during_int_max); in bnxt_hwrm_set_coal_params()
6726 req->cmpl_aggr_dma_tmr_during_int = cpu_to_le16(val); in bnxt_hwrm_set_coal_params()
6727 req->enables |= in bnxt_hwrm_set_coal_params()
6732 hw_coal->idle_thresh && hw_coal->coal_ticks < hw_coal->idle_thresh) in bnxt_hwrm_set_coal_params()
6734 req->flags = cpu_to_le16(flags); in bnxt_hwrm_set_coal_params()
6735 req->enables |= cpu_to_le16(BNXT_COAL_CMPL_ENABLES); in bnxt_hwrm_set_coal_params()
6742 struct bnxt_cp_ring_info *cpr = &bnapi->cp_ring; in __bnxt_hwrm_set_coal_nq()
6743 struct bnxt_coal_cap *coal_cap = &bp->coal_cap; in __bnxt_hwrm_set_coal_nq()
6744 u32 nq_params = coal_cap->nq_params; in __bnxt_hwrm_set_coal_nq()
6755 req->ring_id = cpu_to_le16(cpr->cp_ring_struct.fw_ring_id); in __bnxt_hwrm_set_coal_nq()
6756 req->flags = in __bnxt_hwrm_set_coal_nq()
6759 tmr = bnxt_usec_to_coal_tmr(bp, hw_coal->coal_ticks) / 2; in __bnxt_hwrm_set_coal_nq()
6760 tmr = clamp_t(u16, tmr, 1, coal_cap->int_lat_tmr_min_max); in __bnxt_hwrm_set_coal_nq()
6761 req->int_lat_tmr_min = cpu_to_le16(tmr); in __bnxt_hwrm_set_coal_nq()
6762 req->enables |= cpu_to_le16(BNXT_COAL_CMPL_MIN_TMR_ENABLE); in __bnxt_hwrm_set_coal_nq()
6769 struct bnxt_cp_ring_info *cpr = &bnapi->cp_ring; in bnxt_hwrm_set_ring_coal()
6776 memcpy(&coal, &bp->rx_coal, sizeof(struct bnxt_coal)); in bnxt_hwrm_set_ring_coal()
6778 coal.coal_ticks = cpr->rx_ring_coal.coal_ticks; in bnxt_hwrm_set_ring_coal()
6779 coal.coal_bufs = cpr->rx_ring_coal.coal_bufs; in bnxt_hwrm_set_ring_coal()
6781 if (!bnapi->rx_ring) in bnxt_hwrm_set_ring_coal()
6782 return -ENODEV; in bnxt_hwrm_set_ring_coal()
6790 req_rx->ring_id = cpu_to_le16(bnxt_cp_ring_for_rx(bp, bnapi->rx_ring)); in bnxt_hwrm_set_ring_coal()
6811 bnxt_hwrm_set_coal_params(bp, &bp->rx_coal, req_rx); in bnxt_hwrm_set_coal()
6812 bnxt_hwrm_set_coal_params(bp, &bp->tx_coal, req_tx); in bnxt_hwrm_set_coal()
6816 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_hwrm_set_coal()
6817 struct bnxt_napi *bnapi = bp->bnapi[i]; in bnxt_hwrm_set_coal()
6822 if (!bnapi->rx_ring) { in bnxt_hwrm_set_coal()
6823 ring_id = bnxt_cp_ring_for_tx(bp, bnapi->tx_ring); in bnxt_hwrm_set_coal()
6826 ring_id = bnxt_cp_ring_for_rx(bp, bnapi->rx_ring); in bnxt_hwrm_set_coal()
6828 req->ring_id = cpu_to_le16(ring_id); in bnxt_hwrm_set_coal()
6834 if (!(bp->flags & BNXT_FLAG_CHIP_P5)) in bnxt_hwrm_set_coal()
6837 if (bnapi->rx_ring && bnapi->tx_ring) { in bnxt_hwrm_set_coal()
6839 ring_id = bnxt_cp_ring_for_tx(bp, bnapi->tx_ring); in bnxt_hwrm_set_coal()
6840 req->ring_id = cpu_to_le16(ring_id); in bnxt_hwrm_set_coal()
6845 if (bnapi->rx_ring) in bnxt_hwrm_set_coal()
6846 hw_coal = &bp->rx_coal; in bnxt_hwrm_set_coal()
6848 hw_coal = &bp->tx_coal; in bnxt_hwrm_set_coal()
6862 if (!bp->bnapi) in bnxt_hwrm_stat_ctx_free()
6878 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_hwrm_stat_ctx_free()
6879 struct bnxt_napi *bnapi = bp->bnapi[i]; in bnxt_hwrm_stat_ctx_free()
6880 struct bnxt_cp_ring_info *cpr = &bnapi->cp_ring; in bnxt_hwrm_stat_ctx_free()
6882 if (cpr->hw_stats_ctx_id != INVALID_STATS_CTX_ID) { in bnxt_hwrm_stat_ctx_free()
6883 req->stat_ctx_id = cpu_to_le32(cpr->hw_stats_ctx_id); in bnxt_hwrm_stat_ctx_free()
6885 req0->stat_ctx_id = req->stat_ctx_id; in bnxt_hwrm_stat_ctx_free()
6890 cpr->hw_stats_ctx_id = INVALID_STATS_CTX_ID; in bnxt_hwrm_stat_ctx_free()
6911 req->stats_dma_length = cpu_to_le16(bp->hw_ring_stats_size); in bnxt_hwrm_stat_ctx_alloc()
6912 req->update_period_ms = cpu_to_le32(bp->stats_coal_ticks / 1000); in bnxt_hwrm_stat_ctx_alloc()
6915 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_hwrm_stat_ctx_alloc()
6916 struct bnxt_napi *bnapi = bp->bnapi[i]; in bnxt_hwrm_stat_ctx_alloc()
6917 struct bnxt_cp_ring_info *cpr = &bnapi->cp_ring; in bnxt_hwrm_stat_ctx_alloc()
6919 req->stats_dma_addr = cpu_to_le64(cpr->stats.hw_stats_map); in bnxt_hwrm_stat_ctx_alloc()
6925 cpr->hw_stats_ctx_id = le32_to_cpu(resp->stat_ctx_id); in bnxt_hwrm_stat_ctx_alloc()
6927 bp->grp_info[i].fw_stats_ctx = cpr->hw_stats_ctx_id; in bnxt_hwrm_stat_ctx_alloc()
6945 req->fid = cpu_to_le16(0xffff); in bnxt_hwrm_func_qcfg()
6953 struct bnxt_vf_info *vf = &bp->vf; in bnxt_hwrm_func_qcfg()
6955 vf->vlan = le16_to_cpu(resp->vlan) & VLAN_VID_MASK; in bnxt_hwrm_func_qcfg()
6957 bp->pf.registered_vfs = le16_to_cpu(resp->registered_vfs); in bnxt_hwrm_func_qcfg()
6960 flags = le16_to_cpu(resp->flags); in bnxt_hwrm_func_qcfg()
6963 bp->fw_cap |= BNXT_FW_CAP_LLDP_AGENT; in bnxt_hwrm_func_qcfg()
6965 bp->fw_cap |= BNXT_FW_CAP_DCBX_AGENT; in bnxt_hwrm_func_qcfg()
6968 bp->flags |= BNXT_FLAG_MULTI_HOST; in bnxt_hwrm_func_qcfg()
6971 bp->fw_cap |= BNXT_FW_CAP_RING_MONITOR; in bnxt_hwrm_func_qcfg()
6973 switch (resp->port_partition_type) { in bnxt_hwrm_func_qcfg()
6977 bp->port_partition_type = resp->port_partition_type; in bnxt_hwrm_func_qcfg()
6980 if (bp->hwrm_spec_code < 0x10707 || in bnxt_hwrm_func_qcfg()
6981 resp->evb_mode == FUNC_QCFG_RESP_EVB_MODE_VEB) in bnxt_hwrm_func_qcfg()
6982 bp->br_mode = BRIDGE_MODE_VEB; in bnxt_hwrm_func_qcfg()
6983 else if (resp->evb_mode == FUNC_QCFG_RESP_EVB_MODE_VEPA) in bnxt_hwrm_func_qcfg()
6984 bp->br_mode = BRIDGE_MODE_VEPA; in bnxt_hwrm_func_qcfg()
6986 bp->br_mode = BRIDGE_MODE_UNDEF; in bnxt_hwrm_func_qcfg()
6988 bp->max_mtu = le16_to_cpu(resp->max_mtu_configured); in bnxt_hwrm_func_qcfg()
6989 if (!bp->max_mtu) in bnxt_hwrm_func_qcfg()
6990 bp->max_mtu = BNXT_MAX_MTU; in bnxt_hwrm_func_qcfg()
6992 if (bp->db_size) in bnxt_hwrm_func_qcfg()
6995 if (bp->flags & BNXT_FLAG_CHIP_P5) { in bnxt_hwrm_func_qcfg()
7001 bp->db_size = PAGE_ALIGN(le16_to_cpu(resp->l2_doorbell_bar_size_kb) * in bnxt_hwrm_func_qcfg()
7003 if (!bp->db_size || bp->db_size > pci_resource_len(bp->pdev, 2) || in bnxt_hwrm_func_qcfg()
7004 bp->db_size <= min_db_offset) in bnxt_hwrm_func_qcfg()
7005 bp->db_size = pci_resource_len(bp->pdev, 2); in bnxt_hwrm_func_qcfg()
7021 init_val = resp->ctx_kind_initializer; in bnxt_init_ctx_initializer()
7022 init_mask = le16_to_cpu(resp->ctx_init_mask); in bnxt_init_ctx_initializer()
7023 offset = &resp->qp_init_offset; in bnxt_init_ctx_initializer()
7024 mem_init = &ctx->mem_init[BNXT_CTX_MEM_INIT_QP]; in bnxt_init_ctx_initializer()
7026 mem_init->init_val = init_val; in bnxt_init_ctx_initializer()
7027 mem_init->offset = BNXT_MEM_INVALID_OFFSET; in bnxt_init_ctx_initializer()
7031 offset = &resp->stat_init_offset; in bnxt_init_ctx_initializer()
7033 mem_init->offset = *offset * 4; in bnxt_init_ctx_initializer()
7035 mem_init->init_val = 0; in bnxt_init_ctx_initializer()
7037 ctx->mem_init[BNXT_CTX_MEM_INIT_QP].size = ctx->qp_entry_size; in bnxt_init_ctx_initializer()
7038 ctx->mem_init[BNXT_CTX_MEM_INIT_SRQ].size = ctx->srq_entry_size; in bnxt_init_ctx_initializer()
7039 ctx->mem_init[BNXT_CTX_MEM_INIT_CQ].size = ctx->cq_entry_size; in bnxt_init_ctx_initializer()
7040 ctx->mem_init[BNXT_CTX_MEM_INIT_VNIC].size = ctx->vnic_entry_size; in bnxt_init_ctx_initializer()
7041 ctx->mem_init[BNXT_CTX_MEM_INIT_STAT].size = ctx->stat_entry_size; in bnxt_init_ctx_initializer()
7042 ctx->mem_init[BNXT_CTX_MEM_INIT_MRAV].size = ctx->mrav_entry_size; in bnxt_init_ctx_initializer()
7051 if (bp->hwrm_spec_code < 0x10902 || BNXT_VF(bp) || bp->ctx) in bnxt_hwrm_func_backing_store_qcaps()
7067 rc = -ENOMEM; in bnxt_hwrm_func_backing_store_qcaps()
7070 ctx->qp_max_entries = le32_to_cpu(resp->qp_max_entries); in bnxt_hwrm_func_backing_store_qcaps()
7071 ctx->qp_min_qp1_entries = le16_to_cpu(resp->qp_min_qp1_entries); in bnxt_hwrm_func_backing_store_qcaps()
7072 ctx->qp_max_l2_entries = le16_to_cpu(resp->qp_max_l2_entries); in bnxt_hwrm_func_backing_store_qcaps()
7073 ctx->qp_entry_size = le16_to_cpu(resp->qp_entry_size); in bnxt_hwrm_func_backing_store_qcaps()
7074 ctx->srq_max_l2_entries = le16_to_cpu(resp->srq_max_l2_entries); in bnxt_hwrm_func_backing_store_qcaps()
7075 ctx->srq_max_entries = le32_to_cpu(resp->srq_max_entries); in bnxt_hwrm_func_backing_store_qcaps()
7076 ctx->srq_entry_size = le16_to_cpu(resp->srq_entry_size); in bnxt_hwrm_func_backing_store_qcaps()
7077 ctx->cq_max_l2_entries = le16_to_cpu(resp->cq_max_l2_entries); in bnxt_hwrm_func_backing_store_qcaps()
7078 ctx->cq_max_entries = le32_to_cpu(resp->cq_max_entries); in bnxt_hwrm_func_backing_store_qcaps()
7079 ctx->cq_entry_size = le16_to_cpu(resp->cq_entry_size); in bnxt_hwrm_func_backing_store_qcaps()
7080 ctx->vnic_max_vnic_entries = in bnxt_hwrm_func_backing_store_qcaps()
7081 le16_to_cpu(resp->vnic_max_vnic_entries); in bnxt_hwrm_func_backing_store_qcaps()
7082 ctx->vnic_max_ring_table_entries = in bnxt_hwrm_func_backing_store_qcaps()
7083 le16_to_cpu(resp->vnic_max_ring_table_entries); in bnxt_hwrm_func_backing_store_qcaps()
7084 ctx->vnic_entry_size = le16_to_cpu(resp->vnic_entry_size); in bnxt_hwrm_func_backing_store_qcaps()
7085 ctx->stat_max_entries = le32_to_cpu(resp->stat_max_entries); in bnxt_hwrm_func_backing_store_qcaps()
7086 ctx->stat_entry_size = le16_to_cpu(resp->stat_entry_size); in bnxt_hwrm_func_backing_store_qcaps()
7087 ctx->tqm_entry_size = le16_to_cpu(resp->tqm_entry_size); in bnxt_hwrm_func_backing_store_qcaps()
7088 ctx->tqm_min_entries_per_ring = in bnxt_hwrm_func_backing_store_qcaps()
7089 le32_to_cpu(resp->tqm_min_entries_per_ring); in bnxt_hwrm_func_backing_store_qcaps()
7090 ctx->tqm_max_entries_per_ring = in bnxt_hwrm_func_backing_store_qcaps()
7091 le32_to_cpu(resp->tqm_max_entries_per_ring); in bnxt_hwrm_func_backing_store_qcaps()
7092 ctx->tqm_entries_multiple = resp->tqm_entries_multiple; in bnxt_hwrm_func_backing_store_qcaps()
7093 if (!ctx->tqm_entries_multiple) in bnxt_hwrm_func_backing_store_qcaps()
7094 ctx->tqm_entries_multiple = 1; in bnxt_hwrm_func_backing_store_qcaps()
7095 ctx->mrav_max_entries = le32_to_cpu(resp->mrav_max_entries); in bnxt_hwrm_func_backing_store_qcaps()
7096 ctx->mrav_entry_size = le16_to_cpu(resp->mrav_entry_size); in bnxt_hwrm_func_backing_store_qcaps()
7097 ctx->mrav_num_entries_units = in bnxt_hwrm_func_backing_store_qcaps()
7098 le16_to_cpu(resp->mrav_num_entries_units); in bnxt_hwrm_func_backing_store_qcaps()
7099 ctx->tim_entry_size = le16_to_cpu(resp->tim_entry_size); in bnxt_hwrm_func_backing_store_qcaps()
7100 ctx->tim_max_entries = le32_to_cpu(resp->tim_max_entries); in bnxt_hwrm_func_backing_store_qcaps()
7104 ctx->tqm_fp_rings_count = resp->tqm_fp_rings_count; in bnxt_hwrm_func_backing_store_qcaps()
7105 if (!ctx->tqm_fp_rings_count) in bnxt_hwrm_func_backing_store_qcaps()
7106 ctx->tqm_fp_rings_count = bp->max_q; in bnxt_hwrm_func_backing_store_qcaps()
7107 else if (ctx->tqm_fp_rings_count > BNXT_MAX_TQM_FP_RINGS) in bnxt_hwrm_func_backing_store_qcaps()
7108 ctx->tqm_fp_rings_count = BNXT_MAX_TQM_FP_RINGS; in bnxt_hwrm_func_backing_store_qcaps()
7110 tqm_rings = ctx->tqm_fp_rings_count + BNXT_MAX_TQM_SP_RINGS; in bnxt_hwrm_func_backing_store_qcaps()
7114 rc = -ENOMEM; in bnxt_hwrm_func_backing_store_qcaps()
7118 ctx->tqm_mem[i] = ctx_pg; in bnxt_hwrm_func_backing_store_qcaps()
7119 bp->ctx = ctx; in bnxt_hwrm_func_backing_store_qcaps()
7131 if (!rmem->nr_pages) in bnxt_hwrm_set_pg_attr()
7135 if (rmem->depth >= 1) { in bnxt_hwrm_set_pg_attr()
7136 if (rmem->depth == 2) in bnxt_hwrm_set_pg_attr()
7140 *pg_dir = cpu_to_le64(rmem->pg_tbl_map); in bnxt_hwrm_set_pg_attr()
7142 *pg_dir = cpu_to_le64(rmem->dma_arr[0]); in bnxt_hwrm_set_pg_attr()
7156 struct bnxt_ctx_mem_info *ctx = bp->ctx; in bnxt_hwrm_func_backing_store_cfg()
7171 if (req_len > bp->hwrm_max_ext_req_len) in bnxt_hwrm_func_backing_store_cfg()
7177 req->enables = cpu_to_le32(enables); in bnxt_hwrm_func_backing_store_cfg()
7179 ctx_pg = &ctx->qp_mem; in bnxt_hwrm_func_backing_store_cfg()
7180 req->qp_num_entries = cpu_to_le32(ctx_pg->entries); in bnxt_hwrm_func_backing_store_cfg()
7181 req->qp_num_qp1_entries = cpu_to_le16(ctx->qp_min_qp1_entries); in bnxt_hwrm_func_backing_store_cfg()
7182 req->qp_num_l2_entries = cpu_to_le16(ctx->qp_max_l2_entries); in bnxt_hwrm_func_backing_store_cfg()
7183 req->qp_entry_size = cpu_to_le16(ctx->qp_entry_size); in bnxt_hwrm_func_backing_store_cfg()
7184 bnxt_hwrm_set_pg_attr(&ctx_pg->ring_mem, in bnxt_hwrm_func_backing_store_cfg()
7185 &req->qpc_pg_size_qpc_lvl, in bnxt_hwrm_func_backing_store_cfg()
7186 &req->qpc_page_dir); in bnxt_hwrm_func_backing_store_cfg()
7189 ctx_pg = &ctx->srq_mem; in bnxt_hwrm_func_backing_store_cfg()
7190 req->srq_num_entries = cpu_to_le32(ctx_pg->entries); in bnxt_hwrm_func_backing_store_cfg()
7191 req->srq_num_l2_entries = cpu_to_le16(ctx->srq_max_l2_entries); in bnxt_hwrm_func_backing_store_cfg()
7192 req->srq_entry_size = cpu_to_le16(ctx->srq_entry_size); in bnxt_hwrm_func_backing_store_cfg()
7193 bnxt_hwrm_set_pg_attr(&ctx_pg->ring_mem, in bnxt_hwrm_func_backing_store_cfg()
7194 &req->srq_pg_size_srq_lvl, in bnxt_hwrm_func_backing_store_cfg()
7195 &req->srq_page_dir); in bnxt_hwrm_func_backing_store_cfg()
7198 ctx_pg = &ctx->cq_mem; in bnxt_hwrm_func_backing_store_cfg()
7199 req->cq_num_entries = cpu_to_le32(ctx_pg->entries); in bnxt_hwrm_func_backing_store_cfg()
7200 req->cq_num_l2_entries = cpu_to_le16(ctx->cq_max_l2_entries); in bnxt_hwrm_func_backing_store_cfg()
7201 req->cq_entry_size = cpu_to_le16(ctx->cq_entry_size); in bnxt_hwrm_func_backing_store_cfg()
7202 bnxt_hwrm_set_pg_attr(&ctx_pg->ring_mem, in bnxt_hwrm_func_backing_store_cfg()
7203 &req->cq_pg_size_cq_lvl, in bnxt_hwrm_func_backing_store_cfg()
7204 &req->cq_page_dir); in bnxt_hwrm_func_backing_store_cfg()
7207 ctx_pg = &ctx->vnic_mem; in bnxt_hwrm_func_backing_store_cfg()
7208 req->vnic_num_vnic_entries = in bnxt_hwrm_func_backing_store_cfg()
7209 cpu_to_le16(ctx->vnic_max_vnic_entries); in bnxt_hwrm_func_backing_store_cfg()
7210 req->vnic_num_ring_table_entries = in bnxt_hwrm_func_backing_store_cfg()
7211 cpu_to_le16(ctx->vnic_max_ring_table_entries); in bnxt_hwrm_func_backing_store_cfg()
7212 req->vnic_entry_size = cpu_to_le16(ctx->vnic_entry_size); in bnxt_hwrm_func_backing_store_cfg()
7213 bnxt_hwrm_set_pg_attr(&ctx_pg->ring_mem, in bnxt_hwrm_func_backing_store_cfg()
7214 &req->vnic_pg_size_vnic_lvl, in bnxt_hwrm_func_backing_store_cfg()
7215 &req->vnic_page_dir); in bnxt_hwrm_func_backing_store_cfg()
7218 ctx_pg = &ctx->stat_mem; in bnxt_hwrm_func_backing_store_cfg()
7219 req->stat_num_entries = cpu_to_le32(ctx->stat_max_entries); in bnxt_hwrm_func_backing_store_cfg()
7220 req->stat_entry_size = cpu_to_le16(ctx->stat_entry_size); in bnxt_hwrm_func_backing_store_cfg()
7221 bnxt_hwrm_set_pg_attr(&ctx_pg->ring_mem, in bnxt_hwrm_func_backing_store_cfg()
7222 &req->stat_pg_size_stat_lvl, in bnxt_hwrm_func_backing_store_cfg()
7223 &req->stat_page_dir); in bnxt_hwrm_func_backing_store_cfg()
7226 ctx_pg = &ctx->mrav_mem; in bnxt_hwrm_func_backing_store_cfg()
7227 req->mrav_num_entries = cpu_to_le32(ctx_pg->entries); in bnxt_hwrm_func_backing_store_cfg()
7228 if (ctx->mrav_num_entries_units) in bnxt_hwrm_func_backing_store_cfg()
7231 req->mrav_entry_size = cpu_to_le16(ctx->mrav_entry_size); in bnxt_hwrm_func_backing_store_cfg()
7232 bnxt_hwrm_set_pg_attr(&ctx_pg->ring_mem, in bnxt_hwrm_func_backing_store_cfg()
7233 &req->mrav_pg_size_mrav_lvl, in bnxt_hwrm_func_backing_store_cfg()
7234 &req->mrav_page_dir); in bnxt_hwrm_func_backing_store_cfg()
7237 ctx_pg = &ctx->tim_mem; in bnxt_hwrm_func_backing_store_cfg()
7238 req->tim_num_entries = cpu_to_le32(ctx_pg->entries); in bnxt_hwrm_func_backing_store_cfg()
7239 req->tim_entry_size = cpu_to_le16(ctx->tim_entry_size); in bnxt_hwrm_func_backing_store_cfg()
7240 bnxt_hwrm_set_pg_attr(&ctx_pg->ring_mem, in bnxt_hwrm_func_backing_store_cfg()
7241 &req->tim_pg_size_tim_lvl, in bnxt_hwrm_func_backing_store_cfg()
7242 &req->tim_page_dir); in bnxt_hwrm_func_backing_store_cfg()
7244 for (i = 0, num_entries = &req->tqm_sp_num_entries, in bnxt_hwrm_func_backing_store_cfg()
7245 pg_attr = &req->tqm_sp_pg_size_tqm_sp_lvl, in bnxt_hwrm_func_backing_store_cfg()
7246 pg_dir = &req->tqm_sp_page_dir, in bnxt_hwrm_func_backing_store_cfg()
7253 req->tqm_entry_size = cpu_to_le16(ctx->tqm_entry_size); in bnxt_hwrm_func_backing_store_cfg()
7254 ctx_pg = ctx->tqm_mem[i]; in bnxt_hwrm_func_backing_store_cfg()
7255 *num_entries = cpu_to_le32(ctx_pg->entries); in bnxt_hwrm_func_backing_store_cfg()
7256 bnxt_hwrm_set_pg_attr(&ctx_pg->ring_mem, pg_attr, pg_dir); in bnxt_hwrm_func_backing_store_cfg()
7258 req->flags = cpu_to_le32(flags); in bnxt_hwrm_func_backing_store_cfg()
7265 struct bnxt_ring_mem_info *rmem = &ctx_pg->ring_mem; in bnxt_alloc_ctx_mem_blk()
7267 rmem->page_size = BNXT_PAGE_SIZE; in bnxt_alloc_ctx_mem_blk()
7268 rmem->pg_arr = ctx_pg->ctx_pg_arr; in bnxt_alloc_ctx_mem_blk()
7269 rmem->dma_arr = ctx_pg->ctx_dma_arr; in bnxt_alloc_ctx_mem_blk()
7270 rmem->flags = BNXT_RMEM_VALID_PTE_FLAG; in bnxt_alloc_ctx_mem_blk()
7271 if (rmem->depth >= 1) in bnxt_alloc_ctx_mem_blk()
7272 rmem->flags |= BNXT_RMEM_USE_FULL_PAGE_FLAG; in bnxt_alloc_ctx_mem_blk()
7280 struct bnxt_ring_mem_info *rmem = &ctx_pg->ring_mem; in bnxt_alloc_ctx_pg_tbls()
7284 return -EINVAL; in bnxt_alloc_ctx_pg_tbls()
7286 ctx_pg->nr_pages = DIV_ROUND_UP(mem_size, BNXT_PAGE_SIZE); in bnxt_alloc_ctx_pg_tbls()
7287 if (ctx_pg->nr_pages > MAX_CTX_TOTAL_PAGES) { in bnxt_alloc_ctx_pg_tbls()
7288 ctx_pg->nr_pages = 0; in bnxt_alloc_ctx_pg_tbls()
7289 return -EINVAL; in bnxt_alloc_ctx_pg_tbls()
7291 if (ctx_pg->nr_pages > MAX_CTX_PAGES || depth > 1) { in bnxt_alloc_ctx_pg_tbls()
7294 rmem->depth = 2; in bnxt_alloc_ctx_pg_tbls()
7295 ctx_pg->ctx_pg_tbl = kcalloc(MAX_CTX_PAGES, sizeof(ctx_pg), in bnxt_alloc_ctx_pg_tbls()
7297 if (!ctx_pg->ctx_pg_tbl) in bnxt_alloc_ctx_pg_tbls()
7298 return -ENOMEM; in bnxt_alloc_ctx_pg_tbls()
7299 nr_tbls = DIV_ROUND_UP(ctx_pg->nr_pages, MAX_CTX_PAGES); in bnxt_alloc_ctx_pg_tbls()
7300 rmem->nr_pages = nr_tbls; in bnxt_alloc_ctx_pg_tbls()
7309 return -ENOMEM; in bnxt_alloc_ctx_pg_tbls()
7310 ctx_pg->ctx_pg_tbl[i] = pg_tbl; in bnxt_alloc_ctx_pg_tbls()
7311 rmem = &pg_tbl->ring_mem; in bnxt_alloc_ctx_pg_tbls()
7312 rmem->pg_tbl = ctx_pg->ctx_pg_arr[i]; in bnxt_alloc_ctx_pg_tbls()
7313 rmem->pg_tbl_map = ctx_pg->ctx_dma_arr[i]; in bnxt_alloc_ctx_pg_tbls()
7314 rmem->depth = 1; in bnxt_alloc_ctx_pg_tbls()
7315 rmem->nr_pages = MAX_CTX_PAGES; in bnxt_alloc_ctx_pg_tbls()
7316 rmem->mem_init = mem_init; in bnxt_alloc_ctx_pg_tbls()
7317 if (i == (nr_tbls - 1)) { in bnxt_alloc_ctx_pg_tbls()
7318 int rem = ctx_pg->nr_pages % MAX_CTX_PAGES; in bnxt_alloc_ctx_pg_tbls()
7321 rmem->nr_pages = rem; in bnxt_alloc_ctx_pg_tbls()
7328 rmem->nr_pages = DIV_ROUND_UP(mem_size, BNXT_PAGE_SIZE); in bnxt_alloc_ctx_pg_tbls()
7329 if (rmem->nr_pages > 1 || depth) in bnxt_alloc_ctx_pg_tbls()
7330 rmem->depth = 1; in bnxt_alloc_ctx_pg_tbls()
7331 rmem->mem_init = mem_init; in bnxt_alloc_ctx_pg_tbls()
7340 struct bnxt_ring_mem_info *rmem = &ctx_pg->ring_mem; in bnxt_free_ctx_pg_tbls()
7342 if (rmem->depth > 1 || ctx_pg->nr_pages > MAX_CTX_PAGES || in bnxt_free_ctx_pg_tbls()
7343 ctx_pg->ctx_pg_tbl) { in bnxt_free_ctx_pg_tbls()
7344 int i, nr_tbls = rmem->nr_pages; in bnxt_free_ctx_pg_tbls()
7350 pg_tbl = ctx_pg->ctx_pg_tbl[i]; in bnxt_free_ctx_pg_tbls()
7353 rmem2 = &pg_tbl->ring_mem; in bnxt_free_ctx_pg_tbls()
7355 ctx_pg->ctx_pg_arr[i] = NULL; in bnxt_free_ctx_pg_tbls()
7357 ctx_pg->ctx_pg_tbl[i] = NULL; in bnxt_free_ctx_pg_tbls()
7359 kfree(ctx_pg->ctx_pg_tbl); in bnxt_free_ctx_pg_tbls()
7360 ctx_pg->ctx_pg_tbl = NULL; in bnxt_free_ctx_pg_tbls()
7363 ctx_pg->nr_pages = 0; in bnxt_free_ctx_pg_tbls()
7368 struct bnxt_ctx_mem_info *ctx = bp->ctx; in bnxt_free_ctx_mem()
7374 if (ctx->tqm_mem[0]) { in bnxt_free_ctx_mem()
7375 for (i = 0; i < ctx->tqm_fp_rings_count + 1; i++) in bnxt_free_ctx_mem()
7376 bnxt_free_ctx_pg_tbls(bp, ctx->tqm_mem[i]); in bnxt_free_ctx_mem()
7377 kfree(ctx->tqm_mem[0]); in bnxt_free_ctx_mem()
7378 ctx->tqm_mem[0] = NULL; in bnxt_free_ctx_mem()
7381 bnxt_free_ctx_pg_tbls(bp, &ctx->tim_mem); in bnxt_free_ctx_mem()
7382 bnxt_free_ctx_pg_tbls(bp, &ctx->mrav_mem); in bnxt_free_ctx_mem()
7383 bnxt_free_ctx_pg_tbls(bp, &ctx->stat_mem); in bnxt_free_ctx_mem()
7384 bnxt_free_ctx_pg_tbls(bp, &ctx->vnic_mem); in bnxt_free_ctx_mem()
7385 bnxt_free_ctx_pg_tbls(bp, &ctx->cq_mem); in bnxt_free_ctx_mem()
7386 bnxt_free_ctx_pg_tbls(bp, &ctx->srq_mem); in bnxt_free_ctx_mem()
7387 bnxt_free_ctx_pg_tbls(bp, &ctx->qp_mem); in bnxt_free_ctx_mem()
7388 ctx->flags &= ~BNXT_CTX_FLAG_INITED; in bnxt_free_ctx_mem()
7406 netdev_err(bp->dev, "Failed querying context mem capability, rc = %d.\n", in bnxt_alloc_ctx_mem()
7410 ctx = bp->ctx; in bnxt_alloc_ctx_mem()
7411 if (!ctx || (ctx->flags & BNXT_CTX_FLAG_INITED)) in bnxt_alloc_ctx_mem()
7414 if ((bp->flags & BNXT_FLAG_ROCE_CAP) && !is_kdump_kernel()) { in bnxt_alloc_ctx_mem()
7420 ctx_pg = &ctx->qp_mem; in bnxt_alloc_ctx_mem()
7421 ctx_pg->entries = ctx->qp_min_qp1_entries + ctx->qp_max_l2_entries + in bnxt_alloc_ctx_mem()
7423 if (ctx->qp_entry_size) { in bnxt_alloc_ctx_mem()
7424 mem_size = ctx->qp_entry_size * ctx_pg->entries; in bnxt_alloc_ctx_mem()
7425 init = &ctx->mem_init[BNXT_CTX_MEM_INIT_QP]; in bnxt_alloc_ctx_mem()
7431 ctx_pg = &ctx->srq_mem; in bnxt_alloc_ctx_mem()
7432 ctx_pg->entries = ctx->srq_max_l2_entries + extra_srqs; in bnxt_alloc_ctx_mem()
7433 if (ctx->srq_entry_size) { in bnxt_alloc_ctx_mem()
7434 mem_size = ctx->srq_entry_size * ctx_pg->entries; in bnxt_alloc_ctx_mem()
7435 init = &ctx->mem_init[BNXT_CTX_MEM_INIT_SRQ]; in bnxt_alloc_ctx_mem()
7441 ctx_pg = &ctx->cq_mem; in bnxt_alloc_ctx_mem()
7442 ctx_pg->entries = ctx->cq_max_l2_entries + extra_qps * 2; in bnxt_alloc_ctx_mem()
7443 if (ctx->cq_entry_size) { in bnxt_alloc_ctx_mem()
7444 mem_size = ctx->cq_entry_size * ctx_pg->entries; in bnxt_alloc_ctx_mem()
7445 init = &ctx->mem_init[BNXT_CTX_MEM_INIT_CQ]; in bnxt_alloc_ctx_mem()
7451 ctx_pg = &ctx->vnic_mem; in bnxt_alloc_ctx_mem()
7452 ctx_pg->entries = ctx->vnic_max_vnic_entries + in bnxt_alloc_ctx_mem()
7453 ctx->vnic_max_ring_table_entries; in bnxt_alloc_ctx_mem()
7454 if (ctx->vnic_entry_size) { in bnxt_alloc_ctx_mem()
7455 mem_size = ctx->vnic_entry_size * ctx_pg->entries; in bnxt_alloc_ctx_mem()
7456 init = &ctx->mem_init[BNXT_CTX_MEM_INIT_VNIC]; in bnxt_alloc_ctx_mem()
7462 ctx_pg = &ctx->stat_mem; in bnxt_alloc_ctx_mem()
7463 ctx_pg->entries = ctx->stat_max_entries; in bnxt_alloc_ctx_mem()
7464 if (ctx->stat_entry_size) { in bnxt_alloc_ctx_mem()
7465 mem_size = ctx->stat_entry_size * ctx_pg->entries; in bnxt_alloc_ctx_mem()
7466 init = &ctx->mem_init[BNXT_CTX_MEM_INIT_STAT]; in bnxt_alloc_ctx_mem()
7473 if (!(bp->flags & BNXT_FLAG_ROCE_CAP)) in bnxt_alloc_ctx_mem()
7476 ctx_pg = &ctx->mrav_mem; in bnxt_alloc_ctx_mem()
7482 ctx_pg->entries = num_mr + num_ah; in bnxt_alloc_ctx_mem()
7483 if (ctx->mrav_entry_size) { in bnxt_alloc_ctx_mem()
7484 mem_size = ctx->mrav_entry_size * ctx_pg->entries; in bnxt_alloc_ctx_mem()
7485 init = &ctx->mem_init[BNXT_CTX_MEM_INIT_MRAV]; in bnxt_alloc_ctx_mem()
7491 if (ctx->mrav_num_entries_units) in bnxt_alloc_ctx_mem()
7492 ctx_pg->entries = in bnxt_alloc_ctx_mem()
7493 ((num_mr / ctx->mrav_num_entries_units) << 16) | in bnxt_alloc_ctx_mem()
7494 (num_ah / ctx->mrav_num_entries_units); in bnxt_alloc_ctx_mem()
7496 ctx_pg = &ctx->tim_mem; in bnxt_alloc_ctx_mem()
7497 ctx_pg->entries = ctx->qp_mem.entries; in bnxt_alloc_ctx_mem()
7498 if (ctx->tim_entry_size) { in bnxt_alloc_ctx_mem()
7499 mem_size = ctx->tim_entry_size * ctx_pg->entries; in bnxt_alloc_ctx_mem()
7507 min = ctx->tqm_min_entries_per_ring; in bnxt_alloc_ctx_mem()
7508 entries_sp = ctx->vnic_max_vnic_entries + ctx->qp_max_l2_entries + in bnxt_alloc_ctx_mem()
7509 2 * (extra_qps + ctx->qp_min_qp1_entries) + min; in bnxt_alloc_ctx_mem()
7510 entries_sp = roundup(entries_sp, ctx->tqm_entries_multiple); in bnxt_alloc_ctx_mem()
7511 entries = ctx->qp_max_l2_entries + 2 * (extra_qps + ctx->qp_min_qp1_entries); in bnxt_alloc_ctx_mem()
7512 entries = roundup(entries, ctx->tqm_entries_multiple); in bnxt_alloc_ctx_mem()
7513 entries = clamp_t(u32, entries, min, ctx->tqm_max_entries_per_ring); in bnxt_alloc_ctx_mem()
7514 for (i = 0; i < ctx->tqm_fp_rings_count + 1; i++) { in bnxt_alloc_ctx_mem()
7515 ctx_pg = ctx->tqm_mem[i]; in bnxt_alloc_ctx_mem()
7516 ctx_pg->entries = i ? entries : entries_sp; in bnxt_alloc_ctx_mem()
7517 if (ctx->tqm_entry_size) { in bnxt_alloc_ctx_mem()
7518 mem_size = ctx->tqm_entry_size * ctx_pg->entries; in bnxt_alloc_ctx_mem()
7529 netdev_err(bp->dev, "Failed configuring context mem, rc = %d.\n", in bnxt_alloc_ctx_mem()
7533 ctx->flags |= BNXT_CTX_FLAG_INITED; in bnxt_alloc_ctx_mem()
7541 struct bnxt_hw_resc *hw_resc = &bp->hw_resc; in bnxt_hwrm_func_resc_qcaps()
7548 req->fid = cpu_to_le16(0xffff); in bnxt_hwrm_func_resc_qcaps()
7554 hw_resc->max_tx_sch_inputs = le16_to_cpu(resp->max_tx_scheduler_inputs); in bnxt_hwrm_func_resc_qcaps()
7558 hw_resc->min_rsscos_ctxs = le16_to_cpu(resp->min_rsscos_ctx); in bnxt_hwrm_func_resc_qcaps()
7559 hw_resc->max_rsscos_ctxs = le16_to_cpu(resp->max_rsscos_ctx); in bnxt_hwrm_func_resc_qcaps()
7560 hw_resc->min_cp_rings = le16_to_cpu(resp->min_cmpl_rings); in bnxt_hwrm_func_resc_qcaps()
7561 hw_resc->max_cp_rings = le16_to_cpu(resp->max_cmpl_rings); in bnxt_hwrm_func_resc_qcaps()
7562 hw_resc->min_tx_rings = le16_to_cpu(resp->min_tx_rings); in bnxt_hwrm_func_resc_qcaps()
7563 hw_resc->max_tx_rings = le16_to_cpu(resp->max_tx_rings); in bnxt_hwrm_func_resc_qcaps()
7564 hw_resc->min_rx_rings = le16_to_cpu(resp->min_rx_rings); in bnxt_hwrm_func_resc_qcaps()
7565 hw_resc->max_rx_rings = le16_to_cpu(resp->max_rx_rings); in bnxt_hwrm_func_resc_qcaps()
7566 hw_resc->min_hw_ring_grps = le16_to_cpu(resp->min_hw_ring_grps); in bnxt_hwrm_func_resc_qcaps()
7567 hw_resc->max_hw_ring_grps = le16_to_cpu(resp->max_hw_ring_grps); in bnxt_hwrm_func_resc_qcaps()
7568 hw_resc->min_l2_ctxs = le16_to_cpu(resp->min_l2_ctxs); in bnxt_hwrm_func_resc_qcaps()
7569 hw_resc->max_l2_ctxs = le16_to_cpu(resp->max_l2_ctxs); in bnxt_hwrm_func_resc_qcaps()
7570 hw_resc->min_vnics = le16_to_cpu(resp->min_vnics); in bnxt_hwrm_func_resc_qcaps()
7571 hw_resc->max_vnics = le16_to_cpu(resp->max_vnics); in bnxt_hwrm_func_resc_qcaps()
7572 hw_resc->min_stat_ctxs = le16_to_cpu(resp->min_stat_ctx); in bnxt_hwrm_func_resc_qcaps()
7573 hw_resc->max_stat_ctxs = le16_to_cpu(resp->max_stat_ctx); in bnxt_hwrm_func_resc_qcaps()
7575 if (bp->flags & BNXT_FLAG_CHIP_P5) { in bnxt_hwrm_func_resc_qcaps()
7576 u16 max_msix = le16_to_cpu(resp->max_msix); in bnxt_hwrm_func_resc_qcaps()
7578 hw_resc->max_nqs = max_msix; in bnxt_hwrm_func_resc_qcaps()
7579 hw_resc->max_hw_ring_grps = hw_resc->max_rx_rings; in bnxt_hwrm_func_resc_qcaps()
7583 struct bnxt_pf_info *pf = &bp->pf; in bnxt_hwrm_func_resc_qcaps()
7585 pf->vf_resv_strategy = in bnxt_hwrm_func_resc_qcaps()
7586 le16_to_cpu(resp->vf_reservation_strategy); in bnxt_hwrm_func_resc_qcaps()
7587 if (pf->vf_resv_strategy > BNXT_VF_RESV_STRATEGY_MINIMAL_STATIC) in bnxt_hwrm_func_resc_qcaps()
7588 pf->vf_resv_strategy = BNXT_VF_RESV_STRATEGY_MAXIMAL; in bnxt_hwrm_func_resc_qcaps()
7599 struct bnxt_ptp_cfg *ptp = bp->ptp_cfg; in __bnxt_hwrm_ptp_qcfg()
7603 if (bp->hwrm_spec_code < 0x10801 || !BNXT_CHIP_P5_THOR(bp)) { in __bnxt_hwrm_ptp_qcfg()
7604 rc = -ENODEV; in __bnxt_hwrm_ptp_qcfg()
7612 req->port_id = cpu_to_le16(bp->pf.port_id); in __bnxt_hwrm_ptp_qcfg()
7618 flags = resp->flags; in __bnxt_hwrm_ptp_qcfg()
7620 rc = -ENODEV; in __bnxt_hwrm_ptp_qcfg()
7626 rc = -ENOMEM; in __bnxt_hwrm_ptp_qcfg()
7629 ptp->bp = bp; in __bnxt_hwrm_ptp_qcfg()
7630 bp->ptp_cfg = ptp; in __bnxt_hwrm_ptp_qcfg()
7633 ptp->refclk_regs[0] = le32_to_cpu(resp->ts_ref_clock_reg_lower); in __bnxt_hwrm_ptp_qcfg()
7634 ptp->refclk_regs[1] = le32_to_cpu(resp->ts_ref_clock_reg_upper); in __bnxt_hwrm_ptp_qcfg()
7635 } else if (bp->flags & BNXT_FLAG_CHIP_P5) { in __bnxt_hwrm_ptp_qcfg()
7636 ptp->refclk_regs[0] = BNXT_TS_REG_TIMESYNC_TS0_LOWER; in __bnxt_hwrm_ptp_qcfg()
7637 ptp->refclk_regs[1] = BNXT_TS_REG_TIMESYNC_TS0_UPPER; in __bnxt_hwrm_ptp_qcfg()
7639 rc = -ENODEV; in __bnxt_hwrm_ptp_qcfg()
7642 ptp->rtc_configured = in __bnxt_hwrm_ptp_qcfg()
7646 netdev_warn(bp->dev, "PTP initialization failed.\n"); in __bnxt_hwrm_ptp_qcfg()
7655 bp->ptp_cfg = NULL; in __bnxt_hwrm_ptp_qcfg()
7663 struct bnxt_hw_resc *hw_resc = &bp->hw_resc; in __bnxt_hwrm_func_qcaps()
7671 req->fid = cpu_to_le16(0xffff); in __bnxt_hwrm_func_qcaps()
7677 flags = le32_to_cpu(resp->flags); in __bnxt_hwrm_func_qcaps()
7679 bp->flags |= BNXT_FLAG_ROCEV1_CAP; in __bnxt_hwrm_func_qcaps()
7681 bp->flags |= BNXT_FLAG_ROCEV2_CAP; in __bnxt_hwrm_func_qcaps()
7683 bp->fw_cap |= BNXT_FW_CAP_PCIE_STATS_SUPPORTED; in __bnxt_hwrm_func_qcaps()
7685 bp->fw_cap |= BNXT_FW_CAP_HOT_RESET; in __bnxt_hwrm_func_qcaps()
7687 bp->fw_cap |= BNXT_FW_CAP_EXT_STATS_SUPPORTED; in __bnxt_hwrm_func_qcaps()
7689 bp->fw_cap |= BNXT_FW_CAP_ERROR_RECOVERY; in __bnxt_hwrm_func_qcaps()
7691 bp->fw_cap |= BNXT_FW_CAP_ERR_RECOVER_RELOAD; in __bnxt_hwrm_func_qcaps()
7693 bp->fw_cap |= BNXT_FW_CAP_VLAN_TX_INSERT; in __bnxt_hwrm_func_qcaps()
7695 bp->fw_cap |= BNXT_FW_CAP_DBG_QCAPS; in __bnxt_hwrm_func_qcaps()
7697 flags_ext = le32_to_cpu(resp->flags_ext); in __bnxt_hwrm_func_qcaps()
7699 bp->fw_cap |= BNXT_FW_CAP_EXT_HW_STATS_SUPPORTED; in __bnxt_hwrm_func_qcaps()
7701 bp->fw_cap |= BNXT_FW_CAP_PTP_PPS; in __bnxt_hwrm_func_qcaps()
7703 bp->fw_cap |= BNXT_FW_CAP_PTP_RTC; in __bnxt_hwrm_func_qcaps()
7705 bp->fw_cap |= BNXT_FW_CAP_HOT_RESET_IF; in __bnxt_hwrm_func_qcaps()
7707 bp->fw_cap |= BNXT_FW_CAP_LIVEPATCH; in __bnxt_hwrm_func_qcaps()
7709 flags_ext2 = le32_to_cpu(resp->flags_ext2); in __bnxt_hwrm_func_qcaps()
7711 bp->fw_cap |= BNXT_FW_CAP_RX_ALL_PKT_TS; in __bnxt_hwrm_func_qcaps()
7713 bp->tx_push_thresh = 0; in __bnxt_hwrm_func_qcaps()
7716 bp->tx_push_thresh = BNXT_TX_PUSH_THRESH; in __bnxt_hwrm_func_qcaps()
7718 hw_resc->max_rsscos_ctxs = le16_to_cpu(resp->max_rsscos_ctx); in __bnxt_hwrm_func_qcaps()
7719 hw_resc->max_cp_rings = le16_to_cpu(resp->max_cmpl_rings); in __bnxt_hwrm_func_qcaps()
7720 hw_resc->max_tx_rings = le16_to_cpu(resp->max_tx_rings); in __bnxt_hwrm_func_qcaps()
7721 hw_resc->max_rx_rings = le16_to_cpu(resp->max_rx_rings); in __bnxt_hwrm_func_qcaps()
7722 hw_resc->max_hw_ring_grps = le32_to_cpu(resp->max_hw_ring_grps); in __bnxt_hwrm_func_qcaps()
7723 if (!hw_resc->max_hw_ring_grps) in __bnxt_hwrm_func_qcaps()
7724 hw_resc->max_hw_ring_grps = hw_resc->max_tx_rings; in __bnxt_hwrm_func_qcaps()
7725 hw_resc->max_l2_ctxs = le16_to_cpu(resp->max_l2_ctxs); in __bnxt_hwrm_func_qcaps()
7726 hw_resc->max_vnics = le16_to_cpu(resp->max_vnics); in __bnxt_hwrm_func_qcaps()
7727 hw_resc->max_stat_ctxs = le16_to_cpu(resp->max_stat_ctx); in __bnxt_hwrm_func_qcaps()
7730 struct bnxt_pf_info *pf = &bp->pf; in __bnxt_hwrm_func_qcaps()
7732 pf->fw_fid = le16_to_cpu(resp->fid); in __bnxt_hwrm_func_qcaps()
7733 pf->port_id = le16_to_cpu(resp->port_id); in __bnxt_hwrm_func_qcaps()
7734 memcpy(pf->mac_addr, resp->mac_address, ETH_ALEN); in __bnxt_hwrm_func_qcaps()
7735 pf->first_vf_id = le16_to_cpu(resp->first_vf_id); in __bnxt_hwrm_func_qcaps()
7736 pf->max_vfs = le16_to_cpu(resp->max_vfs); in __bnxt_hwrm_func_qcaps()
7737 pf->max_encap_records = le32_to_cpu(resp->max_encap_records); in __bnxt_hwrm_func_qcaps()
7738 pf->max_decap_records = le32_to_cpu(resp->max_decap_records); in __bnxt_hwrm_func_qcaps()
7739 pf->max_tx_em_flows = le32_to_cpu(resp->max_tx_em_flows); in __bnxt_hwrm_func_qcaps()
7740 pf->max_tx_wm_flows = le32_to_cpu(resp->max_tx_wm_flows); in __bnxt_hwrm_func_qcaps()
7741 pf->max_rx_em_flows = le32_to_cpu(resp->max_rx_em_flows); in __bnxt_hwrm_func_qcaps()
7742 pf->max_rx_wm_flows = le32_to_cpu(resp->max_rx_wm_flows); in __bnxt_hwrm_func_qcaps()
7743 bp->flags &= ~BNXT_FLAG_WOL_CAP; in __bnxt_hwrm_func_qcaps()
7745 bp->flags |= BNXT_FLAG_WOL_CAP; in __bnxt_hwrm_func_qcaps()
7747 bp->fw_cap |= BNXT_FW_CAP_PTP; in __bnxt_hwrm_func_qcaps()
7750 kfree(bp->ptp_cfg); in __bnxt_hwrm_func_qcaps()
7751 bp->ptp_cfg = NULL; in __bnxt_hwrm_func_qcaps()
7755 struct bnxt_vf_info *vf = &bp->vf; in __bnxt_hwrm_func_qcaps()
7757 vf->fw_fid = le16_to_cpu(resp->fid); in __bnxt_hwrm_func_qcaps()
7758 memcpy(vf->mac_addr, resp->mac_address, ETH_ALEN); in __bnxt_hwrm_func_qcaps()
7773 bp->fw_dbg_cap = 0; in bnxt_hwrm_dbg_qcaps()
7774 if (!(bp->fw_cap & BNXT_FW_CAP_DBG_QCAPS)) in bnxt_hwrm_dbg_qcaps()
7781 req->fid = cpu_to_le16(0xffff); in bnxt_hwrm_dbg_qcaps()
7787 bp->fw_dbg_cap = le32_to_cpu(resp->flags); in bnxt_hwrm_dbg_qcaps()
7807 netdev_err(bp->dev, "hwrm query qportcfg failure rc: %d\n", rc); in bnxt_hwrm_func_qcaps()
7810 if (bp->hwrm_spec_code >= 0x10803) { in bnxt_hwrm_func_qcaps()
7816 bp->fw_cap |= BNXT_FW_CAP_NEW_RM; in bnxt_hwrm_func_qcaps()
7828 if (!(bp->fw_cap & BNXT_FW_CAP_CFA_ADV_FLOW)) in bnxt_hwrm_cfa_adv_flow_mgnt_qcaps()
7840 flags = le32_to_cpu(resp->flags); in bnxt_hwrm_cfa_adv_flow_mgnt_qcaps()
7843 bp->fw_cap |= BNXT_FW_CAP_CFA_RFS_RING_TBL_IDX_V2; in bnxt_hwrm_cfa_adv_flow_mgnt_qcaps()
7852 if (bp->fw_health) in __bnxt_alloc_fw_health()
7855 bp->fw_health = kzalloc(sizeof(*bp->fw_health), GFP_KERNEL); in __bnxt_alloc_fw_health()
7856 if (!bp->fw_health) in __bnxt_alloc_fw_health()
7857 return -ENOMEM; in __bnxt_alloc_fw_health()
7859 mutex_init(&bp->fw_health->lock); in __bnxt_alloc_fw_health()
7867 if (!(bp->fw_cap & BNXT_FW_CAP_HOT_RESET) && in bnxt_alloc_fw_health()
7868 !(bp->fw_cap & BNXT_FW_CAP_ERROR_RECOVERY)) in bnxt_alloc_fw_health()
7873 bp->fw_cap &= ~BNXT_FW_CAP_HOT_RESET; in bnxt_alloc_fw_health()
7874 bp->fw_cap &= ~BNXT_FW_CAP_ERROR_RECOVERY; in bnxt_alloc_fw_health()
7883 writel(reg & BNXT_GRC_BASE_MASK, bp->bar0 + in __bnxt_map_fw_health_reg()
7890 struct bnxt_fw_health *fw_health = bp->fw_health; in bnxt_inv_fw_health_reg()
7896 reg_type = BNXT_FW_HEALTH_REG_TYPE(fw_health->regs[BNXT_FW_HEALTH_REG]); in bnxt_inv_fw_health_reg()
7898 fw_health->status_reliable = false; in bnxt_inv_fw_health_reg()
7900 reg_type = BNXT_FW_HEALTH_REG_TYPE(fw_health->regs[BNXT_FW_RESET_CNT_REG]); in bnxt_inv_fw_health_reg()
7902 fw_health->resets_reliable = false; in bnxt_inv_fw_health_reg()
7912 if (bp->fw_health) in bnxt_try_map_fw_health_reg()
7913 bp->fw_health->status_reliable = false; in bnxt_try_map_fw_health_reg()
7916 hs = bp->bar0 + BNXT_FW_HEALTH_WIN_OFF(HCOMM_STATUS_STRUCT_LOC); in bnxt_try_map_fw_health_reg()
7920 if (!bp->chip_num) { in bnxt_try_map_fw_health_reg()
7922 bp->chip_num = readl(bp->bar0 + in bnxt_try_map_fw_health_reg()
7937 netdev_warn(bp->dev, "no memory for firmware status checks\n"); in bnxt_try_map_fw_health_reg()
7941 bp->fw_health->regs[BNXT_FW_HEALTH_REG] = status_loc; in bnxt_try_map_fw_health_reg()
7945 bp->fw_health->mapped_regs[BNXT_FW_HEALTH_REG] = in bnxt_try_map_fw_health_reg()
7949 bp->fw_health->status_reliable = true; in bnxt_try_map_fw_health_reg()
7954 struct bnxt_fw_health *fw_health = bp->fw_health; in bnxt_map_fw_health_regs()
7958 bp->fw_health->status_reliable = false; in bnxt_map_fw_health_regs()
7959 bp->fw_health->resets_reliable = false; in bnxt_map_fw_health_regs()
7960 /* Only pre-map the monitoring GRC registers using window 3 */ in bnxt_map_fw_health_regs()
7962 u32 reg = fw_health->regs[i]; in bnxt_map_fw_health_regs()
7969 return -ERANGE; in bnxt_map_fw_health_regs()
7970 fw_health->mapped_regs[i] = BNXT_FW_HEALTH_WIN_OFF(reg); in bnxt_map_fw_health_regs()
7972 bp->fw_health->status_reliable = true; in bnxt_map_fw_health_regs()
7973 bp->fw_health->resets_reliable = true; in bnxt_map_fw_health_regs()
7983 if (!bp->fw_health) in bnxt_remap_fw_health_regs()
7986 if (bp->fw_cap & BNXT_FW_CAP_ERROR_RECOVERY) { in bnxt_remap_fw_health_regs()
7987 bp->fw_health->status_reliable = true; in bnxt_remap_fw_health_regs()
7988 bp->fw_health->resets_reliable = true; in bnxt_remap_fw_health_regs()
7996 struct bnxt_fw_health *fw_health = bp->fw_health; in bnxt_hwrm_error_recovery_qcfg()
8001 if (!(bp->fw_cap & BNXT_FW_CAP_ERROR_RECOVERY)) in bnxt_hwrm_error_recovery_qcfg()
8012 fw_health->flags = le32_to_cpu(resp->flags); in bnxt_hwrm_error_recovery_qcfg()
8013 if ((fw_health->flags & ERROR_RECOVERY_QCFG_RESP_FLAGS_CO_CPU) && in bnxt_hwrm_error_recovery_qcfg()
8014 !(bp->fw_cap & BNXT_FW_CAP_KONG_MB_CHNL)) { in bnxt_hwrm_error_recovery_qcfg()
8015 rc = -EINVAL; in bnxt_hwrm_error_recovery_qcfg()
8018 fw_health->polling_dsecs = le32_to_cpu(resp->driver_polling_freq); in bnxt_hwrm_error_recovery_qcfg()
8019 fw_health->master_func_wait_dsecs = in bnxt_hwrm_error_recovery_qcfg()
8020 le32_to_cpu(resp->master_func_wait_period); in bnxt_hwrm_error_recovery_qcfg()
8021 fw_health->normal_func_wait_dsecs = in bnxt_hwrm_error_recovery_qcfg()
8022 le32_to_cpu(resp->normal_func_wait_period); in bnxt_hwrm_error_recovery_qcfg()
8023 fw_health->post_reset_wait_dsecs = in bnxt_hwrm_error_recovery_qcfg()
8024 le32_to_cpu(resp->master_func_wait_period_after_reset); in bnxt_hwrm_error_recovery_qcfg()
8025 fw_health->post_reset_max_wait_dsecs = in bnxt_hwrm_error_recovery_qcfg()
8026 le32_to_cpu(resp->max_bailout_time_after_reset); in bnxt_hwrm_error_recovery_qcfg()
8027 fw_health->regs[BNXT_FW_HEALTH_REG] = in bnxt_hwrm_error_recovery_qcfg()
8028 le32_to_cpu(resp->fw_health_status_reg); in bnxt_hwrm_error_recovery_qcfg()
8029 fw_health->regs[BNXT_FW_HEARTBEAT_REG] = in bnxt_hwrm_error_recovery_qcfg()
8030 le32_to_cpu(resp->fw_heartbeat_reg); in bnxt_hwrm_error_recovery_qcfg()
8031 fw_health->regs[BNXT_FW_RESET_CNT_REG] = in bnxt_hwrm_error_recovery_qcfg()
8032 le32_to_cpu(resp->fw_reset_cnt_reg); in bnxt_hwrm_error_recovery_qcfg()
8033 fw_health->regs[BNXT_FW_RESET_INPROG_REG] = in bnxt_hwrm_error_recovery_qcfg()
8034 le32_to_cpu(resp->reset_inprogress_reg); in bnxt_hwrm_error_recovery_qcfg()
8035 fw_health->fw_reset_inprog_reg_mask = in bnxt_hwrm_error_recovery_qcfg()
8036 le32_to_cpu(resp->reset_inprogress_reg_mask); in bnxt_hwrm_error_recovery_qcfg()
8037 fw_health->fw_reset_seq_cnt = resp->reg_array_cnt; in bnxt_hwrm_error_recovery_qcfg()
8038 if (fw_health->fw_reset_seq_cnt >= 16) { in bnxt_hwrm_error_recovery_qcfg()
8039 rc = -EINVAL; in bnxt_hwrm_error_recovery_qcfg()
8042 for (i = 0; i < fw_health->fw_reset_seq_cnt; i++) { in bnxt_hwrm_error_recovery_qcfg()
8043 fw_health->fw_reset_seq_regs[i] = in bnxt_hwrm_error_recovery_qcfg()
8044 le32_to_cpu(resp->reset_reg[i]); in bnxt_hwrm_error_recovery_qcfg()
8045 fw_health->fw_reset_seq_vals[i] = in bnxt_hwrm_error_recovery_qcfg()
8046 le32_to_cpu(resp->reset_reg_val[i]); in bnxt_hwrm_error_recovery_qcfg()
8047 fw_health->fw_reset_seq_delay_msec[i] = in bnxt_hwrm_error_recovery_qcfg()
8048 resp->delay_after_reset[i]; in bnxt_hwrm_error_recovery_qcfg()
8055 bp->fw_cap &= ~BNXT_FW_CAP_ERROR_RECOVERY; in bnxt_hwrm_error_recovery_qcfg()
8068 req->enables = 0; in bnxt_hwrm_func_reset()
8078 snprintf(bp->nvm_cfg_ver, FW_VER_STR_LEN, "%d.%d.%d", in bnxt_nvm_cfg_ver_get()
8100 if (!resp->max_configurable_queues) { in bnxt_hwrm_queue_qportcfg()
8101 rc = -EINVAL; in bnxt_hwrm_queue_qportcfg()
8104 bp->max_tc = resp->max_configurable_queues; in bnxt_hwrm_queue_qportcfg()
8105 bp->max_lltc = resp->max_configurable_lossless_queues; in bnxt_hwrm_queue_qportcfg()
8106 if (bp->max_tc > BNXT_MAX_QUEUE) in bnxt_hwrm_queue_qportcfg()
8107 bp->max_tc = BNXT_MAX_QUEUE; in bnxt_hwrm_queue_qportcfg()
8109 no_rdma = !(bp->flags & BNXT_FLAG_ROCE_CAP); in bnxt_hwrm_queue_qportcfg()
8110 qptr = &resp->queue_id0; in bnxt_hwrm_queue_qportcfg()
8111 for (i = 0, j = 0; i < bp->max_tc; i++) { in bnxt_hwrm_queue_qportcfg()
8112 bp->q_info[j].queue_id = *qptr; in bnxt_hwrm_queue_qportcfg()
8113 bp->q_ids[i] = *qptr++; in bnxt_hwrm_queue_qportcfg()
8114 bp->q_info[j].queue_profile = *qptr++; in bnxt_hwrm_queue_qportcfg()
8115 bp->tc_to_qidx[j] = j; in bnxt_hwrm_queue_qportcfg()
8116 if (!BNXT_CNPQ(bp->q_info[j].queue_profile) || in bnxt_hwrm_queue_qportcfg()
8120 bp->max_q = bp->max_tc; in bnxt_hwrm_queue_qportcfg()
8121 bp->max_tc = max_t(u8, j, 1); in bnxt_hwrm_queue_qportcfg()
8123 if (resp->queue_cfg_info & QUEUE_QPORTCFG_RESP_QUEUE_CFG_INFO_ASYM_CFG) in bnxt_hwrm_queue_qportcfg()
8124 bp->max_tc = 1; in bnxt_hwrm_queue_qportcfg()
8126 if (bp->max_lltc > bp->max_tc) in bnxt_hwrm_queue_qportcfg()
8127 bp->max_lltc = bp->max_tc; in bnxt_hwrm_queue_qportcfg()
8143 req->hwrm_intf_maj = HWRM_VERSION_MAJOR; in bnxt_hwrm_poll()
8144 req->hwrm_intf_min = HWRM_VERSION_MINOR; in bnxt_hwrm_poll()
8145 req->hwrm_intf_upd = HWRM_VERSION_UPDATE; in bnxt_hwrm_poll()
8165 bp->hwrm_max_req_len = HWRM_MAX_REQ_LEN; in bnxt_hwrm_ver_get()
8166 req->hwrm_intf_maj = HWRM_VERSION_MAJOR; in bnxt_hwrm_ver_get()
8167 req->hwrm_intf_min = HWRM_VERSION_MINOR; in bnxt_hwrm_ver_get()
8168 req->hwrm_intf_upd = HWRM_VERSION_UPDATE; in bnxt_hwrm_ver_get()
8175 memcpy(&bp->ver_resp, resp, sizeof(struct hwrm_ver_get_output)); in bnxt_hwrm_ver_get()
8177 bp->hwrm_spec_code = resp->hwrm_intf_maj_8b << 16 | in bnxt_hwrm_ver_get()
8178 resp->hwrm_intf_min_8b << 8 | in bnxt_hwrm_ver_get()
8179 resp->hwrm_intf_upd_8b; in bnxt_hwrm_ver_get()
8180 if (resp->hwrm_intf_maj_8b < 1) { in bnxt_hwrm_ver_get()
8181 netdev_warn(bp->dev, "HWRM interface %d.%d.%d is older than 1.0.0.\n", in bnxt_hwrm_ver_get()
8182 resp->hwrm_intf_maj_8b, resp->hwrm_intf_min_8b, in bnxt_hwrm_ver_get()
8183 resp->hwrm_intf_upd_8b); in bnxt_hwrm_ver_get()
8184 netdev_warn(bp->dev, "Please update firmware with HWRM interface 1.0.0 or newer.\n"); in bnxt_hwrm_ver_get()
8190 if (bp->hwrm_spec_code > hwrm_ver) in bnxt_hwrm_ver_get()
8191 snprintf(bp->hwrm_ver_supp, FW_VER_STR_LEN, "%d.%d.%d", in bnxt_hwrm_ver_get()
8195 snprintf(bp->hwrm_ver_supp, FW_VER_STR_LEN, "%d.%d.%d", in bnxt_hwrm_ver_get()
8196 resp->hwrm_intf_maj_8b, resp->hwrm_intf_min_8b, in bnxt_hwrm_ver_get()
8197 resp->hwrm_intf_upd_8b); in bnxt_hwrm_ver_get()
8199 fw_maj = le16_to_cpu(resp->hwrm_fw_major); in bnxt_hwrm_ver_get()
8200 if (bp->hwrm_spec_code > 0x10803 && fw_maj) { in bnxt_hwrm_ver_get()
8201 fw_min = le16_to_cpu(resp->hwrm_fw_minor); in bnxt_hwrm_ver_get()
8202 fw_bld = le16_to_cpu(resp->hwrm_fw_build); in bnxt_hwrm_ver_get()
8203 fw_rsv = le16_to_cpu(resp->hwrm_fw_patch); in bnxt_hwrm_ver_get()
8206 fw_maj = resp->hwrm_fw_maj_8b; in bnxt_hwrm_ver_get()
8207 fw_min = resp->hwrm_fw_min_8b; in bnxt_hwrm_ver_get()
8208 fw_bld = resp->hwrm_fw_bld_8b; in bnxt_hwrm_ver_get()
8209 fw_rsv = resp->hwrm_fw_rsvd_8b; in bnxt_hwrm_ver_get()
8212 bp->fw_ver_code = BNXT_FW_VER_CODE(fw_maj, fw_min, fw_bld, fw_rsv); in bnxt_hwrm_ver_get()
8213 snprintf(bp->fw_ver_str, len, "%d.%d.%d.%d", fw_maj, fw_min, fw_bld, in bnxt_hwrm_ver_get()
8216 if (strlen(resp->active_pkg_name)) { in bnxt_hwrm_ver_get()
8217 int fw_ver_len = strlen(bp->fw_ver_str); in bnxt_hwrm_ver_get()
8219 snprintf(bp->fw_ver_str + fw_ver_len, in bnxt_hwrm_ver_get()
8220 FW_VER_STR_LEN - fw_ver_len - 1, "/pkg %s", in bnxt_hwrm_ver_get()
8221 resp->active_pkg_name); in bnxt_hwrm_ver_get()
8222 bp->fw_cap |= BNXT_FW_CAP_PKG_VER; in bnxt_hwrm_ver_get()
8225 bp->hwrm_cmd_timeout = le16_to_cpu(resp->def_req_timeout); in bnxt_hwrm_ver_get()
8226 if (!bp->hwrm_cmd_timeout) in bnxt_hwrm_ver_get()
8227 bp->hwrm_cmd_timeout = DFLT_HWRM_CMD_TIMEOUT; in bnxt_hwrm_ver_get()
8228 bp->hwrm_cmd_max_timeout = le16_to_cpu(resp->max_req_timeout) * 1000; in bnxt_hwrm_ver_get()
8229 if (!bp->hwrm_cmd_max_timeout) in bnxt_hwrm_ver_get()
8230 bp->hwrm_cmd_max_timeout = HWRM_CMD_MAX_TIMEOUT; in bnxt_hwrm_ver_get()
8231 else if (bp->hwrm_cmd_max_timeout > HWRM_CMD_MAX_TIMEOUT) in bnxt_hwrm_ver_get()
8232 …netdev_warn(bp->dev, "Device requests max timeout of %d seconds, may trigger hung task watchdog\n", in bnxt_hwrm_ver_get()
8233 bp->hwrm_cmd_max_timeout / 1000); in bnxt_hwrm_ver_get()
8235 if (resp->hwrm_intf_maj_8b >= 1) { in bnxt_hwrm_ver_get()
8236 bp->hwrm_max_req_len = le16_to_cpu(resp->max_req_win_len); in bnxt_hwrm_ver_get()
8237 bp->hwrm_max_ext_req_len = le16_to_cpu(resp->max_ext_req_len); in bnxt_hwrm_ver_get()
8239 if (bp->hwrm_max_ext_req_len < HWRM_MAX_REQ_LEN) in bnxt_hwrm_ver_get()
8240 bp->hwrm_max_ext_req_len = HWRM_MAX_REQ_LEN; in bnxt_hwrm_ver_get()
8242 bp->chip_num = le16_to_cpu(resp->chip_num); in bnxt_hwrm_ver_get()
8243 bp->chip_rev = resp->chip_rev; in bnxt_hwrm_ver_get()
8244 if (bp->chip_num == CHIP_NUM_58700 && !resp->chip_rev && in bnxt_hwrm_ver_get()
8245 !resp->chip_metal) in bnxt_hwrm_ver_get()
8246 bp->flags |= BNXT_FLAG_CHIP_NITRO_A0; in bnxt_hwrm_ver_get()
8248 dev_caps_cfg = le32_to_cpu(resp->dev_caps_cfg); in bnxt_hwrm_ver_get()
8251 bp->fw_cap |= BNXT_FW_CAP_SHORT_CMD; in bnxt_hwrm_ver_get()
8254 bp->fw_cap |= BNXT_FW_CAP_KONG_MB_CHNL; in bnxt_hwrm_ver_get()
8258 bp->fw_cap |= BNXT_FW_CAP_OVS_64BIT_HANDLE; in bnxt_hwrm_ver_get()
8262 bp->fw_cap |= BNXT_FW_CAP_TRUSTED_VF; in bnxt_hwrm_ver_get()
8266 bp->fw_cap |= BNXT_FW_CAP_CFA_ADV_FLOW; in bnxt_hwrm_ver_get()
8280 if ((BNXT_VF(bp) && bp->hwrm_spec_code < 0x10901) || in bnxt_hwrm_fw_set_time()
8281 bp->hwrm_spec_code < 0x10400) in bnxt_hwrm_fw_set_time()
8282 return -EOPNOTSUPP; in bnxt_hwrm_fw_set_time()
8289 req->year = cpu_to_le16(1900 + tm.tm_year); in bnxt_hwrm_fw_set_time()
8290 req->month = 1 + tm.tm_mon; in bnxt_hwrm_fw_set_time()
8291 req->day = tm.tm_mday; in bnxt_hwrm_fw_set_time()
8292 req->hour = tm.tm_hour; in bnxt_hwrm_fw_set_time()
8293 req->minute = tm.tm_min; in bnxt_hwrm_fw_set_time()
8294 req->second = tm.tm_sec; in bnxt_hwrm_fw_set_time()
8320 if (masks[i] == -1ULL) in __bnxt_accumulate_stats()
8329 if (!stats->hw_stats) in bnxt_accumulate_stats()
8332 __bnxt_accumulate_stats(stats->hw_stats, stats->sw_stats, in bnxt_accumulate_stats()
8333 stats->hw_masks, stats->len / 8, false); in bnxt_accumulate_stats()
8343 if (bp->flags & BNXT_FLAG_CHIP_P5) in bnxt_accumulate_all_stats()
8346 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_accumulate_all_stats()
8347 struct bnxt_napi *bnapi = bp->bnapi[i]; in bnxt_accumulate_all_stats()
8351 cpr = &bnapi->cp_ring; in bnxt_accumulate_all_stats()
8352 stats = &cpr->stats; in bnxt_accumulate_all_stats()
8355 __bnxt_accumulate_stats(stats->hw_stats, stats->sw_stats, in bnxt_accumulate_all_stats()
8356 ring0_stats->hw_masks, in bnxt_accumulate_all_stats()
8357 ring0_stats->len / 8, ignore_zero); in bnxt_accumulate_all_stats()
8359 if (bp->flags & BNXT_FLAG_PORT_STATS) { in bnxt_accumulate_all_stats()
8360 struct bnxt_stats_mem *stats = &bp->port_stats; in bnxt_accumulate_all_stats()
8361 __le64 *hw_stats = stats->hw_stats; in bnxt_accumulate_all_stats()
8362 u64 *sw_stats = stats->sw_stats; in bnxt_accumulate_all_stats()
8363 u64 *masks = stats->hw_masks; in bnxt_accumulate_all_stats()
8375 if (bp->flags & BNXT_FLAG_PORT_STATS_EXT) { in bnxt_accumulate_all_stats()
8376 bnxt_accumulate_stats(&bp->rx_port_stats_ext); in bnxt_accumulate_all_stats()
8377 bnxt_accumulate_stats(&bp->tx_port_stats_ext); in bnxt_accumulate_all_stats()
8384 struct bnxt_pf_info *pf = &bp->pf; in bnxt_hwrm_port_qstats()
8387 if (!(bp->flags & BNXT_FLAG_PORT_STATS)) in bnxt_hwrm_port_qstats()
8390 if (flags && !(bp->fw_cap & BNXT_FW_CAP_EXT_HW_STATS_SUPPORTED)) in bnxt_hwrm_port_qstats()
8391 return -EOPNOTSUPP; in bnxt_hwrm_port_qstats()
8397 req->flags = flags; in bnxt_hwrm_port_qstats()
8398 req->port_id = cpu_to_le16(pf->port_id); in bnxt_hwrm_port_qstats()
8399 req->tx_stat_host_addr = cpu_to_le64(bp->port_stats.hw_stats_map + in bnxt_hwrm_port_qstats()
8401 req->rx_stat_host_addr = cpu_to_le64(bp->port_stats.hw_stats_map); in bnxt_hwrm_port_qstats()
8411 struct bnxt_pf_info *pf = &bp->pf; in bnxt_hwrm_port_qstats_ext()
8415 if (!(bp->flags & BNXT_FLAG_PORT_STATS_EXT)) in bnxt_hwrm_port_qstats_ext()
8418 if (flags && !(bp->fw_cap & BNXT_FW_CAP_EXT_HW_STATS_SUPPORTED)) in bnxt_hwrm_port_qstats_ext()
8419 return -EOPNOTSUPP; in bnxt_hwrm_port_qstats_ext()
8425 req_qs->flags = flags; in bnxt_hwrm_port_qstats_ext()
8426 req_qs->port_id = cpu_to_le16(pf->port_id); in bnxt_hwrm_port_qstats_ext()
8427 req_qs->rx_stat_size = cpu_to_le16(sizeof(struct rx_port_stats_ext)); in bnxt_hwrm_port_qstats_ext()
8428 req_qs->rx_stat_host_addr = cpu_to_le64(bp->rx_port_stats_ext.hw_stats_map); in bnxt_hwrm_port_qstats_ext()
8429 tx_stat_size = bp->tx_port_stats_ext.hw_stats ? in bnxt_hwrm_port_qstats_ext()
8431 req_qs->tx_stat_size = cpu_to_le16(tx_stat_size); in bnxt_hwrm_port_qstats_ext()
8432 req_qs->tx_stat_host_addr = cpu_to_le64(bp->tx_port_stats_ext.hw_stats_map); in bnxt_hwrm_port_qstats_ext()
8436 bp->fw_rx_stats_ext_size = in bnxt_hwrm_port_qstats_ext()
8437 le16_to_cpu(resp_qs->rx_stat_size) / 8; in bnxt_hwrm_port_qstats_ext()
8439 bp->fw_rx_stats_ext_size > BNXT_RX_STATS_EXT_NUM_LEGACY) in bnxt_hwrm_port_qstats_ext()
8440 bp->fw_rx_stats_ext_size = BNXT_RX_STATS_EXT_NUM_LEGACY; in bnxt_hwrm_port_qstats_ext()
8442 bp->fw_tx_stats_ext_size = tx_stat_size ? in bnxt_hwrm_port_qstats_ext()
8443 le16_to_cpu(resp_qs->tx_stat_size) / 8 : 0; in bnxt_hwrm_port_qstats_ext()
8445 bp->fw_rx_stats_ext_size = 0; in bnxt_hwrm_port_qstats_ext()
8446 bp->fw_tx_stats_ext_size = 0; in bnxt_hwrm_port_qstats_ext()
8453 if (bp->fw_tx_stats_ext_size <= in bnxt_hwrm_port_qstats_ext()
8455 bp->pri2cos_valid = 0; in bnxt_hwrm_port_qstats_ext()
8463 req_qc->flags = cpu_to_le32(QUEUE_PRI2COS_QCFG_REQ_FLAGS_IVLAN); in bnxt_hwrm_port_qstats_ext()
8471 pri2cos = &resp_qc->pri0_cos_queue_id; in bnxt_hwrm_port_qstats_ext()
8479 bp->pri2cos_valid = false; in bnxt_hwrm_port_qstats_ext()
8483 for (j = 0; j < bp->max_q; j++) { in bnxt_hwrm_port_qstats_ext()
8484 if (bp->q_ids[j] == queue_id) in bnxt_hwrm_port_qstats_ext()
8485 bp->pri2cos_idx[i] = queue_idx; in bnxt_hwrm_port_qstats_ext()
8488 bp->pri2cos_valid = true; in bnxt_hwrm_port_qstats_ext()
8509 tpa_flags = bp->flags & BNXT_FLAG_TPA; in bnxt_set_tpa()
8512 for (i = 0; i < bp->nr_vnics; i++) { in bnxt_set_tpa()
8515 netdev_err(bp->dev, "hwrm vnic set tpa failure rc for vnic %d: %x\n", in bnxt_set_tpa()
8527 for (i = 0; i < bp->nr_vnics; i++) in bnxt_hwrm_clear_vnic_rss()
8533 if (!bp->vnic_info) in bnxt_clear_vnic()
8537 if (!(bp->flags & BNXT_FLAG_CHIP_P5)) { in bnxt_clear_vnic()
8543 if (bp->flags & BNXT_FLAG_TPA) in bnxt_clear_vnic()
8546 if (bp->flags & BNXT_FLAG_CHIP_P5) in bnxt_clear_vnic()
8573 return -EINVAL; in bnxt_hwrm_set_br_mode()
8579 req->fid = cpu_to_le16(0xffff); in bnxt_hwrm_set_br_mode()
8580 req->enables = cpu_to_le32(FUNC_CFG_REQ_ENABLES_EVB_MODE); in bnxt_hwrm_set_br_mode()
8581 req->evb_mode = evb_mode; in bnxt_hwrm_set_br_mode()
8590 if (BNXT_VF(bp) || bp->hwrm_spec_code < 0x10803) in bnxt_hwrm_set_cache_line_size()
8597 req->fid = cpu_to_le16(0xffff); in bnxt_hwrm_set_cache_line_size()
8598 req->enables = cpu_to_le32(FUNC_CFG_REQ_ENABLES_CACHE_LINESIZE); in bnxt_hwrm_set_cache_line_size()
8599 req->options = FUNC_CFG_REQ_OPTIONS_CACHE_LINESIZE_SIZE_64; in bnxt_hwrm_set_cache_line_size()
8601 req->options = FUNC_CFG_REQ_OPTIONS_CACHE_LINESIZE_SIZE_128; in bnxt_hwrm_set_cache_line_size()
8608 struct bnxt_vnic_info *vnic = &bp->vnic_info[vnic_id]; in __bnxt_setup_vnic()
8611 if (vnic->flags & BNXT_VNIC_RFS_NEW_RSS_FLAG) in __bnxt_setup_vnic()
8617 netdev_err(bp->dev, "hwrm vnic %d alloc failure rc: %x\n", in __bnxt_setup_vnic()
8621 bp->rsscos_nr_ctxs++; in __bnxt_setup_vnic()
8626 netdev_err(bp->dev, "hwrm vnic %d cos ctx alloc failure rc: %x\n", in __bnxt_setup_vnic()
8630 bp->rsscos_nr_ctxs++; in __bnxt_setup_vnic()
8637 netdev_err(bp->dev, "hwrm vnic %d cfg failure rc: %x\n", in __bnxt_setup_vnic()
8645 netdev_err(bp->dev, "hwrm vnic %d set rss failure rc: %x\n", in __bnxt_setup_vnic()
8650 if (bp->flags & BNXT_FLAG_AGG_RINGS) { in __bnxt_setup_vnic()
8653 netdev_err(bp->dev, "hwrm vnic %d set hds failure rc: %x\n", in __bnxt_setup_vnic()
8666 nr_ctxs = bnxt_get_nr_rss_ctxs(bp, bp->rx_nr_rings); in __bnxt_setup_vnic_p5()
8670 netdev_err(bp->dev, "hwrm vnic %d ctx %d alloc failure rc: %x\n", in __bnxt_setup_vnic_p5()
8674 bp->rsscos_nr_ctxs++; in __bnxt_setup_vnic_p5()
8677 return -ENOMEM; in __bnxt_setup_vnic_p5()
8681 netdev_err(bp->dev, "hwrm vnic %d set rss failure rc: %d\n", in __bnxt_setup_vnic_p5()
8687 netdev_err(bp->dev, "hwrm vnic %d cfg failure rc: %x\n", in __bnxt_setup_vnic_p5()
8691 if (bp->flags & BNXT_FLAG_AGG_RINGS) { in __bnxt_setup_vnic_p5()
8694 netdev_err(bp->dev, "hwrm vnic %d set hds failure rc: %x\n", in __bnxt_setup_vnic_p5()
8703 if (bp->flags & BNXT_FLAG_CHIP_P5) in bnxt_setup_vnic()
8714 if (bp->flags & BNXT_FLAG_CHIP_P5) in bnxt_alloc_rfs_vnics()
8717 for (i = 0; i < bp->rx_nr_rings; i++) { in bnxt_alloc_rfs_vnics()
8722 if (vnic_id >= bp->nr_vnics) in bnxt_alloc_rfs_vnics()
8725 vnic = &bp->vnic_info[vnic_id]; in bnxt_alloc_rfs_vnics()
8726 vnic->flags |= BNXT_VNIC_RFS_FLAG; in bnxt_alloc_rfs_vnics()
8727 if (bp->flags & BNXT_FLAG_NEW_RSS_CAP) in bnxt_alloc_rfs_vnics()
8728 vnic->flags |= BNXT_VNIC_RFS_NEW_RSS_FLAG; in bnxt_alloc_rfs_vnics()
8731 netdev_err(bp->dev, "hwrm vnic %d alloc failure rc: %x\n", in bnxt_alloc_rfs_vnics()
8749 if (BNXT_VF(bp) && !bp->vf.vlan && !bnxt_is_trusted_vf(bp, &bp->vf)) in bnxt_promisc_ok()
8759 rc = bnxt_hwrm_vnic_alloc(bp, 1, bp->rx_nr_rings - 1, 1); in bnxt_setup_nitroa0_vnic()
8761 netdev_err(bp->dev, "Cannot allocate special vnic for NS2 A0: %x\n", in bnxt_setup_nitroa0_vnic()
8768 netdev_err(bp->dev, "Cannot allocate special vnic for NS2 A0: %x\n", in bnxt_setup_nitroa0_vnic()
8780 struct bnxt_vnic_info *vnic = &bp->vnic_info[0]; in bnxt_init_chip()
8782 unsigned int rx_nr_rings = bp->rx_nr_rings; in bnxt_init_chip()
8787 netdev_err(bp->dev, "hwrm stat ctx alloc failure rc: %x\n", in bnxt_init_chip()
8795 netdev_err(bp->dev, "hwrm ring alloc failure rc: %x\n", rc); in bnxt_init_chip()
8801 netdev_err(bp->dev, "hwrm_ring_grp alloc failure: %x\n", rc); in bnxt_init_chip()
8806 rx_nr_rings--; in bnxt_init_chip()
8811 netdev_err(bp->dev, "hwrm vnic alloc failure rc: %x\n", rc); in bnxt_init_chip()
8821 if (bp->fw_cap & BNXT_FW_CAP_RSS_HASH_TYPE_DELTA) in bnxt_init_chip()
8824 if (bp->flags & BNXT_FLAG_RFS) { in bnxt_init_chip()
8830 if (bp->flags & BNXT_FLAG_TPA) { in bnxt_init_chip()
8840 rc = bnxt_hwrm_set_vnic_filter(bp, 0, 0, bp->dev->dev_addr); in bnxt_init_chip()
8842 if (BNXT_VF(bp) && rc == -ENODEV) in bnxt_init_chip()
8843 netdev_err(bp->dev, "Cannot configure L2 filter while PF is unavailable\n"); in bnxt_init_chip()
8845 netdev_err(bp->dev, "HWRM vnic filter failure rc: %x\n", rc); in bnxt_init_chip()
8848 vnic->uc_filter_count = 1; in bnxt_init_chip()
8850 vnic->rx_mask = 0; in bnxt_init_chip()
8851 if (test_bit(BNXT_STATE_HALF_OPEN, &bp->state)) in bnxt_init_chip()
8854 if (bp->dev->flags & IFF_BROADCAST) in bnxt_init_chip()
8855 vnic->rx_mask |= CFA_L2_SET_RX_MASK_REQ_MASK_BCAST; in bnxt_init_chip()
8857 if (bp->dev->flags & IFF_PROMISC) in bnxt_init_chip()
8858 vnic->rx_mask |= CFA_L2_SET_RX_MASK_REQ_MASK_PROMISCUOUS; in bnxt_init_chip()
8860 if (bp->dev->flags & IFF_ALLMULTI) { in bnxt_init_chip()
8861 vnic->rx_mask |= CFA_L2_SET_RX_MASK_REQ_MASK_ALL_MCAST; in bnxt_init_chip()
8862 vnic->mc_list_count = 0; in bnxt_init_chip()
8863 } else if (bp->dev->flags & IFF_MULTICAST) { in bnxt_init_chip()
8867 vnic->rx_mask |= mask; in bnxt_init_chip()
8877 netdev_warn(bp->dev, "HWRM set coalescing failure rc: %x\n", in bnxt_init_chip()
8883 netdev_err(bp->dev, "Special vnic setup failure for NS2 A0 rc: %x\n", in bnxt_init_chip()
8889 netdev_update_features(bp->dev); in bnxt_init_chip()
8920 struct net_device *dev = bp->dev; in bnxt_set_real_num_queues()
8922 rc = netif_set_real_num_tx_queues(dev, bp->tx_nr_rings - in bnxt_set_real_num_queues()
8923 bp->tx_nr_rings_xdp); in bnxt_set_real_num_queues()
8927 rc = netif_set_real_num_rx_queues(dev, bp->rx_nr_rings); in bnxt_set_real_num_queues()
8932 if (bp->flags & BNXT_FLAG_RFS) in bnxt_set_real_num_queues()
8933 dev->rx_cpu_rmap = alloc_irq_cpu_rmap(bp->rx_nr_rings); in bnxt_set_real_num_queues()
8949 return -ENOMEM; in bnxt_trim_rings()
8953 _rx--; in bnxt_trim_rings()
8955 _tx--; in bnxt_trim_rings()
8965 const int len = sizeof(bp->irq_tbl[0].name); in bnxt_setup_msix()
8966 struct net_device *dev = bp->dev; in bnxt_setup_msix()
8974 count = bp->tx_nr_rings_per_tc; in bnxt_setup_msix()
8980 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_setup_msix()
8984 if (bp->flags & BNXT_FLAG_SHARED_RINGS) in bnxt_setup_msix()
8986 else if (i < bp->rx_nr_rings) in bnxt_setup_msix()
8991 snprintf(bp->irq_tbl[map_idx].name, len, "%s-%s-%d", dev->name, in bnxt_setup_msix()
8993 bp->irq_tbl[map_idx].handler = bnxt_msix; in bnxt_setup_msix()
8999 const int len = sizeof(bp->irq_tbl[0].name); in bnxt_setup_inta()
9001 if (netdev_get_num_tc(bp->dev)) in bnxt_setup_inta()
9002 netdev_reset_tc(bp->dev); in bnxt_setup_inta()
9004 snprintf(bp->irq_tbl[0].name, len, "%s-%s-%d", bp->dev->name, "TxRx", in bnxt_setup_inta()
9006 bp->irq_tbl[0].handler = bnxt_inta; in bnxt_setup_inta()
9015 if (!bp->irq_tbl) { in bnxt_setup_int_mode()
9017 if (rc || !bp->irq_tbl) in bnxt_setup_int_mode()
9018 return rc ?: -ENODEV; in bnxt_setup_int_mode()
9021 if (bp->flags & BNXT_FLAG_USING_MSIX) in bnxt_setup_int_mode()
9033 return bp->hw_resc.max_rsscos_ctxs; in bnxt_get_max_func_rss_ctxs()
9038 return bp->hw_resc.max_vnics; in bnxt_get_max_func_vnics()
9044 return bp->hw_resc.max_stat_ctxs; in bnxt_get_max_func_stat_ctxs()
9049 return bp->hw_resc.max_cp_rings; in bnxt_get_max_func_cp_rings()
9054 unsigned int cp = bp->hw_resc.max_cp_rings; in bnxt_get_max_func_cp_rings_for_en()
9056 if (!(bp->flags & BNXT_FLAG_CHIP_P5)) in bnxt_get_max_func_cp_rings_for_en()
9057 cp -= bnxt_get_ulp_msix_num(bp); in bnxt_get_max_func_cp_rings_for_en()
9064 struct bnxt_hw_resc *hw_resc = &bp->hw_resc; in bnxt_get_max_func_irqs()
9066 if (bp->flags & BNXT_FLAG_CHIP_P5) in bnxt_get_max_func_irqs()
9067 return min_t(unsigned int, hw_resc->max_irqs, hw_resc->max_nqs); in bnxt_get_max_func_irqs()
9069 return min_t(unsigned int, hw_resc->max_irqs, hw_resc->max_cp_rings); in bnxt_get_max_func_irqs()
9074 bp->hw_resc.max_irqs = max_irqs; in bnxt_set_max_func_irqs()
9082 if (bp->flags & BNXT_FLAG_CHIP_P5) in bnxt_get_avail_cp_rings_for_en()
9083 return cp - bp->rx_nr_rings - bp->tx_nr_rings; in bnxt_get_avail_cp_rings_for_en()
9085 return cp - bp->cp_nr_rings; in bnxt_get_avail_cp_rings_for_en()
9090 return bnxt_get_max_func_stat_ctxs(bp) - bnxt_get_func_stat_ctxs(bp); in bnxt_get_avail_stat_ctxs_for_en()
9097 int total_req = bp->cp_nr_rings + num; in bnxt_get_avail_msix()
9100 max_idx = bp->total_irqs; in bnxt_get_avail_msix()
9101 if (!(bp->flags & BNXT_FLAG_CHIP_P5)) in bnxt_get_avail_msix()
9102 max_idx = min_t(int, bp->total_irqs, max_cp); in bnxt_get_avail_msix()
9103 avail_msix = max_idx - bp->cp_nr_rings; in bnxt_get_avail_msix()
9108 num = max_irq - bp->cp_nr_rings; in bnxt_get_avail_msix()
9138 return -ENOMEM; in bnxt_init_msix()
9145 if (!(bp->flags & BNXT_FLAG_SHARED_RINGS)) in bnxt_init_msix()
9148 total_vecs = pci_enable_msix_range(bp->pdev, msix_ent, min, total_vecs); in bnxt_init_msix()
9151 rc = -ENODEV; in bnxt_init_msix()
9155 bp->irq_tbl = kcalloc(total_vecs, sizeof(struct bnxt_irq), GFP_KERNEL); in bnxt_init_msix()
9156 if (bp->irq_tbl) { in bnxt_init_msix()
9158 bp->irq_tbl[i].vector = msix_ent[i].vector; in bnxt_init_msix()
9160 bp->total_irqs = total_vecs; in bnxt_init_msix()
9162 rc = bnxt_trim_rings(bp, &bp->rx_nr_rings, &bp->tx_nr_rings, in bnxt_init_msix()
9163 total_vecs - ulp_msix, min == 1); in bnxt_init_msix()
9167 bp->cp_nr_rings = (min == 1) ? in bnxt_init_msix()
9168 max_t(int, bp->tx_nr_rings, bp->rx_nr_rings) : in bnxt_init_msix()
9169 bp->tx_nr_rings + bp->rx_nr_rings; in bnxt_init_msix()
9172 rc = -ENOMEM; in bnxt_init_msix()
9175 bp->flags |= BNXT_FLAG_USING_MSIX; in bnxt_init_msix()
9180 netdev_err(bp->dev, "bnxt_init_msix err: %x\n", rc); in bnxt_init_msix()
9181 kfree(bp->irq_tbl); in bnxt_init_msix()
9182 bp->irq_tbl = NULL; in bnxt_init_msix()
9183 pci_disable_msix(bp->pdev); in bnxt_init_msix()
9190 bp->irq_tbl = kzalloc(sizeof(struct bnxt_irq), GFP_KERNEL); in bnxt_init_inta()
9191 if (!bp->irq_tbl) in bnxt_init_inta()
9192 return -ENOMEM; in bnxt_init_inta()
9194 bp->total_irqs = 1; in bnxt_init_inta()
9195 bp->rx_nr_rings = 1; in bnxt_init_inta()
9196 bp->tx_nr_rings = 1; in bnxt_init_inta()
9197 bp->cp_nr_rings = 1; in bnxt_init_inta()
9198 bp->flags |= BNXT_FLAG_SHARED_RINGS; in bnxt_init_inta()
9199 bp->irq_tbl[0].vector = bp->pdev->irq; in bnxt_init_inta()
9205 int rc = -ENODEV; in bnxt_init_int_mode()
9207 if (bp->flags & BNXT_FLAG_MSIX_CAP) in bnxt_init_int_mode()
9210 if (!(bp->flags & BNXT_FLAG_USING_MSIX) && BNXT_PF(bp)) { in bnxt_init_int_mode()
9219 if (bp->flags & BNXT_FLAG_USING_MSIX) in bnxt_clear_int_mode()
9220 pci_disable_msix(bp->pdev); in bnxt_clear_int_mode()
9222 kfree(bp->irq_tbl); in bnxt_clear_int_mode()
9223 bp->irq_tbl = NULL; in bnxt_clear_int_mode()
9224 bp->flags &= ~BNXT_FLAG_USING_MSIX; in bnxt_clear_int_mode()
9229 int tcs = netdev_get_num_tc(bp->dev); in bnxt_reserve_rings()
9237 bnxt_get_num_msix(bp) != bp->total_irqs) { in bnxt_reserve_rings()
9249 netdev_err(bp->dev, "ring reservation/IRQ init failure rc: %d\n", rc); in bnxt_reserve_rings()
9252 if (tcs && (bp->tx_nr_rings_per_tc * tcs != in bnxt_reserve_rings()
9253 bp->tx_nr_rings - bp->tx_nr_rings_xdp)) { in bnxt_reserve_rings()
9254 netdev_err(bp->dev, "tx ring reservation failure\n"); in bnxt_reserve_rings()
9255 netdev_reset_tc(bp->dev); in bnxt_reserve_rings()
9256 if (bp->tx_nr_rings_xdp) in bnxt_reserve_rings()
9257 bp->tx_nr_rings_per_tc = bp->tx_nr_rings_xdp; in bnxt_reserve_rings()
9259 bp->tx_nr_rings_per_tc = bp->tx_nr_rings; in bnxt_reserve_rings()
9260 return -ENOMEM; in bnxt_reserve_rings()
9271 free_irq_cpu_rmap(bp->dev->rx_cpu_rmap); in bnxt_free_irq()
9272 bp->dev->rx_cpu_rmap = NULL; in bnxt_free_irq()
9274 if (!bp->irq_tbl || !bp->bnapi) in bnxt_free_irq()
9277 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_free_irq()
9280 irq = &bp->irq_tbl[map_idx]; in bnxt_free_irq()
9281 if (irq->requested) { in bnxt_free_irq()
9282 if (irq->have_cpumask) { in bnxt_free_irq()
9283 irq_set_affinity_hint(irq->vector, NULL); in bnxt_free_irq()
9284 free_cpumask_var(irq->cpu_mask); in bnxt_free_irq()
9285 irq->have_cpumask = 0; in bnxt_free_irq()
9287 free_irq(irq->vector, bp->bnapi[i]); in bnxt_free_irq()
9290 irq->requested = 0; in bnxt_free_irq()
9304 netdev_err(bp->dev, "bnxt_setup_int_mode err: %x\n", in bnxt_request_irq()
9309 rmap = bp->dev->rx_cpu_rmap; in bnxt_request_irq()
9311 if (!(bp->flags & BNXT_FLAG_USING_MSIX)) in bnxt_request_irq()
9314 for (i = 0, j = 0; i < bp->cp_nr_rings; i++) { in bnxt_request_irq()
9316 struct bnxt_irq *irq = &bp->irq_tbl[map_idx]; in bnxt_request_irq()
9319 if (rmap && bp->bnapi[i]->rx_ring) { in bnxt_request_irq()
9320 rc = irq_cpu_rmap_add(rmap, irq->vector); in bnxt_request_irq()
9322 netdev_warn(bp->dev, "failed adding irq rmap for ring %d\n", in bnxt_request_irq()
9327 rc = request_irq(irq->vector, irq->handler, flags, irq->name, in bnxt_request_irq()
9328 bp->bnapi[i]); in bnxt_request_irq()
9332 irq->requested = 1; in bnxt_request_irq()
9334 if (zalloc_cpumask_var(&irq->cpu_mask, GFP_KERNEL)) { in bnxt_request_irq()
9335 int numa_node = dev_to_node(&bp->pdev->dev); in bnxt_request_irq()
9337 irq->have_cpumask = 1; in bnxt_request_irq()
9339 irq->cpu_mask); in bnxt_request_irq()
9340 rc = irq_set_affinity_hint(irq->vector, irq->cpu_mask); in bnxt_request_irq()
9342 netdev_warn(bp->dev, in bnxt_request_irq()
9344 irq->vector); in bnxt_request_irq()
9356 if (!bp->bnapi) in bnxt_del_napi()
9359 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_del_napi()
9360 struct bnxt_napi *bnapi = bp->bnapi[i]; in bnxt_del_napi()
9362 __netif_napi_del(&bnapi->napi); in bnxt_del_napi()
9373 unsigned int cp_nr_rings = bp->cp_nr_rings; in bnxt_init_napi()
9376 if (bp->flags & BNXT_FLAG_USING_MSIX) { in bnxt_init_napi()
9379 if (bp->flags & BNXT_FLAG_CHIP_P5) in bnxt_init_napi()
9382 cp_nr_rings--; in bnxt_init_napi()
9384 bnapi = bp->bnapi[i]; in bnxt_init_napi()
9385 netif_napi_add(bp->dev, &bnapi->napi, poll_fn); in bnxt_init_napi()
9388 bnapi = bp->bnapi[cp_nr_rings]; in bnxt_init_napi()
9389 netif_napi_add(bp->dev, &bnapi->napi, in bnxt_init_napi()
9393 bnapi = bp->bnapi[0]; in bnxt_init_napi()
9394 netif_napi_add(bp->dev, &bnapi->napi, bnxt_poll); in bnxt_init_napi()
9402 if (!bp->bnapi || in bnxt_disable_napi()
9403 test_and_set_bit(BNXT_STATE_NAPI_DISABLED, &bp->state)) in bnxt_disable_napi()
9406 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_disable_napi()
9407 struct bnxt_napi *bnapi = bp->bnapi[i]; in bnxt_disable_napi()
9410 cpr = &bnapi->cp_ring; in bnxt_disable_napi()
9411 if (bnapi->tx_fault) in bnxt_disable_napi()
9412 cpr->sw_stats.tx.tx_resets++; in bnxt_disable_napi()
9413 if (bnapi->in_reset) in bnxt_disable_napi()
9414 cpr->sw_stats.rx.rx_resets++; in bnxt_disable_napi()
9415 napi_disable(&bnapi->napi); in bnxt_disable_napi()
9416 if (bnapi->rx_ring) in bnxt_disable_napi()
9417 cancel_work_sync(&cpr->dim.work); in bnxt_disable_napi()
9425 clear_bit(BNXT_STATE_NAPI_DISABLED, &bp->state); in bnxt_enable_napi()
9426 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_enable_napi()
9427 struct bnxt_napi *bnapi = bp->bnapi[i]; in bnxt_enable_napi()
9430 bnapi->tx_fault = 0; in bnxt_enable_napi()
9432 cpr = &bnapi->cp_ring; in bnxt_enable_napi()
9433 bnapi->in_reset = false; in bnxt_enable_napi()
9435 bnapi->tx_pkts = 0; in bnxt_enable_napi()
9437 if (bnapi->rx_ring) { in bnxt_enable_napi()
9438 INIT_WORK(&cpr->dim.work, bnxt_dim_work); in bnxt_enable_napi()
9439 cpr->dim.mode = DIM_CQ_PERIOD_MODE_START_FROM_EQE; in bnxt_enable_napi()
9441 napi_enable(&bnapi->napi); in bnxt_enable_napi()
9450 if (bp->tx_ring) { in bnxt_tx_disable()
9451 for (i = 0; i < bp->tx_nr_rings; i++) { in bnxt_tx_disable()
9452 txr = &bp->tx_ring[i]; in bnxt_tx_disable()
9453 WRITE_ONCE(txr->dev_state, BNXT_DEV_STATE_CLOSING); in bnxt_tx_disable()
9459 netif_carrier_off(bp->dev); in bnxt_tx_disable()
9461 netif_tx_disable(bp->dev); in bnxt_tx_disable()
9469 for (i = 0; i < bp->tx_nr_rings; i++) { in bnxt_tx_enable()
9470 txr = &bp->tx_ring[i]; in bnxt_tx_enable()
9471 WRITE_ONCE(txr->dev_state, 0); in bnxt_tx_enable()
9475 netif_tx_wake_all_queues(bp->dev); in bnxt_tx_enable()
9477 netif_carrier_on(bp->dev); in bnxt_tx_enable()
9482 u8 active_fec = link_info->active_fec_sig_mode & in bnxt_report_fec()
9513 netif_carrier_on(bp->dev); in bnxt_report_link()
9514 speed = bnxt_fw_to_ethtool_speed(bp->link_info.link_speed); in bnxt_report_link()
9516 netdev_info(bp->dev, "NIC Link is Up, speed unknown\n"); in bnxt_report_link()
9519 if (bp->link_info.duplex == BNXT_LINK_DUPLEX_FULL) in bnxt_report_link()
9523 if (bp->link_info.pause == BNXT_LINK_PAUSE_BOTH) in bnxt_report_link()
9524 flow_ctrl = "ON - receive & transmit"; in bnxt_report_link()
9525 else if (bp->link_info.pause == BNXT_LINK_PAUSE_TX) in bnxt_report_link()
9526 flow_ctrl = "ON - transmit"; in bnxt_report_link()
9527 else if (bp->link_info.pause == BNXT_LINK_PAUSE_RX) in bnxt_report_link()
9528 flow_ctrl = "ON - receive"; in bnxt_report_link()
9531 if (bp->link_info.phy_qcfg_resp.option_flags & in bnxt_report_link()
9533 u8 sig_mode = bp->link_info.active_fec_sig_mode & in bnxt_report_link()
9546 netdev_info(bp->dev, "NIC Link is Up, %u Mbps %s%s duplex, Flow control: %s\n", in bnxt_report_link()
9548 if (bp->phy_flags & BNXT_PHY_FL_EEE_CAP) in bnxt_report_link()
9549 netdev_info(bp->dev, "EEE is %s\n", in bnxt_report_link()
9550 bp->eee.eee_active ? "active" : in bnxt_report_link()
9552 fec = bp->link_info.fec_cfg; in bnxt_report_link()
9554 netdev_info(bp->dev, "FEC autoneg %s encoding: %s\n", in bnxt_report_link()
9556 bnxt_report_fec(&bp->link_info)); in bnxt_report_link()
9558 netif_carrier_off(bp->dev); in bnxt_report_link()
9559 netdev_err(bp->dev, "NIC Link is Down\n"); in bnxt_report_link()
9565 if (!resp->supported_speeds_auto_mode && in bnxt_phy_qcaps_no_speed()
9566 !resp->supported_speeds_force_mode && in bnxt_phy_qcaps_no_speed()
9567 !resp->supported_pam4_speeds_auto_mode && in bnxt_phy_qcaps_no_speed()
9568 !resp->supported_pam4_speeds_force_mode) in bnxt_phy_qcaps_no_speed()
9575 struct bnxt_link_info *link_info = &bp->link_info; in bnxt_hwrm_phy_qcaps()
9580 if (bp->hwrm_spec_code < 0x10201) in bnxt_hwrm_phy_qcaps()
9592 bp->phy_flags = resp->flags | (le16_to_cpu(resp->flags2) << 8); in bnxt_hwrm_phy_qcaps()
9593 if (resp->flags & PORT_PHY_QCAPS_RESP_FLAGS_EEE_SUPPORTED) { in bnxt_hwrm_phy_qcaps()
9594 struct ethtool_eee *eee = &bp->eee; in bnxt_hwrm_phy_qcaps()
9595 u16 fw_speeds = le16_to_cpu(resp->supported_speeds_eee_mode); in bnxt_hwrm_phy_qcaps()
9597 eee->supported = _bnxt_fw_to_ethtool_adv_spds(fw_speeds, 0); in bnxt_hwrm_phy_qcaps()
9598 bp->lpi_tmr_lo = le32_to_cpu(resp->tx_lpi_timer_low) & in bnxt_hwrm_phy_qcaps()
9600 bp->lpi_tmr_hi = le32_to_cpu(resp->valid_tx_lpi_timer_high) & in bnxt_hwrm_phy_qcaps()
9604 if (bp->hwrm_spec_code >= 0x10a01) { in bnxt_hwrm_phy_qcaps()
9606 link_info->phy_state = BNXT_PHY_STATE_DISABLED; in bnxt_hwrm_phy_qcaps()
9607 netdev_warn(bp->dev, "Ethernet link disabled\n"); in bnxt_hwrm_phy_qcaps()
9608 } else if (link_info->phy_state == BNXT_PHY_STATE_DISABLED) { in bnxt_hwrm_phy_qcaps()
9609 link_info->phy_state = BNXT_PHY_STATE_ENABLED; in bnxt_hwrm_phy_qcaps()
9610 netdev_info(bp->dev, "Ethernet link enabled\n"); in bnxt_hwrm_phy_qcaps()
9611 /* Phy re-enabled, reprobe the speeds */ in bnxt_hwrm_phy_qcaps()
9612 link_info->support_auto_speeds = 0; in bnxt_hwrm_phy_qcaps()
9613 link_info->support_pam4_auto_speeds = 0; in bnxt_hwrm_phy_qcaps()
9616 if (resp->supported_speeds_auto_mode) in bnxt_hwrm_phy_qcaps()
9617 link_info->support_auto_speeds = in bnxt_hwrm_phy_qcaps()
9618 le16_to_cpu(resp->supported_speeds_auto_mode); in bnxt_hwrm_phy_qcaps()
9619 if (resp->supported_pam4_speeds_auto_mode) in bnxt_hwrm_phy_qcaps()
9620 link_info->support_pam4_auto_speeds = in bnxt_hwrm_phy_qcaps()
9621 le16_to_cpu(resp->supported_pam4_speeds_auto_mode); in bnxt_hwrm_phy_qcaps()
9623 bp->port_count = resp->port_cnt; in bnxt_hwrm_phy_qcaps()
9639 struct bnxt_link_info *link_info = &bp->link_info; in bnxt_update_link()
9642 u8 link_state = link_info->link_state; in bnxt_update_link()
9654 if (BNXT_VF(bp) && rc == -ENODEV) { in bnxt_update_link()
9655 netdev_warn(bp->dev, "Cannot obtain link state while PF unavailable.\n"); in bnxt_update_link()
9661 memcpy(&link_info->phy_qcfg_resp, resp, sizeof(*resp)); in bnxt_update_link()
9662 link_info->phy_link_status = resp->link; in bnxt_update_link()
9663 link_info->duplex = resp->duplex_cfg; in bnxt_update_link()
9664 if (bp->hwrm_spec_code >= 0x10800) in bnxt_update_link()
9665 link_info->duplex = resp->duplex_state; in bnxt_update_link()
9666 link_info->pause = resp->pause; in bnxt_update_link()
9667 link_info->auto_mode = resp->auto_mode; in bnxt_update_link()
9668 link_info->auto_pause_setting = resp->auto_pause; in bnxt_update_link()
9669 link_info->lp_pause = resp->link_partner_adv_pause; in bnxt_update_link()
9670 link_info->force_pause_setting = resp->force_pause; in bnxt_update_link()
9671 link_info->duplex_setting = resp->duplex_cfg; in bnxt_update_link()
9672 if (link_info->phy_link_status == BNXT_LINK_LINK) in bnxt_update_link()
9673 link_info->link_speed = le16_to_cpu(resp->link_speed); in bnxt_update_link()
9675 link_info->link_speed = 0; in bnxt_update_link()
9676 link_info->force_link_speed = le16_to_cpu(resp->force_link_speed); in bnxt_update_link()
9677 link_info->force_pam4_link_speed = in bnxt_update_link()
9678 le16_to_cpu(resp->force_pam4_link_speed); in bnxt_update_link()
9679 link_info->support_speeds = le16_to_cpu(resp->support_speeds); in bnxt_update_link()
9680 link_info->support_pam4_speeds = le16_to_cpu(resp->support_pam4_speeds); in bnxt_update_link()
9681 link_info->auto_link_speeds = le16_to_cpu(resp->auto_link_speed_mask); in bnxt_update_link()
9682 link_info->auto_pam4_link_speeds = in bnxt_update_link()
9683 le16_to_cpu(resp->auto_pam4_link_speed_mask); in bnxt_update_link()
9684 link_info->lp_auto_link_speeds = in bnxt_update_link()
9685 le16_to_cpu(resp->link_partner_adv_speeds); in bnxt_update_link()
9686 link_info->lp_auto_pam4_link_speeds = in bnxt_update_link()
9687 resp->link_partner_pam4_adv_speeds; in bnxt_update_link()
9688 link_info->preemphasis = le32_to_cpu(resp->preemphasis); in bnxt_update_link()
9689 link_info->phy_ver[0] = resp->phy_maj; in bnxt_update_link()
9690 link_info->phy_ver[1] = resp->phy_min; in bnxt_update_link()
9691 link_info->phy_ver[2] = resp->phy_bld; in bnxt_update_link()
9692 link_info->media_type = resp->media_type; in bnxt_update_link()
9693 link_info->phy_type = resp->phy_type; in bnxt_update_link()
9694 link_info->transceiver = resp->xcvr_pkg_type; in bnxt_update_link()
9695 link_info->phy_addr = resp->eee_config_phy_addr & in bnxt_update_link()
9697 link_info->module_status = resp->module_status; in bnxt_update_link()
9699 if (bp->phy_flags & BNXT_PHY_FL_EEE_CAP) { in bnxt_update_link()
9700 struct ethtool_eee *eee = &bp->eee; in bnxt_update_link()
9703 eee->eee_active = 0; in bnxt_update_link()
9704 if (resp->eee_config_phy_addr & in bnxt_update_link()
9706 eee->eee_active = 1; in bnxt_update_link()
9708 resp->link_partner_adv_eee_link_speed_mask); in bnxt_update_link()
9709 eee->lp_advertised = in bnxt_update_link()
9713 /* Pull initial EEE config */ in bnxt_update_link()
9715 if (resp->eee_config_phy_addr & in bnxt_update_link()
9717 eee->eee_enabled = 1; in bnxt_update_link()
9719 fw_speeds = le16_to_cpu(resp->adv_eee_link_speed_mask); in bnxt_update_link()
9720 eee->advertised = in bnxt_update_link()
9723 if (resp->eee_config_phy_addr & in bnxt_update_link()
9727 eee->tx_lpi_enabled = 1; in bnxt_update_link()
9728 tmr = resp->xcvr_identifier_type_tx_lpi_timer; in bnxt_update_link()
9729 eee->tx_lpi_timer = le32_to_cpu(tmr) & in bnxt_update_link()
9735 link_info->fec_cfg = PORT_PHY_QCFG_RESP_FEC_CFG_FEC_NONE_SUPPORTED; in bnxt_update_link()
9736 if (bp->hwrm_spec_code >= 0x10504) { in bnxt_update_link()
9737 link_info->fec_cfg = le16_to_cpu(resp->fec_cfg); in bnxt_update_link()
9738 link_info->active_fec_sig_mode = resp->active_fec_signal_mode; in bnxt_update_link()
9742 if (link_info->phy_link_status == BNXT_LINK_LINK) in bnxt_update_link()
9743 link_info->link_state = BNXT_LINK_STATE_UP; in bnxt_update_link()
9745 link_info->link_state = BNXT_LINK_STATE_DOWN; in bnxt_update_link()
9746 if (link_state != link_info->link_state) in bnxt_update_link()
9750 link_info->link_state = BNXT_LINK_STATE_DOWN; in bnxt_update_link()
9760 if (bnxt_support_dropped(link_info->advertising, in bnxt_update_link()
9761 link_info->support_auto_speeds)) { in bnxt_update_link()
9762 link_info->advertising = link_info->support_auto_speeds; in bnxt_update_link()
9765 if (bnxt_support_dropped(link_info->advertising_pam4, in bnxt_update_link()
9766 link_info->support_pam4_auto_speeds)) { in bnxt_update_link()
9767 link_info->advertising_pam4 = link_info->support_pam4_auto_speeds; in bnxt_update_link()
9770 if (support_changed && (link_info->autoneg & BNXT_AUTONEG_SPEED)) in bnxt_update_link()
9777 struct bnxt_link_info *link_info = &bp->link_info; in bnxt_get_port_module_status()
9778 struct hwrm_port_phy_qcfg_output *resp = &link_info->phy_qcfg_resp; in bnxt_get_port_module_status()
9784 module_status = link_info->module_status; in bnxt_get_port_module_status()
9789 netdev_warn(bp->dev, "Unqualified SFP+ module detected on port %d\n", in bnxt_get_port_module_status()
9790 bp->pf.port_id); in bnxt_get_port_module_status()
9791 if (bp->hwrm_spec_code >= 0x10201) { in bnxt_get_port_module_status()
9792 netdev_warn(bp->dev, "Module part number %s\n", in bnxt_get_port_module_status()
9793 resp->phy_vendor_partnumber); in bnxt_get_port_module_status()
9796 netdev_warn(bp->dev, "TX is disabled\n"); in bnxt_get_port_module_status()
9798 netdev_warn(bp->dev, "SFP+ module is shutdown\n"); in bnxt_get_port_module_status()
9805 if (bp->link_info.autoneg & BNXT_AUTONEG_FLOW_CTRL) { in bnxt_hwrm_set_pause_common()
9806 if (bp->hwrm_spec_code >= 0x10201) in bnxt_hwrm_set_pause_common()
9807 req->auto_pause = in bnxt_hwrm_set_pause_common()
9809 if (bp->link_info.req_flow_ctrl & BNXT_LINK_PAUSE_RX) in bnxt_hwrm_set_pause_common()
9810 req->auto_pause |= PORT_PHY_CFG_REQ_AUTO_PAUSE_RX; in bnxt_hwrm_set_pause_common()
9811 if (bp->link_info.req_flow_ctrl & BNXT_LINK_PAUSE_TX) in bnxt_hwrm_set_pause_common()
9812 req->auto_pause |= PORT_PHY_CFG_REQ_AUTO_PAUSE_TX; in bnxt_hwrm_set_pause_common()
9813 req->enables |= in bnxt_hwrm_set_pause_common()
9816 if (bp->link_info.req_flow_ctrl & BNXT_LINK_PAUSE_RX) in bnxt_hwrm_set_pause_common()
9817 req->force_pause |= PORT_PHY_CFG_REQ_FORCE_PAUSE_RX; in bnxt_hwrm_set_pause_common()
9818 if (bp->link_info.req_flow_ctrl & BNXT_LINK_PAUSE_TX) in bnxt_hwrm_set_pause_common()
9819 req->force_pause |= PORT_PHY_CFG_REQ_FORCE_PAUSE_TX; in bnxt_hwrm_set_pause_common()
9820 req->enables |= in bnxt_hwrm_set_pause_common()
9822 if (bp->hwrm_spec_code >= 0x10201) { in bnxt_hwrm_set_pause_common()
9823 req->auto_pause = req->force_pause; in bnxt_hwrm_set_pause_common()
9824 req->enables |= cpu_to_le32( in bnxt_hwrm_set_pause_common()
9832 if (bp->link_info.autoneg & BNXT_AUTONEG_SPEED) { in bnxt_hwrm_set_link_common()
9833 req->auto_mode |= PORT_PHY_CFG_REQ_AUTO_MODE_SPEED_MASK; in bnxt_hwrm_set_link_common()
9834 if (bp->link_info.advertising) { in bnxt_hwrm_set_link_common()
9835 req->enables |= cpu_to_le32(PORT_PHY_CFG_REQ_ENABLES_AUTO_LINK_SPEED_MASK); in bnxt_hwrm_set_link_common()
9836 req->auto_link_speed_mask = cpu_to_le16(bp->link_info.advertising); in bnxt_hwrm_set_link_common()
9838 if (bp->link_info.advertising_pam4) { in bnxt_hwrm_set_link_common()
9839 req->enables |= in bnxt_hwrm_set_link_common()
9841 req->auto_link_pam4_speed_mask = in bnxt_hwrm_set_link_common()
9842 cpu_to_le16(bp->link_info.advertising_pam4); in bnxt_hwrm_set_link_common()
9844 req->enables |= cpu_to_le32(PORT_PHY_CFG_REQ_ENABLES_AUTO_MODE); in bnxt_hwrm_set_link_common()
9845 req->flags |= cpu_to_le32(PORT_PHY_CFG_REQ_FLAGS_RESTART_AUTONEG); in bnxt_hwrm_set_link_common()
9847 req->flags |= cpu_to_le32(PORT_PHY_CFG_REQ_FLAGS_FORCE); in bnxt_hwrm_set_link_common()
9848 if (bp->link_info.req_signal_mode == BNXT_SIG_MODE_PAM4) { in bnxt_hwrm_set_link_common()
9849 req->force_pam4_link_speed = cpu_to_le16(bp->link_info.req_link_speed); in bnxt_hwrm_set_link_common()
9850 req->enables |= cpu_to_le32(PORT_PHY_CFG_REQ_ENABLES_FORCE_PAM4_LINK_SPEED); in bnxt_hwrm_set_link_common()
9852 req->force_link_speed = cpu_to_le16(bp->link_info.req_link_speed); in bnxt_hwrm_set_link_common()
9857 req->flags |= cpu_to_le32(PORT_PHY_CFG_REQ_FLAGS_RESET_PHY); in bnxt_hwrm_set_link_common()
9871 if ((bp->link_info.autoneg & BNXT_AUTONEG_FLOW_CTRL) || in bnxt_hwrm_set_pause()
9872 bp->link_info.force_link_chng) in bnxt_hwrm_set_pause()
9876 if (!rc && !(bp->link_info.autoneg & BNXT_AUTONEG_FLOW_CTRL)) { in bnxt_hwrm_set_pause()
9881 bp->link_info.pause = in bnxt_hwrm_set_pause()
9882 bp->link_info.force_pause_setting = bp->link_info.req_flow_ctrl; in bnxt_hwrm_set_pause()
9883 bp->link_info.auto_pause_setting = 0; in bnxt_hwrm_set_pause()
9884 if (!bp->link_info.force_link_chng) in bnxt_hwrm_set_pause()
9887 bp->link_info.force_link_chng = false; in bnxt_hwrm_set_pause()
9894 struct ethtool_eee *eee = &bp->eee; in bnxt_hwrm_set_eee()
9896 if (eee->eee_enabled) { in bnxt_hwrm_set_eee()
9900 if (eee->tx_lpi_enabled) in bnxt_hwrm_set_eee()
9905 req->flags |= cpu_to_le32(flags); in bnxt_hwrm_set_eee()
9906 eee_speeds = bnxt_get_fw_auto_link_speeds(eee->advertised); in bnxt_hwrm_set_eee()
9907 req->eee_link_speed_mask = cpu_to_le16(eee_speeds); in bnxt_hwrm_set_eee()
9908 req->tx_lpi_timer = cpu_to_le32(eee->tx_lpi_timer); in bnxt_hwrm_set_eee()
9910 req->flags |= cpu_to_le32(PORT_PHY_CFG_REQ_FLAGS_EEE_DISABLE); in bnxt_hwrm_set_eee()
9941 if (pci_num_vf(bp->pdev) && in bnxt_hwrm_shutdown_link()
9942 !(bp->phy_flags & BNXT_PHY_FL_FW_MANAGED_LKDN)) in bnxt_hwrm_shutdown_link()
9949 req->flags = cpu_to_le32(PORT_PHY_CFG_REQ_FLAGS_FORCE_LINK_DWN); in bnxt_hwrm_shutdown_link()
9952 mutex_lock(&bp->link_lock); in bnxt_hwrm_shutdown_link()
9958 bp->link_info.link_state = BNXT_LINK_STATE_UNKNOWN; in bnxt_hwrm_shutdown_link()
9959 mutex_unlock(&bp->link_lock); in bnxt_hwrm_shutdown_link()
9970 netdev_err(bp->dev, "Failed FW reset via OP-TEE, rc=%d\n", rc); in bnxt_fw_reset_via_optee()
9974 netdev_err(bp->dev, "OP-TEE not supported\n"); in bnxt_fw_reset_via_optee()
9975 return -ENODEV; in bnxt_fw_reset_via_optee()
9981 if (bp->fw_health && bp->fw_health->status_reliable) { in bnxt_try_recover_fw()
9992 } while (rc == -EBUSY && retry < BNXT_FW_RETRY); in bnxt_try_recover_fw()
9995 netdev_err(bp->dev, in bnxt_try_recover_fw()
9998 rc = -ENODEV; in bnxt_try_recover_fw()
10001 netdev_warn(bp->dev, "Firmware recover via OP-TEE requested\n"); in bnxt_try_recover_fw()
10007 return -ENODEV; in bnxt_try_recover_fw()
10012 struct bnxt_hw_resc *hw_resc = &bp->hw_resc; in bnxt_clear_reservations()
10017 hw_resc->resv_cp_rings = 0; in bnxt_clear_reservations()
10018 hw_resc->resv_stat_ctxs = 0; in bnxt_clear_reservations()
10019 hw_resc->resv_irqs = 0; in bnxt_clear_reservations()
10020 hw_resc->resv_tx_rings = 0; in bnxt_clear_reservations()
10021 hw_resc->resv_rx_rings = 0; in bnxt_clear_reservations()
10022 hw_resc->resv_hw_ring_grps = 0; in bnxt_clear_reservations()
10023 hw_resc->resv_vnics = 0; in bnxt_clear_reservations()
10025 bp->tx_nr_rings = 0; in bnxt_clear_reservations()
10026 bp->rx_nr_rings = 0; in bnxt_clear_reservations()
10039 netdev_err(bp->dev, "resc_qcaps failed\n"); in bnxt_cancel_reservations()
10046 static int bnxt_hwrm_if_change(struct bnxt *bp, bool up) in bnxt_hwrm_if_change() argument
10050 bool fw_reset = !bp->irq_tbl; in bnxt_hwrm_if_change()
10055 if (!(bp->fw_cap & BNXT_FW_CAP_IF_CHANGE)) in bnxt_hwrm_if_change()
10062 if (up) in bnxt_hwrm_if_change()
10063 req->flags = cpu_to_le32(FUNC_DRV_IF_CHANGE_REQ_FLAGS_UP); in bnxt_hwrm_if_change()
10069 if (rc != -EAGAIN) in bnxt_hwrm_if_change()
10076 if (rc == -EAGAIN) { in bnxt_hwrm_if_change()
10080 flags = le32_to_cpu(resp->flags); in bnxt_hwrm_if_change()
10081 } else if (up) { in bnxt_hwrm_if_change()
10089 if (!up) { in bnxt_hwrm_if_change()
10097 test_bit(BNXT_STATE_FW_RESET_DET, &bp->state)) in bnxt_hwrm_if_change()
10102 if (test_bit(BNXT_STATE_IN_FW_RESET, &bp->state) && !fw_reset) { in bnxt_hwrm_if_change()
10103 netdev_err(bp->dev, "RESET_DONE not set during FW reset.\n"); in bnxt_hwrm_if_change()
10104 set_bit(BNXT_STATE_ABORT_ERR, &bp->state); in bnxt_hwrm_if_change()
10105 return -ENODEV; in bnxt_hwrm_if_change()
10109 set_bit(BNXT_STATE_FW_RESET_DET, &bp->state); in bnxt_hwrm_if_change()
10110 if (!test_bit(BNXT_STATE_IN_FW_RESET, &bp->state)) in bnxt_hwrm_if_change()
10113 kfree(bp->ctx); in bnxt_hwrm_if_change()
10114 bp->ctx = NULL; in bnxt_hwrm_if_change()
10118 clear_bit(BNXT_STATE_FW_RESET_DET, &bp->state); in bnxt_hwrm_if_change()
10119 set_bit(BNXT_STATE_ABORT_ERR, &bp->state); in bnxt_hwrm_if_change()
10125 clear_bit(BNXT_STATE_FW_RESET_DET, &bp->state); in bnxt_hwrm_if_change()
10126 netdev_err(bp->dev, "init int mode failed\n"); in bnxt_hwrm_if_change()
10139 struct bnxt_pf_info *pf = &bp->pf; in bnxt_hwrm_port_led_qcaps()
10142 bp->num_leds = 0; in bnxt_hwrm_port_led_qcaps()
10143 if (BNXT_VF(bp) || bp->hwrm_spec_code < 0x10601) in bnxt_hwrm_port_led_qcaps()
10150 req->port_id = cpu_to_le16(pf->port_id); in bnxt_hwrm_port_led_qcaps()
10157 if (resp->num_leds > 0 && resp->num_leds < BNXT_MAX_LED) { in bnxt_hwrm_port_led_qcaps()
10160 bp->num_leds = resp->num_leds; in bnxt_hwrm_port_led_qcaps()
10161 memcpy(bp->leds, &resp->led0_id, sizeof(bp->leds[0]) * in bnxt_hwrm_port_led_qcaps()
10162 bp->num_leds); in bnxt_hwrm_port_led_qcaps()
10163 for (i = 0; i < bp->num_leds; i++) { in bnxt_hwrm_port_led_qcaps()
10164 struct bnxt_led_info *led = &bp->leds[i]; in bnxt_hwrm_port_led_qcaps()
10165 __le16 caps = led->led_state_caps; in bnxt_hwrm_port_led_qcaps()
10167 if (!led->led_group_id || in bnxt_hwrm_port_led_qcaps()
10169 bp->num_leds = 0; in bnxt_hwrm_port_led_qcaps()
10188 req->port_id = cpu_to_le16(bp->pf.port_id); in bnxt_hwrm_alloc_wol_fltr()
10189 req->wol_type = WOL_FILTER_ALLOC_REQ_WOL_TYPE_MAGICPKT; in bnxt_hwrm_alloc_wol_fltr()
10190 req->enables = cpu_to_le32(WOL_FILTER_ALLOC_REQ_ENABLES_MAC_ADDRESS); in bnxt_hwrm_alloc_wol_fltr()
10191 memcpy(req->mac_address, bp->dev->dev_addr, ETH_ALEN); in bnxt_hwrm_alloc_wol_fltr()
10196 bp->wol_filter_id = resp->wol_filter_id; in bnxt_hwrm_alloc_wol_fltr()
10210 req->port_id = cpu_to_le16(bp->pf.port_id); in bnxt_hwrm_free_wol_fltr()
10211 req->enables = cpu_to_le32(WOL_FILTER_FREE_REQ_ENABLES_WOL_FILTER_ID); in bnxt_hwrm_free_wol_fltr()
10212 req->wol_filter_id = bp->wol_filter_id; in bnxt_hwrm_free_wol_fltr()
10228 req->port_id = cpu_to_le16(bp->pf.port_id); in bnxt_hwrm_get_wol_fltrs()
10229 req->handle = cpu_to_le16(handle); in bnxt_hwrm_get_wol_fltrs()
10233 next_handle = le16_to_cpu(resp->next_handle); in bnxt_hwrm_get_wol_fltrs()
10235 if (resp->wol_type == in bnxt_hwrm_get_wol_fltrs()
10237 bp->wol = 1; in bnxt_hwrm_get_wol_fltrs()
10238 bp->wol_filter_id = resp->wol_filter_id; in bnxt_hwrm_get_wol_fltrs()
10250 bp->wol = 0; in bnxt_get_wol_settings()
10251 if (!BNXT_PF(bp) || !(bp->flags & BNXT_FLAG_WOL_CAP)) in bnxt_get_wol_settings()
10275 len = sprintf(buf, "%u\n", resp->temp * 1000); /* display millidegree */ in bnxt_show_temp()
10291 if (bp->hwmon_dev) { in bnxt_hwmon_close()
10292 hwmon_device_unregister(bp->hwmon_dev); in bnxt_hwmon_close()
10293 bp->hwmon_dev = NULL; in bnxt_hwmon_close()
10300 struct pci_dev *pdev = bp->pdev; in bnxt_hwmon_open()
10306 if (rc == -EACCES || rc == -EOPNOTSUPP) { in bnxt_hwmon_open()
10311 if (bp->hwmon_dev) in bnxt_hwmon_open()
10314 bp->hwmon_dev = hwmon_device_register_with_groups(&pdev->dev, in bnxt_hwmon_open()
10317 if (IS_ERR(bp->hwmon_dev)) { in bnxt_hwmon_open()
10318 bp->hwmon_dev = NULL; in bnxt_hwmon_open()
10319 dev_warn(&pdev->dev, "Cannot register hwmon device\n"); in bnxt_hwmon_open()
10334 struct ethtool_eee *eee = &bp->eee; in bnxt_eee_config_ok()
10335 struct bnxt_link_info *link_info = &bp->link_info; in bnxt_eee_config_ok()
10337 if (!(bp->phy_flags & BNXT_PHY_FL_EEE_CAP)) in bnxt_eee_config_ok()
10340 if (eee->eee_enabled) { in bnxt_eee_config_ok()
10342 _bnxt_fw_to_ethtool_adv_spds(link_info->advertising, 0); in bnxt_eee_config_ok()
10344 if (!(link_info->autoneg & BNXT_AUTONEG_SPEED)) { in bnxt_eee_config_ok()
10345 eee->eee_enabled = 0; in bnxt_eee_config_ok()
10348 if (eee->advertised & ~advertising) { in bnxt_eee_config_ok()
10349 eee->advertised = advertising & eee->supported; in bnxt_eee_config_ok()
10362 struct bnxt_link_info *link_info = &bp->link_info; in bnxt_update_phy_setting()
10366 netdev_err(bp->dev, "failed to update link (rc: %x)\n", in bnxt_update_phy_setting()
10373 if ((link_info->autoneg & BNXT_AUTONEG_FLOW_CTRL) && in bnxt_update_phy_setting()
10374 (link_info->auto_pause_setting & BNXT_LINK_PAUSE_BOTH) != in bnxt_update_phy_setting()
10375 link_info->req_flow_ctrl) in bnxt_update_phy_setting()
10377 if (!(link_info->autoneg & BNXT_AUTONEG_FLOW_CTRL) && in bnxt_update_phy_setting()
10378 link_info->force_pause_setting != link_info->req_flow_ctrl) in bnxt_update_phy_setting()
10380 if (!(link_info->autoneg & BNXT_AUTONEG_SPEED)) { in bnxt_update_phy_setting()
10381 if (BNXT_AUTO_MODE(link_info->auto_mode)) in bnxt_update_phy_setting()
10383 if (link_info->req_signal_mode == BNXT_SIG_MODE_NRZ && in bnxt_update_phy_setting()
10384 link_info->req_link_speed != link_info->force_link_speed) in bnxt_update_phy_setting()
10386 else if (link_info->req_signal_mode == BNXT_SIG_MODE_PAM4 && in bnxt_update_phy_setting()
10387 link_info->req_link_speed != link_info->force_pam4_link_speed) in bnxt_update_phy_setting()
10389 if (link_info->req_duplex != link_info->duplex_setting) in bnxt_update_phy_setting()
10392 if (link_info->auto_mode == BNXT_LINK_AUTO_NONE) in bnxt_update_phy_setting()
10394 if (link_info->advertising != link_info->auto_link_speeds || in bnxt_update_phy_setting()
10395 link_info->advertising_pam4 != link_info->auto_pam4_link_speeds) in bnxt_update_phy_setting()
10400 * PHY_CFG to bring it back up. in bnxt_update_phy_setting()
10413 netdev_err(bp->dev, "failed to update phy setting (rc: %x)\n", in bnxt_update_phy_setting()
10421 /* Common routine to pre-map certain register block to different GRC window.
10431 bp->bar0 + BNXT_GRCPF_REG_WINDOW_BASE_OUT + 12); in bnxt_preset_reg_win()
10441 if (test_bit(BNXT_STATE_IN_FW_RESET, &bp->state)) in bnxt_reinit_after_abort()
10442 return -EBUSY; in bnxt_reinit_after_abort()
10444 if (bp->dev->reg_state == NETREG_UNREGISTERED) in bnxt_reinit_after_abort()
10445 return -ENODEV; in bnxt_reinit_after_abort()
10452 clear_bit(BNXT_STATE_ABORT_ERR, &bp->state); in bnxt_reinit_after_abort()
10453 set_bit(BNXT_STATE_FW_RESET_DET, &bp->state); in bnxt_reinit_after_abort()
10464 netif_carrier_off(bp->dev); in __bnxt_open_nic()
10469 netdev_err(bp->dev, "Failed to reserve default rings at open\n"); in __bnxt_open_nic()
10476 if ((bp->flags & BNXT_FLAG_RFS) && in __bnxt_open_nic()
10477 !(bp->flags & BNXT_FLAG_USING_MSIX)) { in __bnxt_open_nic()
10479 bp->dev->hw_features &= ~NETIF_F_NTUPLE; in __bnxt_open_nic()
10480 bp->flags &= ~BNXT_FLAG_RFS; in __bnxt_open_nic()
10485 netdev_err(bp->dev, "bnxt_alloc_mem err: %x\n", rc); in __bnxt_open_nic()
10493 netdev_err(bp->dev, "bnxt_request_irq err: %x\n", rc); in __bnxt_open_nic()
10500 netdev_err(bp->dev, "bnxt_init_nic err: %x\n", rc); in __bnxt_open_nic()
10508 mutex_lock(&bp->link_lock); in __bnxt_open_nic()
10510 mutex_unlock(&bp->link_lock); in __bnxt_open_nic()
10512 netdev_warn(bp->dev, "failed to update phy settings\n"); in __bnxt_open_nic()
10514 bp->link_info.phy_retry = true; in __bnxt_open_nic()
10515 bp->link_info.phy_retry_expires = in __bnxt_open_nic()
10522 udp_tunnel_nic_reset_ntf(bp->dev); in __bnxt_open_nic()
10524 if (bp->tx_nr_rings_xdp < num_possible_cpus()) { in __bnxt_open_nic()
10530 set_bit(BNXT_STATE_OPEN, &bp->state); in __bnxt_open_nic()
10534 mod_timer(&bp->timer, jiffies + bp->current_interval); in __bnxt_open_nic()
10536 mutex_lock(&bp->link_lock); in __bnxt_open_nic()
10538 mutex_unlock(&bp->link_lock); in __bnxt_open_nic()
10540 /* VF-reps may need to be re-opened after the PF is re-opened */ in __bnxt_open_nic()
10543 if (bp->ptp_cfg) in __bnxt_open_nic()
10544 atomic_set(&bp->ptp_cfg->tx_avail, BNXT_MAX_TX_TS); in __bnxt_open_nic()
10564 if (test_bit(BNXT_STATE_ABORT_ERR, &bp->state)) in bnxt_open_nic()
10565 rc = -EIO; in bnxt_open_nic()
10569 netdev_err(bp->dev, "nic open fail (rc: %x)\n", rc); in bnxt_open_nic()
10570 dev_close(bp->dev); in bnxt_open_nic()
10583 if (test_bit(BNXT_STATE_ABORT_ERR, &bp->state)) { in bnxt_half_open_nic()
10584 netdev_err(bp->dev, "A previous firmware reset has not completed, aborting half open\n"); in bnxt_half_open_nic()
10585 rc = -ENODEV; in bnxt_half_open_nic()
10591 netdev_err(bp->dev, "bnxt_alloc_mem err: %x\n", rc); in bnxt_half_open_nic()
10595 set_bit(BNXT_STATE_HALF_OPEN, &bp->state); in bnxt_half_open_nic()
10598 clear_bit(BNXT_STATE_HALF_OPEN, &bp->state); in bnxt_half_open_nic()
10600 netdev_err(bp->dev, "bnxt_init_nic err: %x\n", rc); in bnxt_half_open_nic()
10608 dev_close(bp->dev); in bnxt_half_open_nic()
10621 clear_bit(BNXT_STATE_HALF_OPEN, &bp->state); in bnxt_half_close_nic()
10627 struct bnxt_pf_info *pf = &bp->pf; in bnxt_reenable_sriov()
10628 int n = pf->active_vfs; in bnxt_reenable_sriov()
10640 if (test_bit(BNXT_STATE_ABORT_ERR, &bp->state)) { in bnxt_open()
10643 if (rc == -EBUSY) in bnxt_open()
10644 netdev_err(bp->dev, "A previous firmware reset has not completed, aborting\n"); in bnxt_open()
10646 netdev_err(bp->dev, "Failed to reinitialize after aborted firmware reset\n"); in bnxt_open()
10647 return -ENODEV; in bnxt_open()
10659 if (test_and_clear_bit(BNXT_STATE_FW_RESET_DET, &bp->state)) { in bnxt_open()
10660 if (!test_bit(BNXT_STATE_IN_FW_RESET, &bp->state)) { in bnxt_open()
10673 return (test_bit(BNXT_STATE_IN_SP_TASK, &bp->state) || in bnxt_drv_busy()
10674 test_bit(BNXT_STATE_READ_STATS, &bp->state)); in bnxt_drv_busy()
10683 /* Close the VF-reps before closing PF */ in __bnxt_close_nic()
10687 /* Change device state to avoid TX queue wake up's */ in __bnxt_close_nic()
10690 clear_bit(BNXT_STATE_OPEN, &bp->state); in __bnxt_close_nic()
10702 del_timer_sync(&bp->timer); in __bnxt_close_nic()
10706 if (bp->bnapi && irq_re_init) { in __bnxt_close_nic()
10707 bnxt_get_ring_stats(bp, &bp->net_stats_prev); in __bnxt_close_nic()
10708 bnxt_get_ring_err_stats(bp, &bp->ring_err_stats_prev); in __bnxt_close_nic()
10719 if (test_bit(BNXT_STATE_IN_FW_RESET, &bp->state)) { in bnxt_close_nic()
10727 netdev_warn(bp->dev, "FW reset in progress during close, FW reset will be aborted\n"); in bnxt_close_nic()
10728 set_bit(BNXT_STATE_ABORT_ERR, &bp->state); in bnxt_close_nic()
10732 if (bp->sriov_cfg) { in bnxt_close_nic()
10735 rc = wait_event_interruptible_timeout(bp->sriov_cfg_wait, in bnxt_close_nic()
10736 !bp->sriov_cfg, in bnxt_close_nic()
10739 …netdev_warn(bp->dev, "timeout waiting for SRIOV config operation to complete, proceeding to close!… in bnxt_close_nic()
10741 netdev_warn(bp->dev, "SRIOV config operation interrupted, proceeding to close!\n"); in bnxt_close_nic()
10765 if (bp->hwrm_spec_code < 0x10a00) in bnxt_hwrm_port_phy_read()
10766 return -EOPNOTSUPP; in bnxt_hwrm_port_phy_read()
10772 req->port_id = cpu_to_le16(bp->pf.port_id); in bnxt_hwrm_port_phy_read()
10773 req->phy_addr = phy_addr; in bnxt_hwrm_port_phy_read()
10774 req->reg_addr = cpu_to_le16(reg & 0x1f); in bnxt_hwrm_port_phy_read()
10776 req->cl45_mdio = 1; in bnxt_hwrm_port_phy_read()
10777 req->phy_addr = mdio_phy_id_prtad(phy_addr); in bnxt_hwrm_port_phy_read()
10778 req->dev_addr = mdio_phy_id_devad(phy_addr); in bnxt_hwrm_port_phy_read()
10779 req->reg_addr = cpu_to_le16(reg); in bnxt_hwrm_port_phy_read()
10785 *val = le16_to_cpu(resp->reg_data); in bnxt_hwrm_port_phy_read()
10796 if (bp->hwrm_spec_code < 0x10a00) in bnxt_hwrm_port_phy_write()
10797 return -EOPNOTSUPP; in bnxt_hwrm_port_phy_write()
10803 req->port_id = cpu_to_le16(bp->pf.port_id); in bnxt_hwrm_port_phy_write()
10804 req->phy_addr = phy_addr; in bnxt_hwrm_port_phy_write()
10805 req->reg_addr = cpu_to_le16(reg & 0x1f); in bnxt_hwrm_port_phy_write()
10807 req->cl45_mdio = 1; in bnxt_hwrm_port_phy_write()
10808 req->phy_addr = mdio_phy_id_prtad(phy_addr); in bnxt_hwrm_port_phy_write()
10809 req->dev_addr = mdio_phy_id_devad(phy_addr); in bnxt_hwrm_port_phy_write()
10810 req->reg_addr = cpu_to_le16(reg); in bnxt_hwrm_port_phy_write()
10812 req->reg_data = cpu_to_le16(val); in bnxt_hwrm_port_phy_write()
10826 mdio->phy_id = bp->link_info.phy_addr; in bnxt_ioctl()
10833 return -EAGAIN; in bnxt_ioctl()
10835 rc = bnxt_hwrm_port_phy_read(bp, mdio->phy_id, mdio->reg_num, in bnxt_ioctl()
10837 mdio->val_out = mii_regval; in bnxt_ioctl()
10843 return -EAGAIN; in bnxt_ioctl()
10845 return bnxt_hwrm_port_phy_write(bp, mdio->phy_id, mdio->reg_num, in bnxt_ioctl()
10846 mdio->val_in); in bnxt_ioctl()
10858 return -EOPNOTSUPP; in bnxt_ioctl()
10866 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_get_ring_stats()
10867 struct bnxt_napi *bnapi = bp->bnapi[i]; in bnxt_get_ring_stats()
10868 struct bnxt_cp_ring_info *cpr = &bnapi->cp_ring; in bnxt_get_ring_stats()
10869 u64 *sw = cpr->stats.sw_stats; in bnxt_get_ring_stats()
10871 stats->rx_packets += BNXT_GET_RING_STATS64(sw, rx_ucast_pkts); in bnxt_get_ring_stats()
10872 stats->rx_packets += BNXT_GET_RING_STATS64(sw, rx_mcast_pkts); in bnxt_get_ring_stats()
10873 stats->rx_packets += BNXT_GET_RING_STATS64(sw, rx_bcast_pkts); in bnxt_get_ring_stats()
10875 stats->tx_packets += BNXT_GET_RING_STATS64(sw, tx_ucast_pkts); in bnxt_get_ring_stats()
10876 stats->tx_packets += BNXT_GET_RING_STATS64(sw, tx_mcast_pkts); in bnxt_get_ring_stats()
10877 stats->tx_packets += BNXT_GET_RING_STATS64(sw, tx_bcast_pkts); in bnxt_get_ring_stats()
10879 stats->rx_bytes += BNXT_GET_RING_STATS64(sw, rx_ucast_bytes); in bnxt_get_ring_stats()
10880 stats->rx_bytes += BNXT_GET_RING_STATS64(sw, rx_mcast_bytes); in bnxt_get_ring_stats()
10881 stats->rx_bytes += BNXT_GET_RING_STATS64(sw, rx_bcast_bytes); in bnxt_get_ring_stats()
10883 stats->tx_bytes += BNXT_GET_RING_STATS64(sw, tx_ucast_bytes); in bnxt_get_ring_stats()
10884 stats->tx_bytes += BNXT_GET_RING_STATS64(sw, tx_mcast_bytes); in bnxt_get_ring_stats()
10885 stats->tx_bytes += BNXT_GET_RING_STATS64(sw, tx_bcast_bytes); in bnxt_get_ring_stats()
10887 stats->rx_missed_errors += in bnxt_get_ring_stats()
10890 stats->multicast += BNXT_GET_RING_STATS64(sw, rx_mcast_pkts); in bnxt_get_ring_stats()
10892 stats->tx_dropped += BNXT_GET_RING_STATS64(sw, tx_error_pkts); in bnxt_get_ring_stats()
10894 stats->rx_dropped += in bnxt_get_ring_stats()
10895 cpr->sw_stats.rx.rx_netpoll_discards + in bnxt_get_ring_stats()
10896 cpr->sw_stats.rx.rx_oom_discards; in bnxt_get_ring_stats()
10903 struct rtnl_link_stats64 *prev_stats = &bp->net_stats_prev; in bnxt_add_prev_stats()
10905 stats->rx_packets += prev_stats->rx_packets; in bnxt_add_prev_stats()
10906 stats->tx_packets += prev_stats->tx_packets; in bnxt_add_prev_stats()
10907 stats->rx_bytes += prev_stats->rx_bytes; in bnxt_add_prev_stats()
10908 stats->tx_bytes += prev_stats->tx_bytes; in bnxt_add_prev_stats()
10909 stats->rx_missed_errors += prev_stats->rx_missed_errors; in bnxt_add_prev_stats()
10910 stats->multicast += prev_stats->multicast; in bnxt_add_prev_stats()
10911 stats->rx_dropped += prev_stats->rx_dropped; in bnxt_add_prev_stats()
10912 stats->tx_dropped += prev_stats->tx_dropped; in bnxt_add_prev_stats()
10920 set_bit(BNXT_STATE_READ_STATS, &bp->state); in bnxt_get_stats64()
10925 if (!test_bit(BNXT_STATE_OPEN, &bp->state)) { in bnxt_get_stats64()
10926 clear_bit(BNXT_STATE_READ_STATS, &bp->state); in bnxt_get_stats64()
10927 *stats = bp->net_stats_prev; in bnxt_get_stats64()
10934 if (bp->flags & BNXT_FLAG_PORT_STATS) { in bnxt_get_stats64()
10935 u64 *rx = bp->port_stats.sw_stats; in bnxt_get_stats64()
10936 u64 *tx = bp->port_stats.sw_stats + in bnxt_get_stats64()
10939 stats->rx_crc_errors = in bnxt_get_stats64()
10941 stats->rx_frame_errors = in bnxt_get_stats64()
10943 stats->rx_length_errors = in bnxt_get_stats64()
10947 stats->rx_errors = in bnxt_get_stats64()
10950 stats->collisions = in bnxt_get_stats64()
10952 stats->tx_fifo_errors = in bnxt_get_stats64()
10954 stats->tx_errors = BNXT_GET_TX_PORT_STATS64(tx, tx_err); in bnxt_get_stats64()
10956 clear_bit(BNXT_STATE_READ_STATS, &bp->state); in bnxt_get_stats64()
10963 struct bnxt_sw_stats *sw_stats = &cpr->sw_stats; in bnxt_get_one_ring_err_stats()
10964 u64 *hw_stats = cpr->stats.sw_stats; in bnxt_get_one_ring_err_stats()
10966 stats->rx_total_l4_csum_errors += sw_stats->rx.rx_l4_csum_errors; in bnxt_get_one_ring_err_stats()
10967 stats->rx_total_resets += sw_stats->rx.rx_resets; in bnxt_get_one_ring_err_stats()
10968 stats->rx_total_buf_errors += sw_stats->rx.rx_buf_errors; in bnxt_get_one_ring_err_stats()
10969 stats->rx_total_oom_discards += sw_stats->rx.rx_oom_discards; in bnxt_get_one_ring_err_stats()
10970 stats->rx_total_netpoll_discards += sw_stats->rx.rx_netpoll_discards; in bnxt_get_one_ring_err_stats()
10971 stats->rx_total_ring_discards += in bnxt_get_one_ring_err_stats()
10973 stats->tx_total_resets += sw_stats->tx.tx_resets; in bnxt_get_one_ring_err_stats()
10974 stats->tx_total_ring_discards += in bnxt_get_one_ring_err_stats()
10976 stats->total_missed_irqs += sw_stats->cmn.missed_irqs; in bnxt_get_one_ring_err_stats()
10984 for (i = 0; i < bp->cp_nr_rings; i++) in bnxt_get_ring_err_stats()
10985 bnxt_get_one_ring_err_stats(bp, stats, &bp->bnapi[i]->cp_ring); in bnxt_get_ring_err_stats()
10990 struct net_device *dev = bp->dev; in bnxt_mc_list_updated()
10991 struct bnxt_vnic_info *vnic = &bp->vnic_info[0]; in bnxt_mc_list_updated()
11001 vnic->mc_list_count = 0; in bnxt_mc_list_updated()
11004 haddr = ha->addr; in bnxt_mc_list_updated()
11005 if (!ether_addr_equal(haddr, vnic->mc_list + off)) { in bnxt_mc_list_updated()
11006 memcpy(vnic->mc_list + off, haddr, ETH_ALEN); in bnxt_mc_list_updated()
11015 if (mc_count != vnic->mc_list_count) { in bnxt_mc_list_updated()
11016 vnic->mc_list_count = mc_count; in bnxt_mc_list_updated()
11024 struct net_device *dev = bp->dev; in bnxt_uc_list_updated()
11025 struct bnxt_vnic_info *vnic = &bp->vnic_info[0]; in bnxt_uc_list_updated()
11029 if (netdev_uc_count(dev) != (vnic->uc_filter_count - 1)) in bnxt_uc_list_updated()
11033 if (!ether_addr_equal(ha->addr, vnic->uc_list + off)) in bnxt_uc_list_updated()
11049 if (!test_bit(BNXT_STATE_OPEN, &bp->state)) in bnxt_set_rx_mode()
11052 vnic = &bp->vnic_info[0]; in bnxt_set_rx_mode()
11053 mask = vnic->rx_mask; in bnxt_set_rx_mode()
11059 if (dev->flags & IFF_PROMISC) in bnxt_set_rx_mode()
11064 if (dev->flags & IFF_BROADCAST) in bnxt_set_rx_mode()
11066 if (dev->flags & IFF_ALLMULTI) { in bnxt_set_rx_mode()
11068 vnic->mc_list_count = 0; in bnxt_set_rx_mode()
11069 } else if (dev->flags & IFF_MULTICAST) { in bnxt_set_rx_mode()
11073 if (mask != vnic->rx_mask || uc_update || mc_update) { in bnxt_set_rx_mode()
11074 vnic->rx_mask = mask; in bnxt_set_rx_mode()
11082 struct net_device *dev = bp->dev; in bnxt_cfg_rx_mode()
11083 struct bnxt_vnic_info *vnic = &bp->vnic_info[0]; in bnxt_cfg_rx_mode()
11100 for (i = 1; i < vnic->uc_filter_count; i++) { in bnxt_cfg_rx_mode()
11101 req->l2_filter_id = vnic->fw_l2_filter_id[i]; in bnxt_cfg_rx_mode()
11107 vnic->uc_filter_count = 1; in bnxt_cfg_rx_mode()
11110 if (netdev_uc_count(dev) > (BNXT_MAX_UC_ADDRS - 1)) { in bnxt_cfg_rx_mode()
11111 vnic->rx_mask |= CFA_L2_SET_RX_MASK_REQ_MASK_PROMISCUOUS; in bnxt_cfg_rx_mode()
11114 memcpy(vnic->uc_list + off, ha->addr, ETH_ALEN); in bnxt_cfg_rx_mode()
11116 vnic->uc_filter_count++; in bnxt_cfg_rx_mode()
11121 for (i = 1, off = 0; i < vnic->uc_filter_count; i++, off += ETH_ALEN) { in bnxt_cfg_rx_mode()
11122 rc = bnxt_hwrm_set_vnic_filter(bp, 0, i, vnic->uc_list + off); in bnxt_cfg_rx_mode()
11124 if (BNXT_VF(bp) && rc == -ENODEV) { in bnxt_cfg_rx_mode()
11125 if (!test_and_set_bit(BNXT_STATE_L2_FILTER_RETRY, &bp->state)) in bnxt_cfg_rx_mode()
11126 netdev_warn(bp->dev, "Cannot configure L2 filters while PF is unavailable, will retry\n"); in bnxt_cfg_rx_mode()
11128 netdev_dbg(bp->dev, "PF still unavailable while configuring L2 filters.\n"); in bnxt_cfg_rx_mode()
11131 netdev_err(bp->dev, "HWRM vnic filter failure rc: %x\n", rc); in bnxt_cfg_rx_mode()
11133 vnic->uc_filter_count = i; in bnxt_cfg_rx_mode()
11137 if (test_and_clear_bit(BNXT_STATE_L2_FILTER_RETRY, &bp->state)) in bnxt_cfg_rx_mode()
11138 netdev_notice(bp->dev, "Retry of L2 filter configuration successful.\n"); in bnxt_cfg_rx_mode()
11141 if ((vnic->rx_mask & CFA_L2_SET_RX_MASK_REQ_MASK_PROMISCUOUS) && in bnxt_cfg_rx_mode()
11143 vnic->rx_mask &= ~CFA_L2_SET_RX_MASK_REQ_MASK_PROMISCUOUS; in bnxt_cfg_rx_mode()
11145 if (rc && (vnic->rx_mask & CFA_L2_SET_RX_MASK_REQ_MASK_MCAST)) { in bnxt_cfg_rx_mode()
11146 netdev_info(bp->dev, "Failed setting MC filters rc: %d, turning on ALL_MCAST mode\n", in bnxt_cfg_rx_mode()
11148 vnic->rx_mask &= ~CFA_L2_SET_RX_MASK_REQ_MASK_MCAST; in bnxt_cfg_rx_mode()
11149 vnic->rx_mask |= CFA_L2_SET_RX_MASK_REQ_MASK_ALL_MCAST; in bnxt_cfg_rx_mode()
11150 vnic->mc_list_count = 0; in bnxt_cfg_rx_mode()
11154 netdev_err(bp->dev, "HWRM cfa l2 rx mask failure rc: %d\n", in bnxt_cfg_rx_mode()
11164 struct bnxt_hw_resc *hw_resc = &bp->hw_resc; in bnxt_can_reserve_rings()
11169 if (hw_resc->min_tx_rings || hw_resc->resv_tx_rings) in bnxt_can_reserve_rings()
11172 if (!netif_running(bp->dev)) in bnxt_can_reserve_rings()
11182 if (bp->flags & BNXT_FLAG_CHIP_P5) { in bnxt_rfs_supported()
11183 if (bp->fw_cap & BNXT_FW_CAP_CFA_RFS_RING_TBL_IDX_V2) in bnxt_rfs_supported()
11192 if (bp->flags & BNXT_FLAG_NEW_RSS_CAP) in bnxt_rfs_supported()
11203 if (bp->flags & BNXT_FLAG_CHIP_P5) in bnxt_rfs_capable()
11205 if (!(bp->flags & BNXT_FLAG_MSIX_CAP) || !bnxt_can_reserve_rings(bp) || !bp->rx_nr_rings) in bnxt_rfs_capable()
11208 vnics = 1 + bp->rx_nr_rings; in bnxt_rfs_capable()
11213 if (bp->flags & BNXT_FLAG_NEW_RSS_CAP) in bnxt_rfs_capable()
11216 if (bp->rx_nr_rings > 1) in bnxt_rfs_capable()
11217 netdev_warn(bp->dev, in bnxt_rfs_capable()
11218 "Not enough resources to support NTUPLE filters, enough resources for up to %d rx rings\n", in bnxt_rfs_capable()
11219 min(max_rss_ctxs - 1, max_vnics - 1)); in bnxt_rfs_capable()
11226 if (vnics == bp->hw_resc.resv_vnics) in bnxt_rfs_capable()
11230 if (vnics <= bp->hw_resc.resv_vnics) in bnxt_rfs_capable()
11233 netdev_warn(bp->dev, "Unable to reserve resources to support NTUPLE filters.\n"); in bnxt_rfs_capable()
11250 if ((bp->flags & BNXT_FLAG_NO_AGG_RINGS) || bp->xdp_prog) in bnxt_fix_features()
11264 if (dev->features & BNXT_HW_FEATURE_VLAN_ALL_RX) in bnxt_fix_features()
11270 if (BNXT_VF(bp) && bp->vf.vlan) in bnxt_fix_features()
11279 u32 flags = bp->flags; in bnxt_set_features()
11291 if (bp->flags & BNXT_FLAG_NO_AGG_RINGS) in bnxt_set_features()
11300 changes = flags ^ bp->flags; in bnxt_set_features()
11303 if ((bp->flags & BNXT_FLAG_TPA) == 0 || in bnxt_set_features()
11305 (bp->flags & BNXT_FLAG_CHIP_P5)) in bnxt_set_features()
11312 if (flags != bp->flags) { in bnxt_set_features()
11313 u32 old_flags = bp->flags; in bnxt_set_features()
11315 if (!test_bit(BNXT_STATE_OPEN, &bp->state)) { in bnxt_set_features()
11316 bp->flags = flags; in bnxt_set_features()
11324 bp->flags = flags; in bnxt_set_features()
11331 bp->flags = flags; in bnxt_set_features()
11336 bp->flags = old_flags; in bnxt_set_features()
11345 struct ipv6hdr *ip6h = (struct ipv6hdr *)(skb->data + nw_off); in bnxt_exthdr_check()
11355 nexthdr = &ip6h->nexthdr; in bnxt_exthdr_check()
11363 hp = __skb_header_pointer(NULL, start, sizeof(*hp), skb->data, in bnxt_exthdr_check()
11375 /* The ext header may be a hop-by-hop header inserted for in bnxt_exthdr_check()
11380 if (likely(skb->len <= GRO_LEGACY_MAX_SIZE)) in bnxt_exthdr_check()
11384 if (jhdr->tlv_type != IPV6_TLV_JUMBO || jhdr->hdrlen != 0 || in bnxt_exthdr_check()
11385 jhdr->nexthdr != IPPROTO_TCP) in bnxt_exthdr_check()
11393 nexthdr = &hp->nexthdr; in bnxt_exthdr_check()
11398 if (skb->encapsulation) { in bnxt_exthdr_check()
11404 /* Only support TCP/UDP for non-tunneled ipv6 and inner ipv6 */ in bnxt_exthdr_check()
11412 __be16 udp_port = uh->dest; in bnxt_udp_tunl_check()
11414 if (udp_port != bp->vxlan_port && udp_port != bp->nge_port) in bnxt_udp_tunl_check()
11416 if (skb->inner_protocol_type == ENCAP_TYPE_ETHER) { in bnxt_udp_tunl_check()
11419 switch (eh->h_proto) { in bnxt_udp_tunl_check()
11439 switch (skb->inner_protocol) { in bnxt_tunl_check()
11466 if (!skb->encapsulation) in bnxt_features_check()
11468 l4_proto = &ip_hdr(skb)->protocol; in bnxt_features_check()
11499 rc = -ENOMEM; in bnxt_dbg_hwrm_rd_reg()
11503 req->host_dest_addr = cpu_to_le64(mapping); in bnxt_dbg_hwrm_rd_reg()
11506 req->read_addr = cpu_to_le32(reg_off + CHIMP_REG_VIEW_ADDR); in bnxt_dbg_hwrm_rd_reg()
11507 req->read_len32 = cpu_to_le32(num_words); in bnxt_dbg_hwrm_rd_reg()
11510 if (rc || resp->error_code) { in bnxt_dbg_hwrm_rd_reg()
11511 rc = -EIO; in bnxt_dbg_hwrm_rd_reg()
11533 req->ring_type = ring_type; in bnxt_dbg_hwrm_ring_info_get()
11534 req->fw_ring_id = cpu_to_le32(ring_id); in bnxt_dbg_hwrm_ring_info_get()
11538 *prod = le32_to_cpu(resp->producer_index); in bnxt_dbg_hwrm_ring_info_get()
11539 *cons = le32_to_cpu(resp->consumer_index); in bnxt_dbg_hwrm_ring_info_get()
11547 struct bnxt_tx_ring_info *txr = bnapi->tx_ring; in bnxt_dump_tx_sw_state()
11548 int i = bnapi->index; in bnxt_dump_tx_sw_state()
11553 netdev_info(bnapi->bp->dev, "[%d]: tx{fw_ring: %d prod: %x cons: %x}\n", in bnxt_dump_tx_sw_state()
11554 i, txr->tx_ring_struct.fw_ring_id, txr->tx_prod, in bnxt_dump_tx_sw_state()
11555 txr->tx_cons); in bnxt_dump_tx_sw_state()
11560 struct bnxt_rx_ring_info *rxr = bnapi->rx_ring; in bnxt_dump_rx_sw_state()
11561 int i = bnapi->index; in bnxt_dump_rx_sw_state()
11566 …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()
11567 i, rxr->rx_ring_struct.fw_ring_id, rxr->rx_prod, in bnxt_dump_rx_sw_state()
11568 rxr->rx_agg_ring_struct.fw_ring_id, rxr->rx_agg_prod, in bnxt_dump_rx_sw_state()
11569 rxr->rx_sw_agg_prod); in bnxt_dump_rx_sw_state()
11574 struct bnxt_cp_ring_info *cpr = &bnapi->cp_ring; in bnxt_dump_cp_sw_state()
11575 int i = bnapi->index; in bnxt_dump_cp_sw_state()
11577 netdev_info(bnapi->bp->dev, "[%d]: cp{fw_ring: %d raw_cons: %x}\n", in bnxt_dump_cp_sw_state()
11578 i, cpr->cp_ring_struct.fw_ring_id, cpr->cp_raw_cons); in bnxt_dump_cp_sw_state()
11586 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_dbg_dump_states()
11587 bnapi = bp->bnapi[i]; in bnxt_dbg_dump_states()
11598 struct bnxt_rx_ring_info *rxr = &bp->rx_ring[ring_nr]; in bnxt_hwrm_rx_ring_reset()
11600 struct bnxt_napi *bnapi = rxr->bnapi; in bnxt_hwrm_rx_ring_reset()
11609 cpr = &bnapi->cp_ring; in bnxt_hwrm_rx_ring_reset()
11610 cp_ring_id = cpr->cp_ring_struct.fw_ring_id; in bnxt_hwrm_rx_ring_reset()
11611 req->cmpl_ring = cpu_to_le16(cp_ring_id); in bnxt_hwrm_rx_ring_reset()
11612 req->ring_type = RING_RESET_REQ_RING_TYPE_RX_RING_GRP; in bnxt_hwrm_rx_ring_reset()
11613 req->ring_id = cpu_to_le16(bp->grp_info[bnapi->index].fw_grp_id); in bnxt_hwrm_rx_ring_reset()
11621 if (netif_running(bp->dev)) { in bnxt_reset_task()
11640 netdev_err(bp->dev, "TX timeout detected, starting reset task!\n"); in bnxt_tx_timeout()
11646 struct bnxt_fw_health *fw_health = bp->fw_health; in bnxt_fw_health_check()
11647 struct pci_dev *pdev = bp->pdev; in bnxt_fw_health_check()
11650 if (!fw_health->enabled || test_bit(BNXT_STATE_IN_FW_RESET, &bp->state)) in bnxt_fw_health_check()
11655 if (fw_health->tmr_counter) { in bnxt_fw_health_check()
11656 fw_health->tmr_counter--; in bnxt_fw_health_check()
11661 if (val == fw_health->last_fw_heartbeat && pci_device_is_present(pdev)) { in bnxt_fw_health_check()
11662 fw_health->arrests++; in bnxt_fw_health_check()
11666 fw_health->last_fw_heartbeat = val; in bnxt_fw_health_check()
11669 if (val != fw_health->last_fw_reset_cnt && pci_device_is_present(pdev)) { in bnxt_fw_health_check()
11670 fw_health->discoveries++; in bnxt_fw_health_check()
11674 fw_health->tmr_counter = fw_health->tmr_multiplier; in bnxt_fw_health_check()
11684 struct net_device *dev = bp->dev; in bnxt_timer()
11686 if (!netif_running(dev) || !test_bit(BNXT_STATE_OPEN, &bp->state)) in bnxt_timer()
11689 if (atomic_read(&bp->intr_sem) != 0) in bnxt_timer()
11692 if (bp->fw_cap & BNXT_FW_CAP_ERROR_RECOVERY) in bnxt_timer()
11695 if (BNXT_LINK_IS_UP(bp) && bp->stats_coal_ticks) in bnxt_timer()
11702 if ((bp->flags & BNXT_FLAG_RFS) && bp->ntp_fltr_count) in bnxt_timer()
11706 if (bp->link_info.phy_retry) { in bnxt_timer()
11707 if (time_after(jiffies, bp->link_info.phy_retry_expires)) { in bnxt_timer()
11708 bp->link_info.phy_retry = false; in bnxt_timer()
11709 netdev_warn(bp->dev, "failed to update phy settings after maximum retries.\n"); in bnxt_timer()
11715 if (test_bit(BNXT_STATE_L2_FILTER_RETRY, &bp->state)) in bnxt_timer()
11718 if ((bp->flags & BNXT_FLAG_CHIP_P5) && !bp->chip_rev && in bnxt_timer()
11723 mod_timer(&bp->timer, jiffies + bp->current_interval); in bnxt_timer()
11733 clear_bit(BNXT_STATE_IN_SP_TASK, &bp->state); in bnxt_rtnl_lock_sp()
11739 set_bit(BNXT_STATE_IN_SP_TASK, &bp->state); in bnxt_rtnl_unlock_sp()
11747 if (test_bit(BNXT_STATE_OPEN, &bp->state)) in bnxt_reset()
11758 if (!test_bit(BNXT_STATE_OPEN, &bp->state)) { in bnxt_rx_ring_reset()
11763 if (bp->flags & BNXT_FLAG_TPA) in bnxt_rx_ring_reset()
11765 for (i = 0; i < bp->rx_nr_rings; i++) { in bnxt_rx_ring_reset()
11766 struct bnxt_rx_ring_info *rxr = &bp->rx_ring[i]; in bnxt_rx_ring_reset()
11770 if (!rxr->bnapi->in_reset) in bnxt_rx_ring_reset()
11775 if (rc == -EINVAL || rc == -EOPNOTSUPP) in bnxt_rx_ring_reset()
11776 …netdev_info_once(bp->dev, "RX ring reset not supported by firmware, falling back to global reset\n… in bnxt_rx_ring_reset()
11778 netdev_warn(bp->dev, "RX ring reset failed, rc = %d, falling back to global reset\n", in bnxt_rx_ring_reset()
11784 rxr->rx_prod = 0; in bnxt_rx_ring_reset()
11785 rxr->rx_agg_prod = 0; in bnxt_rx_ring_reset()
11786 rxr->rx_sw_agg_prod = 0; in bnxt_rx_ring_reset()
11787 rxr->rx_next_cons = 0; in bnxt_rx_ring_reset()
11788 rxr->bnapi->in_reset = false; in bnxt_rx_ring_reset()
11790 cpr = &rxr->bnapi->cp_ring; in bnxt_rx_ring_reset()
11791 cpr->sw_stats.rx.rx_resets++; in bnxt_rx_ring_reset()
11792 if (bp->flags & BNXT_FLAG_AGG_RINGS) in bnxt_rx_ring_reset()
11793 bnxt_db_write(bp, &rxr->rx_agg_db, rxr->rx_agg_prod); in bnxt_rx_ring_reset()
11794 bnxt_db_write(bp, &rxr->rx_db, rxr->rx_prod); in bnxt_rx_ring_reset()
11796 if (bp->flags & BNXT_FLAG_TPA) in bnxt_rx_ring_reset()
11808 pci_disable_device(bp->pdev); in bnxt_fw_fatal_close()
11818 if (test_bit(BNXT_STATE_FW_FATAL_COND, &bp->state)) { in bnxt_fw_reset_close()
11821 pci_read_config_word(bp->pdev, PCI_SUBSYSTEM_ID, &val); in bnxt_fw_reset_close()
11823 bp->fw_reset_min_dsecs = 0; in bnxt_fw_reset_close()
11830 if (pci_is_enabled(bp->pdev)) in bnxt_fw_reset_close()
11831 pci_disable_device(bp->pdev); in bnxt_fw_reset_close()
11833 kfree(bp->ctx); in bnxt_fw_reset_close()
11834 bp->ctx = NULL; in bnxt_fw_reset_close()
11839 struct bnxt_fw_health *fw_health = bp->fw_health; in is_bnxt_fw_ok()
11844 if (val == fw_health->last_fw_heartbeat) in is_bnxt_fw_ok()
11848 if (val != fw_health->last_fw_reset_cnt) in is_bnxt_fw_ok()
11860 struct bnxt_fw_health *fw_health = bp->fw_health; in bnxt_force_fw_reset()
11861 struct bnxt_ptp_cfg *ptp = bp->ptp_cfg; in bnxt_force_fw_reset()
11864 if (!test_bit(BNXT_STATE_OPEN, &bp->state) || in bnxt_force_fw_reset()
11865 test_bit(BNXT_STATE_IN_FW_RESET, &bp->state)) in bnxt_force_fw_reset()
11869 spin_lock_bh(&ptp->ptp_lock); in bnxt_force_fw_reset()
11870 set_bit(BNXT_STATE_IN_FW_RESET, &bp->state); in bnxt_force_fw_reset()
11871 spin_unlock_bh(&ptp->ptp_lock); in bnxt_force_fw_reset()
11873 set_bit(BNXT_STATE_IN_FW_RESET, &bp->state); in bnxt_force_fw_reset()
11876 wait_dsecs = fw_health->master_func_wait_dsecs; in bnxt_force_fw_reset()
11877 if (fw_health->primary) { in bnxt_force_fw_reset()
11878 if (fw_health->flags & ERROR_RECOVERY_QCFG_RESP_FLAGS_CO_CPU) in bnxt_force_fw_reset()
11880 bp->fw_reset_state = BNXT_FW_RESET_STATE_RESET_FW; in bnxt_force_fw_reset()
11882 bp->fw_reset_timestamp = jiffies + wait_dsecs * HZ / 10; in bnxt_force_fw_reset()
11883 wait_dsecs = fw_health->normal_func_wait_dsecs; in bnxt_force_fw_reset()
11884 bp->fw_reset_state = BNXT_FW_RESET_STATE_ENABLE_DEV; in bnxt_force_fw_reset()
11887 bp->fw_reset_min_dsecs = fw_health->post_reset_wait_dsecs; in bnxt_force_fw_reset()
11888 bp->fw_reset_max_dsecs = fw_health->post_reset_max_wait_dsecs; in bnxt_force_fw_reset()
11894 netdev_warn(bp->dev, "Detected firmware fatal condition, initiating reset\n"); in bnxt_fw_exception()
11895 set_bit(BNXT_STATE_FW_FATAL_COND, &bp->state); in bnxt_fw_exception()
11914 netdev_err(bp->dev, "func_qcfg cmd failed, rc = %d\n", rc); in bnxt_get_registered_vfs()
11917 if (bp->pf.registered_vfs) in bnxt_get_registered_vfs()
11918 return bp->pf.registered_vfs; in bnxt_get_registered_vfs()
11919 if (bp->sriov_cfg) in bnxt_get_registered_vfs()
11928 if (test_bit(BNXT_STATE_OPEN, &bp->state) && in bnxt_fw_reset()
11929 !test_bit(BNXT_STATE_IN_FW_RESET, &bp->state)) { in bnxt_fw_reset()
11930 struct bnxt_ptp_cfg *ptp = bp->ptp_cfg; in bnxt_fw_reset()
11934 spin_lock_bh(&ptp->ptp_lock); in bnxt_fw_reset()
11935 set_bit(BNXT_STATE_IN_FW_RESET, &bp->state); in bnxt_fw_reset()
11936 spin_unlock_bh(&ptp->ptp_lock); in bnxt_fw_reset()
11938 set_bit(BNXT_STATE_IN_FW_RESET, &bp->state); in bnxt_fw_reset()
11940 if (bp->pf.active_vfs && in bnxt_fw_reset()
11941 !test_bit(BNXT_STATE_FW_FATAL_COND, &bp->state)) in bnxt_fw_reset()
11944 netdev_err(bp->dev, "Firmware reset aborted, rc = %d\n", in bnxt_fw_reset()
11946 clear_bit(BNXT_STATE_IN_FW_RESET, &bp->state); in bnxt_fw_reset()
11947 dev_close(bp->dev); in bnxt_fw_reset()
11952 if (bp->fw_reset_max_dsecs < vf_tmo_dsecs) in bnxt_fw_reset()
11953 bp->fw_reset_max_dsecs = vf_tmo_dsecs; in bnxt_fw_reset()
11954 bp->fw_reset_state = in bnxt_fw_reset()
11960 if (bp->fw_cap & BNXT_FW_CAP_ERR_RECOVER_RELOAD) { in bnxt_fw_reset()
11961 bp->fw_reset_state = BNXT_FW_RESET_STATE_POLL_FW_DOWN; in bnxt_fw_reset()
11964 bp->fw_reset_state = BNXT_FW_RESET_STATE_ENABLE_DEV; in bnxt_fw_reset()
11965 tmo = bp->fw_reset_min_dsecs * HZ / 10; in bnxt_fw_reset()
11977 if (!(bp->flags & BNXT_FLAG_CHIP_P5)) in bnxt_chk_missed_irq()
11980 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_chk_missed_irq()
11981 struct bnxt_napi *bnapi = bp->bnapi[i]; in bnxt_chk_missed_irq()
11989 cpr = &bnapi->cp_ring; in bnxt_chk_missed_irq()
11991 struct bnxt_cp_ring_info *cpr2 = cpr->cp_ring_arr[j]; in bnxt_chk_missed_irq()
11994 if (!cpr2 || cpr2->has_more_work || in bnxt_chk_missed_irq()
11998 if (cpr2->cp_raw_cons != cpr2->last_cp_raw_cons) { in bnxt_chk_missed_irq()
11999 cpr2->last_cp_raw_cons = cpr2->cp_raw_cons; in bnxt_chk_missed_irq()
12002 fw_ring_id = cpr2->cp_ring_struct.fw_ring_id; in bnxt_chk_missed_irq()
12006 cpr->sw_stats.cmn.missed_irqs++; in bnxt_chk_missed_irq()
12015 struct bnxt_link_info *link_info = &bp->link_info; in bnxt_init_ethtool_link_settings()
12017 if (BNXT_AUTO_MODE(link_info->auto_mode)) { in bnxt_init_ethtool_link_settings()
12018 link_info->autoneg = BNXT_AUTONEG_SPEED; in bnxt_init_ethtool_link_settings()
12019 if (bp->hwrm_spec_code >= 0x10201) { in bnxt_init_ethtool_link_settings()
12020 if (link_info->auto_pause_setting & in bnxt_init_ethtool_link_settings()
12022 link_info->autoneg |= BNXT_AUTONEG_FLOW_CTRL; in bnxt_init_ethtool_link_settings()
12024 link_info->autoneg |= BNXT_AUTONEG_FLOW_CTRL; in bnxt_init_ethtool_link_settings()
12026 link_info->advertising = link_info->auto_link_speeds; in bnxt_init_ethtool_link_settings()
12027 link_info->advertising_pam4 = link_info->auto_pam4_link_speeds; in bnxt_init_ethtool_link_settings()
12029 link_info->req_link_speed = link_info->force_link_speed; in bnxt_init_ethtool_link_settings()
12030 link_info->req_signal_mode = BNXT_SIG_MODE_NRZ; in bnxt_init_ethtool_link_settings()
12031 if (link_info->force_pam4_link_speed) { in bnxt_init_ethtool_link_settings()
12032 link_info->req_link_speed = in bnxt_init_ethtool_link_settings()
12033 link_info->force_pam4_link_speed; in bnxt_init_ethtool_link_settings()
12034 link_info->req_signal_mode = BNXT_SIG_MODE_PAM4; in bnxt_init_ethtool_link_settings()
12036 link_info->req_duplex = link_info->duplex_setting; in bnxt_init_ethtool_link_settings()
12038 if (link_info->autoneg & BNXT_AUTONEG_FLOW_CTRL) in bnxt_init_ethtool_link_settings()
12039 link_info->req_flow_ctrl = in bnxt_init_ethtool_link_settings()
12040 link_info->auto_pause_setting & BNXT_LINK_PAUSE_BOTH; in bnxt_init_ethtool_link_settings()
12042 link_info->req_flow_ctrl = link_info->force_pause_setting; in bnxt_init_ethtool_link_settings()
12047 struct bnxt_fw_health *fw_health = bp->fw_health; in bnxt_fw_echo_reply()
12054 req->event_data1 = cpu_to_le32(fw_health->echo_req_data1); in bnxt_fw_echo_reply()
12055 req->event_data2 = cpu_to_le32(fw_health->echo_req_data2); in bnxt_fw_echo_reply()
12063 set_bit(BNXT_STATE_IN_SP_TASK, &bp->state); in bnxt_sp_task()
12065 if (!test_bit(BNXT_STATE_OPEN, &bp->state)) { in bnxt_sp_task()
12066 clear_bit(BNXT_STATE_IN_SP_TASK, &bp->state); in bnxt_sp_task()
12070 if (test_and_clear_bit(BNXT_RX_MASK_SP_EVENT, &bp->sp_event)) in bnxt_sp_task()
12073 if (test_and_clear_bit(BNXT_RX_NTP_FLTR_SP_EVENT, &bp->sp_event)) in bnxt_sp_task()
12075 if (test_and_clear_bit(BNXT_HWRM_EXEC_FWD_REQ_SP_EVENT, &bp->sp_event)) in bnxt_sp_task()
12077 if (test_and_clear_bit(BNXT_HWRM_PF_UNLOAD_SP_EVENT, &bp->sp_event)) in bnxt_sp_task()
12078 netdev_info(bp->dev, "Receive PF driver unload event!\n"); in bnxt_sp_task()
12079 if (test_and_clear_bit(BNXT_PERIODIC_STATS_SP_EVENT, &bp->sp_event)) { in bnxt_sp_task()
12085 if (test_and_clear_bit(BNXT_LINK_CHNG_SP_EVENT, &bp->sp_event)) { in bnxt_sp_task()
12088 mutex_lock(&bp->link_lock); in bnxt_sp_task()
12090 &bp->sp_event)) in bnxt_sp_task()
12095 netdev_err(bp->dev, "SP task can't update link (rc: %x)\n", in bnxt_sp_task()
12099 &bp->sp_event)) in bnxt_sp_task()
12101 mutex_unlock(&bp->link_lock); in bnxt_sp_task()
12103 if (test_and_clear_bit(BNXT_UPDATE_PHY_SP_EVENT, &bp->sp_event)) { in bnxt_sp_task()
12106 mutex_lock(&bp->link_lock); in bnxt_sp_task()
12108 mutex_unlock(&bp->link_lock); in bnxt_sp_task()
12110 netdev_warn(bp->dev, "update phy settings retry failed\n"); in bnxt_sp_task()
12112 bp->link_info.phy_retry = false; in bnxt_sp_task()
12113 netdev_info(bp->dev, "update phy settings retry succeeded\n"); in bnxt_sp_task()
12116 if (test_and_clear_bit(BNXT_HWRM_PORT_MODULE_SP_EVENT, &bp->sp_event)) { in bnxt_sp_task()
12117 mutex_lock(&bp->link_lock); in bnxt_sp_task()
12119 mutex_unlock(&bp->link_lock); in bnxt_sp_task()
12122 if (test_and_clear_bit(BNXT_FLOW_STATS_SP_EVENT, &bp->sp_event)) in bnxt_sp_task()
12125 if (test_and_clear_bit(BNXT_RING_COAL_NOW_SP_EVENT, &bp->sp_event)) in bnxt_sp_task()
12128 if (test_and_clear_bit(BNXT_FW_ECHO_REQUEST_SP_EVENT, &bp->sp_event)) in bnxt_sp_task()
12134 if (test_and_clear_bit(BNXT_RESET_TASK_SP_EVENT, &bp->sp_event)) in bnxt_sp_task()
12137 if (test_and_clear_bit(BNXT_RESET_TASK_SILENT_SP_EVENT, &bp->sp_event)) in bnxt_sp_task()
12140 if (test_and_clear_bit(BNXT_RST_RING_SP_EVENT, &bp->sp_event)) in bnxt_sp_task()
12143 if (test_and_clear_bit(BNXT_FW_RESET_NOTIFY_SP_EVENT, &bp->sp_event)) { in bnxt_sp_task()
12144 if (test_bit(BNXT_STATE_FW_FATAL_COND, &bp->state) || in bnxt_sp_task()
12145 test_bit(BNXT_STATE_FW_NON_FATAL_COND, &bp->state)) in bnxt_sp_task()
12151 if (test_and_clear_bit(BNXT_FW_EXCEPTION_SP_EVENT, &bp->sp_event)) { in bnxt_sp_task()
12157 clear_bit(BNXT_STATE_IN_SP_TASK, &bp->state); in bnxt_sp_task()
12177 return -ENOMEM; in bnxt_check_rings()
12181 return -ENOMEM; in bnxt_check_rings()
12184 if ((bp->flags & (BNXT_FLAG_RFS | BNXT_FLAG_CHIP_P5)) == BNXT_FLAG_RFS) in bnxt_check_rings()
12187 if (bp->flags & BNXT_FLAG_AGG_RINGS) in bnxt_check_rings()
12201 if (bp->bar2) { in bnxt_unmap_bars()
12202 pci_iounmap(pdev, bp->bar2); in bnxt_unmap_bars()
12203 bp->bar2 = NULL; in bnxt_unmap_bars()
12206 if (bp->bar1) { in bnxt_unmap_bars()
12207 pci_iounmap(pdev, bp->bar1); in bnxt_unmap_bars()
12208 bp->bar1 = NULL; in bnxt_unmap_bars()
12211 if (bp->bar0) { in bnxt_unmap_bars()
12212 pci_iounmap(pdev, bp->bar0); in bnxt_unmap_bars()
12213 bp->bar0 = NULL; in bnxt_unmap_bars()
12219 bnxt_unmap_bars(bp, bp->pdev); in bnxt_cleanup_pci()
12220 pci_release_regions(bp->pdev); in bnxt_cleanup_pci()
12221 if (pci_is_enabled(bp->pdev)) in bnxt_cleanup_pci()
12222 pci_disable_device(bp->pdev); in bnxt_cleanup_pci()
12227 struct bnxt_coal_cap *coal_cap = &bp->coal_cap; in bnxt_init_dflt_coal()
12231 if (coal_cap->cmpl_params & in bnxt_init_dflt_coal()
12238 coal = &bp->rx_coal; in bnxt_init_dflt_coal()
12239 coal->coal_ticks = 10; in bnxt_init_dflt_coal()
12240 coal->coal_bufs = 30; in bnxt_init_dflt_coal()
12241 coal->coal_ticks_irq = 1; in bnxt_init_dflt_coal()
12242 coal->coal_bufs_irq = 2; in bnxt_init_dflt_coal()
12243 coal->idle_thresh = 50; in bnxt_init_dflt_coal()
12244 coal->bufs_per_record = 2; in bnxt_init_dflt_coal()
12245 coal->budget = 64; /* NAPI budget */ in bnxt_init_dflt_coal()
12246 coal->flags = flags; in bnxt_init_dflt_coal()
12248 coal = &bp->tx_coal; in bnxt_init_dflt_coal()
12249 coal->coal_ticks = 28; in bnxt_init_dflt_coal()
12250 coal->coal_bufs = 30; in bnxt_init_dflt_coal()
12251 coal->coal_ticks_irq = 2; in bnxt_init_dflt_coal()
12252 coal->coal_bufs_irq = 2; in bnxt_init_dflt_coal()
12253 coal->bufs_per_record = 1; in bnxt_init_dflt_coal()
12254 coal->flags = flags; in bnxt_init_dflt_coal()
12256 bp->stats_coal_ticks = BNXT_DEF_STATS_COAL_TICKS; in bnxt_init_dflt_coal()
12263 bp->fw_cap = 0; in bnxt_fw_init_one_p1()
12284 return -ENODEV; in bnxt_fw_init_one_p1()
12297 netdev_err(bp->dev, "hwrm query capability failure rc: %x\n", in bnxt_fw_init_one_p2()
12299 return -ENODEV; in bnxt_fw_init_one_p2()
12304 netdev_warn(bp->dev, "hwrm query adv flow mgnt failure rc: %d\n", in bnxt_fw_init_one_p2()
12308 netdev_warn(bp->dev, "no memory for firmware error recovery\n"); in bnxt_fw_init_one_p2()
12312 netdev_warn(bp->dev, "hwrm query error recovery failure rc: %d\n", in bnxt_fw_init_one_p2()
12318 return -ENODEV; in bnxt_fw_init_one_p2()
12324 if (bp->fw_cap & BNXT_FW_CAP_PTP) in bnxt_fw_init_one_p2()
12332 bp->flags &= ~BNXT_FLAG_UDP_RSS_CAP; in bnxt_set_dflt_rss_hash_type()
12333 bp->rss_hash_cfg = VNIC_RSS_CFG_REQ_HASH_TYPE_IPV4 | in bnxt_set_dflt_rss_hash_type()
12337 if (bp->fw_cap & BNXT_FW_CAP_RSS_HASH_TYPE_DELTA) in bnxt_set_dflt_rss_hash_type()
12338 bp->rss_hash_delta = bp->rss_hash_cfg; in bnxt_set_dflt_rss_hash_type()
12339 if (BNXT_CHIP_P4_PLUS(bp) && bp->hwrm_spec_code >= 0x10501) { in bnxt_set_dflt_rss_hash_type()
12340 bp->flags |= BNXT_FLAG_UDP_RSS_CAP; in bnxt_set_dflt_rss_hash_type()
12341 bp->rss_hash_cfg |= VNIC_RSS_CFG_REQ_HASH_TYPE_UDP_IPV4 | in bnxt_set_dflt_rss_hash_type()
12348 struct net_device *dev = bp->dev; in bnxt_set_dflt_rfs()
12350 dev->hw_features &= ~NETIF_F_NTUPLE; in bnxt_set_dflt_rfs()
12351 dev->features &= ~NETIF_F_NTUPLE; in bnxt_set_dflt_rfs()
12352 bp->flags &= ~BNXT_FLAG_RFS; in bnxt_set_dflt_rfs()
12354 dev->hw_features |= NETIF_F_NTUPLE; in bnxt_set_dflt_rfs()
12356 bp->flags |= BNXT_FLAG_RFS; in bnxt_set_dflt_rfs()
12357 dev->features |= NETIF_F_NTUPLE; in bnxt_set_dflt_rfs()
12364 struct pci_dev *pdev = bp->pdev; in bnxt_fw_init_one_p3()
12370 if (bp->flags & BNXT_FLAG_WOL_CAP) in bnxt_fw_init_one_p3()
12371 device_set_wakeup_enable(&pdev->dev, bp->wol); in bnxt_fw_init_one_p3()
12373 device_set_wakeup_capable(&pdev->dev, false); in bnxt_fw_init_one_p3()
12387 netdev_err(bp->dev, "Firmware init phase 1 failed\n"); in bnxt_fw_init_one()
12392 netdev_err(bp->dev, "Firmware init phase 2 failed\n"); in bnxt_fw_init_one()
12398 rc = bnxt_approve_mac(bp, bp->dev->dev_addr, false); in bnxt_fw_init_one()
12408 struct bnxt_fw_health *fw_health = bp->fw_health; in bnxt_fw_reset_writel()
12409 u32 reg = fw_health->fw_reset_seq_regs[reg_idx]; in bnxt_fw_reset_writel()
12410 u32 val = fw_health->fw_reset_seq_vals[reg_idx]; in bnxt_fw_reset_writel()
12413 delay_msecs = fw_health->fw_reset_seq_delay_msec[reg_idx]; in bnxt_fw_reset_writel()
12418 pci_write_config_dword(bp->pdev, reg_off, val); in bnxt_fw_reset_writel()
12422 bp->bar0 + BNXT_GRCPF_REG_WINDOW_BASE_OUT + 4); in bnxt_fw_reset_writel()
12426 writel(val, bp->bar0 + reg_off); in bnxt_fw_reset_writel()
12429 writel(val, bp->bar1 + reg_off); in bnxt_fw_reset_writel()
12433 pci_read_config_dword(bp->pdev, 0, &val); in bnxt_fw_reset_writel()
12444 if (~bp->fw_cap & BNXT_FW_CAP_HOT_RESET_IF) in bnxt_hwrm_reset_permitted()
12450 req->fid = cpu_to_le16(0xffff); in bnxt_hwrm_reset_permitted()
12453 result = !!(le16_to_cpu(resp->flags) & in bnxt_hwrm_reset_permitted()
12461 struct bnxt_fw_health *fw_health = bp->fw_health; in bnxt_reset_all()
12464 if (bp->fw_cap & BNXT_FW_CAP_ERR_RECOVER_RELOAD) { in bnxt_reset_all()
12466 bp->fw_reset_timestamp = jiffies; in bnxt_reset_all()
12470 if (fw_health->flags & ERROR_RECOVERY_QCFG_RESP_FLAGS_HOST) { in bnxt_reset_all()
12471 for (i = 0; i < fw_health->fw_reset_seq_cnt; i++) in bnxt_reset_all()
12473 } else if (fw_health->flags & ERROR_RECOVERY_QCFG_RESP_FLAGS_CO_CPU) { in bnxt_reset_all()
12478 req->target_id = cpu_to_le16(HWRM_TARGET_ID_KONG); in bnxt_reset_all()
12479 req->embedded_proc_type = FW_RESET_REQ_EMBEDDED_PROC_TYPE_CHIP; in bnxt_reset_all()
12480 req->selfrst_status = FW_RESET_REQ_SELFRST_STATUS_SELFRSTASAP; in bnxt_reset_all()
12481 req->flags = FW_RESET_REQ_FLAGS_RESET_GRACEFUL; in bnxt_reset_all()
12484 if (rc != -ENODEV) in bnxt_reset_all()
12485 netdev_warn(bp->dev, "Unable to reset FW rc=%d\n", rc); in bnxt_reset_all()
12487 bp->fw_reset_timestamp = jiffies; in bnxt_reset_all()
12492 return time_after(jiffies, bp->fw_reset_timestamp + in bnxt_fw_reset_timeout()
12493 (bp->fw_reset_max_dsecs * HZ / 10)); in bnxt_fw_reset_timeout()
12498 clear_bit(BNXT_STATE_IN_FW_RESET, &bp->state); in bnxt_fw_reset_abort()
12499 if (bp->fw_reset_state != BNXT_FW_RESET_STATE_POLL_VF) { in bnxt_fw_reset_abort()
12503 bp->fw_reset_state = 0; in bnxt_fw_reset_abort()
12504 dev_close(bp->dev); in bnxt_fw_reset_abort()
12512 if (!test_bit(BNXT_STATE_IN_FW_RESET, &bp->state)) { in bnxt_fw_reset_task()
12513 netdev_err(bp->dev, "bnxt_fw_reset_task() called when not in fw reset mode!\n"); in bnxt_fw_reset_task()
12517 switch (bp->fw_reset_state) { in bnxt_fw_reset_task()
12523 …netdev_err(bp->dev, "Firmware reset aborted, subsequent func_qcfg cmd failed, rc = %d, %d msecs si… in bnxt_fw_reset_task()
12524 n, jiffies_to_msecs(jiffies - in bnxt_fw_reset_task()
12525 bp->fw_reset_timestamp)); in bnxt_fw_reset_task()
12529 clear_bit(BNXT_STATE_IN_FW_RESET, &bp->state); in bnxt_fw_reset_task()
12530 bp->fw_reset_state = 0; in bnxt_fw_reset_task()
12531 netdev_err(bp->dev, "Firmware reset aborted, bnxt_get_registered_vfs() returns %d\n", in bnxt_fw_reset_task()
12538 bp->fw_reset_timestamp = jiffies; in bnxt_fw_reset_task()
12540 if (test_bit(BNXT_STATE_ABORT_ERR, &bp->state)) { in bnxt_fw_reset_task()
12546 if (bp->fw_cap & BNXT_FW_CAP_ERR_RECOVER_RELOAD) { in bnxt_fw_reset_task()
12547 bp->fw_reset_state = BNXT_FW_RESET_STATE_POLL_FW_DOWN; in bnxt_fw_reset_task()
12550 bp->fw_reset_state = BNXT_FW_RESET_STATE_ENABLE_DEV; in bnxt_fw_reset_task()
12551 tmo = bp->fw_reset_min_dsecs * HZ / 10; in bnxt_fw_reset_task()
12567 if (!bp->fw_health->primary) { in bnxt_fw_reset_task()
12568 u32 wait_dsecs = bp->fw_health->normal_func_wait_dsecs; in bnxt_fw_reset_task()
12570 bp->fw_reset_state = BNXT_FW_RESET_STATE_ENABLE_DEV; in bnxt_fw_reset_task()
12574 bp->fw_reset_state = BNXT_FW_RESET_STATE_RESET_FW; in bnxt_fw_reset_task()
12579 bp->fw_reset_state = BNXT_FW_RESET_STATE_ENABLE_DEV; in bnxt_fw_reset_task()
12580 bnxt_queue_fw_reset_work(bp, bp->fw_reset_min_dsecs * HZ / 10); in bnxt_fw_reset_task()
12584 if (test_bit(BNXT_STATE_FW_FATAL_COND, &bp->state) && in bnxt_fw_reset_task()
12585 !bp->fw_reset_min_dsecs) { in bnxt_fw_reset_task()
12588 pci_read_config_word(bp->pdev, PCI_SUBSYSTEM_ID, &val); in bnxt_fw_reset_task()
12591 netdev_err(bp->dev, "Firmware reset aborted, PCI config space invalid\n"); in bnxt_fw_reset_task()
12592 rc = -ETIMEDOUT; in bnxt_fw_reset_task()
12599 clear_bit(BNXT_STATE_FW_FATAL_COND, &bp->state); in bnxt_fw_reset_task()
12600 clear_bit(BNXT_STATE_FW_NON_FATAL_COND, &bp->state); in bnxt_fw_reset_task()
12601 if (test_and_clear_bit(BNXT_STATE_FW_ACTIVATE_RESET, &bp->state) && in bnxt_fw_reset_task()
12602 !test_bit(BNXT_STATE_FW_ACTIVATE, &bp->state)) in bnxt_fw_reset_task()
12604 if (pci_enable_device(bp->pdev)) { in bnxt_fw_reset_task()
12605 netdev_err(bp->dev, "Cannot re-enable PCI device\n"); in bnxt_fw_reset_task()
12606 rc = -ENODEV; in bnxt_fw_reset_task()
12609 pci_set_master(bp->pdev); in bnxt_fw_reset_task()
12610 bp->fw_reset_state = BNXT_FW_RESET_STATE_POLL_FW; in bnxt_fw_reset_task()
12613 bp->hwrm_cmd_timeout = SHORT_HWRM_CMD_TIMEOUT; in bnxt_fw_reset_task()
12617 netdev_err(bp->dev, "Firmware reset aborted\n"); in bnxt_fw_reset_task()
12623 bp->hwrm_cmd_timeout = DFLT_HWRM_CMD_TIMEOUT; in bnxt_fw_reset_task()
12624 bp->fw_reset_state = BNXT_FW_RESET_STATE_OPENING; in bnxt_fw_reset_task()
12631 rc = bnxt_open(bp->dev); in bnxt_fw_reset_task()
12633 netdev_err(bp->dev, "bnxt_open() failed during FW reset\n"); in bnxt_fw_reset_task()
12639 if ((bp->fw_cap & BNXT_FW_CAP_ERROR_RECOVERY) && in bnxt_fw_reset_task()
12640 bp->fw_health->enabled) { in bnxt_fw_reset_task()
12641 bp->fw_health->last_fw_reset_cnt = in bnxt_fw_reset_task()
12644 bp->fw_reset_state = 0; in bnxt_fw_reset_task()
12647 clear_bit(BNXT_STATE_IN_FW_RESET, &bp->state); in bnxt_fw_reset_task()
12653 clear_bit(BNXT_STATE_FW_ACTIVATE, &bp->state); in bnxt_fw_reset_task()
12654 if (test_and_clear_bit(BNXT_STATE_RECOVER, &bp->state)) { in bnxt_fw_reset_task()
12664 if (bp->fw_health->status_reliable || in bnxt_fw_reset_task()
12665 (bp->fw_cap & BNXT_FW_CAP_ERROR_RECOVERY)) { in bnxt_fw_reset_task()
12668 netdev_err(bp->dev, "fw_health_status 0x%x\n", sts); in bnxt_fw_reset_task()
12681 SET_NETDEV_DEV(dev, &pdev->dev); in bnxt_init_board()
12683 /* enable device (incl. PCI PM wakeup), and bus-mastering */ in bnxt_init_board()
12686 dev_err(&pdev->dev, "Cannot enable PCI device, aborting\n"); in bnxt_init_board()
12691 dev_err(&pdev->dev, in bnxt_init_board()
12693 rc = -ENODEV; in bnxt_init_board()
12699 dev_err(&pdev->dev, "Cannot obtain PCI resources, aborting\n"); in bnxt_init_board()
12703 if (dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)) != 0 && in bnxt_init_board()
12704 dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32)) != 0) { in bnxt_init_board()
12705 dev_err(&pdev->dev, "System does not support DMA, aborting\n"); in bnxt_init_board()
12706 rc = -EIO; in bnxt_init_board()
12712 bp->dev = dev; in bnxt_init_board()
12713 bp->pdev = pdev; in bnxt_init_board()
12715 /* Doorbell BAR bp->bar1 is mapped after bnxt_fw_init_one_p2() in bnxt_init_board()
12718 bp->bar0 = pci_ioremap_bar(pdev, 0); in bnxt_init_board()
12719 if (!bp->bar0) { in bnxt_init_board()
12720 dev_err(&pdev->dev, "Cannot map device registers, aborting\n"); in bnxt_init_board()
12721 rc = -ENOMEM; in bnxt_init_board()
12725 bp->bar2 = pci_ioremap_bar(pdev, 4); in bnxt_init_board()
12726 if (!bp->bar2) { in bnxt_init_board()
12727 dev_err(&pdev->dev, "Cannot map bar4 registers, aborting\n"); in bnxt_init_board()
12728 rc = -ENOMEM; in bnxt_init_board()
12732 INIT_WORK(&bp->sp_task, bnxt_sp_task); in bnxt_init_board()
12733 INIT_DELAYED_WORK(&bp->fw_reset_task, bnxt_fw_reset_task); in bnxt_init_board()
12735 spin_lock_init(&bp->ntp_fltr_lock); in bnxt_init_board()
12737 spin_lock_init(&bp->db_lock); in bnxt_init_board()
12740 bp->rx_ring_size = BNXT_DEFAULT_RX_RING_SIZE; in bnxt_init_board()
12741 bp->tx_ring_size = BNXT_DEFAULT_TX_RING_SIZE; in bnxt_init_board()
12743 timer_setup(&bp->timer, bnxt_timer, 0); in bnxt_init_board()
12744 bp->current_interval = BNXT_TIMER_INTERVAL; in bnxt_init_board()
12746 bp->vxlan_fw_dst_port_id = INVALID_HW_RING_ID; in bnxt_init_board()
12747 bp->nge_fw_dst_port_id = INVALID_HW_RING_ID; in bnxt_init_board()
12749 clear_bit(BNXT_STATE_OPEN, &bp->state); in bnxt_init_board()
12770 if (!is_valid_ether_addr(addr->sa_data)) in bnxt_change_mac_addr()
12771 return -EADDRNOTAVAIL; in bnxt_change_mac_addr()
12773 if (ether_addr_equal(addr->sa_data, dev->dev_addr)) in bnxt_change_mac_addr()
12776 rc = bnxt_approve_mac(bp, addr->sa_data, true); in bnxt_change_mac_addr()
12780 eth_hw_addr_set(dev, addr->sa_data); in bnxt_change_mac_addr()
12797 dev->mtu = new_mtu; in bnxt_change_mtu()
12812 if (tc > bp->max_tc) { in bnxt_setup_mq_tc()
12814 tc, bp->max_tc); in bnxt_setup_mq_tc()
12815 return -EINVAL; in bnxt_setup_mq_tc()
12821 if (bp->flags & BNXT_FLAG_SHARED_RINGS) in bnxt_setup_mq_tc()
12824 rc = bnxt_check_rings(bp, bp->tx_nr_rings_per_tc, bp->rx_nr_rings, in bnxt_setup_mq_tc()
12825 sh, tc, bp->tx_nr_rings_xdp); in bnxt_setup_mq_tc()
12829 /* Needs to close the device and do hw resource re-allocations */ in bnxt_setup_mq_tc()
12830 if (netif_running(bp->dev)) in bnxt_setup_mq_tc()
12834 bp->tx_nr_rings = bp->tx_nr_rings_per_tc * tc; in bnxt_setup_mq_tc()
12837 bp->tx_nr_rings = bp->tx_nr_rings_per_tc; in bnxt_setup_mq_tc()
12840 bp->tx_nr_rings += bp->tx_nr_rings_xdp; in bnxt_setup_mq_tc()
12841 bp->cp_nr_rings = sh ? max_t(int, bp->tx_nr_rings, bp->rx_nr_rings) : in bnxt_setup_mq_tc()
12842 bp->tx_nr_rings + bp->rx_nr_rings; in bnxt_setup_mq_tc()
12844 if (netif_running(bp->dev)) in bnxt_setup_mq_tc()
12856 !tc_cls_can_offload_and_chain0(bp->dev, type_data)) in bnxt_setup_tc_block_cb()
12857 return -EOPNOTSUPP; in bnxt_setup_tc_block_cb()
12861 return bnxt_tc_setup_flower(bp, bp->pf.fw_fid, type_data); in bnxt_setup_tc_block_cb()
12863 return -EOPNOTSUPP; in bnxt_setup_tc_block_cb()
12883 mqprio->hw = TC_MQPRIO_HW_OFFLOAD_TCS; in bnxt_setup_tc()
12885 return bnxt_setup_mq_tc(dev, mqprio->num_tc); in bnxt_setup_tc()
12888 return -EOPNOTSUPP; in bnxt_setup_tc()
12896 struct flow_keys *keys1 = &f1->fkeys; in bnxt_fltr_match()
12897 struct flow_keys *keys2 = &f2->fkeys; in bnxt_fltr_match()
12899 if (keys1->basic.n_proto != keys2->basic.n_proto || in bnxt_fltr_match()
12900 keys1->basic.ip_proto != keys2->basic.ip_proto) in bnxt_fltr_match()
12903 if (keys1->basic.n_proto == htons(ETH_P_IP)) { in bnxt_fltr_match()
12904 if (keys1->addrs.v4addrs.src != keys2->addrs.v4addrs.src || in bnxt_fltr_match()
12905 keys1->addrs.v4addrs.dst != keys2->addrs.v4addrs.dst) in bnxt_fltr_match()
12908 if (memcmp(&keys1->addrs.v6addrs.src, &keys2->addrs.v6addrs.src, in bnxt_fltr_match()
12909 sizeof(keys1->addrs.v6addrs.src)) || in bnxt_fltr_match()
12910 memcmp(&keys1->addrs.v6addrs.dst, &keys2->addrs.v6addrs.dst, in bnxt_fltr_match()
12911 sizeof(keys1->addrs.v6addrs.dst))) in bnxt_fltr_match()
12915 if (keys1->ports.ports == keys2->ports.ports && in bnxt_fltr_match()
12916 keys1->control.flags == keys2->control.flags && in bnxt_fltr_match()
12917 ether_addr_equal(f1->src_mac_addr, f2->src_mac_addr) && in bnxt_fltr_match()
12918 ether_addr_equal(f1->dst_mac_addr, f2->dst_mac_addr)) in bnxt_fltr_match()
12935 if (!ether_addr_equal(dev->dev_addr, eth->h_dest)) { in bnxt_rx_flow_steer()
12936 struct bnxt_vnic_info *vnic = &bp->vnic_info[0]; in bnxt_rx_flow_steer()
12940 for (j = 0; j < vnic->uc_filter_count; j++, off += ETH_ALEN) { in bnxt_rx_flow_steer()
12941 if (ether_addr_equal(eth->h_dest, in bnxt_rx_flow_steer()
12942 vnic->uc_list + off)) { in bnxt_rx_flow_steer()
12949 return -EINVAL; in bnxt_rx_flow_steer()
12953 return -ENOMEM; in bnxt_rx_flow_steer()
12955 fkeys = &new_fltr->fkeys; in bnxt_rx_flow_steer()
12957 rc = -EPROTONOSUPPORT; in bnxt_rx_flow_steer()
12961 if ((fkeys->basic.n_proto != htons(ETH_P_IP) && in bnxt_rx_flow_steer()
12962 fkeys->basic.n_proto != htons(ETH_P_IPV6)) || in bnxt_rx_flow_steer()
12963 ((fkeys->basic.ip_proto != IPPROTO_TCP) && in bnxt_rx_flow_steer()
12964 (fkeys->basic.ip_proto != IPPROTO_UDP))) { in bnxt_rx_flow_steer()
12965 rc = -EPROTONOSUPPORT; in bnxt_rx_flow_steer()
12968 if (fkeys->basic.n_proto == htons(ETH_P_IPV6) && in bnxt_rx_flow_steer()
12969 bp->hwrm_spec_code < 0x10601) { in bnxt_rx_flow_steer()
12970 rc = -EPROTONOSUPPORT; in bnxt_rx_flow_steer()
12973 flags = fkeys->control.flags; in bnxt_rx_flow_steer()
12975 bp->hwrm_spec_code < 0x10601) || (flags & FLOW_DIS_IS_FRAGMENT)) { in bnxt_rx_flow_steer()
12976 rc = -EPROTONOSUPPORT; in bnxt_rx_flow_steer()
12980 memcpy(new_fltr->dst_mac_addr, eth->h_dest, ETH_ALEN); in bnxt_rx_flow_steer()
12981 memcpy(new_fltr->src_mac_addr, eth->h_source, ETH_ALEN); in bnxt_rx_flow_steer()
12984 head = &bp->ntp_fltr_hash_tbl[idx]; in bnxt_rx_flow_steer()
12988 rc = fltr->sw_id; in bnxt_rx_flow_steer()
12995 spin_lock_bh(&bp->ntp_fltr_lock); in bnxt_rx_flow_steer()
12996 bit_id = bitmap_find_free_region(bp->ntp_fltr_bmap, in bnxt_rx_flow_steer()
12999 spin_unlock_bh(&bp->ntp_fltr_lock); in bnxt_rx_flow_steer()
13000 rc = -ENOMEM; in bnxt_rx_flow_steer()
13004 new_fltr->sw_id = (u16)bit_id; in bnxt_rx_flow_steer()
13005 new_fltr->flow_id = flow_id; in bnxt_rx_flow_steer()
13006 new_fltr->l2_fltr_idx = l2_idx; in bnxt_rx_flow_steer()
13007 new_fltr->rxq = rxq_index; in bnxt_rx_flow_steer()
13008 hlist_add_head_rcu(&new_fltr->hash, head); in bnxt_rx_flow_steer()
13009 bp->ntp_fltr_count++; in bnxt_rx_flow_steer()
13010 spin_unlock_bh(&bp->ntp_fltr_lock); in bnxt_rx_flow_steer()
13014 return new_fltr->sw_id; in bnxt_rx_flow_steer()
13031 head = &bp->ntp_fltr_hash_tbl[i]; in bnxt_cfg_ntp_filters()
13035 if (test_bit(BNXT_FLTR_VALID, &fltr->state)) { in bnxt_cfg_ntp_filters()
13036 if (rps_may_expire_flow(bp->dev, fltr->rxq, in bnxt_cfg_ntp_filters()
13037 fltr->flow_id, in bnxt_cfg_ntp_filters()
13038 fltr->sw_id)) { in bnxt_cfg_ntp_filters()
13049 set_bit(BNXT_FLTR_VALID, &fltr->state); in bnxt_cfg_ntp_filters()
13053 spin_lock_bh(&bp->ntp_fltr_lock); in bnxt_cfg_ntp_filters()
13054 hlist_del_rcu(&fltr->hash); in bnxt_cfg_ntp_filters()
13055 bp->ntp_fltr_count--; in bnxt_cfg_ntp_filters()
13056 spin_unlock_bh(&bp->ntp_fltr_lock); in bnxt_cfg_ntp_filters()
13058 clear_bit(fltr->sw_id, bp->ntp_fltr_bmap); in bnxt_cfg_ntp_filters()
13079 if (ti->type == UDP_TUNNEL_TYPE_VXLAN) in bnxt_udp_tunnel_set_port()
13084 return bnxt_hwrm_tunnel_dst_port_alloc(bp, ti->port, cmd); in bnxt_udp_tunnel_set_port()
13093 if (ti->type == UDP_TUNNEL_TYPE_VXLAN) in bnxt_udp_tunnel_unset_port()
13118 return ndo_dflt_bridge_getlink(skb, pid, seq, dev, bp->br_mode, 0, 0, in bnxt_bridge_getlink()
13129 if (bp->hwrm_spec_code < 0x10708 || !BNXT_SINGLE_PF(bp)) in bnxt_bridge_setlink()
13130 return -EOPNOTSUPP; in bnxt_bridge_setlink()
13134 return -EINVAL; in bnxt_bridge_setlink()
13143 if (mode == bp->br_mode) in bnxt_bridge_setlink()
13148 bp->br_mode = mode; in bnxt_bridge_setlink()
13159 if (bp->eswitch_mode != DEVLINK_ESWITCH_MODE_SWITCHDEV) in bnxt_get_port_parent_id()
13160 return -EOPNOTSUPP; in bnxt_get_port_parent_id()
13162 /* The PF and it's VF-reps only support the switchdev framework */ in bnxt_get_port_parent_id()
13163 if (!BNXT_PF(bp) || !(bp->flags & BNXT_FLAG_DSN_VALID)) in bnxt_get_port_parent_id()
13164 return -EOPNOTSUPP; in bnxt_get_port_parent_id()
13166 ppid->id_len = sizeof(bp->dsn); in bnxt_get_port_parent_id()
13167 memcpy(ppid->id, bp->dsn, ppid->id_len); in bnxt_get_port_parent_id()
13217 clear_bit(BNXT_STATE_IN_FW_RESET, &bp->state); in bnxt_remove_one()
13219 cancel_work_sync(&bp->sp_task); in bnxt_remove_one()
13220 cancel_delayed_work_sync(&bp->fw_reset_task); in bnxt_remove_one()
13221 bp->sp_event = 0; in bnxt_remove_one()
13232 kfree(bp->ptp_cfg); in bnxt_remove_one()
13233 bp->ptp_cfg = NULL; in bnxt_remove_one()
13234 kfree(bp->fw_health); in bnxt_remove_one()
13235 bp->fw_health = NULL; in bnxt_remove_one()
13238 kfree(bp->ctx); in bnxt_remove_one()
13239 bp->ctx = NULL; in bnxt_remove_one()
13240 kfree(bp->rss_indir_tbl); in bnxt_remove_one()
13241 bp->rss_indir_tbl = NULL; in bnxt_remove_one()
13249 struct bnxt_link_info *link_info = &bp->link_info; in bnxt_probe_phy()
13251 bp->phy_flags = 0; in bnxt_probe_phy()
13254 netdev_err(bp->dev, "Probe phy can't get phy capabilities (rc: %x)\n", in bnxt_probe_phy()
13258 if (bp->phy_flags & BNXT_PHY_FL_NO_FCS) in bnxt_probe_phy()
13259 bp->dev->priv_flags |= IFF_SUPP_NOFCS; in bnxt_probe_phy()
13261 bp->dev->priv_flags &= ~IFF_SUPP_NOFCS; in bnxt_probe_phy()
13265 mutex_lock(&bp->link_lock); in bnxt_probe_phy()
13268 mutex_unlock(&bp->link_lock); in bnxt_probe_phy()
13269 netdev_err(bp->dev, "Probe phy can't update link (rc: %x)\n", in bnxt_probe_phy()
13277 if (link_info->auto_link_speeds && !link_info->support_auto_speeds) in bnxt_probe_phy()
13278 link_info->support_auto_speeds = link_info->support_speeds; in bnxt_probe_phy()
13281 mutex_unlock(&bp->link_lock); in bnxt_probe_phy()
13289 if (!pdev->msix_cap) in bnxt_get_max_irq()
13292 pci_read_config_word(pdev, pdev->msix_cap + PCI_MSIX_FLAGS, &ctrl); in bnxt_get_max_irq()
13299 struct bnxt_hw_resc *hw_resc = &bp->hw_resc; in _bnxt_get_max_rings()
13302 *max_tx = hw_resc->max_tx_rings; in _bnxt_get_max_rings()
13303 *max_rx = hw_resc->max_rx_rings; in _bnxt_get_max_rings()
13305 max_irq = min_t(int, bnxt_get_max_func_irqs(bp) - in _bnxt_get_max_rings()
13307 hw_resc->max_stat_ctxs - bnxt_get_ulp_stat_ctxs(bp)); in _bnxt_get_max_rings()
13308 if (!(bp->flags & BNXT_FLAG_CHIP_P5)) in _bnxt_get_max_rings()
13310 max_ring_grps = hw_resc->max_hw_ring_grps; in _bnxt_get_max_rings()
13312 *max_cp -= 1; in _bnxt_get_max_rings()
13313 *max_rx -= 2; in _bnxt_get_max_rings()
13315 if (bp->flags & BNXT_FLAG_AGG_RINGS) in _bnxt_get_max_rings()
13317 if (bp->flags & BNXT_FLAG_CHIP_P5) { in _bnxt_get_max_rings()
13333 return -ENOMEM; in bnxt_get_max_rings()
13344 if (rc && (bp->flags & BNXT_FLAG_AGG_RINGS)) { in bnxt_get_dflt_rings()
13346 bp->flags &= ~BNXT_FLAG_AGG_RINGS; in bnxt_get_dflt_rings()
13350 bp->flags |= BNXT_FLAG_AGG_RINGS; in bnxt_get_dflt_rings()
13353 bp->flags |= BNXT_FLAG_NO_AGG_RINGS; in bnxt_get_dflt_rings()
13354 bp->dev->hw_features &= ~(NETIF_F_LRO | NETIF_F_GRO_HW); in bnxt_get_dflt_rings()
13355 bp->dev->features &= ~(NETIF_F_LRO | NETIF_F_GRO_HW); in bnxt_get_dflt_rings()
13359 if (bp->flags & BNXT_FLAG_ROCE_CAP) { in bnxt_get_dflt_rings()
13371 max_cp -= BNXT_MIN_ROCE_CP_RINGS; in bnxt_get_dflt_rings()
13372 max_irq -= BNXT_MIN_ROCE_CP_RINGS; in bnxt_get_dflt_rings()
13373 max_stat -= BNXT_MIN_ROCE_STAT_CTXS; in bnxt_get_dflt_rings()
13388 bp->cp_nr_rings = min_t(int, bp->tx_nr_rings_per_tc, bp->rx_nr_rings); in bnxt_trim_dflt_sh_rings()
13389 bp->rx_nr_rings = bp->cp_nr_rings; in bnxt_trim_dflt_sh_rings()
13390 bp->tx_nr_rings_per_tc = bp->cp_nr_rings; in bnxt_trim_dflt_sh_rings()
13391 bp->tx_nr_rings = bp->tx_nr_rings_per_tc; in bnxt_trim_dflt_sh_rings()
13402 bp->flags |= BNXT_FLAG_SHARED_RINGS; in bnxt_set_dflt_rings()
13404 /* Reduce default rings on multi-port cards so that total default in bnxt_set_dflt_rings()
13407 if (bp->port_count > 1) { in bnxt_set_dflt_rings()
13409 max_t(int, num_online_cpus() / bp->port_count, 1); in bnxt_set_dflt_rings()
13416 bp->rx_nr_rings = min_t(int, dflt_rings, max_rx_rings); in bnxt_set_dflt_rings()
13417 bp->tx_nr_rings_per_tc = min_t(int, dflt_rings, max_tx_rings); in bnxt_set_dflt_rings()
13421 bp->cp_nr_rings = bp->tx_nr_rings_per_tc + bp->rx_nr_rings; in bnxt_set_dflt_rings()
13422 bp->tx_nr_rings = bp->tx_nr_rings_per_tc; in bnxt_set_dflt_rings()
13425 if (rc && rc != -ENODEV) in bnxt_set_dflt_rings()
13426 netdev_warn(bp->dev, "Unable to reserve tx rings\n"); in bnxt_set_dflt_rings()
13427 bp->tx_nr_rings_per_tc = bp->tx_nr_rings; in bnxt_set_dflt_rings()
13431 /* Rings may have been trimmed, re-reserve the trimmed rings. */ in bnxt_set_dflt_rings()
13434 if (rc && rc != -ENODEV) in bnxt_set_dflt_rings()
13435 netdev_warn(bp->dev, "2nd rings reservation failed.\n"); in bnxt_set_dflt_rings()
13436 bp->tx_nr_rings_per_tc = bp->tx_nr_rings; in bnxt_set_dflt_rings()
13439 bp->rx_nr_rings++; in bnxt_set_dflt_rings()
13440 bp->cp_nr_rings++; in bnxt_set_dflt_rings()
13443 bp->tx_nr_rings = 0; in bnxt_set_dflt_rings()
13444 bp->rx_nr_rings = 0; in bnxt_set_dflt_rings()
13453 if (bp->tx_nr_rings) in bnxt_init_dflt_ring_mode()
13460 if (BNXT_VF(bp) && rc == -ENODEV) in bnxt_init_dflt_ring_mode()
13461 netdev_err(bp->dev, "Cannot configure VF rings while PF is unavailable.\n"); in bnxt_init_dflt_ring_mode()
13463 netdev_err(bp->dev, "Not enough rings available.\n"); in bnxt_init_dflt_ring_mode()
13470 bp->tx_nr_rings_per_tc = bp->tx_nr_rings; in bnxt_init_dflt_ring_mode()
13486 if (netif_running(bp->dev)) in bnxt_restore_pf_fw_resources()
13494 if (netif_running(bp->dev)) { in bnxt_restore_pf_fw_resources()
13496 dev_close(bp->dev); in bnxt_restore_pf_fw_resources()
13509 eth_hw_addr_set(bp->dev, bp->pf.mac_addr); in bnxt_init_mac_addr()
13512 struct bnxt_vf_info *vf = &bp->vf; in bnxt_init_mac_addr()
13515 if (is_valid_ether_addr(vf->mac_addr)) { in bnxt_init_mac_addr()
13517 eth_hw_addr_set(bp->dev, vf->mac_addr); in bnxt_init_mac_addr()
13523 eth_hw_addr_random(bp->dev); in bnxt_init_mac_addr()
13525 rc = bnxt_approve_mac(bp, bp->dev->dev_addr, strict_approval); in bnxt_init_mac_addr()
13533 struct pci_dev *pdev = bp->pdev; in bnxt_vpd_read_info()
13549 size = min_t(int, kw_len, BNXT_VPD_FLD_LEN - 1); in bnxt_vpd_read_info()
13550 memcpy(bp->board_partno, &vpd_data[pos], size); in bnxt_vpd_read_info()
13559 size = min_t(int, kw_len, BNXT_VPD_FLD_LEN - 1); in bnxt_vpd_read_info()
13560 memcpy(bp->board_serialno, &vpd_data[pos], size); in bnxt_vpd_read_info()
13567 struct pci_dev *pdev = bp->pdev; in bnxt_pcie_dsn_get()
13572 netdev_info(bp->dev, "Unable to read adapter's DSN\n"); in bnxt_pcie_dsn_get()
13573 return -EOPNOTSUPP; in bnxt_pcie_dsn_get()
13578 bp->flags |= BNXT_FLAG_DSN_VALID; in bnxt_pcie_dsn_get()
13584 if (!bp->db_size) in bnxt_map_db_bar()
13585 return -ENODEV; in bnxt_map_db_bar()
13586 bp->bar1 = pci_iomap(bp->pdev, 2, bp->db_size); in bnxt_map_db_bar()
13587 if (!bp->bar1) in bnxt_map_db_bar()
13588 return -ENOMEM; in bnxt_map_db_bar()
13594 netdev_info(bp->dev, "%s found at mem %lx, node addr %pM\n", in bnxt_print_device_info()
13595 board_info[bp->board_idx].name, in bnxt_print_device_info()
13596 (long)pci_resource_start(bp->pdev, 0), bp->dev->dev_addr); in bnxt_print_device_info()
13598 pcie_print_link_status(bp->pdev); in bnxt_print_device_info()
13608 return -ENODEV; in bnxt_init_one()
13621 return -ENOMEM; in bnxt_init_one()
13624 bp->board_idx = ent->driver_data; in bnxt_init_one()
13625 bp->msg_enable = BNXT_DEF_MSG_ENABLE; in bnxt_init_one()
13628 if (bnxt_vf_pciid(bp->board_idx)) in bnxt_init_one()
13629 bp->flags |= BNXT_FLAG_VF; in bnxt_init_one()
13633 SET_NETDEV_DEVLINK_PORT(dev, &bp->dl_port); in bnxt_init_one()
13635 if (pdev->msix_cap) in bnxt_init_one()
13636 bp->flags |= BNXT_FLAG_MSIX_CAP; in bnxt_init_one()
13642 dev->netdev_ops = &bnxt_netdev_ops; in bnxt_init_one()
13643 dev->watchdog_timeo = BNXT_TX_TIMEOUT; in bnxt_init_one()
13644 dev->ethtool_ops = &bnxt_ethtool_ops; in bnxt_init_one()
13651 mutex_init(&bp->hwrm_cmd_lock); in bnxt_init_one()
13652 mutex_init(&bp->link_lock); in bnxt_init_one()
13662 bp->flags |= BNXT_FLAG_CHIP_P5; in bnxt_init_one()
13664 bp->flags |= BNXT_FLAG_CHIP_SR2; in bnxt_init_one()
13677 dev_err(&pdev->dev, "Cannot map doorbell BAR rc = %d, aborting\n", in bnxt_init_one()
13682 dev->hw_features = NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM | NETIF_F_SG | in bnxt_init_one()
13691 dev->hw_features |= NETIF_F_LRO; in bnxt_init_one()
13693 dev->hw_enc_features = in bnxt_init_one()
13699 dev->udp_tunnel_nic_info = &bnxt_udp_tunnels; in bnxt_init_one()
13701 dev->gso_partial_features = NETIF_F_GSO_UDP_TUNNEL_CSUM | in bnxt_init_one()
13703 dev->vlan_features = dev->hw_features | NETIF_F_HIGHDMA; in bnxt_init_one()
13704 if (bp->fw_cap & BNXT_FW_CAP_VLAN_RX_STRIP) in bnxt_init_one()
13705 dev->hw_features |= BNXT_HW_FEATURE_VLAN_ALL_RX; in bnxt_init_one()
13706 if (bp->fw_cap & BNXT_FW_CAP_VLAN_TX_INSERT) in bnxt_init_one()
13707 dev->hw_features |= BNXT_HW_FEATURE_VLAN_ALL_TX; in bnxt_init_one()
13709 dev->hw_features |= NETIF_F_GRO_HW; in bnxt_init_one()
13710 dev->features |= dev->hw_features | NETIF_F_HIGHDMA; in bnxt_init_one()
13711 if (dev->features & NETIF_F_GRO_HW) in bnxt_init_one()
13712 dev->features &= ~NETIF_F_LRO; in bnxt_init_one()
13713 dev->priv_flags |= IFF_UNICAST_FLT; in bnxt_init_one()
13717 dev->xdp_features = NETDEV_XDP_ACT_BASIC | NETDEV_XDP_ACT_REDIRECT | in bnxt_init_one()
13721 init_waitqueue_head(&bp->sriov_cfg_wait); in bnxt_init_one()
13724 bp->gro_func = bnxt_gro_func_5730x; in bnxt_init_one()
13726 bp->gro_func = bnxt_gro_func_5731x; in bnxt_init_one()
13728 bp->gro_func = bnxt_gro_func_5750x; in bnxt_init_one()
13731 bp->flags |= BNXT_FLAG_DOUBLE_DB; in bnxt_init_one()
13735 dev_err(&pdev->dev, "Unable to initialize mac address.\n"); in bnxt_init_one()
13736 rc = -EADDRNOTAVAIL; in bnxt_init_one()
13742 rc = bnxt_pcie_dsn_get(bp, bp->dsn); in bnxt_init_one()
13745 /* MTU range: 60 - FW defined max */ in bnxt_init_one()
13746 dev->min_mtu = ETH_ZLEN; in bnxt_init_one()
13747 dev->max_mtu = bp->max_mtu; in bnxt_init_one()
13758 if (BNXT_VF(bp) && rc == -ENODEV) { in bnxt_init_one()
13759 netdev_err(bp->dev, "Cannot configure VF rings while PF is unavailable.\n"); in bnxt_init_one()
13761 netdev_err(bp->dev, "Not enough rings available.\n"); in bnxt_init_one()
13762 rc = -ENOMEM; in bnxt_init_one()
13771 if (dev->hw_features & BNXT_HW_FEATURE_VLAN_ALL_RX) in bnxt_init_one()
13772 bp->flags |= BNXT_FLAG_STRIP_VLAN; in bnxt_init_one()
13779 * limited MSIX, so we re-initialize the TX rings per TC. in bnxt_init_one()
13781 bp->tx_nr_rings_per_tc = bp->tx_nr_rings; in bnxt_init_one()
13788 dev_err(&pdev->dev, "Unable to create workqueue.\n"); in bnxt_init_one()
13789 rc = -ENOMEM; in bnxt_init_one()
13828 kfree(bp->ptp_cfg); in bnxt_init_one()
13829 bp->ptp_cfg = NULL; in bnxt_init_one()
13830 kfree(bp->fw_health); in bnxt_init_one()
13831 bp->fw_health = NULL; in bnxt_init_one()
13834 kfree(bp->ctx); in bnxt_init_one()
13835 bp->ctx = NULL; in bnxt_init_one()
13836 kfree(bp->rss_indir_tbl); in bnxt_init_one()
13837 bp->rss_indir_tbl = NULL; in bnxt_init_one()
13865 pci_wake_from_d3(pdev, bp->wol); in bnxt_shutdown()
13888 pci_disable_device(bp->pdev); in bnxt_suspend()
13890 kfree(bp->ctx); in bnxt_suspend()
13891 bp->ctx = NULL; in bnxt_suspend()
13903 rc = pci_enable_device(bp->pdev); in bnxt_resume()
13905 netdev_err(dev, "Cannot re-enable PCI device during resume, err = %d\n", in bnxt_resume()
13909 pci_set_master(bp->pdev); in bnxt_resume()
13911 rc = -ENODEV; in bnxt_resume()
13916 rc = -EBUSY; in bnxt_resume()
13927 rc = -ENODEV; in bnxt_resume()
13932 kfree(bp->ptp_cfg); in bnxt_resume()
13933 bp->ptp_cfg = NULL; in bnxt_resume()
13960 * bnxt_io_error_detected - called when PCI error is detected
13981 if (test_and_set_bit(BNXT_STATE_IN_FW_RESET, &bp->state)) { in bnxt_io_error_detected()
13982 netdev_err(bp->dev, "Firmware reset already in progress\n"); in bnxt_io_error_detected()
13996 set_bit(BNXT_STATE_PCI_CHANNEL_IO_FROZEN, &bp->state); in bnxt_io_error_detected()
14006 kfree(bp->ctx); in bnxt_io_error_detected()
14007 bp->ctx = NULL; in bnxt_io_error_detected()
14015 * bnxt_io_slot_reset - called after the pci bus has been reset.
14018 * Restart the card from scratch, as if from a cold-boot.
14021 * set up identically to what it was at cold boot.
14032 netdev_info(bp->dev, "PCI Slot Reset\n"); in bnxt_io_slot_reset()
14037 dev_err(&pdev->dev, in bnxt_io_slot_reset()
14038 "Cannot re-enable PCI device after reset.\n"); in bnxt_io_slot_reset()
14045 * As pci_restore_state() does not re-write the BARs if the in bnxt_io_slot_reset()
14050 &bp->state)) { in bnxt_io_slot_reset()
14053 pci_write_config_dword(bp->pdev, off, 0); in bnxt_io_slot_reset()
14061 /* In some PCIe AER scenarios, firmware may take up to in bnxt_io_slot_reset()
14072 dev_err(&pdev->dev, "Firmware not ready\n"); in bnxt_io_slot_reset()
14087 clear_bit(BNXT_STATE_IN_FW_RESET, &bp->state); in bnxt_io_slot_reset()
14095 * bnxt_io_resume - called when traffic can start flowing again.
14107 netdev_info(bp->dev, "PCI Slot Resume\n"); in bnxt_io_resume()