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) 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; 68bfe6d8d1SGal Pressman u64 tx_csum_partial; 69bfe6d8d1SGal Pressman u64 tx_csum_partial_inner; 709218b44dSGal Pressman u64 tx_queue_stopped; 719218b44dSGal Pressman u64 tx_queue_wake; 729218b44dSGal Pressman u64 tx_queue_dropped; 73c8cf78feSTariq Toukan u64 tx_xmit_more; 749218b44dSGal Pressman u64 rx_wqe_err; 759218b44dSGal Pressman u64 rx_mpwqe_filler; 769218b44dSGal Pressman u64 rx_buff_alloc_err; 777219ab34STariq Toukan u64 rx_cqe_compress_blks; 787219ab34STariq Toukan u64 rx_cqe_compress_pkts; 794415a031STariq Toukan u64 rx_cache_reuse; 804415a031STariq Toukan u64 rx_cache_full; 814415a031STariq Toukan u64 rx_cache_empty; 824415a031STariq Toukan u64 rx_cache_busy; 83121fcdc8SGal Pressman 84121fcdc8SGal Pressman /* Special handling counters */ 85bfe6d8d1SGal Pressman u64 link_down_events_phy; 869218b44dSGal Pressman }; 879218b44dSGal Pressman 889218b44dSGal Pressman static const struct counter_desc sw_stats_desc[] = { 899218b44dSGal Pressman { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_packets) }, 909218b44dSGal Pressman { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_bytes) }, 919218b44dSGal Pressman { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, tx_packets) }, 929218b44dSGal Pressman { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, tx_bytes) }, 93bfe6d8d1SGal Pressman { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, tx_tso_packets) }, 94bfe6d8d1SGal Pressman { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, tx_tso_bytes) }, 95bfe6d8d1SGal Pressman { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, tx_tso_inner_packets) }, 96bfe6d8d1SGal Pressman { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, tx_tso_inner_bytes) }, 97bfe6d8d1SGal Pressman { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_lro_packets) }, 98bfe6d8d1SGal Pressman { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_lro_bytes) }, 99bfe6d8d1SGal Pressman { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_csum_unnecessary) }, 1009218b44dSGal Pressman { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_csum_none) }, 101bfe6d8d1SGal Pressman { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_csum_complete) }, 102bfe6d8d1SGal Pressman { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_csum_unnecessary_inner) }, 103bfe6d8d1SGal Pressman { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, tx_csum_partial) }, 104bfe6d8d1SGal Pressman { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, tx_csum_partial_inner) }, 1059218b44dSGal Pressman { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, tx_queue_stopped) }, 1069218b44dSGal Pressman { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, tx_queue_wake) }, 1079218b44dSGal Pressman { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, tx_queue_dropped) }, 108c8cf78feSTariq Toukan { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, tx_xmit_more) }, 1099218b44dSGal Pressman { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_wqe_err) }, 1109218b44dSGal Pressman { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_mpwqe_filler) }, 1119218b44dSGal Pressman { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_buff_alloc_err) }, 1127219ab34STariq Toukan { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_cqe_compress_blks) }, 1137219ab34STariq Toukan { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_cqe_compress_pkts) }, 1144415a031STariq Toukan { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_cache_reuse) }, 1154415a031STariq Toukan { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_cache_full) }, 1164415a031STariq Toukan { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_cache_empty) }, 1174415a031STariq Toukan { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_cache_busy) }, 118bfe6d8d1SGal Pressman { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, link_down_events_phy) }, 1199218b44dSGal Pressman }; 1209218b44dSGal Pressman 1219218b44dSGal Pressman struct mlx5e_qcounter_stats { 1229218b44dSGal Pressman u32 rx_out_of_buffer; 1239218b44dSGal Pressman }; 1249218b44dSGal Pressman 1259218b44dSGal Pressman static const struct counter_desc q_stats_desc[] = { 1269218b44dSGal Pressman { MLX5E_DECLARE_STAT(struct mlx5e_qcounter_stats, rx_out_of_buffer) }, 1279218b44dSGal Pressman }; 1289218b44dSGal Pressman 1299218b44dSGal Pressman #define VPORT_COUNTER_OFF(c) MLX5_BYTE_OFF(query_vport_counter_out, c) 1309218b44dSGal Pressman #define VPORT_COUNTER_GET(vstats, c) MLX5_GET64(query_vport_counter_out, \ 1319218b44dSGal Pressman vstats->query_vport_out, c) 1329218b44dSGal Pressman 1339218b44dSGal Pressman struct mlx5e_vport_stats { 1349218b44dSGal Pressman __be64 query_vport_out[MLX5_ST_SZ_QW(query_vport_counter_out)]; 1359218b44dSGal Pressman }; 1369218b44dSGal Pressman 1379218b44dSGal Pressman static const struct counter_desc vport_stats_desc[] = { 1388075cb72SGal Pressman { "rx_vport_unicast_packets", 1399218b44dSGal Pressman VPORT_COUNTER_OFF(received_eth_unicast.packets) }, 1408075cb72SGal Pressman { "rx_vport_unicast_bytes", 1418075cb72SGal Pressman VPORT_COUNTER_OFF(received_eth_unicast.octets) }, 1428075cb72SGal Pressman { "tx_vport_unicast_packets", 1439218b44dSGal Pressman VPORT_COUNTER_OFF(transmitted_eth_unicast.packets) }, 1448075cb72SGal Pressman { "tx_vport_unicast_bytes", 1459218b44dSGal Pressman VPORT_COUNTER_OFF(transmitted_eth_unicast.octets) }, 1468075cb72SGal Pressman { "rx_vport_multicast_packets", 1479218b44dSGal Pressman VPORT_COUNTER_OFF(received_eth_multicast.packets) }, 1488075cb72SGal Pressman { "rx_vport_multicast_bytes", 1499218b44dSGal Pressman VPORT_COUNTER_OFF(received_eth_multicast.octets) }, 1508075cb72SGal Pressman { "tx_vport_multicast_packets", 1519218b44dSGal Pressman VPORT_COUNTER_OFF(transmitted_eth_multicast.packets) }, 1528075cb72SGal Pressman { "tx_vport_multicast_bytes", 1539218b44dSGal Pressman VPORT_COUNTER_OFF(transmitted_eth_multicast.octets) }, 1548075cb72SGal Pressman { "rx_vport_broadcast_packets", 1559218b44dSGal Pressman VPORT_COUNTER_OFF(received_eth_broadcast.packets) }, 1568075cb72SGal Pressman { "rx_vport_broadcast_bytes", 1579218b44dSGal Pressman VPORT_COUNTER_OFF(received_eth_broadcast.octets) }, 1588075cb72SGal Pressman { "tx_vport_broadcast_packets", 1599218b44dSGal Pressman VPORT_COUNTER_OFF(transmitted_eth_broadcast.packets) }, 1608075cb72SGal Pressman { "tx_vport_broadcast_bytes", 1619218b44dSGal Pressman VPORT_COUNTER_OFF(transmitted_eth_broadcast.octets) }, 162fe6b9bd9SGal Pressman { "rx_vport_rdma_unicast_packets", 163fe6b9bd9SGal Pressman VPORT_COUNTER_OFF(received_ib_unicast.packets) }, 164fe6b9bd9SGal Pressman { "rx_vport_rdma_unicast_bytes", 165fe6b9bd9SGal Pressman VPORT_COUNTER_OFF(received_ib_unicast.octets) }, 166fe6b9bd9SGal Pressman { "tx_vport_rdma_unicast_packets", 167fe6b9bd9SGal Pressman VPORT_COUNTER_OFF(transmitted_ib_unicast.packets) }, 168fe6b9bd9SGal Pressman { "tx_vport_rdma_unicast_bytes", 169fe6b9bd9SGal Pressman VPORT_COUNTER_OFF(transmitted_ib_unicast.octets) }, 170fe6b9bd9SGal Pressman { "rx_vport_rdma_multicast_packets", 171fe6b9bd9SGal Pressman VPORT_COUNTER_OFF(received_ib_multicast.packets) }, 172fe6b9bd9SGal Pressman { "rx_vport_rdma_multicast_bytes", 173fe6b9bd9SGal Pressman VPORT_COUNTER_OFF(received_ib_multicast.octets) }, 174fe6b9bd9SGal Pressman { "tx_vport_rdma_multicast_packets", 175fe6b9bd9SGal Pressman VPORT_COUNTER_OFF(transmitted_ib_multicast.packets) }, 176fe6b9bd9SGal Pressman { "tx_vport_rdma_multicast_bytes", 177fe6b9bd9SGal Pressman VPORT_COUNTER_OFF(transmitted_ib_multicast.octets) }, 1789218b44dSGal Pressman }; 1799218b44dSGal Pressman 1809218b44dSGal Pressman #define PPORT_802_3_OFF(c) \ 1819218b44dSGal Pressman MLX5_BYTE_OFF(ppcnt_reg, \ 1829218b44dSGal Pressman counter_set.eth_802_3_cntrs_grp_data_layout.c##_high) 1839218b44dSGal Pressman #define PPORT_802_3_GET(pstats, c) \ 1849218b44dSGal Pressman MLX5_GET64(ppcnt_reg, pstats->IEEE_802_3_counters, \ 1859218b44dSGal Pressman counter_set.eth_802_3_cntrs_grp_data_layout.c##_high) 1869218b44dSGal Pressman #define PPORT_2863_OFF(c) \ 1879218b44dSGal Pressman MLX5_BYTE_OFF(ppcnt_reg, \ 1889218b44dSGal Pressman counter_set.eth_2863_cntrs_grp_data_layout.c##_high) 1899218b44dSGal Pressman #define PPORT_2863_GET(pstats, c) \ 1909218b44dSGal Pressman MLX5_GET64(ppcnt_reg, pstats->RFC_2863_counters, \ 1919218b44dSGal Pressman counter_set.eth_2863_cntrs_grp_data_layout.c##_high) 1929218b44dSGal Pressman #define PPORT_2819_OFF(c) \ 1939218b44dSGal Pressman MLX5_BYTE_OFF(ppcnt_reg, \ 1949218b44dSGal Pressman counter_set.eth_2819_cntrs_grp_data_layout.c##_high) 1959218b44dSGal Pressman #define PPORT_2819_GET(pstats, c) \ 1969218b44dSGal Pressman MLX5_GET64(ppcnt_reg, pstats->RFC_2819_counters, \ 1979218b44dSGal Pressman counter_set.eth_2819_cntrs_grp_data_layout.c##_high) 198cf678570SGal Pressman #define PPORT_PER_PRIO_OFF(c) \ 199cf678570SGal Pressman MLX5_BYTE_OFF(ppcnt_reg, \ 200cf678570SGal Pressman counter_set.eth_per_prio_grp_data_layout.c##_high) 201cf678570SGal Pressman #define PPORT_PER_PRIO_GET(pstats, prio, c) \ 202cf678570SGal Pressman MLX5_GET64(ppcnt_reg, pstats->per_prio_counters[prio], \ 203cf678570SGal Pressman counter_set.eth_per_prio_grp_data_layout.c##_high) 204cf678570SGal Pressman #define NUM_PPORT_PRIO 8 2059218b44dSGal Pressman 2069218b44dSGal Pressman struct mlx5e_pport_stats { 2079218b44dSGal Pressman __be64 IEEE_802_3_counters[MLX5_ST_SZ_QW(ppcnt_reg)]; 2089218b44dSGal Pressman __be64 RFC_2863_counters[MLX5_ST_SZ_QW(ppcnt_reg)]; 2099218b44dSGal Pressman __be64 RFC_2819_counters[MLX5_ST_SZ_QW(ppcnt_reg)]; 210cf678570SGal Pressman __be64 per_prio_counters[NUM_PPORT_PRIO][MLX5_ST_SZ_QW(ppcnt_reg)]; 211121fcdc8SGal Pressman __be64 phy_counters[MLX5_ST_SZ_QW(ppcnt_reg)]; 2129218b44dSGal Pressman }; 2139218b44dSGal Pressman 2149218b44dSGal Pressman static const struct counter_desc pport_802_3_stats_desc[] = { 215bfe6d8d1SGal Pressman { "tx_packets_phy", PPORT_802_3_OFF(a_frames_transmitted_ok) }, 216bfe6d8d1SGal Pressman { "rx_packets_phy", PPORT_802_3_OFF(a_frames_received_ok) }, 217bfe6d8d1SGal Pressman { "rx_crc_errors_phy", PPORT_802_3_OFF(a_frame_check_sequence_errors) }, 218bfe6d8d1SGal Pressman { "tx_bytes_phy", PPORT_802_3_OFF(a_octets_transmitted_ok) }, 219bfe6d8d1SGal Pressman { "rx_bytes_phy", PPORT_802_3_OFF(a_octets_received_ok) }, 220bfe6d8d1SGal Pressman { "tx_multicast_phy", PPORT_802_3_OFF(a_multicast_frames_xmitted_ok) }, 221bfe6d8d1SGal Pressman { "tx_broadcast_phy", PPORT_802_3_OFF(a_broadcast_frames_xmitted_ok) }, 222bfe6d8d1SGal Pressman { "rx_multicast_phy", PPORT_802_3_OFF(a_multicast_frames_received_ok) }, 223bfe6d8d1SGal Pressman { "rx_broadcast_phy", PPORT_802_3_OFF(a_broadcast_frames_received_ok) }, 224bfe6d8d1SGal Pressman { "rx_in_range_len_errors_phy", PPORT_802_3_OFF(a_in_range_length_errors) }, 225bfe6d8d1SGal Pressman { "rx_out_of_range_len_phy", PPORT_802_3_OFF(a_out_of_range_length_field) }, 226bfe6d8d1SGal Pressman { "rx_oversize_pkts_phy", PPORT_802_3_OFF(a_frame_too_long_errors) }, 227bfe6d8d1SGal Pressman { "rx_symbol_err_phy", PPORT_802_3_OFF(a_symbol_error_during_carrier) }, 228bfe6d8d1SGal Pressman { "tx_mac_control_phy", PPORT_802_3_OFF(a_mac_control_frames_transmitted) }, 229bfe6d8d1SGal Pressman { "rx_mac_control_phy", PPORT_802_3_OFF(a_mac_control_frames_received) }, 230bfe6d8d1SGal Pressman { "rx_unsupported_op_phy", PPORT_802_3_OFF(a_unsupported_opcodes_received) }, 231bfe6d8d1SGal Pressman { "rx_pause_ctrl_phy", PPORT_802_3_OFF(a_pause_mac_ctrl_frames_received) }, 232bfe6d8d1SGal Pressman { "tx_pause_ctrl_phy", PPORT_802_3_OFF(a_pause_mac_ctrl_frames_transmitted) }, 2339218b44dSGal Pressman }; 2349218b44dSGal Pressman 2359218b44dSGal Pressman static const struct counter_desc pport_2863_stats_desc[] = { 236bfe6d8d1SGal Pressman { "rx_discards_phy", PPORT_2863_OFF(if_in_discards) }, 237bfe6d8d1SGal Pressman { "tx_discards_phy", PPORT_2863_OFF(if_out_discards) }, 238bfe6d8d1SGal Pressman { "tx_errors_phy", PPORT_2863_OFF(if_out_errors) }, 2399218b44dSGal Pressman }; 2409218b44dSGal Pressman 2419218b44dSGal Pressman static const struct counter_desc pport_2819_stats_desc[] = { 242bfe6d8d1SGal Pressman { "rx_undersize_pkts_phy", PPORT_2819_OFF(ether_stats_undersize_pkts) }, 243bfe6d8d1SGal Pressman { "rx_fragments_phy", PPORT_2819_OFF(ether_stats_fragments) }, 244bfe6d8d1SGal Pressman { "rx_jabbers_phy", PPORT_2819_OFF(ether_stats_jabbers) }, 245bfe6d8d1SGal Pressman { "rx_64_bytes_phy", PPORT_2819_OFF(ether_stats_pkts64octets) }, 246bfe6d8d1SGal Pressman { "rx_65_to_127_bytes_phy", PPORT_2819_OFF(ether_stats_pkts65to127octets) }, 247bfe6d8d1SGal Pressman { "rx_128_to_255_bytes_phy", PPORT_2819_OFF(ether_stats_pkts128to255octets) }, 248bfe6d8d1SGal Pressman { "rx_256_to_511_bytes_phy", PPORT_2819_OFF(ether_stats_pkts256to511octets) }, 249bfe6d8d1SGal Pressman { "rx_512_to_1023_bytes_phy", PPORT_2819_OFF(ether_stats_pkts512to1023octets) }, 250bfe6d8d1SGal Pressman { "rx_1024_to_1518_bytes_phy", PPORT_2819_OFF(ether_stats_pkts1024to1518octets) }, 251bfe6d8d1SGal Pressman { "rx_1519_to_2047_bytes_phy", PPORT_2819_OFF(ether_stats_pkts1519to2047octets) }, 252bfe6d8d1SGal Pressman { "rx_2048_to_4095_bytes_phy", PPORT_2819_OFF(ether_stats_pkts2048to4095octets) }, 253bfe6d8d1SGal Pressman { "rx_4096_to_8191_bytes_phy", PPORT_2819_OFF(ether_stats_pkts4096to8191octets) }, 254bfe6d8d1SGal Pressman { "rx_8192_to_10239_bytes_phy", PPORT_2819_OFF(ether_stats_pkts8192to10239octets) }, 2559218b44dSGal Pressman }; 2569218b44dSGal Pressman 257cf678570SGal Pressman static const struct counter_desc pport_per_prio_traffic_stats_desc[] = { 258bfe6d8d1SGal Pressman { "rx_prio%d_bytes", PPORT_PER_PRIO_OFF(rx_octets) }, 259bfe6d8d1SGal Pressman { "rx_prio%d_packets", PPORT_PER_PRIO_OFF(rx_frames) }, 260bfe6d8d1SGal Pressman { "tx_prio%d_bytes", PPORT_PER_PRIO_OFF(tx_octets) }, 261bfe6d8d1SGal Pressman { "tx_prio%d_packets", PPORT_PER_PRIO_OFF(tx_frames) }, 262cf678570SGal Pressman }; 263cf678570SGal Pressman 264cf678570SGal Pressman static const struct counter_desc pport_per_prio_pfc_stats_desc[] = { 265e989d5a5SGal Pressman /* %s is "global" or "prio{i}" */ 266e989d5a5SGal Pressman { "rx_%s_pause", PPORT_PER_PRIO_OFF(rx_pause) }, 267e989d5a5SGal Pressman { "rx_%s_pause_duration", PPORT_PER_PRIO_OFF(rx_pause_duration) }, 268e989d5a5SGal Pressman { "tx_%s_pause", PPORT_PER_PRIO_OFF(tx_pause) }, 269e989d5a5SGal Pressman { "tx_%s_pause_duration", PPORT_PER_PRIO_OFF(tx_pause_duration) }, 270e989d5a5SGal Pressman { "rx_%s_pause_transition", PPORT_PER_PRIO_OFF(rx_pause_transition) }, 271cf678570SGal Pressman }; 272cf678570SGal Pressman 2739218b44dSGal Pressman struct mlx5e_rq_stats { 2749218b44dSGal Pressman u64 packets; 2759218b44dSGal Pressman u64 bytes; 276bfe6d8d1SGal Pressman u64 csum_complete; 277bfe6d8d1SGal Pressman u64 csum_unnecessary_inner; 2781b223dd3SSaeed Mahameed u64 csum_none; 2799218b44dSGal Pressman u64 lro_packets; 2809218b44dSGal Pressman u64 lro_bytes; 2819218b44dSGal Pressman u64 wqe_err; 2829218b44dSGal Pressman u64 mpwqe_filler; 2839218b44dSGal Pressman u64 buff_alloc_err; 2847219ab34STariq Toukan u64 cqe_compress_blks; 2857219ab34STariq Toukan u64 cqe_compress_pkts; 2864415a031STariq Toukan u64 cache_reuse; 2874415a031STariq Toukan u64 cache_full; 2884415a031STariq Toukan u64 cache_empty; 2894415a031STariq Toukan u64 cache_busy; 2909218b44dSGal Pressman }; 2919218b44dSGal Pressman 2929218b44dSGal Pressman static const struct counter_desc rq_stats_desc[] = { 293bfe6d8d1SGal Pressman { MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, packets) }, 294bfe6d8d1SGal Pressman { MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, bytes) }, 295bfe6d8d1SGal Pressman { MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, csum_complete) }, 296bfe6d8d1SGal Pressman { MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, csum_unnecessary_inner) }, 297bfe6d8d1SGal Pressman { MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, csum_none) }, 298bfe6d8d1SGal Pressman { MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, lro_packets) }, 299bfe6d8d1SGal Pressman { MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, lro_bytes) }, 300bfe6d8d1SGal Pressman { MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, wqe_err) }, 301bfe6d8d1SGal Pressman { MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, mpwqe_filler) }, 302bfe6d8d1SGal Pressman { MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, buff_alloc_err) }, 303bfe6d8d1SGal Pressman { MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, cqe_compress_blks) }, 304bfe6d8d1SGal Pressman { MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, cqe_compress_pkts) }, 3054415a031STariq Toukan { MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, cache_reuse) }, 3064415a031STariq Toukan { MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, cache_full) }, 3074415a031STariq Toukan { MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, cache_empty) }, 3084415a031STariq Toukan { MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, cache_busy) }, 3099218b44dSGal Pressman }; 3109218b44dSGal Pressman 3119218b44dSGal Pressman struct mlx5e_sq_stats { 3129218b44dSGal Pressman /* commonly accessed in data path */ 3139218b44dSGal Pressman u64 packets; 3149218b44dSGal Pressman u64 bytes; 315c8cf78feSTariq Toukan u64 xmit_more; 3169218b44dSGal Pressman u64 tso_packets; 3179218b44dSGal Pressman u64 tso_bytes; 3189218b44dSGal Pressman u64 tso_inner_packets; 3199218b44dSGal Pressman u64 tso_inner_bytes; 320bfe6d8d1SGal Pressman u64 csum_partial_inner; 3219218b44dSGal Pressman u64 nop; 3229218b44dSGal Pressman /* less likely accessed in data path */ 323bfe6d8d1SGal Pressman u64 csum_none; 3249218b44dSGal Pressman u64 stopped; 3259218b44dSGal Pressman u64 wake; 3269218b44dSGal Pressman u64 dropped; 3279218b44dSGal Pressman }; 3289218b44dSGal Pressman 3299218b44dSGal Pressman static const struct counter_desc sq_stats_desc[] = { 330bfe6d8d1SGal Pressman { MLX5E_DECLARE_TX_STAT(struct mlx5e_sq_stats, packets) }, 331bfe6d8d1SGal Pressman { MLX5E_DECLARE_TX_STAT(struct mlx5e_sq_stats, bytes) }, 332bfe6d8d1SGal Pressman { MLX5E_DECLARE_TX_STAT(struct mlx5e_sq_stats, tso_packets) }, 333bfe6d8d1SGal Pressman { MLX5E_DECLARE_TX_STAT(struct mlx5e_sq_stats, tso_bytes) }, 334bfe6d8d1SGal Pressman { MLX5E_DECLARE_TX_STAT(struct mlx5e_sq_stats, tso_inner_packets) }, 335bfe6d8d1SGal Pressman { MLX5E_DECLARE_TX_STAT(struct mlx5e_sq_stats, tso_inner_bytes) }, 336bfe6d8d1SGal Pressman { MLX5E_DECLARE_TX_STAT(struct mlx5e_sq_stats, csum_partial_inner) }, 337bfe6d8d1SGal Pressman { MLX5E_DECLARE_TX_STAT(struct mlx5e_sq_stats, nop) }, 338bfe6d8d1SGal Pressman { MLX5E_DECLARE_TX_STAT(struct mlx5e_sq_stats, csum_none) }, 339bfe6d8d1SGal Pressman { MLX5E_DECLARE_TX_STAT(struct mlx5e_sq_stats, stopped) }, 340bfe6d8d1SGal Pressman { MLX5E_DECLARE_TX_STAT(struct mlx5e_sq_stats, wake) }, 341bfe6d8d1SGal Pressman { MLX5E_DECLARE_TX_STAT(struct mlx5e_sq_stats, dropped) }, 342c8cf78feSTariq Toukan { MLX5E_DECLARE_TX_STAT(struct mlx5e_sq_stats, xmit_more) }, 3439218b44dSGal Pressman }; 3449218b44dSGal Pressman 3459218b44dSGal Pressman #define NUM_SW_COUNTERS ARRAY_SIZE(sw_stats_desc) 3469218b44dSGal Pressman #define NUM_Q_COUNTERS ARRAY_SIZE(q_stats_desc) 3479218b44dSGal Pressman #define NUM_VPORT_COUNTERS ARRAY_SIZE(vport_stats_desc) 3489218b44dSGal Pressman #define NUM_PPORT_802_3_COUNTERS ARRAY_SIZE(pport_802_3_stats_desc) 3499218b44dSGal Pressman #define NUM_PPORT_2863_COUNTERS ARRAY_SIZE(pport_2863_stats_desc) 3509218b44dSGal Pressman #define NUM_PPORT_2819_COUNTERS ARRAY_SIZE(pport_2819_stats_desc) 351cf678570SGal Pressman #define NUM_PPORT_PER_PRIO_TRAFFIC_COUNTERS \ 352cf678570SGal Pressman ARRAY_SIZE(pport_per_prio_traffic_stats_desc) 353cf678570SGal Pressman #define NUM_PPORT_PER_PRIO_PFC_COUNTERS \ 354cf678570SGal Pressman ARRAY_SIZE(pport_per_prio_pfc_stats_desc) 3559218b44dSGal Pressman #define NUM_PPORT_COUNTERS (NUM_PPORT_802_3_COUNTERS + \ 3569218b44dSGal Pressman NUM_PPORT_2863_COUNTERS + \ 357cf678570SGal Pressman NUM_PPORT_2819_COUNTERS + \ 358cf678570SGal Pressman NUM_PPORT_PER_PRIO_TRAFFIC_COUNTERS * \ 359cf678570SGal Pressman NUM_PPORT_PRIO) 3609218b44dSGal Pressman #define NUM_RQ_STATS ARRAY_SIZE(rq_stats_desc) 3619218b44dSGal Pressman #define NUM_SQ_STATS ARRAY_SIZE(sq_stats_desc) 3629218b44dSGal Pressman 3639218b44dSGal Pressman struct mlx5e_stats { 3649218b44dSGal Pressman struct mlx5e_sw_stats sw; 3659218b44dSGal Pressman struct mlx5e_qcounter_stats qcnt; 3669218b44dSGal Pressman struct mlx5e_vport_stats vport; 3679218b44dSGal Pressman struct mlx5e_pport_stats pport; 3689218b44dSGal Pressman }; 3699218b44dSGal Pressman 3709218b44dSGal Pressman #endif /* __MLX5_EN_STATS_H__ */ 371