Skip to content

Commit d84c3a4

Browse files
Ioana Radulescudavem330
authored andcommitted
dpaa2-eth: Add new DPNI statistics counters
Recent firmware versions expose more DPNI counters. Export relevant ones via ethtool -S. Signed-off-by: Ioana Radulescu <ruxandra.radulescu@nxp.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent ae90a6f commit d84c3a4

File tree

3 files changed

+58
-3
lines changed

3 files changed

+58
-3
lines changed

drivers/net/ethernet/freescale/dpaa2/dpaa2-ethtool.c

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ static char dpaa2_ethtool_stats[][ETH_GSTRING_LEN] = {
2828
"[hw] rx nobuffer discards",
2929
"[hw] tx discarded frames",
3030
"[hw] tx confirmed frames",
31+
"[hw] tx dequeued bytes",
32+
"[hw] tx dequeued frames",
33+
"[hw] tx rejected bytes",
34+
"[hw] tx rejected frames",
35+
"[hw] tx pending frames",
3136
};
3237

3338
#define DPAA2_ETH_NUM_STATS ARRAY_SIZE(dpaa2_ethtool_stats)
@@ -192,16 +197,26 @@ static void dpaa2_eth_get_ethtool_stats(struct net_device *net_dev,
192197
sizeof(dpni_stats.page_0),
193198
sizeof(dpni_stats.page_1),
194199
sizeof(dpni_stats.page_2),
200+
sizeof(dpni_stats.page_3),
201+
sizeof(dpni_stats.page_4),
202+
sizeof(dpni_stats.page_5),
203+
sizeof(dpni_stats.page_6),
195204
};
196205

197206
memset(data, 0,
198207
sizeof(u64) * (DPAA2_ETH_NUM_STATS + DPAA2_ETH_NUM_EXTRA_STATS));
199208

200209
/* Print standard counters, from DPNI statistics */
201-
for (j = 0; j <= 2; j++) {
210+
for (j = 0; j <= 6; j++) {
211+
/* We're not interested in pages 4 & 5 for now */
212+
if (j == 4 || j == 5)
213+
continue;
202214
err = dpni_get_statistics(priv->mc_io, 0, priv->mc_token,
203215
j, &dpni_stats);
204-
if (err != 0)
216+
if (err == -EINVAL)
217+
/* Older firmware versions don't support all pages */
218+
memset(&dpni_stats, 0, sizeof(dpni_stats));
219+
else
205220
netdev_warn(net_dev, "dpni_get_stats(%d) failed\n", j);
206221

207222
num_cnt = dpni_stats_page_size[j] / sizeof(u64);

drivers/net/ethernet/freescale/dpaa2/dpni.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1470,7 +1470,7 @@ int dpni_get_queue(struct fsl_mc_io *mc_io,
14701470
* @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
14711471
* @token: Token of DPNI object
14721472
* @page: Selects the statistics page to retrieve, see
1473-
* DPNI_GET_STATISTICS output. Pages are numbered 0 to 2.
1473+
* DPNI_GET_STATISTICS output. Pages are numbered 0 to 6.
14741474
* @stat: Structure containing the statistics
14751475
*
14761476
* Return: '0' on Success; Error code otherwise.

drivers/net/ethernet/freescale/dpaa2/dpni.h

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,26 @@ int dpni_get_tx_data_offset(struct fsl_mc_io *mc_io,
416416
* lack of buffers
417417
* @page_2.egress_discarded_frames: Egress discarded frame count
418418
* @page_2.egress_confirmed_frames: Egress confirmed frame count
419+
* @page3: Page_3 statistics structure
420+
* @page_3.egress_dequeue_bytes: Cumulative count of the number of bytes
421+
* dequeued from egress FQs
422+
* @page_3.egress_dequeue_frames: Cumulative count of the number of frames
423+
* dequeued from egress FQs
424+
* @page_3.egress_reject_bytes: Cumulative count of the number of bytes in
425+
* egress frames whose enqueue was rejected
426+
* @page_3.egress_reject_frames: Cumulative count of the number of egress
427+
* frames whose enqueue was rejected
428+
* @page_4: Page_4 statistics structure: congestion points
429+
* @page_4.cgr_reject_frames: number of rejected frames due to congestion point
430+
* @page_4.cgr_reject_bytes: number of rejected bytes due to congestion point
431+
* @page_5: Page_5 statistics structure: policer
432+
* @page_5.policer_cnt_red: NUmber of red colored frames
433+
* @page_5.policer_cnt_yellow: number of yellow colored frames
434+
* @page_5.policer_cnt_green: number of green colored frames
435+
* @page_5.policer_cnt_re_red: number of recolored red frames
436+
* @page_5.policer_cnt_re_yellow: number of recolored yellow frames
437+
* @page_6: Page_6 statistics structure
438+
* @page_6.tx_pending_frames: total number of frames pending in egress FQs
419439
* @raw: raw statistics structure, used to index counters
420440
*/
421441
union dpni_statistics {
@@ -442,6 +462,26 @@ union dpni_statistics {
442462
u64 egress_discarded_frames;
443463
u64 egress_confirmed_frames;
444464
} page_2;
465+
struct {
466+
u64 egress_dequeue_bytes;
467+
u64 egress_dequeue_frames;
468+
u64 egress_reject_bytes;
469+
u64 egress_reject_frames;
470+
} page_3;
471+
struct {
472+
u64 cgr_reject_frames;
473+
u64 cgr_reject_bytes;
474+
} page_4;
475+
struct {
476+
u64 policer_cnt_red;
477+
u64 policer_cnt_yellow;
478+
u64 policer_cnt_green;
479+
u64 policer_cnt_re_red;
480+
u64 policer_cnt_re_yellow;
481+
} page_5;
482+
struct {
483+
u64 tx_pending_frames;
484+
} page_6;
445485
struct {
446486
u64 counter[DPNI_STATISTICS_CNT];
447487
} raw;

0 commit comments

Comments
 (0)