Skip to content

Commit 2eecd3a

Browse files
kuba-mooPaolo Abeni
authored andcommitted
eth: fbnic: fix reporting of alloc_failed qstats
Rx processing under normal circumstances has 3 rings - 2 buffer rings (heads, payloads) and a completion ring. All the rings have a struct fbnic_ring. Make sure we expose alloc_failed counter from the buffer rings, previously only the alloc_failed from the completion ring was reported, even tho all ring types may increment this counter (buffer rings in __fbnic_fill_bdq()). This makes the pp_alloc_fail.py test pass, it expects the qstat to be incrementing as page pool injections happen. Reviewed-by: Simon Horman <horms@kernel.org> Fixes: 67dc4eb ("eth: fbnic: report software Rx queue stats") Signed-off-by: Jakub Kicinski <kuba@kernel.org> Reviewed-by: Jacob Keller <jacob.e.keller@intel.com> Link: https://patch.msgid.link/20251007232653.2099376-7-kuba@kernel.org Signed-off-by: Paolo Abeni <pabeni@redhat.com>
1 parent 27ba925 commit 2eecd3a

5 files changed

Lines changed: 58 additions & 11 deletions

File tree

drivers/net/ethernet/meta/fbnic/fbnic_ethtool.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,8 @@ static void fbnic_aggregate_vector_counters(struct fbnic_net *fbn,
190190
}
191191

192192
for (j = 0; j < nv->rxt_count; j++, i++) {
193-
fbnic_aggregate_ring_rx_counters(fbn, &nv->qt[i].sub0);
194-
fbnic_aggregate_ring_rx_counters(fbn, &nv->qt[i].sub1);
193+
fbnic_aggregate_ring_bdq_counters(fbn, &nv->qt[i].sub0);
194+
fbnic_aggregate_ring_bdq_counters(fbn, &nv->qt[i].sub1);
195195
fbnic_aggregate_ring_rx_counters(fbn, &nv->qt[i].cmpl);
196196
}
197197
}

drivers/net/ethernet/meta/fbnic/fbnic_netdev.c

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -543,17 +543,21 @@ static const struct net_device_ops fbnic_netdev_ops = {
543543
static void fbnic_get_queue_stats_rx(struct net_device *dev, int idx,
544544
struct netdev_queue_stats_rx *rx)
545545
{
546+
u64 bytes, packets, alloc_fail, alloc_fail_bdq;
546547
struct fbnic_net *fbn = netdev_priv(dev);
547548
struct fbnic_ring *rxr = fbn->rx[idx];
548549
struct fbnic_dev *fbd = fbn->fbd;
549550
struct fbnic_queue_stats *stats;
550-
u64 bytes, packets, alloc_fail;
551551
u64 csum_complete, csum_none;
552+
struct fbnic_q_triad *qt;
552553
unsigned int start;
553554

554555
if (!rxr)
555556
return;
556557

558+
/* fbn->rx points to completion queues */
559+
qt = container_of(rxr, struct fbnic_q_triad, cmpl);
560+
557561
stats = &rxr->stats;
558562
do {
559563
start = u64_stats_fetch_begin(&stats->syncp);
@@ -564,6 +568,20 @@ static void fbnic_get_queue_stats_rx(struct net_device *dev, int idx,
564568
csum_none = stats->rx.csum_none;
565569
} while (u64_stats_fetch_retry(&stats->syncp, start));
566570

571+
stats = &qt->sub0.stats;
572+
do {
573+
start = u64_stats_fetch_begin(&stats->syncp);
574+
alloc_fail_bdq = stats->bdq.alloc_failed;
575+
} while (u64_stats_fetch_retry(&stats->syncp, start));
576+
alloc_fail += alloc_fail_bdq;
577+
578+
stats = &qt->sub1.stats;
579+
do {
580+
start = u64_stats_fetch_begin(&stats->syncp);
581+
alloc_fail_bdq = stats->bdq.alloc_failed;
582+
} while (u64_stats_fetch_retry(&stats->syncp, start));
583+
alloc_fail += alloc_fail_bdq;
584+
567585
rx->bytes = bytes;
568586
rx->packets = packets;
569587
rx->alloc_fail = alloc_fail;
@@ -641,7 +659,8 @@ static void fbnic_get_base_stats(struct net_device *dev,
641659

642660
rx->bytes = fbn->rx_stats.bytes;
643661
rx->packets = fbn->rx_stats.packets;
644-
rx->alloc_fail = fbn->rx_stats.rx.alloc_failed;
662+
rx->alloc_fail = fbn->rx_stats.rx.alloc_failed +
663+
fbn->bdq_stats.bdq.alloc_failed;
645664
rx->csum_complete = fbn->rx_stats.rx.csum_complete;
646665
rx->csum_none = fbn->rx_stats.rx.csum_none;
647666
}

drivers/net/ethernet/meta/fbnic/fbnic_netdev.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ struct fbnic_net {
6868
/* Storage for stats after ring destruction */
6969
struct fbnic_queue_stats tx_stats;
7070
struct fbnic_queue_stats rx_stats;
71+
struct fbnic_queue_stats bdq_stats;
7172
u64 link_down_events;
7273

7374
/* Time stamping filter config */

drivers/net/ethernet/meta/fbnic/fbnic_txrx.c

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -904,7 +904,7 @@ static void fbnic_fill_bdq(struct fbnic_ring *bdq)
904904
netmem = page_pool_dev_alloc_netmems(bdq->page_pool);
905905
if (!netmem) {
906906
u64_stats_update_begin(&bdq->stats.syncp);
907-
bdq->stats.rx.alloc_failed++;
907+
bdq->stats.bdq.alloc_failed++;
908908
u64_stats_update_end(&bdq->stats.syncp);
909909

910910
break;
@@ -1414,6 +1414,17 @@ void fbnic_aggregate_ring_rx_counters(struct fbnic_net *fbn,
14141414
BUILD_BUG_ON(sizeof(fbn->rx_stats.rx) / 8 != 4);
14151415
}
14161416

1417+
void fbnic_aggregate_ring_bdq_counters(struct fbnic_net *fbn,
1418+
struct fbnic_ring *bdq)
1419+
{
1420+
struct fbnic_queue_stats *stats = &bdq->stats;
1421+
1422+
/* Capture stats from queues before dissasociating them */
1423+
fbn->bdq_stats.bdq.alloc_failed += stats->bdq.alloc_failed;
1424+
/* Remember to add new stats here */
1425+
BUILD_BUG_ON(sizeof(fbn->rx_stats.bdq) / 8 != 1);
1426+
}
1427+
14171428
void fbnic_aggregate_ring_tx_counters(struct fbnic_net *fbn,
14181429
struct fbnic_ring *txr)
14191430
{
@@ -1486,6 +1497,15 @@ static void fbnic_remove_rx_ring(struct fbnic_net *fbn,
14861497
fbn->rx[rxr->q_idx] = NULL;
14871498
}
14881499

1500+
static void fbnic_remove_bdq_ring(struct fbnic_net *fbn,
1501+
struct fbnic_ring *bdq)
1502+
{
1503+
if (!(bdq->flags & FBNIC_RING_F_STATS))
1504+
return;
1505+
1506+
fbnic_aggregate_ring_bdq_counters(fbn, bdq);
1507+
}
1508+
14891509
static void fbnic_free_qt_page_pools(struct fbnic_q_triad *qt)
14901510
{
14911511
page_pool_destroy(qt->sub0.page_pool);
@@ -1505,8 +1525,8 @@ static void fbnic_free_napi_vector(struct fbnic_net *fbn,
15051525
}
15061526

15071527
for (j = 0; j < nv->rxt_count; j++, i++) {
1508-
fbnic_remove_rx_ring(fbn, &nv->qt[i].sub0);
1509-
fbnic_remove_rx_ring(fbn, &nv->qt[i].sub1);
1528+
fbnic_remove_bdq_ring(fbn, &nv->qt[i].sub0);
1529+
fbnic_remove_bdq_ring(fbn, &nv->qt[i].sub1);
15101530
fbnic_remove_rx_ring(fbn, &nv->qt[i].cmpl);
15111531
}
15121532

@@ -1705,11 +1725,13 @@ static int fbnic_alloc_napi_vector(struct fbnic_dev *fbd, struct fbnic_net *fbn,
17051725
while (rxt_count) {
17061726
/* Configure header queue */
17071727
db = &uc_addr[FBNIC_QUEUE(rxq_idx) + FBNIC_QUEUE_BDQ_HPQ_TAIL];
1708-
fbnic_ring_init(&qt->sub0, db, 0, FBNIC_RING_F_CTX);
1728+
fbnic_ring_init(&qt->sub0, db, 0,
1729+
FBNIC_RING_F_CTX | FBNIC_RING_F_STATS);
17091730

17101731
/* Configure payload queue */
17111732
db = &uc_addr[FBNIC_QUEUE(rxq_idx) + FBNIC_QUEUE_BDQ_PPQ_TAIL];
1712-
fbnic_ring_init(&qt->sub1, db, 0, FBNIC_RING_F_CTX);
1733+
fbnic_ring_init(&qt->sub1, db, 0,
1734+
FBNIC_RING_F_CTX | FBNIC_RING_F_STATS);
17131735

17141736
/* Configure Rx completion queue */
17151737
db = &uc_addr[FBNIC_QUEUE(rxq_idx) + FBNIC_QUEUE_RCQ_HEAD];
@@ -2828,8 +2850,8 @@ static int fbnic_queue_start(struct net_device *dev, void *qmem, int idx)
28282850
real = container_of(fbn->rx[idx], struct fbnic_q_triad, cmpl);
28292851
nv = fbn->napi[idx % fbn->num_napi];
28302852

2831-
fbnic_aggregate_ring_rx_counters(fbn, &real->sub0);
2832-
fbnic_aggregate_ring_rx_counters(fbn, &real->sub1);
2853+
fbnic_aggregate_ring_bdq_counters(fbn, &real->sub0);
2854+
fbnic_aggregate_ring_bdq_counters(fbn, &real->sub1);
28332855
fbnic_aggregate_ring_rx_counters(fbn, &real->cmpl);
28342856

28352857
memcpy(real, qmem, sizeof(*real));

drivers/net/ethernet/meta/fbnic/fbnic_txrx.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,9 @@ struct fbnic_queue_stats {
9292
u64 csum_none;
9393
u64 length_errors;
9494
} rx;
95+
struct {
96+
u64 alloc_failed;
97+
} bdq;
9598
};
9699
u64 dropped;
97100
struct u64_stats_sync syncp;
@@ -165,6 +168,8 @@ fbnic_features_check(struct sk_buff *skb, struct net_device *dev,
165168

166169
void fbnic_aggregate_ring_rx_counters(struct fbnic_net *fbn,
167170
struct fbnic_ring *rxr);
171+
void fbnic_aggregate_ring_bdq_counters(struct fbnic_net *fbn,
172+
struct fbnic_ring *rxr);
168173
void fbnic_aggregate_ring_tx_counters(struct fbnic_net *fbn,
169174
struct fbnic_ring *txr);
170175
void fbnic_aggregate_ring_xdp_counters(struct fbnic_net *fbn,

0 commit comments

Comments
 (0)