1/*
2 * Copyright (c) 2014 Mellanox Technologies Ltd.  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
33#ifndef _MLX4_STATS_
34#define _MLX4_STATS_
35
36#define NUM_PRIORITIES	9
37#define NUM_PRIORITY_STATS 2
38
39struct mlx4_en_pkt_stats {
40	u64 rx_packets;
41	u64 rx_bytes;
42	u64 rx_multicast_packets;
43	u64 rx_broadcast_packets;
44	u64 rx_errors;
45	u64 rx_dropped;
46	u64 rx_length_errors;
47	u64 rx_over_errors;
48	u64 rx_crc_errors;
49	u64 rx_jabbers;
50	u64 rx_in_range_length_error;
51	u64 rx_out_range_length_error;
52	u64 rx_lt_64_bytes_packets;
53	u64 rx_127_bytes_packets;
54	u64 rx_255_bytes_packets;
55	u64 rx_511_bytes_packets;
56	u64 rx_1023_bytes_packets;
57	u64 rx_1518_bytes_packets;
58	u64 rx_1522_bytes_packets;
59	u64 rx_1548_bytes_packets;
60	u64 rx_gt_1548_bytes_packets;
61	u64 tx_packets;
62	u64 tx_bytes;
63	u64 tx_multicast_packets;
64	u64 tx_broadcast_packets;
65	u64 tx_errors;
66	u64 tx_dropped;
67	u64 tx_lt_64_bytes_packets;
68	u64 tx_127_bytes_packets;
69	u64 tx_255_bytes_packets;
70	u64 tx_511_bytes_packets;
71	u64 tx_1023_bytes_packets;
72	u64 tx_1518_bytes_packets;
73	u64 tx_1522_bytes_packets;
74	u64 tx_1548_bytes_packets;
75	u64 tx_gt_1548_bytes_packets;
76	u64 rx_prio[NUM_PRIORITIES][NUM_PRIORITY_STATS];
77	u64 tx_prio[NUM_PRIORITIES][NUM_PRIORITY_STATS];
78};
79
80struct mlx4_en_vf_stats {
81	u64 rx_frames;
82	u64 rx_bytes;
83	u64 tx_frames;
84	u64 tx_bytes;
85};
86
87struct mlx4_en_vport_stats {
88	u64 rx_frames;
89	u64 rx_bytes;
90	u64 tx_frames;
91	u64 tx_bytes;
92};
93
94struct mlx4_en_port_stats {
95	u64 tso_packets;
96	u64 queue_stopped;
97	u64 wake_queue;
98	u64 tx_timeout;
99	u64 oversized_packets;
100	u64 rx_alloc_failed;
101	u64 rx_chksum_good;
102	u64 rx_chksum_none;
103	u64 tx_chksum_offload;
104	u64 defrag_attempts;
105};
106
107struct mlx4_en_perf_stats {
108	u32 tx_poll;
109	u64 tx_pktsz_avg;
110	u32 inflight_avg;
111	u16 tx_coal_avg;
112	u16 rx_coal_avg;
113	u32 napi_quota;
114};
115
116#define MLX4_NUM_PRIORITIES	8
117
118struct mlx4_en_flow_stats_rx {
119	u64 rx_pause;
120	u64 rx_pause_duration;
121	u64 rx_pause_transition;
122};
123
124struct mlx4_en_flow_stats_tx {
125	u64 tx_pause;
126	u64 tx_pause_duration;
127	u64 tx_pause_transition;
128};
129
130struct mlx4_en_stat_out_flow_control_mbox {
131	/* Total number of PAUSE frames received from the far-end port */
132	__be64 rx_pause;
133	/* Total number of microseconds that far-end port requested to pause
134	 * transmission of packets
135	 */
136	__be64 rx_pause_duration;
137	/* Number of received transmission from XOFF state to XON state */
138	__be64 rx_pause_transition;
139	/* Total number of PAUSE frames sent from the far-end port */
140	__be64 tx_pause;
141	/* Total time in microseconds that transmission of packets has been
142	 * paused
143	 */
144	__be64 tx_pause_duration;
145	/* Number of transmitter transitions from XOFF state to XON state */
146	__be64 tx_pause_transition;
147	/* Reserverd */
148	__be64 reserved[2];
149};
150
151enum {
152	MLX4_DUMP_ETH_STATS_FLOW_CONTROL = 1 << 12
153};
154
155int mlx4_get_vport_ethtool_stats(struct mlx4_dev *dev, int port,
156    struct mlx4_en_vport_stats *vport_stats,
157    int reset, int *read_counters);
158
159#endif
160