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

1 /* Broadcom NetXtreme-C/E network driver.
3 * Copyright (c) 2014-2016 Broadcom Corporation
4 * Copyright (c) 2016-2019 Broadcom Limited
25 #include <linux/dma-mapping.h>
56 #include <linux/hwmon-sysfs.h>
92 [BCM57301] = { "Broadcom BCM57301 NetXtreme-C 10Gb Ethernet" },
93 [BCM57302] = { "Broadcom BCM57302 NetXtreme-C 10Gb/25Gb Ethernet" },
94 [BCM57304] = { "Broadcom BCM57304 NetXtreme-C 10Gb/25Gb/40Gb/50Gb Ethernet" },
95 [BCM57417_NPAR] = { "Broadcom BCM57417 NetXtreme-E Ethernet Partition" },
97 [BCM57311] = { "Broadcom BCM57311 NetXtreme-C 10Gb Ethernet" },
98 [BCM57312] = { "Broadcom BCM57312 NetXtreme-C 10Gb/25Gb Ethernet" },
99 [BCM57402] = { "Broadcom BCM57402 NetXtreme-E 10Gb Ethernet" },
100 [BCM57404] = { "Broadcom BCM57404 NetXtreme-E 10Gb/25Gb Ethernet" },
101 [BCM57406] = { "Broadcom BCM57406 NetXtreme-E 10GBase-T Ethernet" },
102 [BCM57402_NPAR] = { "Broadcom BCM57402 NetXtreme-E Ethernet Partition" },
103 [BCM57407] = { "Broadcom BCM57407 NetXtreme-E 10GBase-T Ethernet" },
104 [BCM57412] = { "Broadcom BCM57412 NetXtreme-E 10Gb Ethernet" },
105 [BCM57414] = { "Broadcom BCM57414 NetXtreme-E 10Gb/25Gb Ethernet" },
106 [BCM57416] = { "Broadcom BCM57416 NetXtreme-E 10GBase-T Ethernet" },
107 [BCM57417] = { "Broadcom BCM57417 NetXtreme-E 10GBase-T Ethernet" },
108 [BCM57412_NPAR] = { "Broadcom BCM57412 NetXtreme-E Ethernet Partition" },
109 [BCM57314] = { "Broadcom BCM57314 NetXtreme-C 10Gb/25Gb/40Gb/50Gb Ethernet" },
110 [BCM57417_SFP] = { "Broadcom BCM57417 NetXtreme-E 10Gb/25Gb Ethernet" },
111 [BCM57416_SFP] = { "Broadcom BCM57416 NetXtreme-E 10Gb Ethernet" },
112 [BCM57404_NPAR] = { "Broadcom BCM57404 NetXtreme-E Ethernet Partition" },
113 [BCM57406_NPAR] = { "Broadcom BCM57406 NetXtreme-E Ethernet Partition" },
114 [BCM57407_SFP] = { "Broadcom BCM57407 NetXtreme-E 25Gb Ethernet" },
115 [BCM57407_NPAR] = { "Broadcom BCM57407 NetXtreme-E Ethernet Partition" },
116 [BCM57414_NPAR] = { "Broadcom BCM57414 NetXtreme-E Ethernet Partition" },
117 [BCM57416_NPAR] = { "Broadcom BCM57416 NetXtreme-E Ethernet Partition" },
118 [BCM57452] = { "Broadcom BCM57452 NetXtreme-E 10Gb/25Gb/40Gb/50Gb Ethernet" },
119 [BCM57454] = { "Broadcom BCM57454 NetXtreme-E 10Gb/25Gb/40Gb/50Gb/100Gb Ethernet" },
120 [BCM5745x_NPAR] = { "Broadcom BCM5745x NetXtreme-E Ethernet Partition" },
121 [BCM57508] = { "Broadcom BCM57508 NetXtreme-E 10Gb/25Gb/50Gb/100Gb/200Gb Ethernet" },
122 [BCM57504] = { "Broadcom BCM57504 NetXtreme-E 10Gb/25Gb/50Gb/100Gb/200Gb Ethernet" },
123 [BCM57502] = { "Broadcom BCM57502 NetXtreme-E 10Gb/25Gb/50Gb Ethernet" },
124 [BCM57508_NPAR] = { "Broadcom BCM57508 NetXtreme-E Ethernet Partition" },
125 [BCM57504_NPAR] = { "Broadcom BCM57504 NetXtreme-E Ethernet Partition" },
126 [BCM57502_NPAR] = { "Broadcom BCM57502 NetXtreme-E Ethernet Partition" },
127 [BCM58802] = { "Broadcom BCM58802 NetXtreme-S 10Gb/25Gb/40Gb/50Gb Ethernet" },
128 [BCM58804] = { "Broadcom BCM58804 NetXtreme-S 10Gb/25Gb/40Gb/50Gb/100Gb Ethernet" },
129 [BCM58808] = { "Broadcom BCM58808 NetXtreme-S 10Gb/25Gb/40Gb/50Gb/100Gb Ethernet" },
130 [NETXTREME_E_VF] = { "Broadcom NetXtreme-E Ethernet Virtual Function" },
131 [NETXTREME_C_VF] = { "Broadcom NetXtreme-C Ethernet Virtual Function" },
132 [NETXTREME_S_VF] = { "Broadcom NetXtreme-S Ethernet Virtual Function" },
133 [NETXTREME_C_VF_HV] = { "Broadcom NetXtreme-C Virtual Function for Hyper-V" },
134 [NETXTREME_E_VF_HV] = { "Broadcom NetXtreme-E Virtual Function for Hyper-V" },
135 [NETXTREME_E_P5_VF] = { "Broadcom BCM5750X NetXtreme-E Ethernet Virtual Function" },
136 [NETXTREME_E_P5_VF_HV] = { "Broadcom BCM5750X NetXtreme-E Virtual Function for Hyper-V" },
258 writel(DB_CP_FLAGS | RING_CMP(idx), (db)->doorbell)
261 bnxt_writeq(bp, (db)->db_key64 | DBR_TYPE_NQ | RING_CMP(idx), \
262 (db)->doorbell)
265 writel(DB_CP_REARM_FLAGS | RING_CMP(idx), (db)->doorbell)
268 bnxt_writeq(bp, (db)->db_key64 | DBR_TYPE_NQ_ARM | RING_CMP(idx),\
269 (db)->doorbell)
273 if (bp->flags & BNXT_FLAG_CHIP_P5) in bnxt_db_nq()
281 if (bp->flags & BNXT_FLAG_CHIP_P5) in bnxt_db_nq_arm()
289 if (bp->flags & BNXT_FLAG_CHIP_P5) in bnxt_db_cq()
290 bnxt_writeq(bp, db->db_key64 | DBR_TYPE_CQ_ARMALL | in bnxt_db_cq()
291 RING_CMP(idx), db->doorbell); in bnxt_db_cq()
298 if (!(test_bit(BNXT_STATE_IN_FW_RESET, &bp->state))) in bnxt_queue_fw_reset_work()
302 queue_delayed_work(bnxt_pf_wq, &bp->fw_reset_task, delay); in bnxt_queue_fw_reset_work()
304 schedule_delayed_work(&bp->fw_reset_task, delay); in bnxt_queue_fw_reset_work()
310 queue_work(bnxt_pf_wq, &bp->sp_task); in __bnxt_queue_sp_work()
312 schedule_work(&bp->sp_task); in __bnxt_queue_sp_work()
317 set_bit(event, &bp->sp_event); in bnxt_queue_sp_work()
323 if (!rxr->bnapi->in_reset) { in bnxt_sched_reset_rxr()
324 rxr->bnapi->in_reset = true; in bnxt_sched_reset_rxr()
325 if (bp->flags & BNXT_FLAG_CHIP_P5) in bnxt_sched_reset_rxr()
326 set_bit(BNXT_RESET_TASK_SP_EVENT, &bp->sp_event); in bnxt_sched_reset_rxr()
328 set_bit(BNXT_RST_RING_SP_EVENT, &bp->sp_event); in bnxt_sched_reset_rxr()
331 rxr->rx_next_cons = 0xffff; in bnxt_sched_reset_rxr()
337 struct bnxt_napi *bnapi = txr->bnapi; in bnxt_sched_reset_txr()
339 if (bnapi->tx_fault) in bnxt_sched_reset_txr()
342 netdev_err(bp->dev, "Invalid Tx completion (ring:%d tx_pkts:%d cons:%u prod:%u i:%d)", in bnxt_sched_reset_txr()
343 txr->txq_index, bnapi->tx_pkts, in bnxt_sched_reset_txr()
344 txr->tx_cons, txr->tx_prod, idx); in bnxt_sched_reset_txr()
346 bnapi->tx_fault = 1; in bnxt_sched_reset_txr()
376 if (!md_dst || md_dst->type != METADATA_HW_PORT_MUX) in bnxt_xmit_get_cfa_action()
379 return md_dst->u.port_info.port_id; in bnxt_xmit_get_cfa_action()
385 bnxt_db_write(bp, &txr->tx_db, prod); in bnxt_txr_db_kick()
386 txr->kick_pending = 0; in bnxt_txr_db_kick()
400 struct pci_dev *pdev = bp->pdev; in bnxt_start_xmit()
406 if (unlikely(i >= bp->tx_nr_rings)) { in bnxt_start_xmit()
413 txr = &bp->tx_ring[bp->tx_ring_map[i]]; in bnxt_start_xmit()
414 prod = txr->tx_prod; in bnxt_start_xmit()
417 if (unlikely(free_size < skb_shinfo(skb)->nr_frags + 2)) { in bnxt_start_xmit()
419 if (net_ratelimit() && txr->kick_pending) in bnxt_start_xmit()
423 bp->tx_wake_thresh)) in bnxt_start_xmit()
430 length = skb->len; in bnxt_start_xmit()
432 last_frag = skb_shinfo(skb)->nr_frags; in bnxt_start_xmit()
434 txbd = &txr->tx_desc_ring[TX_RING(prod)][TX_IDX(prod)]; in bnxt_start_xmit()
436 txbd->tx_bd_opaque = prod; in bnxt_start_xmit()
438 tx_buf = &txr->tx_buf_ring[prod]; in bnxt_start_xmit()
439 tx_buf->skb = skb; in bnxt_start_xmit()
440 tx_buf->nr_frags = last_frag; in bnxt_start_xmit()
450 if (skb->vlan_proto == htons(ETH_P_8021Q)) in bnxt_start_xmit()
454 if (unlikely(skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP)) { in bnxt_start_xmit()
455 struct bnxt_ptp_cfg *ptp = bp->ptp_cfg; in bnxt_start_xmit()
457 if (ptp && ptp->tx_tstamp_en && !skb_is_gso(skb) && in bnxt_start_xmit()
458 atomic_dec_if_positive(&ptp->tx_avail) >= 0) { in bnxt_start_xmit()
459 if (!bnxt_ptp_parse(skb, &ptp->tx_seqid, in bnxt_start_xmit()
460 &ptp->tx_hdr_off)) { in bnxt_start_xmit()
462 ptp->tx_hdr_off += VLAN_HLEN; in bnxt_start_xmit()
464 skb_shinfo(skb)->tx_flags |= SKBTX_IN_PROGRESS; in bnxt_start_xmit()
466 atomic_inc(&bp->ptp_cfg->tx_avail); in bnxt_start_xmit()
471 if (unlikely(skb->no_fcs)) in bnxt_start_xmit()
474 if (free_size == bp->tx_ring_size && length <= bp->tx_push_thresh && in bnxt_start_xmit()
476 struct tx_push_buffer *tx_push_buf = txr->tx_push; in bnxt_start_xmit()
477 struct tx_push_bd *tx_push = &tx_push_buf->push_bd; in bnxt_start_xmit()
478 struct tx_bd_ext *tx_push1 = &tx_push->txbd2; in bnxt_start_xmit()
479 void __iomem *db = txr->tx_db.doorbell; in bnxt_start_xmit()
480 void *pdata = tx_push_buf->data; in bnxt_start_xmit()
485 tx_push->tx_bd_len_flags_type = in bnxt_start_xmit()
493 if (skb->ip_summed == CHECKSUM_PARTIAL) in bnxt_start_xmit()
494 tx_push1->tx_bd_hsize_lflags = in bnxt_start_xmit()
497 tx_push1->tx_bd_hsize_lflags = 0; in bnxt_start_xmit()
499 tx_push1->tx_bd_cfa_meta = cpu_to_le32(vlan_tag_flags); in bnxt_start_xmit()
500 tx_push1->tx_bd_cfa_action = in bnxt_start_xmit()
504 end = PTR_ALIGN(end, 8) - 1; in bnxt_start_xmit()
510 skb_frag_t *frag = &skb_shinfo(skb)->frags[j]; in bnxt_start_xmit()
521 txbd->tx_bd_len_flags_type = tx_push->tx_bd_len_flags_type; in bnxt_start_xmit()
522 txbd->tx_bd_haddr = txr->data_mapping; in bnxt_start_xmit()
524 txbd = &txr->tx_desc_ring[TX_RING(prod)][TX_IDX(prod)]; in bnxt_start_xmit()
527 tx_push->doorbell = in bnxt_start_xmit()
529 WRITE_ONCE(txr->tx_prod, prod); in bnxt_start_xmit()
531 tx_buf->is_push = 1; in bnxt_start_xmit()
532 netdev_tx_sent_queue(txq, skb->len); in bnxt_start_xmit()
539 (push_len - 16) << 1); in bnxt_start_xmit()
549 pad = BNXT_MIN_PKT_SIZE - length; in bnxt_start_xmit()
556 mapping = dma_map_single(&pdev->dev, skb->data, len, DMA_TO_DEVICE); in bnxt_start_xmit()
558 if (unlikely(dma_mapping_error(&pdev->dev, mapping))) in bnxt_start_xmit()
565 txbd->tx_bd_haddr = cpu_to_le64(mapping); in bnxt_start_xmit()
569 &txr->tx_desc_ring[TX_RING(prod)][TX_IDX(prod)]; in bnxt_start_xmit()
571 txbd1->tx_bd_hsize_lflags = lflags; in bnxt_start_xmit()
575 if (skb->encapsulation) in bnxt_start_xmit()
580 txbd1->tx_bd_hsize_lflags |= cpu_to_le32(TX_BD_FLAGS_LSO | in bnxt_start_xmit()
582 (hdr_len << (TX_BD_HSIZE_SHIFT - 1))); in bnxt_start_xmit()
583 length = skb_shinfo(skb)->gso_size; in bnxt_start_xmit()
584 txbd1->tx_bd_mss = cpu_to_le32(length); in bnxt_start_xmit()
586 } else if (skb->ip_summed == CHECKSUM_PARTIAL) { in bnxt_start_xmit()
587 txbd1->tx_bd_hsize_lflags |= in bnxt_start_xmit()
589 txbd1->tx_bd_mss = 0; in bnxt_start_xmit()
594 dev_warn_ratelimited(&pdev->dev, "Dropped oversize %d bytes TX packet.\n", in bnxt_start_xmit()
595 skb->len); in bnxt_start_xmit()
600 txbd->tx_bd_len_flags_type = cpu_to_le32(flags); in bnxt_start_xmit()
602 txbd1->tx_bd_cfa_meta = cpu_to_le32(vlan_tag_flags); in bnxt_start_xmit()
603 txbd1->tx_bd_cfa_action = in bnxt_start_xmit()
606 skb_frag_t *frag = &skb_shinfo(skb)->frags[i]; in bnxt_start_xmit()
609 txbd = &txr->tx_desc_ring[TX_RING(prod)][TX_IDX(prod)]; in bnxt_start_xmit()
612 mapping = skb_frag_dma_map(&pdev->dev, frag, 0, len, in bnxt_start_xmit()
615 if (unlikely(dma_mapping_error(&pdev->dev, mapping))) in bnxt_start_xmit()
618 tx_buf = &txr->tx_buf_ring[prod]; in bnxt_start_xmit()
621 txbd->tx_bd_haddr = cpu_to_le64(mapping); in bnxt_start_xmit()
624 txbd->tx_bd_len_flags_type = cpu_to_le32(flags); in bnxt_start_xmit()
628 txbd->tx_bd_len_flags_type = in bnxt_start_xmit()
632 netdev_tx_sent_queue(txq, skb->len); in bnxt_start_xmit()
640 WRITE_ONCE(txr->tx_prod, prod); in bnxt_start_xmit()
645 txr->kick_pending = 1; in bnxt_start_xmit()
650 if (netdev_xmit_more() && !tx_buf->is_push) in bnxt_start_xmit()
654 bp->tx_wake_thresh); in bnxt_start_xmit()
660 atomic_inc(&bp->ptp_cfg->tx_avail); in bnxt_start_xmit()
665 prod = txr->tx_prod; in bnxt_start_xmit()
666 tx_buf = &txr->tx_buf_ring[prod]; in bnxt_start_xmit()
667 dma_unmap_single(&pdev->dev, dma_unmap_addr(tx_buf, mapping), in bnxt_start_xmit()
674 tx_buf = &txr->tx_buf_ring[prod]; in bnxt_start_xmit()
675 dma_unmap_page(&pdev->dev, dma_unmap_addr(tx_buf, mapping), in bnxt_start_xmit()
676 skb_frag_size(&skb_shinfo(skb)->frags[i]), in bnxt_start_xmit()
683 if (txr->kick_pending) in bnxt_start_xmit()
684 bnxt_txr_db_kick(bp, txr, txr->tx_prod); in bnxt_start_xmit()
685 txr->tx_buf_ring[txr->tx_prod].skb = NULL; in bnxt_start_xmit()
692 struct bnxt_tx_ring_info *txr = bnapi->tx_ring; in bnxt_tx_int()
693 struct netdev_queue *txq = netdev_get_tx_queue(bp->dev, txr->txq_index); in bnxt_tx_int()
694 u16 cons = txr->tx_cons; in bnxt_tx_int()
695 struct pci_dev *pdev = bp->pdev; in bnxt_tx_int()
696 int nr_pkts = bnapi->tx_pkts; in bnxt_tx_int()
705 tx_buf = &txr->tx_buf_ring[cons]; in bnxt_tx_int()
707 skb = tx_buf->skb; in bnxt_tx_int()
708 tx_buf->skb = NULL; in bnxt_tx_int()
715 tx_bytes += skb->len; in bnxt_tx_int()
717 if (tx_buf->is_push) { in bnxt_tx_int()
718 tx_buf->is_push = 0; in bnxt_tx_int()
722 dma_unmap_single(&pdev->dev, dma_unmap_addr(tx_buf, mapping), in bnxt_tx_int()
724 last = tx_buf->nr_frags; in bnxt_tx_int()
728 tx_buf = &txr->tx_buf_ring[cons]; in bnxt_tx_int()
730 &pdev->dev, in bnxt_tx_int()
732 skb_frag_size(&skb_shinfo(skb)->frags[j]), in bnxt_tx_int()
735 if (unlikely(skb_shinfo(skb)->tx_flags & SKBTX_IN_PROGRESS)) { in bnxt_tx_int()
736 if (bp->flags & BNXT_FLAG_CHIP_P5) { in bnxt_tx_int()
741 atomic_inc(&bp->ptp_cfg->tx_avail); in bnxt_tx_int()
751 bnapi->tx_pkts = 0; in bnxt_tx_int()
752 WRITE_ONCE(txr->tx_cons, cons); in bnxt_tx_int()
755 bnxt_tx_avail(bp, txr), bp->tx_wake_thresh, in bnxt_tx_int()
756 READ_ONCE(txr->dev_state) == BNXT_DEV_STATE_CLOSING); in bnxt_tx_int()
767 page = page_pool_dev_alloc_frag(rxr->page_pool, offset, in __bnxt_alloc_rx_page()
770 page = page_pool_dev_alloc_pages(rxr->page_pool); in __bnxt_alloc_rx_page()
784 struct pci_dev *pdev = bp->pdev; in __bnxt_alloc_rx_frag()
787 data = napi_alloc_frag(bp->rx_buf_size); in __bnxt_alloc_rx_frag()
789 data = netdev_alloc_frag(bp->rx_buf_size); in __bnxt_alloc_rx_frag()
793 *mapping = dma_map_single_attrs(&pdev->dev, data + bp->rx_dma_offset, in __bnxt_alloc_rx_frag()
794 bp->rx_buf_use_size, bp->rx_dir, in __bnxt_alloc_rx_frag()
797 if (dma_mapping_error(&pdev->dev, *mapping)) { in __bnxt_alloc_rx_frag()
807 struct rx_bd *rxbd = &rxr->rx_desc_ring[RX_RING(prod)][RX_IDX(prod)]; in bnxt_alloc_rx_data()
808 struct bnxt_sw_rx_bd *rx_buf = &rxr->rx_buf_ring[prod]; in bnxt_alloc_rx_data()
817 return -ENOMEM; in bnxt_alloc_rx_data()
819 mapping += bp->rx_dma_offset; in bnxt_alloc_rx_data()
820 rx_buf->data = page; in bnxt_alloc_rx_data()
821 rx_buf->data_ptr = page_address(page) + offset + bp->rx_offset; in bnxt_alloc_rx_data()
826 return -ENOMEM; in bnxt_alloc_rx_data()
828 rx_buf->data = data; in bnxt_alloc_rx_data()
829 rx_buf->data_ptr = data + bp->rx_offset; in bnxt_alloc_rx_data()
831 rx_buf->mapping = mapping; in bnxt_alloc_rx_data()
833 rxbd->rx_bd_haddr = cpu_to_le64(mapping); in bnxt_alloc_rx_data()
839 u16 prod = rxr->rx_prod; in bnxt_reuse_rx_data()
843 prod_rx_buf = &rxr->rx_buf_ring[prod]; in bnxt_reuse_rx_data()
844 cons_rx_buf = &rxr->rx_buf_ring[cons]; in bnxt_reuse_rx_data()
846 prod_rx_buf->data = data; in bnxt_reuse_rx_data()
847 prod_rx_buf->data_ptr = cons_rx_buf->data_ptr; in bnxt_reuse_rx_data()
849 prod_rx_buf->mapping = cons_rx_buf->mapping; in bnxt_reuse_rx_data()
851 prod_bd = &rxr->rx_desc_ring[RX_RING(prod)][RX_IDX(prod)]; in bnxt_reuse_rx_data()
852 cons_bd = &rxr->rx_desc_ring[RX_RING(cons)][RX_IDX(cons)]; in bnxt_reuse_rx_data()
854 prod_bd->rx_bd_haddr = cons_bd->rx_bd_haddr; in bnxt_reuse_rx_data()
859 u16 next, max = rxr->rx_agg_bmap_size; in bnxt_find_next_agg_idx()
861 next = find_next_zero_bit(rxr->rx_agg_bmap, max, idx); in bnxt_find_next_agg_idx()
863 next = find_first_zero_bit(rxr->rx_agg_bmap, max); in bnxt_find_next_agg_idx()
872 &rxr->rx_agg_desc_ring[RX_RING(prod)][RX_IDX(prod)]; in bnxt_alloc_rx_page()
876 u16 sw_prod = rxr->rx_sw_agg_prod; in bnxt_alloc_rx_page()
882 return -ENOMEM; in bnxt_alloc_rx_page()
884 if (unlikely(test_bit(sw_prod, rxr->rx_agg_bmap))) in bnxt_alloc_rx_page()
887 __set_bit(sw_prod, rxr->rx_agg_bmap); in bnxt_alloc_rx_page()
888 rx_agg_buf = &rxr->rx_agg_ring[sw_prod]; in bnxt_alloc_rx_page()
889 rxr->rx_sw_agg_prod = NEXT_RX_AGG(sw_prod); in bnxt_alloc_rx_page()
891 rx_agg_buf->page = page; in bnxt_alloc_rx_page()
892 rx_agg_buf->offset = offset; in bnxt_alloc_rx_page()
893 rx_agg_buf->mapping = mapping; in bnxt_alloc_rx_page()
894 rxbd->rx_bd_haddr = cpu_to_le64(mapping); in bnxt_alloc_rx_page()
895 rxbd->rx_bd_opaque = sw_prod; in bnxt_alloc_rx_page()
907 &cpr->cp_desc_ring[CP_RING(cp_cons)][CP_IDX(cp_cons)]; in bnxt_get_agg()
915 struct bnxt_tpa_info *tpa_info = &rxr->rx_tpa[agg_id]; in bnxt_get_tpa_agg_p5()
917 return &tpa_info->agg_arr[curr]; in bnxt_get_tpa_agg_p5()
923 struct bnxt_napi *bnapi = cpr->bnapi; in bnxt_reuse_rx_agg_bufs()
924 struct bnxt *bp = bnapi->bp; in bnxt_reuse_rx_agg_bufs()
925 struct bnxt_rx_ring_info *rxr = bnapi->rx_ring; in bnxt_reuse_rx_agg_bufs()
926 u16 prod = rxr->rx_agg_prod; in bnxt_reuse_rx_agg_bufs()
927 u16 sw_prod = rxr->rx_sw_agg_prod; in bnxt_reuse_rx_agg_bufs()
931 if ((bp->flags & BNXT_FLAG_CHIP_P5) && tpa) in bnxt_reuse_rx_agg_bufs()
945 cons = agg->rx_agg_cmp_opaque; in bnxt_reuse_rx_agg_bufs()
946 __clear_bit(cons, rxr->rx_agg_bmap); in bnxt_reuse_rx_agg_bufs()
948 if (unlikely(test_bit(sw_prod, rxr->rx_agg_bmap))) in bnxt_reuse_rx_agg_bufs()
951 __set_bit(sw_prod, rxr->rx_agg_bmap); in bnxt_reuse_rx_agg_bufs()
952 prod_rx_buf = &rxr->rx_agg_ring[sw_prod]; in bnxt_reuse_rx_agg_bufs()
953 cons_rx_buf = &rxr->rx_agg_ring[cons]; in bnxt_reuse_rx_agg_bufs()
956 * set cons_rx_buf->page to NULL first. in bnxt_reuse_rx_agg_bufs()
958 page = cons_rx_buf->page; in bnxt_reuse_rx_agg_bufs()
959 cons_rx_buf->page = NULL; in bnxt_reuse_rx_agg_bufs()
960 prod_rx_buf->page = page; in bnxt_reuse_rx_agg_bufs()
961 prod_rx_buf->offset = cons_rx_buf->offset; in bnxt_reuse_rx_agg_bufs()
963 prod_rx_buf->mapping = cons_rx_buf->mapping; in bnxt_reuse_rx_agg_bufs()
965 prod_bd = &rxr->rx_agg_desc_ring[RX_RING(prod)][RX_IDX(prod)]; in bnxt_reuse_rx_agg_bufs()
967 prod_bd->rx_bd_haddr = cpu_to_le64(cons_rx_buf->mapping); in bnxt_reuse_rx_agg_bufs()
968 prod_bd->rx_bd_opaque = sw_prod; in bnxt_reuse_rx_agg_bufs()
973 rxr->rx_agg_prod = prod; in bnxt_reuse_rx_agg_bufs()
974 rxr->rx_sw_agg_prod = sw_prod; in bnxt_reuse_rx_agg_bufs()
985 u16 prod = rxr->rx_prod; in bnxt_rx_multi_page_skb()
994 dma_addr -= bp->rx_dma_offset; in bnxt_rx_multi_page_skb()
995 dma_sync_single_for_cpu(&bp->pdev->dev, dma_addr, BNXT_RX_PAGE_SIZE, in bnxt_rx_multi_page_skb()
996 bp->rx_dir); in bnxt_rx_multi_page_skb()
997 skb = napi_build_skb(data_ptr - bp->rx_offset, BNXT_RX_PAGE_SIZE); in bnxt_rx_multi_page_skb()
999 page_pool_recycle_direct(rxr->page_pool, page); in bnxt_rx_multi_page_skb()
1003 skb_reserve(skb, bp->rx_offset); in bnxt_rx_multi_page_skb()
1019 u16 prod = rxr->rx_prod; in bnxt_rx_page_skb()
1028 dma_addr -= bp->rx_dma_offset; in bnxt_rx_page_skb()
1029 dma_sync_single_for_cpu(&bp->pdev->dev, dma_addr, BNXT_RX_PAGE_SIZE, in bnxt_rx_page_skb()
1030 bp->rx_dir); in bnxt_rx_page_skb()
1033 payload = eth_get_headlen(bp->dev, data_ptr, len); in bnxt_rx_page_skb()
1035 skb = napi_alloc_skb(&rxr->bnapi->napi, payload); in bnxt_rx_page_skb()
1037 page_pool_recycle_direct(rxr->page_pool, page); in bnxt_rx_page_skb()
1042 off = (void *)data_ptr - page_address(page); in bnxt_rx_page_skb()
1044 memcpy(skb->data - NET_IP_ALIGN, data_ptr - NET_IP_ALIGN, in bnxt_rx_page_skb()
1047 frag = &skb_shinfo(skb)->frags[0]; in bnxt_rx_page_skb()
1050 skb->data_len -= payload; in bnxt_rx_page_skb()
1051 skb->tail += payload; in bnxt_rx_page_skb()
1062 u16 prod = rxr->rx_prod; in bnxt_rx_skb()
1072 skb = napi_build_skb(data, bp->rx_buf_size); in bnxt_rx_skb()
1073 dma_unmap_single_attrs(&bp->pdev->dev, dma_addr, bp->rx_buf_use_size, in bnxt_rx_skb()
1074 bp->rx_dir, DMA_ATTR_WEAK_ORDERING); in bnxt_rx_skb()
1080 skb_reserve(skb, bp->rx_offset); in bnxt_rx_skb()
1091 struct bnxt_napi *bnapi = cpr->bnapi; in __bnxt_rx_agg_pages()
1092 struct pci_dev *pdev = bp->pdev; in __bnxt_rx_agg_pages()
1093 struct bnxt_rx_ring_info *rxr = bnapi->rx_ring; in __bnxt_rx_agg_pages()
1094 u16 prod = rxr->rx_agg_prod; in __bnxt_rx_agg_pages()
1098 if ((bp->flags & BNXT_FLAG_CHIP_P5) && tpa) in __bnxt_rx_agg_pages()
1102 skb_frag_t *frag = &shinfo->frags[i]; in __bnxt_rx_agg_pages()
1113 cons = agg->rx_agg_cmp_opaque; in __bnxt_rx_agg_pages()
1114 frag_len = (le32_to_cpu(agg->rx_agg_cmp_len_flags_type) & in __bnxt_rx_agg_pages()
1117 cons_rx_buf = &rxr->rx_agg_ring[cons]; in __bnxt_rx_agg_pages()
1118 skb_frag_fill_page_desc(frag, cons_rx_buf->page, in __bnxt_rx_agg_pages()
1119 cons_rx_buf->offset, frag_len); in __bnxt_rx_agg_pages()
1120 shinfo->nr_frags = i + 1; in __bnxt_rx_agg_pages()
1121 __clear_bit(cons, rxr->rx_agg_bmap); in __bnxt_rx_agg_pages()
1127 mapping = cons_rx_buf->mapping; in __bnxt_rx_agg_pages()
1128 page = cons_rx_buf->page; in __bnxt_rx_agg_pages()
1129 cons_rx_buf->page = NULL; in __bnxt_rx_agg_pages()
1135 --shinfo->nr_frags; in __bnxt_rx_agg_pages()
1136 cons_rx_buf->page = page; in __bnxt_rx_agg_pages()
1141 rxr->rx_agg_prod = prod; in __bnxt_rx_agg_pages()
1142 bnxt_reuse_rx_agg_bufs(cpr, idx, i, agg_bufs - i, tpa); in __bnxt_rx_agg_pages()
1146 dma_sync_single_for_cpu(&pdev->dev, mapping, BNXT_RX_PAGE_SIZE, in __bnxt_rx_agg_pages()
1147 bp->rx_dir); in __bnxt_rx_agg_pages()
1152 rxr->rx_agg_prod = prod; in __bnxt_rx_agg_pages()
1172 skb->data_len += total_frag_len; in bnxt_rx_agg_pages_skb()
1173 skb->len += total_frag_len; in bnxt_rx_agg_pages_skb()
1174 skb->truesize += BNXT_RX_PAGE_SIZE * agg_bufs; in bnxt_rx_agg_pages_skb()
1187 shinfo->nr_frags = 0; in bnxt_rx_agg_pages_xdp()
1193 shinfo->nr_frags = agg_bufs; in bnxt_rx_agg_pages_xdp()
1194 shinfo->xdp_frags_size = total_frag_len; in bnxt_rx_agg_pages_xdp()
1208 &cpr->cp_desc_ring[CP_RING(last)][CP_IDX(last)]; in bnxt_agg_bufs_valid()
1216 struct bnxt *bp = bnapi->bp; in bnxt_copy_skb()
1217 struct pci_dev *pdev = bp->pdev; in bnxt_copy_skb()
1220 skb = napi_alloc_skb(&bnapi->napi, len); in bnxt_copy_skb()
1224 dma_sync_single_for_cpu(&pdev->dev, mapping, bp->rx_copy_thresh, in bnxt_copy_skb()
1225 bp->rx_dir); in bnxt_copy_skb()
1227 memcpy(skb->data - NET_IP_ALIGN, data - NET_IP_ALIGN, in bnxt_copy_skb()
1230 dma_sync_single_for_device(&pdev->dev, mapping, bp->rx_copy_thresh, in bnxt_copy_skb()
1231 bp->rx_dir); in bnxt_copy_skb()
1247 agg_bufs = (le32_to_cpu(rxcmp->rx_cmp_misc_v1) & in bnxt_discard_rx()
1253 if (bp->flags & BNXT_FLAG_CHIP_P5) in bnxt_discard_rx()
1261 return -EBUSY; in bnxt_discard_rx()
1269 struct bnxt_tpa_idx_map *map = rxr->rx_tpa_idx_map; in bnxt_alloc_agg_idx()
1272 if (test_bit(idx, map->agg_idx_bmap)) in bnxt_alloc_agg_idx()
1273 idx = find_first_zero_bit(map->agg_idx_bmap, in bnxt_alloc_agg_idx()
1275 __set_bit(idx, map->agg_idx_bmap); in bnxt_alloc_agg_idx()
1276 map->agg_id_tbl[agg_id] = idx; in bnxt_alloc_agg_idx()
1282 struct bnxt_tpa_idx_map *map = rxr->rx_tpa_idx_map; in bnxt_free_agg_idx()
1284 __clear_bit(idx, map->agg_idx_bmap); in bnxt_free_agg_idx()
1289 struct bnxt_tpa_idx_map *map = rxr->rx_tpa_idx_map; in bnxt_lookup_agg_idx()
1291 return map->agg_id_tbl[agg_id]; in bnxt_lookup_agg_idx()
1304 if (bp->flags & BNXT_FLAG_CHIP_P5) { in bnxt_tpa_start()
1310 cons = tpa_start->rx_tpa_start_cmp_opaque; in bnxt_tpa_start()
1311 prod = rxr->rx_prod; in bnxt_tpa_start()
1312 cons_rx_buf = &rxr->rx_buf_ring[cons]; in bnxt_tpa_start()
1313 prod_rx_buf = &rxr->rx_buf_ring[prod]; in bnxt_tpa_start()
1314 tpa_info = &rxr->rx_tpa[agg_id]; in bnxt_tpa_start()
1316 if (unlikely(cons != rxr->rx_next_cons || in bnxt_tpa_start()
1318 netdev_warn(bp->dev, "TPA cons %x, expected cons %x, error code %x\n", in bnxt_tpa_start()
1319 cons, rxr->rx_next_cons, in bnxt_tpa_start()
1327 tpa_info->cfa_code = TPA_START_CFA_CODE(tpa_start1); in bnxt_tpa_start()
1328 prod_rx_buf->data = tpa_info->data; in bnxt_tpa_start()
1329 prod_rx_buf->data_ptr = tpa_info->data_ptr; in bnxt_tpa_start()
1331 mapping = tpa_info->mapping; in bnxt_tpa_start()
1332 prod_rx_buf->mapping = mapping; in bnxt_tpa_start()
1334 prod_bd = &rxr->rx_desc_ring[RX_RING(prod)][RX_IDX(prod)]; in bnxt_tpa_start()
1336 prod_bd->rx_bd_haddr = cpu_to_le64(mapping); in bnxt_tpa_start()
1338 tpa_info->data = cons_rx_buf->data; in bnxt_tpa_start()
1339 tpa_info->data_ptr = cons_rx_buf->data_ptr; in bnxt_tpa_start()
1340 cons_rx_buf->data = NULL; in bnxt_tpa_start()
1341 tpa_info->mapping = cons_rx_buf->mapping; in bnxt_tpa_start()
1343 tpa_info->len = in bnxt_tpa_start()
1344 le32_to_cpu(tpa_start->rx_tpa_start_cmp_len_flags_type) >> in bnxt_tpa_start()
1349 tpa_info->hash_type = PKT_HASH_TYPE_L4; in bnxt_tpa_start()
1350 tpa_info->gso_type = SKB_GSO_TCPV4; in bnxt_tpa_start()
1351 /* RSS profiles 1 and 3 with extract code 0 for inner 4-tuple */ in bnxt_tpa_start()
1353 tpa_info->gso_type = SKB_GSO_TCPV6; in bnxt_tpa_start()
1354 tpa_info->rss_hash = in bnxt_tpa_start()
1355 le32_to_cpu(tpa_start->rx_tpa_start_cmp_rss_hash); in bnxt_tpa_start()
1357 tpa_info->hash_type = PKT_HASH_TYPE_NONE; in bnxt_tpa_start()
1358 tpa_info->gso_type = 0; in bnxt_tpa_start()
1359 netif_warn(bp, rx_err, bp->dev, "TPA packet without valid hash\n"); in bnxt_tpa_start()
1361 tpa_info->flags2 = le32_to_cpu(tpa_start1->rx_tpa_start_cmp_flags2); in bnxt_tpa_start()
1362 tpa_info->metadata = le32_to_cpu(tpa_start1->rx_tpa_start_cmp_metadata); in bnxt_tpa_start()
1363 tpa_info->hdr_info = le32_to_cpu(tpa_start1->rx_tpa_start_cmp_hdr_info); in bnxt_tpa_start()
1364 tpa_info->agg_count = 0; in bnxt_tpa_start()
1366 rxr->rx_prod = NEXT_RX(prod); in bnxt_tpa_start()
1368 rxr->rx_next_cons = NEXT_RX(cons); in bnxt_tpa_start()
1369 cons_rx_buf = &rxr->rx_buf_ring[cons]; in bnxt_tpa_start()
1371 bnxt_reuse_rx_data(rxr, cons, cons_rx_buf->data); in bnxt_tpa_start()
1372 rxr->rx_prod = NEXT_RX(rxr->rx_prod); in bnxt_tpa_start()
1373 cons_rx_buf->data = NULL; in bnxt_tpa_start()
1388 struct iphdr *iph = (struct iphdr *)skb->data; in bnxt_gro_tunnel()
1390 if (iph->protocol == IPPROTO_UDP) in bnxt_gro_tunnel()
1393 struct ipv6hdr *iph = (struct ipv6hdr *)skb->data; in bnxt_gro_tunnel()
1395 if (iph->nexthdr == IPPROTO_UDP) in bnxt_gro_tunnel()
1399 if (uh->check) in bnxt_gro_tunnel()
1400 skb_shinfo(skb)->gso_type |= SKB_GSO_UDP_TUNNEL_CSUM; in bnxt_gro_tunnel()
1402 skb_shinfo(skb)->gso_type |= SKB_GSO_UDP_TUNNEL; in bnxt_gro_tunnel()
1415 u32 hdr_info = tpa_info->hdr_info; in bnxt_gro_func_5731x()
1428 __be16 proto = *((__be16 *)(skb->data + inner_ip_off - in bnxt_gro_func_5731x()
1429 ETH_HLEN - 2)); in bnxt_gro_func_5731x()
1440 inner_ip_off -= 4; in bnxt_gro_func_5731x()
1441 inner_mac_off -= 4; in bnxt_gro_func_5731x()
1442 outer_ip_off -= 4; in bnxt_gro_func_5731x()
1445 nw_off = inner_ip_off - ETH_HLEN; in bnxt_gro_func_5731x()
1447 if (tpa_info->flags2 & RX_TPA_START_CMP_FLAGS2_IP_TYPE) { in bnxt_gro_func_5731x()
1451 len = skb->len - skb_transport_offset(skb); in bnxt_gro_func_5731x()
1453 th->check = ~tcp_v6_check(len, &iph->saddr, &iph->daddr, 0); in bnxt_gro_func_5731x()
1458 len = skb->len - skb_transport_offset(skb); in bnxt_gro_func_5731x()
1460 th->check = ~tcp_v4_check(len, iph->saddr, iph->daddr, 0); in bnxt_gro_func_5731x()
1464 __be16 proto = *((__be16 *)(skb->data + outer_ip_off - in bnxt_gro_func_5731x()
1465 ETH_HLEN - 2)); in bnxt_gro_func_5731x()
1479 u32 hdr_info = tpa_info->hdr_info; in bnxt_gro_func_5750x()
1486 nw_off = inner_ip_off - ETH_HLEN; in bnxt_gro_func_5750x()
1488 iphdr_len = (tpa_info->flags2 & RX_TPA_START_CMP_FLAGS2_IP_TYPE) ? in bnxt_gro_func_5750x()
1493 __be16 proto = *((__be16 *)(skb->data + outer_ip_off - in bnxt_gro_func_5750x()
1494 ETH_HLEN - 2)); in bnxt_gro_func_5750x()
1516 if (tpa_info->gso_type == SKB_GSO_TCPV4) { in bnxt_gro_func_5730x()
1519 nw_off = payload_off - BNXT_IPV4_HDR_SIZE - tcp_opt_len - in bnxt_gro_func_5730x()
1524 len = skb->len - skb_transport_offset(skb); in bnxt_gro_func_5730x()
1526 th->check = ~tcp_v4_check(len, iph->saddr, iph->daddr, 0); in bnxt_gro_func_5730x()
1527 } else if (tpa_info->gso_type == SKB_GSO_TCPV6) { in bnxt_gro_func_5730x()
1530 nw_off = payload_off - BNXT_IPV6_HDR_SIZE - tcp_opt_len - in bnxt_gro_func_5730x()
1535 len = skb->len - skb_transport_offset(skb); in bnxt_gro_func_5730x()
1537 th->check = ~tcp_v6_check(len, &iph->saddr, &iph->daddr, 0); in bnxt_gro_func_5730x()
1544 bnxt_gro_tunnel(skb, skb->protocol); in bnxt_gro_func_5730x()
1563 NAPI_GRO_CB(skb)->count = segs; in bnxt_gro_skb()
1564 skb_shinfo(skb)->gso_size = in bnxt_gro_skb()
1565 le32_to_cpu(tpa_end1->rx_tpa_end_cmp_seg_len); in bnxt_gro_skb()
1566 skb_shinfo(skb)->gso_type = tpa_info->gso_type; in bnxt_gro_skb()
1567 if (bp->flags & BNXT_FLAG_CHIP_P5) in bnxt_gro_skb()
1571 skb = bp->gro_func(tpa_info, payload_off, TPA_END_GRO_TS(tpa_end), skb); in bnxt_gro_skb()
1579 * netdev (vf-rep or PF) the packet is destined to.
1585 /* if vf-rep dev is NULL, the must belongs to the PF */ in bnxt_get_pkt_dev()
1586 return dev ? dev : bp->dev; in bnxt_get_pkt_dev()
1596 struct bnxt_napi *bnapi = cpr->bnapi; in bnxt_tpa_end()
1597 struct bnxt_rx_ring_info *rxr = bnapi->rx_ring; in bnxt_tpa_end()
1607 if (unlikely(bnapi->in_reset)) { in bnxt_tpa_end()
1611 return ERR_PTR(-EBUSY); in bnxt_tpa_end()
1615 if (bp->flags & BNXT_FLAG_CHIP_P5) { in bnxt_tpa_end()
1619 tpa_info = &rxr->rx_tpa[agg_id]; in bnxt_tpa_end()
1620 if (unlikely(agg_bufs != tpa_info->agg_count)) { in bnxt_tpa_end()
1621 netdev_warn(bp->dev, "TPA end agg_buf %d != expected agg_bufs %d\n", in bnxt_tpa_end()
1622 agg_bufs, tpa_info->agg_count); in bnxt_tpa_end()
1623 agg_bufs = tpa_info->agg_count; in bnxt_tpa_end()
1625 tpa_info->agg_count = 0; in bnxt_tpa_end()
1629 gro = !!(bp->flags & BNXT_FLAG_GRO); in bnxt_tpa_end()
1633 tpa_info = &rxr->rx_tpa[agg_id]; in bnxt_tpa_end()
1637 return ERR_PTR(-EBUSY); in bnxt_tpa_end()
1644 data = tpa_info->data; in bnxt_tpa_end()
1645 data_ptr = tpa_info->data_ptr; in bnxt_tpa_end()
1647 len = tpa_info->len; in bnxt_tpa_end()
1648 mapping = tpa_info->mapping; in bnxt_tpa_end()
1653 netdev_warn(bp->dev, "TPA frags %d exceeded MAX_SKB_FRAGS %d\n", in bnxt_tpa_end()
1658 if (len <= bp->rx_copy_thresh) { in bnxt_tpa_end()
1662 cpr->sw_stats.rx.rx_oom_discards += 1; in bnxt_tpa_end()
1672 cpr->sw_stats.rx.rx_oom_discards += 1; in bnxt_tpa_end()
1676 tpa_info->data = new_data; in bnxt_tpa_end()
1677 tpa_info->data_ptr = new_data + bp->rx_offset; in bnxt_tpa_end()
1678 tpa_info->mapping = new_mapping; in bnxt_tpa_end()
1680 skb = napi_build_skb(data, bp->rx_buf_size); in bnxt_tpa_end()
1681 dma_unmap_single_attrs(&bp->pdev->dev, mapping, in bnxt_tpa_end()
1682 bp->rx_buf_use_size, bp->rx_dir, in bnxt_tpa_end()
1688 cpr->sw_stats.rx.rx_oom_discards += 1; in bnxt_tpa_end()
1691 skb_reserve(skb, bp->rx_offset); in bnxt_tpa_end()
1699 cpr->sw_stats.rx.rx_oom_discards += 1; in bnxt_tpa_end()
1704 skb->protocol = in bnxt_tpa_end()
1705 eth_type_trans(skb, bnxt_get_pkt_dev(bp, tpa_info->cfa_code)); in bnxt_tpa_end()
1707 if (tpa_info->hash_type != PKT_HASH_TYPE_NONE) in bnxt_tpa_end()
1708 skb_set_hash(skb, tpa_info->rss_hash, tpa_info->hash_type); in bnxt_tpa_end()
1710 if ((tpa_info->flags2 & RX_CMP_FLAGS2_META_FORMAT_VLAN) && in bnxt_tpa_end()
1711 (skb->dev->features & BNXT_HW_FEATURE_VLAN_ALL_RX)) { in bnxt_tpa_end()
1712 __be16 vlan_proto = htons(tpa_info->metadata >> in bnxt_tpa_end()
1714 u16 vtag = tpa_info->metadata & RX_CMP_FLAGS2_METADATA_TCI_MASK; in bnxt_tpa_end()
1725 if (likely(tpa_info->flags2 & RX_TPA_START_CMP_FLAGS2_L4_CS_CALC)) { in bnxt_tpa_end()
1726 skb->ip_summed = CHECKSUM_UNNECESSARY; in bnxt_tpa_end()
1727 skb->csum_level = in bnxt_tpa_end()
1728 (tpa_info->flags2 & RX_CMP_FLAGS2_T_L4_CS_CALC) >> 3; in bnxt_tpa_end()
1744 tpa_info = &rxr->rx_tpa[agg_id]; in bnxt_tpa_agg()
1745 BUG_ON(tpa_info->agg_count >= MAX_SKB_FRAGS); in bnxt_tpa_agg()
1746 tpa_info->agg_arr[tpa_info->agg_count++] = *rx_agg; in bnxt_tpa_agg()
1752 if (skb->dev != bp->dev) { in bnxt_deliver_skb()
1753 /* this packet belongs to a vf-rep */ in bnxt_deliver_skb()
1757 skb_record_rx_queue(skb, bnapi->index); in bnxt_deliver_skb()
1759 napi_gro_receive(&bnapi->napi, skb); in bnxt_deliver_skb()
1763 * 1 - 1 packet successfully received
1764 * 0 - successful TPA_START, packet not completed yet
1765 * -EBUSY - completion ring does not have all the agg buffers yet
1766 * -ENOMEM - packet aborted due to out of memory
1767 * -EIO - packet aborted due to hw error indicated in BD
1772 struct bnxt_napi *bnapi = cpr->bnapi; in bnxt_rx_pkt()
1773 struct bnxt_rx_ring_info *rxr = bnapi->rx_ring; in bnxt_rx_pkt()
1774 struct net_device *dev = bp->dev; in bnxt_rx_pkt()
1791 &cpr->cp_desc_ring[CP_RING(cp_cons)][CP_IDX(cp_cons)]; in bnxt_rx_pkt()
1803 &cpr->cp_desc_ring[CP_RING(cp_cons)][CP_IDX(cp_cons)]; in bnxt_rx_pkt()
1806 return -EBUSY; in bnxt_rx_pkt()
1812 prod = rxr->rx_prod; in bnxt_rx_pkt()
1827 return -EBUSY; in bnxt_rx_pkt()
1829 rc = -ENOMEM; in bnxt_rx_pkt()
1838 cons = rxcmp->rx_cmp_opaque; in bnxt_rx_pkt()
1839 if (unlikely(cons != rxr->rx_next_cons)) { in bnxt_rx_pkt()
1843 if (rxr->rx_next_cons != 0xffff) in bnxt_rx_pkt()
1844 netdev_warn(bp->dev, "RX cons %x != expected cons %x\n", in bnxt_rx_pkt()
1845 cons, rxr->rx_next_cons); in bnxt_rx_pkt()
1851 rx_buf = &rxr->rx_buf_ring[cons]; in bnxt_rx_pkt()
1852 data = rx_buf->data; in bnxt_rx_pkt()
1853 data_ptr = rx_buf->data_ptr; in bnxt_rx_pkt()
1856 misc = le32_to_cpu(rxcmp->rx_cmp_misc_v1); in bnxt_rx_pkt()
1861 return -EBUSY; in bnxt_rx_pkt()
1868 rx_buf->data = NULL; in bnxt_rx_pkt()
1869 if (rxcmp1->rx_cmp_cfa_code_errors_v2 & RX_CMP_L2_ERRORS) { in bnxt_rx_pkt()
1870 u32 rx_err = le32_to_cpu(rxcmp1->rx_cmp_cfa_code_errors_v2); in bnxt_rx_pkt()
1877 rc = -EIO; in bnxt_rx_pkt()
1879 bnapi->cp_ring.sw_stats.rx.rx_buf_errors++; in bnxt_rx_pkt()
1880 if (!(bp->flags & BNXT_FLAG_CHIP_P5) && in bnxt_rx_pkt()
1881 !(bp->fw_cap & BNXT_FW_CAP_RING_MONITOR)) { in bnxt_rx_pkt()
1882 netdev_warn_once(bp->dev, "RX buffer error %x\n", in bnxt_rx_pkt()
1890 flags = le32_to_cpu(rxcmp->rx_cmp_len_flags_type); in bnxt_rx_pkt()
1892 dma_addr = rx_buf->mapping; in bnxt_rx_pkt()
1901 cpr->sw_stats.rx.rx_oom_discards += 1; in bnxt_rx_pkt()
1902 rc = -ENOMEM; in bnxt_rx_pkt()
1916 if (len <= bp->rx_copy_thresh) { in bnxt_rx_pkt()
1927 cpr->sw_stats.rx.rx_oom_discards += 1; in bnxt_rx_pkt()
1928 rc = -ENOMEM; in bnxt_rx_pkt()
1934 if (rx_buf->data_ptr == data_ptr) in bnxt_rx_pkt()
1938 skb = bp->rx_skb_func(bp, rxr, cons, data, data_ptr, dma_addr, in bnxt_rx_pkt()
1941 cpr->sw_stats.rx.rx_oom_discards += 1; in bnxt_rx_pkt()
1942 rc = -ENOMEM; in bnxt_rx_pkt()
1951 cpr->sw_stats.rx.rx_oom_discards += 1; in bnxt_rx_pkt()
1952 rc = -ENOMEM; in bnxt_rx_pkt()
1956 skb = bnxt_xdp_build_skb(bp, skb, agg_bufs, rxr->page_pool, &xdp, rxcmp1); in bnxt_rx_pkt()
1960 cpr->sw_stats.rx.rx_oom_discards += 1; in bnxt_rx_pkt()
1961 rc = -ENOMEM; in bnxt_rx_pkt()
1971 /* RSS profiles 1 and 3 with extract code 0 for inner 4-tuple */ in bnxt_rx_pkt()
1974 skb_set_hash(skb, le32_to_cpu(rxcmp->rx_cmp_rss_hash), type); in bnxt_rx_pkt()
1978 skb->protocol = eth_type_trans(skb, bnxt_get_pkt_dev(bp, cfa_code)); in bnxt_rx_pkt()
1980 if ((rxcmp1->rx_cmp_flags2 & in bnxt_rx_pkt()
1982 (skb->dev->features & BNXT_HW_FEATURE_VLAN_ALL_RX)) { in bnxt_rx_pkt()
1983 u32 meta_data = le32_to_cpu(rxcmp1->rx_cmp_meta_data); in bnxt_rx_pkt()
1998 if (dev->features & NETIF_F_RXCSUM) { in bnxt_rx_pkt()
1999 skb->ip_summed = CHECKSUM_UNNECESSARY; in bnxt_rx_pkt()
2000 skb->csum_level = RX_CMP_ENCAP(rxcmp1); in bnxt_rx_pkt()
2003 if (rxcmp1->rx_cmp_cfa_code_errors_v2 & RX_CMP_L4_CS_ERR_BITS) { in bnxt_rx_pkt()
2004 if (dev->features & NETIF_F_RXCSUM) in bnxt_rx_pkt()
2005 bnapi->cp_ring.sw_stats.rx.rx_l4_csum_errors++; in bnxt_rx_pkt()
2010 RX_CMP_FLAGS_ITYPE_PTP_W_TS) || bp->ptp_all_rx_tstamp) { in bnxt_rx_pkt()
2011 if (bp->flags & BNXT_FLAG_CHIP_P5) { in bnxt_rx_pkt()
2012 u32 cmpl_ts = le32_to_cpu(rxcmp1->rx_cmp_timestamp); in bnxt_rx_pkt()
2016 struct bnxt_ptp_cfg *ptp = bp->ptp_cfg; in bnxt_rx_pkt()
2018 spin_lock_bh(&ptp->ptp_lock); in bnxt_rx_pkt()
2019 ns = timecounter_cyc2time(&ptp->tc, ts); in bnxt_rx_pkt()
2020 spin_unlock_bh(&ptp->ptp_lock); in bnxt_rx_pkt()
2023 skb_hwtstamps(skb)->hwtstamp = ns_to_ktime(ns); in bnxt_rx_pkt()
2031 cpr->rx_packets += 1; in bnxt_rx_pkt()
2032 cpr->rx_bytes += len; in bnxt_rx_pkt()
2035 rxr->rx_prod = NEXT_RX(prod); in bnxt_rx_pkt()
2036 rxr->rx_next_cons = NEXT_RX(cons); in bnxt_rx_pkt()
2060 &cpr->cp_desc_ring[CP_RING(cp_cons)][CP_IDX(cp_cons)]; in bnxt_force_rx_discard()
2065 &cpr->cp_desc_ring[CP_RING(cp_cons)][CP_IDX(cp_cons)]; in bnxt_force_rx_discard()
2068 return -EBUSY; in bnxt_force_rx_discard()
2076 rxcmp1->rx_cmp_cfa_code_errors_v2 |= in bnxt_force_rx_discard()
2082 tpa_end1->rx_tpa_end_cmp_errors_v2 |= in bnxt_force_rx_discard()
2086 if (rc && rc != -EBUSY) in bnxt_force_rx_discard()
2087 cpr->sw_stats.rx.rx_netpoll_discards += 1; in bnxt_force_rx_discard()
2093 struct bnxt_fw_health *fw_health = bp->fw_health; in bnxt_fw_health_readl()
2094 u32 reg = fw_health->regs[reg_idx]; in bnxt_fw_health_readl()
2101 pci_read_config_dword(bp->pdev, reg_off, &val); in bnxt_fw_health_readl()
2104 reg_off = fw_health->mapped_regs[reg_idx]; in bnxt_fw_health_readl()
2107 val = readl(bp->bar0 + reg_off); in bnxt_fw_health_readl()
2110 val = readl(bp->bar1 + reg_off); in bnxt_fw_health_readl()
2114 val &= fw_health->fw_reset_inprog_reg_mask; in bnxt_fw_health_readl()
2122 for (i = 0; i < bp->rx_nr_rings; i++) { in bnxt_agg_ring_id_to_grp_idx()
2123 u16 grp_idx = bp->rx_ring[i].bnapi->index; in bnxt_agg_ring_id_to_grp_idx()
2126 grp_info = &bp->grp_info[grp_idx]; in bnxt_agg_ring_id_to_grp_idx()
2127 if (grp_info->agg_fw_ring_id == ring_id) in bnxt_agg_ring_id_to_grp_idx()
2139 …netdev_err(bp->dev, "1PPS: Received invalid signal on pin%lu from the external source. Please fix … in bnxt_event_error_report()
2143 netdev_warn(bp->dev, "Pause Storm detected!\n"); in bnxt_event_error_report()
2146 netdev_warn(bp->dev, "One or more MMIO doorbells dropped by the device!\n"); in bnxt_event_error_report()
2149 netdev_err(bp->dev, "FW reported unknown error type %u\n", in bnxt_event_error_report()
2180 u16 event_id = le16_to_cpu(cmpl->event_id); in bnxt_async_event_process()
2181 u32 data1 = le32_to_cpu(cmpl->event_data1); in bnxt_async_event_process()
2182 u32 data2 = le32_to_cpu(cmpl->event_data2); in bnxt_async_event_process()
2184 netdev_dbg(bp->dev, "hwrm event 0x%x {0x%x, 0x%x}\n", in bnxt_async_event_process()
2190 struct bnxt_link_info *link_info = &bp->link_info; in bnxt_async_event_process()
2196 if (!(link_info->autoneg & BNXT_AUTONEG_SPEED) && in bnxt_async_event_process()
2198 u16 fw_speed = link_info->force_link_speed; in bnxt_async_event_process()
2202 netdev_warn(bp->dev, "Link speed %d no longer supported\n", in bnxt_async_event_process()
2205 set_bit(BNXT_LINK_SPEED_CHNG_SP_EVENT, &bp->sp_event); in bnxt_async_event_process()
2210 set_bit(BNXT_LINK_CFG_CHANGE_SP_EVENT, &bp->sp_event); in bnxt_async_event_process()
2213 set_bit(BNXT_LINK_CHNG_SP_EVENT, &bp->sp_event); in bnxt_async_event_process()
2216 set_bit(BNXT_HWRM_PF_UNLOAD_SP_EVENT, &bp->sp_event); in bnxt_async_event_process()
2224 if (bp->pf.port_id != port_id) in bnxt_async_event_process()
2227 set_bit(BNXT_HWRM_PORT_MODULE_SP_EVENT, &bp->sp_event); in bnxt_async_event_process()
2233 set_bit(BNXT_RESET_TASK_SILENT_SP_EVENT, &bp->sp_event); in bnxt_async_event_process()
2238 if (!bp->fw_health) in bnxt_async_event_process()
2241 bp->fw_reset_timestamp = jiffies; in bnxt_async_event_process()
2242 bp->fw_reset_min_dsecs = cmpl->timestamp_lo; in bnxt_async_event_process()
2243 if (!bp->fw_reset_min_dsecs) in bnxt_async_event_process()
2244 bp->fw_reset_min_dsecs = BNXT_DFLT_FW_RST_MIN_DSECS; in bnxt_async_event_process()
2245 bp->fw_reset_max_dsecs = le16_to_cpu(cmpl->timestamp_hi); in bnxt_async_event_process()
2246 if (!bp->fw_reset_max_dsecs) in bnxt_async_event_process()
2247 bp->fw_reset_max_dsecs = BNXT_DFLT_FW_RST_MAX_DSECS; in bnxt_async_event_process()
2249 set_bit(BNXT_STATE_FW_ACTIVATE_RESET, &bp->state); in bnxt_async_event_process()
2252 bp->fw_health->fatalities++; in bnxt_async_event_process()
2253 set_bit(BNXT_STATE_FW_FATAL_COND, &bp->state); in bnxt_async_event_process()
2256 type_str = "Non-fatal"; in bnxt_async_event_process()
2257 bp->fw_health->survivals++; in bnxt_async_event_process()
2258 set_bit(BNXT_STATE_FW_NON_FATAL_COND, &bp->state); in bnxt_async_event_process()
2260 netif_warn(bp, hw, bp->dev, in bnxt_async_event_process()
2263 bp->fw_reset_min_dsecs * 100, in bnxt_async_event_process()
2264 bp->fw_reset_max_dsecs * 100); in bnxt_async_event_process()
2265 set_bit(BNXT_FW_RESET_NOTIFY_SP_EVENT, &bp->sp_event); in bnxt_async_event_process()
2269 struct bnxt_fw_health *fw_health = bp->fw_health; in bnxt_async_event_process()
2277 fw_health->enabled = false; in bnxt_async_event_process()
2278 netif_info(bp, drv, bp->dev, "Driver recovery watchdog is disabled\n"); in bnxt_async_event_process()
2281 fw_health->primary = EVENT_DATA1_RECOVERY_MASTER_FUNC(data1); in bnxt_async_event_process()
2282 fw_health->tmr_multiplier = in bnxt_async_event_process()
2283 DIV_ROUND_UP(fw_health->polling_dsecs * HZ, in bnxt_async_event_process()
2284 bp->current_interval * 10); in bnxt_async_event_process()
2285 fw_health->tmr_counter = fw_health->tmr_multiplier; in bnxt_async_event_process()
2286 if (!fw_health->enabled) in bnxt_async_event_process()
2287 fw_health->last_fw_heartbeat = in bnxt_async_event_process()
2289 fw_health->last_fw_reset_cnt = in bnxt_async_event_process()
2294 netif_info(bp, drv, bp->dev, in bnxt_async_event_process()
2296 fw_health->primary ? "primary" : "backup", status, in bnxt_async_event_process()
2297 status_desc, fw_health->last_fw_reset_cnt); in bnxt_async_event_process()
2298 if (!fw_health->enabled) { in bnxt_async_event_process()
2303 fw_health->enabled = true; in bnxt_async_event_process()
2308 netif_notice(bp, hw, bp->dev, in bnxt_async_event_process()
2316 if (bp->flags & BNXT_FLAG_CHIP_P5) in bnxt_async_event_process()
2319 netdev_warn(bp->dev, "Ring monitor event, ring type %lu id 0x%x\n", in bnxt_async_event_process()
2326 netdev_warn(bp->dev, "Unknown RX agg ring id 0x%x\n", in bnxt_async_event_process()
2330 rxr = bp->bnapi[grp_idx]->rx_ring; in bnxt_async_event_process()
2335 struct bnxt_fw_health *fw_health = bp->fw_health; in bnxt_async_event_process()
2337 netif_notice(bp, hw, bp->dev, in bnxt_async_event_process()
2341 fw_health->echo_req_data1 = data1; in bnxt_async_event_process()
2342 fw_health->echo_req_data2 = data2; in bnxt_async_event_process()
2343 set_bit(BNXT_FW_ECHO_REQUEST_SP_EVENT, &bp->sp_event); in bnxt_async_event_process()
2360 struct bnxt_ptp_cfg *ptp = bp->ptp_cfg; in bnxt_async_event_process()
2366 spin_lock_bh(&ptp->ptp_lock); in bnxt_async_event_process()
2369 BNXT_PHC_BITS) | ptp->current_time); in bnxt_async_event_process()
2371 spin_unlock_bh(&ptp->ptp_lock); in bnxt_async_event_process()
2378 u16 seq_id = le32_to_cpu(cmpl->event_data2) & 0xffff; in bnxt_async_event_process()
2400 seq_id = le16_to_cpu(h_cmpl->sequence_id); in bnxt_hwrm_handler()
2405 vf_id = le16_to_cpu(fwd_req_cmpl->source_id); in bnxt_hwrm_handler()
2407 if ((vf_id < bp->pf.first_vf_id) || in bnxt_hwrm_handler()
2408 (vf_id >= bp->pf.first_vf_id + bp->pf.active_vfs)) { in bnxt_hwrm_handler()
2409 netdev_err(bp->dev, "Msg contains invalid VF id %x\n", in bnxt_hwrm_handler()
2411 return -EINVAL; in bnxt_hwrm_handler()
2414 set_bit(vf_id - bp->pf.first_vf_id, bp->pf.vf_event_bmap); in bnxt_hwrm_handler()
2433 struct bnxt *bp = bnapi->bp; in bnxt_msix()
2434 struct bnxt_cp_ring_info *cpr = &bnapi->cp_ring; in bnxt_msix()
2435 u32 cons = RING_CMP(cpr->cp_raw_cons); in bnxt_msix()
2437 cpr->event_ctr++; in bnxt_msix()
2438 prefetch(&cpr->cp_desc_ring[CP_RING(cons)][CP_IDX(cons)]); in bnxt_msix()
2439 napi_schedule(&bnapi->napi); in bnxt_msix()
2445 u32 raw_cons = cpr->cp_raw_cons; in bnxt_has_work()
2449 txcmp = &cpr->cp_desc_ring[CP_RING(cons)][CP_IDX(cons)]; in bnxt_has_work()
2457 struct bnxt *bp = bnapi->bp; in bnxt_inta()
2458 struct bnxt_cp_ring_info *cpr = &bnapi->cp_ring; in bnxt_inta()
2459 u32 cons = RING_CMP(cpr->cp_raw_cons); in bnxt_inta()
2462 prefetch(&cpr->cp_desc_ring[CP_RING(cons)][CP_IDX(cons)]); in bnxt_inta()
2465 int_status = readl(bp->bar0 + BNXT_CAG_REG_LEGACY_INT_STATUS); in bnxt_inta()
2467 if (!(int_status & (0x10000 << cpr->cp_ring_struct.fw_ring_id))) in bnxt_inta()
2472 BNXT_CP_DB_IRQ_DIS(cpr->cp_db.doorbell); in bnxt_inta()
2475 if (unlikely(atomic_read(&bp->intr_sem) != 0)) in bnxt_inta()
2478 napi_schedule(&bnapi->napi); in bnxt_inta()
2485 struct bnxt_napi *bnapi = cpr->bnapi; in __bnxt_poll_work()
2486 u32 raw_cons = cpr->cp_raw_cons; in __bnxt_poll_work()
2493 cpr->has_more_work = 0; in __bnxt_poll_work()
2494 cpr->had_work_done = 1; in __bnxt_poll_work()
2499 txcmp = &cpr->cp_desc_ring[CP_RING(cons)][CP_IDX(cons)]; in __bnxt_poll_work()
2511 if (unlikely(tx_pkts >= bp->tx_wake_thresh)) { in __bnxt_poll_work()
2515 cpr->has_more_work = 1; in __bnxt_poll_work()
2526 /* Increment rx_pkts when rc is -ENOMEM to count towards in __bnxt_poll_work()
2531 else if (rc == -ENOMEM && budget) in __bnxt_poll_work()
2533 else if (rc == -EBUSY) /* partial completion */ in __bnxt_poll_work()
2546 cpr->has_more_work = 1; in __bnxt_poll_work()
2555 struct bnxt_tx_ring_info *txr = bnapi->tx_ring; in __bnxt_poll_work()
2556 u16 prod = txr->tx_prod; in __bnxt_poll_work()
2561 bnxt_db_write_relaxed(bp, &txr->tx_db, prod); in __bnxt_poll_work()
2564 cpr->cp_raw_cons = raw_cons; in __bnxt_poll_work()
2565 bnapi->tx_pkts += tx_pkts; in __bnxt_poll_work()
2566 bnapi->events |= event; in __bnxt_poll_work()
2573 if (bnapi->tx_pkts && !bnapi->tx_fault) in __bnxt_poll_work_done()
2574 bnapi->tx_int(bp, bnapi, budget); in __bnxt_poll_work_done()
2576 if ((bnapi->events & BNXT_RX_EVENT) && !(bnapi->in_reset)) { in __bnxt_poll_work_done()
2577 struct bnxt_rx_ring_info *rxr = bnapi->rx_ring; in __bnxt_poll_work_done()
2579 bnxt_db_write(bp, &rxr->rx_db, rxr->rx_prod); in __bnxt_poll_work_done()
2581 if (bnapi->events & BNXT_AGG_EVENT) { in __bnxt_poll_work_done()
2582 struct bnxt_rx_ring_info *rxr = bnapi->rx_ring; in __bnxt_poll_work_done()
2584 bnxt_db_write(bp, &rxr->rx_agg_db, rxr->rx_agg_prod); in __bnxt_poll_work_done()
2586 bnapi->events = 0; in __bnxt_poll_work_done()
2592 struct bnxt_napi *bnapi = cpr->bnapi; in bnxt_poll_work()
2601 bnxt_db_cq(bp, &cpr->cp_db, cpr->cp_raw_cons); in bnxt_poll_work()
2610 struct bnxt *bp = bnapi->bp; in bnxt_poll_nitroa0()
2611 struct bnxt_cp_ring_info *cpr = &bnapi->cp_ring; in bnxt_poll_nitroa0()
2612 struct bnxt_rx_ring_info *rxr = bnapi->rx_ring; in bnxt_poll_nitroa0()
2616 u32 raw_cons = cpr->cp_raw_cons; in bnxt_poll_nitroa0()
2625 txcmp = &cpr->cp_desc_ring[CP_RING(cp_cons)][CP_IDX(cp_cons)]; in bnxt_poll_nitroa0()
2638 &cpr->cp_desc_ring[CP_RING(cp_cons)][CP_IDX(cp_cons)]; in bnxt_poll_nitroa0()
2644 rxcmp1->rx_cmp_cfa_code_errors_v2 |= in bnxt_poll_nitroa0()
2648 if (likely(rc == -EIO) && budget) in bnxt_poll_nitroa0()
2650 else if (rc == -EBUSY) /* partial completion */ in bnxt_poll_nitroa0()
2658 netdev_err(bp->dev, in bnxt_poll_nitroa0()
2667 cpr->cp_raw_cons = raw_cons; in bnxt_poll_nitroa0()
2668 BNXT_DB_CQ(&cpr->cp_db, cpr->cp_raw_cons); in bnxt_poll_nitroa0()
2669 bnxt_db_write(bp, &rxr->rx_db, rxr->rx_prod); in bnxt_poll_nitroa0()
2672 bnxt_db_write(bp, &rxr->rx_agg_db, rxr->rx_agg_prod); in bnxt_poll_nitroa0()
2678 BNXT_DB_CQ_ARM(&cpr->cp_db, cpr->cp_raw_cons); in bnxt_poll_nitroa0()
2686 struct bnxt *bp = bnapi->bp; in bnxt_poll()
2687 struct bnxt_cp_ring_info *cpr = &bnapi->cp_ring; in bnxt_poll()
2690 if (unlikely(test_bit(BNXT_STATE_FW_FATAL_COND, &bp->state))) { in bnxt_poll()
2695 work_done += bnxt_poll_work(bp, cpr, budget - work_done); in bnxt_poll()
2699 BNXT_DB_CQ_ARM(&cpr->cp_db, cpr->cp_raw_cons); in bnxt_poll()
2705 BNXT_DB_CQ_ARM(&cpr->cp_db, cpr->cp_raw_cons); in bnxt_poll()
2709 if (bp->flags & BNXT_FLAG_DIM) { in bnxt_poll()
2712 dim_update_sample(cpr->event_ctr, in bnxt_poll()
2713 cpr->rx_packets, in bnxt_poll()
2714 cpr->rx_bytes, in bnxt_poll()
2716 net_dim(&cpr->dim, dim_sample); in bnxt_poll()
2723 struct bnxt_cp_ring_info *cpr = &bnapi->cp_ring; in __bnxt_poll_cqs()
2727 struct bnxt_cp_ring_info *cpr2 = cpr->cp_ring_arr[i]; in __bnxt_poll_cqs()
2731 budget - work_done); in __bnxt_poll_cqs()
2732 cpr->has_more_work |= cpr2->has_more_work; in __bnxt_poll_cqs()
2741 struct bnxt_cp_ring_info *cpr = &bnapi->cp_ring; in __bnxt_poll_cqs_done()
2745 struct bnxt_cp_ring_info *cpr2 = cpr->cp_ring_arr[i]; in __bnxt_poll_cqs_done()
2748 if (cpr2 && cpr2->had_work_done) { in __bnxt_poll_cqs_done()
2749 db = &cpr2->cp_db; in __bnxt_poll_cqs_done()
2750 bnxt_writeq(bp, db->db_key64 | dbr_type | in __bnxt_poll_cqs_done()
2751 RING_CMP(cpr2->cp_raw_cons), db->doorbell); in __bnxt_poll_cqs_done()
2752 cpr2->had_work_done = 0; in __bnxt_poll_cqs_done()
2761 struct bnxt_cp_ring_info *cpr = &bnapi->cp_ring; in bnxt_poll_p5()
2763 u32 raw_cons = cpr->cp_raw_cons; in bnxt_poll_p5()
2764 struct bnxt *bp = bnapi->bp; in bnxt_poll_p5()
2769 if (unlikely(test_bit(BNXT_STATE_FW_FATAL_COND, &bp->state))) { in bnxt_poll_p5()
2773 if (cpr->has_more_work) { in bnxt_poll_p5()
2774 cpr->has_more_work = 0; in bnxt_poll_p5()
2779 nqcmp = &cpr->nq_desc_ring[CP_RING(cons)][CP_IDX(cons)]; in bnxt_poll_p5()
2782 if (cpr->has_more_work) in bnxt_poll_p5()
2787 cpr->cp_raw_cons = raw_cons; in bnxt_poll_p5()
2789 BNXT_DB_NQ_ARM_P5(&cpr->cp_db, in bnxt_poll_p5()
2790 cpr->cp_raw_cons); in bnxt_poll_p5()
2799 if (nqcmp->type == cpu_to_le16(NQ_CN_TYPE_CQ_NOTIFICATION)) { in bnxt_poll_p5()
2800 u32 idx = le32_to_cpu(nqcmp->cq_handle_low); in bnxt_poll_p5()
2807 cpr2 = cpr->cp_ring_arr[idx]; in bnxt_poll_p5()
2809 budget - work_done); in bnxt_poll_p5()
2810 cpr->has_more_work |= cpr2->has_more_work; in bnxt_poll_p5()
2817 if (raw_cons != cpr->cp_raw_cons) { in bnxt_poll_p5()
2818 cpr->cp_raw_cons = raw_cons; in bnxt_poll_p5()
2819 BNXT_DB_NQ_P5(&cpr->cp_db, raw_cons); in bnxt_poll_p5()
2822 cpr_rx = cpr->cp_ring_arr[BNXT_RX_HDL]; in bnxt_poll_p5()
2823 if (cpr_rx && (bp->flags & BNXT_FLAG_DIM)) { in bnxt_poll_p5()
2826 dim_update_sample(cpr->event_ctr, in bnxt_poll_p5()
2827 cpr_rx->rx_packets, in bnxt_poll_p5()
2828 cpr_rx->rx_bytes, in bnxt_poll_p5()
2830 net_dim(&cpr->dim, dim_sample); in bnxt_poll_p5()
2838 struct pci_dev *pdev = bp->pdev; in bnxt_free_tx_skbs()
2840 if (!bp->tx_ring) in bnxt_free_tx_skbs()
2843 max_idx = bp->tx_nr_pages * TX_DESC_CNT; in bnxt_free_tx_skbs()
2844 for (i = 0; i < bp->tx_nr_rings; i++) { in bnxt_free_tx_skbs()
2845 struct bnxt_tx_ring_info *txr = &bp->tx_ring[i]; in bnxt_free_tx_skbs()
2848 if (!txr->tx_buf_ring) in bnxt_free_tx_skbs()
2852 struct bnxt_sw_tx_bd *tx_buf = &txr->tx_buf_ring[j]; in bnxt_free_tx_skbs()
2856 if (i < bp->tx_nr_rings_xdp && in bnxt_free_tx_skbs()
2857 tx_buf->action == XDP_REDIRECT) { in bnxt_free_tx_skbs()
2858 dma_unmap_single(&pdev->dev, in bnxt_free_tx_skbs()
2862 xdp_return_frame(tx_buf->xdpf); in bnxt_free_tx_skbs()
2863 tx_buf->action = 0; in bnxt_free_tx_skbs()
2864 tx_buf->xdpf = NULL; in bnxt_free_tx_skbs()
2869 skb = tx_buf->skb; in bnxt_free_tx_skbs()
2875 tx_buf->skb = NULL; in bnxt_free_tx_skbs()
2877 if (tx_buf->is_push) { in bnxt_free_tx_skbs()
2883 dma_unmap_single(&pdev->dev, in bnxt_free_tx_skbs()
2888 last = tx_buf->nr_frags; in bnxt_free_tx_skbs()
2891 int ring_idx = j & bp->tx_ring_mask; in bnxt_free_tx_skbs()
2892 skb_frag_t *frag = &skb_shinfo(skb)->frags[k]; in bnxt_free_tx_skbs()
2894 tx_buf = &txr->tx_buf_ring[ring_idx]; in bnxt_free_tx_skbs()
2896 &pdev->dev, in bnxt_free_tx_skbs()
2902 netdev_tx_reset_queue(netdev_get_tx_queue(bp->dev, i)); in bnxt_free_tx_skbs()
2908 struct bnxt_rx_ring_info *rxr = &bp->rx_ring[ring_nr]; in bnxt_free_one_rx_ring_skbs()
2909 struct pci_dev *pdev = bp->pdev; in bnxt_free_one_rx_ring_skbs()
2913 max_idx = bp->rx_nr_pages * RX_DESC_CNT; in bnxt_free_one_rx_ring_skbs()
2914 max_agg_idx = bp->rx_agg_nr_pages * RX_DESC_CNT; in bnxt_free_one_rx_ring_skbs()
2915 if (!rxr->rx_tpa) in bnxt_free_one_rx_ring_skbs()
2918 for (i = 0; i < bp->max_tpa; i++) { in bnxt_free_one_rx_ring_skbs()
2919 struct bnxt_tpa_info *tpa_info = &rxr->rx_tpa[i]; in bnxt_free_one_rx_ring_skbs()
2920 u8 *data = tpa_info->data; in bnxt_free_one_rx_ring_skbs()
2925 dma_unmap_single_attrs(&pdev->dev, tpa_info->mapping, in bnxt_free_one_rx_ring_skbs()
2926 bp->rx_buf_use_size, bp->rx_dir, in bnxt_free_one_rx_ring_skbs()
2929 tpa_info->data = NULL; in bnxt_free_one_rx_ring_skbs()
2935 if (!rxr->rx_buf_ring) in bnxt_free_one_rx_ring_skbs()
2939 struct bnxt_sw_rx_bd *rx_buf = &rxr->rx_buf_ring[i]; in bnxt_free_one_rx_ring_skbs()
2940 dma_addr_t mapping = rx_buf->mapping; in bnxt_free_one_rx_ring_skbs()
2941 void *data = rx_buf->data; in bnxt_free_one_rx_ring_skbs()
2946 rx_buf->data = NULL; in bnxt_free_one_rx_ring_skbs()
2948 page_pool_recycle_direct(rxr->page_pool, data); in bnxt_free_one_rx_ring_skbs()
2950 dma_unmap_single_attrs(&pdev->dev, mapping, in bnxt_free_one_rx_ring_skbs()
2951 bp->rx_buf_use_size, bp->rx_dir, in bnxt_free_one_rx_ring_skbs()
2958 if (!rxr->rx_agg_ring) in bnxt_free_one_rx_ring_skbs()
2962 struct bnxt_sw_rx_agg_bd *rx_agg_buf = &rxr->rx_agg_ring[i]; in bnxt_free_one_rx_ring_skbs()
2963 struct page *page = rx_agg_buf->page; in bnxt_free_one_rx_ring_skbs()
2968 rx_agg_buf->page = NULL; in bnxt_free_one_rx_ring_skbs()
2969 __clear_bit(i, rxr->rx_agg_bmap); in bnxt_free_one_rx_ring_skbs()
2971 page_pool_recycle_direct(rxr->page_pool, page); in bnxt_free_one_rx_ring_skbs()
2975 map = rxr->rx_tpa_idx_map; in bnxt_free_one_rx_ring_skbs()
2977 memset(map->agg_idx_bmap, 0, sizeof(map->agg_idx_bmap)); in bnxt_free_one_rx_ring_skbs()
2984 if (!bp->rx_ring) in bnxt_free_rx_skbs()
2987 for (i = 0; i < bp->rx_nr_rings; i++) in bnxt_free_rx_skbs()
2999 u8 init_val = mem_init->init_val; in bnxt_init_ctx_mem()
3000 u16 offset = mem_init->offset; in bnxt_init_ctx_mem()
3010 for (i = 0; i < len; i += mem_init->size) in bnxt_init_ctx_mem()
3016 struct pci_dev *pdev = bp->pdev; in bnxt_free_ring()
3019 if (!rmem->pg_arr) in bnxt_free_ring()
3022 for (i = 0; i < rmem->nr_pages; i++) { in bnxt_free_ring()
3023 if (!rmem->pg_arr[i]) in bnxt_free_ring()
3026 dma_free_coherent(&pdev->dev, rmem->page_size, in bnxt_free_ring()
3027 rmem->pg_arr[i], rmem->dma_arr[i]); in bnxt_free_ring()
3029 rmem->pg_arr[i] = NULL; in bnxt_free_ring()
3032 if (rmem->pg_tbl) { in bnxt_free_ring()
3033 size_t pg_tbl_size = rmem->nr_pages * 8; in bnxt_free_ring()
3035 if (rmem->flags & BNXT_RMEM_USE_FULL_PAGE_FLAG) in bnxt_free_ring()
3036 pg_tbl_size = rmem->page_size; in bnxt_free_ring()
3037 dma_free_coherent(&pdev->dev, pg_tbl_size, in bnxt_free_ring()
3038 rmem->pg_tbl, rmem->pg_tbl_map); in bnxt_free_ring()
3039 rmem->pg_tbl = NULL; in bnxt_free_ring()
3041 if (rmem->vmem_size && *rmem->vmem) { in bnxt_free_ring()
3042 vfree(*rmem->vmem); in bnxt_free_ring()
3043 *rmem->vmem = NULL; in bnxt_free_ring()
3049 struct pci_dev *pdev = bp->pdev; in bnxt_alloc_ring()
3053 if (rmem->flags & (BNXT_RMEM_VALID_PTE_FLAG | BNXT_RMEM_RING_PTE_FLAG)) in bnxt_alloc_ring()
3055 if ((rmem->nr_pages > 1 || rmem->depth > 0) && !rmem->pg_tbl) { in bnxt_alloc_ring()
3056 size_t pg_tbl_size = rmem->nr_pages * 8; in bnxt_alloc_ring()
3058 if (rmem->flags & BNXT_RMEM_USE_FULL_PAGE_FLAG) in bnxt_alloc_ring()
3059 pg_tbl_size = rmem->page_size; in bnxt_alloc_ring()
3060 rmem->pg_tbl = dma_alloc_coherent(&pdev->dev, pg_tbl_size, in bnxt_alloc_ring()
3061 &rmem->pg_tbl_map, in bnxt_alloc_ring()
3063 if (!rmem->pg_tbl) in bnxt_alloc_ring()
3064 return -ENOMEM; in bnxt_alloc_ring()
3067 for (i = 0; i < rmem->nr_pages; i++) { in bnxt_alloc_ring()
3070 rmem->pg_arr[i] = dma_alloc_coherent(&pdev->dev, in bnxt_alloc_ring()
3071 rmem->page_size, in bnxt_alloc_ring()
3072 &rmem->dma_arr[i], in bnxt_alloc_ring()
3074 if (!rmem->pg_arr[i]) in bnxt_alloc_ring()
3075 return -ENOMEM; in bnxt_alloc_ring()
3077 if (rmem->mem_init) in bnxt_alloc_ring()
3078 bnxt_init_ctx_mem(rmem->mem_init, rmem->pg_arr[i], in bnxt_alloc_ring()
3079 rmem->page_size); in bnxt_alloc_ring()
3080 if (rmem->nr_pages > 1 || rmem->depth > 0) { in bnxt_alloc_ring()
3081 if (i == rmem->nr_pages - 2 && in bnxt_alloc_ring()
3082 (rmem->flags & BNXT_RMEM_RING_PTE_FLAG)) in bnxt_alloc_ring()
3084 else if (i == rmem->nr_pages - 1 && in bnxt_alloc_ring()
3085 (rmem->flags & BNXT_RMEM_RING_PTE_FLAG)) in bnxt_alloc_ring()
3087 rmem->pg_tbl[i] = in bnxt_alloc_ring()
3088 cpu_to_le64(rmem->dma_arr[i] | extra_bits); in bnxt_alloc_ring()
3092 if (rmem->vmem_size) { in bnxt_alloc_ring()
3093 *rmem->vmem = vzalloc(rmem->vmem_size); in bnxt_alloc_ring()
3094 if (!(*rmem->vmem)) in bnxt_alloc_ring()
3095 return -ENOMEM; in bnxt_alloc_ring()
3104 for (i = 0; i < bp->rx_nr_rings; i++) { in bnxt_free_tpa_info()
3105 struct bnxt_rx_ring_info *rxr = &bp->rx_ring[i]; in bnxt_free_tpa_info()
3107 kfree(rxr->rx_tpa_idx_map); in bnxt_free_tpa_info()
3108 rxr->rx_tpa_idx_map = NULL; in bnxt_free_tpa_info()
3109 if (rxr->rx_tpa) { in bnxt_free_tpa_info()
3110 for (j = 0; j < bp->max_tpa; j++) { in bnxt_free_tpa_info()
3111 kfree(rxr->rx_tpa[j].agg_arr); in bnxt_free_tpa_info()
3112 rxr->rx_tpa[j].agg_arr = NULL; in bnxt_free_tpa_info()
3115 kfree(rxr->rx_tpa); in bnxt_free_tpa_info()
3116 rxr->rx_tpa = NULL; in bnxt_free_tpa_info()
3124 bp->max_tpa = MAX_TPA; in bnxt_alloc_tpa_info()
3125 if (bp->flags & BNXT_FLAG_CHIP_P5) { in bnxt_alloc_tpa_info()
3126 if (!bp->max_tpa_v2) in bnxt_alloc_tpa_info()
3128 bp->max_tpa = max_t(u16, bp->max_tpa_v2, MAX_TPA_P5); in bnxt_alloc_tpa_info()
3131 for (i = 0; i < bp->rx_nr_rings; i++) { in bnxt_alloc_tpa_info()
3132 struct bnxt_rx_ring_info *rxr = &bp->rx_ring[i]; in bnxt_alloc_tpa_info()
3135 rxr->rx_tpa = kcalloc(bp->max_tpa, sizeof(struct bnxt_tpa_info), in bnxt_alloc_tpa_info()
3137 if (!rxr->rx_tpa) in bnxt_alloc_tpa_info()
3138 return -ENOMEM; in bnxt_alloc_tpa_info()
3140 if (!(bp->flags & BNXT_FLAG_CHIP_P5)) in bnxt_alloc_tpa_info()
3142 for (j = 0; j < bp->max_tpa; j++) { in bnxt_alloc_tpa_info()
3145 return -ENOMEM; in bnxt_alloc_tpa_info()
3146 rxr->rx_tpa[j].agg_arr = agg; in bnxt_alloc_tpa_info()
3148 rxr->rx_tpa_idx_map = kzalloc(sizeof(*rxr->rx_tpa_idx_map), in bnxt_alloc_tpa_info()
3150 if (!rxr->rx_tpa_idx_map) in bnxt_alloc_tpa_info()
3151 return -ENOMEM; in bnxt_alloc_tpa_info()
3160 if (!bp->rx_ring) in bnxt_free_rx_rings()
3164 for (i = 0; i < bp->rx_nr_rings; i++) { in bnxt_free_rx_rings()
3165 struct bnxt_rx_ring_info *rxr = &bp->rx_ring[i]; in bnxt_free_rx_rings()
3168 if (rxr->xdp_prog) in bnxt_free_rx_rings()
3169 bpf_prog_put(rxr->xdp_prog); in bnxt_free_rx_rings()
3171 if (xdp_rxq_info_is_reg(&rxr->xdp_rxq)) in bnxt_free_rx_rings()
3172 xdp_rxq_info_unreg(&rxr->xdp_rxq); in bnxt_free_rx_rings()
3174 page_pool_destroy(rxr->page_pool); in bnxt_free_rx_rings()
3175 rxr->page_pool = NULL; in bnxt_free_rx_rings()
3177 kfree(rxr->rx_agg_bmap); in bnxt_free_rx_rings()
3178 rxr->rx_agg_bmap = NULL; in bnxt_free_rx_rings()
3180 ring = &rxr->rx_ring_struct; in bnxt_free_rx_rings()
3181 bnxt_free_ring(bp, &ring->ring_mem); in bnxt_free_rx_rings()
3183 ring = &rxr->rx_agg_ring_struct; in bnxt_free_rx_rings()
3184 bnxt_free_ring(bp, &ring->ring_mem); in bnxt_free_rx_rings()
3193 pp.pool_size = bp->rx_agg_ring_size; in bnxt_alloc_rx_page_pool()
3195 pp.pool_size += bp->rx_ring_size; in bnxt_alloc_rx_page_pool()
3196 pp.nid = dev_to_node(&bp->pdev->dev); in bnxt_alloc_rx_page_pool()
3197 pp.napi = &rxr->bnapi->napi; in bnxt_alloc_rx_page_pool()
3198 pp.dev = &bp->pdev->dev; in bnxt_alloc_rx_page_pool()
3199 pp.dma_dir = bp->rx_dir; in bnxt_alloc_rx_page_pool()
3205 rxr->page_pool = page_pool_create(&pp); in bnxt_alloc_rx_page_pool()
3206 if (IS_ERR(rxr->page_pool)) { in bnxt_alloc_rx_page_pool()
3207 int err = PTR_ERR(rxr->page_pool); in bnxt_alloc_rx_page_pool()
3209 rxr->page_pool = NULL; in bnxt_alloc_rx_page_pool()
3219 if (!bp->rx_ring) in bnxt_alloc_rx_rings()
3220 return -ENOMEM; in bnxt_alloc_rx_rings()
3222 if (bp->flags & BNXT_FLAG_AGG_RINGS) in bnxt_alloc_rx_rings()
3225 for (i = 0; i < bp->rx_nr_rings; i++) { in bnxt_alloc_rx_rings()
3226 struct bnxt_rx_ring_info *rxr = &bp->rx_ring[i]; in bnxt_alloc_rx_rings()
3229 ring = &rxr->rx_ring_struct; in bnxt_alloc_rx_rings()
3235 rc = xdp_rxq_info_reg(&rxr->xdp_rxq, bp->dev, i, 0); in bnxt_alloc_rx_rings()
3239 rc = xdp_rxq_info_reg_mem_model(&rxr->xdp_rxq, in bnxt_alloc_rx_rings()
3241 rxr->page_pool); in bnxt_alloc_rx_rings()
3243 xdp_rxq_info_unreg(&rxr->xdp_rxq); in bnxt_alloc_rx_rings()
3247 rc = bnxt_alloc_ring(bp, &ring->ring_mem); in bnxt_alloc_rx_rings()
3251 ring->grp_idx = i; in bnxt_alloc_rx_rings()
3255 ring = &rxr->rx_agg_ring_struct; in bnxt_alloc_rx_rings()
3256 rc = bnxt_alloc_ring(bp, &ring->ring_mem); in bnxt_alloc_rx_rings()
3260 ring->grp_idx = i; in bnxt_alloc_rx_rings()
3261 rxr->rx_agg_bmap_size = bp->rx_agg_ring_mask + 1; in bnxt_alloc_rx_rings()
3262 mem_size = rxr->rx_agg_bmap_size / 8; in bnxt_alloc_rx_rings()
3263 rxr->rx_agg_bmap = kzalloc(mem_size, GFP_KERNEL); in bnxt_alloc_rx_rings()
3264 if (!rxr->rx_agg_bmap) in bnxt_alloc_rx_rings()
3265 return -ENOMEM; in bnxt_alloc_rx_rings()
3268 if (bp->flags & BNXT_FLAG_TPA) in bnxt_alloc_rx_rings()
3276 struct pci_dev *pdev = bp->pdev; in bnxt_free_tx_rings()
3278 if (!bp->tx_ring) in bnxt_free_tx_rings()
3281 for (i = 0; i < bp->tx_nr_rings; i++) { in bnxt_free_tx_rings()
3282 struct bnxt_tx_ring_info *txr = &bp->tx_ring[i]; in bnxt_free_tx_rings()
3285 if (txr->tx_push) { in bnxt_free_tx_rings()
3286 dma_free_coherent(&pdev->dev, bp->tx_push_size, in bnxt_free_tx_rings()
3287 txr->tx_push, txr->tx_push_mapping); in bnxt_free_tx_rings()
3288 txr->tx_push = NULL; in bnxt_free_tx_rings()
3291 ring = &txr->tx_ring_struct; in bnxt_free_tx_rings()
3293 bnxt_free_ring(bp, &ring->ring_mem); in bnxt_free_tx_rings()
3300 struct pci_dev *pdev = bp->pdev; in bnxt_alloc_tx_rings()
3302 bp->tx_push_size = 0; in bnxt_alloc_tx_rings()
3303 if (bp->tx_push_thresh) { in bnxt_alloc_tx_rings()
3307 bp->tx_push_thresh); in bnxt_alloc_tx_rings()
3311 bp->tx_push_thresh = 0; in bnxt_alloc_tx_rings()
3314 bp->tx_push_size = push_size; in bnxt_alloc_tx_rings()
3317 for (i = 0, j = 0; i < bp->tx_nr_rings; i++) { in bnxt_alloc_tx_rings()
3318 struct bnxt_tx_ring_info *txr = &bp->tx_ring[i]; in bnxt_alloc_tx_rings()
3322 ring = &txr->tx_ring_struct; in bnxt_alloc_tx_rings()
3324 rc = bnxt_alloc_ring(bp, &ring->ring_mem); in bnxt_alloc_tx_rings()
3328 ring->grp_idx = txr->bnapi->index; in bnxt_alloc_tx_rings()
3329 if (bp->tx_push_size) { in bnxt_alloc_tx_rings()
3332 /* One pre-allocated DMA buffer to backup in bnxt_alloc_tx_rings()
3335 txr->tx_push = dma_alloc_coherent(&pdev->dev, in bnxt_alloc_tx_rings()
3336 bp->tx_push_size, in bnxt_alloc_tx_rings()
3337 &txr->tx_push_mapping, in bnxt_alloc_tx_rings()
3340 if (!txr->tx_push) in bnxt_alloc_tx_rings()
3341 return -ENOMEM; in bnxt_alloc_tx_rings()
3343 mapping = txr->tx_push_mapping + in bnxt_alloc_tx_rings()
3345 txr->data_mapping = cpu_to_le64(mapping); in bnxt_alloc_tx_rings()
3347 qidx = bp->tc_to_qidx[j]; in bnxt_alloc_tx_rings()
3348 ring->queue_id = bp->q_info[qidx].queue_id; in bnxt_alloc_tx_rings()
3349 spin_lock_init(&txr->xdp_tx_lock); in bnxt_alloc_tx_rings()
3350 if (i < bp->tx_nr_rings_xdp) in bnxt_alloc_tx_rings()
3352 if (i % bp->tx_nr_rings_per_tc == (bp->tx_nr_rings_per_tc - 1)) in bnxt_alloc_tx_rings()
3360 struct bnxt_ring_struct *ring = &cpr->cp_ring_struct; in bnxt_free_cp_arrays()
3362 kfree(cpr->cp_desc_ring); in bnxt_free_cp_arrays()
3363 cpr->cp_desc_ring = NULL; in bnxt_free_cp_arrays()
3364 ring->ring_mem.pg_arr = NULL; in bnxt_free_cp_arrays()
3365 kfree(cpr->cp_desc_mapping); in bnxt_free_cp_arrays()
3366 cpr->cp_desc_mapping = NULL; in bnxt_free_cp_arrays()
3367 ring->ring_mem.dma_arr = NULL; in bnxt_free_cp_arrays()
3372 cpr->cp_desc_ring = kcalloc(n, sizeof(*cpr->cp_desc_ring), GFP_KERNEL); in bnxt_alloc_cp_arrays()
3373 if (!cpr->cp_desc_ring) in bnxt_alloc_cp_arrays()
3374 return -ENOMEM; in bnxt_alloc_cp_arrays()
3375 cpr->cp_desc_mapping = kcalloc(n, sizeof(*cpr->cp_desc_mapping), in bnxt_alloc_cp_arrays()
3377 if (!cpr->cp_desc_mapping) in bnxt_alloc_cp_arrays()
3378 return -ENOMEM; in bnxt_alloc_cp_arrays()
3386 if (!bp->bnapi) in bnxt_free_all_cp_arrays()
3388 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_free_all_cp_arrays()
3389 struct bnxt_napi *bnapi = bp->bnapi[i]; in bnxt_free_all_cp_arrays()
3393 bnxt_free_cp_arrays(&bnapi->cp_ring); in bnxt_free_all_cp_arrays()
3399 int i, n = bp->cp_nr_pages; in bnxt_alloc_all_cp_arrays()
3401 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_alloc_all_cp_arrays()
3402 struct bnxt_napi *bnapi = bp->bnapi[i]; in bnxt_alloc_all_cp_arrays()
3407 rc = bnxt_alloc_cp_arrays(&bnapi->cp_ring, n); in bnxt_alloc_all_cp_arrays()
3418 if (!bp->bnapi) in bnxt_free_cp_rings()
3421 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_free_cp_rings()
3422 struct bnxt_napi *bnapi = bp->bnapi[i]; in bnxt_free_cp_rings()
3430 cpr = &bnapi->cp_ring; in bnxt_free_cp_rings()
3431 ring = &cpr->cp_ring_struct; in bnxt_free_cp_rings()
3433 bnxt_free_ring(bp, &ring->ring_mem); in bnxt_free_cp_rings()
3436 struct bnxt_cp_ring_info *cpr2 = cpr->cp_ring_arr[j]; in bnxt_free_cp_rings()
3439 ring = &cpr2->cp_ring_struct; in bnxt_free_cp_rings()
3440 bnxt_free_ring(bp, &ring->ring_mem); in bnxt_free_cp_rings()
3443 cpr->cp_ring_arr[j] = NULL; in bnxt_free_cp_rings()
3460 rc = bnxt_alloc_cp_arrays(cpr, bp->cp_nr_pages); in bnxt_alloc_cp_sub_ring()
3466 ring = &cpr->cp_ring_struct; in bnxt_alloc_cp_sub_ring()
3467 rmem = &ring->ring_mem; in bnxt_alloc_cp_sub_ring()
3468 rmem->nr_pages = bp->cp_nr_pages; in bnxt_alloc_cp_sub_ring()
3469 rmem->page_size = HW_CMPD_RING_SIZE; in bnxt_alloc_cp_sub_ring()
3470 rmem->pg_arr = (void **)cpr->cp_desc_ring; in bnxt_alloc_cp_sub_ring()
3471 rmem->dma_arr = cpr->cp_desc_mapping; in bnxt_alloc_cp_sub_ring()
3472 rmem->flags = BNXT_RMEM_RING_PTE_FLAG; in bnxt_alloc_cp_sub_ring()
3485 bool sh = !!(bp->flags & BNXT_FLAG_SHARED_RINGS); in bnxt_alloc_cp_rings()
3490 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_alloc_cp_rings()
3491 struct bnxt_napi *bnapi = bp->bnapi[i]; in bnxt_alloc_cp_rings()
3498 cpr = &bnapi->cp_ring; in bnxt_alloc_cp_rings()
3499 cpr->bnapi = bnapi; in bnxt_alloc_cp_rings()
3500 ring = &cpr->cp_ring_struct; in bnxt_alloc_cp_rings()
3502 rc = bnxt_alloc_ring(bp, &ring->ring_mem); in bnxt_alloc_cp_rings()
3507 ring->map_idx = i + ulp_msix; in bnxt_alloc_cp_rings()
3509 ring->map_idx = i; in bnxt_alloc_cp_rings()
3511 if (!(bp->flags & BNXT_FLAG_CHIP_P5)) in bnxt_alloc_cp_rings()
3514 if (i < bp->rx_nr_rings) { in bnxt_alloc_cp_rings()
3518 cpr->cp_ring_arr[BNXT_RX_HDL] = cpr2; in bnxt_alloc_cp_rings()
3520 return -ENOMEM; in bnxt_alloc_cp_rings()
3521 cpr2->bnapi = bnapi; in bnxt_alloc_cp_rings()
3523 if ((sh && i < bp->tx_nr_rings) || in bnxt_alloc_cp_rings()
3524 (!sh && i >= bp->rx_nr_rings)) { in bnxt_alloc_cp_rings()
3528 cpr->cp_ring_arr[BNXT_TX_HDL] = cpr2; in bnxt_alloc_cp_rings()
3530 return -ENOMEM; in bnxt_alloc_cp_rings()
3531 cpr2->bnapi = bnapi; in bnxt_alloc_cp_rings()
3541 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_init_ring_struct()
3542 struct bnxt_napi *bnapi = bp->bnapi[i]; in bnxt_init_ring_struct()
3552 cpr = &bnapi->cp_ring; in bnxt_init_ring_struct()
3553 ring = &cpr->cp_ring_struct; in bnxt_init_ring_struct()
3554 rmem = &ring->ring_mem; in bnxt_init_ring_struct()
3555 rmem->nr_pages = bp->cp_nr_pages; in bnxt_init_ring_struct()
3556 rmem->page_size = HW_CMPD_RING_SIZE; in bnxt_init_ring_struct()
3557 rmem->pg_arr = (void **)cpr->cp_desc_ring; in bnxt_init_ring_struct()
3558 rmem->dma_arr = cpr->cp_desc_mapping; in bnxt_init_ring_struct()
3559 rmem->vmem_size = 0; in bnxt_init_ring_struct()
3561 rxr = bnapi->rx_ring; in bnxt_init_ring_struct()
3565 ring = &rxr->rx_ring_struct; in bnxt_init_ring_struct()
3566 rmem = &ring->ring_mem; in bnxt_init_ring_struct()
3567 rmem->nr_pages = bp->rx_nr_pages; in bnxt_init_ring_struct()
3568 rmem->page_size = HW_RXBD_RING_SIZE; in bnxt_init_ring_struct()
3569 rmem->pg_arr = (void **)rxr->rx_desc_ring; in bnxt_init_ring_struct()
3570 rmem->dma_arr = rxr->rx_desc_mapping; in bnxt_init_ring_struct()
3571 rmem->vmem_size = SW_RXBD_RING_SIZE * bp->rx_nr_pages; in bnxt_init_ring_struct()
3572 rmem->vmem = (void **)&rxr->rx_buf_ring; in bnxt_init_ring_struct()
3574 ring = &rxr->rx_agg_ring_struct; in bnxt_init_ring_struct()
3575 rmem = &ring->ring_mem; in bnxt_init_ring_struct()
3576 rmem->nr_pages = bp->rx_agg_nr_pages; in bnxt_init_ring_struct()
3577 rmem->page_size = HW_RXBD_RING_SIZE; in bnxt_init_ring_struct()
3578 rmem->pg_arr = (void **)rxr->rx_agg_desc_ring; in bnxt_init_ring_struct()
3579 rmem->dma_arr = rxr->rx_agg_desc_mapping; in bnxt_init_ring_struct()
3580 rmem->vmem_size = SW_RXBD_AGG_RING_SIZE * bp->rx_agg_nr_pages; in bnxt_init_ring_struct()
3581 rmem->vmem = (void **)&rxr->rx_agg_ring; in bnxt_init_ring_struct()
3584 txr = bnapi->tx_ring; in bnxt_init_ring_struct()
3588 ring = &txr->tx_ring_struct; in bnxt_init_ring_struct()
3589 rmem = &ring->ring_mem; in bnxt_init_ring_struct()
3590 rmem->nr_pages = bp->tx_nr_pages; in bnxt_init_ring_struct()
3591 rmem->page_size = HW_RXBD_RING_SIZE; in bnxt_init_ring_struct()
3592 rmem->pg_arr = (void **)txr->tx_desc_ring; in bnxt_init_ring_struct()
3593 rmem->dma_arr = txr->tx_desc_mapping; in bnxt_init_ring_struct()
3594 rmem->vmem_size = SW_TXBD_RING_SIZE * bp->tx_nr_pages; in bnxt_init_ring_struct()
3595 rmem->vmem = (void **)&txr->tx_buf_ring; in bnxt_init_ring_struct()
3605 rx_buf_ring = (struct rx_bd **)ring->ring_mem.pg_arr; in bnxt_init_rxbd_pages()
3606 for (i = 0, prod = 0; i < ring->ring_mem.nr_pages; i++) { in bnxt_init_rxbd_pages()
3615 rxbd->rx_bd_len_flags_type = cpu_to_le32(type); in bnxt_init_rxbd_pages()
3616 rxbd->rx_bd_opaque = prod; in bnxt_init_rxbd_pages()
3623 struct bnxt_rx_ring_info *rxr = &bp->rx_ring[ring_nr]; in bnxt_alloc_one_rx_ring()
3624 struct net_device *dev = bp->dev; in bnxt_alloc_one_rx_ring()
3628 prod = rxr->rx_prod; in bnxt_alloc_one_rx_ring()
3629 for (i = 0; i < bp->rx_ring_size; i++) { in bnxt_alloc_one_rx_ring()
3632 ring_nr, i, bp->rx_ring_size); in bnxt_alloc_one_rx_ring()
3637 rxr->rx_prod = prod; in bnxt_alloc_one_rx_ring()
3639 if (!(bp->flags & BNXT_FLAG_AGG_RINGS)) in bnxt_alloc_one_rx_ring()
3642 prod = rxr->rx_agg_prod; in bnxt_alloc_one_rx_ring()
3643 for (i = 0; i < bp->rx_agg_ring_size; i++) { in bnxt_alloc_one_rx_ring()
3646 ring_nr, i, bp->rx_ring_size); in bnxt_alloc_one_rx_ring()
3651 rxr->rx_agg_prod = prod; in bnxt_alloc_one_rx_ring()
3653 if (rxr->rx_tpa) { in bnxt_alloc_one_rx_ring()
3657 for (i = 0; i < bp->max_tpa; i++) { in bnxt_alloc_one_rx_ring()
3660 return -ENOMEM; in bnxt_alloc_one_rx_ring()
3662 rxr->rx_tpa[i].data = data; in bnxt_alloc_one_rx_ring()
3663 rxr->rx_tpa[i].data_ptr = data + bp->rx_offset; in bnxt_alloc_one_rx_ring()
3664 rxr->rx_tpa[i].mapping = mapping; in bnxt_alloc_one_rx_ring()
3676 type = (bp->rx_buf_use_size << RX_BD_LEN_SHIFT) | in bnxt_init_one_rx_ring()
3682 rxr = &bp->rx_ring[ring_nr]; in bnxt_init_one_rx_ring()
3683 ring = &rxr->rx_ring_struct; in bnxt_init_one_rx_ring()
3686 if (BNXT_RX_PAGE_MODE(bp) && bp->xdp_prog) { in bnxt_init_one_rx_ring()
3687 bpf_prog_add(bp->xdp_prog, 1); in bnxt_init_one_rx_ring()
3688 rxr->xdp_prog = bp->xdp_prog; in bnxt_init_one_rx_ring()
3690 ring->fw_ring_id = INVALID_HW_RING_ID; in bnxt_init_one_rx_ring()
3692 ring = &rxr->rx_agg_ring_struct; in bnxt_init_one_rx_ring()
3693 ring->fw_ring_id = INVALID_HW_RING_ID; in bnxt_init_one_rx_ring()
3695 if ((bp->flags & BNXT_FLAG_AGG_RINGS)) { in bnxt_init_one_rx_ring()
3709 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_init_cp_rings()
3710 struct bnxt_cp_ring_info *cpr = &bp->bnapi[i]->cp_ring; in bnxt_init_cp_rings()
3711 struct bnxt_ring_struct *ring = &cpr->cp_ring_struct; in bnxt_init_cp_rings()
3713 ring->fw_ring_id = INVALID_HW_RING_ID; in bnxt_init_cp_rings()
3714 cpr->rx_ring_coal.coal_ticks = bp->rx_coal.coal_ticks; in bnxt_init_cp_rings()
3715 cpr->rx_ring_coal.coal_bufs = bp->rx_coal.coal_bufs; in bnxt_init_cp_rings()
3717 struct bnxt_cp_ring_info *cpr2 = cpr->cp_ring_arr[j]; in bnxt_init_cp_rings()
3722 ring = &cpr2->cp_ring_struct; in bnxt_init_cp_rings()
3723 ring->fw_ring_id = INVALID_HW_RING_ID; in bnxt_init_cp_rings()
3724 cpr2->rx_ring_coal.coal_ticks = bp->rx_coal.coal_ticks; in bnxt_init_cp_rings()
3725 cpr2->rx_ring_coal.coal_bufs = bp->rx_coal.coal_bufs; in bnxt_init_cp_rings()
3735 bp->rx_offset = NET_IP_ALIGN + XDP_PACKET_HEADROOM; in bnxt_init_rx_rings()
3736 bp->rx_dma_offset = XDP_PACKET_HEADROOM; in bnxt_init_rx_rings()
3738 bp->rx_offset = BNXT_RX_OFFSET; in bnxt_init_rx_rings()
3739 bp->rx_dma_offset = BNXT_RX_DMA_OFFSET; in bnxt_init_rx_rings()
3742 for (i = 0; i < bp->rx_nr_rings; i++) { in bnxt_init_rx_rings()
3755 bp->tx_wake_thresh = max_t(int, bp->tx_ring_size / 2, in bnxt_init_tx_rings()
3758 for (i = 0; i < bp->tx_nr_rings; i++) { in bnxt_init_tx_rings()
3759 struct bnxt_tx_ring_info *txr = &bp->tx_ring[i]; in bnxt_init_tx_rings()
3760 struct bnxt_ring_struct *ring = &txr->tx_ring_struct; in bnxt_init_tx_rings()
3762 ring->fw_ring_id = INVALID_HW_RING_ID; in bnxt_init_tx_rings()
3770 kfree(bp->grp_info); in bnxt_free_ring_grps()
3771 bp->grp_info = NULL; in bnxt_free_ring_grps()
3779 bp->grp_info = kcalloc(bp->cp_nr_rings, in bnxt_init_ring_grps()
3782 if (!bp->grp_info) in bnxt_init_ring_grps()
3783 return -ENOMEM; in bnxt_init_ring_grps()
3785 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_init_ring_grps()
3787 bp->grp_info[i].fw_stats_ctx = INVALID_HW_RING_ID; in bnxt_init_ring_grps()
3788 bp->grp_info[i].fw_grp_id = INVALID_HW_RING_ID; in bnxt_init_ring_grps()
3789 bp->grp_info[i].rx_fw_ring_id = INVALID_HW_RING_ID; in bnxt_init_ring_grps()
3790 bp->grp_info[i].agg_fw_ring_id = INVALID_HW_RING_ID; in bnxt_init_ring_grps()
3791 bp->grp_info[i].cp_fw_ring_id = INVALID_HW_RING_ID; in bnxt_init_ring_grps()
3798 kfree(bp->vnic_info); in bnxt_free_vnics()
3799 bp->vnic_info = NULL; in bnxt_free_vnics()
3800 bp->nr_vnics = 0; in bnxt_free_vnics()
3808 if ((bp->flags & (BNXT_FLAG_RFS | BNXT_FLAG_CHIP_P5)) == BNXT_FLAG_RFS) in bnxt_alloc_vnics()
3809 num_vnics += bp->rx_nr_rings; in bnxt_alloc_vnics()
3815 bp->vnic_info = kcalloc(num_vnics, sizeof(struct bnxt_vnic_info), in bnxt_alloc_vnics()
3817 if (!bp->vnic_info) in bnxt_alloc_vnics()
3818 return -ENOMEM; in bnxt_alloc_vnics()
3820 bp->nr_vnics = num_vnics; in bnxt_alloc_vnics()
3828 for (i = 0; i < bp->nr_vnics; i++) { in bnxt_init_vnics()
3829 struct bnxt_vnic_info *vnic = &bp->vnic_info[i]; in bnxt_init_vnics()
3832 vnic->fw_vnic_id = INVALID_HW_RING_ID; in bnxt_init_vnics()
3834 vnic->fw_rss_cos_lb_ctx[j] = INVALID_HW_RING_ID; in bnxt_init_vnics()
3836 vnic->fw_l2_ctx_id = INVALID_HW_RING_ID; in bnxt_init_vnics()
3838 if (bp->vnic_info[i].rss_hash_key) { in bnxt_init_vnics()
3840 get_random_bytes(vnic->rss_hash_key, in bnxt_init_vnics()
3843 memcpy(vnic->rss_hash_key, in bnxt_init_vnics()
3844 bp->vnic_info[0].rss_hash_key, in bnxt_init_vnics()
3861 while (pages & (pages - 1)) in bnxt_calc_nr_ring_pages()
3869 bp->flags &= ~BNXT_FLAG_TPA; in bnxt_set_tpa_flags()
3870 if (bp->flags & BNXT_FLAG_NO_AGG_RINGS) in bnxt_set_tpa_flags()
3872 if (bp->dev->features & NETIF_F_LRO) in bnxt_set_tpa_flags()
3873 bp->flags |= BNXT_FLAG_LRO; in bnxt_set_tpa_flags()
3874 else if (bp->dev->features & NETIF_F_GRO_HW) in bnxt_set_tpa_flags()
3875 bp->flags |= BNXT_FLAG_GRO; in bnxt_set_tpa_flags()
3878 /* bp->rx_ring_size, bp->tx_ring_size, dev->mtu, BNXT_FLAG_{G|L}RO flags must
3887 rx_size = SKB_DATA_ALIGN(bp->dev->mtu + ETH_HLEN + NET_IP_ALIGN + 8); in bnxt_set_ring_params()
3892 bp->rx_copy_thresh = BNXT_RX_COPY_THRESH; in bnxt_set_ring_params()
3893 ring_size = bp->rx_ring_size; in bnxt_set_ring_params()
3894 bp->rx_agg_ring_size = 0; in bnxt_set_ring_params()
3895 bp->rx_agg_nr_pages = 0; in bnxt_set_ring_params()
3897 if (bp->flags & BNXT_FLAG_TPA) in bnxt_set_ring_params()
3900 bp->flags &= ~BNXT_FLAG_JUMBO; in bnxt_set_ring_params()
3901 if (rx_space > PAGE_SIZE && !(bp->flags & BNXT_FLAG_NO_AGG_RINGS)) { in bnxt_set_ring_params()
3904 bp->flags |= BNXT_FLAG_JUMBO; in bnxt_set_ring_params()
3905 jumbo_factor = PAGE_ALIGN(bp->dev->mtu - 40) >> PAGE_SHIFT; in bnxt_set_ring_params()
3912 … 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()
3913 bp->rx_ring_size, ring_size); in bnxt_set_ring_params()
3914 bp->rx_ring_size = ring_size; in bnxt_set_ring_params()
3918 bp->rx_agg_nr_pages = bnxt_calc_nr_ring_pages(agg_ring_size, in bnxt_set_ring_params()
3920 if (bp->rx_agg_nr_pages > MAX_RX_AGG_PAGES) { in bnxt_set_ring_params()
3923 bp->rx_agg_nr_pages = MAX_RX_AGG_PAGES; in bnxt_set_ring_params()
3924 agg_ring_size = MAX_RX_AGG_PAGES * RX_DESC_CNT - 1; in bnxt_set_ring_params()
3925 netdev_warn(bp->dev, "rx agg ring size %d reduced to %d.\n", in bnxt_set_ring_params()
3928 bp->rx_agg_ring_size = agg_ring_size; in bnxt_set_ring_params()
3929 bp->rx_agg_ring_mask = (bp->rx_agg_nr_pages * RX_DESC_CNT) - 1; in bnxt_set_ring_params()
3933 rx_size = PAGE_SIZE - in bnxt_set_ring_params()
3934 ALIGN(max(NET_SKB_PAD, XDP_PACKET_HEADROOM), 8) - in bnxt_set_ring_params()
3943 bp->rx_buf_use_size = rx_size; in bnxt_set_ring_params()
3944 bp->rx_buf_size = rx_space; in bnxt_set_ring_params()
3946 bp->rx_nr_pages = bnxt_calc_nr_ring_pages(ring_size, RX_DESC_CNT); in bnxt_set_ring_params()
3947 bp->rx_ring_mask = (bp->rx_nr_pages * RX_DESC_CNT) - 1; in bnxt_set_ring_params()
3949 ring_size = bp->tx_ring_size; in bnxt_set_ring_params()
3950 bp->tx_nr_pages = bnxt_calc_nr_ring_pages(ring_size, TX_DESC_CNT); in bnxt_set_ring_params()
3951 bp->tx_ring_mask = (bp->tx_nr_pages * TX_DESC_CNT) - 1; in bnxt_set_ring_params()
3953 max_rx_cmpl = bp->rx_ring_size; in bnxt_set_ring_params()
3958 if (bp->flags & BNXT_FLAG_TPA) in bnxt_set_ring_params()
3959 max_rx_cmpl += bp->max_tpa; in bnxt_set_ring_params()
3960 /* RX and TPA completions are 32-byte, all others are 16-byte */ in bnxt_set_ring_params()
3961 ring_size = max_rx_cmpl * 2 + agg_ring_size + bp->tx_ring_size; in bnxt_set_ring_params()
3962 bp->cp_ring_size = ring_size; in bnxt_set_ring_params()
3964 bp->cp_nr_pages = bnxt_calc_nr_ring_pages(ring_size, CP_DESC_CNT); in bnxt_set_ring_params()
3965 if (bp->cp_nr_pages > MAX_CP_PAGES) { in bnxt_set_ring_params()
3966 bp->cp_nr_pages = MAX_CP_PAGES; in bnxt_set_ring_params()
3967 bp->cp_ring_size = MAX_CP_PAGES * CP_DESC_CNT - 1; in bnxt_set_ring_params()
3968 netdev_warn(bp->dev, "completion ring size %d reduced to %d.\n", in bnxt_set_ring_params()
3969 ring_size, bp->cp_ring_size); in bnxt_set_ring_params()
3971 bp->cp_bit = bp->cp_nr_pages * CP_DESC_CNT; in bnxt_set_ring_params()
3972 bp->cp_ring_mask = bp->cp_bit - 1; in bnxt_set_ring_params()
3980 struct net_device *dev = bp->dev; in bnxt_set_rx_skb_mode()
3983 bp->flags &= ~BNXT_FLAG_AGG_RINGS; in bnxt_set_rx_skb_mode()
3984 bp->flags |= BNXT_FLAG_RX_PAGE_MODE; in bnxt_set_rx_skb_mode()
3986 if (bp->xdp_prog->aux->xdp_has_frags) in bnxt_set_rx_skb_mode()
3987 dev->max_mtu = min_t(u16, bp->max_mtu, BNXT_MAX_MTU); in bnxt_set_rx_skb_mode()
3989 dev->max_mtu = in bnxt_set_rx_skb_mode()
3990 min_t(u16, bp->max_mtu, BNXT_MAX_PAGE_MODE_MTU); in bnxt_set_rx_skb_mode()
3991 if (dev->mtu > BNXT_MAX_PAGE_MODE_MTU) { in bnxt_set_rx_skb_mode()
3992 bp->flags |= BNXT_FLAG_JUMBO; in bnxt_set_rx_skb_mode()
3993 bp->rx_skb_func = bnxt_rx_multi_page_skb; in bnxt_set_rx_skb_mode()
3995 bp->flags |= BNXT_FLAG_NO_AGG_RINGS; in bnxt_set_rx_skb_mode()
3996 bp->rx_skb_func = bnxt_rx_page_skb; in bnxt_set_rx_skb_mode()
3998 bp->rx_dir = DMA_BIDIRECTIONAL; in bnxt_set_rx_skb_mode()
4002 dev->max_mtu = bp->max_mtu; in bnxt_set_rx_skb_mode()
4003 bp->flags &= ~BNXT_FLAG_RX_PAGE_MODE; in bnxt_set_rx_skb_mode()
4004 bp->rx_dir = DMA_FROM_DEVICE; in bnxt_set_rx_skb_mode()
4005 bp->rx_skb_func = bnxt_rx_skb; in bnxt_set_rx_skb_mode()
4014 struct pci_dev *pdev = bp->pdev; in bnxt_free_vnic_attributes()
4016 if (!bp->vnic_info) in bnxt_free_vnic_attributes()
4019 for (i = 0; i < bp->nr_vnics; i++) { in bnxt_free_vnic_attributes()
4020 vnic = &bp->vnic_info[i]; in bnxt_free_vnic_attributes()
4022 kfree(vnic->fw_grp_ids); in bnxt_free_vnic_attributes()
4023 vnic->fw_grp_ids = NULL; in bnxt_free_vnic_attributes()
4025 kfree(vnic->uc_list); in bnxt_free_vnic_attributes()
4026 vnic->uc_list = NULL; in bnxt_free_vnic_attributes()
4028 if (vnic->mc_list) { in bnxt_free_vnic_attributes()
4029 dma_free_coherent(&pdev->dev, vnic->mc_list_size, in bnxt_free_vnic_attributes()
4030 vnic->mc_list, vnic->mc_list_mapping); in bnxt_free_vnic_attributes()
4031 vnic->mc_list = NULL; in bnxt_free_vnic_attributes()
4034 if (vnic->rss_table) { in bnxt_free_vnic_attributes()
4035 dma_free_coherent(&pdev->dev, vnic->rss_table_size, in bnxt_free_vnic_attributes()
4036 vnic->rss_table, in bnxt_free_vnic_attributes()
4037 vnic->rss_table_dma_addr); in bnxt_free_vnic_attributes()
4038 vnic->rss_table = NULL; in bnxt_free_vnic_attributes()
4041 vnic->rss_hash_key = NULL; in bnxt_free_vnic_attributes()
4042 vnic->flags = 0; in bnxt_free_vnic_attributes()
4050 struct pci_dev *pdev = bp->pdev; in bnxt_alloc_vnic_attributes()
4053 for (i = 0; i < bp->nr_vnics; i++) { in bnxt_alloc_vnic_attributes()
4054 vnic = &bp->vnic_info[i]; in bnxt_alloc_vnic_attributes()
4056 if (vnic->flags & BNXT_VNIC_UCAST_FLAG) { in bnxt_alloc_vnic_attributes()
4057 int mem_size = (BNXT_MAX_UC_ADDRS - 1) * ETH_ALEN; in bnxt_alloc_vnic_attributes()
4060 vnic->uc_list = kmalloc(mem_size, GFP_KERNEL); in bnxt_alloc_vnic_attributes()
4061 if (!vnic->uc_list) { in bnxt_alloc_vnic_attributes()
4062 rc = -ENOMEM; in bnxt_alloc_vnic_attributes()
4068 if (vnic->flags & BNXT_VNIC_MCAST_FLAG) { in bnxt_alloc_vnic_attributes()
4069 vnic->mc_list_size = BNXT_MAX_MC_ADDRS * ETH_ALEN; in bnxt_alloc_vnic_attributes()
4070 vnic->mc_list = in bnxt_alloc_vnic_attributes()
4071 dma_alloc_coherent(&pdev->dev, in bnxt_alloc_vnic_attributes()
4072 vnic->mc_list_size, in bnxt_alloc_vnic_attributes()
4073 &vnic->mc_list_mapping, in bnxt_alloc_vnic_attributes()
4075 if (!vnic->mc_list) { in bnxt_alloc_vnic_attributes()
4076 rc = -ENOMEM; in bnxt_alloc_vnic_attributes()
4081 if (bp->flags & BNXT_FLAG_CHIP_P5) in bnxt_alloc_vnic_attributes()
4084 if (vnic->flags & BNXT_VNIC_RSS_FLAG) in bnxt_alloc_vnic_attributes()
4085 max_rings = bp->rx_nr_rings; in bnxt_alloc_vnic_attributes()
4089 vnic->fw_grp_ids = kcalloc(max_rings, sizeof(u16), GFP_KERNEL); in bnxt_alloc_vnic_attributes()
4090 if (!vnic->fw_grp_ids) { in bnxt_alloc_vnic_attributes()
4091 rc = -ENOMEM; in bnxt_alloc_vnic_attributes()
4095 if ((bp->flags & BNXT_FLAG_NEW_RSS_CAP) && in bnxt_alloc_vnic_attributes()
4096 !(vnic->flags & BNXT_VNIC_RSS_FLAG)) in bnxt_alloc_vnic_attributes()
4101 if (bp->flags & BNXT_FLAG_CHIP_P5) in bnxt_alloc_vnic_attributes()
4104 vnic->rss_table_size = size + HW_HASH_KEY_SIZE; in bnxt_alloc_vnic_attributes()
4105 vnic->rss_table = dma_alloc_coherent(&pdev->dev, in bnxt_alloc_vnic_attributes()
4106 vnic->rss_table_size, in bnxt_alloc_vnic_attributes()
4107 &vnic->rss_table_dma_addr, in bnxt_alloc_vnic_attributes()
4109 if (!vnic->rss_table) { in bnxt_alloc_vnic_attributes()
4110 rc = -ENOMEM; in bnxt_alloc_vnic_attributes()
4114 vnic->rss_hash_key = ((void *)vnic->rss_table) + size; in bnxt_alloc_vnic_attributes()
4115 vnic->rss_hash_key_dma_addr = vnic->rss_table_dma_addr + size; in bnxt_alloc_vnic_attributes()
4127 dma_pool_destroy(bp->hwrm_dma_pool); in bnxt_free_hwrm_resources()
4128 bp->hwrm_dma_pool = NULL; in bnxt_free_hwrm_resources()
4131 hlist_for_each_entry_rcu(token, &bp->hwrm_pending_list, node) in bnxt_free_hwrm_resources()
4132 WRITE_ONCE(token->state, BNXT_HWRM_CANCELLED); in bnxt_free_hwrm_resources()
4138 bp->hwrm_dma_pool = dma_pool_create("bnxt_hwrm", &bp->pdev->dev, in bnxt_alloc_hwrm_resources()
4141 if (!bp->hwrm_dma_pool) in bnxt_alloc_hwrm_resources()
4142 return -ENOMEM; in bnxt_alloc_hwrm_resources()
4144 INIT_HLIST_HEAD(&bp->hwrm_pending_list); in bnxt_alloc_hwrm_resources()
4151 kfree(stats->hw_masks); in bnxt_free_stats_mem()
4152 stats->hw_masks = NULL; in bnxt_free_stats_mem()
4153 kfree(stats->sw_stats); in bnxt_free_stats_mem()
4154 stats->sw_stats = NULL; in bnxt_free_stats_mem()
4155 if (stats->hw_stats) { in bnxt_free_stats_mem()
4156 dma_free_coherent(&bp->pdev->dev, stats->len, stats->hw_stats, in bnxt_free_stats_mem()
4157 stats->hw_stats_map); in bnxt_free_stats_mem()
4158 stats->hw_stats = NULL; in bnxt_free_stats_mem()
4165 stats->hw_stats = dma_alloc_coherent(&bp->pdev->dev, stats->len, in bnxt_alloc_stats_mem()
4166 &stats->hw_stats_map, GFP_KERNEL); in bnxt_alloc_stats_mem()
4167 if (!stats->hw_stats) in bnxt_alloc_stats_mem()
4168 return -ENOMEM; in bnxt_alloc_stats_mem()
4170 stats->sw_stats = kzalloc(stats->len, GFP_KERNEL); in bnxt_alloc_stats_mem()
4171 if (!stats->sw_stats) in bnxt_alloc_stats_mem()
4175 stats->hw_masks = kzalloc(stats->len, GFP_KERNEL); in bnxt_alloc_stats_mem()
4176 if (!stats->hw_masks) in bnxt_alloc_stats_mem()
4183 return -ENOMEM; in bnxt_alloc_stats_mem()
4210 if (!(bp->fw_cap & BNXT_FW_CAP_EXT_HW_STATS_SUPPORTED) || in bnxt_hwrm_func_qstat_ext()
4211 !(bp->flags & BNXT_FLAG_CHIP_P5)) in bnxt_hwrm_func_qstat_ext()
4212 return -EOPNOTSUPP; in bnxt_hwrm_func_qstat_ext()
4218 req->fid = cpu_to_le16(0xffff); in bnxt_hwrm_func_qstat_ext()
4219 req->flags = FUNC_QSTATS_EXT_REQ_FLAGS_COUNTER_MASK; in bnxt_hwrm_func_qstat_ext()
4224 hw_masks = &resp->rx_ucast_pkts; in bnxt_hwrm_func_qstat_ext()
4225 bnxt_copy_hw_masks(stats->hw_masks, hw_masks, stats->len / 8); in bnxt_hwrm_func_qstat_ext()
4236 struct bnxt_napi *bnapi = bp->bnapi[0]; in bnxt_init_stats()
4245 cpr = &bnapi->cp_ring; in bnxt_init_stats()
4246 stats = &cpr->stats; in bnxt_init_stats()
4249 if (bp->flags & BNXT_FLAG_CHIP_P5) in bnxt_init_stats()
4250 mask = (1ULL << 48) - 1; in bnxt_init_stats()
4252 mask = -1ULL; in bnxt_init_stats()
4253 bnxt_fill_masks(stats->hw_masks, mask, stats->len / 8); in bnxt_init_stats()
4255 if (bp->flags & BNXT_FLAG_PORT_STATS) { in bnxt_init_stats()
4256 stats = &bp->port_stats; in bnxt_init_stats()
4257 rx_stats = stats->hw_stats; in bnxt_init_stats()
4258 rx_masks = stats->hw_masks; in bnxt_init_stats()
4267 mask = (1ULL << 40) - 1; in bnxt_init_stats()
4277 if (bp->flags & BNXT_FLAG_PORT_STATS_EXT) { in bnxt_init_stats()
4278 stats = &bp->rx_port_stats_ext; in bnxt_init_stats()
4279 rx_stats = stats->hw_stats; in bnxt_init_stats()
4280 rx_masks = stats->hw_masks; in bnxt_init_stats()
4282 stats = &bp->tx_port_stats_ext; in bnxt_init_stats()
4283 tx_stats = stats->hw_stats; in bnxt_init_stats()
4284 tx_masks = stats->hw_masks; in bnxt_init_stats()
4290 mask = (1ULL << 40) - 1; in bnxt_init_stats()
4307 bp->flags &= ~BNXT_FLAG_PORT_STATS; in bnxt_free_port_stats()
4308 bp->flags &= ~BNXT_FLAG_PORT_STATS_EXT; in bnxt_free_port_stats()
4310 bnxt_free_stats_mem(bp, &bp->port_stats); in bnxt_free_port_stats()
4311 bnxt_free_stats_mem(bp, &bp->rx_port_stats_ext); in bnxt_free_port_stats()
4312 bnxt_free_stats_mem(bp, &bp->tx_port_stats_ext); in bnxt_free_port_stats()
4319 if (!bp->bnapi) in bnxt_free_ring_stats()
4322 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_free_ring_stats()
4323 struct bnxt_napi *bnapi = bp->bnapi[i]; in bnxt_free_ring_stats()
4324 struct bnxt_cp_ring_info *cpr = &bnapi->cp_ring; in bnxt_free_ring_stats()
4326 bnxt_free_stats_mem(bp, &cpr->stats); in bnxt_free_ring_stats()
4335 size = bp->hw_ring_stats_size; in bnxt_alloc_stats()
4337 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_alloc_stats()
4338 struct bnxt_napi *bnapi = bp->bnapi[i]; in bnxt_alloc_stats()
4339 struct bnxt_cp_ring_info *cpr = &bnapi->cp_ring; in bnxt_alloc_stats()
4341 cpr->stats.len = size; in bnxt_alloc_stats()
4342 rc = bnxt_alloc_stats_mem(bp, &cpr->stats, !i); in bnxt_alloc_stats()
4346 cpr->hw_stats_ctx_id = INVALID_STATS_CTX_ID; in bnxt_alloc_stats()
4349 if (BNXT_VF(bp) || bp->chip_num == CHIP_NUM_58700) in bnxt_alloc_stats()
4352 if (bp->port_stats.hw_stats) in bnxt_alloc_stats()
4355 bp->port_stats.len = BNXT_PORT_STATS_SIZE; in bnxt_alloc_stats()
4356 rc = bnxt_alloc_stats_mem(bp, &bp->port_stats, true); in bnxt_alloc_stats()
4360 bp->flags |= BNXT_FLAG_PORT_STATS; in bnxt_alloc_stats()
4364 if (bp->hwrm_spec_code < 0x10804 || bp->hwrm_spec_code == 0x10900) in bnxt_alloc_stats()
4365 if (!(bp->fw_cap & BNXT_FW_CAP_EXT_STATS_SUPPORTED)) in bnxt_alloc_stats()
4368 if (bp->rx_port_stats_ext.hw_stats) in bnxt_alloc_stats()
4371 bp->rx_port_stats_ext.len = sizeof(struct rx_port_stats_ext); in bnxt_alloc_stats()
4372 rc = bnxt_alloc_stats_mem(bp, &bp->rx_port_stats_ext, true); in bnxt_alloc_stats()
4378 if (bp->tx_port_stats_ext.hw_stats) in bnxt_alloc_stats()
4381 if (bp->hwrm_spec_code >= 0x10902 || in bnxt_alloc_stats()
4382 (bp->fw_cap & BNXT_FW_CAP_EXT_STATS_SUPPORTED)) { in bnxt_alloc_stats()
4383 bp->tx_port_stats_ext.len = sizeof(struct tx_port_stats_ext); in bnxt_alloc_stats()
4384 rc = bnxt_alloc_stats_mem(bp, &bp->tx_port_stats_ext, true); in bnxt_alloc_stats()
4389 bp->flags |= BNXT_FLAG_PORT_STATS_EXT; in bnxt_alloc_stats()
4397 if (!bp->bnapi) in bnxt_clear_ring_indices()
4400 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_clear_ring_indices()
4401 struct bnxt_napi *bnapi = bp->bnapi[i]; in bnxt_clear_ring_indices()
4409 cpr = &bnapi->cp_ring; in bnxt_clear_ring_indices()
4410 cpr->cp_raw_cons = 0; in bnxt_clear_ring_indices()
4412 txr = bnapi->tx_ring; in bnxt_clear_ring_indices()
4414 txr->tx_prod = 0; in bnxt_clear_ring_indices()
4415 txr->tx_cons = 0; in bnxt_clear_ring_indices()
4418 rxr = bnapi->rx_ring; in bnxt_clear_ring_indices()
4420 rxr->rx_prod = 0; in bnxt_clear_ring_indices()
4421 rxr->rx_agg_prod = 0; in bnxt_clear_ring_indices()
4422 rxr->rx_sw_agg_prod = 0; in bnxt_clear_ring_indices()
4423 rxr->rx_next_cons = 0; in bnxt_clear_ring_indices()
4441 head = &bp->ntp_fltr_hash_tbl[i]; in bnxt_free_ntp_fltrs()
4443 hlist_del(&fltr->hash); in bnxt_free_ntp_fltrs()
4448 bitmap_free(bp->ntp_fltr_bmap); in bnxt_free_ntp_fltrs()
4449 bp->ntp_fltr_bmap = NULL; in bnxt_free_ntp_fltrs()
4451 bp->ntp_fltr_count = 0; in bnxt_free_ntp_fltrs()
4460 if (!(bp->flags & BNXT_FLAG_RFS)) in bnxt_alloc_ntp_fltrs()
4464 INIT_HLIST_HEAD(&bp->ntp_fltr_hash_tbl[i]); in bnxt_alloc_ntp_fltrs()
4466 bp->ntp_fltr_count = 0; in bnxt_alloc_ntp_fltrs()
4467 bp->ntp_fltr_bmap = bitmap_zalloc(BNXT_NTP_FLTR_MAX_FLTR, GFP_KERNEL); in bnxt_alloc_ntp_fltrs()
4469 if (!bp->ntp_fltr_bmap) in bnxt_alloc_ntp_fltrs()
4470 rc = -ENOMEM; in bnxt_alloc_ntp_fltrs()
4488 if (!(bp->phy_flags & BNXT_PHY_FL_PORT_STATS_NO_RESET) || in bnxt_free_mem()
4489 test_bit(BNXT_STATE_IN_FW_RESET, &bp->state)) in bnxt_free_mem()
4493 kfree(bp->tx_ring_map); in bnxt_free_mem()
4494 bp->tx_ring_map = NULL; in bnxt_free_mem()
4495 kfree(bp->tx_ring); in bnxt_free_mem()
4496 bp->tx_ring = NULL; in bnxt_free_mem()
4497 kfree(bp->rx_ring); in bnxt_free_mem()
4498 bp->rx_ring = NULL; in bnxt_free_mem()
4499 kfree(bp->bnapi); in bnxt_free_mem()
4500 bp->bnapi = NULL; in bnxt_free_mem()
4516 bp->cp_nr_rings); in bnxt_alloc_mem()
4518 bnapi = kzalloc(arr_size + size * bp->cp_nr_rings, GFP_KERNEL); in bnxt_alloc_mem()
4520 return -ENOMEM; in bnxt_alloc_mem()
4522 bp->bnapi = bnapi; in bnxt_alloc_mem()
4524 for (i = 0; i < bp->cp_nr_rings; i++, bnapi += size) { in bnxt_alloc_mem()
4525 bp->bnapi[i] = bnapi; in bnxt_alloc_mem()
4526 bp->bnapi[i]->index = i; in bnxt_alloc_mem()
4527 bp->bnapi[i]->bp = bp; in bnxt_alloc_mem()
4528 if (bp->flags & BNXT_FLAG_CHIP_P5) { in bnxt_alloc_mem()
4530 &bp->bnapi[i]->cp_ring; in bnxt_alloc_mem()
4532 cpr->cp_ring_struct.ring_mem.flags = in bnxt_alloc_mem()
4537 bp->rx_ring = kcalloc(bp->rx_nr_rings, in bnxt_alloc_mem()
4540 if (!bp->rx_ring) in bnxt_alloc_mem()
4541 return -ENOMEM; in bnxt_alloc_mem()
4543 for (i = 0; i < bp->rx_nr_rings; i++) { in bnxt_alloc_mem()
4544 struct bnxt_rx_ring_info *rxr = &bp->rx_ring[i]; in bnxt_alloc_mem()
4546 if (bp->flags & BNXT_FLAG_CHIP_P5) { in bnxt_alloc_mem()
4547 rxr->rx_ring_struct.ring_mem.flags = in bnxt_alloc_mem()
4549 rxr->rx_agg_ring_struct.ring_mem.flags = in bnxt_alloc_mem()
4552 rxr->bnapi = bp->bnapi[i]; in bnxt_alloc_mem()
4553 bp->bnapi[i]->rx_ring = &bp->rx_ring[i]; in bnxt_alloc_mem()
4556 bp->tx_ring = kcalloc(bp->tx_nr_rings, in bnxt_alloc_mem()
4559 if (!bp->tx_ring) in bnxt_alloc_mem()
4560 return -ENOMEM; in bnxt_alloc_mem()
4562 bp->tx_ring_map = kcalloc(bp->tx_nr_rings, sizeof(u16), in bnxt_alloc_mem()
4565 if (!bp->tx_ring_map) in bnxt_alloc_mem()
4566 return -ENOMEM; in bnxt_alloc_mem()
4568 if (bp->flags & BNXT_FLAG_SHARED_RINGS) in bnxt_alloc_mem()
4571 j = bp->rx_nr_rings; in bnxt_alloc_mem()
4573 for (i = 0; i < bp->tx_nr_rings; i++, j++) { in bnxt_alloc_mem()
4574 struct bnxt_tx_ring_info *txr = &bp->tx_ring[i]; in bnxt_alloc_mem()
4576 if (bp->flags & BNXT_FLAG_CHIP_P5) in bnxt_alloc_mem()
4577 txr->tx_ring_struct.ring_mem.flags = in bnxt_alloc_mem()
4579 txr->bnapi = bp->bnapi[j]; in bnxt_alloc_mem()
4580 bp->bnapi[j]->tx_ring = txr; in bnxt_alloc_mem()
4581 bp->tx_ring_map[i] = bp->tx_nr_rings_xdp + i; in bnxt_alloc_mem()
4582 if (i >= bp->tx_nr_rings_xdp) { in bnxt_alloc_mem()
4583 txr->txq_index = i - bp->tx_nr_rings_xdp; in bnxt_alloc_mem()
4584 bp->bnapi[j]->tx_int = bnxt_tx_int; in bnxt_alloc_mem()
4586 bp->bnapi[j]->flags |= BNXT_NAPI_FLAG_XDP; in bnxt_alloc_mem()
4587 bp->bnapi[j]->tx_int = bnxt_tx_int_xdp; in bnxt_alloc_mem()
4623 bp->vnic_info[0].flags |= BNXT_VNIC_RSS_FLAG | BNXT_VNIC_MCAST_FLAG | in bnxt_alloc_mem()
4639 if (!bp->bnapi) in bnxt_disable_int()
4642 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_disable_int()
4643 struct bnxt_napi *bnapi = bp->bnapi[i]; in bnxt_disable_int()
4644 struct bnxt_cp_ring_info *cpr = &bnapi->cp_ring; in bnxt_disable_int()
4645 struct bnxt_ring_struct *ring = &cpr->cp_ring_struct; in bnxt_disable_int()
4647 if (ring->fw_ring_id != INVALID_HW_RING_ID) in bnxt_disable_int()
4648 bnxt_db_nq(bp, &cpr->cp_db, cpr->cp_raw_cons); in bnxt_disable_int()
4654 struct bnxt_napi *bnapi = bp->bnapi[n]; in bnxt_cp_num_to_irq_num()
4657 cpr = &bnapi->cp_ring; in bnxt_cp_num_to_irq_num()
4658 return cpr->cp_ring_struct.map_idx; in bnxt_cp_num_to_irq_num()
4665 if (!bp->irq_tbl) in bnxt_disable_int_sync()
4668 atomic_inc(&bp->intr_sem); in bnxt_disable_int_sync()
4671 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_disable_int_sync()
4674 synchronize_irq(bp->irq_tbl[map_idx].vector); in bnxt_disable_int_sync()
4682 atomic_set(&bp->intr_sem, 0); in bnxt_enable_int()
4683 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_enable_int()
4684 struct bnxt_napi *bnapi = bp->bnapi[i]; in bnxt_enable_int()
4685 struct bnxt_cp_ring_info *cpr = &bnapi->cp_ring; in bnxt_enable_int()
4687 bnxt_db_nq_arm(bp, &cpr->cp_db, cpr->cp_raw_cons); in bnxt_enable_int()
4705 req->enables = cpu_to_le32(FUNC_DRV_RGTR_REQ_ENABLES_OS_TYPE | in bnxt_hwrm_func_drv_rgtr()
4709 req->os_type = cpu_to_le16(FUNC_DRV_RGTR_REQ_OS_TYPE_LINUX); in bnxt_hwrm_func_drv_rgtr()
4711 if (bp->fw_cap & BNXT_FW_CAP_HOT_RESET) in bnxt_hwrm_func_drv_rgtr()
4713 if (bp->fw_cap & BNXT_FW_CAP_ERROR_RECOVERY) in bnxt_hwrm_func_drv_rgtr()
4716 req->flags = cpu_to_le32(flags); in bnxt_hwrm_func_drv_rgtr()
4717 req->ver_maj_8b = DRV_VER_MAJ; in bnxt_hwrm_func_drv_rgtr()
4718 req->ver_min_8b = DRV_VER_MIN; in bnxt_hwrm_func_drv_rgtr()
4719 req->ver_upd_8b = DRV_VER_UPD; in bnxt_hwrm_func_drv_rgtr()
4720 req->ver_maj = cpu_to_le16(DRV_VER_MAJ); in bnxt_hwrm_func_drv_rgtr()
4721 req->ver_min = cpu_to_le16(DRV_VER_MIN); in bnxt_hwrm_func_drv_rgtr()
4722 req->ver_upd = cpu_to_le16(DRV_VER_UPD); in bnxt_hwrm_func_drv_rgtr()
4739 req->vf_req_fwd[i] = cpu_to_le32(data[i]); in bnxt_hwrm_func_drv_rgtr()
4741 req->enables |= in bnxt_hwrm_func_drv_rgtr()
4745 if (bp->fw_cap & BNXT_FW_CAP_OVS_64BIT_HANDLE) in bnxt_hwrm_func_drv_rgtr()
4746 req->flags |= cpu_to_le32( in bnxt_hwrm_func_drv_rgtr()
4754 !(bp->fw_cap & BNXT_FW_CAP_ERROR_RECOVERY)) in bnxt_hwrm_func_drv_rgtr()
4757 !bp->ptp_cfg) in bnxt_hwrm_func_drv_rgtr()
4768 req->async_event_fwd[i] |= cpu_to_le32(events[i]); in bnxt_hwrm_func_drv_rgtr()
4771 req->enables = in bnxt_hwrm_func_drv_rgtr()
4777 set_bit(BNXT_STATE_DRV_REGISTERED, &bp->state); in bnxt_hwrm_func_drv_rgtr()
4778 if (resp->flags & in bnxt_hwrm_func_drv_rgtr()
4780 bp->fw_cap |= BNXT_FW_CAP_IF_CHANGE; in bnxt_hwrm_func_drv_rgtr()
4791 if (!test_and_clear_bit(BNXT_STATE_DRV_REGISTERED, &bp->state)) in bnxt_hwrm_func_drv_unrgtr()
4806 bp->vxlan_fw_dst_port_id == INVALID_HW_RING_ID) in bnxt_hwrm_tunnel_dst_port_free()
4809 bp->nge_fw_dst_port_id == INVALID_HW_RING_ID) in bnxt_hwrm_tunnel_dst_port_free()
4816 req->tunnel_type = tunnel_type; in bnxt_hwrm_tunnel_dst_port_free()
4820 req->tunnel_dst_port_id = cpu_to_le16(bp->vxlan_fw_dst_port_id); in bnxt_hwrm_tunnel_dst_port_free()
4821 bp->vxlan_port = 0; in bnxt_hwrm_tunnel_dst_port_free()
4822 bp->vxlan_fw_dst_port_id = INVALID_HW_RING_ID; in bnxt_hwrm_tunnel_dst_port_free()
4825 req->tunnel_dst_port_id = cpu_to_le16(bp->nge_fw_dst_port_id); in bnxt_hwrm_tunnel_dst_port_free()
4826 bp->nge_port = 0; in bnxt_hwrm_tunnel_dst_port_free()
4827 bp->nge_fw_dst_port_id = INVALID_HW_RING_ID; in bnxt_hwrm_tunnel_dst_port_free()
4835 netdev_err(bp->dev, "hwrm_tunnel_dst_port_free failed. rc:%d\n", in bnxt_hwrm_tunnel_dst_port_free()
4851 req->tunnel_type = tunnel_type; in bnxt_hwrm_tunnel_dst_port_alloc()
4852 req->tunnel_dst_port_val = port; in bnxt_hwrm_tunnel_dst_port_alloc()
4857 netdev_err(bp->dev, "hwrm_tunnel_dst_port_alloc failed. rc:%d\n", in bnxt_hwrm_tunnel_dst_port_alloc()
4864 bp->vxlan_port = port; in bnxt_hwrm_tunnel_dst_port_alloc()
4865 bp->vxlan_fw_dst_port_id = in bnxt_hwrm_tunnel_dst_port_alloc()
4866 le16_to_cpu(resp->tunnel_dst_port_id); in bnxt_hwrm_tunnel_dst_port_alloc()
4869 bp->nge_port = port; in bnxt_hwrm_tunnel_dst_port_alloc()
4870 bp->nge_fw_dst_port_id = le16_to_cpu(resp->tunnel_dst_port_id); in bnxt_hwrm_tunnel_dst_port_alloc()
4884 struct bnxt_vnic_info *vnic = &bp->vnic_info[vnic_id]; in bnxt_hwrm_cfa_l2_set_rx_mask()
4891 req->vnic_id = cpu_to_le32(vnic->fw_vnic_id); in bnxt_hwrm_cfa_l2_set_rx_mask()
4892 if (vnic->rx_mask & CFA_L2_SET_RX_MASK_REQ_MASK_MCAST) { in bnxt_hwrm_cfa_l2_set_rx_mask()
4893 req->num_mc_entries = cpu_to_le32(vnic->mc_list_count); in bnxt_hwrm_cfa_l2_set_rx_mask()
4894 req->mc_tbl_addr = cpu_to_le64(vnic->mc_list_mapping); in bnxt_hwrm_cfa_l2_set_rx_mask()
4896 req->mask = cpu_to_le32(vnic->rx_mask); in bnxt_hwrm_cfa_l2_set_rx_mask()
4911 req->ntuple_filter_id = fltr->filter_id; in bnxt_hwrm_cfa_ntuple_filter_free()
4939 struct flow_keys *keys = &fltr->fkeys; in bnxt_hwrm_cfa_ntuple_filter_alloc()
4948 req->l2_filter_id = bp->vnic_info[0].fw_l2_filter_id[fltr->l2_fltr_idx]; in bnxt_hwrm_cfa_ntuple_filter_alloc()
4950 if (bp->fw_cap & BNXT_FW_CAP_CFA_RFS_RING_TBL_IDX_V2) { in bnxt_hwrm_cfa_ntuple_filter_alloc()
4952 req->dst_id = cpu_to_le16(fltr->rxq); in bnxt_hwrm_cfa_ntuple_filter_alloc()
4954 vnic = &bp->vnic_info[fltr->rxq + 1]; in bnxt_hwrm_cfa_ntuple_filter_alloc()
4955 req->dst_id = cpu_to_le16(vnic->fw_vnic_id); in bnxt_hwrm_cfa_ntuple_filter_alloc()
4957 req->flags = cpu_to_le32(flags); in bnxt_hwrm_cfa_ntuple_filter_alloc()
4958 req->enables = cpu_to_le32(BNXT_NTP_FLTR_FLAGS); in bnxt_hwrm_cfa_ntuple_filter_alloc()
4960 req->ethertype = htons(ETH_P_IP); in bnxt_hwrm_cfa_ntuple_filter_alloc()
4961 memcpy(req->src_macaddr, fltr->src_mac_addr, ETH_ALEN); in bnxt_hwrm_cfa_ntuple_filter_alloc()
4962 req->ip_addr_type = CFA_NTUPLE_FILTER_ALLOC_REQ_IP_ADDR_TYPE_IPV4; in bnxt_hwrm_cfa_ntuple_filter_alloc()
4963 req->ip_protocol = keys->basic.ip_proto; in bnxt_hwrm_cfa_ntuple_filter_alloc()
4965 if (keys->basic.n_proto == htons(ETH_P_IPV6)) { in bnxt_hwrm_cfa_ntuple_filter_alloc()
4968 req->ethertype = htons(ETH_P_IPV6); in bnxt_hwrm_cfa_ntuple_filter_alloc()
4969 req->ip_addr_type = in bnxt_hwrm_cfa_ntuple_filter_alloc()
4971 *(struct in6_addr *)&req->src_ipaddr[0] = in bnxt_hwrm_cfa_ntuple_filter_alloc()
4972 keys->addrs.v6addrs.src; in bnxt_hwrm_cfa_ntuple_filter_alloc()
4973 *(struct in6_addr *)&req->dst_ipaddr[0] = in bnxt_hwrm_cfa_ntuple_filter_alloc()
4974 keys->addrs.v6addrs.dst; in bnxt_hwrm_cfa_ntuple_filter_alloc()
4976 req->src_ipaddr_mask[i] = cpu_to_be32(0xffffffff); in bnxt_hwrm_cfa_ntuple_filter_alloc()
4977 req->dst_ipaddr_mask[i] = cpu_to_be32(0xffffffff); in bnxt_hwrm_cfa_ntuple_filter_alloc()
4980 req->src_ipaddr[0] = keys->addrs.v4addrs.src; in bnxt_hwrm_cfa_ntuple_filter_alloc()
4981 req->src_ipaddr_mask[0] = cpu_to_be32(0xffffffff); in bnxt_hwrm_cfa_ntuple_filter_alloc()
4982 req->dst_ipaddr[0] = keys->addrs.v4addrs.dst; in bnxt_hwrm_cfa_ntuple_filter_alloc()
4983 req->dst_ipaddr_mask[0] = cpu_to_be32(0xffffffff); in bnxt_hwrm_cfa_ntuple_filter_alloc()
4985 if (keys->control.flags & FLOW_DIS_ENCAPSULATION) { in bnxt_hwrm_cfa_ntuple_filter_alloc()
4986 req->enables |= cpu_to_le32(BNXT_NTP_TUNNEL_FLTR_FLAG); in bnxt_hwrm_cfa_ntuple_filter_alloc()
4987 req->tunnel_type = in bnxt_hwrm_cfa_ntuple_filter_alloc()
4991 req->src_port = keys->ports.src; in bnxt_hwrm_cfa_ntuple_filter_alloc()
4992 req->src_port_mask = cpu_to_be16(0xffff); in bnxt_hwrm_cfa_ntuple_filter_alloc()
4993 req->dst_port = keys->ports.dst; in bnxt_hwrm_cfa_ntuple_filter_alloc()
4994 req->dst_port_mask = cpu_to_be16(0xffff); in bnxt_hwrm_cfa_ntuple_filter_alloc()
4999 fltr->filter_id = resp->ntuple_filter_id; in bnxt_hwrm_cfa_ntuple_filter_alloc()
5016 req->flags = cpu_to_le32(CFA_L2_FILTER_ALLOC_REQ_FLAGS_PATH_RX); in bnxt_hwrm_set_vnic_filter()
5018 req->flags |= in bnxt_hwrm_set_vnic_filter()
5020 req->dst_id = cpu_to_le16(bp->vnic_info[vnic_id].fw_vnic_id); in bnxt_hwrm_set_vnic_filter()
5021 req->enables = in bnxt_hwrm_set_vnic_filter()
5025 memcpy(req->l2_addr, mac_addr, ETH_ALEN); in bnxt_hwrm_set_vnic_filter()
5026 req->l2_addr_mask[0] = 0xff; in bnxt_hwrm_set_vnic_filter()
5027 req->l2_addr_mask[1] = 0xff; in bnxt_hwrm_set_vnic_filter()
5028 req->l2_addr_mask[2] = 0xff; in bnxt_hwrm_set_vnic_filter()
5029 req->l2_addr_mask[3] = 0xff; in bnxt_hwrm_set_vnic_filter()
5030 req->l2_addr_mask[4] = 0xff; in bnxt_hwrm_set_vnic_filter()
5031 req->l2_addr_mask[5] = 0xff; in bnxt_hwrm_set_vnic_filter()
5036 bp->vnic_info[vnic_id].fw_l2_filter_id[idx] = in bnxt_hwrm_set_vnic_filter()
5037 resp->l2_filter_id; in bnxt_hwrm_set_vnic_filter()
5054 struct bnxt_vnic_info *vnic = &bp->vnic_info[i]; in bnxt_hwrm_clear_vnic_filter()
5056 for (j = 0; j < vnic->uc_filter_count; j++) { in bnxt_hwrm_clear_vnic_filter()
5057 req->l2_filter_id = vnic->fw_l2_filter_id[j]; in bnxt_hwrm_clear_vnic_filter()
5061 vnic->uc_filter_count = 0; in bnxt_hwrm_clear_vnic_filter()
5069 struct bnxt_vnic_info *vnic = &bp->vnic_info[vnic_id]; in bnxt_hwrm_vnic_set_tpa()
5074 if (vnic->fw_vnic_id == INVALID_HW_RING_ID) in bnxt_hwrm_vnic_set_tpa()
5082 u16 mss = bp->dev->mtu - 40; in bnxt_hwrm_vnic_set_tpa()
5093 req->flags = cpu_to_le32(flags); in bnxt_hwrm_vnic_set_tpa()
5095 req->enables = in bnxt_hwrm_vnic_set_tpa()
5105 nsegs = (MAX_SKB_FRAGS - 1) * n; in bnxt_hwrm_vnic_set_tpa()
5108 if (mss & (BNXT_RX_PAGE_SIZE - 1)) in bnxt_hwrm_vnic_set_tpa()
5110 nsegs = (MAX_SKB_FRAGS - n) / n; in bnxt_hwrm_vnic_set_tpa()
5113 if (bp->flags & BNXT_FLAG_CHIP_P5) { in bnxt_hwrm_vnic_set_tpa()
5115 max_aggs = bp->max_tpa; in bnxt_hwrm_vnic_set_tpa()
5119 req->max_agg_segs = cpu_to_le16(segs); in bnxt_hwrm_vnic_set_tpa()
5120 req->max_aggs = cpu_to_le16(max_aggs); in bnxt_hwrm_vnic_set_tpa()
5122 req->min_agg_len = cpu_to_le32(512); in bnxt_hwrm_vnic_set_tpa()
5124 req->vnic_id = cpu_to_le16(vnic->fw_vnic_id); in bnxt_hwrm_vnic_set_tpa()
5133 grp_info = &bp->grp_info[ring->grp_idx]; in bnxt_cp_ring_from_grp()
5134 return grp_info->cp_fw_ring_id; in bnxt_cp_ring_from_grp()
5139 if (bp->flags & BNXT_FLAG_CHIP_P5) { in bnxt_cp_ring_for_rx()
5140 struct bnxt_napi *bnapi = rxr->bnapi; in bnxt_cp_ring_for_rx()
5143 cpr = bnapi->cp_ring.cp_ring_arr[BNXT_RX_HDL]; in bnxt_cp_ring_for_rx()
5144 return cpr->cp_ring_struct.fw_ring_id; in bnxt_cp_ring_for_rx()
5146 return bnxt_cp_ring_from_grp(bp, &rxr->rx_ring_struct); in bnxt_cp_ring_for_rx()
5152 if (bp->flags & BNXT_FLAG_CHIP_P5) { in bnxt_cp_ring_for_tx()
5153 struct bnxt_napi *bnapi = txr->bnapi; in bnxt_cp_ring_for_tx()
5156 cpr = bnapi->cp_ring.cp_ring_arr[BNXT_TX_HDL]; in bnxt_cp_ring_for_tx()
5157 return cpr->cp_ring_struct.fw_ring_id; in bnxt_cp_ring_for_tx()
5159 return bnxt_cp_ring_from_grp(bp, &txr->tx_ring_struct); in bnxt_cp_ring_for_tx()
5167 if (bp->flags & BNXT_FLAG_CHIP_P5) in bnxt_alloc_rss_indir_tbl()
5172 bp->rss_indir_tbl_entries = entries; in bnxt_alloc_rss_indir_tbl()
5173 bp->rss_indir_tbl = kmalloc_array(entries, sizeof(*bp->rss_indir_tbl), in bnxt_alloc_rss_indir_tbl()
5175 if (!bp->rss_indir_tbl) in bnxt_alloc_rss_indir_tbl()
5176 return -ENOMEM; in bnxt_alloc_rss_indir_tbl()
5184 if (!bp->rx_nr_rings) in bnxt_set_dflt_rss_indir_tbl()
5188 max_rings = bp->rx_nr_rings - 1; in bnxt_set_dflt_rss_indir_tbl()
5190 max_rings = bp->rx_nr_rings; in bnxt_set_dflt_rss_indir_tbl()
5192 max_entries = bnxt_get_rxfh_indir_size(bp->dev); in bnxt_set_dflt_rss_indir_tbl()
5195 bp->rss_indir_tbl[i] = ethtool_rxfh_indir_default(i, max_rings); in bnxt_set_dflt_rss_indir_tbl()
5197 pad = bp->rss_indir_tbl_entries - max_entries; in bnxt_set_dflt_rss_indir_tbl()
5199 memset(&bp->rss_indir_tbl[i], 0, pad * sizeof(u16)); in bnxt_set_dflt_rss_indir_tbl()
5206 if (!bp->rss_indir_tbl) in bnxt_get_max_rss_ring()
5209 tbl_size = bnxt_get_rxfh_indir_size(bp->dev); in bnxt_get_max_rss_ring()
5211 max_ring = max(max_ring, bp->rss_indir_tbl[i]); in bnxt_get_max_rss_ring()
5217 if (bp->flags & BNXT_FLAG_CHIP_P5) in bnxt_get_nr_rss_ctxs()
5226 bool no_rss = !(vnic->flags & BNXT_VNIC_RSS_FLAG); in bnxt_fill_hw_rss_tbl()
5232 j = bp->rss_indir_tbl[i]; in bnxt_fill_hw_rss_tbl()
5233 vnic->rss_table[i] = cpu_to_le16(vnic->fw_grp_ids[j]); in bnxt_fill_hw_rss_tbl()
5240 __le16 *ring_tbl = vnic->rss_table; in bnxt_fill_hw_rss_tbl_p5()
5244 tbl_size = bnxt_get_rxfh_indir_size(bp->dev); in bnxt_fill_hw_rss_tbl_p5()
5249 j = bp->rss_indir_tbl[i]; in bnxt_fill_hw_rss_tbl_p5()
5250 rxr = &bp->rx_ring[j]; in bnxt_fill_hw_rss_tbl_p5()
5252 ring_id = rxr->rx_ring_struct.fw_ring_id; in bnxt_fill_hw_rss_tbl_p5()
5263 if (bp->flags & BNXT_FLAG_CHIP_P5) in __bnxt_hwrm_vnic_set_rss()
5268 if (bp->rss_hash_delta) { in __bnxt_hwrm_vnic_set_rss()
5269 req->hash_type = cpu_to_le32(bp->rss_hash_delta); in __bnxt_hwrm_vnic_set_rss()
5270 if (bp->rss_hash_cfg & bp->rss_hash_delta) in __bnxt_hwrm_vnic_set_rss()
5271 req->flags |= VNIC_RSS_CFG_REQ_FLAGS_HASH_TYPE_INCLUDE; in __bnxt_hwrm_vnic_set_rss()
5273 req->flags |= VNIC_RSS_CFG_REQ_FLAGS_HASH_TYPE_EXCLUDE; in __bnxt_hwrm_vnic_set_rss()
5275 req->hash_type = cpu_to_le32(bp->rss_hash_cfg); in __bnxt_hwrm_vnic_set_rss()
5277 req->hash_mode_flags = VNIC_RSS_CFG_REQ_HASH_MODE_FLAGS_DEFAULT; in __bnxt_hwrm_vnic_set_rss()
5278 req->ring_grp_tbl_addr = cpu_to_le64(vnic->rss_table_dma_addr); in __bnxt_hwrm_vnic_set_rss()
5279 req->hash_key_tbl_addr = cpu_to_le64(vnic->rss_hash_key_dma_addr); in __bnxt_hwrm_vnic_set_rss()
5284 struct bnxt_vnic_info *vnic = &bp->vnic_info[vnic_id]; in bnxt_hwrm_vnic_set_rss()
5288 if ((bp->flags & BNXT_FLAG_CHIP_P5) || in bnxt_hwrm_vnic_set_rss()
5289 vnic->fw_rss_cos_lb_ctx[0] == INVALID_HW_RING_ID) in bnxt_hwrm_vnic_set_rss()
5298 req->rss_ctx_idx = cpu_to_le16(vnic->fw_rss_cos_lb_ctx[0]); in bnxt_hwrm_vnic_set_rss()
5304 struct bnxt_vnic_info *vnic = &bp->vnic_info[vnic_id]; in bnxt_hwrm_vnic_set_rss_p5()
5314 req->vnic_id = cpu_to_le16(vnic->fw_vnic_id); in bnxt_hwrm_vnic_set_rss_p5()
5319 ring_tbl_map = vnic->rss_table_dma_addr; in bnxt_hwrm_vnic_set_rss_p5()
5320 nr_ctxs = bnxt_get_nr_rss_ctxs(bp, bp->rx_nr_rings); in bnxt_hwrm_vnic_set_rss_p5()
5324 req->ring_grp_tbl_addr = cpu_to_le64(ring_tbl_map); in bnxt_hwrm_vnic_set_rss_p5()
5325 req->ring_table_pair_index = i; in bnxt_hwrm_vnic_set_rss_p5()
5326 req->rss_ctx_idx = cpu_to_le16(vnic->fw_rss_cos_lb_ctx[i]); in bnxt_hwrm_vnic_set_rss_p5()
5339 struct bnxt_vnic_info *vnic = &bp->vnic_info[0]; in bnxt_hwrm_update_rss_hash_cfg()
5346 req->vnic_id = cpu_to_le16(vnic->fw_vnic_id); in bnxt_hwrm_update_rss_hash_cfg()
5348 req->rss_ctx_idx = cpu_to_le16(vnic->fw_rss_cos_lb_ctx[0]); in bnxt_hwrm_update_rss_hash_cfg()
5351 bp->rss_hash_cfg = le32_to_cpu(resp->hash_type) ?: bp->rss_hash_cfg; in bnxt_hwrm_update_rss_hash_cfg()
5352 bp->rss_hash_delta = 0; in bnxt_hwrm_update_rss_hash_cfg()
5359 struct bnxt_vnic_info *vnic = &bp->vnic_info[vnic_id]; in bnxt_hwrm_vnic_set_hds()
5367 req->flags = cpu_to_le32(VNIC_PLCMODES_CFG_REQ_FLAGS_JUMBO_PLACEMENT); in bnxt_hwrm_vnic_set_hds()
5368 req->enables = cpu_to_le32(VNIC_PLCMODES_CFG_REQ_ENABLES_JUMBO_THRESH_VALID); in bnxt_hwrm_vnic_set_hds()
5371 req->jumbo_thresh = cpu_to_le16(bp->rx_buf_use_size); in bnxt_hwrm_vnic_set_hds()
5373 req->flags |= cpu_to_le32(VNIC_PLCMODES_CFG_REQ_FLAGS_HDS_IPV4 | in bnxt_hwrm_vnic_set_hds()
5375 req->enables |= in bnxt_hwrm_vnic_set_hds()
5377 req->jumbo_thresh = cpu_to_le16(bp->rx_copy_thresh); in bnxt_hwrm_vnic_set_hds()
5378 req->hds_threshold = cpu_to_le16(bp->rx_copy_thresh); in bnxt_hwrm_vnic_set_hds()
5380 req->vnic_id = cpu_to_le32(vnic->fw_vnic_id); in bnxt_hwrm_vnic_set_hds()
5392 req->rss_cos_lb_ctx_id = in bnxt_hwrm_vnic_ctx_free_one()
5393 cpu_to_le16(bp->vnic_info[vnic_id].fw_rss_cos_lb_ctx[ctx_idx]); in bnxt_hwrm_vnic_ctx_free_one()
5396 bp->vnic_info[vnic_id].fw_rss_cos_lb_ctx[ctx_idx] = INVALID_HW_RING_ID; in bnxt_hwrm_vnic_ctx_free_one()
5403 for (i = 0; i < bp->nr_vnics; i++) { in bnxt_hwrm_vnic_ctx_free()
5404 struct bnxt_vnic_info *vnic = &bp->vnic_info[i]; in bnxt_hwrm_vnic_ctx_free()
5407 if (vnic->fw_rss_cos_lb_ctx[j] != INVALID_HW_RING_ID) in bnxt_hwrm_vnic_ctx_free()
5411 bp->rsscos_nr_ctxs = 0; in bnxt_hwrm_vnic_ctx_free()
5427 bp->vnic_info[vnic_id].fw_rss_cos_lb_ctx[ctx_idx] = in bnxt_hwrm_vnic_ctx_alloc()
5428 le16_to_cpu(resp->rss_cos_lb_ctx_id); in bnxt_hwrm_vnic_ctx_alloc()
5436 if (bp->flags & BNXT_FLAG_ROCE_MIRROR_CAP) in bnxt_get_roce_vnic_mode()
5443 struct bnxt_vnic_info *vnic = &bp->vnic_info[vnic_id]; in bnxt_hwrm_vnic_cfg()
5453 if (bp->flags & BNXT_FLAG_CHIP_P5) { in bnxt_hwrm_vnic_cfg()
5454 struct bnxt_rx_ring_info *rxr = &bp->rx_ring[0]; in bnxt_hwrm_vnic_cfg()
5456 req->default_rx_ring_id = in bnxt_hwrm_vnic_cfg()
5457 cpu_to_le16(rxr->rx_ring_struct.fw_ring_id); in bnxt_hwrm_vnic_cfg()
5458 req->default_cmpl_ring_id = in bnxt_hwrm_vnic_cfg()
5460 req->enables = in bnxt_hwrm_vnic_cfg()
5465 req->enables = cpu_to_le32(VNIC_CFG_REQ_ENABLES_DFLT_RING_GRP); in bnxt_hwrm_vnic_cfg()
5467 if (vnic->fw_rss_cos_lb_ctx[0] != INVALID_HW_RING_ID) { in bnxt_hwrm_vnic_cfg()
5468 req->rss_rule = cpu_to_le16(vnic->fw_rss_cos_lb_ctx[0]); in bnxt_hwrm_vnic_cfg()
5469 req->enables |= cpu_to_le32(VNIC_CFG_REQ_ENABLES_RSS_RULE | in bnxt_hwrm_vnic_cfg()
5471 } else if (vnic->flags & BNXT_VNIC_RFS_NEW_RSS_FLAG) { in bnxt_hwrm_vnic_cfg()
5472 req->rss_rule = in bnxt_hwrm_vnic_cfg()
5473 cpu_to_le16(bp->vnic_info[0].fw_rss_cos_lb_ctx[0]); in bnxt_hwrm_vnic_cfg()
5474 req->enables |= cpu_to_le32(VNIC_CFG_REQ_ENABLES_RSS_RULE | in bnxt_hwrm_vnic_cfg()
5476 req->flags |= cpu_to_le32(VNIC_CFG_REQ_FLAGS_RSS_DFLT_CR_MODE); in bnxt_hwrm_vnic_cfg()
5478 req->rss_rule = cpu_to_le16(0xffff); in bnxt_hwrm_vnic_cfg()
5482 (vnic->fw_rss_cos_lb_ctx[0] != INVALID_HW_RING_ID)) { in bnxt_hwrm_vnic_cfg()
5483 req->cos_rule = cpu_to_le16(vnic->fw_rss_cos_lb_ctx[1]); in bnxt_hwrm_vnic_cfg()
5484 req->enables |= cpu_to_le32(VNIC_CFG_REQ_ENABLES_COS_RULE); in bnxt_hwrm_vnic_cfg()
5486 req->cos_rule = cpu_to_le16(0xffff); in bnxt_hwrm_vnic_cfg()
5489 if (vnic->flags & BNXT_VNIC_RSS_FLAG) in bnxt_hwrm_vnic_cfg()
5491 else if (vnic->flags & BNXT_VNIC_RFS_FLAG) in bnxt_hwrm_vnic_cfg()
5492 ring = vnic_id - 1; in bnxt_hwrm_vnic_cfg()
5494 ring = bp->rx_nr_rings - 1; in bnxt_hwrm_vnic_cfg()
5496 grp_idx = bp->rx_ring[ring].bnapi->index; in bnxt_hwrm_vnic_cfg()
5497 req->dflt_ring_grp = cpu_to_le16(bp->grp_info[grp_idx].fw_grp_id); in bnxt_hwrm_vnic_cfg()
5498 req->lb_rule = cpu_to_le16(0xffff); in bnxt_hwrm_vnic_cfg()
5500 req->mru = cpu_to_le16(bp->dev->mtu + ETH_HLEN + VLAN_HLEN); in bnxt_hwrm_vnic_cfg()
5502 req->vnic_id = cpu_to_le16(vnic->fw_vnic_id); in bnxt_hwrm_vnic_cfg()
5505 def_vlan = bp->vf.vlan; in bnxt_hwrm_vnic_cfg()
5507 if ((bp->flags & BNXT_FLAG_STRIP_VLAN) || def_vlan) in bnxt_hwrm_vnic_cfg()
5508 req->flags |= cpu_to_le32(VNIC_CFG_REQ_FLAGS_VLAN_STRIP_MODE); in bnxt_hwrm_vnic_cfg()
5509 if (!vnic_id && bnxt_ulp_registered(bp->edev)) in bnxt_hwrm_vnic_cfg()
5510 req->flags |= cpu_to_le32(bnxt_get_roce_vnic_mode(bp)); in bnxt_hwrm_vnic_cfg()
5517 if (bp->vnic_info[vnic_id].fw_vnic_id != INVALID_HW_RING_ID) { in bnxt_hwrm_vnic_free_one()
5523 req->vnic_id = in bnxt_hwrm_vnic_free_one()
5524 cpu_to_le32(bp->vnic_info[vnic_id].fw_vnic_id); in bnxt_hwrm_vnic_free_one()
5527 bp->vnic_info[vnic_id].fw_vnic_id = INVALID_HW_RING_ID; in bnxt_hwrm_vnic_free_one()
5535 for (i = 0; i < bp->nr_vnics; i++) in bnxt_hwrm_vnic_free()
5544 struct bnxt_vnic_info *vnic = &bp->vnic_info[vnic_id]; in bnxt_hwrm_vnic_alloc()
5553 if (bp->flags & BNXT_FLAG_CHIP_P5) in bnxt_hwrm_vnic_alloc()
5558 grp_idx = bp->rx_ring[i].bnapi->index; in bnxt_hwrm_vnic_alloc()
5559 if (bp->grp_info[grp_idx].fw_grp_id == INVALID_HW_RING_ID) { in bnxt_hwrm_vnic_alloc()
5560 netdev_err(bp->dev, "Not enough ring groups avail:%x req:%x\n", in bnxt_hwrm_vnic_alloc()
5564 vnic->fw_grp_ids[j] = bp->grp_info[grp_idx].fw_grp_id; in bnxt_hwrm_vnic_alloc()
5569 vnic->fw_rss_cos_lb_ctx[i] = INVALID_HW_RING_ID; in bnxt_hwrm_vnic_alloc()
5571 req->flags = cpu_to_le32(VNIC_ALLOC_REQ_FLAGS_DEFAULT); in bnxt_hwrm_vnic_alloc()
5576 vnic->fw_vnic_id = le32_to_cpu(resp->vnic_id); in bnxt_hwrm_vnic_alloc()
5587 bp->hw_ring_stats_size = sizeof(struct ctx_hw_stats); in bnxt_hwrm_vnic_qcaps()
5588 bp->flags &= ~(BNXT_FLAG_NEW_RSS_CAP | BNXT_FLAG_ROCE_MIRROR_CAP); in bnxt_hwrm_vnic_qcaps()
5589 if (bp->hwrm_spec_code < 0x10600) in bnxt_hwrm_vnic_qcaps()
5599 u32 flags = le32_to_cpu(resp->flags); in bnxt_hwrm_vnic_qcaps()
5601 if (!(bp->flags & BNXT_FLAG_CHIP_P5) && in bnxt_hwrm_vnic_qcaps()
5603 bp->flags |= BNXT_FLAG_NEW_RSS_CAP; in bnxt_hwrm_vnic_qcaps()
5606 bp->flags |= BNXT_FLAG_ROCE_MIRROR_CAP; in bnxt_hwrm_vnic_qcaps()
5613 !(bp->fw_cap & BNXT_FW_CAP_EXT_HW_STATS_SUPPORTED))) in bnxt_hwrm_vnic_qcaps()
5614 bp->fw_cap |= BNXT_FW_CAP_VLAN_RX_STRIP; in bnxt_hwrm_vnic_qcaps()
5616 bp->fw_cap |= BNXT_FW_CAP_RSS_HASH_TYPE_DELTA; in bnxt_hwrm_vnic_qcaps()
5617 bp->max_tpa_v2 = le16_to_cpu(resp->max_aggs_supported); in bnxt_hwrm_vnic_qcaps()
5618 if (bp->max_tpa_v2) { in bnxt_hwrm_vnic_qcaps()
5620 bp->hw_ring_stats_size = BNXT_RING_STATS_SIZE_P5; in bnxt_hwrm_vnic_qcaps()
5622 bp->hw_ring_stats_size = BNXT_RING_STATS_SIZE_P5_SR2; in bnxt_hwrm_vnic_qcaps()
5636 if (bp->flags & BNXT_FLAG_CHIP_P5) in bnxt_hwrm_ring_grp_alloc()
5644 for (i = 0; i < bp->rx_nr_rings; i++) { in bnxt_hwrm_ring_grp_alloc()
5645 unsigned int grp_idx = bp->rx_ring[i].bnapi->index; in bnxt_hwrm_ring_grp_alloc()
5647 req->cr = cpu_to_le16(bp->grp_info[grp_idx].cp_fw_ring_id); in bnxt_hwrm_ring_grp_alloc()
5648 req->rr = cpu_to_le16(bp->grp_info[grp_idx].rx_fw_ring_id); in bnxt_hwrm_ring_grp_alloc()
5649 req->ar = cpu_to_le16(bp->grp_info[grp_idx].agg_fw_ring_id); in bnxt_hwrm_ring_grp_alloc()
5650 req->sc = cpu_to_le16(bp->grp_info[grp_idx].fw_stats_ctx); in bnxt_hwrm_ring_grp_alloc()
5657 bp->grp_info[grp_idx].fw_grp_id = in bnxt_hwrm_ring_grp_alloc()
5658 le32_to_cpu(resp->ring_group_id); in bnxt_hwrm_ring_grp_alloc()
5669 if (!bp->grp_info || (bp->flags & BNXT_FLAG_CHIP_P5)) in bnxt_hwrm_ring_grp_free()
5676 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_hwrm_ring_grp_free()
5677 if (bp->grp_info[i].fw_grp_id == INVALID_HW_RING_ID) in bnxt_hwrm_ring_grp_free()
5679 req->ring_group_id = in bnxt_hwrm_ring_grp_free()
5680 cpu_to_le32(bp->grp_info[i].fw_grp_id); in bnxt_hwrm_ring_grp_free()
5683 bp->grp_info[i].fw_grp_id = INVALID_HW_RING_ID; in bnxt_hwrm_ring_grp_free()
5694 struct bnxt_ring_mem_info *rmem = &ring->ring_mem; in hwrm_ring_alloc_send_msg()
5703 req->enables = 0; in hwrm_ring_alloc_send_msg()
5704 if (rmem->nr_pages > 1) { in hwrm_ring_alloc_send_msg()
5705 req->page_tbl_addr = cpu_to_le64(rmem->pg_tbl_map); in hwrm_ring_alloc_send_msg()
5707 req->page_size = BNXT_PAGE_SHIFT; in hwrm_ring_alloc_send_msg()
5708 req->page_tbl_depth = 1; in hwrm_ring_alloc_send_msg()
5710 req->page_tbl_addr = cpu_to_le64(rmem->dma_arr[0]); in hwrm_ring_alloc_send_msg()
5712 req->fbo = 0; in hwrm_ring_alloc_send_msg()
5714 req->logical_id = cpu_to_le16(map_index); in hwrm_ring_alloc_send_msg()
5722 req->ring_type = RING_ALLOC_REQ_RING_TYPE_TX; in hwrm_ring_alloc_send_msg()
5724 grp_info = &bp->grp_info[ring->grp_idx]; in hwrm_ring_alloc_send_msg()
5725 req->cmpl_ring_id = cpu_to_le16(bnxt_cp_ring_for_tx(bp, txr)); in hwrm_ring_alloc_send_msg()
5726 req->length = cpu_to_le32(bp->tx_ring_mask + 1); in hwrm_ring_alloc_send_msg()
5727 req->stat_ctx_id = cpu_to_le32(grp_info->fw_stats_ctx); in hwrm_ring_alloc_send_msg()
5728 req->queue_id = cpu_to_le16(ring->queue_id); in hwrm_ring_alloc_send_msg()
5732 req->ring_type = RING_ALLOC_REQ_RING_TYPE_RX; in hwrm_ring_alloc_send_msg()
5733 req->length = cpu_to_le32(bp->rx_ring_mask + 1); in hwrm_ring_alloc_send_msg()
5734 if (bp->flags & BNXT_FLAG_CHIP_P5) { in hwrm_ring_alloc_send_msg()
5738 grp_info = &bp->grp_info[ring->grp_idx]; in hwrm_ring_alloc_send_msg()
5739 req->rx_buf_size = cpu_to_le16(bp->rx_buf_use_size); in hwrm_ring_alloc_send_msg()
5740 req->stat_ctx_id = cpu_to_le32(grp_info->fw_stats_ctx); in hwrm_ring_alloc_send_msg()
5741 req->enables |= cpu_to_le32( in hwrm_ring_alloc_send_msg()
5745 req->flags = cpu_to_le16(flags); in hwrm_ring_alloc_send_msg()
5749 if (bp->flags & BNXT_FLAG_CHIP_P5) { in hwrm_ring_alloc_send_msg()
5750 req->ring_type = RING_ALLOC_REQ_RING_TYPE_RX_AGG; in hwrm_ring_alloc_send_msg()
5752 grp_info = &bp->grp_info[ring->grp_idx]; in hwrm_ring_alloc_send_msg()
5753 req->rx_ring_id = cpu_to_le16(grp_info->rx_fw_ring_id); in hwrm_ring_alloc_send_msg()
5754 req->rx_buf_size = cpu_to_le16(BNXT_RX_PAGE_SIZE); in hwrm_ring_alloc_send_msg()
5755 req->stat_ctx_id = cpu_to_le32(grp_info->fw_stats_ctx); in hwrm_ring_alloc_send_msg()
5756 req->enables |= cpu_to_le32( in hwrm_ring_alloc_send_msg()
5760 req->ring_type = RING_ALLOC_REQ_RING_TYPE_RX; in hwrm_ring_alloc_send_msg()
5762 req->length = cpu_to_le32(bp->rx_agg_ring_mask + 1); in hwrm_ring_alloc_send_msg()
5765 req->ring_type = RING_ALLOC_REQ_RING_TYPE_L2_CMPL; in hwrm_ring_alloc_send_msg()
5766 req->length = cpu_to_le32(bp->cp_ring_mask + 1); in hwrm_ring_alloc_send_msg()
5767 if (bp->flags & BNXT_FLAG_CHIP_P5) { in hwrm_ring_alloc_send_msg()
5769 grp_info = &bp->grp_info[map_index]; in hwrm_ring_alloc_send_msg()
5770 req->nq_ring_id = cpu_to_le16(grp_info->cp_fw_ring_id); in hwrm_ring_alloc_send_msg()
5771 req->cq_handle = cpu_to_le64(ring->handle); in hwrm_ring_alloc_send_msg()
5772 req->enables |= cpu_to_le32( in hwrm_ring_alloc_send_msg()
5774 } else if (bp->flags & BNXT_FLAG_USING_MSIX) { in hwrm_ring_alloc_send_msg()
5775 req->int_mode = RING_ALLOC_REQ_INT_MODE_MSIX; in hwrm_ring_alloc_send_msg()
5779 req->ring_type = RING_ALLOC_REQ_RING_TYPE_NQ; in hwrm_ring_alloc_send_msg()
5780 req->length = cpu_to_le32(bp->cp_ring_mask + 1); in hwrm_ring_alloc_send_msg()
5781 if (bp->flags & BNXT_FLAG_USING_MSIX) in hwrm_ring_alloc_send_msg()
5782 req->int_mode = RING_ALLOC_REQ_INT_MODE_MSIX; in hwrm_ring_alloc_send_msg()
5785 netdev_err(bp->dev, "hwrm alloc invalid ring type %d\n", in hwrm_ring_alloc_send_msg()
5787 return -1; in hwrm_ring_alloc_send_msg()
5792 err = le16_to_cpu(resp->error_code); in hwrm_ring_alloc_send_msg()
5793 ring_id = le16_to_cpu(resp->ring_id); in hwrm_ring_alloc_send_msg()
5798 netdev_err(bp->dev, "hwrm_ring_alloc type %d failed. rc:%x err:%x\n", in hwrm_ring_alloc_send_msg()
5800 return -EIO; in hwrm_ring_alloc_send_msg()
5802 ring->fw_ring_id = ring_id; in hwrm_ring_alloc_send_msg()
5817 req->fid = cpu_to_le16(0xffff); in bnxt_hwrm_set_async_event_cr()
5818 req->enables = cpu_to_le32(FUNC_CFG_REQ_ENABLES_ASYNC_EVENT_CR); in bnxt_hwrm_set_async_event_cr()
5819 req->async_event_cr = cpu_to_le16(idx); in bnxt_hwrm_set_async_event_cr()
5828 req->enables = in bnxt_hwrm_set_async_event_cr()
5830 req->async_event_cr = cpu_to_le16(idx); in bnxt_hwrm_set_async_event_cr()
5838 if (bp->flags & BNXT_FLAG_CHIP_P5) { in bnxt_set_db()
5840 db->doorbell = bp->bar1 + DB_PF_OFFSET_P5; in bnxt_set_db()
5842 db->doorbell = bp->bar1 + DB_VF_OFFSET_P5; in bnxt_set_db()
5845 db->db_key64 = DBR_PATH_L2 | DBR_TYPE_SQ; in bnxt_set_db()
5849 db->db_key64 = DBR_PATH_L2 | DBR_TYPE_SRQ; in bnxt_set_db()
5852 db->db_key64 = DBR_PATH_L2; in bnxt_set_db()
5855 db->db_key64 = DBR_PATH_L2; in bnxt_set_db()
5858 db->db_key64 |= (u64)xid << DBR_XID_SFT; in bnxt_set_db()
5860 db->doorbell = bp->bar1 + map_idx * 0x80; in bnxt_set_db()
5863 db->db_key32 = DB_KEY_TX; in bnxt_set_db()
5867 db->db_key32 = DB_KEY_RX; in bnxt_set_db()
5870 db->db_key32 = DB_KEY_CP; in bnxt_set_db()
5878 bool agg_rings = !!(bp->flags & BNXT_FLAG_AGG_RINGS); in bnxt_hwrm_ring_alloc()
5882 if (bp->flags & BNXT_FLAG_CHIP_P5) in bnxt_hwrm_ring_alloc()
5886 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_hwrm_ring_alloc()
5887 struct bnxt_napi *bnapi = bp->bnapi[i]; in bnxt_hwrm_ring_alloc()
5888 struct bnxt_cp_ring_info *cpr = &bnapi->cp_ring; in bnxt_hwrm_ring_alloc()
5889 struct bnxt_ring_struct *ring = &cpr->cp_ring_struct; in bnxt_hwrm_ring_alloc()
5890 u32 map_idx = ring->map_idx; in bnxt_hwrm_ring_alloc()
5893 vector = bp->irq_tbl[map_idx].vector; in bnxt_hwrm_ring_alloc()
5900 bnxt_set_db(bp, &cpr->cp_db, type, map_idx, ring->fw_ring_id); in bnxt_hwrm_ring_alloc()
5901 bnxt_db_nq(bp, &cpr->cp_db, cpr->cp_raw_cons); in bnxt_hwrm_ring_alloc()
5903 bp->grp_info[i].cp_fw_ring_id = ring->fw_ring_id; in bnxt_hwrm_ring_alloc()
5906 rc = bnxt_hwrm_set_async_event_cr(bp, ring->fw_ring_id); in bnxt_hwrm_ring_alloc()
5908 netdev_warn(bp->dev, "Failed to set async event completion ring.\n"); in bnxt_hwrm_ring_alloc()
5913 for (i = 0; i < bp->tx_nr_rings; i++) { in bnxt_hwrm_ring_alloc()
5914 struct bnxt_tx_ring_info *txr = &bp->tx_ring[i]; in bnxt_hwrm_ring_alloc()
5918 if (bp->flags & BNXT_FLAG_CHIP_P5) { in bnxt_hwrm_ring_alloc()
5919 struct bnxt_napi *bnapi = txr->bnapi; in bnxt_hwrm_ring_alloc()
5923 cpr = &bnapi->cp_ring; in bnxt_hwrm_ring_alloc()
5924 cpr2 = cpr->cp_ring_arr[BNXT_TX_HDL]; in bnxt_hwrm_ring_alloc()
5925 ring = &cpr2->cp_ring_struct; in bnxt_hwrm_ring_alloc()
5926 ring->handle = BNXT_TX_HDL; in bnxt_hwrm_ring_alloc()
5927 map_idx = bnapi->index; in bnxt_hwrm_ring_alloc()
5931 bnxt_set_db(bp, &cpr2->cp_db, type2, map_idx, in bnxt_hwrm_ring_alloc()
5932 ring->fw_ring_id); in bnxt_hwrm_ring_alloc()
5933 bnxt_db_cq(bp, &cpr2->cp_db, cpr2->cp_raw_cons); in bnxt_hwrm_ring_alloc()
5935 ring = &txr->tx_ring_struct; in bnxt_hwrm_ring_alloc()
5940 bnxt_set_db(bp, &txr->tx_db, type, map_idx, ring->fw_ring_id); in bnxt_hwrm_ring_alloc()
5944 for (i = 0; i < bp->rx_nr_rings; i++) { in bnxt_hwrm_ring_alloc()
5945 struct bnxt_rx_ring_info *rxr = &bp->rx_ring[i]; in bnxt_hwrm_ring_alloc()
5946 struct bnxt_ring_struct *ring = &rxr->rx_ring_struct; in bnxt_hwrm_ring_alloc()
5947 struct bnxt_napi *bnapi = rxr->bnapi; in bnxt_hwrm_ring_alloc()
5948 u32 map_idx = bnapi->index; in bnxt_hwrm_ring_alloc()
5953 bnxt_set_db(bp, &rxr->rx_db, type, map_idx, ring->fw_ring_id); in bnxt_hwrm_ring_alloc()
5956 bnxt_db_write(bp, &rxr->rx_db, rxr->rx_prod); in bnxt_hwrm_ring_alloc()
5957 bp->grp_info[map_idx].rx_fw_ring_id = ring->fw_ring_id; in bnxt_hwrm_ring_alloc()
5958 if (bp->flags & BNXT_FLAG_CHIP_P5) { in bnxt_hwrm_ring_alloc()
5959 struct bnxt_cp_ring_info *cpr = &bnapi->cp_ring; in bnxt_hwrm_ring_alloc()
5963 cpr2 = cpr->cp_ring_arr[BNXT_RX_HDL]; in bnxt_hwrm_ring_alloc()
5964 ring = &cpr2->cp_ring_struct; in bnxt_hwrm_ring_alloc()
5965 ring->handle = BNXT_RX_HDL; in bnxt_hwrm_ring_alloc()
5969 bnxt_set_db(bp, &cpr2->cp_db, type2, map_idx, in bnxt_hwrm_ring_alloc()
5970 ring->fw_ring_id); in bnxt_hwrm_ring_alloc()
5971 bnxt_db_cq(bp, &cpr2->cp_db, cpr2->cp_raw_cons); in bnxt_hwrm_ring_alloc()
5977 for (i = 0; i < bp->rx_nr_rings; i++) { in bnxt_hwrm_ring_alloc()
5978 struct bnxt_rx_ring_info *rxr = &bp->rx_ring[i]; in bnxt_hwrm_ring_alloc()
5980 &rxr->rx_agg_ring_struct; in bnxt_hwrm_ring_alloc()
5981 u32 grp_idx = ring->grp_idx; in bnxt_hwrm_ring_alloc()
5982 u32 map_idx = grp_idx + bp->rx_nr_rings; in bnxt_hwrm_ring_alloc()
5988 bnxt_set_db(bp, &rxr->rx_agg_db, type, map_idx, in bnxt_hwrm_ring_alloc()
5989 ring->fw_ring_id); in bnxt_hwrm_ring_alloc()
5990 bnxt_db_write(bp, &rxr->rx_agg_db, rxr->rx_agg_prod); in bnxt_hwrm_ring_alloc()
5991 bnxt_db_write(bp, &rxr->rx_db, rxr->rx_prod); in bnxt_hwrm_ring_alloc()
5992 bp->grp_info[grp_idx].agg_fw_ring_id = ring->fw_ring_id; in bnxt_hwrm_ring_alloc()
6015 req->cmpl_ring = cpu_to_le16(cmpl_ring_id); in hwrm_ring_free_send_msg()
6016 req->ring_type = ring_type; in hwrm_ring_free_send_msg()
6017 req->ring_id = cpu_to_le16(ring->fw_ring_id); in hwrm_ring_free_send_msg()
6021 error_code = le16_to_cpu(resp->error_code); in hwrm_ring_free_send_msg()
6025 netdev_err(bp->dev, "hwrm_ring_free type %d failed. rc:%x err:%x\n", in hwrm_ring_free_send_msg()
6027 return -EIO; in hwrm_ring_free_send_msg()
6037 if (!bp->bnapi) in bnxt_hwrm_ring_free()
6040 for (i = 0; i < bp->tx_nr_rings; i++) { in bnxt_hwrm_ring_free()
6041 struct bnxt_tx_ring_info *txr = &bp->tx_ring[i]; in bnxt_hwrm_ring_free()
6042 struct bnxt_ring_struct *ring = &txr->tx_ring_struct; in bnxt_hwrm_ring_free()
6044 if (ring->fw_ring_id != INVALID_HW_RING_ID) { in bnxt_hwrm_ring_free()
6051 ring->fw_ring_id = INVALID_HW_RING_ID; in bnxt_hwrm_ring_free()
6055 for (i = 0; i < bp->rx_nr_rings; i++) { in bnxt_hwrm_ring_free()
6056 struct bnxt_rx_ring_info *rxr = &bp->rx_ring[i]; in bnxt_hwrm_ring_free()
6057 struct bnxt_ring_struct *ring = &rxr->rx_ring_struct; in bnxt_hwrm_ring_free()
6058 u32 grp_idx = rxr->bnapi->index; in bnxt_hwrm_ring_free()
6060 if (ring->fw_ring_id != INVALID_HW_RING_ID) { in bnxt_hwrm_ring_free()
6067 ring->fw_ring_id = INVALID_HW_RING_ID; in bnxt_hwrm_ring_free()
6068 bp->grp_info[grp_idx].rx_fw_ring_id = in bnxt_hwrm_ring_free()
6073 if (bp->flags & BNXT_FLAG_CHIP_P5) in bnxt_hwrm_ring_free()
6077 for (i = 0; i < bp->rx_nr_rings; i++) { in bnxt_hwrm_ring_free()
6078 struct bnxt_rx_ring_info *rxr = &bp->rx_ring[i]; in bnxt_hwrm_ring_free()
6079 struct bnxt_ring_struct *ring = &rxr->rx_agg_ring_struct; in bnxt_hwrm_ring_free()
6080 u32 grp_idx = rxr->bnapi->index; in bnxt_hwrm_ring_free()
6082 if (ring->fw_ring_id != INVALID_HW_RING_ID) { in bnxt_hwrm_ring_free()
6088 ring->fw_ring_id = INVALID_HW_RING_ID; in bnxt_hwrm_ring_free()
6089 bp->grp_info[grp_idx].agg_fw_ring_id = in bnxt_hwrm_ring_free()
6100 if (bp->flags & BNXT_FLAG_CHIP_P5) in bnxt_hwrm_ring_free()
6104 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_hwrm_ring_free()
6105 struct bnxt_napi *bnapi = bp->bnapi[i]; in bnxt_hwrm_ring_free()
6106 struct bnxt_cp_ring_info *cpr = &bnapi->cp_ring; in bnxt_hwrm_ring_free()
6111 struct bnxt_cp_ring_info *cpr2 = cpr->cp_ring_arr[j]; in bnxt_hwrm_ring_free()
6114 ring = &cpr2->cp_ring_struct; in bnxt_hwrm_ring_free()
6115 if (ring->fw_ring_id == INVALID_HW_RING_ID) in bnxt_hwrm_ring_free()
6120 ring->fw_ring_id = INVALID_HW_RING_ID; in bnxt_hwrm_ring_free()
6123 ring = &cpr->cp_ring_struct; in bnxt_hwrm_ring_free()
6124 if (ring->fw_ring_id != INVALID_HW_RING_ID) { in bnxt_hwrm_ring_free()
6127 ring->fw_ring_id = INVALID_HW_RING_ID; in bnxt_hwrm_ring_free()
6128 bp->grp_info[i].cp_fw_ring_id = INVALID_HW_RING_ID; in bnxt_hwrm_ring_free()
6138 struct bnxt_hw_resc *hw_resc = &bp->hw_resc; in bnxt_hwrm_get_rings()
6143 if (bp->hwrm_spec_code < 0x10601) in bnxt_hwrm_get_rings()
6150 req->fid = cpu_to_le16(0xffff); in bnxt_hwrm_get_rings()
6158 hw_resc->resv_tx_rings = le16_to_cpu(resp->alloc_tx_rings); in bnxt_hwrm_get_rings()
6162 hw_resc->resv_rx_rings = le16_to_cpu(resp->alloc_rx_rings); in bnxt_hwrm_get_rings()
6163 hw_resc->resv_hw_ring_grps = in bnxt_hwrm_get_rings()
6164 le32_to_cpu(resp->alloc_hw_ring_grps); in bnxt_hwrm_get_rings()
6165 hw_resc->resv_vnics = le16_to_cpu(resp->alloc_vnics); in bnxt_hwrm_get_rings()
6166 cp = le16_to_cpu(resp->alloc_cmpl_rings); in bnxt_hwrm_get_rings()
6167 stats = le16_to_cpu(resp->alloc_stat_ctx); in bnxt_hwrm_get_rings()
6168 hw_resc->resv_irqs = cp; in bnxt_hwrm_get_rings()
6169 if (bp->flags & BNXT_FLAG_CHIP_P5) { in bnxt_hwrm_get_rings()
6170 int rx = hw_resc->resv_rx_rings; in bnxt_hwrm_get_rings()
6171 int tx = hw_resc->resv_tx_rings; in bnxt_hwrm_get_rings()
6173 if (bp->flags & BNXT_FLAG_AGG_RINGS) in bnxt_hwrm_get_rings()
6177 if (bp->flags & BNXT_FLAG_AGG_RINGS) in bnxt_hwrm_get_rings()
6179 hw_resc->resv_rx_rings = rx; in bnxt_hwrm_get_rings()
6180 hw_resc->resv_tx_rings = tx; in bnxt_hwrm_get_rings()
6182 hw_resc->resv_irqs = le16_to_cpu(resp->alloc_msix); in bnxt_hwrm_get_rings()
6183 hw_resc->resv_hw_ring_grps = rx; in bnxt_hwrm_get_rings()
6185 hw_resc->resv_cp_rings = cp; in bnxt_hwrm_get_rings()
6186 hw_resc->resv_stat_ctxs = stats; in bnxt_hwrm_get_rings()
6198 if (bp->hwrm_spec_code < 0x10601) in __bnxt_hwrm_get_tx_rings()
6205 req->fid = cpu_to_le16(fid); in __bnxt_hwrm_get_tx_rings()
6209 *tx_rings = le16_to_cpu(resp->alloc_tx_rings); in __bnxt_hwrm_get_tx_rings()
6227 req->fid = cpu_to_le16(0xffff); in __bnxt_hwrm_reserve_pf_rings()
6229 req->num_tx_rings = cpu_to_le16(tx_rings); in __bnxt_hwrm_reserve_pf_rings()
6233 if (bp->flags & BNXT_FLAG_CHIP_P5) { in __bnxt_hwrm_reserve_pf_rings()
6248 req->num_rx_rings = cpu_to_le16(rx_rings); in __bnxt_hwrm_reserve_pf_rings()
6249 if (bp->flags & BNXT_FLAG_CHIP_P5) { in __bnxt_hwrm_reserve_pf_rings()
6250 req->num_cmpl_rings = cpu_to_le16(tx_rings + ring_grps); in __bnxt_hwrm_reserve_pf_rings()
6251 req->num_msix = cpu_to_le16(cp_rings); in __bnxt_hwrm_reserve_pf_rings()
6252 req->num_rsscos_ctxs = in __bnxt_hwrm_reserve_pf_rings()
6255 req->num_cmpl_rings = cpu_to_le16(cp_rings); in __bnxt_hwrm_reserve_pf_rings()
6256 req->num_hw_ring_grps = cpu_to_le16(ring_grps); in __bnxt_hwrm_reserve_pf_rings()
6257 req->num_rsscos_ctxs = cpu_to_le16(1); in __bnxt_hwrm_reserve_pf_rings()
6258 if (!(bp->flags & BNXT_FLAG_NEW_RSS_CAP) && in __bnxt_hwrm_reserve_pf_rings()
6260 req->num_rsscos_ctxs = in __bnxt_hwrm_reserve_pf_rings()
6263 req->num_stat_ctxs = cpu_to_le16(stats); in __bnxt_hwrm_reserve_pf_rings()
6264 req->num_vnics = cpu_to_le16(vnics); in __bnxt_hwrm_reserve_pf_rings()
6266 req->enables = cpu_to_le32(enables); in __bnxt_hwrm_reserve_pf_rings()
6284 if (bp->flags & BNXT_FLAG_CHIP_P5) { in __bnxt_hwrm_reserve_vf_rings()
6296 req->num_l2_ctxs = cpu_to_le16(BNXT_VF_MAX_L2_CTX); in __bnxt_hwrm_reserve_vf_rings()
6297 req->num_tx_rings = cpu_to_le16(tx_rings); in __bnxt_hwrm_reserve_vf_rings()
6298 req->num_rx_rings = cpu_to_le16(rx_rings); in __bnxt_hwrm_reserve_vf_rings()
6299 if (bp->flags & BNXT_FLAG_CHIP_P5) { in __bnxt_hwrm_reserve_vf_rings()
6300 req->num_cmpl_rings = cpu_to_le16(tx_rings + ring_grps); in __bnxt_hwrm_reserve_vf_rings()
6301 req->num_rsscos_ctxs = cpu_to_le16(DIV_ROUND_UP(ring_grps, 64)); in __bnxt_hwrm_reserve_vf_rings()
6303 req->num_cmpl_rings = cpu_to_le16(cp_rings); in __bnxt_hwrm_reserve_vf_rings()
6304 req->num_hw_ring_grps = cpu_to_le16(ring_grps); in __bnxt_hwrm_reserve_vf_rings()
6305 req->num_rsscos_ctxs = cpu_to_le16(BNXT_VF_MAX_RSS_CTX); in __bnxt_hwrm_reserve_vf_rings()
6307 req->num_stat_ctxs = cpu_to_le16(stats); in __bnxt_hwrm_reserve_vf_rings()
6308 req->num_vnics = cpu_to_le16(vnics); in __bnxt_hwrm_reserve_vf_rings()
6310 req->enables = cpu_to_le32(enables); in __bnxt_hwrm_reserve_vf_rings()
6324 return -ENOMEM; in bnxt_hwrm_reserve_pf_rings()
6326 if (!req->enables) { in bnxt_hwrm_reserve_pf_rings()
6335 if (bp->hwrm_spec_code < 0x10601) in bnxt_hwrm_reserve_pf_rings()
6336 bp->hw_resc.resv_tx_rings = tx_rings; in bnxt_hwrm_reserve_pf_rings()
6349 bp->hw_resc.resv_tx_rings = tx_rings; in bnxt_hwrm_reserve_vf_rings()
6356 return -ENOMEM; in bnxt_hwrm_reserve_vf_rings()
6378 int cp = bp->cp_nr_rings; in bnxt_nq_rings_in_use()
6395 if (!(bp->flags & BNXT_FLAG_CHIP_P5)) in bnxt_cp_rings_in_use()
6398 cp = bp->tx_nr_rings + bp->rx_nr_rings; in bnxt_cp_rings_in_use()
6405 int cp = bp->cp_nr_rings; in bnxt_get_func_stat_ctxs()
6421 struct bnxt_hw_resc *hw_resc = &bp->hw_resc; in bnxt_check_rss_tbl_no_rmgr()
6424 if (hw_resc->resv_rx_rings != bp->rx_nr_rings) { in bnxt_check_rss_tbl_no_rmgr()
6425 hw_resc->resv_rx_rings = bp->rx_nr_rings; in bnxt_check_rss_tbl_no_rmgr()
6426 if (!netif_is_rxfh_configured(bp->dev)) in bnxt_check_rss_tbl_no_rmgr()
6433 struct bnxt_hw_resc *hw_resc = &bp->hw_resc; in bnxt_need_reserve_rings()
6436 int rx = bp->rx_nr_rings, stat; in bnxt_need_reserve_rings()
6439 if (hw_resc->resv_tx_rings != bp->tx_nr_rings && in bnxt_need_reserve_rings()
6440 bp->hwrm_spec_code >= 0x10601) in bnxt_need_reserve_rings()
6452 if ((bp->flags & BNXT_FLAG_RFS) && !(bp->flags & BNXT_FLAG_CHIP_P5)) in bnxt_need_reserve_rings()
6454 if (bp->flags & BNXT_FLAG_AGG_RINGS) in bnxt_need_reserve_rings()
6457 if (hw_resc->resv_rx_rings != rx || hw_resc->resv_cp_rings != cp || in bnxt_need_reserve_rings()
6458 hw_resc->resv_vnics != vnic || hw_resc->resv_stat_ctxs != stat || in bnxt_need_reserve_rings()
6459 (hw_resc->resv_hw_ring_grps != grp && in bnxt_need_reserve_rings()
6460 !(bp->flags & BNXT_FLAG_CHIP_P5))) in bnxt_need_reserve_rings()
6462 if ((bp->flags & BNXT_FLAG_CHIP_P5) && BNXT_PF(bp) && in bnxt_need_reserve_rings()
6463 hw_resc->resv_irqs != nq) in bnxt_need_reserve_rings()
6470 struct bnxt_hw_resc *hw_resc = &bp->hw_resc; in __bnxt_reserve_rings()
6472 int tx = bp->tx_nr_rings; in __bnxt_reserve_rings()
6473 int rx = bp->rx_nr_rings; in __bnxt_reserve_rings()
6481 if (bp->flags & BNXT_FLAG_SHARED_RINGS) in __bnxt_reserve_rings()
6483 if ((bp->flags & BNXT_FLAG_RFS) && !(bp->flags & BNXT_FLAG_CHIP_P5)) in __bnxt_reserve_rings()
6485 if (bp->flags & BNXT_FLAG_AGG_RINGS) in __bnxt_reserve_rings()
6487 grp = bp->rx_nr_rings; in __bnxt_reserve_rings()
6494 tx = hw_resc->resv_tx_rings; in __bnxt_reserve_rings()
6496 rx = hw_resc->resv_rx_rings; in __bnxt_reserve_rings()
6497 cp = hw_resc->resv_irqs; in __bnxt_reserve_rings()
6498 grp = hw_resc->resv_hw_ring_grps; in __bnxt_reserve_rings()
6499 vnic = hw_resc->resv_vnics; in __bnxt_reserve_rings()
6500 stat = hw_resc->resv_stat_ctxs; in __bnxt_reserve_rings()
6504 if (bp->flags & BNXT_FLAG_AGG_RINGS) { in __bnxt_reserve_rings()
6508 if (netif_running(bp->dev)) in __bnxt_reserve_rings()
6509 return -ENOMEM; in __bnxt_reserve_rings()
6511 bp->flags &= ~BNXT_FLAG_AGG_RINGS; in __bnxt_reserve_rings()
6512 bp->flags |= BNXT_FLAG_NO_AGG_RINGS; in __bnxt_reserve_rings()
6513 bp->dev->hw_features &= ~NETIF_F_LRO; in __bnxt_reserve_rings()
6514 bp->dev->features &= ~NETIF_F_LRO; in __bnxt_reserve_rings()
6519 cp = min_t(int, cp, bp->cp_nr_rings); in __bnxt_reserve_rings()
6521 stat -= bnxt_get_ulp_stat_ctxs(bp); in __bnxt_reserve_rings()
6524 if (bp->flags & BNXT_FLAG_AGG_RINGS) in __bnxt_reserve_rings()
6527 bp->tx_nr_rings = tx; in __bnxt_reserve_rings()
6532 if (rx_rings != bp->rx_nr_rings) { in __bnxt_reserve_rings()
6533 netdev_warn(bp->dev, "Able to reserve only %d out of %d requested RX rings\n", in __bnxt_reserve_rings()
6534 rx_rings, bp->rx_nr_rings); in __bnxt_reserve_rings()
6535 if (netif_is_rxfh_configured(bp->dev) && in __bnxt_reserve_rings()
6536 (bnxt_get_nr_rss_ctxs(bp, bp->rx_nr_rings) != in __bnxt_reserve_rings()
6539 netdev_warn(bp->dev, "RSS table entries reverting to default\n"); in __bnxt_reserve_rings()
6540 bp->dev->priv_flags &= ~IFF_RXFH_CONFIGURED; in __bnxt_reserve_rings()
6543 bp->rx_nr_rings = rx_rings; in __bnxt_reserve_rings()
6544 bp->cp_nr_rings = cp; in __bnxt_reserve_rings()
6547 return -ENOMEM; in __bnxt_reserve_rings()
6549 if (!netif_is_rxfh_configured(bp->dev)) in __bnxt_reserve_rings()
6573 if (!(bp->flags & BNXT_FLAG_CHIP_P5)) in bnxt_hwrm_check_vf_rings()
6576 req->flags = cpu_to_le32(flags); in bnxt_hwrm_check_vf_rings()
6595 if (bp->flags & BNXT_FLAG_CHIP_P5) in bnxt_hwrm_check_pf_rings()
6602 req->flags = cpu_to_le32(flags); in bnxt_hwrm_check_pf_rings()
6610 if (bp->hwrm_spec_code < 0x10801) in bnxt_hwrm_check_rings()
6624 struct bnxt_coal_cap *coal_cap = &bp->coal_cap; in bnxt_hwrm_coal_params_qcaps()
6629 coal_cap->cmpl_params = BNXT_LEGACY_COAL_CMPL_PARAMS; in bnxt_hwrm_coal_params_qcaps()
6630 coal_cap->num_cmpl_dma_aggr_max = 63; in bnxt_hwrm_coal_params_qcaps()
6631 coal_cap->num_cmpl_dma_aggr_during_int_max = 63; in bnxt_hwrm_coal_params_qcaps()
6632 coal_cap->cmpl_aggr_dma_tmr_max = 65535; in bnxt_hwrm_coal_params_qcaps()
6633 coal_cap->cmpl_aggr_dma_tmr_during_int_max = 65535; in bnxt_hwrm_coal_params_qcaps()
6634 coal_cap->int_lat_tmr_min_max = 65535; in bnxt_hwrm_coal_params_qcaps()
6635 coal_cap->int_lat_tmr_max_max = 65535; in bnxt_hwrm_coal_params_qcaps()
6636 coal_cap->num_cmpl_aggr_int_max = 65535; in bnxt_hwrm_coal_params_qcaps()
6637 coal_cap->timer_units = 80; in bnxt_hwrm_coal_params_qcaps()
6639 if (bp->hwrm_spec_code < 0x10902) in bnxt_hwrm_coal_params_qcaps()
6648 coal_cap->cmpl_params = le32_to_cpu(resp->cmpl_params); in bnxt_hwrm_coal_params_qcaps()
6649 coal_cap->nq_params = le32_to_cpu(resp->nq_params); in bnxt_hwrm_coal_params_qcaps()
6650 coal_cap->num_cmpl_dma_aggr_max = in bnxt_hwrm_coal_params_qcaps()
6651 le16_to_cpu(resp->num_cmpl_dma_aggr_max); in bnxt_hwrm_coal_params_qcaps()
6652 coal_cap->num_cmpl_dma_aggr_during_int_max = in bnxt_hwrm_coal_params_qcaps()
6653 le16_to_cpu(resp->num_cmpl_dma_aggr_during_int_max); in bnxt_hwrm_coal_params_qcaps()
6654 coal_cap->cmpl_aggr_dma_tmr_max = in bnxt_hwrm_coal_params_qcaps()
6655 le16_to_cpu(resp->cmpl_aggr_dma_tmr_max); in bnxt_hwrm_coal_params_qcaps()
6656 coal_cap->cmpl_aggr_dma_tmr_during_int_max = in bnxt_hwrm_coal_params_qcaps()
6657 le16_to_cpu(resp->cmpl_aggr_dma_tmr_during_int_max); in bnxt_hwrm_coal_params_qcaps()
6658 coal_cap->int_lat_tmr_min_max = in bnxt_hwrm_coal_params_qcaps()
6659 le16_to_cpu(resp->int_lat_tmr_min_max); in bnxt_hwrm_coal_params_qcaps()
6660 coal_cap->int_lat_tmr_max_max = in bnxt_hwrm_coal_params_qcaps()
6661 le16_to_cpu(resp->int_lat_tmr_max_max); in bnxt_hwrm_coal_params_qcaps()
6662 coal_cap->num_cmpl_aggr_int_max = in bnxt_hwrm_coal_params_qcaps()
6663 le16_to_cpu(resp->num_cmpl_aggr_int_max); in bnxt_hwrm_coal_params_qcaps()
6664 coal_cap->timer_units = le16_to_cpu(resp->timer_units); in bnxt_hwrm_coal_params_qcaps()
6671 struct bnxt_coal_cap *coal_cap = &bp->coal_cap; in bnxt_usec_to_coal_tmr()
6673 return usec * 1000 / coal_cap->timer_units; in bnxt_usec_to_coal_tmr()
6680 struct bnxt_coal_cap *coal_cap = &bp->coal_cap; in bnxt_hwrm_set_coal_params()
6681 u16 val, tmr, max, flags = hw_coal->flags; in bnxt_hwrm_set_coal_params()
6682 u32 cmpl_params = coal_cap->cmpl_params; in bnxt_hwrm_set_coal_params()
6684 max = hw_coal->bufs_per_record * 128; in bnxt_hwrm_set_coal_params()
6685 if (hw_coal->budget) in bnxt_hwrm_set_coal_params()
6686 max = hw_coal->bufs_per_record * hw_coal->budget; in bnxt_hwrm_set_coal_params()
6687 max = min_t(u16, max, coal_cap->num_cmpl_aggr_int_max); in bnxt_hwrm_set_coal_params()
6689 val = clamp_t(u16, hw_coal->coal_bufs, 1, max); in bnxt_hwrm_set_coal_params()
6690 req->num_cmpl_aggr_int = cpu_to_le16(val); in bnxt_hwrm_set_coal_params()
6692 val = min_t(u16, val, coal_cap->num_cmpl_dma_aggr_max); in bnxt_hwrm_set_coal_params()
6693 req->num_cmpl_dma_aggr = cpu_to_le16(val); in bnxt_hwrm_set_coal_params()
6695 val = clamp_t(u16, hw_coal->coal_bufs_irq, 1, in bnxt_hwrm_set_coal_params()
6696 coal_cap->num_cmpl_dma_aggr_during_int_max); in bnxt_hwrm_set_coal_params()
6697 req->num_cmpl_dma_aggr_during_int = cpu_to_le16(val); in bnxt_hwrm_set_coal_params()
6699 tmr = bnxt_usec_to_coal_tmr(bp, hw_coal->coal_ticks); in bnxt_hwrm_set_coal_params()
6700 tmr = clamp_t(u16, tmr, 1, coal_cap->int_lat_tmr_max_max); in bnxt_hwrm_set_coal_params()
6701 req->int_lat_tmr_max = cpu_to_le16(tmr); in bnxt_hwrm_set_coal_params()
6706 val = clamp_t(u16, val, 1, coal_cap->int_lat_tmr_min_max); in bnxt_hwrm_set_coal_params()
6707 req->int_lat_tmr_min = cpu_to_le16(val); in bnxt_hwrm_set_coal_params()
6708 req->enables |= cpu_to_le16(BNXT_COAL_CMPL_MIN_TMR_ENABLE); in bnxt_hwrm_set_coal_params()
6712 val = clamp_t(u16, tmr / 4, 1, coal_cap->cmpl_aggr_dma_tmr_max); in bnxt_hwrm_set_coal_params()
6713 req->cmpl_aggr_dma_tmr = cpu_to_le16(val); in bnxt_hwrm_set_coal_params()
6717 tmr = bnxt_usec_to_coal_tmr(bp, hw_coal->coal_ticks_irq); in bnxt_hwrm_set_coal_params()
6719 coal_cap->cmpl_aggr_dma_tmr_during_int_max); in bnxt_hwrm_set_coal_params()
6720 req->cmpl_aggr_dma_tmr_during_int = cpu_to_le16(val); in bnxt_hwrm_set_coal_params()
6721 req->enables |= in bnxt_hwrm_set_coal_params()
6726 hw_coal->idle_thresh && hw_coal->coal_ticks < hw_coal->idle_thresh) in bnxt_hwrm_set_coal_params()
6728 req->flags = cpu_to_le16(flags); in bnxt_hwrm_set_coal_params()
6729 req->enables |= cpu_to_le16(BNXT_COAL_CMPL_ENABLES); in bnxt_hwrm_set_coal_params()
6736 struct bnxt_cp_ring_info *cpr = &bnapi->cp_ring; in __bnxt_hwrm_set_coal_nq()
6737 struct bnxt_coal_cap *coal_cap = &bp->coal_cap; in __bnxt_hwrm_set_coal_nq()
6738 u32 nq_params = coal_cap->nq_params; in __bnxt_hwrm_set_coal_nq()
6749 req->ring_id = cpu_to_le16(cpr->cp_ring_struct.fw_ring_id); in __bnxt_hwrm_set_coal_nq()
6750 req->flags = in __bnxt_hwrm_set_coal_nq()
6753 tmr = bnxt_usec_to_coal_tmr(bp, hw_coal->coal_ticks) / 2; in __bnxt_hwrm_set_coal_nq()
6754 tmr = clamp_t(u16, tmr, 1, coal_cap->int_lat_tmr_min_max); in __bnxt_hwrm_set_coal_nq()
6755 req->int_lat_tmr_min = cpu_to_le16(tmr); in __bnxt_hwrm_set_coal_nq()
6756 req->enables |= cpu_to_le16(BNXT_COAL_CMPL_MIN_TMR_ENABLE); in __bnxt_hwrm_set_coal_nq()
6763 struct bnxt_cp_ring_info *cpr = &bnapi->cp_ring; in bnxt_hwrm_set_ring_coal()
6770 memcpy(&coal, &bp->rx_coal, sizeof(struct bnxt_coal)); in bnxt_hwrm_set_ring_coal()
6772 coal.coal_ticks = cpr->rx_ring_coal.coal_ticks; in bnxt_hwrm_set_ring_coal()
6773 coal.coal_bufs = cpr->rx_ring_coal.coal_bufs; in bnxt_hwrm_set_ring_coal()
6775 if (!bnapi->rx_ring) in bnxt_hwrm_set_ring_coal()
6776 return -ENODEV; in bnxt_hwrm_set_ring_coal()
6784 req_rx->ring_id = cpu_to_le16(bnxt_cp_ring_for_rx(bp, bnapi->rx_ring)); in bnxt_hwrm_set_ring_coal()
6805 bnxt_hwrm_set_coal_params(bp, &bp->rx_coal, req_rx); in bnxt_hwrm_set_coal()
6806 bnxt_hwrm_set_coal_params(bp, &bp->tx_coal, req_tx); in bnxt_hwrm_set_coal()
6810 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_hwrm_set_coal()
6811 struct bnxt_napi *bnapi = bp->bnapi[i]; in bnxt_hwrm_set_coal()
6816 if (!bnapi->rx_ring) { in bnxt_hwrm_set_coal()
6817 ring_id = bnxt_cp_ring_for_tx(bp, bnapi->tx_ring); in bnxt_hwrm_set_coal()
6820 ring_id = bnxt_cp_ring_for_rx(bp, bnapi->rx_ring); in bnxt_hwrm_set_coal()
6822 req->ring_id = cpu_to_le16(ring_id); in bnxt_hwrm_set_coal()
6828 if (!(bp->flags & BNXT_FLAG_CHIP_P5)) in bnxt_hwrm_set_coal()
6831 if (bnapi->rx_ring && bnapi->tx_ring) { in bnxt_hwrm_set_coal()
6833 ring_id = bnxt_cp_ring_for_tx(bp, bnapi->tx_ring); in bnxt_hwrm_set_coal()
6834 req->ring_id = cpu_to_le16(ring_id); in bnxt_hwrm_set_coal()
6839 if (bnapi->rx_ring) in bnxt_hwrm_set_coal()
6840 hw_coal = &bp->rx_coal; in bnxt_hwrm_set_coal()
6842 hw_coal = &bp->tx_coal; in bnxt_hwrm_set_coal()
6856 if (!bp->bnapi) in bnxt_hwrm_stat_ctx_free()
6872 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_hwrm_stat_ctx_free()
6873 struct bnxt_napi *bnapi = bp->bnapi[i]; in bnxt_hwrm_stat_ctx_free()
6874 struct bnxt_cp_ring_info *cpr = &bnapi->cp_ring; in bnxt_hwrm_stat_ctx_free()
6876 if (cpr->hw_stats_ctx_id != INVALID_STATS_CTX_ID) { in bnxt_hwrm_stat_ctx_free()
6877 req->stat_ctx_id = cpu_to_le32(cpr->hw_stats_ctx_id); in bnxt_hwrm_stat_ctx_free()
6879 req0->stat_ctx_id = req->stat_ctx_id; in bnxt_hwrm_stat_ctx_free()
6884 cpr->hw_stats_ctx_id = INVALID_STATS_CTX_ID; in bnxt_hwrm_stat_ctx_free()
6905 req->stats_dma_length = cpu_to_le16(bp->hw_ring_stats_size); in bnxt_hwrm_stat_ctx_alloc()
6906 req->update_period_ms = cpu_to_le32(bp->stats_coal_ticks / 1000); in bnxt_hwrm_stat_ctx_alloc()
6909 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_hwrm_stat_ctx_alloc()
6910 struct bnxt_napi *bnapi = bp->bnapi[i]; in bnxt_hwrm_stat_ctx_alloc()
6911 struct bnxt_cp_ring_info *cpr = &bnapi->cp_ring; in bnxt_hwrm_stat_ctx_alloc()
6913 req->stats_dma_addr = cpu_to_le64(cpr->stats.hw_stats_map); in bnxt_hwrm_stat_ctx_alloc()
6919 cpr->hw_stats_ctx_id = le32_to_cpu(resp->stat_ctx_id); in bnxt_hwrm_stat_ctx_alloc()
6921 bp->grp_info[i].fw_stats_ctx = cpr->hw_stats_ctx_id; in bnxt_hwrm_stat_ctx_alloc()
6939 req->fid = cpu_to_le16(0xffff); in bnxt_hwrm_func_qcfg()
6947 struct bnxt_vf_info *vf = &bp->vf; in bnxt_hwrm_func_qcfg()
6949 vf->vlan = le16_to_cpu(resp->vlan) & VLAN_VID_MASK; in bnxt_hwrm_func_qcfg()
6951 bp->pf.registered_vfs = le16_to_cpu(resp->registered_vfs); in bnxt_hwrm_func_qcfg()
6954 flags = le16_to_cpu(resp->flags); in bnxt_hwrm_func_qcfg()
6957 bp->fw_cap |= BNXT_FW_CAP_LLDP_AGENT; in bnxt_hwrm_func_qcfg()
6959 bp->fw_cap |= BNXT_FW_CAP_DCBX_AGENT; in bnxt_hwrm_func_qcfg()
6962 bp->flags |= BNXT_FLAG_MULTI_HOST; in bnxt_hwrm_func_qcfg()
6965 bp->fw_cap |= BNXT_FW_CAP_RING_MONITOR; in bnxt_hwrm_func_qcfg()
6967 switch (resp->port_partition_type) { in bnxt_hwrm_func_qcfg()
6971 bp->port_partition_type = resp->port_partition_type; in bnxt_hwrm_func_qcfg()
6974 if (bp->hwrm_spec_code < 0x10707 || in bnxt_hwrm_func_qcfg()
6975 resp->evb_mode == FUNC_QCFG_RESP_EVB_MODE_VEB) in bnxt_hwrm_func_qcfg()
6976 bp->br_mode = BRIDGE_MODE_VEB; in bnxt_hwrm_func_qcfg()
6977 else if (resp->evb_mode == FUNC_QCFG_RESP_EVB_MODE_VEPA) in bnxt_hwrm_func_qcfg()
6978 bp->br_mode = BRIDGE_MODE_VEPA; in bnxt_hwrm_func_qcfg()
6980 bp->br_mode = BRIDGE_MODE_UNDEF; in bnxt_hwrm_func_qcfg()
6982 bp->max_mtu = le16_to_cpu(resp->max_mtu_configured); in bnxt_hwrm_func_qcfg()
6983 if (!bp->max_mtu) in bnxt_hwrm_func_qcfg()
6984 bp->max_mtu = BNXT_MAX_MTU; in bnxt_hwrm_func_qcfg()
6986 if (bp->db_size) in bnxt_hwrm_func_qcfg()
6989 if (bp->flags & BNXT_FLAG_CHIP_P5) { in bnxt_hwrm_func_qcfg()
6995 bp->db_size = PAGE_ALIGN(le16_to_cpu(resp->l2_doorbell_bar_size_kb) * in bnxt_hwrm_func_qcfg()
6997 if (!bp->db_size || bp->db_size > pci_resource_len(bp->pdev, 2) || in bnxt_hwrm_func_qcfg()
6998 bp->db_size <= min_db_offset) in bnxt_hwrm_func_qcfg()
6999 bp->db_size = pci_resource_len(bp->pdev, 2); in bnxt_hwrm_func_qcfg()
7015 init_val = resp->ctx_kind_initializer; in bnxt_init_ctx_initializer()
7016 init_mask = le16_to_cpu(resp->ctx_init_mask); in bnxt_init_ctx_initializer()
7017 offset = &resp->qp_init_offset; in bnxt_init_ctx_initializer()
7018 mem_init = &ctx->mem_init[BNXT_CTX_MEM_INIT_QP]; in bnxt_init_ctx_initializer()
7020 mem_init->init_val = init_val; in bnxt_init_ctx_initializer()
7021 mem_init->offset = BNXT_MEM_INVALID_OFFSET; in bnxt_init_ctx_initializer()
7025 offset = &resp->stat_init_offset; in bnxt_init_ctx_initializer()
7027 mem_init->offset = *offset * 4; in bnxt_init_ctx_initializer()
7029 mem_init->init_val = 0; in bnxt_init_ctx_initializer()
7031 ctx->mem_init[BNXT_CTX_MEM_INIT_QP].size = ctx->qp_entry_size; in bnxt_init_ctx_initializer()
7032 ctx->mem_init[BNXT_CTX_MEM_INIT_SRQ].size = ctx->srq_entry_size; in bnxt_init_ctx_initializer()
7033 ctx->mem_init[BNXT_CTX_MEM_INIT_CQ].size = ctx->cq_entry_size; in bnxt_init_ctx_initializer()
7034 ctx->mem_init[BNXT_CTX_MEM_INIT_VNIC].size = ctx->vnic_entry_size; in bnxt_init_ctx_initializer()
7035 ctx->mem_init[BNXT_CTX_MEM_INIT_STAT].size = ctx->stat_entry_size; in bnxt_init_ctx_initializer()
7036 ctx->mem_init[BNXT_CTX_MEM_INIT_MRAV].size = ctx->mrav_entry_size; in bnxt_init_ctx_initializer()
7045 if (bp->hwrm_spec_code < 0x10902 || BNXT_VF(bp) || bp->ctx) in bnxt_hwrm_func_backing_store_qcaps()
7061 rc = -ENOMEM; in bnxt_hwrm_func_backing_store_qcaps()
7064 ctx->qp_max_entries = le32_to_cpu(resp->qp_max_entries); in bnxt_hwrm_func_backing_store_qcaps()
7065 ctx->qp_min_qp1_entries = le16_to_cpu(resp->qp_min_qp1_entries); in bnxt_hwrm_func_backing_store_qcaps()
7066 ctx->qp_max_l2_entries = le16_to_cpu(resp->qp_max_l2_entries); in bnxt_hwrm_func_backing_store_qcaps()
7067 ctx->qp_entry_size = le16_to_cpu(resp->qp_entry_size); in bnxt_hwrm_func_backing_store_qcaps()
7068 ctx->srq_max_l2_entries = le16_to_cpu(resp->srq_max_l2_entries); in bnxt_hwrm_func_backing_store_qcaps()
7069 ctx->srq_max_entries = le32_to_cpu(resp->srq_max_entries); in bnxt_hwrm_func_backing_store_qcaps()
7070 ctx->srq_entry_size = le16_to_cpu(resp->srq_entry_size); in bnxt_hwrm_func_backing_store_qcaps()
7071 ctx->cq_max_l2_entries = le16_to_cpu(resp->cq_max_l2_entries); in bnxt_hwrm_func_backing_store_qcaps()
7072 ctx->cq_max_entries = le32_to_cpu(resp->cq_max_entries); in bnxt_hwrm_func_backing_store_qcaps()
7073 ctx->cq_entry_size = le16_to_cpu(resp->cq_entry_size); in bnxt_hwrm_func_backing_store_qcaps()
7074 ctx->vnic_max_vnic_entries = in bnxt_hwrm_func_backing_store_qcaps()
7075 le16_to_cpu(resp->vnic_max_vnic_entries); in bnxt_hwrm_func_backing_store_qcaps()
7076 ctx->vnic_max_ring_table_entries = in bnxt_hwrm_func_backing_store_qcaps()
7077 le16_to_cpu(resp->vnic_max_ring_table_entries); in bnxt_hwrm_func_backing_store_qcaps()
7078 ctx->vnic_entry_size = le16_to_cpu(resp->vnic_entry_size); in bnxt_hwrm_func_backing_store_qcaps()
7079 ctx->stat_max_entries = le32_to_cpu(resp->stat_max_entries); in bnxt_hwrm_func_backing_store_qcaps()
7080 ctx->stat_entry_size = le16_to_cpu(resp->stat_entry_size); in bnxt_hwrm_func_backing_store_qcaps()
7081 ctx->tqm_entry_size = le16_to_cpu(resp->tqm_entry_size); in bnxt_hwrm_func_backing_store_qcaps()
7082 ctx->tqm_min_entries_per_ring = in bnxt_hwrm_func_backing_store_qcaps()
7083 le32_to_cpu(resp->tqm_min_entries_per_ring); in bnxt_hwrm_func_backing_store_qcaps()
7084 ctx->tqm_max_entries_per_ring = in bnxt_hwrm_func_backing_store_qcaps()
7085 le32_to_cpu(resp->tqm_max_entries_per_ring); in bnxt_hwrm_func_backing_store_qcaps()
7086 ctx->tqm_entries_multiple = resp->tqm_entries_multiple; in bnxt_hwrm_func_backing_store_qcaps()
7087 if (!ctx->tqm_entries_multiple) in bnxt_hwrm_func_backing_store_qcaps()
7088 ctx->tqm_entries_multiple = 1; in bnxt_hwrm_func_backing_store_qcaps()
7089 ctx->mrav_max_entries = le32_to_cpu(resp->mrav_max_entries); in bnxt_hwrm_func_backing_store_qcaps()
7090 ctx->mrav_entry_size = le16_to_cpu(resp->mrav_entry_size); in bnxt_hwrm_func_backing_store_qcaps()
7091 ctx->mrav_num_entries_units = in bnxt_hwrm_func_backing_store_qcaps()
7092 le16_to_cpu(resp->mrav_num_entries_units); in bnxt_hwrm_func_backing_store_qcaps()
7093 ctx->tim_entry_size = le16_to_cpu(resp->tim_entry_size); in bnxt_hwrm_func_backing_store_qcaps()
7094 ctx->tim_max_entries = le32_to_cpu(resp->tim_max_entries); in bnxt_hwrm_func_backing_store_qcaps()
7098 ctx->tqm_fp_rings_count = resp->tqm_fp_rings_count; in bnxt_hwrm_func_backing_store_qcaps()
7099 if (!ctx->tqm_fp_rings_count) in bnxt_hwrm_func_backing_store_qcaps()
7100 ctx->tqm_fp_rings_count = bp->max_q; in bnxt_hwrm_func_backing_store_qcaps()
7101 else if (ctx->tqm_fp_rings_count > BNXT_MAX_TQM_FP_RINGS) in bnxt_hwrm_func_backing_store_qcaps()
7102 ctx->tqm_fp_rings_count = BNXT_MAX_TQM_FP_RINGS; in bnxt_hwrm_func_backing_store_qcaps()
7104 tqm_rings = ctx->tqm_fp_rings_count + BNXT_MAX_TQM_SP_RINGS; in bnxt_hwrm_func_backing_store_qcaps()
7108 rc = -ENOMEM; in bnxt_hwrm_func_backing_store_qcaps()
7112 ctx->tqm_mem[i] = ctx_pg; in bnxt_hwrm_func_backing_store_qcaps()
7113 bp->ctx = ctx; in bnxt_hwrm_func_backing_store_qcaps()
7125 if (!rmem->nr_pages) in bnxt_hwrm_set_pg_attr()
7129 if (rmem->depth >= 1) { in bnxt_hwrm_set_pg_attr()
7130 if (rmem->depth == 2) in bnxt_hwrm_set_pg_attr()
7134 *pg_dir = cpu_to_le64(rmem->pg_tbl_map); in bnxt_hwrm_set_pg_attr()
7136 *pg_dir = cpu_to_le64(rmem->dma_arr[0]); in bnxt_hwrm_set_pg_attr()
7150 struct bnxt_ctx_mem_info *ctx = bp->ctx; in bnxt_hwrm_func_backing_store_cfg()
7165 if (req_len > bp->hwrm_max_ext_req_len) in bnxt_hwrm_func_backing_store_cfg()
7171 req->enables = cpu_to_le32(enables); in bnxt_hwrm_func_backing_store_cfg()
7173 ctx_pg = &ctx->qp_mem; in bnxt_hwrm_func_backing_store_cfg()
7174 req->qp_num_entries = cpu_to_le32(ctx_pg->entries); in bnxt_hwrm_func_backing_store_cfg()
7175 req->qp_num_qp1_entries = cpu_to_le16(ctx->qp_min_qp1_entries); in bnxt_hwrm_func_backing_store_cfg()
7176 req->qp_num_l2_entries = cpu_to_le16(ctx->qp_max_l2_entries); in bnxt_hwrm_func_backing_store_cfg()
7177 req->qp_entry_size = cpu_to_le16(ctx->qp_entry_size); in bnxt_hwrm_func_backing_store_cfg()
7178 bnxt_hwrm_set_pg_attr(&ctx_pg->ring_mem, in bnxt_hwrm_func_backing_store_cfg()
7179 &req->qpc_pg_size_qpc_lvl, in bnxt_hwrm_func_backing_store_cfg()
7180 &req->qpc_page_dir); in bnxt_hwrm_func_backing_store_cfg()
7183 ctx_pg = &ctx->srq_mem; in bnxt_hwrm_func_backing_store_cfg()
7184 req->srq_num_entries = cpu_to_le32(ctx_pg->entries); in bnxt_hwrm_func_backing_store_cfg()
7185 req->srq_num_l2_entries = cpu_to_le16(ctx->srq_max_l2_entries); in bnxt_hwrm_func_backing_store_cfg()
7186 req->srq_entry_size = cpu_to_le16(ctx->srq_entry_size); in bnxt_hwrm_func_backing_store_cfg()
7187 bnxt_hwrm_set_pg_attr(&ctx_pg->ring_mem, in bnxt_hwrm_func_backing_store_cfg()
7188 &req->srq_pg_size_srq_lvl, in bnxt_hwrm_func_backing_store_cfg()
7189 &req->srq_page_dir); in bnxt_hwrm_func_backing_store_cfg()
7192 ctx_pg = &ctx->cq_mem; in bnxt_hwrm_func_backing_store_cfg()
7193 req->cq_num_entries = cpu_to_le32(ctx_pg->entries); in bnxt_hwrm_func_backing_store_cfg()
7194 req->cq_num_l2_entries = cpu_to_le16(ctx->cq_max_l2_entries); in bnxt_hwrm_func_backing_store_cfg()
7195 req->cq_entry_size = cpu_to_le16(ctx->cq_entry_size); in bnxt_hwrm_func_backing_store_cfg()
7196 bnxt_hwrm_set_pg_attr(&ctx_pg->ring_mem, in bnxt_hwrm_func_backing_store_cfg()
7197 &req->cq_pg_size_cq_lvl, in bnxt_hwrm_func_backing_store_cfg()
7198 &req->cq_page_dir); in bnxt_hwrm_func_backing_store_cfg()
7201 ctx_pg = &ctx->vnic_mem; in bnxt_hwrm_func_backing_store_cfg()
7202 req->vnic_num_vnic_entries = in bnxt_hwrm_func_backing_store_cfg()
7203 cpu_to_le16(ctx->vnic_max_vnic_entries); in bnxt_hwrm_func_backing_store_cfg()
7204 req->vnic_num_ring_table_entries = in bnxt_hwrm_func_backing_store_cfg()
7205 cpu_to_le16(ctx->vnic_max_ring_table_entries); in bnxt_hwrm_func_backing_store_cfg()
7206 req->vnic_entry_size = cpu_to_le16(ctx->vnic_entry_size); in bnxt_hwrm_func_backing_store_cfg()
7207 bnxt_hwrm_set_pg_attr(&ctx_pg->ring_mem, in bnxt_hwrm_func_backing_store_cfg()
7208 &req->vnic_pg_size_vnic_lvl, in bnxt_hwrm_func_backing_store_cfg()
7209 &req->vnic_page_dir); in bnxt_hwrm_func_backing_store_cfg()
7212 ctx_pg = &ctx->stat_mem; in bnxt_hwrm_func_backing_store_cfg()
7213 req->stat_num_entries = cpu_to_le32(ctx->stat_max_entries); in bnxt_hwrm_func_backing_store_cfg()
7214 req->stat_entry_size = cpu_to_le16(ctx->stat_entry_size); in bnxt_hwrm_func_backing_store_cfg()
7215 bnxt_hwrm_set_pg_attr(&ctx_pg->ring_mem, in bnxt_hwrm_func_backing_store_cfg()
7216 &req->stat_pg_size_stat_lvl, in bnxt_hwrm_func_backing_store_cfg()
7217 &req->stat_page_dir); in bnxt_hwrm_func_backing_store_cfg()
7220 ctx_pg = &ctx->mrav_mem; in bnxt_hwrm_func_backing_store_cfg()
7221 req->mrav_num_entries = cpu_to_le32(ctx_pg->entries); in bnxt_hwrm_func_backing_store_cfg()
7222 if (ctx->mrav_num_entries_units) in bnxt_hwrm_func_backing_store_cfg()
7225 req->mrav_entry_size = cpu_to_le16(ctx->mrav_entry_size); in bnxt_hwrm_func_backing_store_cfg()
7226 bnxt_hwrm_set_pg_attr(&ctx_pg->ring_mem, in bnxt_hwrm_func_backing_store_cfg()
7227 &req->mrav_pg_size_mrav_lvl, in bnxt_hwrm_func_backing_store_cfg()
7228 &req->mrav_page_dir); in bnxt_hwrm_func_backing_store_cfg()
7231 ctx_pg = &ctx->tim_mem; in bnxt_hwrm_func_backing_store_cfg()
7232 req->tim_num_entries = cpu_to_le32(ctx_pg->entries); in bnxt_hwrm_func_backing_store_cfg()
7233 req->tim_entry_size = cpu_to_le16(ctx->tim_entry_size); in bnxt_hwrm_func_backing_store_cfg()
7234 bnxt_hwrm_set_pg_attr(&ctx_pg->ring_mem, in bnxt_hwrm_func_backing_store_cfg()
7235 &req->tim_pg_size_tim_lvl, in bnxt_hwrm_func_backing_store_cfg()
7236 &req->tim_page_dir); in bnxt_hwrm_func_backing_store_cfg()
7238 for (i = 0, num_entries = &req->tqm_sp_num_entries, in bnxt_hwrm_func_backing_store_cfg()
7239 pg_attr = &req->tqm_sp_pg_size_tqm_sp_lvl, in bnxt_hwrm_func_backing_store_cfg()
7240 pg_dir = &req->tqm_sp_page_dir, in bnxt_hwrm_func_backing_store_cfg()
7247 req->tqm_entry_size = cpu_to_le16(ctx->tqm_entry_size); in bnxt_hwrm_func_backing_store_cfg()
7248 ctx_pg = ctx->tqm_mem[i]; in bnxt_hwrm_func_backing_store_cfg()
7249 *num_entries = cpu_to_le32(ctx_pg->entries); in bnxt_hwrm_func_backing_store_cfg()
7250 bnxt_hwrm_set_pg_attr(&ctx_pg->ring_mem, pg_attr, pg_dir); in bnxt_hwrm_func_backing_store_cfg()
7252 req->flags = cpu_to_le32(flags); in bnxt_hwrm_func_backing_store_cfg()
7259 struct bnxt_ring_mem_info *rmem = &ctx_pg->ring_mem; in bnxt_alloc_ctx_mem_blk()
7261 rmem->page_size = BNXT_PAGE_SIZE; in bnxt_alloc_ctx_mem_blk()
7262 rmem->pg_arr = ctx_pg->ctx_pg_arr; in bnxt_alloc_ctx_mem_blk()
7263 rmem->dma_arr = ctx_pg->ctx_dma_arr; in bnxt_alloc_ctx_mem_blk()
7264 rmem->flags = BNXT_RMEM_VALID_PTE_FLAG; in bnxt_alloc_ctx_mem_blk()
7265 if (rmem->depth >= 1) in bnxt_alloc_ctx_mem_blk()
7266 rmem->flags |= BNXT_RMEM_USE_FULL_PAGE_FLAG; in bnxt_alloc_ctx_mem_blk()
7274 struct bnxt_ring_mem_info *rmem = &ctx_pg->ring_mem; in bnxt_alloc_ctx_pg_tbls()
7278 return -EINVAL; in bnxt_alloc_ctx_pg_tbls()
7280 ctx_pg->nr_pages = DIV_ROUND_UP(mem_size, BNXT_PAGE_SIZE); in bnxt_alloc_ctx_pg_tbls()
7281 if (ctx_pg->nr_pages > MAX_CTX_TOTAL_PAGES) { in bnxt_alloc_ctx_pg_tbls()
7282 ctx_pg->nr_pages = 0; in bnxt_alloc_ctx_pg_tbls()
7283 return -EINVAL; in bnxt_alloc_ctx_pg_tbls()
7285 if (ctx_pg->nr_pages > MAX_CTX_PAGES || depth > 1) { in bnxt_alloc_ctx_pg_tbls()
7288 rmem->depth = 2; in bnxt_alloc_ctx_pg_tbls()
7289 ctx_pg->ctx_pg_tbl = kcalloc(MAX_CTX_PAGES, sizeof(ctx_pg), in bnxt_alloc_ctx_pg_tbls()
7291 if (!ctx_pg->ctx_pg_tbl) in bnxt_alloc_ctx_pg_tbls()
7292 return -ENOMEM; in bnxt_alloc_ctx_pg_tbls()
7293 nr_tbls = DIV_ROUND_UP(ctx_pg->nr_pages, MAX_CTX_PAGES); in bnxt_alloc_ctx_pg_tbls()
7294 rmem->nr_pages = nr_tbls; in bnxt_alloc_ctx_pg_tbls()
7303 return -ENOMEM; in bnxt_alloc_ctx_pg_tbls()
7304 ctx_pg->ctx_pg_tbl[i] = pg_tbl; in bnxt_alloc_ctx_pg_tbls()
7305 rmem = &pg_tbl->ring_mem; in bnxt_alloc_ctx_pg_tbls()
7306 rmem->pg_tbl = ctx_pg->ctx_pg_arr[i]; in bnxt_alloc_ctx_pg_tbls()
7307 rmem->pg_tbl_map = ctx_pg->ctx_dma_arr[i]; in bnxt_alloc_ctx_pg_tbls()
7308 rmem->depth = 1; in bnxt_alloc_ctx_pg_tbls()
7309 rmem->nr_pages = MAX_CTX_PAGES; in bnxt_alloc_ctx_pg_tbls()
7310 rmem->mem_init = mem_init; in bnxt_alloc_ctx_pg_tbls()
7311 if (i == (nr_tbls - 1)) { in bnxt_alloc_ctx_pg_tbls()
7312 int rem = ctx_pg->nr_pages % MAX_CTX_PAGES; in bnxt_alloc_ctx_pg_tbls()
7315 rmem->nr_pages = rem; in bnxt_alloc_ctx_pg_tbls()
7322 rmem->nr_pages = DIV_ROUND_UP(mem_size, BNXT_PAGE_SIZE); in bnxt_alloc_ctx_pg_tbls()
7323 if (rmem->nr_pages > 1 || depth) in bnxt_alloc_ctx_pg_tbls()
7324 rmem->depth = 1; in bnxt_alloc_ctx_pg_tbls()
7325 rmem->mem_init = mem_init; in bnxt_alloc_ctx_pg_tbls()
7334 struct bnxt_ring_mem_info *rmem = &ctx_pg->ring_mem; in bnxt_free_ctx_pg_tbls()
7336 if (rmem->depth > 1 || ctx_pg->nr_pages > MAX_CTX_PAGES || in bnxt_free_ctx_pg_tbls()
7337 ctx_pg->ctx_pg_tbl) { in bnxt_free_ctx_pg_tbls()
7338 int i, nr_tbls = rmem->nr_pages; in bnxt_free_ctx_pg_tbls()
7344 pg_tbl = ctx_pg->ctx_pg_tbl[i]; in bnxt_free_ctx_pg_tbls()
7347 rmem2 = &pg_tbl->ring_mem; in bnxt_free_ctx_pg_tbls()
7349 ctx_pg->ctx_pg_arr[i] = NULL; in bnxt_free_ctx_pg_tbls()
7351 ctx_pg->ctx_pg_tbl[i] = NULL; in bnxt_free_ctx_pg_tbls()
7353 kfree(ctx_pg->ctx_pg_tbl); in bnxt_free_ctx_pg_tbls()
7354 ctx_pg->ctx_pg_tbl = NULL; in bnxt_free_ctx_pg_tbls()
7357 ctx_pg->nr_pages = 0; in bnxt_free_ctx_pg_tbls()
7362 struct bnxt_ctx_mem_info *ctx = bp->ctx; in bnxt_free_ctx_mem()
7368 if (ctx->tqm_mem[0]) { in bnxt_free_ctx_mem()
7369 for (i = 0; i < ctx->tqm_fp_rings_count + 1; i++) in bnxt_free_ctx_mem()
7370 bnxt_free_ctx_pg_tbls(bp, ctx->tqm_mem[i]); in bnxt_free_ctx_mem()
7371 kfree(ctx->tqm_mem[0]); in bnxt_free_ctx_mem()
7372 ctx->tqm_mem[0] = NULL; in bnxt_free_ctx_mem()
7375 bnxt_free_ctx_pg_tbls(bp, &ctx->tim_mem); in bnxt_free_ctx_mem()
7376 bnxt_free_ctx_pg_tbls(bp, &ctx->mrav_mem); in bnxt_free_ctx_mem()
7377 bnxt_free_ctx_pg_tbls(bp, &ctx->stat_mem); in bnxt_free_ctx_mem()
7378 bnxt_free_ctx_pg_tbls(bp, &ctx->vnic_mem); in bnxt_free_ctx_mem()
7379 bnxt_free_ctx_pg_tbls(bp, &ctx->cq_mem); in bnxt_free_ctx_mem()
7380 bnxt_free_ctx_pg_tbls(bp, &ctx->srq_mem); in bnxt_free_ctx_mem()
7381 bnxt_free_ctx_pg_tbls(bp, &ctx->qp_mem); in bnxt_free_ctx_mem()
7382 ctx->flags &= ~BNXT_CTX_FLAG_INITED; in bnxt_free_ctx_mem()
7400 netdev_err(bp->dev, "Failed querying context mem capability, rc = %d.\n", in bnxt_alloc_ctx_mem()
7404 ctx = bp->ctx; in bnxt_alloc_ctx_mem()
7405 if (!ctx || (ctx->flags & BNXT_CTX_FLAG_INITED)) in bnxt_alloc_ctx_mem()
7408 if ((bp->flags & BNXT_FLAG_ROCE_CAP) && !is_kdump_kernel()) { in bnxt_alloc_ctx_mem()
7414 ctx_pg = &ctx->qp_mem; in bnxt_alloc_ctx_mem()
7415 ctx_pg->entries = ctx->qp_min_qp1_entries + ctx->qp_max_l2_entries + in bnxt_alloc_ctx_mem()
7417 if (ctx->qp_entry_size) { in bnxt_alloc_ctx_mem()
7418 mem_size = ctx->qp_entry_size * ctx_pg->entries; in bnxt_alloc_ctx_mem()
7419 init = &ctx->mem_init[BNXT_CTX_MEM_INIT_QP]; in bnxt_alloc_ctx_mem()
7425 ctx_pg = &ctx->srq_mem; in bnxt_alloc_ctx_mem()
7426 ctx_pg->entries = ctx->srq_max_l2_entries + extra_srqs; in bnxt_alloc_ctx_mem()
7427 if (ctx->srq_entry_size) { in bnxt_alloc_ctx_mem()
7428 mem_size = ctx->srq_entry_size * ctx_pg->entries; in bnxt_alloc_ctx_mem()
7429 init = &ctx->mem_init[BNXT_CTX_MEM_INIT_SRQ]; in bnxt_alloc_ctx_mem()
7435 ctx_pg = &ctx->cq_mem; in bnxt_alloc_ctx_mem()
7436 ctx_pg->entries = ctx->cq_max_l2_entries + extra_qps * 2; in bnxt_alloc_ctx_mem()
7437 if (ctx->cq_entry_size) { in bnxt_alloc_ctx_mem()
7438 mem_size = ctx->cq_entry_size * ctx_pg->entries; in bnxt_alloc_ctx_mem()
7439 init = &ctx->mem_init[BNXT_CTX_MEM_INIT_CQ]; in bnxt_alloc_ctx_mem()
7445 ctx_pg = &ctx->vnic_mem; in bnxt_alloc_ctx_mem()
7446 ctx_pg->entries = ctx->vnic_max_vnic_entries + in bnxt_alloc_ctx_mem()
7447 ctx->vnic_max_ring_table_entries; in bnxt_alloc_ctx_mem()
7448 if (ctx->vnic_entry_size) { in bnxt_alloc_ctx_mem()
7449 mem_size = ctx->vnic_entry_size * ctx_pg->entries; in bnxt_alloc_ctx_mem()
7450 init = &ctx->mem_init[BNXT_CTX_MEM_INIT_VNIC]; in bnxt_alloc_ctx_mem()
7456 ctx_pg = &ctx->stat_mem; in bnxt_alloc_ctx_mem()
7457 ctx_pg->entries = ctx->stat_max_entries; in bnxt_alloc_ctx_mem()
7458 if (ctx->stat_entry_size) { in bnxt_alloc_ctx_mem()
7459 mem_size = ctx->stat_entry_size * ctx_pg->entries; in bnxt_alloc_ctx_mem()
7460 init = &ctx->mem_init[BNXT_CTX_MEM_INIT_STAT]; in bnxt_alloc_ctx_mem()
7467 if (!(bp->flags & BNXT_FLAG_ROCE_CAP)) in bnxt_alloc_ctx_mem()
7470 ctx_pg = &ctx->mrav_mem; in bnxt_alloc_ctx_mem()
7476 ctx_pg->entries = num_mr + num_ah; in bnxt_alloc_ctx_mem()
7477 if (ctx->mrav_entry_size) { in bnxt_alloc_ctx_mem()
7478 mem_size = ctx->mrav_entry_size * ctx_pg->entries; in bnxt_alloc_ctx_mem()
7479 init = &ctx->mem_init[BNXT_CTX_MEM_INIT_MRAV]; in bnxt_alloc_ctx_mem()
7485 if (ctx->mrav_num_entries_units) in bnxt_alloc_ctx_mem()
7486 ctx_pg->entries = in bnxt_alloc_ctx_mem()
7487 ((num_mr / ctx->mrav_num_entries_units) << 16) | in bnxt_alloc_ctx_mem()
7488 (num_ah / ctx->mrav_num_entries_units); in bnxt_alloc_ctx_mem()
7490 ctx_pg = &ctx->tim_mem; in bnxt_alloc_ctx_mem()
7491 ctx_pg->entries = ctx->qp_mem.entries; in bnxt_alloc_ctx_mem()
7492 if (ctx->tim_entry_size) { in bnxt_alloc_ctx_mem()
7493 mem_size = ctx->tim_entry_size * ctx_pg->entries; in bnxt_alloc_ctx_mem()
7501 min = ctx->tqm_min_entries_per_ring; in bnxt_alloc_ctx_mem()
7502 entries_sp = ctx->vnic_max_vnic_entries + ctx->qp_max_l2_entries + in bnxt_alloc_ctx_mem()
7503 2 * (extra_qps + ctx->qp_min_qp1_entries) + min; in bnxt_alloc_ctx_mem()
7504 entries_sp = roundup(entries_sp, ctx->tqm_entries_multiple); in bnxt_alloc_ctx_mem()
7505 entries = ctx->qp_max_l2_entries + 2 * (extra_qps + ctx->qp_min_qp1_entries); in bnxt_alloc_ctx_mem()
7506 entries = roundup(entries, ctx->tqm_entries_multiple); in bnxt_alloc_ctx_mem()
7507 entries = clamp_t(u32, entries, min, ctx->tqm_max_entries_per_ring); in bnxt_alloc_ctx_mem()
7508 for (i = 0; i < ctx->tqm_fp_rings_count + 1; i++) { in bnxt_alloc_ctx_mem()
7509 ctx_pg = ctx->tqm_mem[i]; in bnxt_alloc_ctx_mem()
7510 ctx_pg->entries = i ? entries : entries_sp; in bnxt_alloc_ctx_mem()
7511 if (ctx->tqm_entry_size) { in bnxt_alloc_ctx_mem()
7512 mem_size = ctx->tqm_entry_size * ctx_pg->entries; in bnxt_alloc_ctx_mem()
7523 netdev_err(bp->dev, "Failed configuring context mem, rc = %d.\n", in bnxt_alloc_ctx_mem()
7527 ctx->flags |= BNXT_CTX_FLAG_INITED; in bnxt_alloc_ctx_mem()
7535 struct bnxt_hw_resc *hw_resc = &bp->hw_resc; in bnxt_hwrm_func_resc_qcaps()
7542 req->fid = cpu_to_le16(0xffff); in bnxt_hwrm_func_resc_qcaps()
7548 hw_resc->max_tx_sch_inputs = le16_to_cpu(resp->max_tx_scheduler_inputs); in bnxt_hwrm_func_resc_qcaps()
7552 hw_resc->min_rsscos_ctxs = le16_to_cpu(resp->min_rsscos_ctx); in bnxt_hwrm_func_resc_qcaps()
7553 hw_resc->max_rsscos_ctxs = le16_to_cpu(resp->max_rsscos_ctx); in bnxt_hwrm_func_resc_qcaps()
7554 hw_resc->min_cp_rings = le16_to_cpu(resp->min_cmpl_rings); in bnxt_hwrm_func_resc_qcaps()
7555 hw_resc->max_cp_rings = le16_to_cpu(resp->max_cmpl_rings); in bnxt_hwrm_func_resc_qcaps()
7556 hw_resc->min_tx_rings = le16_to_cpu(resp->min_tx_rings); in bnxt_hwrm_func_resc_qcaps()
7557 hw_resc->max_tx_rings = le16_to_cpu(resp->max_tx_rings); in bnxt_hwrm_func_resc_qcaps()
7558 hw_resc->min_rx_rings = le16_to_cpu(resp->min_rx_rings); in bnxt_hwrm_func_resc_qcaps()
7559 hw_resc->max_rx_rings = le16_to_cpu(resp->max_rx_rings); in bnxt_hwrm_func_resc_qcaps()
7560 hw_resc->min_hw_ring_grps = le16_to_cpu(resp->min_hw_ring_grps); in bnxt_hwrm_func_resc_qcaps()
7561 hw_resc->max_hw_ring_grps = le16_to_cpu(resp->max_hw_ring_grps); in bnxt_hwrm_func_resc_qcaps()
7562 hw_resc->min_l2_ctxs = le16_to_cpu(resp->min_l2_ctxs); in bnxt_hwrm_func_resc_qcaps()
7563 hw_resc->max_l2_ctxs = le16_to_cpu(resp->max_l2_ctxs); in bnxt_hwrm_func_resc_qcaps()
7564 hw_resc->min_vnics = le16_to_cpu(resp->min_vnics); in bnxt_hwrm_func_resc_qcaps()
7565 hw_resc->max_vnics = le16_to_cpu(resp->max_vnics); in bnxt_hwrm_func_resc_qcaps()
7566 hw_resc->min_stat_ctxs = le16_to_cpu(resp->min_stat_ctx); in bnxt_hwrm_func_resc_qcaps()
7567 hw_resc->max_stat_ctxs = le16_to_cpu(resp->max_stat_ctx); in bnxt_hwrm_func_resc_qcaps()
7569 if (bp->flags & BNXT_FLAG_CHIP_P5) { in bnxt_hwrm_func_resc_qcaps()
7570 u16 max_msix = le16_to_cpu(resp->max_msix); in bnxt_hwrm_func_resc_qcaps()
7572 hw_resc->max_nqs = max_msix; in bnxt_hwrm_func_resc_qcaps()
7573 hw_resc->max_hw_ring_grps = hw_resc->max_rx_rings; in bnxt_hwrm_func_resc_qcaps()
7577 struct bnxt_pf_info *pf = &bp->pf; in bnxt_hwrm_func_resc_qcaps()
7579 pf->vf_resv_strategy = in bnxt_hwrm_func_resc_qcaps()
7580 le16_to_cpu(resp->vf_reservation_strategy); in bnxt_hwrm_func_resc_qcaps()
7581 if (pf->vf_resv_strategy > BNXT_VF_RESV_STRATEGY_MINIMAL_STATIC) in bnxt_hwrm_func_resc_qcaps()
7582 pf->vf_resv_strategy = BNXT_VF_RESV_STRATEGY_MAXIMAL; in bnxt_hwrm_func_resc_qcaps()
7593 struct bnxt_ptp_cfg *ptp = bp->ptp_cfg; in __bnxt_hwrm_ptp_qcfg()
7598 if (bp->hwrm_spec_code < 0x10801 || !BNXT_CHIP_P5_THOR(bp)) { in __bnxt_hwrm_ptp_qcfg()
7599 rc = -ENODEV; in __bnxt_hwrm_ptp_qcfg()
7607 req->port_id = cpu_to_le16(bp->pf.port_id); in __bnxt_hwrm_ptp_qcfg()
7613 flags = resp->flags; in __bnxt_hwrm_ptp_qcfg()
7615 rc = -ENODEV; in __bnxt_hwrm_ptp_qcfg()
7621 rc = -ENOMEM; in __bnxt_hwrm_ptp_qcfg()
7624 ptp->bp = bp; in __bnxt_hwrm_ptp_qcfg()
7625 bp->ptp_cfg = ptp; in __bnxt_hwrm_ptp_qcfg()
7628 ptp->refclk_regs[0] = le32_to_cpu(resp->ts_ref_clock_reg_lower); in __bnxt_hwrm_ptp_qcfg()
7629 ptp->refclk_regs[1] = le32_to_cpu(resp->ts_ref_clock_reg_upper); in __bnxt_hwrm_ptp_qcfg()
7630 } else if (bp->flags & BNXT_FLAG_CHIP_P5) { in __bnxt_hwrm_ptp_qcfg()
7631 ptp->refclk_regs[0] = BNXT_TS_REG_TIMESYNC_TS0_LOWER; in __bnxt_hwrm_ptp_qcfg()
7632 ptp->refclk_regs[1] = BNXT_TS_REG_TIMESYNC_TS0_UPPER; in __bnxt_hwrm_ptp_qcfg()
7634 rc = -ENODEV; in __bnxt_hwrm_ptp_qcfg()
7640 netdev_warn(bp->dev, "PTP initialization failed.\n"); in __bnxt_hwrm_ptp_qcfg()
7649 bp->ptp_cfg = NULL; in __bnxt_hwrm_ptp_qcfg()
7657 struct bnxt_hw_resc *hw_resc = &bp->hw_resc; in __bnxt_hwrm_func_qcaps()
7665 req->fid = cpu_to_le16(0xffff); in __bnxt_hwrm_func_qcaps()
7671 flags = le32_to_cpu(resp->flags); in __bnxt_hwrm_func_qcaps()
7673 bp->flags |= BNXT_FLAG_ROCEV1_CAP; in __bnxt_hwrm_func_qcaps()
7675 bp->flags |= BNXT_FLAG_ROCEV2_CAP; in __bnxt_hwrm_func_qcaps()
7677 bp->fw_cap |= BNXT_FW_CAP_PCIE_STATS_SUPPORTED; in __bnxt_hwrm_func_qcaps()
7679 bp->fw_cap |= BNXT_FW_CAP_HOT_RESET; in __bnxt_hwrm_func_qcaps()
7681 bp->fw_cap |= BNXT_FW_CAP_EXT_STATS_SUPPORTED; in __bnxt_hwrm_func_qcaps()
7683 bp->fw_cap |= BNXT_FW_CAP_ERROR_RECOVERY; in __bnxt_hwrm_func_qcaps()
7685 bp->fw_cap |= BNXT_FW_CAP_ERR_RECOVER_RELOAD; in __bnxt_hwrm_func_qcaps()
7687 bp->fw_cap |= BNXT_FW_CAP_VLAN_TX_INSERT; in __bnxt_hwrm_func_qcaps()
7689 bp->fw_cap |= BNXT_FW_CAP_DBG_QCAPS; in __bnxt_hwrm_func_qcaps()
7691 flags_ext = le32_to_cpu(resp->flags_ext); in __bnxt_hwrm_func_qcaps()
7693 bp->fw_cap |= BNXT_FW_CAP_EXT_HW_STATS_SUPPORTED; in __bnxt_hwrm_func_qcaps()
7695 bp->fw_cap |= BNXT_FW_CAP_PTP_PPS; in __bnxt_hwrm_func_qcaps()
7697 bp->fw_cap |= BNXT_FW_CAP_PTP_RTC; in __bnxt_hwrm_func_qcaps()
7699 bp->fw_cap |= BNXT_FW_CAP_HOT_RESET_IF; in __bnxt_hwrm_func_qcaps()
7701 bp->fw_cap |= BNXT_FW_CAP_LIVEPATCH; in __bnxt_hwrm_func_qcaps()
7703 flags_ext2 = le32_to_cpu(resp->flags_ext2); in __bnxt_hwrm_func_qcaps()
7705 bp->fw_cap |= BNXT_FW_CAP_RX_ALL_PKT_TS; in __bnxt_hwrm_func_qcaps()
7707 bp->tx_push_thresh = 0; in __bnxt_hwrm_func_qcaps()
7710 bp->tx_push_thresh = BNXT_TX_PUSH_THRESH; in __bnxt_hwrm_func_qcaps()
7712 hw_resc->max_rsscos_ctxs = le16_to_cpu(resp->max_rsscos_ctx); in __bnxt_hwrm_func_qcaps()
7713 hw_resc->max_cp_rings = le16_to_cpu(resp->max_cmpl_rings); in __bnxt_hwrm_func_qcaps()
7714 hw_resc->max_tx_rings = le16_to_cpu(resp->max_tx_rings); in __bnxt_hwrm_func_qcaps()
7715 hw_resc->max_rx_rings = le16_to_cpu(resp->max_rx_rings); in __bnxt_hwrm_func_qcaps()
7716 hw_resc->max_hw_ring_grps = le32_to_cpu(resp->max_hw_ring_grps); in __bnxt_hwrm_func_qcaps()
7717 if (!hw_resc->max_hw_ring_grps) in __bnxt_hwrm_func_qcaps()
7718 hw_resc->max_hw_ring_grps = hw_resc->max_tx_rings; in __bnxt_hwrm_func_qcaps()
7719 hw_resc->max_l2_ctxs = le16_to_cpu(resp->max_l2_ctxs); in __bnxt_hwrm_func_qcaps()
7720 hw_resc->max_vnics = le16_to_cpu(resp->max_vnics); in __bnxt_hwrm_func_qcaps()
7721 hw_resc->max_stat_ctxs = le16_to_cpu(resp->max_stat_ctx); in __bnxt_hwrm_func_qcaps()
7724 struct bnxt_pf_info *pf = &bp->pf; in __bnxt_hwrm_func_qcaps()
7726 pf->fw_fid = le16_to_cpu(resp->fid); in __bnxt_hwrm_func_qcaps()
7727 pf->port_id = le16_to_cpu(resp->port_id); in __bnxt_hwrm_func_qcaps()
7728 memcpy(pf->mac_addr, resp->mac_address, ETH_ALEN); in __bnxt_hwrm_func_qcaps()
7729 pf->first_vf_id = le16_to_cpu(resp->first_vf_id); in __bnxt_hwrm_func_qcaps()
7730 pf->max_vfs = le16_to_cpu(resp->max_vfs); in __bnxt_hwrm_func_qcaps()
7731 pf->max_encap_records = le32_to_cpu(resp->max_encap_records); in __bnxt_hwrm_func_qcaps()
7732 pf->max_decap_records = le32_to_cpu(resp->max_decap_records); in __bnxt_hwrm_func_qcaps()
7733 pf->max_tx_em_flows = le32_to_cpu(resp->max_tx_em_flows); in __bnxt_hwrm_func_qcaps()
7734 pf->max_tx_wm_flows = le32_to_cpu(resp->max_tx_wm_flows); in __bnxt_hwrm_func_qcaps()
7735 pf->max_rx_em_flows = le32_to_cpu(resp->max_rx_em_flows); in __bnxt_hwrm_func_qcaps()
7736 pf->max_rx_wm_flows = le32_to_cpu(resp->max_rx_wm_flows); in __bnxt_hwrm_func_qcaps()
7737 bp->flags &= ~BNXT_FLAG_WOL_CAP; in __bnxt_hwrm_func_qcaps()
7739 bp->flags |= BNXT_FLAG_WOL_CAP; in __bnxt_hwrm_func_qcaps()
7741 bp->fw_cap |= BNXT_FW_CAP_PTP; in __bnxt_hwrm_func_qcaps()
7744 kfree(bp->ptp_cfg); in __bnxt_hwrm_func_qcaps()
7745 bp->ptp_cfg = NULL; in __bnxt_hwrm_func_qcaps()
7749 struct bnxt_vf_info *vf = &bp->vf; in __bnxt_hwrm_func_qcaps()
7751 vf->fw_fid = le16_to_cpu(resp->fid); in __bnxt_hwrm_func_qcaps()
7752 memcpy(vf->mac_addr, resp->mac_address, ETH_ALEN); in __bnxt_hwrm_func_qcaps()
7767 bp->fw_dbg_cap = 0; in bnxt_hwrm_dbg_qcaps()
7768 if (!(bp->fw_cap & BNXT_FW_CAP_DBG_QCAPS)) in bnxt_hwrm_dbg_qcaps()
7775 req->fid = cpu_to_le16(0xffff); in bnxt_hwrm_dbg_qcaps()
7781 bp->fw_dbg_cap = le32_to_cpu(resp->flags); in bnxt_hwrm_dbg_qcaps()
7801 netdev_err(bp->dev, "hwrm query qportcfg failure rc: %d\n", rc); in bnxt_hwrm_func_qcaps()
7804 if (bp->hwrm_spec_code >= 0x10803) { in bnxt_hwrm_func_qcaps()
7810 bp->fw_cap |= BNXT_FW_CAP_NEW_RM; in bnxt_hwrm_func_qcaps()
7822 if (!(bp->fw_cap & BNXT_FW_CAP_CFA_ADV_FLOW)) in bnxt_hwrm_cfa_adv_flow_mgnt_qcaps()
7834 flags = le32_to_cpu(resp->flags); in bnxt_hwrm_cfa_adv_flow_mgnt_qcaps()
7837 bp->fw_cap |= BNXT_FW_CAP_CFA_RFS_RING_TBL_IDX_V2; in bnxt_hwrm_cfa_adv_flow_mgnt_qcaps()
7846 if (bp->fw_health) in __bnxt_alloc_fw_health()
7849 bp->fw_health = kzalloc(sizeof(*bp->fw_health), GFP_KERNEL); in __bnxt_alloc_fw_health()
7850 if (!bp->fw_health) in __bnxt_alloc_fw_health()
7851 return -ENOMEM; in __bnxt_alloc_fw_health()
7853 mutex_init(&bp->fw_health->lock); in __bnxt_alloc_fw_health()
7861 if (!(bp->fw_cap & BNXT_FW_CAP_HOT_RESET) && in bnxt_alloc_fw_health()
7862 !(bp->fw_cap & BNXT_FW_CAP_ERROR_RECOVERY)) in bnxt_alloc_fw_health()
7867 bp->fw_cap &= ~BNXT_FW_CAP_HOT_RESET; in bnxt_alloc_fw_health()
7868 bp->fw_cap &= ~BNXT_FW_CAP_ERROR_RECOVERY; in bnxt_alloc_fw_health()
7877 writel(reg & BNXT_GRC_BASE_MASK, bp->bar0 + in __bnxt_map_fw_health_reg()
7884 struct bnxt_fw_health *fw_health = bp->fw_health; in bnxt_inv_fw_health_reg()
7890 reg_type = BNXT_FW_HEALTH_REG_TYPE(fw_health->regs[BNXT_FW_HEALTH_REG]); in bnxt_inv_fw_health_reg()
7892 fw_health->status_reliable = false; in bnxt_inv_fw_health_reg()
7894 reg_type = BNXT_FW_HEALTH_REG_TYPE(fw_health->regs[BNXT_FW_RESET_CNT_REG]); in bnxt_inv_fw_health_reg()
7896 fw_health->resets_reliable = false; in bnxt_inv_fw_health_reg()
7906 if (bp->fw_health) in bnxt_try_map_fw_health_reg()
7907 bp->fw_health->status_reliable = false; in bnxt_try_map_fw_health_reg()
7910 hs = bp->bar0 + BNXT_FW_HEALTH_WIN_OFF(HCOMM_STATUS_STRUCT_LOC); in bnxt_try_map_fw_health_reg()
7914 if (!bp->chip_num) { in bnxt_try_map_fw_health_reg()
7916 bp->chip_num = readl(bp->bar0 + in bnxt_try_map_fw_health_reg()
7931 netdev_warn(bp->dev, "no memory for firmware status checks\n"); in bnxt_try_map_fw_health_reg()
7935 bp->fw_health->regs[BNXT_FW_HEALTH_REG] = status_loc; in bnxt_try_map_fw_health_reg()
7939 bp->fw_health->mapped_regs[BNXT_FW_HEALTH_REG] = in bnxt_try_map_fw_health_reg()
7943 bp->fw_health->status_reliable = true; in bnxt_try_map_fw_health_reg()
7948 struct bnxt_fw_health *fw_health = bp->fw_health; in bnxt_map_fw_health_regs()
7952 bp->fw_health->status_reliable = false; in bnxt_map_fw_health_regs()
7953 bp->fw_health->resets_reliable = false; in bnxt_map_fw_health_regs()
7954 /* Only pre-map the monitoring GRC registers using window 3 */ in bnxt_map_fw_health_regs()
7956 u32 reg = fw_health->regs[i]; in bnxt_map_fw_health_regs()
7963 return -ERANGE; in bnxt_map_fw_health_regs()
7964 fw_health->mapped_regs[i] = BNXT_FW_HEALTH_WIN_OFF(reg); in bnxt_map_fw_health_regs()
7966 bp->fw_health->status_reliable = true; in bnxt_map_fw_health_regs()
7967 bp->fw_health->resets_reliable = true; in bnxt_map_fw_health_regs()
7977 if (!bp->fw_health) in bnxt_remap_fw_health_regs()
7980 if (bp->fw_cap & BNXT_FW_CAP_ERROR_RECOVERY) { in bnxt_remap_fw_health_regs()
7981 bp->fw_health->status_reliable = true; in bnxt_remap_fw_health_regs()
7982 bp->fw_health->resets_reliable = true; in bnxt_remap_fw_health_regs()
7990 struct bnxt_fw_health *fw_health = bp->fw_health; in bnxt_hwrm_error_recovery_qcfg()
7995 if (!(bp->fw_cap & BNXT_FW_CAP_ERROR_RECOVERY)) in bnxt_hwrm_error_recovery_qcfg()
8006 fw_health->flags = le32_to_cpu(resp->flags); in bnxt_hwrm_error_recovery_qcfg()
8007 if ((fw_health->flags & ERROR_RECOVERY_QCFG_RESP_FLAGS_CO_CPU) && in bnxt_hwrm_error_recovery_qcfg()
8008 !(bp->fw_cap & BNXT_FW_CAP_KONG_MB_CHNL)) { in bnxt_hwrm_error_recovery_qcfg()
8009 rc = -EINVAL; in bnxt_hwrm_error_recovery_qcfg()
8012 fw_health->polling_dsecs = le32_to_cpu(resp->driver_polling_freq); in bnxt_hwrm_error_recovery_qcfg()
8013 fw_health->master_func_wait_dsecs = in bnxt_hwrm_error_recovery_qcfg()
8014 le32_to_cpu(resp->master_func_wait_period); in bnxt_hwrm_error_recovery_qcfg()
8015 fw_health->normal_func_wait_dsecs = in bnxt_hwrm_error_recovery_qcfg()
8016 le32_to_cpu(resp->normal_func_wait_period); in bnxt_hwrm_error_recovery_qcfg()
8017 fw_health->post_reset_wait_dsecs = in bnxt_hwrm_error_recovery_qcfg()
8018 le32_to_cpu(resp->master_func_wait_period_after_reset); in bnxt_hwrm_error_recovery_qcfg()
8019 fw_health->post_reset_max_wait_dsecs = in bnxt_hwrm_error_recovery_qcfg()
8020 le32_to_cpu(resp->max_bailout_time_after_reset); in bnxt_hwrm_error_recovery_qcfg()
8021 fw_health->regs[BNXT_FW_HEALTH_REG] = in bnxt_hwrm_error_recovery_qcfg()
8022 le32_to_cpu(resp->fw_health_status_reg); in bnxt_hwrm_error_recovery_qcfg()
8023 fw_health->regs[BNXT_FW_HEARTBEAT_REG] = in bnxt_hwrm_error_recovery_qcfg()
8024 le32_to_cpu(resp->fw_heartbeat_reg); in bnxt_hwrm_error_recovery_qcfg()
8025 fw_health->regs[BNXT_FW_RESET_CNT_REG] = in bnxt_hwrm_error_recovery_qcfg()
8026 le32_to_cpu(resp->fw_reset_cnt_reg); in bnxt_hwrm_error_recovery_qcfg()
8027 fw_health->regs[BNXT_FW_RESET_INPROG_REG] = in bnxt_hwrm_error_recovery_qcfg()
8028 le32_to_cpu(resp->reset_inprogress_reg); in bnxt_hwrm_error_recovery_qcfg()
8029 fw_health->fw_reset_inprog_reg_mask = in bnxt_hwrm_error_recovery_qcfg()
8030 le32_to_cpu(resp->reset_inprogress_reg_mask); in bnxt_hwrm_error_recovery_qcfg()
8031 fw_health->fw_reset_seq_cnt = resp->reg_array_cnt; in bnxt_hwrm_error_recovery_qcfg()
8032 if (fw_health->fw_reset_seq_cnt >= 16) { in bnxt_hwrm_error_recovery_qcfg()
8033 rc = -EINVAL; in bnxt_hwrm_error_recovery_qcfg()
8036 for (i = 0; i < fw_health->fw_reset_seq_cnt; i++) { in bnxt_hwrm_error_recovery_qcfg()
8037 fw_health->fw_reset_seq_regs[i] = in bnxt_hwrm_error_recovery_qcfg()
8038 le32_to_cpu(resp->reset_reg[i]); in bnxt_hwrm_error_recovery_qcfg()
8039 fw_health->fw_reset_seq_vals[i] = in bnxt_hwrm_error_recovery_qcfg()
8040 le32_to_cpu(resp->reset_reg_val[i]); in bnxt_hwrm_error_recovery_qcfg()
8041 fw_health->fw_reset_seq_delay_msec[i] = in bnxt_hwrm_error_recovery_qcfg()
8042 resp->delay_after_reset[i]; in bnxt_hwrm_error_recovery_qcfg()
8049 bp->fw_cap &= ~BNXT_FW_CAP_ERROR_RECOVERY; in bnxt_hwrm_error_recovery_qcfg()
8062 req->enables = 0; in bnxt_hwrm_func_reset()
8072 snprintf(bp->nvm_cfg_ver, FW_VER_STR_LEN, "%d.%d.%d", in bnxt_nvm_cfg_ver_get()
8094 if (!resp->max_configurable_queues) { in bnxt_hwrm_queue_qportcfg()
8095 rc = -EINVAL; in bnxt_hwrm_queue_qportcfg()
8098 bp->max_tc = resp->max_configurable_queues; in bnxt_hwrm_queue_qportcfg()
8099 bp->max_lltc = resp->max_configurable_lossless_queues; in bnxt_hwrm_queue_qportcfg()
8100 if (bp->max_tc > BNXT_MAX_QUEUE) in bnxt_hwrm_queue_qportcfg()
8101 bp->max_tc = BNXT_MAX_QUEUE; in bnxt_hwrm_queue_qportcfg()
8103 no_rdma = !(bp->flags & BNXT_FLAG_ROCE_CAP); in bnxt_hwrm_queue_qportcfg()
8104 qptr = &resp->queue_id0; in bnxt_hwrm_queue_qportcfg()
8105 for (i = 0, j = 0; i < bp->max_tc; i++) { in bnxt_hwrm_queue_qportcfg()
8106 bp->q_info[j].queue_id = *qptr; in bnxt_hwrm_queue_qportcfg()
8107 bp->q_ids[i] = *qptr++; in bnxt_hwrm_queue_qportcfg()
8108 bp->q_info[j].queue_profile = *qptr++; in bnxt_hwrm_queue_qportcfg()
8109 bp->tc_to_qidx[j] = j; in bnxt_hwrm_queue_qportcfg()
8110 if (!BNXT_CNPQ(bp->q_info[j].queue_profile) || in bnxt_hwrm_queue_qportcfg()
8114 bp->max_q = bp->max_tc; in bnxt_hwrm_queue_qportcfg()
8115 bp->max_tc = max_t(u8, j, 1); in bnxt_hwrm_queue_qportcfg()
8117 if (resp->queue_cfg_info & QUEUE_QPORTCFG_RESP_QUEUE_CFG_INFO_ASYM_CFG) in bnxt_hwrm_queue_qportcfg()
8118 bp->max_tc = 1; in bnxt_hwrm_queue_qportcfg()
8120 if (bp->max_lltc > bp->max_tc) in bnxt_hwrm_queue_qportcfg()
8121 bp->max_lltc = bp->max_tc; in bnxt_hwrm_queue_qportcfg()
8137 req->hwrm_intf_maj = HWRM_VERSION_MAJOR; in bnxt_hwrm_poll()
8138 req->hwrm_intf_min = HWRM_VERSION_MINOR; in bnxt_hwrm_poll()
8139 req->hwrm_intf_upd = HWRM_VERSION_UPDATE; in bnxt_hwrm_poll()
8159 bp->hwrm_max_req_len = HWRM_MAX_REQ_LEN; in bnxt_hwrm_ver_get()
8160 req->hwrm_intf_maj = HWRM_VERSION_MAJOR; in bnxt_hwrm_ver_get()
8161 req->hwrm_intf_min = HWRM_VERSION_MINOR; in bnxt_hwrm_ver_get()
8162 req->hwrm_intf_upd = HWRM_VERSION_UPDATE; in bnxt_hwrm_ver_get()
8169 memcpy(&bp->ver_resp, resp, sizeof(struct hwrm_ver_get_output)); in bnxt_hwrm_ver_get()
8171 bp->hwrm_spec_code = resp->hwrm_intf_maj_8b << 16 | in bnxt_hwrm_ver_get()
8172 resp->hwrm_intf_min_8b << 8 | in bnxt_hwrm_ver_get()
8173 resp->hwrm_intf_upd_8b; in bnxt_hwrm_ver_get()
8174 if (resp->hwrm_intf_maj_8b < 1) { in bnxt_hwrm_ver_get()
8175 netdev_warn(bp->dev, "HWRM interface %d.%d.%d is older than 1.0.0.\n", in bnxt_hwrm_ver_get()
8176 resp->hwrm_intf_maj_8b, resp->hwrm_intf_min_8b, in bnxt_hwrm_ver_get()
8177 resp->hwrm_intf_upd_8b); in bnxt_hwrm_ver_get()
8178 netdev_warn(bp->dev, "Please update firmware with HWRM interface 1.0.0 or newer.\n"); in bnxt_hwrm_ver_get()
8184 if (bp->hwrm_spec_code > hwrm_ver) in bnxt_hwrm_ver_get()
8185 snprintf(bp->hwrm_ver_supp, FW_VER_STR_LEN, "%d.%d.%d", in bnxt_hwrm_ver_get()
8189 snprintf(bp->hwrm_ver_supp, FW_VER_STR_LEN, "%d.%d.%d", in bnxt_hwrm_ver_get()
8190 resp->hwrm_intf_maj_8b, resp->hwrm_intf_min_8b, in bnxt_hwrm_ver_get()
8191 resp->hwrm_intf_upd_8b); in bnxt_hwrm_ver_get()
8193 fw_maj = le16_to_cpu(resp->hwrm_fw_major); in bnxt_hwrm_ver_get()
8194 if (bp->hwrm_spec_code > 0x10803 && fw_maj) { in bnxt_hwrm_ver_get()
8195 fw_min = le16_to_cpu(resp->hwrm_fw_minor); in bnxt_hwrm_ver_get()
8196 fw_bld = le16_to_cpu(resp->hwrm_fw_build); in bnxt_hwrm_ver_get()
8197 fw_rsv = le16_to_cpu(resp->hwrm_fw_patch); in bnxt_hwrm_ver_get()
8200 fw_maj = resp->hwrm_fw_maj_8b; in bnxt_hwrm_ver_get()
8201 fw_min = resp->hwrm_fw_min_8b; in bnxt_hwrm_ver_get()
8202 fw_bld = resp->hwrm_fw_bld_8b; in bnxt_hwrm_ver_get()
8203 fw_rsv = resp->hwrm_fw_rsvd_8b; in bnxt_hwrm_ver_get()
8206 bp->fw_ver_code = BNXT_FW_VER_CODE(fw_maj, fw_min, fw_bld, fw_rsv); in bnxt_hwrm_ver_get()
8207 snprintf(bp->fw_ver_str, len, "%d.%d.%d.%d", fw_maj, fw_min, fw_bld, in bnxt_hwrm_ver_get()
8210 if (strlen(resp->active_pkg_name)) { in bnxt_hwrm_ver_get()
8211 int fw_ver_len = strlen(bp->fw_ver_str); in bnxt_hwrm_ver_get()
8213 snprintf(bp->fw_ver_str + fw_ver_len, in bnxt_hwrm_ver_get()
8214 FW_VER_STR_LEN - fw_ver_len - 1, "/pkg %s", in bnxt_hwrm_ver_get()
8215 resp->active_pkg_name); in bnxt_hwrm_ver_get()
8216 bp->fw_cap |= BNXT_FW_CAP_PKG_VER; in bnxt_hwrm_ver_get()
8219 bp->hwrm_cmd_timeout = le16_to_cpu(resp->def_req_timeout); in bnxt_hwrm_ver_get()
8220 if (!bp->hwrm_cmd_timeout) in bnxt_hwrm_ver_get()
8221 bp->hwrm_cmd_timeout = DFLT_HWRM_CMD_TIMEOUT; in bnxt_hwrm_ver_get()
8222 bp->hwrm_cmd_max_timeout = le16_to_cpu(resp->max_req_timeout) * 1000; in bnxt_hwrm_ver_get()
8223 if (!bp->hwrm_cmd_max_timeout) in bnxt_hwrm_ver_get()
8224 bp->hwrm_cmd_max_timeout = HWRM_CMD_MAX_TIMEOUT; in bnxt_hwrm_ver_get()
8225 else if (bp->hwrm_cmd_max_timeout > HWRM_CMD_MAX_TIMEOUT) in bnxt_hwrm_ver_get()
8226 …netdev_warn(bp->dev, "Device requests max timeout of %d seconds, may trigger hung task watchdog\n", in bnxt_hwrm_ver_get()
8227 bp->hwrm_cmd_max_timeout / 1000); in bnxt_hwrm_ver_get()
8229 if (resp->hwrm_intf_maj_8b >= 1) { in bnxt_hwrm_ver_get()
8230 bp->hwrm_max_req_len = le16_to_cpu(resp->max_req_win_len); in bnxt_hwrm_ver_get()
8231 bp->hwrm_max_ext_req_len = le16_to_cpu(resp->max_ext_req_len); in bnxt_hwrm_ver_get()
8233 if (bp->hwrm_max_ext_req_len < HWRM_MAX_REQ_LEN) in bnxt_hwrm_ver_get()
8234 bp->hwrm_max_ext_req_len = HWRM_MAX_REQ_LEN; in bnxt_hwrm_ver_get()
8236 bp->chip_num = le16_to_cpu(resp->chip_num); in bnxt_hwrm_ver_get()
8237 bp->chip_rev = resp->chip_rev; in bnxt_hwrm_ver_get()
8238 if (bp->chip_num == CHIP_NUM_58700 && !resp->chip_rev && in bnxt_hwrm_ver_get()
8239 !resp->chip_metal) in bnxt_hwrm_ver_get()
8240 bp->flags |= BNXT_FLAG_CHIP_NITRO_A0; in bnxt_hwrm_ver_get()
8242 dev_caps_cfg = le32_to_cpu(resp->dev_caps_cfg); in bnxt_hwrm_ver_get()
8245 bp->fw_cap |= BNXT_FW_CAP_SHORT_CMD; in bnxt_hwrm_ver_get()
8248 bp->fw_cap |= BNXT_FW_CAP_KONG_MB_CHNL; in bnxt_hwrm_ver_get()
8252 bp->fw_cap |= BNXT_FW_CAP_OVS_64BIT_HANDLE; in bnxt_hwrm_ver_get()
8256 bp->fw_cap |= BNXT_FW_CAP_TRUSTED_VF; in bnxt_hwrm_ver_get()
8260 bp->fw_cap |= BNXT_FW_CAP_CFA_ADV_FLOW; in bnxt_hwrm_ver_get()
8274 if ((BNXT_VF(bp) && bp->hwrm_spec_code < 0x10901) || in bnxt_hwrm_fw_set_time()
8275 bp->hwrm_spec_code < 0x10400) in bnxt_hwrm_fw_set_time()
8276 return -EOPNOTSUPP; in bnxt_hwrm_fw_set_time()
8283 req->year = cpu_to_le16(1900 + tm.tm_year); in bnxt_hwrm_fw_set_time()
8284 req->month = 1 + tm.tm_mon; in bnxt_hwrm_fw_set_time()
8285 req->day = tm.tm_mday; in bnxt_hwrm_fw_set_time()
8286 req->hour = tm.tm_hour; in bnxt_hwrm_fw_set_time()
8287 req->minute = tm.tm_min; in bnxt_hwrm_fw_set_time()
8288 req->second = tm.tm_sec; in bnxt_hwrm_fw_set_time()
8314 if (masks[i] == -1ULL) in __bnxt_accumulate_stats()
8323 if (!stats->hw_stats) in bnxt_accumulate_stats()
8326 __bnxt_accumulate_stats(stats->hw_stats, stats->sw_stats, in bnxt_accumulate_stats()
8327 stats->hw_masks, stats->len / 8, false); in bnxt_accumulate_stats()
8337 if (bp->flags & BNXT_FLAG_CHIP_P5) in bnxt_accumulate_all_stats()
8340 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_accumulate_all_stats()
8341 struct bnxt_napi *bnapi = bp->bnapi[i]; in bnxt_accumulate_all_stats()
8345 cpr = &bnapi->cp_ring; in bnxt_accumulate_all_stats()
8346 stats = &cpr->stats; in bnxt_accumulate_all_stats()
8349 __bnxt_accumulate_stats(stats->hw_stats, stats->sw_stats, in bnxt_accumulate_all_stats()
8350 ring0_stats->hw_masks, in bnxt_accumulate_all_stats()
8351 ring0_stats->len / 8, ignore_zero); in bnxt_accumulate_all_stats()
8353 if (bp->flags & BNXT_FLAG_PORT_STATS) { in bnxt_accumulate_all_stats()
8354 struct bnxt_stats_mem *stats = &bp->port_stats; in bnxt_accumulate_all_stats()
8355 __le64 *hw_stats = stats->hw_stats; in bnxt_accumulate_all_stats()
8356 u64 *sw_stats = stats->sw_stats; in bnxt_accumulate_all_stats()
8357 u64 *masks = stats->hw_masks; in bnxt_accumulate_all_stats()
8369 if (bp->flags & BNXT_FLAG_PORT_STATS_EXT) { in bnxt_accumulate_all_stats()
8370 bnxt_accumulate_stats(&bp->rx_port_stats_ext); in bnxt_accumulate_all_stats()
8371 bnxt_accumulate_stats(&bp->tx_port_stats_ext); in bnxt_accumulate_all_stats()
8378 struct bnxt_pf_info *pf = &bp->pf; in bnxt_hwrm_port_qstats()
8381 if (!(bp->flags & BNXT_FLAG_PORT_STATS)) in bnxt_hwrm_port_qstats()
8384 if (flags && !(bp->fw_cap & BNXT_FW_CAP_EXT_HW_STATS_SUPPORTED)) in bnxt_hwrm_port_qstats()
8385 return -EOPNOTSUPP; in bnxt_hwrm_port_qstats()
8391 req->flags = flags; in bnxt_hwrm_port_qstats()
8392 req->port_id = cpu_to_le16(pf->port_id); in bnxt_hwrm_port_qstats()
8393 req->tx_stat_host_addr = cpu_to_le64(bp->port_stats.hw_stats_map + in bnxt_hwrm_port_qstats()
8395 req->rx_stat_host_addr = cpu_to_le64(bp->port_stats.hw_stats_map); in bnxt_hwrm_port_qstats()
8405 struct bnxt_pf_info *pf = &bp->pf; in bnxt_hwrm_port_qstats_ext()
8409 if (!(bp->flags & BNXT_FLAG_PORT_STATS_EXT)) in bnxt_hwrm_port_qstats_ext()
8412 if (flags && !(bp->fw_cap & BNXT_FW_CAP_EXT_HW_STATS_SUPPORTED)) in bnxt_hwrm_port_qstats_ext()
8413 return -EOPNOTSUPP; in bnxt_hwrm_port_qstats_ext()
8419 req_qs->flags = flags; in bnxt_hwrm_port_qstats_ext()
8420 req_qs->port_id = cpu_to_le16(pf->port_id); in bnxt_hwrm_port_qstats_ext()
8421 req_qs->rx_stat_size = cpu_to_le16(sizeof(struct rx_port_stats_ext)); in bnxt_hwrm_port_qstats_ext()
8422 req_qs->rx_stat_host_addr = cpu_to_le64(bp->rx_port_stats_ext.hw_stats_map); in bnxt_hwrm_port_qstats_ext()
8423 tx_stat_size = bp->tx_port_stats_ext.hw_stats ? in bnxt_hwrm_port_qstats_ext()
8425 req_qs->tx_stat_size = cpu_to_le16(tx_stat_size); in bnxt_hwrm_port_qstats_ext()
8426 req_qs->tx_stat_host_addr = cpu_to_le64(bp->tx_port_stats_ext.hw_stats_map); in bnxt_hwrm_port_qstats_ext()
8430 bp->fw_rx_stats_ext_size = in bnxt_hwrm_port_qstats_ext()
8431 le16_to_cpu(resp_qs->rx_stat_size) / 8; in bnxt_hwrm_port_qstats_ext()
8433 bp->fw_rx_stats_ext_size > BNXT_RX_STATS_EXT_NUM_LEGACY) in bnxt_hwrm_port_qstats_ext()
8434 bp->fw_rx_stats_ext_size = BNXT_RX_STATS_EXT_NUM_LEGACY; in bnxt_hwrm_port_qstats_ext()
8436 bp->fw_tx_stats_ext_size = tx_stat_size ? in bnxt_hwrm_port_qstats_ext()
8437 le16_to_cpu(resp_qs->tx_stat_size) / 8 : 0; in bnxt_hwrm_port_qstats_ext()
8439 bp->fw_rx_stats_ext_size = 0; in bnxt_hwrm_port_qstats_ext()
8440 bp->fw_tx_stats_ext_size = 0; in bnxt_hwrm_port_qstats_ext()
8447 if (bp->fw_tx_stats_ext_size <= in bnxt_hwrm_port_qstats_ext()
8449 bp->pri2cos_valid = 0; in bnxt_hwrm_port_qstats_ext()
8457 req_qc->flags = cpu_to_le32(QUEUE_PRI2COS_QCFG_REQ_FLAGS_IVLAN); in bnxt_hwrm_port_qstats_ext()
8465 pri2cos = &resp_qc->pri0_cos_queue_id; in bnxt_hwrm_port_qstats_ext()
8473 bp->pri2cos_valid = false; in bnxt_hwrm_port_qstats_ext()
8477 for (j = 0; j < bp->max_q; j++) { in bnxt_hwrm_port_qstats_ext()
8478 if (bp->q_ids[j] == queue_id) in bnxt_hwrm_port_qstats_ext()
8479 bp->pri2cos_idx[i] = queue_idx; in bnxt_hwrm_port_qstats_ext()
8482 bp->pri2cos_valid = true; in bnxt_hwrm_port_qstats_ext()
8503 tpa_flags = bp->flags & BNXT_FLAG_TPA; in bnxt_set_tpa()
8506 for (i = 0; i < bp->nr_vnics; i++) { in bnxt_set_tpa()
8509 netdev_err(bp->dev, "hwrm vnic set tpa failure rc for vnic %d: %x\n", in bnxt_set_tpa()
8521 for (i = 0; i < bp->nr_vnics; i++) in bnxt_hwrm_clear_vnic_rss()
8527 if (!bp->vnic_info) in bnxt_clear_vnic()
8531 if (!(bp->flags & BNXT_FLAG_CHIP_P5)) { in bnxt_clear_vnic()
8537 if (bp->flags & BNXT_FLAG_TPA) in bnxt_clear_vnic()
8540 if (bp->flags & BNXT_FLAG_CHIP_P5) in bnxt_clear_vnic()
8567 return -EINVAL; in bnxt_hwrm_set_br_mode()
8573 req->fid = cpu_to_le16(0xffff); in bnxt_hwrm_set_br_mode()
8574 req->enables = cpu_to_le32(FUNC_CFG_REQ_ENABLES_EVB_MODE); in bnxt_hwrm_set_br_mode()
8575 req->evb_mode = evb_mode; in bnxt_hwrm_set_br_mode()
8584 if (BNXT_VF(bp) || bp->hwrm_spec_code < 0x10803) in bnxt_hwrm_set_cache_line_size()
8591 req->fid = cpu_to_le16(0xffff); in bnxt_hwrm_set_cache_line_size()
8592 req->enables = cpu_to_le32(FUNC_CFG_REQ_ENABLES_CACHE_LINESIZE); in bnxt_hwrm_set_cache_line_size()
8593 req->options = FUNC_CFG_REQ_OPTIONS_CACHE_LINESIZE_SIZE_64; in bnxt_hwrm_set_cache_line_size()
8595 req->options = FUNC_CFG_REQ_OPTIONS_CACHE_LINESIZE_SIZE_128; in bnxt_hwrm_set_cache_line_size()
8602 struct bnxt_vnic_info *vnic = &bp->vnic_info[vnic_id]; in __bnxt_setup_vnic()
8605 if (vnic->flags & BNXT_VNIC_RFS_NEW_RSS_FLAG) in __bnxt_setup_vnic()
8611 netdev_err(bp->dev, "hwrm vnic %d alloc failure rc: %x\n", in __bnxt_setup_vnic()
8615 bp->rsscos_nr_ctxs++; in __bnxt_setup_vnic()
8620 netdev_err(bp->dev, "hwrm vnic %d cos ctx alloc failure rc: %x\n", in __bnxt_setup_vnic()
8624 bp->rsscos_nr_ctxs++; in __bnxt_setup_vnic()
8631 netdev_err(bp->dev, "hwrm vnic %d cfg failure rc: %x\n", in __bnxt_setup_vnic()
8639 netdev_err(bp->dev, "hwrm vnic %d set rss failure rc: %x\n", in __bnxt_setup_vnic()
8644 if (bp->flags & BNXT_FLAG_AGG_RINGS) { in __bnxt_setup_vnic()
8647 netdev_err(bp->dev, "hwrm vnic %d set hds failure rc: %x\n", in __bnxt_setup_vnic()
8660 nr_ctxs = bnxt_get_nr_rss_ctxs(bp, bp->rx_nr_rings); in __bnxt_setup_vnic_p5()
8664 netdev_err(bp->dev, "hwrm vnic %d ctx %d alloc failure rc: %x\n", in __bnxt_setup_vnic_p5()
8668 bp->rsscos_nr_ctxs++; in __bnxt_setup_vnic_p5()
8671 return -ENOMEM; in __bnxt_setup_vnic_p5()
8675 netdev_err(bp->dev, "hwrm vnic %d set rss failure rc: %d\n", in __bnxt_setup_vnic_p5()
8681 netdev_err(bp->dev, "hwrm vnic %d cfg failure rc: %x\n", in __bnxt_setup_vnic_p5()
8685 if (bp->flags & BNXT_FLAG_AGG_RINGS) { in __bnxt_setup_vnic_p5()
8688 netdev_err(bp->dev, "hwrm vnic %d set hds failure rc: %x\n", in __bnxt_setup_vnic_p5()
8697 if (bp->flags & BNXT_FLAG_CHIP_P5) in bnxt_setup_vnic()
8708 if (bp->flags & BNXT_FLAG_CHIP_P5) in bnxt_alloc_rfs_vnics()
8711 for (i = 0; i < bp->rx_nr_rings; i++) { in bnxt_alloc_rfs_vnics()
8716 if (vnic_id >= bp->nr_vnics) in bnxt_alloc_rfs_vnics()
8719 vnic = &bp->vnic_info[vnic_id]; in bnxt_alloc_rfs_vnics()
8720 vnic->flags |= BNXT_VNIC_RFS_FLAG; in bnxt_alloc_rfs_vnics()
8721 if (bp->flags & BNXT_FLAG_NEW_RSS_CAP) in bnxt_alloc_rfs_vnics()
8722 vnic->flags |= BNXT_VNIC_RFS_NEW_RSS_FLAG; in bnxt_alloc_rfs_vnics()
8725 netdev_err(bp->dev, "hwrm vnic %d alloc failure rc: %x\n", in bnxt_alloc_rfs_vnics()
8743 if (BNXT_VF(bp) && !bp->vf.vlan && !bnxt_is_trusted_vf(bp, &bp->vf)) in bnxt_promisc_ok()
8753 rc = bnxt_hwrm_vnic_alloc(bp, 1, bp->rx_nr_rings - 1, 1); in bnxt_setup_nitroa0_vnic()
8755 netdev_err(bp->dev, "Cannot allocate special vnic for NS2 A0: %x\n", in bnxt_setup_nitroa0_vnic()
8762 netdev_err(bp->dev, "Cannot allocate special vnic for NS2 A0: %x\n", in bnxt_setup_nitroa0_vnic()
8774 struct bnxt_vnic_info *vnic = &bp->vnic_info[0]; in bnxt_init_chip()
8776 unsigned int rx_nr_rings = bp->rx_nr_rings; in bnxt_init_chip()
8781 netdev_err(bp->dev, "hwrm stat ctx alloc failure rc: %x\n", in bnxt_init_chip()
8789 netdev_err(bp->dev, "hwrm ring alloc failure rc: %x\n", rc); in bnxt_init_chip()
8795 netdev_err(bp->dev, "hwrm_ring_grp alloc failure: %x\n", rc); in bnxt_init_chip()
8800 rx_nr_rings--; in bnxt_init_chip()
8805 netdev_err(bp->dev, "hwrm vnic alloc failure rc: %x\n", rc); in bnxt_init_chip()
8815 if (bp->fw_cap & BNXT_FW_CAP_RSS_HASH_TYPE_DELTA) in bnxt_init_chip()
8818 if (bp->flags & BNXT_FLAG_RFS) { in bnxt_init_chip()
8824 if (bp->flags & BNXT_FLAG_TPA) { in bnxt_init_chip()
8834 rc = bnxt_hwrm_set_vnic_filter(bp, 0, 0, bp->dev->dev_addr); in bnxt_init_chip()
8836 if (BNXT_VF(bp) && rc == -ENODEV) in bnxt_init_chip()
8837 netdev_err(bp->dev, "Cannot configure L2 filter while PF is unavailable\n"); in bnxt_init_chip()
8839 netdev_err(bp->dev, "HWRM vnic filter failure rc: %x\n", rc); in bnxt_init_chip()
8842 vnic->uc_filter_count = 1; in bnxt_init_chip()
8844 vnic->rx_mask = 0; in bnxt_init_chip()
8845 if (test_bit(BNXT_STATE_HALF_OPEN, &bp->state)) in bnxt_init_chip()
8848 if (bp->dev->flags & IFF_BROADCAST) in bnxt_init_chip()
8849 vnic->rx_mask |= CFA_L2_SET_RX_MASK_REQ_MASK_BCAST; in bnxt_init_chip()
8851 if (bp->dev->flags & IFF_PROMISC) in bnxt_init_chip()
8852 vnic->rx_mask |= CFA_L2_SET_RX_MASK_REQ_MASK_PROMISCUOUS; in bnxt_init_chip()
8854 if (bp->dev->flags & IFF_ALLMULTI) { in bnxt_init_chip()
8855 vnic->rx_mask |= CFA_L2_SET_RX_MASK_REQ_MASK_ALL_MCAST; in bnxt_init_chip()
8856 vnic->mc_list_count = 0; in bnxt_init_chip()
8857 } else if (bp->dev->flags & IFF_MULTICAST) { in bnxt_init_chip()
8861 vnic->rx_mask |= mask; in bnxt_init_chip()
8871 netdev_warn(bp->dev, "HWRM set coalescing failure rc: %x\n", in bnxt_init_chip()
8877 netdev_err(bp->dev, "Special vnic setup failure for NS2 A0 rc: %x\n", in bnxt_init_chip()
8883 netdev_update_features(bp->dev); in bnxt_init_chip()
8914 struct net_device *dev = bp->dev; in bnxt_set_real_num_queues()
8916 rc = netif_set_real_num_tx_queues(dev, bp->tx_nr_rings - in bnxt_set_real_num_queues()
8917 bp->tx_nr_rings_xdp); in bnxt_set_real_num_queues()
8921 rc = netif_set_real_num_rx_queues(dev, bp->rx_nr_rings); in bnxt_set_real_num_queues()
8926 if (bp->flags & BNXT_FLAG_RFS) in bnxt_set_real_num_queues()
8927 dev->rx_cpu_rmap = alloc_irq_cpu_rmap(bp->rx_nr_rings); in bnxt_set_real_num_queues()
8943 return -ENOMEM; in bnxt_trim_rings()
8947 _rx--; in bnxt_trim_rings()
8949 _tx--; in bnxt_trim_rings()
8959 const int len = sizeof(bp->irq_tbl[0].name); in bnxt_setup_msix()
8960 struct net_device *dev = bp->dev; in bnxt_setup_msix()
8968 count = bp->tx_nr_rings_per_tc; in bnxt_setup_msix()
8974 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_setup_msix()
8978 if (bp->flags & BNXT_FLAG_SHARED_RINGS) in bnxt_setup_msix()
8980 else if (i < bp->rx_nr_rings) in bnxt_setup_msix()
8985 snprintf(bp->irq_tbl[map_idx].name, len, "%s-%s-%d", dev->name, in bnxt_setup_msix()
8987 bp->irq_tbl[map_idx].handler = bnxt_msix; in bnxt_setup_msix()
8993 const int len = sizeof(bp->irq_tbl[0].name); in bnxt_setup_inta()
8995 if (netdev_get_num_tc(bp->dev)) in bnxt_setup_inta()
8996 netdev_reset_tc(bp->dev); in bnxt_setup_inta()
8998 snprintf(bp->irq_tbl[0].name, len, "%s-%s-%d", bp->dev->name, "TxRx", in bnxt_setup_inta()
9000 bp->irq_tbl[0].handler = bnxt_inta; in bnxt_setup_inta()
9009 if (!bp->irq_tbl) { in bnxt_setup_int_mode()
9011 if (rc || !bp->irq_tbl) in bnxt_setup_int_mode()
9012 return rc ?: -ENODEV; in bnxt_setup_int_mode()
9015 if (bp->flags & BNXT_FLAG_USING_MSIX) in bnxt_setup_int_mode()
9027 return bp->hw_resc.max_rsscos_ctxs; in bnxt_get_max_func_rss_ctxs()
9032 return bp->hw_resc.max_vnics; in bnxt_get_max_func_vnics()
9038 return bp->hw_resc.max_stat_ctxs; in bnxt_get_max_func_stat_ctxs()
9043 return bp->hw_resc.max_cp_rings; in bnxt_get_max_func_cp_rings()
9048 unsigned int cp = bp->hw_resc.max_cp_rings; in bnxt_get_max_func_cp_rings_for_en()
9050 if (!(bp->flags & BNXT_FLAG_CHIP_P5)) in bnxt_get_max_func_cp_rings_for_en()
9051 cp -= bnxt_get_ulp_msix_num(bp); in bnxt_get_max_func_cp_rings_for_en()
9058 struct bnxt_hw_resc *hw_resc = &bp->hw_resc; in bnxt_get_max_func_irqs()
9060 if (bp->flags & BNXT_FLAG_CHIP_P5) in bnxt_get_max_func_irqs()
9061 return min_t(unsigned int, hw_resc->max_irqs, hw_resc->max_nqs); in bnxt_get_max_func_irqs()
9063 return min_t(unsigned int, hw_resc->max_irqs, hw_resc->max_cp_rings); in bnxt_get_max_func_irqs()
9068 bp->hw_resc.max_irqs = max_irqs; in bnxt_set_max_func_irqs()
9076 if (bp->flags & BNXT_FLAG_CHIP_P5) in bnxt_get_avail_cp_rings_for_en()
9077 return cp - bp->rx_nr_rings - bp->tx_nr_rings; in bnxt_get_avail_cp_rings_for_en()
9079 return cp - bp->cp_nr_rings; in bnxt_get_avail_cp_rings_for_en()
9084 return bnxt_get_max_func_stat_ctxs(bp) - bnxt_get_func_stat_ctxs(bp); in bnxt_get_avail_stat_ctxs_for_en()
9091 int total_req = bp->cp_nr_rings + num; in bnxt_get_avail_msix()
9094 max_idx = bp->total_irqs; in bnxt_get_avail_msix()
9095 if (!(bp->flags & BNXT_FLAG_CHIP_P5)) in bnxt_get_avail_msix()
9096 max_idx = min_t(int, bp->total_irqs, max_cp); in bnxt_get_avail_msix()
9097 avail_msix = max_idx - bp->cp_nr_rings; in bnxt_get_avail_msix()
9102 num = max_irq - bp->cp_nr_rings; in bnxt_get_avail_msix()
9132 return -ENOMEM; in bnxt_init_msix()
9139 if (!(bp->flags & BNXT_FLAG_SHARED_RINGS)) in bnxt_init_msix()
9142 total_vecs = pci_enable_msix_range(bp->pdev, msix_ent, min, total_vecs); in bnxt_init_msix()
9145 rc = -ENODEV; in bnxt_init_msix()
9149 bp->irq_tbl = kcalloc(total_vecs, sizeof(struct bnxt_irq), GFP_KERNEL); in bnxt_init_msix()
9150 if (bp->irq_tbl) { in bnxt_init_msix()
9152 bp->irq_tbl[i].vector = msix_ent[i].vector; in bnxt_init_msix()
9154 bp->total_irqs = total_vecs; in bnxt_init_msix()
9156 rc = bnxt_trim_rings(bp, &bp->rx_nr_rings, &bp->tx_nr_rings, in bnxt_init_msix()
9157 total_vecs - ulp_msix, min == 1); in bnxt_init_msix()
9161 bp->cp_nr_rings = (min == 1) ? in bnxt_init_msix()
9162 max_t(int, bp->tx_nr_rings, bp->rx_nr_rings) : in bnxt_init_msix()
9163 bp->tx_nr_rings + bp->rx_nr_rings; in bnxt_init_msix()
9166 rc = -ENOMEM; in bnxt_init_msix()
9169 bp->flags |= BNXT_FLAG_USING_MSIX; in bnxt_init_msix()
9174 netdev_err(bp->dev, "bnxt_init_msix err: %x\n", rc); in bnxt_init_msix()
9175 kfree(bp->irq_tbl); in bnxt_init_msix()
9176 bp->irq_tbl = NULL; in bnxt_init_msix()
9177 pci_disable_msix(bp->pdev); in bnxt_init_msix()
9184 bp->irq_tbl = kzalloc(sizeof(struct bnxt_irq), GFP_KERNEL); in bnxt_init_inta()
9185 if (!bp->irq_tbl) in bnxt_init_inta()
9186 return -ENOMEM; in bnxt_init_inta()
9188 bp->total_irqs = 1; in bnxt_init_inta()
9189 bp->rx_nr_rings = 1; in bnxt_init_inta()
9190 bp->tx_nr_rings = 1; in bnxt_init_inta()
9191 bp->cp_nr_rings = 1; in bnxt_init_inta()
9192 bp->flags |= BNXT_FLAG_SHARED_RINGS; in bnxt_init_inta()
9193 bp->irq_tbl[0].vector = bp->pdev->irq; in bnxt_init_inta()
9199 int rc = -ENODEV; in bnxt_init_int_mode()
9201 if (bp->flags & BNXT_FLAG_MSIX_CAP) in bnxt_init_int_mode()
9204 if (!(bp->flags & BNXT_FLAG_USING_MSIX) && BNXT_PF(bp)) { in bnxt_init_int_mode()
9213 if (bp->flags & BNXT_FLAG_USING_MSIX) in bnxt_clear_int_mode()
9214 pci_disable_msix(bp->pdev); in bnxt_clear_int_mode()
9216 kfree(bp->irq_tbl); in bnxt_clear_int_mode()
9217 bp->irq_tbl = NULL; in bnxt_clear_int_mode()
9218 bp->flags &= ~BNXT_FLAG_USING_MSIX; in bnxt_clear_int_mode()
9223 int tcs = netdev_get_num_tc(bp->dev); in bnxt_reserve_rings()
9231 bnxt_get_num_msix(bp) != bp->total_irqs) { in bnxt_reserve_rings()
9243 netdev_err(bp->dev, "ring reservation/IRQ init failure rc: %d\n", rc); in bnxt_reserve_rings()
9246 if (tcs && (bp->tx_nr_rings_per_tc * tcs != in bnxt_reserve_rings()
9247 bp->tx_nr_rings - bp->tx_nr_rings_xdp)) { in bnxt_reserve_rings()
9248 netdev_err(bp->dev, "tx ring reservation failure\n"); in bnxt_reserve_rings()
9249 netdev_reset_tc(bp->dev); in bnxt_reserve_rings()
9250 if (bp->tx_nr_rings_xdp) in bnxt_reserve_rings()
9251 bp->tx_nr_rings_per_tc = bp->tx_nr_rings_xdp; in bnxt_reserve_rings()
9253 bp->tx_nr_rings_per_tc = bp->tx_nr_rings; in bnxt_reserve_rings()
9254 return -ENOMEM; in bnxt_reserve_rings()
9265 free_irq_cpu_rmap(bp->dev->rx_cpu_rmap); in bnxt_free_irq()
9266 bp->dev->rx_cpu_rmap = NULL; in bnxt_free_irq()
9268 if (!bp->irq_tbl || !bp->bnapi) in bnxt_free_irq()
9271 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_free_irq()
9274 irq = &bp->irq_tbl[map_idx]; in bnxt_free_irq()
9275 if (irq->requested) { in bnxt_free_irq()
9276 if (irq->have_cpumask) { in bnxt_free_irq()
9277 irq_set_affinity_hint(irq->vector, NULL); in bnxt_free_irq()
9278 free_cpumask_var(irq->cpu_mask); in bnxt_free_irq()
9279 irq->have_cpumask = 0; in bnxt_free_irq()
9281 free_irq(irq->vector, bp->bnapi[i]); in bnxt_free_irq()
9284 irq->requested = 0; in bnxt_free_irq()
9298 netdev_err(bp->dev, "bnxt_setup_int_mode err: %x\n", in bnxt_request_irq()
9303 rmap = bp->dev->rx_cpu_rmap; in bnxt_request_irq()
9305 if (!(bp->flags & BNXT_FLAG_USING_MSIX)) in bnxt_request_irq()
9308 for (i = 0, j = 0; i < bp->cp_nr_rings; i++) { in bnxt_request_irq()
9310 struct bnxt_irq *irq = &bp->irq_tbl[map_idx]; in bnxt_request_irq()
9313 if (rmap && bp->bnapi[i]->rx_ring) { in bnxt_request_irq()
9314 rc = irq_cpu_rmap_add(rmap, irq->vector); in bnxt_request_irq()
9316 netdev_warn(bp->dev, "failed adding irq rmap for ring %d\n", in bnxt_request_irq()
9321 rc = request_irq(irq->vector, irq->handler, flags, irq->name, in bnxt_request_irq()
9322 bp->bnapi[i]); in bnxt_request_irq()
9326 irq->requested = 1; in bnxt_request_irq()
9328 if (zalloc_cpumask_var(&irq->cpu_mask, GFP_KERNEL)) { in bnxt_request_irq()
9329 int numa_node = dev_to_node(&bp->pdev->dev); in bnxt_request_irq()
9331 irq->have_cpumask = 1; in bnxt_request_irq()
9333 irq->cpu_mask); in bnxt_request_irq()
9334 rc = irq_set_affinity_hint(irq->vector, irq->cpu_mask); in bnxt_request_irq()
9336 netdev_warn(bp->dev, in bnxt_request_irq()
9338 irq->vector); in bnxt_request_irq()
9350 if (!bp->bnapi) in bnxt_del_napi()
9353 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_del_napi()
9354 struct bnxt_napi *bnapi = bp->bnapi[i]; in bnxt_del_napi()
9356 __netif_napi_del(&bnapi->napi); in bnxt_del_napi()
9367 unsigned int cp_nr_rings = bp->cp_nr_rings; in bnxt_init_napi()
9370 if (bp->flags & BNXT_FLAG_USING_MSIX) { in bnxt_init_napi()
9373 if (bp->flags & BNXT_FLAG_CHIP_P5) in bnxt_init_napi()
9376 cp_nr_rings--; in bnxt_init_napi()
9378 bnapi = bp->bnapi[i]; in bnxt_init_napi()
9379 netif_napi_add(bp->dev, &bnapi->napi, poll_fn); in bnxt_init_napi()
9382 bnapi = bp->bnapi[cp_nr_rings]; in bnxt_init_napi()
9383 netif_napi_add(bp->dev, &bnapi->napi, in bnxt_init_napi()
9387 bnapi = bp->bnapi[0]; in bnxt_init_napi()
9388 netif_napi_add(bp->dev, &bnapi->napi, bnxt_poll); in bnxt_init_napi()
9396 if (!bp->bnapi || in bnxt_disable_napi()
9397 test_and_set_bit(BNXT_STATE_NAPI_DISABLED, &bp->state)) in bnxt_disable_napi()
9400 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_disable_napi()
9401 struct bnxt_napi *bnapi = bp->bnapi[i]; in bnxt_disable_napi()
9404 cpr = &bnapi->cp_ring; in bnxt_disable_napi()
9405 if (bnapi->tx_fault) in bnxt_disable_napi()
9406 cpr->sw_stats.tx.tx_resets++; in bnxt_disable_napi()
9407 if (bnapi->in_reset) in bnxt_disable_napi()
9408 cpr->sw_stats.rx.rx_resets++; in bnxt_disable_napi()
9409 napi_disable(&bnapi->napi); in bnxt_disable_napi()
9410 if (bnapi->rx_ring) in bnxt_disable_napi()
9411 cancel_work_sync(&cpr->dim.work); in bnxt_disable_napi()
9419 clear_bit(BNXT_STATE_NAPI_DISABLED, &bp->state); in bnxt_enable_napi()
9420 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_enable_napi()
9421 struct bnxt_napi *bnapi = bp->bnapi[i]; in bnxt_enable_napi()
9424 bnapi->tx_fault = 0; in bnxt_enable_napi()
9426 cpr = &bnapi->cp_ring; in bnxt_enable_napi()
9427 bnapi->in_reset = false; in bnxt_enable_napi()
9429 bnapi->tx_pkts = 0; in bnxt_enable_napi()
9431 if (bnapi->rx_ring) { in bnxt_enable_napi()
9432 INIT_WORK(&cpr->dim.work, bnxt_dim_work); in bnxt_enable_napi()
9433 cpr->dim.mode = DIM_CQ_PERIOD_MODE_START_FROM_EQE; in bnxt_enable_napi()
9435 napi_enable(&bnapi->napi); in bnxt_enable_napi()
9444 if (bp->tx_ring) { in bnxt_tx_disable()
9445 for (i = 0; i < bp->tx_nr_rings; i++) { in bnxt_tx_disable()
9446 txr = &bp->tx_ring[i]; in bnxt_tx_disable()
9447 WRITE_ONCE(txr->dev_state, BNXT_DEV_STATE_CLOSING); in bnxt_tx_disable()
9453 netif_carrier_off(bp->dev); in bnxt_tx_disable()
9455 netif_tx_disable(bp->dev); in bnxt_tx_disable()
9463 for (i = 0; i < bp->tx_nr_rings; i++) { in bnxt_tx_enable()
9464 txr = &bp->tx_ring[i]; in bnxt_tx_enable()
9465 WRITE_ONCE(txr->dev_state, 0); in bnxt_tx_enable()
9469 netif_tx_wake_all_queues(bp->dev); in bnxt_tx_enable()
9471 netif_carrier_on(bp->dev); in bnxt_tx_enable()
9476 u8 active_fec = link_info->active_fec_sig_mode & in bnxt_report_fec()
9507 netif_carrier_on(bp->dev); in bnxt_report_link()
9508 speed = bnxt_fw_to_ethtool_speed(bp->link_info.link_speed); in bnxt_report_link()
9510 netdev_info(bp->dev, "NIC Link is Up, speed unknown\n"); in bnxt_report_link()
9513 if (bp->link_info.duplex == BNXT_LINK_DUPLEX_FULL) in bnxt_report_link()
9517 if (bp->link_info.pause == BNXT_LINK_PAUSE_BOTH) in bnxt_report_link()
9518 flow_ctrl = "ON - receive & transmit"; in bnxt_report_link()
9519 else if (bp->link_info.pause == BNXT_LINK_PAUSE_TX) in bnxt_report_link()
9520 flow_ctrl = "ON - transmit"; in bnxt_report_link()
9521 else if (bp->link_info.pause == BNXT_LINK_PAUSE_RX) in bnxt_report_link()
9522 flow_ctrl = "ON - receive"; in bnxt_report_link()
9525 if (bp->link_info.phy_qcfg_resp.option_flags & in bnxt_report_link()
9527 u8 sig_mode = bp->link_info.active_fec_sig_mode & in bnxt_report_link()
9540 netdev_info(bp->dev, "NIC Link is Up, %u Mbps %s%s duplex, Flow control: %s\n", in bnxt_report_link()
9542 if (bp->phy_flags & BNXT_PHY_FL_EEE_CAP) in bnxt_report_link()
9543 netdev_info(bp->dev, "EEE is %s\n", in bnxt_report_link()
9544 bp->eee.eee_active ? "active" : in bnxt_report_link()
9546 fec = bp->link_info.fec_cfg; in bnxt_report_link()
9548 netdev_info(bp->dev, "FEC autoneg %s encoding: %s\n", in bnxt_report_link()
9550 bnxt_report_fec(&bp->link_info)); in bnxt_report_link()
9552 netif_carrier_off(bp->dev); in bnxt_report_link()
9553 netdev_err(bp->dev, "NIC Link is Down\n"); in bnxt_report_link()
9559 if (!resp->supported_speeds_auto_mode && in bnxt_phy_qcaps_no_speed()
9560 !resp->supported_speeds_force_mode && in bnxt_phy_qcaps_no_speed()
9561 !resp->supported_pam4_speeds_auto_mode && in bnxt_phy_qcaps_no_speed()
9562 !resp->supported_pam4_speeds_force_mode) in bnxt_phy_qcaps_no_speed()
9569 struct bnxt_link_info *link_info = &bp->link_info; in bnxt_hwrm_phy_qcaps()
9574 if (bp->hwrm_spec_code < 0x10201) in bnxt_hwrm_phy_qcaps()
9586 bp->phy_flags = resp->flags | (le16_to_cpu(resp->flags2) << 8); in bnxt_hwrm_phy_qcaps()
9587 if (resp->flags & PORT_PHY_QCAPS_RESP_FLAGS_EEE_SUPPORTED) { in bnxt_hwrm_phy_qcaps()
9588 struct ethtool_eee *eee = &bp->eee; in bnxt_hwrm_phy_qcaps()
9589 u16 fw_speeds = le16_to_cpu(resp->supported_speeds_eee_mode); in bnxt_hwrm_phy_qcaps()
9591 eee->supported = _bnxt_fw_to_ethtool_adv_spds(fw_speeds, 0); in bnxt_hwrm_phy_qcaps()
9592 bp->lpi_tmr_lo = le32_to_cpu(resp->tx_lpi_timer_low) & in bnxt_hwrm_phy_qcaps()
9594 bp->lpi_tmr_hi = le32_to_cpu(resp->valid_tx_lpi_timer_high) & in bnxt_hwrm_phy_qcaps()
9598 if (bp->hwrm_spec_code >= 0x10a01) { in bnxt_hwrm_phy_qcaps()
9600 link_info->phy_state = BNXT_PHY_STATE_DISABLED; in bnxt_hwrm_phy_qcaps()
9601 netdev_warn(bp->dev, "Ethernet link disabled\n"); in bnxt_hwrm_phy_qcaps()
9602 } else if (link_info->phy_state == BNXT_PHY_STATE_DISABLED) { in bnxt_hwrm_phy_qcaps()
9603 link_info->phy_state = BNXT_PHY_STATE_ENABLED; in bnxt_hwrm_phy_qcaps()
9604 netdev_info(bp->dev, "Ethernet link enabled\n"); in bnxt_hwrm_phy_qcaps()
9605 /* Phy re-enabled, reprobe the speeds */ in bnxt_hwrm_phy_qcaps()
9606 link_info->support_auto_speeds = 0; in bnxt_hwrm_phy_qcaps()
9607 link_info->support_pam4_auto_speeds = 0; in bnxt_hwrm_phy_qcaps()
9610 if (resp->supported_speeds_auto_mode) in bnxt_hwrm_phy_qcaps()
9611 link_info->support_auto_speeds = in bnxt_hwrm_phy_qcaps()
9612 le16_to_cpu(resp->supported_speeds_auto_mode); in bnxt_hwrm_phy_qcaps()
9613 if (resp->supported_pam4_speeds_auto_mode) in bnxt_hwrm_phy_qcaps()
9614 link_info->support_pam4_auto_speeds = in bnxt_hwrm_phy_qcaps()
9615 le16_to_cpu(resp->supported_pam4_speeds_auto_mode); in bnxt_hwrm_phy_qcaps()
9617 bp->port_count = resp->port_cnt; in bnxt_hwrm_phy_qcaps()
9633 struct bnxt_link_info *link_info = &bp->link_info; in bnxt_update_link()
9636 u8 link_state = link_info->link_state; in bnxt_update_link()
9648 if (BNXT_VF(bp) && rc == -ENODEV) { in bnxt_update_link()
9649 netdev_warn(bp->dev, "Cannot obtain link state while PF unavailable.\n"); in bnxt_update_link()
9655 memcpy(&link_info->phy_qcfg_resp, resp, sizeof(*resp)); in bnxt_update_link()
9656 link_info->phy_link_status = resp->link; in bnxt_update_link()
9657 link_info->duplex = resp->duplex_cfg; in bnxt_update_link()
9658 if (bp->hwrm_spec_code >= 0x10800) in bnxt_update_link()
9659 link_info->duplex = resp->duplex_state; in bnxt_update_link()
9660 link_info->pause = resp->pause; in bnxt_update_link()
9661 link_info->auto_mode = resp->auto_mode; in bnxt_update_link()
9662 link_info->auto_pause_setting = resp->auto_pause; in bnxt_update_link()
9663 link_info->lp_pause = resp->link_partner_adv_pause; in bnxt_update_link()
9664 link_info->force_pause_setting = resp->force_pause; in bnxt_update_link()
9665 link_info->duplex_setting = resp->duplex_cfg; in bnxt_update_link()
9666 if (link_info->phy_link_status == BNXT_LINK_LINK) in bnxt_update_link()
9667 link_info->link_speed = le16_to_cpu(resp->link_speed); in bnxt_update_link()
9669 link_info->link_speed = 0; in bnxt_update_link()
9670 link_info->force_link_speed = le16_to_cpu(resp->force_link_speed); in bnxt_update_link()
9671 link_info->force_pam4_link_speed = in bnxt_update_link()
9672 le16_to_cpu(resp->force_pam4_link_speed); in bnxt_update_link()
9673 link_info->support_speeds = le16_to_cpu(resp->support_speeds); in bnxt_update_link()
9674 link_info->support_pam4_speeds = le16_to_cpu(resp->support_pam4_speeds); in bnxt_update_link()
9675 link_info->auto_link_speeds = le16_to_cpu(resp->auto_link_speed_mask); in bnxt_update_link()
9676 link_info->auto_pam4_link_speeds = in bnxt_update_link()
9677 le16_to_cpu(resp->auto_pam4_link_speed_mask); in bnxt_update_link()
9678 link_info->lp_auto_link_speeds = in bnxt_update_link()
9679 le16_to_cpu(resp->link_partner_adv_speeds); in bnxt_update_link()
9680 link_info->lp_auto_pam4_link_speeds = in bnxt_update_link()
9681 resp->link_partner_pam4_adv_speeds; in bnxt_update_link()
9682 link_info->preemphasis = le32_to_cpu(resp->preemphasis); in bnxt_update_link()
9683 link_info->phy_ver[0] = resp->phy_maj; in bnxt_update_link()
9684 link_info->phy_ver[1] = resp->phy_min; in bnxt_update_link()
9685 link_info->phy_ver[2] = resp->phy_bld; in bnxt_update_link()
9686 link_info->media_type = resp->media_type; in bnxt_update_link()
9687 link_info->phy_type = resp->phy_type; in bnxt_update_link()
9688 link_info->transceiver = resp->xcvr_pkg_type; in bnxt_update_link()
9689 link_info->phy_addr = resp->eee_config_phy_addr & in bnxt_update_link()
9691 link_info->module_status = resp->module_status; in bnxt_update_link()
9693 if (bp->phy_flags & BNXT_PHY_FL_EEE_CAP) { in bnxt_update_link()
9694 struct ethtool_eee *eee = &bp->eee; in bnxt_update_link()
9697 eee->eee_active = 0; in bnxt_update_link()
9698 if (resp->eee_config_phy_addr & in bnxt_update_link()
9700 eee->eee_active = 1; in bnxt_update_link()
9702 resp->link_partner_adv_eee_link_speed_mask); in bnxt_update_link()
9703 eee->lp_advertised = in bnxt_update_link()
9707 /* Pull initial EEE config */ in bnxt_update_link()
9709 if (resp->eee_config_phy_addr & in bnxt_update_link()
9711 eee->eee_enabled = 1; in bnxt_update_link()
9713 fw_speeds = le16_to_cpu(resp->adv_eee_link_speed_mask); in bnxt_update_link()
9714 eee->advertised = in bnxt_update_link()
9717 if (resp->eee_config_phy_addr & in bnxt_update_link()
9721 eee->tx_lpi_enabled = 1; in bnxt_update_link()
9722 tmr = resp->xcvr_identifier_type_tx_lpi_timer; in bnxt_update_link()
9723 eee->tx_lpi_timer = le32_to_cpu(tmr) & in bnxt_update_link()
9729 link_info->fec_cfg = PORT_PHY_QCFG_RESP_FEC_CFG_FEC_NONE_SUPPORTED; in bnxt_update_link()
9730 if (bp->hwrm_spec_code >= 0x10504) { in bnxt_update_link()
9731 link_info->fec_cfg = le16_to_cpu(resp->fec_cfg); in bnxt_update_link()
9732 link_info->active_fec_sig_mode = resp->active_fec_signal_mode; in bnxt_update_link()
9736 if (link_info->phy_link_status == BNXT_LINK_LINK) in bnxt_update_link()
9737 link_info->link_state = BNXT_LINK_STATE_UP; in bnxt_update_link()
9739 link_info->link_state = BNXT_LINK_STATE_DOWN; in bnxt_update_link()
9740 if (link_state != link_info->link_state) in bnxt_update_link()
9743 /* always link down if not require to update link state */ in bnxt_update_link()
9744 link_info->link_state = BNXT_LINK_STATE_DOWN; in bnxt_update_link()
9754 if (bnxt_support_dropped(link_info->advertising, in bnxt_update_link()
9755 link_info->support_auto_speeds)) { in bnxt_update_link()
9756 link_info->advertising = link_info->support_auto_speeds; in bnxt_update_link()
9759 if (bnxt_support_dropped(link_info->advertising_pam4, in bnxt_update_link()
9760 link_info->support_pam4_auto_speeds)) { in bnxt_update_link()
9761 link_info->advertising_pam4 = link_info->support_pam4_auto_speeds; in bnxt_update_link()
9764 if (support_changed && (link_info->autoneg & BNXT_AUTONEG_SPEED)) in bnxt_update_link()
9771 struct bnxt_link_info *link_info = &bp->link_info; in bnxt_get_port_module_status()
9772 struct hwrm_port_phy_qcfg_output *resp = &link_info->phy_qcfg_resp; in bnxt_get_port_module_status()
9778 module_status = link_info->module_status; in bnxt_get_port_module_status()
9783 netdev_warn(bp->dev, "Unqualified SFP+ module detected on port %d\n", in bnxt_get_port_module_status()
9784 bp->pf.port_id); in bnxt_get_port_module_status()
9785 if (bp->hwrm_spec_code >= 0x10201) { in bnxt_get_port_module_status()
9786 netdev_warn(bp->dev, "Module part number %s\n", in bnxt_get_port_module_status()
9787 resp->phy_vendor_partnumber); in bnxt_get_port_module_status()
9790 netdev_warn(bp->dev, "TX is disabled\n"); in bnxt_get_port_module_status()
9792 netdev_warn(bp->dev, "SFP+ module is shutdown\n"); in bnxt_get_port_module_status()
9799 if (bp->link_info.autoneg & BNXT_AUTONEG_FLOW_CTRL) { in bnxt_hwrm_set_pause_common()
9800 if (bp->hwrm_spec_code >= 0x10201) in bnxt_hwrm_set_pause_common()
9801 req->auto_pause = in bnxt_hwrm_set_pause_common()
9803 if (bp->link_info.req_flow_ctrl & BNXT_LINK_PAUSE_RX) in bnxt_hwrm_set_pause_common()
9804 req->auto_pause |= PORT_PHY_CFG_REQ_AUTO_PAUSE_RX; in bnxt_hwrm_set_pause_common()
9805 if (bp->link_info.req_flow_ctrl & BNXT_LINK_PAUSE_TX) in bnxt_hwrm_set_pause_common()
9806 req->auto_pause |= PORT_PHY_CFG_REQ_AUTO_PAUSE_TX; in bnxt_hwrm_set_pause_common()
9807 req->enables |= in bnxt_hwrm_set_pause_common()
9810 if (bp->link_info.req_flow_ctrl & BNXT_LINK_PAUSE_RX) in bnxt_hwrm_set_pause_common()
9811 req->force_pause |= PORT_PHY_CFG_REQ_FORCE_PAUSE_RX; in bnxt_hwrm_set_pause_common()
9812 if (bp->link_info.req_flow_ctrl & BNXT_LINK_PAUSE_TX) in bnxt_hwrm_set_pause_common()
9813 req->force_pause |= PORT_PHY_CFG_REQ_FORCE_PAUSE_TX; in bnxt_hwrm_set_pause_common()
9814 req->enables |= in bnxt_hwrm_set_pause_common()
9816 if (bp->hwrm_spec_code >= 0x10201) { in bnxt_hwrm_set_pause_common()
9817 req->auto_pause = req->force_pause; in bnxt_hwrm_set_pause_common()
9818 req->enables |= cpu_to_le32( in bnxt_hwrm_set_pause_common()
9826 if (bp->link_info.autoneg & BNXT_AUTONEG_SPEED) { in bnxt_hwrm_set_link_common()
9827 req->auto_mode |= PORT_PHY_CFG_REQ_AUTO_MODE_SPEED_MASK; in bnxt_hwrm_set_link_common()
9828 if (bp->link_info.advertising) { in bnxt_hwrm_set_link_common()
9829 req->enables |= cpu_to_le32(PORT_PHY_CFG_REQ_ENABLES_AUTO_LINK_SPEED_MASK); in bnxt_hwrm_set_link_common()
9830 req->auto_link_speed_mask = cpu_to_le16(bp->link_info.advertising); in bnxt_hwrm_set_link_common()
9832 if (bp->link_info.advertising_pam4) { in bnxt_hwrm_set_link_common()
9833 req->enables |= in bnxt_hwrm_set_link_common()
9835 req->auto_link_pam4_speed_mask = in bnxt_hwrm_set_link_common()
9836 cpu_to_le16(bp->link_info.advertising_pam4); in bnxt_hwrm_set_link_common()
9838 req->enables |= cpu_to_le32(PORT_PHY_CFG_REQ_ENABLES_AUTO_MODE); in bnxt_hwrm_set_link_common()
9839 req->flags |= cpu_to_le32(PORT_PHY_CFG_REQ_FLAGS_RESTART_AUTONEG); in bnxt_hwrm_set_link_common()
9841 req->flags |= cpu_to_le32(PORT_PHY_CFG_REQ_FLAGS_FORCE); in bnxt_hwrm_set_link_common()
9842 if (bp->link_info.req_signal_mode == BNXT_SIG_MODE_PAM4) { in bnxt_hwrm_set_link_common()
9843 req->force_pam4_link_speed = cpu_to_le16(bp->link_info.req_link_speed); in bnxt_hwrm_set_link_common()
9844 req->enables |= cpu_to_le32(PORT_PHY_CFG_REQ_ENABLES_FORCE_PAM4_LINK_SPEED); in bnxt_hwrm_set_link_common()
9846 req->force_link_speed = cpu_to_le16(bp->link_info.req_link_speed); in bnxt_hwrm_set_link_common()
9851 req->flags |= cpu_to_le32(PORT_PHY_CFG_REQ_FLAGS_RESET_PHY); in bnxt_hwrm_set_link_common()
9865 if ((bp->link_info.autoneg & BNXT_AUTONEG_FLOW_CTRL) || in bnxt_hwrm_set_pause()
9866 bp->link_info.force_link_chng) in bnxt_hwrm_set_pause()
9870 if (!rc && !(bp->link_info.autoneg & BNXT_AUTONEG_FLOW_CTRL)) { in bnxt_hwrm_set_pause()
9875 bp->link_info.pause = in bnxt_hwrm_set_pause()
9876 bp->link_info.force_pause_setting = bp->link_info.req_flow_ctrl; in bnxt_hwrm_set_pause()
9877 bp->link_info.auto_pause_setting = 0; in bnxt_hwrm_set_pause()
9878 if (!bp->link_info.force_link_chng) in bnxt_hwrm_set_pause()
9881 bp->link_info.force_link_chng = false; in bnxt_hwrm_set_pause()
9888 struct ethtool_eee *eee = &bp->eee; in bnxt_hwrm_set_eee()
9890 if (eee->eee_enabled) { in bnxt_hwrm_set_eee()
9894 if (eee->tx_lpi_enabled) in bnxt_hwrm_set_eee()
9899 req->flags |= cpu_to_le32(flags); in bnxt_hwrm_set_eee()
9900 eee_speeds = bnxt_get_fw_auto_link_speeds(eee->advertised); in bnxt_hwrm_set_eee()
9901 req->eee_link_speed_mask = cpu_to_le16(eee_speeds); in bnxt_hwrm_set_eee()
9902 req->tx_lpi_timer = cpu_to_le32(eee->tx_lpi_timer); in bnxt_hwrm_set_eee()
9904 req->flags |= cpu_to_le32(PORT_PHY_CFG_REQ_FLAGS_EEE_DISABLE); in bnxt_hwrm_set_eee()
9935 if (pci_num_vf(bp->pdev) && in bnxt_hwrm_shutdown_link()
9936 !(bp->phy_flags & BNXT_PHY_FL_FW_MANAGED_LKDN)) in bnxt_hwrm_shutdown_link()
9943 req->flags = cpu_to_le32(PORT_PHY_CFG_REQ_FLAGS_FORCE_LINK_DWN); in bnxt_hwrm_shutdown_link()
9946 mutex_lock(&bp->link_lock); in bnxt_hwrm_shutdown_link()
9947 /* Device is not obliged link down in certain scenarios, even in bnxt_hwrm_shutdown_link()
9952 bp->link_info.link_state = BNXT_LINK_STATE_UNKNOWN; in bnxt_hwrm_shutdown_link()
9953 mutex_unlock(&bp->link_lock); in bnxt_hwrm_shutdown_link()
9964 netdev_err(bp->dev, "Failed FW reset via OP-TEE, rc=%d\n", rc); in bnxt_fw_reset_via_optee()
9968 netdev_err(bp->dev, "OP-TEE not supported\n"); in bnxt_fw_reset_via_optee()
9969 return -ENODEV; in bnxt_fw_reset_via_optee()
9975 if (bp->fw_health && bp->fw_health->status_reliable) { in bnxt_try_recover_fw()
9986 } while (rc == -EBUSY && retry < BNXT_FW_RETRY); in bnxt_try_recover_fw()
9989 netdev_err(bp->dev, in bnxt_try_recover_fw()
9992 rc = -ENODEV; in bnxt_try_recover_fw()
9995 netdev_warn(bp->dev, "Firmware recover via OP-TEE requested\n"); in bnxt_try_recover_fw()
10001 return -ENODEV; in bnxt_try_recover_fw()
10006 struct bnxt_hw_resc *hw_resc = &bp->hw_resc; in bnxt_clear_reservations()
10011 hw_resc->resv_cp_rings = 0; in bnxt_clear_reservations()
10012 hw_resc->resv_stat_ctxs = 0; in bnxt_clear_reservations()
10013 hw_resc->resv_irqs = 0; in bnxt_clear_reservations()
10014 hw_resc->resv_tx_rings = 0; in bnxt_clear_reservations()
10015 hw_resc->resv_rx_rings = 0; in bnxt_clear_reservations()
10016 hw_resc->resv_hw_ring_grps = 0; in bnxt_clear_reservations()
10017 hw_resc->resv_vnics = 0; in bnxt_clear_reservations()
10019 bp->tx_nr_rings = 0; in bnxt_clear_reservations()
10020 bp->rx_nr_rings = 0; in bnxt_clear_reservations()
10033 netdev_err(bp->dev, "resc_qcaps failed\n"); in bnxt_cancel_reservations()
10044 bool fw_reset = !bp->irq_tbl; in bnxt_hwrm_if_change()
10049 if (!(bp->fw_cap & BNXT_FW_CAP_IF_CHANGE)) in bnxt_hwrm_if_change()
10057 req->flags = cpu_to_le32(FUNC_DRV_IF_CHANGE_REQ_FLAGS_UP); in bnxt_hwrm_if_change()
10063 if (rc != -EAGAIN) in bnxt_hwrm_if_change()
10070 if (rc == -EAGAIN) { in bnxt_hwrm_if_change()
10074 flags = le32_to_cpu(resp->flags); in bnxt_hwrm_if_change()
10091 test_bit(BNXT_STATE_FW_RESET_DET, &bp->state)) in bnxt_hwrm_if_change()
10096 if (test_bit(BNXT_STATE_IN_FW_RESET, &bp->state) && !fw_reset) { in bnxt_hwrm_if_change()
10097 netdev_err(bp->dev, "RESET_DONE not set during FW reset.\n"); in bnxt_hwrm_if_change()
10098 set_bit(BNXT_STATE_ABORT_ERR, &bp->state); in bnxt_hwrm_if_change()
10099 return -ENODEV; in bnxt_hwrm_if_change()
10103 set_bit(BNXT_STATE_FW_RESET_DET, &bp->state); in bnxt_hwrm_if_change()
10104 if (!test_bit(BNXT_STATE_IN_FW_RESET, &bp->state)) in bnxt_hwrm_if_change()
10107 kfree(bp->ctx); in bnxt_hwrm_if_change()
10108 bp->ctx = NULL; in bnxt_hwrm_if_change()
10112 clear_bit(BNXT_STATE_FW_RESET_DET, &bp->state); in bnxt_hwrm_if_change()
10113 set_bit(BNXT_STATE_ABORT_ERR, &bp->state); in bnxt_hwrm_if_change()
10119 clear_bit(BNXT_STATE_FW_RESET_DET, &bp->state); in bnxt_hwrm_if_change()
10120 netdev_err(bp->dev, "init int mode failed\n"); in bnxt_hwrm_if_change()
10133 struct bnxt_pf_info *pf = &bp->pf; in bnxt_hwrm_port_led_qcaps()
10136 bp->num_leds = 0; in bnxt_hwrm_port_led_qcaps()
10137 if (BNXT_VF(bp) || bp->hwrm_spec_code < 0x10601) in bnxt_hwrm_port_led_qcaps()
10144 req->port_id = cpu_to_le16(pf->port_id); in bnxt_hwrm_port_led_qcaps()
10151 if (resp->num_leds > 0 && resp->num_leds < BNXT_MAX_LED) { in bnxt_hwrm_port_led_qcaps()
10154 bp->num_leds = resp->num_leds; in bnxt_hwrm_port_led_qcaps()
10155 memcpy(bp->leds, &resp->led0_id, sizeof(bp->leds[0]) * in bnxt_hwrm_port_led_qcaps()
10156 bp->num_leds); in bnxt_hwrm_port_led_qcaps()
10157 for (i = 0; i < bp->num_leds; i++) { in bnxt_hwrm_port_led_qcaps()
10158 struct bnxt_led_info *led = &bp->leds[i]; in bnxt_hwrm_port_led_qcaps()
10159 __le16 caps = led->led_state_caps; in bnxt_hwrm_port_led_qcaps()
10161 if (!led->led_group_id || in bnxt_hwrm_port_led_qcaps()
10163 bp->num_leds = 0; in bnxt_hwrm_port_led_qcaps()
10182 req->port_id = cpu_to_le16(bp->pf.port_id); in bnxt_hwrm_alloc_wol_fltr()
10183 req->wol_type = WOL_FILTER_ALLOC_REQ_WOL_TYPE_MAGICPKT; in bnxt_hwrm_alloc_wol_fltr()
10184 req->enables = cpu_to_le32(WOL_FILTER_ALLOC_REQ_ENABLES_MAC_ADDRESS); in bnxt_hwrm_alloc_wol_fltr()
10185 memcpy(req->mac_address, bp->dev->dev_addr, ETH_ALEN); in bnxt_hwrm_alloc_wol_fltr()
10190 bp->wol_filter_id = resp->wol_filter_id; in bnxt_hwrm_alloc_wol_fltr()
10204 req->port_id = cpu_to_le16(bp->pf.port_id); in bnxt_hwrm_free_wol_fltr()
10205 req->enables = cpu_to_le32(WOL_FILTER_FREE_REQ_ENABLES_WOL_FILTER_ID); in bnxt_hwrm_free_wol_fltr()
10206 req->wol_filter_id = bp->wol_filter_id; in bnxt_hwrm_free_wol_fltr()
10222 req->port_id = cpu_to_le16(bp->pf.port_id); in bnxt_hwrm_get_wol_fltrs()
10223 req->handle = cpu_to_le16(handle); in bnxt_hwrm_get_wol_fltrs()
10227 next_handle = le16_to_cpu(resp->next_handle); in bnxt_hwrm_get_wol_fltrs()
10229 if (resp->wol_type == in bnxt_hwrm_get_wol_fltrs()
10231 bp->wol = 1; in bnxt_hwrm_get_wol_fltrs()
10232 bp->wol_filter_id = resp->wol_filter_id; in bnxt_hwrm_get_wol_fltrs()
10244 bp->wol = 0; in bnxt_get_wol_settings()
10245 if (!BNXT_PF(bp) || !(bp->flags & BNXT_FLAG_WOL_CAP)) in bnxt_get_wol_settings()
10269 len = sprintf(buf, "%u\n", resp->temp * 1000); /* display millidegree */ in bnxt_show_temp()
10285 if (bp->hwmon_dev) { in bnxt_hwmon_close()
10286 hwmon_device_unregister(bp->hwmon_dev); in bnxt_hwmon_close()
10287 bp->hwmon_dev = NULL; in bnxt_hwmon_close()
10294 struct pci_dev *pdev = bp->pdev; in bnxt_hwmon_open()
10300 if (rc == -EACCES || rc == -EOPNOTSUPP) { in bnxt_hwmon_open()
10305 if (bp->hwmon_dev) in bnxt_hwmon_open()
10308 bp->hwmon_dev = hwmon_device_register_with_groups(&pdev->dev, in bnxt_hwmon_open()
10311 if (IS_ERR(bp->hwmon_dev)) { in bnxt_hwmon_open()
10312 bp->hwmon_dev = NULL; in bnxt_hwmon_open()
10313 dev_warn(&pdev->dev, "Cannot register hwmon device\n"); in bnxt_hwmon_open()
10328 struct ethtool_eee *eee = &bp->eee; in bnxt_eee_config_ok()
10329 struct bnxt_link_info *link_info = &bp->link_info; in bnxt_eee_config_ok()
10331 if (!(bp->phy_flags & BNXT_PHY_FL_EEE_CAP)) in bnxt_eee_config_ok()
10334 if (eee->eee_enabled) { in bnxt_eee_config_ok()
10336 _bnxt_fw_to_ethtool_adv_spds(link_info->advertising, 0); in bnxt_eee_config_ok()
10338 if (!(link_info->autoneg & BNXT_AUTONEG_SPEED)) { in bnxt_eee_config_ok()
10339 eee->eee_enabled = 0; in bnxt_eee_config_ok()
10342 if (eee->advertised & ~advertising) { in bnxt_eee_config_ok()
10343 eee->advertised = advertising & eee->supported; in bnxt_eee_config_ok()
10356 struct bnxt_link_info *link_info = &bp->link_info; in bnxt_update_phy_setting()
10360 netdev_err(bp->dev, "failed to update link (rc: %x)\n", in bnxt_update_phy_setting()
10367 if ((link_info->autoneg & BNXT_AUTONEG_FLOW_CTRL) && in bnxt_update_phy_setting()
10368 (link_info->auto_pause_setting & BNXT_LINK_PAUSE_BOTH) != in bnxt_update_phy_setting()
10369 link_info->req_flow_ctrl) in bnxt_update_phy_setting()
10371 if (!(link_info->autoneg & BNXT_AUTONEG_FLOW_CTRL) && in bnxt_update_phy_setting()
10372 link_info->force_pause_setting != link_info->req_flow_ctrl) in bnxt_update_phy_setting()
10374 if (!(link_info->autoneg & BNXT_AUTONEG_SPEED)) { in bnxt_update_phy_setting()
10375 if (BNXT_AUTO_MODE(link_info->auto_mode)) in bnxt_update_phy_setting()
10377 if (link_info->req_signal_mode == BNXT_SIG_MODE_NRZ && in bnxt_update_phy_setting()
10378 link_info->req_link_speed != link_info->force_link_speed) in bnxt_update_phy_setting()
10380 else if (link_info->req_signal_mode == BNXT_SIG_MODE_PAM4 && in bnxt_update_phy_setting()
10381 link_info->req_link_speed != link_info->force_pam4_link_speed) in bnxt_update_phy_setting()
10383 if (link_info->req_duplex != link_info->duplex_setting) in bnxt_update_phy_setting()
10386 if (link_info->auto_mode == BNXT_LINK_AUTO_NONE) in bnxt_update_phy_setting()
10388 if (link_info->advertising != link_info->auto_link_speeds || in bnxt_update_phy_setting()
10389 link_info->advertising_pam4 != link_info->auto_pam4_link_speeds) in bnxt_update_phy_setting()
10407 netdev_err(bp->dev, "failed to update phy setting (rc: %x)\n", in bnxt_update_phy_setting()
10415 /* Common routine to pre-map certain register block to different GRC window.
10425 bp->bar0 + BNXT_GRCPF_REG_WINDOW_BASE_OUT + 12); in bnxt_preset_reg_win()
10435 if (test_bit(BNXT_STATE_IN_FW_RESET, &bp->state)) in bnxt_reinit_after_abort()
10436 return -EBUSY; in bnxt_reinit_after_abort()
10438 if (bp->dev->reg_state == NETREG_UNREGISTERED) in bnxt_reinit_after_abort()
10439 return -ENODEV; in bnxt_reinit_after_abort()
10446 clear_bit(BNXT_STATE_ABORT_ERR, &bp->state); in bnxt_reinit_after_abort()
10447 set_bit(BNXT_STATE_FW_RESET_DET, &bp->state); in bnxt_reinit_after_abort()
10458 netif_carrier_off(bp->dev); in __bnxt_open_nic()
10463 netdev_err(bp->dev, "Failed to reserve default rings at open\n"); in __bnxt_open_nic()
10470 if ((bp->flags & BNXT_FLAG_RFS) && in __bnxt_open_nic()
10471 !(bp->flags & BNXT_FLAG_USING_MSIX)) { in __bnxt_open_nic()
10473 bp->dev->hw_features &= ~NETIF_F_NTUPLE; in __bnxt_open_nic()
10474 bp->flags &= ~BNXT_FLAG_RFS; in __bnxt_open_nic()
10479 netdev_err(bp->dev, "bnxt_alloc_mem err: %x\n", rc); in __bnxt_open_nic()
10487 netdev_err(bp->dev, "bnxt_request_irq err: %x\n", rc); in __bnxt_open_nic()
10494 netdev_err(bp->dev, "bnxt_init_nic err: %x\n", rc); in __bnxt_open_nic()
10502 mutex_lock(&bp->link_lock); in __bnxt_open_nic()
10504 mutex_unlock(&bp->link_lock); in __bnxt_open_nic()
10506 netdev_warn(bp->dev, "failed to update phy settings\n"); in __bnxt_open_nic()
10508 bp->link_info.phy_retry = true; in __bnxt_open_nic()
10509 bp->link_info.phy_retry_expires = in __bnxt_open_nic()
10516 udp_tunnel_nic_reset_ntf(bp->dev); in __bnxt_open_nic()
10518 if (bp->tx_nr_rings_xdp < num_possible_cpus()) { in __bnxt_open_nic()
10524 set_bit(BNXT_STATE_OPEN, &bp->state); in __bnxt_open_nic()
10528 mod_timer(&bp->timer, jiffies + bp->current_interval); in __bnxt_open_nic()
10530 mutex_lock(&bp->link_lock); in __bnxt_open_nic()
10532 mutex_unlock(&bp->link_lock); in __bnxt_open_nic()
10534 /* VF-reps may need to be re-opened after the PF is re-opened */ in __bnxt_open_nic()
10556 if (test_bit(BNXT_STATE_ABORT_ERR, &bp->state)) in bnxt_open_nic()
10557 rc = -EIO; in bnxt_open_nic()
10561 netdev_err(bp->dev, "nic open fail (rc: %x)\n", rc); in bnxt_open_nic()
10562 dev_close(bp->dev); in bnxt_open_nic()
10575 if (test_bit(BNXT_STATE_ABORT_ERR, &bp->state)) { in bnxt_half_open_nic()
10576 netdev_err(bp->dev, "A previous firmware reset has not completed, aborting half open\n"); in bnxt_half_open_nic()
10577 rc = -ENODEV; in bnxt_half_open_nic()
10583 netdev_err(bp->dev, "bnxt_alloc_mem err: %x\n", rc); in bnxt_half_open_nic()
10586 set_bit(BNXT_STATE_HALF_OPEN, &bp->state); in bnxt_half_open_nic()
10589 clear_bit(BNXT_STATE_HALF_OPEN, &bp->state); in bnxt_half_open_nic()
10590 netdev_err(bp->dev, "bnxt_init_nic err: %x\n", rc); in bnxt_half_open_nic()
10598 dev_close(bp->dev); in bnxt_half_open_nic()
10610 clear_bit(BNXT_STATE_HALF_OPEN, &bp->state); in bnxt_half_close_nic()
10616 struct bnxt_pf_info *pf = &bp->pf; in bnxt_reenable_sriov()
10617 int n = pf->active_vfs; in bnxt_reenable_sriov()
10629 if (test_bit(BNXT_STATE_ABORT_ERR, &bp->state)) { in bnxt_open()
10632 if (rc == -EBUSY) in bnxt_open()
10633 netdev_err(bp->dev, "A previous firmware reset has not completed, aborting\n"); in bnxt_open()
10635 netdev_err(bp->dev, "Failed to reinitialize after aborted firmware reset\n"); in bnxt_open()
10636 return -ENODEV; in bnxt_open()
10648 if (test_and_clear_bit(BNXT_STATE_FW_RESET_DET, &bp->state)) { in bnxt_open()
10649 if (!test_bit(BNXT_STATE_IN_FW_RESET, &bp->state)) { in bnxt_open()
10662 return (test_bit(BNXT_STATE_IN_SP_TASK, &bp->state) || in bnxt_drv_busy()
10663 test_bit(BNXT_STATE_READ_STATS, &bp->state)); in bnxt_drv_busy()
10672 /* Close the VF-reps before closing PF */ in __bnxt_close_nic()
10679 clear_bit(BNXT_STATE_OPEN, &bp->state); in __bnxt_close_nic()
10691 del_timer_sync(&bp->timer); in __bnxt_close_nic()
10695 if (bp->bnapi && irq_re_init) { in __bnxt_close_nic()
10696 bnxt_get_ring_stats(bp, &bp->net_stats_prev); in __bnxt_close_nic()
10697 bnxt_get_ring_err_stats(bp, &bp->ring_err_stats_prev); in __bnxt_close_nic()
10710 if (test_bit(BNXT_STATE_IN_FW_RESET, &bp->state)) { in bnxt_close_nic()
10718 netdev_warn(bp->dev, "FW reset in progress during close, FW reset will be aborted\n"); in bnxt_close_nic()
10719 set_bit(BNXT_STATE_ABORT_ERR, &bp->state); in bnxt_close_nic()
10723 if (bp->sriov_cfg) { in bnxt_close_nic()
10724 rc = wait_event_interruptible_timeout(bp->sriov_cfg_wait, in bnxt_close_nic()
10725 !bp->sriov_cfg, in bnxt_close_nic()
10728 netdev_warn(bp->dev, "timeout waiting for SRIOV config operation to complete!\n"); in bnxt_close_nic()
10753 if (bp->hwrm_spec_code < 0x10a00) in bnxt_hwrm_port_phy_read()
10754 return -EOPNOTSUPP; in bnxt_hwrm_port_phy_read()
10760 req->port_id = cpu_to_le16(bp->pf.port_id); in bnxt_hwrm_port_phy_read()
10761 req->phy_addr = phy_addr; in bnxt_hwrm_port_phy_read()
10762 req->reg_addr = cpu_to_le16(reg & 0x1f); in bnxt_hwrm_port_phy_read()
10764 req->cl45_mdio = 1; in bnxt_hwrm_port_phy_read()
10765 req->phy_addr = mdio_phy_id_prtad(phy_addr); in bnxt_hwrm_port_phy_read()
10766 req->dev_addr = mdio_phy_id_devad(phy_addr); in bnxt_hwrm_port_phy_read()
10767 req->reg_addr = cpu_to_le16(reg); in bnxt_hwrm_port_phy_read()
10773 *val = le16_to_cpu(resp->reg_data); in bnxt_hwrm_port_phy_read()
10784 if (bp->hwrm_spec_code < 0x10a00) in bnxt_hwrm_port_phy_write()
10785 return -EOPNOTSUPP; in bnxt_hwrm_port_phy_write()
10791 req->port_id = cpu_to_le16(bp->pf.port_id); in bnxt_hwrm_port_phy_write()
10792 req->phy_addr = phy_addr; in bnxt_hwrm_port_phy_write()
10793 req->reg_addr = cpu_to_le16(reg & 0x1f); in bnxt_hwrm_port_phy_write()
10795 req->cl45_mdio = 1; in bnxt_hwrm_port_phy_write()
10796 req->phy_addr = mdio_phy_id_prtad(phy_addr); in bnxt_hwrm_port_phy_write()
10797 req->dev_addr = mdio_phy_id_devad(phy_addr); in bnxt_hwrm_port_phy_write()
10798 req->reg_addr = cpu_to_le16(reg); in bnxt_hwrm_port_phy_write()
10800 req->reg_data = cpu_to_le16(val); in bnxt_hwrm_port_phy_write()
10814 mdio->phy_id = bp->link_info.phy_addr; in bnxt_ioctl()
10821 return -EAGAIN; in bnxt_ioctl()
10823 rc = bnxt_hwrm_port_phy_read(bp, mdio->phy_id, mdio->reg_num, in bnxt_ioctl()
10825 mdio->val_out = mii_regval; in bnxt_ioctl()
10831 return -EAGAIN; in bnxt_ioctl()
10833 return bnxt_hwrm_port_phy_write(bp, mdio->phy_id, mdio->reg_num, in bnxt_ioctl()
10834 mdio->val_in); in bnxt_ioctl()
10846 return -EOPNOTSUPP; in bnxt_ioctl()
10854 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_get_ring_stats()
10855 struct bnxt_napi *bnapi = bp->bnapi[i]; in bnxt_get_ring_stats()
10856 struct bnxt_cp_ring_info *cpr = &bnapi->cp_ring; in bnxt_get_ring_stats()
10857 u64 *sw = cpr->stats.sw_stats; in bnxt_get_ring_stats()
10859 stats->rx_packets += BNXT_GET_RING_STATS64(sw, rx_ucast_pkts); in bnxt_get_ring_stats()
10860 stats->rx_packets += BNXT_GET_RING_STATS64(sw, rx_mcast_pkts); in bnxt_get_ring_stats()
10861 stats->rx_packets += BNXT_GET_RING_STATS64(sw, rx_bcast_pkts); in bnxt_get_ring_stats()
10863 stats->tx_packets += BNXT_GET_RING_STATS64(sw, tx_ucast_pkts); in bnxt_get_ring_stats()
10864 stats->tx_packets += BNXT_GET_RING_STATS64(sw, tx_mcast_pkts); in bnxt_get_ring_stats()
10865 stats->tx_packets += BNXT_GET_RING_STATS64(sw, tx_bcast_pkts); in bnxt_get_ring_stats()
10867 stats->rx_bytes += BNXT_GET_RING_STATS64(sw, rx_ucast_bytes); in bnxt_get_ring_stats()
10868 stats->rx_bytes += BNXT_GET_RING_STATS64(sw, rx_mcast_bytes); in bnxt_get_ring_stats()
10869 stats->rx_bytes += BNXT_GET_RING_STATS64(sw, rx_bcast_bytes); in bnxt_get_ring_stats()
10871 stats->tx_bytes += BNXT_GET_RING_STATS64(sw, tx_ucast_bytes); in bnxt_get_ring_stats()
10872 stats->tx_bytes += BNXT_GET_RING_STATS64(sw, tx_mcast_bytes); in bnxt_get_ring_stats()
10873 stats->tx_bytes += BNXT_GET_RING_STATS64(sw, tx_bcast_bytes); in bnxt_get_ring_stats()
10875 stats->rx_missed_errors += in bnxt_get_ring_stats()
10878 stats->multicast += BNXT_GET_RING_STATS64(sw, rx_mcast_pkts); in bnxt_get_ring_stats()
10880 stats->tx_dropped += BNXT_GET_RING_STATS64(sw, tx_error_pkts); in bnxt_get_ring_stats()
10882 stats->rx_dropped += in bnxt_get_ring_stats()
10883 cpr->sw_stats.rx.rx_netpoll_discards + in bnxt_get_ring_stats()
10884 cpr->sw_stats.rx.rx_oom_discards; in bnxt_get_ring_stats()
10891 struct rtnl_link_stats64 *prev_stats = &bp->net_stats_prev; in bnxt_add_prev_stats()
10893 stats->rx_packets += prev_stats->rx_packets; in bnxt_add_prev_stats()
10894 stats->tx_packets += prev_stats->tx_packets; in bnxt_add_prev_stats()
10895 stats->rx_bytes += prev_stats->rx_bytes; in bnxt_add_prev_stats()
10896 stats->tx_bytes += prev_stats->tx_bytes; in bnxt_add_prev_stats()
10897 stats->rx_missed_errors += prev_stats->rx_missed_errors; in bnxt_add_prev_stats()
10898 stats->multicast += prev_stats->multicast; in bnxt_add_prev_stats()
10899 stats->rx_dropped += prev_stats->rx_dropped; in bnxt_add_prev_stats()
10900 stats->tx_dropped += prev_stats->tx_dropped; in bnxt_add_prev_stats()
10908 set_bit(BNXT_STATE_READ_STATS, &bp->state); in bnxt_get_stats64()
10913 if (!test_bit(BNXT_STATE_OPEN, &bp->state)) { in bnxt_get_stats64()
10914 clear_bit(BNXT_STATE_READ_STATS, &bp->state); in bnxt_get_stats64()
10915 *stats = bp->net_stats_prev; in bnxt_get_stats64()
10922 if (bp->flags & BNXT_FLAG_PORT_STATS) { in bnxt_get_stats64()
10923 u64 *rx = bp->port_stats.sw_stats; in bnxt_get_stats64()
10924 u64 *tx = bp->port_stats.sw_stats + in bnxt_get_stats64()
10927 stats->rx_crc_errors = in bnxt_get_stats64()
10929 stats->rx_frame_errors = in bnxt_get_stats64()
10931 stats->rx_length_errors = in bnxt_get_stats64()
10935 stats->rx_errors = in bnxt_get_stats64()
10938 stats->collisions = in bnxt_get_stats64()
10940 stats->tx_fifo_errors = in bnxt_get_stats64()
10942 stats->tx_errors = BNXT_GET_TX_PORT_STATS64(tx, tx_err); in bnxt_get_stats64()
10944 clear_bit(BNXT_STATE_READ_STATS, &bp->state); in bnxt_get_stats64()
10951 struct bnxt_sw_stats *sw_stats = &cpr->sw_stats; in bnxt_get_one_ring_err_stats()
10952 u64 *hw_stats = cpr->stats.sw_stats; in bnxt_get_one_ring_err_stats()
10954 stats->rx_total_l4_csum_errors += sw_stats->rx.rx_l4_csum_errors; in bnxt_get_one_ring_err_stats()
10955 stats->rx_total_resets += sw_stats->rx.rx_resets; in bnxt_get_one_ring_err_stats()
10956 stats->rx_total_buf_errors += sw_stats->rx.rx_buf_errors; in bnxt_get_one_ring_err_stats()
10957 stats->rx_total_oom_discards += sw_stats->rx.rx_oom_discards; in bnxt_get_one_ring_err_stats()
10958 stats->rx_total_netpoll_discards += sw_stats->rx.rx_netpoll_discards; in bnxt_get_one_ring_err_stats()
10959 stats->rx_total_ring_discards += in bnxt_get_one_ring_err_stats()
10961 stats->tx_total_resets += sw_stats->tx.tx_resets; in bnxt_get_one_ring_err_stats()
10962 stats->tx_total_ring_discards += in bnxt_get_one_ring_err_stats()
10964 stats->total_missed_irqs += sw_stats->cmn.missed_irqs; in bnxt_get_one_ring_err_stats()
10972 for (i = 0; i < bp->cp_nr_rings; i++) in bnxt_get_ring_err_stats()
10973 bnxt_get_one_ring_err_stats(bp, stats, &bp->bnapi[i]->cp_ring); in bnxt_get_ring_err_stats()
10978 struct net_device *dev = bp->dev; in bnxt_mc_list_updated()
10979 struct bnxt_vnic_info *vnic = &bp->vnic_info[0]; in bnxt_mc_list_updated()
10989 vnic->mc_list_count = 0; in bnxt_mc_list_updated()
10992 haddr = ha->addr; in bnxt_mc_list_updated()
10993 if (!ether_addr_equal(haddr, vnic->mc_list + off)) { in bnxt_mc_list_updated()
10994 memcpy(vnic->mc_list + off, haddr, ETH_ALEN); in bnxt_mc_list_updated()
11003 if (mc_count != vnic->mc_list_count) { in bnxt_mc_list_updated()
11004 vnic->mc_list_count = mc_count; in bnxt_mc_list_updated()
11012 struct net_device *dev = bp->dev; in bnxt_uc_list_updated()
11013 struct bnxt_vnic_info *vnic = &bp->vnic_info[0]; in bnxt_uc_list_updated()
11017 if (netdev_uc_count(dev) != (vnic->uc_filter_count - 1)) in bnxt_uc_list_updated()
11021 if (!ether_addr_equal(ha->addr, vnic->uc_list + off)) in bnxt_uc_list_updated()
11037 if (!test_bit(BNXT_STATE_OPEN, &bp->state)) in bnxt_set_rx_mode()
11040 vnic = &bp->vnic_info[0]; in bnxt_set_rx_mode()
11041 mask = vnic->rx_mask; in bnxt_set_rx_mode()
11047 if (dev->flags & IFF_PROMISC) in bnxt_set_rx_mode()
11052 if (dev->flags & IFF_BROADCAST) in bnxt_set_rx_mode()
11054 if (dev->flags & IFF_ALLMULTI) { in bnxt_set_rx_mode()
11056 vnic->mc_list_count = 0; in bnxt_set_rx_mode()
11057 } else if (dev->flags & IFF_MULTICAST) { in bnxt_set_rx_mode()
11061 if (mask != vnic->rx_mask || uc_update || mc_update) { in bnxt_set_rx_mode()
11062 vnic->rx_mask = mask; in bnxt_set_rx_mode()
11070 struct net_device *dev = bp->dev; in bnxt_cfg_rx_mode()
11071 struct bnxt_vnic_info *vnic = &bp->vnic_info[0]; in bnxt_cfg_rx_mode()
11088 for (i = 1; i < vnic->uc_filter_count; i++) { in bnxt_cfg_rx_mode()
11089 req->l2_filter_id = vnic->fw_l2_filter_id[i]; in bnxt_cfg_rx_mode()
11095 vnic->uc_filter_count = 1; in bnxt_cfg_rx_mode()
11098 if (netdev_uc_count(dev) > (BNXT_MAX_UC_ADDRS - 1)) { in bnxt_cfg_rx_mode()
11099 vnic->rx_mask |= CFA_L2_SET_RX_MASK_REQ_MASK_PROMISCUOUS; in bnxt_cfg_rx_mode()
11102 memcpy(vnic->uc_list + off, ha->addr, ETH_ALEN); in bnxt_cfg_rx_mode()
11104 vnic->uc_filter_count++; in bnxt_cfg_rx_mode()
11109 for (i = 1, off = 0; i < vnic->uc_filter_count; i++, off += ETH_ALEN) { in bnxt_cfg_rx_mode()
11110 rc = bnxt_hwrm_set_vnic_filter(bp, 0, i, vnic->uc_list + off); in bnxt_cfg_rx_mode()
11112 if (BNXT_VF(bp) && rc == -ENODEV) { in bnxt_cfg_rx_mode()
11113 if (!test_and_set_bit(BNXT_STATE_L2_FILTER_RETRY, &bp->state)) in bnxt_cfg_rx_mode()
11114 netdev_warn(bp->dev, "Cannot configure L2 filters while PF is unavailable, will retry\n"); in bnxt_cfg_rx_mode()
11116 netdev_dbg(bp->dev, "PF still unavailable while configuring L2 filters.\n"); in bnxt_cfg_rx_mode()
11119 netdev_err(bp->dev, "HWRM vnic filter failure rc: %x\n", rc); in bnxt_cfg_rx_mode()
11121 vnic->uc_filter_count = i; in bnxt_cfg_rx_mode()
11125 if (test_and_clear_bit(BNXT_STATE_L2_FILTER_RETRY, &bp->state)) in bnxt_cfg_rx_mode()
11126 netdev_notice(bp->dev, "Retry of L2 filter configuration successful.\n"); in bnxt_cfg_rx_mode()
11129 if ((vnic->rx_mask & CFA_L2_SET_RX_MASK_REQ_MASK_PROMISCUOUS) && in bnxt_cfg_rx_mode()
11131 vnic->rx_mask &= ~CFA_L2_SET_RX_MASK_REQ_MASK_PROMISCUOUS; in bnxt_cfg_rx_mode()
11133 if (rc && (vnic->rx_mask & CFA_L2_SET_RX_MASK_REQ_MASK_MCAST)) { in bnxt_cfg_rx_mode()
11134 netdev_info(bp->dev, "Failed setting MC filters rc: %d, turning on ALL_MCAST mode\n", in bnxt_cfg_rx_mode()
11136 vnic->rx_mask &= ~CFA_L2_SET_RX_MASK_REQ_MASK_MCAST; in bnxt_cfg_rx_mode()
11137 vnic->rx_mask |= CFA_L2_SET_RX_MASK_REQ_MASK_ALL_MCAST; in bnxt_cfg_rx_mode()
11138 vnic->mc_list_count = 0; in bnxt_cfg_rx_mode()
11142 netdev_err(bp->dev, "HWRM cfa l2 rx mask failure rc: %d\n", in bnxt_cfg_rx_mode()
11152 struct bnxt_hw_resc *hw_resc = &bp->hw_resc; in bnxt_can_reserve_rings()
11155 * reserve rings by default when device is down. in bnxt_can_reserve_rings()
11157 if (hw_resc->min_tx_rings || hw_resc->resv_tx_rings) in bnxt_can_reserve_rings()
11160 if (!netif_running(bp->dev)) in bnxt_can_reserve_rings()
11170 if (bp->flags & BNXT_FLAG_CHIP_P5) { in bnxt_rfs_supported()
11171 if (bp->fw_cap & BNXT_FW_CAP_CFA_RFS_RING_TBL_IDX_V2) in bnxt_rfs_supported()
11180 if (bp->flags & BNXT_FLAG_NEW_RSS_CAP) in bnxt_rfs_supported()
11191 if (bp->flags & BNXT_FLAG_CHIP_P5) in bnxt_rfs_capable()
11193 if (!(bp->flags & BNXT_FLAG_MSIX_CAP) || !bnxt_can_reserve_rings(bp) || !bp->rx_nr_rings) in bnxt_rfs_capable()
11196 vnics = 1 + bp->rx_nr_rings; in bnxt_rfs_capable()
11201 if (bp->flags & BNXT_FLAG_NEW_RSS_CAP) in bnxt_rfs_capable()
11204 if (bp->rx_nr_rings > 1) in bnxt_rfs_capable()
11205 netdev_warn(bp->dev, in bnxt_rfs_capable()
11207 min(max_rss_ctxs - 1, max_vnics - 1)); in bnxt_rfs_capable()
11214 if (vnics == bp->hw_resc.resv_vnics) in bnxt_rfs_capable()
11218 if (vnics <= bp->hw_resc.resv_vnics) in bnxt_rfs_capable()
11221 netdev_warn(bp->dev, "Unable to reserve resources to support NTUPLE filters.\n"); in bnxt_rfs_capable()
11238 if ((bp->flags & BNXT_FLAG_NO_AGG_RINGS) || bp->xdp_prog) in bnxt_fix_features()
11252 if (dev->features & BNXT_HW_FEATURE_VLAN_ALL_RX) in bnxt_fix_features()
11258 if (BNXT_VF(bp) && bp->vf.vlan) in bnxt_fix_features()
11267 u32 flags = bp->flags; in bnxt_set_features()
11279 if (bp->flags & BNXT_FLAG_NO_AGG_RINGS) in bnxt_set_features()
11288 changes = flags ^ bp->flags; in bnxt_set_features()
11291 if ((bp->flags & BNXT_FLAG_TPA) == 0 || in bnxt_set_features()
11293 (bp->flags & BNXT_FLAG_CHIP_P5)) in bnxt_set_features()
11300 if (flags != bp->flags) { in bnxt_set_features()
11301 u32 old_flags = bp->flags; in bnxt_set_features()
11303 if (!test_bit(BNXT_STATE_OPEN, &bp->state)) { in bnxt_set_features()
11304 bp->flags = flags; in bnxt_set_features()
11312 bp->flags = flags; in bnxt_set_features()
11319 bp->flags = flags; in bnxt_set_features()
11324 bp->flags = old_flags; in bnxt_set_features()
11333 struct ipv6hdr *ip6h = (struct ipv6hdr *)(skb->data + nw_off); in bnxt_exthdr_check()
11343 nexthdr = &ip6h->nexthdr; in bnxt_exthdr_check()
11351 hp = __skb_header_pointer(NULL, start, sizeof(*hp), skb->data, in bnxt_exthdr_check()
11363 /* The ext header may be a hop-by-hop header inserted for in bnxt_exthdr_check()
11368 if (likely(skb->len <= GRO_LEGACY_MAX_SIZE)) in bnxt_exthdr_check()
11372 if (jhdr->tlv_type != IPV6_TLV_JUMBO || jhdr->hdrlen != 0 || in bnxt_exthdr_check()
11373 jhdr->nexthdr != IPPROTO_TCP) in bnxt_exthdr_check()
11381 nexthdr = &hp->nexthdr; in bnxt_exthdr_check()
11386 if (skb->encapsulation) { in bnxt_exthdr_check()
11392 /* Only support TCP/UDP for non-tunneled ipv6 and inner ipv6 */ in bnxt_exthdr_check()
11400 __be16 udp_port = uh->dest; in bnxt_udp_tunl_check()
11402 if (udp_port != bp->vxlan_port && udp_port != bp->nge_port) in bnxt_udp_tunl_check()
11404 if (skb->inner_protocol_type == ENCAP_TYPE_ETHER) { in bnxt_udp_tunl_check()
11407 switch (eh->h_proto) { in bnxt_udp_tunl_check()
11427 switch (skb->inner_protocol) { in bnxt_tunl_check()
11454 if (!skb->encapsulation) in bnxt_features_check()
11456 l4_proto = &ip_hdr(skb)->protocol; in bnxt_features_check()
11487 rc = -ENOMEM; in bnxt_dbg_hwrm_rd_reg()
11491 req->host_dest_addr = cpu_to_le64(mapping); in bnxt_dbg_hwrm_rd_reg()
11494 req->read_addr = cpu_to_le32(reg_off + CHIMP_REG_VIEW_ADDR); in bnxt_dbg_hwrm_rd_reg()
11495 req->read_len32 = cpu_to_le32(num_words); in bnxt_dbg_hwrm_rd_reg()
11498 if (rc || resp->error_code) { in bnxt_dbg_hwrm_rd_reg()
11499 rc = -EIO; in bnxt_dbg_hwrm_rd_reg()
11521 req->ring_type = ring_type; in bnxt_dbg_hwrm_ring_info_get()
11522 req->fw_ring_id = cpu_to_le32(ring_id); in bnxt_dbg_hwrm_ring_info_get()
11526 *prod = le32_to_cpu(resp->producer_index); in bnxt_dbg_hwrm_ring_info_get()
11527 *cons = le32_to_cpu(resp->consumer_index); in bnxt_dbg_hwrm_ring_info_get()
11535 struct bnxt_tx_ring_info *txr = bnapi->tx_ring; in bnxt_dump_tx_sw_state()
11536 int i = bnapi->index; in bnxt_dump_tx_sw_state()
11541 netdev_info(bnapi->bp->dev, "[%d]: tx{fw_ring: %d prod: %x cons: %x}\n", in bnxt_dump_tx_sw_state()
11542 i, txr->tx_ring_struct.fw_ring_id, txr->tx_prod, in bnxt_dump_tx_sw_state()
11543 txr->tx_cons); in bnxt_dump_tx_sw_state()
11548 struct bnxt_rx_ring_info *rxr = bnapi->rx_ring; in bnxt_dump_rx_sw_state()
11549 int i = bnapi->index; in bnxt_dump_rx_sw_state()
11554 …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()
11555 i, rxr->rx_ring_struct.fw_ring_id, rxr->rx_prod, in bnxt_dump_rx_sw_state()
11556 rxr->rx_agg_ring_struct.fw_ring_id, rxr->rx_agg_prod, in bnxt_dump_rx_sw_state()
11557 rxr->rx_sw_agg_prod); in bnxt_dump_rx_sw_state()
11562 struct bnxt_cp_ring_info *cpr = &bnapi->cp_ring; in bnxt_dump_cp_sw_state()
11563 int i = bnapi->index; in bnxt_dump_cp_sw_state()
11565 netdev_info(bnapi->bp->dev, "[%d]: cp{fw_ring: %d raw_cons: %x}\n", in bnxt_dump_cp_sw_state()
11566 i, cpr->cp_ring_struct.fw_ring_id, cpr->cp_raw_cons); in bnxt_dump_cp_sw_state()
11574 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_dbg_dump_states()
11575 bnapi = bp->bnapi[i]; in bnxt_dbg_dump_states()
11586 struct bnxt_rx_ring_info *rxr = &bp->rx_ring[ring_nr]; in bnxt_hwrm_rx_ring_reset()
11588 struct bnxt_napi *bnapi = rxr->bnapi; in bnxt_hwrm_rx_ring_reset()
11597 cpr = &bnapi->cp_ring; in bnxt_hwrm_rx_ring_reset()
11598 cp_ring_id = cpr->cp_ring_struct.fw_ring_id; in bnxt_hwrm_rx_ring_reset()
11599 req->cmpl_ring = cpu_to_le16(cp_ring_id); in bnxt_hwrm_rx_ring_reset()
11600 req->ring_type = RING_RESET_REQ_RING_TYPE_RX_RING_GRP; in bnxt_hwrm_rx_ring_reset()
11601 req->ring_id = cpu_to_le16(bp->grp_info[bnapi->index].fw_grp_id); in bnxt_hwrm_rx_ring_reset()
11609 if (netif_running(bp->dev)) { in bnxt_reset_task()
11628 netdev_err(bp->dev, "TX timeout detected, starting reset task!\n"); in bnxt_tx_timeout()
11634 struct bnxt_fw_health *fw_health = bp->fw_health; in bnxt_fw_health_check()
11635 struct pci_dev *pdev = bp->pdev; in bnxt_fw_health_check()
11638 if (!fw_health->enabled || test_bit(BNXT_STATE_IN_FW_RESET, &bp->state)) in bnxt_fw_health_check()
11643 if (fw_health->tmr_counter) { in bnxt_fw_health_check()
11644 fw_health->tmr_counter--; in bnxt_fw_health_check()
11649 if (val == fw_health->last_fw_heartbeat && pci_device_is_present(pdev)) { in bnxt_fw_health_check()
11650 fw_health->arrests++; in bnxt_fw_health_check()
11654 fw_health->last_fw_heartbeat = val; in bnxt_fw_health_check()
11657 if (val != fw_health->last_fw_reset_cnt && pci_device_is_present(pdev)) { in bnxt_fw_health_check()
11658 fw_health->discoveries++; in bnxt_fw_health_check()
11662 fw_health->tmr_counter = fw_health->tmr_multiplier; in bnxt_fw_health_check()
11672 struct net_device *dev = bp->dev; in bnxt_timer()
11674 if (!netif_running(dev) || !test_bit(BNXT_STATE_OPEN, &bp->state)) in bnxt_timer()
11677 if (atomic_read(&bp->intr_sem) != 0) in bnxt_timer()
11680 if (bp->fw_cap & BNXT_FW_CAP_ERROR_RECOVERY) in bnxt_timer()
11683 if (BNXT_LINK_IS_UP(bp) && bp->stats_coal_ticks) in bnxt_timer()
11690 if ((bp->flags & BNXT_FLAG_RFS) && bp->ntp_fltr_count) in bnxt_timer()
11694 if (bp->link_info.phy_retry) { in bnxt_timer()
11695 if (time_after(jiffies, bp->link_info.phy_retry_expires)) { in bnxt_timer()
11696 bp->link_info.phy_retry = false; in bnxt_timer()
11697 netdev_warn(bp->dev, "failed to update phy settings after maximum retries.\n"); in bnxt_timer()
11703 if (test_bit(BNXT_STATE_L2_FILTER_RETRY, &bp->state)) in bnxt_timer()
11706 if ((bp->flags & BNXT_FLAG_CHIP_P5) && !bp->chip_rev && in bnxt_timer()
11711 mod_timer(&bp->timer, jiffies + bp->current_interval); in bnxt_timer()
11721 clear_bit(BNXT_STATE_IN_SP_TASK, &bp->state); in bnxt_rtnl_lock_sp()
11727 set_bit(BNXT_STATE_IN_SP_TASK, &bp->state); in bnxt_rtnl_unlock_sp()
11735 if (test_bit(BNXT_STATE_OPEN, &bp->state)) in bnxt_reset()
11746 if (!test_bit(BNXT_STATE_OPEN, &bp->state)) { in bnxt_rx_ring_reset()
11751 if (bp->flags & BNXT_FLAG_TPA) in bnxt_rx_ring_reset()
11753 for (i = 0; i < bp->rx_nr_rings; i++) { in bnxt_rx_ring_reset()
11754 struct bnxt_rx_ring_info *rxr = &bp->rx_ring[i]; in bnxt_rx_ring_reset()
11758 if (!rxr->bnapi->in_reset) in bnxt_rx_ring_reset()
11763 if (rc == -EINVAL || rc == -EOPNOTSUPP) in bnxt_rx_ring_reset()
11764 …netdev_info_once(bp->dev, "RX ring reset not supported by firmware, falling back to global reset\n… in bnxt_rx_ring_reset()
11766 netdev_warn(bp->dev, "RX ring reset failed, rc = %d, falling back to global reset\n", in bnxt_rx_ring_reset()
11772 rxr->rx_prod = 0; in bnxt_rx_ring_reset()
11773 rxr->rx_agg_prod = 0; in bnxt_rx_ring_reset()
11774 rxr->rx_sw_agg_prod = 0; in bnxt_rx_ring_reset()
11775 rxr->rx_next_cons = 0; in bnxt_rx_ring_reset()
11776 rxr->bnapi->in_reset = false; in bnxt_rx_ring_reset()
11778 cpr = &rxr->bnapi->cp_ring; in bnxt_rx_ring_reset()
11779 cpr->sw_stats.rx.rx_resets++; in bnxt_rx_ring_reset()
11780 if (bp->flags & BNXT_FLAG_AGG_RINGS) in bnxt_rx_ring_reset()
11781 bnxt_db_write(bp, &rxr->rx_agg_db, rxr->rx_agg_prod); in bnxt_rx_ring_reset()
11782 bnxt_db_write(bp, &rxr->rx_db, rxr->rx_prod); in bnxt_rx_ring_reset()
11784 if (bp->flags & BNXT_FLAG_TPA) in bnxt_rx_ring_reset()
11796 if (test_bit(BNXT_STATE_FW_FATAL_COND, &bp->state)) { in bnxt_fw_reset_close()
11799 pci_read_config_word(bp->pdev, PCI_SUBSYSTEM_ID, &val); in bnxt_fw_reset_close()
11801 bp->fw_reset_min_dsecs = 0; in bnxt_fw_reset_close()
11807 pci_disable_device(bp->pdev); in bnxt_fw_reset_close()
11813 if (pci_is_enabled(bp->pdev)) in bnxt_fw_reset_close()
11814 pci_disable_device(bp->pdev); in bnxt_fw_reset_close()
11816 kfree(bp->ctx); in bnxt_fw_reset_close()
11817 bp->ctx = NULL; in bnxt_fw_reset_close()
11822 struct bnxt_fw_health *fw_health = bp->fw_health; in is_bnxt_fw_ok()
11827 if (val == fw_health->last_fw_heartbeat) in is_bnxt_fw_ok()
11831 if (val != fw_health->last_fw_reset_cnt) in is_bnxt_fw_ok()
11843 struct bnxt_fw_health *fw_health = bp->fw_health; in bnxt_force_fw_reset()
11844 struct bnxt_ptp_cfg *ptp = bp->ptp_cfg; in bnxt_force_fw_reset()
11847 if (!test_bit(BNXT_STATE_OPEN, &bp->state) || in bnxt_force_fw_reset()
11848 test_bit(BNXT_STATE_IN_FW_RESET, &bp->state)) in bnxt_force_fw_reset()
11852 spin_lock_bh(&ptp->ptp_lock); in bnxt_force_fw_reset()
11853 set_bit(BNXT_STATE_IN_FW_RESET, &bp->state); in bnxt_force_fw_reset()
11854 spin_unlock_bh(&ptp->ptp_lock); in bnxt_force_fw_reset()
11856 set_bit(BNXT_STATE_IN_FW_RESET, &bp->state); in bnxt_force_fw_reset()
11859 wait_dsecs = fw_health->master_func_wait_dsecs; in bnxt_force_fw_reset()
11860 if (fw_health->primary) { in bnxt_force_fw_reset()
11861 if (fw_health->flags & ERROR_RECOVERY_QCFG_RESP_FLAGS_CO_CPU) in bnxt_force_fw_reset()
11863 bp->fw_reset_state = BNXT_FW_RESET_STATE_RESET_FW; in bnxt_force_fw_reset()
11865 bp->fw_reset_timestamp = jiffies + wait_dsecs * HZ / 10; in bnxt_force_fw_reset()
11866 wait_dsecs = fw_health->normal_func_wait_dsecs; in bnxt_force_fw_reset()
11867 bp->fw_reset_state = BNXT_FW_RESET_STATE_ENABLE_DEV; in bnxt_force_fw_reset()
11870 bp->fw_reset_min_dsecs = fw_health->post_reset_wait_dsecs; in bnxt_force_fw_reset()
11871 bp->fw_reset_max_dsecs = fw_health->post_reset_max_wait_dsecs; in bnxt_force_fw_reset()
11877 netdev_warn(bp->dev, "Detected firmware fatal condition, initiating reset\n"); in bnxt_fw_exception()
11878 set_bit(BNXT_STATE_FW_FATAL_COND, &bp->state); in bnxt_fw_exception()
11897 netdev_err(bp->dev, "func_qcfg cmd failed, rc = %d\n", rc); in bnxt_get_registered_vfs()
11900 if (bp->pf.registered_vfs) in bnxt_get_registered_vfs()
11901 return bp->pf.registered_vfs; in bnxt_get_registered_vfs()
11902 if (bp->sriov_cfg) in bnxt_get_registered_vfs()
11911 if (test_bit(BNXT_STATE_OPEN, &bp->state) && in bnxt_fw_reset()
11912 !test_bit(BNXT_STATE_IN_FW_RESET, &bp->state)) { in bnxt_fw_reset()
11913 struct bnxt_ptp_cfg *ptp = bp->ptp_cfg; in bnxt_fw_reset()
11917 spin_lock_bh(&ptp->ptp_lock); in bnxt_fw_reset()
11918 set_bit(BNXT_STATE_IN_FW_RESET, &bp->state); in bnxt_fw_reset()
11919 spin_unlock_bh(&ptp->ptp_lock); in bnxt_fw_reset()
11921 set_bit(BNXT_STATE_IN_FW_RESET, &bp->state); in bnxt_fw_reset()
11923 if (bp->pf.active_vfs && in bnxt_fw_reset()
11924 !test_bit(BNXT_STATE_FW_FATAL_COND, &bp->state)) in bnxt_fw_reset()
11927 netdev_err(bp->dev, "Firmware reset aborted, rc = %d\n", in bnxt_fw_reset()
11929 clear_bit(BNXT_STATE_IN_FW_RESET, &bp->state); in bnxt_fw_reset()
11930 dev_close(bp->dev); in bnxt_fw_reset()
11935 if (bp->fw_reset_max_dsecs < vf_tmo_dsecs) in bnxt_fw_reset()
11936 bp->fw_reset_max_dsecs = vf_tmo_dsecs; in bnxt_fw_reset()
11937 bp->fw_reset_state = in bnxt_fw_reset()
11943 if (bp->fw_cap & BNXT_FW_CAP_ERR_RECOVER_RELOAD) { in bnxt_fw_reset()
11944 bp->fw_reset_state = BNXT_FW_RESET_STATE_POLL_FW_DOWN; in bnxt_fw_reset()
11947 bp->fw_reset_state = BNXT_FW_RESET_STATE_ENABLE_DEV; in bnxt_fw_reset()
11948 tmo = bp->fw_reset_min_dsecs * HZ / 10; in bnxt_fw_reset()
11960 if (!(bp->flags & BNXT_FLAG_CHIP_P5)) in bnxt_chk_missed_irq()
11963 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_chk_missed_irq()
11964 struct bnxt_napi *bnapi = bp->bnapi[i]; in bnxt_chk_missed_irq()
11972 cpr = &bnapi->cp_ring; in bnxt_chk_missed_irq()
11974 struct bnxt_cp_ring_info *cpr2 = cpr->cp_ring_arr[j]; in bnxt_chk_missed_irq()
11977 if (!cpr2 || cpr2->has_more_work || in bnxt_chk_missed_irq()
11981 if (cpr2->cp_raw_cons != cpr2->last_cp_raw_cons) { in bnxt_chk_missed_irq()
11982 cpr2->last_cp_raw_cons = cpr2->cp_raw_cons; in bnxt_chk_missed_irq()
11985 fw_ring_id = cpr2->cp_ring_struct.fw_ring_id; in bnxt_chk_missed_irq()
11989 cpr->sw_stats.cmn.missed_irqs++; in bnxt_chk_missed_irq()
11998 struct bnxt_link_info *link_info = &bp->link_info; in bnxt_init_ethtool_link_settings()
12000 if (BNXT_AUTO_MODE(link_info->auto_mode)) { in bnxt_init_ethtool_link_settings()
12001 link_info->autoneg = BNXT_AUTONEG_SPEED; in bnxt_init_ethtool_link_settings()
12002 if (bp->hwrm_spec_code >= 0x10201) { in bnxt_init_ethtool_link_settings()
12003 if (link_info->auto_pause_setting & in bnxt_init_ethtool_link_settings()
12005 link_info->autoneg |= BNXT_AUTONEG_FLOW_CTRL; in bnxt_init_ethtool_link_settings()
12007 link_info->autoneg |= BNXT_AUTONEG_FLOW_CTRL; in bnxt_init_ethtool_link_settings()
12009 link_info->advertising = link_info->auto_link_speeds; in bnxt_init_ethtool_link_settings()
12010 link_info->advertising_pam4 = link_info->auto_pam4_link_speeds; in bnxt_init_ethtool_link_settings()
12012 link_info->req_link_speed = link_info->force_link_speed; in bnxt_init_ethtool_link_settings()
12013 link_info->req_signal_mode = BNXT_SIG_MODE_NRZ; in bnxt_init_ethtool_link_settings()
12014 if (link_info->force_pam4_link_speed) { in bnxt_init_ethtool_link_settings()
12015 link_info->req_link_speed = in bnxt_init_ethtool_link_settings()
12016 link_info->force_pam4_link_speed; in bnxt_init_ethtool_link_settings()
12017 link_info->req_signal_mode = BNXT_SIG_MODE_PAM4; in bnxt_init_ethtool_link_settings()
12019 link_info->req_duplex = link_info->duplex_setting; in bnxt_init_ethtool_link_settings()
12021 if (link_info->autoneg & BNXT_AUTONEG_FLOW_CTRL) in bnxt_init_ethtool_link_settings()
12022 link_info->req_flow_ctrl = in bnxt_init_ethtool_link_settings()
12023 link_info->auto_pause_setting & BNXT_LINK_PAUSE_BOTH; in bnxt_init_ethtool_link_settings()
12025 link_info->req_flow_ctrl = link_info->force_pause_setting; in bnxt_init_ethtool_link_settings()
12030 struct bnxt_fw_health *fw_health = bp->fw_health; in bnxt_fw_echo_reply()
12037 req->event_data1 = cpu_to_le32(fw_health->echo_req_data1); in bnxt_fw_echo_reply()
12038 req->event_data2 = cpu_to_le32(fw_health->echo_req_data2); in bnxt_fw_echo_reply()
12046 set_bit(BNXT_STATE_IN_SP_TASK, &bp->state); in bnxt_sp_task()
12048 if (!test_bit(BNXT_STATE_OPEN, &bp->state)) { in bnxt_sp_task()
12049 clear_bit(BNXT_STATE_IN_SP_TASK, &bp->state); in bnxt_sp_task()
12053 if (test_and_clear_bit(BNXT_RX_MASK_SP_EVENT, &bp->sp_event)) in bnxt_sp_task()
12056 if (test_and_clear_bit(BNXT_RX_NTP_FLTR_SP_EVENT, &bp->sp_event)) in bnxt_sp_task()
12058 if (test_and_clear_bit(BNXT_HWRM_EXEC_FWD_REQ_SP_EVENT, &bp->sp_event)) in bnxt_sp_task()
12060 if (test_and_clear_bit(BNXT_PERIODIC_STATS_SP_EVENT, &bp->sp_event)) { in bnxt_sp_task()
12066 if (test_and_clear_bit(BNXT_LINK_CHNG_SP_EVENT, &bp->sp_event)) { in bnxt_sp_task()
12069 mutex_lock(&bp->link_lock); in bnxt_sp_task()
12071 &bp->sp_event)) in bnxt_sp_task()
12076 netdev_err(bp->dev, "SP task can't update link (rc: %x)\n", in bnxt_sp_task()
12080 &bp->sp_event)) in bnxt_sp_task()
12082 mutex_unlock(&bp->link_lock); in bnxt_sp_task()
12084 if (test_and_clear_bit(BNXT_UPDATE_PHY_SP_EVENT, &bp->sp_event)) { in bnxt_sp_task()
12087 mutex_lock(&bp->link_lock); in bnxt_sp_task()
12089 mutex_unlock(&bp->link_lock); in bnxt_sp_task()
12091 netdev_warn(bp->dev, "update phy settings retry failed\n"); in bnxt_sp_task()
12093 bp->link_info.phy_retry = false; in bnxt_sp_task()
12094 netdev_info(bp->dev, "update phy settings retry succeeded\n"); in bnxt_sp_task()
12097 if (test_and_clear_bit(BNXT_HWRM_PORT_MODULE_SP_EVENT, &bp->sp_event)) { in bnxt_sp_task()
12098 mutex_lock(&bp->link_lock); in bnxt_sp_task()
12100 mutex_unlock(&bp->link_lock); in bnxt_sp_task()
12103 if (test_and_clear_bit(BNXT_FLOW_STATS_SP_EVENT, &bp->sp_event)) in bnxt_sp_task()
12106 if (test_and_clear_bit(BNXT_RING_COAL_NOW_SP_EVENT, &bp->sp_event)) in bnxt_sp_task()
12109 if (test_and_clear_bit(BNXT_FW_ECHO_REQUEST_SP_EVENT, &bp->sp_event)) in bnxt_sp_task()
12115 if (test_and_clear_bit(BNXT_RESET_TASK_SP_EVENT, &bp->sp_event)) in bnxt_sp_task()
12118 if (test_and_clear_bit(BNXT_RESET_TASK_SILENT_SP_EVENT, &bp->sp_event)) in bnxt_sp_task()
12121 if (test_and_clear_bit(BNXT_RST_RING_SP_EVENT, &bp->sp_event)) in bnxt_sp_task()
12124 if (test_and_clear_bit(BNXT_FW_RESET_NOTIFY_SP_EVENT, &bp->sp_event)) { in bnxt_sp_task()
12125 if (test_bit(BNXT_STATE_FW_FATAL_COND, &bp->state) || in bnxt_sp_task()
12126 test_bit(BNXT_STATE_FW_NON_FATAL_COND, &bp->state)) in bnxt_sp_task()
12132 if (test_and_clear_bit(BNXT_FW_EXCEPTION_SP_EVENT, &bp->sp_event)) { in bnxt_sp_task()
12138 clear_bit(BNXT_STATE_IN_SP_TASK, &bp->state); in bnxt_sp_task()
12158 return -ENOMEM; in bnxt_check_rings()
12162 return -ENOMEM; in bnxt_check_rings()
12165 if ((bp->flags & (BNXT_FLAG_RFS | BNXT_FLAG_CHIP_P5)) == BNXT_FLAG_RFS) in bnxt_check_rings()
12168 if (bp->flags & BNXT_FLAG_AGG_RINGS) in bnxt_check_rings()
12182 if (bp->bar2) { in bnxt_unmap_bars()
12183 pci_iounmap(pdev, bp->bar2); in bnxt_unmap_bars()
12184 bp->bar2 = NULL; in bnxt_unmap_bars()
12187 if (bp->bar1) { in bnxt_unmap_bars()
12188 pci_iounmap(pdev, bp->bar1); in bnxt_unmap_bars()
12189 bp->bar1 = NULL; in bnxt_unmap_bars()
12192 if (bp->bar0) { in bnxt_unmap_bars()
12193 pci_iounmap(pdev, bp->bar0); in bnxt_unmap_bars()
12194 bp->bar0 = NULL; in bnxt_unmap_bars()
12200 bnxt_unmap_bars(bp, bp->pdev); in bnxt_cleanup_pci()
12201 pci_release_regions(bp->pdev); in bnxt_cleanup_pci()
12202 if (pci_is_enabled(bp->pdev)) in bnxt_cleanup_pci()
12203 pci_disable_device(bp->pdev); in bnxt_cleanup_pci()
12208 struct bnxt_coal_cap *coal_cap = &bp->coal_cap; in bnxt_init_dflt_coal()
12212 if (coal_cap->cmpl_params & in bnxt_init_dflt_coal()
12219 coal = &bp->rx_coal; in bnxt_init_dflt_coal()
12220 coal->coal_ticks = 10; in bnxt_init_dflt_coal()
12221 coal->coal_bufs = 30; in bnxt_init_dflt_coal()
12222 coal->coal_ticks_irq = 1; in bnxt_init_dflt_coal()
12223 coal->coal_bufs_irq = 2; in bnxt_init_dflt_coal()
12224 coal->idle_thresh = 50; in bnxt_init_dflt_coal()
12225 coal->bufs_per_record = 2; in bnxt_init_dflt_coal()
12226 coal->budget = 64; /* NAPI budget */ in bnxt_init_dflt_coal()
12227 coal->flags = flags; in bnxt_init_dflt_coal()
12229 coal = &bp->tx_coal; in bnxt_init_dflt_coal()
12230 coal->coal_ticks = 28; in bnxt_init_dflt_coal()
12231 coal->coal_bufs = 30; in bnxt_init_dflt_coal()
12232 coal->coal_ticks_irq = 2; in bnxt_init_dflt_coal()
12233 coal->coal_bufs_irq = 2; in bnxt_init_dflt_coal()
12234 coal->bufs_per_record = 1; in bnxt_init_dflt_coal()
12235 coal->flags = flags; in bnxt_init_dflt_coal()
12237 bp->stats_coal_ticks = BNXT_DEF_STATS_COAL_TICKS; in bnxt_init_dflt_coal()
12244 bp->fw_cap = 0; in bnxt_fw_init_one_p1()
12260 return -ENODEV; in bnxt_fw_init_one_p1()
12273 netdev_err(bp->dev, "hwrm query capability failure rc: %x\n", in bnxt_fw_init_one_p2()
12275 return -ENODEV; in bnxt_fw_init_one_p2()
12280 netdev_warn(bp->dev, "hwrm query adv flow mgnt failure rc: %d\n", in bnxt_fw_init_one_p2()
12284 netdev_warn(bp->dev, "no memory for firmware error recovery\n"); in bnxt_fw_init_one_p2()
12288 netdev_warn(bp->dev, "hwrm query error recovery failure rc: %d\n", in bnxt_fw_init_one_p2()
12294 return -ENODEV; in bnxt_fw_init_one_p2()
12300 if (bp->fw_cap & BNXT_FW_CAP_PTP) in bnxt_fw_init_one_p2()
12308 bp->flags &= ~BNXT_FLAG_UDP_RSS_CAP; in bnxt_set_dflt_rss_hash_type()
12309 bp->rss_hash_cfg = VNIC_RSS_CFG_REQ_HASH_TYPE_IPV4 | in bnxt_set_dflt_rss_hash_type()
12313 if (bp->fw_cap & BNXT_FW_CAP_RSS_HASH_TYPE_DELTA) in bnxt_set_dflt_rss_hash_type()
12314 bp->rss_hash_delta = bp->rss_hash_cfg; in bnxt_set_dflt_rss_hash_type()
12315 if (BNXT_CHIP_P4_PLUS(bp) && bp->hwrm_spec_code >= 0x10501) { in bnxt_set_dflt_rss_hash_type()
12316 bp->flags |= BNXT_FLAG_UDP_RSS_CAP; in bnxt_set_dflt_rss_hash_type()
12317 bp->rss_hash_cfg |= VNIC_RSS_CFG_REQ_HASH_TYPE_UDP_IPV4 | in bnxt_set_dflt_rss_hash_type()
12324 struct net_device *dev = bp->dev; in bnxt_set_dflt_rfs()
12326 dev->hw_features &= ~NETIF_F_NTUPLE; in bnxt_set_dflt_rfs()
12327 dev->features &= ~NETIF_F_NTUPLE; in bnxt_set_dflt_rfs()
12328 bp->flags &= ~BNXT_FLAG_RFS; in bnxt_set_dflt_rfs()
12330 dev->hw_features |= NETIF_F_NTUPLE; in bnxt_set_dflt_rfs()
12332 bp->flags |= BNXT_FLAG_RFS; in bnxt_set_dflt_rfs()
12333 dev->features |= NETIF_F_NTUPLE; in bnxt_set_dflt_rfs()
12340 struct pci_dev *pdev = bp->pdev; in bnxt_fw_init_one_p3()
12346 if (bp->flags & BNXT_FLAG_WOL_CAP) in bnxt_fw_init_one_p3()
12347 device_set_wakeup_enable(&pdev->dev, bp->wol); in bnxt_fw_init_one_p3()
12349 device_set_wakeup_capable(&pdev->dev, false); in bnxt_fw_init_one_p3()
12363 netdev_err(bp->dev, "Firmware init phase 1 failed\n"); in bnxt_fw_init_one()
12368 netdev_err(bp->dev, "Firmware init phase 2 failed\n"); in bnxt_fw_init_one()
12374 rc = bnxt_approve_mac(bp, bp->dev->dev_addr, false); in bnxt_fw_init_one()
12384 struct bnxt_fw_health *fw_health = bp->fw_health; in bnxt_fw_reset_writel()
12385 u32 reg = fw_health->fw_reset_seq_regs[reg_idx]; in bnxt_fw_reset_writel()
12386 u32 val = fw_health->fw_reset_seq_vals[reg_idx]; in bnxt_fw_reset_writel()
12389 delay_msecs = fw_health->fw_reset_seq_delay_msec[reg_idx]; in bnxt_fw_reset_writel()
12394 pci_write_config_dword(bp->pdev, reg_off, val); in bnxt_fw_reset_writel()
12398 bp->bar0 + BNXT_GRCPF_REG_WINDOW_BASE_OUT + 4); in bnxt_fw_reset_writel()
12402 writel(val, bp->bar0 + reg_off); in bnxt_fw_reset_writel()
12405 writel(val, bp->bar1 + reg_off); in bnxt_fw_reset_writel()
12409 pci_read_config_dword(bp->pdev, 0, &val); in bnxt_fw_reset_writel()
12420 if (~bp->fw_cap & BNXT_FW_CAP_HOT_RESET_IF) in bnxt_hwrm_reset_permitted()
12426 req->fid = cpu_to_le16(0xffff); in bnxt_hwrm_reset_permitted()
12429 result = !!(le16_to_cpu(resp->flags) & in bnxt_hwrm_reset_permitted()
12437 struct bnxt_fw_health *fw_health = bp->fw_health; in bnxt_reset_all()
12440 if (bp->fw_cap & BNXT_FW_CAP_ERR_RECOVER_RELOAD) { in bnxt_reset_all()
12442 bp->fw_reset_timestamp = jiffies; in bnxt_reset_all()
12446 if (fw_health->flags & ERROR_RECOVERY_QCFG_RESP_FLAGS_HOST) { in bnxt_reset_all()
12447 for (i = 0; i < fw_health->fw_reset_seq_cnt; i++) in bnxt_reset_all()
12449 } else if (fw_health->flags & ERROR_RECOVERY_QCFG_RESP_FLAGS_CO_CPU) { in bnxt_reset_all()
12454 req->target_id = cpu_to_le16(HWRM_TARGET_ID_KONG); in bnxt_reset_all()
12455 req->embedded_proc_type = FW_RESET_REQ_EMBEDDED_PROC_TYPE_CHIP; in bnxt_reset_all()
12456 req->selfrst_status = FW_RESET_REQ_SELFRST_STATUS_SELFRSTASAP; in bnxt_reset_all()
12457 req->flags = FW_RESET_REQ_FLAGS_RESET_GRACEFUL; in bnxt_reset_all()
12460 if (rc != -ENODEV) in bnxt_reset_all()
12461 netdev_warn(bp->dev, "Unable to reset FW rc=%d\n", rc); in bnxt_reset_all()
12463 bp->fw_reset_timestamp = jiffies; in bnxt_reset_all()
12468 return time_after(jiffies, bp->fw_reset_timestamp + in bnxt_fw_reset_timeout()
12469 (bp->fw_reset_max_dsecs * HZ / 10)); in bnxt_fw_reset_timeout()
12474 clear_bit(BNXT_STATE_IN_FW_RESET, &bp->state); in bnxt_fw_reset_abort()
12475 if (bp->fw_reset_state != BNXT_FW_RESET_STATE_POLL_VF) { in bnxt_fw_reset_abort()
12479 bp->fw_reset_state = 0; in bnxt_fw_reset_abort()
12480 dev_close(bp->dev); in bnxt_fw_reset_abort()
12488 if (!test_bit(BNXT_STATE_IN_FW_RESET, &bp->state)) { in bnxt_fw_reset_task()
12489 netdev_err(bp->dev, "bnxt_fw_reset_task() called when not in fw reset mode!\n"); in bnxt_fw_reset_task()
12493 switch (bp->fw_reset_state) { in bnxt_fw_reset_task()
12499 …netdev_err(bp->dev, "Firmware reset aborted, subsequent func_qcfg cmd failed, rc = %d, %d msecs si… in bnxt_fw_reset_task()
12500 n, jiffies_to_msecs(jiffies - in bnxt_fw_reset_task()
12501 bp->fw_reset_timestamp)); in bnxt_fw_reset_task()
12505 clear_bit(BNXT_STATE_IN_FW_RESET, &bp->state); in bnxt_fw_reset_task()
12506 bp->fw_reset_state = 0; in bnxt_fw_reset_task()
12507 netdev_err(bp->dev, "Firmware reset aborted, bnxt_get_registered_vfs() returns %d\n", in bnxt_fw_reset_task()
12514 bp->fw_reset_timestamp = jiffies; in bnxt_fw_reset_task()
12516 if (test_bit(BNXT_STATE_ABORT_ERR, &bp->state)) { in bnxt_fw_reset_task()
12522 if (bp->fw_cap & BNXT_FW_CAP_ERR_RECOVER_RELOAD) { in bnxt_fw_reset_task()
12523 bp->fw_reset_state = BNXT_FW_RESET_STATE_POLL_FW_DOWN; in bnxt_fw_reset_task()
12526 bp->fw_reset_state = BNXT_FW_RESET_STATE_ENABLE_DEV; in bnxt_fw_reset_task()
12527 tmo = bp->fw_reset_min_dsecs * HZ / 10; in bnxt_fw_reset_task()
12543 if (!bp->fw_health->primary) { in bnxt_fw_reset_task()
12544 u32 wait_dsecs = bp->fw_health->normal_func_wait_dsecs; in bnxt_fw_reset_task()
12546 bp->fw_reset_state = BNXT_FW_RESET_STATE_ENABLE_DEV; in bnxt_fw_reset_task()
12550 bp->fw_reset_state = BNXT_FW_RESET_STATE_RESET_FW; in bnxt_fw_reset_task()
12555 bp->fw_reset_state = BNXT_FW_RESET_STATE_ENABLE_DEV; in bnxt_fw_reset_task()
12556 bnxt_queue_fw_reset_work(bp, bp->fw_reset_min_dsecs * HZ / 10); in bnxt_fw_reset_task()
12560 if (test_bit(BNXT_STATE_FW_FATAL_COND, &bp->state) && in bnxt_fw_reset_task()
12561 !bp->fw_reset_min_dsecs) { in bnxt_fw_reset_task()
12564 pci_read_config_word(bp->pdev, PCI_SUBSYSTEM_ID, &val); in bnxt_fw_reset_task()
12567 netdev_err(bp->dev, "Firmware reset aborted, PCI config space invalid\n"); in bnxt_fw_reset_task()
12568 rc = -ETIMEDOUT; in bnxt_fw_reset_task()
12575 clear_bit(BNXT_STATE_FW_FATAL_COND, &bp->state); in bnxt_fw_reset_task()
12576 clear_bit(BNXT_STATE_FW_NON_FATAL_COND, &bp->state); in bnxt_fw_reset_task()
12577 if (test_and_clear_bit(BNXT_STATE_FW_ACTIVATE_RESET, &bp->state) && in bnxt_fw_reset_task()
12578 !test_bit(BNXT_STATE_FW_ACTIVATE, &bp->state)) in bnxt_fw_reset_task()
12580 if (pci_enable_device(bp->pdev)) { in bnxt_fw_reset_task()
12581 netdev_err(bp->dev, "Cannot re-enable PCI device\n"); in bnxt_fw_reset_task()
12582 rc = -ENODEV; in bnxt_fw_reset_task()
12585 pci_set_master(bp->pdev); in bnxt_fw_reset_task()
12586 bp->fw_reset_state = BNXT_FW_RESET_STATE_POLL_FW; in bnxt_fw_reset_task()
12589 bp->hwrm_cmd_timeout = SHORT_HWRM_CMD_TIMEOUT; in bnxt_fw_reset_task()
12593 netdev_err(bp->dev, "Firmware reset aborted\n"); in bnxt_fw_reset_task()
12599 bp->hwrm_cmd_timeout = DFLT_HWRM_CMD_TIMEOUT; in bnxt_fw_reset_task()
12600 bp->fw_reset_state = BNXT_FW_RESET_STATE_OPENING; in bnxt_fw_reset_task()
12607 rc = bnxt_open(bp->dev); in bnxt_fw_reset_task()
12609 netdev_err(bp->dev, "bnxt_open() failed during FW reset\n"); in bnxt_fw_reset_task()
12615 if ((bp->fw_cap & BNXT_FW_CAP_ERROR_RECOVERY) && in bnxt_fw_reset_task()
12616 bp->fw_health->enabled) { in bnxt_fw_reset_task()
12617 bp->fw_health->last_fw_reset_cnt = in bnxt_fw_reset_task()
12620 bp->fw_reset_state = 0; in bnxt_fw_reset_task()
12623 clear_bit(BNXT_STATE_IN_FW_RESET, &bp->state); in bnxt_fw_reset_task()
12629 clear_bit(BNXT_STATE_FW_ACTIVATE, &bp->state); in bnxt_fw_reset_task()
12630 if (test_and_clear_bit(BNXT_STATE_RECOVER, &bp->state)) { in bnxt_fw_reset_task()
12640 if (bp->fw_health->status_reliable || in bnxt_fw_reset_task()
12641 (bp->fw_cap & BNXT_FW_CAP_ERROR_RECOVERY)) { in bnxt_fw_reset_task()
12644 netdev_err(bp->dev, "fw_health_status 0x%x\n", sts); in bnxt_fw_reset_task()
12657 SET_NETDEV_DEV(dev, &pdev->dev); in bnxt_init_board()
12659 /* enable device (incl. PCI PM wakeup), and bus-mastering */ in bnxt_init_board()
12662 dev_err(&pdev->dev, "Cannot enable PCI device, aborting\n"); in bnxt_init_board()
12667 dev_err(&pdev->dev, in bnxt_init_board()
12669 rc = -ENODEV; in bnxt_init_board()
12675 dev_err(&pdev->dev, "Cannot obtain PCI resources, aborting\n"); in bnxt_init_board()
12679 if (dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)) != 0 && in bnxt_init_board()
12680 dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32)) != 0) { in bnxt_init_board()
12681 dev_err(&pdev->dev, "System does not support DMA, aborting\n"); in bnxt_init_board()
12682 rc = -EIO; in bnxt_init_board()
12688 bp->dev = dev; in bnxt_init_board()
12689 bp->pdev = pdev; in bnxt_init_board()
12691 /* Doorbell BAR bp->bar1 is mapped after bnxt_fw_init_one_p2() in bnxt_init_board()
12694 bp->bar0 = pci_ioremap_bar(pdev, 0); in bnxt_init_board()
12695 if (!bp->bar0) { in bnxt_init_board()
12696 dev_err(&pdev->dev, "Cannot map device registers, aborting\n"); in bnxt_init_board()
12697 rc = -ENOMEM; in bnxt_init_board()
12701 bp->bar2 = pci_ioremap_bar(pdev, 4); in bnxt_init_board()
12702 if (!bp->bar2) { in bnxt_init_board()
12703 dev_err(&pdev->dev, "Cannot map bar4 registers, aborting\n"); in bnxt_init_board()
12704 rc = -ENOMEM; in bnxt_init_board()
12708 INIT_WORK(&bp->sp_task, bnxt_sp_task); in bnxt_init_board()
12709 INIT_DELAYED_WORK(&bp->fw_reset_task, bnxt_fw_reset_task); in bnxt_init_board()
12711 spin_lock_init(&bp->ntp_fltr_lock); in bnxt_init_board()
12713 spin_lock_init(&bp->db_lock); in bnxt_init_board()
12716 bp->rx_ring_size = BNXT_DEFAULT_RX_RING_SIZE; in bnxt_init_board()
12717 bp->tx_ring_size = BNXT_DEFAULT_TX_RING_SIZE; in bnxt_init_board()
12719 timer_setup(&bp->timer, bnxt_timer, 0); in bnxt_init_board()
12720 bp->current_interval = BNXT_TIMER_INTERVAL; in bnxt_init_board()
12722 bp->vxlan_fw_dst_port_id = INVALID_HW_RING_ID; in bnxt_init_board()
12723 bp->nge_fw_dst_port_id = INVALID_HW_RING_ID; in bnxt_init_board()
12725 clear_bit(BNXT_STATE_OPEN, &bp->state); in bnxt_init_board()
12746 if (!is_valid_ether_addr(addr->sa_data)) in bnxt_change_mac_addr()
12747 return -EADDRNOTAVAIL; in bnxt_change_mac_addr()
12749 if (ether_addr_equal(addr->sa_data, dev->dev_addr)) in bnxt_change_mac_addr()
12752 rc = bnxt_approve_mac(bp, addr->sa_data, true); in bnxt_change_mac_addr()
12756 eth_hw_addr_set(dev, addr->sa_data); in bnxt_change_mac_addr()
12773 dev->mtu = new_mtu; in bnxt_change_mtu()
12788 if (tc > bp->max_tc) { in bnxt_setup_mq_tc()
12790 tc, bp->max_tc); in bnxt_setup_mq_tc()
12791 return -EINVAL; in bnxt_setup_mq_tc()
12797 if (bp->flags & BNXT_FLAG_SHARED_RINGS) in bnxt_setup_mq_tc()
12800 rc = bnxt_check_rings(bp, bp->tx_nr_rings_per_tc, bp->rx_nr_rings, in bnxt_setup_mq_tc()
12801 sh, tc, bp->tx_nr_rings_xdp); in bnxt_setup_mq_tc()
12805 /* Needs to close the device and do hw resource re-allocations */ in bnxt_setup_mq_tc()
12806 if (netif_running(bp->dev)) in bnxt_setup_mq_tc()
12810 bp->tx_nr_rings = bp->tx_nr_rings_per_tc * tc; in bnxt_setup_mq_tc()
12813 bp->tx_nr_rings = bp->tx_nr_rings_per_tc; in bnxt_setup_mq_tc()
12816 bp->tx_nr_rings += bp->tx_nr_rings_xdp; in bnxt_setup_mq_tc()
12817 bp->cp_nr_rings = sh ? max_t(int, bp->tx_nr_rings, bp->rx_nr_rings) : in bnxt_setup_mq_tc()
12818 bp->tx_nr_rings + bp->rx_nr_rings; in bnxt_setup_mq_tc()
12820 if (netif_running(bp->dev)) in bnxt_setup_mq_tc()
12832 !tc_cls_can_offload_and_chain0(bp->dev, type_data)) in bnxt_setup_tc_block_cb()
12833 return -EOPNOTSUPP; in bnxt_setup_tc_block_cb()
12837 return bnxt_tc_setup_flower(bp, bp->pf.fw_fid, type_data); in bnxt_setup_tc_block_cb()
12839 return -EOPNOTSUPP; in bnxt_setup_tc_block_cb()
12859 mqprio->hw = TC_MQPRIO_HW_OFFLOAD_TCS; in bnxt_setup_tc()
12861 return bnxt_setup_mq_tc(dev, mqprio->num_tc); in bnxt_setup_tc()
12864 return -EOPNOTSUPP; in bnxt_setup_tc()
12872 struct flow_keys *keys1 = &f1->fkeys; in bnxt_fltr_match()
12873 struct flow_keys *keys2 = &f2->fkeys; in bnxt_fltr_match()
12875 if (keys1->basic.n_proto != keys2->basic.n_proto || in bnxt_fltr_match()
12876 keys1->basic.ip_proto != keys2->basic.ip_proto) in bnxt_fltr_match()
12879 if (keys1->basic.n_proto == htons(ETH_P_IP)) { in bnxt_fltr_match()
12880 if (keys1->addrs.v4addrs.src != keys2->addrs.v4addrs.src || in bnxt_fltr_match()
12881 keys1->addrs.v4addrs.dst != keys2->addrs.v4addrs.dst) in bnxt_fltr_match()
12884 if (memcmp(&keys1->addrs.v6addrs.src, &keys2->addrs.v6addrs.src, in bnxt_fltr_match()
12885 sizeof(keys1->addrs.v6addrs.src)) || in bnxt_fltr_match()
12886 memcmp(&keys1->addrs.v6addrs.dst, &keys2->addrs.v6addrs.dst, in bnxt_fltr_match()
12887 sizeof(keys1->addrs.v6addrs.dst))) in bnxt_fltr_match()
12891 if (keys1->ports.ports == keys2->ports.ports && in bnxt_fltr_match()
12892 keys1->control.flags == keys2->control.flags && in bnxt_fltr_match()
12893 ether_addr_equal(f1->src_mac_addr, f2->src_mac_addr) && in bnxt_fltr_match()
12894 ether_addr_equal(f1->dst_mac_addr, f2->dst_mac_addr)) in bnxt_fltr_match()
12911 if (!ether_addr_equal(dev->dev_addr, eth->h_dest)) { in bnxt_rx_flow_steer()
12912 struct bnxt_vnic_info *vnic = &bp->vnic_info[0]; in bnxt_rx_flow_steer()
12916 for (j = 0; j < vnic->uc_filter_count; j++, off += ETH_ALEN) { in bnxt_rx_flow_steer()
12917 if (ether_addr_equal(eth->h_dest, in bnxt_rx_flow_steer()
12918 vnic->uc_list + off)) { in bnxt_rx_flow_steer()
12925 return -EINVAL; in bnxt_rx_flow_steer()
12929 return -ENOMEM; in bnxt_rx_flow_steer()
12931 fkeys = &new_fltr->fkeys; in bnxt_rx_flow_steer()
12933 rc = -EPROTONOSUPPORT; in bnxt_rx_flow_steer()
12937 if ((fkeys->basic.n_proto != htons(ETH_P_IP) && in bnxt_rx_flow_steer()
12938 fkeys->basic.n_proto != htons(ETH_P_IPV6)) || in bnxt_rx_flow_steer()
12939 ((fkeys->basic.ip_proto != IPPROTO_TCP) && in bnxt_rx_flow_steer()
12940 (fkeys->basic.ip_proto != IPPROTO_UDP))) { in bnxt_rx_flow_steer()
12941 rc = -EPROTONOSUPPORT; in bnxt_rx_flow_steer()
12944 if (fkeys->basic.n_proto == htons(ETH_P_IPV6) && in bnxt_rx_flow_steer()
12945 bp->hwrm_spec_code < 0x10601) { in bnxt_rx_flow_steer()
12946 rc = -EPROTONOSUPPORT; in bnxt_rx_flow_steer()
12949 flags = fkeys->control.flags; in bnxt_rx_flow_steer()
12951 bp->hwrm_spec_code < 0x10601) || (flags & FLOW_DIS_IS_FRAGMENT)) { in bnxt_rx_flow_steer()
12952 rc = -EPROTONOSUPPORT; in bnxt_rx_flow_steer()
12956 memcpy(new_fltr->dst_mac_addr, eth->h_dest, ETH_ALEN); in bnxt_rx_flow_steer()
12957 memcpy(new_fltr->src_mac_addr, eth->h_source, ETH_ALEN); in bnxt_rx_flow_steer()
12960 head = &bp->ntp_fltr_hash_tbl[idx]; in bnxt_rx_flow_steer()
12964 rc = fltr->sw_id; in bnxt_rx_flow_steer()
12971 spin_lock_bh(&bp->ntp_fltr_lock); in bnxt_rx_flow_steer()
12972 bit_id = bitmap_find_free_region(bp->ntp_fltr_bmap, in bnxt_rx_flow_steer()
12975 spin_unlock_bh(&bp->ntp_fltr_lock); in bnxt_rx_flow_steer()
12976 rc = -ENOMEM; in bnxt_rx_flow_steer()
12980 new_fltr->sw_id = (u16)bit_id; in bnxt_rx_flow_steer()
12981 new_fltr->flow_id = flow_id; in bnxt_rx_flow_steer()
12982 new_fltr->l2_fltr_idx = l2_idx; in bnxt_rx_flow_steer()
12983 new_fltr->rxq = rxq_index; in bnxt_rx_flow_steer()
12984 hlist_add_head_rcu(&new_fltr->hash, head); in bnxt_rx_flow_steer()
12985 bp->ntp_fltr_count++; in bnxt_rx_flow_steer()
12986 spin_unlock_bh(&bp->ntp_fltr_lock); in bnxt_rx_flow_steer()
12990 return new_fltr->sw_id; in bnxt_rx_flow_steer()
13007 head = &bp->ntp_fltr_hash_tbl[i]; in bnxt_cfg_ntp_filters()
13011 if (test_bit(BNXT_FLTR_VALID, &fltr->state)) { in bnxt_cfg_ntp_filters()
13012 if (rps_may_expire_flow(bp->dev, fltr->rxq, in bnxt_cfg_ntp_filters()
13013 fltr->flow_id, in bnxt_cfg_ntp_filters()
13014 fltr->sw_id)) { in bnxt_cfg_ntp_filters()
13025 set_bit(BNXT_FLTR_VALID, &fltr->state); in bnxt_cfg_ntp_filters()
13029 spin_lock_bh(&bp->ntp_fltr_lock); in bnxt_cfg_ntp_filters()
13030 hlist_del_rcu(&fltr->hash); in bnxt_cfg_ntp_filters()
13031 bp->ntp_fltr_count--; in bnxt_cfg_ntp_filters()
13032 spin_unlock_bh(&bp->ntp_fltr_lock); in bnxt_cfg_ntp_filters()
13034 clear_bit(fltr->sw_id, bp->ntp_fltr_bmap); in bnxt_cfg_ntp_filters()
13039 if (test_and_clear_bit(BNXT_HWRM_PF_UNLOAD_SP_EVENT, &bp->sp_event)) in bnxt_cfg_ntp_filters()
13040 netdev_info(bp->dev, "Receive PF driver unload event!\n"); in bnxt_cfg_ntp_filters()
13057 if (ti->type == UDP_TUNNEL_TYPE_VXLAN) in bnxt_udp_tunnel_set_port()
13062 return bnxt_hwrm_tunnel_dst_port_alloc(bp, ti->port, cmd); in bnxt_udp_tunnel_set_port()
13071 if (ti->type == UDP_TUNNEL_TYPE_VXLAN) in bnxt_udp_tunnel_unset_port()
13096 return ndo_dflt_bridge_getlink(skb, pid, seq, dev, bp->br_mode, 0, 0, in bnxt_bridge_getlink()
13107 if (bp->hwrm_spec_code < 0x10708 || !BNXT_SINGLE_PF(bp)) in bnxt_bridge_setlink()
13108 return -EOPNOTSUPP; in bnxt_bridge_setlink()
13112 return -EINVAL; in bnxt_bridge_setlink()
13121 if (mode == bp->br_mode) in bnxt_bridge_setlink()
13126 bp->br_mode = mode; in bnxt_bridge_setlink()
13137 if (bp->eswitch_mode != DEVLINK_ESWITCH_MODE_SWITCHDEV) in bnxt_get_port_parent_id()
13138 return -EOPNOTSUPP; in bnxt_get_port_parent_id()
13140 /* The PF and it's VF-reps only support the switchdev framework */ in bnxt_get_port_parent_id()
13141 if (!BNXT_PF(bp) || !(bp->flags & BNXT_FLAG_DSN_VALID)) in bnxt_get_port_parent_id()
13142 return -EOPNOTSUPP; in bnxt_get_port_parent_id()
13144 ppid->id_len = sizeof(bp->dsn); in bnxt_get_port_parent_id()
13145 memcpy(ppid->id, bp->dsn, ppid->id_len); in bnxt_get_port_parent_id()
13195 clear_bit(BNXT_STATE_IN_FW_RESET, &bp->state); in bnxt_remove_one()
13197 cancel_work_sync(&bp->sp_task); in bnxt_remove_one()
13198 cancel_delayed_work_sync(&bp->fw_reset_task); in bnxt_remove_one()
13199 bp->sp_event = 0; in bnxt_remove_one()
13210 kfree(bp->ptp_cfg); in bnxt_remove_one()
13211 bp->ptp_cfg = NULL; in bnxt_remove_one()
13212 kfree(bp->fw_health); in bnxt_remove_one()
13213 bp->fw_health = NULL; in bnxt_remove_one()
13216 kfree(bp->ctx); in bnxt_remove_one()
13217 bp->ctx = NULL; in bnxt_remove_one()
13218 kfree(bp->rss_indir_tbl); in bnxt_remove_one()
13219 bp->rss_indir_tbl = NULL; in bnxt_remove_one()
13227 struct bnxt_link_info *link_info = &bp->link_info; in bnxt_probe_phy()
13229 bp->phy_flags = 0; in bnxt_probe_phy()
13232 netdev_err(bp->dev, "Probe phy can't get phy capabilities (rc: %x)\n", in bnxt_probe_phy()
13236 if (bp->phy_flags & BNXT_PHY_FL_NO_FCS) in bnxt_probe_phy()
13237 bp->dev->priv_flags |= IFF_SUPP_NOFCS; in bnxt_probe_phy()
13239 bp->dev->priv_flags &= ~IFF_SUPP_NOFCS; in bnxt_probe_phy()
13243 mutex_lock(&bp->link_lock); in bnxt_probe_phy()
13246 mutex_unlock(&bp->link_lock); in bnxt_probe_phy()
13247 netdev_err(bp->dev, "Probe phy can't update link (rc: %x)\n", in bnxt_probe_phy()
13255 if (link_info->auto_link_speeds && !link_info->support_auto_speeds) in bnxt_probe_phy()
13256 link_info->support_auto_speeds = link_info->support_speeds; in bnxt_probe_phy()
13259 mutex_unlock(&bp->link_lock); in bnxt_probe_phy()
13267 if (!pdev->msix_cap) in bnxt_get_max_irq()
13270 pci_read_config_word(pdev, pdev->msix_cap + PCI_MSIX_FLAGS, &ctrl); in bnxt_get_max_irq()
13277 struct bnxt_hw_resc *hw_resc = &bp->hw_resc; in _bnxt_get_max_rings()
13280 *max_tx = hw_resc->max_tx_rings; in _bnxt_get_max_rings()
13281 *max_rx = hw_resc->max_rx_rings; in _bnxt_get_max_rings()
13283 max_irq = min_t(int, bnxt_get_max_func_irqs(bp) - in _bnxt_get_max_rings()
13285 hw_resc->max_stat_ctxs - bnxt_get_ulp_stat_ctxs(bp)); in _bnxt_get_max_rings()
13286 if (!(bp->flags & BNXT_FLAG_CHIP_P5)) in _bnxt_get_max_rings()
13288 max_ring_grps = hw_resc->max_hw_ring_grps; in _bnxt_get_max_rings()
13290 *max_cp -= 1; in _bnxt_get_max_rings()
13291 *max_rx -= 2; in _bnxt_get_max_rings()
13293 if (bp->flags & BNXT_FLAG_AGG_RINGS) in _bnxt_get_max_rings()
13295 if (bp->flags & BNXT_FLAG_CHIP_P5) { in _bnxt_get_max_rings()
13311 return -ENOMEM; in bnxt_get_max_rings()
13322 if (rc && (bp->flags & BNXT_FLAG_AGG_RINGS)) { in bnxt_get_dflt_rings()
13324 bp->flags &= ~BNXT_FLAG_AGG_RINGS; in bnxt_get_dflt_rings()
13328 bp->flags |= BNXT_FLAG_AGG_RINGS; in bnxt_get_dflt_rings()
13331 bp->flags |= BNXT_FLAG_NO_AGG_RINGS; in bnxt_get_dflt_rings()
13332 bp->dev->hw_features &= ~(NETIF_F_LRO | NETIF_F_GRO_HW); in bnxt_get_dflt_rings()
13333 bp->dev->features &= ~(NETIF_F_LRO | NETIF_F_GRO_HW); in bnxt_get_dflt_rings()
13337 if (bp->flags & BNXT_FLAG_ROCE_CAP) { in bnxt_get_dflt_rings()
13349 max_cp -= BNXT_MIN_ROCE_CP_RINGS; in bnxt_get_dflt_rings()
13350 max_irq -= BNXT_MIN_ROCE_CP_RINGS; in bnxt_get_dflt_rings()
13351 max_stat -= BNXT_MIN_ROCE_STAT_CTXS; in bnxt_get_dflt_rings()
13366 bp->cp_nr_rings = min_t(int, bp->tx_nr_rings_per_tc, bp->rx_nr_rings); in bnxt_trim_dflt_sh_rings()
13367 bp->rx_nr_rings = bp->cp_nr_rings; in bnxt_trim_dflt_sh_rings()
13368 bp->tx_nr_rings_per_tc = bp->cp_nr_rings; in bnxt_trim_dflt_sh_rings()
13369 bp->tx_nr_rings = bp->tx_nr_rings_per_tc; in bnxt_trim_dflt_sh_rings()
13380 bp->flags |= BNXT_FLAG_SHARED_RINGS; in bnxt_set_dflt_rings()
13382 /* Reduce default rings on multi-port cards so that total default in bnxt_set_dflt_rings()
13385 if (bp->port_count > 1) { in bnxt_set_dflt_rings()
13387 max_t(int, num_online_cpus() / bp->port_count, 1); in bnxt_set_dflt_rings()
13394 bp->rx_nr_rings = min_t(int, dflt_rings, max_rx_rings); in bnxt_set_dflt_rings()
13395 bp->tx_nr_rings_per_tc = min_t(int, dflt_rings, max_tx_rings); in bnxt_set_dflt_rings()
13399 bp->cp_nr_rings = bp->tx_nr_rings_per_tc + bp->rx_nr_rings; in bnxt_set_dflt_rings()
13400 bp->tx_nr_rings = bp->tx_nr_rings_per_tc; in bnxt_set_dflt_rings()
13403 if (rc && rc != -ENODEV) in bnxt_set_dflt_rings()
13404 netdev_warn(bp->dev, "Unable to reserve tx rings\n"); in bnxt_set_dflt_rings()
13405 bp->tx_nr_rings_per_tc = bp->tx_nr_rings; in bnxt_set_dflt_rings()
13409 /* Rings may have been trimmed, re-reserve the trimmed rings. */ in bnxt_set_dflt_rings()
13412 if (rc && rc != -ENODEV) in bnxt_set_dflt_rings()
13413 netdev_warn(bp->dev, "2nd rings reservation failed.\n"); in bnxt_set_dflt_rings()
13414 bp->tx_nr_rings_per_tc = bp->tx_nr_rings; in bnxt_set_dflt_rings()
13417 bp->rx_nr_rings++; in bnxt_set_dflt_rings()
13418 bp->cp_nr_rings++; in bnxt_set_dflt_rings()
13421 bp->tx_nr_rings = 0; in bnxt_set_dflt_rings()
13422 bp->rx_nr_rings = 0; in bnxt_set_dflt_rings()
13431 if (bp->tx_nr_rings) in bnxt_init_dflt_ring_mode()
13438 if (BNXT_VF(bp) && rc == -ENODEV) in bnxt_init_dflt_ring_mode()
13439 netdev_err(bp->dev, "Cannot configure VF rings while PF is unavailable.\n"); in bnxt_init_dflt_ring_mode()
13441 netdev_err(bp->dev, "Not enough rings available.\n"); in bnxt_init_dflt_ring_mode()
13448 bp->tx_nr_rings_per_tc = bp->tx_nr_rings; in bnxt_init_dflt_ring_mode()
13464 if (netif_running(bp->dev)) in bnxt_restore_pf_fw_resources()
13472 if (netif_running(bp->dev)) { in bnxt_restore_pf_fw_resources()
13474 dev_close(bp->dev); in bnxt_restore_pf_fw_resources()
13487 eth_hw_addr_set(bp->dev, bp->pf.mac_addr); in bnxt_init_mac_addr()
13490 struct bnxt_vf_info *vf = &bp->vf; in bnxt_init_mac_addr()
13493 if (is_valid_ether_addr(vf->mac_addr)) { in bnxt_init_mac_addr()
13495 eth_hw_addr_set(bp->dev, vf->mac_addr); in bnxt_init_mac_addr()
13501 eth_hw_addr_random(bp->dev); in bnxt_init_mac_addr()
13503 rc = bnxt_approve_mac(bp, bp->dev->dev_addr, strict_approval); in bnxt_init_mac_addr()
13511 struct pci_dev *pdev = bp->pdev; in bnxt_vpd_read_info()
13527 size = min_t(int, kw_len, BNXT_VPD_FLD_LEN - 1); in bnxt_vpd_read_info()
13528 memcpy(bp->board_partno, &vpd_data[pos], size); in bnxt_vpd_read_info()
13537 size = min_t(int, kw_len, BNXT_VPD_FLD_LEN - 1); in bnxt_vpd_read_info()
13538 memcpy(bp->board_serialno, &vpd_data[pos], size); in bnxt_vpd_read_info()
13545 struct pci_dev *pdev = bp->pdev; in bnxt_pcie_dsn_get()
13550 netdev_info(bp->dev, "Unable to read adapter's DSN\n"); in bnxt_pcie_dsn_get()
13551 return -EOPNOTSUPP; in bnxt_pcie_dsn_get()
13556 bp->flags |= BNXT_FLAG_DSN_VALID; in bnxt_pcie_dsn_get()
13562 if (!bp->db_size) in bnxt_map_db_bar()
13563 return -ENODEV; in bnxt_map_db_bar()
13564 bp->bar1 = pci_iomap(bp->pdev, 2, bp->db_size); in bnxt_map_db_bar()
13565 if (!bp->bar1) in bnxt_map_db_bar()
13566 return -ENOMEM; in bnxt_map_db_bar()
13572 netdev_info(bp->dev, "%s found at mem %lx, node addr %pM\n", in bnxt_print_device_info()
13573 board_info[bp->board_idx].name, in bnxt_print_device_info()
13574 (long)pci_resource_start(bp->pdev, 0), bp->dev->dev_addr); in bnxt_print_device_info()
13576 pcie_print_link_status(bp->pdev); in bnxt_print_device_info()
13586 return -ENODEV; in bnxt_init_one()
13599 return -ENOMEM; in bnxt_init_one()
13602 bp->board_idx = ent->driver_data; in bnxt_init_one()
13603 bp->msg_enable = BNXT_DEF_MSG_ENABLE; in bnxt_init_one()
13606 if (bnxt_vf_pciid(bp->board_idx)) in bnxt_init_one()
13607 bp->flags |= BNXT_FLAG_VF; in bnxt_init_one()
13611 SET_NETDEV_DEVLINK_PORT(dev, &bp->dl_port); in bnxt_init_one()
13613 if (pdev->msix_cap) in bnxt_init_one()
13614 bp->flags |= BNXT_FLAG_MSIX_CAP; in bnxt_init_one()
13620 dev->netdev_ops = &bnxt_netdev_ops; in bnxt_init_one()
13621 dev->watchdog_timeo = BNXT_TX_TIMEOUT; in bnxt_init_one()
13622 dev->ethtool_ops = &bnxt_ethtool_ops; in bnxt_init_one()
13629 mutex_init(&bp->hwrm_cmd_lock); in bnxt_init_one()
13630 mutex_init(&bp->link_lock); in bnxt_init_one()
13640 bp->flags |= BNXT_FLAG_CHIP_P5; in bnxt_init_one()
13642 bp->flags |= BNXT_FLAG_CHIP_SR2; in bnxt_init_one()
13655 dev_err(&pdev->dev, "Cannot map doorbell BAR rc = %d, aborting\n", in bnxt_init_one()
13660 dev->hw_features = NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM | NETIF_F_SG | in bnxt_init_one()
13669 dev->hw_features |= NETIF_F_LRO; in bnxt_init_one()
13671 dev->hw_enc_features = in bnxt_init_one()
13677 dev->udp_tunnel_nic_info = &bnxt_udp_tunnels; in bnxt_init_one()
13679 dev->gso_partial_features = NETIF_F_GSO_UDP_TUNNEL_CSUM | in bnxt_init_one()
13681 dev->vlan_features = dev->hw_features | NETIF_F_HIGHDMA; in bnxt_init_one()
13682 if (bp->fw_cap & BNXT_FW_CAP_VLAN_RX_STRIP) in bnxt_init_one()
13683 dev->hw_features |= BNXT_HW_FEATURE_VLAN_ALL_RX; in bnxt_init_one()
13684 if (bp->fw_cap & BNXT_FW_CAP_VLAN_TX_INSERT) in bnxt_init_one()
13685 dev->hw_features |= BNXT_HW_FEATURE_VLAN_ALL_TX; in bnxt_init_one()
13687 dev->hw_features |= NETIF_F_GRO_HW; in bnxt_init_one()
13688 dev->features |= dev->hw_features | NETIF_F_HIGHDMA; in bnxt_init_one()
13689 if (dev->features & NETIF_F_GRO_HW) in bnxt_init_one()
13690 dev->features &= ~NETIF_F_LRO; in bnxt_init_one()
13691 dev->priv_flags |= IFF_UNICAST_FLT; in bnxt_init_one()
13695 dev->xdp_features = NETDEV_XDP_ACT_BASIC | NETDEV_XDP_ACT_REDIRECT | in bnxt_init_one()
13699 init_waitqueue_head(&bp->sriov_cfg_wait); in bnxt_init_one()
13702 bp->gro_func = bnxt_gro_func_5730x; in bnxt_init_one()
13704 bp->gro_func = bnxt_gro_func_5731x; in bnxt_init_one()
13706 bp->gro_func = bnxt_gro_func_5750x; in bnxt_init_one()
13709 bp->flags |= BNXT_FLAG_DOUBLE_DB; in bnxt_init_one()
13713 dev_err(&pdev->dev, "Unable to initialize mac address.\n"); in bnxt_init_one()
13714 rc = -EADDRNOTAVAIL; in bnxt_init_one()
13720 rc = bnxt_pcie_dsn_get(bp, bp->dsn); in bnxt_init_one()
13723 /* MTU range: 60 - FW defined max */ in bnxt_init_one()
13724 dev->min_mtu = ETH_ZLEN; in bnxt_init_one()
13725 dev->max_mtu = bp->max_mtu; in bnxt_init_one()
13736 if (BNXT_VF(bp) && rc == -ENODEV) { in bnxt_init_one()
13737 netdev_err(bp->dev, "Cannot configure VF rings while PF is unavailable.\n"); in bnxt_init_one()
13739 netdev_err(bp->dev, "Not enough rings available.\n"); in bnxt_init_one()
13740 rc = -ENOMEM; in bnxt_init_one()
13749 if (dev->hw_features & BNXT_HW_FEATURE_VLAN_ALL_RX) in bnxt_init_one()
13750 bp->flags |= BNXT_FLAG_STRIP_VLAN; in bnxt_init_one()
13757 * limited MSIX, so we re-initialize the TX rings per TC. in bnxt_init_one()
13759 bp->tx_nr_rings_per_tc = bp->tx_nr_rings; in bnxt_init_one()
13766 dev_err(&pdev->dev, "Unable to create workqueue.\n"); in bnxt_init_one()
13767 rc = -ENOMEM; in bnxt_init_one()
13806 kfree(bp->ptp_cfg); in bnxt_init_one()
13807 bp->ptp_cfg = NULL; in bnxt_init_one()
13808 kfree(bp->fw_health); in bnxt_init_one()
13809 bp->fw_health = NULL; in bnxt_init_one()
13812 kfree(bp->ctx); in bnxt_init_one()
13813 bp->ctx = NULL; in bnxt_init_one()
13814 kfree(bp->rss_indir_tbl); in bnxt_init_one()
13815 bp->rss_indir_tbl = NULL; in bnxt_init_one()
13842 pci_wake_from_d3(pdev, bp->wol); in bnxt_shutdown()
13864 pci_disable_device(bp->pdev); in bnxt_suspend()
13866 kfree(bp->ctx); in bnxt_suspend()
13867 bp->ctx = NULL; in bnxt_suspend()
13879 rc = pci_enable_device(bp->pdev); in bnxt_resume()
13881 netdev_err(dev, "Cannot re-enable PCI device during resume, err = %d\n", in bnxt_resume()
13885 pci_set_master(bp->pdev); in bnxt_resume()
13887 rc = -ENODEV; in bnxt_resume()
13892 rc = -EBUSY; in bnxt_resume()
13901 rc = -ENODEV; in bnxt_resume()
13930 * bnxt_io_error_detected - called when PCI error is detected
13956 set_bit(BNXT_STATE_PCI_CHANNEL_IO_FROZEN, &bp->state); in bnxt_io_error_detected()
13964 kfree(bp->ctx); in bnxt_io_error_detected()
13965 bp->ctx = NULL; in bnxt_io_error_detected()
13973 * bnxt_io_slot_reset - called after the pci bus has been reset.
13976 * Restart the card from scratch, as if from a cold-boot.
13990 netdev_info(bp->dev, "PCI Slot Reset\n"); in bnxt_io_slot_reset()
13995 dev_err(&pdev->dev, in bnxt_io_slot_reset()
13996 "Cannot re-enable PCI device after reset.\n"); in bnxt_io_slot_reset()
14003 * As pci_restore_state() does not re-write the BARs if the in bnxt_io_slot_reset()
14008 &bp->state)) { in bnxt_io_slot_reset()
14011 pci_write_config_dword(bp->pdev, off, 0); in bnxt_io_slot_reset()
14030 dev_err(&pdev->dev, "Firmware not ready\n"); in bnxt_io_slot_reset()
14052 * bnxt_io_resume - called when traffic can start flowing again.
14064 netdev_info(bp->dev, "PCI Slot Resume\n"); in bnxt_io_resume()