Re: [net-next v8 07/10] net: bnxt: Implement software USO

From: Eric Dumazet

Date: Thu Apr 02 2026 - 22:42:32 EST


On Thu, Apr 2, 2026 at 5:36 PM Joe Damato <joe@xxxxxxx> wrote:
>
> Implement bnxt_sw_udp_gso_xmit() using the core tso_dma_map API and
> the pre-allocated TX inline buffer for per-segment headers.
>
> The xmit path:
> 1. Calls tso_start() to initialize TSO state
> 2. Stack-allocates a tso_dma_map and calls tso_dma_map_init() to
> DMA-map the linear payload and all frags upfront.
> 3. For each segment:
> - Copies and patches headers via tso_build_hdr() into the
> pre-allocated tx_inline_buf (DMA-synced per segment)
> - Counts payload BDs via tso_dma_map_count()
> - Emits long BD (header) + ext BD + payload BDs
> - Payload BDs use tso_dma_map_next() which yields (dma_addr,
> chunk_len, mapping_len) tuples.
>
> Header BDs set dma_unmap_len=0 since the inline buffer is pre-allocated
> and unmapped only at ring teardown.
>
> Completion state is updated by calling tso_dma_map_completion_save() for
> the last segment.
>
> Suggested-by: Jakub Kicinski <kuba@xxxxxxxxxx>
> Signed-off-by: Joe Damato <joe@xxxxxxx>
> ---
>


> diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.h b/drivers/net/ethernet/broadcom/bnxt/bnxt.h
> index 6b38b84924e0..fe50576ae525 100644
> --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.h
> +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.h
> @@ -11,6 +11,8 @@
> #ifndef BNXT_H
> #define BNXT_H
>
> +#include <net/tso.h>
> +
> #define DRV_MODULE_NAME "bnxt_en"
>
> /* DO NOT CHANGE DRV_VER_* defines
> @@ -899,6 +901,7 @@ struct bnxt_sw_tx_bd {
> u16 rx_prod;
> u16 txts_prod;
> };
> + struct tso_dma_map_completion_state sw_gso_cstate;
> };
>
> #define BNXT_SW_GSO_MID 1
> diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_gso.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_gso.c
> index b296769ee4fe..7a7d40e36cea 100644
> --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_gso.c
> +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_gso.c
> @@ -19,11 +19,213 @@
> #include "bnxt.h"
> #include "bnxt_gso.h"
>
> +static u32 bnxt_sw_gso_lhint(unsigned int len)
> +{
> + if (len <= 512)
> + return TX_BD_FLAGS_LHINT_512_AND_SMALLER;
> + else if (len <= 1023)
> + return TX_BD_FLAGS_LHINT_512_TO_1023;
> + else if (len <= 2047)
> + return TX_BD_FLAGS_LHINT_1024_TO_2047;
> + else
> + return TX_BD_FLAGS_LHINT_2048_AND_LARGER;
> +}
> +
> netdev_tx_t bnxt_sw_udp_gso_xmit(struct bnxt *bp,
> struct bnxt_tx_ring_info *txr,
> struct netdev_queue *txq,
> struct sk_buff *skb)
> {
> + unsigned int last_unmap_len __maybe_unused = 0;
> + dma_addr_t last_unmap_addr __maybe_unused = 0;
> + struct bnxt_sw_tx_bd *last_unmap_buf = NULL;
> + unsigned int hdr_len, mss, num_segs;
> + struct pci_dev *pdev = bp->pdev;
> + unsigned int total_payload;
> + struct tso_dma_map map;
> + u32 vlan_tag_flags = 0;
> + int i, bds_needed;
> + struct tso_t tso;
> + u16 cfa_action;
> + u16 prod;
> +
> + hdr_len = tso_start(skb, &tso);

Orthogonal to your patch:

It seems that tso_start() users do not really check if hdr_len could
be bigger than
their expectations ( TSO_HEADER_SIZE for many of them).

Presumably these drivers should have an ndo_features_check() to detect
this and fallback to GSO.

I can send a series to fix this.