162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
262306a36Sopenharmony_ci/* Texas Instruments ICSSG Ethernet driver
362306a36Sopenharmony_ci *
462306a36Sopenharmony_ci * Copyright (C) 2018-2022 Texas Instruments Incorporated - https://www.ti.com/
562306a36Sopenharmony_ci *
662306a36Sopenharmony_ci */
762306a36Sopenharmony_ci
862306a36Sopenharmony_ci#ifndef __NET_TI_ICSSG_STATS_H
962306a36Sopenharmony_ci#define __NET_TI_ICSSG_STATS_H
1062306a36Sopenharmony_ci
1162306a36Sopenharmony_ci#include "icssg_prueth.h"
1262306a36Sopenharmony_ci
1362306a36Sopenharmony_ci#define STATS_TIME_LIMIT_1G_MS    25000    /* 25 seconds @ 1G */
1462306a36Sopenharmony_ci
1562306a36Sopenharmony_cistruct miig_stats_regs {
1662306a36Sopenharmony_ci	/* Rx */
1762306a36Sopenharmony_ci	u32 rx_packets;
1862306a36Sopenharmony_ci	u32 rx_broadcast_frames;
1962306a36Sopenharmony_ci	u32 rx_multicast_frames;
2062306a36Sopenharmony_ci	u32 rx_crc_errors;
2162306a36Sopenharmony_ci	u32 rx_mii_error_frames;
2262306a36Sopenharmony_ci	u32 rx_odd_nibble_frames;
2362306a36Sopenharmony_ci	u32 rx_frame_max_size;
2462306a36Sopenharmony_ci	u32 rx_max_size_error_frames;
2562306a36Sopenharmony_ci	u32 rx_frame_min_size;
2662306a36Sopenharmony_ci	u32 rx_min_size_error_frames;
2762306a36Sopenharmony_ci	u32 rx_over_errors;
2862306a36Sopenharmony_ci	u32 rx_class0_hits;
2962306a36Sopenharmony_ci	u32 rx_class1_hits;
3062306a36Sopenharmony_ci	u32 rx_class2_hits;
3162306a36Sopenharmony_ci	u32 rx_class3_hits;
3262306a36Sopenharmony_ci	u32 rx_class4_hits;
3362306a36Sopenharmony_ci	u32 rx_class5_hits;
3462306a36Sopenharmony_ci	u32 rx_class6_hits;
3562306a36Sopenharmony_ci	u32 rx_class7_hits;
3662306a36Sopenharmony_ci	u32 rx_class8_hits;
3762306a36Sopenharmony_ci	u32 rx_class9_hits;
3862306a36Sopenharmony_ci	u32 rx_class10_hits;
3962306a36Sopenharmony_ci	u32 rx_class11_hits;
4062306a36Sopenharmony_ci	u32 rx_class12_hits;
4162306a36Sopenharmony_ci	u32 rx_class13_hits;
4262306a36Sopenharmony_ci	u32 rx_class14_hits;
4362306a36Sopenharmony_ci	u32 rx_class15_hits;
4462306a36Sopenharmony_ci	u32 rx_smd_frags;
4562306a36Sopenharmony_ci	u32 rx_bucket1_size;
4662306a36Sopenharmony_ci	u32 rx_bucket2_size;
4762306a36Sopenharmony_ci	u32 rx_bucket3_size;
4862306a36Sopenharmony_ci	u32 rx_bucket4_size;
4962306a36Sopenharmony_ci	u32 rx_64B_frames;
5062306a36Sopenharmony_ci	u32 rx_bucket1_frames;
5162306a36Sopenharmony_ci	u32 rx_bucket2_frames;
5262306a36Sopenharmony_ci	u32 rx_bucket3_frames;
5362306a36Sopenharmony_ci	u32 rx_bucket4_frames;
5462306a36Sopenharmony_ci	u32 rx_bucket5_frames;
5562306a36Sopenharmony_ci	u32 rx_bytes;
5662306a36Sopenharmony_ci	u32 rx_tx_total_bytes;
5762306a36Sopenharmony_ci	/* Tx */
5862306a36Sopenharmony_ci	u32 tx_packets;
5962306a36Sopenharmony_ci	u32 tx_broadcast_frames;
6062306a36Sopenharmony_ci	u32 tx_multicast_frames;
6162306a36Sopenharmony_ci	u32 tx_odd_nibble_frames;
6262306a36Sopenharmony_ci	u32 tx_underflow_errors;
6362306a36Sopenharmony_ci	u32 tx_frame_max_size;
6462306a36Sopenharmony_ci	u32 tx_max_size_error_frames;
6562306a36Sopenharmony_ci	u32 tx_frame_min_size;
6662306a36Sopenharmony_ci	u32 tx_min_size_error_frames;
6762306a36Sopenharmony_ci	u32 tx_bucket1_size;
6862306a36Sopenharmony_ci	u32 tx_bucket2_size;
6962306a36Sopenharmony_ci	u32 tx_bucket3_size;
7062306a36Sopenharmony_ci	u32 tx_bucket4_size;
7162306a36Sopenharmony_ci	u32 tx_64B_frames;
7262306a36Sopenharmony_ci	u32 tx_bucket1_frames;
7362306a36Sopenharmony_ci	u32 tx_bucket2_frames;
7462306a36Sopenharmony_ci	u32 tx_bucket3_frames;
7562306a36Sopenharmony_ci	u32 tx_bucket4_frames;
7662306a36Sopenharmony_ci	u32 tx_bucket5_frames;
7762306a36Sopenharmony_ci	u32 tx_bytes;
7862306a36Sopenharmony_ci};
7962306a36Sopenharmony_ci
8062306a36Sopenharmony_ci#define ICSSG_STATS(field, stats_type)			\
8162306a36Sopenharmony_ci{							\
8262306a36Sopenharmony_ci	#field,						\
8362306a36Sopenharmony_ci	offsetof(struct miig_stats_regs, field),	\
8462306a36Sopenharmony_ci	stats_type					\
8562306a36Sopenharmony_ci}
8662306a36Sopenharmony_ci
8762306a36Sopenharmony_cistruct icssg_stats {
8862306a36Sopenharmony_ci	char name[ETH_GSTRING_LEN];
8962306a36Sopenharmony_ci	u32 offset;
9062306a36Sopenharmony_ci	bool standard_stats;
9162306a36Sopenharmony_ci};
9262306a36Sopenharmony_ci
9362306a36Sopenharmony_cistatic const struct icssg_stats icssg_all_stats[] = {
9462306a36Sopenharmony_ci	/* Rx */
9562306a36Sopenharmony_ci	ICSSG_STATS(rx_packets, true),
9662306a36Sopenharmony_ci	ICSSG_STATS(rx_broadcast_frames, false),
9762306a36Sopenharmony_ci	ICSSG_STATS(rx_multicast_frames, true),
9862306a36Sopenharmony_ci	ICSSG_STATS(rx_crc_errors, true),
9962306a36Sopenharmony_ci	ICSSG_STATS(rx_mii_error_frames, false),
10062306a36Sopenharmony_ci	ICSSG_STATS(rx_odd_nibble_frames, false),
10162306a36Sopenharmony_ci	ICSSG_STATS(rx_frame_max_size, true),
10262306a36Sopenharmony_ci	ICSSG_STATS(rx_max_size_error_frames, false),
10362306a36Sopenharmony_ci	ICSSG_STATS(rx_frame_min_size, true),
10462306a36Sopenharmony_ci	ICSSG_STATS(rx_min_size_error_frames, false),
10562306a36Sopenharmony_ci	ICSSG_STATS(rx_over_errors, true),
10662306a36Sopenharmony_ci	ICSSG_STATS(rx_class0_hits, false),
10762306a36Sopenharmony_ci	ICSSG_STATS(rx_class1_hits, false),
10862306a36Sopenharmony_ci	ICSSG_STATS(rx_class2_hits, false),
10962306a36Sopenharmony_ci	ICSSG_STATS(rx_class3_hits, false),
11062306a36Sopenharmony_ci	ICSSG_STATS(rx_class4_hits, false),
11162306a36Sopenharmony_ci	ICSSG_STATS(rx_class5_hits, false),
11262306a36Sopenharmony_ci	ICSSG_STATS(rx_class6_hits, false),
11362306a36Sopenharmony_ci	ICSSG_STATS(rx_class7_hits, false),
11462306a36Sopenharmony_ci	ICSSG_STATS(rx_class8_hits, false),
11562306a36Sopenharmony_ci	ICSSG_STATS(rx_class9_hits, false),
11662306a36Sopenharmony_ci	ICSSG_STATS(rx_class10_hits, false),
11762306a36Sopenharmony_ci	ICSSG_STATS(rx_class11_hits, false),
11862306a36Sopenharmony_ci	ICSSG_STATS(rx_class12_hits, false),
11962306a36Sopenharmony_ci	ICSSG_STATS(rx_class13_hits, false),
12062306a36Sopenharmony_ci	ICSSG_STATS(rx_class14_hits, false),
12162306a36Sopenharmony_ci	ICSSG_STATS(rx_class15_hits, false),
12262306a36Sopenharmony_ci	ICSSG_STATS(rx_smd_frags, false),
12362306a36Sopenharmony_ci	ICSSG_STATS(rx_bucket1_size, true),
12462306a36Sopenharmony_ci	ICSSG_STATS(rx_bucket2_size, true),
12562306a36Sopenharmony_ci	ICSSG_STATS(rx_bucket3_size, true),
12662306a36Sopenharmony_ci	ICSSG_STATS(rx_bucket4_size, true),
12762306a36Sopenharmony_ci	ICSSG_STATS(rx_64B_frames, true),
12862306a36Sopenharmony_ci	ICSSG_STATS(rx_bucket1_frames, true),
12962306a36Sopenharmony_ci	ICSSG_STATS(rx_bucket2_frames, true),
13062306a36Sopenharmony_ci	ICSSG_STATS(rx_bucket3_frames, true),
13162306a36Sopenharmony_ci	ICSSG_STATS(rx_bucket4_frames, true),
13262306a36Sopenharmony_ci	ICSSG_STATS(rx_bucket5_frames, true),
13362306a36Sopenharmony_ci	ICSSG_STATS(rx_bytes, true),
13462306a36Sopenharmony_ci	ICSSG_STATS(rx_tx_total_bytes, false),
13562306a36Sopenharmony_ci	/* Tx */
13662306a36Sopenharmony_ci	ICSSG_STATS(tx_packets, true),
13762306a36Sopenharmony_ci	ICSSG_STATS(tx_broadcast_frames, false),
13862306a36Sopenharmony_ci	ICSSG_STATS(tx_multicast_frames, false),
13962306a36Sopenharmony_ci	ICSSG_STATS(tx_odd_nibble_frames, false),
14062306a36Sopenharmony_ci	ICSSG_STATS(tx_underflow_errors, false),
14162306a36Sopenharmony_ci	ICSSG_STATS(tx_frame_max_size, true),
14262306a36Sopenharmony_ci	ICSSG_STATS(tx_max_size_error_frames, false),
14362306a36Sopenharmony_ci	ICSSG_STATS(tx_frame_min_size, true),
14462306a36Sopenharmony_ci	ICSSG_STATS(tx_min_size_error_frames, false),
14562306a36Sopenharmony_ci	ICSSG_STATS(tx_bucket1_size, true),
14662306a36Sopenharmony_ci	ICSSG_STATS(tx_bucket2_size, true),
14762306a36Sopenharmony_ci	ICSSG_STATS(tx_bucket3_size, true),
14862306a36Sopenharmony_ci	ICSSG_STATS(tx_bucket4_size, true),
14962306a36Sopenharmony_ci	ICSSG_STATS(tx_64B_frames, true),
15062306a36Sopenharmony_ci	ICSSG_STATS(tx_bucket1_frames, true),
15162306a36Sopenharmony_ci	ICSSG_STATS(tx_bucket2_frames, true),
15262306a36Sopenharmony_ci	ICSSG_STATS(tx_bucket3_frames, true),
15362306a36Sopenharmony_ci	ICSSG_STATS(tx_bucket4_frames, true),
15462306a36Sopenharmony_ci	ICSSG_STATS(tx_bucket5_frames, true),
15562306a36Sopenharmony_ci	ICSSG_STATS(tx_bytes, true),
15662306a36Sopenharmony_ci};
15762306a36Sopenharmony_ci
15862306a36Sopenharmony_ci#endif /* __NET_TI_ICSSG_STATS_H */
159