Skip to content

Commit

Permalink
net: mvneta: discriminate error cause for missed packet
Browse files Browse the repository at this point in the history
In order to improve the diagnostic in case of error, make the distinction
between refill error and skb allocation error. Also make the information
available through the ethtool state.

Based on the work of Yelena Krivosheev <yelena@marvell.com>
Signed-off-by: Gregory CLEMENT <gregory.clement@bootlin.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Gregory CLEMENT authored and David S. Miller committed Jul 29, 2018
1 parent c307e2a commit 17a96da
Showing 1 changed file with 22 additions and 6 deletions.
28 changes: 22 additions & 6 deletions drivers/net/ethernet/marvell/mvneta.c
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,8 @@

enum {
ETHTOOL_STAT_EEE_WAKEUP,
ETHTOOL_STAT_SKB_ALLOC_ERR,
ETHTOOL_STAT_REFILL_ERR,
ETHTOOL_MAX_STATS,
};

Expand Down Expand Up @@ -375,6 +377,8 @@ static const struct mvneta_statistic mvneta_statistics[] = {
{ 0x3054, T_REG_32, "fc_sent", },
{ 0x300c, T_REG_32, "internal_mac_transmit_err", },
{ ETHTOOL_STAT_EEE_WAKEUP, T_SW, "eee_wakeup_errors", },
{ ETHTOOL_STAT_SKB_ALLOC_ERR, T_SW, "skb_alloc_errors", },
{ ETHTOOL_STAT_REFILL_ERR, T_SW, "refill_errors", },
};

struct mvneta_pcpu_stats {
Expand Down Expand Up @@ -589,9 +593,6 @@ struct mvneta_rx_queue {
/* num of rx descriptors in the rx descriptor ring */
int size;

/* counter of times when mvneta_refill() failed */
int missed;

u32 pkts_coal;
u32 time_coal;

Expand All @@ -609,6 +610,10 @@ struct mvneta_rx_queue {

/* Index of the next RX DMA descriptor to process */
int next_desc_to_proc;

/* error counters */
u32 skb_alloc_err;
u32 refill_err;
};

static enum cpuhp_state online_hpstate;
Expand Down Expand Up @@ -1946,8 +1951,13 @@ static int mvneta_rx_swbm(struct napi_struct *napi,
if (rx_bytes <= rx_copybreak) {
/* better copy a small frame and not unmap the DMA region */
skb = netdev_alloc_skb_ip_align(dev, rx_bytes);
if (unlikely(!skb))
if (unlikely(!skb)) {
netdev_err(dev,
"Can't allocate skb on queue %d\n",
rxq->id);
rxq->skb_alloc_err++;
goto err_drop_frame;
}

dma_sync_single_range_for_cpu(dev->dev.parent,
phys_addr,
Expand All @@ -1972,7 +1982,7 @@ static int mvneta_rx_swbm(struct napi_struct *napi,
err = mvneta_rx_refill(pp, rx_desc, rxq);
if (err) {
netdev_err(dev, "Linux processing - Can't refill\n");
rxq->missed++;
rxq->refill_err++;
goto err_drop_frame;
}

Expand Down Expand Up @@ -2102,7 +2112,7 @@ static int mvneta_rx_hwbm(struct napi_struct *napi,
err = hwbm_pool_refill(&bm_pool->hwbm_pool, GFP_ATOMIC);
if (err) {
netdev_err(dev, "Linux processing - Can't refill\n");
rxq->missed++;
rxq->refill_err++;
goto err_drop_frame_ret_pool;
}

Expand Down Expand Up @@ -3963,6 +3973,12 @@ static void mvneta_ethtool_update_stats(struct mvneta_port *pp)
case ETHTOOL_STAT_EEE_WAKEUP:
val = phylink_get_eee_err(pp->phylink);
break;
case ETHTOOL_STAT_SKB_ALLOC_ERR:
val = pp->rxqs[0].skb_alloc_err;
break;
case ETHTOOL_STAT_REFILL_ERR:
val = pp->rxqs[0].refill_err;
break;
}
break;
}
Expand Down

0 comments on commit 17a96da

Please sign in to comment.