stmmac: add last_segment field to dma data

last_segment field is read twice from dma descriptors in stmmac_clean().
Add last_segment to dma data so that this flag is from priv
structure in cache instead of memory.
It avoids reading twice from memory for each loop in stmmac_clean().

Signed-off-by: Fabrice Gasnier <fabrice.gasnier@st.com>
Signed-off-by: Giuseppe Cavallaro <peppe.cavallaro@st.com>
Signed-off-by: Alexandre TORGUE <alexandre.torgue@st.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Giuseppe Cavallaro 2016-02-29 14:27:32 +01:00 committed by David S. Miller
parent 553e2ab313
commit 2a6d8e1726
3 changed files with 7 additions and 2 deletions

View File

@ -150,8 +150,9 @@ static void stmmac_refill_desc3(void *priv_ptr, struct dma_desc *p)
static void stmmac_clean_desc3(void *priv_ptr, struct dma_desc *p) static void stmmac_clean_desc3(void *priv_ptr, struct dma_desc *p)
{ {
struct stmmac_priv *priv = (struct stmmac_priv *)priv_ptr; struct stmmac_priv *priv = (struct stmmac_priv *)priv_ptr;
unsigned int entry = priv->dirty_tx;
if (priv->hw->desc->get_tx_ls(p) && !priv->extend_desc) if (priv->tx_skbuff_dma[entry].last_segment && !priv->extend_desc)
/* NOTE: Device will overwrite des3 with timestamp value if /* NOTE: Device will overwrite des3 with timestamp value if
* 1588-2002 time stamping is enabled, hence reinitialize it * 1588-2002 time stamping is enabled, hence reinitialize it
* to keep explicit chaining in the descriptor. * to keep explicit chaining in the descriptor.

View File

@ -46,6 +46,7 @@ struct stmmac_tx_info {
dma_addr_t buf; dma_addr_t buf;
bool map_as_page; bool map_as_page;
unsigned len; unsigned len;
bool last_segment;
}; };
struct stmmac_priv { struct stmmac_priv {

View File

@ -1094,6 +1094,7 @@ static int init_dma_desc_rings(struct net_device *dev, gfp_t flags)
priv->tx_skbuff_dma[i].buf = 0; priv->tx_skbuff_dma[i].buf = 0;
priv->tx_skbuff_dma[i].map_as_page = false; priv->tx_skbuff_dma[i].map_as_page = false;
priv->tx_skbuff_dma[i].len = 0; priv->tx_skbuff_dma[i].len = 0;
priv->tx_skbuff_dma[i].last_segment = false;
priv->tx_skbuff[i] = NULL; priv->tx_skbuff[i] = NULL;
} }
@ -1326,7 +1327,7 @@ static void stmmac_tx_clean(struct stmmac_priv *priv)
break; break;
/* Verify tx error by looking at the last segment. */ /* Verify tx error by looking at the last segment. */
last = priv->hw->desc->get_tx_ls(p); last = priv->tx_skbuff_dma[entry].last_segment;
if (likely(last)) { if (likely(last)) {
int tx_error = int tx_error =
priv->hw->desc->tx_status(&priv->dev->stats, priv->hw->desc->tx_status(&priv->dev->stats,
@ -1359,6 +1360,7 @@ static void stmmac_tx_clean(struct stmmac_priv *priv)
priv->tx_skbuff_dma[entry].map_as_page = false; priv->tx_skbuff_dma[entry].map_as_page = false;
} }
priv->hw->mode->clean_desc3(priv, p); priv->hw->mode->clean_desc3(priv, p);
priv->tx_skbuff_dma[entry].last_segment = false;
if (likely(skb != NULL)) { if (likely(skb != NULL)) {
pkts_compl++; pkts_compl++;
@ -2028,6 +2030,7 @@ static netdev_tx_t stmmac_xmit(struct sk_buff *skb, struct net_device *dev)
/* Finalize the latest segment. */ /* Finalize the latest segment. */
priv->hw->desc->close_tx_desc(desc); priv->hw->desc->close_tx_desc(desc);
priv->tx_skbuff_dma[entry].last_segment = true;
wmb(); wmb();
/* According to the coalesce parameter the IC bit for the latest /* According to the coalesce parameter the IC bit for the latest