b.liu | e958203 | 2025-04-17 19:18:16 +0800 | [diff] [blame^] | 1 | From 5a43b0405561fb6feffb7042493b58014ac27a4d Mon Sep 17 00:00:00 2001 |
| 2 | From: Ioana Radulescu <ruxandra.radulescu@nxp.com> |
| 3 | Date: Tue, 12 Feb 2019 22:05:16 +0200 |
| 4 | Subject: [PATCH] dpaa2-eth: Add channel stat |
| 5 | |
| 6 | Compute average number of frames processed for each CDAN |
| 7 | received on a channel and print it in the detailed channel |
| 8 | stats. |
| 9 | |
| 10 | Signed-off-by: Ioana Radulescu <ruxandra.radulescu@nxp.com> |
| 11 | --- |
| 12 | drivers/net/ethernet/freescale/dpaa2/dpaa2-eth-debugfs.c | 8 +++++--- |
| 13 | drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c | 1 + |
| 14 | drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.h | 2 ++ |
| 15 | drivers/net/ethernet/freescale/dpaa2/dpaa2-ethtool.c | 2 +- |
| 16 | 4 files changed, 9 insertions(+), 4 deletions(-) |
| 17 | |
| 18 | --- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth-debugfs.c |
| 19 | +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth-debugfs.c |
| 20 | @@ -132,16 +132,18 @@ static int dpaa2_dbg_ch_show(struct seq_ |
| 21 | int i; |
| 22 | |
| 23 | seq_printf(file, "Channel stats for %s:\n", priv->net_dev->name); |
| 24 | - seq_printf(file, "%s%16s%16s%16s%16s\n", |
| 25 | - "CHID", "CPU", "Deq busy", "CDANs", "Buf count"); |
| 26 | + seq_printf(file, "%s%16s%16s%16s%16s%16s%16s\n", |
| 27 | + "CHID", "CPU", "Deq busy", "Frames", "CDANs", "Avg Frm/CDAN", "Buf count"); |
| 28 | |
| 29 | for (i = 0; i < priv->num_channels; i++) { |
| 30 | ch = priv->channel[i]; |
| 31 | - seq_printf(file, "%4d%16d%16llu%16llu%16d\n", |
| 32 | + seq_printf(file, "%4d%16d%16llu%16llu%16llu%16llu%16d\n", |
| 33 | ch->ch_id, |
| 34 | ch->nctx.desired_cpu, |
| 35 | ch->stats.dequeue_portal_busy, |
| 36 | + ch->stats.frames, |
| 37 | ch->stats.cdan, |
| 38 | + ch->stats.frames / ch->stats.cdan, |
| 39 | ch->buf_count); |
| 40 | } |
| 41 | |
| 42 | --- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c |
| 43 | +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c |
| 44 | @@ -540,6 +540,7 @@ static int consume_frames(struct dpaa2_e |
| 45 | return 0; |
| 46 | |
| 47 | fq->stats.frames += cleaned; |
| 48 | + ch->stats.frames += cleaned; |
| 49 | |
| 50 | /* A dequeue operation only pulls frames from a single queue |
| 51 | * into the store. Return the frame queue as an out param. |
| 52 | --- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.h |
| 53 | +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.h |
| 54 | @@ -310,6 +310,8 @@ struct dpaa2_eth_ch_stats { |
| 55 | __u64 xdp_tx; |
| 56 | __u64 xdp_tx_err; |
| 57 | __u64 xdp_redirect; |
| 58 | + /* Must be last, does not show up in ethtool stats */ |
| 59 | + __u64 frames; |
| 60 | }; |
| 61 | |
| 62 | /* Maximum number of queues associated with a DPNI */ |
| 63 | --- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-ethtool.c |
| 64 | +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-ethtool.c |
| 65 | @@ -234,7 +234,7 @@ static void dpaa2_eth_get_ethtool_stats( |
| 66 | /* Per-channel stats */ |
| 67 | for (k = 0; k < priv->num_channels; k++) { |
| 68 | ch_stats = &priv->channel[k]->stats; |
| 69 | - for (j = 0; j < sizeof(*ch_stats) / sizeof(__u64); j++) |
| 70 | + for (j = 0; j < sizeof(*ch_stats) / sizeof(__u64) - 1; j++) |
| 71 | *((__u64 *)data + i + j) += *((__u64 *)ch_stats + j); |
| 72 | } |
| 73 | i += j; |