All of lore.kernel.org
 help / color / mirror / Atom feed
From: Richard Gobert <richardbgobert@gmail.com>
To: Edward Cree <ecree.xilinx@gmail.com>
Cc: netdev@vger.kernel.org, davem@davemloft.net, edumazet@google.com,
	kuba@kernel.org, pabeni@redhat.com, horms@kernel.org,
	corbet@lwn.net, saeedm@nvidia.com, tariqt@nvidia.com,
	mbloch@nvidia.com, leon@kernel.org, dsahern@kernel.org,
	ncardwell@google.com, kuniyu@google.com, shuah@kernel.org,
	sdf@fomichev.me, aleksander.lobakin@intel.com,
	florian.fainelli@broadcom.com, willemdebruijn.kernel@gmail.com,
	alexander.duyck@gmail.com, linux-kernel@vger.kernel.org,
	linux-net-drivers@amd.com
Subject: Re: [PATCH net-next v3 3/5] net: gso: restore ids of outer ip headers correctly
Date: Mon, 25 Aug 2025 15:22:40 +0200	[thread overview]
Message-ID: <491aac69-e138-4863-8d42-01b1011fa347@gmail.com> (raw)
In-Reply-To: <73927f0c-f6aa-464b-ab20-559196e015a8@gmail.com>

Edward Cree wrote:
> On 21/08/2025 08:30, Richard Gobert wrote:
>> Currently, NETIF_F_TSO_MANGLEID indicates that the inner-most ID can
>> be mangled. Outer IDs can always be mangled.
>>
>> Make GSO preserve outer IDs by default, with NETIF_F_TSO_MANGLEID allowing
>> both inner and outer IDs to be mangled. In the future, we could add
>> NETIF_F_TSO_MANGLEID_INNER to provide more granular control to
>> drivers.
>>
>> This commit also modifies a few drivers that use SKB_GSO_FIXEDID directly.
>>
>> Signed-off-by: Richard Gobert <richardbgobert@gmail.com>
> ...
>> diff --git a/drivers/net/ethernet/sfc/ef100_tx.c b/drivers/net/ethernet/sfc/ef100_tx.c
>> index e6b6be549581..4efd22b44986 100644
>> --- a/drivers/net/ethernet/sfc/ef100_tx.c
>> +++ b/drivers/net/ethernet/sfc/ef100_tx.c
>> @@ -189,7 +189,8 @@ static void ef100_make_tso_desc(struct efx_nic *efx,
>>  {
>>  	bool gso_partial = skb_shinfo(skb)->gso_type & SKB_GSO_PARTIAL;
>>  	unsigned int len, ip_offset, tcp_offset, payload_segs;
>> -	u32 mangleid = ESE_GZ_TX_DESC_IP4_ID_INC_MOD16;
>> +	u32 mangleid_outer = ESE_GZ_TX_DESC_IP4_ID_INC_MOD16;
>> +	u32 mangleid_inner = ESE_GZ_TX_DESC_IP4_ID_INC_MOD16;
>>  	unsigned int outer_ip_offset, outer_l4_offset;
>>  	u16 vlan_tci = skb_vlan_tag_get(skb);
>>  	u32 mss = skb_shinfo(skb)->gso_size;
>> @@ -201,7 +202,9 @@ static void ef100_make_tso_desc(struct efx_nic *efx,
>>  	u32 paylen;
>>  
>>  	if (skb_shinfo(skb)->gso_type & SKB_GSO_TCP_FIXEDID)
>> -		mangleid = ESE_GZ_TX_DESC_IP4_ID_NO_OP;
>> +		mangleid_outer = ESE_GZ_TX_DESC_IP4_ID_NO_OP;
>> +	if (skb_shinfo(skb)->gso_type & SKB_GSO_TCP_FIXEDID_INNER)
>> +		mangleid_inner = ESE_GZ_TX_DESC_IP4_ID_NO_OP;
>>  	if (efx->net_dev->features & NETIF_F_HW_VLAN_CTAG_TX)
>>  		vlan_enable = skb_vlan_tag_present(skb);
>>  
>> @@ -239,14 +242,13 @@ static void ef100_make_tso_desc(struct efx_nic *efx,
>>  			      ESF_GZ_TX_TSO_CSO_INNER_L4, 1,
>>  			      ESF_GZ_TX_TSO_INNER_L3_OFF_W, ip_offset >> 1,
>>  			      ESF_GZ_TX_TSO_INNER_L4_OFF_W, tcp_offset >> 1,
>> -			      ESF_GZ_TX_TSO_ED_INNER_IP4_ID, mangleid,
>> +			      ESF_GZ_TX_TSO_ED_INNER_IP4_ID, mangleid_inner,
>>  			      ESF_GZ_TX_TSO_ED_INNER_IP_LEN, 1,
>>  			      ESF_GZ_TX_TSO_OUTER_L3_OFF_W, outer_ip_offset >> 1,
>>  			      ESF_GZ_TX_TSO_OUTER_L4_OFF_W, outer_l4_offset >> 1,
>>  			      ESF_GZ_TX_TSO_ED_OUTER_UDP_LEN, udp_encap && !gso_partial,
>>  			      ESF_GZ_TX_TSO_ED_OUTER_IP_LEN, encap && !gso_partial,
>> -			      ESF_GZ_TX_TSO_ED_OUTER_IP4_ID, encap ? mangleid :
>> -								     ESE_GZ_TX_DESC_IP4_ID_NO_OP,
>> +			      ESF_GZ_TX_TSO_ED_OUTER_IP4_ID, mangleid_outer,
>>  			      ESF_GZ_TX_TSO_VLAN_INSERT_EN, vlan_enable,
>>  			      ESF_GZ_TX_TSO_VLAN_INSERT_TCI, vlan_tci
>>  		);
> 
> AFAICT this will now, in the case when FIXEDID isn't set, set
>  ESF_GZ_TX_TSO_ED_OUTER_IP4_ID on non-encapsulated frames, for which
>  ESF_GZ_TX_TSO_OUTER_L3_OFF_W has been set to 0.  I'm not 100% sure,
>  but I think that will cause the NIC to do an INC_MOD16 on octets 4
>  and 5 of the packet, corrupting the Ethernet header.
> Please retain the existing logic whereby ED_OUTER_IP4_ID is set to
>  NO_OP in the !encap case.
> Note that the EF100 host interface's semantics take the view that an
>  unencapsulated packet has an INNER and no OUTER header, which AIUI
>  is the opposite to how your new gso_type flags are defined, so I
>  think for !encap you also need to set mangleid_inner based on
>  SKB_GSO_TCP_FIXEDID, rather than SKB_GSO_TCP_FIXEDID_INNER.
> 
> My apologies for not spotting this in earlier versions.

Will fix this in v4. Thanks!


  reply	other threads:[~2025-08-25 13:22 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-21  7:30 [PATCH net-next v3 0/5] net: gso: restore outer ip ids correctly Richard Gobert
2025-08-21  7:30 ` [PATCH net-next v3 1/5] net: gro: remove is_ipv6 from napi_gro_cb Richard Gobert
2025-08-21  7:30 ` [PATCH net-next v3 2/5] net: gro: only merge packets with incrementing or fixed outer ids Richard Gobert
2025-08-22  8:26   ` Paolo Abeni
2025-08-22  8:31     ` Paolo Abeni
2025-08-21  7:30 ` [PATCH net-next v3 3/5] net: gso: restore ids of outer ip headers correctly Richard Gobert
2025-08-21 16:20   ` Edward Cree
2025-08-25 13:22     ` Richard Gobert [this message]
2025-08-22 15:51   ` Paolo Abeni
2025-08-25 13:31     ` Richard Gobert
2025-08-25 16:38       ` Paolo Abeni
2025-08-26 14:31         ` Richard Gobert
2025-08-21  7:30 ` [PATCH net-next v3 4/5] net: gro: remove unnecessary df checks Richard Gobert
2025-08-21  7:30 ` [PATCH net-next v3 5/5] selftests/net: test ipip packets in gro.sh Richard Gobert
2025-08-21 17:51 ` [PATCH net-next v3 0/5] net: gso: restore outer ip ids correctly Jakub Kicinski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=491aac69-e138-4863-8d42-01b1011fa347@gmail.com \
    --to=richardbgobert@gmail.com \
    --cc=aleksander.lobakin@intel.com \
    --cc=alexander.duyck@gmail.com \
    --cc=corbet@lwn.net \
    --cc=davem@davemloft.net \
    --cc=dsahern@kernel.org \
    --cc=ecree.xilinx@gmail.com \
    --cc=edumazet@google.com \
    --cc=florian.fainelli@broadcom.com \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=kuniyu@google.com \
    --cc=leon@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-net-drivers@amd.com \
    --cc=mbloch@nvidia.com \
    --cc=ncardwell@google.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=saeedm@nvidia.com \
    --cc=sdf@fomichev.me \
    --cc=shuah@kernel.org \
    --cc=tariqt@nvidia.com \
    --cc=willemdebruijn.kernel@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.