From nobody Wed Apr 8 04:41:03 2026 Received: from mail-pf1-f172.google.com (mail-pf1-f172.google.com [209.85.210.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8040C3E9F9E for ; Tue, 10 Mar 2026 21:22:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773177788; cv=none; b=SgvcZXJ7HOPQNXnrwuEOIX9kxjC7QLeUZVrgGdtCa2DXnXuK7fbKeDvWmuD1F56Uj9qUzTURC738UZVHNUCr4P1QPZqtb8N0eqErbHsxfPj7pENdNRozzWy+yaZEO6aSgTn6ph+GpiqLindXxG3eSQVzYfFU6670VWiJqPDr5ew= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773177788; c=relaxed/simple; bh=khy8AVx3doiUMrd9qJur7EVK1fQ0F9HwWkPOOL6vd9Q=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OZLMllrNUV+EWYi6vCHsoWm0YKGat6Sk0NGLSyLZDM02ZbLmQgI2n5azy3+Q/jgwG4ueHcO5WOdgoy4/wi43H3UBU5lVoWZnLrJ/jqMf+CA0Wwq/g25a2jpuV0x3q8ZlJD1Vto1dJYH5EE1XYTRfQLuNozaMdYk/T3VNv3jYf1Q= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=dama.to; spf=none smtp.mailfrom=dama.to; dkim=pass (2048-bit key) header.d=dama-to.20230601.gappssmtp.com header.i=@dama-to.20230601.gappssmtp.com header.b=KMPOSGOK; arc=none smtp.client-ip=209.85.210.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=dama.to Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=dama.to Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=dama-to.20230601.gappssmtp.com header.i=@dama-to.20230601.gappssmtp.com header.b="KMPOSGOK" Received: by mail-pf1-f172.google.com with SMTP id d2e1a72fcca58-8299c75f730so175384b3a.0 for ; Tue, 10 Mar 2026 14:22:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dama-to.20230601.gappssmtp.com; s=20230601; t=1773177778; x=1773782578; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=2067E4shQM8NlUtqVs4AWG5HTqwBiaYCbw4afwwP34A=; b=KMPOSGOKIjMuS0any7LWP5fdhK5hbbN8yfdiravbYdtLH+KecrG4pDEoFulnnzylgv i4Kq0XfEcVd8MIeU0JftPRYIKAZM+lthzcXbdXTS5704GNVOaSXIRez9MvjefnvHCeQL qjz4rAemZHrlKVap/vvLS5QjmwcNATJDGEAa2pRCz0+wjyLiunYgkYxeB7No71xq4Ie+ TdS8EpI4p8yK9AbuSsb47OdVOqd30+3VY2cggT0GWXiffxXyXBgZE4QsB6BVpnHddhgu 78yFGRdT78AtwNet+92rdkyqA9EaxSc/wsdQ/M3Z0aIibc+k8pIYVxhq4bsOe9biaqGu Mthg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1773177778; x=1773782578; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=2067E4shQM8NlUtqVs4AWG5HTqwBiaYCbw4afwwP34A=; b=j09Vhwe59ZJS3Fbe2ra6zH+sTlu97i2hw38nfbg86qHhpVImsSJ1t56Xjt+880BuY6 buvdY72Qt9s/XfA6Z/DG2YjXlQeyWdMcCKtb5VeGMxKaoPk4ujLvcKzVMjM5ao+eiu2G 9n992nZdVbJR3hNvPIhQupbrB07NbZCIbJn5e81zK0SaXO2Ex8u0s4/9Um2ggiv8vile Op3NcmhyR1pEfir1jIdnTwu9fSn3HunW+4INRcVJdu8OqEbr091/BLorsApusR//lPiy Hnre3MPAAF1sgoCNHVirV4mhOPTFwyGhjQOliGaDyTcaMIWuH2C290ZloTHw0RMvxSh5 SfVg== X-Gm-Message-State: AOJu0Yx/en4V43s52VnzbMuc9b6XCAKWPWmJjlzAU11uvGDxNP7zNq9p C3YoNWDCc4nXCGduKzW6nzmaX5/wG1xSg3R8I1O1JTgzYfjBbaUwvNyFmVutlyL8GvM= X-Gm-Gg: ATEYQzz/WGnO31quFyvLVjDfLy3YSfifAdrVQwqVApP35u2675hBPktNrDHfGBCYDvr 0rVz7qZPf8dcYdlKQsiarzq9jdrStW0Tv2SWx0TZqvAbpdrSwkppta8gTLpFU9t8IsjELC9yvni Ln4HKiiMZ/eInIMBtXxq0RnQDOz8MtHdOUVaCxHUsTHJ4GkOyyVXGVFfEX4ix0r5kEsZJoi8qXr hEZhJ38neF5sf7BS11RBYJT0b2jTHDfBzhpvIdfLBTNHgHjokxPelmfN3Y4I9MKHEeNlz0NySjF S5tOh5HyJdGwQ4YTQHZQoW8kOEimfEYTdBiLmoZ2Hj0+YpW5rafr1r03WwdvssSIHHsOJc1cSSI wXWmbCkX9ckYjBYjo6mpwnOsLH5IMEnXhBmFyjucu2EXBxvWnHzsVgXdbGIU6dqm1GEZdft75Gm H7nERJ X-Received: by 2002:a05:6a00:1826:b0:818:1e8c:a513 with SMTP id d2e1a72fcca58-829f7ab62c1mr127271b3a.17.1773177778635; Tue, 10 Mar 2026 14:22:58 -0700 (PDT) Received: from localhost ([2a03:2880:2ff:74::]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-829f703a7casm184936b3a.59.2026.03.10.14.22.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Mar 2026 14:22:58 -0700 (PDT) From: Joe Damato To: netdev@vger.kernel.org, Michael Chan , Pavan Chebbi , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: linux-kernel@vger.kernel.org, Joe Damato Subject: [RFC net-next 09/10] net: bnxt: Add SW GSO completion and teardown support Date: Tue, 10 Mar 2026 14:21:57 -0700 Message-ID: <20260310212209.2263939-10-joe@dama.to> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260310212209.2263939-1-joe@dama.to> References: <20260310212209.2263939-1-joe@dama.to> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Update __bnxt_tx_int and bnxt_free_one_tx_ring_skbs to handle SW GSO segments: - MID segments: adjust tx_pkts/tx_bytes accounting and skip skb free (the skb is shared across all segments and freed only once) - LAST segments: no special cleanup needed -- payload DMA unmapping is handled by the existing per-BD dma_unmap_len walk, and the header inline buffer is pre-allocated per-ring (freed at ring teardown) sw_gso is initialized to zero, so the new code paths are not run. Suggested-by: Jakub Kicinski Signed-off-by: Joe Damato --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 63 ++++++++++++++++--- .../net/ethernet/broadcom/bnxt/bnxt_ethtool.c | 19 +++++- 2 files changed, 72 insertions(+), 10 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethern= et/broadcom/bnxt/bnxt.c index 906e842d9c53..47dc98479066 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -74,6 +74,8 @@ #include "bnxt_debugfs.h" #include "bnxt_coredump.h" #include "bnxt_hwmon.h" +#include "bnxt_gso.h" +#include =20 #define BNXT_TX_TIMEOUT (5 * HZ) #define BNXT_DEF_MSG_ENABLE (NETIF_MSG_DRV | NETIF_MSG_HW | \ @@ -818,12 +820,13 @@ static bool __bnxt_tx_int(struct bnxt *bp, struct bnx= t_tx_ring_info *txr, bool rc =3D false; =20 while (RING_TX(bp, cons) !=3D hw_cons) { - struct bnxt_sw_tx_bd *tx_buf; + struct bnxt_sw_tx_bd *tx_buf, *head_buf; struct sk_buff *skb; bool is_ts_pkt; int j, last; =20 tx_buf =3D &txr->tx_buf_ring[RING_TX(bp, cons)]; + head_buf =3D tx_buf; skb =3D tx_buf->skb; =20 if (unlikely(!skb)) { @@ -870,6 +873,14 @@ static bool __bnxt_tx_int(struct bnxt *bp, struct bnxt= _tx_ring_info *txr, DMA_TO_DEVICE, 0); } } + if (unlikely(head_buf->is_sw_gso)) { + if (head_buf->is_sw_gso =3D=3D BNXT_SW_GSO_MID) { + tx_pkts--; + tx_bytes -=3D skb->len; + skb =3D NULL; + } + head_buf->is_sw_gso =3D 0; + } if (unlikely(is_ts_pkt)) { if (BNXT_CHIP_P5(bp)) { /* PTP worker takes ownership of the skb */ @@ -3417,6 +3428,7 @@ static void bnxt_free_one_tx_ring_skbs(struct bnxt *b= p, =20 for (i =3D 0; i < max_idx;) { struct bnxt_sw_tx_bd *tx_buf =3D &txr->tx_buf_ring[i]; + struct bnxt_sw_tx_bd *head_buf =3D tx_buf; struct sk_buff *skb; int j, last; =20 @@ -3467,7 +3479,10 @@ static void bnxt_free_one_tx_ring_skbs(struct bnxt *= bp, len), DMA_TO_DEVICE, 0); } - dev_kfree_skb(skb); + if (head_buf->is_sw_gso =3D=3D BNXT_SW_GSO_MID) + skb =3D NULL; + if (skb) + dev_kfree_skb(skb); } netdev_tx_reset_queue(netdev_get_tx_queue(bp->dev, idx)); } @@ -3975,9 +3990,9 @@ static void bnxt_free_tx_inline_buf(struct bnxt_tx_ri= ng_info *txr, txr->tx_inline_size =3D 0; } =20 -static int __maybe_unused bnxt_alloc_tx_inline_buf(struct bnxt_tx_ring_inf= o *txr, - struct pci_dev *pdev, - unsigned int size) +static int bnxt_alloc_tx_inline_buf(struct bnxt_tx_ring_info *txr, + struct pci_dev *pdev, + unsigned int size) { txr->tx_inline_buf =3D kmalloc(size, GFP_KERNEL); if (!txr->tx_inline_buf) @@ -4080,6 +4095,14 @@ static int bnxt_alloc_tx_rings(struct bnxt *bp) sizeof(struct tx_push_bd); txr->data_mapping =3D cpu_to_le64(mapping); } + if (!(bp->flags & BNXT_FLAG_UDP_GSO_CAP) && + (bp->dev->features & NETIF_F_GSO_UDP_L4)) { + rc =3D bnxt_alloc_tx_inline_buf(txr, pdev, + BNXT_SW_USO_MAX_SEGS * + TSO_HEADER_SIZE); + if (rc) + return rc; + } qidx =3D bp->tc_to_qidx[j]; ring->queue_id =3D bp->q_info[qidx].queue_id; spin_lock_init(&txr->xdp_tx_lock); @@ -4611,6 +4634,10 @@ static int bnxt_init_tx_rings(struct bnxt *bp) =20 bp->tx_wake_thresh =3D max_t(int, bp->tx_ring_size / 2, BNXT_MIN_TX_DESC_CNT); + if (!(bp->flags & BNXT_FLAG_UDP_GSO_CAP) && + (bp->dev->features & NETIF_F_GSO_UDP_L4)) + bp->tx_wake_thresh =3D max_t(int, bp->tx_wake_thresh, + BNXT_SW_USO_MAX_DESCS); =20 for (i =3D 0; i < bp->tx_nr_rings; i++) { struct bnxt_tx_ring_info *txr =3D &bp->tx_ring[i]; @@ -13778,6 +13805,11 @@ static netdev_features_t bnxt_fix_features(struct = net_device *dev, if ((features & NETIF_F_NTUPLE) && !bnxt_rfs_capable(bp, false)) features &=3D ~NETIF_F_NTUPLE; =20 + if ((features & NETIF_F_GSO_UDP_L4) && + !(bp->flags & BNXT_FLAG_UDP_GSO_CAP) && + bp->tx_ring_size < 2 * BNXT_SW_USO_MAX_DESCS) + features &=3D ~NETIF_F_GSO_UDP_L4; + if ((bp->flags & BNXT_FLAG_NO_AGG_RINGS) || bp->xdp_prog) features &=3D ~(NETIF_F_LRO | NETIF_F_GRO_HW); =20 @@ -13823,6 +13855,15 @@ static int bnxt_set_features(struct net_device *de= v, netdev_features_t features) int rc =3D 0; bool re_init =3D false; =20 + if (!(bp->flags & BNXT_FLAG_UDP_GSO_CAP)) { + if (features & NETIF_F_GSO_UDP_L4) + bp->tx_wake_thresh =3D max_t(int, bp->tx_wake_thresh, + BNXT_SW_USO_MAX_DESCS); + else + bp->tx_wake_thresh =3D max_t(int, bp->tx_ring_size / 2, + BNXT_MIN_TX_DESC_CNT); + } + flags &=3D ~BNXT_FLAG_ALL_CONFIG_FEATS; if (features & NETIF_F_GRO_HW) flags |=3D BNXT_FLAG_GRO; @@ -16803,8 +16844,7 @@ static int bnxt_init_one(struct pci_dev *pdev, cons= t struct pci_device_id *ent) NETIF_F_GSO_UDP_TUNNEL_CSUM | NETIF_F_GSO_GRE_CSUM | NETIF_F_GSO_PARTIAL | NETIF_F_RXHASH | NETIF_F_RXCSUM | NETIF_F_GRO; - if (bp->flags & BNXT_FLAG_UDP_GSO_CAP) - dev->hw_features |=3D NETIF_F_GSO_UDP_L4; + dev->hw_features |=3D NETIF_F_GSO_UDP_L4; =20 if (BNXT_SUPPORTS_TPA(bp)) dev->hw_features |=3D NETIF_F_LRO; @@ -16837,8 +16877,15 @@ static int bnxt_init_one(struct pci_dev *pdev, con= st struct pci_device_id *ent) dev->priv_flags |=3D IFF_UNICAST_FLT; =20 netif_set_tso_max_size(dev, GSO_MAX_SIZE); - if (bp->tso_max_segs) + if (!(bp->flags & BNXT_FLAG_UDP_GSO_CAP)) { + u16 max_segs =3D BNXT_SW_USO_MAX_SEGS; + + if (bp->tso_max_segs) + max_segs =3D min_t(u16, max_segs, bp->tso_max_segs); + netif_set_tso_max_segs(dev, max_segs); + } else if (bp->tso_max_segs) { netif_set_tso_max_segs(dev, bp->tso_max_segs); + } =20 dev->xdp_features =3D NETDEV_XDP_ACT_BASIC | NETDEV_XDP_ACT_REDIRECT | NETDEV_XDP_ACT_RX_SG; diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c b/drivers/ne= t/ethernet/broadcom/bnxt/bnxt_ethtool.c index 3ce092bc8bba..50a4736f512a 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c @@ -33,6 +33,7 @@ #include "bnxt_xdp.h" #include "bnxt_ptp.h" #include "bnxt_ethtool.h" +#include "bnxt_gso.h" #include "bnxt_nvm_defs.h" /* NVRAM content constant and structure defs */ #include "bnxt_fw_hdr.h" /* Firmware hdr constant and structure defs */ #include "bnxt_coredump.h" @@ -846,12 +847,18 @@ static int bnxt_set_ringparam(struct net_device *dev, u8 tcp_data_split =3D kernel_ering->tcp_data_split; struct bnxt *bp =3D netdev_priv(dev); u8 hds_config_mod; + int rc; =20 if ((ering->rx_pending > BNXT_MAX_RX_DESC_CNT) || (ering->tx_pending > BNXT_MAX_TX_DESC_CNT) || (ering->tx_pending < BNXT_MIN_TX_DESC_CNT)) return -EINVAL; =20 + if ((dev->features & NETIF_F_GSO_UDP_L4) && + !(bp->flags & BNXT_FLAG_UDP_GSO_CAP) && + ering->tx_pending < 2 * BNXT_SW_USO_MAX_DESCS) + return -EINVAL; + hds_config_mod =3D tcp_data_split !=3D dev->cfg->hds_config; if (tcp_data_split =3D=3D ETHTOOL_TCP_DATA_SPLIT_DISABLED && hds_config_m= od) return -EINVAL; @@ -876,9 +883,17 @@ static int bnxt_set_ringparam(struct net_device *dev, bp->tx_ring_size =3D ering->tx_pending; bnxt_set_ring_params(bp); =20 - if (netif_running(dev)) - return bnxt_open_nic(bp, false, false); + if (netif_running(dev)) { + rc =3D bnxt_open_nic(bp, false, false); + if (rc) + return rc; + } =20 + /* ring size changes may affect features (SW USO requires a minimum + * ring size), so recalculate features to ensure the correct features + * are blocked/available. + */ + netdev_update_features(dev); return 0; } =20 --=20 2.52.0