2 * Copyright (c) 2015-2016, Mellanox Technologies. All rights reserved.
4 * This software is available to you under a choice of one of two
5 * licenses. You may choose to be licensed under the terms of the GNU
6 * General Public License (GPL) Version 2, available from the file
7 * COPYING in the main directory of this source tree, or the
8 * OpenIB.org BSD license below:
10 * Redistribution and use in source and binary forms, with or
11 * without modification, are permitted provided that the following
14 * - Redistributions of source code must retain the above
15 * copyright notice, this list of conditions and the following
18 * - Redistributions in binary form must reproduce the above
19 * copyright notice, this list of conditions and the following
20 * disclaimer in the documentation and/or other materials
21 * provided with the distribution.
23 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
27 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
28 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
29 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
33 #ifndef __MLX5_EN_STATS_H__
34 #define __MLX5_EN_STATS_H__
36 #define MLX5E_READ_CTR64_CPU(ptr, dsc, i) \
37 (*(u64 *)((char *)ptr + dsc[i].offset))
38 #define MLX5E_READ_CTR64_BE(ptr, dsc, i) \
39 be64_to_cpu(*(__be64 *)((char *)ptr + dsc[i].offset))
40 #define MLX5E_READ_CTR32_CPU(ptr, dsc, i) \
41 (*(u32 *)((char *)ptr + dsc[i].offset))
42 #define MLX5E_READ_CTR32_BE(ptr, dsc, i) \
43 be32_to_cpu(*(__be32 *)((char *)ptr + dsc[i].offset))
45 #define MLX5E_DECLARE_STAT(type, fld) #fld, offsetof(type, fld)
46 #define MLX5E_DECLARE_RX_STAT(type, fld) "rx%d_"#fld, offsetof(type, fld)
47 #define MLX5E_DECLARE_TX_STAT(type, fld) "tx%d_"#fld, offsetof(type, fld)
48 #define MLX5E_DECLARE_XDPSQ_STAT(type, fld) "tx%d_xdp_"#fld, offsetof(type, fld)
49 #define MLX5E_DECLARE_RQ_XDPSQ_STAT(type, fld) "rx%d_xdp_tx_"#fld, offsetof(type, fld)
50 #define MLX5E_DECLARE_XSKRQ_STAT(type, fld) "rx%d_xsk_"#fld, offsetof(type, fld)
51 #define MLX5E_DECLARE_XSKSQ_STAT(type, fld) "tx%d_xsk_"#fld, offsetof(type, fld)
52 #define MLX5E_DECLARE_CH_STAT(type, fld) "ch%d_"#fld, offsetof(type, fld)
54 #define MLX5E_DECLARE_PTP_TX_STAT(type, fld) "ptp_tx%d_"#fld, offsetof(type, fld)
55 #define MLX5E_DECLARE_PTP_CH_STAT(type, fld) "ptp_ch_"#fld, offsetof(type, fld)
56 #define MLX5E_DECLARE_PTP_CQ_STAT(type, fld) "ptp_cq%d_"#fld, offsetof(type, fld)
59 char format[ETH_GSTRING_LEN];
60 size_t offset; /* Byte offset */
64 MLX5E_NDO_UPDATE_STATS = BIT(0x1),
68 struct mlx5e_stats_grp {
69 u16 update_stats_mask;
70 int (*get_num_stats)(struct mlx5e_priv *priv);
71 int (*fill_strings)(struct mlx5e_priv *priv, u8 *data, int idx);
72 int (*fill_stats)(struct mlx5e_priv *priv, u64 *data, int idx);
73 void (*update_stats)(struct mlx5e_priv *priv);
76 typedef const struct mlx5e_stats_grp *const mlx5e_stats_grp_t;
78 #define MLX5E_STATS_GRP_OP(grp, name) mlx5e_stats_grp_ ## grp ## _ ## name
80 #define MLX5E_DECLARE_STATS_GRP_OP_NUM_STATS(grp) \
81 int MLX5E_STATS_GRP_OP(grp, num_stats)(struct mlx5e_priv *priv)
83 #define MLX5E_DECLARE_STATS_GRP_OP_UPDATE_STATS(grp) \
84 void MLX5E_STATS_GRP_OP(grp, update_stats)(struct mlx5e_priv *priv)
86 #define MLX5E_DECLARE_STATS_GRP_OP_FILL_STRS(grp) \
87 int MLX5E_STATS_GRP_OP(grp, fill_strings)(struct mlx5e_priv *priv, u8 *data, int idx)
89 #define MLX5E_DECLARE_STATS_GRP_OP_FILL_STATS(grp) \
90 int MLX5E_STATS_GRP_OP(grp, fill_stats)(struct mlx5e_priv *priv, u64 *data, int idx)
92 #define MLX5E_STATS_GRP(grp) mlx5e_stats_grp_ ## grp
94 #define MLX5E_DECLARE_STATS_GRP(grp) \
95 const struct mlx5e_stats_grp MLX5E_STATS_GRP(grp)
97 #define MLX5E_DEFINE_STATS_GRP(grp, mask) \
98 MLX5E_DECLARE_STATS_GRP(grp) = { \
99 .get_num_stats = MLX5E_STATS_GRP_OP(grp, num_stats), \
100 .fill_stats = MLX5E_STATS_GRP_OP(grp, fill_stats), \
101 .fill_strings = MLX5E_STATS_GRP_OP(grp, fill_strings), \
102 .update_stats = MLX5E_STATS_GRP_OP(grp, update_stats), \
103 .update_stats_mask = mask, \
106 unsigned int mlx5e_stats_total_num(struct mlx5e_priv *priv);
107 void mlx5e_stats_update(struct mlx5e_priv *priv);
108 void mlx5e_stats_fill(struct mlx5e_priv *priv, u64 *data, int idx);
109 void mlx5e_stats_fill_strings(struct mlx5e_priv *priv, u8 *data);
110 void mlx5e_stats_update_ndo_stats(struct mlx5e_priv *priv);
112 void mlx5e_stats_pause_get(struct mlx5e_priv *priv,
113 struct ethtool_pause_stats *pause_stats);
115 /* Concrete NIC Stats */
117 struct mlx5e_sw_stats {
124 u64 tx_tso_inner_packets;
125 u64 tx_tso_inner_bytes;
126 u64 tx_added_vlan_packets;
132 u64 rx_mcast_packets;
134 u64 rx_removed_vlan_packets;
135 u64 rx_csum_unnecessary;
137 u64 rx_csum_complete;
138 u64 rx_csum_complete_tail;
139 u64 rx_csum_complete_tail_slow;
140 u64 rx_csum_unnecessary_inner;
152 u64 tx_csum_partial_inner;
153 u64 tx_queue_stopped;
154 u64 tx_queue_dropped;
168 u64 rx_mpwqe_filler_cqes;
169 u64 rx_mpwqe_filler_strides;
170 u64 rx_oversize_pkts_sw_drop;
171 u64 rx_buff_alloc_err;
172 u64 rx_cqe_compress_blks;
173 u64 rx_cqe_compress_pkts;
189 #ifdef CONFIG_MLX5_EN_TLS
190 u64 tx_tls_encrypted_packets;
191 u64 tx_tls_encrypted_bytes;
194 u64 tx_tls_dump_packets;
195 u64 tx_tls_dump_bytes;
196 u64 tx_tls_resync_bytes;
197 u64 tx_tls_skip_no_sync_data;
198 u64 tx_tls_drop_no_sync_data;
199 u64 tx_tls_drop_bypass_req;
201 u64 rx_tls_decrypted_packets;
202 u64 rx_tls_decrypted_bytes;
205 u64 rx_tls_resync_req_pkt;
206 u64 rx_tls_resync_req_start;
207 u64 rx_tls_resync_req_end;
208 u64 rx_tls_resync_req_skip;
209 u64 rx_tls_resync_res_ok;
210 u64 rx_tls_resync_res_skip;
216 u64 rx_xsk_csum_complete;
217 u64 rx_xsk_csum_unnecessary;
218 u64 rx_xsk_csum_unnecessary_inner;
219 u64 rx_xsk_csum_none;
221 u64 rx_xsk_removed_vlan_packets;
223 u64 rx_xsk_xdp_redirect;
225 u64 rx_xsk_mpwqe_filler_cqes;
226 u64 rx_xsk_mpwqe_filler_strides;
227 u64 rx_xsk_oversize_pkts_sw_drop;
228 u64 rx_xsk_buff_alloc_err;
229 u64 rx_xsk_cqe_compress_blks;
230 u64 rx_xsk_cqe_compress_pkts;
231 u64 rx_xsk_congst_umr;
241 struct mlx5e_qcounter_stats {
242 u32 rx_out_of_buffer;
243 u32 rx_if_down_packets;
246 struct mlx5e_vnic_env_stats {
247 __be64 query_vnic_env_out[MLX5_ST_SZ_QW(query_vnic_env_out)];
250 #define VPORT_COUNTER_GET(vstats, c) MLX5_GET64(query_vport_counter_out, \
251 vstats->query_vport_out, c)
253 struct mlx5e_vport_stats {
254 __be64 query_vport_out[MLX5_ST_SZ_QW(query_vport_counter_out)];
257 #define PPORT_802_3_GET(pstats, c) \
258 MLX5_GET64(ppcnt_reg, pstats->IEEE_802_3_counters, \
259 counter_set.eth_802_3_cntrs_grp_data_layout.c##_high)
260 #define PPORT_2863_GET(pstats, c) \
261 MLX5_GET64(ppcnt_reg, pstats->RFC_2863_counters, \
262 counter_set.eth_2863_cntrs_grp_data_layout.c##_high)
263 #define PPORT_2819_GET(pstats, c) \
264 MLX5_GET64(ppcnt_reg, pstats->RFC_2819_counters, \
265 counter_set.eth_2819_cntrs_grp_data_layout.c##_high)
266 #define PPORT_PHY_STATISTICAL_GET(pstats, c) \
267 MLX5_GET64(ppcnt_reg, (pstats)->phy_statistical_counters, \
268 counter_set.phys_layer_statistical_cntrs.c##_high)
269 #define PPORT_PER_PRIO_GET(pstats, prio, c) \
270 MLX5_GET64(ppcnt_reg, pstats->per_prio_counters[prio], \
271 counter_set.eth_per_prio_grp_data_layout.c##_high)
272 #define NUM_PPORT_PRIO 8
273 #define PPORT_ETH_EXT_GET(pstats, c) \
274 MLX5_GET64(ppcnt_reg, (pstats)->eth_ext_counters, \
275 counter_set.eth_extended_cntrs_grp_data_layout.c##_high)
277 struct mlx5e_pport_stats {
278 __be64 IEEE_802_3_counters[MLX5_ST_SZ_QW(ppcnt_reg)];
279 __be64 RFC_2863_counters[MLX5_ST_SZ_QW(ppcnt_reg)];
280 __be64 RFC_2819_counters[MLX5_ST_SZ_QW(ppcnt_reg)];
281 __be64 per_prio_counters[NUM_PPORT_PRIO][MLX5_ST_SZ_QW(ppcnt_reg)];
282 __be64 phy_counters[MLX5_ST_SZ_QW(ppcnt_reg)];
283 __be64 phy_statistical_counters[MLX5_ST_SZ_QW(ppcnt_reg)];
284 __be64 eth_ext_counters[MLX5_ST_SZ_QW(ppcnt_reg)];
285 __be64 per_tc_prio_counters[NUM_PPORT_PRIO][MLX5_ST_SZ_QW(ppcnt_reg)];
286 __be64 per_tc_congest_prio_counters[NUM_PPORT_PRIO][MLX5_ST_SZ_QW(ppcnt_reg)];
289 #define PCIE_PERF_GET(pcie_stats, c) \
290 MLX5_GET(mpcnt_reg, (pcie_stats)->pcie_perf_counters, \
291 counter_set.pcie_perf_cntrs_grp_data_layout.c)
293 #define PCIE_PERF_GET64(pcie_stats, c) \
294 MLX5_GET64(mpcnt_reg, (pcie_stats)->pcie_perf_counters, \
295 counter_set.pcie_perf_cntrs_grp_data_layout.c##_high)
297 struct mlx5e_pcie_stats {
298 __be64 pcie_perf_counters[MLX5_ST_SZ_QW(mpcnt_reg)];
301 struct mlx5e_rq_stats {
305 u64 csum_complete_tail;
306 u64 csum_complete_tail_slow;
307 u64 csum_unnecessary;
308 u64 csum_unnecessary_inner;
314 u64 removed_vlan_packets;
318 u64 mpwqe_filler_cqes;
319 u64 mpwqe_filler_strides;
320 u64 oversize_pkts_sw_drop;
322 u64 cqe_compress_blks;
323 u64 cqe_compress_pkts;
332 #ifdef CONFIG_MLX5_EN_TLS
333 u64 tls_decrypted_packets;
334 u64 tls_decrypted_bytes;
337 u64 tls_resync_req_pkt;
338 u64 tls_resync_req_start;
339 u64 tls_resync_req_end;
340 u64 tls_resync_req_skip;
341 u64 tls_resync_res_ok;
342 u64 tls_resync_res_skip;
347 struct mlx5e_sq_stats {
348 /* commonly accessed in data path */
354 u64 tso_inner_packets;
357 u64 csum_partial_inner;
358 u64 added_vlan_packets;
362 #ifdef CONFIG_MLX5_EN_TLS
363 u64 tls_encrypted_packets;
364 u64 tls_encrypted_bytes;
367 u64 tls_dump_packets;
369 u64 tls_resync_bytes;
370 u64 tls_skip_no_sync_data;
371 u64 tls_drop_no_sync_data;
372 u64 tls_drop_bypass_req;
374 /* less likely accessed in data path */
379 /* dirtied @completion */
380 u64 cqes ____cacheline_aligned_in_smp;
385 struct mlx5e_xdpsq_stats {
392 /* dirtied @completion */
393 u64 cqes ____cacheline_aligned_in_smp;
396 struct mlx5e_ch_stats {
405 struct mlx5e_ptp_cq_stats {
409 u64 abort_abs_diff_ns;
413 struct mlx5e_sw_stats sw;
414 struct mlx5e_qcounter_stats qcnt;
415 struct mlx5e_vnic_env_stats vnic;
416 struct mlx5e_vport_stats vport;
417 struct mlx5e_pport_stats pport;
418 struct rtnl_link_stats64 vf_vport;
419 struct mlx5e_pcie_stats pcie;
422 extern mlx5e_stats_grp_t mlx5e_nic_stats_grps[];
423 unsigned int mlx5e_nic_stats_grps_num(struct mlx5e_priv *priv);
425 extern MLX5E_DECLARE_STATS_GRP(sw);
426 extern MLX5E_DECLARE_STATS_GRP(qcnt);
427 extern MLX5E_DECLARE_STATS_GRP(vnic_env);
428 extern MLX5E_DECLARE_STATS_GRP(vport);
429 extern MLX5E_DECLARE_STATS_GRP(802_3);
430 extern MLX5E_DECLARE_STATS_GRP(2863);
431 extern MLX5E_DECLARE_STATS_GRP(2819);
432 extern MLX5E_DECLARE_STATS_GRP(phy);
433 extern MLX5E_DECLARE_STATS_GRP(eth_ext);
434 extern MLX5E_DECLARE_STATS_GRP(pcie);
435 extern MLX5E_DECLARE_STATS_GRP(per_prio);
436 extern MLX5E_DECLARE_STATS_GRP(pme);
437 extern MLX5E_DECLARE_STATS_GRP(channels);
438 extern MLX5E_DECLARE_STATS_GRP(per_port_buff_congest);
439 extern MLX5E_DECLARE_STATS_GRP(ipsec_hw);
440 extern MLX5E_DECLARE_STATS_GRP(ipsec_sw);
442 #endif /* __MLX5_EN_STATS_H__ */