net: stmmac: Move the atds flag to the stmmac_dma_cfg structure
authorYanteng Si <siyanteng@loongson.cn>
Wed, 7 Aug 2024 13:45:28 +0000 (21:45 +0800)
committerPaolo Abeni <pabeni@redhat.com>
Tue, 13 Aug 2024 07:48:00 +0000 (09:48 +0200)
ATDS (Alternate Descriptor Size) is a part of the DMA Bus Mode configs
(together with PBL, ALL, EME, etc) of the DW GMAC controllers. Seeing
it's not changed at runtime but is activated as long as the IP-core
has it supported (at least due to the Type 2 Full Checksum Offload
Engine feature), move the respective parameter from the
stmmac_dma_ops::init() callback argument to the stmmac_dma_cfg
structure, which already have the rest of the DMA-related configs
defined.

Besides the being added in the next commit DW GMAC multi-channels
support will require to add the stmmac_dma_ops::init_chan() callback
and have the ATDS flag set/cleared for each channel in there. Having
the atds-flag in the stmmac_dma_cfg structure will make the parameter
accessible from stmmac_dma_ops::init_chan() callback too.

Signed-off-by: Feiyang Chen <chenfeiyang@loongson.cn>
Signed-off-by: Yinggang Gu <guyinggang@loongson.cn>
Reviewed-by: Serge Semin <fancer.lancer@gmail.com>
Acked-by: Huacai Chen <chenhuacai@loongson.cn>
Signed-off-by: Yanteng Si <siyanteng@loongson.cn>
Tested-by: Serge Semin <fancer.lancer@gmail.com>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
drivers/net/ethernet/stmicro/stmmac/dwmac1000_dma.c
drivers/net/ethernet/stmicro/stmmac/dwmac100_dma.c
drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.c
drivers/net/ethernet/stmicro/stmmac/dwxgmac2_dma.c
drivers/net/ethernet/stmicro/stmmac/hwif.h
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
include/linux/stmmac.h

index e1b761dcfa1dd56f2e5218312933eb1ea6bc06b1..d870790169524ea22c0412b188c00f13e713d12d 100644 (file)
@@ -299,7 +299,7 @@ static int sun8i_dwmac_dma_reset(void __iomem *ioaddr)
  * Called from stmmac via stmmac_dma_ops->init
  */
 static void sun8i_dwmac_dma_init(void __iomem *ioaddr,
-                                struct stmmac_dma_cfg *dma_cfg, int atds)
+                                struct stmmac_dma_cfg *dma_cfg)
 {
        writel(EMAC_RX_INT | EMAC_TX_INT, ioaddr + EMAC_INT_EN);
        writel(0x1FFFFFF, ioaddr + EMAC_INT_STA);
index adccdd816ea913eda3e0b8326ac304ea8016d25f..984b809105afa3a5dfd8f9aca15979179b7be7d8 100644 (file)
@@ -71,7 +71,7 @@ static void dwmac1000_dma_axi(void __iomem *ioaddr, struct stmmac_axi *axi)
 }
 
 static void dwmac1000_dma_init(void __iomem *ioaddr,
-                              struct stmmac_dma_cfg *dma_cfg, int atds)
+                              struct stmmac_dma_cfg *dma_cfg)
 {
        u32 value = readl(ioaddr + DMA_BUS_MODE);
        int txpbl = dma_cfg->txpbl ?: dma_cfg->pbl;
@@ -98,7 +98,7 @@ static void dwmac1000_dma_init(void __iomem *ioaddr,
        if (dma_cfg->mixed_burst)
                value |= DMA_BUS_MODE_MB;
 
-       if (atds)
+       if (dma_cfg->atds)
                value |= DMA_BUS_MODE_ATDS;
 
        if (dma_cfg->aal)
index b402fb54f6131b60d649093c4d4baaa3b0d9b52d..82957db47c991187238da009816251ff371e0b66 100644 (file)
@@ -19,7 +19,7 @@
 #include "dwmac_dma.h"
 
 static void dwmac100_dma_init(void __iomem *ioaddr,
-                             struct stmmac_dma_cfg *dma_cfg, int atds)
+                             struct stmmac_dma_cfg *dma_cfg)
 {
        /* Enable Application Access by writing to DMA CSR0 */
        writel(DMA_BUS_MODE_DEFAULT | (dma_cfg->pbl << DMA_BUS_MODE_PBL_SHIFT),
index 84d3a8551b03225ff114e03cba0e4e6c1a0d616d..e0165358c4ac88bb46adf17dcf449b08eafd5f6e 100644 (file)
@@ -153,7 +153,7 @@ static void dwmac410_dma_init_channel(struct stmmac_priv *priv,
 }
 
 static void dwmac4_dma_init(void __iomem *ioaddr,
-                           struct stmmac_dma_cfg *dma_cfg, int atds)
+                           struct stmmac_dma_cfg *dma_cfg)
 {
        u32 value = readl(ioaddr + DMA_SYS_BUS_MODE);
 
index dd2ab6185c40e813ee4401857875d3e8478303e7..7840bc403788ef8df62870630273abc513da34de 100644 (file)
@@ -20,7 +20,7 @@ static int dwxgmac2_dma_reset(void __iomem *ioaddr)
 }
 
 static void dwxgmac2_dma_init(void __iomem *ioaddr,
-                             struct stmmac_dma_cfg *dma_cfg, int atds)
+                             struct stmmac_dma_cfg *dma_cfg)
 {
        u32 value = readl(ioaddr + XGMAC_DMA_SYSBUS_MODE);
 
index e53c3236277498b8662b74073488bad8ff173853..1c99c99f462796970f0868ed9472c45d51f13c9b 100644 (file)
@@ -175,8 +175,7 @@ struct dma_features;
 struct stmmac_dma_ops {
        /* DMA core initialization */
        int (*reset)(void __iomem *ioaddr);
-       void (*init)(void __iomem *ioaddr, struct stmmac_dma_cfg *dma_cfg,
-                    int atds);
+       void (*init)(void __iomem *ioaddr, struct stmmac_dma_cfg *dma_cfg);
        void (*init_chan)(struct stmmac_priv *priv, void __iomem *ioaddr,
                          struct stmmac_dma_cfg *dma_cfg, u32 chan);
        void (*init_rx_chan)(struct stmmac_priv *priv, void __iomem *ioaddr,
index f3a1b179aaeaca2189974fce4724db0a175b5de3..9f1286835550eb292f4adeedd392d47f5214751d 100644 (file)
@@ -3003,7 +3003,6 @@ static int stmmac_init_dma_engine(struct stmmac_priv *priv)
        struct stmmac_rx_queue *rx_q;
        struct stmmac_tx_queue *tx_q;
        u32 chan = 0;
-       int atds = 0;
        int ret = 0;
 
        if (!priv->plat->dma_cfg || !priv->plat->dma_cfg->pbl) {
@@ -3012,7 +3011,7 @@ static int stmmac_init_dma_engine(struct stmmac_priv *priv)
        }
 
        if (priv->extend_desc && (priv->mode == STMMAC_RING_MODE))
-               atds = 1;
+               priv->plat->dma_cfg->atds = 1;
 
        ret = stmmac_reset(priv, priv->ioaddr);
        if (ret) {
@@ -3021,7 +3020,7 @@ static int stmmac_init_dma_engine(struct stmmac_priv *priv)
        }
 
        /* DMA Configuration */
-       stmmac_dma_init(priv, priv->ioaddr, priv->plat->dma_cfg, atds);
+       stmmac_dma_init(priv, priv->ioaddr, priv->plat->dma_cfg);
 
        if (priv->plat->axi)
                stmmac_axi(priv, priv->ioaddr, priv->plat->axi);
index 84e13bd5df284d3a38f530f59b2346bad9dc913c..338991c08f007287c114f928c75f64e08a9ec029 100644 (file)
@@ -100,6 +100,7 @@ struct stmmac_dma_cfg {
        bool eame;
        bool multi_msi_en;
        bool dche;
+       bool atds;
 };
 
 #define AXI_BLEN       7