[PATCH net-next 1/3] net: stmmac: fpe: Enforce pmac_enabled in set_mm and keep it on at init

From: muhammad . nazim . amirul . nazle . asmade

Date: Tue Jul 28 2026 - 21:55:29 EST


From: Nazim Amirul <muhammad.nazim.amirul.nazle.asmade@xxxxxxxxxx>

The preemptive MAC in DWMAC is always enabled, meaning DWMAC is always
ready to receive preemptive mPackets. Initialize pmac_enabled to true
at init time and reject attempts to disable it via ethtool set_mm.

Also add a missing fpesel capability check in stmmac_set_mm() to return
-EOPNOTSUPP early on hardware without FPE support.

Signed-off-by: Rohan G Thomas <rohan.g.thomas@xxxxxxxxxx>
Signed-off-by: Nazim Amirul <muhammad.nazim.amirul.nazle.asmade@xxxxxxxxxx>
---
drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c | 7 +++++++
drivers/net/ethernet/stmicro/stmmac/stmmac_fpe.c | 5 +++++
2 files changed, 12 insertions(+)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c
index 92585d27ab88..8ebdd249e5c8 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c
@@ -1064,6 +1064,13 @@ static int stmmac_set_mm(struct net_device *ndev, struct ethtool_mm_cfg *cfg,
if (err)
return err;

+ if (!priv->dma_cap.fpesel)
+ return -EOPNOTSUPP;
+
+ /* DWMAC always have preemptible MAC enabled */
+ if (!cfg->pmac_enabled)
+ return -EINVAL;
+
stmmac_fpe_set_add_frag_size(priv, frag_size);
ethtool_mmsv_set_mm(&priv->fpe_cfg.mmsv, cfg);

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_fpe.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_fpe.c
index c54c70224351..2f880c5e35b0 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_fpe.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_fpe.c
@@ -176,6 +176,11 @@ void stmmac_fpe_init(struct stmmac_priv *priv)
if ((!priv->fpe_cfg.reg || !priv->hw->mac->fpe_map_preemption_class) &&
priv->dma_cap.fpesel)
dev_info(priv->device, "FPE is not supported by driver.\n");
+
+ /* The preemptive MAC in DWMAC is always enabled, so initialize
+ * pmac_enabled to true to reflect the hardware state.
+ */
+ priv->fpe_cfg.mmsv.pmac_enabled = true;
}

int stmmac_fpe_get_add_frag_size(struct stmmac_priv *priv)
--
2.43.7