Skip to content

Commit 2f47203

Browse files
committed
Merge branch 'eth-fbnic-report-software-queue-stats'
Jakub Kicinski says: ==================== eth: fbnic: report software queue stats Fill in typical software queue stats. # ./pyynl/cli.py --spec netlink/specs/netdev.yaml --dump qstats-get [{'ifindex': 2, 'rx-alloc-fail': 0, 'rx-bytes': 398064076, 'rx-csum-complete': 271, 'rx-csum-none': 0, 'rx-packets': 276044, 'tx-bytes': 7223770, 'tx-needs-csum': 28148, 'tx-packets': 28449, 'tx-stop': 0, 'tx-wake': 0}] Note that we don't collect csum-unnecessary, just the uncommon cases (and unnecessary is all the rest of the packets). There is no programatic use for these stats AFAIK, just manual debug. ==================== Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
2 parents fea5d56 + 0ec0232 commit 2f47203

File tree

7 files changed

+102
-23
lines changed

7 files changed

+102
-23
lines changed

drivers/net/ethernet/meta/fbnic/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ fbnic-y := fbnic_csr.o \
2020
fbnic_pci.o \
2121
fbnic_phylink.o \
2222
fbnic_rpc.o \
23+
fbnic_time.o \
2324
fbnic_tlv.o \
2425
fbnic_txrx.o \
25-
fbnic_time.o
26+
# End of objects

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1224,14 +1224,14 @@ static void fbnic_get_ts_stats(struct net_device *netdev,
12241224
unsigned int start;
12251225
int i;
12261226

1227-
ts_stats->pkts = fbn->tx_stats.ts_packets;
1228-
ts_stats->lost = fbn->tx_stats.ts_lost;
1227+
ts_stats->pkts = fbn->tx_stats.twq.ts_packets;
1228+
ts_stats->lost = fbn->tx_stats.twq.ts_lost;
12291229
for (i = 0; i < fbn->num_tx_queues; i++) {
12301230
ring = fbn->tx[i];
12311231
do {
12321232
start = u64_stats_fetch_begin(&ring->stats.syncp);
1233-
ts_packets = ring->stats.ts_packets;
1234-
ts_lost = ring->stats.ts_lost;
1233+
ts_packets = ring->stats.twq.ts_packets;
1234+
ts_lost = ring->stats.twq.ts_lost;
12351235
} while (u64_stats_fetch_retry(&ring->stats.syncp, start));
12361236
ts_stats->pkts += ts_packets;
12371237
ts_stats->lost += ts_lost;

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

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -487,8 +487,9 @@ static void fbnic_get_queue_stats_rx(struct net_device *dev, int idx,
487487
struct fbnic_net *fbn = netdev_priv(dev);
488488
struct fbnic_ring *rxr = fbn->rx[idx];
489489
struct fbnic_queue_stats *stats;
490+
u64 bytes, packets, alloc_fail;
491+
u64 csum_complete, csum_none;
490492
unsigned int start;
491-
u64 bytes, packets;
492493

493494
if (!rxr)
494495
return;
@@ -498,10 +499,16 @@ static void fbnic_get_queue_stats_rx(struct net_device *dev, int idx,
498499
start = u64_stats_fetch_begin(&stats->syncp);
499500
bytes = stats->bytes;
500501
packets = stats->packets;
502+
alloc_fail = stats->rx.alloc_failed;
503+
csum_complete = stats->rx.csum_complete;
504+
csum_none = stats->rx.csum_none;
501505
} while (u64_stats_fetch_retry(&stats->syncp, start));
502506

503507
rx->bytes = bytes;
504508
rx->packets = packets;
509+
rx->alloc_fail = alloc_fail;
510+
rx->csum_complete = csum_complete;
511+
rx->csum_none = csum_none;
505512
}
506513

507514
static void fbnic_get_queue_stats_tx(struct net_device *dev, int idx,
@@ -510,6 +517,7 @@ static void fbnic_get_queue_stats_tx(struct net_device *dev, int idx,
510517
struct fbnic_net *fbn = netdev_priv(dev);
511518
struct fbnic_ring *txr = fbn->tx[idx];
512519
struct fbnic_queue_stats *stats;
520+
u64 stop, wake, csum;
513521
unsigned int start;
514522
u64 bytes, packets;
515523

@@ -521,10 +529,16 @@ static void fbnic_get_queue_stats_tx(struct net_device *dev, int idx,
521529
start = u64_stats_fetch_begin(&stats->syncp);
522530
bytes = stats->bytes;
523531
packets = stats->packets;
532+
csum = stats->twq.csum_partial;
533+
stop = stats->twq.stop;
534+
wake = stats->twq.wake;
524535
} while (u64_stats_fetch_retry(&stats->syncp, start));
525536

526537
tx->bytes = bytes;
527538
tx->packets = packets;
539+
tx->needs_csum = csum;
540+
tx->stop = stop;
541+
tx->wake = wake;
528542
}
529543

530544
static void fbnic_get_base_stats(struct net_device *dev,
@@ -535,9 +549,15 @@ static void fbnic_get_base_stats(struct net_device *dev,
535549

536550
tx->bytes = fbn->tx_stats.bytes;
537551
tx->packets = fbn->tx_stats.packets;
552+
tx->needs_csum = fbn->tx_stats.twq.csum_partial;
553+
tx->stop = fbn->tx_stats.twq.stop;
554+
tx->wake = fbn->tx_stats.twq.wake;
538555

539556
rx->bytes = fbn->rx_stats.bytes;
540557
rx->packets = fbn->rx_stats.packets;
558+
rx->alloc_fail = fbn->rx_stats.rx.alloc_failed;
559+
rx->csum_complete = fbn->rx_stats.rx.csum_complete;
560+
rx->csum_none = fbn->rx_stats.rx.csum_none;
541561
}
542562

543563
static const struct netdev_stat_ops fbnic_stat_ops = {

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

Lines changed: 59 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,11 @@ static int fbnic_maybe_stop_tx(const struct net_device *dev,
113113

114114
res = netif_txq_maybe_stop(txq, fbnic_desc_unused(ring), size,
115115
FBNIC_TX_DESC_WAKEUP);
116+
if (!res) {
117+
u64_stats_update_begin(&ring->stats.syncp);
118+
ring->stats.twq.stop++;
119+
u64_stats_update_end(&ring->stats.syncp);
120+
}
116121

117122
return !res;
118123
}
@@ -191,19 +196,25 @@ fbnic_tx_offloads(struct fbnic_ring *ring, struct sk_buff *skb, __le64 *meta)
191196
skb->csum_offset / 2));
192197

193198
*meta |= cpu_to_le64(FBNIC_TWD_FLAG_REQ_CSO);
199+
u64_stats_update_begin(&ring->stats.syncp);
200+
ring->stats.twq.csum_partial++;
201+
u64_stats_update_end(&ring->stats.syncp);
194202

195203
*meta |= cpu_to_le64(FIELD_PREP(FBNIC_TWD_L2_HLEN_MASK, l2len / 2) |
196204
FIELD_PREP(FBNIC_TWD_L3_IHLEN_MASK, i3len / 2));
197205
return false;
198206
}
199207

200208
static void
201-
fbnic_rx_csum(u64 rcd, struct sk_buff *skb, struct fbnic_ring *rcq)
209+
fbnic_rx_csum(u64 rcd, struct sk_buff *skb, struct fbnic_ring *rcq,
210+
u64 *csum_cmpl, u64 *csum_none)
202211
{
203212
skb_checksum_none_assert(skb);
204213

205-
if (unlikely(!(skb->dev->features & NETIF_F_RXCSUM)))
214+
if (unlikely(!(skb->dev->features & NETIF_F_RXCSUM))) {
215+
(*csum_none)++;
206216
return;
217+
}
207218

208219
if (FIELD_GET(FBNIC_RCD_META_L4_CSUM_UNNECESSARY, rcd)) {
209220
skb->ip_summed = CHECKSUM_UNNECESSARY;
@@ -212,6 +223,7 @@ fbnic_rx_csum(u64 rcd, struct sk_buff *skb, struct fbnic_ring *rcq)
212223

213224
skb->ip_summed = CHECKSUM_COMPLETE;
214225
skb->csum = (__force __wsum)csum;
226+
(*csum_cmpl)++;
215227
}
216228
}
217229

@@ -444,7 +456,7 @@ static void fbnic_clean_twq0(struct fbnic_napi_vector *nv, int napi_budget,
444456
if (unlikely(discard)) {
445457
u64_stats_update_begin(&ring->stats.syncp);
446458
ring->stats.dropped += total_packets;
447-
ring->stats.ts_lost += ts_lost;
459+
ring->stats.twq.ts_lost += ts_lost;
448460
u64_stats_update_end(&ring->stats.syncp);
449461

450462
netdev_tx_completed_queue(txq, total_packets, total_bytes);
@@ -456,9 +468,13 @@ static void fbnic_clean_twq0(struct fbnic_napi_vector *nv, int napi_budget,
456468
ring->stats.packets += total_packets;
457469
u64_stats_update_end(&ring->stats.syncp);
458470

459-
netif_txq_completed_wake(txq, total_packets, total_bytes,
460-
fbnic_desc_unused(ring),
461-
FBNIC_TX_DESC_WAKEUP);
471+
if (!netif_txq_completed_wake(txq, total_packets, total_bytes,
472+
fbnic_desc_unused(ring),
473+
FBNIC_TX_DESC_WAKEUP)) {
474+
u64_stats_update_begin(&ring->stats.syncp);
475+
ring->stats.twq.wake++;
476+
u64_stats_update_end(&ring->stats.syncp);
477+
}
462478
}
463479

464480
static void fbnic_clean_tsq(struct fbnic_napi_vector *nv,
@@ -507,7 +523,7 @@ static void fbnic_clean_tsq(struct fbnic_napi_vector *nv,
507523

508524
skb_tstamp_tx(skb, &hwtstamp);
509525
u64_stats_update_begin(&ring->stats.syncp);
510-
ring->stats.ts_packets++;
526+
ring->stats.twq.ts_packets++;
511527
u64_stats_update_end(&ring->stats.syncp);
512528
}
513529

@@ -661,8 +677,13 @@ static void fbnic_fill_bdq(struct fbnic_napi_vector *nv, struct fbnic_ring *bdq)
661677
struct page *page;
662678

663679
page = page_pool_dev_alloc_pages(nv->page_pool);
664-
if (!page)
680+
if (!page) {
681+
u64_stats_update_begin(&bdq->stats.syncp);
682+
bdq->stats.rx.alloc_failed++;
683+
u64_stats_update_end(&bdq->stats.syncp);
684+
665685
break;
686+
}
666687

667688
fbnic_page_pool_init(bdq, i, page);
668689
fbnic_bd_prep(bdq, i, page);
@@ -875,12 +896,13 @@ static void fbnic_rx_tstamp(struct fbnic_napi_vector *nv, u64 rcd,
875896

876897
static void fbnic_populate_skb_fields(struct fbnic_napi_vector *nv,
877898
u64 rcd, struct sk_buff *skb,
878-
struct fbnic_q_triad *qt)
899+
struct fbnic_q_triad *qt,
900+
u64 *csum_cmpl, u64 *csum_none)
879901
{
880902
struct net_device *netdev = nv->napi.dev;
881903
struct fbnic_ring *rcq = &qt->cmpl;
882904

883-
fbnic_rx_csum(rcd, skb, rcq);
905+
fbnic_rx_csum(rcd, skb, rcq, csum_cmpl, csum_none);
884906

885907
if (netdev->features & NETIF_F_RXHASH)
886908
skb_set_hash(skb,
@@ -898,7 +920,8 @@ static bool fbnic_rcd_metadata_err(u64 rcd)
898920
static int fbnic_clean_rcq(struct fbnic_napi_vector *nv,
899921
struct fbnic_q_triad *qt, int budget)
900922
{
901-
unsigned int packets = 0, bytes = 0, dropped = 0;
923+
unsigned int packets = 0, bytes = 0, dropped = 0, alloc_failed = 0;
924+
u64 csum_complete = 0, csum_none = 0;
902925
struct fbnic_ring *rcq = &qt->cmpl;
903926
struct fbnic_pkt_buff *pkt;
904927
s32 head0 = -1, head1 = -1;
@@ -947,14 +970,22 @@ static int fbnic_clean_rcq(struct fbnic_napi_vector *nv,
947970

948971
/* Populate skb and invalidate XDP */
949972
if (!IS_ERR_OR_NULL(skb)) {
950-
fbnic_populate_skb_fields(nv, rcd, skb, qt);
973+
fbnic_populate_skb_fields(nv, rcd, skb, qt,
974+
&csum_complete,
975+
&csum_none);
951976

952977
packets++;
953978
bytes += skb->len;
954979

955980
napi_gro_receive(&nv->napi, skb);
956981
} else {
957-
dropped++;
982+
if (!skb) {
983+
alloc_failed++;
984+
dropped++;
985+
} else {
986+
dropped++;
987+
}
988+
958989
fbnic_put_pkt_buff(nv, pkt, 1);
959990
}
960991

@@ -977,6 +1008,9 @@ static int fbnic_clean_rcq(struct fbnic_napi_vector *nv,
9771008
/* Re-add ethernet header length (removed in fbnic_build_skb) */
9781009
rcq->stats.bytes += ETH_HLEN * packets;
9791010
rcq->stats.dropped += dropped;
1011+
rcq->stats.rx.alloc_failed += alloc_failed;
1012+
rcq->stats.rx.csum_complete += csum_complete;
1013+
rcq->stats.rx.csum_none += csum_none;
9801014
u64_stats_update_end(&rcq->stats.syncp);
9811015

9821016
/* Unmap and free processed buffers */
@@ -1054,6 +1088,11 @@ void fbnic_aggregate_ring_rx_counters(struct fbnic_net *fbn,
10541088
fbn->rx_stats.bytes += stats->bytes;
10551089
fbn->rx_stats.packets += stats->packets;
10561090
fbn->rx_stats.dropped += stats->dropped;
1091+
fbn->rx_stats.rx.alloc_failed += stats->rx.alloc_failed;
1092+
fbn->rx_stats.rx.csum_complete += stats->rx.csum_complete;
1093+
fbn->rx_stats.rx.csum_none += stats->rx.csum_none;
1094+
/* Remember to add new stats here */
1095+
BUILD_BUG_ON(sizeof(fbn->tx_stats.rx) / 8 != 3);
10571096
}
10581097

10591098
void fbnic_aggregate_ring_tx_counters(struct fbnic_net *fbn,
@@ -1065,8 +1104,13 @@ void fbnic_aggregate_ring_tx_counters(struct fbnic_net *fbn,
10651104
fbn->tx_stats.bytes += stats->bytes;
10661105
fbn->tx_stats.packets += stats->packets;
10671106
fbn->tx_stats.dropped += stats->dropped;
1068-
fbn->tx_stats.ts_lost += stats->ts_lost;
1069-
fbn->tx_stats.ts_packets += stats->ts_packets;
1107+
fbn->tx_stats.twq.csum_partial += stats->twq.csum_partial;
1108+
fbn->tx_stats.twq.ts_lost += stats->twq.ts_lost;
1109+
fbn->tx_stats.twq.ts_packets += stats->twq.ts_packets;
1110+
fbn->tx_stats.twq.stop += stats->twq.stop;
1111+
fbn->tx_stats.twq.wake += stats->twq.wake;
1112+
/* Remember to add new stats here */
1113+
BUILD_BUG_ON(sizeof(fbn->tx_stats.twq) / 8 != 5);
10701114
}
10711115

10721116
static void fbnic_remove_tx_ring(struct fbnic_net *fbn,

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

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,21 @@ struct fbnic_pkt_buff {
5656
struct fbnic_queue_stats {
5757
u64 packets;
5858
u64 bytes;
59+
union {
60+
struct {
61+
u64 csum_partial;
62+
u64 ts_packets;
63+
u64 ts_lost;
64+
u64 stop;
65+
u64 wake;
66+
} twq;
67+
struct {
68+
u64 alloc_failed;
69+
u64 csum_complete;
70+
u64 csum_none;
71+
} rx;
72+
};
5973
u64 dropped;
60-
u64 ts_packets;
61-
u64 ts_lost;
6274
struct u64_stats_sync syncp;
6375
};
6476

include/net/netdev_queues.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ struct netdev_queue_stats_rx {
2323
u64 hw_drops;
2424
u64 hw_drop_overruns;
2525

26+
u64 csum_complete;
2627
u64 csum_unnecessary;
2728
u64 csum_none;
2829
u64 csum_bad;

net/core/netdev-genl.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -581,6 +581,7 @@ netdev_nl_stats_write_rx(struct sk_buff *rsp, struct netdev_queue_stats_rx *rx)
581581
netdev_stat_put(rsp, NETDEV_A_QSTATS_RX_ALLOC_FAIL, rx->alloc_fail) ||
582582
netdev_stat_put(rsp, NETDEV_A_QSTATS_RX_HW_DROPS, rx->hw_drops) ||
583583
netdev_stat_put(rsp, NETDEV_A_QSTATS_RX_HW_DROP_OVERRUNS, rx->hw_drop_overruns) ||
584+
netdev_stat_put(rsp, NETDEV_A_QSTATS_RX_CSUM_COMPLETE, rx->csum_complete) ||
584585
netdev_stat_put(rsp, NETDEV_A_QSTATS_RX_CSUM_UNNECESSARY, rx->csum_unnecessary) ||
585586
netdev_stat_put(rsp, NETDEV_A_QSTATS_RX_CSUM_NONE, rx->csum_none) ||
586587
netdev_stat_put(rsp, NETDEV_A_QSTATS_RX_CSUM_BAD, rx->csum_bad) ||

0 commit comments

Comments
 (0)