18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
28c2ecf20Sopenharmony_ci#ifndef _MLX4_STATS_
38c2ecf20Sopenharmony_ci#define _MLX4_STATS_
48c2ecf20Sopenharmony_ci
58c2ecf20Sopenharmony_ci#ifdef MLX4_EN_PERF_STAT
68c2ecf20Sopenharmony_ci#define NUM_PERF_STATS			NUM_PERF_COUNTERS
78c2ecf20Sopenharmony_ci#else
88c2ecf20Sopenharmony_ci#define NUM_PERF_STATS			0
98c2ecf20Sopenharmony_ci#endif
108c2ecf20Sopenharmony_ci
118c2ecf20Sopenharmony_ci#define NUM_PRIORITIES	9
128c2ecf20Sopenharmony_ci#define NUM_PRIORITY_STATS 2
138c2ecf20Sopenharmony_ci
148c2ecf20Sopenharmony_cistruct mlx4_en_pkt_stats {
158c2ecf20Sopenharmony_ci	unsigned long rx_multicast_packets;
168c2ecf20Sopenharmony_ci	unsigned long rx_broadcast_packets;
178c2ecf20Sopenharmony_ci	unsigned long rx_jabbers;
188c2ecf20Sopenharmony_ci	unsigned long rx_in_range_length_error;
198c2ecf20Sopenharmony_ci	unsigned long rx_out_range_length_error;
208c2ecf20Sopenharmony_ci	unsigned long tx_multicast_packets;
218c2ecf20Sopenharmony_ci	unsigned long tx_broadcast_packets;
228c2ecf20Sopenharmony_ci	unsigned long rx_prio[NUM_PRIORITIES][NUM_PRIORITY_STATS];
238c2ecf20Sopenharmony_ci	unsigned long tx_prio[NUM_PRIORITIES][NUM_PRIORITY_STATS];
248c2ecf20Sopenharmony_ci#define NUM_PKT_STATS		43
258c2ecf20Sopenharmony_ci};
268c2ecf20Sopenharmony_ci
278c2ecf20Sopenharmony_cistruct mlx4_en_counter_stats {
288c2ecf20Sopenharmony_ci	unsigned long rx_packets;
298c2ecf20Sopenharmony_ci	unsigned long rx_bytes;
308c2ecf20Sopenharmony_ci	unsigned long tx_packets;
318c2ecf20Sopenharmony_ci	unsigned long tx_bytes;
328c2ecf20Sopenharmony_ci#define NUM_PF_STATS      4
338c2ecf20Sopenharmony_ci};
348c2ecf20Sopenharmony_ci
358c2ecf20Sopenharmony_cistruct mlx4_en_port_stats {
368c2ecf20Sopenharmony_ci	unsigned long tso_packets;
378c2ecf20Sopenharmony_ci	unsigned long xmit_more;
388c2ecf20Sopenharmony_ci	unsigned long queue_stopped;
398c2ecf20Sopenharmony_ci	unsigned long wake_queue;
408c2ecf20Sopenharmony_ci	unsigned long tx_timeout;
418c2ecf20Sopenharmony_ci	unsigned long rx_alloc_pages;
428c2ecf20Sopenharmony_ci	unsigned long rx_chksum_good;
438c2ecf20Sopenharmony_ci	unsigned long rx_chksum_none;
448c2ecf20Sopenharmony_ci	unsigned long rx_chksum_complete;
458c2ecf20Sopenharmony_ci	unsigned long tx_chksum_offload;
468c2ecf20Sopenharmony_ci#define NUM_PORT_STATS		10
478c2ecf20Sopenharmony_ci};
488c2ecf20Sopenharmony_ci
498c2ecf20Sopenharmony_cistruct mlx4_en_perf_stats {
508c2ecf20Sopenharmony_ci	u32 tx_poll;
518c2ecf20Sopenharmony_ci	u64 tx_pktsz_avg;
528c2ecf20Sopenharmony_ci	u32 inflight_avg;
538c2ecf20Sopenharmony_ci	u16 tx_coal_avg;
548c2ecf20Sopenharmony_ci	u16 rx_coal_avg;
558c2ecf20Sopenharmony_ci	u32 napi_quota;
568c2ecf20Sopenharmony_ci#define NUM_PERF_COUNTERS		6
578c2ecf20Sopenharmony_ci};
588c2ecf20Sopenharmony_ci
598c2ecf20Sopenharmony_cistruct mlx4_en_xdp_stats {
608c2ecf20Sopenharmony_ci	unsigned long rx_xdp_drop;
618c2ecf20Sopenharmony_ci	unsigned long rx_xdp_tx;
628c2ecf20Sopenharmony_ci	unsigned long rx_xdp_tx_full;
638c2ecf20Sopenharmony_ci#define NUM_XDP_STATS		3
648c2ecf20Sopenharmony_ci};
658c2ecf20Sopenharmony_ci
668c2ecf20Sopenharmony_cistruct mlx4_en_phy_stats {
678c2ecf20Sopenharmony_ci	unsigned long rx_packets_phy;
688c2ecf20Sopenharmony_ci	unsigned long rx_bytes_phy;
698c2ecf20Sopenharmony_ci	unsigned long tx_packets_phy;
708c2ecf20Sopenharmony_ci	unsigned long tx_bytes_phy;
718c2ecf20Sopenharmony_ci#define NUM_PHY_STATS		4
728c2ecf20Sopenharmony_ci};
738c2ecf20Sopenharmony_ci
748c2ecf20Sopenharmony_ci#define NUM_MAIN_STATS	21
758c2ecf20Sopenharmony_ci
768c2ecf20Sopenharmony_ci#define MLX4_NUM_PRIORITIES	8
778c2ecf20Sopenharmony_ci
788c2ecf20Sopenharmony_cistruct mlx4_en_flow_stats_rx {
798c2ecf20Sopenharmony_ci	u64 rx_pause;
808c2ecf20Sopenharmony_ci	u64 rx_pause_duration;
818c2ecf20Sopenharmony_ci	u64 rx_pause_transition;
828c2ecf20Sopenharmony_ci#define NUM_FLOW_STATS_RX	3
838c2ecf20Sopenharmony_ci#define NUM_FLOW_PRIORITY_STATS_RX	(NUM_FLOW_STATS_RX * \
848c2ecf20Sopenharmony_ci					 MLX4_NUM_PRIORITIES)
858c2ecf20Sopenharmony_ci};
868c2ecf20Sopenharmony_ci
878c2ecf20Sopenharmony_ci#define FLOW_PRIORITY_STATS_IDX_RX_FRAMES	(NUM_MAIN_STATS +	\
888c2ecf20Sopenharmony_ci						 NUM_PORT_STATS +	\
898c2ecf20Sopenharmony_ci						 NUM_PF_STATS +		\
908c2ecf20Sopenharmony_ci						 NUM_FLOW_PRIORITY_STATS_RX)
918c2ecf20Sopenharmony_ci
928c2ecf20Sopenharmony_cistruct mlx4_en_flow_stats_tx {
938c2ecf20Sopenharmony_ci	u64 tx_pause;
948c2ecf20Sopenharmony_ci	u64 tx_pause_duration;
958c2ecf20Sopenharmony_ci	u64 tx_pause_transition;
968c2ecf20Sopenharmony_ci#define NUM_FLOW_STATS_TX	3
978c2ecf20Sopenharmony_ci#define NUM_FLOW_PRIORITY_STATS_TX	(NUM_FLOW_STATS_TX * \
988c2ecf20Sopenharmony_ci					 MLX4_NUM_PRIORITIES)
998c2ecf20Sopenharmony_ci};
1008c2ecf20Sopenharmony_ci
1018c2ecf20Sopenharmony_ci#define FLOW_PRIORITY_STATS_IDX_TX_FRAMES	(NUM_MAIN_STATS +	\
1028c2ecf20Sopenharmony_ci						 NUM_PORT_STATS +	\
1038c2ecf20Sopenharmony_ci						 NUM_PF_STATS +		\
1048c2ecf20Sopenharmony_ci						 NUM_FLOW_PRIORITY_STATS_RX + \
1058c2ecf20Sopenharmony_ci						 NUM_FLOW_STATS_RX +	\
1068c2ecf20Sopenharmony_ci						 NUM_FLOW_PRIORITY_STATS_TX)
1078c2ecf20Sopenharmony_ci
1088c2ecf20Sopenharmony_ci#define NUM_FLOW_STATS (NUM_FLOW_STATS_RX + NUM_FLOW_STATS_TX + \
1098c2ecf20Sopenharmony_ci			NUM_FLOW_PRIORITY_STATS_TX + \
1108c2ecf20Sopenharmony_ci			NUM_FLOW_PRIORITY_STATS_RX)
1118c2ecf20Sopenharmony_ci
1128c2ecf20Sopenharmony_cistruct mlx4_en_stat_out_flow_control_mbox {
1138c2ecf20Sopenharmony_ci	/* Total number of PAUSE frames received from the far-end port */
1148c2ecf20Sopenharmony_ci	__be64 rx_pause;
1158c2ecf20Sopenharmony_ci	/* Total number of microseconds that far-end port requested to pause
1168c2ecf20Sopenharmony_ci	* transmission of packets
1178c2ecf20Sopenharmony_ci	*/
1188c2ecf20Sopenharmony_ci	__be64 rx_pause_duration;
1198c2ecf20Sopenharmony_ci	/* Number of received transmission from XOFF state to XON state */
1208c2ecf20Sopenharmony_ci	__be64 rx_pause_transition;
1218c2ecf20Sopenharmony_ci	/* Total number of PAUSE frames sent from the far-end port */
1228c2ecf20Sopenharmony_ci	__be64 tx_pause;
1238c2ecf20Sopenharmony_ci	/* Total time in microseconds that transmission of packets has been
1248c2ecf20Sopenharmony_ci	* paused
1258c2ecf20Sopenharmony_ci	*/
1268c2ecf20Sopenharmony_ci	__be64 tx_pause_duration;
1278c2ecf20Sopenharmony_ci	/* Number of transmitter transitions from XOFF state to XON state */
1288c2ecf20Sopenharmony_ci	__be64 tx_pause_transition;
1298c2ecf20Sopenharmony_ci	/* Reserverd */
1308c2ecf20Sopenharmony_ci	__be64 reserved[2];
1318c2ecf20Sopenharmony_ci};
1328c2ecf20Sopenharmony_ci
1338c2ecf20Sopenharmony_cienum {
1348c2ecf20Sopenharmony_ci	MLX4_DUMP_ETH_STATS_FLOW_CONTROL = 1 << 12
1358c2ecf20Sopenharmony_ci};
1368c2ecf20Sopenharmony_ci
1378c2ecf20Sopenharmony_ci#define NUM_ALL_STATS	(NUM_MAIN_STATS + NUM_PORT_STATS + NUM_PKT_STATS + \
1388c2ecf20Sopenharmony_ci			 NUM_FLOW_STATS + NUM_PERF_STATS + NUM_PF_STATS + \
1398c2ecf20Sopenharmony_ci			 NUM_XDP_STATS + NUM_PHY_STATS)
1408c2ecf20Sopenharmony_ci
1418c2ecf20Sopenharmony_ci#define MLX4_FIND_NETDEV_STAT(n) (offsetof(struct net_device_stats, n) / \
1428c2ecf20Sopenharmony_ci				  sizeof(((struct net_device_stats *)0)->n))
1438c2ecf20Sopenharmony_ci
1448c2ecf20Sopenharmony_ci#endif
145