xref: /freebsd/sys/dev/mlx4/stats.h (revision 55b1c6e7e4a6909004e13c6d2f328f911a8e7b83)
197549c34SHans Petter Selasky /*
297549c34SHans Petter Selasky  * Copyright (c) 2014 Mellanox Technologies Ltd.  All rights reserved.
397549c34SHans Petter Selasky  *
497549c34SHans Petter Selasky  * This software is available to you under a choice of one of two
597549c34SHans Petter Selasky  * licenses.  You may choose to be licensed under the terms of the GNU
697549c34SHans Petter Selasky  * General Public License (GPL) Version 2, available from the file
797549c34SHans Petter Selasky  * COPYING in the main directory of this source tree, or the
897549c34SHans Petter Selasky  * OpenIB.org BSD license below:
997549c34SHans Petter Selasky  *
1097549c34SHans Petter Selasky  *     Redistribution and use in source and binary forms, with or
1197549c34SHans Petter Selasky  *     without modification, are permitted provided that the following
1297549c34SHans Petter Selasky  *     conditions are met:
1397549c34SHans Petter Selasky  *
1497549c34SHans Petter Selasky  *      - Redistributions of source code must retain the above
1597549c34SHans Petter Selasky  *        copyright notice, this list of conditions and the following
1697549c34SHans Petter Selasky  *        disclaimer.
1797549c34SHans Petter Selasky  *
1897549c34SHans Petter Selasky  *      - Redistributions in binary form must reproduce the above
1997549c34SHans Petter Selasky  *        copyright notice, this list of conditions and the following
2097549c34SHans Petter Selasky  *        disclaimer in the documentation and/or other materials
2197549c34SHans Petter Selasky  *        provided with the distribution.
2297549c34SHans Petter Selasky  *
2397549c34SHans Petter Selasky  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
2497549c34SHans Petter Selasky  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
2597549c34SHans Petter Selasky  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
2697549c34SHans Petter Selasky  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
2797549c34SHans Petter Selasky  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
2897549c34SHans Petter Selasky  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
2997549c34SHans Petter Selasky  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
3097549c34SHans Petter Selasky  * SOFTWARE.
3197549c34SHans Petter Selasky  */
3297549c34SHans Petter Selasky 
3397549c34SHans Petter Selasky #ifndef _MLX4_STATS_
3497549c34SHans Petter Selasky #define _MLX4_STATS_
3597549c34SHans Petter Selasky 
3697549c34SHans Petter Selasky #define NUM_PRIORITIES	9
3797549c34SHans Petter Selasky #define NUM_PRIORITY_STATS 2
3897549c34SHans Petter Selasky 
3997549c34SHans Petter Selasky struct mlx4_en_pkt_stats {
40*c3191c2eSHans Petter Selasky 	u64 rx_packets;
41*c3191c2eSHans Petter Selasky 	u64 rx_bytes;
42*c3191c2eSHans Petter Selasky 	u64 rx_multicast_packets;
43*c3191c2eSHans Petter Selasky 	u64 rx_broadcast_packets;
44*c3191c2eSHans Petter Selasky 	u64 rx_errors;
45*c3191c2eSHans Petter Selasky 	u64 rx_dropped;
46*c3191c2eSHans Petter Selasky 	u64 rx_length_errors;
47*c3191c2eSHans Petter Selasky 	u64 rx_over_errors;
48*c3191c2eSHans Petter Selasky 	u64 rx_crc_errors;
49*c3191c2eSHans Petter Selasky 	u64 rx_jabbers;
50*c3191c2eSHans Petter Selasky 	u64 rx_in_range_length_error;
51*c3191c2eSHans Petter Selasky 	u64 rx_out_range_length_error;
52*c3191c2eSHans Petter Selasky 	u64 rx_lt_64_bytes_packets;
53*c3191c2eSHans Petter Selasky 	u64 rx_127_bytes_packets;
54*c3191c2eSHans Petter Selasky 	u64 rx_255_bytes_packets;
55*c3191c2eSHans Petter Selasky 	u64 rx_511_bytes_packets;
56*c3191c2eSHans Petter Selasky 	u64 rx_1023_bytes_packets;
57*c3191c2eSHans Petter Selasky 	u64 rx_1518_bytes_packets;
58*c3191c2eSHans Petter Selasky 	u64 rx_1522_bytes_packets;
59*c3191c2eSHans Petter Selasky 	u64 rx_1548_bytes_packets;
60*c3191c2eSHans Petter Selasky 	u64 rx_gt_1548_bytes_packets;
61*c3191c2eSHans Petter Selasky 	u64 tx_packets;
62*c3191c2eSHans Petter Selasky 	u64 tx_bytes;
63*c3191c2eSHans Petter Selasky 	u64 tx_multicast_packets;
64*c3191c2eSHans Petter Selasky 	u64 tx_broadcast_packets;
65*c3191c2eSHans Petter Selasky 	u64 tx_errors;
66*c3191c2eSHans Petter Selasky 	u64 tx_dropped;
67*c3191c2eSHans Petter Selasky 	u64 tx_lt_64_bytes_packets;
68*c3191c2eSHans Petter Selasky 	u64 tx_127_bytes_packets;
69*c3191c2eSHans Petter Selasky 	u64 tx_255_bytes_packets;
70*c3191c2eSHans Petter Selasky 	u64 tx_511_bytes_packets;
71*c3191c2eSHans Petter Selasky 	u64 tx_1023_bytes_packets;
72*c3191c2eSHans Petter Selasky 	u64 tx_1518_bytes_packets;
73*c3191c2eSHans Petter Selasky 	u64 tx_1522_bytes_packets;
74*c3191c2eSHans Petter Selasky 	u64 tx_1548_bytes_packets;
75*c3191c2eSHans Petter Selasky 	u64 tx_gt_1548_bytes_packets;
76*c3191c2eSHans Petter Selasky 	u64 rx_prio[NUM_PRIORITIES][NUM_PRIORITY_STATS];
77*c3191c2eSHans Petter Selasky 	u64 tx_prio[NUM_PRIORITIES][NUM_PRIORITY_STATS];
7897549c34SHans Petter Selasky };
7997549c34SHans Petter Selasky 
8097549c34SHans Petter Selasky struct mlx4_en_vf_stats {
81*c3191c2eSHans Petter Selasky 	u64 rx_frames;
82*c3191c2eSHans Petter Selasky 	u64 rx_bytes;
83*c3191c2eSHans Petter Selasky 	u64 tx_frames;
84*c3191c2eSHans Petter Selasky 	u64 tx_bytes;
8597549c34SHans Petter Selasky };
8697549c34SHans Petter Selasky 
8797549c34SHans Petter Selasky struct mlx4_en_vport_stats {
88*c3191c2eSHans Petter Selasky 	u64 rx_frames;
89*c3191c2eSHans Petter Selasky 	u64 rx_bytes;
90*c3191c2eSHans Petter Selasky 	u64 tx_frames;
91*c3191c2eSHans Petter Selasky 	u64 tx_bytes;
9297549c34SHans Petter Selasky };
9397549c34SHans Petter Selasky 
9497549c34SHans Petter Selasky struct mlx4_en_port_stats {
95*c3191c2eSHans Petter Selasky 	u64 tso_packets;
96*c3191c2eSHans Petter Selasky 	u64 queue_stopped;
97*c3191c2eSHans Petter Selasky 	u64 wake_queue;
98*c3191c2eSHans Petter Selasky 	u64 tx_timeout;
99*c3191c2eSHans Petter Selasky 	u64 oversized_packets;
100*c3191c2eSHans Petter Selasky 	u64 rx_alloc_failed;
101*c3191c2eSHans Petter Selasky 	u64 rx_chksum_good;
102*c3191c2eSHans Petter Selasky 	u64 rx_chksum_none;
103*c3191c2eSHans Petter Selasky 	u64 tx_chksum_offload;
104*c3191c2eSHans Petter Selasky 	u64 defrag_attempts;
10597549c34SHans Petter Selasky };
10697549c34SHans Petter Selasky 
10797549c34SHans Petter Selasky struct mlx4_en_perf_stats {
10897549c34SHans Petter Selasky 	u32 tx_poll;
10997549c34SHans Petter Selasky 	u64 tx_pktsz_avg;
11097549c34SHans Petter Selasky 	u32 inflight_avg;
11197549c34SHans Petter Selasky 	u16 tx_coal_avg;
11297549c34SHans Petter Selasky 	u16 rx_coal_avg;
11397549c34SHans Petter Selasky 	u32 napi_quota;
11497549c34SHans Petter Selasky };
11597549c34SHans Petter Selasky 
116*c3191c2eSHans Petter Selasky #define MLX4_NUM_PRIORITIES	8
117*c3191c2eSHans Petter Selasky 
118*c3191c2eSHans Petter Selasky struct mlx4_en_flow_stats_rx {
11997549c34SHans Petter Selasky 	u64 rx_pause;
12097549c34SHans Petter Selasky 	u64 rx_pause_duration;
12197549c34SHans Petter Selasky 	u64 rx_pause_transition;
122*c3191c2eSHans Petter Selasky };
123*c3191c2eSHans Petter Selasky 
124*c3191c2eSHans Petter Selasky struct mlx4_en_flow_stats_tx {
12597549c34SHans Petter Selasky 	u64 tx_pause;
12697549c34SHans Petter Selasky 	u64 tx_pause_duration;
12797549c34SHans Petter Selasky 	u64 tx_pause_transition;
12897549c34SHans Petter Selasky };
12997549c34SHans Petter Selasky 
13097549c34SHans Petter Selasky struct mlx4_en_stat_out_flow_control_mbox {
13197549c34SHans Petter Selasky 	/* Total number of PAUSE frames received from the far-end port */
13297549c34SHans Petter Selasky 	__be64 rx_pause;
13397549c34SHans Petter Selasky 	/* Total number of microseconds that far-end port requested to pause
13497549c34SHans Petter Selasky 	 * transmission of packets
13597549c34SHans Petter Selasky 	 */
13697549c34SHans Petter Selasky 	__be64 rx_pause_duration;
13797549c34SHans Petter Selasky 	/* Number of received transmission from XOFF state to XON state */
13897549c34SHans Petter Selasky 	__be64 rx_pause_transition;
13997549c34SHans Petter Selasky 	/* Total number of PAUSE frames sent from the far-end port */
14097549c34SHans Petter Selasky 	__be64 tx_pause;
14197549c34SHans Petter Selasky 	/* Total time in microseconds that transmission of packets has been
14297549c34SHans Petter Selasky 	 * paused
14397549c34SHans Petter Selasky 	 */
14497549c34SHans Petter Selasky 	__be64 tx_pause_duration;
14597549c34SHans Petter Selasky 	/* Number of transmitter transitions from XOFF state to XON state */
14697549c34SHans Petter Selasky 	__be64 tx_pause_transition;
14797549c34SHans Petter Selasky 	/* Reserverd */
14897549c34SHans Petter Selasky 	__be64 reserved[2];
14997549c34SHans Petter Selasky };
15097549c34SHans Petter Selasky 
151*c3191c2eSHans Petter Selasky enum {
152*c3191c2eSHans Petter Selasky 	MLX4_DUMP_ETH_STATS_FLOW_CONTROL = 1 << 12
153*c3191c2eSHans Petter Selasky };
154*c3191c2eSHans Petter Selasky 
15597549c34SHans Petter Selasky int mlx4_get_vport_ethtool_stats(struct mlx4_dev *dev, int port,
15697549c34SHans Petter Selasky     struct mlx4_en_vport_stats *vport_stats,
157*c3191c2eSHans Petter Selasky     int reset, int *read_counters);
15897549c34SHans Petter Selasky 
15997549c34SHans Petter Selasky #endif
160