Merge tag 'perf_urgent_for_v5.13_rc1' of git://git.kernel.org/pub/scm/linux/kernel...
[platform/kernel/linux-rpi.git] / drivers / net / ethernet / pensando / ionic / ionic_stats.c
1 // SPDX-License-Identifier: GPL-2.0
2 /* Copyright(c) 2017 - 2019 Pensando Systems, Inc */
3
4 #include <linux/ethtool.h>
5 #include <linux/kernel.h>
6 #include <linux/mutex.h>
7 #include <linux/netdevice.h>
8
9 #include "ionic.h"
10 #include "ionic_lif.h"
11 #include "ionic_stats.h"
12
13 static const struct ionic_stat_desc ionic_lif_stats_desc[] = {
14         IONIC_LIF_STAT_DESC(tx_packets),
15         IONIC_LIF_STAT_DESC(tx_bytes),
16         IONIC_LIF_STAT_DESC(rx_packets),
17         IONIC_LIF_STAT_DESC(rx_bytes),
18         IONIC_LIF_STAT_DESC(tx_tso),
19         IONIC_LIF_STAT_DESC(tx_tso_bytes),
20         IONIC_LIF_STAT_DESC(tx_csum_none),
21         IONIC_LIF_STAT_DESC(tx_csum),
22         IONIC_LIF_STAT_DESC(rx_csum_none),
23         IONIC_LIF_STAT_DESC(rx_csum_complete),
24         IONIC_LIF_STAT_DESC(rx_csum_error),
25         IONIC_LIF_STAT_DESC(hw_tx_dropped),
26         IONIC_LIF_STAT_DESC(hw_rx_dropped),
27         IONIC_LIF_STAT_DESC(hw_rx_over_errors),
28         IONIC_LIF_STAT_DESC(hw_rx_missed_errors),
29         IONIC_LIF_STAT_DESC(hw_tx_aborted_errors),
30 };
31
32 static const struct ionic_stat_desc ionic_port_stats_desc[] = {
33         IONIC_PORT_STAT_DESC(frames_rx_ok),
34         IONIC_PORT_STAT_DESC(frames_rx_all),
35         IONIC_PORT_STAT_DESC(frames_rx_bad_fcs),
36         IONIC_PORT_STAT_DESC(frames_rx_bad_all),
37         IONIC_PORT_STAT_DESC(octets_rx_ok),
38         IONIC_PORT_STAT_DESC(octets_rx_all),
39         IONIC_PORT_STAT_DESC(frames_rx_unicast),
40         IONIC_PORT_STAT_DESC(frames_rx_multicast),
41         IONIC_PORT_STAT_DESC(frames_rx_broadcast),
42         IONIC_PORT_STAT_DESC(frames_rx_pause),
43         IONIC_PORT_STAT_DESC(frames_rx_bad_length),
44         IONIC_PORT_STAT_DESC(frames_rx_undersized),
45         IONIC_PORT_STAT_DESC(frames_rx_oversized),
46         IONIC_PORT_STAT_DESC(frames_rx_fragments),
47         IONIC_PORT_STAT_DESC(frames_rx_jabber),
48         IONIC_PORT_STAT_DESC(frames_rx_pripause),
49         IONIC_PORT_STAT_DESC(frames_rx_stomped_crc),
50         IONIC_PORT_STAT_DESC(frames_rx_too_long),
51         IONIC_PORT_STAT_DESC(frames_rx_vlan_good),
52         IONIC_PORT_STAT_DESC(frames_rx_dropped),
53         IONIC_PORT_STAT_DESC(frames_rx_less_than_64b),
54         IONIC_PORT_STAT_DESC(frames_rx_64b),
55         IONIC_PORT_STAT_DESC(frames_rx_65b_127b),
56         IONIC_PORT_STAT_DESC(frames_rx_128b_255b),
57         IONIC_PORT_STAT_DESC(frames_rx_256b_511b),
58         IONIC_PORT_STAT_DESC(frames_rx_512b_1023b),
59         IONIC_PORT_STAT_DESC(frames_rx_1024b_1518b),
60         IONIC_PORT_STAT_DESC(frames_rx_1519b_2047b),
61         IONIC_PORT_STAT_DESC(frames_rx_2048b_4095b),
62         IONIC_PORT_STAT_DESC(frames_rx_4096b_8191b),
63         IONIC_PORT_STAT_DESC(frames_rx_8192b_9215b),
64         IONIC_PORT_STAT_DESC(frames_rx_other),
65         IONIC_PORT_STAT_DESC(frames_tx_ok),
66         IONIC_PORT_STAT_DESC(frames_tx_all),
67         IONIC_PORT_STAT_DESC(frames_tx_bad),
68         IONIC_PORT_STAT_DESC(octets_tx_ok),
69         IONIC_PORT_STAT_DESC(octets_tx_total),
70         IONIC_PORT_STAT_DESC(frames_tx_unicast),
71         IONIC_PORT_STAT_DESC(frames_tx_multicast),
72         IONIC_PORT_STAT_DESC(frames_tx_broadcast),
73         IONIC_PORT_STAT_DESC(frames_tx_pause),
74         IONIC_PORT_STAT_DESC(frames_tx_pripause),
75         IONIC_PORT_STAT_DESC(frames_tx_vlan),
76         IONIC_PORT_STAT_DESC(frames_tx_less_than_64b),
77         IONIC_PORT_STAT_DESC(frames_tx_64b),
78         IONIC_PORT_STAT_DESC(frames_tx_65b_127b),
79         IONIC_PORT_STAT_DESC(frames_tx_128b_255b),
80         IONIC_PORT_STAT_DESC(frames_tx_256b_511b),
81         IONIC_PORT_STAT_DESC(frames_tx_512b_1023b),
82         IONIC_PORT_STAT_DESC(frames_tx_1024b_1518b),
83         IONIC_PORT_STAT_DESC(frames_tx_1519b_2047b),
84         IONIC_PORT_STAT_DESC(frames_tx_2048b_4095b),
85         IONIC_PORT_STAT_DESC(frames_tx_4096b_8191b),
86         IONIC_PORT_STAT_DESC(frames_tx_8192b_9215b),
87         IONIC_PORT_STAT_DESC(frames_tx_other),
88         IONIC_PORT_STAT_DESC(frames_tx_pri_0),
89         IONIC_PORT_STAT_DESC(frames_tx_pri_1),
90         IONIC_PORT_STAT_DESC(frames_tx_pri_2),
91         IONIC_PORT_STAT_DESC(frames_tx_pri_3),
92         IONIC_PORT_STAT_DESC(frames_tx_pri_4),
93         IONIC_PORT_STAT_DESC(frames_tx_pri_5),
94         IONIC_PORT_STAT_DESC(frames_tx_pri_6),
95         IONIC_PORT_STAT_DESC(frames_tx_pri_7),
96         IONIC_PORT_STAT_DESC(frames_rx_pri_0),
97         IONIC_PORT_STAT_DESC(frames_rx_pri_1),
98         IONIC_PORT_STAT_DESC(frames_rx_pri_2),
99         IONIC_PORT_STAT_DESC(frames_rx_pri_3),
100         IONIC_PORT_STAT_DESC(frames_rx_pri_4),
101         IONIC_PORT_STAT_DESC(frames_rx_pri_5),
102         IONIC_PORT_STAT_DESC(frames_rx_pri_6),
103         IONIC_PORT_STAT_DESC(frames_rx_pri_7),
104         IONIC_PORT_STAT_DESC(tx_pripause_0_1us_count),
105         IONIC_PORT_STAT_DESC(tx_pripause_1_1us_count),
106         IONIC_PORT_STAT_DESC(tx_pripause_2_1us_count),
107         IONIC_PORT_STAT_DESC(tx_pripause_3_1us_count),
108         IONIC_PORT_STAT_DESC(tx_pripause_4_1us_count),
109         IONIC_PORT_STAT_DESC(tx_pripause_5_1us_count),
110         IONIC_PORT_STAT_DESC(tx_pripause_6_1us_count),
111         IONIC_PORT_STAT_DESC(tx_pripause_7_1us_count),
112         IONIC_PORT_STAT_DESC(rx_pripause_0_1us_count),
113         IONIC_PORT_STAT_DESC(rx_pripause_1_1us_count),
114         IONIC_PORT_STAT_DESC(rx_pripause_2_1us_count),
115         IONIC_PORT_STAT_DESC(rx_pripause_3_1us_count),
116         IONIC_PORT_STAT_DESC(rx_pripause_4_1us_count),
117         IONIC_PORT_STAT_DESC(rx_pripause_5_1us_count),
118         IONIC_PORT_STAT_DESC(rx_pripause_6_1us_count),
119         IONIC_PORT_STAT_DESC(rx_pripause_7_1us_count),
120         IONIC_PORT_STAT_DESC(rx_pause_1us_count),
121         IONIC_PORT_STAT_DESC(frames_tx_truncated),
122 };
123
124 static const struct ionic_stat_desc ionic_tx_stats_desc[] = {
125         IONIC_TX_STAT_DESC(pkts),
126         IONIC_TX_STAT_DESC(bytes),
127         IONIC_TX_STAT_DESC(clean),
128         IONIC_TX_STAT_DESC(dma_map_err),
129         IONIC_TX_STAT_DESC(linearize),
130         IONIC_TX_STAT_DESC(frags),
131         IONIC_TX_STAT_DESC(tso),
132         IONIC_TX_STAT_DESC(tso_bytes),
133         IONIC_TX_STAT_DESC(hwstamp_valid),
134         IONIC_TX_STAT_DESC(hwstamp_invalid),
135         IONIC_TX_STAT_DESC(csum_none),
136         IONIC_TX_STAT_DESC(csum),
137         IONIC_TX_STAT_DESC(vlan_inserted),
138 };
139
140 static const struct ionic_stat_desc ionic_rx_stats_desc[] = {
141         IONIC_RX_STAT_DESC(pkts),
142         IONIC_RX_STAT_DESC(bytes),
143         IONIC_RX_STAT_DESC(dma_map_err),
144         IONIC_RX_STAT_DESC(alloc_err),
145         IONIC_RX_STAT_DESC(csum_none),
146         IONIC_RX_STAT_DESC(csum_complete),
147         IONIC_RX_STAT_DESC(csum_error),
148         IONIC_RX_STAT_DESC(hwstamp_valid),
149         IONIC_RX_STAT_DESC(hwstamp_invalid),
150         IONIC_RX_STAT_DESC(dropped),
151         IONIC_RX_STAT_DESC(vlan_stripped),
152 };
153
154 static const struct ionic_stat_desc ionic_txq_stats_desc[] = {
155         IONIC_TX_Q_STAT_DESC(stop),
156         IONIC_TX_Q_STAT_DESC(wake),
157         IONIC_TX_Q_STAT_DESC(drop),
158         IONIC_TX_Q_STAT_DESC(dbell_count),
159 };
160
161 static const struct ionic_stat_desc ionic_dbg_cq_stats_desc[] = {
162         IONIC_CQ_STAT_DESC(compl_count),
163 };
164
165 static const struct ionic_stat_desc ionic_dbg_intr_stats_desc[] = {
166         IONIC_INTR_STAT_DESC(rearm_count),
167 };
168
169 static const struct ionic_stat_desc ionic_dbg_napi_stats_desc[] = {
170         IONIC_NAPI_STAT_DESC(poll_count),
171 };
172
173 #define IONIC_NUM_LIF_STATS ARRAY_SIZE(ionic_lif_stats_desc)
174 #define IONIC_NUM_PORT_STATS ARRAY_SIZE(ionic_port_stats_desc)
175 #define IONIC_NUM_TX_STATS ARRAY_SIZE(ionic_tx_stats_desc)
176 #define IONIC_NUM_RX_STATS ARRAY_SIZE(ionic_rx_stats_desc)
177 #define IONIC_NUM_TX_Q_STATS ARRAY_SIZE(ionic_txq_stats_desc)
178 #define IONIC_NUM_DBG_CQ_STATS ARRAY_SIZE(ionic_dbg_cq_stats_desc)
179 #define IONIC_NUM_DBG_INTR_STATS ARRAY_SIZE(ionic_dbg_intr_stats_desc)
180 #define IONIC_NUM_DBG_NAPI_STATS ARRAY_SIZE(ionic_dbg_napi_stats_desc)
181
182 #define MAX_Q(lif)   ((lif)->netdev->real_num_tx_queues)
183
184 static void ionic_add_lif_txq_stats(struct ionic_lif *lif, int q_num,
185                                     struct ionic_lif_sw_stats *stats)
186 {
187         struct ionic_tx_stats *txstats = &lif->txqstats[q_num];
188
189         stats->tx_packets += txstats->pkts;
190         stats->tx_bytes += txstats->bytes;
191         stats->tx_tso += txstats->tso;
192         stats->tx_tso_bytes += txstats->tso_bytes;
193         stats->tx_csum_none += txstats->csum_none;
194         stats->tx_csum += txstats->csum;
195         stats->tx_hwstamp_valid += txstats->hwstamp_valid;
196         stats->tx_hwstamp_invalid += txstats->hwstamp_invalid;
197 }
198
199 static void ionic_add_lif_rxq_stats(struct ionic_lif *lif, int q_num,
200                                     struct ionic_lif_sw_stats *stats)
201 {
202         struct ionic_rx_stats *rxstats = &lif->rxqstats[q_num];
203
204         stats->rx_packets += rxstats->pkts;
205         stats->rx_bytes += rxstats->bytes;
206         stats->rx_csum_none += rxstats->csum_none;
207         stats->rx_csum_complete += rxstats->csum_complete;
208         stats->rx_csum_error += rxstats->csum_error;
209         stats->rx_hwstamp_valid += rxstats->hwstamp_valid;
210         stats->rx_hwstamp_invalid += rxstats->hwstamp_invalid;
211 }
212
213 static void ionic_get_lif_stats(struct ionic_lif *lif,
214                                 struct ionic_lif_sw_stats *stats)
215 {
216         struct rtnl_link_stats64 ns;
217         int q_num;
218
219         memset(stats, 0, sizeof(*stats));
220
221         for (q_num = 0; q_num < MAX_Q(lif); q_num++) {
222                 ionic_add_lif_txq_stats(lif, q_num, stats);
223                 ionic_add_lif_rxq_stats(lif, q_num, stats);
224         }
225
226         if (lif->hwstamp_txq)
227                 ionic_add_lif_txq_stats(lif, lif->hwstamp_txq->q.index, stats);
228
229         if (lif->hwstamp_rxq)
230                 ionic_add_lif_rxq_stats(lif, lif->hwstamp_rxq->q.index, stats);
231
232         ionic_get_stats64(lif->netdev, &ns);
233         stats->hw_tx_dropped = ns.tx_dropped;
234         stats->hw_rx_dropped = ns.rx_dropped;
235         stats->hw_rx_over_errors = ns.rx_over_errors;
236         stats->hw_rx_missed_errors = ns.rx_missed_errors;
237         stats->hw_tx_aborted_errors = ns.tx_aborted_errors;
238 }
239
240 static u64 ionic_sw_stats_get_count(struct ionic_lif *lif)
241 {
242         u64 total = 0, tx_queues = MAX_Q(lif), rx_queues = MAX_Q(lif);
243
244         if (lif->hwstamp_txq)
245                 tx_queues += 1;
246
247         if (lif->hwstamp_rxq)
248                 rx_queues += 1;
249
250         total += IONIC_NUM_LIF_STATS;
251         total += IONIC_NUM_PORT_STATS;
252
253         total += tx_queues * IONIC_NUM_TX_STATS;
254         total += rx_queues * IONIC_NUM_RX_STATS;
255
256         if (test_bit(IONIC_LIF_F_UP, lif->state) &&
257             test_bit(IONIC_LIF_F_SW_DEBUG_STATS, lif->state)) {
258                 /* tx debug stats */
259                 total += tx_queues * (IONIC_NUM_DBG_CQ_STATS +
260                                       IONIC_NUM_TX_Q_STATS +
261                                       IONIC_NUM_DBG_INTR_STATS +
262                                       IONIC_MAX_NUM_SG_CNTR);
263
264                 /* rx debug stats */
265                 total += rx_queues * (IONIC_NUM_DBG_CQ_STATS +
266                                       IONIC_NUM_DBG_INTR_STATS +
267                                       IONIC_NUM_DBG_NAPI_STATS +
268                                       IONIC_MAX_NUM_NAPI_CNTR);
269         }
270
271         return total;
272 }
273
274 static void ionic_sw_stats_get_tx_strings(struct ionic_lif *lif, u8 **buf,
275                                           int q_num)
276 {
277         int i;
278
279         for (i = 0; i < IONIC_NUM_TX_STATS; i++)
280                 ethtool_sprintf(buf, "tx_%d_%s", q_num,
281                                 ionic_tx_stats_desc[i].name);
282
283         if (!test_bit(IONIC_LIF_F_UP, lif->state) ||
284             !test_bit(IONIC_LIF_F_SW_DEBUG_STATS, lif->state))
285                 return;
286
287         for (i = 0; i < IONIC_NUM_TX_Q_STATS; i++)
288                 ethtool_sprintf(buf, "txq_%d_%s", q_num,
289                                 ionic_txq_stats_desc[i].name);
290         for (i = 0; i < IONIC_NUM_DBG_CQ_STATS; i++)
291                 ethtool_sprintf(buf, "txq_%d_cq_%s", q_num,
292                                 ionic_dbg_cq_stats_desc[i].name);
293         for (i = 0; i < IONIC_NUM_DBG_INTR_STATS; i++)
294                 ethtool_sprintf(buf, "txq_%d_intr_%s", q_num,
295                                 ionic_dbg_intr_stats_desc[i].name);
296         for (i = 0; i < IONIC_MAX_NUM_SG_CNTR; i++)
297                 ethtool_sprintf(buf, "txq_%d_sg_cntr_%d", q_num, i);
298 }
299
300 static void ionic_sw_stats_get_rx_strings(struct ionic_lif *lif, u8 **buf,
301                                           int q_num)
302 {
303         int i;
304
305         for (i = 0; i < IONIC_NUM_RX_STATS; i++)
306                 ethtool_sprintf(buf, "rx_%d_%s", q_num,
307                                 ionic_rx_stats_desc[i].name);
308
309         if (!test_bit(IONIC_LIF_F_UP, lif->state) ||
310             !test_bit(IONIC_LIF_F_SW_DEBUG_STATS, lif->state))
311                 return;
312
313         for (i = 0; i < IONIC_NUM_DBG_CQ_STATS; i++)
314                 ethtool_sprintf(buf, "rxq_%d_cq_%s", q_num,
315                                 ionic_dbg_cq_stats_desc[i].name);
316         for (i = 0; i < IONIC_NUM_DBG_INTR_STATS; i++)
317                 ethtool_sprintf(buf, "rxq_%d_intr_%s", q_num,
318                                 ionic_dbg_intr_stats_desc[i].name);
319         for (i = 0; i < IONIC_NUM_DBG_NAPI_STATS; i++)
320                 ethtool_sprintf(buf, "rxq_%d_napi_%s", q_num,
321                                 ionic_dbg_napi_stats_desc[i].name);
322         for (i = 0; i < IONIC_MAX_NUM_NAPI_CNTR; i++)
323                 ethtool_sprintf(buf, "rxq_%d_napi_work_done_%d", q_num, i);
324 }
325
326 static void ionic_sw_stats_get_strings(struct ionic_lif *lif, u8 **buf)
327 {
328         int i, q_num;
329
330         for (i = 0; i < IONIC_NUM_LIF_STATS; i++)
331                 ethtool_sprintf(buf, ionic_lif_stats_desc[i].name);
332
333         for (i = 0; i < IONIC_NUM_PORT_STATS; i++)
334                 ethtool_sprintf(buf, ionic_port_stats_desc[i].name);
335
336         for (q_num = 0; q_num < MAX_Q(lif); q_num++)
337                 ionic_sw_stats_get_tx_strings(lif, buf, q_num);
338
339         if (lif->hwstamp_txq)
340                 ionic_sw_stats_get_tx_strings(lif, buf, lif->hwstamp_txq->q.index);
341
342         for (q_num = 0; q_num < MAX_Q(lif); q_num++)
343                 ionic_sw_stats_get_rx_strings(lif, buf, q_num);
344
345         if (lif->hwstamp_rxq)
346                 ionic_sw_stats_get_rx_strings(lif, buf, lif->hwstamp_rxq->q.index);
347 }
348
349 static void ionic_sw_stats_get_txq_values(struct ionic_lif *lif, u64 **buf,
350                                           int q_num)
351 {
352         struct ionic_tx_stats *txstats;
353         struct ionic_qcq *txqcq;
354         int i;
355
356         txstats = &lif->txqstats[q_num];
357
358         for (i = 0; i < IONIC_NUM_TX_STATS; i++) {
359                 **buf = IONIC_READ_STAT64(txstats, &ionic_tx_stats_desc[i]);
360                 (*buf)++;
361         }
362
363         if (!test_bit(IONIC_LIF_F_UP, lif->state) ||
364             !test_bit(IONIC_LIF_F_SW_DEBUG_STATS, lif->state))
365                 return;
366
367         txqcq = lif->txqcqs[q_num];
368         for (i = 0; i < IONIC_NUM_TX_Q_STATS; i++) {
369                 **buf = IONIC_READ_STAT64(&txqcq->q,
370                                           &ionic_txq_stats_desc[i]);
371                 (*buf)++;
372         }
373         for (i = 0; i < IONIC_NUM_DBG_CQ_STATS; i++) {
374                 **buf = IONIC_READ_STAT64(&txqcq->cq,
375                                           &ionic_dbg_cq_stats_desc[i]);
376                 (*buf)++;
377         }
378         for (i = 0; i < IONIC_NUM_DBG_INTR_STATS; i++) {
379                 **buf = IONIC_READ_STAT64(&txqcq->intr,
380                                           &ionic_dbg_intr_stats_desc[i]);
381                 (*buf)++;
382         }
383         for (i = 0; i < IONIC_NUM_DBG_NAPI_STATS; i++) {
384                 **buf = IONIC_READ_STAT64(&txqcq->napi_stats,
385                                           &ionic_dbg_napi_stats_desc[i]);
386                 (*buf)++;
387         }
388         for (i = 0; i < IONIC_MAX_NUM_NAPI_CNTR; i++) {
389                 **buf = txqcq->napi_stats.work_done_cntr[i];
390                 (*buf)++;
391         }
392         for (i = 0; i < IONIC_MAX_NUM_SG_CNTR; i++) {
393                 **buf = txstats->sg_cntr[i];
394                 (*buf)++;
395         }
396 }
397
398 static void ionic_sw_stats_get_rxq_values(struct ionic_lif *lif, u64 **buf,
399                                           int q_num)
400 {
401         struct ionic_rx_stats *rxstats;
402         struct ionic_qcq *rxqcq;
403         int i;
404
405         rxstats = &lif->rxqstats[q_num];
406
407         for (i = 0; i < IONIC_NUM_RX_STATS; i++) {
408                 **buf = IONIC_READ_STAT64(rxstats, &ionic_rx_stats_desc[i]);
409                 (*buf)++;
410         }
411
412         if (!test_bit(IONIC_LIF_F_UP, lif->state) ||
413             !test_bit(IONIC_LIF_F_SW_DEBUG_STATS, lif->state))
414                 return;
415
416         rxqcq = lif->rxqcqs[q_num];
417         for (i = 0; i < IONIC_NUM_DBG_CQ_STATS; i++) {
418                 **buf = IONIC_READ_STAT64(&rxqcq->cq,
419                                           &ionic_dbg_cq_stats_desc[i]);
420                 (*buf)++;
421         }
422         for (i = 0; i < IONIC_NUM_DBG_INTR_STATS; i++) {
423                 **buf = IONIC_READ_STAT64(&rxqcq->intr,
424                                           &ionic_dbg_intr_stats_desc[i]);
425                 (*buf)++;
426         }
427         for (i = 0; i < IONIC_NUM_DBG_NAPI_STATS; i++) {
428                 **buf = IONIC_READ_STAT64(&rxqcq->napi_stats,
429                                           &ionic_dbg_napi_stats_desc[i]);
430                 (*buf)++;
431         }
432         for (i = 0; i < IONIC_MAX_NUM_NAPI_CNTR; i++) {
433                 **buf = rxqcq->napi_stats.work_done_cntr[i];
434                 (*buf)++;
435         }
436 }
437
438 static void ionic_sw_stats_get_values(struct ionic_lif *lif, u64 **buf)
439 {
440         struct ionic_port_stats *port_stats;
441         struct ionic_lif_sw_stats lif_stats;
442         int i, q_num;
443
444         ionic_get_lif_stats(lif, &lif_stats);
445
446         for (i = 0; i < IONIC_NUM_LIF_STATS; i++) {
447                 **buf = IONIC_READ_STAT64(&lif_stats, &ionic_lif_stats_desc[i]);
448                 (*buf)++;
449         }
450
451         port_stats = &lif->ionic->idev.port_info->stats;
452         for (i = 0; i < IONIC_NUM_PORT_STATS; i++) {
453                 **buf = IONIC_READ_STAT_LE64(port_stats,
454                                              &ionic_port_stats_desc[i]);
455                 (*buf)++;
456         }
457
458         for (q_num = 0; q_num < MAX_Q(lif); q_num++)
459                 ionic_sw_stats_get_txq_values(lif, buf, q_num);
460
461         if (lif->hwstamp_txq)
462                 ionic_sw_stats_get_txq_values(lif, buf, lif->hwstamp_txq->q.index);
463
464         for (q_num = 0; q_num < MAX_Q(lif); q_num++)
465                 ionic_sw_stats_get_rxq_values(lif, buf, q_num);
466
467         if (lif->hwstamp_rxq)
468                 ionic_sw_stats_get_rxq_values(lif, buf, lif->hwstamp_rxq->q.index);
469 }
470
471 const struct ionic_stats_group_intf ionic_stats_groups[] = {
472         /* SW Stats group */
473         {
474                 .get_strings = ionic_sw_stats_get_strings,
475                 .get_values = ionic_sw_stats_get_values,
476                 .get_count = ionic_sw_stats_get_count,
477         },
478         /* Add more stat groups here */
479 };
480
481 const int ionic_num_stats_grps = ARRAY_SIZE(ionic_stats_groups);