Skip to contentSkip to conversation

net: stmmac: enhance XDP ZC driver level switching performance

PATCH Applied Ong Boon Leong 3 participants 3 messages Nov 11, 2021 – Nov 15, 2021

Subsystems (6)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: stmmac: enhance XDP ZC driver level switching performance

The previous stmmac_xdp_set_prog() implementation uses stmmac_release() and stmmac_open() which tear down the PHY device and causes undesirable autonegotiation which causes a delay whenever AFXDP ZC is setup.

This patch introduces two new functions that just sufficiently tear down DMA descriptors, buffer, NAPI process, and IRQs and reestablish them accordingly in both stmmac_xdp_release() and stammac_xdp_open().

As the results of this enhancement, we get rid of transient state introduced by the link auto-negotiation:

$ ./xdpsock -i eth0 -t -z

sock0@eth0:0 txonly xdp-drv

                   pps            pkts           1.00
rx                 0              0
tx                 634444         634560

sock0@eth0:0 txonly xdp-drv

                   pps            pkts           1.00
rx                 0              0
tx                 632330         1267072

sock0@eth0:0 txonly xdp-drv

                   pps            pkts           1.00
rx                 0              0
tx                 632438         1899584

sock0@eth0:0 txonly xdp-drv

                   pps            pkts           1.00
rx                 0              0
tx                 632502         2532160
---
 drivers/net/ethernet/stmicro/stmmac/stmmac.h  |   4 +-
 .../net/ethernet/stmicro/stmmac/stmmac_main.c | 137 +++++++++++++++++-
 .../net/ethernet/stmicro/stmmac/stmmac_xdp.c  |   4 +-
 3 files changed, 139 insertions(+), 6 deletions(-)
drivers/net/ethernet/stmicro/stmmac/stmmac.h +2 -2
index 43eead726886..dd7adf9b2537 100644
@@ -316,8 +316,8 @@ void stmmac_set_ethtool_ops(struct net_device *netdev);
 
 void stmmac_ptp_register(struct stmmac_priv *priv);
 void stmmac_ptp_unregister(struct stmmac_priv *priv);
-int stmmac_open(struct net_device *dev);
-int stmmac_release(struct net_device *dev);
+int stmmac_xdp_open(struct net_device *dev);
+void stmmac_xdp_release(struct net_device *dev);
 int stmmac_resume(struct device *dev);
 int stmmac_suspend(struct device *dev);
 int stmmac_dvr_remove(struct device *dev);
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +135 -2

155 lines not on this page · raw message

drivers/net/ethernet/stmicro/stmmac/stmmac_xdp.c +2 -2
index 2a616c6f7cd0..9d4d8c3dad0a 100644
@@ -119,7 +119,7 @@ int stmmac_xdp_set_prog(struct stmmac_priv *priv, struct bpf_prog *prog,
 
 	need_update = !!priv->xdp_prog != !!prog;
 	if (if_running && need_update)
-		stmmac_release(dev);
+		stmmac_xdp_release(dev);
 
 	old_prog = xchg(&priv->xdp_prog, prog);
 	if (old_prog)
@@ -129,7 +129,7 @@ int stmmac_xdp_set_prog(struct stmmac_priv *priv, struct bpf_prog *prog,
 	priv->sph = priv->sph_cap && !stmmac_xdp_is_enabled(priv);
 
 	if (if_running && need_update)
-		stmmac_open(dev);
+		stmmac_xdp_open(dev);
 
 	return 0;
 }
Signature · 1 line
2.25.1
Tested-by on v1 1/1
#1 lore raw
Quoted 28 lines · Ong Boon Leong

The previous stmmac_xdp_set_prog() implementation uses stmmac_release() and stmmac_open() which tear down the PHY device and causes undesirable autonegotiation which causes a delay whenever AFXDP ZC is setup.

This patch introduces two new functions that just sufficiently tear down DMA descriptors, buffer, NAPI process, and IRQs and reestablish them accordingly in both stmmac_xdp_release() and stammac_xdp_open().

As the results of this enhancement, we get rid of transient state introduced by the link auto-negotiation:

$ ./xdpsock -i eth0 -t -z

sock0@eth0:0 txonly xdp-drv

                   pps            pkts           1.00
rx                 0              0
tx                 634444         634560

sock0@eth0:0 txonly xdp-drv

                   pps            pkts           1.00
rx                 0              0
tx                 632330         1267072

sock0@eth0:0 txonly xdp-drv

                   pps            pkts           1.00
rx                 0              0
tx                 632438         1899584
Quoted 7 lines

sock0@eth0:0 txonly xdp-drv

                   pps            pkts           1.00
rx                 0              0
tx                 632502         2532160
#2 lore raw
In reply to Ong Boon Leong
This patch was applied to netdev/net-next.git (master) by David S. Miller <[email protected]>:

Hello:

This patch was applied to netdev/net-next.git (master) by David S. Miller <[email protected]>:

Quoted 9 lines · On Thu, 11 Nov 2021 22:39:49 +0800 you wrote:

The previous stmmac_xdp_set_prog() implementation uses stmmac_release() and stmmac_open() which tear down the PHY device and causes undesirable autonegotiation which causes a delay whenever AFXDP ZC is setup.

This patch introduces two new functions that just sufficiently tear down DMA descriptors, buffer, NAPI process, and IRQs and reestablish them accordingly in both stmmac_xdp_release() and stammac_xdp_open().

[...]

Here is the summary with links:
- [net-next,1/1] net: stmmac: enhance XDP ZC driver level switching performance

    https://git.kernel.org/netdev/net-next/c/ac746c8520d9

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html