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 37 #ifdef MLX4_EN_PERF_STAT 38 #define NUM_PERF_STATS NUM_PERF_COUNTERS 39 #else 40 #define NUM_PERF_STATS 0 41 #endif 42 43 #define NUM_PRIORITIES 9 44 #define NUM_PRIORITY_STATS 2 45 46 struct mlx4_en_pkt_stats { 47 unsigned long rx_packets; 48 unsigned long rx_bytes; 49 unsigned long rx_multicast_packets; 50 unsigned long rx_broadcast_packets; 51 unsigned long rx_errors; 52 unsigned long rx_dropped; 53 unsigned long rx_length_errors; 54 unsigned long rx_over_errors; 55 unsigned long rx_crc_errors; 56 unsigned long rx_jabbers; 57 unsigned long rx_in_range_length_error; 58 unsigned long rx_out_range_length_error; 59 unsigned long rx_lt_64_bytes_packets; 60 unsigned long rx_127_bytes_packets; 61 unsigned long rx_255_bytes_packets; 62 unsigned long rx_511_bytes_packets; 63 unsigned long rx_1023_bytes_packets; 64 unsigned long rx_1518_bytes_packets; 65 unsigned long rx_1522_bytes_packets; 66 unsigned long rx_1548_bytes_packets; 67 unsigned long rx_gt_1548_bytes_packets; 68 unsigned long tx_packets; 69 unsigned long tx_bytes; 70 unsigned long tx_multicast_packets; 71 unsigned long tx_broadcast_packets; 72 unsigned long tx_errors; 73 unsigned long tx_dropped; 74 unsigned long tx_lt_64_bytes_packets; 75 unsigned long tx_127_bytes_packets; 76 unsigned long tx_255_bytes_packets; 77 unsigned long tx_511_bytes_packets; 78 unsigned long tx_1023_bytes_packets; 79 unsigned long tx_1518_bytes_packets; 80 unsigned long tx_1522_bytes_packets; 81 unsigned long tx_1548_bytes_packets; 82 unsigned long tx_gt_1548_bytes_packets; 83 unsigned long rx_prio[NUM_PRIORITIES][NUM_PRIORITY_STATS]; 84 unsigned long tx_prio[NUM_PRIORITIES][NUM_PRIORITY_STATS]; 85 #define NUM_PKT_STATS 72 86 }; 87 88 struct mlx4_en_vf_stats { 89 unsigned long rx_packets; 90 unsigned long rx_bytes; 91 unsigned long rx_multicast_packets; 92 unsigned long rx_broadcast_packets; 93 unsigned long rx_errors; 94 unsigned long rx_dropped; 95 unsigned long tx_packets; 96 unsigned long tx_bytes; 97 unsigned long tx_multicast_packets; 98 unsigned long tx_broadcast_packets; 99 unsigned long tx_errors; 100 #define NUM_VF_STATS 11 101 }; 102 103 struct mlx4_en_vport_stats { 104 unsigned long rx_unicast_packets; 105 unsigned long rx_unicast_bytes; 106 unsigned long rx_multicast_packets; 107 unsigned long rx_multicast_bytes; 108 unsigned long rx_broadcast_packets; 109 unsigned long rx_broadcast_bytes; 110 unsigned long rx_dropped; 111 unsigned long rx_errors; 112 unsigned long tx_unicast_packets; 113 unsigned long tx_unicast_bytes; 114 unsigned long tx_multicast_packets; 115 unsigned long tx_multicast_bytes; 116 unsigned long tx_broadcast_packets; 117 unsigned long tx_broadcast_bytes; 118 unsigned long tx_errors; 119 #define NUM_VPORT_STATS 15 120 }; 121 122 struct mlx4_en_port_stats { 123 unsigned long tso_packets; 124 unsigned long queue_stopped; 125 unsigned long wake_queue; 126 unsigned long tx_timeout; 127 unsigned long oversized_packets; 128 unsigned long rx_alloc_failed; 129 unsigned long rx_chksum_good; 130 unsigned long rx_chksum_none; 131 unsigned long tx_chksum_offload; 132 #define NUM_PORT_STATS 8 133 }; 134 135 struct mlx4_en_perf_stats { 136 u32 tx_poll; 137 u64 tx_pktsz_avg; 138 u32 inflight_avg; 139 u16 tx_coal_avg; 140 u16 rx_coal_avg; 141 u32 napi_quota; 142 #define NUM_PERF_COUNTERS 6 143 }; 144 145 struct mlx4_en_flow_stats { 146 u64 rx_pause; 147 u64 rx_pause_duration; 148 u64 rx_pause_transition; 149 u64 tx_pause; 150 u64 tx_pause_duration; 151 u64 tx_pause_transition; 152 }; 153 #define MLX4_NUM_PRIORITIES 8 154 #define NUM_FLOW_PRIORITY_STATS 6 155 #define NUM_FLOW_STATS (NUM_FLOW_PRIORITY_STATS*MLX4_NUM_PRIORITIES) 156 157 158 struct mlx4_en_stat_out_flow_control_mbox { 159 /* Total number of PAUSE frames received from the far-end port */ 160 __be64 rx_pause; 161 /* Total number of microseconds that far-end port requested to pause 162 * transmission of packets 163 */ 164 __be64 rx_pause_duration; 165 /* Number of received transmission from XOFF state to XON state */ 166 __be64 rx_pause_transition; 167 /* Total number of PAUSE frames sent from the far-end port */ 168 __be64 tx_pause; 169 /* Total time in microseconds that transmission of packets has been 170 * paused 171 */ 172 __be64 tx_pause_duration; 173 /* Number of transmitter transitions from XOFF state to XON state */ 174 __be64 tx_pause_transition; 175 /* Reserverd */ 176 __be64 reserved[2]; 177 }; 178 179 int mlx4_get_vport_ethtool_stats(struct mlx4_dev *dev, int port, 180 struct mlx4_en_vport_stats *vport_stats, 181 int reset); 182 183 #define NUM_ALL_STATS (NUM_PKT_STATS + NUM_FLOW_STATS + NUM_VPORT_STATS + \ 184 NUM_VF_STATS + NUM_PORT_STATS + NUM_PERF_STATS) 185 #endif 186