Lines Matching +full:ns2 +full:- +full:pcie +full:- +full:phy

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>
57 #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()
322 if (!md_dst || md_dst->type != METADATA_HW_PORT_MUX) in bnxt_xmit_get_cfa_action()
325 return md_dst->u.port_info.port_id; in bnxt_xmit_get_cfa_action()
331 bnxt_db_write(bp, &txr->tx_db, prod); in bnxt_txr_db_kick()
332 txr->kick_pending = 0; in bnxt_txr_db_kick()
347 if (bnxt_tx_avail(bp, txr) >= bp->tx_wake_thresh) { in bnxt_txr_netif_try_stop_queue()
366 struct pci_dev *pdev = bp->pdev; in bnxt_start_xmit()
372 if (unlikely(i >= bp->tx_nr_rings)) { in bnxt_start_xmit()
379 txr = &bp->tx_ring[bp->tx_ring_map[i]]; in bnxt_start_xmit()
380 prod = txr->tx_prod; in bnxt_start_xmit()
383 if (unlikely(free_size < skb_shinfo(skb)->nr_frags + 2)) { in bnxt_start_xmit()
385 if (net_ratelimit() && txr->kick_pending) in bnxt_start_xmit()
392 length = skb->len; in bnxt_start_xmit()
394 last_frag = skb_shinfo(skb)->nr_frags; in bnxt_start_xmit()
396 txbd = &txr->tx_desc_ring[TX_RING(prod)][TX_IDX(prod)]; in bnxt_start_xmit()
398 txbd->tx_bd_opaque = prod; in bnxt_start_xmit()
400 tx_buf = &txr->tx_buf_ring[prod]; in bnxt_start_xmit()
401 tx_buf->skb = skb; in bnxt_start_xmit()
402 tx_buf->nr_frags = last_frag; in bnxt_start_xmit()
412 if (skb->vlan_proto == htons(ETH_P_8021Q)) in bnxt_start_xmit()
416 if (unlikely(skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP)) { in bnxt_start_xmit()
417 struct bnxt_ptp_cfg *ptp = bp->ptp_cfg; in bnxt_start_xmit()
419 if (ptp && ptp->tx_tstamp_en && !skb_is_gso(skb) && in bnxt_start_xmit()
420 atomic_dec_if_positive(&ptp->tx_avail) >= 0) { in bnxt_start_xmit()
421 if (!bnxt_ptp_parse(skb, &ptp->tx_seqid, in bnxt_start_xmit()
422 &ptp->tx_hdr_off)) { in bnxt_start_xmit()
424 ptp->tx_hdr_off += VLAN_HLEN; in bnxt_start_xmit()
426 skb_shinfo(skb)->tx_flags |= SKBTX_IN_PROGRESS; in bnxt_start_xmit()
428 atomic_inc(&bp->ptp_cfg->tx_avail); in bnxt_start_xmit()
433 if (unlikely(skb->no_fcs)) in bnxt_start_xmit()
436 if (free_size == bp->tx_ring_size && length <= bp->tx_push_thresh && in bnxt_start_xmit()
438 struct tx_push_buffer *tx_push_buf = txr->tx_push; in bnxt_start_xmit()
439 struct tx_push_bd *tx_push = &tx_push_buf->push_bd; in bnxt_start_xmit()
440 struct tx_bd_ext *tx_push1 = &tx_push->txbd2; in bnxt_start_xmit()
441 void __iomem *db = txr->tx_db.doorbell; in bnxt_start_xmit()
442 void *pdata = tx_push_buf->data; in bnxt_start_xmit()
447 tx_push->tx_bd_len_flags_type = in bnxt_start_xmit()
455 if (skb->ip_summed == CHECKSUM_PARTIAL) in bnxt_start_xmit()
456 tx_push1->tx_bd_hsize_lflags = in bnxt_start_xmit()
459 tx_push1->tx_bd_hsize_lflags = 0; in bnxt_start_xmit()
461 tx_push1->tx_bd_cfa_meta = cpu_to_le32(vlan_tag_flags); in bnxt_start_xmit()
462 tx_push1->tx_bd_cfa_action = in bnxt_start_xmit()
466 end = PTR_ALIGN(end, 8) - 1; in bnxt_start_xmit()
472 skb_frag_t *frag = &skb_shinfo(skb)->frags[j]; in bnxt_start_xmit()
483 txbd->tx_bd_len_flags_type = tx_push->tx_bd_len_flags_type; in bnxt_start_xmit()
484 txbd->tx_bd_haddr = txr->data_mapping; in bnxt_start_xmit()
486 txbd = &txr->tx_desc_ring[TX_RING(prod)][TX_IDX(prod)]; in bnxt_start_xmit()
489 tx_push->doorbell = in bnxt_start_xmit()
491 txr->tx_prod = prod; in bnxt_start_xmit()
493 tx_buf->is_push = 1; in bnxt_start_xmit()
494 netdev_tx_sent_queue(txq, skb->len); in bnxt_start_xmit()
501 (push_len - 16) << 1); in bnxt_start_xmit()
511 pad = BNXT_MIN_PKT_SIZE - length; in bnxt_start_xmit()
518 mapping = dma_map_single(&pdev->dev, skb->data, len, DMA_TO_DEVICE); in bnxt_start_xmit()
520 if (unlikely(dma_mapping_error(&pdev->dev, mapping))) in bnxt_start_xmit()
527 txbd->tx_bd_haddr = cpu_to_le64(mapping); in bnxt_start_xmit()
531 &txr->tx_desc_ring[TX_RING(prod)][TX_IDX(prod)]; in bnxt_start_xmit()
533 txbd1->tx_bd_hsize_lflags = lflags; in bnxt_start_xmit()
537 if (skb->encapsulation) in bnxt_start_xmit()
542 txbd1->tx_bd_hsize_lflags |= cpu_to_le32(TX_BD_FLAGS_LSO | in bnxt_start_xmit()
544 (hdr_len << (TX_BD_HSIZE_SHIFT - 1))); in bnxt_start_xmit()
545 length = skb_shinfo(skb)->gso_size; in bnxt_start_xmit()
546 txbd1->tx_bd_mss = cpu_to_le32(length); in bnxt_start_xmit()
548 } else if (skb->ip_summed == CHECKSUM_PARTIAL) { in bnxt_start_xmit()
549 txbd1->tx_bd_hsize_lflags |= in bnxt_start_xmit()
551 txbd1->tx_bd_mss = 0; in bnxt_start_xmit()
556 dev_warn_ratelimited(&pdev->dev, "Dropped oversize %d bytes TX packet.\n", in bnxt_start_xmit()
557 skb->len); in bnxt_start_xmit()
562 txbd->tx_bd_len_flags_type = cpu_to_le32(flags); in bnxt_start_xmit()
564 txbd1->tx_bd_cfa_meta = cpu_to_le32(vlan_tag_flags); in bnxt_start_xmit()
565 txbd1->tx_bd_cfa_action = in bnxt_start_xmit()
568 skb_frag_t *frag = &skb_shinfo(skb)->frags[i]; in bnxt_start_xmit()
571 txbd = &txr->tx_desc_ring[TX_RING(prod)][TX_IDX(prod)]; in bnxt_start_xmit()
574 mapping = skb_frag_dma_map(&pdev->dev, frag, 0, len, in bnxt_start_xmit()
577 if (unlikely(dma_mapping_error(&pdev->dev, mapping))) in bnxt_start_xmit()
580 tx_buf = &txr->tx_buf_ring[prod]; in bnxt_start_xmit()
583 txbd->tx_bd_haddr = cpu_to_le64(mapping); in bnxt_start_xmit()
586 txbd->tx_bd_len_flags_type = cpu_to_le32(flags); in bnxt_start_xmit()
590 txbd->tx_bd_len_flags_type = in bnxt_start_xmit()
594 netdev_tx_sent_queue(txq, skb->len); in bnxt_start_xmit()
602 txr->tx_prod = prod; in bnxt_start_xmit()
607 txr->kick_pending = 1; in bnxt_start_xmit()
612 if (netdev_xmit_more() && !tx_buf->is_push) in bnxt_start_xmit()
621 atomic_inc(&bp->ptp_cfg->tx_avail); in bnxt_start_xmit()
626 prod = txr->tx_prod; in bnxt_start_xmit()
627 tx_buf = &txr->tx_buf_ring[prod]; in bnxt_start_xmit()
628 dma_unmap_single(&pdev->dev, dma_unmap_addr(tx_buf, mapping), in bnxt_start_xmit()
635 tx_buf = &txr->tx_buf_ring[prod]; in bnxt_start_xmit()
636 dma_unmap_page(&pdev->dev, dma_unmap_addr(tx_buf, mapping), in bnxt_start_xmit()
637 skb_frag_size(&skb_shinfo(skb)->frags[i]), in bnxt_start_xmit()
644 if (txr->kick_pending) in bnxt_start_xmit()
645 bnxt_txr_db_kick(bp, txr, txr->tx_prod); in bnxt_start_xmit()
646 txr->tx_buf_ring[txr->tx_prod].skb = NULL; in bnxt_start_xmit()
653 struct bnxt_tx_ring_info *txr = bnapi->tx_ring; in bnxt_tx_int()
654 struct netdev_queue *txq = netdev_get_tx_queue(bp->dev, txr->txq_index); in bnxt_tx_int()
655 u16 cons = txr->tx_cons; in bnxt_tx_int()
656 struct pci_dev *pdev = bp->pdev; in bnxt_tx_int()
665 tx_buf = &txr->tx_buf_ring[cons]; in bnxt_tx_int()
667 skb = tx_buf->skb; in bnxt_tx_int()
668 tx_buf->skb = NULL; in bnxt_tx_int()
670 tx_bytes += skb->len; in bnxt_tx_int()
672 if (tx_buf->is_push) { in bnxt_tx_int()
673 tx_buf->is_push = 0; in bnxt_tx_int()
677 dma_unmap_single(&pdev->dev, dma_unmap_addr(tx_buf, mapping), in bnxt_tx_int()
679 last = tx_buf->nr_frags; in bnxt_tx_int()
683 tx_buf = &txr->tx_buf_ring[cons]; in bnxt_tx_int()
685 &pdev->dev, in bnxt_tx_int()
687 skb_frag_size(&skb_shinfo(skb)->frags[j]), in bnxt_tx_int()
690 if (unlikely(skb_shinfo(skb)->tx_flags & SKBTX_IN_PROGRESS)) { in bnxt_tx_int()
691 if (bp->flags & BNXT_FLAG_CHIP_P5) { in bnxt_tx_int()
696 atomic_inc(&bp->ptp_cfg->tx_avail); in bnxt_tx_int()
707 txr->tx_cons = cons; in bnxt_tx_int()
717 bnxt_tx_avail(bp, txr) >= bp->tx_wake_thresh && in bnxt_tx_int()
718 READ_ONCE(txr->dev_state) != BNXT_DEV_STATE_CLOSING) in bnxt_tx_int()
726 struct device *dev = &bp->pdev->dev; in __bnxt_alloc_rx_page()
729 page = page_pool_dev_alloc_pages(rxr->page_pool); in __bnxt_alloc_rx_page()
733 *mapping = dma_map_page_attrs(dev, page, 0, PAGE_SIZE, bp->rx_dir, in __bnxt_alloc_rx_page()
736 page_pool_recycle_direct(rxr->page_pool, page); in __bnxt_alloc_rx_page()
746 struct pci_dev *pdev = bp->pdev; in __bnxt_alloc_rx_frag()
749 data = napi_alloc_frag(bp->rx_buf_size); in __bnxt_alloc_rx_frag()
751 data = netdev_alloc_frag(bp->rx_buf_size); in __bnxt_alloc_rx_frag()
755 *mapping = dma_map_single_attrs(&pdev->dev, data + bp->rx_dma_offset, in __bnxt_alloc_rx_frag()
756 bp->rx_buf_use_size, bp->rx_dir, in __bnxt_alloc_rx_frag()
759 if (dma_mapping_error(&pdev->dev, *mapping)) { in __bnxt_alloc_rx_frag()
769 struct rx_bd *rxbd = &rxr->rx_desc_ring[RX_RING(prod)][RX_IDX(prod)]; in bnxt_alloc_rx_data()
770 struct bnxt_sw_rx_bd *rx_buf = &rxr->rx_buf_ring[prod]; in bnxt_alloc_rx_data()
778 return -ENOMEM; in bnxt_alloc_rx_data()
780 mapping += bp->rx_dma_offset; in bnxt_alloc_rx_data()
781 rx_buf->data = page; in bnxt_alloc_rx_data()
782 rx_buf->data_ptr = page_address(page) + bp->rx_offset; in bnxt_alloc_rx_data()
787 return -ENOMEM; in bnxt_alloc_rx_data()
789 rx_buf->data = data; in bnxt_alloc_rx_data()
790 rx_buf->data_ptr = data + bp->rx_offset; in bnxt_alloc_rx_data()
792 rx_buf->mapping = mapping; in bnxt_alloc_rx_data()
794 rxbd->rx_bd_haddr = cpu_to_le64(mapping); in bnxt_alloc_rx_data()
800 u16 prod = rxr->rx_prod; in bnxt_reuse_rx_data()
804 prod_rx_buf = &rxr->rx_buf_ring[prod]; in bnxt_reuse_rx_data()
805 cons_rx_buf = &rxr->rx_buf_ring[cons]; in bnxt_reuse_rx_data()
807 prod_rx_buf->data = data; in bnxt_reuse_rx_data()
808 prod_rx_buf->data_ptr = cons_rx_buf->data_ptr; in bnxt_reuse_rx_data()
810 prod_rx_buf->mapping = cons_rx_buf->mapping; in bnxt_reuse_rx_data()
812 prod_bd = &rxr->rx_desc_ring[RX_RING(prod)][RX_IDX(prod)]; in bnxt_reuse_rx_data()
813 cons_bd = &rxr->rx_desc_ring[RX_RING(cons)][RX_IDX(cons)]; in bnxt_reuse_rx_data()
815 prod_bd->rx_bd_haddr = cons_bd->rx_bd_haddr; in bnxt_reuse_rx_data()
820 u16 next, max = rxr->rx_agg_bmap_size; in bnxt_find_next_agg_idx()
822 next = find_next_zero_bit(rxr->rx_agg_bmap, max, idx); in bnxt_find_next_agg_idx()
824 next = find_first_zero_bit(rxr->rx_agg_bmap, max); in bnxt_find_next_agg_idx()
833 &rxr->rx_agg_desc_ring[RX_RING(prod)][RX_IDX(prod)]; in bnxt_alloc_rx_page()
835 struct pci_dev *pdev = bp->pdev; in bnxt_alloc_rx_page()
838 u16 sw_prod = rxr->rx_sw_agg_prod; in bnxt_alloc_rx_page()
845 return -ENOMEM; in bnxt_alloc_rx_page()
849 page = rxr->rx_page; in bnxt_alloc_rx_page()
853 return -ENOMEM; in bnxt_alloc_rx_page()
854 rxr->rx_page = page; in bnxt_alloc_rx_page()
855 rxr->rx_page_offset = 0; in bnxt_alloc_rx_page()
857 offset = rxr->rx_page_offset; in bnxt_alloc_rx_page()
858 rxr->rx_page_offset += BNXT_RX_PAGE_SIZE; in bnxt_alloc_rx_page()
859 if (rxr->rx_page_offset == PAGE_SIZE) in bnxt_alloc_rx_page()
860 rxr->rx_page = NULL; in bnxt_alloc_rx_page()
866 return -ENOMEM; in bnxt_alloc_rx_page()
869 mapping = dma_map_page_attrs(&pdev->dev, page, offset, in bnxt_alloc_rx_page()
872 if (dma_mapping_error(&pdev->dev, mapping)) { in bnxt_alloc_rx_page()
874 return -EIO; in bnxt_alloc_rx_page()
878 if (unlikely(test_bit(sw_prod, rxr->rx_agg_bmap))) in bnxt_alloc_rx_page()
881 __set_bit(sw_prod, rxr->rx_agg_bmap); in bnxt_alloc_rx_page()
882 rx_agg_buf = &rxr->rx_agg_ring[sw_prod]; in bnxt_alloc_rx_page()
883 rxr->rx_sw_agg_prod = NEXT_RX_AGG(sw_prod); in bnxt_alloc_rx_page()
885 rx_agg_buf->page = page; in bnxt_alloc_rx_page()
886 rx_agg_buf->offset = offset; in bnxt_alloc_rx_page()
887 rx_agg_buf->mapping = mapping; in bnxt_alloc_rx_page()
888 rxbd->rx_bd_haddr = cpu_to_le64(mapping); in bnxt_alloc_rx_page()
889 rxbd->rx_bd_opaque = sw_prod; in bnxt_alloc_rx_page()
901 &cpr->cp_desc_ring[CP_RING(cp_cons)][CP_IDX(cp_cons)]; in bnxt_get_agg()
909 struct bnxt_tpa_info *tpa_info = &rxr->rx_tpa[agg_id]; in bnxt_get_tpa_agg_p5()
911 return &tpa_info->agg_arr[curr]; in bnxt_get_tpa_agg_p5()
917 struct bnxt_napi *bnapi = cpr->bnapi; in bnxt_reuse_rx_agg_bufs()
918 struct bnxt *bp = bnapi->bp; in bnxt_reuse_rx_agg_bufs()
919 struct bnxt_rx_ring_info *rxr = bnapi->rx_ring; in bnxt_reuse_rx_agg_bufs()
920 u16 prod = rxr->rx_agg_prod; in bnxt_reuse_rx_agg_bufs()
921 u16 sw_prod = rxr->rx_sw_agg_prod; in bnxt_reuse_rx_agg_bufs()
925 if ((bp->flags & BNXT_FLAG_CHIP_P5) && tpa) in bnxt_reuse_rx_agg_bufs()
939 cons = agg->rx_agg_cmp_opaque; in bnxt_reuse_rx_agg_bufs()
940 __clear_bit(cons, rxr->rx_agg_bmap); in bnxt_reuse_rx_agg_bufs()
942 if (unlikely(test_bit(sw_prod, rxr->rx_agg_bmap))) in bnxt_reuse_rx_agg_bufs()
945 __set_bit(sw_prod, rxr->rx_agg_bmap); in bnxt_reuse_rx_agg_bufs()
946 prod_rx_buf = &rxr->rx_agg_ring[sw_prod]; in bnxt_reuse_rx_agg_bufs()
947 cons_rx_buf = &rxr->rx_agg_ring[cons]; in bnxt_reuse_rx_agg_bufs()
950 * set cons_rx_buf->page to NULL first. in bnxt_reuse_rx_agg_bufs()
952 page = cons_rx_buf->page; in bnxt_reuse_rx_agg_bufs()
953 cons_rx_buf->page = NULL; in bnxt_reuse_rx_agg_bufs()
954 prod_rx_buf->page = page; in bnxt_reuse_rx_agg_bufs()
955 prod_rx_buf->offset = cons_rx_buf->offset; in bnxt_reuse_rx_agg_bufs()
957 prod_rx_buf->mapping = cons_rx_buf->mapping; in bnxt_reuse_rx_agg_bufs()
959 prod_bd = &rxr->rx_agg_desc_ring[RX_RING(prod)][RX_IDX(prod)]; in bnxt_reuse_rx_agg_bufs()
961 prod_bd->rx_bd_haddr = cpu_to_le64(cons_rx_buf->mapping); in bnxt_reuse_rx_agg_bufs()
962 prod_bd->rx_bd_opaque = sw_prod; in bnxt_reuse_rx_agg_bufs()
967 rxr->rx_agg_prod = prod; in bnxt_reuse_rx_agg_bufs()
968 rxr->rx_sw_agg_prod = sw_prod; in bnxt_reuse_rx_agg_bufs()
979 u16 prod = rxr->rx_prod; in bnxt_rx_multi_page_skb()
988 dma_addr -= bp->rx_dma_offset; in bnxt_rx_multi_page_skb()
989 dma_unmap_page_attrs(&bp->pdev->dev, dma_addr, PAGE_SIZE, bp->rx_dir, in bnxt_rx_multi_page_skb()
992 bp->rx_dma_offset); in bnxt_rx_multi_page_skb()
998 skb_reserve(skb, bp->rx_dma_offset); in bnxt_rx_multi_page_skb()
1014 u16 prod = rxr->rx_prod; in bnxt_rx_page_skb()
1023 dma_addr -= bp->rx_dma_offset; in bnxt_rx_page_skb()
1024 dma_unmap_page_attrs(&bp->pdev->dev, dma_addr, PAGE_SIZE, bp->rx_dir, in bnxt_rx_page_skb()
1028 payload = eth_get_headlen(bp->dev, data_ptr, len); in bnxt_rx_page_skb()
1030 skb = napi_alloc_skb(&rxr->bnapi->napi, payload); in bnxt_rx_page_skb()
1037 off = (void *)data_ptr - page_address(page); in bnxt_rx_page_skb()
1039 memcpy(skb->data - NET_IP_ALIGN, data_ptr - NET_IP_ALIGN, in bnxt_rx_page_skb()
1042 frag = &skb_shinfo(skb)->frags[0]; in bnxt_rx_page_skb()
1045 skb->data_len -= payload; in bnxt_rx_page_skb()
1046 skb->tail += payload; in bnxt_rx_page_skb()
1057 u16 prod = rxr->rx_prod; in bnxt_rx_skb()
1067 skb = build_skb(data, bp->rx_buf_size); in bnxt_rx_skb()
1068 dma_unmap_single_attrs(&bp->pdev->dev, dma_addr, bp->rx_buf_use_size, in bnxt_rx_skb()
1069 bp->rx_dir, DMA_ATTR_WEAK_ORDERING); in bnxt_rx_skb()
1075 skb_reserve(skb, bp->rx_offset); in bnxt_rx_skb()
1086 struct bnxt_napi *bnapi = cpr->bnapi; in __bnxt_rx_agg_pages()
1087 struct pci_dev *pdev = bp->pdev; in __bnxt_rx_agg_pages()
1088 struct bnxt_rx_ring_info *rxr = bnapi->rx_ring; in __bnxt_rx_agg_pages()
1089 u16 prod = rxr->rx_agg_prod; in __bnxt_rx_agg_pages()
1093 if ((bp->flags & BNXT_FLAG_CHIP_P5) && tpa) in __bnxt_rx_agg_pages()
1097 skb_frag_t *frag = &shinfo->frags[i]; in __bnxt_rx_agg_pages()
1108 cons = agg->rx_agg_cmp_opaque; in __bnxt_rx_agg_pages()
1109 frag_len = (le32_to_cpu(agg->rx_agg_cmp_len_flags_type) & in __bnxt_rx_agg_pages()
1112 cons_rx_buf = &rxr->rx_agg_ring[cons]; in __bnxt_rx_agg_pages()
1113 skb_frag_off_set(frag, cons_rx_buf->offset); in __bnxt_rx_agg_pages()
1115 __skb_frag_set_page(frag, cons_rx_buf->page); in __bnxt_rx_agg_pages()
1116 shinfo->nr_frags = i + 1; in __bnxt_rx_agg_pages()
1117 __clear_bit(cons, rxr->rx_agg_bmap); in __bnxt_rx_agg_pages()
1123 mapping = cons_rx_buf->mapping; in __bnxt_rx_agg_pages()
1124 page = cons_rx_buf->page; in __bnxt_rx_agg_pages()
1125 cons_rx_buf->page = NULL; in __bnxt_rx_agg_pages()
1133 nr_frags = --shinfo->nr_frags; in __bnxt_rx_agg_pages()
1134 __skb_frag_set_page(&shinfo->frags[nr_frags], NULL); 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_unmap_page_attrs(&pdev->dev, mapping, BNXT_RX_PAGE_SIZE, in __bnxt_rx_agg_pages()
1146 bp->rx_dir, in __bnxt_rx_agg_pages()
1152 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 += 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 if (!(test_bit(BNXT_STATE_IN_FW_RESET, &bp->state))) in bnxt_queue_fw_reset_work()
1272 queue_delayed_work(bnxt_pf_wq, &bp->fw_reset_task, delay); in bnxt_queue_fw_reset_work()
1274 schedule_delayed_work(&bp->fw_reset_task, delay); in bnxt_queue_fw_reset_work()
1280 queue_work(bnxt_pf_wq, &bp->sp_task); in bnxt_queue_sp_work()
1282 schedule_work(&bp->sp_task); in bnxt_queue_sp_work()
1287 if (!rxr->bnapi->in_reset) { in bnxt_sched_reset()
1288 rxr->bnapi->in_reset = true; in bnxt_sched_reset()
1289 if (bp->flags & BNXT_FLAG_CHIP_P5) in bnxt_sched_reset()
1290 set_bit(BNXT_RESET_TASK_SP_EVENT, &bp->sp_event); in bnxt_sched_reset()
1292 set_bit(BNXT_RST_RING_SP_EVENT, &bp->sp_event); in bnxt_sched_reset()
1295 rxr->rx_next_cons = 0xffff; in bnxt_sched_reset()
1300 struct bnxt_tpa_idx_map *map = rxr->rx_tpa_idx_map; in bnxt_alloc_agg_idx()
1303 if (test_bit(idx, map->agg_idx_bmap)) in bnxt_alloc_agg_idx()
1304 idx = find_first_zero_bit(map->agg_idx_bmap, in bnxt_alloc_agg_idx()
1306 __set_bit(idx, map->agg_idx_bmap); in bnxt_alloc_agg_idx()
1307 map->agg_id_tbl[agg_id] = idx; in bnxt_alloc_agg_idx()
1313 struct bnxt_tpa_idx_map *map = rxr->rx_tpa_idx_map; in bnxt_free_agg_idx()
1315 __clear_bit(idx, map->agg_idx_bmap); in bnxt_free_agg_idx()
1320 struct bnxt_tpa_idx_map *map = rxr->rx_tpa_idx_map; in bnxt_lookup_agg_idx()
1322 return map->agg_id_tbl[agg_id]; in bnxt_lookup_agg_idx()
1335 if (bp->flags & BNXT_FLAG_CHIP_P5) { in bnxt_tpa_start()
1341 cons = tpa_start->rx_tpa_start_cmp_opaque; in bnxt_tpa_start()
1342 prod = rxr->rx_prod; in bnxt_tpa_start()
1343 cons_rx_buf = &rxr->rx_buf_ring[cons]; in bnxt_tpa_start()
1344 prod_rx_buf = &rxr->rx_buf_ring[prod]; in bnxt_tpa_start()
1345 tpa_info = &rxr->rx_tpa[agg_id]; in bnxt_tpa_start()
1347 if (unlikely(cons != rxr->rx_next_cons || in bnxt_tpa_start()
1349 netdev_warn(bp->dev, "TPA cons %x, expected cons %x, error code %x\n", in bnxt_tpa_start()
1350 cons, rxr->rx_next_cons, in bnxt_tpa_start()
1358 tpa_info->cfa_code = TPA_START_CFA_CODE(tpa_start1); in bnxt_tpa_start()
1359 prod_rx_buf->data = tpa_info->data; in bnxt_tpa_start()
1360 prod_rx_buf->data_ptr = tpa_info->data_ptr; in bnxt_tpa_start()
1362 mapping = tpa_info->mapping; in bnxt_tpa_start()
1363 prod_rx_buf->mapping = mapping; in bnxt_tpa_start()
1365 prod_bd = &rxr->rx_desc_ring[RX_RING(prod)][RX_IDX(prod)]; in bnxt_tpa_start()
1367 prod_bd->rx_bd_haddr = cpu_to_le64(mapping); in bnxt_tpa_start()
1369 tpa_info->data = cons_rx_buf->data; in bnxt_tpa_start()
1370 tpa_info->data_ptr = cons_rx_buf->data_ptr; in bnxt_tpa_start()
1371 cons_rx_buf->data = NULL; in bnxt_tpa_start()
1372 tpa_info->mapping = cons_rx_buf->mapping; in bnxt_tpa_start()
1374 tpa_info->len = in bnxt_tpa_start()
1375 le32_to_cpu(tpa_start->rx_tpa_start_cmp_len_flags_type) >> in bnxt_tpa_start()
1380 tpa_info->hash_type = PKT_HASH_TYPE_L4; in bnxt_tpa_start()
1381 tpa_info->gso_type = SKB_GSO_TCPV4; in bnxt_tpa_start()
1382 /* RSS profiles 1 and 3 with extract code 0 for inner 4-tuple */ in bnxt_tpa_start()
1384 tpa_info->gso_type = SKB_GSO_TCPV6; in bnxt_tpa_start()
1385 tpa_info->rss_hash = in bnxt_tpa_start()
1386 le32_to_cpu(tpa_start->rx_tpa_start_cmp_rss_hash); in bnxt_tpa_start()
1388 tpa_info->hash_type = PKT_HASH_TYPE_NONE; in bnxt_tpa_start()
1389 tpa_info->gso_type = 0; in bnxt_tpa_start()
1390 netif_warn(bp, rx_err, bp->dev, "TPA packet without valid hash\n"); in bnxt_tpa_start()
1392 tpa_info->flags2 = le32_to_cpu(tpa_start1->rx_tpa_start_cmp_flags2); in bnxt_tpa_start()
1393 tpa_info->metadata = le32_to_cpu(tpa_start1->rx_tpa_start_cmp_metadata); in bnxt_tpa_start()
1394 tpa_info->hdr_info = le32_to_cpu(tpa_start1->rx_tpa_start_cmp_hdr_info); in bnxt_tpa_start()
1395 tpa_info->agg_count = 0; in bnxt_tpa_start()
1397 rxr->rx_prod = NEXT_RX(prod); in bnxt_tpa_start()
1399 rxr->rx_next_cons = NEXT_RX(cons); in bnxt_tpa_start()
1400 cons_rx_buf = &rxr->rx_buf_ring[cons]; in bnxt_tpa_start()
1402 bnxt_reuse_rx_data(rxr, cons, cons_rx_buf->data); in bnxt_tpa_start()
1403 rxr->rx_prod = NEXT_RX(rxr->rx_prod); in bnxt_tpa_start()
1404 cons_rx_buf->data = NULL; in bnxt_tpa_start()
1419 struct iphdr *iph = (struct iphdr *)skb->data; in bnxt_gro_tunnel()
1421 if (iph->protocol == IPPROTO_UDP) in bnxt_gro_tunnel()
1424 struct ipv6hdr *iph = (struct ipv6hdr *)skb->data; in bnxt_gro_tunnel()
1426 if (iph->nexthdr == IPPROTO_UDP) in bnxt_gro_tunnel()
1430 if (uh->check) in bnxt_gro_tunnel()
1431 skb_shinfo(skb)->gso_type |= SKB_GSO_UDP_TUNNEL_CSUM; in bnxt_gro_tunnel()
1433 skb_shinfo(skb)->gso_type |= SKB_GSO_UDP_TUNNEL; in bnxt_gro_tunnel()
1446 u32 hdr_info = tpa_info->hdr_info; in bnxt_gro_func_5731x()
1459 __be16 proto = *((__be16 *)(skb->data + inner_ip_off - in bnxt_gro_func_5731x()
1460 ETH_HLEN - 2)); in bnxt_gro_func_5731x()
1471 inner_ip_off -= 4; in bnxt_gro_func_5731x()
1472 inner_mac_off -= 4; in bnxt_gro_func_5731x()
1473 outer_ip_off -= 4; in bnxt_gro_func_5731x()
1476 nw_off = inner_ip_off - ETH_HLEN; in bnxt_gro_func_5731x()
1478 if (tpa_info->flags2 & RX_TPA_START_CMP_FLAGS2_IP_TYPE) { in bnxt_gro_func_5731x()
1482 len = skb->len - skb_transport_offset(skb); in bnxt_gro_func_5731x()
1484 th->check = ~tcp_v6_check(len, &iph->saddr, &iph->daddr, 0); in bnxt_gro_func_5731x()
1489 len = skb->len - skb_transport_offset(skb); in bnxt_gro_func_5731x()
1491 th->check = ~tcp_v4_check(len, iph->saddr, iph->daddr, 0); in bnxt_gro_func_5731x()
1495 __be16 proto = *((__be16 *)(skb->data + outer_ip_off - in bnxt_gro_func_5731x()
1496 ETH_HLEN - 2)); in bnxt_gro_func_5731x()
1510 u32 hdr_info = tpa_info->hdr_info; in bnxt_gro_func_5750x()
1517 nw_off = inner_ip_off - ETH_HLEN; in bnxt_gro_func_5750x()
1519 iphdr_len = (tpa_info->flags2 & RX_TPA_START_CMP_FLAGS2_IP_TYPE) ? in bnxt_gro_func_5750x()
1524 __be16 proto = *((__be16 *)(skb->data + outer_ip_off - in bnxt_gro_func_5750x()
1525 ETH_HLEN - 2)); in bnxt_gro_func_5750x()
1547 if (tpa_info->gso_type == SKB_GSO_TCPV4) { in bnxt_gro_func_5730x()
1550 nw_off = payload_off - BNXT_IPV4_HDR_SIZE - tcp_opt_len - in bnxt_gro_func_5730x()
1555 len = skb->len - skb_transport_offset(skb); in bnxt_gro_func_5730x()
1557 th->check = ~tcp_v4_check(len, iph->saddr, iph->daddr, 0); in bnxt_gro_func_5730x()
1558 } else if (tpa_info->gso_type == SKB_GSO_TCPV6) { in bnxt_gro_func_5730x()
1561 nw_off = payload_off - BNXT_IPV6_HDR_SIZE - tcp_opt_len - in bnxt_gro_func_5730x()
1566 len = skb->len - skb_transport_offset(skb); in bnxt_gro_func_5730x()
1568 th->check = ~tcp_v6_check(len, &iph->saddr, &iph->daddr, 0); in bnxt_gro_func_5730x()
1575 bnxt_gro_tunnel(skb, skb->protocol); in bnxt_gro_func_5730x()
1594 NAPI_GRO_CB(skb)->count = segs; in bnxt_gro_skb()
1595 skb_shinfo(skb)->gso_size = in bnxt_gro_skb()
1596 le32_to_cpu(tpa_end1->rx_tpa_end_cmp_seg_len); in bnxt_gro_skb()
1597 skb_shinfo(skb)->gso_type = tpa_info->gso_type; in bnxt_gro_skb()
1598 if (bp->flags & BNXT_FLAG_CHIP_P5) in bnxt_gro_skb()
1602 skb = bp->gro_func(tpa_info, payload_off, TPA_END_GRO_TS(tpa_end), skb); in bnxt_gro_skb()
1610 * netdev (vf-rep or PF) the packet is destined to.
1616 /* if vf-rep dev is NULL, the must belongs to the PF */ in bnxt_get_pkt_dev()
1617 return dev ? dev : bp->dev; in bnxt_get_pkt_dev()
1627 struct bnxt_napi *bnapi = cpr->bnapi; in bnxt_tpa_end()
1628 struct bnxt_rx_ring_info *rxr = bnapi->rx_ring; in bnxt_tpa_end()
1638 if (unlikely(bnapi->in_reset)) { in bnxt_tpa_end()
1642 return ERR_PTR(-EBUSY); in bnxt_tpa_end()
1646 if (bp->flags & BNXT_FLAG_CHIP_P5) { in bnxt_tpa_end()
1650 tpa_info = &rxr->rx_tpa[agg_id]; in bnxt_tpa_end()
1651 if (unlikely(agg_bufs != tpa_info->agg_count)) { in bnxt_tpa_end()
1652 netdev_warn(bp->dev, "TPA end agg_buf %d != expected agg_bufs %d\n", in bnxt_tpa_end()
1653 agg_bufs, tpa_info->agg_count); in bnxt_tpa_end()
1654 agg_bufs = tpa_info->agg_count; in bnxt_tpa_end()
1656 tpa_info->agg_count = 0; in bnxt_tpa_end()
1660 gro = !!(bp->flags & BNXT_FLAG_GRO); in bnxt_tpa_end()
1664 tpa_info = &rxr->rx_tpa[agg_id]; in bnxt_tpa_end()
1668 return ERR_PTR(-EBUSY); in bnxt_tpa_end()
1675 data = tpa_info->data; in bnxt_tpa_end()
1676 data_ptr = tpa_info->data_ptr; in bnxt_tpa_end()
1678 len = tpa_info->len; in bnxt_tpa_end()
1679 mapping = tpa_info->mapping; in bnxt_tpa_end()
1684 netdev_warn(bp->dev, "TPA frags %d exceeded MAX_SKB_FRAGS %d\n", in bnxt_tpa_end()
1689 if (len <= bp->rx_copy_thresh) { in bnxt_tpa_end()
1693 cpr->sw_stats.rx.rx_oom_discards += 1; in bnxt_tpa_end()
1703 cpr->sw_stats.rx.rx_oom_discards += 1; in bnxt_tpa_end()
1707 tpa_info->data = new_data; in bnxt_tpa_end()
1708 tpa_info->data_ptr = new_data + bp->rx_offset; in bnxt_tpa_end()
1709 tpa_info->mapping = new_mapping; in bnxt_tpa_end()
1711 skb = build_skb(data, bp->rx_buf_size); in bnxt_tpa_end()
1712 dma_unmap_single_attrs(&bp->pdev->dev, mapping, in bnxt_tpa_end()
1713 bp->rx_buf_use_size, bp->rx_dir, in bnxt_tpa_end()
1719 cpr->sw_stats.rx.rx_oom_discards += 1; in bnxt_tpa_end()
1722 skb_reserve(skb, bp->rx_offset); in bnxt_tpa_end()
1730 cpr->sw_stats.rx.rx_oom_discards += 1; in bnxt_tpa_end()
1735 skb->protocol = in bnxt_tpa_end()
1736 eth_type_trans(skb, bnxt_get_pkt_dev(bp, tpa_info->cfa_code)); in bnxt_tpa_end()
1738 if (tpa_info->hash_type != PKT_HASH_TYPE_NONE) in bnxt_tpa_end()
1739 skb_set_hash(skb, tpa_info->rss_hash, tpa_info->hash_type); in bnxt_tpa_end()
1741 if ((tpa_info->flags2 & RX_CMP_FLAGS2_META_FORMAT_VLAN) && in bnxt_tpa_end()
1742 (skb->dev->features & BNXT_HW_FEATURE_VLAN_ALL_RX)) { in bnxt_tpa_end()
1743 __be16 vlan_proto = htons(tpa_info->metadata >> in bnxt_tpa_end()
1745 u16 vtag = tpa_info->metadata & RX_CMP_FLAGS2_METADATA_TCI_MASK; in bnxt_tpa_end()
1756 if (likely(tpa_info->flags2 & RX_TPA_START_CMP_FLAGS2_L4_CS_CALC)) { in bnxt_tpa_end()
1757 skb->ip_summed = CHECKSUM_UNNECESSARY; in bnxt_tpa_end()
1758 skb->csum_level = in bnxt_tpa_end()
1759 (tpa_info->flags2 & RX_CMP_FLAGS2_T_L4_CS_CALC) >> 3; in bnxt_tpa_end()
1775 tpa_info = &rxr->rx_tpa[agg_id]; in bnxt_tpa_agg()
1776 BUG_ON(tpa_info->agg_count >= MAX_SKB_FRAGS); in bnxt_tpa_agg()
1777 tpa_info->agg_arr[tpa_info->agg_count++] = *rx_agg; in bnxt_tpa_agg()
1783 if (skb->dev != bp->dev) { in bnxt_deliver_skb()
1784 /* this packet belongs to a vf-rep */ in bnxt_deliver_skb()
1788 skb_record_rx_queue(skb, bnapi->index); in bnxt_deliver_skb()
1789 napi_gro_receive(&bnapi->napi, skb); in bnxt_deliver_skb()
1793 * 1 - 1 packet successfully received
1794 * 0 - successful TPA_START, packet not completed yet
1795 * -EBUSY - completion ring does not have all the agg buffers yet
1796 * -ENOMEM - packet aborted due to out of memory
1797 * -EIO - packet aborted due to hw error indicated in BD
1802 struct bnxt_napi *bnapi = cpr->bnapi; in bnxt_rx_pkt()
1803 struct bnxt_rx_ring_info *rxr = bnapi->rx_ring; in bnxt_rx_pkt()
1804 struct net_device *dev = bp->dev; in bnxt_rx_pkt()
1821 &cpr->cp_desc_ring[CP_RING(cp_cons)][CP_IDX(cp_cons)]; in bnxt_rx_pkt()
1833 &cpr->cp_desc_ring[CP_RING(cp_cons)][CP_IDX(cp_cons)]; in bnxt_rx_pkt()
1836 return -EBUSY; in bnxt_rx_pkt()
1842 prod = rxr->rx_prod; in bnxt_rx_pkt()
1857 return -EBUSY; in bnxt_rx_pkt()
1859 rc = -ENOMEM; in bnxt_rx_pkt()
1868 cons = rxcmp->rx_cmp_opaque; in bnxt_rx_pkt()
1869 if (unlikely(cons != rxr->rx_next_cons)) { in bnxt_rx_pkt()
1873 if (rxr->rx_next_cons != 0xffff) in bnxt_rx_pkt()
1874 netdev_warn(bp->dev, "RX cons %x != expected cons %x\n", in bnxt_rx_pkt()
1875 cons, rxr->rx_next_cons); in bnxt_rx_pkt()
1881 rx_buf = &rxr->rx_buf_ring[cons]; in bnxt_rx_pkt()
1882 data = rx_buf->data; in bnxt_rx_pkt()
1883 data_ptr = rx_buf->data_ptr; in bnxt_rx_pkt()
1886 misc = le32_to_cpu(rxcmp->rx_cmp_misc_v1); in bnxt_rx_pkt()
1891 return -EBUSY; in bnxt_rx_pkt()
1898 rx_buf->data = NULL; in bnxt_rx_pkt()
1899 if (rxcmp1->rx_cmp_cfa_code_errors_v2 & RX_CMP_L2_ERRORS) { in bnxt_rx_pkt()
1900 u32 rx_err = le32_to_cpu(rxcmp1->rx_cmp_cfa_code_errors_v2); in bnxt_rx_pkt()
1907 rc = -EIO; in bnxt_rx_pkt()
1909 bnapi->cp_ring.sw_stats.rx.rx_buf_errors++; in bnxt_rx_pkt()
1910 if (!(bp->flags & BNXT_FLAG_CHIP_P5) && in bnxt_rx_pkt()
1911 !(bp->fw_cap & BNXT_FW_CAP_RING_MONITOR)) { in bnxt_rx_pkt()
1912 netdev_warn_once(bp->dev, "RX buffer error %x\n", in bnxt_rx_pkt()
1920 flags = le32_to_cpu(rxcmp->rx_cmp_len_flags_type); in bnxt_rx_pkt()
1922 dma_addr = rx_buf->mapping; in bnxt_rx_pkt()
1931 cpr->sw_stats.rx.rx_oom_discards += 1; in bnxt_rx_pkt()
1932 rc = -ENOMEM; in bnxt_rx_pkt()
1946 if (len <= bp->rx_copy_thresh) { in bnxt_rx_pkt()
1957 cpr->sw_stats.rx.rx_oom_discards += 1; in bnxt_rx_pkt()
1958 rc = -ENOMEM; in bnxt_rx_pkt()
1964 if (rx_buf->data_ptr == data_ptr) in bnxt_rx_pkt()
1968 skb = bp->rx_skb_func(bp, rxr, cons, data, data_ptr, dma_addr, in bnxt_rx_pkt()
1971 cpr->sw_stats.rx.rx_oom_discards += 1; in bnxt_rx_pkt()
1972 rc = -ENOMEM; in bnxt_rx_pkt()
1981 cpr->sw_stats.rx.rx_oom_discards += 1; in bnxt_rx_pkt()
1982 rc = -ENOMEM; in bnxt_rx_pkt()
1986 skb = bnxt_xdp_build_skb(bp, skb, agg_bufs, rxr->page_pool, &xdp, rxcmp1); in bnxt_rx_pkt()
1990 cpr->sw_stats.rx.rx_oom_discards += 1; in bnxt_rx_pkt()
1991 rc = -ENOMEM; in bnxt_rx_pkt()
2001 /* RSS profiles 1 and 3 with extract code 0 for inner 4-tuple */ in bnxt_rx_pkt()
2004 skb_set_hash(skb, le32_to_cpu(rxcmp->rx_cmp_rss_hash), type); in bnxt_rx_pkt()
2008 skb->protocol = eth_type_trans(skb, bnxt_get_pkt_dev(bp, cfa_code)); in bnxt_rx_pkt()
2010 if ((rxcmp1->rx_cmp_flags2 & in bnxt_rx_pkt()
2012 (skb->dev->features & BNXT_HW_FEATURE_VLAN_ALL_RX)) { in bnxt_rx_pkt()
2013 u32 meta_data = le32_to_cpu(rxcmp1->rx_cmp_meta_data); in bnxt_rx_pkt()
2028 if (dev->features & NETIF_F_RXCSUM) { in bnxt_rx_pkt()
2029 skb->ip_summed = CHECKSUM_UNNECESSARY; in bnxt_rx_pkt()
2030 skb->csum_level = RX_CMP_ENCAP(rxcmp1); in bnxt_rx_pkt()
2033 if (rxcmp1->rx_cmp_cfa_code_errors_v2 & RX_CMP_L4_CS_ERR_BITS) { in bnxt_rx_pkt()
2034 if (dev->features & NETIF_F_RXCSUM) in bnxt_rx_pkt()
2035 bnapi->cp_ring.sw_stats.rx.rx_l4_csum_errors++; in bnxt_rx_pkt()
2040 RX_CMP_FLAGS_ITYPE_PTP_W_TS) || bp->ptp_all_rx_tstamp) { in bnxt_rx_pkt()
2041 if (bp->flags & BNXT_FLAG_CHIP_P5) { in bnxt_rx_pkt()
2042 u32 cmpl_ts = le32_to_cpu(rxcmp1->rx_cmp_timestamp); in bnxt_rx_pkt()
2046 struct bnxt_ptp_cfg *ptp = bp->ptp_cfg; in bnxt_rx_pkt()
2048 spin_lock_bh(&ptp->ptp_lock); in bnxt_rx_pkt()
2049 ns = timecounter_cyc2time(&ptp->tc, ts); in bnxt_rx_pkt()
2050 spin_unlock_bh(&ptp->ptp_lock); in bnxt_rx_pkt()
2053 skb_hwtstamps(skb)->hwtstamp = ns_to_ktime(ns); in bnxt_rx_pkt()
2061 cpr->rx_packets += 1; in bnxt_rx_pkt()
2062 cpr->rx_bytes += len; in bnxt_rx_pkt()
2065 rxr->rx_prod = NEXT_RX(prod); in bnxt_rx_pkt()
2066 rxr->rx_next_cons = NEXT_RX(cons); in bnxt_rx_pkt()
2090 &cpr->cp_desc_ring[CP_RING(cp_cons)][CP_IDX(cp_cons)]; in bnxt_force_rx_discard()
2095 &cpr->cp_desc_ring[CP_RING(cp_cons)][CP_IDX(cp_cons)]; in bnxt_force_rx_discard()
2098 return -EBUSY; in bnxt_force_rx_discard()
2106 rxcmp1->rx_cmp_cfa_code_errors_v2 |= in bnxt_force_rx_discard()
2112 tpa_end1->rx_tpa_end_cmp_errors_v2 |= in bnxt_force_rx_discard()
2116 if (rc && rc != -EBUSY) in bnxt_force_rx_discard()
2117 cpr->sw_stats.rx.rx_netpoll_discards += 1; in bnxt_force_rx_discard()
2123 struct bnxt_fw_health *fw_health = bp->fw_health; in bnxt_fw_health_readl()
2124 u32 reg = fw_health->regs[reg_idx]; in bnxt_fw_health_readl()
2131 pci_read_config_dword(bp->pdev, reg_off, &val); in bnxt_fw_health_readl()
2134 reg_off = fw_health->mapped_regs[reg_idx]; in bnxt_fw_health_readl()
2137 val = readl(bp->bar0 + reg_off); in bnxt_fw_health_readl()
2140 val = readl(bp->bar1 + reg_off); in bnxt_fw_health_readl()
2144 val &= fw_health->fw_reset_inprog_reg_mask; in bnxt_fw_health_readl()
2152 for (i = 0; i < bp->rx_nr_rings; i++) { in bnxt_agg_ring_id_to_grp_idx()
2153 u16 grp_idx = bp->rx_ring[i].bnapi->index; in bnxt_agg_ring_id_to_grp_idx()
2156 grp_info = &bp->grp_info[grp_idx]; in bnxt_agg_ring_id_to_grp_idx()
2157 if (grp_info->agg_fw_ring_id == ring_id) in bnxt_agg_ring_id_to_grp_idx()
2169 …netdev_err(bp->dev, "1PPS: Received invalid signal on pin%lu from the external source. Please fix … in bnxt_event_error_report()
2173 netdev_warn(bp->dev, "Pause Storm detected!\n"); in bnxt_event_error_report()
2176 netdev_warn(bp->dev, "One or more MMIO doorbells dropped by the device!\n"); in bnxt_event_error_report()
2179 netdev_err(bp->dev, "FW reported unknown error type %u\n", in bnxt_event_error_report()
2210 u16 event_id = le16_to_cpu(cmpl->event_id); in bnxt_async_event_process()
2211 u32 data1 = le32_to_cpu(cmpl->event_data1); in bnxt_async_event_process()
2212 u32 data2 = le32_to_cpu(cmpl->event_data2); in bnxt_async_event_process()
2214 netdev_dbg(bp->dev, "hwrm event 0x%x {0x%x, 0x%x}\n", in bnxt_async_event_process()
2220 struct bnxt_link_info *link_info = &bp->link_info; in bnxt_async_event_process()
2226 if (!(link_info->autoneg & BNXT_AUTONEG_SPEED) && in bnxt_async_event_process()
2228 u16 fw_speed = link_info->force_link_speed; in bnxt_async_event_process()
2232 netdev_warn(bp->dev, "Link speed %d no longer supported\n", in bnxt_async_event_process()
2235 set_bit(BNXT_LINK_SPEED_CHNG_SP_EVENT, &bp->sp_event); in bnxt_async_event_process()
2240 set_bit(BNXT_LINK_CFG_CHANGE_SP_EVENT, &bp->sp_event); in bnxt_async_event_process()
2243 set_bit(BNXT_LINK_CHNG_SP_EVENT, &bp->sp_event); in bnxt_async_event_process()
2246 set_bit(BNXT_HWRM_PF_UNLOAD_SP_EVENT, &bp->sp_event); in bnxt_async_event_process()
2254 if (bp->pf.port_id != port_id) in bnxt_async_event_process()
2257 set_bit(BNXT_HWRM_PORT_MODULE_SP_EVENT, &bp->sp_event); in bnxt_async_event_process()
2263 set_bit(BNXT_RESET_TASK_SILENT_SP_EVENT, &bp->sp_event); in bnxt_async_event_process()
2268 if (!bp->fw_health) in bnxt_async_event_process()
2271 bp->fw_reset_timestamp = jiffies; in bnxt_async_event_process()
2272 bp->fw_reset_min_dsecs = cmpl->timestamp_lo; in bnxt_async_event_process()
2273 if (!bp->fw_reset_min_dsecs) in bnxt_async_event_process()
2274 bp->fw_reset_min_dsecs = BNXT_DFLT_FW_RST_MIN_DSECS; in bnxt_async_event_process()
2275 bp->fw_reset_max_dsecs = le16_to_cpu(cmpl->timestamp_hi); in bnxt_async_event_process()
2276 if (!bp->fw_reset_max_dsecs) in bnxt_async_event_process()
2277 bp->fw_reset_max_dsecs = BNXT_DFLT_FW_RST_MAX_DSECS; in bnxt_async_event_process()
2279 set_bit(BNXT_STATE_FW_ACTIVATE_RESET, &bp->state); in bnxt_async_event_process()
2282 bp->fw_health->fatalities++; in bnxt_async_event_process()
2283 set_bit(BNXT_STATE_FW_FATAL_COND, &bp->state); in bnxt_async_event_process()
2286 type_str = "Non-fatal"; in bnxt_async_event_process()
2287 bp->fw_health->survivals++; in bnxt_async_event_process()
2288 set_bit(BNXT_STATE_FW_NON_FATAL_COND, &bp->state); in bnxt_async_event_process()
2290 netif_warn(bp, hw, bp->dev, in bnxt_async_event_process()
2293 bp->fw_reset_min_dsecs * 100, in bnxt_async_event_process()
2294 bp->fw_reset_max_dsecs * 100); in bnxt_async_event_process()
2295 set_bit(BNXT_FW_RESET_NOTIFY_SP_EVENT, &bp->sp_event); in bnxt_async_event_process()
2299 struct bnxt_fw_health *fw_health = bp->fw_health; in bnxt_async_event_process()
2307 fw_health->enabled = false; in bnxt_async_event_process()
2308 netif_info(bp, drv, bp->dev, "Driver recovery watchdog is disabled\n"); in bnxt_async_event_process()
2311 fw_health->primary = EVENT_DATA1_RECOVERY_MASTER_FUNC(data1); in bnxt_async_event_process()
2312 fw_health->tmr_multiplier = in bnxt_async_event_process()
2313 DIV_ROUND_UP(fw_health->polling_dsecs * HZ, in bnxt_async_event_process()
2314 bp->current_interval * 10); in bnxt_async_event_process()
2315 fw_health->tmr_counter = fw_health->tmr_multiplier; in bnxt_async_event_process()
2316 if (!fw_health->enabled) in bnxt_async_event_process()
2317 fw_health->last_fw_heartbeat = in bnxt_async_event_process()
2319 fw_health->last_fw_reset_cnt = in bnxt_async_event_process()
2324 netif_info(bp, drv, bp->dev, in bnxt_async_event_process()
2326 fw_health->primary ? "primary" : "backup", status, in bnxt_async_event_process()
2327 status_desc, fw_health->last_fw_reset_cnt); in bnxt_async_event_process()
2328 if (!fw_health->enabled) { in bnxt_async_event_process()
2333 fw_health->enabled = true; in bnxt_async_event_process()
2338 netif_notice(bp, hw, bp->dev, in bnxt_async_event_process()
2346 if (bp->flags & BNXT_FLAG_CHIP_P5) in bnxt_async_event_process()
2349 netdev_warn(bp->dev, "Ring monitor event, ring type %lu id 0x%x\n", in bnxt_async_event_process()
2356 netdev_warn(bp->dev, "Unknown RX agg ring id 0x%x\n", in bnxt_async_event_process()
2360 rxr = bp->bnapi[grp_idx]->rx_ring; in bnxt_async_event_process()
2365 struct bnxt_fw_health *fw_health = bp->fw_health; in bnxt_async_event_process()
2367 netif_notice(bp, hw, bp->dev, in bnxt_async_event_process()
2371 fw_health->echo_req_data1 = data1; in bnxt_async_event_process()
2372 fw_health->echo_req_data2 = data2; in bnxt_async_event_process()
2373 set_bit(BNXT_FW_ECHO_REQUEST_SP_EVENT, &bp->sp_event); in bnxt_async_event_process()
2389 if (bp->fw_cap & BNXT_FW_CAP_PTP_RTC) { in bnxt_async_event_process()
2390 struct bnxt_ptp_cfg *ptp = bp->ptp_cfg; in bnxt_async_event_process()
2393 spin_lock_bh(&ptp->ptp_lock); in bnxt_async_event_process()
2396 BNXT_PHC_BITS) | ptp->current_time); in bnxt_async_event_process()
2398 spin_unlock_bh(&ptp->ptp_lock); in bnxt_async_event_process()
2405 u16 seq_id = le32_to_cpu(cmpl->event_data2) & 0xffff; in bnxt_async_event_process()
2428 seq_id = le16_to_cpu(h_cmpl->sequence_id); in bnxt_hwrm_handler()
2433 vf_id = le16_to_cpu(fwd_req_cmpl->source_id); in bnxt_hwrm_handler()
2435 if ((vf_id < bp->pf.first_vf_id) || in bnxt_hwrm_handler()
2436 (vf_id >= bp->pf.first_vf_id + bp->pf.active_vfs)) { in bnxt_hwrm_handler()
2437 netdev_err(bp->dev, "Msg contains invalid VF id %x\n", in bnxt_hwrm_handler()
2439 return -EINVAL; in bnxt_hwrm_handler()
2442 set_bit(vf_id - bp->pf.first_vf_id, bp->pf.vf_event_bmap); in bnxt_hwrm_handler()
2443 set_bit(BNXT_HWRM_EXEC_FWD_REQ_SP_EVENT, &bp->sp_event); in bnxt_hwrm_handler()
2462 struct bnxt *bp = bnapi->bp; in bnxt_msix()
2463 struct bnxt_cp_ring_info *cpr = &bnapi->cp_ring; in bnxt_msix()
2464 u32 cons = RING_CMP(cpr->cp_raw_cons); in bnxt_msix()
2466 cpr->event_ctr++; in bnxt_msix()
2467 prefetch(&cpr->cp_desc_ring[CP_RING(cons)][CP_IDX(cons)]); in bnxt_msix()
2468 napi_schedule(&bnapi->napi); in bnxt_msix()
2474 u32 raw_cons = cpr->cp_raw_cons; in bnxt_has_work()
2478 txcmp = &cpr->cp_desc_ring[CP_RING(cons)][CP_IDX(cons)]; in bnxt_has_work()
2486 struct bnxt *bp = bnapi->bp; in bnxt_inta()
2487 struct bnxt_cp_ring_info *cpr = &bnapi->cp_ring; in bnxt_inta()
2488 u32 cons = RING_CMP(cpr->cp_raw_cons); in bnxt_inta()
2491 prefetch(&cpr->cp_desc_ring[CP_RING(cons)][CP_IDX(cons)]); in bnxt_inta()
2494 int_status = readl(bp->bar0 + BNXT_CAG_REG_LEGACY_INT_STATUS); in bnxt_inta()
2496 if (!(int_status & (0x10000 << cpr->cp_ring_struct.fw_ring_id))) in bnxt_inta()
2501 BNXT_CP_DB_IRQ_DIS(cpr->cp_db.doorbell); in bnxt_inta()
2504 if (unlikely(atomic_read(&bp->intr_sem) != 0)) in bnxt_inta()
2507 napi_schedule(&bnapi->napi); in bnxt_inta()
2514 struct bnxt_napi *bnapi = cpr->bnapi; in __bnxt_poll_work()
2515 u32 raw_cons = cpr->cp_raw_cons; in __bnxt_poll_work()
2522 cpr->has_more_work = 0; in __bnxt_poll_work()
2523 cpr->had_work_done = 1; in __bnxt_poll_work()
2528 txcmp = &cpr->cp_desc_ring[CP_RING(cons)][CP_IDX(cons)]; in __bnxt_poll_work()
2540 if (unlikely(tx_pkts >= bp->tx_wake_thresh)) { in __bnxt_poll_work()
2544 cpr->has_more_work = 1; in __bnxt_poll_work()
2555 /* Increment rx_pkts when rc is -ENOMEM to count towards in __bnxt_poll_work()
2560 else if (rc == -ENOMEM && budget) in __bnxt_poll_work()
2562 else if (rc == -EBUSY) /* partial completion */ in __bnxt_poll_work()
2575 cpr->has_more_work = 1; in __bnxt_poll_work()
2584 struct bnxt_tx_ring_info *txr = bnapi->tx_ring; in __bnxt_poll_work()
2585 u16 prod = txr->tx_prod; in __bnxt_poll_work()
2590 bnxt_db_write_relaxed(bp, &txr->tx_db, prod); in __bnxt_poll_work()
2593 cpr->cp_raw_cons = raw_cons; in __bnxt_poll_work()
2594 bnapi->tx_pkts += tx_pkts; in __bnxt_poll_work()
2595 bnapi->events |= event; in __bnxt_poll_work()
2601 if (bnapi->tx_pkts) { in __bnxt_poll_work_done()
2602 bnapi->tx_int(bp, bnapi, bnapi->tx_pkts); in __bnxt_poll_work_done()
2603 bnapi->tx_pkts = 0; in __bnxt_poll_work_done()
2606 if ((bnapi->events & BNXT_RX_EVENT) && !(bnapi->in_reset)) { in __bnxt_poll_work_done()
2607 struct bnxt_rx_ring_info *rxr = bnapi->rx_ring; in __bnxt_poll_work_done()
2609 bnxt_db_write(bp, &rxr->rx_db, rxr->rx_prod); in __bnxt_poll_work_done()
2611 if (bnapi->events & BNXT_AGG_EVENT) { in __bnxt_poll_work_done()
2612 struct bnxt_rx_ring_info *rxr = bnapi->rx_ring; in __bnxt_poll_work_done()
2614 bnxt_db_write(bp, &rxr->rx_agg_db, rxr->rx_agg_prod); in __bnxt_poll_work_done()
2616 bnapi->events = 0; in __bnxt_poll_work_done()
2622 struct bnxt_napi *bnapi = cpr->bnapi; in bnxt_poll_work()
2631 bnxt_db_cq(bp, &cpr->cp_db, cpr->cp_raw_cons); in bnxt_poll_work()
2640 struct bnxt *bp = bnapi->bp; in bnxt_poll_nitroa0()
2641 struct bnxt_cp_ring_info *cpr = &bnapi->cp_ring; in bnxt_poll_nitroa0()
2642 struct bnxt_rx_ring_info *rxr = bnapi->rx_ring; in bnxt_poll_nitroa0()
2646 u32 raw_cons = cpr->cp_raw_cons; in bnxt_poll_nitroa0()
2654 txcmp = &cpr->cp_desc_ring[CP_RING(cp_cons)][CP_IDX(cp_cons)]; in bnxt_poll_nitroa0()
2667 &cpr->cp_desc_ring[CP_RING(cp_cons)][CP_IDX(cp_cons)]; in bnxt_poll_nitroa0()
2673 rxcmp1->rx_cmp_cfa_code_errors_v2 |= in bnxt_poll_nitroa0()
2677 if (likely(rc == -EIO) && budget) in bnxt_poll_nitroa0()
2679 else if (rc == -EBUSY) /* partial completion */ in bnxt_poll_nitroa0()
2685 netdev_err(bp->dev, in bnxt_poll_nitroa0()
2694 cpr->cp_raw_cons = raw_cons; in bnxt_poll_nitroa0()
2695 BNXT_DB_CQ(&cpr->cp_db, cpr->cp_raw_cons); in bnxt_poll_nitroa0()
2696 bnxt_db_write(bp, &rxr->rx_db, rxr->rx_prod); in bnxt_poll_nitroa0()
2699 bnxt_db_write(bp, &rxr->rx_agg_db, rxr->rx_agg_prod); in bnxt_poll_nitroa0()
2703 BNXT_DB_CQ_ARM(&cpr->cp_db, cpr->cp_raw_cons); in bnxt_poll_nitroa0()
2711 struct bnxt *bp = bnapi->bp; in bnxt_poll()
2712 struct bnxt_cp_ring_info *cpr = &bnapi->cp_ring; in bnxt_poll()
2715 if (unlikely(test_bit(BNXT_STATE_FW_FATAL_COND, &bp->state))) { in bnxt_poll()
2720 work_done += bnxt_poll_work(bp, cpr, budget - work_done); in bnxt_poll()
2724 BNXT_DB_CQ_ARM(&cpr->cp_db, cpr->cp_raw_cons); in bnxt_poll()
2730 BNXT_DB_CQ_ARM(&cpr->cp_db, cpr->cp_raw_cons); in bnxt_poll()
2734 if (bp->flags & BNXT_FLAG_DIM) { in bnxt_poll()
2737 dim_update_sample(cpr->event_ctr, in bnxt_poll()
2738 cpr->rx_packets, in bnxt_poll()
2739 cpr->rx_bytes, in bnxt_poll()
2741 net_dim(&cpr->dim, dim_sample); in bnxt_poll()
2748 struct bnxt_cp_ring_info *cpr = &bnapi->cp_ring; in __bnxt_poll_cqs()
2752 struct bnxt_cp_ring_info *cpr2 = cpr->cp_ring_arr[i]; in __bnxt_poll_cqs()
2756 budget - work_done); in __bnxt_poll_cqs()
2757 cpr->has_more_work |= cpr2->has_more_work; in __bnxt_poll_cqs()
2766 struct bnxt_cp_ring_info *cpr = &bnapi->cp_ring; in __bnxt_poll_cqs_done()
2770 struct bnxt_cp_ring_info *cpr2 = cpr->cp_ring_arr[i]; in __bnxt_poll_cqs_done()
2773 if (cpr2 && cpr2->had_work_done) { in __bnxt_poll_cqs_done()
2774 db = &cpr2->cp_db; in __bnxt_poll_cqs_done()
2775 bnxt_writeq(bp, db->db_key64 | dbr_type | in __bnxt_poll_cqs_done()
2776 RING_CMP(cpr2->cp_raw_cons), db->doorbell); in __bnxt_poll_cqs_done()
2777 cpr2->had_work_done = 0; in __bnxt_poll_cqs_done()
2786 struct bnxt_cp_ring_info *cpr = &bnapi->cp_ring; in bnxt_poll_p5()
2788 u32 raw_cons = cpr->cp_raw_cons; in bnxt_poll_p5()
2789 struct bnxt *bp = bnapi->bp; in bnxt_poll_p5()
2794 if (unlikely(test_bit(BNXT_STATE_FW_FATAL_COND, &bp->state))) { in bnxt_poll_p5()
2798 if (cpr->has_more_work) { in bnxt_poll_p5()
2799 cpr->has_more_work = 0; in bnxt_poll_p5()
2804 nqcmp = &cpr->nq_desc_ring[CP_RING(cons)][CP_IDX(cons)]; in bnxt_poll_p5()
2807 if (cpr->has_more_work) in bnxt_poll_p5()
2811 cpr->cp_raw_cons = raw_cons; in bnxt_poll_p5()
2813 BNXT_DB_NQ_ARM_P5(&cpr->cp_db, in bnxt_poll_p5()
2814 cpr->cp_raw_cons); in bnxt_poll_p5()
2823 if (nqcmp->type == cpu_to_le16(NQ_CN_TYPE_CQ_NOTIFICATION)) { in bnxt_poll_p5()
2824 u32 idx = le32_to_cpu(nqcmp->cq_handle_low); in bnxt_poll_p5()
2831 cpr2 = cpr->cp_ring_arr[idx]; in bnxt_poll_p5()
2833 budget - work_done); in bnxt_poll_p5()
2834 cpr->has_more_work |= cpr2->has_more_work; in bnxt_poll_p5()
2841 if (raw_cons != cpr->cp_raw_cons) { in bnxt_poll_p5()
2842 cpr->cp_raw_cons = raw_cons; in bnxt_poll_p5()
2843 BNXT_DB_NQ_P5(&cpr->cp_db, raw_cons); in bnxt_poll_p5()
2846 cpr_rx = cpr->cp_ring_arr[BNXT_RX_HDL]; in bnxt_poll_p5()
2847 if (cpr_rx && (bp->flags & BNXT_FLAG_DIM)) { in bnxt_poll_p5()
2850 dim_update_sample(cpr->event_ctr, in bnxt_poll_p5()
2851 cpr_rx->rx_packets, in bnxt_poll_p5()
2852 cpr_rx->rx_bytes, in bnxt_poll_p5()
2854 net_dim(&cpr->dim, dim_sample); in bnxt_poll_p5()
2862 struct pci_dev *pdev = bp->pdev; in bnxt_free_tx_skbs()
2864 if (!bp->tx_ring) in bnxt_free_tx_skbs()
2867 max_idx = bp->tx_nr_pages * TX_DESC_CNT; in bnxt_free_tx_skbs()
2868 for (i = 0; i < bp->tx_nr_rings; i++) { in bnxt_free_tx_skbs()
2869 struct bnxt_tx_ring_info *txr = &bp->tx_ring[i]; in bnxt_free_tx_skbs()
2872 if (!txr->tx_buf_ring) in bnxt_free_tx_skbs()
2876 struct bnxt_sw_tx_bd *tx_buf = &txr->tx_buf_ring[j]; in bnxt_free_tx_skbs()
2880 if (i < bp->tx_nr_rings_xdp && in bnxt_free_tx_skbs()
2881 tx_buf->action == XDP_REDIRECT) { in bnxt_free_tx_skbs()
2882 dma_unmap_single(&pdev->dev, in bnxt_free_tx_skbs()
2886 xdp_return_frame(tx_buf->xdpf); in bnxt_free_tx_skbs()
2887 tx_buf->action = 0; in bnxt_free_tx_skbs()
2888 tx_buf->xdpf = NULL; in bnxt_free_tx_skbs()
2893 skb = tx_buf->skb; in bnxt_free_tx_skbs()
2899 tx_buf->skb = NULL; in bnxt_free_tx_skbs()
2901 if (tx_buf->is_push) { in bnxt_free_tx_skbs()
2907 dma_unmap_single(&pdev->dev, in bnxt_free_tx_skbs()
2912 last = tx_buf->nr_frags; in bnxt_free_tx_skbs()
2915 int ring_idx = j & bp->tx_ring_mask; in bnxt_free_tx_skbs()
2916 skb_frag_t *frag = &skb_shinfo(skb)->frags[k]; in bnxt_free_tx_skbs()
2918 tx_buf = &txr->tx_buf_ring[ring_idx]; in bnxt_free_tx_skbs()
2920 &pdev->dev, in bnxt_free_tx_skbs()
2926 netdev_tx_reset_queue(netdev_get_tx_queue(bp->dev, i)); in bnxt_free_tx_skbs()
2932 struct bnxt_rx_ring_info *rxr = &bp->rx_ring[ring_nr]; in bnxt_free_one_rx_ring_skbs()
2933 struct pci_dev *pdev = bp->pdev; in bnxt_free_one_rx_ring_skbs()
2937 max_idx = bp->rx_nr_pages * RX_DESC_CNT; in bnxt_free_one_rx_ring_skbs()
2938 max_agg_idx = bp->rx_agg_nr_pages * RX_DESC_CNT; in bnxt_free_one_rx_ring_skbs()
2939 if (!rxr->rx_tpa) in bnxt_free_one_rx_ring_skbs()
2942 for (i = 0; i < bp->max_tpa; i++) { in bnxt_free_one_rx_ring_skbs()
2943 struct bnxt_tpa_info *tpa_info = &rxr->rx_tpa[i]; in bnxt_free_one_rx_ring_skbs()
2944 u8 *data = tpa_info->data; in bnxt_free_one_rx_ring_skbs()
2949 dma_unmap_single_attrs(&pdev->dev, tpa_info->mapping, in bnxt_free_one_rx_ring_skbs()
2950 bp->rx_buf_use_size, bp->rx_dir, in bnxt_free_one_rx_ring_skbs()
2953 tpa_info->data = NULL; in bnxt_free_one_rx_ring_skbs()
2959 if (!rxr->rx_buf_ring) in bnxt_free_one_rx_ring_skbs()
2963 struct bnxt_sw_rx_bd *rx_buf = &rxr->rx_buf_ring[i]; in bnxt_free_one_rx_ring_skbs()
2964 dma_addr_t mapping = rx_buf->mapping; in bnxt_free_one_rx_ring_skbs()
2965 void *data = rx_buf->data; in bnxt_free_one_rx_ring_skbs()
2970 rx_buf->data = NULL; in bnxt_free_one_rx_ring_skbs()
2972 mapping -= bp->rx_dma_offset; in bnxt_free_one_rx_ring_skbs()
2973 dma_unmap_page_attrs(&pdev->dev, mapping, PAGE_SIZE, in bnxt_free_one_rx_ring_skbs()
2974 bp->rx_dir, in bnxt_free_one_rx_ring_skbs()
2976 page_pool_recycle_direct(rxr->page_pool, data); in bnxt_free_one_rx_ring_skbs()
2978 dma_unmap_single_attrs(&pdev->dev, mapping, in bnxt_free_one_rx_ring_skbs()
2979 bp->rx_buf_use_size, bp->rx_dir, in bnxt_free_one_rx_ring_skbs()
2986 if (!rxr->rx_agg_ring) in bnxt_free_one_rx_ring_skbs()
2990 struct bnxt_sw_rx_agg_bd *rx_agg_buf = &rxr->rx_agg_ring[i]; in bnxt_free_one_rx_ring_skbs()
2991 struct page *page = rx_agg_buf->page; in bnxt_free_one_rx_ring_skbs()
2997 dma_unmap_page_attrs(&pdev->dev, rx_agg_buf->mapping, in bnxt_free_one_rx_ring_skbs()
2998 BNXT_RX_PAGE_SIZE, bp->rx_dir, in bnxt_free_one_rx_ring_skbs()
3000 rx_agg_buf->page = NULL; in bnxt_free_one_rx_ring_skbs()
3001 __clear_bit(i, rxr->rx_agg_bmap); in bnxt_free_one_rx_ring_skbs()
3003 page_pool_recycle_direct(rxr->page_pool, page); in bnxt_free_one_rx_ring_skbs()
3005 dma_unmap_page_attrs(&pdev->dev, rx_agg_buf->mapping, in bnxt_free_one_rx_ring_skbs()
3008 rx_agg_buf->page = NULL; in bnxt_free_one_rx_ring_skbs()
3009 __clear_bit(i, rxr->rx_agg_bmap); in bnxt_free_one_rx_ring_skbs()
3016 if (rxr->rx_page) { in bnxt_free_one_rx_ring_skbs()
3017 __free_page(rxr->rx_page); in bnxt_free_one_rx_ring_skbs()
3018 rxr->rx_page = NULL; in bnxt_free_one_rx_ring_skbs()
3020 map = rxr->rx_tpa_idx_map; in bnxt_free_one_rx_ring_skbs()
3022 memset(map->agg_idx_bmap, 0, sizeof(map->agg_idx_bmap)); in bnxt_free_one_rx_ring_skbs()
3029 if (!bp->rx_ring) in bnxt_free_rx_skbs()
3032 for (i = 0; i < bp->rx_nr_rings; i++) in bnxt_free_rx_skbs()
3044 u8 init_val = mem_init->init_val; in bnxt_init_ctx_mem()
3045 u16 offset = mem_init->offset; in bnxt_init_ctx_mem()
3055 for (i = 0; i < len; i += mem_init->size) in bnxt_init_ctx_mem()
3061 struct pci_dev *pdev = bp->pdev; in bnxt_free_ring()
3064 if (!rmem->pg_arr) in bnxt_free_ring()
3067 for (i = 0; i < rmem->nr_pages; i++) { in bnxt_free_ring()
3068 if (!rmem->pg_arr[i]) in bnxt_free_ring()
3071 dma_free_coherent(&pdev->dev, rmem->page_size, in bnxt_free_ring()
3072 rmem->pg_arr[i], rmem->dma_arr[i]); in bnxt_free_ring()
3074 rmem->pg_arr[i] = NULL; in bnxt_free_ring()
3077 if (rmem->pg_tbl) { in bnxt_free_ring()
3078 size_t pg_tbl_size = rmem->nr_pages * 8; in bnxt_free_ring()
3080 if (rmem->flags & BNXT_RMEM_USE_FULL_PAGE_FLAG) in bnxt_free_ring()
3081 pg_tbl_size = rmem->page_size; in bnxt_free_ring()
3082 dma_free_coherent(&pdev->dev, pg_tbl_size, in bnxt_free_ring()
3083 rmem->pg_tbl, rmem->pg_tbl_map); in bnxt_free_ring()
3084 rmem->pg_tbl = NULL; in bnxt_free_ring()
3086 if (rmem->vmem_size && *rmem->vmem) { in bnxt_free_ring()
3087 vfree(*rmem->vmem); in bnxt_free_ring()
3088 *rmem->vmem = NULL; in bnxt_free_ring()
3094 struct pci_dev *pdev = bp->pdev; in bnxt_alloc_ring()
3098 if (rmem->flags & (BNXT_RMEM_VALID_PTE_FLAG | BNXT_RMEM_RING_PTE_FLAG)) in bnxt_alloc_ring()
3100 if ((rmem->nr_pages > 1 || rmem->depth > 0) && !rmem->pg_tbl) { in bnxt_alloc_ring()
3101 size_t pg_tbl_size = rmem->nr_pages * 8; in bnxt_alloc_ring()
3103 if (rmem->flags & BNXT_RMEM_USE_FULL_PAGE_FLAG) in bnxt_alloc_ring()
3104 pg_tbl_size = rmem->page_size; in bnxt_alloc_ring()
3105 rmem->pg_tbl = dma_alloc_coherent(&pdev->dev, pg_tbl_size, in bnxt_alloc_ring()
3106 &rmem->pg_tbl_map, in bnxt_alloc_ring()
3108 if (!rmem->pg_tbl) in bnxt_alloc_ring()
3109 return -ENOMEM; in bnxt_alloc_ring()
3112 for (i = 0; i < rmem->nr_pages; i++) { in bnxt_alloc_ring()
3115 rmem->pg_arr[i] = dma_alloc_coherent(&pdev->dev, in bnxt_alloc_ring()
3116 rmem->page_size, in bnxt_alloc_ring()
3117 &rmem->dma_arr[i], in bnxt_alloc_ring()
3119 if (!rmem->pg_arr[i]) in bnxt_alloc_ring()
3120 return -ENOMEM; in bnxt_alloc_ring()
3122 if (rmem->mem_init) in bnxt_alloc_ring()
3123 bnxt_init_ctx_mem(rmem->mem_init, rmem->pg_arr[i], in bnxt_alloc_ring()
3124 rmem->page_size); in bnxt_alloc_ring()
3125 if (rmem->nr_pages > 1 || rmem->depth > 0) { in bnxt_alloc_ring()
3126 if (i == rmem->nr_pages - 2 && in bnxt_alloc_ring()
3127 (rmem->flags & BNXT_RMEM_RING_PTE_FLAG)) in bnxt_alloc_ring()
3129 else if (i == rmem->nr_pages - 1 && in bnxt_alloc_ring()
3130 (rmem->flags & BNXT_RMEM_RING_PTE_FLAG)) in bnxt_alloc_ring()
3132 rmem->pg_tbl[i] = in bnxt_alloc_ring()
3133 cpu_to_le64(rmem->dma_arr[i] | extra_bits); in bnxt_alloc_ring()
3137 if (rmem->vmem_size) { in bnxt_alloc_ring()
3138 *rmem->vmem = vzalloc(rmem->vmem_size); in bnxt_alloc_ring()
3139 if (!(*rmem->vmem)) in bnxt_alloc_ring()
3140 return -ENOMEM; in bnxt_alloc_ring()
3149 for (i = 0; i < bp->rx_nr_rings; i++) { in bnxt_free_tpa_info()
3150 struct bnxt_rx_ring_info *rxr = &bp->rx_ring[i]; in bnxt_free_tpa_info()
3152 kfree(rxr->rx_tpa_idx_map); in bnxt_free_tpa_info()
3153 rxr->rx_tpa_idx_map = NULL; in bnxt_free_tpa_info()
3154 if (rxr->rx_tpa) { in bnxt_free_tpa_info()
3155 kfree(rxr->rx_tpa[0].agg_arr); in bnxt_free_tpa_info()
3156 rxr->rx_tpa[0].agg_arr = NULL; in bnxt_free_tpa_info()
3158 kfree(rxr->rx_tpa); in bnxt_free_tpa_info()
3159 rxr->rx_tpa = NULL; in bnxt_free_tpa_info()
3167 bp->max_tpa = MAX_TPA; in bnxt_alloc_tpa_info()
3168 if (bp->flags & BNXT_FLAG_CHIP_P5) { in bnxt_alloc_tpa_info()
3169 if (!bp->max_tpa_v2) in bnxt_alloc_tpa_info()
3171 bp->max_tpa = max_t(u16, bp->max_tpa_v2, MAX_TPA_P5); in bnxt_alloc_tpa_info()
3172 total_aggs = bp->max_tpa * MAX_SKB_FRAGS; in bnxt_alloc_tpa_info()
3175 for (i = 0; i < bp->rx_nr_rings; i++) { in bnxt_alloc_tpa_info()
3176 struct bnxt_rx_ring_info *rxr = &bp->rx_ring[i]; in bnxt_alloc_tpa_info()
3179 rxr->rx_tpa = kcalloc(bp->max_tpa, sizeof(struct bnxt_tpa_info), in bnxt_alloc_tpa_info()
3181 if (!rxr->rx_tpa) in bnxt_alloc_tpa_info()
3182 return -ENOMEM; in bnxt_alloc_tpa_info()
3184 if (!(bp->flags & BNXT_FLAG_CHIP_P5)) in bnxt_alloc_tpa_info()
3187 rxr->rx_tpa[0].agg_arr = agg; in bnxt_alloc_tpa_info()
3189 return -ENOMEM; in bnxt_alloc_tpa_info()
3190 for (j = 1; j < bp->max_tpa; j++) in bnxt_alloc_tpa_info()
3191 rxr->rx_tpa[j].agg_arr = agg + j * MAX_SKB_FRAGS; in bnxt_alloc_tpa_info()
3192 rxr->rx_tpa_idx_map = kzalloc(sizeof(*rxr->rx_tpa_idx_map), in bnxt_alloc_tpa_info()
3194 if (!rxr->rx_tpa_idx_map) in bnxt_alloc_tpa_info()
3195 return -ENOMEM; in bnxt_alloc_tpa_info()
3204 if (!bp->rx_ring) in bnxt_free_rx_rings()
3208 for (i = 0; i < bp->rx_nr_rings; i++) { in bnxt_free_rx_rings()
3209 struct bnxt_rx_ring_info *rxr = &bp->rx_ring[i]; in bnxt_free_rx_rings()
3212 if (rxr->xdp_prog) in bnxt_free_rx_rings()
3213 bpf_prog_put(rxr->xdp_prog); in bnxt_free_rx_rings()
3215 if (xdp_rxq_info_is_reg(&rxr->xdp_rxq)) in bnxt_free_rx_rings()
3216 xdp_rxq_info_unreg(&rxr->xdp_rxq); in bnxt_free_rx_rings()
3218 page_pool_destroy(rxr->page_pool); in bnxt_free_rx_rings()
3219 rxr->page_pool = NULL; in bnxt_free_rx_rings()
3221 kfree(rxr->rx_agg_bmap); in bnxt_free_rx_rings()
3222 rxr->rx_agg_bmap = NULL; in bnxt_free_rx_rings()
3224 ring = &rxr->rx_ring_struct; in bnxt_free_rx_rings()
3225 bnxt_free_ring(bp, &ring->ring_mem); in bnxt_free_rx_rings()
3227 ring = &rxr->rx_agg_ring_struct; in bnxt_free_rx_rings()
3228 bnxt_free_ring(bp, &ring->ring_mem); in bnxt_free_rx_rings()
3237 pp.pool_size = bp->rx_ring_size; in bnxt_alloc_rx_page_pool()
3238 pp.nid = dev_to_node(&bp->pdev->dev); in bnxt_alloc_rx_page_pool()
3239 pp.dev = &bp->pdev->dev; in bnxt_alloc_rx_page_pool()
3242 rxr->page_pool = page_pool_create(&pp); in bnxt_alloc_rx_page_pool()
3243 if (IS_ERR(rxr->page_pool)) { in bnxt_alloc_rx_page_pool()
3244 int err = PTR_ERR(rxr->page_pool); in bnxt_alloc_rx_page_pool()
3246 rxr->page_pool = NULL; in bnxt_alloc_rx_page_pool()
3256 if (!bp->rx_ring) in bnxt_alloc_rx_rings()
3257 return -ENOMEM; in bnxt_alloc_rx_rings()
3259 if (bp->flags & BNXT_FLAG_AGG_RINGS) in bnxt_alloc_rx_rings()
3262 for (i = 0; i < bp->rx_nr_rings; i++) { in bnxt_alloc_rx_rings()
3263 struct bnxt_rx_ring_info *rxr = &bp->rx_ring[i]; in bnxt_alloc_rx_rings()
3266 ring = &rxr->rx_ring_struct; in bnxt_alloc_rx_rings()
3272 rc = xdp_rxq_info_reg(&rxr->xdp_rxq, bp->dev, i, 0); in bnxt_alloc_rx_rings()
3276 rc = xdp_rxq_info_reg_mem_model(&rxr->xdp_rxq, in bnxt_alloc_rx_rings()
3278 rxr->page_pool); in bnxt_alloc_rx_rings()
3280 xdp_rxq_info_unreg(&rxr->xdp_rxq); in bnxt_alloc_rx_rings()
3284 rc = bnxt_alloc_ring(bp, &ring->ring_mem); in bnxt_alloc_rx_rings()
3288 ring->grp_idx = i; in bnxt_alloc_rx_rings()
3292 ring = &rxr->rx_agg_ring_struct; in bnxt_alloc_rx_rings()
3293 rc = bnxt_alloc_ring(bp, &ring->ring_mem); in bnxt_alloc_rx_rings()
3297 ring->grp_idx = i; in bnxt_alloc_rx_rings()
3298 rxr->rx_agg_bmap_size = bp->rx_agg_ring_mask + 1; in bnxt_alloc_rx_rings()
3299 mem_size = rxr->rx_agg_bmap_size / 8; in bnxt_alloc_rx_rings()
3300 rxr->rx_agg_bmap = kzalloc(mem_size, GFP_KERNEL); in bnxt_alloc_rx_rings()
3301 if (!rxr->rx_agg_bmap) in bnxt_alloc_rx_rings()
3302 return -ENOMEM; in bnxt_alloc_rx_rings()
3305 if (bp->flags & BNXT_FLAG_TPA) in bnxt_alloc_rx_rings()
3313 struct pci_dev *pdev = bp->pdev; in bnxt_free_tx_rings()
3315 if (!bp->tx_ring) in bnxt_free_tx_rings()
3318 for (i = 0; i < bp->tx_nr_rings; i++) { in bnxt_free_tx_rings()
3319 struct bnxt_tx_ring_info *txr = &bp->tx_ring[i]; in bnxt_free_tx_rings()
3322 if (txr->tx_push) { in bnxt_free_tx_rings()
3323 dma_free_coherent(&pdev->dev, bp->tx_push_size, in bnxt_free_tx_rings()
3324 txr->tx_push, txr->tx_push_mapping); in bnxt_free_tx_rings()
3325 txr->tx_push = NULL; in bnxt_free_tx_rings()
3328 ring = &txr->tx_ring_struct; in bnxt_free_tx_rings()
3330 bnxt_free_ring(bp, &ring->ring_mem); in bnxt_free_tx_rings()
3337 struct pci_dev *pdev = bp->pdev; in bnxt_alloc_tx_rings()
3339 bp->tx_push_size = 0; in bnxt_alloc_tx_rings()
3340 if (bp->tx_push_thresh) { in bnxt_alloc_tx_rings()
3344 bp->tx_push_thresh); in bnxt_alloc_tx_rings()
3348 bp->tx_push_thresh = 0; in bnxt_alloc_tx_rings()
3351 bp->tx_push_size = push_size; in bnxt_alloc_tx_rings()
3354 for (i = 0, j = 0; i < bp->tx_nr_rings; i++) { in bnxt_alloc_tx_rings()
3355 struct bnxt_tx_ring_info *txr = &bp->tx_ring[i]; in bnxt_alloc_tx_rings()
3359 ring = &txr->tx_ring_struct; in bnxt_alloc_tx_rings()
3361 rc = bnxt_alloc_ring(bp, &ring->ring_mem); in bnxt_alloc_tx_rings()
3365 ring->grp_idx = txr->bnapi->index; in bnxt_alloc_tx_rings()
3366 if (bp->tx_push_size) { in bnxt_alloc_tx_rings()
3369 /* One pre-allocated DMA buffer to backup in bnxt_alloc_tx_rings()
3372 txr->tx_push = dma_alloc_coherent(&pdev->dev, in bnxt_alloc_tx_rings()
3373 bp->tx_push_size, in bnxt_alloc_tx_rings()
3374 &txr->tx_push_mapping, in bnxt_alloc_tx_rings()
3377 if (!txr->tx_push) in bnxt_alloc_tx_rings()
3378 return -ENOMEM; in bnxt_alloc_tx_rings()
3380 mapping = txr->tx_push_mapping + in bnxt_alloc_tx_rings()
3382 txr->data_mapping = cpu_to_le64(mapping); in bnxt_alloc_tx_rings()
3384 qidx = bp->tc_to_qidx[j]; in bnxt_alloc_tx_rings()
3385 ring->queue_id = bp->q_info[qidx].queue_id; in bnxt_alloc_tx_rings()
3386 spin_lock_init(&txr->xdp_tx_lock); in bnxt_alloc_tx_rings()
3387 if (i < bp->tx_nr_rings_xdp) in bnxt_alloc_tx_rings()
3389 if (i % bp->tx_nr_rings_per_tc == (bp->tx_nr_rings_per_tc - 1)) in bnxt_alloc_tx_rings()
3397 struct bnxt_ring_struct *ring = &cpr->cp_ring_struct; in bnxt_free_cp_arrays()
3399 kfree(cpr->cp_desc_ring); in bnxt_free_cp_arrays()
3400 cpr->cp_desc_ring = NULL; in bnxt_free_cp_arrays()
3401 ring->ring_mem.pg_arr = NULL; in bnxt_free_cp_arrays()
3402 kfree(cpr->cp_desc_mapping); in bnxt_free_cp_arrays()
3403 cpr->cp_desc_mapping = NULL; in bnxt_free_cp_arrays()
3404 ring->ring_mem.dma_arr = NULL; in bnxt_free_cp_arrays()
3409 cpr->cp_desc_ring = kcalloc(n, sizeof(*cpr->cp_desc_ring), GFP_KERNEL); in bnxt_alloc_cp_arrays()
3410 if (!cpr->cp_desc_ring) in bnxt_alloc_cp_arrays()
3411 return -ENOMEM; in bnxt_alloc_cp_arrays()
3412 cpr->cp_desc_mapping = kcalloc(n, sizeof(*cpr->cp_desc_mapping), in bnxt_alloc_cp_arrays()
3414 if (!cpr->cp_desc_mapping) in bnxt_alloc_cp_arrays()
3415 return -ENOMEM; in bnxt_alloc_cp_arrays()
3423 if (!bp->bnapi) in bnxt_free_all_cp_arrays()
3425 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_free_all_cp_arrays()
3426 struct bnxt_napi *bnapi = bp->bnapi[i]; in bnxt_free_all_cp_arrays()
3430 bnxt_free_cp_arrays(&bnapi->cp_ring); in bnxt_free_all_cp_arrays()
3436 int i, n = bp->cp_nr_pages; in bnxt_alloc_all_cp_arrays()
3438 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_alloc_all_cp_arrays()
3439 struct bnxt_napi *bnapi = bp->bnapi[i]; in bnxt_alloc_all_cp_arrays()
3444 rc = bnxt_alloc_cp_arrays(&bnapi->cp_ring, n); in bnxt_alloc_all_cp_arrays()
3455 if (!bp->bnapi) in bnxt_free_cp_rings()
3458 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_free_cp_rings()
3459 struct bnxt_napi *bnapi = bp->bnapi[i]; in bnxt_free_cp_rings()
3467 cpr = &bnapi->cp_ring; in bnxt_free_cp_rings()
3468 ring = &cpr->cp_ring_struct; in bnxt_free_cp_rings()
3470 bnxt_free_ring(bp, &ring->ring_mem); in bnxt_free_cp_rings()
3473 struct bnxt_cp_ring_info *cpr2 = cpr->cp_ring_arr[j]; in bnxt_free_cp_rings()
3476 ring = &cpr2->cp_ring_struct; in bnxt_free_cp_rings()
3477 bnxt_free_ring(bp, &ring->ring_mem); in bnxt_free_cp_rings()
3480 cpr->cp_ring_arr[j] = NULL; in bnxt_free_cp_rings()
3497 rc = bnxt_alloc_cp_arrays(cpr, bp->cp_nr_pages); in bnxt_alloc_cp_sub_ring()
3503 ring = &cpr->cp_ring_struct; in bnxt_alloc_cp_sub_ring()
3504 rmem = &ring->ring_mem; in bnxt_alloc_cp_sub_ring()
3505 rmem->nr_pages = bp->cp_nr_pages; in bnxt_alloc_cp_sub_ring()
3506 rmem->page_size = HW_CMPD_RING_SIZE; in bnxt_alloc_cp_sub_ring()
3507 rmem->pg_arr = (void **)cpr->cp_desc_ring; in bnxt_alloc_cp_sub_ring()
3508 rmem->dma_arr = cpr->cp_desc_mapping; in bnxt_alloc_cp_sub_ring()
3509 rmem->flags = BNXT_RMEM_RING_PTE_FLAG; in bnxt_alloc_cp_sub_ring()
3522 bool sh = !!(bp->flags & BNXT_FLAG_SHARED_RINGS); in bnxt_alloc_cp_rings()
3527 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_alloc_cp_rings()
3528 struct bnxt_napi *bnapi = bp->bnapi[i]; in bnxt_alloc_cp_rings()
3535 cpr = &bnapi->cp_ring; in bnxt_alloc_cp_rings()
3536 cpr->bnapi = bnapi; in bnxt_alloc_cp_rings()
3537 ring = &cpr->cp_ring_struct; in bnxt_alloc_cp_rings()
3539 rc = bnxt_alloc_ring(bp, &ring->ring_mem); in bnxt_alloc_cp_rings()
3544 ring->map_idx = i + ulp_msix; in bnxt_alloc_cp_rings()
3546 ring->map_idx = i; in bnxt_alloc_cp_rings()
3548 if (!(bp->flags & BNXT_FLAG_CHIP_P5)) in bnxt_alloc_cp_rings()
3551 if (i < bp->rx_nr_rings) { in bnxt_alloc_cp_rings()
3555 cpr->cp_ring_arr[BNXT_RX_HDL] = cpr2; in bnxt_alloc_cp_rings()
3557 return -ENOMEM; in bnxt_alloc_cp_rings()
3558 cpr2->bnapi = bnapi; in bnxt_alloc_cp_rings()
3560 if ((sh && i < bp->tx_nr_rings) || in bnxt_alloc_cp_rings()
3561 (!sh && i >= bp->rx_nr_rings)) { in bnxt_alloc_cp_rings()
3565 cpr->cp_ring_arr[BNXT_TX_HDL] = cpr2; in bnxt_alloc_cp_rings()
3567 return -ENOMEM; in bnxt_alloc_cp_rings()
3568 cpr2->bnapi = bnapi; in bnxt_alloc_cp_rings()
3578 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_init_ring_struct()
3579 struct bnxt_napi *bnapi = bp->bnapi[i]; in bnxt_init_ring_struct()
3589 cpr = &bnapi->cp_ring; in bnxt_init_ring_struct()
3590 ring = &cpr->cp_ring_struct; in bnxt_init_ring_struct()
3591 rmem = &ring->ring_mem; in bnxt_init_ring_struct()
3592 rmem->nr_pages = bp->cp_nr_pages; in bnxt_init_ring_struct()
3593 rmem->page_size = HW_CMPD_RING_SIZE; in bnxt_init_ring_struct()
3594 rmem->pg_arr = (void **)cpr->cp_desc_ring; in bnxt_init_ring_struct()
3595 rmem->dma_arr = cpr->cp_desc_mapping; in bnxt_init_ring_struct()
3596 rmem->vmem_size = 0; in bnxt_init_ring_struct()
3598 rxr = bnapi->rx_ring; in bnxt_init_ring_struct()
3602 ring = &rxr->rx_ring_struct; in bnxt_init_ring_struct()
3603 rmem = &ring->ring_mem; in bnxt_init_ring_struct()
3604 rmem->nr_pages = bp->rx_nr_pages; in bnxt_init_ring_struct()
3605 rmem->page_size = HW_RXBD_RING_SIZE; in bnxt_init_ring_struct()
3606 rmem->pg_arr = (void **)rxr->rx_desc_ring; in bnxt_init_ring_struct()
3607 rmem->dma_arr = rxr->rx_desc_mapping; in bnxt_init_ring_struct()
3608 rmem->vmem_size = SW_RXBD_RING_SIZE * bp->rx_nr_pages; in bnxt_init_ring_struct()
3609 rmem->vmem = (void **)&rxr->rx_buf_ring; in bnxt_init_ring_struct()
3611 ring = &rxr->rx_agg_ring_struct; in bnxt_init_ring_struct()
3612 rmem = &ring->ring_mem; in bnxt_init_ring_struct()
3613 rmem->nr_pages = bp->rx_agg_nr_pages; in bnxt_init_ring_struct()
3614 rmem->page_size = HW_RXBD_RING_SIZE; in bnxt_init_ring_struct()
3615 rmem->pg_arr = (void **)rxr->rx_agg_desc_ring; in bnxt_init_ring_struct()
3616 rmem->dma_arr = rxr->rx_agg_desc_mapping; in bnxt_init_ring_struct()
3617 rmem->vmem_size = SW_RXBD_AGG_RING_SIZE * bp->rx_agg_nr_pages; in bnxt_init_ring_struct()
3618 rmem->vmem = (void **)&rxr->rx_agg_ring; in bnxt_init_ring_struct()
3621 txr = bnapi->tx_ring; in bnxt_init_ring_struct()
3625 ring = &txr->tx_ring_struct; in bnxt_init_ring_struct()
3626 rmem = &ring->ring_mem; in bnxt_init_ring_struct()
3627 rmem->nr_pages = bp->tx_nr_pages; in bnxt_init_ring_struct()
3628 rmem->page_size = HW_RXBD_RING_SIZE; in bnxt_init_ring_struct()
3629 rmem->pg_arr = (void **)txr->tx_desc_ring; in bnxt_init_ring_struct()
3630 rmem->dma_arr = txr->tx_desc_mapping; in bnxt_init_ring_struct()
3631 rmem->vmem_size = SW_TXBD_RING_SIZE * bp->tx_nr_pages; in bnxt_init_ring_struct()
3632 rmem->vmem = (void **)&txr->tx_buf_ring; in bnxt_init_ring_struct()
3642 rx_buf_ring = (struct rx_bd **)ring->ring_mem.pg_arr; in bnxt_init_rxbd_pages()
3643 for (i = 0, prod = 0; i < ring->ring_mem.nr_pages; i++) { in bnxt_init_rxbd_pages()
3652 rxbd->rx_bd_len_flags_type = cpu_to_le32(type); in bnxt_init_rxbd_pages()
3653 rxbd->rx_bd_opaque = prod; in bnxt_init_rxbd_pages()
3660 struct bnxt_rx_ring_info *rxr = &bp->rx_ring[ring_nr]; in bnxt_alloc_one_rx_ring()
3661 struct net_device *dev = bp->dev; in bnxt_alloc_one_rx_ring()
3665 prod = rxr->rx_prod; in bnxt_alloc_one_rx_ring()
3666 for (i = 0; i < bp->rx_ring_size; i++) { in bnxt_alloc_one_rx_ring()
3669 ring_nr, i, bp->rx_ring_size); in bnxt_alloc_one_rx_ring()
3674 rxr->rx_prod = prod; in bnxt_alloc_one_rx_ring()
3676 if (!(bp->flags & BNXT_FLAG_AGG_RINGS)) in bnxt_alloc_one_rx_ring()
3679 prod = rxr->rx_agg_prod; in bnxt_alloc_one_rx_ring()
3680 for (i = 0; i < bp->rx_agg_ring_size; i++) { in bnxt_alloc_one_rx_ring()
3683 ring_nr, i, bp->rx_ring_size); in bnxt_alloc_one_rx_ring()
3688 rxr->rx_agg_prod = prod; in bnxt_alloc_one_rx_ring()
3690 if (rxr->rx_tpa) { in bnxt_alloc_one_rx_ring()
3694 for (i = 0; i < bp->max_tpa; i++) { in bnxt_alloc_one_rx_ring()
3697 return -ENOMEM; in bnxt_alloc_one_rx_ring()
3699 rxr->rx_tpa[i].data = data; in bnxt_alloc_one_rx_ring()
3700 rxr->rx_tpa[i].data_ptr = data + bp->rx_offset; in bnxt_alloc_one_rx_ring()
3701 rxr->rx_tpa[i].mapping = mapping; in bnxt_alloc_one_rx_ring()
3713 type = (bp->rx_buf_use_size << RX_BD_LEN_SHIFT) | in bnxt_init_one_rx_ring()
3719 rxr = &bp->rx_ring[ring_nr]; in bnxt_init_one_rx_ring()
3720 ring = &rxr->rx_ring_struct; in bnxt_init_one_rx_ring()
3723 if (BNXT_RX_PAGE_MODE(bp) && bp->xdp_prog) { in bnxt_init_one_rx_ring()
3724 bpf_prog_add(bp->xdp_prog, 1); in bnxt_init_one_rx_ring()
3725 rxr->xdp_prog = bp->xdp_prog; in bnxt_init_one_rx_ring()
3727 ring->fw_ring_id = INVALID_HW_RING_ID; in bnxt_init_one_rx_ring()
3729 ring = &rxr->rx_agg_ring_struct; in bnxt_init_one_rx_ring()
3730 ring->fw_ring_id = INVALID_HW_RING_ID; in bnxt_init_one_rx_ring()
3732 if ((bp->flags & BNXT_FLAG_AGG_RINGS)) { in bnxt_init_one_rx_ring()
3746 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_init_cp_rings()
3747 struct bnxt_cp_ring_info *cpr = &bp->bnapi[i]->cp_ring; in bnxt_init_cp_rings()
3748 struct bnxt_ring_struct *ring = &cpr->cp_ring_struct; in bnxt_init_cp_rings()
3750 ring->fw_ring_id = INVALID_HW_RING_ID; in bnxt_init_cp_rings()
3751 cpr->rx_ring_coal.coal_ticks = bp->rx_coal.coal_ticks; in bnxt_init_cp_rings()
3752 cpr->rx_ring_coal.coal_bufs = bp->rx_coal.coal_bufs; in bnxt_init_cp_rings()
3754 struct bnxt_cp_ring_info *cpr2 = cpr->cp_ring_arr[j]; in bnxt_init_cp_rings()
3759 ring = &cpr2->cp_ring_struct; in bnxt_init_cp_rings()
3760 ring->fw_ring_id = INVALID_HW_RING_ID; in bnxt_init_cp_rings()
3761 cpr2->rx_ring_coal.coal_ticks = bp->rx_coal.coal_ticks; in bnxt_init_cp_rings()
3762 cpr2->rx_ring_coal.coal_bufs = bp->rx_coal.coal_bufs; in bnxt_init_cp_rings()
3772 bp->rx_offset = NET_IP_ALIGN + XDP_PACKET_HEADROOM; in bnxt_init_rx_rings()
3773 bp->rx_dma_offset = XDP_PACKET_HEADROOM; in bnxt_init_rx_rings()
3775 bp->rx_offset = BNXT_RX_OFFSET; in bnxt_init_rx_rings()
3776 bp->rx_dma_offset = BNXT_RX_DMA_OFFSET; in bnxt_init_rx_rings()
3779 for (i = 0; i < bp->rx_nr_rings; i++) { in bnxt_init_rx_rings()
3792 bp->tx_wake_thresh = max_t(int, bp->tx_ring_size / 2, in bnxt_init_tx_rings()
3795 for (i = 0; i < bp->tx_nr_rings; i++) { in bnxt_init_tx_rings()
3796 struct bnxt_tx_ring_info *txr = &bp->tx_ring[i]; in bnxt_init_tx_rings()
3797 struct bnxt_ring_struct *ring = &txr->tx_ring_struct; in bnxt_init_tx_rings()
3799 ring->fw_ring_id = INVALID_HW_RING_ID; in bnxt_init_tx_rings()
3807 kfree(bp->grp_info); in bnxt_free_ring_grps()
3808 bp->grp_info = NULL; in bnxt_free_ring_grps()
3816 bp->grp_info = kcalloc(bp->cp_nr_rings, in bnxt_init_ring_grps()
3819 if (!bp->grp_info) in bnxt_init_ring_grps()
3820 return -ENOMEM; in bnxt_init_ring_grps()
3822 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_init_ring_grps()
3824 bp->grp_info[i].fw_stats_ctx = INVALID_HW_RING_ID; in bnxt_init_ring_grps()
3825 bp->grp_info[i].fw_grp_id = INVALID_HW_RING_ID; in bnxt_init_ring_grps()
3826 bp->grp_info[i].rx_fw_ring_id = INVALID_HW_RING_ID; in bnxt_init_ring_grps()
3827 bp->grp_info[i].agg_fw_ring_id = INVALID_HW_RING_ID; in bnxt_init_ring_grps()
3828 bp->grp_info[i].cp_fw_ring_id = INVALID_HW_RING_ID; in bnxt_init_ring_grps()
3835 kfree(bp->vnic_info); in bnxt_free_vnics()
3836 bp->vnic_info = NULL; in bnxt_free_vnics()
3837 bp->nr_vnics = 0; in bnxt_free_vnics()
3845 if ((bp->flags & (BNXT_FLAG_RFS | BNXT_FLAG_CHIP_P5)) == BNXT_FLAG_RFS) in bnxt_alloc_vnics()
3846 num_vnics += bp->rx_nr_rings; in bnxt_alloc_vnics()
3852 bp->vnic_info = kcalloc(num_vnics, sizeof(struct bnxt_vnic_info), in bnxt_alloc_vnics()
3854 if (!bp->vnic_info) in bnxt_alloc_vnics()
3855 return -ENOMEM; in bnxt_alloc_vnics()
3857 bp->nr_vnics = num_vnics; in bnxt_alloc_vnics()
3865 for (i = 0; i < bp->nr_vnics; i++) { in bnxt_init_vnics()
3866 struct bnxt_vnic_info *vnic = &bp->vnic_info[i]; in bnxt_init_vnics()
3869 vnic->fw_vnic_id = INVALID_HW_RING_ID; in bnxt_init_vnics()
3871 vnic->fw_rss_cos_lb_ctx[j] = INVALID_HW_RING_ID; in bnxt_init_vnics()
3873 vnic->fw_l2_ctx_id = INVALID_HW_RING_ID; in bnxt_init_vnics()
3875 if (bp->vnic_info[i].rss_hash_key) { in bnxt_init_vnics()
3877 get_random_bytes(vnic->rss_hash_key, in bnxt_init_vnics()
3880 memcpy(vnic->rss_hash_key, in bnxt_init_vnics()
3881 bp->vnic_info[0].rss_hash_key, in bnxt_init_vnics()
3898 while (pages & (pages - 1)) in bnxt_calc_nr_ring_pages()
3906 bp->flags &= ~BNXT_FLAG_TPA; in bnxt_set_tpa_flags()
3907 if (bp->flags & BNXT_FLAG_NO_AGG_RINGS) in bnxt_set_tpa_flags()
3909 if (bp->dev->features & NETIF_F_LRO) in bnxt_set_tpa_flags()
3910 bp->flags |= BNXT_FLAG_LRO; in bnxt_set_tpa_flags()
3911 else if (bp->dev->features & NETIF_F_GRO_HW) in bnxt_set_tpa_flags()
3912 bp->flags |= BNXT_FLAG_GRO; in bnxt_set_tpa_flags()
3915 /* bp->rx_ring_size, bp->tx_ring_size, dev->mtu, BNXT_FLAG_{G|L}RO flags must
3924 rx_size = SKB_DATA_ALIGN(bp->dev->mtu + ETH_HLEN + NET_IP_ALIGN + 8); in bnxt_set_ring_params()
3929 bp->rx_copy_thresh = BNXT_RX_COPY_THRESH; in bnxt_set_ring_params()
3930 ring_size = bp->rx_ring_size; in bnxt_set_ring_params()
3931 bp->rx_agg_ring_size = 0; in bnxt_set_ring_params()
3932 bp->rx_agg_nr_pages = 0; in bnxt_set_ring_params()
3934 if (bp->flags & BNXT_FLAG_TPA) in bnxt_set_ring_params()
3937 bp->flags &= ~BNXT_FLAG_JUMBO; in bnxt_set_ring_params()
3938 if (rx_space > PAGE_SIZE && !(bp->flags & BNXT_FLAG_NO_AGG_RINGS)) { in bnxt_set_ring_params()
3941 bp->flags |= BNXT_FLAG_JUMBO; in bnxt_set_ring_params()
3942 jumbo_factor = PAGE_ALIGN(bp->dev->mtu - 40) >> PAGE_SHIFT; in bnxt_set_ring_params()
3949 … 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()
3950 bp->rx_ring_size, ring_size); in bnxt_set_ring_params()
3951 bp->rx_ring_size = ring_size; in bnxt_set_ring_params()
3955 bp->rx_agg_nr_pages = bnxt_calc_nr_ring_pages(agg_ring_size, in bnxt_set_ring_params()
3957 if (bp->rx_agg_nr_pages > MAX_RX_AGG_PAGES) { in bnxt_set_ring_params()
3960 bp->rx_agg_nr_pages = MAX_RX_AGG_PAGES; in bnxt_set_ring_params()
3961 agg_ring_size = MAX_RX_AGG_PAGES * RX_DESC_CNT - 1; in bnxt_set_ring_params()
3962 netdev_warn(bp->dev, "rx agg ring size %d reduced to %d.\n", in bnxt_set_ring_params()
3965 bp->rx_agg_ring_size = agg_ring_size; in bnxt_set_ring_params()
3966 bp->rx_agg_ring_mask = (bp->rx_agg_nr_pages * RX_DESC_CNT) - 1; in bnxt_set_ring_params()
3978 bp->rx_buf_use_size = rx_size; in bnxt_set_ring_params()
3979 bp->rx_buf_size = rx_space; in bnxt_set_ring_params()
3981 bp->rx_nr_pages = bnxt_calc_nr_ring_pages(ring_size, RX_DESC_CNT); in bnxt_set_ring_params()
3982 bp->rx_ring_mask = (bp->rx_nr_pages * RX_DESC_CNT) - 1; in bnxt_set_ring_params()
3984 ring_size = bp->tx_ring_size; in bnxt_set_ring_params()
3985 bp->tx_nr_pages = bnxt_calc_nr_ring_pages(ring_size, TX_DESC_CNT); in bnxt_set_ring_params()
3986 bp->tx_ring_mask = (bp->tx_nr_pages * TX_DESC_CNT) - 1; in bnxt_set_ring_params()
3988 max_rx_cmpl = bp->rx_ring_size; in bnxt_set_ring_params()
3993 if (bp->flags & BNXT_FLAG_TPA) in bnxt_set_ring_params()
3994 max_rx_cmpl += bp->max_tpa; in bnxt_set_ring_params()
3995 /* RX and TPA completions are 32-byte, all others are 16-byte */ in bnxt_set_ring_params()
3996 ring_size = max_rx_cmpl * 2 + agg_ring_size + bp->tx_ring_size; in bnxt_set_ring_params()
3997 bp->cp_ring_size = ring_size; in bnxt_set_ring_params()
3999 bp->cp_nr_pages = bnxt_calc_nr_ring_pages(ring_size, CP_DESC_CNT); in bnxt_set_ring_params()
4000 if (bp->cp_nr_pages > MAX_CP_PAGES) { in bnxt_set_ring_params()
4001 bp->cp_nr_pages = MAX_CP_PAGES; in bnxt_set_ring_params()
4002 bp->cp_ring_size = MAX_CP_PAGES * CP_DESC_CNT - 1; in bnxt_set_ring_params()
4003 netdev_warn(bp->dev, "completion ring size %d reduced to %d.\n", in bnxt_set_ring_params()
4004 ring_size, bp->cp_ring_size); in bnxt_set_ring_params()
4006 bp->cp_bit = bp->cp_nr_pages * CP_DESC_CNT; in bnxt_set_ring_params()
4007 bp->cp_ring_mask = bp->cp_bit - 1; in bnxt_set_ring_params()
4016 bp->flags &= ~BNXT_FLAG_AGG_RINGS; in bnxt_set_rx_skb_mode()
4017 bp->flags |= BNXT_FLAG_RX_PAGE_MODE; in bnxt_set_rx_skb_mode()
4019 if (bp->dev->mtu > BNXT_MAX_PAGE_MODE_MTU) { in bnxt_set_rx_skb_mode()
4020 bp->flags |= BNXT_FLAG_JUMBO; in bnxt_set_rx_skb_mode()
4021 bp->rx_skb_func = bnxt_rx_multi_page_skb; in bnxt_set_rx_skb_mode()
4022 bp->dev->max_mtu = in bnxt_set_rx_skb_mode()
4023 min_t(u16, bp->max_mtu, BNXT_MAX_MTU); in bnxt_set_rx_skb_mode()
4025 bp->flags |= BNXT_FLAG_NO_AGG_RINGS; in bnxt_set_rx_skb_mode()
4026 bp->rx_skb_func = bnxt_rx_page_skb; in bnxt_set_rx_skb_mode()
4027 bp->dev->max_mtu = in bnxt_set_rx_skb_mode()
4028 min_t(u16, bp->max_mtu, BNXT_MAX_PAGE_MODE_MTU); in bnxt_set_rx_skb_mode()
4030 bp->rx_dir = DMA_BIDIRECTIONAL; in bnxt_set_rx_skb_mode()
4032 netdev_update_features(bp->dev); in bnxt_set_rx_skb_mode()
4034 bp->dev->max_mtu = bp->max_mtu; in bnxt_set_rx_skb_mode()
4035 bp->flags &= ~BNXT_FLAG_RX_PAGE_MODE; in bnxt_set_rx_skb_mode()
4036 bp->rx_dir = DMA_FROM_DEVICE; in bnxt_set_rx_skb_mode()
4037 bp->rx_skb_func = bnxt_rx_skb; in bnxt_set_rx_skb_mode()
4046 struct pci_dev *pdev = bp->pdev; in bnxt_free_vnic_attributes()
4048 if (!bp->vnic_info) in bnxt_free_vnic_attributes()
4051 for (i = 0; i < bp->nr_vnics; i++) { in bnxt_free_vnic_attributes()
4052 vnic = &bp->vnic_info[i]; in bnxt_free_vnic_attributes()
4054 kfree(vnic->fw_grp_ids); in bnxt_free_vnic_attributes()
4055 vnic->fw_grp_ids = NULL; in bnxt_free_vnic_attributes()
4057 kfree(vnic->uc_list); in bnxt_free_vnic_attributes()
4058 vnic->uc_list = NULL; in bnxt_free_vnic_attributes()
4060 if (vnic->mc_list) { in bnxt_free_vnic_attributes()
4061 dma_free_coherent(&pdev->dev, vnic->mc_list_size, in bnxt_free_vnic_attributes()
4062 vnic->mc_list, vnic->mc_list_mapping); in bnxt_free_vnic_attributes()
4063 vnic->mc_list = NULL; in bnxt_free_vnic_attributes()
4066 if (vnic->rss_table) { in bnxt_free_vnic_attributes()
4067 dma_free_coherent(&pdev->dev, vnic->rss_table_size, in bnxt_free_vnic_attributes()
4068 vnic->rss_table, in bnxt_free_vnic_attributes()
4069 vnic->rss_table_dma_addr); in bnxt_free_vnic_attributes()
4070 vnic->rss_table = NULL; in bnxt_free_vnic_attributes()
4073 vnic->rss_hash_key = NULL; in bnxt_free_vnic_attributes()
4074 vnic->flags = 0; in bnxt_free_vnic_attributes()
4082 struct pci_dev *pdev = bp->pdev; in bnxt_alloc_vnic_attributes()
4085 for (i = 0; i < bp->nr_vnics; i++) { in bnxt_alloc_vnic_attributes()
4086 vnic = &bp->vnic_info[i]; in bnxt_alloc_vnic_attributes()
4088 if (vnic->flags & BNXT_VNIC_UCAST_FLAG) { in bnxt_alloc_vnic_attributes()
4089 int mem_size = (BNXT_MAX_UC_ADDRS - 1) * ETH_ALEN; in bnxt_alloc_vnic_attributes()
4092 vnic->uc_list = kmalloc(mem_size, GFP_KERNEL); in bnxt_alloc_vnic_attributes()
4093 if (!vnic->uc_list) { in bnxt_alloc_vnic_attributes()
4094 rc = -ENOMEM; in bnxt_alloc_vnic_attributes()
4100 if (vnic->flags & BNXT_VNIC_MCAST_FLAG) { in bnxt_alloc_vnic_attributes()
4101 vnic->mc_list_size = BNXT_MAX_MC_ADDRS * ETH_ALEN; in bnxt_alloc_vnic_attributes()
4102 vnic->mc_list = in bnxt_alloc_vnic_attributes()
4103 dma_alloc_coherent(&pdev->dev, in bnxt_alloc_vnic_attributes()
4104 vnic->mc_list_size, in bnxt_alloc_vnic_attributes()
4105 &vnic->mc_list_mapping, in bnxt_alloc_vnic_attributes()
4107 if (!vnic->mc_list) { in bnxt_alloc_vnic_attributes()
4108 rc = -ENOMEM; in bnxt_alloc_vnic_attributes()
4113 if (bp->flags & BNXT_FLAG_CHIP_P5) in bnxt_alloc_vnic_attributes()
4116 if (vnic->flags & BNXT_VNIC_RSS_FLAG) in bnxt_alloc_vnic_attributes()
4117 max_rings = bp->rx_nr_rings; in bnxt_alloc_vnic_attributes()
4121 vnic->fw_grp_ids = kcalloc(max_rings, sizeof(u16), GFP_KERNEL); in bnxt_alloc_vnic_attributes()
4122 if (!vnic->fw_grp_ids) { in bnxt_alloc_vnic_attributes()
4123 rc = -ENOMEM; in bnxt_alloc_vnic_attributes()
4127 if ((bp->flags & BNXT_FLAG_NEW_RSS_CAP) && in bnxt_alloc_vnic_attributes()
4128 !(vnic->flags & BNXT_VNIC_RSS_FLAG)) in bnxt_alloc_vnic_attributes()
4133 if (bp->flags & BNXT_FLAG_CHIP_P5) in bnxt_alloc_vnic_attributes()
4136 vnic->rss_table_size = size + HW_HASH_KEY_SIZE; in bnxt_alloc_vnic_attributes()
4137 vnic->rss_table = dma_alloc_coherent(&pdev->dev, in bnxt_alloc_vnic_attributes()
4138 vnic->rss_table_size, in bnxt_alloc_vnic_attributes()
4139 &vnic->rss_table_dma_addr, in bnxt_alloc_vnic_attributes()
4141 if (!vnic->rss_table) { in bnxt_alloc_vnic_attributes()
4142 rc = -ENOMEM; in bnxt_alloc_vnic_attributes()
4146 vnic->rss_hash_key = ((void *)vnic->rss_table) + size; in bnxt_alloc_vnic_attributes()
4147 vnic->rss_hash_key_dma_addr = vnic->rss_table_dma_addr + size; in bnxt_alloc_vnic_attributes()
4159 dma_pool_destroy(bp->hwrm_dma_pool); in bnxt_free_hwrm_resources()
4160 bp->hwrm_dma_pool = NULL; in bnxt_free_hwrm_resources()
4163 hlist_for_each_entry_rcu(token, &bp->hwrm_pending_list, node) in bnxt_free_hwrm_resources()
4164 WRITE_ONCE(token->state, BNXT_HWRM_CANCELLED); in bnxt_free_hwrm_resources()
4170 bp->hwrm_dma_pool = dma_pool_create("bnxt_hwrm", &bp->pdev->dev, in bnxt_alloc_hwrm_resources()
4173 if (!bp->hwrm_dma_pool) in bnxt_alloc_hwrm_resources()
4174 return -ENOMEM; in bnxt_alloc_hwrm_resources()
4176 INIT_HLIST_HEAD(&bp->hwrm_pending_list); in bnxt_alloc_hwrm_resources()
4183 kfree(stats->hw_masks); in bnxt_free_stats_mem()
4184 stats->hw_masks = NULL; in bnxt_free_stats_mem()
4185 kfree(stats->sw_stats); in bnxt_free_stats_mem()
4186 stats->sw_stats = NULL; in bnxt_free_stats_mem()
4187 if (stats->hw_stats) { in bnxt_free_stats_mem()
4188 dma_free_coherent(&bp->pdev->dev, stats->len, stats->hw_stats, in bnxt_free_stats_mem()
4189 stats->hw_stats_map); in bnxt_free_stats_mem()
4190 stats->hw_stats = NULL; in bnxt_free_stats_mem()
4197 stats->hw_stats = dma_alloc_coherent(&bp->pdev->dev, stats->len, in bnxt_alloc_stats_mem()
4198 &stats->hw_stats_map, GFP_KERNEL); in bnxt_alloc_stats_mem()
4199 if (!stats->hw_stats) in bnxt_alloc_stats_mem()
4200 return -ENOMEM; in bnxt_alloc_stats_mem()
4202 stats->sw_stats = kzalloc(stats->len, GFP_KERNEL); in bnxt_alloc_stats_mem()
4203 if (!stats->sw_stats) in bnxt_alloc_stats_mem()
4207 stats->hw_masks = kzalloc(stats->len, GFP_KERNEL); in bnxt_alloc_stats_mem()
4208 if (!stats->hw_masks) in bnxt_alloc_stats_mem()
4215 return -ENOMEM; in bnxt_alloc_stats_mem()
4242 if (!(bp->fw_cap & BNXT_FW_CAP_EXT_HW_STATS_SUPPORTED) || in bnxt_hwrm_func_qstat_ext()
4243 !(bp->flags & BNXT_FLAG_CHIP_P5)) in bnxt_hwrm_func_qstat_ext()
4244 return -EOPNOTSUPP; in bnxt_hwrm_func_qstat_ext()
4250 req->fid = cpu_to_le16(0xffff); in bnxt_hwrm_func_qstat_ext()
4251 req->flags = FUNC_QSTATS_EXT_REQ_FLAGS_COUNTER_MASK; in bnxt_hwrm_func_qstat_ext()
4256 hw_masks = &resp->rx_ucast_pkts; in bnxt_hwrm_func_qstat_ext()
4257 bnxt_copy_hw_masks(stats->hw_masks, hw_masks, stats->len / 8); in bnxt_hwrm_func_qstat_ext()
4268 struct bnxt_napi *bnapi = bp->bnapi[0]; in bnxt_init_stats()
4277 cpr = &bnapi->cp_ring; in bnxt_init_stats()
4278 stats = &cpr->stats; in bnxt_init_stats()
4281 if (bp->flags & BNXT_FLAG_CHIP_P5) in bnxt_init_stats()
4282 mask = (1ULL << 48) - 1; in bnxt_init_stats()
4284 mask = -1ULL; in bnxt_init_stats()
4285 bnxt_fill_masks(stats->hw_masks, mask, stats->len / 8); in bnxt_init_stats()
4287 if (bp->flags & BNXT_FLAG_PORT_STATS) { in bnxt_init_stats()
4288 stats = &bp->port_stats; in bnxt_init_stats()
4289 rx_stats = stats->hw_stats; in bnxt_init_stats()
4290 rx_masks = stats->hw_masks; in bnxt_init_stats()
4299 mask = (1ULL << 40) - 1; in bnxt_init_stats()
4309 if (bp->flags & BNXT_FLAG_PORT_STATS_EXT) { in bnxt_init_stats()
4310 stats = &bp->rx_port_stats_ext; in bnxt_init_stats()
4311 rx_stats = stats->hw_stats; in bnxt_init_stats()
4312 rx_masks = stats->hw_masks; in bnxt_init_stats()
4314 stats = &bp->tx_port_stats_ext; in bnxt_init_stats()
4315 tx_stats = stats->hw_stats; in bnxt_init_stats()
4316 tx_masks = stats->hw_masks; in bnxt_init_stats()
4322 mask = (1ULL << 40) - 1; in bnxt_init_stats()
4339 bp->flags &= ~BNXT_FLAG_PORT_STATS; in bnxt_free_port_stats()
4340 bp->flags &= ~BNXT_FLAG_PORT_STATS_EXT; in bnxt_free_port_stats()
4342 bnxt_free_stats_mem(bp, &bp->port_stats); in bnxt_free_port_stats()
4343 bnxt_free_stats_mem(bp, &bp->rx_port_stats_ext); in bnxt_free_port_stats()
4344 bnxt_free_stats_mem(bp, &bp->tx_port_stats_ext); in bnxt_free_port_stats()
4351 if (!bp->bnapi) in bnxt_free_ring_stats()
4354 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_free_ring_stats()
4355 struct bnxt_napi *bnapi = bp->bnapi[i]; in bnxt_free_ring_stats()
4356 struct bnxt_cp_ring_info *cpr = &bnapi->cp_ring; in bnxt_free_ring_stats()
4358 bnxt_free_stats_mem(bp, &cpr->stats); in bnxt_free_ring_stats()
4367 size = bp->hw_ring_stats_size; in bnxt_alloc_stats()
4369 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_alloc_stats()
4370 struct bnxt_napi *bnapi = bp->bnapi[i]; in bnxt_alloc_stats()
4371 struct bnxt_cp_ring_info *cpr = &bnapi->cp_ring; in bnxt_alloc_stats()
4373 cpr->stats.len = size; in bnxt_alloc_stats()
4374 rc = bnxt_alloc_stats_mem(bp, &cpr->stats, !i); in bnxt_alloc_stats()
4378 cpr->hw_stats_ctx_id = INVALID_STATS_CTX_ID; in bnxt_alloc_stats()
4381 if (BNXT_VF(bp) || bp->chip_num == CHIP_NUM_58700) in bnxt_alloc_stats()
4384 if (bp->port_stats.hw_stats) in bnxt_alloc_stats()
4387 bp->port_stats.len = BNXT_PORT_STATS_SIZE; in bnxt_alloc_stats()
4388 rc = bnxt_alloc_stats_mem(bp, &bp->port_stats, true); in bnxt_alloc_stats()
4392 bp->flags |= BNXT_FLAG_PORT_STATS; in bnxt_alloc_stats()
4396 if (bp->hwrm_spec_code < 0x10804 || bp->hwrm_spec_code == 0x10900) in bnxt_alloc_stats()
4397 if (!(bp->fw_cap & BNXT_FW_CAP_EXT_STATS_SUPPORTED)) in bnxt_alloc_stats()
4400 if (bp->rx_port_stats_ext.hw_stats) in bnxt_alloc_stats()
4403 bp->rx_port_stats_ext.len = sizeof(struct rx_port_stats_ext); in bnxt_alloc_stats()
4404 rc = bnxt_alloc_stats_mem(bp, &bp->rx_port_stats_ext, true); in bnxt_alloc_stats()
4410 if (bp->tx_port_stats_ext.hw_stats) in bnxt_alloc_stats()
4413 if (bp->hwrm_spec_code >= 0x10902 || in bnxt_alloc_stats()
4414 (bp->fw_cap & BNXT_FW_CAP_EXT_STATS_SUPPORTED)) { in bnxt_alloc_stats()
4415 bp->tx_port_stats_ext.len = sizeof(struct tx_port_stats_ext); in bnxt_alloc_stats()
4416 rc = bnxt_alloc_stats_mem(bp, &bp->tx_port_stats_ext, true); in bnxt_alloc_stats()
4421 bp->flags |= BNXT_FLAG_PORT_STATS_EXT; in bnxt_alloc_stats()
4429 if (!bp->bnapi) in bnxt_clear_ring_indices()
4432 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_clear_ring_indices()
4433 struct bnxt_napi *bnapi = bp->bnapi[i]; in bnxt_clear_ring_indices()
4441 cpr = &bnapi->cp_ring; in bnxt_clear_ring_indices()
4442 cpr->cp_raw_cons = 0; in bnxt_clear_ring_indices()
4444 txr = bnapi->tx_ring; in bnxt_clear_ring_indices()
4446 txr->tx_prod = 0; in bnxt_clear_ring_indices()
4447 txr->tx_cons = 0; in bnxt_clear_ring_indices()
4450 rxr = bnapi->rx_ring; in bnxt_clear_ring_indices()
4452 rxr->rx_prod = 0; in bnxt_clear_ring_indices()
4453 rxr->rx_agg_prod = 0; in bnxt_clear_ring_indices()
4454 rxr->rx_sw_agg_prod = 0; in bnxt_clear_ring_indices()
4455 rxr->rx_next_cons = 0; in bnxt_clear_ring_indices()
4473 head = &bp->ntp_fltr_hash_tbl[i]; in bnxt_free_ntp_fltrs()
4475 hlist_del(&fltr->hash); in bnxt_free_ntp_fltrs()
4480 bitmap_free(bp->ntp_fltr_bmap); in bnxt_free_ntp_fltrs()
4481 bp->ntp_fltr_bmap = NULL; in bnxt_free_ntp_fltrs()
4483 bp->ntp_fltr_count = 0; in bnxt_free_ntp_fltrs()
4492 if (!(bp->flags & BNXT_FLAG_RFS)) in bnxt_alloc_ntp_fltrs()
4496 INIT_HLIST_HEAD(&bp->ntp_fltr_hash_tbl[i]); in bnxt_alloc_ntp_fltrs()
4498 bp->ntp_fltr_count = 0; in bnxt_alloc_ntp_fltrs()
4499 bp->ntp_fltr_bmap = bitmap_zalloc(BNXT_NTP_FLTR_MAX_FLTR, GFP_KERNEL); in bnxt_alloc_ntp_fltrs()
4501 if (!bp->ntp_fltr_bmap) in bnxt_alloc_ntp_fltrs()
4502 rc = -ENOMEM; in bnxt_alloc_ntp_fltrs()
4520 if (!(bp->phy_flags & BNXT_PHY_FL_PORT_STATS_NO_RESET) || in bnxt_free_mem()
4521 test_bit(BNXT_STATE_IN_FW_RESET, &bp->state)) in bnxt_free_mem()
4525 kfree(bp->tx_ring_map); in bnxt_free_mem()
4526 bp->tx_ring_map = NULL; in bnxt_free_mem()
4527 kfree(bp->tx_ring); in bnxt_free_mem()
4528 bp->tx_ring = NULL; in bnxt_free_mem()
4529 kfree(bp->rx_ring); in bnxt_free_mem()
4530 bp->rx_ring = NULL; in bnxt_free_mem()
4531 kfree(bp->bnapi); in bnxt_free_mem()
4532 bp->bnapi = NULL; in bnxt_free_mem()
4548 bp->cp_nr_rings); in bnxt_alloc_mem()
4550 bnapi = kzalloc(arr_size + size * bp->cp_nr_rings, GFP_KERNEL); in bnxt_alloc_mem()
4552 return -ENOMEM; in bnxt_alloc_mem()
4554 bp->bnapi = bnapi; in bnxt_alloc_mem()
4556 for (i = 0; i < bp->cp_nr_rings; i++, bnapi += size) { in bnxt_alloc_mem()
4557 bp->bnapi[i] = bnapi; in bnxt_alloc_mem()
4558 bp->bnapi[i]->index = i; in bnxt_alloc_mem()
4559 bp->bnapi[i]->bp = bp; in bnxt_alloc_mem()
4560 if (bp->flags & BNXT_FLAG_CHIP_P5) { in bnxt_alloc_mem()
4562 &bp->bnapi[i]->cp_ring; in bnxt_alloc_mem()
4564 cpr->cp_ring_struct.ring_mem.flags = in bnxt_alloc_mem()
4569 bp->rx_ring = kcalloc(bp->rx_nr_rings, in bnxt_alloc_mem()
4572 if (!bp->rx_ring) in bnxt_alloc_mem()
4573 return -ENOMEM; in bnxt_alloc_mem()
4575 for (i = 0; i < bp->rx_nr_rings; i++) { in bnxt_alloc_mem()
4576 struct bnxt_rx_ring_info *rxr = &bp->rx_ring[i]; in bnxt_alloc_mem()
4578 if (bp->flags & BNXT_FLAG_CHIP_P5) { in bnxt_alloc_mem()
4579 rxr->rx_ring_struct.ring_mem.flags = in bnxt_alloc_mem()
4581 rxr->rx_agg_ring_struct.ring_mem.flags = in bnxt_alloc_mem()
4584 rxr->bnapi = bp->bnapi[i]; in bnxt_alloc_mem()
4585 bp->bnapi[i]->rx_ring = &bp->rx_ring[i]; in bnxt_alloc_mem()
4588 bp->tx_ring = kcalloc(bp->tx_nr_rings, in bnxt_alloc_mem()
4591 if (!bp->tx_ring) in bnxt_alloc_mem()
4592 return -ENOMEM; in bnxt_alloc_mem()
4594 bp->tx_ring_map = kcalloc(bp->tx_nr_rings, sizeof(u16), in bnxt_alloc_mem()
4597 if (!bp->tx_ring_map) in bnxt_alloc_mem()
4598 return -ENOMEM; in bnxt_alloc_mem()
4600 if (bp->flags & BNXT_FLAG_SHARED_RINGS) in bnxt_alloc_mem()
4603 j = bp->rx_nr_rings; in bnxt_alloc_mem()
4605 for (i = 0; i < bp->tx_nr_rings; i++, j++) { in bnxt_alloc_mem()
4606 struct bnxt_tx_ring_info *txr = &bp->tx_ring[i]; in bnxt_alloc_mem()
4608 if (bp->flags & BNXT_FLAG_CHIP_P5) in bnxt_alloc_mem()
4609 txr->tx_ring_struct.ring_mem.flags = in bnxt_alloc_mem()
4611 txr->bnapi = bp->bnapi[j]; in bnxt_alloc_mem()
4612 bp->bnapi[j]->tx_ring = txr; in bnxt_alloc_mem()
4613 bp->tx_ring_map[i] = bp->tx_nr_rings_xdp + i; in bnxt_alloc_mem()
4614 if (i >= bp->tx_nr_rings_xdp) { in bnxt_alloc_mem()
4615 txr->txq_index = i - bp->tx_nr_rings_xdp; in bnxt_alloc_mem()
4616 bp->bnapi[j]->tx_int = bnxt_tx_int; in bnxt_alloc_mem()
4618 bp->bnapi[j]->flags |= BNXT_NAPI_FLAG_XDP; in bnxt_alloc_mem()
4619 bp->bnapi[j]->tx_int = bnxt_tx_int_xdp; in bnxt_alloc_mem()
4655 bp->vnic_info[0].flags |= BNXT_VNIC_RSS_FLAG | BNXT_VNIC_MCAST_FLAG | in bnxt_alloc_mem()
4671 if (!bp->bnapi) in bnxt_disable_int()
4674 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_disable_int()
4675 struct bnxt_napi *bnapi = bp->bnapi[i]; in bnxt_disable_int()
4676 struct bnxt_cp_ring_info *cpr = &bnapi->cp_ring; in bnxt_disable_int()
4677 struct bnxt_ring_struct *ring = &cpr->cp_ring_struct; in bnxt_disable_int()
4679 if (ring->fw_ring_id != INVALID_HW_RING_ID) in bnxt_disable_int()
4680 bnxt_db_nq(bp, &cpr->cp_db, cpr->cp_raw_cons); in bnxt_disable_int()
4686 struct bnxt_napi *bnapi = bp->bnapi[n]; in bnxt_cp_num_to_irq_num()
4689 cpr = &bnapi->cp_ring; in bnxt_cp_num_to_irq_num()
4690 return cpr->cp_ring_struct.map_idx; in bnxt_cp_num_to_irq_num()
4697 if (!bp->irq_tbl) in bnxt_disable_int_sync()
4700 atomic_inc(&bp->intr_sem); in bnxt_disable_int_sync()
4703 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_disable_int_sync()
4706 synchronize_irq(bp->irq_tbl[map_idx].vector); in bnxt_disable_int_sync()
4714 atomic_set(&bp->intr_sem, 0); in bnxt_enable_int()
4715 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_enable_int()
4716 struct bnxt_napi *bnapi = bp->bnapi[i]; in bnxt_enable_int()
4717 struct bnxt_cp_ring_info *cpr = &bnapi->cp_ring; in bnxt_enable_int()
4719 bnxt_db_nq_arm(bp, &cpr->cp_db, cpr->cp_raw_cons); in bnxt_enable_int()
4737 req->enables = cpu_to_le32(FUNC_DRV_RGTR_REQ_ENABLES_OS_TYPE | in bnxt_hwrm_func_drv_rgtr()
4741 req->os_type = cpu_to_le16(FUNC_DRV_RGTR_REQ_OS_TYPE_LINUX); in bnxt_hwrm_func_drv_rgtr()
4743 if (bp->fw_cap & BNXT_FW_CAP_HOT_RESET) in bnxt_hwrm_func_drv_rgtr()
4745 if (bp->fw_cap & BNXT_FW_CAP_ERROR_RECOVERY) in bnxt_hwrm_func_drv_rgtr()
4748 req->flags = cpu_to_le32(flags); in bnxt_hwrm_func_drv_rgtr()
4749 req->ver_maj_8b = DRV_VER_MAJ; in bnxt_hwrm_func_drv_rgtr()
4750 req->ver_min_8b = DRV_VER_MIN; in bnxt_hwrm_func_drv_rgtr()
4751 req->ver_upd_8b = DRV_VER_UPD; in bnxt_hwrm_func_drv_rgtr()
4752 req->ver_maj = cpu_to_le16(DRV_VER_MAJ); in bnxt_hwrm_func_drv_rgtr()
4753 req->ver_min = cpu_to_le16(DRV_VER_MIN); in bnxt_hwrm_func_drv_rgtr()
4754 req->ver_upd = cpu_to_le16(DRV_VER_UPD); in bnxt_hwrm_func_drv_rgtr()
4771 req->vf_req_fwd[i] = cpu_to_le32(data[i]); in bnxt_hwrm_func_drv_rgtr()
4773 req->enables |= in bnxt_hwrm_func_drv_rgtr()
4777 if (bp->fw_cap & BNXT_FW_CAP_OVS_64BIT_HANDLE) in bnxt_hwrm_func_drv_rgtr()
4778 req->flags |= cpu_to_le32( in bnxt_hwrm_func_drv_rgtr()
4786 !(bp->fw_cap & BNXT_FW_CAP_ERROR_RECOVERY)) in bnxt_hwrm_func_drv_rgtr()
4797 req->async_event_fwd[i] |= cpu_to_le32(events[i]); in bnxt_hwrm_func_drv_rgtr()
4800 req->enables = in bnxt_hwrm_func_drv_rgtr()
4806 set_bit(BNXT_STATE_DRV_REGISTERED, &bp->state); in bnxt_hwrm_func_drv_rgtr()
4807 if (resp->flags & in bnxt_hwrm_func_drv_rgtr()
4809 bp->fw_cap |= BNXT_FW_CAP_IF_CHANGE; in bnxt_hwrm_func_drv_rgtr()
4820 if (!test_and_clear_bit(BNXT_STATE_DRV_REGISTERED, &bp->state)) in bnxt_hwrm_func_drv_unrgtr()
4835 bp->vxlan_fw_dst_port_id == INVALID_HW_RING_ID) in bnxt_hwrm_tunnel_dst_port_free()
4838 bp->nge_fw_dst_port_id == INVALID_HW_RING_ID) in bnxt_hwrm_tunnel_dst_port_free()
4845 req->tunnel_type = tunnel_type; in bnxt_hwrm_tunnel_dst_port_free()
4849 req->tunnel_dst_port_id = cpu_to_le16(bp->vxlan_fw_dst_port_id); in bnxt_hwrm_tunnel_dst_port_free()
4850 bp->vxlan_port = 0; in bnxt_hwrm_tunnel_dst_port_free()
4851 bp->vxlan_fw_dst_port_id = INVALID_HW_RING_ID; in bnxt_hwrm_tunnel_dst_port_free()
4854 req->tunnel_dst_port_id = cpu_to_le16(bp->nge_fw_dst_port_id); in bnxt_hwrm_tunnel_dst_port_free()
4855 bp->nge_port = 0; in bnxt_hwrm_tunnel_dst_port_free()
4856 bp->nge_fw_dst_port_id = INVALID_HW_RING_ID; in bnxt_hwrm_tunnel_dst_port_free()
4864 netdev_err(bp->dev, "hwrm_tunnel_dst_port_free failed. rc:%d\n", in bnxt_hwrm_tunnel_dst_port_free()
4880 req->tunnel_type = tunnel_type; in bnxt_hwrm_tunnel_dst_port_alloc()
4881 req->tunnel_dst_port_val = port; in bnxt_hwrm_tunnel_dst_port_alloc()
4886 netdev_err(bp->dev, "hwrm_tunnel_dst_port_alloc failed. rc:%d\n", in bnxt_hwrm_tunnel_dst_port_alloc()
4893 bp->vxlan_port = port; in bnxt_hwrm_tunnel_dst_port_alloc()
4894 bp->vxlan_fw_dst_port_id = in bnxt_hwrm_tunnel_dst_port_alloc()
4895 le16_to_cpu(resp->tunnel_dst_port_id); in bnxt_hwrm_tunnel_dst_port_alloc()
4898 bp->nge_port = port; in bnxt_hwrm_tunnel_dst_port_alloc()
4899 bp->nge_fw_dst_port_id = le16_to_cpu(resp->tunnel_dst_port_id); in bnxt_hwrm_tunnel_dst_port_alloc()
4913 struct bnxt_vnic_info *vnic = &bp->vnic_info[vnic_id]; in bnxt_hwrm_cfa_l2_set_rx_mask()
4920 req->vnic_id = cpu_to_le32(vnic->fw_vnic_id); in bnxt_hwrm_cfa_l2_set_rx_mask()
4921 if (vnic->rx_mask & CFA_L2_SET_RX_MASK_REQ_MASK_MCAST) { in bnxt_hwrm_cfa_l2_set_rx_mask()
4922 req->num_mc_entries = cpu_to_le32(vnic->mc_list_count); in bnxt_hwrm_cfa_l2_set_rx_mask()
4923 req->mc_tbl_addr = cpu_to_le64(vnic->mc_list_mapping); in bnxt_hwrm_cfa_l2_set_rx_mask()
4925 req->mask = cpu_to_le32(vnic->rx_mask); in bnxt_hwrm_cfa_l2_set_rx_mask()
4940 req->ntuple_filter_id = fltr->filter_id; in bnxt_hwrm_cfa_ntuple_filter_free()
4968 struct flow_keys *keys = &fltr->fkeys; in bnxt_hwrm_cfa_ntuple_filter_alloc()
4977 req->l2_filter_id = bp->vnic_info[0].fw_l2_filter_id[fltr->l2_fltr_idx]; in bnxt_hwrm_cfa_ntuple_filter_alloc()
4979 if (bp->fw_cap & BNXT_FW_CAP_CFA_RFS_RING_TBL_IDX_V2) { in bnxt_hwrm_cfa_ntuple_filter_alloc()
4981 req->dst_id = cpu_to_le16(fltr->rxq); in bnxt_hwrm_cfa_ntuple_filter_alloc()
4983 vnic = &bp->vnic_info[fltr->rxq + 1]; in bnxt_hwrm_cfa_ntuple_filter_alloc()
4984 req->dst_id = cpu_to_le16(vnic->fw_vnic_id); in bnxt_hwrm_cfa_ntuple_filter_alloc()
4986 req->flags = cpu_to_le32(flags); in bnxt_hwrm_cfa_ntuple_filter_alloc()
4987 req->enables = cpu_to_le32(BNXT_NTP_FLTR_FLAGS); in bnxt_hwrm_cfa_ntuple_filter_alloc()
4989 req->ethertype = htons(ETH_P_IP); in bnxt_hwrm_cfa_ntuple_filter_alloc()
4990 memcpy(req->src_macaddr, fltr->src_mac_addr, ETH_ALEN); in bnxt_hwrm_cfa_ntuple_filter_alloc()
4991 req->ip_addr_type = CFA_NTUPLE_FILTER_ALLOC_REQ_IP_ADDR_TYPE_IPV4; in bnxt_hwrm_cfa_ntuple_filter_alloc()
4992 req->ip_protocol = keys->basic.ip_proto; in bnxt_hwrm_cfa_ntuple_filter_alloc()
4994 if (keys->basic.n_proto == htons(ETH_P_IPV6)) { in bnxt_hwrm_cfa_ntuple_filter_alloc()
4997 req->ethertype = htons(ETH_P_IPV6); in bnxt_hwrm_cfa_ntuple_filter_alloc()
4998 req->ip_addr_type = in bnxt_hwrm_cfa_ntuple_filter_alloc()
5000 *(struct in6_addr *)&req->src_ipaddr[0] = in bnxt_hwrm_cfa_ntuple_filter_alloc()
5001 keys->addrs.v6addrs.src; in bnxt_hwrm_cfa_ntuple_filter_alloc()
5002 *(struct in6_addr *)&req->dst_ipaddr[0] = in bnxt_hwrm_cfa_ntuple_filter_alloc()
5003 keys->addrs.v6addrs.dst; in bnxt_hwrm_cfa_ntuple_filter_alloc()
5005 req->src_ipaddr_mask[i] = cpu_to_be32(0xffffffff); in bnxt_hwrm_cfa_ntuple_filter_alloc()
5006 req->dst_ipaddr_mask[i] = cpu_to_be32(0xffffffff); in bnxt_hwrm_cfa_ntuple_filter_alloc()
5009 req->src_ipaddr[0] = keys->addrs.v4addrs.src; in bnxt_hwrm_cfa_ntuple_filter_alloc()
5010 req->src_ipaddr_mask[0] = cpu_to_be32(0xffffffff); in bnxt_hwrm_cfa_ntuple_filter_alloc()
5011 req->dst_ipaddr[0] = keys->addrs.v4addrs.dst; in bnxt_hwrm_cfa_ntuple_filter_alloc()
5012 req->dst_ipaddr_mask[0] = cpu_to_be32(0xffffffff); in bnxt_hwrm_cfa_ntuple_filter_alloc()
5014 if (keys->control.flags & FLOW_DIS_ENCAPSULATION) { in bnxt_hwrm_cfa_ntuple_filter_alloc()
5015 req->enables |= cpu_to_le32(BNXT_NTP_TUNNEL_FLTR_FLAG); in bnxt_hwrm_cfa_ntuple_filter_alloc()
5016 req->tunnel_type = in bnxt_hwrm_cfa_ntuple_filter_alloc()
5020 req->src_port = keys->ports.src; in bnxt_hwrm_cfa_ntuple_filter_alloc()
5021 req->src_port_mask = cpu_to_be16(0xffff); in bnxt_hwrm_cfa_ntuple_filter_alloc()
5022 req->dst_port = keys->ports.dst; in bnxt_hwrm_cfa_ntuple_filter_alloc()
5023 req->dst_port_mask = cpu_to_be16(0xffff); in bnxt_hwrm_cfa_ntuple_filter_alloc()
5028 fltr->filter_id = resp->ntuple_filter_id; in bnxt_hwrm_cfa_ntuple_filter_alloc()
5045 req->flags = cpu_to_le32(CFA_L2_FILTER_ALLOC_REQ_FLAGS_PATH_RX); in bnxt_hwrm_set_vnic_filter()
5047 req->flags |= in bnxt_hwrm_set_vnic_filter()
5049 req->dst_id = cpu_to_le16(bp->vnic_info[vnic_id].fw_vnic_id); in bnxt_hwrm_set_vnic_filter()
5050 req->enables = in bnxt_hwrm_set_vnic_filter()
5054 memcpy(req->l2_addr, mac_addr, ETH_ALEN); in bnxt_hwrm_set_vnic_filter()
5055 req->l2_addr_mask[0] = 0xff; in bnxt_hwrm_set_vnic_filter()
5056 req->l2_addr_mask[1] = 0xff; in bnxt_hwrm_set_vnic_filter()
5057 req->l2_addr_mask[2] = 0xff; in bnxt_hwrm_set_vnic_filter()
5058 req->l2_addr_mask[3] = 0xff; in bnxt_hwrm_set_vnic_filter()
5059 req->l2_addr_mask[4] = 0xff; in bnxt_hwrm_set_vnic_filter()
5060 req->l2_addr_mask[5] = 0xff; in bnxt_hwrm_set_vnic_filter()
5065 bp->vnic_info[vnic_id].fw_l2_filter_id[idx] = in bnxt_hwrm_set_vnic_filter()
5066 resp->l2_filter_id; in bnxt_hwrm_set_vnic_filter()
5083 struct bnxt_vnic_info *vnic = &bp->vnic_info[i]; in bnxt_hwrm_clear_vnic_filter()
5085 for (j = 0; j < vnic->uc_filter_count; j++) { in bnxt_hwrm_clear_vnic_filter()
5086 req->l2_filter_id = vnic->fw_l2_filter_id[j]; in bnxt_hwrm_clear_vnic_filter()
5090 vnic->uc_filter_count = 0; in bnxt_hwrm_clear_vnic_filter()
5098 struct bnxt_vnic_info *vnic = &bp->vnic_info[vnic_id]; in bnxt_hwrm_vnic_set_tpa()
5103 if (vnic->fw_vnic_id == INVALID_HW_RING_ID) in bnxt_hwrm_vnic_set_tpa()
5111 u16 mss = bp->dev->mtu - 40; in bnxt_hwrm_vnic_set_tpa()
5122 req->flags = cpu_to_le32(flags); in bnxt_hwrm_vnic_set_tpa()
5124 req->enables = in bnxt_hwrm_vnic_set_tpa()
5134 nsegs = (MAX_SKB_FRAGS - 1) * n; in bnxt_hwrm_vnic_set_tpa()
5137 if (mss & (BNXT_RX_PAGE_SIZE - 1)) in bnxt_hwrm_vnic_set_tpa()
5139 nsegs = (MAX_SKB_FRAGS - n) / n; in bnxt_hwrm_vnic_set_tpa()
5142 if (bp->flags & BNXT_FLAG_CHIP_P5) { in bnxt_hwrm_vnic_set_tpa()
5144 max_aggs = bp->max_tpa; in bnxt_hwrm_vnic_set_tpa()
5148 req->max_agg_segs = cpu_to_le16(segs); in bnxt_hwrm_vnic_set_tpa()
5149 req->max_aggs = cpu_to_le16(max_aggs); in bnxt_hwrm_vnic_set_tpa()
5151 req->min_agg_len = cpu_to_le32(512); in bnxt_hwrm_vnic_set_tpa()
5153 req->vnic_id = cpu_to_le16(vnic->fw_vnic_id); in bnxt_hwrm_vnic_set_tpa()
5162 grp_info = &bp->grp_info[ring->grp_idx]; in bnxt_cp_ring_from_grp()
5163 return grp_info->cp_fw_ring_id; in bnxt_cp_ring_from_grp()
5168 if (bp->flags & BNXT_FLAG_CHIP_P5) { in bnxt_cp_ring_for_rx()
5169 struct bnxt_napi *bnapi = rxr->bnapi; in bnxt_cp_ring_for_rx()
5172 cpr = bnapi->cp_ring.cp_ring_arr[BNXT_RX_HDL]; in bnxt_cp_ring_for_rx()
5173 return cpr->cp_ring_struct.fw_ring_id; in bnxt_cp_ring_for_rx()
5175 return bnxt_cp_ring_from_grp(bp, &rxr->rx_ring_struct); in bnxt_cp_ring_for_rx()
5181 if (bp->flags & BNXT_FLAG_CHIP_P5) { in bnxt_cp_ring_for_tx()
5182 struct bnxt_napi *bnapi = txr->bnapi; in bnxt_cp_ring_for_tx()
5185 cpr = bnapi->cp_ring.cp_ring_arr[BNXT_TX_HDL]; in bnxt_cp_ring_for_tx()
5186 return cpr->cp_ring_struct.fw_ring_id; in bnxt_cp_ring_for_tx()
5188 return bnxt_cp_ring_from_grp(bp, &txr->tx_ring_struct); in bnxt_cp_ring_for_tx()
5196 if (bp->flags & BNXT_FLAG_CHIP_P5) in bnxt_alloc_rss_indir_tbl()
5201 bp->rss_indir_tbl_entries = entries; in bnxt_alloc_rss_indir_tbl()
5202 bp->rss_indir_tbl = kmalloc_array(entries, sizeof(*bp->rss_indir_tbl), in bnxt_alloc_rss_indir_tbl()
5204 if (!bp->rss_indir_tbl) in bnxt_alloc_rss_indir_tbl()
5205 return -ENOMEM; in bnxt_alloc_rss_indir_tbl()
5213 if (!bp->rx_nr_rings) in bnxt_set_dflt_rss_indir_tbl()
5217 max_rings = bp->rx_nr_rings - 1; in bnxt_set_dflt_rss_indir_tbl()
5219 max_rings = bp->rx_nr_rings; in bnxt_set_dflt_rss_indir_tbl()
5221 max_entries = bnxt_get_rxfh_indir_size(bp->dev); in bnxt_set_dflt_rss_indir_tbl()
5224 bp->rss_indir_tbl[i] = ethtool_rxfh_indir_default(i, max_rings); in bnxt_set_dflt_rss_indir_tbl()
5226 pad = bp->rss_indir_tbl_entries - max_entries; in bnxt_set_dflt_rss_indir_tbl()
5228 memset(&bp->rss_indir_tbl[i], 0, pad * sizeof(u16)); in bnxt_set_dflt_rss_indir_tbl()
5235 if (!bp->rss_indir_tbl) in bnxt_get_max_rss_ring()
5238 tbl_size = bnxt_get_rxfh_indir_size(bp->dev); in bnxt_get_max_rss_ring()
5240 max_ring = max(max_ring, bp->rss_indir_tbl[i]); in bnxt_get_max_rss_ring()
5246 if (bp->flags & BNXT_FLAG_CHIP_P5) in bnxt_get_nr_rss_ctxs()
5255 bool no_rss = !(vnic->flags & BNXT_VNIC_RSS_FLAG); in __bnxt_fill_hw_rss_tbl()
5261 j = bp->rss_indir_tbl[i]; in __bnxt_fill_hw_rss_tbl()
5262 vnic->rss_table[i] = cpu_to_le16(vnic->fw_grp_ids[j]); in __bnxt_fill_hw_rss_tbl()
5269 __le16 *ring_tbl = vnic->rss_table; in __bnxt_fill_hw_rss_tbl_p5()
5273 tbl_size = bnxt_get_rxfh_indir_size(bp->dev); in __bnxt_fill_hw_rss_tbl_p5()
5278 j = bp->rss_indir_tbl[i]; in __bnxt_fill_hw_rss_tbl_p5()
5279 rxr = &bp->rx_ring[j]; in __bnxt_fill_hw_rss_tbl_p5()
5281 ring_id = rxr->rx_ring_struct.fw_ring_id; in __bnxt_fill_hw_rss_tbl_p5()
5290 if (bp->flags & BNXT_FLAG_CHIP_P5) in bnxt_fill_hw_rss_tbl()
5298 struct bnxt_vnic_info *vnic = &bp->vnic_info[vnic_id]; in bnxt_hwrm_vnic_set_rss()
5302 if ((bp->flags & BNXT_FLAG_CHIP_P5) || in bnxt_hwrm_vnic_set_rss()
5303 vnic->fw_rss_cos_lb_ctx[0] == INVALID_HW_RING_ID) in bnxt_hwrm_vnic_set_rss()
5312 req->hash_type = cpu_to_le32(bp->rss_hash_cfg); in bnxt_hwrm_vnic_set_rss()
5313 req->hash_mode_flags = VNIC_RSS_CFG_REQ_HASH_MODE_FLAGS_DEFAULT; in bnxt_hwrm_vnic_set_rss()
5314 req->ring_grp_tbl_addr = cpu_to_le64(vnic->rss_table_dma_addr); in bnxt_hwrm_vnic_set_rss()
5315 req->hash_key_tbl_addr = in bnxt_hwrm_vnic_set_rss()
5316 cpu_to_le64(vnic->rss_hash_key_dma_addr); in bnxt_hwrm_vnic_set_rss()
5318 req->rss_ctx_idx = cpu_to_le16(vnic->fw_rss_cos_lb_ctx[0]); in bnxt_hwrm_vnic_set_rss()
5324 struct bnxt_vnic_info *vnic = &bp->vnic_info[vnic_id]; in bnxt_hwrm_vnic_set_rss_p5()
5334 req->vnic_id = cpu_to_le16(vnic->fw_vnic_id); in bnxt_hwrm_vnic_set_rss_p5()
5339 req->hash_type = cpu_to_le32(bp->rss_hash_cfg); in bnxt_hwrm_vnic_set_rss_p5()
5340 req->hash_mode_flags = VNIC_RSS_CFG_REQ_HASH_MODE_FLAGS_DEFAULT; in bnxt_hwrm_vnic_set_rss_p5()
5341 req->hash_key_tbl_addr = cpu_to_le64(vnic->rss_hash_key_dma_addr); in bnxt_hwrm_vnic_set_rss_p5()
5342 ring_tbl_map = vnic->rss_table_dma_addr; in bnxt_hwrm_vnic_set_rss_p5()
5343 nr_ctxs = bnxt_get_nr_rss_ctxs(bp, bp->rx_nr_rings); in bnxt_hwrm_vnic_set_rss_p5()
5347 req->ring_grp_tbl_addr = cpu_to_le64(ring_tbl_map); in bnxt_hwrm_vnic_set_rss_p5()
5348 req->ring_table_pair_index = i; in bnxt_hwrm_vnic_set_rss_p5()
5349 req->rss_ctx_idx = cpu_to_le16(vnic->fw_rss_cos_lb_ctx[i]); in bnxt_hwrm_vnic_set_rss_p5()
5362 struct bnxt_vnic_info *vnic = &bp->vnic_info[vnic_id]; in bnxt_hwrm_vnic_set_hds()
5370 req->flags = cpu_to_le32(VNIC_PLCMODES_CFG_REQ_FLAGS_JUMBO_PLACEMENT); in bnxt_hwrm_vnic_set_hds()
5371 req->enables = cpu_to_le32(VNIC_PLCMODES_CFG_REQ_ENABLES_JUMBO_THRESH_VALID); in bnxt_hwrm_vnic_set_hds()
5374 req->flags |= cpu_to_le32(VNIC_PLCMODES_CFG_REQ_FLAGS_HDS_IPV4 | in bnxt_hwrm_vnic_set_hds()
5376 req->enables |= in bnxt_hwrm_vnic_set_hds()
5380 req->jumbo_thresh = cpu_to_le16(bp->rx_copy_thresh); in bnxt_hwrm_vnic_set_hds()
5381 req->hds_threshold = cpu_to_le16(bp->rx_copy_thresh); in bnxt_hwrm_vnic_set_hds()
5382 req->vnic_id = cpu_to_le32(vnic->fw_vnic_id); in bnxt_hwrm_vnic_set_hds()
5394 req->rss_cos_lb_ctx_id = in bnxt_hwrm_vnic_ctx_free_one()
5395 cpu_to_le16(bp->vnic_info[vnic_id].fw_rss_cos_lb_ctx[ctx_idx]); in bnxt_hwrm_vnic_ctx_free_one()
5398 bp->vnic_info[vnic_id].fw_rss_cos_lb_ctx[ctx_idx] = INVALID_HW_RING_ID; in bnxt_hwrm_vnic_ctx_free_one()
5405 for (i = 0; i < bp->nr_vnics; i++) { in bnxt_hwrm_vnic_ctx_free()
5406 struct bnxt_vnic_info *vnic = &bp->vnic_info[i]; in bnxt_hwrm_vnic_ctx_free()
5409 if (vnic->fw_rss_cos_lb_ctx[j] != INVALID_HW_RING_ID) in bnxt_hwrm_vnic_ctx_free()
5413 bp->rsscos_nr_ctxs = 0; in bnxt_hwrm_vnic_ctx_free()
5429 bp->vnic_info[vnic_id].fw_rss_cos_lb_ctx[ctx_idx] = in bnxt_hwrm_vnic_ctx_alloc()
5430 le16_to_cpu(resp->rss_cos_lb_ctx_id); in bnxt_hwrm_vnic_ctx_alloc()
5438 if (bp->flags & BNXT_FLAG_ROCE_MIRROR_CAP) in bnxt_get_roce_vnic_mode()
5445 struct bnxt_vnic_info *vnic = &bp->vnic_info[vnic_id]; in bnxt_hwrm_vnic_cfg()
5455 if (bp->flags & BNXT_FLAG_CHIP_P5) { in bnxt_hwrm_vnic_cfg()
5456 struct bnxt_rx_ring_info *rxr = &bp->rx_ring[0]; in bnxt_hwrm_vnic_cfg()
5458 req->default_rx_ring_id = in bnxt_hwrm_vnic_cfg()
5459 cpu_to_le16(rxr->rx_ring_struct.fw_ring_id); in bnxt_hwrm_vnic_cfg()
5460 req->default_cmpl_ring_id = in bnxt_hwrm_vnic_cfg()
5462 req->enables = in bnxt_hwrm_vnic_cfg()
5467 req->enables = cpu_to_le32(VNIC_CFG_REQ_ENABLES_DFLT_RING_GRP); in bnxt_hwrm_vnic_cfg()
5469 if (vnic->fw_rss_cos_lb_ctx[0] != INVALID_HW_RING_ID) { in bnxt_hwrm_vnic_cfg()
5470 req->rss_rule = cpu_to_le16(vnic->fw_rss_cos_lb_ctx[0]); in bnxt_hwrm_vnic_cfg()
5471 req->enables |= cpu_to_le32(VNIC_CFG_REQ_ENABLES_RSS_RULE | in bnxt_hwrm_vnic_cfg()
5473 } else if (vnic->flags & BNXT_VNIC_RFS_NEW_RSS_FLAG) { in bnxt_hwrm_vnic_cfg()
5474 req->rss_rule = in bnxt_hwrm_vnic_cfg()
5475 cpu_to_le16(bp->vnic_info[0].fw_rss_cos_lb_ctx[0]); in bnxt_hwrm_vnic_cfg()
5476 req->enables |= cpu_to_le32(VNIC_CFG_REQ_ENABLES_RSS_RULE | in bnxt_hwrm_vnic_cfg()
5478 req->flags |= cpu_to_le32(VNIC_CFG_REQ_FLAGS_RSS_DFLT_CR_MODE); in bnxt_hwrm_vnic_cfg()
5480 req->rss_rule = cpu_to_le16(0xffff); in bnxt_hwrm_vnic_cfg()
5484 (vnic->fw_rss_cos_lb_ctx[0] != INVALID_HW_RING_ID)) { in bnxt_hwrm_vnic_cfg()
5485 req->cos_rule = cpu_to_le16(vnic->fw_rss_cos_lb_ctx[1]); in bnxt_hwrm_vnic_cfg()
5486 req->enables |= cpu_to_le32(VNIC_CFG_REQ_ENABLES_COS_RULE); in bnxt_hwrm_vnic_cfg()
5488 req->cos_rule = cpu_to_le16(0xffff); in bnxt_hwrm_vnic_cfg()
5491 if (vnic->flags & BNXT_VNIC_RSS_FLAG) in bnxt_hwrm_vnic_cfg()
5493 else if (vnic->flags & BNXT_VNIC_RFS_FLAG) in bnxt_hwrm_vnic_cfg()
5494 ring = vnic_id - 1; in bnxt_hwrm_vnic_cfg()
5496 ring = bp->rx_nr_rings - 1; in bnxt_hwrm_vnic_cfg()
5498 grp_idx = bp->rx_ring[ring].bnapi->index; in bnxt_hwrm_vnic_cfg()
5499 req->dflt_ring_grp = cpu_to_le16(bp->grp_info[grp_idx].fw_grp_id); in bnxt_hwrm_vnic_cfg()
5500 req->lb_rule = cpu_to_le16(0xffff); in bnxt_hwrm_vnic_cfg()
5502 req->mru = cpu_to_le16(bp->dev->mtu + ETH_HLEN + VLAN_HLEN); in bnxt_hwrm_vnic_cfg()
5504 req->vnic_id = cpu_to_le16(vnic->fw_vnic_id); in bnxt_hwrm_vnic_cfg()
5507 def_vlan = bp->vf.vlan; in bnxt_hwrm_vnic_cfg()
5509 if ((bp->flags & BNXT_FLAG_STRIP_VLAN) || def_vlan) in bnxt_hwrm_vnic_cfg()
5510 req->flags |= cpu_to_le32(VNIC_CFG_REQ_FLAGS_VLAN_STRIP_MODE); in bnxt_hwrm_vnic_cfg()
5511 if (!vnic_id && bnxt_ulp_registered(bp->edev, BNXT_ROCE_ULP)) in bnxt_hwrm_vnic_cfg()
5512 req->flags |= cpu_to_le32(bnxt_get_roce_vnic_mode(bp)); in bnxt_hwrm_vnic_cfg()
5519 if (bp->vnic_info[vnic_id].fw_vnic_id != INVALID_HW_RING_ID) { in bnxt_hwrm_vnic_free_one()
5525 req->vnic_id = in bnxt_hwrm_vnic_free_one()
5526 cpu_to_le32(bp->vnic_info[vnic_id].fw_vnic_id); in bnxt_hwrm_vnic_free_one()
5529 bp->vnic_info[vnic_id].fw_vnic_id = INVALID_HW_RING_ID; in bnxt_hwrm_vnic_free_one()
5537 for (i = 0; i < bp->nr_vnics; i++) in bnxt_hwrm_vnic_free()
5546 struct bnxt_vnic_info *vnic = &bp->vnic_info[vnic_id]; in bnxt_hwrm_vnic_alloc()
5555 if (bp->flags & BNXT_FLAG_CHIP_P5) in bnxt_hwrm_vnic_alloc()
5560 grp_idx = bp->rx_ring[i].bnapi->index; in bnxt_hwrm_vnic_alloc()
5561 if (bp->grp_info[grp_idx].fw_grp_id == INVALID_HW_RING_ID) { in bnxt_hwrm_vnic_alloc()
5562 netdev_err(bp->dev, "Not enough ring groups avail:%x req:%x\n", in bnxt_hwrm_vnic_alloc()
5566 vnic->fw_grp_ids[j] = bp->grp_info[grp_idx].fw_grp_id; in bnxt_hwrm_vnic_alloc()
5571 vnic->fw_rss_cos_lb_ctx[i] = INVALID_HW_RING_ID; in bnxt_hwrm_vnic_alloc()
5573 req->flags = cpu_to_le32(VNIC_ALLOC_REQ_FLAGS_DEFAULT); in bnxt_hwrm_vnic_alloc()
5578 vnic->fw_vnic_id = le32_to_cpu(resp->vnic_id); in bnxt_hwrm_vnic_alloc()
5589 bp->hw_ring_stats_size = sizeof(struct ctx_hw_stats); in bnxt_hwrm_vnic_qcaps()
5590 bp->flags &= ~(BNXT_FLAG_NEW_RSS_CAP | BNXT_FLAG_ROCE_MIRROR_CAP); in bnxt_hwrm_vnic_qcaps()
5591 if (bp->hwrm_spec_code < 0x10600) in bnxt_hwrm_vnic_qcaps()
5601 u32 flags = le32_to_cpu(resp->flags); in bnxt_hwrm_vnic_qcaps()
5603 if (!(bp->flags & BNXT_FLAG_CHIP_P5) && in bnxt_hwrm_vnic_qcaps()
5605 bp->flags |= BNXT_FLAG_NEW_RSS_CAP; in bnxt_hwrm_vnic_qcaps()
5608 bp->flags |= BNXT_FLAG_ROCE_MIRROR_CAP; in bnxt_hwrm_vnic_qcaps()
5615 !(bp->fw_cap & BNXT_FW_CAP_EXT_HW_STATS_SUPPORTED))) in bnxt_hwrm_vnic_qcaps()
5616 bp->fw_cap |= BNXT_FW_CAP_VLAN_RX_STRIP; in bnxt_hwrm_vnic_qcaps()
5617 bp->max_tpa_v2 = le16_to_cpu(resp->max_aggs_supported); in bnxt_hwrm_vnic_qcaps()
5618 if (bp->max_tpa_v2) { in bnxt_hwrm_vnic_qcaps()
5620 bp->hw_ring_stats_size = BNXT_RING_STATS_SIZE_P5; in bnxt_hwrm_vnic_qcaps()
5622 bp->hw_ring_stats_size = BNXT_RING_STATS_SIZE_P5_SR2; in bnxt_hwrm_vnic_qcaps()
5636 if (bp->flags & BNXT_FLAG_CHIP_P5) in bnxt_hwrm_ring_grp_alloc()
5644 for (i = 0; i < bp->rx_nr_rings; i++) { in bnxt_hwrm_ring_grp_alloc()
5645 unsigned int grp_idx = bp->rx_ring[i].bnapi->index; in bnxt_hwrm_ring_grp_alloc()
5647 req->cr = cpu_to_le16(bp->grp_info[grp_idx].cp_fw_ring_id); in bnxt_hwrm_ring_grp_alloc()
5648 req->rr = cpu_to_le16(bp->grp_info[grp_idx].rx_fw_ring_id); in bnxt_hwrm_ring_grp_alloc()
5649 req->ar = cpu_to_le16(bp->grp_info[grp_idx].agg_fw_ring_id); in bnxt_hwrm_ring_grp_alloc()
5650 req->sc = cpu_to_le16(bp->grp_info[grp_idx].fw_stats_ctx); in bnxt_hwrm_ring_grp_alloc()
5657 bp->grp_info[grp_idx].fw_grp_id = in bnxt_hwrm_ring_grp_alloc()
5658 le32_to_cpu(resp->ring_group_id); in bnxt_hwrm_ring_grp_alloc()
5669 if (!bp->grp_info || (bp->flags & BNXT_FLAG_CHIP_P5)) in bnxt_hwrm_ring_grp_free()
5676 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_hwrm_ring_grp_free()
5677 if (bp->grp_info[i].fw_grp_id == INVALID_HW_RING_ID) in bnxt_hwrm_ring_grp_free()
5679 req->ring_group_id = in bnxt_hwrm_ring_grp_free()
5680 cpu_to_le32(bp->grp_info[i].fw_grp_id); in bnxt_hwrm_ring_grp_free()
5683 bp->grp_info[i].fw_grp_id = INVALID_HW_RING_ID; in bnxt_hwrm_ring_grp_free()
5694 struct bnxt_ring_mem_info *rmem = &ring->ring_mem; in hwrm_ring_alloc_send_msg()
5703 req->enables = 0; in hwrm_ring_alloc_send_msg()
5704 if (rmem->nr_pages > 1) { in hwrm_ring_alloc_send_msg()
5705 req->page_tbl_addr = cpu_to_le64(rmem->pg_tbl_map); in hwrm_ring_alloc_send_msg()
5707 req->page_size = BNXT_PAGE_SHIFT; in hwrm_ring_alloc_send_msg()
5708 req->page_tbl_depth = 1; in hwrm_ring_alloc_send_msg()
5710 req->page_tbl_addr = cpu_to_le64(rmem->dma_arr[0]); in hwrm_ring_alloc_send_msg()
5712 req->fbo = 0; in hwrm_ring_alloc_send_msg()
5714 req->logical_id = cpu_to_le16(map_index); in hwrm_ring_alloc_send_msg()
5722 req->ring_type = RING_ALLOC_REQ_RING_TYPE_TX; in hwrm_ring_alloc_send_msg()
5724 grp_info = &bp->grp_info[ring->grp_idx]; in hwrm_ring_alloc_send_msg()
5725 req->cmpl_ring_id = cpu_to_le16(bnxt_cp_ring_for_tx(bp, txr)); in hwrm_ring_alloc_send_msg()
5726 req->length = cpu_to_le32(bp->tx_ring_mask + 1); in hwrm_ring_alloc_send_msg()
5727 req->stat_ctx_id = cpu_to_le32(grp_info->fw_stats_ctx); in hwrm_ring_alloc_send_msg()
5728 req->queue_id = cpu_to_le16(ring->queue_id); in hwrm_ring_alloc_send_msg()
5732 req->ring_type = RING_ALLOC_REQ_RING_TYPE_RX; in hwrm_ring_alloc_send_msg()
5733 req->length = cpu_to_le32(bp->rx_ring_mask + 1); in hwrm_ring_alloc_send_msg()
5734 if (bp->flags & BNXT_FLAG_CHIP_P5) { in hwrm_ring_alloc_send_msg()
5738 grp_info = &bp->grp_info[ring->grp_idx]; in hwrm_ring_alloc_send_msg()
5739 req->rx_buf_size = cpu_to_le16(bp->rx_buf_use_size); in hwrm_ring_alloc_send_msg()
5740 req->stat_ctx_id = cpu_to_le32(grp_info->fw_stats_ctx); in hwrm_ring_alloc_send_msg()
5741 req->enables |= cpu_to_le32( in hwrm_ring_alloc_send_msg()
5745 req->flags = cpu_to_le16(flags); in hwrm_ring_alloc_send_msg()
5749 if (bp->flags & BNXT_FLAG_CHIP_P5) { in hwrm_ring_alloc_send_msg()
5750 req->ring_type = RING_ALLOC_REQ_RING_TYPE_RX_AGG; in hwrm_ring_alloc_send_msg()
5752 grp_info = &bp->grp_info[ring->grp_idx]; in hwrm_ring_alloc_send_msg()
5753 req->rx_ring_id = cpu_to_le16(grp_info->rx_fw_ring_id); in hwrm_ring_alloc_send_msg()
5754 req->rx_buf_size = cpu_to_le16(BNXT_RX_PAGE_SIZE); in hwrm_ring_alloc_send_msg()
5755 req->stat_ctx_id = cpu_to_le32(grp_info->fw_stats_ctx); in hwrm_ring_alloc_send_msg()
5756 req->enables |= cpu_to_le32( in hwrm_ring_alloc_send_msg()
5760 req->ring_type = RING_ALLOC_REQ_RING_TYPE_RX; in hwrm_ring_alloc_send_msg()
5762 req->length = cpu_to_le32(bp->rx_agg_ring_mask + 1); in hwrm_ring_alloc_send_msg()
5765 req->ring_type = RING_ALLOC_REQ_RING_TYPE_L2_CMPL; in hwrm_ring_alloc_send_msg()
5766 req->length = cpu_to_le32(bp->cp_ring_mask + 1); in hwrm_ring_alloc_send_msg()
5767 if (bp->flags & BNXT_FLAG_CHIP_P5) { in hwrm_ring_alloc_send_msg()
5769 grp_info = &bp->grp_info[map_index]; in hwrm_ring_alloc_send_msg()
5770 req->nq_ring_id = cpu_to_le16(grp_info->cp_fw_ring_id); in hwrm_ring_alloc_send_msg()
5771 req->cq_handle = cpu_to_le64(ring->handle); in hwrm_ring_alloc_send_msg()
5772 req->enables |= cpu_to_le32( in hwrm_ring_alloc_send_msg()
5774 } else if (bp->flags & BNXT_FLAG_USING_MSIX) { in hwrm_ring_alloc_send_msg()
5775 req->int_mode = RING_ALLOC_REQ_INT_MODE_MSIX; in hwrm_ring_alloc_send_msg()
5779 req->ring_type = RING_ALLOC_REQ_RING_TYPE_NQ; in hwrm_ring_alloc_send_msg()
5780 req->length = cpu_to_le32(bp->cp_ring_mask + 1); in hwrm_ring_alloc_send_msg()
5781 if (bp->flags & BNXT_FLAG_USING_MSIX) in hwrm_ring_alloc_send_msg()
5782 req->int_mode = RING_ALLOC_REQ_INT_MODE_MSIX; in hwrm_ring_alloc_send_msg()
5785 netdev_err(bp->dev, "hwrm alloc invalid ring type %d\n", in hwrm_ring_alloc_send_msg()
5787 return -1; in hwrm_ring_alloc_send_msg()
5792 err = le16_to_cpu(resp->error_code); in hwrm_ring_alloc_send_msg()
5793 ring_id = le16_to_cpu(resp->ring_id); in hwrm_ring_alloc_send_msg()
5798 netdev_err(bp->dev, "hwrm_ring_alloc type %d failed. rc:%x err:%x\n", in hwrm_ring_alloc_send_msg()
5800 return -EIO; in hwrm_ring_alloc_send_msg()
5802 ring->fw_ring_id = ring_id; in hwrm_ring_alloc_send_msg()
5817 req->fid = cpu_to_le16(0xffff); in bnxt_hwrm_set_async_event_cr()
5818 req->enables = cpu_to_le32(FUNC_CFG_REQ_ENABLES_ASYNC_EVENT_CR); in bnxt_hwrm_set_async_event_cr()
5819 req->async_event_cr = cpu_to_le16(idx); in bnxt_hwrm_set_async_event_cr()
5828 req->enables = in bnxt_hwrm_set_async_event_cr()
5830 req->async_event_cr = cpu_to_le16(idx); in bnxt_hwrm_set_async_event_cr()
5838 if (bp->flags & BNXT_FLAG_CHIP_P5) { in bnxt_set_db()
5840 db->doorbell = bp->bar1 + DB_PF_OFFSET_P5; in bnxt_set_db()
5842 db->doorbell = bp->bar1 + DB_VF_OFFSET_P5; in bnxt_set_db()
5845 db->db_key64 = DBR_PATH_L2 | DBR_TYPE_SQ; in bnxt_set_db()
5849 db->db_key64 = DBR_PATH_L2 | DBR_TYPE_SRQ; in bnxt_set_db()
5852 db->db_key64 = DBR_PATH_L2; in bnxt_set_db()
5855 db->db_key64 = DBR_PATH_L2; in bnxt_set_db()
5858 db->db_key64 |= (u64)xid << DBR_XID_SFT; in bnxt_set_db()
5860 db->doorbell = bp->bar1 + map_idx * 0x80; in bnxt_set_db()
5863 db->db_key32 = DB_KEY_TX; in bnxt_set_db()
5867 db->db_key32 = DB_KEY_RX; in bnxt_set_db()
5870 db->db_key32 = DB_KEY_CP; in bnxt_set_db()
5878 bool agg_rings = !!(bp->flags & BNXT_FLAG_AGG_RINGS); in bnxt_hwrm_ring_alloc()
5882 if (bp->flags & BNXT_FLAG_CHIP_P5) in bnxt_hwrm_ring_alloc()
5886 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_hwrm_ring_alloc()
5887 struct bnxt_napi *bnapi = bp->bnapi[i]; in bnxt_hwrm_ring_alloc()
5888 struct bnxt_cp_ring_info *cpr = &bnapi->cp_ring; in bnxt_hwrm_ring_alloc()
5889 struct bnxt_ring_struct *ring = &cpr->cp_ring_struct; in bnxt_hwrm_ring_alloc()
5890 u32 map_idx = ring->map_idx; in bnxt_hwrm_ring_alloc()
5893 vector = bp->irq_tbl[map_idx].vector; in bnxt_hwrm_ring_alloc()
5900 bnxt_set_db(bp, &cpr->cp_db, type, map_idx, ring->fw_ring_id); in bnxt_hwrm_ring_alloc()
5901 bnxt_db_nq(bp, &cpr->cp_db, cpr->cp_raw_cons); in bnxt_hwrm_ring_alloc()
5903 bp->grp_info[i].cp_fw_ring_id = ring->fw_ring_id; in bnxt_hwrm_ring_alloc()
5906 rc = bnxt_hwrm_set_async_event_cr(bp, ring->fw_ring_id); in bnxt_hwrm_ring_alloc()
5908 netdev_warn(bp->dev, "Failed to set async event completion ring.\n"); in bnxt_hwrm_ring_alloc()
5913 for (i = 0; i < bp->tx_nr_rings; i++) { in bnxt_hwrm_ring_alloc()
5914 struct bnxt_tx_ring_info *txr = &bp->tx_ring[i]; in bnxt_hwrm_ring_alloc()
5918 if (bp->flags & BNXT_FLAG_CHIP_P5) { in bnxt_hwrm_ring_alloc()
5919 struct bnxt_napi *bnapi = txr->bnapi; in bnxt_hwrm_ring_alloc()
5923 cpr = &bnapi->cp_ring; in bnxt_hwrm_ring_alloc()
5924 cpr2 = cpr->cp_ring_arr[BNXT_TX_HDL]; in bnxt_hwrm_ring_alloc()
5925 ring = &cpr2->cp_ring_struct; in bnxt_hwrm_ring_alloc()
5926 ring->handle = BNXT_TX_HDL; in bnxt_hwrm_ring_alloc()
5927 map_idx = bnapi->index; in bnxt_hwrm_ring_alloc()
5931 bnxt_set_db(bp, &cpr2->cp_db, type2, map_idx, in bnxt_hwrm_ring_alloc()
5932 ring->fw_ring_id); in bnxt_hwrm_ring_alloc()
5933 bnxt_db_cq(bp, &cpr2->cp_db, cpr2->cp_raw_cons); in bnxt_hwrm_ring_alloc()
5935 ring = &txr->tx_ring_struct; in bnxt_hwrm_ring_alloc()
5940 bnxt_set_db(bp, &txr->tx_db, type, map_idx, ring->fw_ring_id); in bnxt_hwrm_ring_alloc()
5944 for (i = 0; i < bp->rx_nr_rings; i++) { in bnxt_hwrm_ring_alloc()
5945 struct bnxt_rx_ring_info *rxr = &bp->rx_ring[i]; in bnxt_hwrm_ring_alloc()
5946 struct bnxt_ring_struct *ring = &rxr->rx_ring_struct; in bnxt_hwrm_ring_alloc()
5947 struct bnxt_napi *bnapi = rxr->bnapi; in bnxt_hwrm_ring_alloc()
5948 u32 map_idx = bnapi->index; in bnxt_hwrm_ring_alloc()
5953 bnxt_set_db(bp, &rxr->rx_db, type, map_idx, ring->fw_ring_id); in bnxt_hwrm_ring_alloc()
5956 bnxt_db_write(bp, &rxr->rx_db, rxr->rx_prod); in bnxt_hwrm_ring_alloc()
5957 bp->grp_info[map_idx].rx_fw_ring_id = ring->fw_ring_id; in bnxt_hwrm_ring_alloc()
5958 if (bp->flags & BNXT_FLAG_CHIP_P5) { in bnxt_hwrm_ring_alloc()
5959 struct bnxt_cp_ring_info *cpr = &bnapi->cp_ring; in bnxt_hwrm_ring_alloc()
5963 cpr2 = cpr->cp_ring_arr[BNXT_RX_HDL]; in bnxt_hwrm_ring_alloc()
5964 ring = &cpr2->cp_ring_struct; in bnxt_hwrm_ring_alloc()
5965 ring->handle = BNXT_RX_HDL; in bnxt_hwrm_ring_alloc()
5969 bnxt_set_db(bp, &cpr2->cp_db, type2, map_idx, in bnxt_hwrm_ring_alloc()
5970 ring->fw_ring_id); in bnxt_hwrm_ring_alloc()
5971 bnxt_db_cq(bp, &cpr2->cp_db, cpr2->cp_raw_cons); in bnxt_hwrm_ring_alloc()
5977 for (i = 0; i < bp->rx_nr_rings; i++) { in bnxt_hwrm_ring_alloc()
5978 struct bnxt_rx_ring_info *rxr = &bp->rx_ring[i]; in bnxt_hwrm_ring_alloc()
5980 &rxr->rx_agg_ring_struct; in bnxt_hwrm_ring_alloc()
5981 u32 grp_idx = ring->grp_idx; in bnxt_hwrm_ring_alloc()
5982 u32 map_idx = grp_idx + bp->rx_nr_rings; in bnxt_hwrm_ring_alloc()
5988 bnxt_set_db(bp, &rxr->rx_agg_db, type, map_idx, in bnxt_hwrm_ring_alloc()
5989 ring->fw_ring_id); in bnxt_hwrm_ring_alloc()
5990 bnxt_db_write(bp, &rxr->rx_agg_db, rxr->rx_agg_prod); in bnxt_hwrm_ring_alloc()
5991 bnxt_db_write(bp, &rxr->rx_db, rxr->rx_prod); in bnxt_hwrm_ring_alloc()
5992 bp->grp_info[grp_idx].agg_fw_ring_id = ring->fw_ring_id; in bnxt_hwrm_ring_alloc()
6015 req->cmpl_ring = cpu_to_le16(cmpl_ring_id); in hwrm_ring_free_send_msg()
6016 req->ring_type = ring_type; in hwrm_ring_free_send_msg()
6017 req->ring_id = cpu_to_le16(ring->fw_ring_id); in hwrm_ring_free_send_msg()
6021 error_code = le16_to_cpu(resp->error_code); in hwrm_ring_free_send_msg()
6025 netdev_err(bp->dev, "hwrm_ring_free type %d failed. rc:%x err:%x\n", in hwrm_ring_free_send_msg()
6027 return -EIO; in hwrm_ring_free_send_msg()
6037 if (!bp->bnapi) in bnxt_hwrm_ring_free()
6040 for (i = 0; i < bp->tx_nr_rings; i++) { in bnxt_hwrm_ring_free()
6041 struct bnxt_tx_ring_info *txr = &bp->tx_ring[i]; in bnxt_hwrm_ring_free()
6042 struct bnxt_ring_struct *ring = &txr->tx_ring_struct; in bnxt_hwrm_ring_free()
6044 if (ring->fw_ring_id != INVALID_HW_RING_ID) { in bnxt_hwrm_ring_free()
6051 ring->fw_ring_id = INVALID_HW_RING_ID; in bnxt_hwrm_ring_free()
6055 for (i = 0; i < bp->rx_nr_rings; i++) { in bnxt_hwrm_ring_free()
6056 struct bnxt_rx_ring_info *rxr = &bp->rx_ring[i]; in bnxt_hwrm_ring_free()
6057 struct bnxt_ring_struct *ring = &rxr->rx_ring_struct; in bnxt_hwrm_ring_free()
6058 u32 grp_idx = rxr->bnapi->index; in bnxt_hwrm_ring_free()
6060 if (ring->fw_ring_id != INVALID_HW_RING_ID) { in bnxt_hwrm_ring_free()
6067 ring->fw_ring_id = INVALID_HW_RING_ID; in bnxt_hwrm_ring_free()
6068 bp->grp_info[grp_idx].rx_fw_ring_id = in bnxt_hwrm_ring_free()
6073 if (bp->flags & BNXT_FLAG_CHIP_P5) in bnxt_hwrm_ring_free()
6077 for (i = 0; i < bp->rx_nr_rings; i++) { in bnxt_hwrm_ring_free()
6078 struct bnxt_rx_ring_info *rxr = &bp->rx_ring[i]; in bnxt_hwrm_ring_free()
6079 struct bnxt_ring_struct *ring = &rxr->rx_agg_ring_struct; in bnxt_hwrm_ring_free()
6080 u32 grp_idx = rxr->bnapi->index; in bnxt_hwrm_ring_free()
6082 if (ring->fw_ring_id != INVALID_HW_RING_ID) { in bnxt_hwrm_ring_free()
6088 ring->fw_ring_id = INVALID_HW_RING_ID; in bnxt_hwrm_ring_free()
6089 bp->grp_info[grp_idx].agg_fw_ring_id = in bnxt_hwrm_ring_free()
6100 if (bp->flags & BNXT_FLAG_CHIP_P5) in bnxt_hwrm_ring_free()
6104 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_hwrm_ring_free()
6105 struct bnxt_napi *bnapi = bp->bnapi[i]; in bnxt_hwrm_ring_free()
6106 struct bnxt_cp_ring_info *cpr = &bnapi->cp_ring; in bnxt_hwrm_ring_free()
6111 struct bnxt_cp_ring_info *cpr2 = cpr->cp_ring_arr[j]; in bnxt_hwrm_ring_free()
6114 ring = &cpr2->cp_ring_struct; in bnxt_hwrm_ring_free()
6115 if (ring->fw_ring_id == INVALID_HW_RING_ID) in bnxt_hwrm_ring_free()
6120 ring->fw_ring_id = INVALID_HW_RING_ID; in bnxt_hwrm_ring_free()
6123 ring = &cpr->cp_ring_struct; in bnxt_hwrm_ring_free()
6124 if (ring->fw_ring_id != INVALID_HW_RING_ID) { in bnxt_hwrm_ring_free()
6127 ring->fw_ring_id = INVALID_HW_RING_ID; in bnxt_hwrm_ring_free()
6128 bp->grp_info[i].cp_fw_ring_id = INVALID_HW_RING_ID; in bnxt_hwrm_ring_free()
6138 struct bnxt_hw_resc *hw_resc = &bp->hw_resc; in bnxt_hwrm_get_rings()
6143 if (bp->hwrm_spec_code < 0x10601) in bnxt_hwrm_get_rings()
6150 req->fid = cpu_to_le16(0xffff); in bnxt_hwrm_get_rings()
6158 hw_resc->resv_tx_rings = le16_to_cpu(resp->alloc_tx_rings); in bnxt_hwrm_get_rings()
6162 hw_resc->resv_rx_rings = le16_to_cpu(resp->alloc_rx_rings); in bnxt_hwrm_get_rings()
6163 hw_resc->resv_hw_ring_grps = in bnxt_hwrm_get_rings()
6164 le32_to_cpu(resp->alloc_hw_ring_grps); in bnxt_hwrm_get_rings()
6165 hw_resc->resv_vnics = le16_to_cpu(resp->alloc_vnics); in bnxt_hwrm_get_rings()
6166 cp = le16_to_cpu(resp->alloc_cmpl_rings); in bnxt_hwrm_get_rings()
6167 stats = le16_to_cpu(resp->alloc_stat_ctx); in bnxt_hwrm_get_rings()
6168 hw_resc->resv_irqs = cp; in bnxt_hwrm_get_rings()
6169 if (bp->flags & BNXT_FLAG_CHIP_P5) { in bnxt_hwrm_get_rings()
6170 int rx = hw_resc->resv_rx_rings; in bnxt_hwrm_get_rings()
6171 int tx = hw_resc->resv_tx_rings; in bnxt_hwrm_get_rings()
6173 if (bp->flags & BNXT_FLAG_AGG_RINGS) in bnxt_hwrm_get_rings()
6177 if (bp->flags & BNXT_FLAG_AGG_RINGS) in bnxt_hwrm_get_rings()
6179 hw_resc->resv_rx_rings = rx; in bnxt_hwrm_get_rings()
6180 hw_resc->resv_tx_rings = tx; in bnxt_hwrm_get_rings()
6182 hw_resc->resv_irqs = le16_to_cpu(resp->alloc_msix); in bnxt_hwrm_get_rings()
6183 hw_resc->resv_hw_ring_grps = rx; in bnxt_hwrm_get_rings()
6185 hw_resc->resv_cp_rings = cp; in bnxt_hwrm_get_rings()
6186 hw_resc->resv_stat_ctxs = stats; in bnxt_hwrm_get_rings()
6198 if (bp->hwrm_spec_code < 0x10601) in __bnxt_hwrm_get_tx_rings()
6205 req->fid = cpu_to_le16(fid); in __bnxt_hwrm_get_tx_rings()
6209 *tx_rings = le16_to_cpu(resp->alloc_tx_rings); in __bnxt_hwrm_get_tx_rings()
6227 req->fid = cpu_to_le16(0xffff); in __bnxt_hwrm_reserve_pf_rings()
6229 req->num_tx_rings = cpu_to_le16(tx_rings); in __bnxt_hwrm_reserve_pf_rings()
6233 if (bp->flags & BNXT_FLAG_CHIP_P5) { in __bnxt_hwrm_reserve_pf_rings()
6248 req->num_rx_rings = cpu_to_le16(rx_rings); in __bnxt_hwrm_reserve_pf_rings()
6249 if (bp->flags & BNXT_FLAG_CHIP_P5) { in __bnxt_hwrm_reserve_pf_rings()
6250 req->num_cmpl_rings = cpu_to_le16(tx_rings + ring_grps); in __bnxt_hwrm_reserve_pf_rings()
6251 req->num_msix = cpu_to_le16(cp_rings); in __bnxt_hwrm_reserve_pf_rings()
6252 req->num_rsscos_ctxs = in __bnxt_hwrm_reserve_pf_rings()
6255 req->num_cmpl_rings = cpu_to_le16(cp_rings); in __bnxt_hwrm_reserve_pf_rings()
6256 req->num_hw_ring_grps = cpu_to_le16(ring_grps); in __bnxt_hwrm_reserve_pf_rings()
6257 req->num_rsscos_ctxs = cpu_to_le16(1); in __bnxt_hwrm_reserve_pf_rings()
6258 if (!(bp->flags & BNXT_FLAG_NEW_RSS_CAP) && in __bnxt_hwrm_reserve_pf_rings()
6260 req->num_rsscos_ctxs = in __bnxt_hwrm_reserve_pf_rings()
6263 req->num_stat_ctxs = cpu_to_le16(stats); in __bnxt_hwrm_reserve_pf_rings()
6264 req->num_vnics = cpu_to_le16(vnics); in __bnxt_hwrm_reserve_pf_rings()
6266 req->enables = cpu_to_le32(enables); in __bnxt_hwrm_reserve_pf_rings()
6284 if (bp->flags & BNXT_FLAG_CHIP_P5) { in __bnxt_hwrm_reserve_vf_rings()
6296 req->num_l2_ctxs = cpu_to_le16(BNXT_VF_MAX_L2_CTX); in __bnxt_hwrm_reserve_vf_rings()
6297 req->num_tx_rings = cpu_to_le16(tx_rings); in __bnxt_hwrm_reserve_vf_rings()
6298 req->num_rx_rings = cpu_to_le16(rx_rings); in __bnxt_hwrm_reserve_vf_rings()
6299 if (bp->flags & BNXT_FLAG_CHIP_P5) { in __bnxt_hwrm_reserve_vf_rings()
6300 req->num_cmpl_rings = cpu_to_le16(tx_rings + ring_grps); in __bnxt_hwrm_reserve_vf_rings()
6301 req->num_rsscos_ctxs = cpu_to_le16(DIV_ROUND_UP(ring_grps, 64)); in __bnxt_hwrm_reserve_vf_rings()
6303 req->num_cmpl_rings = cpu_to_le16(cp_rings); in __bnxt_hwrm_reserve_vf_rings()
6304 req->num_hw_ring_grps = cpu_to_le16(ring_grps); in __bnxt_hwrm_reserve_vf_rings()
6305 req->num_rsscos_ctxs = cpu_to_le16(BNXT_VF_MAX_RSS_CTX); in __bnxt_hwrm_reserve_vf_rings()
6307 req->num_stat_ctxs = cpu_to_le16(stats); in __bnxt_hwrm_reserve_vf_rings()
6308 req->num_vnics = cpu_to_le16(vnics); in __bnxt_hwrm_reserve_vf_rings()
6310 req->enables = cpu_to_le32(enables); in __bnxt_hwrm_reserve_vf_rings()
6324 return -ENOMEM; in bnxt_hwrm_reserve_pf_rings()
6326 if (!req->enables) { in bnxt_hwrm_reserve_pf_rings()
6335 if (bp->hwrm_spec_code < 0x10601) in bnxt_hwrm_reserve_pf_rings()
6336 bp->hw_resc.resv_tx_rings = tx_rings; in bnxt_hwrm_reserve_pf_rings()
6349 bp->hw_resc.resv_tx_rings = tx_rings; in bnxt_hwrm_reserve_vf_rings()
6356 return -ENOMEM; in bnxt_hwrm_reserve_vf_rings()
6378 int cp = bp->cp_nr_rings; in bnxt_nq_rings_in_use()
6395 if (!(bp->flags & BNXT_FLAG_CHIP_P5)) in bnxt_cp_rings_in_use()
6398 cp = bp->tx_nr_rings + bp->rx_nr_rings; in bnxt_cp_rings_in_use()
6405 int cp = bp->cp_nr_rings; in bnxt_get_func_stat_ctxs()
6421 struct bnxt_hw_resc *hw_resc = &bp->hw_resc; in bnxt_check_rss_tbl_no_rmgr()
6424 if (hw_resc->resv_rx_rings != bp->rx_nr_rings) { in bnxt_check_rss_tbl_no_rmgr()
6425 hw_resc->resv_rx_rings = bp->rx_nr_rings; in bnxt_check_rss_tbl_no_rmgr()
6426 if (!netif_is_rxfh_configured(bp->dev)) in bnxt_check_rss_tbl_no_rmgr()
6433 struct bnxt_hw_resc *hw_resc = &bp->hw_resc; in bnxt_need_reserve_rings()
6436 int rx = bp->rx_nr_rings, stat; in bnxt_need_reserve_rings()
6439 if (hw_resc->resv_tx_rings != bp->tx_nr_rings && in bnxt_need_reserve_rings()
6440 bp->hwrm_spec_code >= 0x10601) in bnxt_need_reserve_rings()
6452 if ((bp->flags & BNXT_FLAG_RFS) && !(bp->flags & BNXT_FLAG_CHIP_P5)) in bnxt_need_reserve_rings()
6454 if (bp->flags & BNXT_FLAG_AGG_RINGS) in bnxt_need_reserve_rings()
6457 if (hw_resc->resv_rx_rings != rx || hw_resc->resv_cp_rings != cp || in bnxt_need_reserve_rings()
6458 hw_resc->resv_vnics != vnic || hw_resc->resv_stat_ctxs != stat || in bnxt_need_reserve_rings()
6459 (hw_resc->resv_hw_ring_grps != grp && in bnxt_need_reserve_rings()
6460 !(bp->flags & BNXT_FLAG_CHIP_P5))) in bnxt_need_reserve_rings()
6462 if ((bp->flags & BNXT_FLAG_CHIP_P5) && BNXT_PF(bp) && in bnxt_need_reserve_rings()
6463 hw_resc->resv_irqs != nq) in bnxt_need_reserve_rings()
6470 struct bnxt_hw_resc *hw_resc = &bp->hw_resc; in __bnxt_reserve_rings()
6472 int tx = bp->tx_nr_rings; in __bnxt_reserve_rings()
6473 int rx = bp->rx_nr_rings; in __bnxt_reserve_rings()
6481 if (bp->flags & BNXT_FLAG_SHARED_RINGS) in __bnxt_reserve_rings()
6483 if ((bp->flags & BNXT_FLAG_RFS) && !(bp->flags & BNXT_FLAG_CHIP_P5)) in __bnxt_reserve_rings()
6485 if (bp->flags & BNXT_FLAG_AGG_RINGS) in __bnxt_reserve_rings()
6487 grp = bp->rx_nr_rings; in __bnxt_reserve_rings()
6494 tx = hw_resc->resv_tx_rings; in __bnxt_reserve_rings()
6496 rx = hw_resc->resv_rx_rings; in __bnxt_reserve_rings()
6497 cp = hw_resc->resv_irqs; in __bnxt_reserve_rings()
6498 grp = hw_resc->resv_hw_ring_grps; in __bnxt_reserve_rings()
6499 vnic = hw_resc->resv_vnics; in __bnxt_reserve_rings()
6500 stat = hw_resc->resv_stat_ctxs; in __bnxt_reserve_rings()
6504 if (bp->flags & BNXT_FLAG_AGG_RINGS) { in __bnxt_reserve_rings()
6508 if (netif_running(bp->dev)) in __bnxt_reserve_rings()
6509 return -ENOMEM; in __bnxt_reserve_rings()
6511 bp->flags &= ~BNXT_FLAG_AGG_RINGS; in __bnxt_reserve_rings()
6512 bp->flags |= BNXT_FLAG_NO_AGG_RINGS; in __bnxt_reserve_rings()
6513 bp->dev->hw_features &= ~NETIF_F_LRO; in __bnxt_reserve_rings()
6514 bp->dev->features &= ~NETIF_F_LRO; in __bnxt_reserve_rings()
6519 cp = min_t(int, cp, bp->cp_nr_rings); in __bnxt_reserve_rings()
6521 stat -= bnxt_get_ulp_stat_ctxs(bp); in __bnxt_reserve_rings()
6524 if (bp->flags & BNXT_FLAG_AGG_RINGS) in __bnxt_reserve_rings()
6527 bp->tx_nr_rings = tx; in __bnxt_reserve_rings()
6532 if (rx_rings != bp->rx_nr_rings) { in __bnxt_reserve_rings()
6533 netdev_warn(bp->dev, "Able to reserve only %d out of %d requested RX rings\n", in __bnxt_reserve_rings()
6534 rx_rings, bp->rx_nr_rings); in __bnxt_reserve_rings()
6535 if (netif_is_rxfh_configured(bp->dev) && in __bnxt_reserve_rings()
6536 (bnxt_get_nr_rss_ctxs(bp, bp->rx_nr_rings) != in __bnxt_reserve_rings()
6539 netdev_warn(bp->dev, "RSS table entries reverting to default\n"); in __bnxt_reserve_rings()
6540 bp->dev->priv_flags &= ~IFF_RXFH_CONFIGURED; in __bnxt_reserve_rings()
6543 bp->rx_nr_rings = rx_rings; in __bnxt_reserve_rings()
6544 bp->cp_nr_rings = cp; in __bnxt_reserve_rings()
6547 return -ENOMEM; in __bnxt_reserve_rings()
6549 if (!netif_is_rxfh_configured(bp->dev)) in __bnxt_reserve_rings()
6573 if (!(bp->flags & BNXT_FLAG_CHIP_P5)) in bnxt_hwrm_check_vf_rings()
6576 req->flags = cpu_to_le32(flags); in bnxt_hwrm_check_vf_rings()
6595 if (bp->flags & BNXT_FLAG_CHIP_P5) in bnxt_hwrm_check_pf_rings()
6602 req->flags = cpu_to_le32(flags); in bnxt_hwrm_check_pf_rings()
6610 if (bp->hwrm_spec_code < 0x10801) in bnxt_hwrm_check_rings()
6624 struct bnxt_coal_cap *coal_cap = &bp->coal_cap; in bnxt_hwrm_coal_params_qcaps()
6629 coal_cap->cmpl_params = BNXT_LEGACY_COAL_CMPL_PARAMS; in bnxt_hwrm_coal_params_qcaps()
6630 coal_cap->num_cmpl_dma_aggr_max = 63; in bnxt_hwrm_coal_params_qcaps()
6631 coal_cap->num_cmpl_dma_aggr_during_int_max = 63; in bnxt_hwrm_coal_params_qcaps()
6632 coal_cap->cmpl_aggr_dma_tmr_max = 65535; in bnxt_hwrm_coal_params_qcaps()
6633 coal_cap->cmpl_aggr_dma_tmr_during_int_max = 65535; in bnxt_hwrm_coal_params_qcaps()
6634 coal_cap->int_lat_tmr_min_max = 65535; in bnxt_hwrm_coal_params_qcaps()
6635 coal_cap->int_lat_tmr_max_max = 65535; in bnxt_hwrm_coal_params_qcaps()
6636 coal_cap->num_cmpl_aggr_int_max = 65535; in bnxt_hwrm_coal_params_qcaps()
6637 coal_cap->timer_units = 80; in bnxt_hwrm_coal_params_qcaps()
6639 if (bp->hwrm_spec_code < 0x10902) in bnxt_hwrm_coal_params_qcaps()
6648 coal_cap->cmpl_params = le32_to_cpu(resp->cmpl_params); in bnxt_hwrm_coal_params_qcaps()
6649 coal_cap->nq_params = le32_to_cpu(resp->nq_params); in bnxt_hwrm_coal_params_qcaps()
6650 coal_cap->num_cmpl_dma_aggr_max = in bnxt_hwrm_coal_params_qcaps()
6651 le16_to_cpu(resp->num_cmpl_dma_aggr_max); in bnxt_hwrm_coal_params_qcaps()
6652 coal_cap->num_cmpl_dma_aggr_during_int_max = in bnxt_hwrm_coal_params_qcaps()
6653 le16_to_cpu(resp->num_cmpl_dma_aggr_during_int_max); in bnxt_hwrm_coal_params_qcaps()
6654 coal_cap->cmpl_aggr_dma_tmr_max = in bnxt_hwrm_coal_params_qcaps()
6655 le16_to_cpu(resp->cmpl_aggr_dma_tmr_max); in bnxt_hwrm_coal_params_qcaps()
6656 coal_cap->cmpl_aggr_dma_tmr_during_int_max = in bnxt_hwrm_coal_params_qcaps()
6657 le16_to_cpu(resp->cmpl_aggr_dma_tmr_during_int_max); in bnxt_hwrm_coal_params_qcaps()
6658 coal_cap->int_lat_tmr_min_max = in bnxt_hwrm_coal_params_qcaps()
6659 le16_to_cpu(resp->int_lat_tmr_min_max); in bnxt_hwrm_coal_params_qcaps()
6660 coal_cap->int_lat_tmr_max_max = in bnxt_hwrm_coal_params_qcaps()
6661 le16_to_cpu(resp->int_lat_tmr_max_max); in bnxt_hwrm_coal_params_qcaps()
6662 coal_cap->num_cmpl_aggr_int_max = in bnxt_hwrm_coal_params_qcaps()
6663 le16_to_cpu(resp->num_cmpl_aggr_int_max); in bnxt_hwrm_coal_params_qcaps()
6664 coal_cap->timer_units = le16_to_cpu(resp->timer_units); in bnxt_hwrm_coal_params_qcaps()
6671 struct bnxt_coal_cap *coal_cap = &bp->coal_cap; in bnxt_usec_to_coal_tmr()
6673 return usec * 1000 / coal_cap->timer_units; in bnxt_usec_to_coal_tmr()
6680 struct bnxt_coal_cap *coal_cap = &bp->coal_cap; in bnxt_hwrm_set_coal_params()
6681 u16 val, tmr, max, flags = hw_coal->flags; in bnxt_hwrm_set_coal_params()
6682 u32 cmpl_params = coal_cap->cmpl_params; in bnxt_hwrm_set_coal_params()
6684 max = hw_coal->bufs_per_record * 128; in bnxt_hwrm_set_coal_params()
6685 if (hw_coal->budget) in bnxt_hwrm_set_coal_params()
6686 max = hw_coal->bufs_per_record * hw_coal->budget; in bnxt_hwrm_set_coal_params()
6687 max = min_t(u16, max, coal_cap->num_cmpl_aggr_int_max); in bnxt_hwrm_set_coal_params()
6689 val = clamp_t(u16, hw_coal->coal_bufs, 1, max); in bnxt_hwrm_set_coal_params()
6690 req->num_cmpl_aggr_int = cpu_to_le16(val); in bnxt_hwrm_set_coal_params()
6692 val = min_t(u16, val, coal_cap->num_cmpl_dma_aggr_max); in bnxt_hwrm_set_coal_params()
6693 req->num_cmpl_dma_aggr = cpu_to_le16(val); in bnxt_hwrm_set_coal_params()
6695 val = clamp_t(u16, hw_coal->coal_bufs_irq, 1, in bnxt_hwrm_set_coal_params()
6696 coal_cap->num_cmpl_dma_aggr_during_int_max); in bnxt_hwrm_set_coal_params()
6697 req->num_cmpl_dma_aggr_during_int = cpu_to_le16(val); in bnxt_hwrm_set_coal_params()
6699 tmr = bnxt_usec_to_coal_tmr(bp, hw_coal->coal_ticks); in bnxt_hwrm_set_coal_params()
6700 tmr = clamp_t(u16, tmr, 1, coal_cap->int_lat_tmr_max_max); in bnxt_hwrm_set_coal_params()
6701 req->int_lat_tmr_max = cpu_to_le16(tmr); in bnxt_hwrm_set_coal_params()
6706 val = clamp_t(u16, val, 1, coal_cap->int_lat_tmr_min_max); in bnxt_hwrm_set_coal_params()
6707 req->int_lat_tmr_min = cpu_to_le16(val); in bnxt_hwrm_set_coal_params()
6708 req->enables |= cpu_to_le16(BNXT_COAL_CMPL_MIN_TMR_ENABLE); in bnxt_hwrm_set_coal_params()
6712 val = clamp_t(u16, tmr / 4, 1, coal_cap->cmpl_aggr_dma_tmr_max); in bnxt_hwrm_set_coal_params()
6713 req->cmpl_aggr_dma_tmr = cpu_to_le16(val); in bnxt_hwrm_set_coal_params()
6717 tmr = bnxt_usec_to_coal_tmr(bp, hw_coal->coal_ticks_irq); in bnxt_hwrm_set_coal_params()
6719 coal_cap->cmpl_aggr_dma_tmr_during_int_max); in bnxt_hwrm_set_coal_params()
6720 req->cmpl_aggr_dma_tmr_during_int = cpu_to_le16(val); in bnxt_hwrm_set_coal_params()
6721 req->enables |= in bnxt_hwrm_set_coal_params()
6726 hw_coal->idle_thresh && hw_coal->coal_ticks < hw_coal->idle_thresh) in bnxt_hwrm_set_coal_params()
6728 req->flags = cpu_to_le16(flags); in bnxt_hwrm_set_coal_params()
6729 req->enables |= cpu_to_le16(BNXT_COAL_CMPL_ENABLES); in bnxt_hwrm_set_coal_params()
6736 struct bnxt_cp_ring_info *cpr = &bnapi->cp_ring; in __bnxt_hwrm_set_coal_nq()
6737 struct bnxt_coal_cap *coal_cap = &bp->coal_cap; in __bnxt_hwrm_set_coal_nq()
6738 u32 nq_params = coal_cap->nq_params; in __bnxt_hwrm_set_coal_nq()
6749 req->ring_id = cpu_to_le16(cpr->cp_ring_struct.fw_ring_id); in __bnxt_hwrm_set_coal_nq()
6750 req->flags = in __bnxt_hwrm_set_coal_nq()
6753 tmr = bnxt_usec_to_coal_tmr(bp, hw_coal->coal_ticks) / 2; in __bnxt_hwrm_set_coal_nq()
6754 tmr = clamp_t(u16, tmr, 1, coal_cap->int_lat_tmr_min_max); in __bnxt_hwrm_set_coal_nq()
6755 req->int_lat_tmr_min = cpu_to_le16(tmr); in __bnxt_hwrm_set_coal_nq()
6756 req->enables |= cpu_to_le16(BNXT_COAL_CMPL_MIN_TMR_ENABLE); in __bnxt_hwrm_set_coal_nq()
6763 struct bnxt_cp_ring_info *cpr = &bnapi->cp_ring; in bnxt_hwrm_set_ring_coal()
6770 memcpy(&coal, &bp->rx_coal, sizeof(struct bnxt_coal)); in bnxt_hwrm_set_ring_coal()
6772 coal.coal_ticks = cpr->rx_ring_coal.coal_ticks; in bnxt_hwrm_set_ring_coal()
6773 coal.coal_bufs = cpr->rx_ring_coal.coal_bufs; in bnxt_hwrm_set_ring_coal()
6775 if (!bnapi->rx_ring) in bnxt_hwrm_set_ring_coal()
6776 return -ENODEV; in bnxt_hwrm_set_ring_coal()
6784 req_rx->ring_id = cpu_to_le16(bnxt_cp_ring_for_rx(bp, bnapi->rx_ring)); in bnxt_hwrm_set_ring_coal()
6805 bnxt_hwrm_set_coal_params(bp, &bp->rx_coal, req_rx); in bnxt_hwrm_set_coal()
6806 bnxt_hwrm_set_coal_params(bp, &bp->tx_coal, req_tx); in bnxt_hwrm_set_coal()
6810 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_hwrm_set_coal()
6811 struct bnxt_napi *bnapi = bp->bnapi[i]; in bnxt_hwrm_set_coal()
6816 if (!bnapi->rx_ring) { in bnxt_hwrm_set_coal()
6817 ring_id = bnxt_cp_ring_for_tx(bp, bnapi->tx_ring); in bnxt_hwrm_set_coal()
6820 ring_id = bnxt_cp_ring_for_rx(bp, bnapi->rx_ring); in bnxt_hwrm_set_coal()
6822 req->ring_id = cpu_to_le16(ring_id); in bnxt_hwrm_set_coal()
6828 if (!(bp->flags & BNXT_FLAG_CHIP_P5)) in bnxt_hwrm_set_coal()
6831 if (bnapi->rx_ring && bnapi->tx_ring) { in bnxt_hwrm_set_coal()
6833 ring_id = bnxt_cp_ring_for_tx(bp, bnapi->tx_ring); in bnxt_hwrm_set_coal()
6834 req->ring_id = cpu_to_le16(ring_id); in bnxt_hwrm_set_coal()
6839 if (bnapi->rx_ring) in bnxt_hwrm_set_coal()
6840 hw_coal = &bp->rx_coal; in bnxt_hwrm_set_coal()
6842 hw_coal = &bp->tx_coal; in bnxt_hwrm_set_coal()
6856 if (!bp->bnapi) in bnxt_hwrm_stat_ctx_free()
6872 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_hwrm_stat_ctx_free()
6873 struct bnxt_napi *bnapi = bp->bnapi[i]; in bnxt_hwrm_stat_ctx_free()
6874 struct bnxt_cp_ring_info *cpr = &bnapi->cp_ring; in bnxt_hwrm_stat_ctx_free()
6876 if (cpr->hw_stats_ctx_id != INVALID_STATS_CTX_ID) { in bnxt_hwrm_stat_ctx_free()
6877 req->stat_ctx_id = cpu_to_le32(cpr->hw_stats_ctx_id); in bnxt_hwrm_stat_ctx_free()
6879 req0->stat_ctx_id = req->stat_ctx_id; in bnxt_hwrm_stat_ctx_free()
6884 cpr->hw_stats_ctx_id = INVALID_STATS_CTX_ID; in bnxt_hwrm_stat_ctx_free()
6905 req->stats_dma_length = cpu_to_le16(bp->hw_ring_stats_size); in bnxt_hwrm_stat_ctx_alloc()
6906 req->update_period_ms = cpu_to_le32(bp->stats_coal_ticks / 1000); in bnxt_hwrm_stat_ctx_alloc()
6909 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_hwrm_stat_ctx_alloc()
6910 struct bnxt_napi *bnapi = bp->bnapi[i]; in bnxt_hwrm_stat_ctx_alloc()
6911 struct bnxt_cp_ring_info *cpr = &bnapi->cp_ring; in bnxt_hwrm_stat_ctx_alloc()
6913 req->stats_dma_addr = cpu_to_le64(cpr->stats.hw_stats_map); in bnxt_hwrm_stat_ctx_alloc()
6919 cpr->hw_stats_ctx_id = le32_to_cpu(resp->stat_ctx_id); in bnxt_hwrm_stat_ctx_alloc()
6921 bp->grp_info[i].fw_stats_ctx = cpr->hw_stats_ctx_id; in bnxt_hwrm_stat_ctx_alloc()
6939 req->fid = cpu_to_le16(0xffff); in bnxt_hwrm_func_qcfg()
6947 struct bnxt_vf_info *vf = &bp->vf; in bnxt_hwrm_func_qcfg()
6949 vf->vlan = le16_to_cpu(resp->vlan) & VLAN_VID_MASK; in bnxt_hwrm_func_qcfg()
6951 bp->pf.registered_vfs = le16_to_cpu(resp->registered_vfs); in bnxt_hwrm_func_qcfg()
6954 flags = le16_to_cpu(resp->flags); in bnxt_hwrm_func_qcfg()
6957 bp->fw_cap |= BNXT_FW_CAP_LLDP_AGENT; in bnxt_hwrm_func_qcfg()
6959 bp->fw_cap |= BNXT_FW_CAP_DCBX_AGENT; in bnxt_hwrm_func_qcfg()
6962 bp->flags |= BNXT_FLAG_MULTI_HOST; in bnxt_hwrm_func_qcfg()
6964 bp->fw_cap |= BNXT_FW_CAP_RING_MONITOR; in bnxt_hwrm_func_qcfg()
6966 switch (resp->port_partition_type) { in bnxt_hwrm_func_qcfg()
6970 bp->port_partition_type = resp->port_partition_type; in bnxt_hwrm_func_qcfg()
6973 if (bp->hwrm_spec_code < 0x10707 || in bnxt_hwrm_func_qcfg()
6974 resp->evb_mode == FUNC_QCFG_RESP_EVB_MODE_VEB) in bnxt_hwrm_func_qcfg()
6975 bp->br_mode = BRIDGE_MODE_VEB; in bnxt_hwrm_func_qcfg()
6976 else if (resp->evb_mode == FUNC_QCFG_RESP_EVB_MODE_VEPA) in bnxt_hwrm_func_qcfg()
6977 bp->br_mode = BRIDGE_MODE_VEPA; in bnxt_hwrm_func_qcfg()
6979 bp->br_mode = BRIDGE_MODE_UNDEF; in bnxt_hwrm_func_qcfg()
6981 bp->max_mtu = le16_to_cpu(resp->max_mtu_configured); in bnxt_hwrm_func_qcfg()
6982 if (!bp->max_mtu) in bnxt_hwrm_func_qcfg()
6983 bp->max_mtu = BNXT_MAX_MTU; in bnxt_hwrm_func_qcfg()
6985 if (bp->db_size) in bnxt_hwrm_func_qcfg()
6988 if (bp->flags & BNXT_FLAG_CHIP_P5) { in bnxt_hwrm_func_qcfg()
6994 bp->db_size = PAGE_ALIGN(le16_to_cpu(resp->l2_doorbell_bar_size_kb) * in bnxt_hwrm_func_qcfg()
6996 if (!bp->db_size || bp->db_size > pci_resource_len(bp->pdev, 2) || in bnxt_hwrm_func_qcfg()
6997 bp->db_size <= min_db_offset) in bnxt_hwrm_func_qcfg()
6998 bp->db_size = pci_resource_len(bp->pdev, 2); in bnxt_hwrm_func_qcfg()
7014 init_val = resp->ctx_kind_initializer; in bnxt_init_ctx_initializer()
7015 init_mask = le16_to_cpu(resp->ctx_init_mask); in bnxt_init_ctx_initializer()
7016 offset = &resp->qp_init_offset; in bnxt_init_ctx_initializer()
7017 mem_init = &ctx->mem_init[BNXT_CTX_MEM_INIT_QP]; in bnxt_init_ctx_initializer()
7019 mem_init->init_val = init_val; in bnxt_init_ctx_initializer()
7020 mem_init->offset = BNXT_MEM_INVALID_OFFSET; in bnxt_init_ctx_initializer()
7024 offset = &resp->stat_init_offset; in bnxt_init_ctx_initializer()
7026 mem_init->offset = *offset * 4; in bnxt_init_ctx_initializer()
7028 mem_init->init_val = 0; in bnxt_init_ctx_initializer()
7030 ctx->mem_init[BNXT_CTX_MEM_INIT_QP].size = ctx->qp_entry_size; in bnxt_init_ctx_initializer()
7031 ctx->mem_init[BNXT_CTX_MEM_INIT_SRQ].size = ctx->srq_entry_size; in bnxt_init_ctx_initializer()
7032 ctx->mem_init[BNXT_CTX_MEM_INIT_CQ].size = ctx->cq_entry_size; in bnxt_init_ctx_initializer()
7033 ctx->mem_init[BNXT_CTX_MEM_INIT_VNIC].size = ctx->vnic_entry_size; in bnxt_init_ctx_initializer()
7034 ctx->mem_init[BNXT_CTX_MEM_INIT_STAT].size = ctx->stat_entry_size; in bnxt_init_ctx_initializer()
7035 ctx->mem_init[BNXT_CTX_MEM_INIT_MRAV].size = ctx->mrav_entry_size; in bnxt_init_ctx_initializer()
7044 if (bp->hwrm_spec_code < 0x10902 || BNXT_VF(bp) || bp->ctx) in bnxt_hwrm_func_backing_store_qcaps()
7060 rc = -ENOMEM; in bnxt_hwrm_func_backing_store_qcaps()
7063 ctx->qp_max_entries = le32_to_cpu(resp->qp_max_entries); in bnxt_hwrm_func_backing_store_qcaps()
7064 ctx->qp_min_qp1_entries = le16_to_cpu(resp->qp_min_qp1_entries); in bnxt_hwrm_func_backing_store_qcaps()
7065 ctx->qp_max_l2_entries = le16_to_cpu(resp->qp_max_l2_entries); in bnxt_hwrm_func_backing_store_qcaps()
7066 ctx->qp_entry_size = le16_to_cpu(resp->qp_entry_size); in bnxt_hwrm_func_backing_store_qcaps()
7067 ctx->srq_max_l2_entries = le16_to_cpu(resp->srq_max_l2_entries); in bnxt_hwrm_func_backing_store_qcaps()
7068 ctx->srq_max_entries = le32_to_cpu(resp->srq_max_entries); in bnxt_hwrm_func_backing_store_qcaps()
7069 ctx->srq_entry_size = le16_to_cpu(resp->srq_entry_size); in bnxt_hwrm_func_backing_store_qcaps()
7070 ctx->cq_max_l2_entries = le16_to_cpu(resp->cq_max_l2_entries); in bnxt_hwrm_func_backing_store_qcaps()
7071 ctx->cq_max_entries = le32_to_cpu(resp->cq_max_entries); in bnxt_hwrm_func_backing_store_qcaps()
7072 ctx->cq_entry_size = le16_to_cpu(resp->cq_entry_size); in bnxt_hwrm_func_backing_store_qcaps()
7073 ctx->vnic_max_vnic_entries = in bnxt_hwrm_func_backing_store_qcaps()
7074 le16_to_cpu(resp->vnic_max_vnic_entries); in bnxt_hwrm_func_backing_store_qcaps()
7075 ctx->vnic_max_ring_table_entries = in bnxt_hwrm_func_backing_store_qcaps()
7076 le16_to_cpu(resp->vnic_max_ring_table_entries); in bnxt_hwrm_func_backing_store_qcaps()
7077 ctx->vnic_entry_size = le16_to_cpu(resp->vnic_entry_size); in bnxt_hwrm_func_backing_store_qcaps()
7078 ctx->stat_max_entries = le32_to_cpu(resp->stat_max_entries); in bnxt_hwrm_func_backing_store_qcaps()
7079 ctx->stat_entry_size = le16_to_cpu(resp->stat_entry_size); in bnxt_hwrm_func_backing_store_qcaps()
7080 ctx->tqm_entry_size = le16_to_cpu(resp->tqm_entry_size); in bnxt_hwrm_func_backing_store_qcaps()
7081 ctx->tqm_min_entries_per_ring = in bnxt_hwrm_func_backing_store_qcaps()
7082 le32_to_cpu(resp->tqm_min_entries_per_ring); in bnxt_hwrm_func_backing_store_qcaps()
7083 ctx->tqm_max_entries_per_ring = in bnxt_hwrm_func_backing_store_qcaps()
7084 le32_to_cpu(resp->tqm_max_entries_per_ring); in bnxt_hwrm_func_backing_store_qcaps()
7085 ctx->tqm_entries_multiple = resp->tqm_entries_multiple; in bnxt_hwrm_func_backing_store_qcaps()
7086 if (!ctx->tqm_entries_multiple) in bnxt_hwrm_func_backing_store_qcaps()
7087 ctx->tqm_entries_multiple = 1; in bnxt_hwrm_func_backing_store_qcaps()
7088 ctx->mrav_max_entries = le32_to_cpu(resp->mrav_max_entries); in bnxt_hwrm_func_backing_store_qcaps()
7089 ctx->mrav_entry_size = le16_to_cpu(resp->mrav_entry_size); in bnxt_hwrm_func_backing_store_qcaps()
7090 ctx->mrav_num_entries_units = in bnxt_hwrm_func_backing_store_qcaps()
7091 le16_to_cpu(resp->mrav_num_entries_units); in bnxt_hwrm_func_backing_store_qcaps()
7092 ctx->tim_entry_size = le16_to_cpu(resp->tim_entry_size); in bnxt_hwrm_func_backing_store_qcaps()
7093 ctx->tim_max_entries = le32_to_cpu(resp->tim_max_entries); in bnxt_hwrm_func_backing_store_qcaps()
7097 ctx->tqm_fp_rings_count = resp->tqm_fp_rings_count; in bnxt_hwrm_func_backing_store_qcaps()
7098 if (!ctx->tqm_fp_rings_count) in bnxt_hwrm_func_backing_store_qcaps()
7099 ctx->tqm_fp_rings_count = bp->max_q; in bnxt_hwrm_func_backing_store_qcaps()
7100 else if (ctx->tqm_fp_rings_count > BNXT_MAX_TQM_FP_RINGS) in bnxt_hwrm_func_backing_store_qcaps()
7101 ctx->tqm_fp_rings_count = BNXT_MAX_TQM_FP_RINGS; in bnxt_hwrm_func_backing_store_qcaps()
7103 tqm_rings = ctx->tqm_fp_rings_count + BNXT_MAX_TQM_SP_RINGS; in bnxt_hwrm_func_backing_store_qcaps()
7107 rc = -ENOMEM; in bnxt_hwrm_func_backing_store_qcaps()
7111 ctx->tqm_mem[i] = ctx_pg; in bnxt_hwrm_func_backing_store_qcaps()
7112 bp->ctx = ctx; in bnxt_hwrm_func_backing_store_qcaps()
7124 if (!rmem->nr_pages) in bnxt_hwrm_set_pg_attr()
7128 if (rmem->depth >= 1) { in bnxt_hwrm_set_pg_attr()
7129 if (rmem->depth == 2) in bnxt_hwrm_set_pg_attr()
7133 *pg_dir = cpu_to_le64(rmem->pg_tbl_map); in bnxt_hwrm_set_pg_attr()
7135 *pg_dir = cpu_to_le64(rmem->dma_arr[0]); in bnxt_hwrm_set_pg_attr()
7149 struct bnxt_ctx_mem_info *ctx = bp->ctx; in bnxt_hwrm_func_backing_store_cfg()
7164 if (req_len > bp->hwrm_max_ext_req_len) in bnxt_hwrm_func_backing_store_cfg()
7170 req->enables = cpu_to_le32(enables); in bnxt_hwrm_func_backing_store_cfg()
7172 ctx_pg = &ctx->qp_mem; in bnxt_hwrm_func_backing_store_cfg()
7173 req->qp_num_entries = cpu_to_le32(ctx_pg->entries); in bnxt_hwrm_func_backing_store_cfg()
7174 req->qp_num_qp1_entries = cpu_to_le16(ctx->qp_min_qp1_entries); in bnxt_hwrm_func_backing_store_cfg()
7175 req->qp_num_l2_entries = cpu_to_le16(ctx->qp_max_l2_entries); in bnxt_hwrm_func_backing_store_cfg()
7176 req->qp_entry_size = cpu_to_le16(ctx->qp_entry_size); in bnxt_hwrm_func_backing_store_cfg()
7177 bnxt_hwrm_set_pg_attr(&ctx_pg->ring_mem, in bnxt_hwrm_func_backing_store_cfg()
7178 &req->qpc_pg_size_qpc_lvl, in bnxt_hwrm_func_backing_store_cfg()
7179 &req->qpc_page_dir); in bnxt_hwrm_func_backing_store_cfg()
7182 ctx_pg = &ctx->srq_mem; in bnxt_hwrm_func_backing_store_cfg()
7183 req->srq_num_entries = cpu_to_le32(ctx_pg->entries); in bnxt_hwrm_func_backing_store_cfg()
7184 req->srq_num_l2_entries = cpu_to_le16(ctx->srq_max_l2_entries); in bnxt_hwrm_func_backing_store_cfg()
7185 req->srq_entry_size = cpu_to_le16(ctx->srq_entry_size); in bnxt_hwrm_func_backing_store_cfg()
7186 bnxt_hwrm_set_pg_attr(&ctx_pg->ring_mem, in bnxt_hwrm_func_backing_store_cfg()
7187 &req->srq_pg_size_srq_lvl, in bnxt_hwrm_func_backing_store_cfg()
7188 &req->srq_page_dir); in bnxt_hwrm_func_backing_store_cfg()
7191 ctx_pg = &ctx->cq_mem; in bnxt_hwrm_func_backing_store_cfg()
7192 req->cq_num_entries = cpu_to_le32(ctx_pg->entries); in bnxt_hwrm_func_backing_store_cfg()
7193 req->cq_num_l2_entries = cpu_to_le16(ctx->cq_max_l2_entries); in bnxt_hwrm_func_backing_store_cfg()
7194 req->cq_entry_size = cpu_to_le16(ctx->cq_entry_size); in bnxt_hwrm_func_backing_store_cfg()
7195 bnxt_hwrm_set_pg_attr(&ctx_pg->ring_mem, in bnxt_hwrm_func_backing_store_cfg()
7196 &req->cq_pg_size_cq_lvl, in bnxt_hwrm_func_backing_store_cfg()
7197 &req->cq_page_dir); in bnxt_hwrm_func_backing_store_cfg()
7200 ctx_pg = &ctx->vnic_mem; in bnxt_hwrm_func_backing_store_cfg()
7201 req->vnic_num_vnic_entries = in bnxt_hwrm_func_backing_store_cfg()
7202 cpu_to_le16(ctx->vnic_max_vnic_entries); in bnxt_hwrm_func_backing_store_cfg()
7203 req->vnic_num_ring_table_entries = in bnxt_hwrm_func_backing_store_cfg()
7204 cpu_to_le16(ctx->vnic_max_ring_table_entries); in bnxt_hwrm_func_backing_store_cfg()
7205 req->vnic_entry_size = cpu_to_le16(ctx->vnic_entry_size); in bnxt_hwrm_func_backing_store_cfg()
7206 bnxt_hwrm_set_pg_attr(&ctx_pg->ring_mem, in bnxt_hwrm_func_backing_store_cfg()
7207 &req->vnic_pg_size_vnic_lvl, in bnxt_hwrm_func_backing_store_cfg()
7208 &req->vnic_page_dir); in bnxt_hwrm_func_backing_store_cfg()
7211 ctx_pg = &ctx->stat_mem; in bnxt_hwrm_func_backing_store_cfg()
7212 req->stat_num_entries = cpu_to_le32(ctx->stat_max_entries); in bnxt_hwrm_func_backing_store_cfg()
7213 req->stat_entry_size = cpu_to_le16(ctx->stat_entry_size); in bnxt_hwrm_func_backing_store_cfg()
7214 bnxt_hwrm_set_pg_attr(&ctx_pg->ring_mem, in bnxt_hwrm_func_backing_store_cfg()
7215 &req->stat_pg_size_stat_lvl, in bnxt_hwrm_func_backing_store_cfg()
7216 &req->stat_page_dir); in bnxt_hwrm_func_backing_store_cfg()
7219 ctx_pg = &ctx->mrav_mem; in bnxt_hwrm_func_backing_store_cfg()
7220 req->mrav_num_entries = cpu_to_le32(ctx_pg->entries); in bnxt_hwrm_func_backing_store_cfg()
7221 if (ctx->mrav_num_entries_units) in bnxt_hwrm_func_backing_store_cfg()
7224 req->mrav_entry_size = cpu_to_le16(ctx->mrav_entry_size); in bnxt_hwrm_func_backing_store_cfg()
7225 bnxt_hwrm_set_pg_attr(&ctx_pg->ring_mem, in bnxt_hwrm_func_backing_store_cfg()
7226 &req->mrav_pg_size_mrav_lvl, in bnxt_hwrm_func_backing_store_cfg()
7227 &req->mrav_page_dir); in bnxt_hwrm_func_backing_store_cfg()
7230 ctx_pg = &ctx->tim_mem; in bnxt_hwrm_func_backing_store_cfg()
7231 req->tim_num_entries = cpu_to_le32(ctx_pg->entries); in bnxt_hwrm_func_backing_store_cfg()
7232 req->tim_entry_size = cpu_to_le16(ctx->tim_entry_size); in bnxt_hwrm_func_backing_store_cfg()
7233 bnxt_hwrm_set_pg_attr(&ctx_pg->ring_mem, in bnxt_hwrm_func_backing_store_cfg()
7234 &req->tim_pg_size_tim_lvl, in bnxt_hwrm_func_backing_store_cfg()
7235 &req->tim_page_dir); in bnxt_hwrm_func_backing_store_cfg()
7237 for (i = 0, num_entries = &req->tqm_sp_num_entries, in bnxt_hwrm_func_backing_store_cfg()
7238 pg_attr = &req->tqm_sp_pg_size_tqm_sp_lvl, in bnxt_hwrm_func_backing_store_cfg()
7239 pg_dir = &req->tqm_sp_page_dir, in bnxt_hwrm_func_backing_store_cfg()
7246 req->tqm_entry_size = cpu_to_le16(ctx->tqm_entry_size); in bnxt_hwrm_func_backing_store_cfg()
7247 ctx_pg = ctx->tqm_mem[i]; in bnxt_hwrm_func_backing_store_cfg()
7248 *num_entries = cpu_to_le32(ctx_pg->entries); in bnxt_hwrm_func_backing_store_cfg()
7249 bnxt_hwrm_set_pg_attr(&ctx_pg->ring_mem, pg_attr, pg_dir); in bnxt_hwrm_func_backing_store_cfg()
7251 req->flags = cpu_to_le32(flags); in bnxt_hwrm_func_backing_store_cfg()
7258 struct bnxt_ring_mem_info *rmem = &ctx_pg->ring_mem; in bnxt_alloc_ctx_mem_blk()
7260 rmem->page_size = BNXT_PAGE_SIZE; in bnxt_alloc_ctx_mem_blk()
7261 rmem->pg_arr = ctx_pg->ctx_pg_arr; in bnxt_alloc_ctx_mem_blk()
7262 rmem->dma_arr = ctx_pg->ctx_dma_arr; in bnxt_alloc_ctx_mem_blk()
7263 rmem->flags = BNXT_RMEM_VALID_PTE_FLAG; in bnxt_alloc_ctx_mem_blk()
7264 if (rmem->depth >= 1) in bnxt_alloc_ctx_mem_blk()
7265 rmem->flags |= BNXT_RMEM_USE_FULL_PAGE_FLAG; in bnxt_alloc_ctx_mem_blk()
7273 struct bnxt_ring_mem_info *rmem = &ctx_pg->ring_mem; in bnxt_alloc_ctx_pg_tbls()
7277 return -EINVAL; in bnxt_alloc_ctx_pg_tbls()
7279 ctx_pg->nr_pages = DIV_ROUND_UP(mem_size, BNXT_PAGE_SIZE); in bnxt_alloc_ctx_pg_tbls()
7280 if (ctx_pg->nr_pages > MAX_CTX_TOTAL_PAGES) { in bnxt_alloc_ctx_pg_tbls()
7281 ctx_pg->nr_pages = 0; in bnxt_alloc_ctx_pg_tbls()
7282 return -EINVAL; in bnxt_alloc_ctx_pg_tbls()
7284 if (ctx_pg->nr_pages > MAX_CTX_PAGES || depth > 1) { in bnxt_alloc_ctx_pg_tbls()
7287 rmem->depth = 2; in bnxt_alloc_ctx_pg_tbls()
7288 ctx_pg->ctx_pg_tbl = kcalloc(MAX_CTX_PAGES, sizeof(ctx_pg), in bnxt_alloc_ctx_pg_tbls()
7290 if (!ctx_pg->ctx_pg_tbl) in bnxt_alloc_ctx_pg_tbls()
7291 return -ENOMEM; in bnxt_alloc_ctx_pg_tbls()
7292 nr_tbls = DIV_ROUND_UP(ctx_pg->nr_pages, MAX_CTX_PAGES); in bnxt_alloc_ctx_pg_tbls()
7293 rmem->nr_pages = nr_tbls; in bnxt_alloc_ctx_pg_tbls()
7302 return -ENOMEM; in bnxt_alloc_ctx_pg_tbls()
7303 ctx_pg->ctx_pg_tbl[i] = pg_tbl; in bnxt_alloc_ctx_pg_tbls()
7304 rmem = &pg_tbl->ring_mem; in bnxt_alloc_ctx_pg_tbls()
7305 rmem->pg_tbl = ctx_pg->ctx_pg_arr[i]; in bnxt_alloc_ctx_pg_tbls()
7306 rmem->pg_tbl_map = ctx_pg->ctx_dma_arr[i]; in bnxt_alloc_ctx_pg_tbls()
7307 rmem->depth = 1; in bnxt_alloc_ctx_pg_tbls()
7308 rmem->nr_pages = MAX_CTX_PAGES; in bnxt_alloc_ctx_pg_tbls()
7309 rmem->mem_init = mem_init; in bnxt_alloc_ctx_pg_tbls()
7310 if (i == (nr_tbls - 1)) { in bnxt_alloc_ctx_pg_tbls()
7311 int rem = ctx_pg->nr_pages % MAX_CTX_PAGES; in bnxt_alloc_ctx_pg_tbls()
7314 rmem->nr_pages = rem; in bnxt_alloc_ctx_pg_tbls()
7321 rmem->nr_pages = DIV_ROUND_UP(mem_size, BNXT_PAGE_SIZE); in bnxt_alloc_ctx_pg_tbls()
7322 if (rmem->nr_pages > 1 || depth) in bnxt_alloc_ctx_pg_tbls()
7323 rmem->depth = 1; in bnxt_alloc_ctx_pg_tbls()
7324 rmem->mem_init = mem_init; in bnxt_alloc_ctx_pg_tbls()
7333 struct bnxt_ring_mem_info *rmem = &ctx_pg->ring_mem; in bnxt_free_ctx_pg_tbls()
7335 if (rmem->depth > 1 || ctx_pg->nr_pages > MAX_CTX_PAGES || in bnxt_free_ctx_pg_tbls()
7336 ctx_pg->ctx_pg_tbl) { in bnxt_free_ctx_pg_tbls()
7337 int i, nr_tbls = rmem->nr_pages; in bnxt_free_ctx_pg_tbls()
7343 pg_tbl = ctx_pg->ctx_pg_tbl[i]; in bnxt_free_ctx_pg_tbls()
7346 rmem2 = &pg_tbl->ring_mem; in bnxt_free_ctx_pg_tbls()
7348 ctx_pg->ctx_pg_arr[i] = NULL; in bnxt_free_ctx_pg_tbls()
7350 ctx_pg->ctx_pg_tbl[i] = NULL; in bnxt_free_ctx_pg_tbls()
7352 kfree(ctx_pg->ctx_pg_tbl); in bnxt_free_ctx_pg_tbls()
7353 ctx_pg->ctx_pg_tbl = NULL; in bnxt_free_ctx_pg_tbls()
7356 ctx_pg->nr_pages = 0; in bnxt_free_ctx_pg_tbls()
7361 struct bnxt_ctx_mem_info *ctx = bp->ctx; in bnxt_free_ctx_mem()
7367 if (ctx->tqm_mem[0]) { in bnxt_free_ctx_mem()
7368 for (i = 0; i < ctx->tqm_fp_rings_count + 1; i++) in bnxt_free_ctx_mem()
7369 bnxt_free_ctx_pg_tbls(bp, ctx->tqm_mem[i]); in bnxt_free_ctx_mem()
7370 kfree(ctx->tqm_mem[0]); in bnxt_free_ctx_mem()
7371 ctx->tqm_mem[0] = NULL; in bnxt_free_ctx_mem()
7374 bnxt_free_ctx_pg_tbls(bp, &ctx->tim_mem); in bnxt_free_ctx_mem()
7375 bnxt_free_ctx_pg_tbls(bp, &ctx->mrav_mem); in bnxt_free_ctx_mem()
7376 bnxt_free_ctx_pg_tbls(bp, &ctx->stat_mem); in bnxt_free_ctx_mem()
7377 bnxt_free_ctx_pg_tbls(bp, &ctx->vnic_mem); in bnxt_free_ctx_mem()
7378 bnxt_free_ctx_pg_tbls(bp, &ctx->cq_mem); in bnxt_free_ctx_mem()
7379 bnxt_free_ctx_pg_tbls(bp, &ctx->srq_mem); in bnxt_free_ctx_mem()
7380 bnxt_free_ctx_pg_tbls(bp, &ctx->qp_mem); in bnxt_free_ctx_mem()
7381 ctx->flags &= ~BNXT_CTX_FLAG_INITED; in bnxt_free_ctx_mem()
7399 netdev_err(bp->dev, "Failed querying context mem capability, rc = %d.\n", in bnxt_alloc_ctx_mem()
7403 ctx = bp->ctx; in bnxt_alloc_ctx_mem()
7404 if (!ctx || (ctx->flags & BNXT_CTX_FLAG_INITED)) in bnxt_alloc_ctx_mem()
7407 if ((bp->flags & BNXT_FLAG_ROCE_CAP) && !is_kdump_kernel()) { in bnxt_alloc_ctx_mem()
7413 ctx_pg = &ctx->qp_mem; in bnxt_alloc_ctx_mem()
7414 ctx_pg->entries = ctx->qp_min_qp1_entries + ctx->qp_max_l2_entries + in bnxt_alloc_ctx_mem()
7416 if (ctx->qp_entry_size) { in bnxt_alloc_ctx_mem()
7417 mem_size = ctx->qp_entry_size * ctx_pg->entries; in bnxt_alloc_ctx_mem()
7418 init = &ctx->mem_init[BNXT_CTX_MEM_INIT_QP]; in bnxt_alloc_ctx_mem()
7424 ctx_pg = &ctx->srq_mem; in bnxt_alloc_ctx_mem()
7425 ctx_pg->entries = ctx->srq_max_l2_entries + extra_srqs; in bnxt_alloc_ctx_mem()
7426 if (ctx->srq_entry_size) { in bnxt_alloc_ctx_mem()
7427 mem_size = ctx->srq_entry_size * ctx_pg->entries; in bnxt_alloc_ctx_mem()
7428 init = &ctx->mem_init[BNXT_CTX_MEM_INIT_SRQ]; in bnxt_alloc_ctx_mem()
7434 ctx_pg = &ctx->cq_mem; in bnxt_alloc_ctx_mem()
7435 ctx_pg->entries = ctx->cq_max_l2_entries + extra_qps * 2; in bnxt_alloc_ctx_mem()
7436 if (ctx->cq_entry_size) { in bnxt_alloc_ctx_mem()
7437 mem_size = ctx->cq_entry_size * ctx_pg->entries; in bnxt_alloc_ctx_mem()
7438 init = &ctx->mem_init[BNXT_CTX_MEM_INIT_CQ]; in bnxt_alloc_ctx_mem()
7444 ctx_pg = &ctx->vnic_mem; in bnxt_alloc_ctx_mem()
7445 ctx_pg->entries = ctx->vnic_max_vnic_entries + in bnxt_alloc_ctx_mem()
7446 ctx->vnic_max_ring_table_entries; in bnxt_alloc_ctx_mem()
7447 if (ctx->vnic_entry_size) { in bnxt_alloc_ctx_mem()
7448 mem_size = ctx->vnic_entry_size * ctx_pg->entries; in bnxt_alloc_ctx_mem()
7449 init = &ctx->mem_init[BNXT_CTX_MEM_INIT_VNIC]; in bnxt_alloc_ctx_mem()
7455 ctx_pg = &ctx->stat_mem; in bnxt_alloc_ctx_mem()
7456 ctx_pg->entries = ctx->stat_max_entries; in bnxt_alloc_ctx_mem()
7457 if (ctx->stat_entry_size) { in bnxt_alloc_ctx_mem()
7458 mem_size = ctx->stat_entry_size * ctx_pg->entries; in bnxt_alloc_ctx_mem()
7459 init = &ctx->mem_init[BNXT_CTX_MEM_INIT_STAT]; in bnxt_alloc_ctx_mem()
7466 if (!(bp->flags & BNXT_FLAG_ROCE_CAP)) in bnxt_alloc_ctx_mem()
7469 ctx_pg = &ctx->mrav_mem; in bnxt_alloc_ctx_mem()
7475 ctx_pg->entries = num_mr + num_ah; in bnxt_alloc_ctx_mem()
7476 if (ctx->mrav_entry_size) { in bnxt_alloc_ctx_mem()
7477 mem_size = ctx->mrav_entry_size * ctx_pg->entries; in bnxt_alloc_ctx_mem()
7478 init = &ctx->mem_init[BNXT_CTX_MEM_INIT_MRAV]; in bnxt_alloc_ctx_mem()
7484 if (ctx->mrav_num_entries_units) in bnxt_alloc_ctx_mem()
7485 ctx_pg->entries = in bnxt_alloc_ctx_mem()
7486 ((num_mr / ctx->mrav_num_entries_units) << 16) | in bnxt_alloc_ctx_mem()
7487 (num_ah / ctx->mrav_num_entries_units); in bnxt_alloc_ctx_mem()
7489 ctx_pg = &ctx->tim_mem; in bnxt_alloc_ctx_mem()
7490 ctx_pg->entries = ctx->qp_mem.entries; in bnxt_alloc_ctx_mem()
7491 if (ctx->tim_entry_size) { in bnxt_alloc_ctx_mem()
7492 mem_size = ctx->tim_entry_size * ctx_pg->entries; in bnxt_alloc_ctx_mem()
7500 min = ctx->tqm_min_entries_per_ring; in bnxt_alloc_ctx_mem()
7501 entries_sp = ctx->vnic_max_vnic_entries + ctx->qp_max_l2_entries + in bnxt_alloc_ctx_mem()
7502 2 * (extra_qps + ctx->qp_min_qp1_entries) + min; in bnxt_alloc_ctx_mem()
7503 entries_sp = roundup(entries_sp, ctx->tqm_entries_multiple); in bnxt_alloc_ctx_mem()
7504 entries = ctx->qp_max_l2_entries + 2 * (extra_qps + ctx->qp_min_qp1_entries); in bnxt_alloc_ctx_mem()
7505 entries = roundup(entries, ctx->tqm_entries_multiple); in bnxt_alloc_ctx_mem()
7506 entries = clamp_t(u32, entries, min, ctx->tqm_max_entries_per_ring); in bnxt_alloc_ctx_mem()
7507 for (i = 0; i < ctx->tqm_fp_rings_count + 1; i++) { in bnxt_alloc_ctx_mem()
7508 ctx_pg = ctx->tqm_mem[i]; in bnxt_alloc_ctx_mem()
7509 ctx_pg->entries = i ? entries : entries_sp; in bnxt_alloc_ctx_mem()
7510 if (ctx->tqm_entry_size) { in bnxt_alloc_ctx_mem()
7511 mem_size = ctx->tqm_entry_size * ctx_pg->entries; in bnxt_alloc_ctx_mem()
7522 netdev_err(bp->dev, "Failed configuring context mem, rc = %d.\n", in bnxt_alloc_ctx_mem()
7526 ctx->flags |= BNXT_CTX_FLAG_INITED; in bnxt_alloc_ctx_mem()
7534 struct bnxt_hw_resc *hw_resc = &bp->hw_resc; in bnxt_hwrm_func_resc_qcaps()
7541 req->fid = cpu_to_le16(0xffff); in bnxt_hwrm_func_resc_qcaps()
7547 hw_resc->max_tx_sch_inputs = le16_to_cpu(resp->max_tx_scheduler_inputs); in bnxt_hwrm_func_resc_qcaps()
7551 hw_resc->min_rsscos_ctxs = le16_to_cpu(resp->min_rsscos_ctx); in bnxt_hwrm_func_resc_qcaps()
7552 hw_resc->max_rsscos_ctxs = le16_to_cpu(resp->max_rsscos_ctx); in bnxt_hwrm_func_resc_qcaps()
7553 hw_resc->min_cp_rings = le16_to_cpu(resp->min_cmpl_rings); in bnxt_hwrm_func_resc_qcaps()
7554 hw_resc->max_cp_rings = le16_to_cpu(resp->max_cmpl_rings); in bnxt_hwrm_func_resc_qcaps()
7555 hw_resc->min_tx_rings = le16_to_cpu(resp->min_tx_rings); in bnxt_hwrm_func_resc_qcaps()
7556 hw_resc->max_tx_rings = le16_to_cpu(resp->max_tx_rings); in bnxt_hwrm_func_resc_qcaps()
7557 hw_resc->min_rx_rings = le16_to_cpu(resp->min_rx_rings); in bnxt_hwrm_func_resc_qcaps()
7558 hw_resc->max_rx_rings = le16_to_cpu(resp->max_rx_rings); in bnxt_hwrm_func_resc_qcaps()
7559 hw_resc->min_hw_ring_grps = le16_to_cpu(resp->min_hw_ring_grps); in bnxt_hwrm_func_resc_qcaps()
7560 hw_resc->max_hw_ring_grps = le16_to_cpu(resp->max_hw_ring_grps); in bnxt_hwrm_func_resc_qcaps()
7561 hw_resc->min_l2_ctxs = le16_to_cpu(resp->min_l2_ctxs); in bnxt_hwrm_func_resc_qcaps()
7562 hw_resc->max_l2_ctxs = le16_to_cpu(resp->max_l2_ctxs); in bnxt_hwrm_func_resc_qcaps()
7563 hw_resc->min_vnics = le16_to_cpu(resp->min_vnics); in bnxt_hwrm_func_resc_qcaps()
7564 hw_resc->max_vnics = le16_to_cpu(resp->max_vnics); in bnxt_hwrm_func_resc_qcaps()
7565 hw_resc->min_stat_ctxs = le16_to_cpu(resp->min_stat_ctx); in bnxt_hwrm_func_resc_qcaps()
7566 hw_resc->max_stat_ctxs = le16_to_cpu(resp->max_stat_ctx); in bnxt_hwrm_func_resc_qcaps()
7568 if (bp->flags & BNXT_FLAG_CHIP_P5) { in bnxt_hwrm_func_resc_qcaps()
7569 u16 max_msix = le16_to_cpu(resp->max_msix); in bnxt_hwrm_func_resc_qcaps()
7571 hw_resc->max_nqs = max_msix; in bnxt_hwrm_func_resc_qcaps()
7572 hw_resc->max_hw_ring_grps = hw_resc->max_rx_rings; in bnxt_hwrm_func_resc_qcaps()
7576 struct bnxt_pf_info *pf = &bp->pf; in bnxt_hwrm_func_resc_qcaps()
7578 pf->vf_resv_strategy = in bnxt_hwrm_func_resc_qcaps()
7579 le16_to_cpu(resp->vf_reservation_strategy); in bnxt_hwrm_func_resc_qcaps()
7580 if (pf->vf_resv_strategy > BNXT_VF_RESV_STRATEGY_MINIMAL_STATIC) in bnxt_hwrm_func_resc_qcaps()
7581 pf->vf_resv_strategy = BNXT_VF_RESV_STRATEGY_MAXIMAL; in bnxt_hwrm_func_resc_qcaps()
7592 struct bnxt_ptp_cfg *ptp = bp->ptp_cfg; in __bnxt_hwrm_ptp_qcfg()
7597 if (bp->hwrm_spec_code < 0x10801) { in __bnxt_hwrm_ptp_qcfg()
7598 rc = -ENODEV; in __bnxt_hwrm_ptp_qcfg()
7606 req->port_id = cpu_to_le16(bp->pf.port_id); in __bnxt_hwrm_ptp_qcfg()
7612 flags = resp->flags; in __bnxt_hwrm_ptp_qcfg()
7614 rc = -ENODEV; in __bnxt_hwrm_ptp_qcfg()
7620 rc = -ENOMEM; in __bnxt_hwrm_ptp_qcfg()
7623 ptp->bp = bp; in __bnxt_hwrm_ptp_qcfg()
7624 bp->ptp_cfg = ptp; in __bnxt_hwrm_ptp_qcfg()
7627 ptp->refclk_regs[0] = le32_to_cpu(resp->ts_ref_clock_reg_lower); in __bnxt_hwrm_ptp_qcfg()
7628 ptp->refclk_regs[1] = le32_to_cpu(resp->ts_ref_clock_reg_upper); in __bnxt_hwrm_ptp_qcfg()
7629 } else if (bp->flags & BNXT_FLAG_CHIP_P5) { in __bnxt_hwrm_ptp_qcfg()
7630 ptp->refclk_regs[0] = BNXT_TS_REG_TIMESYNC_TS0_LOWER; in __bnxt_hwrm_ptp_qcfg()
7631 ptp->refclk_regs[1] = BNXT_TS_REG_TIMESYNC_TS0_UPPER; in __bnxt_hwrm_ptp_qcfg()
7633 rc = -ENODEV; in __bnxt_hwrm_ptp_qcfg()
7639 netdev_warn(bp->dev, "PTP initialization failed.\n"); in __bnxt_hwrm_ptp_qcfg()
7648 bp->ptp_cfg = NULL; in __bnxt_hwrm_ptp_qcfg()
7656 struct bnxt_hw_resc *hw_resc = &bp->hw_resc; in __bnxt_hwrm_func_qcaps()
7664 req->fid = cpu_to_le16(0xffff); in __bnxt_hwrm_func_qcaps()
7670 flags = le32_to_cpu(resp->flags); in __bnxt_hwrm_func_qcaps()
7672 bp->flags |= BNXT_FLAG_ROCEV1_CAP; in __bnxt_hwrm_func_qcaps()
7674 bp->flags |= BNXT_FLAG_ROCEV2_CAP; in __bnxt_hwrm_func_qcaps()
7676 bp->fw_cap |= BNXT_FW_CAP_PCIE_STATS_SUPPORTED; in __bnxt_hwrm_func_qcaps()
7678 bp->fw_cap |= BNXT_FW_CAP_HOT_RESET; in __bnxt_hwrm_func_qcaps()
7680 bp->fw_cap |= BNXT_FW_CAP_EXT_STATS_SUPPORTED; in __bnxt_hwrm_func_qcaps()
7682 bp->fw_cap |= BNXT_FW_CAP_ERROR_RECOVERY; in __bnxt_hwrm_func_qcaps()
7684 bp->fw_cap |= BNXT_FW_CAP_ERR_RECOVER_RELOAD; in __bnxt_hwrm_func_qcaps()
7686 bp->fw_cap |= BNXT_FW_CAP_VLAN_TX_INSERT; in __bnxt_hwrm_func_qcaps()
7688 bp->fw_cap |= BNXT_FW_CAP_DBG_QCAPS; in __bnxt_hwrm_func_qcaps()
7690 flags_ext = le32_to_cpu(resp->flags_ext); in __bnxt_hwrm_func_qcaps()
7692 bp->fw_cap |= BNXT_FW_CAP_EXT_HW_STATS_SUPPORTED; in __bnxt_hwrm_func_qcaps()
7694 bp->fw_cap |= BNXT_FW_CAP_PTP_PPS; in __bnxt_hwrm_func_qcaps()
7696 bp->fw_cap |= BNXT_FW_CAP_PTP_RTC; in __bnxt_hwrm_func_qcaps()
7698 bp->fw_cap |= BNXT_FW_CAP_HOT_RESET_IF; in __bnxt_hwrm_func_qcaps()
7700 bp->fw_cap |= BNXT_FW_CAP_LIVEPATCH; in __bnxt_hwrm_func_qcaps()
7702 flags_ext2 = le32_to_cpu(resp->flags_ext2); in __bnxt_hwrm_func_qcaps()
7704 bp->fw_cap |= BNXT_FW_CAP_RX_ALL_PKT_TS; in __bnxt_hwrm_func_qcaps()
7706 bp->tx_push_thresh = 0; in __bnxt_hwrm_func_qcaps()
7709 bp->tx_push_thresh = BNXT_TX_PUSH_THRESH; in __bnxt_hwrm_func_qcaps()
7711 hw_resc->max_rsscos_ctxs = le16_to_cpu(resp->max_rsscos_ctx); in __bnxt_hwrm_func_qcaps()
7712 hw_resc->max_cp_rings = le16_to_cpu(resp->max_cmpl_rings); in __bnxt_hwrm_func_qcaps()
7713 hw_resc->max_tx_rings = le16_to_cpu(resp->max_tx_rings); in __bnxt_hwrm_func_qcaps()
7714 hw_resc->max_rx_rings = le16_to_cpu(resp->max_rx_rings); in __bnxt_hwrm_func_qcaps()
7715 hw_resc->max_hw_ring_grps = le32_to_cpu(resp->max_hw_ring_grps); in __bnxt_hwrm_func_qcaps()
7716 if (!hw_resc->max_hw_ring_grps) in __bnxt_hwrm_func_qcaps()
7717 hw_resc->max_hw_ring_grps = hw_resc->max_tx_rings; in __bnxt_hwrm_func_qcaps()
7718 hw_resc->max_l2_ctxs = le16_to_cpu(resp->max_l2_ctxs); in __bnxt_hwrm_func_qcaps()
7719 hw_resc->max_vnics = le16_to_cpu(resp->max_vnics); in __bnxt_hwrm_func_qcaps()
7720 hw_resc->max_stat_ctxs = le16_to_cpu(resp->max_stat_ctx); in __bnxt_hwrm_func_qcaps()
7723 struct bnxt_pf_info *pf = &bp->pf; in __bnxt_hwrm_func_qcaps()
7725 pf->fw_fid = le16_to_cpu(resp->fid); in __bnxt_hwrm_func_qcaps()
7726 pf->port_id = le16_to_cpu(resp->port_id); in __bnxt_hwrm_func_qcaps()
7727 memcpy(pf->mac_addr, resp->mac_address, ETH_ALEN); in __bnxt_hwrm_func_qcaps()
7728 pf->first_vf_id = le16_to_cpu(resp->first_vf_id); in __bnxt_hwrm_func_qcaps()
7729 pf->max_vfs = le16_to_cpu(resp->max_vfs); in __bnxt_hwrm_func_qcaps()
7730 pf->max_encap_records = le32_to_cpu(resp->max_encap_records); in __bnxt_hwrm_func_qcaps()
7731 pf->max_decap_records = le32_to_cpu(resp->max_decap_records); in __bnxt_hwrm_func_qcaps()
7732 pf->max_tx_em_flows = le32_to_cpu(resp->max_tx_em_flows); in __bnxt_hwrm_func_qcaps()
7733 pf->max_tx_wm_flows = le32_to_cpu(resp->max_tx_wm_flows); in __bnxt_hwrm_func_qcaps()
7734 pf->max_rx_em_flows = le32_to_cpu(resp->max_rx_em_flows); in __bnxt_hwrm_func_qcaps()
7735 pf->max_rx_wm_flows = le32_to_cpu(resp->max_rx_wm_flows); in __bnxt_hwrm_func_qcaps()
7736 bp->flags &= ~BNXT_FLAG_WOL_CAP; in __bnxt_hwrm_func_qcaps()
7738 bp->flags |= BNXT_FLAG_WOL_CAP; in __bnxt_hwrm_func_qcaps()
7743 kfree(bp->ptp_cfg); in __bnxt_hwrm_func_qcaps()
7744 bp->ptp_cfg = NULL; in __bnxt_hwrm_func_qcaps()
7748 struct bnxt_vf_info *vf = &bp->vf; in __bnxt_hwrm_func_qcaps()
7750 vf->fw_fid = le16_to_cpu(resp->fid); in __bnxt_hwrm_func_qcaps()
7751 memcpy(vf->mac_addr, resp->mac_address, ETH_ALEN); in __bnxt_hwrm_func_qcaps()
7766 bp->fw_dbg_cap = 0; in bnxt_hwrm_dbg_qcaps()
7767 if (!(bp->fw_cap & BNXT_FW_CAP_DBG_QCAPS)) in bnxt_hwrm_dbg_qcaps()
7774 req->fid = cpu_to_le16(0xffff); in bnxt_hwrm_dbg_qcaps()
7780 bp->fw_dbg_cap = le32_to_cpu(resp->flags); in bnxt_hwrm_dbg_qcaps()
7800 netdev_err(bp->dev, "hwrm query qportcfg failure rc: %d\n", rc); in bnxt_hwrm_func_qcaps()
7803 if (bp->hwrm_spec_code >= 0x10803) { in bnxt_hwrm_func_qcaps()
7809 bp->fw_cap |= BNXT_FW_CAP_NEW_RM; in bnxt_hwrm_func_qcaps()
7821 if (!(bp->fw_cap & BNXT_FW_CAP_CFA_ADV_FLOW)) in bnxt_hwrm_cfa_adv_flow_mgnt_qcaps()
7833 flags = le32_to_cpu(resp->flags); in bnxt_hwrm_cfa_adv_flow_mgnt_qcaps()
7836 bp->fw_cap |= BNXT_FW_CAP_CFA_RFS_RING_TBL_IDX_V2; in bnxt_hwrm_cfa_adv_flow_mgnt_qcaps()
7845 if (bp->fw_health) in __bnxt_alloc_fw_health()
7848 bp->fw_health = kzalloc(sizeof(*bp->fw_health), GFP_KERNEL); in __bnxt_alloc_fw_health()
7849 if (!bp->fw_health) in __bnxt_alloc_fw_health()
7850 return -ENOMEM; in __bnxt_alloc_fw_health()
7852 mutex_init(&bp->fw_health->lock); in __bnxt_alloc_fw_health()
7860 if (!(bp->fw_cap & BNXT_FW_CAP_HOT_RESET) && in bnxt_alloc_fw_health()
7861 !(bp->fw_cap & BNXT_FW_CAP_ERROR_RECOVERY)) in bnxt_alloc_fw_health()
7866 bp->fw_cap &= ~BNXT_FW_CAP_HOT_RESET; in bnxt_alloc_fw_health()
7867 bp->fw_cap &= ~BNXT_FW_CAP_ERROR_RECOVERY; in bnxt_alloc_fw_health()
7876 writel(reg & BNXT_GRC_BASE_MASK, bp->bar0 + in __bnxt_map_fw_health_reg()
7883 struct bnxt_fw_health *fw_health = bp->fw_health; in bnxt_inv_fw_health_reg()
7889 reg_type = BNXT_FW_HEALTH_REG_TYPE(fw_health->regs[BNXT_FW_HEALTH_REG]); in bnxt_inv_fw_health_reg()
7891 fw_health->status_reliable = false; in bnxt_inv_fw_health_reg()
7893 reg_type = BNXT_FW_HEALTH_REG_TYPE(fw_health->regs[BNXT_FW_RESET_CNT_REG]); in bnxt_inv_fw_health_reg()
7895 fw_health->resets_reliable = false; in bnxt_inv_fw_health_reg()
7905 if (bp->fw_health) in bnxt_try_map_fw_health_reg()
7906 bp->fw_health->status_reliable = false; in bnxt_try_map_fw_health_reg()
7909 hs = bp->bar0 + BNXT_FW_HEALTH_WIN_OFF(HCOMM_STATUS_STRUCT_LOC); in bnxt_try_map_fw_health_reg()
7913 if (!bp->chip_num) { in bnxt_try_map_fw_health_reg()
7915 bp->chip_num = readl(bp->bar0 + in bnxt_try_map_fw_health_reg()
7930 netdev_warn(bp->dev, "no memory for firmware status checks\n"); in bnxt_try_map_fw_health_reg()
7934 bp->fw_health->regs[BNXT_FW_HEALTH_REG] = status_loc; in bnxt_try_map_fw_health_reg()
7938 bp->fw_health->mapped_regs[BNXT_FW_HEALTH_REG] = in bnxt_try_map_fw_health_reg()
7942 bp->fw_health->status_reliable = true; in bnxt_try_map_fw_health_reg()
7947 struct bnxt_fw_health *fw_health = bp->fw_health; in bnxt_map_fw_health_regs()
7951 bp->fw_health->status_reliable = false; in bnxt_map_fw_health_regs()
7952 bp->fw_health->resets_reliable = false; in bnxt_map_fw_health_regs()
7953 /* Only pre-map the monitoring GRC registers using window 3 */ in bnxt_map_fw_health_regs()
7955 u32 reg = fw_health->regs[i]; in bnxt_map_fw_health_regs()
7962 return -ERANGE; in bnxt_map_fw_health_regs()
7963 fw_health->mapped_regs[i] = BNXT_FW_HEALTH_WIN_OFF(reg); in bnxt_map_fw_health_regs()
7965 bp->fw_health->status_reliable = true; in bnxt_map_fw_health_regs()
7966 bp->fw_health->resets_reliable = true; in bnxt_map_fw_health_regs()
7976 if (!bp->fw_health) in bnxt_remap_fw_health_regs()
7979 if (bp->fw_cap & BNXT_FW_CAP_ERROR_RECOVERY) { in bnxt_remap_fw_health_regs()
7980 bp->fw_health->status_reliable = true; in bnxt_remap_fw_health_regs()
7981 bp->fw_health->resets_reliable = true; in bnxt_remap_fw_health_regs()
7989 struct bnxt_fw_health *fw_health = bp->fw_health; in bnxt_hwrm_error_recovery_qcfg()
7994 if (!(bp->fw_cap & BNXT_FW_CAP_ERROR_RECOVERY)) in bnxt_hwrm_error_recovery_qcfg()
8005 fw_health->flags = le32_to_cpu(resp->flags); in bnxt_hwrm_error_recovery_qcfg()
8006 if ((fw_health->flags & ERROR_RECOVERY_QCFG_RESP_FLAGS_CO_CPU) && in bnxt_hwrm_error_recovery_qcfg()
8007 !(bp->fw_cap & BNXT_FW_CAP_KONG_MB_CHNL)) { in bnxt_hwrm_error_recovery_qcfg()
8008 rc = -EINVAL; in bnxt_hwrm_error_recovery_qcfg()
8011 fw_health->polling_dsecs = le32_to_cpu(resp->driver_polling_freq); in bnxt_hwrm_error_recovery_qcfg()
8012 fw_health->master_func_wait_dsecs = in bnxt_hwrm_error_recovery_qcfg()
8013 le32_to_cpu(resp->master_func_wait_period); in bnxt_hwrm_error_recovery_qcfg()
8014 fw_health->normal_func_wait_dsecs = in bnxt_hwrm_error_recovery_qcfg()
8015 le32_to_cpu(resp->normal_func_wait_period); in bnxt_hwrm_error_recovery_qcfg()
8016 fw_health->post_reset_wait_dsecs = in bnxt_hwrm_error_recovery_qcfg()
8017 le32_to_cpu(resp->master_func_wait_period_after_reset); in bnxt_hwrm_error_recovery_qcfg()
8018 fw_health->post_reset_max_wait_dsecs = in bnxt_hwrm_error_recovery_qcfg()
8019 le32_to_cpu(resp->max_bailout_time_after_reset); in bnxt_hwrm_error_recovery_qcfg()
8020 fw_health->regs[BNXT_FW_HEALTH_REG] = in bnxt_hwrm_error_recovery_qcfg()
8021 le32_to_cpu(resp->fw_health_status_reg); in bnxt_hwrm_error_recovery_qcfg()
8022 fw_health->regs[BNXT_FW_HEARTBEAT_REG] = in bnxt_hwrm_error_recovery_qcfg()
8023 le32_to_cpu(resp->fw_heartbeat_reg); in bnxt_hwrm_error_recovery_qcfg()
8024 fw_health->regs[BNXT_FW_RESET_CNT_REG] = in bnxt_hwrm_error_recovery_qcfg()
8025 le32_to_cpu(resp->fw_reset_cnt_reg); in bnxt_hwrm_error_recovery_qcfg()
8026 fw_health->regs[BNXT_FW_RESET_INPROG_REG] = in bnxt_hwrm_error_recovery_qcfg()
8027 le32_to_cpu(resp->reset_inprogress_reg); in bnxt_hwrm_error_recovery_qcfg()
8028 fw_health->fw_reset_inprog_reg_mask = in bnxt_hwrm_error_recovery_qcfg()
8029 le32_to_cpu(resp->reset_inprogress_reg_mask); in bnxt_hwrm_error_recovery_qcfg()
8030 fw_health->fw_reset_seq_cnt = resp->reg_array_cnt; in bnxt_hwrm_error_recovery_qcfg()
8031 if (fw_health->fw_reset_seq_cnt >= 16) { in bnxt_hwrm_error_recovery_qcfg()
8032 rc = -EINVAL; in bnxt_hwrm_error_recovery_qcfg()
8035 for (i = 0; i < fw_health->fw_reset_seq_cnt; i++) { in bnxt_hwrm_error_recovery_qcfg()
8036 fw_health->fw_reset_seq_regs[i] = in bnxt_hwrm_error_recovery_qcfg()
8037 le32_to_cpu(resp->reset_reg[i]); in bnxt_hwrm_error_recovery_qcfg()
8038 fw_health->fw_reset_seq_vals[i] = in bnxt_hwrm_error_recovery_qcfg()
8039 le32_to_cpu(resp->reset_reg_val[i]); in bnxt_hwrm_error_recovery_qcfg()
8040 fw_health->fw_reset_seq_delay_msec[i] = in bnxt_hwrm_error_recovery_qcfg()
8041 resp->delay_after_reset[i]; in bnxt_hwrm_error_recovery_qcfg()
8048 bp->fw_cap &= ~BNXT_FW_CAP_ERROR_RECOVERY; in bnxt_hwrm_error_recovery_qcfg()
8061 req->enables = 0; in bnxt_hwrm_func_reset()
8071 snprintf(bp->nvm_cfg_ver, FW_VER_STR_LEN, "%d.%d.%d", in bnxt_nvm_cfg_ver_get()
8093 if (!resp->max_configurable_queues) { in bnxt_hwrm_queue_qportcfg()
8094 rc = -EINVAL; in bnxt_hwrm_queue_qportcfg()
8097 bp->max_tc = resp->max_configurable_queues; in bnxt_hwrm_queue_qportcfg()
8098 bp->max_lltc = resp->max_configurable_lossless_queues; in bnxt_hwrm_queue_qportcfg()
8099 if (bp->max_tc > BNXT_MAX_QUEUE) in bnxt_hwrm_queue_qportcfg()
8100 bp->max_tc = BNXT_MAX_QUEUE; in bnxt_hwrm_queue_qportcfg()
8102 no_rdma = !(bp->flags & BNXT_FLAG_ROCE_CAP); in bnxt_hwrm_queue_qportcfg()
8103 qptr = &resp->queue_id0; in bnxt_hwrm_queue_qportcfg()
8104 for (i = 0, j = 0; i < bp->max_tc; i++) { in bnxt_hwrm_queue_qportcfg()
8105 bp->q_info[j].queue_id = *qptr; in bnxt_hwrm_queue_qportcfg()
8106 bp->q_ids[i] = *qptr++; in bnxt_hwrm_queue_qportcfg()
8107 bp->q_info[j].queue_profile = *qptr++; in bnxt_hwrm_queue_qportcfg()
8108 bp->tc_to_qidx[j] = j; in bnxt_hwrm_queue_qportcfg()
8109 if (!BNXT_CNPQ(bp->q_info[j].queue_profile) || in bnxt_hwrm_queue_qportcfg()
8113 bp->max_q = bp->max_tc; in bnxt_hwrm_queue_qportcfg()
8114 bp->max_tc = max_t(u8, j, 1); in bnxt_hwrm_queue_qportcfg()
8116 if (resp->queue_cfg_info & QUEUE_QPORTCFG_RESP_QUEUE_CFG_INFO_ASYM_CFG) in bnxt_hwrm_queue_qportcfg()
8117 bp->max_tc = 1; in bnxt_hwrm_queue_qportcfg()
8119 if (bp->max_lltc > bp->max_tc) in bnxt_hwrm_queue_qportcfg()
8120 bp->max_lltc = bp->max_tc; in bnxt_hwrm_queue_qportcfg()
8136 req->hwrm_intf_maj = HWRM_VERSION_MAJOR; in bnxt_hwrm_poll()
8137 req->hwrm_intf_min = HWRM_VERSION_MINOR; in bnxt_hwrm_poll()
8138 req->hwrm_intf_upd = HWRM_VERSION_UPDATE; in bnxt_hwrm_poll()
8158 bp->hwrm_max_req_len = HWRM_MAX_REQ_LEN; in bnxt_hwrm_ver_get()
8159 req->hwrm_intf_maj = HWRM_VERSION_MAJOR; in bnxt_hwrm_ver_get()
8160 req->hwrm_intf_min = HWRM_VERSION_MINOR; in bnxt_hwrm_ver_get()
8161 req->hwrm_intf_upd = HWRM_VERSION_UPDATE; in bnxt_hwrm_ver_get()
8168 memcpy(&bp->ver_resp, resp, sizeof(struct hwrm_ver_get_output)); in bnxt_hwrm_ver_get()
8170 bp->hwrm_spec_code = resp->hwrm_intf_maj_8b << 16 | in bnxt_hwrm_ver_get()
8171 resp->hwrm_intf_min_8b << 8 | in bnxt_hwrm_ver_get()
8172 resp->hwrm_intf_upd_8b; in bnxt_hwrm_ver_get()
8173 if (resp->hwrm_intf_maj_8b < 1) { in bnxt_hwrm_ver_get()
8174 netdev_warn(bp->dev, "HWRM interface %d.%d.%d is older than 1.0.0.\n", in bnxt_hwrm_ver_get()
8175 resp->hwrm_intf_maj_8b, resp->hwrm_intf_min_8b, in bnxt_hwrm_ver_get()
8176 resp->hwrm_intf_upd_8b); in bnxt_hwrm_ver_get()
8177 netdev_warn(bp->dev, "Please update firmware with HWRM interface 1.0.0 or newer.\n"); in bnxt_hwrm_ver_get()
8183 if (bp->hwrm_spec_code > hwrm_ver) in bnxt_hwrm_ver_get()
8184 snprintf(bp->hwrm_ver_supp, FW_VER_STR_LEN, "%d.%d.%d", in bnxt_hwrm_ver_get()
8188 snprintf(bp->hwrm_ver_supp, FW_VER_STR_LEN, "%d.%d.%d", in bnxt_hwrm_ver_get()
8189 resp->hwrm_intf_maj_8b, resp->hwrm_intf_min_8b, in bnxt_hwrm_ver_get()
8190 resp->hwrm_intf_upd_8b); in bnxt_hwrm_ver_get()
8192 fw_maj = le16_to_cpu(resp->hwrm_fw_major); in bnxt_hwrm_ver_get()
8193 if (bp->hwrm_spec_code > 0x10803 && fw_maj) { in bnxt_hwrm_ver_get()
8194 fw_min = le16_to_cpu(resp->hwrm_fw_minor); in bnxt_hwrm_ver_get()
8195 fw_bld = le16_to_cpu(resp->hwrm_fw_build); in bnxt_hwrm_ver_get()
8196 fw_rsv = le16_to_cpu(resp->hwrm_fw_patch); in bnxt_hwrm_ver_get()
8199 fw_maj = resp->hwrm_fw_maj_8b; in bnxt_hwrm_ver_get()
8200 fw_min = resp->hwrm_fw_min_8b; in bnxt_hwrm_ver_get()
8201 fw_bld = resp->hwrm_fw_bld_8b; in bnxt_hwrm_ver_get()
8202 fw_rsv = resp->hwrm_fw_rsvd_8b; in bnxt_hwrm_ver_get()
8205 bp->fw_ver_code = BNXT_FW_VER_CODE(fw_maj, fw_min, fw_bld, fw_rsv); in bnxt_hwrm_ver_get()
8206 snprintf(bp->fw_ver_str, len, "%d.%d.%d.%d", fw_maj, fw_min, fw_bld, in bnxt_hwrm_ver_get()
8209 if (strlen(resp->active_pkg_name)) { in bnxt_hwrm_ver_get()
8210 int fw_ver_len = strlen(bp->fw_ver_str); in bnxt_hwrm_ver_get()
8212 snprintf(bp->fw_ver_str + fw_ver_len, in bnxt_hwrm_ver_get()
8213 FW_VER_STR_LEN - fw_ver_len - 1, "/pkg %s", in bnxt_hwrm_ver_get()
8214 resp->active_pkg_name); in bnxt_hwrm_ver_get()
8215 bp->fw_cap |= BNXT_FW_CAP_PKG_VER; in bnxt_hwrm_ver_get()
8218 bp->hwrm_cmd_timeout = le16_to_cpu(resp->def_req_timeout); in bnxt_hwrm_ver_get()
8219 if (!bp->hwrm_cmd_timeout) in bnxt_hwrm_ver_get()
8220 bp->hwrm_cmd_timeout = DFLT_HWRM_CMD_TIMEOUT; in bnxt_hwrm_ver_get()
8221 bp->hwrm_cmd_max_timeout = le16_to_cpu(resp->max_req_timeout) * 1000; in bnxt_hwrm_ver_get()
8222 if (!bp->hwrm_cmd_max_timeout) in bnxt_hwrm_ver_get()
8223 bp->hwrm_cmd_max_timeout = HWRM_CMD_MAX_TIMEOUT; in bnxt_hwrm_ver_get()
8224 else if (bp->hwrm_cmd_max_timeout > HWRM_CMD_MAX_TIMEOUT) in bnxt_hwrm_ver_get()
8225 …netdev_warn(bp->dev, "Device requests max timeout of %d seconds, may trigger hung task watchdog\n", in bnxt_hwrm_ver_get()
8226 bp->hwrm_cmd_max_timeout / 1000); in bnxt_hwrm_ver_get()
8228 if (resp->hwrm_intf_maj_8b >= 1) { in bnxt_hwrm_ver_get()
8229 bp->hwrm_max_req_len = le16_to_cpu(resp->max_req_win_len); in bnxt_hwrm_ver_get()
8230 bp->hwrm_max_ext_req_len = le16_to_cpu(resp->max_ext_req_len); in bnxt_hwrm_ver_get()
8232 if (bp->hwrm_max_ext_req_len < HWRM_MAX_REQ_LEN) in bnxt_hwrm_ver_get()
8233 bp->hwrm_max_ext_req_len = HWRM_MAX_REQ_LEN; in bnxt_hwrm_ver_get()
8235 bp->chip_num = le16_to_cpu(resp->chip_num); in bnxt_hwrm_ver_get()
8236 bp->chip_rev = resp->chip_rev; in bnxt_hwrm_ver_get()
8237 if (bp->chip_num == CHIP_NUM_58700 && !resp->chip_rev && in bnxt_hwrm_ver_get()
8238 !resp->chip_metal) in bnxt_hwrm_ver_get()
8239 bp->flags |= BNXT_FLAG_CHIP_NITRO_A0; in bnxt_hwrm_ver_get()
8241 dev_caps_cfg = le32_to_cpu(resp->dev_caps_cfg); in bnxt_hwrm_ver_get()
8244 bp->fw_cap |= BNXT_FW_CAP_SHORT_CMD; in bnxt_hwrm_ver_get()
8247 bp->fw_cap |= BNXT_FW_CAP_KONG_MB_CHNL; in bnxt_hwrm_ver_get()
8251 bp->fw_cap |= BNXT_FW_CAP_OVS_64BIT_HANDLE; in bnxt_hwrm_ver_get()
8255 bp->fw_cap |= BNXT_FW_CAP_TRUSTED_VF; in bnxt_hwrm_ver_get()
8259 bp->fw_cap |= BNXT_FW_CAP_CFA_ADV_FLOW; in bnxt_hwrm_ver_get()
8273 if ((BNXT_VF(bp) && bp->hwrm_spec_code < 0x10901) || in bnxt_hwrm_fw_set_time()
8274 bp->hwrm_spec_code < 0x10400) in bnxt_hwrm_fw_set_time()
8275 return -EOPNOTSUPP; in bnxt_hwrm_fw_set_time()
8282 req->year = cpu_to_le16(1900 + tm.tm_year); in bnxt_hwrm_fw_set_time()
8283 req->month = 1 + tm.tm_mon; in bnxt_hwrm_fw_set_time()
8284 req->day = tm.tm_mday; in bnxt_hwrm_fw_set_time()
8285 req->hour = tm.tm_hour; in bnxt_hwrm_fw_set_time()
8286 req->minute = tm.tm_min; in bnxt_hwrm_fw_set_time()
8287 req->second = tm.tm_sec; in bnxt_hwrm_fw_set_time()
8313 if (masks[i] == -1ULL) in __bnxt_accumulate_stats()
8322 if (!stats->hw_stats) in bnxt_accumulate_stats()
8325 __bnxt_accumulate_stats(stats->hw_stats, stats->sw_stats, in bnxt_accumulate_stats()
8326 stats->hw_masks, stats->len / 8, false); in bnxt_accumulate_stats()
8336 if (bp->flags & BNXT_FLAG_CHIP_P5) in bnxt_accumulate_all_stats()
8339 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_accumulate_all_stats()
8340 struct bnxt_napi *bnapi = bp->bnapi[i]; in bnxt_accumulate_all_stats()
8344 cpr = &bnapi->cp_ring; in bnxt_accumulate_all_stats()
8345 stats = &cpr->stats; in bnxt_accumulate_all_stats()
8348 __bnxt_accumulate_stats(stats->hw_stats, stats->sw_stats, in bnxt_accumulate_all_stats()
8349 ring0_stats->hw_masks, in bnxt_accumulate_all_stats()
8350 ring0_stats->len / 8, ignore_zero); in bnxt_accumulate_all_stats()
8352 if (bp->flags & BNXT_FLAG_PORT_STATS) { in bnxt_accumulate_all_stats()
8353 struct bnxt_stats_mem *stats = &bp->port_stats; in bnxt_accumulate_all_stats()
8354 __le64 *hw_stats = stats->hw_stats; in bnxt_accumulate_all_stats()
8355 u64 *sw_stats = stats->sw_stats; in bnxt_accumulate_all_stats()
8356 u64 *masks = stats->hw_masks; in bnxt_accumulate_all_stats()
8368 if (bp->flags & BNXT_FLAG_PORT_STATS_EXT) { in bnxt_accumulate_all_stats()
8369 bnxt_accumulate_stats(&bp->rx_port_stats_ext); in bnxt_accumulate_all_stats()
8370 bnxt_accumulate_stats(&bp->tx_port_stats_ext); in bnxt_accumulate_all_stats()
8377 struct bnxt_pf_info *pf = &bp->pf; in bnxt_hwrm_port_qstats()
8380 if (!(bp->flags & BNXT_FLAG_PORT_STATS)) in bnxt_hwrm_port_qstats()
8383 if (flags && !(bp->fw_cap & BNXT_FW_CAP_EXT_HW_STATS_SUPPORTED)) in bnxt_hwrm_port_qstats()
8384 return -EOPNOTSUPP; in bnxt_hwrm_port_qstats()
8390 req->flags = flags; in bnxt_hwrm_port_qstats()
8391 req->port_id = cpu_to_le16(pf->port_id); in bnxt_hwrm_port_qstats()
8392 req->tx_stat_host_addr = cpu_to_le64(bp->port_stats.hw_stats_map + in bnxt_hwrm_port_qstats()
8394 req->rx_stat_host_addr = cpu_to_le64(bp->port_stats.hw_stats_map); in bnxt_hwrm_port_qstats()
8404 struct bnxt_pf_info *pf = &bp->pf; in bnxt_hwrm_port_qstats_ext()
8408 if (!(bp->flags & BNXT_FLAG_PORT_STATS_EXT)) in bnxt_hwrm_port_qstats_ext()
8411 if (flags && !(bp->fw_cap & BNXT_FW_CAP_EXT_HW_STATS_SUPPORTED)) in bnxt_hwrm_port_qstats_ext()
8412 return -EOPNOTSUPP; in bnxt_hwrm_port_qstats_ext()
8418 req_qs->flags = flags; in bnxt_hwrm_port_qstats_ext()
8419 req_qs->port_id = cpu_to_le16(pf->port_id); in bnxt_hwrm_port_qstats_ext()
8420 req_qs->rx_stat_size = cpu_to_le16(sizeof(struct rx_port_stats_ext)); in bnxt_hwrm_port_qstats_ext()
8421 req_qs->rx_stat_host_addr = cpu_to_le64(bp->rx_port_stats_ext.hw_stats_map); in bnxt_hwrm_port_qstats_ext()
8422 tx_stat_size = bp->tx_port_stats_ext.hw_stats ? in bnxt_hwrm_port_qstats_ext()
8424 req_qs->tx_stat_size = cpu_to_le16(tx_stat_size); in bnxt_hwrm_port_qstats_ext()
8425 req_qs->tx_stat_host_addr = cpu_to_le64(bp->tx_port_stats_ext.hw_stats_map); in bnxt_hwrm_port_qstats_ext()
8429 bp->fw_rx_stats_ext_size = in bnxt_hwrm_port_qstats_ext()
8430 le16_to_cpu(resp_qs->rx_stat_size) / 8; in bnxt_hwrm_port_qstats_ext()
8432 bp->fw_rx_stats_ext_size > BNXT_RX_STATS_EXT_NUM_LEGACY) in bnxt_hwrm_port_qstats_ext()
8433 bp->fw_rx_stats_ext_size = BNXT_RX_STATS_EXT_NUM_LEGACY; in bnxt_hwrm_port_qstats_ext()
8435 bp->fw_tx_stats_ext_size = tx_stat_size ? in bnxt_hwrm_port_qstats_ext()
8436 le16_to_cpu(resp_qs->tx_stat_size) / 8 : 0; in bnxt_hwrm_port_qstats_ext()
8438 bp->fw_rx_stats_ext_size = 0; in bnxt_hwrm_port_qstats_ext()
8439 bp->fw_tx_stats_ext_size = 0; in bnxt_hwrm_port_qstats_ext()
8446 if (bp->fw_tx_stats_ext_size <= in bnxt_hwrm_port_qstats_ext()
8448 bp->pri2cos_valid = 0; in bnxt_hwrm_port_qstats_ext()
8456 req_qc->flags = cpu_to_le32(QUEUE_PRI2COS_QCFG_REQ_FLAGS_IVLAN); in bnxt_hwrm_port_qstats_ext()
8464 pri2cos = &resp_qc->pri0_cos_queue_id; in bnxt_hwrm_port_qstats_ext()
8472 bp->pri2cos_valid = false; in bnxt_hwrm_port_qstats_ext()
8476 for (j = 0; j < bp->max_q; j++) { in bnxt_hwrm_port_qstats_ext()
8477 if (bp->q_ids[j] == queue_id) in bnxt_hwrm_port_qstats_ext()
8478 bp->pri2cos_idx[i] = queue_idx; in bnxt_hwrm_port_qstats_ext()
8481 bp->pri2cos_valid = true; in bnxt_hwrm_port_qstats_ext()
8502 tpa_flags = bp->flags & BNXT_FLAG_TPA; in bnxt_set_tpa()
8505 for (i = 0; i < bp->nr_vnics; i++) { in bnxt_set_tpa()
8508 netdev_err(bp->dev, "hwrm vnic set tpa failure rc for vnic %d: %x\n", in bnxt_set_tpa()
8520 for (i = 0; i < bp->nr_vnics; i++) in bnxt_hwrm_clear_vnic_rss()
8526 if (!bp->vnic_info) in bnxt_clear_vnic()
8530 if (!(bp->flags & BNXT_FLAG_CHIP_P5)) { in bnxt_clear_vnic()
8536 if (bp->flags & BNXT_FLAG_TPA) in bnxt_clear_vnic()
8539 if (bp->flags & BNXT_FLAG_CHIP_P5) in bnxt_clear_vnic()
8566 return -EINVAL; in bnxt_hwrm_set_br_mode()
8572 req->fid = cpu_to_le16(0xffff); in bnxt_hwrm_set_br_mode()
8573 req->enables = cpu_to_le32(FUNC_CFG_REQ_ENABLES_EVB_MODE); in bnxt_hwrm_set_br_mode()
8574 req->evb_mode = evb_mode; in bnxt_hwrm_set_br_mode()
8583 if (BNXT_VF(bp) || bp->hwrm_spec_code < 0x10803) in bnxt_hwrm_set_cache_line_size()
8590 req->fid = cpu_to_le16(0xffff); in bnxt_hwrm_set_cache_line_size()
8591 req->enables = cpu_to_le32(FUNC_CFG_REQ_ENABLES_CACHE_LINESIZE); in bnxt_hwrm_set_cache_line_size()
8592 req->options = FUNC_CFG_REQ_OPTIONS_CACHE_LINESIZE_SIZE_64; in bnxt_hwrm_set_cache_line_size()
8594 req->options = FUNC_CFG_REQ_OPTIONS_CACHE_LINESIZE_SIZE_128; in bnxt_hwrm_set_cache_line_size()
8601 struct bnxt_vnic_info *vnic = &bp->vnic_info[vnic_id]; in __bnxt_setup_vnic()
8604 if (vnic->flags & BNXT_VNIC_RFS_NEW_RSS_FLAG) in __bnxt_setup_vnic()
8610 netdev_err(bp->dev, "hwrm vnic %d alloc failure rc: %x\n", in __bnxt_setup_vnic()
8614 bp->rsscos_nr_ctxs++; in __bnxt_setup_vnic()
8619 netdev_err(bp->dev, "hwrm vnic %d cos ctx alloc failure rc: %x\n", in __bnxt_setup_vnic()
8623 bp->rsscos_nr_ctxs++; in __bnxt_setup_vnic()
8630 netdev_err(bp->dev, "hwrm vnic %d cfg failure rc: %x\n", in __bnxt_setup_vnic()
8638 netdev_err(bp->dev, "hwrm vnic %d set rss failure rc: %x\n", in __bnxt_setup_vnic()
8643 if (bp->flags & BNXT_FLAG_AGG_RINGS) { in __bnxt_setup_vnic()
8646 netdev_err(bp->dev, "hwrm vnic %d set hds failure rc: %x\n", in __bnxt_setup_vnic()
8659 nr_ctxs = bnxt_get_nr_rss_ctxs(bp, bp->rx_nr_rings); in __bnxt_setup_vnic_p5()
8663 netdev_err(bp->dev, "hwrm vnic %d ctx %d alloc failure rc: %x\n", in __bnxt_setup_vnic_p5()
8667 bp->rsscos_nr_ctxs++; in __bnxt_setup_vnic_p5()
8670 return -ENOMEM; in __bnxt_setup_vnic_p5()
8674 netdev_err(bp->dev, "hwrm vnic %d set rss failure rc: %d\n", in __bnxt_setup_vnic_p5()
8680 netdev_err(bp->dev, "hwrm vnic %d cfg failure rc: %x\n", in __bnxt_setup_vnic_p5()
8684 if (bp->flags & BNXT_FLAG_AGG_RINGS) { in __bnxt_setup_vnic_p5()
8687 netdev_err(bp->dev, "hwrm vnic %d set hds failure rc: %x\n", in __bnxt_setup_vnic_p5()
8696 if (bp->flags & BNXT_FLAG_CHIP_P5) in bnxt_setup_vnic()
8707 if (bp->flags & BNXT_FLAG_CHIP_P5) in bnxt_alloc_rfs_vnics()
8710 for (i = 0; i < bp->rx_nr_rings; i++) { in bnxt_alloc_rfs_vnics()
8715 if (vnic_id >= bp->nr_vnics) in bnxt_alloc_rfs_vnics()
8718 vnic = &bp->vnic_info[vnic_id]; in bnxt_alloc_rfs_vnics()
8719 vnic->flags |= BNXT_VNIC_RFS_FLAG; in bnxt_alloc_rfs_vnics()
8720 if (bp->flags & BNXT_FLAG_NEW_RSS_CAP) in bnxt_alloc_rfs_vnics()
8721 vnic->flags |= BNXT_VNIC_RFS_NEW_RSS_FLAG; in bnxt_alloc_rfs_vnics()
8724 netdev_err(bp->dev, "hwrm vnic %d alloc failure rc: %x\n", in bnxt_alloc_rfs_vnics()
8742 if (BNXT_VF(bp) && !bp->vf.vlan && !bnxt_is_trusted_vf(bp, &bp->vf)) in bnxt_promisc_ok()
8752 rc = bnxt_hwrm_vnic_alloc(bp, 1, bp->rx_nr_rings - 1, 1); in bnxt_setup_nitroa0_vnic()
8754 netdev_err(bp->dev, "Cannot allocate special vnic for NS2 A0: %x\n", in bnxt_setup_nitroa0_vnic()
8761 netdev_err(bp->dev, "Cannot allocate special vnic for NS2 A0: %x\n", in bnxt_setup_nitroa0_vnic()
8773 struct bnxt_vnic_info *vnic = &bp->vnic_info[0]; in bnxt_init_chip()
8775 unsigned int rx_nr_rings = bp->rx_nr_rings; in bnxt_init_chip()
8780 netdev_err(bp->dev, "hwrm stat ctx alloc failure rc: %x\n", in bnxt_init_chip()
8788 netdev_err(bp->dev, "hwrm ring alloc failure rc: %x\n", rc); in bnxt_init_chip()
8794 netdev_err(bp->dev, "hwrm_ring_grp alloc failure: %x\n", rc); in bnxt_init_chip()
8799 rx_nr_rings--; in bnxt_init_chip()
8804 netdev_err(bp->dev, "hwrm vnic alloc failure rc: %x\n", rc); in bnxt_init_chip()
8812 if (bp->flags & BNXT_FLAG_RFS) { in bnxt_init_chip()
8818 if (bp->flags & BNXT_FLAG_TPA) { in bnxt_init_chip()
8828 rc = bnxt_hwrm_set_vnic_filter(bp, 0, 0, bp->dev->dev_addr); in bnxt_init_chip()
8830 if (BNXT_VF(bp) && rc == -ENODEV) in bnxt_init_chip()
8831 netdev_err(bp->dev, "Cannot configure L2 filter while PF is unavailable\n"); in bnxt_init_chip()
8833 netdev_err(bp->dev, "HWRM vnic filter failure rc: %x\n", rc); in bnxt_init_chip()
8836 vnic->uc_filter_count = 1; in bnxt_init_chip()
8838 vnic->rx_mask = 0; in bnxt_init_chip()
8839 if (test_bit(BNXT_STATE_HALF_OPEN, &bp->state)) in bnxt_init_chip()
8842 if (bp->dev->flags & IFF_BROADCAST) in bnxt_init_chip()
8843 vnic->rx_mask |= CFA_L2_SET_RX_MASK_REQ_MASK_BCAST; in bnxt_init_chip()
8845 if (bp->dev->flags & IFF_PROMISC) in bnxt_init_chip()
8846 vnic->rx_mask |= CFA_L2_SET_RX_MASK_REQ_MASK_PROMISCUOUS; in bnxt_init_chip()
8848 if (bp->dev->flags & IFF_ALLMULTI) { in bnxt_init_chip()
8849 vnic->rx_mask |= CFA_L2_SET_RX_MASK_REQ_MASK_ALL_MCAST; in bnxt_init_chip()
8850 vnic->mc_list_count = 0; in bnxt_init_chip()
8851 } else if (bp->dev->flags & IFF_MULTICAST) { in bnxt_init_chip()
8855 vnic->rx_mask |= mask; in bnxt_init_chip()
8865 netdev_warn(bp->dev, "HWRM set coalescing failure rc: %x\n", in bnxt_init_chip()
8871 netdev_err(bp->dev, "Special vnic setup failure for NS2 A0 rc: %x\n", in bnxt_init_chip()
8877 netdev_update_features(bp->dev); in bnxt_init_chip()
8908 struct net_device *dev = bp->dev; in bnxt_set_real_num_queues()
8910 rc = netif_set_real_num_tx_queues(dev, bp->tx_nr_rings - in bnxt_set_real_num_queues()
8911 bp->tx_nr_rings_xdp); in bnxt_set_real_num_queues()
8915 rc = netif_set_real_num_rx_queues(dev, bp->rx_nr_rings); in bnxt_set_real_num_queues()
8920 if (bp->flags & BNXT_FLAG_RFS) in bnxt_set_real_num_queues()
8921 dev->rx_cpu_rmap = alloc_irq_cpu_rmap(bp->rx_nr_rings); in bnxt_set_real_num_queues()
8937 return -ENOMEM; in bnxt_trim_rings()
8941 _rx--; in bnxt_trim_rings()
8943 _tx--; in bnxt_trim_rings()
8953 const int len = sizeof(bp->irq_tbl[0].name); in bnxt_setup_msix()
8954 struct net_device *dev = bp->dev; in bnxt_setup_msix()
8962 count = bp->tx_nr_rings_per_tc; in bnxt_setup_msix()
8968 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_setup_msix()
8972 if (bp->flags & BNXT_FLAG_SHARED_RINGS) in bnxt_setup_msix()
8974 else if (i < bp->rx_nr_rings) in bnxt_setup_msix()
8979 snprintf(bp->irq_tbl[map_idx].name, len, "%s-%s-%d", dev->name, in bnxt_setup_msix()
8981 bp->irq_tbl[map_idx].handler = bnxt_msix; in bnxt_setup_msix()
8987 const int len = sizeof(bp->irq_tbl[0].name); in bnxt_setup_inta()
8989 if (netdev_get_num_tc(bp->dev)) in bnxt_setup_inta()
8990 netdev_reset_tc(bp->dev); in bnxt_setup_inta()
8992 snprintf(bp->irq_tbl[0].name, len, "%s-%s-%d", bp->dev->name, "TxRx", in bnxt_setup_inta()
8994 bp->irq_tbl[0].handler = bnxt_inta; in bnxt_setup_inta()
9003 if (!bp->irq_tbl) { in bnxt_setup_int_mode()
9005 if (rc || !bp->irq_tbl) in bnxt_setup_int_mode()
9006 return rc ?: -ENODEV; in bnxt_setup_int_mode()
9009 if (bp->flags & BNXT_FLAG_USING_MSIX) in bnxt_setup_int_mode()
9021 return bp->hw_resc.max_rsscos_ctxs; in bnxt_get_max_func_rss_ctxs()
9026 return bp->hw_resc.max_vnics; in bnxt_get_max_func_vnics()
9032 return bp->hw_resc.max_stat_ctxs; in bnxt_get_max_func_stat_ctxs()
9037 return bp->hw_resc.max_cp_rings; in bnxt_get_max_func_cp_rings()
9042 unsigned int cp = bp->hw_resc.max_cp_rings; in bnxt_get_max_func_cp_rings_for_en()
9044 if (!(bp->flags & BNXT_FLAG_CHIP_P5)) in bnxt_get_max_func_cp_rings_for_en()
9045 cp -= bnxt_get_ulp_msix_num(bp); in bnxt_get_max_func_cp_rings_for_en()
9052 struct bnxt_hw_resc *hw_resc = &bp->hw_resc; in bnxt_get_max_func_irqs()
9054 if (bp->flags & BNXT_FLAG_CHIP_P5) in bnxt_get_max_func_irqs()
9055 return min_t(unsigned int, hw_resc->max_irqs, hw_resc->max_nqs); in bnxt_get_max_func_irqs()
9057 return min_t(unsigned int, hw_resc->max_irqs, hw_resc->max_cp_rings); in bnxt_get_max_func_irqs()
9062 bp->hw_resc.max_irqs = max_irqs; in bnxt_set_max_func_irqs()
9070 if (bp->flags & BNXT_FLAG_CHIP_P5) in bnxt_get_avail_cp_rings_for_en()
9071 return cp - bp->rx_nr_rings - bp->tx_nr_rings; in bnxt_get_avail_cp_rings_for_en()
9073 return cp - bp->cp_nr_rings; in bnxt_get_avail_cp_rings_for_en()
9078 return bnxt_get_max_func_stat_ctxs(bp) - bnxt_get_func_stat_ctxs(bp); in bnxt_get_avail_stat_ctxs_for_en()
9085 int total_req = bp->cp_nr_rings + num; in bnxt_get_avail_msix()
9088 max_idx = bp->total_irqs; in bnxt_get_avail_msix()
9089 if (!(bp->flags & BNXT_FLAG_CHIP_P5)) in bnxt_get_avail_msix()
9090 max_idx = min_t(int, bp->total_irqs, max_cp); in bnxt_get_avail_msix()
9091 avail_msix = max_idx - bp->cp_nr_rings; in bnxt_get_avail_msix()
9096 num = max_irq - bp->cp_nr_rings; in bnxt_get_avail_msix()
9126 return -ENOMEM; in bnxt_init_msix()
9133 if (!(bp->flags & BNXT_FLAG_SHARED_RINGS)) in bnxt_init_msix()
9136 total_vecs = pci_enable_msix_range(bp->pdev, msix_ent, min, total_vecs); in bnxt_init_msix()
9139 rc = -ENODEV; in bnxt_init_msix()
9143 bp->irq_tbl = kcalloc(total_vecs, sizeof(struct bnxt_irq), GFP_KERNEL); in bnxt_init_msix()
9144 if (bp->irq_tbl) { in bnxt_init_msix()
9146 bp->irq_tbl[i].vector = msix_ent[i].vector; in bnxt_init_msix()
9148 bp->total_irqs = total_vecs; in bnxt_init_msix()
9150 rc = bnxt_trim_rings(bp, &bp->rx_nr_rings, &bp->tx_nr_rings, in bnxt_init_msix()
9151 total_vecs - ulp_msix, min == 1); in bnxt_init_msix()
9155 bp->cp_nr_rings = (min == 1) ? in bnxt_init_msix()
9156 max_t(int, bp->tx_nr_rings, bp->rx_nr_rings) : in bnxt_init_msix()
9157 bp->tx_nr_rings + bp->rx_nr_rings; in bnxt_init_msix()
9160 rc = -ENOMEM; in bnxt_init_msix()
9163 bp->flags |= BNXT_FLAG_USING_MSIX; in bnxt_init_msix()
9168 netdev_err(bp->dev, "bnxt_init_msix err: %x\n", rc); in bnxt_init_msix()
9169 kfree(bp->irq_tbl); in bnxt_init_msix()
9170 bp->irq_tbl = NULL; in bnxt_init_msix()
9171 pci_disable_msix(bp->pdev); in bnxt_init_msix()
9178 bp->irq_tbl = kzalloc(sizeof(struct bnxt_irq), GFP_KERNEL); in bnxt_init_inta()
9179 if (!bp->irq_tbl) in bnxt_init_inta()
9180 return -ENOMEM; in bnxt_init_inta()
9182 bp->total_irqs = 1; in bnxt_init_inta()
9183 bp->rx_nr_rings = 1; in bnxt_init_inta()
9184 bp->tx_nr_rings = 1; in bnxt_init_inta()
9185 bp->cp_nr_rings = 1; in bnxt_init_inta()
9186 bp->flags |= BNXT_FLAG_SHARED_RINGS; in bnxt_init_inta()
9187 bp->irq_tbl[0].vector = bp->pdev->irq; in bnxt_init_inta()
9193 int rc = -ENODEV; in bnxt_init_int_mode()
9195 if (bp->flags & BNXT_FLAG_MSIX_CAP) in bnxt_init_int_mode()
9198 if (!(bp->flags & BNXT_FLAG_USING_MSIX) && BNXT_PF(bp)) { in bnxt_init_int_mode()
9207 if (bp->flags & BNXT_FLAG_USING_MSIX) in bnxt_clear_int_mode()
9208 pci_disable_msix(bp->pdev); in bnxt_clear_int_mode()
9210 kfree(bp->irq_tbl); in bnxt_clear_int_mode()
9211 bp->irq_tbl = NULL; in bnxt_clear_int_mode()
9212 bp->flags &= ~BNXT_FLAG_USING_MSIX; in bnxt_clear_int_mode()
9217 int tcs = netdev_get_num_tc(bp->dev); in bnxt_reserve_rings()
9225 bnxt_get_num_msix(bp) != bp->total_irqs) { in bnxt_reserve_rings()
9237 netdev_err(bp->dev, "ring reservation/IRQ init failure rc: %d\n", rc); in bnxt_reserve_rings()
9240 if (tcs && (bp->tx_nr_rings_per_tc * tcs != bp->tx_nr_rings)) { in bnxt_reserve_rings()
9241 netdev_err(bp->dev, "tx ring reservation failure\n"); in bnxt_reserve_rings()
9242 netdev_reset_tc(bp->dev); in bnxt_reserve_rings()
9243 bp->tx_nr_rings_per_tc = bp->tx_nr_rings; in bnxt_reserve_rings()
9244 return -ENOMEM; in bnxt_reserve_rings()
9255 free_irq_cpu_rmap(bp->dev->rx_cpu_rmap); in bnxt_free_irq()
9256 bp->dev->rx_cpu_rmap = NULL; in bnxt_free_irq()
9258 if (!bp->irq_tbl || !bp->bnapi) in bnxt_free_irq()
9261 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_free_irq()
9264 irq = &bp->irq_tbl[map_idx]; in bnxt_free_irq()
9265 if (irq->requested) { in bnxt_free_irq()
9266 if (irq->have_cpumask) { in bnxt_free_irq()
9267 irq_set_affinity_hint(irq->vector, NULL); in bnxt_free_irq()
9268 free_cpumask_var(irq->cpu_mask); in bnxt_free_irq()
9269 irq->have_cpumask = 0; in bnxt_free_irq()
9271 free_irq(irq->vector, bp->bnapi[i]); in bnxt_free_irq()
9274 irq->requested = 0; in bnxt_free_irq()
9288 netdev_err(bp->dev, "bnxt_setup_int_mode err: %x\n", in bnxt_request_irq()
9293 rmap = bp->dev->rx_cpu_rmap; in bnxt_request_irq()
9295 if (!(bp->flags & BNXT_FLAG_USING_MSIX)) in bnxt_request_irq()
9298 for (i = 0, j = 0; i < bp->cp_nr_rings; i++) { in bnxt_request_irq()
9300 struct bnxt_irq *irq = &bp->irq_tbl[map_idx]; in bnxt_request_irq()
9303 if (rmap && bp->bnapi[i]->rx_ring) { in bnxt_request_irq()
9304 rc = irq_cpu_rmap_add(rmap, irq->vector); in bnxt_request_irq()
9306 netdev_warn(bp->dev, "failed adding irq rmap for ring %d\n", in bnxt_request_irq()
9311 rc = request_irq(irq->vector, irq->handler, flags, irq->name, in bnxt_request_irq()
9312 bp->bnapi[i]); in bnxt_request_irq()
9316 irq->requested = 1; in bnxt_request_irq()
9318 if (zalloc_cpumask_var(&irq->cpu_mask, GFP_KERNEL)) { in bnxt_request_irq()
9319 int numa_node = dev_to_node(&bp->pdev->dev); in bnxt_request_irq()
9321 irq->have_cpumask = 1; in bnxt_request_irq()
9323 irq->cpu_mask); in bnxt_request_irq()
9324 rc = irq_set_affinity_hint(irq->vector, irq->cpu_mask); in bnxt_request_irq()
9326 netdev_warn(bp->dev, in bnxt_request_irq()
9328 irq->vector); in bnxt_request_irq()
9340 if (!bp->bnapi) in bnxt_del_napi()
9343 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_del_napi()
9344 struct bnxt_napi *bnapi = bp->bnapi[i]; in bnxt_del_napi()
9346 __netif_napi_del(&bnapi->napi); in bnxt_del_napi()
9357 unsigned int cp_nr_rings = bp->cp_nr_rings; in bnxt_init_napi()
9360 if (bp->flags & BNXT_FLAG_USING_MSIX) { in bnxt_init_napi()
9363 if (bp->flags & BNXT_FLAG_CHIP_P5) in bnxt_init_napi()
9366 cp_nr_rings--; in bnxt_init_napi()
9368 bnapi = bp->bnapi[i]; in bnxt_init_napi()
9369 netif_napi_add(bp->dev, &bnapi->napi, poll_fn); in bnxt_init_napi()
9372 bnapi = bp->bnapi[cp_nr_rings]; in bnxt_init_napi()
9373 netif_napi_add(bp->dev, &bnapi->napi, in bnxt_init_napi()
9377 bnapi = bp->bnapi[0]; in bnxt_init_napi()
9378 netif_napi_add(bp->dev, &bnapi->napi, bnxt_poll); in bnxt_init_napi()
9386 if (!bp->bnapi || in bnxt_disable_napi()
9387 test_and_set_bit(BNXT_STATE_NAPI_DISABLED, &bp->state)) in bnxt_disable_napi()
9390 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_disable_napi()
9391 struct bnxt_cp_ring_info *cpr = &bp->bnapi[i]->cp_ring; in bnxt_disable_napi()
9393 napi_disable(&bp->bnapi[i]->napi); in bnxt_disable_napi()
9394 if (bp->bnapi[i]->rx_ring) in bnxt_disable_napi()
9395 cancel_work_sync(&cpr->dim.work); in bnxt_disable_napi()
9403 clear_bit(BNXT_STATE_NAPI_DISABLED, &bp->state); in bnxt_enable_napi()
9404 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_enable_napi()
9405 struct bnxt_napi *bnapi = bp->bnapi[i]; in bnxt_enable_napi()
9408 cpr = &bnapi->cp_ring; in bnxt_enable_napi()
9409 if (bnapi->in_reset) in bnxt_enable_napi()
9410 cpr->sw_stats.rx.rx_resets++; in bnxt_enable_napi()
9411 bnapi->in_reset = false; in bnxt_enable_napi()
9413 if (bnapi->rx_ring) { in bnxt_enable_napi()
9414 INIT_WORK(&cpr->dim.work, bnxt_dim_work); in bnxt_enable_napi()
9415 cpr->dim.mode = DIM_CQ_PERIOD_MODE_START_FROM_EQE; in bnxt_enable_napi()
9417 napi_enable(&bnapi->napi); in bnxt_enable_napi()
9426 if (bp->tx_ring) { in bnxt_tx_disable()
9427 for (i = 0; i < bp->tx_nr_rings; i++) { in bnxt_tx_disable()
9428 txr = &bp->tx_ring[i]; in bnxt_tx_disable()
9429 WRITE_ONCE(txr->dev_state, BNXT_DEV_STATE_CLOSING); in bnxt_tx_disable()
9435 netif_carrier_off(bp->dev); in bnxt_tx_disable()
9437 netif_tx_disable(bp->dev); in bnxt_tx_disable()
9445 for (i = 0; i < bp->tx_nr_rings; i++) { in bnxt_tx_enable()
9446 txr = &bp->tx_ring[i]; in bnxt_tx_enable()
9447 WRITE_ONCE(txr->dev_state, 0); in bnxt_tx_enable()
9451 netif_tx_wake_all_queues(bp->dev); in bnxt_tx_enable()
9453 netif_carrier_on(bp->dev); in bnxt_tx_enable()
9458 u8 active_fec = link_info->active_fec_sig_mode & in bnxt_report_fec()
9489 netif_carrier_on(bp->dev); in bnxt_report_link()
9490 speed = bnxt_fw_to_ethtool_speed(bp->link_info.link_speed); in bnxt_report_link()
9492 netdev_info(bp->dev, "NIC Link is Up, speed unknown\n"); in bnxt_report_link()
9495 if (bp->link_info.duplex == BNXT_LINK_DUPLEX_FULL) in bnxt_report_link()
9499 if (bp->link_info.pause == BNXT_LINK_PAUSE_BOTH) in bnxt_report_link()
9500 flow_ctrl = "ON - receive & transmit"; in bnxt_report_link()
9501 else if (bp->link_info.pause == BNXT_LINK_PAUSE_TX) in bnxt_report_link()
9502 flow_ctrl = "ON - transmit"; in bnxt_report_link()
9503 else if (bp->link_info.pause == BNXT_LINK_PAUSE_RX) in bnxt_report_link()
9504 flow_ctrl = "ON - receive"; in bnxt_report_link()
9507 if (bp->link_info.phy_qcfg_resp.option_flags & in bnxt_report_link()
9509 u8 sig_mode = bp->link_info.active_fec_sig_mode & in bnxt_report_link()
9522 netdev_info(bp->dev, "NIC Link is Up, %u Mbps %s%s duplex, Flow control: %s\n", in bnxt_report_link()
9524 if (bp->phy_flags & BNXT_PHY_FL_EEE_CAP) in bnxt_report_link()
9525 netdev_info(bp->dev, "EEE is %s\n", in bnxt_report_link()
9526 bp->eee.eee_active ? "active" : in bnxt_report_link()
9528 fec = bp->link_info.fec_cfg; in bnxt_report_link()
9530 netdev_info(bp->dev, "FEC autoneg %s encoding: %s\n", in bnxt_report_link()
9532 bnxt_report_fec(&bp->link_info)); in bnxt_report_link()
9534 netif_carrier_off(bp->dev); in bnxt_report_link()
9535 netdev_err(bp->dev, "NIC Link is Down\n"); in bnxt_report_link()
9541 if (!resp->supported_speeds_auto_mode && in bnxt_phy_qcaps_no_speed()
9542 !resp->supported_speeds_force_mode && in bnxt_phy_qcaps_no_speed()
9543 !resp->supported_pam4_speeds_auto_mode && in bnxt_phy_qcaps_no_speed()
9544 !resp->supported_pam4_speeds_force_mode) in bnxt_phy_qcaps_no_speed()
9551 struct bnxt_link_info *link_info = &bp->link_info; in bnxt_hwrm_phy_qcaps()
9556 if (bp->hwrm_spec_code < 0x10201) in bnxt_hwrm_phy_qcaps()
9568 bp->phy_flags = resp->flags | (le16_to_cpu(resp->flags2) << 8); in bnxt_hwrm_phy_qcaps()
9569 if (resp->flags & PORT_PHY_QCAPS_RESP_FLAGS_EEE_SUPPORTED) { in bnxt_hwrm_phy_qcaps()
9570 struct ethtool_eee *eee = &bp->eee; in bnxt_hwrm_phy_qcaps()
9571 u16 fw_speeds = le16_to_cpu(resp->supported_speeds_eee_mode); in bnxt_hwrm_phy_qcaps()
9573 eee->supported = _bnxt_fw_to_ethtool_adv_spds(fw_speeds, 0); in bnxt_hwrm_phy_qcaps()
9574 bp->lpi_tmr_lo = le32_to_cpu(resp->tx_lpi_timer_low) & in bnxt_hwrm_phy_qcaps()
9576 bp->lpi_tmr_hi = le32_to_cpu(resp->valid_tx_lpi_timer_high) & in bnxt_hwrm_phy_qcaps()
9580 if (bp->hwrm_spec_code >= 0x10a01) { in bnxt_hwrm_phy_qcaps()
9582 link_info->phy_state = BNXT_PHY_STATE_DISABLED; in bnxt_hwrm_phy_qcaps()
9583 netdev_warn(bp->dev, "Ethernet link disabled\n"); in bnxt_hwrm_phy_qcaps()
9584 } else if (link_info->phy_state == BNXT_PHY_STATE_DISABLED) { in bnxt_hwrm_phy_qcaps()
9585 link_info->phy_state = BNXT_PHY_STATE_ENABLED; in bnxt_hwrm_phy_qcaps()
9586 netdev_info(bp->dev, "Ethernet link enabled\n"); in bnxt_hwrm_phy_qcaps()
9587 /* Phy re-enabled, reprobe the speeds */ in bnxt_hwrm_phy_qcaps()
9588 link_info->support_auto_speeds = 0; in bnxt_hwrm_phy_qcaps()
9589 link_info->support_pam4_auto_speeds = 0; in bnxt_hwrm_phy_qcaps()
9592 if (resp->supported_speeds_auto_mode) in bnxt_hwrm_phy_qcaps()
9593 link_info->support_auto_speeds = in bnxt_hwrm_phy_qcaps()
9594 le16_to_cpu(resp->supported_speeds_auto_mode); in bnxt_hwrm_phy_qcaps()
9595 if (resp->supported_pam4_speeds_auto_mode) in bnxt_hwrm_phy_qcaps()
9596 link_info->support_pam4_auto_speeds = in bnxt_hwrm_phy_qcaps()
9597 le16_to_cpu(resp->supported_pam4_speeds_auto_mode); in bnxt_hwrm_phy_qcaps()
9599 bp->port_count = resp->port_cnt; in bnxt_hwrm_phy_qcaps()
9615 struct bnxt_link_info *link_info = &bp->link_info; in bnxt_update_link()
9618 u8 link_state = link_info->link_state; in bnxt_update_link()
9630 if (BNXT_VF(bp) && rc == -ENODEV) { in bnxt_update_link()
9631 netdev_warn(bp->dev, "Cannot obtain link state while PF unavailable.\n"); in bnxt_update_link()
9637 memcpy(&link_info->phy_qcfg_resp, resp, sizeof(*resp)); in bnxt_update_link()
9638 link_info->phy_link_status = resp->link; in bnxt_update_link()
9639 link_info->duplex = resp->duplex_cfg; in bnxt_update_link()
9640 if (bp->hwrm_spec_code >= 0x10800) in bnxt_update_link()
9641 link_info->duplex = resp->duplex_state; in bnxt_update_link()
9642 link_info->pause = resp->pause; in bnxt_update_link()
9643 link_info->auto_mode = resp->auto_mode; in bnxt_update_link()
9644 link_info->auto_pause_setting = resp->auto_pause; in bnxt_update_link()
9645 link_info->lp_pause = resp->link_partner_adv_pause; in bnxt_update_link()
9646 link_info->force_pause_setting = resp->force_pause; in bnxt_update_link()
9647 link_info->duplex_setting = resp->duplex_cfg; in bnxt_update_link()
9648 if (link_info->phy_link_status == BNXT_LINK_LINK) in bnxt_update_link()
9649 link_info->link_speed = le16_to_cpu(resp->link_speed); in bnxt_update_link()
9651 link_info->link_speed = 0; in bnxt_update_link()
9652 link_info->force_link_speed = le16_to_cpu(resp->force_link_speed); in bnxt_update_link()
9653 link_info->force_pam4_link_speed = in bnxt_update_link()
9654 le16_to_cpu(resp->force_pam4_link_speed); in bnxt_update_link()
9655 link_info->support_speeds = le16_to_cpu(resp->support_speeds); in bnxt_update_link()
9656 link_info->support_pam4_speeds = le16_to_cpu(resp->support_pam4_speeds); in bnxt_update_link()
9657 link_info->auto_link_speeds = le16_to_cpu(resp->auto_link_speed_mask); in bnxt_update_link()
9658 link_info->auto_pam4_link_speeds = in bnxt_update_link()
9659 le16_to_cpu(resp->auto_pam4_link_speed_mask); in bnxt_update_link()
9660 link_info->lp_auto_link_speeds = in bnxt_update_link()
9661 le16_to_cpu(resp->link_partner_adv_speeds); in bnxt_update_link()
9662 link_info->lp_auto_pam4_link_speeds = in bnxt_update_link()
9663 resp->link_partner_pam4_adv_speeds; in bnxt_update_link()
9664 link_info->preemphasis = le32_to_cpu(resp->preemphasis); in bnxt_update_link()
9665 link_info->phy_ver[0] = resp->phy_maj; in bnxt_update_link()
9666 link_info->phy_ver[1] = resp->phy_min; in bnxt_update_link()
9667 link_info->phy_ver[2] = resp->phy_bld; in bnxt_update_link()
9668 link_info->media_type = resp->media_type; in bnxt_update_link()
9669 link_info->phy_type = resp->phy_type; in bnxt_update_link()
9670 link_info->transceiver = resp->xcvr_pkg_type; in bnxt_update_link()
9671 link_info->phy_addr = resp->eee_config_phy_addr & in bnxt_update_link()
9673 link_info->module_status = resp->module_status; in bnxt_update_link()
9675 if (bp->phy_flags & BNXT_PHY_FL_EEE_CAP) { in bnxt_update_link()
9676 struct ethtool_eee *eee = &bp->eee; in bnxt_update_link()
9679 eee->eee_active = 0; in bnxt_update_link()
9680 if (resp->eee_config_phy_addr & in bnxt_update_link()
9682 eee->eee_active = 1; in bnxt_update_link()
9684 resp->link_partner_adv_eee_link_speed_mask); in bnxt_update_link()
9685 eee->lp_advertised = in bnxt_update_link()
9691 if (resp->eee_config_phy_addr & in bnxt_update_link()
9693 eee->eee_enabled = 1; in bnxt_update_link()
9695 fw_speeds = le16_to_cpu(resp->adv_eee_link_speed_mask); in bnxt_update_link()
9696 eee->advertised = in bnxt_update_link()
9699 if (resp->eee_config_phy_addr & in bnxt_update_link()
9703 eee->tx_lpi_enabled = 1; in bnxt_update_link()
9704 tmr = resp->xcvr_identifier_type_tx_lpi_timer; in bnxt_update_link()
9705 eee->tx_lpi_timer = le32_to_cpu(tmr) & in bnxt_update_link()
9711 link_info->fec_cfg = PORT_PHY_QCFG_RESP_FEC_CFG_FEC_NONE_SUPPORTED; in bnxt_update_link()
9712 if (bp->hwrm_spec_code >= 0x10504) { in bnxt_update_link()
9713 link_info->fec_cfg = le16_to_cpu(resp->fec_cfg); in bnxt_update_link()
9714 link_info->active_fec_sig_mode = resp->active_fec_signal_mode; in bnxt_update_link()
9718 if (link_info->phy_link_status == BNXT_LINK_LINK) in bnxt_update_link()
9719 link_info->link_state = BNXT_LINK_STATE_UP; in bnxt_update_link()
9721 link_info->link_state = BNXT_LINK_STATE_DOWN; in bnxt_update_link()
9722 if (link_state != link_info->link_state) in bnxt_update_link()
9726 link_info->link_state = BNXT_LINK_STATE_DOWN; in bnxt_update_link()
9736 if (bnxt_support_dropped(link_info->advertising, in bnxt_update_link()
9737 link_info->support_auto_speeds)) { in bnxt_update_link()
9738 link_info->advertising = link_info->support_auto_speeds; in bnxt_update_link()
9741 if (bnxt_support_dropped(link_info->advertising_pam4, in bnxt_update_link()
9742 link_info->support_pam4_auto_speeds)) { in bnxt_update_link()
9743 link_info->advertising_pam4 = link_info->support_pam4_auto_speeds; in bnxt_update_link()
9746 if (support_changed && (link_info->autoneg & BNXT_AUTONEG_SPEED)) in bnxt_update_link()
9753 struct bnxt_link_info *link_info = &bp->link_info; in bnxt_get_port_module_status()
9754 struct hwrm_port_phy_qcfg_output *resp = &link_info->phy_qcfg_resp; in bnxt_get_port_module_status()
9760 module_status = link_info->module_status; in bnxt_get_port_module_status()
9765 netdev_warn(bp->dev, "Unqualified SFP+ module detected on port %d\n", in bnxt_get_port_module_status()
9766 bp->pf.port_id); in bnxt_get_port_module_status()
9767 if (bp->hwrm_spec_code >= 0x10201) { in bnxt_get_port_module_status()
9768 netdev_warn(bp->dev, "Module part number %s\n", in bnxt_get_port_module_status()
9769 resp->phy_vendor_partnumber); in bnxt_get_port_module_status()
9772 netdev_warn(bp->dev, "TX is disabled\n"); in bnxt_get_port_module_status()
9774 netdev_warn(bp->dev, "SFP+ module is shutdown\n"); in bnxt_get_port_module_status()
9781 if (bp->link_info.autoneg & BNXT_AUTONEG_FLOW_CTRL) { in bnxt_hwrm_set_pause_common()
9782 if (bp->hwrm_spec_code >= 0x10201) in bnxt_hwrm_set_pause_common()
9783 req->auto_pause = in bnxt_hwrm_set_pause_common()
9785 if (bp->link_info.req_flow_ctrl & BNXT_LINK_PAUSE_RX) in bnxt_hwrm_set_pause_common()
9786 req->auto_pause |= PORT_PHY_CFG_REQ_AUTO_PAUSE_RX; in bnxt_hwrm_set_pause_common()
9787 if (bp->link_info.req_flow_ctrl & BNXT_LINK_PAUSE_TX) in bnxt_hwrm_set_pause_common()
9788 req->auto_pause |= PORT_PHY_CFG_REQ_AUTO_PAUSE_TX; in bnxt_hwrm_set_pause_common()
9789 req->enables |= in bnxt_hwrm_set_pause_common()
9792 if (bp->link_info.req_flow_ctrl & BNXT_LINK_PAUSE_RX) in bnxt_hwrm_set_pause_common()
9793 req->force_pause |= PORT_PHY_CFG_REQ_FORCE_PAUSE_RX; in bnxt_hwrm_set_pause_common()
9794 if (bp->link_info.req_flow_ctrl & BNXT_LINK_PAUSE_TX) in bnxt_hwrm_set_pause_common()
9795 req->force_pause |= PORT_PHY_CFG_REQ_FORCE_PAUSE_TX; in bnxt_hwrm_set_pause_common()
9796 req->enables |= in bnxt_hwrm_set_pause_common()
9798 if (bp->hwrm_spec_code >= 0x10201) { in bnxt_hwrm_set_pause_common()
9799 req->auto_pause = req->force_pause; in bnxt_hwrm_set_pause_common()
9800 req->enables |= cpu_to_le32( in bnxt_hwrm_set_pause_common()
9808 if (bp->link_info.autoneg & BNXT_AUTONEG_SPEED) { in bnxt_hwrm_set_link_common()
9809 req->auto_mode |= PORT_PHY_CFG_REQ_AUTO_MODE_SPEED_MASK; in bnxt_hwrm_set_link_common()
9810 if (bp->link_info.advertising) { in bnxt_hwrm_set_link_common()
9811 req->enables |= cpu_to_le32(PORT_PHY_CFG_REQ_ENABLES_AUTO_LINK_SPEED_MASK); in bnxt_hwrm_set_link_common()
9812 req->auto_link_speed_mask = cpu_to_le16(bp->link_info.advertising); in bnxt_hwrm_set_link_common()
9814 if (bp->link_info.advertising_pam4) { in bnxt_hwrm_set_link_common()
9815 req->enables |= in bnxt_hwrm_set_link_common()
9817 req->auto_link_pam4_speed_mask = in bnxt_hwrm_set_link_common()
9818 cpu_to_le16(bp->link_info.advertising_pam4); in bnxt_hwrm_set_link_common()
9820 req->enables |= cpu_to_le32(PORT_PHY_CFG_REQ_ENABLES_AUTO_MODE); in bnxt_hwrm_set_link_common()
9821 req->flags |= cpu_to_le32(PORT_PHY_CFG_REQ_FLAGS_RESTART_AUTONEG); in bnxt_hwrm_set_link_common()
9823 req->flags |= cpu_to_le32(PORT_PHY_CFG_REQ_FLAGS_FORCE); in bnxt_hwrm_set_link_common()
9824 if (bp->link_info.req_signal_mode == BNXT_SIG_MODE_PAM4) { in bnxt_hwrm_set_link_common()
9825 req->force_pam4_link_speed = cpu_to_le16(bp->link_info.req_link_speed); in bnxt_hwrm_set_link_common()
9826 req->enables |= cpu_to_le32(PORT_PHY_CFG_REQ_ENABLES_FORCE_PAM4_LINK_SPEED); in bnxt_hwrm_set_link_common()
9828 req->force_link_speed = cpu_to_le16(bp->link_info.req_link_speed); in bnxt_hwrm_set_link_common()
9833 req->flags |= cpu_to_le32(PORT_PHY_CFG_REQ_FLAGS_RESET_PHY); in bnxt_hwrm_set_link_common()
9847 if ((bp->link_info.autoneg & BNXT_AUTONEG_FLOW_CTRL) || in bnxt_hwrm_set_pause()
9848 bp->link_info.force_link_chng) in bnxt_hwrm_set_pause()
9852 if (!rc && !(bp->link_info.autoneg & BNXT_AUTONEG_FLOW_CTRL)) { in bnxt_hwrm_set_pause()
9857 bp->link_info.pause = in bnxt_hwrm_set_pause()
9858 bp->link_info.force_pause_setting = bp->link_info.req_flow_ctrl; in bnxt_hwrm_set_pause()
9859 bp->link_info.auto_pause_setting = 0; in bnxt_hwrm_set_pause()
9860 if (!bp->link_info.force_link_chng) in bnxt_hwrm_set_pause()
9863 bp->link_info.force_link_chng = false; in bnxt_hwrm_set_pause()
9870 struct ethtool_eee *eee = &bp->eee; in bnxt_hwrm_set_eee()
9872 if (eee->eee_enabled) { in bnxt_hwrm_set_eee()
9876 if (eee->tx_lpi_enabled) in bnxt_hwrm_set_eee()
9881 req->flags |= cpu_to_le32(flags); in bnxt_hwrm_set_eee()
9882 eee_speeds = bnxt_get_fw_auto_link_speeds(eee->advertised); in bnxt_hwrm_set_eee()
9883 req->eee_link_speed_mask = cpu_to_le16(eee_speeds); in bnxt_hwrm_set_eee()
9884 req->tx_lpi_timer = cpu_to_le32(eee->tx_lpi_timer); in bnxt_hwrm_set_eee()
9886 req->flags |= cpu_to_le32(PORT_PHY_CFG_REQ_FLAGS_EEE_DISABLE); in bnxt_hwrm_set_eee()
9917 if (pci_num_vf(bp->pdev) && in bnxt_hwrm_shutdown_link()
9918 !(bp->phy_flags & BNXT_PHY_FL_FW_MANAGED_LKDN)) in bnxt_hwrm_shutdown_link()
9925 req->flags = cpu_to_le32(PORT_PHY_CFG_REQ_FLAGS_FORCE_LINK_DWN); in bnxt_hwrm_shutdown_link()
9928 mutex_lock(&bp->link_lock); in bnxt_hwrm_shutdown_link()
9934 bp->link_info.link_state = BNXT_LINK_STATE_UNKNOWN; in bnxt_hwrm_shutdown_link()
9935 mutex_unlock(&bp->link_lock); in bnxt_hwrm_shutdown_link()
9946 netdev_err(bp->dev, "Failed FW reset via OP-TEE, rc=%d\n", rc); in bnxt_fw_reset_via_optee()
9950 netdev_err(bp->dev, "OP-TEE not supported\n"); in bnxt_fw_reset_via_optee()
9951 return -ENODEV; in bnxt_fw_reset_via_optee()
9957 if (bp->fw_health && bp->fw_health->status_reliable) { in bnxt_try_recover_fw()
9968 } while (rc == -EBUSY && retry < BNXT_FW_RETRY); in bnxt_try_recover_fw()
9971 netdev_err(bp->dev, in bnxt_try_recover_fw()
9974 rc = -ENODEV; in bnxt_try_recover_fw()
9977 netdev_warn(bp->dev, "Firmware recover via OP-TEE requested\n"); in bnxt_try_recover_fw()
9983 return -ENODEV; in bnxt_try_recover_fw()
9988 struct bnxt_hw_resc *hw_resc = &bp->hw_resc; in bnxt_clear_reservations()
9993 hw_resc->resv_cp_rings = 0; in bnxt_clear_reservations()
9994 hw_resc->resv_stat_ctxs = 0; in bnxt_clear_reservations()
9995 hw_resc->resv_irqs = 0; in bnxt_clear_reservations()
9996 hw_resc->resv_tx_rings = 0; in bnxt_clear_reservations()
9997 hw_resc->resv_rx_rings = 0; in bnxt_clear_reservations()
9998 hw_resc->resv_hw_ring_grps = 0; in bnxt_clear_reservations()
9999 hw_resc->resv_vnics = 0; in bnxt_clear_reservations()
10001 bp->tx_nr_rings = 0; in bnxt_clear_reservations()
10002 bp->rx_nr_rings = 0; in bnxt_clear_reservations()
10015 netdev_err(bp->dev, "resc_qcaps failed\n"); in bnxt_cancel_reservations()
10026 bool fw_reset = !bp->irq_tbl; in bnxt_hwrm_if_change()
10031 if (!(bp->fw_cap & BNXT_FW_CAP_IF_CHANGE)) in bnxt_hwrm_if_change()
10039 req->flags = cpu_to_le32(FUNC_DRV_IF_CHANGE_REQ_FLAGS_UP); in bnxt_hwrm_if_change()
10045 if (rc != -EAGAIN) in bnxt_hwrm_if_change()
10052 if (rc == -EAGAIN) { in bnxt_hwrm_if_change()
10056 flags = le32_to_cpu(resp->flags); in bnxt_hwrm_if_change()
10073 test_bit(BNXT_STATE_FW_RESET_DET, &bp->state)) in bnxt_hwrm_if_change()
10078 if (test_bit(BNXT_STATE_IN_FW_RESET, &bp->state) && !fw_reset) { in bnxt_hwrm_if_change()
10079 netdev_err(bp->dev, "RESET_DONE not set during FW reset.\n"); in bnxt_hwrm_if_change()
10080 set_bit(BNXT_STATE_ABORT_ERR, &bp->state); in bnxt_hwrm_if_change()
10081 return -ENODEV; in bnxt_hwrm_if_change()
10085 set_bit(BNXT_STATE_FW_RESET_DET, &bp->state); in bnxt_hwrm_if_change()
10086 if (!test_bit(BNXT_STATE_IN_FW_RESET, &bp->state)) in bnxt_hwrm_if_change()
10089 kfree(bp->ctx); in bnxt_hwrm_if_change()
10090 bp->ctx = NULL; in bnxt_hwrm_if_change()
10094 clear_bit(BNXT_STATE_FW_RESET_DET, &bp->state); in bnxt_hwrm_if_change()
10095 set_bit(BNXT_STATE_ABORT_ERR, &bp->state); in bnxt_hwrm_if_change()
10101 clear_bit(BNXT_STATE_FW_RESET_DET, &bp->state); in bnxt_hwrm_if_change()
10102 netdev_err(bp->dev, "init int mode failed\n"); in bnxt_hwrm_if_change()
10115 struct bnxt_pf_info *pf = &bp->pf; in bnxt_hwrm_port_led_qcaps()
10118 bp->num_leds = 0; in bnxt_hwrm_port_led_qcaps()
10119 if (BNXT_VF(bp) || bp->hwrm_spec_code < 0x10601) in bnxt_hwrm_port_led_qcaps()
10126 req->port_id = cpu_to_le16(pf->port_id); in bnxt_hwrm_port_led_qcaps()
10133 if (resp->num_leds > 0 && resp->num_leds < BNXT_MAX_LED) { in bnxt_hwrm_port_led_qcaps()
10136 bp->num_leds = resp->num_leds; in bnxt_hwrm_port_led_qcaps()
10137 memcpy(bp->leds, &resp->led0_id, sizeof(bp->leds[0]) * in bnxt_hwrm_port_led_qcaps()
10138 bp->num_leds); in bnxt_hwrm_port_led_qcaps()
10139 for (i = 0; i < bp->num_leds; i++) { in bnxt_hwrm_port_led_qcaps()
10140 struct bnxt_led_info *led = &bp->leds[i]; in bnxt_hwrm_port_led_qcaps()
10141 __le16 caps = led->led_state_caps; in bnxt_hwrm_port_led_qcaps()
10143 if (!led->led_group_id || in bnxt_hwrm_port_led_qcaps()
10145 bp->num_leds = 0; in bnxt_hwrm_port_led_qcaps()
10164 req->port_id = cpu_to_le16(bp->pf.port_id); in bnxt_hwrm_alloc_wol_fltr()
10165 req->wol_type = WOL_FILTER_ALLOC_REQ_WOL_TYPE_MAGICPKT; in bnxt_hwrm_alloc_wol_fltr()
10166 req->enables = cpu_to_le32(WOL_FILTER_ALLOC_REQ_ENABLES_MAC_ADDRESS); in bnxt_hwrm_alloc_wol_fltr()
10167 memcpy(req->mac_address, bp->dev->dev_addr, ETH_ALEN); in bnxt_hwrm_alloc_wol_fltr()
10172 bp->wol_filter_id = resp->wol_filter_id; in bnxt_hwrm_alloc_wol_fltr()
10186 req->port_id = cpu_to_le16(bp->pf.port_id); in bnxt_hwrm_free_wol_fltr()
10187 req->enables = cpu_to_le32(WOL_FILTER_FREE_REQ_ENABLES_WOL_FILTER_ID); in bnxt_hwrm_free_wol_fltr()
10188 req->wol_filter_id = bp->wol_filter_id; in bnxt_hwrm_free_wol_fltr()
10204 req->port_id = cpu_to_le16(bp->pf.port_id); in bnxt_hwrm_get_wol_fltrs()
10205 req->handle = cpu_to_le16(handle); in bnxt_hwrm_get_wol_fltrs()
10209 next_handle = le16_to_cpu(resp->next_handle); in bnxt_hwrm_get_wol_fltrs()
10211 if (resp->wol_type == in bnxt_hwrm_get_wol_fltrs()
10213 bp->wol = 1; in bnxt_hwrm_get_wol_fltrs()
10214 bp->wol_filter_id = resp->wol_filter_id; in bnxt_hwrm_get_wol_fltrs()
10226 bp->wol = 0; in bnxt_get_wol_settings()
10227 if (!BNXT_PF(bp) || !(bp->flags & BNXT_FLAG_WOL_CAP)) in bnxt_get_wol_settings()
10251 len = sprintf(buf, "%u\n", resp->temp * 1000); /* display millidegree */ in bnxt_show_temp()
10267 if (bp->hwmon_dev) { in bnxt_hwmon_close()
10268 hwmon_device_unregister(bp->hwmon_dev); in bnxt_hwmon_close()
10269 bp->hwmon_dev = NULL; in bnxt_hwmon_close()
10276 struct pci_dev *pdev = bp->pdev; in bnxt_hwmon_open()
10282 if (rc == -EACCES || rc == -EOPNOTSUPP) { in bnxt_hwmon_open()
10287 if (bp->hwmon_dev) in bnxt_hwmon_open()
10290 bp->hwmon_dev = hwmon_device_register_with_groups(&pdev->dev, in bnxt_hwmon_open()
10293 if (IS_ERR(bp->hwmon_dev)) { in bnxt_hwmon_open()
10294 bp->hwmon_dev = NULL; in bnxt_hwmon_open()
10295 dev_warn(&pdev->dev, "Cannot register hwmon device\n"); in bnxt_hwmon_open()
10310 struct ethtool_eee *eee = &bp->eee; in bnxt_eee_config_ok()
10311 struct bnxt_link_info *link_info = &bp->link_info; in bnxt_eee_config_ok()
10313 if (!(bp->phy_flags & BNXT_PHY_FL_EEE_CAP)) in bnxt_eee_config_ok()
10316 if (eee->eee_enabled) { in bnxt_eee_config_ok()
10318 _bnxt_fw_to_ethtool_adv_spds(link_info->advertising, 0); in bnxt_eee_config_ok()
10320 if (!(link_info->autoneg & BNXT_AUTONEG_SPEED)) { in bnxt_eee_config_ok()
10321 eee->eee_enabled = 0; in bnxt_eee_config_ok()
10324 if (eee->advertised & ~advertising) { in bnxt_eee_config_ok()
10325 eee->advertised = advertising & eee->supported; in bnxt_eee_config_ok()
10338 struct bnxt_link_info *link_info = &bp->link_info; in bnxt_update_phy_setting()
10342 netdev_err(bp->dev, "failed to update link (rc: %x)\n", in bnxt_update_phy_setting()
10349 if ((link_info->autoneg & BNXT_AUTONEG_FLOW_CTRL) && in bnxt_update_phy_setting()
10350 (link_info->auto_pause_setting & BNXT_LINK_PAUSE_BOTH) != in bnxt_update_phy_setting()
10351 link_info->req_flow_ctrl) in bnxt_update_phy_setting()
10353 if (!(link_info->autoneg & BNXT_AUTONEG_FLOW_CTRL) && in bnxt_update_phy_setting()
10354 link_info->force_pause_setting != link_info->req_flow_ctrl) in bnxt_update_phy_setting()
10356 if (!(link_info->autoneg & BNXT_AUTONEG_SPEED)) { in bnxt_update_phy_setting()
10357 if (BNXT_AUTO_MODE(link_info->auto_mode)) in bnxt_update_phy_setting()
10359 if (link_info->req_signal_mode == BNXT_SIG_MODE_NRZ && in bnxt_update_phy_setting()
10360 link_info->req_link_speed != link_info->force_link_speed) in bnxt_update_phy_setting()
10362 else if (link_info->req_signal_mode == BNXT_SIG_MODE_PAM4 && in bnxt_update_phy_setting()
10363 link_info->req_link_speed != link_info->force_pam4_link_speed) in bnxt_update_phy_setting()
10365 if (link_info->req_duplex != link_info->duplex_setting) in bnxt_update_phy_setting()
10368 if (link_info->auto_mode == BNXT_LINK_AUTO_NONE) in bnxt_update_phy_setting()
10370 if (link_info->advertising != link_info->auto_link_speeds || in bnxt_update_phy_setting()
10371 link_info->advertising_pam4 != link_info->auto_pam4_link_speeds) in bnxt_update_phy_setting()
10389 netdev_err(bp->dev, "failed to update phy setting (rc: %x)\n", in bnxt_update_phy_setting()
10397 /* Common routine to pre-map certain register block to different GRC window.
10407 bp->bar0 + BNXT_GRCPF_REG_WINDOW_BASE_OUT + 12); in bnxt_preset_reg_win()
10417 if (test_bit(BNXT_STATE_IN_FW_RESET, &bp->state)) in bnxt_reinit_after_abort()
10418 return -EBUSY; in bnxt_reinit_after_abort()
10420 if (bp->dev->reg_state == NETREG_UNREGISTERED) in bnxt_reinit_after_abort()
10421 return -ENODEV; in bnxt_reinit_after_abort()
10428 clear_bit(BNXT_STATE_ABORT_ERR, &bp->state); in bnxt_reinit_after_abort()
10429 set_bit(BNXT_STATE_FW_RESET_DET, &bp->state); in bnxt_reinit_after_abort()
10440 netif_carrier_off(bp->dev); in __bnxt_open_nic()
10445 netdev_err(bp->dev, "Failed to reserve default rings at open\n"); in __bnxt_open_nic()
10452 if ((bp->flags & BNXT_FLAG_RFS) && in __bnxt_open_nic()
10453 !(bp->flags & BNXT_FLAG_USING_MSIX)) { in __bnxt_open_nic()
10455 bp->dev->hw_features &= ~NETIF_F_NTUPLE; in __bnxt_open_nic()
10456 bp->flags &= ~BNXT_FLAG_RFS; in __bnxt_open_nic()
10461 netdev_err(bp->dev, "bnxt_alloc_mem err: %x\n", rc); in __bnxt_open_nic()
10469 netdev_err(bp->dev, "bnxt_request_irq err: %x\n", rc); in __bnxt_open_nic()
10476 netdev_err(bp->dev, "bnxt_init_nic err: %x\n", rc); in __bnxt_open_nic()
10484 mutex_lock(&bp->link_lock); in __bnxt_open_nic()
10486 mutex_unlock(&bp->link_lock); in __bnxt_open_nic()
10488 netdev_warn(bp->dev, "failed to update phy settings\n"); in __bnxt_open_nic()
10490 bp->link_info.phy_retry = true; in __bnxt_open_nic()
10491 bp->link_info.phy_retry_expires = in __bnxt_open_nic()
10498 udp_tunnel_nic_reset_ntf(bp->dev); in __bnxt_open_nic()
10500 if (bp->tx_nr_rings_xdp < num_possible_cpus()) { in __bnxt_open_nic()
10506 set_bit(BNXT_STATE_OPEN, &bp->state); in __bnxt_open_nic()
10510 mod_timer(&bp->timer, jiffies + bp->current_interval); in __bnxt_open_nic()
10512 mutex_lock(&bp->link_lock); in __bnxt_open_nic()
10514 mutex_unlock(&bp->link_lock); in __bnxt_open_nic()
10516 /* VF-reps may need to be re-opened after the PF is re-opened */ in __bnxt_open_nic()
10538 if (test_bit(BNXT_STATE_ABORT_ERR, &bp->state)) in bnxt_open_nic()
10539 rc = -EIO; in bnxt_open_nic()
10543 netdev_err(bp->dev, "nic open fail (rc: %x)\n", rc); in bnxt_open_nic()
10544 dev_close(bp->dev); in bnxt_open_nic()
10557 if (test_bit(BNXT_STATE_ABORT_ERR, &bp->state)) { in bnxt_half_open_nic()
10558 netdev_err(bp->dev, "A previous firmware reset has not completed, aborting half open\n"); in bnxt_half_open_nic()
10559 rc = -ENODEV; in bnxt_half_open_nic()
10565 netdev_err(bp->dev, "bnxt_alloc_mem err: %x\n", rc); in bnxt_half_open_nic()
10568 set_bit(BNXT_STATE_HALF_OPEN, &bp->state); in bnxt_half_open_nic()
10571 clear_bit(BNXT_STATE_HALF_OPEN, &bp->state); in bnxt_half_open_nic()
10572 netdev_err(bp->dev, "bnxt_init_nic err: %x\n", rc); in bnxt_half_open_nic()
10580 dev_close(bp->dev); in bnxt_half_open_nic()
10592 clear_bit(BNXT_STATE_HALF_OPEN, &bp->state); in bnxt_half_close_nic()
10598 struct bnxt_pf_info *pf = &bp->pf; in bnxt_reenable_sriov()
10599 int n = pf->active_vfs; in bnxt_reenable_sriov()
10611 if (test_bit(BNXT_STATE_ABORT_ERR, &bp->state)) { in bnxt_open()
10614 if (rc == -EBUSY) in bnxt_open()
10615 netdev_err(bp->dev, "A previous firmware reset has not completed, aborting\n"); in bnxt_open()
10617 netdev_err(bp->dev, "Failed to reinitialize after aborted firmware reset\n"); in bnxt_open()
10618 return -ENODEV; in bnxt_open()
10630 if (test_and_clear_bit(BNXT_STATE_FW_RESET_DET, &bp->state)) { in bnxt_open()
10631 if (!test_bit(BNXT_STATE_IN_FW_RESET, &bp->state)) { in bnxt_open()
10644 return (test_bit(BNXT_STATE_IN_SP_TASK, &bp->state) || in bnxt_drv_busy()
10645 test_bit(BNXT_STATE_READ_STATS, &bp->state)); in bnxt_drv_busy()
10654 /* Close the VF-reps before closing PF */ in __bnxt_close_nic()
10661 clear_bit(BNXT_STATE_OPEN, &bp->state); in __bnxt_close_nic()
10669 /* TODO CHIMP_FW: Link/PHY related cleanup if (link_re_init) */ in __bnxt_close_nic()
10673 del_timer_sync(&bp->timer); in __bnxt_close_nic()
10677 if (bp->bnapi && irq_re_init) in __bnxt_close_nic()
10678 bnxt_get_ring_stats(bp, &bp->net_stats_prev); in __bnxt_close_nic()
10690 if (test_bit(BNXT_STATE_IN_FW_RESET, &bp->state)) { in bnxt_close_nic()
10698 netdev_warn(bp->dev, "FW reset in progress during close, FW reset will be aborted\n"); in bnxt_close_nic()
10699 set_bit(BNXT_STATE_ABORT_ERR, &bp->state); in bnxt_close_nic()
10703 if (bp->sriov_cfg) { in bnxt_close_nic()
10704 rc = wait_event_interruptible_timeout(bp->sriov_cfg_wait, in bnxt_close_nic()
10705 !bp->sriov_cfg, in bnxt_close_nic()
10708 netdev_warn(bp->dev, "timeout waiting for SRIOV config operation to complete!\n"); in bnxt_close_nic()
10733 if (bp->hwrm_spec_code < 0x10a00) in bnxt_hwrm_port_phy_read()
10734 return -EOPNOTSUPP; in bnxt_hwrm_port_phy_read()
10740 req->port_id = cpu_to_le16(bp->pf.port_id); in bnxt_hwrm_port_phy_read()
10741 req->phy_addr = phy_addr; in bnxt_hwrm_port_phy_read()
10742 req->reg_addr = cpu_to_le16(reg & 0x1f); in bnxt_hwrm_port_phy_read()
10744 req->cl45_mdio = 1; in bnxt_hwrm_port_phy_read()
10745 req->phy_addr = mdio_phy_id_prtad(phy_addr); in bnxt_hwrm_port_phy_read()
10746 req->dev_addr = mdio_phy_id_devad(phy_addr); in bnxt_hwrm_port_phy_read()
10747 req->reg_addr = cpu_to_le16(reg); in bnxt_hwrm_port_phy_read()
10753 *val = le16_to_cpu(resp->reg_data); in bnxt_hwrm_port_phy_read()
10764 if (bp->hwrm_spec_code < 0x10a00) in bnxt_hwrm_port_phy_write()
10765 return -EOPNOTSUPP; in bnxt_hwrm_port_phy_write()
10771 req->port_id = cpu_to_le16(bp->pf.port_id); in bnxt_hwrm_port_phy_write()
10772 req->phy_addr = phy_addr; in bnxt_hwrm_port_phy_write()
10773 req->reg_addr = cpu_to_le16(reg & 0x1f); in bnxt_hwrm_port_phy_write()
10775 req->cl45_mdio = 1; in bnxt_hwrm_port_phy_write()
10776 req->phy_addr = mdio_phy_id_prtad(phy_addr); in bnxt_hwrm_port_phy_write()
10777 req->dev_addr = mdio_phy_id_devad(phy_addr); in bnxt_hwrm_port_phy_write()
10778 req->reg_addr = cpu_to_le16(reg); in bnxt_hwrm_port_phy_write()
10780 req->reg_data = cpu_to_le16(val); in bnxt_hwrm_port_phy_write()
10794 mdio->phy_id = bp->link_info.phy_addr; in bnxt_ioctl()
10801 return -EAGAIN; in bnxt_ioctl()
10803 rc = bnxt_hwrm_port_phy_read(bp, mdio->phy_id, mdio->reg_num, in bnxt_ioctl()
10805 mdio->val_out = mii_regval; in bnxt_ioctl()
10811 return -EAGAIN; in bnxt_ioctl()
10813 return bnxt_hwrm_port_phy_write(bp, mdio->phy_id, mdio->reg_num, in bnxt_ioctl()
10814 mdio->val_in); in bnxt_ioctl()
10826 return -EOPNOTSUPP; in bnxt_ioctl()
10834 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_get_ring_stats()
10835 struct bnxt_napi *bnapi = bp->bnapi[i]; in bnxt_get_ring_stats()
10836 struct bnxt_cp_ring_info *cpr = &bnapi->cp_ring; in bnxt_get_ring_stats()
10837 u64 *sw = cpr->stats.sw_stats; in bnxt_get_ring_stats()
10839 stats->rx_packets += BNXT_GET_RING_STATS64(sw, rx_ucast_pkts); in bnxt_get_ring_stats()
10840 stats->rx_packets += BNXT_GET_RING_STATS64(sw, rx_mcast_pkts); in bnxt_get_ring_stats()
10841 stats->rx_packets += BNXT_GET_RING_STATS64(sw, rx_bcast_pkts); in bnxt_get_ring_stats()
10843 stats->tx_packets += BNXT_GET_RING_STATS64(sw, tx_ucast_pkts); in bnxt_get_ring_stats()
10844 stats->tx_packets += BNXT_GET_RING_STATS64(sw, tx_mcast_pkts); in bnxt_get_ring_stats()
10845 stats->tx_packets += BNXT_GET_RING_STATS64(sw, tx_bcast_pkts); in bnxt_get_ring_stats()
10847 stats->rx_bytes += BNXT_GET_RING_STATS64(sw, rx_ucast_bytes); in bnxt_get_ring_stats()
10848 stats->rx_bytes += BNXT_GET_RING_STATS64(sw, rx_mcast_bytes); in bnxt_get_ring_stats()
10849 stats->rx_bytes += BNXT_GET_RING_STATS64(sw, rx_bcast_bytes); in bnxt_get_ring_stats()
10851 stats->tx_bytes += BNXT_GET_RING_STATS64(sw, tx_ucast_bytes); in bnxt_get_ring_stats()
10852 stats->tx_bytes += BNXT_GET_RING_STATS64(sw, tx_mcast_bytes); in bnxt_get_ring_stats()
10853 stats->tx_bytes += BNXT_GET_RING_STATS64(sw, tx_bcast_bytes); in bnxt_get_ring_stats()
10855 stats->rx_missed_errors += in bnxt_get_ring_stats()
10858 stats->multicast += BNXT_GET_RING_STATS64(sw, rx_mcast_pkts); in bnxt_get_ring_stats()
10860 stats->tx_dropped += BNXT_GET_RING_STATS64(sw, tx_error_pkts); in bnxt_get_ring_stats()
10862 stats->rx_dropped += in bnxt_get_ring_stats()
10863 cpr->sw_stats.rx.rx_netpoll_discards + in bnxt_get_ring_stats()
10864 cpr->sw_stats.rx.rx_oom_discards; in bnxt_get_ring_stats()
10871 struct rtnl_link_stats64 *prev_stats = &bp->net_stats_prev; in bnxt_add_prev_stats()
10873 stats->rx_packets += prev_stats->rx_packets; in bnxt_add_prev_stats()
10874 stats->tx_packets += prev_stats->tx_packets; in bnxt_add_prev_stats()
10875 stats->rx_bytes += prev_stats->rx_bytes; in bnxt_add_prev_stats()
10876 stats->tx_bytes += prev_stats->tx_bytes; in bnxt_add_prev_stats()
10877 stats->rx_missed_errors += prev_stats->rx_missed_errors; in bnxt_add_prev_stats()
10878 stats->multicast += prev_stats->multicast; in bnxt_add_prev_stats()
10879 stats->rx_dropped += prev_stats->rx_dropped; in bnxt_add_prev_stats()
10880 stats->tx_dropped += prev_stats->tx_dropped; in bnxt_add_prev_stats()
10888 set_bit(BNXT_STATE_READ_STATS, &bp->state); in bnxt_get_stats64()
10893 if (!test_bit(BNXT_STATE_OPEN, &bp->state)) { in bnxt_get_stats64()
10894 clear_bit(BNXT_STATE_READ_STATS, &bp->state); in bnxt_get_stats64()
10895 *stats = bp->net_stats_prev; in bnxt_get_stats64()
10902 if (bp->flags & BNXT_FLAG_PORT_STATS) { in bnxt_get_stats64()
10903 u64 *rx = bp->port_stats.sw_stats; in bnxt_get_stats64()
10904 u64 *tx = bp->port_stats.sw_stats + in bnxt_get_stats64()
10907 stats->rx_crc_errors = in bnxt_get_stats64()
10909 stats->rx_frame_errors = in bnxt_get_stats64()
10911 stats->rx_length_errors = in bnxt_get_stats64()
10915 stats->rx_errors = in bnxt_get_stats64()
10918 stats->collisions = in bnxt_get_stats64()
10920 stats->tx_fifo_errors = in bnxt_get_stats64()
10922 stats->tx_errors = BNXT_GET_TX_PORT_STATS64(tx, tx_err); in bnxt_get_stats64()
10924 clear_bit(BNXT_STATE_READ_STATS, &bp->state); in bnxt_get_stats64()
10929 struct net_device *dev = bp->dev; in bnxt_mc_list_updated()
10930 struct bnxt_vnic_info *vnic = &bp->vnic_info[0]; in bnxt_mc_list_updated()
10940 vnic->mc_list_count = 0; in bnxt_mc_list_updated()
10943 haddr = ha->addr; in bnxt_mc_list_updated()
10944 if (!ether_addr_equal(haddr, vnic->mc_list + off)) { in bnxt_mc_list_updated()
10945 memcpy(vnic->mc_list + off, haddr, ETH_ALEN); in bnxt_mc_list_updated()
10954 if (mc_count != vnic->mc_list_count) { in bnxt_mc_list_updated()
10955 vnic->mc_list_count = mc_count; in bnxt_mc_list_updated()
10963 struct net_device *dev = bp->dev; in bnxt_uc_list_updated()
10964 struct bnxt_vnic_info *vnic = &bp->vnic_info[0]; in bnxt_uc_list_updated()
10968 if (netdev_uc_count(dev) != (vnic->uc_filter_count - 1)) in bnxt_uc_list_updated()
10972 if (!ether_addr_equal(ha->addr, vnic->uc_list + off)) in bnxt_uc_list_updated()
10988 if (!test_bit(BNXT_STATE_OPEN, &bp->state)) in bnxt_set_rx_mode()
10991 vnic = &bp->vnic_info[0]; in bnxt_set_rx_mode()
10992 mask = vnic->rx_mask; in bnxt_set_rx_mode()
10998 if (dev->flags & IFF_PROMISC) in bnxt_set_rx_mode()
11003 if (dev->flags & IFF_BROADCAST) in bnxt_set_rx_mode()
11005 if (dev->flags & IFF_ALLMULTI) { in bnxt_set_rx_mode()
11007 vnic->mc_list_count = 0; in bnxt_set_rx_mode()
11008 } else if (dev->flags & IFF_MULTICAST) { in bnxt_set_rx_mode()
11012 if (mask != vnic->rx_mask || uc_update || mc_update) { in bnxt_set_rx_mode()
11013 vnic->rx_mask = mask; in bnxt_set_rx_mode()
11015 set_bit(BNXT_RX_MASK_SP_EVENT, &bp->sp_event); in bnxt_set_rx_mode()
11022 struct net_device *dev = bp->dev; in bnxt_cfg_rx_mode()
11023 struct bnxt_vnic_info *vnic = &bp->vnic_info[0]; in bnxt_cfg_rx_mode()
11040 for (i = 1; i < vnic->uc_filter_count; i++) { in bnxt_cfg_rx_mode()
11041 req->l2_filter_id = vnic->fw_l2_filter_id[i]; in bnxt_cfg_rx_mode()
11047 vnic->uc_filter_count = 1; in bnxt_cfg_rx_mode()
11050 if (netdev_uc_count(dev) > (BNXT_MAX_UC_ADDRS - 1)) { in bnxt_cfg_rx_mode()
11051 vnic->rx_mask |= CFA_L2_SET_RX_MASK_REQ_MASK_PROMISCUOUS; in bnxt_cfg_rx_mode()
11054 memcpy(vnic->uc_list + off, ha->addr, ETH_ALEN); in bnxt_cfg_rx_mode()
11056 vnic->uc_filter_count++; in bnxt_cfg_rx_mode()
11061 for (i = 1, off = 0; i < vnic->uc_filter_count; i++, off += ETH_ALEN) { in bnxt_cfg_rx_mode()
11062 rc = bnxt_hwrm_set_vnic_filter(bp, 0, i, vnic->uc_list + off); in bnxt_cfg_rx_mode()
11064 if (BNXT_VF(bp) && rc == -ENODEV) { in bnxt_cfg_rx_mode()
11065 if (!test_and_set_bit(BNXT_STATE_L2_FILTER_RETRY, &bp->state)) in bnxt_cfg_rx_mode()
11066 netdev_warn(bp->dev, "Cannot configure L2 filters while PF is unavailable, will retry\n"); in bnxt_cfg_rx_mode()
11068 netdev_dbg(bp->dev, "PF still unavailable while configuring L2 filters.\n"); in bnxt_cfg_rx_mode()
11071 netdev_err(bp->dev, "HWRM vnic filter failure rc: %x\n", rc); in bnxt_cfg_rx_mode()
11073 vnic->uc_filter_count = i; in bnxt_cfg_rx_mode()
11077 if (test_and_clear_bit(BNXT_STATE_L2_FILTER_RETRY, &bp->state)) in bnxt_cfg_rx_mode()
11078 netdev_notice(bp->dev, "Retry of L2 filter configuration successful.\n"); in bnxt_cfg_rx_mode()
11081 if ((vnic->rx_mask & CFA_L2_SET_RX_MASK_REQ_MASK_PROMISCUOUS) && in bnxt_cfg_rx_mode()
11083 vnic->rx_mask &= ~CFA_L2_SET_RX_MASK_REQ_MASK_PROMISCUOUS; in bnxt_cfg_rx_mode()
11085 if (rc && (vnic->rx_mask & CFA_L2_SET_RX_MASK_REQ_MASK_MCAST)) { in bnxt_cfg_rx_mode()
11086 netdev_info(bp->dev, "Failed setting MC filters rc: %d, turning on ALL_MCAST mode\n", in bnxt_cfg_rx_mode()
11088 vnic->rx_mask &= ~CFA_L2_SET_RX_MASK_REQ_MASK_MCAST; in bnxt_cfg_rx_mode()
11089 vnic->rx_mask |= CFA_L2_SET_RX_MASK_REQ_MASK_ALL_MCAST; in bnxt_cfg_rx_mode()
11090 vnic->mc_list_count = 0; in bnxt_cfg_rx_mode()
11094 netdev_err(bp->dev, "HWRM cfa l2 rx mask failure rc: %d\n", in bnxt_cfg_rx_mode()
11104 struct bnxt_hw_resc *hw_resc = &bp->hw_resc; in bnxt_can_reserve_rings()
11109 if (hw_resc->min_tx_rings || hw_resc->resv_tx_rings) in bnxt_can_reserve_rings()
11112 if (!netif_running(bp->dev)) in bnxt_can_reserve_rings()
11122 if (bp->flags & BNXT_FLAG_CHIP_P5) { in bnxt_rfs_supported()
11123 if (bp->fw_cap & BNXT_FW_CAP_CFA_RFS_RING_TBL_IDX_V2) in bnxt_rfs_supported()
11132 if (bp->flags & BNXT_FLAG_NEW_RSS_CAP) in bnxt_rfs_supported()
11143 if (bp->flags & BNXT_FLAG_CHIP_P5) in bnxt_rfs_capable()
11145 if (!(bp->flags & BNXT_FLAG_MSIX_CAP) || !bnxt_can_reserve_rings(bp) || !bp->rx_nr_rings) in bnxt_rfs_capable()
11148 vnics = 1 + bp->rx_nr_rings; in bnxt_rfs_capable()
11153 if (bp->flags & BNXT_FLAG_NEW_RSS_CAP) in bnxt_rfs_capable()
11156 if (bp->rx_nr_rings > 1) in bnxt_rfs_capable()
11157 netdev_warn(bp->dev, in bnxt_rfs_capable()
11159 min(max_rss_ctxs - 1, max_vnics - 1)); in bnxt_rfs_capable()
11166 if (vnics == bp->hw_resc.resv_vnics) in bnxt_rfs_capable()
11170 if (vnics <= bp->hw_resc.resv_vnics) in bnxt_rfs_capable()
11173 netdev_warn(bp->dev, "Unable to reserve resources to support NTUPLE filters.\n"); in bnxt_rfs_capable()
11190 if ((bp->flags & BNXT_FLAG_NO_AGG_RINGS) || bp->xdp_prog) in bnxt_fix_features()
11204 if (dev->features & BNXT_HW_FEATURE_VLAN_ALL_RX) in bnxt_fix_features()
11210 if (BNXT_VF(bp) && bp->vf.vlan) in bnxt_fix_features()
11219 u32 flags = bp->flags; in bnxt_set_features()
11231 if (bp->flags & BNXT_FLAG_NO_AGG_RINGS) in bnxt_set_features()
11240 changes = flags ^ bp->flags; in bnxt_set_features()
11243 if ((bp->flags & BNXT_FLAG_TPA) == 0 || in bnxt_set_features()
11245 (bp->flags & BNXT_FLAG_CHIP_P5)) in bnxt_set_features()
11252 if (flags != bp->flags) { in bnxt_set_features()
11253 u32 old_flags = bp->flags; in bnxt_set_features()
11255 if (!test_bit(BNXT_STATE_OPEN, &bp->state)) { in bnxt_set_features()
11256 bp->flags = flags; in bnxt_set_features()
11264 bp->flags = flags; in bnxt_set_features()
11271 bp->flags = flags; in bnxt_set_features()
11276 bp->flags = old_flags; in bnxt_set_features()
11285 struct ipv6hdr *ip6h = (struct ipv6hdr *)(skb->data + nw_off); in bnxt_exthdr_check()
11294 nexthdr = &ip6h->nexthdr; in bnxt_exthdr_check()
11302 hp = __skb_header_pointer(NULL, start, sizeof(*hp), skb->data, in bnxt_exthdr_check()
11313 nexthdr = &hp->nexthdr; in bnxt_exthdr_check()
11319 if (skb->encapsulation) { in bnxt_exthdr_check()
11325 /* Only support TCP/UDP for non-tunneled ipv6 and inner ipv6 */ in bnxt_exthdr_check()
11333 __be16 udp_port = uh->dest; in bnxt_udp_tunl_check()
11335 if (udp_port != bp->vxlan_port && udp_port != bp->nge_port) in bnxt_udp_tunl_check()
11337 if (skb->inner_protocol_type == ENCAP_TYPE_ETHER) { in bnxt_udp_tunl_check()
11340 switch (eh->h_proto) { in bnxt_udp_tunl_check()
11360 switch (skb->inner_protocol) { in bnxt_tunl_check()
11387 if (!skb->encapsulation) in bnxt_features_check()
11389 l4_proto = &ip_hdr(skb)->protocol; in bnxt_features_check()
11420 rc = -ENOMEM; in bnxt_dbg_hwrm_rd_reg()
11424 req->host_dest_addr = cpu_to_le64(mapping); in bnxt_dbg_hwrm_rd_reg()
11427 req->read_addr = cpu_to_le32(reg_off + CHIMP_REG_VIEW_ADDR); in bnxt_dbg_hwrm_rd_reg()
11428 req->read_len32 = cpu_to_le32(num_words); in bnxt_dbg_hwrm_rd_reg()
11431 if (rc || resp->error_code) { in bnxt_dbg_hwrm_rd_reg()
11432 rc = -EIO; in bnxt_dbg_hwrm_rd_reg()
11454 req->ring_type = ring_type; in bnxt_dbg_hwrm_ring_info_get()
11455 req->fw_ring_id = cpu_to_le32(ring_id); in bnxt_dbg_hwrm_ring_info_get()
11459 *prod = le32_to_cpu(resp->producer_index); in bnxt_dbg_hwrm_ring_info_get()
11460 *cons = le32_to_cpu(resp->consumer_index); in bnxt_dbg_hwrm_ring_info_get()
11468 struct bnxt_tx_ring_info *txr = bnapi->tx_ring; in bnxt_dump_tx_sw_state()
11469 int i = bnapi->index; in bnxt_dump_tx_sw_state()
11474 netdev_info(bnapi->bp->dev, "[%d]: tx{fw_ring: %d prod: %x cons: %x}\n", in bnxt_dump_tx_sw_state()
11475 i, txr->tx_ring_struct.fw_ring_id, txr->tx_prod, in bnxt_dump_tx_sw_state()
11476 txr->tx_cons); in bnxt_dump_tx_sw_state()
11481 struct bnxt_rx_ring_info *rxr = bnapi->rx_ring; in bnxt_dump_rx_sw_state()
11482 int i = bnapi->index; in bnxt_dump_rx_sw_state()
11487 …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()
11488 i, rxr->rx_ring_struct.fw_ring_id, rxr->rx_prod, in bnxt_dump_rx_sw_state()
11489 rxr->rx_agg_ring_struct.fw_ring_id, rxr->rx_agg_prod, in bnxt_dump_rx_sw_state()
11490 rxr->rx_sw_agg_prod); in bnxt_dump_rx_sw_state()
11495 struct bnxt_cp_ring_info *cpr = &bnapi->cp_ring; in bnxt_dump_cp_sw_state()
11496 int i = bnapi->index; in bnxt_dump_cp_sw_state()
11498 netdev_info(bnapi->bp->dev, "[%d]: cp{fw_ring: %d raw_cons: %x}\n", in bnxt_dump_cp_sw_state()
11499 i, cpr->cp_ring_struct.fw_ring_id, cpr->cp_raw_cons); in bnxt_dump_cp_sw_state()
11507 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_dbg_dump_states()
11508 bnapi = bp->bnapi[i]; in bnxt_dbg_dump_states()
11519 struct bnxt_rx_ring_info *rxr = &bp->rx_ring[ring_nr]; in bnxt_hwrm_rx_ring_reset()
11521 struct bnxt_napi *bnapi = rxr->bnapi; in bnxt_hwrm_rx_ring_reset()
11530 cpr = &bnapi->cp_ring; in bnxt_hwrm_rx_ring_reset()
11531 cp_ring_id = cpr->cp_ring_struct.fw_ring_id; in bnxt_hwrm_rx_ring_reset()
11532 req->cmpl_ring = cpu_to_le16(cp_ring_id); in bnxt_hwrm_rx_ring_reset()
11533 req->ring_type = RING_RESET_REQ_RING_TYPE_RX_RING_GRP; in bnxt_hwrm_rx_ring_reset()
11534 req->ring_id = cpu_to_le16(bp->grp_info[bnapi->index].fw_grp_id); in bnxt_hwrm_rx_ring_reset()
11542 if (netif_running(bp->dev)) { in bnxt_reset_task()
11561 netdev_err(bp->dev, "TX timeout detected, starting reset task!\n"); in bnxt_tx_timeout()
11562 set_bit(BNXT_RESET_TASK_SP_EVENT, &bp->sp_event); in bnxt_tx_timeout()
11568 struct bnxt_fw_health *fw_health = bp->fw_health; in bnxt_fw_health_check()
11571 if (!fw_health->enabled || test_bit(BNXT_STATE_IN_FW_RESET, &bp->state)) in bnxt_fw_health_check()
11576 if (fw_health->tmr_counter) { in bnxt_fw_health_check()
11577 fw_health->tmr_counter--; in bnxt_fw_health_check()
11582 if (val == fw_health->last_fw_heartbeat) { in bnxt_fw_health_check()
11583 fw_health->arrests++; in bnxt_fw_health_check()
11587 fw_health->last_fw_heartbeat = val; in bnxt_fw_health_check()
11590 if (val != fw_health->last_fw_reset_cnt) { in bnxt_fw_health_check()
11591 fw_health->discoveries++; in bnxt_fw_health_check()
11595 fw_health->tmr_counter = fw_health->tmr_multiplier; in bnxt_fw_health_check()
11599 set_bit(BNXT_FW_EXCEPTION_SP_EVENT, &bp->sp_event); in bnxt_fw_health_check()
11606 struct net_device *dev = bp->dev; in bnxt_timer()
11608 if (!netif_running(dev) || !test_bit(BNXT_STATE_OPEN, &bp->state)) in bnxt_timer()
11611 if (atomic_read(&bp->intr_sem) != 0) in bnxt_timer()
11614 if (bp->fw_cap & BNXT_FW_CAP_ERROR_RECOVERY) in bnxt_timer()
11617 if (BNXT_LINK_IS_UP(bp) && bp->stats_coal_ticks) { in bnxt_timer()
11618 set_bit(BNXT_PERIODIC_STATS_SP_EVENT, &bp->sp_event); in bnxt_timer()
11623 set_bit(BNXT_FLOW_STATS_SP_EVENT, &bp->sp_event); in bnxt_timer()
11628 if ((bp->flags & BNXT_FLAG_RFS) && bp->ntp_fltr_count) { in bnxt_timer()
11629 set_bit(BNXT_RX_NTP_FLTR_SP_EVENT, &bp->sp_event); in bnxt_timer()
11634 if (bp->link_info.phy_retry) { in bnxt_timer()
11635 if (time_after(jiffies, bp->link_info.phy_retry_expires)) { in bnxt_timer()
11636 bp->link_info.phy_retry = false; in bnxt_timer()
11637 netdev_warn(bp->dev, "failed to update phy settings after maximum retries.\n"); in bnxt_timer()
11639 set_bit(BNXT_UPDATE_PHY_SP_EVENT, &bp->sp_event); in bnxt_timer()
11644 if (test_bit(BNXT_STATE_L2_FILTER_RETRY, &bp->state)) { in bnxt_timer()
11645 set_bit(BNXT_RX_MASK_SP_EVENT, &bp->sp_event); in bnxt_timer()
11649 if ((bp->flags & BNXT_FLAG_CHIP_P5) && !bp->chip_rev && in bnxt_timer()
11651 set_bit(BNXT_RING_COAL_NOW_SP_EVENT, &bp->sp_event); in bnxt_timer()
11655 mod_timer(&bp->timer, jiffies + bp->current_interval); in bnxt_timer()
11665 clear_bit(BNXT_STATE_IN_SP_TASK, &bp->state); in bnxt_rtnl_lock_sp()
11671 set_bit(BNXT_STATE_IN_SP_TASK, &bp->state); in bnxt_rtnl_unlock_sp()
11679 if (test_bit(BNXT_STATE_OPEN, &bp->state)) in bnxt_reset()
11690 if (!test_bit(BNXT_STATE_OPEN, &bp->state)) { in bnxt_rx_ring_reset()
11695 if (bp->flags & BNXT_FLAG_TPA) in bnxt_rx_ring_reset()
11697 for (i = 0; i < bp->rx_nr_rings; i++) { in bnxt_rx_ring_reset()
11698 struct bnxt_rx_ring_info *rxr = &bp->rx_ring[i]; in bnxt_rx_ring_reset()
11702 if (!rxr->bnapi->in_reset) in bnxt_rx_ring_reset()
11707 if (rc == -EINVAL || rc == -EOPNOTSUPP) in bnxt_rx_ring_reset()
11708 …netdev_info_once(bp->dev, "RX ring reset not supported by firmware, falling back to global reset\n… in bnxt_rx_ring_reset()
11710 netdev_warn(bp->dev, "RX ring reset failed, rc = %d, falling back to global reset\n", in bnxt_rx_ring_reset()
11716 rxr->rx_prod = 0; in bnxt_rx_ring_reset()
11717 rxr->rx_agg_prod = 0; in bnxt_rx_ring_reset()
11718 rxr->rx_sw_agg_prod = 0; in bnxt_rx_ring_reset()
11719 rxr->rx_next_cons = 0; in bnxt_rx_ring_reset()
11720 rxr->bnapi->in_reset = false; in bnxt_rx_ring_reset()
11722 cpr = &rxr->bnapi->cp_ring; in bnxt_rx_ring_reset()
11723 cpr->sw_stats.rx.rx_resets++; in bnxt_rx_ring_reset()
11724 if (bp->flags & BNXT_FLAG_AGG_RINGS) in bnxt_rx_ring_reset()
11725 bnxt_db_write(bp, &rxr->rx_agg_db, rxr->rx_agg_prod); in bnxt_rx_ring_reset()
11726 bnxt_db_write(bp, &rxr->rx_db, rxr->rx_prod); in bnxt_rx_ring_reset()
11728 if (bp->flags & BNXT_FLAG_TPA) in bnxt_rx_ring_reset()
11740 if (test_bit(BNXT_STATE_FW_FATAL_COND, &bp->state)) { in bnxt_fw_reset_close()
11743 pci_read_config_word(bp->pdev, PCI_SUBSYSTEM_ID, &val); in bnxt_fw_reset_close()
11745 bp->fw_reset_min_dsecs = 0; in bnxt_fw_reset_close()
11751 pci_disable_device(bp->pdev); in bnxt_fw_reset_close()
11757 if (pci_is_enabled(bp->pdev)) in bnxt_fw_reset_close()
11758 pci_disable_device(bp->pdev); in bnxt_fw_reset_close()
11760 kfree(bp->ctx); in bnxt_fw_reset_close()
11761 bp->ctx = NULL; in bnxt_fw_reset_close()
11766 struct bnxt_fw_health *fw_health = bp->fw_health; in is_bnxt_fw_ok()
11771 if (val == fw_health->last_fw_heartbeat) in is_bnxt_fw_ok()
11775 if (val != fw_health->last_fw_reset_cnt) in is_bnxt_fw_ok()
11787 struct bnxt_fw_health *fw_health = bp->fw_health; in bnxt_force_fw_reset()
11788 struct bnxt_ptp_cfg *ptp = bp->ptp_cfg; in bnxt_force_fw_reset()
11791 if (!test_bit(BNXT_STATE_OPEN, &bp->state) || in bnxt_force_fw_reset()
11792 test_bit(BNXT_STATE_IN_FW_RESET, &bp->state)) in bnxt_force_fw_reset()
11796 spin_lock_bh(&ptp->ptp_lock); in bnxt_force_fw_reset()
11797 set_bit(BNXT_STATE_IN_FW_RESET, &bp->state); in bnxt_force_fw_reset()
11798 spin_unlock_bh(&ptp->ptp_lock); in bnxt_force_fw_reset()
11800 set_bit(BNXT_STATE_IN_FW_RESET, &bp->state); in bnxt_force_fw_reset()
11803 wait_dsecs = fw_health->master_func_wait_dsecs; in bnxt_force_fw_reset()
11804 if (fw_health->primary) { in bnxt_force_fw_reset()
11805 if (fw_health->flags & ERROR_RECOVERY_QCFG_RESP_FLAGS_CO_CPU) in bnxt_force_fw_reset()
11807 bp->fw_reset_state = BNXT_FW_RESET_STATE_RESET_FW; in bnxt_force_fw_reset()
11809 bp->fw_reset_timestamp = jiffies + wait_dsecs * HZ / 10; in bnxt_force_fw_reset()
11810 wait_dsecs = fw_health->normal_func_wait_dsecs; in bnxt_force_fw_reset()
11811 bp->fw_reset_state = BNXT_FW_RESET_STATE_ENABLE_DEV; in bnxt_force_fw_reset()
11814 bp->fw_reset_min_dsecs = fw_health->post_reset_wait_dsecs; in bnxt_force_fw_reset()
11815 bp->fw_reset_max_dsecs = fw_health->post_reset_max_wait_dsecs; in bnxt_force_fw_reset()
11821 netdev_warn(bp->dev, "Detected firmware fatal condition, initiating reset\n"); in bnxt_fw_exception()
11822 set_bit(BNXT_STATE_FW_FATAL_COND, &bp->state); in bnxt_fw_exception()
11841 netdev_err(bp->dev, "func_qcfg cmd failed, rc = %d\n", rc); in bnxt_get_registered_vfs()
11844 if (bp->pf.registered_vfs) in bnxt_get_registered_vfs()
11845 return bp->pf.registered_vfs; in bnxt_get_registered_vfs()
11846 if (bp->sriov_cfg) in bnxt_get_registered_vfs()
11855 if (test_bit(BNXT_STATE_OPEN, &bp->state) && in bnxt_fw_reset()
11856 !test_bit(BNXT_STATE_IN_FW_RESET, &bp->state)) { in bnxt_fw_reset()
11857 struct bnxt_ptp_cfg *ptp = bp->ptp_cfg; in bnxt_fw_reset()
11861 spin_lock_bh(&ptp->ptp_lock); in bnxt_fw_reset()
11862 set_bit(BNXT_STATE_IN_FW_RESET, &bp->state); in bnxt_fw_reset()
11863 spin_unlock_bh(&ptp->ptp_lock); in bnxt_fw_reset()
11865 set_bit(BNXT_STATE_IN_FW_RESET, &bp->state); in bnxt_fw_reset()
11867 if (bp->pf.active_vfs && in bnxt_fw_reset()
11868 !test_bit(BNXT_STATE_FW_FATAL_COND, &bp->state)) in bnxt_fw_reset()
11871 netdev_err(bp->dev, "Firmware reset aborted, rc = %d\n", in bnxt_fw_reset()
11873 clear_bit(BNXT_STATE_IN_FW_RESET, &bp->state); in bnxt_fw_reset()
11874 dev_close(bp->dev); in bnxt_fw_reset()
11879 if (bp->fw_reset_max_dsecs < vf_tmo_dsecs) in bnxt_fw_reset()
11880 bp->fw_reset_max_dsecs = vf_tmo_dsecs; in bnxt_fw_reset()
11881 bp->fw_reset_state = in bnxt_fw_reset()
11887 if (bp->fw_cap & BNXT_FW_CAP_ERR_RECOVER_RELOAD) { in bnxt_fw_reset()
11888 bp->fw_reset_state = BNXT_FW_RESET_STATE_POLL_FW_DOWN; in bnxt_fw_reset()
11891 bp->fw_reset_state = BNXT_FW_RESET_STATE_ENABLE_DEV; in bnxt_fw_reset()
11892 tmo = bp->fw_reset_min_dsecs * HZ / 10; in bnxt_fw_reset()
11904 if (!(bp->flags & BNXT_FLAG_CHIP_P5)) in bnxt_chk_missed_irq()
11907 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_chk_missed_irq()
11908 struct bnxt_napi *bnapi = bp->bnapi[i]; in bnxt_chk_missed_irq()
11916 cpr = &bnapi->cp_ring; in bnxt_chk_missed_irq()
11918 struct bnxt_cp_ring_info *cpr2 = cpr->cp_ring_arr[j]; in bnxt_chk_missed_irq()
11921 if (!cpr2 || cpr2->has_more_work || in bnxt_chk_missed_irq()
11925 if (cpr2->cp_raw_cons != cpr2->last_cp_raw_cons) { in bnxt_chk_missed_irq()
11926 cpr2->last_cp_raw_cons = cpr2->cp_raw_cons; in bnxt_chk_missed_irq()
11929 fw_ring_id = cpr2->cp_ring_struct.fw_ring_id; in bnxt_chk_missed_irq()
11933 cpr->sw_stats.cmn.missed_irqs++; in bnxt_chk_missed_irq()
11942 struct bnxt_link_info *link_info = &bp->link_info; in bnxt_init_ethtool_link_settings()
11944 if (BNXT_AUTO_MODE(link_info->auto_mode)) { in bnxt_init_ethtool_link_settings()
11945 link_info->autoneg = BNXT_AUTONEG_SPEED; in bnxt_init_ethtool_link_settings()
11946 if (bp->hwrm_spec_code >= 0x10201) { in bnxt_init_ethtool_link_settings()
11947 if (link_info->auto_pause_setting & in bnxt_init_ethtool_link_settings()
11949 link_info->autoneg |= BNXT_AUTONEG_FLOW_CTRL; in bnxt_init_ethtool_link_settings()
11951 link_info->autoneg |= BNXT_AUTONEG_FLOW_CTRL; in bnxt_init_ethtool_link_settings()
11953 link_info->advertising = link_info->auto_link_speeds; in bnxt_init_ethtool_link_settings()
11954 link_info->advertising_pam4 = link_info->auto_pam4_link_speeds; in bnxt_init_ethtool_link_settings()
11956 link_info->req_link_speed = link_info->force_link_speed; in bnxt_init_ethtool_link_settings()
11957 link_info->req_signal_mode = BNXT_SIG_MODE_NRZ; in bnxt_init_ethtool_link_settings()
11958 if (link_info->force_pam4_link_speed) { in bnxt_init_ethtool_link_settings()
11959 link_info->req_link_speed = in bnxt_init_ethtool_link_settings()
11960 link_info->force_pam4_link_speed; in bnxt_init_ethtool_link_settings()
11961 link_info->req_signal_mode = BNXT_SIG_MODE_PAM4; in bnxt_init_ethtool_link_settings()
11963 link_info->req_duplex = link_info->duplex_setting; in bnxt_init_ethtool_link_settings()
11965 if (link_info->autoneg & BNXT_AUTONEG_FLOW_CTRL) in bnxt_init_ethtool_link_settings()
11966 link_info->req_flow_ctrl = in bnxt_init_ethtool_link_settings()
11967 link_info->auto_pause_setting & BNXT_LINK_PAUSE_BOTH; in bnxt_init_ethtool_link_settings()
11969 link_info->req_flow_ctrl = link_info->force_pause_setting; in bnxt_init_ethtool_link_settings()
11974 struct bnxt_fw_health *fw_health = bp->fw_health; in bnxt_fw_echo_reply()
11981 req->event_data1 = cpu_to_le32(fw_health->echo_req_data1); in bnxt_fw_echo_reply()
11982 req->event_data2 = cpu_to_le32(fw_health->echo_req_data2); in bnxt_fw_echo_reply()
11990 set_bit(BNXT_STATE_IN_SP_TASK, &bp->state); in bnxt_sp_task()
11992 if (!test_bit(BNXT_STATE_OPEN, &bp->state)) { in bnxt_sp_task()
11993 clear_bit(BNXT_STATE_IN_SP_TASK, &bp->state); in bnxt_sp_task()
11997 if (test_and_clear_bit(BNXT_RX_MASK_SP_EVENT, &bp->sp_event)) in bnxt_sp_task()
12000 if (test_and_clear_bit(BNXT_RX_NTP_FLTR_SP_EVENT, &bp->sp_event)) in bnxt_sp_task()
12002 if (test_and_clear_bit(BNXT_HWRM_EXEC_FWD_REQ_SP_EVENT, &bp->sp_event)) in bnxt_sp_task()
12004 if (test_and_clear_bit(BNXT_PERIODIC_STATS_SP_EVENT, &bp->sp_event)) { in bnxt_sp_task()
12010 if (test_and_clear_bit(BNXT_LINK_CHNG_SP_EVENT, &bp->sp_event)) { in bnxt_sp_task()
12013 mutex_lock(&bp->link_lock); in bnxt_sp_task()
12015 &bp->sp_event)) in bnxt_sp_task()
12020 netdev_err(bp->dev, "SP task can't update link (rc: %x)\n", in bnxt_sp_task()
12024 &bp->sp_event)) in bnxt_sp_task()
12026 mutex_unlock(&bp->link_lock); in bnxt_sp_task()
12028 if (test_and_clear_bit(BNXT_UPDATE_PHY_SP_EVENT, &bp->sp_event)) { in bnxt_sp_task()
12031 mutex_lock(&bp->link_lock); in bnxt_sp_task()
12033 mutex_unlock(&bp->link_lock); in bnxt_sp_task()
12035 netdev_warn(bp->dev, "update phy settings retry failed\n"); in bnxt_sp_task()
12037 bp->link_info.phy_retry = false; in bnxt_sp_task()
12038 netdev_info(bp->dev, "update phy settings retry succeeded\n"); in bnxt_sp_task()
12041 if (test_and_clear_bit(BNXT_HWRM_PORT_MODULE_SP_EVENT, &bp->sp_event)) { in bnxt_sp_task()
12042 mutex_lock(&bp->link_lock); in bnxt_sp_task()
12044 mutex_unlock(&bp->link_lock); in bnxt_sp_task()
12047 if (test_and_clear_bit(BNXT_FLOW_STATS_SP_EVENT, &bp->sp_event)) in bnxt_sp_task()
12050 if (test_and_clear_bit(BNXT_RING_COAL_NOW_SP_EVENT, &bp->sp_event)) in bnxt_sp_task()
12053 if (test_and_clear_bit(BNXT_FW_ECHO_REQUEST_SP_EVENT, &bp->sp_event)) in bnxt_sp_task()
12059 if (test_and_clear_bit(BNXT_RESET_TASK_SP_EVENT, &bp->sp_event)) in bnxt_sp_task()
12062 if (test_and_clear_bit(BNXT_RESET_TASK_SILENT_SP_EVENT, &bp->sp_event)) in bnxt_sp_task()
12065 if (test_and_clear_bit(BNXT_RST_RING_SP_EVENT, &bp->sp_event)) in bnxt_sp_task()
12068 if (test_and_clear_bit(BNXT_FW_RESET_NOTIFY_SP_EVENT, &bp->sp_event)) { in bnxt_sp_task()
12069 if (test_bit(BNXT_STATE_FW_FATAL_COND, &bp->state) || in bnxt_sp_task()
12070 test_bit(BNXT_STATE_FW_NON_FATAL_COND, &bp->state)) in bnxt_sp_task()
12076 if (test_and_clear_bit(BNXT_FW_EXCEPTION_SP_EVENT, &bp->sp_event)) { in bnxt_sp_task()
12082 clear_bit(BNXT_STATE_IN_SP_TASK, &bp->state); in bnxt_sp_task()
12102 return -ENOMEM; in bnxt_check_rings()
12106 return -ENOMEM; in bnxt_check_rings()
12109 if ((bp->flags & (BNXT_FLAG_RFS | BNXT_FLAG_CHIP_P5)) == BNXT_FLAG_RFS) in bnxt_check_rings()
12112 if (bp->flags & BNXT_FLAG_AGG_RINGS) in bnxt_check_rings()
12126 if (bp->bar2) { in bnxt_unmap_bars()
12127 pci_iounmap(pdev, bp->bar2); in bnxt_unmap_bars()
12128 bp->bar2 = NULL; in bnxt_unmap_bars()
12131 if (bp->bar1) { in bnxt_unmap_bars()
12132 pci_iounmap(pdev, bp->bar1); in bnxt_unmap_bars()
12133 bp->bar1 = NULL; in bnxt_unmap_bars()
12136 if (bp->bar0) { in bnxt_unmap_bars()
12137 pci_iounmap(pdev, bp->bar0); in bnxt_unmap_bars()
12138 bp->bar0 = NULL; in bnxt_unmap_bars()
12144 bnxt_unmap_bars(bp, bp->pdev); in bnxt_cleanup_pci()
12145 pci_release_regions(bp->pdev); in bnxt_cleanup_pci()
12146 if (pci_is_enabled(bp->pdev)) in bnxt_cleanup_pci()
12147 pci_disable_device(bp->pdev); in bnxt_cleanup_pci()
12152 struct bnxt_coal_cap *coal_cap = &bp->coal_cap; in bnxt_init_dflt_coal()
12156 if (coal_cap->cmpl_params & in bnxt_init_dflt_coal()
12163 coal = &bp->rx_coal; in bnxt_init_dflt_coal()
12164 coal->coal_ticks = 10; in bnxt_init_dflt_coal()
12165 coal->coal_bufs = 30; in bnxt_init_dflt_coal()
12166 coal->coal_ticks_irq = 1; in bnxt_init_dflt_coal()
12167 coal->coal_bufs_irq = 2; in bnxt_init_dflt_coal()
12168 coal->idle_thresh = 50; in bnxt_init_dflt_coal()
12169 coal->bufs_per_record = 2; in bnxt_init_dflt_coal()
12170 coal->budget = 64; /* NAPI budget */ in bnxt_init_dflt_coal()
12171 coal->flags = flags; in bnxt_init_dflt_coal()
12173 coal = &bp->tx_coal; in bnxt_init_dflt_coal()
12174 coal->coal_ticks = 28; in bnxt_init_dflt_coal()
12175 coal->coal_bufs = 30; in bnxt_init_dflt_coal()
12176 coal->coal_ticks_irq = 2; in bnxt_init_dflt_coal()
12177 coal->coal_bufs_irq = 2; in bnxt_init_dflt_coal()
12178 coal->bufs_per_record = 1; in bnxt_init_dflt_coal()
12179 coal->flags = flags; in bnxt_init_dflt_coal()
12181 bp->stats_coal_ticks = BNXT_DEF_STATS_COAL_TICKS; in bnxt_init_dflt_coal()
12188 bp->fw_cap = 0; in bnxt_fw_init_one_p1()
12204 return -ENODEV; in bnxt_fw_init_one_p1()
12217 netdev_err(bp->dev, "hwrm query capability failure rc: %x\n", in bnxt_fw_init_one_p2()
12219 return -ENODEV; in bnxt_fw_init_one_p2()
12224 netdev_warn(bp->dev, "hwrm query adv flow mgnt failure rc: %d\n", in bnxt_fw_init_one_p2()
12228 netdev_warn(bp->dev, "no memory for firmware error recovery\n"); in bnxt_fw_init_one_p2()
12232 netdev_warn(bp->dev, "hwrm query error recovery failure rc: %d\n", in bnxt_fw_init_one_p2()
12238 return -ENODEV; in bnxt_fw_init_one_p2()
12250 bp->flags &= ~BNXT_FLAG_UDP_RSS_CAP; in bnxt_set_dflt_rss_hash_type()
12251 bp->rss_hash_cfg = VNIC_RSS_CFG_REQ_HASH_TYPE_IPV4 | in bnxt_set_dflt_rss_hash_type()
12255 if (BNXT_CHIP_P4_PLUS(bp) && bp->hwrm_spec_code >= 0x10501) { in bnxt_set_dflt_rss_hash_type()
12256 bp->flags |= BNXT_FLAG_UDP_RSS_CAP; in bnxt_set_dflt_rss_hash_type()
12257 bp->rss_hash_cfg |= VNIC_RSS_CFG_REQ_HASH_TYPE_UDP_IPV4 | in bnxt_set_dflt_rss_hash_type()
12264 struct net_device *dev = bp->dev; in bnxt_set_dflt_rfs()
12266 dev->hw_features &= ~NETIF_F_NTUPLE; in bnxt_set_dflt_rfs()
12267 dev->features &= ~NETIF_F_NTUPLE; in bnxt_set_dflt_rfs()
12268 bp->flags &= ~BNXT_FLAG_RFS; in bnxt_set_dflt_rfs()
12270 dev->hw_features |= NETIF_F_NTUPLE; in bnxt_set_dflt_rfs()
12272 bp->flags |= BNXT_FLAG_RFS; in bnxt_set_dflt_rfs()
12273 dev->features |= NETIF_F_NTUPLE; in bnxt_set_dflt_rfs()
12280 struct pci_dev *pdev = bp->pdev; in bnxt_fw_init_one_p3()
12286 if (bp->flags & BNXT_FLAG_WOL_CAP) in bnxt_fw_init_one_p3()
12287 device_set_wakeup_enable(&pdev->dev, bp->wol); in bnxt_fw_init_one_p3()
12289 device_set_wakeup_capable(&pdev->dev, false); in bnxt_fw_init_one_p3()
12303 netdev_err(bp->dev, "Firmware init phase 1 failed\n"); in bnxt_fw_init_one()
12308 netdev_err(bp->dev, "Firmware init phase 2 failed\n"); in bnxt_fw_init_one()
12314 rc = bnxt_approve_mac(bp, bp->dev->dev_addr, false); in bnxt_fw_init_one()
12324 struct bnxt_fw_health *fw_health = bp->fw_health; in bnxt_fw_reset_writel()
12325 u32 reg = fw_health->fw_reset_seq_regs[reg_idx]; in bnxt_fw_reset_writel()
12326 u32 val = fw_health->fw_reset_seq_vals[reg_idx]; in bnxt_fw_reset_writel()
12329 delay_msecs = fw_health->fw_reset_seq_delay_msec[reg_idx]; in bnxt_fw_reset_writel()
12334 pci_write_config_dword(bp->pdev, reg_off, val); in bnxt_fw_reset_writel()
12338 bp->bar0 + BNXT_GRCPF_REG_WINDOW_BASE_OUT + 4); in bnxt_fw_reset_writel()
12342 writel(val, bp->bar0 + reg_off); in bnxt_fw_reset_writel()
12345 writel(val, bp->bar1 + reg_off); in bnxt_fw_reset_writel()
12349 pci_read_config_dword(bp->pdev, 0, &val); in bnxt_fw_reset_writel()
12360 if (~bp->fw_cap & BNXT_FW_CAP_HOT_RESET_IF) in bnxt_hwrm_reset_permitted()
12366 req->fid = cpu_to_le16(0xffff); in bnxt_hwrm_reset_permitted()
12369 result = !!(le16_to_cpu(resp->flags) & in bnxt_hwrm_reset_permitted()
12377 struct bnxt_fw_health *fw_health = bp->fw_health; in bnxt_reset_all()
12380 if (bp->fw_cap & BNXT_FW_CAP_ERR_RECOVER_RELOAD) { in bnxt_reset_all()
12382 bp->fw_reset_timestamp = jiffies; in bnxt_reset_all()
12386 if (fw_health->flags & ERROR_RECOVERY_QCFG_RESP_FLAGS_HOST) { in bnxt_reset_all()
12387 for (i = 0; i < fw_health->fw_reset_seq_cnt; i++) in bnxt_reset_all()
12389 } else if (fw_health->flags & ERROR_RECOVERY_QCFG_RESP_FLAGS_CO_CPU) { in bnxt_reset_all()
12394 req->target_id = cpu_to_le16(HWRM_TARGET_ID_KONG); in bnxt_reset_all()
12395 req->embedded_proc_type = FW_RESET_REQ_EMBEDDED_PROC_TYPE_CHIP; in bnxt_reset_all()
12396 req->selfrst_status = FW_RESET_REQ_SELFRST_STATUS_SELFRSTASAP; in bnxt_reset_all()
12397 req->flags = FW_RESET_REQ_FLAGS_RESET_GRACEFUL; in bnxt_reset_all()
12400 if (rc != -ENODEV) in bnxt_reset_all()
12401 netdev_warn(bp->dev, "Unable to reset FW rc=%d\n", rc); in bnxt_reset_all()
12403 bp->fw_reset_timestamp = jiffies; in bnxt_reset_all()
12408 return time_after(jiffies, bp->fw_reset_timestamp + in bnxt_fw_reset_timeout()
12409 (bp->fw_reset_max_dsecs * HZ / 10)); in bnxt_fw_reset_timeout()
12414 clear_bit(BNXT_STATE_IN_FW_RESET, &bp->state); in bnxt_fw_reset_abort()
12415 if (bp->fw_reset_state != BNXT_FW_RESET_STATE_POLL_VF) { in bnxt_fw_reset_abort()
12419 bp->fw_reset_state = 0; in bnxt_fw_reset_abort()
12420 dev_close(bp->dev); in bnxt_fw_reset_abort()
12428 if (!test_bit(BNXT_STATE_IN_FW_RESET, &bp->state)) { in bnxt_fw_reset_task()
12429 netdev_err(bp->dev, "bnxt_fw_reset_task() called when not in fw reset mode!\n"); in bnxt_fw_reset_task()
12433 switch (bp->fw_reset_state) { in bnxt_fw_reset_task()
12439 …netdev_err(bp->dev, "Firmware reset aborted, subsequent func_qcfg cmd failed, rc = %d, %d msecs si… in bnxt_fw_reset_task()
12440 n, jiffies_to_msecs(jiffies - in bnxt_fw_reset_task()
12441 bp->fw_reset_timestamp)); in bnxt_fw_reset_task()
12445 clear_bit(BNXT_STATE_IN_FW_RESET, &bp->state); in bnxt_fw_reset_task()
12446 bp->fw_reset_state = 0; in bnxt_fw_reset_task()
12447 netdev_err(bp->dev, "Firmware reset aborted, bnxt_get_registered_vfs() returns %d\n", in bnxt_fw_reset_task()
12454 bp->fw_reset_timestamp = jiffies; in bnxt_fw_reset_task()
12456 if (test_bit(BNXT_STATE_ABORT_ERR, &bp->state)) { in bnxt_fw_reset_task()
12462 if (bp->fw_cap & BNXT_FW_CAP_ERR_RECOVER_RELOAD) { in bnxt_fw_reset_task()
12463 bp->fw_reset_state = BNXT_FW_RESET_STATE_POLL_FW_DOWN; in bnxt_fw_reset_task()
12466 bp->fw_reset_state = BNXT_FW_RESET_STATE_ENABLE_DEV; in bnxt_fw_reset_task()
12467 tmo = bp->fw_reset_min_dsecs * HZ / 10; in bnxt_fw_reset_task()
12483 if (!bp->fw_health->primary) { in bnxt_fw_reset_task()
12484 u32 wait_dsecs = bp->fw_health->normal_func_wait_dsecs; in bnxt_fw_reset_task()
12486 bp->fw_reset_state = BNXT_FW_RESET_STATE_ENABLE_DEV; in bnxt_fw_reset_task()
12490 bp->fw_reset_state = BNXT_FW_RESET_STATE_RESET_FW; in bnxt_fw_reset_task()
12495 bp->fw_reset_state = BNXT_FW_RESET_STATE_ENABLE_DEV; in bnxt_fw_reset_task()
12496 bnxt_queue_fw_reset_work(bp, bp->fw_reset_min_dsecs * HZ / 10); in bnxt_fw_reset_task()
12500 if (test_bit(BNXT_STATE_FW_FATAL_COND, &bp->state) && in bnxt_fw_reset_task()
12501 !bp->fw_reset_min_dsecs) { in bnxt_fw_reset_task()
12504 pci_read_config_word(bp->pdev, PCI_SUBSYSTEM_ID, &val); in bnxt_fw_reset_task()
12507 netdev_err(bp->dev, "Firmware reset aborted, PCI config space invalid\n"); in bnxt_fw_reset_task()
12508 rc = -ETIMEDOUT; in bnxt_fw_reset_task()
12515 clear_bit(BNXT_STATE_FW_FATAL_COND, &bp->state); in bnxt_fw_reset_task()
12516 clear_bit(BNXT_STATE_FW_NON_FATAL_COND, &bp->state); in bnxt_fw_reset_task()
12517 if (test_and_clear_bit(BNXT_STATE_FW_ACTIVATE_RESET, &bp->state) && in bnxt_fw_reset_task()
12518 !test_bit(BNXT_STATE_FW_ACTIVATE, &bp->state)) in bnxt_fw_reset_task()
12520 if (pci_enable_device(bp->pdev)) { in bnxt_fw_reset_task()
12521 netdev_err(bp->dev, "Cannot re-enable PCI device\n"); in bnxt_fw_reset_task()
12522 rc = -ENODEV; in bnxt_fw_reset_task()
12525 pci_set_master(bp->pdev); in bnxt_fw_reset_task()
12526 bp->fw_reset_state = BNXT_FW_RESET_STATE_POLL_FW; in bnxt_fw_reset_task()
12529 bp->hwrm_cmd_timeout = SHORT_HWRM_CMD_TIMEOUT; in bnxt_fw_reset_task()
12533 netdev_err(bp->dev, "Firmware reset aborted\n"); in bnxt_fw_reset_task()
12539 bp->hwrm_cmd_timeout = DFLT_HWRM_CMD_TIMEOUT; in bnxt_fw_reset_task()
12540 bp->fw_reset_state = BNXT_FW_RESET_STATE_OPENING; in bnxt_fw_reset_task()
12547 rc = bnxt_open(bp->dev); in bnxt_fw_reset_task()
12549 netdev_err(bp->dev, "bnxt_open() failed during FW reset\n"); in bnxt_fw_reset_task()
12555 if ((bp->fw_cap & BNXT_FW_CAP_ERROR_RECOVERY) && in bnxt_fw_reset_task()
12556 bp->fw_health->enabled) { in bnxt_fw_reset_task()
12557 bp->fw_health->last_fw_reset_cnt = in bnxt_fw_reset_task()
12560 bp->fw_reset_state = 0; in bnxt_fw_reset_task()
12563 clear_bit(BNXT_STATE_IN_FW_RESET, &bp->state); in bnxt_fw_reset_task()
12569 clear_bit(BNXT_STATE_FW_ACTIVATE, &bp->state); in bnxt_fw_reset_task()
12570 if (test_and_clear_bit(BNXT_STATE_RECOVER, &bp->state)) { in bnxt_fw_reset_task()
12580 if (bp->fw_health->status_reliable || in bnxt_fw_reset_task()
12581 (bp->fw_cap & BNXT_FW_CAP_ERROR_RECOVERY)) { in bnxt_fw_reset_task()
12584 netdev_err(bp->dev, "fw_health_status 0x%x\n", sts); in bnxt_fw_reset_task()
12597 SET_NETDEV_DEV(dev, &pdev->dev); in bnxt_init_board()
12599 /* enable device (incl. PCI PM wakeup), and bus-mastering */ in bnxt_init_board()
12602 dev_err(&pdev->dev, "Cannot enable PCI device, aborting\n"); in bnxt_init_board()
12607 dev_err(&pdev->dev, in bnxt_init_board()
12609 rc = -ENODEV; in bnxt_init_board()
12615 dev_err(&pdev->dev, "Cannot obtain PCI resources, aborting\n"); in bnxt_init_board()
12619 if (dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)) != 0 && in bnxt_init_board()
12620 dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32)) != 0) { in bnxt_init_board()
12621 dev_err(&pdev->dev, "System does not support DMA, aborting\n"); in bnxt_init_board()
12622 rc = -EIO; in bnxt_init_board()
12628 bp->dev = dev; in bnxt_init_board()
12629 bp->pdev = pdev; in bnxt_init_board()
12631 /* Doorbell BAR bp->bar1 is mapped after bnxt_fw_init_one_p2() in bnxt_init_board()
12634 bp->bar0 = pci_ioremap_bar(pdev, 0); in bnxt_init_board()
12635 if (!bp->bar0) { in bnxt_init_board()
12636 dev_err(&pdev->dev, "Cannot map device registers, aborting\n"); in bnxt_init_board()
12637 rc = -ENOMEM; in bnxt_init_board()
12641 bp->bar2 = pci_ioremap_bar(pdev, 4); in bnxt_init_board()
12642 if (!bp->bar2) { in bnxt_init_board()
12643 dev_err(&pdev->dev, "Cannot map bar4 registers, aborting\n"); in bnxt_init_board()
12644 rc = -ENOMEM; in bnxt_init_board()
12650 INIT_WORK(&bp->sp_task, bnxt_sp_task); in bnxt_init_board()
12651 INIT_DELAYED_WORK(&bp->fw_reset_task, bnxt_fw_reset_task); in bnxt_init_board()
12653 spin_lock_init(&bp->ntp_fltr_lock); in bnxt_init_board()
12655 spin_lock_init(&bp->db_lock); in bnxt_init_board()
12658 bp->rx_ring_size = BNXT_DEFAULT_RX_RING_SIZE; in bnxt_init_board()
12659 bp->tx_ring_size = BNXT_DEFAULT_TX_RING_SIZE; in bnxt_init_board()
12661 timer_setup(&bp->timer, bnxt_timer, 0); in bnxt_init_board()
12662 bp->current_interval = BNXT_TIMER_INTERVAL; in bnxt_init_board()
12664 bp->vxlan_fw_dst_port_id = INVALID_HW_RING_ID; in bnxt_init_board()
12665 bp->nge_fw_dst_port_id = INVALID_HW_RING_ID; in bnxt_init_board()
12667 clear_bit(BNXT_STATE_OPEN, &bp->state); in bnxt_init_board()
12688 if (!is_valid_ether_addr(addr->sa_data)) in bnxt_change_mac_addr()
12689 return -EADDRNOTAVAIL; in bnxt_change_mac_addr()
12691 if (ether_addr_equal(addr->sa_data, dev->dev_addr)) in bnxt_change_mac_addr()
12694 rc = bnxt_approve_mac(bp, addr->sa_data, true); in bnxt_change_mac_addr()
12698 eth_hw_addr_set(dev, addr->sa_data); in bnxt_change_mac_addr()
12715 dev->mtu = new_mtu; in bnxt_change_mtu()
12730 if (tc > bp->max_tc) { in bnxt_setup_mq_tc()
12732 tc, bp->max_tc); in bnxt_setup_mq_tc()
12733 return -EINVAL; in bnxt_setup_mq_tc()
12739 if (bp->flags & BNXT_FLAG_SHARED_RINGS) in bnxt_setup_mq_tc()
12742 rc = bnxt_check_rings(bp, bp->tx_nr_rings_per_tc, bp->rx_nr_rings, in bnxt_setup_mq_tc()
12743 sh, tc, bp->tx_nr_rings_xdp); in bnxt_setup_mq_tc()
12747 /* Needs to close the device and do hw resource re-allocations */ in bnxt_setup_mq_tc()
12748 if (netif_running(bp->dev)) in bnxt_setup_mq_tc()
12752 bp->tx_nr_rings = bp->tx_nr_rings_per_tc * tc; in bnxt_setup_mq_tc()
12755 bp->tx_nr_rings = bp->tx_nr_rings_per_tc; in bnxt_setup_mq_tc()
12758 bp->tx_nr_rings += bp->tx_nr_rings_xdp; in bnxt_setup_mq_tc()
12759 bp->cp_nr_rings = sh ? max_t(int, bp->tx_nr_rings, bp->rx_nr_rings) : in bnxt_setup_mq_tc()
12760 bp->tx_nr_rings + bp->rx_nr_rings; in bnxt_setup_mq_tc()
12762 if (netif_running(bp->dev)) in bnxt_setup_mq_tc()
12774 !tc_cls_can_offload_and_chain0(bp->dev, type_data)) in bnxt_setup_tc_block_cb()
12775 return -EOPNOTSUPP; in bnxt_setup_tc_block_cb()
12779 return bnxt_tc_setup_flower(bp, bp->pf.fw_fid, type_data); in bnxt_setup_tc_block_cb()
12781 return -EOPNOTSUPP; in bnxt_setup_tc_block_cb()
12801 mqprio->hw = TC_MQPRIO_HW_OFFLOAD_TCS; in bnxt_setup_tc()
12803 return bnxt_setup_mq_tc(dev, mqprio->num_tc); in bnxt_setup_tc()
12806 return -EOPNOTSUPP; in bnxt_setup_tc()
12814 struct flow_keys *keys1 = &f1->fkeys; in bnxt_fltr_match()
12815 struct flow_keys *keys2 = &f2->fkeys; in bnxt_fltr_match()
12817 if (keys1->basic.n_proto != keys2->basic.n_proto || in bnxt_fltr_match()
12818 keys1->basic.ip_proto != keys2->basic.ip_proto) in bnxt_fltr_match()
12821 if (keys1->basic.n_proto == htons(ETH_P_IP)) { in bnxt_fltr_match()
12822 if (keys1->addrs.v4addrs.src != keys2->addrs.v4addrs.src || in bnxt_fltr_match()
12823 keys1->addrs.v4addrs.dst != keys2->addrs.v4addrs.dst) in bnxt_fltr_match()
12826 if (memcmp(&keys1->addrs.v6addrs.src, &keys2->addrs.v6addrs.src, in bnxt_fltr_match()
12827 sizeof(keys1->addrs.v6addrs.src)) || in bnxt_fltr_match()
12828 memcmp(&keys1->addrs.v6addrs.dst, &keys2->addrs.v6addrs.dst, in bnxt_fltr_match()
12829 sizeof(keys1->addrs.v6addrs.dst))) in bnxt_fltr_match()
12833 if (keys1->ports.ports == keys2->ports.ports && in bnxt_fltr_match()
12834 keys1->control.flags == keys2->control.flags && in bnxt_fltr_match()
12835 ether_addr_equal(f1->src_mac_addr, f2->src_mac_addr) && in bnxt_fltr_match()
12836 ether_addr_equal(f1->dst_mac_addr, f2->dst_mac_addr)) in bnxt_fltr_match()
12853 if (!ether_addr_equal(dev->dev_addr, eth->h_dest)) { in bnxt_rx_flow_steer()
12854 struct bnxt_vnic_info *vnic = &bp->vnic_info[0]; in bnxt_rx_flow_steer()
12858 for (j = 0; j < vnic->uc_filter_count; j++, off += ETH_ALEN) { in bnxt_rx_flow_steer()
12859 if (ether_addr_equal(eth->h_dest, in bnxt_rx_flow_steer()
12860 vnic->uc_list + off)) { in bnxt_rx_flow_steer()
12867 return -EINVAL; in bnxt_rx_flow_steer()
12871 return -ENOMEM; in bnxt_rx_flow_steer()
12873 fkeys = &new_fltr->fkeys; in bnxt_rx_flow_steer()
12875 rc = -EPROTONOSUPPORT; in bnxt_rx_flow_steer()
12879 if ((fkeys->basic.n_proto != htons(ETH_P_IP) && in bnxt_rx_flow_steer()
12880 fkeys->basic.n_proto != htons(ETH_P_IPV6)) || in bnxt_rx_flow_steer()
12881 ((fkeys->basic.ip_proto != IPPROTO_TCP) && in bnxt_rx_flow_steer()
12882 (fkeys->basic.ip_proto != IPPROTO_UDP))) { in bnxt_rx_flow_steer()
12883 rc = -EPROTONOSUPPORT; in bnxt_rx_flow_steer()
12886 if (fkeys->basic.n_proto == htons(ETH_P_IPV6) && in bnxt_rx_flow_steer()
12887 bp->hwrm_spec_code < 0x10601) { in bnxt_rx_flow_steer()
12888 rc = -EPROTONOSUPPORT; in bnxt_rx_flow_steer()
12891 flags = fkeys->control.flags; in bnxt_rx_flow_steer()
12893 bp->hwrm_spec_code < 0x10601) || (flags & FLOW_DIS_IS_FRAGMENT)) { in bnxt_rx_flow_steer()
12894 rc = -EPROTONOSUPPORT; in bnxt_rx_flow_steer()
12898 memcpy(new_fltr->dst_mac_addr, eth->h_dest, ETH_ALEN); in bnxt_rx_flow_steer()
12899 memcpy(new_fltr->src_mac_addr, eth->h_source, ETH_ALEN); in bnxt_rx_flow_steer()
12902 head = &bp->ntp_fltr_hash_tbl[idx]; in bnxt_rx_flow_steer()
12906 rc = fltr->sw_id; in bnxt_rx_flow_steer()
12913 spin_lock_bh(&bp->ntp_fltr_lock); in bnxt_rx_flow_steer()
12914 bit_id = bitmap_find_free_region(bp->ntp_fltr_bmap, in bnxt_rx_flow_steer()
12917 spin_unlock_bh(&bp->ntp_fltr_lock); in bnxt_rx_flow_steer()
12918 rc = -ENOMEM; in bnxt_rx_flow_steer()
12922 new_fltr->sw_id = (u16)bit_id; in bnxt_rx_flow_steer()
12923 new_fltr->flow_id = flow_id; in bnxt_rx_flow_steer()
12924 new_fltr->l2_fltr_idx = l2_idx; in bnxt_rx_flow_steer()
12925 new_fltr->rxq = rxq_index; in bnxt_rx_flow_steer()
12926 hlist_add_head_rcu(&new_fltr->hash, head); in bnxt_rx_flow_steer()
12927 bp->ntp_fltr_count++; in bnxt_rx_flow_steer()
12928 spin_unlock_bh(&bp->ntp_fltr_lock); in bnxt_rx_flow_steer()
12930 set_bit(BNXT_RX_NTP_FLTR_SP_EVENT, &bp->sp_event); in bnxt_rx_flow_steer()
12933 return new_fltr->sw_id; in bnxt_rx_flow_steer()
12950 head = &bp->ntp_fltr_hash_tbl[i]; in bnxt_cfg_ntp_filters()
12954 if (test_bit(BNXT_FLTR_VALID, &fltr->state)) { in bnxt_cfg_ntp_filters()
12955 if (rps_may_expire_flow(bp->dev, fltr->rxq, in bnxt_cfg_ntp_filters()
12956 fltr->flow_id, in bnxt_cfg_ntp_filters()
12957 fltr->sw_id)) { in bnxt_cfg_ntp_filters()
12968 set_bit(BNXT_FLTR_VALID, &fltr->state); in bnxt_cfg_ntp_filters()
12972 spin_lock_bh(&bp->ntp_fltr_lock); in bnxt_cfg_ntp_filters()
12973 hlist_del_rcu(&fltr->hash); in bnxt_cfg_ntp_filters()
12974 bp->ntp_fltr_count--; in bnxt_cfg_ntp_filters()
12975 spin_unlock_bh(&bp->ntp_fltr_lock); in bnxt_cfg_ntp_filters()
12977 clear_bit(fltr->sw_id, bp->ntp_fltr_bmap); in bnxt_cfg_ntp_filters()
12982 if (test_and_clear_bit(BNXT_HWRM_PF_UNLOAD_SP_EVENT, &bp->sp_event)) in bnxt_cfg_ntp_filters()
12983 netdev_info(bp->dev, "Receive PF driver unload event!\n"); in bnxt_cfg_ntp_filters()
13028 return ndo_dflt_bridge_getlink(skb, pid, seq, dev, bp->br_mode, 0, 0, in bnxt_bridge_getlink()
13039 if (bp->hwrm_spec_code < 0x10708 || !BNXT_SINGLE_PF(bp)) in bnxt_bridge_setlink()
13040 return -EOPNOTSUPP; in bnxt_bridge_setlink()
13044 return -EINVAL; in bnxt_bridge_setlink()
13053 return -EINVAL; in bnxt_bridge_setlink()
13056 if (mode == bp->br_mode) in bnxt_bridge_setlink()
13061 bp->br_mode = mode; in bnxt_bridge_setlink()
13072 if (bp->eswitch_mode != DEVLINK_ESWITCH_MODE_SWITCHDEV) in bnxt_get_port_parent_id()
13073 return -EOPNOTSUPP; in bnxt_get_port_parent_id()
13075 /* The PF and it's VF-reps only support the switchdev framework */ in bnxt_get_port_parent_id()
13076 if (!BNXT_PF(bp) || !(bp->flags & BNXT_FLAG_DSN_VALID)) in bnxt_get_port_parent_id()
13077 return -EOPNOTSUPP; in bnxt_get_port_parent_id()
13079 ppid->id_len = sizeof(bp->dsn); in bnxt_get_port_parent_id()
13080 memcpy(ppid->id, bp->dsn, ppid->id_len); in bnxt_get_port_parent_id()
13089 return &bp->dl_port; in bnxt_get_devlink_port()
13135 devlink_port_type_clear(&bp->dl_port); in bnxt_remove_one()
13140 clear_bit(BNXT_STATE_IN_FW_RESET, &bp->state); in bnxt_remove_one()
13142 cancel_work_sync(&bp->sp_task); in bnxt_remove_one()
13143 cancel_delayed_work_sync(&bp->fw_reset_task); in bnxt_remove_one()
13144 bp->sp_event = 0; in bnxt_remove_one()
13155 kfree(bp->edev); in bnxt_remove_one()
13156 bp->edev = NULL; in bnxt_remove_one()
13157 kfree(bp->ptp_cfg); in bnxt_remove_one()
13158 bp->ptp_cfg = NULL; in bnxt_remove_one()
13159 kfree(bp->fw_health); in bnxt_remove_one()
13160 bp->fw_health = NULL; in bnxt_remove_one()
13163 kfree(bp->ctx); in bnxt_remove_one()
13164 bp->ctx = NULL; in bnxt_remove_one()
13165 kfree(bp->rss_indir_tbl); in bnxt_remove_one()
13166 bp->rss_indir_tbl = NULL; in bnxt_remove_one()
13174 struct bnxt_link_info *link_info = &bp->link_info; in bnxt_probe_phy()
13176 bp->phy_flags = 0; in bnxt_probe_phy()
13179 netdev_err(bp->dev, "Probe phy can't get phy capabilities (rc: %x)\n", in bnxt_probe_phy()
13183 if (bp->phy_flags & BNXT_PHY_FL_NO_FCS) in bnxt_probe_phy()
13184 bp->dev->priv_flags |= IFF_SUPP_NOFCS; in bnxt_probe_phy()
13186 bp->dev->priv_flags &= ~IFF_SUPP_NOFCS; in bnxt_probe_phy()
13190 mutex_lock(&bp->link_lock); in bnxt_probe_phy()
13193 mutex_unlock(&bp->link_lock); in bnxt_probe_phy()
13194 netdev_err(bp->dev, "Probe phy can't update link (rc: %x)\n", in bnxt_probe_phy()
13202 if (link_info->auto_link_speeds && !link_info->support_auto_speeds) in bnxt_probe_phy()
13203 link_info->support_auto_speeds = link_info->support_speeds; in bnxt_probe_phy()
13206 mutex_unlock(&bp->link_lock); in bnxt_probe_phy()
13214 if (!pdev->msix_cap) in bnxt_get_max_irq()
13217 pci_read_config_word(pdev, pdev->msix_cap + PCI_MSIX_FLAGS, &ctrl); in bnxt_get_max_irq()
13224 struct bnxt_hw_resc *hw_resc = &bp->hw_resc; in _bnxt_get_max_rings()
13227 *max_tx = hw_resc->max_tx_rings; in _bnxt_get_max_rings()
13228 *max_rx = hw_resc->max_rx_rings; in _bnxt_get_max_rings()
13230 max_irq = min_t(int, bnxt_get_max_func_irqs(bp) - in _bnxt_get_max_rings()
13232 hw_resc->max_stat_ctxs - bnxt_get_ulp_stat_ctxs(bp)); in _bnxt_get_max_rings()
13233 if (!(bp->flags & BNXT_FLAG_CHIP_P5)) in _bnxt_get_max_rings()
13235 max_ring_grps = hw_resc->max_hw_ring_grps; in _bnxt_get_max_rings()
13237 *max_cp -= 1; in _bnxt_get_max_rings()
13238 *max_rx -= 2; in _bnxt_get_max_rings()
13240 if (bp->flags & BNXT_FLAG_AGG_RINGS) in _bnxt_get_max_rings()
13242 if (bp->flags & BNXT_FLAG_CHIP_P5) { in _bnxt_get_max_rings()
13258 return -ENOMEM; in bnxt_get_max_rings()
13269 if (rc && (bp->flags & BNXT_FLAG_AGG_RINGS)) { in bnxt_get_dflt_rings()
13271 bp->flags &= ~BNXT_FLAG_AGG_RINGS; in bnxt_get_dflt_rings()
13275 bp->flags |= BNXT_FLAG_AGG_RINGS; in bnxt_get_dflt_rings()
13278 bp->flags |= BNXT_FLAG_NO_AGG_RINGS; in bnxt_get_dflt_rings()
13279 bp->dev->hw_features &= ~(NETIF_F_LRO | NETIF_F_GRO_HW); in bnxt_get_dflt_rings()
13280 bp->dev->features &= ~(NETIF_F_LRO | NETIF_F_GRO_HW); in bnxt_get_dflt_rings()
13284 if (bp->flags & BNXT_FLAG_ROCE_CAP) { in bnxt_get_dflt_rings()
13296 max_cp -= BNXT_MIN_ROCE_CP_RINGS; in bnxt_get_dflt_rings()
13297 max_irq -= BNXT_MIN_ROCE_CP_RINGS; in bnxt_get_dflt_rings()
13298 max_stat -= BNXT_MIN_ROCE_STAT_CTXS; in bnxt_get_dflt_rings()
13313 bp->cp_nr_rings = min_t(int, bp->tx_nr_rings_per_tc, bp->rx_nr_rings); in bnxt_trim_dflt_sh_rings()
13314 bp->rx_nr_rings = bp->cp_nr_rings; in bnxt_trim_dflt_sh_rings()
13315 bp->tx_nr_rings_per_tc = bp->cp_nr_rings; in bnxt_trim_dflt_sh_rings()
13316 bp->tx_nr_rings = bp->tx_nr_rings_per_tc; in bnxt_trim_dflt_sh_rings()
13327 bp->flags |= BNXT_FLAG_SHARED_RINGS; in bnxt_set_dflt_rings()
13329 /* Reduce default rings on multi-port cards so that total default in bnxt_set_dflt_rings()
13332 if (bp->port_count > 1) { in bnxt_set_dflt_rings()
13334 max_t(int, num_online_cpus() / bp->port_count, 1); in bnxt_set_dflt_rings()
13341 bp->rx_nr_rings = min_t(int, dflt_rings, max_rx_rings); in bnxt_set_dflt_rings()
13342 bp->tx_nr_rings_per_tc = min_t(int, dflt_rings, max_tx_rings); in bnxt_set_dflt_rings()
13346 bp->cp_nr_rings = bp->tx_nr_rings_per_tc + bp->rx_nr_rings; in bnxt_set_dflt_rings()
13347 bp->tx_nr_rings = bp->tx_nr_rings_per_tc; in bnxt_set_dflt_rings()
13350 if (rc && rc != -ENODEV) in bnxt_set_dflt_rings()
13351 netdev_warn(bp->dev, "Unable to reserve tx rings\n"); in bnxt_set_dflt_rings()
13352 bp->tx_nr_rings_per_tc = bp->tx_nr_rings; in bnxt_set_dflt_rings()
13356 /* Rings may have been trimmed, re-reserve the trimmed rings. */ in bnxt_set_dflt_rings()
13359 if (rc && rc != -ENODEV) in bnxt_set_dflt_rings()
13360 netdev_warn(bp->dev, "2nd rings reservation failed.\n"); in bnxt_set_dflt_rings()
13361 bp->tx_nr_rings_per_tc = bp->tx_nr_rings; in bnxt_set_dflt_rings()
13364 bp->rx_nr_rings++; in bnxt_set_dflt_rings()
13365 bp->cp_nr_rings++; in bnxt_set_dflt_rings()
13368 bp->tx_nr_rings = 0; in bnxt_set_dflt_rings()
13369 bp->rx_nr_rings = 0; in bnxt_set_dflt_rings()
13378 if (bp->tx_nr_rings) in bnxt_init_dflt_ring_mode()
13385 if (BNXT_VF(bp) && rc == -ENODEV) in bnxt_init_dflt_ring_mode()
13386 netdev_err(bp->dev, "Cannot configure VF rings while PF is unavailable.\n"); in bnxt_init_dflt_ring_mode()
13388 netdev_err(bp->dev, "Not enough rings available.\n"); in bnxt_init_dflt_ring_mode()
13395 bp->tx_nr_rings_per_tc = bp->tx_nr_rings; in bnxt_init_dflt_ring_mode()
13411 if (netif_running(bp->dev)) in bnxt_restore_pf_fw_resources()
13419 if (netif_running(bp->dev)) { in bnxt_restore_pf_fw_resources()
13421 dev_close(bp->dev); in bnxt_restore_pf_fw_resources()
13434 eth_hw_addr_set(bp->dev, bp->pf.mac_addr); in bnxt_init_mac_addr()
13437 struct bnxt_vf_info *vf = &bp->vf; in bnxt_init_mac_addr()
13440 if (is_valid_ether_addr(vf->mac_addr)) { in bnxt_init_mac_addr()
13442 eth_hw_addr_set(bp->dev, vf->mac_addr); in bnxt_init_mac_addr()
13448 eth_hw_addr_random(bp->dev); in bnxt_init_mac_addr()
13450 rc = bnxt_approve_mac(bp, bp->dev->dev_addr, strict_approval); in bnxt_init_mac_addr()
13458 struct pci_dev *pdev = bp->pdev; in bnxt_vpd_read_info()
13474 size = min_t(int, kw_len, BNXT_VPD_FLD_LEN - 1); in bnxt_vpd_read_info()
13475 memcpy(bp->board_partno, &vpd_data[pos], size); in bnxt_vpd_read_info()
13484 size = min_t(int, kw_len, BNXT_VPD_FLD_LEN - 1); in bnxt_vpd_read_info()
13485 memcpy(bp->board_serialno, &vpd_data[pos], size); in bnxt_vpd_read_info()
13492 struct pci_dev *pdev = bp->pdev; in bnxt_pcie_dsn_get()
13497 netdev_info(bp->dev, "Unable to read adapter's DSN\n"); in bnxt_pcie_dsn_get()
13498 return -EOPNOTSUPP; in bnxt_pcie_dsn_get()
13503 bp->flags |= BNXT_FLAG_DSN_VALID; in bnxt_pcie_dsn_get()
13509 if (!bp->db_size) in bnxt_map_db_bar()
13510 return -ENODEV; in bnxt_map_db_bar()
13511 bp->bar1 = pci_iomap(bp->pdev, 2, bp->db_size); in bnxt_map_db_bar()
13512 if (!bp->bar1) in bnxt_map_db_bar()
13513 return -ENOMEM; in bnxt_map_db_bar()
13519 netdev_info(bp->dev, "%s found at mem %lx, node addr %pM\n", in bnxt_print_device_info()
13520 board_info[bp->board_idx].name, in bnxt_print_device_info()
13521 (long)pci_resource_start(bp->pdev, 0), bp->dev->dev_addr); in bnxt_print_device_info()
13523 pcie_print_link_status(bp->pdev); in bnxt_print_device_info()
13533 return -ENODEV; in bnxt_init_one()
13546 return -ENOMEM; in bnxt_init_one()
13549 bp->board_idx = ent->driver_data; in bnxt_init_one()
13550 bp->msg_enable = BNXT_DEF_MSG_ENABLE; in bnxt_init_one()
13553 if (bnxt_vf_pciid(bp->board_idx)) in bnxt_init_one()
13554 bp->flags |= BNXT_FLAG_VF; in bnxt_init_one()
13556 if (pdev->msix_cap) in bnxt_init_one()
13557 bp->flags |= BNXT_FLAG_MSIX_CAP; in bnxt_init_one()
13563 dev->netdev_ops = &bnxt_netdev_ops; in bnxt_init_one()
13564 dev->watchdog_timeo = BNXT_TX_TIMEOUT; in bnxt_init_one()
13565 dev->ethtool_ops = &bnxt_ethtool_ops; in bnxt_init_one()
13572 mutex_init(&bp->hwrm_cmd_lock); in bnxt_init_one()
13573 mutex_init(&bp->link_lock); in bnxt_init_one()
13583 bp->flags |= BNXT_FLAG_CHIP_P5; in bnxt_init_one()
13585 bp->flags |= BNXT_FLAG_CHIP_SR2; in bnxt_init_one()
13598 dev_err(&pdev->dev, "Cannot map doorbell BAR rc = %d, aborting\n", in bnxt_init_one()
13603 dev->hw_features = NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM | NETIF_F_SG | in bnxt_init_one()
13612 dev->hw_features |= NETIF_F_LRO; in bnxt_init_one()
13614 dev->hw_enc_features = in bnxt_init_one()
13620 dev->udp_tunnel_nic_info = &bnxt_udp_tunnels; in bnxt_init_one()
13622 dev->gso_partial_features = NETIF_F_GSO_UDP_TUNNEL_CSUM | in bnxt_init_one()
13624 dev->vlan_features = dev->hw_features | NETIF_F_HIGHDMA; in bnxt_init_one()
13625 if (bp->fw_cap & BNXT_FW_CAP_VLAN_RX_STRIP) in bnxt_init_one()
13626 dev->hw_features |= BNXT_HW_FEATURE_VLAN_ALL_RX; in bnxt_init_one()
13627 if (bp->fw_cap & BNXT_FW_CAP_VLAN_TX_INSERT) in bnxt_init_one()
13628 dev->hw_features |= BNXT_HW_FEATURE_VLAN_ALL_TX; in bnxt_init_one()
13630 dev->hw_features |= NETIF_F_GRO_HW; in bnxt_init_one()
13631 dev->features |= dev->hw_features | NETIF_F_HIGHDMA; in bnxt_init_one()
13632 if (dev->features & NETIF_F_GRO_HW) in bnxt_init_one()
13633 dev->features &= ~NETIF_F_LRO; in bnxt_init_one()
13634 dev->priv_flags |= IFF_UNICAST_FLT; in bnxt_init_one()
13637 init_waitqueue_head(&bp->sriov_cfg_wait); in bnxt_init_one()
13640 bp->gro_func = bnxt_gro_func_5730x; in bnxt_init_one()
13642 bp->gro_func = bnxt_gro_func_5731x; in bnxt_init_one()
13644 bp->gro_func = bnxt_gro_func_5750x; in bnxt_init_one()
13647 bp->flags |= BNXT_FLAG_DOUBLE_DB; in bnxt_init_one()
13651 dev_err(&pdev->dev, "Unable to initialize mac address.\n"); in bnxt_init_one()
13652 rc = -EADDRNOTAVAIL; in bnxt_init_one()
13658 rc = bnxt_pcie_dsn_get(bp, bp->dsn); in bnxt_init_one()
13661 /* MTU range: 60 - FW defined max */ in bnxt_init_one()
13662 dev->min_mtu = ETH_ZLEN; in bnxt_init_one()
13663 dev->max_mtu = bp->max_mtu; in bnxt_init_one()
13674 if (BNXT_VF(bp) && rc == -ENODEV) { in bnxt_init_one()
13675 netdev_err(bp->dev, "Cannot configure VF rings while PF is unavailable.\n"); in bnxt_init_one()
13677 netdev_err(bp->dev, "Not enough rings available.\n"); in bnxt_init_one()
13678 rc = -ENOMEM; in bnxt_init_one()
13687 if (dev->hw_features & BNXT_HW_FEATURE_VLAN_ALL_RX) in bnxt_init_one()
13688 bp->flags |= BNXT_FLAG_STRIP_VLAN; in bnxt_init_one()
13695 * limited MSIX, so we re-initialize the TX rings per TC. in bnxt_init_one()
13697 bp->tx_nr_rings_per_tc = bp->tx_nr_rings; in bnxt_init_one()
13704 dev_err(&pdev->dev, "Unable to create workqueue.\n"); in bnxt_init_one()
13705 rc = -ENOMEM; in bnxt_init_one()
13725 devlink_port_type_eth_set(&bp->dl_port, bp->dev); in bnxt_init_one()
13744 kfree(bp->ptp_cfg); in bnxt_init_one()
13745 bp->ptp_cfg = NULL; in bnxt_init_one()
13746 kfree(bp->fw_health); in bnxt_init_one()
13747 bp->fw_health = NULL; in bnxt_init_one()
13750 kfree(bp->ctx); in bnxt_init_one()
13751 bp->ctx = NULL; in bnxt_init_one()
13752 kfree(bp->rss_indir_tbl); in bnxt_init_one()
13753 bp->rss_indir_tbl = NULL; in bnxt_init_one()
13781 pci_wake_from_d3(pdev, bp->wol); in bnxt_shutdown()
13803 pci_disable_device(bp->pdev); in bnxt_suspend()
13805 kfree(bp->ctx); in bnxt_suspend()
13806 bp->ctx = NULL; in bnxt_suspend()
13818 rc = pci_enable_device(bp->pdev); in bnxt_resume()
13820 netdev_err(dev, "Cannot re-enable PCI device during resume, err = %d\n", in bnxt_resume()
13824 pci_set_master(bp->pdev); in bnxt_resume()
13826 rc = -ENODEV; in bnxt_resume()
13831 rc = -EBUSY; in bnxt_resume()
13840 rc = -ENODEV; in bnxt_resume()
13869 * bnxt_io_error_detected - called when PCI error is detected
13895 set_bit(BNXT_STATE_PCI_CHANNEL_IO_FROZEN, &bp->state); in bnxt_io_error_detected()
13903 kfree(bp->ctx); in bnxt_io_error_detected()
13904 bp->ctx = NULL; in bnxt_io_error_detected()
13912 * bnxt_io_slot_reset - called after the pci bus has been reset.
13915 * Restart the card from scratch, as if from a cold-boot.
13929 netdev_info(bp->dev, "PCI Slot Reset\n"); in bnxt_io_slot_reset()
13934 dev_err(&pdev->dev, in bnxt_io_slot_reset()
13935 "Cannot re-enable PCI device after reset.\n"); in bnxt_io_slot_reset()
13942 * As pci_restore_state() does not re-write the BARs if the in bnxt_io_slot_reset()
13947 &bp->state)) { in bnxt_io_slot_reset()
13950 pci_write_config_dword(bp->pdev, off, 0); in bnxt_io_slot_reset()
13958 /* In some PCIe AER scenarios, firmware may take up to in bnxt_io_slot_reset()
13969 dev_err(&pdev->dev, "Firmware not ready\n"); in bnxt_io_slot_reset()
13991 * bnxt_io_resume - called when traffic can start flowing again.
14003 netdev_info(bp->dev, "PCI Slot Resume\n"); in bnxt_io_resume()