From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=185.246.84.56 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796536613; b=4H4KS1gHG/IxNniZO0BMYQJDJ97mrbvh30M0W/6h62+7eKJLWb7W8smNjhnxA5cMd+m+ wFiPoOnYAB8fTVuZanSaIi8aTTJ2wE1QlFS9jYZh3JwYj269TWckA0RsIOes6X3U7iB27 fOXFSdWjcH59ASxBYuwwO24oS3RGHSdf824ms4DBzzEB75W88h1OhhGNDlNUOqAuklv5L 1hXebmRSb+tP9+0VwlZMF4DwmNoNX9BlYMDHl7MS2NmDT/3czQHCk+tbPdDelH7NhGSG1 /NPOOhvLhScSi0eZQXFmR+P0Lx64NKeb+zNJdpzgYBl/sz8d1JcxQ4DQxD6F/ZxloWQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796536613; h=DMARC-Filter:Received:Received:Received:DKIM-Signature:Message-ID: Date:MIME-Version:User-Agent:Subject:To:Cc:References: Content-Language:From:In-Reply-To:Content-Type: Content-Transfer-Encoding:X-Last-TLS-Session-Version; bh=Vx5ToooHmdO4LjXdCndrCeuwFCPXViyno9W+D5Pa/Jc=; b=WZLrRxWWRbhLeFOZzWIA1Tmtdb8pMVnWPvnNAloR528OptB597g6wM5H//eetqJ1maXv mPStCzjpNJjzm4M8aCuQZvHDOzBe3MY3gEYbHo86qTRqgagF5Llq8QsxPUmGBv0UsU6DV C5Jpiz06S6oFZIzIz2rMLCzPWqXIb9pgprAu/naAMM/Zf+iJaVEPZEtsxJJswg6eJAtNS gTA0tFTQ3FqXTv2bZj9Jbw3EZ5ura09CJLqj2AxjWY+fxjaV6XsYi6/cocqU3muT6TUQB pHgFQfSXOHb8MC3et8mmwyWqXlvQBK3VrAhjF9aAhFoOJDKbGT4OiozR+R+ow8zh4vA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass header.d=bootlin.com header.i=@bootlin.com header.a=rsa-sha256 header.s=dkim header.b=LwHdnpfp; arc=none smtp.remote-ip=185.246.84.56 Received: from smtpout-02.galae.net (smtpout-02.galae.net [185.246.84.56]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4FB45606A31F for ; Sun, 6 Dec 2026 05:56:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 4FB45606A31F Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=bootlin.com header.i=@bootlin.com header.a=rsa-sha256 header.s=dkim header.b=LwHdnpfp Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-02.galae.net (Postfix) with ESMTPS id 59CE01A1999; Sun, 6 Dec 2026 05:56:49 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 2499D604C0; Sun, 6 Dec 2026 05:56:49 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id D2E4411EA179C; Sun, 06 Dec 2026 06:56:42 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1796536608; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:content-language:in-reply-to:references; bh=Vx5ToooHmdO4LjXdCndrCeuwFCPXViyno9W+D5Pa/Jc=; b=LwHdnpfpQ0kqJN58N7PvRs3yDcmCD2jzGPWWV93CmH20g4XU8FLZa0gLHYu3Pb+/PqX3kK JsCLnQv8Gc8xKt0ytxIu4LsIvlv/Qxm6N527tzqGC/bSshzVndY9T6Thlr++LBCe0zSuE8 36ubyOURk/f22G5QL9BXz4ilH60HwitZfnBHrlIJaw7OdQKJDk3Iz6g0bq+NTaiNstEtW6 KMzn8dw0LvdJp8+v8NNoVgff58zx99e+nU6fHZjpn6KIIq4JOAWUjjtqH342ecJ29A3TcN dA29bqmKYYzcpLXYq3m48kB0tmzlevvyDqGCePeabbXdDCsQzl/SKjDjQtma1A== Message-ID: <5d6b1d95-d942-4cb8-b452-29f980223c27@bootlin.com> Date: Sun, 6 Dec 2026 06:56:41 +0100 X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH net] net: stmmac: do not toggle RX VLAN offload while running To: Lorenzo Bianconi , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin , Alexandre Torgue , Lai Peter Jun Ann Cc: netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org References: <20261205-stmmac-do-not-flip-vlan-offload-v1-1-5b3fa52c306b@oss.qualcomm.com> Content-Language: en-US From: Maxime Chevallier In-Reply-To: <20261205-stmmac-do-not-flip-vlan-offload-v1-1-5b3fa52c306b@oss.qualcomm.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Last-TLS-Session-Version: TLSv1.3 Hi Lorenzo, On 12/5/26 18:26, Lorenzo Bianconi wrote: > The RX VLAN offload mode is consumed by the receive path: stmmac_rx() > and stmmac_dispatch_skb_zc() use hw_vlan_en to decide whether to take > the VLAN tag from the RX descriptor, and the software stripping path > uses the advertised RX VLAN feature bits. > > stmmac_set_features() changes that state at runtime, while RX NAPI can > run concurrently. A frame received with one setting can therefore be > processed after the setting has changed, which may lose a tag that was > stripped or duplicate a tag that is still in the frame. The MAC register > update also cannot be made atomic with respect to frames already in > flight without stopping RX DMA and flushing the descriptor rings. > > Since this is an RX offload mode change and there is no cheap way to > synchronize it with the receive path, only allow it while the interface > is down. Mask the RX VLAN feature bits back to their currently advertised > state in stmmac_fix_features() when the device is running, so > ndo_set_features() never changes the mode under a live RX path. A request > made while the interface is running is ignored and is not deferred to the > next open; userspace must bring the interface down to change the RX VLAN > offload. > > Fixes: 750011e239a5 ("net: stmmac: Add support for HW-accelerated VLAN stripping") > Signed-off-by: Lorenzo Bianconi This triggered some new failures on the Netdev CI for 6 stmmac runners: - https://netdevci.bootlin.com/stmmac/outputs/941929-bootlin-stmmac-rk3568/test-outputs/24-vlan-py/ - https://netdevci.bootlin.com/stmmac/outputs/941929-bootlin-stmmac-imx8mp/test-outputs/24-vlan-py/ - https://netdevci.bootlin.com/stmmac/outputs/941929-bootlin-stmmac-jh7110/test-outputs/24-vlan-py/ - https://netdevci.bootlin.com/stmmac/outputs/941929-bootlin-stmmac-socfpga-agilex5/test-outputs/24-vlan-py/ - https://netdevci.bootlin.com/stmmac/outputs/941929-bootlin-stmmac-stm32mp1/test-outputs/24-vlan-py/ - https://netdevci.bootlin.com/stmmac/outputs/941929-bootlin-stmmac-stm32mp2/test-outputs/24-vlan-py/ The test fails precisely because we can't switch offload mode while interface is on. Besides the selftest, is it worth fixing ? We may have an error on one frame while it's being actively reconfigured, I guess a lot of other drivers are subject to the same class of problem... Is it a bit too defensive ? I may be wrong here, I don't know exactly what's the netdev policy regarding wether it's OK to have potentially one frame corrupt while the user is reconfiguring offloads... Maxime > --- > drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 11 +++++++++++ > 1 file changed, 11 insertions(+) > > diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c > index d32d3e7b1b8c..b978e64399d4 100644 > --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c > +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c > @@ -6371,6 +6371,8 @@ static netdev_features_t stmmac_fix_features(struct net_device *dev, > netdev_features_t features) > { > struct stmmac_priv *priv = netdev_priv(dev); > + netdev_features_t vlan_rx = NETIF_F_HW_VLAN_CTAG_RX | > + NETIF_F_HW_VLAN_STAG_RX; > > if (priv->plat->rx_coe == STMMAC_RX_COE_NONE) > features &= ~NETIF_F_RXCSUM; > @@ -6393,6 +6395,15 @@ static netdev_features_t stmmac_fix_features(struct net_device *dev, > features &= ~NETIF_F_HW_VLAN_STAG_RX; > } > > + /* The RX VLAN mode cannot be changed while RX is running: frames > + * received under the old mode might otherwise be processed with the > + * new one. Keep the current mode and defer the change until the > + * interface is down. > + */ > + if (netif_running(dev) && > + (features & vlan_rx) != (dev->features & vlan_rx)) > + features = (features & ~vlan_rx) | (dev->features & vlan_rx); > + > return features; > } > > > --- > base-commit: e9d78fc6741ac06d438cf64e314c28e57014432a > change-id: 20261205-stmmac-do-not-flip-vlan-offload-613a9cad635b > > Best regards,