1 /*******************************************************************************
3 * Intel Ethernet Controller XL710 Family Linux Driver
4 * Copyright(c) 2013 - 2015 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
16 * with this program. If not, see <http://www.gnu.org/licenses/>.
18 * The full GNU General Public License is included in this distribution in
19 * the file called "COPYING".
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
25 ******************************************************************************/
27 /* ethtool support for i40e */
30 #include "i40e_diag.h"
33 char stat_string[ETH_GSTRING_LEN];
38 #define I40E_STAT(_type, _name, _stat) { \
39 .stat_string = _name, \
40 .sizeof_stat = FIELD_SIZEOF(_type, _stat), \
41 .stat_offset = offsetof(_type, _stat) \
44 #define I40E_NETDEV_STAT(_net_stat) \
45 I40E_STAT(struct rtnl_link_stats64, #_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)
50 #define I40E_VEB_STAT(_name, _stat) \
51 I40E_STAT(struct i40e_veb, _name, _stat)
53 static const struct i40e_stats i40e_gstrings_net_stats[] = {
54 I40E_NETDEV_STAT(rx_packets),
55 I40E_NETDEV_STAT(tx_packets),
56 I40E_NETDEV_STAT(rx_bytes),
57 I40E_NETDEV_STAT(tx_bytes),
58 I40E_NETDEV_STAT(rx_errors),
59 I40E_NETDEV_STAT(tx_errors),
60 I40E_NETDEV_STAT(rx_dropped),
61 I40E_NETDEV_STAT(tx_dropped),
62 I40E_NETDEV_STAT(collisions),
63 I40E_NETDEV_STAT(rx_length_errors),
64 I40E_NETDEV_STAT(rx_crc_errors),
67 static const struct i40e_stats i40e_gstrings_veb_stats[] = {
68 I40E_VEB_STAT("rx_bytes", stats.rx_bytes),
69 I40E_VEB_STAT("tx_bytes", stats.tx_bytes),
70 I40E_VEB_STAT("rx_unicast", stats.rx_unicast),
71 I40E_VEB_STAT("tx_unicast", stats.tx_unicast),
72 I40E_VEB_STAT("rx_multicast", stats.rx_multicast),
73 I40E_VEB_STAT("tx_multicast", stats.tx_multicast),
74 I40E_VEB_STAT("rx_broadcast", stats.rx_broadcast),
75 I40E_VEB_STAT("tx_broadcast", stats.tx_broadcast),
76 I40E_VEB_STAT("rx_discards", stats.rx_discards),
77 I40E_VEB_STAT("tx_discards", stats.tx_discards),
78 I40E_VEB_STAT("tx_errors", stats.tx_errors),
79 I40E_VEB_STAT("rx_unknown_protocol", stats.rx_unknown_protocol),
82 static const struct i40e_stats i40e_gstrings_misc_stats[] = {
83 I40E_VSI_STAT("rx_unicast", eth_stats.rx_unicast),
84 I40E_VSI_STAT("tx_unicast", eth_stats.tx_unicast),
85 I40E_VSI_STAT("rx_multicast", eth_stats.rx_multicast),
86 I40E_VSI_STAT("tx_multicast", eth_stats.tx_multicast),
87 I40E_VSI_STAT("rx_broadcast", eth_stats.rx_broadcast),
88 I40E_VSI_STAT("tx_broadcast", eth_stats.tx_broadcast),
89 I40E_VSI_STAT("rx_unknown_protocol", eth_stats.rx_unknown_protocol),
92 static int i40e_add_fdir_ethtool(struct i40e_vsi *vsi,
93 struct ethtool_rxnfc *cmd);
95 /* These PF_STATs might look like duplicates of some NETDEV_STATs,
96 * but they are separate. This device supports Virtualization, and
97 * as such might have several netdevs supporting VMDq and FCoE going
98 * through a single port. The NETDEV_STATs are for individual netdevs
99 * seen at the top of the stack, and the PF_STATs are for the physical
100 * function at the bottom of the stack hosting those netdevs.
102 * The PF_STATs are appended to the netdev stats only when ethtool -S
103 * is queried on the base PF netdev, not on the VMDq or FCoE netdev.
105 static struct i40e_stats i40e_gstrings_stats[] = {
106 I40E_PF_STAT("rx_bytes", stats.eth.rx_bytes),
107 I40E_PF_STAT("tx_bytes", stats.eth.tx_bytes),
108 I40E_PF_STAT("rx_unicast", stats.eth.rx_unicast),
109 I40E_PF_STAT("tx_unicast", stats.eth.tx_unicast),
110 I40E_PF_STAT("rx_multicast", stats.eth.rx_multicast),
111 I40E_PF_STAT("tx_multicast", stats.eth.tx_multicast),
112 I40E_PF_STAT("rx_broadcast", stats.eth.rx_broadcast),
113 I40E_PF_STAT("tx_broadcast", stats.eth.tx_broadcast),
114 I40E_PF_STAT("tx_errors", stats.eth.tx_errors),
115 I40E_PF_STAT("rx_dropped", stats.eth.rx_discards),
116 I40E_PF_STAT("tx_dropped_link_down", stats.tx_dropped_link_down),
117 I40E_PF_STAT("crc_errors", stats.crc_errors),
118 I40E_PF_STAT("illegal_bytes", stats.illegal_bytes),
119 I40E_PF_STAT("mac_local_faults", stats.mac_local_faults),
120 I40E_PF_STAT("mac_remote_faults", stats.mac_remote_faults),
121 I40E_PF_STAT("tx_timeout", tx_timeout_count),
122 I40E_PF_STAT("rx_csum_bad", hw_csum_rx_error),
123 I40E_PF_STAT("rx_length_errors", stats.rx_length_errors),
124 I40E_PF_STAT("link_xon_rx", stats.link_xon_rx),
125 I40E_PF_STAT("link_xoff_rx", stats.link_xoff_rx),
126 I40E_PF_STAT("link_xon_tx", stats.link_xon_tx),
127 I40E_PF_STAT("link_xoff_tx", stats.link_xoff_tx),
128 I40E_PF_STAT("rx_size_64", stats.rx_size_64),
129 I40E_PF_STAT("rx_size_127", stats.rx_size_127),
130 I40E_PF_STAT("rx_size_255", stats.rx_size_255),
131 I40E_PF_STAT("rx_size_511", stats.rx_size_511),
132 I40E_PF_STAT("rx_size_1023", stats.rx_size_1023),
133 I40E_PF_STAT("rx_size_1522", stats.rx_size_1522),
134 I40E_PF_STAT("rx_size_big", stats.rx_size_big),
135 I40E_PF_STAT("tx_size_64", stats.tx_size_64),
136 I40E_PF_STAT("tx_size_127", stats.tx_size_127),
137 I40E_PF_STAT("tx_size_255", stats.tx_size_255),
138 I40E_PF_STAT("tx_size_511", stats.tx_size_511),
139 I40E_PF_STAT("tx_size_1023", stats.tx_size_1023),
140 I40E_PF_STAT("tx_size_1522", stats.tx_size_1522),
141 I40E_PF_STAT("tx_size_big", stats.tx_size_big),
142 I40E_PF_STAT("rx_undersize", stats.rx_undersize),
143 I40E_PF_STAT("rx_fragments", stats.rx_fragments),
144 I40E_PF_STAT("rx_oversize", stats.rx_oversize),
145 I40E_PF_STAT("rx_jabber", stats.rx_jabber),
146 I40E_PF_STAT("VF_admin_queue_requests", vf_aq_requests),
147 I40E_PF_STAT("rx_hwtstamp_cleared", rx_hwtstamp_cleared),
148 I40E_PF_STAT("fdir_flush_cnt", fd_flush_cnt),
149 I40E_PF_STAT("fdir_atr_match", stats.fd_atr_match),
150 I40E_PF_STAT("fdir_atr_tunnel_match", stats.fd_atr_tunnel_match),
151 I40E_PF_STAT("fdir_atr_status", stats.fd_atr_status),
152 I40E_PF_STAT("fdir_sb_match", stats.fd_sb_match),
153 I40E_PF_STAT("fdir_sb_status", stats.fd_sb_status),
156 I40E_PF_STAT("tx_lpi_status", stats.tx_lpi_status),
157 I40E_PF_STAT("rx_lpi_status", stats.rx_lpi_status),
158 I40E_PF_STAT("tx_lpi_count", stats.tx_lpi_count),
159 I40E_PF_STAT("rx_lpi_count", stats.rx_lpi_count),
163 static const struct i40e_stats i40e_gstrings_fcoe_stats[] = {
164 I40E_VSI_STAT("fcoe_bad_fccrc", fcoe_stats.fcoe_bad_fccrc),
165 I40E_VSI_STAT("rx_fcoe_dropped", fcoe_stats.rx_fcoe_dropped),
166 I40E_VSI_STAT("rx_fcoe_packets", fcoe_stats.rx_fcoe_packets),
167 I40E_VSI_STAT("rx_fcoe_dwords", fcoe_stats.rx_fcoe_dwords),
168 I40E_VSI_STAT("fcoe_ddp_count", fcoe_stats.fcoe_ddp_count),
169 I40E_VSI_STAT("fcoe_last_error", fcoe_stats.fcoe_last_error),
170 I40E_VSI_STAT("tx_fcoe_packets", fcoe_stats.tx_fcoe_packets),
171 I40E_VSI_STAT("tx_fcoe_dwords", fcoe_stats.tx_fcoe_dwords),
174 #endif /* I40E_FCOE */
175 #define I40E_QUEUE_STATS_LEN(n) \
176 (((struct i40e_netdev_priv *)netdev_priv((n)))->vsi->num_queue_pairs \
177 * 2 /* Tx and Rx together */ \
178 * (sizeof(struct i40e_queue_stats) / sizeof(u64)))
179 #define I40E_GLOBAL_STATS_LEN ARRAY_SIZE(i40e_gstrings_stats)
180 #define I40E_NETDEV_STATS_LEN ARRAY_SIZE(i40e_gstrings_net_stats)
181 #define I40E_MISC_STATS_LEN ARRAY_SIZE(i40e_gstrings_misc_stats)
183 #define I40E_FCOE_STATS_LEN ARRAY_SIZE(i40e_gstrings_fcoe_stats)
184 #define I40E_VSI_STATS_LEN(n) (I40E_NETDEV_STATS_LEN + \
185 I40E_FCOE_STATS_LEN + \
186 I40E_MISC_STATS_LEN + \
187 I40E_QUEUE_STATS_LEN((n)))
189 #define I40E_VSI_STATS_LEN(n) (I40E_NETDEV_STATS_LEN + \
190 I40E_MISC_STATS_LEN + \
191 I40E_QUEUE_STATS_LEN((n)))
192 #endif /* I40E_FCOE */
193 #define I40E_PFC_STATS_LEN ( \
194 (FIELD_SIZEOF(struct i40e_pf, stats.priority_xoff_rx) + \
195 FIELD_SIZEOF(struct i40e_pf, stats.priority_xon_rx) + \
196 FIELD_SIZEOF(struct i40e_pf, stats.priority_xoff_tx) + \
197 FIELD_SIZEOF(struct i40e_pf, stats.priority_xon_tx) + \
198 FIELD_SIZEOF(struct i40e_pf, stats.priority_xon_2_xoff)) \
200 #define I40E_VEB_STATS_LEN ARRAY_SIZE(i40e_gstrings_veb_stats)
201 #define I40E_PF_STATS_LEN(n) (I40E_GLOBAL_STATS_LEN + \
202 I40E_PFC_STATS_LEN + \
203 I40E_VSI_STATS_LEN((n)))
205 enum i40e_ethtool_test_id {
206 I40E_ETH_TEST_REG = 0,
207 I40E_ETH_TEST_EEPROM,
209 I40E_ETH_TEST_LOOPBACK,
213 static const char i40e_gstrings_test[][ETH_GSTRING_LEN] = {
214 "Register test (offline)",
215 "Eeprom test (offline)",
216 "Interrupt test (offline)",
217 "Loopback test (offline)",
218 "Link test (on/offline)"
221 #define I40E_TEST_LEN (sizeof(i40e_gstrings_test) / ETH_GSTRING_LEN)
223 static const char i40e_priv_flags_strings[][ETH_GSTRING_LEN] = {
227 #define I40E_PRIV_FLAGS_STR_LEN \
228 (sizeof(i40e_priv_flags_strings) / ETH_GSTRING_LEN)
231 * i40e_partition_setting_complaint - generic complaint for MFP restriction
234 static void i40e_partition_setting_complaint(struct i40e_pf *pf)
236 dev_info(&pf->pdev->dev,
237 "The link settings are allowed to be changed only from the first partition of a given port. Please switch to the first partition in order to change the setting.\n");
241 * i40e_get_settings_link_up - Get the Link settings for when link is up
243 * @ecmd: ethtool command to fill in
244 * @netdev: network interface device structure
247 static void i40e_get_settings_link_up(struct i40e_hw *hw,
248 struct ethtool_cmd *ecmd,
249 struct net_device *netdev)
251 struct i40e_link_status *hw_link_info = &hw->phy.link_info;
252 u32 link_speed = hw_link_info->link_speed;
254 /* Initialize supported and advertised settings based on phy settings */
255 switch (hw_link_info->phy_type) {
256 case I40E_PHY_TYPE_40GBASE_CR4:
257 case I40E_PHY_TYPE_40GBASE_CR4_CU:
258 ecmd->supported = SUPPORTED_Autoneg |
259 SUPPORTED_40000baseCR4_Full;
260 ecmd->advertising = ADVERTISED_Autoneg |
261 ADVERTISED_40000baseCR4_Full;
263 case I40E_PHY_TYPE_XLAUI:
264 case I40E_PHY_TYPE_XLPPI:
265 case I40E_PHY_TYPE_40GBASE_AOC:
266 ecmd->supported = SUPPORTED_40000baseCR4_Full;
268 case I40E_PHY_TYPE_40GBASE_KR4:
269 ecmd->supported = SUPPORTED_Autoneg |
270 SUPPORTED_40000baseKR4_Full;
271 ecmd->advertising = ADVERTISED_Autoneg |
272 ADVERTISED_40000baseKR4_Full;
274 case I40E_PHY_TYPE_40GBASE_SR4:
275 ecmd->supported = SUPPORTED_40000baseSR4_Full;
277 case I40E_PHY_TYPE_40GBASE_LR4:
278 ecmd->supported = SUPPORTED_40000baseLR4_Full;
280 case I40E_PHY_TYPE_20GBASE_KR2:
281 ecmd->supported = SUPPORTED_Autoneg |
282 SUPPORTED_20000baseKR2_Full;
283 ecmd->advertising = ADVERTISED_Autoneg |
284 ADVERTISED_20000baseKR2_Full;
286 case I40E_PHY_TYPE_10GBASE_KX4:
287 ecmd->supported = SUPPORTED_Autoneg |
288 SUPPORTED_10000baseKX4_Full;
289 ecmd->advertising = ADVERTISED_Autoneg |
290 ADVERTISED_10000baseKX4_Full;
292 case I40E_PHY_TYPE_10GBASE_KR:
293 ecmd->supported = SUPPORTED_Autoneg |
294 SUPPORTED_10000baseKR_Full;
295 ecmd->advertising = ADVERTISED_Autoneg |
296 ADVERTISED_10000baseKR_Full;
298 case I40E_PHY_TYPE_10GBASE_SR:
299 case I40E_PHY_TYPE_10GBASE_LR:
300 case I40E_PHY_TYPE_1000BASE_SX:
301 case I40E_PHY_TYPE_1000BASE_LX:
302 ecmd->supported = SUPPORTED_10000baseT_Full |
303 SUPPORTED_1000baseT_Full;
304 if (hw_link_info->requested_speeds & I40E_LINK_SPEED_10GB)
305 ecmd->advertising |= ADVERTISED_10000baseT_Full;
306 if (hw_link_info->requested_speeds & I40E_LINK_SPEED_1GB)
307 ecmd->advertising |= ADVERTISED_1000baseT_Full;
309 case I40E_PHY_TYPE_1000BASE_KX:
310 ecmd->supported = SUPPORTED_Autoneg |
311 SUPPORTED_1000baseKX_Full;
312 ecmd->advertising = ADVERTISED_Autoneg |
313 ADVERTISED_1000baseKX_Full;
315 case I40E_PHY_TYPE_10GBASE_T:
316 case I40E_PHY_TYPE_1000BASE_T:
317 case I40E_PHY_TYPE_100BASE_TX:
318 ecmd->supported = SUPPORTED_Autoneg |
319 SUPPORTED_10000baseT_Full |
320 SUPPORTED_1000baseT_Full |
321 SUPPORTED_100baseT_Full;
322 ecmd->advertising = ADVERTISED_Autoneg;
323 if (hw_link_info->requested_speeds & I40E_LINK_SPEED_10GB)
324 ecmd->advertising |= ADVERTISED_10000baseT_Full;
325 if (hw_link_info->requested_speeds & I40E_LINK_SPEED_1GB)
326 ecmd->advertising |= ADVERTISED_1000baseT_Full;
327 if (hw_link_info->requested_speeds & I40E_LINK_SPEED_100MB)
328 ecmd->advertising |= ADVERTISED_100baseT_Full;
330 case I40E_PHY_TYPE_10GBASE_CR1_CU:
331 case I40E_PHY_TYPE_10GBASE_CR1:
332 ecmd->supported = SUPPORTED_Autoneg |
333 SUPPORTED_10000baseT_Full;
334 ecmd->advertising = ADVERTISED_Autoneg |
335 ADVERTISED_10000baseT_Full;
337 case I40E_PHY_TYPE_XAUI:
338 case I40E_PHY_TYPE_XFI:
339 case I40E_PHY_TYPE_SFI:
340 case I40E_PHY_TYPE_10GBASE_SFPP_CU:
341 case I40E_PHY_TYPE_10GBASE_AOC:
342 ecmd->supported = SUPPORTED_10000baseT_Full;
344 case I40E_PHY_TYPE_SGMII:
345 ecmd->supported = SUPPORTED_Autoneg |
346 SUPPORTED_1000baseT_Full |
347 SUPPORTED_100baseT_Full;
348 if (hw_link_info->requested_speeds & I40E_LINK_SPEED_1GB)
349 ecmd->advertising |= ADVERTISED_1000baseT_Full;
350 if (hw_link_info->requested_speeds & I40E_LINK_SPEED_100MB)
351 ecmd->advertising |= ADVERTISED_100baseT_Full;
354 /* if we got here and link is up something bad is afoot */
355 netdev_info(netdev, "WARNING: Link is up but PHY type 0x%x is not recognized.\n",
356 hw_link_info->phy_type);
359 /* Set speed and duplex */
360 switch (link_speed) {
361 case I40E_LINK_SPEED_40GB:
362 ethtool_cmd_speed_set(ecmd, SPEED_40000);
364 case I40E_LINK_SPEED_20GB:
365 ethtool_cmd_speed_set(ecmd, SPEED_20000);
367 case I40E_LINK_SPEED_10GB:
368 ethtool_cmd_speed_set(ecmd, SPEED_10000);
370 case I40E_LINK_SPEED_1GB:
371 ethtool_cmd_speed_set(ecmd, SPEED_1000);
373 case I40E_LINK_SPEED_100MB:
374 ethtool_cmd_speed_set(ecmd, SPEED_100);
379 ecmd->duplex = DUPLEX_FULL;
383 * i40e_get_settings_link_down - Get the Link settings for when link is down
385 * @ecmd: ethtool command to fill in
387 * Reports link settings that can be determined when link is down
389 static void i40e_get_settings_link_down(struct i40e_hw *hw,
390 struct ethtool_cmd *ecmd)
392 struct i40e_link_status *hw_link_info = &hw->phy.link_info;
394 /* link is down and the driver needs to fall back on
395 * device ID to determine what kinds of info to display,
396 * it's mostly a guess that may change when link is up
398 switch (hw->device_id) {
399 case I40E_DEV_ID_QSFP_A:
400 case I40E_DEV_ID_QSFP_B:
401 case I40E_DEV_ID_QSFP_C:
403 ecmd->supported = SUPPORTED_40000baseSR4_Full |
404 SUPPORTED_40000baseCR4_Full |
405 SUPPORTED_40000baseLR4_Full;
406 ecmd->advertising = ADVERTISED_40000baseSR4_Full |
407 ADVERTISED_40000baseCR4_Full |
408 ADVERTISED_40000baseLR4_Full;
410 case I40E_DEV_ID_KX_B:
412 ecmd->supported = SUPPORTED_40000baseKR4_Full;
413 ecmd->advertising = ADVERTISED_40000baseKR4_Full;
415 case I40E_DEV_ID_KX_C:
417 ecmd->supported = SUPPORTED_10000baseKR_Full;
418 ecmd->advertising = ADVERTISED_10000baseKR_Full;
420 case I40E_DEV_ID_10G_BASE_T:
421 ecmd->supported = SUPPORTED_10000baseT_Full |
422 SUPPORTED_1000baseT_Full |
423 SUPPORTED_100baseT_Full;
424 /* Figure out what has been requested */
425 if (hw_link_info->requested_speeds & I40E_LINK_SPEED_10GB)
426 ecmd->advertising |= ADVERTISED_10000baseT_Full;
427 if (hw_link_info->requested_speeds & I40E_LINK_SPEED_1GB)
428 ecmd->advertising |= ADVERTISED_1000baseT_Full;
429 if (hw_link_info->requested_speeds & I40E_LINK_SPEED_100MB)
430 ecmd->advertising |= ADVERTISED_100baseT_Full;
432 case I40E_DEV_ID_20G_KR2:
434 ecmd->supported = SUPPORTED_20000baseKR2_Full;
435 ecmd->advertising = ADVERTISED_20000baseKR2_Full;
438 /* all the rest are 10G/1G */
439 ecmd->supported = SUPPORTED_10000baseT_Full |
440 SUPPORTED_1000baseT_Full;
441 /* Figure out what has been requested */
442 if (hw_link_info->requested_speeds & I40E_LINK_SPEED_10GB)
443 ecmd->advertising |= ADVERTISED_10000baseT_Full;
444 if (hw_link_info->requested_speeds & I40E_LINK_SPEED_1GB)
445 ecmd->advertising |= ADVERTISED_1000baseT_Full;
449 /* With no link speed and duplex are unknown */
450 ethtool_cmd_speed_set(ecmd, SPEED_UNKNOWN);
451 ecmd->duplex = DUPLEX_UNKNOWN;
455 * i40e_get_settings - Get Link Speed and Duplex settings
456 * @netdev: network interface device structure
457 * @ecmd: ethtool command
459 * Reports speed/duplex settings based on media_type
461 static int i40e_get_settings(struct net_device *netdev,
462 struct ethtool_cmd *ecmd)
464 struct i40e_netdev_priv *np = netdev_priv(netdev);
465 struct i40e_pf *pf = np->vsi->back;
466 struct i40e_hw *hw = &pf->hw;
467 struct i40e_link_status *hw_link_info = &hw->phy.link_info;
468 bool link_up = hw_link_info->link_info & I40E_AQ_LINK_UP;
471 i40e_get_settings_link_up(hw, ecmd, netdev);
473 i40e_get_settings_link_down(hw, ecmd);
475 /* Now set the settings that don't rely on link being up/down */
477 /* Set autoneg settings */
478 ecmd->autoneg = ((hw_link_info->an_info & I40E_AQ_AN_COMPLETED) ?
479 AUTONEG_ENABLE : AUTONEG_DISABLE);
481 switch (hw->phy.media_type) {
482 case I40E_MEDIA_TYPE_BACKPLANE:
483 ecmd->supported |= SUPPORTED_Autoneg |
485 ecmd->advertising |= ADVERTISED_Autoneg |
486 ADVERTISED_Backplane;
487 ecmd->port = PORT_NONE;
489 case I40E_MEDIA_TYPE_BASET:
490 ecmd->supported |= SUPPORTED_TP;
491 ecmd->advertising |= ADVERTISED_TP;
492 ecmd->port = PORT_TP;
494 case I40E_MEDIA_TYPE_DA:
495 case I40E_MEDIA_TYPE_CX4:
496 ecmd->supported |= SUPPORTED_FIBRE;
497 ecmd->advertising |= ADVERTISED_FIBRE;
498 ecmd->port = PORT_DA;
500 case I40E_MEDIA_TYPE_FIBER:
501 ecmd->supported |= SUPPORTED_FIBRE;
502 ecmd->port = PORT_FIBRE;
504 case I40E_MEDIA_TYPE_UNKNOWN:
506 ecmd->port = PORT_OTHER;
510 /* Set transceiver */
511 ecmd->transceiver = XCVR_EXTERNAL;
513 /* Set flow control settings */
514 ecmd->supported |= SUPPORTED_Pause;
516 switch (hw->fc.requested_mode) {
518 ecmd->advertising |= ADVERTISED_Pause;
520 case I40E_FC_TX_PAUSE:
521 ecmd->advertising |= ADVERTISED_Asym_Pause;
523 case I40E_FC_RX_PAUSE:
524 ecmd->advertising |= (ADVERTISED_Pause |
525 ADVERTISED_Asym_Pause);
528 ecmd->advertising &= ~(ADVERTISED_Pause |
529 ADVERTISED_Asym_Pause);
537 * i40e_set_settings - Set Speed and Duplex
538 * @netdev: network interface device structure
539 * @ecmd: ethtool command
541 * Set speed/duplex per media_types advertised/forced
543 static int i40e_set_settings(struct net_device *netdev,
544 struct ethtool_cmd *ecmd)
546 struct i40e_netdev_priv *np = netdev_priv(netdev);
547 struct i40e_aq_get_phy_abilities_resp abilities;
548 struct i40e_aq_set_phy_config config;
549 struct i40e_pf *pf = np->vsi->back;
550 struct i40e_vsi *vsi = np->vsi;
551 struct i40e_hw *hw = &pf->hw;
552 struct ethtool_cmd safe_ecmd;
553 i40e_status status = 0;
559 /* Changing port settings is not supported if this isn't the
560 * port's controlling PF
562 if (hw->partition_id != 1) {
563 i40e_partition_setting_complaint(pf);
567 if (vsi != pf->vsi[pf->lan_vsi])
570 if (hw->phy.media_type != I40E_MEDIA_TYPE_BASET &&
571 hw->phy.media_type != I40E_MEDIA_TYPE_FIBER &&
572 hw->phy.media_type != I40E_MEDIA_TYPE_BACKPLANE &&
573 hw->phy.link_info.link_info & I40E_AQ_LINK_UP)
576 /* get our own copy of the bits to check against */
577 memset(&safe_ecmd, 0, sizeof(struct ethtool_cmd));
578 i40e_get_settings(netdev, &safe_ecmd);
580 /* save autoneg and speed out of ecmd */
581 autoneg = ecmd->autoneg;
582 advertise = ecmd->advertising;
584 /* set autoneg and speed back to what they currently are */
585 ecmd->autoneg = safe_ecmd.autoneg;
586 ecmd->advertising = safe_ecmd.advertising;
588 ecmd->cmd = safe_ecmd.cmd;
589 /* If ecmd and safe_ecmd are not the same now, then they are
590 * trying to set something that we do not support
592 if (memcmp(ecmd, &safe_ecmd, sizeof(struct ethtool_cmd)))
595 while (test_bit(__I40E_CONFIG_BUSY, &vsi->state))
596 usleep_range(1000, 2000);
598 /* Get the current phy config */
599 status = i40e_aq_get_phy_capabilities(hw, false, false, &abilities,
604 /* Copy abilities to config in case autoneg is not
607 memset(&config, 0, sizeof(struct i40e_aq_set_phy_config));
608 config.abilities = abilities.abilities;
611 if (autoneg == AUTONEG_ENABLE) {
612 /* If autoneg is not supported, return error */
613 if (!(safe_ecmd.supported & SUPPORTED_Autoneg)) {
614 netdev_info(netdev, "Autoneg not supported on this phy\n");
617 /* If autoneg was not already enabled */
618 if (!(hw->phy.link_info.an_info & I40E_AQ_AN_COMPLETED)) {
619 config.abilities = abilities.abilities |
620 I40E_AQ_PHY_ENABLE_AN;
624 /* If autoneg is supported 10GBASE_T is the only phy that
625 * can disable it, so otherwise return error
627 if (safe_ecmd.supported & SUPPORTED_Autoneg &&
628 hw->phy.link_info.phy_type != I40E_PHY_TYPE_10GBASE_T) {
629 netdev_info(netdev, "Autoneg cannot be disabled on this phy\n");
632 /* If autoneg is currently enabled */
633 if (hw->phy.link_info.an_info & I40E_AQ_AN_COMPLETED) {
634 config.abilities = abilities.abilities &
635 ~I40E_AQ_PHY_ENABLE_AN;
640 if (advertise & ~safe_ecmd.supported)
643 if (advertise & ADVERTISED_100baseT_Full)
644 config.link_speed |= I40E_LINK_SPEED_100MB;
645 if (advertise & ADVERTISED_1000baseT_Full ||
646 advertise & ADVERTISED_1000baseKX_Full)
647 config.link_speed |= I40E_LINK_SPEED_1GB;
648 if (advertise & ADVERTISED_10000baseT_Full ||
649 advertise & ADVERTISED_10000baseKX4_Full ||
650 advertise & ADVERTISED_10000baseKR_Full)
651 config.link_speed |= I40E_LINK_SPEED_10GB;
652 if (advertise & ADVERTISED_20000baseKR2_Full)
653 config.link_speed |= I40E_LINK_SPEED_20GB;
654 if (advertise & ADVERTISED_40000baseKR4_Full ||
655 advertise & ADVERTISED_40000baseCR4_Full ||
656 advertise & ADVERTISED_40000baseSR4_Full ||
657 advertise & ADVERTISED_40000baseLR4_Full)
658 config.link_speed |= I40E_LINK_SPEED_40GB;
660 if (change || (abilities.link_speed != config.link_speed)) {
661 /* copy over the rest of the abilities */
662 config.phy_type = abilities.phy_type;
663 config.eee_capability = abilities.eee_capability;
664 config.eeer = abilities.eeer_val;
665 config.low_power_ctrl = abilities.d3_lpan;
667 /* save the requested speeds */
668 hw->phy.link_info.requested_speeds = config.link_speed;
669 /* set link and auto negotiation so changes take effect */
670 config.abilities |= I40E_AQ_PHY_ENABLE_ATOMIC_LINK;
671 /* If link is up put link down */
672 if (hw->phy.link_info.link_info & I40E_AQ_LINK_UP) {
673 /* Tell the OS link is going down, the link will go
674 * back up when fw says it is ready asynchronously
676 netdev_info(netdev, "PHY settings change requested, NIC Link is going down.\n");
677 netif_carrier_off(netdev);
678 netif_tx_stop_all_queues(netdev);
681 /* make the aq call */
682 status = i40e_aq_set_phy_config(hw, &config, NULL);
684 netdev_info(netdev, "Set phy config failed with error %d.\n",
689 status = i40e_aq_get_link_info(hw, true, NULL, NULL);
691 netdev_info(netdev, "Updating link info failed with error %d\n",
695 netdev_info(netdev, "Nothing changed, exiting without setting anything.\n");
701 static int i40e_nway_reset(struct net_device *netdev)
703 /* restart autonegotiation */
704 struct i40e_netdev_priv *np = netdev_priv(netdev);
705 struct i40e_pf *pf = np->vsi->back;
706 struct i40e_hw *hw = &pf->hw;
707 bool link_up = hw->phy.link_info.link_info & I40E_AQ_LINK_UP;
710 ret = i40e_aq_set_link_restart_an(hw, link_up, NULL);
712 netdev_info(netdev, "link restart failed, aq_err=%d\n",
713 pf->hw.aq.asq_last_status);
721 * i40e_get_pauseparam - Get Flow Control status
722 * Return tx/rx-pause status
724 static void i40e_get_pauseparam(struct net_device *netdev,
725 struct ethtool_pauseparam *pause)
727 struct i40e_netdev_priv *np = netdev_priv(netdev);
728 struct i40e_pf *pf = np->vsi->back;
729 struct i40e_hw *hw = &pf->hw;
730 struct i40e_link_status *hw_link_info = &hw->phy.link_info;
731 struct i40e_dcbx_config *dcbx_cfg = &hw->local_dcbx_config;
734 ((hw_link_info->an_info & I40E_AQ_AN_COMPLETED) ?
735 AUTONEG_ENABLE : AUTONEG_DISABLE);
737 /* PFC enabled so report LFC as off */
738 if (dcbx_cfg->pfc.pfcenable) {
744 if (hw->fc.current_mode == I40E_FC_RX_PAUSE) {
746 } else if (hw->fc.current_mode == I40E_FC_TX_PAUSE) {
748 } else if (hw->fc.current_mode == I40E_FC_FULL) {
755 * i40e_set_pauseparam - Set Flow Control parameter
756 * @netdev: network interface device structure
757 * @pause: return tx/rx flow control status
759 static int i40e_set_pauseparam(struct net_device *netdev,
760 struct ethtool_pauseparam *pause)
762 struct i40e_netdev_priv *np = netdev_priv(netdev);
763 struct i40e_pf *pf = np->vsi->back;
764 struct i40e_vsi *vsi = np->vsi;
765 struct i40e_hw *hw = &pf->hw;
766 struct i40e_link_status *hw_link_info = &hw->phy.link_info;
767 struct i40e_dcbx_config *dcbx_cfg = &hw->local_dcbx_config;
768 bool link_up = hw_link_info->link_info & I40E_AQ_LINK_UP;
773 /* Changing the port's flow control is not supported if this isn't the
774 * port's controlling PF
776 if (hw->partition_id != 1) {
777 i40e_partition_setting_complaint(pf);
781 if (vsi != pf->vsi[pf->lan_vsi])
784 if (pause->autoneg != ((hw_link_info->an_info & I40E_AQ_AN_COMPLETED) ?
785 AUTONEG_ENABLE : AUTONEG_DISABLE)) {
786 netdev_info(netdev, "To change autoneg please use: ethtool -s <dev> autoneg <on|off>\n");
790 /* If we have link and don't have autoneg */
791 if (!test_bit(__I40E_DOWN, &pf->state) &&
792 !(hw_link_info->an_info & I40E_AQ_AN_COMPLETED)) {
793 /* Send message that it might not necessarily work*/
794 netdev_info(netdev, "Autoneg did not complete so changing settings may not result in an actual change.\n");
797 if (dcbx_cfg->pfc.pfcenable) {
799 "Priority flow control enabled. Cannot set link flow control.\n");
803 if (pause->rx_pause && pause->tx_pause)
804 hw->fc.requested_mode = I40E_FC_FULL;
805 else if (pause->rx_pause && !pause->tx_pause)
806 hw->fc.requested_mode = I40E_FC_RX_PAUSE;
807 else if (!pause->rx_pause && pause->tx_pause)
808 hw->fc.requested_mode = I40E_FC_TX_PAUSE;
809 else if (!pause->rx_pause && !pause->tx_pause)
810 hw->fc.requested_mode = I40E_FC_NONE;
814 /* Tell the OS link is going down, the link will go back up when fw
815 * says it is ready asynchronously
817 netdev_info(netdev, "Flow control settings change requested, NIC Link is going down.\n");
818 netif_carrier_off(netdev);
819 netif_tx_stop_all_queues(netdev);
821 /* Set the fc mode and only restart an if link is up*/
822 status = i40e_set_fc(hw, &aq_failures, link_up);
824 if (aq_failures & I40E_SET_FC_AQ_FAIL_GET) {
825 netdev_info(netdev, "Set fc failed on the get_phy_capabilities call with error %d and status %d\n",
826 status, hw->aq.asq_last_status);
829 if (aq_failures & I40E_SET_FC_AQ_FAIL_SET) {
830 netdev_info(netdev, "Set fc failed on the set_phy_config call with error %d and status %d\n",
831 status, hw->aq.asq_last_status);
834 if (aq_failures & I40E_SET_FC_AQ_FAIL_UPDATE) {
835 netdev_info(netdev, "Set fc failed on the get_link_info call with error %d and status %d\n",
836 status, hw->aq.asq_last_status);
840 if (!test_bit(__I40E_DOWN, &pf->state)) {
841 /* Give it a little more time to try to come back */
843 if (!test_bit(__I40E_DOWN, &pf->state))
844 return i40e_nway_reset(netdev);
850 static u32 i40e_get_msglevel(struct net_device *netdev)
852 struct i40e_netdev_priv *np = netdev_priv(netdev);
853 struct i40e_pf *pf = np->vsi->back;
855 return pf->msg_enable;
858 static void i40e_set_msglevel(struct net_device *netdev, u32 data)
860 struct i40e_netdev_priv *np = netdev_priv(netdev);
861 struct i40e_pf *pf = np->vsi->back;
863 if (I40E_DEBUG_USER & data)
864 pf->hw.debug_mask = data;
865 pf->msg_enable = data;
868 static int i40e_get_regs_len(struct net_device *netdev)
873 for (i = 0; i40e_reg_list[i].offset != 0; i++)
874 reg_count += i40e_reg_list[i].elements;
876 return reg_count * sizeof(u32);
879 static void i40e_get_regs(struct net_device *netdev, struct ethtool_regs *regs,
882 struct i40e_netdev_priv *np = netdev_priv(netdev);
883 struct i40e_pf *pf = np->vsi->back;
884 struct i40e_hw *hw = &pf->hw;
889 /* Tell ethtool which driver-version-specific regs output we have.
891 * At some point, if we have ethtool doing special formatting of
892 * this data, it will rely on this version number to know how to
893 * interpret things. Hence, this needs to be updated if/when the
894 * diags register table is changed.
898 /* loop through the diags reg table for what to print */
900 for (i = 0; i40e_reg_list[i].offset != 0; i++) {
901 for (j = 0; j < i40e_reg_list[i].elements; j++) {
902 reg = i40e_reg_list[i].offset
903 + (j * i40e_reg_list[i].stride);
904 reg_buf[ri++] = rd32(hw, reg);
910 static int i40e_get_eeprom(struct net_device *netdev,
911 struct ethtool_eeprom *eeprom, u8 *bytes)
913 struct i40e_netdev_priv *np = netdev_priv(netdev);
914 struct i40e_hw *hw = &np->vsi->back->hw;
915 struct i40e_pf *pf = np->vsi->back;
916 int ret_val = 0, len, offset;
922 #define I40E_NVM_SECTOR_SIZE 4096
923 if (eeprom->len == 0)
926 /* check for NVMUpdate access method */
927 magic = hw->vendor_id | (hw->device_id << 16);
928 if (eeprom->magic && eeprom->magic != magic) {
929 struct i40e_nvm_access *cmd;
932 /* make sure it is the right magic for NVMUpdate */
933 if ((eeprom->magic >> 16) != hw->device_id)
936 cmd = (struct i40e_nvm_access *)eeprom;
937 ret_val = i40e_nvmupd_command(hw, cmd, bytes, &errno);
939 ((hw->aq.asq_last_status != I40E_AQ_RC_EACCES) ||
940 (hw->debug_mask & I40E_DEBUG_NVM)))
941 dev_info(&pf->pdev->dev,
942 "NVMUpdate read failed err=%d status=0x%x errno=%d module=%d offset=0x%x size=%d\n",
943 ret_val, hw->aq.asq_last_status, errno,
944 (u8)(cmd->config & I40E_NVM_MOD_PNT_MASK),
945 cmd->offset, cmd->data_size);
950 /* normal ethtool get_eeprom support */
951 eeprom->magic = hw->vendor_id | (hw->device_id << 16);
953 eeprom_buff = kzalloc(eeprom->len, GFP_KERNEL);
957 ret_val = i40e_acquire_nvm(hw, I40E_RESOURCE_READ);
959 dev_info(&pf->pdev->dev,
960 "Failed Acquiring NVM resource for read err=%d status=0x%x\n",
961 ret_val, hw->aq.asq_last_status);
965 sectors = eeprom->len / I40E_NVM_SECTOR_SIZE;
966 sectors += (eeprom->len % I40E_NVM_SECTOR_SIZE) ? 1 : 0;
967 len = I40E_NVM_SECTOR_SIZE;
969 for (i = 0; i < sectors; i++) {
970 if (i == (sectors - 1)) {
971 len = eeprom->len - (I40E_NVM_SECTOR_SIZE * i);
974 offset = eeprom->offset + (I40E_NVM_SECTOR_SIZE * i),
975 ret_val = i40e_aq_read_nvm(hw, 0x0, offset, len,
976 (u8 *)eeprom_buff + (I40E_NVM_SECTOR_SIZE * i),
978 if (ret_val && hw->aq.asq_last_status == I40E_AQ_RC_EPERM) {
979 dev_info(&pf->pdev->dev,
980 "read NVM failed, invalid offset 0x%x\n",
983 } else if (ret_val &&
984 hw->aq.asq_last_status == I40E_AQ_RC_EACCES) {
985 dev_info(&pf->pdev->dev,
986 "read NVM failed, access, offset 0x%x\n",
989 } else if (ret_val) {
990 dev_info(&pf->pdev->dev,
991 "read NVM failed offset %d err=%d status=0x%x\n",
992 offset, ret_val, hw->aq.asq_last_status);
997 i40e_release_nvm(hw);
998 memcpy(bytes, (u8 *)eeprom_buff, eeprom->len);
1004 static int i40e_get_eeprom_len(struct net_device *netdev)
1006 struct i40e_netdev_priv *np = netdev_priv(netdev);
1007 struct i40e_hw *hw = &np->vsi->back->hw;
1010 val = (rd32(hw, I40E_GLPCI_LBARCTRL)
1011 & I40E_GLPCI_LBARCTRL_FL_SIZE_MASK)
1012 >> I40E_GLPCI_LBARCTRL_FL_SIZE_SHIFT;
1013 /* register returns value in power of 2, 64Kbyte chunks. */
1014 val = (64 * 1024) * (1 << val);
1018 static int i40e_set_eeprom(struct net_device *netdev,
1019 struct ethtool_eeprom *eeprom, u8 *bytes)
1021 struct i40e_netdev_priv *np = netdev_priv(netdev);
1022 struct i40e_hw *hw = &np->vsi->back->hw;
1023 struct i40e_pf *pf = np->vsi->back;
1024 struct i40e_nvm_access *cmd;
1029 /* normal ethtool set_eeprom is not supported */
1030 magic = hw->vendor_id | (hw->device_id << 16);
1031 if (eeprom->magic == magic)
1034 /* check for NVMUpdate access method */
1035 if (!eeprom->magic || (eeprom->magic >> 16) != hw->device_id)
1038 if (test_bit(__I40E_RESET_RECOVERY_PENDING, &pf->state) ||
1039 test_bit(__I40E_RESET_INTR_RECEIVED, &pf->state))
1042 cmd = (struct i40e_nvm_access *)eeprom;
1043 ret_val = i40e_nvmupd_command(hw, cmd, bytes, &errno);
1045 ((hw->aq.asq_last_status != I40E_AQ_RC_EPERM &&
1046 hw->aq.asq_last_status != I40E_AQ_RC_EBUSY) ||
1047 (hw->debug_mask & I40E_DEBUG_NVM)))
1048 dev_info(&pf->pdev->dev,
1049 "NVMUpdate write failed err=%d status=0x%x errno=%d module=%d offset=0x%x size=%d\n",
1050 ret_val, hw->aq.asq_last_status, errno,
1051 (u8)(cmd->config & I40E_NVM_MOD_PNT_MASK),
1052 cmd->offset, cmd->data_size);
1057 static void i40e_get_drvinfo(struct net_device *netdev,
1058 struct ethtool_drvinfo *drvinfo)
1060 struct i40e_netdev_priv *np = netdev_priv(netdev);
1061 struct i40e_vsi *vsi = np->vsi;
1062 struct i40e_pf *pf = vsi->back;
1064 strlcpy(drvinfo->driver, i40e_driver_name, sizeof(drvinfo->driver));
1065 strlcpy(drvinfo->version, i40e_driver_version_str,
1066 sizeof(drvinfo->version));
1067 strlcpy(drvinfo->fw_version, i40e_fw_version_str(&pf->hw),
1068 sizeof(drvinfo->fw_version));
1069 strlcpy(drvinfo->bus_info, pci_name(pf->pdev),
1070 sizeof(drvinfo->bus_info));
1071 drvinfo->n_priv_flags = I40E_PRIV_FLAGS_STR_LEN;
1074 static void i40e_get_ringparam(struct net_device *netdev,
1075 struct ethtool_ringparam *ring)
1077 struct i40e_netdev_priv *np = netdev_priv(netdev);
1078 struct i40e_pf *pf = np->vsi->back;
1079 struct i40e_vsi *vsi = pf->vsi[pf->lan_vsi];
1081 ring->rx_max_pending = I40E_MAX_NUM_DESCRIPTORS;
1082 ring->tx_max_pending = I40E_MAX_NUM_DESCRIPTORS;
1083 ring->rx_mini_max_pending = 0;
1084 ring->rx_jumbo_max_pending = 0;
1085 ring->rx_pending = vsi->rx_rings[0]->count;
1086 ring->tx_pending = vsi->tx_rings[0]->count;
1087 ring->rx_mini_pending = 0;
1088 ring->rx_jumbo_pending = 0;
1091 static int i40e_set_ringparam(struct net_device *netdev,
1092 struct ethtool_ringparam *ring)
1094 struct i40e_ring *tx_rings = NULL, *rx_rings = NULL;
1095 struct i40e_netdev_priv *np = netdev_priv(netdev);
1096 struct i40e_vsi *vsi = np->vsi;
1097 struct i40e_pf *pf = vsi->back;
1098 u32 new_rx_count, new_tx_count;
1101 if ((ring->rx_mini_pending) || (ring->rx_jumbo_pending))
1104 if (ring->tx_pending > I40E_MAX_NUM_DESCRIPTORS ||
1105 ring->tx_pending < I40E_MIN_NUM_DESCRIPTORS ||
1106 ring->rx_pending > I40E_MAX_NUM_DESCRIPTORS ||
1107 ring->rx_pending < I40E_MIN_NUM_DESCRIPTORS) {
1109 "Descriptors requested (Tx: %d / Rx: %d) out of range [%d-%d]\n",
1110 ring->tx_pending, ring->rx_pending,
1111 I40E_MIN_NUM_DESCRIPTORS, I40E_MAX_NUM_DESCRIPTORS);
1115 new_tx_count = ALIGN(ring->tx_pending, I40E_REQ_DESCRIPTOR_MULTIPLE);
1116 new_rx_count = ALIGN(ring->rx_pending, I40E_REQ_DESCRIPTOR_MULTIPLE);
1118 /* if nothing to do return success */
1119 if ((new_tx_count == vsi->tx_rings[0]->count) &&
1120 (new_rx_count == vsi->rx_rings[0]->count))
1123 while (test_and_set_bit(__I40E_CONFIG_BUSY, &pf->state))
1124 usleep_range(1000, 2000);
1126 if (!netif_running(vsi->netdev)) {
1127 /* simple case - set for the next time the netdev is started */
1128 for (i = 0; i < vsi->num_queue_pairs; i++) {
1129 vsi->tx_rings[i]->count = new_tx_count;
1130 vsi->rx_rings[i]->count = new_rx_count;
1135 /* We can't just free everything and then setup again,
1136 * because the ISRs in MSI-X mode get passed pointers
1137 * to the Tx and Rx ring structs.
1140 /* alloc updated Tx resources */
1141 if (new_tx_count != vsi->tx_rings[0]->count) {
1143 "Changing Tx descriptor count from %d to %d.\n",
1144 vsi->tx_rings[0]->count, new_tx_count);
1145 tx_rings = kcalloc(vsi->alloc_queue_pairs,
1146 sizeof(struct i40e_ring), GFP_KERNEL);
1152 for (i = 0; i < vsi->num_queue_pairs; i++) {
1153 /* clone ring and setup updated count */
1154 tx_rings[i] = *vsi->tx_rings[i];
1155 tx_rings[i].count = new_tx_count;
1156 err = i40e_setup_tx_descriptors(&tx_rings[i]);
1160 i40e_free_tx_resources(&tx_rings[i]);
1170 /* alloc updated Rx resources */
1171 if (new_rx_count != vsi->rx_rings[0]->count) {
1173 "Changing Rx descriptor count from %d to %d\n",
1174 vsi->rx_rings[0]->count, new_rx_count);
1175 rx_rings = kcalloc(vsi->alloc_queue_pairs,
1176 sizeof(struct i40e_ring), GFP_KERNEL);
1182 for (i = 0; i < vsi->num_queue_pairs; i++) {
1183 /* clone ring and setup updated count */
1184 rx_rings[i] = *vsi->rx_rings[i];
1185 rx_rings[i].count = new_rx_count;
1186 err = i40e_setup_rx_descriptors(&rx_rings[i]);
1190 i40e_free_rx_resources(&rx_rings[i]);
1200 /* Bring interface down, copy in the new ring info,
1201 * then restore the interface
1206 for (i = 0; i < vsi->num_queue_pairs; i++) {
1207 i40e_free_tx_resources(vsi->tx_rings[i]);
1208 *vsi->tx_rings[i] = tx_rings[i];
1215 for (i = 0; i < vsi->num_queue_pairs; i++) {
1216 i40e_free_rx_resources(vsi->rx_rings[i]);
1217 *vsi->rx_rings[i] = rx_rings[i];
1226 /* error cleanup if the Rx allocations failed after getting Tx */
1228 for (i = 0; i < vsi->num_queue_pairs; i++)
1229 i40e_free_tx_resources(&tx_rings[i]);
1235 clear_bit(__I40E_CONFIG_BUSY, &pf->state);
1240 static int i40e_get_sset_count(struct net_device *netdev, int sset)
1242 struct i40e_netdev_priv *np = netdev_priv(netdev);
1243 struct i40e_vsi *vsi = np->vsi;
1244 struct i40e_pf *pf = vsi->back;
1248 return I40E_TEST_LEN;
1250 if (vsi == pf->vsi[pf->lan_vsi] && pf->hw.partition_id == 1) {
1251 int len = I40E_PF_STATS_LEN(netdev);
1253 if (pf->lan_veb != I40E_NO_VEB)
1254 len += I40E_VEB_STATS_LEN;
1257 return I40E_VSI_STATS_LEN(netdev);
1259 case ETH_SS_PRIV_FLAGS:
1260 return I40E_PRIV_FLAGS_STR_LEN;
1266 static void i40e_get_ethtool_stats(struct net_device *netdev,
1267 struct ethtool_stats *stats, u64 *data)
1269 struct i40e_netdev_priv *np = netdev_priv(netdev);
1270 struct i40e_ring *tx_ring, *rx_ring;
1271 struct i40e_vsi *vsi = np->vsi;
1272 struct i40e_pf *pf = vsi->back;
1276 struct rtnl_link_stats64 *net_stats = i40e_get_vsi_stats_struct(vsi);
1279 i40e_update_stats(vsi);
1281 for (j = 0; j < I40E_NETDEV_STATS_LEN; j++) {
1282 p = (char *)net_stats + i40e_gstrings_net_stats[j].stat_offset;
1283 data[i++] = (i40e_gstrings_net_stats[j].sizeof_stat ==
1284 sizeof(u64)) ? *(u64 *)p : *(u32 *)p;
1286 for (j = 0; j < I40E_MISC_STATS_LEN; j++) {
1287 p = (char *)vsi + i40e_gstrings_misc_stats[j].stat_offset;
1288 data[i++] = (i40e_gstrings_misc_stats[j].sizeof_stat ==
1289 sizeof(u64)) ? *(u64 *)p : *(u32 *)p;
1292 for (j = 0; j < I40E_FCOE_STATS_LEN; j++) {
1293 p = (char *)vsi + i40e_gstrings_fcoe_stats[j].stat_offset;
1294 data[i++] = (i40e_gstrings_fcoe_stats[j].sizeof_stat ==
1295 sizeof(u64)) ? *(u64 *)p : *(u32 *)p;
1299 for (j = 0; j < vsi->num_queue_pairs; j++) {
1300 tx_ring = ACCESS_ONCE(vsi->tx_rings[j]);
1305 /* process Tx ring statistics */
1307 start = u64_stats_fetch_begin_irq(&tx_ring->syncp);
1308 data[i] = tx_ring->stats.packets;
1309 data[i + 1] = tx_ring->stats.bytes;
1310 } while (u64_stats_fetch_retry_irq(&tx_ring->syncp, start));
1313 /* Rx ring is the 2nd half of the queue pair */
1314 rx_ring = &tx_ring[1];
1316 start = u64_stats_fetch_begin_irq(&rx_ring->syncp);
1317 data[i] = rx_ring->stats.packets;
1318 data[i + 1] = rx_ring->stats.bytes;
1319 } while (u64_stats_fetch_retry_irq(&rx_ring->syncp, start));
1323 if (vsi != pf->vsi[pf->lan_vsi] || pf->hw.partition_id != 1)
1326 if (pf->lan_veb != I40E_NO_VEB) {
1327 struct i40e_veb *veb = pf->veb[pf->lan_veb];
1328 for (j = 0; j < I40E_VEB_STATS_LEN; j++) {
1330 p += i40e_gstrings_veb_stats[j].stat_offset;
1331 data[i++] = (i40e_gstrings_veb_stats[j].sizeof_stat ==
1332 sizeof(u64)) ? *(u64 *)p : *(u32 *)p;
1335 for (j = 0; j < I40E_GLOBAL_STATS_LEN; j++) {
1336 p = (char *)pf + i40e_gstrings_stats[j].stat_offset;
1337 data[i++] = (i40e_gstrings_stats[j].sizeof_stat ==
1338 sizeof(u64)) ? *(u64 *)p : *(u32 *)p;
1340 for (j = 0; j < I40E_MAX_USER_PRIORITY; j++) {
1341 data[i++] = pf->stats.priority_xon_tx[j];
1342 data[i++] = pf->stats.priority_xoff_tx[j];
1344 for (j = 0; j < I40E_MAX_USER_PRIORITY; j++) {
1345 data[i++] = pf->stats.priority_xon_rx[j];
1346 data[i++] = pf->stats.priority_xoff_rx[j];
1348 for (j = 0; j < I40E_MAX_USER_PRIORITY; j++)
1349 data[i++] = pf->stats.priority_xon_2_xoff[j];
1352 static void i40e_get_strings(struct net_device *netdev, u32 stringset,
1355 struct i40e_netdev_priv *np = netdev_priv(netdev);
1356 struct i40e_vsi *vsi = np->vsi;
1357 struct i40e_pf *pf = vsi->back;
1358 char *p = (char *)data;
1361 switch (stringset) {
1363 for (i = 0; i < I40E_TEST_LEN; i++) {
1364 memcpy(data, i40e_gstrings_test[i], ETH_GSTRING_LEN);
1365 data += ETH_GSTRING_LEN;
1369 for (i = 0; i < I40E_NETDEV_STATS_LEN; i++) {
1370 snprintf(p, ETH_GSTRING_LEN, "%s",
1371 i40e_gstrings_net_stats[i].stat_string);
1372 p += ETH_GSTRING_LEN;
1374 for (i = 0; i < I40E_MISC_STATS_LEN; i++) {
1375 snprintf(p, ETH_GSTRING_LEN, "%s",
1376 i40e_gstrings_misc_stats[i].stat_string);
1377 p += ETH_GSTRING_LEN;
1380 for (i = 0; i < I40E_FCOE_STATS_LEN; i++) {
1381 snprintf(p, ETH_GSTRING_LEN, "%s",
1382 i40e_gstrings_fcoe_stats[i].stat_string);
1383 p += ETH_GSTRING_LEN;
1386 for (i = 0; i < vsi->num_queue_pairs; i++) {
1387 snprintf(p, ETH_GSTRING_LEN, "tx-%u.tx_packets", i);
1388 p += ETH_GSTRING_LEN;
1389 snprintf(p, ETH_GSTRING_LEN, "tx-%u.tx_bytes", i);
1390 p += ETH_GSTRING_LEN;
1391 snprintf(p, ETH_GSTRING_LEN, "rx-%u.rx_packets", i);
1392 p += ETH_GSTRING_LEN;
1393 snprintf(p, ETH_GSTRING_LEN, "rx-%u.rx_bytes", i);
1394 p += ETH_GSTRING_LEN;
1396 if (vsi != pf->vsi[pf->lan_vsi] || pf->hw.partition_id != 1)
1399 if (pf->lan_veb != I40E_NO_VEB) {
1400 for (i = 0; i < I40E_VEB_STATS_LEN; i++) {
1401 snprintf(p, ETH_GSTRING_LEN, "veb.%s",
1402 i40e_gstrings_veb_stats[i].stat_string);
1403 p += ETH_GSTRING_LEN;
1406 for (i = 0; i < I40E_GLOBAL_STATS_LEN; i++) {
1407 snprintf(p, ETH_GSTRING_LEN, "port.%s",
1408 i40e_gstrings_stats[i].stat_string);
1409 p += ETH_GSTRING_LEN;
1411 for (i = 0; i < I40E_MAX_USER_PRIORITY; i++) {
1412 snprintf(p, ETH_GSTRING_LEN,
1413 "port.tx_priority_%u_xon", i);
1414 p += ETH_GSTRING_LEN;
1415 snprintf(p, ETH_GSTRING_LEN,
1416 "port.tx_priority_%u_xoff", i);
1417 p += ETH_GSTRING_LEN;
1419 for (i = 0; i < I40E_MAX_USER_PRIORITY; i++) {
1420 snprintf(p, ETH_GSTRING_LEN,
1421 "port.rx_priority_%u_xon", i);
1422 p += ETH_GSTRING_LEN;
1423 snprintf(p, ETH_GSTRING_LEN,
1424 "port.rx_priority_%u_xoff", i);
1425 p += ETH_GSTRING_LEN;
1427 for (i = 0; i < I40E_MAX_USER_PRIORITY; i++) {
1428 snprintf(p, ETH_GSTRING_LEN,
1429 "port.rx_priority_%u_xon_2_xoff", i);
1430 p += ETH_GSTRING_LEN;
1432 /* BUG_ON(p - data != I40E_STATS_LEN * ETH_GSTRING_LEN); */
1434 case ETH_SS_PRIV_FLAGS:
1435 for (i = 0; i < I40E_PRIV_FLAGS_STR_LEN; i++) {
1436 memcpy(data, i40e_priv_flags_strings[i],
1438 data += ETH_GSTRING_LEN;
1446 static int i40e_get_ts_info(struct net_device *dev,
1447 struct ethtool_ts_info *info)
1449 struct i40e_pf *pf = i40e_netdev_to_pf(dev);
1451 /* only report HW timestamping if PTP is enabled */
1452 if (!(pf->flags & I40E_FLAG_PTP))
1453 return ethtool_op_get_ts_info(dev, info);
1455 info->so_timestamping = SOF_TIMESTAMPING_TX_SOFTWARE |
1456 SOF_TIMESTAMPING_RX_SOFTWARE |
1457 SOF_TIMESTAMPING_SOFTWARE |
1458 SOF_TIMESTAMPING_TX_HARDWARE |
1459 SOF_TIMESTAMPING_RX_HARDWARE |
1460 SOF_TIMESTAMPING_RAW_HARDWARE;
1463 info->phc_index = ptp_clock_index(pf->ptp_clock);
1465 info->phc_index = -1;
1467 info->tx_types = (1 << HWTSTAMP_TX_OFF) | (1 << HWTSTAMP_TX_ON);
1469 info->rx_filters = (1 << HWTSTAMP_FILTER_NONE) |
1470 (1 << HWTSTAMP_FILTER_PTP_V1_L4_EVENT) |
1471 (1 << HWTSTAMP_FILTER_PTP_V2_EVENT);
1476 static int i40e_link_test(struct net_device *netdev, u64 *data)
1478 struct i40e_netdev_priv *np = netdev_priv(netdev);
1479 struct i40e_pf *pf = np->vsi->back;
1481 netif_info(pf, hw, netdev, "link test\n");
1482 if (i40e_get_link_status(&pf->hw))
1490 static int i40e_reg_test(struct net_device *netdev, u64 *data)
1492 struct i40e_netdev_priv *np = netdev_priv(netdev);
1493 struct i40e_pf *pf = np->vsi->back;
1495 netif_info(pf, hw, netdev, "register test\n");
1496 *data = i40e_diag_reg_test(&pf->hw);
1501 static int i40e_eeprom_test(struct net_device *netdev, u64 *data)
1503 struct i40e_netdev_priv *np = netdev_priv(netdev);
1504 struct i40e_pf *pf = np->vsi->back;
1506 netif_info(pf, hw, netdev, "eeprom test\n");
1507 *data = i40e_diag_eeprom_test(&pf->hw);
1509 /* forcebly clear the NVM Update state machine */
1510 pf->hw.nvmupd_state = I40E_NVMUPD_STATE_INIT;
1515 static int i40e_intr_test(struct net_device *netdev, u64 *data)
1517 struct i40e_netdev_priv *np = netdev_priv(netdev);
1518 struct i40e_pf *pf = np->vsi->back;
1519 u16 swc_old = pf->sw_int_count;
1521 netif_info(pf, hw, netdev, "interrupt test\n");
1522 wr32(&pf->hw, I40E_PFINT_DYN_CTL0,
1523 (I40E_PFINT_DYN_CTL0_INTENA_MASK |
1524 I40E_PFINT_DYN_CTL0_SWINT_TRIG_MASK |
1525 I40E_PFINT_DYN_CTL0_ITR_INDX_MASK |
1526 I40E_PFINT_DYN_CTL0_SW_ITR_INDX_ENA_MASK |
1527 I40E_PFINT_DYN_CTL0_SW_ITR_INDX_MASK));
1528 usleep_range(1000, 2000);
1529 *data = (swc_old == pf->sw_int_count);
1534 static int i40e_loopback_test(struct net_device *netdev, u64 *data)
1536 struct i40e_netdev_priv *np = netdev_priv(netdev);
1537 struct i40e_pf *pf = np->vsi->back;
1539 netif_info(pf, hw, netdev, "loopback test not implemented\n");
1545 static inline bool i40e_active_vfs(struct i40e_pf *pf)
1547 struct i40e_vf *vfs = pf->vf;
1550 for (i = 0; i < pf->num_alloc_vfs; i++)
1551 if (vfs[i].vf_states & I40E_VF_STAT_ACTIVE)
1556 static void i40e_diag_test(struct net_device *netdev,
1557 struct ethtool_test *eth_test, u64 *data)
1559 struct i40e_netdev_priv *np = netdev_priv(netdev);
1560 bool if_running = netif_running(netdev);
1561 struct i40e_pf *pf = np->vsi->back;
1563 if (eth_test->flags == ETH_TEST_FL_OFFLINE) {
1565 netif_info(pf, drv, netdev, "offline testing starting\n");
1567 set_bit(__I40E_TESTING, &pf->state);
1569 if (i40e_active_vfs(pf)) {
1570 dev_warn(&pf->pdev->dev,
1571 "Please take active VFS offline and restart the adapter before running NIC diagnostics\n");
1572 data[I40E_ETH_TEST_REG] = 1;
1573 data[I40E_ETH_TEST_EEPROM] = 1;
1574 data[I40E_ETH_TEST_INTR] = 1;
1575 data[I40E_ETH_TEST_LOOPBACK] = 1;
1576 data[I40E_ETH_TEST_LINK] = 1;
1577 eth_test->flags |= ETH_TEST_FL_FAILED;
1578 clear_bit(__I40E_TESTING, &pf->state);
1582 /* If the device is online then take it offline */
1584 /* indicate we're in test mode */
1587 i40e_do_reset(pf, (1 << __I40E_PF_RESET_REQUESTED));
1589 /* Link test performed before hardware reset
1590 * so autoneg doesn't interfere with test result
1592 if (i40e_link_test(netdev, &data[I40E_ETH_TEST_LINK]))
1593 eth_test->flags |= ETH_TEST_FL_FAILED;
1595 if (i40e_eeprom_test(netdev, &data[I40E_ETH_TEST_EEPROM]))
1596 eth_test->flags |= ETH_TEST_FL_FAILED;
1598 if (i40e_intr_test(netdev, &data[I40E_ETH_TEST_INTR]))
1599 eth_test->flags |= ETH_TEST_FL_FAILED;
1601 if (i40e_loopback_test(netdev, &data[I40E_ETH_TEST_LOOPBACK]))
1602 eth_test->flags |= ETH_TEST_FL_FAILED;
1604 /* run reg test last, a reset is required after it */
1605 if (i40e_reg_test(netdev, &data[I40E_ETH_TEST_REG]))
1606 eth_test->flags |= ETH_TEST_FL_FAILED;
1608 clear_bit(__I40E_TESTING, &pf->state);
1609 i40e_do_reset(pf, (1 << __I40E_PF_RESET_REQUESTED));
1615 netif_info(pf, drv, netdev, "online testing starting\n");
1617 if (i40e_link_test(netdev, &data[I40E_ETH_TEST_LINK]))
1618 eth_test->flags |= ETH_TEST_FL_FAILED;
1620 /* Offline only tests, not run in online; pass by default */
1621 data[I40E_ETH_TEST_REG] = 0;
1622 data[I40E_ETH_TEST_EEPROM] = 0;
1623 data[I40E_ETH_TEST_INTR] = 0;
1624 data[I40E_ETH_TEST_LOOPBACK] = 0;
1629 netif_info(pf, drv, netdev, "testing finished\n");
1632 static void i40e_get_wol(struct net_device *netdev,
1633 struct ethtool_wolinfo *wol)
1635 struct i40e_netdev_priv *np = netdev_priv(netdev);
1636 struct i40e_pf *pf = np->vsi->back;
1637 struct i40e_hw *hw = &pf->hw;
1640 /* NVM bit on means WoL disabled for the port */
1641 i40e_read_nvm_word(hw, I40E_SR_NVM_WAKE_ON_LAN, &wol_nvm_bits);
1642 if ((1 << hw->port) & wol_nvm_bits || hw->partition_id != 1) {
1646 wol->supported = WAKE_MAGIC;
1647 wol->wolopts = (pf->wol_en ? WAKE_MAGIC : 0);
1652 * i40e_set_wol - set the WakeOnLAN configuration
1653 * @netdev: the netdev in question
1654 * @wol: the ethtool WoL setting data
1656 static int i40e_set_wol(struct net_device *netdev, struct ethtool_wolinfo *wol)
1658 struct i40e_netdev_priv *np = netdev_priv(netdev);
1659 struct i40e_pf *pf = np->vsi->back;
1660 struct i40e_vsi *vsi = np->vsi;
1661 struct i40e_hw *hw = &pf->hw;
1664 /* WoL not supported if this isn't the controlling PF on the port */
1665 if (hw->partition_id != 1) {
1666 i40e_partition_setting_complaint(pf);
1670 if (vsi != pf->vsi[pf->lan_vsi])
1673 /* NVM bit on means WoL disabled for the port */
1674 i40e_read_nvm_word(hw, I40E_SR_NVM_WAKE_ON_LAN, &wol_nvm_bits);
1675 if (((1 << hw->port) & wol_nvm_bits))
1678 /* only magic packet is supported */
1679 if (wol->wolopts && (wol->wolopts != WAKE_MAGIC))
1682 /* is this a new value? */
1683 if (pf->wol_en != !!wol->wolopts) {
1684 pf->wol_en = !!wol->wolopts;
1685 device_set_wakeup_enable(&pf->pdev->dev, pf->wol_en);
1691 static int i40e_set_phys_id(struct net_device *netdev,
1692 enum ethtool_phys_id_state state)
1694 struct i40e_netdev_priv *np = netdev_priv(netdev);
1695 struct i40e_pf *pf = np->vsi->back;
1696 struct i40e_hw *hw = &pf->hw;
1700 case ETHTOOL_ID_ACTIVE:
1701 pf->led_status = i40e_led_get(hw);
1704 i40e_led_set(hw, 0xF, false);
1706 case ETHTOOL_ID_OFF:
1707 i40e_led_set(hw, 0x0, false);
1709 case ETHTOOL_ID_INACTIVE:
1710 i40e_led_set(hw, pf->led_status, false);
1719 /* NOTE: i40e hardware uses a conversion factor of 2 for Interrupt
1720 * Throttle Rate (ITR) ie. ITR(1) = 2us ITR(10) = 20 us, and also
1721 * 125us (8000 interrupts per second) == ITR(62)
1724 static int i40e_get_coalesce(struct net_device *netdev,
1725 struct ethtool_coalesce *ec)
1727 struct i40e_netdev_priv *np = netdev_priv(netdev);
1728 struct i40e_vsi *vsi = np->vsi;
1730 ec->tx_max_coalesced_frames_irq = vsi->work_limit;
1731 ec->rx_max_coalesced_frames_irq = vsi->work_limit;
1733 if (ITR_IS_DYNAMIC(vsi->rx_itr_setting))
1734 ec->use_adaptive_rx_coalesce = 1;
1736 if (ITR_IS_DYNAMIC(vsi->tx_itr_setting))
1737 ec->use_adaptive_tx_coalesce = 1;
1739 ec->rx_coalesce_usecs = vsi->rx_itr_setting & ~I40E_ITR_DYNAMIC;
1740 ec->tx_coalesce_usecs = vsi->tx_itr_setting & ~I40E_ITR_DYNAMIC;
1745 static int i40e_set_coalesce(struct net_device *netdev,
1746 struct ethtool_coalesce *ec)
1748 struct i40e_netdev_priv *np = netdev_priv(netdev);
1749 struct i40e_q_vector *q_vector;
1750 struct i40e_vsi *vsi = np->vsi;
1751 struct i40e_pf *pf = vsi->back;
1752 struct i40e_hw *hw = &pf->hw;
1756 if (ec->tx_max_coalesced_frames_irq || ec->rx_max_coalesced_frames_irq)
1757 vsi->work_limit = ec->tx_max_coalesced_frames_irq;
1759 vector = vsi->base_vector;
1760 if ((ec->rx_coalesce_usecs >= (I40E_MIN_ITR << 1)) &&
1761 (ec->rx_coalesce_usecs <= (I40E_MAX_ITR << 1))) {
1762 vsi->rx_itr_setting = ec->rx_coalesce_usecs;
1763 } else if (ec->rx_coalesce_usecs == 0) {
1764 vsi->rx_itr_setting = ec->rx_coalesce_usecs;
1765 if (ec->use_adaptive_rx_coalesce)
1766 netif_info(pf, drv, netdev, "rx-usecs=0, need to disable adaptive-rx for a complete disable\n");
1768 netif_info(pf, drv, netdev, "Invalid value, rx-usecs range is 0-8160\n");
1772 if ((ec->tx_coalesce_usecs >= (I40E_MIN_ITR << 1)) &&
1773 (ec->tx_coalesce_usecs <= (I40E_MAX_ITR << 1))) {
1774 vsi->tx_itr_setting = ec->tx_coalesce_usecs;
1775 } else if (ec->tx_coalesce_usecs == 0) {
1776 vsi->tx_itr_setting = ec->tx_coalesce_usecs;
1777 if (ec->use_adaptive_tx_coalesce)
1778 netif_info(pf, drv, netdev, "tx-usecs=0, need to disable adaptive-tx for a complete disable\n");
1780 netif_info(pf, drv, netdev,
1781 "Invalid value, tx-usecs range is 0-8160\n");
1785 if (ec->use_adaptive_rx_coalesce)
1786 vsi->rx_itr_setting |= I40E_ITR_DYNAMIC;
1788 vsi->rx_itr_setting &= ~I40E_ITR_DYNAMIC;
1790 if (ec->use_adaptive_tx_coalesce)
1791 vsi->tx_itr_setting |= I40E_ITR_DYNAMIC;
1793 vsi->tx_itr_setting &= ~I40E_ITR_DYNAMIC;
1795 for (i = 0; i < vsi->num_q_vectors; i++, vector++) {
1796 q_vector = vsi->q_vectors[i];
1797 q_vector->rx.itr = ITR_TO_REG(vsi->rx_itr_setting);
1798 wr32(hw, I40E_PFINT_ITRN(0, vector - 1), q_vector->rx.itr);
1799 q_vector->tx.itr = ITR_TO_REG(vsi->tx_itr_setting);
1800 wr32(hw, I40E_PFINT_ITRN(1, vector - 1), q_vector->tx.itr);
1808 * i40e_get_rss_hash_opts - Get RSS hash Input Set for each flow type
1809 * @pf: pointer to the physical function struct
1810 * @cmd: ethtool rxnfc command
1812 * Returns Success if the flow is supported, else Invalid Input.
1814 static int i40e_get_rss_hash_opts(struct i40e_pf *pf, struct ethtool_rxnfc *cmd)
1818 if (pf->vsi[pf->lan_vsi]->rxnfc.data != 0) {
1819 cmd->data = pf->vsi[pf->lan_vsi]->rxnfc.data;
1820 cmd->flow_type = pf->vsi[pf->lan_vsi]->rxnfc.flow_type;
1823 /* Report default options for RSS on i40e */
1824 switch (cmd->flow_type) {
1827 cmd->data |= RXH_L4_B_0_1 | RXH_L4_B_2_3;
1828 /* fall through to add IP fields */
1830 case AH_ESP_V4_FLOW:
1834 cmd->data |= RXH_IP_SRC | RXH_IP_DST;
1838 cmd->data |= RXH_L4_B_0_1 | RXH_L4_B_2_3;
1839 /* fall through to add IP fields */
1841 case AH_ESP_V6_FLOW:
1845 cmd->data |= RXH_IP_SRC | RXH_IP_DST;
1855 * i40e_get_ethtool_fdir_all - Populates the rule count of a command
1856 * @pf: Pointer to the physical function struct
1857 * @cmd: The command to get or set Rx flow classification rules
1858 * @rule_locs: Array of used rule locations
1860 * This function populates both the total and actual rule count of
1861 * the ethtool flow classification command
1863 * Returns 0 on success or -EMSGSIZE if entry not found
1865 static int i40e_get_ethtool_fdir_all(struct i40e_pf *pf,
1866 struct ethtool_rxnfc *cmd,
1869 struct i40e_fdir_filter *rule;
1870 struct hlist_node *node2;
1873 /* report total rule count */
1874 cmd->data = i40e_get_fd_cnt_all(pf);
1876 hlist_for_each_entry_safe(rule, node2,
1877 &pf->fdir_filter_list, fdir_node) {
1878 if (cnt == cmd->rule_cnt)
1881 rule_locs[cnt] = rule->fd_id;
1885 cmd->rule_cnt = cnt;
1891 * i40e_get_ethtool_fdir_entry - Look up a filter based on Rx flow
1892 * @pf: Pointer to the physical function struct
1893 * @cmd: The command to get or set Rx flow classification rules
1895 * This function looks up a filter based on the Rx flow classification
1896 * command and fills the flow spec info for it if found
1898 * Returns 0 on success or -EINVAL if filter not found
1900 static int i40e_get_ethtool_fdir_entry(struct i40e_pf *pf,
1901 struct ethtool_rxnfc *cmd)
1903 struct ethtool_rx_flow_spec *fsp =
1904 (struct ethtool_rx_flow_spec *)&cmd->fs;
1905 struct i40e_fdir_filter *rule = NULL;
1906 struct hlist_node *node2;
1908 hlist_for_each_entry_safe(rule, node2,
1909 &pf->fdir_filter_list, fdir_node) {
1910 if (fsp->location <= rule->fd_id)
1914 if (!rule || fsp->location != rule->fd_id)
1917 fsp->flow_type = rule->flow_type;
1918 if (fsp->flow_type == IP_USER_FLOW) {
1919 fsp->h_u.usr_ip4_spec.ip_ver = ETH_RX_NFC_IP4;
1920 fsp->h_u.usr_ip4_spec.proto = 0;
1921 fsp->m_u.usr_ip4_spec.proto = 0;
1924 /* Reverse the src and dest notion, since the HW views them from
1925 * Tx perspective where as the user expects it from Rx filter view.
1927 fsp->h_u.tcp_ip4_spec.psrc = rule->dst_port;
1928 fsp->h_u.tcp_ip4_spec.pdst = rule->src_port;
1929 fsp->h_u.tcp_ip4_spec.ip4src = rule->dst_ip[0];
1930 fsp->h_u.tcp_ip4_spec.ip4dst = rule->src_ip[0];
1932 if (rule->dest_ctl == I40E_FILTER_PROGRAM_DESC_DEST_DROP_PACKET)
1933 fsp->ring_cookie = RX_CLS_FLOW_DISC;
1935 fsp->ring_cookie = rule->q_index;
1937 if (rule->dest_vsi != pf->vsi[pf->lan_vsi]->id) {
1938 struct i40e_vsi *vsi;
1940 vsi = i40e_find_vsi_from_id(pf, rule->dest_vsi);
1941 if (vsi && vsi->type == I40E_VSI_SRIOV) {
1942 fsp->h_ext.data[1] = htonl(vsi->vf_id);
1943 fsp->m_ext.data[1] = htonl(0x1);
1951 * i40e_get_rxnfc - command to get RX flow classification rules
1952 * @netdev: network interface device structure
1953 * @cmd: ethtool rxnfc command
1955 * Returns Success if the command is supported.
1957 static int i40e_get_rxnfc(struct net_device *netdev, struct ethtool_rxnfc *cmd,
1960 struct i40e_netdev_priv *np = netdev_priv(netdev);
1961 struct i40e_vsi *vsi = np->vsi;
1962 struct i40e_pf *pf = vsi->back;
1963 int ret = -EOPNOTSUPP;
1966 case ETHTOOL_GRXRINGS:
1967 cmd->data = vsi->alloc_queue_pairs;
1971 ret = i40e_get_rss_hash_opts(pf, cmd);
1973 case ETHTOOL_GRXCLSRLCNT:
1974 cmd->rule_cnt = pf->fdir_pf_active_filters;
1975 /* report total rule count */
1976 cmd->data = i40e_get_fd_cnt_all(pf);
1979 case ETHTOOL_GRXCLSRULE:
1980 ret = i40e_get_ethtool_fdir_entry(pf, cmd);
1982 case ETHTOOL_GRXCLSRLALL:
1983 ret = i40e_get_ethtool_fdir_all(pf, cmd, rule_locs);
1993 * i40e_set_rss_hash_opt - Enable/Disable flow types for RSS hash
1994 * @pf: pointer to the physical function struct
1995 * @cmd: ethtool rxnfc command
1997 * Returns Success if the flow input set is supported.
1999 static int i40e_set_rss_hash_opt(struct i40e_pf *pf, struct ethtool_rxnfc *nfc)
2001 struct i40e_hw *hw = &pf->hw;
2002 u64 hena = (u64)rd32(hw, I40E_PFQF_HENA(0)) |
2003 ((u64)rd32(hw, I40E_PFQF_HENA(1)) << 32);
2005 /* RSS does not support anything other than hashing
2006 * to queues on src and dst IPs and ports
2008 if (nfc->data & ~(RXH_IP_SRC | RXH_IP_DST |
2009 RXH_L4_B_0_1 | RXH_L4_B_2_3))
2012 /* We need at least the IP SRC and DEST fields for hashing */
2013 if (!(nfc->data & RXH_IP_SRC) ||
2014 !(nfc->data & RXH_IP_DST))
2017 switch (nfc->flow_type) {
2019 switch (nfc->data & (RXH_L4_B_0_1 | RXH_L4_B_2_3)) {
2021 hena &= ~((u64)1 << I40E_FILTER_PCTYPE_NONF_IPV4_TCP);
2023 case (RXH_L4_B_0_1 | RXH_L4_B_2_3):
2024 hena |= ((u64)1 << I40E_FILTER_PCTYPE_NONF_IPV4_TCP);
2031 switch (nfc->data & (RXH_L4_B_0_1 | RXH_L4_B_2_3)) {
2033 hena &= ~((u64)1 << I40E_FILTER_PCTYPE_NONF_IPV6_TCP);
2035 case (RXH_L4_B_0_1 | RXH_L4_B_2_3):
2036 hena |= ((u64)1 << I40E_FILTER_PCTYPE_NONF_IPV6_TCP);
2043 switch (nfc->data & (RXH_L4_B_0_1 | RXH_L4_B_2_3)) {
2045 hena &= ~(((u64)1 << I40E_FILTER_PCTYPE_NONF_IPV4_UDP) |
2046 ((u64)1 << I40E_FILTER_PCTYPE_FRAG_IPV4));
2048 case (RXH_L4_B_0_1 | RXH_L4_B_2_3):
2049 hena |= (((u64)1 << I40E_FILTER_PCTYPE_NONF_IPV4_UDP) |
2050 ((u64)1 << I40E_FILTER_PCTYPE_FRAG_IPV4));
2057 switch (nfc->data & (RXH_L4_B_0_1 | RXH_L4_B_2_3)) {
2059 hena &= ~(((u64)1 << I40E_FILTER_PCTYPE_NONF_IPV6_UDP) |
2060 ((u64)1 << I40E_FILTER_PCTYPE_FRAG_IPV6));
2062 case (RXH_L4_B_0_1 | RXH_L4_B_2_3):
2063 hena |= (((u64)1 << I40E_FILTER_PCTYPE_NONF_IPV6_UDP) |
2064 ((u64)1 << I40E_FILTER_PCTYPE_FRAG_IPV6));
2070 case AH_ESP_V4_FLOW:
2074 if ((nfc->data & RXH_L4_B_0_1) ||
2075 (nfc->data & RXH_L4_B_2_3))
2077 hena |= ((u64)1 << I40E_FILTER_PCTYPE_NONF_IPV4_OTHER);
2079 case AH_ESP_V6_FLOW:
2083 if ((nfc->data & RXH_L4_B_0_1) ||
2084 (nfc->data & RXH_L4_B_2_3))
2086 hena |= ((u64)1 << I40E_FILTER_PCTYPE_NONF_IPV6_OTHER);
2089 hena |= ((u64)1 << I40E_FILTER_PCTYPE_NONF_IPV4_OTHER) |
2090 ((u64)1 << I40E_FILTER_PCTYPE_FRAG_IPV4);
2093 hena |= ((u64)1 << I40E_FILTER_PCTYPE_NONF_IPV6_OTHER) |
2094 ((u64)1 << I40E_FILTER_PCTYPE_FRAG_IPV6);
2100 wr32(hw, I40E_PFQF_HENA(0), (u32)hena);
2101 wr32(hw, I40E_PFQF_HENA(1), (u32)(hena >> 32));
2104 /* Save setting for future output/update */
2105 pf->vsi[pf->lan_vsi]->rxnfc = *nfc;
2111 * i40e_match_fdir_input_set - Match a new filter against an existing one
2112 * @rule: The filter already added
2113 * @input: The new filter to comapre against
2115 * Returns true if the two input set match
2117 static bool i40e_match_fdir_input_set(struct i40e_fdir_filter *rule,
2118 struct i40e_fdir_filter *input)
2120 if ((rule->dst_ip[0] != input->dst_ip[0]) ||
2121 (rule->src_ip[0] != input->src_ip[0]) ||
2122 (rule->dst_port != input->dst_port) ||
2123 (rule->src_port != input->src_port))
2129 * i40e_update_ethtool_fdir_entry - Updates the fdir filter entry
2130 * @vsi: Pointer to the targeted VSI
2131 * @input: The filter to update or NULL to indicate deletion
2132 * @sw_idx: Software index to the filter
2133 * @cmd: The command to get or set Rx flow classification rules
2135 * This function updates (or deletes) a Flow Director entry from
2136 * the hlist of the corresponding PF
2138 * Returns 0 on success
2140 static int i40e_update_ethtool_fdir_entry(struct i40e_vsi *vsi,
2141 struct i40e_fdir_filter *input,
2143 struct ethtool_rxnfc *cmd)
2145 struct i40e_fdir_filter *rule, *parent;
2146 struct i40e_pf *pf = vsi->back;
2147 struct hlist_node *node2;
2153 hlist_for_each_entry_safe(rule, node2,
2154 &pf->fdir_filter_list, fdir_node) {
2155 /* hash found, or no matching entry */
2156 if (rule->fd_id >= sw_idx)
2161 /* if there is an old rule occupying our place remove it */
2162 if (rule && (rule->fd_id == sw_idx)) {
2163 if (input && !i40e_match_fdir_input_set(rule, input))
2164 err = i40e_add_del_fdir(vsi, rule, false);
2166 err = i40e_add_del_fdir(vsi, rule, false);
2167 hlist_del(&rule->fdir_node);
2169 pf->fdir_pf_active_filters--;
2172 /* If no input this was a delete, err should be 0 if a rule was
2173 * successfully found and removed from the list else -EINVAL
2178 /* initialize node and set software index */
2179 INIT_HLIST_NODE(&input->fdir_node);
2181 /* add filter to the list */
2183 hlist_add_behind(&input->fdir_node, &parent->fdir_node);
2185 hlist_add_head(&input->fdir_node,
2186 &pf->fdir_filter_list);
2189 pf->fdir_pf_active_filters++;
2195 * i40e_del_fdir_entry - Deletes a Flow Director filter entry
2196 * @vsi: Pointer to the targeted VSI
2197 * @cmd: The command to get or set Rx flow classification rules
2199 * The function removes a Flow Director filter entry from the
2200 * hlist of the corresponding PF
2202 * Returns 0 on success
2204 static int i40e_del_fdir_entry(struct i40e_vsi *vsi,
2205 struct ethtool_rxnfc *cmd)
2207 struct ethtool_rx_flow_spec *fsp =
2208 (struct ethtool_rx_flow_spec *)&cmd->fs;
2209 struct i40e_pf *pf = vsi->back;
2212 if (test_bit(__I40E_RESET_RECOVERY_PENDING, &pf->state) ||
2213 test_bit(__I40E_RESET_INTR_RECEIVED, &pf->state))
2216 if (test_bit(__I40E_FD_FLUSH_REQUESTED, &pf->state))
2219 ret = i40e_update_ethtool_fdir_entry(vsi, NULL, fsp->location, cmd);
2221 i40e_fdir_check_and_reenable(pf);
2226 * i40e_add_fdir_ethtool - Add/Remove Flow Director filters
2227 * @vsi: pointer to the targeted VSI
2228 * @cmd: command to get or set RX flow classification rules
2230 * Add Flow Director filters for a specific flow spec based on their
2231 * protocol. Returns 0 if the filters were successfully added.
2233 static int i40e_add_fdir_ethtool(struct i40e_vsi *vsi,
2234 struct ethtool_rxnfc *cmd)
2236 struct ethtool_rx_flow_spec *fsp;
2237 struct i40e_fdir_filter *input;
2247 if (!(pf->flags & I40E_FLAG_FD_SB_ENABLED))
2250 if (pf->auto_disable_flags & I40E_FLAG_FD_SB_ENABLED)
2253 if (test_bit(__I40E_RESET_RECOVERY_PENDING, &pf->state) ||
2254 test_bit(__I40E_RESET_INTR_RECEIVED, &pf->state))
2257 if (test_bit(__I40E_FD_FLUSH_REQUESTED, &pf->state))
2260 fsp = (struct ethtool_rx_flow_spec *)&cmd->fs;
2262 if (fsp->location >= (pf->hw.func_caps.fd_filters_best_effort +
2263 pf->hw.func_caps.fd_filters_guaranteed)) {
2267 if ((fsp->ring_cookie != RX_CLS_FLOW_DISC) &&
2268 (fsp->ring_cookie >= vsi->num_queue_pairs))
2271 input = kzalloc(sizeof(*input), GFP_KERNEL);
2276 input->fd_id = fsp->location;
2278 if (fsp->ring_cookie == RX_CLS_FLOW_DISC)
2279 input->dest_ctl = I40E_FILTER_PROGRAM_DESC_DEST_DROP_PACKET;
2282 I40E_FILTER_PROGRAM_DESC_DEST_DIRECT_PACKET_QINDEX;
2284 input->q_index = fsp->ring_cookie;
2285 input->flex_off = 0;
2287 input->dest_vsi = vsi->id;
2288 input->fd_status = I40E_FILTER_PROGRAM_DESC_FD_STATUS_FD_ID;
2289 input->cnt_index = I40E_FD_SB_STAT_IDX(pf->hw.pf_id);
2290 input->flow_type = fsp->flow_type;
2291 input->ip4_proto = fsp->h_u.usr_ip4_spec.proto;
2293 /* Reverse the src and dest notion, since the HW expects them to be from
2294 * Tx perspective where as the input from user is from Rx filter view.
2296 input->dst_port = fsp->h_u.tcp_ip4_spec.psrc;
2297 input->src_port = fsp->h_u.tcp_ip4_spec.pdst;
2298 input->dst_ip[0] = fsp->h_u.tcp_ip4_spec.ip4src;
2299 input->src_ip[0] = fsp->h_u.tcp_ip4_spec.ip4dst;
2301 if (ntohl(fsp->m_ext.data[1])) {
2302 if (ntohl(fsp->h_ext.data[1]) >= pf->num_alloc_vfs) {
2303 netif_info(pf, drv, vsi->netdev, "Invalid VF id\n");
2306 vf_id = ntohl(fsp->h_ext.data[1]);
2307 /* Find vsi id from vf id and override dest vsi */
2308 input->dest_vsi = pf->vf[vf_id].lan_vsi_id;
2309 if (input->q_index >= pf->vf[vf_id].num_queue_pairs) {
2310 netif_info(pf, drv, vsi->netdev, "Invalid queue id\n");
2315 ret = i40e_add_del_fdir(vsi, input, true);
2320 i40e_update_ethtool_fdir_entry(vsi, input, fsp->location, NULL);
2326 * i40e_set_rxnfc - command to set RX flow classification rules
2327 * @netdev: network interface device structure
2328 * @cmd: ethtool rxnfc command
2330 * Returns Success if the command is supported.
2332 static int i40e_set_rxnfc(struct net_device *netdev, struct ethtool_rxnfc *cmd)
2334 struct i40e_netdev_priv *np = netdev_priv(netdev);
2335 struct i40e_vsi *vsi = np->vsi;
2336 struct i40e_pf *pf = vsi->back;
2337 int ret = -EOPNOTSUPP;
2341 ret = i40e_set_rss_hash_opt(pf, cmd);
2343 case ETHTOOL_SRXCLSRLINS:
2344 ret = i40e_add_fdir_ethtool(vsi, cmd);
2346 case ETHTOOL_SRXCLSRLDEL:
2347 ret = i40e_del_fdir_entry(vsi, cmd);
2357 * i40e_max_channels - get Max number of combined channels supported
2360 static unsigned int i40e_max_channels(struct i40e_vsi *vsi)
2362 /* TODO: This code assumes DCB and FD is disabled for now. */
2363 return vsi->alloc_queue_pairs;
2367 * i40e_get_channels - Get the current channels enabled and max supported etc.
2368 * @netdev: network interface device structure
2369 * @ch: ethtool channels structure
2371 * We don't support separate tx and rx queues as channels. The other count
2372 * represents how many queues are being used for control. max_combined counts
2373 * how many queue pairs we can support. They may not be mapped 1 to 1 with
2374 * q_vectors since we support a lot more queue pairs than q_vectors.
2376 static void i40e_get_channels(struct net_device *dev,
2377 struct ethtool_channels *ch)
2379 struct i40e_netdev_priv *np = netdev_priv(dev);
2380 struct i40e_vsi *vsi = np->vsi;
2381 struct i40e_pf *pf = vsi->back;
2383 /* report maximum channels */
2384 ch->max_combined = i40e_max_channels(vsi);
2386 /* report info for other vector */
2387 ch->other_count = (pf->flags & I40E_FLAG_FD_SB_ENABLED) ? 1 : 0;
2388 ch->max_other = ch->other_count;
2390 /* Note: This code assumes DCB is disabled for now. */
2391 ch->combined_count = vsi->num_queue_pairs;
2395 * i40e_set_channels - Set the new channels count.
2396 * @netdev: network interface device structure
2397 * @ch: ethtool channels structure
2399 * The new channels count may not be the same as requested by the user
2400 * since it gets rounded down to a power of 2 value.
2402 static int i40e_set_channels(struct net_device *dev,
2403 struct ethtool_channels *ch)
2405 struct i40e_netdev_priv *np = netdev_priv(dev);
2406 unsigned int count = ch->combined_count;
2407 struct i40e_vsi *vsi = np->vsi;
2408 struct i40e_pf *pf = vsi->back;
2411 /* We do not support setting channels for any other VSI at present */
2412 if (vsi->type != I40E_VSI_MAIN)
2415 /* verify they are not requesting separate vectors */
2416 if (!count || ch->rx_count || ch->tx_count)
2419 /* verify other_count has not changed */
2420 if (ch->other_count != ((pf->flags & I40E_FLAG_FD_SB_ENABLED) ? 1 : 0))
2423 /* verify the number of channels does not exceed hardware limits */
2424 if (count > i40e_max_channels(vsi))
2427 /* update feature limits from largest to smallest supported values */
2428 /* TODO: Flow director limit, DCB etc */
2430 /* use rss_reconfig to rebuild with new queue count and update traffic
2431 * class queue mapping
2433 new_count = i40e_reconfig_rss_queues(pf, count);
2440 #define I40E_HLUT_ARRAY_SIZE ((I40E_PFQF_HLUT_MAX_INDEX + 1) * 4)
2442 * i40e_get_rxfh_key_size - get the RSS hash key size
2443 * @netdev: network interface device structure
2445 * Returns the table size.
2447 static u32 i40e_get_rxfh_key_size(struct net_device *netdev)
2449 return I40E_HKEY_ARRAY_SIZE;
2453 * i40e_get_rxfh_indir_size - get the rx flow hash indirection table size
2454 * @netdev: network interface device structure
2456 * Returns the table size.
2458 static u32 i40e_get_rxfh_indir_size(struct net_device *netdev)
2460 return I40E_HLUT_ARRAY_SIZE;
2463 static int i40e_get_rxfh(struct net_device *netdev, u32 *indir, u8 *key,
2466 struct i40e_netdev_priv *np = netdev_priv(netdev);
2467 struct i40e_vsi *vsi = np->vsi;
2468 struct i40e_pf *pf = vsi->back;
2469 struct i40e_hw *hw = &pf->hw;
2474 *hfunc = ETH_RSS_HASH_TOP;
2479 for (i = 0, j = 0; i <= I40E_PFQF_HLUT_MAX_INDEX; i++) {
2480 reg_val = rd32(hw, I40E_PFQF_HLUT(i));
2481 indir[j++] = reg_val & 0xff;
2482 indir[j++] = (reg_val >> 8) & 0xff;
2483 indir[j++] = (reg_val >> 16) & 0xff;
2484 indir[j++] = (reg_val >> 24) & 0xff;
2488 for (i = 0, j = 0; i <= I40E_PFQF_HKEY_MAX_INDEX; i++) {
2489 reg_val = rd32(hw, I40E_PFQF_HKEY(i));
2490 key[j++] = (u8)(reg_val & 0xff);
2491 key[j++] = (u8)((reg_val >> 8) & 0xff);
2492 key[j++] = (u8)((reg_val >> 16) & 0xff);
2493 key[j++] = (u8)((reg_val >> 24) & 0xff);
2500 * i40e_set_rxfh - set the rx flow hash indirection table
2501 * @netdev: network interface device structure
2502 * @indir: indirection table
2505 * Returns -EINVAL if the table specifies an inavlid queue id, otherwise
2506 * returns 0 after programming the table.
2508 static int i40e_set_rxfh(struct net_device *netdev, const u32 *indir,
2509 const u8 *key, const u8 hfunc)
2511 struct i40e_netdev_priv *np = netdev_priv(netdev);
2512 struct i40e_vsi *vsi = np->vsi;
2513 struct i40e_pf *pf = vsi->back;
2514 struct i40e_hw *hw = &pf->hw;
2518 if (hfunc != ETH_RSS_HASH_NO_CHANGE && hfunc != ETH_RSS_HASH_TOP)
2524 for (i = 0, j = 0; i <= I40E_PFQF_HLUT_MAX_INDEX; i++) {
2525 reg_val = indir[j++];
2526 reg_val |= indir[j++] << 8;
2527 reg_val |= indir[j++] << 16;
2528 reg_val |= indir[j++] << 24;
2529 wr32(hw, I40E_PFQF_HLUT(i), reg_val);
2533 for (i = 0, j = 0; i <= I40E_PFQF_HKEY_MAX_INDEX; i++) {
2535 reg_val |= key[j++] << 8;
2536 reg_val |= key[j++] << 16;
2537 reg_val |= key[j++] << 24;
2538 wr32(hw, I40E_PFQF_HKEY(i), reg_val);
2545 * i40e_get_priv_flags - report device private flags
2546 * @dev: network interface device structure
2548 * The get string set count and the string set should be matched for each
2549 * flag returned. Add new strings for each flag to the i40e_priv_flags_strings
2552 * Returns a u32 bitmap of flags.
2554 static u32 i40e_get_priv_flags(struct net_device *dev)
2556 struct i40e_netdev_priv *np = netdev_priv(dev);
2557 struct i40e_vsi *vsi = np->vsi;
2558 struct i40e_pf *pf = vsi->back;
2561 ret_flags |= pf->hw.func_caps.npar_enable ?
2562 I40E_PRIV_FLAGS_NPAR_FLAG : 0;
2567 static const struct ethtool_ops i40e_ethtool_ops = {
2568 .get_settings = i40e_get_settings,
2569 .set_settings = i40e_set_settings,
2570 .get_drvinfo = i40e_get_drvinfo,
2571 .get_regs_len = i40e_get_regs_len,
2572 .get_regs = i40e_get_regs,
2573 .nway_reset = i40e_nway_reset,
2574 .get_link = ethtool_op_get_link,
2575 .get_wol = i40e_get_wol,
2576 .set_wol = i40e_set_wol,
2577 .set_eeprom = i40e_set_eeprom,
2578 .get_eeprom_len = i40e_get_eeprom_len,
2579 .get_eeprom = i40e_get_eeprom,
2580 .get_ringparam = i40e_get_ringparam,
2581 .set_ringparam = i40e_set_ringparam,
2582 .get_pauseparam = i40e_get_pauseparam,
2583 .set_pauseparam = i40e_set_pauseparam,
2584 .get_msglevel = i40e_get_msglevel,
2585 .set_msglevel = i40e_set_msglevel,
2586 .get_rxnfc = i40e_get_rxnfc,
2587 .set_rxnfc = i40e_set_rxnfc,
2588 .self_test = i40e_diag_test,
2589 .get_strings = i40e_get_strings,
2590 .set_phys_id = i40e_set_phys_id,
2591 .get_sset_count = i40e_get_sset_count,
2592 .get_ethtool_stats = i40e_get_ethtool_stats,
2593 .get_coalesce = i40e_get_coalesce,
2594 .set_coalesce = i40e_set_coalesce,
2595 .get_rxfh_key_size = i40e_get_rxfh_key_size,
2596 .get_rxfh_indir_size = i40e_get_rxfh_indir_size,
2597 .get_rxfh = i40e_get_rxfh,
2598 .set_rxfh = i40e_set_rxfh,
2599 .get_channels = i40e_get_channels,
2600 .set_channels = i40e_set_channels,
2601 .get_ts_info = i40e_get_ts_info,
2602 .get_priv_flags = i40e_get_priv_flags,
2605 void i40e_set_ethtool_ops(struct net_device *netdev)
2607 netdev->ethtool_ops = &i40e_ethtool_ops;