]> Git Repo - linux.git/blame - drivers/net/ethernet/mellanox/mlx5/core/en_stats.h
Merge branch 'x86-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel...
[linux.git] / drivers / net / ethernet / mellanox / mlx5 / core / en_stats.h
CommitLineData
9218b44d
GP
1/*
2 * Copyright (c) 2015-2016, Mellanox Technologies. All rights reserved.
3 *
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:
9 *
10 * Redistribution and use in source and binary forms, with or
11 * without modification, are permitted provided that the following
12 * conditions are met:
13 *
14 * - Redistributions of source code must retain the above
15 * copyright notice, this list of conditions and the following
16 * disclaimer.
17 *
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.
22 *
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
30 * SOFTWARE.
31 */
32#ifndef __MLX5_EN_STATS_H__
33#define __MLX5_EN_STATS_H__
34
35#define MLX5E_READ_CTR64_CPU(ptr, dsc, i) \
36 (*(u64 *)((char *)ptr + dsc[i].offset))
37#define MLX5E_READ_CTR64_BE(ptr, dsc, i) \
38 be64_to_cpu(*(__be64 *)((char *)ptr + dsc[i].offset))
39#define MLX5E_READ_CTR32_CPU(ptr, dsc, i) \
40 (*(u32 *)((char *)ptr + dsc[i].offset))
41#define MLX5E_READ_CTR32_BE(ptr, dsc, i) \
0f7f3481 42 be32_to_cpu(*(__be32 *)((char *)ptr + dsc[i].offset))
9218b44d
GP
43
44#define MLX5E_DECLARE_STAT(type, fld) #fld, offsetof(type, fld)
bfe6d8d1
GP
45#define MLX5E_DECLARE_RX_STAT(type, fld) "rx%d_"#fld, offsetof(type, fld)
46#define MLX5E_DECLARE_TX_STAT(type, fld) "tx%d_"#fld, offsetof(type, fld)
58b99ee3 47#define MLX5E_DECLARE_XDPSQ_STAT(type, fld) "tx%d_xdp_"#fld, offsetof(type, fld)
890388ad 48#define MLX5E_DECLARE_RQ_XDPSQ_STAT(type, fld) "rx%d_xdp_tx_"#fld, offsetof(type, fld)
57d689a8 49#define MLX5E_DECLARE_CH_STAT(type, fld) "ch%d_"#fld, offsetof(type, fld)
9218b44d
GP
50
51struct counter_desc {
bfe6d8d1 52 char format[ETH_GSTRING_LEN];
9da5106c 53 size_t offset; /* Byte offset */
9218b44d
GP
54};
55
56struct mlx5e_sw_stats {
57 u64 rx_packets;
58 u64 rx_bytes;
59 u64 tx_packets;
60 u64 tx_bytes;
bfe6d8d1
GP
61 u64 tx_tso_packets;
62 u64 tx_tso_bytes;
63 u64 tx_tso_inner_packets;
64 u64 tx_tso_inner_bytes;
f24686e8 65 u64 tx_added_vlan_packets;
2ad9ecdb 66 u64 tx_nop;
bfe6d8d1
GP
67 u64 rx_lro_packets;
68 u64 rx_lro_bytes;
f007c13d 69 u64 rx_ecn_mark;
f24686e8 70 u64 rx_removed_vlan_packets;
bfe6d8d1 71 u64 rx_csum_unnecessary;
9218b44d 72 u64 rx_csum_none;
bfe6d8d1
GP
73 u64 rx_csum_complete;
74 u64 rx_csum_unnecessary_inner;
86994156 75 u64 rx_xdp_drop;
86690b4b 76 u64 rx_xdp_redirect;
890388ad 77 u64 rx_xdp_tx_xmit;
b5503b99 78 u64 rx_xdp_tx_full;
890388ad
TT
79 u64 rx_xdp_tx_err;
80 u64 rx_xdp_tx_cqe;
603e1f5b 81 u64 tx_csum_none;
bfe6d8d1
GP
82 u64 tx_csum_partial;
83 u64 tx_csum_partial_inner;
9218b44d 84 u64 tx_queue_stopped;
9218b44d 85 u64 tx_queue_dropped;
c8cf78fe 86 u64 tx_xmit_more;
db75373c 87 u64 tx_recover;
86155656 88 u64 tx_cqes;
f65a59ff 89 u64 tx_queue_wake;
bc5a7ccd 90 u64 tx_udp_seg_rem;
f65a59ff 91 u64 tx_cqe_err;
58b99ee3
TT
92 u64 tx_xdp_xmit;
93 u64 tx_xdp_full;
94 u64 tx_xdp_err;
95 u64 tx_xdp_cqes;
9218b44d 96 u64 rx_wqe_err;
b71ba6b4
TT
97 u64 rx_mpwqe_filler_cqes;
98 u64 rx_mpwqe_filler_strides;
0073c8f7 99 u64 rx_oversize_pkts_sw_drop;
9218b44d 100 u64 rx_buff_alloc_err;
7219ab34
TT
101 u64 rx_cqe_compress_blks;
102 u64 rx_cqe_compress_pkts;
accd5883 103 u64 rx_page_reuse;
4415a031
TT
104 u64 rx_cache_reuse;
105 u64 rx_cache_full;
106 u64 rx_cache_empty;
107 u64 rx_cache_busy;
70871f1e 108 u64 rx_cache_waive;
dc983f0e 109 u64 rx_congst_umr;
94563847 110 u64 rx_arfs_err;
a1bf74dc 111 u64 ch_events;
2d7103c8
TT
112 u64 ch_poll;
113 u64 ch_arm;
114 u64 ch_aff_change;
57d689a8 115 u64 ch_eq_rearm;
121fcdc8 116
bf239741
IL
117#ifdef CONFIG_MLX5_EN_TLS
118 u64 tx_tls_ooo;
119 u64 tx_tls_resync_bytes;
120#endif
9218b44d
GP
121};
122
9218b44d
GP
123struct mlx5e_qcounter_stats {
124 u32 rx_out_of_buffer;
7cbaf9a3 125 u32 rx_if_down_packets;
9218b44d
GP
126};
127
5c298143
MS
128struct mlx5e_vnic_env_stats {
129 __be64 query_vnic_env_out[MLX5_ST_SZ_QW(query_vnic_env_out)];
130};
131
9218b44d
GP
132#define VPORT_COUNTER_GET(vstats, c) MLX5_GET64(query_vport_counter_out, \
133 vstats->query_vport_out, c)
134
135struct mlx5e_vport_stats {
136 __be64 query_vport_out[MLX5_ST_SZ_QW(query_vport_counter_out)];
137};
138
9218b44d
GP
139#define PPORT_802_3_GET(pstats, c) \
140 MLX5_GET64(ppcnt_reg, pstats->IEEE_802_3_counters, \
141 counter_set.eth_802_3_cntrs_grp_data_layout.c##_high)
9218b44d
GP
142#define PPORT_2863_GET(pstats, c) \
143 MLX5_GET64(ppcnt_reg, pstats->RFC_2863_counters, \
144 counter_set.eth_2863_cntrs_grp_data_layout.c##_high)
9218b44d
GP
145#define PPORT_2819_GET(pstats, c) \
146 MLX5_GET64(ppcnt_reg, pstats->RFC_2819_counters, \
147 counter_set.eth_2819_cntrs_grp_data_layout.c##_high)
5db0a4f6
GP
148#define PPORT_PHY_STATISTICAL_GET(pstats, c) \
149 MLX5_GET64(ppcnt_reg, (pstats)->phy_statistical_counters, \
150 counter_set.phys_layer_statistical_cntrs.c##_high)
cf678570
GP
151#define PPORT_PER_PRIO_GET(pstats, prio, c) \
152 MLX5_GET64(ppcnt_reg, pstats->per_prio_counters[prio], \
153 counter_set.eth_per_prio_grp_data_layout.c##_high)
154#define NUM_PPORT_PRIO 8
068aef33
GP
155#define PPORT_ETH_EXT_GET(pstats, c) \
156 MLX5_GET64(ppcnt_reg, (pstats)->eth_ext_counters, \
157 counter_set.eth_extended_cntrs_grp_data_layout.c##_high)
9218b44d
GP
158
159struct mlx5e_pport_stats {
160 __be64 IEEE_802_3_counters[MLX5_ST_SZ_QW(ppcnt_reg)];
161 __be64 RFC_2863_counters[MLX5_ST_SZ_QW(ppcnt_reg)];
162 __be64 RFC_2819_counters[MLX5_ST_SZ_QW(ppcnt_reg)];
cf678570 163 __be64 per_prio_counters[NUM_PPORT_PRIO][MLX5_ST_SZ_QW(ppcnt_reg)];
121fcdc8 164 __be64 phy_counters[MLX5_ST_SZ_QW(ppcnt_reg)];
5db0a4f6 165 __be64 phy_statistical_counters[MLX5_ST_SZ_QW(ppcnt_reg)];
068aef33 166 __be64 eth_ext_counters[MLX5_ST_SZ_QW(ppcnt_reg)];
9218b44d
GP
167};
168
0f7f3481
GP
169#define PCIE_PERF_GET(pcie_stats, c) \
170 MLX5_GET(mpcnt_reg, (pcie_stats)->pcie_perf_counters, \
171 counter_set.pcie_perf_cntrs_grp_data_layout.c)
172
efae7f78
EBE
173#define PCIE_PERF_GET64(pcie_stats, c) \
174 MLX5_GET64(mpcnt_reg, (pcie_stats)->pcie_perf_counters, \
175 counter_set.pcie_perf_cntrs_grp_data_layout.c##_high)
176
0f7f3481
GP
177struct mlx5e_pcie_stats {
178 __be64 pcie_perf_counters[MLX5_ST_SZ_QW(mpcnt_reg)];
179};
180
9218b44d
GP
181struct mlx5e_rq_stats {
182 u64 packets;
183 u64 bytes;
bfe6d8d1 184 u64 csum_complete;
603e1f5b 185 u64 csum_unnecessary;
bfe6d8d1 186 u64 csum_unnecessary_inner;
1b223dd3 187 u64 csum_none;
9218b44d
GP
188 u64 lro_packets;
189 u64 lro_bytes;
f007c13d 190 u64 ecn_mark;
f24686e8 191 u64 removed_vlan_packets;
86994156 192 u64 xdp_drop;
86690b4b 193 u64 xdp_redirect;
9218b44d 194 u64 wqe_err;
b71ba6b4
TT
195 u64 mpwqe_filler_cqes;
196 u64 mpwqe_filler_strides;
0073c8f7 197 u64 oversize_pkts_sw_drop;
9218b44d 198 u64 buff_alloc_err;
7219ab34
TT
199 u64 cqe_compress_blks;
200 u64 cqe_compress_pkts;
accd5883 201 u64 page_reuse;
4415a031
TT
202 u64 cache_reuse;
203 u64 cache_full;
204 u64 cache_empty;
205 u64 cache_busy;
70871f1e 206 u64 cache_waive;
dc983f0e 207 u64 congst_umr;
94563847 208 u64 arfs_err;
9218b44d
GP
209};
210
9218b44d
GP
211struct mlx5e_sq_stats {
212 /* commonly accessed in data path */
213 u64 packets;
214 u64 bytes;
c8cf78fe 215 u64 xmit_more;
9218b44d
GP
216 u64 tso_packets;
217 u64 tso_bytes;
218 u64 tso_inner_packets;
219 u64 tso_inner_bytes;
603e1f5b 220 u64 csum_partial;
bfe6d8d1 221 u64 csum_partial_inner;
f24686e8 222 u64 added_vlan_packets;
9218b44d 223 u64 nop;
bc5a7ccd 224 u64 udp_seg_rem;
bf239741
IL
225#ifdef CONFIG_MLX5_EN_TLS
226 u64 tls_ooo;
227 u64 tls_resync_bytes;
228#endif
9218b44d 229 /* less likely accessed in data path */
bfe6d8d1 230 u64 csum_none;
9218b44d 231 u64 stopped;
9218b44d 232 u64 dropped;
db75373c 233 u64 recover;
f65a59ff 234 /* dirtied @completion */
86155656
TT
235 u64 cqes ____cacheline_aligned_in_smp;
236 u64 wake;
f65a59ff 237 u64 cqe_err;
9218b44d
GP
238};
239
890388ad
TT
240struct mlx5e_xdpsq_stats {
241 u64 xmit;
242 u64 full;
243 u64 err;
dac0d15f
TT
244 /* dirtied @completion */
245 u64 cqes ____cacheline_aligned_in_smp;
890388ad
TT
246};
247
57d689a8 248struct mlx5e_ch_stats {
a1bf74dc 249 u64 events;
2d7103c8
TT
250 u64 poll;
251 u64 arm;
252 u64 aff_change;
57d689a8
EBE
253 u64 eq_rearm;
254};
255
9218b44d
GP
256struct mlx5e_stats {
257 struct mlx5e_sw_stats sw;
258 struct mlx5e_qcounter_stats qcnt;
5c298143 259 struct mlx5e_vnic_env_stats vnic;
9218b44d
GP
260 struct mlx5e_vport_stats vport;
261 struct mlx5e_pport_stats pport;
370bad0f 262 struct rtnl_link_stats64 vf_vport;
0f7f3481 263 struct mlx5e_pcie_stats pcie;
9218b44d
GP
264};
265
19386177
KH
266enum {
267 MLX5E_NDO_UPDATE_STATS = BIT(0x1),
268};
269
c0752f2b
KH
270struct mlx5e_priv;
271struct mlx5e_stats_grp {
19386177 272 u16 update_stats_mask;
c0752f2b
KH
273 int (*get_num_stats)(struct mlx5e_priv *priv);
274 int (*fill_strings)(struct mlx5e_priv *priv, u8 *data, int idx);
275 int (*fill_stats)(struct mlx5e_priv *priv, u64 *data, int idx);
19386177 276 void (*update_stats)(struct mlx5e_priv *priv);
c0752f2b
KH
277};
278
279extern const struct mlx5e_stats_grp mlx5e_stats_grps[];
280extern const int mlx5e_num_stats_grps;
281
868a01a2
SL
282void mlx5e_grp_sw_update_stats(struct mlx5e_priv *priv);
283
9218b44d 284#endif /* __MLX5_EN_STATS_H__ */
This page took 0.478453 seconds and 4 git commands to generate.