@@ -783,15 +783,15 @@ static netdev_tx_t bnxt_start_xmit(struct sk_buff *skb, struct net_device *dev)
783783 dev_kfree_skb_any (skb );
784784tx_kick_pending :
785785 if (BNXT_TX_PTP_IS_SET (lflags )) {
786- txr -> tx_buf_ring [txr -> tx_prod ].is_ts_pkt = 0 ;
786+ txr -> tx_buf_ring [RING_TX ( bp , txr -> tx_prod ) ].is_ts_pkt = 0 ;
787787 atomic64_inc (& bp -> ptp_cfg -> stats .ts_err );
788788 if (!(bp -> fw_cap & BNXT_FW_CAP_TX_TS_CMP ))
789789 /* set SKB to err so PTP worker will clean up */
790790 ptp -> txts_req [txts_prod ].tx_skb = ERR_PTR (- EIO );
791791 }
792792 if (txr -> kick_pending )
793793 bnxt_txr_db_kick (bp , txr , txr -> tx_prod );
794- txr -> tx_buf_ring [txr -> tx_prod ].skb = NULL ;
794+ txr -> tx_buf_ring [RING_TX ( bp , txr -> tx_prod ) ].skb = NULL ;
795795 dev_core_stats_tx_dropped_inc (dev );
796796 return NETDEV_TX_OK ;
797797}
@@ -2050,6 +2050,7 @@ static int bnxt_rx_pkt(struct bnxt *bp, struct bnxt_cp_ring_info *cpr,
20502050 struct rx_cmp_ext * rxcmp1 ;
20512051 u32 tmp_raw_cons = * raw_cons ;
20522052 u16 cons , prod , cp_cons = RING_CMP (tmp_raw_cons );
2053+ struct skb_shared_info * sinfo ;
20532054 struct bnxt_sw_rx_bd * rx_buf ;
20542055 unsigned int len ;
20552056 u8 * data_ptr , agg_bufs , cmp_type ;
@@ -2176,6 +2177,7 @@ static int bnxt_rx_pkt(struct bnxt *bp, struct bnxt_cp_ring_info *cpr,
21762177 false);
21772178 if (!frag_len )
21782179 goto oom_next_rx ;
2180+
21792181 }
21802182 xdp_active = true;
21812183 }
@@ -2185,6 +2187,12 @@ static int bnxt_rx_pkt(struct bnxt *bp, struct bnxt_cp_ring_info *cpr,
21852187 rc = 1 ;
21862188 goto next_rx ;
21872189 }
2190+ if (xdp_buff_has_frags (& xdp )) {
2191+ sinfo = xdp_get_shared_info_from_buff (& xdp );
2192+ agg_bufs = sinfo -> nr_frags ;
2193+ } else {
2194+ agg_bufs = 0 ;
2195+ }
21882196 }
21892197
21902198 if (len <= bp -> rx_copybreak ) {
@@ -2222,7 +2230,8 @@ static int bnxt_rx_pkt(struct bnxt *bp, struct bnxt_cp_ring_info *cpr,
22222230 if (!skb )
22232231 goto oom_next_rx ;
22242232 } else {
2225- skb = bnxt_xdp_build_skb (bp , skb , agg_bufs , rxr -> page_pool , & xdp , rxcmp1 );
2233+ skb = bnxt_xdp_build_skb (bp , skb , agg_bufs ,
2234+ rxr -> page_pool , & xdp );
22262235 if (!skb ) {
22272236 /* we should be able to free the old skb here */
22282237 bnxt_xdp_buff_frags_free (rxr , & xdp );
@@ -4632,8 +4641,13 @@ void bnxt_set_tpa_flags(struct bnxt *bp)
46324641
46334642static void bnxt_init_ring_params (struct bnxt * bp )
46344643{
4644+ unsigned int rx_size ;
4645+
46354646 bp -> rx_copybreak = BNXT_DEFAULT_RX_COPYBREAK ;
4636- bp -> dev -> cfg -> hds_thresh = BNXT_DEFAULT_RX_COPYBREAK ;
4647+ /* Try to fit 4 chunks into a 4k page */
4648+ rx_size = SZ_1K -
4649+ NET_SKB_PAD - SKB_DATA_ALIGN (sizeof (struct skb_shared_info ));
4650+ bp -> dev -> cfg -> hds_thresh = max (BNXT_DEFAULT_RX_COPYBREAK , rx_size );
46374651}
46384652
46394653/* bp->rx_ring_size, bp->tx_ring_size, dev->mtu, BNXT_FLAG_{G|L}RO flags must
@@ -4738,7 +4752,7 @@ void bnxt_set_ring_params(struct bnxt *bp)
47384752/* Changing allocation mode of RX rings.
47394753 * TODO: Update when extending xdp_rxq_info to support allocation modes.
47404754 */
4741- int bnxt_set_rx_skb_mode (struct bnxt * bp , bool page_mode )
4755+ static void __bnxt_set_rx_skb_mode (struct bnxt * bp , bool page_mode )
47424756{
47434757 struct net_device * dev = bp -> dev ;
47444758
@@ -4759,15 +4773,30 @@ int bnxt_set_rx_skb_mode(struct bnxt *bp, bool page_mode)
47594773 bp -> rx_skb_func = bnxt_rx_page_skb ;
47604774 }
47614775 bp -> rx_dir = DMA_BIDIRECTIONAL ;
4762- /* Disable LRO or GRO_HW */
4763- netdev_update_features (dev );
47644776 } else {
47654777 dev -> max_mtu = bp -> max_mtu ;
47664778 bp -> flags &= ~BNXT_FLAG_RX_PAGE_MODE ;
47674779 bp -> rx_dir = DMA_FROM_DEVICE ;
47684780 bp -> rx_skb_func = bnxt_rx_skb ;
47694781 }
4770- return 0 ;
4782+ }
4783+
4784+ void bnxt_set_rx_skb_mode (struct bnxt * bp , bool page_mode )
4785+ {
4786+ __bnxt_set_rx_skb_mode (bp , page_mode );
4787+
4788+ if (!page_mode ) {
4789+ int rx , tx ;
4790+
4791+ bnxt_get_max_rings (bp , & rx , & tx , true);
4792+ if (rx > 1 ) {
4793+ bp -> flags &= ~BNXT_FLAG_NO_AGG_RINGS ;
4794+ bp -> dev -> hw_features |= NETIF_F_LRO ;
4795+ }
4796+ }
4797+
4798+ /* Update LRO and GRO_HW availability */
4799+ netdev_update_features (bp -> dev );
47714800}
47724801
47734802static void bnxt_free_vnic_attributes (struct bnxt * bp )
@@ -12192,12 +12221,15 @@ static int bnxt_hwrm_if_change(struct bnxt *bp, bool up)
1219212221{
1219312222 struct hwrm_func_drv_if_change_output * resp ;
1219412223 struct hwrm_func_drv_if_change_input * req ;
12195- bool fw_reset = !bp -> irq_tbl ;
1219612224 bool resc_reinit = false;
1219712225 bool caps_change = false;
1219812226 int rc , retry = 0 ;
12227+ bool fw_reset ;
1219912228 u32 flags = 0 ;
1220012229
12230+ fw_reset = (bp -> fw_reset_state == BNXT_FW_RESET_STATE_ABORT );
12231+ bp -> fw_reset_state = 0 ;
12232+
1220112233 if (!(bp -> fw_cap & BNXT_FW_CAP_IF_CHANGE ))
1220212234 return 0 ;
1220312235
@@ -12826,7 +12858,7 @@ static void __bnxt_close_nic(struct bnxt *bp, bool irq_re_init,
1282612858
1282712859 bnxt_debug_dev_exit (bp );
1282812860 bnxt_disable_napi (bp );
12829- del_timer_sync (& bp -> timer );
12861+ timer_delete_sync (& bp -> timer );
1283012862 bnxt_free_skbs (bp );
1283112863
1283212864 /* Save ring stats before shutdown */
@@ -13385,7 +13417,7 @@ static netdev_features_t bnxt_fix_features(struct net_device *dev,
1338513417 if (features & NETIF_F_GRO_HW )
1338613418 features &= ~NETIF_F_LRO ;
1338713419
13388- /* Both CTAG and STAG VLAN accelaration on the RX side have to be
13420+ /* Both CTAG and STAG VLAN acceleration on the RX side have to be
1338913421 * turned on or off together.
1339013422 */
1339113423 vlan_features = features & BNXT_HW_FEATURE_VLAN_ALL_RX ;
@@ -14699,7 +14731,7 @@ static void bnxt_fw_reset_abort(struct bnxt *bp, int rc)
1469914731 clear_bit (BNXT_STATE_IN_FW_RESET , & bp -> state );
1470014732 if (bp -> fw_reset_state != BNXT_FW_RESET_STATE_POLL_VF )
1470114733 bnxt_dl_health_fw_status_update (bp , false);
14702- bp -> fw_reset_state = 0 ;
14734+ bp -> fw_reset_state = BNXT_FW_RESET_STATE_ABORT ;
1470314735 dev_close (bp -> dev );
1470414736}
1470514737
@@ -15489,6 +15521,9 @@ static void bnxt_get_queue_stats_rx(struct net_device *dev, int i,
1548915521 struct bnxt_cp_ring_info * cpr ;
1549015522 u64 * sw ;
1549115523
15524+ if (!bp -> bnapi )
15525+ return ;
15526+
1549215527 cpr = & bp -> bnapi [i ]-> cp_ring ;
1549315528 sw = cpr -> stats .sw_stats ;
1549415529
@@ -15512,6 +15547,9 @@ static void bnxt_get_queue_stats_tx(struct net_device *dev, int i,
1551215547 struct bnxt_napi * bnapi ;
1551315548 u64 * sw ;
1551415549
15550+ if (!bp -> tx_ring )
15551+ return ;
15552+
1551515553 bnapi = bp -> tx_ring [bp -> tx_ring_map [i ]].bnapi ;
1551615554 sw = bnapi -> cp_ring .stats .sw_stats ;
1551715555
@@ -15553,6 +15591,9 @@ static int bnxt_queue_mem_alloc(struct net_device *dev, void *qmem, int idx)
1555315591 struct bnxt_ring_struct * ring ;
1555415592 int rc ;
1555515593
15594+ if (!bp -> rx_ring )
15595+ return - ENETDOWN ;
15596+
1555615597 rxr = & bp -> rx_ring [idx ];
1555715598 clone = qmem ;
1555815599 memcpy (clone , rxr , sizeof (* rxr ));
@@ -15635,6 +15676,7 @@ static void bnxt_queue_mem_free(struct net_device *dev, void *qmem)
1563515676 struct bnxt_ring_struct * ring ;
1563615677
1563715678 bnxt_free_one_rx_ring_skbs (bp , rxr );
15679+ bnxt_free_one_tpa_info (bp , rxr );
1563815680
1563915681 xdp_rxq_info_unreg (& rxr -> xdp_rxq );
1564015682
@@ -15766,7 +15808,7 @@ static int bnxt_queue_start(struct net_device *dev, void *qmem, int idx)
1576615808 napi_enable (& bnapi -> napi );
1576715809 bnxt_db_nq_arm (bp , & cpr -> cp_db , cpr -> cp_raw_cons );
1576815810
15769- for (i = 0 ; i <= BNXT_VNIC_NTUPLE ; i ++ ) {
15811+ for (i = 0 ; i < bp -> nr_vnics ; i ++ ) {
1577015812 vnic = & bp -> vnic_info [i ];
1577115813
1577215814 rc = bnxt_hwrm_vnic_set_rss_p5 (bp , vnic , true);
@@ -15800,7 +15842,7 @@ static int bnxt_queue_stop(struct net_device *dev, void *qmem, int idx)
1580015842 struct bnxt_napi * bnapi ;
1580115843 int i ;
1580215844
15803- for (i = 0 ; i <= BNXT_VNIC_NTUPLE ; i ++ ) {
15845+ for (i = 0 ; i < bp -> nr_vnics ; i ++ ) {
1580415846 vnic = & bp -> vnic_info [i ];
1580515847 vnic -> mru = 0 ;
1580615848 bnxt_hwrm_vnic_update (bp , vnic ,
@@ -16442,7 +16484,7 @@ static int bnxt_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
1644216484 if (bp -> max_fltr < BNXT_MAX_FLTR )
1644316485 bp -> max_fltr = BNXT_MAX_FLTR ;
1644416486 bnxt_init_l2_fltr_tbl (bp );
16445- bnxt_set_rx_skb_mode (bp , false);
16487+ __bnxt_set_rx_skb_mode (bp , false);
1644616488 bnxt_set_tpa_flags (bp );
1644716489 bnxt_init_ring_params (bp );
1644816490 bnxt_set_ring_params (bp );
@@ -16717,7 +16759,7 @@ static pci_ers_result_t bnxt_io_error_detected(struct pci_dev *pdev,
1671716759 * @pdev: Pointer to PCI device
1671816760 *
1671916761 * Restart the card from scratch, as if from a cold-boot.
16720- * At this point, the card has exprienced a hard reset,
16762+ * At this point, the card has experienced a hard reset,
1672116763 * followed by fixups by BIOS, and has its config space
1672216764 * set up identically to what it was at cold boot.
1672316765 */
@@ -16745,7 +16787,7 @@ static pci_ers_result_t bnxt_io_slot_reset(struct pci_dev *pdev)
1674516787 pci_set_master (pdev );
1674616788 /* Upon fatal error, our device internal logic that latches to
1674716789 * BAR value is getting reset and will restore only upon
16748- * rewritting the BARs.
16790+ * rewriting the BARs.
1674916791 *
1675016792 * As pci_restore_state() does not re-write the BARs if the
1675116793 * value is same as saved value earlier, driver needs to
@@ -16782,10 +16824,9 @@ static pci_ers_result_t bnxt_io_slot_reset(struct pci_dev *pdev)
1678216824 if (!err )
1678316825 result = PCI_ERS_RESULT_RECOVERED ;
1678416826
16827+ /* IRQ will be initialized later in bnxt_io_resume */
1678516828 bnxt_ulp_irq_stop (bp );
1678616829 bnxt_clear_int_mode (bp );
16787- err = bnxt_init_int_mode (bp );
16788- bnxt_ulp_irq_restart (bp , err );
1678916830 }
1679016831
1679116832reset_exit :
@@ -16814,10 +16855,13 @@ static void bnxt_io_resume(struct pci_dev *pdev)
1681416855
1681516856 err = bnxt_hwrm_func_qcaps (bp );
1681616857 if (!err ) {
16817- if (netif_running (netdev ))
16858+ if (netif_running (netdev )) {
1681816859 err = bnxt_open (netdev );
16819- else
16860+ } else {
1682016861 err = bnxt_reserve_rings (bp , true);
16862+ if (!err )
16863+ err = bnxt_init_int_mode (bp );
16864+ }
1682116865 }
1682216866
1682316867 if (!err )
0 commit comments