Lines Matching +full:ns2 +full:- +full:pcie +full:- +full:phy
1 /* Broadcom NetXtreme-C/E network driver.
3 * Copyright (c) 2014-2016 Broadcom Corporation
4 * Copyright (c) 2016-2019 Broadcom Limited
25 #include <linux/dma-mapping.h>
91 [BCM57301] = { "Broadcom BCM57301 NetXtreme-C 10Gb Ethernet" },
92 [BCM57302] = { "Broadcom BCM57302 NetXtreme-C 10Gb/25Gb Ethernet" },
93 [BCM57304] = { "Broadcom BCM57304 NetXtreme-C 10Gb/25Gb/40Gb/50Gb Ethernet" },
94 [BCM57417_NPAR] = { "Broadcom BCM57417 NetXtreme-E Ethernet Partition" },
96 [BCM57311] = { "Broadcom BCM57311 NetXtreme-C 10Gb Ethernet" },
97 [BCM57312] = { "Broadcom BCM57312 NetXtreme-C 10Gb/25Gb Ethernet" },
98 [BCM57402] = { "Broadcom BCM57402 NetXtreme-E 10Gb Ethernet" },
99 [BCM57404] = { "Broadcom BCM57404 NetXtreme-E 10Gb/25Gb Ethernet" },
100 [BCM57406] = { "Broadcom BCM57406 NetXtreme-E 10GBase-T Ethernet" },
101 [BCM57402_NPAR] = { "Broadcom BCM57402 NetXtreme-E Ethernet Partition" },
102 [BCM57407] = { "Broadcom BCM57407 NetXtreme-E 10GBase-T Ethernet" },
103 [BCM57412] = { "Broadcom BCM57412 NetXtreme-E 10Gb Ethernet" },
104 [BCM57414] = { "Broadcom BCM57414 NetXtreme-E 10Gb/25Gb Ethernet" },
105 [BCM57416] = { "Broadcom BCM57416 NetXtreme-E 10GBase-T Ethernet" },
106 [BCM57417] = { "Broadcom BCM57417 NetXtreme-E 10GBase-T Ethernet" },
107 [BCM57412_NPAR] = { "Broadcom BCM57412 NetXtreme-E Ethernet Partition" },
108 [BCM57314] = { "Broadcom BCM57314 NetXtreme-C 10Gb/25Gb/40Gb/50Gb Ethernet" },
109 [BCM57417_SFP] = { "Broadcom BCM57417 NetXtreme-E 10Gb/25Gb Ethernet" },
110 [BCM57416_SFP] = { "Broadcom BCM57416 NetXtreme-E 10Gb Ethernet" },
111 [BCM57404_NPAR] = { "Broadcom BCM57404 NetXtreme-E Ethernet Partition" },
112 [BCM57406_NPAR] = { "Broadcom BCM57406 NetXtreme-E Ethernet Partition" },
113 [BCM57407_SFP] = { "Broadcom BCM57407 NetXtreme-E 25Gb Ethernet" },
114 [BCM57407_NPAR] = { "Broadcom BCM57407 NetXtreme-E Ethernet Partition" },
115 [BCM57414_NPAR] = { "Broadcom BCM57414 NetXtreme-E Ethernet Partition" },
116 [BCM57416_NPAR] = { "Broadcom BCM57416 NetXtreme-E Ethernet Partition" },
117 [BCM57452] = { "Broadcom BCM57452 NetXtreme-E 10Gb/25Gb/40Gb/50Gb Ethernet" },
118 [BCM57454] = { "Broadcom BCM57454 NetXtreme-E 10Gb/25Gb/40Gb/50Gb/100Gb Ethernet" },
119 [BCM5745x_NPAR] = { "Broadcom BCM5745x NetXtreme-E Ethernet Partition" },
120 [BCM57508] = { "Broadcom BCM57508 NetXtreme-E 10Gb/25Gb/50Gb/100Gb/200Gb Ethernet" },
121 [BCM57504] = { "Broadcom BCM57504 NetXtreme-E 10Gb/25Gb/50Gb/100Gb/200Gb Ethernet" },
122 [BCM57502] = { "Broadcom BCM57502 NetXtreme-E 10Gb/25Gb/50Gb Ethernet" },
123 [BCM57608] = { "Broadcom BCM57608 NetXtreme-E 10Gb/25Gb/50Gb/100Gb/200Gb/400Gb Ethernet" },
124 [BCM57604] = { "Broadcom BCM57604 NetXtreme-E 10Gb/25Gb/50Gb/100Gb/200Gb Ethernet" },
125 [BCM57602] = { "Broadcom BCM57602 NetXtreme-E 10Gb/25Gb/50Gb/100Gb Ethernet" },
126 [BCM57601] = { "Broadcom BCM57601 NetXtreme-E 10Gb/25Gb/50Gb/100Gb/200Gb/400Gb Ethernet" },
127 [BCM57508_NPAR] = { "Broadcom BCM57508 NetXtreme-E Ethernet Partition" },
128 [BCM57504_NPAR] = { "Broadcom BCM57504 NetXtreme-E Ethernet Partition" },
129 [BCM57502_NPAR] = { "Broadcom BCM57502 NetXtreme-E Ethernet Partition" },
130 [BCM58802] = { "Broadcom BCM58802 NetXtreme-S 10Gb/25Gb/40Gb/50Gb Ethernet" },
131 [BCM58804] = { "Broadcom BCM58804 NetXtreme-S 10Gb/25Gb/40Gb/50Gb/100Gb Ethernet" },
132 [BCM58808] = { "Broadcom BCM58808 NetXtreme-S 10Gb/25Gb/40Gb/50Gb/100Gb Ethernet" },
133 [NETXTREME_E_VF] = { "Broadcom NetXtreme-E Ethernet Virtual Function" },
134 [NETXTREME_C_VF] = { "Broadcom NetXtreme-C Ethernet Virtual Function" },
135 [NETXTREME_S_VF] = { "Broadcom NetXtreme-S Ethernet Virtual Function" },
136 [NETXTREME_C_VF_HV] = { "Broadcom NetXtreme-C Virtual Function for Hyper-V" },
137 [NETXTREME_E_VF_HV] = { "Broadcom NetXtreme-E Virtual Function for Hyper-V" },
138 [NETXTREME_E_P5_VF] = { "Broadcom BCM5750X NetXtreme-E Ethernet Virtual Function" },
139 [NETXTREME_E_P5_VF_HV] = { "Broadcom BCM5750X NetXtreme-E Virtual Function for Hyper-V" },
321 writel(DB_CP_FLAGS | DB_RING_IDX(db, idx), (db)->doorbell)
324 bnxt_writeq(bp, (db)->db_key64 | DBR_TYPE_NQ | DB_RING_IDX(db, idx),\
325 (db)->doorbell)
328 bnxt_writeq(bp, (db)->db_key64 | DBR_TYPE_NQ_MASK | \
329 DB_RING_IDX(db, idx), (db)->doorbell)
332 writel(DB_CP_REARM_FLAGS | DB_RING_IDX(db, idx), (db)->doorbell)
335 bnxt_writeq(bp, (db)->db_key64 | DBR_TYPE_NQ_ARM | \
336 DB_RING_IDX(db, idx), (db)->doorbell)
340 if (bp->flags & BNXT_FLAG_CHIP_P7) in bnxt_db_nq()
342 else if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) in bnxt_db_nq()
350 if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) in bnxt_db_nq_arm()
358 if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) in bnxt_db_cq()
359 bnxt_writeq(bp, db->db_key64 | DBR_TYPE_CQ_ARMALL | in bnxt_db_cq()
360 DB_RING_IDX(db, idx), db->doorbell); in bnxt_db_cq()
367 if (!(test_bit(BNXT_STATE_IN_FW_RESET, &bp->state))) in bnxt_queue_fw_reset_work()
371 queue_delayed_work(bnxt_pf_wq, &bp->fw_reset_task, delay); in bnxt_queue_fw_reset_work()
373 schedule_delayed_work(&bp->fw_reset_task, delay); in bnxt_queue_fw_reset_work()
379 queue_work(bnxt_pf_wq, &bp->sp_task); in __bnxt_queue_sp_work()
381 schedule_work(&bp->sp_task); in __bnxt_queue_sp_work()
386 set_bit(event, &bp->sp_event); in bnxt_queue_sp_work()
392 if (!rxr->bnapi->in_reset) { in bnxt_sched_reset_rxr()
393 rxr->bnapi->in_reset = true; in bnxt_sched_reset_rxr()
394 if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) in bnxt_sched_reset_rxr()
395 set_bit(BNXT_RESET_TASK_SP_EVENT, &bp->sp_event); in bnxt_sched_reset_rxr()
397 set_bit(BNXT_RST_RING_SP_EVENT, &bp->sp_event); in bnxt_sched_reset_rxr()
400 rxr->rx_next_cons = 0xffff; in bnxt_sched_reset_rxr()
406 struct bnxt_napi *bnapi = txr->bnapi; in bnxt_sched_reset_txr()
408 if (bnapi->tx_fault) in bnxt_sched_reset_txr()
411 netdev_err(bp->dev, "Invalid Tx completion (ring:%d tx_hw_cons:%u cons:%u prod:%u curr:%u)", in bnxt_sched_reset_txr()
412 txr->txq_index, txr->tx_hw_cons, in bnxt_sched_reset_txr()
413 txr->tx_cons, txr->tx_prod, curr); in bnxt_sched_reset_txr()
415 bnapi->tx_fault = 1; in bnxt_sched_reset_txr()
445 if (!md_dst || md_dst->type != METADATA_HW_PORT_MUX) in bnxt_xmit_get_cfa_action()
448 return md_dst->u.port_info.port_id; in bnxt_xmit_get_cfa_action()
456 bnxt_db_write(bp, &txr->tx_db, prod); in bnxt_txr_db_kick()
457 txr->kick_pending = 0; in bnxt_txr_db_kick()
470 struct bnxt_ptp_cfg *ptp = bp->ptp_cfg; in bnxt_start_xmit()
471 struct pci_dev *pdev = bp->pdev; in bnxt_start_xmit()
478 if (unlikely(i >= bp->tx_nr_rings)) { in bnxt_start_xmit()
485 txr = &bp->tx_ring[bp->tx_ring_map[i]]; in bnxt_start_xmit()
486 prod = txr->tx_prod; in bnxt_start_xmit()
489 if (skb_shinfo(skb)->nr_frags > TX_MAX_FRAGS) { in bnxt_start_xmit()
491 skb_shinfo(skb)->nr_frags, TX_MAX_FRAGS); in bnxt_start_xmit()
500 if (unlikely(free_size < skb_shinfo(skb)->nr_frags + 2)) { in bnxt_start_xmit()
502 if (net_ratelimit() && txr->kick_pending) in bnxt_start_xmit()
506 bp->tx_wake_thresh)) in bnxt_start_xmit()
513 length = skb->len; in bnxt_start_xmit()
515 last_frag = skb_shinfo(skb)->nr_frags; in bnxt_start_xmit()
517 txbd = &txr->tx_desc_ring[TX_RING(bp, prod)][TX_IDX(prod)]; in bnxt_start_xmit()
519 tx_buf = &txr->tx_buf_ring[RING_TX(bp, prod)]; in bnxt_start_xmit()
520 tx_buf->skb = skb; in bnxt_start_xmit()
521 tx_buf->nr_frags = last_frag; in bnxt_start_xmit()
531 if (skb->vlan_proto == htons(ETH_P_8021Q)) in bnxt_start_xmit()
535 if (unlikely(skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP) && ptp && in bnxt_start_xmit()
536 ptp->tx_tstamp_en) { in bnxt_start_xmit()
537 if (bp->fw_cap & BNXT_FW_CAP_TX_TS_CMP) { in bnxt_start_xmit()
539 tx_buf->is_ts_pkt = 1; in bnxt_start_xmit()
540 skb_shinfo(skb)->tx_flags |= SKBTX_IN_PROGRESS; in bnxt_start_xmit()
549 tx_buf->is_ts_pkt = 1; in bnxt_start_xmit()
550 skb_shinfo(skb)->tx_flags |= SKBTX_IN_PROGRESS; in bnxt_start_xmit()
552 ptp->txts_req[txts_prod].tx_seqid = seq_id; in bnxt_start_xmit()
553 ptp->txts_req[txts_prod].tx_hdr_off = hdr_off; in bnxt_start_xmit()
554 tx_buf->txts_prod = txts_prod; in bnxt_start_xmit()
558 if (unlikely(skb->no_fcs)) in bnxt_start_xmit()
561 if (free_size == bp->tx_ring_size && length <= bp->tx_push_thresh && in bnxt_start_xmit()
563 struct tx_push_buffer *tx_push_buf = txr->tx_push; in bnxt_start_xmit()
564 struct tx_push_bd *tx_push = &tx_push_buf->push_bd; in bnxt_start_xmit()
565 struct tx_bd_ext *tx_push1 = &tx_push->txbd2; in bnxt_start_xmit()
566 void __iomem *db = txr->tx_db.doorbell; in bnxt_start_xmit()
567 void *pdata = tx_push_buf->data; in bnxt_start_xmit()
572 tx_push->tx_bd_len_flags_type = in bnxt_start_xmit()
580 if (skb->ip_summed == CHECKSUM_PARTIAL) in bnxt_start_xmit()
581 tx_push1->tx_bd_hsize_lflags = in bnxt_start_xmit()
584 tx_push1->tx_bd_hsize_lflags = 0; in bnxt_start_xmit()
586 tx_push1->tx_bd_cfa_meta = cpu_to_le32(vlan_tag_flags); in bnxt_start_xmit()
587 tx_push1->tx_bd_cfa_action = in bnxt_start_xmit()
591 end = PTR_ALIGN(end, 8) - 1; in bnxt_start_xmit()
597 skb_frag_t *frag = &skb_shinfo(skb)->frags[j]; in bnxt_start_xmit()
608 txbd->tx_bd_len_flags_type = tx_push->tx_bd_len_flags_type; in bnxt_start_xmit()
609 txbd->tx_bd_haddr = txr->data_mapping; in bnxt_start_xmit()
610 txbd->tx_bd_opaque = SET_TX_OPAQUE(bp, txr, prod, 2); in bnxt_start_xmit()
612 tx_push->tx_bd_opaque = txbd->tx_bd_opaque; in bnxt_start_xmit()
613 txbd = &txr->tx_desc_ring[TX_RING(bp, prod)][TX_IDX(prod)]; in bnxt_start_xmit()
616 tx_push->doorbell = in bnxt_start_xmit()
618 DB_RING_IDX(&txr->tx_db, prod)); in bnxt_start_xmit()
619 WRITE_ONCE(txr->tx_prod, prod); in bnxt_start_xmit()
621 tx_buf->is_push = 1; in bnxt_start_xmit()
622 netdev_tx_sent_queue(txq, skb->len); in bnxt_start_xmit()
629 (push_len - 16) << 1); in bnxt_start_xmit()
639 pad = BNXT_MIN_PKT_SIZE - length; in bnxt_start_xmit()
646 mapping = dma_map_single(&pdev->dev, skb->data, len, DMA_TO_DEVICE); in bnxt_start_xmit()
648 if (unlikely(dma_mapping_error(&pdev->dev, mapping))) in bnxt_start_xmit()
655 txbd->tx_bd_haddr = cpu_to_le64(mapping); in bnxt_start_xmit()
656 txbd->tx_bd_opaque = SET_TX_OPAQUE(bp, txr, prod, 2 + last_frag); in bnxt_start_xmit()
660 &txr->tx_desc_ring[TX_RING(bp, prod)][TX_IDX(prod)]; in bnxt_start_xmit()
662 txbd1->tx_bd_hsize_lflags = lflags; in bnxt_start_xmit()
664 bool udp_gso = !!(skb_shinfo(skb)->gso_type & SKB_GSO_UDP_L4); in bnxt_start_xmit()
667 if (skb->encapsulation) { in bnxt_start_xmit()
680 txbd1->tx_bd_hsize_lflags |= cpu_to_le32(TX_BD_FLAGS_LSO | in bnxt_start_xmit()
682 (hdr_len << (TX_BD_HSIZE_SHIFT - 1))); in bnxt_start_xmit()
683 length = skb_shinfo(skb)->gso_size; in bnxt_start_xmit()
684 txbd1->tx_bd_mss = cpu_to_le32(length); in bnxt_start_xmit()
686 } else if (skb->ip_summed == CHECKSUM_PARTIAL) { in bnxt_start_xmit()
687 txbd1->tx_bd_hsize_lflags |= in bnxt_start_xmit()
689 txbd1->tx_bd_mss = 0; in bnxt_start_xmit()
694 dev_warn_ratelimited(&pdev->dev, "Dropped oversize %d bytes TX packet.\n", in bnxt_start_xmit()
695 skb->len); in bnxt_start_xmit()
700 txbd->tx_bd_len_flags_type = cpu_to_le32(flags); in bnxt_start_xmit()
702 txbd1->tx_bd_cfa_meta = cpu_to_le32(vlan_tag_flags); in bnxt_start_xmit()
703 txbd1->tx_bd_cfa_action = in bnxt_start_xmit()
707 skb_frag_t *frag = &skb_shinfo(skb)->frags[i]; in bnxt_start_xmit()
710 txbd = &txr->tx_desc_ring[TX_RING(bp, prod)][TX_IDX(prod)]; in bnxt_start_xmit()
713 mapping = skb_frag_dma_map(&pdev->dev, frag, 0, len, in bnxt_start_xmit()
716 if (unlikely(dma_mapping_error(&pdev->dev, mapping))) in bnxt_start_xmit()
719 tx_buf = &txr->tx_buf_ring[RING_TX(bp, prod)]; in bnxt_start_xmit()
722 txbd->tx_bd_haddr = cpu_to_le64(mapping); in bnxt_start_xmit()
725 txbd->tx_bd_len_flags_type = cpu_to_le32(flags); in bnxt_start_xmit()
729 txbd->tx_bd_len_flags_type = in bnxt_start_xmit()
733 netdev_tx_sent_queue(txq, skb->len); in bnxt_start_xmit()
738 WRITE_ONCE(txr->tx_prod, prod); in bnxt_start_xmit()
743 if (free_size >= bp->tx_wake_thresh) in bnxt_start_xmit()
744 txbd0->tx_bd_len_flags_type |= in bnxt_start_xmit()
746 txr->kick_pending = 1; in bnxt_start_xmit()
752 if (netdev_xmit_more() && !tx_buf->is_push) { in bnxt_start_xmit()
753 txbd0->tx_bd_len_flags_type &= in bnxt_start_xmit()
759 bp->tx_wake_thresh); in bnxt_start_xmit()
767 prod = txr->tx_prod; in bnxt_start_xmit()
768 tx_buf = &txr->tx_buf_ring[RING_TX(bp, prod)]; in bnxt_start_xmit()
769 dma_unmap_single(&pdev->dev, dma_unmap_addr(tx_buf, mapping), in bnxt_start_xmit()
776 tx_buf = &txr->tx_buf_ring[RING_TX(bp, prod)]; in bnxt_start_xmit()
777 dma_unmap_page(&pdev->dev, dma_unmap_addr(tx_buf, mapping), in bnxt_start_xmit()
778 skb_frag_size(&skb_shinfo(skb)->frags[i]), in bnxt_start_xmit()
786 txr->tx_buf_ring[RING_TX(bp, txr->tx_prod)].is_ts_pkt = 0; in bnxt_start_xmit()
787 atomic64_inc(&bp->ptp_cfg->stats.ts_err); in bnxt_start_xmit()
788 if (!(bp->fw_cap & BNXT_FW_CAP_TX_TS_CMP)) in bnxt_start_xmit()
790 ptp->txts_req[txts_prod].tx_skb = ERR_PTR(-EIO); in bnxt_start_xmit()
792 if (txr->kick_pending) in bnxt_start_xmit()
793 bnxt_txr_db_kick(bp, txr, txr->tx_prod); in bnxt_start_xmit()
794 txr->tx_buf_ring[RING_TX(bp, txr->tx_prod)].skb = NULL; in bnxt_start_xmit()
803 struct netdev_queue *txq = netdev_get_tx_queue(bp->dev, txr->txq_index); in __bnxt_tx_int()
804 struct pci_dev *pdev = bp->pdev; in __bnxt_tx_int()
805 u16 hw_cons = txr->tx_hw_cons; in __bnxt_tx_int()
807 u16 cons = txr->tx_cons; in __bnxt_tx_int()
817 tx_buf = &txr->tx_buf_ring[RING_TX(bp, cons)]; in __bnxt_tx_int()
818 skb = tx_buf->skb; in __bnxt_tx_int()
825 is_ts_pkt = tx_buf->is_ts_pkt; in __bnxt_tx_int()
826 if (is_ts_pkt && (bp->fw_cap & BNXT_FW_CAP_TX_TS_CMP)) { in __bnxt_tx_int()
833 tx_bytes += skb->len; in __bnxt_tx_int()
834 tx_buf->skb = NULL; in __bnxt_tx_int()
835 tx_buf->is_ts_pkt = 0; in __bnxt_tx_int()
837 if (tx_buf->is_push) { in __bnxt_tx_int()
838 tx_buf->is_push = 0; in __bnxt_tx_int()
842 dma_unmap_single(&pdev->dev, dma_unmap_addr(tx_buf, mapping), in __bnxt_tx_int()
844 last = tx_buf->nr_frags; in __bnxt_tx_int()
848 tx_buf = &txr->tx_buf_ring[RING_TX(bp, cons)]; in __bnxt_tx_int()
850 &pdev->dev, in __bnxt_tx_int()
852 skb_frag_size(&skb_shinfo(skb)->frags[j]), in __bnxt_tx_int()
858 bnxt_get_tx_ts_p5(bp, skb, tx_buf->txts_prod); in __bnxt_tx_int()
869 WRITE_ONCE(txr->tx_cons, cons); in __bnxt_tx_int()
872 bnxt_tx_avail(bp, txr), bp->tx_wake_thresh, in __bnxt_tx_int()
873 READ_ONCE(txr->dev_state) == BNXT_DEV_STATE_CLOSING); in __bnxt_tx_int()
885 if (txr->tx_hw_cons != RING_TX(bp, txr->tx_cons)) in bnxt_tx_int()
889 bnapi->events &= ~BNXT_TX_CMP_EVENT; in bnxt_tx_int()
905 page = page_pool_dev_alloc_frag(rxr->page_pool, offset, in __bnxt_alloc_rx_page()
908 page = page_pool_dev_alloc_pages(rxr->page_pool); in __bnxt_alloc_rx_page()
925 page = page_pool_alloc_frag(rxr->head_pool, &offset, in __bnxt_alloc_rx_frag()
926 bp->rx_buf_size, gfp); in __bnxt_alloc_rx_frag()
930 *mapping = page_pool_get_dma_addr(page) + bp->rx_dma_offset + offset; in __bnxt_alloc_rx_frag()
937 struct rx_bd *rxbd = &rxr->rx_desc_ring[RX_RING(bp, prod)][RX_IDX(prod)]; in bnxt_alloc_rx_data()
938 struct bnxt_sw_rx_bd *rx_buf = &rxr->rx_buf_ring[RING_RX(bp, prod)]; in bnxt_alloc_rx_data()
947 return -ENOMEM; in bnxt_alloc_rx_data()
949 mapping += bp->rx_dma_offset; in bnxt_alloc_rx_data()
950 rx_buf->data = page; in bnxt_alloc_rx_data()
951 rx_buf->data_ptr = page_address(page) + offset + bp->rx_offset; in bnxt_alloc_rx_data()
956 return -ENOMEM; in bnxt_alloc_rx_data()
958 rx_buf->data = data; in bnxt_alloc_rx_data()
959 rx_buf->data_ptr = data + bp->rx_offset; in bnxt_alloc_rx_data()
961 rx_buf->mapping = mapping; in bnxt_alloc_rx_data()
963 rxbd->rx_bd_haddr = cpu_to_le64(mapping); in bnxt_alloc_rx_data()
969 u16 prod = rxr->rx_prod; in bnxt_reuse_rx_data()
971 struct bnxt *bp = rxr->bnapi->bp; in bnxt_reuse_rx_data()
974 prod_rx_buf = &rxr->rx_buf_ring[RING_RX(bp, prod)]; in bnxt_reuse_rx_data()
975 cons_rx_buf = &rxr->rx_buf_ring[cons]; in bnxt_reuse_rx_data()
977 prod_rx_buf->data = data; in bnxt_reuse_rx_data()
978 prod_rx_buf->data_ptr = cons_rx_buf->data_ptr; in bnxt_reuse_rx_data()
980 prod_rx_buf->mapping = cons_rx_buf->mapping; in bnxt_reuse_rx_data()
982 prod_bd = &rxr->rx_desc_ring[RX_RING(bp, prod)][RX_IDX(prod)]; in bnxt_reuse_rx_data()
983 cons_bd = &rxr->rx_desc_ring[RX_RING(bp, cons)][RX_IDX(cons)]; in bnxt_reuse_rx_data()
985 prod_bd->rx_bd_haddr = cons_bd->rx_bd_haddr; in bnxt_reuse_rx_data()
990 u16 next, max = rxr->rx_agg_bmap_size; in bnxt_find_next_agg_idx()
992 next = find_next_zero_bit(rxr->rx_agg_bmap, max, idx); in bnxt_find_next_agg_idx()
994 next = find_first_zero_bit(rxr->rx_agg_bmap, max); in bnxt_find_next_agg_idx()
1003 &rxr->rx_agg_desc_ring[RX_AGG_RING(bp, prod)][RX_IDX(prod)]; in bnxt_alloc_rx_page()
1007 u16 sw_prod = rxr->rx_sw_agg_prod; in bnxt_alloc_rx_page()
1013 return -ENOMEM; in bnxt_alloc_rx_page()
1015 if (unlikely(test_bit(sw_prod, rxr->rx_agg_bmap))) in bnxt_alloc_rx_page()
1018 __set_bit(sw_prod, rxr->rx_agg_bmap); in bnxt_alloc_rx_page()
1019 rx_agg_buf = &rxr->rx_agg_ring[sw_prod]; in bnxt_alloc_rx_page()
1020 rxr->rx_sw_agg_prod = RING_RX_AGG(bp, NEXT_RX_AGG(sw_prod)); in bnxt_alloc_rx_page()
1022 rx_agg_buf->page = page; in bnxt_alloc_rx_page()
1023 rx_agg_buf->offset = offset; in bnxt_alloc_rx_page()
1024 rx_agg_buf->mapping = mapping; in bnxt_alloc_rx_page()
1025 rxbd->rx_bd_haddr = cpu_to_le64(mapping); in bnxt_alloc_rx_page()
1026 rxbd->rx_bd_opaque = sw_prod; in bnxt_alloc_rx_page()
1038 &cpr->cp_desc_ring[CP_RING(cp_cons)][CP_IDX(cp_cons)]; in bnxt_get_agg()
1046 struct bnxt_tpa_info *tpa_info = &rxr->rx_tpa[agg_id]; in bnxt_get_tpa_agg_p5()
1048 return &tpa_info->agg_arr[curr]; in bnxt_get_tpa_agg_p5()
1054 struct bnxt_napi *bnapi = cpr->bnapi; in bnxt_reuse_rx_agg_bufs()
1055 struct bnxt *bp = bnapi->bp; in bnxt_reuse_rx_agg_bufs()
1056 struct bnxt_rx_ring_info *rxr = bnapi->rx_ring; in bnxt_reuse_rx_agg_bufs()
1057 u16 prod = rxr->rx_agg_prod; in bnxt_reuse_rx_agg_bufs()
1058 u16 sw_prod = rxr->rx_sw_agg_prod; in bnxt_reuse_rx_agg_bufs()
1062 if ((bp->flags & BNXT_FLAG_CHIP_P5_PLUS) && tpa) in bnxt_reuse_rx_agg_bufs()
1076 cons = agg->rx_agg_cmp_opaque; in bnxt_reuse_rx_agg_bufs()
1077 __clear_bit(cons, rxr->rx_agg_bmap); in bnxt_reuse_rx_agg_bufs()
1079 if (unlikely(test_bit(sw_prod, rxr->rx_agg_bmap))) in bnxt_reuse_rx_agg_bufs()
1082 __set_bit(sw_prod, rxr->rx_agg_bmap); in bnxt_reuse_rx_agg_bufs()
1083 prod_rx_buf = &rxr->rx_agg_ring[sw_prod]; in bnxt_reuse_rx_agg_bufs()
1084 cons_rx_buf = &rxr->rx_agg_ring[cons]; in bnxt_reuse_rx_agg_bufs()
1087 * set cons_rx_buf->page to NULL first. in bnxt_reuse_rx_agg_bufs()
1089 page = cons_rx_buf->page; in bnxt_reuse_rx_agg_bufs()
1090 cons_rx_buf->page = NULL; in bnxt_reuse_rx_agg_bufs()
1091 prod_rx_buf->page = page; in bnxt_reuse_rx_agg_bufs()
1092 prod_rx_buf->offset = cons_rx_buf->offset; in bnxt_reuse_rx_agg_bufs()
1094 prod_rx_buf->mapping = cons_rx_buf->mapping; in bnxt_reuse_rx_agg_bufs()
1096 prod_bd = &rxr->rx_agg_desc_ring[RX_AGG_RING(bp, prod)][RX_IDX(prod)]; in bnxt_reuse_rx_agg_bufs()
1098 prod_bd->rx_bd_haddr = cpu_to_le64(cons_rx_buf->mapping); in bnxt_reuse_rx_agg_bufs()
1099 prod_bd->rx_bd_opaque = sw_prod; in bnxt_reuse_rx_agg_bufs()
1104 rxr->rx_agg_prod = prod; in bnxt_reuse_rx_agg_bufs()
1105 rxr->rx_sw_agg_prod = sw_prod; in bnxt_reuse_rx_agg_bufs()
1116 u16 prod = rxr->rx_prod; in bnxt_rx_multi_page_skb()
1125 dma_addr -= bp->rx_dma_offset; in bnxt_rx_multi_page_skb()
1126 dma_sync_single_for_cpu(&bp->pdev->dev, dma_addr, BNXT_RX_PAGE_SIZE, in bnxt_rx_multi_page_skb()
1127 bp->rx_dir); in bnxt_rx_multi_page_skb()
1128 skb = napi_build_skb(data_ptr - bp->rx_offset, BNXT_RX_PAGE_SIZE); in bnxt_rx_multi_page_skb()
1130 page_pool_recycle_direct(rxr->page_pool, page); in bnxt_rx_multi_page_skb()
1134 skb_reserve(skb, bp->rx_offset); in bnxt_rx_multi_page_skb()
1150 u16 prod = rxr->rx_prod; in bnxt_rx_page_skb()
1159 dma_addr -= bp->rx_dma_offset; in bnxt_rx_page_skb()
1160 dma_sync_single_for_cpu(&bp->pdev->dev, dma_addr, BNXT_RX_PAGE_SIZE, in bnxt_rx_page_skb()
1161 bp->rx_dir); in bnxt_rx_page_skb()
1164 payload = eth_get_headlen(bp->dev, data_ptr, len); in bnxt_rx_page_skb()
1166 skb = napi_alloc_skb(&rxr->bnapi->napi, payload); in bnxt_rx_page_skb()
1168 page_pool_recycle_direct(rxr->page_pool, page); in bnxt_rx_page_skb()
1173 off = (void *)data_ptr - page_address(page); in bnxt_rx_page_skb()
1175 memcpy(skb->data - NET_IP_ALIGN, data_ptr - NET_IP_ALIGN, in bnxt_rx_page_skb()
1178 frag = &skb_shinfo(skb)->frags[0]; in bnxt_rx_page_skb()
1181 skb->data_len -= payload; in bnxt_rx_page_skb()
1182 skb->tail += payload; in bnxt_rx_page_skb()
1193 u16 prod = rxr->rx_prod; in bnxt_rx_skb()
1203 skb = napi_build_skb(data, bp->rx_buf_size); in bnxt_rx_skb()
1204 dma_sync_single_for_cpu(&bp->pdev->dev, dma_addr, bp->rx_buf_use_size, in bnxt_rx_skb()
1205 bp->rx_dir); in bnxt_rx_skb()
1207 page_pool_free_va(rxr->head_pool, data, true); in bnxt_rx_skb()
1212 skb_reserve(skb, bp->rx_offset); in bnxt_rx_skb()
1223 struct bnxt_napi *bnapi = cpr->bnapi; in __bnxt_rx_agg_pages()
1224 struct pci_dev *pdev = bp->pdev; in __bnxt_rx_agg_pages()
1225 struct bnxt_rx_ring_info *rxr = bnapi->rx_ring; in __bnxt_rx_agg_pages()
1226 u16 prod = rxr->rx_agg_prod; in __bnxt_rx_agg_pages()
1230 if ((bp->flags & BNXT_FLAG_CHIP_P5_PLUS) && tpa) in __bnxt_rx_agg_pages()
1234 skb_frag_t *frag = &shinfo->frags[i]; in __bnxt_rx_agg_pages()
1245 cons = agg->rx_agg_cmp_opaque; in __bnxt_rx_agg_pages()
1246 frag_len = (le32_to_cpu(agg->rx_agg_cmp_len_flags_type) & in __bnxt_rx_agg_pages()
1249 cons_rx_buf = &rxr->rx_agg_ring[cons]; in __bnxt_rx_agg_pages()
1250 skb_frag_fill_page_desc(frag, cons_rx_buf->page, in __bnxt_rx_agg_pages()
1251 cons_rx_buf->offset, frag_len); in __bnxt_rx_agg_pages()
1252 shinfo->nr_frags = i + 1; in __bnxt_rx_agg_pages()
1253 __clear_bit(cons, rxr->rx_agg_bmap); in __bnxt_rx_agg_pages()
1259 mapping = cons_rx_buf->mapping; in __bnxt_rx_agg_pages()
1260 page = cons_rx_buf->page; in __bnxt_rx_agg_pages()
1261 cons_rx_buf->page = NULL; in __bnxt_rx_agg_pages()
1267 --shinfo->nr_frags; in __bnxt_rx_agg_pages()
1268 cons_rx_buf->page = page; in __bnxt_rx_agg_pages()
1273 rxr->rx_agg_prod = prod; in __bnxt_rx_agg_pages()
1274 bnxt_reuse_rx_agg_bufs(cpr, idx, i, agg_bufs - i, tpa); in __bnxt_rx_agg_pages()
1278 dma_sync_single_for_cpu(&pdev->dev, mapping, BNXT_RX_PAGE_SIZE, in __bnxt_rx_agg_pages()
1279 bp->rx_dir); in __bnxt_rx_agg_pages()
1284 rxr->rx_agg_prod = prod; in __bnxt_rx_agg_pages()
1304 skb->data_len += total_frag_len; in bnxt_rx_agg_pages_skb()
1305 skb->len += total_frag_len; in bnxt_rx_agg_pages_skb()
1306 skb->truesize += BNXT_RX_PAGE_SIZE * agg_bufs; in bnxt_rx_agg_pages_skb()
1319 shinfo->nr_frags = 0; in bnxt_rx_agg_pages_xdp()
1325 shinfo->nr_frags = agg_bufs; in bnxt_rx_agg_pages_xdp()
1326 shinfo->xdp_frags_size = total_frag_len; in bnxt_rx_agg_pages_xdp()
1340 &cpr->cp_desc_ring[CP_RING(last)][CP_IDX(last)]; in bnxt_agg_bufs_valid()
1348 struct bnxt *bp = bnapi->bp; in bnxt_copy_data()
1349 struct pci_dev *pdev = bp->pdev; in bnxt_copy_data()
1352 skb = napi_alloc_skb(&bnapi->napi, len); in bnxt_copy_data()
1356 dma_sync_single_for_cpu(&pdev->dev, mapping, bp->rx_copybreak, in bnxt_copy_data()
1357 bp->rx_dir); in bnxt_copy_data()
1359 memcpy(skb->data - NET_IP_ALIGN, data - NET_IP_ALIGN, in bnxt_copy_data()
1362 dma_sync_single_for_device(&pdev->dev, mapping, bp->rx_copybreak, in bnxt_copy_data()
1363 bp->rx_dir); in bnxt_copy_data()
1383 u8 *data = xdp->data; in bnxt_copy_xdp()
1386 len = xdp->data_end - xdp->data_meta; in bnxt_copy_xdp()
1387 metasize = xdp->data - xdp->data_meta; in bnxt_copy_xdp()
1388 data = xdp->data_meta; in bnxt_copy_xdp()
1412 agg_bufs = (le32_to_cpu(rxcmp->rx_cmp_misc_v1) & in bnxt_discard_rx()
1418 if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) in bnxt_discard_rx()
1426 return -EBUSY; in bnxt_discard_rx()
1434 struct bnxt_tpa_idx_map *map = rxr->rx_tpa_idx_map; in bnxt_alloc_agg_idx()
1437 if (test_bit(idx, map->agg_idx_bmap)) in bnxt_alloc_agg_idx()
1438 idx = find_first_zero_bit(map->agg_idx_bmap, in bnxt_alloc_agg_idx()
1440 __set_bit(idx, map->agg_idx_bmap); in bnxt_alloc_agg_idx()
1441 map->agg_id_tbl[agg_id] = idx; in bnxt_alloc_agg_idx()
1447 struct bnxt_tpa_idx_map *map = rxr->rx_tpa_idx_map; in bnxt_free_agg_idx()
1449 __clear_bit(idx, map->agg_idx_bmap); in bnxt_free_agg_idx()
1454 struct bnxt_tpa_idx_map *map = rxr->rx_tpa_idx_map; in bnxt_lookup_agg_idx()
1456 return map->agg_id_tbl[agg_id]; in bnxt_lookup_agg_idx()
1463 tpa_info->cfa_code_valid = 1; in bnxt_tpa_metadata()
1464 tpa_info->cfa_code = TPA_START_CFA_CODE(tpa_start1); in bnxt_tpa_metadata()
1465 tpa_info->vlan_valid = 0; in bnxt_tpa_metadata()
1466 if (tpa_info->flags2 & RX_CMP_FLAGS2_META_FORMAT_VLAN) { in bnxt_tpa_metadata()
1467 tpa_info->vlan_valid = 1; in bnxt_tpa_metadata()
1468 tpa_info->metadata = in bnxt_tpa_metadata()
1469 le32_to_cpu(tpa_start1->rx_tpa_start_cmp_metadata); in bnxt_tpa_metadata()
1477 tpa_info->vlan_valid = 0; in bnxt_tpa_metadata_v2()
1482 tpa_info->vlan_valid = 1; in bnxt_tpa_metadata_v2()
1485 tpa_info->metadata = vlan_proto << 16 | in bnxt_tpa_metadata_v2()
1500 if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) { in bnxt_tpa_start()
1506 cons = tpa_start->rx_tpa_start_cmp_opaque; in bnxt_tpa_start()
1507 prod = rxr->rx_prod; in bnxt_tpa_start()
1508 cons_rx_buf = &rxr->rx_buf_ring[cons]; in bnxt_tpa_start()
1509 prod_rx_buf = &rxr->rx_buf_ring[RING_RX(bp, prod)]; in bnxt_tpa_start()
1510 tpa_info = &rxr->rx_tpa[agg_id]; in bnxt_tpa_start()
1512 if (unlikely(cons != rxr->rx_next_cons || in bnxt_tpa_start()
1514 netdev_warn(bp->dev, "TPA cons %x, expected cons %x, error code %x\n", in bnxt_tpa_start()
1515 cons, rxr->rx_next_cons, in bnxt_tpa_start()
1520 prod_rx_buf->data = tpa_info->data; in bnxt_tpa_start()
1521 prod_rx_buf->data_ptr = tpa_info->data_ptr; in bnxt_tpa_start()
1523 mapping = tpa_info->mapping; in bnxt_tpa_start()
1524 prod_rx_buf->mapping = mapping; in bnxt_tpa_start()
1526 prod_bd = &rxr->rx_desc_ring[RX_RING(bp, prod)][RX_IDX(prod)]; in bnxt_tpa_start()
1528 prod_bd->rx_bd_haddr = cpu_to_le64(mapping); in bnxt_tpa_start()
1530 tpa_info->data = cons_rx_buf->data; in bnxt_tpa_start()
1531 tpa_info->data_ptr = cons_rx_buf->data_ptr; in bnxt_tpa_start()
1532 cons_rx_buf->data = NULL; in bnxt_tpa_start()
1533 tpa_info->mapping = cons_rx_buf->mapping; in bnxt_tpa_start()
1535 tpa_info->len = in bnxt_tpa_start()
1536 le32_to_cpu(tpa_start->rx_tpa_start_cmp_len_flags_type) >> in bnxt_tpa_start()
1539 tpa_info->hash_type = PKT_HASH_TYPE_L4; in bnxt_tpa_start()
1540 tpa_info->gso_type = SKB_GSO_TCPV4; in bnxt_tpa_start()
1542 tpa_info->gso_type = SKB_GSO_TCPV6; in bnxt_tpa_start()
1543 /* RSS profiles 1 and 3 with extract code 0 for inner 4-tuple */ in bnxt_tpa_start()
1546 tpa_info->gso_type = SKB_GSO_TCPV6; in bnxt_tpa_start()
1547 tpa_info->rss_hash = in bnxt_tpa_start()
1548 le32_to_cpu(tpa_start->rx_tpa_start_cmp_rss_hash); in bnxt_tpa_start()
1550 tpa_info->hash_type = PKT_HASH_TYPE_NONE; in bnxt_tpa_start()
1551 tpa_info->gso_type = 0; in bnxt_tpa_start()
1552 netif_warn(bp, rx_err, bp->dev, "TPA packet without valid hash\n"); in bnxt_tpa_start()
1554 tpa_info->flags2 = le32_to_cpu(tpa_start1->rx_tpa_start_cmp_flags2); in bnxt_tpa_start()
1555 tpa_info->hdr_info = le32_to_cpu(tpa_start1->rx_tpa_start_cmp_hdr_info); in bnxt_tpa_start()
1560 tpa_info->agg_count = 0; in bnxt_tpa_start()
1562 rxr->rx_prod = NEXT_RX(prod); in bnxt_tpa_start()
1564 rxr->rx_next_cons = RING_RX(bp, NEXT_RX(cons)); in bnxt_tpa_start()
1565 cons_rx_buf = &rxr->rx_buf_ring[cons]; in bnxt_tpa_start()
1567 bnxt_reuse_rx_data(rxr, cons, cons_rx_buf->data); in bnxt_tpa_start()
1568 rxr->rx_prod = NEXT_RX(rxr->rx_prod); in bnxt_tpa_start()
1569 cons_rx_buf->data = NULL; in bnxt_tpa_start()
1584 struct iphdr *iph = (struct iphdr *)skb->data; in bnxt_gro_tunnel()
1586 if (iph->protocol == IPPROTO_UDP) in bnxt_gro_tunnel()
1589 struct ipv6hdr *iph = (struct ipv6hdr *)skb->data; in bnxt_gro_tunnel()
1591 if (iph->nexthdr == IPPROTO_UDP) in bnxt_gro_tunnel()
1595 if (uh->check) in bnxt_gro_tunnel()
1596 skb_shinfo(skb)->gso_type |= SKB_GSO_UDP_TUNNEL_CSUM; in bnxt_gro_tunnel()
1598 skb_shinfo(skb)->gso_type |= SKB_GSO_UDP_TUNNEL; in bnxt_gro_tunnel()
1611 u32 hdr_info = tpa_info->hdr_info; in bnxt_gro_func_5731x()
1624 __be16 proto = *((__be16 *)(skb->data + inner_ip_off - in bnxt_gro_func_5731x()
1625 ETH_HLEN - 2)); in bnxt_gro_func_5731x()
1636 inner_ip_off -= 4; in bnxt_gro_func_5731x()
1637 inner_mac_off -= 4; in bnxt_gro_func_5731x()
1638 outer_ip_off -= 4; in bnxt_gro_func_5731x()
1641 nw_off = inner_ip_off - ETH_HLEN; in bnxt_gro_func_5731x()
1643 if (tpa_info->flags2 & RX_TPA_START_CMP_FLAGS2_IP_TYPE) { in bnxt_gro_func_5731x()
1647 len = skb->len - skb_transport_offset(skb); in bnxt_gro_func_5731x()
1649 th->check = ~tcp_v6_check(len, &iph->saddr, &iph->daddr, 0); in bnxt_gro_func_5731x()
1654 len = skb->len - skb_transport_offset(skb); in bnxt_gro_func_5731x()
1656 th->check = ~tcp_v4_check(len, iph->saddr, iph->daddr, 0); in bnxt_gro_func_5731x()
1660 __be16 proto = *((__be16 *)(skb->data + outer_ip_off - in bnxt_gro_func_5731x()
1661 ETH_HLEN - 2)); in bnxt_gro_func_5731x()
1675 u32 hdr_info = tpa_info->hdr_info; in bnxt_gro_func_5750x()
1682 nw_off = inner_ip_off - ETH_HLEN; in bnxt_gro_func_5750x()
1684 iphdr_len = (tpa_info->flags2 & RX_TPA_START_CMP_FLAGS2_IP_TYPE) ? in bnxt_gro_func_5750x()
1689 __be16 proto = *((__be16 *)(skb->data + outer_ip_off - in bnxt_gro_func_5750x()
1690 ETH_HLEN - 2)); in bnxt_gro_func_5750x()
1712 if (tpa_info->gso_type == SKB_GSO_TCPV4) { in bnxt_gro_func_5730x()
1715 nw_off = payload_off - BNXT_IPV4_HDR_SIZE - tcp_opt_len - in bnxt_gro_func_5730x()
1720 len = skb->len - skb_transport_offset(skb); in bnxt_gro_func_5730x()
1722 th->check = ~tcp_v4_check(len, iph->saddr, iph->daddr, 0); in bnxt_gro_func_5730x()
1723 } else if (tpa_info->gso_type == SKB_GSO_TCPV6) { in bnxt_gro_func_5730x()
1726 nw_off = payload_off - BNXT_IPV6_HDR_SIZE - tcp_opt_len - in bnxt_gro_func_5730x()
1731 len = skb->len - skb_transport_offset(skb); in bnxt_gro_func_5730x()
1733 th->check = ~tcp_v6_check(len, &iph->saddr, &iph->daddr, 0); in bnxt_gro_func_5730x()
1740 bnxt_gro_tunnel(skb, skb->protocol); in bnxt_gro_func_5730x()
1759 NAPI_GRO_CB(skb)->count = segs; in bnxt_gro_skb()
1760 skb_shinfo(skb)->gso_size = in bnxt_gro_skb()
1761 le32_to_cpu(tpa_end1->rx_tpa_end_cmp_seg_len); in bnxt_gro_skb()
1762 skb_shinfo(skb)->gso_type = tpa_info->gso_type; in bnxt_gro_skb()
1763 if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) in bnxt_gro_skb()
1767 skb = bp->gro_func(tpa_info, payload_off, TPA_END_GRO_TS(tpa_end), skb); in bnxt_gro_skb()
1775 * netdev (vf-rep or PF) the packet is destined to.
1781 /* if vf-rep dev is NULL, the must belongs to the PF */ in bnxt_get_pkt_dev()
1782 return dev ? dev : bp->dev; in bnxt_get_pkt_dev()
1792 struct bnxt_napi *bnapi = cpr->bnapi; in bnxt_tpa_end()
1793 struct bnxt_rx_ring_info *rxr = bnapi->rx_ring; in bnxt_tpa_end()
1794 struct net_device *dev = bp->dev; in bnxt_tpa_end()
1804 if (unlikely(bnapi->in_reset)) { in bnxt_tpa_end()
1808 return ERR_PTR(-EBUSY); in bnxt_tpa_end()
1812 if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) { in bnxt_tpa_end()
1816 tpa_info = &rxr->rx_tpa[agg_id]; in bnxt_tpa_end()
1817 if (unlikely(agg_bufs != tpa_info->agg_count)) { in bnxt_tpa_end()
1818 netdev_warn(bp->dev, "TPA end agg_buf %d != expected agg_bufs %d\n", in bnxt_tpa_end()
1819 agg_bufs, tpa_info->agg_count); in bnxt_tpa_end()
1820 agg_bufs = tpa_info->agg_count; in bnxt_tpa_end()
1822 tpa_info->agg_count = 0; in bnxt_tpa_end()
1826 gro = !!(bp->flags & BNXT_FLAG_GRO); in bnxt_tpa_end()
1830 tpa_info = &rxr->rx_tpa[agg_id]; in bnxt_tpa_end()
1834 return ERR_PTR(-EBUSY); in bnxt_tpa_end()
1841 data = tpa_info->data; in bnxt_tpa_end()
1842 data_ptr = tpa_info->data_ptr; in bnxt_tpa_end()
1844 len = tpa_info->len; in bnxt_tpa_end()
1845 mapping = tpa_info->mapping; in bnxt_tpa_end()
1850 netdev_warn(bp->dev, "TPA frags %d exceeded MAX_SKB_FRAGS %d\n", in bnxt_tpa_end()
1855 if (len <= bp->rx_copybreak) { in bnxt_tpa_end()
1859 cpr->sw_stats->rx.rx_oom_discards += 1; in bnxt_tpa_end()
1870 cpr->sw_stats->rx.rx_oom_discards += 1; in bnxt_tpa_end()
1874 tpa_info->data = new_data; in bnxt_tpa_end()
1875 tpa_info->data_ptr = new_data + bp->rx_offset; in bnxt_tpa_end()
1876 tpa_info->mapping = new_mapping; in bnxt_tpa_end()
1878 skb = napi_build_skb(data, bp->rx_buf_size); in bnxt_tpa_end()
1879 dma_sync_single_for_cpu(&bp->pdev->dev, mapping, in bnxt_tpa_end()
1880 bp->rx_buf_use_size, bp->rx_dir); in bnxt_tpa_end()
1883 page_pool_free_va(rxr->head_pool, data, true); in bnxt_tpa_end()
1885 cpr->sw_stats->rx.rx_oom_discards += 1; in bnxt_tpa_end()
1889 skb_reserve(skb, bp->rx_offset); in bnxt_tpa_end()
1897 cpr->sw_stats->rx.rx_oom_discards += 1; in bnxt_tpa_end()
1902 if (tpa_info->cfa_code_valid) in bnxt_tpa_end()
1903 dev = bnxt_get_pkt_dev(bp, tpa_info->cfa_code); in bnxt_tpa_end()
1904 skb->protocol = eth_type_trans(skb, dev); in bnxt_tpa_end()
1906 if (tpa_info->hash_type != PKT_HASH_TYPE_NONE) in bnxt_tpa_end()
1907 skb_set_hash(skb, tpa_info->rss_hash, tpa_info->hash_type); in bnxt_tpa_end()
1909 if (tpa_info->vlan_valid && in bnxt_tpa_end()
1910 (dev->features & BNXT_HW_FEATURE_VLAN_ALL_RX)) { in bnxt_tpa_end()
1911 __be16 vlan_proto = htons(tpa_info->metadata >> in bnxt_tpa_end()
1913 u16 vtag = tpa_info->metadata & RX_CMP_FLAGS2_METADATA_TCI_MASK; in bnxt_tpa_end()
1924 if (likely(tpa_info->flags2 & RX_TPA_START_CMP_FLAGS2_L4_CS_CALC)) { in bnxt_tpa_end()
1925 skb->ip_summed = CHECKSUM_UNNECESSARY; in bnxt_tpa_end()
1926 skb->csum_level = in bnxt_tpa_end()
1927 (tpa_info->flags2 & RX_CMP_FLAGS2_T_L4_CS_CALC) >> 3; in bnxt_tpa_end()
1943 tpa_info = &rxr->rx_tpa[agg_id]; in bnxt_tpa_agg()
1944 BUG_ON(tpa_info->agg_count >= MAX_SKB_FRAGS); in bnxt_tpa_agg()
1945 tpa_info->agg_arr[tpa_info->agg_count++] = *rx_agg; in bnxt_tpa_agg()
1953 if (skb->dev != bp->dev) { in bnxt_deliver_skb()
1954 /* this packet belongs to a vf-rep */ in bnxt_deliver_skb()
1958 skb_record_rx_queue(skb, bnapi->index); in bnxt_deliver_skb()
1959 napi_gro_receive(&bnapi->napi, skb); in bnxt_deliver_skb()
1965 u32 ts = le32_to_cpu(rxcmp1->rx_cmp_timestamp); in bnxt_rx_ts_valid()
1969 if (!bp->ptp_all_rx_tstamp || !ts || !BNXT_ALL_RX_TS_VALID(flags)) in bnxt_rx_ts_valid()
1985 __le32 flags2 = rxcmp1->rx_cmp_flags2; in bnxt_rx_vlan()
1991 meta_data = le32_to_cpu(rxcmp1->rx_cmp_meta_data); in bnxt_rx_vlan()
2036 * 1 - 1 packet successfully received
2037 * 0 - successful TPA_START, packet not completed yet
2038 * -EBUSY - completion ring does not have all the agg buffers yet
2039 * -ENOMEM - packet aborted due to out of memory
2040 * -EIO - packet aborted due to hw error indicated in BD
2045 struct bnxt_napi *bnapi = cpr->bnapi; in bnxt_rx_pkt()
2046 struct bnxt_rx_ring_info *rxr = bnapi->rx_ring; in bnxt_rx_pkt()
2047 struct net_device *dev = bp->dev; in bnxt_rx_pkt()
2066 &cpr->cp_desc_ring[CP_RING(cp_cons)][CP_IDX(cp_cons)]; in bnxt_rx_pkt()
2078 &cpr->cp_desc_ring[CP_RING(cp_cons)][CP_IDX(cp_cons)]; in bnxt_rx_pkt()
2081 return -EBUSY; in bnxt_rx_pkt()
2087 prod = rxr->rx_prod; in bnxt_rx_pkt()
2104 return -EBUSY; in bnxt_rx_pkt()
2106 rc = -ENOMEM; in bnxt_rx_pkt()
2115 cons = rxcmp->rx_cmp_opaque; in bnxt_rx_pkt()
2116 if (unlikely(cons != rxr->rx_next_cons)) { in bnxt_rx_pkt()
2120 if (rxr->rx_next_cons != 0xffff) in bnxt_rx_pkt()
2121 netdev_warn(bp->dev, "RX cons %x != expected cons %x\n", in bnxt_rx_pkt()
2122 cons, rxr->rx_next_cons); in bnxt_rx_pkt()
2128 rx_buf = &rxr->rx_buf_ring[cons]; in bnxt_rx_pkt()
2129 data = rx_buf->data; in bnxt_rx_pkt()
2130 data_ptr = rx_buf->data_ptr; in bnxt_rx_pkt()
2133 misc = le32_to_cpu(rxcmp->rx_cmp_misc_v1); in bnxt_rx_pkt()
2138 return -EBUSY; in bnxt_rx_pkt()
2145 rx_buf->data = NULL; in bnxt_rx_pkt()
2146 if (rxcmp1->rx_cmp_cfa_code_errors_v2 & RX_CMP_L2_ERRORS) { in bnxt_rx_pkt()
2147 u32 rx_err = le32_to_cpu(rxcmp1->rx_cmp_cfa_code_errors_v2); in bnxt_rx_pkt()
2154 rc = -EIO; in bnxt_rx_pkt()
2156 bnapi->cp_ring.sw_stats->rx.rx_buf_errors++; in bnxt_rx_pkt()
2157 if (!(bp->flags & BNXT_FLAG_CHIP_P5_PLUS) && in bnxt_rx_pkt()
2158 !(bp->fw_cap & BNXT_FW_CAP_RING_MONITOR)) { in bnxt_rx_pkt()
2159 netdev_warn_once(bp->dev, "RX buffer error %x\n", in bnxt_rx_pkt()
2167 flags = le32_to_cpu(rxcmp->rx_cmp_len_flags_type); in bnxt_rx_pkt()
2169 dma_addr = rx_buf->mapping; in bnxt_rx_pkt()
2191 agg_bufs = sinfo->nr_frags; in bnxt_rx_pkt()
2197 if (len <= bp->rx_copybreak) { in bnxt_rx_pkt()
2216 if (rx_buf->data_ptr == data_ptr) in bnxt_rx_pkt()
2220 skb = bp->rx_skb_func(bp, rxr, cons, data, data_ptr, dma_addr, in bnxt_rx_pkt()
2233 rxr->page_pool, &xdp); in bnxt_rx_pkt()
2256 skb_set_hash(skb, le32_to_cpu(rxcmp->rx_cmp_rss_hash), type); in bnxt_rx_pkt()
2261 skb->protocol = eth_type_trans(skb, dev); in bnxt_rx_pkt()
2263 if (skb->dev->features & BNXT_HW_FEATURE_VLAN_ALL_RX) { in bnxt_rx_pkt()
2271 if (dev->features & NETIF_F_RXCSUM) { in bnxt_rx_pkt()
2272 skb->ip_summed = CHECKSUM_UNNECESSARY; in bnxt_rx_pkt()
2273 skb->csum_level = RX_CMP_ENCAP(rxcmp1); in bnxt_rx_pkt()
2276 if (rxcmp1->rx_cmp_cfa_code_errors_v2 & RX_CMP_L4_CS_ERR_BITS) { in bnxt_rx_pkt()
2277 if (dev->features & NETIF_F_RXCSUM) in bnxt_rx_pkt()
2278 bnapi->cp_ring.sw_stats->rx.rx_l4_csum_errors++; in bnxt_rx_pkt()
2283 if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) { in bnxt_rx_pkt()
2287 struct bnxt_ptp_cfg *ptp = bp->ptp_cfg; in bnxt_rx_pkt()
2292 skb_hwtstamps(skb)->hwtstamp = ns_to_ktime(ns); in bnxt_rx_pkt()
2300 cpr->rx_packets += 1; in bnxt_rx_pkt()
2301 cpr->rx_bytes += len; in bnxt_rx_pkt()
2304 rxr->rx_prod = NEXT_RX(prod); in bnxt_rx_pkt()
2305 rxr->rx_next_cons = RING_RX(bp, NEXT_RX(cons)); in bnxt_rx_pkt()
2313 cpr->sw_stats->rx.rx_oom_discards += 1; in bnxt_rx_pkt()
2314 rc = -ENOMEM; in bnxt_rx_pkt()
2334 &cpr->cp_desc_ring[CP_RING(cp_cons)][CP_IDX(cp_cons)]; in bnxt_force_rx_discard()
2339 &cpr->cp_desc_ring[CP_RING(cp_cons)][CP_IDX(cp_cons)]; in bnxt_force_rx_discard()
2342 return -EBUSY; in bnxt_force_rx_discard()
2351 rxcmp1->rx_cmp_cfa_code_errors_v2 |= in bnxt_force_rx_discard()
2357 tpa_end1->rx_tpa_end_cmp_errors_v2 |= in bnxt_force_rx_discard()
2361 if (rc && rc != -EBUSY) in bnxt_force_rx_discard()
2362 cpr->sw_stats->rx.rx_netpoll_discards += 1; in bnxt_force_rx_discard()
2368 struct bnxt_fw_health *fw_health = bp->fw_health; in bnxt_fw_health_readl()
2369 u32 reg = fw_health->regs[reg_idx]; in bnxt_fw_health_readl()
2376 pci_read_config_dword(bp->pdev, reg_off, &val); in bnxt_fw_health_readl()
2379 reg_off = fw_health->mapped_regs[reg_idx]; in bnxt_fw_health_readl()
2382 val = readl(bp->bar0 + reg_off); in bnxt_fw_health_readl()
2385 val = readl(bp->bar1 + reg_off); in bnxt_fw_health_readl()
2389 val &= fw_health->fw_reset_inprog_reg_mask; in bnxt_fw_health_readl()
2397 for (i = 0; i < bp->rx_nr_rings; i++) { in bnxt_agg_ring_id_to_grp_idx()
2398 u16 grp_idx = bp->rx_ring[i].bnapi->index; in bnxt_agg_ring_id_to_grp_idx()
2401 grp_info = &bp->grp_info[grp_idx]; in bnxt_agg_ring_id_to_grp_idx()
2402 if (grp_info->agg_fw_ring_id == ring_id) in bnxt_agg_ring_id_to_grp_idx()
2412 if (bp->phy_flags & BNXT_PHY_FL_SPEEDS2) in bnxt_get_force_speed()
2413 return link_info->force_link_speed2; in bnxt_get_force_speed()
2414 if (link_info->req_signal_mode == BNXT_SIG_MODE_PAM4) in bnxt_get_force_speed()
2415 return link_info->force_pam4_link_speed; in bnxt_get_force_speed()
2416 return link_info->force_link_speed; in bnxt_get_force_speed()
2423 if (bp->phy_flags & BNXT_PHY_FL_SPEEDS2) { in bnxt_set_force_speed()
2424 link_info->req_link_speed = link_info->force_link_speed2; in bnxt_set_force_speed()
2425 link_info->req_signal_mode = BNXT_SIG_MODE_NRZ; in bnxt_set_force_speed()
2426 switch (link_info->req_link_speed) { in bnxt_set_force_speed()
2431 link_info->req_signal_mode = BNXT_SIG_MODE_PAM4; in bnxt_set_force_speed()
2436 link_info->req_signal_mode = BNXT_SIG_MODE_PAM4_112; in bnxt_set_force_speed()
2439 link_info->req_signal_mode = BNXT_SIG_MODE_NRZ; in bnxt_set_force_speed()
2443 link_info->req_link_speed = link_info->force_link_speed; in bnxt_set_force_speed()
2444 link_info->req_signal_mode = BNXT_SIG_MODE_NRZ; in bnxt_set_force_speed()
2445 if (link_info->force_pam4_link_speed) { in bnxt_set_force_speed()
2446 link_info->req_link_speed = link_info->force_pam4_link_speed; in bnxt_set_force_speed()
2447 link_info->req_signal_mode = BNXT_SIG_MODE_PAM4; in bnxt_set_force_speed()
2455 if (bp->phy_flags & BNXT_PHY_FL_SPEEDS2) { in bnxt_set_auto_speed()
2456 link_info->advertising = link_info->auto_link_speeds2; in bnxt_set_auto_speed()
2459 link_info->advertising = link_info->auto_link_speeds; in bnxt_set_auto_speed()
2460 link_info->advertising_pam4 = link_info->auto_pam4_link_speeds; in bnxt_set_auto_speed()
2467 if (bp->phy_flags & BNXT_PHY_FL_SPEEDS2) { in bnxt_force_speed_updated()
2468 if (link_info->req_link_speed != link_info->force_link_speed2) in bnxt_force_speed_updated()
2472 if (link_info->req_signal_mode == BNXT_SIG_MODE_NRZ && in bnxt_force_speed_updated()
2473 link_info->req_link_speed != link_info->force_link_speed) in bnxt_force_speed_updated()
2475 if (link_info->req_signal_mode == BNXT_SIG_MODE_PAM4 && in bnxt_force_speed_updated()
2476 link_info->req_link_speed != link_info->force_pam4_link_speed) in bnxt_force_speed_updated()
2485 if (bp->phy_flags & BNXT_PHY_FL_SPEEDS2) { in bnxt_auto_speed_updated()
2486 if (link_info->advertising != link_info->auto_link_speeds2) in bnxt_auto_speed_updated()
2490 if (link_info->advertising != link_info->auto_link_speeds || in bnxt_auto_speed_updated()
2491 link_info->advertising_pam4 != link_info->auto_pam4_link_speeds) in bnxt_auto_speed_updated()
2498 u32 flags = bp->ctx->ctx_arr[type].flags; in bnxt_bs_trace_avail()
2508 u16 trace_type = bnxt_bstore_to_trace[ctxm->type]; in bnxt_bs_trace_init()
2509 struct bnxt_ctx_pg_info *ctx_pg = ctxm->pg_info; in bnxt_bs_trace_init()
2514 if (ctxm->instance_bmap && ctxm->instance_bmap > 1) in bnxt_bs_trace_init()
2517 mem_size = ctxm->max_entries * ctxm->entry_size; in bnxt_bs_trace_init()
2521 last_pg = (pages - 1) & (MAX_CTX_PAGES - 1); in bnxt_bs_trace_init()
2522 magic_byte_offset = (rem_bytes ? rem_bytes : BNXT_PAGE_SIZE) - 1; in bnxt_bs_trace_init()
2525 bs_trace = &bp->bs_trace[trace_type]; in bnxt_bs_trace_init()
2526 bs_trace->ctx_type = ctxm->type; in bnxt_bs_trace_init()
2527 bs_trace->trace_type = trace_type; in bnxt_bs_trace_init()
2529 int last_pg_dir = rmem->nr_pages - 1; in bnxt_bs_trace_init()
2531 rmem_pg_tbl = &ctx_pg[0].ctx_pg_tbl[last_pg_dir]->ring_mem; in bnxt_bs_trace_init()
2532 bs_trace->magic_byte = rmem_pg_tbl->pg_arr[last_pg]; in bnxt_bs_trace_init()
2534 bs_trace->magic_byte = rmem->pg_arr[last_pg]; in bnxt_bs_trace_init()
2536 bs_trace->magic_byte += magic_byte_offset; in bnxt_bs_trace_init()
2537 *bs_trace->magic_byte = BNXT_TRACE_BUF_MAGIC_BYTE; in bnxt_bs_trace_init()
2574 …netdev_err(bp->dev, "1PPS: Received invalid signal on pin%lu from the external source. Please fix … in bnxt_event_error_report()
2578 netdev_warn(bp->dev, "Pause Storm detected!\n"); in bnxt_event_error_report()
2581 netdev_warn(bp->dev, "One or more MMIO doorbells dropped by the device!\n"); in bnxt_event_error_report()
2603 netdev_err(bp->dev, "Unknown Thermal threshold type event\n"); in bnxt_event_error_report()
2612 netdev_warn(bp->dev, "Chip temperature has gone %s the %s thermal threshold!\n", in bnxt_event_error_report()
2614 netdev_warn(bp->dev, "Temperature (In Celsius), Current: %lu, threshold: %lu\n", in bnxt_event_error_report()
2618 bp->thermal_threshold_type = type; in bnxt_event_error_report()
2619 set_bit(BNXT_THERMAL_THRESHOLD_SP_EVENT, &bp->sp_event); in bnxt_event_error_report()
2625 netdev_warn(bp->dev, "Speed change not supported with dual rate transceivers on this board\n"); in bnxt_event_error_report()
2628 netdev_err(bp->dev, "FW reported unknown error type %u\n", in bnxt_event_error_report()
2660 u16 event_id = le16_to_cpu(cmpl->event_id); in bnxt_async_event_process()
2661 u32 data1 = le32_to_cpu(cmpl->event_data1); in bnxt_async_event_process()
2662 u32 data2 = le32_to_cpu(cmpl->event_data2); in bnxt_async_event_process()
2664 netdev_dbg(bp->dev, "hwrm event 0x%x {0x%x, 0x%x}\n", in bnxt_async_event_process()
2670 struct bnxt_link_info *link_info = &bp->link_info; in bnxt_async_event_process()
2676 if (!(link_info->autoneg & BNXT_AUTONEG_SPEED) && in bnxt_async_event_process()
2682 netdev_warn(bp->dev, "Link speed %d no longer supported\n", in bnxt_async_event_process()
2685 set_bit(BNXT_LINK_SPEED_CHNG_SP_EVENT, &bp->sp_event); in bnxt_async_event_process()
2690 set_bit(BNXT_LINK_CFG_CHANGE_SP_EVENT, &bp->sp_event); in bnxt_async_event_process()
2693 set_bit(BNXT_LINK_CHNG_SP_EVENT, &bp->sp_event); in bnxt_async_event_process()
2696 set_bit(BNXT_HWRM_PF_UNLOAD_SP_EVENT, &bp->sp_event); in bnxt_async_event_process()
2704 if (bp->pf.port_id != port_id) in bnxt_async_event_process()
2707 set_bit(BNXT_HWRM_PORT_MODULE_SP_EVENT, &bp->sp_event); in bnxt_async_event_process()
2713 set_bit(BNXT_RESET_TASK_SILENT_SP_EVENT, &bp->sp_event); in bnxt_async_event_process()
2718 if (!bp->fw_health) in bnxt_async_event_process()
2721 bp->fw_reset_timestamp = jiffies; in bnxt_async_event_process()
2722 bp->fw_reset_min_dsecs = cmpl->timestamp_lo; in bnxt_async_event_process()
2723 if (!bp->fw_reset_min_dsecs) in bnxt_async_event_process()
2724 bp->fw_reset_min_dsecs = BNXT_DFLT_FW_RST_MIN_DSECS; in bnxt_async_event_process()
2725 bp->fw_reset_max_dsecs = le16_to_cpu(cmpl->timestamp_hi); in bnxt_async_event_process()
2726 if (!bp->fw_reset_max_dsecs) in bnxt_async_event_process()
2727 bp->fw_reset_max_dsecs = BNXT_DFLT_FW_RST_MAX_DSECS; in bnxt_async_event_process()
2729 set_bit(BNXT_STATE_FW_ACTIVATE_RESET, &bp->state); in bnxt_async_event_process()
2732 bp->fw_health->fatalities++; in bnxt_async_event_process()
2733 set_bit(BNXT_STATE_FW_FATAL_COND, &bp->state); in bnxt_async_event_process()
2736 type_str = "Non-fatal"; in bnxt_async_event_process()
2737 bp->fw_health->survivals++; in bnxt_async_event_process()
2738 set_bit(BNXT_STATE_FW_NON_FATAL_COND, &bp->state); in bnxt_async_event_process()
2740 netif_warn(bp, hw, bp->dev, in bnxt_async_event_process()
2743 bp->fw_reset_min_dsecs * 100, in bnxt_async_event_process()
2744 bp->fw_reset_max_dsecs * 100); in bnxt_async_event_process()
2745 set_bit(BNXT_FW_RESET_NOTIFY_SP_EVENT, &bp->sp_event); in bnxt_async_event_process()
2749 struct bnxt_fw_health *fw_health = bp->fw_health; in bnxt_async_event_process()
2757 fw_health->enabled = false; in bnxt_async_event_process()
2758 netif_info(bp, drv, bp->dev, "Driver recovery watchdog is disabled\n"); in bnxt_async_event_process()
2761 fw_health->primary = EVENT_DATA1_RECOVERY_MASTER_FUNC(data1); in bnxt_async_event_process()
2762 fw_health->tmr_multiplier = in bnxt_async_event_process()
2763 DIV_ROUND_UP(fw_health->polling_dsecs * HZ, in bnxt_async_event_process()
2764 bp->current_interval * 10); in bnxt_async_event_process()
2765 fw_health->tmr_counter = fw_health->tmr_multiplier; in bnxt_async_event_process()
2766 if (!fw_health->enabled) in bnxt_async_event_process()
2767 fw_health->last_fw_heartbeat = in bnxt_async_event_process()
2769 fw_health->last_fw_reset_cnt = in bnxt_async_event_process()
2774 netif_info(bp, drv, bp->dev, in bnxt_async_event_process()
2776 fw_health->primary ? "primary" : "backup", status, in bnxt_async_event_process()
2777 status_desc, fw_health->last_fw_reset_cnt); in bnxt_async_event_process()
2778 if (!fw_health->enabled) { in bnxt_async_event_process()
2783 fw_health->enabled = true; in bnxt_async_event_process()
2788 netif_notice(bp, hw, bp->dev, in bnxt_async_event_process()
2796 if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) in bnxt_async_event_process()
2799 netdev_warn(bp->dev, "Ring monitor event, ring type %lu id 0x%x\n", in bnxt_async_event_process()
2806 netdev_warn(bp->dev, "Unknown RX agg ring id 0x%x\n", in bnxt_async_event_process()
2810 rxr = bp->bnapi[grp_idx]->rx_ring; in bnxt_async_event_process()
2815 struct bnxt_fw_health *fw_health = bp->fw_health; in bnxt_async_event_process()
2817 netif_notice(bp, hw, bp->dev, in bnxt_async_event_process()
2821 fw_health->echo_req_data1 = data1; in bnxt_async_event_process()
2822 fw_health->echo_req_data2 = data2; in bnxt_async_event_process()
2823 set_bit(BNXT_FW_ECHO_REQUEST_SP_EVENT, &bp->sp_event); in bnxt_async_event_process()
2841 struct bnxt_ptp_cfg *ptp = bp->ptp_cfg; in bnxt_async_event_process()
2850 BNXT_PHC_BITS) | ptp->current_time); in bnxt_async_event_process()
2851 write_seqlock_irqsave(&ptp->ptp_lock, flags); in bnxt_async_event_process()
2853 write_sequnlock_irqrestore(&ptp->ptp_lock, flags); in bnxt_async_event_process()
2860 u16 seq_id = le32_to_cpu(cmpl->event_data2) & 0xffff; in bnxt_async_event_process()
2869 bnxt_bs_trace_check_wrap(&bp->bs_trace[type], offset); in bnxt_async_event_process()
2890 seq_id = le16_to_cpu(h_cmpl->sequence_id); in bnxt_hwrm_handler()
2895 vf_id = le16_to_cpu(fwd_req_cmpl->source_id); in bnxt_hwrm_handler()
2897 if ((vf_id < bp->pf.first_vf_id) || in bnxt_hwrm_handler()
2898 (vf_id >= bp->pf.first_vf_id + bp->pf.active_vfs)) { in bnxt_hwrm_handler()
2899 netdev_err(bp->dev, "Msg contains invalid VF id %x\n", in bnxt_hwrm_handler()
2901 return -EINVAL; in bnxt_hwrm_handler()
2904 set_bit(vf_id - bp->pf.first_vf_id, bp->pf.vf_event_bmap); in bnxt_hwrm_handler()
2922 struct bnxt_vnic_info *vnic = &bp->vnic_info[0]; in bnxt_vnic_is_active()
2924 return vnic->fw_vnic_id != INVALID_HW_RING_ID && vnic->mru > 0; in bnxt_vnic_is_active()
2930 struct bnxt *bp = bnapi->bp; in bnxt_msix()
2931 struct bnxt_cp_ring_info *cpr = &bnapi->cp_ring; in bnxt_msix()
2932 u32 cons = RING_CMP(cpr->cp_raw_cons); in bnxt_msix()
2934 cpr->event_ctr++; in bnxt_msix()
2935 prefetch(&cpr->cp_desc_ring[CP_RING(cons)][CP_IDX(cons)]); in bnxt_msix()
2936 napi_schedule(&bnapi->napi); in bnxt_msix()
2942 u32 raw_cons = cpr->cp_raw_cons; in bnxt_has_work()
2946 txcmp = &cpr->cp_desc_ring[CP_RING(cons)][CP_IDX(cons)]; in bnxt_has_work()
2954 struct bnxt_napi *bnapi = cpr->bnapi; in __bnxt_poll_work()
2955 u32 raw_cons = cpr->cp_raw_cons; in __bnxt_poll_work()
2961 cpr->has_more_work = 0; in __bnxt_poll_work()
2962 cpr->had_work_done = 1; in __bnxt_poll_work()
2968 txcmp = &cpr->cp_desc_ring[CP_RING(cons)][CP_IDX(cons)]; in __bnxt_poll_work()
2980 u32 opaque = txcmp->tx_cmp_opaque; in __bnxt_poll_work()
2984 txr = bnapi->tx_ring[TX_OPAQUE_RING(opaque)]; in __bnxt_poll_work()
2987 txr->tx_hw_cons = TX_CMP_SQ_CONS_IDX(txcmp); in __bnxt_poll_work()
2989 txr->tx_hw_cons = TX_OPAQUE_PROD(bp, opaque); in __bnxt_poll_work()
2990 tx_freed = (txr->tx_hw_cons - txr->tx_cons) & in __bnxt_poll_work()
2991 bp->tx_ring_mask; in __bnxt_poll_work()
2993 if (unlikely(tx_freed >= bp->tx_wake_thresh)) { in __bnxt_poll_work()
2997 cpr->has_more_work = 1; in __bnxt_poll_work()
3011 /* Increment rx_pkts when rc is -ENOMEM to count towards in __bnxt_poll_work()
3016 else if (rc == -ENOMEM && budget) in __bnxt_poll_work()
3018 else if (rc == -EBUSY) /* partial completion */ in __bnxt_poll_work()
3028 cpr->has_more_work = 1; in __bnxt_poll_work()
3039 struct bnxt_tx_ring_info *txr = bnapi->tx_ring[0]; in __bnxt_poll_work()
3040 u16 prod = txr->tx_prod; in __bnxt_poll_work()
3045 bnxt_db_write_relaxed(bp, &txr->tx_db, prod); in __bnxt_poll_work()
3049 cpr->cp_raw_cons = raw_cons; in __bnxt_poll_work()
3050 bnapi->events |= event; in __bnxt_poll_work()
3057 if ((bnapi->events & BNXT_TX_CMP_EVENT) && !bnapi->tx_fault) in __bnxt_poll_work_done()
3058 bnapi->tx_int(bp, bnapi, budget); in __bnxt_poll_work_done()
3060 if ((bnapi->events & BNXT_RX_EVENT) && !(bnapi->in_reset)) { in __bnxt_poll_work_done()
3061 struct bnxt_rx_ring_info *rxr = bnapi->rx_ring; in __bnxt_poll_work_done()
3063 bnxt_db_write(bp, &rxr->rx_db, rxr->rx_prod); in __bnxt_poll_work_done()
3064 bnapi->events &= ~BNXT_RX_EVENT; in __bnxt_poll_work_done()
3066 if (bnapi->events & BNXT_AGG_EVENT) { in __bnxt_poll_work_done()
3067 struct bnxt_rx_ring_info *rxr = bnapi->rx_ring; in __bnxt_poll_work_done()
3069 bnxt_db_write(bp, &rxr->rx_agg_db, rxr->rx_agg_prod); in __bnxt_poll_work_done()
3070 bnapi->events &= ~BNXT_AGG_EVENT; in __bnxt_poll_work_done()
3077 struct bnxt_napi *bnapi = cpr->bnapi; in bnxt_poll_work()
3086 bnxt_db_cq(bp, &cpr->cp_db, cpr->cp_raw_cons); in bnxt_poll_work()
3095 struct bnxt *bp = bnapi->bp; in bnxt_poll_nitroa0()
3096 struct bnxt_cp_ring_info *cpr = &bnapi->cp_ring; in bnxt_poll_nitroa0()
3097 struct bnxt_rx_ring_info *rxr = bnapi->rx_ring; in bnxt_poll_nitroa0()
3101 u32 raw_cons = cpr->cp_raw_cons; in bnxt_poll_nitroa0()
3110 txcmp = &cpr->cp_desc_ring[CP_RING(cp_cons)][CP_IDX(cp_cons)]; in bnxt_poll_nitroa0()
3123 &cpr->cp_desc_ring[CP_RING(cp_cons)][CP_IDX(cp_cons)]; in bnxt_poll_nitroa0()
3129 rxcmp1->rx_cmp_cfa_code_errors_v2 |= in bnxt_poll_nitroa0()
3133 if (likely(rc == -EIO) && budget) in bnxt_poll_nitroa0()
3135 else if (rc == -EBUSY) /* partial completion */ in bnxt_poll_nitroa0()
3143 netdev_err(bp->dev, in bnxt_poll_nitroa0()
3152 cpr->cp_raw_cons = raw_cons; in bnxt_poll_nitroa0()
3153 BNXT_DB_CQ(&cpr->cp_db, cpr->cp_raw_cons); in bnxt_poll_nitroa0()
3154 bnxt_db_write(bp, &rxr->rx_db, rxr->rx_prod); in bnxt_poll_nitroa0()
3157 bnxt_db_write(bp, &rxr->rx_agg_db, rxr->rx_agg_prod); in bnxt_poll_nitroa0()
3163 BNXT_DB_CQ_ARM(&cpr->cp_db, cpr->cp_raw_cons); in bnxt_poll_nitroa0()
3171 struct bnxt *bp = bnapi->bp; in bnxt_poll()
3172 struct bnxt_cp_ring_info *cpr = &bnapi->cp_ring; in bnxt_poll()
3175 if (unlikely(test_bit(BNXT_STATE_FW_FATAL_COND, &bp->state))) { in bnxt_poll()
3180 work_done += bnxt_poll_work(bp, cpr, budget - work_done); in bnxt_poll()
3184 BNXT_DB_CQ_ARM(&cpr->cp_db, cpr->cp_raw_cons); in bnxt_poll()
3190 BNXT_DB_CQ_ARM(&cpr->cp_db, cpr->cp_raw_cons); in bnxt_poll()
3194 if ((bp->flags & BNXT_FLAG_DIM) && bnxt_vnic_is_active(bp)) { in bnxt_poll()
3197 dim_update_sample(cpr->event_ctr, in bnxt_poll()
3198 cpr->rx_packets, in bnxt_poll()
3199 cpr->rx_bytes, in bnxt_poll()
3201 net_dim(&cpr->dim, &dim_sample); in bnxt_poll()
3208 struct bnxt_cp_ring_info *cpr = &bnapi->cp_ring; in __bnxt_poll_cqs()
3211 for (i = 0; i < cpr->cp_ring_count; i++) { in __bnxt_poll_cqs()
3212 struct bnxt_cp_ring_info *cpr2 = &cpr->cp_ring_arr[i]; in __bnxt_poll_cqs()
3214 if (cpr2->had_nqe_notify) { in __bnxt_poll_cqs()
3216 budget - work_done); in __bnxt_poll_cqs()
3217 cpr->has_more_work |= cpr2->has_more_work; in __bnxt_poll_cqs()
3226 struct bnxt_cp_ring_info *cpr = &bnapi->cp_ring; in __bnxt_poll_cqs_done()
3229 for (i = 0; i < cpr->cp_ring_count; i++) { in __bnxt_poll_cqs_done()
3230 struct bnxt_cp_ring_info *cpr2 = &cpr->cp_ring_arr[i]; in __bnxt_poll_cqs_done()
3233 if (cpr2->had_work_done) { in __bnxt_poll_cqs_done()
3237 cpr2->had_nqe_notify = 0; in __bnxt_poll_cqs_done()
3238 tgl = cpr2->toggle; in __bnxt_poll_cqs_done()
3240 db = &cpr2->cp_db; in __bnxt_poll_cqs_done()
3242 db->db_key64 | dbr_type | DB_TOGGLE(tgl) | in __bnxt_poll_cqs_done()
3243 DB_RING_IDX(db, cpr2->cp_raw_cons), in __bnxt_poll_cqs_done()
3244 db->doorbell); in __bnxt_poll_cqs_done()
3245 cpr2->had_work_done = 0; in __bnxt_poll_cqs_done()
3254 struct bnxt_cp_ring_info *cpr = &bnapi->cp_ring; in bnxt_poll_p5()
3256 u32 raw_cons = cpr->cp_raw_cons; in bnxt_poll_p5()
3257 struct bnxt *bp = bnapi->bp; in bnxt_poll_p5()
3262 if (unlikely(test_bit(BNXT_STATE_FW_FATAL_COND, &bp->state))) { in bnxt_poll_p5()
3266 if (cpr->has_more_work) { in bnxt_poll_p5()
3267 cpr->has_more_work = 0; in bnxt_poll_p5()
3274 nqcmp = &cpr->nq_desc_ring[CP_RING(cons)][CP_IDX(cons)]; in bnxt_poll_p5()
3277 if (cpr->has_more_work) in bnxt_poll_p5()
3282 cpr->cp_raw_cons = raw_cons; in bnxt_poll_p5()
3284 BNXT_DB_NQ_ARM_P5(&cpr->cp_db, in bnxt_poll_p5()
3285 cpr->cp_raw_cons); in bnxt_poll_p5()
3294 type = le16_to_cpu(nqcmp->type); in bnxt_poll_p5()
3296 u32 idx = le32_to_cpu(nqcmp->cq_handle_low); in bnxt_poll_p5()
3306 cpr2 = &cpr->cp_ring_arr[idx]; in bnxt_poll_p5()
3307 cpr2->had_nqe_notify = 1; in bnxt_poll_p5()
3308 cpr2->toggle = NQE_CN_TOGGLE(type); in bnxt_poll_p5()
3310 budget - work_done); in bnxt_poll_p5()
3311 cpr->has_more_work |= cpr2->has_more_work; in bnxt_poll_p5()
3318 if (raw_cons != cpr->cp_raw_cons) { in bnxt_poll_p5()
3319 cpr->cp_raw_cons = raw_cons; in bnxt_poll_p5()
3320 BNXT_DB_NQ_P5(&cpr->cp_db, raw_cons); in bnxt_poll_p5()
3323 cpr_rx = &cpr->cp_ring_arr[0]; in bnxt_poll_p5()
3324 if (cpr_rx->cp_ring_type == BNXT_NQ_HDL_TYPE_RX && in bnxt_poll_p5()
3325 (bp->flags & BNXT_FLAG_DIM) && bnxt_vnic_is_active(bp)) { in bnxt_poll_p5()
3328 dim_update_sample(cpr->event_ctr, in bnxt_poll_p5()
3329 cpr_rx->rx_packets, in bnxt_poll_p5()
3330 cpr_rx->rx_bytes, in bnxt_poll_p5()
3332 net_dim(&cpr->dim, &dim_sample); in bnxt_poll_p5()
3340 struct pci_dev *pdev = bp->pdev; in bnxt_free_tx_skbs()
3342 if (!bp->tx_ring) in bnxt_free_tx_skbs()
3345 max_idx = bp->tx_nr_pages * TX_DESC_CNT; in bnxt_free_tx_skbs()
3346 for (i = 0; i < bp->tx_nr_rings; i++) { in bnxt_free_tx_skbs()
3347 struct bnxt_tx_ring_info *txr = &bp->tx_ring[i]; in bnxt_free_tx_skbs()
3350 if (!txr->tx_buf_ring) in bnxt_free_tx_skbs()
3354 struct bnxt_sw_tx_bd *tx_buf = &txr->tx_buf_ring[j]; in bnxt_free_tx_skbs()
3358 if (i < bp->tx_nr_rings_xdp && in bnxt_free_tx_skbs()
3359 tx_buf->action == XDP_REDIRECT) { in bnxt_free_tx_skbs()
3360 dma_unmap_single(&pdev->dev, in bnxt_free_tx_skbs()
3364 xdp_return_frame(tx_buf->xdpf); in bnxt_free_tx_skbs()
3365 tx_buf->action = 0; in bnxt_free_tx_skbs()
3366 tx_buf->xdpf = NULL; in bnxt_free_tx_skbs()
3371 skb = tx_buf->skb; in bnxt_free_tx_skbs()
3377 tx_buf->skb = NULL; in bnxt_free_tx_skbs()
3379 if (tx_buf->is_push) { in bnxt_free_tx_skbs()
3385 dma_unmap_single(&pdev->dev, in bnxt_free_tx_skbs()
3390 last = tx_buf->nr_frags; in bnxt_free_tx_skbs()
3393 int ring_idx = j & bp->tx_ring_mask; in bnxt_free_tx_skbs()
3394 skb_frag_t *frag = &skb_shinfo(skb)->frags[k]; in bnxt_free_tx_skbs()
3396 tx_buf = &txr->tx_buf_ring[ring_idx]; in bnxt_free_tx_skbs()
3398 &pdev->dev, in bnxt_free_tx_skbs()
3404 netdev_tx_reset_queue(netdev_get_tx_queue(bp->dev, i)); in bnxt_free_tx_skbs()
3412 max_idx = bp->rx_nr_pages * RX_DESC_CNT; in bnxt_free_one_rx_ring()
3415 struct bnxt_sw_rx_bd *rx_buf = &rxr->rx_buf_ring[i]; in bnxt_free_one_rx_ring()
3416 void *data = rx_buf->data; in bnxt_free_one_rx_ring()
3421 rx_buf->data = NULL; in bnxt_free_one_rx_ring()
3423 page_pool_recycle_direct(rxr->page_pool, data); in bnxt_free_one_rx_ring()
3425 page_pool_free_va(rxr->head_pool, data, true); in bnxt_free_one_rx_ring()
3433 max_idx = bp->rx_agg_nr_pages * RX_DESC_CNT; in bnxt_free_one_rx_agg_ring()
3436 struct bnxt_sw_rx_agg_bd *rx_agg_buf = &rxr->rx_agg_ring[i]; in bnxt_free_one_rx_agg_ring()
3437 struct page *page = rx_agg_buf->page; in bnxt_free_one_rx_agg_ring()
3442 rx_agg_buf->page = NULL; in bnxt_free_one_rx_agg_ring()
3443 __clear_bit(i, rxr->rx_agg_bmap); in bnxt_free_one_rx_agg_ring()
3445 page_pool_recycle_direct(rxr->page_pool, page); in bnxt_free_one_rx_agg_ring()
3454 for (i = 0; i < bp->max_tpa; i++) { in bnxt_free_one_tpa_info_data()
3455 struct bnxt_tpa_info *tpa_info = &rxr->rx_tpa[i]; in bnxt_free_one_tpa_info_data()
3456 u8 *data = tpa_info->data; in bnxt_free_one_tpa_info_data()
3461 tpa_info->data = NULL; in bnxt_free_one_tpa_info_data()
3462 page_pool_free_va(rxr->head_pool, data, false); in bnxt_free_one_tpa_info_data()
3471 if (!rxr->rx_tpa) in bnxt_free_one_rx_ring_skbs()
3477 if (!rxr->rx_buf_ring) in bnxt_free_one_rx_ring_skbs()
3483 if (!rxr->rx_agg_ring) in bnxt_free_one_rx_ring_skbs()
3489 map = rxr->rx_tpa_idx_map; in bnxt_free_one_rx_ring_skbs()
3491 memset(map->agg_idx_bmap, 0, sizeof(map->agg_idx_bmap)); in bnxt_free_one_rx_ring_skbs()
3498 if (!bp->rx_ring) in bnxt_free_rx_skbs()
3501 for (i = 0; i < bp->rx_nr_rings; i++) in bnxt_free_rx_skbs()
3502 bnxt_free_one_rx_ring_skbs(bp, &bp->rx_ring[i]); in bnxt_free_rx_skbs()
3513 u8 init_val = ctxm->init_value; in bnxt_init_ctx_mem()
3514 u16 offset = ctxm->init_offset; in bnxt_init_ctx_mem()
3524 for (i = 0; i < len; i += ctxm->entry_size) in bnxt_init_ctx_mem()
3535 head_page = head / rmem->page_size; in __bnxt_copy_ring()
3536 source_offset = head % rmem->page_size; in __bnxt_copy_ring()
3537 total_len = (tail - head) & MAX_CTX_BYTES_MASK; in __bnxt_copy_ring()
3541 max_bytes = (rmem->nr_pages - start_idx) * rmem->page_size - in __bnxt_copy_ring()
3547 len = min((size_t)(rmem->page_size - source_offset), rem_len); in __bnxt_copy_ring()
3549 memcpy(buf + offset, rmem->pg_arr[i] + source_offset, in __bnxt_copy_ring()
3552 rem_len -= len; in __bnxt_copy_ring()
3559 struct pci_dev *pdev = bp->pdev; in bnxt_free_ring()
3562 if (!rmem->pg_arr) in bnxt_free_ring()
3565 for (i = 0; i < rmem->nr_pages; i++) { in bnxt_free_ring()
3566 if (!rmem->pg_arr[i]) in bnxt_free_ring()
3569 dma_free_coherent(&pdev->dev, rmem->page_size, in bnxt_free_ring()
3570 rmem->pg_arr[i], rmem->dma_arr[i]); in bnxt_free_ring()
3572 rmem->pg_arr[i] = NULL; in bnxt_free_ring()
3575 if (rmem->pg_tbl) { in bnxt_free_ring()
3576 size_t pg_tbl_size = rmem->nr_pages * 8; in bnxt_free_ring()
3578 if (rmem->flags & BNXT_RMEM_USE_FULL_PAGE_FLAG) in bnxt_free_ring()
3579 pg_tbl_size = rmem->page_size; in bnxt_free_ring()
3580 dma_free_coherent(&pdev->dev, pg_tbl_size, in bnxt_free_ring()
3581 rmem->pg_tbl, rmem->pg_tbl_map); in bnxt_free_ring()
3582 rmem->pg_tbl = NULL; in bnxt_free_ring()
3584 if (rmem->vmem_size && *rmem->vmem) { in bnxt_free_ring()
3585 vfree(*rmem->vmem); in bnxt_free_ring()
3586 *rmem->vmem = NULL; in bnxt_free_ring()
3592 struct pci_dev *pdev = bp->pdev; in bnxt_alloc_ring()
3596 if (rmem->flags & (BNXT_RMEM_VALID_PTE_FLAG | BNXT_RMEM_RING_PTE_FLAG)) in bnxt_alloc_ring()
3598 if ((rmem->nr_pages > 1 || rmem->depth > 0) && !rmem->pg_tbl) { in bnxt_alloc_ring()
3599 size_t pg_tbl_size = rmem->nr_pages * 8; in bnxt_alloc_ring()
3601 if (rmem->flags & BNXT_RMEM_USE_FULL_PAGE_FLAG) in bnxt_alloc_ring()
3602 pg_tbl_size = rmem->page_size; in bnxt_alloc_ring()
3603 rmem->pg_tbl = dma_alloc_coherent(&pdev->dev, pg_tbl_size, in bnxt_alloc_ring()
3604 &rmem->pg_tbl_map, in bnxt_alloc_ring()
3606 if (!rmem->pg_tbl) in bnxt_alloc_ring()
3607 return -ENOMEM; in bnxt_alloc_ring()
3610 for (i = 0; i < rmem->nr_pages; i++) { in bnxt_alloc_ring()
3613 rmem->pg_arr[i] = dma_alloc_coherent(&pdev->dev, in bnxt_alloc_ring()
3614 rmem->page_size, in bnxt_alloc_ring()
3615 &rmem->dma_arr[i], in bnxt_alloc_ring()
3617 if (!rmem->pg_arr[i]) in bnxt_alloc_ring()
3618 return -ENOMEM; in bnxt_alloc_ring()
3620 if (rmem->ctx_mem) in bnxt_alloc_ring()
3621 bnxt_init_ctx_mem(rmem->ctx_mem, rmem->pg_arr[i], in bnxt_alloc_ring()
3622 rmem->page_size); in bnxt_alloc_ring()
3623 if (rmem->nr_pages > 1 || rmem->depth > 0) { in bnxt_alloc_ring()
3624 if (i == rmem->nr_pages - 2 && in bnxt_alloc_ring()
3625 (rmem->flags & BNXT_RMEM_RING_PTE_FLAG)) in bnxt_alloc_ring()
3627 else if (i == rmem->nr_pages - 1 && in bnxt_alloc_ring()
3628 (rmem->flags & BNXT_RMEM_RING_PTE_FLAG)) in bnxt_alloc_ring()
3630 rmem->pg_tbl[i] = in bnxt_alloc_ring()
3631 cpu_to_le64(rmem->dma_arr[i] | extra_bits); in bnxt_alloc_ring()
3635 if (rmem->vmem_size) { in bnxt_alloc_ring()
3636 *rmem->vmem = vzalloc(rmem->vmem_size); in bnxt_alloc_ring()
3637 if (!(*rmem->vmem)) in bnxt_alloc_ring()
3638 return -ENOMEM; in bnxt_alloc_ring()
3648 kfree(rxr->rx_tpa_idx_map); in bnxt_free_one_tpa_info()
3649 rxr->rx_tpa_idx_map = NULL; in bnxt_free_one_tpa_info()
3650 if (rxr->rx_tpa) { in bnxt_free_one_tpa_info()
3651 for (i = 0; i < bp->max_tpa; i++) { in bnxt_free_one_tpa_info()
3652 kfree(rxr->rx_tpa[i].agg_arr); in bnxt_free_one_tpa_info()
3653 rxr->rx_tpa[i].agg_arr = NULL; in bnxt_free_one_tpa_info()
3656 kfree(rxr->rx_tpa); in bnxt_free_one_tpa_info()
3657 rxr->rx_tpa = NULL; in bnxt_free_one_tpa_info()
3664 for (i = 0; i < bp->rx_nr_rings; i++) { in bnxt_free_tpa_info()
3665 struct bnxt_rx_ring_info *rxr = &bp->rx_ring[i]; in bnxt_free_tpa_info()
3677 rxr->rx_tpa = kcalloc(bp->max_tpa, sizeof(struct bnxt_tpa_info), in bnxt_alloc_one_tpa_info()
3679 if (!rxr->rx_tpa) in bnxt_alloc_one_tpa_info()
3680 return -ENOMEM; in bnxt_alloc_one_tpa_info()
3682 if (!(bp->flags & BNXT_FLAG_CHIP_P5_PLUS)) in bnxt_alloc_one_tpa_info()
3684 for (i = 0; i < bp->max_tpa; i++) { in bnxt_alloc_one_tpa_info()
3687 return -ENOMEM; in bnxt_alloc_one_tpa_info()
3688 rxr->rx_tpa[i].agg_arr = agg; in bnxt_alloc_one_tpa_info()
3690 rxr->rx_tpa_idx_map = kzalloc(sizeof(*rxr->rx_tpa_idx_map), in bnxt_alloc_one_tpa_info()
3692 if (!rxr->rx_tpa_idx_map) in bnxt_alloc_one_tpa_info()
3693 return -ENOMEM; in bnxt_alloc_one_tpa_info()
3702 bp->max_tpa = MAX_TPA; in bnxt_alloc_tpa_info()
3703 if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) { in bnxt_alloc_tpa_info()
3704 if (!bp->max_tpa_v2) in bnxt_alloc_tpa_info()
3706 bp->max_tpa = max_t(u16, bp->max_tpa_v2, MAX_TPA_P5); in bnxt_alloc_tpa_info()
3709 for (i = 0; i < bp->rx_nr_rings; i++) { in bnxt_alloc_tpa_info()
3710 struct bnxt_rx_ring_info *rxr = &bp->rx_ring[i]; in bnxt_alloc_tpa_info()
3723 if (!bp->rx_ring) in bnxt_free_rx_rings()
3727 for (i = 0; i < bp->rx_nr_rings; i++) { in bnxt_free_rx_rings()
3728 struct bnxt_rx_ring_info *rxr = &bp->rx_ring[i]; in bnxt_free_rx_rings()
3731 if (rxr->xdp_prog) in bnxt_free_rx_rings()
3732 bpf_prog_put(rxr->xdp_prog); in bnxt_free_rx_rings()
3734 if (xdp_rxq_info_is_reg(&rxr->xdp_rxq)) in bnxt_free_rx_rings()
3735 xdp_rxq_info_unreg(&rxr->xdp_rxq); in bnxt_free_rx_rings()
3737 page_pool_destroy(rxr->page_pool); in bnxt_free_rx_rings()
3739 page_pool_destroy(rxr->head_pool); in bnxt_free_rx_rings()
3740 rxr->page_pool = rxr->head_pool = NULL; in bnxt_free_rx_rings()
3742 kfree(rxr->rx_agg_bmap); in bnxt_free_rx_rings()
3743 rxr->rx_agg_bmap = NULL; in bnxt_free_rx_rings()
3745 ring = &rxr->rx_ring_struct; in bnxt_free_rx_rings()
3746 bnxt_free_ring(bp, &ring->ring_mem); in bnxt_free_rx_rings()
3748 ring = &rxr->rx_agg_ring_struct; in bnxt_free_rx_rings()
3749 bnxt_free_ring(bp, &ring->ring_mem); in bnxt_free_rx_rings()
3760 pp.pool_size = bp->rx_agg_ring_size; in bnxt_alloc_rx_page_pool()
3762 pp.pool_size += bp->rx_ring_size; in bnxt_alloc_rx_page_pool()
3764 pp.napi = &rxr->bnapi->napi; in bnxt_alloc_rx_page_pool()
3765 pp.netdev = bp->dev; in bnxt_alloc_rx_page_pool()
3766 pp.dev = &bp->pdev->dev; in bnxt_alloc_rx_page_pool()
3767 pp.dma_dir = bp->rx_dir; in bnxt_alloc_rx_page_pool()
3774 rxr->page_pool = pool; in bnxt_alloc_rx_page_pool()
3777 pp.pool_size = max(bp->rx_ring_size, 1024); in bnxt_alloc_rx_page_pool()
3782 rxr->head_pool = pool; in bnxt_alloc_rx_page_pool()
3787 page_pool_destroy(rxr->page_pool); in bnxt_alloc_rx_page_pool()
3788 rxr->page_pool = NULL; in bnxt_alloc_rx_page_pool()
3796 rxr->rx_agg_bmap_size = bp->rx_agg_ring_mask + 1; in bnxt_alloc_rx_agg_bmap()
3797 mem_size = rxr->rx_agg_bmap_size / 8; in bnxt_alloc_rx_agg_bmap()
3798 rxr->rx_agg_bmap = kzalloc(mem_size, GFP_KERNEL); in bnxt_alloc_rx_agg_bmap()
3799 if (!rxr->rx_agg_bmap) in bnxt_alloc_rx_agg_bmap()
3800 return -ENOMEM; in bnxt_alloc_rx_agg_bmap()
3807 int numa_node = dev_to_node(&bp->pdev->dev); in bnxt_alloc_rx_rings()
3810 if (!bp->rx_ring) in bnxt_alloc_rx_rings()
3811 return -ENOMEM; in bnxt_alloc_rx_rings()
3813 if (bp->flags & BNXT_FLAG_AGG_RINGS) in bnxt_alloc_rx_rings()
3816 for (i = 0; i < bp->rx_nr_rings; i++) { in bnxt_alloc_rx_rings()
3817 struct bnxt_rx_ring_info *rxr = &bp->rx_ring[i]; in bnxt_alloc_rx_rings()
3821 ring = &rxr->rx_ring_struct; in bnxt_alloc_rx_rings()
3825 netdev_dbg(bp->dev, "Allocating page pool for rx_ring[%d] on numa_node: %d\n", in bnxt_alloc_rx_rings()
3831 rc = xdp_rxq_info_reg(&rxr->xdp_rxq, bp->dev, i, 0); in bnxt_alloc_rx_rings()
3835 rc = xdp_rxq_info_reg_mem_model(&rxr->xdp_rxq, in bnxt_alloc_rx_rings()
3837 rxr->page_pool); in bnxt_alloc_rx_rings()
3839 xdp_rxq_info_unreg(&rxr->xdp_rxq); in bnxt_alloc_rx_rings()
3843 rc = bnxt_alloc_ring(bp, &ring->ring_mem); in bnxt_alloc_rx_rings()
3847 ring->grp_idx = i; in bnxt_alloc_rx_rings()
3849 ring = &rxr->rx_agg_ring_struct; in bnxt_alloc_rx_rings()
3850 rc = bnxt_alloc_ring(bp, &ring->ring_mem); in bnxt_alloc_rx_rings()
3854 ring->grp_idx = i; in bnxt_alloc_rx_rings()
3860 if (bp->flags & BNXT_FLAG_TPA) in bnxt_alloc_rx_rings()
3868 struct pci_dev *pdev = bp->pdev; in bnxt_free_tx_rings()
3870 if (!bp->tx_ring) in bnxt_free_tx_rings()
3873 for (i = 0; i < bp->tx_nr_rings; i++) { in bnxt_free_tx_rings()
3874 struct bnxt_tx_ring_info *txr = &bp->tx_ring[i]; in bnxt_free_tx_rings()
3877 if (txr->tx_push) { in bnxt_free_tx_rings()
3878 dma_free_coherent(&pdev->dev, bp->tx_push_size, in bnxt_free_tx_rings()
3879 txr->tx_push, txr->tx_push_mapping); in bnxt_free_tx_rings()
3880 txr->tx_push = NULL; in bnxt_free_tx_rings()
3883 ring = &txr->tx_ring_struct; in bnxt_free_tx_rings()
3885 bnxt_free_ring(bp, &ring->ring_mem); in bnxt_free_tx_rings()
3890 ((tc) * (bp)->tx_nr_rings_per_tc)
3893 ((tx) % (bp)->tx_nr_rings_per_tc)
3896 ((tx) / (bp)->tx_nr_rings_per_tc)
3901 struct pci_dev *pdev = bp->pdev; in bnxt_alloc_tx_rings()
3903 bp->tx_push_size = 0; in bnxt_alloc_tx_rings()
3904 if (bp->tx_push_thresh) { in bnxt_alloc_tx_rings()
3908 bp->tx_push_thresh); in bnxt_alloc_tx_rings()
3912 bp->tx_push_thresh = 0; in bnxt_alloc_tx_rings()
3915 bp->tx_push_size = push_size; in bnxt_alloc_tx_rings()
3918 for (i = 0, j = 0; i < bp->tx_nr_rings; i++) { in bnxt_alloc_tx_rings()
3919 struct bnxt_tx_ring_info *txr = &bp->tx_ring[i]; in bnxt_alloc_tx_rings()
3923 ring = &txr->tx_ring_struct; in bnxt_alloc_tx_rings()
3925 rc = bnxt_alloc_ring(bp, &ring->ring_mem); in bnxt_alloc_tx_rings()
3929 ring->grp_idx = txr->bnapi->index; in bnxt_alloc_tx_rings()
3930 if (bp->tx_push_size) { in bnxt_alloc_tx_rings()
3933 /* One pre-allocated DMA buffer to backup in bnxt_alloc_tx_rings()
3936 txr->tx_push = dma_alloc_coherent(&pdev->dev, in bnxt_alloc_tx_rings()
3937 bp->tx_push_size, in bnxt_alloc_tx_rings()
3938 &txr->tx_push_mapping, in bnxt_alloc_tx_rings()
3941 if (!txr->tx_push) in bnxt_alloc_tx_rings()
3942 return -ENOMEM; in bnxt_alloc_tx_rings()
3944 mapping = txr->tx_push_mapping + in bnxt_alloc_tx_rings()
3946 txr->data_mapping = cpu_to_le64(mapping); in bnxt_alloc_tx_rings()
3948 qidx = bp->tc_to_qidx[j]; in bnxt_alloc_tx_rings()
3949 ring->queue_id = bp->q_info[qidx].queue_id; in bnxt_alloc_tx_rings()
3950 spin_lock_init(&txr->xdp_tx_lock); in bnxt_alloc_tx_rings()
3951 if (i < bp->tx_nr_rings_xdp) in bnxt_alloc_tx_rings()
3953 if (BNXT_RING_TO_TC_OFF(bp, i) == (bp->tx_nr_rings_per_tc - 1)) in bnxt_alloc_tx_rings()
3961 struct bnxt_ring_struct *ring = &cpr->cp_ring_struct; in bnxt_free_cp_arrays()
3963 kfree(cpr->cp_desc_ring); in bnxt_free_cp_arrays()
3964 cpr->cp_desc_ring = NULL; in bnxt_free_cp_arrays()
3965 ring->ring_mem.pg_arr = NULL; in bnxt_free_cp_arrays()
3966 kfree(cpr->cp_desc_mapping); in bnxt_free_cp_arrays()
3967 cpr->cp_desc_mapping = NULL; in bnxt_free_cp_arrays()
3968 ring->ring_mem.dma_arr = NULL; in bnxt_free_cp_arrays()
3973 cpr->cp_desc_ring = kcalloc(n, sizeof(*cpr->cp_desc_ring), GFP_KERNEL); in bnxt_alloc_cp_arrays()
3974 if (!cpr->cp_desc_ring) in bnxt_alloc_cp_arrays()
3975 return -ENOMEM; in bnxt_alloc_cp_arrays()
3976 cpr->cp_desc_mapping = kcalloc(n, sizeof(*cpr->cp_desc_mapping), in bnxt_alloc_cp_arrays()
3978 if (!cpr->cp_desc_mapping) in bnxt_alloc_cp_arrays()
3979 return -ENOMEM; in bnxt_alloc_cp_arrays()
3987 if (!bp->bnapi) in bnxt_free_all_cp_arrays()
3989 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_free_all_cp_arrays()
3990 struct bnxt_napi *bnapi = bp->bnapi[i]; in bnxt_free_all_cp_arrays()
3994 bnxt_free_cp_arrays(&bnapi->cp_ring); in bnxt_free_all_cp_arrays()
4000 int i, n = bp->cp_nr_pages; in bnxt_alloc_all_cp_arrays()
4002 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_alloc_all_cp_arrays()
4003 struct bnxt_napi *bnapi = bp->bnapi[i]; in bnxt_alloc_all_cp_arrays()
4008 rc = bnxt_alloc_cp_arrays(&bnapi->cp_ring, n); in bnxt_alloc_all_cp_arrays()
4019 if (!bp->bnapi) in bnxt_free_cp_rings()
4022 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_free_cp_rings()
4023 struct bnxt_napi *bnapi = bp->bnapi[i]; in bnxt_free_cp_rings()
4031 cpr = &bnapi->cp_ring; in bnxt_free_cp_rings()
4032 ring = &cpr->cp_ring_struct; in bnxt_free_cp_rings()
4034 bnxt_free_ring(bp, &ring->ring_mem); in bnxt_free_cp_rings()
4036 if (!cpr->cp_ring_arr) in bnxt_free_cp_rings()
4039 for (j = 0; j < cpr->cp_ring_count; j++) { in bnxt_free_cp_rings()
4040 struct bnxt_cp_ring_info *cpr2 = &cpr->cp_ring_arr[j]; in bnxt_free_cp_rings()
4042 ring = &cpr2->cp_ring_struct; in bnxt_free_cp_rings()
4043 bnxt_free_ring(bp, &ring->ring_mem); in bnxt_free_cp_rings()
4046 kfree(cpr->cp_ring_arr); in bnxt_free_cp_rings()
4047 cpr->cp_ring_arr = NULL; in bnxt_free_cp_rings()
4048 cpr->cp_ring_count = 0; in bnxt_free_cp_rings()
4059 rc = bnxt_alloc_cp_arrays(cpr, bp->cp_nr_pages); in bnxt_alloc_cp_sub_ring()
4062 return -ENOMEM; in bnxt_alloc_cp_sub_ring()
4064 ring = &cpr->cp_ring_struct; in bnxt_alloc_cp_sub_ring()
4065 rmem = &ring->ring_mem; in bnxt_alloc_cp_sub_ring()
4066 rmem->nr_pages = bp->cp_nr_pages; in bnxt_alloc_cp_sub_ring()
4067 rmem->page_size = HW_CMPD_RING_SIZE; in bnxt_alloc_cp_sub_ring()
4068 rmem->pg_arr = (void **)cpr->cp_desc_ring; in bnxt_alloc_cp_sub_ring()
4069 rmem->dma_arr = cpr->cp_desc_mapping; in bnxt_alloc_cp_sub_ring()
4070 rmem->flags = BNXT_RMEM_RING_PTE_FLAG; in bnxt_alloc_cp_sub_ring()
4081 bool sh = !!(bp->flags & BNXT_FLAG_SHARED_RINGS); in bnxt_alloc_cp_rings()
4083 int tcs = bp->num_tc; in bnxt_alloc_cp_rings()
4088 for (i = 0, j = 0; i < bp->cp_nr_rings; i++) { in bnxt_alloc_cp_rings()
4089 struct bnxt_napi *bnapi = bp->bnapi[i]; in bnxt_alloc_cp_rings()
4098 cpr = &bnapi->cp_ring; in bnxt_alloc_cp_rings()
4099 cpr->bnapi = bnapi; in bnxt_alloc_cp_rings()
4100 ring = &cpr->cp_ring_struct; in bnxt_alloc_cp_rings()
4102 rc = bnxt_alloc_ring(bp, &ring->ring_mem); in bnxt_alloc_cp_rings()
4106 ring->map_idx = ulp_msix + i; in bnxt_alloc_cp_rings()
4108 if (!(bp->flags & BNXT_FLAG_CHIP_P5_PLUS)) in bnxt_alloc_cp_rings()
4111 if (i < bp->rx_nr_rings) { in bnxt_alloc_cp_rings()
4115 if (i < bp->tx_nr_rings_xdp) { in bnxt_alloc_cp_rings()
4118 } else if ((sh && i < bp->tx_nr_rings) || in bnxt_alloc_cp_rings()
4119 (!sh && i >= bp->rx_nr_rings)) { in bnxt_alloc_cp_rings()
4124 cpr->cp_ring_arr = kcalloc(cp_count, sizeof(*cpr), in bnxt_alloc_cp_rings()
4126 if (!cpr->cp_ring_arr) in bnxt_alloc_cp_rings()
4127 return -ENOMEM; in bnxt_alloc_cp_rings()
4128 cpr->cp_ring_count = cp_count; in bnxt_alloc_cp_rings()
4131 cpr2 = &cpr->cp_ring_arr[k]; in bnxt_alloc_cp_rings()
4135 cpr2->bnapi = bnapi; in bnxt_alloc_cp_rings()
4136 cpr2->sw_stats = cpr->sw_stats; in bnxt_alloc_cp_rings()
4137 cpr2->cp_idx = k; in bnxt_alloc_cp_rings()
4139 bp->rx_ring[i].rx_cpr = cpr2; in bnxt_alloc_cp_rings()
4140 cpr2->cp_ring_type = BNXT_NQ_HDL_TYPE_RX; in bnxt_alloc_cp_rings()
4142 int n, tc = k - rx; in bnxt_alloc_cp_rings()
4145 bp->tx_ring[n].tx_cpr = cpr2; in bnxt_alloc_cp_rings()
4146 cpr2->cp_ring_type = BNXT_NQ_HDL_TYPE_TX; in bnxt_alloc_cp_rings()
4161 ring = &rxr->rx_ring_struct; in bnxt_init_rx_ring_struct()
4162 rmem = &ring->ring_mem; in bnxt_init_rx_ring_struct()
4163 rmem->nr_pages = bp->rx_nr_pages; in bnxt_init_rx_ring_struct()
4164 rmem->page_size = HW_RXBD_RING_SIZE; in bnxt_init_rx_ring_struct()
4165 rmem->pg_arr = (void **)rxr->rx_desc_ring; in bnxt_init_rx_ring_struct()
4166 rmem->dma_arr = rxr->rx_desc_mapping; in bnxt_init_rx_ring_struct()
4167 rmem->vmem_size = SW_RXBD_RING_SIZE * bp->rx_nr_pages; in bnxt_init_rx_ring_struct()
4168 rmem->vmem = (void **)&rxr->rx_buf_ring; in bnxt_init_rx_ring_struct()
4170 ring = &rxr->rx_agg_ring_struct; in bnxt_init_rx_ring_struct()
4171 rmem = &ring->ring_mem; in bnxt_init_rx_ring_struct()
4172 rmem->nr_pages = bp->rx_agg_nr_pages; in bnxt_init_rx_ring_struct()
4173 rmem->page_size = HW_RXBD_RING_SIZE; in bnxt_init_rx_ring_struct()
4174 rmem->pg_arr = (void **)rxr->rx_agg_desc_ring; in bnxt_init_rx_ring_struct()
4175 rmem->dma_arr = rxr->rx_agg_desc_mapping; in bnxt_init_rx_ring_struct()
4176 rmem->vmem_size = SW_RXBD_AGG_RING_SIZE * bp->rx_agg_nr_pages; in bnxt_init_rx_ring_struct()
4177 rmem->vmem = (void **)&rxr->rx_agg_ring; in bnxt_init_rx_ring_struct()
4187 rxr->page_pool->p.napi = NULL; in bnxt_reset_rx_ring_struct()
4188 rxr->page_pool = NULL; in bnxt_reset_rx_ring_struct()
4189 memset(&rxr->xdp_rxq, 0, sizeof(struct xdp_rxq_info)); in bnxt_reset_rx_ring_struct()
4191 ring = &rxr->rx_ring_struct; in bnxt_reset_rx_ring_struct()
4192 rmem = &ring->ring_mem; in bnxt_reset_rx_ring_struct()
4193 rmem->pg_tbl = NULL; in bnxt_reset_rx_ring_struct()
4194 rmem->pg_tbl_map = 0; in bnxt_reset_rx_ring_struct()
4195 for (i = 0; i < rmem->nr_pages; i++) { in bnxt_reset_rx_ring_struct()
4196 rmem->pg_arr[i] = NULL; in bnxt_reset_rx_ring_struct()
4197 rmem->dma_arr[i] = 0; in bnxt_reset_rx_ring_struct()
4199 *rmem->vmem = NULL; in bnxt_reset_rx_ring_struct()
4201 ring = &rxr->rx_agg_ring_struct; in bnxt_reset_rx_ring_struct()
4202 rmem = &ring->ring_mem; in bnxt_reset_rx_ring_struct()
4203 rmem->pg_tbl = NULL; in bnxt_reset_rx_ring_struct()
4204 rmem->pg_tbl_map = 0; in bnxt_reset_rx_ring_struct()
4205 for (i = 0; i < rmem->nr_pages; i++) { in bnxt_reset_rx_ring_struct()
4206 rmem->pg_arr[i] = NULL; in bnxt_reset_rx_ring_struct()
4207 rmem->dma_arr[i] = 0; in bnxt_reset_rx_ring_struct()
4209 *rmem->vmem = NULL; in bnxt_reset_rx_ring_struct()
4216 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_init_ring_struct()
4217 struct bnxt_napi *bnapi = bp->bnapi[i]; in bnxt_init_ring_struct()
4227 cpr = &bnapi->cp_ring; in bnxt_init_ring_struct()
4228 ring = &cpr->cp_ring_struct; in bnxt_init_ring_struct()
4229 rmem = &ring->ring_mem; in bnxt_init_ring_struct()
4230 rmem->nr_pages = bp->cp_nr_pages; in bnxt_init_ring_struct()
4231 rmem->page_size = HW_CMPD_RING_SIZE; in bnxt_init_ring_struct()
4232 rmem->pg_arr = (void **)cpr->cp_desc_ring; in bnxt_init_ring_struct()
4233 rmem->dma_arr = cpr->cp_desc_mapping; in bnxt_init_ring_struct()
4234 rmem->vmem_size = 0; in bnxt_init_ring_struct()
4236 rxr = bnapi->rx_ring; in bnxt_init_ring_struct()
4240 ring = &rxr->rx_ring_struct; in bnxt_init_ring_struct()
4241 rmem = &ring->ring_mem; in bnxt_init_ring_struct()
4242 rmem->nr_pages = bp->rx_nr_pages; in bnxt_init_ring_struct()
4243 rmem->page_size = HW_RXBD_RING_SIZE; in bnxt_init_ring_struct()
4244 rmem->pg_arr = (void **)rxr->rx_desc_ring; in bnxt_init_ring_struct()
4245 rmem->dma_arr = rxr->rx_desc_mapping; in bnxt_init_ring_struct()
4246 rmem->vmem_size = SW_RXBD_RING_SIZE * bp->rx_nr_pages; in bnxt_init_ring_struct()
4247 rmem->vmem = (void **)&rxr->rx_buf_ring; in bnxt_init_ring_struct()
4249 ring = &rxr->rx_agg_ring_struct; in bnxt_init_ring_struct()
4250 rmem = &ring->ring_mem; in bnxt_init_ring_struct()
4251 rmem->nr_pages = bp->rx_agg_nr_pages; in bnxt_init_ring_struct()
4252 rmem->page_size = HW_RXBD_RING_SIZE; in bnxt_init_ring_struct()
4253 rmem->pg_arr = (void **)rxr->rx_agg_desc_ring; in bnxt_init_ring_struct()
4254 rmem->dma_arr = rxr->rx_agg_desc_mapping; in bnxt_init_ring_struct()
4255 rmem->vmem_size = SW_RXBD_AGG_RING_SIZE * bp->rx_agg_nr_pages; in bnxt_init_ring_struct()
4256 rmem->vmem = (void **)&rxr->rx_agg_ring; in bnxt_init_ring_struct()
4260 ring = &txr->tx_ring_struct; in bnxt_init_ring_struct()
4261 rmem = &ring->ring_mem; in bnxt_init_ring_struct()
4262 rmem->nr_pages = bp->tx_nr_pages; in bnxt_init_ring_struct()
4263 rmem->page_size = HW_TXBD_RING_SIZE; in bnxt_init_ring_struct()
4264 rmem->pg_arr = (void **)txr->tx_desc_ring; in bnxt_init_ring_struct()
4265 rmem->dma_arr = txr->tx_desc_mapping; in bnxt_init_ring_struct()
4266 rmem->vmem_size = SW_TXBD_RING_SIZE * bp->tx_nr_pages; in bnxt_init_ring_struct()
4267 rmem->vmem = (void **)&txr->tx_buf_ring; in bnxt_init_ring_struct()
4278 rx_buf_ring = (struct rx_bd **)ring->ring_mem.pg_arr; in bnxt_init_rxbd_pages()
4279 for (i = 0, prod = 0; i < ring->ring_mem.nr_pages; i++) { in bnxt_init_rxbd_pages()
4288 rxbd->rx_bd_len_flags_type = cpu_to_le32(type); in bnxt_init_rxbd_pages()
4289 rxbd->rx_bd_opaque = prod; in bnxt_init_rxbd_pages()
4301 prod = rxr->rx_prod; in bnxt_alloc_one_rx_ring_skb()
4302 for (i = 0; i < bp->rx_ring_size; i++) { in bnxt_alloc_one_rx_ring_skb()
4304 netdev_warn(bp->dev, "init'ed rx ring %d with %d/%d skbs only\n", in bnxt_alloc_one_rx_ring_skb()
4305 ring_nr, i, bp->rx_ring_size); in bnxt_alloc_one_rx_ring_skb()
4310 rxr->rx_prod = prod; in bnxt_alloc_one_rx_ring_skb()
4320 prod = rxr->rx_agg_prod; in bnxt_alloc_one_rx_ring_page()
4321 for (i = 0; i < bp->rx_agg_ring_size; i++) { in bnxt_alloc_one_rx_ring_page()
4323 netdev_warn(bp->dev, "init'ed rx ring %d with %d/%d pages only\n", in bnxt_alloc_one_rx_ring_page()
4324 ring_nr, i, bp->rx_ring_size); in bnxt_alloc_one_rx_ring_page()
4329 rxr->rx_agg_prod = prod; in bnxt_alloc_one_rx_ring_page()
4339 for (i = 0; i < bp->max_tpa; i++) { in bnxt_alloc_one_tpa_info_data()
4343 return -ENOMEM; in bnxt_alloc_one_tpa_info_data()
4345 rxr->rx_tpa[i].data = data; in bnxt_alloc_one_tpa_info_data()
4346 rxr->rx_tpa[i].data_ptr = data + bp->rx_offset; in bnxt_alloc_one_tpa_info_data()
4347 rxr->rx_tpa[i].mapping = mapping; in bnxt_alloc_one_tpa_info_data()
4355 struct bnxt_rx_ring_info *rxr = &bp->rx_ring[ring_nr]; in bnxt_alloc_one_rx_ring()
4360 if (!(bp->flags & BNXT_FLAG_AGG_RINGS)) in bnxt_alloc_one_rx_ring()
4365 if (rxr->rx_tpa) { in bnxt_alloc_one_rx_ring()
4379 type = (bp->rx_buf_use_size << RX_BD_LEN_SHIFT) | in bnxt_init_one_rx_ring_rxbd()
4385 ring = &rxr->rx_ring_struct; in bnxt_init_one_rx_ring_rxbd()
4387 ring->fw_ring_id = INVALID_HW_RING_ID; in bnxt_init_one_rx_ring_rxbd()
4396 ring = &rxr->rx_agg_ring_struct; in bnxt_init_one_rx_agg_ring_rxbd()
4397 ring->fw_ring_id = INVALID_HW_RING_ID; in bnxt_init_one_rx_agg_ring_rxbd()
4398 if ((bp->flags & BNXT_FLAG_AGG_RINGS)) { in bnxt_init_one_rx_agg_ring_rxbd()
4410 rxr = &bp->rx_ring[ring_nr]; in bnxt_init_one_rx_ring()
4413 netif_queue_set_napi(bp->dev, ring_nr, NETDEV_QUEUE_TYPE_RX, in bnxt_init_one_rx_ring()
4414 &rxr->bnapi->napi); in bnxt_init_one_rx_ring()
4416 if (BNXT_RX_PAGE_MODE(bp) && bp->xdp_prog) { in bnxt_init_one_rx_ring()
4417 bpf_prog_add(bp->xdp_prog, 1); in bnxt_init_one_rx_ring()
4418 rxr->xdp_prog = bp->xdp_prog; in bnxt_init_one_rx_ring()
4430 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_init_cp_rings()
4431 struct bnxt_cp_ring_info *cpr = &bp->bnapi[i]->cp_ring; in bnxt_init_cp_rings()
4432 struct bnxt_ring_struct *ring = &cpr->cp_ring_struct; in bnxt_init_cp_rings()
4434 ring->fw_ring_id = INVALID_HW_RING_ID; in bnxt_init_cp_rings()
4435 cpr->rx_ring_coal.coal_ticks = bp->rx_coal.coal_ticks; in bnxt_init_cp_rings()
4436 cpr->rx_ring_coal.coal_bufs = bp->rx_coal.coal_bufs; in bnxt_init_cp_rings()
4437 if (!cpr->cp_ring_arr) in bnxt_init_cp_rings()
4439 for (j = 0; j < cpr->cp_ring_count; j++) { in bnxt_init_cp_rings()
4440 struct bnxt_cp_ring_info *cpr2 = &cpr->cp_ring_arr[j]; in bnxt_init_cp_rings()
4442 ring = &cpr2->cp_ring_struct; in bnxt_init_cp_rings()
4443 ring->fw_ring_id = INVALID_HW_RING_ID; in bnxt_init_cp_rings()
4444 cpr2->rx_ring_coal.coal_ticks = bp->rx_coal.coal_ticks; in bnxt_init_cp_rings()
4445 cpr2->rx_ring_coal.coal_bufs = bp->rx_coal.coal_bufs; in bnxt_init_cp_rings()
4455 bp->rx_offset = NET_IP_ALIGN + XDP_PACKET_HEADROOM; in bnxt_init_rx_rings()
4456 bp->rx_dma_offset = XDP_PACKET_HEADROOM; in bnxt_init_rx_rings()
4458 bp->rx_offset = BNXT_RX_OFFSET; in bnxt_init_rx_rings()
4459 bp->rx_dma_offset = BNXT_RX_DMA_OFFSET; in bnxt_init_rx_rings()
4462 for (i = 0; i < bp->rx_nr_rings; i++) { in bnxt_init_rx_rings()
4475 bp->tx_wake_thresh = max_t(int, bp->tx_ring_size / 2, in bnxt_init_tx_rings()
4478 for (i = 0; i < bp->tx_nr_rings; i++) { in bnxt_init_tx_rings()
4479 struct bnxt_tx_ring_info *txr = &bp->tx_ring[i]; in bnxt_init_tx_rings()
4480 struct bnxt_ring_struct *ring = &txr->tx_ring_struct; in bnxt_init_tx_rings()
4482 ring->fw_ring_id = INVALID_HW_RING_ID; in bnxt_init_tx_rings()
4484 if (i >= bp->tx_nr_rings_xdp) in bnxt_init_tx_rings()
4485 netif_queue_set_napi(bp->dev, i - bp->tx_nr_rings_xdp, in bnxt_init_tx_rings()
4487 &txr->bnapi->napi); in bnxt_init_tx_rings()
4495 kfree(bp->grp_info); in bnxt_free_ring_grps()
4496 bp->grp_info = NULL; in bnxt_free_ring_grps()
4504 bp->grp_info = kcalloc(bp->cp_nr_rings, in bnxt_init_ring_grps()
4507 if (!bp->grp_info) in bnxt_init_ring_grps()
4508 return -ENOMEM; in bnxt_init_ring_grps()
4510 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_init_ring_grps()
4512 bp->grp_info[i].fw_stats_ctx = INVALID_HW_RING_ID; in bnxt_init_ring_grps()
4513 bp->grp_info[i].fw_grp_id = INVALID_HW_RING_ID; in bnxt_init_ring_grps()
4514 bp->grp_info[i].rx_fw_ring_id = INVALID_HW_RING_ID; in bnxt_init_ring_grps()
4515 bp->grp_info[i].agg_fw_ring_id = INVALID_HW_RING_ID; in bnxt_init_ring_grps()
4516 bp->grp_info[i].cp_fw_ring_id = INVALID_HW_RING_ID; in bnxt_init_ring_grps()
4523 kfree(bp->vnic_info); in bnxt_free_vnics()
4524 bp->vnic_info = NULL; in bnxt_free_vnics()
4525 bp->nr_vnics = 0; in bnxt_free_vnics()
4533 if (bp->flags & BNXT_FLAG_RFS) { in bnxt_alloc_vnics()
4536 else if (!(bp->flags & BNXT_FLAG_CHIP_P5_PLUS)) in bnxt_alloc_vnics()
4537 num_vnics += bp->rx_nr_rings; in bnxt_alloc_vnics()
4544 bp->vnic_info = kcalloc(num_vnics, sizeof(struct bnxt_vnic_info), in bnxt_alloc_vnics()
4546 if (!bp->vnic_info) in bnxt_alloc_vnics()
4547 return -ENOMEM; in bnxt_alloc_vnics()
4549 bp->nr_vnics = num_vnics; in bnxt_alloc_vnics()
4555 struct bnxt_vnic_info *vnic0 = &bp->vnic_info[BNXT_VNIC_DEFAULT]; in bnxt_init_vnics()
4558 for (i = 0; i < bp->nr_vnics; i++) { in bnxt_init_vnics()
4559 struct bnxt_vnic_info *vnic = &bp->vnic_info[i]; in bnxt_init_vnics()
4562 vnic->fw_vnic_id = INVALID_HW_RING_ID; in bnxt_init_vnics()
4563 vnic->vnic_id = i; in bnxt_init_vnics()
4565 vnic->fw_rss_cos_lb_ctx[j] = INVALID_HW_RING_ID; in bnxt_init_vnics()
4567 vnic->fw_l2_ctx_id = INVALID_HW_RING_ID; in bnxt_init_vnics()
4569 if (bp->vnic_info[i].rss_hash_key) { in bnxt_init_vnics()
4571 u8 *key = (void *)vnic->rss_hash_key; in bnxt_init_vnics()
4574 if (!bp->rss_hash_key_valid && in bnxt_init_vnics()
4575 !bp->rss_hash_key_updated) { in bnxt_init_vnics()
4576 get_random_bytes(bp->rss_hash_key, in bnxt_init_vnics()
4578 bp->rss_hash_key_updated = true; in bnxt_init_vnics()
4581 memcpy(vnic->rss_hash_key, bp->rss_hash_key, in bnxt_init_vnics()
4584 if (!bp->rss_hash_key_updated) in bnxt_init_vnics()
4587 bp->rss_hash_key_updated = false; in bnxt_init_vnics()
4588 bp->rss_hash_key_valid = true; in bnxt_init_vnics()
4590 bp->toeplitz_prefix = 0; in bnxt_init_vnics()
4592 bp->toeplitz_prefix <<= 8; in bnxt_init_vnics()
4593 bp->toeplitz_prefix |= key[k]; in bnxt_init_vnics()
4596 memcpy(vnic->rss_hash_key, vnic0->rss_hash_key, in bnxt_init_vnics()
4614 while (pages & (pages - 1)) in bnxt_calc_nr_ring_pages()
4622 bp->flags &= ~BNXT_FLAG_TPA; in bnxt_set_tpa_flags()
4623 if (bp->flags & BNXT_FLAG_NO_AGG_RINGS) in bnxt_set_tpa_flags()
4625 if (bp->dev->features & NETIF_F_LRO) in bnxt_set_tpa_flags()
4626 bp->flags |= BNXT_FLAG_LRO; in bnxt_set_tpa_flags()
4627 else if (bp->dev->features & NETIF_F_GRO_HW) in bnxt_set_tpa_flags()
4628 bp->flags |= BNXT_FLAG_GRO; in bnxt_set_tpa_flags()
4635 bp->rx_copybreak = BNXT_DEFAULT_RX_COPYBREAK; in bnxt_init_ring_params()
4637 rx_size = SZ_1K - in bnxt_init_ring_params()
4638 NET_SKB_PAD - SKB_DATA_ALIGN(sizeof(struct skb_shared_info)); in bnxt_init_ring_params()
4639 bp->dev->cfg->hds_thresh = max(BNXT_DEFAULT_RX_COPYBREAK, rx_size); in bnxt_init_ring_params()
4642 /* bp->rx_ring_size, bp->tx_ring_size, dev->mtu, BNXT_FLAG_{G|L}RO flags must
4651 rx_size = SKB_DATA_ALIGN(bp->dev->mtu + ETH_HLEN + NET_IP_ALIGN + 8); in bnxt_set_ring_params()
4656 ring_size = bp->rx_ring_size; in bnxt_set_ring_params()
4657 bp->rx_agg_ring_size = 0; in bnxt_set_ring_params()
4658 bp->rx_agg_nr_pages = 0; in bnxt_set_ring_params()
4660 if (bp->flags & BNXT_FLAG_TPA || bp->flags & BNXT_FLAG_HDS) in bnxt_set_ring_params()
4663 bp->flags &= ~BNXT_FLAG_JUMBO; in bnxt_set_ring_params()
4664 if (rx_space > PAGE_SIZE && !(bp->flags & BNXT_FLAG_NO_AGG_RINGS)) { in bnxt_set_ring_params()
4667 bp->flags |= BNXT_FLAG_JUMBO; in bnxt_set_ring_params()
4668 jumbo_factor = PAGE_ALIGN(bp->dev->mtu - 40) >> PAGE_SHIFT; in bnxt_set_ring_params()
4675 … 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()
4676 bp->rx_ring_size, ring_size); in bnxt_set_ring_params()
4677 bp->rx_ring_size = ring_size; in bnxt_set_ring_params()
4681 bp->rx_agg_nr_pages = bnxt_calc_nr_ring_pages(agg_ring_size, in bnxt_set_ring_params()
4683 if (bp->rx_agg_nr_pages > MAX_RX_AGG_PAGES) { in bnxt_set_ring_params()
4686 bp->rx_agg_nr_pages = MAX_RX_AGG_PAGES; in bnxt_set_ring_params()
4687 agg_ring_size = MAX_RX_AGG_PAGES * RX_DESC_CNT - 1; in bnxt_set_ring_params()
4688 netdev_warn(bp->dev, "rx agg ring size %d reduced to %d.\n", in bnxt_set_ring_params()
4691 bp->rx_agg_ring_size = agg_ring_size; in bnxt_set_ring_params()
4692 bp->rx_agg_ring_mask = (bp->rx_agg_nr_pages * RX_DESC_CNT) - 1; in bnxt_set_ring_params()
4696 rx_size = PAGE_SIZE - in bnxt_set_ring_params()
4697 ALIGN(max(NET_SKB_PAD, XDP_PACKET_HEADROOM), 8) - in bnxt_set_ring_params()
4701 bp->rx_copybreak, in bnxt_set_ring_params()
4702 bp->dev->cfg_pending->hds_thresh); in bnxt_set_ring_params()
4709 bp->rx_buf_use_size = rx_size; in bnxt_set_ring_params()
4710 bp->rx_buf_size = rx_space; in bnxt_set_ring_params()
4712 bp->rx_nr_pages = bnxt_calc_nr_ring_pages(ring_size, RX_DESC_CNT); in bnxt_set_ring_params()
4713 bp->rx_ring_mask = (bp->rx_nr_pages * RX_DESC_CNT) - 1; in bnxt_set_ring_params()
4715 ring_size = bp->tx_ring_size; in bnxt_set_ring_params()
4716 bp->tx_nr_pages = bnxt_calc_nr_ring_pages(ring_size, TX_DESC_CNT); in bnxt_set_ring_params()
4717 bp->tx_ring_mask = (bp->tx_nr_pages * TX_DESC_CNT) - 1; in bnxt_set_ring_params()
4719 max_rx_cmpl = bp->rx_ring_size; in bnxt_set_ring_params()
4724 if (bp->flags & BNXT_FLAG_TPA) in bnxt_set_ring_params()
4725 max_rx_cmpl += bp->max_tpa; in bnxt_set_ring_params()
4726 /* RX and TPA completions are 32-byte, all others are 16-byte */ in bnxt_set_ring_params()
4727 ring_size = max_rx_cmpl * 2 + agg_ring_size + bp->tx_ring_size; in bnxt_set_ring_params()
4728 bp->cp_ring_size = ring_size; in bnxt_set_ring_params()
4730 bp->cp_nr_pages = bnxt_calc_nr_ring_pages(ring_size, CP_DESC_CNT); in bnxt_set_ring_params()
4731 if (bp->cp_nr_pages > MAX_CP_PAGES) { in bnxt_set_ring_params()
4732 bp->cp_nr_pages = MAX_CP_PAGES; in bnxt_set_ring_params()
4733 bp->cp_ring_size = MAX_CP_PAGES * CP_DESC_CNT - 1; in bnxt_set_ring_params()
4734 netdev_warn(bp->dev, "completion ring size %d reduced to %d.\n", in bnxt_set_ring_params()
4735 ring_size, bp->cp_ring_size); in bnxt_set_ring_params()
4737 bp->cp_bit = bp->cp_nr_pages * CP_DESC_CNT; in bnxt_set_ring_params()
4738 bp->cp_ring_mask = bp->cp_bit - 1; in bnxt_set_ring_params()
4746 struct net_device *dev = bp->dev; in __bnxt_set_rx_skb_mode()
4749 bp->flags &= ~(BNXT_FLAG_AGG_RINGS | BNXT_FLAG_NO_AGG_RINGS); in __bnxt_set_rx_skb_mode()
4750 bp->flags |= BNXT_FLAG_RX_PAGE_MODE; in __bnxt_set_rx_skb_mode()
4752 if (bp->xdp_prog->aux->xdp_has_frags) in __bnxt_set_rx_skb_mode()
4753 dev->max_mtu = min_t(u16, bp->max_mtu, BNXT_MAX_MTU); in __bnxt_set_rx_skb_mode()
4755 dev->max_mtu = in __bnxt_set_rx_skb_mode()
4756 min_t(u16, bp->max_mtu, BNXT_MAX_PAGE_MODE_MTU); in __bnxt_set_rx_skb_mode()
4757 if (dev->mtu > BNXT_MAX_PAGE_MODE_MTU) { in __bnxt_set_rx_skb_mode()
4758 bp->flags |= BNXT_FLAG_JUMBO; in __bnxt_set_rx_skb_mode()
4759 bp->rx_skb_func = bnxt_rx_multi_page_skb; in __bnxt_set_rx_skb_mode()
4761 bp->flags |= BNXT_FLAG_NO_AGG_RINGS; in __bnxt_set_rx_skb_mode()
4762 bp->rx_skb_func = bnxt_rx_page_skb; in __bnxt_set_rx_skb_mode()
4764 bp->rx_dir = DMA_BIDIRECTIONAL; in __bnxt_set_rx_skb_mode()
4766 dev->max_mtu = bp->max_mtu; in __bnxt_set_rx_skb_mode()
4767 bp->flags &= ~BNXT_FLAG_RX_PAGE_MODE; in __bnxt_set_rx_skb_mode()
4768 bp->rx_dir = DMA_FROM_DEVICE; in __bnxt_set_rx_skb_mode()
4769 bp->rx_skb_func = bnxt_rx_skb; in __bnxt_set_rx_skb_mode()
4782 bp->flags &= ~BNXT_FLAG_NO_AGG_RINGS; in bnxt_set_rx_skb_mode()
4783 bp->dev->hw_features |= NETIF_F_LRO; in bnxt_set_rx_skb_mode()
4788 netdev_update_features(bp->dev); in bnxt_set_rx_skb_mode()
4795 struct pci_dev *pdev = bp->pdev; in bnxt_free_vnic_attributes()
4797 if (!bp->vnic_info) in bnxt_free_vnic_attributes()
4800 for (i = 0; i < bp->nr_vnics; i++) { in bnxt_free_vnic_attributes()
4801 vnic = &bp->vnic_info[i]; in bnxt_free_vnic_attributes()
4803 kfree(vnic->fw_grp_ids); in bnxt_free_vnic_attributes()
4804 vnic->fw_grp_ids = NULL; in bnxt_free_vnic_attributes()
4806 kfree(vnic->uc_list); in bnxt_free_vnic_attributes()
4807 vnic->uc_list = NULL; in bnxt_free_vnic_attributes()
4809 if (vnic->mc_list) { in bnxt_free_vnic_attributes()
4810 dma_free_coherent(&pdev->dev, vnic->mc_list_size, in bnxt_free_vnic_attributes()
4811 vnic->mc_list, vnic->mc_list_mapping); in bnxt_free_vnic_attributes()
4812 vnic->mc_list = NULL; in bnxt_free_vnic_attributes()
4815 if (vnic->rss_table) { in bnxt_free_vnic_attributes()
4816 dma_free_coherent(&pdev->dev, vnic->rss_table_size, in bnxt_free_vnic_attributes()
4817 vnic->rss_table, in bnxt_free_vnic_attributes()
4818 vnic->rss_table_dma_addr); in bnxt_free_vnic_attributes()
4819 vnic->rss_table = NULL; in bnxt_free_vnic_attributes()
4822 vnic->rss_hash_key = NULL; in bnxt_free_vnic_attributes()
4823 vnic->flags = 0; in bnxt_free_vnic_attributes()
4831 struct pci_dev *pdev = bp->pdev; in bnxt_alloc_vnic_attributes()
4834 for (i = 0; i < bp->nr_vnics; i++) { in bnxt_alloc_vnic_attributes()
4835 vnic = &bp->vnic_info[i]; in bnxt_alloc_vnic_attributes()
4837 if (vnic->flags & BNXT_VNIC_UCAST_FLAG) { in bnxt_alloc_vnic_attributes()
4838 int mem_size = (BNXT_MAX_UC_ADDRS - 1) * ETH_ALEN; in bnxt_alloc_vnic_attributes()
4841 vnic->uc_list = kmalloc(mem_size, GFP_KERNEL); in bnxt_alloc_vnic_attributes()
4842 if (!vnic->uc_list) { in bnxt_alloc_vnic_attributes()
4843 rc = -ENOMEM; in bnxt_alloc_vnic_attributes()
4849 if (vnic->flags & BNXT_VNIC_MCAST_FLAG) { in bnxt_alloc_vnic_attributes()
4850 vnic->mc_list_size = BNXT_MAX_MC_ADDRS * ETH_ALEN; in bnxt_alloc_vnic_attributes()
4851 vnic->mc_list = in bnxt_alloc_vnic_attributes()
4852 dma_alloc_coherent(&pdev->dev, in bnxt_alloc_vnic_attributes()
4853 vnic->mc_list_size, in bnxt_alloc_vnic_attributes()
4854 &vnic->mc_list_mapping, in bnxt_alloc_vnic_attributes()
4856 if (!vnic->mc_list) { in bnxt_alloc_vnic_attributes()
4857 rc = -ENOMEM; in bnxt_alloc_vnic_attributes()
4862 if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) in bnxt_alloc_vnic_attributes()
4865 if (vnic->flags & BNXT_VNIC_RSS_FLAG) in bnxt_alloc_vnic_attributes()
4866 max_rings = bp->rx_nr_rings; in bnxt_alloc_vnic_attributes()
4870 vnic->fw_grp_ids = kcalloc(max_rings, sizeof(u16), GFP_KERNEL); in bnxt_alloc_vnic_attributes()
4871 if (!vnic->fw_grp_ids) { in bnxt_alloc_vnic_attributes()
4872 rc = -ENOMEM; in bnxt_alloc_vnic_attributes()
4876 if ((bp->rss_cap & BNXT_RSS_CAP_NEW_RSS_CAP) && in bnxt_alloc_vnic_attributes()
4877 !(vnic->flags & BNXT_VNIC_RSS_FLAG)) in bnxt_alloc_vnic_attributes()
4882 if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) in bnxt_alloc_vnic_attributes()
4885 vnic->rss_table_size = size + HW_HASH_KEY_SIZE; in bnxt_alloc_vnic_attributes()
4886 vnic->rss_table = dma_alloc_coherent(&pdev->dev, in bnxt_alloc_vnic_attributes()
4887 vnic->rss_table_size, in bnxt_alloc_vnic_attributes()
4888 &vnic->rss_table_dma_addr, in bnxt_alloc_vnic_attributes()
4890 if (!vnic->rss_table) { in bnxt_alloc_vnic_attributes()
4891 rc = -ENOMEM; in bnxt_alloc_vnic_attributes()
4895 vnic->rss_hash_key = ((void *)vnic->rss_table) + size; in bnxt_alloc_vnic_attributes()
4896 vnic->rss_hash_key_dma_addr = vnic->rss_table_dma_addr + size; in bnxt_alloc_vnic_attributes()
4908 dma_pool_destroy(bp->hwrm_dma_pool); in bnxt_free_hwrm_resources()
4909 bp->hwrm_dma_pool = NULL; in bnxt_free_hwrm_resources()
4912 hlist_for_each_entry_rcu(token, &bp->hwrm_pending_list, node) in bnxt_free_hwrm_resources()
4913 WRITE_ONCE(token->state, BNXT_HWRM_CANCELLED); in bnxt_free_hwrm_resources()
4919 bp->hwrm_dma_pool = dma_pool_create("bnxt_hwrm", &bp->pdev->dev, in bnxt_alloc_hwrm_resources()
4922 if (!bp->hwrm_dma_pool) in bnxt_alloc_hwrm_resources()
4923 return -ENOMEM; in bnxt_alloc_hwrm_resources()
4925 INIT_HLIST_HEAD(&bp->hwrm_pending_list); in bnxt_alloc_hwrm_resources()
4932 kfree(stats->hw_masks); in bnxt_free_stats_mem()
4933 stats->hw_masks = NULL; in bnxt_free_stats_mem()
4934 kfree(stats->sw_stats); in bnxt_free_stats_mem()
4935 stats->sw_stats = NULL; in bnxt_free_stats_mem()
4936 if (stats->hw_stats) { in bnxt_free_stats_mem()
4937 dma_free_coherent(&bp->pdev->dev, stats->len, stats->hw_stats, in bnxt_free_stats_mem()
4938 stats->hw_stats_map); in bnxt_free_stats_mem()
4939 stats->hw_stats = NULL; in bnxt_free_stats_mem()
4946 stats->hw_stats = dma_alloc_coherent(&bp->pdev->dev, stats->len, in bnxt_alloc_stats_mem()
4947 &stats->hw_stats_map, GFP_KERNEL); in bnxt_alloc_stats_mem()
4948 if (!stats->hw_stats) in bnxt_alloc_stats_mem()
4949 return -ENOMEM; in bnxt_alloc_stats_mem()
4951 stats->sw_stats = kzalloc(stats->len, GFP_KERNEL); in bnxt_alloc_stats_mem()
4952 if (!stats->sw_stats) in bnxt_alloc_stats_mem()
4956 stats->hw_masks = kzalloc(stats->len, GFP_KERNEL); in bnxt_alloc_stats_mem()
4957 if (!stats->hw_masks) in bnxt_alloc_stats_mem()
4964 return -ENOMEM; in bnxt_alloc_stats_mem()
4991 if (!(bp->fw_cap & BNXT_FW_CAP_EXT_HW_STATS_SUPPORTED) || in bnxt_hwrm_func_qstat_ext()
4992 !(bp->flags & BNXT_FLAG_CHIP_P5_PLUS)) in bnxt_hwrm_func_qstat_ext()
4993 return -EOPNOTSUPP; in bnxt_hwrm_func_qstat_ext()
4999 req->fid = cpu_to_le16(0xffff); in bnxt_hwrm_func_qstat_ext()
5000 req->flags = FUNC_QSTATS_EXT_REQ_FLAGS_COUNTER_MASK; in bnxt_hwrm_func_qstat_ext()
5005 hw_masks = &resp->rx_ucast_pkts; in bnxt_hwrm_func_qstat_ext()
5006 bnxt_copy_hw_masks(stats->hw_masks, hw_masks, stats->len / 8); in bnxt_hwrm_func_qstat_ext()
5017 struct bnxt_napi *bnapi = bp->bnapi[0]; in bnxt_init_stats()
5026 cpr = &bnapi->cp_ring; in bnxt_init_stats()
5027 stats = &cpr->stats; in bnxt_init_stats()
5030 if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) in bnxt_init_stats()
5031 mask = (1ULL << 48) - 1; in bnxt_init_stats()
5033 mask = -1ULL; in bnxt_init_stats()
5034 bnxt_fill_masks(stats->hw_masks, mask, stats->len / 8); in bnxt_init_stats()
5036 if (bp->flags & BNXT_FLAG_PORT_STATS) { in bnxt_init_stats()
5037 stats = &bp->port_stats; in bnxt_init_stats()
5038 rx_stats = stats->hw_stats; in bnxt_init_stats()
5039 rx_masks = stats->hw_masks; in bnxt_init_stats()
5048 mask = (1ULL << 40) - 1; in bnxt_init_stats()
5058 if (bp->flags & BNXT_FLAG_PORT_STATS_EXT) { in bnxt_init_stats()
5059 stats = &bp->rx_port_stats_ext; in bnxt_init_stats()
5060 rx_stats = stats->hw_stats; in bnxt_init_stats()
5061 rx_masks = stats->hw_masks; in bnxt_init_stats()
5063 stats = &bp->tx_port_stats_ext; in bnxt_init_stats()
5064 tx_stats = stats->hw_stats; in bnxt_init_stats()
5065 tx_masks = stats->hw_masks; in bnxt_init_stats()
5071 mask = (1ULL << 40) - 1; in bnxt_init_stats()
5088 bp->flags &= ~BNXT_FLAG_PORT_STATS; in bnxt_free_port_stats()
5089 bp->flags &= ~BNXT_FLAG_PORT_STATS_EXT; in bnxt_free_port_stats()
5091 bnxt_free_stats_mem(bp, &bp->port_stats); in bnxt_free_port_stats()
5092 bnxt_free_stats_mem(bp, &bp->rx_port_stats_ext); in bnxt_free_port_stats()
5093 bnxt_free_stats_mem(bp, &bp->tx_port_stats_ext); in bnxt_free_port_stats()
5100 if (!bp->bnapi) in bnxt_free_ring_stats()
5103 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_free_ring_stats()
5104 struct bnxt_napi *bnapi = bp->bnapi[i]; in bnxt_free_ring_stats()
5105 struct bnxt_cp_ring_info *cpr = &bnapi->cp_ring; in bnxt_free_ring_stats()
5107 bnxt_free_stats_mem(bp, &cpr->stats); in bnxt_free_ring_stats()
5109 kfree(cpr->sw_stats); in bnxt_free_ring_stats()
5110 cpr->sw_stats = NULL; in bnxt_free_ring_stats()
5119 size = bp->hw_ring_stats_size; in bnxt_alloc_stats()
5121 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_alloc_stats()
5122 struct bnxt_napi *bnapi = bp->bnapi[i]; in bnxt_alloc_stats()
5123 struct bnxt_cp_ring_info *cpr = &bnapi->cp_ring; in bnxt_alloc_stats()
5125 cpr->sw_stats = kzalloc(sizeof(*cpr->sw_stats), GFP_KERNEL); in bnxt_alloc_stats()
5126 if (!cpr->sw_stats) in bnxt_alloc_stats()
5127 return -ENOMEM; in bnxt_alloc_stats()
5129 cpr->stats.len = size; in bnxt_alloc_stats()
5130 rc = bnxt_alloc_stats_mem(bp, &cpr->stats, !i); in bnxt_alloc_stats()
5134 cpr->hw_stats_ctx_id = INVALID_STATS_CTX_ID; in bnxt_alloc_stats()
5137 if (BNXT_VF(bp) || bp->chip_num == CHIP_NUM_58700) in bnxt_alloc_stats()
5140 if (bp->port_stats.hw_stats) in bnxt_alloc_stats()
5143 bp->port_stats.len = BNXT_PORT_STATS_SIZE; in bnxt_alloc_stats()
5144 rc = bnxt_alloc_stats_mem(bp, &bp->port_stats, true); in bnxt_alloc_stats()
5148 bp->flags |= BNXT_FLAG_PORT_STATS; in bnxt_alloc_stats()
5152 if (bp->hwrm_spec_code < 0x10804 || bp->hwrm_spec_code == 0x10900) in bnxt_alloc_stats()
5153 if (!(bp->fw_cap & BNXT_FW_CAP_EXT_STATS_SUPPORTED)) in bnxt_alloc_stats()
5156 if (bp->rx_port_stats_ext.hw_stats) in bnxt_alloc_stats()
5159 bp->rx_port_stats_ext.len = sizeof(struct rx_port_stats_ext); in bnxt_alloc_stats()
5160 rc = bnxt_alloc_stats_mem(bp, &bp->rx_port_stats_ext, true); in bnxt_alloc_stats()
5166 if (bp->tx_port_stats_ext.hw_stats) in bnxt_alloc_stats()
5169 if (bp->hwrm_spec_code >= 0x10902 || in bnxt_alloc_stats()
5170 (bp->fw_cap & BNXT_FW_CAP_EXT_STATS_SUPPORTED)) { in bnxt_alloc_stats()
5171 bp->tx_port_stats_ext.len = sizeof(struct tx_port_stats_ext); in bnxt_alloc_stats()
5172 rc = bnxt_alloc_stats_mem(bp, &bp->tx_port_stats_ext, true); in bnxt_alloc_stats()
5177 bp->flags |= BNXT_FLAG_PORT_STATS_EXT; in bnxt_alloc_stats()
5185 if (!bp->bnapi) in bnxt_clear_ring_indices()
5188 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_clear_ring_indices()
5189 struct bnxt_napi *bnapi = bp->bnapi[i]; in bnxt_clear_ring_indices()
5197 cpr = &bnapi->cp_ring; in bnxt_clear_ring_indices()
5198 cpr->cp_raw_cons = 0; in bnxt_clear_ring_indices()
5201 txr->tx_prod = 0; in bnxt_clear_ring_indices()
5202 txr->tx_cons = 0; in bnxt_clear_ring_indices()
5203 txr->tx_hw_cons = 0; in bnxt_clear_ring_indices()
5206 rxr = bnapi->rx_ring; in bnxt_clear_ring_indices()
5208 rxr->rx_prod = 0; in bnxt_clear_ring_indices()
5209 rxr->rx_agg_prod = 0; in bnxt_clear_ring_indices()
5210 rxr->rx_sw_agg_prod = 0; in bnxt_clear_ring_indices()
5211 rxr->rx_next_cons = 0; in bnxt_clear_ring_indices()
5213 bnapi->events = 0; in bnxt_clear_ring_indices()
5219 u8 type = fltr->type, flags = fltr->flags; in bnxt_insert_usr_fltr()
5221 INIT_LIST_HEAD(&fltr->list); in bnxt_insert_usr_fltr()
5224 list_add_tail(&fltr->list, &bp->usr_fltr_list); in bnxt_insert_usr_fltr()
5229 if (!list_empty(&fltr->list)) in bnxt_del_one_usr_fltr()
5230 list_del_init(&fltr->list); in bnxt_del_one_usr_fltr()
5237 list_for_each_entry_safe(usr_fltr, tmp, &bp->usr_fltr_list, list) { in bnxt_clear_usr_fltrs()
5238 if (!all && usr_fltr->type == BNXT_FLTR_TYPE_L2) in bnxt_clear_usr_fltrs()
5246 hlist_del(&fltr->hash); in bnxt_del_fltr()
5248 if (fltr->flags) { in bnxt_del_fltr()
5249 clear_bit(fltr->sw_id, bp->ntp_fltr_bmap); in bnxt_del_fltr()
5250 bp->ntp_fltr_count--; in bnxt_del_fltr()
5267 head = &bp->ntp_fltr_hash_tbl[i]; in bnxt_free_ntp_fltrs()
5269 bnxt_del_l2_filter(bp, fltr->l2_fltr); in bnxt_free_ntp_fltrs()
5270 if (!all && ((fltr->base.flags & BNXT_ACT_FUNC_DST) || in bnxt_free_ntp_fltrs()
5271 !list_empty(&fltr->base.list))) in bnxt_free_ntp_fltrs()
5273 bnxt_del_fltr(bp, &fltr->base); in bnxt_free_ntp_fltrs()
5279 bitmap_free(bp->ntp_fltr_bmap); in bnxt_free_ntp_fltrs()
5280 bp->ntp_fltr_bmap = NULL; in bnxt_free_ntp_fltrs()
5281 bp->ntp_fltr_count = 0; in bnxt_free_ntp_fltrs()
5288 if (!(bp->flags & BNXT_FLAG_RFS) || bp->ntp_fltr_bmap) in bnxt_alloc_ntp_fltrs()
5292 INIT_HLIST_HEAD(&bp->ntp_fltr_hash_tbl[i]); in bnxt_alloc_ntp_fltrs()
5294 bp->ntp_fltr_count = 0; in bnxt_alloc_ntp_fltrs()
5295 bp->ntp_fltr_bmap = bitmap_zalloc(bp->max_fltr, GFP_KERNEL); in bnxt_alloc_ntp_fltrs()
5297 if (!bp->ntp_fltr_bmap) in bnxt_alloc_ntp_fltrs()
5298 rc = -ENOMEM; in bnxt_alloc_ntp_fltrs()
5312 head = &bp->l2_fltr_hash_tbl[i]; in bnxt_free_l2_filters()
5314 if (!all && ((fltr->base.flags & BNXT_ACT_FUNC_DST) || in bnxt_free_l2_filters()
5315 !list_empty(&fltr->base.list))) in bnxt_free_l2_filters()
5317 bnxt_del_fltr(bp, &fltr->base); in bnxt_free_l2_filters()
5327 INIT_HLIST_HEAD(&bp->l2_fltr_hash_tbl[i]); in bnxt_init_l2_fltr_tbl()
5328 get_random_bytes(&bp->hash_seed, sizeof(bp->hash_seed)); in bnxt_init_l2_fltr_tbl()
5342 if (!(bp->phy_flags & BNXT_PHY_FL_PORT_STATS_NO_RESET) || in bnxt_free_mem()
5343 test_bit(BNXT_STATE_IN_FW_RESET, &bp->state)) in bnxt_free_mem()
5347 kfree(bp->tx_ring_map); in bnxt_free_mem()
5348 bp->tx_ring_map = NULL; in bnxt_free_mem()
5349 kfree(bp->tx_ring); in bnxt_free_mem()
5350 bp->tx_ring = NULL; in bnxt_free_mem()
5351 kfree(bp->rx_ring); in bnxt_free_mem()
5352 bp->rx_ring = NULL; in bnxt_free_mem()
5353 kfree(bp->bnapi); in bnxt_free_mem()
5354 bp->bnapi = NULL; in bnxt_free_mem()
5370 bp->cp_nr_rings); in bnxt_alloc_mem()
5372 bnapi = kzalloc(arr_size + size * bp->cp_nr_rings, GFP_KERNEL); in bnxt_alloc_mem()
5374 return -ENOMEM; in bnxt_alloc_mem()
5376 bp->bnapi = bnapi; in bnxt_alloc_mem()
5378 for (i = 0; i < bp->cp_nr_rings; i++, bnapi += size) { in bnxt_alloc_mem()
5379 bp->bnapi[i] = bnapi; in bnxt_alloc_mem()
5380 bp->bnapi[i]->index = i; in bnxt_alloc_mem()
5381 bp->bnapi[i]->bp = bp; in bnxt_alloc_mem()
5382 if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) { in bnxt_alloc_mem()
5384 &bp->bnapi[i]->cp_ring; in bnxt_alloc_mem()
5386 cpr->cp_ring_struct.ring_mem.flags = in bnxt_alloc_mem()
5391 bp->rx_ring = kcalloc(bp->rx_nr_rings, in bnxt_alloc_mem()
5394 if (!bp->rx_ring) in bnxt_alloc_mem()
5395 return -ENOMEM; in bnxt_alloc_mem()
5397 for (i = 0; i < bp->rx_nr_rings; i++) { in bnxt_alloc_mem()
5398 struct bnxt_rx_ring_info *rxr = &bp->rx_ring[i]; in bnxt_alloc_mem()
5400 if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) { in bnxt_alloc_mem()
5401 rxr->rx_ring_struct.ring_mem.flags = in bnxt_alloc_mem()
5403 rxr->rx_agg_ring_struct.ring_mem.flags = in bnxt_alloc_mem()
5406 rxr->rx_cpr = &bp->bnapi[i]->cp_ring; in bnxt_alloc_mem()
5408 rxr->bnapi = bp->bnapi[i]; in bnxt_alloc_mem()
5409 bp->bnapi[i]->rx_ring = &bp->rx_ring[i]; in bnxt_alloc_mem()
5412 bp->tx_ring = kcalloc(bp->tx_nr_rings, in bnxt_alloc_mem()
5415 if (!bp->tx_ring) in bnxt_alloc_mem()
5416 return -ENOMEM; in bnxt_alloc_mem()
5418 bp->tx_ring_map = kcalloc(bp->tx_nr_rings, sizeof(u16), in bnxt_alloc_mem()
5421 if (!bp->tx_ring_map) in bnxt_alloc_mem()
5422 return -ENOMEM; in bnxt_alloc_mem()
5424 if (bp->flags & BNXT_FLAG_SHARED_RINGS) in bnxt_alloc_mem()
5427 j = bp->rx_nr_rings; in bnxt_alloc_mem()
5429 for (i = 0; i < bp->tx_nr_rings; i++) { in bnxt_alloc_mem()
5430 struct bnxt_tx_ring_info *txr = &bp->tx_ring[i]; in bnxt_alloc_mem()
5433 if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) in bnxt_alloc_mem()
5434 txr->tx_ring_struct.ring_mem.flags = in bnxt_alloc_mem()
5436 bp->tx_ring_map[i] = bp->tx_nr_rings_xdp + i; in bnxt_alloc_mem()
5437 if (i >= bp->tx_nr_rings_xdp) { in bnxt_alloc_mem()
5440 bnapi2 = bp->bnapi[k]; in bnxt_alloc_mem()
5441 txr->txq_index = i - bp->tx_nr_rings_xdp; in bnxt_alloc_mem()
5442 txr->tx_napi_idx = in bnxt_alloc_mem()
5443 BNXT_RING_TO_TC(bp, txr->txq_index); in bnxt_alloc_mem()
5444 bnapi2->tx_ring[txr->tx_napi_idx] = txr; in bnxt_alloc_mem()
5445 bnapi2->tx_int = bnxt_tx_int; in bnxt_alloc_mem()
5447 bnapi2 = bp->bnapi[j]; in bnxt_alloc_mem()
5448 bnapi2->flags |= BNXT_NAPI_FLAG_XDP; in bnxt_alloc_mem()
5449 bnapi2->tx_ring[0] = txr; in bnxt_alloc_mem()
5450 bnapi2->tx_int = bnxt_tx_int_xdp; in bnxt_alloc_mem()
5453 txr->bnapi = bnapi2; in bnxt_alloc_mem()
5454 if (!(bp->flags & BNXT_FLAG_CHIP_P5_PLUS)) in bnxt_alloc_mem()
5455 txr->tx_cpr = &bnapi2->cp_ring; in bnxt_alloc_mem()
5490 bp->vnic_info[BNXT_VNIC_DEFAULT].flags |= BNXT_VNIC_RSS_FLAG | in bnxt_alloc_mem()
5493 if (BNXT_SUPPORTS_NTUPLE_VNIC(bp) && (bp->flags & BNXT_FLAG_RFS)) in bnxt_alloc_mem()
5494 bp->vnic_info[BNXT_VNIC_NTUPLE].flags |= in bnxt_alloc_mem()
5511 if (!bp->bnapi) in bnxt_disable_int()
5514 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_disable_int()
5515 struct bnxt_napi *bnapi = bp->bnapi[i]; in bnxt_disable_int()
5516 struct bnxt_cp_ring_info *cpr = &bnapi->cp_ring; in bnxt_disable_int()
5517 struct bnxt_ring_struct *ring = &cpr->cp_ring_struct; in bnxt_disable_int()
5519 if (ring->fw_ring_id != INVALID_HW_RING_ID) in bnxt_disable_int()
5520 bnxt_db_nq(bp, &cpr->cp_db, cpr->cp_raw_cons); in bnxt_disable_int()
5526 struct bnxt_napi *bnapi = bp->bnapi[n]; in bnxt_cp_num_to_irq_num()
5529 cpr = &bnapi->cp_ring; in bnxt_cp_num_to_irq_num()
5530 return cpr->cp_ring_struct.map_idx; in bnxt_cp_num_to_irq_num()
5537 if (!bp->irq_tbl) in bnxt_disable_int_sync()
5540 atomic_inc(&bp->intr_sem); in bnxt_disable_int_sync()
5543 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_disable_int_sync()
5546 synchronize_irq(bp->irq_tbl[map_idx].vector); in bnxt_disable_int_sync()
5554 atomic_set(&bp->intr_sem, 0); in bnxt_enable_int()
5555 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_enable_int()
5556 struct bnxt_napi *bnapi = bp->bnapi[i]; in bnxt_enable_int()
5557 struct bnxt_cp_ring_info *cpr = &bnapi->cp_ring; in bnxt_enable_int()
5559 bnxt_db_nq_arm(bp, &cpr->cp_db, cpr->cp_raw_cons); in bnxt_enable_int()
5577 req->enables = cpu_to_le32(FUNC_DRV_RGTR_REQ_ENABLES_OS_TYPE | in bnxt_hwrm_func_drv_rgtr()
5581 req->os_type = cpu_to_le16(FUNC_DRV_RGTR_REQ_OS_TYPE_LINUX); in bnxt_hwrm_func_drv_rgtr()
5583 if (bp->fw_cap & BNXT_FW_CAP_HOT_RESET) in bnxt_hwrm_func_drv_rgtr()
5585 if (bp->fw_cap & BNXT_FW_CAP_ERROR_RECOVERY) in bnxt_hwrm_func_drv_rgtr()
5588 req->flags = cpu_to_le32(flags); in bnxt_hwrm_func_drv_rgtr()
5589 req->ver_maj_8b = DRV_VER_MAJ; in bnxt_hwrm_func_drv_rgtr()
5590 req->ver_min_8b = DRV_VER_MIN; in bnxt_hwrm_func_drv_rgtr()
5591 req->ver_upd_8b = DRV_VER_UPD; in bnxt_hwrm_func_drv_rgtr()
5592 req->ver_maj = cpu_to_le16(DRV_VER_MAJ); in bnxt_hwrm_func_drv_rgtr()
5593 req->ver_min = cpu_to_le16(DRV_VER_MIN); in bnxt_hwrm_func_drv_rgtr()
5594 req->ver_upd = cpu_to_le16(DRV_VER_UPD); in bnxt_hwrm_func_drv_rgtr()
5611 req->vf_req_fwd[i] = cpu_to_le32(data[i]); in bnxt_hwrm_func_drv_rgtr()
5613 req->enables |= in bnxt_hwrm_func_drv_rgtr()
5617 if (bp->fw_cap & BNXT_FW_CAP_OVS_64BIT_HANDLE) in bnxt_hwrm_func_drv_rgtr()
5618 req->flags |= cpu_to_le32( in bnxt_hwrm_func_drv_rgtr()
5626 !(bp->fw_cap & BNXT_FW_CAP_ERROR_RECOVERY)) in bnxt_hwrm_func_drv_rgtr()
5629 !bp->ptp_cfg) in bnxt_hwrm_func_drv_rgtr()
5640 req->async_event_fwd[i] |= cpu_to_le32(events[i]); in bnxt_hwrm_func_drv_rgtr()
5643 req->enables = in bnxt_hwrm_func_drv_rgtr()
5649 set_bit(BNXT_STATE_DRV_REGISTERED, &bp->state); in bnxt_hwrm_func_drv_rgtr()
5650 if (resp->flags & in bnxt_hwrm_func_drv_rgtr()
5652 bp->fw_cap |= BNXT_FW_CAP_IF_CHANGE; in bnxt_hwrm_func_drv_rgtr()
5663 if (!test_and_clear_bit(BNXT_STATE_DRV_REGISTERED, &bp->state)) in bnxt_hwrm_func_drv_unrgtr()
5680 bp->vxlan_fw_dst_port_id == INVALID_HW_RING_ID) in bnxt_hwrm_tunnel_dst_port_free()
5683 bp->nge_fw_dst_port_id == INVALID_HW_RING_ID) in bnxt_hwrm_tunnel_dst_port_free()
5690 req->tunnel_type = tunnel_type; in bnxt_hwrm_tunnel_dst_port_free()
5694 req->tunnel_dst_port_id = cpu_to_le16(bp->vxlan_fw_dst_port_id); in bnxt_hwrm_tunnel_dst_port_free()
5695 bp->vxlan_port = 0; in bnxt_hwrm_tunnel_dst_port_free()
5696 bp->vxlan_fw_dst_port_id = INVALID_HW_RING_ID; in bnxt_hwrm_tunnel_dst_port_free()
5699 req->tunnel_dst_port_id = cpu_to_le16(bp->nge_fw_dst_port_id); in bnxt_hwrm_tunnel_dst_port_free()
5700 bp->nge_port = 0; in bnxt_hwrm_tunnel_dst_port_free()
5701 bp->nge_fw_dst_port_id = INVALID_HW_RING_ID; in bnxt_hwrm_tunnel_dst_port_free()
5704 req->tunnel_dst_port_id = cpu_to_le16(bp->vxlan_gpe_fw_dst_port_id); in bnxt_hwrm_tunnel_dst_port_free()
5705 bp->vxlan_gpe_port = 0; in bnxt_hwrm_tunnel_dst_port_free()
5706 bp->vxlan_gpe_fw_dst_port_id = INVALID_HW_RING_ID; in bnxt_hwrm_tunnel_dst_port_free()
5714 netdev_err(bp->dev, "hwrm_tunnel_dst_port_free failed. rc:%d\n", in bnxt_hwrm_tunnel_dst_port_free()
5716 if (bp->flags & BNXT_FLAG_TPA) in bnxt_hwrm_tunnel_dst_port_free()
5732 req->tunnel_type = tunnel_type; in bnxt_hwrm_tunnel_dst_port_alloc()
5733 req->tunnel_dst_port_val = port; in bnxt_hwrm_tunnel_dst_port_alloc()
5738 netdev_err(bp->dev, "hwrm_tunnel_dst_port_alloc failed. rc:%d\n", in bnxt_hwrm_tunnel_dst_port_alloc()
5745 bp->vxlan_port = port; in bnxt_hwrm_tunnel_dst_port_alloc()
5746 bp->vxlan_fw_dst_port_id = in bnxt_hwrm_tunnel_dst_port_alloc()
5747 le16_to_cpu(resp->tunnel_dst_port_id); in bnxt_hwrm_tunnel_dst_port_alloc()
5750 bp->nge_port = port; in bnxt_hwrm_tunnel_dst_port_alloc()
5751 bp->nge_fw_dst_port_id = le16_to_cpu(resp->tunnel_dst_port_id); in bnxt_hwrm_tunnel_dst_port_alloc()
5754 bp->vxlan_gpe_port = port; in bnxt_hwrm_tunnel_dst_port_alloc()
5755 bp->vxlan_gpe_fw_dst_port_id = in bnxt_hwrm_tunnel_dst_port_alloc()
5756 le16_to_cpu(resp->tunnel_dst_port_id); in bnxt_hwrm_tunnel_dst_port_alloc()
5761 if (bp->flags & BNXT_FLAG_TPA) in bnxt_hwrm_tunnel_dst_port_alloc()
5772 struct bnxt_vnic_info *vnic = &bp->vnic_info[vnic_id]; in bnxt_hwrm_cfa_l2_set_rx_mask()
5779 req->vnic_id = cpu_to_le32(vnic->fw_vnic_id); in bnxt_hwrm_cfa_l2_set_rx_mask()
5780 if (vnic->rx_mask & CFA_L2_SET_RX_MASK_REQ_MASK_MCAST) { in bnxt_hwrm_cfa_l2_set_rx_mask()
5781 req->num_mc_entries = cpu_to_le32(vnic->mc_list_count); in bnxt_hwrm_cfa_l2_set_rx_mask()
5782 req->mc_tbl_addr = cpu_to_le64(vnic->mc_list_mapping); in bnxt_hwrm_cfa_l2_set_rx_mask()
5784 req->mask = cpu_to_le32(vnic->rx_mask); in bnxt_hwrm_cfa_l2_set_rx_mask()
5790 if (!atomic_dec_and_test(&fltr->refcnt)) in bnxt_del_l2_filter()
5792 spin_lock_bh(&bp->ntp_fltr_lock); in bnxt_del_l2_filter()
5793 if (!test_and_clear_bit(BNXT_FLTR_INSERTED, &fltr->base.state)) { in bnxt_del_l2_filter()
5794 spin_unlock_bh(&bp->ntp_fltr_lock); in bnxt_del_l2_filter()
5797 hlist_del_rcu(&fltr->base.hash); in bnxt_del_l2_filter()
5798 bnxt_del_one_usr_fltr(bp, &fltr->base); in bnxt_del_l2_filter()
5799 if (fltr->base.flags) { in bnxt_del_l2_filter()
5800 clear_bit(fltr->base.sw_id, bp->ntp_fltr_bmap); in bnxt_del_l2_filter()
5801 bp->ntp_fltr_count--; in bnxt_del_l2_filter()
5803 spin_unlock_bh(&bp->ntp_fltr_lock); in bnxt_del_l2_filter()
5811 struct hlist_head *head = &bp->l2_fltr_hash_tbl[idx]; in __bnxt_lookup_l2_filter()
5815 struct bnxt_l2_key *l2_key = &fltr->l2_key; in __bnxt_lookup_l2_filter()
5817 if (ether_addr_equal(l2_key->dst_mac_addr, key->dst_mac_addr) && in __bnxt_lookup_l2_filter()
5818 l2_key->vlan == key->vlan) in __bnxt_lookup_l2_filter()
5833 atomic_inc(&fltr->refcnt); in bnxt_lookup_l2_filter()
5839 (((fkeys)->basic.ip_proto == IPPROTO_TCP && \
5840 (bp)->rss_hash_cfg & VNIC_RSS_CFG_REQ_HASH_TYPE_TCP_IPV4) || \
5841 ((fkeys)->basic.ip_proto == IPPROTO_UDP && \
5842 (bp)->rss_hash_cfg & VNIC_RSS_CFG_REQ_HASH_TYPE_UDP_IPV4))
5845 (((fkeys)->basic.ip_proto == IPPROTO_TCP && \
5846 (bp)->rss_hash_cfg & VNIC_RSS_CFG_REQ_HASH_TYPE_TCP_IPV6) || \
5847 ((fkeys)->basic.ip_proto == IPPROTO_UDP && \
5848 (bp)->rss_hash_cfg & VNIC_RSS_CFG_REQ_HASH_TYPE_UDP_IPV6))
5852 if (fkeys->basic.n_proto == htons(ETH_P_IP)) { in bnxt_get_rss_flow_tuple_len()
5854 return sizeof(fkeys->addrs.v4addrs) + in bnxt_get_rss_flow_tuple_len()
5855 sizeof(fkeys->ports); in bnxt_get_rss_flow_tuple_len()
5857 if (bp->rss_hash_cfg & VNIC_RSS_CFG_REQ_HASH_TYPE_IPV4) in bnxt_get_rss_flow_tuple_len()
5858 return sizeof(fkeys->addrs.v4addrs); in bnxt_get_rss_flow_tuple_len()
5861 if (fkeys->basic.n_proto == htons(ETH_P_IPV6)) { in bnxt_get_rss_flow_tuple_len()
5863 return sizeof(fkeys->addrs.v6addrs) + in bnxt_get_rss_flow_tuple_len()
5864 sizeof(fkeys->ports); in bnxt_get_rss_flow_tuple_len()
5866 if (bp->rss_hash_cfg & VNIC_RSS_CFG_REQ_HASH_TYPE_IPV6) in bnxt_get_rss_flow_tuple_len()
5867 return sizeof(fkeys->addrs.v6addrs); in bnxt_get_rss_flow_tuple_len()
5876 u64 prefix = bp->toeplitz_prefix, hash = 0; in bnxt_toeplitz()
5886 if (fkeys->basic.n_proto == htons(ETH_P_IP)) { in bnxt_toeplitz()
5887 tuple4.v4addrs = fkeys->addrs.v4addrs; in bnxt_toeplitz()
5888 tuple4.ports = fkeys->ports; in bnxt_toeplitz()
5891 tuple6.v6addrs = fkeys->addrs.v6addrs; in bnxt_toeplitz()
5892 tuple6.ports = fkeys->ports; in bnxt_toeplitz()
5918 idx = jhash2(&key->filter_key, BNXT_L2_KEY_SIZE, bp->hash_seed) & in bnxt_lookup_l2_filter_from_key()
5930 ether_addr_copy(fltr->l2_key.dst_mac_addr, key->dst_mac_addr); in bnxt_init_l2_filter()
5931 fltr->l2_key.vlan = key->vlan; in bnxt_init_l2_filter()
5932 fltr->base.type = BNXT_FLTR_TYPE_L2; in bnxt_init_l2_filter()
5933 if (fltr->base.flags) { in bnxt_init_l2_filter()
5936 bit_id = bitmap_find_free_region(bp->ntp_fltr_bmap, in bnxt_init_l2_filter()
5937 bp->max_fltr, 0); in bnxt_init_l2_filter()
5939 return -ENOMEM; in bnxt_init_l2_filter()
5940 fltr->base.sw_id = (u16)bit_id; in bnxt_init_l2_filter()
5941 bp->ntp_fltr_count++; in bnxt_init_l2_filter()
5943 head = &bp->l2_fltr_hash_tbl[idx]; in bnxt_init_l2_filter()
5944 hlist_add_head_rcu(&fltr->base.hash, head); in bnxt_init_l2_filter()
5945 bnxt_insert_usr_fltr(bp, &fltr->base); in bnxt_init_l2_filter()
5946 set_bit(BNXT_FLTR_INSERTED, &fltr->base.state); in bnxt_init_l2_filter()
5947 atomic_set(&fltr->refcnt, 1); in bnxt_init_l2_filter()
5959 idx = jhash2(&key->filter_key, BNXT_L2_KEY_SIZE, bp->hash_seed) & in bnxt_alloc_l2_filter()
5967 return ERR_PTR(-ENOMEM); in bnxt_alloc_l2_filter()
5968 spin_lock_bh(&bp->ntp_fltr_lock); in bnxt_alloc_l2_filter()
5970 spin_unlock_bh(&bp->ntp_fltr_lock); in bnxt_alloc_l2_filter()
5986 idx = jhash2(&key->filter_key, BNXT_L2_KEY_SIZE, bp->hash_seed) & in bnxt_alloc_new_l2_filter()
5988 spin_lock_bh(&bp->ntp_fltr_lock); in bnxt_alloc_new_l2_filter()
5991 fltr = ERR_PTR(-EEXIST); in bnxt_alloc_new_l2_filter()
5996 fltr = ERR_PTR(-ENOMEM); in bnxt_alloc_new_l2_filter()
5999 fltr->base.flags = flags; in bnxt_alloc_new_l2_filter()
6002 spin_unlock_bh(&bp->ntp_fltr_lock); in bnxt_alloc_new_l2_filter()
6008 spin_unlock_bh(&bp->ntp_fltr_lock); in bnxt_alloc_new_l2_filter()
6015 struct bnxt_vf_info *vf = &pf->vf[vf_idx]; in bnxt_vf_target_id()
6017 return vf->fw_fid; in bnxt_vf_target_id()
6029 if (fltr->base.flags & BNXT_ACT_FUNC_DST) { in bnxt_hwrm_l2_filter_free()
6030 struct bnxt_pf_info *pf = &bp->pf; in bnxt_hwrm_l2_filter_free()
6032 if (fltr->base.vf_idx >= pf->active_vfs) in bnxt_hwrm_l2_filter_free()
6033 return -EINVAL; in bnxt_hwrm_l2_filter_free()
6035 target_id = bnxt_vf_target_id(pf, fltr->base.vf_idx); in bnxt_hwrm_l2_filter_free()
6037 return -EINVAL; in bnxt_hwrm_l2_filter_free()
6044 req->target_id = cpu_to_le16(target_id); in bnxt_hwrm_l2_filter_free()
6045 req->l2_filter_id = fltr->base.filter_id; in bnxt_hwrm_l2_filter_free()
6056 if (fltr->base.flags & BNXT_ACT_FUNC_DST) { in bnxt_hwrm_l2_filter_alloc()
6057 struct bnxt_pf_info *pf = &bp->pf; in bnxt_hwrm_l2_filter_alloc()
6059 if (fltr->base.vf_idx >= pf->active_vfs) in bnxt_hwrm_l2_filter_alloc()
6060 return -EINVAL; in bnxt_hwrm_l2_filter_alloc()
6062 target_id = bnxt_vf_target_id(pf, fltr->base.vf_idx); in bnxt_hwrm_l2_filter_alloc()
6068 req->target_id = cpu_to_le16(target_id); in bnxt_hwrm_l2_filter_alloc()
6069 req->flags = cpu_to_le32(CFA_L2_FILTER_ALLOC_REQ_FLAGS_PATH_RX); in bnxt_hwrm_l2_filter_alloc()
6072 req->flags |= in bnxt_hwrm_l2_filter_alloc()
6074 req->dst_id = cpu_to_le16(fltr->base.fw_vnic_id); in bnxt_hwrm_l2_filter_alloc()
6075 req->enables = in bnxt_hwrm_l2_filter_alloc()
6079 ether_addr_copy(req->l2_addr, fltr->l2_key.dst_mac_addr); in bnxt_hwrm_l2_filter_alloc()
6080 eth_broadcast_addr(req->l2_addr_mask); in bnxt_hwrm_l2_filter_alloc()
6082 if (fltr->l2_key.vlan) { in bnxt_hwrm_l2_filter_alloc()
6083 req->enables |= in bnxt_hwrm_l2_filter_alloc()
6087 req->num_vlans = 1; in bnxt_hwrm_l2_filter_alloc()
6088 req->l2_ivlan = cpu_to_le16(fltr->l2_key.vlan); in bnxt_hwrm_l2_filter_alloc()
6089 req->l2_ivlan_mask = cpu_to_le16(0xfff); in bnxt_hwrm_l2_filter_alloc()
6095 fltr->base.filter_id = resp->l2_filter_id; in bnxt_hwrm_l2_filter_alloc()
6096 set_bit(BNXT_FLTR_VALID, &fltr->base.state); in bnxt_hwrm_l2_filter_alloc()
6108 set_bit(BNXT_FLTR_FW_DELETED, &fltr->base.state); in bnxt_hwrm_cfa_ntuple_filter_free()
6113 req->ntuple_filter_id = fltr->base.filter_id; in bnxt_hwrm_cfa_ntuple_filter_free()
6148 u16 rxq = fltr->base.rxq; in bnxt_cfg_rfs_ring_tbl_idx()
6150 if (fltr->base.flags & BNXT_ACT_RSS_CTX) { in bnxt_cfg_rfs_ring_tbl_idx()
6155 ctx = xa_load(&bp->dev->ethtool->rss_ctx, in bnxt_cfg_rfs_ring_tbl_idx()
6156 fltr->base.fw_vnic_id); in bnxt_cfg_rfs_ring_tbl_idx()
6159 vnic = &rss_ctx->vnic; in bnxt_cfg_rfs_ring_tbl_idx()
6161 req->dst_id = cpu_to_le16(vnic->fw_vnic_id); in bnxt_cfg_rfs_ring_tbl_idx()
6169 vnic = &bp->vnic_info[BNXT_VNIC_NTUPLE]; in bnxt_cfg_rfs_ring_tbl_idx()
6170 req->dst_id = cpu_to_le16(vnic->fw_vnic_id); in bnxt_cfg_rfs_ring_tbl_idx()
6172 req->enables |= cpu_to_le32(enables); in bnxt_cfg_rfs_ring_tbl_idx()
6173 req->rfs_ring_tbl_idx = cpu_to_le16(rxq); in bnxt_cfg_rfs_ring_tbl_idx()
6178 req->flags |= cpu_to_le32(flags); in bnxt_cfg_rfs_ring_tbl_idx()
6179 req->dst_id = cpu_to_le16(rxq); in bnxt_cfg_rfs_ring_tbl_idx()
6188 struct bnxt_flow_masks *masks = &fltr->fmasks; in bnxt_hwrm_cfa_ntuple_filter_alloc()
6189 struct flow_keys *keys = &fltr->fkeys; in bnxt_hwrm_cfa_ntuple_filter_alloc()
6198 l2_fltr = fltr->l2_fltr; in bnxt_hwrm_cfa_ntuple_filter_alloc()
6199 req->l2_filter_id = l2_fltr->base.filter_id; in bnxt_hwrm_cfa_ntuple_filter_alloc()
6201 if (fltr->base.flags & BNXT_ACT_DROP) { in bnxt_hwrm_cfa_ntuple_filter_alloc()
6202 req->flags = in bnxt_hwrm_cfa_ntuple_filter_alloc()
6204 } else if (bp->fw_cap & BNXT_FW_CAP_CFA_RFS_RING_TBL_IDX_V2) { in bnxt_hwrm_cfa_ntuple_filter_alloc()
6207 vnic = &bp->vnic_info[fltr->base.rxq + 1]; in bnxt_hwrm_cfa_ntuple_filter_alloc()
6208 req->dst_id = cpu_to_le16(vnic->fw_vnic_id); in bnxt_hwrm_cfa_ntuple_filter_alloc()
6210 req->enables |= cpu_to_le32(BNXT_NTP_FLTR_FLAGS); in bnxt_hwrm_cfa_ntuple_filter_alloc()
6212 req->ethertype = htons(ETH_P_IP); in bnxt_hwrm_cfa_ntuple_filter_alloc()
6213 req->ip_addr_type = CFA_NTUPLE_FILTER_ALLOC_REQ_IP_ADDR_TYPE_IPV4; in bnxt_hwrm_cfa_ntuple_filter_alloc()
6214 req->ip_protocol = keys->basic.ip_proto; in bnxt_hwrm_cfa_ntuple_filter_alloc()
6216 if (keys->basic.n_proto == htons(ETH_P_IPV6)) { in bnxt_hwrm_cfa_ntuple_filter_alloc()
6217 req->ethertype = htons(ETH_P_IPV6); in bnxt_hwrm_cfa_ntuple_filter_alloc()
6218 req->ip_addr_type = in bnxt_hwrm_cfa_ntuple_filter_alloc()
6220 *(struct in6_addr *)&req->src_ipaddr[0] = keys->addrs.v6addrs.src; in bnxt_hwrm_cfa_ntuple_filter_alloc()
6221 *(struct in6_addr *)&req->src_ipaddr_mask[0] = masks->addrs.v6addrs.src; in bnxt_hwrm_cfa_ntuple_filter_alloc()
6222 *(struct in6_addr *)&req->dst_ipaddr[0] = keys->addrs.v6addrs.dst; in bnxt_hwrm_cfa_ntuple_filter_alloc()
6223 *(struct in6_addr *)&req->dst_ipaddr_mask[0] = masks->addrs.v6addrs.dst; in bnxt_hwrm_cfa_ntuple_filter_alloc()
6225 req->src_ipaddr[0] = keys->addrs.v4addrs.src; in bnxt_hwrm_cfa_ntuple_filter_alloc()
6226 req->src_ipaddr_mask[0] = masks->addrs.v4addrs.src; in bnxt_hwrm_cfa_ntuple_filter_alloc()
6227 req->dst_ipaddr[0] = keys->addrs.v4addrs.dst; in bnxt_hwrm_cfa_ntuple_filter_alloc()
6228 req->dst_ipaddr_mask[0] = masks->addrs.v4addrs.dst; in bnxt_hwrm_cfa_ntuple_filter_alloc()
6230 if (keys->control.flags & FLOW_DIS_ENCAPSULATION) { in bnxt_hwrm_cfa_ntuple_filter_alloc()
6231 req->enables |= cpu_to_le32(BNXT_NTP_TUNNEL_FLTR_FLAG); in bnxt_hwrm_cfa_ntuple_filter_alloc()
6232 req->tunnel_type = in bnxt_hwrm_cfa_ntuple_filter_alloc()
6236 req->src_port = keys->ports.src; in bnxt_hwrm_cfa_ntuple_filter_alloc()
6237 req->src_port_mask = masks->ports.src; in bnxt_hwrm_cfa_ntuple_filter_alloc()
6238 req->dst_port = keys->ports.dst; in bnxt_hwrm_cfa_ntuple_filter_alloc()
6239 req->dst_port_mask = masks->ports.dst; in bnxt_hwrm_cfa_ntuple_filter_alloc()
6244 fltr->base.filter_id = resp->ntuple_filter_id; in bnxt_hwrm_cfa_ntuple_filter_alloc()
6262 fltr->base.fw_vnic_id = bp->vnic_info[vnic_id].fw_vnic_id; in bnxt_hwrm_set_vnic_filter()
6267 bp->vnic_info[vnic_id].l2_filters[idx] = fltr; in bnxt_hwrm_set_vnic_filter()
6277 struct bnxt_vnic_info *vnic = &bp->vnic_info[i]; in bnxt_hwrm_clear_vnic_filter()
6279 for (j = 0; j < vnic->uc_filter_count; j++) { in bnxt_hwrm_clear_vnic_filter()
6280 struct bnxt_l2_filter *fltr = vnic->l2_filters[j]; in bnxt_hwrm_clear_vnic_filter()
6285 vnic->uc_filter_count = 0; in bnxt_hwrm_clear_vnic_filter()
6299 if (!(bp->fw_cap & BNXT_FW_CAP_VNIC_TUNNEL_TPA)) in bnxt_hwrm_vnic_update_tunl_tpa()
6302 if (bp->vxlan_port) in bnxt_hwrm_vnic_update_tunl_tpa()
6304 if (bp->vxlan_gpe_port) in bnxt_hwrm_vnic_update_tunl_tpa()
6306 if (bp->nge_port) in bnxt_hwrm_vnic_update_tunl_tpa()
6309 req->enables |= cpu_to_le32(VNIC_TPA_CFG_REQ_ENABLES_TNL_TPA_EN); in bnxt_hwrm_vnic_update_tunl_tpa()
6310 req->tnl_tpa_en_bitmap = cpu_to_le32(tunl_tpa_bmap); in bnxt_hwrm_vnic_update_tunl_tpa()
6320 if (vnic->fw_vnic_id == INVALID_HW_RING_ID) in bnxt_hwrm_vnic_set_tpa()
6328 u16 mss = bp->dev->mtu - 40; in bnxt_hwrm_vnic_set_tpa()
6339 req->flags = cpu_to_le32(flags); in bnxt_hwrm_vnic_set_tpa()
6341 req->enables = in bnxt_hwrm_vnic_set_tpa()
6351 nsegs = (MAX_SKB_FRAGS - 1) * n; in bnxt_hwrm_vnic_set_tpa()
6354 if (mss & (BNXT_RX_PAGE_SIZE - 1)) in bnxt_hwrm_vnic_set_tpa()
6356 nsegs = (MAX_SKB_FRAGS - n) / n; in bnxt_hwrm_vnic_set_tpa()
6359 if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) { in bnxt_hwrm_vnic_set_tpa()
6361 max_aggs = bp->max_tpa; in bnxt_hwrm_vnic_set_tpa()
6365 req->max_agg_segs = cpu_to_le16(segs); in bnxt_hwrm_vnic_set_tpa()
6366 req->max_aggs = cpu_to_le16(max_aggs); in bnxt_hwrm_vnic_set_tpa()
6368 req->min_agg_len = cpu_to_le32(512); in bnxt_hwrm_vnic_set_tpa()
6371 req->vnic_id = cpu_to_le16(vnic->fw_vnic_id); in bnxt_hwrm_vnic_set_tpa()
6380 grp_info = &bp->grp_info[ring->grp_idx]; in bnxt_cp_ring_from_grp()
6381 return grp_info->cp_fw_ring_id; in bnxt_cp_ring_from_grp()
6386 if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) in bnxt_cp_ring_for_rx()
6387 return rxr->rx_cpr->cp_ring_struct.fw_ring_id; in bnxt_cp_ring_for_rx()
6389 return bnxt_cp_ring_from_grp(bp, &rxr->rx_ring_struct); in bnxt_cp_ring_for_rx()
6394 if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) in bnxt_cp_ring_for_tx()
6395 return txr->tx_cpr->cp_ring_struct.fw_ring_id; in bnxt_cp_ring_for_tx()
6397 return bnxt_cp_ring_from_grp(bp, &txr->tx_ring_struct); in bnxt_cp_ring_for_tx()
6404 if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) in bnxt_alloc_rss_indir_tbl()
6409 bp->rss_indir_tbl_entries = entries; in bnxt_alloc_rss_indir_tbl()
6410 bp->rss_indir_tbl = in bnxt_alloc_rss_indir_tbl()
6411 kmalloc_array(entries, sizeof(*bp->rss_indir_tbl), GFP_KERNEL); in bnxt_alloc_rss_indir_tbl()
6412 if (!bp->rss_indir_tbl) in bnxt_alloc_rss_indir_tbl()
6413 return -ENOMEM; in bnxt_alloc_rss_indir_tbl()
6424 if (!bp->rx_nr_rings) in bnxt_set_dflt_rss_indir_tbl()
6428 max_rings = bp->rx_nr_rings - 1; in bnxt_set_dflt_rss_indir_tbl()
6430 max_rings = bp->rx_nr_rings; in bnxt_set_dflt_rss_indir_tbl()
6432 max_entries = bnxt_get_rxfh_indir_size(bp->dev); in bnxt_set_dflt_rss_indir_tbl()
6436 rss_indir_tbl = &bp->rss_indir_tbl[0]; in bnxt_set_dflt_rss_indir_tbl()
6441 pad = bp->rss_indir_tbl_entries - max_entries; in bnxt_set_dflt_rss_indir_tbl()
6450 if (!bp->rss_indir_tbl) in bnxt_get_max_rss_ring()
6453 tbl_size = bnxt_get_rxfh_indir_size(bp->dev); in bnxt_get_max_rss_ring()
6455 max_ring = max(max_ring, bp->rss_indir_tbl[i]); in bnxt_get_max_rss_ring()
6461 if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) { in bnxt_get_nr_rss_ctxs()
6464 return bnxt_calc_nr_ring_pages(rx_rings - 1, in bnxt_get_nr_rss_ctxs()
6474 bool no_rss = !(vnic->flags & BNXT_VNIC_RSS_FLAG); in bnxt_fill_hw_rss_tbl()
6480 j = bp->rss_indir_tbl[i]; in bnxt_fill_hw_rss_tbl()
6481 vnic->rss_table[i] = cpu_to_le16(vnic->fw_grp_ids[j]); in bnxt_fill_hw_rss_tbl()
6488 __le16 *ring_tbl = vnic->rss_table; in bnxt_fill_hw_rss_tbl_p5()
6492 tbl_size = bnxt_get_rxfh_indir_size(bp->dev); in bnxt_fill_hw_rss_tbl_p5()
6497 if (vnic->flags & BNXT_VNIC_NTUPLE_FLAG) in bnxt_fill_hw_rss_tbl_p5()
6498 j = ethtool_rxfh_indir_default(i, bp->rx_nr_rings); in bnxt_fill_hw_rss_tbl_p5()
6499 else if (vnic->flags & BNXT_VNIC_RSSCTX_FLAG) in bnxt_fill_hw_rss_tbl_p5()
6500 j = ethtool_rxfh_context_indir(vnic->rss_ctx)[i]; in bnxt_fill_hw_rss_tbl_p5()
6502 j = bp->rss_indir_tbl[i]; in bnxt_fill_hw_rss_tbl_p5()
6503 rxr = &bp->rx_ring[j]; in bnxt_fill_hw_rss_tbl_p5()
6505 ring_id = rxr->rx_ring_struct.fw_ring_id; in bnxt_fill_hw_rss_tbl_p5()
6516 if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) { in __bnxt_hwrm_vnic_set_rss()
6518 if (bp->flags & BNXT_FLAG_CHIP_P7) in __bnxt_hwrm_vnic_set_rss()
6519 req->flags |= VNIC_RSS_CFG_REQ_FLAGS_IPSEC_HASH_TYPE_CFG_SUPPORT; in __bnxt_hwrm_vnic_set_rss()
6524 if (bp->rss_hash_delta) { in __bnxt_hwrm_vnic_set_rss()
6525 req->hash_type = cpu_to_le32(bp->rss_hash_delta); in __bnxt_hwrm_vnic_set_rss()
6526 if (bp->rss_hash_cfg & bp->rss_hash_delta) in __bnxt_hwrm_vnic_set_rss()
6527 req->flags |= VNIC_RSS_CFG_REQ_FLAGS_HASH_TYPE_INCLUDE; in __bnxt_hwrm_vnic_set_rss()
6529 req->flags |= VNIC_RSS_CFG_REQ_FLAGS_HASH_TYPE_EXCLUDE; in __bnxt_hwrm_vnic_set_rss()
6531 req->hash_type = cpu_to_le32(bp->rss_hash_cfg); in __bnxt_hwrm_vnic_set_rss()
6533 req->hash_mode_flags = VNIC_RSS_CFG_REQ_HASH_MODE_FLAGS_DEFAULT; in __bnxt_hwrm_vnic_set_rss()
6534 req->ring_grp_tbl_addr = cpu_to_le64(vnic->rss_table_dma_addr); in __bnxt_hwrm_vnic_set_rss()
6535 req->hash_key_tbl_addr = cpu_to_le64(vnic->rss_hash_key_dma_addr); in __bnxt_hwrm_vnic_set_rss()
6544 if ((bp->flags & BNXT_FLAG_CHIP_P5_PLUS) || in bnxt_hwrm_vnic_set_rss()
6545 vnic->fw_rss_cos_lb_ctx[0] == INVALID_HW_RING_ID) in bnxt_hwrm_vnic_set_rss()
6554 req->rss_ctx_idx = cpu_to_le16(vnic->fw_rss_cos_lb_ctx[0]); in bnxt_hwrm_vnic_set_rss()
6570 req->vnic_id = cpu_to_le16(vnic->fw_vnic_id); in bnxt_hwrm_vnic_set_rss_p5()
6575 ring_tbl_map = vnic->rss_table_dma_addr; in bnxt_hwrm_vnic_set_rss_p5()
6576 nr_ctxs = bnxt_get_nr_rss_ctxs(bp, bp->rx_nr_rings); in bnxt_hwrm_vnic_set_rss_p5()
6580 req->ring_grp_tbl_addr = cpu_to_le64(ring_tbl_map); in bnxt_hwrm_vnic_set_rss_p5()
6581 req->ring_table_pair_index = i; in bnxt_hwrm_vnic_set_rss_p5()
6582 req->rss_ctx_idx = cpu_to_le16(vnic->fw_rss_cos_lb_ctx[i]); in bnxt_hwrm_vnic_set_rss_p5()
6595 struct bnxt_vnic_info *vnic = &bp->vnic_info[BNXT_VNIC_DEFAULT]; in bnxt_hwrm_update_rss_hash_cfg()
6602 req->vnic_id = cpu_to_le16(vnic->fw_vnic_id); in bnxt_hwrm_update_rss_hash_cfg()
6604 req->rss_ctx_idx = cpu_to_le16(vnic->fw_rss_cos_lb_ctx[0]); in bnxt_hwrm_update_rss_hash_cfg()
6607 bp->rss_hash_cfg = le32_to_cpu(resp->hash_type) ?: bp->rss_hash_cfg; in bnxt_hwrm_update_rss_hash_cfg()
6608 bp->rss_hash_delta = 0; in bnxt_hwrm_update_rss_hash_cfg()
6615 u16 hds_thresh = (u16)bp->dev->cfg_pending->hds_thresh; in bnxt_hwrm_vnic_set_hds()
6623 req->flags = cpu_to_le32(VNIC_PLCMODES_CFG_REQ_FLAGS_JUMBO_PLACEMENT); in bnxt_hwrm_vnic_set_hds()
6624 req->enables = cpu_to_le32(VNIC_PLCMODES_CFG_REQ_ENABLES_JUMBO_THRESH_VALID); in bnxt_hwrm_vnic_set_hds()
6625 req->jumbo_thresh = cpu_to_le16(bp->rx_buf_use_size); in bnxt_hwrm_vnic_set_hds()
6627 if (!BNXT_RX_PAGE_MODE(bp) && (bp->flags & BNXT_FLAG_AGG_RINGS)) { in bnxt_hwrm_vnic_set_hds()
6628 req->flags |= cpu_to_le32(VNIC_PLCMODES_CFG_REQ_FLAGS_HDS_IPV4 | in bnxt_hwrm_vnic_set_hds()
6630 req->enables |= in bnxt_hwrm_vnic_set_hds()
6632 req->hds_threshold = cpu_to_le16(hds_thresh); in bnxt_hwrm_vnic_set_hds()
6634 req->vnic_id = cpu_to_le32(vnic->fw_vnic_id); in bnxt_hwrm_vnic_set_hds()
6647 req->rss_cos_lb_ctx_id = in bnxt_hwrm_vnic_ctx_free_one()
6648 cpu_to_le16(vnic->fw_rss_cos_lb_ctx[ctx_idx]); in bnxt_hwrm_vnic_ctx_free_one()
6651 vnic->fw_rss_cos_lb_ctx[ctx_idx] = INVALID_HW_RING_ID; in bnxt_hwrm_vnic_ctx_free_one()
6658 for (i = 0; i < bp->nr_vnics; i++) { in bnxt_hwrm_vnic_ctx_free()
6659 struct bnxt_vnic_info *vnic = &bp->vnic_info[i]; in bnxt_hwrm_vnic_ctx_free()
6662 if (vnic->fw_rss_cos_lb_ctx[j] != INVALID_HW_RING_ID) in bnxt_hwrm_vnic_ctx_free()
6666 bp->rsscos_nr_ctxs = 0; in bnxt_hwrm_vnic_ctx_free()
6683 vnic->fw_rss_cos_lb_ctx[ctx_idx] = in bnxt_hwrm_vnic_ctx_alloc()
6684 le16_to_cpu(resp->rss_cos_lb_ctx_id); in bnxt_hwrm_vnic_ctx_alloc()
6692 if (bp->flags & BNXT_FLAG_ROCE_MIRROR_CAP) in bnxt_get_roce_vnic_mode()
6699 struct bnxt_vnic_info *vnic0 = &bp->vnic_info[BNXT_VNIC_DEFAULT]; in bnxt_hwrm_vnic_cfg()
6709 if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) { in bnxt_hwrm_vnic_cfg()
6710 struct bnxt_rx_ring_info *rxr = &bp->rx_ring[0]; in bnxt_hwrm_vnic_cfg()
6712 req->default_rx_ring_id = in bnxt_hwrm_vnic_cfg()
6713 cpu_to_le16(rxr->rx_ring_struct.fw_ring_id); in bnxt_hwrm_vnic_cfg()
6714 req->default_cmpl_ring_id = in bnxt_hwrm_vnic_cfg()
6716 req->enables = in bnxt_hwrm_vnic_cfg()
6721 req->enables = cpu_to_le32(VNIC_CFG_REQ_ENABLES_DFLT_RING_GRP); in bnxt_hwrm_vnic_cfg()
6723 if (vnic->fw_rss_cos_lb_ctx[0] != INVALID_HW_RING_ID) { in bnxt_hwrm_vnic_cfg()
6724 req->rss_rule = cpu_to_le16(vnic->fw_rss_cos_lb_ctx[0]); in bnxt_hwrm_vnic_cfg()
6725 req->enables |= cpu_to_le32(VNIC_CFG_REQ_ENABLES_RSS_RULE | in bnxt_hwrm_vnic_cfg()
6727 } else if (vnic->flags & BNXT_VNIC_RFS_NEW_RSS_FLAG) { in bnxt_hwrm_vnic_cfg()
6728 req->rss_rule = cpu_to_le16(vnic0->fw_rss_cos_lb_ctx[0]); in bnxt_hwrm_vnic_cfg()
6729 req->enables |= cpu_to_le32(VNIC_CFG_REQ_ENABLES_RSS_RULE | in bnxt_hwrm_vnic_cfg()
6731 req->flags |= cpu_to_le32(VNIC_CFG_REQ_FLAGS_RSS_DFLT_CR_MODE); in bnxt_hwrm_vnic_cfg()
6733 req->rss_rule = cpu_to_le16(0xffff); in bnxt_hwrm_vnic_cfg()
6737 (vnic->fw_rss_cos_lb_ctx[0] != INVALID_HW_RING_ID)) { in bnxt_hwrm_vnic_cfg()
6738 req->cos_rule = cpu_to_le16(vnic->fw_rss_cos_lb_ctx[1]); in bnxt_hwrm_vnic_cfg()
6739 req->enables |= cpu_to_le32(VNIC_CFG_REQ_ENABLES_COS_RULE); in bnxt_hwrm_vnic_cfg()
6741 req->cos_rule = cpu_to_le16(0xffff); in bnxt_hwrm_vnic_cfg()
6744 if (vnic->flags & BNXT_VNIC_RSS_FLAG) in bnxt_hwrm_vnic_cfg()
6746 else if (vnic->flags & BNXT_VNIC_RFS_FLAG) in bnxt_hwrm_vnic_cfg()
6747 ring = vnic->vnic_id - 1; in bnxt_hwrm_vnic_cfg()
6748 else if ((vnic->vnic_id == 1) && BNXT_CHIP_TYPE_NITRO_A0(bp)) in bnxt_hwrm_vnic_cfg()
6749 ring = bp->rx_nr_rings - 1; in bnxt_hwrm_vnic_cfg()
6751 grp_idx = bp->rx_ring[ring].bnapi->index; in bnxt_hwrm_vnic_cfg()
6752 req->dflt_ring_grp = cpu_to_le16(bp->grp_info[grp_idx].fw_grp_id); in bnxt_hwrm_vnic_cfg()
6753 req->lb_rule = cpu_to_le16(0xffff); in bnxt_hwrm_vnic_cfg()
6755 vnic->mru = bp->dev->mtu + ETH_HLEN + VLAN_HLEN; in bnxt_hwrm_vnic_cfg()
6756 req->mru = cpu_to_le16(vnic->mru); in bnxt_hwrm_vnic_cfg()
6758 req->vnic_id = cpu_to_le16(vnic->fw_vnic_id); in bnxt_hwrm_vnic_cfg()
6761 def_vlan = bp->vf.vlan; in bnxt_hwrm_vnic_cfg()
6763 if ((bp->flags & BNXT_FLAG_STRIP_VLAN) || def_vlan) in bnxt_hwrm_vnic_cfg()
6764 req->flags |= cpu_to_le32(VNIC_CFG_REQ_FLAGS_VLAN_STRIP_MODE); in bnxt_hwrm_vnic_cfg()
6765 if (vnic->vnic_id == BNXT_VNIC_DEFAULT && bnxt_ulp_registered(bp->edev)) in bnxt_hwrm_vnic_cfg()
6766 req->flags |= cpu_to_le32(bnxt_get_roce_vnic_mode(bp)); in bnxt_hwrm_vnic_cfg()
6774 if (vnic->fw_vnic_id != INVALID_HW_RING_ID) { in bnxt_hwrm_vnic_free_one()
6780 req->vnic_id = cpu_to_le32(vnic->fw_vnic_id); in bnxt_hwrm_vnic_free_one()
6783 vnic->fw_vnic_id = INVALID_HW_RING_ID; in bnxt_hwrm_vnic_free_one()
6791 for (i = 0; i < bp->nr_vnics; i++) in bnxt_hwrm_vnic_free()
6792 bnxt_hwrm_vnic_free_one(bp, &bp->vnic_info[i]); in bnxt_hwrm_vnic_free()
6808 if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) in bnxt_hwrm_vnic_alloc()
6813 grp_idx = bp->rx_ring[i].bnapi->index; in bnxt_hwrm_vnic_alloc()
6814 if (bp->grp_info[grp_idx].fw_grp_id == INVALID_HW_RING_ID) { in bnxt_hwrm_vnic_alloc()
6815 netdev_err(bp->dev, "Not enough ring groups avail:%x req:%x\n", in bnxt_hwrm_vnic_alloc()
6819 vnic->fw_grp_ids[j] = bp->grp_info[grp_idx].fw_grp_id; in bnxt_hwrm_vnic_alloc()
6824 vnic->fw_rss_cos_lb_ctx[i] = INVALID_HW_RING_ID; in bnxt_hwrm_vnic_alloc()
6825 if (vnic->vnic_id == BNXT_VNIC_DEFAULT) in bnxt_hwrm_vnic_alloc()
6826 req->flags = cpu_to_le32(VNIC_ALLOC_REQ_FLAGS_DEFAULT); in bnxt_hwrm_vnic_alloc()
6831 vnic->fw_vnic_id = le32_to_cpu(resp->vnic_id); in bnxt_hwrm_vnic_alloc()
6842 bp->hw_ring_stats_size = sizeof(struct ctx_hw_stats); in bnxt_hwrm_vnic_qcaps()
6843 bp->flags &= ~BNXT_FLAG_ROCE_MIRROR_CAP; in bnxt_hwrm_vnic_qcaps()
6844 bp->rss_cap &= ~BNXT_RSS_CAP_NEW_RSS_CAP; in bnxt_hwrm_vnic_qcaps()
6845 if (bp->hwrm_spec_code < 0x10600) in bnxt_hwrm_vnic_qcaps()
6855 u32 flags = le32_to_cpu(resp->flags); in bnxt_hwrm_vnic_qcaps()
6857 if (!(bp->flags & BNXT_FLAG_CHIP_P5_PLUS) && in bnxt_hwrm_vnic_qcaps()
6859 bp->rss_cap |= BNXT_RSS_CAP_NEW_RSS_CAP; in bnxt_hwrm_vnic_qcaps()
6862 bp->flags |= BNXT_FLAG_ROCE_MIRROR_CAP; in bnxt_hwrm_vnic_qcaps()
6869 !(bp->fw_cap & BNXT_FW_CAP_EXT_HW_STATS_SUPPORTED))) in bnxt_hwrm_vnic_qcaps()
6870 bp->fw_cap |= BNXT_FW_CAP_VLAN_RX_STRIP; in bnxt_hwrm_vnic_qcaps()
6872 bp->rss_cap |= BNXT_RSS_CAP_RSS_HASH_TYPE_DELTA; in bnxt_hwrm_vnic_qcaps()
6874 bp->rss_cap |= BNXT_RSS_CAP_RSS_TCAM; in bnxt_hwrm_vnic_qcaps()
6875 bp->max_tpa_v2 = le16_to_cpu(resp->max_aggs_supported); in bnxt_hwrm_vnic_qcaps()
6876 if (bp->max_tpa_v2) { in bnxt_hwrm_vnic_qcaps()
6878 bp->hw_ring_stats_size = BNXT_RING_STATS_SIZE_P5; in bnxt_hwrm_vnic_qcaps()
6880 bp->hw_ring_stats_size = BNXT_RING_STATS_SIZE_P7; in bnxt_hwrm_vnic_qcaps()
6883 bp->fw_cap |= BNXT_FW_CAP_VNIC_TUNNEL_TPA; in bnxt_hwrm_vnic_qcaps()
6885 bp->rss_cap |= BNXT_RSS_CAP_AH_V4_RSS_CAP; in bnxt_hwrm_vnic_qcaps()
6887 bp->rss_cap |= BNXT_RSS_CAP_AH_V6_RSS_CAP; in bnxt_hwrm_vnic_qcaps()
6889 bp->rss_cap |= BNXT_RSS_CAP_ESP_V4_RSS_CAP; in bnxt_hwrm_vnic_qcaps()
6891 bp->rss_cap |= BNXT_RSS_CAP_ESP_V6_RSS_CAP; in bnxt_hwrm_vnic_qcaps()
6893 bp->fw_cap |= BNXT_FW_CAP_VNIC_RE_FLUSH; in bnxt_hwrm_vnic_qcaps()
6906 if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) in bnxt_hwrm_ring_grp_alloc()
6914 for (i = 0; i < bp->rx_nr_rings; i++) { in bnxt_hwrm_ring_grp_alloc()
6915 unsigned int grp_idx = bp->rx_ring[i].bnapi->index; in bnxt_hwrm_ring_grp_alloc()
6917 req->cr = cpu_to_le16(bp->grp_info[grp_idx].cp_fw_ring_id); in bnxt_hwrm_ring_grp_alloc()
6918 req->rr = cpu_to_le16(bp->grp_info[grp_idx].rx_fw_ring_id); in bnxt_hwrm_ring_grp_alloc()
6919 req->ar = cpu_to_le16(bp->grp_info[grp_idx].agg_fw_ring_id); in bnxt_hwrm_ring_grp_alloc()
6920 req->sc = cpu_to_le16(bp->grp_info[grp_idx].fw_stats_ctx); in bnxt_hwrm_ring_grp_alloc()
6927 bp->grp_info[grp_idx].fw_grp_id = in bnxt_hwrm_ring_grp_alloc()
6928 le32_to_cpu(resp->ring_group_id); in bnxt_hwrm_ring_grp_alloc()
6939 if (!bp->grp_info || (bp->flags & BNXT_FLAG_CHIP_P5_PLUS)) in bnxt_hwrm_ring_grp_free()
6946 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_hwrm_ring_grp_free()
6947 if (bp->grp_info[i].fw_grp_id == INVALID_HW_RING_ID) in bnxt_hwrm_ring_grp_free()
6949 req->ring_group_id = in bnxt_hwrm_ring_grp_free()
6950 cpu_to_le32(bp->grp_info[i].fw_grp_id); in bnxt_hwrm_ring_grp_free()
6953 bp->grp_info[i].fw_grp_id = INVALID_HW_RING_ID; in bnxt_hwrm_ring_grp_free()
6964 struct bnxt_ring_mem_info *rmem = &ring->ring_mem; in hwrm_ring_alloc_send_msg()
6973 req->enables = 0; in hwrm_ring_alloc_send_msg()
6974 if (rmem->nr_pages > 1) { in hwrm_ring_alloc_send_msg()
6975 req->page_tbl_addr = cpu_to_le64(rmem->pg_tbl_map); in hwrm_ring_alloc_send_msg()
6977 req->page_size = BNXT_PAGE_SHIFT; in hwrm_ring_alloc_send_msg()
6978 req->page_tbl_depth = 1; in hwrm_ring_alloc_send_msg()
6980 req->page_tbl_addr = cpu_to_le64(rmem->dma_arr[0]); in hwrm_ring_alloc_send_msg()
6982 req->fbo = 0; in hwrm_ring_alloc_send_msg()
6984 req->logical_id = cpu_to_le16(map_index); in hwrm_ring_alloc_send_msg()
6993 req->ring_type = RING_ALLOC_REQ_RING_TYPE_TX; in hwrm_ring_alloc_send_msg()
6995 grp_info = &bp->grp_info[ring->grp_idx]; in hwrm_ring_alloc_send_msg()
6996 req->cmpl_ring_id = cpu_to_le16(bnxt_cp_ring_for_tx(bp, txr)); in hwrm_ring_alloc_send_msg()
6997 req->length = cpu_to_le32(bp->tx_ring_mask + 1); in hwrm_ring_alloc_send_msg()
6998 req->stat_ctx_id = cpu_to_le32(grp_info->fw_stats_ctx); in hwrm_ring_alloc_send_msg()
6999 req->queue_id = cpu_to_le16(ring->queue_id); in hwrm_ring_alloc_send_msg()
7000 if (bp->flags & BNXT_FLAG_TX_COAL_CMPL) in hwrm_ring_alloc_send_msg()
7001 req->cmpl_coal_cnt = in hwrm_ring_alloc_send_msg()
7003 if ((bp->fw_cap & BNXT_FW_CAP_TX_TS_CMP) && bp->ptp_cfg) in hwrm_ring_alloc_send_msg()
7005 req->flags = cpu_to_le16(flags); in hwrm_ring_alloc_send_msg()
7009 req->ring_type = RING_ALLOC_REQ_RING_TYPE_RX; in hwrm_ring_alloc_send_msg()
7010 req->length = cpu_to_le32(bp->rx_ring_mask + 1); in hwrm_ring_alloc_send_msg()
7011 if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) { in hwrm_ring_alloc_send_msg()
7015 grp_info = &bp->grp_info[ring->grp_idx]; in hwrm_ring_alloc_send_msg()
7016 req->rx_buf_size = cpu_to_le16(bp->rx_buf_use_size); in hwrm_ring_alloc_send_msg()
7017 req->stat_ctx_id = cpu_to_le32(grp_info->fw_stats_ctx); in hwrm_ring_alloc_send_msg()
7018 req->enables |= cpu_to_le32( in hwrm_ring_alloc_send_msg()
7022 req->flags = cpu_to_le16(flags); in hwrm_ring_alloc_send_msg()
7026 if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) { in hwrm_ring_alloc_send_msg()
7027 req->ring_type = RING_ALLOC_REQ_RING_TYPE_RX_AGG; in hwrm_ring_alloc_send_msg()
7029 grp_info = &bp->grp_info[ring->grp_idx]; in hwrm_ring_alloc_send_msg()
7030 req->rx_ring_id = cpu_to_le16(grp_info->rx_fw_ring_id); in hwrm_ring_alloc_send_msg()
7031 req->rx_buf_size = cpu_to_le16(BNXT_RX_PAGE_SIZE); in hwrm_ring_alloc_send_msg()
7032 req->stat_ctx_id = cpu_to_le32(grp_info->fw_stats_ctx); in hwrm_ring_alloc_send_msg()
7033 req->enables |= cpu_to_le32( in hwrm_ring_alloc_send_msg()
7037 req->ring_type = RING_ALLOC_REQ_RING_TYPE_RX; in hwrm_ring_alloc_send_msg()
7039 req->length = cpu_to_le32(bp->rx_agg_ring_mask + 1); in hwrm_ring_alloc_send_msg()
7042 req->ring_type = RING_ALLOC_REQ_RING_TYPE_L2_CMPL; in hwrm_ring_alloc_send_msg()
7043 req->length = cpu_to_le32(bp->cp_ring_mask + 1); in hwrm_ring_alloc_send_msg()
7044 if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) { in hwrm_ring_alloc_send_msg()
7046 grp_info = &bp->grp_info[map_index]; in hwrm_ring_alloc_send_msg()
7047 req->nq_ring_id = cpu_to_le16(grp_info->cp_fw_ring_id); in hwrm_ring_alloc_send_msg()
7048 req->cq_handle = cpu_to_le64(ring->handle); in hwrm_ring_alloc_send_msg()
7049 req->enables |= cpu_to_le32( in hwrm_ring_alloc_send_msg()
7052 req->int_mode = RING_ALLOC_REQ_INT_MODE_MSIX; in hwrm_ring_alloc_send_msg()
7056 req->ring_type = RING_ALLOC_REQ_RING_TYPE_NQ; in hwrm_ring_alloc_send_msg()
7057 req->length = cpu_to_le32(bp->cp_ring_mask + 1); in hwrm_ring_alloc_send_msg()
7058 req->int_mode = RING_ALLOC_REQ_INT_MODE_MSIX; in hwrm_ring_alloc_send_msg()
7061 netdev_err(bp->dev, "hwrm alloc invalid ring type %d\n", in hwrm_ring_alloc_send_msg()
7063 return -1; in hwrm_ring_alloc_send_msg()
7068 err = le16_to_cpu(resp->error_code); in hwrm_ring_alloc_send_msg()
7069 ring_id = le16_to_cpu(resp->ring_id); in hwrm_ring_alloc_send_msg()
7074 netdev_err(bp->dev, "hwrm_ring_alloc type %d failed. rc:%x err:%x\n", in hwrm_ring_alloc_send_msg()
7076 return -EIO; in hwrm_ring_alloc_send_msg()
7078 ring->fw_ring_id = ring_id; in hwrm_ring_alloc_send_msg()
7093 req->fid = cpu_to_le16(0xffff); in bnxt_hwrm_set_async_event_cr()
7094 req->enables = cpu_to_le32(FUNC_CFG_REQ_ENABLES_ASYNC_EVENT_CR); in bnxt_hwrm_set_async_event_cr()
7095 req->async_event_cr = cpu_to_le16(idx); in bnxt_hwrm_set_async_event_cr()
7104 req->enables = in bnxt_hwrm_set_async_event_cr()
7106 req->async_event_cr = cpu_to_le16(idx); in bnxt_hwrm_set_async_event_cr()
7116 db->db_ring_mask = bp->tx_ring_mask; in bnxt_set_db_mask()
7119 db->db_ring_mask = bp->rx_ring_mask; in bnxt_set_db_mask()
7122 db->db_ring_mask = bp->rx_agg_ring_mask; in bnxt_set_db_mask()
7126 db->db_ring_mask = bp->cp_ring_mask; in bnxt_set_db_mask()
7129 if (bp->flags & BNXT_FLAG_CHIP_P7) { in bnxt_set_db_mask()
7130 db->db_epoch_mask = db->db_ring_mask + 1; in bnxt_set_db_mask()
7131 db->db_epoch_shift = DBR_EPOCH_SFT - ilog2(db->db_epoch_mask); in bnxt_set_db_mask()
7138 if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) { in bnxt_set_db()
7141 db->db_key64 = DBR_PATH_L2 | DBR_TYPE_SQ; in bnxt_set_db()
7145 db->db_key64 = DBR_PATH_L2 | DBR_TYPE_SRQ; in bnxt_set_db()
7148 db->db_key64 = DBR_PATH_L2; in bnxt_set_db()
7151 db->db_key64 = DBR_PATH_L2; in bnxt_set_db()
7154 db->db_key64 |= (u64)xid << DBR_XID_SFT; in bnxt_set_db()
7156 if (bp->flags & BNXT_FLAG_CHIP_P7) in bnxt_set_db()
7157 db->db_key64 |= DBR_VALID; in bnxt_set_db()
7159 db->doorbell = bp->bar1 + bp->db_offset; in bnxt_set_db()
7161 db->doorbell = bp->bar1 + map_idx * 0x80; in bnxt_set_db()
7164 db->db_key32 = DB_KEY_TX; in bnxt_set_db()
7168 db->db_key32 = DB_KEY_RX; in bnxt_set_db()
7171 db->db_key32 = DB_KEY_CP; in bnxt_set_db()
7181 struct bnxt_ring_struct *ring = &rxr->rx_ring_struct; in bnxt_hwrm_rx_ring_alloc()
7182 struct bnxt_napi *bnapi = rxr->bnapi; in bnxt_hwrm_rx_ring_alloc()
7184 u32 map_idx = bnapi->index; in bnxt_hwrm_rx_ring_alloc()
7191 bnxt_set_db(bp, &rxr->rx_db, type, map_idx, ring->fw_ring_id); in bnxt_hwrm_rx_ring_alloc()
7192 bp->grp_info[map_idx].rx_fw_ring_id = ring->fw_ring_id; in bnxt_hwrm_rx_ring_alloc()
7200 struct bnxt_ring_struct *ring = &rxr->rx_agg_ring_struct; in bnxt_hwrm_rx_agg_ring_alloc()
7202 u32 grp_idx = ring->grp_idx; in bnxt_hwrm_rx_agg_ring_alloc()
7206 map_idx = grp_idx + bp->rx_nr_rings; in bnxt_hwrm_rx_agg_ring_alloc()
7211 bnxt_set_db(bp, &rxr->rx_agg_db, type, map_idx, in bnxt_hwrm_rx_agg_ring_alloc()
7212 ring->fw_ring_id); in bnxt_hwrm_rx_agg_ring_alloc()
7213 bnxt_db_write(bp, &rxr->rx_agg_db, rxr->rx_agg_prod); in bnxt_hwrm_rx_agg_ring_alloc()
7214 bnxt_db_write(bp, &rxr->rx_db, rxr->rx_prod); in bnxt_hwrm_rx_agg_ring_alloc()
7215 bp->grp_info[grp_idx].agg_fw_ring_id = ring->fw_ring_id; in bnxt_hwrm_rx_agg_ring_alloc()
7222 bool agg_rings = !!(bp->flags & BNXT_FLAG_AGG_RINGS); in bnxt_hwrm_ring_alloc()
7226 if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) in bnxt_hwrm_ring_alloc()
7230 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_hwrm_ring_alloc()
7231 struct bnxt_napi *bnapi = bp->bnapi[i]; in bnxt_hwrm_ring_alloc()
7232 struct bnxt_cp_ring_info *cpr = &bnapi->cp_ring; in bnxt_hwrm_ring_alloc()
7233 struct bnxt_ring_struct *ring = &cpr->cp_ring_struct; in bnxt_hwrm_ring_alloc()
7234 u32 map_idx = ring->map_idx; in bnxt_hwrm_ring_alloc()
7237 vector = bp->irq_tbl[map_idx].vector; in bnxt_hwrm_ring_alloc()
7244 bnxt_set_db(bp, &cpr->cp_db, type, map_idx, ring->fw_ring_id); in bnxt_hwrm_ring_alloc()
7245 bnxt_db_nq(bp, &cpr->cp_db, cpr->cp_raw_cons); in bnxt_hwrm_ring_alloc()
7247 bp->grp_info[i].cp_fw_ring_id = ring->fw_ring_id; in bnxt_hwrm_ring_alloc()
7250 rc = bnxt_hwrm_set_async_event_cr(bp, ring->fw_ring_id); in bnxt_hwrm_ring_alloc()
7252 netdev_warn(bp->dev, "Failed to set async event completion ring.\n"); in bnxt_hwrm_ring_alloc()
7257 for (i = 0; i < bp->tx_nr_rings; i++) { in bnxt_hwrm_ring_alloc()
7258 struct bnxt_tx_ring_info *txr = &bp->tx_ring[i]; in bnxt_hwrm_ring_alloc()
7262 if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) { in bnxt_hwrm_ring_alloc()
7263 struct bnxt_cp_ring_info *cpr2 = txr->tx_cpr; in bnxt_hwrm_ring_alloc()
7264 struct bnxt_napi *bnapi = txr->bnapi; in bnxt_hwrm_ring_alloc()
7267 ring = &cpr2->cp_ring_struct; in bnxt_hwrm_ring_alloc()
7268 ring->handle = BNXT_SET_NQ_HDL(cpr2); in bnxt_hwrm_ring_alloc()
7269 map_idx = bnapi->index; in bnxt_hwrm_ring_alloc()
7273 bnxt_set_db(bp, &cpr2->cp_db, type2, map_idx, in bnxt_hwrm_ring_alloc()
7274 ring->fw_ring_id); in bnxt_hwrm_ring_alloc()
7275 bnxt_db_cq(bp, &cpr2->cp_db, cpr2->cp_raw_cons); in bnxt_hwrm_ring_alloc()
7277 ring = &txr->tx_ring_struct; in bnxt_hwrm_ring_alloc()
7282 bnxt_set_db(bp, &txr->tx_db, type, map_idx, ring->fw_ring_id); in bnxt_hwrm_ring_alloc()
7285 for (i = 0; i < bp->rx_nr_rings; i++) { in bnxt_hwrm_ring_alloc()
7286 struct bnxt_rx_ring_info *rxr = &bp->rx_ring[i]; in bnxt_hwrm_ring_alloc()
7293 bnxt_db_write(bp, &rxr->rx_db, rxr->rx_prod); in bnxt_hwrm_ring_alloc()
7294 if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) { in bnxt_hwrm_ring_alloc()
7295 struct bnxt_cp_ring_info *cpr2 = rxr->rx_cpr; in bnxt_hwrm_ring_alloc()
7296 struct bnxt_napi *bnapi = rxr->bnapi; in bnxt_hwrm_ring_alloc()
7299 u32 map_idx = bnapi->index; in bnxt_hwrm_ring_alloc()
7301 ring = &cpr2->cp_ring_struct; in bnxt_hwrm_ring_alloc()
7302 ring->handle = BNXT_SET_NQ_HDL(cpr2); in bnxt_hwrm_ring_alloc()
7306 bnxt_set_db(bp, &cpr2->cp_db, type2, map_idx, in bnxt_hwrm_ring_alloc()
7307 ring->fw_ring_id); in bnxt_hwrm_ring_alloc()
7308 bnxt_db_cq(bp, &cpr2->cp_db, cpr2->cp_raw_cons); in bnxt_hwrm_ring_alloc()
7313 for (i = 0; i < bp->rx_nr_rings; i++) { in bnxt_hwrm_ring_alloc()
7314 rc = bnxt_hwrm_rx_agg_ring_alloc(bp, &bp->rx_ring[i]); in bnxt_hwrm_ring_alloc()
7330 if (!bp->bnapi || test_bit(BNXT_STATE_NAPI_DISABLED, &bp->state)) in bnxt_cancel_dim()
7335 for (i = 0; i < bp->rx_nr_rings; i++) { in bnxt_cancel_dim()
7336 struct bnxt_rx_ring_info *rxr = &bp->rx_ring[i]; in bnxt_cancel_dim()
7337 struct bnxt_napi *bnapi = rxr->bnapi; in bnxt_cancel_dim()
7339 cancel_work_sync(&bnapi->cp_ring.dim.work); in bnxt_cancel_dim()
7359 req->cmpl_ring = cpu_to_le16(cmpl_ring_id); in hwrm_ring_free_send_msg()
7360 req->ring_type = ring_type; in hwrm_ring_free_send_msg()
7361 req->ring_id = cpu_to_le16(ring->fw_ring_id); in hwrm_ring_free_send_msg()
7365 error_code = le16_to_cpu(resp->error_code); in hwrm_ring_free_send_msg()
7369 netdev_err(bp->dev, "hwrm_ring_free type %d failed. rc:%x err:%x\n", in hwrm_ring_free_send_msg()
7371 return -EIO; in hwrm_ring_free_send_msg()
7380 struct bnxt_ring_struct *ring = &rxr->rx_ring_struct; in bnxt_hwrm_rx_ring_free()
7381 u32 grp_idx = rxr->bnapi->index; in bnxt_hwrm_rx_ring_free()
7384 if (ring->fw_ring_id == INVALID_HW_RING_ID) in bnxt_hwrm_rx_ring_free()
7392 ring->fw_ring_id = INVALID_HW_RING_ID; in bnxt_hwrm_rx_ring_free()
7393 bp->grp_info[grp_idx].rx_fw_ring_id = INVALID_HW_RING_ID; in bnxt_hwrm_rx_ring_free()
7400 struct bnxt_ring_struct *ring = &rxr->rx_agg_ring_struct; in bnxt_hwrm_rx_agg_ring_free()
7401 u32 grp_idx = rxr->bnapi->index; in bnxt_hwrm_rx_agg_ring_free()
7404 if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) in bnxt_hwrm_rx_agg_ring_free()
7409 if (ring->fw_ring_id == INVALID_HW_RING_ID) in bnxt_hwrm_rx_agg_ring_free()
7416 ring->fw_ring_id = INVALID_HW_RING_ID; in bnxt_hwrm_rx_agg_ring_free()
7417 bp->grp_info[grp_idx].agg_fw_ring_id = INVALID_HW_RING_ID; in bnxt_hwrm_rx_agg_ring_free()
7425 if (!bp->bnapi) in bnxt_hwrm_ring_free()
7428 for (i = 0; i < bp->tx_nr_rings; i++) { in bnxt_hwrm_ring_free()
7429 struct bnxt_tx_ring_info *txr = &bp->tx_ring[i]; in bnxt_hwrm_ring_free()
7430 struct bnxt_ring_struct *ring = &txr->tx_ring_struct; in bnxt_hwrm_ring_free()
7432 if (ring->fw_ring_id != INVALID_HW_RING_ID) { in bnxt_hwrm_ring_free()
7439 ring->fw_ring_id = INVALID_HW_RING_ID; in bnxt_hwrm_ring_free()
7444 for (i = 0; i < bp->rx_nr_rings; i++) { in bnxt_hwrm_ring_free()
7445 bnxt_hwrm_rx_ring_free(bp, &bp->rx_ring[i], close_path); in bnxt_hwrm_ring_free()
7446 bnxt_hwrm_rx_agg_ring_free(bp, &bp->rx_ring[i], close_path); in bnxt_hwrm_ring_free()
7455 if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) in bnxt_hwrm_ring_free()
7459 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_hwrm_ring_free()
7460 struct bnxt_napi *bnapi = bp->bnapi[i]; in bnxt_hwrm_ring_free()
7461 struct bnxt_cp_ring_info *cpr = &bnapi->cp_ring; in bnxt_hwrm_ring_free()
7465 for (j = 0; j < cpr->cp_ring_count && cpr->cp_ring_arr; j++) { in bnxt_hwrm_ring_free()
7466 struct bnxt_cp_ring_info *cpr2 = &cpr->cp_ring_arr[j]; in bnxt_hwrm_ring_free()
7468 ring = &cpr2->cp_ring_struct; in bnxt_hwrm_ring_free()
7469 if (ring->fw_ring_id == INVALID_HW_RING_ID) in bnxt_hwrm_ring_free()
7474 ring->fw_ring_id = INVALID_HW_RING_ID; in bnxt_hwrm_ring_free()
7476 ring = &cpr->cp_ring_struct; in bnxt_hwrm_ring_free()
7477 if (ring->fw_ring_id != INVALID_HW_RING_ID) { in bnxt_hwrm_ring_free()
7480 ring->fw_ring_id = INVALID_HW_RING_ID; in bnxt_hwrm_ring_free()
7481 bp->grp_info[i].cp_fw_ring_id = INVALID_HW_RING_ID; in bnxt_hwrm_ring_free()
7493 struct bnxt_hw_resc *hw_resc = &bp->hw_resc; in bnxt_hwrm_get_rings()
7498 if (bp->hwrm_spec_code < 0x10601) in bnxt_hwrm_get_rings()
7505 req->fid = cpu_to_le16(0xffff); in bnxt_hwrm_get_rings()
7513 hw_resc->resv_tx_rings = le16_to_cpu(resp->alloc_tx_rings); in bnxt_hwrm_get_rings()
7517 hw_resc->resv_rx_rings = le16_to_cpu(resp->alloc_rx_rings); in bnxt_hwrm_get_rings()
7518 hw_resc->resv_hw_ring_grps = in bnxt_hwrm_get_rings()
7519 le32_to_cpu(resp->alloc_hw_ring_grps); in bnxt_hwrm_get_rings()
7520 hw_resc->resv_vnics = le16_to_cpu(resp->alloc_vnics); in bnxt_hwrm_get_rings()
7521 hw_resc->resv_rsscos_ctxs = le16_to_cpu(resp->alloc_rsscos_ctx); in bnxt_hwrm_get_rings()
7522 cp = le16_to_cpu(resp->alloc_cmpl_rings); in bnxt_hwrm_get_rings()
7523 stats = le16_to_cpu(resp->alloc_stat_ctx); in bnxt_hwrm_get_rings()
7524 hw_resc->resv_irqs = cp; in bnxt_hwrm_get_rings()
7525 if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) { in bnxt_hwrm_get_rings()
7526 int rx = hw_resc->resv_rx_rings; in bnxt_hwrm_get_rings()
7527 int tx = hw_resc->resv_tx_rings; in bnxt_hwrm_get_rings()
7529 if (bp->flags & BNXT_FLAG_AGG_RINGS) in bnxt_hwrm_get_rings()
7535 if (bp->flags & BNXT_FLAG_AGG_RINGS) in bnxt_hwrm_get_rings()
7537 hw_resc->resv_rx_rings = rx; in bnxt_hwrm_get_rings()
7538 hw_resc->resv_tx_rings = tx; in bnxt_hwrm_get_rings()
7540 hw_resc->resv_irqs = le16_to_cpu(resp->alloc_msix); in bnxt_hwrm_get_rings()
7541 hw_resc->resv_hw_ring_grps = rx; in bnxt_hwrm_get_rings()
7543 hw_resc->resv_cp_rings = cp; in bnxt_hwrm_get_rings()
7544 hw_resc->resv_stat_ctxs = stats; in bnxt_hwrm_get_rings()
7557 if (bp->hwrm_spec_code < 0x10601) in __bnxt_hwrm_get_tx_rings()
7564 req->fid = cpu_to_le16(fid); in __bnxt_hwrm_get_tx_rings()
7568 *tx_rings = le16_to_cpu(resp->alloc_tx_rings); in __bnxt_hwrm_get_tx_rings()
7585 req->fid = cpu_to_le16(0xffff); in __bnxt_hwrm_reserve_pf_rings()
7586 enables |= hwr->tx ? FUNC_CFG_REQ_ENABLES_NUM_TX_RINGS : 0; in __bnxt_hwrm_reserve_pf_rings()
7587 req->num_tx_rings = cpu_to_le16(hwr->tx); in __bnxt_hwrm_reserve_pf_rings()
7589 enables |= hwr->rx ? FUNC_CFG_REQ_ENABLES_NUM_RX_RINGS : 0; in __bnxt_hwrm_reserve_pf_rings()
7590 enables |= hwr->stat ? FUNC_CFG_REQ_ENABLES_NUM_STAT_CTXS : 0; in __bnxt_hwrm_reserve_pf_rings()
7591 if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) { in __bnxt_hwrm_reserve_pf_rings()
7592 enables |= hwr->cp ? FUNC_CFG_REQ_ENABLES_NUM_MSIX : 0; in __bnxt_hwrm_reserve_pf_rings()
7593 enables |= hwr->cp_p5 ? in __bnxt_hwrm_reserve_pf_rings()
7596 enables |= hwr->cp ? in __bnxt_hwrm_reserve_pf_rings()
7598 enables |= hwr->grp ? in __bnxt_hwrm_reserve_pf_rings()
7601 enables |= hwr->vnic ? FUNC_CFG_REQ_ENABLES_NUM_VNICS : 0; in __bnxt_hwrm_reserve_pf_rings()
7602 enables |= hwr->rss_ctx ? FUNC_CFG_REQ_ENABLES_NUM_RSSCOS_CTXS : in __bnxt_hwrm_reserve_pf_rings()
7604 req->num_rx_rings = cpu_to_le16(hwr->rx); in __bnxt_hwrm_reserve_pf_rings()
7605 req->num_rsscos_ctxs = cpu_to_le16(hwr->rss_ctx); in __bnxt_hwrm_reserve_pf_rings()
7606 if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) { in __bnxt_hwrm_reserve_pf_rings()
7607 req->num_cmpl_rings = cpu_to_le16(hwr->cp_p5); in __bnxt_hwrm_reserve_pf_rings()
7608 req->num_msix = cpu_to_le16(hwr->cp); in __bnxt_hwrm_reserve_pf_rings()
7610 req->num_cmpl_rings = cpu_to_le16(hwr->cp); in __bnxt_hwrm_reserve_pf_rings()
7611 req->num_hw_ring_grps = cpu_to_le16(hwr->grp); in __bnxt_hwrm_reserve_pf_rings()
7613 req->num_stat_ctxs = cpu_to_le16(hwr->stat); in __bnxt_hwrm_reserve_pf_rings()
7614 req->num_vnics = cpu_to_le16(hwr->vnic); in __bnxt_hwrm_reserve_pf_rings()
7616 req->enables = cpu_to_le32(enables); in __bnxt_hwrm_reserve_pf_rings()
7629 enables |= hwr->tx ? FUNC_VF_CFG_REQ_ENABLES_NUM_TX_RINGS : 0; in __bnxt_hwrm_reserve_vf_rings()
7630 enables |= hwr->rx ? FUNC_VF_CFG_REQ_ENABLES_NUM_RX_RINGS | in __bnxt_hwrm_reserve_vf_rings()
7632 enables |= hwr->stat ? FUNC_VF_CFG_REQ_ENABLES_NUM_STAT_CTXS : 0; in __bnxt_hwrm_reserve_vf_rings()
7633 enables |= hwr->rss_ctx ? FUNC_VF_CFG_REQ_ENABLES_NUM_RSSCOS_CTXS : 0; in __bnxt_hwrm_reserve_vf_rings()
7634 if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) { in __bnxt_hwrm_reserve_vf_rings()
7635 enables |= hwr->cp_p5 ? in __bnxt_hwrm_reserve_vf_rings()
7638 enables |= hwr->cp ? FUNC_VF_CFG_REQ_ENABLES_NUM_CMPL_RINGS : 0; in __bnxt_hwrm_reserve_vf_rings()
7639 enables |= hwr->grp ? in __bnxt_hwrm_reserve_vf_rings()
7642 enables |= hwr->vnic ? FUNC_VF_CFG_REQ_ENABLES_NUM_VNICS : 0; in __bnxt_hwrm_reserve_vf_rings()
7645 req->num_l2_ctxs = cpu_to_le16(BNXT_VF_MAX_L2_CTX); in __bnxt_hwrm_reserve_vf_rings()
7646 req->num_tx_rings = cpu_to_le16(hwr->tx); in __bnxt_hwrm_reserve_vf_rings()
7647 req->num_rx_rings = cpu_to_le16(hwr->rx); in __bnxt_hwrm_reserve_vf_rings()
7648 req->num_rsscos_ctxs = cpu_to_le16(hwr->rss_ctx); in __bnxt_hwrm_reserve_vf_rings()
7649 if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) { in __bnxt_hwrm_reserve_vf_rings()
7650 req->num_cmpl_rings = cpu_to_le16(hwr->cp_p5); in __bnxt_hwrm_reserve_vf_rings()
7652 req->num_cmpl_rings = cpu_to_le16(hwr->cp); in __bnxt_hwrm_reserve_vf_rings()
7653 req->num_hw_ring_grps = cpu_to_le16(hwr->grp); in __bnxt_hwrm_reserve_vf_rings()
7655 req->num_stat_ctxs = cpu_to_le16(hwr->stat); in __bnxt_hwrm_reserve_vf_rings()
7656 req->num_vnics = cpu_to_le16(hwr->vnic); in __bnxt_hwrm_reserve_vf_rings()
7658 req->enables = cpu_to_le32(enables); in __bnxt_hwrm_reserve_vf_rings()
7670 return -ENOMEM; in bnxt_hwrm_reserve_pf_rings()
7672 if (!req->enables) { in bnxt_hwrm_reserve_pf_rings()
7681 if (bp->hwrm_spec_code < 0x10601) in bnxt_hwrm_reserve_pf_rings()
7682 bp->hw_resc.resv_tx_rings = hwr->tx; in bnxt_hwrm_reserve_pf_rings()
7694 bp->hw_resc.resv_tx_rings = hwr->tx; in bnxt_hwrm_reserve_vf_rings()
7700 return -ENOMEM; in bnxt_hwrm_reserve_vf_rings()
7719 return bp->cp_nr_rings + bnxt_get_ulp_msix_num(bp); in bnxt_nq_rings_in_use()
7726 if (!(bp->flags & BNXT_FLAG_CHIP_P5_PLUS)) in bnxt_cp_rings_in_use()
7729 cp = bp->tx_nr_rings + bp->rx_nr_rings; in bnxt_cp_rings_in_use()
7735 return bp->cp_nr_rings + bnxt_get_ulp_stat_ctxs(bp); in bnxt_get_func_stat_ctxs()
7740 if (!hwr->grp) in bnxt_get_total_rss_ctxs()
7742 if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) { in bnxt_get_total_rss_ctxs()
7743 int rss_ctx = bnxt_get_nr_rss_ctxs(bp, hwr->grp); in bnxt_get_total_rss_ctxs()
7746 rss_ctx *= hwr->vnic; in bnxt_get_total_rss_ctxs()
7751 if (!(bp->rss_cap & BNXT_RSS_CAP_NEW_RSS_CAP) && bnxt_rfs_supported(bp)) in bnxt_get_total_rss_ctxs()
7752 return hwr->grp + 1; in bnxt_get_total_rss_ctxs()
7761 struct bnxt_hw_resc *hw_resc = &bp->hw_resc; in bnxt_check_rss_tbl_no_rmgr()
7764 if (hw_resc->resv_rx_rings != bp->rx_nr_rings) { in bnxt_check_rss_tbl_no_rmgr()
7765 hw_resc->resv_rx_rings = bp->rx_nr_rings; in bnxt_check_rss_tbl_no_rmgr()
7766 if (!netif_is_rxfh_configured(bp->dev)) in bnxt_check_rss_tbl_no_rmgr()
7773 if (bp->flags & BNXT_FLAG_RFS) { in bnxt_get_total_vnics()
7775 return 2 + bp->num_rss_ctx; in bnxt_get_total_vnics()
7776 if (!(bp->flags & BNXT_FLAG_CHIP_P5_PLUS)) in bnxt_get_total_vnics()
7784 struct bnxt_hw_resc *hw_resc = &bp->hw_resc; in bnxt_need_reserve_rings()
7787 int rx = bp->rx_nr_rings, stat; in bnxt_need_reserve_rings()
7798 if (hw_resc->resv_tx_rings != bp->tx_nr_rings && in bnxt_need_reserve_rings()
7799 bp->hwrm_spec_code >= 0x10601) in bnxt_need_reserve_rings()
7807 if (bp->flags & BNXT_FLAG_AGG_RINGS) in bnxt_need_reserve_rings()
7810 if (hw_resc->resv_rx_rings != rx || hw_resc->resv_cp_rings != cp || in bnxt_need_reserve_rings()
7811 hw_resc->resv_vnics != vnic || hw_resc->resv_stat_ctxs != stat || in bnxt_need_reserve_rings()
7812 (hw_resc->resv_hw_ring_grps != grp && in bnxt_need_reserve_rings()
7813 !(bp->flags & BNXT_FLAG_CHIP_P5_PLUS))) in bnxt_need_reserve_rings()
7815 if ((bp->flags & BNXT_FLAG_CHIP_P5_PLUS) && BNXT_PF(bp) && in bnxt_need_reserve_rings()
7816 hw_resc->resv_irqs != nq) in bnxt_need_reserve_rings()
7823 struct bnxt_hw_resc *hw_resc = &bp->hw_resc; in bnxt_copy_reserved_rings()
7825 hwr->tx = hw_resc->resv_tx_rings; in bnxt_copy_reserved_rings()
7827 hwr->rx = hw_resc->resv_rx_rings; in bnxt_copy_reserved_rings()
7828 hwr->cp = hw_resc->resv_irqs; in bnxt_copy_reserved_rings()
7829 if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) in bnxt_copy_reserved_rings()
7830 hwr->cp_p5 = hw_resc->resv_cp_rings; in bnxt_copy_reserved_rings()
7831 hwr->grp = hw_resc->resv_hw_ring_grps; in bnxt_copy_reserved_rings()
7832 hwr->vnic = hw_resc->resv_vnics; in bnxt_copy_reserved_rings()
7833 hwr->stat = hw_resc->resv_stat_ctxs; in bnxt_copy_reserved_rings()
7834 hwr->rss_ctx = hw_resc->resv_rsscos_ctxs; in bnxt_copy_reserved_rings()
7840 return hwr->tx && hwr->rx && hwr->cp && hwr->grp && hwr->vnic && in bnxt_rings_ok()
7841 hwr->stat && (hwr->cp_p5 || !(bp->flags & BNXT_FLAG_CHIP_P5_PLUS)); in bnxt_rings_ok()
7850 int cp = bp->cp_nr_rings; in __bnxt_reserve_rings()
7858 if (BNXT_NEW_RM(bp) && !bnxt_ulp_registered(bp->edev)) { in __bnxt_reserve_rings()
7859 ulp_msix = bnxt_get_avail_msix(bp, bp->ulp_num_msix_want); in __bnxt_reserve_rings()
7863 if (ulp_msix > bp->ulp_num_msix_want) in __bnxt_reserve_rings()
7864 ulp_msix = bp->ulp_num_msix_want; in __bnxt_reserve_rings()
7870 hwr.tx = bp->tx_nr_rings; in __bnxt_reserve_rings()
7871 hwr.rx = bp->rx_nr_rings; in __bnxt_reserve_rings()
7872 if (bp->flags & BNXT_FLAG_SHARED_RINGS) in __bnxt_reserve_rings()
7874 if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) in __bnxt_reserve_rings()
7879 if (bp->flags & BNXT_FLAG_AGG_RINGS) in __bnxt_reserve_rings()
7881 hwr.grp = bp->rx_nr_rings; in __bnxt_reserve_rings()
7884 old_rx_rings = bp->hw_resc.resv_rx_rings; in __bnxt_reserve_rings()
7893 if (bp->flags & BNXT_FLAG_AGG_RINGS) { in __bnxt_reserve_rings()
7897 if (netif_running(bp->dev)) in __bnxt_reserve_rings()
7898 return -ENOMEM; in __bnxt_reserve_rings()
7900 bp->flags &= ~BNXT_FLAG_AGG_RINGS; in __bnxt_reserve_rings()
7901 bp->flags |= BNXT_FLAG_NO_AGG_RINGS; in __bnxt_reserve_rings()
7902 bp->dev->hw_features &= ~NETIF_F_LRO; in __bnxt_reserve_rings()
7903 bp->dev->features &= ~NETIF_F_LRO; in __bnxt_reserve_rings()
7908 hwr.cp = min_t(int, hwr.cp, bp->cp_nr_rings); in __bnxt_reserve_rings()
7910 hwr.stat -= bnxt_get_ulp_stat_ctxs(bp); in __bnxt_reserve_rings()
7913 if (bp->flags & BNXT_FLAG_AGG_RINGS) in __bnxt_reserve_rings()
7917 bp->tx_nr_rings = hwr.tx; in __bnxt_reserve_rings()
7922 if (rx_rings != bp->rx_nr_rings) { in __bnxt_reserve_rings()
7923 netdev_warn(bp->dev, "Able to reserve only %d out of %d requested RX rings\n", in __bnxt_reserve_rings()
7924 rx_rings, bp->rx_nr_rings); in __bnxt_reserve_rings()
7925 if (netif_is_rxfh_configured(bp->dev) && in __bnxt_reserve_rings()
7926 (bnxt_get_nr_rss_ctxs(bp, bp->rx_nr_rings) != in __bnxt_reserve_rings()
7929 netdev_warn(bp->dev, "RSS table entries reverting to default\n"); in __bnxt_reserve_rings()
7930 bp->dev->priv_flags &= ~IFF_RXFH_CONFIGURED; in __bnxt_reserve_rings()
7933 bp->rx_nr_rings = rx_rings; in __bnxt_reserve_rings()
7934 bp->cp_nr_rings = hwr.cp; in __bnxt_reserve_rings()
7937 return -ENOMEM; in __bnxt_reserve_rings()
7939 if (old_rx_rings != bp->hw_resc.resv_rx_rings && in __bnxt_reserve_rings()
7940 !netif_is_rxfh_configured(bp->dev)) in __bnxt_reserve_rings()
7943 if (!bnxt_ulp_registered(bp->edev) && BNXT_NEW_RM(bp)) { in __bnxt_reserve_rings()
7947 hw_resc = &bp->hw_resc; in __bnxt_reserve_rings()
7948 resv_msix = hw_resc->resv_irqs - bp->cp_nr_rings; in __bnxt_reserve_rings()
7951 resv_ctx = hw_resc->resv_stat_ctxs - bp->cp_nr_rings; in __bnxt_reserve_rings()
7974 if (!(bp->flags & BNXT_FLAG_CHIP_P5_PLUS)) in bnxt_hwrm_check_vf_rings()
7977 req->flags = cpu_to_le32(flags); in bnxt_hwrm_check_vf_rings()
7993 if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) in bnxt_hwrm_check_pf_rings()
8000 req->flags = cpu_to_le32(flags); in bnxt_hwrm_check_pf_rings()
8006 if (bp->hwrm_spec_code < 0x10801) in bnxt_hwrm_check_rings()
8017 struct bnxt_coal_cap *coal_cap = &bp->coal_cap; in bnxt_hwrm_coal_params_qcaps()
8022 coal_cap->cmpl_params = BNXT_LEGACY_COAL_CMPL_PARAMS; in bnxt_hwrm_coal_params_qcaps()
8023 coal_cap->num_cmpl_dma_aggr_max = 63; in bnxt_hwrm_coal_params_qcaps()
8024 coal_cap->num_cmpl_dma_aggr_during_int_max = 63; in bnxt_hwrm_coal_params_qcaps()
8025 coal_cap->cmpl_aggr_dma_tmr_max = 65535; in bnxt_hwrm_coal_params_qcaps()
8026 coal_cap->cmpl_aggr_dma_tmr_during_int_max = 65535; in bnxt_hwrm_coal_params_qcaps()
8027 coal_cap->int_lat_tmr_min_max = 65535; in bnxt_hwrm_coal_params_qcaps()
8028 coal_cap->int_lat_tmr_max_max = 65535; in bnxt_hwrm_coal_params_qcaps()
8029 coal_cap->num_cmpl_aggr_int_max = 65535; in bnxt_hwrm_coal_params_qcaps()
8030 coal_cap->timer_units = 80; in bnxt_hwrm_coal_params_qcaps()
8032 if (bp->hwrm_spec_code < 0x10902) in bnxt_hwrm_coal_params_qcaps()
8041 coal_cap->cmpl_params = le32_to_cpu(resp->cmpl_params); in bnxt_hwrm_coal_params_qcaps()
8042 coal_cap->nq_params = le32_to_cpu(resp->nq_params); in bnxt_hwrm_coal_params_qcaps()
8043 coal_cap->num_cmpl_dma_aggr_max = in bnxt_hwrm_coal_params_qcaps()
8044 le16_to_cpu(resp->num_cmpl_dma_aggr_max); in bnxt_hwrm_coal_params_qcaps()
8045 coal_cap->num_cmpl_dma_aggr_during_int_max = in bnxt_hwrm_coal_params_qcaps()
8046 le16_to_cpu(resp->num_cmpl_dma_aggr_during_int_max); in bnxt_hwrm_coal_params_qcaps()
8047 coal_cap->cmpl_aggr_dma_tmr_max = in bnxt_hwrm_coal_params_qcaps()
8048 le16_to_cpu(resp->cmpl_aggr_dma_tmr_max); in bnxt_hwrm_coal_params_qcaps()
8049 coal_cap->cmpl_aggr_dma_tmr_during_int_max = in bnxt_hwrm_coal_params_qcaps()
8050 le16_to_cpu(resp->cmpl_aggr_dma_tmr_during_int_max); in bnxt_hwrm_coal_params_qcaps()
8051 coal_cap->int_lat_tmr_min_max = in bnxt_hwrm_coal_params_qcaps()
8052 le16_to_cpu(resp->int_lat_tmr_min_max); in bnxt_hwrm_coal_params_qcaps()
8053 coal_cap->int_lat_tmr_max_max = in bnxt_hwrm_coal_params_qcaps()
8054 le16_to_cpu(resp->int_lat_tmr_max_max); in bnxt_hwrm_coal_params_qcaps()
8055 coal_cap->num_cmpl_aggr_int_max = in bnxt_hwrm_coal_params_qcaps()
8056 le16_to_cpu(resp->num_cmpl_aggr_int_max); in bnxt_hwrm_coal_params_qcaps()
8057 coal_cap->timer_units = le16_to_cpu(resp->timer_units); in bnxt_hwrm_coal_params_qcaps()
8064 struct bnxt_coal_cap *coal_cap = &bp->coal_cap; in bnxt_usec_to_coal_tmr()
8066 return usec * 1000 / coal_cap->timer_units; in bnxt_usec_to_coal_tmr()
8073 struct bnxt_coal_cap *coal_cap = &bp->coal_cap; in bnxt_hwrm_set_coal_params()
8074 u16 val, tmr, max, flags = hw_coal->flags; in bnxt_hwrm_set_coal_params()
8075 u32 cmpl_params = coal_cap->cmpl_params; in bnxt_hwrm_set_coal_params()
8077 max = hw_coal->bufs_per_record * 128; in bnxt_hwrm_set_coal_params()
8078 if (hw_coal->budget) in bnxt_hwrm_set_coal_params()
8079 max = hw_coal->bufs_per_record * hw_coal->budget; in bnxt_hwrm_set_coal_params()
8080 max = min_t(u16, max, coal_cap->num_cmpl_aggr_int_max); in bnxt_hwrm_set_coal_params()
8082 val = clamp_t(u16, hw_coal->coal_bufs, 1, max); in bnxt_hwrm_set_coal_params()
8083 req->num_cmpl_aggr_int = cpu_to_le16(val); in bnxt_hwrm_set_coal_params()
8085 val = min_t(u16, val, coal_cap->num_cmpl_dma_aggr_max); in bnxt_hwrm_set_coal_params()
8086 req->num_cmpl_dma_aggr = cpu_to_le16(val); in bnxt_hwrm_set_coal_params()
8088 val = clamp_t(u16, hw_coal->coal_bufs_irq, 1, in bnxt_hwrm_set_coal_params()
8089 coal_cap->num_cmpl_dma_aggr_during_int_max); in bnxt_hwrm_set_coal_params()
8090 req->num_cmpl_dma_aggr_during_int = cpu_to_le16(val); in bnxt_hwrm_set_coal_params()
8092 tmr = bnxt_usec_to_coal_tmr(bp, hw_coal->coal_ticks); in bnxt_hwrm_set_coal_params()
8093 tmr = clamp_t(u16, tmr, 1, coal_cap->int_lat_tmr_max_max); in bnxt_hwrm_set_coal_params()
8094 req->int_lat_tmr_max = cpu_to_le16(tmr); in bnxt_hwrm_set_coal_params()
8099 val = clamp_t(u16, val, 1, coal_cap->int_lat_tmr_min_max); in bnxt_hwrm_set_coal_params()
8100 req->int_lat_tmr_min = cpu_to_le16(val); in bnxt_hwrm_set_coal_params()
8101 req->enables |= cpu_to_le16(BNXT_COAL_CMPL_MIN_TMR_ENABLE); in bnxt_hwrm_set_coal_params()
8105 val = clamp_t(u16, tmr / 4, 1, coal_cap->cmpl_aggr_dma_tmr_max); in bnxt_hwrm_set_coal_params()
8106 req->cmpl_aggr_dma_tmr = cpu_to_le16(val); in bnxt_hwrm_set_coal_params()
8110 tmr = bnxt_usec_to_coal_tmr(bp, hw_coal->coal_ticks_irq); in bnxt_hwrm_set_coal_params()
8112 coal_cap->cmpl_aggr_dma_tmr_during_int_max); in bnxt_hwrm_set_coal_params()
8113 req->cmpl_aggr_dma_tmr_during_int = cpu_to_le16(val); in bnxt_hwrm_set_coal_params()
8114 req->enables |= in bnxt_hwrm_set_coal_params()
8119 hw_coal->idle_thresh && hw_coal->coal_ticks < hw_coal->idle_thresh) in bnxt_hwrm_set_coal_params()
8121 req->flags = cpu_to_le16(flags); in bnxt_hwrm_set_coal_params()
8122 req->enables |= cpu_to_le16(BNXT_COAL_CMPL_ENABLES); in bnxt_hwrm_set_coal_params()
8129 struct bnxt_cp_ring_info *cpr = &bnapi->cp_ring; in __bnxt_hwrm_set_coal_nq()
8130 struct bnxt_coal_cap *coal_cap = &bp->coal_cap; in __bnxt_hwrm_set_coal_nq()
8131 u32 nq_params = coal_cap->nq_params; in __bnxt_hwrm_set_coal_nq()
8142 req->ring_id = cpu_to_le16(cpr->cp_ring_struct.fw_ring_id); in __bnxt_hwrm_set_coal_nq()
8143 req->flags = in __bnxt_hwrm_set_coal_nq()
8146 tmr = bnxt_usec_to_coal_tmr(bp, hw_coal->coal_ticks) / 2; in __bnxt_hwrm_set_coal_nq()
8147 tmr = clamp_t(u16, tmr, 1, coal_cap->int_lat_tmr_min_max); in __bnxt_hwrm_set_coal_nq()
8148 req->int_lat_tmr_min = cpu_to_le16(tmr); in __bnxt_hwrm_set_coal_nq()
8149 req->enables |= cpu_to_le16(BNXT_COAL_CMPL_MIN_TMR_ENABLE); in __bnxt_hwrm_set_coal_nq()
8156 struct bnxt_cp_ring_info *cpr = &bnapi->cp_ring; in bnxt_hwrm_set_ring_coal()
8163 memcpy(&coal, &bp->rx_coal, sizeof(struct bnxt_coal)); in bnxt_hwrm_set_ring_coal()
8165 coal.coal_ticks = cpr->rx_ring_coal.coal_ticks; in bnxt_hwrm_set_ring_coal()
8166 coal.coal_bufs = cpr->rx_ring_coal.coal_bufs; in bnxt_hwrm_set_ring_coal()
8168 if (!bnapi->rx_ring) in bnxt_hwrm_set_ring_coal()
8169 return -ENODEV; in bnxt_hwrm_set_ring_coal()
8177 req_rx->ring_id = cpu_to_le16(bnxt_cp_ring_for_rx(bp, bnapi->rx_ring)); in bnxt_hwrm_set_ring_coal()
8186 u16 ring_id = bnxt_cp_ring_for_rx(bp, bnapi->rx_ring); in bnxt_hwrm_set_rx_coal()
8188 req->ring_id = cpu_to_le16(ring_id); in bnxt_hwrm_set_rx_coal()
8203 req->ring_id = cpu_to_le16(ring_id); in bnxt_hwrm_set_tx_coal()
8207 if (!(bp->flags & BNXT_FLAG_CHIP_P5_PLUS)) in bnxt_hwrm_set_tx_coal()
8228 bnxt_hwrm_set_coal_params(bp, &bp->rx_coal, req_rx); in bnxt_hwrm_set_coal()
8229 bnxt_hwrm_set_coal_params(bp, &bp->tx_coal, req_tx); in bnxt_hwrm_set_coal()
8233 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_hwrm_set_coal()
8234 struct bnxt_napi *bnapi = bp->bnapi[i]; in bnxt_hwrm_set_coal()
8237 if (!bnapi->rx_ring) in bnxt_hwrm_set_coal()
8244 if (!(bp->flags & BNXT_FLAG_CHIP_P5_PLUS)) in bnxt_hwrm_set_coal()
8247 if (bnapi->rx_ring && bnapi->tx_ring[0]) { in bnxt_hwrm_set_coal()
8252 if (bnapi->rx_ring) in bnxt_hwrm_set_coal()
8253 hw_coal = &bp->rx_coal; in bnxt_hwrm_set_coal()
8255 hw_coal = &bp->tx_coal; in bnxt_hwrm_set_coal()
8269 if (!bp->bnapi) in bnxt_hwrm_stat_ctx_free()
8285 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_hwrm_stat_ctx_free()
8286 struct bnxt_napi *bnapi = bp->bnapi[i]; in bnxt_hwrm_stat_ctx_free()
8287 struct bnxt_cp_ring_info *cpr = &bnapi->cp_ring; in bnxt_hwrm_stat_ctx_free()
8289 if (cpr->hw_stats_ctx_id != INVALID_STATS_CTX_ID) { in bnxt_hwrm_stat_ctx_free()
8290 req->stat_ctx_id = cpu_to_le32(cpr->hw_stats_ctx_id); in bnxt_hwrm_stat_ctx_free()
8292 req0->stat_ctx_id = req->stat_ctx_id; in bnxt_hwrm_stat_ctx_free()
8297 cpr->hw_stats_ctx_id = INVALID_STATS_CTX_ID; in bnxt_hwrm_stat_ctx_free()
8318 req->stats_dma_length = cpu_to_le16(bp->hw_ring_stats_size); in bnxt_hwrm_stat_ctx_alloc()
8319 req->update_period_ms = cpu_to_le32(bp->stats_coal_ticks / 1000); in bnxt_hwrm_stat_ctx_alloc()
8322 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_hwrm_stat_ctx_alloc()
8323 struct bnxt_napi *bnapi = bp->bnapi[i]; in bnxt_hwrm_stat_ctx_alloc()
8324 struct bnxt_cp_ring_info *cpr = &bnapi->cp_ring; in bnxt_hwrm_stat_ctx_alloc()
8326 req->stats_dma_addr = cpu_to_le64(cpr->stats.hw_stats_map); in bnxt_hwrm_stat_ctx_alloc()
8332 cpr->hw_stats_ctx_id = le32_to_cpu(resp->stat_ctx_id); in bnxt_hwrm_stat_ctx_alloc()
8334 bp->grp_info[i].fw_stats_ctx = cpr->hw_stats_ctx_id; in bnxt_hwrm_stat_ctx_alloc()
8351 req->fid = cpu_to_le16(0xffff); in bnxt_hwrm_func_qcfg()
8357 flags = le16_to_cpu(resp->flags); in bnxt_hwrm_func_qcfg()
8360 struct bnxt_vf_info *vf = &bp->vf; in bnxt_hwrm_func_qcfg()
8362 vf->vlan = le16_to_cpu(resp->vlan) & VLAN_VID_MASK; in bnxt_hwrm_func_qcfg()
8364 vf->flags |= BNXT_VF_TRUST; in bnxt_hwrm_func_qcfg()
8366 vf->flags &= ~BNXT_VF_TRUST; in bnxt_hwrm_func_qcfg()
8368 bp->pf.registered_vfs = le16_to_cpu(resp->registered_vfs); in bnxt_hwrm_func_qcfg()
8373 bp->fw_cap |= BNXT_FW_CAP_LLDP_AGENT; in bnxt_hwrm_func_qcfg()
8375 bp->fw_cap |= BNXT_FW_CAP_DCBX_AGENT; in bnxt_hwrm_func_qcfg()
8378 bp->flags |= BNXT_FLAG_MULTI_HOST; in bnxt_hwrm_func_qcfg()
8381 bp->fw_cap |= BNXT_FW_CAP_RING_MONITOR; in bnxt_hwrm_func_qcfg()
8384 bp->fw_cap |= BNXT_FW_CAP_ENABLE_RDMA_SRIOV; in bnxt_hwrm_func_qcfg()
8386 switch (resp->port_partition_type) { in bnxt_hwrm_func_qcfg()
8390 bp->port_partition_type = resp->port_partition_type; in bnxt_hwrm_func_qcfg()
8393 if (bp->hwrm_spec_code < 0x10707 || in bnxt_hwrm_func_qcfg()
8394 resp->evb_mode == FUNC_QCFG_RESP_EVB_MODE_VEB) in bnxt_hwrm_func_qcfg()
8395 bp->br_mode = BRIDGE_MODE_VEB; in bnxt_hwrm_func_qcfg()
8396 else if (resp->evb_mode == FUNC_QCFG_RESP_EVB_MODE_VEPA) in bnxt_hwrm_func_qcfg()
8397 bp->br_mode = BRIDGE_MODE_VEPA; in bnxt_hwrm_func_qcfg()
8399 bp->br_mode = BRIDGE_MODE_UNDEF; in bnxt_hwrm_func_qcfg()
8401 bp->max_mtu = le16_to_cpu(resp->max_mtu_configured); in bnxt_hwrm_func_qcfg()
8402 if (!bp->max_mtu) in bnxt_hwrm_func_qcfg()
8403 bp->max_mtu = BNXT_MAX_MTU; in bnxt_hwrm_func_qcfg()
8405 if (bp->db_size) in bnxt_hwrm_func_qcfg()
8408 bp->db_offset = le16_to_cpu(resp->legacy_l2_db_size_kb) * 1024; in bnxt_hwrm_func_qcfg()
8411 bp->db_offset = DB_PF_OFFSET_P5; in bnxt_hwrm_func_qcfg()
8413 bp->db_offset = DB_VF_OFFSET_P5; in bnxt_hwrm_func_qcfg()
8415 bp->db_size = PAGE_ALIGN(le16_to_cpu(resp->l2_doorbell_bar_size_kb) * in bnxt_hwrm_func_qcfg()
8417 if (!bp->db_size || bp->db_size > pci_resource_len(bp->pdev, 2) || in bnxt_hwrm_func_qcfg()
8418 bp->db_size <= bp->db_offset) in bnxt_hwrm_func_qcfg()
8419 bp->db_size = pci_resource_len(bp->pdev, 2); in bnxt_hwrm_func_qcfg()
8430 ctxm->init_value = init_val; in bnxt_init_ctx_initializer()
8431 ctxm->init_offset = BNXT_CTX_INIT_INVALID_OFFSET; in bnxt_init_ctx_initializer()
8433 ctxm->init_offset = init_offset * 4; in bnxt_init_ctx_initializer()
8435 ctxm->init_value = 0; in bnxt_init_ctx_initializer()
8440 struct bnxt_ctx_mem_info *ctx = bp->ctx; in bnxt_alloc_all_ctx_pg_info()
8444 struct bnxt_ctx_mem_type *ctxm = &ctx->ctx_arr[type]; in bnxt_alloc_all_ctx_pg_info()
8447 if (!ctxm->max_entries || ctxm->pg_info) in bnxt_alloc_all_ctx_pg_info()
8450 if (ctxm->instance_bmap) in bnxt_alloc_all_ctx_pg_info()
8451 n = hweight32(ctxm->instance_bmap); in bnxt_alloc_all_ctx_pg_info()
8452 ctxm->pg_info = kcalloc(n, sizeof(*ctxm->pg_info), GFP_KERNEL); in bnxt_alloc_all_ctx_pg_info()
8453 if (!ctxm->pg_info) in bnxt_alloc_all_ctx_pg_info()
8454 return -ENOMEM; in bnxt_alloc_all_ctx_pg_info()
8470 struct bnxt_ctx_mem_info *ctx = bp->ctx; in bnxt_hwrm_func_backing_store_qcaps_v2()
8481 return -ENOMEM; in bnxt_hwrm_func_backing_store_qcaps_v2()
8482 bp->ctx = ctx; in bnxt_hwrm_func_backing_store_qcaps_v2()
8488 struct bnxt_ctx_mem_type *ctxm = &ctx->ctx_arr[type]; in bnxt_hwrm_func_backing_store_qcaps_v2()
8495 req->type = cpu_to_le16(type); in bnxt_hwrm_func_backing_store_qcaps_v2()
8499 flags = le32_to_cpu(resp->flags); in bnxt_hwrm_func_backing_store_qcaps_v2()
8500 type = le16_to_cpu(resp->next_valid_type); in bnxt_hwrm_func_backing_store_qcaps_v2()
8505 entry_size = le16_to_cpu(resp->entry_size); in bnxt_hwrm_func_backing_store_qcaps_v2()
8506 max_entries = le32_to_cpu(resp->max_num_entries); in bnxt_hwrm_func_backing_store_qcaps_v2()
8507 if (ctxm->mem_valid) { in bnxt_hwrm_func_backing_store_qcaps_v2()
8509 ctxm->entry_size != entry_size || in bnxt_hwrm_func_backing_store_qcaps_v2()
8510 ctxm->max_entries != max_entries) in bnxt_hwrm_func_backing_store_qcaps_v2()
8515 ctxm->type = le16_to_cpu(resp->type); in bnxt_hwrm_func_backing_store_qcaps_v2()
8516 ctxm->entry_size = entry_size; in bnxt_hwrm_func_backing_store_qcaps_v2()
8517 ctxm->flags = flags; in bnxt_hwrm_func_backing_store_qcaps_v2()
8518 ctxm->instance_bmap = le32_to_cpu(resp->instance_bit_map); in bnxt_hwrm_func_backing_store_qcaps_v2()
8519 ctxm->entry_multiple = resp->entry_multiple; in bnxt_hwrm_func_backing_store_qcaps_v2()
8520 ctxm->max_entries = max_entries; in bnxt_hwrm_func_backing_store_qcaps_v2()
8521 ctxm->min_entries = le32_to_cpu(resp->min_num_entries); in bnxt_hwrm_func_backing_store_qcaps_v2()
8522 init_val = resp->ctx_init_value; in bnxt_hwrm_func_backing_store_qcaps_v2()
8523 init_off = resp->ctx_init_offset; in bnxt_hwrm_func_backing_store_qcaps_v2()
8526 ctxm->split_entry_cnt = min_t(u8, resp->subtype_valid_cnt, in bnxt_hwrm_func_backing_store_qcaps_v2()
8528 for (i = 0, p = &resp->split_entry_0; i < ctxm->split_entry_cnt; in bnxt_hwrm_func_backing_store_qcaps_v2()
8530 ctxm->split[i] = le32_to_cpu(*p); in bnxt_hwrm_func_backing_store_qcaps_v2()
8545 if (bp->hwrm_spec_code < 0x10902 || BNXT_VF(bp) || in bnxt_hwrm_func_backing_store_qcaps()
8546 (bp->ctx && bp->ctx->flags & BNXT_CTX_FLAG_INITED)) in bnxt_hwrm_func_backing_store_qcaps()
8549 if (bp->fw_cap & BNXT_FW_CAP_BACKING_STORE_V2) in bnxt_hwrm_func_backing_store_qcaps()
8564 ctx = bp->ctx; in bnxt_hwrm_func_backing_store_qcaps()
8568 rc = -ENOMEM; in bnxt_hwrm_func_backing_store_qcaps()
8571 bp->ctx = ctx; in bnxt_hwrm_func_backing_store_qcaps()
8573 init_val = resp->ctx_kind_initializer; in bnxt_hwrm_func_backing_store_qcaps()
8574 init_mask = le16_to_cpu(resp->ctx_init_mask); in bnxt_hwrm_func_backing_store_qcaps()
8576 ctxm = &ctx->ctx_arr[BNXT_CTX_QP]; in bnxt_hwrm_func_backing_store_qcaps()
8577 ctxm->max_entries = le32_to_cpu(resp->qp_max_entries); in bnxt_hwrm_func_backing_store_qcaps()
8578 ctxm->qp_qp1_entries = le16_to_cpu(resp->qp_min_qp1_entries); in bnxt_hwrm_func_backing_store_qcaps()
8579 ctxm->qp_l2_entries = le16_to_cpu(resp->qp_max_l2_entries); in bnxt_hwrm_func_backing_store_qcaps()
8580 ctxm->qp_fast_qpmd_entries = le16_to_cpu(resp->fast_qpmd_qp_num_entries); in bnxt_hwrm_func_backing_store_qcaps()
8581 ctxm->entry_size = le16_to_cpu(resp->qp_entry_size); in bnxt_hwrm_func_backing_store_qcaps()
8582 bnxt_init_ctx_initializer(ctxm, init_val, resp->qp_init_offset, in bnxt_hwrm_func_backing_store_qcaps()
8585 ctxm = &ctx->ctx_arr[BNXT_CTX_SRQ]; in bnxt_hwrm_func_backing_store_qcaps()
8586 ctxm->srq_l2_entries = le16_to_cpu(resp->srq_max_l2_entries); in bnxt_hwrm_func_backing_store_qcaps()
8587 ctxm->max_entries = le32_to_cpu(resp->srq_max_entries); in bnxt_hwrm_func_backing_store_qcaps()
8588 ctxm->entry_size = le16_to_cpu(resp->srq_entry_size); in bnxt_hwrm_func_backing_store_qcaps()
8589 bnxt_init_ctx_initializer(ctxm, init_val, resp->srq_init_offset, in bnxt_hwrm_func_backing_store_qcaps()
8592 ctxm = &ctx->ctx_arr[BNXT_CTX_CQ]; in bnxt_hwrm_func_backing_store_qcaps()
8593 ctxm->cq_l2_entries = le16_to_cpu(resp->cq_max_l2_entries); in bnxt_hwrm_func_backing_store_qcaps()
8594 ctxm->max_entries = le32_to_cpu(resp->cq_max_entries); in bnxt_hwrm_func_backing_store_qcaps()
8595 ctxm->entry_size = le16_to_cpu(resp->cq_entry_size); in bnxt_hwrm_func_backing_store_qcaps()
8596 bnxt_init_ctx_initializer(ctxm, init_val, resp->cq_init_offset, in bnxt_hwrm_func_backing_store_qcaps()
8599 ctxm = &ctx->ctx_arr[BNXT_CTX_VNIC]; in bnxt_hwrm_func_backing_store_qcaps()
8600 ctxm->vnic_entries = le16_to_cpu(resp->vnic_max_vnic_entries); in bnxt_hwrm_func_backing_store_qcaps()
8601 ctxm->max_entries = ctxm->vnic_entries + in bnxt_hwrm_func_backing_store_qcaps()
8602 le16_to_cpu(resp->vnic_max_ring_table_entries); in bnxt_hwrm_func_backing_store_qcaps()
8603 ctxm->entry_size = le16_to_cpu(resp->vnic_entry_size); in bnxt_hwrm_func_backing_store_qcaps()
8605 resp->vnic_init_offset, in bnxt_hwrm_func_backing_store_qcaps()
8608 ctxm = &ctx->ctx_arr[BNXT_CTX_STAT]; in bnxt_hwrm_func_backing_store_qcaps()
8609 ctxm->max_entries = le32_to_cpu(resp->stat_max_entries); in bnxt_hwrm_func_backing_store_qcaps()
8610 ctxm->entry_size = le16_to_cpu(resp->stat_entry_size); in bnxt_hwrm_func_backing_store_qcaps()
8612 resp->stat_init_offset, in bnxt_hwrm_func_backing_store_qcaps()
8615 ctxm = &ctx->ctx_arr[BNXT_CTX_STQM]; in bnxt_hwrm_func_backing_store_qcaps()
8616 ctxm->entry_size = le16_to_cpu(resp->tqm_entry_size); in bnxt_hwrm_func_backing_store_qcaps()
8617 ctxm->min_entries = le32_to_cpu(resp->tqm_min_entries_per_ring); in bnxt_hwrm_func_backing_store_qcaps()
8618 ctxm->max_entries = le32_to_cpu(resp->tqm_max_entries_per_ring); in bnxt_hwrm_func_backing_store_qcaps()
8619 ctxm->entry_multiple = resp->tqm_entries_multiple; in bnxt_hwrm_func_backing_store_qcaps()
8620 if (!ctxm->entry_multiple) in bnxt_hwrm_func_backing_store_qcaps()
8621 ctxm->entry_multiple = 1; in bnxt_hwrm_func_backing_store_qcaps()
8623 memcpy(&ctx->ctx_arr[BNXT_CTX_FTQM], ctxm, sizeof(*ctxm)); in bnxt_hwrm_func_backing_store_qcaps()
8625 ctxm = &ctx->ctx_arr[BNXT_CTX_MRAV]; in bnxt_hwrm_func_backing_store_qcaps()
8626 ctxm->max_entries = le32_to_cpu(resp->mrav_max_entries); in bnxt_hwrm_func_backing_store_qcaps()
8627 ctxm->entry_size = le16_to_cpu(resp->mrav_entry_size); in bnxt_hwrm_func_backing_store_qcaps()
8628 ctxm->mrav_num_entries_units = in bnxt_hwrm_func_backing_store_qcaps()
8629 le16_to_cpu(resp->mrav_num_entries_units); in bnxt_hwrm_func_backing_store_qcaps()
8631 resp->mrav_init_offset, in bnxt_hwrm_func_backing_store_qcaps()
8634 ctxm = &ctx->ctx_arr[BNXT_CTX_TIM]; in bnxt_hwrm_func_backing_store_qcaps()
8635 ctxm->entry_size = le16_to_cpu(resp->tim_entry_size); in bnxt_hwrm_func_backing_store_qcaps()
8636 ctxm->max_entries = le32_to_cpu(resp->tim_max_entries); in bnxt_hwrm_func_backing_store_qcaps()
8638 ctx->tqm_fp_rings_count = resp->tqm_fp_rings_count; in bnxt_hwrm_func_backing_store_qcaps()
8639 if (!ctx->tqm_fp_rings_count) in bnxt_hwrm_func_backing_store_qcaps()
8640 ctx->tqm_fp_rings_count = bp->max_q; in bnxt_hwrm_func_backing_store_qcaps()
8641 else if (ctx->tqm_fp_rings_count > BNXT_MAX_TQM_FP_RINGS) in bnxt_hwrm_func_backing_store_qcaps()
8642 ctx->tqm_fp_rings_count = BNXT_MAX_TQM_FP_RINGS; in bnxt_hwrm_func_backing_store_qcaps()
8644 ctxm = &ctx->ctx_arr[BNXT_CTX_FTQM]; in bnxt_hwrm_func_backing_store_qcaps()
8645 memcpy(ctxm, &ctx->ctx_arr[BNXT_CTX_STQM], sizeof(*ctxm)); in bnxt_hwrm_func_backing_store_qcaps()
8646 ctxm->instance_bmap = (1 << ctx->tqm_fp_rings_count) - 1; in bnxt_hwrm_func_backing_store_qcaps()
8660 if (!rmem->nr_pages) in bnxt_hwrm_set_pg_attr()
8664 if (rmem->depth >= 1) { in bnxt_hwrm_set_pg_attr()
8665 if (rmem->depth == 2) in bnxt_hwrm_set_pg_attr()
8669 *pg_dir = cpu_to_le64(rmem->pg_tbl_map); in bnxt_hwrm_set_pg_attr()
8671 *pg_dir = cpu_to_le64(rmem->dma_arr[0]); in bnxt_hwrm_set_pg_attr()
8685 struct bnxt_ctx_mem_info *ctx = bp->ctx; in bnxt_hwrm_func_backing_store_cfg()
8701 if (req_len > bp->hwrm_max_ext_req_len) in bnxt_hwrm_func_backing_store_cfg()
8707 req->enables = cpu_to_le32(enables); in bnxt_hwrm_func_backing_store_cfg()
8709 ctxm = &ctx->ctx_arr[BNXT_CTX_QP]; in bnxt_hwrm_func_backing_store_cfg()
8710 ctx_pg = ctxm->pg_info; in bnxt_hwrm_func_backing_store_cfg()
8711 req->qp_num_entries = cpu_to_le32(ctx_pg->entries); in bnxt_hwrm_func_backing_store_cfg()
8712 req->qp_num_qp1_entries = cpu_to_le16(ctxm->qp_qp1_entries); in bnxt_hwrm_func_backing_store_cfg()
8713 req->qp_num_l2_entries = cpu_to_le16(ctxm->qp_l2_entries); in bnxt_hwrm_func_backing_store_cfg()
8714 req->qp_entry_size = cpu_to_le16(ctxm->entry_size); in bnxt_hwrm_func_backing_store_cfg()
8715 bnxt_hwrm_set_pg_attr(&ctx_pg->ring_mem, in bnxt_hwrm_func_backing_store_cfg()
8716 &req->qpc_pg_size_qpc_lvl, in bnxt_hwrm_func_backing_store_cfg()
8717 &req->qpc_page_dir); in bnxt_hwrm_func_backing_store_cfg()
8720 req->qp_num_fast_qpmd_entries = cpu_to_le16(ctxm->qp_fast_qpmd_entries); in bnxt_hwrm_func_backing_store_cfg()
8723 ctxm = &ctx->ctx_arr[BNXT_CTX_SRQ]; in bnxt_hwrm_func_backing_store_cfg()
8724 ctx_pg = ctxm->pg_info; in bnxt_hwrm_func_backing_store_cfg()
8725 req->srq_num_entries = cpu_to_le32(ctx_pg->entries); in bnxt_hwrm_func_backing_store_cfg()
8726 req->srq_num_l2_entries = cpu_to_le16(ctxm->srq_l2_entries); in bnxt_hwrm_func_backing_store_cfg()
8727 req->srq_entry_size = cpu_to_le16(ctxm->entry_size); in bnxt_hwrm_func_backing_store_cfg()
8728 bnxt_hwrm_set_pg_attr(&ctx_pg->ring_mem, in bnxt_hwrm_func_backing_store_cfg()
8729 &req->srq_pg_size_srq_lvl, in bnxt_hwrm_func_backing_store_cfg()
8730 &req->srq_page_dir); in bnxt_hwrm_func_backing_store_cfg()
8733 ctxm = &ctx->ctx_arr[BNXT_CTX_CQ]; in bnxt_hwrm_func_backing_store_cfg()
8734 ctx_pg = ctxm->pg_info; in bnxt_hwrm_func_backing_store_cfg()
8735 req->cq_num_entries = cpu_to_le32(ctx_pg->entries); in bnxt_hwrm_func_backing_store_cfg()
8736 req->cq_num_l2_entries = cpu_to_le16(ctxm->cq_l2_entries); in bnxt_hwrm_func_backing_store_cfg()
8737 req->cq_entry_size = cpu_to_le16(ctxm->entry_size); in bnxt_hwrm_func_backing_store_cfg()
8738 bnxt_hwrm_set_pg_attr(&ctx_pg->ring_mem, in bnxt_hwrm_func_backing_store_cfg()
8739 &req->cq_pg_size_cq_lvl, in bnxt_hwrm_func_backing_store_cfg()
8740 &req->cq_page_dir); in bnxt_hwrm_func_backing_store_cfg()
8743 ctxm = &ctx->ctx_arr[BNXT_CTX_VNIC]; in bnxt_hwrm_func_backing_store_cfg()
8744 ctx_pg = ctxm->pg_info; in bnxt_hwrm_func_backing_store_cfg()
8745 req->vnic_num_vnic_entries = cpu_to_le16(ctxm->vnic_entries); in bnxt_hwrm_func_backing_store_cfg()
8746 req->vnic_num_ring_table_entries = in bnxt_hwrm_func_backing_store_cfg()
8747 cpu_to_le16(ctxm->max_entries - ctxm->vnic_entries); in bnxt_hwrm_func_backing_store_cfg()
8748 req->vnic_entry_size = cpu_to_le16(ctxm->entry_size); in bnxt_hwrm_func_backing_store_cfg()
8749 bnxt_hwrm_set_pg_attr(&ctx_pg->ring_mem, in bnxt_hwrm_func_backing_store_cfg()
8750 &req->vnic_pg_size_vnic_lvl, in bnxt_hwrm_func_backing_store_cfg()
8751 &req->vnic_page_dir); in bnxt_hwrm_func_backing_store_cfg()
8754 ctxm = &ctx->ctx_arr[BNXT_CTX_STAT]; in bnxt_hwrm_func_backing_store_cfg()
8755 ctx_pg = ctxm->pg_info; in bnxt_hwrm_func_backing_store_cfg()
8756 req->stat_num_entries = cpu_to_le32(ctxm->max_entries); in bnxt_hwrm_func_backing_store_cfg()
8757 req->stat_entry_size = cpu_to_le16(ctxm->entry_size); in bnxt_hwrm_func_backing_store_cfg()
8758 bnxt_hwrm_set_pg_attr(&ctx_pg->ring_mem, in bnxt_hwrm_func_backing_store_cfg()
8759 &req->stat_pg_size_stat_lvl, in bnxt_hwrm_func_backing_store_cfg()
8760 &req->stat_page_dir); in bnxt_hwrm_func_backing_store_cfg()
8765 ctxm = &ctx->ctx_arr[BNXT_CTX_MRAV]; in bnxt_hwrm_func_backing_store_cfg()
8766 ctx_pg = ctxm->pg_info; in bnxt_hwrm_func_backing_store_cfg()
8767 req->mrav_num_entries = cpu_to_le32(ctx_pg->entries); in bnxt_hwrm_func_backing_store_cfg()
8768 units = ctxm->mrav_num_entries_units; in bnxt_hwrm_func_backing_store_cfg()
8770 u32 num_mr, num_ah = ctxm->mrav_av_entries; in bnxt_hwrm_func_backing_store_cfg()
8773 num_mr = ctx_pg->entries - num_ah; in bnxt_hwrm_func_backing_store_cfg()
8775 req->mrav_num_entries = cpu_to_le32(entries); in bnxt_hwrm_func_backing_store_cfg()
8778 req->mrav_entry_size = cpu_to_le16(ctxm->entry_size); in bnxt_hwrm_func_backing_store_cfg()
8779 bnxt_hwrm_set_pg_attr(&ctx_pg->ring_mem, in bnxt_hwrm_func_backing_store_cfg()
8780 &req->mrav_pg_size_mrav_lvl, in bnxt_hwrm_func_backing_store_cfg()
8781 &req->mrav_page_dir); in bnxt_hwrm_func_backing_store_cfg()
8784 ctxm = &ctx->ctx_arr[BNXT_CTX_TIM]; in bnxt_hwrm_func_backing_store_cfg()
8785 ctx_pg = ctxm->pg_info; in bnxt_hwrm_func_backing_store_cfg()
8786 req->tim_num_entries = cpu_to_le32(ctx_pg->entries); in bnxt_hwrm_func_backing_store_cfg()
8787 req->tim_entry_size = cpu_to_le16(ctxm->entry_size); in bnxt_hwrm_func_backing_store_cfg()
8788 bnxt_hwrm_set_pg_attr(&ctx_pg->ring_mem, in bnxt_hwrm_func_backing_store_cfg()
8789 &req->tim_pg_size_tim_lvl, in bnxt_hwrm_func_backing_store_cfg()
8790 &req->tim_page_dir); in bnxt_hwrm_func_backing_store_cfg()
8792 ctxm = &ctx->ctx_arr[BNXT_CTX_STQM]; in bnxt_hwrm_func_backing_store_cfg()
8793 for (i = 0, num_entries = &req->tqm_sp_num_entries, in bnxt_hwrm_func_backing_store_cfg()
8794 pg_attr = &req->tqm_sp_pg_size_tqm_sp_lvl, in bnxt_hwrm_func_backing_store_cfg()
8795 pg_dir = &req->tqm_sp_page_dir, in bnxt_hwrm_func_backing_store_cfg()
8797 ctx_pg = ctxm->pg_info; in bnxt_hwrm_func_backing_store_cfg()
8799 ctx_pg = &ctx->ctx_arr[BNXT_CTX_FTQM].pg_info[i], in bnxt_hwrm_func_backing_store_cfg()
8804 req->tqm_entry_size = cpu_to_le16(ctxm->entry_size); in bnxt_hwrm_func_backing_store_cfg()
8805 *num_entries = cpu_to_le32(ctx_pg->entries); in bnxt_hwrm_func_backing_store_cfg()
8806 bnxt_hwrm_set_pg_attr(&ctx_pg->ring_mem, pg_attr, pg_dir); in bnxt_hwrm_func_backing_store_cfg()
8808 req->flags = cpu_to_le32(flags); in bnxt_hwrm_func_backing_store_cfg()
8815 struct bnxt_ring_mem_info *rmem = &ctx_pg->ring_mem; in bnxt_alloc_ctx_mem_blk()
8817 rmem->page_size = BNXT_PAGE_SIZE; in bnxt_alloc_ctx_mem_blk()
8818 rmem->pg_arr = ctx_pg->ctx_pg_arr; in bnxt_alloc_ctx_mem_blk()
8819 rmem->dma_arr = ctx_pg->ctx_dma_arr; in bnxt_alloc_ctx_mem_blk()
8820 rmem->flags = BNXT_RMEM_VALID_PTE_FLAG; in bnxt_alloc_ctx_mem_blk()
8821 if (rmem->depth >= 1) in bnxt_alloc_ctx_mem_blk()
8822 rmem->flags |= BNXT_RMEM_USE_FULL_PAGE_FLAG; in bnxt_alloc_ctx_mem_blk()
8830 struct bnxt_ring_mem_info *rmem = &ctx_pg->ring_mem; in bnxt_alloc_ctx_pg_tbls()
8834 return -EINVAL; in bnxt_alloc_ctx_pg_tbls()
8836 ctx_pg->nr_pages = DIV_ROUND_UP(mem_size, BNXT_PAGE_SIZE); in bnxt_alloc_ctx_pg_tbls()
8837 if (ctx_pg->nr_pages > MAX_CTX_TOTAL_PAGES) { in bnxt_alloc_ctx_pg_tbls()
8838 ctx_pg->nr_pages = 0; in bnxt_alloc_ctx_pg_tbls()
8839 return -EINVAL; in bnxt_alloc_ctx_pg_tbls()
8841 if (ctx_pg->nr_pages > MAX_CTX_PAGES || depth > 1) { in bnxt_alloc_ctx_pg_tbls()
8844 rmem->depth = 2; in bnxt_alloc_ctx_pg_tbls()
8845 ctx_pg->ctx_pg_tbl = kcalloc(MAX_CTX_PAGES, sizeof(ctx_pg), in bnxt_alloc_ctx_pg_tbls()
8847 if (!ctx_pg->ctx_pg_tbl) in bnxt_alloc_ctx_pg_tbls()
8848 return -ENOMEM; in bnxt_alloc_ctx_pg_tbls()
8849 nr_tbls = DIV_ROUND_UP(ctx_pg->nr_pages, MAX_CTX_PAGES); in bnxt_alloc_ctx_pg_tbls()
8850 rmem->nr_pages = nr_tbls; in bnxt_alloc_ctx_pg_tbls()
8859 return -ENOMEM; in bnxt_alloc_ctx_pg_tbls()
8860 ctx_pg->ctx_pg_tbl[i] = pg_tbl; in bnxt_alloc_ctx_pg_tbls()
8861 rmem = &pg_tbl->ring_mem; in bnxt_alloc_ctx_pg_tbls()
8862 rmem->pg_tbl = ctx_pg->ctx_pg_arr[i]; in bnxt_alloc_ctx_pg_tbls()
8863 rmem->pg_tbl_map = ctx_pg->ctx_dma_arr[i]; in bnxt_alloc_ctx_pg_tbls()
8864 rmem->depth = 1; in bnxt_alloc_ctx_pg_tbls()
8865 rmem->nr_pages = MAX_CTX_PAGES; in bnxt_alloc_ctx_pg_tbls()
8866 rmem->ctx_mem = ctxm; in bnxt_alloc_ctx_pg_tbls()
8867 if (i == (nr_tbls - 1)) { in bnxt_alloc_ctx_pg_tbls()
8868 int rem = ctx_pg->nr_pages % MAX_CTX_PAGES; in bnxt_alloc_ctx_pg_tbls()
8871 rmem->nr_pages = rem; in bnxt_alloc_ctx_pg_tbls()
8878 rmem->nr_pages = DIV_ROUND_UP(mem_size, BNXT_PAGE_SIZE); in bnxt_alloc_ctx_pg_tbls()
8879 if (rmem->nr_pages > 1 || depth) in bnxt_alloc_ctx_pg_tbls()
8880 rmem->depth = 1; in bnxt_alloc_ctx_pg_tbls()
8881 rmem->ctx_mem = ctxm; in bnxt_alloc_ctx_pg_tbls()
8892 struct bnxt_ring_mem_info *rmem = &ctx_pg->ring_mem; in bnxt_copy_ctx_pg_tbls()
8893 size_t nr_pages = ctx_pg->nr_pages; in bnxt_copy_ctx_pg_tbls()
8894 int page_size = rmem->page_size; in bnxt_copy_ctx_pg_tbls()
8896 u16 depth = rmem->depth; in bnxt_copy_ctx_pg_tbls()
8904 pg_tbl = ctx_pg->ctx_pg_tbl[i]; in bnxt_copy_ctx_pg_tbls()
8905 rmem = &pg_tbl->ring_mem; in bnxt_copy_ctx_pg_tbls()
8920 struct bnxt_ring_mem_info *rmem = &ctx_pg->ring_mem; in bnxt_free_ctx_pg_tbls()
8922 if (rmem->depth > 1 || ctx_pg->nr_pages > MAX_CTX_PAGES || in bnxt_free_ctx_pg_tbls()
8923 ctx_pg->ctx_pg_tbl) { in bnxt_free_ctx_pg_tbls()
8924 int i, nr_tbls = rmem->nr_pages; in bnxt_free_ctx_pg_tbls()
8930 pg_tbl = ctx_pg->ctx_pg_tbl[i]; in bnxt_free_ctx_pg_tbls()
8933 rmem2 = &pg_tbl->ring_mem; in bnxt_free_ctx_pg_tbls()
8935 ctx_pg->ctx_pg_arr[i] = NULL; in bnxt_free_ctx_pg_tbls()
8937 ctx_pg->ctx_pg_tbl[i] = NULL; in bnxt_free_ctx_pg_tbls()
8939 kfree(ctx_pg->ctx_pg_tbl); in bnxt_free_ctx_pg_tbls()
8940 ctx_pg->ctx_pg_tbl = NULL; in bnxt_free_ctx_pg_tbls()
8943 ctx_pg->nr_pages = 0; in bnxt_free_ctx_pg_tbls()
8950 struct bnxt_ctx_pg_info *ctx_pg = ctxm->pg_info; in bnxt_setup_ctxm_pg_tbls()
8954 if (!ctxm->entry_size || !ctx_pg) in bnxt_setup_ctxm_pg_tbls()
8955 return -EINVAL; in bnxt_setup_ctxm_pg_tbls()
8956 if (ctxm->instance_bmap) in bnxt_setup_ctxm_pg_tbls()
8957 n = hweight32(ctxm->instance_bmap); in bnxt_setup_ctxm_pg_tbls()
8958 if (ctxm->entry_multiple) in bnxt_setup_ctxm_pg_tbls()
8959 entries = roundup(entries, ctxm->entry_multiple); in bnxt_setup_ctxm_pg_tbls()
8960 entries = clamp_t(u32, entries, ctxm->min_entries, ctxm->max_entries); in bnxt_setup_ctxm_pg_tbls()
8961 mem_size = entries * ctxm->entry_size; in bnxt_setup_ctxm_pg_tbls()
8965 ctxm->init_value ? ctxm : NULL); in bnxt_setup_ctxm_pg_tbls()
8968 ctxm->mem_valid = 1; in bnxt_setup_ctxm_pg_tbls()
8977 u32 instance_bmap = ctxm->instance_bmap; in bnxt_hwrm_func_backing_store_cfg_v2()
8981 if (!(ctxm->flags & BNXT_CTX_MEM_TYPE_VALID) || !ctxm->pg_info) in bnxt_hwrm_func_backing_store_cfg_v2()
8985 n = hweight32(ctxm->instance_bmap); in bnxt_hwrm_func_backing_store_cfg_v2()
8993 req->type = cpu_to_le16(ctxm->type); in bnxt_hwrm_func_backing_store_cfg_v2()
8994 req->entry_size = cpu_to_le16(ctxm->entry_size); in bnxt_hwrm_func_backing_store_cfg_v2()
8995 if ((ctxm->flags & BNXT_CTX_MEM_PERSIST) && in bnxt_hwrm_func_backing_store_cfg_v2()
8996 bnxt_bs_trace_avail(bp, ctxm->type)) { in bnxt_hwrm_func_backing_store_cfg_v2()
9001 req->enables = cpu_to_le32(enables); in bnxt_hwrm_func_backing_store_cfg_v2()
9002 bs_trace = &bp->bs_trace[bnxt_bstore_to_trace[ctxm->type]]; in bnxt_hwrm_func_backing_store_cfg_v2()
9003 req->next_bs_offset = cpu_to_le32(bs_trace->last_offset); in bnxt_hwrm_func_backing_store_cfg_v2()
9005 req->subtype_valid_cnt = ctxm->split_entry_cnt; in bnxt_hwrm_func_backing_store_cfg_v2()
9006 for (i = 0, p = &req->split_entry_0; i < ctxm->split_entry_cnt; i++) in bnxt_hwrm_func_backing_store_cfg_v2()
9007 p[i] = cpu_to_le32(ctxm->split[i]); in bnxt_hwrm_func_backing_store_cfg_v2()
9013 req->instance = cpu_to_le16(i); in bnxt_hwrm_func_backing_store_cfg_v2()
9014 ctx_pg = &ctxm->pg_info[j++]; in bnxt_hwrm_func_backing_store_cfg_v2()
9015 if (!ctx_pg->entries) in bnxt_hwrm_func_backing_store_cfg_v2()
9017 req->num_entries = cpu_to_le32(ctx_pg->entries); in bnxt_hwrm_func_backing_store_cfg_v2()
9018 bnxt_hwrm_set_pg_attr(&ctx_pg->ring_mem, in bnxt_hwrm_func_backing_store_cfg_v2()
9019 &req->page_size_pbl_level, in bnxt_hwrm_func_backing_store_cfg_v2()
9020 &req->page_dir); in bnxt_hwrm_func_backing_store_cfg_v2()
9022 req->flags = in bnxt_hwrm_func_backing_store_cfg_v2()
9032 struct bnxt_ctx_mem_info *ctx = bp->ctx; in bnxt_backing_store_cfg_v2()
9039 ctxm = &ctx->ctx_arr[type]; in bnxt_backing_store_cfg_v2()
9042 if (!ctxm->mem_valid) { in bnxt_backing_store_cfg_v2()
9044 ctxm->max_entries, 1); in bnxt_backing_store_cfg_v2()
9046 netdev_warn(bp->dev, "Unable to setup ctx page for type:0x%x.\n", in bnxt_backing_store_cfg_v2()
9059 last_type = BNXT_CTX_MAX - 1; in bnxt_backing_store_cfg_v2()
9061 last_type = BNXT_CTX_L2_MAX - 1; in bnxt_backing_store_cfg_v2()
9063 ctx->ctx_arr[last_type].last = 1; in bnxt_backing_store_cfg_v2()
9066 ctxm = &ctx->ctx_arr[type]; in bnxt_backing_store_cfg_v2()
9068 if (!ctxm->mem_valid) in bnxt_backing_store_cfg_v2()
9070 rc = bnxt_hwrm_func_backing_store_cfg_v2(bp, ctxm, ctxm->last); in bnxt_backing_store_cfg_v2()
9078 * __bnxt_copy_ctx_mem - copy host context memory
9095 struct bnxt_ctx_pg_info *ctx_pg = ctxm->pg_info; in __bnxt_copy_ctx_mem()
9102 if (ctxm->instance_bmap) in __bnxt_copy_ctx_mem()
9103 n = hweight32(ctxm->instance_bmap); in __bnxt_copy_ctx_mem()
9116 size_t tail = ctxm->max_entries * ctxm->entry_size; in bnxt_copy_ctx_mem()
9127 ctxm->last = 0; in bnxt_free_one_ctx_mem()
9129 if (ctxm->mem_valid && !force && (ctxm->flags & BNXT_CTX_MEM_PERSIST)) in bnxt_free_one_ctx_mem()
9132 ctx_pg = ctxm->pg_info; in bnxt_free_one_ctx_mem()
9134 if (ctxm->instance_bmap) in bnxt_free_one_ctx_mem()
9135 n = hweight32(ctxm->instance_bmap); in bnxt_free_one_ctx_mem()
9140 ctxm->pg_info = NULL; in bnxt_free_one_ctx_mem()
9141 ctxm->mem_valid = 0; in bnxt_free_one_ctx_mem()
9148 struct bnxt_ctx_mem_info *ctx = bp->ctx; in bnxt_free_ctx_mem()
9155 bnxt_free_one_ctx_mem(bp, &ctx->ctx_arr[type], force); in bnxt_free_ctx_mem()
9157 ctx->flags &= ~BNXT_CTX_FLAG_INITED; in bnxt_free_ctx_mem()
9160 bp->ctx = NULL; in bnxt_free_ctx_mem()
9180 netdev_err(bp->dev, "Failed querying context mem capability, rc = %d.\n", in bnxt_alloc_ctx_mem()
9184 ctx = bp->ctx; in bnxt_alloc_ctx_mem()
9185 if (!ctx || (ctx->flags & BNXT_CTX_FLAG_INITED)) in bnxt_alloc_ctx_mem()
9188 ctxm = &ctx->ctx_arr[BNXT_CTX_QP]; in bnxt_alloc_ctx_mem()
9189 l2_qps = ctxm->qp_l2_entries; in bnxt_alloc_ctx_mem()
9190 qp1_qps = ctxm->qp_qp1_entries; in bnxt_alloc_ctx_mem()
9191 fast_qpmd_qps = ctxm->qp_fast_qpmd_entries; in bnxt_alloc_ctx_mem()
9192 max_qps = ctxm->max_entries; in bnxt_alloc_ctx_mem()
9193 ctxm = &ctx->ctx_arr[BNXT_CTX_SRQ]; in bnxt_alloc_ctx_mem()
9194 srqs = ctxm->srq_l2_entries; in bnxt_alloc_ctx_mem()
9195 max_srqs = ctxm->max_entries; in bnxt_alloc_ctx_mem()
9197 if ((bp->flags & BNXT_FLAG_ROCE_CAP) && !is_kdump_kernel()) { in bnxt_alloc_ctx_mem()
9200 extra_qps = max_qps - l2_qps - qp1_qps; in bnxt_alloc_ctx_mem()
9201 extra_srqs = max_srqs - srqs; in bnxt_alloc_ctx_mem()
9204 max_qps - l2_qps - qp1_qps); in bnxt_alloc_ctx_mem()
9209 extra_srqs = min_t(u32, 8192, max_srqs - srqs); in bnxt_alloc_ctx_mem()
9215 ctxm = &ctx->ctx_arr[BNXT_CTX_QP]; in bnxt_alloc_ctx_mem()
9221 ctxm = &ctx->ctx_arr[BNXT_CTX_SRQ]; in bnxt_alloc_ctx_mem()
9226 ctxm = &ctx->ctx_arr[BNXT_CTX_CQ]; in bnxt_alloc_ctx_mem()
9227 rc = bnxt_setup_ctxm_pg_tbls(bp, ctxm, ctxm->cq_l2_entries + in bnxt_alloc_ctx_mem()
9232 ctxm = &ctx->ctx_arr[BNXT_CTX_VNIC]; in bnxt_alloc_ctx_mem()
9233 rc = bnxt_setup_ctxm_pg_tbls(bp, ctxm, ctxm->max_entries, 1); in bnxt_alloc_ctx_mem()
9237 ctxm = &ctx->ctx_arr[BNXT_CTX_STAT]; in bnxt_alloc_ctx_mem()
9238 rc = bnxt_setup_ctxm_pg_tbls(bp, ctxm, ctxm->max_entries, 1); in bnxt_alloc_ctx_mem()
9242 if (!(bp->flags & BNXT_FLAG_ROCE_CAP)) in bnxt_alloc_ctx_mem()
9245 ctxm = &ctx->ctx_arr[BNXT_CTX_MRAV]; in bnxt_alloc_ctx_mem()
9247 ctxm->split_entry_cnt == BNXT_CTX_MRAV_AV_SPLIT_ENTRY + 1) { in bnxt_alloc_ctx_mem()
9248 num_ah = ctxm->mrav_av_entries; in bnxt_alloc_ctx_mem()
9249 num_mr = ctxm->max_entries - num_ah; in bnxt_alloc_ctx_mem()
9254 num_mr = min_t(u32, ctxm->max_entries / 2, 1024 * 256); in bnxt_alloc_ctx_mem()
9256 ctxm->split_entry_cnt = BNXT_CTX_MRAV_AV_SPLIT_ENTRY + 1; in bnxt_alloc_ctx_mem()
9257 if (!ctxm->mrav_av_entries || ctxm->mrav_av_entries > num_ah) in bnxt_alloc_ctx_mem()
9258 ctxm->mrav_av_entries = num_ah; in bnxt_alloc_ctx_mem()
9266 ctxm = &ctx->ctx_arr[BNXT_CTX_TIM]; in bnxt_alloc_ctx_mem()
9273 ctxm = &ctx->ctx_arr[BNXT_CTX_STQM]; in bnxt_alloc_ctx_mem()
9274 min = ctxm->min_entries; in bnxt_alloc_ctx_mem()
9275 entries_sp = ctx->ctx_arr[BNXT_CTX_VNIC].vnic_entries + l2_qps + in bnxt_alloc_ctx_mem()
9281 ctxm = &ctx->ctx_arr[BNXT_CTX_FTQM]; in bnxt_alloc_ctx_mem()
9286 for (i = 0; i < ctx->tqm_fp_rings_count + 1; i++) in bnxt_alloc_ctx_mem()
9290 if (bp->fw_cap & BNXT_FW_CAP_BACKING_STORE_V2) in bnxt_alloc_ctx_mem()
9295 netdev_err(bp->dev, "Failed configuring context mem, rc = %d.\n", in bnxt_alloc_ctx_mem()
9299 ctx->flags |= BNXT_CTX_FLAG_INITED; in bnxt_alloc_ctx_mem()
9309 if (!(bp->fw_dbg_cap & DBG_QCAPS_RESP_FLAGS_CRASHDUMP_HOST_DDR)) in bnxt_hwrm_crash_dump_mem_cfg()
9322 req->pg_size_lvl = cpu_to_le16(page_attr | in bnxt_hwrm_crash_dump_mem_cfg()
9323 bp->fw_crash_mem->ring_mem.depth); in bnxt_hwrm_crash_dump_mem_cfg()
9324 req->pbl = cpu_to_le64(bp->fw_crash_mem->ring_mem.pg_tbl_map); in bnxt_hwrm_crash_dump_mem_cfg()
9325 req->size = cpu_to_le32(bp->fw_crash_len); in bnxt_hwrm_crash_dump_mem_cfg()
9326 req->output_dest_flags = cpu_to_le16(BNXT_DBG_CR_DUMP_MDM_CFG_DDR); in bnxt_hwrm_crash_dump_mem_cfg()
9332 if (bp->fw_crash_mem) { in bnxt_free_crash_dump_mem()
9333 bnxt_free_ctx_pg_tbls(bp, bp->fw_crash_mem); in bnxt_free_crash_dump_mem()
9334 kfree(bp->fw_crash_mem); in bnxt_free_crash_dump_mem()
9335 bp->fw_crash_mem = NULL; in bnxt_free_crash_dump_mem()
9344 if (!(bp->fw_dbg_cap & DBG_QCAPS_RESP_FLAGS_CRASHDUMP_HOST_DDR)) in bnxt_alloc_crash_dump_mem()
9354 if (bp->fw_crash_mem && in bnxt_alloc_crash_dump_mem()
9355 mem_size <= bp->fw_crash_mem->nr_pages * BNXT_PAGE_SIZE) in bnxt_alloc_crash_dump_mem()
9358 if (bp->fw_crash_mem) in bnxt_alloc_crash_dump_mem()
9359 bnxt_free_ctx_pg_tbls(bp, bp->fw_crash_mem); in bnxt_alloc_crash_dump_mem()
9361 bp->fw_crash_mem = kzalloc(sizeof(*bp->fw_crash_mem), in bnxt_alloc_crash_dump_mem()
9363 if (!bp->fw_crash_mem) in bnxt_alloc_crash_dump_mem()
9364 return -ENOMEM; in bnxt_alloc_crash_dump_mem()
9366 rc = bnxt_alloc_ctx_pg_tbls(bp, bp->fw_crash_mem, mem_size, 1, NULL); in bnxt_alloc_crash_dump_mem()
9373 bp->fw_crash_len = mem_size; in bnxt_alloc_crash_dump_mem()
9381 struct bnxt_hw_resc *hw_resc = &bp->hw_resc; in bnxt_hwrm_func_resc_qcaps()
9388 req->fid = cpu_to_le16(0xffff); in bnxt_hwrm_func_resc_qcaps()
9394 hw_resc->max_tx_sch_inputs = le16_to_cpu(resp->max_tx_scheduler_inputs); in bnxt_hwrm_func_resc_qcaps()
9398 hw_resc->min_rsscos_ctxs = le16_to_cpu(resp->min_rsscos_ctx); in bnxt_hwrm_func_resc_qcaps()
9399 hw_resc->max_rsscos_ctxs = le16_to_cpu(resp->max_rsscos_ctx); in bnxt_hwrm_func_resc_qcaps()
9400 hw_resc->min_cp_rings = le16_to_cpu(resp->min_cmpl_rings); in bnxt_hwrm_func_resc_qcaps()
9401 hw_resc->max_cp_rings = le16_to_cpu(resp->max_cmpl_rings); in bnxt_hwrm_func_resc_qcaps()
9402 hw_resc->min_tx_rings = le16_to_cpu(resp->min_tx_rings); in bnxt_hwrm_func_resc_qcaps()
9403 hw_resc->max_tx_rings = le16_to_cpu(resp->max_tx_rings); in bnxt_hwrm_func_resc_qcaps()
9404 hw_resc->min_rx_rings = le16_to_cpu(resp->min_rx_rings); in bnxt_hwrm_func_resc_qcaps()
9405 hw_resc->max_rx_rings = le16_to_cpu(resp->max_rx_rings); in bnxt_hwrm_func_resc_qcaps()
9406 hw_resc->min_hw_ring_grps = le16_to_cpu(resp->min_hw_ring_grps); in bnxt_hwrm_func_resc_qcaps()
9407 hw_resc->max_hw_ring_grps = le16_to_cpu(resp->max_hw_ring_grps); in bnxt_hwrm_func_resc_qcaps()
9408 hw_resc->min_l2_ctxs = le16_to_cpu(resp->min_l2_ctxs); in bnxt_hwrm_func_resc_qcaps()
9409 hw_resc->max_l2_ctxs = le16_to_cpu(resp->max_l2_ctxs); in bnxt_hwrm_func_resc_qcaps()
9410 hw_resc->min_vnics = le16_to_cpu(resp->min_vnics); in bnxt_hwrm_func_resc_qcaps()
9411 hw_resc->max_vnics = le16_to_cpu(resp->max_vnics); in bnxt_hwrm_func_resc_qcaps()
9412 hw_resc->min_stat_ctxs = le16_to_cpu(resp->min_stat_ctx); in bnxt_hwrm_func_resc_qcaps()
9413 hw_resc->max_stat_ctxs = le16_to_cpu(resp->max_stat_ctx); in bnxt_hwrm_func_resc_qcaps()
9415 if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) { in bnxt_hwrm_func_resc_qcaps()
9416 u16 max_msix = le16_to_cpu(resp->max_msix); in bnxt_hwrm_func_resc_qcaps()
9418 hw_resc->max_nqs = max_msix; in bnxt_hwrm_func_resc_qcaps()
9419 hw_resc->max_hw_ring_grps = hw_resc->max_rx_rings; in bnxt_hwrm_func_resc_qcaps()
9423 struct bnxt_pf_info *pf = &bp->pf; in bnxt_hwrm_func_resc_qcaps()
9425 pf->vf_resv_strategy = in bnxt_hwrm_func_resc_qcaps()
9426 le16_to_cpu(resp->vf_reservation_strategy); in bnxt_hwrm_func_resc_qcaps()
9427 if (pf->vf_resv_strategy > BNXT_VF_RESV_STRATEGY_MINIMAL_STATIC) in bnxt_hwrm_func_resc_qcaps()
9428 pf->vf_resv_strategy = BNXT_VF_RESV_STRATEGY_MAXIMAL; in bnxt_hwrm_func_resc_qcaps()
9439 struct bnxt_ptp_cfg *ptp = bp->ptp_cfg; in __bnxt_hwrm_ptp_qcfg()
9443 if (bp->hwrm_spec_code < 0x10801 || !BNXT_CHIP_P5_PLUS(bp)) { in __bnxt_hwrm_ptp_qcfg()
9444 rc = -ENODEV; in __bnxt_hwrm_ptp_qcfg()
9452 req->port_id = cpu_to_le16(bp->pf.port_id); in __bnxt_hwrm_ptp_qcfg()
9458 flags = resp->flags; in __bnxt_hwrm_ptp_qcfg()
9461 rc = -ENODEV; in __bnxt_hwrm_ptp_qcfg()
9467 rc = -ENOMEM; in __bnxt_hwrm_ptp_qcfg()
9470 ptp->bp = bp; in __bnxt_hwrm_ptp_qcfg()
9471 bp->ptp_cfg = ptp; in __bnxt_hwrm_ptp_qcfg()
9477 ptp->refclk_regs[0] = le32_to_cpu(resp->ts_ref_clock_reg_lower); in __bnxt_hwrm_ptp_qcfg()
9478 ptp->refclk_regs[1] = le32_to_cpu(resp->ts_ref_clock_reg_upper); in __bnxt_hwrm_ptp_qcfg()
9480 ptp->refclk_regs[0] = BNXT_TS_REG_TIMESYNC_TS0_LOWER; in __bnxt_hwrm_ptp_qcfg()
9481 ptp->refclk_regs[1] = BNXT_TS_REG_TIMESYNC_TS0_UPPER; in __bnxt_hwrm_ptp_qcfg()
9483 rc = -ENODEV; in __bnxt_hwrm_ptp_qcfg()
9486 ptp->rtc_configured = in __bnxt_hwrm_ptp_qcfg()
9490 netdev_warn(bp->dev, "PTP initialization failed.\n"); in __bnxt_hwrm_ptp_qcfg()
9499 bp->ptp_cfg = NULL; in __bnxt_hwrm_ptp_qcfg()
9507 struct bnxt_hw_resc *hw_resc = &bp->hw_resc; in __bnxt_hwrm_func_qcaps()
9515 req->fid = cpu_to_le16(0xffff); in __bnxt_hwrm_func_qcaps()
9521 flags = le32_to_cpu(resp->flags); in __bnxt_hwrm_func_qcaps()
9523 bp->flags |= BNXT_FLAG_ROCEV1_CAP; in __bnxt_hwrm_func_qcaps()
9525 bp->flags |= BNXT_FLAG_ROCEV2_CAP; in __bnxt_hwrm_func_qcaps()
9527 bp->fw_cap |= BNXT_FW_CAP_PCIE_STATS_SUPPORTED; in __bnxt_hwrm_func_qcaps()
9529 bp->fw_cap |= BNXT_FW_CAP_HOT_RESET; in __bnxt_hwrm_func_qcaps()
9531 bp->fw_cap |= BNXT_FW_CAP_EXT_STATS_SUPPORTED; in __bnxt_hwrm_func_qcaps()
9533 bp->fw_cap |= BNXT_FW_CAP_ERROR_RECOVERY; in __bnxt_hwrm_func_qcaps()
9535 bp->fw_cap |= BNXT_FW_CAP_ERR_RECOVER_RELOAD; in __bnxt_hwrm_func_qcaps()
9537 bp->fw_cap |= BNXT_FW_CAP_VLAN_TX_INSERT; in __bnxt_hwrm_func_qcaps()
9539 bp->fw_cap |= BNXT_FW_CAP_DBG_QCAPS; in __bnxt_hwrm_func_qcaps()
9541 flags_ext = le32_to_cpu(resp->flags_ext); in __bnxt_hwrm_func_qcaps()
9543 bp->fw_cap |= BNXT_FW_CAP_EXT_HW_STATS_SUPPORTED; in __bnxt_hwrm_func_qcaps()
9545 bp->fw_cap |= BNXT_FW_CAP_PTP_PPS; in __bnxt_hwrm_func_qcaps()
9547 bp->fw_cap |= BNXT_FW_CAP_PTP_RTC; in __bnxt_hwrm_func_qcaps()
9549 bp->fw_cap |= BNXT_FW_CAP_HOT_RESET_IF; in __bnxt_hwrm_func_qcaps()
9551 bp->fw_cap |= BNXT_FW_CAP_LIVEPATCH; in __bnxt_hwrm_func_qcaps()
9553 bp->fw_cap |= BNXT_FW_CAP_DFLT_VLAN_TPID_PCP; in __bnxt_hwrm_func_qcaps()
9555 bp->fw_cap |= BNXT_FW_CAP_BACKING_STORE_V2; in __bnxt_hwrm_func_qcaps()
9557 bp->flags |= BNXT_FLAG_TX_COAL_CMPL; in __bnxt_hwrm_func_qcaps()
9559 flags_ext2 = le32_to_cpu(resp->flags_ext2); in __bnxt_hwrm_func_qcaps()
9561 bp->fw_cap |= BNXT_FW_CAP_RX_ALL_PKT_TS; in __bnxt_hwrm_func_qcaps()
9563 bp->flags |= BNXT_FLAG_UDP_GSO_CAP; in __bnxt_hwrm_func_qcaps()
9565 bp->fw_cap |= BNXT_FW_CAP_TX_TS_CMP; in __bnxt_hwrm_func_qcaps()
9568 bp->fw_cap |= BNXT_FW_CAP_SW_MAX_RESOURCE_LIMITS; in __bnxt_hwrm_func_qcaps()
9571 bp->fw_cap |= BNXT_FW_CAP_ROCE_VF_RESC_MGMT_SUPPORTED; in __bnxt_hwrm_func_qcaps()
9573 bp->tx_push_thresh = 0; in __bnxt_hwrm_func_qcaps()
9576 bp->tx_push_thresh = BNXT_TX_PUSH_THRESH; in __bnxt_hwrm_func_qcaps()
9578 hw_resc->max_rsscos_ctxs = le16_to_cpu(resp->max_rsscos_ctx); in __bnxt_hwrm_func_qcaps()
9579 hw_resc->max_cp_rings = le16_to_cpu(resp->max_cmpl_rings); in __bnxt_hwrm_func_qcaps()
9580 hw_resc->max_tx_rings = le16_to_cpu(resp->max_tx_rings); in __bnxt_hwrm_func_qcaps()
9581 hw_resc->max_rx_rings = le16_to_cpu(resp->max_rx_rings); in __bnxt_hwrm_func_qcaps()
9582 hw_resc->max_hw_ring_grps = le32_to_cpu(resp->max_hw_ring_grps); in __bnxt_hwrm_func_qcaps()
9583 if (!hw_resc->max_hw_ring_grps) in __bnxt_hwrm_func_qcaps()
9584 hw_resc->max_hw_ring_grps = hw_resc->max_tx_rings; in __bnxt_hwrm_func_qcaps()
9585 hw_resc->max_l2_ctxs = le16_to_cpu(resp->max_l2_ctxs); in __bnxt_hwrm_func_qcaps()
9586 hw_resc->max_vnics = le16_to_cpu(resp->max_vnics); in __bnxt_hwrm_func_qcaps()
9587 hw_resc->max_stat_ctxs = le16_to_cpu(resp->max_stat_ctx); in __bnxt_hwrm_func_qcaps()
9589 hw_resc->max_encap_records = le32_to_cpu(resp->max_encap_records); in __bnxt_hwrm_func_qcaps()
9590 hw_resc->max_decap_records = le32_to_cpu(resp->max_decap_records); in __bnxt_hwrm_func_qcaps()
9591 hw_resc->max_tx_em_flows = le32_to_cpu(resp->max_tx_em_flows); in __bnxt_hwrm_func_qcaps()
9592 hw_resc->max_tx_wm_flows = le32_to_cpu(resp->max_tx_wm_flows); in __bnxt_hwrm_func_qcaps()
9593 hw_resc->max_rx_em_flows = le32_to_cpu(resp->max_rx_em_flows); in __bnxt_hwrm_func_qcaps()
9594 hw_resc->max_rx_wm_flows = le32_to_cpu(resp->max_rx_wm_flows); in __bnxt_hwrm_func_qcaps()
9597 struct bnxt_pf_info *pf = &bp->pf; in __bnxt_hwrm_func_qcaps()
9599 pf->fw_fid = le16_to_cpu(resp->fid); in __bnxt_hwrm_func_qcaps()
9600 pf->port_id = le16_to_cpu(resp->port_id); in __bnxt_hwrm_func_qcaps()
9601 memcpy(pf->mac_addr, resp->mac_address, ETH_ALEN); in __bnxt_hwrm_func_qcaps()
9602 pf->first_vf_id = le16_to_cpu(resp->first_vf_id); in __bnxt_hwrm_func_qcaps()
9603 pf->max_vfs = le16_to_cpu(resp->max_vfs); in __bnxt_hwrm_func_qcaps()
9604 bp->flags &= ~BNXT_FLAG_WOL_CAP; in __bnxt_hwrm_func_qcaps()
9606 bp->flags |= BNXT_FLAG_WOL_CAP; in __bnxt_hwrm_func_qcaps()
9608 bp->fw_cap |= BNXT_FW_CAP_PTP; in __bnxt_hwrm_func_qcaps()
9611 kfree(bp->ptp_cfg); in __bnxt_hwrm_func_qcaps()
9612 bp->ptp_cfg = NULL; in __bnxt_hwrm_func_qcaps()
9616 struct bnxt_vf_info *vf = &bp->vf; in __bnxt_hwrm_func_qcaps()
9618 vf->fw_fid = le16_to_cpu(resp->fid); in __bnxt_hwrm_func_qcaps()
9619 memcpy(vf->mac_addr, resp->mac_address, ETH_ALEN); in __bnxt_hwrm_func_qcaps()
9622 bp->tso_max_segs = le16_to_cpu(resp->max_tso_segs); in __bnxt_hwrm_func_qcaps()
9635 bp->fw_dbg_cap = 0; in bnxt_hwrm_dbg_qcaps()
9636 if (!(bp->fw_cap & BNXT_FW_CAP_DBG_QCAPS)) in bnxt_hwrm_dbg_qcaps()
9643 req->fid = cpu_to_le16(0xffff); in bnxt_hwrm_dbg_qcaps()
9649 bp->fw_dbg_cap = le32_to_cpu(resp->flags); in bnxt_hwrm_dbg_qcaps()
9669 netdev_err(bp->dev, "hwrm query qportcfg failure rc: %d\n", rc); in bnxt_hwrm_func_qcaps()
9672 if (bp->hwrm_spec_code >= 0x10803) { in bnxt_hwrm_func_qcaps()
9678 bp->fw_cap |= BNXT_FW_CAP_NEW_RM; in bnxt_hwrm_func_qcaps()
9690 if (!(bp->fw_cap & BNXT_FW_CAP_CFA_ADV_FLOW)) in bnxt_hwrm_cfa_adv_flow_mgnt_qcaps()
9702 flags = le32_to_cpu(resp->flags); in bnxt_hwrm_cfa_adv_flow_mgnt_qcaps()
9705 bp->fw_cap |= BNXT_FW_CAP_CFA_RFS_RING_TBL_IDX_V2; in bnxt_hwrm_cfa_adv_flow_mgnt_qcaps()
9709 bp->fw_cap |= BNXT_FW_CAP_CFA_RFS_RING_TBL_IDX_V3; in bnxt_hwrm_cfa_adv_flow_mgnt_qcaps()
9713 bp->fw_cap |= BNXT_FW_CAP_CFA_NTUPLE_RX_EXT_IP_PROTO; in bnxt_hwrm_cfa_adv_flow_mgnt_qcaps()
9722 if (bp->fw_health) in __bnxt_alloc_fw_health()
9725 bp->fw_health = kzalloc(sizeof(*bp->fw_health), GFP_KERNEL); in __bnxt_alloc_fw_health()
9726 if (!bp->fw_health) in __bnxt_alloc_fw_health()
9727 return -ENOMEM; in __bnxt_alloc_fw_health()
9729 mutex_init(&bp->fw_health->lock); in __bnxt_alloc_fw_health()
9737 if (!(bp->fw_cap & BNXT_FW_CAP_HOT_RESET) && in bnxt_alloc_fw_health()
9738 !(bp->fw_cap & BNXT_FW_CAP_ERROR_RECOVERY)) in bnxt_alloc_fw_health()
9743 bp->fw_cap &= ~BNXT_FW_CAP_HOT_RESET; in bnxt_alloc_fw_health()
9744 bp->fw_cap &= ~BNXT_FW_CAP_ERROR_RECOVERY; in bnxt_alloc_fw_health()
9753 writel(reg & BNXT_GRC_BASE_MASK, bp->bar0 + in __bnxt_map_fw_health_reg()
9760 struct bnxt_fw_health *fw_health = bp->fw_health; in bnxt_inv_fw_health_reg()
9766 reg_type = BNXT_FW_HEALTH_REG_TYPE(fw_health->regs[BNXT_FW_HEALTH_REG]); in bnxt_inv_fw_health_reg()
9768 fw_health->status_reliable = false; in bnxt_inv_fw_health_reg()
9770 reg_type = BNXT_FW_HEALTH_REG_TYPE(fw_health->regs[BNXT_FW_RESET_CNT_REG]); in bnxt_inv_fw_health_reg()
9772 fw_health->resets_reliable = false; in bnxt_inv_fw_health_reg()
9782 if (bp->fw_health) in bnxt_try_map_fw_health_reg()
9783 bp->fw_health->status_reliable = false; in bnxt_try_map_fw_health_reg()
9786 hs = bp->bar0 + BNXT_FW_HEALTH_WIN_OFF(HCOMM_STATUS_STRUCT_LOC); in bnxt_try_map_fw_health_reg()
9790 if (!bp->chip_num) { in bnxt_try_map_fw_health_reg()
9792 bp->chip_num = readl(bp->bar0 + in bnxt_try_map_fw_health_reg()
9807 netdev_warn(bp->dev, "no memory for firmware status checks\n"); in bnxt_try_map_fw_health_reg()
9811 bp->fw_health->regs[BNXT_FW_HEALTH_REG] = status_loc; in bnxt_try_map_fw_health_reg()
9815 bp->fw_health->mapped_regs[BNXT_FW_HEALTH_REG] = in bnxt_try_map_fw_health_reg()
9819 bp->fw_health->status_reliable = true; in bnxt_try_map_fw_health_reg()
9824 struct bnxt_fw_health *fw_health = bp->fw_health; in bnxt_map_fw_health_regs()
9828 bp->fw_health->status_reliable = false; in bnxt_map_fw_health_regs()
9829 bp->fw_health->resets_reliable = false; in bnxt_map_fw_health_regs()
9830 /* Only pre-map the monitoring GRC registers using window 3 */ in bnxt_map_fw_health_regs()
9832 u32 reg = fw_health->regs[i]; in bnxt_map_fw_health_regs()
9839 return -ERANGE; in bnxt_map_fw_health_regs()
9840 fw_health->mapped_regs[i] = BNXT_FW_HEALTH_WIN_OFF(reg); in bnxt_map_fw_health_regs()
9842 bp->fw_health->status_reliable = true; in bnxt_map_fw_health_regs()
9843 bp->fw_health->resets_reliable = true; in bnxt_map_fw_health_regs()
9853 if (!bp->fw_health) in bnxt_remap_fw_health_regs()
9856 if (bp->fw_cap & BNXT_FW_CAP_ERROR_RECOVERY) { in bnxt_remap_fw_health_regs()
9857 bp->fw_health->status_reliable = true; in bnxt_remap_fw_health_regs()
9858 bp->fw_health->resets_reliable = true; in bnxt_remap_fw_health_regs()
9866 struct bnxt_fw_health *fw_health = bp->fw_health; in bnxt_hwrm_error_recovery_qcfg()
9871 if (!(bp->fw_cap & BNXT_FW_CAP_ERROR_RECOVERY)) in bnxt_hwrm_error_recovery_qcfg()
9882 fw_health->flags = le32_to_cpu(resp->flags); in bnxt_hwrm_error_recovery_qcfg()
9883 if ((fw_health->flags & ERROR_RECOVERY_QCFG_RESP_FLAGS_CO_CPU) && in bnxt_hwrm_error_recovery_qcfg()
9884 !(bp->fw_cap & BNXT_FW_CAP_KONG_MB_CHNL)) { in bnxt_hwrm_error_recovery_qcfg()
9885 rc = -EINVAL; in bnxt_hwrm_error_recovery_qcfg()
9888 fw_health->polling_dsecs = le32_to_cpu(resp->driver_polling_freq); in bnxt_hwrm_error_recovery_qcfg()
9889 fw_health->master_func_wait_dsecs = in bnxt_hwrm_error_recovery_qcfg()
9890 le32_to_cpu(resp->master_func_wait_period); in bnxt_hwrm_error_recovery_qcfg()
9891 fw_health->normal_func_wait_dsecs = in bnxt_hwrm_error_recovery_qcfg()
9892 le32_to_cpu(resp->normal_func_wait_period); in bnxt_hwrm_error_recovery_qcfg()
9893 fw_health->post_reset_wait_dsecs = in bnxt_hwrm_error_recovery_qcfg()
9894 le32_to_cpu(resp->master_func_wait_period_after_reset); in bnxt_hwrm_error_recovery_qcfg()
9895 fw_health->post_reset_max_wait_dsecs = in bnxt_hwrm_error_recovery_qcfg()
9896 le32_to_cpu(resp->max_bailout_time_after_reset); in bnxt_hwrm_error_recovery_qcfg()
9897 fw_health->regs[BNXT_FW_HEALTH_REG] = in bnxt_hwrm_error_recovery_qcfg()
9898 le32_to_cpu(resp->fw_health_status_reg); in bnxt_hwrm_error_recovery_qcfg()
9899 fw_health->regs[BNXT_FW_HEARTBEAT_REG] = in bnxt_hwrm_error_recovery_qcfg()
9900 le32_to_cpu(resp->fw_heartbeat_reg); in bnxt_hwrm_error_recovery_qcfg()
9901 fw_health->regs[BNXT_FW_RESET_CNT_REG] = in bnxt_hwrm_error_recovery_qcfg()
9902 le32_to_cpu(resp->fw_reset_cnt_reg); in bnxt_hwrm_error_recovery_qcfg()
9903 fw_health->regs[BNXT_FW_RESET_INPROG_REG] = in bnxt_hwrm_error_recovery_qcfg()
9904 le32_to_cpu(resp->reset_inprogress_reg); in bnxt_hwrm_error_recovery_qcfg()
9905 fw_health->fw_reset_inprog_reg_mask = in bnxt_hwrm_error_recovery_qcfg()
9906 le32_to_cpu(resp->reset_inprogress_reg_mask); in bnxt_hwrm_error_recovery_qcfg()
9907 fw_health->fw_reset_seq_cnt = resp->reg_array_cnt; in bnxt_hwrm_error_recovery_qcfg()
9908 if (fw_health->fw_reset_seq_cnt >= 16) { in bnxt_hwrm_error_recovery_qcfg()
9909 rc = -EINVAL; in bnxt_hwrm_error_recovery_qcfg()
9912 for (i = 0; i < fw_health->fw_reset_seq_cnt; i++) { in bnxt_hwrm_error_recovery_qcfg()
9913 fw_health->fw_reset_seq_regs[i] = in bnxt_hwrm_error_recovery_qcfg()
9914 le32_to_cpu(resp->reset_reg[i]); in bnxt_hwrm_error_recovery_qcfg()
9915 fw_health->fw_reset_seq_vals[i] = in bnxt_hwrm_error_recovery_qcfg()
9916 le32_to_cpu(resp->reset_reg_val[i]); in bnxt_hwrm_error_recovery_qcfg()
9917 fw_health->fw_reset_seq_delay_msec[i] = in bnxt_hwrm_error_recovery_qcfg()
9918 resp->delay_after_reset[i]; in bnxt_hwrm_error_recovery_qcfg()
9925 bp->fw_cap &= ~BNXT_FW_CAP_ERROR_RECOVERY; in bnxt_hwrm_error_recovery_qcfg()
9938 req->enables = 0; in bnxt_hwrm_func_reset()
9948 snprintf(bp->nvm_cfg_ver, FW_VER_STR_LEN, "%d.%d.%d", in bnxt_nvm_cfg_ver_get()
9970 if (!resp->max_configurable_queues) { in bnxt_hwrm_queue_qportcfg()
9971 rc = -EINVAL; in bnxt_hwrm_queue_qportcfg()
9974 bp->max_tc = resp->max_configurable_queues; in bnxt_hwrm_queue_qportcfg()
9975 bp->max_lltc = resp->max_configurable_lossless_queues; in bnxt_hwrm_queue_qportcfg()
9976 if (bp->max_tc > BNXT_MAX_QUEUE) in bnxt_hwrm_queue_qportcfg()
9977 bp->max_tc = BNXT_MAX_QUEUE; in bnxt_hwrm_queue_qportcfg()
9979 no_rdma = !(bp->flags & BNXT_FLAG_ROCE_CAP); in bnxt_hwrm_queue_qportcfg()
9980 qptr = &resp->queue_id0; in bnxt_hwrm_queue_qportcfg()
9981 for (i = 0, j = 0; i < bp->max_tc; i++) { in bnxt_hwrm_queue_qportcfg()
9982 bp->q_info[j].queue_id = *qptr; in bnxt_hwrm_queue_qportcfg()
9983 bp->q_ids[i] = *qptr++; in bnxt_hwrm_queue_qportcfg()
9984 bp->q_info[j].queue_profile = *qptr++; in bnxt_hwrm_queue_qportcfg()
9985 bp->tc_to_qidx[j] = j; in bnxt_hwrm_queue_qportcfg()
9986 if (!BNXT_CNPQ(bp->q_info[j].queue_profile) || in bnxt_hwrm_queue_qportcfg()
9990 bp->max_q = bp->max_tc; in bnxt_hwrm_queue_qportcfg()
9991 bp->max_tc = max_t(u8, j, 1); in bnxt_hwrm_queue_qportcfg()
9993 if (resp->queue_cfg_info & QUEUE_QPORTCFG_RESP_QUEUE_CFG_INFO_ASYM_CFG) in bnxt_hwrm_queue_qportcfg()
9994 bp->max_tc = 1; in bnxt_hwrm_queue_qportcfg()
9996 if (bp->max_lltc > bp->max_tc) in bnxt_hwrm_queue_qportcfg()
9997 bp->max_lltc = bp->max_tc; in bnxt_hwrm_queue_qportcfg()
10013 req->hwrm_intf_maj = HWRM_VERSION_MAJOR; in bnxt_hwrm_poll()
10014 req->hwrm_intf_min = HWRM_VERSION_MINOR; in bnxt_hwrm_poll()
10015 req->hwrm_intf_upd = HWRM_VERSION_UPDATE; in bnxt_hwrm_poll()
10035 bp->hwrm_max_req_len = HWRM_MAX_REQ_LEN; in bnxt_hwrm_ver_get()
10036 req->hwrm_intf_maj = HWRM_VERSION_MAJOR; in bnxt_hwrm_ver_get()
10037 req->hwrm_intf_min = HWRM_VERSION_MINOR; in bnxt_hwrm_ver_get()
10038 req->hwrm_intf_upd = HWRM_VERSION_UPDATE; in bnxt_hwrm_ver_get()
10045 memcpy(&bp->ver_resp, resp, sizeof(struct hwrm_ver_get_output)); in bnxt_hwrm_ver_get()
10047 bp->hwrm_spec_code = resp->hwrm_intf_maj_8b << 16 | in bnxt_hwrm_ver_get()
10048 resp->hwrm_intf_min_8b << 8 | in bnxt_hwrm_ver_get()
10049 resp->hwrm_intf_upd_8b; in bnxt_hwrm_ver_get()
10050 if (resp->hwrm_intf_maj_8b < 1) { in bnxt_hwrm_ver_get()
10051 netdev_warn(bp->dev, "HWRM interface %d.%d.%d is older than 1.0.0.\n", in bnxt_hwrm_ver_get()
10052 resp->hwrm_intf_maj_8b, resp->hwrm_intf_min_8b, in bnxt_hwrm_ver_get()
10053 resp->hwrm_intf_upd_8b); in bnxt_hwrm_ver_get()
10054 netdev_warn(bp->dev, "Please update firmware with HWRM interface 1.0.0 or newer.\n"); in bnxt_hwrm_ver_get()
10060 if (bp->hwrm_spec_code > hwrm_ver) in bnxt_hwrm_ver_get()
10061 snprintf(bp->hwrm_ver_supp, FW_VER_STR_LEN, "%d.%d.%d", in bnxt_hwrm_ver_get()
10065 snprintf(bp->hwrm_ver_supp, FW_VER_STR_LEN, "%d.%d.%d", in bnxt_hwrm_ver_get()
10066 resp->hwrm_intf_maj_8b, resp->hwrm_intf_min_8b, in bnxt_hwrm_ver_get()
10067 resp->hwrm_intf_upd_8b); in bnxt_hwrm_ver_get()
10069 fw_maj = le16_to_cpu(resp->hwrm_fw_major); in bnxt_hwrm_ver_get()
10070 if (bp->hwrm_spec_code > 0x10803 && fw_maj) { in bnxt_hwrm_ver_get()
10071 fw_min = le16_to_cpu(resp->hwrm_fw_minor); in bnxt_hwrm_ver_get()
10072 fw_bld = le16_to_cpu(resp->hwrm_fw_build); in bnxt_hwrm_ver_get()
10073 fw_rsv = le16_to_cpu(resp->hwrm_fw_patch); in bnxt_hwrm_ver_get()
10076 fw_maj = resp->hwrm_fw_maj_8b; in bnxt_hwrm_ver_get()
10077 fw_min = resp->hwrm_fw_min_8b; in bnxt_hwrm_ver_get()
10078 fw_bld = resp->hwrm_fw_bld_8b; in bnxt_hwrm_ver_get()
10079 fw_rsv = resp->hwrm_fw_rsvd_8b; in bnxt_hwrm_ver_get()
10082 bp->fw_ver_code = BNXT_FW_VER_CODE(fw_maj, fw_min, fw_bld, fw_rsv); in bnxt_hwrm_ver_get()
10083 snprintf(bp->fw_ver_str, len, "%d.%d.%d.%d", fw_maj, fw_min, fw_bld, in bnxt_hwrm_ver_get()
10086 if (strlen(resp->active_pkg_name)) { in bnxt_hwrm_ver_get()
10087 int fw_ver_len = strlen(bp->fw_ver_str); in bnxt_hwrm_ver_get()
10089 snprintf(bp->fw_ver_str + fw_ver_len, in bnxt_hwrm_ver_get()
10090 FW_VER_STR_LEN - fw_ver_len - 1, "/pkg %s", in bnxt_hwrm_ver_get()
10091 resp->active_pkg_name); in bnxt_hwrm_ver_get()
10092 bp->fw_cap |= BNXT_FW_CAP_PKG_VER; in bnxt_hwrm_ver_get()
10095 bp->hwrm_cmd_timeout = le16_to_cpu(resp->def_req_timeout); in bnxt_hwrm_ver_get()
10096 if (!bp->hwrm_cmd_timeout) in bnxt_hwrm_ver_get()
10097 bp->hwrm_cmd_timeout = DFLT_HWRM_CMD_TIMEOUT; in bnxt_hwrm_ver_get()
10098 bp->hwrm_cmd_max_timeout = le16_to_cpu(resp->max_req_timeout) * 1000; in bnxt_hwrm_ver_get()
10099 if (!bp->hwrm_cmd_max_timeout) in bnxt_hwrm_ver_get()
10100 bp->hwrm_cmd_max_timeout = HWRM_CMD_MAX_TIMEOUT; in bnxt_hwrm_ver_get()
10101 else if (bp->hwrm_cmd_max_timeout > HWRM_CMD_MAX_TIMEOUT) in bnxt_hwrm_ver_get()
10102 …netdev_warn(bp->dev, "Device requests max timeout of %d seconds, may trigger hung task watchdog\n", in bnxt_hwrm_ver_get()
10103 bp->hwrm_cmd_max_timeout / 1000); in bnxt_hwrm_ver_get()
10105 if (resp->hwrm_intf_maj_8b >= 1) { in bnxt_hwrm_ver_get()
10106 bp->hwrm_max_req_len = le16_to_cpu(resp->max_req_win_len); in bnxt_hwrm_ver_get()
10107 bp->hwrm_max_ext_req_len = le16_to_cpu(resp->max_ext_req_len); in bnxt_hwrm_ver_get()
10109 if (bp->hwrm_max_ext_req_len < HWRM_MAX_REQ_LEN) in bnxt_hwrm_ver_get()
10110 bp->hwrm_max_ext_req_len = HWRM_MAX_REQ_LEN; in bnxt_hwrm_ver_get()
10112 bp->chip_num = le16_to_cpu(resp->chip_num); in bnxt_hwrm_ver_get()
10113 bp->chip_rev = resp->chip_rev; in bnxt_hwrm_ver_get()
10114 if (bp->chip_num == CHIP_NUM_58700 && !resp->chip_rev && in bnxt_hwrm_ver_get()
10115 !resp->chip_metal) in bnxt_hwrm_ver_get()
10116 bp->flags |= BNXT_FLAG_CHIP_NITRO_A0; in bnxt_hwrm_ver_get()
10118 dev_caps_cfg = le32_to_cpu(resp->dev_caps_cfg); in bnxt_hwrm_ver_get()
10121 bp->fw_cap |= BNXT_FW_CAP_SHORT_CMD; in bnxt_hwrm_ver_get()
10124 bp->fw_cap |= BNXT_FW_CAP_KONG_MB_CHNL; in bnxt_hwrm_ver_get()
10128 bp->fw_cap |= BNXT_FW_CAP_OVS_64BIT_HANDLE; in bnxt_hwrm_ver_get()
10132 bp->fw_cap |= BNXT_FW_CAP_TRUSTED_VF; in bnxt_hwrm_ver_get()
10136 bp->fw_cap |= BNXT_FW_CAP_CFA_ADV_FLOW; in bnxt_hwrm_ver_get()
10150 if ((BNXT_VF(bp) && bp->hwrm_spec_code < 0x10901) || in bnxt_hwrm_fw_set_time()
10151 bp->hwrm_spec_code < 0x10400) in bnxt_hwrm_fw_set_time()
10152 return -EOPNOTSUPP; in bnxt_hwrm_fw_set_time()
10159 req->year = cpu_to_le16(1900 + tm.tm_year); in bnxt_hwrm_fw_set_time()
10160 req->month = 1 + tm.tm_mon; in bnxt_hwrm_fw_set_time()
10161 req->day = tm.tm_mday; in bnxt_hwrm_fw_set_time()
10162 req->hour = tm.tm_hour; in bnxt_hwrm_fw_set_time()
10163 req->minute = tm.tm_min; in bnxt_hwrm_fw_set_time()
10164 req->second = tm.tm_sec; in bnxt_hwrm_fw_set_time()
10190 if (masks[i] == -1ULL) in __bnxt_accumulate_stats()
10199 if (!stats->hw_stats) in bnxt_accumulate_stats()
10202 __bnxt_accumulate_stats(stats->hw_stats, stats->sw_stats, in bnxt_accumulate_stats()
10203 stats->hw_masks, stats->len / 8, false); in bnxt_accumulate_stats()
10213 if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) in bnxt_accumulate_all_stats()
10216 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_accumulate_all_stats()
10217 struct bnxt_napi *bnapi = bp->bnapi[i]; in bnxt_accumulate_all_stats()
10221 cpr = &bnapi->cp_ring; in bnxt_accumulate_all_stats()
10222 stats = &cpr->stats; in bnxt_accumulate_all_stats()
10225 __bnxt_accumulate_stats(stats->hw_stats, stats->sw_stats, in bnxt_accumulate_all_stats()
10226 ring0_stats->hw_masks, in bnxt_accumulate_all_stats()
10227 ring0_stats->len / 8, ignore_zero); in bnxt_accumulate_all_stats()
10229 if (bp->flags & BNXT_FLAG_PORT_STATS) { in bnxt_accumulate_all_stats()
10230 struct bnxt_stats_mem *stats = &bp->port_stats; in bnxt_accumulate_all_stats()
10231 __le64 *hw_stats = stats->hw_stats; in bnxt_accumulate_all_stats()
10232 u64 *sw_stats = stats->sw_stats; in bnxt_accumulate_all_stats()
10233 u64 *masks = stats->hw_masks; in bnxt_accumulate_all_stats()
10245 if (bp->flags & BNXT_FLAG_PORT_STATS_EXT) { in bnxt_accumulate_all_stats()
10246 bnxt_accumulate_stats(&bp->rx_port_stats_ext); in bnxt_accumulate_all_stats()
10247 bnxt_accumulate_stats(&bp->tx_port_stats_ext); in bnxt_accumulate_all_stats()
10254 struct bnxt_pf_info *pf = &bp->pf; in bnxt_hwrm_port_qstats()
10257 if (!(bp->flags & BNXT_FLAG_PORT_STATS)) in bnxt_hwrm_port_qstats()
10260 if (flags && !(bp->fw_cap & BNXT_FW_CAP_EXT_HW_STATS_SUPPORTED)) in bnxt_hwrm_port_qstats()
10261 return -EOPNOTSUPP; in bnxt_hwrm_port_qstats()
10267 req->flags = flags; in bnxt_hwrm_port_qstats()
10268 req->port_id = cpu_to_le16(pf->port_id); in bnxt_hwrm_port_qstats()
10269 req->tx_stat_host_addr = cpu_to_le64(bp->port_stats.hw_stats_map + in bnxt_hwrm_port_qstats()
10271 req->rx_stat_host_addr = cpu_to_le64(bp->port_stats.hw_stats_map); in bnxt_hwrm_port_qstats()
10281 struct bnxt_pf_info *pf = &bp->pf; in bnxt_hwrm_port_qstats_ext()
10285 if (!(bp->flags & BNXT_FLAG_PORT_STATS_EXT)) in bnxt_hwrm_port_qstats_ext()
10288 if (flags && !(bp->fw_cap & BNXT_FW_CAP_EXT_HW_STATS_SUPPORTED)) in bnxt_hwrm_port_qstats_ext()
10289 return -EOPNOTSUPP; in bnxt_hwrm_port_qstats_ext()
10295 req_qs->flags = flags; in bnxt_hwrm_port_qstats_ext()
10296 req_qs->port_id = cpu_to_le16(pf->port_id); in bnxt_hwrm_port_qstats_ext()
10297 req_qs->rx_stat_size = cpu_to_le16(sizeof(struct rx_port_stats_ext)); in bnxt_hwrm_port_qstats_ext()
10298 req_qs->rx_stat_host_addr = cpu_to_le64(bp->rx_port_stats_ext.hw_stats_map); in bnxt_hwrm_port_qstats_ext()
10299 tx_stat_size = bp->tx_port_stats_ext.hw_stats ? in bnxt_hwrm_port_qstats_ext()
10301 req_qs->tx_stat_size = cpu_to_le16(tx_stat_size); in bnxt_hwrm_port_qstats_ext()
10302 req_qs->tx_stat_host_addr = cpu_to_le64(bp->tx_port_stats_ext.hw_stats_map); in bnxt_hwrm_port_qstats_ext()
10306 bp->fw_rx_stats_ext_size = in bnxt_hwrm_port_qstats_ext()
10307 le16_to_cpu(resp_qs->rx_stat_size) / 8; in bnxt_hwrm_port_qstats_ext()
10309 bp->fw_rx_stats_ext_size > BNXT_RX_STATS_EXT_NUM_LEGACY) in bnxt_hwrm_port_qstats_ext()
10310 bp->fw_rx_stats_ext_size = BNXT_RX_STATS_EXT_NUM_LEGACY; in bnxt_hwrm_port_qstats_ext()
10312 bp->fw_tx_stats_ext_size = tx_stat_size ? in bnxt_hwrm_port_qstats_ext()
10313 le16_to_cpu(resp_qs->tx_stat_size) / 8 : 0; in bnxt_hwrm_port_qstats_ext()
10315 bp->fw_rx_stats_ext_size = 0; in bnxt_hwrm_port_qstats_ext()
10316 bp->fw_tx_stats_ext_size = 0; in bnxt_hwrm_port_qstats_ext()
10323 if (bp->fw_tx_stats_ext_size <= in bnxt_hwrm_port_qstats_ext()
10325 bp->pri2cos_valid = 0; in bnxt_hwrm_port_qstats_ext()
10333 req_qc->flags = cpu_to_le32(QUEUE_PRI2COS_QCFG_REQ_FLAGS_IVLAN); in bnxt_hwrm_port_qstats_ext()
10341 pri2cos = &resp_qc->pri0_cos_queue_id; in bnxt_hwrm_port_qstats_ext()
10349 bp->pri2cos_valid = false; in bnxt_hwrm_port_qstats_ext()
10353 for (j = 0; j < bp->max_q; j++) { in bnxt_hwrm_port_qstats_ext()
10354 if (bp->q_ids[j] == queue_id) in bnxt_hwrm_port_qstats_ext()
10355 bp->pri2cos_idx[i] = queue_idx; in bnxt_hwrm_port_qstats_ext()
10358 bp->pri2cos_valid = true; in bnxt_hwrm_port_qstats_ext()
10379 tpa_flags = bp->flags & BNXT_FLAG_TPA; in bnxt_set_tpa()
10382 for (i = 0; i < bp->nr_vnics; i++) { in bnxt_set_tpa()
10383 rc = bnxt_hwrm_vnic_set_tpa(bp, &bp->vnic_info[i], tpa_flags); in bnxt_set_tpa()
10385 netdev_err(bp->dev, "hwrm vnic set tpa failure rc for vnic %d: %x\n", in bnxt_set_tpa()
10397 for (i = 0; i < bp->nr_vnics; i++) in bnxt_hwrm_clear_vnic_rss()
10398 bnxt_hwrm_vnic_set_rss(bp, &bp->vnic_info[i], false); in bnxt_hwrm_clear_vnic_rss()
10403 if (!bp->vnic_info) in bnxt_clear_vnic()
10407 if (!(bp->flags & BNXT_FLAG_CHIP_P5_PLUS)) { in bnxt_clear_vnic()
10413 if (bp->flags & BNXT_FLAG_TPA) in bnxt_clear_vnic()
10416 if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) in bnxt_clear_vnic()
10443 return -EINVAL; in bnxt_hwrm_set_br_mode()
10449 req->fid = cpu_to_le16(0xffff); in bnxt_hwrm_set_br_mode()
10450 req->enables = cpu_to_le32(FUNC_CFG_REQ_ENABLES_EVB_MODE); in bnxt_hwrm_set_br_mode()
10451 req->evb_mode = evb_mode; in bnxt_hwrm_set_br_mode()
10460 if (BNXT_VF(bp) || bp->hwrm_spec_code < 0x10803) in bnxt_hwrm_set_cache_line_size()
10467 req->fid = cpu_to_le16(0xffff); in bnxt_hwrm_set_cache_line_size()
10468 req->enables = cpu_to_le32(FUNC_CFG_REQ_ENABLES_CACHE_LINESIZE); in bnxt_hwrm_set_cache_line_size()
10469 req->options = FUNC_CFG_REQ_OPTIONS_CACHE_LINESIZE_SIZE_64; in bnxt_hwrm_set_cache_line_size()
10471 req->options = FUNC_CFG_REQ_OPTIONS_CACHE_LINESIZE_SIZE_128; in bnxt_hwrm_set_cache_line_size()
10480 if (vnic->flags & BNXT_VNIC_RFS_NEW_RSS_FLAG) in __bnxt_setup_vnic()
10486 netdev_err(bp->dev, "hwrm vnic %d alloc failure rc: %x\n", in __bnxt_setup_vnic()
10487 vnic->vnic_id, rc); in __bnxt_setup_vnic()
10490 bp->rsscos_nr_ctxs++; in __bnxt_setup_vnic()
10495 netdev_err(bp->dev, "hwrm vnic %d cos ctx alloc failure rc: %x\n", in __bnxt_setup_vnic()
10496 vnic->vnic_id, rc); in __bnxt_setup_vnic()
10499 bp->rsscos_nr_ctxs++; in __bnxt_setup_vnic()
10506 netdev_err(bp->dev, "hwrm vnic %d cfg failure rc: %x\n", in __bnxt_setup_vnic()
10507 vnic->vnic_id, rc); in __bnxt_setup_vnic()
10514 netdev_err(bp->dev, "hwrm vnic %d set rss failure rc: %x\n", in __bnxt_setup_vnic()
10515 vnic->vnic_id, rc); in __bnxt_setup_vnic()
10519 if (bp->flags & BNXT_FLAG_AGG_RINGS) { in __bnxt_setup_vnic()
10522 netdev_err(bp->dev, "hwrm vnic %d set hds failure rc: %x\n", in __bnxt_setup_vnic()
10523 vnic->vnic_id, rc); in __bnxt_setup_vnic()
10541 req->vnic_id = cpu_to_le32(vnic->fw_vnic_id); in bnxt_hwrm_vnic_update()
10544 req->mru = cpu_to_le16(vnic->mru); in bnxt_hwrm_vnic_update()
10546 req->enables = cpu_to_le32(valid); in bnxt_hwrm_vnic_update()
10557 netdev_err(bp->dev, "hwrm vnic %d set rss failure rc: %d\n", in bnxt_hwrm_vnic_rss_cfg_p5()
10558 vnic->vnic_id, rc); in bnxt_hwrm_vnic_rss_cfg_p5()
10563 netdev_err(bp->dev, "hwrm vnic %d cfg failure rc: %x\n", in bnxt_hwrm_vnic_rss_cfg_p5()
10564 vnic->vnic_id, rc); in bnxt_hwrm_vnic_rss_cfg_p5()
10572 nr_ctxs = bnxt_get_nr_rss_ctxs(bp, bp->rx_nr_rings); in __bnxt_setup_vnic_p5()
10576 netdev_err(bp->dev, "hwrm vnic %d ctx %d alloc failure rc: %x\n", in __bnxt_setup_vnic_p5()
10577 vnic->vnic_id, i, rc); in __bnxt_setup_vnic_p5()
10580 bp->rsscos_nr_ctxs++; in __bnxt_setup_vnic_p5()
10583 return -ENOMEM; in __bnxt_setup_vnic_p5()
10589 if (bp->flags & BNXT_FLAG_AGG_RINGS) { in __bnxt_setup_vnic_p5()
10592 netdev_err(bp->dev, "hwrm vnic %d set hds failure rc: %x\n", in __bnxt_setup_vnic_p5()
10593 vnic->vnic_id, rc); in __bnxt_setup_vnic_p5()
10601 if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) in bnxt_setup_vnic()
10615 netdev_err(bp->dev, "hwrm vnic %d alloc failure rc: %x\n", in bnxt_alloc_and_setup_vnic()
10616 vnic->vnic_id, rc); in bnxt_alloc_and_setup_vnic()
10628 vnic = &bp->vnic_info[BNXT_VNIC_NTUPLE]; in bnxt_alloc_rfs_vnics()
10629 return bnxt_alloc_and_setup_vnic(bp, vnic, 0, bp->rx_nr_rings); in bnxt_alloc_rfs_vnics()
10632 if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) in bnxt_alloc_rfs_vnics()
10635 for (i = 0; i < bp->rx_nr_rings; i++) { in bnxt_alloc_rfs_vnics()
10639 if (vnic_id >= bp->nr_vnics) in bnxt_alloc_rfs_vnics()
10642 vnic = &bp->vnic_info[vnic_id]; in bnxt_alloc_rfs_vnics()
10643 vnic->flags |= BNXT_VNIC_RFS_FLAG; in bnxt_alloc_rfs_vnics()
10644 if (bp->rss_cap & BNXT_RSS_CAP_NEW_RSS_CAP) in bnxt_alloc_rfs_vnics()
10645 vnic->flags |= BNXT_VNIC_RFS_NEW_RSS_FLAG; in bnxt_alloc_rfs_vnics()
10646 if (bnxt_alloc_and_setup_vnic(bp, &bp->vnic_info[vnic_id], ring_id, 1)) in bnxt_alloc_rfs_vnics()
10655 struct bnxt_vnic_info *vnic = &rss_ctx->vnic; in bnxt_del_one_rss_ctx()
10660 if (netif_running(bp->dev)) { in bnxt_del_one_rss_ctx()
10661 bnxt_hwrm_vnic_free_one(bp, &rss_ctx->vnic); in bnxt_del_one_rss_ctx()
10663 if (vnic->fw_rss_cos_lb_ctx[i] != INVALID_HW_RING_ID) in bnxt_del_one_rss_ctx()
10670 list_for_each_entry_safe(usr_fltr, tmp, &bp->usr_fltr_list, list) { in bnxt_del_one_rss_ctx()
10671 if ((usr_fltr->flags & BNXT_ACT_RSS_CTX) && in bnxt_del_one_rss_ctx()
10672 usr_fltr->fw_vnic_id == rss_ctx->index) { in bnxt_del_one_rss_ctx()
10682 if (vnic->rss_table) in bnxt_del_one_rss_ctx()
10683 dma_free_coherent(&bp->pdev->dev, vnic->rss_table_size, in bnxt_del_one_rss_ctx()
10684 vnic->rss_table, in bnxt_del_one_rss_ctx()
10685 vnic->rss_table_dma_addr); in bnxt_del_one_rss_ctx()
10686 bp->num_rss_ctx--; in bnxt_del_one_rss_ctx()
10691 bool set_tpa = !!(bp->flags & BNXT_FLAG_TPA); in bnxt_hwrm_realloc_rss_ctx_vnic()
10695 xa_for_each(&bp->dev->ethtool->rss_ctx, context, ctx) { in bnxt_hwrm_realloc_rss_ctx_vnic()
10697 struct bnxt_vnic_info *vnic = &rss_ctx->vnic; in bnxt_hwrm_realloc_rss_ctx_vnic()
10699 if (bnxt_hwrm_vnic_alloc(bp, vnic, 0, bp->rx_nr_rings) || in bnxt_hwrm_realloc_rss_ctx_vnic()
10702 netdev_err(bp->dev, "Failed to restore RSS ctx %d\n", in bnxt_hwrm_realloc_rss_ctx_vnic()
10703 rss_ctx->index); in bnxt_hwrm_realloc_rss_ctx_vnic()
10705 ethtool_rxfh_context_lost(bp->dev, rss_ctx->index); in bnxt_hwrm_realloc_rss_ctx_vnic()
10715 xa_for_each(&bp->dev->ethtool->rss_ctx, context, ctx) { in bnxt_clear_rss_ctxs()
10726 if (BNXT_VF(bp) && !bp->vf.vlan && !bnxt_is_trusted_vf(bp, &bp->vf)) in bnxt_promisc_ok()
10734 struct bnxt_vnic_info *vnic = &bp->vnic_info[1]; in bnxt_setup_nitroa0_vnic()
10737 rc = bnxt_hwrm_vnic_alloc(bp, vnic, bp->rx_nr_rings - 1, 1); in bnxt_setup_nitroa0_vnic()
10739 netdev_err(bp->dev, "Cannot allocate special vnic for NS2 A0: %x\n", in bnxt_setup_nitroa0_vnic()
10746 netdev_err(bp->dev, "Cannot allocate special vnic for NS2 A0: %x\n", in bnxt_setup_nitroa0_vnic()
10758 struct bnxt_vnic_info *vnic = &bp->vnic_info[BNXT_VNIC_DEFAULT]; in bnxt_init_chip()
10760 unsigned int rx_nr_rings = bp->rx_nr_rings; in bnxt_init_chip()
10765 netdev_err(bp->dev, "hwrm stat ctx alloc failure rc: %x\n", in bnxt_init_chip()
10773 netdev_err(bp->dev, "hwrm ring alloc failure rc: %x\n", rc); in bnxt_init_chip()
10779 netdev_err(bp->dev, "hwrm_ring_grp alloc failure: %x\n", rc); in bnxt_init_chip()
10784 rx_nr_rings--; in bnxt_init_chip()
10789 netdev_err(bp->dev, "hwrm vnic alloc failure rc: %x\n", rc); in bnxt_init_chip()
10799 if (bp->rss_cap & BNXT_RSS_CAP_RSS_HASH_TYPE_DELTA) in bnxt_init_chip()
10802 if (bp->flags & BNXT_FLAG_RFS) { in bnxt_init_chip()
10808 if (bp->flags & BNXT_FLAG_TPA) { in bnxt_init_chip()
10818 rc = bnxt_hwrm_set_vnic_filter(bp, 0, 0, bp->dev->dev_addr); in bnxt_init_chip()
10820 if (BNXT_VF(bp) && rc == -ENODEV) in bnxt_init_chip()
10821 netdev_err(bp->dev, "Cannot configure L2 filter while PF is unavailable\n"); in bnxt_init_chip()
10823 netdev_err(bp->dev, "HWRM vnic filter failure rc: %x\n", rc); in bnxt_init_chip()
10826 vnic->uc_filter_count = 1; in bnxt_init_chip()
10828 vnic->rx_mask = 0; in bnxt_init_chip()
10829 if (test_bit(BNXT_STATE_HALF_OPEN, &bp->state)) in bnxt_init_chip()
10832 if (bp->dev->flags & IFF_BROADCAST) in bnxt_init_chip()
10833 vnic->rx_mask |= CFA_L2_SET_RX_MASK_REQ_MASK_BCAST; in bnxt_init_chip()
10835 if (bp->dev->flags & IFF_PROMISC) in bnxt_init_chip()
10836 vnic->rx_mask |= CFA_L2_SET_RX_MASK_REQ_MASK_PROMISCUOUS; in bnxt_init_chip()
10838 if (bp->dev->flags & IFF_ALLMULTI) { in bnxt_init_chip()
10839 vnic->rx_mask |= CFA_L2_SET_RX_MASK_REQ_MASK_ALL_MCAST; in bnxt_init_chip()
10840 vnic->mc_list_count = 0; in bnxt_init_chip()
10841 } else if (bp->dev->flags & IFF_MULTICAST) { in bnxt_init_chip()
10845 vnic->rx_mask |= mask; in bnxt_init_chip()
10855 netdev_warn(bp->dev, "HWRM set coalescing failure rc: %x\n", in bnxt_init_chip()
10861 netdev_err(bp->dev, "Special vnic setup failure for NS2 A0 rc: %x\n", in bnxt_init_chip()
10867 netdev_update_features(bp->dev); in bnxt_init_chip()
10898 struct net_device *dev = bp->dev; in bnxt_set_real_num_queues()
10900 rc = netif_set_real_num_tx_queues(dev, bp->tx_nr_rings - in bnxt_set_real_num_queues()
10901 bp->tx_nr_rings_xdp); in bnxt_set_real_num_queues()
10905 rc = netif_set_real_num_rx_queues(dev, bp->rx_nr_rings); in bnxt_set_real_num_queues()
10910 if (bp->flags & BNXT_FLAG_RFS) in bnxt_set_real_num_queues()
10911 dev->rx_cpu_rmap = alloc_irq_cpu_rmap(bp->rx_nr_rings); in bnxt_set_real_num_queues()
10927 return -ENOMEM; in __bnxt_trim_rings()
10931 _rx--; in __bnxt_trim_rings()
10933 _tx--; in __bnxt_trim_rings()
10943 return (tx - tx_xdp) / tx_sets + tx_xdp; in __bnxt_num_tx_to_cp()
10948 int tcs = bp->num_tc; in bnxt_num_tx_to_cp()
10952 return __bnxt_num_tx_to_cp(bp, tx, tcs, bp->tx_nr_rings_xdp); in bnxt_num_tx_to_cp()
10957 int tcs = bp->num_tc; in bnxt_num_cp_to_tx()
10959 return (tx_cp - bp->tx_nr_rings_xdp) * tcs + in bnxt_num_cp_to_tx()
10960 bp->tx_nr_rings_xdp; in bnxt_num_cp_to_tx()
10983 const int len = sizeof(bp->irq_tbl[0].name); in bnxt_setup_msix()
10984 struct net_device *dev = bp->dev; in bnxt_setup_msix()
10987 tcs = bp->num_tc; in bnxt_setup_msix()
10992 count = bp->tx_nr_rings_per_tc; in bnxt_setup_msix()
10998 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_setup_msix()
11002 if (bp->flags & BNXT_FLAG_SHARED_RINGS) in bnxt_setup_msix()
11004 else if (i < bp->rx_nr_rings) in bnxt_setup_msix()
11009 snprintf(bp->irq_tbl[map_idx].name, len, "%s-%s-%d", dev->name, in bnxt_setup_msix()
11011 bp->irq_tbl[map_idx].handler = bnxt_msix; in bnxt_setup_msix()
11023 for (i = bp->total_irqs; i < total; i++) { in bnxt_change_msix()
11024 map = pci_msix_alloc_irq_at(bp->pdev, i, NULL); in bnxt_change_msix()
11026 return bp->total_irqs; in bnxt_change_msix()
11027 bp->irq_tbl[i].vector = map.virq; in bnxt_change_msix()
11028 bp->total_irqs++; in bnxt_change_msix()
11032 for (i = bp->total_irqs; i > total; i--) { in bnxt_change_msix()
11033 map.index = i - 1; in bnxt_change_msix()
11034 map.virq = bp->irq_tbl[i - 1].vector; in bnxt_change_msix()
11035 pci_msix_free_irq(bp->pdev, map); in bnxt_change_msix()
11036 bp->total_irqs--; in bnxt_change_msix()
11038 return bp->total_irqs; in bnxt_change_msix()
11045 if (!bp->irq_tbl) { in bnxt_setup_int_mode()
11047 if (rc || !bp->irq_tbl) in bnxt_setup_int_mode()
11048 return rc ?: -ENODEV; in bnxt_setup_int_mode()
11059 return bp->hw_resc.max_rsscos_ctxs; in bnxt_get_max_func_rss_ctxs()
11064 return bp->hw_resc.max_vnics; in bnxt_get_max_func_vnics()
11069 return bp->hw_resc.max_stat_ctxs; in bnxt_get_max_func_stat_ctxs()
11074 return bp->hw_resc.max_cp_rings; in bnxt_get_max_func_cp_rings()
11079 unsigned int cp = bp->hw_resc.max_cp_rings; in bnxt_get_max_func_cp_rings_for_en()
11081 if (!(bp->flags & BNXT_FLAG_CHIP_P5_PLUS)) in bnxt_get_max_func_cp_rings_for_en()
11082 cp -= bnxt_get_ulp_msix_num(bp); in bnxt_get_max_func_cp_rings_for_en()
11089 struct bnxt_hw_resc *hw_resc = &bp->hw_resc; in bnxt_get_max_func_irqs()
11091 if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) in bnxt_get_max_func_irqs()
11092 return min_t(unsigned int, hw_resc->max_irqs, hw_resc->max_nqs); in bnxt_get_max_func_irqs()
11094 return min_t(unsigned int, hw_resc->max_irqs, hw_resc->max_cp_rings); in bnxt_get_max_func_irqs()
11099 bp->hw_resc.max_irqs = max_irqs; in bnxt_set_max_func_irqs()
11107 if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) in bnxt_get_avail_cp_rings_for_en()
11108 return cp - bp->rx_nr_rings - bp->tx_nr_rings; in bnxt_get_avail_cp_rings_for_en()
11110 return cp - bp->cp_nr_rings; in bnxt_get_avail_cp_rings_for_en()
11115 return bnxt_get_max_func_stat_ctxs(bp) - bnxt_get_func_stat_ctxs(bp); in bnxt_get_avail_stat_ctxs_for_en()
11121 int total_req = bp->cp_nr_rings + num; in bnxt_get_avail_msix()
11124 num = max_irq - bp->cp_nr_rings; in bnxt_get_avail_msix()
11151 if (!(bp->flags & BNXT_FLAG_SHARED_RINGS)) in bnxt_init_int_mode()
11154 total_vecs = pci_alloc_irq_vectors(bp->pdev, min, total_vecs, in bnxt_init_int_mode()
11158 rc = -ENODEV; in bnxt_init_int_mode()
11163 if (pci_msix_can_alloc_dyn(bp->pdev)) in bnxt_init_int_mode()
11165 bp->irq_tbl = kcalloc(tbl_size, sizeof(*bp->irq_tbl), GFP_KERNEL); in bnxt_init_int_mode()
11166 if (bp->irq_tbl) { in bnxt_init_int_mode()
11168 bp->irq_tbl[i].vector = pci_irq_vector(bp->pdev, i); in bnxt_init_int_mode()
11170 bp->total_irqs = total_vecs; in bnxt_init_int_mode()
11172 rc = bnxt_trim_rings(bp, &bp->rx_nr_rings, &bp->tx_nr_rings, in bnxt_init_int_mode()
11173 total_vecs - ulp_msix, min == 1); in bnxt_init_int_mode()
11177 tx_cp = bnxt_num_tx_to_cp(bp, bp->tx_nr_rings); in bnxt_init_int_mode()
11178 bp->cp_nr_rings = (min == 1) ? in bnxt_init_int_mode()
11179 max_t(int, tx_cp, bp->rx_nr_rings) : in bnxt_init_int_mode()
11180 tx_cp + bp->rx_nr_rings; in bnxt_init_int_mode()
11183 rc = -ENOMEM; in bnxt_init_int_mode()
11189 netdev_err(bp->dev, "bnxt_init_int_mode err: %x\n", rc); in bnxt_init_int_mode()
11190 kfree(bp->irq_tbl); in bnxt_init_int_mode()
11191 bp->irq_tbl = NULL; in bnxt_init_int_mode()
11192 pci_free_irq_vectors(bp->pdev); in bnxt_init_int_mode()
11198 pci_free_irq_vectors(bp->pdev); in bnxt_clear_int_mode()
11200 kfree(bp->irq_tbl); in bnxt_clear_int_mode()
11201 bp->irq_tbl = NULL; in bnxt_clear_int_mode()
11208 int tcs = bp->num_tc; in bnxt_reserve_rings()
11215 if (BNXT_NEW_RM(bp) && !bnxt_ulp_registered(bp->edev)) { in bnxt_reserve_rings()
11216 int ulp_msix = bnxt_get_avail_msix(bp, bp->ulp_num_msix_want); in bnxt_reserve_rings()
11218 if (ulp_msix > bp->ulp_num_msix_want) in bnxt_reserve_rings()
11219 ulp_msix = bp->ulp_num_msix_want; in bnxt_reserve_rings()
11220 irqs_required = ulp_msix + bp->cp_nr_rings; in bnxt_reserve_rings()
11225 if (irq_re_init && BNXT_NEW_RM(bp) && irqs_required != bp->total_irqs) { in bnxt_reserve_rings()
11227 if (!pci_msix_can_alloc_dyn(bp->pdev)) { in bnxt_reserve_rings()
11240 rc = -ENOSPC; in bnxt_reserve_rings()
11243 netdev_err(bp->dev, "ring reservation/IRQ init failure rc: %d\n", rc); in bnxt_reserve_rings()
11246 if (tcs && (bp->tx_nr_rings_per_tc * tcs != in bnxt_reserve_rings()
11247 bp->tx_nr_rings - bp->tx_nr_rings_xdp)) { in bnxt_reserve_rings()
11248 netdev_err(bp->dev, "tx ring reservation failure\n"); in bnxt_reserve_rings()
11249 netdev_reset_tc(bp->dev); in bnxt_reserve_rings()
11250 bp->num_tc = 0; in bnxt_reserve_rings()
11251 if (bp->tx_nr_rings_xdp) in bnxt_reserve_rings()
11252 bp->tx_nr_rings_per_tc = bp->tx_nr_rings_xdp; in bnxt_reserve_rings()
11254 bp->tx_nr_rings_per_tc = bp->tx_nr_rings; in bnxt_reserve_rings()
11255 return -ENOMEM; in bnxt_reserve_rings()
11266 free_irq_cpu_rmap(bp->dev->rx_cpu_rmap); in bnxt_free_irq()
11267 bp->dev->rx_cpu_rmap = NULL; in bnxt_free_irq()
11269 if (!bp->irq_tbl || !bp->bnapi) in bnxt_free_irq()
11272 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_free_irq()
11275 irq = &bp->irq_tbl[map_idx]; in bnxt_free_irq()
11276 if (irq->requested) { in bnxt_free_irq()
11277 if (irq->have_cpumask) { in bnxt_free_irq()
11278 irq_update_affinity_hint(irq->vector, NULL); in bnxt_free_irq()
11279 free_cpumask_var(irq->cpu_mask); in bnxt_free_irq()
11280 irq->have_cpumask = 0; in bnxt_free_irq()
11282 free_irq(irq->vector, bp->bnapi[i]); in bnxt_free_irq()
11285 irq->requested = 0; in bnxt_free_irq()
11299 netdev_err(bp->dev, "bnxt_setup_int_mode err: %x\n", in bnxt_request_irq()
11304 rmap = bp->dev->rx_cpu_rmap; in bnxt_request_irq()
11306 for (i = 0, j = 0; i < bp->cp_nr_rings; i++) { in bnxt_request_irq()
11308 struct bnxt_irq *irq = &bp->irq_tbl[map_idx]; in bnxt_request_irq()
11311 if (rmap && bp->bnapi[i]->rx_ring) { in bnxt_request_irq()
11312 rc = irq_cpu_rmap_add(rmap, irq->vector); in bnxt_request_irq()
11314 netdev_warn(bp->dev, "failed adding irq rmap for ring %d\n", in bnxt_request_irq()
11319 rc = request_irq(irq->vector, irq->handler, flags, irq->name, in bnxt_request_irq()
11320 bp->bnapi[i]); in bnxt_request_irq()
11324 netif_napi_set_irq(&bp->bnapi[i]->napi, irq->vector); in bnxt_request_irq()
11325 irq->requested = 1; in bnxt_request_irq()
11327 if (zalloc_cpumask_var(&irq->cpu_mask, GFP_KERNEL)) { in bnxt_request_irq()
11328 int numa_node = dev_to_node(&bp->pdev->dev); in bnxt_request_irq()
11330 irq->have_cpumask = 1; in bnxt_request_irq()
11332 irq->cpu_mask); in bnxt_request_irq()
11333 rc = irq_update_affinity_hint(irq->vector, irq->cpu_mask); in bnxt_request_irq()
11335 netdev_warn(bp->dev, in bnxt_request_irq()
11337 irq->vector); in bnxt_request_irq()
11349 if (!bp->bnapi) in bnxt_del_napi()
11352 for (i = 0; i < bp->rx_nr_rings; i++) in bnxt_del_napi()
11353 netif_queue_set_napi(bp->dev, i, NETDEV_QUEUE_TYPE_RX, NULL); in bnxt_del_napi()
11354 for (i = 0; i < bp->tx_nr_rings - bp->tx_nr_rings_xdp; i++) in bnxt_del_napi()
11355 netif_queue_set_napi(bp->dev, i, NETDEV_QUEUE_TYPE_TX, NULL); in bnxt_del_napi()
11357 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_del_napi()
11358 struct bnxt_napi *bnapi = bp->bnapi[i]; in bnxt_del_napi()
11360 __netif_napi_del(&bnapi->napi); in bnxt_del_napi()
11371 unsigned int cp_nr_rings = bp->cp_nr_rings; in bnxt_init_napi()
11375 if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) in bnxt_init_napi()
11378 cp_nr_rings--; in bnxt_init_napi()
11380 bnapi = bp->bnapi[i]; in bnxt_init_napi()
11381 netif_napi_add_config(bp->dev, &bnapi->napi, poll_fn, in bnxt_init_napi()
11382 bnapi->index); in bnxt_init_napi()
11385 bnapi = bp->bnapi[cp_nr_rings]; in bnxt_init_napi()
11386 netif_napi_add(bp->dev, &bnapi->napi, bnxt_poll_nitroa0); in bnxt_init_napi()
11394 if (!bp->bnapi || in bnxt_disable_napi()
11395 test_and_set_bit(BNXT_STATE_NAPI_DISABLED, &bp->state)) in bnxt_disable_napi()
11398 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_disable_napi()
11399 struct bnxt_napi *bnapi = bp->bnapi[i]; in bnxt_disable_napi()
11402 cpr = &bnapi->cp_ring; in bnxt_disable_napi()
11403 if (bnapi->tx_fault) in bnxt_disable_napi()
11404 cpr->sw_stats->tx.tx_resets++; in bnxt_disable_napi()
11405 if (bnapi->in_reset) in bnxt_disable_napi()
11406 cpr->sw_stats->rx.rx_resets++; in bnxt_disable_napi()
11407 napi_disable(&bnapi->napi); in bnxt_disable_napi()
11415 clear_bit(BNXT_STATE_NAPI_DISABLED, &bp->state); in bnxt_enable_napi()
11416 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_enable_napi()
11417 struct bnxt_napi *bnapi = bp->bnapi[i]; in bnxt_enable_napi()
11420 bnapi->tx_fault = 0; in bnxt_enable_napi()
11422 cpr = &bnapi->cp_ring; in bnxt_enable_napi()
11423 bnapi->in_reset = false; in bnxt_enable_napi()
11425 if (bnapi->rx_ring) { in bnxt_enable_napi()
11426 INIT_WORK(&cpr->dim.work, bnxt_dim_work); in bnxt_enable_napi()
11427 cpr->dim.mode = DIM_CQ_PERIOD_MODE_START_FROM_EQE; in bnxt_enable_napi()
11429 napi_enable(&bnapi->napi); in bnxt_enable_napi()
11438 if (bp->tx_ring) { in bnxt_tx_disable()
11439 for (i = 0; i < bp->tx_nr_rings; i++) { in bnxt_tx_disable()
11440 txr = &bp->tx_ring[i]; in bnxt_tx_disable()
11441 WRITE_ONCE(txr->dev_state, BNXT_DEV_STATE_CLOSING); in bnxt_tx_disable()
11447 netif_carrier_off(bp->dev); in bnxt_tx_disable()
11449 netif_tx_disable(bp->dev); in bnxt_tx_disable()
11457 for (i = 0; i < bp->tx_nr_rings; i++) { in bnxt_tx_enable()
11458 txr = &bp->tx_ring[i]; in bnxt_tx_enable()
11459 WRITE_ONCE(txr->dev_state, 0); in bnxt_tx_enable()
11463 netif_tx_wake_all_queues(bp->dev); in bnxt_tx_enable()
11465 netif_carrier_on(bp->dev); in bnxt_tx_enable()
11470 u8 active_fec = link_info->active_fec_sig_mode & in bnxt_report_fec()
11501 netif_carrier_on(bp->dev); in bnxt_report_link()
11502 speed = bnxt_fw_to_ethtool_speed(bp->link_info.link_speed); in bnxt_report_link()
11504 netdev_info(bp->dev, "NIC Link is Up, speed unknown\n"); in bnxt_report_link()
11507 if (bp->link_info.duplex == BNXT_LINK_DUPLEX_FULL) in bnxt_report_link()
11511 if (bp->link_info.pause == BNXT_LINK_PAUSE_BOTH) in bnxt_report_link()
11512 flow_ctrl = "ON - receive & transmit"; in bnxt_report_link()
11513 else if (bp->link_info.pause == BNXT_LINK_PAUSE_TX) in bnxt_report_link()
11514 flow_ctrl = "ON - transmit"; in bnxt_report_link()
11515 else if (bp->link_info.pause == BNXT_LINK_PAUSE_RX) in bnxt_report_link()
11516 flow_ctrl = "ON - receive"; in bnxt_report_link()
11519 if (bp->link_info.phy_qcfg_resp.option_flags & in bnxt_report_link()
11521 u8 sig_mode = bp->link_info.active_fec_sig_mode & in bnxt_report_link()
11537 netdev_info(bp->dev, "NIC Link is Up, %u Mbps %s%s duplex, Flow control: %s\n", in bnxt_report_link()
11539 if (bp->phy_flags & BNXT_PHY_FL_EEE_CAP) in bnxt_report_link()
11540 netdev_info(bp->dev, "EEE is %s\n", in bnxt_report_link()
11541 bp->eee.eee_active ? "active" : in bnxt_report_link()
11543 fec = bp->link_info.fec_cfg; in bnxt_report_link()
11545 netdev_info(bp->dev, "FEC autoneg %s encoding: %s\n", in bnxt_report_link()
11547 bnxt_report_fec(&bp->link_info)); in bnxt_report_link()
11549 netif_carrier_off(bp->dev); in bnxt_report_link()
11550 netdev_err(bp->dev, "NIC Link is Down\n"); in bnxt_report_link()
11556 if (!resp->supported_speeds_auto_mode && in bnxt_phy_qcaps_no_speed()
11557 !resp->supported_speeds_force_mode && in bnxt_phy_qcaps_no_speed()
11558 !resp->supported_pam4_speeds_auto_mode && in bnxt_phy_qcaps_no_speed()
11559 !resp->supported_pam4_speeds_force_mode && in bnxt_phy_qcaps_no_speed()
11560 !resp->supported_speeds2_auto_mode && in bnxt_phy_qcaps_no_speed()
11561 !resp->supported_speeds2_force_mode) in bnxt_phy_qcaps_no_speed()
11568 struct bnxt_link_info *link_info = &bp->link_info; in bnxt_hwrm_phy_qcaps()
11573 if (bp->hwrm_spec_code < 0x10201) in bnxt_hwrm_phy_qcaps()
11585 bp->phy_flags = resp->flags | (le16_to_cpu(resp->flags2) << 8); in bnxt_hwrm_phy_qcaps()
11586 if (resp->flags & PORT_PHY_QCAPS_RESP_FLAGS_EEE_SUPPORTED) { in bnxt_hwrm_phy_qcaps()
11587 struct ethtool_keee *eee = &bp->eee; in bnxt_hwrm_phy_qcaps()
11588 u16 fw_speeds = le16_to_cpu(resp->supported_speeds_eee_mode); in bnxt_hwrm_phy_qcaps()
11590 _bnxt_fw_to_linkmode(eee->supported, fw_speeds); in bnxt_hwrm_phy_qcaps()
11591 bp->lpi_tmr_lo = le32_to_cpu(resp->tx_lpi_timer_low) & in bnxt_hwrm_phy_qcaps()
11593 bp->lpi_tmr_hi = le32_to_cpu(resp->valid_tx_lpi_timer_high) & in bnxt_hwrm_phy_qcaps()
11597 if (bp->hwrm_spec_code >= 0x10a01) { in bnxt_hwrm_phy_qcaps()
11599 link_info->phy_state = BNXT_PHY_STATE_DISABLED; in bnxt_hwrm_phy_qcaps()
11600 netdev_warn(bp->dev, "Ethernet link disabled\n"); in bnxt_hwrm_phy_qcaps()
11601 } else if (link_info->phy_state == BNXT_PHY_STATE_DISABLED) { in bnxt_hwrm_phy_qcaps()
11602 link_info->phy_state = BNXT_PHY_STATE_ENABLED; in bnxt_hwrm_phy_qcaps()
11603 netdev_info(bp->dev, "Ethernet link enabled\n"); in bnxt_hwrm_phy_qcaps()
11604 /* Phy re-enabled, reprobe the speeds */ in bnxt_hwrm_phy_qcaps()
11605 link_info->support_auto_speeds = 0; in bnxt_hwrm_phy_qcaps()
11606 link_info->support_pam4_auto_speeds = 0; in bnxt_hwrm_phy_qcaps()
11607 link_info->support_auto_speeds2 = 0; in bnxt_hwrm_phy_qcaps()
11610 if (resp->supported_speeds_auto_mode) in bnxt_hwrm_phy_qcaps()
11611 link_info->support_auto_speeds = in bnxt_hwrm_phy_qcaps()
11612 le16_to_cpu(resp->supported_speeds_auto_mode); in bnxt_hwrm_phy_qcaps()
11613 if (resp->supported_pam4_speeds_auto_mode) in bnxt_hwrm_phy_qcaps()
11614 link_info->support_pam4_auto_speeds = in bnxt_hwrm_phy_qcaps()
11615 le16_to_cpu(resp->supported_pam4_speeds_auto_mode); in bnxt_hwrm_phy_qcaps()
11616 if (resp->supported_speeds2_auto_mode) in bnxt_hwrm_phy_qcaps()
11617 link_info->support_auto_speeds2 = in bnxt_hwrm_phy_qcaps()
11618 le16_to_cpu(resp->supported_speeds2_auto_mode); in bnxt_hwrm_phy_qcaps()
11620 bp->port_count = resp->port_cnt; in bnxt_hwrm_phy_qcaps()
11633 if (bp->hwrm_spec_code < 0x10a03) in bnxt_hwrm_mac_qcaps()
11643 bp->mac_flags = resp->flags; in bnxt_hwrm_mac_qcaps()
11661 if (bp->phy_flags & BNXT_PHY_FL_SPEEDS2) { in bnxt_support_speed_dropped()
11662 if (bnxt_support_dropped(link_info->advertising, in bnxt_support_speed_dropped()
11663 link_info->support_auto_speeds2)) { in bnxt_support_speed_dropped()
11664 link_info->advertising = link_info->support_auto_speeds2; in bnxt_support_speed_dropped()
11669 if (bnxt_support_dropped(link_info->advertising, in bnxt_support_speed_dropped()
11670 link_info->support_auto_speeds)) { in bnxt_support_speed_dropped()
11671 link_info->advertising = link_info->support_auto_speeds; in bnxt_support_speed_dropped()
11674 if (bnxt_support_dropped(link_info->advertising_pam4, in bnxt_support_speed_dropped()
11675 link_info->support_pam4_auto_speeds)) { in bnxt_support_speed_dropped()
11676 link_info->advertising_pam4 = link_info->support_pam4_auto_speeds; in bnxt_support_speed_dropped()
11684 struct bnxt_link_info *link_info = &bp->link_info; in bnxt_update_link()
11687 u8 link_state = link_info->link_state; in bnxt_update_link()
11699 if (BNXT_VF(bp) && rc == -ENODEV) { in bnxt_update_link()
11700 netdev_warn(bp->dev, "Cannot obtain link state while PF unavailable.\n"); in bnxt_update_link()
11706 memcpy(&link_info->phy_qcfg_resp, resp, sizeof(*resp)); in bnxt_update_link()
11707 link_info->phy_link_status = resp->link; in bnxt_update_link()
11708 link_info->duplex = resp->duplex_cfg; in bnxt_update_link()
11709 if (bp->hwrm_spec_code >= 0x10800) in bnxt_update_link()
11710 link_info->duplex = resp->duplex_state; in bnxt_update_link()
11711 link_info->pause = resp->pause; in bnxt_update_link()
11712 link_info->auto_mode = resp->auto_mode; in bnxt_update_link()
11713 link_info->auto_pause_setting = resp->auto_pause; in bnxt_update_link()
11714 link_info->lp_pause = resp->link_partner_adv_pause; in bnxt_update_link()
11715 link_info->force_pause_setting = resp->force_pause; in bnxt_update_link()
11716 link_info->duplex_setting = resp->duplex_cfg; in bnxt_update_link()
11717 if (link_info->phy_link_status == BNXT_LINK_LINK) { in bnxt_update_link()
11718 link_info->link_speed = le16_to_cpu(resp->link_speed); in bnxt_update_link()
11719 if (bp->phy_flags & BNXT_PHY_FL_SPEEDS2) in bnxt_update_link()
11720 link_info->active_lanes = resp->active_lanes; in bnxt_update_link()
11722 link_info->link_speed = 0; in bnxt_update_link()
11723 link_info->active_lanes = 0; in bnxt_update_link()
11725 link_info->force_link_speed = le16_to_cpu(resp->force_link_speed); in bnxt_update_link()
11726 link_info->force_pam4_link_speed = in bnxt_update_link()
11727 le16_to_cpu(resp->force_pam4_link_speed); in bnxt_update_link()
11728 link_info->force_link_speed2 = le16_to_cpu(resp->force_link_speeds2); in bnxt_update_link()
11729 link_info->support_speeds = le16_to_cpu(resp->support_speeds); in bnxt_update_link()
11730 link_info->support_pam4_speeds = le16_to_cpu(resp->support_pam4_speeds); in bnxt_update_link()
11731 link_info->support_speeds2 = le16_to_cpu(resp->support_speeds2); in bnxt_update_link()
11732 link_info->auto_link_speeds = le16_to_cpu(resp->auto_link_speed_mask); in bnxt_update_link()
11733 link_info->auto_pam4_link_speeds = in bnxt_update_link()
11734 le16_to_cpu(resp->auto_pam4_link_speed_mask); in bnxt_update_link()
11735 link_info->auto_link_speeds2 = le16_to_cpu(resp->auto_link_speeds2); in bnxt_update_link()
11736 link_info->lp_auto_link_speeds = in bnxt_update_link()
11737 le16_to_cpu(resp->link_partner_adv_speeds); in bnxt_update_link()
11738 link_info->lp_auto_pam4_link_speeds = in bnxt_update_link()
11739 resp->link_partner_pam4_adv_speeds; in bnxt_update_link()
11740 link_info->preemphasis = le32_to_cpu(resp->preemphasis); in bnxt_update_link()
11741 link_info->phy_ver[0] = resp->phy_maj; in bnxt_update_link()
11742 link_info->phy_ver[1] = resp->phy_min; in bnxt_update_link()
11743 link_info->phy_ver[2] = resp->phy_bld; in bnxt_update_link()
11744 link_info->media_type = resp->media_type; in bnxt_update_link()
11745 link_info->phy_type = resp->phy_type; in bnxt_update_link()
11746 link_info->transceiver = resp->xcvr_pkg_type; in bnxt_update_link()
11747 link_info->phy_addr = resp->eee_config_phy_addr & in bnxt_update_link()
11749 link_info->module_status = resp->module_status; in bnxt_update_link()
11751 if (bp->phy_flags & BNXT_PHY_FL_EEE_CAP) { in bnxt_update_link()
11752 struct ethtool_keee *eee = &bp->eee; in bnxt_update_link()
11755 eee->eee_active = 0; in bnxt_update_link()
11756 if (resp->eee_config_phy_addr & in bnxt_update_link()
11758 eee->eee_active = 1; in bnxt_update_link()
11760 resp->link_partner_adv_eee_link_speed_mask); in bnxt_update_link()
11761 _bnxt_fw_to_linkmode(eee->lp_advertised, fw_speeds); in bnxt_update_link()
11766 if (resp->eee_config_phy_addr & in bnxt_update_link()
11768 eee->eee_enabled = 1; in bnxt_update_link()
11770 fw_speeds = le16_to_cpu(resp->adv_eee_link_speed_mask); in bnxt_update_link()
11771 _bnxt_fw_to_linkmode(eee->advertised, fw_speeds); in bnxt_update_link()
11773 if (resp->eee_config_phy_addr & in bnxt_update_link()
11777 eee->tx_lpi_enabled = 1; in bnxt_update_link()
11778 tmr = resp->xcvr_identifier_type_tx_lpi_timer; in bnxt_update_link()
11779 eee->tx_lpi_timer = le32_to_cpu(tmr) & in bnxt_update_link()
11785 link_info->fec_cfg = PORT_PHY_QCFG_RESP_FEC_CFG_FEC_NONE_SUPPORTED; in bnxt_update_link()
11786 if (bp->hwrm_spec_code >= 0x10504) { in bnxt_update_link()
11787 link_info->fec_cfg = le16_to_cpu(resp->fec_cfg); in bnxt_update_link()
11788 link_info->active_fec_sig_mode = resp->active_fec_signal_mode; in bnxt_update_link()
11792 if (link_info->phy_link_status == BNXT_LINK_LINK) in bnxt_update_link()
11793 link_info->link_state = BNXT_LINK_STATE_UP; in bnxt_update_link()
11795 link_info->link_state = BNXT_LINK_STATE_DOWN; in bnxt_update_link()
11796 if (link_state != link_info->link_state) in bnxt_update_link()
11800 link_info->link_state = BNXT_LINK_STATE_DOWN; in bnxt_update_link()
11808 if (support_changed && (link_info->autoneg & BNXT_AUTONEG_SPEED)) in bnxt_update_link()
11815 struct bnxt_link_info *link_info = &bp->link_info; in bnxt_get_port_module_status()
11816 struct hwrm_port_phy_qcfg_output *resp = &link_info->phy_qcfg_resp; in bnxt_get_port_module_status()
11822 module_status = link_info->module_status; in bnxt_get_port_module_status()
11827 netdev_warn(bp->dev, "Unqualified SFP+ module detected on port %d\n", in bnxt_get_port_module_status()
11828 bp->pf.port_id); in bnxt_get_port_module_status()
11829 if (bp->hwrm_spec_code >= 0x10201) { in bnxt_get_port_module_status()
11830 netdev_warn(bp->dev, "Module part number %s\n", in bnxt_get_port_module_status()
11831 resp->phy_vendor_partnumber); in bnxt_get_port_module_status()
11834 netdev_warn(bp->dev, "TX is disabled\n"); in bnxt_get_port_module_status()
11836 netdev_warn(bp->dev, "SFP+ module is shutdown\n"); in bnxt_get_port_module_status()
11843 if (bp->link_info.autoneg & BNXT_AUTONEG_FLOW_CTRL) { in bnxt_hwrm_set_pause_common()
11844 if (bp->hwrm_spec_code >= 0x10201) in bnxt_hwrm_set_pause_common()
11845 req->auto_pause = in bnxt_hwrm_set_pause_common()
11847 if (bp->link_info.req_flow_ctrl & BNXT_LINK_PAUSE_RX) in bnxt_hwrm_set_pause_common()
11848 req->auto_pause |= PORT_PHY_CFG_REQ_AUTO_PAUSE_RX; in bnxt_hwrm_set_pause_common()
11849 if (bp->link_info.req_flow_ctrl & BNXT_LINK_PAUSE_TX) in bnxt_hwrm_set_pause_common()
11850 req->auto_pause |= PORT_PHY_CFG_REQ_AUTO_PAUSE_TX; in bnxt_hwrm_set_pause_common()
11851 req->enables |= in bnxt_hwrm_set_pause_common()
11854 if (bp->link_info.req_flow_ctrl & BNXT_LINK_PAUSE_RX) in bnxt_hwrm_set_pause_common()
11855 req->force_pause |= PORT_PHY_CFG_REQ_FORCE_PAUSE_RX; in bnxt_hwrm_set_pause_common()
11856 if (bp->link_info.req_flow_ctrl & BNXT_LINK_PAUSE_TX) in bnxt_hwrm_set_pause_common()
11857 req->force_pause |= PORT_PHY_CFG_REQ_FORCE_PAUSE_TX; in bnxt_hwrm_set_pause_common()
11858 req->enables |= in bnxt_hwrm_set_pause_common()
11860 if (bp->hwrm_spec_code >= 0x10201) { in bnxt_hwrm_set_pause_common()
11861 req->auto_pause = req->force_pause; in bnxt_hwrm_set_pause_common()
11862 req->enables |= cpu_to_le32( in bnxt_hwrm_set_pause_common()
11870 if (bp->link_info.autoneg & BNXT_AUTONEG_SPEED) { in bnxt_hwrm_set_link_common()
11871 req->auto_mode |= PORT_PHY_CFG_REQ_AUTO_MODE_SPEED_MASK; in bnxt_hwrm_set_link_common()
11872 if (bp->phy_flags & BNXT_PHY_FL_SPEEDS2) { in bnxt_hwrm_set_link_common()
11873 req->enables |= in bnxt_hwrm_set_link_common()
11875 req->auto_link_speeds2_mask = cpu_to_le16(bp->link_info.advertising); in bnxt_hwrm_set_link_common()
11876 } else if (bp->link_info.advertising) { in bnxt_hwrm_set_link_common()
11877 req->enables |= cpu_to_le32(PORT_PHY_CFG_REQ_ENABLES_AUTO_LINK_SPEED_MASK); in bnxt_hwrm_set_link_common()
11878 req->auto_link_speed_mask = cpu_to_le16(bp->link_info.advertising); in bnxt_hwrm_set_link_common()
11880 if (bp->link_info.advertising_pam4) { in bnxt_hwrm_set_link_common()
11881 req->enables |= in bnxt_hwrm_set_link_common()
11883 req->auto_link_pam4_speed_mask = in bnxt_hwrm_set_link_common()
11884 cpu_to_le16(bp->link_info.advertising_pam4); in bnxt_hwrm_set_link_common()
11886 req->enables |= cpu_to_le32(PORT_PHY_CFG_REQ_ENABLES_AUTO_MODE); in bnxt_hwrm_set_link_common()
11887 req->flags |= cpu_to_le32(PORT_PHY_CFG_REQ_FLAGS_RESTART_AUTONEG); in bnxt_hwrm_set_link_common()
11889 req->flags |= cpu_to_le32(PORT_PHY_CFG_REQ_FLAGS_FORCE); in bnxt_hwrm_set_link_common()
11890 if (bp->phy_flags & BNXT_PHY_FL_SPEEDS2) { in bnxt_hwrm_set_link_common()
11891 req->force_link_speeds2 = cpu_to_le16(bp->link_info.req_link_speed); in bnxt_hwrm_set_link_common()
11892 req->enables |= cpu_to_le32(PORT_PHY_CFG_REQ_ENABLES_FORCE_LINK_SPEEDS2); in bnxt_hwrm_set_link_common()
11893 netif_info(bp, link, bp->dev, "Forcing FW speed2: %d\n", in bnxt_hwrm_set_link_common()
11894 (u32)bp->link_info.req_link_speed); in bnxt_hwrm_set_link_common()
11895 } else if (bp->link_info.req_signal_mode == BNXT_SIG_MODE_PAM4) { in bnxt_hwrm_set_link_common()
11896 req->force_pam4_link_speed = cpu_to_le16(bp->link_info.req_link_speed); in bnxt_hwrm_set_link_common()
11897 req->enables |= cpu_to_le32(PORT_PHY_CFG_REQ_ENABLES_FORCE_PAM4_LINK_SPEED); in bnxt_hwrm_set_link_common()
11899 req->force_link_speed = cpu_to_le16(bp->link_info.req_link_speed); in bnxt_hwrm_set_link_common()
11904 req->flags |= cpu_to_le32(PORT_PHY_CFG_REQ_FLAGS_RESET_PHY); in bnxt_hwrm_set_link_common()
11918 if ((bp->link_info.autoneg & BNXT_AUTONEG_FLOW_CTRL) || in bnxt_hwrm_set_pause()
11919 bp->link_info.force_link_chng) in bnxt_hwrm_set_pause()
11923 if (!rc && !(bp->link_info.autoneg & BNXT_AUTONEG_FLOW_CTRL)) { in bnxt_hwrm_set_pause()
11928 bp->link_info.pause = in bnxt_hwrm_set_pause()
11929 bp->link_info.force_pause_setting = bp->link_info.req_flow_ctrl; in bnxt_hwrm_set_pause()
11930 bp->link_info.auto_pause_setting = 0; in bnxt_hwrm_set_pause()
11931 if (!bp->link_info.force_link_chng) in bnxt_hwrm_set_pause()
11934 bp->link_info.force_link_chng = false; in bnxt_hwrm_set_pause()
11941 struct ethtool_keee *eee = &bp->eee; in bnxt_hwrm_set_eee()
11943 if (eee->eee_enabled) { in bnxt_hwrm_set_eee()
11947 if (eee->tx_lpi_enabled) in bnxt_hwrm_set_eee()
11952 req->flags |= cpu_to_le32(flags); in bnxt_hwrm_set_eee()
11953 eee_speeds = bnxt_get_fw_auto_link_speeds(eee->advertised); in bnxt_hwrm_set_eee()
11954 req->eee_link_speed_mask = cpu_to_le16(eee_speeds); in bnxt_hwrm_set_eee()
11955 req->tx_lpi_timer = cpu_to_le32(eee->tx_lpi_timer); in bnxt_hwrm_set_eee()
11957 req->flags |= cpu_to_le32(PORT_PHY_CFG_REQ_FLAGS_EEE_DISABLE); in bnxt_hwrm_set_eee()
11988 if (pci_num_vf(bp->pdev) && in bnxt_hwrm_shutdown_link()
11989 !(bp->phy_flags & BNXT_PHY_FL_FW_MANAGED_LKDN)) in bnxt_hwrm_shutdown_link()
11996 req->flags = cpu_to_le32(PORT_PHY_CFG_REQ_FLAGS_FORCE_LINK_DWN); in bnxt_hwrm_shutdown_link()
11999 mutex_lock(&bp->link_lock); in bnxt_hwrm_shutdown_link()
12005 bp->link_info.link_state = BNXT_LINK_STATE_UNKNOWN; in bnxt_hwrm_shutdown_link()
12006 mutex_unlock(&bp->link_lock); in bnxt_hwrm_shutdown_link()
12017 netdev_err(bp->dev, "Failed FW reset via OP-TEE, rc=%d\n", rc); in bnxt_fw_reset_via_optee()
12021 netdev_err(bp->dev, "OP-TEE not supported\n"); in bnxt_fw_reset_via_optee()
12022 return -ENODEV; in bnxt_fw_reset_via_optee()
12028 if (bp->fw_health && bp->fw_health->status_reliable) { in bnxt_try_recover_fw()
12039 } while (rc == -EBUSY && retry < BNXT_FW_RETRY); in bnxt_try_recover_fw()
12042 netdev_err(bp->dev, in bnxt_try_recover_fw()
12045 rc = -ENODEV; in bnxt_try_recover_fw()
12048 netdev_warn(bp->dev, "Firmware recover via OP-TEE requested\n"); in bnxt_try_recover_fw()
12054 return -ENODEV; in bnxt_try_recover_fw()
12059 struct bnxt_hw_resc *hw_resc = &bp->hw_resc; in bnxt_clear_reservations()
12064 hw_resc->resv_cp_rings = 0; in bnxt_clear_reservations()
12065 hw_resc->resv_stat_ctxs = 0; in bnxt_clear_reservations()
12066 hw_resc->resv_irqs = 0; in bnxt_clear_reservations()
12067 hw_resc->resv_tx_rings = 0; in bnxt_clear_reservations()
12068 hw_resc->resv_rx_rings = 0; in bnxt_clear_reservations()
12069 hw_resc->resv_hw_ring_grps = 0; in bnxt_clear_reservations()
12070 hw_resc->resv_vnics = 0; in bnxt_clear_reservations()
12071 hw_resc->resv_rsscos_ctxs = 0; in bnxt_clear_reservations()
12073 bp->tx_nr_rings = 0; in bnxt_clear_reservations()
12074 bp->rx_nr_rings = 0; in bnxt_clear_reservations()
12087 netdev_err(bp->dev, "resc_qcaps failed\n"); in bnxt_cancel_reservations()
12098 bool fw_reset = !bp->irq_tbl; in bnxt_hwrm_if_change()
12103 if (!(bp->fw_cap & BNXT_FW_CAP_IF_CHANGE)) in bnxt_hwrm_if_change()
12111 req->flags = cpu_to_le32(FUNC_DRV_IF_CHANGE_REQ_FLAGS_UP); in bnxt_hwrm_if_change()
12117 if (rc != -EAGAIN) in bnxt_hwrm_if_change()
12124 if (rc == -EAGAIN) { in bnxt_hwrm_if_change()
12128 flags = le32_to_cpu(resp->flags); in bnxt_hwrm_if_change()
12145 test_bit(BNXT_STATE_FW_RESET_DET, &bp->state)) in bnxt_hwrm_if_change()
12150 if (test_bit(BNXT_STATE_IN_FW_RESET, &bp->state) && !fw_reset) { in bnxt_hwrm_if_change()
12151 netdev_err(bp->dev, "RESET_DONE not set during FW reset.\n"); in bnxt_hwrm_if_change()
12152 set_bit(BNXT_STATE_ABORT_ERR, &bp->state); in bnxt_hwrm_if_change()
12153 return -ENODEV; in bnxt_hwrm_if_change()
12157 set_bit(BNXT_STATE_FW_RESET_DET, &bp->state); in bnxt_hwrm_if_change()
12158 if (!test_bit(BNXT_STATE_IN_FW_RESET, &bp->state)) in bnxt_hwrm_if_change()
12164 clear_bit(BNXT_STATE_FW_RESET_DET, &bp->state); in bnxt_hwrm_if_change()
12165 set_bit(BNXT_STATE_ABORT_ERR, &bp->state); in bnxt_hwrm_if_change()
12171 clear_bit(BNXT_STATE_FW_RESET_DET, &bp->state); in bnxt_hwrm_if_change()
12172 netdev_err(bp->dev, "init int mode failed\n"); in bnxt_hwrm_if_change()
12185 struct bnxt_pf_info *pf = &bp->pf; in bnxt_hwrm_port_led_qcaps()
12188 bp->num_leds = 0; in bnxt_hwrm_port_led_qcaps()
12189 if (BNXT_VF(bp) || bp->hwrm_spec_code < 0x10601) in bnxt_hwrm_port_led_qcaps()
12196 req->port_id = cpu_to_le16(pf->port_id); in bnxt_hwrm_port_led_qcaps()
12203 if (resp->num_leds > 0 && resp->num_leds < BNXT_MAX_LED) { in bnxt_hwrm_port_led_qcaps()
12206 bp->num_leds = resp->num_leds; in bnxt_hwrm_port_led_qcaps()
12207 memcpy(bp->leds, &resp->led0_id, sizeof(bp->leds[0]) * in bnxt_hwrm_port_led_qcaps()
12208 bp->num_leds); in bnxt_hwrm_port_led_qcaps()
12209 for (i = 0; i < bp->num_leds; i++) { in bnxt_hwrm_port_led_qcaps()
12210 struct bnxt_led_info *led = &bp->leds[i]; in bnxt_hwrm_port_led_qcaps()
12211 __le16 caps = led->led_state_caps; in bnxt_hwrm_port_led_qcaps()
12213 if (!led->led_group_id || in bnxt_hwrm_port_led_qcaps()
12215 bp->num_leds = 0; in bnxt_hwrm_port_led_qcaps()
12234 req->port_id = cpu_to_le16(bp->pf.port_id); in bnxt_hwrm_alloc_wol_fltr()
12235 req->wol_type = WOL_FILTER_ALLOC_REQ_WOL_TYPE_MAGICPKT; in bnxt_hwrm_alloc_wol_fltr()
12236 req->enables = cpu_to_le32(WOL_FILTER_ALLOC_REQ_ENABLES_MAC_ADDRESS); in bnxt_hwrm_alloc_wol_fltr()
12237 memcpy(req->mac_address, bp->dev->dev_addr, ETH_ALEN); in bnxt_hwrm_alloc_wol_fltr()
12242 bp->wol_filter_id = resp->wol_filter_id; in bnxt_hwrm_alloc_wol_fltr()
12256 req->port_id = cpu_to_le16(bp->pf.port_id); in bnxt_hwrm_free_wol_fltr()
12257 req->enables = cpu_to_le32(WOL_FILTER_FREE_REQ_ENABLES_WOL_FILTER_ID); in bnxt_hwrm_free_wol_fltr()
12258 req->wol_filter_id = bp->wol_filter_id; in bnxt_hwrm_free_wol_fltr()
12274 req->port_id = cpu_to_le16(bp->pf.port_id); in bnxt_hwrm_get_wol_fltrs()
12275 req->handle = cpu_to_le16(handle); in bnxt_hwrm_get_wol_fltrs()
12279 next_handle = le16_to_cpu(resp->next_handle); in bnxt_hwrm_get_wol_fltrs()
12281 if (resp->wol_type == in bnxt_hwrm_get_wol_fltrs()
12283 bp->wol = 1; in bnxt_hwrm_get_wol_fltrs()
12284 bp->wol_filter_id = resp->wol_filter_id; in bnxt_hwrm_get_wol_fltrs()
12296 bp->wol = 0; in bnxt_get_wol_settings()
12297 if (!BNXT_PF(bp) || !(bp->flags & BNXT_FLAG_WOL_CAP)) in bnxt_get_wol_settings()
12307 struct ethtool_keee *eee = &bp->eee; in bnxt_eee_config_ok()
12308 struct bnxt_link_info *link_info = &bp->link_info; in bnxt_eee_config_ok()
12310 if (!(bp->phy_flags & BNXT_PHY_FL_EEE_CAP)) in bnxt_eee_config_ok()
12313 if (eee->eee_enabled) { in bnxt_eee_config_ok()
12317 _bnxt_fw_to_linkmode(advertising, link_info->advertising); in bnxt_eee_config_ok()
12319 if (!(link_info->autoneg & BNXT_AUTONEG_SPEED)) { in bnxt_eee_config_ok()
12320 eee->eee_enabled = 0; in bnxt_eee_config_ok()
12323 if (linkmode_andnot(tmp, eee->advertised, advertising)) { in bnxt_eee_config_ok()
12324 linkmode_and(eee->advertised, advertising, in bnxt_eee_config_ok()
12325 eee->supported); in bnxt_eee_config_ok()
12338 struct bnxt_link_info *link_info = &bp->link_info; in bnxt_update_phy_setting()
12342 netdev_err(bp->dev, "failed to update link (rc: %x)\n", in bnxt_update_phy_setting()
12349 if ((link_info->autoneg & BNXT_AUTONEG_FLOW_CTRL) && in bnxt_update_phy_setting()
12350 (link_info->auto_pause_setting & BNXT_LINK_PAUSE_BOTH) != in bnxt_update_phy_setting()
12351 link_info->req_flow_ctrl) in bnxt_update_phy_setting()
12353 if (!(link_info->autoneg & BNXT_AUTONEG_FLOW_CTRL) && in bnxt_update_phy_setting()
12354 link_info->force_pause_setting != link_info->req_flow_ctrl) in bnxt_update_phy_setting()
12356 if (!(link_info->autoneg & BNXT_AUTONEG_SPEED)) { in bnxt_update_phy_setting()
12357 if (BNXT_AUTO_MODE(link_info->auto_mode)) in bnxt_update_phy_setting()
12361 if (link_info->req_duplex != link_info->duplex_setting) in bnxt_update_phy_setting()
12364 if (link_info->auto_mode == BNXT_LINK_AUTO_NONE) in bnxt_update_phy_setting()
12384 netdev_err(bp->dev, "failed to update phy setting (rc: %x)\n", in bnxt_update_phy_setting()
12398 if (test_bit(BNXT_STATE_IN_FW_RESET, &bp->state)) in bnxt_reinit_after_abort()
12399 return -EBUSY; in bnxt_reinit_after_abort()
12401 if (bp->dev->reg_state == NETREG_UNREGISTERED) in bnxt_reinit_after_abort()
12402 return -ENODEV; in bnxt_reinit_after_abort()
12409 clear_bit(BNXT_STATE_ABORT_ERR, &bp->state); in bnxt_reinit_after_abort()
12410 set_bit(BNXT_STATE_FW_RESET_DET, &bp->state); in bnxt_reinit_after_abort()
12421 if (list_empty(&fltr->list)) in bnxt_cfg_one_usr_fltr()
12424 if (fltr->type == BNXT_FLTR_TYPE_NTUPLE) { in bnxt_cfg_one_usr_fltr()
12426 l2_fltr = bp->vnic_info[BNXT_VNIC_DEFAULT].l2_filters[0]; in bnxt_cfg_one_usr_fltr()
12427 atomic_inc(&l2_fltr->refcnt); in bnxt_cfg_one_usr_fltr()
12428 ntp_fltr->l2_fltr = l2_fltr; in bnxt_cfg_one_usr_fltr()
12431 netdev_err(bp->dev, "restoring previously configured ntuple filter id %d failed\n", in bnxt_cfg_one_usr_fltr()
12432 fltr->sw_id); in bnxt_cfg_one_usr_fltr()
12434 } else if (fltr->type == BNXT_FLTR_TYPE_L2) { in bnxt_cfg_one_usr_fltr()
12438 netdev_err(bp->dev, "restoring previously configured l2 filter id %d failed\n", in bnxt_cfg_one_usr_fltr()
12439 fltr->sw_id); in bnxt_cfg_one_usr_fltr()
12448 list_for_each_entry_safe(usr_fltr, tmp, &bp->usr_fltr_list, list) in bnxt_cfg_usr_fltrs()
12454 int numa_node = dev_to_node(&bp->pdev->dev); in bnxt_set_xps_mapping()
12461 q_map = kcalloc(bp->tx_nr_rings_per_tc, sizeof(*q_map), GFP_KERNEL); in bnxt_set_xps_mapping()
12463 return -ENOMEM; in bnxt_set_xps_mapping()
12470 map_idx = i % bp->tx_nr_rings_per_tc; in bnxt_set_xps_mapping()
12477 for (q_idx = 0; q_idx < bp->dev->real_num_tx_queues; q_idx++) { in bnxt_set_xps_mapping()
12478 map_idx = q_idx % bp->tx_nr_rings_per_tc; in bnxt_set_xps_mapping()
12479 rc = netif_set_xps_queue(bp->dev, &q_map[map_idx], q_idx); in bnxt_set_xps_mapping()
12481 netdev_warn(bp->dev, "Error setting XPS for q:%d\n", in bnxt_set_xps_mapping()
12496 netif_carrier_off(bp->dev); in __bnxt_open_nic()
12501 netdev_err(bp->dev, "Failed to reserve default rings at open\n"); in __bnxt_open_nic()
12511 netdev_err(bp->dev, "bnxt_alloc_mem err: %x\n", rc); in __bnxt_open_nic()
12519 netdev_err(bp->dev, "bnxt_request_irq err: %x\n", rc); in __bnxt_open_nic()
12526 netdev_err(bp->dev, "bnxt_init_nic err: %x\n", rc); in __bnxt_open_nic()
12534 mutex_lock(&bp->link_lock); in __bnxt_open_nic()
12536 mutex_unlock(&bp->link_lock); in __bnxt_open_nic()
12538 netdev_warn(bp->dev, "failed to update phy settings\n"); in __bnxt_open_nic()
12540 bp->link_info.phy_retry = true; in __bnxt_open_nic()
12541 bp->link_info.phy_retry_expires = in __bnxt_open_nic()
12548 udp_tunnel_nic_reset_ntf(bp->dev); in __bnxt_open_nic()
12551 netdev_warn(bp->dev, "failed to set xps mapping\n"); in __bnxt_open_nic()
12554 if (bp->tx_nr_rings_xdp < num_possible_cpus()) { in __bnxt_open_nic()
12560 set_bit(BNXT_STATE_OPEN, &bp->state); in __bnxt_open_nic()
12564 mod_timer(&bp->timer, jiffies + bp->current_interval); in __bnxt_open_nic()
12566 mutex_lock(&bp->link_lock); in __bnxt_open_nic()
12568 mutex_unlock(&bp->link_lock); in __bnxt_open_nic()
12570 /* VF-reps may need to be re-opened after the PF is re-opened */ in __bnxt_open_nic()
12573 if (bp->ptp_cfg && !(bp->fw_cap & BNXT_FW_CAP_TX_TS_CMP)) in __bnxt_open_nic()
12574 WRITE_ONCE(bp->ptp_cfg->tx_avail, BNXT_MAX_TX_TS); in __bnxt_open_nic()
12597 if (test_bit(BNXT_STATE_ABORT_ERR, &bp->state)) in bnxt_open_nic()
12598 rc = -EIO; in bnxt_open_nic()
12602 netdev_err(bp->dev, "nic open fail (rc: %x)\n", rc); in bnxt_open_nic()
12603 dev_close(bp->dev); in bnxt_open_nic()
12616 if (test_bit(BNXT_STATE_ABORT_ERR, &bp->state)) { in bnxt_half_open_nic()
12617 netdev_err(bp->dev, "A previous firmware reset has not completed, aborting half open\n"); in bnxt_half_open_nic()
12618 rc = -ENODEV; in bnxt_half_open_nic()
12624 netdev_err(bp->dev, "bnxt_alloc_mem err: %x\n", rc); in bnxt_half_open_nic()
12628 set_bit(BNXT_STATE_HALF_OPEN, &bp->state); in bnxt_half_open_nic()
12631 clear_bit(BNXT_STATE_HALF_OPEN, &bp->state); in bnxt_half_open_nic()
12633 netdev_err(bp->dev, "bnxt_init_nic err: %x\n", rc); in bnxt_half_open_nic()
12641 dev_close(bp->dev); in bnxt_half_open_nic()
12654 clear_bit(BNXT_STATE_HALF_OPEN, &bp->state); in bnxt_half_close_nic()
12660 struct bnxt_pf_info *pf = &bp->pf; in bnxt_reenable_sriov()
12661 int n = pf->active_vfs; in bnxt_reenable_sriov()
12673 if (test_bit(BNXT_STATE_ABORT_ERR, &bp->state)) { in bnxt_open()
12676 if (rc == -EBUSY) in bnxt_open()
12677 netdev_err(bp->dev, "A previous firmware reset has not completed, aborting\n"); in bnxt_open()
12679 netdev_err(bp->dev, "Failed to reinitialize after aborted firmware reset\n"); in bnxt_open()
12680 return -ENODEV; in bnxt_open()
12692 if (test_and_clear_bit(BNXT_STATE_FW_RESET_DET, &bp->state)) { in bnxt_open()
12693 if (!test_bit(BNXT_STATE_IN_FW_RESET, &bp->state)) in bnxt_open()
12704 return (test_bit(BNXT_STATE_IN_SP_TASK, &bp->state) || in bnxt_drv_busy()
12705 test_bit(BNXT_STATE_READ_STATS, &bp->state)); in bnxt_drv_busy()
12714 /* Close the VF-reps before closing PF */ in __bnxt_close_nic()
12721 clear_bit(BNXT_STATE_OPEN, &bp->state); in __bnxt_close_nic()
12731 /* TODO CHIMP_FW: Link/PHY related cleanup if (link_re_init) */ in __bnxt_close_nic()
12735 del_timer_sync(&bp->timer); in __bnxt_close_nic()
12739 if (bp->bnapi && irq_re_init) { in __bnxt_close_nic()
12740 bnxt_get_ring_stats(bp, &bp->net_stats_prev); in __bnxt_close_nic()
12741 bnxt_get_ring_err_stats(bp, &bp->ring_err_stats_prev); in __bnxt_close_nic()
12752 if (test_bit(BNXT_STATE_IN_FW_RESET, &bp->state)) { in bnxt_close_nic()
12760 netdev_warn(bp->dev, "FW reset in progress during close, FW reset will be aborted\n"); in bnxt_close_nic()
12761 set_bit(BNXT_STATE_ABORT_ERR, &bp->state); in bnxt_close_nic()
12765 if (bp->sriov_cfg) { in bnxt_close_nic()
12768 rc = wait_event_interruptible_timeout(bp->sriov_cfg_wait, in bnxt_close_nic()
12769 !bp->sriov_cfg, in bnxt_close_nic()
12772 …netdev_warn(bp->dev, "timeout waiting for SRIOV config operation to complete, proceeding to close!… in bnxt_close_nic()
12774 netdev_warn(bp->dev, "SRIOV config operation interrupted, proceeding to close!\n"); in bnxt_close_nic()
12797 if (bp->hwrm_spec_code < 0x10a00) in bnxt_hwrm_port_phy_read()
12798 return -EOPNOTSUPP; in bnxt_hwrm_port_phy_read()
12804 req->port_id = cpu_to_le16(bp->pf.port_id); in bnxt_hwrm_port_phy_read()
12805 req->phy_addr = phy_addr; in bnxt_hwrm_port_phy_read()
12806 req->reg_addr = cpu_to_le16(reg & 0x1f); in bnxt_hwrm_port_phy_read()
12808 req->cl45_mdio = 1; in bnxt_hwrm_port_phy_read()
12809 req->phy_addr = mdio_phy_id_prtad(phy_addr); in bnxt_hwrm_port_phy_read()
12810 req->dev_addr = mdio_phy_id_devad(phy_addr); in bnxt_hwrm_port_phy_read()
12811 req->reg_addr = cpu_to_le16(reg); in bnxt_hwrm_port_phy_read()
12817 *val = le16_to_cpu(resp->reg_data); in bnxt_hwrm_port_phy_read()
12828 if (bp->hwrm_spec_code < 0x10a00) in bnxt_hwrm_port_phy_write()
12829 return -EOPNOTSUPP; in bnxt_hwrm_port_phy_write()
12835 req->port_id = cpu_to_le16(bp->pf.port_id); in bnxt_hwrm_port_phy_write()
12836 req->phy_addr = phy_addr; in bnxt_hwrm_port_phy_write()
12837 req->reg_addr = cpu_to_le16(reg & 0x1f); in bnxt_hwrm_port_phy_write()
12839 req->cl45_mdio = 1; in bnxt_hwrm_port_phy_write()
12840 req->phy_addr = mdio_phy_id_prtad(phy_addr); in bnxt_hwrm_port_phy_write()
12841 req->dev_addr = mdio_phy_id_devad(phy_addr); in bnxt_hwrm_port_phy_write()
12842 req->reg_addr = cpu_to_le16(reg); in bnxt_hwrm_port_phy_write()
12844 req->reg_data = cpu_to_le16(val); in bnxt_hwrm_port_phy_write()
12858 mdio->phy_id = bp->link_info.phy_addr; in bnxt_ioctl()
12865 return -EAGAIN; in bnxt_ioctl()
12867 rc = bnxt_hwrm_port_phy_read(bp, mdio->phy_id, mdio->reg_num, in bnxt_ioctl()
12869 mdio->val_out = mii_regval; in bnxt_ioctl()
12875 return -EAGAIN; in bnxt_ioctl()
12877 return bnxt_hwrm_port_phy_write(bp, mdio->phy_id, mdio->reg_num, in bnxt_ioctl()
12878 mdio->val_in); in bnxt_ioctl()
12890 return -EOPNOTSUPP; in bnxt_ioctl()
12898 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_get_ring_stats()
12899 struct bnxt_napi *bnapi = bp->bnapi[i]; in bnxt_get_ring_stats()
12900 struct bnxt_cp_ring_info *cpr = &bnapi->cp_ring; in bnxt_get_ring_stats()
12901 u64 *sw = cpr->stats.sw_stats; in bnxt_get_ring_stats()
12903 stats->rx_packets += BNXT_GET_RING_STATS64(sw, rx_ucast_pkts); in bnxt_get_ring_stats()
12904 stats->rx_packets += BNXT_GET_RING_STATS64(sw, rx_mcast_pkts); in bnxt_get_ring_stats()
12905 stats->rx_packets += BNXT_GET_RING_STATS64(sw, rx_bcast_pkts); in bnxt_get_ring_stats()
12907 stats->tx_packets += BNXT_GET_RING_STATS64(sw, tx_ucast_pkts); in bnxt_get_ring_stats()
12908 stats->tx_packets += BNXT_GET_RING_STATS64(sw, tx_mcast_pkts); in bnxt_get_ring_stats()
12909 stats->tx_packets += BNXT_GET_RING_STATS64(sw, tx_bcast_pkts); in bnxt_get_ring_stats()
12911 stats->rx_bytes += BNXT_GET_RING_STATS64(sw, rx_ucast_bytes); in bnxt_get_ring_stats()
12912 stats->rx_bytes += BNXT_GET_RING_STATS64(sw, rx_mcast_bytes); in bnxt_get_ring_stats()
12913 stats->rx_bytes += BNXT_GET_RING_STATS64(sw, rx_bcast_bytes); in bnxt_get_ring_stats()
12915 stats->tx_bytes += BNXT_GET_RING_STATS64(sw, tx_ucast_bytes); in bnxt_get_ring_stats()
12916 stats->tx_bytes += BNXT_GET_RING_STATS64(sw, tx_mcast_bytes); in bnxt_get_ring_stats()
12917 stats->tx_bytes += BNXT_GET_RING_STATS64(sw, tx_bcast_bytes); in bnxt_get_ring_stats()
12919 stats->rx_missed_errors += in bnxt_get_ring_stats()
12922 stats->multicast += BNXT_GET_RING_STATS64(sw, rx_mcast_pkts); in bnxt_get_ring_stats()
12924 stats->tx_dropped += BNXT_GET_RING_STATS64(sw, tx_error_pkts); in bnxt_get_ring_stats()
12926 stats->rx_dropped += in bnxt_get_ring_stats()
12927 cpr->sw_stats->rx.rx_netpoll_discards + in bnxt_get_ring_stats()
12928 cpr->sw_stats->rx.rx_oom_discards; in bnxt_get_ring_stats()
12935 struct rtnl_link_stats64 *prev_stats = &bp->net_stats_prev; in bnxt_add_prev_stats()
12937 stats->rx_packets += prev_stats->rx_packets; in bnxt_add_prev_stats()
12938 stats->tx_packets += prev_stats->tx_packets; in bnxt_add_prev_stats()
12939 stats->rx_bytes += prev_stats->rx_bytes; in bnxt_add_prev_stats()
12940 stats->tx_bytes += prev_stats->tx_bytes; in bnxt_add_prev_stats()
12941 stats->rx_missed_errors += prev_stats->rx_missed_errors; in bnxt_add_prev_stats()
12942 stats->multicast += prev_stats->multicast; in bnxt_add_prev_stats()
12943 stats->rx_dropped += prev_stats->rx_dropped; in bnxt_add_prev_stats()
12944 stats->tx_dropped += prev_stats->tx_dropped; in bnxt_add_prev_stats()
12952 set_bit(BNXT_STATE_READ_STATS, &bp->state); in bnxt_get_stats64()
12957 if (!test_bit(BNXT_STATE_OPEN, &bp->state)) { in bnxt_get_stats64()
12958 clear_bit(BNXT_STATE_READ_STATS, &bp->state); in bnxt_get_stats64()
12959 *stats = bp->net_stats_prev; in bnxt_get_stats64()
12966 if (bp->flags & BNXT_FLAG_PORT_STATS) { in bnxt_get_stats64()
12967 u64 *rx = bp->port_stats.sw_stats; in bnxt_get_stats64()
12968 u64 *tx = bp->port_stats.sw_stats + in bnxt_get_stats64()
12971 stats->rx_crc_errors = in bnxt_get_stats64()
12973 stats->rx_frame_errors = in bnxt_get_stats64()
12975 stats->rx_length_errors = in bnxt_get_stats64()
12979 stats->rx_errors = in bnxt_get_stats64()
12982 stats->collisions = in bnxt_get_stats64()
12984 stats->tx_fifo_errors = in bnxt_get_stats64()
12986 stats->tx_errors = BNXT_GET_TX_PORT_STATS64(tx, tx_err); in bnxt_get_stats64()
12988 clear_bit(BNXT_STATE_READ_STATS, &bp->state); in bnxt_get_stats64()
12995 struct bnxt_sw_stats *sw_stats = cpr->sw_stats; in bnxt_get_one_ring_err_stats()
12996 u64 *hw_stats = cpr->stats.sw_stats; in bnxt_get_one_ring_err_stats()
12998 stats->rx_total_l4_csum_errors += sw_stats->rx.rx_l4_csum_errors; in bnxt_get_one_ring_err_stats()
12999 stats->rx_total_resets += sw_stats->rx.rx_resets; in bnxt_get_one_ring_err_stats()
13000 stats->rx_total_buf_errors += sw_stats->rx.rx_buf_errors; in bnxt_get_one_ring_err_stats()
13001 stats->rx_total_oom_discards += sw_stats->rx.rx_oom_discards; in bnxt_get_one_ring_err_stats()
13002 stats->rx_total_netpoll_discards += sw_stats->rx.rx_netpoll_discards; in bnxt_get_one_ring_err_stats()
13003 stats->rx_total_ring_discards += in bnxt_get_one_ring_err_stats()
13005 stats->tx_total_resets += sw_stats->tx.tx_resets; in bnxt_get_one_ring_err_stats()
13006 stats->tx_total_ring_discards += in bnxt_get_one_ring_err_stats()
13008 stats->total_missed_irqs += sw_stats->cmn.missed_irqs; in bnxt_get_one_ring_err_stats()
13016 for (i = 0; i < bp->cp_nr_rings; i++) in bnxt_get_ring_err_stats()
13017 bnxt_get_one_ring_err_stats(bp, stats, &bp->bnapi[i]->cp_ring); in bnxt_get_ring_err_stats()
13022 struct bnxt_vnic_info *vnic = &bp->vnic_info[BNXT_VNIC_DEFAULT]; in bnxt_mc_list_updated()
13023 struct net_device *dev = bp->dev; in bnxt_mc_list_updated()
13033 vnic->mc_list_count = 0; in bnxt_mc_list_updated()
13036 haddr = ha->addr; in bnxt_mc_list_updated()
13037 if (!ether_addr_equal(haddr, vnic->mc_list + off)) { in bnxt_mc_list_updated()
13038 memcpy(vnic->mc_list + off, haddr, ETH_ALEN); in bnxt_mc_list_updated()
13047 if (mc_count != vnic->mc_list_count) { in bnxt_mc_list_updated()
13048 vnic->mc_list_count = mc_count; in bnxt_mc_list_updated()
13056 struct net_device *dev = bp->dev; in bnxt_uc_list_updated()
13057 struct bnxt_vnic_info *vnic = &bp->vnic_info[BNXT_VNIC_DEFAULT]; in bnxt_uc_list_updated()
13061 if (netdev_uc_count(dev) != (vnic->uc_filter_count - 1)) in bnxt_uc_list_updated()
13065 if (!ether_addr_equal(ha->addr, vnic->uc_list + off)) in bnxt_uc_list_updated()
13081 if (!test_bit(BNXT_STATE_OPEN, &bp->state)) in bnxt_set_rx_mode()
13084 vnic = &bp->vnic_info[BNXT_VNIC_DEFAULT]; in bnxt_set_rx_mode()
13085 mask = vnic->rx_mask; in bnxt_set_rx_mode()
13091 if (dev->flags & IFF_PROMISC) in bnxt_set_rx_mode()
13096 if (dev->flags & IFF_BROADCAST) in bnxt_set_rx_mode()
13098 if (dev->flags & IFF_ALLMULTI) { in bnxt_set_rx_mode()
13100 vnic->mc_list_count = 0; in bnxt_set_rx_mode()
13101 } else if (dev->flags & IFF_MULTICAST) { in bnxt_set_rx_mode()
13105 if (mask != vnic->rx_mask || uc_update || mc_update) { in bnxt_set_rx_mode()
13106 vnic->rx_mask = mask; in bnxt_set_rx_mode()
13114 struct net_device *dev = bp->dev; in bnxt_cfg_rx_mode()
13115 struct bnxt_vnic_info *vnic = &bp->vnic_info[BNXT_VNIC_DEFAULT]; in bnxt_cfg_rx_mode()
13127 for (i = 1; i < vnic->uc_filter_count; i++) { in bnxt_cfg_rx_mode()
13128 struct bnxt_l2_filter *fltr = vnic->l2_filters[i]; in bnxt_cfg_rx_mode()
13134 vnic->uc_filter_count = 1; in bnxt_cfg_rx_mode()
13137 if (netdev_uc_count(dev) > (BNXT_MAX_UC_ADDRS - 1)) { in bnxt_cfg_rx_mode()
13138 vnic->rx_mask |= CFA_L2_SET_RX_MASK_REQ_MASK_PROMISCUOUS; in bnxt_cfg_rx_mode()
13141 memcpy(vnic->uc_list + off, ha->addr, ETH_ALEN); in bnxt_cfg_rx_mode()
13143 vnic->uc_filter_count++; in bnxt_cfg_rx_mode()
13148 for (i = 1, off = 0; i < vnic->uc_filter_count; i++, off += ETH_ALEN) { in bnxt_cfg_rx_mode()
13149 rc = bnxt_hwrm_set_vnic_filter(bp, 0, i, vnic->uc_list + off); in bnxt_cfg_rx_mode()
13151 if (BNXT_VF(bp) && rc == -ENODEV) { in bnxt_cfg_rx_mode()
13152 if (!test_and_set_bit(BNXT_STATE_L2_FILTER_RETRY, &bp->state)) in bnxt_cfg_rx_mode()
13153 netdev_warn(bp->dev, "Cannot configure L2 filters while PF is unavailable, will retry\n"); in bnxt_cfg_rx_mode()
13155 netdev_dbg(bp->dev, "PF still unavailable while configuring L2 filters.\n"); in bnxt_cfg_rx_mode()
13158 netdev_err(bp->dev, "HWRM vnic filter failure rc: %x\n", rc); in bnxt_cfg_rx_mode()
13160 vnic->uc_filter_count = i; in bnxt_cfg_rx_mode()
13164 if (test_and_clear_bit(BNXT_STATE_L2_FILTER_RETRY, &bp->state)) in bnxt_cfg_rx_mode()
13165 netdev_notice(bp->dev, "Retry of L2 filter configuration successful.\n"); in bnxt_cfg_rx_mode()
13168 if ((vnic->rx_mask & CFA_L2_SET_RX_MASK_REQ_MASK_PROMISCUOUS) && in bnxt_cfg_rx_mode()
13170 vnic->rx_mask &= ~CFA_L2_SET_RX_MASK_REQ_MASK_PROMISCUOUS; in bnxt_cfg_rx_mode()
13172 if (rc && (vnic->rx_mask & CFA_L2_SET_RX_MASK_REQ_MASK_MCAST)) { in bnxt_cfg_rx_mode()
13173 netdev_info(bp->dev, "Failed setting MC filters rc: %d, turning on ALL_MCAST mode\n", in bnxt_cfg_rx_mode()
13175 vnic->rx_mask &= ~CFA_L2_SET_RX_MASK_REQ_MASK_MCAST; in bnxt_cfg_rx_mode()
13176 vnic->rx_mask |= CFA_L2_SET_RX_MASK_REQ_MASK_ALL_MCAST; in bnxt_cfg_rx_mode()
13177 vnic->mc_list_count = 0; in bnxt_cfg_rx_mode()
13181 netdev_err(bp->dev, "HWRM cfa l2 rx mask failure rc: %d\n", in bnxt_cfg_rx_mode()
13191 struct bnxt_hw_resc *hw_resc = &bp->hw_resc; in bnxt_can_reserve_rings()
13196 if (hw_resc->min_tx_rings || hw_resc->resv_tx_rings) in bnxt_can_reserve_rings()
13199 if (!netif_running(bp->dev)) in bnxt_can_reserve_rings()
13209 if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) { in bnxt_rfs_supported()
13210 if (bp->fw_cap & BNXT_FW_CAP_CFA_RFS_RING_TBL_IDX_V2) in bnxt_rfs_supported()
13219 if (bp->rss_cap & BNXT_RSS_CAP_NEW_RSS_CAP) in bnxt_rfs_supported()
13230 if ((bp->flags & BNXT_FLAG_CHIP_P5_PLUS) && in bnxt_rfs_capable()
13234 if (!bnxt_can_reserve_rings(bp) || !bp->rx_nr_rings) in bnxt_rfs_capable()
13237 hwr.grp = bp->rx_nr_rings; in bnxt_rfs_capable()
13238 hwr.vnic = bnxt_get_total_vnics(bp, bp->rx_nr_rings); in bnxt_rfs_capable()
13246 if (bp->rx_nr_rings > 1) in bnxt_rfs_capable()
13247 netdev_warn(bp->dev, in bnxt_rfs_capable()
13249 min(max_rss_ctxs - 1, max_vnics - 1)); in bnxt_rfs_capable()
13260 if (hwr.vnic <= bp->hw_resc.resv_vnics && in bnxt_rfs_capable()
13261 hwr.rss_ctx <= bp->hw_resc.resv_rsscos_ctxs) in bnxt_rfs_capable()
13265 if (hwr.vnic <= bp->hw_resc.resv_vnics && in bnxt_rfs_capable()
13266 hwr.rss_ctx <= bp->hw_resc.resv_rsscos_ctxs) in bnxt_rfs_capable()
13269 netdev_warn(bp->dev, "Unable to reserve resources to support NTUPLE filters.\n"); in bnxt_rfs_capable()
13285 if ((bp->flags & BNXT_FLAG_NO_AGG_RINGS) || bp->xdp_prog) in bnxt_fix_features()
13299 if (dev->features & BNXT_HW_FEATURE_VLAN_ALL_RX) in bnxt_fix_features()
13305 if (BNXT_VF(bp) && bp->vf.vlan) in bnxt_fix_features()
13315 bp->flags = flags; in bnxt_reinit_features()
13325 u32 flags = bp->flags; in bnxt_set_features()
13336 if (bp->flags & BNXT_FLAG_NO_AGG_RINGS) in bnxt_set_features()
13347 changes = flags ^ bp->flags; in bnxt_set_features()
13350 if ((bp->flags & BNXT_FLAG_TPA) == 0 || in bnxt_set_features()
13352 (bp->flags & BNXT_FLAG_CHIP_P5_PLUS)) in bnxt_set_features()
13362 if (flags != bp->flags) { in bnxt_set_features()
13363 u32 old_flags = bp->flags; in bnxt_set_features()
13365 if (!test_bit(BNXT_STATE_OPEN, &bp->state)) { in bnxt_set_features()
13366 bp->flags = flags; in bnxt_set_features()
13379 bp->flags = flags; in bnxt_set_features()
13384 bp->flags = old_flags; in bnxt_set_features()
13393 struct ipv6hdr *ip6h = (struct ipv6hdr *)(skb->data + nw_off); in bnxt_exthdr_check()
13403 nexthdr = &ip6h->nexthdr; in bnxt_exthdr_check()
13411 hp = __skb_header_pointer(NULL, start, sizeof(*hp), skb->data, in bnxt_exthdr_check()
13423 /* The ext header may be a hop-by-hop header inserted for in bnxt_exthdr_check()
13428 if (likely(skb->len <= GRO_LEGACY_MAX_SIZE)) in bnxt_exthdr_check()
13432 if (jhdr->tlv_type != IPV6_TLV_JUMBO || jhdr->hdrlen != 0 || in bnxt_exthdr_check()
13433 jhdr->nexthdr != IPPROTO_TCP) in bnxt_exthdr_check()
13441 nexthdr = &hp->nexthdr; in bnxt_exthdr_check()
13446 if (skb->encapsulation) { in bnxt_exthdr_check()
13452 /* Only support TCP/UDP for non-tunneled ipv6 and inner ipv6 */ in bnxt_exthdr_check()
13460 __be16 udp_port = uh->dest; in bnxt_udp_tunl_check()
13462 if (udp_port != bp->vxlan_port && udp_port != bp->nge_port && in bnxt_udp_tunl_check()
13463 udp_port != bp->vxlan_gpe_port) in bnxt_udp_tunl_check()
13465 if (skb->inner_protocol == htons(ETH_P_TEB)) { in bnxt_udp_tunl_check()
13468 switch (eh->h_proto) { in bnxt_udp_tunl_check()
13476 } else if (skb->inner_protocol == htons(ETH_P_IP)) { in bnxt_udp_tunl_check()
13478 } else if (skb->inner_protocol == htons(ETH_P_IPV6)) { in bnxt_udp_tunl_check()
13493 switch (skb->inner_protocol) { in bnxt_tunl_check()
13520 if (!skb->encapsulation) in bnxt_features_check()
13522 l4_proto = &ip_hdr(skb)->protocol; in bnxt_features_check()
13553 rc = -ENOMEM; in bnxt_dbg_hwrm_rd_reg()
13557 req->host_dest_addr = cpu_to_le64(mapping); in bnxt_dbg_hwrm_rd_reg()
13560 req->read_addr = cpu_to_le32(reg_off + CHIMP_REG_VIEW_ADDR); in bnxt_dbg_hwrm_rd_reg()
13561 req->read_len32 = cpu_to_le32(num_words); in bnxt_dbg_hwrm_rd_reg()
13564 if (rc || resp->error_code) { in bnxt_dbg_hwrm_rd_reg()
13565 rc = -EIO; in bnxt_dbg_hwrm_rd_reg()
13587 req->ring_type = ring_type; in bnxt_dbg_hwrm_ring_info_get()
13588 req->fw_ring_id = cpu_to_le32(ring_id); in bnxt_dbg_hwrm_ring_info_get()
13592 *prod = le32_to_cpu(resp->producer_index); in bnxt_dbg_hwrm_ring_info_get()
13593 *cons = le32_to_cpu(resp->consumer_index); in bnxt_dbg_hwrm_ring_info_get()
13602 int i = bnapi->index, j; in bnxt_dump_tx_sw_state()
13605 netdev_info(bnapi->bp->dev, "[%d.%d]: tx{fw_ring: %d prod: %x cons: %x}\n", in bnxt_dump_tx_sw_state()
13606 i, j, txr->tx_ring_struct.fw_ring_id, txr->tx_prod, in bnxt_dump_tx_sw_state()
13607 txr->tx_cons); in bnxt_dump_tx_sw_state()
13612 struct bnxt_rx_ring_info *rxr = bnapi->rx_ring; in bnxt_dump_rx_sw_state()
13613 int i = bnapi->index; in bnxt_dump_rx_sw_state()
13618 …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()
13619 i, rxr->rx_ring_struct.fw_ring_id, rxr->rx_prod, in bnxt_dump_rx_sw_state()
13620 rxr->rx_agg_ring_struct.fw_ring_id, rxr->rx_agg_prod, in bnxt_dump_rx_sw_state()
13621 rxr->rx_sw_agg_prod); in bnxt_dump_rx_sw_state()
13626 struct bnxt_cp_ring_info *cpr = &bnapi->cp_ring; in bnxt_dump_cp_sw_state()
13627 int i = bnapi->index; in bnxt_dump_cp_sw_state()
13629 netdev_info(bnapi->bp->dev, "[%d]: cp{fw_ring: %d raw_cons: %x}\n", in bnxt_dump_cp_sw_state()
13630 i, cpr->cp_ring_struct.fw_ring_id, cpr->cp_raw_cons); in bnxt_dump_cp_sw_state()
13638 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_dbg_dump_states()
13639 bnapi = bp->bnapi[i]; in bnxt_dbg_dump_states()
13650 struct bnxt_rx_ring_info *rxr = &bp->rx_ring[ring_nr]; in bnxt_hwrm_rx_ring_reset()
13652 struct bnxt_napi *bnapi = rxr->bnapi; in bnxt_hwrm_rx_ring_reset()
13661 cpr = &bnapi->cp_ring; in bnxt_hwrm_rx_ring_reset()
13662 cp_ring_id = cpr->cp_ring_struct.fw_ring_id; in bnxt_hwrm_rx_ring_reset()
13663 req->cmpl_ring = cpu_to_le16(cp_ring_id); in bnxt_hwrm_rx_ring_reset()
13664 req->ring_type = RING_RESET_REQ_RING_TYPE_RX_RING_GRP; in bnxt_hwrm_rx_ring_reset()
13665 req->ring_id = cpu_to_le16(bp->grp_info[bnapi->index].fw_grp_id); in bnxt_hwrm_rx_ring_reset()
13673 if (netif_running(bp->dev)) { in bnxt_reset_task()
13683 netdev_err(bp->dev, "TX timeout detected, starting reset task!\n"); in bnxt_tx_timeout()
13689 struct bnxt_fw_health *fw_health = bp->fw_health; in bnxt_fw_health_check()
13690 struct pci_dev *pdev = bp->pdev; in bnxt_fw_health_check()
13693 if (!fw_health->enabled || test_bit(BNXT_STATE_IN_FW_RESET, &bp->state)) in bnxt_fw_health_check()
13698 if (fw_health->tmr_counter) { in bnxt_fw_health_check()
13699 fw_health->tmr_counter--; in bnxt_fw_health_check()
13704 if (val == fw_health->last_fw_heartbeat && pci_device_is_present(pdev)) { in bnxt_fw_health_check()
13705 fw_health->arrests++; in bnxt_fw_health_check()
13709 fw_health->last_fw_heartbeat = val; in bnxt_fw_health_check()
13712 if (val != fw_health->last_fw_reset_cnt && pci_device_is_present(pdev)) { in bnxt_fw_health_check()
13713 fw_health->discoveries++; in bnxt_fw_health_check()
13717 fw_health->tmr_counter = fw_health->tmr_multiplier; in bnxt_fw_health_check()
13727 struct net_device *dev = bp->dev; in bnxt_timer()
13729 if (!netif_running(dev) || !test_bit(BNXT_STATE_OPEN, &bp->state)) in bnxt_timer()
13732 if (atomic_read(&bp->intr_sem) != 0) in bnxt_timer()
13735 if (bp->fw_cap & BNXT_FW_CAP_ERROR_RECOVERY) in bnxt_timer()
13738 if (BNXT_LINK_IS_UP(bp) && bp->stats_coal_ticks) in bnxt_timer()
13745 if ((bp->flags & BNXT_FLAG_RFS) && bp->ntp_fltr_count) in bnxt_timer()
13749 if (bp->link_info.phy_retry) { in bnxt_timer()
13750 if (time_after(jiffies, bp->link_info.phy_retry_expires)) { in bnxt_timer()
13751 bp->link_info.phy_retry = false; in bnxt_timer()
13752 netdev_warn(bp->dev, "failed to update phy settings after maximum retries.\n"); in bnxt_timer()
13758 if (test_bit(BNXT_STATE_L2_FILTER_RETRY, &bp->state)) in bnxt_timer()
13761 if ((BNXT_CHIP_P5(bp)) && !bp->chip_rev && netif_carrier_ok(dev)) in bnxt_timer()
13765 mod_timer(&bp->timer, jiffies + bp->current_interval); in bnxt_timer()
13775 clear_bit(BNXT_STATE_IN_SP_TASK, &bp->state); in bnxt_rtnl_lock_sp()
13781 set_bit(BNXT_STATE_IN_SP_TASK, &bp->state); in bnxt_rtnl_unlock_sp()
13789 if (test_bit(BNXT_STATE_OPEN, &bp->state)) in bnxt_reset()
13800 if (!test_bit(BNXT_STATE_OPEN, &bp->state)) { in bnxt_rx_ring_reset()
13805 if (bp->flags & BNXT_FLAG_TPA) in bnxt_rx_ring_reset()
13807 for (i = 0; i < bp->rx_nr_rings; i++) { in bnxt_rx_ring_reset()
13808 struct bnxt_rx_ring_info *rxr = &bp->rx_ring[i]; in bnxt_rx_ring_reset()
13812 if (!rxr->bnapi->in_reset) in bnxt_rx_ring_reset()
13817 if (rc == -EINVAL || rc == -EOPNOTSUPP) in bnxt_rx_ring_reset()
13818 …netdev_info_once(bp->dev, "RX ring reset not supported by firmware, falling back to global reset\n… in bnxt_rx_ring_reset()
13820 netdev_warn(bp->dev, "RX ring reset failed, rc = %d, falling back to global reset\n", in bnxt_rx_ring_reset()
13826 rxr->rx_prod = 0; in bnxt_rx_ring_reset()
13827 rxr->rx_agg_prod = 0; in bnxt_rx_ring_reset()
13828 rxr->rx_sw_agg_prod = 0; in bnxt_rx_ring_reset()
13829 rxr->rx_next_cons = 0; in bnxt_rx_ring_reset()
13830 rxr->bnapi->in_reset = false; in bnxt_rx_ring_reset()
13832 cpr = &rxr->bnapi->cp_ring; in bnxt_rx_ring_reset()
13833 cpr->sw_stats->rx.rx_resets++; in bnxt_rx_ring_reset()
13834 if (bp->flags & BNXT_FLAG_AGG_RINGS) in bnxt_rx_ring_reset()
13835 bnxt_db_write(bp, &rxr->rx_agg_db, rxr->rx_agg_prod); in bnxt_rx_ring_reset()
13836 bnxt_db_write(bp, &rxr->rx_db, rxr->rx_prod); in bnxt_rx_ring_reset()
13838 if (bp->flags & BNXT_FLAG_TPA) in bnxt_rx_ring_reset()
13850 pci_disable_device(bp->pdev); in bnxt_fw_fatal_close()
13859 if (test_bit(BNXT_STATE_FW_FATAL_COND, &bp->state)) { in bnxt_fw_reset_close()
13862 pci_read_config_word(bp->pdev, PCI_SUBSYSTEM_ID, &val); in bnxt_fw_reset_close()
13864 bp->fw_reset_min_dsecs = 0; in bnxt_fw_reset_close()
13871 if (pci_is_enabled(bp->pdev)) in bnxt_fw_reset_close()
13872 pci_disable_device(bp->pdev); in bnxt_fw_reset_close()
13878 struct bnxt_fw_health *fw_health = bp->fw_health; in is_bnxt_fw_ok()
13883 if (val == fw_health->last_fw_heartbeat) in is_bnxt_fw_ok()
13887 if (val != fw_health->last_fw_reset_cnt) in is_bnxt_fw_ok()
13899 struct bnxt_fw_health *fw_health = bp->fw_health; in bnxt_force_fw_reset()
13900 struct bnxt_ptp_cfg *ptp = bp->ptp_cfg; in bnxt_force_fw_reset()
13903 if (!test_bit(BNXT_STATE_OPEN, &bp->state) || in bnxt_force_fw_reset()
13904 test_bit(BNXT_STATE_IN_FW_RESET, &bp->state)) in bnxt_force_fw_reset()
13911 write_seqlock_irqsave(&ptp->ptp_lock, flags); in bnxt_force_fw_reset()
13912 set_bit(BNXT_STATE_IN_FW_RESET, &bp->state); in bnxt_force_fw_reset()
13913 write_sequnlock_irqrestore(&ptp->ptp_lock, flags); in bnxt_force_fw_reset()
13915 set_bit(BNXT_STATE_IN_FW_RESET, &bp->state); in bnxt_force_fw_reset()
13918 wait_dsecs = fw_health->master_func_wait_dsecs; in bnxt_force_fw_reset()
13919 if (fw_health->primary) { in bnxt_force_fw_reset()
13920 if (fw_health->flags & ERROR_RECOVERY_QCFG_RESP_FLAGS_CO_CPU) in bnxt_force_fw_reset()
13922 bp->fw_reset_state = BNXT_FW_RESET_STATE_RESET_FW; in bnxt_force_fw_reset()
13924 bp->fw_reset_timestamp = jiffies + wait_dsecs * HZ / 10; in bnxt_force_fw_reset()
13925 wait_dsecs = fw_health->normal_func_wait_dsecs; in bnxt_force_fw_reset()
13926 bp->fw_reset_state = BNXT_FW_RESET_STATE_ENABLE_DEV; in bnxt_force_fw_reset()
13929 bp->fw_reset_min_dsecs = fw_health->post_reset_wait_dsecs; in bnxt_force_fw_reset()
13930 bp->fw_reset_max_dsecs = fw_health->post_reset_max_wait_dsecs; in bnxt_force_fw_reset()
13936 netdev_warn(bp->dev, "Detected firmware fatal condition, initiating reset\n"); in bnxt_fw_exception()
13937 set_bit(BNXT_STATE_FW_FATAL_COND, &bp->state); in bnxt_fw_exception()
13957 netdev_err(bp->dev, "func_qcfg cmd failed, rc = %d\n", rc); in bnxt_get_registered_vfs()
13960 if (bp->pf.registered_vfs) in bnxt_get_registered_vfs()
13961 return bp->pf.registered_vfs; in bnxt_get_registered_vfs()
13962 if (bp->sriov_cfg) in bnxt_get_registered_vfs()
13972 if (test_bit(BNXT_STATE_OPEN, &bp->state) && in bnxt_fw_reset()
13973 !test_bit(BNXT_STATE_IN_FW_RESET, &bp->state)) { in bnxt_fw_reset()
13974 struct bnxt_ptp_cfg *ptp = bp->ptp_cfg; in bnxt_fw_reset()
13981 write_seqlock_irqsave(&ptp->ptp_lock, flags); in bnxt_fw_reset()
13982 set_bit(BNXT_STATE_IN_FW_RESET, &bp->state); in bnxt_fw_reset()
13983 write_sequnlock_irqrestore(&ptp->ptp_lock, flags); in bnxt_fw_reset()
13985 set_bit(BNXT_STATE_IN_FW_RESET, &bp->state); in bnxt_fw_reset()
13987 if (bp->pf.active_vfs && in bnxt_fw_reset()
13988 !test_bit(BNXT_STATE_FW_FATAL_COND, &bp->state)) in bnxt_fw_reset()
13991 netdev_err(bp->dev, "Firmware reset aborted, rc = %d\n", in bnxt_fw_reset()
13993 clear_bit(BNXT_STATE_IN_FW_RESET, &bp->state); in bnxt_fw_reset()
13994 dev_close(bp->dev); in bnxt_fw_reset()
13999 if (bp->fw_reset_max_dsecs < vf_tmo_dsecs) in bnxt_fw_reset()
14000 bp->fw_reset_max_dsecs = vf_tmo_dsecs; in bnxt_fw_reset()
14001 bp->fw_reset_state = in bnxt_fw_reset()
14007 if (bp->fw_cap & BNXT_FW_CAP_ERR_RECOVER_RELOAD) { in bnxt_fw_reset()
14008 bp->fw_reset_state = BNXT_FW_RESET_STATE_POLL_FW_DOWN; in bnxt_fw_reset()
14011 bp->fw_reset_state = BNXT_FW_RESET_STATE_ENABLE_DEV; in bnxt_fw_reset()
14012 tmo = bp->fw_reset_min_dsecs * HZ / 10; in bnxt_fw_reset()
14024 if (!(bp->flags & BNXT_FLAG_CHIP_P5_PLUS)) in bnxt_chk_missed_irq()
14027 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_chk_missed_irq()
14028 struct bnxt_napi *bnapi = bp->bnapi[i]; in bnxt_chk_missed_irq()
14036 cpr = &bnapi->cp_ring; in bnxt_chk_missed_irq()
14037 for (j = 0; j < cpr->cp_ring_count; j++) { in bnxt_chk_missed_irq()
14038 struct bnxt_cp_ring_info *cpr2 = &cpr->cp_ring_arr[j]; in bnxt_chk_missed_irq()
14041 if (cpr2->has_more_work || !bnxt_has_work(bp, cpr2)) in bnxt_chk_missed_irq()
14044 if (cpr2->cp_raw_cons != cpr2->last_cp_raw_cons) { in bnxt_chk_missed_irq()
14045 cpr2->last_cp_raw_cons = cpr2->cp_raw_cons; in bnxt_chk_missed_irq()
14048 fw_ring_id = cpr2->cp_ring_struct.fw_ring_id; in bnxt_chk_missed_irq()
14052 cpr->sw_stats->cmn.missed_irqs++; in bnxt_chk_missed_irq()
14061 struct bnxt_link_info *link_info = &bp->link_info; in bnxt_init_ethtool_link_settings()
14063 if (BNXT_AUTO_MODE(link_info->auto_mode)) { in bnxt_init_ethtool_link_settings()
14064 link_info->autoneg = BNXT_AUTONEG_SPEED; in bnxt_init_ethtool_link_settings()
14065 if (bp->hwrm_spec_code >= 0x10201) { in bnxt_init_ethtool_link_settings()
14066 if (link_info->auto_pause_setting & in bnxt_init_ethtool_link_settings()
14068 link_info->autoneg |= BNXT_AUTONEG_FLOW_CTRL; in bnxt_init_ethtool_link_settings()
14070 link_info->autoneg |= BNXT_AUTONEG_FLOW_CTRL; in bnxt_init_ethtool_link_settings()
14075 link_info->req_duplex = link_info->duplex_setting; in bnxt_init_ethtool_link_settings()
14077 if (link_info->autoneg & BNXT_AUTONEG_FLOW_CTRL) in bnxt_init_ethtool_link_settings()
14078 link_info->req_flow_ctrl = in bnxt_init_ethtool_link_settings()
14079 link_info->auto_pause_setting & BNXT_LINK_PAUSE_BOTH; in bnxt_init_ethtool_link_settings()
14081 link_info->req_flow_ctrl = link_info->force_pause_setting; in bnxt_init_ethtool_link_settings()
14086 struct bnxt_fw_health *fw_health = bp->fw_health; in bnxt_fw_echo_reply()
14093 req->event_data1 = cpu_to_le32(fw_health->echo_req_data1); in bnxt_fw_echo_reply()
14094 req->event_data2 = cpu_to_le32(fw_health->echo_req_data2); in bnxt_fw_echo_reply()
14108 set_bit(BNXT_STATE_IN_SP_TASK, &bp->state); in bnxt_sp_task()
14110 if (!test_bit(BNXT_STATE_OPEN, &bp->state)) { in bnxt_sp_task()
14111 clear_bit(BNXT_STATE_IN_SP_TASK, &bp->state); in bnxt_sp_task()
14115 if (test_and_clear_bit(BNXT_RESTART_ULP_SP_EVENT, &bp->sp_event)) { in bnxt_sp_task()
14120 if (test_and_clear_bit(BNXT_RX_MASK_SP_EVENT, &bp->sp_event)) in bnxt_sp_task()
14123 if (test_and_clear_bit(BNXT_RX_NTP_FLTR_SP_EVENT, &bp->sp_event)) in bnxt_sp_task()
14125 if (test_and_clear_bit(BNXT_HWRM_EXEC_FWD_REQ_SP_EVENT, &bp->sp_event)) in bnxt_sp_task()
14127 if (test_and_clear_bit(BNXT_HWRM_PF_UNLOAD_SP_EVENT, &bp->sp_event)) in bnxt_sp_task()
14128 netdev_info(bp->dev, "Receive PF driver unload event!\n"); in bnxt_sp_task()
14129 if (test_and_clear_bit(BNXT_PERIODIC_STATS_SP_EVENT, &bp->sp_event)) { in bnxt_sp_task()
14135 if (test_and_clear_bit(BNXT_LINK_CHNG_SP_EVENT, &bp->sp_event)) { in bnxt_sp_task()
14138 mutex_lock(&bp->link_lock); in bnxt_sp_task()
14140 &bp->sp_event)) in bnxt_sp_task()
14145 netdev_err(bp->dev, "SP task can't update link (rc: %x)\n", in bnxt_sp_task()
14149 &bp->sp_event)) in bnxt_sp_task()
14151 mutex_unlock(&bp->link_lock); in bnxt_sp_task()
14153 if (test_and_clear_bit(BNXT_UPDATE_PHY_SP_EVENT, &bp->sp_event)) { in bnxt_sp_task()
14156 mutex_lock(&bp->link_lock); in bnxt_sp_task()
14158 mutex_unlock(&bp->link_lock); in bnxt_sp_task()
14160 netdev_warn(bp->dev, "update phy settings retry failed\n"); in bnxt_sp_task()
14162 bp->link_info.phy_retry = false; in bnxt_sp_task()
14163 netdev_info(bp->dev, "update phy settings retry succeeded\n"); in bnxt_sp_task()
14166 if (test_and_clear_bit(BNXT_HWRM_PORT_MODULE_SP_EVENT, &bp->sp_event)) { in bnxt_sp_task()
14167 mutex_lock(&bp->link_lock); in bnxt_sp_task()
14169 mutex_unlock(&bp->link_lock); in bnxt_sp_task()
14172 if (test_and_clear_bit(BNXT_FLOW_STATS_SP_EVENT, &bp->sp_event)) in bnxt_sp_task()
14175 if (test_and_clear_bit(BNXT_RING_COAL_NOW_SP_EVENT, &bp->sp_event)) in bnxt_sp_task()
14178 if (test_and_clear_bit(BNXT_FW_ECHO_REQUEST_SP_EVENT, &bp->sp_event)) in bnxt_sp_task()
14181 if (test_and_clear_bit(BNXT_THERMAL_THRESHOLD_SP_EVENT, &bp->sp_event)) in bnxt_sp_task()
14187 if (test_and_clear_bit(BNXT_RESET_TASK_SP_EVENT, &bp->sp_event)) in bnxt_sp_task()
14190 if (test_and_clear_bit(BNXT_RESET_TASK_SILENT_SP_EVENT, &bp->sp_event)) in bnxt_sp_task()
14193 if (test_and_clear_bit(BNXT_RST_RING_SP_EVENT, &bp->sp_event)) in bnxt_sp_task()
14196 if (test_and_clear_bit(BNXT_FW_RESET_NOTIFY_SP_EVENT, &bp->sp_event)) { in bnxt_sp_task()
14197 if (test_bit(BNXT_STATE_FW_FATAL_COND, &bp->state) || in bnxt_sp_task()
14198 test_bit(BNXT_STATE_FW_NON_FATAL_COND, &bp->state)) in bnxt_sp_task()
14204 if (test_and_clear_bit(BNXT_FW_EXCEPTION_SP_EVENT, &bp->sp_event)) { in bnxt_sp_task()
14210 clear_bit(BNXT_STATE_IN_SP_TASK, &bp->state); in bnxt_sp_task()
14231 return -ENOMEM; in bnxt_check_rings()
14233 if (bp->flags & BNXT_FLAG_AGG_RINGS) in bnxt_check_rings()
14239 return -ENOMEM; in bnxt_check_rings()
14246 return -ENOMEM; in bnxt_check_rings()
14254 if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) in bnxt_check_rings()
14257 if (!rc && pci_msix_can_alloc_dyn(bp->pdev)) { in bnxt_check_rings()
14258 if (!bnxt_ulp_registered(bp->edev)) { in bnxt_check_rings()
14262 if (hwr.cp > bp->total_irqs) { in bnxt_check_rings()
14266 netdev_warn(bp->dev, "Unable to allocate %d MSIX vectors, maximum available %d\n", in bnxt_check_rings()
14268 rc = -ENOSPC; in bnxt_check_rings()
14277 if (bp->bar2) { in bnxt_unmap_bars()
14278 pci_iounmap(pdev, bp->bar2); in bnxt_unmap_bars()
14279 bp->bar2 = NULL; in bnxt_unmap_bars()
14282 if (bp->bar1) { in bnxt_unmap_bars()
14283 pci_iounmap(pdev, bp->bar1); in bnxt_unmap_bars()
14284 bp->bar1 = NULL; in bnxt_unmap_bars()
14287 if (bp->bar0) { in bnxt_unmap_bars()
14288 pci_iounmap(pdev, bp->bar0); in bnxt_unmap_bars()
14289 bp->bar0 = NULL; in bnxt_unmap_bars()
14295 bnxt_unmap_bars(bp, bp->pdev); in bnxt_cleanup_pci()
14296 pci_release_regions(bp->pdev); in bnxt_cleanup_pci()
14297 if (pci_is_enabled(bp->pdev)) in bnxt_cleanup_pci()
14298 pci_disable_device(bp->pdev); in bnxt_cleanup_pci()
14303 struct bnxt_coal_cap *coal_cap = &bp->coal_cap; in bnxt_init_dflt_coal()
14307 if (coal_cap->cmpl_params & in bnxt_init_dflt_coal()
14314 coal = &bp->rx_coal; in bnxt_init_dflt_coal()
14315 coal->coal_ticks = 10; in bnxt_init_dflt_coal()
14316 coal->coal_bufs = 30; in bnxt_init_dflt_coal()
14317 coal->coal_ticks_irq = 1; in bnxt_init_dflt_coal()
14318 coal->coal_bufs_irq = 2; in bnxt_init_dflt_coal()
14319 coal->idle_thresh = 50; in bnxt_init_dflt_coal()
14320 coal->bufs_per_record = 2; in bnxt_init_dflt_coal()
14321 coal->budget = 64; /* NAPI budget */ in bnxt_init_dflt_coal()
14322 coal->flags = flags; in bnxt_init_dflt_coal()
14324 coal = &bp->tx_coal; in bnxt_init_dflt_coal()
14325 coal->coal_ticks = 28; in bnxt_init_dflt_coal()
14326 coal->coal_bufs = 30; in bnxt_init_dflt_coal()
14327 coal->coal_ticks_irq = 2; in bnxt_init_dflt_coal()
14328 coal->coal_bufs_irq = 2; in bnxt_init_dflt_coal()
14329 coal->bufs_per_record = 1; in bnxt_init_dflt_coal()
14330 coal->flags = flags; in bnxt_init_dflt_coal()
14332 bp->stats_coal_ticks = BNXT_DEF_STATS_COAL_TICKS; in bnxt_init_dflt_coal()
14335 /* FW that pre-reserves 1 VNIC per function */
14340 if (!(bp->flags & BNXT_FLAG_CHIP_P5_PLUS) && in bnxt_fw_pre_resv_vnics()
14343 if ((bp->flags & BNXT_FLAG_CHIP_P5_PLUS) && in bnxt_fw_pre_resv_vnics()
14353 bp->fw_cap = 0; in bnxt_fw_init_one_p1()
14374 return -ENODEV; in bnxt_fw_init_one_p1()
14387 netdev_err(bp->dev, "hwrm query capability failure rc: %x\n", in bnxt_fw_init_one_p2()
14389 return -ENODEV; in bnxt_fw_init_one_p2()
14394 netdev_warn(bp->dev, "hwrm query adv flow mgnt failure rc: %d\n", in bnxt_fw_init_one_p2()
14398 netdev_warn(bp->dev, "no memory for firmware error recovery\n"); in bnxt_fw_init_one_p2()
14402 netdev_warn(bp->dev, "hwrm query error recovery failure rc: %d\n", in bnxt_fw_init_one_p2()
14408 return -ENODEV; in bnxt_fw_init_one_p2()
14412 netdev_warn(bp->dev, "crash dump mem alloc failure rc: %d\n", in bnxt_fw_init_one_p2()
14418 netdev_warn(bp->dev, in bnxt_fw_init_one_p2()
14424 bp->fw_cap |= BNXT_FW_CAP_PRE_RESV_VNICS; in bnxt_fw_init_one_p2()
14430 if (bp->fw_cap & BNXT_FW_CAP_PTP) in bnxt_fw_init_one_p2()
14439 bp->rss_cap &= ~BNXT_RSS_CAP_UDP_RSS_CAP; in bnxt_set_dflt_rss_hash_type()
14440 bp->rss_hash_cfg = VNIC_RSS_CFG_REQ_HASH_TYPE_IPV4 | in bnxt_set_dflt_rss_hash_type()
14444 if (bp->rss_cap & BNXT_RSS_CAP_RSS_HASH_TYPE_DELTA) in bnxt_set_dflt_rss_hash_type()
14445 bp->rss_hash_delta = bp->rss_hash_cfg; in bnxt_set_dflt_rss_hash_type()
14446 if (BNXT_CHIP_P4_PLUS(bp) && bp->hwrm_spec_code >= 0x10501) { in bnxt_set_dflt_rss_hash_type()
14447 bp->rss_cap |= BNXT_RSS_CAP_UDP_RSS_CAP; in bnxt_set_dflt_rss_hash_type()
14448 bp->rss_hash_cfg |= VNIC_RSS_CFG_REQ_HASH_TYPE_UDP_IPV4 | in bnxt_set_dflt_rss_hash_type()
14455 struct net_device *dev = bp->dev; in bnxt_set_dflt_rfs()
14457 dev->hw_features &= ~NETIF_F_NTUPLE; in bnxt_set_dflt_rfs()
14458 dev->features &= ~NETIF_F_NTUPLE; in bnxt_set_dflt_rfs()
14459 bp->flags &= ~BNXT_FLAG_RFS; in bnxt_set_dflt_rfs()
14461 dev->hw_features |= NETIF_F_NTUPLE; in bnxt_set_dflt_rfs()
14463 bp->flags |= BNXT_FLAG_RFS; in bnxt_set_dflt_rfs()
14464 dev->features |= NETIF_F_NTUPLE; in bnxt_set_dflt_rfs()
14471 struct pci_dev *pdev = bp->pdev; in bnxt_fw_init_one_p3()
14477 if (bp->flags & BNXT_FLAG_WOL_CAP) in bnxt_fw_init_one_p3()
14478 device_set_wakeup_enable(&pdev->dev, bp->wol); in bnxt_fw_init_one_p3()
14480 device_set_wakeup_capable(&pdev->dev, false); in bnxt_fw_init_one_p3()
14494 netdev_err(bp->dev, "Firmware init phase 1 failed\n"); in bnxt_fw_init_one()
14499 netdev_err(bp->dev, "Firmware init phase 2 failed\n"); in bnxt_fw_init_one()
14505 rc = bnxt_approve_mac(bp, bp->dev->dev_addr, false); in bnxt_fw_init_one()
14515 struct bnxt_fw_health *fw_health = bp->fw_health; in bnxt_fw_reset_writel()
14516 u32 reg = fw_health->fw_reset_seq_regs[reg_idx]; in bnxt_fw_reset_writel()
14517 u32 val = fw_health->fw_reset_seq_vals[reg_idx]; in bnxt_fw_reset_writel()
14520 delay_msecs = fw_health->fw_reset_seq_delay_msec[reg_idx]; in bnxt_fw_reset_writel()
14525 pci_write_config_dword(bp->pdev, reg_off, val); in bnxt_fw_reset_writel()
14529 bp->bar0 + BNXT_GRCPF_REG_WINDOW_BASE_OUT + 4); in bnxt_fw_reset_writel()
14533 writel(val, bp->bar0 + reg_off); in bnxt_fw_reset_writel()
14536 writel(val, bp->bar1 + reg_off); in bnxt_fw_reset_writel()
14540 pci_read_config_dword(bp->pdev, 0, &val); in bnxt_fw_reset_writel()
14551 if (~bp->fw_cap & BNXT_FW_CAP_HOT_RESET_IF) in bnxt_hwrm_reset_permitted()
14557 req->fid = cpu_to_le16(0xffff); in bnxt_hwrm_reset_permitted()
14560 result = !!(le16_to_cpu(resp->flags) & in bnxt_hwrm_reset_permitted()
14568 struct bnxt_fw_health *fw_health = bp->fw_health; in bnxt_reset_all()
14571 if (bp->fw_cap & BNXT_FW_CAP_ERR_RECOVER_RELOAD) { in bnxt_reset_all()
14573 bp->fw_reset_timestamp = jiffies; in bnxt_reset_all()
14577 if (fw_health->flags & ERROR_RECOVERY_QCFG_RESP_FLAGS_HOST) { in bnxt_reset_all()
14578 for (i = 0; i < fw_health->fw_reset_seq_cnt; i++) in bnxt_reset_all()
14580 } else if (fw_health->flags & ERROR_RECOVERY_QCFG_RESP_FLAGS_CO_CPU) { in bnxt_reset_all()
14585 req->target_id = cpu_to_le16(HWRM_TARGET_ID_KONG); in bnxt_reset_all()
14586 req->embedded_proc_type = FW_RESET_REQ_EMBEDDED_PROC_TYPE_CHIP; in bnxt_reset_all()
14587 req->selfrst_status = FW_RESET_REQ_SELFRST_STATUS_SELFRSTASAP; in bnxt_reset_all()
14588 req->flags = FW_RESET_REQ_FLAGS_RESET_GRACEFUL; in bnxt_reset_all()
14591 if (rc != -ENODEV) in bnxt_reset_all()
14592 netdev_warn(bp->dev, "Unable to reset FW rc=%d\n", rc); in bnxt_reset_all()
14594 bp->fw_reset_timestamp = jiffies; in bnxt_reset_all()
14599 return time_after(jiffies, bp->fw_reset_timestamp + in bnxt_fw_reset_timeout()
14600 (bp->fw_reset_max_dsecs * HZ / 10)); in bnxt_fw_reset_timeout()
14605 clear_bit(BNXT_STATE_IN_FW_RESET, &bp->state); in bnxt_fw_reset_abort()
14606 if (bp->fw_reset_state != BNXT_FW_RESET_STATE_POLL_VF) in bnxt_fw_reset_abort()
14608 bp->fw_reset_state = 0; in bnxt_fw_reset_abort()
14609 dev_close(bp->dev); in bnxt_fw_reset_abort()
14617 if (!test_bit(BNXT_STATE_IN_FW_RESET, &bp->state)) { in bnxt_fw_reset_task()
14618 netdev_err(bp->dev, "bnxt_fw_reset_task() called when not in fw reset mode!\n"); in bnxt_fw_reset_task()
14622 switch (bp->fw_reset_state) { in bnxt_fw_reset_task()
14628 …netdev_err(bp->dev, "Firmware reset aborted, subsequent func_qcfg cmd failed, rc = %d, %d msecs si… in bnxt_fw_reset_task()
14629 n, jiffies_to_msecs(jiffies - in bnxt_fw_reset_task()
14630 bp->fw_reset_timestamp)); in bnxt_fw_reset_task()
14634 clear_bit(BNXT_STATE_IN_FW_RESET, &bp->state); in bnxt_fw_reset_task()
14635 bp->fw_reset_state = 0; in bnxt_fw_reset_task()
14636 netdev_err(bp->dev, "Firmware reset aborted, bnxt_get_registered_vfs() returns %d\n", in bnxt_fw_reset_task()
14643 bp->fw_reset_timestamp = jiffies; in bnxt_fw_reset_task()
14645 if (test_bit(BNXT_STATE_ABORT_ERR, &bp->state)) { in bnxt_fw_reset_task()
14651 if (bp->fw_cap & BNXT_FW_CAP_ERR_RECOVER_RELOAD) { in bnxt_fw_reset_task()
14652 bp->fw_reset_state = BNXT_FW_RESET_STATE_POLL_FW_DOWN; in bnxt_fw_reset_task()
14655 bp->fw_reset_state = BNXT_FW_RESET_STATE_ENABLE_DEV; in bnxt_fw_reset_task()
14656 tmo = bp->fw_reset_min_dsecs * HZ / 10; in bnxt_fw_reset_task()
14672 if (!bp->fw_health->primary) { in bnxt_fw_reset_task()
14673 u32 wait_dsecs = bp->fw_health->normal_func_wait_dsecs; in bnxt_fw_reset_task()
14675 bp->fw_reset_state = BNXT_FW_RESET_STATE_ENABLE_DEV; in bnxt_fw_reset_task()
14679 bp->fw_reset_state = BNXT_FW_RESET_STATE_RESET_FW; in bnxt_fw_reset_task()
14684 bp->fw_reset_state = BNXT_FW_RESET_STATE_ENABLE_DEV; in bnxt_fw_reset_task()
14685 bnxt_queue_fw_reset_work(bp, bp->fw_reset_min_dsecs * HZ / 10); in bnxt_fw_reset_task()
14689 if (test_bit(BNXT_STATE_FW_FATAL_COND, &bp->state) && in bnxt_fw_reset_task()
14690 !bp->fw_reset_min_dsecs) { in bnxt_fw_reset_task()
14693 pci_read_config_word(bp->pdev, PCI_SUBSYSTEM_ID, &val); in bnxt_fw_reset_task()
14696 netdev_err(bp->dev, "Firmware reset aborted, PCI config space invalid\n"); in bnxt_fw_reset_task()
14697 rc = -ETIMEDOUT; in bnxt_fw_reset_task()
14704 clear_bit(BNXT_STATE_FW_FATAL_COND, &bp->state); in bnxt_fw_reset_task()
14705 clear_bit(BNXT_STATE_FW_NON_FATAL_COND, &bp->state); in bnxt_fw_reset_task()
14706 if (test_and_clear_bit(BNXT_STATE_FW_ACTIVATE_RESET, &bp->state) && in bnxt_fw_reset_task()
14707 !test_bit(BNXT_STATE_FW_ACTIVATE, &bp->state)) in bnxt_fw_reset_task()
14709 if (pci_enable_device(bp->pdev)) { in bnxt_fw_reset_task()
14710 netdev_err(bp->dev, "Cannot re-enable PCI device\n"); in bnxt_fw_reset_task()
14711 rc = -ENODEV; in bnxt_fw_reset_task()
14714 pci_set_master(bp->pdev); in bnxt_fw_reset_task()
14715 bp->fw_reset_state = BNXT_FW_RESET_STATE_POLL_FW; in bnxt_fw_reset_task()
14718 bp->hwrm_cmd_timeout = SHORT_HWRM_CMD_TIMEOUT; in bnxt_fw_reset_task()
14722 netdev_err(bp->dev, "Firmware reset aborted\n"); in bnxt_fw_reset_task()
14728 bp->hwrm_cmd_timeout = DFLT_HWRM_CMD_TIMEOUT; in bnxt_fw_reset_task()
14729 bp->fw_reset_state = BNXT_FW_RESET_STATE_OPENING; in bnxt_fw_reset_task()
14736 rc = bnxt_open(bp->dev); in bnxt_fw_reset_task()
14738 netdev_err(bp->dev, "bnxt_open() failed during FW reset\n"); in bnxt_fw_reset_task()
14744 if ((bp->fw_cap & BNXT_FW_CAP_ERROR_RECOVERY) && in bnxt_fw_reset_task()
14745 bp->fw_health->enabled) { in bnxt_fw_reset_task()
14746 bp->fw_health->last_fw_reset_cnt = in bnxt_fw_reset_task()
14749 bp->fw_reset_state = 0; in bnxt_fw_reset_task()
14752 clear_bit(BNXT_STATE_IN_FW_RESET, &bp->state); in bnxt_fw_reset_task()
14754 clear_bit(BNXT_STATE_FW_ACTIVATE, &bp->state); in bnxt_fw_reset_task()
14755 if (test_and_clear_bit(BNXT_STATE_RECOVER, &bp->state)) { in bnxt_fw_reset_task()
14771 if (bp->fw_health->status_reliable || in bnxt_fw_reset_task()
14772 (bp->fw_cap & BNXT_FW_CAP_ERROR_RECOVERY)) { in bnxt_fw_reset_task()
14775 netdev_err(bp->dev, "fw_health_status 0x%x\n", sts); in bnxt_fw_reset_task()
14790 SET_NETDEV_DEV(dev, &pdev->dev); in bnxt_init_board()
14792 /* enable device (incl. PCI PM wakeup), and bus-mastering */ in bnxt_init_board()
14795 dev_err(&pdev->dev, "Cannot enable PCI device, aborting\n"); in bnxt_init_board()
14800 dev_err(&pdev->dev, in bnxt_init_board()
14802 rc = -ENODEV; in bnxt_init_board()
14808 dev_err(&pdev->dev, "Cannot obtain PCI resources, aborting\n"); in bnxt_init_board()
14812 if (dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)) != 0 && in bnxt_init_board()
14813 dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32)) != 0) { in bnxt_init_board()
14814 dev_err(&pdev->dev, "System does not support DMA, aborting\n"); in bnxt_init_board()
14815 rc = -EIO; in bnxt_init_board()
14821 bp->dev = dev; in bnxt_init_board()
14822 bp->pdev = pdev; in bnxt_init_board()
14824 /* Doorbell BAR bp->bar1 is mapped after bnxt_fw_init_one_p2() in bnxt_init_board()
14827 bp->bar0 = pci_ioremap_bar(pdev, 0); in bnxt_init_board()
14828 if (!bp->bar0) { in bnxt_init_board()
14829 dev_err(&pdev->dev, "Cannot map device registers, aborting\n"); in bnxt_init_board()
14830 rc = -ENOMEM; in bnxt_init_board()
14834 bp->bar2 = pci_ioremap_bar(pdev, 4); in bnxt_init_board()
14835 if (!bp->bar2) { in bnxt_init_board()
14836 dev_err(&pdev->dev, "Cannot map bar4 registers, aborting\n"); in bnxt_init_board()
14837 rc = -ENOMEM; in bnxt_init_board()
14841 INIT_WORK(&bp->sp_task, bnxt_sp_task); in bnxt_init_board()
14842 INIT_DELAYED_WORK(&bp->fw_reset_task, bnxt_fw_reset_task); in bnxt_init_board()
14844 spin_lock_init(&bp->ntp_fltr_lock); in bnxt_init_board()
14846 spin_lock_init(&bp->db_lock); in bnxt_init_board()
14849 bp->rx_ring_size = BNXT_DEFAULT_RX_RING_SIZE; in bnxt_init_board()
14850 bp->tx_ring_size = BNXT_DEFAULT_TX_RING_SIZE; in bnxt_init_board()
14852 timer_setup(&bp->timer, bnxt_timer, 0); in bnxt_init_board()
14853 bp->current_interval = BNXT_TIMER_INTERVAL; in bnxt_init_board()
14855 bp->vxlan_fw_dst_port_id = INVALID_HW_RING_ID; in bnxt_init_board()
14856 bp->nge_fw_dst_port_id = INVALID_HW_RING_ID; in bnxt_init_board()
14858 clear_bit(BNXT_STATE_OPEN, &bp->state); in bnxt_init_board()
14879 if (!is_valid_ether_addr(addr->sa_data)) in bnxt_change_mac_addr()
14880 return -EADDRNOTAVAIL; in bnxt_change_mac_addr()
14882 if (ether_addr_equal(addr->sa_data, dev->dev_addr)) in bnxt_change_mac_addr()
14885 rc = bnxt_approve_mac(bp, addr->sa_data, true); in bnxt_change_mac_addr()
14889 eth_hw_addr_set(dev, addr->sa_data); in bnxt_change_mac_addr()
14907 WRITE_ONCE(dev->mtu, new_mtu); in bnxt_change_mtu()
14909 /* MTU change may change the AGG ring settings if an XDP multi-buffer in bnxt_change_mtu()
14913 if (READ_ONCE(bp->xdp_prog)) in bnxt_change_mtu()
14930 if (tc > bp->max_tc) { in bnxt_setup_mq_tc()
14932 tc, bp->max_tc); in bnxt_setup_mq_tc()
14933 return -EINVAL; in bnxt_setup_mq_tc()
14936 if (bp->num_tc == tc) in bnxt_setup_mq_tc()
14939 if (bp->flags & BNXT_FLAG_SHARED_RINGS) in bnxt_setup_mq_tc()
14942 rc = bnxt_check_rings(bp, bp->tx_nr_rings_per_tc, bp->rx_nr_rings, in bnxt_setup_mq_tc()
14943 sh, tc, bp->tx_nr_rings_xdp); in bnxt_setup_mq_tc()
14947 /* Needs to close the device and do hw resource re-allocations */ in bnxt_setup_mq_tc()
14948 if (netif_running(bp->dev)) in bnxt_setup_mq_tc()
14952 bp->tx_nr_rings = bp->tx_nr_rings_per_tc * tc; in bnxt_setup_mq_tc()
14954 bp->num_tc = tc; in bnxt_setup_mq_tc()
14956 bp->tx_nr_rings = bp->tx_nr_rings_per_tc; in bnxt_setup_mq_tc()
14958 bp->num_tc = 0; in bnxt_setup_mq_tc()
14960 bp->tx_nr_rings += bp->tx_nr_rings_xdp; in bnxt_setup_mq_tc()
14961 tx_cp = bnxt_num_tx_to_cp(bp, bp->tx_nr_rings); in bnxt_setup_mq_tc()
14962 bp->cp_nr_rings = sh ? max_t(int, tx_cp, bp->rx_nr_rings) : in bnxt_setup_mq_tc()
14963 tx_cp + bp->rx_nr_rings; in bnxt_setup_mq_tc()
14965 if (netif_running(bp->dev)) in bnxt_setup_mq_tc()
14977 !tc_cls_can_offload_and_chain0(bp->dev, type_data)) in bnxt_setup_tc_block_cb()
14978 return -EOPNOTSUPP; in bnxt_setup_tc_block_cb()
14982 return bnxt_tc_setup_flower(bp, bp->pf.fw_fid, type_data); in bnxt_setup_tc_block_cb()
14984 return -EOPNOTSUPP; in bnxt_setup_tc_block_cb()
15004 mqprio->hw = TC_MQPRIO_HW_OFFLOAD_TCS; in bnxt_setup_tc()
15006 return bnxt_setup_mq_tc(dev, mqprio->num_tc); in bnxt_setup_tc()
15009 return -EOPNOTSUPP; in bnxt_setup_tc()
15021 vnic = &bp->vnic_info[BNXT_VNIC_DEFAULT]; in bnxt_get_ntp_filter_idx()
15022 return bnxt_toeplitz(bp, fkeys, (void *)vnic->rss_hash_key); in bnxt_get_ntp_filter_idx()
15031 spin_lock_bh(&bp->ntp_fltr_lock); in bnxt_insert_ntp_filter()
15032 bit_id = bitmap_find_free_region(bp->ntp_fltr_bmap, bp->max_fltr, 0); in bnxt_insert_ntp_filter()
15034 spin_unlock_bh(&bp->ntp_fltr_lock); in bnxt_insert_ntp_filter()
15035 return -ENOMEM; in bnxt_insert_ntp_filter()
15038 fltr->base.sw_id = (u16)bit_id; in bnxt_insert_ntp_filter()
15039 fltr->base.type = BNXT_FLTR_TYPE_NTUPLE; in bnxt_insert_ntp_filter()
15040 fltr->base.flags |= BNXT_ACT_RING_DST; in bnxt_insert_ntp_filter()
15041 head = &bp->ntp_fltr_hash_tbl[idx]; in bnxt_insert_ntp_filter()
15042 hlist_add_head_rcu(&fltr->base.hash, head); in bnxt_insert_ntp_filter()
15043 set_bit(BNXT_FLTR_INSERTED, &fltr->base.state); in bnxt_insert_ntp_filter()
15044 bnxt_insert_usr_fltr(bp, &fltr->base); in bnxt_insert_ntp_filter()
15045 bp->ntp_fltr_count++; in bnxt_insert_ntp_filter()
15046 spin_unlock_bh(&bp->ntp_fltr_lock); in bnxt_insert_ntp_filter()
15053 struct bnxt_flow_masks *masks1 = &f1->fmasks; in bnxt_fltr_match()
15054 struct bnxt_flow_masks *masks2 = &f2->fmasks; in bnxt_fltr_match()
15055 struct flow_keys *keys1 = &f1->fkeys; in bnxt_fltr_match()
15056 struct flow_keys *keys2 = &f2->fkeys; in bnxt_fltr_match()
15058 if (keys1->basic.n_proto != keys2->basic.n_proto || in bnxt_fltr_match()
15059 keys1->basic.ip_proto != keys2->basic.ip_proto) in bnxt_fltr_match()
15062 if (keys1->basic.n_proto == htons(ETH_P_IP)) { in bnxt_fltr_match()
15063 if (keys1->addrs.v4addrs.src != keys2->addrs.v4addrs.src || in bnxt_fltr_match()
15064 masks1->addrs.v4addrs.src != masks2->addrs.v4addrs.src || in bnxt_fltr_match()
15065 keys1->addrs.v4addrs.dst != keys2->addrs.v4addrs.dst || in bnxt_fltr_match()
15066 masks1->addrs.v4addrs.dst != masks2->addrs.v4addrs.dst) in bnxt_fltr_match()
15069 if (!ipv6_addr_equal(&keys1->addrs.v6addrs.src, in bnxt_fltr_match()
15070 &keys2->addrs.v6addrs.src) || in bnxt_fltr_match()
15071 !ipv6_addr_equal(&masks1->addrs.v6addrs.src, in bnxt_fltr_match()
15072 &masks2->addrs.v6addrs.src) || in bnxt_fltr_match()
15073 !ipv6_addr_equal(&keys1->addrs.v6addrs.dst, in bnxt_fltr_match()
15074 &keys2->addrs.v6addrs.dst) || in bnxt_fltr_match()
15075 !ipv6_addr_equal(&masks1->addrs.v6addrs.dst, in bnxt_fltr_match()
15076 &masks2->addrs.v6addrs.dst)) in bnxt_fltr_match()
15080 return keys1->ports.src == keys2->ports.src && in bnxt_fltr_match()
15081 masks1->ports.src == masks2->ports.src && in bnxt_fltr_match()
15082 keys1->ports.dst == keys2->ports.dst && in bnxt_fltr_match()
15083 masks1->ports.dst == masks2->ports.dst && in bnxt_fltr_match()
15084 keys1->control.flags == keys2->control.flags && in bnxt_fltr_match()
15085 f1->l2_fltr == f2->l2_fltr; in bnxt_fltr_match()
15095 head = &bp->ntp_fltr_hash_tbl[idx]; in bnxt_lookup_ntp_filter_from_idx()
15115 if (ether_addr_equal(dev->dev_addr, eth->h_dest)) { in bnxt_rx_flow_steer()
15116 l2_fltr = bp->vnic_info[BNXT_VNIC_DEFAULT].l2_filters[0]; in bnxt_rx_flow_steer()
15117 atomic_inc(&l2_fltr->refcnt); in bnxt_rx_flow_steer()
15121 ether_addr_copy(key.dst_mac_addr, eth->h_dest); in bnxt_rx_flow_steer()
15125 return -EINVAL; in bnxt_rx_flow_steer()
15126 if (l2_fltr->base.flags & BNXT_ACT_FUNC_DST) { in bnxt_rx_flow_steer()
15128 return -EINVAL; in bnxt_rx_flow_steer()
15134 return -ENOMEM; in bnxt_rx_flow_steer()
15137 fkeys = &new_fltr->fkeys; in bnxt_rx_flow_steer()
15139 rc = -EPROTONOSUPPORT; in bnxt_rx_flow_steer()
15143 if ((fkeys->basic.n_proto != htons(ETH_P_IP) && in bnxt_rx_flow_steer()
15144 fkeys->basic.n_proto != htons(ETH_P_IPV6)) || in bnxt_rx_flow_steer()
15145 ((fkeys->basic.ip_proto != IPPROTO_TCP) && in bnxt_rx_flow_steer()
15146 (fkeys->basic.ip_proto != IPPROTO_UDP))) { in bnxt_rx_flow_steer()
15147 rc = -EPROTONOSUPPORT; in bnxt_rx_flow_steer()
15150 new_fltr->fmasks = BNXT_FLOW_IPV4_MASK_ALL; in bnxt_rx_flow_steer()
15151 if (fkeys->basic.n_proto == htons(ETH_P_IPV6)) { in bnxt_rx_flow_steer()
15152 if (bp->hwrm_spec_code < 0x10601) { in bnxt_rx_flow_steer()
15153 rc = -EPROTONOSUPPORT; in bnxt_rx_flow_steer()
15156 new_fltr->fmasks = BNXT_FLOW_IPV6_MASK_ALL; in bnxt_rx_flow_steer()
15158 flags = fkeys->control.flags; in bnxt_rx_flow_steer()
15160 bp->hwrm_spec_code < 0x10601) || (flags & FLOW_DIS_IS_FRAGMENT)) { in bnxt_rx_flow_steer()
15161 rc = -EPROTONOSUPPORT; in bnxt_rx_flow_steer()
15164 new_fltr->l2_fltr = l2_fltr; in bnxt_rx_flow_steer()
15170 rc = fltr->base.sw_id; in bnxt_rx_flow_steer()
15176 new_fltr->flow_id = flow_id; in bnxt_rx_flow_steer()
15177 new_fltr->base.rxq = rxq_index; in bnxt_rx_flow_steer()
15181 return new_fltr->base.sw_id; in bnxt_rx_flow_steer()
15193 spin_lock_bh(&bp->ntp_fltr_lock); in bnxt_del_ntp_filter()
15194 if (!test_and_clear_bit(BNXT_FLTR_INSERTED, &fltr->base.state)) { in bnxt_del_ntp_filter()
15195 spin_unlock_bh(&bp->ntp_fltr_lock); in bnxt_del_ntp_filter()
15198 hlist_del_rcu(&fltr->base.hash); in bnxt_del_ntp_filter()
15199 bnxt_del_one_usr_fltr(bp, &fltr->base); in bnxt_del_ntp_filter()
15200 bp->ntp_fltr_count--; in bnxt_del_ntp_filter()
15201 spin_unlock_bh(&bp->ntp_fltr_lock); in bnxt_del_ntp_filter()
15202 bnxt_del_l2_filter(bp, fltr->l2_fltr); in bnxt_del_ntp_filter()
15203 clear_bit(fltr->base.sw_id, bp->ntp_fltr_bmap); in bnxt_del_ntp_filter()
15218 head = &bp->ntp_fltr_hash_tbl[i]; in bnxt_cfg_ntp_filters()
15222 if (test_bit(BNXT_FLTR_VALID, &fltr->base.state)) { in bnxt_cfg_ntp_filters()
15223 if (fltr->base.flags & BNXT_ACT_NO_AGING) in bnxt_cfg_ntp_filters()
15225 if (rps_may_expire_flow(bp->dev, fltr->base.rxq, in bnxt_cfg_ntp_filters()
15226 fltr->flow_id, in bnxt_cfg_ntp_filters()
15227 fltr->base.sw_id)) { in bnxt_cfg_ntp_filters()
15238 set_bit(BNXT_FLTR_VALID, &fltr->base.state); in bnxt_cfg_ntp_filters()
15254 if (ti->type == UDP_TUNNEL_TYPE_VXLAN) in bnxt_udp_tunnel_set_port()
15256 else if (ti->type == UDP_TUNNEL_TYPE_GENEVE) in bnxt_udp_tunnel_set_port()
15261 return bnxt_hwrm_tunnel_dst_port_alloc(bp, ti->port, cmd); in bnxt_udp_tunnel_set_port()
15270 if (ti->type == UDP_TUNNEL_TYPE_VXLAN) in bnxt_udp_tunnel_unset_port()
15272 else if (ti->type == UDP_TUNNEL_TYPE_GENEVE) in bnxt_udp_tunnel_unset_port()
15307 return ndo_dflt_bridge_getlink(skb, pid, seq, dev, bp->br_mode, 0, 0, in bnxt_bridge_getlink()
15318 if (bp->hwrm_spec_code < 0x10708 || !BNXT_SINGLE_PF(bp)) in bnxt_bridge_setlink()
15319 return -EOPNOTSUPP; in bnxt_bridge_setlink()
15323 return -EINVAL; in bnxt_bridge_setlink()
15329 if (mode == bp->br_mode) in bnxt_bridge_setlink()
15334 bp->br_mode = mode; in bnxt_bridge_setlink()
15345 if (bp->eswitch_mode != DEVLINK_ESWITCH_MODE_SWITCHDEV) in bnxt_get_port_parent_id()
15346 return -EOPNOTSUPP; in bnxt_get_port_parent_id()
15348 /* The PF and it's VF-reps only support the switchdev framework */ in bnxt_get_port_parent_id()
15349 if (!BNXT_PF(bp) || !(bp->flags & BNXT_FLAG_DSN_VALID)) in bnxt_get_port_parent_id()
15350 return -EOPNOTSUPP; in bnxt_get_port_parent_id()
15352 ppid->id_len = sizeof(bp->dsn); in bnxt_get_port_parent_id()
15353 memcpy(ppid->id, bp->dsn, ppid->id_len); in bnxt_get_port_parent_id()
15398 if (!bp->bnapi) in bnxt_get_queue_stats_rx()
15401 cpr = &bp->bnapi[i]->cp_ring; in bnxt_get_queue_stats_rx()
15402 sw = cpr->stats.sw_stats; in bnxt_get_queue_stats_rx()
15404 stats->packets = 0; in bnxt_get_queue_stats_rx()
15405 stats->packets += BNXT_GET_RING_STATS64(sw, rx_ucast_pkts); in bnxt_get_queue_stats_rx()
15406 stats->packets += BNXT_GET_RING_STATS64(sw, rx_mcast_pkts); in bnxt_get_queue_stats_rx()
15407 stats->packets += BNXT_GET_RING_STATS64(sw, rx_bcast_pkts); in bnxt_get_queue_stats_rx()
15409 stats->bytes = 0; in bnxt_get_queue_stats_rx()
15410 stats->bytes += BNXT_GET_RING_STATS64(sw, rx_ucast_bytes); in bnxt_get_queue_stats_rx()
15411 stats->bytes += BNXT_GET_RING_STATS64(sw, rx_mcast_bytes); in bnxt_get_queue_stats_rx()
15412 stats->bytes += BNXT_GET_RING_STATS64(sw, rx_bcast_bytes); in bnxt_get_queue_stats_rx()
15414 stats->alloc_fail = cpr->sw_stats->rx.rx_oom_discards; in bnxt_get_queue_stats_rx()
15424 if (!bp->tx_ring) in bnxt_get_queue_stats_tx()
15427 bnapi = bp->tx_ring[bp->tx_ring_map[i]].bnapi; in bnxt_get_queue_stats_tx()
15428 sw = bnapi->cp_ring.stats.sw_stats; in bnxt_get_queue_stats_tx()
15430 stats->packets = 0; in bnxt_get_queue_stats_tx()
15431 stats->packets += BNXT_GET_RING_STATS64(sw, tx_ucast_pkts); in bnxt_get_queue_stats_tx()
15432 stats->packets += BNXT_GET_RING_STATS64(sw, tx_mcast_pkts); in bnxt_get_queue_stats_tx()
15433 stats->packets += BNXT_GET_RING_STATS64(sw, tx_bcast_pkts); in bnxt_get_queue_stats_tx()
15435 stats->bytes = 0; in bnxt_get_queue_stats_tx()
15436 stats->bytes += BNXT_GET_RING_STATS64(sw, tx_ucast_bytes); in bnxt_get_queue_stats_tx()
15437 stats->bytes += BNXT_GET_RING_STATS64(sw, tx_mcast_bytes); in bnxt_get_queue_stats_tx()
15438 stats->bytes += BNXT_GET_RING_STATS64(sw, tx_bcast_bytes); in bnxt_get_queue_stats_tx()
15447 rx->packets = bp->net_stats_prev.rx_packets; in bnxt_get_base_stats()
15448 rx->bytes = bp->net_stats_prev.rx_bytes; in bnxt_get_base_stats()
15449 rx->alloc_fail = bp->ring_err_stats_prev.rx_total_oom_discards; in bnxt_get_base_stats()
15451 tx->packets = bp->net_stats_prev.tx_packets; in bnxt_get_base_stats()
15452 tx->bytes = bp->net_stats_prev.tx_bytes; in bnxt_get_base_stats()
15468 if (!bp->rx_ring) in bnxt_queue_mem_alloc()
15469 return -ENETDOWN; in bnxt_queue_mem_alloc()
15471 rxr = &bp->rx_ring[idx]; in bnxt_queue_mem_alloc()
15477 clone->rx_prod = 0; in bnxt_queue_mem_alloc()
15478 clone->rx_agg_prod = 0; in bnxt_queue_mem_alloc()
15479 clone->rx_sw_agg_prod = 0; in bnxt_queue_mem_alloc()
15480 clone->rx_next_cons = 0; in bnxt_queue_mem_alloc()
15482 rc = bnxt_alloc_rx_page_pool(bp, clone, rxr->page_pool->p.nid); in bnxt_queue_mem_alloc()
15486 rc = xdp_rxq_info_reg(&clone->xdp_rxq, bp->dev, idx, 0); in bnxt_queue_mem_alloc()
15490 rc = xdp_rxq_info_reg_mem_model(&clone->xdp_rxq, in bnxt_queue_mem_alloc()
15492 clone->page_pool); in bnxt_queue_mem_alloc()
15496 ring = &clone->rx_ring_struct; in bnxt_queue_mem_alloc()
15497 rc = bnxt_alloc_ring(bp, &ring->ring_mem); in bnxt_queue_mem_alloc()
15501 if (bp->flags & BNXT_FLAG_AGG_RINGS) { in bnxt_queue_mem_alloc()
15502 ring = &clone->rx_agg_ring_struct; in bnxt_queue_mem_alloc()
15503 rc = bnxt_alloc_ring(bp, &ring->ring_mem); in bnxt_queue_mem_alloc()
15512 if (bp->flags & BNXT_FLAG_TPA) { in bnxt_queue_mem_alloc()
15522 if (bp->flags & BNXT_FLAG_AGG_RINGS) in bnxt_queue_mem_alloc()
15524 if (bp->flags & BNXT_FLAG_TPA) in bnxt_queue_mem_alloc()
15532 bnxt_free_ring(bp, &clone->rx_agg_ring_struct.ring_mem); in bnxt_queue_mem_alloc()
15534 bnxt_free_ring(bp, &clone->rx_ring_struct.ring_mem); in bnxt_queue_mem_alloc()
15536 xdp_rxq_info_unreg(&clone->xdp_rxq); in bnxt_queue_mem_alloc()
15538 page_pool_destroy(clone->page_pool); in bnxt_queue_mem_alloc()
15540 page_pool_destroy(clone->head_pool); in bnxt_queue_mem_alloc()
15541 clone->page_pool = NULL; in bnxt_queue_mem_alloc()
15542 clone->head_pool = NULL; in bnxt_queue_mem_alloc()
15555 xdp_rxq_info_unreg(&rxr->xdp_rxq); in bnxt_queue_mem_free()
15557 page_pool_destroy(rxr->page_pool); in bnxt_queue_mem_free()
15559 page_pool_destroy(rxr->head_pool); in bnxt_queue_mem_free()
15560 rxr->page_pool = NULL; in bnxt_queue_mem_free()
15561 rxr->head_pool = NULL; in bnxt_queue_mem_free()
15563 ring = &rxr->rx_ring_struct; in bnxt_queue_mem_free()
15564 bnxt_free_ring(bp, &ring->ring_mem); in bnxt_queue_mem_free()
15566 ring = &rxr->rx_agg_ring_struct; in bnxt_queue_mem_free()
15567 bnxt_free_ring(bp, &ring->ring_mem); in bnxt_queue_mem_free()
15569 kfree(rxr->rx_agg_bmap); in bnxt_queue_mem_free()
15570 rxr->rx_agg_bmap = NULL; in bnxt_queue_mem_free()
15581 dst_ring = &dst->rx_ring_struct; in bnxt_copy_rx_ring()
15582 dst_rmem = &dst_ring->ring_mem; in bnxt_copy_rx_ring()
15583 src_ring = &src->rx_ring_struct; in bnxt_copy_rx_ring()
15584 src_rmem = &src_ring->ring_mem; in bnxt_copy_rx_ring()
15586 WARN_ON(dst_rmem->nr_pages != src_rmem->nr_pages); in bnxt_copy_rx_ring()
15587 WARN_ON(dst_rmem->page_size != src_rmem->page_size); in bnxt_copy_rx_ring()
15588 WARN_ON(dst_rmem->flags != src_rmem->flags); in bnxt_copy_rx_ring()
15589 WARN_ON(dst_rmem->depth != src_rmem->depth); in bnxt_copy_rx_ring()
15590 WARN_ON(dst_rmem->vmem_size != src_rmem->vmem_size); in bnxt_copy_rx_ring()
15591 WARN_ON(dst_rmem->ctx_mem != src_rmem->ctx_mem); in bnxt_copy_rx_ring()
15593 dst_rmem->pg_tbl = src_rmem->pg_tbl; in bnxt_copy_rx_ring()
15594 dst_rmem->pg_tbl_map = src_rmem->pg_tbl_map; in bnxt_copy_rx_ring()
15595 *dst_rmem->vmem = *src_rmem->vmem; in bnxt_copy_rx_ring()
15596 for (i = 0; i < dst_rmem->nr_pages; i++) { in bnxt_copy_rx_ring()
15597 dst_rmem->pg_arr[i] = src_rmem->pg_arr[i]; in bnxt_copy_rx_ring()
15598 dst_rmem->dma_arr[i] = src_rmem->dma_arr[i]; in bnxt_copy_rx_ring()
15601 if (!(bp->flags & BNXT_FLAG_AGG_RINGS)) in bnxt_copy_rx_ring()
15604 dst_ring = &dst->rx_agg_ring_struct; in bnxt_copy_rx_ring()
15605 dst_rmem = &dst_ring->ring_mem; in bnxt_copy_rx_ring()
15606 src_ring = &src->rx_agg_ring_struct; in bnxt_copy_rx_ring()
15607 src_rmem = &src_ring->ring_mem; in bnxt_copy_rx_ring()
15609 WARN_ON(dst_rmem->nr_pages != src_rmem->nr_pages); in bnxt_copy_rx_ring()
15610 WARN_ON(dst_rmem->page_size != src_rmem->page_size); in bnxt_copy_rx_ring()
15611 WARN_ON(dst_rmem->flags != src_rmem->flags); in bnxt_copy_rx_ring()
15612 WARN_ON(dst_rmem->depth != src_rmem->depth); in bnxt_copy_rx_ring()
15613 WARN_ON(dst_rmem->vmem_size != src_rmem->vmem_size); in bnxt_copy_rx_ring()
15614 WARN_ON(dst_rmem->ctx_mem != src_rmem->ctx_mem); in bnxt_copy_rx_ring()
15615 WARN_ON(dst->rx_agg_bmap_size != src->rx_agg_bmap_size); in bnxt_copy_rx_ring()
15617 dst_rmem->pg_tbl = src_rmem->pg_tbl; in bnxt_copy_rx_ring()
15618 dst_rmem->pg_tbl_map = src_rmem->pg_tbl_map; in bnxt_copy_rx_ring()
15619 *dst_rmem->vmem = *src_rmem->vmem; in bnxt_copy_rx_ring()
15620 for (i = 0; i < dst_rmem->nr_pages; i++) { in bnxt_copy_rx_ring()
15621 dst_rmem->pg_arr[i] = src_rmem->pg_arr[i]; in bnxt_copy_rx_ring()
15622 dst_rmem->dma_arr[i] = src_rmem->dma_arr[i]; in bnxt_copy_rx_ring()
15625 dst->rx_agg_bmap = src->rx_agg_bmap; in bnxt_copy_rx_ring()
15636 rxr = &bp->rx_ring[idx]; in bnxt_queue_start()
15639 rxr->rx_prod = clone->rx_prod; in bnxt_queue_start()
15640 rxr->rx_agg_prod = clone->rx_agg_prod; in bnxt_queue_start()
15641 rxr->rx_sw_agg_prod = clone->rx_sw_agg_prod; in bnxt_queue_start()
15642 rxr->rx_next_cons = clone->rx_next_cons; in bnxt_queue_start()
15643 rxr->rx_tpa = clone->rx_tpa; in bnxt_queue_start()
15644 rxr->rx_tpa_idx_map = clone->rx_tpa_idx_map; in bnxt_queue_start()
15645 rxr->page_pool = clone->page_pool; in bnxt_queue_start()
15646 rxr->head_pool = clone->head_pool; in bnxt_queue_start()
15647 rxr->xdp_rxq = clone->xdp_rxq; in bnxt_queue_start()
15658 bnxt_db_write(bp, &rxr->rx_db, rxr->rx_prod); in bnxt_queue_start()
15659 if (bp->flags & BNXT_FLAG_AGG_RINGS) in bnxt_queue_start()
15660 bnxt_db_write(bp, &rxr->rx_agg_db, rxr->rx_agg_prod); in bnxt_queue_start()
15662 cpr = &rxr->bnapi->cp_ring; in bnxt_queue_start()
15663 cpr->sw_stats->rx.rx_resets++; in bnxt_queue_start()
15665 for (i = 0; i < bp->nr_vnics; i++) { in bnxt_queue_start()
15666 vnic = &bp->vnic_info[i]; in bnxt_queue_start()
15670 netdev_err(bp->dev, "hwrm vnic %d set rss failure rc: %d\n", in bnxt_queue_start()
15671 vnic->vnic_id, rc); in bnxt_queue_start()
15674 vnic->mru = bp->dev->mtu + ETH_HLEN + VLAN_HLEN; in bnxt_queue_start()
15693 for (i = 0; i < bp->nr_vnics; i++) { in bnxt_queue_stop()
15694 vnic = &bp->vnic_info[i]; in bnxt_queue_stop()
15695 vnic->mru = 0; in bnxt_queue_stop()
15701 rxr = &bp->rx_ring[idx]; in bnxt_queue_stop()
15702 cancel_work_sync(&rxr->bnapi->cp_ring.dim.work); in bnxt_queue_stop()
15705 rxr->rx_next_cons = 0; in bnxt_queue_stop()
15706 page_pool_disable_direct_recycling(rxr->page_pool); in bnxt_queue_stop()
15708 page_pool_disable_direct_recycling(rxr->head_pool); in bnxt_queue_stop()
15741 WARN_ON(bp->num_rss_ctx); in bnxt_remove_one()
15742 clear_bit(BNXT_STATE_IN_FW_RESET, &bp->state); in bnxt_remove_one()
15744 cancel_work_sync(&bp->sp_task); in bnxt_remove_one()
15745 cancel_delayed_work_sync(&bp->fw_reset_task); in bnxt_remove_one()
15746 bp->sp_event = 0; in bnxt_remove_one()
15758 kfree(bp->ptp_cfg); in bnxt_remove_one()
15759 bp->ptp_cfg = NULL; in bnxt_remove_one()
15760 kfree(bp->fw_health); in bnxt_remove_one()
15761 bp->fw_health = NULL; in bnxt_remove_one()
15765 kfree(bp->rss_indir_tbl); in bnxt_remove_one()
15766 bp->rss_indir_tbl = NULL; in bnxt_remove_one()
15774 struct bnxt_link_info *link_info = &bp->link_info; in bnxt_probe_phy()
15776 bp->phy_flags = 0; in bnxt_probe_phy()
15779 netdev_err(bp->dev, "Probe phy can't get phy capabilities (rc: %x)\n", in bnxt_probe_phy()
15783 if (bp->phy_flags & BNXT_PHY_FL_NO_FCS) in bnxt_probe_phy()
15784 bp->dev->priv_flags |= IFF_SUPP_NOFCS; in bnxt_probe_phy()
15786 bp->dev->priv_flags &= ~IFF_SUPP_NOFCS; in bnxt_probe_phy()
15788 bp->mac_flags = 0; in bnxt_probe_phy()
15794 mutex_lock(&bp->link_lock); in bnxt_probe_phy()
15797 mutex_unlock(&bp->link_lock); in bnxt_probe_phy()
15798 netdev_err(bp->dev, "Probe phy can't update link (rc: %x)\n", in bnxt_probe_phy()
15806 if (link_info->auto_link_speeds && !link_info->support_auto_speeds) in bnxt_probe_phy()
15807 link_info->support_auto_speeds = link_info->support_speeds; in bnxt_probe_phy()
15810 mutex_unlock(&bp->link_lock); in bnxt_probe_phy()
15818 if (!pdev->msix_cap) in bnxt_get_max_irq()
15821 pci_read_config_word(pdev, pdev->msix_cap + PCI_MSIX_FLAGS, &ctrl); in bnxt_get_max_irq()
15828 struct bnxt_hw_resc *hw_resc = &bp->hw_resc; in _bnxt_get_max_rings()
15831 *max_tx = hw_resc->max_tx_rings; in _bnxt_get_max_rings()
15832 *max_rx = hw_resc->max_rx_rings; in _bnxt_get_max_rings()
15834 max_irq = min_t(int, bnxt_get_max_func_irqs(bp) - in _bnxt_get_max_rings()
15836 hw_resc->max_stat_ctxs - in _bnxt_get_max_rings()
15838 if (!(bp->flags & BNXT_FLAG_CHIP_P5_PLUS)) in _bnxt_get_max_rings()
15840 max_ring_grps = hw_resc->max_hw_ring_grps; in _bnxt_get_max_rings()
15842 *max_cp -= 1; in _bnxt_get_max_rings()
15843 *max_rx -= 2; in _bnxt_get_max_rings()
15845 if (bp->flags & BNXT_FLAG_AGG_RINGS) in _bnxt_get_max_rings()
15847 if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) { in _bnxt_get_max_rings()
15869 return -ENOMEM; in bnxt_get_max_rings()
15880 if (rc && (bp->flags & BNXT_FLAG_AGG_RINGS)) { in bnxt_get_dflt_rings()
15882 bp->flags &= ~BNXT_FLAG_AGG_RINGS; in bnxt_get_dflt_rings()
15886 bp->flags |= BNXT_FLAG_AGG_RINGS; in bnxt_get_dflt_rings()
15889 bp->flags |= BNXT_FLAG_NO_AGG_RINGS; in bnxt_get_dflt_rings()
15890 bp->dev->hw_features &= ~(NETIF_F_LRO | NETIF_F_GRO_HW); in bnxt_get_dflt_rings()
15891 bp->dev->features &= ~(NETIF_F_LRO | NETIF_F_GRO_HW); in bnxt_get_dflt_rings()
15895 if (bp->flags & BNXT_FLAG_ROCE_CAP) { in bnxt_get_dflt_rings()
15907 max_cp -= BNXT_MIN_ROCE_CP_RINGS; in bnxt_get_dflt_rings()
15908 max_irq -= BNXT_MIN_ROCE_CP_RINGS; in bnxt_get_dflt_rings()
15909 max_stat -= BNXT_MIN_ROCE_STAT_CTXS; in bnxt_get_dflt_rings()
15924 bp->cp_nr_rings = min_t(int, bp->tx_nr_rings_per_tc, bp->rx_nr_rings); in bnxt_trim_dflt_sh_rings()
15925 bp->rx_nr_rings = bp->cp_nr_rings; in bnxt_trim_dflt_sh_rings()
15926 bp->tx_nr_rings_per_tc = bp->cp_nr_rings; in bnxt_trim_dflt_sh_rings()
15927 bp->tx_nr_rings = bp->tx_nr_rings_per_tc; in bnxt_trim_dflt_sh_rings()
15939 bp->flags |= BNXT_FLAG_SHARED_RINGS; in bnxt_set_dflt_rings()
15941 /* Reduce default rings on multi-port cards so that total default in bnxt_set_dflt_rings()
15944 if (bp->port_count > 1) { in bnxt_set_dflt_rings()
15946 max_t(int, num_online_cpus() / bp->port_count, 1); in bnxt_set_dflt_rings()
15953 bp->rx_nr_rings = min_t(int, dflt_rings, max_rx_rings); in bnxt_set_dflt_rings()
15954 bp->tx_nr_rings_per_tc = min_t(int, dflt_rings, max_tx_rings); in bnxt_set_dflt_rings()
15958 bp->cp_nr_rings = bp->tx_nr_rings_per_tc + bp->rx_nr_rings; in bnxt_set_dflt_rings()
15959 bp->tx_nr_rings = bp->tx_nr_rings_per_tc; in bnxt_set_dflt_rings()
15961 avail_msix = bnxt_get_max_func_irqs(bp) - bp->cp_nr_rings; in bnxt_set_dflt_rings()
15963 int ulp_num_msix = min(avail_msix, bp->ulp_num_msix_want); in bnxt_set_dflt_rings()
15970 if (rc && rc != -ENODEV) in bnxt_set_dflt_rings()
15971 netdev_warn(bp->dev, "Unable to reserve tx rings\n"); in bnxt_set_dflt_rings()
15972 bp->tx_nr_rings_per_tc = bp->tx_nr_rings; in bnxt_set_dflt_rings()
15976 /* Rings may have been trimmed, re-reserve the trimmed rings. */ in bnxt_set_dflt_rings()
15979 if (rc && rc != -ENODEV) in bnxt_set_dflt_rings()
15980 netdev_warn(bp->dev, "2nd rings reservation failed.\n"); in bnxt_set_dflt_rings()
15981 bp->tx_nr_rings_per_tc = bp->tx_nr_rings; in bnxt_set_dflt_rings()
15984 bp->rx_nr_rings++; in bnxt_set_dflt_rings()
15985 bp->cp_nr_rings++; in bnxt_set_dflt_rings()
15988 bp->tx_nr_rings = 0; in bnxt_set_dflt_rings()
15989 bp->rx_nr_rings = 0; in bnxt_set_dflt_rings()
15998 if (bp->tx_nr_rings) in bnxt_init_dflt_ring_mode()
16005 if (BNXT_VF(bp) && rc == -ENODEV) in bnxt_init_dflt_ring_mode()
16006 netdev_err(bp->dev, "Cannot configure VF rings while PF is unavailable.\n"); in bnxt_init_dflt_ring_mode()
16008 netdev_err(bp->dev, "Not enough rings available.\n"); in bnxt_init_dflt_ring_mode()
16015 bp->tx_nr_rings_per_tc = bp->tx_nr_rings; in bnxt_init_dflt_ring_mode()
16031 if (netif_running(bp->dev)) in bnxt_restore_pf_fw_resources()
16039 if (netif_running(bp->dev)) { in bnxt_restore_pf_fw_resources()
16041 dev_close(bp->dev); in bnxt_restore_pf_fw_resources()
16054 eth_hw_addr_set(bp->dev, bp->pf.mac_addr); in bnxt_init_mac_addr()
16057 struct bnxt_vf_info *vf = &bp->vf; in bnxt_init_mac_addr()
16060 if (is_valid_ether_addr(vf->mac_addr)) { in bnxt_init_mac_addr()
16062 eth_hw_addr_set(bp->dev, vf->mac_addr); in bnxt_init_mac_addr()
16068 eth_hw_addr_random(bp->dev); in bnxt_init_mac_addr()
16070 rc = bnxt_approve_mac(bp, bp->dev->dev_addr, strict_approval); in bnxt_init_mac_addr()
16078 struct pci_dev *pdev = bp->pdev; in bnxt_vpd_read_info()
16094 size = min_t(int, kw_len, BNXT_VPD_FLD_LEN - 1); in bnxt_vpd_read_info()
16095 memcpy(bp->board_partno, &vpd_data[pos], size); in bnxt_vpd_read_info()
16104 size = min_t(int, kw_len, BNXT_VPD_FLD_LEN - 1); in bnxt_vpd_read_info()
16105 memcpy(bp->board_serialno, &vpd_data[pos], size); in bnxt_vpd_read_info()
16112 struct pci_dev *pdev = bp->pdev; in bnxt_pcie_dsn_get()
16117 netdev_info(bp->dev, "Unable to read adapter's DSN\n"); in bnxt_pcie_dsn_get()
16118 return -EOPNOTSUPP; in bnxt_pcie_dsn_get()
16123 bp->flags |= BNXT_FLAG_DSN_VALID; in bnxt_pcie_dsn_get()
16129 if (!bp->db_size) in bnxt_map_db_bar()
16130 return -ENODEV; in bnxt_map_db_bar()
16131 bp->bar1 = pci_iomap(bp->pdev, 2, bp->db_size); in bnxt_map_db_bar()
16132 if (!bp->bar1) in bnxt_map_db_bar()
16133 return -ENOMEM; in bnxt_map_db_bar()
16139 netdev_info(bp->dev, "%s found at mem %lx, node addr %pM\n", in bnxt_print_device_info()
16140 board_info[bp->board_idx].name, in bnxt_print_device_info()
16141 (long)pci_resource_start(bp->pdev, 0), bp->dev->dev_addr); in bnxt_print_device_info()
16143 pcie_print_link_status(bp->pdev); in bnxt_print_device_info()
16154 return -ENODEV; in bnxt_init_one()
16156 if (!pdev->msix_cap) { in bnxt_init_one()
16157 dev_err(&pdev->dev, "MSIX capability not found, aborting\n"); in bnxt_init_one()
16158 return -ENODEV; in bnxt_init_one()
16173 return -ENOMEM; in bnxt_init_one()
16176 bp->board_idx = ent->driver_data; in bnxt_init_one()
16177 bp->msg_enable = BNXT_DEF_MSG_ENABLE; in bnxt_init_one()
16180 if (bnxt_vf_pciid(bp->board_idx)) in bnxt_init_one()
16181 bp->flags |= BNXT_FLAG_VF; in bnxt_init_one()
16185 SET_NETDEV_DEVLINK_PORT(dev, &bp->dl_port); in bnxt_init_one()
16191 dev->netdev_ops = &bnxt_netdev_ops; in bnxt_init_one()
16192 dev->stat_ops = &bnxt_stat_ops; in bnxt_init_one()
16193 dev->watchdog_timeo = BNXT_TX_TIMEOUT; in bnxt_init_one()
16194 dev->ethtool_ops = &bnxt_ethtool_ops; in bnxt_init_one()
16201 mutex_init(&bp->hwrm_cmd_lock); in bnxt_init_one()
16202 mutex_init(&bp->link_lock); in bnxt_init_one()
16212 bp->flags |= BNXT_FLAG_CHIP_P5_PLUS; in bnxt_init_one()
16214 bp->flags |= BNXT_FLAG_CHIP_P7; in bnxt_init_one()
16227 dev_err(&pdev->dev, "Cannot map doorbell BAR rc = %d, aborting\n", in bnxt_init_one()
16232 dev->hw_features = NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM | NETIF_F_SG | in bnxt_init_one()
16239 if (bp->flags & BNXT_FLAG_UDP_GSO_CAP) in bnxt_init_one()
16240 dev->hw_features |= NETIF_F_GSO_UDP_L4; in bnxt_init_one()
16243 dev->hw_features |= NETIF_F_LRO; in bnxt_init_one()
16245 dev->hw_enc_features = in bnxt_init_one()
16251 if (bp->flags & BNXT_FLAG_UDP_GSO_CAP) in bnxt_init_one()
16252 dev->hw_enc_features |= NETIF_F_GSO_UDP_L4; in bnxt_init_one()
16253 if (bp->flags & BNXT_FLAG_CHIP_P7) in bnxt_init_one()
16254 dev->udp_tunnel_nic_info = &bnxt_udp_tunnels_p7; in bnxt_init_one()
16256 dev->udp_tunnel_nic_info = &bnxt_udp_tunnels; in bnxt_init_one()
16258 dev->gso_partial_features = NETIF_F_GSO_UDP_TUNNEL_CSUM | in bnxt_init_one()
16260 dev->vlan_features = dev->hw_features | NETIF_F_HIGHDMA; in bnxt_init_one()
16261 if (bp->fw_cap & BNXT_FW_CAP_VLAN_RX_STRIP) in bnxt_init_one()
16262 dev->hw_features |= BNXT_HW_FEATURE_VLAN_ALL_RX; in bnxt_init_one()
16263 if (bp->fw_cap & BNXT_FW_CAP_VLAN_TX_INSERT) in bnxt_init_one()
16264 dev->hw_features |= BNXT_HW_FEATURE_VLAN_ALL_TX; in bnxt_init_one()
16266 dev->hw_features |= NETIF_F_GRO_HW; in bnxt_init_one()
16267 dev->features |= dev->hw_features | NETIF_F_HIGHDMA; in bnxt_init_one()
16268 if (dev->features & NETIF_F_GRO_HW) in bnxt_init_one()
16269 dev->features &= ~NETIF_F_LRO; in bnxt_init_one()
16270 dev->priv_flags |= IFF_UNICAST_FLT; in bnxt_init_one()
16273 if (bp->tso_max_segs) in bnxt_init_one()
16274 netif_set_tso_max_segs(dev, bp->tso_max_segs); in bnxt_init_one()
16276 dev->xdp_features = NETDEV_XDP_ACT_BASIC | NETDEV_XDP_ACT_REDIRECT | in bnxt_init_one()
16280 init_waitqueue_head(&bp->sriov_cfg_wait); in bnxt_init_one()
16283 bp->gro_func = bnxt_gro_func_5730x; in bnxt_init_one()
16285 bp->gro_func = bnxt_gro_func_5731x; in bnxt_init_one()
16287 bp->gro_func = bnxt_gro_func_5750x; in bnxt_init_one()
16290 bp->flags |= BNXT_FLAG_DOUBLE_DB; in bnxt_init_one()
16294 dev_err(&pdev->dev, "Unable to initialize mac address.\n"); in bnxt_init_one()
16295 rc = -EADDRNOTAVAIL; in bnxt_init_one()
16301 rc = bnxt_pcie_dsn_get(bp, bp->dsn); in bnxt_init_one()
16304 /* MTU range: 60 - FW defined max */ in bnxt_init_one()
16305 dev->min_mtu = ETH_ZLEN; in bnxt_init_one()
16306 dev->max_mtu = bp->max_mtu; in bnxt_init_one()
16312 hw_resc = &bp->hw_resc; in bnxt_init_one()
16313 bp->max_fltr = hw_resc->max_rx_em_flows + hw_resc->max_rx_wm_flows + in bnxt_init_one()
16316 if (bp->max_fltr < BNXT_MAX_FLTR) in bnxt_init_one()
16317 bp->max_fltr = BNXT_MAX_FLTR; in bnxt_init_one()
16326 if (BNXT_VF(bp) && rc == -ENODEV) { in bnxt_init_one()
16327 netdev_err(bp->dev, "Cannot configure VF rings while PF is unavailable.\n"); in bnxt_init_one()
16329 netdev_err(bp->dev, "Not enough rings available.\n"); in bnxt_init_one()
16330 rc = -ENOMEM; in bnxt_init_one()
16339 if (dev->hw_features & BNXT_HW_FEATURE_VLAN_ALL_RX) in bnxt_init_one()
16340 bp->flags |= BNXT_FLAG_STRIP_VLAN; in bnxt_init_one()
16347 * limited MSIX, so we re-initialize the TX rings per TC. in bnxt_init_one()
16349 bp->tx_nr_rings_per_tc = bp->tx_nr_rings; in bnxt_init_one()
16356 dev_err(&pdev->dev, "Unable to create workqueue.\n"); in bnxt_init_one()
16357 rc = -ENOMEM; in bnxt_init_one()
16372 INIT_LIST_HEAD(&bp->usr_fltr_list); in bnxt_init_one()
16375 bp->rss_cap |= BNXT_RSS_CAP_MULTI_RSS_CTX; in bnxt_init_one()
16377 dev->queue_mgmt_ops = &bnxt_queue_mgmt_ops; in bnxt_init_one()
16405 kfree(bp->ptp_cfg); in bnxt_init_one()
16406 bp->ptp_cfg = NULL; in bnxt_init_one()
16407 kfree(bp->fw_health); in bnxt_init_one()
16408 bp->fw_health = NULL; in bnxt_init_one()
16412 kfree(bp->rss_indir_tbl); in bnxt_init_one()
16413 bp->rss_indir_tbl = NULL; in bnxt_init_one()
16441 pci_wake_from_d3(pdev, bp->wol); in bnxt_shutdown()
16465 pci_disable_device(bp->pdev); in bnxt_suspend()
16478 rc = pci_enable_device(bp->pdev); in bnxt_resume()
16480 netdev_err(dev, "Cannot re-enable PCI device during resume, err = %d\n", in bnxt_resume()
16484 pci_set_master(bp->pdev); in bnxt_resume()
16486 rc = -ENODEV; in bnxt_resume()
16491 rc = -EBUSY; in bnxt_resume()
16502 rc = -ENODEV; in bnxt_resume()
16505 if (bp->fw_crash_mem) in bnxt_resume()
16509 kfree(bp->ptp_cfg); in bnxt_resume()
16510 bp->ptp_cfg = NULL; in bnxt_resume()
16537 * bnxt_io_error_detected - called when PCI error is detected
16558 if (test_and_set_bit(BNXT_STATE_IN_FW_RESET, &bp->state)) { in bnxt_io_error_detected()
16559 netdev_err(bp->dev, "Firmware reset already in progress\n"); in bnxt_io_error_detected()
16573 set_bit(BNXT_STATE_PCI_CHANNEL_IO_FROZEN, &bp->state); in bnxt_io_error_detected()
16590 * bnxt_io_slot_reset - called after the pci bus has been reset.
16593 * Restart the card from scratch, as if from a cold-boot.
16607 netdev_info(bp->dev, "PCI Slot Reset\n"); in bnxt_io_slot_reset()
16609 if (!(bp->flags & BNXT_FLAG_CHIP_P5_PLUS) && in bnxt_io_slot_reset()
16610 test_bit(BNXT_STATE_PCI_CHANNEL_IO_FROZEN, &bp->state)) in bnxt_io_slot_reset()
16616 dev_err(&pdev->dev, in bnxt_io_slot_reset()
16617 "Cannot re-enable PCI device after reset.\n"); in bnxt_io_slot_reset()
16624 * As pci_restore_state() does not re-write the BARs if the in bnxt_io_slot_reset()
16629 &bp->state)) { in bnxt_io_slot_reset()
16632 pci_write_config_dword(bp->pdev, off, 0); in bnxt_io_slot_reset()
16640 /* In some PCIe AER scenarios, firmware may take up to in bnxt_io_slot_reset()
16651 dev_err(&pdev->dev, "Firmware not ready\n"); in bnxt_io_slot_reset()
16666 clear_bit(BNXT_STATE_IN_FW_RESET, &bp->state); in bnxt_io_slot_reset()
16674 * bnxt_io_resume - called when traffic can start flowing again.
16686 netdev_info(bp->dev, "PCI Slot Resume\n"); in bnxt_io_resume()