Skip to content

Commit 0d15a26

Browse files
danish-tikuba-moo
authored andcommitted
net: ti: icssg-prueth: Add ICSSG FW Stats
The ICSSG firmware maintains set of stats called PA_STATS. Currently the driver only dumps 4 stats. Add support for dumping more stats. The offset for different stats are defined as MACROs in icssg_switch_map.h file. All the offsets are for Slice0. Slice1 offsets are slice0 + 4. The offset calculation is taken care while reading the stats in emac_update_hardware_stats(). The statistics are documented in Documentation/networking/device_drivers/icssg_prueth.rst Reviewed-by: Simon Horman <[email protected]> Signed-off-by: MD Danish Anwar <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent a427e7f commit 0d15a26

File tree

7 files changed

+151
-31
lines changed

7 files changed

+151
-31
lines changed

Documentation/networking/device_drivers/ethernet/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ Contents:
5555
ti/cpsw_switchdev
5656
ti/am65_nuss_cpsw_switchdev
5757
ti/tlan
58+
ti/icssg_prueth
5859
wangxun/txgbe
5960
wangxun/ngbe
6061

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
.. SPDX-License-Identifier: GPL-2.0
2+
3+
==============================================
4+
Texas Instruments ICSSG PRUETH ethernet driver
5+
==============================================
6+
7+
:Version: 1.0
8+
9+
ICSSG Firmware
10+
==============
11+
12+
Every ICSSG core has two Programmable Real-Time Unit(PRUs), two auxiliary
13+
Real-Time Transfer Unit (RTUs), and two Transmit Real-Time Transfer Units
14+
(TX_PRUs). Each one of these runs its own firmware. The firmwares combnined are
15+
referred as ICSSG Firmware.
16+
17+
Firmware Statistics
18+
===================
19+
20+
The ICSSG firmware maintains certain statistics which are dumped by the driver
21+
via ``ethtool -S <interface>``
22+
23+
These statistics are as follows,
24+
25+
- ``FW_RTU_PKT_DROP``: Diagnostic error counter which increments when RTU drops a locally injected packet due to port being disabled or rule violation.
26+
- ``FW_Q0_OVERFLOW``: TX overflow counter for queue0
27+
- ``FW_Q1_OVERFLOW``: TX overflow counter for queue1
28+
- ``FW_Q2_OVERFLOW``: TX overflow counter for queue2
29+
- ``FW_Q3_OVERFLOW``: TX overflow counter for queue3
30+
- ``FW_Q4_OVERFLOW``: TX overflow counter for queue4
31+
- ``FW_Q5_OVERFLOW``: TX overflow counter for queue5
32+
- ``FW_Q6_OVERFLOW``: TX overflow counter for queue6
33+
- ``FW_Q7_OVERFLOW``: TX overflow counter for queue7
34+
- ``FW_DROPPED_PKT``: This counter is incremented when a packet is dropped at PRU because of rule violation.
35+
- ``FW_RX_ERROR``: Incremented if there was a CRC error or Min/Max frame error at PRU
36+
- ``FW_RX_DS_INVALID``: Incremented when RTU detects Data Status invalid condition
37+
- ``FW_TX_DROPPED_PACKET``: Counter for packets dropped via TX Port
38+
- ``FW_TX_TS_DROPPED_PACKET``: Counter for packets with TS flag dropped via TX Port
39+
- ``FW_INF_PORT_DISABLED``: Incremented when RX frame is dropped due to port being disabled
40+
- ``FW_INF_SAV``: Incremented when RX frame is dropped due to Source Address violation
41+
- ``FW_INF_SA_DL``: Incremented when RX frame is dropped due to Source Address being in the denylist
42+
- ``FW_INF_PORT_BLOCKED``: Incremented when RX frame is dropped due to port being blocked and frame being a special frame
43+
- ``FW_INF_DROP_TAGGED`` : Incremented when RX frame is dropped for being tagged
44+
- ``FW_INF_DROP_PRIOTAGGED``: Incremented when RX frame is dropped for being priority tagged
45+
- ``FW_INF_DROP_NOTAG``: Incremented when RX frame is dropped for being untagged
46+
- ``FW_INF_DROP_NOTMEMBER``: Incremented when RX frame is dropped for port not being member of VLAN
47+
- ``FW_RX_EOF_SHORT_FRMERR``: Incremented if End Of Frame (EOF) task is scheduled without seeing RX_B1
48+
- ``FW_RX_B0_DROP_EARLY_EOF``: Incremented when frame is dropped due to Early EOF
49+
- ``FW_TX_JUMBO_FRM_CUTOFF``: Incremented when frame is cut off to prevent packet size > 2000 Bytes
50+
- ``FW_RX_EXP_FRAG_Q_DROP``: Incremented when express frame is received in the same queue as the previous fragment
51+
- ``FW_RX_FIFO_OVERRUN``: RX fifo overrun counter
52+
- ``FW_CUT_THR_PKT``: Incremented when a packet is forwarded using Cut-Through forwarding method
53+
- ``FW_HOST_RX_PKT_CNT``: Number of valid packets sent by Rx PRU to Host on PSI
54+
- ``FW_HOST_TX_PKT_CNT``: Number of valid packets copied by RTU0 to Tx queues
55+
- ``FW_HOST_EGRESS_Q_PRE_OVERFLOW``: Host Egress Q (Pre-emptible) Overflow Counter
56+
- ``FW_HOST_EGRESS_Q_EXP_OVERFLOW``: Host Egress Q (Pre-emptible) Overflow Counter

drivers/net/ethernet/ti/icssg/icssg_common.c

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1318,10 +1318,28 @@ void icssg_ndo_get_stats64(struct net_device *ndev,
13181318
stats->rx_over_errors = emac_get_stat_by_name(emac, "rx_over_errors");
13191319
stats->multicast = emac_get_stat_by_name(emac, "rx_multicast_frames");
13201320

1321-
stats->rx_errors = ndev->stats.rx_errors;
1322-
stats->rx_dropped = ndev->stats.rx_dropped;
1321+
stats->rx_errors = ndev->stats.rx_errors +
1322+
emac_get_stat_by_name(emac, "FW_RX_ERROR") +
1323+
emac_get_stat_by_name(emac, "FW_RX_EOF_SHORT_FRMERR") +
1324+
emac_get_stat_by_name(emac, "FW_RX_B0_DROP_EARLY_EOF") +
1325+
emac_get_stat_by_name(emac, "FW_RX_EXP_FRAG_Q_DROP") +
1326+
emac_get_stat_by_name(emac, "FW_RX_FIFO_OVERRUN");
1327+
stats->rx_dropped = ndev->stats.rx_dropped +
1328+
emac_get_stat_by_name(emac, "FW_DROPPED_PKT") +
1329+
emac_get_stat_by_name(emac, "FW_INF_PORT_DISABLED") +
1330+
emac_get_stat_by_name(emac, "FW_INF_SAV") +
1331+
emac_get_stat_by_name(emac, "FW_INF_SA_DL") +
1332+
emac_get_stat_by_name(emac, "FW_INF_PORT_BLOCKED") +
1333+
emac_get_stat_by_name(emac, "FW_INF_DROP_TAGGED") +
1334+
emac_get_stat_by_name(emac, "FW_INF_DROP_PRIOTAGGED") +
1335+
emac_get_stat_by_name(emac, "FW_INF_DROP_NOTAG") +
1336+
emac_get_stat_by_name(emac, "FW_INF_DROP_NOTMEMBER");
13231337
stats->tx_errors = ndev->stats.tx_errors;
1324-
stats->tx_dropped = ndev->stats.tx_dropped;
1338+
stats->tx_dropped = ndev->stats.tx_dropped +
1339+
emac_get_stat_by_name(emac, "FW_RTU_PKT_DROP") +
1340+
emac_get_stat_by_name(emac, "FW_TX_DROPPED_PACKET") +
1341+
emac_get_stat_by_name(emac, "FW_TX_TS_DROPPED_PACKET") +
1342+
emac_get_stat_by_name(emac, "FW_TX_JUMBO_FRM_CUTOFF");
13251343
}
13261344
EXPORT_SYMBOL_GPL(icssg_ndo_get_stats64);
13271345

drivers/net/ethernet/ti/icssg/icssg_prueth.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454

5555
#define ICSSG_MAX_RFLOWS 8 /* per slice */
5656

57-
#define ICSSG_NUM_PA_STATS 4
57+
#define ICSSG_NUM_PA_STATS 32
5858
#define ICSSG_NUM_MIIG_STATS 60
5959
/* Number of ICSSG related stats */
6060
#define ICSSG_NUM_STATS (ICSSG_NUM_MIIG_STATS + ICSSG_NUM_PA_STATS)

drivers/net/ethernet/ti/icssg/icssg_stats.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
#define ICSSG_TX_PACKET_OFFSET 0xA0
1313
#define ICSSG_TX_BYTE_OFFSET 0xEC
14-
#define ICSSG_FW_STATS_BASE 0x0248
1514

1615
static u32 stats_base[] = { 0x54c, /* Slice 0 stats start */
1716
0xb18, /* Slice 1 stats start */
@@ -46,9 +45,8 @@ void emac_update_hardware_stats(struct prueth_emac *emac)
4645

4746
if (prueth->pa_stats) {
4847
for (i = 0; i < ARRAY_SIZE(icssg_all_pa_stats); i++) {
49-
reg = ICSSG_FW_STATS_BASE +
50-
icssg_all_pa_stats[i].offset *
51-
PRUETH_NUM_MACS + slice * sizeof(u32);
48+
reg = icssg_all_pa_stats[i].offset +
49+
slice * sizeof(u32);
5250
regmap_read(prueth->pa_stats, reg, &val);
5351
emac->pa_stats[i] += val;
5452
}
@@ -80,7 +78,7 @@ int emac_get_stat_by_name(struct prueth_emac *emac, char *stat_name)
8078
if (emac->prueth->pa_stats) {
8179
for (i = 0; i < ARRAY_SIZE(icssg_all_pa_stats); i++) {
8280
if (!strcmp(icssg_all_pa_stats[i].name, stat_name))
83-
return emac->pa_stats[icssg_all_pa_stats[i].offset / sizeof(u32)];
81+
return emac->pa_stats[i];
8482
}
8583
}
8684

drivers/net/ethernet/ti/icssg/icssg_stats.h

Lines changed: 36 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -155,24 +155,10 @@ static const struct icssg_miig_stats icssg_all_miig_stats[] = {
155155
ICSSG_MIIG_STATS(tx_bytes, true),
156156
};
157157

158-
/**
159-
* struct pa_stats_regs - ICSSG Firmware maintained PA Stats register
160-
* @fw_rx_cnt: Number of valid packets sent by Rx PRU to Host on PSI
161-
* @fw_tx_cnt: Number of valid packets copied by RTU0 to Tx queues
162-
* @fw_tx_pre_overflow: Host Egress Q (Pre-emptible) Overflow Counter
163-
* @fw_tx_exp_overflow: Host Egress Q (Express) Overflow Counter
164-
*/
165-
struct pa_stats_regs {
166-
u32 fw_rx_cnt;
167-
u32 fw_tx_cnt;
168-
u32 fw_tx_pre_overflow;
169-
u32 fw_tx_exp_overflow;
170-
};
171-
172-
#define ICSSG_PA_STATS(field) \
173-
{ \
174-
#field, \
175-
offsetof(struct pa_stats_regs, field), \
158+
#define ICSSG_PA_STATS(field) \
159+
{ \
160+
#field, \
161+
field, \
176162
}
177163

178164
struct icssg_pa_stats {
@@ -181,10 +167,38 @@ struct icssg_pa_stats {
181167
};
182168

183169
static const struct icssg_pa_stats icssg_all_pa_stats[] = {
184-
ICSSG_PA_STATS(fw_rx_cnt),
185-
ICSSG_PA_STATS(fw_tx_cnt),
186-
ICSSG_PA_STATS(fw_tx_pre_overflow),
187-
ICSSG_PA_STATS(fw_tx_exp_overflow),
170+
ICSSG_PA_STATS(FW_RTU_PKT_DROP),
171+
ICSSG_PA_STATS(FW_Q0_OVERFLOW),
172+
ICSSG_PA_STATS(FW_Q1_OVERFLOW),
173+
ICSSG_PA_STATS(FW_Q2_OVERFLOW),
174+
ICSSG_PA_STATS(FW_Q3_OVERFLOW),
175+
ICSSG_PA_STATS(FW_Q4_OVERFLOW),
176+
ICSSG_PA_STATS(FW_Q5_OVERFLOW),
177+
ICSSG_PA_STATS(FW_Q6_OVERFLOW),
178+
ICSSG_PA_STATS(FW_Q7_OVERFLOW),
179+
ICSSG_PA_STATS(FW_DROPPED_PKT),
180+
ICSSG_PA_STATS(FW_RX_ERROR),
181+
ICSSG_PA_STATS(FW_RX_DS_INVALID),
182+
ICSSG_PA_STATS(FW_TX_DROPPED_PACKET),
183+
ICSSG_PA_STATS(FW_TX_TS_DROPPED_PACKET),
184+
ICSSG_PA_STATS(FW_INF_PORT_DISABLED),
185+
ICSSG_PA_STATS(FW_INF_SAV),
186+
ICSSG_PA_STATS(FW_INF_SA_DL),
187+
ICSSG_PA_STATS(FW_INF_PORT_BLOCKED),
188+
ICSSG_PA_STATS(FW_INF_DROP_TAGGED),
189+
ICSSG_PA_STATS(FW_INF_DROP_PRIOTAGGED),
190+
ICSSG_PA_STATS(FW_INF_DROP_NOTAG),
191+
ICSSG_PA_STATS(FW_INF_DROP_NOTMEMBER),
192+
ICSSG_PA_STATS(FW_RX_EOF_SHORT_FRMERR),
193+
ICSSG_PA_STATS(FW_RX_B0_DROP_EARLY_EOF),
194+
ICSSG_PA_STATS(FW_TX_JUMBO_FRM_CUTOFF),
195+
ICSSG_PA_STATS(FW_RX_EXP_FRAG_Q_DROP),
196+
ICSSG_PA_STATS(FW_RX_FIFO_OVERRUN),
197+
ICSSG_PA_STATS(FW_CUT_THR_PKT),
198+
ICSSG_PA_STATS(FW_HOST_RX_PKT_CNT),
199+
ICSSG_PA_STATS(FW_HOST_TX_PKT_CNT),
200+
ICSSG_PA_STATS(FW_HOST_EGRESS_Q_PRE_OVERFLOW),
201+
ICSSG_PA_STATS(FW_HOST_EGRESS_Q_EXP_OVERFLOW),
188202
};
189203

190204
#endif /* __NET_TI_ICSSG_STATS_H */

drivers/net/ethernet/ti/icssg/icssg_switch_map.h

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,4 +231,37 @@
231231
/* Start of 32 bits PA_STAT counters */
232232
#define PA_STAT_32b_START_OFFSET 0x0080
233233

234+
#define FW_RTU_PKT_DROP 0x0088
235+
#define FW_Q0_OVERFLOW 0x0090
236+
#define FW_Q1_OVERFLOW 0x0098
237+
#define FW_Q2_OVERFLOW 0x00A0
238+
#define FW_Q3_OVERFLOW 0x00A8
239+
#define FW_Q4_OVERFLOW 0x00B0
240+
#define FW_Q5_OVERFLOW 0x00B8
241+
#define FW_Q6_OVERFLOW 0x00C0
242+
#define FW_Q7_OVERFLOW 0x00C8
243+
#define FW_DROPPED_PKT 0x00F8
244+
#define FW_RX_ERROR 0x0100
245+
#define FW_RX_DS_INVALID 0x0108
246+
#define FW_TX_DROPPED_PACKET 0x0110
247+
#define FW_TX_TS_DROPPED_PACKET 0x0118
248+
#define FW_INF_PORT_DISABLED 0x0120
249+
#define FW_INF_SAV 0x0128
250+
#define FW_INF_SA_DL 0x0130
251+
#define FW_INF_PORT_BLOCKED 0x0138
252+
#define FW_INF_DROP_TAGGED 0x0140
253+
#define FW_INF_DROP_PRIOTAGGED 0x0148
254+
#define FW_INF_DROP_NOTAG 0x0150
255+
#define FW_INF_DROP_NOTMEMBER 0x0158
256+
#define FW_RX_EOF_SHORT_FRMERR 0x0188
257+
#define FW_RX_B0_DROP_EARLY_EOF 0x0190
258+
#define FW_TX_JUMBO_FRM_CUTOFF 0x0198
259+
#define FW_RX_EXP_FRAG_Q_DROP 0x01A0
260+
#define FW_RX_FIFO_OVERRUN 0x01A8
261+
#define FW_CUT_THR_PKT 0x01B0
262+
#define FW_HOST_RX_PKT_CNT 0x0248
263+
#define FW_HOST_TX_PKT_CNT 0x0250
264+
#define FW_HOST_EGRESS_Q_PRE_OVERFLOW 0x0258
265+
#define FW_HOST_EGRESS_Q_EXP_OVERFLOW 0x0260
266+
234267
#endif /* __NET_TI_ICSSG_SWITCH_MAP_H */

0 commit comments

Comments
 (0)