From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796467546; b=N5E1mqyeH2KVWWn0j4INbcW6Ik9HSLnGIcpKWNoPGwTl7QZFUJh6ViXoi3IVQ/mO/nWn D3FV0gVVtArMx8JBSITPYStpzNkIKXLcP9pT5Q2Ef1jQWdgpd4MNMZH9HFCnD0sdsLlRF UE3NFQHVZiQvUFjNchc91O8/z0OwCBR8huQ8snG6A1Iiq74r6VHv9/828bu4/nFeDMMNg 4vWX2QX7UW95mOlE7/Y03gQPwLD2oOdf3OkxWq2K8IQQQ8CmQi3dcqJ52nGhuMu3F0+cx +wb2+da7iJs2/5QOskyHmHvdrj4TZ8i5nllCG7ijQjFk7A/AgbJa0CRqfzaTIq7r4XA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796467546; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=n10XgXZ1q8hTvgsmelRW1zV+l95EwEDkdkMAg+j6czE=; b=hUe/ovhNsnzgz44cJeQvb6fpRZTgRhcet49wJac6a2sIrVr/nhbENLfdHRPAPOAmoxzR q2dtyF3bLfzk2IC+hkadvlWyZ1zawBW5vWrFqL7+hgW9UeEcgFlf2lik06OJiuqGtAfmj JIwgoahF6saeAZDUepzWuDJHKhvSctJAD5q/PWY+JvVE1E6de1b4JXa5f0iL4uGBlH23+ ADr7gJJ+ohkgbUgu573IGoilpcIrktAhhxWg6T/NELDzhg5x97Pe/4PFLfcMC9Q4ENGlp FePDyxqFL9tJRgfsstGVokLM29x9xl4e37uDfSAhfzFvMEOT4CEpd48TJ27zdcbO1hA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=mQCP+KIL; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 78FAA606A322 for ; Sat, 5 Dec 2026 10:45:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=mQCP+KIL Received: by smtp.kernel.org (Postfix) with ESMTPSA id 45D2F1F00936; Sat, 5 Dec 2026 10:45:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796467546; bh=n10XgXZ1q8hTvgsmelRW1zV+l95EwEDkdkMAg+j6czE=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=mQCP+KILxkkPYCF+rcRbasGjvAi1v8gtQcheK/dMvYtIy0EPbaAultuwLQElIi+3L ca+N4XkQvPUnFPpJw5bZlbQ3GTjSXKjauHsAPv+2laSWAU9sk2FdyS19eH7pUOCjpP RMr1Dk6Q9ucjWCDI7oVViw3rndDsdqNa0MyuscVp8AnlYHVkd98nthW65GAa3kNIag yr26Am8s5VmE3pkflcB7jFwczU6SuyLj0QR25EK381wxNhzBN+nZjv65zYVNTmmwAP 9uFTpHvcLfUNayQHbUqwGUwmV8CPiptRLt9aiNFdHz9EKuFQ8WZvdYYgUJKMTulOz8 e3+5ej2tH6zgQ== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH net-next v14 2/5] net: stmmac: remove software VLAN tag stripping Reply-To: sashiko-reviews@lists.linux.dev To: "Lorenzo Bianconi" Cc: bpf@vger.kernel.org In-Reply-To: <20261204-stmmac-rx-mb-v14-2-5506796fd39e@oss.qualcomm.com> References: <20261204-stmmac-rx-mb-v14-0-5506796fd39e@oss.qualcomm.com> <20261204-stmmac-rx-mb-v14-2-5506796fd39e@oss.qualcomm.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Sat, 05 Dec 2026 10:45:45 +0000 X-Mailing-List: bpf@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 3 potential issues to consider: - [Medium] net: stmmac: data race and TOCTOU on hw_vlan_en in stmmac_set_features() - [Medium] net: stmmac: VLAN feature gating enables EEE RXC stop on dwmac1000/DWXLGMAC - [Low] net: stmmac: Fixes tag queues broad non-backportable VLAN cleanup to stable -- commit 5b78ea93f852617d0df5a6496b17b18f659bcb2d Author: Lorenzo Bianconi > net: stmmac: remove software VLAN tag stripping > > The software VLAN stripping logic in stmmac_rx_vlan() was originally > introduced in 2014 by 'commit b93819854d6e ("stmmac: Add vlan rx for > better GRO performance.")' as a workaround to improve GRO performance, > since at that time GRO could not handle frames with VLAN tags. However, > this limitation was resolved in 2015 by 'commit 66e5133f19e9 ("vlan: Add > GRO support for non hardware accelerated vlan")', which added GRO support > for non-hardware-accelerated VLAN frames. Keeping a software fallback > path for VLAN stripping is no longer necessary and only adds complexity. > > After removing it, VLAN tags remain in the packet, so > stmmac_has_ip_ethertype() has to keep recognising IPv4/IPv6 behind a > single in-payload VLAN tag. On RX the helper runs after eth_type_trans(), > which has already pulled the Ethernet header, so walk the tag chain with > skb_mac_offset() instead of __vlan_get_protocol(), which assumes the MAC > header still sits at skb->data. On TX the helper still runs before the > header is pulled. > > Make the tolerated L2 depth explicit: > - on RX allow a single in-payload C-tag while the MAC is not stripping > tags (VLAN_ETH_HLEN); when HW stripping is active the payload must be > tag-free, so keep the ETH_HLEN limit and reject any tag that is still > there; > - in-payload S-tags are always rejected, as only an S-tag that the > hardware stripped (and whose type is reported through > get_rx_vlan_proto) is known to have been parsed by the checksum engine; > - on TX keep the old ETH_HLEN limit, so DSA-tagged frames that the > checksum engine ignores (see commit c2945c435c99 ("net: stmmac: > Prevent DSA tags from breaking COE")) remain excluded from hardware > checksum and TSO. > > This intentionally changes the advertised features: > - dwmac100/dwmac1000 no longer advertise NETIF_F_HW_VLAN_CTAG_RX; > they have no hardware VLAN stripping. > - On xmac cores NETIF_F_HW_VLAN_CTAG_RX is advertised only when the > VLAN ops provide .set_hw_vlan_mode and .rx_hw_vlan, so DWXLGMAC no > longer falsely advertises RX VLAN offload. > - NETIF_F_HW_VLAN_STAG_RX is advertised only on cores that provide > hardware RX VLAN offload and whose descriptor ops report the stripped > tag protocol (get_rx_vlan_proto), i.e. DWXGMAC. DWXLGMAC loses it > because it has no RX VLAN offload, while cores without > get_rx_vlan_proto report stripped S-tags as C-tags. > > The DWXLGMAC mis-advertisement was introduced by 'commit 534df0c1724b > ("net: stmmac: dwxgmac2: Add support for HW-accelerated VLAN stripping"), > which widened the RX VLAN offload gate from GMAC4 to all xmac cores but > only added .rx_hw_vlan to dwxgmac210_vlan_ops. DWXLGMAC is also > DWMAC_CORE_XGMAC, and dwxlgmac2_vlan_ops has no .rx_hw_vlan, so it ended > up advertising RX VLAN offload while neither hardware nor software > stripped the tag. Tag the fix accordingly. > > With NETIF_F_VLAN_FEATURES possibly empty, stmmac_phylink_setup() may > now allow the PHY to stop the RX clock in LPI on cores that no longer > advertise any VLAN feature, for example dwmac1000 with EEE and DWXLGMAC > without vlhash/vlins. The MAC needs RXC running for some register > accesses, including the MAC address and filter registers written by > stmmac_set_rx_mode(). That callback runs with bottom halves disabled and > cannot use phylink_rx_clk_stop_block(), so a multicast, unicast or > promiscuous update could be lost while the clock is stopped. > > This is not a new failure mode: the same window already exists with > CONFIG_VLAN_8021Q=3Dn and existed before 'commit c171e679ee66 ("net: stmm= ac: > Disable EEE RX clock stop when VLAN is enabled"), whose VLAN feature > check only guarded it incidentally. dwmac100 is unaffected because it > has no EEE. > > This will be addressed by a dedicated follow-up patch that decouples the > EEE RX clock-stop policy from the advertised VLAN features and makes the > atomic register accesses safe. The preceding selftests patch already > blocks RX clock stop while the ethtool selftests run. > > This depends on the preceding selftests fix. > > Fixes: 534df0c1724b ("net: stmmac: dwxgmac2: Add support for HW-accelerat= ed VLAN stripping") > Suggested-by: Maxime Chevallier > Co-developed-by: Peilin He > Signed-off-by: Peilin He > Reviewed-by: Maxime Chevallier > Signed-off-by: Lorenzo Bianconi [Severity: Low] Should this patch carry Fixes: 534df0c1724b ("net: stmmac: dwxgmac2: Add support for HW-accelerated VLAN stripping")? In netdev, a Fixes: tag queues the commit for automated stable backporting, but this change cannot be backported standalone to stable trees carrying 534df0c1724b: stmmac_has_ip_ethertype() calls vlan_get_protocol_offset_inline() from 7a4cd71fa451 ("net: add vlan_get_protocol_offset_inline() helper"), and the patch depends on commit "net: stmmac: selftests: Prevent RXC from being disabled in LPI". It also bundles the narrow DWXLGMAC fix with removing stmmac_rx_vlan(), dropping NETIF_F_HW_VLAN_CTAG_RX on dwmac100/dwmac1000, and exposing the EEE RX clock-stop window noted above. Splitting out the DWXLGMAC advertisement fix for net/stable, or dropping the Fixes: tag here, would avoid broken backports. [ ... ] > diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/= net/ethernet/stmicro/stmmac/stmmac_main.c > index b3524d46863da..c429cb9e1ccbe 100644 > --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c > +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c > @@ -4893,16 +4895,25 @@ static netdev_tx_t stmmac_tso_xmit(struct sk_buff= *skb, struct net_device *dev) > * Return: true if the ethertype can trigger the checksum engine, false > * otherwise > */ > -static bool stmmac_has_ip_ethertype(struct sk_buff *skb) > +static bool stmmac_has_ip_ethertype(struct stmmac_priv *priv, > + struct sk_buff *skb, bool xmit) > { > - int depth =3D 0; > - __be16 proto; > + __be16 proto, h_proto =3D eth_header_parse_protocol(skb); > + int max_l2_hlen, depth =3D 0; > + > + /* An S-tag still in the payload may not have been parsed by the > + * checksum engine; only trust it when the hardware stripped it, in > + * which case h_proto is no longer ETH_P_8021AD. > + */ > + if (h_proto =3D=3D htons(ETH_P_8021AD)) > + return false; > =20 > - proto =3D __vlan_get_protocol(skb, eth_header_parse_protocol(skb), > - &depth); > + proto =3D vlan_get_protocol_offset_inline(skb, h_proto, > + skb_mac_offset(skb), &depth); > =20 > - return (depth <=3D ETH_HLEN) && > - (proto =3D=3D htons(ETH_P_IP) || proto =3D=3D htons(ETH_P_IPV6)); > + max_l2_hlen =3D xmit || priv->hw->hw_vlan_en ? ETH_HLEN : VLAN_ETH_HLEN; > + return depth <=3D max_l2_hlen && > + (proto =3D=3D htons(ETH_P_IP) || proto =3D=3D htons(ETH_P_IPV6)); > } [Severity: Medium] Can concurrent ethtool -K rxvlan toggling race with RX polling on priv->hw->hw_vlan_en? stmmac_set_features() writes priv->hw->hw_vlan_en under rtnl_lock() without stopping NAPI or using WRITE_ONCE(), while stmmac_rx() and stmmac_dispatch_skb_zc() now read it twice per packet without locking: once before stmmac_rx_hw_vlan() and again inside stmmac_has_ip_ethertype(). CPU0 CPU1 stmmac_set_features() stmmac_rx() (ethtool -K rxvlan off) if (priv->hw->hw_vlan_en) /* true */ stmmac_rx_hw_vlan(...) eth_type_trans(...) priv->hw->hw_vlan_en =3D false; phylink_rx_clk_stop_block(...) stmmac_has_ip_ethertype(...) priv->hw->hw_vlan_en /* false */ max_l2_hlen =3D VLAN_ETH_HLEN <-- inner C-tag marked UNNECESSARY On a double-tagged frame whose outer tag hardware already stripped, reading true then false lets stmmac_has_ip_ethertype() accept the remaining inner C-tag and mark the frame CHECKSUM_UNNECESSARY. This also compounds the window where stmmac_set_features() flips hw_vlan_en before sleeping in phylink_rx_clk_stop_block() and before stmmac_set_hw_vlan_mode() updates the hardware register: toggling rxvlan on can duplicate an unstripped tag, while toggling it off can drop a stripped tag. Passing a single READ_ONCE(priv->hw->hw_vlan_en) snapshot into stmmac_has_ip_ethertype() avoids the per-packet mismatch, and synchronizing the flag update with NAPI/RX programming avoids the hardware/software window. [ ... ] > @@ -8282,15 +8255,15 @@ static int __stmmac_dvr_probe(struct device *devi= ce, > ndev->features |=3D ndev->hw_features | NETIF_F_HIGHDMA; > ndev->watchdog_timeo =3D msecs_to_jiffies(watchdog); > #ifdef STMMAC_VLAN_TAG_USED > - /* Both mac100 and gmac support receive VLAN tag detection */ > - ndev->features |=3D NETIF_F_HW_VLAN_CTAG_RX; > - if (priv->plat->core_type =3D=3D DWMAC_CORE_XGMAC) > - ndev->features |=3D NETIF_F_HW_VLAN_STAG_RX; > - > - if (dwmac_is_xmac(priv->plat->core_type)) { > + if (stmmac_rx_8021q_offload(priv)) { > + ndev->features |=3D NETIF_F_HW_VLAN_CTAG_RX; > ndev->hw_features |=3D NETIF_F_HW_VLAN_CTAG_RX; > priv->hw->hw_vlan_en =3D true; > } > + > + if (stmmac_rx_8021ad_offload(priv)) > + ndev->features |=3D NETIF_F_HW_VLAN_STAG_RX; > + > if (priv->dma_cap.vlhash) { > ndev->features |=3D NETIF_F_HW_VLAN_CTAG_FILTER; > if (priv->plat->core_type =3D=3D DWMAC_CORE_XGMAC) [Severity: Medium] Can gating NETIF_F_HW_VLAN_CTAG_RX here cause stmmac_set_rx_mode() register writes to be lost on dwmac1000 and DWXLGMAC? Previously, with CONFIG_VLAN_8021Q enabled, __stmmac_dvr_probe() always set NETIF_F_HW_VLAN_CTAG_RX, keeping NETIF_F_VLAN_FEATURES non-empty so stmmac_phylink_setup() left config->eee_rx_clk_stop_enable false. Now dwmac1000 (which has no vlan ops and no vlhash/vlins, but supports EEE) and DWXLGMAC without vlhash/vlins leave NETIF_F_VLAN_FEATURES empty, enabling PHY RX clock stop in LPI. Because stmmac_set_rx_mode() runs with bottom halves disabled and cannot call phylink_rx_clk_stop_block(), multicast, unicast, or promiscuous filter updates can be silently dropped while RXC is stopped. The commit message defers decoupling EEE RX clock stop from NETIF_F_VLAN_FEATURES to a future patch outside this series; should that fix land before gating NETIF_F_HW_VLAN_CTAG_RX here? --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261204-stmmac-rx-= mb-v14-0-5506796fd39e@oss.qualcomm.com?part=3D2