From nobody Fri Sep 25 13:16:57 2026 Received: from smtpout-04.galae.net (smtpout-04.galae.net [185.171.202.116]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BE6A457ED98 for ; Fri, 11 Sep 2026 21:21:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.171.202.116 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789161670; cv=none; b=Y2pgLas+NH+wrcGCWig8qOoUR+iuyhWQRD1rrD44CJTkFAfUqPFkupXpBJzMnebCsNlqoCgafDil2aGVkSoU6alhNCrd25I/vZxil8BGchFOSRwDagu+KnH2YH9sWggkpYjskA1HDb+kFsrmDEgg0v9DUVQyEsmkaijqq/7cJXE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789161670; c=relaxed/simple; bh=7pira/Itzz3rt5Mowwcd8v5tFyFrbvGMwM9PTuvAQqY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=T9gtdQk8T0q8zJ44PTmdLD11JQRRnl++6iS1JxI4w2gH4whFpJdQOrfeMICvhyzK+NSLLOu4X2agal/LxM3EJm2QxEYR+5qX86rV/M9lSiuMXSazAcuAEo/80/YxK4blpni+iiCaPYfnN5SNCUweWZ5wIH54lDNJxjH7XqJVXLI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=tBMMVrjG; arc=none smtp.client-ip=185.171.202.116 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) header.d=bootlin.com header.i=@bootlin.com header.b="tBMMVrjG" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-04.galae.net (Postfix) with ESMTPS id 48E79C63A11; Fri, 11 Sep 2026 21:21:40 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 5A4E4601A3; Fri, 11 Sep 2026 21:20:58 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id B16EB11C7A9DC; Fri, 11 Sep 2026 23:20:48 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1789161652; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding:in-reply-to:references; bh=alhSdTU+WSc1RGEtM98aWp0kuu26VmSDDIWj2jWxOk4=; b=tBMMVrjGExTfza6tHxixi2E+c8uLvUSDYTqcN156DvKYWt5NUSaZLSzWtVj8EYtH/oBCUJ 9JbUbrKqPo1l0DaAJbHGqwXt/0IK2NROJmg0MS35VcYP5AssMC+FikufJ4uTUSi3tkSOMw 41NLKgQEqi7/A9mAJ53odWu7KMMhtkr4qZ92kKScgScyXKOZKKogRYZUmj7VQto9XvsH0Z npzqg5vD6Ft4wP+UtQW2mzaopqWe7yIlmrY6mrNqvmEErJbyd4aeRcKW4mUFcGr+JeMRbs mJAxdXr0JAJLcE1h6eK/ywakOGkcEyVQD9HKCwEQIe4wtGUZP2GNUmDBdwKeBw== From: Maxime Chevallier To: Andrew Lunn , davem@davemloft.net, Eric Dumazet , Jakub Kicinski , Paolo Abeni , Russell King , Heiner Kallweit , =?UTF-8?q?Alexis=20Lothor=C3=A9?= , Maxime Coquelin , Alexandre Torgue , Emil Renner Berthing , Minda Chen , Neil Armstrong , Kevin Hilman , Jerome Brunet , Martin Blumenstingl , Jan Petrous , Ovidiu Panait , Jose.Abreu@synopsys.com, Nicolai Buchwitz Cc: Maxime Chevallier , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, thomas.petazzoni@bootlin.com, linux-arm-kernel@lists.infradead.org, linux-stm32@st-md-mailman.stormreply.com, PKneuper@dspace.de, David Laight Subject: [PATCH net v3 1/6] net: stmmac: selftests: Support running selftests on DSA conduits Date: Fri, 11 Sep 2026 23:20:21 +0200 Message-ID: <20260911212028.1497613-2-maxime.chevallier@bootlin.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260911212028.1497613-1-maxime.chevallier@bootlin.com> References: <20260911212028.1497613-1-maxime.chevallier@bootlin.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Last-TLS-Session-Version: TLSv1.3 Content-Type: text/plain; charset="utf-8" Most stmmac selftests rely on dev_add_pack() to add custom handlers, that validate the packets sent to ourselves through MAC loopback. However, when the stmmac-driven interface is a DSA CPU conduit, all frames that are received have ETH_P_XDSA as a protocol, even though they don't actually contain any tag as they come from the loopback and not the switch. This will prevent any incoming packet to match our packet handlers. Let's register a ETH_P_ALL packet handler when we detect that we're a DSA conduit, and use a proxy packet handler to filter the h_proto. Note that we may still receive incoming packets from the switch, but these frames shouldn't interfere with the very specific frames used for selftests, and stmmac selftests in general aren't safe against external traffic interferences. This was validated on a WPQ864 devkit for IPQ8064, that has the SoC connected to a QCA8k switch. The ARP offload's packet handler is left alone, this feature is just not implemented in stmmac and due for removal. Fixes: 091810dbded9 ("net: stmmac: Introduce selftests support") Reviewed-by: Nicolai Buchwitz Signed-off-by: Maxime Chevallier --- .../stmicro/stmmac/stmmac_selftests.c | 68 ++++++++++++++++--- 1 file changed, 58 insertions(+), 10 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_selftests.c b/drive= rs/net/ethernet/stmicro/stmmac/stmmac_selftests.c index 6372ec7c3f31..6503678b646e 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_selftests.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_selftests.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -237,6 +238,9 @@ struct stmmac_test_priv { struct stmmac_packet_attrs *packet; struct packet_type pt; struct completion comp; + __be16 packet_type; + int (*func)(struct sk_buff *skb, struct net_device *ndev, + struct packet_type *pt, struct net_device *orig_ndev); int double_vlan; int vlan_id; int ok; @@ -316,6 +320,50 @@ static int stmmac_test_loopback_validate(struct sk_buf= f *skb, return 0; } =20 +static int stmmac_sft_filter(struct sk_buff *skb, struct net_device *ndev, + struct packet_type *pt, + struct net_device *orig_ndev) +{ + struct stmmac_test_priv *tpriv =3D pt->af_packet_priv; + struct ethhdr *hdr =3D eth_hdr(skb); + int ret =3D 0; + + if (hdr->h_proto =3D=3D tpriv->packet_type) { + struct sk_buff *nskb =3D skb_clone(skb, GFP_ATOMIC); + + if (nskb) + ret =3D tpriv->func(nskb, ndev, pt, orig_ndev); + } + + kfree_skb(skb); + return ret; +} + +static void stmmac_sft_add_pack(struct packet_type *pt) +{ + struct stmmac_test_priv *tpriv =3D pt->af_packet_priv; + + if (netdev_uses_dsa(tpriv->pt.dev)) { + tpriv->packet_type =3D tpriv->pt.type; + tpriv->func =3D tpriv->pt.func; + + /* DSA conduit will report ETH_P_XDSA, so our packet handler + * won't match. Let's register a ETH_P_ALL match and filter + * manually in stmmac_sft_filter. + */ + tpriv->pt.type =3D htons(ETH_P_ALL); + tpriv->pt.func =3D stmmac_sft_filter; + tpriv->pt.ignore_outgoing =3D true; + } + + dev_add_pack(pt); +} + +static void stmmac_sft_remove_pack(struct packet_type *pt) +{ + dev_remove_pack(pt); +} + static int __stmmac_test_loopback(struct stmmac_priv *priv, struct stmmac_packet_attrs *attr) { @@ -337,7 +385,7 @@ static int __stmmac_test_loopback(struct stmmac_priv *p= riv, tpriv->packet =3D attr; =20 if (!attr->dont_wait) - dev_add_pack(&tpriv->pt); + stmmac_sft_add_pack(&tpriv->pt); =20 skb =3D stmmac_test_get_udp_skb(priv, attr); if (!skb) { @@ -360,7 +408,7 @@ static int __stmmac_test_loopback(struct stmmac_priv *p= riv, =20 cleanup: if (!attr->dont_wait) - dev_remove_pack(&tpriv->pt); + stmmac_sft_remove_pack(&tpriv->pt); kfree(tpriv); return ret; } @@ -767,7 +815,7 @@ static int stmmac_test_flowctrl(struct stmmac_priv *pri= v) tpriv->pt.func =3D stmmac_test_flowctrl_validate; tpriv->pt.dev =3D priv->dev; tpriv->pt.af_packet_priv =3D tpriv; - dev_add_pack(&tpriv->pt); + stmmac_sft_add_pack(&tpriv->pt); =20 /* Compute minimum number of packets to make FIFO full */ pkt_count =3D rx_fifo_size; @@ -823,7 +871,7 @@ static int stmmac_test_flowctrl(struct stmmac_priv *pri= v) cleanup: dev_mc_del(priv->dev, paddr); dev_set_promiscuity(priv->dev, -1); - dev_remove_pack(&tpriv->pt); + stmmac_sft_remove_pack(&tpriv->pt); kfree(tpriv); return ret; } @@ -928,7 +976,7 @@ static int __stmmac_test_vlanfilt(struct stmmac_priv *p= riv) * HASH values. */ tpriv->vlan_id =3D 0x123; - dev_add_pack(&tpriv->pt); + stmmac_sft_add_pack(&tpriv->pt); =20 ret =3D vlan_vid_add(priv->dev, htons(ETH_P_8021Q), tpriv->vlan_id); if (ret) @@ -968,7 +1016,7 @@ static int __stmmac_test_vlanfilt(struct stmmac_priv *= priv) vlan_del: vlan_vid_del(priv->dev, htons(ETH_P_8021Q), tpriv->vlan_id); cleanup: - dev_remove_pack(&tpriv->pt); + stmmac_sft_remove_pack(&tpriv->pt); kfree(tpriv); return ret; } @@ -1022,7 +1070,7 @@ static int __stmmac_test_dvlanfilt(struct stmmac_priv= *priv) * HASH values. */ tpriv->vlan_id =3D 0x123; - dev_add_pack(&tpriv->pt); + stmmac_sft_add_pack(&tpriv->pt); =20 ret =3D vlan_vid_add(priv->dev, htons(ETH_P_8021AD), tpriv->vlan_id); if (ret) @@ -1062,7 +1110,7 @@ static int __stmmac_test_dvlanfilt(struct stmmac_priv= *priv) vlan_del: vlan_vid_del(priv->dev, htons(ETH_P_8021AD), tpriv->vlan_id); cleanup: - dev_remove_pack(&tpriv->pt); + stmmac_sft_remove_pack(&tpriv->pt); kfree(tpriv); return ret; } @@ -1293,7 +1341,7 @@ static int stmmac_test_vlanoff_common(struct stmmac_p= riv *priv, bool svlan) tpriv->pt.af_packet_priv =3D tpriv; tpriv->packet =3D &attr; tpriv->vlan_id =3D 0x123; - dev_add_pack(&tpriv->pt); + stmmac_sft_add_pack(&tpriv->pt); =20 ret =3D vlan_vid_add(priv->dev, htons(proto), tpriv->vlan_id); if (ret) @@ -1320,7 +1368,7 @@ static int stmmac_test_vlanoff_common(struct stmmac_p= riv *priv, bool svlan) vlan_del: vlan_vid_del(priv->dev, htons(proto), tpriv->vlan_id); cleanup: - dev_remove_pack(&tpriv->pt); + stmmac_sft_remove_pack(&tpriv->pt); kfree(tpriv); return ret; } --=20 2.55.0 From nobody Fri Sep 25 13:16:57 2026 Received: from smtpout-03.galae.net (smtpout-03.galae.net [185.246.85.4]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 43F1C530E1D for ; Fri, 11 Sep 2026 21:21:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.246.85.4 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789161670; cv=none; b=fAJmrftd/CWF0mPa2B7kHyraJN6UgDfAQaAQFFIUldHoTWhEpdBlxCcPvLLhPZDzNTIyExT/CUhwYqHlkjEMdhuL4Mx5MYqJKBox1KAJIRZA0suwJhVC+TiWL+J2hC9GNGUPmULlWUF8T8eSxLWe61nuRzGus9Z+laaB4D9HYVY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789161670; c=relaxed/simple; bh=RK38IZFLPu4ZNdz36EQmVTuMw3HAUKeLk91jdfgK/Lo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=LHprtwQB/CyPPtGoGGY0mDCbGw9JSPflP7lRlIsjew6qjmWiiNufxtUgCkle7X2mb8nXkKTqTGg9f6VU2fM+3/28HTz2z/yBC2ym4gMSgOvfZKTYbvdzNrJ3JHxwAJewSWoGPq8KD/iovPy6J7dKdU+Qgz1zyXnH7z0TsB58cgY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=k7okRelX; arc=none smtp.client-ip=185.246.85.4 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) header.d=bootlin.com header.i=@bootlin.com header.b="k7okRelX" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-03.galae.net (Postfix) with ESMTPS id 512844E4026D; Fri, 11 Sep 2026 21:21:06 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 1BBCA601A3; Fri, 11 Sep 2026 21:21:06 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 3BABE11C7A23F; Fri, 11 Sep 2026 23:20:57 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1789161660; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding:in-reply-to:references; bh=E53E+laYN2V9OrwunsngYOX3sgSFNZRroU2RxbAo3+g=; b=k7okRelX+F97+CgvB8hxPWdgZCN4Jcuo8AECXrt0Gz9P09JJEpFqGrDueFYp4y62XEU12r YV2Zh3+Tf0znV3ECJOUDxnSsveZrcchnwQc8EadD98uWcm4Eu1UgMS5sf9g5wfSNQ8kAsO WYmkOBn0BiayzPy7EdgP6DPYtp++/4y+xYGkEAghxrqMMRlu83AKtP+z1bKFMdLV3ie8lA w+ZmXL200BZXHZJ42lW3M/aIo/MS0yAbE0DLJ2nzjz0TMpxkfpFJSvT+RBNzG0a782p0Mi e/Oc6YwjZsCLYGLP4vZIs0EYLuHGvmR148t7tRPqdC0FbWxZL6gLCaRTJPgyEQ== From: Maxime Chevallier To: Andrew Lunn , davem@davemloft.net, Eric Dumazet , Jakub Kicinski , Paolo Abeni , Russell King , Heiner Kallweit , =?UTF-8?q?Alexis=20Lothor=C3=A9?= , Maxime Coquelin , Alexandre Torgue , Emil Renner Berthing , Minda Chen , Neil Armstrong , Kevin Hilman , Jerome Brunet , Martin Blumenstingl , Jan Petrous , Ovidiu Panait , Jose.Abreu@synopsys.com, Nicolai Buchwitz Cc: Maxime Chevallier , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, thomas.petazzoni@bootlin.com, linux-arm-kernel@lists.infradead.org, linux-stm32@st-md-mailman.stormreply.com, PKneuper@dspace.de, David Laight Subject: [PATCH net v3 2/6] net: stmmac: selftests: Validate EEE based on the actual LPI timer value Date: Fri, 11 Sep 2026 23:20:22 +0200 Message-ID: <20260911212028.1497613-3-maxime.chevallier@bootlin.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260911212028.1497613-1-maxime.chevallier@bootlin.com> References: <20260911212028.1497613-1-maxime.chevallier@bootlin.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Last-TLS-Session-Version: TLSv1.3 Content-Type: text/plain; charset="utf-8" The EEE selftest is a 2-step test : - It validates that we enter in LPI mode with the irq_tx_path_in_lpi_mode_n counter - It then validates that we exit LPI when sending a frame, with the irq_tx_path_exit_lpi_mode_n counter. The current state of the test lacks 2 main things : - We don't know exactly when was the previous frame sent (it's from the previous selftest) - The timeout is hardcoded, while the LPI is entered after a user-configurable delay. On top of that, the timeout loop uses a pre-decrement iterator (--retries) that actually only iterate nine times, so 900ms while the default LPI value is 1 second. Let's therefore make it more deterministic : - Send a frame at the beginning of the test - Wait for more than the lpi timer value, we timeout after about twice the value, - Then send another frame, and verify that we do go out of LPI, also with a timeout. As LPI timer can get pretty high, bail out if LPI timer is over 5 seconds. Note that the test's goal isn't to validate the LPI timer value itself, only that we enter/leave LPI mode. Fixes: 091810dbded9 ("net: stmmac: Introduce selftests support") Reviewed-by: Nicolai Buchwitz Signed-off-by: Maxime Chevallier --- .../stmicro/stmmac/stmmac_selftests.c | 44 ++++++++++++++++--- 1 file changed, 37 insertions(+), 7 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_selftests.c b/drive= rs/net/ethernet/stmicro/stmmac/stmmac_selftests.c index 6503678b646e..df28741abf2b 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_selftests.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_selftests.c @@ -30,6 +30,7 @@ struct stmmachdr { sizeof(struct stmmachdr)) #define STMMAC_TEST_PKT_MAGIC 0xdeadcafecafedeadULL #define STMMAC_LB_TIMEOUT msecs_to_jiffies(200) +#define STMMAC_SFT_MAX_LPI (5 * USEC_PER_SEC) =20 struct stmmac_packet_attrs { int vlan; @@ -462,12 +463,16 @@ static int stmmac_test_mmc(struct stmmac_priv *priv) static int stmmac_test_eee(struct stmmac_priv *priv) { struct stmmac_extra_stats *initial, *final; - int retries =3D 10; + unsigned long timeout, max_duration; int ret; =20 if (!priv->dma_cap.eee || !priv->eee_active) return -EOPNOTSUPP; =20 + /* Bail out if the configured LPI timer is too long */ + if (priv->tx_lpi_timer > STMMAC_SFT_MAX_LPI) + return -EOPNOTSUPP; + initial =3D kzalloc_obj(*initial); if (!initial) return -ENOMEM; @@ -478,14 +483,21 @@ static int stmmac_test_eee(struct stmmac_priv *priv) goto out_free_initial; } =20 + /* Snapshot stats, we want to count the in_lpi events. We may enter + * LPI just after the packet was sent. + */ memcpy(initial, &priv->xstats, sizeof(*initial)); =20 + /* Send a frame, then wait to enter LPI */ ret =3D stmmac_test_mac_loopback(priv); if (ret) goto out_free_final; =20 + max_duration =3D usecs_to_jiffies(2 * priv->tx_lpi_timer); + /* We have no traffic in the line so, sooner or later it will go LPI */ - while (--retries) { + timeout =3D jiffies + max_duration; + while (!time_after(jiffies, timeout)) { memcpy(final, &priv->xstats, sizeof(*final)); =20 if (final->irq_tx_path_in_lpi_mode_n > @@ -494,20 +506,38 @@ static int stmmac_test_eee(struct stmmac_priv *priv) msleep(100); } =20 - if (!retries) { + memcpy(final, &priv->xstats, sizeof(*final)); + if (final->irq_tx_path_in_lpi_mode_n <=3D + initial->irq_tx_path_in_lpi_mode_n) { ret =3D -ETIMEDOUT; goto out_free_final; } =20 - if (final->irq_tx_path_in_lpi_mode_n <=3D - initial->irq_tx_path_in_lpi_mode_n) { - ret =3D -EINVAL; + /* Re-snapshot, as we want to measure exit_lpi events. We should be + * in LPI right now. + */ + memcpy(initial, &priv->xstats, sizeof(*initial)); + + /* TX something so we go out of LPI */ + ret =3D stmmac_test_mac_loopback(priv); + if (ret) goto out_free_final; + + /* Wait for the exit LPI interrupt */ + timeout =3D jiffies + max_duration; + while (!time_after(jiffies, timeout)) { + memcpy(final, &priv->xstats, sizeof(*final)); + + if (final->irq_tx_path_exit_lpi_mode_n > + initial->irq_tx_path_exit_lpi_mode_n) + break; + msleep(100); } =20 + memcpy(final, &priv->xstats, sizeof(*final)); if (final->irq_tx_path_exit_lpi_mode_n <=3D initial->irq_tx_path_exit_lpi_mode_n) { - ret =3D -EINVAL; + ret =3D -ETIMEDOUT; goto out_free_final; } =20 --=20 2.55.0 From nobody Fri Sep 25 13:16:57 2026 Received: from smtpout-04.galae.net (smtpout-04.galae.net [185.171.202.116]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9B0145AEC6F for ; Fri, 11 Sep 2026 21:21:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.171.202.116 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789161682; cv=none; b=sYeW4lXTmb5paiIgaz1kZQrS0VAVDWq4DKIwe2iT7UBlisJNaGVgDvHkcAPg+OFdwjsPM/a2ZN7uGBDfSU30VfvGrHaOEIjzcpPgYGPS5KNmei7A/VY9f2jkN8iElYo2PnTwxkdMwLztbmLGhq+nCMe6TCQoF5SEwOcQl8nBvjA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789161682; c=relaxed/simple; bh=WA2JBB0axH0muAjc04e2AE/HhIvgUjJOlD0AGPU4ExI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jCuW1pgd67f+DBnnVwKYt2xx2hzeb5mEdTvcGVq3Dhs6OvpHbDK5ViZUK1oMR9nxGF8uS+oFT8zbsCSJXcMsFmV/Zl1IgSr2hkd6kJIRm3vm4P3fAQ7xLoJtWUi3aQxZLzrluyvb3qOPOYs9OqTc+GfnBMgjFuB9Sei/QM34VjQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=rg4zCM4j; arc=none smtp.client-ip=185.171.202.116 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) header.d=bootlin.com header.i=@bootlin.com header.b="rg4zCM4j" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-04.galae.net (Postfix) with ESMTPS id 1B35BC63A10; Fri, 11 Sep 2026 21:21:57 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 2C4A2601A3; Fri, 11 Sep 2026 21:21:15 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 1D88B11C7AFB3; Fri, 11 Sep 2026 23:21:04 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1789161669; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding:in-reply-to:references; bh=eF2zdbvuflY5doNoW+50hx8vDNZ+Z3JDjCoh+Vqsa14=; b=rg4zCM4jIoD79xSsIv0sEGbwKw4LfyNp8x8Ch7e6QNCzO/Q8ayOupTucHT5HFR+q5woMS4 MeHpt2Vo73w3dgIa2xgAeDOC263ElleWLUhXb1QPAr3YoJH72EjW0TnqSaNTr4ZLvUD91u N7Z4vkA5mcT9EZKaGEfBrVoFfCPtIUbhZdCT+1/PsmYKf2pVbn1Iqz1EIgIvbvVPKpNuBe 59D+6Zz5uFrxcROKyzCpivEg3hHld90NVldvK7YPufe4+Zqf0BpemQQGT6LFVByp7G64+1 eZ39k1v+0b8ZGwarg3++yc5BE2/6LgCN0Yp6EusgaxuphNH3E614FpQ/YLMTIQ== From: Maxime Chevallier To: Andrew Lunn , davem@davemloft.net, Eric Dumazet , Jakub Kicinski , Paolo Abeni , Russell King , Heiner Kallweit , =?UTF-8?q?Alexis=20Lothor=C3=A9?= , Maxime Coquelin , Alexandre Torgue , Emil Renner Berthing , Minda Chen , Neil Armstrong , Kevin Hilman , Jerome Brunet , Martin Blumenstingl , Jan Petrous , Ovidiu Panait , Jose.Abreu@synopsys.com, Nicolai Buchwitz Cc: Maxime Chevallier , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, thomas.petazzoni@bootlin.com, linux-arm-kernel@lists.infradead.org, linux-stm32@st-md-mailman.stormreply.com, PKneuper@dspace.de, David Laight Subject: [PATCH net v3 3/6] net: stmmac: selftests: Check the dev->features for S-TAG offload testing Date: Fri, 11 Sep 2026 23:20:23 +0200 Message-ID: <20260911212028.1497613-4-maxime.chevallier@bootlin.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260911212028.1497613-1-maxime.chevallier@bootlin.com> References: <20260911212028.1497613-1-maxime.chevallier@bootlin.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Last-TLS-Session-Version: TLSv1.3 Content-Type: text/plain; charset="utf-8" The S-TAG offload insertion incorrectly checks the dvlan (double vlan) DMA cap, which is different than S-TAG support. Use NETIF_F_HW_VLAN_STAG_TX to check if the feature is supported instead. Note that this flag isn't set in stmmac yet, but contrary to ARP offload, this is a feature that has a chance to get there eventually so let's leave the selftest here for now. It'll report -EOPNOTSUPP in the meantime. Fixes: 091810dbded9 ("net: stmmac: Introduce selftests support") Reviewed-by: Nicolai Buchwitz Signed-off-by: Maxime Chevallier --- drivers/net/ethernet/stmicro/stmmac/stmmac_selftests.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_selftests.c b/drive= rs/net/ethernet/stmicro/stmmac/stmmac_selftests.c index df28741abf2b..7f5837d1fed9 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_selftests.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_selftests.c @@ -1410,7 +1410,7 @@ static int stmmac_test_vlanoff(struct stmmac_priv *pr= iv) =20 static int stmmac_test_svlanoff(struct stmmac_priv *priv) { - if (!priv->dma_cap.dvlan) + if (!(priv->dev->features & NETIF_F_HW_VLAN_STAG_TX)) return -EOPNOTSUPP; return stmmac_test_vlanoff_common(priv, true); } --=20 2.55.0 From nobody Fri Sep 25 13:16:57 2026 Received: from smtpout-04.galae.net (smtpout-04.galae.net [185.171.202.116]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9B5D04A4EFF for ; Fri, 11 Sep 2026 21:21:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.171.202.116 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789161688; cv=none; b=kJAo814xw6UoIDfX1dCU238xPOVvRuq9U19Jsqr9FDlz6ZuqTpu/KNFdnw3SWrv+bOqqNkYIadJWwk/ssE0UpCFLnEptWnND5iqah5Sa14rFVhi8f3KIvR5YQAYYRIbMKw0IjoqVNULXZDxfMTqzbFpnUnFAsvlSUtD+NGsKnFM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789161688; c=relaxed/simple; bh=BbZqd0Qnr74HmN1tX6QWLPCZq5rjnQo6pnfDmQMB6xY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jSVhCaOL4SK4TAJ2RaINMr5sGcToUxhFQxw9ebzAuDnp51DgC7OT4mfdcBUws9eLTdPqTWUmnvX5u/vrqv6zvcMsPwTNTUB3ic5e12UVHi7WgtL7mU7vtTUOgWgwYMSDuBM2v55j1W+6oKiwrNSdUR186nkkw3eBGXr+rmJ/zf8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=ePWEwFFT; arc=none smtp.client-ip=185.171.202.116 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) header.d=bootlin.com header.i=@bootlin.com header.b="ePWEwFFT" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-04.galae.net (Postfix) with ESMTPS id DA35AC63A11; Fri, 11 Sep 2026 21:22:03 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id E8C9C601A3; Fri, 11 Sep 2026 21:21:21 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id F3B7411C7AFAD; Fri, 11 Sep 2026 23:21:13 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1789161676; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding:in-reply-to:references; bh=cMhOLV8x7K+5uAmBeY6FYmcfS4Vx9S3mVbL6AGPu8ls=; b=ePWEwFFTNii0zDNob4nHk76iDASYPFvtKkt+ZgZiftVd+bKyTsl+Lt+m5j3JL7niqoDNwO rdacsgH2yQ1T/TY7c6x2ygFV/HcsDGHlJh58Ps/yr0YHk+y2KEGPytokYMMSw4z33eFF8K HJthTHf+jPI59I/egmv5KTAvv/kBblOQSgsQhvPEDzpJQFNCA9WztE3wdTjh9DN1Rx6/LV /nZ8wMEn+qdtVHzllWFHgH1EgiwouFG0LfMULv4mNQ0DvVYs0b1SCSUVrzCm4TCLxHYCbU haLbUrpUoIyWJ2mVzm8GN/y+CI3ORZE6osiVyHNoeivX5W0ABNJMjgEE9jErXw== From: Maxime Chevallier To: Andrew Lunn , davem@davemloft.net, Eric Dumazet , Jakub Kicinski , Paolo Abeni , Russell King , Heiner Kallweit , =?UTF-8?q?Alexis=20Lothor=C3=A9?= , Maxime Coquelin , Alexandre Torgue , Emil Renner Berthing , Minda Chen , Neil Armstrong , Kevin Hilman , Jerome Brunet , Martin Blumenstingl , Jan Petrous , Ovidiu Panait , Jose.Abreu@synopsys.com, Nicolai Buchwitz Cc: Maxime Chevallier , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, thomas.petazzoni@bootlin.com, linux-arm-kernel@lists.infradead.org, linux-stm32@st-md-mailman.stormreply.com, PKneuper@dspace.de, David Laight Subject: [PATCH net v3 4/6] net: stmmac: selftests: Capture all packets for vlan checks Date: Fri, 11 Sep 2026 23:20:24 +0200 Message-ID: <20260911212028.1497613-5-maxime.chevallier@bootlin.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260911212028.1497613-1-maxime.chevallier@bootlin.com> References: <20260911212028.1497613-1-maxime.chevallier@bootlin.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Last-TLS-Session-Version: TLSv1.3 Content-Type: text/plain; charset="utf-8" While we use vlan_vid_add to trigger the tag filtering machinery in the driver, there's no netdev associated to the VLAN. This causes the skb to arrive with empty skb->vlan_tci fields, as the packet is marked OTHERHOST in __netif_receive_skb_core(), and we fail our validation. Let's use the proxy mechanism introduced for DSA, that registers a ETH_P_ALL packet handler that runs earlier, before the vlan netdev lookup, then filters for the correct ethertype before passing an skb clone to our validation function. Fixes: 091810dbded9 ("net: stmmac: Introduce selftests support") Reviewed-by: Nicolai Buchwitz Signed-off-by: Maxime Chevallier --- drivers/net/ethernet/stmicro/stmmac/stmmac_selftests.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_selftests.c b/drive= rs/net/ethernet/stmicro/stmmac/stmmac_selftests.c index 7f5837d1fed9..315c3cf82230 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_selftests.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_selftests.c @@ -242,6 +242,7 @@ struct stmmac_test_priv { __be16 packet_type; int (*func)(struct sk_buff *skb, struct net_device *ndev, struct packet_type *pt, struct net_device *orig_ndev); + bool capture_all; int double_vlan; int vlan_id; int ok; @@ -344,7 +345,7 @@ static void stmmac_sft_add_pack(struct packet_type *pt) { struct stmmac_test_priv *tpriv =3D pt->af_packet_priv; =20 - if (netdev_uses_dsa(tpriv->pt.dev)) { + if (netdev_uses_dsa(tpriv->pt.dev) || tpriv->capture_all) { tpriv->packet_type =3D tpriv->pt.type; tpriv->func =3D tpriv->pt.func; =20 @@ -999,6 +1000,7 @@ static int __stmmac_test_vlanfilt(struct stmmac_priv *= priv) tpriv->pt.dev =3D priv->dev; tpriv->pt.af_packet_priv =3D tpriv; tpriv->packet =3D &attr; + tpriv->capture_all =3D true; =20 /* * As we use HASH filtering, false positives may appear. This is a @@ -1093,6 +1095,7 @@ static int __stmmac_test_dvlanfilt(struct stmmac_priv= *priv) tpriv->pt.dev =3D priv->dev; tpriv->pt.af_packet_priv =3D tpriv; tpriv->packet =3D &attr; + tpriv->capture_all =3D true; =20 /* * As we use HASH filtering, false positives may appear. This is a @@ -1371,6 +1374,7 @@ static int stmmac_test_vlanoff_common(struct stmmac_p= riv *priv, bool svlan) tpriv->pt.af_packet_priv =3D tpriv; tpriv->packet =3D &attr; tpriv->vlan_id =3D 0x123; + tpriv->capture_all =3D true; stmmac_sft_add_pack(&tpriv->pt); =20 ret =3D vlan_vid_add(priv->dev, htons(proto), tpriv->vlan_id); --=20 2.55.0 From nobody Fri Sep 25 13:16:57 2026 Received: from smtpout-03.galae.net (smtpout-03.galae.net [185.246.85.4]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0C14C486403 for ; Fri, 11 Sep 2026 21:21:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.246.85.4 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789161692; cv=none; b=YMzX43RGmO/IbEtFUkxGohip99W+AYaLS5B2Vw1+k8iz1fyqVj4sHKj1ytm74smc4B0zFQ54kn/IUGpmhyXxz6llW8LBoz+oIjzITGS7Vw0aLjuiPYnxY53XUD8eAcmy8rLMRYTZMzx8vFrg5f+byoMKEIpRGb4gxSRCOdInoVI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789161692; c=relaxed/simple; bh=CjVuknf9p5QVjP83fJ9wEyCm8dX+C+ZG7ZpVXaER/SQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=WQtpQvkuTo2KZstKyahvwEaRWFR3shUQi5pvcSP1l/NiSmPi5gDzayVURXAhfypmsx0bcEzPoSqTTNJptkY3w9ieLkkXMXL7FFkk1slj5zN6t3d+qpBpNyF4FTKwiZ/euJrgOb2uhtNS8/PqaVDqqMBCwLecCj/E4sUPuwlUEFE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=nJpDo/Ij; arc=none smtp.client-ip=185.246.85.4 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) header.d=bootlin.com header.i=@bootlin.com header.b="nJpDo/Ij" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-03.galae.net (Postfix) with ESMTPS id 97F3A4E40240; Fri, 11 Sep 2026 21:21:29 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 6BDF3601A3; Fri, 11 Sep 2026 21:21:29 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 0A39011C7A9DC; Fri, 11 Sep 2026 23:21:20 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1789161684; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding:in-reply-to:references; bh=XNIT1uyOzSSofYvR/lzX3M0WT4Kg9DVts0sXrRa7wIE=; b=nJpDo/Ij//aHoqMb2+TXo+G/sM6hgTk0OWJkGa6OIKynij06LDIOet7Stc3VoD00hhPXcq yoF1KpJ3YgXYrVVVhVSfpTXu+QwNF+tLYnqKB8zaS0DPATkkQzrkT9LEtZ1AurBXyJUQRa oJxz8REdubsEFcAZ8O0ihMixfOguVnouNaKjM2gcw23zkiRFKhqbt5zDkzY4KLq3Y9CZI0 N6UhWtSm39Ef9/1Q5To0xzpLcvTgm4qIGnoUKCtj7BQZLlepeBds3pw5av526apJi1n8Y4 DC4gAZ0p8WCPwia58ey63LnZ76XstJMA41Qby48PBdgEgVFnEW3nKs2cRqkjtw== From: Maxime Chevallier To: Andrew Lunn , davem@davemloft.net, Eric Dumazet , Jakub Kicinski , Paolo Abeni , Russell King , Heiner Kallweit , =?UTF-8?q?Alexis=20Lothor=C3=A9?= , Maxime Coquelin , Alexandre Torgue , Emil Renner Berthing , Minda Chen , Neil Armstrong , Kevin Hilman , Jerome Brunet , Martin Blumenstingl , Jan Petrous , Ovidiu Panait , Jose.Abreu@synopsys.com, Nicolai Buchwitz Cc: Maxime Chevallier , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, thomas.petazzoni@bootlin.com, linux-arm-kernel@lists.infradead.org, linux-stm32@st-md-mailman.stormreply.com, PKneuper@dspace.de, David Laight Subject: [PATCH net v3 5/6] net: stmmac: size the RX buffers from the frame length, not the MTU Date: Fri, 11 Sep 2026 23:20:25 +0200 Message-ID: <20260911212028.1497613-6-maxime.chevallier@bootlin.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260911212028.1497613-1-maxime.chevallier@bootlin.com> References: <20260911212028.1497613-1-maxime.chevallier@bootlin.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Last-TLS-Session-Version: TLSv1.3 Content-Type: text/plain; charset="utf-8" When picking the buffsize to use based on the MTU, we shouldn't check only the MTU value, but also : - ETH_HLEN for the L2 header, - up to 2 VLAN tags, - the FCS, - the NET_IP_ALIGN The default bufsize is 1536 bytes, which is enough to contain all the above so this hasn't surfaced before, but the addition of NET_IP_ALIGN to the start of buffer address tripped the Jumbo selftest, leading to this discovery. With that, we don't need the '>=3D' checks on the buffer len, we can use more consistent comparison operators in stmmac_set_bfsize. Fixes: 286a83721720 ("stmmac: add CHAINED descriptor mode support (V4)") Reviewed-by: Nicolai Buchwitz Signed-off-by: Maxime Chevallier --- .../net/ethernet/stmicro/stmmac/stmmac_main.c | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/ne= t/ethernet/stmicro/stmmac/stmmac_main.c index 62c3441911e7..29b970574a38 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -1536,17 +1536,17 @@ static unsigned int stmmac_rx_offset(struct stmmac_= priv *priv) return NET_SKB_PAD + NET_IP_ALIGN; } =20 -static int stmmac_set_bfsize(int mtu) +static int stmmac_set_bfsize(int len) { int ret; =20 - if (mtu >=3D BUF_SIZE_8KiB) + if (len > BUF_SIZE_8KiB) ret =3D BUF_SIZE_16KiB; - else if (mtu >=3D BUF_SIZE_4KiB) + else if (len > BUF_SIZE_4KiB) ret =3D BUF_SIZE_8KiB; - else if (mtu >=3D BUF_SIZE_2KiB) + else if (len > BUF_SIZE_2KiB) ret =3D BUF_SIZE_4KiB; - else if (mtu > DEFAULT_BUFSIZE) + else if (len > DEFAULT_BUFSIZE) ret =3D BUF_SIZE_2KiB; else ret =3D DEFAULT_BUFSIZE; @@ -4063,7 +4063,7 @@ static struct stmmac_dma_conf * stmmac_setup_dma_desc(struct stmmac_priv *priv, unsigned int mtu) { struct stmmac_dma_conf *dma_conf; - int bfsize, ret; + int bfsize, len, ret; u8 chan; =20 dma_conf =3D kzalloc_obj(*dma_conf); @@ -4073,13 +4073,15 @@ stmmac_setup_dma_desc(struct stmmac_priv *priv, uns= igned int mtu) return ERR_PTR(-ENOMEM); } =20 - /* Returns 0 or BUF_SIZE_16KiB if mtu > 8KiB and dwmac4 or ring mode */ - bfsize =3D stmmac_set_16kib_bfsize(priv, mtu); + len =3D mtu + ETH_HLEN + 2 * VLAN_HLEN + ETH_FCS_LEN + NET_IP_ALIGN; + + /* Returns 0 or BUF_SIZE_16KiB if len > 8KiB and dwmac4 or ring mode */ + bfsize =3D stmmac_set_16kib_bfsize(priv, len); if (bfsize < 0) bfsize =3D 0; =20 if (bfsize < BUF_SIZE_16KiB) - bfsize =3D stmmac_set_bfsize(mtu); + bfsize =3D stmmac_set_bfsize(len); =20 dma_conf->dma_buf_sz =3D bfsize; /* Chose the tx/rx size from the already defined one in the --=20 2.55.0 From nobody Fri Sep 25 13:16:57 2026 Received: from smtpout-02.galae.net (smtpout-02.galae.net [185.246.84.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D42414BA1D9 for ; Fri, 11 Sep 2026 21:21:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.246.84.56 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789161700; cv=none; b=hNOgVa9pXAsDBxVrecLQ6VfG9nvoelJ2nR020w1KUhBtPEp1r5uvWG2Ruh0D0mhBGURtROY8pOZNnpMivLOEe+qiLf/jeUBilTXrFDeJzJEZ1zssQy7cR6Tde1BTbR6gA7GrsfEqsGLeytBvEUTQwykKfCZbVHvX74LfPZVUo10= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789161700; c=relaxed/simple; bh=w3vUhgx3u1w5w5lsNBe8uid6akfNeA658Av9oc09LCA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DtTF89CEObBhZ2ZBmvUm1azoKTzcYl1r0T+XNYA2hCx577iJvdJlsrjHjqP4hwll6tMSRUpIeHHVDWlxLudsZnKORPOvFRmXh6gaQSDM0gX2stJ5S3LBtOFfq5IArQ8nu09W3VrDBL7ZzKolnd8pZnBW+ZpsC9QHOlN9yNW/JZM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=e0oZoW/N; arc=none smtp.client-ip=185.246.84.56 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) header.d=bootlin.com header.i=@bootlin.com header.b="e0oZoW/N" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-02.galae.net (Postfix) with ESMTPS id 7704C1A0226; Fri, 11 Sep 2026 21:21:37 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 4A7D7601A3; Fri, 11 Sep 2026 21:21:37 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 803A111C7AF95; Fri, 11 Sep 2026 23:21:28 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1789161691; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding:in-reply-to:references; bh=lVlFXXS0Y6100599x+SkiEbiGjCXQZYo+KZ+IT1mUds=; b=e0oZoW/NeajrzMZfAtHlmyRmvl8y+c82WNxSszyjf/Z9R8zzTU8zotCd+uuFOEsalNEnqT mgwFUFOgttZlV3H/Je6oYnrW8/LtkviIawv2b5BXDRb4MV+TkpbRC8QeHH61eH/F6n/Ahy H5VTdsHGHkI5UMod2Bi0gPrNh4aJybdYJ8WMVEzgYWwJ/ZzbYvBJCWNYAK7QHv74BhEACK HeXA9H4L82Zm9+JfZ1HNxlKLwfH6/rB5GMhlKCDSqnkFSsv6fgcuqKnkmOkRFx07iz6pWc 9XvMDvDRjcskGPdZShfcpEFXfiCXbXH5QYEvPDi/PVQZcOx14AkEc3uLSp8aSw== From: Maxime Chevallier To: Andrew Lunn , davem@davemloft.net, Eric Dumazet , Jakub Kicinski , Paolo Abeni , Russell King , Heiner Kallweit , =?UTF-8?q?Alexis=20Lothor=C3=A9?= , Maxime Coquelin , Alexandre Torgue , Emil Renner Berthing , Minda Chen , Neil Armstrong , Kevin Hilman , Jerome Brunet , Martin Blumenstingl , Jan Petrous , Ovidiu Panait , Jose.Abreu@synopsys.com, Nicolai Buchwitz Cc: Maxime Chevallier , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, thomas.petazzoni@bootlin.com, linux-arm-kernel@lists.infradead.org, linux-stm32@st-md-mailman.stormreply.com, PKneuper@dspace.de, David Laight Subject: [PATCH net v3 6/6] net: stmmac: selftests: Account for alignment shift on dwmac1000 for Jumbo test Date: Fri, 11 Sep 2026 23:20:26 +0200 Message-ID: <20260911212028.1497613-7-maxime.chevallier@bootlin.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260911212028.1497613-1-maxime.chevallier@bootlin.com> References: <20260911212028.1497613-1-maxime.chevallier@bootlin.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Last-TLS-Session-Version: TLSv1.3 Content-Type: text/plain; charset="utf-8" On dwmac1000, we currently only support single-descriptor frames. The Jumbo test started failing when NET_IP_ALIGN was added to align the IP header, as this tests tries to send the biggest possible frame. On dwmac1000 the DMA transfer is aligned on 4-bytes, so adding a 2-byte shift at the start-of-buffer address means it takes a whole extra 4-byte DMA burst to receive the Jumbo packet, causing it to spill over the next descriptor. This doesn't seem to happen on dwmac4 and xgmac that appear to correctly handle unaligned xfers (only tested on dwmac4) Let's account for that in the Jumbo test, reduce the size of our big packet by the align size. Fixes: 23680bf5f8c6 ("net: stmmac: restore NET_IP_ALIGN in the RX DMA offse= t") Reviewed-by: Nicolai Buchwitz Signed-off-by: Maxime Chevallier --- drivers/net/ethernet/stmicro/stmmac/stmmac_selftests.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_selftests.c b/drive= rs/net/ethernet/stmicro/stmmac/stmmac_selftests.c index 315c3cf82230..cd7dc99095a0 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_selftests.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_selftests.c @@ -1781,6 +1781,9 @@ static int __stmmac_test_jumbo(struct stmmac_priv *pr= iv, u16 queue) struct stmmac_packet_attrs attr =3D { }; int size =3D priv->dma_conf.dma_buf_sz; =20 + if (!dwmac_is_xmac(priv->plat->core_type)) + size -=3D NET_IP_ALIGN; + attr.dst =3D priv->dev->dev_addr; attr.max_size =3D size - ETH_FCS_LEN; attr.queue_mapping =3D queue; --=20 2.55.0