linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Jakub Kicinski <kuba@kernel.org>
To: Romain Gantois <romain.gantois@bootlin.com>
Cc: Alexandre Torgue <alexandre.torgue@foss.st.com>,
	Jose Abreu <joabreu@synopsys.com>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Paolo Abeni <pabeni@redhat.com>,
	Maxime Coquelin <mcoquelin.stm32@gmail.com>,
	Miquel Raynal <miquel.raynal@bootlin.com>,
	Maxime Chevallier <maxime.chevallier@bootlin.com>,
	Sylvain Girard <sylvain.girard@se.com>,
	Pascal EBERHARD <pascal.eberhard@se.com>,
	Richard Tresidder <rtresidd@electromag.com.au>,
	Linus Walleij <linus.walleij@linaro.org>,
	Vladimir Oltean <olteanv@gmail.com>, Andrew Lunn <andrew@lunn.ch>,
	Thomas Petazzoni <thomas.petazzoni@bootlin.com>,
	netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com,
	linux-arm-kernel@lists.infradead.org, stable@vger.kernel.org,
	Vladimir Oltean <vladimir.oltean@nxp.com>
Subject: Re: [PATCH net v5] net: stmmac: Prevent DSA tags from breaking COE
Date: Fri, 12 Jan 2024 18:13:27 -0800	[thread overview]
Message-ID: <20240112181327.505b424e@kernel.org> (raw)
In-Reply-To: <20240111-prevent_dsa_tags-v5-1-63e795a4d129@bootlin.com>

On Thu, 11 Jan 2024 15:58:51 +0100 Romain Gantois wrote:
> Some DSA tagging protocols change the EtherType field in the MAC header
> e.g.  DSA_TAG_PROTO_(DSA/EDSA/BRCM/MTK/RTL4C_A/SJA1105). On TX these tagged
> frames are ignored by the checksum offload engine and IP header checker of
> some stmmac cores.
> 
> On RX, the stmmac driver wrongly assumes that checksums have been computed
> for these tagged packets, and sets CHECKSUM_UNNECESSARY.
> 
> Add an additional check in the stmmac TX and RX hotpaths so that COE is
> deactivated for packets with ethertypes that will not trigger the COE and
> IP header checks.
> 
> Fixes: 6b2c6e4a938f ("net: stmmac: propagate feature flags to vlan")
> Cc:  <stable@vger.kernel.org>

nit: double space

> +/**
> + * stmmac_has_ip_ethertype() - Check if packet has IP ethertype
> + * @skb: socket buffer to check
> + *
> + * Check if a packet has an ethertype that will trigger the IP header checks
> + * and IP/TCP checksum engine of the stmmac core.
> + *
> + * Return: true if the ethertype can trigger the checksum engine, false otherwise

nit: please don't go over 80 chars unless there's a good reason.
we are old school and stick to checkpatch --max-line-length=80 in netdev

>  	if (csum_insertion &&
> -	    priv->plat->tx_queues_cfg[queue].coe_unsupported) {
> +	    (priv->plat->tx_queues_cfg[queue].coe_unsupported ||
> +	    !stmmac_has_ip_ethertype(skb))) {

nit: minor misalignment here, the '!' should be under 'p'

>  		if (unlikely(skb_checksum_help(skb)))
>  			goto dma_map_err;
>  		csum_insertion = !csum_insertion;
> @@ -4997,7 +5020,7 @@ static void stmmac_dispatch_skb_zc(struct stmmac_priv *priv, u32 queue,
>  	stmmac_rx_vlan(priv->dev, skb);
>  	skb->protocol = eth_type_trans(skb, priv->dev);
>  
> -	if (unlikely(!coe))
> +	if (unlikely(!coe) || !stmmac_has_ip_ethertype(skb))

The lack of Rx side COE checking in this driver is kinda crazy.
Looking at enh_desc_coe_rdes0() it seems like RDES0_FRAME_TYPE
may be the indication we need here? 

We can dig into it as a follow up but I'm guessing that sending
an IPv6 packet with extension headers will also make the device
skip checksumming, or a UDP packet with csum of 0?

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2024-01-13  2:16 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-11 14:58 [PATCH net v5] net: stmmac: Prevent DSA tags from breaking COE Romain Gantois
2024-01-13  2:13 ` Jakub Kicinski [this message]
2024-01-16 12:14   ` Romain Gantois
2024-01-16 15:23     ` Jakub Kicinski
2024-01-16 16:18       ` Romain Gantois
2024-01-16 18:36         ` 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=20240112181327.505b424e@kernel.org \
    --to=kuba@kernel.org \
    --cc=alexandre.torgue@foss.st.com \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=joabreu@synopsys.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-stm32@st-md-mailman.stormreply.com \
    --cc=maxime.chevallier@bootlin.com \
    --cc=mcoquelin.stm32@gmail.com \
    --cc=miquel.raynal@bootlin.com \
    --cc=netdev@vger.kernel.org \
    --cc=olteanv@gmail.com \
    --cc=pabeni@redhat.com \
    --cc=pascal.eberhard@se.com \
    --cc=romain.gantois@bootlin.com \
    --cc=rtresidd@electromag.com.au \
    --cc=stable@vger.kernel.org \
    --cc=sylvain.girard@se.com \
    --cc=thomas.petazzoni@bootlin.com \
    --cc=vladimir.oltean@nxp.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;
as well as URLs for NNTP newsgroup(s).