net: stmmac: More selftest-related fixes
Subsystems (4)
Maxime Chevallier
maintainerv2 cover net: stmmac: More selftest-related fixes
Hi everyone,
Here's V2 of the stmmac selftest fixes. I don't really know why but V1 was only partially delivered, yet Nicolai was kind enough to review whatever managed to get to the lists, and found some things to improve in the EEE test, addressed in this new iteration :) Hence, this is V2 and not a resend.
This is another round of stmmac selftest fixes, mostly about the selftests themselves but a few things were discovered w.r.t MTU and buffer size handling, see patch 5.
I've continued expanding the test devices I'm running this on, more devices should come in the future. With this series, _almost_ everything is green, except for some flow control stuff that is either a false positive or a real thing that needs investigating.
After this is merged, I consider the selftests to be now reliable enough to run them nightly on every stmmac series that's sent, and I'll be requiring clean selftests for new glue drivers.
I've been running this on :
- Altera CycloneV (dwmac-socfpga, dwmac1000 IP, v3.70a)
- NXP imx8mp (dwmac-imx, dwmac4, v5.10a)
- Allwinner H2S (dwmac-sun8i, dwmac1000)
- Amlogic S905X3 (dwmac-meson8b, dwmac1000, v3.70a)
- STM32mp157a (dwmac-stm32, dwmac4, v4.20a)
- SiFive JH7110 (dwmac-starfive, dwmac4, v5.20)
- Motorcomm YT8061 (PCIe, dwmac-motorcomm, dwmac4)
- Qualcomm IPQ8064 (dwmac-ipq806x, dwmac1000)
Tests are OK if return is 0 or -95 (-EOPNOTSUPP), tests are KO otherwise
Before the series :
Test imx socfpga sun8i meson8b stm32 starV mcom ipq806x
MAC Loopback 0 0 0 0 0 0 0 -110 MMC Counters 0 0 -95 0 0 0 0 -110 EEE -95 -95 -95 -110 -110 -95 -95 -95 Hash Filter MC 0 0 -95 0 0 0 0 -95 Perfect Filter UC -95 0 0 -95 -95 -95 -95 -95 MC Filter -95 0 -95 -95 -95 -95 -95 -95 UC Filter -95 0 -95 -95 -95 -95 -95 -95 Flow Control -95 0 -110 0 -110 -95 -110 -110 RSS -95 -95 -95 -95 -95 -95 -95 -95 VLAN Filtering -110 -95 -95 -95 -110 -110 -95 -95 VLAN Filtering (perf) -110 -95 -95 -95 -110 -110 -95 -95 Double VLAN Filter -110 -95 -95 -95 -110 -110 -95 -95 Double VLAN Filter (perf) -110 -95 -95 -95 -110 -110 -95 -95 Flexible RX Parser 0 -95 -95 -95 -95 -95 -95 -95 SA Insertion (desc) 0 -95 -95 -95 0 0 0 -95 SA Replacement (desc) 0 -95 -95 -95 0 0 0 -95 SA Insertion (reg 0 -95 -95 -95 0 0 0 -95 SA Replacement (reg) 0 -95 -95 -95 0 0 0 -95 VLAN TX Insertion -110 -95 -95 -95 -110 -110 -110 -95 SVLAN TX Insertion -110 -95 -95 -95 -110 -95 -110 -95 L3 DA Filtering 0 -95 -95 -95 -95 -95 -95 -95 L3 SA Filtering 0 -95 -95 -95 -95 -95 -95 -95 L4 DA TCP Filtering 0 -95 -95 -95 -95 -95 -95 -95 L4 SA TCP Filtering 0 -95 -95 -95 -95 -95 -95 -95 L4 DA UDP Filtering 0 -95 -95 -95 -95 -95 -95 -95 L4 SA UDP Filtering 0 -95 -95 -95 -95 -95 -95 -95 ARP Offload -95 -95 -95 -95 -110 -110 -110 -95 Jumbo Frame 0 -110 -110 0 0 0 0 -110 Multichannel Jumbo 0 -95 -95 -95 -95 -95 -95 -95 Split Header --95 -95 -95 -95 -95 -95 0 -95 TBS (ETF Scheduler) --95 -95 -95 -95 -95 -95 -95 -95
ARP offload's still there as this was a net-next patch and I've ran these checks on the net tree.
Jumbo frame tests on dwmac1000 started failing after :
commit 23680bf5f8c6 ("net: stmmac: restore NET_IP_ALIGN in the RX DMA offset")
This commit is OK though, it just made the selftest reveal the cracks hiding beneath the surface of MTU/bufsz handling.
After this series :
Test imx socfpga sun8i meson8b stm32 starV mcom ipq806x
MAC Loopback 0 0 0 0 0 0 0 0 MMC Counters 0 0 -95 0 0 0 0 0 EEE -95 -95 -95 0 0 -95 -95 -95 Hash Filter MC 0 0 -95 0 0 0 0 -95 Perfect Filter UC -95 0 0 -95 -95 -95 -95 -95 MC Filter -95 0 -95 -95 -95 -95 -95 -95 UC Filter -95 0 -95 -95 -95 -95 -95 -95 Flow Control -95 0 -110 0 -110 -95 -110 -110 RSS -95 -95 -95 -95 -95 -95 -95 -95 VLAN Filtering 0 -95 -95 -95 0 0 -95 -95 VLAN Filtering (perf) 0 -95 -95 -95 0 0 -95 -95 Double VLAN Filter 0 -95 -95 -95 0 0 -95 -95 Double VLAN Filter (perf) 0 -95 -95 -95 0 0 -95 -95 Flexible RX Parser 0 -95 -95 -95 -95 -95 -95 -95 SA Insertion (desc) 0 -95 -95 -95 0 0 0 -95 SA Replacement (desc) 0 -95 -95 -95 0 0 0 -95 SA Insertion (reg 0 -95 -95 -95 0 0 0 -95 SA Replacement (reg) 0 -95 -95 -95 0 0 0 -95 VLAN TX Insertion 0 -95 -95 -95 0 0 0 -95 SVLAN TX Insertion -95 -95 -95 -95 -95 -95 -95 -95 L3 DA Filtering 0 -95 -95 -95 -95 -95 -95 -95 L3 SA Filtering 0 -95 -95 -95 -95 -95 -95 -95 L4 DA TCP Filtering 0 -95 -95 -95 -95 -95 -95 -95 L4 SA TCP Filtering 0 -95 -95 -95 -95 -95 -95 -95 L4 DA UDP Filtering 0 -95 -95 -95 -95 -95 -95 -95 L4 SA UDP Filtering 0 -95 -95 -95 -95 -95 -95 -95 ARP Offload -95 -95 -95 -95 -110 -110 -110 -95 Jumbo Frame 0 0 0 0 0 0 0 0 Multichannel Jumbo 0 -95 -95 -95 -95 -95 -95 -95 Split Header -95 -95 -95 -95 -95 -95 0 -95 TBS (ETF Scheduler) -95 -95 -95 -95 -95 -95 -95 -95
ARP can be ignored, and Flow control needs some more attention, but we're getting there :)
Thanks,
Maxime
V2:
- Snapshot before sending the frame for EEE, in case we immediately enter LPI
- Also return -ETIMEDOUT instead of EINVAL
V1: https://lore.kernel.org/lkml/[email protected]/
Maxime Chevallier (6):
net: stmmac: selftests: Support running selftests on DSA conduits
net: stmmac: selftests: Validate EEE based on the actual LPI timer
value
net: stmmac: selftests: Check the dev->features for S-TAG offload
testing
net: stmmac: selftests: Capture all packets for vlan checks
net: stmmac: size the RX buffers from the frame length, not the MTU
net: stmmac: selftests: Account for alignment shift on dwmac1000 for
Jumbo test
.../net/ethernet/stmicro/stmmac/stmmac_main.c | 20 +-- .../stmicro/stmmac/stmmac_selftests.c | 116 +++++++++++++++--- 2 files changed, 109 insertions(+), 27 deletions(-)
Signature · 1 line
2.55.0
Maxime Chevallier
maintainerPATCH v2 1/6 net: stmmac: selftests: Support running selftests on DSA conduits
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.
--- .../stmicro/stmmac/stmmac_selftests.c | 68 ++++++++++++++++--- 1 file changed, 58 insertions(+), 10 deletions(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_selftests.c +58 -10
@@ -12,6 +12,7 @@#include <linux/ethtool.h> #include <linux/ip.h> #include <linux/udp.h> +#include <net/dsa.h> #include <net/pkt_cls.h> #include <net/pkt_sched.h> #include <net/tcp.h>
@@ -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_buff *skb,return 0 ; } +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 = pt->af_packet_priv; +struct ethhdr *hdr =eth_hdr (skb); +int ret =0 ; + +if (hdr->h_proto == tpriv->packet_type) { +struct sk_buff *nskb =skb_clone (skb,GFP_ATOMIC ); + +if (nskb) + ret = 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 = pt->af_packet_priv; + +if (netdev_uses_dsa (tpriv->pt.dev)) { + tpriv->packet_type = tpriv->pt.type; + tpriv->func = 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 =htons (ETH_P_ALL ); + tpriv->pt.func = stmmac_sft_filter; + tpriv->pt.ignore_outgoing = 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 *priv, tpriv->packet = attr;if (!attr->dont_wait) -dev_add_pack (&tpriv->pt); +stmmac_sft_add_pack (&tpriv->pt); skb =stmmac_test_get_udp_skb (priv, attr);if (!skb) {
@@ -360,7 +408,7 @@ static int __stmmac_test_loopback(struct stmmac_priv *priv, 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 *priv) tpriv->pt.func = stmmac_test_flowctrl_validate; tpriv->pt.dev = priv->dev; tpriv->pt.af_packet_priv = tpriv; -dev_add_pack (&tpriv->pt); +stmmac_sft_add_pack (&tpriv->pt);/* Compute minimum number of packets to make FIFO full */ pkt_count = rx_fifo_size;
@@ -823,7 +871,7 @@ static int stmmac_test_flowctrl(struct stmmac_priv *priv) 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 *priv)* HASH values. */ tpriv->vlan_id =0x123 ; -dev_add_pack (&tpriv->pt); +stmmac_sft_add_pack (&tpriv->pt); ret =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 =0x123 ; -dev_add_pack (&tpriv->pt); +stmmac_sft_add_pack (&tpriv->pt); ret =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_priv *priv, bool svlan) tpriv->pt.af_packet_priv = tpriv; tpriv->packet = &attr; tpriv->vlan_id =0x123 ; -dev_add_pack (&tpriv->pt); +stmmac_sft_add_pack (&tpriv->pt); ret =vlan_vid_add (priv->dev,htons (proto), tpriv->vlan_id);if (ret)
@@ -1320,7 +1368,7 @@ static int stmmac_test_vlanoff_common(struct stmmac_priv *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; }
Signature · 1 line
2.55.0
Re: [PATCH net v2 1/6] net: stmmac: selftests: Support running selftests on DSA conduits
Quoted 21 lines · Maxime Chevallier
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_XDSAas 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_ALLpacket handler when we detect that we're a DSA conduit, and use a proxy packet handler to filter theh_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.
Quoted 8 lines
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")Signed-off-by Maxime Chevallier <[email protected]>---
[...]
Thanks,
Nicolai
Maxime Chevallier
maintainerPATCH v2 2/6 net: stmmac: selftests: Validate EEE based on the actual LPI timer value
In reply to Maxime ChevallierThe 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.
Note that the test's goal isn't to validate the LPI timer value itself, only that we enter/leave LPI mode.
--- .../stmicro/stmmac/stmmac_selftests.c | 39 +++++++++++++++---- 1 file changed, 32 insertions(+), 7 deletions(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_selftests.c +32 -7
@@ -462,7 +462,7 @@ 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 =10 ; +unsigned long timeout, max_duration;int ret;if (!priv->dma_cap.eee || !priv->eee_active)
@@ -478,14 +478,21 @@ static int stmmac_test_eee(struct stmmac_priv *priv) goto out_free_initial; } +/* 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)); +/* Send a frame, then wait to enter LPI */ ret =stmmac_test_mac_loopback (priv);if (ret) goto out_free_final; + max_duration =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 = jiffies + max_duration; +while (!time_after (jiffies, timeout)) {memcpy (final, &priv->xstats,sizeof (*final)); if (final->irq_tx_path_in_lpi_mode_n >
@@ -494,20 +501,38 @@ static int stmmac_test_eee(struct stmmac_priv *priv)msleep (100 ); } -if (!retries) { +memcpy (final, &priv->xstats,sizeof (*final)); +if (final->irq_tx_path_in_lpi_mode_n <= + initial->irq_tx_path_in_lpi_mode_n) { ret = -ETIMEDOUT ; goto out_free_final; } -if (final->irq_tx_path_in_lpi_mode_n <= - initial->irq_tx_path_in_lpi_mode_n) { - ret = -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 =stmmac_test_mac_loopback (priv); +if (ret) goto out_free_final; + +/* Wait for the exit LPI interrupt */ + timeout = 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 ); } +memcpy (final, &priv->xstats,sizeof (*final));if (final->irq_tx_path_exit_lpi_mode_n <= initial->irq_tx_path_exit_lpi_mode_n) { - ret = -EINVAL ; + ret = -ETIMEDOUT ; goto out_free_final; }
Signature · 1 line
2.55.0
Re: [PATCH net v2 2/6] net: stmmac: selftests: Validate EEE based on the actual LPI timer value
Hi Maxime,
Quoted 107 lines · Maxime Chevallier
The EEE selftest is a 2-step test :
- It validates that we enter in LPI mode with theirq_tx_path_in_lpi_mode_ncounter
- It then validates that we exit LPI when sending a frame, with theirq_tx_path_exit_lpi_mode_ncounter.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.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")Signed-off-by Maxime Chevallier <[email protected]>--- .../stmicro/stmmac/stmmac_selftests.c | 39 +++++++++++++++---- 1 file changed, 32 insertions(+), 7 deletions(-)drivers/net/ethernet/stmicro/stmmac/stmmac_selftests.c +1
-1@@ -462,7 +462,7 @@ 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 =10 ; +unsigned long timeout, max_duration;int ret;drivers/net/ethernet/stmicro/stmmac/stmmac_selftests.c +8
-1if (!priv->dma_cap.eee || !priv->eee_active)@@ -478,14 +478,21 @@ static int stmmac_test_eee(struct stmmac_priv *priv) goto out_free_initial; } +/* 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)); +/* Send a frame, then wait to enter LPI */ ret =stmmac_test_mac_loopback (priv);if (ret) goto out_free_final; + max_duration =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 = jiffies + max_duration; +while (!time_after (jiffies, timeout)) {memcpy (final, &priv->xstats,sizeof (*final));drivers/net/ethernet/stmicro/stmmac/stmmac_selftests.c +20
-4if (final->irq_tx_path_in_lpi_mode_n >@@ -494,20 +501,38 @@ static int stmmac_test_eee(struct stmmac_priv *priv)msleep (100 ); } -if (!retries) { +memcpy (final, &priv->xstats,sizeof (*final)); +if (final->irq_tx_path_in_lpi_mode_n <= + initial->irq_tx_path_in_lpi_mode_n) { ret = -ETIMEDOUT ; goto out_free_final; } -if (final->irq_tx_path_in_lpi_mode_n <= - initial->irq_tx_path_in_lpi_mode_n) { - ret = -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 =stmmac_test_mac_loopback (priv); +if (ret) goto out_free_final; + +/* Wait for the exit LPI interrupt */ + timeout = 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 ;
drivers/net/ethernet/stmicro/stmmac/stmmac_selftests.c static int stmmac_test_eee(struct stmmac_priv · line 538
Quoted 10 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_selftests.c +3
-1+msleep (100 ); } +memcpy (final, &priv->xstats,sizeof (*final));if (final->irq_tx_path_exit_lpi_mode_n <= initial->irq_tx_path_exit_lpi_mode_n) { - ret = -EINVAL ; + ret = -ETIMEDOUT ; goto out_free_final; }
Thanks,
Nicolai
Re: [PATCH net v2 2/6] net: stmmac: selftests: Validate EEE based on the actual LPI timer value
In reply to Maxime ChevallierHi Maxime,
Sorry for the noise, but after having a second look, there is something which I think should be discussed at least.
Quoted 34 lines · Maxime Chevallier
The EEE selftest is a 2-step test :
- It validates that we enter in LPI mode with theirq_tx_path_in_lpi_mode_ncounter
- It then validates that we exit LPI when sending a frame, with theirq_tx_path_exit_lpi_mode_ncounter.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.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")Signed-off-by Maxime Chevallier <[email protected]>---
[...]
drivers/net/ethernet/stmicro/stmmac/stmmac_selftests.c static int stmmac_test_eee(struct stmmac_priv *priv) · line 491
Quoted 4 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_selftests.c +1
-0+ max_duration =usecs_to_jiffies (2 * priv->tx_lpi_timer);
tx_lpi_timer comes direct from ethtool as an unvalidated u32. So if a (arguable privileged user) does 'ethtool --set-eee eth0 tx-lpi-timer 1000000000', the code will sleep ~2000 seconds under rtnl_lock. Tge old code capped it at 900 ms regardless of the timer.
Thus I think we should clamp it at some sane value. Feel free to keep my R-b with the clamp.
Quoted 1 line
[...]
Regards,
Nicolai
Maxime Chevallier
maintainerRe: [PATCH net v2 2/6] net: stmmac: selftests: Validate EEE based on the actual LPI timer value
Hi Nicolai,
Quoted 7 lines · Nicolai Buchwitz
Quoted 1 line
+
max_duration=usecs_to_jiffies(2 * priv->tx_lpi_timer);
tx_lpi_timercomes direct from ethtool as an unvalidated u32. So if a (arguable privileged user) does 'ethtool --set-eee eth0 tx-lpi-timer 1000000000', the code will sleep ~2000 seconds underrtnl_lock. Tge old code capped it at 900 ms regardless of the timer.Thus I think we should clamp it at some sane value. Feel free to keep my R-b with the clamp.
I was wondering if 802.3 said anything about the LPI timer value, but Clause 78 says :
78.1.2.1.3 When generated
Specification of the time when this primitive is generated by the LPI client is out of the scope of this standard.
I'll clamp that as a safety precaution.
As a side-note, there are other limitations, that apply to both eee and flow control. Even though we're in MAC loopback mode, the link MUST be up for the selftests to run, and both EEE and Pause are affected by the autoneg results, and this will affect the selftest outcome.
I'll address that in another series though, but I'll send a V3 for the clamping still :)
Thanks for taking a look,
Maxime
Maxime Chevallier
maintainerPATCH v2 3/6 net: stmmac: selftests: Check the dev->features for S-TAG offload testing
In reply to Maxime ChevallierThe 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.
--- drivers/net/ethernet/stmicro/stmmac/stmmac_selftests.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_selftests.c +1 -1
@@ -1405,7 +1405,7 @@ static int stmmac_test_vlanoff(struct stmmac_priv *priv)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); }
Signature · 1 line
2.55.0
Re: [PATCH net v2 3/6] net: stmmac: selftests: Check the dev->features for S-TAG offload testing
Quoted 28 lines · Maxime Chevallier
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_TXto 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
-EOPNOTSUPPin the meantime.Fixes 091810dbded9 ("net: stmmac: Introduce selftests support")Signed-off-by Maxime Chevallier <[email protected]>--- drivers/net/ethernet/stmicro/stmmac/stmmac_selftests.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/net/ethernet/stmicro/stmmac/stmmac_selftests.c +1
-1@@ -1405,7 +1405,7 @@ static int stmmac_test_vlanoff(struct stmmac_priv *priv)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);
Quoted 1 line
}
Thanks,
Nicolai
Maxime Chevallier
maintainerPATCH v2 4/6 net: stmmac: selftests: Capture all packets for vlan checks
In reply to Maxime ChevallierWhile 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.
--- drivers/net/ethernet/stmicro/stmmac/stmmac_selftests.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_selftests.c +5 -1
@@ -241,6 +241,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;
@@ -343,7 +344,7 @@ static void stmmac_sft_add_pack(struct packet_type *pt) {struct stmmac_test_priv *tpriv = pt->af_packet_priv; -if (netdev_uses_dsa (tpriv->pt.dev)) { +if (netdev_uses_dsa (tpriv->pt.dev) || tpriv->capture_all) { tpriv->packet_type = tpriv->pt.type; tpriv->func = tpriv->pt.func;
@@ -994,6 +995,7 @@ static int __stmmac_test_vlanfilt(struct stmmac_priv *priv) tpriv->pt.dev = priv->dev; tpriv->pt.af_packet_priv = tpriv; tpriv->packet = &attr; + tpriv->capture_all = true;/* * As we use HASH filtering, false positives may appear. This is a
@@ -1088,6 +1090,7 @@ static int __stmmac_test_dvlanfilt(struct stmmac_priv *priv) tpriv->pt.dev = priv->dev; tpriv->pt.af_packet_priv = tpriv; tpriv->packet = &attr; + tpriv->capture_all = true;/* * As we use HASH filtering, false positives may appear. This is a
@@ -1366,6 +1369,7 @@ static int stmmac_test_vlanoff_common(struct stmmac_priv *priv, bool svlan) tpriv->pt.af_packet_priv = tpriv; tpriv->packet = &attr; tpriv->vlan_id =0x123 ; + tpriv->capture_all = true;stmmac_sft_add_pack (&tpriv->pt); ret =vlan_vid_add (priv->dev,htons (proto), tpriv->vlan_id);
Signature · 1 line
2.55.0
Re: [PATCH net v2 4/6] net: stmmac: selftests: Capture all packets for vlan checks
Quoted 64 lines · Maxime Chevallier
While we use
vlan_vid_addto trigger the tag filtering machinery in the driver, there's no netdev associated to the VLAN. This causes the skb to arrive with emptyskb->vlan_tcifields, 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_ALLpacket 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")Signed-off-by Maxime Chevallier <[email protected]>--- drivers/net/ethernet/stmicro/stmmac/stmmac_selftests.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)drivers/net/ethernet/stmicro/stmmac/stmmac_selftests.c +3
-1@@ -241,6 +241,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;@@ -343,7 +344,7 @@ static void stmmac_sft_add_pack(struct packet_type *pt) {struct stmmac_test_priv *tpriv = pt->af_packet_priv; -if (netdev_uses_dsa (tpriv->pt.dev)) { +if (netdev_uses_dsa (tpriv->pt.dev) || tpriv->capture_all) { tpriv->packet_type = tpriv->pt.type; tpriv->func = tpriv->pt.func;@@ -994,6 +995,7 @@ static int __stmmac_test_vlanfilt(struct stmmac_priv *priv) tpriv->pt.dev = priv->dev; tpriv->pt.af_packet_priv = tpriv; tpriv->packet = &attr; + tpriv->capture_all = true;/* drivers/net/ethernet/stmicro/stmmac/stmmac_selftests.c +1
-0* As we use HASH filtering, false positives may appear. This is a @@ -1088,6 +1090,7 @@ static int __stmmac_test_dvlanfilt(struct stmmac_priv *priv) tpriv->pt.dev = priv->dev; tpriv->pt.af_packet_priv = tpriv; tpriv->packet = &attr; + tpriv->capture_all = true;/* drivers/net/ethernet/stmicro/stmmac/stmmac_selftests.c +1
-0* As we use HASH filtering, false positives may appear. This is a @@ -1366,6 +1369,7 @@ static int stmmac_test_vlanoff_common(struct stmmac_priv *priv, bool svlan) tpriv->pt.af_packet_priv = tpriv; tpriv->packet = &attr; tpriv->vlan_id =0x123 ; + tpriv->capture_all = true;stmmac_sft_add_pack (&tpriv->pt);
Quoted 1 line
ret =
vlan_vid_add(priv->dev, htons(proto), tpriv->vlan_id);
Thanks,
Nicolai
Maxime Chevallier
maintainerPATCH v2 5/6 net: stmmac: size the RX buffers from the frame length, not the MTU
In reply to Maxime ChevallierWhen 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 '>=' checks on the buffer len, we can use more consistent comparison operators in stmmac_set_bfsize.
--- .../net/ethernet/stmicro/stmmac/stmmac_main.c | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +11 -9
@@ -1536,17 +1536,17 @@ static unsigned int stmmac_rx_offset(struct stmmac_priv *priv)return NET_SKB_PAD +NET_IP_ALIGN ; } -static int stmmac_set_bfsize (int mtu) +static int stmmac_set_bfsize (int len) {int ret; -if (mtu >= BUF_SIZE_8KiB) +if (len > BUF_SIZE_8KiB) ret = BUF_SIZE_16KiB; -else if (mtu >= BUF_SIZE_4KiB) +else if (len > BUF_SIZE_4KiB) ret = BUF_SIZE_8KiB; -else if (mtu >= BUF_SIZE_2KiB) +else if (len > BUF_SIZE_2KiB) ret = BUF_SIZE_4KiB; -else if (mtu >DEFAULT_BUFSIZE ) +else if (len >DEFAULT_BUFSIZE ) ret = BUF_SIZE_2KiB;else ret =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; dma_conf =kzalloc_obj (*dma_conf);
@@ -4073,13 +4073,15 @@ stmmac_setup_dma_desc(struct stmmac_priv *priv, unsigned int mtu)return ERR_PTR (-ENOMEM ); } -/* Returns 0 or BUF_SIZE_16KiB if mtu > 8KiB and dwmac4 or ring mode */ - bfsize =stmmac_set_16kib_bfsize (priv, mtu); + len = 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 =stmmac_set_16kib_bfsize (priv, len);if (bfsize <0 ) bfsize =0 ;if (bfsize < BUF_SIZE_16KiB) - bfsize =stmmac_set_bfsize (mtu); + bfsize =stmmac_set_bfsize (len); dma_conf->dma_buf_sz = bfsize;/* Chose the tx/rx size from the already defined one in the
Signature · 1 line
2.55.0
Re: [PATCH net v2 5/6] net: stmmac: size the RX buffers from the frame length, not the MTU
Quoted 81 lines · Maxime Chevallier
When picking the buffsize to use based on the MTU, we shouldn't check only the MTU value, but also :
-ETH_HLENfor the L2 header,
- up to 2 VLAN tags,
- the FCS,
- theNET_IP_ALIGNThe 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_ALIGNto the start of buffer address tripped the Jumbo selftest, leading to this discovery.With that, we don't need the '>=' 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)")Signed-off-by Maxime Chevallier <[email protected]>--- .../net/ethernet/stmicro/stmmac/stmmac_main.c | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-)drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +11
-9@@ -1536,17 +1536,17 @@ static unsigned int stmmac_rx_offset(struct stmmac_priv *priv)return NET_SKB_PAD +NET_IP_ALIGN ; } -static int stmmac_set_bfsize (int mtu) +static int stmmac_set_bfsize (int len) {int ret; -if (mtu >= BUF_SIZE_8KiB) +if (len > BUF_SIZE_8KiB) ret = BUF_SIZE_16KiB; -else if (mtu >= BUF_SIZE_4KiB) +else if (len > BUF_SIZE_4KiB) ret = BUF_SIZE_8KiB; -else if (mtu >= BUF_SIZE_2KiB) +else if (len > BUF_SIZE_2KiB) ret = BUF_SIZE_4KiB; -else if (mtu >DEFAULT_BUFSIZE ) +else if (len >DEFAULT_BUFSIZE ) ret = BUF_SIZE_2KiB;else ret =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; dma_conf =kzalloc_obj (*dma_conf);@@ -4073,13 +4073,15 @@ stmmac_setup_dma_desc(struct stmmac_priv *priv,unsigned int mtu) return ERR_PTR(-ENOMEM); } -/* Returns 0 or BUF_SIZE_16KiB if mtu > 8KiB and dwmac4 or ring mode */ - bfsize =stmmac_set_16kib_bfsize (priv, mtu); + len = 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 =stmmac_set_16kib_bfsize (priv, len);if (bfsize <0 ) bfsize =0 ;if (bfsize < BUF_SIZE_16KiB) - bfsize =stmmac_set_bfsize (mtu); + bfsize =stmmac_set_bfsize (len);
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c stmmac_setup_dma_desc(struct stmmac_priv *priv, unsigned int mtu) · line 4087
Quoted 2 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +0
-0dma_conf->dma_buf_sz = bfsize;/* Chose the tx/rx size from the already defined one in the
Thanks,
Nicolai
Maxime Chevallier
maintainerPATCH v2 6/6 net: stmmac: selftests: Account for alignment shift on dwmac1000 for Jumbo test
In reply to Maxime ChevallierOn 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.
--- drivers/net/ethernet/stmicro/stmmac/stmmac_selftests.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/ethernet/stmicro/stmmac/stmmac_selftests.c +3 -0
@@ -1776,6 +1776,9 @@ static int __stmmac_test_jumbo(struct stmmac_priv *priv, u16 queue)struct stmmac_packet_attrs attr = { };int size = priv->dma_conf.dma_buf_sz; +if (!dwmac_is_xmac (priv->plat->core_type)) + size -=NET_IP_ALIGN ; + attr.dst = priv->dev->dev_addr; attr.max_size = size -ETH_FCS_LEN ; attr.queue_mapping = queue;
Signature · 1 line
2.55.0
Re: [PATCH net v2 6/6] net: stmmac: selftests: Account for alignment shift on dwmac1000 for Jumbo test
Quoted 35 lines · Maxime Chevallier
On dwmac1000, we currently only support single-descriptor frames. The Jumbo test started failing when
NET_IP_ALIGNwas 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 offset")Signed-off-by Maxime Chevallier <[email protected]>--- drivers/net/ethernet/stmicro/stmmac/stmmac_selftests.c | 3 +++ 1 file changed, 3 insertions(+)drivers/net/ethernet/stmicro/stmmac/stmmac_selftests.c +3
-0@@ -1776,6 +1776,9 @@ static int __stmmac_test_jumbo(struct stmmac_priv *priv, u16 queue)struct stmmac_packet_attrs attr = { };int size = priv->dma_conf.dma_buf_sz; +if (!dwmac_is_xmac (priv->plat->core_type)) + size -=NET_IP_ALIGN ; + attr.dst = priv->dev->dev_addr; attr.max_size = size -ETH_FCS_LEN ;
Quoted 1 line
attr.queue_mapping = queue;
Thanks,
Nicolai