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

muhammad.nazim.amirul.nazle.asmade at altera.com muhammad.nazim.amirul.nazle.asmade at altera.com
Wed Nov 4 00:12:33 PST 2026


From: Nazim Amirul <muhammad.nazim.amirul.nazle.asmade at altera.com>

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.

Only initialize pmac_enabled when FPE is actually supported: gate it on
stmmac_fpe_supported() and return early otherwise, so hardware without
FPE (dma_cap.fpesel clear) does not get pmac_enabled set. Keep emitting
the "FPE is not supported by driver" notice for the case where the
hardware advertises FPE but the driver cannot wire it up.

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 at altera.com>
Signed-off-by: Nazim Amirul <muhammad.nazim.amirul.nazle.asmade at altera.com>
Reviewed-by: Maxime Chevallier <maxime.chevallier at bootlin.com>
---
v3: Gate the pmac_enabled init on stmmac_fpe_supported() and return
    early, so hardware without FPE no longer gets pmac_enabled set. This
    folds in the previous "Add missing return in stmmac_fpe_init()" patch
    and fixes the condition that did not reach its intended effect, per
    Paolo Abeni / Sashiko.
v2: No changes. Collect Reviewed-by from Maxime Chevallier.

 .../net/ethernet/stmicro/stmmac/stmmac_ethtool.c    |  7 +++++++
 drivers/net/ethernet/stmicro/stmmac/stmmac_fpe.c    | 13 ++++++++++---
 2 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c
index c616a1c95e5d..0dfb312d72f1 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c
@@ -1066,6 +1066,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 b6b5ef7c8fc4..2607e29930b7 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_fpe.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_fpe.c
@@ -173,9 +173,16 @@ void stmmac_fpe_init(struct stmmac_priv *priv)
 	ethtool_mmsv_init(&priv->fpe_cfg.mmsv, priv->dev,
 			  &stmmac_mmsv_ops);
 
-	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");
+	if (!stmmac_fpe_supported(priv)) {
+		if (priv->dma_cap.fpesel)
+			dev_info(priv->device, "FPE is not supported by driver.\n");
+		return;
+	}
+
+	/* 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




More information about the linux-arm-kernel mailing list