Skip to content

Commit 16f50cd

Browse files
Jakub Kicinskidavem330
authored andcommitted
nfp: use a counter instead of log message for allocation failures
Add a counter incremented when allocation of replacement RX page fails. Signed-off-by: Jakub Kicinski <[email protected]> Reviewed-by: Simon Horman <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 790a399 commit 16f50cd

File tree

3 files changed

+20
-10
lines changed

3 files changed

+20
-10
lines changed

drivers/net/ethernet/netronome/nfp/nfp_net.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,7 @@ struct nfp_net_rx_ring {
394394
* @tx_lso: Counter of LSO packets sent
395395
* @tx_errors: How many TX errors were encountered
396396
* @tx_busy: How often was TX busy (no space)?
397+
* @rx_replace_buf_alloc_fail: Counter of RX buffer allocation failures
397398
* @irq_vector: Interrupt vector number (use for talking to the OS)
398399
* @handler: Interrupt handler for this ring vector
399400
* @name: Name of the interrupt vector
@@ -437,6 +438,8 @@ struct nfp_net_r_vector {
437438
u64 hw_csum_tx_inner;
438439
u64 tx_gather;
439440
u64 tx_lso;
441+
442+
u64 rx_replace_buf_alloc_fail;
440443
u64 tx_errors;
441444
u64 tx_busy;
442445

drivers/net/ethernet/netronome/nfp/nfp_net_common.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1209,15 +1209,15 @@ static void *nfp_net_napi_alloc_one(struct nfp_net_dp *dp, dma_addr_t *dma_addr)
12091209

12101210
if (!dp->xdp_prog) {
12111211
frag = napi_alloc_frag(dp->fl_bufsz);
1212+
if (unlikely(!frag))
1213+
return NULL;
12121214
} else {
12131215
struct page *page;
12141216

12151217
page = dev_alloc_page();
1216-
frag = page ? page_address(page) : NULL;
1217-
}
1218-
if (!frag) {
1219-
nn_dp_warn(dp, "Failed to alloc receive page frag\n");
1220-
return NULL;
1218+
if (unlikely(!page))
1219+
return NULL;
1220+
frag = page_address(page);
12211221
}
12221222

12231223
*dma_addr = nfp_net_dma_map_rx(dp, frag);
@@ -1514,6 +1514,11 @@ nfp_net_rx_drop(const struct nfp_net_dp *dp, struct nfp_net_r_vector *r_vec,
15141514
{
15151515
u64_stats_update_begin(&r_vec->rx_sync);
15161516
r_vec->rx_drops++;
1517+
/* If we have both skb and rxbuf the replacement buffer allocation
1518+
* must have failed, count this as an alloc failure.
1519+
*/
1520+
if (skb && rxbuf)
1521+
r_vec->rx_replace_buf_alloc_fail++;
15171522
u64_stats_update_end(&r_vec->rx_sync);
15181523

15191524
/* skb is build based on the frag, free_skb() would free the frag

drivers/net/ethernet/netronome/nfp/nfp_net_ethtool.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ static const struct nfp_et_stat nfp_mac_et_stats[] = {
181181

182182
#define NN_ET_GLOBAL_STATS_LEN ARRAY_SIZE(nfp_net_et_stats)
183183
#define NN_ET_SWITCH_STATS_LEN 9
184-
#define NN_ET_RVEC_GATHER_STATS 7
184+
#define NN_ET_RVEC_GATHER_STATS 8
185185

186186
static void nfp_net_get_nspinfo(struct nfp_app *app, char *version)
187187
{
@@ -444,6 +444,7 @@ static u8 *nfp_vnic_get_sw_stats_strings(struct net_device *netdev, u8 *data)
444444
data = nfp_pr_et(data, "hw_rx_csum_ok");
445445
data = nfp_pr_et(data, "hw_rx_csum_inner_ok");
446446
data = nfp_pr_et(data, "hw_rx_csum_err");
447+
data = nfp_pr_et(data, "rx_replace_buf_alloc_fail");
447448
data = nfp_pr_et(data, "hw_tx_csum");
448449
data = nfp_pr_et(data, "hw_tx_inner_csum");
449450
data = nfp_pr_et(data, "tx_gather");
@@ -468,16 +469,17 @@ static u64 *nfp_vnic_get_sw_stats(struct net_device *netdev, u64 *data)
468469
tmp[0] = nn->r_vecs[i].hw_csum_rx_ok;
469470
tmp[1] = nn->r_vecs[i].hw_csum_rx_inner_ok;
470471
tmp[2] = nn->r_vecs[i].hw_csum_rx_error;
472+
tmp[3] = nn->r_vecs[i].rx_replace_buf_alloc_fail;
471473
} while (u64_stats_fetch_retry(&nn->r_vecs[i].rx_sync, start));
472474

473475
do {
474476
start = u64_stats_fetch_begin(&nn->r_vecs[i].tx_sync);
475477
data[1] = nn->r_vecs[i].tx_pkts;
476478
data[2] = nn->r_vecs[i].tx_busy;
477-
tmp[3] = nn->r_vecs[i].hw_csum_tx;
478-
tmp[4] = nn->r_vecs[i].hw_csum_tx_inner;
479-
tmp[5] = nn->r_vecs[i].tx_gather;
480-
tmp[6] = nn->r_vecs[i].tx_lso;
479+
tmp[4] = nn->r_vecs[i].hw_csum_tx;
480+
tmp[5] = nn->r_vecs[i].hw_csum_tx_inner;
481+
tmp[6] = nn->r_vecs[i].tx_gather;
482+
tmp[7] = nn->r_vecs[i].tx_lso;
481483
} while (u64_stats_fetch_retry(&nn->r_vecs[i].tx_sync, start));
482484

483485
data += 3;

0 commit comments

Comments
 (0)