Lines Matching +full:xps +full:- +full:timer +full:- +full:1

1 /* Broadcom NetXtreme-C/E network driver.
3 * Copyright (c) 2014-2016 Broadcom Corporation
4 * Copyright (c) 2016-2019 Broadcom Limited
15 #include <linux/timer.h>
25 #include <linux/dma-mapping.h>
60 #include <linux/pci-tph.h>
95 [BCM57301] = { "Broadcom BCM57301 NetXtreme-C 10Gb Ethernet" },
96 [BCM57302] = { "Broadcom BCM57302 NetXtreme-C 10Gb/25Gb Ethernet" },
97 [BCM57304] = { "Broadcom BCM57304 NetXtreme-C 10Gb/25Gb/40Gb/50Gb Ethernet" },
98 [BCM57417_NPAR] = { "Broadcom BCM57417 NetXtreme-E Ethernet Partition" },
99 [BCM58700] = { "Broadcom BCM58700 Nitro 1Gb/2.5Gb/10Gb Ethernet" },
100 [BCM57311] = { "Broadcom BCM57311 NetXtreme-C 10Gb Ethernet" },
101 [BCM57312] = { "Broadcom BCM57312 NetXtreme-C 10Gb/25Gb Ethernet" },
102 [BCM57402] = { "Broadcom BCM57402 NetXtreme-E 10Gb Ethernet" },
103 [BCM57404] = { "Broadcom BCM57404 NetXtreme-E 10Gb/25Gb Ethernet" },
104 [BCM57406] = { "Broadcom BCM57406 NetXtreme-E 10GBase-T Ethernet" },
105 [BCM57402_NPAR] = { "Broadcom BCM57402 NetXtreme-E Ethernet Partition" },
106 [BCM57407] = { "Broadcom BCM57407 NetXtreme-E 10GBase-T Ethernet" },
107 [BCM57412] = { "Broadcom BCM57412 NetXtreme-E 10Gb Ethernet" },
108 [BCM57414] = { "Broadcom BCM57414 NetXtreme-E 10Gb/25Gb Ethernet" },
109 [BCM57416] = { "Broadcom BCM57416 NetXtreme-E 10GBase-T Ethernet" },
110 [BCM57417] = { "Broadcom BCM57417 NetXtreme-E 10GBase-T Ethernet" },
111 [BCM57412_NPAR] = { "Broadcom BCM57412 NetXtreme-E Ethernet Partition" },
112 [BCM57314] = { "Broadcom BCM57314 NetXtreme-C 10Gb/25Gb/40Gb/50Gb Ethernet" },
113 [BCM57417_SFP] = { "Broadcom BCM57417 NetXtreme-E 10Gb/25Gb Ethernet" },
114 [BCM57416_SFP] = { "Broadcom BCM57416 NetXtreme-E 10Gb Ethernet" },
115 [BCM57404_NPAR] = { "Broadcom BCM57404 NetXtreme-E Ethernet Partition" },
116 [BCM57406_NPAR] = { "Broadcom BCM57406 NetXtreme-E Ethernet Partition" },
117 [BCM57407_SFP] = { "Broadcom BCM57407 NetXtreme-E 25Gb Ethernet" },
118 [BCM57407_NPAR] = { "Broadcom BCM57407 NetXtreme-E Ethernet Partition" },
119 [BCM57414_NPAR] = { "Broadcom BCM57414 NetXtreme-E Ethernet Partition" },
120 [BCM57416_NPAR] = { "Broadcom BCM57416 NetXtreme-E Ethernet Partition" },
121 [BCM57452] = { "Broadcom BCM57452 NetXtreme-E 10Gb/25Gb/40Gb/50Gb Ethernet" },
122 [BCM57454] = { "Broadcom BCM57454 NetXtreme-E 10Gb/25Gb/40Gb/50Gb/100Gb Ethernet" },
123 [BCM5745x_NPAR] = { "Broadcom BCM5745x NetXtreme-E Ethernet Partition" },
124 [BCM57508] = { "Broadcom BCM57508 NetXtreme-E 10Gb/25Gb/50Gb/100Gb/200Gb Ethernet" },
125 [BCM57504] = { "Broadcom BCM57504 NetXtreme-E 10Gb/25Gb/50Gb/100Gb/200Gb Ethernet" },
126 [BCM57502] = { "Broadcom BCM57502 NetXtreme-E 10Gb/25Gb/50Gb Ethernet" },
127 [BCM57608] = { "Broadcom BCM57608 NetXtreme-E 10Gb/25Gb/50Gb/100Gb/200Gb/400Gb Ethernet" },
128 [BCM57604] = { "Broadcom BCM57604 NetXtreme-E 10Gb/25Gb/50Gb/100Gb/200Gb Ethernet" },
129 [BCM57602] = { "Broadcom BCM57602 NetXtreme-E 10Gb/25Gb/50Gb/100Gb Ethernet" },
130 [BCM57601] = { "Broadcom BCM57601 NetXtreme-E 10Gb/25Gb/50Gb/100Gb/200Gb/400Gb Ethernet" },
131 [BCM57508_NPAR] = { "Broadcom BCM57508 NetXtreme-E Ethernet Partition" },
132 [BCM57504_NPAR] = { "Broadcom BCM57504 NetXtreme-E Ethernet Partition" },
133 [BCM57502_NPAR] = { "Broadcom BCM57502 NetXtreme-E Ethernet Partition" },
134 [BCM58802] = { "Broadcom BCM58802 NetXtreme-S 10Gb/25Gb/40Gb/50Gb Ethernet" },
135 [BCM58804] = { "Broadcom BCM58804 NetXtreme-S 10Gb/25Gb/40Gb/50Gb/100Gb Ethernet" },
136 [BCM58808] = { "Broadcom BCM58808 NetXtreme-S 10Gb/25Gb/40Gb/50Gb/100Gb Ethernet" },
137 [NETXTREME_E_VF] = { "Broadcom NetXtreme-E Ethernet Virtual Function" },
138 [NETXTREME_C_VF] = { "Broadcom NetXtreme-C Ethernet Virtual Function" },
139 [NETXTREME_S_VF] = { "Broadcom NetXtreme-S Ethernet Virtual Function" },
140 [NETXTREME_C_VF_HV] = { "Broadcom NetXtreme-C Virtual Function for Hyper-V" },
141 [NETXTREME_E_VF_HV] = { "Broadcom NetXtreme-E Virtual Function for Hyper-V" },
142 [NETXTREME_E_P5_VF] = { "Broadcom BCM5750X NetXtreme-E Ethernet Virtual Function" },
143 [NETXTREME_E_P5_VF_HV] = { "Broadcom BCM5750X NetXtreme-E Virtual Function for Hyper-V" },
325 writel(DB_CP_FLAGS | DB_RING_IDX(db, idx), (db)->doorbell)
328 bnxt_writeq(bp, (db)->db_key64 | DBR_TYPE_NQ | DB_RING_IDX(db, idx),\
329 (db)->doorbell)
332 bnxt_writeq(bp, (db)->db_key64 | DBR_TYPE_NQ_MASK | \
333 DB_RING_IDX(db, idx), (db)->doorbell)
336 writel(DB_CP_REARM_FLAGS | DB_RING_IDX(db, idx), (db)->doorbell)
339 bnxt_writeq(bp, (db)->db_key64 | DBR_TYPE_NQ_ARM | \
340 DB_RING_IDX(db, idx), (db)->doorbell)
344 if (bp->flags & BNXT_FLAG_CHIP_P7) in bnxt_db_nq()
346 else if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) in bnxt_db_nq()
354 if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) in bnxt_db_nq_arm()
362 if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) in bnxt_db_cq()
363 bnxt_writeq(bp, db->db_key64 | DBR_TYPE_CQ_ARMALL | in bnxt_db_cq()
364 DB_RING_IDX(db, idx), db->doorbell); in bnxt_db_cq()
371 if (!(test_bit(BNXT_STATE_IN_FW_RESET, &bp->state))) in bnxt_queue_fw_reset_work()
375 queue_delayed_work(bnxt_pf_wq, &bp->fw_reset_task, delay); in bnxt_queue_fw_reset_work()
377 schedule_delayed_work(&bp->fw_reset_task, delay); in bnxt_queue_fw_reset_work()
383 queue_work(bnxt_pf_wq, &bp->sp_task); in __bnxt_queue_sp_work()
385 schedule_work(&bp->sp_task); in __bnxt_queue_sp_work()
390 set_bit(event, &bp->sp_event); in bnxt_queue_sp_work()
396 if (!rxr->bnapi->in_reset) { in bnxt_sched_reset_rxr()
397 rxr->bnapi->in_reset = true; in bnxt_sched_reset_rxr()
398 if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) in bnxt_sched_reset_rxr()
399 set_bit(BNXT_RESET_TASK_SP_EVENT, &bp->sp_event); in bnxt_sched_reset_rxr()
401 set_bit(BNXT_RST_RING_SP_EVENT, &bp->sp_event); in bnxt_sched_reset_rxr()
404 rxr->rx_next_cons = 0xffff; in bnxt_sched_reset_rxr()
410 struct bnxt_napi *bnapi = txr->bnapi; in bnxt_sched_reset_txr()
412 if (bnapi->tx_fault) in bnxt_sched_reset_txr()
415 netdev_err(bp->dev, "Invalid Tx completion (ring:%d tx_hw_cons:%u cons:%u prod:%u curr:%u)", in bnxt_sched_reset_txr()
416 txr->txq_index, txr->tx_hw_cons, in bnxt_sched_reset_txr()
417 txr->tx_cons, txr->tx_prod, curr); in bnxt_sched_reset_txr()
418 WARN_ON_ONCE(1); in bnxt_sched_reset_txr()
419 bnapi->tx_fault = 1; in bnxt_sched_reset_txr()
449 if (!md_dst || md_dst->type != METADATA_HW_PORT_MUX) in bnxt_xmit_get_cfa_action()
452 return md_dst->u.port_info.port_id; in bnxt_xmit_get_cfa_action()
460 bnxt_db_write(bp, &txr->tx_db, prod); in bnxt_txr_db_kick()
461 txr->kick_pending = 0; in bnxt_txr_db_kick()
474 struct bnxt_ptp_cfg *ptp = bp->ptp_cfg; in bnxt_start_xmit()
475 struct pci_dev *pdev = bp->pdev; in bnxt_start_xmit()
483 if (unlikely(i >= bp->tx_nr_rings)) { in bnxt_start_xmit()
490 txr = &bp->tx_ring[bp->tx_ring_map[i]]; in bnxt_start_xmit()
491 prod = txr->tx_prod; in bnxt_start_xmit()
494 if (skb_shinfo(skb)->nr_frags > TX_MAX_FRAGS) { in bnxt_start_xmit()
496 skb_shinfo(skb)->nr_frags, TX_MAX_FRAGS); in bnxt_start_xmit()
505 if (unlikely(free_size < skb_shinfo(skb)->nr_frags + 2)) { in bnxt_start_xmit()
507 if (net_ratelimit() && txr->kick_pending) in bnxt_start_xmit()
511 bp->tx_wake_thresh)) in bnxt_start_xmit()
518 length = skb->len; in bnxt_start_xmit()
520 last_frag = skb_shinfo(skb)->nr_frags; in bnxt_start_xmit()
522 txbd = &txr->tx_desc_ring[TX_RING(bp, prod)][TX_IDX(prod)]; in bnxt_start_xmit()
524 tx_buf = &txr->tx_buf_ring[RING_TX(bp, prod)]; in bnxt_start_xmit()
525 tx_buf->skb = skb; in bnxt_start_xmit()
526 tx_buf->nr_frags = last_frag; in bnxt_start_xmit()
536 if (skb->vlan_proto == htons(ETH_P_8021Q)) in bnxt_start_xmit()
537 vlan_tag_flags |= 1 << TX_BD_CFA_META_TPID_SHIFT; in bnxt_start_xmit()
540 if (unlikely(skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP) && ptp && in bnxt_start_xmit()
541 ptp->tx_tstamp_en) { in bnxt_start_xmit()
542 if (bp->fw_cap & BNXT_FW_CAP_TX_TS_CMP) { in bnxt_start_xmit()
544 tx_buf->is_ts_pkt = 1; in bnxt_start_xmit()
545 skb_shinfo(skb)->tx_flags |= SKBTX_IN_PROGRESS; in bnxt_start_xmit()
554 tx_buf->is_ts_pkt = 1; in bnxt_start_xmit()
555 skb_shinfo(skb)->tx_flags |= SKBTX_IN_PROGRESS; in bnxt_start_xmit()
557 ptp->txts_req[txts_prod].tx_seqid = seq_id; in bnxt_start_xmit()
558 ptp->txts_req[txts_prod].tx_hdr_off = hdr_off; in bnxt_start_xmit()
559 tx_buf->txts_prod = txts_prod; in bnxt_start_xmit()
563 if (unlikely(skb->no_fcs)) in bnxt_start_xmit()
566 if (free_size == bp->tx_ring_size && length <= bp->tx_push_thresh && in bnxt_start_xmit()
568 struct tx_push_buffer *tx_push_buf = txr->tx_push; in bnxt_start_xmit()
569 struct tx_push_bd *tx_push = &tx_push_buf->push_bd; in bnxt_start_xmit()
570 struct tx_bd_ext *tx_push1 = &tx_push->txbd2; in bnxt_start_xmit()
571 void __iomem *db = txr->tx_db.doorbell; in bnxt_start_xmit()
572 void *pdata = tx_push_buf->data; in bnxt_start_xmit()
577 tx_push->tx_bd_len_flags_type = in bnxt_start_xmit()
585 if (skb->ip_summed == CHECKSUM_PARTIAL) in bnxt_start_xmit()
586 tx_push1->tx_bd_hsize_lflags = in bnxt_start_xmit()
589 tx_push1->tx_bd_hsize_lflags = 0; in bnxt_start_xmit()
591 tx_push1->tx_bd_cfa_meta = cpu_to_le32(vlan_tag_flags); in bnxt_start_xmit()
592 tx_push1->tx_bd_cfa_action = in bnxt_start_xmit()
596 end = PTR_ALIGN(end, 8) - 1; in bnxt_start_xmit()
604 frag = &skb_shinfo(skb)->frags[j]; in bnxt_start_xmit()
613 txbd->tx_bd_len_flags_type = tx_push->tx_bd_len_flags_type; in bnxt_start_xmit()
614 txbd->tx_bd_haddr = txr->data_mapping; in bnxt_start_xmit()
615 txbd->tx_bd_opaque = SET_TX_OPAQUE(bp, txr, prod, 2); in bnxt_start_xmit()
617 tx_push->tx_bd_opaque = txbd->tx_bd_opaque; in bnxt_start_xmit()
618 txbd = &txr->tx_desc_ring[TX_RING(bp, prod)][TX_IDX(prod)]; in bnxt_start_xmit()
621 tx_push->doorbell = in bnxt_start_xmit()
623 DB_RING_IDX(&txr->tx_db, prod)); in bnxt_start_xmit()
624 WRITE_ONCE(txr->tx_prod, prod); in bnxt_start_xmit()
626 tx_buf->is_push = 1; in bnxt_start_xmit()
627 netdev_tx_sent_queue(txq, skb->len); in bnxt_start_xmit()
633 __iowrite32_copy(db + 4, tx_push_buf + 1, in bnxt_start_xmit()
634 (push_len - 16) << 1); in bnxt_start_xmit()
644 pad = BNXT_MIN_PKT_SIZE - length; in bnxt_start_xmit()
651 mapping = dma_map_single(&pdev->dev, skb->data, len, DMA_TO_DEVICE); in bnxt_start_xmit()
653 if (unlikely(dma_mapping_error(&pdev->dev, mapping))) in bnxt_start_xmit()
660 txbd->tx_bd_haddr = cpu_to_le64(mapping); in bnxt_start_xmit()
661 txbd->tx_bd_opaque = SET_TX_OPAQUE(bp, txr, prod, 2 + last_frag); in bnxt_start_xmit()
665 &txr->tx_desc_ring[TX_RING(bp, prod)][TX_IDX(prod)]; in bnxt_start_xmit()
667 txbd1->tx_bd_hsize_lflags = lflags; in bnxt_start_xmit()
669 bool udp_gso = !!(skb_shinfo(skb)->gso_type & SKB_GSO_UDP_L4); in bnxt_start_xmit()
672 if (skb->encapsulation) { in bnxt_start_xmit()
685 txbd1->tx_bd_hsize_lflags |= cpu_to_le32(TX_BD_FLAGS_LSO | in bnxt_start_xmit()
687 (hdr_len << (TX_BD_HSIZE_SHIFT - 1))); in bnxt_start_xmit()
688 length = skb_shinfo(skb)->gso_size; in bnxt_start_xmit()
689 txbd1->tx_bd_mss = cpu_to_le32(length); in bnxt_start_xmit()
691 } else if (skb->ip_summed == CHECKSUM_PARTIAL) { in bnxt_start_xmit()
692 txbd1->tx_bd_hsize_lflags |= in bnxt_start_xmit()
694 txbd1->tx_bd_mss = 0; in bnxt_start_xmit()
699 dev_warn_ratelimited(&pdev->dev, "Dropped oversize %d bytes TX packet.\n", in bnxt_start_xmit()
700 skb->len); in bnxt_start_xmit()
705 txbd->tx_bd_len_flags_type = cpu_to_le32(flags); in bnxt_start_xmit()
707 txbd1->tx_bd_cfa_meta = cpu_to_le32(vlan_tag_flags); in bnxt_start_xmit()
708 txbd1->tx_bd_cfa_action = in bnxt_start_xmit()
712 frag = &skb_shinfo(skb)->frags[i]; in bnxt_start_xmit()
714 txbd = &txr->tx_desc_ring[TX_RING(bp, prod)][TX_IDX(prod)]; in bnxt_start_xmit()
717 mapping = skb_frag_dma_map(&pdev->dev, frag, 0, len, in bnxt_start_xmit()
720 if (unlikely(dma_mapping_error(&pdev->dev, mapping))) in bnxt_start_xmit()
723 tx_buf = &txr->tx_buf_ring[RING_TX(bp, prod)]; in bnxt_start_xmit()
727 txbd->tx_bd_haddr = cpu_to_le64(mapping); in bnxt_start_xmit()
730 txbd->tx_bd_len_flags_type = cpu_to_le32(flags); in bnxt_start_xmit()
734 txbd->tx_bd_len_flags_type = in bnxt_start_xmit()
738 netdev_tx_sent_queue(txq, skb->len); in bnxt_start_xmit()
743 WRITE_ONCE(txr->tx_prod, prod); in bnxt_start_xmit()
748 if (free_size >= bp->tx_wake_thresh) in bnxt_start_xmit()
749 txbd0->tx_bd_len_flags_type |= in bnxt_start_xmit()
751 txr->kick_pending = 1; in bnxt_start_xmit()
756 if (unlikely(bnxt_tx_avail(bp, txr) <= MAX_SKB_FRAGS + 1)) { in bnxt_start_xmit()
757 if (netdev_xmit_more() && !tx_buf->is_push) { in bnxt_start_xmit()
758 txbd0->tx_bd_len_flags_type &= in bnxt_start_xmit()
764 bp->tx_wake_thresh); in bnxt_start_xmit()
772 prod = txr->tx_prod; in bnxt_start_xmit()
773 tx_buf = &txr->tx_buf_ring[RING_TX(bp, prod)]; in bnxt_start_xmit()
774 dma_unmap_single(&pdev->dev, dma_unmap_addr(tx_buf, mapping), in bnxt_start_xmit()
781 tx_buf = &txr->tx_buf_ring[RING_TX(bp, prod)]; in bnxt_start_xmit()
782 frag = &skb_shinfo(skb)->frags[i]; in bnxt_start_xmit()
783 netmem_dma_unmap_page_attrs(&pdev->dev, in bnxt_start_xmit()
793 txr->tx_buf_ring[RING_TX(bp, txr->tx_prod)].is_ts_pkt = 0; in bnxt_start_xmit()
794 atomic64_inc(&bp->ptp_cfg->stats.ts_err); in bnxt_start_xmit()
795 if (!(bp->fw_cap & BNXT_FW_CAP_TX_TS_CMP)) in bnxt_start_xmit()
797 ptp->txts_req[txts_prod].tx_skb = ERR_PTR(-EIO); in bnxt_start_xmit()
799 if (txr->kick_pending) in bnxt_start_xmit()
800 bnxt_txr_db_kick(bp, txr, txr->tx_prod); in bnxt_start_xmit()
801 txr->tx_buf_ring[RING_TX(bp, txr->tx_prod)].skb = NULL; in bnxt_start_xmit()
810 struct netdev_queue *txq = netdev_get_tx_queue(bp->dev, txr->txq_index); in __bnxt_tx_int()
811 struct pci_dev *pdev = bp->pdev; in __bnxt_tx_int()
812 u16 hw_cons = txr->tx_hw_cons; in __bnxt_tx_int()
814 u16 cons = txr->tx_cons; in __bnxt_tx_int()
825 tx_buf = &txr->tx_buf_ring[RING_TX(bp, cons)]; in __bnxt_tx_int()
826 skb = tx_buf->skb; in __bnxt_tx_int()
833 is_ts_pkt = tx_buf->is_ts_pkt; in __bnxt_tx_int()
834 if (is_ts_pkt && (bp->fw_cap & BNXT_FW_CAP_TX_TS_CMP)) { in __bnxt_tx_int()
841 tx_bytes += skb->len; in __bnxt_tx_int()
842 tx_buf->skb = NULL; in __bnxt_tx_int()
843 tx_buf->is_ts_pkt = 0; in __bnxt_tx_int()
845 if (tx_buf->is_push) { in __bnxt_tx_int()
846 tx_buf->is_push = 0; in __bnxt_tx_int()
850 dma_unmap_single(&pdev->dev, dma_unmap_addr(tx_buf, mapping), in __bnxt_tx_int()
852 last = tx_buf->nr_frags; in __bnxt_tx_int()
855 frag = &skb_shinfo(skb)->frags[j]; in __bnxt_tx_int()
857 tx_buf = &txr->tx_buf_ring[RING_TX(bp, cons)]; in __bnxt_tx_int()
858 netmem_dma_unmap_page_attrs(&pdev->dev, in __bnxt_tx_int()
867 bnxt_get_tx_ts_p5(bp, skb, tx_buf->txts_prod); in __bnxt_tx_int()
878 WRITE_ONCE(txr->tx_cons, cons); in __bnxt_tx_int()
881 bnxt_tx_avail(bp, txr), bp->tx_wake_thresh, in __bnxt_tx_int()
882 READ_ONCE(txr->dev_state) == BNXT_DEV_STATE_CLOSING); in __bnxt_tx_int()
894 if (txr->tx_hw_cons != RING_TX(bp, txr->tx_cons)) in bnxt_tx_int()
898 bnapi->events &= ~BNXT_TX_CMP_EVENT; in bnxt_tx_int()
903 return rxr->need_head_pool || PAGE_SIZE > BNXT_RX_PAGE_SIZE; in bnxt_separate_head_pool()
914 page = page_pool_dev_alloc_frag(rxr->page_pool, offset, in __bnxt_alloc_rx_page()
917 page = page_pool_dev_alloc_pages(rxr->page_pool); in __bnxt_alloc_rx_page()
933 netmem = page_pool_alloc_netmems(rxr->page_pool, gfp); in __bnxt_alloc_rx_netmem()
948 page = page_pool_alloc_frag(rxr->head_pool, &offset, in __bnxt_alloc_rx_frag()
949 bp->rx_buf_size, gfp); in __bnxt_alloc_rx_frag()
953 *mapping = page_pool_get_dma_addr(page) + bp->rx_dma_offset + offset; in __bnxt_alloc_rx_frag()
960 struct rx_bd *rxbd = &rxr->rx_desc_ring[RX_RING(bp, prod)][RX_IDX(prod)]; in bnxt_alloc_rx_data()
961 struct bnxt_sw_rx_bd *rx_buf = &rxr->rx_buf_ring[RING_RX(bp, prod)]; in bnxt_alloc_rx_data()
970 return -ENOMEM; in bnxt_alloc_rx_data()
972 mapping += bp->rx_dma_offset; in bnxt_alloc_rx_data()
973 rx_buf->data = page; in bnxt_alloc_rx_data()
974 rx_buf->data_ptr = page_address(page) + offset + bp->rx_offset; in bnxt_alloc_rx_data()
979 return -ENOMEM; in bnxt_alloc_rx_data()
981 rx_buf->data = data; in bnxt_alloc_rx_data()
982 rx_buf->data_ptr = data + bp->rx_offset; in bnxt_alloc_rx_data()
984 rx_buf->mapping = mapping; in bnxt_alloc_rx_data()
986 rxbd->rx_bd_haddr = cpu_to_le64(mapping); in bnxt_alloc_rx_data()
992 u16 prod = rxr->rx_prod; in bnxt_reuse_rx_data()
994 struct bnxt *bp = rxr->bnapi->bp; in bnxt_reuse_rx_data()
997 prod_rx_buf = &rxr->rx_buf_ring[RING_RX(bp, prod)]; in bnxt_reuse_rx_data()
998 cons_rx_buf = &rxr->rx_buf_ring[cons]; in bnxt_reuse_rx_data()
1000 prod_rx_buf->data = data; in bnxt_reuse_rx_data()
1001 prod_rx_buf->data_ptr = cons_rx_buf->data_ptr; in bnxt_reuse_rx_data()
1003 prod_rx_buf->mapping = cons_rx_buf->mapping; in bnxt_reuse_rx_data()
1005 prod_bd = &rxr->rx_desc_ring[RX_RING(bp, prod)][RX_IDX(prod)]; in bnxt_reuse_rx_data()
1006 cons_bd = &rxr->rx_desc_ring[RX_RING(bp, cons)][RX_IDX(cons)]; in bnxt_reuse_rx_data()
1008 prod_bd->rx_bd_haddr = cons_bd->rx_bd_haddr; in bnxt_reuse_rx_data()
1013 u16 next, max = rxr->rx_agg_bmap_size; in bnxt_find_next_agg_idx()
1015 next = find_next_zero_bit(rxr->rx_agg_bmap, max, idx); in bnxt_find_next_agg_idx()
1017 next = find_first_zero_bit(rxr->rx_agg_bmap, max); in bnxt_find_next_agg_idx()
1025 &rxr->rx_agg_desc_ring[RX_AGG_RING(bp, prod)][RX_IDX(prod)]; in bnxt_alloc_rx_netmem()
1027 u16 sw_prod = rxr->rx_sw_agg_prod; in bnxt_alloc_rx_netmem()
1034 return -ENOMEM; in bnxt_alloc_rx_netmem()
1036 if (unlikely(test_bit(sw_prod, rxr->rx_agg_bmap))) in bnxt_alloc_rx_netmem()
1039 __set_bit(sw_prod, rxr->rx_agg_bmap); in bnxt_alloc_rx_netmem()
1040 rx_agg_buf = &rxr->rx_agg_ring[sw_prod]; in bnxt_alloc_rx_netmem()
1041 rxr->rx_sw_agg_prod = RING_RX_AGG(bp, NEXT_RX_AGG(sw_prod)); in bnxt_alloc_rx_netmem()
1043 rx_agg_buf->netmem = netmem; in bnxt_alloc_rx_netmem()
1044 rx_agg_buf->offset = offset; in bnxt_alloc_rx_netmem()
1045 rx_agg_buf->mapping = mapping; in bnxt_alloc_rx_netmem()
1046 rxbd->rx_bd_haddr = cpu_to_le64(mapping); in bnxt_alloc_rx_netmem()
1047 rxbd->rx_bd_opaque = sw_prod; in bnxt_alloc_rx_netmem()
1059 &cpr->cp_desc_ring[CP_RING(cp_cons)][CP_IDX(cp_cons)]; in bnxt_get_agg()
1067 struct bnxt_tpa_info *tpa_info = &rxr->rx_tpa[agg_id]; in bnxt_get_tpa_agg_p5()
1069 return &tpa_info->agg_arr[curr]; in bnxt_get_tpa_agg_p5()
1075 struct bnxt_napi *bnapi = cpr->bnapi; in bnxt_reuse_rx_agg_bufs()
1076 struct bnxt *bp = bnapi->bp; in bnxt_reuse_rx_agg_bufs()
1077 struct bnxt_rx_ring_info *rxr = bnapi->rx_ring; in bnxt_reuse_rx_agg_bufs()
1078 u16 prod = rxr->rx_agg_prod; in bnxt_reuse_rx_agg_bufs()
1079 u16 sw_prod = rxr->rx_sw_agg_prod; in bnxt_reuse_rx_agg_bufs()
1083 if ((bp->flags & BNXT_FLAG_CHIP_P5_PLUS) && tpa) in bnxt_reuse_rx_agg_bufs()
1097 cons = agg->rx_agg_cmp_opaque; in bnxt_reuse_rx_agg_bufs()
1098 __clear_bit(cons, rxr->rx_agg_bmap); in bnxt_reuse_rx_agg_bufs()
1100 if (unlikely(test_bit(sw_prod, rxr->rx_agg_bmap))) in bnxt_reuse_rx_agg_bufs()
1103 __set_bit(sw_prod, rxr->rx_agg_bmap); in bnxt_reuse_rx_agg_bufs()
1104 prod_rx_buf = &rxr->rx_agg_ring[sw_prod]; in bnxt_reuse_rx_agg_bufs()
1105 cons_rx_buf = &rxr->rx_agg_ring[cons]; in bnxt_reuse_rx_agg_bufs()
1108 * set cons_rx_buf->netmem to 0 first. in bnxt_reuse_rx_agg_bufs()
1110 netmem = cons_rx_buf->netmem; in bnxt_reuse_rx_agg_bufs()
1111 cons_rx_buf->netmem = 0; in bnxt_reuse_rx_agg_bufs()
1112 prod_rx_buf->netmem = netmem; in bnxt_reuse_rx_agg_bufs()
1113 prod_rx_buf->offset = cons_rx_buf->offset; in bnxt_reuse_rx_agg_bufs()
1115 prod_rx_buf->mapping = cons_rx_buf->mapping; in bnxt_reuse_rx_agg_bufs()
1117 prod_bd = &rxr->rx_agg_desc_ring[RX_AGG_RING(bp, prod)][RX_IDX(prod)]; in bnxt_reuse_rx_agg_bufs()
1119 prod_bd->rx_bd_haddr = cpu_to_le64(cons_rx_buf->mapping); in bnxt_reuse_rx_agg_bufs()
1120 prod_bd->rx_bd_opaque = sw_prod; in bnxt_reuse_rx_agg_bufs()
1125 rxr->rx_agg_prod = prod; in bnxt_reuse_rx_agg_bufs()
1126 rxr->rx_sw_agg_prod = sw_prod; in bnxt_reuse_rx_agg_bufs()
1137 u16 prod = rxr->rx_prod; in bnxt_rx_multi_page_skb()
1146 dma_addr -= bp->rx_dma_offset; in bnxt_rx_multi_page_skb()
1147 dma_sync_single_for_cpu(&bp->pdev->dev, dma_addr, BNXT_RX_PAGE_SIZE, in bnxt_rx_multi_page_skb()
1148 bp->rx_dir); in bnxt_rx_multi_page_skb()
1149 skb = napi_build_skb(data_ptr - bp->rx_offset, BNXT_RX_PAGE_SIZE); in bnxt_rx_multi_page_skb()
1151 page_pool_recycle_direct(rxr->page_pool, page); in bnxt_rx_multi_page_skb()
1155 skb_reserve(skb, bp->rx_offset); in bnxt_rx_multi_page_skb()
1171 u16 prod = rxr->rx_prod; in bnxt_rx_page_skb()
1180 dma_addr -= bp->rx_dma_offset; in bnxt_rx_page_skb()
1181 dma_sync_single_for_cpu(&bp->pdev->dev, dma_addr, BNXT_RX_PAGE_SIZE, in bnxt_rx_page_skb()
1182 bp->rx_dir); in bnxt_rx_page_skb()
1185 payload = eth_get_headlen(bp->dev, data_ptr, len); in bnxt_rx_page_skb()
1187 skb = napi_alloc_skb(&rxr->bnapi->napi, payload); in bnxt_rx_page_skb()
1189 page_pool_recycle_direct(rxr->page_pool, page); in bnxt_rx_page_skb()
1194 off = (void *)data_ptr - page_address(page); in bnxt_rx_page_skb()
1196 memcpy(skb->data - NET_IP_ALIGN, data_ptr - NET_IP_ALIGN, in bnxt_rx_page_skb()
1199 frag = &skb_shinfo(skb)->frags[0]; in bnxt_rx_page_skb()
1202 skb->data_len -= payload; in bnxt_rx_page_skb()
1203 skb->tail += payload; in bnxt_rx_page_skb()
1214 u16 prod = rxr->rx_prod; in bnxt_rx_skb()
1224 skb = napi_build_skb(data, bp->rx_buf_size); in bnxt_rx_skb()
1225 dma_sync_single_for_cpu(&bp->pdev->dev, dma_addr, bp->rx_buf_use_size, in bnxt_rx_skb()
1226 bp->rx_dir); in bnxt_rx_skb()
1228 page_pool_free_va(rxr->head_pool, data, true); in bnxt_rx_skb()
1233 skb_reserve(skb, bp->rx_offset); in bnxt_rx_skb()
1244 struct bnxt_napi *bnapi = cpr->bnapi; in __bnxt_rx_agg_netmems()
1251 rxr = bnapi->rx_ring; in __bnxt_rx_agg_netmems()
1252 prod = rxr->rx_agg_prod; in __bnxt_rx_agg_netmems()
1254 if ((bp->flags & BNXT_FLAG_CHIP_P5_PLUS) && tpa) in __bnxt_rx_agg_netmems()
1272 cons = agg->rx_agg_cmp_opaque; in __bnxt_rx_agg_netmems()
1273 frag_len = (le32_to_cpu(agg->rx_agg_cmp_len_flags_type) & in __bnxt_rx_agg_netmems()
1276 cons_rx_buf = &rxr->rx_agg_ring[cons]; in __bnxt_rx_agg_netmems()
1278 skb_add_rx_frag_netmem(skb, i, cons_rx_buf->netmem, in __bnxt_rx_agg_netmems()
1279 cons_rx_buf->offset, in __bnxt_rx_agg_netmems()
1282 skb_frag_t *frag = &shinfo->frags[i]; in __bnxt_rx_agg_netmems()
1284 skb_frag_fill_netmem_desc(frag, cons_rx_buf->netmem, in __bnxt_rx_agg_netmems()
1285 cons_rx_buf->offset, in __bnxt_rx_agg_netmems()
1287 shinfo->nr_frags = i + 1; in __bnxt_rx_agg_netmems()
1289 __clear_bit(cons, rxr->rx_agg_bmap); in __bnxt_rx_agg_netmems()
1295 netmem = cons_rx_buf->netmem; in __bnxt_rx_agg_netmems()
1296 cons_rx_buf->netmem = 0; in __bnxt_rx_agg_netmems()
1303 skb->len -= frag_len; in __bnxt_rx_agg_netmems()
1304 skb->data_len -= frag_len; in __bnxt_rx_agg_netmems()
1305 skb->truesize -= BNXT_RX_PAGE_SIZE; in __bnxt_rx_agg_netmems()
1308 --shinfo->nr_frags; in __bnxt_rx_agg_netmems()
1309 cons_rx_buf->netmem = netmem; in __bnxt_rx_agg_netmems()
1314 rxr->rx_agg_prod = prod; in __bnxt_rx_agg_netmems()
1315 bnxt_reuse_rx_agg_bufs(cpr, idx, i, agg_bufs - i, tpa); in __bnxt_rx_agg_netmems()
1319 page_pool_dma_sync_netmem_for_cpu(rxr->page_pool, netmem, 0, in __bnxt_rx_agg_netmems()
1325 rxr->rx_agg_prod = prod; in __bnxt_rx_agg_netmems()
1356 shinfo->nr_frags = 0; in bnxt_rx_agg_netmems_xdp()
1362 shinfo->nr_frags = agg_bufs; in bnxt_rx_agg_netmems_xdp()
1363 shinfo->xdp_frags_size = total_frag_len; in bnxt_rx_agg_netmems_xdp()
1377 &cpr->cp_desc_ring[CP_RING(last)][CP_IDX(last)]; in bnxt_agg_bufs_valid()
1385 struct bnxt *bp = bnapi->bp; in bnxt_copy_data()
1386 struct pci_dev *pdev = bp->pdev; in bnxt_copy_data()
1389 skb = napi_alloc_skb(&bnapi->napi, len); in bnxt_copy_data()
1393 dma_sync_single_for_cpu(&pdev->dev, mapping, bp->rx_copybreak, in bnxt_copy_data()
1394 bp->rx_dir); in bnxt_copy_data()
1396 memcpy(skb->data - NET_IP_ALIGN, data - NET_IP_ALIGN, in bnxt_copy_data()
1399 dma_sync_single_for_device(&pdev->dev, mapping, bp->rx_copybreak, in bnxt_copy_data()
1400 bp->rx_dir); in bnxt_copy_data()
1420 u8 *data = xdp->data; in bnxt_copy_xdp()
1423 len = xdp->data_end - xdp->data_meta; in bnxt_copy_xdp()
1424 metasize = xdp->data - xdp->data_meta; in bnxt_copy_xdp()
1425 data = xdp->data_meta; in bnxt_copy_xdp()
1449 agg_bufs = (le32_to_cpu(rxcmp->rx_cmp_misc_v1) & in bnxt_discard_rx()
1455 if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) in bnxt_discard_rx()
1463 return -EBUSY; in bnxt_discard_rx()
1471 struct bnxt_tpa_idx_map *map = rxr->rx_tpa_idx_map; in bnxt_alloc_agg_idx()
1474 if (test_bit(idx, map->agg_idx_bmap)) in bnxt_alloc_agg_idx()
1475 idx = find_first_zero_bit(map->agg_idx_bmap, in bnxt_alloc_agg_idx()
1477 __set_bit(idx, map->agg_idx_bmap); in bnxt_alloc_agg_idx()
1478 map->agg_id_tbl[agg_id] = idx; in bnxt_alloc_agg_idx()
1484 struct bnxt_tpa_idx_map *map = rxr->rx_tpa_idx_map; in bnxt_free_agg_idx()
1486 __clear_bit(idx, map->agg_idx_bmap); in bnxt_free_agg_idx()
1491 struct bnxt_tpa_idx_map *map = rxr->rx_tpa_idx_map; in bnxt_lookup_agg_idx()
1493 return map->agg_id_tbl[agg_id]; in bnxt_lookup_agg_idx()
1500 tpa_info->cfa_code_valid = 1; in bnxt_tpa_metadata()
1501 tpa_info->cfa_code = TPA_START_CFA_CODE(tpa_start1); in bnxt_tpa_metadata()
1502 tpa_info->vlan_valid = 0; in bnxt_tpa_metadata()
1503 if (tpa_info->flags2 & RX_CMP_FLAGS2_META_FORMAT_VLAN) { in bnxt_tpa_metadata()
1504 tpa_info->vlan_valid = 1; in bnxt_tpa_metadata()
1505 tpa_info->metadata = in bnxt_tpa_metadata()
1506 le32_to_cpu(tpa_start1->rx_tpa_start_cmp_metadata); in bnxt_tpa_metadata()
1514 tpa_info->vlan_valid = 0; in bnxt_tpa_metadata_v2()
1519 tpa_info->vlan_valid = 1; in bnxt_tpa_metadata_v2()
1522 tpa_info->metadata = vlan_proto << 16 | in bnxt_tpa_metadata_v2()
1537 if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) { in bnxt_tpa_start()
1543 cons = tpa_start->rx_tpa_start_cmp_opaque; in bnxt_tpa_start()
1544 prod = rxr->rx_prod; in bnxt_tpa_start()
1545 cons_rx_buf = &rxr->rx_buf_ring[cons]; in bnxt_tpa_start()
1546 prod_rx_buf = &rxr->rx_buf_ring[RING_RX(bp, prod)]; in bnxt_tpa_start()
1547 tpa_info = &rxr->rx_tpa[agg_id]; in bnxt_tpa_start()
1549 if (unlikely(cons != rxr->rx_next_cons || in bnxt_tpa_start()
1551 netdev_warn(bp->dev, "TPA cons %x, expected cons %x, error code %x\n", in bnxt_tpa_start()
1552 cons, rxr->rx_next_cons, in bnxt_tpa_start()
1557 prod_rx_buf->data = tpa_info->data; in bnxt_tpa_start()
1558 prod_rx_buf->data_ptr = tpa_info->data_ptr; in bnxt_tpa_start()
1560 mapping = tpa_info->mapping; in bnxt_tpa_start()
1561 prod_rx_buf->mapping = mapping; in bnxt_tpa_start()
1563 prod_bd = &rxr->rx_desc_ring[RX_RING(bp, prod)][RX_IDX(prod)]; in bnxt_tpa_start()
1565 prod_bd->rx_bd_haddr = cpu_to_le64(mapping); in bnxt_tpa_start()
1567 tpa_info->data = cons_rx_buf->data; in bnxt_tpa_start()
1568 tpa_info->data_ptr = cons_rx_buf->data_ptr; in bnxt_tpa_start()
1569 cons_rx_buf->data = NULL; in bnxt_tpa_start()
1570 tpa_info->mapping = cons_rx_buf->mapping; in bnxt_tpa_start()
1572 tpa_info->len = in bnxt_tpa_start()
1573 le32_to_cpu(tpa_start->rx_tpa_start_cmp_len_flags_type) >> in bnxt_tpa_start()
1576 tpa_info->hash_type = PKT_HASH_TYPE_L4; in bnxt_tpa_start()
1577 tpa_info->gso_type = SKB_GSO_TCPV4; in bnxt_tpa_start()
1579 tpa_info->gso_type = SKB_GSO_TCPV6; in bnxt_tpa_start()
1580 /* RSS profiles 1 and 3 with extract code 0 for inner 4-tuple */ in bnxt_tpa_start()
1583 tpa_info->gso_type = SKB_GSO_TCPV6; in bnxt_tpa_start()
1584 tpa_info->rss_hash = in bnxt_tpa_start()
1585 le32_to_cpu(tpa_start->rx_tpa_start_cmp_rss_hash); in bnxt_tpa_start()
1587 tpa_info->hash_type = PKT_HASH_TYPE_NONE; in bnxt_tpa_start()
1588 tpa_info->gso_type = 0; in bnxt_tpa_start()
1589 netif_warn(bp, rx_err, bp->dev, "TPA packet without valid hash\n"); in bnxt_tpa_start()
1591 tpa_info->flags2 = le32_to_cpu(tpa_start1->rx_tpa_start_cmp_flags2); in bnxt_tpa_start()
1592 tpa_info->hdr_info = le32_to_cpu(tpa_start1->rx_tpa_start_cmp_hdr_info); in bnxt_tpa_start()
1597 tpa_info->agg_count = 0; in bnxt_tpa_start()
1599 rxr->rx_prod = NEXT_RX(prod); in bnxt_tpa_start()
1601 rxr->rx_next_cons = RING_RX(bp, NEXT_RX(cons)); in bnxt_tpa_start()
1602 cons_rx_buf = &rxr->rx_buf_ring[cons]; in bnxt_tpa_start()
1604 bnxt_reuse_rx_data(rxr, cons, cons_rx_buf->data); in bnxt_tpa_start()
1605 rxr->rx_prod = NEXT_RX(rxr->rx_prod); in bnxt_tpa_start()
1606 cons_rx_buf->data = NULL; in bnxt_tpa_start()
1621 struct iphdr *iph = (struct iphdr *)skb->data; in bnxt_gro_tunnel()
1623 if (iph->protocol == IPPROTO_UDP) in bnxt_gro_tunnel()
1624 uh = (struct udphdr *)(iph + 1); in bnxt_gro_tunnel()
1626 struct ipv6hdr *iph = (struct ipv6hdr *)skb->data; in bnxt_gro_tunnel()
1628 if (iph->nexthdr == IPPROTO_UDP) in bnxt_gro_tunnel()
1629 uh = (struct udphdr *)(iph + 1); in bnxt_gro_tunnel()
1632 if (uh->check) in bnxt_gro_tunnel()
1633 skb_shinfo(skb)->gso_type |= SKB_GSO_UDP_TUNNEL_CSUM; in bnxt_gro_tunnel()
1635 skb_shinfo(skb)->gso_type |= SKB_GSO_UDP_TUNNEL; in bnxt_gro_tunnel()
1648 u32 hdr_info = tpa_info->hdr_info; in bnxt_gro_func_5731x()
1661 __be16 proto = *((__be16 *)(skb->data + inner_ip_off - in bnxt_gro_func_5731x()
1662 ETH_HLEN - 2)); in bnxt_gro_func_5731x()
1673 inner_ip_off -= 4; in bnxt_gro_func_5731x()
1674 inner_mac_off -= 4; in bnxt_gro_func_5731x()
1675 outer_ip_off -= 4; in bnxt_gro_func_5731x()
1678 nw_off = inner_ip_off - ETH_HLEN; in bnxt_gro_func_5731x()
1680 if (tpa_info->flags2 & RX_TPA_START_CMP_FLAGS2_IP_TYPE) { in bnxt_gro_func_5731x()
1684 len = skb->len - skb_transport_offset(skb); in bnxt_gro_func_5731x()
1686 th->check = ~tcp_v6_check(len, &iph->saddr, &iph->daddr, 0); in bnxt_gro_func_5731x()
1691 len = skb->len - skb_transport_offset(skb); in bnxt_gro_func_5731x()
1693 th->check = ~tcp_v4_check(len, iph->saddr, iph->daddr, 0); in bnxt_gro_func_5731x()
1697 __be16 proto = *((__be16 *)(skb->data + outer_ip_off - in bnxt_gro_func_5731x()
1698 ETH_HLEN - 2)); in bnxt_gro_func_5731x()
1712 u32 hdr_info = tpa_info->hdr_info; in bnxt_gro_func_5750x()
1719 nw_off = inner_ip_off - ETH_HLEN; in bnxt_gro_func_5750x()
1721 iphdr_len = (tpa_info->flags2 & RX_TPA_START_CMP_FLAGS2_IP_TYPE) ? in bnxt_gro_func_5750x()
1726 __be16 proto = *((__be16 *)(skb->data + outer_ip_off - in bnxt_gro_func_5750x()
1727 ETH_HLEN - 2)); in bnxt_gro_func_5750x()
1749 if (tpa_info->gso_type == SKB_GSO_TCPV4) { in bnxt_gro_func_5730x()
1752 nw_off = payload_off - BNXT_IPV4_HDR_SIZE - tcp_opt_len - in bnxt_gro_func_5730x()
1757 len = skb->len - skb_transport_offset(skb); in bnxt_gro_func_5730x()
1759 th->check = ~tcp_v4_check(len, iph->saddr, iph->daddr, 0); in bnxt_gro_func_5730x()
1760 } else if (tpa_info->gso_type == SKB_GSO_TCPV6) { in bnxt_gro_func_5730x()
1763 nw_off = payload_off - BNXT_IPV6_HDR_SIZE - tcp_opt_len - in bnxt_gro_func_5730x()
1768 len = skb->len - skb_transport_offset(skb); in bnxt_gro_func_5730x()
1770 th->check = ~tcp_v6_check(len, &iph->saddr, &iph->daddr, 0); in bnxt_gro_func_5730x()
1777 bnxt_gro_tunnel(skb, skb->protocol); in bnxt_gro_func_5730x()
1793 if (segs == 1) in bnxt_gro_skb()
1796 NAPI_GRO_CB(skb)->count = segs; in bnxt_gro_skb()
1797 skb_shinfo(skb)->gso_size = in bnxt_gro_skb()
1798 le32_to_cpu(tpa_end1->rx_tpa_end_cmp_seg_len); in bnxt_gro_skb()
1799 skb_shinfo(skb)->gso_type = tpa_info->gso_type; in bnxt_gro_skb()
1800 if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) in bnxt_gro_skb()
1804 skb = bp->gro_func(tpa_info, payload_off, TPA_END_GRO_TS(tpa_end), skb); in bnxt_gro_skb()
1812 * netdev (vf-rep or PF) the packet is destined to.
1818 /* if vf-rep dev is NULL, it must belong to the PF */ in bnxt_get_pkt_dev()
1819 return dev ? dev : bp->dev; in bnxt_get_pkt_dev()
1829 struct bnxt_napi *bnapi = cpr->bnapi; in bnxt_tpa_end()
1830 struct bnxt_rx_ring_info *rxr = bnapi->rx_ring; in bnxt_tpa_end()
1831 struct net_device *dev = bp->dev; in bnxt_tpa_end()
1841 if (unlikely(bnapi->in_reset)) { in bnxt_tpa_end()
1845 return ERR_PTR(-EBUSY); in bnxt_tpa_end()
1849 if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) { in bnxt_tpa_end()
1853 tpa_info = &rxr->rx_tpa[agg_id]; in bnxt_tpa_end()
1854 if (unlikely(agg_bufs != tpa_info->agg_count)) { in bnxt_tpa_end()
1855 netdev_warn(bp->dev, "TPA end agg_buf %d != expected agg_bufs %d\n", in bnxt_tpa_end()
1856 agg_bufs, tpa_info->agg_count); in bnxt_tpa_end()
1857 agg_bufs = tpa_info->agg_count; in bnxt_tpa_end()
1859 tpa_info->agg_count = 0; in bnxt_tpa_end()
1863 gro = !!(bp->flags & BNXT_FLAG_GRO); in bnxt_tpa_end()
1867 tpa_info = &rxr->rx_tpa[agg_id]; in bnxt_tpa_end()
1871 return ERR_PTR(-EBUSY); in bnxt_tpa_end()
1878 data = tpa_info->data; in bnxt_tpa_end()
1879 data_ptr = tpa_info->data_ptr; in bnxt_tpa_end()
1881 len = tpa_info->len; in bnxt_tpa_end()
1882 mapping = tpa_info->mapping; in bnxt_tpa_end()
1887 netdev_warn(bp->dev, "TPA frags %d exceeded MAX_SKB_FRAGS %d\n", in bnxt_tpa_end()
1892 if (len <= bp->rx_copybreak) { in bnxt_tpa_end()
1896 cpr->sw_stats->rx.rx_oom_discards += 1; in bnxt_tpa_end()
1907 cpr->sw_stats->rx.rx_oom_discards += 1; in bnxt_tpa_end()
1911 tpa_info->data = new_data; in bnxt_tpa_end()
1912 tpa_info->data_ptr = new_data + bp->rx_offset; in bnxt_tpa_end()
1913 tpa_info->mapping = new_mapping; in bnxt_tpa_end()
1915 skb = napi_build_skb(data, bp->rx_buf_size); in bnxt_tpa_end()
1916 dma_sync_single_for_cpu(&bp->pdev->dev, mapping, in bnxt_tpa_end()
1917 bp->rx_buf_use_size, bp->rx_dir); in bnxt_tpa_end()
1920 page_pool_free_va(rxr->head_pool, data, true); in bnxt_tpa_end()
1922 cpr->sw_stats->rx.rx_oom_discards += 1; in bnxt_tpa_end()
1926 skb_reserve(skb, bp->rx_offset); in bnxt_tpa_end()
1935 cpr->sw_stats->rx.rx_oom_discards += 1; in bnxt_tpa_end()
1940 if (tpa_info->cfa_code_valid) in bnxt_tpa_end()
1941 dev = bnxt_get_pkt_dev(bp, tpa_info->cfa_code); in bnxt_tpa_end()
1942 skb->protocol = eth_type_trans(skb, dev); in bnxt_tpa_end()
1944 if (tpa_info->hash_type != PKT_HASH_TYPE_NONE) in bnxt_tpa_end()
1945 skb_set_hash(skb, tpa_info->rss_hash, tpa_info->hash_type); in bnxt_tpa_end()
1947 if (tpa_info->vlan_valid && in bnxt_tpa_end()
1948 (dev->features & BNXT_HW_FEATURE_VLAN_ALL_RX)) { in bnxt_tpa_end()
1949 __be16 vlan_proto = htons(tpa_info->metadata >> in bnxt_tpa_end()
1951 u16 vtag = tpa_info->metadata & RX_CMP_FLAGS2_METADATA_TCI_MASK; in bnxt_tpa_end()
1962 if (likely(tpa_info->flags2 & RX_TPA_START_CMP_FLAGS2_L4_CS_CALC)) { in bnxt_tpa_end()
1963 skb->ip_summed = CHECKSUM_UNNECESSARY; in bnxt_tpa_end()
1964 skb->csum_level = in bnxt_tpa_end()
1965 (tpa_info->flags2 & RX_CMP_FLAGS2_T_L4_CS_CALC) >> 3; in bnxt_tpa_end()
1981 tpa_info = &rxr->rx_tpa[agg_id]; in bnxt_tpa_agg()
1982 BUG_ON(tpa_info->agg_count >= MAX_SKB_FRAGS); in bnxt_tpa_agg()
1983 tpa_info->agg_arr[tpa_info->agg_count++] = *rx_agg; in bnxt_tpa_agg()
1991 if (skb->dev != bp->dev) { in bnxt_deliver_skb()
1992 /* this packet belongs to a vf-rep */ in bnxt_deliver_skb()
1996 skb_record_rx_queue(skb, bnapi->index); in bnxt_deliver_skb()
1997 napi_gro_receive(&bnapi->napi, skb); in bnxt_deliver_skb()
2003 u32 ts = le32_to_cpu(rxcmp1->rx_cmp_timestamp); in bnxt_rx_ts_valid()
2007 if (!bp->ptp_all_rx_tstamp || !ts || !BNXT_ALL_RX_TS_VALID(flags)) in bnxt_rx_ts_valid()
2023 __le32 flags2 = rxcmp1->rx_cmp_flags2; in bnxt_rx_vlan()
2029 meta_data = le32_to_cpu(rxcmp1->rx_cmp_meta_data); in bnxt_rx_vlan()
2075 * 1 - 1 packet successfully received
2076 * 0 - successful TPA_START, packet not completed yet
2077 * -EBUSY - completion ring does not have all the agg buffers yet
2078 * -ENOMEM - packet aborted due to out of memory
2079 * -EIO - packet aborted due to hw error indicated in BD
2084 struct bnxt_napi *bnapi = cpr->bnapi; in bnxt_rx_pkt()
2085 struct bnxt_rx_ring_info *rxr = bnapi->rx_ring; in bnxt_rx_pkt()
2086 struct net_device *dev = bp->dev; in bnxt_rx_pkt()
2105 &cpr->cp_desc_ring[CP_RING(cp_cons)][CP_IDX(cp_cons)]; in bnxt_rx_pkt()
2117 &cpr->cp_desc_ring[CP_RING(cp_cons)][CP_IDX(cp_cons)]; in bnxt_rx_pkt()
2120 return -EBUSY; in bnxt_rx_pkt()
2126 prod = rxr->rx_prod; in bnxt_rx_pkt()
2143 return -EBUSY; in bnxt_rx_pkt()
2145 rc = -ENOMEM; in bnxt_rx_pkt()
2148 rc = 1; in bnxt_rx_pkt()
2154 cons = rxcmp->rx_cmp_opaque; in bnxt_rx_pkt()
2155 if (unlikely(cons != rxr->rx_next_cons)) { in bnxt_rx_pkt()
2159 if (rxr->rx_next_cons != 0xffff) in bnxt_rx_pkt()
2160 netdev_warn(bp->dev, "RX cons %x != expected cons %x\n", in bnxt_rx_pkt()
2161 cons, rxr->rx_next_cons); in bnxt_rx_pkt()
2167 rx_buf = &rxr->rx_buf_ring[cons]; in bnxt_rx_pkt()
2168 data = rx_buf->data; in bnxt_rx_pkt()
2169 data_ptr = rx_buf->data_ptr; in bnxt_rx_pkt()
2172 misc = le32_to_cpu(rxcmp->rx_cmp_misc_v1); in bnxt_rx_pkt()
2177 return -EBUSY; in bnxt_rx_pkt()
2184 rx_buf->data = NULL; in bnxt_rx_pkt()
2185 if (rxcmp1->rx_cmp_cfa_code_errors_v2 & RX_CMP_L2_ERRORS) { in bnxt_rx_pkt()
2186 u32 rx_err = le32_to_cpu(rxcmp1->rx_cmp_cfa_code_errors_v2); in bnxt_rx_pkt()
2193 rc = -EIO; in bnxt_rx_pkt()
2195 bnapi->cp_ring.sw_stats->rx.rx_buf_errors++; in bnxt_rx_pkt()
2196 if (!(bp->flags & BNXT_FLAG_CHIP_P5_PLUS) && in bnxt_rx_pkt()
2197 !(bp->fw_cap & BNXT_FW_CAP_RING_MONITOR)) { in bnxt_rx_pkt()
2198 netdev_warn_once(bp->dev, "RX buffer error %x\n", in bnxt_rx_pkt()
2206 flags = le32_to_cpu(rxcmp->rx_cmp_len_flags_type); in bnxt_rx_pkt()
2208 dma_addr = rx_buf->mapping; in bnxt_rx_pkt()
2226 rc = 1; in bnxt_rx_pkt()
2231 agg_bufs = sinfo->nr_frags; in bnxt_rx_pkt()
2237 if (len <= bp->rx_copybreak) { in bnxt_rx_pkt()
2256 if (rx_buf->data_ptr == data_ptr) in bnxt_rx_pkt()
2260 skb = bp->rx_skb_func(bp, rxr, cons, data, data_ptr, dma_addr, in bnxt_rx_pkt()
2274 rxr->page_pool, &xdp); in bnxt_rx_pkt()
2297 skb_set_hash(skb, le32_to_cpu(rxcmp->rx_cmp_rss_hash), type); in bnxt_rx_pkt()
2302 skb->protocol = eth_type_trans(skb, dev); in bnxt_rx_pkt()
2304 if (skb->dev->features & BNXT_HW_FEATURE_VLAN_ALL_RX) { in bnxt_rx_pkt()
2312 if (dev->features & NETIF_F_RXCSUM) { in bnxt_rx_pkt()
2313 skb->ip_summed = CHECKSUM_UNNECESSARY; in bnxt_rx_pkt()
2314 skb->csum_level = RX_CMP_ENCAP(rxcmp1); in bnxt_rx_pkt()
2317 if (rxcmp1->rx_cmp_cfa_code_errors_v2 & RX_CMP_L4_CS_ERR_BITS) { in bnxt_rx_pkt()
2318 if (dev->features & NETIF_F_RXCSUM) in bnxt_rx_pkt()
2319 bnapi->cp_ring.sw_stats->rx.rx_l4_csum_errors++; in bnxt_rx_pkt()
2324 if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) { in bnxt_rx_pkt()
2328 struct bnxt_ptp_cfg *ptp = bp->ptp_cfg; in bnxt_rx_pkt()
2333 skb_hwtstamps(skb)->hwtstamp = ns_to_ktime(ns); in bnxt_rx_pkt()
2338 rc = 1; in bnxt_rx_pkt()
2341 cpr->rx_packets += 1; in bnxt_rx_pkt()
2342 cpr->rx_bytes += len; in bnxt_rx_pkt()
2345 rxr->rx_prod = NEXT_RX(prod); in bnxt_rx_pkt()
2346 rxr->rx_next_cons = RING_RX(bp, NEXT_RX(cons)); in bnxt_rx_pkt()
2354 cpr->sw_stats->rx.rx_oom_discards += 1; in bnxt_rx_pkt()
2355 rc = -ENOMEM; in bnxt_rx_pkt()
2375 &cpr->cp_desc_ring[CP_RING(cp_cons)][CP_IDX(cp_cons)]; in bnxt_force_rx_discard()
2380 &cpr->cp_desc_ring[CP_RING(cp_cons)][CP_IDX(cp_cons)]; in bnxt_force_rx_discard()
2383 return -EBUSY; in bnxt_force_rx_discard()
2392 rxcmp1->rx_cmp_cfa_code_errors_v2 |= in bnxt_force_rx_discard()
2398 tpa_end1->rx_tpa_end_cmp_errors_v2 |= in bnxt_force_rx_discard()
2402 if (rc && rc != -EBUSY) in bnxt_force_rx_discard()
2403 cpr->sw_stats->rx.rx_netpoll_discards += 1; in bnxt_force_rx_discard()
2409 struct bnxt_fw_health *fw_health = bp->fw_health; in bnxt_fw_health_readl()
2410 u32 reg = fw_health->regs[reg_idx]; in bnxt_fw_health_readl()
2417 pci_read_config_dword(bp->pdev, reg_off, &val); in bnxt_fw_health_readl()
2420 reg_off = fw_health->mapped_regs[reg_idx]; in bnxt_fw_health_readl()
2423 val = readl(bp->bar0 + reg_off); in bnxt_fw_health_readl()
2426 val = readl(bp->bar1 + reg_off); in bnxt_fw_health_readl()
2430 val &= fw_health->fw_reset_inprog_reg_mask; in bnxt_fw_health_readl()
2438 for (i = 0; i < bp->rx_nr_rings; i++) { in bnxt_agg_ring_id_to_grp_idx()
2439 u16 grp_idx = bp->rx_ring[i].bnapi->index; in bnxt_agg_ring_id_to_grp_idx()
2442 grp_info = &bp->grp_info[grp_idx]; in bnxt_agg_ring_id_to_grp_idx()
2443 if (grp_info->agg_fw_ring_id == ring_id) in bnxt_agg_ring_id_to_grp_idx()
2453 if (bp->phy_flags & BNXT_PHY_FL_SPEEDS2) in bnxt_get_force_speed()
2454 return link_info->force_link_speed2; in bnxt_get_force_speed()
2455 if (link_info->req_signal_mode == BNXT_SIG_MODE_PAM4) in bnxt_get_force_speed()
2456 return link_info->force_pam4_link_speed; in bnxt_get_force_speed()
2457 return link_info->force_link_speed; in bnxt_get_force_speed()
2464 if (bp->phy_flags & BNXT_PHY_FL_SPEEDS2) { in bnxt_set_force_speed()
2465 link_info->req_link_speed = link_info->force_link_speed2; in bnxt_set_force_speed()
2466 link_info->req_signal_mode = BNXT_SIG_MODE_NRZ; in bnxt_set_force_speed()
2467 switch (link_info->req_link_speed) { in bnxt_set_force_speed()
2472 link_info->req_signal_mode = BNXT_SIG_MODE_PAM4; in bnxt_set_force_speed()
2477 link_info->req_signal_mode = BNXT_SIG_MODE_PAM4_112; in bnxt_set_force_speed()
2480 link_info->req_signal_mode = BNXT_SIG_MODE_NRZ; in bnxt_set_force_speed()
2484 link_info->req_link_speed = link_info->force_link_speed; in bnxt_set_force_speed()
2485 link_info->req_signal_mode = BNXT_SIG_MODE_NRZ; in bnxt_set_force_speed()
2486 if (link_info->force_pam4_link_speed) { in bnxt_set_force_speed()
2487 link_info->req_link_speed = link_info->force_pam4_link_speed; in bnxt_set_force_speed()
2488 link_info->req_signal_mode = BNXT_SIG_MODE_PAM4; in bnxt_set_force_speed()
2496 if (bp->phy_flags & BNXT_PHY_FL_SPEEDS2) { in bnxt_set_auto_speed()
2497 link_info->advertising = link_info->auto_link_speeds2; in bnxt_set_auto_speed()
2500 link_info->advertising = link_info->auto_link_speeds; in bnxt_set_auto_speed()
2501 link_info->advertising_pam4 = link_info->auto_pam4_link_speeds; in bnxt_set_auto_speed()
2508 if (bp->phy_flags & BNXT_PHY_FL_SPEEDS2) { in bnxt_force_speed_updated()
2509 if (link_info->req_link_speed != link_info->force_link_speed2) in bnxt_force_speed_updated()
2513 if (link_info->req_signal_mode == BNXT_SIG_MODE_NRZ && in bnxt_force_speed_updated()
2514 link_info->req_link_speed != link_info->force_link_speed) in bnxt_force_speed_updated()
2516 if (link_info->req_signal_mode == BNXT_SIG_MODE_PAM4 && in bnxt_force_speed_updated()
2517 link_info->req_link_speed != link_info->force_pam4_link_speed) in bnxt_force_speed_updated()
2526 if (bp->phy_flags & BNXT_PHY_FL_SPEEDS2) { in bnxt_auto_speed_updated()
2527 if (link_info->advertising != link_info->auto_link_speeds2) in bnxt_auto_speed_updated()
2531 if (link_info->advertising != link_info->auto_link_speeds || in bnxt_auto_speed_updated()
2532 link_info->advertising_pam4 != link_info->auto_pam4_link_speeds) in bnxt_auto_speed_updated()
2539 u32 flags = bp->ctx->ctx_arr[type].flags; in bnxt_bs_trace_avail()
2549 u16 trace_type = bnxt_bstore_to_trace[ctxm->type]; in bnxt_bs_trace_init()
2550 struct bnxt_ctx_pg_info *ctx_pg = ctxm->pg_info; in bnxt_bs_trace_init()
2555 if (ctxm->instance_bmap && ctxm->instance_bmap > 1) in bnxt_bs_trace_init()
2558 mem_size = ctxm->max_entries * ctxm->entry_size; in bnxt_bs_trace_init()
2562 last_pg = (pages - 1) & (MAX_CTX_PAGES - 1); in bnxt_bs_trace_init()
2563 magic_byte_offset = (rem_bytes ? rem_bytes : BNXT_PAGE_SIZE) - 1; in bnxt_bs_trace_init()
2566 bs_trace = &bp->bs_trace[trace_type]; in bnxt_bs_trace_init()
2567 bs_trace->ctx_type = ctxm->type; in bnxt_bs_trace_init()
2568 bs_trace->trace_type = trace_type; in bnxt_bs_trace_init()
2570 int last_pg_dir = rmem->nr_pages - 1; in bnxt_bs_trace_init()
2572 rmem_pg_tbl = &ctx_pg[0].ctx_pg_tbl[last_pg_dir]->ring_mem; in bnxt_bs_trace_init()
2573 bs_trace->magic_byte = rmem_pg_tbl->pg_arr[last_pg]; in bnxt_bs_trace_init()
2575 bs_trace->magic_byte = rmem->pg_arr[last_pg]; in bnxt_bs_trace_init()
2577 bs_trace->magic_byte += magic_byte_offset; in bnxt_bs_trace_init()
2578 *bs_trace->magic_byte = BNXT_TRACE_BUF_MAGIC_BYTE; in bnxt_bs_trace_init()
2615 …netdev_err(bp->dev, "1PPS: Received invalid signal on pin%lu from the external source. Please fix … in bnxt_event_error_report()
2619 netdev_warn(bp->dev, "Pause Storm detected!\n"); in bnxt_event_error_report()
2622 netdev_warn(bp->dev, "One or more MMIO doorbells dropped by the device!\n"); in bnxt_event_error_report()
2644 netdev_err(bp->dev, "Unknown Thermal threshold type event\n"); in bnxt_event_error_report()
2653 netdev_warn(bp->dev, "Chip temperature has gone %s the %s thermal threshold!\n", in bnxt_event_error_report()
2655 netdev_warn(bp->dev, "Temperature (In Celsius), Current: %lu, threshold: %lu\n", in bnxt_event_error_report()
2659 bp->thermal_threshold_type = type; in bnxt_event_error_report()
2660 set_bit(BNXT_THERMAL_THRESHOLD_SP_EVENT, &bp->sp_event); in bnxt_event_error_report()
2666 netdev_warn(bp->dev, "Speed change not supported with dual rate transceivers on this board\n"); in bnxt_event_error_report()
2669 netdev_err(bp->dev, "FW reported unknown error type %u\n", in bnxt_event_error_report()
2701 u16 event_id = le16_to_cpu(cmpl->event_id); in bnxt_async_event_process()
2702 u32 data1 = le32_to_cpu(cmpl->event_data1); in bnxt_async_event_process()
2703 u32 data2 = le32_to_cpu(cmpl->event_data2); in bnxt_async_event_process()
2705 netdev_dbg(bp->dev, "hwrm event 0x%x {0x%x, 0x%x}\n", in bnxt_async_event_process()
2711 struct bnxt_link_info *link_info = &bp->link_info; in bnxt_async_event_process()
2717 if (!(link_info->autoneg & BNXT_AUTONEG_SPEED) && in bnxt_async_event_process()
2723 netdev_warn(bp->dev, "Link speed %d no longer supported\n", in bnxt_async_event_process()
2726 set_bit(BNXT_LINK_SPEED_CHNG_SP_EVENT, &bp->sp_event); in bnxt_async_event_process()
2731 set_bit(BNXT_LINK_CFG_CHANGE_SP_EVENT, &bp->sp_event); in bnxt_async_event_process()
2734 set_bit(BNXT_LINK_CHNG_SP_EVENT, &bp->sp_event); in bnxt_async_event_process()
2737 set_bit(BNXT_HWRM_PF_UNLOAD_SP_EVENT, &bp->sp_event); in bnxt_async_event_process()
2745 if (bp->pf.port_id != port_id) in bnxt_async_event_process()
2748 set_bit(BNXT_HWRM_PORT_MODULE_SP_EVENT, &bp->sp_event); in bnxt_async_event_process()
2754 set_bit(BNXT_RESET_TASK_SILENT_SP_EVENT, &bp->sp_event); in bnxt_async_event_process()
2759 if (!bp->fw_health) in bnxt_async_event_process()
2762 bp->fw_reset_timestamp = jiffies; in bnxt_async_event_process()
2763 bp->fw_reset_min_dsecs = cmpl->timestamp_lo; in bnxt_async_event_process()
2764 if (!bp->fw_reset_min_dsecs) in bnxt_async_event_process()
2765 bp->fw_reset_min_dsecs = BNXT_DFLT_FW_RST_MIN_DSECS; in bnxt_async_event_process()
2766 bp->fw_reset_max_dsecs = le16_to_cpu(cmpl->timestamp_hi); in bnxt_async_event_process()
2767 if (!bp->fw_reset_max_dsecs) in bnxt_async_event_process()
2768 bp->fw_reset_max_dsecs = BNXT_DFLT_FW_RST_MAX_DSECS; in bnxt_async_event_process()
2770 set_bit(BNXT_STATE_FW_ACTIVATE_RESET, &bp->state); in bnxt_async_event_process()
2773 bp->fw_health->fatalities++; in bnxt_async_event_process()
2774 set_bit(BNXT_STATE_FW_FATAL_COND, &bp->state); in bnxt_async_event_process()
2777 type_str = "Non-fatal"; in bnxt_async_event_process()
2778 bp->fw_health->survivals++; in bnxt_async_event_process()
2779 set_bit(BNXT_STATE_FW_NON_FATAL_COND, &bp->state); in bnxt_async_event_process()
2781 netif_warn(bp, hw, bp->dev, in bnxt_async_event_process()
2784 bp->fw_reset_min_dsecs * 100, in bnxt_async_event_process()
2785 bp->fw_reset_max_dsecs * 100); in bnxt_async_event_process()
2786 set_bit(BNXT_FW_RESET_NOTIFY_SP_EVENT, &bp->sp_event); in bnxt_async_event_process()
2790 struct bnxt_fw_health *fw_health = bp->fw_health; in bnxt_async_event_process()
2798 fw_health->enabled = false; in bnxt_async_event_process()
2799 netif_info(bp, drv, bp->dev, "Driver recovery watchdog is disabled\n"); in bnxt_async_event_process()
2802 fw_health->primary = EVENT_DATA1_RECOVERY_MASTER_FUNC(data1); in bnxt_async_event_process()
2803 fw_health->tmr_multiplier = in bnxt_async_event_process()
2804 DIV_ROUND_UP(fw_health->polling_dsecs * HZ, in bnxt_async_event_process()
2805 bp->current_interval * 10); in bnxt_async_event_process()
2806 fw_health->tmr_counter = fw_health->tmr_multiplier; in bnxt_async_event_process()
2807 if (!fw_health->enabled) in bnxt_async_event_process()
2808 fw_health->last_fw_heartbeat = in bnxt_async_event_process()
2810 fw_health->last_fw_reset_cnt = in bnxt_async_event_process()
2815 netif_info(bp, drv, bp->dev, in bnxt_async_event_process()
2817 fw_health->primary ? "primary" : "backup", status, in bnxt_async_event_process()
2818 status_desc, fw_health->last_fw_reset_cnt); in bnxt_async_event_process()
2819 if (!fw_health->enabled) { in bnxt_async_event_process()
2824 fw_health->enabled = true; in bnxt_async_event_process()
2829 netif_notice(bp, hw, bp->dev, in bnxt_async_event_process()
2837 if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) in bnxt_async_event_process()
2840 netdev_warn(bp->dev, "Ring monitor event, ring type %lu id 0x%x\n", in bnxt_async_event_process()
2847 netdev_warn(bp->dev, "Unknown RX agg ring id 0x%x\n", in bnxt_async_event_process()
2851 rxr = bp->bnapi[grp_idx]->rx_ring; in bnxt_async_event_process()
2856 struct bnxt_fw_health *fw_health = bp->fw_health; in bnxt_async_event_process()
2858 netif_notice(bp, hw, bp->dev, in bnxt_async_event_process()
2862 fw_health->echo_req_data1 = data1; in bnxt_async_event_process()
2863 fw_health->echo_req_data2 = data2; in bnxt_async_event_process()
2864 set_bit(BNXT_FW_ECHO_REQUEST_SP_EVENT, &bp->sp_event); in bnxt_async_event_process()
2882 struct bnxt_ptp_cfg *ptp = bp->ptp_cfg; in bnxt_async_event_process()
2891 BNXT_PHC_BITS) | ptp->current_time); in bnxt_async_event_process()
2892 write_seqlock_irqsave(&ptp->ptp_lock, flags); in bnxt_async_event_process()
2894 write_sequnlock_irqrestore(&ptp->ptp_lock, flags); in bnxt_async_event_process()
2901 u16 seq_id = le32_to_cpu(cmpl->event_data2) & 0xffff; in bnxt_async_event_process()
2910 bnxt_bs_trace_check_wrap(&bp->bs_trace[type], offset); in bnxt_async_event_process()
2931 seq_id = le16_to_cpu(h_cmpl->sequence_id); in bnxt_hwrm_handler()
2936 vf_id = le16_to_cpu(fwd_req_cmpl->source_id); in bnxt_hwrm_handler()
2938 if ((vf_id < bp->pf.first_vf_id) || in bnxt_hwrm_handler()
2939 (vf_id >= bp->pf.first_vf_id + bp->pf.active_vfs)) { in bnxt_hwrm_handler()
2940 netdev_err(bp->dev, "Msg contains invalid VF id %x\n", in bnxt_hwrm_handler()
2942 return -EINVAL; in bnxt_hwrm_handler()
2945 set_bit(vf_id - bp->pf.first_vf_id, bp->pf.vf_event_bmap); in bnxt_hwrm_handler()
2963 struct bnxt_vnic_info *vnic = &bp->vnic_info[0]; in bnxt_vnic_is_active()
2965 return vnic->fw_vnic_id != INVALID_HW_RING_ID && vnic->mru > 0; in bnxt_vnic_is_active()
2971 struct bnxt *bp = bnapi->bp; in bnxt_msix()
2972 struct bnxt_cp_ring_info *cpr = &bnapi->cp_ring; in bnxt_msix()
2973 u32 cons = RING_CMP(cpr->cp_raw_cons); in bnxt_msix()
2975 cpr->event_ctr++; in bnxt_msix()
2976 prefetch(&cpr->cp_desc_ring[CP_RING(cons)][CP_IDX(cons)]); in bnxt_msix()
2977 napi_schedule(&bnapi->napi); in bnxt_msix()
2983 u32 raw_cons = cpr->cp_raw_cons; in bnxt_has_work()
2987 txcmp = &cpr->cp_desc_ring[CP_RING(cons)][CP_IDX(cons)]; in bnxt_has_work()
2995 struct bnxt_napi *bnapi = cpr->bnapi; in __bnxt_poll_work()
2996 u32 raw_cons = cpr->cp_raw_cons; in __bnxt_poll_work()
3003 cpr->has_more_work = 0; in __bnxt_poll_work()
3004 cpr->had_work_done = 1; in __bnxt_poll_work()
3005 while (1) { in __bnxt_poll_work()
3010 txcmp = &cpr->cp_desc_ring[CP_RING(cons)][CP_IDX(cons)]; in __bnxt_poll_work()
3022 u32 opaque = txcmp->tx_cmp_opaque; in __bnxt_poll_work()
3026 txr = bnapi->tx_ring[TX_OPAQUE_RING(opaque)]; in __bnxt_poll_work()
3029 txr->tx_hw_cons = TX_CMP_SQ_CONS_IDX(txcmp); in __bnxt_poll_work()
3031 txr->tx_hw_cons = TX_OPAQUE_PROD(bp, opaque); in __bnxt_poll_work()
3032 tx_freed = (txr->tx_hw_cons - txr->tx_cons) & in __bnxt_poll_work()
3033 bp->tx_ring_mask; in __bnxt_poll_work()
3035 if (unlikely(tx_freed >= bp->tx_wake_thresh)) { in __bnxt_poll_work()
3039 cpr->has_more_work = 1; in __bnxt_poll_work()
3055 /* Increment rx_pkts when rc is -ENOMEM to count towards in __bnxt_poll_work()
3060 else if (rc == -ENOMEM && budget) in __bnxt_poll_work()
3062 else if (rc == -EBUSY) /* partial completion */ in __bnxt_poll_work()
3072 cpr->has_more_work = 1; in __bnxt_poll_work()
3083 struct bnxt_tx_ring_info *txr = bnapi->tx_ring[0]; in __bnxt_poll_work()
3084 u16 prod = txr->tx_prod; in __bnxt_poll_work()
3089 bnxt_db_write_relaxed(bp, &txr->tx_db, prod); in __bnxt_poll_work()
3093 cpr->cp_raw_cons = raw_cons; in __bnxt_poll_work()
3094 bnapi->events |= event; in __bnxt_poll_work()
3101 if ((bnapi->events & BNXT_TX_CMP_EVENT) && !bnapi->tx_fault) in __bnxt_poll_work_done()
3102 bnapi->tx_int(bp, bnapi, budget); in __bnxt_poll_work_done()
3104 if ((bnapi->events & BNXT_RX_EVENT) && !(bnapi->in_reset)) { in __bnxt_poll_work_done()
3105 struct bnxt_rx_ring_info *rxr = bnapi->rx_ring; in __bnxt_poll_work_done()
3107 bnxt_db_write(bp, &rxr->rx_db, rxr->rx_prod); in __bnxt_poll_work_done()
3108 bnapi->events &= ~BNXT_RX_EVENT; in __bnxt_poll_work_done()
3110 if (bnapi->events & BNXT_AGG_EVENT) { in __bnxt_poll_work_done()
3111 struct bnxt_rx_ring_info *rxr = bnapi->rx_ring; in __bnxt_poll_work_done()
3113 bnxt_db_write(bp, &rxr->rx_agg_db, rxr->rx_agg_prod); in __bnxt_poll_work_done()
3114 bnapi->events &= ~BNXT_AGG_EVENT; in __bnxt_poll_work_done()
3121 struct bnxt_napi *bnapi = cpr->bnapi; in bnxt_poll_work()
3130 bnxt_db_cq(bp, &cpr->cp_db, cpr->cp_raw_cons); in bnxt_poll_work()
3139 struct bnxt *bp = bnapi->bp; in bnxt_poll_nitroa0()
3140 struct bnxt_cp_ring_info *cpr = &bnapi->cp_ring; in bnxt_poll_nitroa0()
3141 struct bnxt_rx_ring_info *rxr = bnapi->rx_ring; in bnxt_poll_nitroa0()
3145 u32 raw_cons = cpr->cp_raw_cons; in bnxt_poll_nitroa0()
3150 while (1) { in bnxt_poll_nitroa0()
3154 txcmp = &cpr->cp_desc_ring[CP_RING(cp_cons)][CP_IDX(cp_cons)]; in bnxt_poll_nitroa0()
3167 &cpr->cp_desc_ring[CP_RING(cp_cons)][CP_IDX(cp_cons)]; in bnxt_poll_nitroa0()
3173 rxcmp1->rx_cmp_cfa_code_errors_v2 |= in bnxt_poll_nitroa0()
3177 if (likely(rc == -EIO) && budget) in bnxt_poll_nitroa0()
3179 else if (rc == -EBUSY) /* partial completion */ in bnxt_poll_nitroa0()
3187 netdev_err(bp->dev, in bnxt_poll_nitroa0()
3196 cpr->cp_raw_cons = raw_cons; in bnxt_poll_nitroa0()
3197 BNXT_DB_CQ(&cpr->cp_db, cpr->cp_raw_cons); in bnxt_poll_nitroa0()
3198 bnxt_db_write(bp, &rxr->rx_db, rxr->rx_prod); in bnxt_poll_nitroa0()
3201 bnxt_db_write(bp, &rxr->rx_agg_db, rxr->rx_agg_prod); in bnxt_poll_nitroa0()
3207 BNXT_DB_CQ_ARM(&cpr->cp_db, cpr->cp_raw_cons); in bnxt_poll_nitroa0()
3215 struct bnxt *bp = bnapi->bp; in bnxt_poll()
3216 struct bnxt_cp_ring_info *cpr = &bnapi->cp_ring; in bnxt_poll()
3219 if (unlikely(test_bit(BNXT_STATE_FW_FATAL_COND, &bp->state))) { in bnxt_poll()
3223 while (1) { in bnxt_poll()
3224 work_done += bnxt_poll_work(bp, cpr, budget - work_done); in bnxt_poll()
3228 BNXT_DB_CQ_ARM(&cpr->cp_db, cpr->cp_raw_cons); in bnxt_poll()
3234 BNXT_DB_CQ_ARM(&cpr->cp_db, cpr->cp_raw_cons); in bnxt_poll()
3238 if ((bp->flags & BNXT_FLAG_DIM) && bnxt_vnic_is_active(bp)) { in bnxt_poll()
3241 dim_update_sample(cpr->event_ctr, in bnxt_poll()
3242 cpr->rx_packets, in bnxt_poll()
3243 cpr->rx_bytes, in bnxt_poll()
3245 net_dim(&cpr->dim, &dim_sample); in bnxt_poll()
3252 struct bnxt_cp_ring_info *cpr = &bnapi->cp_ring; in __bnxt_poll_cqs()
3255 for (i = 0; i < cpr->cp_ring_count; i++) { in __bnxt_poll_cqs()
3256 struct bnxt_cp_ring_info *cpr2 = &cpr->cp_ring_arr[i]; in __bnxt_poll_cqs()
3258 if (cpr2->had_nqe_notify) { in __bnxt_poll_cqs()
3260 budget - work_done); in __bnxt_poll_cqs()
3261 cpr->has_more_work |= cpr2->has_more_work; in __bnxt_poll_cqs()
3270 struct bnxt_cp_ring_info *cpr = &bnapi->cp_ring; in __bnxt_poll_cqs_done()
3273 for (i = 0; i < cpr->cp_ring_count; i++) { in __bnxt_poll_cqs_done()
3274 struct bnxt_cp_ring_info *cpr2 = &cpr->cp_ring_arr[i]; in __bnxt_poll_cqs_done()
3277 if (cpr2->had_work_done) { in __bnxt_poll_cqs_done()
3281 cpr2->had_nqe_notify = 0; in __bnxt_poll_cqs_done()
3282 tgl = cpr2->toggle; in __bnxt_poll_cqs_done()
3284 db = &cpr2->cp_db; in __bnxt_poll_cqs_done()
3286 db->db_key64 | dbr_type | DB_TOGGLE(tgl) | in __bnxt_poll_cqs_done()
3287 DB_RING_IDX(db, cpr2->cp_raw_cons), in __bnxt_poll_cqs_done()
3288 db->doorbell); in __bnxt_poll_cqs_done()
3289 cpr2->had_work_done = 0; in __bnxt_poll_cqs_done()
3298 struct bnxt_cp_ring_info *cpr = &bnapi->cp_ring; in bnxt_poll_p5()
3300 u32 raw_cons = cpr->cp_raw_cons; in bnxt_poll_p5()
3301 struct bnxt *bp = bnapi->bp; in bnxt_poll_p5()
3306 if (unlikely(test_bit(BNXT_STATE_FW_FATAL_COND, &bp->state))) { in bnxt_poll_p5()
3310 if (cpr->has_more_work) { in bnxt_poll_p5()
3311 cpr->has_more_work = 0; in bnxt_poll_p5()
3314 while (1) { in bnxt_poll_p5()
3318 nqcmp = &cpr->nq_desc_ring[CP_RING(cons)][CP_IDX(cons)]; in bnxt_poll_p5()
3321 if (cpr->has_more_work) in bnxt_poll_p5()
3326 cpr->cp_raw_cons = raw_cons; in bnxt_poll_p5()
3328 BNXT_DB_NQ_ARM_P5(&cpr->cp_db, in bnxt_poll_p5()
3329 cpr->cp_raw_cons); in bnxt_poll_p5()
3338 type = le16_to_cpu(nqcmp->type); in bnxt_poll_p5()
3340 u32 idx = le32_to_cpu(nqcmp->cq_handle_low); in bnxt_poll_p5()
3350 cpr2 = &cpr->cp_ring_arr[idx]; in bnxt_poll_p5()
3351 cpr2->had_nqe_notify = 1; in bnxt_poll_p5()
3352 cpr2->toggle = NQE_CN_TOGGLE(type); in bnxt_poll_p5()
3354 budget - work_done); in bnxt_poll_p5()
3355 cpr->has_more_work |= cpr2->has_more_work; in bnxt_poll_p5()
3362 if (raw_cons != cpr->cp_raw_cons) { in bnxt_poll_p5()
3363 cpr->cp_raw_cons = raw_cons; in bnxt_poll_p5()
3364 BNXT_DB_NQ_P5(&cpr->cp_db, raw_cons); in bnxt_poll_p5()
3367 cpr_rx = &cpr->cp_ring_arr[0]; in bnxt_poll_p5()
3368 if (cpr_rx->cp_ring_type == BNXT_NQ_HDL_TYPE_RX && in bnxt_poll_p5()
3369 (bp->flags & BNXT_FLAG_DIM) && bnxt_vnic_is_active(bp)) { in bnxt_poll_p5()
3372 dim_update_sample(cpr->event_ctr, in bnxt_poll_p5()
3373 cpr_rx->rx_packets, in bnxt_poll_p5()
3374 cpr_rx->rx_bytes, in bnxt_poll_p5()
3376 net_dim(&cpr->dim, &dim_sample); in bnxt_poll_p5()
3385 struct pci_dev *pdev = bp->pdev; in bnxt_free_one_tx_ring_skbs()
3387 max_idx = bp->tx_nr_pages * TX_DESC_CNT; in bnxt_free_one_tx_ring_skbs()
3390 struct bnxt_sw_tx_bd *tx_buf = &txr->tx_buf_ring[i]; in bnxt_free_one_tx_ring_skbs()
3394 if (idx < bp->tx_nr_rings_xdp && in bnxt_free_one_tx_ring_skbs()
3395 tx_buf->action == XDP_REDIRECT) { in bnxt_free_one_tx_ring_skbs()
3396 dma_unmap_single(&pdev->dev, in bnxt_free_one_tx_ring_skbs()
3400 xdp_return_frame(tx_buf->xdpf); in bnxt_free_one_tx_ring_skbs()
3401 tx_buf->action = 0; in bnxt_free_one_tx_ring_skbs()
3402 tx_buf->xdpf = NULL; in bnxt_free_one_tx_ring_skbs()
3407 skb = tx_buf->skb; in bnxt_free_one_tx_ring_skbs()
3413 tx_buf->skb = NULL; in bnxt_free_one_tx_ring_skbs()
3415 if (tx_buf->is_push) { in bnxt_free_one_tx_ring_skbs()
3421 dma_unmap_single(&pdev->dev, in bnxt_free_one_tx_ring_skbs()
3426 last = tx_buf->nr_frags; in bnxt_free_one_tx_ring_skbs()
3429 int ring_idx = i & bp->tx_ring_mask; in bnxt_free_one_tx_ring_skbs()
3430 skb_frag_t *frag = &skb_shinfo(skb)->frags[j]; in bnxt_free_one_tx_ring_skbs()
3432 tx_buf = &txr->tx_buf_ring[ring_idx]; in bnxt_free_one_tx_ring_skbs()
3433 netmem_dma_unmap_page_attrs(&pdev->dev, in bnxt_free_one_tx_ring_skbs()
3441 netdev_tx_reset_queue(netdev_get_tx_queue(bp->dev, idx)); in bnxt_free_one_tx_ring_skbs()
3448 if (!bp->tx_ring) in bnxt_free_tx_skbs()
3451 for (i = 0; i < bp->tx_nr_rings; i++) { in bnxt_free_tx_skbs()
3452 struct bnxt_tx_ring_info *txr = &bp->tx_ring[i]; in bnxt_free_tx_skbs()
3454 if (!txr->tx_buf_ring) in bnxt_free_tx_skbs()
3460 if (bp->ptp_cfg && !(bp->fw_cap & BNXT_FW_CAP_TX_TS_CMP)) in bnxt_free_tx_skbs()
3461 bnxt_ptp_free_txts_skbs(bp->ptp_cfg); in bnxt_free_tx_skbs()
3468 max_idx = bp->rx_nr_pages * RX_DESC_CNT; in bnxt_free_one_rx_ring()
3471 struct bnxt_sw_rx_bd *rx_buf = &rxr->rx_buf_ring[i]; in bnxt_free_one_rx_ring()
3472 void *data = rx_buf->data; in bnxt_free_one_rx_ring()
3477 rx_buf->data = NULL; in bnxt_free_one_rx_ring()
3479 page_pool_recycle_direct(rxr->page_pool, data); in bnxt_free_one_rx_ring()
3481 page_pool_free_va(rxr->head_pool, data, true); in bnxt_free_one_rx_ring()
3489 max_idx = bp->rx_agg_nr_pages * RX_DESC_CNT; in bnxt_free_one_rx_agg_ring()
3492 struct bnxt_sw_rx_agg_bd *rx_agg_buf = &rxr->rx_agg_ring[i]; in bnxt_free_one_rx_agg_ring()
3493 netmem_ref netmem = rx_agg_buf->netmem; in bnxt_free_one_rx_agg_ring()
3498 rx_agg_buf->netmem = 0; in bnxt_free_one_rx_agg_ring()
3499 __clear_bit(i, rxr->rx_agg_bmap); in bnxt_free_one_rx_agg_ring()
3501 page_pool_recycle_direct_netmem(rxr->page_pool, netmem); in bnxt_free_one_rx_agg_ring()
3510 for (i = 0; i < bp->max_tpa; i++) { in bnxt_free_one_tpa_info_data()
3511 struct bnxt_tpa_info *tpa_info = &rxr->rx_tpa[i]; in bnxt_free_one_tpa_info_data()
3512 u8 *data = tpa_info->data; in bnxt_free_one_tpa_info_data()
3517 tpa_info->data = NULL; in bnxt_free_one_tpa_info_data()
3518 page_pool_free_va(rxr->head_pool, data, false); in bnxt_free_one_tpa_info_data()
3527 if (!rxr->rx_tpa) in bnxt_free_one_rx_ring_skbs()
3533 if (!rxr->rx_buf_ring) in bnxt_free_one_rx_ring_skbs()
3539 if (!rxr->rx_agg_ring) in bnxt_free_one_rx_ring_skbs()
3545 map = rxr->rx_tpa_idx_map; in bnxt_free_one_rx_ring_skbs()
3547 memset(map->agg_idx_bmap, 0, sizeof(map->agg_idx_bmap)); in bnxt_free_one_rx_ring_skbs()
3554 if (!bp->rx_ring) in bnxt_free_rx_skbs()
3557 for (i = 0; i < bp->rx_nr_rings; i++) in bnxt_free_rx_skbs()
3558 bnxt_free_one_rx_ring_skbs(bp, &bp->rx_ring[i]); in bnxt_free_rx_skbs()
3569 u8 init_val = ctxm->init_value; in bnxt_init_ctx_mem()
3570 u16 offset = ctxm->init_offset; in bnxt_init_ctx_mem()
3580 for (i = 0; i < len; i += ctxm->entry_size) in bnxt_init_ctx_mem()
3591 head_page = head / rmem->page_size; in __bnxt_copy_ring()
3592 source_offset = head % rmem->page_size; in __bnxt_copy_ring()
3593 total_len = (tail - head) & MAX_CTX_BYTES_MASK; in __bnxt_copy_ring()
3597 max_bytes = (rmem->nr_pages - start_idx) * rmem->page_size - in __bnxt_copy_ring()
3603 len = min((size_t)(rmem->page_size - source_offset), rem_len); in __bnxt_copy_ring()
3605 memcpy(buf + offset, rmem->pg_arr[i] + source_offset, in __bnxt_copy_ring()
3608 rem_len -= len; in __bnxt_copy_ring()
3615 struct pci_dev *pdev = bp->pdev; in bnxt_free_ring()
3618 if (!rmem->pg_arr) in bnxt_free_ring()
3621 for (i = 0; i < rmem->nr_pages; i++) { in bnxt_free_ring()
3622 if (!rmem->pg_arr[i]) in bnxt_free_ring()
3625 dma_free_coherent(&pdev->dev, rmem->page_size, in bnxt_free_ring()
3626 rmem->pg_arr[i], rmem->dma_arr[i]); in bnxt_free_ring()
3628 rmem->pg_arr[i] = NULL; in bnxt_free_ring()
3631 if (rmem->pg_tbl) { in bnxt_free_ring()
3632 size_t pg_tbl_size = rmem->nr_pages * 8; in bnxt_free_ring()
3634 if (rmem->flags & BNXT_RMEM_USE_FULL_PAGE_FLAG) in bnxt_free_ring()
3635 pg_tbl_size = rmem->page_size; in bnxt_free_ring()
3636 dma_free_coherent(&pdev->dev, pg_tbl_size, in bnxt_free_ring()
3637 rmem->pg_tbl, rmem->pg_tbl_map); in bnxt_free_ring()
3638 rmem->pg_tbl = NULL; in bnxt_free_ring()
3640 if (rmem->vmem_size && *rmem->vmem) { in bnxt_free_ring()
3641 vfree(*rmem->vmem); in bnxt_free_ring()
3642 *rmem->vmem = NULL; in bnxt_free_ring()
3648 struct pci_dev *pdev = bp->pdev; in bnxt_alloc_ring()
3652 if (rmem->flags & (BNXT_RMEM_VALID_PTE_FLAG | BNXT_RMEM_RING_PTE_FLAG)) in bnxt_alloc_ring()
3654 if ((rmem->nr_pages > 1 || rmem->depth > 0) && !rmem->pg_tbl) { in bnxt_alloc_ring()
3655 size_t pg_tbl_size = rmem->nr_pages * 8; in bnxt_alloc_ring()
3657 if (rmem->flags & BNXT_RMEM_USE_FULL_PAGE_FLAG) in bnxt_alloc_ring()
3658 pg_tbl_size = rmem->page_size; in bnxt_alloc_ring()
3659 rmem->pg_tbl = dma_alloc_coherent(&pdev->dev, pg_tbl_size, in bnxt_alloc_ring()
3660 &rmem->pg_tbl_map, in bnxt_alloc_ring()
3662 if (!rmem->pg_tbl) in bnxt_alloc_ring()
3663 return -ENOMEM; in bnxt_alloc_ring()
3666 for (i = 0; i < rmem->nr_pages; i++) { in bnxt_alloc_ring()
3669 rmem->pg_arr[i] = dma_alloc_coherent(&pdev->dev, in bnxt_alloc_ring()
3670 rmem->page_size, in bnxt_alloc_ring()
3671 &rmem->dma_arr[i], in bnxt_alloc_ring()
3673 if (!rmem->pg_arr[i]) in bnxt_alloc_ring()
3674 return -ENOMEM; in bnxt_alloc_ring()
3676 if (rmem->ctx_mem) in bnxt_alloc_ring()
3677 bnxt_init_ctx_mem(rmem->ctx_mem, rmem->pg_arr[i], in bnxt_alloc_ring()
3678 rmem->page_size); in bnxt_alloc_ring()
3679 if (rmem->nr_pages > 1 || rmem->depth > 0) { in bnxt_alloc_ring()
3680 if (i == rmem->nr_pages - 2 && in bnxt_alloc_ring()
3681 (rmem->flags & BNXT_RMEM_RING_PTE_FLAG)) in bnxt_alloc_ring()
3683 else if (i == rmem->nr_pages - 1 && in bnxt_alloc_ring()
3684 (rmem->flags & BNXT_RMEM_RING_PTE_FLAG)) in bnxt_alloc_ring()
3686 rmem->pg_tbl[i] = in bnxt_alloc_ring()
3687 cpu_to_le64(rmem->dma_arr[i] | extra_bits); in bnxt_alloc_ring()
3691 if (rmem->vmem_size) { in bnxt_alloc_ring()
3692 *rmem->vmem = vzalloc(rmem->vmem_size); in bnxt_alloc_ring()
3693 if (!(*rmem->vmem)) in bnxt_alloc_ring()
3694 return -ENOMEM; in bnxt_alloc_ring()
3704 kfree(rxr->rx_tpa_idx_map); in bnxt_free_one_tpa_info()
3705 rxr->rx_tpa_idx_map = NULL; in bnxt_free_one_tpa_info()
3706 if (rxr->rx_tpa) { in bnxt_free_one_tpa_info()
3707 for (i = 0; i < bp->max_tpa; i++) { in bnxt_free_one_tpa_info()
3708 kfree(rxr->rx_tpa[i].agg_arr); in bnxt_free_one_tpa_info()
3709 rxr->rx_tpa[i].agg_arr = NULL; in bnxt_free_one_tpa_info()
3712 kfree(rxr->rx_tpa); in bnxt_free_one_tpa_info()
3713 rxr->rx_tpa = NULL; in bnxt_free_one_tpa_info()
3720 for (i = 0; i < bp->rx_nr_rings; i++) { in bnxt_free_tpa_info()
3721 struct bnxt_rx_ring_info *rxr = &bp->rx_ring[i]; in bnxt_free_tpa_info()
3733 rxr->rx_tpa = kcalloc(bp->max_tpa, sizeof(struct bnxt_tpa_info), in bnxt_alloc_one_tpa_info()
3735 if (!rxr->rx_tpa) in bnxt_alloc_one_tpa_info()
3736 return -ENOMEM; in bnxt_alloc_one_tpa_info()
3738 if (!(bp->flags & BNXT_FLAG_CHIP_P5_PLUS)) in bnxt_alloc_one_tpa_info()
3740 for (i = 0; i < bp->max_tpa; i++) { in bnxt_alloc_one_tpa_info()
3743 return -ENOMEM; in bnxt_alloc_one_tpa_info()
3744 rxr->rx_tpa[i].agg_arr = agg; in bnxt_alloc_one_tpa_info()
3746 rxr->rx_tpa_idx_map = kzalloc(sizeof(*rxr->rx_tpa_idx_map), in bnxt_alloc_one_tpa_info()
3748 if (!rxr->rx_tpa_idx_map) in bnxt_alloc_one_tpa_info()
3749 return -ENOMEM; in bnxt_alloc_one_tpa_info()
3758 bp->max_tpa = MAX_TPA; in bnxt_alloc_tpa_info()
3759 if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) { in bnxt_alloc_tpa_info()
3760 if (!bp->max_tpa_v2) in bnxt_alloc_tpa_info()
3762 bp->max_tpa = max_t(u16, bp->max_tpa_v2, MAX_TPA_P5); in bnxt_alloc_tpa_info()
3765 for (i = 0; i < bp->rx_nr_rings; i++) { in bnxt_alloc_tpa_info()
3766 struct bnxt_rx_ring_info *rxr = &bp->rx_ring[i]; in bnxt_alloc_tpa_info()
3779 if (!bp->rx_ring) in bnxt_free_rx_rings()
3783 for (i = 0; i < bp->rx_nr_rings; i++) { in bnxt_free_rx_rings()
3784 struct bnxt_rx_ring_info *rxr = &bp->rx_ring[i]; in bnxt_free_rx_rings()
3787 if (rxr->xdp_prog) in bnxt_free_rx_rings()
3788 bpf_prog_put(rxr->xdp_prog); in bnxt_free_rx_rings()
3790 if (xdp_rxq_info_is_reg(&rxr->xdp_rxq)) in bnxt_free_rx_rings()
3791 xdp_rxq_info_unreg(&rxr->xdp_rxq); in bnxt_free_rx_rings()
3793 page_pool_destroy(rxr->page_pool); in bnxt_free_rx_rings()
3795 page_pool_destroy(rxr->head_pool); in bnxt_free_rx_rings()
3796 rxr->page_pool = rxr->head_pool = NULL; in bnxt_free_rx_rings()
3798 kfree(rxr->rx_agg_bmap); in bnxt_free_rx_rings()
3799 rxr->rx_agg_bmap = NULL; in bnxt_free_rx_rings()
3801 ring = &rxr->rx_ring_struct; in bnxt_free_rx_rings()
3802 bnxt_free_ring(bp, &ring->ring_mem); in bnxt_free_rx_rings()
3804 ring = &rxr->rx_agg_ring_struct; in bnxt_free_rx_rings()
3805 bnxt_free_ring(bp, &ring->ring_mem); in bnxt_free_rx_rings()
3818 pp.pool_size = bp->rx_agg_ring_size / agg_size_fac; in bnxt_alloc_rx_page_pool()
3820 pp.pool_size += bp->rx_ring_size / rx_size_fac; in bnxt_alloc_rx_page_pool()
3822 pp.napi = &rxr->bnapi->napi; in bnxt_alloc_rx_page_pool()
3823 pp.netdev = bp->dev; in bnxt_alloc_rx_page_pool()
3824 pp.dev = &bp->pdev->dev; in bnxt_alloc_rx_page_pool()
3825 pp.dma_dir = bp->rx_dir; in bnxt_alloc_rx_page_pool()
3829 pp.queue_idx = rxr->bnapi->index; in bnxt_alloc_rx_page_pool()
3834 rxr->page_pool = pool; in bnxt_alloc_rx_page_pool()
3836 rxr->need_head_pool = page_pool_is_unreadable(pool); in bnxt_alloc_rx_page_pool()
3838 pp.pool_size = min(bp->rx_ring_size / rx_size_fac, 1024); in bnxt_alloc_rx_page_pool()
3844 rxr->head_pool = pool; in bnxt_alloc_rx_page_pool()
3849 page_pool_destroy(rxr->page_pool); in bnxt_alloc_rx_page_pool()
3850 rxr->page_pool = NULL; in bnxt_alloc_rx_page_pool()
3858 rxr->rx_agg_bmap_size = bp->rx_agg_ring_mask + 1; in bnxt_alloc_rx_agg_bmap()
3859 mem_size = rxr->rx_agg_bmap_size / 8; in bnxt_alloc_rx_agg_bmap()
3860 rxr->rx_agg_bmap = kzalloc(mem_size, GFP_KERNEL); in bnxt_alloc_rx_agg_bmap()
3861 if (!rxr->rx_agg_bmap) in bnxt_alloc_rx_agg_bmap()
3862 return -ENOMEM; in bnxt_alloc_rx_agg_bmap()
3869 int numa_node = dev_to_node(&bp->pdev->dev); in bnxt_alloc_rx_rings()
3872 if (!bp->rx_ring) in bnxt_alloc_rx_rings()
3873 return -ENOMEM; in bnxt_alloc_rx_rings()
3875 if (bp->flags & BNXT_FLAG_AGG_RINGS) in bnxt_alloc_rx_rings()
3876 agg_rings = 1; in bnxt_alloc_rx_rings()
3878 for (i = 0; i < bp->rx_nr_rings; i++) { in bnxt_alloc_rx_rings()
3879 struct bnxt_rx_ring_info *rxr = &bp->rx_ring[i]; in bnxt_alloc_rx_rings()
3883 ring = &rxr->rx_ring_struct; in bnxt_alloc_rx_rings()
3887 netdev_dbg(bp->dev, "Allocating page pool for rx_ring[%d] on numa_node: %d\n", in bnxt_alloc_rx_rings()
3893 rc = xdp_rxq_info_reg(&rxr->xdp_rxq, bp->dev, i, 0); in bnxt_alloc_rx_rings()
3897 rc = xdp_rxq_info_reg_mem_model(&rxr->xdp_rxq, in bnxt_alloc_rx_rings()
3899 rxr->page_pool); in bnxt_alloc_rx_rings()
3901 xdp_rxq_info_unreg(&rxr->xdp_rxq); in bnxt_alloc_rx_rings()
3905 rc = bnxt_alloc_ring(bp, &ring->ring_mem); in bnxt_alloc_rx_rings()
3909 ring->grp_idx = i; in bnxt_alloc_rx_rings()
3911 ring = &rxr->rx_agg_ring_struct; in bnxt_alloc_rx_rings()
3912 rc = bnxt_alloc_ring(bp, &ring->ring_mem); in bnxt_alloc_rx_rings()
3916 ring->grp_idx = i; in bnxt_alloc_rx_rings()
3922 if (bp->flags & BNXT_FLAG_TPA) in bnxt_alloc_rx_rings()
3930 struct pci_dev *pdev = bp->pdev; in bnxt_free_tx_rings()
3932 if (!bp->tx_ring) in bnxt_free_tx_rings()
3935 for (i = 0; i < bp->tx_nr_rings; i++) { in bnxt_free_tx_rings()
3936 struct bnxt_tx_ring_info *txr = &bp->tx_ring[i]; in bnxt_free_tx_rings()
3939 if (txr->tx_push) { in bnxt_free_tx_rings()
3940 dma_free_coherent(&pdev->dev, bp->tx_push_size, in bnxt_free_tx_rings()
3941 txr->tx_push, txr->tx_push_mapping); in bnxt_free_tx_rings()
3942 txr->tx_push = NULL; in bnxt_free_tx_rings()
3945 ring = &txr->tx_ring_struct; in bnxt_free_tx_rings()
3947 bnxt_free_ring(bp, &ring->ring_mem); in bnxt_free_tx_rings()
3952 ((tc) * (bp)->tx_nr_rings_per_tc)
3955 ((tx) % (bp)->tx_nr_rings_per_tc)
3958 ((tx) / (bp)->tx_nr_rings_per_tc)
3963 struct pci_dev *pdev = bp->pdev; in bnxt_alloc_tx_rings()
3965 bp->tx_push_size = 0; in bnxt_alloc_tx_rings()
3966 if (bp->tx_push_thresh) { in bnxt_alloc_tx_rings()
3970 bp->tx_push_thresh); in bnxt_alloc_tx_rings()
3974 bp->tx_push_thresh = 0; in bnxt_alloc_tx_rings()
3977 bp->tx_push_size = push_size; in bnxt_alloc_tx_rings()
3980 for (i = 0, j = 0; i < bp->tx_nr_rings; i++) { in bnxt_alloc_tx_rings()
3981 struct bnxt_tx_ring_info *txr = &bp->tx_ring[i]; in bnxt_alloc_tx_rings()
3985 ring = &txr->tx_ring_struct; in bnxt_alloc_tx_rings()
3987 rc = bnxt_alloc_ring(bp, &ring->ring_mem); in bnxt_alloc_tx_rings()
3991 ring->grp_idx = txr->bnapi->index; in bnxt_alloc_tx_rings()
3992 if (bp->tx_push_size) { in bnxt_alloc_tx_rings()
3995 /* One pre-allocated DMA buffer to backup in bnxt_alloc_tx_rings()
3998 txr->tx_push = dma_alloc_coherent(&pdev->dev, in bnxt_alloc_tx_rings()
3999 bp->tx_push_size, in bnxt_alloc_tx_rings()
4000 &txr->tx_push_mapping, in bnxt_alloc_tx_rings()
4003 if (!txr->tx_push) in bnxt_alloc_tx_rings()
4004 return -ENOMEM; in bnxt_alloc_tx_rings()
4006 mapping = txr->tx_push_mapping + in bnxt_alloc_tx_rings()
4008 txr->data_mapping = cpu_to_le64(mapping); in bnxt_alloc_tx_rings()
4010 qidx = bp->tc_to_qidx[j]; in bnxt_alloc_tx_rings()
4011 ring->queue_id = bp->q_info[qidx].queue_id; in bnxt_alloc_tx_rings()
4012 spin_lock_init(&txr->xdp_tx_lock); in bnxt_alloc_tx_rings()
4013 if (i < bp->tx_nr_rings_xdp) in bnxt_alloc_tx_rings()
4015 if (BNXT_RING_TO_TC_OFF(bp, i) == (bp->tx_nr_rings_per_tc - 1)) in bnxt_alloc_tx_rings()
4023 struct bnxt_ring_struct *ring = &cpr->cp_ring_struct; in bnxt_free_cp_arrays()
4025 kfree(cpr->cp_desc_ring); in bnxt_free_cp_arrays()
4026 cpr->cp_desc_ring = NULL; in bnxt_free_cp_arrays()
4027 ring->ring_mem.pg_arr = NULL; in bnxt_free_cp_arrays()
4028 kfree(cpr->cp_desc_mapping); in bnxt_free_cp_arrays()
4029 cpr->cp_desc_mapping = NULL; in bnxt_free_cp_arrays()
4030 ring->ring_mem.dma_arr = NULL; in bnxt_free_cp_arrays()
4035 cpr->cp_desc_ring = kcalloc(n, sizeof(*cpr->cp_desc_ring), GFP_KERNEL); in bnxt_alloc_cp_arrays()
4036 if (!cpr->cp_desc_ring) in bnxt_alloc_cp_arrays()
4037 return -ENOMEM; in bnxt_alloc_cp_arrays()
4038 cpr->cp_desc_mapping = kcalloc(n, sizeof(*cpr->cp_desc_mapping), in bnxt_alloc_cp_arrays()
4040 if (!cpr->cp_desc_mapping) in bnxt_alloc_cp_arrays()
4041 return -ENOMEM; in bnxt_alloc_cp_arrays()
4049 if (!bp->bnapi) in bnxt_free_all_cp_arrays()
4051 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_free_all_cp_arrays()
4052 struct bnxt_napi *bnapi = bp->bnapi[i]; in bnxt_free_all_cp_arrays()
4056 bnxt_free_cp_arrays(&bnapi->cp_ring); in bnxt_free_all_cp_arrays()
4062 int i, n = bp->cp_nr_pages; in bnxt_alloc_all_cp_arrays()
4064 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_alloc_all_cp_arrays()
4065 struct bnxt_napi *bnapi = bp->bnapi[i]; in bnxt_alloc_all_cp_arrays()
4070 rc = bnxt_alloc_cp_arrays(&bnapi->cp_ring, n); in bnxt_alloc_all_cp_arrays()
4081 if (!bp->bnapi) in bnxt_free_cp_rings()
4084 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_free_cp_rings()
4085 struct bnxt_napi *bnapi = bp->bnapi[i]; in bnxt_free_cp_rings()
4093 cpr = &bnapi->cp_ring; in bnxt_free_cp_rings()
4094 ring = &cpr->cp_ring_struct; in bnxt_free_cp_rings()
4096 bnxt_free_ring(bp, &ring->ring_mem); in bnxt_free_cp_rings()
4098 if (!cpr->cp_ring_arr) in bnxt_free_cp_rings()
4101 for (j = 0; j < cpr->cp_ring_count; j++) { in bnxt_free_cp_rings()
4102 struct bnxt_cp_ring_info *cpr2 = &cpr->cp_ring_arr[j]; in bnxt_free_cp_rings()
4104 ring = &cpr2->cp_ring_struct; in bnxt_free_cp_rings()
4105 bnxt_free_ring(bp, &ring->ring_mem); in bnxt_free_cp_rings()
4108 kfree(cpr->cp_ring_arr); in bnxt_free_cp_rings()
4109 cpr->cp_ring_arr = NULL; in bnxt_free_cp_rings()
4110 cpr->cp_ring_count = 0; in bnxt_free_cp_rings()
4121 rc = bnxt_alloc_cp_arrays(cpr, bp->cp_nr_pages); in bnxt_alloc_cp_sub_ring()
4124 return -ENOMEM; in bnxt_alloc_cp_sub_ring()
4126 ring = &cpr->cp_ring_struct; in bnxt_alloc_cp_sub_ring()
4127 rmem = &ring->ring_mem; in bnxt_alloc_cp_sub_ring()
4128 rmem->nr_pages = bp->cp_nr_pages; in bnxt_alloc_cp_sub_ring()
4129 rmem->page_size = HW_CMPD_RING_SIZE; in bnxt_alloc_cp_sub_ring()
4130 rmem->pg_arr = (void **)cpr->cp_desc_ring; in bnxt_alloc_cp_sub_ring()
4131 rmem->dma_arr = cpr->cp_desc_mapping; in bnxt_alloc_cp_sub_ring()
4132 rmem->flags = BNXT_RMEM_RING_PTE_FLAG; in bnxt_alloc_cp_sub_ring()
4143 bool sh = !!(bp->flags & BNXT_FLAG_SHARED_RINGS); in bnxt_alloc_cp_rings()
4145 int tcs = bp->num_tc; in bnxt_alloc_cp_rings()
4148 tcs = 1; in bnxt_alloc_cp_rings()
4150 for (i = 0, j = 0; i < bp->cp_nr_rings; i++) { in bnxt_alloc_cp_rings()
4151 struct bnxt_napi *bnapi = bp->bnapi[i]; in bnxt_alloc_cp_rings()
4160 cpr = &bnapi->cp_ring; in bnxt_alloc_cp_rings()
4161 cpr->bnapi = bnapi; in bnxt_alloc_cp_rings()
4162 ring = &cpr->cp_ring_struct; in bnxt_alloc_cp_rings()
4164 rc = bnxt_alloc_ring(bp, &ring->ring_mem); in bnxt_alloc_cp_rings()
4168 ring->map_idx = ulp_msix + i; in bnxt_alloc_cp_rings()
4170 if (!(bp->flags & BNXT_FLAG_CHIP_P5_PLUS)) in bnxt_alloc_cp_rings()
4173 if (i < bp->rx_nr_rings) { in bnxt_alloc_cp_rings()
4175 rx = 1; in bnxt_alloc_cp_rings()
4177 if (i < bp->tx_nr_rings_xdp) { in bnxt_alloc_cp_rings()
4179 tx = 1; in bnxt_alloc_cp_rings()
4180 } else if ((sh && i < bp->tx_nr_rings) || in bnxt_alloc_cp_rings()
4181 (!sh && i >= bp->rx_nr_rings)) { in bnxt_alloc_cp_rings()
4183 tx = 1; in bnxt_alloc_cp_rings()
4186 cpr->cp_ring_arr = kcalloc(cp_count, sizeof(*cpr), in bnxt_alloc_cp_rings()
4188 if (!cpr->cp_ring_arr) in bnxt_alloc_cp_rings()
4189 return -ENOMEM; in bnxt_alloc_cp_rings()
4190 cpr->cp_ring_count = cp_count; in bnxt_alloc_cp_rings()
4193 cpr2 = &cpr->cp_ring_arr[k]; in bnxt_alloc_cp_rings()
4197 cpr2->bnapi = bnapi; in bnxt_alloc_cp_rings()
4198 cpr2->sw_stats = cpr->sw_stats; in bnxt_alloc_cp_rings()
4199 cpr2->cp_idx = k; in bnxt_alloc_cp_rings()
4201 bp->rx_ring[i].rx_cpr = cpr2; in bnxt_alloc_cp_rings()
4202 cpr2->cp_ring_type = BNXT_NQ_HDL_TYPE_RX; in bnxt_alloc_cp_rings()
4204 int n, tc = k - rx; in bnxt_alloc_cp_rings()
4207 bp->tx_ring[n].tx_cpr = cpr2; in bnxt_alloc_cp_rings()
4208 cpr2->cp_ring_type = BNXT_NQ_HDL_TYPE_TX; in bnxt_alloc_cp_rings()
4223 ring = &rxr->rx_ring_struct; in bnxt_init_rx_ring_struct()
4224 rmem = &ring->ring_mem; in bnxt_init_rx_ring_struct()
4225 rmem->nr_pages = bp->rx_nr_pages; in bnxt_init_rx_ring_struct()
4226 rmem->page_size = HW_RXBD_RING_SIZE; in bnxt_init_rx_ring_struct()
4227 rmem->pg_arr = (void **)rxr->rx_desc_ring; in bnxt_init_rx_ring_struct()
4228 rmem->dma_arr = rxr->rx_desc_mapping; in bnxt_init_rx_ring_struct()
4229 rmem->vmem_size = SW_RXBD_RING_SIZE * bp->rx_nr_pages; in bnxt_init_rx_ring_struct()
4230 rmem->vmem = (void **)&rxr->rx_buf_ring; in bnxt_init_rx_ring_struct()
4232 ring = &rxr->rx_agg_ring_struct; in bnxt_init_rx_ring_struct()
4233 rmem = &ring->ring_mem; in bnxt_init_rx_ring_struct()
4234 rmem->nr_pages = bp->rx_agg_nr_pages; in bnxt_init_rx_ring_struct()
4235 rmem->page_size = HW_RXBD_RING_SIZE; in bnxt_init_rx_ring_struct()
4236 rmem->pg_arr = (void **)rxr->rx_agg_desc_ring; in bnxt_init_rx_ring_struct()
4237 rmem->dma_arr = rxr->rx_agg_desc_mapping; in bnxt_init_rx_ring_struct()
4238 rmem->vmem_size = SW_RXBD_AGG_RING_SIZE * bp->rx_agg_nr_pages; in bnxt_init_rx_ring_struct()
4239 rmem->vmem = (void **)&rxr->rx_agg_ring; in bnxt_init_rx_ring_struct()
4249 rxr->page_pool->p.napi = NULL; in bnxt_reset_rx_ring_struct()
4250 rxr->page_pool = NULL; in bnxt_reset_rx_ring_struct()
4251 rxr->head_pool->p.napi = NULL; in bnxt_reset_rx_ring_struct()
4252 rxr->head_pool = NULL; in bnxt_reset_rx_ring_struct()
4253 memset(&rxr->xdp_rxq, 0, sizeof(struct xdp_rxq_info)); in bnxt_reset_rx_ring_struct()
4255 ring = &rxr->rx_ring_struct; in bnxt_reset_rx_ring_struct()
4256 rmem = &ring->ring_mem; in bnxt_reset_rx_ring_struct()
4257 rmem->pg_tbl = NULL; in bnxt_reset_rx_ring_struct()
4258 rmem->pg_tbl_map = 0; in bnxt_reset_rx_ring_struct()
4259 for (i = 0; i < rmem->nr_pages; i++) { in bnxt_reset_rx_ring_struct()
4260 rmem->pg_arr[i] = NULL; in bnxt_reset_rx_ring_struct()
4261 rmem->dma_arr[i] = 0; in bnxt_reset_rx_ring_struct()
4263 *rmem->vmem = NULL; in bnxt_reset_rx_ring_struct()
4265 ring = &rxr->rx_agg_ring_struct; in bnxt_reset_rx_ring_struct()
4266 rmem = &ring->ring_mem; in bnxt_reset_rx_ring_struct()
4267 rmem->pg_tbl = NULL; in bnxt_reset_rx_ring_struct()
4268 rmem->pg_tbl_map = 0; in bnxt_reset_rx_ring_struct()
4269 for (i = 0; i < rmem->nr_pages; i++) { in bnxt_reset_rx_ring_struct()
4270 rmem->pg_arr[i] = NULL; in bnxt_reset_rx_ring_struct()
4271 rmem->dma_arr[i] = 0; in bnxt_reset_rx_ring_struct()
4273 *rmem->vmem = NULL; in bnxt_reset_rx_ring_struct()
4280 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_init_ring_struct()
4281 struct bnxt_napi *bnapi = bp->bnapi[i]; in bnxt_init_ring_struct()
4291 cpr = &bnapi->cp_ring; in bnxt_init_ring_struct()
4292 ring = &cpr->cp_ring_struct; in bnxt_init_ring_struct()
4293 rmem = &ring->ring_mem; in bnxt_init_ring_struct()
4294 rmem->nr_pages = bp->cp_nr_pages; in bnxt_init_ring_struct()
4295 rmem->page_size = HW_CMPD_RING_SIZE; in bnxt_init_ring_struct()
4296 rmem->pg_arr = (void **)cpr->cp_desc_ring; in bnxt_init_ring_struct()
4297 rmem->dma_arr = cpr->cp_desc_mapping; in bnxt_init_ring_struct()
4298 rmem->vmem_size = 0; in bnxt_init_ring_struct()
4300 rxr = bnapi->rx_ring; in bnxt_init_ring_struct()
4304 ring = &rxr->rx_ring_struct; in bnxt_init_ring_struct()
4305 rmem = &ring->ring_mem; in bnxt_init_ring_struct()
4306 rmem->nr_pages = bp->rx_nr_pages; in bnxt_init_ring_struct()
4307 rmem->page_size = HW_RXBD_RING_SIZE; in bnxt_init_ring_struct()
4308 rmem->pg_arr = (void **)rxr->rx_desc_ring; in bnxt_init_ring_struct()
4309 rmem->dma_arr = rxr->rx_desc_mapping; in bnxt_init_ring_struct()
4310 rmem->vmem_size = SW_RXBD_RING_SIZE * bp->rx_nr_pages; in bnxt_init_ring_struct()
4311 rmem->vmem = (void **)&rxr->rx_buf_ring; in bnxt_init_ring_struct()
4313 ring = &rxr->rx_agg_ring_struct; in bnxt_init_ring_struct()
4314 rmem = &ring->ring_mem; in bnxt_init_ring_struct()
4315 rmem->nr_pages = bp->rx_agg_nr_pages; in bnxt_init_ring_struct()
4316 rmem->page_size = HW_RXBD_RING_SIZE; in bnxt_init_ring_struct()
4317 rmem->pg_arr = (void **)rxr->rx_agg_desc_ring; in bnxt_init_ring_struct()
4318 rmem->dma_arr = rxr->rx_agg_desc_mapping; in bnxt_init_ring_struct()
4319 rmem->vmem_size = SW_RXBD_AGG_RING_SIZE * bp->rx_agg_nr_pages; in bnxt_init_ring_struct()
4320 rmem->vmem = (void **)&rxr->rx_agg_ring; in bnxt_init_ring_struct()
4324 ring = &txr->tx_ring_struct; in bnxt_init_ring_struct()
4325 rmem = &ring->ring_mem; in bnxt_init_ring_struct()
4326 rmem->nr_pages = bp->tx_nr_pages; in bnxt_init_ring_struct()
4327 rmem->page_size = HW_TXBD_RING_SIZE; in bnxt_init_ring_struct()
4328 rmem->pg_arr = (void **)txr->tx_desc_ring; in bnxt_init_ring_struct()
4329 rmem->dma_arr = txr->tx_desc_mapping; in bnxt_init_ring_struct()
4330 rmem->vmem_size = SW_TXBD_RING_SIZE * bp->tx_nr_pages; in bnxt_init_ring_struct()
4331 rmem->vmem = (void **)&txr->tx_buf_ring; in bnxt_init_ring_struct()
4342 rx_buf_ring = (struct rx_bd **)ring->ring_mem.pg_arr; in bnxt_init_rxbd_pages()
4343 for (i = 0, prod = 0; i < ring->ring_mem.nr_pages; i++) { in bnxt_init_rxbd_pages()
4352 rxbd->rx_bd_len_flags_type = cpu_to_le32(type); in bnxt_init_rxbd_pages()
4353 rxbd->rx_bd_opaque = prod; in bnxt_init_rxbd_pages()
4365 prod = rxr->rx_prod; in bnxt_alloc_one_rx_ring_skb()
4366 for (i = 0; i < bp->rx_ring_size; i++) { in bnxt_alloc_one_rx_ring_skb()
4368 netdev_warn(bp->dev, "init'ed rx ring %d with %d/%d skbs only\n", in bnxt_alloc_one_rx_ring_skb()
4369 ring_nr, i, bp->rx_ring_size); in bnxt_alloc_one_rx_ring_skb()
4374 rxr->rx_prod = prod; in bnxt_alloc_one_rx_ring_skb()
4384 prod = rxr->rx_agg_prod; in bnxt_alloc_one_rx_ring_netmem()
4385 for (i = 0; i < bp->rx_agg_ring_size; i++) { in bnxt_alloc_one_rx_ring_netmem()
4387 netdev_warn(bp->dev, "init'ed rx ring %d with %d/%d pages only\n", in bnxt_alloc_one_rx_ring_netmem()
4388 ring_nr, i, bp->rx_ring_size); in bnxt_alloc_one_rx_ring_netmem()
4393 rxr->rx_agg_prod = prod; in bnxt_alloc_one_rx_ring_netmem()
4403 for (i = 0; i < bp->max_tpa; i++) { in bnxt_alloc_one_tpa_info_data()
4407 return -ENOMEM; in bnxt_alloc_one_tpa_info_data()
4409 rxr->rx_tpa[i].data = data; in bnxt_alloc_one_tpa_info_data()
4410 rxr->rx_tpa[i].data_ptr = data + bp->rx_offset; in bnxt_alloc_one_tpa_info_data()
4411 rxr->rx_tpa[i].mapping = mapping; in bnxt_alloc_one_tpa_info_data()
4419 struct bnxt_rx_ring_info *rxr = &bp->rx_ring[ring_nr]; in bnxt_alloc_one_rx_ring()
4424 if (!(bp->flags & BNXT_FLAG_AGG_RINGS)) in bnxt_alloc_one_rx_ring()
4429 if (rxr->rx_tpa) { in bnxt_alloc_one_rx_ring()
4443 type = (bp->rx_buf_use_size << RX_BD_LEN_SHIFT) | in bnxt_init_one_rx_ring_rxbd()
4449 ring = &rxr->rx_ring_struct; in bnxt_init_one_rx_ring_rxbd()
4451 ring->fw_ring_id = INVALID_HW_RING_ID; in bnxt_init_one_rx_ring_rxbd()
4460 ring = &rxr->rx_agg_ring_struct; in bnxt_init_one_rx_agg_ring_rxbd()
4461 ring->fw_ring_id = INVALID_HW_RING_ID; in bnxt_init_one_rx_agg_ring_rxbd()
4462 if ((bp->flags & BNXT_FLAG_AGG_RINGS)) { in bnxt_init_one_rx_agg_ring_rxbd()
4474 rxr = &bp->rx_ring[ring_nr]; in bnxt_init_one_rx_ring()
4477 netif_queue_set_napi(bp->dev, ring_nr, NETDEV_QUEUE_TYPE_RX, in bnxt_init_one_rx_ring()
4478 &rxr->bnapi->napi); in bnxt_init_one_rx_ring()
4480 if (BNXT_RX_PAGE_MODE(bp) && bp->xdp_prog) { in bnxt_init_one_rx_ring()
4481 bpf_prog_add(bp->xdp_prog, 1); in bnxt_init_one_rx_ring()
4482 rxr->xdp_prog = bp->xdp_prog; in bnxt_init_one_rx_ring()
4494 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_init_cp_rings()
4495 struct bnxt_cp_ring_info *cpr = &bp->bnapi[i]->cp_ring; in bnxt_init_cp_rings()
4496 struct bnxt_ring_struct *ring = &cpr->cp_ring_struct; in bnxt_init_cp_rings()
4498 ring->fw_ring_id = INVALID_HW_RING_ID; in bnxt_init_cp_rings()
4499 cpr->rx_ring_coal.coal_ticks = bp->rx_coal.coal_ticks; in bnxt_init_cp_rings()
4500 cpr->rx_ring_coal.coal_bufs = bp->rx_coal.coal_bufs; in bnxt_init_cp_rings()
4501 if (!cpr->cp_ring_arr) in bnxt_init_cp_rings()
4503 for (j = 0; j < cpr->cp_ring_count; j++) { in bnxt_init_cp_rings()
4504 struct bnxt_cp_ring_info *cpr2 = &cpr->cp_ring_arr[j]; in bnxt_init_cp_rings()
4506 ring = &cpr2->cp_ring_struct; in bnxt_init_cp_rings()
4507 ring->fw_ring_id = INVALID_HW_RING_ID; in bnxt_init_cp_rings()
4508 cpr2->rx_ring_coal.coal_ticks = bp->rx_coal.coal_ticks; in bnxt_init_cp_rings()
4509 cpr2->rx_ring_coal.coal_bufs = bp->rx_coal.coal_bufs; in bnxt_init_cp_rings()
4519 bp->rx_offset = NET_IP_ALIGN + XDP_PACKET_HEADROOM; in bnxt_init_rx_rings()
4520 bp->rx_dma_offset = XDP_PACKET_HEADROOM; in bnxt_init_rx_rings()
4522 bp->rx_offset = BNXT_RX_OFFSET; in bnxt_init_rx_rings()
4523 bp->rx_dma_offset = BNXT_RX_DMA_OFFSET; in bnxt_init_rx_rings()
4526 for (i = 0; i < bp->rx_nr_rings; i++) { in bnxt_init_rx_rings()
4539 bp->tx_wake_thresh = max_t(int, bp->tx_ring_size / 2, in bnxt_init_tx_rings()
4542 for (i = 0; i < bp->tx_nr_rings; i++) { in bnxt_init_tx_rings()
4543 struct bnxt_tx_ring_info *txr = &bp->tx_ring[i]; in bnxt_init_tx_rings()
4544 struct bnxt_ring_struct *ring = &txr->tx_ring_struct; in bnxt_init_tx_rings()
4546 ring->fw_ring_id = INVALID_HW_RING_ID; in bnxt_init_tx_rings()
4548 if (i >= bp->tx_nr_rings_xdp) in bnxt_init_tx_rings()
4549 netif_queue_set_napi(bp->dev, i - bp->tx_nr_rings_xdp, in bnxt_init_tx_rings()
4551 &txr->bnapi->napi); in bnxt_init_tx_rings()
4559 kfree(bp->grp_info); in bnxt_free_ring_grps()
4560 bp->grp_info = NULL; in bnxt_free_ring_grps()
4568 bp->grp_info = kcalloc(bp->cp_nr_rings, in bnxt_init_ring_grps()
4571 if (!bp->grp_info) in bnxt_init_ring_grps()
4572 return -ENOMEM; in bnxt_init_ring_grps()
4574 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_init_ring_grps()
4576 bp->grp_info[i].fw_stats_ctx = INVALID_HW_RING_ID; in bnxt_init_ring_grps()
4577 bp->grp_info[i].fw_grp_id = INVALID_HW_RING_ID; in bnxt_init_ring_grps()
4578 bp->grp_info[i].rx_fw_ring_id = INVALID_HW_RING_ID; in bnxt_init_ring_grps()
4579 bp->grp_info[i].agg_fw_ring_id = INVALID_HW_RING_ID; in bnxt_init_ring_grps()
4580 bp->grp_info[i].cp_fw_ring_id = INVALID_HW_RING_ID; in bnxt_init_ring_grps()
4587 kfree(bp->vnic_info); in bnxt_free_vnics()
4588 bp->vnic_info = NULL; in bnxt_free_vnics()
4589 bp->nr_vnics = 0; in bnxt_free_vnics()
4594 int num_vnics = 1; in bnxt_alloc_vnics()
4597 if (bp->flags & BNXT_FLAG_RFS) { in bnxt_alloc_vnics()
4600 else if (!(bp->flags & BNXT_FLAG_CHIP_P5_PLUS)) in bnxt_alloc_vnics()
4601 num_vnics += bp->rx_nr_rings; in bnxt_alloc_vnics()
4608 bp->vnic_info = kcalloc(num_vnics, sizeof(struct bnxt_vnic_info), in bnxt_alloc_vnics()
4610 if (!bp->vnic_info) in bnxt_alloc_vnics()
4611 return -ENOMEM; in bnxt_alloc_vnics()
4613 bp->nr_vnics = num_vnics; in bnxt_alloc_vnics()
4619 struct bnxt_vnic_info *vnic0 = &bp->vnic_info[BNXT_VNIC_DEFAULT]; in bnxt_init_vnics()
4622 for (i = 0; i < bp->nr_vnics; i++) { in bnxt_init_vnics()
4623 struct bnxt_vnic_info *vnic = &bp->vnic_info[i]; in bnxt_init_vnics()
4626 vnic->fw_vnic_id = INVALID_HW_RING_ID; in bnxt_init_vnics()
4627 vnic->vnic_id = i; in bnxt_init_vnics()
4629 vnic->fw_rss_cos_lb_ctx[j] = INVALID_HW_RING_ID; in bnxt_init_vnics()
4631 vnic->fw_l2_ctx_id = INVALID_HW_RING_ID; in bnxt_init_vnics()
4633 if (bp->vnic_info[i].rss_hash_key) { in bnxt_init_vnics()
4635 u8 *key = (void *)vnic->rss_hash_key; in bnxt_init_vnics()
4638 if (!bp->rss_hash_key_valid && in bnxt_init_vnics()
4639 !bp->rss_hash_key_updated) { in bnxt_init_vnics()
4640 get_random_bytes(bp->rss_hash_key, in bnxt_init_vnics()
4642 bp->rss_hash_key_updated = true; in bnxt_init_vnics()
4645 memcpy(vnic->rss_hash_key, bp->rss_hash_key, in bnxt_init_vnics()
4648 if (!bp->rss_hash_key_updated) in bnxt_init_vnics()
4651 bp->rss_hash_key_updated = false; in bnxt_init_vnics()
4652 bp->rss_hash_key_valid = true; in bnxt_init_vnics()
4654 bp->toeplitz_prefix = 0; in bnxt_init_vnics()
4656 bp->toeplitz_prefix <<= 8; in bnxt_init_vnics()
4657 bp->toeplitz_prefix |= key[k]; in bnxt_init_vnics()
4660 memcpy(vnic->rss_hash_key, vnic0->rss_hash_key, in bnxt_init_vnics()
4674 return 1; in bnxt_calc_nr_ring_pages()
4678 while (pages & (pages - 1)) in bnxt_calc_nr_ring_pages()
4686 bp->flags &= ~BNXT_FLAG_TPA; in bnxt_set_tpa_flags()
4687 if (bp->flags & BNXT_FLAG_NO_AGG_RINGS) in bnxt_set_tpa_flags()
4689 if (bp->dev->features & NETIF_F_LRO) in bnxt_set_tpa_flags()
4690 bp->flags |= BNXT_FLAG_LRO; in bnxt_set_tpa_flags()
4691 else if (bp->dev->features & NETIF_F_GRO_HW) in bnxt_set_tpa_flags()
4692 bp->flags |= BNXT_FLAG_GRO; in bnxt_set_tpa_flags()
4699 bp->rx_copybreak = BNXT_DEFAULT_RX_COPYBREAK; in bnxt_init_ring_params()
4701 rx_size = SZ_1K - in bnxt_init_ring_params()
4702 NET_SKB_PAD - SKB_DATA_ALIGN(sizeof(struct skb_shared_info)); in bnxt_init_ring_params()
4703 bp->dev->cfg->hds_thresh = max(BNXT_DEFAULT_RX_COPYBREAK, rx_size); in bnxt_init_ring_params()
4706 /* bp->rx_ring_size, bp->tx_ring_size, dev->mtu, BNXT_FLAG_{G|L}RO flags must
4715 rx_size = SKB_DATA_ALIGN(bp->dev->mtu + ETH_HLEN + NET_IP_ALIGN + 8); in bnxt_set_ring_params()
4720 ring_size = bp->rx_ring_size; in bnxt_set_ring_params()
4721 bp->rx_agg_ring_size = 0; in bnxt_set_ring_params()
4722 bp->rx_agg_nr_pages = 0; in bnxt_set_ring_params()
4724 if (bp->flags & BNXT_FLAG_TPA || bp->flags & BNXT_FLAG_HDS) in bnxt_set_ring_params()
4727 bp->flags &= ~BNXT_FLAG_JUMBO; in bnxt_set_ring_params()
4728 if (rx_space > PAGE_SIZE && !(bp->flags & BNXT_FLAG_NO_AGG_RINGS)) { in bnxt_set_ring_params()
4731 bp->flags |= BNXT_FLAG_JUMBO; in bnxt_set_ring_params()
4732 jumbo_factor = PAGE_ALIGN(bp->dev->mtu - 40) >> PAGE_SHIFT; in bnxt_set_ring_params()
4739 … 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()
4740 bp->rx_ring_size, ring_size); in bnxt_set_ring_params()
4741 bp->rx_ring_size = ring_size; in bnxt_set_ring_params()
4745 bp->rx_agg_nr_pages = bnxt_calc_nr_ring_pages(agg_ring_size, in bnxt_set_ring_params()
4747 if (bp->rx_agg_nr_pages > MAX_RX_AGG_PAGES) { in bnxt_set_ring_params()
4750 bp->rx_agg_nr_pages = MAX_RX_AGG_PAGES; in bnxt_set_ring_params()
4751 agg_ring_size = MAX_RX_AGG_PAGES * RX_DESC_CNT - 1; in bnxt_set_ring_params()
4752 netdev_warn(bp->dev, "rx agg ring size %d reduced to %d.\n", in bnxt_set_ring_params()
4755 bp->rx_agg_ring_size = agg_ring_size; in bnxt_set_ring_params()
4756 bp->rx_agg_ring_mask = (bp->rx_agg_nr_pages * RX_DESC_CNT) - 1; in bnxt_set_ring_params()
4760 rx_size = PAGE_SIZE - in bnxt_set_ring_params()
4761 ALIGN(max(NET_SKB_PAD, XDP_PACKET_HEADROOM), 8) - in bnxt_set_ring_params()
4765 bp->rx_copybreak, in bnxt_set_ring_params()
4766 bp->dev->cfg_pending->hds_thresh); in bnxt_set_ring_params()
4773 bp->rx_buf_use_size = rx_size; in bnxt_set_ring_params()
4774 bp->rx_buf_size = rx_space; in bnxt_set_ring_params()
4776 bp->rx_nr_pages = bnxt_calc_nr_ring_pages(ring_size, RX_DESC_CNT); in bnxt_set_ring_params()
4777 bp->rx_ring_mask = (bp->rx_nr_pages * RX_DESC_CNT) - 1; in bnxt_set_ring_params()
4779 ring_size = bp->tx_ring_size; in bnxt_set_ring_params()
4780 bp->tx_nr_pages = bnxt_calc_nr_ring_pages(ring_size, TX_DESC_CNT); in bnxt_set_ring_params()
4781 bp->tx_ring_mask = (bp->tx_nr_pages * TX_DESC_CNT) - 1; in bnxt_set_ring_params()
4783 max_rx_cmpl = bp->rx_ring_size; in bnxt_set_ring_params()
4788 if (bp->flags & BNXT_FLAG_TPA) in bnxt_set_ring_params()
4789 max_rx_cmpl += bp->max_tpa; in bnxt_set_ring_params()
4790 /* RX and TPA completions are 32-byte, all others are 16-byte */ in bnxt_set_ring_params()
4791 ring_size = max_rx_cmpl * 2 + agg_ring_size + bp->tx_ring_size; in bnxt_set_ring_params()
4792 bp->cp_ring_size = ring_size; in bnxt_set_ring_params()
4794 bp->cp_nr_pages = bnxt_calc_nr_ring_pages(ring_size, CP_DESC_CNT); in bnxt_set_ring_params()
4795 if (bp->cp_nr_pages > MAX_CP_PAGES) { in bnxt_set_ring_params()
4796 bp->cp_nr_pages = MAX_CP_PAGES; in bnxt_set_ring_params()
4797 bp->cp_ring_size = MAX_CP_PAGES * CP_DESC_CNT - 1; in bnxt_set_ring_params()
4798 netdev_warn(bp->dev, "completion ring size %d reduced to %d.\n", in bnxt_set_ring_params()
4799 ring_size, bp->cp_ring_size); in bnxt_set_ring_params()
4801 bp->cp_bit = bp->cp_nr_pages * CP_DESC_CNT; in bnxt_set_ring_params()
4802 bp->cp_ring_mask = bp->cp_bit - 1; in bnxt_set_ring_params()
4810 struct net_device *dev = bp->dev; in __bnxt_set_rx_skb_mode()
4813 bp->flags &= ~(BNXT_FLAG_AGG_RINGS | BNXT_FLAG_NO_AGG_RINGS); in __bnxt_set_rx_skb_mode()
4814 bp->flags |= BNXT_FLAG_RX_PAGE_MODE; in __bnxt_set_rx_skb_mode()
4816 if (bp->xdp_prog->aux->xdp_has_frags) in __bnxt_set_rx_skb_mode()
4817 dev->max_mtu = min_t(u16, bp->max_mtu, BNXT_MAX_MTU); in __bnxt_set_rx_skb_mode()
4819 dev->max_mtu = in __bnxt_set_rx_skb_mode()
4820 min_t(u16, bp->max_mtu, BNXT_MAX_PAGE_MODE_MTU); in __bnxt_set_rx_skb_mode()
4821 if (dev->mtu > BNXT_MAX_PAGE_MODE_MTU) { in __bnxt_set_rx_skb_mode()
4822 bp->flags |= BNXT_FLAG_JUMBO; in __bnxt_set_rx_skb_mode()
4823 bp->rx_skb_func = bnxt_rx_multi_page_skb; in __bnxt_set_rx_skb_mode()
4825 bp->flags |= BNXT_FLAG_NO_AGG_RINGS; in __bnxt_set_rx_skb_mode()
4826 bp->rx_skb_func = bnxt_rx_page_skb; in __bnxt_set_rx_skb_mode()
4828 bp->rx_dir = DMA_BIDIRECTIONAL; in __bnxt_set_rx_skb_mode()
4830 dev->max_mtu = bp->max_mtu; in __bnxt_set_rx_skb_mode()
4831 bp->flags &= ~BNXT_FLAG_RX_PAGE_MODE; in __bnxt_set_rx_skb_mode()
4832 bp->rx_dir = DMA_FROM_DEVICE; in __bnxt_set_rx_skb_mode()
4833 bp->rx_skb_func = bnxt_rx_skb; in __bnxt_set_rx_skb_mode()
4845 if (rx > 1) { in bnxt_set_rx_skb_mode()
4846 bp->flags &= ~BNXT_FLAG_NO_AGG_RINGS; in bnxt_set_rx_skb_mode()
4847 bp->dev->hw_features |= NETIF_F_LRO; in bnxt_set_rx_skb_mode()
4852 netdev_update_features(bp->dev); in bnxt_set_rx_skb_mode()
4859 struct pci_dev *pdev = bp->pdev; in bnxt_free_vnic_attributes()
4861 if (!bp->vnic_info) in bnxt_free_vnic_attributes()
4864 for (i = 0; i < bp->nr_vnics; i++) { in bnxt_free_vnic_attributes()
4865 vnic = &bp->vnic_info[i]; in bnxt_free_vnic_attributes()
4867 kfree(vnic->fw_grp_ids); in bnxt_free_vnic_attributes()
4868 vnic->fw_grp_ids = NULL; in bnxt_free_vnic_attributes()
4870 kfree(vnic->uc_list); in bnxt_free_vnic_attributes()
4871 vnic->uc_list = NULL; in bnxt_free_vnic_attributes()
4873 if (vnic->mc_list) { in bnxt_free_vnic_attributes()
4874 dma_free_coherent(&pdev->dev, vnic->mc_list_size, in bnxt_free_vnic_attributes()
4875 vnic->mc_list, vnic->mc_list_mapping); in bnxt_free_vnic_attributes()
4876 vnic->mc_list = NULL; in bnxt_free_vnic_attributes()
4879 if (vnic->rss_table) { in bnxt_free_vnic_attributes()
4880 dma_free_coherent(&pdev->dev, vnic->rss_table_size, in bnxt_free_vnic_attributes()
4881 vnic->rss_table, in bnxt_free_vnic_attributes()
4882 vnic->rss_table_dma_addr); in bnxt_free_vnic_attributes()
4883 vnic->rss_table = NULL; in bnxt_free_vnic_attributes()
4886 vnic->rss_hash_key = NULL; in bnxt_free_vnic_attributes()
4887 vnic->flags = 0; in bnxt_free_vnic_attributes()
4895 struct pci_dev *pdev = bp->pdev; in bnxt_alloc_vnic_attributes()
4898 for (i = 0; i < bp->nr_vnics; i++) { in bnxt_alloc_vnic_attributes()
4899 vnic = &bp->vnic_info[i]; in bnxt_alloc_vnic_attributes()
4901 if (vnic->flags & BNXT_VNIC_UCAST_FLAG) { in bnxt_alloc_vnic_attributes()
4902 int mem_size = (BNXT_MAX_UC_ADDRS - 1) * ETH_ALEN; in bnxt_alloc_vnic_attributes()
4905 vnic->uc_list = kmalloc(mem_size, GFP_KERNEL); in bnxt_alloc_vnic_attributes()
4906 if (!vnic->uc_list) { in bnxt_alloc_vnic_attributes()
4907 rc = -ENOMEM; in bnxt_alloc_vnic_attributes()
4913 if (vnic->flags & BNXT_VNIC_MCAST_FLAG) { in bnxt_alloc_vnic_attributes()
4914 vnic->mc_list_size = BNXT_MAX_MC_ADDRS * ETH_ALEN; in bnxt_alloc_vnic_attributes()
4915 vnic->mc_list = in bnxt_alloc_vnic_attributes()
4916 dma_alloc_coherent(&pdev->dev, in bnxt_alloc_vnic_attributes()
4917 vnic->mc_list_size, in bnxt_alloc_vnic_attributes()
4918 &vnic->mc_list_mapping, in bnxt_alloc_vnic_attributes()
4920 if (!vnic->mc_list) { in bnxt_alloc_vnic_attributes()
4921 rc = -ENOMEM; in bnxt_alloc_vnic_attributes()
4926 if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) in bnxt_alloc_vnic_attributes()
4929 if (vnic->flags & BNXT_VNIC_RSS_FLAG) in bnxt_alloc_vnic_attributes()
4930 max_rings = bp->rx_nr_rings; in bnxt_alloc_vnic_attributes()
4932 max_rings = 1; in bnxt_alloc_vnic_attributes()
4934 vnic->fw_grp_ids = kcalloc(max_rings, sizeof(u16), GFP_KERNEL); in bnxt_alloc_vnic_attributes()
4935 if (!vnic->fw_grp_ids) { in bnxt_alloc_vnic_attributes()
4936 rc = -ENOMEM; in bnxt_alloc_vnic_attributes()
4940 if ((bp->rss_cap & BNXT_RSS_CAP_NEW_RSS_CAP) && in bnxt_alloc_vnic_attributes()
4941 !(vnic->flags & BNXT_VNIC_RSS_FLAG)) in bnxt_alloc_vnic_attributes()
4946 if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) in bnxt_alloc_vnic_attributes()
4949 vnic->rss_table_size = size + HW_HASH_KEY_SIZE; in bnxt_alloc_vnic_attributes()
4950 vnic->rss_table = dma_alloc_coherent(&pdev->dev, in bnxt_alloc_vnic_attributes()
4951 vnic->rss_table_size, in bnxt_alloc_vnic_attributes()
4952 &vnic->rss_table_dma_addr, in bnxt_alloc_vnic_attributes()
4954 if (!vnic->rss_table) { in bnxt_alloc_vnic_attributes()
4955 rc = -ENOMEM; in bnxt_alloc_vnic_attributes()
4959 vnic->rss_hash_key = ((void *)vnic->rss_table) + size; in bnxt_alloc_vnic_attributes()
4960 vnic->rss_hash_key_dma_addr = vnic->rss_table_dma_addr + size; in bnxt_alloc_vnic_attributes()
4972 dma_pool_destroy(bp->hwrm_dma_pool); in bnxt_free_hwrm_resources()
4973 bp->hwrm_dma_pool = NULL; in bnxt_free_hwrm_resources()
4976 hlist_for_each_entry_rcu(token, &bp->hwrm_pending_list, node) in bnxt_free_hwrm_resources()
4977 WRITE_ONCE(token->state, BNXT_HWRM_CANCELLED); in bnxt_free_hwrm_resources()
4983 bp->hwrm_dma_pool = dma_pool_create("bnxt_hwrm", &bp->pdev->dev, in bnxt_alloc_hwrm_resources()
4986 if (!bp->hwrm_dma_pool) in bnxt_alloc_hwrm_resources()
4987 return -ENOMEM; in bnxt_alloc_hwrm_resources()
4989 INIT_HLIST_HEAD(&bp->hwrm_pending_list); in bnxt_alloc_hwrm_resources()
4996 kfree(stats->hw_masks); in bnxt_free_stats_mem()
4997 stats->hw_masks = NULL; in bnxt_free_stats_mem()
4998 kfree(stats->sw_stats); in bnxt_free_stats_mem()
4999 stats->sw_stats = NULL; in bnxt_free_stats_mem()
5000 if (stats->hw_stats) { in bnxt_free_stats_mem()
5001 dma_free_coherent(&bp->pdev->dev, stats->len, stats->hw_stats, in bnxt_free_stats_mem()
5002 stats->hw_stats_map); in bnxt_free_stats_mem()
5003 stats->hw_stats = NULL; in bnxt_free_stats_mem()
5010 stats->hw_stats = dma_alloc_coherent(&bp->pdev->dev, stats->len, in bnxt_alloc_stats_mem()
5011 &stats->hw_stats_map, GFP_KERNEL); in bnxt_alloc_stats_mem()
5012 if (!stats->hw_stats) in bnxt_alloc_stats_mem()
5013 return -ENOMEM; in bnxt_alloc_stats_mem()
5015 stats->sw_stats = kzalloc(stats->len, GFP_KERNEL); in bnxt_alloc_stats_mem()
5016 if (!stats->sw_stats) in bnxt_alloc_stats_mem()
5020 stats->hw_masks = kzalloc(stats->len, GFP_KERNEL); in bnxt_alloc_stats_mem()
5021 if (!stats->hw_masks) in bnxt_alloc_stats_mem()
5028 return -ENOMEM; in bnxt_alloc_stats_mem()
5055 if (!(bp->fw_cap & BNXT_FW_CAP_EXT_HW_STATS_SUPPORTED) || in bnxt_hwrm_func_qstat_ext()
5056 !(bp->flags & BNXT_FLAG_CHIP_P5_PLUS)) in bnxt_hwrm_func_qstat_ext()
5057 return -EOPNOTSUPP; in bnxt_hwrm_func_qstat_ext()
5063 req->fid = cpu_to_le16(0xffff); in bnxt_hwrm_func_qstat_ext()
5064 req->flags = FUNC_QSTATS_EXT_REQ_FLAGS_COUNTER_MASK; in bnxt_hwrm_func_qstat_ext()
5069 hw_masks = &resp->rx_ucast_pkts; in bnxt_hwrm_func_qstat_ext()
5070 bnxt_copy_hw_masks(stats->hw_masks, hw_masks, stats->len / 8); in bnxt_hwrm_func_qstat_ext()
5081 struct bnxt_napi *bnapi = bp->bnapi[0]; in bnxt_init_stats()
5090 cpr = &bnapi->cp_ring; in bnxt_init_stats()
5091 stats = &cpr->stats; in bnxt_init_stats()
5094 if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) in bnxt_init_stats()
5095 mask = (1ULL << 48) - 1; in bnxt_init_stats()
5097 mask = -1ULL; in bnxt_init_stats()
5098 bnxt_fill_masks(stats->hw_masks, mask, stats->len / 8); in bnxt_init_stats()
5100 if (bp->flags & BNXT_FLAG_PORT_STATS) { in bnxt_init_stats()
5101 stats = &bp->port_stats; in bnxt_init_stats()
5102 rx_stats = stats->hw_stats; in bnxt_init_stats()
5103 rx_masks = stats->hw_masks; in bnxt_init_stats()
5112 mask = (1ULL << 40) - 1; in bnxt_init_stats()
5122 if (bp->flags & BNXT_FLAG_PORT_STATS_EXT) { in bnxt_init_stats()
5123 stats = &bp->rx_port_stats_ext; in bnxt_init_stats()
5124 rx_stats = stats->hw_stats; in bnxt_init_stats()
5125 rx_masks = stats->hw_masks; in bnxt_init_stats()
5127 stats = &bp->tx_port_stats_ext; in bnxt_init_stats()
5128 tx_stats = stats->hw_stats; in bnxt_init_stats()
5129 tx_masks = stats->hw_masks; in bnxt_init_stats()
5135 mask = (1ULL << 40) - 1; in bnxt_init_stats()
5152 bp->flags &= ~BNXT_FLAG_PORT_STATS; in bnxt_free_port_stats()
5153 bp->flags &= ~BNXT_FLAG_PORT_STATS_EXT; in bnxt_free_port_stats()
5155 bnxt_free_stats_mem(bp, &bp->port_stats); in bnxt_free_port_stats()
5156 bnxt_free_stats_mem(bp, &bp->rx_port_stats_ext); in bnxt_free_port_stats()
5157 bnxt_free_stats_mem(bp, &bp->tx_port_stats_ext); in bnxt_free_port_stats()
5164 if (!bp->bnapi) in bnxt_free_ring_stats()
5167 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_free_ring_stats()
5168 struct bnxt_napi *bnapi = bp->bnapi[i]; in bnxt_free_ring_stats()
5169 struct bnxt_cp_ring_info *cpr = &bnapi->cp_ring; in bnxt_free_ring_stats()
5171 bnxt_free_stats_mem(bp, &cpr->stats); in bnxt_free_ring_stats()
5173 kfree(cpr->sw_stats); in bnxt_free_ring_stats()
5174 cpr->sw_stats = NULL; in bnxt_free_ring_stats()
5183 size = bp->hw_ring_stats_size; in bnxt_alloc_stats()
5185 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_alloc_stats()
5186 struct bnxt_napi *bnapi = bp->bnapi[i]; in bnxt_alloc_stats()
5187 struct bnxt_cp_ring_info *cpr = &bnapi->cp_ring; in bnxt_alloc_stats()
5189 cpr->sw_stats = kzalloc(sizeof(*cpr->sw_stats), GFP_KERNEL); in bnxt_alloc_stats()
5190 if (!cpr->sw_stats) in bnxt_alloc_stats()
5191 return -ENOMEM; in bnxt_alloc_stats()
5193 cpr->stats.len = size; in bnxt_alloc_stats()
5194 rc = bnxt_alloc_stats_mem(bp, &cpr->stats, !i); in bnxt_alloc_stats()
5198 cpr->hw_stats_ctx_id = INVALID_STATS_CTX_ID; in bnxt_alloc_stats()
5201 if (BNXT_VF(bp) || bp->chip_num == CHIP_NUM_58700) in bnxt_alloc_stats()
5204 if (bp->port_stats.hw_stats) in bnxt_alloc_stats()
5207 bp->port_stats.len = BNXT_PORT_STATS_SIZE; in bnxt_alloc_stats()
5208 rc = bnxt_alloc_stats_mem(bp, &bp->port_stats, true); in bnxt_alloc_stats()
5212 bp->flags |= BNXT_FLAG_PORT_STATS; in bnxt_alloc_stats()
5216 if (bp->hwrm_spec_code < 0x10804 || bp->hwrm_spec_code == 0x10900) in bnxt_alloc_stats()
5217 if (!(bp->fw_cap & BNXT_FW_CAP_EXT_STATS_SUPPORTED)) in bnxt_alloc_stats()
5220 if (bp->rx_port_stats_ext.hw_stats) in bnxt_alloc_stats()
5223 bp->rx_port_stats_ext.len = sizeof(struct rx_port_stats_ext); in bnxt_alloc_stats()
5224 rc = bnxt_alloc_stats_mem(bp, &bp->rx_port_stats_ext, true); in bnxt_alloc_stats()
5230 if (bp->tx_port_stats_ext.hw_stats) in bnxt_alloc_stats()
5233 if (bp->hwrm_spec_code >= 0x10902 || in bnxt_alloc_stats()
5234 (bp->fw_cap & BNXT_FW_CAP_EXT_STATS_SUPPORTED)) { in bnxt_alloc_stats()
5235 bp->tx_port_stats_ext.len = sizeof(struct tx_port_stats_ext); in bnxt_alloc_stats()
5236 rc = bnxt_alloc_stats_mem(bp, &bp->tx_port_stats_ext, true); in bnxt_alloc_stats()
5241 bp->flags |= BNXT_FLAG_PORT_STATS_EXT; in bnxt_alloc_stats()
5249 if (!bp->bnapi) in bnxt_clear_ring_indices()
5252 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_clear_ring_indices()
5253 struct bnxt_napi *bnapi = bp->bnapi[i]; in bnxt_clear_ring_indices()
5261 cpr = &bnapi->cp_ring; in bnxt_clear_ring_indices()
5262 cpr->cp_raw_cons = 0; in bnxt_clear_ring_indices()
5265 txr->tx_prod = 0; in bnxt_clear_ring_indices()
5266 txr->tx_cons = 0; in bnxt_clear_ring_indices()
5267 txr->tx_hw_cons = 0; in bnxt_clear_ring_indices()
5270 rxr = bnapi->rx_ring; in bnxt_clear_ring_indices()
5272 rxr->rx_prod = 0; in bnxt_clear_ring_indices()
5273 rxr->rx_agg_prod = 0; in bnxt_clear_ring_indices()
5274 rxr->rx_sw_agg_prod = 0; in bnxt_clear_ring_indices()
5275 rxr->rx_next_cons = 0; in bnxt_clear_ring_indices()
5277 bnapi->events = 0; in bnxt_clear_ring_indices()
5283 u8 type = fltr->type, flags = fltr->flags; in bnxt_insert_usr_fltr()
5285 INIT_LIST_HEAD(&fltr->list); in bnxt_insert_usr_fltr()
5288 list_add_tail(&fltr->list, &bp->usr_fltr_list); in bnxt_insert_usr_fltr()
5293 if (!list_empty(&fltr->list)) in bnxt_del_one_usr_fltr()
5294 list_del_init(&fltr->list); in bnxt_del_one_usr_fltr()
5301 list_for_each_entry_safe(usr_fltr, tmp, &bp->usr_fltr_list, list) { in bnxt_clear_usr_fltrs()
5302 if (!all && usr_fltr->type == BNXT_FLTR_TYPE_L2) in bnxt_clear_usr_fltrs()
5310 hlist_del(&fltr->hash); in bnxt_del_fltr()
5312 if (fltr->flags) { in bnxt_del_fltr()
5313 clear_bit(fltr->sw_id, bp->ntp_fltr_bmap); in bnxt_del_fltr()
5314 bp->ntp_fltr_count--; in bnxt_del_fltr()
5323 netdev_assert_locked(bp->dev); in bnxt_free_ntp_fltrs()
5333 head = &bp->ntp_fltr_hash_tbl[i]; in bnxt_free_ntp_fltrs()
5335 bnxt_del_l2_filter(bp, fltr->l2_fltr); in bnxt_free_ntp_fltrs()
5336 if (!all && ((fltr->base.flags & BNXT_ACT_FUNC_DST) || in bnxt_free_ntp_fltrs()
5337 !list_empty(&fltr->base.list))) in bnxt_free_ntp_fltrs()
5339 bnxt_del_fltr(bp, &fltr->base); in bnxt_free_ntp_fltrs()
5345 bitmap_free(bp->ntp_fltr_bmap); in bnxt_free_ntp_fltrs()
5346 bp->ntp_fltr_bmap = NULL; in bnxt_free_ntp_fltrs()
5347 bp->ntp_fltr_count = 0; in bnxt_free_ntp_fltrs()
5354 if (!(bp->flags & BNXT_FLAG_RFS) || bp->ntp_fltr_bmap) in bnxt_alloc_ntp_fltrs()
5358 INIT_HLIST_HEAD(&bp->ntp_fltr_hash_tbl[i]); in bnxt_alloc_ntp_fltrs()
5360 bp->ntp_fltr_count = 0; in bnxt_alloc_ntp_fltrs()
5361 bp->ntp_fltr_bmap = bitmap_zalloc(bp->max_fltr, GFP_KERNEL); in bnxt_alloc_ntp_fltrs()
5363 if (!bp->ntp_fltr_bmap) in bnxt_alloc_ntp_fltrs()
5364 rc = -ENOMEM; in bnxt_alloc_ntp_fltrs()
5378 head = &bp->l2_fltr_hash_tbl[i]; in bnxt_free_l2_filters()
5380 if (!all && ((fltr->base.flags & BNXT_ACT_FUNC_DST) || in bnxt_free_l2_filters()
5381 !list_empty(&fltr->base.list))) in bnxt_free_l2_filters()
5383 bnxt_del_fltr(bp, &fltr->base); in bnxt_free_l2_filters()
5393 INIT_HLIST_HEAD(&bp->l2_fltr_hash_tbl[i]); in bnxt_init_l2_fltr_tbl()
5394 get_random_bytes(&bp->hash_seed, sizeof(bp->hash_seed)); in bnxt_init_l2_fltr_tbl()
5408 if (!(bp->phy_flags & BNXT_PHY_FL_PORT_STATS_NO_RESET) || in bnxt_free_mem()
5409 test_bit(BNXT_STATE_IN_FW_RESET, &bp->state)) in bnxt_free_mem()
5413 kfree(bp->tx_ring_map); in bnxt_free_mem()
5414 bp->tx_ring_map = NULL; in bnxt_free_mem()
5415 kfree(bp->tx_ring); in bnxt_free_mem()
5416 bp->tx_ring = NULL; in bnxt_free_mem()
5417 kfree(bp->rx_ring); in bnxt_free_mem()
5418 bp->rx_ring = NULL; in bnxt_free_mem()
5419 kfree(bp->bnapi); in bnxt_free_mem()
5420 bp->bnapi = NULL; in bnxt_free_mem()
5436 bp->cp_nr_rings); in bnxt_alloc_mem()
5438 bnapi = kzalloc(arr_size + size * bp->cp_nr_rings, GFP_KERNEL); in bnxt_alloc_mem()
5440 return -ENOMEM; in bnxt_alloc_mem()
5442 bp->bnapi = bnapi; in bnxt_alloc_mem()
5444 for (i = 0; i < bp->cp_nr_rings; i++, bnapi += size) { in bnxt_alloc_mem()
5445 bp->bnapi[i] = bnapi; in bnxt_alloc_mem()
5446 bp->bnapi[i]->index = i; in bnxt_alloc_mem()
5447 bp->bnapi[i]->bp = bp; in bnxt_alloc_mem()
5448 if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) { in bnxt_alloc_mem()
5450 &bp->bnapi[i]->cp_ring; in bnxt_alloc_mem()
5452 cpr->cp_ring_struct.ring_mem.flags = in bnxt_alloc_mem()
5457 bp->rx_ring = kcalloc(bp->rx_nr_rings, in bnxt_alloc_mem()
5460 if (!bp->rx_ring) in bnxt_alloc_mem()
5461 return -ENOMEM; in bnxt_alloc_mem()
5463 for (i = 0; i < bp->rx_nr_rings; i++) { in bnxt_alloc_mem()
5464 struct bnxt_rx_ring_info *rxr = &bp->rx_ring[i]; in bnxt_alloc_mem()
5466 if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) { in bnxt_alloc_mem()
5467 rxr->rx_ring_struct.ring_mem.flags = in bnxt_alloc_mem()
5469 rxr->rx_agg_ring_struct.ring_mem.flags = in bnxt_alloc_mem()
5472 rxr->rx_cpr = &bp->bnapi[i]->cp_ring; in bnxt_alloc_mem()
5474 rxr->bnapi = bp->bnapi[i]; in bnxt_alloc_mem()
5475 bp->bnapi[i]->rx_ring = &bp->rx_ring[i]; in bnxt_alloc_mem()
5478 bp->tx_ring = kcalloc(bp->tx_nr_rings, in bnxt_alloc_mem()
5481 if (!bp->tx_ring) in bnxt_alloc_mem()
5482 return -ENOMEM; in bnxt_alloc_mem()
5484 bp->tx_ring_map = kcalloc(bp->tx_nr_rings, sizeof(u16), in bnxt_alloc_mem()
5487 if (!bp->tx_ring_map) in bnxt_alloc_mem()
5488 return -ENOMEM; in bnxt_alloc_mem()
5490 if (bp->flags & BNXT_FLAG_SHARED_RINGS) in bnxt_alloc_mem()
5493 j = bp->rx_nr_rings; in bnxt_alloc_mem()
5495 for (i = 0; i < bp->tx_nr_rings; i++) { in bnxt_alloc_mem()
5496 struct bnxt_tx_ring_info *txr = &bp->tx_ring[i]; in bnxt_alloc_mem()
5499 if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) in bnxt_alloc_mem()
5500 txr->tx_ring_struct.ring_mem.flags = in bnxt_alloc_mem()
5502 bp->tx_ring_map[i] = bp->tx_nr_rings_xdp + i; in bnxt_alloc_mem()
5503 if (i >= bp->tx_nr_rings_xdp) { in bnxt_alloc_mem()
5506 bnapi2 = bp->bnapi[k]; in bnxt_alloc_mem()
5507 txr->txq_index = i - bp->tx_nr_rings_xdp; in bnxt_alloc_mem()
5508 txr->tx_napi_idx = in bnxt_alloc_mem()
5509 BNXT_RING_TO_TC(bp, txr->txq_index); in bnxt_alloc_mem()
5510 bnapi2->tx_ring[txr->tx_napi_idx] = txr; in bnxt_alloc_mem()
5511 bnapi2->tx_int = bnxt_tx_int; in bnxt_alloc_mem()
5513 bnapi2 = bp->bnapi[j]; in bnxt_alloc_mem()
5514 bnapi2->flags |= BNXT_NAPI_FLAG_XDP; in bnxt_alloc_mem()
5515 bnapi2->tx_ring[0] = txr; in bnxt_alloc_mem()
5516 bnapi2->tx_int = bnxt_tx_int_xdp; in bnxt_alloc_mem()
5519 txr->bnapi = bnapi2; in bnxt_alloc_mem()
5520 if (!(bp->flags & BNXT_FLAG_CHIP_P5_PLUS)) in bnxt_alloc_mem()
5521 txr->tx_cpr = &bnapi2->cp_ring; in bnxt_alloc_mem()
5556 bp->vnic_info[BNXT_VNIC_DEFAULT].flags |= BNXT_VNIC_RSS_FLAG | in bnxt_alloc_mem()
5559 if (BNXT_SUPPORTS_NTUPLE_VNIC(bp) && (bp->flags & BNXT_FLAG_RFS)) in bnxt_alloc_mem()
5560 bp->vnic_info[BNXT_VNIC_NTUPLE].flags |= in bnxt_alloc_mem()
5577 if (!bp->bnapi) in bnxt_disable_int()
5580 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_disable_int()
5581 struct bnxt_napi *bnapi = bp->bnapi[i]; in bnxt_disable_int()
5582 struct bnxt_cp_ring_info *cpr = &bnapi->cp_ring; in bnxt_disable_int()
5583 struct bnxt_ring_struct *ring = &cpr->cp_ring_struct; in bnxt_disable_int()
5585 if (ring->fw_ring_id != INVALID_HW_RING_ID) in bnxt_disable_int()
5586 bnxt_db_nq(bp, &cpr->cp_db, cpr->cp_raw_cons); in bnxt_disable_int()
5592 struct bnxt_napi *bnapi = bp->bnapi[n]; in bnxt_cp_num_to_irq_num()
5595 cpr = &bnapi->cp_ring; in bnxt_cp_num_to_irq_num()
5596 return cpr->cp_ring_struct.map_idx; in bnxt_cp_num_to_irq_num()
5603 if (!bp->irq_tbl) in bnxt_disable_int_sync()
5606 atomic_inc(&bp->intr_sem); in bnxt_disable_int_sync()
5609 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_disable_int_sync()
5612 synchronize_irq(bp->irq_tbl[map_idx].vector); in bnxt_disable_int_sync()
5620 atomic_set(&bp->intr_sem, 0); in bnxt_enable_int()
5621 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_enable_int()
5622 struct bnxt_napi *bnapi = bp->bnapi[i]; in bnxt_enable_int()
5623 struct bnxt_cp_ring_info *cpr = &bnapi->cp_ring; in bnxt_enable_int()
5625 bnxt_db_nq_arm(bp, &cpr->cp_db, cpr->cp_raw_cons); in bnxt_enable_int()
5643 req->enables = cpu_to_le32(FUNC_DRV_RGTR_REQ_ENABLES_OS_TYPE | in bnxt_hwrm_func_drv_rgtr()
5647 req->os_type = cpu_to_le16(FUNC_DRV_RGTR_REQ_OS_TYPE_LINUX); in bnxt_hwrm_func_drv_rgtr()
5649 if (bp->fw_cap & BNXT_FW_CAP_HOT_RESET) in bnxt_hwrm_func_drv_rgtr()
5651 if (bp->fw_cap & BNXT_FW_CAP_ERROR_RECOVERY) in bnxt_hwrm_func_drv_rgtr()
5654 if (bp->fw_cap & BNXT_FW_CAP_NPAR_1_2) in bnxt_hwrm_func_drv_rgtr()
5656 req->flags = cpu_to_le32(flags); in bnxt_hwrm_func_drv_rgtr()
5657 req->ver_maj_8b = DRV_VER_MAJ; in bnxt_hwrm_func_drv_rgtr()
5658 req->ver_min_8b = DRV_VER_MIN; in bnxt_hwrm_func_drv_rgtr()
5659 req->ver_upd_8b = DRV_VER_UPD; in bnxt_hwrm_func_drv_rgtr()
5660 req->ver_maj = cpu_to_le16(DRV_VER_MAJ); in bnxt_hwrm_func_drv_rgtr()
5661 req->ver_min = cpu_to_le16(DRV_VER_MIN); in bnxt_hwrm_func_drv_rgtr()
5662 req->ver_upd = cpu_to_le16(DRV_VER_UPD); in bnxt_hwrm_func_drv_rgtr()
5675 data[idx] |= 1 << bit; in bnxt_hwrm_func_drv_rgtr()
5679 req->vf_req_fwd[i] = cpu_to_le32(data[i]); in bnxt_hwrm_func_drv_rgtr()
5681 req->enables |= in bnxt_hwrm_func_drv_rgtr()
5685 if (bp->fw_cap & BNXT_FW_CAP_OVS_64BIT_HANDLE) in bnxt_hwrm_func_drv_rgtr()
5686 req->flags |= cpu_to_le32( in bnxt_hwrm_func_drv_rgtr()
5694 !(bp->fw_cap & BNXT_FW_CAP_ERROR_RECOVERY)) in bnxt_hwrm_func_drv_rgtr()
5697 !bp->ptp_cfg) in bnxt_hwrm_func_drv_rgtr()
5708 req->async_event_fwd[i] |= cpu_to_le32(events[i]); in bnxt_hwrm_func_drv_rgtr()
5711 req->enables = in bnxt_hwrm_func_drv_rgtr()
5717 set_bit(BNXT_STATE_DRV_REGISTERED, &bp->state); in bnxt_hwrm_func_drv_rgtr()
5718 if (resp->flags & in bnxt_hwrm_func_drv_rgtr()
5720 bp->fw_cap |= BNXT_FW_CAP_IF_CHANGE; in bnxt_hwrm_func_drv_rgtr()
5731 if (!test_and_clear_bit(BNXT_STATE_DRV_REGISTERED, &bp->state)) in bnxt_hwrm_func_drv_unrgtr()
5748 bp->vxlan_fw_dst_port_id == INVALID_HW_RING_ID) in bnxt_hwrm_tunnel_dst_port_free()
5751 bp->nge_fw_dst_port_id == INVALID_HW_RING_ID) in bnxt_hwrm_tunnel_dst_port_free()
5758 req->tunnel_type = tunnel_type; in bnxt_hwrm_tunnel_dst_port_free()
5762 req->tunnel_dst_port_id = cpu_to_le16(bp->vxlan_fw_dst_port_id); in bnxt_hwrm_tunnel_dst_port_free()
5763 bp->vxlan_port = 0; in bnxt_hwrm_tunnel_dst_port_free()
5764 bp->vxlan_fw_dst_port_id = INVALID_HW_RING_ID; in bnxt_hwrm_tunnel_dst_port_free()
5767 req->tunnel_dst_port_id = cpu_to_le16(bp->nge_fw_dst_port_id); in bnxt_hwrm_tunnel_dst_port_free()
5768 bp->nge_port = 0; in bnxt_hwrm_tunnel_dst_port_free()
5769 bp->nge_fw_dst_port_id = INVALID_HW_RING_ID; in bnxt_hwrm_tunnel_dst_port_free()
5772 req->tunnel_dst_port_id = cpu_to_le16(bp->vxlan_gpe_fw_dst_port_id); in bnxt_hwrm_tunnel_dst_port_free()
5773 bp->vxlan_gpe_port = 0; in bnxt_hwrm_tunnel_dst_port_free()
5774 bp->vxlan_gpe_fw_dst_port_id = INVALID_HW_RING_ID; in bnxt_hwrm_tunnel_dst_port_free()
5782 netdev_err(bp->dev, "hwrm_tunnel_dst_port_free failed. rc:%d\n", in bnxt_hwrm_tunnel_dst_port_free()
5784 if (bp->flags & BNXT_FLAG_TPA) in bnxt_hwrm_tunnel_dst_port_free()
5800 req->tunnel_type = tunnel_type; in bnxt_hwrm_tunnel_dst_port_alloc()
5801 req->tunnel_dst_port_val = port; in bnxt_hwrm_tunnel_dst_port_alloc()
5806 netdev_err(bp->dev, "hwrm_tunnel_dst_port_alloc failed. rc:%d\n", in bnxt_hwrm_tunnel_dst_port_alloc()
5813 bp->vxlan_port = port; in bnxt_hwrm_tunnel_dst_port_alloc()
5814 bp->vxlan_fw_dst_port_id = in bnxt_hwrm_tunnel_dst_port_alloc()
5815 le16_to_cpu(resp->tunnel_dst_port_id); in bnxt_hwrm_tunnel_dst_port_alloc()
5818 bp->nge_port = port; in bnxt_hwrm_tunnel_dst_port_alloc()
5819 bp->nge_fw_dst_port_id = le16_to_cpu(resp->tunnel_dst_port_id); in bnxt_hwrm_tunnel_dst_port_alloc()
5822 bp->vxlan_gpe_port = port; in bnxt_hwrm_tunnel_dst_port_alloc()
5823 bp->vxlan_gpe_fw_dst_port_id = in bnxt_hwrm_tunnel_dst_port_alloc()
5824 le16_to_cpu(resp->tunnel_dst_port_id); in bnxt_hwrm_tunnel_dst_port_alloc()
5829 if (bp->flags & BNXT_FLAG_TPA) in bnxt_hwrm_tunnel_dst_port_alloc()
5840 struct bnxt_vnic_info *vnic = &bp->vnic_info[vnic_id]; in bnxt_hwrm_cfa_l2_set_rx_mask()
5847 req->vnic_id = cpu_to_le32(vnic->fw_vnic_id); in bnxt_hwrm_cfa_l2_set_rx_mask()
5848 if (vnic->rx_mask & CFA_L2_SET_RX_MASK_REQ_MASK_MCAST) { in bnxt_hwrm_cfa_l2_set_rx_mask()
5849 req->num_mc_entries = cpu_to_le32(vnic->mc_list_count); in bnxt_hwrm_cfa_l2_set_rx_mask()
5850 req->mc_tbl_addr = cpu_to_le64(vnic->mc_list_mapping); in bnxt_hwrm_cfa_l2_set_rx_mask()
5852 req->mask = cpu_to_le32(vnic->rx_mask); in bnxt_hwrm_cfa_l2_set_rx_mask()
5858 if (!atomic_dec_and_test(&fltr->refcnt)) in bnxt_del_l2_filter()
5860 spin_lock_bh(&bp->ntp_fltr_lock); in bnxt_del_l2_filter()
5861 if (!test_and_clear_bit(BNXT_FLTR_INSERTED, &fltr->base.state)) { in bnxt_del_l2_filter()
5862 spin_unlock_bh(&bp->ntp_fltr_lock); in bnxt_del_l2_filter()
5865 hlist_del_rcu(&fltr->base.hash); in bnxt_del_l2_filter()
5866 bnxt_del_one_usr_fltr(bp, &fltr->base); in bnxt_del_l2_filter()
5867 if (fltr->base.flags) { in bnxt_del_l2_filter()
5868 clear_bit(fltr->base.sw_id, bp->ntp_fltr_bmap); in bnxt_del_l2_filter()
5869 bp->ntp_fltr_count--; in bnxt_del_l2_filter()
5871 spin_unlock_bh(&bp->ntp_fltr_lock); in bnxt_del_l2_filter()
5879 struct hlist_head *head = &bp->l2_fltr_hash_tbl[idx]; in __bnxt_lookup_l2_filter()
5883 struct bnxt_l2_key *l2_key = &fltr->l2_key; in __bnxt_lookup_l2_filter()
5885 if (ether_addr_equal(l2_key->dst_mac_addr, key->dst_mac_addr) && in __bnxt_lookup_l2_filter()
5886 l2_key->vlan == key->vlan) in __bnxt_lookup_l2_filter()
5901 atomic_inc(&fltr->refcnt); in bnxt_lookup_l2_filter()
5907 (((fkeys)->basic.ip_proto == IPPROTO_TCP && \
5908 (bp)->rss_hash_cfg & VNIC_RSS_CFG_REQ_HASH_TYPE_TCP_IPV4) || \
5909 ((fkeys)->basic.ip_proto == IPPROTO_UDP && \
5910 (bp)->rss_hash_cfg & VNIC_RSS_CFG_REQ_HASH_TYPE_UDP_IPV4))
5913 (((fkeys)->basic.ip_proto == IPPROTO_TCP && \
5914 (bp)->rss_hash_cfg & VNIC_RSS_CFG_REQ_HASH_TYPE_TCP_IPV6) || \
5915 ((fkeys)->basic.ip_proto == IPPROTO_UDP && \
5916 (bp)->rss_hash_cfg & VNIC_RSS_CFG_REQ_HASH_TYPE_UDP_IPV6))
5920 if (fkeys->basic.n_proto == htons(ETH_P_IP)) { in bnxt_get_rss_flow_tuple_len()
5922 return sizeof(fkeys->addrs.v4addrs) + in bnxt_get_rss_flow_tuple_len()
5923 sizeof(fkeys->ports); in bnxt_get_rss_flow_tuple_len()
5925 if (bp->rss_hash_cfg & VNIC_RSS_CFG_REQ_HASH_TYPE_IPV4) in bnxt_get_rss_flow_tuple_len()
5926 return sizeof(fkeys->addrs.v4addrs); in bnxt_get_rss_flow_tuple_len()
5929 if (fkeys->basic.n_proto == htons(ETH_P_IPV6)) { in bnxt_get_rss_flow_tuple_len()
5931 return sizeof(fkeys->addrs.v6addrs) + in bnxt_get_rss_flow_tuple_len()
5932 sizeof(fkeys->ports); in bnxt_get_rss_flow_tuple_len()
5934 if (bp->rss_hash_cfg & VNIC_RSS_CFG_REQ_HASH_TYPE_IPV6) in bnxt_get_rss_flow_tuple_len()
5935 return sizeof(fkeys->addrs.v6addrs); in bnxt_get_rss_flow_tuple_len()
5944 u64 prefix = bp->toeplitz_prefix, hash = 0; in bnxt_toeplitz()
5954 if (fkeys->basic.n_proto == htons(ETH_P_IP)) { in bnxt_toeplitz()
5955 tuple4.v4addrs = fkeys->addrs.v4addrs; in bnxt_toeplitz()
5956 tuple4.ports = fkeys->ports; in bnxt_toeplitz()
5959 tuple6.v6addrs = fkeys->addrs.v6addrs; in bnxt_toeplitz()
5960 tuple6.ports = fkeys->ports; in bnxt_toeplitz()
5968 for (bit = 0; bit < 8; bit++, prefix <<= 1, byte <<= 1) { in bnxt_toeplitz()
5986 idx = jhash2(&key->filter_key, BNXT_L2_KEY_SIZE, bp->hash_seed) & in bnxt_lookup_l2_filter_from_key()
5998 ether_addr_copy(fltr->l2_key.dst_mac_addr, key->dst_mac_addr); in bnxt_init_l2_filter()
5999 fltr->l2_key.vlan = key->vlan; in bnxt_init_l2_filter()
6000 fltr->base.type = BNXT_FLTR_TYPE_L2; in bnxt_init_l2_filter()
6001 if (fltr->base.flags) { in bnxt_init_l2_filter()
6004 bit_id = bitmap_find_free_region(bp->ntp_fltr_bmap, in bnxt_init_l2_filter()
6005 bp->max_fltr, 0); in bnxt_init_l2_filter()
6007 return -ENOMEM; in bnxt_init_l2_filter()
6008 fltr->base.sw_id = (u16)bit_id; in bnxt_init_l2_filter()
6009 bp->ntp_fltr_count++; in bnxt_init_l2_filter()
6011 head = &bp->l2_fltr_hash_tbl[idx]; in bnxt_init_l2_filter()
6012 hlist_add_head_rcu(&fltr->base.hash, head); in bnxt_init_l2_filter()
6013 bnxt_insert_usr_fltr(bp, &fltr->base); in bnxt_init_l2_filter()
6014 set_bit(BNXT_FLTR_INSERTED, &fltr->base.state); in bnxt_init_l2_filter()
6015 atomic_set(&fltr->refcnt, 1); in bnxt_init_l2_filter()
6027 idx = jhash2(&key->filter_key, BNXT_L2_KEY_SIZE, bp->hash_seed) & in bnxt_alloc_l2_filter()
6035 return ERR_PTR(-ENOMEM); in bnxt_alloc_l2_filter()
6036 spin_lock_bh(&bp->ntp_fltr_lock); in bnxt_alloc_l2_filter()
6038 spin_unlock_bh(&bp->ntp_fltr_lock); in bnxt_alloc_l2_filter()
6054 idx = jhash2(&key->filter_key, BNXT_L2_KEY_SIZE, bp->hash_seed) & in bnxt_alloc_new_l2_filter()
6056 spin_lock_bh(&bp->ntp_fltr_lock); in bnxt_alloc_new_l2_filter()
6059 fltr = ERR_PTR(-EEXIST); in bnxt_alloc_new_l2_filter()
6064 fltr = ERR_PTR(-ENOMEM); in bnxt_alloc_new_l2_filter()
6067 fltr->base.flags = flags; in bnxt_alloc_new_l2_filter()
6070 spin_unlock_bh(&bp->ntp_fltr_lock); in bnxt_alloc_new_l2_filter()
6076 spin_unlock_bh(&bp->ntp_fltr_lock); in bnxt_alloc_new_l2_filter()
6083 struct bnxt_vf_info *vf = &pf->vf[vf_idx]; in bnxt_vf_target_id()
6085 return vf->fw_fid; in bnxt_vf_target_id()
6097 if (fltr->base.flags & BNXT_ACT_FUNC_DST) { in bnxt_hwrm_l2_filter_free()
6098 struct bnxt_pf_info *pf = &bp->pf; in bnxt_hwrm_l2_filter_free()
6100 if (fltr->base.vf_idx >= pf->active_vfs) in bnxt_hwrm_l2_filter_free()
6101 return -EINVAL; in bnxt_hwrm_l2_filter_free()
6103 target_id = bnxt_vf_target_id(pf, fltr->base.vf_idx); in bnxt_hwrm_l2_filter_free()
6105 return -EINVAL; in bnxt_hwrm_l2_filter_free()
6112 req->target_id = cpu_to_le16(target_id); in bnxt_hwrm_l2_filter_free()
6113 req->l2_filter_id = fltr->base.filter_id; in bnxt_hwrm_l2_filter_free()
6124 if (fltr->base.flags & BNXT_ACT_FUNC_DST) { in bnxt_hwrm_l2_filter_alloc()
6125 struct bnxt_pf_info *pf = &bp->pf; in bnxt_hwrm_l2_filter_alloc()
6127 if (fltr->base.vf_idx >= pf->active_vfs) in bnxt_hwrm_l2_filter_alloc()
6128 return -EINVAL; in bnxt_hwrm_l2_filter_alloc()
6130 target_id = bnxt_vf_target_id(pf, fltr->base.vf_idx); in bnxt_hwrm_l2_filter_alloc()
6136 req->target_id = cpu_to_le16(target_id); in bnxt_hwrm_l2_filter_alloc()
6137 req->flags = cpu_to_le32(CFA_L2_FILTER_ALLOC_REQ_FLAGS_PATH_RX); in bnxt_hwrm_l2_filter_alloc()
6140 req->flags |= in bnxt_hwrm_l2_filter_alloc()
6142 req->dst_id = cpu_to_le16(fltr->base.fw_vnic_id); in bnxt_hwrm_l2_filter_alloc()
6143 req->enables = in bnxt_hwrm_l2_filter_alloc()
6147 ether_addr_copy(req->l2_addr, fltr->l2_key.dst_mac_addr); in bnxt_hwrm_l2_filter_alloc()
6148 eth_broadcast_addr(req->l2_addr_mask); in bnxt_hwrm_l2_filter_alloc()
6150 if (fltr->l2_key.vlan) { in bnxt_hwrm_l2_filter_alloc()
6151 req->enables |= in bnxt_hwrm_l2_filter_alloc()
6155 req->num_vlans = 1; in bnxt_hwrm_l2_filter_alloc()
6156 req->l2_ivlan = cpu_to_le16(fltr->l2_key.vlan); in bnxt_hwrm_l2_filter_alloc()
6157 req->l2_ivlan_mask = cpu_to_le16(0xfff); in bnxt_hwrm_l2_filter_alloc()
6163 fltr->base.filter_id = resp->l2_filter_id; in bnxt_hwrm_l2_filter_alloc()
6164 set_bit(BNXT_FLTR_VALID, &fltr->base.state); in bnxt_hwrm_l2_filter_alloc()
6176 set_bit(BNXT_FLTR_FW_DELETED, &fltr->base.state); in bnxt_hwrm_cfa_ntuple_filter_free()
6181 req->ntuple_filter_id = fltr->base.filter_id; in bnxt_hwrm_cfa_ntuple_filter_free()
6216 u16 rxq = fltr->base.rxq; in bnxt_cfg_rfs_ring_tbl_idx()
6218 if (fltr->base.flags & BNXT_ACT_RSS_CTX) { in bnxt_cfg_rfs_ring_tbl_idx()
6223 ctx = xa_load(&bp->dev->ethtool->rss_ctx, in bnxt_cfg_rfs_ring_tbl_idx()
6224 fltr->base.fw_vnic_id); in bnxt_cfg_rfs_ring_tbl_idx()
6227 vnic = &rss_ctx->vnic; in bnxt_cfg_rfs_ring_tbl_idx()
6229 req->dst_id = cpu_to_le16(vnic->fw_vnic_id); in bnxt_cfg_rfs_ring_tbl_idx()
6237 vnic = &bp->vnic_info[BNXT_VNIC_NTUPLE]; in bnxt_cfg_rfs_ring_tbl_idx()
6238 req->dst_id = cpu_to_le16(vnic->fw_vnic_id); in bnxt_cfg_rfs_ring_tbl_idx()
6240 req->enables |= cpu_to_le32(enables); in bnxt_cfg_rfs_ring_tbl_idx()
6241 req->rfs_ring_tbl_idx = cpu_to_le16(rxq); in bnxt_cfg_rfs_ring_tbl_idx()
6246 req->flags |= cpu_to_le32(flags); in bnxt_cfg_rfs_ring_tbl_idx()
6247 req->dst_id = cpu_to_le16(rxq); in bnxt_cfg_rfs_ring_tbl_idx()
6256 struct bnxt_flow_masks *masks = &fltr->fmasks; in bnxt_hwrm_cfa_ntuple_filter_alloc()
6257 struct flow_keys *keys = &fltr->fkeys; in bnxt_hwrm_cfa_ntuple_filter_alloc()
6266 l2_fltr = fltr->l2_fltr; in bnxt_hwrm_cfa_ntuple_filter_alloc()
6267 req->l2_filter_id = l2_fltr->base.filter_id; in bnxt_hwrm_cfa_ntuple_filter_alloc()
6269 if (fltr->base.flags & BNXT_ACT_DROP) { in bnxt_hwrm_cfa_ntuple_filter_alloc()
6270 req->flags = in bnxt_hwrm_cfa_ntuple_filter_alloc()
6272 } else if (bp->fw_cap & BNXT_FW_CAP_CFA_RFS_RING_TBL_IDX_V2) { in bnxt_hwrm_cfa_ntuple_filter_alloc()
6275 vnic = &bp->vnic_info[fltr->base.rxq + 1]; in bnxt_hwrm_cfa_ntuple_filter_alloc()
6276 req->dst_id = cpu_to_le16(vnic->fw_vnic_id); in bnxt_hwrm_cfa_ntuple_filter_alloc()
6278 req->enables |= cpu_to_le32(BNXT_NTP_FLTR_FLAGS); in bnxt_hwrm_cfa_ntuple_filter_alloc()
6280 req->ethertype = htons(ETH_P_IP); in bnxt_hwrm_cfa_ntuple_filter_alloc()
6281 req->ip_addr_type = CFA_NTUPLE_FILTER_ALLOC_REQ_IP_ADDR_TYPE_IPV4; in bnxt_hwrm_cfa_ntuple_filter_alloc()
6282 req->ip_protocol = keys->basic.ip_proto; in bnxt_hwrm_cfa_ntuple_filter_alloc()
6284 if (keys->basic.n_proto == htons(ETH_P_IPV6)) { in bnxt_hwrm_cfa_ntuple_filter_alloc()
6285 req->ethertype = htons(ETH_P_IPV6); in bnxt_hwrm_cfa_ntuple_filter_alloc()
6286 req->ip_addr_type = in bnxt_hwrm_cfa_ntuple_filter_alloc()
6288 *(struct in6_addr *)&req->src_ipaddr[0] = keys->addrs.v6addrs.src; in bnxt_hwrm_cfa_ntuple_filter_alloc()
6289 *(struct in6_addr *)&req->src_ipaddr_mask[0] = masks->addrs.v6addrs.src; in bnxt_hwrm_cfa_ntuple_filter_alloc()
6290 *(struct in6_addr *)&req->dst_ipaddr[0] = keys->addrs.v6addrs.dst; in bnxt_hwrm_cfa_ntuple_filter_alloc()
6291 *(struct in6_addr *)&req->dst_ipaddr_mask[0] = masks->addrs.v6addrs.dst; in bnxt_hwrm_cfa_ntuple_filter_alloc()
6293 req->src_ipaddr[0] = keys->addrs.v4addrs.src; in bnxt_hwrm_cfa_ntuple_filter_alloc()
6294 req->src_ipaddr_mask[0] = masks->addrs.v4addrs.src; in bnxt_hwrm_cfa_ntuple_filter_alloc()
6295 req->dst_ipaddr[0] = keys->addrs.v4addrs.dst; in bnxt_hwrm_cfa_ntuple_filter_alloc()
6296 req->dst_ipaddr_mask[0] = masks->addrs.v4addrs.dst; in bnxt_hwrm_cfa_ntuple_filter_alloc()
6298 if (keys->control.flags & FLOW_DIS_ENCAPSULATION) { in bnxt_hwrm_cfa_ntuple_filter_alloc()
6299 req->enables |= cpu_to_le32(BNXT_NTP_TUNNEL_FLTR_FLAG); in bnxt_hwrm_cfa_ntuple_filter_alloc()
6300 req->tunnel_type = in bnxt_hwrm_cfa_ntuple_filter_alloc()
6304 req->src_port = keys->ports.src; in bnxt_hwrm_cfa_ntuple_filter_alloc()
6305 req->src_port_mask = masks->ports.src; in bnxt_hwrm_cfa_ntuple_filter_alloc()
6306 req->dst_port = keys->ports.dst; in bnxt_hwrm_cfa_ntuple_filter_alloc()
6307 req->dst_port_mask = masks->ports.dst; in bnxt_hwrm_cfa_ntuple_filter_alloc()
6312 fltr->base.filter_id = resp->ntuple_filter_id; in bnxt_hwrm_cfa_ntuple_filter_alloc()
6330 fltr->base.fw_vnic_id = bp->vnic_info[vnic_id].fw_vnic_id; in bnxt_hwrm_set_vnic_filter()
6335 bp->vnic_info[vnic_id].l2_filters[idx] = fltr; in bnxt_hwrm_set_vnic_filter()
6341 u16 i, j, num_of_vnics = 1; /* only vnic 0 supported */ in bnxt_hwrm_clear_vnic_filter()
6345 struct bnxt_vnic_info *vnic = &bp->vnic_info[i]; in bnxt_hwrm_clear_vnic_filter()
6347 for (j = 0; j < vnic->uc_filter_count; j++) { in bnxt_hwrm_clear_vnic_filter()
6348 struct bnxt_l2_filter *fltr = vnic->l2_filters[j]; in bnxt_hwrm_clear_vnic_filter()
6353 vnic->uc_filter_count = 0; in bnxt_hwrm_clear_vnic_filter()
6367 if (!(bp->fw_cap & BNXT_FW_CAP_VNIC_TUNNEL_TPA)) in bnxt_hwrm_vnic_update_tunl_tpa()
6370 if (bp->vxlan_port) in bnxt_hwrm_vnic_update_tunl_tpa()
6372 if (bp->vxlan_gpe_port) in bnxt_hwrm_vnic_update_tunl_tpa()
6374 if (bp->nge_port) in bnxt_hwrm_vnic_update_tunl_tpa()
6377 req->enables |= cpu_to_le32(VNIC_TPA_CFG_REQ_ENABLES_TNL_TPA_EN); in bnxt_hwrm_vnic_update_tunl_tpa()
6378 req->tnl_tpa_en_bitmap = cpu_to_le32(tunl_tpa_bmap); in bnxt_hwrm_vnic_update_tunl_tpa()
6388 if (vnic->fw_vnic_id == INVALID_HW_RING_ID) in bnxt_hwrm_vnic_set_tpa()
6396 u16 mss = bp->dev->mtu - 40; in bnxt_hwrm_vnic_set_tpa()
6407 req->flags = cpu_to_le32(flags); in bnxt_hwrm_vnic_set_tpa()
6409 req->enables = in bnxt_hwrm_vnic_set_tpa()
6419 nsegs = (MAX_SKB_FRAGS - 1) * n; in bnxt_hwrm_vnic_set_tpa()
6422 if (mss & (BNXT_RX_PAGE_SIZE - 1)) in bnxt_hwrm_vnic_set_tpa()
6424 nsegs = (MAX_SKB_FRAGS - n) / n; in bnxt_hwrm_vnic_set_tpa()
6427 if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) { in bnxt_hwrm_vnic_set_tpa()
6429 max_aggs = bp->max_tpa; in bnxt_hwrm_vnic_set_tpa()
6433 req->max_agg_segs = cpu_to_le16(segs); in bnxt_hwrm_vnic_set_tpa()
6434 req->max_aggs = cpu_to_le16(max_aggs); in bnxt_hwrm_vnic_set_tpa()
6436 req->min_agg_len = cpu_to_le32(512); in bnxt_hwrm_vnic_set_tpa()
6439 req->vnic_id = cpu_to_le16(vnic->fw_vnic_id); in bnxt_hwrm_vnic_set_tpa()
6448 grp_info = &bp->grp_info[ring->grp_idx]; in bnxt_cp_ring_from_grp()
6449 return grp_info->cp_fw_ring_id; in bnxt_cp_ring_from_grp()
6454 if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) in bnxt_cp_ring_for_rx()
6455 return rxr->rx_cpr->cp_ring_struct.fw_ring_id; in bnxt_cp_ring_for_rx()
6457 return bnxt_cp_ring_from_grp(bp, &rxr->rx_ring_struct); in bnxt_cp_ring_for_rx()
6462 if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) in bnxt_cp_ring_for_tx()
6463 return txr->tx_cpr->cp_ring_struct.fw_ring_id; in bnxt_cp_ring_for_tx()
6465 return bnxt_cp_ring_from_grp(bp, &txr->tx_ring_struct); in bnxt_cp_ring_for_tx()
6472 if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) in bnxt_alloc_rss_indir_tbl()
6477 bp->rss_indir_tbl_entries = entries; in bnxt_alloc_rss_indir_tbl()
6478 bp->rss_indir_tbl = in bnxt_alloc_rss_indir_tbl()
6479 kmalloc_array(entries, sizeof(*bp->rss_indir_tbl), GFP_KERNEL); in bnxt_alloc_rss_indir_tbl()
6480 if (!bp->rss_indir_tbl) in bnxt_alloc_rss_indir_tbl()
6481 return -ENOMEM; in bnxt_alloc_rss_indir_tbl()
6492 if (!bp->rx_nr_rings) in bnxt_set_dflt_rss_indir_tbl()
6496 max_rings = bp->rx_nr_rings - 1; in bnxt_set_dflt_rss_indir_tbl()
6498 max_rings = bp->rx_nr_rings; in bnxt_set_dflt_rss_indir_tbl()
6500 max_entries = bnxt_get_rxfh_indir_size(bp->dev); in bnxt_set_dflt_rss_indir_tbl()
6504 rss_indir_tbl = &bp->rss_indir_tbl[0]; in bnxt_set_dflt_rss_indir_tbl()
6509 pad = bp->rss_indir_tbl_entries - max_entries; in bnxt_set_dflt_rss_indir_tbl()
6518 if (!bp->rss_indir_tbl) in bnxt_get_max_rss_ring()
6521 tbl_size = bnxt_get_rxfh_indir_size(bp->dev); in bnxt_get_max_rss_ring()
6523 max_ring = max(max_ring, bp->rss_indir_tbl[i]); in bnxt_get_max_rss_ring()
6529 if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) { in bnxt_get_nr_rss_ctxs()
6532 return bnxt_calc_nr_ring_pages(rx_rings - 1, in bnxt_get_nr_rss_ctxs()
6537 return 1; in bnxt_get_nr_rss_ctxs()
6542 bool no_rss = !(vnic->flags & BNXT_VNIC_RSS_FLAG); in bnxt_fill_hw_rss_tbl()
6548 j = bp->rss_indir_tbl[i]; in bnxt_fill_hw_rss_tbl()
6549 vnic->rss_table[i] = cpu_to_le16(vnic->fw_grp_ids[j]); in bnxt_fill_hw_rss_tbl()
6556 __le16 *ring_tbl = vnic->rss_table; in bnxt_fill_hw_rss_tbl_p5()
6560 tbl_size = bnxt_get_rxfh_indir_size(bp->dev); in bnxt_fill_hw_rss_tbl_p5()
6565 if (vnic->flags & BNXT_VNIC_NTUPLE_FLAG) in bnxt_fill_hw_rss_tbl_p5()
6566 j = ethtool_rxfh_indir_default(i, bp->rx_nr_rings); in bnxt_fill_hw_rss_tbl_p5()
6567 else if (vnic->flags & BNXT_VNIC_RSSCTX_FLAG) in bnxt_fill_hw_rss_tbl_p5()
6568 j = ethtool_rxfh_context_indir(vnic->rss_ctx)[i]; in bnxt_fill_hw_rss_tbl_p5()
6570 j = bp->rss_indir_tbl[i]; in bnxt_fill_hw_rss_tbl_p5()
6571 rxr = &bp->rx_ring[j]; in bnxt_fill_hw_rss_tbl_p5()
6573 ring_id = rxr->rx_ring_struct.fw_ring_id; in bnxt_fill_hw_rss_tbl_p5()
6584 if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) { in __bnxt_hwrm_vnic_set_rss()
6586 if (bp->flags & BNXT_FLAG_CHIP_P7) in __bnxt_hwrm_vnic_set_rss()
6587 req->flags |= VNIC_RSS_CFG_REQ_FLAGS_IPSEC_HASH_TYPE_CFG_SUPPORT; in __bnxt_hwrm_vnic_set_rss()
6592 if (bp->rss_hash_delta) { in __bnxt_hwrm_vnic_set_rss()
6593 req->hash_type = cpu_to_le32(bp->rss_hash_delta); in __bnxt_hwrm_vnic_set_rss()
6594 if (bp->rss_hash_cfg & bp->rss_hash_delta) in __bnxt_hwrm_vnic_set_rss()
6595 req->flags |= VNIC_RSS_CFG_REQ_FLAGS_HASH_TYPE_INCLUDE; in __bnxt_hwrm_vnic_set_rss()
6597 req->flags |= VNIC_RSS_CFG_REQ_FLAGS_HASH_TYPE_EXCLUDE; in __bnxt_hwrm_vnic_set_rss()
6599 req->hash_type = cpu_to_le32(bp->rss_hash_cfg); in __bnxt_hwrm_vnic_set_rss()
6601 req->hash_mode_flags = VNIC_RSS_CFG_REQ_HASH_MODE_FLAGS_DEFAULT; in __bnxt_hwrm_vnic_set_rss()
6602 req->ring_grp_tbl_addr = cpu_to_le64(vnic->rss_table_dma_addr); in __bnxt_hwrm_vnic_set_rss()
6603 req->hash_key_tbl_addr = cpu_to_le64(vnic->rss_hash_key_dma_addr); in __bnxt_hwrm_vnic_set_rss()
6612 if ((bp->flags & BNXT_FLAG_CHIP_P5_PLUS) || in bnxt_hwrm_vnic_set_rss()
6613 vnic->fw_rss_cos_lb_ctx[0] == INVALID_HW_RING_ID) in bnxt_hwrm_vnic_set_rss()
6622 req->rss_ctx_idx = cpu_to_le16(vnic->fw_rss_cos_lb_ctx[0]); in bnxt_hwrm_vnic_set_rss()
6638 req->vnic_id = cpu_to_le16(vnic->fw_vnic_id); in bnxt_hwrm_vnic_set_rss_p5()
6643 ring_tbl_map = vnic->rss_table_dma_addr; in bnxt_hwrm_vnic_set_rss_p5()
6644 nr_ctxs = bnxt_get_nr_rss_ctxs(bp, bp->rx_nr_rings); in bnxt_hwrm_vnic_set_rss_p5()
6648 req->ring_grp_tbl_addr = cpu_to_le64(ring_tbl_map); in bnxt_hwrm_vnic_set_rss_p5()
6649 req->ring_table_pair_index = i; in bnxt_hwrm_vnic_set_rss_p5()
6650 req->rss_ctx_idx = cpu_to_le16(vnic->fw_rss_cos_lb_ctx[i]); in bnxt_hwrm_vnic_set_rss_p5()
6663 struct bnxt_vnic_info *vnic = &bp->vnic_info[BNXT_VNIC_DEFAULT]; in bnxt_hwrm_update_rss_hash_cfg()
6670 req->vnic_id = cpu_to_le16(vnic->fw_vnic_id); in bnxt_hwrm_update_rss_hash_cfg()
6672 req->rss_ctx_idx = cpu_to_le16(vnic->fw_rss_cos_lb_ctx[0]); in bnxt_hwrm_update_rss_hash_cfg()
6675 bp->rss_hash_cfg = le32_to_cpu(resp->hash_type) ?: bp->rss_hash_cfg; in bnxt_hwrm_update_rss_hash_cfg()
6676 bp->rss_hash_delta = 0; in bnxt_hwrm_update_rss_hash_cfg()
6683 u16 hds_thresh = (u16)bp->dev->cfg_pending->hds_thresh; in bnxt_hwrm_vnic_set_hds()
6691 req->flags = cpu_to_le32(VNIC_PLCMODES_CFG_REQ_FLAGS_JUMBO_PLACEMENT); in bnxt_hwrm_vnic_set_hds()
6692 req->enables = cpu_to_le32(VNIC_PLCMODES_CFG_REQ_ENABLES_JUMBO_THRESH_VALID); in bnxt_hwrm_vnic_set_hds()
6693 req->jumbo_thresh = cpu_to_le16(bp->rx_buf_use_size); in bnxt_hwrm_vnic_set_hds()
6695 if (!BNXT_RX_PAGE_MODE(bp) && (bp->flags & BNXT_FLAG_AGG_RINGS)) { in bnxt_hwrm_vnic_set_hds()
6696 req->flags |= cpu_to_le32(VNIC_PLCMODES_CFG_REQ_FLAGS_HDS_IPV4 | in bnxt_hwrm_vnic_set_hds()
6698 req->enables |= in bnxt_hwrm_vnic_set_hds()
6700 req->hds_threshold = cpu_to_le16(hds_thresh); in bnxt_hwrm_vnic_set_hds()
6702 req->vnic_id = cpu_to_le32(vnic->fw_vnic_id); in bnxt_hwrm_vnic_set_hds()
6715 req->rss_cos_lb_ctx_id = in bnxt_hwrm_vnic_ctx_free_one()
6716 cpu_to_le16(vnic->fw_rss_cos_lb_ctx[ctx_idx]); in bnxt_hwrm_vnic_ctx_free_one()
6719 vnic->fw_rss_cos_lb_ctx[ctx_idx] = INVALID_HW_RING_ID; in bnxt_hwrm_vnic_ctx_free_one()
6726 for (i = 0; i < bp->nr_vnics; i++) { in bnxt_hwrm_vnic_ctx_free()
6727 struct bnxt_vnic_info *vnic = &bp->vnic_info[i]; in bnxt_hwrm_vnic_ctx_free()
6730 if (vnic->fw_rss_cos_lb_ctx[j] != INVALID_HW_RING_ID) in bnxt_hwrm_vnic_ctx_free()
6734 bp->rsscos_nr_ctxs = 0; in bnxt_hwrm_vnic_ctx_free()
6751 vnic->fw_rss_cos_lb_ctx[ctx_idx] = in bnxt_hwrm_vnic_ctx_alloc()
6752 le16_to_cpu(resp->rss_cos_lb_ctx_id); in bnxt_hwrm_vnic_ctx_alloc()
6760 if (bp->flags & BNXT_FLAG_ROCE_MIRROR_CAP) in bnxt_get_roce_vnic_mode()
6767 struct bnxt_vnic_info *vnic0 = &bp->vnic_info[BNXT_VNIC_DEFAULT]; in bnxt_hwrm_vnic_cfg()
6777 if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) { in bnxt_hwrm_vnic_cfg()
6778 struct bnxt_rx_ring_info *rxr = &bp->rx_ring[0]; in bnxt_hwrm_vnic_cfg()
6780 req->default_rx_ring_id = in bnxt_hwrm_vnic_cfg()
6781 cpu_to_le16(rxr->rx_ring_struct.fw_ring_id); in bnxt_hwrm_vnic_cfg()
6782 req->default_cmpl_ring_id = in bnxt_hwrm_vnic_cfg()
6784 req->enables = in bnxt_hwrm_vnic_cfg()
6789 req->enables = cpu_to_le32(VNIC_CFG_REQ_ENABLES_DFLT_RING_GRP); in bnxt_hwrm_vnic_cfg()
6791 if (vnic->fw_rss_cos_lb_ctx[0] != INVALID_HW_RING_ID) { in bnxt_hwrm_vnic_cfg()
6792 req->rss_rule = cpu_to_le16(vnic->fw_rss_cos_lb_ctx[0]); in bnxt_hwrm_vnic_cfg()
6793 req->enables |= cpu_to_le32(VNIC_CFG_REQ_ENABLES_RSS_RULE | in bnxt_hwrm_vnic_cfg()
6795 } else if (vnic->flags & BNXT_VNIC_RFS_NEW_RSS_FLAG) { in bnxt_hwrm_vnic_cfg()
6796 req->rss_rule = cpu_to_le16(vnic0->fw_rss_cos_lb_ctx[0]); in bnxt_hwrm_vnic_cfg()
6797 req->enables |= cpu_to_le32(VNIC_CFG_REQ_ENABLES_RSS_RULE | in bnxt_hwrm_vnic_cfg()
6799 req->flags |= cpu_to_le32(VNIC_CFG_REQ_FLAGS_RSS_DFLT_CR_MODE); in bnxt_hwrm_vnic_cfg()
6801 req->rss_rule = cpu_to_le16(0xffff); in bnxt_hwrm_vnic_cfg()
6805 (vnic->fw_rss_cos_lb_ctx[0] != INVALID_HW_RING_ID)) { in bnxt_hwrm_vnic_cfg()
6806 req->cos_rule = cpu_to_le16(vnic->fw_rss_cos_lb_ctx[1]); in bnxt_hwrm_vnic_cfg()
6807 req->enables |= cpu_to_le32(VNIC_CFG_REQ_ENABLES_COS_RULE); in bnxt_hwrm_vnic_cfg()
6809 req->cos_rule = cpu_to_le16(0xffff); in bnxt_hwrm_vnic_cfg()
6812 if (vnic->flags & BNXT_VNIC_RSS_FLAG) in bnxt_hwrm_vnic_cfg()
6814 else if (vnic->flags & BNXT_VNIC_RFS_FLAG) in bnxt_hwrm_vnic_cfg()
6815 ring = vnic->vnic_id - 1; in bnxt_hwrm_vnic_cfg()
6816 else if ((vnic->vnic_id == 1) && BNXT_CHIP_TYPE_NITRO_A0(bp)) in bnxt_hwrm_vnic_cfg()
6817 ring = bp->rx_nr_rings - 1; in bnxt_hwrm_vnic_cfg()
6819 grp_idx = bp->rx_ring[ring].bnapi->index; in bnxt_hwrm_vnic_cfg()
6820 req->dflt_ring_grp = cpu_to_le16(bp->grp_info[grp_idx].fw_grp_id); in bnxt_hwrm_vnic_cfg()
6821 req->lb_rule = cpu_to_le16(0xffff); in bnxt_hwrm_vnic_cfg()
6823 vnic->mru = bp->dev->mtu + ETH_HLEN + VLAN_HLEN; in bnxt_hwrm_vnic_cfg()
6824 req->mru = cpu_to_le16(vnic->mru); in bnxt_hwrm_vnic_cfg()
6826 req->vnic_id = cpu_to_le16(vnic->fw_vnic_id); in bnxt_hwrm_vnic_cfg()
6829 def_vlan = bp->vf.vlan; in bnxt_hwrm_vnic_cfg()
6831 if ((bp->flags & BNXT_FLAG_STRIP_VLAN) || def_vlan) in bnxt_hwrm_vnic_cfg()
6832 req->flags |= cpu_to_le32(VNIC_CFG_REQ_FLAGS_VLAN_STRIP_MODE); in bnxt_hwrm_vnic_cfg()
6833 if (vnic->vnic_id == BNXT_VNIC_DEFAULT && bnxt_ulp_registered(bp->edev)) in bnxt_hwrm_vnic_cfg()
6834 req->flags |= cpu_to_le32(bnxt_get_roce_vnic_mode(bp)); in bnxt_hwrm_vnic_cfg()
6842 if (vnic->fw_vnic_id != INVALID_HW_RING_ID) { in bnxt_hwrm_vnic_free_one()
6848 req->vnic_id = cpu_to_le32(vnic->fw_vnic_id); in bnxt_hwrm_vnic_free_one()
6851 vnic->fw_vnic_id = INVALID_HW_RING_ID; in bnxt_hwrm_vnic_free_one()
6859 for (i = 0; i < bp->nr_vnics; i++) in bnxt_hwrm_vnic_free()
6860 bnxt_hwrm_vnic_free_one(bp, &bp->vnic_info[i]); in bnxt_hwrm_vnic_free()
6876 if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) in bnxt_hwrm_vnic_alloc()
6881 grp_idx = bp->rx_ring[i].bnapi->index; in bnxt_hwrm_vnic_alloc()
6882 if (bp->grp_info[grp_idx].fw_grp_id == INVALID_HW_RING_ID) { in bnxt_hwrm_vnic_alloc()
6883 netdev_err(bp->dev, "Not enough ring groups avail:%x req:%x\n", in bnxt_hwrm_vnic_alloc()
6887 vnic->fw_grp_ids[j] = bp->grp_info[grp_idx].fw_grp_id; in bnxt_hwrm_vnic_alloc()
6892 vnic->fw_rss_cos_lb_ctx[i] = INVALID_HW_RING_ID; in bnxt_hwrm_vnic_alloc()
6893 if (vnic->vnic_id == BNXT_VNIC_DEFAULT) in bnxt_hwrm_vnic_alloc()
6894 req->flags = cpu_to_le32(VNIC_ALLOC_REQ_FLAGS_DEFAULT); in bnxt_hwrm_vnic_alloc()
6899 vnic->fw_vnic_id = le32_to_cpu(resp->vnic_id); in bnxt_hwrm_vnic_alloc()
6910 bp->hw_ring_stats_size = sizeof(struct ctx_hw_stats); in bnxt_hwrm_vnic_qcaps()
6911 bp->flags &= ~BNXT_FLAG_ROCE_MIRROR_CAP; in bnxt_hwrm_vnic_qcaps()
6912 bp->rss_cap &= ~BNXT_RSS_CAP_NEW_RSS_CAP; in bnxt_hwrm_vnic_qcaps()
6913 if (bp->hwrm_spec_code < 0x10600) in bnxt_hwrm_vnic_qcaps()
6923 u32 flags = le32_to_cpu(resp->flags); in bnxt_hwrm_vnic_qcaps()
6925 if (!(bp->flags & BNXT_FLAG_CHIP_P5_PLUS) && in bnxt_hwrm_vnic_qcaps()
6927 bp->rss_cap |= BNXT_RSS_CAP_NEW_RSS_CAP; in bnxt_hwrm_vnic_qcaps()
6930 bp->flags |= BNXT_FLAG_ROCE_MIRROR_CAP; in bnxt_hwrm_vnic_qcaps()
6937 !(bp->fw_cap & BNXT_FW_CAP_EXT_HW_STATS_SUPPORTED))) in bnxt_hwrm_vnic_qcaps()
6938 bp->fw_cap |= BNXT_FW_CAP_VLAN_RX_STRIP; in bnxt_hwrm_vnic_qcaps()
6940 bp->rss_cap |= BNXT_RSS_CAP_RSS_HASH_TYPE_DELTA; in bnxt_hwrm_vnic_qcaps()
6942 bp->rss_cap |= BNXT_RSS_CAP_RSS_TCAM; in bnxt_hwrm_vnic_qcaps()
6943 bp->max_tpa_v2 = le16_to_cpu(resp->max_aggs_supported); in bnxt_hwrm_vnic_qcaps()
6944 if (bp->max_tpa_v2) { in bnxt_hwrm_vnic_qcaps()
6946 bp->hw_ring_stats_size = BNXT_RING_STATS_SIZE_P5; in bnxt_hwrm_vnic_qcaps()
6948 bp->hw_ring_stats_size = BNXT_RING_STATS_SIZE_P7; in bnxt_hwrm_vnic_qcaps()
6951 bp->fw_cap |= BNXT_FW_CAP_VNIC_TUNNEL_TPA; in bnxt_hwrm_vnic_qcaps()
6953 bp->rss_cap |= BNXT_RSS_CAP_AH_V4_RSS_CAP; in bnxt_hwrm_vnic_qcaps()
6955 bp->rss_cap |= BNXT_RSS_CAP_AH_V6_RSS_CAP; in bnxt_hwrm_vnic_qcaps()
6957 bp->rss_cap |= BNXT_RSS_CAP_ESP_V4_RSS_CAP; in bnxt_hwrm_vnic_qcaps()
6959 bp->rss_cap |= BNXT_RSS_CAP_ESP_V6_RSS_CAP; in bnxt_hwrm_vnic_qcaps()
6961 bp->fw_cap |= BNXT_FW_CAP_VNIC_RE_FLUSH; in bnxt_hwrm_vnic_qcaps()
6974 if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) in bnxt_hwrm_ring_grp_alloc()
6982 for (i = 0; i < bp->rx_nr_rings; i++) { in bnxt_hwrm_ring_grp_alloc()
6983 unsigned int grp_idx = bp->rx_ring[i].bnapi->index; in bnxt_hwrm_ring_grp_alloc()
6985 req->cr = cpu_to_le16(bp->grp_info[grp_idx].cp_fw_ring_id); in bnxt_hwrm_ring_grp_alloc()
6986 req->rr = cpu_to_le16(bp->grp_info[grp_idx].rx_fw_ring_id); in bnxt_hwrm_ring_grp_alloc()
6987 req->ar = cpu_to_le16(bp->grp_info[grp_idx].agg_fw_ring_id); in bnxt_hwrm_ring_grp_alloc()
6988 req->sc = cpu_to_le16(bp->grp_info[grp_idx].fw_stats_ctx); in bnxt_hwrm_ring_grp_alloc()
6995 bp->grp_info[grp_idx].fw_grp_id = in bnxt_hwrm_ring_grp_alloc()
6996 le32_to_cpu(resp->ring_group_id); in bnxt_hwrm_ring_grp_alloc()
7007 if (!bp->grp_info || (bp->flags & BNXT_FLAG_CHIP_P5_PLUS)) in bnxt_hwrm_ring_grp_free()
7014 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_hwrm_ring_grp_free()
7015 if (bp->grp_info[i].fw_grp_id == INVALID_HW_RING_ID) in bnxt_hwrm_ring_grp_free()
7017 req->ring_group_id = in bnxt_hwrm_ring_grp_free()
7018 cpu_to_le32(bp->grp_info[i].fw_grp_id); in bnxt_hwrm_ring_grp_free()
7021 bp->grp_info[i].fw_grp_id = INVALID_HW_RING_ID; in bnxt_hwrm_ring_grp_free()
7030 struct bnxt_ring_grp_info *grp_info = &bp->grp_info[ring->grp_idx]; in bnxt_set_rx_ring_params_p5()
7035 req->ring_type = RING_ALLOC_REQ_RING_TYPE_RX_AGG; in bnxt_set_rx_ring_params_p5()
7036 req->rx_ring_id = cpu_to_le16(grp_info->rx_fw_ring_id); in bnxt_set_rx_ring_params_p5()
7037 req->rx_buf_size = cpu_to_le16(BNXT_RX_PAGE_SIZE); in bnxt_set_rx_ring_params_p5()
7040 req->rx_buf_size = cpu_to_le16(bp->rx_buf_use_size); in bnxt_set_rx_ring_params_p5()
7042 req->flags = in bnxt_set_rx_ring_params_p5()
7045 req->stat_ctx_id = cpu_to_le32(grp_info->fw_stats_ctx); in bnxt_set_rx_ring_params_p5()
7046 req->nq_ring_id = cpu_to_le16(grp_info->cp_fw_ring_id); in bnxt_set_rx_ring_params_p5()
7047 req->enables |= cpu_to_le32(enables); in bnxt_set_rx_ring_params_p5()
7056 struct bnxt_ring_mem_info *rmem = &ring->ring_mem; in hwrm_ring_alloc_send_msg()
7065 req->enables = 0; in hwrm_ring_alloc_send_msg()
7066 if (rmem->nr_pages > 1) { in hwrm_ring_alloc_send_msg()
7067 req->page_tbl_addr = cpu_to_le64(rmem->pg_tbl_map); in hwrm_ring_alloc_send_msg()
7069 req->page_size = BNXT_PAGE_SHIFT; in hwrm_ring_alloc_send_msg()
7070 req->page_tbl_depth = 1; in hwrm_ring_alloc_send_msg()
7072 req->page_tbl_addr = cpu_to_le64(rmem->dma_arr[0]); in hwrm_ring_alloc_send_msg()
7074 req->fbo = 0; in hwrm_ring_alloc_send_msg()
7076 req->logical_id = cpu_to_le16(map_index); in hwrm_ring_alloc_send_msg()
7085 req->ring_type = RING_ALLOC_REQ_RING_TYPE_TX; in hwrm_ring_alloc_send_msg()
7087 grp_info = &bp->grp_info[ring->grp_idx]; in hwrm_ring_alloc_send_msg()
7088 req->cmpl_ring_id = cpu_to_le16(bnxt_cp_ring_for_tx(bp, txr)); in hwrm_ring_alloc_send_msg()
7089 req->length = cpu_to_le32(bp->tx_ring_mask + 1); in hwrm_ring_alloc_send_msg()
7090 req->stat_ctx_id = cpu_to_le32(grp_info->fw_stats_ctx); in hwrm_ring_alloc_send_msg()
7091 req->queue_id = cpu_to_le16(ring->queue_id); in hwrm_ring_alloc_send_msg()
7092 if (bp->flags & BNXT_FLAG_TX_COAL_CMPL) in hwrm_ring_alloc_send_msg()
7093 req->cmpl_coal_cnt = in hwrm_ring_alloc_send_msg()
7095 if ((bp->fw_cap & BNXT_FW_CAP_TX_TS_CMP) && bp->ptp_cfg) in hwrm_ring_alloc_send_msg()
7097 req->flags = cpu_to_le16(flags); in hwrm_ring_alloc_send_msg()
7102 req->ring_type = RING_ALLOC_REQ_RING_TYPE_RX; in hwrm_ring_alloc_send_msg()
7103 req->length = (ring_type == HWRM_RING_ALLOC_RX) ? in hwrm_ring_alloc_send_msg()
7104 cpu_to_le32(bp->rx_ring_mask + 1) : in hwrm_ring_alloc_send_msg()
7105 cpu_to_le32(bp->rx_agg_ring_mask + 1); in hwrm_ring_alloc_send_msg()
7106 if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) in hwrm_ring_alloc_send_msg()
7110 req->ring_type = RING_ALLOC_REQ_RING_TYPE_L2_CMPL; in hwrm_ring_alloc_send_msg()
7111 req->length = cpu_to_le32(bp->cp_ring_mask + 1); in hwrm_ring_alloc_send_msg()
7112 if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) { in hwrm_ring_alloc_send_msg()
7114 grp_info = &bp->grp_info[map_index]; in hwrm_ring_alloc_send_msg()
7115 req->nq_ring_id = cpu_to_le16(grp_info->cp_fw_ring_id); in hwrm_ring_alloc_send_msg()
7116 req->cq_handle = cpu_to_le64(ring->handle); in hwrm_ring_alloc_send_msg()
7117 req->enables |= cpu_to_le32( in hwrm_ring_alloc_send_msg()
7120 req->int_mode = RING_ALLOC_REQ_INT_MODE_MSIX; in hwrm_ring_alloc_send_msg()
7124 req->ring_type = RING_ALLOC_REQ_RING_TYPE_NQ; in hwrm_ring_alloc_send_msg()
7125 req->length = cpu_to_le32(bp->cp_ring_mask + 1); in hwrm_ring_alloc_send_msg()
7126 req->int_mode = RING_ALLOC_REQ_INT_MODE_MSIX; in hwrm_ring_alloc_send_msg()
7129 netdev_err(bp->dev, "hwrm alloc invalid ring type %d\n", in hwrm_ring_alloc_send_msg()
7131 return -EINVAL; in hwrm_ring_alloc_send_msg()
7136 err = le16_to_cpu(resp->error_code); in hwrm_ring_alloc_send_msg()
7137 ring_id = le16_to_cpu(resp->ring_id); in hwrm_ring_alloc_send_msg()
7142 netdev_err(bp->dev, "hwrm_ring_alloc type %d failed. rc:%x err:%x\n", in hwrm_ring_alloc_send_msg()
7144 return -EIO; in hwrm_ring_alloc_send_msg()
7146 ring->fw_ring_id = ring_id; in hwrm_ring_alloc_send_msg()
7161 req->fid = cpu_to_le16(0xffff); in bnxt_hwrm_set_async_event_cr()
7162 req->enables = cpu_to_le32(FUNC_CFG_REQ_ENABLES_ASYNC_EVENT_CR); in bnxt_hwrm_set_async_event_cr()
7163 req->async_event_cr = cpu_to_le16(idx); in bnxt_hwrm_set_async_event_cr()
7172 req->enables = in bnxt_hwrm_set_async_event_cr()
7174 req->async_event_cr = cpu_to_le16(idx); in bnxt_hwrm_set_async_event_cr()
7184 db->db_ring_mask = bp->tx_ring_mask; in bnxt_set_db_mask()
7187 db->db_ring_mask = bp->rx_ring_mask; in bnxt_set_db_mask()
7190 db->db_ring_mask = bp->rx_agg_ring_mask; in bnxt_set_db_mask()
7194 db->db_ring_mask = bp->cp_ring_mask; in bnxt_set_db_mask()
7197 if (bp->flags & BNXT_FLAG_CHIP_P7) { in bnxt_set_db_mask()
7198 db->db_epoch_mask = db->db_ring_mask + 1; in bnxt_set_db_mask()
7199 db->db_epoch_shift = DBR_EPOCH_SFT - ilog2(db->db_epoch_mask); in bnxt_set_db_mask()
7206 if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) { in bnxt_set_db()
7209 db->db_key64 = DBR_PATH_L2 | DBR_TYPE_SQ; in bnxt_set_db()
7213 db->db_key64 = DBR_PATH_L2 | DBR_TYPE_SRQ; in bnxt_set_db()
7216 db->db_key64 = DBR_PATH_L2; in bnxt_set_db()
7219 db->db_key64 = DBR_PATH_L2; in bnxt_set_db()
7222 db->db_key64 |= (u64)xid << DBR_XID_SFT; in bnxt_set_db()
7224 if (bp->flags & BNXT_FLAG_CHIP_P7) in bnxt_set_db()
7225 db->db_key64 |= DBR_VALID; in bnxt_set_db()
7227 db->doorbell = bp->bar1 + bp->db_offset; in bnxt_set_db()
7229 db->doorbell = bp->bar1 + map_idx * 0x80; in bnxt_set_db()
7232 db->db_key32 = DB_KEY_TX; in bnxt_set_db()
7236 db->db_key32 = DB_KEY_RX; in bnxt_set_db()
7239 db->db_key32 = DB_KEY_CP; in bnxt_set_db()
7249 struct bnxt_ring_struct *ring = &rxr->rx_ring_struct; in bnxt_hwrm_rx_ring_alloc()
7250 struct bnxt_napi *bnapi = rxr->bnapi; in bnxt_hwrm_rx_ring_alloc()
7252 u32 map_idx = bnapi->index; in bnxt_hwrm_rx_ring_alloc()
7259 bnxt_set_db(bp, &rxr->rx_db, type, map_idx, ring->fw_ring_id); in bnxt_hwrm_rx_ring_alloc()
7260 bp->grp_info[map_idx].rx_fw_ring_id = ring->fw_ring_id; in bnxt_hwrm_rx_ring_alloc()
7268 struct bnxt_ring_struct *ring = &rxr->rx_agg_ring_struct; in bnxt_hwrm_rx_agg_ring_alloc()
7270 u32 grp_idx = ring->grp_idx; in bnxt_hwrm_rx_agg_ring_alloc()
7274 map_idx = grp_idx + bp->rx_nr_rings; in bnxt_hwrm_rx_agg_ring_alloc()
7279 bnxt_set_db(bp, &rxr->rx_agg_db, type, map_idx, in bnxt_hwrm_rx_agg_ring_alloc()
7280 ring->fw_ring_id); in bnxt_hwrm_rx_agg_ring_alloc()
7281 bnxt_db_write(bp, &rxr->rx_agg_db, rxr->rx_agg_prod); in bnxt_hwrm_rx_agg_ring_alloc()
7282 bnxt_db_write(bp, &rxr->rx_db, rxr->rx_prod); in bnxt_hwrm_rx_agg_ring_alloc()
7283 bp->grp_info[grp_idx].agg_fw_ring_id = ring->fw_ring_id; in bnxt_hwrm_rx_agg_ring_alloc()
7292 struct bnxt_napi *bnapi = cpr->bnapi; in bnxt_hwrm_cp_ring_alloc_p5()
7294 u32 map_idx = bnapi->index; in bnxt_hwrm_cp_ring_alloc_p5()
7297 ring = &cpr->cp_ring_struct; in bnxt_hwrm_cp_ring_alloc_p5()
7298 ring->handle = BNXT_SET_NQ_HDL(cpr); in bnxt_hwrm_cp_ring_alloc_p5()
7302 bnxt_set_db(bp, &cpr->cp_db, type, map_idx, ring->fw_ring_id); in bnxt_hwrm_cp_ring_alloc_p5()
7303 bnxt_db_cq(bp, &cpr->cp_db, cpr->cp_raw_cons); in bnxt_hwrm_cp_ring_alloc_p5()
7310 struct bnxt_ring_struct *ring = &txr->tx_ring_struct; in bnxt_hwrm_tx_ring_alloc()
7317 bnxt_set_db(bp, &txr->tx_db, type, tx_idx, ring->fw_ring_id); in bnxt_hwrm_tx_ring_alloc()
7323 bool agg_rings = !!(bp->flags & BNXT_FLAG_AGG_RINGS); in bnxt_hwrm_ring_alloc()
7327 if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) in bnxt_hwrm_ring_alloc()
7331 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_hwrm_ring_alloc()
7332 struct bnxt_napi *bnapi = bp->bnapi[i]; in bnxt_hwrm_ring_alloc()
7333 struct bnxt_cp_ring_info *cpr = &bnapi->cp_ring; in bnxt_hwrm_ring_alloc()
7334 struct bnxt_ring_struct *ring = &cpr->cp_ring_struct; in bnxt_hwrm_ring_alloc()
7335 u32 map_idx = ring->map_idx; in bnxt_hwrm_ring_alloc()
7338 vector = bp->irq_tbl[map_idx].vector; in bnxt_hwrm_ring_alloc()
7345 bnxt_set_db(bp, &cpr->cp_db, type, map_idx, ring->fw_ring_id); in bnxt_hwrm_ring_alloc()
7346 bnxt_db_nq(bp, &cpr->cp_db, cpr->cp_raw_cons); in bnxt_hwrm_ring_alloc()
7348 bp->grp_info[i].cp_fw_ring_id = ring->fw_ring_id; in bnxt_hwrm_ring_alloc()
7351 rc = bnxt_hwrm_set_async_event_cr(bp, ring->fw_ring_id); in bnxt_hwrm_ring_alloc()
7353 netdev_warn(bp->dev, "Failed to set async event completion ring.\n"); in bnxt_hwrm_ring_alloc()
7357 for (i = 0; i < bp->tx_nr_rings; i++) { in bnxt_hwrm_ring_alloc()
7358 struct bnxt_tx_ring_info *txr = &bp->tx_ring[i]; in bnxt_hwrm_ring_alloc()
7360 if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) { in bnxt_hwrm_ring_alloc()
7361 rc = bnxt_hwrm_cp_ring_alloc_p5(bp, txr->tx_cpr); in bnxt_hwrm_ring_alloc()
7370 for (i = 0; i < bp->rx_nr_rings; i++) { in bnxt_hwrm_ring_alloc()
7371 struct bnxt_rx_ring_info *rxr = &bp->rx_ring[i]; in bnxt_hwrm_ring_alloc()
7378 bnxt_db_write(bp, &rxr->rx_db, rxr->rx_prod); in bnxt_hwrm_ring_alloc()
7379 if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) { in bnxt_hwrm_ring_alloc()
7380 rc = bnxt_hwrm_cp_ring_alloc_p5(bp, rxr->rx_cpr); in bnxt_hwrm_ring_alloc()
7387 for (i = 0; i < bp->rx_nr_rings; i++) { in bnxt_hwrm_ring_alloc()
7388 rc = bnxt_hwrm_rx_agg_ring_alloc(bp, &bp->rx_ring[i]); in bnxt_hwrm_ring_alloc()
7404 if (!bp->bnapi || test_bit(BNXT_STATE_NAPI_DISABLED, &bp->state)) in bnxt_cancel_dim()
7409 for (i = 0; i < bp->rx_nr_rings; i++) { in bnxt_cancel_dim()
7410 struct bnxt_rx_ring_info *rxr = &bp->rx_ring[i]; in bnxt_cancel_dim()
7411 struct bnxt_napi *bnapi = rxr->bnapi; in bnxt_cancel_dim()
7413 cancel_work_sync(&bnapi->cp_ring.dim.work); in bnxt_cancel_dim()
7433 req->cmpl_ring = cpu_to_le16(cmpl_ring_id); in hwrm_ring_free_send_msg()
7434 req->ring_type = ring_type; in hwrm_ring_free_send_msg()
7435 req->ring_id = cpu_to_le16(ring->fw_ring_id); in hwrm_ring_free_send_msg()
7439 error_code = le16_to_cpu(resp->error_code); in hwrm_ring_free_send_msg()
7443 netdev_err(bp->dev, "hwrm_ring_free type %d failed. rc:%x err:%x\n", in hwrm_ring_free_send_msg()
7445 return -EIO; in hwrm_ring_free_send_msg()
7454 struct bnxt_ring_struct *ring = &txr->tx_ring_struct; in bnxt_hwrm_tx_ring_free()
7457 if (ring->fw_ring_id == INVALID_HW_RING_ID) in bnxt_hwrm_tx_ring_free()
7464 ring->fw_ring_id = INVALID_HW_RING_ID; in bnxt_hwrm_tx_ring_free()
7471 struct bnxt_ring_struct *ring = &rxr->rx_ring_struct; in bnxt_hwrm_rx_ring_free()
7472 u32 grp_idx = rxr->bnapi->index; in bnxt_hwrm_rx_ring_free()
7475 if (ring->fw_ring_id == INVALID_HW_RING_ID) in bnxt_hwrm_rx_ring_free()
7483 ring->fw_ring_id = INVALID_HW_RING_ID; in bnxt_hwrm_rx_ring_free()
7484 bp->grp_info[grp_idx].rx_fw_ring_id = INVALID_HW_RING_ID; in bnxt_hwrm_rx_ring_free()
7491 struct bnxt_ring_struct *ring = &rxr->rx_agg_ring_struct; in bnxt_hwrm_rx_agg_ring_free()
7492 u32 grp_idx = rxr->bnapi->index; in bnxt_hwrm_rx_agg_ring_free()
7495 if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) in bnxt_hwrm_rx_agg_ring_free()
7500 if (ring->fw_ring_id == INVALID_HW_RING_ID) in bnxt_hwrm_rx_agg_ring_free()
7507 ring->fw_ring_id = INVALID_HW_RING_ID; in bnxt_hwrm_rx_agg_ring_free()
7508 bp->grp_info[grp_idx].agg_fw_ring_id = INVALID_HW_RING_ID; in bnxt_hwrm_rx_agg_ring_free()
7516 ring = &cpr->cp_ring_struct; in bnxt_hwrm_cp_ring_free()
7517 if (ring->fw_ring_id == INVALID_HW_RING_ID) in bnxt_hwrm_cp_ring_free()
7522 ring->fw_ring_id = INVALID_HW_RING_ID; in bnxt_hwrm_cp_ring_free()
7527 struct bnxt_ring_struct *ring = &cpr->cp_ring_struct; in bnxt_clear_one_cp_ring()
7528 int i, size = ring->ring_mem.page_size; in bnxt_clear_one_cp_ring()
7530 cpr->cp_raw_cons = 0; in bnxt_clear_one_cp_ring()
7531 cpr->toggle = 0; in bnxt_clear_one_cp_ring()
7533 for (i = 0; i < bp->cp_nr_pages; i++) in bnxt_clear_one_cp_ring()
7534 if (cpr->cp_desc_ring[i]) in bnxt_clear_one_cp_ring()
7535 memset(cpr->cp_desc_ring[i], 0, size); in bnxt_clear_one_cp_ring()
7543 if (!bp->bnapi) in bnxt_hwrm_ring_free()
7546 for (i = 0; i < bp->tx_nr_rings; i++) in bnxt_hwrm_ring_free()
7547 bnxt_hwrm_tx_ring_free(bp, &bp->tx_ring[i], close_path); in bnxt_hwrm_ring_free()
7550 for (i = 0; i < bp->rx_nr_rings; i++) { in bnxt_hwrm_ring_free()
7551 bnxt_hwrm_rx_ring_free(bp, &bp->rx_ring[i], close_path); in bnxt_hwrm_ring_free()
7552 bnxt_hwrm_rx_agg_ring_free(bp, &bp->rx_ring[i], close_path); in bnxt_hwrm_ring_free()
7561 if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) in bnxt_hwrm_ring_free()
7565 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_hwrm_ring_free()
7566 struct bnxt_napi *bnapi = bp->bnapi[i]; in bnxt_hwrm_ring_free()
7567 struct bnxt_cp_ring_info *cpr = &bnapi->cp_ring; in bnxt_hwrm_ring_free()
7571 for (j = 0; j < cpr->cp_ring_count && cpr->cp_ring_arr; j++) in bnxt_hwrm_ring_free()
7572 bnxt_hwrm_cp_ring_free(bp, &cpr->cp_ring_arr[j]); in bnxt_hwrm_ring_free()
7574 ring = &cpr->cp_ring_struct; in bnxt_hwrm_ring_free()
7575 if (ring->fw_ring_id != INVALID_HW_RING_ID) { in bnxt_hwrm_ring_free()
7578 ring->fw_ring_id = INVALID_HW_RING_ID; in bnxt_hwrm_ring_free()
7579 bp->grp_info[i].cp_fw_ring_id = INVALID_HW_RING_ID; in bnxt_hwrm_ring_free()
7591 struct bnxt_hw_resc *hw_resc = &bp->hw_resc; in bnxt_hwrm_get_rings()
7596 if (bp->hwrm_spec_code < 0x10601) in bnxt_hwrm_get_rings()
7603 req->fid = cpu_to_le16(0xffff); in bnxt_hwrm_get_rings()
7611 hw_resc->resv_tx_rings = le16_to_cpu(resp->alloc_tx_rings); in bnxt_hwrm_get_rings()
7615 hw_resc->resv_rx_rings = le16_to_cpu(resp->alloc_rx_rings); in bnxt_hwrm_get_rings()
7616 hw_resc->resv_hw_ring_grps = in bnxt_hwrm_get_rings()
7617 le32_to_cpu(resp->alloc_hw_ring_grps); in bnxt_hwrm_get_rings()
7618 hw_resc->resv_vnics = le16_to_cpu(resp->alloc_vnics); in bnxt_hwrm_get_rings()
7619 hw_resc->resv_rsscos_ctxs = le16_to_cpu(resp->alloc_rsscos_ctx); in bnxt_hwrm_get_rings()
7620 cp = le16_to_cpu(resp->alloc_cmpl_rings); in bnxt_hwrm_get_rings()
7621 stats = le16_to_cpu(resp->alloc_stat_ctx); in bnxt_hwrm_get_rings()
7622 hw_resc->resv_irqs = cp; in bnxt_hwrm_get_rings()
7623 if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) { in bnxt_hwrm_get_rings()
7624 int rx = hw_resc->resv_rx_rings; in bnxt_hwrm_get_rings()
7625 int tx = hw_resc->resv_tx_rings; in bnxt_hwrm_get_rings()
7627 if (bp->flags & BNXT_FLAG_AGG_RINGS) in bnxt_hwrm_get_rings()
7628 rx >>= 1; in bnxt_hwrm_get_rings()
7633 if (bp->flags & BNXT_FLAG_AGG_RINGS) in bnxt_hwrm_get_rings()
7634 rx <<= 1; in bnxt_hwrm_get_rings()
7635 hw_resc->resv_rx_rings = rx; in bnxt_hwrm_get_rings()
7636 hw_resc->resv_tx_rings = tx; in bnxt_hwrm_get_rings()
7638 hw_resc->resv_irqs = le16_to_cpu(resp->alloc_msix); in bnxt_hwrm_get_rings()
7639 hw_resc->resv_hw_ring_grps = rx; in bnxt_hwrm_get_rings()
7641 hw_resc->resv_cp_rings = cp; in bnxt_hwrm_get_rings()
7642 hw_resc->resv_stat_ctxs = stats; in bnxt_hwrm_get_rings()
7655 if (bp->hwrm_spec_code < 0x10601) in __bnxt_hwrm_get_tx_rings()
7662 req->fid = cpu_to_le16(fid); in __bnxt_hwrm_get_tx_rings()
7666 *tx_rings = le16_to_cpu(resp->alloc_tx_rings); in __bnxt_hwrm_get_tx_rings()
7683 req->fid = cpu_to_le16(0xffff); in __bnxt_hwrm_reserve_pf_rings()
7684 enables |= hwr->tx ? FUNC_CFG_REQ_ENABLES_NUM_TX_RINGS : 0; in __bnxt_hwrm_reserve_pf_rings()
7685 req->num_tx_rings = cpu_to_le16(hwr->tx); in __bnxt_hwrm_reserve_pf_rings()
7687 enables |= hwr->rx ? FUNC_CFG_REQ_ENABLES_NUM_RX_RINGS : 0; in __bnxt_hwrm_reserve_pf_rings()
7688 enables |= hwr->stat ? FUNC_CFG_REQ_ENABLES_NUM_STAT_CTXS : 0; in __bnxt_hwrm_reserve_pf_rings()
7689 if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) { in __bnxt_hwrm_reserve_pf_rings()
7690 enables |= hwr->cp ? FUNC_CFG_REQ_ENABLES_NUM_MSIX : 0; in __bnxt_hwrm_reserve_pf_rings()
7691 enables |= hwr->cp_p5 ? in __bnxt_hwrm_reserve_pf_rings()
7694 enables |= hwr->cp ? in __bnxt_hwrm_reserve_pf_rings()
7696 enables |= hwr->grp ? in __bnxt_hwrm_reserve_pf_rings()
7699 enables |= hwr->vnic ? FUNC_CFG_REQ_ENABLES_NUM_VNICS : 0; in __bnxt_hwrm_reserve_pf_rings()
7700 enables |= hwr->rss_ctx ? FUNC_CFG_REQ_ENABLES_NUM_RSSCOS_CTXS : in __bnxt_hwrm_reserve_pf_rings()
7702 req->num_rx_rings = cpu_to_le16(hwr->rx); in __bnxt_hwrm_reserve_pf_rings()
7703 req->num_rsscos_ctxs = cpu_to_le16(hwr->rss_ctx); in __bnxt_hwrm_reserve_pf_rings()
7704 if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) { in __bnxt_hwrm_reserve_pf_rings()
7705 req->num_cmpl_rings = cpu_to_le16(hwr->cp_p5); in __bnxt_hwrm_reserve_pf_rings()
7706 req->num_msix = cpu_to_le16(hwr->cp); in __bnxt_hwrm_reserve_pf_rings()
7708 req->num_cmpl_rings = cpu_to_le16(hwr->cp); in __bnxt_hwrm_reserve_pf_rings()
7709 req->num_hw_ring_grps = cpu_to_le16(hwr->grp); in __bnxt_hwrm_reserve_pf_rings()
7711 req->num_stat_ctxs = cpu_to_le16(hwr->stat); in __bnxt_hwrm_reserve_pf_rings()
7712 req->num_vnics = cpu_to_le16(hwr->vnic); in __bnxt_hwrm_reserve_pf_rings()
7714 req->enables = cpu_to_le32(enables); in __bnxt_hwrm_reserve_pf_rings()
7727 enables |= hwr->tx ? FUNC_VF_CFG_REQ_ENABLES_NUM_TX_RINGS : 0; in __bnxt_hwrm_reserve_vf_rings()
7728 enables |= hwr->rx ? FUNC_VF_CFG_REQ_ENABLES_NUM_RX_RINGS | in __bnxt_hwrm_reserve_vf_rings()
7730 enables |= hwr->stat ? FUNC_VF_CFG_REQ_ENABLES_NUM_STAT_CTXS : 0; in __bnxt_hwrm_reserve_vf_rings()
7731 enables |= hwr->rss_ctx ? FUNC_VF_CFG_REQ_ENABLES_NUM_RSSCOS_CTXS : 0; in __bnxt_hwrm_reserve_vf_rings()
7732 if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) { in __bnxt_hwrm_reserve_vf_rings()
7733 enables |= hwr->cp_p5 ? in __bnxt_hwrm_reserve_vf_rings()
7736 enables |= hwr->cp ? FUNC_VF_CFG_REQ_ENABLES_NUM_CMPL_RINGS : 0; in __bnxt_hwrm_reserve_vf_rings()
7737 enables |= hwr->grp ? in __bnxt_hwrm_reserve_vf_rings()
7740 enables |= hwr->vnic ? FUNC_VF_CFG_REQ_ENABLES_NUM_VNICS : 0; in __bnxt_hwrm_reserve_vf_rings()
7743 req->num_l2_ctxs = cpu_to_le16(BNXT_VF_MAX_L2_CTX); in __bnxt_hwrm_reserve_vf_rings()
7744 req->num_tx_rings = cpu_to_le16(hwr->tx); in __bnxt_hwrm_reserve_vf_rings()
7745 req->num_rx_rings = cpu_to_le16(hwr->rx); in __bnxt_hwrm_reserve_vf_rings()
7746 req->num_rsscos_ctxs = cpu_to_le16(hwr->rss_ctx); in __bnxt_hwrm_reserve_vf_rings()
7747 if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) { in __bnxt_hwrm_reserve_vf_rings()
7748 req->num_cmpl_rings = cpu_to_le16(hwr->cp_p5); in __bnxt_hwrm_reserve_vf_rings()
7750 req->num_cmpl_rings = cpu_to_le16(hwr->cp); in __bnxt_hwrm_reserve_vf_rings()
7751 req->num_hw_ring_grps = cpu_to_le16(hwr->grp); in __bnxt_hwrm_reserve_vf_rings()
7753 req->num_stat_ctxs = cpu_to_le16(hwr->stat); in __bnxt_hwrm_reserve_vf_rings()
7754 req->num_vnics = cpu_to_le16(hwr->vnic); in __bnxt_hwrm_reserve_vf_rings()
7756 req->enables = cpu_to_le32(enables); in __bnxt_hwrm_reserve_vf_rings()
7768 return -ENOMEM; in bnxt_hwrm_reserve_pf_rings()
7770 if (!req->enables) { in bnxt_hwrm_reserve_pf_rings()
7779 if (bp->hwrm_spec_code < 0x10601) in bnxt_hwrm_reserve_pf_rings()
7780 bp->hw_resc.resv_tx_rings = hwr->tx; in bnxt_hwrm_reserve_pf_rings()
7792 bp->hw_resc.resv_tx_rings = hwr->tx; in bnxt_hwrm_reserve_vf_rings()
7798 return -ENOMEM; in bnxt_hwrm_reserve_vf_rings()
7817 return bp->cp_nr_rings + bnxt_get_ulp_msix_num(bp); in bnxt_nq_rings_in_use()
7824 if (!(bp->flags & BNXT_FLAG_CHIP_P5_PLUS)) in bnxt_cp_rings_in_use()
7827 cp = bp->tx_nr_rings + bp->rx_nr_rings; in bnxt_cp_rings_in_use()
7833 return bp->cp_nr_rings + bnxt_get_ulp_stat_ctxs(bp); in bnxt_get_func_stat_ctxs()
7838 if (!hwr->grp) in bnxt_get_total_rss_ctxs()
7840 if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) { in bnxt_get_total_rss_ctxs()
7841 int rss_ctx = bnxt_get_nr_rss_ctxs(bp, hwr->grp); in bnxt_get_total_rss_ctxs()
7844 rss_ctx *= hwr->vnic; in bnxt_get_total_rss_ctxs()
7849 if (!(bp->rss_cap & BNXT_RSS_CAP_NEW_RSS_CAP) && bnxt_rfs_supported(bp)) in bnxt_get_total_rss_ctxs()
7850 return hwr->grp + 1; in bnxt_get_total_rss_ctxs()
7851 return 1; in bnxt_get_total_rss_ctxs()
7859 struct bnxt_hw_resc *hw_resc = &bp->hw_resc; in bnxt_check_rss_tbl_no_rmgr()
7862 if (hw_resc->resv_rx_rings != bp->rx_nr_rings) { in bnxt_check_rss_tbl_no_rmgr()
7863 hw_resc->resv_rx_rings = bp->rx_nr_rings; in bnxt_check_rss_tbl_no_rmgr()
7864 if (!netif_is_rxfh_configured(bp->dev)) in bnxt_check_rss_tbl_no_rmgr()
7871 if (bp->flags & BNXT_FLAG_RFS) { in bnxt_get_total_vnics()
7873 return 2 + bp->num_rss_ctx; in bnxt_get_total_vnics()
7874 if (!(bp->flags & BNXT_FLAG_CHIP_P5_PLUS)) in bnxt_get_total_vnics()
7875 return rx_rings + 1; in bnxt_get_total_vnics()
7877 return 1; in bnxt_get_total_vnics()
7882 struct bnxt_hw_resc *hw_resc = &bp->hw_resc; in bnxt_need_reserve_rings()
7885 int rx = bp->rx_nr_rings, stat; in bnxt_need_reserve_rings()
7896 if (hw_resc->resv_tx_rings != bp->tx_nr_rings && in bnxt_need_reserve_rings()
7897 bp->hwrm_spec_code >= 0x10601) in bnxt_need_reserve_rings()
7905 if (bp->flags & BNXT_FLAG_AGG_RINGS) in bnxt_need_reserve_rings()
7906 rx <<= 1; in bnxt_need_reserve_rings()
7908 if (hw_resc->resv_rx_rings != rx || hw_resc->resv_cp_rings != cp || in bnxt_need_reserve_rings()
7909 hw_resc->resv_vnics != vnic || hw_resc->resv_stat_ctxs != stat || in bnxt_need_reserve_rings()
7910 (hw_resc->resv_hw_ring_grps != grp && in bnxt_need_reserve_rings()
7911 !(bp->flags & BNXT_FLAG_CHIP_P5_PLUS))) in bnxt_need_reserve_rings()
7913 if ((bp->flags & BNXT_FLAG_CHIP_P5_PLUS) && BNXT_PF(bp) && in bnxt_need_reserve_rings()
7914 hw_resc->resv_irqs != nq) in bnxt_need_reserve_rings()
7921 struct bnxt_hw_resc *hw_resc = &bp->hw_resc; in bnxt_copy_reserved_rings()
7923 hwr->tx = hw_resc->resv_tx_rings; in bnxt_copy_reserved_rings()
7925 hwr->rx = hw_resc->resv_rx_rings; in bnxt_copy_reserved_rings()
7926 hwr->cp = hw_resc->resv_irqs; in bnxt_copy_reserved_rings()
7927 if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) in bnxt_copy_reserved_rings()
7928 hwr->cp_p5 = hw_resc->resv_cp_rings; in bnxt_copy_reserved_rings()
7929 hwr->grp = hw_resc->resv_hw_ring_grps; in bnxt_copy_reserved_rings()
7930 hwr->vnic = hw_resc->resv_vnics; in bnxt_copy_reserved_rings()
7931 hwr->stat = hw_resc->resv_stat_ctxs; in bnxt_copy_reserved_rings()
7932 hwr->rss_ctx = hw_resc->resv_rsscos_ctxs; in bnxt_copy_reserved_rings()
7938 return hwr->tx && hwr->rx && hwr->cp && hwr->grp && hwr->vnic && in bnxt_rings_ok()
7939 hwr->stat && (hwr->cp_p5 || !(bp->flags & BNXT_FLAG_CHIP_P5_PLUS)); in bnxt_rings_ok()
7948 int cp = bp->cp_nr_rings; in __bnxt_reserve_rings()
7956 if (BNXT_NEW_RM(bp) && !bnxt_ulp_registered(bp->edev)) { in __bnxt_reserve_rings()
7957 ulp_msix = bnxt_get_avail_msix(bp, bp->ulp_num_msix_want); in __bnxt_reserve_rings()
7961 if (ulp_msix > bp->ulp_num_msix_want) in __bnxt_reserve_rings()
7962 ulp_msix = bp->ulp_num_msix_want; in __bnxt_reserve_rings()
7968 hwr.tx = bp->tx_nr_rings; in __bnxt_reserve_rings()
7969 hwr.rx = bp->rx_nr_rings; in __bnxt_reserve_rings()
7970 if (bp->flags & BNXT_FLAG_SHARED_RINGS) in __bnxt_reserve_rings()
7972 if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) in __bnxt_reserve_rings()
7977 if (bp->flags & BNXT_FLAG_AGG_RINGS) in __bnxt_reserve_rings()
7978 hwr.rx <<= 1; in __bnxt_reserve_rings()
7979 hwr.grp = bp->rx_nr_rings; in __bnxt_reserve_rings()
7982 old_rx_rings = bp->hw_resc.resv_rx_rings; in __bnxt_reserve_rings()
7991 if (bp->flags & BNXT_FLAG_AGG_RINGS) { in __bnxt_reserve_rings()
7993 rx_rings = hwr.rx >> 1; in __bnxt_reserve_rings()
7995 if (netif_running(bp->dev)) in __bnxt_reserve_rings()
7996 return -ENOMEM; in __bnxt_reserve_rings()
7998 bp->flags &= ~BNXT_FLAG_AGG_RINGS; in __bnxt_reserve_rings()
7999 bp->flags |= BNXT_FLAG_NO_AGG_RINGS; in __bnxt_reserve_rings()
8000 bp->dev->hw_features &= ~NETIF_F_LRO; in __bnxt_reserve_rings()
8001 bp->dev->features &= ~NETIF_F_LRO; in __bnxt_reserve_rings()
8006 hwr.cp = min_t(int, hwr.cp, bp->cp_nr_rings); in __bnxt_reserve_rings()
8008 hwr.stat -= bnxt_get_ulp_stat_ctxs(bp); in __bnxt_reserve_rings()
8011 if (bp->flags & BNXT_FLAG_AGG_RINGS) in __bnxt_reserve_rings()
8012 hwr.rx = rx_rings << 1; in __bnxt_reserve_rings()
8015 bp->tx_nr_rings = hwr.tx; in __bnxt_reserve_rings()
8020 if (rx_rings != bp->rx_nr_rings) { in __bnxt_reserve_rings()
8021 netdev_warn(bp->dev, "Able to reserve only %d out of %d requested RX rings\n", in __bnxt_reserve_rings()
8022 rx_rings, bp->rx_nr_rings); in __bnxt_reserve_rings()
8023 if (netif_is_rxfh_configured(bp->dev) && in __bnxt_reserve_rings()
8024 (bnxt_get_nr_rss_ctxs(bp, bp->rx_nr_rings) != in __bnxt_reserve_rings()
8027 netdev_warn(bp->dev, "RSS table entries reverting to default\n"); in __bnxt_reserve_rings()
8028 bp->dev->priv_flags &= ~IFF_RXFH_CONFIGURED; in __bnxt_reserve_rings()
8031 bp->rx_nr_rings = rx_rings; in __bnxt_reserve_rings()
8032 bp->cp_nr_rings = hwr.cp; in __bnxt_reserve_rings()
8035 return -ENOMEM; in __bnxt_reserve_rings()
8037 if (old_rx_rings != bp->hw_resc.resv_rx_rings && in __bnxt_reserve_rings()
8038 !netif_is_rxfh_configured(bp->dev)) in __bnxt_reserve_rings()
8041 if (!bnxt_ulp_registered(bp->edev) && BNXT_NEW_RM(bp)) { in __bnxt_reserve_rings()
8045 hw_resc = &bp->hw_resc; in __bnxt_reserve_rings()
8046 resv_msix = hw_resc->resv_irqs - bp->cp_nr_rings; in __bnxt_reserve_rings()
8049 resv_ctx = hw_resc->resv_stat_ctxs - bp->cp_nr_rings; in __bnxt_reserve_rings()
8072 if (!(bp->flags & BNXT_FLAG_CHIP_P5_PLUS)) in bnxt_hwrm_check_vf_rings()
8075 req->flags = cpu_to_le32(flags); in bnxt_hwrm_check_vf_rings()
8091 if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) in bnxt_hwrm_check_pf_rings()
8098 req->flags = cpu_to_le32(flags); in bnxt_hwrm_check_pf_rings()
8104 if (bp->hwrm_spec_code < 0x10801) in bnxt_hwrm_check_rings()
8115 struct bnxt_coal_cap *coal_cap = &bp->coal_cap; in bnxt_hwrm_coal_params_qcaps()
8120 coal_cap->cmpl_params = BNXT_LEGACY_COAL_CMPL_PARAMS; in bnxt_hwrm_coal_params_qcaps()
8121 coal_cap->num_cmpl_dma_aggr_max = 63; in bnxt_hwrm_coal_params_qcaps()
8122 coal_cap->num_cmpl_dma_aggr_during_int_max = 63; in bnxt_hwrm_coal_params_qcaps()
8123 coal_cap->cmpl_aggr_dma_tmr_max = 65535; in bnxt_hwrm_coal_params_qcaps()
8124 coal_cap->cmpl_aggr_dma_tmr_during_int_max = 65535; in bnxt_hwrm_coal_params_qcaps()
8125 coal_cap->int_lat_tmr_min_max = 65535; in bnxt_hwrm_coal_params_qcaps()
8126 coal_cap->int_lat_tmr_max_max = 65535; in bnxt_hwrm_coal_params_qcaps()
8127 coal_cap->num_cmpl_aggr_int_max = 65535; in bnxt_hwrm_coal_params_qcaps()
8128 coal_cap->timer_units = 80; in bnxt_hwrm_coal_params_qcaps()
8130 if (bp->hwrm_spec_code < 0x10902) in bnxt_hwrm_coal_params_qcaps()
8139 coal_cap->cmpl_params = le32_to_cpu(resp->cmpl_params); in bnxt_hwrm_coal_params_qcaps()
8140 coal_cap->nq_params = le32_to_cpu(resp->nq_params); in bnxt_hwrm_coal_params_qcaps()
8141 coal_cap->num_cmpl_dma_aggr_max = in bnxt_hwrm_coal_params_qcaps()
8142 le16_to_cpu(resp->num_cmpl_dma_aggr_max); in bnxt_hwrm_coal_params_qcaps()
8143 coal_cap->num_cmpl_dma_aggr_during_int_max = in bnxt_hwrm_coal_params_qcaps()
8144 le16_to_cpu(resp->num_cmpl_dma_aggr_during_int_max); in bnxt_hwrm_coal_params_qcaps()
8145 coal_cap->cmpl_aggr_dma_tmr_max = in bnxt_hwrm_coal_params_qcaps()
8146 le16_to_cpu(resp->cmpl_aggr_dma_tmr_max); in bnxt_hwrm_coal_params_qcaps()
8147 coal_cap->cmpl_aggr_dma_tmr_during_int_max = in bnxt_hwrm_coal_params_qcaps()
8148 le16_to_cpu(resp->cmpl_aggr_dma_tmr_during_int_max); in bnxt_hwrm_coal_params_qcaps()
8149 coal_cap->int_lat_tmr_min_max = in bnxt_hwrm_coal_params_qcaps()
8150 le16_to_cpu(resp->int_lat_tmr_min_max); in bnxt_hwrm_coal_params_qcaps()
8151 coal_cap->int_lat_tmr_max_max = in bnxt_hwrm_coal_params_qcaps()
8152 le16_to_cpu(resp->int_lat_tmr_max_max); in bnxt_hwrm_coal_params_qcaps()
8153 coal_cap->num_cmpl_aggr_int_max = in bnxt_hwrm_coal_params_qcaps()
8154 le16_to_cpu(resp->num_cmpl_aggr_int_max); in bnxt_hwrm_coal_params_qcaps()
8155 coal_cap->timer_units = le16_to_cpu(resp->timer_units); in bnxt_hwrm_coal_params_qcaps()
8162 struct bnxt_coal_cap *coal_cap = &bp->coal_cap; in bnxt_usec_to_coal_tmr()
8164 return usec * 1000 / coal_cap->timer_units; in bnxt_usec_to_coal_tmr()
8171 struct bnxt_coal_cap *coal_cap = &bp->coal_cap; in bnxt_hwrm_set_coal_params()
8172 u16 val, tmr, max, flags = hw_coal->flags; in bnxt_hwrm_set_coal_params()
8173 u32 cmpl_params = coal_cap->cmpl_params; in bnxt_hwrm_set_coal_params()
8175 max = hw_coal->bufs_per_record * 128; in bnxt_hwrm_set_coal_params()
8176 if (hw_coal->budget) in bnxt_hwrm_set_coal_params()
8177 max = hw_coal->bufs_per_record * hw_coal->budget; in bnxt_hwrm_set_coal_params()
8178 max = min_t(u16, max, coal_cap->num_cmpl_aggr_int_max); in bnxt_hwrm_set_coal_params()
8180 val = clamp_t(u16, hw_coal->coal_bufs, 1, max); in bnxt_hwrm_set_coal_params()
8181 req->num_cmpl_aggr_int = cpu_to_le16(val); in bnxt_hwrm_set_coal_params()
8183 val = min_t(u16, val, coal_cap->num_cmpl_dma_aggr_max); in bnxt_hwrm_set_coal_params()
8184 req->num_cmpl_dma_aggr = cpu_to_le16(val); in bnxt_hwrm_set_coal_params()
8186 val = clamp_t(u16, hw_coal->coal_bufs_irq, 1, in bnxt_hwrm_set_coal_params()
8187 coal_cap->num_cmpl_dma_aggr_during_int_max); in bnxt_hwrm_set_coal_params()
8188 req->num_cmpl_dma_aggr_during_int = cpu_to_le16(val); in bnxt_hwrm_set_coal_params()
8190 tmr = bnxt_usec_to_coal_tmr(bp, hw_coal->coal_ticks); in bnxt_hwrm_set_coal_params()
8191 tmr = clamp_t(u16, tmr, 1, coal_cap->int_lat_tmr_max_max); in bnxt_hwrm_set_coal_params()
8192 req->int_lat_tmr_max = cpu_to_le16(tmr); in bnxt_hwrm_set_coal_params()
8194 /* min timer set to 1/2 of interrupt timer */ in bnxt_hwrm_set_coal_params()
8197 val = clamp_t(u16, val, 1, coal_cap->int_lat_tmr_min_max); in bnxt_hwrm_set_coal_params()
8198 req->int_lat_tmr_min = cpu_to_le16(val); in bnxt_hwrm_set_coal_params()
8199 req->enables |= cpu_to_le16(BNXT_COAL_CMPL_MIN_TMR_ENABLE); in bnxt_hwrm_set_coal_params()
8202 /* buf timer set to 1/4 of interrupt timer */ in bnxt_hwrm_set_coal_params()
8203 val = clamp_t(u16, tmr / 4, 1, coal_cap->cmpl_aggr_dma_tmr_max); in bnxt_hwrm_set_coal_params()
8204 req->cmpl_aggr_dma_tmr = cpu_to_le16(val); in bnxt_hwrm_set_coal_params()
8208 tmr = bnxt_usec_to_coal_tmr(bp, hw_coal->coal_ticks_irq); in bnxt_hwrm_set_coal_params()
8209 val = clamp_t(u16, tmr, 1, in bnxt_hwrm_set_coal_params()
8210 coal_cap->cmpl_aggr_dma_tmr_during_int_max); in bnxt_hwrm_set_coal_params()
8211 req->cmpl_aggr_dma_tmr_during_int = cpu_to_le16(val); in bnxt_hwrm_set_coal_params()
8212 req->enables |= in bnxt_hwrm_set_coal_params()
8217 hw_coal->idle_thresh && hw_coal->coal_ticks < hw_coal->idle_thresh) in bnxt_hwrm_set_coal_params()
8219 req->flags = cpu_to_le16(flags); in bnxt_hwrm_set_coal_params()
8220 req->enables |= cpu_to_le16(BNXT_COAL_CMPL_ENABLES); in bnxt_hwrm_set_coal_params()
8227 struct bnxt_cp_ring_info *cpr = &bnapi->cp_ring; in __bnxt_hwrm_set_coal_nq()
8228 struct bnxt_coal_cap *coal_cap = &bp->coal_cap; in __bnxt_hwrm_set_coal_nq()
8229 u32 nq_params = coal_cap->nq_params; in __bnxt_hwrm_set_coal_nq()
8240 req->ring_id = cpu_to_le16(cpr->cp_ring_struct.fw_ring_id); in __bnxt_hwrm_set_coal_nq()
8241 req->flags = in __bnxt_hwrm_set_coal_nq()
8244 tmr = bnxt_usec_to_coal_tmr(bp, hw_coal->coal_ticks) / 2; in __bnxt_hwrm_set_coal_nq()
8245 tmr = clamp_t(u16, tmr, 1, coal_cap->int_lat_tmr_min_max); in __bnxt_hwrm_set_coal_nq()
8246 req->int_lat_tmr_min = cpu_to_le16(tmr); in __bnxt_hwrm_set_coal_nq()
8247 req->enables |= cpu_to_le16(BNXT_COAL_CMPL_MIN_TMR_ENABLE); in __bnxt_hwrm_set_coal_nq()
8254 struct bnxt_cp_ring_info *cpr = &bnapi->cp_ring; in bnxt_hwrm_set_ring_coal()
8259 * 1 coal_buf x bufs_per_record = 1 completion record. in bnxt_hwrm_set_ring_coal()
8261 memcpy(&coal, &bp->rx_coal, sizeof(struct bnxt_coal)); in bnxt_hwrm_set_ring_coal()
8263 coal.coal_ticks = cpr->rx_ring_coal.coal_ticks; in bnxt_hwrm_set_ring_coal()
8264 coal.coal_bufs = cpr->rx_ring_coal.coal_bufs; in bnxt_hwrm_set_ring_coal()
8266 if (!bnapi->rx_ring) in bnxt_hwrm_set_ring_coal()
8267 return -ENODEV; in bnxt_hwrm_set_ring_coal()
8275 req_rx->ring_id = cpu_to_le16(bnxt_cp_ring_for_rx(bp, bnapi->rx_ring)); in bnxt_hwrm_set_ring_coal()
8284 u16 ring_id = bnxt_cp_ring_for_rx(bp, bnapi->rx_ring); in bnxt_hwrm_set_rx_coal()
8286 req->ring_id = cpu_to_le16(ring_id); in bnxt_hwrm_set_rx_coal()
8301 req->ring_id = cpu_to_le16(ring_id); in bnxt_hwrm_set_tx_coal()
8305 if (!(bp->flags & BNXT_FLAG_CHIP_P5_PLUS)) in bnxt_hwrm_set_tx_coal()
8326 bnxt_hwrm_set_coal_params(bp, &bp->rx_coal, req_rx); in bnxt_hwrm_set_coal()
8327 bnxt_hwrm_set_coal_params(bp, &bp->tx_coal, req_tx); in bnxt_hwrm_set_coal()
8331 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_hwrm_set_coal()
8332 struct bnxt_napi *bnapi = bp->bnapi[i]; in bnxt_hwrm_set_coal()
8335 if (!bnapi->rx_ring) in bnxt_hwrm_set_coal()
8342 if (!(bp->flags & BNXT_FLAG_CHIP_P5_PLUS)) in bnxt_hwrm_set_coal()
8345 if (bnapi->rx_ring && bnapi->tx_ring[0]) { in bnxt_hwrm_set_coal()
8350 if (bnapi->rx_ring) in bnxt_hwrm_set_coal()
8351 hw_coal = &bp->rx_coal; in bnxt_hwrm_set_coal()
8353 hw_coal = &bp->tx_coal; in bnxt_hwrm_set_coal()
8367 if (!bp->bnapi) in bnxt_hwrm_stat_ctx_free()
8383 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_hwrm_stat_ctx_free()
8384 struct bnxt_napi *bnapi = bp->bnapi[i]; in bnxt_hwrm_stat_ctx_free()
8385 struct bnxt_cp_ring_info *cpr = &bnapi->cp_ring; in bnxt_hwrm_stat_ctx_free()
8387 if (cpr->hw_stats_ctx_id != INVALID_STATS_CTX_ID) { in bnxt_hwrm_stat_ctx_free()
8388 req->stat_ctx_id = cpu_to_le32(cpr->hw_stats_ctx_id); in bnxt_hwrm_stat_ctx_free()
8390 req0->stat_ctx_id = req->stat_ctx_id; in bnxt_hwrm_stat_ctx_free()
8395 cpr->hw_stats_ctx_id = INVALID_STATS_CTX_ID; in bnxt_hwrm_stat_ctx_free()
8416 req->stats_dma_length = cpu_to_le16(bp->hw_ring_stats_size); in bnxt_hwrm_stat_ctx_alloc()
8417 req->update_period_ms = cpu_to_le32(bp->stats_coal_ticks / 1000); in bnxt_hwrm_stat_ctx_alloc()
8420 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_hwrm_stat_ctx_alloc()
8421 struct bnxt_napi *bnapi = bp->bnapi[i]; in bnxt_hwrm_stat_ctx_alloc()
8422 struct bnxt_cp_ring_info *cpr = &bnapi->cp_ring; in bnxt_hwrm_stat_ctx_alloc()
8424 req->stats_dma_addr = cpu_to_le64(cpr->stats.hw_stats_map); in bnxt_hwrm_stat_ctx_alloc()
8430 cpr->hw_stats_ctx_id = le32_to_cpu(resp->stat_ctx_id); in bnxt_hwrm_stat_ctx_alloc()
8432 bp->grp_info[i].fw_stats_ctx = cpr->hw_stats_ctx_id; in bnxt_hwrm_stat_ctx_alloc()
8449 req->fid = cpu_to_le16(0xffff); in bnxt_hwrm_func_qcfg()
8455 flags = le16_to_cpu(resp->flags); in bnxt_hwrm_func_qcfg()
8458 struct bnxt_vf_info *vf = &bp->vf; in bnxt_hwrm_func_qcfg()
8460 vf->vlan = le16_to_cpu(resp->vlan) & VLAN_VID_MASK; in bnxt_hwrm_func_qcfg()
8462 vf->flags |= BNXT_VF_TRUST; in bnxt_hwrm_func_qcfg()
8464 vf->flags &= ~BNXT_VF_TRUST; in bnxt_hwrm_func_qcfg()
8466 bp->pf.registered_vfs = le16_to_cpu(resp->registered_vfs); in bnxt_hwrm_func_qcfg()
8471 bp->fw_cap |= BNXT_FW_CAP_LLDP_AGENT; in bnxt_hwrm_func_qcfg()
8473 bp->fw_cap |= BNXT_FW_CAP_DCBX_AGENT; in bnxt_hwrm_func_qcfg()
8476 bp->flags |= BNXT_FLAG_MULTI_HOST; in bnxt_hwrm_func_qcfg()
8479 bp->fw_cap |= BNXT_FW_CAP_RING_MONITOR; in bnxt_hwrm_func_qcfg()
8482 bp->fw_cap |= BNXT_FW_CAP_ENABLE_RDMA_SRIOV; in bnxt_hwrm_func_qcfg()
8484 switch (resp->port_partition_type) { in bnxt_hwrm_func_qcfg()
8489 bp->port_partition_type = resp->port_partition_type; in bnxt_hwrm_func_qcfg()
8492 if (bp->hwrm_spec_code < 0x10707 || in bnxt_hwrm_func_qcfg()
8493 resp->evb_mode == FUNC_QCFG_RESP_EVB_MODE_VEB) in bnxt_hwrm_func_qcfg()
8494 bp->br_mode = BRIDGE_MODE_VEB; in bnxt_hwrm_func_qcfg()
8495 else if (resp->evb_mode == FUNC_QCFG_RESP_EVB_MODE_VEPA) in bnxt_hwrm_func_qcfg()
8496 bp->br_mode = BRIDGE_MODE_VEPA; in bnxt_hwrm_func_qcfg()
8498 bp->br_mode = BRIDGE_MODE_UNDEF; in bnxt_hwrm_func_qcfg()
8500 bp->max_mtu = le16_to_cpu(resp->max_mtu_configured); in bnxt_hwrm_func_qcfg()
8501 if (!bp->max_mtu) in bnxt_hwrm_func_qcfg()
8502 bp->max_mtu = BNXT_MAX_MTU; in bnxt_hwrm_func_qcfg()
8504 if (bp->db_size) in bnxt_hwrm_func_qcfg()
8507 bp->db_offset = le16_to_cpu(resp->legacy_l2_db_size_kb) * 1024; in bnxt_hwrm_func_qcfg()
8510 bp->db_offset = DB_PF_OFFSET_P5; in bnxt_hwrm_func_qcfg()
8512 bp->db_offset = DB_VF_OFFSET_P5; in bnxt_hwrm_func_qcfg()
8514 bp->db_size = PAGE_ALIGN(le16_to_cpu(resp->l2_doorbell_bar_size_kb) * in bnxt_hwrm_func_qcfg()
8516 if (!bp->db_size || bp->db_size > pci_resource_len(bp->pdev, 2) || in bnxt_hwrm_func_qcfg()
8517 bp->db_size <= bp->db_offset) in bnxt_hwrm_func_qcfg()
8518 bp->db_size = pci_resource_len(bp->pdev, 2); in bnxt_hwrm_func_qcfg()
8529 ctxm->init_value = init_val; in bnxt_init_ctx_initializer()
8530 ctxm->init_offset = BNXT_CTX_INIT_INVALID_OFFSET; in bnxt_init_ctx_initializer()
8532 ctxm->init_offset = init_offset * 4; in bnxt_init_ctx_initializer()
8534 ctxm->init_value = 0; in bnxt_init_ctx_initializer()
8539 struct bnxt_ctx_mem_info *ctx = bp->ctx; in bnxt_alloc_all_ctx_pg_info()
8543 struct bnxt_ctx_mem_type *ctxm = &ctx->ctx_arr[type]; in bnxt_alloc_all_ctx_pg_info()
8544 int n = 1; in bnxt_alloc_all_ctx_pg_info()
8546 if (!ctxm->max_entries || ctxm->pg_info) in bnxt_alloc_all_ctx_pg_info()
8549 if (ctxm->instance_bmap) in bnxt_alloc_all_ctx_pg_info()
8550 n = hweight32(ctxm->instance_bmap); in bnxt_alloc_all_ctx_pg_info()
8551 ctxm->pg_info = kcalloc(n, sizeof(*ctxm->pg_info), GFP_KERNEL); in bnxt_alloc_all_ctx_pg_info()
8552 if (!ctxm->pg_info) in bnxt_alloc_all_ctx_pg_info()
8553 return -ENOMEM; in bnxt_alloc_all_ctx_pg_info()
8569 struct bnxt_ctx_mem_info *ctx = bp->ctx; in bnxt_hwrm_func_backing_store_qcaps_v2()
8580 return -ENOMEM; in bnxt_hwrm_func_backing_store_qcaps_v2()
8581 bp->ctx = ctx; in bnxt_hwrm_func_backing_store_qcaps_v2()
8587 struct bnxt_ctx_mem_type *ctxm = &ctx->ctx_arr[type]; in bnxt_hwrm_func_backing_store_qcaps_v2()
8594 req->type = cpu_to_le16(type); in bnxt_hwrm_func_backing_store_qcaps_v2()
8598 flags = le32_to_cpu(resp->flags); in bnxt_hwrm_func_backing_store_qcaps_v2()
8599 type = le16_to_cpu(resp->next_valid_type); in bnxt_hwrm_func_backing_store_qcaps_v2()
8604 entry_size = le16_to_cpu(resp->entry_size); in bnxt_hwrm_func_backing_store_qcaps_v2()
8605 max_entries = le32_to_cpu(resp->max_num_entries); in bnxt_hwrm_func_backing_store_qcaps_v2()
8606 if (ctxm->mem_valid) { in bnxt_hwrm_func_backing_store_qcaps_v2()
8608 ctxm->entry_size != entry_size || in bnxt_hwrm_func_backing_store_qcaps_v2()
8609 ctxm->max_entries != max_entries) in bnxt_hwrm_func_backing_store_qcaps_v2()
8614 ctxm->type = le16_to_cpu(resp->type); in bnxt_hwrm_func_backing_store_qcaps_v2()
8615 ctxm->entry_size = entry_size; in bnxt_hwrm_func_backing_store_qcaps_v2()
8616 ctxm->flags = flags; in bnxt_hwrm_func_backing_store_qcaps_v2()
8617 ctxm->instance_bmap = le32_to_cpu(resp->instance_bit_map); in bnxt_hwrm_func_backing_store_qcaps_v2()
8618 ctxm->entry_multiple = resp->entry_multiple; in bnxt_hwrm_func_backing_store_qcaps_v2()
8619 ctxm->max_entries = max_entries; in bnxt_hwrm_func_backing_store_qcaps_v2()
8620 ctxm->min_entries = le32_to_cpu(resp->min_num_entries); in bnxt_hwrm_func_backing_store_qcaps_v2()
8621 init_val = resp->ctx_init_value; in bnxt_hwrm_func_backing_store_qcaps_v2()
8622 init_off = resp->ctx_init_offset; in bnxt_hwrm_func_backing_store_qcaps_v2()
8625 ctxm->split_entry_cnt = min_t(u8, resp->subtype_valid_cnt, in bnxt_hwrm_func_backing_store_qcaps_v2()
8627 for (i = 0, p = &resp->split_entry_0; i < ctxm->split_entry_cnt; in bnxt_hwrm_func_backing_store_qcaps_v2()
8629 ctxm->split[i] = le32_to_cpu(*p); in bnxt_hwrm_func_backing_store_qcaps_v2()
8644 if (bp->hwrm_spec_code < 0x10902 || BNXT_VF(bp) || in bnxt_hwrm_func_backing_store_qcaps()
8645 (bp->ctx && bp->ctx->flags & BNXT_CTX_FLAG_INITED)) in bnxt_hwrm_func_backing_store_qcaps()
8648 if (bp->fw_cap & BNXT_FW_CAP_BACKING_STORE_V2) in bnxt_hwrm_func_backing_store_qcaps()
8663 ctx = bp->ctx; in bnxt_hwrm_func_backing_store_qcaps()
8667 rc = -ENOMEM; in bnxt_hwrm_func_backing_store_qcaps()
8670 bp->ctx = ctx; in bnxt_hwrm_func_backing_store_qcaps()
8672 init_val = resp->ctx_kind_initializer; in bnxt_hwrm_func_backing_store_qcaps()
8673 init_mask = le16_to_cpu(resp->ctx_init_mask); in bnxt_hwrm_func_backing_store_qcaps()
8675 ctxm = &ctx->ctx_arr[BNXT_CTX_QP]; in bnxt_hwrm_func_backing_store_qcaps()
8676 ctxm->max_entries = le32_to_cpu(resp->qp_max_entries); in bnxt_hwrm_func_backing_store_qcaps()
8677 ctxm->qp_qp1_entries = le16_to_cpu(resp->qp_min_qp1_entries); in bnxt_hwrm_func_backing_store_qcaps()
8678 ctxm->qp_l2_entries = le16_to_cpu(resp->qp_max_l2_entries); in bnxt_hwrm_func_backing_store_qcaps()
8679 ctxm->qp_fast_qpmd_entries = le16_to_cpu(resp->fast_qpmd_qp_num_entries); in bnxt_hwrm_func_backing_store_qcaps()
8680 ctxm->entry_size = le16_to_cpu(resp->qp_entry_size); in bnxt_hwrm_func_backing_store_qcaps()
8681 bnxt_init_ctx_initializer(ctxm, init_val, resp->qp_init_offset, in bnxt_hwrm_func_backing_store_qcaps()
8682 (init_mask & (1 << init_idx++)) != 0); in bnxt_hwrm_func_backing_store_qcaps()
8684 ctxm = &ctx->ctx_arr[BNXT_CTX_SRQ]; in bnxt_hwrm_func_backing_store_qcaps()
8685 ctxm->srq_l2_entries = le16_to_cpu(resp->srq_max_l2_entries); in bnxt_hwrm_func_backing_store_qcaps()
8686 ctxm->max_entries = le32_to_cpu(resp->srq_max_entries); in bnxt_hwrm_func_backing_store_qcaps()
8687 ctxm->entry_size = le16_to_cpu(resp->srq_entry_size); in bnxt_hwrm_func_backing_store_qcaps()
8688 bnxt_init_ctx_initializer(ctxm, init_val, resp->srq_init_offset, in bnxt_hwrm_func_backing_store_qcaps()
8689 (init_mask & (1 << init_idx++)) != 0); in bnxt_hwrm_func_backing_store_qcaps()
8691 ctxm = &ctx->ctx_arr[BNXT_CTX_CQ]; in bnxt_hwrm_func_backing_store_qcaps()
8692 ctxm->cq_l2_entries = le16_to_cpu(resp->cq_max_l2_entries); in bnxt_hwrm_func_backing_store_qcaps()
8693 ctxm->max_entries = le32_to_cpu(resp->cq_max_entries); in bnxt_hwrm_func_backing_store_qcaps()
8694 ctxm->entry_size = le16_to_cpu(resp->cq_entry_size); in bnxt_hwrm_func_backing_store_qcaps()
8695 bnxt_init_ctx_initializer(ctxm, init_val, resp->cq_init_offset, in bnxt_hwrm_func_backing_store_qcaps()
8696 (init_mask & (1 << init_idx++)) != 0); in bnxt_hwrm_func_backing_store_qcaps()
8698 ctxm = &ctx->ctx_arr[BNXT_CTX_VNIC]; in bnxt_hwrm_func_backing_store_qcaps()
8699 ctxm->vnic_entries = le16_to_cpu(resp->vnic_max_vnic_entries); in bnxt_hwrm_func_backing_store_qcaps()
8700 ctxm->max_entries = ctxm->vnic_entries + in bnxt_hwrm_func_backing_store_qcaps()
8701 le16_to_cpu(resp->vnic_max_ring_table_entries); in bnxt_hwrm_func_backing_store_qcaps()
8702 ctxm->entry_size = le16_to_cpu(resp->vnic_entry_size); in bnxt_hwrm_func_backing_store_qcaps()
8704 resp->vnic_init_offset, in bnxt_hwrm_func_backing_store_qcaps()
8705 (init_mask & (1 << init_idx++)) != 0); in bnxt_hwrm_func_backing_store_qcaps()
8707 ctxm = &ctx->ctx_arr[BNXT_CTX_STAT]; in bnxt_hwrm_func_backing_store_qcaps()
8708 ctxm->max_entries = le32_to_cpu(resp->stat_max_entries); in bnxt_hwrm_func_backing_store_qcaps()
8709 ctxm->entry_size = le16_to_cpu(resp->stat_entry_size); in bnxt_hwrm_func_backing_store_qcaps()
8711 resp->stat_init_offset, in bnxt_hwrm_func_backing_store_qcaps()
8712 (init_mask & (1 << init_idx++)) != 0); in bnxt_hwrm_func_backing_store_qcaps()
8714 ctxm = &ctx->ctx_arr[BNXT_CTX_STQM]; in bnxt_hwrm_func_backing_store_qcaps()
8715 ctxm->entry_size = le16_to_cpu(resp->tqm_entry_size); in bnxt_hwrm_func_backing_store_qcaps()
8716 ctxm->min_entries = le32_to_cpu(resp->tqm_min_entries_per_ring); in bnxt_hwrm_func_backing_store_qcaps()
8717 ctxm->max_entries = le32_to_cpu(resp->tqm_max_entries_per_ring); in bnxt_hwrm_func_backing_store_qcaps()
8718 ctxm->entry_multiple = resp->tqm_entries_multiple; in bnxt_hwrm_func_backing_store_qcaps()
8719 if (!ctxm->entry_multiple) in bnxt_hwrm_func_backing_store_qcaps()
8720 ctxm->entry_multiple = 1; in bnxt_hwrm_func_backing_store_qcaps()
8722 memcpy(&ctx->ctx_arr[BNXT_CTX_FTQM], ctxm, sizeof(*ctxm)); in bnxt_hwrm_func_backing_store_qcaps()
8724 ctxm = &ctx->ctx_arr[BNXT_CTX_MRAV]; in bnxt_hwrm_func_backing_store_qcaps()
8725 ctxm->max_entries = le32_to_cpu(resp->mrav_max_entries); in bnxt_hwrm_func_backing_store_qcaps()
8726 ctxm->entry_size = le16_to_cpu(resp->mrav_entry_size); in bnxt_hwrm_func_backing_store_qcaps()
8727 ctxm->mrav_num_entries_units = in bnxt_hwrm_func_backing_store_qcaps()
8728 le16_to_cpu(resp->mrav_num_entries_units); in bnxt_hwrm_func_backing_store_qcaps()
8730 resp->mrav_init_offset, in bnxt_hwrm_func_backing_store_qcaps()
8731 (init_mask & (1 << init_idx++)) != 0); in bnxt_hwrm_func_backing_store_qcaps()
8733 ctxm = &ctx->ctx_arr[BNXT_CTX_TIM]; in bnxt_hwrm_func_backing_store_qcaps()
8734 ctxm->entry_size = le16_to_cpu(resp->tim_entry_size); in bnxt_hwrm_func_backing_store_qcaps()
8735 ctxm->max_entries = le32_to_cpu(resp->tim_max_entries); in bnxt_hwrm_func_backing_store_qcaps()
8737 ctx->tqm_fp_rings_count = resp->tqm_fp_rings_count; in bnxt_hwrm_func_backing_store_qcaps()
8738 if (!ctx->tqm_fp_rings_count) in bnxt_hwrm_func_backing_store_qcaps()
8739 ctx->tqm_fp_rings_count = bp->max_q; in bnxt_hwrm_func_backing_store_qcaps()
8740 else if (ctx->tqm_fp_rings_count > BNXT_MAX_TQM_FP_RINGS) in bnxt_hwrm_func_backing_store_qcaps()
8741 ctx->tqm_fp_rings_count = BNXT_MAX_TQM_FP_RINGS; in bnxt_hwrm_func_backing_store_qcaps()
8743 ctxm = &ctx->ctx_arr[BNXT_CTX_FTQM]; in bnxt_hwrm_func_backing_store_qcaps()
8744 memcpy(ctxm, &ctx->ctx_arr[BNXT_CTX_STQM], sizeof(*ctxm)); in bnxt_hwrm_func_backing_store_qcaps()
8745 ctxm->instance_bmap = (1 << ctx->tqm_fp_rings_count) - 1; in bnxt_hwrm_func_backing_store_qcaps()
8759 if (!rmem->nr_pages) in bnxt_hwrm_set_pg_attr()
8763 if (rmem->depth >= 1) { in bnxt_hwrm_set_pg_attr()
8764 if (rmem->depth == 2) in bnxt_hwrm_set_pg_attr()
8767 *pg_attr |= 1; in bnxt_hwrm_set_pg_attr()
8768 *pg_dir = cpu_to_le64(rmem->pg_tbl_map); in bnxt_hwrm_set_pg_attr()
8770 *pg_dir = cpu_to_le64(rmem->dma_arr[0]); in bnxt_hwrm_set_pg_attr()
8784 struct bnxt_ctx_mem_info *ctx = bp->ctx; in bnxt_hwrm_func_backing_store_cfg()
8800 if (req_len > bp->hwrm_max_ext_req_len) in bnxt_hwrm_func_backing_store_cfg()
8806 req->enables = cpu_to_le32(enables); in bnxt_hwrm_func_backing_store_cfg()
8808 ctxm = &ctx->ctx_arr[BNXT_CTX_QP]; in bnxt_hwrm_func_backing_store_cfg()
8809 ctx_pg = ctxm->pg_info; in bnxt_hwrm_func_backing_store_cfg()
8810 req->qp_num_entries = cpu_to_le32(ctx_pg->entries); in bnxt_hwrm_func_backing_store_cfg()
8811 req->qp_num_qp1_entries = cpu_to_le16(ctxm->qp_qp1_entries); in bnxt_hwrm_func_backing_store_cfg()
8812 req->qp_num_l2_entries = cpu_to_le16(ctxm->qp_l2_entries); in bnxt_hwrm_func_backing_store_cfg()
8813 req->qp_entry_size = cpu_to_le16(ctxm->entry_size); in bnxt_hwrm_func_backing_store_cfg()
8814 bnxt_hwrm_set_pg_attr(&ctx_pg->ring_mem, in bnxt_hwrm_func_backing_store_cfg()
8815 &req->qpc_pg_size_qpc_lvl, in bnxt_hwrm_func_backing_store_cfg()
8816 &req->qpc_page_dir); in bnxt_hwrm_func_backing_store_cfg()
8819 req->qp_num_fast_qpmd_entries = cpu_to_le16(ctxm->qp_fast_qpmd_entries); in bnxt_hwrm_func_backing_store_cfg()
8822 ctxm = &ctx->ctx_arr[BNXT_CTX_SRQ]; in bnxt_hwrm_func_backing_store_cfg()
8823 ctx_pg = ctxm->pg_info; in bnxt_hwrm_func_backing_store_cfg()
8824 req->srq_num_entries = cpu_to_le32(ctx_pg->entries); in bnxt_hwrm_func_backing_store_cfg()
8825 req->srq_num_l2_entries = cpu_to_le16(ctxm->srq_l2_entries); in bnxt_hwrm_func_backing_store_cfg()
8826 req->srq_entry_size = cpu_to_le16(ctxm->entry_size); in bnxt_hwrm_func_backing_store_cfg()
8827 bnxt_hwrm_set_pg_attr(&ctx_pg->ring_mem, in bnxt_hwrm_func_backing_store_cfg()
8828 &req->srq_pg_size_srq_lvl, in bnxt_hwrm_func_backing_store_cfg()
8829 &req->srq_page_dir); in bnxt_hwrm_func_backing_store_cfg()
8832 ctxm = &ctx->ctx_arr[BNXT_CTX_CQ]; in bnxt_hwrm_func_backing_store_cfg()
8833 ctx_pg = ctxm->pg_info; in bnxt_hwrm_func_backing_store_cfg()
8834 req->cq_num_entries = cpu_to_le32(ctx_pg->entries); in bnxt_hwrm_func_backing_store_cfg()
8835 req->cq_num_l2_entries = cpu_to_le16(ctxm->cq_l2_entries); in bnxt_hwrm_func_backing_store_cfg()
8836 req->cq_entry_size = cpu_to_le16(ctxm->entry_size); in bnxt_hwrm_func_backing_store_cfg()
8837 bnxt_hwrm_set_pg_attr(&ctx_pg->ring_mem, in bnxt_hwrm_func_backing_store_cfg()
8838 &req->cq_pg_size_cq_lvl, in bnxt_hwrm_func_backing_store_cfg()
8839 &req->cq_page_dir); in bnxt_hwrm_func_backing_store_cfg()
8842 ctxm = &ctx->ctx_arr[BNXT_CTX_VNIC]; in bnxt_hwrm_func_backing_store_cfg()
8843 ctx_pg = ctxm->pg_info; in bnxt_hwrm_func_backing_store_cfg()
8844 req->vnic_num_vnic_entries = cpu_to_le16(ctxm->vnic_entries); in bnxt_hwrm_func_backing_store_cfg()
8845 req->vnic_num_ring_table_entries = in bnxt_hwrm_func_backing_store_cfg()
8846 cpu_to_le16(ctxm->max_entries - ctxm->vnic_entries); in bnxt_hwrm_func_backing_store_cfg()
8847 req->vnic_entry_size = cpu_to_le16(ctxm->entry_size); in bnxt_hwrm_func_backing_store_cfg()
8848 bnxt_hwrm_set_pg_attr(&ctx_pg->ring_mem, in bnxt_hwrm_func_backing_store_cfg()
8849 &req->vnic_pg_size_vnic_lvl, in bnxt_hwrm_func_backing_store_cfg()
8850 &req->vnic_page_dir); in bnxt_hwrm_func_backing_store_cfg()
8853 ctxm = &ctx->ctx_arr[BNXT_CTX_STAT]; in bnxt_hwrm_func_backing_store_cfg()
8854 ctx_pg = ctxm->pg_info; in bnxt_hwrm_func_backing_store_cfg()
8855 req->stat_num_entries = cpu_to_le32(ctxm->max_entries); in bnxt_hwrm_func_backing_store_cfg()
8856 req->stat_entry_size = cpu_to_le16(ctxm->entry_size); in bnxt_hwrm_func_backing_store_cfg()
8857 bnxt_hwrm_set_pg_attr(&ctx_pg->ring_mem, in bnxt_hwrm_func_backing_store_cfg()
8858 &req->stat_pg_size_stat_lvl, in bnxt_hwrm_func_backing_store_cfg()
8859 &req->stat_page_dir); in bnxt_hwrm_func_backing_store_cfg()
8864 ctxm = &ctx->ctx_arr[BNXT_CTX_MRAV]; in bnxt_hwrm_func_backing_store_cfg()
8865 ctx_pg = ctxm->pg_info; in bnxt_hwrm_func_backing_store_cfg()
8866 req->mrav_num_entries = cpu_to_le32(ctx_pg->entries); in bnxt_hwrm_func_backing_store_cfg()
8867 units = ctxm->mrav_num_entries_units; in bnxt_hwrm_func_backing_store_cfg()
8869 u32 num_mr, num_ah = ctxm->mrav_av_entries; in bnxt_hwrm_func_backing_store_cfg()
8872 num_mr = ctx_pg->entries - num_ah; in bnxt_hwrm_func_backing_store_cfg()
8874 req->mrav_num_entries = cpu_to_le32(entries); in bnxt_hwrm_func_backing_store_cfg()
8877 req->mrav_entry_size = cpu_to_le16(ctxm->entry_size); in bnxt_hwrm_func_backing_store_cfg()
8878 bnxt_hwrm_set_pg_attr(&ctx_pg->ring_mem, in bnxt_hwrm_func_backing_store_cfg()
8879 &req->mrav_pg_size_mrav_lvl, in bnxt_hwrm_func_backing_store_cfg()
8880 &req->mrav_page_dir); in bnxt_hwrm_func_backing_store_cfg()
8883 ctxm = &ctx->ctx_arr[BNXT_CTX_TIM]; in bnxt_hwrm_func_backing_store_cfg()
8884 ctx_pg = ctxm->pg_info; in bnxt_hwrm_func_backing_store_cfg()
8885 req->tim_num_entries = cpu_to_le32(ctx_pg->entries); in bnxt_hwrm_func_backing_store_cfg()
8886 req->tim_entry_size = cpu_to_le16(ctxm->entry_size); in bnxt_hwrm_func_backing_store_cfg()
8887 bnxt_hwrm_set_pg_attr(&ctx_pg->ring_mem, in bnxt_hwrm_func_backing_store_cfg()
8888 &req->tim_pg_size_tim_lvl, in bnxt_hwrm_func_backing_store_cfg()
8889 &req->tim_page_dir); in bnxt_hwrm_func_backing_store_cfg()
8891 ctxm = &ctx->ctx_arr[BNXT_CTX_STQM]; in bnxt_hwrm_func_backing_store_cfg()
8892 for (i = 0, num_entries = &req->tqm_sp_num_entries, in bnxt_hwrm_func_backing_store_cfg()
8893 pg_attr = &req->tqm_sp_pg_size_tqm_sp_lvl, in bnxt_hwrm_func_backing_store_cfg()
8894 pg_dir = &req->tqm_sp_page_dir, in bnxt_hwrm_func_backing_store_cfg()
8896 ctx_pg = ctxm->pg_info; in bnxt_hwrm_func_backing_store_cfg()
8898 ctx_pg = &ctx->ctx_arr[BNXT_CTX_FTQM].pg_info[i], in bnxt_hwrm_func_backing_store_cfg()
8899 i++, num_entries++, pg_attr++, pg_dir++, ena <<= 1) { in bnxt_hwrm_func_backing_store_cfg()
8903 req->tqm_entry_size = cpu_to_le16(ctxm->entry_size); in bnxt_hwrm_func_backing_store_cfg()
8904 *num_entries = cpu_to_le32(ctx_pg->entries); in bnxt_hwrm_func_backing_store_cfg()
8905 bnxt_hwrm_set_pg_attr(&ctx_pg->ring_mem, pg_attr, pg_dir); in bnxt_hwrm_func_backing_store_cfg()
8907 req->flags = cpu_to_le32(flags); in bnxt_hwrm_func_backing_store_cfg()
8914 struct bnxt_ring_mem_info *rmem = &ctx_pg->ring_mem; in bnxt_alloc_ctx_mem_blk()
8916 rmem->page_size = BNXT_PAGE_SIZE; in bnxt_alloc_ctx_mem_blk()
8917 rmem->pg_arr = ctx_pg->ctx_pg_arr; in bnxt_alloc_ctx_mem_blk()
8918 rmem->dma_arr = ctx_pg->ctx_dma_arr; in bnxt_alloc_ctx_mem_blk()
8919 rmem->flags = BNXT_RMEM_VALID_PTE_FLAG; in bnxt_alloc_ctx_mem_blk()
8920 if (rmem->depth >= 1) in bnxt_alloc_ctx_mem_blk()
8921 rmem->flags |= BNXT_RMEM_USE_FULL_PAGE_FLAG; in bnxt_alloc_ctx_mem_blk()
8929 struct bnxt_ring_mem_info *rmem = &ctx_pg->ring_mem; in bnxt_alloc_ctx_pg_tbls()
8933 return -EINVAL; in bnxt_alloc_ctx_pg_tbls()
8935 ctx_pg->nr_pages = DIV_ROUND_UP(mem_size, BNXT_PAGE_SIZE); in bnxt_alloc_ctx_pg_tbls()
8936 if (ctx_pg->nr_pages > MAX_CTX_TOTAL_PAGES) { in bnxt_alloc_ctx_pg_tbls()
8937 ctx_pg->nr_pages = 0; in bnxt_alloc_ctx_pg_tbls()
8938 return -EINVAL; in bnxt_alloc_ctx_pg_tbls()
8940 if (ctx_pg->nr_pages > MAX_CTX_PAGES || depth > 1) { in bnxt_alloc_ctx_pg_tbls()
8943 rmem->depth = 2; in bnxt_alloc_ctx_pg_tbls()
8944 ctx_pg->ctx_pg_tbl = kcalloc(MAX_CTX_PAGES, sizeof(ctx_pg), in bnxt_alloc_ctx_pg_tbls()
8946 if (!ctx_pg->ctx_pg_tbl) in bnxt_alloc_ctx_pg_tbls()
8947 return -ENOMEM; in bnxt_alloc_ctx_pg_tbls()
8948 nr_tbls = DIV_ROUND_UP(ctx_pg->nr_pages, MAX_CTX_PAGES); in bnxt_alloc_ctx_pg_tbls()
8949 rmem->nr_pages = nr_tbls; in bnxt_alloc_ctx_pg_tbls()
8958 return -ENOMEM; in bnxt_alloc_ctx_pg_tbls()
8959 ctx_pg->ctx_pg_tbl[i] = pg_tbl; in bnxt_alloc_ctx_pg_tbls()
8960 rmem = &pg_tbl->ring_mem; in bnxt_alloc_ctx_pg_tbls()
8961 rmem->pg_tbl = ctx_pg->ctx_pg_arr[i]; in bnxt_alloc_ctx_pg_tbls()
8962 rmem->pg_tbl_map = ctx_pg->ctx_dma_arr[i]; in bnxt_alloc_ctx_pg_tbls()
8963 rmem->depth = 1; in bnxt_alloc_ctx_pg_tbls()
8964 rmem->nr_pages = MAX_CTX_PAGES; in bnxt_alloc_ctx_pg_tbls()
8965 rmem->ctx_mem = ctxm; in bnxt_alloc_ctx_pg_tbls()
8966 if (i == (nr_tbls - 1)) { in bnxt_alloc_ctx_pg_tbls()
8967 int rem = ctx_pg->nr_pages % MAX_CTX_PAGES; in bnxt_alloc_ctx_pg_tbls()
8970 rmem->nr_pages = rem; in bnxt_alloc_ctx_pg_tbls()
8977 rmem->nr_pages = DIV_ROUND_UP(mem_size, BNXT_PAGE_SIZE); in bnxt_alloc_ctx_pg_tbls()
8978 if (rmem->nr_pages > 1 || depth) in bnxt_alloc_ctx_pg_tbls()
8979 rmem->depth = 1; in bnxt_alloc_ctx_pg_tbls()
8980 rmem->ctx_mem = ctxm; in bnxt_alloc_ctx_pg_tbls()
8991 struct bnxt_ring_mem_info *rmem = &ctx_pg->ring_mem; in bnxt_copy_ctx_pg_tbls()
8992 size_t nr_pages = ctx_pg->nr_pages; in bnxt_copy_ctx_pg_tbls()
8993 int page_size = rmem->page_size; in bnxt_copy_ctx_pg_tbls()
8995 u16 depth = rmem->depth; in bnxt_copy_ctx_pg_tbls()
8999 if (depth > 1) { in bnxt_copy_ctx_pg_tbls()
9003 pg_tbl = ctx_pg->ctx_pg_tbl[i]; in bnxt_copy_ctx_pg_tbls()
9004 rmem = &pg_tbl->ring_mem; in bnxt_copy_ctx_pg_tbls()
9019 struct bnxt_ring_mem_info *rmem = &ctx_pg->ring_mem; in bnxt_free_ctx_pg_tbls()
9021 if (rmem->depth > 1 || ctx_pg->nr_pages > MAX_CTX_PAGES || in bnxt_free_ctx_pg_tbls()
9022 ctx_pg->ctx_pg_tbl) { in bnxt_free_ctx_pg_tbls()
9023 int i, nr_tbls = rmem->nr_pages; in bnxt_free_ctx_pg_tbls()
9029 pg_tbl = ctx_pg->ctx_pg_tbl[i]; in bnxt_free_ctx_pg_tbls()
9032 rmem2 = &pg_tbl->ring_mem; in bnxt_free_ctx_pg_tbls()
9034 ctx_pg->ctx_pg_arr[i] = NULL; in bnxt_free_ctx_pg_tbls()
9036 ctx_pg->ctx_pg_tbl[i] = NULL; in bnxt_free_ctx_pg_tbls()
9038 kfree(ctx_pg->ctx_pg_tbl); in bnxt_free_ctx_pg_tbls()
9039 ctx_pg->ctx_pg_tbl = NULL; in bnxt_free_ctx_pg_tbls()
9042 ctx_pg->nr_pages = 0; in bnxt_free_ctx_pg_tbls()
9049 struct bnxt_ctx_pg_info *ctx_pg = ctxm->pg_info; in bnxt_setup_ctxm_pg_tbls()
9050 int i, rc = 0, n = 1; in bnxt_setup_ctxm_pg_tbls()
9053 if (!ctxm->entry_size || !ctx_pg) in bnxt_setup_ctxm_pg_tbls()
9054 return -EINVAL; in bnxt_setup_ctxm_pg_tbls()
9055 if (ctxm->instance_bmap) in bnxt_setup_ctxm_pg_tbls()
9056 n = hweight32(ctxm->instance_bmap); in bnxt_setup_ctxm_pg_tbls()
9057 if (ctxm->entry_multiple) in bnxt_setup_ctxm_pg_tbls()
9058 entries = roundup(entries, ctxm->entry_multiple); in bnxt_setup_ctxm_pg_tbls()
9059 entries = clamp_t(u32, entries, ctxm->min_entries, ctxm->max_entries); in bnxt_setup_ctxm_pg_tbls()
9060 mem_size = entries * ctxm->entry_size; in bnxt_setup_ctxm_pg_tbls()
9064 ctxm->init_value ? ctxm : NULL); in bnxt_setup_ctxm_pg_tbls()
9067 ctxm->mem_valid = 1; in bnxt_setup_ctxm_pg_tbls()
9076 u32 instance_bmap = ctxm->instance_bmap; in bnxt_hwrm_func_backing_store_cfg_v2()
9077 int i, j, rc = 0, n = 1; in bnxt_hwrm_func_backing_store_cfg_v2()
9080 if (!(ctxm->flags & BNXT_CTX_MEM_TYPE_VALID) || !ctxm->pg_info) in bnxt_hwrm_func_backing_store_cfg_v2()
9084 n = hweight32(ctxm->instance_bmap); in bnxt_hwrm_func_backing_store_cfg_v2()
9086 instance_bmap = 1; in bnxt_hwrm_func_backing_store_cfg_v2()
9092 req->type = cpu_to_le16(ctxm->type); in bnxt_hwrm_func_backing_store_cfg_v2()
9093 req->entry_size = cpu_to_le16(ctxm->entry_size); in bnxt_hwrm_func_backing_store_cfg_v2()
9094 if ((ctxm->flags & BNXT_CTX_MEM_PERSIST) && in bnxt_hwrm_func_backing_store_cfg_v2()
9095 bnxt_bs_trace_avail(bp, ctxm->type)) { in bnxt_hwrm_func_backing_store_cfg_v2()
9100 req->enables = cpu_to_le32(enables); in bnxt_hwrm_func_backing_store_cfg_v2()
9101 bs_trace = &bp->bs_trace[bnxt_bstore_to_trace[ctxm->type]]; in bnxt_hwrm_func_backing_store_cfg_v2()
9102 req->next_bs_offset = cpu_to_le32(bs_trace->last_offset); in bnxt_hwrm_func_backing_store_cfg_v2()
9104 req->subtype_valid_cnt = ctxm->split_entry_cnt; in bnxt_hwrm_func_backing_store_cfg_v2()
9105 for (i = 0, p = &req->split_entry_0; i < ctxm->split_entry_cnt; i++) in bnxt_hwrm_func_backing_store_cfg_v2()
9106 p[i] = cpu_to_le32(ctxm->split[i]); in bnxt_hwrm_func_backing_store_cfg_v2()
9110 if (!(instance_bmap & (1 << i))) in bnxt_hwrm_func_backing_store_cfg_v2()
9112 req->instance = cpu_to_le16(i); in bnxt_hwrm_func_backing_store_cfg_v2()
9113 ctx_pg = &ctxm->pg_info[j++]; in bnxt_hwrm_func_backing_store_cfg_v2()
9114 if (!ctx_pg->entries) in bnxt_hwrm_func_backing_store_cfg_v2()
9116 req->num_entries = cpu_to_le32(ctx_pg->entries); in bnxt_hwrm_func_backing_store_cfg_v2()
9117 bnxt_hwrm_set_pg_attr(&ctx_pg->ring_mem, in bnxt_hwrm_func_backing_store_cfg_v2()
9118 &req->page_size_pbl_level, in bnxt_hwrm_func_backing_store_cfg_v2()
9119 &req->page_dir); in bnxt_hwrm_func_backing_store_cfg_v2()
9121 req->flags = in bnxt_hwrm_func_backing_store_cfg_v2()
9131 struct bnxt_ctx_mem_info *ctx = bp->ctx; in bnxt_backing_store_cfg_v2()
9138 ctxm = &ctx->ctx_arr[type]; in bnxt_backing_store_cfg_v2()
9141 if (!ctxm->mem_valid) { in bnxt_backing_store_cfg_v2()
9143 ctxm->max_entries, 1); in bnxt_backing_store_cfg_v2()
9145 netdev_warn(bp->dev, "Unable to setup ctx page for type:0x%x.\n", in bnxt_backing_store_cfg_v2()
9158 last_type = BNXT_CTX_MAX - 1; in bnxt_backing_store_cfg_v2()
9160 last_type = BNXT_CTX_L2_MAX - 1; in bnxt_backing_store_cfg_v2()
9162 ctx->ctx_arr[last_type].last = 1; in bnxt_backing_store_cfg_v2()
9165 ctxm = &ctx->ctx_arr[type]; in bnxt_backing_store_cfg_v2()
9167 if (!ctxm->mem_valid) in bnxt_backing_store_cfg_v2()
9169 rc = bnxt_hwrm_func_backing_store_cfg_v2(bp, ctxm, ctxm->last); in bnxt_backing_store_cfg_v2()
9177 * __bnxt_copy_ctx_mem - copy host context memory
9183 * @tail: The tail offset (last byte + 1) of context memory to end the copy
9194 struct bnxt_ctx_pg_info *ctx_pg = ctxm->pg_info; in __bnxt_copy_ctx_mem()
9196 int i, n = 1; in __bnxt_copy_ctx_mem()
9201 if (ctxm->instance_bmap) in __bnxt_copy_ctx_mem()
9202 n = hweight32(ctxm->instance_bmap); in __bnxt_copy_ctx_mem()
9215 size_t tail = ctxm->max_entries * ctxm->entry_size; in bnxt_copy_ctx_mem()
9224 int i, n = 1; in bnxt_free_one_ctx_mem()
9226 ctxm->last = 0; in bnxt_free_one_ctx_mem()
9228 if (ctxm->mem_valid && !force && (ctxm->flags & BNXT_CTX_MEM_PERSIST)) in bnxt_free_one_ctx_mem()
9231 ctx_pg = ctxm->pg_info; in bnxt_free_one_ctx_mem()
9233 if (ctxm->instance_bmap) in bnxt_free_one_ctx_mem()
9234 n = hweight32(ctxm->instance_bmap); in bnxt_free_one_ctx_mem()
9239 ctxm->pg_info = NULL; in bnxt_free_one_ctx_mem()
9240 ctxm->mem_valid = 0; in bnxt_free_one_ctx_mem()
9247 struct bnxt_ctx_mem_info *ctx = bp->ctx; in bnxt_free_ctx_mem()
9254 bnxt_free_one_ctx_mem(bp, &ctx->ctx_arr[type], force); in bnxt_free_ctx_mem()
9256 ctx->flags &= ~BNXT_CTX_FLAG_INITED; in bnxt_free_ctx_mem()
9259 bp->ctx = NULL; in bnxt_free_ctx_mem()
9274 u8 pg_lvl = 1; in bnxt_alloc_ctx_mem()
9279 netdev_err(bp->dev, "Failed querying context mem capability, rc = %d.\n", in bnxt_alloc_ctx_mem()
9283 ctx = bp->ctx; in bnxt_alloc_ctx_mem()
9284 if (!ctx || (ctx->flags & BNXT_CTX_FLAG_INITED)) in bnxt_alloc_ctx_mem()
9287 ctxm = &ctx->ctx_arr[BNXT_CTX_QP]; in bnxt_alloc_ctx_mem()
9288 l2_qps = ctxm->qp_l2_entries; in bnxt_alloc_ctx_mem()
9289 qp1_qps = ctxm->qp_qp1_entries; in bnxt_alloc_ctx_mem()
9290 fast_qpmd_qps = ctxm->qp_fast_qpmd_entries; in bnxt_alloc_ctx_mem()
9291 max_qps = ctxm->max_entries; in bnxt_alloc_ctx_mem()
9292 ctxm = &ctx->ctx_arr[BNXT_CTX_SRQ]; in bnxt_alloc_ctx_mem()
9293 srqs = ctxm->srq_l2_entries; in bnxt_alloc_ctx_mem()
9294 max_srqs = ctxm->max_entries; in bnxt_alloc_ctx_mem()
9296 if ((bp->flags & BNXT_FLAG_ROCE_CAP) && !is_kdump_kernel()) { in bnxt_alloc_ctx_mem()
9299 extra_qps = max_qps - l2_qps - qp1_qps; in bnxt_alloc_ctx_mem()
9300 extra_srqs = max_srqs - srqs; in bnxt_alloc_ctx_mem()
9303 max_qps - l2_qps - qp1_qps); in bnxt_alloc_ctx_mem()
9308 extra_srqs = min_t(u32, 8192, max_srqs - srqs); in bnxt_alloc_ctx_mem()
9314 ctxm = &ctx->ctx_arr[BNXT_CTX_QP]; in bnxt_alloc_ctx_mem()
9320 ctxm = &ctx->ctx_arr[BNXT_CTX_SRQ]; in bnxt_alloc_ctx_mem()
9325 ctxm = &ctx->ctx_arr[BNXT_CTX_CQ]; in bnxt_alloc_ctx_mem()
9326 rc = bnxt_setup_ctxm_pg_tbls(bp, ctxm, ctxm->cq_l2_entries + in bnxt_alloc_ctx_mem()
9331 ctxm = &ctx->ctx_arr[BNXT_CTX_VNIC]; in bnxt_alloc_ctx_mem()
9332 rc = bnxt_setup_ctxm_pg_tbls(bp, ctxm, ctxm->max_entries, 1); in bnxt_alloc_ctx_mem()
9336 ctxm = &ctx->ctx_arr[BNXT_CTX_STAT]; in bnxt_alloc_ctx_mem()
9337 rc = bnxt_setup_ctxm_pg_tbls(bp, ctxm, ctxm->max_entries, 1); in bnxt_alloc_ctx_mem()
9341 if (!(bp->flags & BNXT_FLAG_ROCE_CAP)) in bnxt_alloc_ctx_mem()
9344 ctxm = &ctx->ctx_arr[BNXT_CTX_MRAV]; in bnxt_alloc_ctx_mem()
9346 ctxm->split_entry_cnt == BNXT_CTX_MRAV_AV_SPLIT_ENTRY + 1) { in bnxt_alloc_ctx_mem()
9347 num_ah = ctxm->mrav_av_entries; in bnxt_alloc_ctx_mem()
9348 num_mr = ctxm->max_entries - num_ah; in bnxt_alloc_ctx_mem()
9353 num_mr = min_t(u32, ctxm->max_entries / 2, 1024 * 256); in bnxt_alloc_ctx_mem()
9355 ctxm->split_entry_cnt = BNXT_CTX_MRAV_AV_SPLIT_ENTRY + 1; in bnxt_alloc_ctx_mem()
9356 if (!ctxm->mrav_av_entries || ctxm->mrav_av_entries > num_ah) in bnxt_alloc_ctx_mem()
9357 ctxm->mrav_av_entries = num_ah; in bnxt_alloc_ctx_mem()
9365 ctxm = &ctx->ctx_arr[BNXT_CTX_TIM]; in bnxt_alloc_ctx_mem()
9366 rc = bnxt_setup_ctxm_pg_tbls(bp, ctxm, l2_qps + qp1_qps + extra_qps, 1); in bnxt_alloc_ctx_mem()
9372 ctxm = &ctx->ctx_arr[BNXT_CTX_STQM]; in bnxt_alloc_ctx_mem()
9373 min = ctxm->min_entries; in bnxt_alloc_ctx_mem()
9374 entries_sp = ctx->ctx_arr[BNXT_CTX_VNIC].vnic_entries + l2_qps + in bnxt_alloc_ctx_mem()
9380 ctxm = &ctx->ctx_arr[BNXT_CTX_FTQM]; in bnxt_alloc_ctx_mem()
9385 for (i = 0; i < ctx->tqm_fp_rings_count + 1; i++) in bnxt_alloc_ctx_mem()
9389 if (bp->fw_cap & BNXT_FW_CAP_BACKING_STORE_V2) in bnxt_alloc_ctx_mem()
9394 netdev_err(bp->dev, "Failed configuring context mem, rc = %d.\n", in bnxt_alloc_ctx_mem()
9398 ctx->flags |= BNXT_CTX_FLAG_INITED; in bnxt_alloc_ctx_mem()
9408 if (!(bp->fw_dbg_cap & DBG_QCAPS_RESP_FLAGS_CRASHDUMP_HOST_DDR)) in bnxt_hwrm_crash_dump_mem_cfg()
9421 req->pg_size_lvl = cpu_to_le16(page_attr | in bnxt_hwrm_crash_dump_mem_cfg()
9422 bp->fw_crash_mem->ring_mem.depth); in bnxt_hwrm_crash_dump_mem_cfg()
9423 req->pbl = cpu_to_le64(bp->fw_crash_mem->ring_mem.pg_tbl_map); in bnxt_hwrm_crash_dump_mem_cfg()
9424 req->size = cpu_to_le32(bp->fw_crash_len); in bnxt_hwrm_crash_dump_mem_cfg()
9425 req->output_dest_flags = cpu_to_le16(BNXT_DBG_CR_DUMP_MDM_CFG_DDR); in bnxt_hwrm_crash_dump_mem_cfg()
9431 if (bp->fw_crash_mem) { in bnxt_free_crash_dump_mem()
9432 bnxt_free_ctx_pg_tbls(bp, bp->fw_crash_mem); in bnxt_free_crash_dump_mem()
9433 kfree(bp->fw_crash_mem); in bnxt_free_crash_dump_mem()
9434 bp->fw_crash_mem = NULL; in bnxt_free_crash_dump_mem()
9443 if (!(bp->fw_dbg_cap & DBG_QCAPS_RESP_FLAGS_CRASHDUMP_HOST_DDR)) in bnxt_alloc_crash_dump_mem()
9453 if (bp->fw_crash_mem && in bnxt_alloc_crash_dump_mem()
9454 mem_size <= bp->fw_crash_mem->nr_pages * BNXT_PAGE_SIZE) in bnxt_alloc_crash_dump_mem()
9457 if (bp->fw_crash_mem) in bnxt_alloc_crash_dump_mem()
9458 bnxt_free_ctx_pg_tbls(bp, bp->fw_crash_mem); in bnxt_alloc_crash_dump_mem()
9460 bp->fw_crash_mem = kzalloc(sizeof(*bp->fw_crash_mem), in bnxt_alloc_crash_dump_mem()
9462 if (!bp->fw_crash_mem) in bnxt_alloc_crash_dump_mem()
9463 return -ENOMEM; in bnxt_alloc_crash_dump_mem()
9465 rc = bnxt_alloc_ctx_pg_tbls(bp, bp->fw_crash_mem, mem_size, 1, NULL); in bnxt_alloc_crash_dump_mem()
9472 bp->fw_crash_len = mem_size; in bnxt_alloc_crash_dump_mem()
9480 struct bnxt_hw_resc *hw_resc = &bp->hw_resc; in bnxt_hwrm_func_resc_qcaps()
9487 req->fid = cpu_to_le16(0xffff); in bnxt_hwrm_func_resc_qcaps()
9493 hw_resc->max_tx_sch_inputs = le16_to_cpu(resp->max_tx_scheduler_inputs); in bnxt_hwrm_func_resc_qcaps()
9497 hw_resc->min_rsscos_ctxs = le16_to_cpu(resp->min_rsscos_ctx); in bnxt_hwrm_func_resc_qcaps()
9498 hw_resc->max_rsscos_ctxs = le16_to_cpu(resp->max_rsscos_ctx); in bnxt_hwrm_func_resc_qcaps()
9499 hw_resc->min_cp_rings = le16_to_cpu(resp->min_cmpl_rings); in bnxt_hwrm_func_resc_qcaps()
9500 hw_resc->max_cp_rings = le16_to_cpu(resp->max_cmpl_rings); in bnxt_hwrm_func_resc_qcaps()
9501 hw_resc->min_tx_rings = le16_to_cpu(resp->min_tx_rings); in bnxt_hwrm_func_resc_qcaps()
9502 hw_resc->max_tx_rings = le16_to_cpu(resp->max_tx_rings); in bnxt_hwrm_func_resc_qcaps()
9503 hw_resc->min_rx_rings = le16_to_cpu(resp->min_rx_rings); in bnxt_hwrm_func_resc_qcaps()
9504 hw_resc->max_rx_rings = le16_to_cpu(resp->max_rx_rings); in bnxt_hwrm_func_resc_qcaps()
9505 hw_resc->min_hw_ring_grps = le16_to_cpu(resp->min_hw_ring_grps); in bnxt_hwrm_func_resc_qcaps()
9506 hw_resc->max_hw_ring_grps = le16_to_cpu(resp->max_hw_ring_grps); in bnxt_hwrm_func_resc_qcaps()
9507 hw_resc->min_l2_ctxs = le16_to_cpu(resp->min_l2_ctxs); in bnxt_hwrm_func_resc_qcaps()
9508 hw_resc->max_l2_ctxs = le16_to_cpu(resp->max_l2_ctxs); in bnxt_hwrm_func_resc_qcaps()
9509 hw_resc->min_vnics = le16_to_cpu(resp->min_vnics); in bnxt_hwrm_func_resc_qcaps()
9510 hw_resc->max_vnics = le16_to_cpu(resp->max_vnics); in bnxt_hwrm_func_resc_qcaps()
9511 hw_resc->min_stat_ctxs = le16_to_cpu(resp->min_stat_ctx); in bnxt_hwrm_func_resc_qcaps()
9512 hw_resc->max_stat_ctxs = le16_to_cpu(resp->max_stat_ctx); in bnxt_hwrm_func_resc_qcaps()
9514 if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) { in bnxt_hwrm_func_resc_qcaps()
9515 u16 max_msix = le16_to_cpu(resp->max_msix); in bnxt_hwrm_func_resc_qcaps()
9517 hw_resc->max_nqs = max_msix; in bnxt_hwrm_func_resc_qcaps()
9518 hw_resc->max_hw_ring_grps = hw_resc->max_rx_rings; in bnxt_hwrm_func_resc_qcaps()
9522 struct bnxt_pf_info *pf = &bp->pf; in bnxt_hwrm_func_resc_qcaps()
9524 pf->vf_resv_strategy = in bnxt_hwrm_func_resc_qcaps()
9525 le16_to_cpu(resp->vf_reservation_strategy); in bnxt_hwrm_func_resc_qcaps()
9526 if (pf->vf_resv_strategy > BNXT_VF_RESV_STRATEGY_MINIMAL_STATIC) in bnxt_hwrm_func_resc_qcaps()
9527 pf->vf_resv_strategy = BNXT_VF_RESV_STRATEGY_MAXIMAL; in bnxt_hwrm_func_resc_qcaps()
9538 struct bnxt_ptp_cfg *ptp = bp->ptp_cfg; in __bnxt_hwrm_ptp_qcfg()
9542 if (bp->hwrm_spec_code < 0x10801 || !BNXT_CHIP_P5_PLUS(bp)) { in __bnxt_hwrm_ptp_qcfg()
9543 rc = -ENODEV; in __bnxt_hwrm_ptp_qcfg()
9551 req->port_id = cpu_to_le16(bp->pf.port_id); in __bnxt_hwrm_ptp_qcfg()
9557 flags = resp->flags; in __bnxt_hwrm_ptp_qcfg()
9560 rc = -ENODEV; in __bnxt_hwrm_ptp_qcfg()
9566 rc = -ENOMEM; in __bnxt_hwrm_ptp_qcfg()
9569 ptp->bp = bp; in __bnxt_hwrm_ptp_qcfg()
9570 bp->ptp_cfg = ptp; in __bnxt_hwrm_ptp_qcfg()
9576 ptp->refclk_regs[0] = le32_to_cpu(resp->ts_ref_clock_reg_lower); in __bnxt_hwrm_ptp_qcfg()
9577 ptp->refclk_regs[1] = le32_to_cpu(resp->ts_ref_clock_reg_upper); in __bnxt_hwrm_ptp_qcfg()
9579 ptp->refclk_regs[0] = BNXT_TS_REG_TIMESYNC_TS0_LOWER; in __bnxt_hwrm_ptp_qcfg()
9580 ptp->refclk_regs[1] = BNXT_TS_REG_TIMESYNC_TS0_UPPER; in __bnxt_hwrm_ptp_qcfg()
9582 rc = -ENODEV; in __bnxt_hwrm_ptp_qcfg()
9585 ptp->rtc_configured = in __bnxt_hwrm_ptp_qcfg()
9589 netdev_warn(bp->dev, "PTP initialization failed.\n"); in __bnxt_hwrm_ptp_qcfg()
9598 bp->ptp_cfg = NULL; in __bnxt_hwrm_ptp_qcfg()
9606 struct bnxt_hw_resc *hw_resc = &bp->hw_resc; in __bnxt_hwrm_func_qcaps()
9614 req->fid = cpu_to_le16(0xffff); in __bnxt_hwrm_func_qcaps()
9620 flags = le32_to_cpu(resp->flags); in __bnxt_hwrm_func_qcaps()
9622 bp->flags |= BNXT_FLAG_ROCEV1_CAP; in __bnxt_hwrm_func_qcaps()
9624 bp->flags |= BNXT_FLAG_ROCEV2_CAP; in __bnxt_hwrm_func_qcaps()
9626 bp->fw_cap |= BNXT_FW_CAP_PCIE_STATS_SUPPORTED; in __bnxt_hwrm_func_qcaps()
9628 bp->fw_cap |= BNXT_FW_CAP_HOT_RESET; in __bnxt_hwrm_func_qcaps()
9630 bp->fw_cap |= BNXT_FW_CAP_EXT_STATS_SUPPORTED; in __bnxt_hwrm_func_qcaps()
9632 bp->fw_cap |= BNXT_FW_CAP_ERROR_RECOVERY; in __bnxt_hwrm_func_qcaps()
9634 bp->fw_cap |= BNXT_FW_CAP_ERR_RECOVER_RELOAD; in __bnxt_hwrm_func_qcaps()
9636 bp->fw_cap |= BNXT_FW_CAP_VLAN_TX_INSERT; in __bnxt_hwrm_func_qcaps()
9638 bp->fw_cap |= BNXT_FW_CAP_DBG_QCAPS; in __bnxt_hwrm_func_qcaps()
9640 flags_ext = le32_to_cpu(resp->flags_ext); in __bnxt_hwrm_func_qcaps()
9642 bp->fw_cap |= BNXT_FW_CAP_EXT_HW_STATS_SUPPORTED; in __bnxt_hwrm_func_qcaps()
9644 bp->fw_cap |= BNXT_FW_CAP_PTP_PPS; in __bnxt_hwrm_func_qcaps()
9646 bp->fw_cap |= BNXT_FW_CAP_PTP_RTC; in __bnxt_hwrm_func_qcaps()
9648 bp->fw_cap |= BNXT_FW_CAP_HOT_RESET_IF; in __bnxt_hwrm_func_qcaps()
9650 bp->fw_cap |= BNXT_FW_CAP_LIVEPATCH; in __bnxt_hwrm_func_qcaps()
9652 bp->fw_cap |= BNXT_FW_CAP_NPAR_1_2; in __bnxt_hwrm_func_qcaps()
9654 bp->fw_cap |= BNXT_FW_CAP_DFLT_VLAN_TPID_PCP; in __bnxt_hwrm_func_qcaps()
9656 bp->fw_cap |= BNXT_FW_CAP_BACKING_STORE_V2; in __bnxt_hwrm_func_qcaps()
9658 bp->flags |= BNXT_FLAG_TX_COAL_CMPL; in __bnxt_hwrm_func_qcaps()
9660 flags_ext2 = le32_to_cpu(resp->flags_ext2); in __bnxt_hwrm_func_qcaps()
9662 bp->fw_cap |= BNXT_FW_CAP_RX_ALL_PKT_TS; in __bnxt_hwrm_func_qcaps()
9664 bp->flags |= BNXT_FLAG_UDP_GSO_CAP; in __bnxt_hwrm_func_qcaps()
9666 bp->fw_cap |= BNXT_FW_CAP_TX_TS_CMP; in __bnxt_hwrm_func_qcaps()
9669 bp->fw_cap |= BNXT_FW_CAP_SW_MAX_RESOURCE_LIMITS; in __bnxt_hwrm_func_qcaps()
9672 bp->fw_cap |= BNXT_FW_CAP_ROCE_VF_RESC_MGMT_SUPPORTED; in __bnxt_hwrm_func_qcaps()
9674 bp->tx_push_thresh = 0; in __bnxt_hwrm_func_qcaps()
9677 bp->tx_push_thresh = BNXT_TX_PUSH_THRESH; in __bnxt_hwrm_func_qcaps()
9679 hw_resc->max_rsscos_ctxs = le16_to_cpu(resp->max_rsscos_ctx); in __bnxt_hwrm_func_qcaps()
9680 hw_resc->max_cp_rings = le16_to_cpu(resp->max_cmpl_rings); in __bnxt_hwrm_func_qcaps()
9681 hw_resc->max_tx_rings = le16_to_cpu(resp->max_tx_rings); in __bnxt_hwrm_func_qcaps()
9682 hw_resc->max_rx_rings = le16_to_cpu(resp->max_rx_rings); in __bnxt_hwrm_func_qcaps()
9683 hw_resc->max_hw_ring_grps = le32_to_cpu(resp->max_hw_ring_grps); in __bnxt_hwrm_func_qcaps()
9684 if (!hw_resc->max_hw_ring_grps) in __bnxt_hwrm_func_qcaps()
9685 hw_resc->max_hw_ring_grps = hw_resc->max_tx_rings; in __bnxt_hwrm_func_qcaps()
9686 hw_resc->max_l2_ctxs = le16_to_cpu(resp->max_l2_ctxs); in __bnxt_hwrm_func_qcaps()
9687 hw_resc->max_vnics = le16_to_cpu(resp->max_vnics); in __bnxt_hwrm_func_qcaps()
9688 hw_resc->max_stat_ctxs = le16_to_cpu(resp->max_stat_ctx); in __bnxt_hwrm_func_qcaps()
9690 hw_resc->max_encap_records = le32_to_cpu(resp->max_encap_records); in __bnxt_hwrm_func_qcaps()
9691 hw_resc->max_decap_records = le32_to_cpu(resp->max_decap_records); in __bnxt_hwrm_func_qcaps()
9692 hw_resc->max_tx_em_flows = le32_to_cpu(resp->max_tx_em_flows); in __bnxt_hwrm_func_qcaps()
9693 hw_resc->max_tx_wm_flows = le32_to_cpu(resp->max_tx_wm_flows); in __bnxt_hwrm_func_qcaps()
9694 hw_resc->max_rx_em_flows = le32_to_cpu(resp->max_rx_em_flows); in __bnxt_hwrm_func_qcaps()
9695 hw_resc->max_rx_wm_flows = le32_to_cpu(resp->max_rx_wm_flows); in __bnxt_hwrm_func_qcaps()
9698 struct bnxt_pf_info *pf = &bp->pf; in __bnxt_hwrm_func_qcaps()
9700 pf->fw_fid = le16_to_cpu(resp->fid); in __bnxt_hwrm_func_qcaps()
9701 pf->port_id = le16_to_cpu(resp->port_id); in __bnxt_hwrm_func_qcaps()
9702 memcpy(pf->mac_addr, resp->mac_address, ETH_ALEN); in __bnxt_hwrm_func_qcaps()
9703 pf->first_vf_id = le16_to_cpu(resp->first_vf_id); in __bnxt_hwrm_func_qcaps()
9704 pf->max_vfs = le16_to_cpu(resp->max_vfs); in __bnxt_hwrm_func_qcaps()
9705 bp->flags &= ~BNXT_FLAG_WOL_CAP; in __bnxt_hwrm_func_qcaps()
9707 bp->flags |= BNXT_FLAG_WOL_CAP; in __bnxt_hwrm_func_qcaps()
9709 bp->fw_cap |= BNXT_FW_CAP_PTP; in __bnxt_hwrm_func_qcaps()
9712 kfree(bp->ptp_cfg); in __bnxt_hwrm_func_qcaps()
9713 bp->ptp_cfg = NULL; in __bnxt_hwrm_func_qcaps()
9717 struct bnxt_vf_info *vf = &bp->vf; in __bnxt_hwrm_func_qcaps()
9719 vf->fw_fid = le16_to_cpu(resp->fid); in __bnxt_hwrm_func_qcaps()
9720 memcpy(vf->mac_addr, resp->mac_address, ETH_ALEN); in __bnxt_hwrm_func_qcaps()
9723 bp->tso_max_segs = le16_to_cpu(resp->max_tso_segs); in __bnxt_hwrm_func_qcaps()
9736 bp->fw_dbg_cap = 0; in bnxt_hwrm_dbg_qcaps()
9737 if (!(bp->fw_cap & BNXT_FW_CAP_DBG_QCAPS)) in bnxt_hwrm_dbg_qcaps()
9744 req->fid = cpu_to_le16(0xffff); in bnxt_hwrm_dbg_qcaps()
9750 bp->fw_dbg_cap = le32_to_cpu(resp->flags); in bnxt_hwrm_dbg_qcaps()
9770 netdev_err(bp->dev, "hwrm query qportcfg failure rc: %d\n", rc); in bnxt_hwrm_func_qcaps()
9773 if (bp->hwrm_spec_code >= 0x10803) { in bnxt_hwrm_func_qcaps()
9779 bp->fw_cap |= BNXT_FW_CAP_NEW_RM; in bnxt_hwrm_func_qcaps()
9791 if (!(bp->fw_cap & BNXT_FW_CAP_CFA_ADV_FLOW)) in bnxt_hwrm_cfa_adv_flow_mgnt_qcaps()
9803 flags = le32_to_cpu(resp->flags); in bnxt_hwrm_cfa_adv_flow_mgnt_qcaps()
9806 bp->fw_cap |= BNXT_FW_CAP_CFA_RFS_RING_TBL_IDX_V2; in bnxt_hwrm_cfa_adv_flow_mgnt_qcaps()
9810 bp->fw_cap |= BNXT_FW_CAP_CFA_RFS_RING_TBL_IDX_V3; in bnxt_hwrm_cfa_adv_flow_mgnt_qcaps()
9814 bp->fw_cap |= BNXT_FW_CAP_CFA_NTUPLE_RX_EXT_IP_PROTO; in bnxt_hwrm_cfa_adv_flow_mgnt_qcaps()
9823 if (bp->fw_health) in __bnxt_alloc_fw_health()
9826 bp->fw_health = kzalloc(sizeof(*bp->fw_health), GFP_KERNEL); in __bnxt_alloc_fw_health()
9827 if (!bp->fw_health) in __bnxt_alloc_fw_health()
9828 return -ENOMEM; in __bnxt_alloc_fw_health()
9830 mutex_init(&bp->fw_health->lock); in __bnxt_alloc_fw_health()
9838 if (!(bp->fw_cap & BNXT_FW_CAP_HOT_RESET) && in bnxt_alloc_fw_health()
9839 !(bp->fw_cap & BNXT_FW_CAP_ERROR_RECOVERY)) in bnxt_alloc_fw_health()
9844 bp->fw_cap &= ~BNXT_FW_CAP_HOT_RESET; in bnxt_alloc_fw_health()
9845 bp->fw_cap &= ~BNXT_FW_CAP_ERROR_RECOVERY; in bnxt_alloc_fw_health()
9854 writel(reg & BNXT_GRC_BASE_MASK, bp->bar0 + in __bnxt_map_fw_health_reg()
9861 struct bnxt_fw_health *fw_health = bp->fw_health; in bnxt_inv_fw_health_reg()
9867 reg_type = BNXT_FW_HEALTH_REG_TYPE(fw_health->regs[BNXT_FW_HEALTH_REG]); in bnxt_inv_fw_health_reg()
9869 fw_health->status_reliable = false; in bnxt_inv_fw_health_reg()
9871 reg_type = BNXT_FW_HEALTH_REG_TYPE(fw_health->regs[BNXT_FW_RESET_CNT_REG]); in bnxt_inv_fw_health_reg()
9873 fw_health->resets_reliable = false; in bnxt_inv_fw_health_reg()
9883 if (bp->fw_health) in bnxt_try_map_fw_health_reg()
9884 bp->fw_health->status_reliable = false; in bnxt_try_map_fw_health_reg()
9887 hs = bp->bar0 + BNXT_FW_HEALTH_WIN_OFF(HCOMM_STATUS_STRUCT_LOC); in bnxt_try_map_fw_health_reg()
9891 if (!bp->chip_num) { in bnxt_try_map_fw_health_reg()
9893 bp->chip_num = readl(bp->bar0 + in bnxt_try_map_fw_health_reg()
9908 netdev_warn(bp->dev, "no memory for firmware status checks\n"); in bnxt_try_map_fw_health_reg()
9912 bp->fw_health->regs[BNXT_FW_HEALTH_REG] = status_loc; in bnxt_try_map_fw_health_reg()
9916 bp->fw_health->mapped_regs[BNXT_FW_HEALTH_REG] = in bnxt_try_map_fw_health_reg()
9920 bp->fw_health->status_reliable = true; in bnxt_try_map_fw_health_reg()
9925 struct bnxt_fw_health *fw_health = bp->fw_health; in bnxt_map_fw_health_regs()
9929 bp->fw_health->status_reliable = false; in bnxt_map_fw_health_regs()
9930 bp->fw_health->resets_reliable = false; in bnxt_map_fw_health_regs()
9931 /* Only pre-map the monitoring GRC registers using window 3 */ in bnxt_map_fw_health_regs()
9933 u32 reg = fw_health->regs[i]; in bnxt_map_fw_health_regs()
9940 return -ERANGE; in bnxt_map_fw_health_regs()
9941 fw_health->mapped_regs[i] = BNXT_FW_HEALTH_WIN_OFF(reg); in bnxt_map_fw_health_regs()
9943 bp->fw_health->status_reliable = true; in bnxt_map_fw_health_regs()
9944 bp->fw_health->resets_reliable = true; in bnxt_map_fw_health_regs()
9954 if (!bp->fw_health) in bnxt_remap_fw_health_regs()
9957 if (bp->fw_cap & BNXT_FW_CAP_ERROR_RECOVERY) { in bnxt_remap_fw_health_regs()
9958 bp->fw_health->status_reliable = true; in bnxt_remap_fw_health_regs()
9959 bp->fw_health->resets_reliable = true; in bnxt_remap_fw_health_regs()
9967 struct bnxt_fw_health *fw_health = bp->fw_health; in bnxt_hwrm_error_recovery_qcfg()
9972 if (!(bp->fw_cap & BNXT_FW_CAP_ERROR_RECOVERY)) in bnxt_hwrm_error_recovery_qcfg()
9983 fw_health->flags = le32_to_cpu(resp->flags); in bnxt_hwrm_error_recovery_qcfg()
9984 if ((fw_health->flags & ERROR_RECOVERY_QCFG_RESP_FLAGS_CO_CPU) && in bnxt_hwrm_error_recovery_qcfg()
9985 !(bp->fw_cap & BNXT_FW_CAP_KONG_MB_CHNL)) { in bnxt_hwrm_error_recovery_qcfg()
9986 rc = -EINVAL; in bnxt_hwrm_error_recovery_qcfg()
9989 fw_health->polling_dsecs = le32_to_cpu(resp->driver_polling_freq); in bnxt_hwrm_error_recovery_qcfg()
9990 fw_health->master_func_wait_dsecs = in bnxt_hwrm_error_recovery_qcfg()
9991 le32_to_cpu(resp->master_func_wait_period); in bnxt_hwrm_error_recovery_qcfg()
9992 fw_health->normal_func_wait_dsecs = in bnxt_hwrm_error_recovery_qcfg()
9993 le32_to_cpu(resp->normal_func_wait_period); in bnxt_hwrm_error_recovery_qcfg()
9994 fw_health->post_reset_wait_dsecs = in bnxt_hwrm_error_recovery_qcfg()
9995 le32_to_cpu(resp->master_func_wait_period_after_reset); in bnxt_hwrm_error_recovery_qcfg()
9996 fw_health->post_reset_max_wait_dsecs = in bnxt_hwrm_error_recovery_qcfg()
9997 le32_to_cpu(resp->max_bailout_time_after_reset); in bnxt_hwrm_error_recovery_qcfg()
9998 fw_health->regs[BNXT_FW_HEALTH_REG] = in bnxt_hwrm_error_recovery_qcfg()
9999 le32_to_cpu(resp->fw_health_status_reg); in bnxt_hwrm_error_recovery_qcfg()
10000 fw_health->regs[BNXT_FW_HEARTBEAT_REG] = in bnxt_hwrm_error_recovery_qcfg()
10001 le32_to_cpu(resp->fw_heartbeat_reg); in bnxt_hwrm_error_recovery_qcfg()
10002 fw_health->regs[BNXT_FW_RESET_CNT_REG] = in bnxt_hwrm_error_recovery_qcfg()
10003 le32_to_cpu(resp->fw_reset_cnt_reg); in bnxt_hwrm_error_recovery_qcfg()
10004 fw_health->regs[BNXT_FW_RESET_INPROG_REG] = in bnxt_hwrm_error_recovery_qcfg()
10005 le32_to_cpu(resp->reset_inprogress_reg); in bnxt_hwrm_error_recovery_qcfg()
10006 fw_health->fw_reset_inprog_reg_mask = in bnxt_hwrm_error_recovery_qcfg()
10007 le32_to_cpu(resp->reset_inprogress_reg_mask); in bnxt_hwrm_error_recovery_qcfg()
10008 fw_health->fw_reset_seq_cnt = resp->reg_array_cnt; in bnxt_hwrm_error_recovery_qcfg()
10009 if (fw_health->fw_reset_seq_cnt >= 16) { in bnxt_hwrm_error_recovery_qcfg()
10010 rc = -EINVAL; in bnxt_hwrm_error_recovery_qcfg()
10013 for (i = 0; i < fw_health->fw_reset_seq_cnt; i++) { in bnxt_hwrm_error_recovery_qcfg()
10014 fw_health->fw_reset_seq_regs[i] = in bnxt_hwrm_error_recovery_qcfg()
10015 le32_to_cpu(resp->reset_reg[i]); in bnxt_hwrm_error_recovery_qcfg()
10016 fw_health->fw_reset_seq_vals[i] = in bnxt_hwrm_error_recovery_qcfg()
10017 le32_to_cpu(resp->reset_reg_val[i]); in bnxt_hwrm_error_recovery_qcfg()
10018 fw_health->fw_reset_seq_delay_msec[i] = in bnxt_hwrm_error_recovery_qcfg()
10019 resp->delay_after_reset[i]; in bnxt_hwrm_error_recovery_qcfg()
10026 bp->fw_cap &= ~BNXT_FW_CAP_ERROR_RECOVERY; in bnxt_hwrm_error_recovery_qcfg()
10039 req->enables = 0; in bnxt_hwrm_func_reset()
10049 snprintf(bp->nvm_cfg_ver, FW_VER_STR_LEN, "%d.%d.%d", in bnxt_nvm_cfg_ver_get()
10071 if (!resp->max_configurable_queues) { in bnxt_hwrm_queue_qportcfg()
10072 rc = -EINVAL; in bnxt_hwrm_queue_qportcfg()
10075 bp->max_tc = resp->max_configurable_queues; in bnxt_hwrm_queue_qportcfg()
10076 bp->max_lltc = resp->max_configurable_lossless_queues; in bnxt_hwrm_queue_qportcfg()
10077 if (bp->max_tc > BNXT_MAX_QUEUE) in bnxt_hwrm_queue_qportcfg()
10078 bp->max_tc = BNXT_MAX_QUEUE; in bnxt_hwrm_queue_qportcfg()
10080 no_rdma = !(bp->flags & BNXT_FLAG_ROCE_CAP); in bnxt_hwrm_queue_qportcfg()
10081 qptr = &resp->queue_id0; in bnxt_hwrm_queue_qportcfg()
10082 for (i = 0, j = 0; i < bp->max_tc; i++) { in bnxt_hwrm_queue_qportcfg()
10083 bp->q_info[j].queue_id = *qptr; in bnxt_hwrm_queue_qportcfg()
10084 bp->q_ids[i] = *qptr++; in bnxt_hwrm_queue_qportcfg()
10085 bp->q_info[j].queue_profile = *qptr++; in bnxt_hwrm_queue_qportcfg()
10086 bp->tc_to_qidx[j] = j; in bnxt_hwrm_queue_qportcfg()
10087 if (!BNXT_CNPQ(bp->q_info[j].queue_profile) || in bnxt_hwrm_queue_qportcfg()
10091 bp->max_q = bp->max_tc; in bnxt_hwrm_queue_qportcfg()
10092 bp->max_tc = max_t(u8, j, 1); in bnxt_hwrm_queue_qportcfg()
10094 if (resp->queue_cfg_info & QUEUE_QPORTCFG_RESP_QUEUE_CFG_INFO_ASYM_CFG) in bnxt_hwrm_queue_qportcfg()
10095 bp->max_tc = 1; in bnxt_hwrm_queue_qportcfg()
10097 if (bp->max_lltc > bp->max_tc) in bnxt_hwrm_queue_qportcfg()
10098 bp->max_lltc = bp->max_tc; in bnxt_hwrm_queue_qportcfg()
10114 req->hwrm_intf_maj = HWRM_VERSION_MAJOR; in bnxt_hwrm_poll()
10115 req->hwrm_intf_min = HWRM_VERSION_MINOR; in bnxt_hwrm_poll()
10116 req->hwrm_intf_upd = HWRM_VERSION_UPDATE; in bnxt_hwrm_poll()
10136 bp->hwrm_max_req_len = HWRM_MAX_REQ_LEN; in bnxt_hwrm_ver_get()
10137 req->hwrm_intf_maj = HWRM_VERSION_MAJOR; in bnxt_hwrm_ver_get()
10138 req->hwrm_intf_min = HWRM_VERSION_MINOR; in bnxt_hwrm_ver_get()
10139 req->hwrm_intf_upd = HWRM_VERSION_UPDATE; in bnxt_hwrm_ver_get()
10146 memcpy(&bp->ver_resp, resp, sizeof(struct hwrm_ver_get_output)); in bnxt_hwrm_ver_get()
10148 bp->hwrm_spec_code = resp->hwrm_intf_maj_8b << 16 | in bnxt_hwrm_ver_get()
10149 resp->hwrm_intf_min_8b << 8 | in bnxt_hwrm_ver_get()
10150 resp->hwrm_intf_upd_8b; in bnxt_hwrm_ver_get()
10151 if (resp->hwrm_intf_maj_8b < 1) { in bnxt_hwrm_ver_get()
10152 netdev_warn(bp->dev, "HWRM interface %d.%d.%d is older than 1.0.0.\n", in bnxt_hwrm_ver_get()
10153 resp->hwrm_intf_maj_8b, resp->hwrm_intf_min_8b, in bnxt_hwrm_ver_get()
10154 resp->hwrm_intf_upd_8b); in bnxt_hwrm_ver_get()
10155 netdev_warn(bp->dev, "Please update firmware with HWRM interface 1.0.0 or newer.\n"); in bnxt_hwrm_ver_get()
10161 if (bp->hwrm_spec_code > hwrm_ver) in bnxt_hwrm_ver_get()
10162 snprintf(bp->hwrm_ver_supp, FW_VER_STR_LEN, "%d.%d.%d", in bnxt_hwrm_ver_get()
10166 snprintf(bp->hwrm_ver_supp, FW_VER_STR_LEN, "%d.%d.%d", in bnxt_hwrm_ver_get()
10167 resp->hwrm_intf_maj_8b, resp->hwrm_intf_min_8b, in bnxt_hwrm_ver_get()
10168 resp->hwrm_intf_upd_8b); in bnxt_hwrm_ver_get()
10170 fw_maj = le16_to_cpu(resp->hwrm_fw_major); in bnxt_hwrm_ver_get()
10171 if (bp->hwrm_spec_code > 0x10803 && fw_maj) { in bnxt_hwrm_ver_get()
10172 fw_min = le16_to_cpu(resp->hwrm_fw_minor); in bnxt_hwrm_ver_get()
10173 fw_bld = le16_to_cpu(resp->hwrm_fw_build); in bnxt_hwrm_ver_get()
10174 fw_rsv = le16_to_cpu(resp->hwrm_fw_patch); in bnxt_hwrm_ver_get()
10177 fw_maj = resp->hwrm_fw_maj_8b; in bnxt_hwrm_ver_get()
10178 fw_min = resp->hwrm_fw_min_8b; in bnxt_hwrm_ver_get()
10179 fw_bld = resp->hwrm_fw_bld_8b; in bnxt_hwrm_ver_get()
10180 fw_rsv = resp->hwrm_fw_rsvd_8b; in bnxt_hwrm_ver_get()
10183 bp->fw_ver_code = BNXT_FW_VER_CODE(fw_maj, fw_min, fw_bld, fw_rsv); in bnxt_hwrm_ver_get()
10184 snprintf(bp->fw_ver_str, len, "%d.%d.%d.%d", fw_maj, fw_min, fw_bld, in bnxt_hwrm_ver_get()
10187 if (strlen(resp->active_pkg_name)) { in bnxt_hwrm_ver_get()
10188 int fw_ver_len = strlen(bp->fw_ver_str); in bnxt_hwrm_ver_get()
10190 snprintf(bp->fw_ver_str + fw_ver_len, in bnxt_hwrm_ver_get()
10191 FW_VER_STR_LEN - fw_ver_len - 1, "/pkg %s", in bnxt_hwrm_ver_get()
10192 resp->active_pkg_name); in bnxt_hwrm_ver_get()
10193 bp->fw_cap |= BNXT_FW_CAP_PKG_VER; in bnxt_hwrm_ver_get()
10196 bp->hwrm_cmd_timeout = le16_to_cpu(resp->def_req_timeout); in bnxt_hwrm_ver_get()
10197 if (!bp->hwrm_cmd_timeout) in bnxt_hwrm_ver_get()
10198 bp->hwrm_cmd_timeout = DFLT_HWRM_CMD_TIMEOUT; in bnxt_hwrm_ver_get()
10199 bp->hwrm_cmd_max_timeout = le16_to_cpu(resp->max_req_timeout) * 1000; in bnxt_hwrm_ver_get()
10200 if (!bp->hwrm_cmd_max_timeout) in bnxt_hwrm_ver_get()
10201 bp->hwrm_cmd_max_timeout = HWRM_CMD_MAX_TIMEOUT; in bnxt_hwrm_ver_get()
10202 max_tmo_secs = bp->hwrm_cmd_max_timeout / 1000; in bnxt_hwrm_ver_get()
10204 if (bp->hwrm_cmd_max_timeout > HWRM_CMD_MAX_TIMEOUT || in bnxt_hwrm_ver_get()
10206 …netdev_warn(bp->dev, "Device requests max timeout of %d seconds, may trigger hung task watchdog (k… in bnxt_hwrm_ver_get()
10211 if (resp->hwrm_intf_maj_8b >= 1) { in bnxt_hwrm_ver_get()
10212 bp->hwrm_max_req_len = le16_to_cpu(resp->max_req_win_len); in bnxt_hwrm_ver_get()
10213 bp->hwrm_max_ext_req_len = le16_to_cpu(resp->max_ext_req_len); in bnxt_hwrm_ver_get()
10215 if (bp->hwrm_max_ext_req_len < HWRM_MAX_REQ_LEN) in bnxt_hwrm_ver_get()
10216 bp->hwrm_max_ext_req_len = HWRM_MAX_REQ_LEN; in bnxt_hwrm_ver_get()
10218 bp->chip_num = le16_to_cpu(resp->chip_num); in bnxt_hwrm_ver_get()
10219 bp->chip_rev = resp->chip_rev; in bnxt_hwrm_ver_get()
10220 if (bp->chip_num == CHIP_NUM_58700 && !resp->chip_rev && in bnxt_hwrm_ver_get()
10221 !resp->chip_metal) in bnxt_hwrm_ver_get()
10222 bp->flags |= BNXT_FLAG_CHIP_NITRO_A0; in bnxt_hwrm_ver_get()
10224 dev_caps_cfg = le32_to_cpu(resp->dev_caps_cfg); in bnxt_hwrm_ver_get()
10227 bp->fw_cap |= BNXT_FW_CAP_SHORT_CMD; in bnxt_hwrm_ver_get()
10230 bp->fw_cap |= BNXT_FW_CAP_KONG_MB_CHNL; in bnxt_hwrm_ver_get()
10234 bp->fw_cap |= BNXT_FW_CAP_OVS_64BIT_HANDLE; in bnxt_hwrm_ver_get()
10238 bp->fw_cap |= BNXT_FW_CAP_TRUSTED_VF; in bnxt_hwrm_ver_get()
10242 bp->fw_cap |= BNXT_FW_CAP_CFA_ADV_FLOW; in bnxt_hwrm_ver_get()
10256 if ((BNXT_VF(bp) && bp->hwrm_spec_code < 0x10901) || in bnxt_hwrm_fw_set_time()
10257 bp->hwrm_spec_code < 0x10400) in bnxt_hwrm_fw_set_time()
10258 return -EOPNOTSUPP; in bnxt_hwrm_fw_set_time()
10265 req->year = cpu_to_le16(1900 + tm.tm_year); in bnxt_hwrm_fw_set_time()
10266 req->month = 1 + tm.tm_mon; in bnxt_hwrm_fw_set_time()
10267 req->day = tm.tm_mday; in bnxt_hwrm_fw_set_time()
10268 req->hour = tm.tm_hour; in bnxt_hwrm_fw_set_time()
10269 req->minute = tm.tm_min; in bnxt_hwrm_fw_set_time()
10270 req->second = tm.tm_sec; in bnxt_hwrm_fw_set_time()
10281 sw_tmp += mask + 1; in bnxt_add_one_ctr()
10296 if (masks[i] == -1ULL) in __bnxt_accumulate_stats()
10305 if (!stats->hw_stats) in bnxt_accumulate_stats()
10308 __bnxt_accumulate_stats(stats->hw_stats, stats->sw_stats, in bnxt_accumulate_stats()
10309 stats->hw_masks, stats->len / 8, false); in bnxt_accumulate_stats()
10319 if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) in bnxt_accumulate_all_stats()
10322 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_accumulate_all_stats()
10323 struct bnxt_napi *bnapi = bp->bnapi[i]; in bnxt_accumulate_all_stats()
10327 cpr = &bnapi->cp_ring; in bnxt_accumulate_all_stats()
10328 stats = &cpr->stats; in bnxt_accumulate_all_stats()
10331 __bnxt_accumulate_stats(stats->hw_stats, stats->sw_stats, in bnxt_accumulate_all_stats()
10332 ring0_stats->hw_masks, in bnxt_accumulate_all_stats()
10333 ring0_stats->len / 8, ignore_zero); in bnxt_accumulate_all_stats()
10335 if (bp->flags & BNXT_FLAG_PORT_STATS) { in bnxt_accumulate_all_stats()
10336 struct bnxt_stats_mem *stats = &bp->port_stats; in bnxt_accumulate_all_stats()
10337 __le64 *hw_stats = stats->hw_stats; in bnxt_accumulate_all_stats()
10338 u64 *sw_stats = stats->sw_stats; in bnxt_accumulate_all_stats()
10339 u64 *masks = stats->hw_masks; in bnxt_accumulate_all_stats()
10351 if (bp->flags & BNXT_FLAG_PORT_STATS_EXT) { in bnxt_accumulate_all_stats()
10352 bnxt_accumulate_stats(&bp->rx_port_stats_ext); in bnxt_accumulate_all_stats()
10353 bnxt_accumulate_stats(&bp->tx_port_stats_ext); in bnxt_accumulate_all_stats()
10360 struct bnxt_pf_info *pf = &bp->pf; in bnxt_hwrm_port_qstats()
10363 if (!(bp->flags & BNXT_FLAG_PORT_STATS)) in bnxt_hwrm_port_qstats()
10366 if (flags && !(bp->fw_cap & BNXT_FW_CAP_EXT_HW_STATS_SUPPORTED)) in bnxt_hwrm_port_qstats()
10367 return -EOPNOTSUPP; in bnxt_hwrm_port_qstats()
10373 req->flags = flags; in bnxt_hwrm_port_qstats()
10374 req->port_id = cpu_to_le16(pf->port_id); in bnxt_hwrm_port_qstats()
10375 req->tx_stat_host_addr = cpu_to_le64(bp->port_stats.hw_stats_map + in bnxt_hwrm_port_qstats()
10377 req->rx_stat_host_addr = cpu_to_le64(bp->port_stats.hw_stats_map); in bnxt_hwrm_port_qstats()
10387 struct bnxt_pf_info *pf = &bp->pf; in bnxt_hwrm_port_qstats_ext()
10391 if (!(bp->flags & BNXT_FLAG_PORT_STATS_EXT)) in bnxt_hwrm_port_qstats_ext()
10394 if (flags && !(bp->fw_cap & BNXT_FW_CAP_EXT_HW_STATS_SUPPORTED)) in bnxt_hwrm_port_qstats_ext()
10395 return -EOPNOTSUPP; in bnxt_hwrm_port_qstats_ext()
10401 req_qs->flags = flags; in bnxt_hwrm_port_qstats_ext()
10402 req_qs->port_id = cpu_to_le16(pf->port_id); in bnxt_hwrm_port_qstats_ext()
10403 req_qs->rx_stat_size = cpu_to_le16(sizeof(struct rx_port_stats_ext)); in bnxt_hwrm_port_qstats_ext()
10404 req_qs->rx_stat_host_addr = cpu_to_le64(bp->rx_port_stats_ext.hw_stats_map); in bnxt_hwrm_port_qstats_ext()
10405 tx_stat_size = bp->tx_port_stats_ext.hw_stats ? in bnxt_hwrm_port_qstats_ext()
10407 req_qs->tx_stat_size = cpu_to_le16(tx_stat_size); in bnxt_hwrm_port_qstats_ext()
10408 req_qs->tx_stat_host_addr = cpu_to_le64(bp->tx_port_stats_ext.hw_stats_map); in bnxt_hwrm_port_qstats_ext()
10412 bp->fw_rx_stats_ext_size = in bnxt_hwrm_port_qstats_ext()
10413 le16_to_cpu(resp_qs->rx_stat_size) / 8; in bnxt_hwrm_port_qstats_ext()
10415 bp->fw_rx_stats_ext_size > BNXT_RX_STATS_EXT_NUM_LEGACY) in bnxt_hwrm_port_qstats_ext()
10416 bp->fw_rx_stats_ext_size = BNXT_RX_STATS_EXT_NUM_LEGACY; in bnxt_hwrm_port_qstats_ext()
10418 bp->fw_tx_stats_ext_size = tx_stat_size ? in bnxt_hwrm_port_qstats_ext()
10419 le16_to_cpu(resp_qs->tx_stat_size) / 8 : 0; in bnxt_hwrm_port_qstats_ext()
10421 bp->fw_rx_stats_ext_size = 0; in bnxt_hwrm_port_qstats_ext()
10422 bp->fw_tx_stats_ext_size = 0; in bnxt_hwrm_port_qstats_ext()
10429 if (bp->fw_tx_stats_ext_size <= in bnxt_hwrm_port_qstats_ext()
10431 bp->pri2cos_valid = 0; in bnxt_hwrm_port_qstats_ext()
10439 req_qc->flags = cpu_to_le32(QUEUE_PRI2COS_QCFG_REQ_FLAGS_IVLAN); in bnxt_hwrm_port_qstats_ext()
10447 pri2cos = &resp_qc->pri0_cos_queue_id; in bnxt_hwrm_port_qstats_ext()
10455 bp->pri2cos_valid = false; in bnxt_hwrm_port_qstats_ext()
10459 for (j = 0; j < bp->max_q; j++) { in bnxt_hwrm_port_qstats_ext()
10460 if (bp->q_ids[j] == queue_id) in bnxt_hwrm_port_qstats_ext()
10461 bp->pri2cos_idx[i] = queue_idx; in bnxt_hwrm_port_qstats_ext()
10464 bp->pri2cos_valid = true; in bnxt_hwrm_port_qstats_ext()
10485 tpa_flags = bp->flags & BNXT_FLAG_TPA; in bnxt_set_tpa()
10488 for (i = 0; i < bp->nr_vnics; i++) { in bnxt_set_tpa()
10489 rc = bnxt_hwrm_vnic_set_tpa(bp, &bp->vnic_info[i], tpa_flags); in bnxt_set_tpa()
10491 netdev_err(bp->dev, "hwrm vnic set tpa failure rc for vnic %d: %x\n", in bnxt_set_tpa()
10503 for (i = 0; i < bp->nr_vnics; i++) in bnxt_hwrm_clear_vnic_rss()
10504 bnxt_hwrm_vnic_set_rss(bp, &bp->vnic_info[i], false); in bnxt_hwrm_clear_vnic_rss()
10509 if (!bp->vnic_info) in bnxt_clear_vnic()
10513 if (!(bp->flags & BNXT_FLAG_CHIP_P5_PLUS)) { in bnxt_clear_vnic()
10519 if (bp->flags & BNXT_FLAG_TPA) in bnxt_clear_vnic()
10522 if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) in bnxt_clear_vnic()
10549 return -EINVAL; in bnxt_hwrm_set_br_mode()
10555 req->fid = cpu_to_le16(0xffff); in bnxt_hwrm_set_br_mode()
10556 req->enables = cpu_to_le32(FUNC_CFG_REQ_ENABLES_EVB_MODE); in bnxt_hwrm_set_br_mode()
10557 req->evb_mode = evb_mode; in bnxt_hwrm_set_br_mode()
10566 if (BNXT_VF(bp) || bp->hwrm_spec_code < 0x10803) in bnxt_hwrm_set_cache_line_size()
10573 req->fid = cpu_to_le16(0xffff); in bnxt_hwrm_set_cache_line_size()
10574 req->enables = cpu_to_le32(FUNC_CFG_REQ_ENABLES_CACHE_LINESIZE); in bnxt_hwrm_set_cache_line_size()
10575 req->options = FUNC_CFG_REQ_OPTIONS_CACHE_LINESIZE_SIZE_64; in bnxt_hwrm_set_cache_line_size()
10577 req->options = FUNC_CFG_REQ_OPTIONS_CACHE_LINESIZE_SIZE_128; in bnxt_hwrm_set_cache_line_size()
10586 if (vnic->flags & BNXT_VNIC_RFS_NEW_RSS_FLAG) in __bnxt_setup_vnic()
10592 netdev_err(bp->dev, "hwrm vnic %d alloc failure rc: %x\n", in __bnxt_setup_vnic()
10593 vnic->vnic_id, rc); in __bnxt_setup_vnic()
10596 bp->rsscos_nr_ctxs++; in __bnxt_setup_vnic()
10599 rc = bnxt_hwrm_vnic_ctx_alloc(bp, vnic, 1); in __bnxt_setup_vnic()
10601 netdev_err(bp->dev, "hwrm vnic %d cos ctx alloc failure rc: %x\n", in __bnxt_setup_vnic()
10602 vnic->vnic_id, rc); in __bnxt_setup_vnic()
10605 bp->rsscos_nr_ctxs++; in __bnxt_setup_vnic()
10612 netdev_err(bp->dev, "hwrm vnic %d cfg failure rc: %x\n", in __bnxt_setup_vnic()
10613 vnic->vnic_id, rc); in __bnxt_setup_vnic()
10620 netdev_err(bp->dev, "hwrm vnic %d set rss failure rc: %x\n", in __bnxt_setup_vnic()
10621 vnic->vnic_id, rc); in __bnxt_setup_vnic()
10625 if (bp->flags & BNXT_FLAG_AGG_RINGS) { in __bnxt_setup_vnic()
10628 netdev_err(bp->dev, "hwrm vnic %d set hds failure rc: %x\n", in __bnxt_setup_vnic()
10629 vnic->vnic_id, rc); in __bnxt_setup_vnic()
10647 req->vnic_id = cpu_to_le32(vnic->fw_vnic_id); in bnxt_hwrm_vnic_update()
10650 req->mru = cpu_to_le16(vnic->mru); in bnxt_hwrm_vnic_update()
10652 req->enables = cpu_to_le32(valid); in bnxt_hwrm_vnic_update()
10663 netdev_err(bp->dev, "hwrm vnic %d set rss failure rc: %d\n", in bnxt_hwrm_vnic_rss_cfg_p5()
10664 vnic->vnic_id, rc); in bnxt_hwrm_vnic_rss_cfg_p5()
10669 netdev_err(bp->dev, "hwrm vnic %d cfg failure rc: %x\n", in bnxt_hwrm_vnic_rss_cfg_p5()
10670 vnic->vnic_id, rc); in bnxt_hwrm_vnic_rss_cfg_p5()
10678 nr_ctxs = bnxt_get_nr_rss_ctxs(bp, bp->rx_nr_rings); in __bnxt_setup_vnic_p5()
10682 netdev_err(bp->dev, "hwrm vnic %d ctx %d alloc failure rc: %x\n", in __bnxt_setup_vnic_p5()
10683 vnic->vnic_id, i, rc); in __bnxt_setup_vnic_p5()
10686 bp->rsscos_nr_ctxs++; in __bnxt_setup_vnic_p5()
10689 return -ENOMEM; in __bnxt_setup_vnic_p5()
10695 if (bp->flags & BNXT_FLAG_AGG_RINGS) { in __bnxt_setup_vnic_p5()
10698 netdev_err(bp->dev, "hwrm vnic %d set hds failure rc: %x\n", in __bnxt_setup_vnic_p5()
10699 vnic->vnic_id, rc); in __bnxt_setup_vnic_p5()
10707 if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) in bnxt_setup_vnic()
10721 netdev_err(bp->dev, "hwrm vnic %d alloc failure rc: %x\n", in bnxt_alloc_and_setup_vnic()
10722 vnic->vnic_id, rc); in bnxt_alloc_and_setup_vnic()
10734 vnic = &bp->vnic_info[BNXT_VNIC_NTUPLE]; in bnxt_alloc_rfs_vnics()
10735 return bnxt_alloc_and_setup_vnic(bp, vnic, 0, bp->rx_nr_rings); in bnxt_alloc_rfs_vnics()
10738 if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) in bnxt_alloc_rfs_vnics()
10741 for (i = 0; i < bp->rx_nr_rings; i++) { in bnxt_alloc_rfs_vnics()
10742 u16 vnic_id = i + 1; in bnxt_alloc_rfs_vnics()
10745 if (vnic_id >= bp->nr_vnics) in bnxt_alloc_rfs_vnics()
10748 vnic = &bp->vnic_info[vnic_id]; in bnxt_alloc_rfs_vnics()
10749 vnic->flags |= BNXT_VNIC_RFS_FLAG; in bnxt_alloc_rfs_vnics()
10750 if (bp->rss_cap & BNXT_RSS_CAP_NEW_RSS_CAP) in bnxt_alloc_rfs_vnics()
10751 vnic->flags |= BNXT_VNIC_RFS_NEW_RSS_FLAG; in bnxt_alloc_rfs_vnics()
10752 if (bnxt_alloc_and_setup_vnic(bp, &bp->vnic_info[vnic_id], ring_id, 1)) in bnxt_alloc_rfs_vnics()
10761 struct bnxt_vnic_info *vnic = &rss_ctx->vnic; in bnxt_del_one_rss_ctx()
10766 if (netif_running(bp->dev)) { in bnxt_del_one_rss_ctx()
10767 bnxt_hwrm_vnic_free_one(bp, &rss_ctx->vnic); in bnxt_del_one_rss_ctx()
10769 if (vnic->fw_rss_cos_lb_ctx[i] != INVALID_HW_RING_ID) in bnxt_del_one_rss_ctx()
10776 list_for_each_entry_safe(usr_fltr, tmp, &bp->usr_fltr_list, list) { in bnxt_del_one_rss_ctx()
10777 if ((usr_fltr->flags & BNXT_ACT_RSS_CTX) && in bnxt_del_one_rss_ctx()
10778 usr_fltr->fw_vnic_id == rss_ctx->index) { in bnxt_del_one_rss_ctx()
10788 if (vnic->rss_table) in bnxt_del_one_rss_ctx()
10789 dma_free_coherent(&bp->pdev->dev, vnic->rss_table_size, in bnxt_del_one_rss_ctx()
10790 vnic->rss_table, in bnxt_del_one_rss_ctx()
10791 vnic->rss_table_dma_addr); in bnxt_del_one_rss_ctx()
10792 bp->num_rss_ctx--; in bnxt_del_one_rss_ctx()
10798 u16 tbl_size = bnxt_get_rxfh_indir_size(bp->dev); in bnxt_vnic_has_rx_ring()
10804 if (vnic->flags & BNXT_VNIC_NTUPLE_FLAG) in bnxt_vnic_has_rx_ring()
10808 if (vnic->flags & BNXT_VNIC_RSSCTX_FLAG) in bnxt_vnic_has_rx_ring()
10809 vnic_rx = ethtool_rxfh_context_indir(vnic->rss_ctx)[i]; in bnxt_vnic_has_rx_ring()
10811 vnic_rx = bp->rss_indir_tbl[i]; in bnxt_vnic_has_rx_ring()
10831 netdev_err(bp->dev, "hwrm vnic %d set rss failure rc: %d\n", in bnxt_set_vnic_mru_p5()
10832 vnic->vnic_id, rc); in bnxt_set_vnic_mru_p5()
10836 vnic->mru = mru; in bnxt_set_vnic_mru_p5()
10849 xa_for_each(&bp->dev->ethtool->rss_ctx, context, ctx) { in bnxt_set_rss_ctx_vnic_mru()
10851 struct bnxt_vnic_info *vnic = &rss_ctx->vnic; in bnxt_set_rss_ctx_vnic_mru()
10863 bool set_tpa = !!(bp->flags & BNXT_FLAG_TPA); in bnxt_hwrm_realloc_rss_ctx_vnic()
10867 xa_for_each(&bp->dev->ethtool->rss_ctx, context, ctx) { in bnxt_hwrm_realloc_rss_ctx_vnic()
10869 struct bnxt_vnic_info *vnic = &rss_ctx->vnic; in bnxt_hwrm_realloc_rss_ctx_vnic()
10871 if (bnxt_hwrm_vnic_alloc(bp, vnic, 0, bp->rx_nr_rings) || in bnxt_hwrm_realloc_rss_ctx_vnic()
10874 netdev_err(bp->dev, "Failed to restore RSS ctx %d\n", in bnxt_hwrm_realloc_rss_ctx_vnic()
10875 rss_ctx->index); in bnxt_hwrm_realloc_rss_ctx_vnic()
10877 ethtool_rxfh_context_lost(bp->dev, rss_ctx->index); in bnxt_hwrm_realloc_rss_ctx_vnic()
10887 xa_for_each(&bp->dev->ethtool->rss_ctx, context, ctx) { in bnxt_clear_rss_ctxs()
10898 if (BNXT_VF(bp) && !bp->vf.vlan && !bnxt_is_trusted_vf(bp, &bp->vf)) in bnxt_promisc_ok()
10906 struct bnxt_vnic_info *vnic = &bp->vnic_info[1]; in bnxt_setup_nitroa0_vnic()
10909 rc = bnxt_hwrm_vnic_alloc(bp, vnic, bp->rx_nr_rings - 1, 1); in bnxt_setup_nitroa0_vnic()
10911 netdev_err(bp->dev, "Cannot allocate special vnic for NS2 A0: %x\n", in bnxt_setup_nitroa0_vnic()
10918 netdev_err(bp->dev, "Cannot allocate special vnic for NS2 A0: %x\n", in bnxt_setup_nitroa0_vnic()
10930 struct bnxt_vnic_info *vnic = &bp->vnic_info[BNXT_VNIC_DEFAULT]; in bnxt_init_chip()
10932 unsigned int rx_nr_rings = bp->rx_nr_rings; in bnxt_init_chip()
10937 netdev_err(bp->dev, "hwrm stat ctx alloc failure rc: %x\n", in bnxt_init_chip()
10945 netdev_err(bp->dev, "hwrm ring alloc failure rc: %x\n", rc); in bnxt_init_chip()
10951 netdev_err(bp->dev, "hwrm_ring_grp alloc failure: %x\n", rc); in bnxt_init_chip()
10956 rx_nr_rings--; in bnxt_init_chip()
10961 netdev_err(bp->dev, "hwrm vnic alloc failure rc: %x\n", rc); in bnxt_init_chip()
10971 if (bp->rss_cap & BNXT_RSS_CAP_RSS_HASH_TYPE_DELTA) in bnxt_init_chip()
10974 if (bp->flags & BNXT_FLAG_RFS) { in bnxt_init_chip()
10980 if (bp->flags & BNXT_FLAG_TPA) { in bnxt_init_chip()
10990 rc = bnxt_hwrm_set_vnic_filter(bp, 0, 0, bp->dev->dev_addr); in bnxt_init_chip()
10992 if (BNXT_VF(bp) && rc == -ENODEV) in bnxt_init_chip()
10993 netdev_err(bp->dev, "Cannot configure L2 filter while PF is unavailable\n"); in bnxt_init_chip()
10995 netdev_err(bp->dev, "HWRM vnic filter failure rc: %x\n", rc); in bnxt_init_chip()
10998 vnic->uc_filter_count = 1; in bnxt_init_chip()
11000 vnic->rx_mask = 0; in bnxt_init_chip()
11001 if (test_bit(BNXT_STATE_HALF_OPEN, &bp->state)) in bnxt_init_chip()
11004 if (bp->dev->flags & IFF_BROADCAST) in bnxt_init_chip()
11005 vnic->rx_mask |= CFA_L2_SET_RX_MASK_REQ_MASK_BCAST; in bnxt_init_chip()
11007 if (bp->dev->flags & IFF_PROMISC) in bnxt_init_chip()
11008 vnic->rx_mask |= CFA_L2_SET_RX_MASK_REQ_MASK_PROMISCUOUS; in bnxt_init_chip()
11010 if (bp->dev->flags & IFF_ALLMULTI) { in bnxt_init_chip()
11011 vnic->rx_mask |= CFA_L2_SET_RX_MASK_REQ_MASK_ALL_MCAST; in bnxt_init_chip()
11012 vnic->mc_list_count = 0; in bnxt_init_chip()
11013 } else if (bp->dev->flags & IFF_MULTICAST) { in bnxt_init_chip()
11017 vnic->rx_mask |= mask; in bnxt_init_chip()
11027 netdev_warn(bp->dev, "HWRM set coalescing failure rc: %x\n", in bnxt_init_chip()
11033 netdev_err(bp->dev, "Special vnic setup failure for NS2 A0 rc: %x\n", in bnxt_init_chip()
11039 netdev_update_features(bp->dev); in bnxt_init_chip()
11052 bnxt_hwrm_resource_free(bp, 1, irq_re_init); in bnxt_shutdown_nic()
11070 struct net_device *dev = bp->dev; in bnxt_set_real_num_queues()
11072 rc = netif_set_real_num_tx_queues(dev, bp->tx_nr_rings - in bnxt_set_real_num_queues()
11073 bp->tx_nr_rings_xdp); in bnxt_set_real_num_queues()
11077 rc = netif_set_real_num_rx_queues(dev, bp->rx_nr_rings); in bnxt_set_real_num_queues()
11082 if (bp->flags & BNXT_FLAG_RFS) in bnxt_set_real_num_queues()
11083 dev->rx_cpu_rmap = alloc_irq_cpu_rmap(bp->rx_nr_rings); in bnxt_set_real_num_queues()
11099 return -ENOMEM; in __bnxt_trim_rings()
11102 if (_rx > _tx && _rx > 1) in __bnxt_trim_rings()
11103 _rx--; in __bnxt_trim_rings()
11104 else if (_tx > 1) in __bnxt_trim_rings()
11105 _tx--; in __bnxt_trim_rings()
11115 return (tx - tx_xdp) / tx_sets + tx_xdp; in __bnxt_num_tx_to_cp()
11120 int tcs = bp->num_tc; in bnxt_num_tx_to_cp()
11123 tcs = 1; in bnxt_num_tx_to_cp()
11124 return __bnxt_num_tx_to_cp(bp, tx, tcs, bp->tx_nr_rings_xdp); in bnxt_num_tx_to_cp()
11129 int tcs = bp->num_tc; in bnxt_num_cp_to_tx()
11131 return (tx_cp - bp->tx_nr_rings_xdp) * tcs + in bnxt_num_cp_to_tx()
11132 bp->tx_nr_rings_xdp; in bnxt_num_cp_to_tx()
11155 const int len = sizeof(bp->irq_tbl[0].name); in bnxt_setup_msix()
11156 struct net_device *dev = bp->dev; in bnxt_setup_msix()
11159 tcs = bp->num_tc; in bnxt_setup_msix()
11164 count = bp->tx_nr_rings_per_tc; in bnxt_setup_msix()
11170 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_setup_msix()
11174 if (bp->flags & BNXT_FLAG_SHARED_RINGS) in bnxt_setup_msix()
11176 else if (i < bp->rx_nr_rings) in bnxt_setup_msix()
11181 snprintf(bp->irq_tbl[map_idx].name, len, "%s-%s-%d", dev->name, in bnxt_setup_msix()
11183 bp->irq_tbl[map_idx].handler = bnxt_msix; in bnxt_setup_msix()
11195 for (i = bp->total_irqs; i < total; i++) { in bnxt_change_msix()
11196 map = pci_msix_alloc_irq_at(bp->pdev, i, NULL); in bnxt_change_msix()
11198 return bp->total_irqs; in bnxt_change_msix()
11199 bp->irq_tbl[i].vector = map.virq; in bnxt_change_msix()
11200 bp->total_irqs++; in bnxt_change_msix()
11204 for (i = bp->total_irqs; i > total; i--) { in bnxt_change_msix()
11205 map.index = i - 1; in bnxt_change_msix()
11206 map.virq = bp->irq_tbl[i - 1].vector; in bnxt_change_msix()
11207 pci_msix_free_irq(bp->pdev, map); in bnxt_change_msix()
11208 bp->total_irqs--; in bnxt_change_msix()
11210 return bp->total_irqs; in bnxt_change_msix()
11217 if (!bp->irq_tbl) { in bnxt_setup_int_mode()
11219 if (rc || !bp->irq_tbl) in bnxt_setup_int_mode()
11220 return rc ?: -ENODEV; in bnxt_setup_int_mode()
11231 return bp->hw_resc.max_rsscos_ctxs; in bnxt_get_max_func_rss_ctxs()
11236 return bp->hw_resc.max_vnics; in bnxt_get_max_func_vnics()
11241 return bp->hw_resc.max_stat_ctxs; in bnxt_get_max_func_stat_ctxs()
11246 return bp->hw_resc.max_cp_rings; in bnxt_get_max_func_cp_rings()
11251 unsigned int cp = bp->hw_resc.max_cp_rings; in bnxt_get_max_func_cp_rings_for_en()
11253 if (!(bp->flags & BNXT_FLAG_CHIP_P5_PLUS)) in bnxt_get_max_func_cp_rings_for_en()
11254 cp -= bnxt_get_ulp_msix_num(bp); in bnxt_get_max_func_cp_rings_for_en()
11261 struct bnxt_hw_resc *hw_resc = &bp->hw_resc; in bnxt_get_max_func_irqs()
11263 if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) in bnxt_get_max_func_irqs()
11264 return min_t(unsigned int, hw_resc->max_irqs, hw_resc->max_nqs); in bnxt_get_max_func_irqs()
11266 return min_t(unsigned int, hw_resc->max_irqs, hw_resc->max_cp_rings); in bnxt_get_max_func_irqs()
11271 bp->hw_resc.max_irqs = max_irqs; in bnxt_set_max_func_irqs()
11279 if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) in bnxt_get_avail_cp_rings_for_en()
11280 return cp - bp->rx_nr_rings - bp->tx_nr_rings; in bnxt_get_avail_cp_rings_for_en()
11282 return cp - bp->cp_nr_rings; in bnxt_get_avail_cp_rings_for_en()
11287 return bnxt_get_max_func_stat_ctxs(bp) - bnxt_get_func_stat_ctxs(bp); in bnxt_get_avail_stat_ctxs_for_en()
11293 int total_req = bp->cp_nr_rings + num; in bnxt_get_avail_msix()
11296 num = max_irq - bp->cp_nr_rings; in bnxt_get_avail_msix()
11313 int i, total_vecs, max, rc = 0, min = 1, ulp_msix, tx_cp, tbl_size; in bnxt_init_int_mode()
11323 if (!(bp->flags & BNXT_FLAG_SHARED_RINGS)) in bnxt_init_int_mode()
11326 total_vecs = pci_alloc_irq_vectors(bp->pdev, min, total_vecs, in bnxt_init_int_mode()
11330 rc = -ENODEV; in bnxt_init_int_mode()
11335 if (pci_msix_can_alloc_dyn(bp->pdev)) in bnxt_init_int_mode()
11337 bp->irq_tbl = kcalloc(tbl_size, sizeof(*bp->irq_tbl), GFP_KERNEL); in bnxt_init_int_mode()
11338 if (bp->irq_tbl) { in bnxt_init_int_mode()
11340 bp->irq_tbl[i].vector = pci_irq_vector(bp->pdev, i); in bnxt_init_int_mode()
11342 bp->total_irqs = total_vecs; in bnxt_init_int_mode()
11344 rc = bnxt_trim_rings(bp, &bp->rx_nr_rings, &bp->tx_nr_rings, in bnxt_init_int_mode()
11345 total_vecs - ulp_msix, min == 1); in bnxt_init_int_mode()
11349 tx_cp = bnxt_num_tx_to_cp(bp, bp->tx_nr_rings); in bnxt_init_int_mode()
11350 bp->cp_nr_rings = (min == 1) ? in bnxt_init_int_mode()
11351 max_t(int, tx_cp, bp->rx_nr_rings) : in bnxt_init_int_mode()
11352 tx_cp + bp->rx_nr_rings; in bnxt_init_int_mode()
11355 rc = -ENOMEM; in bnxt_init_int_mode()
11361 netdev_err(bp->dev, "bnxt_init_int_mode err: %x\n", rc); in bnxt_init_int_mode()
11362 kfree(bp->irq_tbl); in bnxt_init_int_mode()
11363 bp->irq_tbl = NULL; in bnxt_init_int_mode()
11364 pci_free_irq_vectors(bp->pdev); in bnxt_init_int_mode()
11370 pci_free_irq_vectors(bp->pdev); in bnxt_clear_int_mode()
11372 kfree(bp->irq_tbl); in bnxt_clear_int_mode()
11373 bp->irq_tbl = NULL; in bnxt_clear_int_mode()
11380 int tcs = bp->num_tc; in bnxt_reserve_rings()
11387 if (BNXT_NEW_RM(bp) && !bnxt_ulp_registered(bp->edev)) { in bnxt_reserve_rings()
11388 int ulp_msix = bnxt_get_avail_msix(bp, bp->ulp_num_msix_want); in bnxt_reserve_rings()
11390 if (ulp_msix > bp->ulp_num_msix_want) in bnxt_reserve_rings()
11391 ulp_msix = bp->ulp_num_msix_want; in bnxt_reserve_rings()
11392 irqs_required = ulp_msix + bp->cp_nr_rings; in bnxt_reserve_rings()
11397 if (irq_re_init && BNXT_NEW_RM(bp) && irqs_required != bp->total_irqs) { in bnxt_reserve_rings()
11399 if (!pci_msix_can_alloc_dyn(bp->pdev)) { in bnxt_reserve_rings()
11412 rc = -ENOSPC; in bnxt_reserve_rings()
11415 netdev_err(bp->dev, "ring reservation/IRQ init failure rc: %d\n", rc); in bnxt_reserve_rings()
11418 if (tcs && (bp->tx_nr_rings_per_tc * tcs != in bnxt_reserve_rings()
11419 bp->tx_nr_rings - bp->tx_nr_rings_xdp)) { in bnxt_reserve_rings()
11420 netdev_err(bp->dev, "tx ring reservation failure\n"); in bnxt_reserve_rings()
11421 netdev_reset_tc(bp->dev); in bnxt_reserve_rings()
11422 bp->num_tc = 0; in bnxt_reserve_rings()
11423 if (bp->tx_nr_rings_xdp) in bnxt_reserve_rings()
11424 bp->tx_nr_rings_per_tc = bp->tx_nr_rings_xdp; in bnxt_reserve_rings()
11426 bp->tx_nr_rings_per_tc = bp->tx_nr_rings; in bnxt_reserve_rings()
11427 return -ENOMEM; in bnxt_reserve_rings()
11439 bnapi = bp->bnapi[idx]; in bnxt_tx_queue_stop()
11441 WRITE_ONCE(txr->dev_state, BNXT_DEV_STATE_CLOSING); in bnxt_tx_queue_stop()
11444 if (!(bnapi->flags & BNXT_NAPI_FLAG_XDP)) { in bnxt_tx_queue_stop()
11445 txq = netdev_get_tx_queue(bp->dev, txr->txq_index); in bnxt_tx_queue_stop()
11453 if (!bp->tph_mode) in bnxt_tx_queue_stop()
11457 bnxt_hwrm_cp_ring_free(bp, txr->tx_cpr); in bnxt_tx_queue_stop()
11458 bnxt_free_one_tx_ring_skbs(bp, txr, txr->txq_index); in bnxt_tx_queue_stop()
11459 bnxt_clear_one_cp_ring(bp, txr->tx_cpr); in bnxt_tx_queue_stop()
11470 bnapi = bp->bnapi[idx]; in bnxt_tx_queue_start()
11475 if (!bp->tph_mode) in bnxt_tx_queue_start()
11478 rc = bnxt_hwrm_cp_ring_alloc_p5(bp, txr->tx_cpr); in bnxt_tx_queue_start()
11486 txr->tx_prod = 0; in bnxt_tx_queue_start()
11487 txr->tx_cons = 0; in bnxt_tx_queue_start()
11488 txr->tx_hw_cons = 0; in bnxt_tx_queue_start()
11490 WRITE_ONCE(txr->dev_state, 0); in bnxt_tx_queue_start()
11493 if (bnapi->flags & BNXT_NAPI_FLAG_XDP) in bnxt_tx_queue_start()
11496 txq = netdev_get_tx_queue(bp->dev, txr->txq_index); in bnxt_tx_queue_start()
11513 if (!irq->bp->tph_mode) in bnxt_irq_affinity_notify()
11516 cpumask_copy(irq->cpu_mask, mask); in bnxt_irq_affinity_notify()
11518 if (irq->ring_nr >= irq->bp->rx_nr_rings) in bnxt_irq_affinity_notify()
11521 if (pcie_tph_get_cpu_st(irq->bp->pdev, TPH_MEM_TYPE_VM, in bnxt_irq_affinity_notify()
11522 cpumask_first(irq->cpu_mask), &tag)) in bnxt_irq_affinity_notify()
11525 if (pcie_tph_set_st_entry(irq->bp->pdev, irq->msix_nr, tag)) in bnxt_irq_affinity_notify()
11528 netdev_lock(irq->bp->dev); in bnxt_irq_affinity_notify()
11529 if (netif_running(irq->bp->dev)) { in bnxt_irq_affinity_notify()
11530 err = netdev_rx_queue_restart(irq->bp->dev, irq->ring_nr); in bnxt_irq_affinity_notify()
11532 netdev_err(irq->bp->dev, in bnxt_irq_affinity_notify()
11535 netdev_unlock(irq->bp->dev); in bnxt_irq_affinity_notify()
11546 if (!irq->bp->tph_mode) in bnxt_irq_affinity_release()
11549 if (pcie_tph_set_st_entry(irq->bp->pdev, irq->msix_nr, 0)) { in bnxt_irq_affinity_release()
11550 netdev_err(irq->bp->dev, in bnxt_irq_affinity_release()
11552 irq->msix_nr); in bnxt_irq_affinity_release()
11559 irq_set_affinity_notifier(irq->vector, NULL); in bnxt_release_irq_notifier()
11566 irq->bp = bp; in bnxt_register_irq_notifier()
11569 if (!bp->tph_mode) in bnxt_register_irq_notifier()
11573 notify = &irq->affinity_notify; in bnxt_register_irq_notifier()
11574 notify->irq = irq->vector; in bnxt_register_irq_notifier()
11575 notify->notify = bnxt_irq_affinity_notify; in bnxt_register_irq_notifier()
11576 notify->release = bnxt_irq_affinity_release; in bnxt_register_irq_notifier()
11578 irq_set_affinity_notifier(irq->vector, notify); in bnxt_register_irq_notifier()
11587 free_irq_cpu_rmap(bp->dev->rx_cpu_rmap); in bnxt_free_irq()
11588 bp->dev->rx_cpu_rmap = NULL; in bnxt_free_irq()
11590 if (!bp->irq_tbl || !bp->bnapi) in bnxt_free_irq()
11593 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_free_irq()
11596 irq = &bp->irq_tbl[map_idx]; in bnxt_free_irq()
11597 if (irq->requested) { in bnxt_free_irq()
11598 if (irq->have_cpumask) { in bnxt_free_irq()
11599 irq_update_affinity_hint(irq->vector, NULL); in bnxt_free_irq()
11600 free_cpumask_var(irq->cpu_mask); in bnxt_free_irq()
11601 irq->have_cpumask = 0; in bnxt_free_irq()
11606 free_irq(irq->vector, bp->bnapi[i]); in bnxt_free_irq()
11609 irq->requested = 0; in bnxt_free_irq()
11613 pcie_disable_tph(bp->pdev); in bnxt_free_irq()
11614 bp->tph_mode = 0; in bnxt_free_irq()
11625 netdev_err(bp->dev, "bnxt_setup_int_mode err: %x\n", in bnxt_request_irq()
11630 rmap = bp->dev->rx_cpu_rmap; in bnxt_request_irq()
11634 rc = pcie_enable_tph(bp->pdev, PCI_TPH_ST_IV_MODE); in bnxt_request_irq()
11636 bp->tph_mode = PCI_TPH_ST_IV_MODE; in bnxt_request_irq()
11638 for (i = 0, j = 0; i < bp->cp_nr_rings; i++) { in bnxt_request_irq()
11640 struct bnxt_irq *irq = &bp->irq_tbl[map_idx]; in bnxt_request_irq()
11643 rmap && bp->bnapi[i]->rx_ring) { in bnxt_request_irq()
11644 rc = irq_cpu_rmap_add(rmap, irq->vector); in bnxt_request_irq()
11646 netdev_warn(bp->dev, "failed adding irq rmap for ring %d\n", in bnxt_request_irq()
11651 rc = request_irq(irq->vector, irq->handler, flags, irq->name, in bnxt_request_irq()
11652 bp->bnapi[i]); in bnxt_request_irq()
11656 netif_napi_set_irq_locked(&bp->bnapi[i]->napi, irq->vector); in bnxt_request_irq()
11657 irq->requested = 1; in bnxt_request_irq()
11659 if (zalloc_cpumask_var(&irq->cpu_mask, GFP_KERNEL)) { in bnxt_request_irq()
11660 int numa_node = dev_to_node(&bp->pdev->dev); in bnxt_request_irq()
11663 irq->have_cpumask = 1; in bnxt_request_irq()
11664 irq->msix_nr = map_idx; in bnxt_request_irq()
11665 irq->ring_nr = i; in bnxt_request_irq()
11667 irq->cpu_mask); in bnxt_request_irq()
11668 rc = irq_update_affinity_hint(irq->vector, irq->cpu_mask); in bnxt_request_irq()
11670 netdev_warn(bp->dev, in bnxt_request_irq()
11672 irq->vector); in bnxt_request_irq()
11679 if (pcie_tph_get_cpu_st(irq->bp->pdev, TPH_MEM_TYPE_VM, in bnxt_request_irq()
11680 cpumask_first(irq->cpu_mask), in bnxt_request_irq()
11684 pcie_tph_set_st_entry(irq->bp->pdev, irq->msix_nr, tag); in bnxt_request_irq()
11694 if (!bp->bnapi) in bnxt_del_napi()
11697 for (i = 0; i < bp->rx_nr_rings; i++) in bnxt_del_napi()
11698 netif_queue_set_napi(bp->dev, i, NETDEV_QUEUE_TYPE_RX, NULL); in bnxt_del_napi()
11699 for (i = 0; i < bp->tx_nr_rings - bp->tx_nr_rings_xdp; i++) in bnxt_del_napi()
11700 netif_queue_set_napi(bp->dev, i, NETDEV_QUEUE_TYPE_TX, NULL); in bnxt_del_napi()
11702 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_del_napi()
11703 struct bnxt_napi *bnapi = bp->bnapi[i]; in bnxt_del_napi()
11705 __netif_napi_del_locked(&bnapi->napi); in bnxt_del_napi()
11716 unsigned int cp_nr_rings = bp->cp_nr_rings; in bnxt_init_napi()
11720 if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) in bnxt_init_napi()
11723 cp_nr_rings--; in bnxt_init_napi()
11725 set_bit(BNXT_STATE_NAPI_DISABLED, &bp->state); in bnxt_init_napi()
11728 bnapi = bp->bnapi[i]; in bnxt_init_napi()
11729 netif_napi_add_config_locked(bp->dev, &bnapi->napi, poll_fn, in bnxt_init_napi()
11730 bnapi->index); in bnxt_init_napi()
11733 bnapi = bp->bnapi[cp_nr_rings]; in bnxt_init_napi()
11734 netif_napi_add_locked(bp->dev, &bnapi->napi, bnxt_poll_nitroa0); in bnxt_init_napi()
11742 if (!bp->bnapi || in bnxt_disable_napi()
11743 test_and_set_bit(BNXT_STATE_NAPI_DISABLED, &bp->state)) in bnxt_disable_napi()
11746 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_disable_napi()
11747 struct bnxt_napi *bnapi = bp->bnapi[i]; in bnxt_disable_napi()
11750 cpr = &bnapi->cp_ring; in bnxt_disable_napi()
11751 if (bnapi->tx_fault) in bnxt_disable_napi()
11752 cpr->sw_stats->tx.tx_resets++; in bnxt_disable_napi()
11753 if (bnapi->in_reset) in bnxt_disable_napi()
11754 cpr->sw_stats->rx.rx_resets++; in bnxt_disable_napi()
11755 napi_disable_locked(&bnapi->napi); in bnxt_disable_napi()
11763 clear_bit(BNXT_STATE_NAPI_DISABLED, &bp->state); in bnxt_enable_napi()
11764 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_enable_napi()
11765 struct bnxt_napi *bnapi = bp->bnapi[i]; in bnxt_enable_napi()
11768 bnapi->tx_fault = 0; in bnxt_enable_napi()
11770 cpr = &bnapi->cp_ring; in bnxt_enable_napi()
11771 bnapi->in_reset = false; in bnxt_enable_napi()
11773 if (bnapi->rx_ring) { in bnxt_enable_napi()
11774 INIT_WORK(&cpr->dim.work, bnxt_dim_work); in bnxt_enable_napi()
11775 cpr->dim.mode = DIM_CQ_PERIOD_MODE_START_FROM_EQE; in bnxt_enable_napi()
11777 napi_enable_locked(&bnapi->napi); in bnxt_enable_napi()
11786 if (bp->tx_ring) { in bnxt_tx_disable()
11787 for (i = 0; i < bp->tx_nr_rings; i++) { in bnxt_tx_disable()
11788 txr = &bp->tx_ring[i]; in bnxt_tx_disable()
11789 WRITE_ONCE(txr->dev_state, BNXT_DEV_STATE_CLOSING); in bnxt_tx_disable()
11795 netif_carrier_off(bp->dev); in bnxt_tx_disable()
11797 netif_tx_disable(bp->dev); in bnxt_tx_disable()
11805 for (i = 0; i < bp->tx_nr_rings; i++) { in bnxt_tx_enable()
11806 txr = &bp->tx_ring[i]; in bnxt_tx_enable()
11807 WRITE_ONCE(txr->dev_state, 0); in bnxt_tx_enable()
11811 netif_tx_wake_all_queues(bp->dev); in bnxt_tx_enable()
11813 netif_carrier_on(bp->dev); in bnxt_tx_enable()
11818 u8 active_fec = link_info->active_fec_sig_mode & in bnxt_report_fec()
11849 netif_carrier_on(bp->dev); in bnxt_report_link()
11850 speed = bnxt_fw_to_ethtool_speed(bp->link_info.link_speed); in bnxt_report_link()
11852 netdev_info(bp->dev, "NIC Link is Up, speed unknown\n"); in bnxt_report_link()
11855 if (bp->link_info.duplex == BNXT_LINK_DUPLEX_FULL) in bnxt_report_link()
11859 if (bp->link_info.pause == BNXT_LINK_PAUSE_BOTH) in bnxt_report_link()
11860 flow_ctrl = "ON - receive & transmit"; in bnxt_report_link()
11861 else if (bp->link_info.pause == BNXT_LINK_PAUSE_TX) in bnxt_report_link()
11862 flow_ctrl = "ON - transmit"; in bnxt_report_link()
11863 else if (bp->link_info.pause == BNXT_LINK_PAUSE_RX) in bnxt_report_link()
11864 flow_ctrl = "ON - receive"; in bnxt_report_link()
11867 if (bp->link_info.phy_qcfg_resp.option_flags & in bnxt_report_link()
11869 u8 sig_mode = bp->link_info.active_fec_sig_mode & in bnxt_report_link()
11885 netdev_info(bp->dev, "NIC Link is Up, %u Mbps %s%s duplex, Flow control: %s\n", in bnxt_report_link()
11887 if (bp->phy_flags & BNXT_PHY_FL_EEE_CAP) in bnxt_report_link()
11888 netdev_info(bp->dev, "EEE is %s\n", in bnxt_report_link()
11889 bp->eee.eee_active ? "active" : in bnxt_report_link()
11891 fec = bp->link_info.fec_cfg; in bnxt_report_link()
11893 netdev_info(bp->dev, "FEC autoneg %s encoding: %s\n", in bnxt_report_link()
11895 bnxt_report_fec(&bp->link_info)); in bnxt_report_link()
11897 netif_carrier_off(bp->dev); in bnxt_report_link()
11898 netdev_err(bp->dev, "NIC Link is Down\n"); in bnxt_report_link()
11904 if (!resp->supported_speeds_auto_mode && in bnxt_phy_qcaps_no_speed()
11905 !resp->supported_speeds_force_mode && in bnxt_phy_qcaps_no_speed()
11906 !resp->supported_pam4_speeds_auto_mode && in bnxt_phy_qcaps_no_speed()
11907 !resp->supported_pam4_speeds_force_mode && in bnxt_phy_qcaps_no_speed()
11908 !resp->supported_speeds2_auto_mode && in bnxt_phy_qcaps_no_speed()
11909 !resp->supported_speeds2_force_mode) in bnxt_phy_qcaps_no_speed()
11916 struct bnxt_link_info *link_info = &bp->link_info; in bnxt_hwrm_phy_qcaps()
11921 if (bp->hwrm_spec_code < 0x10201) in bnxt_hwrm_phy_qcaps()
11933 bp->phy_flags = resp->flags | (le16_to_cpu(resp->flags2) << 8); in bnxt_hwrm_phy_qcaps()
11934 if (resp->flags & PORT_PHY_QCAPS_RESP_FLAGS_EEE_SUPPORTED) { in bnxt_hwrm_phy_qcaps()
11935 struct ethtool_keee *eee = &bp->eee; in bnxt_hwrm_phy_qcaps()
11936 u16 fw_speeds = le16_to_cpu(resp->supported_speeds_eee_mode); in bnxt_hwrm_phy_qcaps()
11938 _bnxt_fw_to_linkmode(eee->supported, fw_speeds); in bnxt_hwrm_phy_qcaps()
11939 bp->lpi_tmr_lo = le32_to_cpu(resp->tx_lpi_timer_low) & in bnxt_hwrm_phy_qcaps()
11941 bp->lpi_tmr_hi = le32_to_cpu(resp->valid_tx_lpi_timer_high) & in bnxt_hwrm_phy_qcaps()
11945 if (bp->hwrm_spec_code >= 0x10a01) { in bnxt_hwrm_phy_qcaps()
11947 link_info->phy_state = BNXT_PHY_STATE_DISABLED; in bnxt_hwrm_phy_qcaps()
11948 netdev_warn(bp->dev, "Ethernet link disabled\n"); in bnxt_hwrm_phy_qcaps()
11949 } else if (link_info->phy_state == BNXT_PHY_STATE_DISABLED) { in bnxt_hwrm_phy_qcaps()
11950 link_info->phy_state = BNXT_PHY_STATE_ENABLED; in bnxt_hwrm_phy_qcaps()
11951 netdev_info(bp->dev, "Ethernet link enabled\n"); in bnxt_hwrm_phy_qcaps()
11952 /* Phy re-enabled, reprobe the speeds */ in bnxt_hwrm_phy_qcaps()
11953 link_info->support_auto_speeds = 0; in bnxt_hwrm_phy_qcaps()
11954 link_info->support_pam4_auto_speeds = 0; in bnxt_hwrm_phy_qcaps()
11955 link_info->support_auto_speeds2 = 0; in bnxt_hwrm_phy_qcaps()
11958 if (resp->supported_speeds_auto_mode) in bnxt_hwrm_phy_qcaps()
11959 link_info->support_auto_speeds = in bnxt_hwrm_phy_qcaps()
11960 le16_to_cpu(resp->supported_speeds_auto_mode); in bnxt_hwrm_phy_qcaps()
11961 if (resp->supported_pam4_speeds_auto_mode) in bnxt_hwrm_phy_qcaps()
11962 link_info->support_pam4_auto_speeds = in bnxt_hwrm_phy_qcaps()
11963 le16_to_cpu(resp->supported_pam4_speeds_auto_mode); in bnxt_hwrm_phy_qcaps()
11964 if (resp->supported_speeds2_auto_mode) in bnxt_hwrm_phy_qcaps()
11965 link_info->support_auto_speeds2 = in bnxt_hwrm_phy_qcaps()
11966 le16_to_cpu(resp->supported_speeds2_auto_mode); in bnxt_hwrm_phy_qcaps()
11968 bp->port_count = resp->port_cnt; in bnxt_hwrm_phy_qcaps()
11981 if (bp->hwrm_spec_code < 0x10a03) in bnxt_hwrm_mac_qcaps()
11991 bp->mac_flags = resp->flags; in bnxt_hwrm_mac_qcaps()
12009 if (bp->phy_flags & BNXT_PHY_FL_SPEEDS2) { in bnxt_support_speed_dropped()
12010 if (bnxt_support_dropped(link_info->advertising, in bnxt_support_speed_dropped()
12011 link_info->support_auto_speeds2)) { in bnxt_support_speed_dropped()
12012 link_info->advertising = link_info->support_auto_speeds2; in bnxt_support_speed_dropped()
12017 if (bnxt_support_dropped(link_info->advertising, in bnxt_support_speed_dropped()
12018 link_info->support_auto_speeds)) { in bnxt_support_speed_dropped()
12019 link_info->advertising = link_info->support_auto_speeds; in bnxt_support_speed_dropped()
12022 if (bnxt_support_dropped(link_info->advertising_pam4, in bnxt_support_speed_dropped()
12023 link_info->support_pam4_auto_speeds)) { in bnxt_support_speed_dropped()
12024 link_info->advertising_pam4 = link_info->support_pam4_auto_speeds; in bnxt_support_speed_dropped()
12032 struct bnxt_link_info *link_info = &bp->link_info; in bnxt_update_link()
12035 u8 link_state = link_info->link_state; in bnxt_update_link()
12047 if (BNXT_VF(bp) && rc == -ENODEV) { in bnxt_update_link()
12048 netdev_warn(bp->dev, "Cannot obtain link state while PF unavailable.\n"); in bnxt_update_link()
12054 memcpy(&link_info->phy_qcfg_resp, resp, sizeof(*resp)); in bnxt_update_link()
12055 link_info->phy_link_status = resp->link; in bnxt_update_link()
12056 link_info->duplex = resp->duplex_cfg; in bnxt_update_link()
12057 if (bp->hwrm_spec_code >= 0x10800) in bnxt_update_link()
12058 link_info->duplex = resp->duplex_state; in bnxt_update_link()
12059 link_info->pause = resp->pause; in bnxt_update_link()
12060 link_info->auto_mode = resp->auto_mode; in bnxt_update_link()
12061 link_info->auto_pause_setting = resp->auto_pause; in bnxt_update_link()
12062 link_info->lp_pause = resp->link_partner_adv_pause; in bnxt_update_link()
12063 link_info->force_pause_setting = resp->force_pause; in bnxt_update_link()
12064 link_info->duplex_setting = resp->duplex_cfg; in bnxt_update_link()
12065 if (link_info->phy_link_status == BNXT_LINK_LINK) { in bnxt_update_link()
12066 link_info->link_speed = le16_to_cpu(resp->link_speed); in bnxt_update_link()
12067 if (bp->phy_flags & BNXT_PHY_FL_SPEEDS2) in bnxt_update_link()
12068 link_info->active_lanes = resp->active_lanes; in bnxt_update_link()
12070 link_info->link_speed = 0; in bnxt_update_link()
12071 link_info->active_lanes = 0; in bnxt_update_link()
12073 link_info->force_link_speed = le16_to_cpu(resp->force_link_speed); in bnxt_update_link()
12074 link_info->force_pam4_link_speed = in bnxt_update_link()
12075 le16_to_cpu(resp->force_pam4_link_speed); in bnxt_update_link()
12076 link_info->force_link_speed2 = le16_to_cpu(resp->force_link_speeds2); in bnxt_update_link()
12077 link_info->support_speeds = le16_to_cpu(resp->support_speeds); in bnxt_update_link()
12078 link_info->support_pam4_speeds = le16_to_cpu(resp->support_pam4_speeds); in bnxt_update_link()
12079 link_info->support_speeds2 = le16_to_cpu(resp->support_speeds2); in bnxt_update_link()
12080 link_info->auto_link_speeds = le16_to_cpu(resp->auto_link_speed_mask); in bnxt_update_link()
12081 link_info->auto_pam4_link_speeds = in bnxt_update_link()
12082 le16_to_cpu(resp->auto_pam4_link_speed_mask); in bnxt_update_link()
12083 link_info->auto_link_speeds2 = le16_to_cpu(resp->auto_link_speeds2); in bnxt_update_link()
12084 link_info->lp_auto_link_speeds = in bnxt_update_link()
12085 le16_to_cpu(resp->link_partner_adv_speeds); in bnxt_update_link()
12086 link_info->lp_auto_pam4_link_speeds = in bnxt_update_link()
12087 resp->link_partner_pam4_adv_speeds; in bnxt_update_link()
12088 link_info->preemphasis = le32_to_cpu(resp->preemphasis); in bnxt_update_link()
12089 link_info->phy_ver[0] = resp->phy_maj; in bnxt_update_link()
12090 link_info->phy_ver[1] = resp->phy_min; in bnxt_update_link()
12091 link_info->phy_ver[2] = resp->phy_bld; in bnxt_update_link()
12092 link_info->media_type = resp->media_type; in bnxt_update_link()
12093 link_info->phy_type = resp->phy_type; in bnxt_update_link()
12094 link_info->transceiver = resp->xcvr_pkg_type; in bnxt_update_link()
12095 link_info->phy_addr = resp->eee_config_phy_addr & in bnxt_update_link()
12097 link_info->module_status = resp->module_status; in bnxt_update_link()
12099 if (bp->phy_flags & BNXT_PHY_FL_EEE_CAP) { in bnxt_update_link()
12100 struct ethtool_keee *eee = &bp->eee; in bnxt_update_link()
12103 eee->eee_active = 0; in bnxt_update_link()
12104 if (resp->eee_config_phy_addr & in bnxt_update_link()
12106 eee->eee_active = 1; in bnxt_update_link()
12108 resp->link_partner_adv_eee_link_speed_mask); in bnxt_update_link()
12109 _bnxt_fw_to_linkmode(eee->lp_advertised, fw_speeds); in bnxt_update_link()
12114 if (resp->eee_config_phy_addr & in bnxt_update_link()
12116 eee->eee_enabled = 1; in bnxt_update_link()
12118 fw_speeds = le16_to_cpu(resp->adv_eee_link_speed_mask); in bnxt_update_link()
12119 _bnxt_fw_to_linkmode(eee->advertised, fw_speeds); in bnxt_update_link()
12121 if (resp->eee_config_phy_addr & in bnxt_update_link()
12125 eee->tx_lpi_enabled = 1; in bnxt_update_link()
12126 tmr = resp->xcvr_identifier_type_tx_lpi_timer; in bnxt_update_link()
12127 eee->tx_lpi_timer = le32_to_cpu(tmr) & in bnxt_update_link()
12133 link_info->fec_cfg = PORT_PHY_QCFG_RESP_FEC_CFG_FEC_NONE_SUPPORTED; in bnxt_update_link()
12134 if (bp->hwrm_spec_code >= 0x10504) { in bnxt_update_link()
12135 link_info->fec_cfg = le16_to_cpu(resp->fec_cfg); in bnxt_update_link()
12136 link_info->active_fec_sig_mode = resp->active_fec_signal_mode; in bnxt_update_link()
12140 if (link_info->phy_link_status == BNXT_LINK_LINK) in bnxt_update_link()
12141 link_info->link_state = BNXT_LINK_STATE_UP; in bnxt_update_link()
12143 link_info->link_state = BNXT_LINK_STATE_DOWN; in bnxt_update_link()
12144 if (link_state != link_info->link_state) in bnxt_update_link()
12148 link_info->link_state = BNXT_LINK_STATE_DOWN; in bnxt_update_link()
12156 if (support_changed && (link_info->autoneg & BNXT_AUTONEG_SPEED)) in bnxt_update_link()
12163 struct bnxt_link_info *link_info = &bp->link_info; in bnxt_get_port_module_status()
12164 struct hwrm_port_phy_qcfg_output *resp = &link_info->phy_qcfg_resp; in bnxt_get_port_module_status()
12170 module_status = link_info->module_status; in bnxt_get_port_module_status()
12175 netdev_warn(bp->dev, "Unqualified SFP+ module detected on port %d\n", in bnxt_get_port_module_status()
12176 bp->pf.port_id); in bnxt_get_port_module_status()
12177 if (bp->hwrm_spec_code >= 0x10201) { in bnxt_get_port_module_status()
12178 netdev_warn(bp->dev, "Module part number %s\n", in bnxt_get_port_module_status()
12179 resp->phy_vendor_partnumber); in bnxt_get_port_module_status()
12182 netdev_warn(bp->dev, "TX is disabled\n"); in bnxt_get_port_module_status()
12184 netdev_warn(bp->dev, "SFP+ module is shutdown\n"); in bnxt_get_port_module_status()
12191 if (bp->link_info.autoneg & BNXT_AUTONEG_FLOW_CTRL) { in bnxt_hwrm_set_pause_common()
12192 if (bp->hwrm_spec_code >= 0x10201) in bnxt_hwrm_set_pause_common()
12193 req->auto_pause = in bnxt_hwrm_set_pause_common()
12195 if (bp->link_info.req_flow_ctrl & BNXT_LINK_PAUSE_RX) in bnxt_hwrm_set_pause_common()
12196 req->auto_pause |= PORT_PHY_CFG_REQ_AUTO_PAUSE_RX; in bnxt_hwrm_set_pause_common()
12197 if (bp->link_info.req_flow_ctrl & BNXT_LINK_PAUSE_TX) in bnxt_hwrm_set_pause_common()
12198 req->auto_pause |= PORT_PHY_CFG_REQ_AUTO_PAUSE_TX; in bnxt_hwrm_set_pause_common()
12199 req->enables |= in bnxt_hwrm_set_pause_common()
12202 if (bp->link_info.req_flow_ctrl & BNXT_LINK_PAUSE_RX) in bnxt_hwrm_set_pause_common()
12203 req->force_pause |= PORT_PHY_CFG_REQ_FORCE_PAUSE_RX; in bnxt_hwrm_set_pause_common()
12204 if (bp->link_info.req_flow_ctrl & BNXT_LINK_PAUSE_TX) in bnxt_hwrm_set_pause_common()
12205 req->force_pause |= PORT_PHY_CFG_REQ_FORCE_PAUSE_TX; in bnxt_hwrm_set_pause_common()
12206 req->enables |= in bnxt_hwrm_set_pause_common()
12208 if (bp->hwrm_spec_code >= 0x10201) { in bnxt_hwrm_set_pause_common()
12209 req->auto_pause = req->force_pause; in bnxt_hwrm_set_pause_common()
12210 req->enables |= cpu_to_le32( in bnxt_hwrm_set_pause_common()
12218 if (bp->link_info.autoneg & BNXT_AUTONEG_SPEED) { in bnxt_hwrm_set_link_common()
12219 req->auto_mode |= PORT_PHY_CFG_REQ_AUTO_MODE_SPEED_MASK; in bnxt_hwrm_set_link_common()
12220 if (bp->phy_flags & BNXT_PHY_FL_SPEEDS2) { in bnxt_hwrm_set_link_common()
12221 req->enables |= in bnxt_hwrm_set_link_common()
12223 req->auto_link_speeds2_mask = cpu_to_le16(bp->link_info.advertising); in bnxt_hwrm_set_link_common()
12224 } else if (bp->link_info.advertising) { in bnxt_hwrm_set_link_common()
12225 req->enables |= cpu_to_le32(PORT_PHY_CFG_REQ_ENABLES_AUTO_LINK_SPEED_MASK); in bnxt_hwrm_set_link_common()
12226 req->auto_link_speed_mask = cpu_to_le16(bp->link_info.advertising); in bnxt_hwrm_set_link_common()
12228 if (bp->link_info.advertising_pam4) { in bnxt_hwrm_set_link_common()
12229 req->enables |= in bnxt_hwrm_set_link_common()
12231 req->auto_link_pam4_speed_mask = in bnxt_hwrm_set_link_common()
12232 cpu_to_le16(bp->link_info.advertising_pam4); in bnxt_hwrm_set_link_common()
12234 req->enables |= cpu_to_le32(PORT_PHY_CFG_REQ_ENABLES_AUTO_MODE); in bnxt_hwrm_set_link_common()
12235 req->flags |= cpu_to_le32(PORT_PHY_CFG_REQ_FLAGS_RESTART_AUTONEG); in bnxt_hwrm_set_link_common()
12237 req->flags |= cpu_to_le32(PORT_PHY_CFG_REQ_FLAGS_FORCE); in bnxt_hwrm_set_link_common()
12238 if (bp->phy_flags & BNXT_PHY_FL_SPEEDS2) { in bnxt_hwrm_set_link_common()
12239 req->force_link_speeds2 = cpu_to_le16(bp->link_info.req_link_speed); in bnxt_hwrm_set_link_common()
12240 req->enables |= cpu_to_le32(PORT_PHY_CFG_REQ_ENABLES_FORCE_LINK_SPEEDS2); in bnxt_hwrm_set_link_common()
12241 netif_info(bp, link, bp->dev, "Forcing FW speed2: %d\n", in bnxt_hwrm_set_link_common()
12242 (u32)bp->link_info.req_link_speed); in bnxt_hwrm_set_link_common()
12243 } else if (bp->link_info.req_signal_mode == BNXT_SIG_MODE_PAM4) { in bnxt_hwrm_set_link_common()
12244 req->force_pam4_link_speed = cpu_to_le16(bp->link_info.req_link_speed); in bnxt_hwrm_set_link_common()
12245 req->enables |= cpu_to_le32(PORT_PHY_CFG_REQ_ENABLES_FORCE_PAM4_LINK_SPEED); in bnxt_hwrm_set_link_common()
12247 req->force_link_speed = cpu_to_le16(bp->link_info.req_link_speed); in bnxt_hwrm_set_link_common()
12252 req->flags |= cpu_to_le32(PORT_PHY_CFG_REQ_FLAGS_RESET_PHY); in bnxt_hwrm_set_link_common()
12266 if ((bp->link_info.autoneg & BNXT_AUTONEG_FLOW_CTRL) || in bnxt_hwrm_set_pause()
12267 bp->link_info.force_link_chng) in bnxt_hwrm_set_pause()
12271 if (!rc && !(bp->link_info.autoneg & BNXT_AUTONEG_FLOW_CTRL)) { in bnxt_hwrm_set_pause()
12276 bp->link_info.pause = in bnxt_hwrm_set_pause()
12277 bp->link_info.force_pause_setting = bp->link_info.req_flow_ctrl; in bnxt_hwrm_set_pause()
12278 bp->link_info.auto_pause_setting = 0; in bnxt_hwrm_set_pause()
12279 if (!bp->link_info.force_link_chng) in bnxt_hwrm_set_pause()
12282 bp->link_info.force_link_chng = false; in bnxt_hwrm_set_pause()
12289 struct ethtool_keee *eee = &bp->eee; in bnxt_hwrm_set_eee()
12291 if (eee->eee_enabled) { in bnxt_hwrm_set_eee()
12295 if (eee->tx_lpi_enabled) in bnxt_hwrm_set_eee()
12300 req->flags |= cpu_to_le32(flags); in bnxt_hwrm_set_eee()
12301 eee_speeds = bnxt_get_fw_auto_link_speeds(eee->advertised); in bnxt_hwrm_set_eee()
12302 req->eee_link_speed_mask = cpu_to_le16(eee_speeds); in bnxt_hwrm_set_eee()
12303 req->tx_lpi_timer = cpu_to_le32(eee->tx_lpi_timer); in bnxt_hwrm_set_eee()
12305 req->flags |= cpu_to_le32(PORT_PHY_CFG_REQ_FLAGS_EEE_DISABLE); in bnxt_hwrm_set_eee()
12336 if (pci_num_vf(bp->pdev) && in bnxt_hwrm_shutdown_link()
12337 !(bp->phy_flags & BNXT_PHY_FL_FW_MANAGED_LKDN)) in bnxt_hwrm_shutdown_link()
12344 req->flags = cpu_to_le32(PORT_PHY_CFG_REQ_FLAGS_FORCE_LINK_DWN); in bnxt_hwrm_shutdown_link()
12347 mutex_lock(&bp->link_lock); in bnxt_hwrm_shutdown_link()
12353 bp->link_info.link_state = BNXT_LINK_STATE_UNKNOWN; in bnxt_hwrm_shutdown_link()
12354 mutex_unlock(&bp->link_lock); in bnxt_hwrm_shutdown_link()
12365 netdev_err(bp->dev, "Failed FW reset via OP-TEE, rc=%d\n", rc); in bnxt_fw_reset_via_optee()
12369 netdev_err(bp->dev, "OP-TEE not supported\n"); in bnxt_fw_reset_via_optee()
12370 return -ENODEV; in bnxt_fw_reset_via_optee()
12376 if (bp->fw_health && bp->fw_health->status_reliable) { in bnxt_try_recover_fw()
12387 } while (rc == -EBUSY && retry < BNXT_FW_RETRY); in bnxt_try_recover_fw()
12390 netdev_err(bp->dev, in bnxt_try_recover_fw()
12393 rc = -ENODEV; in bnxt_try_recover_fw()
12396 netdev_warn(bp->dev, "Firmware recover via OP-TEE requested\n"); in bnxt_try_recover_fw()
12402 return -ENODEV; in bnxt_try_recover_fw()
12407 struct bnxt_hw_resc *hw_resc = &bp->hw_resc; in bnxt_clear_reservations()
12412 hw_resc->resv_cp_rings = 0; in bnxt_clear_reservations()
12413 hw_resc->resv_stat_ctxs = 0; in bnxt_clear_reservations()
12414 hw_resc->resv_irqs = 0; in bnxt_clear_reservations()
12415 hw_resc->resv_tx_rings = 0; in bnxt_clear_reservations()
12416 hw_resc->resv_rx_rings = 0; in bnxt_clear_reservations()
12417 hw_resc->resv_hw_ring_grps = 0; in bnxt_clear_reservations()
12418 hw_resc->resv_vnics = 0; in bnxt_clear_reservations()
12419 hw_resc->resv_rsscos_ctxs = 0; in bnxt_clear_reservations()
12421 bp->tx_nr_rings = 0; in bnxt_clear_reservations()
12422 bp->rx_nr_rings = 0; in bnxt_clear_reservations()
12435 netdev_err(bp->dev, "resc_qcaps failed\n"); in bnxt_cancel_reservations()
12452 fw_reset = (bp->fw_reset_state == BNXT_FW_RESET_STATE_ABORT); in bnxt_hwrm_if_change()
12453 bp->fw_reset_state = 0; in bnxt_hwrm_if_change()
12455 if (!(bp->fw_cap & BNXT_FW_CAP_IF_CHANGE)) in bnxt_hwrm_if_change()
12463 req->flags = cpu_to_le32(FUNC_DRV_IF_CHANGE_REQ_FLAGS_UP); in bnxt_hwrm_if_change()
12469 if (rc != -EAGAIN) in bnxt_hwrm_if_change()
12476 if (rc == -EAGAIN) { in bnxt_hwrm_if_change()
12480 flags = le32_to_cpu(resp->flags); in bnxt_hwrm_if_change()
12497 test_bit(BNXT_STATE_FW_RESET_DET, &bp->state)) in bnxt_hwrm_if_change()
12502 if (test_bit(BNXT_STATE_IN_FW_RESET, &bp->state) && !fw_reset) { in bnxt_hwrm_if_change()
12503 netdev_err(bp->dev, "RESET_DONE not set during FW reset.\n"); in bnxt_hwrm_if_change()
12504 set_bit(BNXT_STATE_ABORT_ERR, &bp->state); in bnxt_hwrm_if_change()
12505 return -ENODEV; in bnxt_hwrm_if_change()
12512 set_bit(BNXT_STATE_FW_RESET_DET, &bp->state); in bnxt_hwrm_if_change()
12513 if (!test_bit(BNXT_STATE_IN_FW_RESET, &bp->state)) in bnxt_hwrm_if_change()
12519 clear_bit(BNXT_STATE_FW_RESET_DET, &bp->state); in bnxt_hwrm_if_change()
12520 set_bit(BNXT_STATE_ABORT_ERR, &bp->state); in bnxt_hwrm_if_change()
12535 struct bnxt_pf_info *pf = &bp->pf; in bnxt_hwrm_port_led_qcaps()
12538 bp->num_leds = 0; in bnxt_hwrm_port_led_qcaps()
12539 if (BNXT_VF(bp) || bp->hwrm_spec_code < 0x10601) in bnxt_hwrm_port_led_qcaps()
12546 req->port_id = cpu_to_le16(pf->port_id); in bnxt_hwrm_port_led_qcaps()
12553 if (resp->num_leds > 0 && resp->num_leds < BNXT_MAX_LED) { in bnxt_hwrm_port_led_qcaps()
12556 bp->num_leds = resp->num_leds; in bnxt_hwrm_port_led_qcaps()
12557 memcpy(bp->leds, &resp->led0_id, sizeof(bp->leds[0]) * in bnxt_hwrm_port_led_qcaps()
12558 bp->num_leds); in bnxt_hwrm_port_led_qcaps()
12559 for (i = 0; i < bp->num_leds; i++) { in bnxt_hwrm_port_led_qcaps()
12560 struct bnxt_led_info *led = &bp->leds[i]; in bnxt_hwrm_port_led_qcaps()
12561 __le16 caps = led->led_state_caps; in bnxt_hwrm_port_led_qcaps()
12563 if (!led->led_group_id || in bnxt_hwrm_port_led_qcaps()
12565 bp->num_leds = 0; in bnxt_hwrm_port_led_qcaps()
12584 req->port_id = cpu_to_le16(bp->pf.port_id); in bnxt_hwrm_alloc_wol_fltr()
12585 req->wol_type = WOL_FILTER_ALLOC_REQ_WOL_TYPE_MAGICPKT; in bnxt_hwrm_alloc_wol_fltr()
12586 req->enables = cpu_to_le32(WOL_FILTER_ALLOC_REQ_ENABLES_MAC_ADDRESS); in bnxt_hwrm_alloc_wol_fltr()
12587 memcpy(req->mac_address, bp->dev->dev_addr, ETH_ALEN); in bnxt_hwrm_alloc_wol_fltr()
12592 bp->wol_filter_id = resp->wol_filter_id; in bnxt_hwrm_alloc_wol_fltr()
12606 req->port_id = cpu_to_le16(bp->pf.port_id); in bnxt_hwrm_free_wol_fltr()
12607 req->enables = cpu_to_le32(WOL_FILTER_FREE_REQ_ENABLES_WOL_FILTER_ID); in bnxt_hwrm_free_wol_fltr()
12608 req->wol_filter_id = bp->wol_filter_id; in bnxt_hwrm_free_wol_fltr()
12624 req->port_id = cpu_to_le16(bp->pf.port_id); in bnxt_hwrm_get_wol_fltrs()
12625 req->handle = cpu_to_le16(handle); in bnxt_hwrm_get_wol_fltrs()
12629 next_handle = le16_to_cpu(resp->next_handle); in bnxt_hwrm_get_wol_fltrs()
12631 if (resp->wol_type == in bnxt_hwrm_get_wol_fltrs()
12633 bp->wol = 1; in bnxt_hwrm_get_wol_fltrs()
12634 bp->wol_filter_id = resp->wol_filter_id; in bnxt_hwrm_get_wol_fltrs()
12646 bp->wol = 0; in bnxt_get_wol_settings()
12647 if (!BNXT_PF(bp) || !(bp->flags & BNXT_FLAG_WOL_CAP)) in bnxt_get_wol_settings()
12657 struct ethtool_keee *eee = &bp->eee; in bnxt_eee_config_ok()
12658 struct bnxt_link_info *link_info = &bp->link_info; in bnxt_eee_config_ok()
12660 if (!(bp->phy_flags & BNXT_PHY_FL_EEE_CAP)) in bnxt_eee_config_ok()
12663 if (eee->eee_enabled) { in bnxt_eee_config_ok()
12667 _bnxt_fw_to_linkmode(advertising, link_info->advertising); in bnxt_eee_config_ok()
12669 if (!(link_info->autoneg & BNXT_AUTONEG_SPEED)) { in bnxt_eee_config_ok()
12670 eee->eee_enabled = 0; in bnxt_eee_config_ok()
12673 if (linkmode_andnot(tmp, eee->advertised, advertising)) { in bnxt_eee_config_ok()
12674 linkmode_and(eee->advertised, advertising, in bnxt_eee_config_ok()
12675 eee->supported); in bnxt_eee_config_ok()
12688 struct bnxt_link_info *link_info = &bp->link_info; in bnxt_update_phy_setting()
12692 netdev_err(bp->dev, "failed to update link (rc: %x)\n", in bnxt_update_phy_setting()
12699 if ((link_info->autoneg & BNXT_AUTONEG_FLOW_CTRL) && in bnxt_update_phy_setting()
12700 (link_info->auto_pause_setting & BNXT_LINK_PAUSE_BOTH) != in bnxt_update_phy_setting()
12701 link_info->req_flow_ctrl) in bnxt_update_phy_setting()
12703 if (!(link_info->autoneg & BNXT_AUTONEG_FLOW_CTRL) && in bnxt_update_phy_setting()
12704 link_info->force_pause_setting != link_info->req_flow_ctrl) in bnxt_update_phy_setting()
12706 if (!(link_info->autoneg & BNXT_AUTONEG_SPEED)) { in bnxt_update_phy_setting()
12707 if (BNXT_AUTO_MODE(link_info->auto_mode)) in bnxt_update_phy_setting()
12711 if (link_info->req_duplex != link_info->duplex_setting) in bnxt_update_phy_setting()
12714 if (link_info->auto_mode == BNXT_LINK_AUTO_NONE) in bnxt_update_phy_setting()
12734 netdev_err(bp->dev, "failed to update phy setting (rc: %x)\n", in bnxt_update_phy_setting()
12748 if (test_bit(BNXT_STATE_IN_FW_RESET, &bp->state)) in bnxt_reinit_after_abort()
12749 return -EBUSY; in bnxt_reinit_after_abort()
12751 if (bp->dev->reg_state == NETREG_UNREGISTERED) in bnxt_reinit_after_abort()
12752 return -ENODEV; in bnxt_reinit_after_abort()
12759 clear_bit(BNXT_STATE_ABORT_ERR, &bp->state); in bnxt_reinit_after_abort()
12760 set_bit(BNXT_STATE_FW_RESET_DET, &bp->state); in bnxt_reinit_after_abort()
12771 if (list_empty(&fltr->list)) in bnxt_cfg_one_usr_fltr()
12774 if (fltr->type == BNXT_FLTR_TYPE_NTUPLE) { in bnxt_cfg_one_usr_fltr()
12776 l2_fltr = bp->vnic_info[BNXT_VNIC_DEFAULT].l2_filters[0]; in bnxt_cfg_one_usr_fltr()
12777 atomic_inc(&l2_fltr->refcnt); in bnxt_cfg_one_usr_fltr()
12778 ntp_fltr->l2_fltr = l2_fltr; in bnxt_cfg_one_usr_fltr()
12781 netdev_err(bp->dev, "restoring previously configured ntuple filter id %d failed\n", in bnxt_cfg_one_usr_fltr()
12782 fltr->sw_id); in bnxt_cfg_one_usr_fltr()
12784 } else if (fltr->type == BNXT_FLTR_TYPE_L2) { in bnxt_cfg_one_usr_fltr()
12788 netdev_err(bp->dev, "restoring previously configured l2 filter id %d failed\n", in bnxt_cfg_one_usr_fltr()
12789 fltr->sw_id); in bnxt_cfg_one_usr_fltr()
12798 list_for_each_entry_safe(usr_fltr, tmp, &bp->usr_fltr_list, list) in bnxt_cfg_usr_fltrs()
12804 int numa_node = dev_to_node(&bp->pdev->dev); in bnxt_set_xps_mapping()
12811 q_map = kcalloc(bp->tx_nr_rings_per_tc, sizeof(*q_map), GFP_KERNEL); in bnxt_set_xps_mapping()
12813 return -ENOMEM; in bnxt_set_xps_mapping()
12820 map_idx = i % bp->tx_nr_rings_per_tc; in bnxt_set_xps_mapping()
12827 for (q_idx = 0; q_idx < bp->dev->real_num_tx_queues; q_idx++) { in bnxt_set_xps_mapping()
12828 map_idx = q_idx % bp->tx_nr_rings_per_tc; in bnxt_set_xps_mapping()
12829 rc = netif_set_xps_queue(bp->dev, &q_map[map_idx], q_idx); in bnxt_set_xps_mapping()
12831 netdev_warn(bp->dev, "Error setting XPS for q:%d\n", in bnxt_set_xps_mapping()
12846 netif_carrier_off(bp->dev); in __bnxt_open_nic()
12851 netdev_err(bp->dev, "Failed to reserve default rings at open\n"); in __bnxt_open_nic()
12861 netdev_err(bp->dev, "bnxt_alloc_mem err: %x\n", rc); in __bnxt_open_nic()
12869 netdev_err(bp->dev, "bnxt_request_irq err: %x\n", rc); in __bnxt_open_nic()
12876 netdev_err(bp->dev, "bnxt_init_nic err: %x\n", rc); in __bnxt_open_nic()
12884 mutex_lock(&bp->link_lock); in __bnxt_open_nic()
12886 mutex_unlock(&bp->link_lock); in __bnxt_open_nic()
12888 netdev_warn(bp->dev, "failed to update phy settings\n"); in __bnxt_open_nic()
12890 bp->link_info.phy_retry = true; in __bnxt_open_nic()
12891 bp->link_info.phy_retry_expires = in __bnxt_open_nic()
12898 udp_tunnel_nic_reset_ntf(bp->dev); in __bnxt_open_nic()
12901 netdev_warn(bp->dev, "failed to set xps mapping\n"); in __bnxt_open_nic()
12904 if (bp->tx_nr_rings_xdp < num_possible_cpus()) { in __bnxt_open_nic()
12910 set_bit(BNXT_STATE_OPEN, &bp->state); in __bnxt_open_nic()
12914 mod_timer(&bp->timer, jiffies + bp->current_interval); in __bnxt_open_nic()
12916 mutex_lock(&bp->link_lock); in __bnxt_open_nic()
12918 mutex_unlock(&bp->link_lock); in __bnxt_open_nic()
12920 /* VF-reps may need to be re-opened after the PF is re-opened */ in __bnxt_open_nic()
12944 if (test_bit(BNXT_STATE_ABORT_ERR, &bp->state)) in bnxt_open_nic()
12945 rc = -EIO; in bnxt_open_nic()
12949 netdev_err(bp->dev, "nic open fail (rc: %x)\n", rc); in bnxt_open_nic()
12950 netif_close(bp->dev); in bnxt_open_nic()
12963 if (test_bit(BNXT_STATE_ABORT_ERR, &bp->state)) { in bnxt_half_open_nic()
12964 netdev_err(bp->dev, "A previous firmware reset has not completed, aborting half open\n"); in bnxt_half_open_nic()
12965 rc = -ENODEV; in bnxt_half_open_nic()
12971 netdev_err(bp->dev, "bnxt_alloc_mem err: %x\n", rc); in bnxt_half_open_nic()
12975 set_bit(BNXT_STATE_HALF_OPEN, &bp->state); in bnxt_half_open_nic()
12978 clear_bit(BNXT_STATE_HALF_OPEN, &bp->state); in bnxt_half_open_nic()
12980 netdev_err(bp->dev, "bnxt_init_nic err: %x\n", rc); in bnxt_half_open_nic()
12988 netif_close(bp->dev); in bnxt_half_open_nic()
13001 clear_bit(BNXT_STATE_HALF_OPEN, &bp->state); in bnxt_half_close_nic()
13007 struct bnxt_pf_info *pf = &bp->pf; in bnxt_reenable_sriov()
13008 int n = pf->active_vfs; in bnxt_reenable_sriov()
13020 if (test_bit(BNXT_STATE_ABORT_ERR, &bp->state)) { in bnxt_open()
13023 if (rc == -EBUSY) in bnxt_open()
13024 netdev_err(bp->dev, "A previous firmware reset has not completed, aborting\n"); in bnxt_open()
13026 netdev_err(bp->dev, "Failed to reinitialize after aborted firmware reset\n"); in bnxt_open()
13027 return -ENODEV; in bnxt_open()
13039 if (test_and_clear_bit(BNXT_STATE_FW_RESET_DET, &bp->state)) { in bnxt_open()
13040 if (!test_bit(BNXT_STATE_IN_FW_RESET, &bp->state)) in bnxt_open()
13051 return (test_bit(BNXT_STATE_IN_SP_TASK, &bp->state) || in bnxt_drv_busy()
13052 test_bit(BNXT_STATE_READ_STATS, &bp->state)); in bnxt_drv_busy()
13061 /* Close the VF-reps before closing PF */ in __bnxt_close_nic()
13068 clear_bit(BNXT_STATE_OPEN, &bp->state); in __bnxt_close_nic()
13082 timer_delete_sync(&bp->timer); in __bnxt_close_nic()
13086 if (bp->bnapi && irq_re_init) { in __bnxt_close_nic()
13087 bnxt_get_ring_stats(bp, &bp->net_stats_prev); in __bnxt_close_nic()
13088 bnxt_get_ring_err_stats(bp, &bp->ring_err_stats_prev); in __bnxt_close_nic()
13099 if (test_bit(BNXT_STATE_IN_FW_RESET, &bp->state)) { in bnxt_close_nic()
13108 netdev_warn(bp->dev, "FW reset in progress during close, FW reset will be aborted\n"); in bnxt_close_nic()
13109 set_bit(BNXT_STATE_ABORT_ERR, &bp->state); in bnxt_close_nic()
13113 if (bp->sriov_cfg) { in bnxt_close_nic()
13116 rc = wait_event_interruptible_timeout(bp->sriov_cfg_wait, in bnxt_close_nic()
13117 !bp->sriov_cfg, in bnxt_close_nic()
13120 …netdev_warn(bp->dev, "timeout waiting for SRIOV config operation to complete, proceeding to close!… in bnxt_close_nic()
13122 netdev_warn(bp->dev, "SRIOV config operation interrupted, proceeding to close!\n"); in bnxt_close_nic()
13145 if (bp->hwrm_spec_code < 0x10a00) in bnxt_hwrm_port_phy_read()
13146 return -EOPNOTSUPP; in bnxt_hwrm_port_phy_read()
13152 req->port_id = cpu_to_le16(bp->pf.port_id); in bnxt_hwrm_port_phy_read()
13153 req->phy_addr = phy_addr; in bnxt_hwrm_port_phy_read()
13154 req->reg_addr = cpu_to_le16(reg & 0x1f); in bnxt_hwrm_port_phy_read()
13156 req->cl45_mdio = 1; in bnxt_hwrm_port_phy_read()
13157 req->phy_addr = mdio_phy_id_prtad(phy_addr); in bnxt_hwrm_port_phy_read()
13158 req->dev_addr = mdio_phy_id_devad(phy_addr); in bnxt_hwrm_port_phy_read()
13159 req->reg_addr = cpu_to_le16(reg); in bnxt_hwrm_port_phy_read()
13165 *val = le16_to_cpu(resp->reg_data); in bnxt_hwrm_port_phy_read()
13176 if (bp->hwrm_spec_code < 0x10a00) in bnxt_hwrm_port_phy_write()
13177 return -EOPNOTSUPP; in bnxt_hwrm_port_phy_write()
13183 req->port_id = cpu_to_le16(bp->pf.port_id); in bnxt_hwrm_port_phy_write()
13184 req->phy_addr = phy_addr; in bnxt_hwrm_port_phy_write()
13185 req->reg_addr = cpu_to_le16(reg & 0x1f); in bnxt_hwrm_port_phy_write()
13187 req->cl45_mdio = 1; in bnxt_hwrm_port_phy_write()
13188 req->phy_addr = mdio_phy_id_prtad(phy_addr); in bnxt_hwrm_port_phy_write()
13189 req->dev_addr = mdio_phy_id_devad(phy_addr); in bnxt_hwrm_port_phy_write()
13190 req->reg_addr = cpu_to_le16(reg); in bnxt_hwrm_port_phy_write()
13192 req->reg_data = cpu_to_le16(val); in bnxt_hwrm_port_phy_write()
13206 mdio->phy_id = bp->link_info.phy_addr; in bnxt_ioctl()
13213 return -EAGAIN; in bnxt_ioctl()
13215 rc = bnxt_hwrm_port_phy_read(bp, mdio->phy_id, mdio->reg_num, in bnxt_ioctl()
13217 mdio->val_out = mii_regval; in bnxt_ioctl()
13223 return -EAGAIN; in bnxt_ioctl()
13225 return bnxt_hwrm_port_phy_write(bp, mdio->phy_id, mdio->reg_num, in bnxt_ioctl()
13226 mdio->val_in); in bnxt_ioctl()
13238 return -EOPNOTSUPP; in bnxt_ioctl()
13246 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_get_ring_stats()
13247 struct bnxt_napi *bnapi = bp->bnapi[i]; in bnxt_get_ring_stats()
13248 struct bnxt_cp_ring_info *cpr = &bnapi->cp_ring; in bnxt_get_ring_stats()
13249 u64 *sw = cpr->stats.sw_stats; in bnxt_get_ring_stats()
13251 stats->rx_packets += BNXT_GET_RING_STATS64(sw, rx_ucast_pkts); in bnxt_get_ring_stats()
13252 stats->rx_packets += BNXT_GET_RING_STATS64(sw, rx_mcast_pkts); in bnxt_get_ring_stats()
13253 stats->rx_packets += BNXT_GET_RING_STATS64(sw, rx_bcast_pkts); in bnxt_get_ring_stats()
13255 stats->tx_packets += BNXT_GET_RING_STATS64(sw, tx_ucast_pkts); in bnxt_get_ring_stats()
13256 stats->tx_packets += BNXT_GET_RING_STATS64(sw, tx_mcast_pkts); in bnxt_get_ring_stats()
13257 stats->tx_packets += BNXT_GET_RING_STATS64(sw, tx_bcast_pkts); in bnxt_get_ring_stats()
13259 stats->rx_bytes += BNXT_GET_RING_STATS64(sw, rx_ucast_bytes); in bnxt_get_ring_stats()
13260 stats->rx_bytes += BNXT_GET_RING_STATS64(sw, rx_mcast_bytes); in bnxt_get_ring_stats()
13261 stats->rx_bytes += BNXT_GET_RING_STATS64(sw, rx_bcast_bytes); in bnxt_get_ring_stats()
13263 stats->tx_bytes += BNXT_GET_RING_STATS64(sw, tx_ucast_bytes); in bnxt_get_ring_stats()
13264 stats->tx_bytes += BNXT_GET_RING_STATS64(sw, tx_mcast_bytes); in bnxt_get_ring_stats()
13265 stats->tx_bytes += BNXT_GET_RING_STATS64(sw, tx_bcast_bytes); in bnxt_get_ring_stats()
13267 stats->rx_missed_errors += in bnxt_get_ring_stats()
13270 stats->multicast += BNXT_GET_RING_STATS64(sw, rx_mcast_pkts); in bnxt_get_ring_stats()
13272 stats->tx_dropped += BNXT_GET_RING_STATS64(sw, tx_error_pkts); in bnxt_get_ring_stats()
13274 stats->rx_dropped += in bnxt_get_ring_stats()
13275 cpr->sw_stats->rx.rx_netpoll_discards + in bnxt_get_ring_stats()
13276 cpr->sw_stats->rx.rx_oom_discards; in bnxt_get_ring_stats()
13283 struct rtnl_link_stats64 *prev_stats = &bp->net_stats_prev; in bnxt_add_prev_stats()
13285 stats->rx_packets += prev_stats->rx_packets; in bnxt_add_prev_stats()
13286 stats->tx_packets += prev_stats->tx_packets; in bnxt_add_prev_stats()
13287 stats->rx_bytes += prev_stats->rx_bytes; in bnxt_add_prev_stats()
13288 stats->tx_bytes += prev_stats->tx_bytes; in bnxt_add_prev_stats()
13289 stats->rx_missed_errors += prev_stats->rx_missed_errors; in bnxt_add_prev_stats()
13290 stats->multicast += prev_stats->multicast; in bnxt_add_prev_stats()
13291 stats->rx_dropped += prev_stats->rx_dropped; in bnxt_add_prev_stats()
13292 stats->tx_dropped += prev_stats->tx_dropped; in bnxt_add_prev_stats()
13300 set_bit(BNXT_STATE_READ_STATS, &bp->state); in bnxt_get_stats64()
13305 if (!test_bit(BNXT_STATE_OPEN, &bp->state)) { in bnxt_get_stats64()
13306 clear_bit(BNXT_STATE_READ_STATS, &bp->state); in bnxt_get_stats64()
13307 *stats = bp->net_stats_prev; in bnxt_get_stats64()
13314 if (bp->flags & BNXT_FLAG_PORT_STATS) { in bnxt_get_stats64()
13315 u64 *rx = bp->port_stats.sw_stats; in bnxt_get_stats64()
13316 u64 *tx = bp->port_stats.sw_stats + in bnxt_get_stats64()
13319 stats->rx_crc_errors = in bnxt_get_stats64()
13321 stats->rx_frame_errors = in bnxt_get_stats64()
13323 stats->rx_length_errors = in bnxt_get_stats64()
13327 stats->rx_errors = in bnxt_get_stats64()
13330 stats->collisions = in bnxt_get_stats64()
13332 stats->tx_fifo_errors = in bnxt_get_stats64()
13334 stats->tx_errors = BNXT_GET_TX_PORT_STATS64(tx, tx_err); in bnxt_get_stats64()
13336 clear_bit(BNXT_STATE_READ_STATS, &bp->state); in bnxt_get_stats64()
13343 struct bnxt_sw_stats *sw_stats = cpr->sw_stats; in bnxt_get_one_ring_err_stats()
13344 u64 *hw_stats = cpr->stats.sw_stats; in bnxt_get_one_ring_err_stats()
13346 stats->rx_total_l4_csum_errors += sw_stats->rx.rx_l4_csum_errors; in bnxt_get_one_ring_err_stats()
13347 stats->rx_total_resets += sw_stats->rx.rx_resets; in bnxt_get_one_ring_err_stats()
13348 stats->rx_total_buf_errors += sw_stats->rx.rx_buf_errors; in bnxt_get_one_ring_err_stats()
13349 stats->rx_total_oom_discards += sw_stats->rx.rx_oom_discards; in bnxt_get_one_ring_err_stats()
13350 stats->rx_total_netpoll_discards += sw_stats->rx.rx_netpoll_discards; in bnxt_get_one_ring_err_stats()
13351 stats->rx_total_ring_discards += in bnxt_get_one_ring_err_stats()
13353 stats->tx_total_resets += sw_stats->tx.tx_resets; in bnxt_get_one_ring_err_stats()
13354 stats->tx_total_ring_discards += in bnxt_get_one_ring_err_stats()
13356 stats->total_missed_irqs += sw_stats->cmn.missed_irqs; in bnxt_get_one_ring_err_stats()
13364 for (i = 0; i < bp->cp_nr_rings; i++) in bnxt_get_ring_err_stats()
13365 bnxt_get_one_ring_err_stats(bp, stats, &bp->bnapi[i]->cp_ring); in bnxt_get_ring_err_stats()
13370 struct bnxt_vnic_info *vnic = &bp->vnic_info[BNXT_VNIC_DEFAULT]; in bnxt_mc_list_updated()
13371 struct net_device *dev = bp->dev; in bnxt_mc_list_updated()
13381 vnic->mc_list_count = 0; in bnxt_mc_list_updated()
13384 haddr = ha->addr; in bnxt_mc_list_updated()
13385 if (!ether_addr_equal(haddr, vnic->mc_list + off)) { in bnxt_mc_list_updated()
13386 memcpy(vnic->mc_list + off, haddr, ETH_ALEN); in bnxt_mc_list_updated()
13395 if (mc_count != vnic->mc_list_count) { in bnxt_mc_list_updated()
13396 vnic->mc_list_count = mc_count; in bnxt_mc_list_updated()
13404 struct net_device *dev = bp->dev; in bnxt_uc_list_updated()
13405 struct bnxt_vnic_info *vnic = &bp->vnic_info[BNXT_VNIC_DEFAULT]; in bnxt_uc_list_updated()
13409 if (netdev_uc_count(dev) != (vnic->uc_filter_count - 1)) in bnxt_uc_list_updated()
13413 if (!ether_addr_equal(ha->addr, vnic->uc_list + off)) in bnxt_uc_list_updated()
13429 if (!test_bit(BNXT_STATE_OPEN, &bp->state)) in bnxt_set_rx_mode()
13432 vnic = &bp->vnic_info[BNXT_VNIC_DEFAULT]; in bnxt_set_rx_mode()
13433 mask = vnic->rx_mask; in bnxt_set_rx_mode()
13439 if (dev->flags & IFF_PROMISC) in bnxt_set_rx_mode()
13444 if (dev->flags & IFF_BROADCAST) in bnxt_set_rx_mode()
13446 if (dev->flags & IFF_ALLMULTI) { in bnxt_set_rx_mode()
13448 vnic->mc_list_count = 0; in bnxt_set_rx_mode()
13449 } else if (dev->flags & IFF_MULTICAST) { in bnxt_set_rx_mode()
13453 if (mask != vnic->rx_mask || uc_update || mc_update) { in bnxt_set_rx_mode()
13454 vnic->rx_mask = mask; in bnxt_set_rx_mode()
13462 struct net_device *dev = bp->dev; in bnxt_cfg_rx_mode()
13463 struct bnxt_vnic_info *vnic = &bp->vnic_info[BNXT_VNIC_DEFAULT]; in bnxt_cfg_rx_mode()
13475 for (i = 1; i < vnic->uc_filter_count; i++) { in bnxt_cfg_rx_mode()
13476 struct bnxt_l2_filter *fltr = vnic->l2_filters[i]; in bnxt_cfg_rx_mode()
13482 vnic->uc_filter_count = 1; in bnxt_cfg_rx_mode()
13485 if (netdev_uc_count(dev) > (BNXT_MAX_UC_ADDRS - 1)) { in bnxt_cfg_rx_mode()
13486 vnic->rx_mask |= CFA_L2_SET_RX_MASK_REQ_MASK_PROMISCUOUS; in bnxt_cfg_rx_mode()
13489 memcpy(vnic->uc_list + off, ha->addr, ETH_ALEN); in bnxt_cfg_rx_mode()
13491 vnic->uc_filter_count++; in bnxt_cfg_rx_mode()
13496 for (i = 1, off = 0; i < vnic->uc_filter_count; i++, off += ETH_ALEN) { in bnxt_cfg_rx_mode()
13497 rc = bnxt_hwrm_set_vnic_filter(bp, 0, i, vnic->uc_list + off); in bnxt_cfg_rx_mode()
13499 if (BNXT_VF(bp) && rc == -ENODEV) { in bnxt_cfg_rx_mode()
13500 if (!test_and_set_bit(BNXT_STATE_L2_FILTER_RETRY, &bp->state)) in bnxt_cfg_rx_mode()
13501 netdev_warn(bp->dev, "Cannot configure L2 filters while PF is unavailable, will retry\n"); in bnxt_cfg_rx_mode()
13503 netdev_dbg(bp->dev, "PF still unavailable while configuring L2 filters.\n"); in bnxt_cfg_rx_mode()
13506 netdev_err(bp->dev, "HWRM vnic filter failure rc: %x\n", rc); in bnxt_cfg_rx_mode()
13508 vnic->uc_filter_count = i; in bnxt_cfg_rx_mode()
13512 if (test_and_clear_bit(BNXT_STATE_L2_FILTER_RETRY, &bp->state)) in bnxt_cfg_rx_mode()
13513 netdev_notice(bp->dev, "Retry of L2 filter configuration successful.\n"); in bnxt_cfg_rx_mode()
13516 if ((vnic->rx_mask & CFA_L2_SET_RX_MASK_REQ_MASK_PROMISCUOUS) && in bnxt_cfg_rx_mode()
13518 vnic->rx_mask &= ~CFA_L2_SET_RX_MASK_REQ_MASK_PROMISCUOUS; in bnxt_cfg_rx_mode()
13520 if (rc && (vnic->rx_mask & CFA_L2_SET_RX_MASK_REQ_MASK_MCAST)) { in bnxt_cfg_rx_mode()
13521 netdev_info(bp->dev, "Failed setting MC filters rc: %d, turning on ALL_MCAST mode\n", in bnxt_cfg_rx_mode()
13523 vnic->rx_mask &= ~CFA_L2_SET_RX_MASK_REQ_MASK_MCAST; in bnxt_cfg_rx_mode()
13524 vnic->rx_mask |= CFA_L2_SET_RX_MASK_REQ_MASK_ALL_MCAST; in bnxt_cfg_rx_mode()
13525 vnic->mc_list_count = 0; in bnxt_cfg_rx_mode()
13529 netdev_err(bp->dev, "HWRM cfa l2 rx mask failure rc: %d\n", in bnxt_cfg_rx_mode()
13539 struct bnxt_hw_resc *hw_resc = &bp->hw_resc; in bnxt_can_reserve_rings()
13544 if (hw_resc->min_tx_rings || hw_resc->resv_tx_rings) in bnxt_can_reserve_rings()
13547 if (!netif_running(bp->dev)) in bnxt_can_reserve_rings()
13557 if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) { in bnxt_rfs_supported()
13558 if (bp->fw_cap & BNXT_FW_CAP_CFA_RFS_RING_TBL_IDX_V2) in bnxt_rfs_supported()
13567 if (bp->rss_cap & BNXT_RSS_CAP_NEW_RSS_CAP) in bnxt_rfs_supported()
13578 if ((bp->flags & BNXT_FLAG_CHIP_P5_PLUS) && in bnxt_rfs_capable()
13582 if (!bnxt_can_reserve_rings(bp) || !bp->rx_nr_rings) in bnxt_rfs_capable()
13585 hwr.grp = bp->rx_nr_rings; in bnxt_rfs_capable()
13586 hwr.vnic = bnxt_get_total_vnics(bp, bp->rx_nr_rings); in bnxt_rfs_capable()
13594 if (bp->rx_nr_rings > 1) in bnxt_rfs_capable()
13595 netdev_warn(bp->dev, in bnxt_rfs_capable()
13597 min(max_rss_ctxs - 1, max_vnics - 1)); in bnxt_rfs_capable()
13608 if (hwr.vnic <= bp->hw_resc.resv_vnics && in bnxt_rfs_capable()
13609 hwr.rss_ctx <= bp->hw_resc.resv_rsscos_ctxs) in bnxt_rfs_capable()
13613 if (hwr.vnic <= bp->hw_resc.resv_vnics && in bnxt_rfs_capable()
13614 hwr.rss_ctx <= bp->hw_resc.resv_rsscos_ctxs) in bnxt_rfs_capable()
13617 netdev_warn(bp->dev, "Unable to reserve resources to support NTUPLE filters.\n"); in bnxt_rfs_capable()
13618 hwr.vnic = 1; in bnxt_rfs_capable()
13633 if ((bp->flags & BNXT_FLAG_NO_AGG_RINGS) || bp->xdp_prog) in bnxt_fix_features()
13647 if (dev->features & BNXT_HW_FEATURE_VLAN_ALL_RX) in bnxt_fix_features()
13653 if (BNXT_VF(bp) && bp->vf.vlan) in bnxt_fix_features()
13663 bp->flags = flags; in bnxt_reinit_features()
13673 u32 flags = bp->flags; in bnxt_set_features()
13684 if (bp->flags & BNXT_FLAG_NO_AGG_RINGS) in bnxt_set_features()
13695 changes = flags ^ bp->flags; in bnxt_set_features()
13698 if ((bp->flags & BNXT_FLAG_TPA) == 0 || in bnxt_set_features()
13700 (bp->flags & BNXT_FLAG_CHIP_P5_PLUS)) in bnxt_set_features()
13710 if (flags != bp->flags) { in bnxt_set_features()
13711 u32 old_flags = bp->flags; in bnxt_set_features()
13713 if (!test_bit(BNXT_STATE_OPEN, &bp->state)) { in bnxt_set_features()
13714 bp->flags = flags; in bnxt_set_features()
13727 bp->flags = flags; in bnxt_set_features()
13732 bp->flags = old_flags; in bnxt_set_features()
13741 struct ipv6hdr *ip6h = (struct ipv6hdr *)(skb->data + nw_off); in bnxt_exthdr_check()
13751 nexthdr = &ip6h->nexthdr; in bnxt_exthdr_check()
13759 hp = __skb_header_pointer(NULL, start, sizeof(*hp), skb->data, in bnxt_exthdr_check()
13771 /* The ext header may be a hop-by-hop header inserted for in bnxt_exthdr_check()
13776 if (likely(skb->len <= GRO_LEGACY_MAX_SIZE)) in bnxt_exthdr_check()
13780 if (jhdr->tlv_type != IPV6_TLV_JUMBO || jhdr->hdrlen != 0 || in bnxt_exthdr_check()
13781 jhdr->nexthdr != IPPROTO_TCP) in bnxt_exthdr_check()
13789 nexthdr = &hp->nexthdr; in bnxt_exthdr_check()
13794 if (skb->encapsulation) { in bnxt_exthdr_check()
13800 /* Only support TCP/UDP for non-tunneled ipv6 and inner ipv6 */ in bnxt_exthdr_check()
13804 /* For UDP, we can only handle 1 Vxlan port and 1 Geneve port. */
13808 __be16 udp_port = uh->dest; in bnxt_udp_tunl_check()
13810 if (udp_port != bp->vxlan_port && udp_port != bp->nge_port && in bnxt_udp_tunl_check()
13811 udp_port != bp->vxlan_gpe_port) in bnxt_udp_tunl_check()
13813 if (skb->inner_protocol == htons(ETH_P_TEB)) { in bnxt_udp_tunl_check()
13816 switch (eh->h_proto) { in bnxt_udp_tunl_check()
13824 } else if (skb->inner_protocol == htons(ETH_P_IP)) { in bnxt_udp_tunl_check()
13826 } else if (skb->inner_protocol == htons(ETH_P_IPV6)) { in bnxt_udp_tunl_check()
13841 switch (skb->inner_protocol) { in bnxt_tunl_check()
13868 if (!skb->encapsulation) in bnxt_features_check()
13870 l4_proto = &ip_hdr(skb)->protocol; in bnxt_features_check()
13901 rc = -ENOMEM; in bnxt_dbg_hwrm_rd_reg()
13905 req->host_dest_addr = cpu_to_le64(mapping); in bnxt_dbg_hwrm_rd_reg()
13908 req->read_addr = cpu_to_le32(reg_off + CHIMP_REG_VIEW_ADDR); in bnxt_dbg_hwrm_rd_reg()
13909 req->read_len32 = cpu_to_le32(num_words); in bnxt_dbg_hwrm_rd_reg()
13912 if (rc || resp->error_code) { in bnxt_dbg_hwrm_rd_reg()
13913 rc = -EIO; in bnxt_dbg_hwrm_rd_reg()
13935 req->ring_type = ring_type; in bnxt_dbg_hwrm_ring_info_get()
13936 req->fw_ring_id = cpu_to_le32(ring_id); in bnxt_dbg_hwrm_ring_info_get()
13940 *prod = le32_to_cpu(resp->producer_index); in bnxt_dbg_hwrm_ring_info_get()
13941 *cons = le32_to_cpu(resp->consumer_index); in bnxt_dbg_hwrm_ring_info_get()
13950 int i = bnapi->index, j; in bnxt_dump_tx_sw_state()
13953 netdev_info(bnapi->bp->dev, "[%d.%d]: tx{fw_ring: %d prod: %x cons: %x}\n", in bnxt_dump_tx_sw_state()
13954 i, j, txr->tx_ring_struct.fw_ring_id, txr->tx_prod, in bnxt_dump_tx_sw_state()
13955 txr->tx_cons); in bnxt_dump_tx_sw_state()
13960 struct bnxt_rx_ring_info *rxr = bnapi->rx_ring; in bnxt_dump_rx_sw_state()
13961 int i = bnapi->index; in bnxt_dump_rx_sw_state()
13966 …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()
13967 i, rxr->rx_ring_struct.fw_ring_id, rxr->rx_prod, in bnxt_dump_rx_sw_state()
13968 rxr->rx_agg_ring_struct.fw_ring_id, rxr->rx_agg_prod, in bnxt_dump_rx_sw_state()
13969 rxr->rx_sw_agg_prod); in bnxt_dump_rx_sw_state()
13974 struct bnxt_cp_ring_info *cpr = &bnapi->cp_ring; in bnxt_dump_cp_sw_state()
13975 int i = bnapi->index; in bnxt_dump_cp_sw_state()
13977 netdev_info(bnapi->bp->dev, "[%d]: cp{fw_ring: %d raw_cons: %x}\n", in bnxt_dump_cp_sw_state()
13978 i, cpr->cp_ring_struct.fw_ring_id, cpr->cp_raw_cons); in bnxt_dump_cp_sw_state()
13986 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_dbg_dump_states()
13987 bnapi = bp->bnapi[i]; in bnxt_dbg_dump_states()
13998 struct bnxt_rx_ring_info *rxr = &bp->rx_ring[ring_nr]; in bnxt_hwrm_rx_ring_reset()
14000 struct bnxt_napi *bnapi = rxr->bnapi; in bnxt_hwrm_rx_ring_reset()
14009 cpr = &bnapi->cp_ring; in bnxt_hwrm_rx_ring_reset()
14010 cp_ring_id = cpr->cp_ring_struct.fw_ring_id; in bnxt_hwrm_rx_ring_reset()
14011 req->cmpl_ring = cpu_to_le16(cp_ring_id); in bnxt_hwrm_rx_ring_reset()
14012 req->ring_type = RING_RESET_REQ_RING_TYPE_RX_RING_GRP; in bnxt_hwrm_rx_ring_reset()
14013 req->ring_id = cpu_to_le16(bp->grp_info[bnapi->index].fw_grp_id); in bnxt_hwrm_rx_ring_reset()
14021 if (netif_running(bp->dev)) { in bnxt_reset_task()
14031 netdev_err(bp->dev, "TX timeout detected, starting reset task!\n"); in bnxt_tx_timeout()
14037 struct bnxt_fw_health *fw_health = bp->fw_health; in bnxt_fw_health_check()
14038 struct pci_dev *pdev = bp->pdev; in bnxt_fw_health_check()
14041 if (!fw_health->enabled || test_bit(BNXT_STATE_IN_FW_RESET, &bp->state)) in bnxt_fw_health_check()
14046 if (fw_health->tmr_counter) { in bnxt_fw_health_check()
14047 fw_health->tmr_counter--; in bnxt_fw_health_check()
14052 if (val == fw_health->last_fw_heartbeat && pci_device_is_present(pdev)) { in bnxt_fw_health_check()
14053 fw_health->arrests++; in bnxt_fw_health_check()
14057 fw_health->last_fw_heartbeat = val; in bnxt_fw_health_check()
14060 if (val != fw_health->last_fw_reset_cnt && pci_device_is_present(pdev)) { in bnxt_fw_health_check()
14061 fw_health->discoveries++; in bnxt_fw_health_check()
14065 fw_health->tmr_counter = fw_health->tmr_multiplier; in bnxt_fw_health_check()
14074 struct bnxt *bp = timer_container_of(bp, t, timer); in bnxt_timer()
14075 struct net_device *dev = bp->dev; in bnxt_timer()
14077 if (!netif_running(dev) || !test_bit(BNXT_STATE_OPEN, &bp->state)) in bnxt_timer()
14080 if (atomic_read(&bp->intr_sem) != 0) in bnxt_timer()
14083 if (bp->fw_cap & BNXT_FW_CAP_ERROR_RECOVERY) in bnxt_timer()
14086 if (BNXT_LINK_IS_UP(bp) && bp->stats_coal_ticks) in bnxt_timer()
14093 if ((bp->flags & BNXT_FLAG_RFS) && bp->ntp_fltr_count) in bnxt_timer()
14097 if (bp->link_info.phy_retry) { in bnxt_timer()
14098 if (time_after(jiffies, bp->link_info.phy_retry_expires)) { in bnxt_timer()
14099 bp->link_info.phy_retry = false; in bnxt_timer()
14100 netdev_warn(bp->dev, "failed to update phy settings after maximum retries.\n"); in bnxt_timer()
14106 if (test_bit(BNXT_STATE_L2_FILTER_RETRY, &bp->state)) in bnxt_timer()
14109 if ((BNXT_CHIP_P5(bp)) && !bp->chip_rev && netif_carrier_ok(dev)) in bnxt_timer()
14113 mod_timer(&bp->timer, jiffies + bp->current_interval); in bnxt_timer()
14124 clear_bit(BNXT_STATE_IN_SP_TASK, &bp->state); in bnxt_lock_sp()
14125 netdev_lock(bp->dev); in bnxt_lock_sp()
14130 set_bit(BNXT_STATE_IN_SP_TASK, &bp->state); in bnxt_unlock_sp()
14131 netdev_unlock(bp->dev); in bnxt_unlock_sp()
14138 if (test_bit(BNXT_STATE_OPEN, &bp->state)) in bnxt_reset()
14149 if (!test_bit(BNXT_STATE_OPEN, &bp->state)) { in bnxt_rx_ring_reset()
14154 if (bp->flags & BNXT_FLAG_TPA) in bnxt_rx_ring_reset()
14156 for (i = 0; i < bp->rx_nr_rings; i++) { in bnxt_rx_ring_reset()
14157 struct bnxt_rx_ring_info *rxr = &bp->rx_ring[i]; in bnxt_rx_ring_reset()
14161 if (!rxr->bnapi->in_reset) in bnxt_rx_ring_reset()
14166 if (rc == -EINVAL || rc == -EOPNOTSUPP) in bnxt_rx_ring_reset()
14167 …netdev_info_once(bp->dev, "RX ring reset not supported by firmware, falling back to global reset\n… in bnxt_rx_ring_reset()
14169 netdev_warn(bp->dev, "RX ring reset failed, rc = %d, falling back to global reset\n", in bnxt_rx_ring_reset()
14175 rxr->rx_prod = 0; in bnxt_rx_ring_reset()
14176 rxr->rx_agg_prod = 0; in bnxt_rx_ring_reset()
14177 rxr->rx_sw_agg_prod = 0; in bnxt_rx_ring_reset()
14178 rxr->rx_next_cons = 0; in bnxt_rx_ring_reset()
14179 rxr->bnapi->in_reset = false; in bnxt_rx_ring_reset()
14181 cpr = &rxr->bnapi->cp_ring; in bnxt_rx_ring_reset()
14182 cpr->sw_stats->rx.rx_resets++; in bnxt_rx_ring_reset()
14183 if (bp->flags & BNXT_FLAG_AGG_RINGS) in bnxt_rx_ring_reset()
14184 bnxt_db_write(bp, &rxr->rx_agg_db, rxr->rx_agg_prod); in bnxt_rx_ring_reset()
14185 bnxt_db_write(bp, &rxr->rx_db, rxr->rx_prod); in bnxt_rx_ring_reset()
14187 if (bp->flags & BNXT_FLAG_TPA) in bnxt_rx_ring_reset()
14199 pci_disable_device(bp->pdev); in bnxt_fw_fatal_close()
14208 if (test_bit(BNXT_STATE_FW_FATAL_COND, &bp->state)) { in bnxt_fw_reset_close()
14211 pci_read_config_word(bp->pdev, PCI_SUBSYSTEM_ID, &val); in bnxt_fw_reset_close()
14213 bp->fw_reset_min_dsecs = 0; in bnxt_fw_reset_close()
14220 if (pci_is_enabled(bp->pdev)) in bnxt_fw_reset_close()
14221 pci_disable_device(bp->pdev); in bnxt_fw_reset_close()
14227 struct bnxt_fw_health *fw_health = bp->fw_health; in is_bnxt_fw_ok()
14232 if (val == fw_health->last_fw_heartbeat) in is_bnxt_fw_ok()
14236 if (val != fw_health->last_fw_reset_cnt) in is_bnxt_fw_ok()
14248 struct bnxt_fw_health *fw_health = bp->fw_health; in bnxt_force_fw_reset()
14249 struct bnxt_ptp_cfg *ptp = bp->ptp_cfg; in bnxt_force_fw_reset()
14252 if (!test_bit(BNXT_STATE_OPEN, &bp->state) || in bnxt_force_fw_reset()
14253 test_bit(BNXT_STATE_IN_FW_RESET, &bp->state)) in bnxt_force_fw_reset()
14260 write_seqlock_irqsave(&ptp->ptp_lock, flags); in bnxt_force_fw_reset()
14261 set_bit(BNXT_STATE_IN_FW_RESET, &bp->state); in bnxt_force_fw_reset()
14262 write_sequnlock_irqrestore(&ptp->ptp_lock, flags); in bnxt_force_fw_reset()
14264 set_bit(BNXT_STATE_IN_FW_RESET, &bp->state); in bnxt_force_fw_reset()
14267 wait_dsecs = fw_health->master_func_wait_dsecs; in bnxt_force_fw_reset()
14268 if (fw_health->primary) { in bnxt_force_fw_reset()
14269 if (fw_health->flags & ERROR_RECOVERY_QCFG_RESP_FLAGS_CO_CPU) in bnxt_force_fw_reset()
14271 bp->fw_reset_state = BNXT_FW_RESET_STATE_RESET_FW; in bnxt_force_fw_reset()
14273 bp->fw_reset_timestamp = jiffies + wait_dsecs * HZ / 10; in bnxt_force_fw_reset()
14274 wait_dsecs = fw_health->normal_func_wait_dsecs; in bnxt_force_fw_reset()
14275 bp->fw_reset_state = BNXT_FW_RESET_STATE_ENABLE_DEV; in bnxt_force_fw_reset()
14278 bp->fw_reset_min_dsecs = fw_health->post_reset_wait_dsecs; in bnxt_force_fw_reset()
14279 bp->fw_reset_max_dsecs = fw_health->post_reset_max_wait_dsecs; in bnxt_force_fw_reset()
14285 netdev_warn(bp->dev, "Detected firmware fatal condition, initiating reset\n"); in bnxt_fw_exception()
14286 set_bit(BNXT_STATE_FW_FATAL_COND, &bp->state); in bnxt_fw_exception()
14293 /* Returns the number of registered VFs, or 1 if VF configuration is pending, or
14306 netdev_err(bp->dev, "func_qcfg cmd failed, rc = %d\n", rc); in bnxt_get_registered_vfs()
14309 if (bp->pf.registered_vfs) in bnxt_get_registered_vfs()
14310 return bp->pf.registered_vfs; in bnxt_get_registered_vfs()
14311 if (bp->sriov_cfg) in bnxt_get_registered_vfs()
14312 return 1; in bnxt_get_registered_vfs()
14321 if (test_bit(BNXT_STATE_OPEN, &bp->state) && in bnxt_fw_reset()
14322 !test_bit(BNXT_STATE_IN_FW_RESET, &bp->state)) { in bnxt_fw_reset()
14323 struct bnxt_ptp_cfg *ptp = bp->ptp_cfg; in bnxt_fw_reset()
14330 write_seqlock_irqsave(&ptp->ptp_lock, flags); in bnxt_fw_reset()
14331 set_bit(BNXT_STATE_IN_FW_RESET, &bp->state); in bnxt_fw_reset()
14332 write_sequnlock_irqrestore(&ptp->ptp_lock, flags); in bnxt_fw_reset()
14334 set_bit(BNXT_STATE_IN_FW_RESET, &bp->state); in bnxt_fw_reset()
14336 if (bp->pf.active_vfs && in bnxt_fw_reset()
14337 !test_bit(BNXT_STATE_FW_FATAL_COND, &bp->state)) in bnxt_fw_reset()
14340 netdev_err(bp->dev, "Firmware reset aborted, rc = %d\n", in bnxt_fw_reset()
14342 clear_bit(BNXT_STATE_IN_FW_RESET, &bp->state); in bnxt_fw_reset()
14343 netif_close(bp->dev); in bnxt_fw_reset()
14348 if (bp->fw_reset_max_dsecs < vf_tmo_dsecs) in bnxt_fw_reset()
14349 bp->fw_reset_max_dsecs = vf_tmo_dsecs; in bnxt_fw_reset()
14350 bp->fw_reset_state = in bnxt_fw_reset()
14356 if (bp->fw_cap & BNXT_FW_CAP_ERR_RECOVER_RELOAD) { in bnxt_fw_reset()
14357 bp->fw_reset_state = BNXT_FW_RESET_STATE_POLL_FW_DOWN; in bnxt_fw_reset()
14360 bp->fw_reset_state = BNXT_FW_RESET_STATE_ENABLE_DEV; in bnxt_fw_reset()
14361 tmo = bp->fw_reset_min_dsecs * HZ / 10; in bnxt_fw_reset()
14373 if (!(bp->flags & BNXT_FLAG_CHIP_P5_PLUS)) in bnxt_chk_missed_irq()
14376 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_chk_missed_irq()
14377 struct bnxt_napi *bnapi = bp->bnapi[i]; in bnxt_chk_missed_irq()
14385 cpr = &bnapi->cp_ring; in bnxt_chk_missed_irq()
14386 for (j = 0; j < cpr->cp_ring_count; j++) { in bnxt_chk_missed_irq()
14387 struct bnxt_cp_ring_info *cpr2 = &cpr->cp_ring_arr[j]; in bnxt_chk_missed_irq()
14390 if (cpr2->has_more_work || !bnxt_has_work(bp, cpr2)) in bnxt_chk_missed_irq()
14393 if (cpr2->cp_raw_cons != cpr2->last_cp_raw_cons) { in bnxt_chk_missed_irq()
14394 cpr2->last_cp_raw_cons = cpr2->cp_raw_cons; in bnxt_chk_missed_irq()
14397 fw_ring_id = cpr2->cp_ring_struct.fw_ring_id; in bnxt_chk_missed_irq()
14400 fw_ring_id, &val[0], &val[1]); in bnxt_chk_missed_irq()
14401 cpr->sw_stats->cmn.missed_irqs++; in bnxt_chk_missed_irq()
14410 struct bnxt_link_info *link_info = &bp->link_info; in bnxt_init_ethtool_link_settings()
14412 if (BNXT_AUTO_MODE(link_info->auto_mode)) { in bnxt_init_ethtool_link_settings()
14413 link_info->autoneg = BNXT_AUTONEG_SPEED; in bnxt_init_ethtool_link_settings()
14414 if (bp->hwrm_spec_code >= 0x10201) { in bnxt_init_ethtool_link_settings()
14415 if (link_info->auto_pause_setting & in bnxt_init_ethtool_link_settings()
14417 link_info->autoneg |= BNXT_AUTONEG_FLOW_CTRL; in bnxt_init_ethtool_link_settings()
14419 link_info->autoneg |= BNXT_AUTONEG_FLOW_CTRL; in bnxt_init_ethtool_link_settings()
14424 link_info->req_duplex = link_info->duplex_setting; in bnxt_init_ethtool_link_settings()
14426 if (link_info->autoneg & BNXT_AUTONEG_FLOW_CTRL) in bnxt_init_ethtool_link_settings()
14427 link_info->req_flow_ctrl = in bnxt_init_ethtool_link_settings()
14428 link_info->auto_pause_setting & BNXT_LINK_PAUSE_BOTH; in bnxt_init_ethtool_link_settings()
14430 link_info->req_flow_ctrl = link_info->force_pause_setting; in bnxt_init_ethtool_link_settings()
14435 struct bnxt_fw_health *fw_health = bp->fw_health; in bnxt_fw_echo_reply()
14442 req->event_data1 = cpu_to_le32(fw_health->echo_req_data1); in bnxt_fw_echo_reply()
14443 req->event_data2 = cpu_to_le32(fw_health->echo_req_data2); in bnxt_fw_echo_reply()
14457 set_bit(BNXT_STATE_IN_SP_TASK, &bp->state); in bnxt_sp_task()
14459 if (!test_bit(BNXT_STATE_OPEN, &bp->state)) { in bnxt_sp_task()
14460 clear_bit(BNXT_STATE_IN_SP_TASK, &bp->state); in bnxt_sp_task()
14464 if (test_and_clear_bit(BNXT_RESTART_ULP_SP_EVENT, &bp->sp_event)) { in bnxt_sp_task()
14469 if (test_and_clear_bit(BNXT_RX_MASK_SP_EVENT, &bp->sp_event)) in bnxt_sp_task()
14472 if (test_and_clear_bit(BNXT_RX_NTP_FLTR_SP_EVENT, &bp->sp_event)) in bnxt_sp_task()
14474 if (test_and_clear_bit(BNXT_HWRM_EXEC_FWD_REQ_SP_EVENT, &bp->sp_event)) in bnxt_sp_task()
14476 if (test_and_clear_bit(BNXT_HWRM_PF_UNLOAD_SP_EVENT, &bp->sp_event)) in bnxt_sp_task()
14477 netdev_info(bp->dev, "Receive PF driver unload event!\n"); in bnxt_sp_task()
14478 if (test_and_clear_bit(BNXT_PERIODIC_STATS_SP_EVENT, &bp->sp_event)) { in bnxt_sp_task()
14484 if (test_and_clear_bit(BNXT_LINK_CHNG_SP_EVENT, &bp->sp_event)) { in bnxt_sp_task()
14487 mutex_lock(&bp->link_lock); in bnxt_sp_task()
14489 &bp->sp_event)) in bnxt_sp_task()
14494 netdev_err(bp->dev, "SP task can't update link (rc: %x)\n", in bnxt_sp_task()
14498 &bp->sp_event)) in bnxt_sp_task()
14500 mutex_unlock(&bp->link_lock); in bnxt_sp_task()
14502 if (test_and_clear_bit(BNXT_UPDATE_PHY_SP_EVENT, &bp->sp_event)) { in bnxt_sp_task()
14505 mutex_lock(&bp->link_lock); in bnxt_sp_task()
14507 mutex_unlock(&bp->link_lock); in bnxt_sp_task()
14509 netdev_warn(bp->dev, "update phy settings retry failed\n"); in bnxt_sp_task()
14511 bp->link_info.phy_retry = false; in bnxt_sp_task()
14512 netdev_info(bp->dev, "update phy settings retry succeeded\n"); in bnxt_sp_task()
14515 if (test_and_clear_bit(BNXT_HWRM_PORT_MODULE_SP_EVENT, &bp->sp_event)) { in bnxt_sp_task()
14516 mutex_lock(&bp->link_lock); in bnxt_sp_task()
14518 mutex_unlock(&bp->link_lock); in bnxt_sp_task()
14521 if (test_and_clear_bit(BNXT_FLOW_STATS_SP_EVENT, &bp->sp_event)) in bnxt_sp_task()
14524 if (test_and_clear_bit(BNXT_RING_COAL_NOW_SP_EVENT, &bp->sp_event)) in bnxt_sp_task()
14527 if (test_and_clear_bit(BNXT_FW_ECHO_REQUEST_SP_EVENT, &bp->sp_event)) in bnxt_sp_task()
14530 if (test_and_clear_bit(BNXT_THERMAL_THRESHOLD_SP_EVENT, &bp->sp_event)) in bnxt_sp_task()
14536 if (test_and_clear_bit(BNXT_RESET_TASK_SP_EVENT, &bp->sp_event)) in bnxt_sp_task()
14539 if (test_and_clear_bit(BNXT_RESET_TASK_SILENT_SP_EVENT, &bp->sp_event)) in bnxt_sp_task()
14542 if (test_and_clear_bit(BNXT_RST_RING_SP_EVENT, &bp->sp_event)) in bnxt_sp_task()
14545 if (test_and_clear_bit(BNXT_FW_RESET_NOTIFY_SP_EVENT, &bp->sp_event)) { in bnxt_sp_task()
14546 if (test_bit(BNXT_STATE_FW_FATAL_COND, &bp->state) || in bnxt_sp_task()
14547 test_bit(BNXT_STATE_FW_NON_FATAL_COND, &bp->state)) in bnxt_sp_task()
14553 if (test_and_clear_bit(BNXT_FW_EXCEPTION_SP_EVENT, &bp->sp_event)) { in bnxt_sp_task()
14559 clear_bit(BNXT_STATE_IN_SP_TASK, &bp->state); in bnxt_sp_task()
14569 int max_rx, max_tx, max_cp, tx_sets = 1, tx_cp; in bnxt_check_rings()
14580 return -ENOMEM; in bnxt_check_rings()
14582 if (bp->flags & BNXT_FLAG_AGG_RINGS) in bnxt_check_rings()
14583 rx_rings <<= 1; in bnxt_check_rings()
14588 return -ENOMEM; in bnxt_check_rings()
14595 return -ENOMEM; in bnxt_check_rings()
14603 if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) in bnxt_check_rings()
14606 if (!rc && pci_msix_can_alloc_dyn(bp->pdev)) { in bnxt_check_rings()
14607 if (!bnxt_ulp_registered(bp->edev)) { in bnxt_check_rings()
14611 if (hwr.cp > bp->total_irqs) { in bnxt_check_rings()
14615 netdev_warn(bp->dev, "Unable to allocate %d MSIX vectors, maximum available %d\n", in bnxt_check_rings()
14617 rc = -ENOSPC; in bnxt_check_rings()
14626 if (bp->bar2) { in bnxt_unmap_bars()
14627 pci_iounmap(pdev, bp->bar2); in bnxt_unmap_bars()
14628 bp->bar2 = NULL; in bnxt_unmap_bars()
14631 if (bp->bar1) { in bnxt_unmap_bars()
14632 pci_iounmap(pdev, bp->bar1); in bnxt_unmap_bars()
14633 bp->bar1 = NULL; in bnxt_unmap_bars()
14636 if (bp->bar0) { in bnxt_unmap_bars()
14637 pci_iounmap(pdev, bp->bar0); in bnxt_unmap_bars()
14638 bp->bar0 = NULL; in bnxt_unmap_bars()
14644 bnxt_unmap_bars(bp, bp->pdev); in bnxt_cleanup_pci()
14645 pci_release_regions(bp->pdev); in bnxt_cleanup_pci()
14646 if (pci_is_enabled(bp->pdev)) in bnxt_cleanup_pci()
14647 pci_disable_device(bp->pdev); in bnxt_cleanup_pci()
14652 struct bnxt_coal_cap *coal_cap = &bp->coal_cap; in bnxt_init_dflt_coal()
14656 if (coal_cap->cmpl_params & in bnxt_init_dflt_coal()
14661 * 1 coal_buf x bufs_per_record = 1 completion record. in bnxt_init_dflt_coal()
14663 coal = &bp->rx_coal; in bnxt_init_dflt_coal()
14664 coal->coal_ticks = 10; in bnxt_init_dflt_coal()
14665 coal->coal_bufs = 30; in bnxt_init_dflt_coal()
14666 coal->coal_ticks_irq = 1; in bnxt_init_dflt_coal()
14667 coal->coal_bufs_irq = 2; in bnxt_init_dflt_coal()
14668 coal->idle_thresh = 50; in bnxt_init_dflt_coal()
14669 coal->bufs_per_record = 2; in bnxt_init_dflt_coal()
14670 coal->budget = 64; /* NAPI budget */ in bnxt_init_dflt_coal()
14671 coal->flags = flags; in bnxt_init_dflt_coal()
14673 coal = &bp->tx_coal; in bnxt_init_dflt_coal()
14674 coal->coal_ticks = 28; in bnxt_init_dflt_coal()
14675 coal->coal_bufs = 30; in bnxt_init_dflt_coal()
14676 coal->coal_ticks_irq = 2; in bnxt_init_dflt_coal()
14677 coal->coal_bufs_irq = 2; in bnxt_init_dflt_coal()
14678 coal->bufs_per_record = 1; in bnxt_init_dflt_coal()
14679 coal->flags = flags; in bnxt_init_dflt_coal()
14681 bp->stats_coal_ticks = BNXT_DEF_STATS_COAL_TICKS; in bnxt_init_dflt_coal()
14684 /* FW that pre-reserves 1 VNIC per function */
14689 if (!(bp->flags & BNXT_FLAG_CHIP_P5_PLUS) && in bnxt_fw_pre_resv_vnics()
14692 if ((bp->flags & BNXT_FLAG_CHIP_P5_PLUS) && in bnxt_fw_pre_resv_vnics()
14702 bp->fw_cap = 0; in bnxt_fw_init_one_p1()
14723 return -ENODEV; in bnxt_fw_init_one_p1()
14736 netdev_err(bp->dev, "hwrm query capability failure rc: %x\n", in bnxt_fw_init_one_p2()
14738 return -ENODEV; in bnxt_fw_init_one_p2()
14743 netdev_warn(bp->dev, "hwrm query adv flow mgnt failure rc: %d\n", in bnxt_fw_init_one_p2()
14747 netdev_warn(bp->dev, "no memory for firmware error recovery\n"); in bnxt_fw_init_one_p2()
14751 netdev_warn(bp->dev, "hwrm query error recovery failure rc: %d\n", in bnxt_fw_init_one_p2()
14757 return -ENODEV; in bnxt_fw_init_one_p2()
14761 netdev_warn(bp->dev, "crash dump mem alloc failure rc: %d\n", in bnxt_fw_init_one_p2()
14767 netdev_warn(bp->dev, in bnxt_fw_init_one_p2()
14773 bp->fw_cap |= BNXT_FW_CAP_PRE_RESV_VNICS; in bnxt_fw_init_one_p2()
14779 if (bp->fw_cap & BNXT_FW_CAP_PTP) in bnxt_fw_init_one_p2()
14788 bp->rss_cap &= ~BNXT_RSS_CAP_UDP_RSS_CAP; in bnxt_set_dflt_rss_hash_type()
14789 bp->rss_hash_cfg = VNIC_RSS_CFG_REQ_HASH_TYPE_IPV4 | in bnxt_set_dflt_rss_hash_type()
14793 if (bp->rss_cap & BNXT_RSS_CAP_RSS_HASH_TYPE_DELTA) in bnxt_set_dflt_rss_hash_type()
14794 bp->rss_hash_delta = bp->rss_hash_cfg; in bnxt_set_dflt_rss_hash_type()
14795 if (BNXT_CHIP_P4_PLUS(bp) && bp->hwrm_spec_code >= 0x10501) { in bnxt_set_dflt_rss_hash_type()
14796 bp->rss_cap |= BNXT_RSS_CAP_UDP_RSS_CAP; in bnxt_set_dflt_rss_hash_type()
14797 bp->rss_hash_cfg |= VNIC_RSS_CFG_REQ_HASH_TYPE_UDP_IPV4 | in bnxt_set_dflt_rss_hash_type()
14804 struct net_device *dev = bp->dev; in bnxt_set_dflt_rfs()
14806 dev->hw_features &= ~NETIF_F_NTUPLE; in bnxt_set_dflt_rfs()
14807 dev->features &= ~NETIF_F_NTUPLE; in bnxt_set_dflt_rfs()
14808 bp->flags &= ~BNXT_FLAG_RFS; in bnxt_set_dflt_rfs()
14810 dev->hw_features |= NETIF_F_NTUPLE; in bnxt_set_dflt_rfs()
14812 bp->flags |= BNXT_FLAG_RFS; in bnxt_set_dflt_rfs()
14813 dev->features |= NETIF_F_NTUPLE; in bnxt_set_dflt_rfs()
14820 struct pci_dev *pdev = bp->pdev; in bnxt_fw_init_one_p3()
14826 if (bp->flags & BNXT_FLAG_WOL_CAP) in bnxt_fw_init_one_p3()
14827 device_set_wakeup_enable(&pdev->dev, bp->wol); in bnxt_fw_init_one_p3()
14829 device_set_wakeup_capable(&pdev->dev, false); in bnxt_fw_init_one_p3()
14843 netdev_err(bp->dev, "Firmware init phase 1 failed\n"); in bnxt_fw_init_one()
14848 netdev_err(bp->dev, "Firmware init phase 2 failed\n"); in bnxt_fw_init_one()
14854 rc = bnxt_approve_mac(bp, bp->dev->dev_addr, false); in bnxt_fw_init_one()
14864 struct bnxt_fw_health *fw_health = bp->fw_health; in bnxt_fw_reset_writel()
14865 u32 reg = fw_health->fw_reset_seq_regs[reg_idx]; in bnxt_fw_reset_writel()
14866 u32 val = fw_health->fw_reset_seq_vals[reg_idx]; in bnxt_fw_reset_writel()
14869 delay_msecs = fw_health->fw_reset_seq_delay_msec[reg_idx]; in bnxt_fw_reset_writel()
14874 pci_write_config_dword(bp->pdev, reg_off, val); in bnxt_fw_reset_writel()
14878 bp->bar0 + BNXT_GRCPF_REG_WINDOW_BASE_OUT + 4); in bnxt_fw_reset_writel()
14882 writel(val, bp->bar0 + reg_off); in bnxt_fw_reset_writel()
14885 writel(val, bp->bar1 + reg_off); in bnxt_fw_reset_writel()
14889 pci_read_config_dword(bp->pdev, 0, &val); in bnxt_fw_reset_writel()
14900 if (~bp->fw_cap & BNXT_FW_CAP_HOT_RESET_IF) in bnxt_hwrm_reset_permitted()
14906 req->fid = cpu_to_le16(0xffff); in bnxt_hwrm_reset_permitted()
14909 result = !!(le16_to_cpu(resp->flags) & in bnxt_hwrm_reset_permitted()
14917 struct bnxt_fw_health *fw_health = bp->fw_health; in bnxt_reset_all()
14920 if (bp->fw_cap & BNXT_FW_CAP_ERR_RECOVER_RELOAD) { in bnxt_reset_all()
14922 bp->fw_reset_timestamp = jiffies; in bnxt_reset_all()
14926 if (fw_health->flags & ERROR_RECOVERY_QCFG_RESP_FLAGS_HOST) { in bnxt_reset_all()
14927 for (i = 0; i < fw_health->fw_reset_seq_cnt; i++) in bnxt_reset_all()
14929 } else if (fw_health->flags & ERROR_RECOVERY_QCFG_RESP_FLAGS_CO_CPU) { in bnxt_reset_all()
14934 req->target_id = cpu_to_le16(HWRM_TARGET_ID_KONG); in bnxt_reset_all()
14935 req->embedded_proc_type = FW_RESET_REQ_EMBEDDED_PROC_TYPE_CHIP; in bnxt_reset_all()
14936 req->selfrst_status = FW_RESET_REQ_SELFRST_STATUS_SELFRSTASAP; in bnxt_reset_all()
14937 req->flags = FW_RESET_REQ_FLAGS_RESET_GRACEFUL; in bnxt_reset_all()
14940 if (rc != -ENODEV) in bnxt_reset_all()
14941 netdev_warn(bp->dev, "Unable to reset FW rc=%d\n", rc); in bnxt_reset_all()
14943 bp->fw_reset_timestamp = jiffies; in bnxt_reset_all()
14948 return time_after(jiffies, bp->fw_reset_timestamp + in bnxt_fw_reset_timeout()
14949 (bp->fw_reset_max_dsecs * HZ / 10)); in bnxt_fw_reset_timeout()
14954 clear_bit(BNXT_STATE_IN_FW_RESET, &bp->state); in bnxt_fw_reset_abort()
14955 if (bp->fw_reset_state != BNXT_FW_RESET_STATE_POLL_VF) in bnxt_fw_reset_abort()
14957 bp->fw_reset_state = BNXT_FW_RESET_STATE_ABORT; in bnxt_fw_reset_abort()
14958 netif_close(bp->dev); in bnxt_fw_reset_abort()
14966 if (!test_bit(BNXT_STATE_IN_FW_RESET, &bp->state)) { in bnxt_fw_reset_task()
14967 netdev_err(bp->dev, "bnxt_fw_reset_task() called when not in fw reset mode!\n"); in bnxt_fw_reset_task()
14971 switch (bp->fw_reset_state) { in bnxt_fw_reset_task()
14977 …netdev_err(bp->dev, "Firmware reset aborted, subsequent func_qcfg cmd failed, rc = %d, %d msecs si… in bnxt_fw_reset_task()
14978 n, jiffies_to_msecs(jiffies - in bnxt_fw_reset_task()
14979 bp->fw_reset_timestamp)); in bnxt_fw_reset_task()
14983 clear_bit(BNXT_STATE_IN_FW_RESET, &bp->state); in bnxt_fw_reset_task()
14984 bp->fw_reset_state = 0; in bnxt_fw_reset_task()
14985 netdev_err(bp->dev, "Firmware reset aborted, bnxt_get_registered_vfs() returns %d\n", in bnxt_fw_reset_task()
14992 bp->fw_reset_timestamp = jiffies; in bnxt_fw_reset_task()
14993 netdev_lock(bp->dev); in bnxt_fw_reset_task()
14994 if (test_bit(BNXT_STATE_ABORT_ERR, &bp->state)) { in bnxt_fw_reset_task()
14996 netdev_unlock(bp->dev); in bnxt_fw_reset_task()
15000 if (bp->fw_cap & BNXT_FW_CAP_ERR_RECOVER_RELOAD) { in bnxt_fw_reset_task()
15001 bp->fw_reset_state = BNXT_FW_RESET_STATE_POLL_FW_DOWN; in bnxt_fw_reset_task()
15004 bp->fw_reset_state = BNXT_FW_RESET_STATE_ENABLE_DEV; in bnxt_fw_reset_task()
15005 tmo = bp->fw_reset_min_dsecs * HZ / 10; in bnxt_fw_reset_task()
15007 netdev_unlock(bp->dev); in bnxt_fw_reset_task()
15021 if (!bp->fw_health->primary) { in bnxt_fw_reset_task()
15022 u32 wait_dsecs = bp->fw_health->normal_func_wait_dsecs; in bnxt_fw_reset_task()
15024 bp->fw_reset_state = BNXT_FW_RESET_STATE_ENABLE_DEV; in bnxt_fw_reset_task()
15028 bp->fw_reset_state = BNXT_FW_RESET_STATE_RESET_FW; in bnxt_fw_reset_task()
15033 bp->fw_reset_state = BNXT_FW_RESET_STATE_ENABLE_DEV; in bnxt_fw_reset_task()
15034 bnxt_queue_fw_reset_work(bp, bp->fw_reset_min_dsecs * HZ / 10); in bnxt_fw_reset_task()
15038 if (test_bit(BNXT_STATE_FW_FATAL_COND, &bp->state) && in bnxt_fw_reset_task()
15039 !bp->fw_reset_min_dsecs) { in bnxt_fw_reset_task()
15042 pci_read_config_word(bp->pdev, PCI_SUBSYSTEM_ID, &val); in bnxt_fw_reset_task()
15045 netdev_err(bp->dev, "Firmware reset aborted, PCI config space invalid\n"); in bnxt_fw_reset_task()
15046 rc = -ETIMEDOUT; in bnxt_fw_reset_task()
15053 clear_bit(BNXT_STATE_FW_FATAL_COND, &bp->state); in bnxt_fw_reset_task()
15054 clear_bit(BNXT_STATE_FW_NON_FATAL_COND, &bp->state); in bnxt_fw_reset_task()
15055 if (test_and_clear_bit(BNXT_STATE_FW_ACTIVATE_RESET, &bp->state) && in bnxt_fw_reset_task()
15056 !test_bit(BNXT_STATE_FW_ACTIVATE, &bp->state)) in bnxt_fw_reset_task()
15058 if (pci_enable_device(bp->pdev)) { in bnxt_fw_reset_task()
15059 netdev_err(bp->dev, "Cannot re-enable PCI device\n"); in bnxt_fw_reset_task()
15060 rc = -ENODEV; in bnxt_fw_reset_task()
15063 pci_set_master(bp->pdev); in bnxt_fw_reset_task()
15064 bp->fw_reset_state = BNXT_FW_RESET_STATE_POLL_FW; in bnxt_fw_reset_task()
15067 bp->hwrm_cmd_timeout = SHORT_HWRM_CMD_TIMEOUT; in bnxt_fw_reset_task()
15071 netdev_err(bp->dev, "Firmware reset aborted\n"); in bnxt_fw_reset_task()
15077 bp->hwrm_cmd_timeout = DFLT_HWRM_CMD_TIMEOUT; in bnxt_fw_reset_task()
15078 bp->fw_reset_state = BNXT_FW_RESET_STATE_OPENING; in bnxt_fw_reset_task()
15081 while (!netdev_trylock(bp->dev)) { in bnxt_fw_reset_task()
15085 rc = bnxt_open(bp->dev); in bnxt_fw_reset_task()
15087 netdev_err(bp->dev, "bnxt_open() failed during FW reset\n"); in bnxt_fw_reset_task()
15089 netdev_unlock(bp->dev); in bnxt_fw_reset_task()
15093 if ((bp->fw_cap & BNXT_FW_CAP_ERROR_RECOVERY) && in bnxt_fw_reset_task()
15094 bp->fw_health->enabled) { in bnxt_fw_reset_task()
15095 bp->fw_health->last_fw_reset_cnt = in bnxt_fw_reset_task()
15098 bp->fw_reset_state = 0; in bnxt_fw_reset_task()
15101 clear_bit(BNXT_STATE_IN_FW_RESET, &bp->state); in bnxt_fw_reset_task()
15103 clear_bit(BNXT_STATE_FW_ACTIVATE, &bp->state); in bnxt_fw_reset_task()
15104 if (test_and_clear_bit(BNXT_STATE_RECOVER, &bp->state)) { in bnxt_fw_reset_task()
15108 netdev_unlock(bp->dev); in bnxt_fw_reset_task()
15111 netdev_lock(bp->dev); in bnxt_fw_reset_task()
15114 netdev_unlock(bp->dev); in bnxt_fw_reset_task()
15120 if (bp->fw_health->status_reliable || in bnxt_fw_reset_task()
15121 (bp->fw_cap & BNXT_FW_CAP_ERROR_RECOVERY)) { in bnxt_fw_reset_task()
15124 netdev_err(bp->dev, "fw_health_status 0x%x\n", sts); in bnxt_fw_reset_task()
15127 netdev_lock(bp->dev); in bnxt_fw_reset_task()
15129 netdev_unlock(bp->dev); in bnxt_fw_reset_task()
15139 SET_NETDEV_DEV(dev, &pdev->dev); in bnxt_init_board()
15141 /* enable device (incl. PCI PM wakeup), and bus-mastering */ in bnxt_init_board()
15144 dev_err(&pdev->dev, "Cannot enable PCI device, aborting\n"); in bnxt_init_board()
15149 dev_err(&pdev->dev, in bnxt_init_board()
15151 rc = -ENODEV; in bnxt_init_board()
15157 dev_err(&pdev->dev, "Cannot obtain PCI resources, aborting\n"); in bnxt_init_board()
15161 if (dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)) != 0 && in bnxt_init_board()
15162 dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32)) != 0) { in bnxt_init_board()
15163 dev_err(&pdev->dev, "System does not support DMA, aborting\n"); in bnxt_init_board()
15164 rc = -EIO; in bnxt_init_board()
15170 bp->dev = dev; in bnxt_init_board()
15171 bp->pdev = pdev; in bnxt_init_board()
15173 /* Doorbell BAR bp->bar1 is mapped after bnxt_fw_init_one_p2() in bnxt_init_board()
15176 bp->bar0 = pci_ioremap_bar(pdev, 0); in bnxt_init_board()
15177 if (!bp->bar0) { in bnxt_init_board()
15178 dev_err(&pdev->dev, "Cannot map device registers, aborting\n"); in bnxt_init_board()
15179 rc = -ENOMEM; in bnxt_init_board()
15183 bp->bar2 = pci_ioremap_bar(pdev, 4); in bnxt_init_board()
15184 if (!bp->bar2) { in bnxt_init_board()
15185 dev_err(&pdev->dev, "Cannot map bar4 registers, aborting\n"); in bnxt_init_board()
15186 rc = -ENOMEM; in bnxt_init_board()
15190 INIT_WORK(&bp->sp_task, bnxt_sp_task); in bnxt_init_board()
15191 INIT_DELAYED_WORK(&bp->fw_reset_task, bnxt_fw_reset_task); in bnxt_init_board()
15193 spin_lock_init(&bp->ntp_fltr_lock); in bnxt_init_board()
15195 spin_lock_init(&bp->db_lock); in bnxt_init_board()
15198 bp->rx_ring_size = BNXT_DEFAULT_RX_RING_SIZE; in bnxt_init_board()
15199 bp->tx_ring_size = BNXT_DEFAULT_TX_RING_SIZE; in bnxt_init_board()
15201 timer_setup(&bp->timer, bnxt_timer, 0); in bnxt_init_board()
15202 bp->current_interval = BNXT_TIMER_INTERVAL; in bnxt_init_board()
15204 bp->vxlan_fw_dst_port_id = INVALID_HW_RING_ID; in bnxt_init_board()
15205 bp->nge_fw_dst_port_id = INVALID_HW_RING_ID; in bnxt_init_board()
15207 clear_bit(BNXT_STATE_OPEN, &bp->state); in bnxt_init_board()
15229 if (!is_valid_ether_addr(addr->sa_data)) in bnxt_change_mac_addr()
15230 return -EADDRNOTAVAIL; in bnxt_change_mac_addr()
15232 if (ether_addr_equal(addr->sa_data, dev->dev_addr)) in bnxt_change_mac_addr()
15235 rc = bnxt_approve_mac(bp, addr->sa_data, true); in bnxt_change_mac_addr()
15239 eth_hw_addr_set(dev, addr->sa_data); in bnxt_change_mac_addr()
15258 WRITE_ONCE(dev->mtu, new_mtu); in bnxt_change_mtu()
15260 /* MTU change may change the AGG ring settings if an XDP multi-buffer in bnxt_change_mtu()
15264 if (READ_ONCE(bp->xdp_prog)) in bnxt_change_mtu()
15281 if (tc > bp->max_tc) { in bnxt_setup_mq_tc()
15283 tc, bp->max_tc); in bnxt_setup_mq_tc()
15284 return -EINVAL; in bnxt_setup_mq_tc()
15287 if (bp->num_tc == tc) in bnxt_setup_mq_tc()
15290 if (bp->flags & BNXT_FLAG_SHARED_RINGS) in bnxt_setup_mq_tc()
15293 rc = bnxt_check_rings(bp, bp->tx_nr_rings_per_tc, bp->rx_nr_rings, in bnxt_setup_mq_tc()
15294 sh, tc, bp->tx_nr_rings_xdp); in bnxt_setup_mq_tc()
15298 /* Needs to close the device and do hw resource re-allocations */ in bnxt_setup_mq_tc()
15299 if (netif_running(bp->dev)) in bnxt_setup_mq_tc()
15303 bp->tx_nr_rings = bp->tx_nr_rings_per_tc * tc; in bnxt_setup_mq_tc()
15305 bp->num_tc = tc; in bnxt_setup_mq_tc()
15307 bp->tx_nr_rings = bp->tx_nr_rings_per_tc; in bnxt_setup_mq_tc()
15309 bp->num_tc = 0; in bnxt_setup_mq_tc()
15311 bp->tx_nr_rings += bp->tx_nr_rings_xdp; in bnxt_setup_mq_tc()
15312 tx_cp = bnxt_num_tx_to_cp(bp, bp->tx_nr_rings); in bnxt_setup_mq_tc()
15313 bp->cp_nr_rings = sh ? max_t(int, tx_cp, bp->rx_nr_rings) : in bnxt_setup_mq_tc()
15314 tx_cp + bp->rx_nr_rings; in bnxt_setup_mq_tc()
15316 if (netif_running(bp->dev)) in bnxt_setup_mq_tc()
15328 !tc_cls_can_offload_and_chain0(bp->dev, type_data)) in bnxt_setup_tc_block_cb()
15329 return -EOPNOTSUPP; in bnxt_setup_tc_block_cb()
15333 return bnxt_tc_setup_flower(bp, bp->pf.fw_fid, type_data); in bnxt_setup_tc_block_cb()
15335 return -EOPNOTSUPP; in bnxt_setup_tc_block_cb()
15355 mqprio->hw = TC_MQPRIO_HW_OFFLOAD_TCS; in bnxt_setup_tc()
15357 return bnxt_setup_mq_tc(dev, mqprio->num_tc); in bnxt_setup_tc()
15360 return -EOPNOTSUPP; in bnxt_setup_tc()
15372 vnic = &bp->vnic_info[BNXT_VNIC_DEFAULT]; in bnxt_get_ntp_filter_idx()
15373 return bnxt_toeplitz(bp, fkeys, (void *)vnic->rss_hash_key); in bnxt_get_ntp_filter_idx()
15382 spin_lock_bh(&bp->ntp_fltr_lock); in bnxt_insert_ntp_filter()
15383 bit_id = bitmap_find_free_region(bp->ntp_fltr_bmap, bp->max_fltr, 0); in bnxt_insert_ntp_filter()
15385 spin_unlock_bh(&bp->ntp_fltr_lock); in bnxt_insert_ntp_filter()
15386 return -ENOMEM; in bnxt_insert_ntp_filter()
15389 fltr->base.sw_id = (u16)bit_id; in bnxt_insert_ntp_filter()
15390 fltr->base.type = BNXT_FLTR_TYPE_NTUPLE; in bnxt_insert_ntp_filter()
15391 fltr->base.flags |= BNXT_ACT_RING_DST; in bnxt_insert_ntp_filter()
15392 head = &bp->ntp_fltr_hash_tbl[idx]; in bnxt_insert_ntp_filter()
15393 hlist_add_head_rcu(&fltr->base.hash, head); in bnxt_insert_ntp_filter()
15394 set_bit(BNXT_FLTR_INSERTED, &fltr->base.state); in bnxt_insert_ntp_filter()
15395 bnxt_insert_usr_fltr(bp, &fltr->base); in bnxt_insert_ntp_filter()
15396 bp->ntp_fltr_count++; in bnxt_insert_ntp_filter()
15397 spin_unlock_bh(&bp->ntp_fltr_lock); in bnxt_insert_ntp_filter()
15404 struct bnxt_flow_masks *masks1 = &f1->fmasks; in bnxt_fltr_match()
15405 struct bnxt_flow_masks *masks2 = &f2->fmasks; in bnxt_fltr_match()
15406 struct flow_keys *keys1 = &f1->fkeys; in bnxt_fltr_match()
15407 struct flow_keys *keys2 = &f2->fkeys; in bnxt_fltr_match()
15409 if (keys1->basic.n_proto != keys2->basic.n_proto || in bnxt_fltr_match()
15410 keys1->basic.ip_proto != keys2->basic.ip_proto) in bnxt_fltr_match()
15413 if (keys1->basic.n_proto == htons(ETH_P_IP)) { in bnxt_fltr_match()
15414 if (keys1->addrs.v4addrs.src != keys2->addrs.v4addrs.src || in bnxt_fltr_match()
15415 masks1->addrs.v4addrs.src != masks2->addrs.v4addrs.src || in bnxt_fltr_match()
15416 keys1->addrs.v4addrs.dst != keys2->addrs.v4addrs.dst || in bnxt_fltr_match()
15417 masks1->addrs.v4addrs.dst != masks2->addrs.v4addrs.dst) in bnxt_fltr_match()
15420 if (!ipv6_addr_equal(&keys1->addrs.v6addrs.src, in bnxt_fltr_match()
15421 &keys2->addrs.v6addrs.src) || in bnxt_fltr_match()
15422 !ipv6_addr_equal(&masks1->addrs.v6addrs.src, in bnxt_fltr_match()
15423 &masks2->addrs.v6addrs.src) || in bnxt_fltr_match()
15424 !ipv6_addr_equal(&keys1->addrs.v6addrs.dst, in bnxt_fltr_match()
15425 &keys2->addrs.v6addrs.dst) || in bnxt_fltr_match()
15426 !ipv6_addr_equal(&masks1->addrs.v6addrs.dst, in bnxt_fltr_match()
15427 &masks2->addrs.v6addrs.dst)) in bnxt_fltr_match()
15431 return keys1->ports.src == keys2->ports.src && in bnxt_fltr_match()
15432 masks1->ports.src == masks2->ports.src && in bnxt_fltr_match()
15433 keys1->ports.dst == keys2->ports.dst && in bnxt_fltr_match()
15434 masks1->ports.dst == masks2->ports.dst && in bnxt_fltr_match()
15435 keys1->control.flags == keys2->control.flags && in bnxt_fltr_match()
15436 f1->l2_fltr == f2->l2_fltr; in bnxt_fltr_match()
15446 head = &bp->ntp_fltr_hash_tbl[idx]; in bnxt_lookup_ntp_filter_from_idx()
15466 if (ether_addr_equal(dev->dev_addr, eth->h_dest)) { in bnxt_rx_flow_steer()
15467 l2_fltr = bp->vnic_info[BNXT_VNIC_DEFAULT].l2_filters[0]; in bnxt_rx_flow_steer()
15468 atomic_inc(&l2_fltr->refcnt); in bnxt_rx_flow_steer()
15472 ether_addr_copy(key.dst_mac_addr, eth->h_dest); in bnxt_rx_flow_steer()
15476 return -EINVAL; in bnxt_rx_flow_steer()
15477 if (l2_fltr->base.flags & BNXT_ACT_FUNC_DST) { in bnxt_rx_flow_steer()
15479 return -EINVAL; in bnxt_rx_flow_steer()
15485 return -ENOMEM; in bnxt_rx_flow_steer()
15488 fkeys = &new_fltr->fkeys; in bnxt_rx_flow_steer()
15490 rc = -EPROTONOSUPPORT; in bnxt_rx_flow_steer()
15494 if ((fkeys->basic.n_proto != htons(ETH_P_IP) && in bnxt_rx_flow_steer()
15495 fkeys->basic.n_proto != htons(ETH_P_IPV6)) || in bnxt_rx_flow_steer()
15496 ((fkeys->basic.ip_proto != IPPROTO_TCP) && in bnxt_rx_flow_steer()
15497 (fkeys->basic.ip_proto != IPPROTO_UDP))) { in bnxt_rx_flow_steer()
15498 rc = -EPROTONOSUPPORT; in bnxt_rx_flow_steer()
15501 new_fltr->fmasks = BNXT_FLOW_IPV4_MASK_ALL; in bnxt_rx_flow_steer()
15502 if (fkeys->basic.n_proto == htons(ETH_P_IPV6)) { in bnxt_rx_flow_steer()
15503 if (bp->hwrm_spec_code < 0x10601) { in bnxt_rx_flow_steer()
15504 rc = -EPROTONOSUPPORT; in bnxt_rx_flow_steer()
15507 new_fltr->fmasks = BNXT_FLOW_IPV6_MASK_ALL; in bnxt_rx_flow_steer()
15509 flags = fkeys->control.flags; in bnxt_rx_flow_steer()
15511 bp->hwrm_spec_code < 0x10601) || (flags & FLOW_DIS_IS_FRAGMENT)) { in bnxt_rx_flow_steer()
15512 rc = -EPROTONOSUPPORT; in bnxt_rx_flow_steer()
15515 new_fltr->l2_fltr = l2_fltr; in bnxt_rx_flow_steer()
15521 rc = fltr->base.sw_id; in bnxt_rx_flow_steer()
15527 new_fltr->flow_id = flow_id; in bnxt_rx_flow_steer()
15528 new_fltr->base.rxq = rxq_index; in bnxt_rx_flow_steer()
15532 return new_fltr->base.sw_id; in bnxt_rx_flow_steer()
15544 spin_lock_bh(&bp->ntp_fltr_lock); in bnxt_del_ntp_filter()
15545 if (!test_and_clear_bit(BNXT_FLTR_INSERTED, &fltr->base.state)) { in bnxt_del_ntp_filter()
15546 spin_unlock_bh(&bp->ntp_fltr_lock); in bnxt_del_ntp_filter()
15549 hlist_del_rcu(&fltr->base.hash); in bnxt_del_ntp_filter()
15550 bnxt_del_one_usr_fltr(bp, &fltr->base); in bnxt_del_ntp_filter()
15551 bp->ntp_fltr_count--; in bnxt_del_ntp_filter()
15552 spin_unlock_bh(&bp->ntp_fltr_lock); in bnxt_del_ntp_filter()
15553 bnxt_del_l2_filter(bp, fltr->l2_fltr); in bnxt_del_ntp_filter()
15554 clear_bit(fltr->base.sw_id, bp->ntp_fltr_bmap); in bnxt_del_ntp_filter()
15569 head = &bp->ntp_fltr_hash_tbl[i]; in bnxt_cfg_ntp_filters()
15573 if (test_bit(BNXT_FLTR_VALID, &fltr->base.state)) { in bnxt_cfg_ntp_filters()
15574 if (fltr->base.flags & BNXT_ACT_NO_AGING) in bnxt_cfg_ntp_filters()
15576 if (rps_may_expire_flow(bp->dev, fltr->base.rxq, in bnxt_cfg_ntp_filters()
15577 fltr->flow_id, in bnxt_cfg_ntp_filters()
15578 fltr->base.sw_id)) { in bnxt_cfg_ntp_filters()
15589 set_bit(BNXT_FLTR_VALID, &fltr->base.state); in bnxt_cfg_ntp_filters()
15605 if (ti->type == UDP_TUNNEL_TYPE_VXLAN) in bnxt_udp_tunnel_set_port()
15607 else if (ti->type == UDP_TUNNEL_TYPE_GENEVE) in bnxt_udp_tunnel_set_port()
15612 return bnxt_hwrm_tunnel_dst_port_alloc(bp, ti->port, cmd); in bnxt_udp_tunnel_set_port()
15621 if (ti->type == UDP_TUNNEL_TYPE_VXLAN) in bnxt_udp_tunnel_unset_port()
15623 else if (ti->type == UDP_TUNNEL_TYPE_GENEVE) in bnxt_udp_tunnel_unset_port()
15636 { .n_entries = 1, .tunnel_types = UDP_TUNNEL_TYPE_VXLAN, },
15637 { .n_entries = 1, .tunnel_types = UDP_TUNNEL_TYPE_GENEVE, },
15644 { .n_entries = 1, .tunnel_types = UDP_TUNNEL_TYPE_VXLAN, },
15645 { .n_entries = 1, .tunnel_types = UDP_TUNNEL_TYPE_GENEVE, },
15646 { .n_entries = 1, .tunnel_types = UDP_TUNNEL_TYPE_VXLAN_GPE, },
15656 return ndo_dflt_bridge_getlink(skb, pid, seq, dev, bp->br_mode, 0, 0, in bnxt_bridge_getlink()
15667 if (bp->hwrm_spec_code < 0x10708 || !BNXT_SINGLE_PF(bp)) in bnxt_bridge_setlink()
15668 return -EOPNOTSUPP; in bnxt_bridge_setlink()
15672 return -EINVAL; in bnxt_bridge_setlink()
15678 if (mode == bp->br_mode) in bnxt_bridge_setlink()
15683 bp->br_mode = mode; in bnxt_bridge_setlink()
15694 if (bp->eswitch_mode != DEVLINK_ESWITCH_MODE_SWITCHDEV) in bnxt_get_port_parent_id()
15695 return -EOPNOTSUPP; in bnxt_get_port_parent_id()
15697 /* The PF and it's VF-reps only support the switchdev framework */ in bnxt_get_port_parent_id()
15698 if (!BNXT_PF(bp) || !(bp->flags & BNXT_FLAG_DSN_VALID)) in bnxt_get_port_parent_id()
15699 return -EOPNOTSUPP; in bnxt_get_port_parent_id()
15701 ppid->id_len = sizeof(bp->dsn); in bnxt_get_port_parent_id()
15702 memcpy(ppid->id, bp->dsn, ppid->id_len); in bnxt_get_port_parent_id()
15747 if (!bp->bnapi) in bnxt_get_queue_stats_rx()
15750 cpr = &bp->bnapi[i]->cp_ring; in bnxt_get_queue_stats_rx()
15751 sw = cpr->stats.sw_stats; in bnxt_get_queue_stats_rx()
15753 stats->packets = 0; in bnxt_get_queue_stats_rx()
15754 stats->packets += BNXT_GET_RING_STATS64(sw, rx_ucast_pkts); in bnxt_get_queue_stats_rx()
15755 stats->packets += BNXT_GET_RING_STATS64(sw, rx_mcast_pkts); in bnxt_get_queue_stats_rx()
15756 stats->packets += BNXT_GET_RING_STATS64(sw, rx_bcast_pkts); in bnxt_get_queue_stats_rx()
15758 stats->bytes = 0; in bnxt_get_queue_stats_rx()
15759 stats->bytes += BNXT_GET_RING_STATS64(sw, rx_ucast_bytes); in bnxt_get_queue_stats_rx()
15760 stats->bytes += BNXT_GET_RING_STATS64(sw, rx_mcast_bytes); in bnxt_get_queue_stats_rx()
15761 stats->bytes += BNXT_GET_RING_STATS64(sw, rx_bcast_bytes); in bnxt_get_queue_stats_rx()
15763 stats->alloc_fail = cpr->sw_stats->rx.rx_oom_discards; in bnxt_get_queue_stats_rx()
15773 if (!bp->tx_ring) in bnxt_get_queue_stats_tx()
15776 bnapi = bp->tx_ring[bp->tx_ring_map[i]].bnapi; in bnxt_get_queue_stats_tx()
15777 sw = bnapi->cp_ring.stats.sw_stats; in bnxt_get_queue_stats_tx()
15779 stats->packets = 0; in bnxt_get_queue_stats_tx()
15780 stats->packets += BNXT_GET_RING_STATS64(sw, tx_ucast_pkts); in bnxt_get_queue_stats_tx()
15781 stats->packets += BNXT_GET_RING_STATS64(sw, tx_mcast_pkts); in bnxt_get_queue_stats_tx()
15782 stats->packets += BNXT_GET_RING_STATS64(sw, tx_bcast_pkts); in bnxt_get_queue_stats_tx()
15784 stats->bytes = 0; in bnxt_get_queue_stats_tx()
15785 stats->bytes += BNXT_GET_RING_STATS64(sw, tx_ucast_bytes); in bnxt_get_queue_stats_tx()
15786 stats->bytes += BNXT_GET_RING_STATS64(sw, tx_mcast_bytes); in bnxt_get_queue_stats_tx()
15787 stats->bytes += BNXT_GET_RING_STATS64(sw, tx_bcast_bytes); in bnxt_get_queue_stats_tx()
15796 rx->packets = bp->net_stats_prev.rx_packets; in bnxt_get_base_stats()
15797 rx->bytes = bp->net_stats_prev.rx_bytes; in bnxt_get_base_stats()
15798 rx->alloc_fail = bp->ring_err_stats_prev.rx_total_oom_discards; in bnxt_get_base_stats()
15800 tx->packets = bp->net_stats_prev.tx_packets; in bnxt_get_base_stats()
15801 tx->bytes = bp->net_stats_prev.tx_bytes; in bnxt_get_base_stats()
15817 if (!bp->rx_ring) in bnxt_queue_mem_alloc()
15818 return -ENETDOWN; in bnxt_queue_mem_alloc()
15820 rxr = &bp->rx_ring[idx]; in bnxt_queue_mem_alloc()
15826 clone->rx_prod = 0; in bnxt_queue_mem_alloc()
15827 clone->rx_agg_prod = 0; in bnxt_queue_mem_alloc()
15828 clone->rx_sw_agg_prod = 0; in bnxt_queue_mem_alloc()
15829 clone->rx_next_cons = 0; in bnxt_queue_mem_alloc()
15830 clone->need_head_pool = false; in bnxt_queue_mem_alloc()
15832 rc = bnxt_alloc_rx_page_pool(bp, clone, rxr->page_pool->p.nid); in bnxt_queue_mem_alloc()
15836 rc = xdp_rxq_info_reg(&clone->xdp_rxq, bp->dev, idx, 0); in bnxt_queue_mem_alloc()
15840 rc = xdp_rxq_info_reg_mem_model(&clone->xdp_rxq, in bnxt_queue_mem_alloc()
15842 clone->page_pool); in bnxt_queue_mem_alloc()
15846 ring = &clone->rx_ring_struct; in bnxt_queue_mem_alloc()
15847 rc = bnxt_alloc_ring(bp, &ring->ring_mem); in bnxt_queue_mem_alloc()
15851 if (bp->flags & BNXT_FLAG_AGG_RINGS) { in bnxt_queue_mem_alloc()
15852 ring = &clone->rx_agg_ring_struct; in bnxt_queue_mem_alloc()
15853 rc = bnxt_alloc_ring(bp, &ring->ring_mem); in bnxt_queue_mem_alloc()
15862 if (bp->flags & BNXT_FLAG_TPA) { in bnxt_queue_mem_alloc()
15872 if (bp->flags & BNXT_FLAG_AGG_RINGS) in bnxt_queue_mem_alloc()
15874 if (bp->flags & BNXT_FLAG_TPA) in bnxt_queue_mem_alloc()
15882 bnxt_free_ring(bp, &clone->rx_agg_ring_struct.ring_mem); in bnxt_queue_mem_alloc()
15884 bnxt_free_ring(bp, &clone->rx_ring_struct.ring_mem); in bnxt_queue_mem_alloc()
15886 xdp_rxq_info_unreg(&clone->xdp_rxq); in bnxt_queue_mem_alloc()
15888 page_pool_destroy(clone->page_pool); in bnxt_queue_mem_alloc()
15890 page_pool_destroy(clone->head_pool); in bnxt_queue_mem_alloc()
15891 clone->page_pool = NULL; in bnxt_queue_mem_alloc()
15892 clone->head_pool = NULL; in bnxt_queue_mem_alloc()
15905 xdp_rxq_info_unreg(&rxr->xdp_rxq); in bnxt_queue_mem_free()
15907 page_pool_destroy(rxr->page_pool); in bnxt_queue_mem_free()
15909 page_pool_destroy(rxr->head_pool); in bnxt_queue_mem_free()
15910 rxr->page_pool = NULL; in bnxt_queue_mem_free()
15911 rxr->head_pool = NULL; in bnxt_queue_mem_free()
15913 ring = &rxr->rx_ring_struct; in bnxt_queue_mem_free()
15914 bnxt_free_ring(bp, &ring->ring_mem); in bnxt_queue_mem_free()
15916 ring = &rxr->rx_agg_ring_struct; in bnxt_queue_mem_free()
15917 bnxt_free_ring(bp, &ring->ring_mem); in bnxt_queue_mem_free()
15919 kfree(rxr->rx_agg_bmap); in bnxt_queue_mem_free()
15920 rxr->rx_agg_bmap = NULL; in bnxt_queue_mem_free()
15931 dst_ring = &dst->rx_ring_struct; in bnxt_copy_rx_ring()
15932 dst_rmem = &dst_ring->ring_mem; in bnxt_copy_rx_ring()
15933 src_ring = &src->rx_ring_struct; in bnxt_copy_rx_ring()
15934 src_rmem = &src_ring->ring_mem; in bnxt_copy_rx_ring()
15936 WARN_ON(dst_rmem->nr_pages != src_rmem->nr_pages); in bnxt_copy_rx_ring()
15937 WARN_ON(dst_rmem->page_size != src_rmem->page_size); in bnxt_copy_rx_ring()
15938 WARN_ON(dst_rmem->flags != src_rmem->flags); in bnxt_copy_rx_ring()
15939 WARN_ON(dst_rmem->depth != src_rmem->depth); in bnxt_copy_rx_ring()
15940 WARN_ON(dst_rmem->vmem_size != src_rmem->vmem_size); in bnxt_copy_rx_ring()
15941 WARN_ON(dst_rmem->ctx_mem != src_rmem->ctx_mem); in bnxt_copy_rx_ring()
15943 dst_rmem->pg_tbl = src_rmem->pg_tbl; in bnxt_copy_rx_ring()
15944 dst_rmem->pg_tbl_map = src_rmem->pg_tbl_map; in bnxt_copy_rx_ring()
15945 *dst_rmem->vmem = *src_rmem->vmem; in bnxt_copy_rx_ring()
15946 for (i = 0; i < dst_rmem->nr_pages; i++) { in bnxt_copy_rx_ring()
15947 dst_rmem->pg_arr[i] = src_rmem->pg_arr[i]; in bnxt_copy_rx_ring()
15948 dst_rmem->dma_arr[i] = src_rmem->dma_arr[i]; in bnxt_copy_rx_ring()
15951 if (!(bp->flags & BNXT_FLAG_AGG_RINGS)) in bnxt_copy_rx_ring()
15954 dst_ring = &dst->rx_agg_ring_struct; in bnxt_copy_rx_ring()
15955 dst_rmem = &dst_ring->ring_mem; in bnxt_copy_rx_ring()
15956 src_ring = &src->rx_agg_ring_struct; in bnxt_copy_rx_ring()
15957 src_rmem = &src_ring->ring_mem; in bnxt_copy_rx_ring()
15959 WARN_ON(dst_rmem->nr_pages != src_rmem->nr_pages); in bnxt_copy_rx_ring()
15960 WARN_ON(dst_rmem->page_size != src_rmem->page_size); in bnxt_copy_rx_ring()
15961 WARN_ON(dst_rmem->flags != src_rmem->flags); in bnxt_copy_rx_ring()
15962 WARN_ON(dst_rmem->depth != src_rmem->depth); in bnxt_copy_rx_ring()
15963 WARN_ON(dst_rmem->vmem_size != src_rmem->vmem_size); in bnxt_copy_rx_ring()
15964 WARN_ON(dst_rmem->ctx_mem != src_rmem->ctx_mem); in bnxt_copy_rx_ring()
15965 WARN_ON(dst->rx_agg_bmap_size != src->rx_agg_bmap_size); in bnxt_copy_rx_ring()
15967 dst_rmem->pg_tbl = src_rmem->pg_tbl; in bnxt_copy_rx_ring()
15968 dst_rmem->pg_tbl_map = src_rmem->pg_tbl_map; in bnxt_copy_rx_ring()
15969 *dst_rmem->vmem = *src_rmem->vmem; in bnxt_copy_rx_ring()
15970 for (i = 0; i < dst_rmem->nr_pages; i++) { in bnxt_copy_rx_ring()
15971 dst_rmem->pg_arr[i] = src_rmem->pg_arr[i]; in bnxt_copy_rx_ring()
15972 dst_rmem->dma_arr[i] = src_rmem->dma_arr[i]; in bnxt_copy_rx_ring()
15975 dst->rx_agg_bmap = src->rx_agg_bmap; in bnxt_copy_rx_ring()
15988 rxr = &bp->rx_ring[idx]; in bnxt_queue_start()
15991 rxr->rx_prod = clone->rx_prod; in bnxt_queue_start()
15992 rxr->rx_agg_prod = clone->rx_agg_prod; in bnxt_queue_start()
15993 rxr->rx_sw_agg_prod = clone->rx_sw_agg_prod; in bnxt_queue_start()
15994 rxr->rx_next_cons = clone->rx_next_cons; in bnxt_queue_start()
15995 rxr->rx_tpa = clone->rx_tpa; in bnxt_queue_start()
15996 rxr->rx_tpa_idx_map = clone->rx_tpa_idx_map; in bnxt_queue_start()
15997 rxr->page_pool = clone->page_pool; in bnxt_queue_start()
15998 rxr->head_pool = clone->head_pool; in bnxt_queue_start()
15999 rxr->xdp_rxq = clone->xdp_rxq; in bnxt_queue_start()
16000 rxr->need_head_pool = clone->need_head_pool; in bnxt_queue_start()
16004 bnapi = rxr->bnapi; in bnxt_queue_start()
16005 cpr = &bnapi->cp_ring; in bnxt_queue_start()
16014 if (bp->tph_mode) { in bnxt_queue_start()
16015 rc = bnxt_hwrm_cp_ring_alloc_p5(bp, rxr->rx_cpr); in bnxt_queue_start()
16024 bnxt_db_write(bp, &rxr->rx_db, rxr->rx_prod); in bnxt_queue_start()
16025 if (bp->flags & BNXT_FLAG_AGG_RINGS) in bnxt_queue_start()
16026 bnxt_db_write(bp, &rxr->rx_agg_db, rxr->rx_agg_prod); in bnxt_queue_start()
16028 if (bp->flags & BNXT_FLAG_SHARED_RINGS) { in bnxt_queue_start()
16034 napi_enable_locked(&bnapi->napi); in bnxt_queue_start()
16035 bnxt_db_nq_arm(bp, &cpr->cp_db, cpr->cp_raw_cons); in bnxt_queue_start()
16037 mru = bp->dev->mtu + ETH_HLEN + VLAN_HLEN; in bnxt_queue_start()
16038 for (i = 0; i < bp->nr_vnics; i++) { in bnxt_queue_start()
16039 vnic = &bp->vnic_info[i]; in bnxt_queue_start()
16048 netdev_err(bp->dev, "Unexpected HWRM error during queue start rc: %d\n", in bnxt_queue_start()
16050 napi_enable_locked(&bnapi->napi); in bnxt_queue_start()
16051 bnxt_db_nq_arm(bp, &cpr->cp_db, cpr->cp_raw_cons); in bnxt_queue_start()
16065 for (i = 0; i < bp->nr_vnics; i++) { in bnxt_queue_stop()
16066 vnic = &bp->vnic_info[i]; in bnxt_queue_stop()
16073 rxr = &bp->rx_ring[idx]; in bnxt_queue_stop()
16074 bnapi = rxr->bnapi; in bnxt_queue_stop()
16075 cpr = &bnapi->cp_ring; in bnxt_queue_stop()
16076 cancel_work_sync(&cpr->dim.work); in bnxt_queue_stop()
16079 page_pool_disable_direct_recycling(rxr->page_pool); in bnxt_queue_stop()
16081 page_pool_disable_direct_recycling(rxr->head_pool); in bnxt_queue_stop()
16083 if (bp->flags & BNXT_FLAG_SHARED_RINGS) in bnxt_queue_stop()
16090 napi_disable_locked(&bnapi->napi); in bnxt_queue_stop()
16092 if (bp->tph_mode) { in bnxt_queue_stop()
16093 bnxt_hwrm_cp_ring_free(bp, rxr->rx_cpr); in bnxt_queue_stop()
16094 bnxt_clear_one_cp_ring(bp, rxr->rx_cpr); in bnxt_queue_stop()
16096 bnxt_db_nq(bp, &cpr->cp_db, cpr->cp_raw_cons); in bnxt_queue_stop()
16129 WARN_ON(bp->num_rss_ctx); in bnxt_remove_one()
16130 clear_bit(BNXT_STATE_IN_FW_RESET, &bp->state); in bnxt_remove_one()
16132 cancel_work_sync(&bp->sp_task); in bnxt_remove_one()
16133 cancel_delayed_work_sync(&bp->fw_reset_task); in bnxt_remove_one()
16134 bp->sp_event = 0; in bnxt_remove_one()
16146 kfree(bp->ptp_cfg); in bnxt_remove_one()
16147 bp->ptp_cfg = NULL; in bnxt_remove_one()
16148 kfree(bp->fw_health); in bnxt_remove_one()
16149 bp->fw_health = NULL; in bnxt_remove_one()
16153 kfree(bp->rss_indir_tbl); in bnxt_remove_one()
16154 bp->rss_indir_tbl = NULL; in bnxt_remove_one()
16162 struct bnxt_link_info *link_info = &bp->link_info; in bnxt_probe_phy()
16164 bp->phy_flags = 0; in bnxt_probe_phy()
16167 netdev_err(bp->dev, "Probe phy can't get phy capabilities (rc: %x)\n", in bnxt_probe_phy()
16171 if (bp->phy_flags & BNXT_PHY_FL_NO_FCS) in bnxt_probe_phy()
16172 bp->dev->priv_flags |= IFF_SUPP_NOFCS; in bnxt_probe_phy()
16174 bp->dev->priv_flags &= ~IFF_SUPP_NOFCS; in bnxt_probe_phy()
16176 bp->mac_flags = 0; in bnxt_probe_phy()
16182 mutex_lock(&bp->link_lock); in bnxt_probe_phy()
16185 mutex_unlock(&bp->link_lock); in bnxt_probe_phy()
16186 netdev_err(bp->dev, "Probe phy can't update link (rc: %x)\n", in bnxt_probe_phy()
16194 if (link_info->auto_link_speeds && !link_info->support_auto_speeds) in bnxt_probe_phy()
16195 link_info->support_auto_speeds = link_info->support_speeds; in bnxt_probe_phy()
16198 mutex_unlock(&bp->link_lock); in bnxt_probe_phy()
16206 if (!pdev->msix_cap) in bnxt_get_max_irq()
16207 return 1; in bnxt_get_max_irq()
16209 pci_read_config_word(pdev, pdev->msix_cap + PCI_MSIX_FLAGS, &ctrl); in bnxt_get_max_irq()
16210 return (ctrl & PCI_MSIX_FLAGS_QSIZE) + 1; in bnxt_get_max_irq()
16216 struct bnxt_hw_resc *hw_resc = &bp->hw_resc; in _bnxt_get_max_rings()
16219 *max_tx = hw_resc->max_tx_rings; in _bnxt_get_max_rings()
16220 *max_rx = hw_resc->max_rx_rings; in _bnxt_get_max_rings()
16222 max_irq = min_t(int, bnxt_get_max_func_irqs(bp) - in _bnxt_get_max_rings()
16224 hw_resc->max_stat_ctxs - in _bnxt_get_max_rings()
16226 if (!(bp->flags & BNXT_FLAG_CHIP_P5_PLUS)) in _bnxt_get_max_rings()
16228 max_ring_grps = hw_resc->max_hw_ring_grps; in _bnxt_get_max_rings()
16230 *max_cp -= 1; in _bnxt_get_max_rings()
16231 *max_rx -= 2; in _bnxt_get_max_rings()
16233 if (bp->flags & BNXT_FLAG_AGG_RINGS) in _bnxt_get_max_rings()
16234 *max_rx >>= 1; in _bnxt_get_max_rings()
16235 if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) { in _bnxt_get_max_rings()
16257 return -ENOMEM; in bnxt_get_max_rings()
16268 if (rc && (bp->flags & BNXT_FLAG_AGG_RINGS)) { in bnxt_get_dflt_rings()
16270 bp->flags &= ~BNXT_FLAG_AGG_RINGS; in bnxt_get_dflt_rings()
16274 bp->flags |= BNXT_FLAG_AGG_RINGS; in bnxt_get_dflt_rings()
16277 bp->flags |= BNXT_FLAG_NO_AGG_RINGS; in bnxt_get_dflt_rings()
16278 bp->dev->hw_features &= ~(NETIF_F_LRO | NETIF_F_GRO_HW); in bnxt_get_dflt_rings()
16279 bp->dev->features &= ~(NETIF_F_LRO | NETIF_F_GRO_HW); in bnxt_get_dflt_rings()
16283 if (bp->flags & BNXT_FLAG_ROCE_CAP) { in bnxt_get_dflt_rings()
16295 max_cp -= BNXT_MIN_ROCE_CP_RINGS; in bnxt_get_dflt_rings()
16296 max_irq -= BNXT_MIN_ROCE_CP_RINGS; in bnxt_get_dflt_rings()
16297 max_stat -= BNXT_MIN_ROCE_STAT_CTXS; in bnxt_get_dflt_rings()
16312 bp->cp_nr_rings = min_t(int, bp->tx_nr_rings_per_tc, bp->rx_nr_rings); in bnxt_trim_dflt_sh_rings()
16313 bp->rx_nr_rings = bp->cp_nr_rings; in bnxt_trim_dflt_sh_rings()
16314 bp->tx_nr_rings_per_tc = bp->cp_nr_rings; in bnxt_trim_dflt_sh_rings()
16315 bp->tx_nr_rings = bp->tx_nr_rings_per_tc; in bnxt_trim_dflt_sh_rings()
16327 bp->flags |= BNXT_FLAG_SHARED_RINGS; in bnxt_set_dflt_rings()
16328 dflt_rings = is_kdump_kernel() ? 1 : netif_get_num_default_rss_queues(); in bnxt_set_dflt_rings()
16329 /* Reduce default rings on multi-port cards so that total default in bnxt_set_dflt_rings()
16332 if (bp->port_count > 1) { in bnxt_set_dflt_rings()
16334 max_t(int, num_online_cpus() / bp->port_count, 1); in bnxt_set_dflt_rings()
16341 bp->rx_nr_rings = min_t(int, dflt_rings, max_rx_rings); in bnxt_set_dflt_rings()
16342 bp->tx_nr_rings_per_tc = min_t(int, dflt_rings, max_tx_rings); in bnxt_set_dflt_rings()
16346 bp->cp_nr_rings = bp->tx_nr_rings_per_tc + bp->rx_nr_rings; in bnxt_set_dflt_rings()
16347 bp->tx_nr_rings = bp->tx_nr_rings_per_tc; in bnxt_set_dflt_rings()
16349 avail_msix = bnxt_get_max_func_irqs(bp) - bp->cp_nr_rings; in bnxt_set_dflt_rings()
16351 int ulp_num_msix = min(avail_msix, bp->ulp_num_msix_want); in bnxt_set_dflt_rings()
16358 if (rc && rc != -ENODEV) in bnxt_set_dflt_rings()
16359 netdev_warn(bp->dev, "Unable to reserve tx rings\n"); in bnxt_set_dflt_rings()
16360 bp->tx_nr_rings_per_tc = bp->tx_nr_rings; in bnxt_set_dflt_rings()
16364 /* Rings may have been trimmed, re-reserve the trimmed rings. */ in bnxt_set_dflt_rings()
16367 if (rc && rc != -ENODEV) in bnxt_set_dflt_rings()
16368 netdev_warn(bp->dev, "2nd rings reservation failed.\n"); in bnxt_set_dflt_rings()
16369 bp->tx_nr_rings_per_tc = bp->tx_nr_rings; in bnxt_set_dflt_rings()
16372 bp->rx_nr_rings++; in bnxt_set_dflt_rings()
16373 bp->cp_nr_rings++; in bnxt_set_dflt_rings()
16376 bp->tx_nr_rings = 0; in bnxt_set_dflt_rings()
16377 bp->rx_nr_rings = 0; in bnxt_set_dflt_rings()
16386 if (bp->tx_nr_rings) in bnxt_init_dflt_ring_mode()
16393 if (BNXT_VF(bp) && rc == -ENODEV) in bnxt_init_dflt_ring_mode()
16394 netdev_err(bp->dev, "Cannot configure VF rings while PF is unavailable.\n"); in bnxt_init_dflt_ring_mode()
16396 netdev_err(bp->dev, "Not enough rings available.\n"); in bnxt_init_dflt_ring_mode()
16403 bp->tx_nr_rings_per_tc = bp->tx_nr_rings; in bnxt_init_dflt_ring_mode()
16416 netdev_ops_assert_locked(bp->dev); in bnxt_restore_pf_fw_resources()
16419 if (netif_running(bp->dev)) in bnxt_restore_pf_fw_resources()
16427 if (netif_running(bp->dev)) { in bnxt_restore_pf_fw_resources()
16429 netif_close(bp->dev); in bnxt_restore_pf_fw_resources()
16442 eth_hw_addr_set(bp->dev, bp->pf.mac_addr); in bnxt_init_mac_addr()
16445 struct bnxt_vf_info *vf = &bp->vf; in bnxt_init_mac_addr()
16448 if (is_valid_ether_addr(vf->mac_addr)) { in bnxt_init_mac_addr()
16450 eth_hw_addr_set(bp->dev, vf->mac_addr); in bnxt_init_mac_addr()
16456 eth_hw_addr_random(bp->dev); in bnxt_init_mac_addr()
16458 rc = bnxt_approve_mac(bp, bp->dev->dev_addr, strict_approval); in bnxt_init_mac_addr()
16466 struct pci_dev *pdev = bp->pdev; in bnxt_vpd_read_info()
16482 size = min_t(int, kw_len, BNXT_VPD_FLD_LEN - 1); in bnxt_vpd_read_info()
16483 memcpy(bp->board_partno, &vpd_data[pos], size); in bnxt_vpd_read_info()
16492 size = min_t(int, kw_len, BNXT_VPD_FLD_LEN - 1); in bnxt_vpd_read_info()
16493 memcpy(bp->board_serialno, &vpd_data[pos], size); in bnxt_vpd_read_info()
16500 struct pci_dev *pdev = bp->pdev; in bnxt_pcie_dsn_get()
16505 netdev_info(bp->dev, "Unable to read adapter's DSN\n"); in bnxt_pcie_dsn_get()
16506 return -EOPNOTSUPP; in bnxt_pcie_dsn_get()
16511 bp->flags |= BNXT_FLAG_DSN_VALID; in bnxt_pcie_dsn_get()
16517 if (!bp->db_size) in bnxt_map_db_bar()
16518 return -ENODEV; in bnxt_map_db_bar()
16519 bp->bar1 = pci_iomap(bp->pdev, 2, bp->db_size); in bnxt_map_db_bar()
16520 if (!bp->bar1) in bnxt_map_db_bar()
16521 return -ENOMEM; in bnxt_map_db_bar()
16527 netdev_info(bp->dev, "%s found at mem %lx, node addr %pM\n", in bnxt_print_device_info()
16528 board_info[bp->board_idx].name, in bnxt_print_device_info()
16529 (long)pci_resource_start(bp->pdev, 0), bp->dev->dev_addr); in bnxt_print_device_info()
16531 pcie_print_link_status(bp->pdev); in bnxt_print_device_info()
16542 return -ENODEV; in bnxt_init_one()
16544 if (!pdev->msix_cap) { in bnxt_init_one()
16545 dev_err(&pdev->dev, "MSIX capability not found, aborting\n"); in bnxt_init_one()
16546 return -ENODEV; in bnxt_init_one()
16561 return -ENOMEM; in bnxt_init_one()
16564 bp->board_idx = ent->driver_data; in bnxt_init_one()
16565 bp->msg_enable = BNXT_DEF_MSG_ENABLE; in bnxt_init_one()
16568 if (bnxt_vf_pciid(bp->board_idx)) in bnxt_init_one()
16569 bp->flags |= BNXT_FLAG_VF; in bnxt_init_one()
16573 SET_NETDEV_DEVLINK_PORT(dev, &bp->dl_port); in bnxt_init_one()
16579 dev->netdev_ops = &bnxt_netdev_ops; in bnxt_init_one()
16580 dev->stat_ops = &bnxt_stat_ops; in bnxt_init_one()
16581 dev->watchdog_timeo = BNXT_TX_TIMEOUT; in bnxt_init_one()
16582 dev->ethtool_ops = &bnxt_ethtool_ops; in bnxt_init_one()
16589 mutex_init(&bp->hwrm_cmd_lock); in bnxt_init_one()
16590 mutex_init(&bp->link_lock); in bnxt_init_one()
16600 bp->flags |= BNXT_FLAG_CHIP_P5_PLUS; in bnxt_init_one()
16602 bp->flags |= BNXT_FLAG_CHIP_P7; in bnxt_init_one()
16615 dev_err(&pdev->dev, "Cannot map doorbell BAR rc = %d, aborting\n", in bnxt_init_one()
16620 dev->hw_features = NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM | NETIF_F_SG | in bnxt_init_one()
16627 if (bp->flags & BNXT_FLAG_UDP_GSO_CAP) in bnxt_init_one()
16628 dev->hw_features |= NETIF_F_GSO_UDP_L4; in bnxt_init_one()
16631 dev->hw_features |= NETIF_F_LRO; in bnxt_init_one()
16633 dev->hw_enc_features = in bnxt_init_one()
16639 if (bp->flags & BNXT_FLAG_UDP_GSO_CAP) in bnxt_init_one()
16640 dev->hw_enc_features |= NETIF_F_GSO_UDP_L4; in bnxt_init_one()
16641 if (bp->flags & BNXT_FLAG_CHIP_P7) in bnxt_init_one()
16642 dev->udp_tunnel_nic_info = &bnxt_udp_tunnels_p7; in bnxt_init_one()
16644 dev->udp_tunnel_nic_info = &bnxt_udp_tunnels; in bnxt_init_one()
16646 dev->gso_partial_features = NETIF_F_GSO_UDP_TUNNEL_CSUM | in bnxt_init_one()
16648 dev->vlan_features = dev->hw_features | NETIF_F_HIGHDMA; in bnxt_init_one()
16649 if (bp->fw_cap & BNXT_FW_CAP_VLAN_RX_STRIP) in bnxt_init_one()
16650 dev->hw_features |= BNXT_HW_FEATURE_VLAN_ALL_RX; in bnxt_init_one()
16651 if (bp->fw_cap & BNXT_FW_CAP_VLAN_TX_INSERT) in bnxt_init_one()
16652 dev->hw_features |= BNXT_HW_FEATURE_VLAN_ALL_TX; in bnxt_init_one()
16654 dev->hw_features |= NETIF_F_GRO_HW; in bnxt_init_one()
16655 dev->features |= dev->hw_features | NETIF_F_HIGHDMA; in bnxt_init_one()
16656 if (dev->features & NETIF_F_GRO_HW) in bnxt_init_one()
16657 dev->features &= ~NETIF_F_LRO; in bnxt_init_one()
16658 dev->priv_flags |= IFF_UNICAST_FLT; in bnxt_init_one()
16661 if (bp->tso_max_segs) in bnxt_init_one()
16662 netif_set_tso_max_segs(dev, bp->tso_max_segs); in bnxt_init_one()
16664 dev->xdp_features = NETDEV_XDP_ACT_BASIC | NETDEV_XDP_ACT_REDIRECT | in bnxt_init_one()
16668 init_waitqueue_head(&bp->sriov_cfg_wait); in bnxt_init_one()
16671 bp->gro_func = bnxt_gro_func_5730x; in bnxt_init_one()
16673 bp->gro_func = bnxt_gro_func_5731x; in bnxt_init_one()
16675 bp->gro_func = bnxt_gro_func_5750x; in bnxt_init_one()
16678 bp->flags |= BNXT_FLAG_DOUBLE_DB; in bnxt_init_one()
16682 dev_err(&pdev->dev, "Unable to initialize mac address.\n"); in bnxt_init_one()
16683 rc = -EADDRNOTAVAIL; in bnxt_init_one()
16689 rc = bnxt_pcie_dsn_get(bp, bp->dsn); in bnxt_init_one()
16692 /* MTU range: 60 - FW defined max */ in bnxt_init_one()
16693 dev->min_mtu = ETH_ZLEN; in bnxt_init_one()
16694 dev->max_mtu = bp->max_mtu; in bnxt_init_one()
16700 hw_resc = &bp->hw_resc; in bnxt_init_one()
16701 bp->max_fltr = hw_resc->max_rx_em_flows + hw_resc->max_rx_wm_flows + in bnxt_init_one()
16704 if (bp->max_fltr < BNXT_MAX_FLTR) in bnxt_init_one()
16705 bp->max_fltr = BNXT_MAX_FLTR; in bnxt_init_one()
16714 if (BNXT_VF(bp) && rc == -ENODEV) { in bnxt_init_one()
16715 netdev_err(bp->dev, "Cannot configure VF rings while PF is unavailable.\n"); in bnxt_init_one()
16717 netdev_err(bp->dev, "Not enough rings available.\n"); in bnxt_init_one()
16718 rc = -ENOMEM; in bnxt_init_one()
16727 if (dev->hw_features & BNXT_HW_FEATURE_VLAN_ALL_RX) in bnxt_init_one()
16728 bp->flags |= BNXT_FLAG_STRIP_VLAN; in bnxt_init_one()
16735 * limited MSIX, so we re-initialize the TX rings per TC. in bnxt_init_one()
16737 bp->tx_nr_rings_per_tc = bp->tx_nr_rings; in bnxt_init_one()
16744 dev_err(&pdev->dev, "Unable to create workqueue.\n"); in bnxt_init_one()
16745 rc = -ENOMEM; in bnxt_init_one()
16760 INIT_LIST_HEAD(&bp->usr_fltr_list); in bnxt_init_one()
16763 bp->rss_cap |= BNXT_RSS_CAP_MULTI_RSS_CTX; in bnxt_init_one()
16765 dev->queue_mgmt_ops = &bnxt_queue_mgmt_ops; in bnxt_init_one()
16766 dev->request_ops_lock = true; in bnxt_init_one()
16767 dev->netmem_tx = true; in bnxt_init_one()
16795 kfree(bp->ptp_cfg); in bnxt_init_one()
16796 bp->ptp_cfg = NULL; in bnxt_init_one()
16797 kfree(bp->fw_health); in bnxt_init_one()
16798 bp->fw_health = NULL; in bnxt_init_one()
16802 kfree(bp->rss_indir_tbl); in bnxt_init_one()
16803 bp->rss_indir_tbl = NULL; in bnxt_init_one()
16832 pci_wake_from_d3(pdev, bp->wol); in bnxt_shutdown()
16857 pci_disable_device(bp->pdev); in bnxt_suspend()
16870 rc = pci_enable_device(bp->pdev); in bnxt_resume()
16872 netdev_err(dev, "Cannot re-enable PCI device during resume, err = %d\n", in bnxt_resume()
16876 pci_set_master(bp->pdev); in bnxt_resume()
16878 rc = -ENODEV; in bnxt_resume()
16883 rc = -EBUSY; in bnxt_resume()
16894 rc = -ENODEV; in bnxt_resume()
16897 if (bp->fw_crash_mem) in bnxt_resume()
16901 kfree(bp->ptp_cfg); in bnxt_resume()
16902 bp->ptp_cfg = NULL; in bnxt_resume()
16912 netdev_unlock(bp->dev); in bnxt_resume()
16929 * bnxt_io_error_detected - called when PCI error is detected
16950 if (test_and_set_bit(BNXT_STATE_IN_FW_RESET, &bp->state)) { in bnxt_io_error_detected()
16951 netdev_err(bp->dev, "Firmware reset already in progress\n"); in bnxt_io_error_detected()
16965 set_bit(BNXT_STATE_PCI_CHANNEL_IO_FROZEN, &bp->state); in bnxt_io_error_detected()
16982 * bnxt_io_slot_reset - called after the pci bus has been reset.
16985 * Restart the card from scratch, as if from a cold-boot.
16999 netdev_info(bp->dev, "PCI Slot Reset\n"); in bnxt_io_slot_reset()
17001 if (!(bp->flags & BNXT_FLAG_CHIP_P5_PLUS) && in bnxt_io_slot_reset()
17002 test_bit(BNXT_STATE_PCI_CHANNEL_IO_FROZEN, &bp->state)) in bnxt_io_slot_reset()
17008 dev_err(&pdev->dev, in bnxt_io_slot_reset()
17009 "Cannot re-enable PCI device after reset.\n"); in bnxt_io_slot_reset()
17016 * As pci_restore_state() does not re-write the BARs if the in bnxt_io_slot_reset()
17021 &bp->state)) { in bnxt_io_slot_reset()
17024 pci_write_config_dword(bp->pdev, off, 0); in bnxt_io_slot_reset()
17043 dev_err(&pdev->dev, "Firmware not ready\n"); in bnxt_io_slot_reset()
17057 clear_bit(BNXT_STATE_IN_FW_RESET, &bp->state); in bnxt_io_slot_reset()
17065 * bnxt_io_resume - called when traffic can start flowing again.
17077 netdev_info(bp->dev, "PCI Slot Resume\n"); in bnxt_io_resume()