Skip to content

Commit 17a96da

Browse files
gclementdavem330
authored andcommitted
net: mvneta: discriminate error cause for missed packet
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 <[email protected]> Signed-off-by: Gregory CLEMENT <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent c307e2a commit 17a96da

File tree

1 file changed

+22
-6
lines changed

1 file changed

+22
-6
lines changed

drivers/net/ethernet/marvell/mvneta.c

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,8 @@
328328

329329
enum {
330330
ETHTOOL_STAT_EEE_WAKEUP,
331+
ETHTOOL_STAT_SKB_ALLOC_ERR,
332+
ETHTOOL_STAT_REFILL_ERR,
331333
ETHTOOL_MAX_STATS,
332334
};
333335

@@ -375,6 +377,8 @@ static const struct mvneta_statistic mvneta_statistics[] = {
375377
{ 0x3054, T_REG_32, "fc_sent", },
376378
{ 0x300c, T_REG_32, "internal_mac_transmit_err", },
377379
{ ETHTOOL_STAT_EEE_WAKEUP, T_SW, "eee_wakeup_errors", },
380+
{ ETHTOOL_STAT_SKB_ALLOC_ERR, T_SW, "skb_alloc_errors", },
381+
{ ETHTOOL_STAT_REFILL_ERR, T_SW, "refill_errors", },
378382
};
379383

380384
struct mvneta_pcpu_stats {
@@ -589,9 +593,6 @@ struct mvneta_rx_queue {
589593
/* num of rx descriptors in the rx descriptor ring */
590594
int size;
591595

592-
/* counter of times when mvneta_refill() failed */
593-
int missed;
594-
595596
u32 pkts_coal;
596597
u32 time_coal;
597598

@@ -609,6 +610,10 @@ struct mvneta_rx_queue {
609610

610611
/* Index of the next RX DMA descriptor to process */
611612
int next_desc_to_proc;
613+
614+
/* error counters */
615+
u32 skb_alloc_err;
616+
u32 refill_err;
612617
};
613618

614619
static enum cpuhp_state online_hpstate;
@@ -1946,8 +1951,13 @@ static int mvneta_rx_swbm(struct napi_struct *napi,
19461951
if (rx_bytes <= rx_copybreak) {
19471952
/* better copy a small frame and not unmap the DMA region */
19481953
skb = netdev_alloc_skb_ip_align(dev, rx_bytes);
1949-
if (unlikely(!skb))
1954+
if (unlikely(!skb)) {
1955+
netdev_err(dev,
1956+
"Can't allocate skb on queue %d\n",
1957+
rxq->id);
1958+
rxq->skb_alloc_err++;
19501959
goto err_drop_frame;
1960+
}
19511961

19521962
dma_sync_single_range_for_cpu(dev->dev.parent,
19531963
phys_addr,
@@ -1972,7 +1982,7 @@ static int mvneta_rx_swbm(struct napi_struct *napi,
19721982
err = mvneta_rx_refill(pp, rx_desc, rxq);
19731983
if (err) {
19741984
netdev_err(dev, "Linux processing - Can't refill\n");
1975-
rxq->missed++;
1985+
rxq->refill_err++;
19761986
goto err_drop_frame;
19771987
}
19781988

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

@@ -3963,6 +3973,12 @@ static void mvneta_ethtool_update_stats(struct mvneta_port *pp)
39633973
case ETHTOOL_STAT_EEE_WAKEUP:
39643974
val = phylink_get_eee_err(pp->phylink);
39653975
break;
3976+
case ETHTOOL_STAT_SKB_ALLOC_ERR:
3977+
val = pp->rxqs[0].skb_alloc_err;
3978+
break;
3979+
case ETHTOOL_STAT_REFILL_ERR:
3980+
val = pp->rxqs[0].refill_err;
3981+
break;
39663982
}
39673983
break;
39683984
}

0 commit comments

Comments
 (0)