Yevgeny Petrilin | c27a02c | 2008-10-22 15:47:49 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2007 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 | */ |
| 33 | |
| 34 | #include <linux/kernel.h> |
| 35 | #include <linux/ethtool.h> |
| 36 | #include <linux/netdevice.h> |
| 37 | |
| 38 | #include "mlx4_en.h" |
| 39 | #include "en_port.h" |
| 40 | |
Yevgeny Petrilin | c27a02c | 2008-10-22 15:47:49 -0700 | [diff] [blame] | 41 | |
Yevgeny Petrilin | c27a02c | 2008-10-22 15:47:49 -0700 | [diff] [blame] | 42 | static void |
| 43 | mlx4_en_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *drvinfo) |
| 44 | { |
| 45 | struct mlx4_en_priv *priv = netdev_priv(dev); |
| 46 | struct mlx4_en_dev *mdev = priv->mdev; |
| 47 | |
| 48 | sprintf(drvinfo->driver, DRV_NAME " (%s)", mdev->dev->board_id); |
| 49 | strncpy(drvinfo->version, DRV_VERSION " (" DRV_RELDATE ")", 32); |
| 50 | sprintf(drvinfo->fw_version, "%d.%d.%d", |
| 51 | (u16) (mdev->dev->caps.fw_ver >> 32), |
| 52 | (u16) ((mdev->dev->caps.fw_ver >> 16) & 0xffff), |
| 53 | (u16) (mdev->dev->caps.fw_ver & 0xffff)); |
| 54 | strncpy(drvinfo->bus_info, pci_name(mdev->dev->pdev), 32); |
| 55 | drvinfo->n_stats = 0; |
| 56 | drvinfo->regdump_len = 0; |
| 57 | drvinfo->eedump_len = 0; |
| 58 | } |
| 59 | |
| 60 | static u32 mlx4_en_get_tso(struct net_device *dev) |
| 61 | { |
| 62 | return (dev->features & NETIF_F_TSO) != 0; |
| 63 | } |
| 64 | |
| 65 | static int mlx4_en_set_tso(struct net_device *dev, u32 data) |
| 66 | { |
| 67 | struct mlx4_en_priv *priv = netdev_priv(dev); |
| 68 | |
| 69 | if (data) { |
| 70 | if (!priv->mdev->LSO_support) |
| 71 | return -EPERM; |
| 72 | dev->features |= (NETIF_F_TSO | NETIF_F_TSO6); |
| 73 | } else |
| 74 | dev->features &= ~(NETIF_F_TSO | NETIF_F_TSO6); |
| 75 | return 0; |
| 76 | } |
| 77 | |
| 78 | static u32 mlx4_en_get_rx_csum(struct net_device *dev) |
| 79 | { |
| 80 | struct mlx4_en_priv *priv = netdev_priv(dev); |
| 81 | return priv->rx_csum; |
| 82 | } |
| 83 | |
| 84 | static int mlx4_en_set_rx_csum(struct net_device *dev, u32 data) |
| 85 | { |
| 86 | struct mlx4_en_priv *priv = netdev_priv(dev); |
| 87 | priv->rx_csum = (data != 0); |
| 88 | return 0; |
| 89 | } |
| 90 | |
| 91 | static const char main_strings[][ETH_GSTRING_LEN] = { |
| 92 | "rx_packets", "tx_packets", "rx_bytes", "tx_bytes", "rx_errors", |
| 93 | "tx_errors", "rx_dropped", "tx_dropped", "multicast", "collisions", |
| 94 | "rx_length_errors", "rx_over_errors", "rx_crc_errors", |
| 95 | "rx_frame_errors", "rx_fifo_errors", "rx_missed_errors", |
| 96 | "tx_aborted_errors", "tx_carrier_errors", "tx_fifo_errors", |
| 97 | "tx_heartbeat_errors", "tx_window_errors", |
| 98 | |
| 99 | /* port statistics */ |
Yevgeny Petrilin | fa37a95 | 2010-08-24 03:46:46 +0000 | [diff] [blame] | 100 | "tso_packets", |
Yevgeny Petrilin | c27a02c | 2008-10-22 15:47:49 -0700 | [diff] [blame] | 101 | "queue_stopped", "wake_queue", "tx_timeout", "rx_alloc_failed", |
| 102 | "rx_csum_good", "rx_csum_none", "tx_chksum_offload", |
| 103 | |
| 104 | /* packet statistics */ |
| 105 | "broadcast", "rx_prio_0", "rx_prio_1", "rx_prio_2", "rx_prio_3", |
| 106 | "rx_prio_4", "rx_prio_5", "rx_prio_6", "rx_prio_7", "tx_prio_0", |
| 107 | "tx_prio_1", "tx_prio_2", "tx_prio_3", "tx_prio_4", "tx_prio_5", |
| 108 | "tx_prio_6", "tx_prio_7", |
| 109 | }; |
Yevgeny Petrilin | d61702f | 2010-09-05 22:20:24 +0000 | [diff] [blame] | 110 | #define NUM_MAIN_STATS 21 |
Yevgeny Petrilin | c27a02c | 2008-10-22 15:47:49 -0700 | [diff] [blame] | 111 | #define NUM_ALL_STATS (NUM_MAIN_STATS + NUM_PORT_STATS + NUM_PKT_STATS + NUM_PERF_STATS) |
| 112 | |
Yevgeny Petrilin | e7c1c2c4 | 2010-08-24 03:46:18 +0000 | [diff] [blame] | 113 | static const char mlx4_en_test_names[][ETH_GSTRING_LEN]= { |
| 114 | "Interupt Test", |
| 115 | "Link Test", |
| 116 | "Speed Test", |
| 117 | "Register Test", |
| 118 | "Loopback Test", |
| 119 | }; |
| 120 | |
Yevgeny Petrilin | c27a02c | 2008-10-22 15:47:49 -0700 | [diff] [blame] | 121 | static u32 mlx4_en_get_msglevel(struct net_device *dev) |
| 122 | { |
| 123 | return ((struct mlx4_en_priv *) netdev_priv(dev))->msg_enable; |
| 124 | } |
| 125 | |
| 126 | static void mlx4_en_set_msglevel(struct net_device *dev, u32 val) |
| 127 | { |
| 128 | ((struct mlx4_en_priv *) netdev_priv(dev))->msg_enable = val; |
| 129 | } |
| 130 | |
| 131 | static void mlx4_en_get_wol(struct net_device *netdev, |
| 132 | struct ethtool_wolinfo *wol) |
| 133 | { |
| 134 | wol->supported = 0; |
| 135 | wol->wolopts = 0; |
Yevgeny Petrilin | c27a02c | 2008-10-22 15:47:49 -0700 | [diff] [blame] | 136 | } |
| 137 | |
| 138 | static int mlx4_en_get_sset_count(struct net_device *dev, int sset) |
| 139 | { |
| 140 | struct mlx4_en_priv *priv = netdev_priv(dev); |
| 141 | |
Yevgeny Petrilin | e7c1c2c4 | 2010-08-24 03:46:18 +0000 | [diff] [blame] | 142 | switch (sset) { |
| 143 | case ETH_SS_STATS: |
| 144 | return NUM_ALL_STATS + |
| 145 | (priv->tx_ring_num + priv->rx_ring_num) * 2; |
| 146 | case ETH_SS_TEST: |
| 147 | return MLX4_EN_NUM_SELF_TEST - !(priv->mdev->dev->caps.loopback_support) * 2; |
| 148 | default: |
Yevgeny Petrilin | c27a02c | 2008-10-22 15:47:49 -0700 | [diff] [blame] | 149 | return -EOPNOTSUPP; |
Yevgeny Petrilin | e7c1c2c4 | 2010-08-24 03:46:18 +0000 | [diff] [blame] | 150 | } |
Yevgeny Petrilin | c27a02c | 2008-10-22 15:47:49 -0700 | [diff] [blame] | 151 | } |
| 152 | |
| 153 | static void mlx4_en_get_ethtool_stats(struct net_device *dev, |
| 154 | struct ethtool_stats *stats, uint64_t *data) |
| 155 | { |
| 156 | struct mlx4_en_priv *priv = netdev_priv(dev); |
| 157 | int index = 0; |
| 158 | int i; |
| 159 | |
| 160 | spin_lock_bh(&priv->stats_lock); |
| 161 | |
Yevgeny Petrilin | c27a02c | 2008-10-22 15:47:49 -0700 | [diff] [blame] | 162 | for (i = 0; i < NUM_MAIN_STATS; i++) |
| 163 | data[index++] = ((unsigned long *) &priv->stats)[i]; |
| 164 | for (i = 0; i < NUM_PORT_STATS; i++) |
| 165 | data[index++] = ((unsigned long *) &priv->port_stats)[i]; |
| 166 | for (i = 0; i < priv->tx_ring_num; i++) { |
| 167 | data[index++] = priv->tx_ring[i].packets; |
| 168 | data[index++] = priv->tx_ring[i].bytes; |
| 169 | } |
| 170 | for (i = 0; i < priv->rx_ring_num; i++) { |
| 171 | data[index++] = priv->rx_ring[i].packets; |
| 172 | data[index++] = priv->rx_ring[i].bytes; |
| 173 | } |
| 174 | for (i = 0; i < NUM_PKT_STATS; i++) |
| 175 | data[index++] = ((unsigned long *) &priv->pkstats)[i]; |
| 176 | spin_unlock_bh(&priv->stats_lock); |
| 177 | |
| 178 | } |
| 179 | |
Yevgeny Petrilin | e7c1c2c4 | 2010-08-24 03:46:18 +0000 | [diff] [blame] | 180 | static void mlx4_en_self_test(struct net_device *dev, |
| 181 | struct ethtool_test *etest, u64 *buf) |
| 182 | { |
| 183 | mlx4_en_ex_selftest(dev, &etest->flags, buf); |
| 184 | } |
| 185 | |
Yevgeny Petrilin | c27a02c | 2008-10-22 15:47:49 -0700 | [diff] [blame] | 186 | static void mlx4_en_get_strings(struct net_device *dev, |
| 187 | uint32_t stringset, uint8_t *data) |
| 188 | { |
| 189 | struct mlx4_en_priv *priv = netdev_priv(dev); |
| 190 | int index = 0; |
| 191 | int i; |
| 192 | |
Yevgeny Petrilin | e7c1c2c4 | 2010-08-24 03:46:18 +0000 | [diff] [blame] | 193 | switch (stringset) { |
| 194 | case ETH_SS_TEST: |
| 195 | for (i = 0; i < MLX4_EN_NUM_SELF_TEST - 2; i++) |
| 196 | strcpy(data + i * ETH_GSTRING_LEN, mlx4_en_test_names[i]); |
| 197 | if (priv->mdev->dev->caps.loopback_support) |
| 198 | for (; i < MLX4_EN_NUM_SELF_TEST; i++) |
| 199 | strcpy(data + i * ETH_GSTRING_LEN, mlx4_en_test_names[i]); |
| 200 | break; |
Yevgeny Petrilin | c27a02c | 2008-10-22 15:47:49 -0700 | [diff] [blame] | 201 | |
Yevgeny Petrilin | e7c1c2c4 | 2010-08-24 03:46:18 +0000 | [diff] [blame] | 202 | case ETH_SS_STATS: |
| 203 | /* Add main counters */ |
| 204 | for (i = 0; i < NUM_MAIN_STATS; i++) |
| 205 | strcpy(data + (index++) * ETH_GSTRING_LEN, main_strings[i]); |
| 206 | for (i = 0; i< NUM_PORT_STATS; i++) |
| 207 | strcpy(data + (index++) * ETH_GSTRING_LEN, |
Yevgeny Petrilin | c27a02c | 2008-10-22 15:47:49 -0700 | [diff] [blame] | 208 | main_strings[i + NUM_MAIN_STATS]); |
Yevgeny Petrilin | e7c1c2c4 | 2010-08-24 03:46:18 +0000 | [diff] [blame] | 209 | for (i = 0; i < priv->tx_ring_num; i++) { |
| 210 | sprintf(data + (index++) * ETH_GSTRING_LEN, |
| 211 | "tx%d_packets", i); |
| 212 | sprintf(data + (index++) * ETH_GSTRING_LEN, |
| 213 | "tx%d_bytes", i); |
| 214 | } |
| 215 | for (i = 0; i < priv->rx_ring_num; i++) { |
| 216 | sprintf(data + (index++) * ETH_GSTRING_LEN, |
| 217 | "rx%d_packets", i); |
| 218 | sprintf(data + (index++) * ETH_GSTRING_LEN, |
| 219 | "rx%d_bytes", i); |
| 220 | } |
| 221 | for (i = 0; i< NUM_PKT_STATS; i++) |
| 222 | strcpy(data + (index++) * ETH_GSTRING_LEN, |
Yevgeny Petrilin | c27a02c | 2008-10-22 15:47:49 -0700 | [diff] [blame] | 223 | main_strings[i + NUM_MAIN_STATS + NUM_PORT_STATS]); |
Yevgeny Petrilin | e7c1c2c4 | 2010-08-24 03:46:18 +0000 | [diff] [blame] | 224 | break; |
| 225 | } |
Yevgeny Petrilin | c27a02c | 2008-10-22 15:47:49 -0700 | [diff] [blame] | 226 | } |
| 227 | |
| 228 | static int mlx4_en_get_settings(struct net_device *dev, struct ethtool_cmd *cmd) |
| 229 | { |
Yevgeny Petrilin | 7699517 | 2010-08-24 03:46:23 +0000 | [diff] [blame] | 230 | struct mlx4_en_priv *priv = netdev_priv(dev); |
| 231 | int trans_type; |
| 232 | |
Yevgeny Petrilin | c27a02c | 2008-10-22 15:47:49 -0700 | [diff] [blame] | 233 | cmd->autoneg = AUTONEG_DISABLE; |
| 234 | cmd->supported = SUPPORTED_10000baseT_Full; |
Yevgeny Petrilin | 7699517 | 2010-08-24 03:46:23 +0000 | [diff] [blame] | 235 | cmd->advertising = ADVERTISED_10000baseT_Full; |
| 236 | |
| 237 | if (mlx4_en_QUERY_PORT(priv->mdev, priv->port)) |
| 238 | return -ENOMEM; |
| 239 | |
| 240 | trans_type = priv->port_state.transciver; |
Yevgeny Petrilin | c27a02c | 2008-10-22 15:47:49 -0700 | [diff] [blame] | 241 | if (netif_carrier_ok(dev)) { |
Yevgeny Petrilin | 7699517 | 2010-08-24 03:46:23 +0000 | [diff] [blame] | 242 | cmd->speed = priv->port_state.link_speed; |
Yevgeny Petrilin | c27a02c | 2008-10-22 15:47:49 -0700 | [diff] [blame] | 243 | cmd->duplex = DUPLEX_FULL; |
| 244 | } else { |
| 245 | cmd->speed = -1; |
| 246 | cmd->duplex = -1; |
| 247 | } |
Yevgeny Petrilin | 7699517 | 2010-08-24 03:46:23 +0000 | [diff] [blame] | 248 | |
| 249 | if (trans_type > 0 && trans_type <= 0xC) { |
| 250 | cmd->port = PORT_FIBRE; |
| 251 | cmd->transceiver = XCVR_EXTERNAL; |
| 252 | cmd->supported |= SUPPORTED_FIBRE; |
| 253 | cmd->advertising |= ADVERTISED_FIBRE; |
| 254 | } else if (trans_type == 0x80 || trans_type == 0) { |
| 255 | cmd->port = PORT_TP; |
| 256 | cmd->transceiver = XCVR_INTERNAL; |
| 257 | cmd->supported |= SUPPORTED_TP; |
| 258 | cmd->advertising |= ADVERTISED_TP; |
| 259 | } else { |
| 260 | cmd->port = -1; |
| 261 | cmd->transceiver = -1; |
| 262 | } |
Yevgeny Petrilin | c27a02c | 2008-10-22 15:47:49 -0700 | [diff] [blame] | 263 | return 0; |
| 264 | } |
| 265 | |
| 266 | static int mlx4_en_set_settings(struct net_device *dev, struct ethtool_cmd *cmd) |
| 267 | { |
| 268 | if ((cmd->autoneg == AUTONEG_ENABLE) || |
| 269 | (cmd->speed != SPEED_10000) || (cmd->duplex != DUPLEX_FULL)) |
| 270 | return -EINVAL; |
| 271 | |
| 272 | /* Nothing to change */ |
| 273 | return 0; |
| 274 | } |
| 275 | |
| 276 | static int mlx4_en_get_coalesce(struct net_device *dev, |
| 277 | struct ethtool_coalesce *coal) |
| 278 | { |
| 279 | struct mlx4_en_priv *priv = netdev_priv(dev); |
| 280 | |
| 281 | coal->tx_coalesce_usecs = 0; |
| 282 | coal->tx_max_coalesced_frames = 0; |
| 283 | coal->rx_coalesce_usecs = priv->rx_usecs; |
| 284 | coal->rx_max_coalesced_frames = priv->rx_frames; |
| 285 | |
| 286 | coal->pkt_rate_low = priv->pkt_rate_low; |
| 287 | coal->rx_coalesce_usecs_low = priv->rx_usecs_low; |
| 288 | coal->pkt_rate_high = priv->pkt_rate_high; |
| 289 | coal->rx_coalesce_usecs_high = priv->rx_usecs_high; |
| 290 | coal->rate_sample_interval = priv->sample_interval; |
| 291 | coal->use_adaptive_rx_coalesce = priv->adaptive_rx_coal; |
| 292 | return 0; |
| 293 | } |
| 294 | |
| 295 | static int mlx4_en_set_coalesce(struct net_device *dev, |
| 296 | struct ethtool_coalesce *coal) |
| 297 | { |
| 298 | struct mlx4_en_priv *priv = netdev_priv(dev); |
| 299 | int err, i; |
| 300 | |
| 301 | priv->rx_frames = (coal->rx_max_coalesced_frames == |
| 302 | MLX4_EN_AUTO_CONF) ? |
Yevgeny Petrilin | 3db36fb | 2009-06-01 23:23:13 +0000 | [diff] [blame] | 303 | MLX4_EN_RX_COAL_TARGET : |
Yevgeny Petrilin | c27a02c | 2008-10-22 15:47:49 -0700 | [diff] [blame] | 304 | coal->rx_max_coalesced_frames; |
| 305 | priv->rx_usecs = (coal->rx_coalesce_usecs == |
| 306 | MLX4_EN_AUTO_CONF) ? |
| 307 | MLX4_EN_RX_COAL_TIME : |
| 308 | coal->rx_coalesce_usecs; |
| 309 | |
| 310 | /* Set adaptive coalescing params */ |
| 311 | priv->pkt_rate_low = coal->pkt_rate_low; |
| 312 | priv->rx_usecs_low = coal->rx_coalesce_usecs_low; |
| 313 | priv->pkt_rate_high = coal->pkt_rate_high; |
| 314 | priv->rx_usecs_high = coal->rx_coalesce_usecs_high; |
| 315 | priv->sample_interval = coal->rate_sample_interval; |
| 316 | priv->adaptive_rx_coal = coal->use_adaptive_rx_coalesce; |
| 317 | priv->last_moder_time = MLX4_EN_AUTO_CONF; |
| 318 | if (priv->adaptive_rx_coal) |
| 319 | return 0; |
| 320 | |
| 321 | for (i = 0; i < priv->rx_ring_num; i++) { |
| 322 | priv->rx_cq[i].moder_cnt = priv->rx_frames; |
| 323 | priv->rx_cq[i].moder_time = priv->rx_usecs; |
| 324 | err = mlx4_en_set_cq_moder(priv, &priv->rx_cq[i]); |
| 325 | if (err) |
| 326 | return err; |
| 327 | } |
| 328 | return 0; |
| 329 | } |
| 330 | |
| 331 | static int mlx4_en_set_pauseparam(struct net_device *dev, |
| 332 | struct ethtool_pauseparam *pause) |
| 333 | { |
| 334 | struct mlx4_en_priv *priv = netdev_priv(dev); |
| 335 | struct mlx4_en_dev *mdev = priv->mdev; |
| 336 | int err; |
| 337 | |
Yevgeny Petrilin | d53b93f | 2008-11-05 04:48:36 +0000 | [diff] [blame] | 338 | priv->prof->tx_pause = pause->tx_pause != 0; |
| 339 | priv->prof->rx_pause = pause->rx_pause != 0; |
Yevgeny Petrilin | c27a02c | 2008-10-22 15:47:49 -0700 | [diff] [blame] | 340 | err = mlx4_SET_PORT_general(mdev->dev, priv->port, |
| 341 | priv->rx_skb_size + ETH_FCS_LEN, |
Yevgeny Petrilin | d53b93f | 2008-11-05 04:48:36 +0000 | [diff] [blame] | 342 | priv->prof->tx_pause, |
| 343 | priv->prof->tx_ppp, |
| 344 | priv->prof->rx_pause, |
| 345 | priv->prof->rx_ppp); |
Yevgeny Petrilin | c27a02c | 2008-10-22 15:47:49 -0700 | [diff] [blame] | 346 | if (err) |
Yevgeny Petrilin | 453a608 | 2009-06-01 20:27:13 +0000 | [diff] [blame] | 347 | en_err(priv, "Failed setting pause params\n"); |
Yevgeny Petrilin | c27a02c | 2008-10-22 15:47:49 -0700 | [diff] [blame] | 348 | |
| 349 | return err; |
| 350 | } |
| 351 | |
| 352 | static void mlx4_en_get_pauseparam(struct net_device *dev, |
| 353 | struct ethtool_pauseparam *pause) |
| 354 | { |
| 355 | struct mlx4_en_priv *priv = netdev_priv(dev); |
Yevgeny Petrilin | c27a02c | 2008-10-22 15:47:49 -0700 | [diff] [blame] | 356 | |
Yevgeny Petrilin | d53b93f | 2008-11-05 04:48:36 +0000 | [diff] [blame] | 357 | pause->tx_pause = priv->prof->tx_pause; |
| 358 | pause->rx_pause = priv->prof->rx_pause; |
Yevgeny Petrilin | c27a02c | 2008-10-22 15:47:49 -0700 | [diff] [blame] | 359 | } |
| 360 | |
Yevgeny Petrilin | 18cc42a | 2008-12-29 18:39:20 -0800 | [diff] [blame] | 361 | static int mlx4_en_set_ringparam(struct net_device *dev, |
| 362 | struct ethtool_ringparam *param) |
| 363 | { |
| 364 | struct mlx4_en_priv *priv = netdev_priv(dev); |
| 365 | struct mlx4_en_dev *mdev = priv->mdev; |
| 366 | u32 rx_size, tx_size; |
| 367 | int port_up = 0; |
| 368 | int err = 0; |
| 369 | |
| 370 | if (param->rx_jumbo_pending || param->rx_mini_pending) |
| 371 | return -EINVAL; |
| 372 | |
| 373 | rx_size = roundup_pow_of_two(param->rx_pending); |
| 374 | rx_size = max_t(u32, rx_size, MLX4_EN_MIN_RX_SIZE); |
Yevgeny Petrilin | bd531e3 | 2009-01-08 10:57:37 -0800 | [diff] [blame] | 375 | rx_size = min_t(u32, rx_size, MLX4_EN_MAX_RX_SIZE); |
Yevgeny Petrilin | 18cc42a | 2008-12-29 18:39:20 -0800 | [diff] [blame] | 376 | tx_size = roundup_pow_of_two(param->tx_pending); |
| 377 | tx_size = max_t(u32, tx_size, MLX4_EN_MIN_TX_SIZE); |
Yevgeny Petrilin | bd531e3 | 2009-01-08 10:57:37 -0800 | [diff] [blame] | 378 | tx_size = min_t(u32, tx_size, MLX4_EN_MAX_TX_SIZE); |
Yevgeny Petrilin | 18cc42a | 2008-12-29 18:39:20 -0800 | [diff] [blame] | 379 | |
Yevgeny Petrilin | bc081ce | 2010-08-24 03:46:34 +0000 | [diff] [blame] | 380 | if (rx_size == (priv->port_up ? priv->rx_ring[0].actual_size : |
| 381 | priv->rx_ring[0].size) && |
| 382 | tx_size == priv->tx_ring[0].size) |
Yevgeny Petrilin | 18cc42a | 2008-12-29 18:39:20 -0800 | [diff] [blame] | 383 | return 0; |
| 384 | |
| 385 | mutex_lock(&mdev->state_lock); |
| 386 | if (priv->port_up) { |
| 387 | port_up = 1; |
| 388 | mlx4_en_stop_port(dev); |
| 389 | } |
| 390 | |
Yevgeny Petrilin | 1fb9876 | 2011-03-22 22:37:52 +0000 | [diff] [blame^] | 391 | mlx4_en_free_resources(priv, true); |
Yevgeny Petrilin | 18cc42a | 2008-12-29 18:39:20 -0800 | [diff] [blame] | 392 | |
| 393 | priv->prof->tx_ring_size = tx_size; |
| 394 | priv->prof->rx_ring_size = rx_size; |
| 395 | |
| 396 | err = mlx4_en_alloc_resources(priv); |
| 397 | if (err) { |
Yevgeny Petrilin | 453a608 | 2009-06-01 20:27:13 +0000 | [diff] [blame] | 398 | en_err(priv, "Failed reallocating port resources\n"); |
Yevgeny Petrilin | 18cc42a | 2008-12-29 18:39:20 -0800 | [diff] [blame] | 399 | goto out; |
| 400 | } |
| 401 | if (port_up) { |
| 402 | err = mlx4_en_start_port(dev); |
| 403 | if (err) |
Yevgeny Petrilin | 453a608 | 2009-06-01 20:27:13 +0000 | [diff] [blame] | 404 | en_err(priv, "Failed starting port\n"); |
Yevgeny Petrilin | 18cc42a | 2008-12-29 18:39:20 -0800 | [diff] [blame] | 405 | } |
| 406 | |
| 407 | out: |
| 408 | mutex_unlock(&mdev->state_lock); |
| 409 | return err; |
| 410 | } |
| 411 | |
Yevgeny Petrilin | c27a02c | 2008-10-22 15:47:49 -0700 | [diff] [blame] | 412 | static void mlx4_en_get_ringparam(struct net_device *dev, |
| 413 | struct ethtool_ringparam *param) |
| 414 | { |
| 415 | struct mlx4_en_priv *priv = netdev_priv(dev); |
Yevgeny Petrilin | c27a02c | 2008-10-22 15:47:49 -0700 | [diff] [blame] | 416 | |
| 417 | memset(param, 0, sizeof(*param)); |
Yevgeny Petrilin | bd531e3 | 2009-01-08 10:57:37 -0800 | [diff] [blame] | 418 | param->rx_max_pending = MLX4_EN_MAX_RX_SIZE; |
| 419 | param->tx_max_pending = MLX4_EN_MAX_TX_SIZE; |
Yevgeny Petrilin | bc081ce | 2010-08-24 03:46:34 +0000 | [diff] [blame] | 420 | param->rx_pending = priv->port_up ? |
| 421 | priv->rx_ring[0].actual_size : priv->rx_ring[0].size; |
| 422 | param->tx_pending = priv->tx_ring[0].size; |
Yevgeny Petrilin | c27a02c | 2008-10-22 15:47:49 -0700 | [diff] [blame] | 423 | } |
| 424 | |
| 425 | const struct ethtool_ops mlx4_en_ethtool_ops = { |
| 426 | .get_drvinfo = mlx4_en_get_drvinfo, |
| 427 | .get_settings = mlx4_en_get_settings, |
| 428 | .set_settings = mlx4_en_set_settings, |
| 429 | #ifdef NETIF_F_TSO |
| 430 | .get_tso = mlx4_en_get_tso, |
| 431 | .set_tso = mlx4_en_set_tso, |
| 432 | #endif |
| 433 | .get_sg = ethtool_op_get_sg, |
| 434 | .set_sg = ethtool_op_set_sg, |
| 435 | .get_link = ethtool_op_get_link, |
| 436 | .get_rx_csum = mlx4_en_get_rx_csum, |
| 437 | .set_rx_csum = mlx4_en_set_rx_csum, |
| 438 | .get_tx_csum = ethtool_op_get_tx_csum, |
| 439 | .set_tx_csum = ethtool_op_set_tx_ipv6_csum, |
| 440 | .get_strings = mlx4_en_get_strings, |
| 441 | .get_sset_count = mlx4_en_get_sset_count, |
| 442 | .get_ethtool_stats = mlx4_en_get_ethtool_stats, |
Yevgeny Petrilin | e7c1c2c4 | 2010-08-24 03:46:18 +0000 | [diff] [blame] | 443 | .self_test = mlx4_en_self_test, |
Yevgeny Petrilin | c27a02c | 2008-10-22 15:47:49 -0700 | [diff] [blame] | 444 | .get_wol = mlx4_en_get_wol, |
| 445 | .get_msglevel = mlx4_en_get_msglevel, |
| 446 | .set_msglevel = mlx4_en_set_msglevel, |
| 447 | .get_coalesce = mlx4_en_get_coalesce, |
| 448 | .set_coalesce = mlx4_en_set_coalesce, |
| 449 | .get_pauseparam = mlx4_en_get_pauseparam, |
| 450 | .set_pauseparam = mlx4_en_set_pauseparam, |
| 451 | .get_ringparam = mlx4_en_get_ringparam, |
Yevgeny Petrilin | 18cc42a | 2008-12-29 18:39:20 -0800 | [diff] [blame] | 452 | .set_ringparam = mlx4_en_set_ringparam, |
Yevgeny Petrilin | c27a02c | 2008-10-22 15:47:49 -0700 | [diff] [blame] | 453 | .get_flags = ethtool_op_get_flags, |
Yevgeny Petrilin | c27a02c | 2008-10-22 15:47:49 -0700 | [diff] [blame] | 454 | }; |
| 455 | |
| 456 | |
| 457 | |
| 458 | |
| 459 | |