Skip to content

Commit 986c63a

Browse files
Mohsin BashirPaolo Abeni
authored andcommitted
eth: fbnic: add coverage for RXB stats
This patch provides coverage to the RXB (RX Buffer) stats. RXB stats are divided into 3 sections: RXB enqueue, RXB FIFO, and RXB dequeue stats. The RXB enqueue/dequeue stats are indexed from 0-3 and cater for the input/output counters whereas, the RXB fifo stats are indexed from 0-7. The RXB also supports pause frame stats counters which we are leaving for a later patch. ethtool -S eth0 | grep rxb rxb_integrity_err0: 0 rxb_mac_err0: 0 rxb_parser_err0: 0 rxb_frm_err0: 0 rxb_drbo0_frames: 1433543 rxb_drbo0_bytes: 775949081 --- --- rxb_intf3_frames: 1195711 rxb_intf3_bytes: 739650210 rxb_pbuf3_frames: 1195711 rxb_pbuf3_bytes: 765948092 Signed-off-by: Jakub Kicinski <[email protected]> Signed-off-by: Mohsin Bashir <[email protected]> Reviewed-by: Simon Horman <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Paolo Abeni <[email protected]>
1 parent 8f20a2b commit 986c63a

File tree

6 files changed

+356
-1
lines changed

6 files changed

+356
-1
lines changed

Documentation/networking/device_drivers/ethernet/meta/fbnic.rst

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,32 @@ separate entry.
3131
Statistics
3232
----------
3333

34+
RXB (RX Buffer) Enqueue
35+
~~~~~~~~~~~~~~~~~~~~~~~
36+
37+
- ``rxb_integrity_err[i]``: frames enqueued with integrity errors (e.g., multi-bit ECC errors) on RXB input i
38+
- ``rxb_mac_err[i]``: frames enqueued with MAC end-of-frame errors (e.g., bad FCS) on RXB input i
39+
- ``rxb_parser_err[i]``: frames experienced RPC parser errors
40+
- ``rxb_frm_err[i]``: frames experienced signaling errors (e.g., missing end-of-packet/start-of-packet) on RXB input i
41+
- ``rxb_drbo[i]_frames``: frames received at RXB input i
42+
- ``rxb_drbo[i]_bytes``: bytes received at RXB input i
43+
44+
RXB (RX Buffer) FIFO
45+
~~~~~~~~~~~~~~~~~~~~
46+
47+
- ``rxb_fifo[i]_drop``: transitions into the drop state on RXB pool i
48+
- ``rxb_fifo[i]_dropped_frames``: frames dropped on RXB pool i
49+
- ``rxb_fifo[i]_ecn``: transitions into the ECN mark state on RXB pool i
50+
- ``rxb_fifo[i]_level``: current occupancy of RXB pool i
51+
52+
RXB (RX Buffer) Dequeue
53+
~~~~~~~~~~~~~~~~~~~~~~~
54+
55+
- ``rxb_intf[i]_frames``: frames sent to the output i
56+
- ``rxb_intf[i]_bytes``: bytes sent to the output i
57+
- ``rxb_pbuf[i]_frames``: frames sent to output i from the perspective of internal packet buffer
58+
- ``rxb_pbuf[i]_bytes``: bytes sent to output i from the perspective of internal packet buffer
59+
3460
RPC (Rx parser)
3561
~~~~~~~~~~~~~~~
3662

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -485,6 +485,14 @@ enum {
485485
FBNIC_RXB_FIFO_INDICES = 8
486486
};
487487

488+
enum {
489+
FBNIC_RXB_INTF_NET = 0,
490+
FBNIC_RXB_INTF_RBT = 1,
491+
/* Unused */
492+
/* Unused */
493+
FBNIC_RXB_INTF_INDICES = 4
494+
};
495+
488496
#define FBNIC_RXB_CT_SIZE(n) (0x08000 + (n)) /* 0x20000 + 4*n */
489497
#define FBNIC_RXB_CT_SIZE_CNT 8
490498
#define FBNIC_RXB_CT_SIZE_HEADER CSR_GENMASK(5, 0)

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

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,47 @@ static const struct fbnic_stat fbnic_gstrings_hw_stats[] = {
4040

4141
#define FBNIC_HW_FIXED_STATS_LEN ARRAY_SIZE(fbnic_gstrings_hw_stats)
4242

43+
#define FBNIC_RXB_ENQUEUE_STAT(name, stat) \
44+
FBNIC_STAT_FIELDS(fbnic_rxb_enqueue_stats, name, stat)
45+
46+
static const struct fbnic_stat fbnic_gstrings_rxb_enqueue_stats[] = {
47+
FBNIC_RXB_ENQUEUE_STAT("rxb_integrity_err%u", integrity_err),
48+
FBNIC_RXB_ENQUEUE_STAT("rxb_mac_err%u", mac_err),
49+
FBNIC_RXB_ENQUEUE_STAT("rxb_parser_err%u", parser_err),
50+
FBNIC_RXB_ENQUEUE_STAT("rxb_frm_err%u", frm_err),
51+
52+
FBNIC_RXB_ENQUEUE_STAT("rxb_drbo%u_frames", drbo.frames),
53+
FBNIC_RXB_ENQUEUE_STAT("rxb_drbo%u_bytes", drbo.bytes),
54+
};
55+
56+
#define FBNIC_HW_RXB_ENQUEUE_STATS_LEN \
57+
ARRAY_SIZE(fbnic_gstrings_rxb_enqueue_stats)
58+
59+
#define FBNIC_RXB_FIFO_STAT(name, stat) \
60+
FBNIC_STAT_FIELDS(fbnic_rxb_fifo_stats, name, stat)
61+
62+
static const struct fbnic_stat fbnic_gstrings_rxb_fifo_stats[] = {
63+
FBNIC_RXB_FIFO_STAT("rxb_fifo%u_drop", trans_drop),
64+
FBNIC_RXB_FIFO_STAT("rxb_fifo%u_dropped_frames", drop.frames),
65+
FBNIC_RXB_FIFO_STAT("rxb_fifo%u_ecn", trans_ecn),
66+
FBNIC_RXB_FIFO_STAT("rxb_fifo%u_level", level),
67+
};
68+
69+
#define FBNIC_HW_RXB_FIFO_STATS_LEN ARRAY_SIZE(fbnic_gstrings_rxb_fifo_stats)
70+
71+
#define FBNIC_RXB_DEQUEUE_STAT(name, stat) \
72+
FBNIC_STAT_FIELDS(fbnic_rxb_dequeue_stats, name, stat)
73+
74+
static const struct fbnic_stat fbnic_gstrings_rxb_dequeue_stats[] = {
75+
FBNIC_RXB_DEQUEUE_STAT("rxb_intf%u_frames", intf.frames),
76+
FBNIC_RXB_DEQUEUE_STAT("rxb_intf%u_bytes", intf.bytes),
77+
FBNIC_RXB_DEQUEUE_STAT("rxb_pbuf%u_frames", pbuf.frames),
78+
FBNIC_RXB_DEQUEUE_STAT("rxb_pbuf%u_bytes", pbuf.bytes),
79+
};
80+
81+
#define FBNIC_HW_RXB_DEQUEUE_STATS_LEN \
82+
ARRAY_SIZE(fbnic_gstrings_rxb_dequeue_stats)
83+
4384
#define FBNIC_HW_Q_STAT(name, stat) \
4485
FBNIC_STAT_FIELDS(fbnic_hw_q_stats, name, stat.value)
4586

@@ -52,6 +93,9 @@ static const struct fbnic_stat fbnic_gstrings_hw_q_stats[] = {
5293
#define FBNIC_HW_Q_STATS_LEN ARRAY_SIZE(fbnic_gstrings_hw_q_stats)
5394
#define FBNIC_HW_STATS_LEN \
5495
(FBNIC_HW_FIXED_STATS_LEN + \
96+
FBNIC_HW_RXB_ENQUEUE_STATS_LEN * FBNIC_RXB_ENQUEUE_INDICES + \
97+
FBNIC_HW_RXB_FIFO_STATS_LEN * FBNIC_RXB_FIFO_INDICES + \
98+
FBNIC_HW_RXB_DEQUEUE_STATS_LEN * FBNIC_RXB_DEQUEUE_INDICES + \
5599
FBNIC_HW_Q_STATS_LEN * FBNIC_MAX_QUEUES)
56100

57101
static void
@@ -311,6 +355,36 @@ fbnic_set_ringparam(struct net_device *netdev, struct ethtool_ringparam *ring,
311355
return err;
312356
}
313357

358+
static void fbnic_get_rxb_enqueue_strings(u8 **data, unsigned int idx)
359+
{
360+
const struct fbnic_stat *stat;
361+
int i;
362+
363+
stat = fbnic_gstrings_rxb_enqueue_stats;
364+
for (i = 0; i < FBNIC_HW_RXB_ENQUEUE_STATS_LEN; i++, stat++)
365+
ethtool_sprintf(data, stat->string, idx);
366+
}
367+
368+
static void fbnic_get_rxb_fifo_strings(u8 **data, unsigned int idx)
369+
{
370+
const struct fbnic_stat *stat;
371+
int i;
372+
373+
stat = fbnic_gstrings_rxb_fifo_stats;
374+
for (i = 0; i < FBNIC_HW_RXB_FIFO_STATS_LEN; i++, stat++)
375+
ethtool_sprintf(data, stat->string, idx);
376+
}
377+
378+
static void fbnic_get_rxb_dequeue_strings(u8 **data, unsigned int idx)
379+
{
380+
const struct fbnic_stat *stat;
381+
int i;
382+
383+
stat = fbnic_gstrings_rxb_dequeue_stats;
384+
for (i = 0; i < FBNIC_HW_RXB_DEQUEUE_STATS_LEN; i++, stat++)
385+
ethtool_sprintf(data, stat->string, idx);
386+
}
387+
314388
static void fbnic_get_strings(struct net_device *dev, u32 sset, u8 *data)
315389
{
316390
const struct fbnic_stat *stat;
@@ -321,6 +395,15 @@ static void fbnic_get_strings(struct net_device *dev, u32 sset, u8 *data)
321395
for (i = 0; i < FBNIC_HW_FIXED_STATS_LEN; i++)
322396
ethtool_puts(&data, fbnic_gstrings_hw_stats[i].string);
323397

398+
for (i = 0; i < FBNIC_RXB_ENQUEUE_INDICES; i++)
399+
fbnic_get_rxb_enqueue_strings(&data, i);
400+
401+
for (i = 0; i < FBNIC_RXB_FIFO_INDICES; i++)
402+
fbnic_get_rxb_fifo_strings(&data, i);
403+
404+
for (i = 0; i < FBNIC_RXB_DEQUEUE_INDICES; i++)
405+
fbnic_get_rxb_dequeue_strings(&data, i);
406+
324407
for (idx = 0; idx < FBNIC_MAX_QUEUES; idx++) {
325408
stat = fbnic_gstrings_hw_q_stats;
326409

@@ -357,6 +440,33 @@ static void fbnic_get_ethtool_stats(struct net_device *dev,
357440
fbnic_report_hw_stats(fbnic_gstrings_hw_stats, &fbd->hw_stats,
358441
FBNIC_HW_FIXED_STATS_LEN, &data);
359442

443+
for (i = 0; i < FBNIC_RXB_ENQUEUE_INDICES; i++) {
444+
const struct fbnic_rxb_enqueue_stats *enq;
445+
446+
enq = &fbd->hw_stats.rxb.enq[i];
447+
fbnic_report_hw_stats(fbnic_gstrings_rxb_enqueue_stats,
448+
enq, FBNIC_HW_RXB_ENQUEUE_STATS_LEN,
449+
&data);
450+
}
451+
452+
for (i = 0; i < FBNIC_RXB_FIFO_INDICES; i++) {
453+
const struct fbnic_rxb_fifo_stats *fifo;
454+
455+
fifo = &fbd->hw_stats.rxb.fifo[i];
456+
fbnic_report_hw_stats(fbnic_gstrings_rxb_fifo_stats,
457+
fifo, FBNIC_HW_RXB_FIFO_STATS_LEN,
458+
&data);
459+
}
460+
461+
for (i = 0; i < FBNIC_RXB_DEQUEUE_INDICES; i++) {
462+
const struct fbnic_rxb_dequeue_stats *deq;
463+
464+
deq = &fbd->hw_stats.rxb.deq[i];
465+
fbnic_report_hw_stats(fbnic_gstrings_rxb_dequeue_stats,
466+
deq, FBNIC_HW_RXB_DEQUEUE_STATS_LEN,
467+
&data);
468+
}
469+
360470
for (i = 0; i < FBNIC_MAX_QUEUES; i++) {
361471
const struct fbnic_hw_q_stats *hw_q = &fbd->hw_stats.hw_q[i];
362472

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

Lines changed: 171 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,173 @@ static void fbnic_get_rpc_stats32(struct fbnic_dev *fbd,
117117
&rpc->ovr_size_err);
118118
}
119119

120+
static void fbnic_reset_rxb_fifo_stats(struct fbnic_dev *fbd, int i,
121+
struct fbnic_rxb_fifo_stats *fifo)
122+
{
123+
fbnic_hw_stat_rst32(fbd, FBNIC_RXB_DROP_FRMS_STS(i),
124+
&fifo->drop.frames);
125+
fbnic_hw_stat_rst64(fbd, FBNIC_RXB_DROP_BYTES_STS_L(i), 1,
126+
&fifo->drop.bytes);
127+
128+
fbnic_hw_stat_rst32(fbd, FBNIC_RXB_TRUN_FRMS_STS(i),
129+
&fifo->trunc.frames);
130+
fbnic_hw_stat_rst64(fbd, FBNIC_RXB_TRUN_BYTES_STS_L(i), 1,
131+
&fifo->trunc.bytes);
132+
133+
fbnic_hw_stat_rst32(fbd, FBNIC_RXB_TRANS_DROP_STS(i),
134+
&fifo->trans_drop);
135+
fbnic_hw_stat_rst32(fbd, FBNIC_RXB_TRANS_ECN_STS(i),
136+
&fifo->trans_ecn);
137+
138+
fifo->level.u.old_reg_value_32 = 0;
139+
}
140+
141+
static void fbnic_reset_rxb_enq_stats(struct fbnic_dev *fbd, int i,
142+
struct fbnic_rxb_enqueue_stats *enq)
143+
{
144+
fbnic_hw_stat_rst32(fbd, FBNIC_RXB_DRBO_FRM_CNT_SRC(i),
145+
&enq->drbo.frames);
146+
fbnic_hw_stat_rst64(fbd, FBNIC_RXB_DRBO_BYTE_CNT_SRC_L(i), 4,
147+
&enq->drbo.bytes);
148+
149+
fbnic_hw_stat_rst32(fbd, FBNIC_RXB_INTEGRITY_ERR(i),
150+
&enq->integrity_err);
151+
fbnic_hw_stat_rst32(fbd, FBNIC_RXB_MAC_ERR(i),
152+
&enq->mac_err);
153+
fbnic_hw_stat_rst32(fbd, FBNIC_RXB_PARSER_ERR(i),
154+
&enq->parser_err);
155+
fbnic_hw_stat_rst32(fbd, FBNIC_RXB_FRM_ERR(i),
156+
&enq->frm_err);
157+
}
158+
159+
static void fbnic_reset_rxb_deq_stats(struct fbnic_dev *fbd, int i,
160+
struct fbnic_rxb_dequeue_stats *deq)
161+
{
162+
fbnic_hw_stat_rst32(fbd, FBNIC_RXB_INTF_FRM_CNT_DST(i),
163+
&deq->intf.frames);
164+
fbnic_hw_stat_rst64(fbd, FBNIC_RXB_INTF_BYTE_CNT_DST_L(i), 4,
165+
&deq->intf.bytes);
166+
167+
fbnic_hw_stat_rst32(fbd, FBNIC_RXB_PBUF_FRM_CNT_DST(i),
168+
&deq->pbuf.frames);
169+
fbnic_hw_stat_rst64(fbd, FBNIC_RXB_PBUF_BYTE_CNT_DST_L(i), 4,
170+
&deq->pbuf.bytes);
171+
}
172+
173+
static void fbnic_reset_rxb_stats(struct fbnic_dev *fbd,
174+
struct fbnic_rxb_stats *rxb)
175+
{
176+
int i;
177+
178+
for (i = 0; i < FBNIC_RXB_FIFO_INDICES; i++)
179+
fbnic_reset_rxb_fifo_stats(fbd, i, &rxb->fifo[i]);
180+
181+
for (i = 0; i < FBNIC_RXB_INTF_INDICES; i++) {
182+
fbnic_reset_rxb_enq_stats(fbd, i, &rxb->enq[i]);
183+
fbnic_reset_rxb_deq_stats(fbd, i, &rxb->deq[i]);
184+
}
185+
}
186+
187+
static void fbnic_get_rxb_fifo_stats32(struct fbnic_dev *fbd, int i,
188+
struct fbnic_rxb_fifo_stats *fifo)
189+
{
190+
fbnic_hw_stat_rd32(fbd, FBNIC_RXB_DROP_FRMS_STS(i),
191+
&fifo->drop.frames);
192+
fbnic_hw_stat_rd32(fbd, FBNIC_RXB_TRUN_FRMS_STS(i),
193+
&fifo->trunc.frames);
194+
195+
fbnic_hw_stat_rd32(fbd, FBNIC_RXB_TRANS_DROP_STS(i),
196+
&fifo->trans_drop);
197+
fbnic_hw_stat_rd32(fbd, FBNIC_RXB_TRANS_ECN_STS(i),
198+
&fifo->trans_ecn);
199+
200+
fifo->level.value = rd32(fbd, FBNIC_RXB_PBUF_FIFO_LEVEL(i));
201+
}
202+
203+
static void fbnic_get_rxb_fifo_stats(struct fbnic_dev *fbd, int i,
204+
struct fbnic_rxb_fifo_stats *fifo)
205+
{
206+
fbnic_hw_stat_rd64(fbd, FBNIC_RXB_DROP_BYTES_STS_L(i), 1,
207+
&fifo->drop.bytes);
208+
fbnic_hw_stat_rd64(fbd, FBNIC_RXB_TRUN_BYTES_STS_L(i), 1,
209+
&fifo->trunc.bytes);
210+
211+
fbnic_get_rxb_fifo_stats32(fbd, i, fifo);
212+
}
213+
214+
static void fbnic_get_rxb_enq_stats32(struct fbnic_dev *fbd, int i,
215+
struct fbnic_rxb_enqueue_stats *enq)
216+
{
217+
fbnic_hw_stat_rd32(fbd, FBNIC_RXB_DRBO_FRM_CNT_SRC(i),
218+
&enq->drbo.frames);
219+
220+
fbnic_hw_stat_rd32(fbd, FBNIC_RXB_INTEGRITY_ERR(i),
221+
&enq->integrity_err);
222+
fbnic_hw_stat_rd32(fbd, FBNIC_RXB_MAC_ERR(i),
223+
&enq->mac_err);
224+
fbnic_hw_stat_rd32(fbd, FBNIC_RXB_PARSER_ERR(i),
225+
&enq->parser_err);
226+
fbnic_hw_stat_rd32(fbd, FBNIC_RXB_FRM_ERR(i),
227+
&enq->frm_err);
228+
}
229+
230+
static void fbnic_get_rxb_enq_stats(struct fbnic_dev *fbd, int i,
231+
struct fbnic_rxb_enqueue_stats *enq)
232+
{
233+
fbnic_hw_stat_rd64(fbd, FBNIC_RXB_DRBO_BYTE_CNT_SRC_L(i), 4,
234+
&enq->drbo.bytes);
235+
236+
fbnic_get_rxb_enq_stats32(fbd, i, enq);
237+
}
238+
239+
static void fbnic_get_rxb_deq_stats32(struct fbnic_dev *fbd, int i,
240+
struct fbnic_rxb_dequeue_stats *deq)
241+
{
242+
fbnic_hw_stat_rd32(fbd, FBNIC_RXB_INTF_FRM_CNT_DST(i),
243+
&deq->intf.frames);
244+
fbnic_hw_stat_rd32(fbd, FBNIC_RXB_PBUF_FRM_CNT_DST(i),
245+
&deq->pbuf.frames);
246+
}
247+
248+
static void fbnic_get_rxb_deq_stats(struct fbnic_dev *fbd, int i,
249+
struct fbnic_rxb_dequeue_stats *deq)
250+
{
251+
fbnic_hw_stat_rd64(fbd, FBNIC_RXB_INTF_BYTE_CNT_DST_L(i), 4,
252+
&deq->intf.bytes);
253+
fbnic_hw_stat_rd64(fbd, FBNIC_RXB_PBUF_BYTE_CNT_DST_L(i), 4,
254+
&deq->pbuf.bytes);
255+
256+
fbnic_get_rxb_deq_stats32(fbd, i, deq);
257+
}
258+
259+
static void fbnic_get_rxb_stats32(struct fbnic_dev *fbd,
260+
struct fbnic_rxb_stats *rxb)
261+
{
262+
int i;
263+
264+
for (i = 0; i < FBNIC_RXB_FIFO_INDICES; i++)
265+
fbnic_get_rxb_fifo_stats32(fbd, i, &rxb->fifo[i]);
266+
267+
for (i = 0; i < FBNIC_RXB_INTF_INDICES; i++) {
268+
fbnic_get_rxb_enq_stats32(fbd, i, &rxb->enq[i]);
269+
fbnic_get_rxb_deq_stats32(fbd, i, &rxb->deq[i]);
270+
}
271+
}
272+
273+
static void fbnic_get_rxb_stats(struct fbnic_dev *fbd,
274+
struct fbnic_rxb_stats *rxb)
275+
{
276+
int i;
277+
278+
for (i = 0; i < FBNIC_RXB_FIFO_INDICES; i++)
279+
fbnic_get_rxb_fifo_stats(fbd, i, &rxb->fifo[i]);
280+
281+
for (i = 0; i < FBNIC_RXB_INTF_INDICES; i++) {
282+
fbnic_get_rxb_enq_stats(fbd, i, &rxb->enq[i]);
283+
fbnic_get_rxb_deq_stats(fbd, i, &rxb->deq[i]);
284+
}
285+
}
286+
120287
static void fbnic_reset_hw_rxq_stats(struct fbnic_dev *fbd,
121288
struct fbnic_hw_q_stats *hw_q)
122289
{
@@ -253,6 +420,7 @@ void fbnic_reset_hw_stats(struct fbnic_dev *fbd)
253420
{
254421
spin_lock(&fbd->hw_stats_lock);
255422
fbnic_reset_rpc_stats(fbd, &fbd->hw_stats.rpc);
423+
fbnic_reset_rxb_stats(fbd, &fbd->hw_stats.rxb);
256424
fbnic_reset_hw_rxq_stats(fbd, fbd->hw_stats.hw_q);
257425
fbnic_reset_pcie_stats_asic(fbd, &fbd->hw_stats.pcie);
258426
spin_unlock(&fbd->hw_stats_lock);
@@ -261,6 +429,7 @@ void fbnic_reset_hw_stats(struct fbnic_dev *fbd)
261429
static void __fbnic_get_hw_stats32(struct fbnic_dev *fbd)
262430
{
263431
fbnic_get_rpc_stats32(fbd, &fbd->hw_stats.rpc);
432+
fbnic_get_rxb_stats32(fbd, &fbd->hw_stats.rxb);
264433
fbnic_get_hw_rxq_stats32(fbd, fbd->hw_stats.hw_q);
265434
}
266435

@@ -275,6 +444,8 @@ void fbnic_get_hw_stats(struct fbnic_dev *fbd)
275444
{
276445
spin_lock(&fbd->hw_stats_lock);
277446
__fbnic_get_hw_stats32(fbd);
447+
448+
fbnic_get_rxb_stats(fbd, &fbd->hw_stats.rxb);
278449
fbnic_get_pcie_stats_asic64(fbd, &fbd->hw_stats.pcie);
279450
spin_unlock(&fbd->hw_stats_lock);
280451
}

0 commit comments

Comments
 (0)