# Re: \[PATCH net 2/2\] bnxt\_en: Linearize TX SKB if the fragments exceed the max

- From: Michael Chan \<michael.chan@broadcom.com\>
- Date: 2025-05-05 18:34:31 
- List: netdev
- Page: https://ratatoskr.run/netdev/2025/05/11326487
- Thread: https://ratatoskr.run/netdev/2025/03/11322953/t.md

```text
On Mon, May 5, 2025 at 8:37 AM Eric Dumazet [ref] wrote:
>
> On Fri, Mar 21, 2025 at 2:17 PM Michael Chan [ref] wrote:
> >  drivers/net/ethernet/broadcom/bnxt/bnxt.c | 11 +++++++++++
> >  drivers/net/ethernet/broadcom/bnxt/bnxt.h |  4 ++++
> >  2 files changed, 15 insertions(+)
> >
> > diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
> > index 158e9789c1f4..2cd79b59cf00 100644
> > --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
> > +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
> > @@ -485,6 +485,17 @@ static netdev_tx_t bnxt_start_xmit(struct sk_buff *skb, struct net_device *dev)
> >         txr = &bp->tx_ring[bp->tx_ring_map[i]];
> >         prod = txr->tx_prod;
> >
> > +#if (MAX_SKB_FRAGS > TX_MAX_FRAGS)
> > +       if (skb_shinfo(skb)->nr_frags > TX_MAX_FRAGS) {
> > +               netdev_warn_once(dev, "SKB has too many (%d) fragments, max supported is %d.  SKB will be linearized.\n",
> > +                                skb_shinfo(skb)->nr_frags, TX_MAX_FRAGS);
> > +               if (skb_linearize(skb)) {
> > +                       dev_kfree_skb_any(skb);
> > +                       dev_core_stats_tx_dropped_inc(dev);
> > +                       return NETDEV_TX_OK;
> > +               }
> > +       }
> > +#endif
>
> Hi Michael
>
> Sorry for the delay. I just saw your patch.
>
> GSO would be more efficient and less likely to fail under memory pressure.
>
> Could you test the following patch for me ?
>
> Thanks !

The patch works.  I forced a smaller TX_MAX_FRAGS to easily test it.
But we now skip the warn_once() above since we intercept it earlier.
 Should we add a warn_once() here also?  Thanks.

>
> diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
> b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
> index 3a9ffaaf60ae810bf8772b0cad0da45bc4ec9a05..c2a831efa969742711f5afdc7b24ba2c450cc595
> 100644
> --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
> +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
> @@ -13787,6 +13787,10 @@ static netdev_features_t
> bnxt_features_check(struct sk_buff *skb,
>         u8 *l4_proto;
>
>         features = vlan_features_check(skb, features);
> +#if MAX_SKB_FRAGS > TX_MAX_FRAGS
> +       if (skb_shinfo(skb)->nr_frags > TX_MAX_FRAGS)
> +               features &= ~NETIF_F_GSO_MASK;
> +#endif
>         switch (vlan_get_protocol(skb)) {
>         case htons(ETH_P_IP):
>                 if (!skb->encapsulation)
```

## Attachments

- [smime.p7s](https://ratatoskr.run/netdev/2025/05/11326487/attachment/0) (application/pkcs7-signature, 4196 bytes)
