Commit d2df9ea0 authored by Jose Abreu's avatar Jose Abreu Committed by David S. Miller

net: stmmac: Let descriptor code get skbuff address

Stop using if conditions depending on the GMAC version for getting the
descriptor skbuff address and use instead a helper implemented in the
descriptor files.
Signed-off-by: default avatarJose Abreu <joabreu@synopsys.com>
Cc: David S. Miller <davem@davemloft.net>
Cc: Joao Pinto <jpinto@synopsys.com>
Cc: Vitor Soares <soares@synopsys.com>
Cc: Giuseppe Cavallaro <peppe.cavallaro@st.com>
Cc: Alexandre Torgue <alexandre.torgue@st.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 357951cd
...@@ -424,6 +424,11 @@ static void dwmac4_set_mss_ctxt(struct dma_desc *p, unsigned int mss) ...@@ -424,6 +424,11 @@ static void dwmac4_set_mss_ctxt(struct dma_desc *p, unsigned int mss)
p->des3 = cpu_to_le32(TDES3_CONTEXT_TYPE | TDES3_CTXT_TCMSSV); p->des3 = cpu_to_le32(TDES3_CONTEXT_TYPE | TDES3_CTXT_TCMSSV);
} }
static void dwmac4_get_addr(struct dma_desc *p, unsigned int *addr)
{
*addr = le32_to_cpu(p->des0);
}
static void dwmac4_set_addr(struct dma_desc *p, dma_addr_t addr) static void dwmac4_set_addr(struct dma_desc *p, dma_addr_t addr)
{ {
p->des0 = cpu_to_le32(addr); p->des0 = cpu_to_le32(addr);
...@@ -459,6 +464,7 @@ const struct stmmac_desc_ops dwmac4_desc_ops = { ...@@ -459,6 +464,7 @@ const struct stmmac_desc_ops dwmac4_desc_ops = {
.init_tx_desc = dwmac4_rd_init_tx_desc, .init_tx_desc = dwmac4_rd_init_tx_desc,
.display_ring = dwmac4_display_ring, .display_ring = dwmac4_display_ring,
.set_mss = dwmac4_set_mss_ctxt, .set_mss = dwmac4_set_mss_ctxt,
.get_addr = dwmac4_get_addr,
.set_addr = dwmac4_set_addr, .set_addr = dwmac4_set_addr,
.clear = dwmac4_clear, .clear = dwmac4_clear,
}; };
......
...@@ -437,6 +437,11 @@ static void enh_desc_display_ring(void *head, unsigned int size, bool rx) ...@@ -437,6 +437,11 @@ static void enh_desc_display_ring(void *head, unsigned int size, bool rx)
pr_info("\n"); pr_info("\n");
} }
static void enh_desc_get_addr(struct dma_desc *p, unsigned int *addr)
{
*addr = le32_to_cpu(p->des2);
}
static void enh_desc_set_addr(struct dma_desc *p, dma_addr_t addr) static void enh_desc_set_addr(struct dma_desc *p, dma_addr_t addr)
{ {
p->des2 = cpu_to_le32(addr); p->des2 = cpu_to_le32(addr);
...@@ -467,6 +472,7 @@ const struct stmmac_desc_ops enh_desc_ops = { ...@@ -467,6 +472,7 @@ const struct stmmac_desc_ops enh_desc_ops = {
.get_timestamp = enh_desc_get_timestamp, .get_timestamp = enh_desc_get_timestamp,
.get_rx_timestamp_status = enh_desc_get_rx_timestamp_status, .get_rx_timestamp_status = enh_desc_get_rx_timestamp_status,
.display_ring = enh_desc_display_ring, .display_ring = enh_desc_display_ring,
.get_addr = enh_desc_get_addr,
.set_addr = enh_desc_set_addr, .set_addr = enh_desc_set_addr,
.clear = enh_desc_clear, .clear = enh_desc_clear,
}; };
...@@ -79,6 +79,8 @@ struct stmmac_desc_ops { ...@@ -79,6 +79,8 @@ struct stmmac_desc_ops {
void (*display_ring)(void *head, unsigned int size, bool rx); void (*display_ring)(void *head, unsigned int size, bool rx);
/* set MSS via context descriptor */ /* set MSS via context descriptor */
void (*set_mss)(struct dma_desc *p, unsigned int mss); void (*set_mss)(struct dma_desc *p, unsigned int mss);
/* get descriptor skbuff address */
void (*get_addr)(struct dma_desc *p, unsigned int *addr);
/* set descriptor skbuff address */ /* set descriptor skbuff address */
void (*set_addr)(struct dma_desc *p, dma_addr_t addr); void (*set_addr)(struct dma_desc *p, dma_addr_t addr);
/* clear descriptor */ /* clear descriptor */
...@@ -127,6 +129,8 @@ struct stmmac_desc_ops { ...@@ -127,6 +129,8 @@ struct stmmac_desc_ops {
stmmac_do_void_callback(__priv, desc, display_ring, __args) stmmac_do_void_callback(__priv, desc, display_ring, __args)
#define stmmac_set_mss(__priv, __args...) \ #define stmmac_set_mss(__priv, __args...) \
stmmac_do_void_callback(__priv, desc, set_mss, __args) stmmac_do_void_callback(__priv, desc, set_mss, __args)
#define stmmac_get_desc_addr(__priv, __args...) \
stmmac_do_void_callback(__priv, desc, get_addr, __args)
#define stmmac_set_desc_addr(__priv, __args...) \ #define stmmac_set_desc_addr(__priv, __args...) \
stmmac_do_void_callback(__priv, desc, set_addr, __args) stmmac_do_void_callback(__priv, desc, set_addr, __args)
#define stmmac_clear_desc(__priv, __args...) \ #define stmmac_clear_desc(__priv, __args...) \
......
...@@ -297,6 +297,11 @@ static void ndesc_display_ring(void *head, unsigned int size, bool rx) ...@@ -297,6 +297,11 @@ static void ndesc_display_ring(void *head, unsigned int size, bool rx)
pr_info("\n"); pr_info("\n");
} }
static void ndesc_get_addr(struct dma_desc *p, unsigned int *addr)
{
*addr = le32_to_cpu(p->des2);
}
static void ndesc_set_addr(struct dma_desc *p, dma_addr_t addr) static void ndesc_set_addr(struct dma_desc *p, dma_addr_t addr)
{ {
p->des2 = cpu_to_le32(addr); p->des2 = cpu_to_le32(addr);
...@@ -326,6 +331,7 @@ const struct stmmac_desc_ops ndesc_ops = { ...@@ -326,6 +331,7 @@ const struct stmmac_desc_ops ndesc_ops = {
.get_timestamp = ndesc_get_timestamp, .get_timestamp = ndesc_get_timestamp,
.get_rx_timestamp_status = ndesc_get_rx_timestamp_status, .get_rx_timestamp_status = ndesc_get_rx_timestamp_status,
.display_ring = ndesc_display_ring, .display_ring = ndesc_display_ring,
.get_addr = ndesc_get_addr,
.set_addr = ndesc_set_addr, .set_addr = ndesc_set_addr,
.clear = ndesc_clear, .clear = ndesc_clear,
}; };
...@@ -3350,11 +3350,7 @@ static int stmmac_rx(struct stmmac_priv *priv, int limit, u32 queue) ...@@ -3350,11 +3350,7 @@ static int stmmac_rx(struct stmmac_priv *priv, int limit, u32 queue)
int frame_len; int frame_len;
unsigned int des; unsigned int des;
if (unlikely(priv->synopsys_id >= DWMAC_CORE_4_00)) stmmac_get_desc_addr(priv, p, &des);
des = le32_to_cpu(p->des0);
else
des = le32_to_cpu(p->des2);
frame_len = stmmac_get_rx_frame_len(priv, p, coe); frame_len = stmmac_get_rx_frame_len(priv, p, coe);
/* If frame length is greater than skb buffer size /* If frame length is greater than skb buffer size
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment