net: stmmac: Switch stmmac_desc_ops to generic HW Interface Helpers
authorJose Abreu <Jose.Abreu@synopsys.com>
Mon, 16 Apr 2018 15:08:12 +0000 (16:08 +0100)
committerDavid S. Miller <davem@davemloft.net>
Mon, 16 Apr 2018 22:49:26 +0000 (18:49 -0400)
Switch stmmac_desc_ops to generic Hardware Interface Helpers instead of
using hard-coded callbacks. This makes the code more readable and more
flexible.

No functional change.

Signed-off-by: Jose Abreu <joabreu@synopsys.com>
Cc: David S. Miller <davem@davemloft.net>
Cc: Joao Pinto <jpinto@synopsys.com>
Cc: Giuseppe Cavallaro <peppe.cavallaro@st.com>
Cc: Alexandre Torgue <alexandre.torgue@st.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/stmicro/stmmac/chain_mode.c
drivers/net/ethernet/stmicro/stmmac/common.h
drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c
drivers/net/ethernet/stmicro/stmmac/enh_desc.c
drivers/net/ethernet/stmicro/stmmac/hwif.h [new file with mode: 0644]
drivers/net/ethernet/stmicro/stmmac/norm_desc.c
drivers/net/ethernet/stmicro/stmmac/ring_mode.c
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c

index e93c40b4631ecfd706cb0b7c16d58fa5089aa35f..ca0f9c205f9dc6c067551bca8b18396dd3c0a570 100644 (file)
@@ -51,8 +51,8 @@ static int stmmac_jumbo_frm(void *p, struct sk_buff *skb, int csum)
        tx_q->tx_skbuff_dma[entry].buf = des2;
        tx_q->tx_skbuff_dma[entry].len = bmax;
        /* do not close the descriptor and do not set own bit */
-       priv->hw->desc->prepare_tx_desc(desc, 1, bmax, csum, STMMAC_CHAIN_MODE,
-                                       0, false, skb->len);
+       stmmac_prepare_tx_desc(priv, desc, 1, bmax, csum, STMMAC_CHAIN_MODE,
+                       0, false, skb->len);
 
        while (len != 0) {
                tx_q->tx_skbuff[entry] = NULL;
@@ -68,9 +68,8 @@ static int stmmac_jumbo_frm(void *p, struct sk_buff *skb, int csum)
                                return -1;
                        tx_q->tx_skbuff_dma[entry].buf = des2;
                        tx_q->tx_skbuff_dma[entry].len = bmax;
-                       priv->hw->desc->prepare_tx_desc(desc, 0, bmax, csum,
-                                                       STMMAC_CHAIN_MODE, 1,
-                                                       false, skb->len);
+                       stmmac_prepare_tx_desc(priv, desc, 0, bmax, csum,
+                                       STMMAC_CHAIN_MODE, 1, false, skb->len);
                        len -= bmax;
                        i++;
                } else {
@@ -83,9 +82,8 @@ static int stmmac_jumbo_frm(void *p, struct sk_buff *skb, int csum)
                        tx_q->tx_skbuff_dma[entry].buf = des2;
                        tx_q->tx_skbuff_dma[entry].len = len;
                        /* last descriptor can be set now */
-                       priv->hw->desc->prepare_tx_desc(desc, 0, len, csum,
-                                                       STMMAC_CHAIN_MODE, 1,
-                                                       true, skb->len);
+                       stmmac_prepare_tx_desc(priv, desc, 0, len, csum,
+                                       STMMAC_CHAIN_MODE, 1, true, skb->len);
                        len = 0;
                }
        }
index ad2388aee4637b56cd676cf08782febcdb9d1d2e..2c50d8c0a5570896c5790cbf8066d700ffd62726 100644 (file)
@@ -32,6 +32,7 @@
 #endif
 
 #include "descs.h"
+#include "hwif.h"
 #include "mmc.h"
 
 /* Synopsys Core versions */
@@ -377,60 +378,6 @@ struct dma_features {
 
 #define JUMBO_LEN              9000
 
-/* Descriptors helpers */
-struct stmmac_desc_ops {
-       /* DMA RX descriptor ring initialization */
-       void (*init_rx_desc) (struct dma_desc *p, int disable_rx_ic, int mode,
-                             int end);
-       /* DMA TX descriptor ring initialization */
-       void (*init_tx_desc) (struct dma_desc *p, int mode, int end);
-
-       /* Invoked by the xmit function to prepare the tx descriptor */
-       void (*prepare_tx_desc) (struct dma_desc *p, int is_fs, int len,
-                                bool csum_flag, int mode, bool tx_own,
-                                bool ls, unsigned int tot_pkt_len);
-       void (*prepare_tso_tx_desc)(struct dma_desc *p, int is_fs, int len1,
-                                   int len2, bool tx_own, bool ls,
-                                   unsigned int tcphdrlen,
-                                   unsigned int tcppayloadlen);
-       /* Set/get the owner of the descriptor */
-       void (*set_tx_owner) (struct dma_desc *p);
-       int (*get_tx_owner) (struct dma_desc *p);
-       /* Clean the tx descriptor as soon as the tx irq is received */
-       void (*release_tx_desc) (struct dma_desc *p, int mode);
-       /* Clear interrupt on tx frame completion. When this bit is
-        * set an interrupt happens as soon as the frame is transmitted */
-       void (*set_tx_ic)(struct dma_desc *p);
-       /* Last tx segment reports the transmit status */
-       int (*get_tx_ls) (struct dma_desc *p);
-       /* Return the transmit status looking at the TDES1 */
-       int (*tx_status) (void *data, struct stmmac_extra_stats *x,
-                         struct dma_desc *p, void __iomem *ioaddr);
-       /* Get the buffer size from the descriptor */
-       int (*get_tx_len) (struct dma_desc *p);
-       /* Handle extra events on specific interrupts hw dependent */
-       void (*set_rx_owner) (struct dma_desc *p);
-       /* Get the receive frame size */
-       int (*get_rx_frame_len) (struct dma_desc *p, int rx_coe_type);
-       /* Return the reception status looking at the RDES1 */
-       int (*rx_status) (void *data, struct stmmac_extra_stats *x,
-                         struct dma_desc *p);
-       void (*rx_extended_status) (void *data, struct stmmac_extra_stats *x,
-                                   struct dma_extended_desc *p);
-       /* Set tx timestamp enable bit */
-       void (*enable_tx_timestamp) (struct dma_desc *p);
-       /* get tx timestamp status */
-       int (*get_tx_timestamp_status) (struct dma_desc *p);
-       /* get timestamp value */
-        u64(*get_timestamp) (void *desc, u32 ats);
-       /* get rx timestamp status */
-       int (*get_rx_timestamp_status)(void *desc, void *next_desc, u32 ats);
-       /* Display ring */
-       void (*display_ring)(void *head, unsigned int size, bool rx);
-       /* set MSS via context descriptor */
-       void (*set_mss)(struct dma_desc *p, unsigned int mss);
-};
-
 extern const struct stmmac_desc_ops enh_desc_ops;
 extern const struct stmmac_desc_ops ndesc_ops;
 
index 2a6521d33e4327ce420eb8fdaad1b09b05bdc615..65ed896c13cb3f1f4acf892075f6c99a3d200668 100644 (file)
@@ -223,7 +223,7 @@ static int dwmac4_wrback_get_tx_timestamp_status(struct dma_desc *p)
        return 0;
 }
 
-static inline u64 dwmac4_get_timestamp(void *desc, u32 ats)
+static inline void dwmac4_get_timestamp(void *desc, u32 ats, u64 *ts)
 {
        struct dma_desc *p = (struct dma_desc *)desc;
        u64 ns;
@@ -232,7 +232,7 @@ static inline u64 dwmac4_get_timestamp(void *desc, u32 ats)
        /* convert high/sec time stamp value to nanosecond */
        ns += le32_to_cpu(p->des1) * 1000000000ULL;
 
-       return ns;
+       *ts = ns;
 }
 
 static int dwmac4_rx_check_timestamp(void *desc)
index 6768a25b6aa09443e831e65a01db11fe7b350a28..3bfb3f584be2008a00ff084b932ad8665116931b 100644 (file)
@@ -382,7 +382,7 @@ static int enh_desc_get_tx_timestamp_status(struct dma_desc *p)
        return (le32_to_cpu(p->des0) & ETDES0_TIME_STAMP_STATUS) >> 17;
 }
 
-static u64 enh_desc_get_timestamp(void *desc, u32 ats)
+static void enh_desc_get_timestamp(void *desc, u32 ats, u64 *ts)
 {
        u64 ns;
 
@@ -397,7 +397,7 @@ static u64 enh_desc_get_timestamp(void *desc, u32 ats)
                ns += le32_to_cpu(p->des3) * 1000000000ULL;
        }
 
-       return ns;
+       *ts = ns;
 }
 
 static int enh_desc_get_rx_timestamp_status(void *desc, void *next_desc,
diff --git a/drivers/net/ethernet/stmicro/stmmac/hwif.h b/drivers/net/ethernet/stmicro/stmmac/hwif.h
new file mode 100644 (file)
index 0000000..4994677
--- /dev/null
@@ -0,0 +1,125 @@
+// SPDX-License-Identifier: (GPL-2.0 OR MIT)
+// Copyright (c) 2018 Synopsys, Inc. and/or its affiliates.
+// stmmac HW Interface Callbacks
+
+#ifndef __STMMAC_HWIF_H__
+#define __STMMAC_HWIF_H__
+
+#define stmmac_do_void_callback(__priv, __module, __cname,  __arg0, __args...) \
+({ \
+       int __result = -EINVAL; \
+       if ((__priv)->hw->__module->__cname) { \
+               (__priv)->hw->__module->__cname((__arg0), ##__args); \
+               __result = 0; \
+       } \
+       __result; \
+})
+#define stmmac_do_callback(__priv, __module, __cname,  __arg0, __args...) \
+({ \
+       int __result = -EINVAL; \
+       if ((__priv)->hw->__module->__cname) \
+               __result = (__priv)->hw->__module->__cname((__arg0), ##__args); \
+       __result; \
+})
+
+struct stmmac_extra_stats;
+struct stmmac_safety_stats;
+struct dma_desc;
+struct dma_extended_desc;
+
+/* Descriptors helpers */
+struct stmmac_desc_ops {
+       /* DMA RX descriptor ring initialization */
+       void (*init_rx_desc)(struct dma_desc *p, int disable_rx_ic, int mode,
+                       int end);
+       /* DMA TX descriptor ring initialization */
+       void (*init_tx_desc)(struct dma_desc *p, int mode, int end);
+       /* Invoked by the xmit function to prepare the tx descriptor */
+       void (*prepare_tx_desc)(struct dma_desc *p, int is_fs, int len,
+                       bool csum_flag, int mode, bool tx_own, bool ls,
+                       unsigned int tot_pkt_len);
+       void (*prepare_tso_tx_desc)(struct dma_desc *p, int is_fs, int len1,
+                       int len2, bool tx_own, bool ls, unsigned int tcphdrlen,
+                       unsigned int tcppayloadlen);
+       /* Set/get the owner of the descriptor */
+       void (*set_tx_owner)(struct dma_desc *p);
+       int (*get_tx_owner)(struct dma_desc *p);
+       /* Clean the tx descriptor as soon as the tx irq is received */
+       void (*release_tx_desc)(struct dma_desc *p, int mode);
+       /* Clear interrupt on tx frame completion. When this bit is
+        * set an interrupt happens as soon as the frame is transmitted */
+       void (*set_tx_ic)(struct dma_desc *p);
+       /* Last tx segment reports the transmit status */
+       int (*get_tx_ls)(struct dma_desc *p);
+       /* Return the transmit status looking at the TDES1 */
+       int (*tx_status)(void *data, struct stmmac_extra_stats *x,
+                       struct dma_desc *p, void __iomem *ioaddr);
+       /* Get the buffer size from the descriptor */
+       int (*get_tx_len)(struct dma_desc *p);
+       /* Handle extra events on specific interrupts hw dependent */
+       void (*set_rx_owner)(struct dma_desc *p);
+       /* Get the receive frame size */
+       int (*get_rx_frame_len)(struct dma_desc *p, int rx_coe_type);
+       /* Return the reception status looking at the RDES1 */
+       int (*rx_status)(void *data, struct stmmac_extra_stats *x,
+                       struct dma_desc *p);
+       void (*rx_extended_status)(void *data, struct stmmac_extra_stats *x,
+                       struct dma_extended_desc *p);
+       /* Set tx timestamp enable bit */
+       void (*enable_tx_timestamp) (struct dma_desc *p);
+       /* get tx timestamp status */
+       int (*get_tx_timestamp_status) (struct dma_desc *p);
+       /* get timestamp value */
+       void (*get_timestamp)(void *desc, u32 ats, u64 *ts);
+       /* get rx timestamp status */
+       int (*get_rx_timestamp_status)(void *desc, void *next_desc, u32 ats);
+       /* Display ring */
+       void (*display_ring)(void *head, unsigned int size, bool rx);
+       /* set MSS via context descriptor */
+       void (*set_mss)(struct dma_desc *p, unsigned int mss);
+};
+
+#define stmmac_init_rx_desc(__priv, __args...) \
+       stmmac_do_void_callback(__priv, desc, init_rx_desc, __args)
+#define stmmac_init_tx_desc(__priv, __args...) \
+       stmmac_do_void_callback(__priv, desc, init_tx_desc, __args)
+#define stmmac_prepare_tx_desc(__priv, __args...) \
+       stmmac_do_void_callback(__priv, desc, prepare_tx_desc, __args)
+#define stmmac_prepare_tso_tx_desc(__priv, __args...) \
+       stmmac_do_void_callback(__priv, desc, prepare_tso_tx_desc, __args)
+#define stmmac_set_tx_owner(__priv, __args...) \
+       stmmac_do_void_callback(__priv, desc, set_tx_owner, __args)
+#define stmmac_get_tx_owner(__priv, __args...) \
+       stmmac_do_callback(__priv, desc, get_tx_owner, __args)
+#define stmmac_release_tx_desc(__priv, __args...) \
+       stmmac_do_void_callback(__priv, desc, release_tx_desc, __args)
+#define stmmac_set_tx_ic(__priv, __args...) \
+       stmmac_do_void_callback(__priv, desc, set_tx_ic, __args)
+#define stmmac_get_tx_ls(__priv, __args...) \
+       stmmac_do_callback(__priv, desc, get_tx_ls, __args)
+#define stmmac_tx_status(__priv, __args...) \
+       stmmac_do_callback(__priv, desc, tx_status, __args)
+#define stmmac_get_tx_len(__priv, __args...) \
+       stmmac_do_callback(__priv, desc, get_tx_len, __args)
+#define stmmac_set_rx_owner(__priv, __args...) \
+       stmmac_do_void_callback(__priv, desc, set_rx_owner, __args)
+#define stmmac_get_rx_frame_len(__priv, __args...) \
+       stmmac_do_callback(__priv, desc, get_rx_frame_len, __args)
+#define stmmac_rx_status(__priv, __args...) \
+       stmmac_do_callback(__priv, desc, rx_status, __args)
+#define stmmac_rx_extended_status(__priv, __args...) \
+       stmmac_do_void_callback(__priv, desc, rx_extended_status, __args)
+#define stmmac_enable_tx_timestamp(__priv, __args...) \
+       stmmac_do_void_callback(__priv, desc, enable_tx_timestamp, __args)
+#define stmmac_get_tx_timestamp_status(__priv, __args...) \
+       stmmac_do_callback(__priv, desc, get_tx_timestamp_status, __args)
+#define stmmac_get_timestamp(__priv, __args...) \
+       stmmac_do_void_callback(__priv, desc, get_timestamp, __args)
+#define stmmac_get_rx_timestamp_status(__priv, __args...) \
+       stmmac_do_callback(__priv, desc, get_rx_timestamp_status, __args)
+#define stmmac_display_ring(__priv, __args...) \
+       stmmac_do_void_callback(__priv, desc, display_ring, __args)
+#define stmmac_set_mss(__priv, __args...) \
+       stmmac_do_void_callback(__priv, desc, set_mss, __args)
+
+#endif /* __STMMAC_HWIF_H__ */
index ebd9e5e00f1619c9d09718a2d13163ecf3596687..7b1d901bf5bc2e3af72f5b08ebceb534384d7b7c 100644 (file)
@@ -253,7 +253,7 @@ static int ndesc_get_tx_timestamp_status(struct dma_desc *p)
        return (le32_to_cpu(p->des0) & TDES0_TIME_STAMP_STATUS) >> 17;
 }
 
-static u64 ndesc_get_timestamp(void *desc, u32 ats)
+static void ndesc_get_timestamp(void *desc, u32 ats, u64 *ts)
 {
        struct dma_desc *p = (struct dma_desc *)desc;
        u64 ns;
@@ -262,7 +262,7 @@ static u64 ndesc_get_timestamp(void *desc, u32 ats)
        /* convert high/sec time stamp value to nanosecond */
        ns += le32_to_cpu(p->des3) * 1000000000ULL;
 
-       return ns;
+       *ts = ns;
 }
 
 static int ndesc_get_rx_timestamp_status(void *desc, void *next_desc, u32 ats)
index 28e4b5d50ce6c0afc9c0e03dd5dc312009acda02..808ca758d0aeb888c3b7df825dd8fd92643e93ee 100644 (file)
@@ -58,9 +58,8 @@ static int stmmac_jumbo_frm(void *p, struct sk_buff *skb, int csum)
                tx_q->tx_skbuff_dma[entry].is_jumbo = true;
 
                desc->des3 = cpu_to_le32(des2 + BUF_SIZE_4KiB);
-               priv->hw->desc->prepare_tx_desc(desc, 1, bmax, csum,
-                                               STMMAC_RING_MODE, 0,
-                                               false, skb->len);
+               stmmac_prepare_tx_desc(priv, desc, 1, bmax, csum,
+                               STMMAC_RING_MODE, 0, false, skb->len);
                tx_q->tx_skbuff[entry] = NULL;
                entry = STMMAC_GET_ENTRY(entry, DMA_TX_SIZE);
 
@@ -79,9 +78,8 @@ static int stmmac_jumbo_frm(void *p, struct sk_buff *skb, int csum)
                tx_q->tx_skbuff_dma[entry].is_jumbo = true;
 
                desc->des3 = cpu_to_le32(des2 + BUF_SIZE_4KiB);
-               priv->hw->desc->prepare_tx_desc(desc, 0, len, csum,
-                                               STMMAC_RING_MODE, 1,
-                                               true, skb->len);
+               stmmac_prepare_tx_desc(priv, desc, 0, len, csum,
+                               STMMAC_RING_MODE, 1, true, skb->len);
        } else {
                des2 = dma_map_single(priv->device, skb->data,
                                      nopaged_len, DMA_TO_DEVICE);
@@ -92,9 +90,8 @@ static int stmmac_jumbo_frm(void *p, struct sk_buff *skb, int csum)
                tx_q->tx_skbuff_dma[entry].len = nopaged_len;
                tx_q->tx_skbuff_dma[entry].is_jumbo = true;
                desc->des3 = cpu_to_le32(des2 + BUF_SIZE_4KiB);
-               priv->hw->desc->prepare_tx_desc(desc, 1, nopaged_len, csum,
-                                               STMMAC_RING_MODE, 0,
-                                               true, skb->len);
+               stmmac_prepare_tx_desc(priv, desc, 1, nopaged_len, csum,
+                               STMMAC_RING_MODE, 0, true, skb->len);
        }
 
        tx_q->cur_tx = entry;
index 9a16931ce39d14c43ecb950cf46779c7197f0a22..c44e19d5dbf238455fdecc7cb1dd662c34a22f14 100644 (file)
@@ -50,6 +50,7 @@
 #include <linux/reset.h>
 #include <linux/of_mdio.h>
 #include "dwmac1000.h"
+#include "hwif.h"
 
 #define STMMAC_ALIGN(x)        L1_CACHE_ALIGN(x)
 #define        TSO_MAX_BUFF_SIZE       (SZ_16K - 1)
@@ -464,9 +465,9 @@ static void stmmac_get_tx_hwtstamp(struct stmmac_priv *priv,
                return;
 
        /* check tx tstamp status */
-       if (priv->hw->desc->get_tx_timestamp_status(p)) {
+       if (stmmac_get_tx_timestamp_status(priv, p)) {
                /* get the valid tstamp */
-               ns = priv->hw->desc->get_timestamp(p, priv->adv_ts);
+               stmmac_get_timestamp(priv, p, priv->adv_ts, &ns);
 
                memset(&shhwtstamp, 0, sizeof(struct skb_shared_hwtstamps));
                shhwtstamp.hwtstamp = ns_to_ktime(ns);
@@ -502,8 +503,8 @@ static void stmmac_get_rx_hwtstamp(struct stmmac_priv *priv, struct dma_desc *p,
                desc = np;
 
        /* Check if timestamp is available */
-       if (priv->hw->desc->get_rx_timestamp_status(p, np, priv->adv_ts)) {
-               ns = priv->hw->desc->get_timestamp(desc, priv->adv_ts);
+       if (stmmac_get_rx_timestamp_status(priv, p, np, priv->adv_ts)) {
+               stmmac_get_timestamp(priv, desc, priv->adv_ts, &ns);
                netdev_dbg(priv->dev, "get valid RX hw timestamp %llu\n", ns);
                shhwtstamp = skb_hwtstamps(skb);
                memset(shhwtstamp, 0, sizeof(struct skb_shared_hwtstamps));
@@ -1008,7 +1009,7 @@ static void stmmac_display_rx_rings(struct stmmac_priv *priv)
                        head_rx = (void *)rx_q->dma_rx;
 
                /* Display RX ring */
-               priv->hw->desc->display_ring(head_rx, DMA_RX_SIZE, true);
+               stmmac_display_ring(priv, head_rx, DMA_RX_SIZE, true);
        }
 }
 
@@ -1029,7 +1030,7 @@ static void stmmac_display_tx_rings(struct stmmac_priv *priv)
                else
                        head_tx = (void *)tx_q->dma_tx;
 
-               priv->hw->desc->display_ring(head_tx, DMA_TX_SIZE, false);
+               stmmac_display_ring(priv, head_tx, DMA_TX_SIZE, false);
        }
 }
 
@@ -1073,13 +1074,13 @@ static void stmmac_clear_rx_descriptors(struct stmmac_priv *priv, u32 queue)
        /* Clear the RX descriptors */
        for (i = 0; i < DMA_RX_SIZE; i++)
                if (priv->extend_desc)
-                       priv->hw->desc->init_rx_desc(&rx_q->dma_erx[i].basic,
-                                                    priv->use_riwt, priv->mode,
-                                                    (i == DMA_RX_SIZE - 1));
+                       stmmac_init_rx_desc(priv, &rx_q->dma_erx[i].basic,
+                                       priv->use_riwt, priv->mode,
+                                       (i == DMA_RX_SIZE - 1));
                else
-                       priv->hw->desc->init_rx_desc(&rx_q->dma_rx[i],
-                                                    priv->use_riwt, priv->mode,
-                                                    (i == DMA_RX_SIZE - 1));
+                       stmmac_init_rx_desc(priv, &rx_q->dma_rx[i],
+                                       priv->use_riwt, priv->mode,
+                                       (i == DMA_RX_SIZE - 1));
 }
 
 /**
@@ -1097,13 +1098,11 @@ static void stmmac_clear_tx_descriptors(struct stmmac_priv *priv, u32 queue)
        /* Clear the TX descriptors */
        for (i = 0; i < DMA_TX_SIZE; i++)
                if (priv->extend_desc)
-                       priv->hw->desc->init_tx_desc(&tx_q->dma_etx[i].basic,
-                                                    priv->mode,
-                                                    (i == DMA_TX_SIZE - 1));
+                       stmmac_init_tx_desc(priv, &tx_q->dma_etx[i].basic,
+                                       priv->mode, (i == DMA_TX_SIZE - 1));
                else
-                       priv->hw->desc->init_tx_desc(&tx_q->dma_tx[i],
-                                                    priv->mode,
-                                                    (i == DMA_TX_SIZE - 1));
+                       stmmac_init_tx_desc(priv, &tx_q->dma_tx[i],
+                                       priv->mode, (i == DMA_TX_SIZE - 1));
 }
 
 /**
@@ -1851,9 +1850,8 @@ static void stmmac_tx_clean(struct stmmac_priv *priv, u32 queue)
                else
                        p = tx_q->dma_tx + entry;
 
-               status = priv->hw->desc->tx_status(&priv->dev->stats,
-                                                     &priv->xstats, p,
-                                                     priv->ioaddr);
+               status = stmmac_tx_status(priv, &priv->dev->stats,
+                               &priv->xstats, p, priv->ioaddr);
                /* Check if the descriptor is owned by the DMA */
                if (unlikely(status & tx_dma_own))
                        break;
@@ -1904,7 +1902,7 @@ static void stmmac_tx_clean(struct stmmac_priv *priv, u32 queue)
                        tx_q->tx_skbuff[entry] = NULL;
                }
 
-               priv->hw->desc->release_tx_desc(p, priv->mode);
+               stmmac_release_tx_desc(priv, p, priv->mode);
 
                entry = STMMAC_GET_ENTRY(entry, DMA_TX_SIZE);
        }
@@ -1957,13 +1955,11 @@ static void stmmac_tx_err(struct stmmac_priv *priv, u32 chan)
        dma_free_tx_skbufs(priv, chan);
        for (i = 0; i < DMA_TX_SIZE; i++)
                if (priv->extend_desc)
-                       priv->hw->desc->init_tx_desc(&tx_q->dma_etx[i].basic,
-                                                    priv->mode,
-                                                    (i == DMA_TX_SIZE - 1));
+                       stmmac_init_tx_desc(priv, &tx_q->dma_etx[i].basic,
+                                       priv->mode, (i == DMA_TX_SIZE - 1));
                else
-                       priv->hw->desc->init_tx_desc(&tx_q->dma_tx[i],
-                                                    priv->mode,
-                                                    (i == DMA_TX_SIZE - 1));
+                       stmmac_init_tx_desc(priv, &tx_q->dma_tx[i],
+                                       priv->mode, (i == DMA_TX_SIZE - 1));
        tx_q->dirty_tx = 0;
        tx_q->cur_tx = 0;
        tx_q->mss = 0;
@@ -2851,10 +2847,10 @@ static void stmmac_tso_allocator(struct stmmac_priv *priv, unsigned int des,
                buff_size = tmp_len >= TSO_MAX_BUFF_SIZE ?
                            TSO_MAX_BUFF_SIZE : tmp_len;
 
-               priv->hw->desc->prepare_tso_tx_desc(desc, 0, buff_size,
-                       0, 1,
-                       (last_segment) && (tmp_len <= TSO_MAX_BUFF_SIZE),
-                       0, 0);
+               stmmac_prepare_tso_tx_desc(priv, desc, 0, buff_size,
+                               0, 1,
+                               (last_segment) && (tmp_len <= TSO_MAX_BUFF_SIZE),
+                               0, 0);
 
                tmp_len -= TSO_MAX_BUFF_SIZE;
        }
@@ -2926,7 +2922,7 @@ static netdev_tx_t stmmac_tso_xmit(struct sk_buff *skb, struct net_device *dev)
        /* set new MSS value if needed */
        if (mss != tx_q->mss) {
                mss_desc = tx_q->dma_tx + tx_q->cur_tx;
-               priv->hw->desc->set_mss(mss_desc, mss);
+               stmmac_set_mss(priv, mss_desc, mss);
                tx_q->mss = mss;
                tx_q->cur_tx = STMMAC_GET_ENTRY(tx_q->cur_tx, DMA_TX_SIZE);
                WARN_ON(tx_q->tx_skbuff[tx_q->cur_tx]);
@@ -3012,7 +3008,7 @@ static netdev_tx_t stmmac_tso_xmit(struct sk_buff *skb, struct net_device *dev)
                          STMMAC_COAL_TIMER(priv->tx_coal_timer));
        } else {
                priv->tx_count_frames = 0;
-               priv->hw->desc->set_tx_ic(desc);
+               stmmac_set_tx_ic(priv, desc);
                priv->xstats.tx_set_ic_bit++;
        }
 
@@ -3022,11 +3018,11 @@ static netdev_tx_t stmmac_tso_xmit(struct sk_buff *skb, struct net_device *dev)
                     priv->hwts_tx_en)) {
                /* declare that device is doing timestamping */
                skb_shinfo(skb)->tx_flags |= SKBTX_IN_PROGRESS;
-               priv->hw->desc->enable_tx_timestamp(first);
+               stmmac_enable_tx_timestamp(priv, first);
        }
 
        /* Complete the first descriptor before granting the DMA */
-       priv->hw->desc->prepare_tso_tx_desc(first, 1,
+       stmmac_prepare_tso_tx_desc(priv, first, 1,
                        proto_hdr_len,
                        pay_len,
                        1, tx_q->tx_skbuff_dma[first_entry].last_segment,
@@ -3040,7 +3036,7 @@ static netdev_tx_t stmmac_tso_xmit(struct sk_buff *skb, struct net_device *dev)
                 * sure that MSS's own bit is the last thing written.
                 */
                dma_wmb();
-               priv->hw->desc->set_tx_owner(mss_desc);
+               stmmac_set_tx_owner(priv, mss_desc);
        }
 
        /* The own bit must be the latest setting done when prepare the
@@ -3054,8 +3050,7 @@ static netdev_tx_t stmmac_tso_xmit(struct sk_buff *skb, struct net_device *dev)
                        __func__, tx_q->cur_tx, tx_q->dirty_tx, first_entry,
                        tx_q->cur_tx, first, nfrags);
 
-               priv->hw->desc->display_ring((void *)tx_q->dma_tx, DMA_TX_SIZE,
-                                            0);
+               stmmac_display_ring(priv, (void *)tx_q->dma_tx, DMA_TX_SIZE, 0);
 
                pr_info(">>> frame to be transmitted: ");
                print_pkt(skb->data, skb_headlen(skb));
@@ -3174,9 +3169,8 @@ static netdev_tx_t stmmac_xmit(struct sk_buff *skb, struct net_device *dev)
                tx_q->tx_skbuff_dma[entry].last_segment = last_segment;
 
                /* Prepare the descriptor and set the own bit too */
-               priv->hw->desc->prepare_tx_desc(desc, 0, len, csum_insertion,
-                                               priv->mode, 1, last_segment,
-                                               skb->len);
+               stmmac_prepare_tx_desc(priv, desc, 0, len, csum_insertion,
+                               priv->mode, 1, last_segment, skb->len);
        }
 
        /* Only the last descriptor gets to point to the skb. */
@@ -3203,7 +3197,7 @@ static netdev_tx_t stmmac_xmit(struct sk_buff *skb, struct net_device *dev)
                else
                        tx_head = (void *)tx_q->dma_tx;
 
-               priv->hw->desc->display_ring(tx_head, DMA_TX_SIZE, false);
+               stmmac_display_ring(priv, tx_head, DMA_TX_SIZE, false);
 
                netdev_dbg(priv->dev, ">>> frame to be transmitted: ");
                print_pkt(skb->data, skb->len);
@@ -3228,7 +3222,7 @@ static netdev_tx_t stmmac_xmit(struct sk_buff *skb, struct net_device *dev)
                          STMMAC_COAL_TIMER(priv->tx_coal_timer));
        } else {
                priv->tx_count_frames = 0;
-               priv->hw->desc->set_tx_ic(desc);
+               stmmac_set_tx_ic(priv, desc);
                priv->xstats.tx_set_ic_bit++;
        }
 
@@ -3259,13 +3253,13 @@ static netdev_tx_t stmmac_xmit(struct sk_buff *skb, struct net_device *dev)
                             priv->hwts_tx_en)) {
                        /* declare that device is doing timestamping */
                        skb_shinfo(skb)->tx_flags |= SKBTX_IN_PROGRESS;
-                       priv->hw->desc->enable_tx_timestamp(first);
+                       stmmac_enable_tx_timestamp(priv, first);
                }
 
                /* Prepare the first descriptor setting the OWN bit too */
-               priv->hw->desc->prepare_tx_desc(first, 1, nopaged_len,
-                                               csum_insertion, priv->mode, 1,
-                                               last_segment, skb->len);
+               stmmac_prepare_tx_desc(priv, first, 1, nopaged_len,
+                               csum_insertion, priv->mode, 1, last_segment,
+                               skb->len);
 
                /* The own bit must be the latest setting done when prepare the
                 * descriptor and then barrier is needed to make sure that
@@ -3382,9 +3376,9 @@ static inline void stmmac_rx_refill(struct stmmac_priv *priv, u32 queue)
                dma_wmb();
 
                if (unlikely(priv->synopsys_id >= DWMAC_CORE_4_00))
-                       priv->hw->desc->init_rx_desc(p, priv->use_riwt, 0, 0);
+                       stmmac_init_rx_desc(priv, p, priv->use_riwt, 0, 0);
                else
-                       priv->hw->desc->set_rx_owner(p);
+                       stmmac_set_rx_owner(priv, p);
 
                dma_wmb();
 
@@ -3418,7 +3412,7 @@ static int stmmac_rx(struct stmmac_priv *priv, int limit, u32 queue)
                else
                        rx_head = (void *)rx_q->dma_rx;
 
-               priv->hw->desc->display_ring(rx_head, DMA_RX_SIZE, true);
+               stmmac_display_ring(priv, rx_head, DMA_RX_SIZE, true);
        }
        while (count < limit) {
                int status;
@@ -3431,8 +3425,8 @@ static int stmmac_rx(struct stmmac_priv *priv, int limit, u32 queue)
                        p = rx_q->dma_rx + entry;
 
                /* read the status of the incoming frame */
-               status = priv->hw->desc->rx_status(&priv->dev->stats,
-                                                  &priv->xstats, p);
+               status = stmmac_rx_status(priv, &priv->dev->stats,
+                               &priv->xstats, p);
                /* check if managed by the DMA otherwise go ahead */
                if (unlikely(status & dma_own))
                        break;
@@ -3449,11 +3443,9 @@ static int stmmac_rx(struct stmmac_priv *priv, int limit, u32 queue)
 
                prefetch(np);
 
-               if ((priv->extend_desc) && (priv->hw->desc->rx_extended_status))
-                       priv->hw->desc->rx_extended_status(&priv->dev->stats,
-                                                          &priv->xstats,
-                                                          rx_q->dma_erx +
-                                                          entry);
+               if (priv->extend_desc)
+                       stmmac_rx_extended_status(priv, &priv->dev->stats,
+                                       &priv->xstats, rx_q->dma_erx + entry);
                if (unlikely(status == discard_frame)) {
                        priv->dev->stats.rx_errors++;
                        if (priv->hwts_rx_en && !priv->extend_desc) {
@@ -3479,7 +3471,7 @@ static int stmmac_rx(struct stmmac_priv *priv, int limit, u32 queue)
                        else
                                des = le32_to_cpu(p->des2);
 
-                       frame_len = priv->hw->desc->get_rx_frame_len(p, coe);
+                       frame_len = stmmac_get_rx_frame_len(priv, p, coe);
 
                        /*  If frame length is greater than skb buffer size
                         *  (preallocated during init) then the packet is