162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 262306a36Sopenharmony_ci#ifndef _MLX4_STATS_ 362306a36Sopenharmony_ci#define _MLX4_STATS_ 462306a36Sopenharmony_ci 562306a36Sopenharmony_ci#define NUM_PRIORITIES 9 662306a36Sopenharmony_ci#define NUM_PRIORITY_STATS 2 762306a36Sopenharmony_ci 862306a36Sopenharmony_cistruct mlx4_en_pkt_stats { 962306a36Sopenharmony_ci unsigned long rx_multicast_packets; 1062306a36Sopenharmony_ci unsigned long rx_broadcast_packets; 1162306a36Sopenharmony_ci unsigned long rx_jabbers; 1262306a36Sopenharmony_ci unsigned long rx_in_range_length_error; 1362306a36Sopenharmony_ci unsigned long rx_out_range_length_error; 1462306a36Sopenharmony_ci unsigned long tx_multicast_packets; 1562306a36Sopenharmony_ci unsigned long tx_broadcast_packets; 1662306a36Sopenharmony_ci unsigned long rx_prio[NUM_PRIORITIES][NUM_PRIORITY_STATS]; 1762306a36Sopenharmony_ci unsigned long tx_prio[NUM_PRIORITIES][NUM_PRIORITY_STATS]; 1862306a36Sopenharmony_ci#define NUM_PKT_STATS 43 1962306a36Sopenharmony_ci}; 2062306a36Sopenharmony_ci 2162306a36Sopenharmony_cistruct mlx4_en_counter_stats { 2262306a36Sopenharmony_ci unsigned long rx_packets; 2362306a36Sopenharmony_ci unsigned long rx_bytes; 2462306a36Sopenharmony_ci unsigned long tx_packets; 2562306a36Sopenharmony_ci unsigned long tx_bytes; 2662306a36Sopenharmony_ci#define NUM_PF_STATS 4 2762306a36Sopenharmony_ci}; 2862306a36Sopenharmony_ci 2962306a36Sopenharmony_cistruct mlx4_en_port_stats { 3062306a36Sopenharmony_ci unsigned long tso_packets; 3162306a36Sopenharmony_ci unsigned long xmit_more; 3262306a36Sopenharmony_ci unsigned long queue_stopped; 3362306a36Sopenharmony_ci unsigned long wake_queue; 3462306a36Sopenharmony_ci unsigned long tx_timeout; 3562306a36Sopenharmony_ci unsigned long rx_alloc_pages; 3662306a36Sopenharmony_ci unsigned long rx_chksum_good; 3762306a36Sopenharmony_ci unsigned long rx_chksum_none; 3862306a36Sopenharmony_ci unsigned long rx_chksum_complete; 3962306a36Sopenharmony_ci unsigned long tx_chksum_offload; 4062306a36Sopenharmony_ci#define NUM_PORT_STATS 10 4162306a36Sopenharmony_ci}; 4262306a36Sopenharmony_ci 4362306a36Sopenharmony_cistruct mlx4_en_xdp_stats { 4462306a36Sopenharmony_ci unsigned long rx_xdp_drop; 4562306a36Sopenharmony_ci unsigned long rx_xdp_redirect; 4662306a36Sopenharmony_ci unsigned long rx_xdp_redirect_fail; 4762306a36Sopenharmony_ci unsigned long rx_xdp_tx; 4862306a36Sopenharmony_ci unsigned long rx_xdp_tx_full; 4962306a36Sopenharmony_ci#define NUM_XDP_STATS 5 5062306a36Sopenharmony_ci}; 5162306a36Sopenharmony_ci 5262306a36Sopenharmony_cistruct mlx4_en_phy_stats { 5362306a36Sopenharmony_ci unsigned long rx_packets_phy; 5462306a36Sopenharmony_ci unsigned long rx_bytes_phy; 5562306a36Sopenharmony_ci unsigned long tx_packets_phy; 5662306a36Sopenharmony_ci unsigned long tx_bytes_phy; 5762306a36Sopenharmony_ci#define NUM_PHY_STATS 4 5862306a36Sopenharmony_ci}; 5962306a36Sopenharmony_ci 6062306a36Sopenharmony_ci#define NUM_MAIN_STATS 21 6162306a36Sopenharmony_ci 6262306a36Sopenharmony_ci#define MLX4_NUM_PRIORITIES 8 6362306a36Sopenharmony_ci 6462306a36Sopenharmony_cistruct mlx4_en_flow_stats_rx { 6562306a36Sopenharmony_ci u64 rx_pause; 6662306a36Sopenharmony_ci u64 rx_pause_duration; 6762306a36Sopenharmony_ci u64 rx_pause_transition; 6862306a36Sopenharmony_ci#define NUM_FLOW_STATS_RX 3 6962306a36Sopenharmony_ci#define NUM_FLOW_PRIORITY_STATS_RX (NUM_FLOW_STATS_RX * \ 7062306a36Sopenharmony_ci MLX4_NUM_PRIORITIES) 7162306a36Sopenharmony_ci}; 7262306a36Sopenharmony_ci 7362306a36Sopenharmony_ci#define FLOW_PRIORITY_STATS_IDX_RX_FRAMES (NUM_MAIN_STATS + \ 7462306a36Sopenharmony_ci NUM_PORT_STATS + \ 7562306a36Sopenharmony_ci NUM_PF_STATS + \ 7662306a36Sopenharmony_ci NUM_FLOW_PRIORITY_STATS_RX) 7762306a36Sopenharmony_ci 7862306a36Sopenharmony_cistruct mlx4_en_flow_stats_tx { 7962306a36Sopenharmony_ci u64 tx_pause; 8062306a36Sopenharmony_ci u64 tx_pause_duration; 8162306a36Sopenharmony_ci u64 tx_pause_transition; 8262306a36Sopenharmony_ci#define NUM_FLOW_STATS_TX 3 8362306a36Sopenharmony_ci#define NUM_FLOW_PRIORITY_STATS_TX (NUM_FLOW_STATS_TX * \ 8462306a36Sopenharmony_ci MLX4_NUM_PRIORITIES) 8562306a36Sopenharmony_ci}; 8662306a36Sopenharmony_ci 8762306a36Sopenharmony_ci#define FLOW_PRIORITY_STATS_IDX_TX_FRAMES (NUM_MAIN_STATS + \ 8862306a36Sopenharmony_ci NUM_PORT_STATS + \ 8962306a36Sopenharmony_ci NUM_PF_STATS + \ 9062306a36Sopenharmony_ci NUM_FLOW_PRIORITY_STATS_RX + \ 9162306a36Sopenharmony_ci NUM_FLOW_STATS_RX + \ 9262306a36Sopenharmony_ci NUM_FLOW_PRIORITY_STATS_TX) 9362306a36Sopenharmony_ci 9462306a36Sopenharmony_ci#define NUM_FLOW_STATS (NUM_FLOW_STATS_RX + NUM_FLOW_STATS_TX + \ 9562306a36Sopenharmony_ci NUM_FLOW_PRIORITY_STATS_TX + \ 9662306a36Sopenharmony_ci NUM_FLOW_PRIORITY_STATS_RX) 9762306a36Sopenharmony_ci 9862306a36Sopenharmony_cistruct mlx4_en_stat_out_flow_control_mbox { 9962306a36Sopenharmony_ci /* Total number of PAUSE frames received from the far-end port */ 10062306a36Sopenharmony_ci __be64 rx_pause; 10162306a36Sopenharmony_ci /* Total number of microseconds that far-end port requested to pause 10262306a36Sopenharmony_ci * transmission of packets 10362306a36Sopenharmony_ci */ 10462306a36Sopenharmony_ci __be64 rx_pause_duration; 10562306a36Sopenharmony_ci /* Number of received transmission from XOFF state to XON state */ 10662306a36Sopenharmony_ci __be64 rx_pause_transition; 10762306a36Sopenharmony_ci /* Total number of PAUSE frames sent from the far-end port */ 10862306a36Sopenharmony_ci __be64 tx_pause; 10962306a36Sopenharmony_ci /* Total time in microseconds that transmission of packets has been 11062306a36Sopenharmony_ci * paused 11162306a36Sopenharmony_ci */ 11262306a36Sopenharmony_ci __be64 tx_pause_duration; 11362306a36Sopenharmony_ci /* Number of transmitter transitions from XOFF state to XON state */ 11462306a36Sopenharmony_ci __be64 tx_pause_transition; 11562306a36Sopenharmony_ci /* Reserverd */ 11662306a36Sopenharmony_ci __be64 reserved[2]; 11762306a36Sopenharmony_ci}; 11862306a36Sopenharmony_ci 11962306a36Sopenharmony_cienum { 12062306a36Sopenharmony_ci MLX4_DUMP_ETH_STATS_FLOW_CONTROL = 1 << 12 12162306a36Sopenharmony_ci}; 12262306a36Sopenharmony_ci 12362306a36Sopenharmony_ci#define NUM_ALL_STATS (NUM_MAIN_STATS + NUM_PORT_STATS + NUM_PKT_STATS + \ 12462306a36Sopenharmony_ci NUM_FLOW_STATS + NUM_PF_STATS + \ 12562306a36Sopenharmony_ci NUM_XDP_STATS + NUM_PHY_STATS) 12662306a36Sopenharmony_ci 12762306a36Sopenharmony_ci#define MLX4_FIND_NETDEV_STAT(n) (offsetof(struct net_device_stats, n) / \ 12862306a36Sopenharmony_ci sizeof(((struct net_device_stats *)0)->n)) 12962306a36Sopenharmony_ci 13062306a36Sopenharmony_ci#endif 131