From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 686BCC3DA79 for ; Sat, 13 Jan 2024 02:16:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=AepddBl2YYUD/kow6RCLHPPEmdUuS3/gxiipkOy7yY4=; b=G9TuucvSB3drf/ 6IcB9KZQ1U4aYt9iGWAKiEAEE8IV7516vkqbytzh65M2cuRB+YdgvnVVQNVNDISg9rSZg90rpuKeo wZ4VZdksLVUTYRJoRQLIGdAv5F7ZU8f2rD3D8oXVY2IVYNxZ0y7kvlul1LvS2ch16ynfPW/JxzRYJ CpnOUOQ2gHxBhp3vVZQyFdIRZ/l4LZMtw6jSiDYGmXiPN99pEbV1zz/a0cbQiMcjR77AmDoxO+4Wl 2URpOZo10jUZcnwKSetuGJ76H6QKI9ffqpAfxUCo1/YXNkZcIoZpfz5MRaEUTkBvSp0/VrX7whRLX FhuLUpxmcesrtulVNwvA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rOTXE-004RFT-1F; Sat, 13 Jan 2024 02:14:08 +0000 Received: from ams.source.kernel.org ([145.40.68.75]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rOTX8-004REq-1n for linux-arm-kernel@lists.infradead.org; Sat, 13 Jan 2024 02:14:04 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by ams.source.kernel.org (Postfix) with ESMTP id 777C6B82416; Sat, 13 Jan 2024 02:13:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F3378C433C7; Sat, 13 Jan 2024 02:13:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705112009; bh=5ognxcE1HcI052/VObEGy4guszc42K8ozoLqQioknjI=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=Db8vIRk4Ae3BQLrgCp+c/2hJK3FZun1UD1mAy8lg/2z/iWzQBR+nSOmSmatK2Vu8U OrAGcFYQEKp4HQzwOs6jQyhINXj10TqS4Ahx1/YSGu/SpaRFTiObr0Sz/UF8bw4gdb CmS5mKqcM46hwGLJNWARbSWlCIXKEoS7mX1ezjHU9mKr7GZx7vkvGJReT8AFxgoyeO uLAsw6Vgn6/VOVN1DjXGQrX9hw4ptlqAO5W/8DzO2y5CWAbJKcbvz+g+aOfYf2inPf KDyqgheBVC2+zT6i+6bW8/rizBsaZiBJhtOonvdUaSG46N1RKnIXIpPoYNcCjeUAQh 54nAoBwyugGdg== Date: Fri, 12 Jan 2024 18:13:27 -0800 From: Jakub Kicinski To: Romain Gantois Cc: Alexandre Torgue , Jose Abreu , "David S. Miller" , Eric Dumazet , Paolo Abeni , Maxime Coquelin , Miquel Raynal , Maxime Chevallier , Sylvain Girard , Pascal EBERHARD , Richard Tresidder , Linus Walleij , Vladimir Oltean , Andrew Lunn , Thomas Petazzoni , netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, stable@vger.kernel.org, Vladimir Oltean Subject: Re: [PATCH net v5] net: stmmac: Prevent DSA tags from breaking COE Message-ID: <20240112181327.505b424e@kernel.org> In-Reply-To: <20240111-prevent_dsa_tags-v5-1-63e795a4d129@bootlin.com> References: <20240111-prevent_dsa_tags-v5-1-63e795a4d129@bootlin.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240112_181402_941067_6D33809E X-CRM114-Status: GOOD ( 16.82 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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: 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