1 /*******************************************************************************
3 * Intel Ethernet Controller XL710 Family Linux Driver
4 * Copyright(c) 2013 Intel Corporation.
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.
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
15 * You should have received a copy of the GNU General Public License along with
16 * this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
19 * The full GNU General Public License is included in this distribution in
20 * the file called "COPYING".
22 * Contact Information:
23 * e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
24 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
26 ******************************************************************************/
28 /* ethtool support for i40e */
31 #include "i40e_diag.h"
34 char stat_string[ETH_GSTRING_LEN];
39 #define I40E_STAT(_type, _name, _stat) { \
40 .stat_string = _name, \
41 .sizeof_stat = FIELD_SIZEOF(_type, _stat), \
42 .stat_offset = offsetof(_type, _stat) \
44 #define I40E_NETDEV_STAT(_net_stat) \
45 I40E_STAT(struct net_device_stats, #_net_stat, _net_stat)
46 #define I40E_PF_STAT(_name, _stat) \
47 I40E_STAT(struct i40e_pf, _name, _stat)
48 #define I40E_VSI_STAT(_name, _stat) \
49 I40E_STAT(struct i40e_vsi, _name, _stat)
51 static const struct i40e_stats i40e_gstrings_net_stats[] = {
52 I40E_NETDEV_STAT(rx_packets),
53 I40E_NETDEV_STAT(tx_packets),
54 I40E_NETDEV_STAT(rx_bytes),
55 I40E_NETDEV_STAT(tx_bytes),
56 I40E_NETDEV_STAT(rx_errors),
57 I40E_NETDEV_STAT(tx_errors),
58 I40E_NETDEV_STAT(rx_dropped),
59 I40E_NETDEV_STAT(tx_dropped),
60 I40E_NETDEV_STAT(multicast),
61 I40E_NETDEV_STAT(collisions),
62 I40E_NETDEV_STAT(rx_length_errors),
63 I40E_NETDEV_STAT(rx_crc_errors),
66 /* These PF_STATs might look like duplicates of some NETDEV_STATs,
67 * but they are separate. This device supports Virtualization, and
68 * as such might have several netdevs supporting VMDq and FCoE going
69 * through a single port. The NETDEV_STATs are for individual netdevs
70 * seen at the top of the stack, and the PF_STATs are for the physical
71 * function at the bottom of the stack hosting those netdevs.
73 * The PF_STATs are appended to the netdev stats only when ethtool -S
74 * is queried on the base PF netdev, not on the VMDq or FCoE netdev.
76 static struct i40e_stats i40e_gstrings_stats[] = {
77 I40E_PF_STAT("rx_bytes", stats.eth.rx_bytes),
78 I40E_PF_STAT("tx_bytes", stats.eth.tx_bytes),
79 I40E_PF_STAT("rx_errors", stats.eth.rx_errors),
80 I40E_PF_STAT("tx_errors", stats.eth.tx_errors),
81 I40E_PF_STAT("rx_dropped", stats.eth.rx_discards),
82 I40E_PF_STAT("tx_dropped", stats.eth.tx_discards),
83 I40E_PF_STAT("tx_dropped_link_down", stats.tx_dropped_link_down),
84 I40E_PF_STAT("crc_errors", stats.crc_errors),
85 I40E_PF_STAT("illegal_bytes", stats.illegal_bytes),
86 I40E_PF_STAT("mac_local_faults", stats.mac_local_faults),
87 I40E_PF_STAT("mac_remote_faults", stats.mac_remote_faults),
88 I40E_PF_STAT("rx_length_errors", stats.rx_length_errors),
89 I40E_PF_STAT("link_xon_rx", stats.link_xon_rx),
90 I40E_PF_STAT("link_xoff_rx", stats.link_xoff_rx),
91 I40E_PF_STAT("link_xon_tx", stats.link_xon_tx),
92 I40E_PF_STAT("link_xoff_tx", stats.link_xoff_tx),
93 I40E_PF_STAT("rx_size_64", stats.rx_size_64),
94 I40E_PF_STAT("rx_size_127", stats.rx_size_127),
95 I40E_PF_STAT("rx_size_255", stats.rx_size_255),
96 I40E_PF_STAT("rx_size_511", stats.rx_size_511),
97 I40E_PF_STAT("rx_size_1023", stats.rx_size_1023),
98 I40E_PF_STAT("rx_size_1522", stats.rx_size_1522),
99 I40E_PF_STAT("rx_size_big", stats.rx_size_big),
100 I40E_PF_STAT("tx_size_64", stats.tx_size_64),
101 I40E_PF_STAT("tx_size_127", stats.tx_size_127),
102 I40E_PF_STAT("tx_size_255", stats.tx_size_255),
103 I40E_PF_STAT("tx_size_511", stats.tx_size_511),
104 I40E_PF_STAT("tx_size_1023", stats.tx_size_1023),
105 I40E_PF_STAT("tx_size_1522", stats.tx_size_1522),
106 I40E_PF_STAT("tx_size_big", stats.tx_size_big),
107 I40E_PF_STAT("rx_undersize", stats.rx_undersize),
108 I40E_PF_STAT("rx_fragments", stats.rx_fragments),
109 I40E_PF_STAT("rx_oversize", stats.rx_oversize),
110 I40E_PF_STAT("rx_jabber", stats.rx_jabber),
111 I40E_PF_STAT("VF_admin_queue_requests", vf_aq_requests),
114 #define I40E_QUEUE_STATS_LEN(n) \
115 ((((struct i40e_netdev_priv *)netdev_priv((n)))->vsi->num_queue_pairs + \
116 ((struct i40e_netdev_priv *)netdev_priv((n)))->vsi->num_queue_pairs) * 2)
117 #define I40E_GLOBAL_STATS_LEN ARRAY_SIZE(i40e_gstrings_stats)
118 #define I40E_NETDEV_STATS_LEN ARRAY_SIZE(i40e_gstrings_net_stats)
119 #define I40E_VSI_STATS_LEN(n) (I40E_NETDEV_STATS_LEN + \
120 I40E_QUEUE_STATS_LEN((n)))
121 #define I40E_PFC_STATS_LEN ( \
122 (FIELD_SIZEOF(struct i40e_pf, stats.priority_xoff_rx) + \
123 FIELD_SIZEOF(struct i40e_pf, stats.priority_xon_rx) + \
124 FIELD_SIZEOF(struct i40e_pf, stats.priority_xoff_tx) + \
125 FIELD_SIZEOF(struct i40e_pf, stats.priority_xon_tx) + \
126 FIELD_SIZEOF(struct i40e_pf, stats.priority_xon_2_xoff)) \
128 #define I40E_PF_STATS_LEN(n) (I40E_GLOBAL_STATS_LEN + \
129 I40E_PFC_STATS_LEN + \
130 I40E_VSI_STATS_LEN((n)))
132 enum i40e_ethtool_test_id {
133 I40E_ETH_TEST_REG = 0,
134 I40E_ETH_TEST_EEPROM,
136 I40E_ETH_TEST_LOOPBACK,
140 static const char i40e_gstrings_test[][ETH_GSTRING_LEN] = {
141 "Register test (offline)",
142 "Eeprom test (offline)",
143 "Interrupt test (offline)",
144 "Loopback test (offline)",
145 "Link test (on/offline)"
148 #define I40E_TEST_LEN (sizeof(i40e_gstrings_test) / ETH_GSTRING_LEN)
151 * i40e_get_settings - Get Link Speed and Duplex settings
152 * @netdev: network interface device structure
153 * @ecmd: ethtool command
155 * Reports speed/duplex settings based on media_type
157 static int i40e_get_settings(struct net_device *netdev,
158 struct ethtool_cmd *ecmd)
160 struct i40e_netdev_priv *np = netdev_priv(netdev);
161 struct i40e_pf *pf = np->vsi->back;
162 struct i40e_hw *hw = &pf->hw;
163 struct i40e_link_status *hw_link_info = &hw->phy.link_info;
164 bool link_up = hw_link_info->link_info & I40E_AQ_LINK_UP;
165 u32 link_speed = hw_link_info->link_speed;
167 /* hardware is either in 40G mode or 10G mode
168 * NOTE: this section initializes supported and advertising
170 switch (hw_link_info->phy_type) {
171 case I40E_PHY_TYPE_40GBASE_CR4:
172 case I40E_PHY_TYPE_40GBASE_CR4_CU:
173 ecmd->supported = SUPPORTED_40000baseCR4_Full;
174 ecmd->advertising = ADVERTISED_40000baseCR4_Full;
176 case I40E_PHY_TYPE_40GBASE_KR4:
177 ecmd->supported = SUPPORTED_40000baseKR4_Full;
178 ecmd->advertising = ADVERTISED_40000baseKR4_Full;
180 case I40E_PHY_TYPE_40GBASE_SR4:
181 ecmd->supported = SUPPORTED_40000baseSR4_Full;
182 ecmd->advertising = ADVERTISED_40000baseSR4_Full;
184 case I40E_PHY_TYPE_40GBASE_LR4:
185 ecmd->supported = SUPPORTED_40000baseLR4_Full;
186 ecmd->advertising = ADVERTISED_40000baseLR4_Full;
188 case I40E_PHY_TYPE_10GBASE_KX4:
189 ecmd->supported = SUPPORTED_10000baseKX4_Full;
190 ecmd->advertising = ADVERTISED_10000baseKX4_Full;
192 case I40E_PHY_TYPE_10GBASE_KR:
193 ecmd->supported = SUPPORTED_10000baseKR_Full;
194 ecmd->advertising = ADVERTISED_10000baseKR_Full;
196 case I40E_PHY_TYPE_10GBASE_T:
198 ecmd->supported = SUPPORTED_10000baseT_Full;
199 ecmd->advertising = ADVERTISED_10000baseT_Full;
203 /* for now just say autoneg all the time */
204 ecmd->supported |= SUPPORTED_Autoneg;
206 if (hw->phy.media_type == I40E_MEDIA_TYPE_BACKPLANE) {
207 ecmd->supported |= SUPPORTED_Backplane;
208 ecmd->advertising |= ADVERTISED_Backplane;
209 ecmd->port = PORT_NONE;
210 } else if (hw->phy.media_type == I40E_MEDIA_TYPE_BASET) {
211 ecmd->supported |= SUPPORTED_TP;
212 ecmd->advertising |= ADVERTISED_TP;
213 ecmd->port = PORT_TP;
215 ecmd->supported |= SUPPORTED_FIBRE;
216 ecmd->advertising |= ADVERTISED_FIBRE;
217 ecmd->port = PORT_FIBRE;
220 ecmd->transceiver = XCVR_EXTERNAL;
223 switch (link_speed) {
224 case I40E_LINK_SPEED_40GB:
225 /* need a SPEED_40000 in ethtool.h */
226 ethtool_cmd_speed_set(ecmd, 40000);
228 case I40E_LINK_SPEED_10GB:
229 ethtool_cmd_speed_set(ecmd, SPEED_10000);
234 ecmd->duplex = DUPLEX_FULL;
236 ethtool_cmd_speed_set(ecmd, SPEED_UNKNOWN);
237 ecmd->duplex = DUPLEX_UNKNOWN;
244 * i40e_get_pauseparam - Get Flow Control status
245 * Return tx/rx-pause status
247 static void i40e_get_pauseparam(struct net_device *netdev,
248 struct ethtool_pauseparam *pause)
250 struct i40e_netdev_priv *np = netdev_priv(netdev);
251 struct i40e_pf *pf = np->vsi->back;
252 struct i40e_hw *hw = &pf->hw;
253 struct i40e_link_status *hw_link_info = &hw->phy.link_info;
256 ((hw_link_info->an_info & I40E_AQ_AN_COMPLETED) ?
257 AUTONEG_ENABLE : AUTONEG_DISABLE);
261 if (hw_link_info->an_info & I40E_AQ_LINK_PAUSE_RX)
263 if (hw_link_info->an_info & I40E_AQ_LINK_PAUSE_TX)
267 static u32 i40e_get_msglevel(struct net_device *netdev)
269 struct i40e_netdev_priv *np = netdev_priv(netdev);
270 struct i40e_pf *pf = np->vsi->back;
272 return pf->msg_enable;
275 static void i40e_set_msglevel(struct net_device *netdev, u32 data)
277 struct i40e_netdev_priv *np = netdev_priv(netdev);
278 struct i40e_pf *pf = np->vsi->back;
280 if (I40E_DEBUG_USER & data)
281 pf->hw.debug_mask = data;
282 pf->msg_enable = data;
285 static int i40e_get_regs_len(struct net_device *netdev)
290 for (i = 0; i40e_reg_list[i].offset != 0; i++)
291 reg_count += i40e_reg_list[i].elements;
293 return reg_count * sizeof(u32);
296 static void i40e_get_regs(struct net_device *netdev, struct ethtool_regs *regs,
299 struct i40e_netdev_priv *np = netdev_priv(netdev);
300 struct i40e_pf *pf = np->vsi->back;
301 struct i40e_hw *hw = &pf->hw;
306 /* Tell ethtool which driver-version-specific regs output we have.
308 * At some point, if we have ethtool doing special formatting of
309 * this data, it will rely on this version number to know how to
310 * interpret things. Hence, this needs to be updated if/when the
311 * diags register table is changed.
315 /* loop through the diags reg table for what to print */
317 for (i = 0; i40e_reg_list[i].offset != 0; i++) {
318 for (j = 0; j < i40e_reg_list[i].elements; j++) {
319 reg = i40e_reg_list[i].offset
320 + (j * i40e_reg_list[i].stride);
321 reg_buf[ri++] = rd32(hw, reg);
327 static int i40e_get_eeprom(struct net_device *netdev,
328 struct ethtool_eeprom *eeprom, u8 *bytes)
330 struct i40e_netdev_priv *np = netdev_priv(netdev);
331 struct i40e_hw *hw = &np->vsi->back->hw;
332 int first_word, last_word;
337 if (eeprom->len == 0)
340 eeprom->magic = hw->vendor_id | (hw->device_id << 16);
342 first_word = eeprom->offset >> 1;
343 last_word = (eeprom->offset + eeprom->len - 1) >> 1;
344 eeprom_len = last_word - first_word + 1;
346 eeprom_buff = kmalloc(sizeof(u16) * eeprom_len, GFP_KERNEL);
350 ret_val = i40e_read_nvm_buffer(hw, first_word, &eeprom_len,
352 if (eeprom_len == 0) {
357 /* Device's eeprom is always little-endian, word addressable */
358 for (i = 0; i < eeprom_len; i++)
359 le16_to_cpus(&eeprom_buff[i]);
361 memcpy(bytes, (u8 *)eeprom_buff + (eeprom->offset & 1), eeprom->len);
367 static int i40e_get_eeprom_len(struct net_device *netdev)
369 struct i40e_netdev_priv *np = netdev_priv(netdev);
370 struct i40e_hw *hw = &np->vsi->back->hw;
372 return hw->nvm.sr_size * 2;
375 static void i40e_get_drvinfo(struct net_device *netdev,
376 struct ethtool_drvinfo *drvinfo)
378 struct i40e_netdev_priv *np = netdev_priv(netdev);
379 struct i40e_vsi *vsi = np->vsi;
380 struct i40e_pf *pf = vsi->back;
382 strlcpy(drvinfo->driver, i40e_driver_name, sizeof(drvinfo->driver));
383 strlcpy(drvinfo->version, i40e_driver_version_str,
384 sizeof(drvinfo->version));
385 strlcpy(drvinfo->fw_version, i40e_fw_version_str(&pf->hw),
386 sizeof(drvinfo->fw_version));
387 strlcpy(drvinfo->bus_info, pci_name(pf->pdev),
388 sizeof(drvinfo->bus_info));
391 static void i40e_get_ringparam(struct net_device *netdev,
392 struct ethtool_ringparam *ring)
394 struct i40e_netdev_priv *np = netdev_priv(netdev);
395 struct i40e_pf *pf = np->vsi->back;
396 struct i40e_vsi *vsi = pf->vsi[pf->lan_vsi];
398 ring->rx_max_pending = I40E_MAX_NUM_DESCRIPTORS;
399 ring->tx_max_pending = I40E_MAX_NUM_DESCRIPTORS;
400 ring->rx_mini_max_pending = 0;
401 ring->rx_jumbo_max_pending = 0;
402 ring->rx_pending = vsi->rx_rings[0].count;
403 ring->tx_pending = vsi->tx_rings[0].count;
404 ring->rx_mini_pending = 0;
405 ring->rx_jumbo_pending = 0;
408 static int i40e_set_ringparam(struct net_device *netdev,
409 struct ethtool_ringparam *ring)
411 struct i40e_ring *tx_rings = NULL, *rx_rings = NULL;
412 struct i40e_netdev_priv *np = netdev_priv(netdev);
413 struct i40e_vsi *vsi = np->vsi;
414 struct i40e_pf *pf = vsi->back;
415 u32 new_rx_count, new_tx_count;
418 if ((ring->rx_mini_pending) || (ring->rx_jumbo_pending))
421 new_tx_count = clamp_t(u32, ring->tx_pending,
422 I40E_MIN_NUM_DESCRIPTORS,
423 I40E_MAX_NUM_DESCRIPTORS);
424 new_tx_count = ALIGN(new_tx_count, I40E_REQ_DESCRIPTOR_MULTIPLE);
426 new_rx_count = clamp_t(u32, ring->rx_pending,
427 I40E_MIN_NUM_DESCRIPTORS,
428 I40E_MAX_NUM_DESCRIPTORS);
429 new_rx_count = ALIGN(new_rx_count, I40E_REQ_DESCRIPTOR_MULTIPLE);
431 /* if nothing to do return success */
432 if ((new_tx_count == vsi->tx_rings[0].count) &&
433 (new_rx_count == vsi->rx_rings[0].count))
436 while (test_and_set_bit(__I40E_CONFIG_BUSY, &pf->state))
437 usleep_range(1000, 2000);
439 if (!netif_running(vsi->netdev)) {
440 /* simple case - set for the next time the netdev is started */
441 for (i = 0; i < vsi->num_queue_pairs; i++) {
442 vsi->tx_rings[i].count = new_tx_count;
443 vsi->rx_rings[i].count = new_rx_count;
448 /* We can't just free everything and then setup again,
449 * because the ISRs in MSI-X mode get passed pointers
450 * to the Tx and Rx ring structs.
453 /* alloc updated Tx resources */
454 if (new_tx_count != vsi->tx_rings[0].count) {
456 "Changing Tx descriptor count from %d to %d.\n",
457 vsi->tx_rings[0].count, new_tx_count);
458 tx_rings = kcalloc(vsi->alloc_queue_pairs,
459 sizeof(struct i40e_ring), GFP_KERNEL);
465 for (i = 0; i < vsi->num_queue_pairs; i++) {
466 /* clone ring and setup updated count */
467 tx_rings[i] = vsi->tx_rings[i];
468 tx_rings[i].count = new_tx_count;
469 err = i40e_setup_tx_descriptors(&tx_rings[i]);
473 i40e_free_tx_resources(&tx_rings[i]);
483 /* alloc updated Rx resources */
484 if (new_rx_count != vsi->rx_rings[0].count) {
486 "Changing Rx descriptor count from %d to %d\n",
487 vsi->rx_rings[0].count, new_rx_count);
488 rx_rings = kcalloc(vsi->alloc_queue_pairs,
489 sizeof(struct i40e_ring), GFP_KERNEL);
495 for (i = 0; i < vsi->num_queue_pairs; i++) {
496 /* clone ring and setup updated count */
497 rx_rings[i] = vsi->rx_rings[i];
498 rx_rings[i].count = new_rx_count;
499 err = i40e_setup_rx_descriptors(&rx_rings[i]);
503 i40e_free_rx_resources(&rx_rings[i]);
513 /* Bring interface down, copy in the new ring info,
514 * then restore the interface
519 for (i = 0; i < vsi->num_queue_pairs; i++) {
520 i40e_free_tx_resources(&vsi->tx_rings[i]);
521 vsi->tx_rings[i] = tx_rings[i];
528 for (i = 0; i < vsi->num_queue_pairs; i++) {
529 i40e_free_rx_resources(&vsi->rx_rings[i]);
530 vsi->rx_rings[i] = rx_rings[i];
539 /* error cleanup if the Rx allocations failed after getting Tx */
541 for (i = 0; i < vsi->num_queue_pairs; i++)
542 i40e_free_tx_resources(&tx_rings[i]);
548 clear_bit(__I40E_CONFIG_BUSY, &pf->state);
553 static int i40e_get_sset_count(struct net_device *netdev, int sset)
555 struct i40e_netdev_priv *np = netdev_priv(netdev);
556 struct i40e_vsi *vsi = np->vsi;
557 struct i40e_pf *pf = vsi->back;
561 return I40E_TEST_LEN;
563 if (vsi == pf->vsi[pf->lan_vsi])
564 return I40E_PF_STATS_LEN(netdev);
566 return I40E_VSI_STATS_LEN(netdev);
572 static void i40e_get_ethtool_stats(struct net_device *netdev,
573 struct ethtool_stats *stats, u64 *data)
575 struct i40e_netdev_priv *np = netdev_priv(netdev);
576 struct i40e_vsi *vsi = np->vsi;
577 struct i40e_pf *pf = vsi->back;
581 struct rtnl_link_stats64 *net_stats = i40e_get_vsi_stats_struct(vsi);
583 i40e_update_stats(vsi);
585 for (j = 0; j < I40E_NETDEV_STATS_LEN; j++) {
586 p = (char *)net_stats + i40e_gstrings_net_stats[j].stat_offset;
587 data[i++] = (i40e_gstrings_net_stats[j].sizeof_stat ==
588 sizeof(u64)) ? *(u64 *)p : *(u32 *)p;
590 for (j = 0; j < vsi->num_queue_pairs; j++) {
591 data[i++] = vsi->tx_rings[j].tx_stats.packets;
592 data[i++] = vsi->tx_rings[j].tx_stats.bytes;
594 for (j = 0; j < vsi->num_queue_pairs; j++) {
595 data[i++] = vsi->rx_rings[j].rx_stats.packets;
596 data[i++] = vsi->rx_rings[j].rx_stats.bytes;
598 if (vsi == pf->vsi[pf->lan_vsi]) {
599 for (j = 0; j < I40E_GLOBAL_STATS_LEN; j++) {
600 p = (char *)pf + i40e_gstrings_stats[j].stat_offset;
601 data[i++] = (i40e_gstrings_stats[j].sizeof_stat ==
602 sizeof(u64)) ? *(u64 *)p : *(u32 *)p;
604 for (j = 0; j < I40E_MAX_USER_PRIORITY; j++) {
605 data[i++] = pf->stats.priority_xon_tx[j];
606 data[i++] = pf->stats.priority_xoff_tx[j];
608 for (j = 0; j < I40E_MAX_USER_PRIORITY; j++) {
609 data[i++] = pf->stats.priority_xon_rx[j];
610 data[i++] = pf->stats.priority_xoff_rx[j];
612 for (j = 0; j < I40E_MAX_USER_PRIORITY; j++)
613 data[i++] = pf->stats.priority_xon_2_xoff[j];
617 static void i40e_get_strings(struct net_device *netdev, u32 stringset,
620 struct i40e_netdev_priv *np = netdev_priv(netdev);
621 struct i40e_vsi *vsi = np->vsi;
622 struct i40e_pf *pf = vsi->back;
623 char *p = (char *)data;
628 for (i = 0; i < I40E_TEST_LEN; i++) {
629 memcpy(data, i40e_gstrings_test[i], ETH_GSTRING_LEN);
630 data += ETH_GSTRING_LEN;
634 for (i = 0; i < I40E_NETDEV_STATS_LEN; i++) {
635 snprintf(p, ETH_GSTRING_LEN, "%s",
636 i40e_gstrings_net_stats[i].stat_string);
637 p += ETH_GSTRING_LEN;
639 for (i = 0; i < vsi->num_queue_pairs; i++) {
640 snprintf(p, ETH_GSTRING_LEN, "tx-%u.tx_packets", i);
641 p += ETH_GSTRING_LEN;
642 snprintf(p, ETH_GSTRING_LEN, "tx-%u.tx_bytes", i);
643 p += ETH_GSTRING_LEN;
645 for (i = 0; i < vsi->num_queue_pairs; i++) {
646 snprintf(p, ETH_GSTRING_LEN, "rx-%u.rx_packets", i);
647 p += ETH_GSTRING_LEN;
648 snprintf(p, ETH_GSTRING_LEN, "rx-%u.rx_bytes", i);
649 p += ETH_GSTRING_LEN;
651 if (vsi == pf->vsi[pf->lan_vsi]) {
652 for (i = 0; i < I40E_GLOBAL_STATS_LEN; i++) {
653 snprintf(p, ETH_GSTRING_LEN, "port.%s",
654 i40e_gstrings_stats[i].stat_string);
655 p += ETH_GSTRING_LEN;
657 for (i = 0; i < I40E_MAX_USER_PRIORITY; i++) {
658 snprintf(p, ETH_GSTRING_LEN,
659 "port.tx_priority_%u_xon", i);
660 p += ETH_GSTRING_LEN;
661 snprintf(p, ETH_GSTRING_LEN,
662 "port.tx_priority_%u_xoff", i);
663 p += ETH_GSTRING_LEN;
665 for (i = 0; i < I40E_MAX_USER_PRIORITY; i++) {
666 snprintf(p, ETH_GSTRING_LEN,
667 "port.rx_priority_%u_xon", i);
668 p += ETH_GSTRING_LEN;
669 snprintf(p, ETH_GSTRING_LEN,
670 "port.rx_priority_%u_xoff", i);
671 p += ETH_GSTRING_LEN;
673 for (i = 0; i < I40E_MAX_USER_PRIORITY; i++) {
674 snprintf(p, ETH_GSTRING_LEN,
675 "port.rx_priority_%u_xon_2_xoff", i);
676 p += ETH_GSTRING_LEN;
679 /* BUG_ON(p - data != I40E_STATS_LEN * ETH_GSTRING_LEN); */
684 static int i40e_get_ts_info(struct net_device *dev,
685 struct ethtool_ts_info *info)
687 return ethtool_op_get_ts_info(dev, info);
690 static int i40e_link_test(struct i40e_pf *pf, u64 *data)
692 if (i40e_get_link_status(&pf->hw))
700 static int i40e_reg_test(struct i40e_pf *pf, u64 *data)
704 ret = i40e_diag_reg_test(&pf->hw);
710 static int i40e_eeprom_test(struct i40e_pf *pf, u64 *data)
714 ret = i40e_diag_eeprom_test(&pf->hw);
720 static int i40e_intr_test(struct i40e_pf *pf, u64 *data)
727 static int i40e_loopback_test(struct i40e_pf *pf, u64 *data)
734 static void i40e_diag_test(struct net_device *netdev,
735 struct ethtool_test *eth_test, u64 *data)
737 struct i40e_netdev_priv *np = netdev_priv(netdev);
738 struct i40e_pf *pf = np->vsi->back;
740 set_bit(__I40E_TESTING, &pf->state);
741 if (eth_test->flags == ETH_TEST_FL_OFFLINE) {
744 netdev_info(netdev, "offline testing starting\n");
746 /* Link test performed before hardware reset
747 * so autoneg doesn't interfere with test result
749 netdev_info(netdev, "link test starting\n");
750 if (i40e_link_test(pf, &data[I40E_ETH_TEST_LINK]))
751 eth_test->flags |= ETH_TEST_FL_FAILED;
753 netdev_info(netdev, "register test starting\n");
754 if (i40e_reg_test(pf, &data[I40E_ETH_TEST_REG]))
755 eth_test->flags |= ETH_TEST_FL_FAILED;
757 i40e_do_reset(pf, (1 << __I40E_PF_RESET_REQUESTED));
758 netdev_info(netdev, "eeprom test starting\n");
759 if (i40e_eeprom_test(pf, &data[I40E_ETH_TEST_EEPROM]))
760 eth_test->flags |= ETH_TEST_FL_FAILED;
762 i40e_do_reset(pf, (1 << __I40E_PF_RESET_REQUESTED));
763 netdev_info(netdev, "interrupt test starting\n");
764 if (i40e_intr_test(pf, &data[I40E_ETH_TEST_INTR]))
765 eth_test->flags |= ETH_TEST_FL_FAILED;
767 i40e_do_reset(pf, (1 << __I40E_PF_RESET_REQUESTED));
768 netdev_info(netdev, "loopback test starting\n");
769 if (i40e_loopback_test(pf, &data[I40E_ETH_TEST_LOOPBACK]))
770 eth_test->flags |= ETH_TEST_FL_FAILED;
773 netdev_info(netdev, "online test starting\n");
775 if (i40e_link_test(pf, &data[I40E_ETH_TEST_LINK]))
776 eth_test->flags |= ETH_TEST_FL_FAILED;
778 /* Offline only tests, not run in online; pass by default */
779 data[I40E_ETH_TEST_REG] = 0;
780 data[I40E_ETH_TEST_EEPROM] = 0;
781 data[I40E_ETH_TEST_INTR] = 0;
782 data[I40E_ETH_TEST_LOOPBACK] = 0;
784 clear_bit(__I40E_TESTING, &pf->state);
788 static void i40e_get_wol(struct net_device *netdev,
789 struct ethtool_wolinfo *wol)
795 static int i40e_nway_reset(struct net_device *netdev)
797 /* restart autonegotiation */
798 struct i40e_netdev_priv *np = netdev_priv(netdev);
799 struct i40e_pf *pf = np->vsi->back;
800 struct i40e_hw *hw = &pf->hw;
803 ret = i40e_aq_set_link_restart_an(hw, NULL);
805 netdev_info(netdev, "link restart failed, aq_err=%d\n",
806 pf->hw.aq.asq_last_status);
813 static int i40e_set_phys_id(struct net_device *netdev,
814 enum ethtool_phys_id_state state)
816 struct i40e_netdev_priv *np = netdev_priv(netdev);
817 struct i40e_pf *pf = np->vsi->back;
818 struct i40e_hw *hw = &pf->hw;
822 case ETHTOOL_ID_ACTIVE:
823 pf->led_status = i40e_led_get(hw);
826 i40e_led_set(hw, 0xF);
829 i40e_led_set(hw, 0x0);
831 case ETHTOOL_ID_INACTIVE:
832 i40e_led_set(hw, pf->led_status);
839 /* NOTE: i40e hardware uses a conversion factor of 2 for Interrupt
840 * Throttle Rate (ITR) ie. ITR(1) = 2us ITR(10) = 20 us, and also
841 * 125us (8000 interrupts per second) == ITR(62)
844 static int i40e_get_coalesce(struct net_device *netdev,
845 struct ethtool_coalesce *ec)
847 struct i40e_netdev_priv *np = netdev_priv(netdev);
848 struct i40e_vsi *vsi = np->vsi;
850 ec->tx_max_coalesced_frames_irq = vsi->work_limit;
851 ec->rx_max_coalesced_frames_irq = vsi->work_limit;
853 if (ITR_IS_DYNAMIC(vsi->rx_itr_setting))
854 ec->rx_coalesce_usecs = 1;
856 ec->rx_coalesce_usecs = vsi->rx_itr_setting;
858 if (ITR_IS_DYNAMIC(vsi->tx_itr_setting))
859 ec->tx_coalesce_usecs = 1;
861 ec->tx_coalesce_usecs = vsi->tx_itr_setting;
866 static int i40e_set_coalesce(struct net_device *netdev,
867 struct ethtool_coalesce *ec)
869 struct i40e_netdev_priv *np = netdev_priv(netdev);
870 struct i40e_q_vector *q_vector;
871 struct i40e_vsi *vsi = np->vsi;
872 struct i40e_pf *pf = vsi->back;
873 struct i40e_hw *hw = &pf->hw;
877 if (ec->tx_max_coalesced_frames_irq || ec->rx_max_coalesced_frames_irq)
878 vsi->work_limit = ec->tx_max_coalesced_frames_irq;
880 switch (ec->rx_coalesce_usecs) {
882 vsi->rx_itr_setting = 0;
885 vsi->rx_itr_setting = (I40E_ITR_DYNAMIC |
886 ITR_REG_TO_USEC(I40E_ITR_RX_DEF));
889 if ((ec->rx_coalesce_usecs < (I40E_MIN_ITR << 1)) ||
890 (ec->rx_coalesce_usecs > (I40E_MAX_ITR << 1)))
892 vsi->rx_itr_setting = ec->rx_coalesce_usecs;
896 switch (ec->tx_coalesce_usecs) {
898 vsi->tx_itr_setting = 0;
901 vsi->tx_itr_setting = (I40E_ITR_DYNAMIC |
902 ITR_REG_TO_USEC(I40E_ITR_TX_DEF));
905 if ((ec->tx_coalesce_usecs < (I40E_MIN_ITR << 1)) ||
906 (ec->tx_coalesce_usecs > (I40E_MAX_ITR << 1)))
908 vsi->tx_itr_setting = ec->tx_coalesce_usecs;
912 vector = vsi->base_vector;
913 q_vector = vsi->q_vectors;
914 for (i = 0; i < vsi->num_q_vectors; i++, vector++, q_vector++) {
915 q_vector->rx.itr = ITR_TO_REG(vsi->rx_itr_setting);
916 wr32(hw, I40E_PFINT_ITRN(0, vector - 1), q_vector->rx.itr);
917 q_vector->tx.itr = ITR_TO_REG(vsi->tx_itr_setting);
918 wr32(hw, I40E_PFINT_ITRN(1, vector - 1), q_vector->tx.itr);
926 * i40e_get_rss_hash_opts - Get RSS hash Input Set for each flow type
927 * @pf: pointer to the physical function struct
928 * @cmd: ethtool rxnfc command
930 * Returns Success if the flow is supported, else Invalid Input.
932 static int i40e_get_rss_hash_opts(struct i40e_pf *pf, struct ethtool_rxnfc *cmd)
936 /* Report default options for RSS on i40e */
937 switch (cmd->flow_type) {
940 cmd->data |= RXH_L4_B_0_1 | RXH_L4_B_2_3;
941 /* fall through to add IP fields */
947 cmd->data |= RXH_IP_SRC | RXH_IP_DST;
951 cmd->data |= RXH_L4_B_0_1 | RXH_L4_B_2_3;
952 /* fall through to add IP fields */
958 cmd->data |= RXH_IP_SRC | RXH_IP_DST;
968 * i40e_get_rxnfc - command to get RX flow classification rules
969 * @netdev: network interface device structure
970 * @cmd: ethtool rxnfc command
972 * Returns Success if the command is supported.
974 static int i40e_get_rxnfc(struct net_device *netdev, struct ethtool_rxnfc *cmd,
977 struct i40e_netdev_priv *np = netdev_priv(netdev);
978 struct i40e_vsi *vsi = np->vsi;
979 struct i40e_pf *pf = vsi->back;
980 int ret = -EOPNOTSUPP;
983 case ETHTOOL_GRXRINGS:
984 cmd->data = vsi->alloc_queue_pairs;
988 ret = i40e_get_rss_hash_opts(pf, cmd);
990 case ETHTOOL_GRXCLSRLCNT:
993 case ETHTOOL_GRXCLSRULE:
996 case ETHTOOL_GRXCLSRLALL:
1007 * i40e_set_rss_hash_opt - Enable/Disable flow types for RSS hash
1008 * @pf: pointer to the physical function struct
1009 * @cmd: ethtool rxnfc command
1011 * Returns Success if the flow input set is supported.
1013 static int i40e_set_rss_hash_opt(struct i40e_pf *pf, struct ethtool_rxnfc *nfc)
1015 struct i40e_hw *hw = &pf->hw;
1016 u64 hena = (u64)rd32(hw, I40E_PFQF_HENA(0)) |
1017 ((u64)rd32(hw, I40E_PFQF_HENA(1)) << 32);
1019 /* RSS does not support anything other than hashing
1020 * to queues on src and dst IPs and ports
1022 if (nfc->data & ~(RXH_IP_SRC | RXH_IP_DST |
1023 RXH_L4_B_0_1 | RXH_L4_B_2_3))
1026 /* We need at least the IP SRC and DEST fields for hashing */
1027 if (!(nfc->data & RXH_IP_SRC) ||
1028 !(nfc->data & RXH_IP_DST))
1031 switch (nfc->flow_type) {
1033 switch (nfc->data & (RXH_L4_B_0_1 | RXH_L4_B_2_3)) {
1035 hena &= ~((u64)1 << I40E_FILTER_PCTYPE_NONF_IPV4_TCP);
1037 case (RXH_L4_B_0_1 | RXH_L4_B_2_3):
1038 hena |= ((u64)1 << I40E_FILTER_PCTYPE_NONF_IPV4_TCP);
1045 switch (nfc->data & (RXH_L4_B_0_1 | RXH_L4_B_2_3)) {
1047 hena &= ~((u64)1 << I40E_FILTER_PCTYPE_NONF_IPV6_TCP);
1049 case (RXH_L4_B_0_1 | RXH_L4_B_2_3):
1050 hena |= ((u64)1 << I40E_FILTER_PCTYPE_NONF_IPV6_TCP);
1057 switch (nfc->data & (RXH_L4_B_0_1 | RXH_L4_B_2_3)) {
1060 ~(((u64)1 << I40E_FILTER_PCTYPE_NONF_UNICAST_IPV4_UDP) |
1061 ((u64)1 << I40E_FILTER_PCTYPE_NONF_MULTICAST_IPV4_UDP) |
1062 ((u64)1 << I40E_FILTER_PCTYPE_FRAG_IPV4));
1064 case (RXH_L4_B_0_1 | RXH_L4_B_2_3):
1066 (((u64)1 << I40E_FILTER_PCTYPE_NONF_UNICAST_IPV4_UDP) |
1067 ((u64)1 << I40E_FILTER_PCTYPE_NONF_MULTICAST_IPV4_UDP) |
1068 ((u64)1 << I40E_FILTER_PCTYPE_FRAG_IPV4));
1075 switch (nfc->data & (RXH_L4_B_0_1 | RXH_L4_B_2_3)) {
1078 ~(((u64)1 << I40E_FILTER_PCTYPE_NONF_UNICAST_IPV6_UDP) |
1079 ((u64)1 << I40E_FILTER_PCTYPE_NONF_MULTICAST_IPV6_UDP) |
1080 ((u64)1 << I40E_FILTER_PCTYPE_FRAG_IPV6));
1082 case (RXH_L4_B_0_1 | RXH_L4_B_2_3):
1084 (((u64)1 << I40E_FILTER_PCTYPE_NONF_UNICAST_IPV6_UDP) |
1085 ((u64)1 << I40E_FILTER_PCTYPE_NONF_MULTICAST_IPV6_UDP) |
1086 ((u64)1 << I40E_FILTER_PCTYPE_FRAG_IPV6));
1092 case AH_ESP_V4_FLOW:
1096 if ((nfc->data & RXH_L4_B_0_1) ||
1097 (nfc->data & RXH_L4_B_2_3))
1099 hena |= ((u64)1 << I40E_FILTER_PCTYPE_NONF_IPV4_OTHER);
1101 case AH_ESP_V6_FLOW:
1105 if ((nfc->data & RXH_L4_B_0_1) ||
1106 (nfc->data & RXH_L4_B_2_3))
1108 hena |= ((u64)1 << I40E_FILTER_PCTYPE_NONF_IPV6_OTHER);
1111 hena |= ((u64)1 << I40E_FILTER_PCTYPE_NONF_IPV4_OTHER) |
1112 ((u64)1 << I40E_FILTER_PCTYPE_FRAG_IPV4);
1115 hena |= ((u64)1 << I40E_FILTER_PCTYPE_NONF_IPV6_OTHER) |
1116 ((u64)1 << I40E_FILTER_PCTYPE_FRAG_IPV6);
1122 wr32(hw, I40E_PFQF_HENA(0), (u32)hena);
1123 wr32(hw, I40E_PFQF_HENA(1), (u32)(hena >> 32));
1129 #define IP_HEADER_OFFSET 14
1131 * i40e_add_del_fdir_udpv4 - Add/Remove UDPv4 Flow Director filters for
1132 * a specific flow spec
1133 * @vsi: pointer to the targeted VSI
1134 * @fd_data: the flow director data required from the FDir descriptor
1135 * @ethtool_rx_flow_spec: the flow spec
1136 * @add: true adds a filter, false removes it
1138 * Returns 0 if the filters were successfully added or removed
1140 static int i40e_add_del_fdir_udpv4(struct i40e_vsi *vsi,
1141 struct i40e_fdir_data *fd_data,
1142 struct ethtool_rx_flow_spec *fsp, bool add)
1144 struct i40e_pf *pf = vsi->back;
1151 ip = (struct iphdr *)(fd_data->raw_packet + IP_HEADER_OFFSET);
1152 udp = (struct udphdr *)(fd_data->raw_packet + IP_HEADER_OFFSET
1153 + sizeof(struct iphdr));
1155 ip->saddr = fsp->h_u.tcp_ip4_spec.ip4src;
1156 ip->daddr = fsp->h_u.tcp_ip4_spec.ip4dst;
1157 udp->source = fsp->h_u.tcp_ip4_spec.psrc;
1158 udp->dest = fsp->h_u.tcp_ip4_spec.pdst;
1160 for (i = I40E_FILTER_PCTYPE_NONF_UNICAST_IPV4_UDP;
1161 i <= I40E_FILTER_PCTYPE_NONF_IPV4_UDP; i++) {
1162 fd_data->pctype = i;
1163 ret = i40e_program_fdir_filter(fd_data, pf, add);
1166 dev_info(&pf->pdev->dev,
1167 "Filter command send failed for PCTYPE %d (ret = %d)\n",
1168 fd_data->pctype, ret);
1171 dev_info(&pf->pdev->dev,
1172 "Filter OK for PCTYPE %d (ret = %d)\n",
1173 fd_data->pctype, ret);
1177 return err ? -EOPNOTSUPP : 0;
1181 * i40e_add_del_fdir_tcpv4 - Add/Remove TCPv4 Flow Director filters for
1182 * a specific flow spec
1183 * @vsi: pointer to the targeted VSI
1184 * @fd_data: the flow director data required from the FDir descriptor
1185 * @ethtool_rx_flow_spec: the flow spec
1186 * @add: true adds a filter, false removes it
1188 * Returns 0 if the filters were successfully added or removed
1190 static int i40e_add_del_fdir_tcpv4(struct i40e_vsi *vsi,
1191 struct i40e_fdir_data *fd_data,
1192 struct ethtool_rx_flow_spec *fsp, bool add)
1194 struct i40e_pf *pf = vsi->back;
1200 ip = (struct iphdr *)(fd_data->raw_packet + IP_HEADER_OFFSET);
1201 tcp = (struct tcphdr *)(fd_data->raw_packet + IP_HEADER_OFFSET
1202 + sizeof(struct iphdr));
1204 ip->daddr = fsp->h_u.tcp_ip4_spec.ip4dst;
1205 tcp->dest = fsp->h_u.tcp_ip4_spec.pdst;
1207 fd_data->pctype = I40E_FILTER_PCTYPE_NONF_IPV4_TCP_SYN;
1208 ret = i40e_program_fdir_filter(fd_data, pf, add);
1211 dev_info(&pf->pdev->dev,
1212 "Filter command send failed for PCTYPE %d (ret = %d)\n",
1213 fd_data->pctype, ret);
1216 dev_info(&pf->pdev->dev, "Filter OK for PCTYPE %d (ret = %d)\n",
1217 fd_data->pctype, ret);
1220 ip->saddr = fsp->h_u.tcp_ip4_spec.ip4src;
1221 tcp->source = fsp->h_u.tcp_ip4_spec.psrc;
1223 fd_data->pctype = I40E_FILTER_PCTYPE_NONF_IPV4_TCP;
1225 ret = i40e_program_fdir_filter(fd_data, pf, add);
1227 dev_info(&pf->pdev->dev,
1228 "Filter command send failed for PCTYPE %d (ret = %d)\n",
1229 fd_data->pctype, ret);
1232 dev_info(&pf->pdev->dev, "Filter OK for PCTYPE %d (ret = %d)\n",
1233 fd_data->pctype, ret);
1236 return err ? -EOPNOTSUPP : 0;
1240 * i40e_add_del_fdir_sctpv4 - Add/Remove SCTPv4 Flow Director filters for
1241 * a specific flow spec
1242 * @vsi: pointer to the targeted VSI
1243 * @fd_data: the flow director data required from the FDir descriptor
1244 * @ethtool_rx_flow_spec: the flow spec
1245 * @add: true adds a filter, false removes it
1247 * Returns 0 if the filters were successfully added or removed
1249 static int i40e_add_del_fdir_sctpv4(struct i40e_vsi *vsi,
1250 struct i40e_fdir_data *fd_data,
1251 struct ethtool_rx_flow_spec *fsp, bool add)
1257 * i40e_add_del_fdir_ipv4 - Add/Remove IPv4 Flow Director filters for
1258 * a specific flow spec
1259 * @vsi: pointer to the targeted VSI
1260 * @fd_data: the flow director data required for the FDir descriptor
1261 * @fsp: the ethtool flow spec
1262 * @add: true adds a filter, false removes it
1264 * Returns 0 if the filters were successfully added or removed
1266 static int i40e_add_del_fdir_ipv4(struct i40e_vsi *vsi,
1267 struct i40e_fdir_data *fd_data,
1268 struct ethtool_rx_flow_spec *fsp, bool add)
1270 struct i40e_pf *pf = vsi->back;
1276 ip = (struct iphdr *)(fd_data->raw_packet + IP_HEADER_OFFSET);
1278 ip->saddr = fsp->h_u.usr_ip4_spec.ip4src;
1279 ip->daddr = fsp->h_u.usr_ip4_spec.ip4dst;
1280 ip->protocol = fsp->h_u.usr_ip4_spec.proto;
1282 for (i = I40E_FILTER_PCTYPE_NONF_IPV4_OTHER;
1283 i <= I40E_FILTER_PCTYPE_FRAG_IPV4; i++) {
1284 fd_data->pctype = i;
1285 ret = i40e_program_fdir_filter(fd_data, pf, add);
1288 dev_info(&pf->pdev->dev,
1289 "Filter command send failed for PCTYPE %d (ret = %d)\n",
1290 fd_data->pctype, ret);
1293 dev_info(&pf->pdev->dev,
1294 "Filter OK for PCTYPE %d (ret = %d)\n",
1295 fd_data->pctype, ret);
1299 return err ? -EOPNOTSUPP : 0;
1303 * i40e_add_del_fdir_ethtool - Add/Remove Flow Director filters for
1304 * a specific flow spec based on their protocol
1305 * @vsi: pointer to the targeted VSI
1306 * @cmd: command to get or set RX flow classification rules
1307 * @add: true adds a filter, false removes it
1309 * Returns 0 if the filters were successfully added or removed
1311 static int i40e_add_del_fdir_ethtool(struct i40e_vsi *vsi,
1312 struct ethtool_rxnfc *cmd, bool add)
1314 struct i40e_fdir_data fd_data;
1317 struct ethtool_rx_flow_spec *fsp =
1318 (struct ethtool_rx_flow_spec *)&cmd->fs;
1325 if ((fsp->ring_cookie != RX_CLS_FLOW_DISC) &&
1326 (fsp->ring_cookie >= vsi->num_queue_pairs))
1329 /* Populate the Flow Director that we have at the moment
1330 * and allocate the raw packet buffer for the calling functions
1332 fd_data.raw_packet = kzalloc(I40E_FDIR_MAX_RAW_PACKET_LOOKUP,
1335 if (!fd_data.raw_packet) {
1336 dev_info(&pf->pdev->dev, "Could not allocate memory\n");
1340 fd_data.q_index = fsp->ring_cookie;
1341 fd_data.flex_off = 0;
1343 fd_data.dest_vsi = vsi->id;
1344 fd_data.dest_ctl = 0;
1345 fd_data.fd_status = 0;
1346 fd_data.cnt_index = 0;
1349 switch (fsp->flow_type & ~FLOW_EXT) {
1351 ret = i40e_add_del_fdir_tcpv4(vsi, &fd_data, fsp, add);
1354 ret = i40e_add_del_fdir_udpv4(vsi, &fd_data, fsp, add);
1357 ret = i40e_add_del_fdir_sctpv4(vsi, &fd_data, fsp, add);
1360 ret = i40e_add_del_fdir_ipv4(vsi, &fd_data, fsp, add);
1363 switch (fsp->h_u.usr_ip4_spec.proto) {
1365 ret = i40e_add_del_fdir_tcpv4(vsi, &fd_data, fsp, add);
1368 ret = i40e_add_del_fdir_udpv4(vsi, &fd_data, fsp, add);
1371 ret = i40e_add_del_fdir_sctpv4(vsi, &fd_data, fsp, add);
1374 ret = i40e_add_del_fdir_ipv4(vsi, &fd_data, fsp, add);
1379 dev_info(&pf->pdev->dev, "Could not specify spec type\n");
1383 kfree(fd_data.raw_packet);
1384 fd_data.raw_packet = NULL;
1389 * i40e_set_rxnfc - command to set RX flow classification rules
1390 * @netdev: network interface device structure
1391 * @cmd: ethtool rxnfc command
1393 * Returns Success if the command is supported.
1395 static int i40e_set_rxnfc(struct net_device *netdev, struct ethtool_rxnfc *cmd)
1397 struct i40e_netdev_priv *np = netdev_priv(netdev);
1398 struct i40e_vsi *vsi = np->vsi;
1399 struct i40e_pf *pf = vsi->back;
1400 int ret = -EOPNOTSUPP;
1404 ret = i40e_set_rss_hash_opt(pf, cmd);
1406 case ETHTOOL_SRXCLSRLINS:
1407 ret = i40e_add_del_fdir_ethtool(vsi, cmd, true);
1409 case ETHTOOL_SRXCLSRLDEL:
1410 ret = i40e_add_del_fdir_ethtool(vsi, cmd, false);
1419 static const struct ethtool_ops i40e_ethtool_ops = {
1420 .get_settings = i40e_get_settings,
1421 .get_drvinfo = i40e_get_drvinfo,
1422 .get_regs_len = i40e_get_regs_len,
1423 .get_regs = i40e_get_regs,
1424 .nway_reset = i40e_nway_reset,
1425 .get_link = ethtool_op_get_link,
1426 .get_wol = i40e_get_wol,
1427 .get_eeprom_len = i40e_get_eeprom_len,
1428 .get_eeprom = i40e_get_eeprom,
1429 .get_ringparam = i40e_get_ringparam,
1430 .set_ringparam = i40e_set_ringparam,
1431 .get_pauseparam = i40e_get_pauseparam,
1432 .get_msglevel = i40e_get_msglevel,
1433 .set_msglevel = i40e_set_msglevel,
1434 .get_rxnfc = i40e_get_rxnfc,
1435 .set_rxnfc = i40e_set_rxnfc,
1436 .self_test = i40e_diag_test,
1437 .get_strings = i40e_get_strings,
1438 .set_phys_id = i40e_set_phys_id,
1439 .get_sset_count = i40e_get_sset_count,
1440 .get_ethtool_stats = i40e_get_ethtool_stats,
1441 .get_coalesce = i40e_get_coalesce,
1442 .set_coalesce = i40e_set_coalesce,
1443 .get_ts_info = i40e_get_ts_info,
1446 void i40e_set_ethtool_ops(struct net_device *netdev)
1448 SET_ETHTOOL_OPS(netdev, &i40e_ethtool_ops);