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) \ 420f7f3481SGal Pressman be32_to_cpu(*(__be32 *)((char *)ptr + dsc[i].offset)) 439218b44dSGal Pressman 449218b44dSGal Pressman #define MLX5E_DECLARE_STAT(type, fld) #fld, offsetof(type, fld) 45bfe6d8d1SGal Pressman #define MLX5E_DECLARE_RX_STAT(type, fld) "rx%d_"#fld, offsetof(type, fld) 46bfe6d8d1SGal Pressman #define MLX5E_DECLARE_TX_STAT(type, fld) "tx%d_"#fld, offsetof(type, fld) 479218b44dSGal Pressman 489218b44dSGal Pressman struct counter_desc { 49bfe6d8d1SGal Pressman char format[ETH_GSTRING_LEN]; 509218b44dSGal Pressman int offset; /* Byte offset */ 519218b44dSGal Pressman }; 529218b44dSGal Pressman 539218b44dSGal Pressman struct mlx5e_sw_stats { 549218b44dSGal Pressman u64 rx_packets; 559218b44dSGal Pressman u64 rx_bytes; 569218b44dSGal Pressman u64 tx_packets; 579218b44dSGal Pressman u64 tx_bytes; 58bfe6d8d1SGal Pressman u64 tx_tso_packets; 59bfe6d8d1SGal Pressman u64 tx_tso_bytes; 60bfe6d8d1SGal Pressman u64 tx_tso_inner_packets; 61bfe6d8d1SGal Pressman u64 tx_tso_inner_bytes; 62bfe6d8d1SGal Pressman u64 rx_lro_packets; 63bfe6d8d1SGal Pressman u64 rx_lro_bytes; 64bfe6d8d1SGal Pressman u64 rx_csum_unnecessary; 659218b44dSGal Pressman u64 rx_csum_none; 66bfe6d8d1SGal Pressman u64 rx_csum_complete; 67bfe6d8d1SGal Pressman u64 rx_csum_unnecessary_inner; 6886994156SRana Shahout u64 rx_xdp_drop; 69b5503b99SSaeed Mahameed u64 rx_xdp_tx; 70b5503b99SSaeed Mahameed u64 rx_xdp_tx_full; 71bfe6d8d1SGal Pressman u64 tx_csum_partial; 72bfe6d8d1SGal Pressman u64 tx_csum_partial_inner; 739218b44dSGal Pressman u64 tx_queue_stopped; 749218b44dSGal Pressman u64 tx_queue_wake; 759218b44dSGal Pressman u64 tx_queue_dropped; 76c8cf78feSTariq Toukan u64 tx_xmit_more; 779218b44dSGal Pressman u64 rx_wqe_err; 789218b44dSGal Pressman u64 rx_mpwqe_filler; 799218b44dSGal Pressman u64 rx_buff_alloc_err; 807219ab34STariq Toukan u64 rx_cqe_compress_blks; 817219ab34STariq Toukan u64 rx_cqe_compress_pkts; 82accd5883STariq Toukan u64 rx_page_reuse; 834415a031STariq Toukan u64 rx_cache_reuse; 844415a031STariq Toukan u64 rx_cache_full; 854415a031STariq Toukan u64 rx_cache_empty; 864415a031STariq Toukan u64 rx_cache_busy; 87121fcdc8SGal Pressman 88121fcdc8SGal Pressman /* Special handling counters */ 89bfe6d8d1SGal Pressman u64 link_down_events_phy; 909218b44dSGal Pressman }; 919218b44dSGal Pressman 929218b44dSGal Pressman static const struct counter_desc sw_stats_desc[] = { 939218b44dSGal Pressman { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_packets) }, 949218b44dSGal Pressman { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_bytes) }, 959218b44dSGal Pressman { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, tx_packets) }, 969218b44dSGal Pressman { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, tx_bytes) }, 97bfe6d8d1SGal Pressman { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, tx_tso_packets) }, 98bfe6d8d1SGal Pressman { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, tx_tso_bytes) }, 99bfe6d8d1SGal Pressman { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, tx_tso_inner_packets) }, 100bfe6d8d1SGal Pressman { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, tx_tso_inner_bytes) }, 101bfe6d8d1SGal Pressman { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_lro_packets) }, 102bfe6d8d1SGal Pressman { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_lro_bytes) }, 103bfe6d8d1SGal Pressman { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_csum_unnecessary) }, 1049218b44dSGal Pressman { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_csum_none) }, 105bfe6d8d1SGal Pressman { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_csum_complete) }, 106bfe6d8d1SGal Pressman { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_csum_unnecessary_inner) }, 10786994156SRana Shahout { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_xdp_drop) }, 108b5503b99SSaeed Mahameed { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_xdp_tx) }, 109b5503b99SSaeed Mahameed { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_xdp_tx_full) }, 110bfe6d8d1SGal Pressman { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, tx_csum_partial) }, 111bfe6d8d1SGal Pressman { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, tx_csum_partial_inner) }, 1129218b44dSGal Pressman { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, tx_queue_stopped) }, 1139218b44dSGal Pressman { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, tx_queue_wake) }, 1149218b44dSGal Pressman { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, tx_queue_dropped) }, 115c8cf78feSTariq Toukan { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, tx_xmit_more) }, 1169218b44dSGal Pressman { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_wqe_err) }, 1179218b44dSGal Pressman { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_mpwqe_filler) }, 1189218b44dSGal Pressman { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_buff_alloc_err) }, 1197219ab34STariq Toukan { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_cqe_compress_blks) }, 1207219ab34STariq Toukan { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_cqe_compress_pkts) }, 121accd5883STariq Toukan { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_page_reuse) }, 1224415a031STariq Toukan { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_cache_reuse) }, 1234415a031STariq Toukan { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_cache_full) }, 1244415a031STariq Toukan { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_cache_empty) }, 1254415a031STariq Toukan { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_cache_busy) }, 126bfe6d8d1SGal Pressman { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, link_down_events_phy) }, 1279218b44dSGal Pressman }; 1289218b44dSGal Pressman 1299218b44dSGal Pressman struct mlx5e_qcounter_stats { 1309218b44dSGal Pressman u32 rx_out_of_buffer; 1319218b44dSGal Pressman }; 1329218b44dSGal Pressman 1339218b44dSGal Pressman static const struct counter_desc q_stats_desc[] = { 1349218b44dSGal Pressman { MLX5E_DECLARE_STAT(struct mlx5e_qcounter_stats, rx_out_of_buffer) }, 1359218b44dSGal Pressman }; 1369218b44dSGal Pressman 1379218b44dSGal Pressman #define VPORT_COUNTER_OFF(c) MLX5_BYTE_OFF(query_vport_counter_out, c) 1389218b44dSGal Pressman #define VPORT_COUNTER_GET(vstats, c) MLX5_GET64(query_vport_counter_out, \ 1399218b44dSGal Pressman vstats->query_vport_out, c) 1409218b44dSGal Pressman 1419218b44dSGal Pressman struct mlx5e_vport_stats { 1429218b44dSGal Pressman __be64 query_vport_out[MLX5_ST_SZ_QW(query_vport_counter_out)]; 1439218b44dSGal Pressman }; 1449218b44dSGal Pressman 1459218b44dSGal Pressman static const struct counter_desc vport_stats_desc[] = { 1468075cb72SGal Pressman { "rx_vport_unicast_packets", 1479218b44dSGal Pressman VPORT_COUNTER_OFF(received_eth_unicast.packets) }, 1488075cb72SGal Pressman { "rx_vport_unicast_bytes", 1498075cb72SGal Pressman VPORT_COUNTER_OFF(received_eth_unicast.octets) }, 1508075cb72SGal Pressman { "tx_vport_unicast_packets", 1519218b44dSGal Pressman VPORT_COUNTER_OFF(transmitted_eth_unicast.packets) }, 1528075cb72SGal Pressman { "tx_vport_unicast_bytes", 1539218b44dSGal Pressman VPORT_COUNTER_OFF(transmitted_eth_unicast.octets) }, 1548075cb72SGal Pressman { "rx_vport_multicast_packets", 1559218b44dSGal Pressman VPORT_COUNTER_OFF(received_eth_multicast.packets) }, 1568075cb72SGal Pressman { "rx_vport_multicast_bytes", 1579218b44dSGal Pressman VPORT_COUNTER_OFF(received_eth_multicast.octets) }, 1588075cb72SGal Pressman { "tx_vport_multicast_packets", 1599218b44dSGal Pressman VPORT_COUNTER_OFF(transmitted_eth_multicast.packets) }, 1608075cb72SGal Pressman { "tx_vport_multicast_bytes", 1619218b44dSGal Pressman VPORT_COUNTER_OFF(transmitted_eth_multicast.octets) }, 1628075cb72SGal Pressman { "rx_vport_broadcast_packets", 1639218b44dSGal Pressman VPORT_COUNTER_OFF(received_eth_broadcast.packets) }, 1648075cb72SGal Pressman { "rx_vport_broadcast_bytes", 1659218b44dSGal Pressman VPORT_COUNTER_OFF(received_eth_broadcast.octets) }, 1668075cb72SGal Pressman { "tx_vport_broadcast_packets", 1679218b44dSGal Pressman VPORT_COUNTER_OFF(transmitted_eth_broadcast.packets) }, 1688075cb72SGal Pressman { "tx_vport_broadcast_bytes", 1699218b44dSGal Pressman VPORT_COUNTER_OFF(transmitted_eth_broadcast.octets) }, 170fe6b9bd9SGal Pressman { "rx_vport_rdma_unicast_packets", 171fe6b9bd9SGal Pressman VPORT_COUNTER_OFF(received_ib_unicast.packets) }, 172fe6b9bd9SGal Pressman { "rx_vport_rdma_unicast_bytes", 173fe6b9bd9SGal Pressman VPORT_COUNTER_OFF(received_ib_unicast.octets) }, 174fe6b9bd9SGal Pressman { "tx_vport_rdma_unicast_packets", 175fe6b9bd9SGal Pressman VPORT_COUNTER_OFF(transmitted_ib_unicast.packets) }, 176fe6b9bd9SGal Pressman { "tx_vport_rdma_unicast_bytes", 177fe6b9bd9SGal Pressman VPORT_COUNTER_OFF(transmitted_ib_unicast.octets) }, 178fe6b9bd9SGal Pressman { "rx_vport_rdma_multicast_packets", 179fe6b9bd9SGal Pressman VPORT_COUNTER_OFF(received_ib_multicast.packets) }, 180fe6b9bd9SGal Pressman { "rx_vport_rdma_multicast_bytes", 181fe6b9bd9SGal Pressman VPORT_COUNTER_OFF(received_ib_multicast.octets) }, 182fe6b9bd9SGal Pressman { "tx_vport_rdma_multicast_packets", 183fe6b9bd9SGal Pressman VPORT_COUNTER_OFF(transmitted_ib_multicast.packets) }, 184fe6b9bd9SGal Pressman { "tx_vport_rdma_multicast_bytes", 185fe6b9bd9SGal Pressman VPORT_COUNTER_OFF(transmitted_ib_multicast.octets) }, 1869218b44dSGal Pressman }; 1879218b44dSGal Pressman 1889218b44dSGal Pressman #define PPORT_802_3_OFF(c) \ 1899218b44dSGal Pressman MLX5_BYTE_OFF(ppcnt_reg, \ 1909218b44dSGal Pressman counter_set.eth_802_3_cntrs_grp_data_layout.c##_high) 1919218b44dSGal Pressman #define PPORT_802_3_GET(pstats, c) \ 1929218b44dSGal Pressman MLX5_GET64(ppcnt_reg, pstats->IEEE_802_3_counters, \ 1939218b44dSGal Pressman counter_set.eth_802_3_cntrs_grp_data_layout.c##_high) 1949218b44dSGal Pressman #define PPORT_2863_OFF(c) \ 1959218b44dSGal Pressman MLX5_BYTE_OFF(ppcnt_reg, \ 1969218b44dSGal Pressman counter_set.eth_2863_cntrs_grp_data_layout.c##_high) 1979218b44dSGal Pressman #define PPORT_2863_GET(pstats, c) \ 1989218b44dSGal Pressman MLX5_GET64(ppcnt_reg, pstats->RFC_2863_counters, \ 1999218b44dSGal Pressman counter_set.eth_2863_cntrs_grp_data_layout.c##_high) 2009218b44dSGal Pressman #define PPORT_2819_OFF(c) \ 2019218b44dSGal Pressman MLX5_BYTE_OFF(ppcnt_reg, \ 2029218b44dSGal Pressman counter_set.eth_2819_cntrs_grp_data_layout.c##_high) 2039218b44dSGal Pressman #define PPORT_2819_GET(pstats, c) \ 2049218b44dSGal Pressman MLX5_GET64(ppcnt_reg, pstats->RFC_2819_counters, \ 2059218b44dSGal Pressman counter_set.eth_2819_cntrs_grp_data_layout.c##_high) 2065db0a4f6SGal Pressman #define PPORT_PHY_STATISTICAL_OFF(c) \ 2075db0a4f6SGal Pressman MLX5_BYTE_OFF(ppcnt_reg, \ 2085db0a4f6SGal Pressman counter_set.phys_layer_statistical_cntrs.c##_high) 2095db0a4f6SGal Pressman #define PPORT_PHY_STATISTICAL_GET(pstats, c) \ 2105db0a4f6SGal Pressman MLX5_GET64(ppcnt_reg, (pstats)->phy_statistical_counters, \ 2115db0a4f6SGal Pressman counter_set.phys_layer_statistical_cntrs.c##_high) 212cf678570SGal Pressman #define PPORT_PER_PRIO_OFF(c) \ 213cf678570SGal Pressman MLX5_BYTE_OFF(ppcnt_reg, \ 214cf678570SGal Pressman counter_set.eth_per_prio_grp_data_layout.c##_high) 215cf678570SGal Pressman #define PPORT_PER_PRIO_GET(pstats, prio, c) \ 216cf678570SGal Pressman MLX5_GET64(ppcnt_reg, pstats->per_prio_counters[prio], \ 217cf678570SGal Pressman counter_set.eth_per_prio_grp_data_layout.c##_high) 218cf678570SGal Pressman #define NUM_PPORT_PRIO 8 2199218b44dSGal Pressman 2209218b44dSGal Pressman struct mlx5e_pport_stats { 2219218b44dSGal Pressman __be64 IEEE_802_3_counters[MLX5_ST_SZ_QW(ppcnt_reg)]; 2229218b44dSGal Pressman __be64 RFC_2863_counters[MLX5_ST_SZ_QW(ppcnt_reg)]; 2239218b44dSGal Pressman __be64 RFC_2819_counters[MLX5_ST_SZ_QW(ppcnt_reg)]; 224cf678570SGal Pressman __be64 per_prio_counters[NUM_PPORT_PRIO][MLX5_ST_SZ_QW(ppcnt_reg)]; 225121fcdc8SGal Pressman __be64 phy_counters[MLX5_ST_SZ_QW(ppcnt_reg)]; 2265db0a4f6SGal Pressman __be64 phy_statistical_counters[MLX5_ST_SZ_QW(ppcnt_reg)]; 2279218b44dSGal Pressman }; 2289218b44dSGal Pressman 2299218b44dSGal Pressman static const struct counter_desc pport_802_3_stats_desc[] = { 230bfe6d8d1SGal Pressman { "tx_packets_phy", PPORT_802_3_OFF(a_frames_transmitted_ok) }, 231bfe6d8d1SGal Pressman { "rx_packets_phy", PPORT_802_3_OFF(a_frames_received_ok) }, 232bfe6d8d1SGal Pressman { "rx_crc_errors_phy", PPORT_802_3_OFF(a_frame_check_sequence_errors) }, 233bfe6d8d1SGal Pressman { "tx_bytes_phy", PPORT_802_3_OFF(a_octets_transmitted_ok) }, 234bfe6d8d1SGal Pressman { "rx_bytes_phy", PPORT_802_3_OFF(a_octets_received_ok) }, 235bfe6d8d1SGal Pressman { "tx_multicast_phy", PPORT_802_3_OFF(a_multicast_frames_xmitted_ok) }, 236bfe6d8d1SGal Pressman { "tx_broadcast_phy", PPORT_802_3_OFF(a_broadcast_frames_xmitted_ok) }, 237bfe6d8d1SGal Pressman { "rx_multicast_phy", PPORT_802_3_OFF(a_multicast_frames_received_ok) }, 238bfe6d8d1SGal Pressman { "rx_broadcast_phy", PPORT_802_3_OFF(a_broadcast_frames_received_ok) }, 239bfe6d8d1SGal Pressman { "rx_in_range_len_errors_phy", PPORT_802_3_OFF(a_in_range_length_errors) }, 240bfe6d8d1SGal Pressman { "rx_out_of_range_len_phy", PPORT_802_3_OFF(a_out_of_range_length_field) }, 241bfe6d8d1SGal Pressman { "rx_oversize_pkts_phy", PPORT_802_3_OFF(a_frame_too_long_errors) }, 242bfe6d8d1SGal Pressman { "rx_symbol_err_phy", PPORT_802_3_OFF(a_symbol_error_during_carrier) }, 243bfe6d8d1SGal Pressman { "tx_mac_control_phy", PPORT_802_3_OFF(a_mac_control_frames_transmitted) }, 244bfe6d8d1SGal Pressman { "rx_mac_control_phy", PPORT_802_3_OFF(a_mac_control_frames_received) }, 245bfe6d8d1SGal Pressman { "rx_unsupported_op_phy", PPORT_802_3_OFF(a_unsupported_opcodes_received) }, 246bfe6d8d1SGal Pressman { "rx_pause_ctrl_phy", PPORT_802_3_OFF(a_pause_mac_ctrl_frames_received) }, 247bfe6d8d1SGal Pressman { "tx_pause_ctrl_phy", PPORT_802_3_OFF(a_pause_mac_ctrl_frames_transmitted) }, 2489218b44dSGal Pressman }; 2499218b44dSGal Pressman 2509218b44dSGal Pressman static const struct counter_desc pport_2863_stats_desc[] = { 251bfe6d8d1SGal Pressman { "rx_discards_phy", PPORT_2863_OFF(if_in_discards) }, 252bfe6d8d1SGal Pressman { "tx_discards_phy", PPORT_2863_OFF(if_out_discards) }, 253bfe6d8d1SGal Pressman { "tx_errors_phy", PPORT_2863_OFF(if_out_errors) }, 2549218b44dSGal Pressman }; 2559218b44dSGal Pressman 2569218b44dSGal Pressman static const struct counter_desc pport_2819_stats_desc[] = { 257bfe6d8d1SGal Pressman { "rx_undersize_pkts_phy", PPORT_2819_OFF(ether_stats_undersize_pkts) }, 258bfe6d8d1SGal Pressman { "rx_fragments_phy", PPORT_2819_OFF(ether_stats_fragments) }, 259bfe6d8d1SGal Pressman { "rx_jabbers_phy", PPORT_2819_OFF(ether_stats_jabbers) }, 260bfe6d8d1SGal Pressman { "rx_64_bytes_phy", PPORT_2819_OFF(ether_stats_pkts64octets) }, 261bfe6d8d1SGal Pressman { "rx_65_to_127_bytes_phy", PPORT_2819_OFF(ether_stats_pkts65to127octets) }, 262bfe6d8d1SGal Pressman { "rx_128_to_255_bytes_phy", PPORT_2819_OFF(ether_stats_pkts128to255octets) }, 263bfe6d8d1SGal Pressman { "rx_256_to_511_bytes_phy", PPORT_2819_OFF(ether_stats_pkts256to511octets) }, 264bfe6d8d1SGal Pressman { "rx_512_to_1023_bytes_phy", PPORT_2819_OFF(ether_stats_pkts512to1023octets) }, 265bfe6d8d1SGal Pressman { "rx_1024_to_1518_bytes_phy", PPORT_2819_OFF(ether_stats_pkts1024to1518octets) }, 266bfe6d8d1SGal Pressman { "rx_1519_to_2047_bytes_phy", PPORT_2819_OFF(ether_stats_pkts1519to2047octets) }, 267bfe6d8d1SGal Pressman { "rx_2048_to_4095_bytes_phy", PPORT_2819_OFF(ether_stats_pkts2048to4095octets) }, 268bfe6d8d1SGal Pressman { "rx_4096_to_8191_bytes_phy", PPORT_2819_OFF(ether_stats_pkts4096to8191octets) }, 269bfe6d8d1SGal Pressman { "rx_8192_to_10239_bytes_phy", PPORT_2819_OFF(ether_stats_pkts8192to10239octets) }, 2709218b44dSGal Pressman }; 2719218b44dSGal Pressman 2725db0a4f6SGal Pressman static const struct counter_desc pport_phy_statistical_stats_desc[] = { 273ebc88870SGal Pressman { "rx_pcs_symbol_err_phy", PPORT_PHY_STATISTICAL_OFF(phy_symbol_errors) }, 2745db0a4f6SGal Pressman { "rx_corrected_bits_phy", PPORT_PHY_STATISTICAL_OFF(phy_corrected_bits) }, 2755db0a4f6SGal Pressman }; 2765db0a4f6SGal Pressman 277cf678570SGal Pressman static const struct counter_desc pport_per_prio_traffic_stats_desc[] = { 278bfe6d8d1SGal Pressman { "rx_prio%d_bytes", PPORT_PER_PRIO_OFF(rx_octets) }, 279bfe6d8d1SGal Pressman { "rx_prio%d_packets", PPORT_PER_PRIO_OFF(rx_frames) }, 280bfe6d8d1SGal Pressman { "tx_prio%d_bytes", PPORT_PER_PRIO_OFF(tx_octets) }, 281bfe6d8d1SGal Pressman { "tx_prio%d_packets", PPORT_PER_PRIO_OFF(tx_frames) }, 282cf678570SGal Pressman }; 283cf678570SGal Pressman 284cf678570SGal Pressman static const struct counter_desc pport_per_prio_pfc_stats_desc[] = { 285e989d5a5SGal Pressman /* %s is "global" or "prio{i}" */ 286e989d5a5SGal Pressman { "rx_%s_pause", PPORT_PER_PRIO_OFF(rx_pause) }, 287e989d5a5SGal Pressman { "rx_%s_pause_duration", PPORT_PER_PRIO_OFF(rx_pause_duration) }, 288e989d5a5SGal Pressman { "tx_%s_pause", PPORT_PER_PRIO_OFF(tx_pause) }, 289e989d5a5SGal Pressman { "tx_%s_pause_duration", PPORT_PER_PRIO_OFF(tx_pause_duration) }, 290e989d5a5SGal Pressman { "rx_%s_pause_transition", PPORT_PER_PRIO_OFF(rx_pause_transition) }, 291cf678570SGal Pressman }; 292cf678570SGal Pressman 2930f7f3481SGal Pressman #define PCIE_PERF_OFF(c) \ 2940f7f3481SGal Pressman MLX5_BYTE_OFF(mpcnt_reg, counter_set.pcie_perf_cntrs_grp_data_layout.c) 2950f7f3481SGal Pressman #define PCIE_PERF_GET(pcie_stats, c) \ 2960f7f3481SGal Pressman MLX5_GET(mpcnt_reg, (pcie_stats)->pcie_perf_counters, \ 2970f7f3481SGal Pressman counter_set.pcie_perf_cntrs_grp_data_layout.c) 2980f7f3481SGal Pressman 2990f7f3481SGal Pressman struct mlx5e_pcie_stats { 3000f7f3481SGal Pressman __be64 pcie_perf_counters[MLX5_ST_SZ_QW(mpcnt_reg)]; 3010f7f3481SGal Pressman }; 3020f7f3481SGal Pressman 3030f7f3481SGal Pressman static const struct counter_desc pcie_perf_stats_desc[] = { 3040f7f3481SGal Pressman { "rx_pci_signal_integrity", PCIE_PERF_OFF(rx_errors) }, 3050f7f3481SGal Pressman { "tx_pci_signal_integrity", PCIE_PERF_OFF(tx_errors) }, 3060f7f3481SGal Pressman }; 3070f7f3481SGal Pressman 3089218b44dSGal Pressman struct mlx5e_rq_stats { 3099218b44dSGal Pressman u64 packets; 3109218b44dSGal Pressman u64 bytes; 311bfe6d8d1SGal Pressman u64 csum_complete; 312bfe6d8d1SGal Pressman u64 csum_unnecessary_inner; 3131b223dd3SSaeed Mahameed u64 csum_none; 3149218b44dSGal Pressman u64 lro_packets; 3159218b44dSGal Pressman u64 lro_bytes; 31686994156SRana Shahout u64 xdp_drop; 317b5503b99SSaeed Mahameed u64 xdp_tx; 318b5503b99SSaeed Mahameed u64 xdp_tx_full; 3199218b44dSGal Pressman u64 wqe_err; 3209218b44dSGal Pressman u64 mpwqe_filler; 3219218b44dSGal Pressman u64 buff_alloc_err; 3227219ab34STariq Toukan u64 cqe_compress_blks; 3237219ab34STariq Toukan u64 cqe_compress_pkts; 324accd5883STariq Toukan u64 page_reuse; 3254415a031STariq Toukan u64 cache_reuse; 3264415a031STariq Toukan u64 cache_full; 3274415a031STariq Toukan u64 cache_empty; 3284415a031STariq Toukan u64 cache_busy; 3299218b44dSGal Pressman }; 3309218b44dSGal Pressman 3319218b44dSGal Pressman static const struct counter_desc rq_stats_desc[] = { 332bfe6d8d1SGal Pressman { MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, packets) }, 333bfe6d8d1SGal Pressman { MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, bytes) }, 334bfe6d8d1SGal Pressman { MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, csum_complete) }, 335bfe6d8d1SGal Pressman { MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, csum_unnecessary_inner) }, 336bfe6d8d1SGal Pressman { MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, csum_none) }, 33786994156SRana Shahout { MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, xdp_drop) }, 338b5503b99SSaeed Mahameed { MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, xdp_tx) }, 339b5503b99SSaeed Mahameed { MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, xdp_tx_full) }, 340bfe6d8d1SGal Pressman { MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, lro_packets) }, 341bfe6d8d1SGal Pressman { MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, lro_bytes) }, 342bfe6d8d1SGal Pressman { MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, wqe_err) }, 343bfe6d8d1SGal Pressman { MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, mpwqe_filler) }, 344bfe6d8d1SGal Pressman { MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, buff_alloc_err) }, 345bfe6d8d1SGal Pressman { MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, cqe_compress_blks) }, 346bfe6d8d1SGal Pressman { MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, cqe_compress_pkts) }, 347accd5883STariq Toukan { MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, page_reuse) }, 3484415a031STariq Toukan { MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, cache_reuse) }, 3494415a031STariq Toukan { MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, cache_full) }, 3504415a031STariq Toukan { MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, cache_empty) }, 3514415a031STariq Toukan { MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, cache_busy) }, 3529218b44dSGal Pressman }; 3539218b44dSGal Pressman 3549218b44dSGal Pressman struct mlx5e_sq_stats { 3559218b44dSGal Pressman /* commonly accessed in data path */ 3569218b44dSGal Pressman u64 packets; 3579218b44dSGal Pressman u64 bytes; 358c8cf78feSTariq Toukan u64 xmit_more; 3599218b44dSGal Pressman u64 tso_packets; 3609218b44dSGal Pressman u64 tso_bytes; 3619218b44dSGal Pressman u64 tso_inner_packets; 3629218b44dSGal Pressman u64 tso_inner_bytes; 363bfe6d8d1SGal Pressman u64 csum_partial_inner; 3649218b44dSGal Pressman u64 nop; 3659218b44dSGal Pressman /* less likely accessed in data path */ 366bfe6d8d1SGal Pressman u64 csum_none; 3679218b44dSGal Pressman u64 stopped; 3689218b44dSGal Pressman u64 wake; 3699218b44dSGal Pressman u64 dropped; 3709218b44dSGal Pressman }; 3719218b44dSGal Pressman 3729218b44dSGal Pressman static const struct counter_desc sq_stats_desc[] = { 373bfe6d8d1SGal Pressman { MLX5E_DECLARE_TX_STAT(struct mlx5e_sq_stats, packets) }, 374bfe6d8d1SGal Pressman { MLX5E_DECLARE_TX_STAT(struct mlx5e_sq_stats, bytes) }, 375bfe6d8d1SGal Pressman { MLX5E_DECLARE_TX_STAT(struct mlx5e_sq_stats, tso_packets) }, 376bfe6d8d1SGal Pressman { MLX5E_DECLARE_TX_STAT(struct mlx5e_sq_stats, tso_bytes) }, 377bfe6d8d1SGal Pressman { MLX5E_DECLARE_TX_STAT(struct mlx5e_sq_stats, tso_inner_packets) }, 378bfe6d8d1SGal Pressman { MLX5E_DECLARE_TX_STAT(struct mlx5e_sq_stats, tso_inner_bytes) }, 379bfe6d8d1SGal Pressman { MLX5E_DECLARE_TX_STAT(struct mlx5e_sq_stats, csum_partial_inner) }, 380bfe6d8d1SGal Pressman { MLX5E_DECLARE_TX_STAT(struct mlx5e_sq_stats, nop) }, 381bfe6d8d1SGal Pressman { MLX5E_DECLARE_TX_STAT(struct mlx5e_sq_stats, csum_none) }, 382bfe6d8d1SGal Pressman { MLX5E_DECLARE_TX_STAT(struct mlx5e_sq_stats, stopped) }, 383bfe6d8d1SGal Pressman { MLX5E_DECLARE_TX_STAT(struct mlx5e_sq_stats, wake) }, 384bfe6d8d1SGal Pressman { MLX5E_DECLARE_TX_STAT(struct mlx5e_sq_stats, dropped) }, 385c8cf78feSTariq Toukan { MLX5E_DECLARE_TX_STAT(struct mlx5e_sq_stats, xmit_more) }, 3869218b44dSGal Pressman }; 3879218b44dSGal Pressman 3889218b44dSGal Pressman #define NUM_SW_COUNTERS ARRAY_SIZE(sw_stats_desc) 3899218b44dSGal Pressman #define NUM_Q_COUNTERS ARRAY_SIZE(q_stats_desc) 3909218b44dSGal Pressman #define NUM_VPORT_COUNTERS ARRAY_SIZE(vport_stats_desc) 3919218b44dSGal Pressman #define NUM_PPORT_802_3_COUNTERS ARRAY_SIZE(pport_802_3_stats_desc) 3929218b44dSGal Pressman #define NUM_PPORT_2863_COUNTERS ARRAY_SIZE(pport_2863_stats_desc) 3939218b44dSGal Pressman #define NUM_PPORT_2819_COUNTERS ARRAY_SIZE(pport_2819_stats_desc) 3945db0a4f6SGal Pressman #define NUM_PPORT_PHY_STATISTICAL_COUNTERS(priv) \ 3955db0a4f6SGal Pressman (ARRAY_SIZE(pport_phy_statistical_stats_desc) * \ 3965db0a4f6SGal Pressman MLX5_CAP_PCAM_FEATURE((priv)->mdev, ppcnt_statistical_group)) 3970f7f3481SGal Pressman #define NUM_PCIE_PERF_COUNTERS(priv) \ 3980f7f3481SGal Pressman (ARRAY_SIZE(pcie_perf_stats_desc) * \ 3990f7f3481SGal Pressman MLX5_CAP_MCAM_FEATURE((priv)->mdev, pcie_performance_group)) 400cf678570SGal Pressman #define NUM_PPORT_PER_PRIO_TRAFFIC_COUNTERS \ 401cf678570SGal Pressman ARRAY_SIZE(pport_per_prio_traffic_stats_desc) 402cf678570SGal Pressman #define NUM_PPORT_PER_PRIO_PFC_COUNTERS \ 403cf678570SGal Pressman ARRAY_SIZE(pport_per_prio_pfc_stats_desc) 4045db0a4f6SGal Pressman #define NUM_PPORT_COUNTERS(priv) (NUM_PPORT_802_3_COUNTERS + \ 4059218b44dSGal Pressman NUM_PPORT_2863_COUNTERS + \ 406cf678570SGal Pressman NUM_PPORT_2819_COUNTERS + \ 4075db0a4f6SGal Pressman NUM_PPORT_PHY_STATISTICAL_COUNTERS(priv) + \ 408cf678570SGal Pressman NUM_PPORT_PER_PRIO_TRAFFIC_COUNTERS * \ 409cf678570SGal Pressman NUM_PPORT_PRIO) 4100f7f3481SGal Pressman #define NUM_PCIE_COUNTERS(priv) NUM_PCIE_PERF_COUNTERS(priv) 4119218b44dSGal Pressman #define NUM_RQ_STATS ARRAY_SIZE(rq_stats_desc) 4129218b44dSGal Pressman #define NUM_SQ_STATS ARRAY_SIZE(sq_stats_desc) 4139218b44dSGal Pressman 4149218b44dSGal Pressman struct mlx5e_stats { 4159218b44dSGal Pressman struct mlx5e_sw_stats sw; 4169218b44dSGal Pressman struct mlx5e_qcounter_stats qcnt; 4179218b44dSGal Pressman struct mlx5e_vport_stats vport; 4189218b44dSGal Pressman struct mlx5e_pport_stats pport; 419370bad0fSOr Gerlitz struct rtnl_link_stats64 vf_vport; 4200f7f3481SGal Pressman struct mlx5e_pcie_stats pcie; 4219218b44dSGal Pressman }; 4229218b44dSGal Pressman 423bedb7c90SHuy Nguyen static const struct counter_desc mlx5e_pme_status_desc[] = { 424bedb7c90SHuy Nguyen { "module_unplug", 8 }, 425bedb7c90SHuy Nguyen }; 426bedb7c90SHuy Nguyen 427bedb7c90SHuy Nguyen static const struct counter_desc mlx5e_pme_error_desc[] = { 428bedb7c90SHuy Nguyen { "module_bus_stuck", 16 }, /* bus stuck (I2C or data shorted) */ 429bedb7c90SHuy Nguyen { "module_high_temp", 48 }, /* high temperature */ 430bedb7c90SHuy Nguyen { "module_bad_shorted", 56 }, /* bad or shorted cable/module */ 431bedb7c90SHuy Nguyen }; 432bedb7c90SHuy Nguyen 4339218b44dSGal Pressman #endif /* __MLX5_EN_STATS_H__ */ 434