19218b44dSGal Pressman /*
29218b44dSGal Pressman  * Copyright (c) 2015-2016, Mellanox Technologies. All rights reserved.
39218b44dSGal Pressman  *
49218b44dSGal Pressman  * This software is available to you under a choice of one of two
59218b44dSGal Pressman  * licenses.  You may choose to be licensed under the terms of the GNU
69218b44dSGal Pressman  * General Public License (GPL) Version 2, available from the file
79218b44dSGal Pressman  * COPYING in the main directory of this source tree, or the
89218b44dSGal Pressman  * OpenIB.org BSD license below:
99218b44dSGal Pressman  *
109218b44dSGal Pressman  *     Redistribution and use in source and binary forms, with or
119218b44dSGal Pressman  *     without modification, are permitted provided that the following
129218b44dSGal Pressman  *     conditions are met:
139218b44dSGal Pressman  *
149218b44dSGal Pressman  *      - Redistributions of source code must retain the above
159218b44dSGal Pressman  *        copyright notice, this list of conditions and the following
169218b44dSGal Pressman  *        disclaimer.
179218b44dSGal Pressman  *
189218b44dSGal Pressman  *      - Redistributions in binary form must reproduce the above
199218b44dSGal Pressman  *        copyright notice, this list of conditions and the following
209218b44dSGal Pressman  *        disclaimer in the documentation and/or other materials
219218b44dSGal Pressman  *        provided with the distribution.
229218b44dSGal Pressman  *
239218b44dSGal Pressman  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
249218b44dSGal Pressman  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
259218b44dSGal Pressman  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
269218b44dSGal Pressman  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
279218b44dSGal Pressman  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
289218b44dSGal Pressman  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
299218b44dSGal Pressman  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
309218b44dSGal Pressman  * SOFTWARE.
319218b44dSGal Pressman  */
329218b44dSGal Pressman #ifndef __MLX5_EN_STATS_H__
339218b44dSGal Pressman #define __MLX5_EN_STATS_H__
349218b44dSGal Pressman 
359218b44dSGal Pressman #define MLX5E_READ_CTR64_CPU(ptr, dsc, i) \
369218b44dSGal Pressman 	(*(u64 *)((char *)ptr + dsc[i].offset))
379218b44dSGal Pressman #define MLX5E_READ_CTR64_BE(ptr, dsc, i) \
389218b44dSGal Pressman 	be64_to_cpu(*(__be64 *)((char *)ptr + dsc[i].offset))
399218b44dSGal Pressman #define MLX5E_READ_CTR32_CPU(ptr, dsc, i) \
409218b44dSGal Pressman 	(*(u32 *)((char *)ptr + dsc[i].offset))
419218b44dSGal Pressman #define MLX5E_READ_CTR32_BE(ptr, dsc, i) \
429218b44dSGal Pressman 	be64_to_cpu(*(__be32 *)((char *)ptr + dsc[i].offset))
439218b44dSGal Pressman 
449218b44dSGal Pressman #define MLX5E_DECLARE_STAT(type, fld) #fld, offsetof(type, fld)
459218b44dSGal Pressman 
469218b44dSGal Pressman struct counter_desc {
479218b44dSGal Pressman 	char		name[ETH_GSTRING_LEN];
489218b44dSGal Pressman 	int		offset; /* Byte offset */
499218b44dSGal Pressman };
509218b44dSGal Pressman 
519218b44dSGal Pressman struct mlx5e_sw_stats {
529218b44dSGal Pressman 	u64 rx_packets;
539218b44dSGal Pressman 	u64 rx_bytes;
549218b44dSGal Pressman 	u64 tx_packets;
559218b44dSGal Pressman 	u64 tx_bytes;
569218b44dSGal Pressman 	u64 tso_packets;
579218b44dSGal Pressman 	u64 tso_bytes;
589218b44dSGal Pressman 	u64 tso_inner_packets;
599218b44dSGal Pressman 	u64 tso_inner_bytes;
609218b44dSGal Pressman 	u64 lro_packets;
619218b44dSGal Pressman 	u64 lro_bytes;
629218b44dSGal Pressman 	u64 rx_csum_good;
639218b44dSGal Pressman 	u64 rx_csum_none;
649218b44dSGal Pressman 	u64 rx_csum_sw;
651b223dd3SSaeed Mahameed 	u64 rx_csum_inner;
669218b44dSGal Pressman 	u64 tx_csum_offload;
679218b44dSGal Pressman 	u64 tx_csum_inner;
689218b44dSGal Pressman 	u64 tx_queue_stopped;
699218b44dSGal Pressman 	u64 tx_queue_wake;
709218b44dSGal Pressman 	u64 tx_queue_dropped;
719218b44dSGal Pressman 	u64 rx_wqe_err;
729218b44dSGal Pressman 	u64 rx_mpwqe_filler;
739218b44dSGal Pressman 	u64 rx_mpwqe_frag;
749218b44dSGal Pressman 	u64 rx_buff_alloc_err;
75121fcdc8SGal Pressman 
76121fcdc8SGal Pressman 	/* Special handling counters */
77121fcdc8SGal Pressman 	u64 link_down_events;
789218b44dSGal Pressman };
799218b44dSGal Pressman 
809218b44dSGal Pressman static const struct counter_desc sw_stats_desc[] = {
819218b44dSGal Pressman 	{ MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_packets) },
829218b44dSGal Pressman 	{ MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_bytes) },
839218b44dSGal Pressman 	{ MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, tx_packets) },
849218b44dSGal Pressman 	{ MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, tx_bytes) },
859218b44dSGal Pressman 	{ MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, tso_packets) },
869218b44dSGal Pressman 	{ MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, tso_bytes) },
879218b44dSGal Pressman 	{ MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, tso_inner_packets) },
889218b44dSGal Pressman 	{ MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, tso_inner_bytes) },
899218b44dSGal Pressman 	{ MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, lro_packets) },
909218b44dSGal Pressman 	{ MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, lro_bytes) },
919218b44dSGal Pressman 	{ MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_csum_good) },
929218b44dSGal Pressman 	{ MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_csum_none) },
939218b44dSGal Pressman 	{ MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_csum_sw) },
941b223dd3SSaeed Mahameed 	{ MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_csum_inner) },
959218b44dSGal Pressman 	{ MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, tx_csum_offload) },
969218b44dSGal Pressman 	{ MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, tx_csum_inner) },
979218b44dSGal Pressman 	{ MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, tx_queue_stopped) },
989218b44dSGal Pressman 	{ MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, tx_queue_wake) },
999218b44dSGal Pressman 	{ MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, tx_queue_dropped) },
1009218b44dSGal Pressman 	{ MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_wqe_err) },
1019218b44dSGal Pressman 	{ MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_mpwqe_filler) },
1029218b44dSGal Pressman 	{ MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_mpwqe_frag) },
1039218b44dSGal Pressman 	{ MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_buff_alloc_err) },
104121fcdc8SGal Pressman 	{ MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, link_down_events) },
1059218b44dSGal Pressman };
1069218b44dSGal Pressman 
1079218b44dSGal Pressman struct mlx5e_qcounter_stats {
1089218b44dSGal Pressman 	u32 rx_out_of_buffer;
1099218b44dSGal Pressman };
1109218b44dSGal Pressman 
1119218b44dSGal Pressman static const struct counter_desc q_stats_desc[] = {
1129218b44dSGal Pressman 	{ MLX5E_DECLARE_STAT(struct mlx5e_qcounter_stats, rx_out_of_buffer) },
1139218b44dSGal Pressman };
1149218b44dSGal Pressman 
1159218b44dSGal Pressman #define VPORT_COUNTER_OFF(c) MLX5_BYTE_OFF(query_vport_counter_out, c)
1169218b44dSGal Pressman #define VPORT_COUNTER_GET(vstats, c) MLX5_GET64(query_vport_counter_out, \
1179218b44dSGal Pressman 						vstats->query_vport_out, c)
1189218b44dSGal Pressman 
1199218b44dSGal Pressman struct mlx5e_vport_stats {
1209218b44dSGal Pressman 	__be64 query_vport_out[MLX5_ST_SZ_QW(query_vport_counter_out)];
1219218b44dSGal Pressman };
1229218b44dSGal Pressman 
1239218b44dSGal Pressman static const struct counter_desc vport_stats_desc[] = {
1248075cb72SGal Pressman 	{ "rx_vport_error_packets",
1258075cb72SGal Pressman 		VPORT_COUNTER_OFF(received_errors.packets) },
1268075cb72SGal Pressman 	{ "rx_vport_error_bytes", VPORT_COUNTER_OFF(received_errors.octets) },
1278075cb72SGal Pressman 	{ "tx_vport_error_packets",
1288075cb72SGal Pressman 		VPORT_COUNTER_OFF(transmit_errors.packets) },
1298075cb72SGal Pressman 	{ "tx_vport_error_bytes", VPORT_COUNTER_OFF(transmit_errors.octets) },
1308075cb72SGal Pressman 	{ "rx_vport_unicast_packets",
1319218b44dSGal Pressman 		VPORT_COUNTER_OFF(received_eth_unicast.packets) },
1328075cb72SGal Pressman 	{ "rx_vport_unicast_bytes",
1338075cb72SGal Pressman 		VPORT_COUNTER_OFF(received_eth_unicast.octets) },
1348075cb72SGal Pressman 	{ "tx_vport_unicast_packets",
1359218b44dSGal Pressman 		VPORT_COUNTER_OFF(transmitted_eth_unicast.packets) },
1368075cb72SGal Pressman 	{ "tx_vport_unicast_bytes",
1379218b44dSGal Pressman 		VPORT_COUNTER_OFF(transmitted_eth_unicast.octets) },
1388075cb72SGal Pressman 	{ "rx_vport_multicast_packets",
1399218b44dSGal Pressman 		VPORT_COUNTER_OFF(received_eth_multicast.packets) },
1408075cb72SGal Pressman 	{ "rx_vport_multicast_bytes",
1419218b44dSGal Pressman 		VPORT_COUNTER_OFF(received_eth_multicast.octets) },
1428075cb72SGal Pressman 	{ "tx_vport_multicast_packets",
1439218b44dSGal Pressman 		VPORT_COUNTER_OFF(transmitted_eth_multicast.packets) },
1448075cb72SGal Pressman 	{ "tx_vport_multicast_bytes",
1459218b44dSGal Pressman 		VPORT_COUNTER_OFF(transmitted_eth_multicast.octets) },
1468075cb72SGal Pressman 	{ "rx_vport_broadcast_packets",
1479218b44dSGal Pressman 		VPORT_COUNTER_OFF(received_eth_broadcast.packets) },
1488075cb72SGal Pressman 	{ "rx_vport_broadcast_bytes",
1499218b44dSGal Pressman 		VPORT_COUNTER_OFF(received_eth_broadcast.octets) },
1508075cb72SGal Pressman 	{ "tx_vport_broadcast_packets",
1519218b44dSGal Pressman 		VPORT_COUNTER_OFF(transmitted_eth_broadcast.packets) },
1528075cb72SGal Pressman 	{ "tx_vport_broadcast_bytes",
1539218b44dSGal Pressman 		VPORT_COUNTER_OFF(transmitted_eth_broadcast.octets) },
1549218b44dSGal Pressman };
1559218b44dSGal Pressman 
1569218b44dSGal Pressman #define PPORT_802_3_OFF(c) \
1579218b44dSGal Pressman 	MLX5_BYTE_OFF(ppcnt_reg, \
1589218b44dSGal Pressman 		      counter_set.eth_802_3_cntrs_grp_data_layout.c##_high)
1599218b44dSGal Pressman #define PPORT_802_3_GET(pstats, c) \
1609218b44dSGal Pressman 	MLX5_GET64(ppcnt_reg, pstats->IEEE_802_3_counters, \
1619218b44dSGal Pressman 		   counter_set.eth_802_3_cntrs_grp_data_layout.c##_high)
1629218b44dSGal Pressman #define PPORT_2863_OFF(c) \
1639218b44dSGal Pressman 	MLX5_BYTE_OFF(ppcnt_reg, \
1649218b44dSGal Pressman 		      counter_set.eth_2863_cntrs_grp_data_layout.c##_high)
1659218b44dSGal Pressman #define PPORT_2863_GET(pstats, c) \
1669218b44dSGal Pressman 	MLX5_GET64(ppcnt_reg, pstats->RFC_2863_counters, \
1679218b44dSGal Pressman 		   counter_set.eth_2863_cntrs_grp_data_layout.c##_high)
1689218b44dSGal Pressman #define PPORT_2819_OFF(c) \
1699218b44dSGal Pressman 	MLX5_BYTE_OFF(ppcnt_reg, \
1709218b44dSGal Pressman 		      counter_set.eth_2819_cntrs_grp_data_layout.c##_high)
1719218b44dSGal Pressman #define PPORT_2819_GET(pstats, c) \
1729218b44dSGal Pressman 	MLX5_GET64(ppcnt_reg, pstats->RFC_2819_counters, \
1739218b44dSGal Pressman 		   counter_set.eth_2819_cntrs_grp_data_layout.c##_high)
174cf678570SGal Pressman #define PPORT_PER_PRIO_OFF(c) \
175cf678570SGal Pressman 	MLX5_BYTE_OFF(ppcnt_reg, \
176cf678570SGal Pressman 		      counter_set.eth_per_prio_grp_data_layout.c##_high)
177cf678570SGal Pressman #define PPORT_PER_PRIO_GET(pstats, prio, c) \
178cf678570SGal Pressman 	MLX5_GET64(ppcnt_reg, pstats->per_prio_counters[prio], \
179cf678570SGal Pressman 		   counter_set.eth_per_prio_grp_data_layout.c##_high)
180cf678570SGal Pressman #define NUM_PPORT_PRIO				8
1819218b44dSGal Pressman 
1829218b44dSGal Pressman struct mlx5e_pport_stats {
1839218b44dSGal Pressman 	__be64 IEEE_802_3_counters[MLX5_ST_SZ_QW(ppcnt_reg)];
1849218b44dSGal Pressman 	__be64 RFC_2863_counters[MLX5_ST_SZ_QW(ppcnt_reg)];
1859218b44dSGal Pressman 	__be64 RFC_2819_counters[MLX5_ST_SZ_QW(ppcnt_reg)];
186cf678570SGal Pressman 	__be64 per_prio_counters[NUM_PPORT_PRIO][MLX5_ST_SZ_QW(ppcnt_reg)];
187121fcdc8SGal Pressman 	__be64 phy_counters[MLX5_ST_SZ_QW(ppcnt_reg)];
1889218b44dSGal Pressman };
1899218b44dSGal Pressman 
1909218b44dSGal Pressman static const struct counter_desc pport_802_3_stats_desc[] = {
1919218b44dSGal Pressman 	{ "frames_tx", PPORT_802_3_OFF(a_frames_transmitted_ok) },
1929218b44dSGal Pressman 	{ "frames_rx", PPORT_802_3_OFF(a_frames_received_ok) },
1939218b44dSGal Pressman 	{ "check_seq_err", PPORT_802_3_OFF(a_frame_check_sequence_errors) },
1949218b44dSGal Pressman 	{ "alignment_err", PPORT_802_3_OFF(a_alignment_errors) },
1959218b44dSGal Pressman 	{ "octets_tx", PPORT_802_3_OFF(a_octets_transmitted_ok) },
1969218b44dSGal Pressman 	{ "octets_received", PPORT_802_3_OFF(a_octets_received_ok) },
1979218b44dSGal Pressman 	{ "multicast_xmitted", PPORT_802_3_OFF(a_multicast_frames_xmitted_ok) },
1989218b44dSGal Pressman 	{ "broadcast_xmitted", PPORT_802_3_OFF(a_broadcast_frames_xmitted_ok) },
1999218b44dSGal Pressman 	{ "multicast_rx", PPORT_802_3_OFF(a_multicast_frames_received_ok) },
2009218b44dSGal Pressman 	{ "broadcast_rx", PPORT_802_3_OFF(a_broadcast_frames_received_ok) },
2019218b44dSGal Pressman 	{ "in_range_len_errors", PPORT_802_3_OFF(a_in_range_length_errors) },
2029218b44dSGal Pressman 	{ "out_of_range_len", PPORT_802_3_OFF(a_out_of_range_length_field) },
2039218b44dSGal Pressman 	{ "too_long_errors", PPORT_802_3_OFF(a_frame_too_long_errors) },
2049218b44dSGal Pressman 	{ "symbol_err", PPORT_802_3_OFF(a_symbol_error_during_carrier) },
2059218b44dSGal Pressman 	{ "mac_control_tx", PPORT_802_3_OFF(a_mac_control_frames_transmitted) },
2069218b44dSGal Pressman 	{ "mac_control_rx", PPORT_802_3_OFF(a_mac_control_frames_received) },
2079218b44dSGal Pressman 	{ "unsupported_op_rx",
2089218b44dSGal Pressman 		PPORT_802_3_OFF(a_unsupported_opcodes_received) },
2099218b44dSGal Pressman 	{ "pause_ctrl_rx", PPORT_802_3_OFF(a_pause_mac_ctrl_frames_received) },
2109218b44dSGal Pressman 	{ "pause_ctrl_tx",
2119218b44dSGal Pressman 		PPORT_802_3_OFF(a_pause_mac_ctrl_frames_transmitted) },
2129218b44dSGal Pressman };
2139218b44dSGal Pressman 
2149218b44dSGal Pressman static const struct counter_desc pport_2863_stats_desc[] = {
2159218b44dSGal Pressman 	{ "in_octets", PPORT_2863_OFF(if_in_octets) },
2169218b44dSGal Pressman 	{ "in_ucast_pkts", PPORT_2863_OFF(if_in_ucast_pkts) },
2179218b44dSGal Pressman 	{ "in_discards", PPORT_2863_OFF(if_in_discards) },
2189218b44dSGal Pressman 	{ "in_errors", PPORT_2863_OFF(if_in_errors) },
2199218b44dSGal Pressman 	{ "in_unknown_protos", PPORT_2863_OFF(if_in_unknown_protos) },
2209218b44dSGal Pressman 	{ "out_octets", PPORT_2863_OFF(if_out_octets) },
2219218b44dSGal Pressman 	{ "out_ucast_pkts", PPORT_2863_OFF(if_out_ucast_pkts) },
2229218b44dSGal Pressman 	{ "out_discards", PPORT_2863_OFF(if_out_discards) },
2239218b44dSGal Pressman 	{ "out_errors", PPORT_2863_OFF(if_out_errors) },
2249218b44dSGal Pressman 	{ "in_multicast_pkts", PPORT_2863_OFF(if_in_multicast_pkts) },
2259218b44dSGal Pressman 	{ "in_broadcast_pkts", PPORT_2863_OFF(if_in_broadcast_pkts) },
2269218b44dSGal Pressman 	{ "out_multicast_pkts", PPORT_2863_OFF(if_out_multicast_pkts) },
2279218b44dSGal Pressman 	{ "out_broadcast_pkts", PPORT_2863_OFF(if_out_broadcast_pkts) },
2289218b44dSGal Pressman };
2299218b44dSGal Pressman 
2309218b44dSGal Pressman static const struct counter_desc pport_2819_stats_desc[] = {
2319218b44dSGal Pressman 	{ "drop_events", PPORT_2819_OFF(ether_stats_drop_events) },
2329218b44dSGal Pressman 	{ "octets", PPORT_2819_OFF(ether_stats_octets) },
2339218b44dSGal Pressman 	{ "pkts", PPORT_2819_OFF(ether_stats_pkts) },
2349218b44dSGal Pressman 	{ "broadcast_pkts", PPORT_2819_OFF(ether_stats_broadcast_pkts) },
2359218b44dSGal Pressman 	{ "multicast_pkts", PPORT_2819_OFF(ether_stats_multicast_pkts) },
2369218b44dSGal Pressman 	{ "crc_align_errors", PPORT_2819_OFF(ether_stats_crc_align_errors) },
2379218b44dSGal Pressman 	{ "undersize_pkts", PPORT_2819_OFF(ether_stats_undersize_pkts) },
2389218b44dSGal Pressman 	{ "oversize_pkts", PPORT_2819_OFF(ether_stats_oversize_pkts) },
2399218b44dSGal Pressman 	{ "fragments", PPORT_2819_OFF(ether_stats_fragments) },
2409218b44dSGal Pressman 	{ "jabbers", PPORT_2819_OFF(ether_stats_jabbers) },
2419218b44dSGal Pressman 	{ "collisions", PPORT_2819_OFF(ether_stats_collisions) },
2429218b44dSGal Pressman 	{ "p64octets", PPORT_2819_OFF(ether_stats_pkts64octets) },
2439218b44dSGal Pressman 	{ "p65to127octets", PPORT_2819_OFF(ether_stats_pkts65to127octets) },
2449218b44dSGal Pressman 	{ "p128to255octets", PPORT_2819_OFF(ether_stats_pkts128to255octets) },
2459218b44dSGal Pressman 	{ "p256to511octets", PPORT_2819_OFF(ether_stats_pkts256to511octets) },
2469218b44dSGal Pressman 	{ "p512to1023octets", PPORT_2819_OFF(ether_stats_pkts512to1023octets) },
2479218b44dSGal Pressman 	{ "p1024to1518octets",
2489218b44dSGal Pressman 		PPORT_2819_OFF(ether_stats_pkts1024to1518octets) },
2499218b44dSGal Pressman 	{ "p1519to2047octets",
2509218b44dSGal Pressman 		PPORT_2819_OFF(ether_stats_pkts1519to2047octets) },
2519218b44dSGal Pressman 	{ "p2048to4095octets",
2529218b44dSGal Pressman 		PPORT_2819_OFF(ether_stats_pkts2048to4095octets) },
2539218b44dSGal Pressman 	{ "p4096to8191octets",
2549218b44dSGal Pressman 		PPORT_2819_OFF(ether_stats_pkts4096to8191octets) },
2559218b44dSGal Pressman 	{ "p8192to10239octets",
2569218b44dSGal Pressman 		PPORT_2819_OFF(ether_stats_pkts8192to10239octets) },
2579218b44dSGal Pressman };
2589218b44dSGal Pressman 
259cf678570SGal Pressman static const struct counter_desc pport_per_prio_traffic_stats_desc[] = {
260cf678570SGal Pressman 	{ "rx_octets", PPORT_PER_PRIO_OFF(rx_octets) },
261cf678570SGal Pressman 	{ "rx_frames", PPORT_PER_PRIO_OFF(rx_frames) },
262cf678570SGal Pressman 	{ "tx_octets", PPORT_PER_PRIO_OFF(tx_octets) },
263cf678570SGal Pressman 	{ "tx_frames", PPORT_PER_PRIO_OFF(tx_frames) },
264cf678570SGal Pressman };
265cf678570SGal Pressman 
266cf678570SGal Pressman static const struct counter_desc pport_per_prio_pfc_stats_desc[] = {
267cf678570SGal Pressman 	{ "rx_pause", PPORT_PER_PRIO_OFF(rx_pause) },
268cf678570SGal Pressman 	{ "rx_pause_duration", PPORT_PER_PRIO_OFF(rx_pause_duration) },
269cf678570SGal Pressman 	{ "tx_pause", PPORT_PER_PRIO_OFF(tx_pause) },
270cf678570SGal Pressman 	{ "tx_pause_duration", PPORT_PER_PRIO_OFF(tx_pause_duration) },
271cf678570SGal Pressman 	{ "rx_pause_transition", PPORT_PER_PRIO_OFF(rx_pause_transition) },
272cf678570SGal Pressman };
273cf678570SGal Pressman 
2749218b44dSGal Pressman struct mlx5e_rq_stats {
2759218b44dSGal Pressman 	u64 packets;
2769218b44dSGal Pressman 	u64 bytes;
2779218b44dSGal Pressman 	u64 csum_sw;
2781b223dd3SSaeed Mahameed 	u64 csum_inner;
2791b223dd3SSaeed Mahameed 	u64 csum_none;
2809218b44dSGal Pressman 	u64 lro_packets;
2819218b44dSGal Pressman 	u64 lro_bytes;
2829218b44dSGal Pressman 	u64 wqe_err;
2839218b44dSGal Pressman 	u64 mpwqe_filler;
2849218b44dSGal Pressman 	u64 mpwqe_frag;
2859218b44dSGal Pressman 	u64 buff_alloc_err;
2869218b44dSGal Pressman };
2879218b44dSGal Pressman 
2889218b44dSGal Pressman static const struct counter_desc rq_stats_desc[] = {
2899218b44dSGal Pressman 	{ MLX5E_DECLARE_STAT(struct mlx5e_rq_stats, packets) },
2909218b44dSGal Pressman 	{ MLX5E_DECLARE_STAT(struct mlx5e_rq_stats, bytes) },
2919218b44dSGal Pressman 	{ MLX5E_DECLARE_STAT(struct mlx5e_rq_stats, csum_sw) },
2921b223dd3SSaeed Mahameed 	{ MLX5E_DECLARE_STAT(struct mlx5e_rq_stats, csum_inner) },
2931b223dd3SSaeed Mahameed 	{ MLX5E_DECLARE_STAT(struct mlx5e_rq_stats, csum_none) },
2949218b44dSGal Pressman 	{ MLX5E_DECLARE_STAT(struct mlx5e_rq_stats, lro_packets) },
2959218b44dSGal Pressman 	{ MLX5E_DECLARE_STAT(struct mlx5e_rq_stats, lro_bytes) },
2969218b44dSGal Pressman 	{ MLX5E_DECLARE_STAT(struct mlx5e_rq_stats, wqe_err) },
2979218b44dSGal Pressman 	{ MLX5E_DECLARE_STAT(struct mlx5e_rq_stats, mpwqe_filler) },
2989218b44dSGal Pressman 	{ MLX5E_DECLARE_STAT(struct mlx5e_rq_stats, mpwqe_frag) },
2999218b44dSGal Pressman 	{ MLX5E_DECLARE_STAT(struct mlx5e_rq_stats, buff_alloc_err) },
3009218b44dSGal Pressman };
3019218b44dSGal Pressman 
3029218b44dSGal Pressman struct mlx5e_sq_stats {
3039218b44dSGal Pressman 	/* commonly accessed in data path */
3049218b44dSGal Pressman 	u64 packets;
3059218b44dSGal Pressman 	u64 bytes;
3069218b44dSGal Pressman 	u64 tso_packets;
3079218b44dSGal Pressman 	u64 tso_bytes;
3089218b44dSGal Pressman 	u64 tso_inner_packets;
3099218b44dSGal Pressman 	u64 tso_inner_bytes;
3109218b44dSGal Pressman 	u64 csum_offload_inner;
3119218b44dSGal Pressman 	u64 nop;
3129218b44dSGal Pressman 	/* less likely accessed in data path */
3139218b44dSGal Pressman 	u64 csum_offload_none;
3149218b44dSGal Pressman 	u64 stopped;
3159218b44dSGal Pressman 	u64 wake;
3169218b44dSGal Pressman 	u64 dropped;
3179218b44dSGal Pressman };
3189218b44dSGal Pressman 
3199218b44dSGal Pressman static const struct counter_desc sq_stats_desc[] = {
3209218b44dSGal Pressman 	{ MLX5E_DECLARE_STAT(struct mlx5e_sq_stats, packets) },
3219218b44dSGal Pressman 	{ MLX5E_DECLARE_STAT(struct mlx5e_sq_stats, bytes) },
3229218b44dSGal Pressman 	{ MLX5E_DECLARE_STAT(struct mlx5e_sq_stats, tso_packets) },
3239218b44dSGal Pressman 	{ MLX5E_DECLARE_STAT(struct mlx5e_sq_stats, tso_bytes) },
3249218b44dSGal Pressman 	{ MLX5E_DECLARE_STAT(struct mlx5e_sq_stats, tso_inner_packets) },
3259218b44dSGal Pressman 	{ MLX5E_DECLARE_STAT(struct mlx5e_sq_stats, tso_inner_bytes) },
3269218b44dSGal Pressman 	{ MLX5E_DECLARE_STAT(struct mlx5e_sq_stats, csum_offload_inner) },
3279218b44dSGal Pressman 	{ MLX5E_DECLARE_STAT(struct mlx5e_sq_stats, nop) },
3289218b44dSGal Pressman 	{ MLX5E_DECLARE_STAT(struct mlx5e_sq_stats, csum_offload_none) },
3299218b44dSGal Pressman 	{ MLX5E_DECLARE_STAT(struct mlx5e_sq_stats, stopped) },
3309218b44dSGal Pressman 	{ MLX5E_DECLARE_STAT(struct mlx5e_sq_stats, wake) },
3319218b44dSGal Pressman 	{ MLX5E_DECLARE_STAT(struct mlx5e_sq_stats, dropped) },
3329218b44dSGal Pressman };
3339218b44dSGal Pressman 
3349218b44dSGal Pressman #define NUM_SW_COUNTERS			ARRAY_SIZE(sw_stats_desc)
3359218b44dSGal Pressman #define NUM_Q_COUNTERS			ARRAY_SIZE(q_stats_desc)
3369218b44dSGal Pressman #define NUM_VPORT_COUNTERS		ARRAY_SIZE(vport_stats_desc)
3379218b44dSGal Pressman #define NUM_PPORT_802_3_COUNTERS	ARRAY_SIZE(pport_802_3_stats_desc)
3389218b44dSGal Pressman #define NUM_PPORT_2863_COUNTERS		ARRAY_SIZE(pport_2863_stats_desc)
3399218b44dSGal Pressman #define NUM_PPORT_2819_COUNTERS		ARRAY_SIZE(pport_2819_stats_desc)
340cf678570SGal Pressman #define NUM_PPORT_PER_PRIO_TRAFFIC_COUNTERS \
341cf678570SGal Pressman 	ARRAY_SIZE(pport_per_prio_traffic_stats_desc)
342cf678570SGal Pressman #define NUM_PPORT_PER_PRIO_PFC_COUNTERS \
343cf678570SGal Pressman 	ARRAY_SIZE(pport_per_prio_pfc_stats_desc)
3449218b44dSGal Pressman #define NUM_PPORT_COUNTERS		(NUM_PPORT_802_3_COUNTERS + \
3459218b44dSGal Pressman 					 NUM_PPORT_2863_COUNTERS  + \
346cf678570SGal Pressman 					 NUM_PPORT_2819_COUNTERS  + \
347cf678570SGal Pressman 					 NUM_PPORT_PER_PRIO_TRAFFIC_COUNTERS * \
348cf678570SGal Pressman 					 NUM_PPORT_PRIO)
3499218b44dSGal Pressman #define NUM_RQ_STATS			ARRAY_SIZE(rq_stats_desc)
3509218b44dSGal Pressman #define NUM_SQ_STATS			ARRAY_SIZE(sq_stats_desc)
3519218b44dSGal Pressman 
3529218b44dSGal Pressman struct mlx5e_stats {
3539218b44dSGal Pressman 	struct mlx5e_sw_stats sw;
3549218b44dSGal Pressman 	struct mlx5e_qcounter_stats qcnt;
3559218b44dSGal Pressman 	struct mlx5e_vport_stats vport;
3569218b44dSGal Pressman 	struct mlx5e_pport_stats pport;
3579218b44dSGal Pressman };
3589218b44dSGal Pressman 
3599218b44dSGal Pressman #endif /* __MLX5_EN_STATS_H__ */
360