1 // SPDX-License-Identifier: GPL-2.0
2 /* Copyright(c) 2013 - 2018 Intel Corporation. */
4 /* ethtool support for i40evf */
7 #include <linux/uaccess.h>
10 char stat_string[ETH_GSTRING_LEN];
14 #define I40EVF_STAT(_name, _stat) { \
15 .stat_string = _name, \
16 .stat_offset = offsetof(struct i40evf_adapter, _stat) \
19 /* All stats are u64, so we don't need to track the size of the field. */
20 static const struct i40evf_stats i40evf_gstrings_stats[] = {
21 I40EVF_STAT("rx_bytes", current_stats.rx_bytes),
22 I40EVF_STAT("rx_unicast", current_stats.rx_unicast),
23 I40EVF_STAT("rx_multicast", current_stats.rx_multicast),
24 I40EVF_STAT("rx_broadcast", current_stats.rx_broadcast),
25 I40EVF_STAT("rx_discards", current_stats.rx_discards),
26 I40EVF_STAT("rx_unknown_protocol", current_stats.rx_unknown_protocol),
27 I40EVF_STAT("tx_bytes", current_stats.tx_bytes),
28 I40EVF_STAT("tx_unicast", current_stats.tx_unicast),
29 I40EVF_STAT("tx_multicast", current_stats.tx_multicast),
30 I40EVF_STAT("tx_broadcast", current_stats.tx_broadcast),
31 I40EVF_STAT("tx_discards", current_stats.tx_discards),
32 I40EVF_STAT("tx_errors", current_stats.tx_errors),
35 #define I40EVF_GLOBAL_STATS_LEN ARRAY_SIZE(i40evf_gstrings_stats)
36 #define I40EVF_QUEUE_STATS_LEN(_dev) \
37 (((struct i40evf_adapter *)\
38 netdev_priv(_dev))->num_active_queues \
39 * 2 * (sizeof(struct i40e_queue_stats) / sizeof(u64)))
40 #define I40EVF_STATS_LEN(_dev) \
41 (I40EVF_GLOBAL_STATS_LEN + I40EVF_QUEUE_STATS_LEN(_dev))
43 /* For now we have one and only one private flag and it is only defined
44 * when we have support for the SKIP_CPU_SYNC DMA attribute. Instead
45 * of leaving all this code sitting around empty we will strip it unless
46 * our one private flag is actually available.
48 struct i40evf_priv_flags {
49 char flag_string[ETH_GSTRING_LEN];
54 #define I40EVF_PRIV_FLAG(_name, _flag, _read_only) { \
55 .flag_string = _name, \
57 .read_only = _read_only, \
60 static const struct i40evf_priv_flags i40evf_gstrings_priv_flags[] = {
61 I40EVF_PRIV_FLAG("legacy-rx", I40EVF_FLAG_LEGACY_RX, 0),
64 #define I40EVF_PRIV_FLAGS_STR_LEN ARRAY_SIZE(i40evf_gstrings_priv_flags)
67 * i40evf_get_link_ksettings - Get Link Speed and Duplex settings
68 * @netdev: network interface device structure
69 * @cmd: ethtool command
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.
74 static int i40evf_get_link_ksettings(struct net_device *netdev,
75 struct ethtool_link_ksettings *cmd)
77 struct i40evf_adapter *adapter = netdev_priv(netdev);
79 ethtool_link_ksettings_zero_link_mode(cmd, supported);
80 cmd->base.autoneg = AUTONEG_DISABLE;
81 cmd->base.port = PORT_NONE;
82 /* Set speed and duplex */
83 switch (adapter->link_speed) {
84 case I40E_LINK_SPEED_40GB:
85 cmd->base.speed = SPEED_40000;
87 case I40E_LINK_SPEED_25GB:
89 cmd->base.speed = SPEED_25000;
92 "Speed is 25G, display not supported by this version of ethtool.\n");
95 case I40E_LINK_SPEED_20GB:
96 cmd->base.speed = SPEED_20000;
98 case I40E_LINK_SPEED_10GB:
99 cmd->base.speed = SPEED_10000;
101 case I40E_LINK_SPEED_1GB:
102 cmd->base.speed = SPEED_1000;
104 case I40E_LINK_SPEED_100MB:
105 cmd->base.speed = SPEED_100;
110 cmd->base.duplex = DUPLEX_FULL;
116 * i40evf_get_sset_count - Get length of string set
117 * @netdev: network interface device structure
118 * @sset: id of string set
120 * Reports size of string table. This driver only supports
121 * strings for statistics.
123 static int i40evf_get_sset_count(struct net_device *netdev, int sset)
125 if (sset == ETH_SS_STATS)
126 return I40EVF_STATS_LEN(netdev);
127 else if (sset == ETH_SS_PRIV_FLAGS)
128 return I40EVF_PRIV_FLAGS_STR_LEN;
134 * i40evf_get_ethtool_stats - report device statistics
135 * @netdev: network interface device structure
136 * @stats: ethtool statistics structure
137 * @data: pointer to data buffer
139 * All statistics are added to the data buffer as an array of u64.
141 static void i40evf_get_ethtool_stats(struct net_device *netdev,
142 struct ethtool_stats *stats, u64 *data)
144 struct i40evf_adapter *adapter = netdev_priv(netdev);
148 for (i = 0; i < I40EVF_GLOBAL_STATS_LEN; i++) {
149 p = (char *)adapter + i40evf_gstrings_stats[i].stat_offset;
152 for (j = 0; j < adapter->num_active_queues; j++) {
153 data[i++] = adapter->tx_rings[j].stats.packets;
154 data[i++] = adapter->tx_rings[j].stats.bytes;
156 for (j = 0; j < adapter->num_active_queues; j++) {
157 data[i++] = adapter->rx_rings[j].stats.packets;
158 data[i++] = adapter->rx_rings[j].stats.bytes;
163 * i40evf_get_strings - Get string set
164 * @netdev: network interface device structure
165 * @sset: id of string set
166 * @data: buffer for string data
168 * Builds stats string table.
170 static void i40evf_get_strings(struct net_device *netdev, u32 sset, u8 *data)
172 struct i40evf_adapter *adapter = netdev_priv(netdev);
176 if (sset == ETH_SS_STATS) {
177 for (i = 0; i < (int)I40EVF_GLOBAL_STATS_LEN; i++) {
178 memcpy(p, i40evf_gstrings_stats[i].stat_string,
180 p += ETH_GSTRING_LEN;
182 for (i = 0; i < adapter->num_active_queues; i++) {
183 snprintf(p, ETH_GSTRING_LEN, "tx-%u.packets", i);
184 p += ETH_GSTRING_LEN;
185 snprintf(p, ETH_GSTRING_LEN, "tx-%u.bytes", i);
186 p += ETH_GSTRING_LEN;
188 for (i = 0; i < adapter->num_active_queues; i++) {
189 snprintf(p, ETH_GSTRING_LEN, "rx-%u.packets", i);
190 p += ETH_GSTRING_LEN;
191 snprintf(p, ETH_GSTRING_LEN, "rx-%u.bytes", i);
192 p += ETH_GSTRING_LEN;
194 } else if (sset == ETH_SS_PRIV_FLAGS) {
195 for (i = 0; i < I40EVF_PRIV_FLAGS_STR_LEN; i++) {
196 snprintf(p, ETH_GSTRING_LEN, "%s",
197 i40evf_gstrings_priv_flags[i].flag_string);
198 p += ETH_GSTRING_LEN;
204 * i40evf_get_priv_flags - report device private flags
205 * @netdev: network interface device structure
207 * The get string set count and the string set should be matched for each
208 * flag returned. Add new strings for each flag to the i40e_gstrings_priv_flags
211 * Returns a u32 bitmap of flags.
213 static u32 i40evf_get_priv_flags(struct net_device *netdev)
215 struct i40evf_adapter *adapter = netdev_priv(netdev);
216 u32 i, ret_flags = 0;
218 for (i = 0; i < I40EVF_PRIV_FLAGS_STR_LEN; i++) {
219 const struct i40evf_priv_flags *priv_flags;
221 priv_flags = &i40evf_gstrings_priv_flags[i];
223 if (priv_flags->flag & adapter->flags)
231 * i40evf_set_priv_flags - set private flags
232 * @netdev: network interface device structure
233 * @flags: bit flags to be set
235 static int i40evf_set_priv_flags(struct net_device *netdev, u32 flags)
237 struct i40evf_adapter *adapter = netdev_priv(netdev);
238 u32 orig_flags, new_flags, changed_flags;
241 orig_flags = READ_ONCE(adapter->flags);
242 new_flags = orig_flags;
244 for (i = 0; i < I40EVF_PRIV_FLAGS_STR_LEN; i++) {
245 const struct i40evf_priv_flags *priv_flags;
247 priv_flags = &i40evf_gstrings_priv_flags[i];
250 new_flags |= priv_flags->flag;
252 new_flags &= ~(priv_flags->flag);
254 if (priv_flags->read_only &&
255 ((orig_flags ^ new_flags) & ~BIT(i)))
259 /* Before we finalize any flag changes, any checks which we need to
260 * perform to determine if the new flags will be supported should go
264 /* Compare and exchange the new flags into place. If we failed, that
265 * is if cmpxchg returns anything but the old value, this means
266 * something else must have modified the flags variable since we
267 * copied it. We'll just punt with an error and log something in the
270 if (cmpxchg(&adapter->flags, orig_flags, new_flags) != orig_flags) {
271 dev_warn(&adapter->pdev->dev,
272 "Unable to update adapter->flags as it was modified by another thread...\n");
276 changed_flags = orig_flags ^ new_flags;
278 /* Process any additional changes needed as a result of flag changes.
279 * The changed_flags value reflects the list of bits that were changed
283 /* issue a reset to force legacy-rx change to take effect */
284 if (changed_flags & I40EVF_FLAG_LEGACY_RX) {
285 if (netif_running(netdev)) {
286 adapter->flags |= I40EVF_FLAG_RESET_NEEDED;
287 schedule_work(&adapter->reset_task);
295 * i40evf_get_msglevel - Get debug message level
296 * @netdev: network interface device structure
298 * Returns current debug message level.
300 static u32 i40evf_get_msglevel(struct net_device *netdev)
302 struct i40evf_adapter *adapter = netdev_priv(netdev);
304 return adapter->msg_enable;
308 * i40evf_set_msglevel - Set debug message level
309 * @netdev: network interface device structure
310 * @data: message level
312 * Set current debug message level. Higher values cause the driver to
315 static void i40evf_set_msglevel(struct net_device *netdev, u32 data)
317 struct i40evf_adapter *adapter = netdev_priv(netdev);
319 if (I40E_DEBUG_USER & data)
320 adapter->hw.debug_mask = data;
321 adapter->msg_enable = data;
325 * i40evf_get_drvinfo - Get driver info
326 * @netdev: network interface device structure
327 * @drvinfo: ethool driver info structure
329 * Returns information about the driver and device for display to the user.
331 static void i40evf_get_drvinfo(struct net_device *netdev,
332 struct ethtool_drvinfo *drvinfo)
334 struct i40evf_adapter *adapter = netdev_priv(netdev);
336 strlcpy(drvinfo->driver, i40evf_driver_name, 32);
337 strlcpy(drvinfo->version, i40evf_driver_version, 32);
338 strlcpy(drvinfo->fw_version, "N/A", 4);
339 strlcpy(drvinfo->bus_info, pci_name(adapter->pdev), 32);
340 drvinfo->n_priv_flags = I40EVF_PRIV_FLAGS_STR_LEN;
344 * i40evf_get_ringparam - Get ring parameters
345 * @netdev: network interface device structure
346 * @ring: ethtool ringparam structure
348 * Returns current ring parameters. TX and RX rings are reported separately,
349 * but the number of rings is not reported.
351 static void i40evf_get_ringparam(struct net_device *netdev,
352 struct ethtool_ringparam *ring)
354 struct i40evf_adapter *adapter = netdev_priv(netdev);
356 ring->rx_max_pending = I40EVF_MAX_RXD;
357 ring->tx_max_pending = I40EVF_MAX_TXD;
358 ring->rx_pending = adapter->rx_desc_count;
359 ring->tx_pending = adapter->tx_desc_count;
363 * i40evf_set_ringparam - Set ring parameters
364 * @netdev: network interface device structure
365 * @ring: ethtool ringparam structure
367 * Sets ring parameters. TX and RX rings are controlled separately, but the
368 * number of rings is not specified, so all rings get the same settings.
370 static int i40evf_set_ringparam(struct net_device *netdev,
371 struct ethtool_ringparam *ring)
373 struct i40evf_adapter *adapter = netdev_priv(netdev);
374 u32 new_rx_count, new_tx_count;
376 if ((ring->rx_mini_pending) || (ring->rx_jumbo_pending))
379 new_tx_count = clamp_t(u32, ring->tx_pending,
382 new_tx_count = ALIGN(new_tx_count, I40EVF_REQ_DESCRIPTOR_MULTIPLE);
384 new_rx_count = clamp_t(u32, ring->rx_pending,
387 new_rx_count = ALIGN(new_rx_count, I40EVF_REQ_DESCRIPTOR_MULTIPLE);
389 /* if nothing to do return success */
390 if ((new_tx_count == adapter->tx_desc_count) &&
391 (new_rx_count == adapter->rx_desc_count))
394 adapter->tx_desc_count = new_tx_count;
395 adapter->rx_desc_count = new_rx_count;
397 if (netif_running(netdev)) {
398 adapter->flags |= I40EVF_FLAG_RESET_NEEDED;
399 schedule_work(&adapter->reset_task);
406 * __i40evf_get_coalesce - get per-queue coalesce settings
407 * @netdev: the netdev to check
408 * @ec: ethtool coalesce data structure
409 * @queue: which queue to pick
411 * Gets the per-queue settings for coalescence. Specifically Rx and Tx usecs
412 * are per queue. If queue is <0 then we default to queue 0 as the
413 * representative value.
415 static int __i40evf_get_coalesce(struct net_device *netdev,
416 struct ethtool_coalesce *ec,
419 struct i40evf_adapter *adapter = netdev_priv(netdev);
420 struct i40e_vsi *vsi = &adapter->vsi;
421 struct i40e_ring *rx_ring, *tx_ring;
423 ec->tx_max_coalesced_frames = vsi->work_limit;
424 ec->rx_max_coalesced_frames = vsi->work_limit;
426 /* Rx and Tx usecs per queue value. If user doesn't specify the
427 * queue, return queue 0's value to represent.
431 else if (queue >= adapter->num_active_queues)
434 rx_ring = &adapter->rx_rings[queue];
435 tx_ring = &adapter->tx_rings[queue];
437 if (ITR_IS_DYNAMIC(rx_ring->itr_setting))
438 ec->use_adaptive_rx_coalesce = 1;
440 if (ITR_IS_DYNAMIC(tx_ring->itr_setting))
441 ec->use_adaptive_tx_coalesce = 1;
443 ec->rx_coalesce_usecs = rx_ring->itr_setting & ~I40E_ITR_DYNAMIC;
444 ec->tx_coalesce_usecs = tx_ring->itr_setting & ~I40E_ITR_DYNAMIC;
450 * i40evf_get_coalesce - Get interrupt coalescing settings
451 * @netdev: network interface device structure
452 * @ec: ethtool coalesce structure
454 * Returns current coalescing settings. This is referred to elsewhere in the
455 * driver as Interrupt Throttle Rate, as this is how the hardware describes
456 * this functionality. Note that if per-queue settings have been modified this
457 * only represents the settings of queue 0.
459 static int i40evf_get_coalesce(struct net_device *netdev,
460 struct ethtool_coalesce *ec)
462 return __i40evf_get_coalesce(netdev, ec, -1);
466 * i40evf_get_per_queue_coalesce - get coalesce values for specific queue
467 * @netdev: netdev to read
468 * @ec: coalesce settings from ethtool
469 * @queue: the queue to read
471 * Read specific queue's coalesce settings.
473 static int i40evf_get_per_queue_coalesce(struct net_device *netdev,
475 struct ethtool_coalesce *ec)
477 return __i40evf_get_coalesce(netdev, ec, queue);
481 * i40evf_set_itr_per_queue - set ITR values for specific queue
482 * @adapter: the VF adapter struct to set values for
483 * @ec: coalesce settings from ethtool
484 * @queue: the queue to modify
486 * Change the ITR settings for a specific queue.
488 static void i40evf_set_itr_per_queue(struct i40evf_adapter *adapter,
489 struct ethtool_coalesce *ec,
492 struct i40e_ring *rx_ring = &adapter->rx_rings[queue];
493 struct i40e_ring *tx_ring = &adapter->tx_rings[queue];
494 struct i40e_q_vector *q_vector;
496 rx_ring->itr_setting = ITR_REG_ALIGN(ec->rx_coalesce_usecs);
497 tx_ring->itr_setting = ITR_REG_ALIGN(ec->tx_coalesce_usecs);
499 rx_ring->itr_setting |= I40E_ITR_DYNAMIC;
500 if (!ec->use_adaptive_rx_coalesce)
501 rx_ring->itr_setting ^= I40E_ITR_DYNAMIC;
503 tx_ring->itr_setting |= I40E_ITR_DYNAMIC;
504 if (!ec->use_adaptive_tx_coalesce)
505 tx_ring->itr_setting ^= I40E_ITR_DYNAMIC;
507 q_vector = rx_ring->q_vector;
508 q_vector->rx.target_itr = ITR_TO_REG(rx_ring->itr_setting);
510 q_vector = tx_ring->q_vector;
511 q_vector->tx.target_itr = ITR_TO_REG(tx_ring->itr_setting);
513 /* The interrupt handler itself will take care of programming
514 * the Tx and Rx ITR values based on the values we have entered
515 * into the q_vector, no need to write the values now.
520 * __i40evf_set_coalesce - set coalesce settings for particular queue
521 * @netdev: the netdev to change
522 * @ec: ethtool coalesce settings
523 * @queue: the queue to change
525 * Sets the coalesce settings for a particular queue.
527 static int __i40evf_set_coalesce(struct net_device *netdev,
528 struct ethtool_coalesce *ec,
531 struct i40evf_adapter *adapter = netdev_priv(netdev);
532 struct i40e_vsi *vsi = &adapter->vsi;
535 if (ec->tx_max_coalesced_frames_irq || ec->rx_max_coalesced_frames_irq)
536 vsi->work_limit = ec->tx_max_coalesced_frames_irq;
538 if (ec->rx_coalesce_usecs == 0) {
539 if (ec->use_adaptive_rx_coalesce)
540 netif_info(adapter, drv, netdev, "rx-usecs=0, need to disable adaptive-rx for a complete disable\n");
541 } else if ((ec->rx_coalesce_usecs < I40E_MIN_ITR) ||
542 (ec->rx_coalesce_usecs > I40E_MAX_ITR)) {
543 netif_info(adapter, drv, netdev, "Invalid value, rx-usecs range is 0-8160\n");
548 if (ec->tx_coalesce_usecs == 0) {
549 if (ec->use_adaptive_tx_coalesce)
550 netif_info(adapter, drv, netdev, "tx-usecs=0, need to disable adaptive-tx for a complete disable\n");
551 } else if ((ec->tx_coalesce_usecs < I40E_MIN_ITR) ||
552 (ec->tx_coalesce_usecs > I40E_MAX_ITR)) {
553 netif_info(adapter, drv, netdev, "Invalid value, tx-usecs range is 0-8160\n");
557 /* Rx and Tx usecs has per queue value. If user doesn't specify the
558 * queue, apply to all queues.
561 for (i = 0; i < adapter->num_active_queues; i++)
562 i40evf_set_itr_per_queue(adapter, ec, i);
563 } else if (queue < adapter->num_active_queues) {
564 i40evf_set_itr_per_queue(adapter, ec, queue);
566 netif_info(adapter, drv, netdev, "Invalid queue value, queue range is 0 - %d\n",
567 adapter->num_active_queues - 1);
575 * i40evf_set_coalesce - Set interrupt coalescing settings
576 * @netdev: network interface device structure
577 * @ec: ethtool coalesce structure
579 * Change current coalescing settings for every queue.
581 static int i40evf_set_coalesce(struct net_device *netdev,
582 struct ethtool_coalesce *ec)
584 return __i40evf_set_coalesce(netdev, ec, -1);
588 * i40evf_set_per_queue_coalesce - set specific queue's coalesce settings
589 * @netdev: the netdev to change
590 * @ec: ethtool's coalesce settings
591 * @queue: the queue to modify
593 * Modifies a specific queue's coalesce settings.
595 static int i40evf_set_per_queue_coalesce(struct net_device *netdev,
597 struct ethtool_coalesce *ec)
599 return __i40evf_set_coalesce(netdev, ec, queue);
603 * i40evf_get_rxnfc - command to get RX flow classification rules
604 * @netdev: network interface device structure
605 * @cmd: ethtool rxnfc command
606 * @rule_locs: pointer to store rule locations
608 * Returns Success if the command is supported.
610 static int i40evf_get_rxnfc(struct net_device *netdev,
611 struct ethtool_rxnfc *cmd,
614 struct i40evf_adapter *adapter = netdev_priv(netdev);
615 int ret = -EOPNOTSUPP;
618 case ETHTOOL_GRXRINGS:
619 cmd->data = adapter->num_active_queues;
624 "RSS hash info is not available to vf, use pf.\n");
633 * i40evf_get_channels: get the number of channels supported by the device
634 * @netdev: network interface device structure
635 * @ch: channel information structure
637 * For the purposes of our device, we only use combined channels, i.e. a tx/rx
638 * queue pair. Report one extra channel to match our "other" MSI-X vector.
640 static void i40evf_get_channels(struct net_device *netdev,
641 struct ethtool_channels *ch)
643 struct i40evf_adapter *adapter = netdev_priv(netdev);
645 /* Report maximum channels */
646 ch->max_combined = I40EVF_MAX_REQ_QUEUES;
648 ch->max_other = NONQ_VECS;
649 ch->other_count = NONQ_VECS;
651 ch->combined_count = adapter->num_active_queues;
655 * i40evf_set_channels: set the new channel count
656 * @netdev: network interface device structure
657 * @ch: channel information structure
659 * Negotiate a new number of channels with the PF then do a reset. During
660 * reset we'll realloc queues and fix the RSS table. Returns 0 on success,
661 * negative on failure.
663 static int i40evf_set_channels(struct net_device *netdev,
664 struct ethtool_channels *ch)
666 struct i40evf_adapter *adapter = netdev_priv(netdev);
667 int num_req = ch->combined_count;
669 if (num_req != adapter->num_active_queues &&
670 !(adapter->vf_res->vf_cap_flags &
671 VIRTCHNL_VF_OFFLOAD_REQ_QUEUES)) {
672 dev_info(&adapter->pdev->dev, "PF is not capable of queue negotiation.\n");
676 if ((adapter->vf_res->vf_cap_flags & VIRTCHNL_VF_OFFLOAD_ADQ) &&
678 dev_info(&adapter->pdev->dev, "Cannot set channels since ADq is enabled.\n");
682 /* All of these should have already been checked by ethtool before this
683 * even gets to us, but just to be sure.
685 if (num_req <= 0 || num_req > I40EVF_MAX_REQ_QUEUES)
688 if (ch->rx_count || ch->tx_count || ch->other_count != NONQ_VECS)
691 adapter->num_req_queues = num_req;
692 return i40evf_request_queues(adapter, num_req);
696 * i40evf_get_rxfh_key_size - get the RSS hash key size
697 * @netdev: network interface device structure
699 * Returns the table size.
701 static u32 i40evf_get_rxfh_key_size(struct net_device *netdev)
703 struct i40evf_adapter *adapter = netdev_priv(netdev);
705 return adapter->rss_key_size;
709 * i40evf_get_rxfh_indir_size - get the rx flow hash indirection table size
710 * @netdev: network interface device structure
712 * Returns the table size.
714 static u32 i40evf_get_rxfh_indir_size(struct net_device *netdev)
716 struct i40evf_adapter *adapter = netdev_priv(netdev);
718 return adapter->rss_lut_size;
722 * i40evf_get_rxfh - get the rx flow hash indirection table
723 * @netdev: network interface device structure
724 * @indir: indirection table
726 * @hfunc: hash function in use
728 * Reads the indirection table directly from the hardware. Always returns 0.
730 static int i40evf_get_rxfh(struct net_device *netdev, u32 *indir, u8 *key,
733 struct i40evf_adapter *adapter = netdev_priv(netdev);
737 *hfunc = ETH_RSS_HASH_TOP;
741 memcpy(key, adapter->rss_key, adapter->rss_key_size);
743 /* Each 32 bits pointed by 'indir' is stored with a lut entry */
744 for (i = 0; i < adapter->rss_lut_size; i++)
745 indir[i] = (u32)adapter->rss_lut[i];
751 * i40evf_set_rxfh - set the rx flow hash indirection table
752 * @netdev: network interface device structure
753 * @indir: indirection table
755 * @hfunc: hash function to use
757 * Returns -EINVAL if the table specifies an inavlid queue id, otherwise
758 * returns 0 after programming the table.
760 static int i40evf_set_rxfh(struct net_device *netdev, const u32 *indir,
761 const u8 *key, const u8 hfunc)
763 struct i40evf_adapter *adapter = netdev_priv(netdev);
766 /* We do not allow change in unsupported parameters */
768 (hfunc != ETH_RSS_HASH_NO_CHANGE && hfunc != ETH_RSS_HASH_TOP))
774 memcpy(adapter->rss_key, key, adapter->rss_key_size);
777 /* Each 32 bits pointed by 'indir' is stored with a lut entry */
778 for (i = 0; i < adapter->rss_lut_size; i++)
779 adapter->rss_lut[i] = (u8)(indir[i]);
781 return i40evf_config_rss(adapter);
784 static const struct ethtool_ops i40evf_ethtool_ops = {
785 .get_drvinfo = i40evf_get_drvinfo,
786 .get_link = ethtool_op_get_link,
787 .get_ringparam = i40evf_get_ringparam,
788 .set_ringparam = i40evf_set_ringparam,
789 .get_strings = i40evf_get_strings,
790 .get_ethtool_stats = i40evf_get_ethtool_stats,
791 .get_sset_count = i40evf_get_sset_count,
792 .get_priv_flags = i40evf_get_priv_flags,
793 .set_priv_flags = i40evf_set_priv_flags,
794 .get_msglevel = i40evf_get_msglevel,
795 .set_msglevel = i40evf_set_msglevel,
796 .get_coalesce = i40evf_get_coalesce,
797 .set_coalesce = i40evf_set_coalesce,
798 .get_per_queue_coalesce = i40evf_get_per_queue_coalesce,
799 .set_per_queue_coalesce = i40evf_set_per_queue_coalesce,
800 .get_rxnfc = i40evf_get_rxnfc,
801 .get_rxfh_indir_size = i40evf_get_rxfh_indir_size,
802 .get_rxfh = i40evf_get_rxfh,
803 .set_rxfh = i40evf_set_rxfh,
804 .get_channels = i40evf_get_channels,
805 .set_channels = i40evf_set_channels,
806 .get_rxfh_key_size = i40evf_get_rxfh_key_size,
807 .get_link_ksettings = i40evf_get_link_ksettings,
811 * i40evf_set_ethtool_ops - Initialize ethtool ops struct
812 * @netdev: network interface device structure
814 * Sets ethtool ops struct in our netdev so that ethtool can call
817 void i40evf_set_ethtool_ops(struct net_device *netdev)
819 netdev->ethtool_ops = &i40evf_ethtool_ops;