lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20241206123030.GM2581@kernel.org>
Date: Fri, 6 Dec 2024 12:30:30 +0000
From: Simon Horman <horms@...nel.org>
To: Wei Fang <wei.fang@....com>
Cc: Claudiu Manoil <claudiu.manoil@....com>,
	Vladimir Oltean <vladimir.oltean@....com>,
	Clark Wang <xiaoning.wang@....com>,
	"andrew+netdev@...n.ch" <andrew+netdev@...n.ch>,
	"davem@...emloft.net" <davem@...emloft.net>,
	"edumazet@...gle.com" <edumazet@...gle.com>,
	"kuba@...nel.org" <kuba@...nel.org>,
	"pabeni@...hat.com" <pabeni@...hat.com>,
	Frank Li <frank.li@....com>,
	"netdev@...r.kernel.org" <netdev@...r.kernel.org>,
	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
	"imx@...ts.linux.dev" <imx@...ts.linux.dev>
Subject: Re: [PATCH v6 RESEND net-next 1/5] net: enetc: add Rx checksum
 offload for i.MX95 ENETC

On Fri, Dec 06, 2024 at 10:33:15AM +0000, Wei Fang wrote:
> > -----Original Message-----
> > From: Simon Horman <horms@...nel.org>
> > Sent: 2024年12月6日 17:23
> > To: Wei Fang <wei.fang@....com>
> > Cc: Claudiu Manoil <claudiu.manoil@....com>; Vladimir Oltean
> > <vladimir.oltean@....com>; Clark Wang <xiaoning.wang@....com>;
> > andrew+netdev@...n.ch; davem@...emloft.net; edumazet@...gle.com;
> > kuba@...nel.org; pabeni@...hat.com; Frank Li <frank.li@....com>;
> > netdev@...r.kernel.org; linux-kernel@...r.kernel.org; imx@...ts.linux.dev
> > Subject: Re: [PATCH v6 RESEND net-next 1/5] net: enetc: add Rx checksum
> > offload for i.MX95 ENETC
> > 
> > On Wed, Dec 04, 2024 at 01:29:28PM +0800, Wei Fang wrote:
> > > ENETC rev 4.1 supports TCP and UDP checksum offload for receive, the bit
> > > 108 of the Rx BD will be set if the TCP/UDP checksum is correct. Since
> > > this capability is not defined in register, the rx_csum bit is added to
> > > struct enetc_drvdata to indicate whether the device supports Rx checksum
> > > offload.
> > >
> > > Signed-off-by: Wei Fang <wei.fang@....com>
> > > Reviewed-by: Frank Li <Frank.Li@....com>
> > > Reviewed-by: Claudiu Manoil <claudiu.manoil@....com>
> > > ---
> > > v2: no changes
> > > v3: no changes
> > > v4: no changes
> > > v5: no changes
> > > v6: no changes
> > > ---
> > >  drivers/net/ethernet/freescale/enetc/enetc.c       | 14 ++++++++++----
> > >  drivers/net/ethernet/freescale/enetc/enetc.h       |  2 ++
> > >  drivers/net/ethernet/freescale/enetc/enetc_hw.h    |  2 ++
> > >  .../net/ethernet/freescale/enetc/enetc_pf_common.c |  3 +++
> > >  4 files changed, 17 insertions(+), 4 deletions(-)
> > >
> > > diff --git a/drivers/net/ethernet/freescale/enetc/enetc.c
> > b/drivers/net/ethernet/freescale/enetc/enetc.c
> > > index 35634c516e26..3137b6ee62d3 100644
> > > --- a/drivers/net/ethernet/freescale/enetc/enetc.c
> > > +++ b/drivers/net/ethernet/freescale/enetc/enetc.c
> > > @@ -1011,10 +1011,15 @@ static void enetc_get_offloads(struct enetc_bdr
> > *rx_ring,
> > >
> > >  	/* TODO: hashing */
> > >  	if (rx_ring->ndev->features & NETIF_F_RXCSUM) {
> > > -		u16 inet_csum = le16_to_cpu(rxbd->r.inet_csum);
> > > -
> > > -		skb->csum = csum_unfold((__force __sum16)~htons(inet_csum));
> > > -		skb->ip_summed = CHECKSUM_COMPLETE;
> > > +		if (priv->active_offloads & ENETC_F_RXCSUM &&
> > > +		    le16_to_cpu(rxbd->r.flags) & ENETC_RXBD_FLAG_L4_CSUM_OK)
> > {
> > > +			skb->ip_summed = CHECKSUM_UNNECESSARY;
> > > +		} else {
> > > +			u16 inet_csum = le16_to_cpu(rxbd->r.inet_csum);
> > > +
> > > +			skb->csum = csum_unfold((__force __sum16)~htons(inet_csum));
> > > +			skb->ip_summed = CHECKSUM_COMPLETE;
> > > +		}
> > >  	}
> > 
> > Hi Wei,
> > 
> > I am wondering about the relationship between the above and
> > hardware support for CHECKSUM_COMPLETE.
> > 
> > Prior to this patch CHECKSUM_COMPLETE was always used, which seems
> > desirable. But with this patch, CHECKSUM_UNNECESSARY is conditionally used.
> > 
> > If those cases don't work with CHECKSUM_COMPLETE then is this a bug-fix?
> > 
> > Or, alternatively, if those cases do work with CHECKSUM_COMPLETE, then
> > I'm unsure why this change is necessary or desirable. It's my understanding
> > that from the Kernel's perspective CHECKSUM_COMPLETE is preferable to
> > CHECKSUM_UNNECESSARY.
> > 
> > ...
> 
> Rx checksum offload is a new feature of ENETC v4. We would like to exploit this
> capability of the hardware to save CPU cycles in calculating and verifying checksum.
> 

Understood, but CHECKSUM_UNNECESSARY is usually the preferred option as it
is more flexible, e.g. allowing low-cost calculation of inner checksums
in the presence of encapsulation.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ