Netdev List
 help / color / mirror / Atom feed
From: Willem de Bruijn <willemdebruijn.kernel@gmail.com>
To: "Chia-Yu Chang (Nokia)" <chia-yu.chang@nokia-bell-labs.com>,
	 Mirja Kuehlewind <mirja.kuehlewind@ericsson.com>,
	 Willem de Bruijn <willemdebruijn.kernel@gmail.com>
Cc: Jakub Kicinski <kuba@kernel.org>,
	 "shaojijie@huawei.com" <shaojijie@huawei.com>,
	 "shenjian15@huawei.com" <shenjian15@huawei.com>,
	 "linux-rdma@vger.kernel.org" <linux-rdma@vger.kernel.org>,
	 "eperezma@redhat.com" <eperezma@redhat.com>,
	 "jasowang@redhat.com" <jasowang@redhat.com>,
	 "virtualization@lists.linux.dev"
	<virtualization@lists.linux.dev>,
	 "mst@redhat.com" <mst@redhat.com>,
	 "xuanzhuo@linux.alibaba.com" <xuanzhuo@linux.alibaba.com>,
	 "pabeni@redhat.com" <pabeni@redhat.com>,
	 "edumazet@google.com" <edumazet@google.com>,
	 "linux-doc@vger.kernel.org" <linux-doc@vger.kernel.org>,
	 "corbet@lwn.net" <corbet@lwn.net>,
	 "horms@kernel.org" <horms@kernel.org>,
	 "dsahern@kernel.org" <dsahern@kernel.org>,
	 "kuniyu@google.com" <kuniyu@google.com>,
	 "bpf@vger.kernel.org" <bpf@vger.kernel.org>,
	 "netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	 "dave.taht@gmail.com" <dave.taht@gmail.com>,
	 "jhs@mojatatu.com" <jhs@mojatatu.com>,
	 "stephen@networkplumber.org" <stephen@networkplumber.org>,
	 "xiyou.wangcong@gmail.com" <xiyou.wangcong@gmail.com>,
	 "jiri@resnulli.us" <jiri@resnulli.us>,
	 "davem@davemloft.net" <davem@davemloft.net>,
	 "andrew+netdev@lunn.ch" <andrew+netdev@lunn.ch>,
	 "donald.hunter@gmail.com" <donald.hunter@gmail.com>,
	 "ast@fiberby.net" <ast@fiberby.net>,
	 "liuhangbin@gmail.com" <liuhangbin@gmail.com>,
	 "shuah@kernel.org" <shuah@kernel.org>,
	 "linux-kselftest@vger.kernel.org"
	<linux-kselftest@vger.kernel.org>,
	 "ij@kernel.org" <ij@kernel.org>,
	 "ncardwell@google.com" <ncardwell@google.com>,
	 "Koen De Schepper (Nokia)"
	<koen.de_schepper@nokia-bell-labs.com>,
	 "g.white@cablelabs.com" <g.white@cablelabs.com>,
	 Ingemar Johansson S <ingemar.s.johansson@ericsson.com>,
	 "cheshire@apple.com" <cheshire@apple.com>,
	 "rs.ietf@gmx.at" <rs.ietf@gmx.at>,
	 "Jason_Livingood@comcast.com" <Jason_Livingood@comcast.com>,
	 "vidhi_goel@apple.com" <vidhi_goel@apple.com>,
	 Parav Pandit <parav@nvidia.com>,
	 Willem de Bruijn <willemb@google.com>
Subject: RE: [PATCH v5 net-next 1/2] net: update comments for SKB_GSO_TCP_ECN and SKB_GSO_TCP_ACCECN
Date: Fri, 14 Aug 2026 09:34:01 -0400	[thread overview]
Message-ID: <willemdebruijn.kernel.c248a28f9c86@gmail.com> (raw)
In-Reply-To: <PAXPR07MB7984ED42ED0849D3A9AB8C19A3DA2@PAXPR07MB7984.eurprd07.prod.outlook.com>

Chia-Yu Chang (Nokia) wrote:
> > From: Mirja Kuehlewind <mirja.kuehlewind@ericsson.com> 
> > Sent: Friday, August 14, 2026 10:57 AM
> > To: Willem de Bruijn <willemdebruijn.kernel@gmail.com>; Chia-Yu Chang (Nokia) <chia-yu.chang@nokia-bell-labs.com>
> > Cc: Jakub Kicinski <kuba@kernel.org>; shaojijie@huawei.com; shenjian15@huawei.com; linux-rdma@vger.kernel.org; eperezma@redhat.com; jasowang@redhat.com; virtualization@lists.linux.dev; mst@redhat.com; xuanzhuo@linux.alibaba.com; pabeni@redhat.com; edumazet@google.com; linux-doc@vger.kernel.org; corbet@lwn.net; horms@kernel.org; dsahern@kernel.org; kuniyu@google.com; bpf@vger.kernel.org; netdev@vger.kernel.org; dave.taht@gmail.com; jhs@mojatatu.com; stephen@networkplumber.org; xiyou.wangcong@gmail.com; jiri@resnulli.us; davem@davemloft.net; andrew+netdev@lunn.ch; donald.hunter@gmail.com; ast@fiberby.net; liuhangbin@gmail.com; shuah@kernel.org; linux-kselftest@vger.kernel.org; ij@kernel.org; ncardwell@google.com; Koen De Schepper (Nokia) <koen.de_schepper@nokia-bell-labs.com>; g.white@cablelabs.com; Ingemar Johansson S <ingemar.s.johansson@ericsson.com>; cheshire@apple.com; rs.ietf@gmx.at; Jason_Livingood@comcast.com; vidhi_goel@apple.com; Parav Pandit <parav@nvidia.com>; Willem de Bruijn <willemb@google.com>
> > Subject: Re: [PATCH v5 net-next 1/2] net: update comments for SKB_GSO_TCP_ECN and SKB_GSO_TCP_ACCECN
> > 
> > Hi Willem,
> > 
> > The current function of is SKB_GSO_TCP_ECN wrong. Fixing this causes the regression.
> > 
> > Mirja
> > 
> > 
> > 
> > From: Willem de Bruijn <mailto:willemdebruijn.kernel@gmail.com>
> > Subject: Re: [PATCH v5 net-next 1/2] net: update comments for SKB_GSO_TCP_ECN and SKB_GSO_TCP_ACCECN
> > 
> > On Thu, Aug 13, 2026 at 6:33 AM Chia-Yu Chang (Nokia)
> > <mailto:chia-yu.chang@nokia-bell-labs.com> wrote:
> > 
> > > On Wed, 12 Aug 2026 10:33:19 +0000 Chia-Yu Chang (Nokia) wrote:
> > > > > > -     /* This indicates the tcp segment has CWR set. */
> > > > > > +     /* For TX, this indicates that the first TCP segment has CWR set, and
> > > > > > +      * any subsequent segment in the same skb has CWR cleared. This flag
> > > > > > +      * must not be used in RX, because the connection to which the segment
> > > > > > +      * belongs is not tracked to use RFC3168 or AccECN. Using RFC3168 ECN
> > > > > > +      * offload may clear CWR and corrupt ACE signal (CWR is part of it).
> > > > > > +      * Instead, SKB_GSO_TCP_ACCECN shall be used to avoid CWR corruption.
> > > > > > +      */
> > > > >
> > > > > I still can't wrap my head around this TBH.
> > > > >
> > > > > SKB_GSO_TCP_ECN means RFC3168
> > > > > SKB_GSO_TCP_ACCECN means AccECN
> > > > >
> > > > > If the HW can correctly detect cwr on first frame and then no cwr and report that as ECN/RFC3168 - what's the problem? TSO will produce the exact expected segment sequence.
> > > > >
> > > > > Is the program that if we re-GRO that frame in SW we end up with
> > > > > ECN+ACCECN on the same skb?
> > > >
> > > > Yes, this is the problem.
> > > > The HW does not know whether the received packets belong to an RFC3168 ECN flow or an AccECN flow on the RX path.
> > > > For example, HW GRO may set SKB_GSO_TCP_ECN after observing that the first packet has CWR=1:
> > > >
> > > > +===================+==========+=================+================+
> > > > |     Packet id     | CWR flag |       Flag      | Flushed as SKB |
> > > > +===================+==========+=================+================+
> > > > |         0         |     1    | SKB_GSO_TCP_ECN |        0       |
> > > > |         1         |     0    |         -       |        0       |
> > > > |         2         |     1    |         -       |        0       |
> > > > |         3         |     1    |         -       |        1       |
> > > > +===================+==========+=================+================+
> > > >
> > > > If the aggregated skb is forwarded through a device using GSO, e.g.,
> > > > HW RX (GRO) -> veth TX (GSO), the SKB_GSO_TCP_ECN applies RFC3168
> > > > semantics. This means that only the 1st segment keeps the CWR flag
> > > > while all subsequent segments have CWR cleared:
> > > >
> > > > +===================+==========+
> > > > |     Packet id     | CWR flag |
> > > > +===================+==========+
> > > > |         0         |     1    |
> > > > |         1         |     0    |
> > > > |         2         |     0    |
> > > > |         3         |     0    |
> > > > +===================+==========+
> > > >
> > > > This behavior is ok for RFC3168, since CWR is expected to appear only
> > > > once. However, for AccECN, CWR is part of the ACE signal and must be
> > > > preserved across all segments.
> > >
> > > But this would be obviously a buggy HW-GRO implementation.
> > > The rules for HW-GRO RFC3168 are -- ignore CWR on first segment (host responsible for populating SKB_GSO_TCP_ECN), and CWR _must be 0_ for all subsequent segments.
> > >
> > > > In the example above, the original CWR sequence was 1,0,1,1.
> > > > But after re-segmentation it becomes: 1,0,0,0.
> > > > This is why SKB_GSO_TCP_ECN should not be used in RX/GRO paths.
> > >
> > > We have extensive gro tests under
> > > tools/testing/selftests/drivers/net/gro.py
> > >
> > > If you want to catch bad devices - add appropriate test cases there.
> > >
> > 
> > I added a test case in patch 6f74bc8b6e8d related to the CWR flag.
> > In that case, there are 5 packets with CWR values of 0, 1, 1, 0, and 0, and packets are flushed after the 1st, 3rd, and 5th packets.
> > The gro.py uses this case in tools/testing/selftests/net/lib/gro.c to verify CWR behavior.
> > But indeed, that does not cover whether SKB_GSO_TCP_ECN or SKB_GSO_TCP_ACCECN shall be set during the GRO.
> > So, a test might be added to verify the SKB_GSO_TCP_ECN or SKB_GSO_TCP_ACCECN flags (if there is another suggested way, please let me know)?
> > 
> > > The comment as stated seems to be misleading - there's nothing wrong with using the flag if the device follows the RFC3168 semantics correctly.
> > >
> > > And of course, adding a comment and hoping people will find it is much weaker than adding tests.
> > >
> > > Again, maybe I'm missing what _actually_ doesn't work here.
> > 
> > Before adding an extra test, we need to clarify the definition and usages of these flags.
> > At the TX path, in tcp_gso_segment() of net/ipv4/tcp_offload.c, the SKB_GSO_TCP_ACCECN flag is used to preserve the CWR flags for AccECN flows.
> > Otherwise, when without SKB_GSO_TCP_ACCECN (RFC3168 ECN or Non-ECN flows), cwr will be cleared from the following packets.
> > 
> > For the RX path, unfortunately I do not find a clear rule of when SKB_GSO_TCP_ECN shall be set except in include/linux/skbuff.h.
> > Plus, the device usually does not track packets belonging to RFC3168 ECN or ACCECN flows.
> > So, my previous thought is to always use SKB_GSO_TCP_ACCECN in the RX path to avoid any potential CWR bleaching.
> > 
> > This would be a case where AccECN support causes a regression for
> > regular ECN handling, if that is no longer allowed to be coalesced.
> > 
> > Most HW-GRO hardware out there today likely only supports ECN. In
> > which case they can set SKB_GSO_TCP_ECN fine.
> > 
> > If AccECN flows cannot be differentiated from ECN flows, on such
> > devices, does the admin have to disable HW-GRO with ECN if they care
> > about preserving AccECN signals?
> > 
> > What does SW GRO do here?
> 
> Hi Willem,
> 
> Current SW GRO sets SKB_GSO_TCP_ACCECN when the flushed skb carries CWR in tcp_gro_complete():
> if (th->cwr)
>     shinfo->gso_type |= SKB_GSO_TCP_ACCECN;

And I suppose it follows correct AccECN rules for coalescing.

That is a performance regression from RFC 3168 ECN, as it allows for
less effective coalescing. I have no intuition how much it will
differ in practice.

> 
> For HW GRO of a legacy device that implementing RFC3168 semantics, setting SKB_GSO_TCP_ECN seems reasonable.
> However, such a device would not be able to preserve ACCECN signaling across the GRO/GSO.
> In that case, if preserving AccECN signaling is required, disabling HW GRO may indeed be necessary.

Right. And there currently is no kernel API to disable only ECN
coalescing. NETIF_F_GRO_HW enables or disables HW-GRO entirely.
Or even to signal whether a HW-GRO implementation is AccECN
capable.

Disabling HW-GRO can be a huge efficiency regression. I suspect
many users will prioritize the efficiency over preserving the AccECN
signal.

That said, some devices may have other ways to configure such
finer details of their HW-GRO, even though not available through
Ethtool.

> And I still think the SKB_GSO_TCP_ECN comment could be clarified.
> For example, by stating that "RX GRO implementations which need to preserve CWR information across re-segmentation should use SKB_GSO_TCP_ACCECN."?
> 
> Thanks!
> Chia-Yu



  reply	other threads:[~2026-08-14 13:34 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-04 21:35 [PATCH v5 net-next 0/2] ECN offload handling series chia-yu.chang
2026-08-04 21:35 ` [PATCH v5 net-next 1/2] net: update comments for SKB_GSO_TCP_ECN and SKB_GSO_TCP_ACCECN chia-yu.chang
2026-08-12  0:30   ` Jakub Kicinski
2026-08-12 10:33     ` Chia-Yu Chang (Nokia)
2026-08-12 22:54       ` Jakub Kicinski
2026-08-13 10:28         ` Chia-Yu Chang (Nokia)
2026-08-13 15:58           ` Willem de Bruijn
     [not found]             ` <47BE8A8A-F80C-4C30-BC95-C85FEBFFB606@ericsson.com>
2026-08-14 10:29               ` Chia-Yu Chang (Nokia)
2026-08-14 13:34                 ` Willem de Bruijn [this message]
2026-08-04 21:35 ` [PATCH v5 net-next 2/2] net: hns3: fix GSO_ECN flag setting in the RX path chia-yu.chang
2026-08-06 11:47   ` Jijie Shao
2026-08-11 13:31   ` Jijie Shao
2026-08-12 10:35     ` Chia-Yu Chang (Nokia)
2026-08-12 22:59       ` 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=willemdebruijn.kernel.c248a28f9c86@gmail.com \
    --to=willemdebruijn.kernel@gmail.com \
    --cc=Jason_Livingood@comcast.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=ast@fiberby.net \
    --cc=bpf@vger.kernel.org \
    --cc=cheshire@apple.com \
    --cc=chia-yu.chang@nokia-bell-labs.com \
    --cc=corbet@lwn.net \
    --cc=dave.taht@gmail.com \
    --cc=davem@davemloft.net \
    --cc=donald.hunter@gmail.com \
    --cc=dsahern@kernel.org \
    --cc=edumazet@google.com \
    --cc=eperezma@redhat.com \
    --cc=g.white@cablelabs.com \
    --cc=horms@kernel.org \
    --cc=ij@kernel.org \
    --cc=ingemar.s.johansson@ericsson.com \
    --cc=jasowang@redhat.com \
    --cc=jhs@mojatatu.com \
    --cc=jiri@resnulli.us \
    --cc=koen.de_schepper@nokia-bell-labs.com \
    --cc=kuba@kernel.org \
    --cc=kuniyu@google.com \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=liuhangbin@gmail.com \
    --cc=mirja.kuehlewind@ericsson.com \
    --cc=mst@redhat.com \
    --cc=ncardwell@google.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=parav@nvidia.com \
    --cc=rs.ietf@gmx.at \
    --cc=shaojijie@huawei.com \
    --cc=shenjian15@huawei.com \
    --cc=shuah@kernel.org \
    --cc=stephen@networkplumber.org \
    --cc=vidhi_goel@apple.com \
    --cc=virtualization@lists.linux.dev \
    --cc=willemb@google.com \
    --cc=xiyou.wangcong@gmail.com \
    --cc=xuanzhuo@linux.alibaba.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox