net: stmmac: Introduce stmmac_fpe_supported()
authorFurong Xu <0x1207@gmail.com>
Fri, 1 Nov 2024 13:31:30 +0000 (21:31 +0800)
committerJakub Kicinski <kuba@kernel.org>
Sun, 3 Nov 2024 23:31:23 +0000 (15:31 -0800)
A single "priv->dma_cap.fpesel" checks HW capability only,
while both HW capability and driver capability shall be
checked by later refactoring to prevent unexpected behavior
for FPE on unsupported MAC cores and keep FPE as an optional
implementation for current and new MAC cores.

Signed-off-by: Furong Xu <0x1207@gmail.com>
Reviewed-by: Vladimir Oltean <olteanv@gmail.com>
Link: https://patch.msgid.link/01e9cd13aedd38cb0e9a5d9875c475ce35250188.1730449003.git.0x1207@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c
drivers/net/ethernet/stmicro/stmmac/stmmac_fpe.c
drivers/net/ethernet/stmicro/stmmac/stmmac_fpe.h
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c

index 2792a4c6cbcd288eefacd722d44d3299974ecae9..704019e2755b386756608da836c07dacbe2a9494 100644 (file)
@@ -1271,7 +1271,7 @@ static int stmmac_get_mm(struct net_device *ndev,
        unsigned long flags;
        u32 frag_size;
 
-       if (!priv->dma_cap.fpesel)
+       if (!stmmac_fpe_supported(priv))
                return -EOPNOTSUPP;
 
        spin_lock_irqsave(&priv->fpe_cfg.lock, flags);
index 41c9cccfb5de66d04c358ef61b7bf1cd1031ea79..2b99033f94252f5dccd25a937a3c584fa60d4d1e 100644 (file)
 #define STMMAC_MAC_FPE_CTRL_STS_SVER   BIT(1)
 #define STMMAC_MAC_FPE_CTRL_STS_EFPE   BIT(0)
 
+bool stmmac_fpe_supported(struct stmmac_priv *priv)
+{
+       return priv->dma_cap.fpesel;
+}
+
 void dwmac5_fpe_configure(void __iomem *ioaddr, struct stmmac_fpe_cfg *cfg,
                          u32 num_txq, u32 num_rxq,
                          bool tx_enable, bool pmac_enable)
index 25725fd5182fffbeee61aedabcf338ed153af208..fc9d869f9b6a7afc4ad82e1a4637f8c19a0b00a6 100644 (file)
@@ -23,6 +23,7 @@ struct stmmac_fpe_cfg;
 
 void stmmac_fpe_link_state_handle(struct stmmac_priv *priv, bool is_up);
 void stmmac_fpe_event_status(struct stmmac_priv *priv, int status);
+bool stmmac_fpe_supported(struct stmmac_priv *priv);
 void stmmac_fpe_init(struct stmmac_priv *priv);
 void stmmac_fpe_apply(struct stmmac_priv *priv);
 
index 20bd5440abcaabe14cb84189e53c37ae9157b782..342edec8b5074f6a59a75c7064f459bc5fc6a902 100644 (file)
@@ -978,7 +978,7 @@ static void stmmac_mac_link_down(struct phylink_config *config,
        priv->eee_enabled = stmmac_eee_init(priv);
        stmmac_set_eee_pls(priv, priv->hw, false);
 
-       if (priv->dma_cap.fpesel)
+       if (stmmac_fpe_supported(priv))
                stmmac_fpe_link_state_handle(priv, false);
 }
 
@@ -1092,7 +1092,7 @@ static void stmmac_mac_link_up(struct phylink_config *config,
                stmmac_set_eee_pls(priv, priv->hw, true);
        }
 
-       if (priv->dma_cap.fpesel)
+       if (stmmac_fpe_supported(priv))
                stmmac_fpe_link_state_handle(priv, true);
 
        if (priv->plat->flags & STMMAC_FLAG_HWTSTAMP_CORRECT_LATENCY)
@@ -4040,7 +4040,7 @@ static int stmmac_release(struct net_device *dev)
 
        stmmac_release_ptp(priv);
 
-       if (priv->dma_cap.fpesel)
+       if (stmmac_fpe_supported(priv))
                timer_shutdown_sync(&priv->fpe_cfg.verify_timer);
 
        pm_runtime_put(priv->device);
@@ -5955,7 +5955,7 @@ static void stmmac_common_interrupt(struct stmmac_priv *priv)
                stmmac_est_irq_status(priv, priv, priv->dev,
                                      &priv->xstats, tx_cnt);
 
-       if (priv->dma_cap.fpesel) {
+       if (stmmac_fpe_supported(priv)) {
                int status = stmmac_fpe_irq_status(priv, priv->ioaddr,
                                                   priv->dev);
 
@@ -7745,7 +7745,7 @@ int stmmac_suspend(struct device *dev)
        }
        rtnl_unlock();
 
-       if (priv->dma_cap.fpesel)
+       if (stmmac_fpe_supported(priv))
                timer_shutdown_sync(&priv->fpe_cfg.verify_timer);
 
        priv->speed = SPEED_UNKNOWN;