Greg Rose | fbb7ddf | 2013-12-21 06:12:56 +0000 | [diff] [blame] | 1 | /******************************************************************************* |
| 2 | * |
| 3 | * Intel Ethernet Controller XL710 Family Linux Virtual Function Driver |
Ashish Shah | 0e88898 | 2015-02-06 08:52:10 +0000 | [diff] [blame] | 4 | * Copyright(c) 2013 - 2015 Intel Corporation. |
Greg Rose | fbb7ddf | 2013-12-21 06:12:56 +0000 | [diff] [blame] | 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify it |
| 7 | * under the terms and conditions of the GNU General Public License, |
| 8 | * version 2, as published by the Free Software Foundation. |
| 9 | * |
| 10 | * This program is distributed in the hope it will be useful, but WITHOUT |
| 11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
| 13 | * more details. |
| 14 | * |
Jesse Brandeburg | b831607 | 2014-04-05 07:46:11 +0000 | [diff] [blame] | 15 | * You should have received a copy of the GNU General Public License along |
| 16 | * with this program. If not, see <http://www.gnu.org/licenses/>. |
| 17 | * |
Greg Rose | fbb7ddf | 2013-12-21 06:12:56 +0000 | [diff] [blame] | 18 | * The full GNU General Public License is included in this distribution in |
| 19 | * the file called "COPYING". |
| 20 | * |
| 21 | * Contact Information: |
| 22 | * e1000-devel Mailing List <e1000-devel@lists.sourceforge.net> |
| 23 | * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 |
| 24 | * |
| 25 | ******************************************************************************/ |
| 26 | |
| 27 | /* ethtool support for i40evf */ |
| 28 | #include "i40evf.h" |
| 29 | |
| 30 | #include <linux/uaccess.h> |
| 31 | |
Greg Rose | fbb7ddf | 2013-12-21 06:12:56 +0000 | [diff] [blame] | 32 | struct i40evf_stats { |
| 33 | char stat_string[ETH_GSTRING_LEN]; |
| 34 | int stat_offset; |
| 35 | }; |
| 36 | |
| 37 | #define I40EVF_STAT(_name, _stat) { \ |
| 38 | .stat_string = _name, \ |
| 39 | .stat_offset = offsetof(struct i40evf_adapter, _stat) \ |
| 40 | } |
| 41 | |
| 42 | /* All stats are u64, so we don't need to track the size of the field. */ |
| 43 | static const struct i40evf_stats i40evf_gstrings_stats[] = { |
| 44 | I40EVF_STAT("rx_bytes", current_stats.rx_bytes), |
| 45 | I40EVF_STAT("rx_unicast", current_stats.rx_unicast), |
| 46 | I40EVF_STAT("rx_multicast", current_stats.rx_multicast), |
| 47 | I40EVF_STAT("rx_broadcast", current_stats.rx_broadcast), |
| 48 | I40EVF_STAT("rx_discards", current_stats.rx_discards), |
Greg Rose | fbb7ddf | 2013-12-21 06:12:56 +0000 | [diff] [blame] | 49 | I40EVF_STAT("rx_unknown_protocol", current_stats.rx_unknown_protocol), |
| 50 | I40EVF_STAT("tx_bytes", current_stats.tx_bytes), |
| 51 | I40EVF_STAT("tx_unicast", current_stats.tx_unicast), |
| 52 | I40EVF_STAT("tx_multicast", current_stats.tx_multicast), |
| 53 | I40EVF_STAT("tx_broadcast", current_stats.tx_broadcast), |
| 54 | I40EVF_STAT("tx_discards", current_stats.tx_discards), |
| 55 | I40EVF_STAT("tx_errors", current_stats.tx_errors), |
| 56 | }; |
| 57 | |
| 58 | #define I40EVF_GLOBAL_STATS_LEN ARRAY_SIZE(i40evf_gstrings_stats) |
Mitch Williams | c7b8d97 | 2014-04-04 04:43:08 +0000 | [diff] [blame] | 59 | #define I40EVF_QUEUE_STATS_LEN(_dev) \ |
Mitch Williams | 75a6443 | 2014-11-11 20:02:42 +0000 | [diff] [blame] | 60 | (((struct i40evf_adapter *)\ |
Mitch Williams | cc05292 | 2014-10-25 03:24:34 +0000 | [diff] [blame] | 61 | netdev_priv(_dev))->num_active_queues \ |
Mitch Williams | c7b8d97 | 2014-04-04 04:43:08 +0000 | [diff] [blame] | 62 | * 2 * (sizeof(struct i40e_queue_stats) / sizeof(u64))) |
| 63 | #define I40EVF_STATS_LEN(_dev) \ |
| 64 | (I40EVF_GLOBAL_STATS_LEN + I40EVF_QUEUE_STATS_LEN(_dev)) |
Greg Rose | fbb7ddf | 2013-12-21 06:12:56 +0000 | [diff] [blame] | 65 | |
| 66 | /** |
| 67 | * i40evf_get_settings - Get Link Speed and Duplex settings |
| 68 | * @netdev: network interface device structure |
| 69 | * @ecmd: ethtool command |
| 70 | * |
| 71 | * Reports speed/duplex settings. Because this is a VF, we don't know what |
| 72 | * kind of link we really have, so we fake it. |
| 73 | **/ |
| 74 | static int i40evf_get_settings(struct net_device *netdev, |
| 75 | struct ethtool_cmd *ecmd) |
| 76 | { |
| 77 | /* In the future the VF will be able to query the PF for |
| 78 | * some information - for now use a dummy value |
| 79 | */ |
Mitch Williams | 107f301 | 2014-04-04 04:43:09 +0000 | [diff] [blame] | 80 | ecmd->supported = 0; |
Greg Rose | fbb7ddf | 2013-12-21 06:12:56 +0000 | [diff] [blame] | 81 | ecmd->autoneg = AUTONEG_DISABLE; |
| 82 | ecmd->transceiver = XCVR_DUMMY1; |
| 83 | ecmd->port = PORT_NONE; |
| 84 | |
| 85 | return 0; |
| 86 | } |
| 87 | |
| 88 | /** |
| 89 | * i40evf_get_sset_count - Get length of string set |
| 90 | * @netdev: network interface device structure |
| 91 | * @sset: id of string set |
| 92 | * |
| 93 | * Reports size of string table. This driver only supports |
| 94 | * strings for statistics. |
| 95 | **/ |
| 96 | static int i40evf_get_sset_count(struct net_device *netdev, int sset) |
| 97 | { |
| 98 | if (sset == ETH_SS_STATS) |
Mitch Williams | c7b8d97 | 2014-04-04 04:43:08 +0000 | [diff] [blame] | 99 | return I40EVF_STATS_LEN(netdev); |
Greg Rose | fbb7ddf | 2013-12-21 06:12:56 +0000 | [diff] [blame] | 100 | else |
Mitch Williams | c7b8d97 | 2014-04-04 04:43:08 +0000 | [diff] [blame] | 101 | return -EINVAL; |
Greg Rose | fbb7ddf | 2013-12-21 06:12:56 +0000 | [diff] [blame] | 102 | } |
| 103 | |
| 104 | /** |
| 105 | * i40evf_get_ethtool_stats - report device statistics |
| 106 | * @netdev: network interface device structure |
| 107 | * @stats: ethtool statistics structure |
| 108 | * @data: pointer to data buffer |
| 109 | * |
| 110 | * All statistics are added to the data buffer as an array of u64. |
| 111 | **/ |
| 112 | static void i40evf_get_ethtool_stats(struct net_device *netdev, |
| 113 | struct ethtool_stats *stats, u64 *data) |
| 114 | { |
| 115 | struct i40evf_adapter *adapter = netdev_priv(netdev); |
| 116 | int i, j; |
| 117 | char *p; |
| 118 | |
| 119 | for (i = 0; i < I40EVF_GLOBAL_STATS_LEN; i++) { |
| 120 | p = (char *)adapter + i40evf_gstrings_stats[i].stat_offset; |
| 121 | data[i] = *(u64 *)p; |
| 122 | } |
Mitch Williams | cc05292 | 2014-10-25 03:24:34 +0000 | [diff] [blame] | 123 | for (j = 0; j < adapter->num_active_queues; j++) { |
Mitch Williams | 0dd438d | 2015-10-26 19:44:40 -0400 | [diff] [blame^] | 124 | data[i++] = adapter->tx_rings[j].stats.packets; |
| 125 | data[i++] = adapter->tx_rings[j].stats.bytes; |
Greg Rose | fbb7ddf | 2013-12-21 06:12:56 +0000 | [diff] [blame] | 126 | } |
Mitch Williams | cc05292 | 2014-10-25 03:24:34 +0000 | [diff] [blame] | 127 | for (j = 0; j < adapter->num_active_queues; j++) { |
Mitch Williams | 0dd438d | 2015-10-26 19:44:40 -0400 | [diff] [blame^] | 128 | data[i++] = adapter->rx_rings[j].stats.packets; |
| 129 | data[i++] = adapter->rx_rings[j].stats.bytes; |
Greg Rose | fbb7ddf | 2013-12-21 06:12:56 +0000 | [diff] [blame] | 130 | } |
| 131 | } |
| 132 | |
| 133 | /** |
| 134 | * i40evf_get_strings - Get string set |
| 135 | * @netdev: network interface device structure |
| 136 | * @sset: id of string set |
| 137 | * @data: buffer for string data |
| 138 | * |
| 139 | * Builds stats string table. |
| 140 | **/ |
| 141 | static void i40evf_get_strings(struct net_device *netdev, u32 sset, u8 *data) |
| 142 | { |
| 143 | struct i40evf_adapter *adapter = netdev_priv(netdev); |
| 144 | u8 *p = data; |
| 145 | int i; |
| 146 | |
| 147 | if (sset == ETH_SS_STATS) { |
| 148 | for (i = 0; i < I40EVF_GLOBAL_STATS_LEN; i++) { |
| 149 | memcpy(p, i40evf_gstrings_stats[i].stat_string, |
| 150 | ETH_GSTRING_LEN); |
| 151 | p += ETH_GSTRING_LEN; |
| 152 | } |
Mitch Williams | cc05292 | 2014-10-25 03:24:34 +0000 | [diff] [blame] | 153 | for (i = 0; i < adapter->num_active_queues; i++) { |
Greg Rose | fbb7ddf | 2013-12-21 06:12:56 +0000 | [diff] [blame] | 154 | snprintf(p, ETH_GSTRING_LEN, "tx-%u.packets", i); |
| 155 | p += ETH_GSTRING_LEN; |
| 156 | snprintf(p, ETH_GSTRING_LEN, "tx-%u.bytes", i); |
| 157 | p += ETH_GSTRING_LEN; |
| 158 | } |
Mitch Williams | cc05292 | 2014-10-25 03:24:34 +0000 | [diff] [blame] | 159 | for (i = 0; i < adapter->num_active_queues; i++) { |
Greg Rose | fbb7ddf | 2013-12-21 06:12:56 +0000 | [diff] [blame] | 160 | snprintf(p, ETH_GSTRING_LEN, "rx-%u.packets", i); |
| 161 | p += ETH_GSTRING_LEN; |
| 162 | snprintf(p, ETH_GSTRING_LEN, "rx-%u.bytes", i); |
| 163 | p += ETH_GSTRING_LEN; |
| 164 | } |
| 165 | } |
| 166 | } |
| 167 | |
| 168 | /** |
| 169 | * i40evf_get_msglevel - Get debug message level |
| 170 | * @netdev: network interface device structure |
| 171 | * |
| 172 | * Returns current debug message level. |
| 173 | **/ |
| 174 | static u32 i40evf_get_msglevel(struct net_device *netdev) |
| 175 | { |
| 176 | struct i40evf_adapter *adapter = netdev_priv(netdev); |
Mitch Williams | 75a6443 | 2014-11-11 20:02:42 +0000 | [diff] [blame] | 177 | |
Greg Rose | fbb7ddf | 2013-12-21 06:12:56 +0000 | [diff] [blame] | 178 | return adapter->msg_enable; |
| 179 | } |
| 180 | |
| 181 | /** |
Ashish Shah | 0e88898 | 2015-02-06 08:52:10 +0000 | [diff] [blame] | 182 | * i40evf_set_msglevel - Set debug message level |
Greg Rose | fbb7ddf | 2013-12-21 06:12:56 +0000 | [diff] [blame] | 183 | * @netdev: network interface device structure |
| 184 | * @data: message level |
| 185 | * |
| 186 | * Set current debug message level. Higher values cause the driver to |
| 187 | * be noisier. |
| 188 | **/ |
| 189 | static void i40evf_set_msglevel(struct net_device *netdev, u32 data) |
| 190 | { |
| 191 | struct i40evf_adapter *adapter = netdev_priv(netdev); |
Mitch Williams | 75a6443 | 2014-11-11 20:02:42 +0000 | [diff] [blame] | 192 | |
Ashish Shah | 0e88898 | 2015-02-06 08:52:10 +0000 | [diff] [blame] | 193 | if (I40E_DEBUG_USER & data) |
| 194 | adapter->hw.debug_mask = data; |
Greg Rose | fbb7ddf | 2013-12-21 06:12:56 +0000 | [diff] [blame] | 195 | adapter->msg_enable = data; |
| 196 | } |
| 197 | |
| 198 | /** |
Jesse Brandeburg | b39c1e2 | 2014-08-01 13:27:08 -0700 | [diff] [blame] | 199 | * i40evf_get_drvinfo - Get driver info |
Greg Rose | fbb7ddf | 2013-12-21 06:12:56 +0000 | [diff] [blame] | 200 | * @netdev: network interface device structure |
| 201 | * @drvinfo: ethool driver info structure |
| 202 | * |
| 203 | * Returns information about the driver and device for display to the user. |
| 204 | **/ |
| 205 | static void i40evf_get_drvinfo(struct net_device *netdev, |
| 206 | struct ethtool_drvinfo *drvinfo) |
| 207 | { |
| 208 | struct i40evf_adapter *adapter = netdev_priv(netdev); |
| 209 | |
| 210 | strlcpy(drvinfo->driver, i40evf_driver_name, 32); |
| 211 | strlcpy(drvinfo->version, i40evf_driver_version, 32); |
Mitch Williams | cc470a8 | 2015-03-27 00:12:11 -0700 | [diff] [blame] | 212 | strlcpy(drvinfo->fw_version, "N/A", 4); |
Greg Rose | fbb7ddf | 2013-12-21 06:12:56 +0000 | [diff] [blame] | 213 | strlcpy(drvinfo->bus_info, pci_name(adapter->pdev), 32); |
| 214 | } |
| 215 | |
| 216 | /** |
| 217 | * i40evf_get_ringparam - Get ring parameters |
| 218 | * @netdev: network interface device structure |
| 219 | * @ring: ethtool ringparam structure |
| 220 | * |
| 221 | * Returns current ring parameters. TX and RX rings are reported separately, |
| 222 | * but the number of rings is not reported. |
| 223 | **/ |
| 224 | static void i40evf_get_ringparam(struct net_device *netdev, |
Mitch Williams | 75a6443 | 2014-11-11 20:02:42 +0000 | [diff] [blame] | 225 | struct ethtool_ringparam *ring) |
Greg Rose | fbb7ddf | 2013-12-21 06:12:56 +0000 | [diff] [blame] | 226 | { |
| 227 | struct i40evf_adapter *adapter = netdev_priv(netdev); |
Greg Rose | fbb7ddf | 2013-12-21 06:12:56 +0000 | [diff] [blame] | 228 | |
| 229 | ring->rx_max_pending = I40EVF_MAX_RXD; |
| 230 | ring->tx_max_pending = I40EVF_MAX_TXD; |
Mitch Williams | d732a18 | 2014-04-24 06:41:37 +0000 | [diff] [blame] | 231 | ring->rx_pending = adapter->rx_desc_count; |
| 232 | ring->tx_pending = adapter->tx_desc_count; |
Greg Rose | fbb7ddf | 2013-12-21 06:12:56 +0000 | [diff] [blame] | 233 | } |
| 234 | |
| 235 | /** |
| 236 | * i40evf_set_ringparam - Set ring parameters |
| 237 | * @netdev: network interface device structure |
| 238 | * @ring: ethtool ringparam structure |
| 239 | * |
| 240 | * Sets ring parameters. TX and RX rings are controlled separately, but the |
| 241 | * number of rings is not specified, so all rings get the same settings. |
| 242 | **/ |
| 243 | static int i40evf_set_ringparam(struct net_device *netdev, |
| 244 | struct ethtool_ringparam *ring) |
| 245 | { |
| 246 | struct i40evf_adapter *adapter = netdev_priv(netdev); |
| 247 | u32 new_rx_count, new_tx_count; |
| 248 | |
| 249 | if ((ring->rx_mini_pending) || (ring->rx_jumbo_pending)) |
| 250 | return -EINVAL; |
| 251 | |
| 252 | new_tx_count = clamp_t(u32, ring->tx_pending, |
| 253 | I40EVF_MIN_TXD, |
| 254 | I40EVF_MAX_TXD); |
| 255 | new_tx_count = ALIGN(new_tx_count, I40EVF_REQ_DESCRIPTOR_MULTIPLE); |
| 256 | |
| 257 | new_rx_count = clamp_t(u32, ring->rx_pending, |
| 258 | I40EVF_MIN_RXD, |
| 259 | I40EVF_MAX_RXD); |
| 260 | new_rx_count = ALIGN(new_rx_count, I40EVF_REQ_DESCRIPTOR_MULTIPLE); |
| 261 | |
| 262 | /* if nothing to do return success */ |
Mitch Williams | d732a18 | 2014-04-24 06:41:37 +0000 | [diff] [blame] | 263 | if ((new_tx_count == adapter->tx_desc_count) && |
| 264 | (new_rx_count == adapter->rx_desc_count)) |
Greg Rose | fbb7ddf | 2013-12-21 06:12:56 +0000 | [diff] [blame] | 265 | return 0; |
| 266 | |
Mitch Williams | d732a18 | 2014-04-24 06:41:37 +0000 | [diff] [blame] | 267 | adapter->tx_desc_count = new_tx_count; |
| 268 | adapter->rx_desc_count = new_rx_count; |
Greg Rose | fbb7ddf | 2013-12-21 06:12:56 +0000 | [diff] [blame] | 269 | |
Mitch Williams | 67c818a | 2015-06-19 08:56:30 -0700 | [diff] [blame] | 270 | if (netif_running(netdev)) { |
| 271 | adapter->flags |= I40EVF_FLAG_RESET_NEEDED; |
| 272 | schedule_work(&adapter->reset_task); |
| 273 | } |
Mitch Williams | d732a18 | 2014-04-24 06:41:37 +0000 | [diff] [blame] | 274 | |
Greg Rose | fbb7ddf | 2013-12-21 06:12:56 +0000 | [diff] [blame] | 275 | return 0; |
| 276 | } |
| 277 | |
| 278 | /** |
| 279 | * i40evf_get_coalesce - Get interrupt coalescing settings |
| 280 | * @netdev: network interface device structure |
| 281 | * @ec: ethtool coalesce structure |
| 282 | * |
| 283 | * Returns current coalescing settings. This is referred to elsewhere in the |
| 284 | * driver as Interrupt Throttle Rate, as this is how the hardware describes |
| 285 | * this functionality. |
| 286 | **/ |
| 287 | static int i40evf_get_coalesce(struct net_device *netdev, |
Mitch Williams | 75a6443 | 2014-11-11 20:02:42 +0000 | [diff] [blame] | 288 | struct ethtool_coalesce *ec) |
Greg Rose | fbb7ddf | 2013-12-21 06:12:56 +0000 | [diff] [blame] | 289 | { |
| 290 | struct i40evf_adapter *adapter = netdev_priv(netdev); |
| 291 | struct i40e_vsi *vsi = &adapter->vsi; |
| 292 | |
| 293 | ec->tx_max_coalesced_frames = vsi->work_limit; |
| 294 | ec->rx_max_coalesced_frames = vsi->work_limit; |
| 295 | |
| 296 | if (ITR_IS_DYNAMIC(vsi->rx_itr_setting)) |
Mitch Williams | 32f5f54 | 2014-04-04 04:43:10 +0000 | [diff] [blame] | 297 | ec->use_adaptive_rx_coalesce = 1; |
Greg Rose | fbb7ddf | 2013-12-21 06:12:56 +0000 | [diff] [blame] | 298 | |
| 299 | if (ITR_IS_DYNAMIC(vsi->tx_itr_setting)) |
Mitch Williams | 32f5f54 | 2014-04-04 04:43:10 +0000 | [diff] [blame] | 300 | ec->use_adaptive_tx_coalesce = 1; |
| 301 | |
| 302 | ec->rx_coalesce_usecs = vsi->rx_itr_setting & ~I40E_ITR_DYNAMIC; |
| 303 | ec->tx_coalesce_usecs = vsi->tx_itr_setting & ~I40E_ITR_DYNAMIC; |
Greg Rose | fbb7ddf | 2013-12-21 06:12:56 +0000 | [diff] [blame] | 304 | |
| 305 | return 0; |
| 306 | } |
| 307 | |
| 308 | /** |
| 309 | * i40evf_set_coalesce - Set interrupt coalescing settings |
| 310 | * @netdev: network interface device structure |
| 311 | * @ec: ethtool coalesce structure |
| 312 | * |
| 313 | * Change current coalescing settings. |
| 314 | **/ |
| 315 | static int i40evf_set_coalesce(struct net_device *netdev, |
Mitch Williams | 75a6443 | 2014-11-11 20:02:42 +0000 | [diff] [blame] | 316 | struct ethtool_coalesce *ec) |
Greg Rose | fbb7ddf | 2013-12-21 06:12:56 +0000 | [diff] [blame] | 317 | { |
| 318 | struct i40evf_adapter *adapter = netdev_priv(netdev); |
| 319 | struct i40e_hw *hw = &adapter->hw; |
| 320 | struct i40e_vsi *vsi = &adapter->vsi; |
| 321 | struct i40e_q_vector *q_vector; |
| 322 | int i; |
| 323 | |
Mitch Williams | 32f5f54 | 2014-04-04 04:43:10 +0000 | [diff] [blame] | 324 | if (ec->tx_max_coalesced_frames_irq || ec->rx_max_coalesced_frames_irq) |
| 325 | vsi->work_limit = ec->tx_max_coalesced_frames_irq; |
Greg Rose | fbb7ddf | 2013-12-21 06:12:56 +0000 | [diff] [blame] | 326 | |
Mitch Williams | 32f5f54 | 2014-04-04 04:43:10 +0000 | [diff] [blame] | 327 | if ((ec->rx_coalesce_usecs >= (I40E_MIN_ITR << 1)) && |
| 328 | (ec->rx_coalesce_usecs <= (I40E_MAX_ITR << 1))) |
Greg Rose | fbb7ddf | 2013-12-21 06:12:56 +0000 | [diff] [blame] | 329 | vsi->rx_itr_setting = ec->rx_coalesce_usecs; |
Greg Rose | fbb7ddf | 2013-12-21 06:12:56 +0000 | [diff] [blame] | 330 | |
Mitch Williams | 32f5f54 | 2014-04-04 04:43:10 +0000 | [diff] [blame] | 331 | else |
| 332 | return -EINVAL; |
| 333 | |
| 334 | if ((ec->tx_coalesce_usecs >= (I40E_MIN_ITR << 1)) && |
| 335 | (ec->tx_coalesce_usecs <= (I40E_MAX_ITR << 1))) |
Greg Rose | fbb7ddf | 2013-12-21 06:12:56 +0000 | [diff] [blame] | 336 | vsi->tx_itr_setting = ec->tx_coalesce_usecs; |
Mitch Williams | 32f5f54 | 2014-04-04 04:43:10 +0000 | [diff] [blame] | 337 | else if (ec->use_adaptive_tx_coalesce) |
| 338 | vsi->tx_itr_setting = (I40E_ITR_DYNAMIC | |
| 339 | ITR_REG_TO_USEC(I40E_ITR_RX_DEF)); |
| 340 | else |
| 341 | return -EINVAL; |
| 342 | |
| 343 | if (ec->use_adaptive_rx_coalesce) |
| 344 | vsi->rx_itr_setting |= I40E_ITR_DYNAMIC; |
| 345 | else |
| 346 | vsi->rx_itr_setting &= ~I40E_ITR_DYNAMIC; |
| 347 | |
| 348 | if (ec->use_adaptive_tx_coalesce) |
| 349 | vsi->tx_itr_setting |= I40E_ITR_DYNAMIC; |
| 350 | else |
| 351 | vsi->tx_itr_setting &= ~I40E_ITR_DYNAMIC; |
Greg Rose | fbb7ddf | 2013-12-21 06:12:56 +0000 | [diff] [blame] | 352 | |
| 353 | for (i = 0; i < adapter->num_msix_vectors - NONQ_VECS; i++) { |
Mitch Williams | 7d96ba1 | 2015-10-26 19:44:39 -0400 | [diff] [blame] | 354 | q_vector = &adapter->q_vectors[i]; |
Greg Rose | fbb7ddf | 2013-12-21 06:12:56 +0000 | [diff] [blame] | 355 | q_vector->rx.itr = ITR_TO_REG(vsi->rx_itr_setting); |
| 356 | wr32(hw, I40E_VFINT_ITRN1(0, i), q_vector->rx.itr); |
| 357 | q_vector->tx.itr = ITR_TO_REG(vsi->tx_itr_setting); |
| 358 | wr32(hw, I40E_VFINT_ITRN1(1, i), q_vector->tx.itr); |
| 359 | i40e_flush(hw); |
| 360 | } |
| 361 | |
| 362 | return 0; |
| 363 | } |
| 364 | |
Mitch A Williams | 4e9dc31 | 2014-04-01 04:43:49 +0000 | [diff] [blame] | 365 | /** |
| 366 | * i40e_get_rss_hash_opts - Get RSS hash Input Set for each flow type |
| 367 | * @adapter: board private structure |
| 368 | * @cmd: ethtool rxnfc command |
| 369 | * |
| 370 | * Returns Success if the flow is supported, else Invalid Input. |
| 371 | **/ |
| 372 | static int i40evf_get_rss_hash_opts(struct i40evf_adapter *adapter, |
| 373 | struct ethtool_rxnfc *cmd) |
| 374 | { |
| 375 | struct i40e_hw *hw = &adapter->hw; |
| 376 | u64 hena = (u64)rd32(hw, I40E_VFQF_HENA(0)) | |
| 377 | ((u64)rd32(hw, I40E_VFQF_HENA(1)) << 32); |
| 378 | |
| 379 | /* We always hash on IP src and dest addresses */ |
| 380 | cmd->data = RXH_IP_SRC | RXH_IP_DST; |
| 381 | |
| 382 | switch (cmd->flow_type) { |
| 383 | case TCP_V4_FLOW: |
Jesse Brandeburg | 41a1d04 | 2015-06-04 16:24:02 -0400 | [diff] [blame] | 384 | if (hena & BIT_ULL(I40E_FILTER_PCTYPE_NONF_IPV4_TCP)) |
Mitch A Williams | 4e9dc31 | 2014-04-01 04:43:49 +0000 | [diff] [blame] | 385 | cmd->data |= RXH_L4_B_0_1 | RXH_L4_B_2_3; |
| 386 | break; |
| 387 | case UDP_V4_FLOW: |
Jesse Brandeburg | 41a1d04 | 2015-06-04 16:24:02 -0400 | [diff] [blame] | 388 | if (hena & BIT_ULL(I40E_FILTER_PCTYPE_NONF_IPV4_UDP)) |
Mitch A Williams | 4e9dc31 | 2014-04-01 04:43:49 +0000 | [diff] [blame] | 389 | cmd->data |= RXH_L4_B_0_1 | RXH_L4_B_2_3; |
| 390 | break; |
| 391 | |
| 392 | case SCTP_V4_FLOW: |
| 393 | case AH_ESP_V4_FLOW: |
| 394 | case AH_V4_FLOW: |
| 395 | case ESP_V4_FLOW: |
| 396 | case IPV4_FLOW: |
| 397 | break; |
| 398 | |
| 399 | case TCP_V6_FLOW: |
Jesse Brandeburg | 41a1d04 | 2015-06-04 16:24:02 -0400 | [diff] [blame] | 400 | if (hena & BIT_ULL(I40E_FILTER_PCTYPE_NONF_IPV6_TCP)) |
Mitch A Williams | 4e9dc31 | 2014-04-01 04:43:49 +0000 | [diff] [blame] | 401 | cmd->data |= RXH_L4_B_0_1 | RXH_L4_B_2_3; |
| 402 | break; |
| 403 | case UDP_V6_FLOW: |
Jesse Brandeburg | 41a1d04 | 2015-06-04 16:24:02 -0400 | [diff] [blame] | 404 | if (hena & BIT_ULL(I40E_FILTER_PCTYPE_NONF_IPV6_UDP)) |
Mitch A Williams | 4e9dc31 | 2014-04-01 04:43:49 +0000 | [diff] [blame] | 405 | cmd->data |= RXH_L4_B_0_1 | RXH_L4_B_2_3; |
| 406 | break; |
| 407 | |
| 408 | case SCTP_V6_FLOW: |
| 409 | case AH_ESP_V6_FLOW: |
| 410 | case AH_V6_FLOW: |
| 411 | case ESP_V6_FLOW: |
| 412 | case IPV6_FLOW: |
| 413 | break; |
| 414 | default: |
| 415 | cmd->data = 0; |
| 416 | return -EINVAL; |
| 417 | } |
| 418 | |
| 419 | return 0; |
| 420 | } |
| 421 | |
| 422 | /** |
| 423 | * i40evf_get_rxnfc - command to get RX flow classification rules |
| 424 | * @netdev: network interface device structure |
| 425 | * @cmd: ethtool rxnfc command |
| 426 | * |
| 427 | * Returns Success if the command is supported. |
| 428 | **/ |
| 429 | static int i40evf_get_rxnfc(struct net_device *netdev, |
| 430 | struct ethtool_rxnfc *cmd, |
| 431 | u32 *rule_locs) |
| 432 | { |
| 433 | struct i40evf_adapter *adapter = netdev_priv(netdev); |
| 434 | int ret = -EOPNOTSUPP; |
| 435 | |
| 436 | switch (cmd->cmd) { |
| 437 | case ETHTOOL_GRXRINGS: |
Mitch Williams | cc05292 | 2014-10-25 03:24:34 +0000 | [diff] [blame] | 438 | cmd->data = adapter->num_active_queues; |
Mitch A Williams | 4e9dc31 | 2014-04-01 04:43:49 +0000 | [diff] [blame] | 439 | ret = 0; |
| 440 | break; |
| 441 | case ETHTOOL_GRXFH: |
| 442 | ret = i40evf_get_rss_hash_opts(adapter, cmd); |
| 443 | break; |
| 444 | default: |
| 445 | break; |
| 446 | } |
| 447 | |
| 448 | return ret; |
| 449 | } |
| 450 | |
| 451 | /** |
| 452 | * i40evf_set_rss_hash_opt - Enable/Disable flow types for RSS hash |
| 453 | * @adapter: board private structure |
| 454 | * @cmd: ethtool rxnfc command |
| 455 | * |
| 456 | * Returns Success if the flow input set is supported. |
| 457 | **/ |
| 458 | static int i40evf_set_rss_hash_opt(struct i40evf_adapter *adapter, |
| 459 | struct ethtool_rxnfc *nfc) |
| 460 | { |
| 461 | struct i40e_hw *hw = &adapter->hw; |
| 462 | |
| 463 | u64 hena = (u64)rd32(hw, I40E_VFQF_HENA(0)) | |
| 464 | ((u64)rd32(hw, I40E_VFQF_HENA(1)) << 32); |
| 465 | |
| 466 | /* RSS does not support anything other than hashing |
| 467 | * to queues on src and dst IPs and ports |
| 468 | */ |
| 469 | if (nfc->data & ~(RXH_IP_SRC | RXH_IP_DST | |
| 470 | RXH_L4_B_0_1 | RXH_L4_B_2_3)) |
| 471 | return -EINVAL; |
| 472 | |
| 473 | /* We need at least the IP SRC and DEST fields for hashing */ |
| 474 | if (!(nfc->data & RXH_IP_SRC) || |
| 475 | !(nfc->data & RXH_IP_DST)) |
| 476 | return -EINVAL; |
| 477 | |
| 478 | switch (nfc->flow_type) { |
| 479 | case TCP_V4_FLOW: |
| 480 | switch (nfc->data & (RXH_L4_B_0_1 | RXH_L4_B_2_3)) { |
| 481 | case 0: |
Jesse Brandeburg | 41a1d04 | 2015-06-04 16:24:02 -0400 | [diff] [blame] | 482 | hena &= ~BIT_ULL(I40E_FILTER_PCTYPE_NONF_IPV4_TCP); |
Mitch A Williams | 4e9dc31 | 2014-04-01 04:43:49 +0000 | [diff] [blame] | 483 | break; |
| 484 | case (RXH_L4_B_0_1 | RXH_L4_B_2_3): |
Jesse Brandeburg | 41a1d04 | 2015-06-04 16:24:02 -0400 | [diff] [blame] | 485 | hena |= BIT_ULL(I40E_FILTER_PCTYPE_NONF_IPV4_TCP); |
Mitch A Williams | 4e9dc31 | 2014-04-01 04:43:49 +0000 | [diff] [blame] | 486 | break; |
| 487 | default: |
| 488 | return -EINVAL; |
| 489 | } |
| 490 | break; |
| 491 | case TCP_V6_FLOW: |
| 492 | switch (nfc->data & (RXH_L4_B_0_1 | RXH_L4_B_2_3)) { |
| 493 | case 0: |
Jesse Brandeburg | 41a1d04 | 2015-06-04 16:24:02 -0400 | [diff] [blame] | 494 | hena &= ~BIT_ULL(I40E_FILTER_PCTYPE_NONF_IPV6_TCP); |
Mitch A Williams | 4e9dc31 | 2014-04-01 04:43:49 +0000 | [diff] [blame] | 495 | break; |
| 496 | case (RXH_L4_B_0_1 | RXH_L4_B_2_3): |
Jesse Brandeburg | 41a1d04 | 2015-06-04 16:24:02 -0400 | [diff] [blame] | 497 | hena |= BIT_ULL(I40E_FILTER_PCTYPE_NONF_IPV6_TCP); |
Mitch A Williams | 4e9dc31 | 2014-04-01 04:43:49 +0000 | [diff] [blame] | 498 | break; |
| 499 | default: |
| 500 | return -EINVAL; |
| 501 | } |
| 502 | break; |
| 503 | case UDP_V4_FLOW: |
| 504 | switch (nfc->data & (RXH_L4_B_0_1 | RXH_L4_B_2_3)) { |
| 505 | case 0: |
Jesse Brandeburg | 41a1d04 | 2015-06-04 16:24:02 -0400 | [diff] [blame] | 506 | hena &= ~(BIT_ULL(I40E_FILTER_PCTYPE_NONF_IPV4_UDP) | |
| 507 | BIT_ULL(I40E_FILTER_PCTYPE_FRAG_IPV4)); |
Mitch A Williams | 4e9dc31 | 2014-04-01 04:43:49 +0000 | [diff] [blame] | 508 | break; |
| 509 | case (RXH_L4_B_0_1 | RXH_L4_B_2_3): |
Jesse Brandeburg | 41a1d04 | 2015-06-04 16:24:02 -0400 | [diff] [blame] | 510 | hena |= (BIT_ULL(I40E_FILTER_PCTYPE_NONF_IPV4_UDP) | |
| 511 | BIT_ULL(I40E_FILTER_PCTYPE_FRAG_IPV4)); |
Mitch A Williams | 4e9dc31 | 2014-04-01 04:43:49 +0000 | [diff] [blame] | 512 | break; |
| 513 | default: |
| 514 | return -EINVAL; |
| 515 | } |
| 516 | break; |
| 517 | case UDP_V6_FLOW: |
| 518 | switch (nfc->data & (RXH_L4_B_0_1 | RXH_L4_B_2_3)) { |
| 519 | case 0: |
Jesse Brandeburg | 41a1d04 | 2015-06-04 16:24:02 -0400 | [diff] [blame] | 520 | hena &= ~(BIT_ULL(I40E_FILTER_PCTYPE_NONF_IPV6_UDP) | |
| 521 | BIT_ULL(I40E_FILTER_PCTYPE_FRAG_IPV6)); |
Mitch A Williams | 4e9dc31 | 2014-04-01 04:43:49 +0000 | [diff] [blame] | 522 | break; |
| 523 | case (RXH_L4_B_0_1 | RXH_L4_B_2_3): |
Jesse Brandeburg | 41a1d04 | 2015-06-04 16:24:02 -0400 | [diff] [blame] | 524 | hena |= (BIT_ULL(I40E_FILTER_PCTYPE_NONF_IPV6_UDP) | |
| 525 | BIT_ULL(I40E_FILTER_PCTYPE_FRAG_IPV6)); |
Mitch A Williams | 4e9dc31 | 2014-04-01 04:43:49 +0000 | [diff] [blame] | 526 | break; |
| 527 | default: |
| 528 | return -EINVAL; |
| 529 | } |
| 530 | break; |
| 531 | case AH_ESP_V4_FLOW: |
| 532 | case AH_V4_FLOW: |
| 533 | case ESP_V4_FLOW: |
| 534 | case SCTP_V4_FLOW: |
| 535 | if ((nfc->data & RXH_L4_B_0_1) || |
| 536 | (nfc->data & RXH_L4_B_2_3)) |
| 537 | return -EINVAL; |
Jesse Brandeburg | 41a1d04 | 2015-06-04 16:24:02 -0400 | [diff] [blame] | 538 | hena |= BIT_ULL(I40E_FILTER_PCTYPE_NONF_IPV4_OTHER); |
Mitch A Williams | 4e9dc31 | 2014-04-01 04:43:49 +0000 | [diff] [blame] | 539 | break; |
| 540 | case AH_ESP_V6_FLOW: |
| 541 | case AH_V6_FLOW: |
| 542 | case ESP_V6_FLOW: |
| 543 | case SCTP_V6_FLOW: |
| 544 | if ((nfc->data & RXH_L4_B_0_1) || |
| 545 | (nfc->data & RXH_L4_B_2_3)) |
| 546 | return -EINVAL; |
Jesse Brandeburg | 41a1d04 | 2015-06-04 16:24:02 -0400 | [diff] [blame] | 547 | hena |= BIT_ULL(I40E_FILTER_PCTYPE_NONF_IPV6_OTHER); |
Mitch A Williams | 4e9dc31 | 2014-04-01 04:43:49 +0000 | [diff] [blame] | 548 | break; |
| 549 | case IPV4_FLOW: |
Jesse Brandeburg | 41a1d04 | 2015-06-04 16:24:02 -0400 | [diff] [blame] | 550 | hena |= (BIT_ULL(I40E_FILTER_PCTYPE_NONF_IPV4_OTHER) | |
| 551 | BIT_ULL(I40E_FILTER_PCTYPE_FRAG_IPV4)); |
Mitch A Williams | 4e9dc31 | 2014-04-01 04:43:49 +0000 | [diff] [blame] | 552 | break; |
| 553 | case IPV6_FLOW: |
Jesse Brandeburg | 41a1d04 | 2015-06-04 16:24:02 -0400 | [diff] [blame] | 554 | hena |= (BIT_ULL(I40E_FILTER_PCTYPE_NONF_IPV6_OTHER) | |
| 555 | BIT_ULL(I40E_FILTER_PCTYPE_FRAG_IPV6)); |
Mitch A Williams | 4e9dc31 | 2014-04-01 04:43:49 +0000 | [diff] [blame] | 556 | break; |
| 557 | default: |
| 558 | return -EINVAL; |
| 559 | } |
| 560 | |
| 561 | wr32(hw, I40E_VFQF_HENA(0), (u32)hena); |
| 562 | wr32(hw, I40E_VFQF_HENA(1), (u32)(hena >> 32)); |
| 563 | i40e_flush(hw); |
| 564 | |
| 565 | return 0; |
| 566 | } |
| 567 | |
| 568 | /** |
| 569 | * i40evf_set_rxnfc - command to set RX flow classification rules |
| 570 | * @netdev: network interface device structure |
| 571 | * @cmd: ethtool rxnfc command |
| 572 | * |
| 573 | * Returns Success if the command is supported. |
| 574 | **/ |
| 575 | static int i40evf_set_rxnfc(struct net_device *netdev, |
| 576 | struct ethtool_rxnfc *cmd) |
| 577 | { |
| 578 | struct i40evf_adapter *adapter = netdev_priv(netdev); |
| 579 | int ret = -EOPNOTSUPP; |
| 580 | |
| 581 | switch (cmd->cmd) { |
| 582 | case ETHTOOL_SRXFH: |
| 583 | ret = i40evf_set_rss_hash_opt(adapter, cmd); |
| 584 | break; |
| 585 | default: |
| 586 | break; |
| 587 | } |
| 588 | |
| 589 | return ret; |
| 590 | } |
| 591 | |
| 592 | /** |
| 593 | * i40evf_get_channels: get the number of channels supported by the device |
| 594 | * @netdev: network interface device structure |
| 595 | * @ch: channel information structure |
| 596 | * |
| 597 | * For the purposes of our device, we only use combined channels, i.e. a tx/rx |
| 598 | * queue pair. Report one extra channel to match our "other" MSI-X vector. |
| 599 | **/ |
| 600 | static void i40evf_get_channels(struct net_device *netdev, |
| 601 | struct ethtool_channels *ch) |
| 602 | { |
| 603 | struct i40evf_adapter *adapter = netdev_priv(netdev); |
| 604 | |
| 605 | /* Report maximum channels */ |
Mitch Williams | cc05292 | 2014-10-25 03:24:34 +0000 | [diff] [blame] | 606 | ch->max_combined = adapter->num_active_queues; |
Mitch A Williams | 4e9dc31 | 2014-04-01 04:43:49 +0000 | [diff] [blame] | 607 | |
| 608 | ch->max_other = NONQ_VECS; |
| 609 | ch->other_count = NONQ_VECS; |
| 610 | |
Mitch Williams | cc05292 | 2014-10-25 03:24:34 +0000 | [diff] [blame] | 611 | ch->combined_count = adapter->num_active_queues; |
Mitch A Williams | 4e9dc31 | 2014-04-01 04:43:49 +0000 | [diff] [blame] | 612 | } |
| 613 | |
| 614 | /** |
| 615 | * i40evf_get_rxfh_indir_size - get the rx flow hash indirection table size |
| 616 | * @netdev: network interface device structure |
| 617 | * |
| 618 | * Returns the table size. |
| 619 | **/ |
| 620 | static u32 i40evf_get_rxfh_indir_size(struct net_device *netdev) |
| 621 | { |
| 622 | return (I40E_VFQF_HLUT_MAX_INDEX + 1) * 4; |
| 623 | } |
| 624 | |
| 625 | /** |
Ben Hutchings | fe62d00 | 2014-05-15 01:25:27 +0100 | [diff] [blame] | 626 | * i40evf_get_rxfh - get the rx flow hash indirection table |
Mitch A Williams | 4e9dc31 | 2014-04-01 04:43:49 +0000 | [diff] [blame] | 627 | * @netdev: network interface device structure |
| 628 | * @indir: indirection table |
Mitch Williams | 2cda3f3 | 2014-11-11 20:02:31 +0000 | [diff] [blame] | 629 | * @key: hash key |
Mitch A Williams | 4e9dc31 | 2014-04-01 04:43:49 +0000 | [diff] [blame] | 630 | * |
| 631 | * Reads the indirection table directly from the hardware. Always returns 0. |
| 632 | **/ |
Eyal Perry | 892311f | 2014-12-02 18:12:10 +0200 | [diff] [blame] | 633 | static int i40evf_get_rxfh(struct net_device *netdev, u32 *indir, u8 *key, |
| 634 | u8 *hfunc) |
Mitch A Williams | 4e9dc31 | 2014-04-01 04:43:49 +0000 | [diff] [blame] | 635 | { |
| 636 | struct i40evf_adapter *adapter = netdev_priv(netdev); |
Helin Zhang | 90b02b4 | 2015-10-26 19:44:33 -0400 | [diff] [blame] | 637 | struct i40e_vsi *vsi = &adapter->vsi; |
| 638 | u8 *seed = NULL, *lut; |
| 639 | int ret; |
| 640 | u16 i; |
Mitch A Williams | 4e9dc31 | 2014-04-01 04:43:49 +0000 | [diff] [blame] | 641 | |
Eyal Perry | 892311f | 2014-12-02 18:12:10 +0200 | [diff] [blame] | 642 | if (hfunc) |
| 643 | *hfunc = ETH_RSS_HASH_TOP; |
| 644 | if (!indir) |
| 645 | return 0; |
| 646 | |
Helin Zhang | 90b02b4 | 2015-10-26 19:44:33 -0400 | [diff] [blame] | 647 | seed = key; |
| 648 | |
| 649 | lut = kzalloc(I40EVF_HLUT_ARRAY_SIZE, GFP_KERNEL); |
| 650 | if (!lut) |
| 651 | return -ENOMEM; |
| 652 | |
| 653 | ret = i40evf_get_rss(vsi, seed, lut, I40EVF_HLUT_ARRAY_SIZE); |
| 654 | if (ret) |
| 655 | goto out; |
| 656 | |
| 657 | /* Each 32 bits pointed by 'indir' is stored with a lut entry */ |
| 658 | for (i = 0; i < I40EVF_HLUT_ARRAY_SIZE; i++) |
| 659 | indir[i] = (u32)lut[i]; |
| 660 | |
| 661 | out: |
| 662 | kfree(lut); |
| 663 | |
| 664 | return ret; |
Mitch A Williams | 4e9dc31 | 2014-04-01 04:43:49 +0000 | [diff] [blame] | 665 | } |
| 666 | |
| 667 | /** |
Ben Hutchings | fe62d00 | 2014-05-15 01:25:27 +0100 | [diff] [blame] | 668 | * i40evf_set_rxfh - set the rx flow hash indirection table |
Mitch A Williams | 4e9dc31 | 2014-04-01 04:43:49 +0000 | [diff] [blame] | 669 | * @netdev: network interface device structure |
| 670 | * @indir: indirection table |
Mitch Williams | 2cda3f3 | 2014-11-11 20:02:31 +0000 | [diff] [blame] | 671 | * @key: hash key |
Mitch A Williams | 4e9dc31 | 2014-04-01 04:43:49 +0000 | [diff] [blame] | 672 | * |
| 673 | * Returns -EINVAL if the table specifies an inavlid queue id, otherwise |
| 674 | * returns 0 after programming the table. |
| 675 | **/ |
Ben Hutchings | fe62d00 | 2014-05-15 01:25:27 +0100 | [diff] [blame] | 676 | static int i40evf_set_rxfh(struct net_device *netdev, const u32 *indir, |
Eyal Perry | 892311f | 2014-12-02 18:12:10 +0200 | [diff] [blame] | 677 | const u8 *key, const u8 hfunc) |
Mitch A Williams | 4e9dc31 | 2014-04-01 04:43:49 +0000 | [diff] [blame] | 678 | { |
| 679 | struct i40evf_adapter *adapter = netdev_priv(netdev); |
Helin Zhang | 2c86ac3 | 2015-10-27 16:15:06 -0400 | [diff] [blame] | 680 | struct i40e_vsi *vsi = &adapter->vsi; |
Helin Zhang | 66f9af85 | 2015-10-26 19:44:34 -0400 | [diff] [blame] | 681 | u8 *seed = NULL; |
Helin Zhang | 2c86ac3 | 2015-10-27 16:15:06 -0400 | [diff] [blame] | 682 | u16 i; |
Mitch A Williams | 4e9dc31 | 2014-04-01 04:43:49 +0000 | [diff] [blame] | 683 | |
Eyal Perry | 892311f | 2014-12-02 18:12:10 +0200 | [diff] [blame] | 684 | /* We do not allow change in unsupported parameters */ |
| 685 | if (key || |
| 686 | (hfunc != ETH_RSS_HASH_NO_CHANGE && hfunc != ETH_RSS_HASH_TOP)) |
| 687 | return -EOPNOTSUPP; |
| 688 | if (!indir) |
| 689 | return 0; |
| 690 | |
Helin Zhang | 2c86ac3 | 2015-10-27 16:15:06 -0400 | [diff] [blame] | 691 | if (key) { |
Helin Zhang | 66f9af85 | 2015-10-26 19:44:34 -0400 | [diff] [blame] | 692 | if (!vsi->rss_hkey_user) { |
| 693 | vsi->rss_hkey_user = kzalloc(I40EVF_HKEY_ARRAY_SIZE, |
| 694 | GFP_KERNEL); |
| 695 | if (!vsi->rss_hkey_user) |
| 696 | return -ENOMEM; |
| 697 | } |
| 698 | memcpy(vsi->rss_hkey_user, key, I40EVF_HKEY_ARRAY_SIZE); |
| 699 | seed = vsi->rss_hkey_user; |
Mitch A Williams | 4e9dc31 | 2014-04-01 04:43:49 +0000 | [diff] [blame] | 700 | } |
Helin Zhang | 66f9af85 | 2015-10-26 19:44:34 -0400 | [diff] [blame] | 701 | if (!vsi->rss_lut_user) { |
| 702 | vsi->rss_lut_user = kzalloc(I40EVF_HLUT_ARRAY_SIZE, |
| 703 | GFP_KERNEL); |
| 704 | if (!vsi->rss_lut_user) |
| 705 | return -ENOMEM; |
| 706 | } |
Mitch A Williams | 4e9dc31 | 2014-04-01 04:43:49 +0000 | [diff] [blame] | 707 | |
Helin Zhang | 2c86ac3 | 2015-10-27 16:15:06 -0400 | [diff] [blame] | 708 | /* Each 32 bits pointed by 'indir' is stored with a lut entry */ |
| 709 | for (i = 0; i < I40EVF_HLUT_ARRAY_SIZE; i++) |
Helin Zhang | 66f9af85 | 2015-10-26 19:44:34 -0400 | [diff] [blame] | 710 | vsi->rss_lut_user[i] = (u8)(indir[i]); |
Helin Zhang | 2c86ac3 | 2015-10-27 16:15:06 -0400 | [diff] [blame] | 711 | |
Helin Zhang | 66f9af85 | 2015-10-26 19:44:34 -0400 | [diff] [blame] | 712 | return i40evf_config_rss(vsi, seed, vsi->rss_lut_user, |
| 713 | I40EVF_HLUT_ARRAY_SIZE); |
Mitch A Williams | 4e9dc31 | 2014-04-01 04:43:49 +0000 | [diff] [blame] | 714 | } |
| 715 | |
Mitch Williams | f0c53c7 | 2014-04-04 04:43:11 +0000 | [diff] [blame] | 716 | static const struct ethtool_ops i40evf_ethtool_ops = { |
Greg Rose | fbb7ddf | 2013-12-21 06:12:56 +0000 | [diff] [blame] | 717 | .get_settings = i40evf_get_settings, |
| 718 | .get_drvinfo = i40evf_get_drvinfo, |
| 719 | .get_link = ethtool_op_get_link, |
| 720 | .get_ringparam = i40evf_get_ringparam, |
| 721 | .set_ringparam = i40evf_set_ringparam, |
| 722 | .get_strings = i40evf_get_strings, |
| 723 | .get_ethtool_stats = i40evf_get_ethtool_stats, |
| 724 | .get_sset_count = i40evf_get_sset_count, |
| 725 | .get_msglevel = i40evf_get_msglevel, |
| 726 | .set_msglevel = i40evf_set_msglevel, |
| 727 | .get_coalesce = i40evf_get_coalesce, |
| 728 | .set_coalesce = i40evf_set_coalesce, |
Mitch A Williams | 4e9dc31 | 2014-04-01 04:43:49 +0000 | [diff] [blame] | 729 | .get_rxnfc = i40evf_get_rxnfc, |
| 730 | .set_rxnfc = i40evf_set_rxnfc, |
| 731 | .get_rxfh_indir_size = i40evf_get_rxfh_indir_size, |
Ben Hutchings | fe62d00 | 2014-05-15 01:25:27 +0100 | [diff] [blame] | 732 | .get_rxfh = i40evf_get_rxfh, |
| 733 | .set_rxfh = i40evf_set_rxfh, |
Mitch A Williams | 4e9dc31 | 2014-04-01 04:43:49 +0000 | [diff] [blame] | 734 | .get_channels = i40evf_get_channels, |
Greg Rose | fbb7ddf | 2013-12-21 06:12:56 +0000 | [diff] [blame] | 735 | }; |
| 736 | |
| 737 | /** |
| 738 | * i40evf_set_ethtool_ops - Initialize ethtool ops struct |
| 739 | * @netdev: network interface device structure |
| 740 | * |
| 741 | * Sets ethtool ops struct in our netdev so that ethtool can call |
| 742 | * our functions. |
| 743 | **/ |
| 744 | void i40evf_set_ethtool_ops(struct net_device *netdev) |
| 745 | { |
Wilfried Klaebe | 7ad24ea | 2014-05-11 00:12:32 +0000 | [diff] [blame] | 746 | netdev->ethtool_ops = &i40evf_ethtool_ops; |
Greg Rose | fbb7ddf | 2013-12-21 06:12:56 +0000 | [diff] [blame] | 747 | } |