Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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 <horms@kernel.org>
Signed-off-by: MD Danish Anwar <danishanwar@ti.com>
Link: https://patch.msgid.link/20250424095316.2643573-1-danishanwar@ti.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

MD Danish Anwar and committed by
Jakub Kicinski
0d15a26b a427e7f9

+151 -31
+1
Documentation/networking/device_drivers/ethernet/index.rst
··· 55 55 ti/cpsw_switchdev 56 56 ti/am65_nuss_cpsw_switchdev 57 57 ti/tlan 58 + ti/icssg_prueth 58 59 wangxun/txgbe 59 60 wangxun/ngbe 60 61
+56
Documentation/networking/device_drivers/ethernet/ti/icssg_prueth.rst
··· 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
+21 -3
drivers/net/ethernet/ti/icssg/icssg_common.c
··· 1318 1318 stats->rx_over_errors = emac_get_stat_by_name(emac, "rx_over_errors"); 1319 1319 stats->multicast = emac_get_stat_by_name(emac, "rx_multicast_frames"); 1320 1320 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"); 1323 1337 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"); 1325 1343 } 1326 1344 EXPORT_SYMBOL_GPL(icssg_ndo_get_stats64); 1327 1345
+1 -1
drivers/net/ethernet/ti/icssg/icssg_prueth.h
··· 54 54 55 55 #define ICSSG_MAX_RFLOWS 8 /* per slice */ 56 56 57 - #define ICSSG_NUM_PA_STATS 4 57 + #define ICSSG_NUM_PA_STATS 32 58 58 #define ICSSG_NUM_MIIG_STATS 60 59 59 /* Number of ICSSG related stats */ 60 60 #define ICSSG_NUM_STATS (ICSSG_NUM_MIIG_STATS + ICSSG_NUM_PA_STATS)
+3 -5
drivers/net/ethernet/ti/icssg/icssg_stats.c
··· 11 11 12 12 #define ICSSG_TX_PACKET_OFFSET 0xA0 13 13 #define ICSSG_TX_BYTE_OFFSET 0xEC 14 - #define ICSSG_FW_STATS_BASE 0x0248 15 14 16 15 static u32 stats_base[] = { 0x54c, /* Slice 0 stats start */ 17 16 0xb18, /* Slice 1 stats start */ ··· 45 46 46 47 if (prueth->pa_stats) { 47 48 for (i = 0; i < ARRAY_SIZE(icssg_all_pa_stats); i++) { 48 - reg = ICSSG_FW_STATS_BASE + 49 - icssg_all_pa_stats[i].offset * 50 - PRUETH_NUM_MACS + slice * sizeof(u32); 49 + reg = icssg_all_pa_stats[i].offset + 50 + slice * sizeof(u32); 51 51 regmap_read(prueth->pa_stats, reg, &val); 52 52 emac->pa_stats[i] += val; 53 53 } ··· 78 80 if (emac->prueth->pa_stats) { 79 81 for (i = 0; i < ARRAY_SIZE(icssg_all_pa_stats); i++) { 80 82 if (!strcmp(icssg_all_pa_stats[i].name, stat_name)) 81 - return emac->pa_stats[icssg_all_pa_stats[i].offset / sizeof(u32)]; 83 + return emac->pa_stats[i]; 82 84 } 83 85 } 84 86
+36 -22
drivers/net/ethernet/ti/icssg/icssg_stats.h
··· 155 155 ICSSG_MIIG_STATS(tx_bytes, true), 156 156 }; 157 157 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, \ 176 162 } 177 163 178 164 struct icssg_pa_stats { ··· 167 181 }; 168 182 169 183 static const struct icssg_pa_stats icssg_all_pa_stats[] = { 170 - ICSSG_PA_STATS(fw_rx_cnt), 171 - ICSSG_PA_STATS(fw_tx_cnt), 172 - ICSSG_PA_STATS(fw_tx_pre_overflow), 173 - ICSSG_PA_STATS(fw_tx_exp_overflow), 184 + ICSSG_PA_STATS(FW_RTU_PKT_DROP), 185 + ICSSG_PA_STATS(FW_Q0_OVERFLOW), 186 + ICSSG_PA_STATS(FW_Q1_OVERFLOW), 187 + ICSSG_PA_STATS(FW_Q2_OVERFLOW), 188 + ICSSG_PA_STATS(FW_Q3_OVERFLOW), 189 + ICSSG_PA_STATS(FW_Q4_OVERFLOW), 190 + ICSSG_PA_STATS(FW_Q5_OVERFLOW), 191 + ICSSG_PA_STATS(FW_Q6_OVERFLOW), 192 + ICSSG_PA_STATS(FW_Q7_OVERFLOW), 193 + ICSSG_PA_STATS(FW_DROPPED_PKT), 194 + ICSSG_PA_STATS(FW_RX_ERROR), 195 + ICSSG_PA_STATS(FW_RX_DS_INVALID), 196 + ICSSG_PA_STATS(FW_TX_DROPPED_PACKET), 197 + ICSSG_PA_STATS(FW_TX_TS_DROPPED_PACKET), 198 + ICSSG_PA_STATS(FW_INF_PORT_DISABLED), 199 + ICSSG_PA_STATS(FW_INF_SAV), 200 + ICSSG_PA_STATS(FW_INF_SA_DL), 201 + ICSSG_PA_STATS(FW_INF_PORT_BLOCKED), 202 + ICSSG_PA_STATS(FW_INF_DROP_TAGGED), 203 + ICSSG_PA_STATS(FW_INF_DROP_PRIOTAGGED), 204 + ICSSG_PA_STATS(FW_INF_DROP_NOTAG), 205 + ICSSG_PA_STATS(FW_INF_DROP_NOTMEMBER), 206 + ICSSG_PA_STATS(FW_RX_EOF_SHORT_FRMERR), 207 + ICSSG_PA_STATS(FW_RX_B0_DROP_EARLY_EOF), 208 + ICSSG_PA_STATS(FW_TX_JUMBO_FRM_CUTOFF), 209 + ICSSG_PA_STATS(FW_RX_EXP_FRAG_Q_DROP), 210 + ICSSG_PA_STATS(FW_RX_FIFO_OVERRUN), 211 + ICSSG_PA_STATS(FW_CUT_THR_PKT), 212 + ICSSG_PA_STATS(FW_HOST_RX_PKT_CNT), 213 + ICSSG_PA_STATS(FW_HOST_TX_PKT_CNT), 214 + ICSSG_PA_STATS(FW_HOST_EGRESS_Q_PRE_OVERFLOW), 215 + ICSSG_PA_STATS(FW_HOST_EGRESS_Q_EXP_OVERFLOW), 174 216 }; 175 217 176 218 #endif /* __NET_TI_ICSSG_STATS_H */
+33
drivers/net/ethernet/ti/icssg/icssg_switch_map.h
··· 231 231 /* Start of 32 bits PA_STAT counters */ 232 232 #define PA_STAT_32b_START_OFFSET 0x0080 233 233 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 + 234 267 #endif /* __NET_TI_ICSSG_SWITCH_MAP_H */