Commit c1fa3212 authored by Fabrice Gasnier's avatar Fabrice Gasnier Committed by David S. Miller

stmmac: merge get_rx_owner into rx_status routine.

The RDES0 register can be read several times while doing RX of a
packet.
This patch slightly improves RX path performance by reading rdes0
once for two operation: check rx owner, get rx status bits.
Signed-off-by: default avatarFabrice Gasnier <fabrice.gasnier@st.com>
Acked-by: default avatarGiuseppe Cavallaro <peppe.cavallaro@st.com>
Signed-off-by: default avatarAlexandre TORGUE <alexandre.torgue@st.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 96951366
...@@ -238,10 +238,11 @@ struct stmmac_extra_stats { ...@@ -238,10 +238,11 @@ struct stmmac_extra_stats {
/* Rx IPC status */ /* Rx IPC status */
enum rx_frame_status { enum rx_frame_status {
good_frame = 0, good_frame = 0x0,
discard_frame = 1, discard_frame = 0x1,
csum_none = 2, csum_none = 0x2,
llc_snap = 4, llc_snap = 0x4,
dma_own = 0x8,
}; };
enum dma_irq_status { enum dma_irq_status {
...@@ -356,7 +357,6 @@ struct stmmac_desc_ops { ...@@ -356,7 +357,6 @@ struct stmmac_desc_ops {
/* Get the buffer size from the descriptor */ /* Get the buffer size from the descriptor */
int (*get_tx_len) (struct dma_desc *p); int (*get_tx_len) (struct dma_desc *p);
/* Handle extra events on specific interrupts hw dependent */ /* Handle extra events on specific interrupts hw dependent */
int (*get_rx_owner) (struct dma_desc *p);
void (*set_rx_owner) (struct dma_desc *p); void (*set_rx_owner) (struct dma_desc *p);
/* Get the receive frame size */ /* Get the receive frame size */
int (*get_rx_frame_len) (struct dma_desc *p, int rx_coe_type); int (*get_rx_frame_len) (struct dma_desc *p, int rx_coe_type);
......
...@@ -186,6 +186,9 @@ static int enh_desc_get_rx_status(void *data, struct stmmac_extra_stats *x, ...@@ -186,6 +186,9 @@ static int enh_desc_get_rx_status(void *data, struct stmmac_extra_stats *x,
unsigned int rdes0 = p->des0; unsigned int rdes0 = p->des0;
int ret = good_frame; int ret = good_frame;
if (unlikely(rdes0 & RDES0_OWN))
return dma_own;
if (unlikely(rdes0 & RDES0_ERROR_SUMMARY)) { if (unlikely(rdes0 & RDES0_ERROR_SUMMARY)) {
if (unlikely(rdes0 & RDES0_DESCRIPTOR_ERROR)) { if (unlikely(rdes0 & RDES0_DESCRIPTOR_ERROR)) {
x->rx_desc++; x->rx_desc++;
...@@ -272,11 +275,6 @@ static int enh_desc_get_tx_owner(struct dma_desc *p) ...@@ -272,11 +275,6 @@ static int enh_desc_get_tx_owner(struct dma_desc *p)
return (p->des0 & ETDES0_OWN) >> 31; return (p->des0 & ETDES0_OWN) >> 31;
} }
static int enh_desc_get_rx_owner(struct dma_desc *p)
{
return (p->des0 & RDES0_OWN) >> 31;
}
static void enh_desc_set_tx_owner(struct dma_desc *p) static void enh_desc_set_tx_owner(struct dma_desc *p)
{ {
p->des0 |= ETDES0_OWN; p->des0 |= ETDES0_OWN;
...@@ -402,7 +400,6 @@ const struct stmmac_desc_ops enh_desc_ops = { ...@@ -402,7 +400,6 @@ const struct stmmac_desc_ops enh_desc_ops = {
.init_rx_desc = enh_desc_init_rx_desc, .init_rx_desc = enh_desc_init_rx_desc,
.init_tx_desc = enh_desc_init_tx_desc, .init_tx_desc = enh_desc_init_tx_desc,
.get_tx_owner = enh_desc_get_tx_owner, .get_tx_owner = enh_desc_get_tx_owner,
.get_rx_owner = enh_desc_get_rx_owner,
.release_tx_desc = enh_desc_release_tx_desc, .release_tx_desc = enh_desc_release_tx_desc,
.prepare_tx_desc = enh_desc_prepare_tx_desc, .prepare_tx_desc = enh_desc_prepare_tx_desc,
.clear_tx_ic = enh_desc_clear_tx_ic, .clear_tx_ic = enh_desc_clear_tx_ic,
......
...@@ -82,6 +82,9 @@ static int ndesc_get_rx_status(void *data, struct stmmac_extra_stats *x, ...@@ -82,6 +82,9 @@ static int ndesc_get_rx_status(void *data, struct stmmac_extra_stats *x,
unsigned int rdes0 = p->des0; unsigned int rdes0 = p->des0;
struct net_device_stats *stats = (struct net_device_stats *)data; struct net_device_stats *stats = (struct net_device_stats *)data;
if (unlikely(rdes0 & RDES0_OWN))
return dma_own;
if (unlikely(!(rdes0 & RDES0_LAST_DESCRIPTOR))) { if (unlikely(!(rdes0 & RDES0_LAST_DESCRIPTOR))) {
pr_warn("%s: Oversized frame spanned multiple buffers\n", pr_warn("%s: Oversized frame spanned multiple buffers\n",
__func__); __func__);
...@@ -155,11 +158,6 @@ static int ndesc_get_tx_owner(struct dma_desc *p) ...@@ -155,11 +158,6 @@ static int ndesc_get_tx_owner(struct dma_desc *p)
return (p->des0 & TDES0_OWN) >> 31; return (p->des0 & TDES0_OWN) >> 31;
} }
static int ndesc_get_rx_owner(struct dma_desc *p)
{
return (p->des0 & RDES0_OWN) >> 31;
}
static void ndesc_set_tx_owner(struct dma_desc *p) static void ndesc_set_tx_owner(struct dma_desc *p)
{ {
p->des0 |= TDES0_OWN; p->des0 |= TDES0_OWN;
...@@ -277,7 +275,6 @@ const struct stmmac_desc_ops ndesc_ops = { ...@@ -277,7 +275,6 @@ const struct stmmac_desc_ops ndesc_ops = {
.init_rx_desc = ndesc_init_rx_desc, .init_rx_desc = ndesc_init_rx_desc,
.init_tx_desc = ndesc_init_tx_desc, .init_tx_desc = ndesc_init_tx_desc,
.get_tx_owner = ndesc_get_tx_owner, .get_tx_owner = ndesc_get_tx_owner,
.get_rx_owner = ndesc_get_rx_owner,
.release_tx_desc = ndesc_release_tx_desc, .release_tx_desc = ndesc_release_tx_desc,
.prepare_tx_desc = ndesc_prepare_tx_desc, .prepare_tx_desc = ndesc_prepare_tx_desc,
.clear_tx_ic = ndesc_clear_tx_ic, .clear_tx_ic = ndesc_clear_tx_ic,
......
...@@ -2205,7 +2205,11 @@ static int stmmac_rx(struct stmmac_priv *priv, int limit) ...@@ -2205,7 +2205,11 @@ static int stmmac_rx(struct stmmac_priv *priv, int limit)
else else
p = priv->dma_rx + entry; p = priv->dma_rx + entry;
if (priv->hw->desc->get_rx_owner(p)) /* read the status of the incoming frame */
status = priv->hw->desc->rx_status(&priv->dev->stats,
&priv->xstats, p);
/* check if managed by the DMA otherwise go ahead */
if (unlikely(status & dma_own))
break; break;
count++; count++;
...@@ -2218,9 +2222,6 @@ static int stmmac_rx(struct stmmac_priv *priv, int limit) ...@@ -2218,9 +2222,6 @@ static int stmmac_rx(struct stmmac_priv *priv, int limit)
else else
prefetch(priv->dma_rx + next_entry); prefetch(priv->dma_rx + next_entry);
/* read the status of the incoming frame */
status = priv->hw->desc->rx_status(&priv->dev->stats,
&priv->xstats, p);
if ((priv->extend_desc) && (priv->hw->desc->rx_extended_status)) if ((priv->extend_desc) && (priv->hw->desc->rx_extended_status))
priv->hw->desc->rx_extended_status(&priv->dev->stats, priv->hw->desc->rx_extended_status(&priv->dev->stats,
&priv->xstats, &priv->xstats,
......
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