i40e: use priv flags to control flow director
[deliverable/linux.git] / drivers / net / ethernet / intel / i40e / i40e_ethtool.c
1 /*******************************************************************************
2 *
3 * Intel Ethernet Controller XL710 Family Linux Driver
4 * Copyright(c) 2013 - 2015 Intel Corporation.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms and conditions of the GNU General Public License,
8 * version 2, as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program. If not, see <http://www.gnu.org/licenses/>.
17 *
18 * The full GNU General Public License is included in this distribution in
19 * the file called "COPYING".
20 *
21 * Contact Information:
22 * e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
23 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
24 *
25 ******************************************************************************/
26
27 /* ethtool support for i40e */
28
29 #include "i40e.h"
30 #include "i40e_diag.h"
31
32 struct i40e_stats {
33 char stat_string[ETH_GSTRING_LEN];
34 int sizeof_stat;
35 int stat_offset;
36 };
37
38 #define I40E_STAT(_type, _name, _stat) { \
39 .stat_string = _name, \
40 .sizeof_stat = FIELD_SIZEOF(_type, _stat), \
41 .stat_offset = offsetof(_type, _stat) \
42 }
43
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)
52
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),
65 };
66
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),
80 };
81
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),
90 I40E_VSI_STAT("tx_linearize", tx_linearize),
91 };
92
93 static int i40e_add_fdir_ethtool(struct i40e_vsi *vsi,
94 struct ethtool_rxnfc *cmd);
95
96 /* These PF_STATs might look like duplicates of some NETDEV_STATs,
97 * but they are separate. This device supports Virtualization, and
98 * as such might have several netdevs supporting VMDq and FCoE going
99 * through a single port. The NETDEV_STATs are for individual netdevs
100 * seen at the top of the stack, and the PF_STATs are for the physical
101 * function at the bottom of the stack hosting those netdevs.
102 *
103 * The PF_STATs are appended to the netdev stats only when ethtool -S
104 * is queried on the base PF netdev, not on the VMDq or FCoE netdev.
105 */
106 static struct i40e_stats i40e_gstrings_stats[] = {
107 I40E_PF_STAT("rx_bytes", stats.eth.rx_bytes),
108 I40E_PF_STAT("tx_bytes", stats.eth.tx_bytes),
109 I40E_PF_STAT("rx_unicast", stats.eth.rx_unicast),
110 I40E_PF_STAT("tx_unicast", stats.eth.tx_unicast),
111 I40E_PF_STAT("rx_multicast", stats.eth.rx_multicast),
112 I40E_PF_STAT("tx_multicast", stats.eth.tx_multicast),
113 I40E_PF_STAT("rx_broadcast", stats.eth.rx_broadcast),
114 I40E_PF_STAT("tx_broadcast", stats.eth.tx_broadcast),
115 I40E_PF_STAT("tx_errors", stats.eth.tx_errors),
116 I40E_PF_STAT("rx_dropped", stats.eth.rx_discards),
117 I40E_PF_STAT("tx_dropped_link_down", stats.tx_dropped_link_down),
118 I40E_PF_STAT("rx_crc_errors", stats.crc_errors),
119 I40E_PF_STAT("illegal_bytes", stats.illegal_bytes),
120 I40E_PF_STAT("mac_local_faults", stats.mac_local_faults),
121 I40E_PF_STAT("mac_remote_faults", stats.mac_remote_faults),
122 I40E_PF_STAT("tx_timeout", tx_timeout_count),
123 I40E_PF_STAT("rx_csum_bad", hw_csum_rx_error),
124 I40E_PF_STAT("rx_length_errors", stats.rx_length_errors),
125 I40E_PF_STAT("link_xon_rx", stats.link_xon_rx),
126 I40E_PF_STAT("link_xoff_rx", stats.link_xoff_rx),
127 I40E_PF_STAT("link_xon_tx", stats.link_xon_tx),
128 I40E_PF_STAT("link_xoff_tx", stats.link_xoff_tx),
129 I40E_PF_STAT("rx_size_64", stats.rx_size_64),
130 I40E_PF_STAT("rx_size_127", stats.rx_size_127),
131 I40E_PF_STAT("rx_size_255", stats.rx_size_255),
132 I40E_PF_STAT("rx_size_511", stats.rx_size_511),
133 I40E_PF_STAT("rx_size_1023", stats.rx_size_1023),
134 I40E_PF_STAT("rx_size_1522", stats.rx_size_1522),
135 I40E_PF_STAT("rx_size_big", stats.rx_size_big),
136 I40E_PF_STAT("tx_size_64", stats.tx_size_64),
137 I40E_PF_STAT("tx_size_127", stats.tx_size_127),
138 I40E_PF_STAT("tx_size_255", stats.tx_size_255),
139 I40E_PF_STAT("tx_size_511", stats.tx_size_511),
140 I40E_PF_STAT("tx_size_1023", stats.tx_size_1023),
141 I40E_PF_STAT("tx_size_1522", stats.tx_size_1522),
142 I40E_PF_STAT("tx_size_big", stats.tx_size_big),
143 I40E_PF_STAT("rx_undersize", stats.rx_undersize),
144 I40E_PF_STAT("rx_fragments", stats.rx_fragments),
145 I40E_PF_STAT("rx_oversize", stats.rx_oversize),
146 I40E_PF_STAT("rx_jabber", stats.rx_jabber),
147 I40E_PF_STAT("VF_admin_queue_requests", vf_aq_requests),
148 I40E_PF_STAT("rx_hwtstamp_cleared", rx_hwtstamp_cleared),
149 I40E_PF_STAT("fdir_flush_cnt", fd_flush_cnt),
150 I40E_PF_STAT("fdir_atr_match", stats.fd_atr_match),
151 I40E_PF_STAT("fdir_atr_tunnel_match", stats.fd_atr_tunnel_match),
152 I40E_PF_STAT("fdir_atr_status", stats.fd_atr_status),
153 I40E_PF_STAT("fdir_sb_match", stats.fd_sb_match),
154 I40E_PF_STAT("fdir_sb_status", stats.fd_sb_status),
155
156 /* LPI stats */
157 I40E_PF_STAT("tx_lpi_status", stats.tx_lpi_status),
158 I40E_PF_STAT("rx_lpi_status", stats.rx_lpi_status),
159 I40E_PF_STAT("tx_lpi_count", stats.tx_lpi_count),
160 I40E_PF_STAT("rx_lpi_count", stats.rx_lpi_count),
161 };
162
163 #ifdef I40E_FCOE
164 static const struct i40e_stats i40e_gstrings_fcoe_stats[] = {
165 I40E_VSI_STAT("fcoe_bad_fccrc", fcoe_stats.fcoe_bad_fccrc),
166 I40E_VSI_STAT("rx_fcoe_dropped", fcoe_stats.rx_fcoe_dropped),
167 I40E_VSI_STAT("rx_fcoe_packets", fcoe_stats.rx_fcoe_packets),
168 I40E_VSI_STAT("rx_fcoe_dwords", fcoe_stats.rx_fcoe_dwords),
169 I40E_VSI_STAT("fcoe_ddp_count", fcoe_stats.fcoe_ddp_count),
170 I40E_VSI_STAT("fcoe_last_error", fcoe_stats.fcoe_last_error),
171 I40E_VSI_STAT("tx_fcoe_packets", fcoe_stats.tx_fcoe_packets),
172 I40E_VSI_STAT("tx_fcoe_dwords", fcoe_stats.tx_fcoe_dwords),
173 };
174
175 #endif /* I40E_FCOE */
176 #define I40E_QUEUE_STATS_LEN(n) \
177 (((struct i40e_netdev_priv *)netdev_priv((n)))->vsi->num_queue_pairs \
178 * 2 /* Tx and Rx together */ \
179 * (sizeof(struct i40e_queue_stats) / sizeof(u64)))
180 #define I40E_GLOBAL_STATS_LEN ARRAY_SIZE(i40e_gstrings_stats)
181 #define I40E_NETDEV_STATS_LEN ARRAY_SIZE(i40e_gstrings_net_stats)
182 #define I40E_MISC_STATS_LEN ARRAY_SIZE(i40e_gstrings_misc_stats)
183 #ifdef I40E_FCOE
184 #define I40E_FCOE_STATS_LEN ARRAY_SIZE(i40e_gstrings_fcoe_stats)
185 #define I40E_VSI_STATS_LEN(n) (I40E_NETDEV_STATS_LEN + \
186 I40E_FCOE_STATS_LEN + \
187 I40E_MISC_STATS_LEN + \
188 I40E_QUEUE_STATS_LEN((n)))
189 #else
190 #define I40E_VSI_STATS_LEN(n) (I40E_NETDEV_STATS_LEN + \
191 I40E_MISC_STATS_LEN + \
192 I40E_QUEUE_STATS_LEN((n)))
193 #endif /* I40E_FCOE */
194 #define I40E_PFC_STATS_LEN ( \
195 (FIELD_SIZEOF(struct i40e_pf, stats.priority_xoff_rx) + \
196 FIELD_SIZEOF(struct i40e_pf, stats.priority_xon_rx) + \
197 FIELD_SIZEOF(struct i40e_pf, stats.priority_xoff_tx) + \
198 FIELD_SIZEOF(struct i40e_pf, stats.priority_xon_tx) + \
199 FIELD_SIZEOF(struct i40e_pf, stats.priority_xon_2_xoff)) \
200 / sizeof(u64))
201 #define I40E_VEB_TC_STATS_LEN ( \
202 (FIELD_SIZEOF(struct i40e_veb, tc_stats.tc_rx_packets) + \
203 FIELD_SIZEOF(struct i40e_veb, tc_stats.tc_rx_bytes) + \
204 FIELD_SIZEOF(struct i40e_veb, tc_stats.tc_tx_packets) + \
205 FIELD_SIZEOF(struct i40e_veb, tc_stats.tc_tx_bytes)) \
206 / sizeof(u64))
207 #define I40E_VEB_STATS_LEN ARRAY_SIZE(i40e_gstrings_veb_stats)
208 #define I40E_VEB_STATS_TOTAL (I40E_VEB_STATS_LEN + I40E_VEB_TC_STATS_LEN)
209 #define I40E_PF_STATS_LEN(n) (I40E_GLOBAL_STATS_LEN + \
210 I40E_PFC_STATS_LEN + \
211 I40E_VSI_STATS_LEN((n)))
212
213 enum i40e_ethtool_test_id {
214 I40E_ETH_TEST_REG = 0,
215 I40E_ETH_TEST_EEPROM,
216 I40E_ETH_TEST_INTR,
217 I40E_ETH_TEST_LOOPBACK,
218 I40E_ETH_TEST_LINK,
219 };
220
221 static const char i40e_gstrings_test[][ETH_GSTRING_LEN] = {
222 "Register test (offline)",
223 "Eeprom test (offline)",
224 "Interrupt test (offline)",
225 "Loopback test (offline)",
226 "Link test (on/offline)"
227 };
228
229 #define I40E_TEST_LEN (sizeof(i40e_gstrings_test) / ETH_GSTRING_LEN)
230
231 static const char i40e_priv_flags_strings[][ETH_GSTRING_LEN] = {
232 "NPAR",
233 "LinkPolling",
234 "flow-director-atr",
235 };
236
237 #define I40E_PRIV_FLAGS_STR_LEN ARRAY_SIZE(i40e_priv_flags_strings)
238
239 /**
240 * i40e_partition_setting_complaint - generic complaint for MFP restriction
241 * @pf: the PF struct
242 **/
243 static void i40e_partition_setting_complaint(struct i40e_pf *pf)
244 {
245 dev_info(&pf->pdev->dev,
246 "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");
247 }
248
249 /**
250 * i40e_get_settings_link_up - Get the Link settings for when link is up
251 * @hw: hw structure
252 * @ecmd: ethtool command to fill in
253 * @netdev: network interface device structure
254 *
255 **/
256 static void i40e_get_settings_link_up(struct i40e_hw *hw,
257 struct ethtool_cmd *ecmd,
258 struct net_device *netdev)
259 {
260 struct i40e_link_status *hw_link_info = &hw->phy.link_info;
261 u32 link_speed = hw_link_info->link_speed;
262
263 /* Initialize supported and advertised settings based on phy settings */
264 switch (hw_link_info->phy_type) {
265 case I40E_PHY_TYPE_40GBASE_CR4:
266 case I40E_PHY_TYPE_40GBASE_CR4_CU:
267 ecmd->supported = SUPPORTED_Autoneg |
268 SUPPORTED_40000baseCR4_Full;
269 ecmd->advertising = ADVERTISED_Autoneg |
270 ADVERTISED_40000baseCR4_Full;
271 break;
272 case I40E_PHY_TYPE_XLAUI:
273 case I40E_PHY_TYPE_XLPPI:
274 case I40E_PHY_TYPE_40GBASE_AOC:
275 ecmd->supported = SUPPORTED_40000baseCR4_Full;
276 break;
277 case I40E_PHY_TYPE_40GBASE_SR4:
278 ecmd->supported = SUPPORTED_40000baseSR4_Full;
279 break;
280 case I40E_PHY_TYPE_40GBASE_LR4:
281 ecmd->supported = SUPPORTED_40000baseLR4_Full;
282 break;
283 case I40E_PHY_TYPE_10GBASE_SR:
284 case I40E_PHY_TYPE_10GBASE_LR:
285 case I40E_PHY_TYPE_1000BASE_SX:
286 case I40E_PHY_TYPE_1000BASE_LX:
287 ecmd->supported = SUPPORTED_10000baseT_Full;
288 if (hw_link_info->module_type[2] &
289 I40E_MODULE_TYPE_1000BASE_SX ||
290 hw_link_info->module_type[2] &
291 I40E_MODULE_TYPE_1000BASE_LX) {
292 ecmd->supported |= SUPPORTED_1000baseT_Full;
293 if (hw_link_info->requested_speeds &
294 I40E_LINK_SPEED_1GB)
295 ecmd->advertising |= ADVERTISED_1000baseT_Full;
296 }
297 if (hw_link_info->requested_speeds & I40E_LINK_SPEED_10GB)
298 ecmd->advertising |= ADVERTISED_10000baseT_Full;
299 break;
300 case I40E_PHY_TYPE_10GBASE_T:
301 case I40E_PHY_TYPE_1000BASE_T:
302 case I40E_PHY_TYPE_100BASE_TX:
303 ecmd->supported = SUPPORTED_Autoneg |
304 SUPPORTED_10000baseT_Full |
305 SUPPORTED_1000baseT_Full |
306 SUPPORTED_100baseT_Full;
307 ecmd->advertising = ADVERTISED_Autoneg;
308 if (hw_link_info->requested_speeds & I40E_LINK_SPEED_10GB)
309 ecmd->advertising |= ADVERTISED_10000baseT_Full;
310 if (hw_link_info->requested_speeds & I40E_LINK_SPEED_1GB)
311 ecmd->advertising |= ADVERTISED_1000baseT_Full;
312 if (hw_link_info->requested_speeds & I40E_LINK_SPEED_100MB)
313 ecmd->advertising |= ADVERTISED_100baseT_Full;
314 break;
315 case I40E_PHY_TYPE_10GBASE_CR1_CU:
316 case I40E_PHY_TYPE_10GBASE_CR1:
317 ecmd->supported = SUPPORTED_Autoneg |
318 SUPPORTED_10000baseT_Full;
319 ecmd->advertising = ADVERTISED_Autoneg |
320 ADVERTISED_10000baseT_Full;
321 break;
322 case I40E_PHY_TYPE_XAUI:
323 case I40E_PHY_TYPE_XFI:
324 case I40E_PHY_TYPE_SFI:
325 case I40E_PHY_TYPE_10GBASE_SFPP_CU:
326 case I40E_PHY_TYPE_10GBASE_AOC:
327 ecmd->supported = SUPPORTED_10000baseT_Full;
328 break;
329 case I40E_PHY_TYPE_SGMII:
330 ecmd->supported = SUPPORTED_Autoneg |
331 SUPPORTED_1000baseT_Full |
332 SUPPORTED_100baseT_Full;
333 if (hw_link_info->requested_speeds & I40E_LINK_SPEED_1GB)
334 ecmd->advertising |= ADVERTISED_1000baseT_Full;
335 if (hw_link_info->requested_speeds & I40E_LINK_SPEED_100MB)
336 ecmd->advertising |= ADVERTISED_100baseT_Full;
337 break;
338 /* Backplane is set based on supported phy types in get_settings
339 * so don't set anything here but don't warn either
340 */
341 case I40E_PHY_TYPE_40GBASE_KR4:
342 case I40E_PHY_TYPE_20GBASE_KR2:
343 case I40E_PHY_TYPE_10GBASE_KR:
344 case I40E_PHY_TYPE_10GBASE_KX4:
345 case I40E_PHY_TYPE_1000BASE_KX:
346 break;
347 default:
348 /* if we got here and link is up something bad is afoot */
349 netdev_info(netdev, "WARNING: Link is up but PHY type 0x%x is not recognized.\n",
350 hw_link_info->phy_type);
351 }
352
353 /* Set speed and duplex */
354 switch (link_speed) {
355 case I40E_LINK_SPEED_40GB:
356 ethtool_cmd_speed_set(ecmd, SPEED_40000);
357 break;
358 case I40E_LINK_SPEED_20GB:
359 ethtool_cmd_speed_set(ecmd, SPEED_20000);
360 break;
361 case I40E_LINK_SPEED_10GB:
362 ethtool_cmd_speed_set(ecmd, SPEED_10000);
363 break;
364 case I40E_LINK_SPEED_1GB:
365 ethtool_cmd_speed_set(ecmd, SPEED_1000);
366 break;
367 case I40E_LINK_SPEED_100MB:
368 ethtool_cmd_speed_set(ecmd, SPEED_100);
369 break;
370 default:
371 break;
372 }
373 ecmd->duplex = DUPLEX_FULL;
374 }
375
376 /**
377 * i40e_get_settings_link_down - Get the Link settings for when link is down
378 * @hw: hw structure
379 * @ecmd: ethtool command to fill in
380 *
381 * Reports link settings that can be determined when link is down
382 **/
383 static void i40e_get_settings_link_down(struct i40e_hw *hw,
384 struct ethtool_cmd *ecmd)
385 {
386 enum i40e_aq_capabilities_phy_type phy_types = hw->phy.phy_types;
387
388 /* link is down and the driver needs to fall back on
389 * supported phy types to figure out what info to display
390 */
391 ecmd->supported = 0x0;
392 ecmd->advertising = 0x0;
393 if (phy_types & I40E_CAP_PHY_TYPE_SGMII) {
394 ecmd->supported |= SUPPORTED_Autoneg |
395 SUPPORTED_1000baseT_Full |
396 SUPPORTED_100baseT_Full;
397 ecmd->advertising |= ADVERTISED_Autoneg |
398 ADVERTISED_1000baseT_Full |
399 ADVERTISED_100baseT_Full;
400 }
401 if (phy_types & I40E_CAP_PHY_TYPE_XAUI ||
402 phy_types & I40E_CAP_PHY_TYPE_XFI ||
403 phy_types & I40E_CAP_PHY_TYPE_SFI ||
404 phy_types & I40E_CAP_PHY_TYPE_10GBASE_SFPP_CU ||
405 phy_types & I40E_CAP_PHY_TYPE_10GBASE_AOC)
406 ecmd->supported |= SUPPORTED_10000baseT_Full;
407 if (phy_types & I40E_CAP_PHY_TYPE_10GBASE_CR1_CU ||
408 phy_types & I40E_CAP_PHY_TYPE_10GBASE_CR1 ||
409 phy_types & I40E_CAP_PHY_TYPE_10GBASE_T ||
410 phy_types & I40E_CAP_PHY_TYPE_10GBASE_SR ||
411 phy_types & I40E_CAP_PHY_TYPE_10GBASE_LR) {
412 ecmd->supported |= SUPPORTED_Autoneg |
413 SUPPORTED_10000baseT_Full;
414 ecmd->advertising |= ADVERTISED_Autoneg |
415 ADVERTISED_10000baseT_Full;
416 }
417 if (phy_types & I40E_CAP_PHY_TYPE_XLAUI ||
418 phy_types & I40E_CAP_PHY_TYPE_XLPPI ||
419 phy_types & I40E_CAP_PHY_TYPE_40GBASE_AOC)
420 ecmd->supported |= SUPPORTED_40000baseCR4_Full;
421 if (phy_types & I40E_CAP_PHY_TYPE_40GBASE_CR4_CU ||
422 phy_types & I40E_CAP_PHY_TYPE_40GBASE_CR4) {
423 ecmd->supported |= SUPPORTED_Autoneg |
424 SUPPORTED_40000baseCR4_Full;
425 ecmd->advertising |= ADVERTISED_Autoneg |
426 ADVERTISED_40000baseCR4_Full;
427 }
428 if (phy_types & I40E_CAP_PHY_TYPE_100BASE_TX) {
429 ecmd->supported |= SUPPORTED_Autoneg |
430 SUPPORTED_100baseT_Full;
431 ecmd->advertising |= ADVERTISED_Autoneg |
432 ADVERTISED_100baseT_Full;
433 }
434 if (phy_types & I40E_CAP_PHY_TYPE_1000BASE_T ||
435 phy_types & I40E_CAP_PHY_TYPE_1000BASE_SX ||
436 phy_types & I40E_CAP_PHY_TYPE_1000BASE_LX ||
437 phy_types & I40E_CAP_PHY_TYPE_1000BASE_T_OPTICAL) {
438 ecmd->supported |= SUPPORTED_Autoneg |
439 SUPPORTED_1000baseT_Full;
440 ecmd->advertising |= ADVERTISED_Autoneg |
441 ADVERTISED_1000baseT_Full;
442 }
443 if (phy_types & I40E_CAP_PHY_TYPE_40GBASE_SR4)
444 ecmd->supported |= SUPPORTED_40000baseSR4_Full;
445 if (phy_types & I40E_CAP_PHY_TYPE_40GBASE_LR4)
446 ecmd->supported |= SUPPORTED_40000baseLR4_Full;
447
448 /* With no link speed and duplex are unknown */
449 ethtool_cmd_speed_set(ecmd, SPEED_UNKNOWN);
450 ecmd->duplex = DUPLEX_UNKNOWN;
451 }
452
453 /**
454 * i40e_get_settings - Get Link Speed and Duplex settings
455 * @netdev: network interface device structure
456 * @ecmd: ethtool command
457 *
458 * Reports speed/duplex settings based on media_type
459 **/
460 static int i40e_get_settings(struct net_device *netdev,
461 struct ethtool_cmd *ecmd)
462 {
463 struct i40e_netdev_priv *np = netdev_priv(netdev);
464 struct i40e_pf *pf = np->vsi->back;
465 struct i40e_hw *hw = &pf->hw;
466 struct i40e_link_status *hw_link_info = &hw->phy.link_info;
467 bool link_up = hw_link_info->link_info & I40E_AQ_LINK_UP;
468
469 if (link_up)
470 i40e_get_settings_link_up(hw, ecmd, netdev);
471 else
472 i40e_get_settings_link_down(hw, ecmd);
473
474 /* Now set the settings that don't rely on link being up/down */
475
476 /* For backplane, supported and advertised are only reliant on the
477 * phy types the NVM specifies are supported.
478 */
479 if (hw->device_id == I40E_DEV_ID_KX_B ||
480 hw->device_id == I40E_DEV_ID_KX_C ||
481 hw->device_id == I40E_DEV_ID_20G_KR2 ||
482 hw->device_id == I40E_DEV_ID_20G_KR2_A) {
483 ecmd->supported = SUPPORTED_Autoneg;
484 ecmd->advertising = ADVERTISED_Autoneg;
485 if (hw->phy.phy_types & I40E_CAP_PHY_TYPE_40GBASE_KR4) {
486 ecmd->supported |= SUPPORTED_40000baseKR4_Full;
487 ecmd->advertising |= ADVERTISED_40000baseKR4_Full;
488 }
489 if (hw->phy.phy_types & I40E_CAP_PHY_TYPE_20GBASE_KR2) {
490 ecmd->supported |= SUPPORTED_20000baseKR2_Full;
491 ecmd->advertising |= ADVERTISED_20000baseKR2_Full;
492 }
493 if (hw->phy.phy_types & I40E_CAP_PHY_TYPE_10GBASE_KR) {
494 ecmd->supported |= SUPPORTED_10000baseKR_Full;
495 ecmd->advertising |= ADVERTISED_10000baseKR_Full;
496 }
497 if (hw->phy.phy_types & I40E_CAP_PHY_TYPE_10GBASE_KX4) {
498 ecmd->supported |= SUPPORTED_10000baseKX4_Full;
499 ecmd->advertising |= ADVERTISED_10000baseKX4_Full;
500 }
501 if (hw->phy.phy_types & I40E_CAP_PHY_TYPE_1000BASE_KX) {
502 ecmd->supported |= SUPPORTED_1000baseKX_Full;
503 ecmd->advertising |= ADVERTISED_1000baseKX_Full;
504 }
505 }
506
507 /* Set autoneg settings */
508 ecmd->autoneg = ((hw_link_info->an_info & I40E_AQ_AN_COMPLETED) ?
509 AUTONEG_ENABLE : AUTONEG_DISABLE);
510
511 switch (hw->phy.media_type) {
512 case I40E_MEDIA_TYPE_BACKPLANE:
513 ecmd->supported |= SUPPORTED_Autoneg |
514 SUPPORTED_Backplane;
515 ecmd->advertising |= ADVERTISED_Autoneg |
516 ADVERTISED_Backplane;
517 ecmd->port = PORT_NONE;
518 break;
519 case I40E_MEDIA_TYPE_BASET:
520 ecmd->supported |= SUPPORTED_TP;
521 ecmd->advertising |= ADVERTISED_TP;
522 ecmd->port = PORT_TP;
523 break;
524 case I40E_MEDIA_TYPE_DA:
525 case I40E_MEDIA_TYPE_CX4:
526 ecmd->supported |= SUPPORTED_FIBRE;
527 ecmd->advertising |= ADVERTISED_FIBRE;
528 ecmd->port = PORT_DA;
529 break;
530 case I40E_MEDIA_TYPE_FIBER:
531 ecmd->supported |= SUPPORTED_FIBRE;
532 ecmd->port = PORT_FIBRE;
533 break;
534 case I40E_MEDIA_TYPE_UNKNOWN:
535 default:
536 ecmd->port = PORT_OTHER;
537 break;
538 }
539
540 /* Set transceiver */
541 ecmd->transceiver = XCVR_EXTERNAL;
542
543 /* Set flow control settings */
544 ecmd->supported |= SUPPORTED_Pause;
545
546 switch (hw->fc.requested_mode) {
547 case I40E_FC_FULL:
548 ecmd->advertising |= ADVERTISED_Pause;
549 break;
550 case I40E_FC_TX_PAUSE:
551 ecmd->advertising |= ADVERTISED_Asym_Pause;
552 break;
553 case I40E_FC_RX_PAUSE:
554 ecmd->advertising |= (ADVERTISED_Pause |
555 ADVERTISED_Asym_Pause);
556 break;
557 default:
558 ecmd->advertising &= ~(ADVERTISED_Pause |
559 ADVERTISED_Asym_Pause);
560 break;
561 }
562
563 return 0;
564 }
565
566 /**
567 * i40e_set_settings - Set Speed and Duplex
568 * @netdev: network interface device structure
569 * @ecmd: ethtool command
570 *
571 * Set speed/duplex per media_types advertised/forced
572 **/
573 static int i40e_set_settings(struct net_device *netdev,
574 struct ethtool_cmd *ecmd)
575 {
576 struct i40e_netdev_priv *np = netdev_priv(netdev);
577 struct i40e_aq_get_phy_abilities_resp abilities;
578 struct i40e_aq_set_phy_config config;
579 struct i40e_pf *pf = np->vsi->back;
580 struct i40e_vsi *vsi = np->vsi;
581 struct i40e_hw *hw = &pf->hw;
582 struct ethtool_cmd safe_ecmd;
583 i40e_status status = 0;
584 bool change = false;
585 int err = 0;
586 u8 autoneg;
587 u32 advertise;
588
589 /* Changing port settings is not supported if this isn't the
590 * port's controlling PF
591 */
592 if (hw->partition_id != 1) {
593 i40e_partition_setting_complaint(pf);
594 return -EOPNOTSUPP;
595 }
596
597 if (vsi != pf->vsi[pf->lan_vsi])
598 return -EOPNOTSUPP;
599
600 if (hw->phy.media_type != I40E_MEDIA_TYPE_BASET &&
601 hw->phy.media_type != I40E_MEDIA_TYPE_FIBER &&
602 hw->phy.media_type != I40E_MEDIA_TYPE_BACKPLANE &&
603 hw->phy.link_info.link_info & I40E_AQ_LINK_UP)
604 return -EOPNOTSUPP;
605
606 if (hw->device_id == I40E_DEV_ID_KX_B ||
607 hw->device_id == I40E_DEV_ID_KX_C ||
608 hw->device_id == I40E_DEV_ID_20G_KR2 ||
609 hw->device_id == I40E_DEV_ID_20G_KR2_A) {
610 netdev_info(netdev, "Changing settings is not supported on backplane.\n");
611 return -EOPNOTSUPP;
612 }
613
614 /* get our own copy of the bits to check against */
615 memset(&safe_ecmd, 0, sizeof(struct ethtool_cmd));
616 i40e_get_settings(netdev, &safe_ecmd);
617
618 /* save autoneg and speed out of ecmd */
619 autoneg = ecmd->autoneg;
620 advertise = ecmd->advertising;
621
622 /* set autoneg and speed back to what they currently are */
623 ecmd->autoneg = safe_ecmd.autoneg;
624 ecmd->advertising = safe_ecmd.advertising;
625
626 ecmd->cmd = safe_ecmd.cmd;
627 /* If ecmd and safe_ecmd are not the same now, then they are
628 * trying to set something that we do not support
629 */
630 if (memcmp(ecmd, &safe_ecmd, sizeof(struct ethtool_cmd)))
631 return -EOPNOTSUPP;
632
633 while (test_bit(__I40E_CONFIG_BUSY, &vsi->state))
634 usleep_range(1000, 2000);
635
636 /* Get the current phy config */
637 status = i40e_aq_get_phy_capabilities(hw, false, false, &abilities,
638 NULL);
639 if (status)
640 return -EAGAIN;
641
642 /* Copy abilities to config in case autoneg is not
643 * set below
644 */
645 memset(&config, 0, sizeof(struct i40e_aq_set_phy_config));
646 config.abilities = abilities.abilities;
647
648 /* Check autoneg */
649 if (autoneg == AUTONEG_ENABLE) {
650 /* If autoneg is not supported, return error */
651 if (!(safe_ecmd.supported & SUPPORTED_Autoneg)) {
652 netdev_info(netdev, "Autoneg not supported on this phy\n");
653 return -EINVAL;
654 }
655 /* If autoneg was not already enabled */
656 if (!(hw->phy.link_info.an_info & I40E_AQ_AN_COMPLETED)) {
657 config.abilities = abilities.abilities |
658 I40E_AQ_PHY_ENABLE_AN;
659 change = true;
660 }
661 } else {
662 /* If autoneg is supported 10GBASE_T is the only phy that
663 * can disable it, so otherwise return error
664 */
665 if (safe_ecmd.supported & SUPPORTED_Autoneg &&
666 hw->phy.link_info.phy_type != I40E_PHY_TYPE_10GBASE_T) {
667 netdev_info(netdev, "Autoneg cannot be disabled on this phy\n");
668 return -EINVAL;
669 }
670 /* If autoneg is currently enabled */
671 if (hw->phy.link_info.an_info & I40E_AQ_AN_COMPLETED) {
672 config.abilities = abilities.abilities &
673 ~I40E_AQ_PHY_ENABLE_AN;
674 change = true;
675 }
676 }
677
678 if (advertise & ~safe_ecmd.supported)
679 return -EINVAL;
680
681 if (advertise & ADVERTISED_100baseT_Full)
682 config.link_speed |= I40E_LINK_SPEED_100MB;
683 if (advertise & ADVERTISED_1000baseT_Full ||
684 advertise & ADVERTISED_1000baseKX_Full)
685 config.link_speed |= I40E_LINK_SPEED_1GB;
686 if (advertise & ADVERTISED_10000baseT_Full ||
687 advertise & ADVERTISED_10000baseKX4_Full ||
688 advertise & ADVERTISED_10000baseKR_Full)
689 config.link_speed |= I40E_LINK_SPEED_10GB;
690 if (advertise & ADVERTISED_20000baseKR2_Full)
691 config.link_speed |= I40E_LINK_SPEED_20GB;
692 if (advertise & ADVERTISED_40000baseKR4_Full ||
693 advertise & ADVERTISED_40000baseCR4_Full ||
694 advertise & ADVERTISED_40000baseSR4_Full ||
695 advertise & ADVERTISED_40000baseLR4_Full)
696 config.link_speed |= I40E_LINK_SPEED_40GB;
697
698 /* If speed didn't get set, set it to what it currently is.
699 * This is needed because if advertise is 0 (as it is when autoneg
700 * is disabled) then speed won't get set.
701 */
702 if (!config.link_speed)
703 config.link_speed = abilities.link_speed;
704
705 if (change || (abilities.link_speed != config.link_speed)) {
706 /* copy over the rest of the abilities */
707 config.phy_type = abilities.phy_type;
708 config.eee_capability = abilities.eee_capability;
709 config.eeer = abilities.eeer_val;
710 config.low_power_ctrl = abilities.d3_lpan;
711
712 /* save the requested speeds */
713 hw->phy.link_info.requested_speeds = config.link_speed;
714 /* set link and auto negotiation so changes take effect */
715 config.abilities |= I40E_AQ_PHY_ENABLE_ATOMIC_LINK;
716 /* If link is up put link down */
717 if (hw->phy.link_info.link_info & I40E_AQ_LINK_UP) {
718 /* Tell the OS link is going down, the link will go
719 * back up when fw says it is ready asynchronously
720 */
721 i40e_print_link_message(vsi, false);
722 netif_carrier_off(netdev);
723 netif_tx_stop_all_queues(netdev);
724 }
725
726 /* make the aq call */
727 status = i40e_aq_set_phy_config(hw, &config, NULL);
728 if (status) {
729 netdev_info(netdev, "Set phy config failed, err %s aq_err %s\n",
730 i40e_stat_str(hw, status),
731 i40e_aq_str(hw, hw->aq.asq_last_status));
732 return -EAGAIN;
733 }
734
735 status = i40e_update_link_info(hw);
736 if (status)
737 netdev_info(netdev, "Updating link info failed with err %s aq_err %s\n",
738 i40e_stat_str(hw, status),
739 i40e_aq_str(hw, hw->aq.asq_last_status));
740
741 } else {
742 netdev_info(netdev, "Nothing changed, exiting without setting anything.\n");
743 }
744
745 return err;
746 }
747
748 static int i40e_nway_reset(struct net_device *netdev)
749 {
750 /* restart autonegotiation */
751 struct i40e_netdev_priv *np = netdev_priv(netdev);
752 struct i40e_pf *pf = np->vsi->back;
753 struct i40e_hw *hw = &pf->hw;
754 bool link_up = hw->phy.link_info.link_info & I40E_AQ_LINK_UP;
755 i40e_status ret = 0;
756
757 ret = i40e_aq_set_link_restart_an(hw, link_up, NULL);
758 if (ret) {
759 netdev_info(netdev, "link restart failed, err %s aq_err %s\n",
760 i40e_stat_str(hw, ret),
761 i40e_aq_str(hw, hw->aq.asq_last_status));
762 return -EIO;
763 }
764
765 return 0;
766 }
767
768 /**
769 * i40e_get_pauseparam - Get Flow Control status
770 * Return tx/rx-pause status
771 **/
772 static void i40e_get_pauseparam(struct net_device *netdev,
773 struct ethtool_pauseparam *pause)
774 {
775 struct i40e_netdev_priv *np = netdev_priv(netdev);
776 struct i40e_pf *pf = np->vsi->back;
777 struct i40e_hw *hw = &pf->hw;
778 struct i40e_link_status *hw_link_info = &hw->phy.link_info;
779 struct i40e_dcbx_config *dcbx_cfg = &hw->local_dcbx_config;
780
781 pause->autoneg =
782 ((hw_link_info->an_info & I40E_AQ_AN_COMPLETED) ?
783 AUTONEG_ENABLE : AUTONEG_DISABLE);
784
785 /* PFC enabled so report LFC as off */
786 if (dcbx_cfg->pfc.pfcenable) {
787 pause->rx_pause = 0;
788 pause->tx_pause = 0;
789 return;
790 }
791
792 if (hw->fc.current_mode == I40E_FC_RX_PAUSE) {
793 pause->rx_pause = 1;
794 } else if (hw->fc.current_mode == I40E_FC_TX_PAUSE) {
795 pause->tx_pause = 1;
796 } else if (hw->fc.current_mode == I40E_FC_FULL) {
797 pause->rx_pause = 1;
798 pause->tx_pause = 1;
799 }
800 }
801
802 /**
803 * i40e_set_pauseparam - Set Flow Control parameter
804 * @netdev: network interface device structure
805 * @pause: return tx/rx flow control status
806 **/
807 static int i40e_set_pauseparam(struct net_device *netdev,
808 struct ethtool_pauseparam *pause)
809 {
810 struct i40e_netdev_priv *np = netdev_priv(netdev);
811 struct i40e_pf *pf = np->vsi->back;
812 struct i40e_vsi *vsi = np->vsi;
813 struct i40e_hw *hw = &pf->hw;
814 struct i40e_link_status *hw_link_info = &hw->phy.link_info;
815 struct i40e_dcbx_config *dcbx_cfg = &hw->local_dcbx_config;
816 bool link_up = hw_link_info->link_info & I40E_AQ_LINK_UP;
817 i40e_status status;
818 u8 aq_failures;
819 int err = 0;
820
821 /* Changing the port's flow control is not supported if this isn't the
822 * port's controlling PF
823 */
824 if (hw->partition_id != 1) {
825 i40e_partition_setting_complaint(pf);
826 return -EOPNOTSUPP;
827 }
828
829 if (vsi != pf->vsi[pf->lan_vsi])
830 return -EOPNOTSUPP;
831
832 if (pause->autoneg != ((hw_link_info->an_info & I40E_AQ_AN_COMPLETED) ?
833 AUTONEG_ENABLE : AUTONEG_DISABLE)) {
834 netdev_info(netdev, "To change autoneg please use: ethtool -s <dev> autoneg <on|off>\n");
835 return -EOPNOTSUPP;
836 }
837
838 /* If we have link and don't have autoneg */
839 if (!test_bit(__I40E_DOWN, &pf->state) &&
840 !(hw_link_info->an_info & I40E_AQ_AN_COMPLETED)) {
841 /* Send message that it might not necessarily work*/
842 netdev_info(netdev, "Autoneg did not complete so changing settings may not result in an actual change.\n");
843 }
844
845 if (dcbx_cfg->pfc.pfcenable) {
846 netdev_info(netdev,
847 "Priority flow control enabled. Cannot set link flow control.\n");
848 return -EOPNOTSUPP;
849 }
850
851 if (pause->rx_pause && pause->tx_pause)
852 hw->fc.requested_mode = I40E_FC_FULL;
853 else if (pause->rx_pause && !pause->tx_pause)
854 hw->fc.requested_mode = I40E_FC_RX_PAUSE;
855 else if (!pause->rx_pause && pause->tx_pause)
856 hw->fc.requested_mode = I40E_FC_TX_PAUSE;
857 else if (!pause->rx_pause && !pause->tx_pause)
858 hw->fc.requested_mode = I40E_FC_NONE;
859 else
860 return -EINVAL;
861
862 /* Tell the OS link is going down, the link will go back up when fw
863 * says it is ready asynchronously
864 */
865 i40e_print_link_message(vsi, false);
866 netif_carrier_off(netdev);
867 netif_tx_stop_all_queues(netdev);
868
869 /* Set the fc mode and only restart an if link is up*/
870 status = i40e_set_fc(hw, &aq_failures, link_up);
871
872 if (aq_failures & I40E_SET_FC_AQ_FAIL_GET) {
873 netdev_info(netdev, "Set fc failed on the get_phy_capabilities call with err %s aq_err %s\n",
874 i40e_stat_str(hw, status),
875 i40e_aq_str(hw, hw->aq.asq_last_status));
876 err = -EAGAIN;
877 }
878 if (aq_failures & I40E_SET_FC_AQ_FAIL_SET) {
879 netdev_info(netdev, "Set fc failed on the set_phy_config call with err %s aq_err %s\n",
880 i40e_stat_str(hw, status),
881 i40e_aq_str(hw, hw->aq.asq_last_status));
882 err = -EAGAIN;
883 }
884 if (aq_failures & I40E_SET_FC_AQ_FAIL_UPDATE) {
885 netdev_info(netdev, "Set fc failed on the get_link_info call with err %s aq_err %s\n",
886 i40e_stat_str(hw, status),
887 i40e_aq_str(hw, hw->aq.asq_last_status));
888 err = -EAGAIN;
889 }
890
891 if (!test_bit(__I40E_DOWN, &pf->state)) {
892 /* Give it a little more time to try to come back */
893 msleep(75);
894 if (!test_bit(__I40E_DOWN, &pf->state))
895 return i40e_nway_reset(netdev);
896 }
897
898 return err;
899 }
900
901 static u32 i40e_get_msglevel(struct net_device *netdev)
902 {
903 struct i40e_netdev_priv *np = netdev_priv(netdev);
904 struct i40e_pf *pf = np->vsi->back;
905
906 return pf->msg_enable;
907 }
908
909 static void i40e_set_msglevel(struct net_device *netdev, u32 data)
910 {
911 struct i40e_netdev_priv *np = netdev_priv(netdev);
912 struct i40e_pf *pf = np->vsi->back;
913
914 if (I40E_DEBUG_USER & data)
915 pf->hw.debug_mask = data;
916 pf->msg_enable = data;
917 }
918
919 static int i40e_get_regs_len(struct net_device *netdev)
920 {
921 int reg_count = 0;
922 int i;
923
924 for (i = 0; i40e_reg_list[i].offset != 0; i++)
925 reg_count += i40e_reg_list[i].elements;
926
927 return reg_count * sizeof(u32);
928 }
929
930 static void i40e_get_regs(struct net_device *netdev, struct ethtool_regs *regs,
931 void *p)
932 {
933 struct i40e_netdev_priv *np = netdev_priv(netdev);
934 struct i40e_pf *pf = np->vsi->back;
935 struct i40e_hw *hw = &pf->hw;
936 u32 *reg_buf = p;
937 int i, j, ri;
938 u32 reg;
939
940 /* Tell ethtool which driver-version-specific regs output we have.
941 *
942 * At some point, if we have ethtool doing special formatting of
943 * this data, it will rely on this version number to know how to
944 * interpret things. Hence, this needs to be updated if/when the
945 * diags register table is changed.
946 */
947 regs->version = 1;
948
949 /* loop through the diags reg table for what to print */
950 ri = 0;
951 for (i = 0; i40e_reg_list[i].offset != 0; i++) {
952 for (j = 0; j < i40e_reg_list[i].elements; j++) {
953 reg = i40e_reg_list[i].offset
954 + (j * i40e_reg_list[i].stride);
955 reg_buf[ri++] = rd32(hw, reg);
956 }
957 }
958
959 }
960
961 static int i40e_get_eeprom(struct net_device *netdev,
962 struct ethtool_eeprom *eeprom, u8 *bytes)
963 {
964 struct i40e_netdev_priv *np = netdev_priv(netdev);
965 struct i40e_hw *hw = &np->vsi->back->hw;
966 struct i40e_pf *pf = np->vsi->back;
967 int ret_val = 0, len, offset;
968 u8 *eeprom_buff;
969 u16 i, sectors;
970 bool last;
971 u32 magic;
972
973 #define I40E_NVM_SECTOR_SIZE 4096
974 if (eeprom->len == 0)
975 return -EINVAL;
976
977 /* check for NVMUpdate access method */
978 magic = hw->vendor_id | (hw->device_id << 16);
979 if (eeprom->magic && eeprom->magic != magic) {
980 struct i40e_nvm_access *cmd;
981 int errno;
982
983 /* make sure it is the right magic for NVMUpdate */
984 if ((eeprom->magic >> 16) != hw->device_id)
985 return -EINVAL;
986
987 cmd = (struct i40e_nvm_access *)eeprom;
988 ret_val = i40e_nvmupd_command(hw, cmd, bytes, &errno);
989 if (ret_val &&
990 ((hw->aq.asq_last_status != I40E_AQ_RC_EACCES) ||
991 (hw->debug_mask & I40E_DEBUG_NVM)))
992 dev_info(&pf->pdev->dev,
993 "NVMUpdate read failed err=%d status=0x%x errno=%d module=%d offset=0x%x size=%d\n",
994 ret_val, hw->aq.asq_last_status, errno,
995 (u8)(cmd->config & I40E_NVM_MOD_PNT_MASK),
996 cmd->offset, cmd->data_size);
997
998 return errno;
999 }
1000
1001 /* normal ethtool get_eeprom support */
1002 eeprom->magic = hw->vendor_id | (hw->device_id << 16);
1003
1004 eeprom_buff = kzalloc(eeprom->len, GFP_KERNEL);
1005 if (!eeprom_buff)
1006 return -ENOMEM;
1007
1008 ret_val = i40e_acquire_nvm(hw, I40E_RESOURCE_READ);
1009 if (ret_val) {
1010 dev_info(&pf->pdev->dev,
1011 "Failed Acquiring NVM resource for read err=%d status=0x%x\n",
1012 ret_val, hw->aq.asq_last_status);
1013 goto free_buff;
1014 }
1015
1016 sectors = eeprom->len / I40E_NVM_SECTOR_SIZE;
1017 sectors += (eeprom->len % I40E_NVM_SECTOR_SIZE) ? 1 : 0;
1018 len = I40E_NVM_SECTOR_SIZE;
1019 last = false;
1020 for (i = 0; i < sectors; i++) {
1021 if (i == (sectors - 1)) {
1022 len = eeprom->len - (I40E_NVM_SECTOR_SIZE * i);
1023 last = true;
1024 }
1025 offset = eeprom->offset + (I40E_NVM_SECTOR_SIZE * i),
1026 ret_val = i40e_aq_read_nvm(hw, 0x0, offset, len,
1027 (u8 *)eeprom_buff + (I40E_NVM_SECTOR_SIZE * i),
1028 last, NULL);
1029 if (ret_val && hw->aq.asq_last_status == I40E_AQ_RC_EPERM) {
1030 dev_info(&pf->pdev->dev,
1031 "read NVM failed, invalid offset 0x%x\n",
1032 offset);
1033 break;
1034 } else if (ret_val &&
1035 hw->aq.asq_last_status == I40E_AQ_RC_EACCES) {
1036 dev_info(&pf->pdev->dev,
1037 "read NVM failed, access, offset 0x%x\n",
1038 offset);
1039 break;
1040 } else if (ret_val) {
1041 dev_info(&pf->pdev->dev,
1042 "read NVM failed offset %d err=%d status=0x%x\n",
1043 offset, ret_val, hw->aq.asq_last_status);
1044 break;
1045 }
1046 }
1047
1048 i40e_release_nvm(hw);
1049 memcpy(bytes, (u8 *)eeprom_buff, eeprom->len);
1050 free_buff:
1051 kfree(eeprom_buff);
1052 return ret_val;
1053 }
1054
1055 static int i40e_get_eeprom_len(struct net_device *netdev)
1056 {
1057 struct i40e_netdev_priv *np = netdev_priv(netdev);
1058 struct i40e_hw *hw = &np->vsi->back->hw;
1059 u32 val;
1060
1061 val = (rd32(hw, I40E_GLPCI_LBARCTRL)
1062 & I40E_GLPCI_LBARCTRL_FL_SIZE_MASK)
1063 >> I40E_GLPCI_LBARCTRL_FL_SIZE_SHIFT;
1064 /* register returns value in power of 2, 64Kbyte chunks. */
1065 val = (64 * 1024) * BIT(val);
1066 return val;
1067 }
1068
1069 static int i40e_set_eeprom(struct net_device *netdev,
1070 struct ethtool_eeprom *eeprom, u8 *bytes)
1071 {
1072 struct i40e_netdev_priv *np = netdev_priv(netdev);
1073 struct i40e_hw *hw = &np->vsi->back->hw;
1074 struct i40e_pf *pf = np->vsi->back;
1075 struct i40e_nvm_access *cmd;
1076 int ret_val = 0;
1077 int errno;
1078 u32 magic;
1079
1080 /* normal ethtool set_eeprom is not supported */
1081 magic = hw->vendor_id | (hw->device_id << 16);
1082 if (eeprom->magic == magic)
1083 return -EOPNOTSUPP;
1084
1085 /* check for NVMUpdate access method */
1086 if (!eeprom->magic || (eeprom->magic >> 16) != hw->device_id)
1087 return -EINVAL;
1088
1089 if (test_bit(__I40E_RESET_RECOVERY_PENDING, &pf->state) ||
1090 test_bit(__I40E_RESET_INTR_RECEIVED, &pf->state))
1091 return -EBUSY;
1092
1093 cmd = (struct i40e_nvm_access *)eeprom;
1094 ret_val = i40e_nvmupd_command(hw, cmd, bytes, &errno);
1095 if (ret_val &&
1096 ((hw->aq.asq_last_status != I40E_AQ_RC_EPERM &&
1097 hw->aq.asq_last_status != I40E_AQ_RC_EBUSY) ||
1098 (hw->debug_mask & I40E_DEBUG_NVM)))
1099 dev_info(&pf->pdev->dev,
1100 "NVMUpdate write failed err=%d status=0x%x errno=%d module=%d offset=0x%x size=%d\n",
1101 ret_val, hw->aq.asq_last_status, errno,
1102 (u8)(cmd->config & I40E_NVM_MOD_PNT_MASK),
1103 cmd->offset, cmd->data_size);
1104
1105 return errno;
1106 }
1107
1108 static void i40e_get_drvinfo(struct net_device *netdev,
1109 struct ethtool_drvinfo *drvinfo)
1110 {
1111 struct i40e_netdev_priv *np = netdev_priv(netdev);
1112 struct i40e_vsi *vsi = np->vsi;
1113 struct i40e_pf *pf = vsi->back;
1114
1115 strlcpy(drvinfo->driver, i40e_driver_name, sizeof(drvinfo->driver));
1116 strlcpy(drvinfo->version, i40e_driver_version_str,
1117 sizeof(drvinfo->version));
1118 strlcpy(drvinfo->fw_version, i40e_fw_version_str(&pf->hw),
1119 sizeof(drvinfo->fw_version));
1120 strlcpy(drvinfo->bus_info, pci_name(pf->pdev),
1121 sizeof(drvinfo->bus_info));
1122 drvinfo->n_priv_flags = I40E_PRIV_FLAGS_STR_LEN;
1123 }
1124
1125 static void i40e_get_ringparam(struct net_device *netdev,
1126 struct ethtool_ringparam *ring)
1127 {
1128 struct i40e_netdev_priv *np = netdev_priv(netdev);
1129 struct i40e_pf *pf = np->vsi->back;
1130 struct i40e_vsi *vsi = pf->vsi[pf->lan_vsi];
1131
1132 ring->rx_max_pending = I40E_MAX_NUM_DESCRIPTORS;
1133 ring->tx_max_pending = I40E_MAX_NUM_DESCRIPTORS;
1134 ring->rx_mini_max_pending = 0;
1135 ring->rx_jumbo_max_pending = 0;
1136 ring->rx_pending = vsi->rx_rings[0]->count;
1137 ring->tx_pending = vsi->tx_rings[0]->count;
1138 ring->rx_mini_pending = 0;
1139 ring->rx_jumbo_pending = 0;
1140 }
1141
1142 static int i40e_set_ringparam(struct net_device *netdev,
1143 struct ethtool_ringparam *ring)
1144 {
1145 struct i40e_ring *tx_rings = NULL, *rx_rings = NULL;
1146 struct i40e_netdev_priv *np = netdev_priv(netdev);
1147 struct i40e_vsi *vsi = np->vsi;
1148 struct i40e_pf *pf = vsi->back;
1149 u32 new_rx_count, new_tx_count;
1150 int i, err = 0;
1151
1152 if ((ring->rx_mini_pending) || (ring->rx_jumbo_pending))
1153 return -EINVAL;
1154
1155 if (ring->tx_pending > I40E_MAX_NUM_DESCRIPTORS ||
1156 ring->tx_pending < I40E_MIN_NUM_DESCRIPTORS ||
1157 ring->rx_pending > I40E_MAX_NUM_DESCRIPTORS ||
1158 ring->rx_pending < I40E_MIN_NUM_DESCRIPTORS) {
1159 netdev_info(netdev,
1160 "Descriptors requested (Tx: %d / Rx: %d) out of range [%d-%d]\n",
1161 ring->tx_pending, ring->rx_pending,
1162 I40E_MIN_NUM_DESCRIPTORS, I40E_MAX_NUM_DESCRIPTORS);
1163 return -EINVAL;
1164 }
1165
1166 new_tx_count = ALIGN(ring->tx_pending, I40E_REQ_DESCRIPTOR_MULTIPLE);
1167 new_rx_count = ALIGN(ring->rx_pending, I40E_REQ_DESCRIPTOR_MULTIPLE);
1168
1169 /* if nothing to do return success */
1170 if ((new_tx_count == vsi->tx_rings[0]->count) &&
1171 (new_rx_count == vsi->rx_rings[0]->count))
1172 return 0;
1173
1174 while (test_and_set_bit(__I40E_CONFIG_BUSY, &pf->state))
1175 usleep_range(1000, 2000);
1176
1177 if (!netif_running(vsi->netdev)) {
1178 /* simple case - set for the next time the netdev is started */
1179 for (i = 0; i < vsi->num_queue_pairs; i++) {
1180 vsi->tx_rings[i]->count = new_tx_count;
1181 vsi->rx_rings[i]->count = new_rx_count;
1182 }
1183 goto done;
1184 }
1185
1186 /* We can't just free everything and then setup again,
1187 * because the ISRs in MSI-X mode get passed pointers
1188 * to the Tx and Rx ring structs.
1189 */
1190
1191 /* alloc updated Tx resources */
1192 if (new_tx_count != vsi->tx_rings[0]->count) {
1193 netdev_info(netdev,
1194 "Changing Tx descriptor count from %d to %d.\n",
1195 vsi->tx_rings[0]->count, new_tx_count);
1196 tx_rings = kcalloc(vsi->alloc_queue_pairs,
1197 sizeof(struct i40e_ring), GFP_KERNEL);
1198 if (!tx_rings) {
1199 err = -ENOMEM;
1200 goto done;
1201 }
1202
1203 for (i = 0; i < vsi->num_queue_pairs; i++) {
1204 /* clone ring and setup updated count */
1205 tx_rings[i] = *vsi->tx_rings[i];
1206 tx_rings[i].count = new_tx_count;
1207 /* the desc and bi pointers will be reallocated in the
1208 * setup call
1209 */
1210 tx_rings[i].desc = NULL;
1211 tx_rings[i].rx_bi = NULL;
1212 err = i40e_setup_tx_descriptors(&tx_rings[i]);
1213 if (err) {
1214 while (i) {
1215 i--;
1216 i40e_free_tx_resources(&tx_rings[i]);
1217 }
1218 kfree(tx_rings);
1219 tx_rings = NULL;
1220
1221 goto done;
1222 }
1223 }
1224 }
1225
1226 /* alloc updated Rx resources */
1227 if (new_rx_count != vsi->rx_rings[0]->count) {
1228 netdev_info(netdev,
1229 "Changing Rx descriptor count from %d to %d\n",
1230 vsi->rx_rings[0]->count, new_rx_count);
1231 rx_rings = kcalloc(vsi->alloc_queue_pairs,
1232 sizeof(struct i40e_ring), GFP_KERNEL);
1233 if (!rx_rings) {
1234 err = -ENOMEM;
1235 goto free_tx;
1236 }
1237
1238 for (i = 0; i < vsi->num_queue_pairs; i++) {
1239 /* clone ring and setup updated count */
1240 rx_rings[i] = *vsi->rx_rings[i];
1241 rx_rings[i].count = new_rx_count;
1242 /* the desc and bi pointers will be reallocated in the
1243 * setup call
1244 */
1245 rx_rings[i].desc = NULL;
1246 rx_rings[i].rx_bi = NULL;
1247 err = i40e_setup_rx_descriptors(&rx_rings[i]);
1248 if (err) {
1249 while (i) {
1250 i--;
1251 i40e_free_rx_resources(&rx_rings[i]);
1252 }
1253 kfree(rx_rings);
1254 rx_rings = NULL;
1255
1256 goto free_tx;
1257 }
1258 }
1259 }
1260
1261 /* Bring interface down, copy in the new ring info,
1262 * then restore the interface
1263 */
1264 i40e_down(vsi);
1265
1266 if (tx_rings) {
1267 for (i = 0; i < vsi->num_queue_pairs; i++) {
1268 i40e_free_tx_resources(vsi->tx_rings[i]);
1269 *vsi->tx_rings[i] = tx_rings[i];
1270 }
1271 kfree(tx_rings);
1272 tx_rings = NULL;
1273 }
1274
1275 if (rx_rings) {
1276 for (i = 0; i < vsi->num_queue_pairs; i++) {
1277 i40e_free_rx_resources(vsi->rx_rings[i]);
1278 *vsi->rx_rings[i] = rx_rings[i];
1279 }
1280 kfree(rx_rings);
1281 rx_rings = NULL;
1282 }
1283
1284 i40e_up(vsi);
1285
1286 free_tx:
1287 /* error cleanup if the Rx allocations failed after getting Tx */
1288 if (tx_rings) {
1289 for (i = 0; i < vsi->num_queue_pairs; i++)
1290 i40e_free_tx_resources(&tx_rings[i]);
1291 kfree(tx_rings);
1292 tx_rings = NULL;
1293 }
1294
1295 done:
1296 clear_bit(__I40E_CONFIG_BUSY, &pf->state);
1297
1298 return err;
1299 }
1300
1301 static int i40e_get_sset_count(struct net_device *netdev, int sset)
1302 {
1303 struct i40e_netdev_priv *np = netdev_priv(netdev);
1304 struct i40e_vsi *vsi = np->vsi;
1305 struct i40e_pf *pf = vsi->back;
1306
1307 switch (sset) {
1308 case ETH_SS_TEST:
1309 return I40E_TEST_LEN;
1310 case ETH_SS_STATS:
1311 if (vsi == pf->vsi[pf->lan_vsi] && pf->hw.partition_id == 1) {
1312 int len = I40E_PF_STATS_LEN(netdev);
1313
1314 if ((pf->lan_veb != I40E_NO_VEB) &&
1315 (pf->flags & I40E_FLAG_VEB_STATS_ENABLED))
1316 len += I40E_VEB_STATS_TOTAL;
1317 return len;
1318 } else {
1319 return I40E_VSI_STATS_LEN(netdev);
1320 }
1321 case ETH_SS_PRIV_FLAGS:
1322 return I40E_PRIV_FLAGS_STR_LEN;
1323 default:
1324 return -EOPNOTSUPP;
1325 }
1326 }
1327
1328 static void i40e_get_ethtool_stats(struct net_device *netdev,
1329 struct ethtool_stats *stats, u64 *data)
1330 {
1331 struct i40e_netdev_priv *np = netdev_priv(netdev);
1332 struct i40e_ring *tx_ring, *rx_ring;
1333 struct i40e_vsi *vsi = np->vsi;
1334 struct i40e_pf *pf = vsi->back;
1335 int i = 0;
1336 char *p;
1337 int j;
1338 struct rtnl_link_stats64 *net_stats = i40e_get_vsi_stats_struct(vsi);
1339 unsigned int start;
1340
1341 i40e_update_stats(vsi);
1342
1343 for (j = 0; j < I40E_NETDEV_STATS_LEN; j++) {
1344 p = (char *)net_stats + i40e_gstrings_net_stats[j].stat_offset;
1345 data[i++] = (i40e_gstrings_net_stats[j].sizeof_stat ==
1346 sizeof(u64)) ? *(u64 *)p : *(u32 *)p;
1347 }
1348 for (j = 0; j < I40E_MISC_STATS_LEN; j++) {
1349 p = (char *)vsi + i40e_gstrings_misc_stats[j].stat_offset;
1350 data[i++] = (i40e_gstrings_misc_stats[j].sizeof_stat ==
1351 sizeof(u64)) ? *(u64 *)p : *(u32 *)p;
1352 }
1353 #ifdef I40E_FCOE
1354 for (j = 0; j < I40E_FCOE_STATS_LEN; j++) {
1355 p = (char *)vsi + i40e_gstrings_fcoe_stats[j].stat_offset;
1356 data[i++] = (i40e_gstrings_fcoe_stats[j].sizeof_stat ==
1357 sizeof(u64)) ? *(u64 *)p : *(u32 *)p;
1358 }
1359 #endif
1360 rcu_read_lock();
1361 for (j = 0; j < vsi->num_queue_pairs; j++) {
1362 tx_ring = ACCESS_ONCE(vsi->tx_rings[j]);
1363
1364 if (!tx_ring)
1365 continue;
1366
1367 /* process Tx ring statistics */
1368 do {
1369 start = u64_stats_fetch_begin_irq(&tx_ring->syncp);
1370 data[i] = tx_ring->stats.packets;
1371 data[i + 1] = tx_ring->stats.bytes;
1372 } while (u64_stats_fetch_retry_irq(&tx_ring->syncp, start));
1373 i += 2;
1374
1375 /* Rx ring is the 2nd half of the queue pair */
1376 rx_ring = &tx_ring[1];
1377 do {
1378 start = u64_stats_fetch_begin_irq(&rx_ring->syncp);
1379 data[i] = rx_ring->stats.packets;
1380 data[i + 1] = rx_ring->stats.bytes;
1381 } while (u64_stats_fetch_retry_irq(&rx_ring->syncp, start));
1382 i += 2;
1383 }
1384 rcu_read_unlock();
1385 if (vsi != pf->vsi[pf->lan_vsi] || pf->hw.partition_id != 1)
1386 return;
1387
1388 if ((pf->lan_veb != I40E_NO_VEB) &&
1389 (pf->flags & I40E_FLAG_VEB_STATS_ENABLED)) {
1390 struct i40e_veb *veb = pf->veb[pf->lan_veb];
1391
1392 for (j = 0; j < I40E_VEB_STATS_LEN; j++) {
1393 p = (char *)veb;
1394 p += i40e_gstrings_veb_stats[j].stat_offset;
1395 data[i++] = (i40e_gstrings_veb_stats[j].sizeof_stat ==
1396 sizeof(u64)) ? *(u64 *)p : *(u32 *)p;
1397 }
1398 }
1399 for (j = 0; j < I40E_GLOBAL_STATS_LEN; j++) {
1400 p = (char *)pf + i40e_gstrings_stats[j].stat_offset;
1401 data[i++] = (i40e_gstrings_stats[j].sizeof_stat ==
1402 sizeof(u64)) ? *(u64 *)p : *(u32 *)p;
1403 }
1404 for (j = 0; j < I40E_MAX_USER_PRIORITY; j++) {
1405 data[i++] = pf->stats.priority_xon_tx[j];
1406 data[i++] = pf->stats.priority_xoff_tx[j];
1407 }
1408 for (j = 0; j < I40E_MAX_USER_PRIORITY; j++) {
1409 data[i++] = pf->stats.priority_xon_rx[j];
1410 data[i++] = pf->stats.priority_xoff_rx[j];
1411 }
1412 for (j = 0; j < I40E_MAX_USER_PRIORITY; j++)
1413 data[i++] = pf->stats.priority_xon_2_xoff[j];
1414 }
1415
1416 static void i40e_get_strings(struct net_device *netdev, u32 stringset,
1417 u8 *data)
1418 {
1419 struct i40e_netdev_priv *np = netdev_priv(netdev);
1420 struct i40e_vsi *vsi = np->vsi;
1421 struct i40e_pf *pf = vsi->back;
1422 char *p = (char *)data;
1423 int i;
1424
1425 switch (stringset) {
1426 case ETH_SS_TEST:
1427 for (i = 0; i < I40E_TEST_LEN; i++) {
1428 memcpy(data, i40e_gstrings_test[i], ETH_GSTRING_LEN);
1429 data += ETH_GSTRING_LEN;
1430 }
1431 break;
1432 case ETH_SS_STATS:
1433 for (i = 0; i < I40E_NETDEV_STATS_LEN; i++) {
1434 snprintf(p, ETH_GSTRING_LEN, "%s",
1435 i40e_gstrings_net_stats[i].stat_string);
1436 p += ETH_GSTRING_LEN;
1437 }
1438 for (i = 0; i < I40E_MISC_STATS_LEN; i++) {
1439 snprintf(p, ETH_GSTRING_LEN, "%s",
1440 i40e_gstrings_misc_stats[i].stat_string);
1441 p += ETH_GSTRING_LEN;
1442 }
1443 #ifdef I40E_FCOE
1444 for (i = 0; i < I40E_FCOE_STATS_LEN; i++) {
1445 snprintf(p, ETH_GSTRING_LEN, "%s",
1446 i40e_gstrings_fcoe_stats[i].stat_string);
1447 p += ETH_GSTRING_LEN;
1448 }
1449 #endif
1450 for (i = 0; i < vsi->num_queue_pairs; i++) {
1451 snprintf(p, ETH_GSTRING_LEN, "tx-%u.tx_packets", i);
1452 p += ETH_GSTRING_LEN;
1453 snprintf(p, ETH_GSTRING_LEN, "tx-%u.tx_bytes", i);
1454 p += ETH_GSTRING_LEN;
1455 snprintf(p, ETH_GSTRING_LEN, "rx-%u.rx_packets", i);
1456 p += ETH_GSTRING_LEN;
1457 snprintf(p, ETH_GSTRING_LEN, "rx-%u.rx_bytes", i);
1458 p += ETH_GSTRING_LEN;
1459 }
1460 if (vsi != pf->vsi[pf->lan_vsi] || pf->hw.partition_id != 1)
1461 return;
1462
1463 if ((pf->lan_veb != I40E_NO_VEB) &&
1464 (pf->flags & I40E_FLAG_VEB_STATS_ENABLED)) {
1465 for (i = 0; i < I40E_VEB_STATS_LEN; i++) {
1466 snprintf(p, ETH_GSTRING_LEN, "veb.%s",
1467 i40e_gstrings_veb_stats[i].stat_string);
1468 p += ETH_GSTRING_LEN;
1469 }
1470 for (i = 0; i < I40E_MAX_TRAFFIC_CLASS; i++) {
1471 snprintf(p, ETH_GSTRING_LEN,
1472 "veb.tc_%u_tx_packets", i);
1473 p += ETH_GSTRING_LEN;
1474 snprintf(p, ETH_GSTRING_LEN,
1475 "veb.tc_%u_tx_bytes", i);
1476 p += ETH_GSTRING_LEN;
1477 snprintf(p, ETH_GSTRING_LEN,
1478 "veb.tc_%u_rx_packets", i);
1479 p += ETH_GSTRING_LEN;
1480 snprintf(p, ETH_GSTRING_LEN,
1481 "veb.tc_%u_rx_bytes", i);
1482 p += ETH_GSTRING_LEN;
1483 }
1484 }
1485 for (i = 0; i < I40E_GLOBAL_STATS_LEN; i++) {
1486 snprintf(p, ETH_GSTRING_LEN, "port.%s",
1487 i40e_gstrings_stats[i].stat_string);
1488 p += ETH_GSTRING_LEN;
1489 }
1490 for (i = 0; i < I40E_MAX_USER_PRIORITY; i++) {
1491 snprintf(p, ETH_GSTRING_LEN,
1492 "port.tx_priority_%u_xon", i);
1493 p += ETH_GSTRING_LEN;
1494 snprintf(p, ETH_GSTRING_LEN,
1495 "port.tx_priority_%u_xoff", i);
1496 p += ETH_GSTRING_LEN;
1497 }
1498 for (i = 0; i < I40E_MAX_USER_PRIORITY; i++) {
1499 snprintf(p, ETH_GSTRING_LEN,
1500 "port.rx_priority_%u_xon", i);
1501 p += ETH_GSTRING_LEN;
1502 snprintf(p, ETH_GSTRING_LEN,
1503 "port.rx_priority_%u_xoff", i);
1504 p += ETH_GSTRING_LEN;
1505 }
1506 for (i = 0; i < I40E_MAX_USER_PRIORITY; i++) {
1507 snprintf(p, ETH_GSTRING_LEN,
1508 "port.rx_priority_%u_xon_2_xoff", i);
1509 p += ETH_GSTRING_LEN;
1510 }
1511 /* BUG_ON(p - data != I40E_STATS_LEN * ETH_GSTRING_LEN); */
1512 break;
1513 case ETH_SS_PRIV_FLAGS:
1514 for (i = 0; i < I40E_PRIV_FLAGS_STR_LEN; i++) {
1515 memcpy(data, i40e_priv_flags_strings[i],
1516 ETH_GSTRING_LEN);
1517 data += ETH_GSTRING_LEN;
1518 }
1519 break;
1520 default:
1521 break;
1522 }
1523 }
1524
1525 static int i40e_get_ts_info(struct net_device *dev,
1526 struct ethtool_ts_info *info)
1527 {
1528 struct i40e_pf *pf = i40e_netdev_to_pf(dev);
1529
1530 /* only report HW timestamping if PTP is enabled */
1531 if (!(pf->flags & I40E_FLAG_PTP))
1532 return ethtool_op_get_ts_info(dev, info);
1533
1534 info->so_timestamping = SOF_TIMESTAMPING_TX_SOFTWARE |
1535 SOF_TIMESTAMPING_RX_SOFTWARE |
1536 SOF_TIMESTAMPING_SOFTWARE |
1537 SOF_TIMESTAMPING_TX_HARDWARE |
1538 SOF_TIMESTAMPING_RX_HARDWARE |
1539 SOF_TIMESTAMPING_RAW_HARDWARE;
1540
1541 if (pf->ptp_clock)
1542 info->phc_index = ptp_clock_index(pf->ptp_clock);
1543 else
1544 info->phc_index = -1;
1545
1546 info->tx_types = BIT(HWTSTAMP_TX_OFF) | BIT(HWTSTAMP_TX_ON);
1547
1548 info->rx_filters = BIT(HWTSTAMP_FILTER_NONE) |
1549 BIT(HWTSTAMP_FILTER_PTP_V1_L4_EVENT) |
1550 BIT(HWTSTAMP_FILTER_PTP_V2_EVENT);
1551
1552 return 0;
1553 }
1554
1555 static int i40e_link_test(struct net_device *netdev, u64 *data)
1556 {
1557 struct i40e_netdev_priv *np = netdev_priv(netdev);
1558 struct i40e_pf *pf = np->vsi->back;
1559 i40e_status status;
1560 bool link_up = false;
1561
1562 netif_info(pf, hw, netdev, "link test\n");
1563 status = i40e_get_link_status(&pf->hw, &link_up);
1564 if (status) {
1565 netif_err(pf, drv, netdev, "link query timed out, please retry test\n");
1566 *data = 1;
1567 return *data;
1568 }
1569
1570 if (link_up)
1571 *data = 0;
1572 else
1573 *data = 1;
1574
1575 return *data;
1576 }
1577
1578 static int i40e_reg_test(struct net_device *netdev, u64 *data)
1579 {
1580 struct i40e_netdev_priv *np = netdev_priv(netdev);
1581 struct i40e_pf *pf = np->vsi->back;
1582
1583 netif_info(pf, hw, netdev, "register test\n");
1584 *data = i40e_diag_reg_test(&pf->hw);
1585
1586 return *data;
1587 }
1588
1589 static int i40e_eeprom_test(struct net_device *netdev, u64 *data)
1590 {
1591 struct i40e_netdev_priv *np = netdev_priv(netdev);
1592 struct i40e_pf *pf = np->vsi->back;
1593
1594 netif_info(pf, hw, netdev, "eeprom test\n");
1595 *data = i40e_diag_eeprom_test(&pf->hw);
1596
1597 /* forcebly clear the NVM Update state machine */
1598 pf->hw.nvmupd_state = I40E_NVMUPD_STATE_INIT;
1599
1600 return *data;
1601 }
1602
1603 static int i40e_intr_test(struct net_device *netdev, u64 *data)
1604 {
1605 struct i40e_netdev_priv *np = netdev_priv(netdev);
1606 struct i40e_pf *pf = np->vsi->back;
1607 u16 swc_old = pf->sw_int_count;
1608
1609 netif_info(pf, hw, netdev, "interrupt test\n");
1610 wr32(&pf->hw, I40E_PFINT_DYN_CTL0,
1611 (I40E_PFINT_DYN_CTL0_INTENA_MASK |
1612 I40E_PFINT_DYN_CTL0_SWINT_TRIG_MASK |
1613 I40E_PFINT_DYN_CTL0_ITR_INDX_MASK |
1614 I40E_PFINT_DYN_CTL0_SW_ITR_INDX_ENA_MASK |
1615 I40E_PFINT_DYN_CTL0_SW_ITR_INDX_MASK));
1616 usleep_range(1000, 2000);
1617 *data = (swc_old == pf->sw_int_count);
1618
1619 return *data;
1620 }
1621
1622 static int i40e_loopback_test(struct net_device *netdev, u64 *data)
1623 {
1624 struct i40e_netdev_priv *np = netdev_priv(netdev);
1625 struct i40e_pf *pf = np->vsi->back;
1626
1627 netif_info(pf, hw, netdev, "loopback test not implemented\n");
1628 *data = 0;
1629
1630 return *data;
1631 }
1632
1633 static inline bool i40e_active_vfs(struct i40e_pf *pf)
1634 {
1635 struct i40e_vf *vfs = pf->vf;
1636 int i;
1637
1638 for (i = 0; i < pf->num_alloc_vfs; i++)
1639 if (test_bit(I40E_VF_STAT_ACTIVE, &vfs[i].vf_states))
1640 return true;
1641 return false;
1642 }
1643
1644 static inline bool i40e_active_vmdqs(struct i40e_pf *pf)
1645 {
1646 struct i40e_vsi **vsi = pf->vsi;
1647 int i;
1648
1649 for (i = 0; i < pf->num_alloc_vsi; i++) {
1650 if (!vsi[i])
1651 continue;
1652 if (vsi[i]->type == I40E_VSI_VMDQ2)
1653 return true;
1654 }
1655
1656 return false;
1657 }
1658
1659 static void i40e_diag_test(struct net_device *netdev,
1660 struct ethtool_test *eth_test, u64 *data)
1661 {
1662 struct i40e_netdev_priv *np = netdev_priv(netdev);
1663 bool if_running = netif_running(netdev);
1664 struct i40e_pf *pf = np->vsi->back;
1665
1666 if (eth_test->flags == ETH_TEST_FL_OFFLINE) {
1667 /* Offline tests */
1668 netif_info(pf, drv, netdev, "offline testing starting\n");
1669
1670 set_bit(__I40E_TESTING, &pf->state);
1671
1672 if (i40e_active_vfs(pf) || i40e_active_vmdqs(pf)) {
1673 dev_warn(&pf->pdev->dev,
1674 "Please take active VFs and Netqueues offline and restart the adapter before running NIC diagnostics\n");
1675 data[I40E_ETH_TEST_REG] = 1;
1676 data[I40E_ETH_TEST_EEPROM] = 1;
1677 data[I40E_ETH_TEST_INTR] = 1;
1678 data[I40E_ETH_TEST_LOOPBACK] = 1;
1679 data[I40E_ETH_TEST_LINK] = 1;
1680 eth_test->flags |= ETH_TEST_FL_FAILED;
1681 clear_bit(__I40E_TESTING, &pf->state);
1682 goto skip_ol_tests;
1683 }
1684
1685 /* If the device is online then take it offline */
1686 if (if_running)
1687 /* indicate we're in test mode */
1688 dev_close(netdev);
1689 else
1690 /* This reset does not affect link - if it is
1691 * changed to a type of reset that does affect
1692 * link then the following link test would have
1693 * to be moved to before the reset
1694 */
1695 i40e_do_reset(pf, BIT(__I40E_PF_RESET_REQUESTED));
1696
1697 if (i40e_link_test(netdev, &data[I40E_ETH_TEST_LINK]))
1698 eth_test->flags |= ETH_TEST_FL_FAILED;
1699
1700 if (i40e_eeprom_test(netdev, &data[I40E_ETH_TEST_EEPROM]))
1701 eth_test->flags |= ETH_TEST_FL_FAILED;
1702
1703 if (i40e_intr_test(netdev, &data[I40E_ETH_TEST_INTR]))
1704 eth_test->flags |= ETH_TEST_FL_FAILED;
1705
1706 if (i40e_loopback_test(netdev, &data[I40E_ETH_TEST_LOOPBACK]))
1707 eth_test->flags |= ETH_TEST_FL_FAILED;
1708
1709 /* run reg test last, a reset is required after it */
1710 if (i40e_reg_test(netdev, &data[I40E_ETH_TEST_REG]))
1711 eth_test->flags |= ETH_TEST_FL_FAILED;
1712
1713 clear_bit(__I40E_TESTING, &pf->state);
1714 i40e_do_reset(pf, BIT(__I40E_PF_RESET_REQUESTED));
1715
1716 if (if_running)
1717 dev_open(netdev);
1718 } else {
1719 /* Online tests */
1720 netif_info(pf, drv, netdev, "online testing starting\n");
1721
1722 if (i40e_link_test(netdev, &data[I40E_ETH_TEST_LINK]))
1723 eth_test->flags |= ETH_TEST_FL_FAILED;
1724
1725 /* Offline only tests, not run in online; pass by default */
1726 data[I40E_ETH_TEST_REG] = 0;
1727 data[I40E_ETH_TEST_EEPROM] = 0;
1728 data[I40E_ETH_TEST_INTR] = 0;
1729 data[I40E_ETH_TEST_LOOPBACK] = 0;
1730 }
1731
1732 skip_ol_tests:
1733
1734 netif_info(pf, drv, netdev, "testing finished\n");
1735 }
1736
1737 static void i40e_get_wol(struct net_device *netdev,
1738 struct ethtool_wolinfo *wol)
1739 {
1740 struct i40e_netdev_priv *np = netdev_priv(netdev);
1741 struct i40e_pf *pf = np->vsi->back;
1742 struct i40e_hw *hw = &pf->hw;
1743 u16 wol_nvm_bits;
1744
1745 /* NVM bit on means WoL disabled for the port */
1746 i40e_read_nvm_word(hw, I40E_SR_NVM_WAKE_ON_LAN, &wol_nvm_bits);
1747 if ((BIT(hw->port) & wol_nvm_bits) || (hw->partition_id != 1)) {
1748 wol->supported = 0;
1749 wol->wolopts = 0;
1750 } else {
1751 wol->supported = WAKE_MAGIC;
1752 wol->wolopts = (pf->wol_en ? WAKE_MAGIC : 0);
1753 }
1754 }
1755
1756 /**
1757 * i40e_set_wol - set the WakeOnLAN configuration
1758 * @netdev: the netdev in question
1759 * @wol: the ethtool WoL setting data
1760 **/
1761 static int i40e_set_wol(struct net_device *netdev, struct ethtool_wolinfo *wol)
1762 {
1763 struct i40e_netdev_priv *np = netdev_priv(netdev);
1764 struct i40e_pf *pf = np->vsi->back;
1765 struct i40e_vsi *vsi = np->vsi;
1766 struct i40e_hw *hw = &pf->hw;
1767 u16 wol_nvm_bits;
1768
1769 /* WoL not supported if this isn't the controlling PF on the port */
1770 if (hw->partition_id != 1) {
1771 i40e_partition_setting_complaint(pf);
1772 return -EOPNOTSUPP;
1773 }
1774
1775 if (vsi != pf->vsi[pf->lan_vsi])
1776 return -EOPNOTSUPP;
1777
1778 /* NVM bit on means WoL disabled for the port */
1779 i40e_read_nvm_word(hw, I40E_SR_NVM_WAKE_ON_LAN, &wol_nvm_bits);
1780 if (BIT(hw->port) & wol_nvm_bits)
1781 return -EOPNOTSUPP;
1782
1783 /* only magic packet is supported */
1784 if (wol->wolopts && (wol->wolopts != WAKE_MAGIC))
1785 return -EOPNOTSUPP;
1786
1787 /* is this a new value? */
1788 if (pf->wol_en != !!wol->wolopts) {
1789 pf->wol_en = !!wol->wolopts;
1790 device_set_wakeup_enable(&pf->pdev->dev, pf->wol_en);
1791 }
1792
1793 return 0;
1794 }
1795
1796 static int i40e_set_phys_id(struct net_device *netdev,
1797 enum ethtool_phys_id_state state)
1798 {
1799 struct i40e_netdev_priv *np = netdev_priv(netdev);
1800 struct i40e_pf *pf = np->vsi->back;
1801 struct i40e_hw *hw = &pf->hw;
1802 int blink_freq = 2;
1803
1804 switch (state) {
1805 case ETHTOOL_ID_ACTIVE:
1806 pf->led_status = i40e_led_get(hw);
1807 return blink_freq;
1808 case ETHTOOL_ID_ON:
1809 i40e_led_set(hw, 0xF, false);
1810 break;
1811 case ETHTOOL_ID_OFF:
1812 i40e_led_set(hw, 0x0, false);
1813 break;
1814 case ETHTOOL_ID_INACTIVE:
1815 i40e_led_set(hw, pf->led_status, false);
1816 break;
1817 default:
1818 break;
1819 }
1820
1821 return 0;
1822 }
1823
1824 /* NOTE: i40e hardware uses a conversion factor of 2 for Interrupt
1825 * Throttle Rate (ITR) ie. ITR(1) = 2us ITR(10) = 20 us, and also
1826 * 125us (8000 interrupts per second) == ITR(62)
1827 */
1828
1829 static int i40e_get_coalesce(struct net_device *netdev,
1830 struct ethtool_coalesce *ec)
1831 {
1832 struct i40e_netdev_priv *np = netdev_priv(netdev);
1833 struct i40e_vsi *vsi = np->vsi;
1834
1835 ec->tx_max_coalesced_frames_irq = vsi->work_limit;
1836 ec->rx_max_coalesced_frames_irq = vsi->work_limit;
1837
1838 if (ITR_IS_DYNAMIC(vsi->rx_itr_setting))
1839 ec->use_adaptive_rx_coalesce = 1;
1840
1841 if (ITR_IS_DYNAMIC(vsi->tx_itr_setting))
1842 ec->use_adaptive_tx_coalesce = 1;
1843
1844 ec->rx_coalesce_usecs = vsi->rx_itr_setting & ~I40E_ITR_DYNAMIC;
1845 ec->tx_coalesce_usecs = vsi->tx_itr_setting & ~I40E_ITR_DYNAMIC;
1846
1847 return 0;
1848 }
1849
1850 static int i40e_set_coalesce(struct net_device *netdev,
1851 struct ethtool_coalesce *ec)
1852 {
1853 struct i40e_netdev_priv *np = netdev_priv(netdev);
1854 struct i40e_q_vector *q_vector;
1855 struct i40e_vsi *vsi = np->vsi;
1856 struct i40e_pf *pf = vsi->back;
1857 struct i40e_hw *hw = &pf->hw;
1858 u16 vector;
1859 int i;
1860
1861 if (ec->tx_max_coalesced_frames_irq || ec->rx_max_coalesced_frames_irq)
1862 vsi->work_limit = ec->tx_max_coalesced_frames_irq;
1863
1864 vector = vsi->base_vector;
1865 if ((ec->rx_coalesce_usecs >= (I40E_MIN_ITR << 1)) &&
1866 (ec->rx_coalesce_usecs <= (I40E_MAX_ITR << 1))) {
1867 vsi->rx_itr_setting = ec->rx_coalesce_usecs;
1868 } else if (ec->rx_coalesce_usecs == 0) {
1869 vsi->rx_itr_setting = ec->rx_coalesce_usecs;
1870 if (ec->use_adaptive_rx_coalesce)
1871 netif_info(pf, drv, netdev, "rx-usecs=0, need to disable adaptive-rx for a complete disable\n");
1872 } else {
1873 netif_info(pf, drv, netdev, "Invalid value, rx-usecs range is 0-8160\n");
1874 return -EINVAL;
1875 }
1876
1877 if ((ec->tx_coalesce_usecs >= (I40E_MIN_ITR << 1)) &&
1878 (ec->tx_coalesce_usecs <= (I40E_MAX_ITR << 1))) {
1879 vsi->tx_itr_setting = ec->tx_coalesce_usecs;
1880 } else if (ec->tx_coalesce_usecs == 0) {
1881 vsi->tx_itr_setting = ec->tx_coalesce_usecs;
1882 if (ec->use_adaptive_tx_coalesce)
1883 netif_info(pf, drv, netdev, "tx-usecs=0, need to disable adaptive-tx for a complete disable\n");
1884 } else {
1885 netif_info(pf, drv, netdev,
1886 "Invalid value, tx-usecs range is 0-8160\n");
1887 return -EINVAL;
1888 }
1889
1890 if (ec->use_adaptive_rx_coalesce)
1891 vsi->rx_itr_setting |= I40E_ITR_DYNAMIC;
1892 else
1893 vsi->rx_itr_setting &= ~I40E_ITR_DYNAMIC;
1894
1895 if (ec->use_adaptive_tx_coalesce)
1896 vsi->tx_itr_setting |= I40E_ITR_DYNAMIC;
1897 else
1898 vsi->tx_itr_setting &= ~I40E_ITR_DYNAMIC;
1899
1900 for (i = 0; i < vsi->num_q_vectors; i++, vector++) {
1901 q_vector = vsi->q_vectors[i];
1902 q_vector->rx.itr = ITR_TO_REG(vsi->rx_itr_setting);
1903 wr32(hw, I40E_PFINT_ITRN(0, vector - 1), q_vector->rx.itr);
1904 q_vector->tx.itr = ITR_TO_REG(vsi->tx_itr_setting);
1905 wr32(hw, I40E_PFINT_ITRN(1, vector - 1), q_vector->tx.itr);
1906 i40e_flush(hw);
1907 }
1908
1909 return 0;
1910 }
1911
1912 /**
1913 * i40e_get_rss_hash_opts - Get RSS hash Input Set for each flow type
1914 * @pf: pointer to the physical function struct
1915 * @cmd: ethtool rxnfc command
1916 *
1917 * Returns Success if the flow is supported, else Invalid Input.
1918 **/
1919 static int i40e_get_rss_hash_opts(struct i40e_pf *pf, struct ethtool_rxnfc *cmd)
1920 {
1921 cmd->data = 0;
1922
1923 if (pf->vsi[pf->lan_vsi]->rxnfc.data != 0) {
1924 cmd->data = pf->vsi[pf->lan_vsi]->rxnfc.data;
1925 cmd->flow_type = pf->vsi[pf->lan_vsi]->rxnfc.flow_type;
1926 return 0;
1927 }
1928 /* Report default options for RSS on i40e */
1929 switch (cmd->flow_type) {
1930 case TCP_V4_FLOW:
1931 case UDP_V4_FLOW:
1932 cmd->data |= RXH_L4_B_0_1 | RXH_L4_B_2_3;
1933 /* fall through to add IP fields */
1934 case SCTP_V4_FLOW:
1935 case AH_ESP_V4_FLOW:
1936 case AH_V4_FLOW:
1937 case ESP_V4_FLOW:
1938 case IPV4_FLOW:
1939 cmd->data |= RXH_IP_SRC | RXH_IP_DST;
1940 break;
1941 case TCP_V6_FLOW:
1942 case UDP_V6_FLOW:
1943 cmd->data |= RXH_L4_B_0_1 | RXH_L4_B_2_3;
1944 /* fall through to add IP fields */
1945 case SCTP_V6_FLOW:
1946 case AH_ESP_V6_FLOW:
1947 case AH_V6_FLOW:
1948 case ESP_V6_FLOW:
1949 case IPV6_FLOW:
1950 cmd->data |= RXH_IP_SRC | RXH_IP_DST;
1951 break;
1952 default:
1953 return -EINVAL;
1954 }
1955
1956 return 0;
1957 }
1958
1959 /**
1960 * i40e_get_ethtool_fdir_all - Populates the rule count of a command
1961 * @pf: Pointer to the physical function struct
1962 * @cmd: The command to get or set Rx flow classification rules
1963 * @rule_locs: Array of used rule locations
1964 *
1965 * This function populates both the total and actual rule count of
1966 * the ethtool flow classification command
1967 *
1968 * Returns 0 on success or -EMSGSIZE if entry not found
1969 **/
1970 static int i40e_get_ethtool_fdir_all(struct i40e_pf *pf,
1971 struct ethtool_rxnfc *cmd,
1972 u32 *rule_locs)
1973 {
1974 struct i40e_fdir_filter *rule;
1975 struct hlist_node *node2;
1976 int cnt = 0;
1977
1978 /* report total rule count */
1979 cmd->data = i40e_get_fd_cnt_all(pf);
1980
1981 hlist_for_each_entry_safe(rule, node2,
1982 &pf->fdir_filter_list, fdir_node) {
1983 if (cnt == cmd->rule_cnt)
1984 return -EMSGSIZE;
1985
1986 rule_locs[cnt] = rule->fd_id;
1987 cnt++;
1988 }
1989
1990 cmd->rule_cnt = cnt;
1991
1992 return 0;
1993 }
1994
1995 /**
1996 * i40e_get_ethtool_fdir_entry - Look up a filter based on Rx flow
1997 * @pf: Pointer to the physical function struct
1998 * @cmd: The command to get or set Rx flow classification rules
1999 *
2000 * This function looks up a filter based on the Rx flow classification
2001 * command and fills the flow spec info for it if found
2002 *
2003 * Returns 0 on success or -EINVAL if filter not found
2004 **/
2005 static int i40e_get_ethtool_fdir_entry(struct i40e_pf *pf,
2006 struct ethtool_rxnfc *cmd)
2007 {
2008 struct ethtool_rx_flow_spec *fsp =
2009 (struct ethtool_rx_flow_spec *)&cmd->fs;
2010 struct i40e_fdir_filter *rule = NULL;
2011 struct hlist_node *node2;
2012
2013 hlist_for_each_entry_safe(rule, node2,
2014 &pf->fdir_filter_list, fdir_node) {
2015 if (fsp->location <= rule->fd_id)
2016 break;
2017 }
2018
2019 if (!rule || fsp->location != rule->fd_id)
2020 return -EINVAL;
2021
2022 fsp->flow_type = rule->flow_type;
2023 if (fsp->flow_type == IP_USER_FLOW) {
2024 fsp->h_u.usr_ip4_spec.ip_ver = ETH_RX_NFC_IP4;
2025 fsp->h_u.usr_ip4_spec.proto = 0;
2026 fsp->m_u.usr_ip4_spec.proto = 0;
2027 }
2028
2029 /* Reverse the src and dest notion, since the HW views them from
2030 * Tx perspective where as the user expects it from Rx filter view.
2031 */
2032 fsp->h_u.tcp_ip4_spec.psrc = rule->dst_port;
2033 fsp->h_u.tcp_ip4_spec.pdst = rule->src_port;
2034 fsp->h_u.tcp_ip4_spec.ip4src = rule->dst_ip[0];
2035 fsp->h_u.tcp_ip4_spec.ip4dst = rule->src_ip[0];
2036
2037 if (rule->dest_ctl == I40E_FILTER_PROGRAM_DESC_DEST_DROP_PACKET)
2038 fsp->ring_cookie = RX_CLS_FLOW_DISC;
2039 else
2040 fsp->ring_cookie = rule->q_index;
2041
2042 if (rule->dest_vsi != pf->vsi[pf->lan_vsi]->id) {
2043 struct i40e_vsi *vsi;
2044
2045 vsi = i40e_find_vsi_from_id(pf, rule->dest_vsi);
2046 if (vsi && vsi->type == I40E_VSI_SRIOV) {
2047 fsp->h_ext.data[1] = htonl(vsi->vf_id);
2048 fsp->m_ext.data[1] = htonl(0x1);
2049 }
2050 }
2051
2052 return 0;
2053 }
2054
2055 /**
2056 * i40e_get_rxnfc - command to get RX flow classification rules
2057 * @netdev: network interface device structure
2058 * @cmd: ethtool rxnfc command
2059 *
2060 * Returns Success if the command is supported.
2061 **/
2062 static int i40e_get_rxnfc(struct net_device *netdev, struct ethtool_rxnfc *cmd,
2063 u32 *rule_locs)
2064 {
2065 struct i40e_netdev_priv *np = netdev_priv(netdev);
2066 struct i40e_vsi *vsi = np->vsi;
2067 struct i40e_pf *pf = vsi->back;
2068 int ret = -EOPNOTSUPP;
2069
2070 switch (cmd->cmd) {
2071 case ETHTOOL_GRXRINGS:
2072 cmd->data = vsi->alloc_queue_pairs;
2073 ret = 0;
2074 break;
2075 case ETHTOOL_GRXFH:
2076 ret = i40e_get_rss_hash_opts(pf, cmd);
2077 break;
2078 case ETHTOOL_GRXCLSRLCNT:
2079 cmd->rule_cnt = pf->fdir_pf_active_filters;
2080 /* report total rule count */
2081 cmd->data = i40e_get_fd_cnt_all(pf);
2082 ret = 0;
2083 break;
2084 case ETHTOOL_GRXCLSRULE:
2085 ret = i40e_get_ethtool_fdir_entry(pf, cmd);
2086 break;
2087 case ETHTOOL_GRXCLSRLALL:
2088 ret = i40e_get_ethtool_fdir_all(pf, cmd, rule_locs);
2089 break;
2090 default:
2091 break;
2092 }
2093
2094 return ret;
2095 }
2096
2097 /**
2098 * i40e_set_rss_hash_opt - Enable/Disable flow types for RSS hash
2099 * @pf: pointer to the physical function struct
2100 * @cmd: ethtool rxnfc command
2101 *
2102 * Returns Success if the flow input set is supported.
2103 **/
2104 static int i40e_set_rss_hash_opt(struct i40e_pf *pf, struct ethtool_rxnfc *nfc)
2105 {
2106 struct i40e_hw *hw = &pf->hw;
2107 u64 hena = (u64)rd32(hw, I40E_PFQF_HENA(0)) |
2108 ((u64)rd32(hw, I40E_PFQF_HENA(1)) << 32);
2109
2110 /* RSS does not support anything other than hashing
2111 * to queues on src and dst IPs and ports
2112 */
2113 if (nfc->data & ~(RXH_IP_SRC | RXH_IP_DST |
2114 RXH_L4_B_0_1 | RXH_L4_B_2_3))
2115 return -EINVAL;
2116
2117 /* We need at least the IP SRC and DEST fields for hashing */
2118 if (!(nfc->data & RXH_IP_SRC) ||
2119 !(nfc->data & RXH_IP_DST))
2120 return -EINVAL;
2121
2122 switch (nfc->flow_type) {
2123 case TCP_V4_FLOW:
2124 switch (nfc->data & (RXH_L4_B_0_1 | RXH_L4_B_2_3)) {
2125 case 0:
2126 hena &= ~BIT_ULL(I40E_FILTER_PCTYPE_NONF_IPV4_TCP);
2127 break;
2128 case (RXH_L4_B_0_1 | RXH_L4_B_2_3):
2129 hena |= BIT_ULL(I40E_FILTER_PCTYPE_NONF_IPV4_TCP);
2130 break;
2131 default:
2132 return -EINVAL;
2133 }
2134 break;
2135 case TCP_V6_FLOW:
2136 switch (nfc->data & (RXH_L4_B_0_1 | RXH_L4_B_2_3)) {
2137 case 0:
2138 hena &= ~BIT_ULL(I40E_FILTER_PCTYPE_NONF_IPV6_TCP);
2139 break;
2140 case (RXH_L4_B_0_1 | RXH_L4_B_2_3):
2141 hena |= BIT_ULL(I40E_FILTER_PCTYPE_NONF_IPV6_TCP);
2142 break;
2143 default:
2144 return -EINVAL;
2145 }
2146 break;
2147 case UDP_V4_FLOW:
2148 switch (nfc->data & (RXH_L4_B_0_1 | RXH_L4_B_2_3)) {
2149 case 0:
2150 hena &= ~(BIT_ULL(I40E_FILTER_PCTYPE_NONF_IPV4_UDP) |
2151 BIT_ULL(I40E_FILTER_PCTYPE_FRAG_IPV4));
2152 break;
2153 case (RXH_L4_B_0_1 | RXH_L4_B_2_3):
2154 hena |= (BIT_ULL(I40E_FILTER_PCTYPE_NONF_IPV4_UDP) |
2155 BIT_ULL(I40E_FILTER_PCTYPE_FRAG_IPV4));
2156 break;
2157 default:
2158 return -EINVAL;
2159 }
2160 break;
2161 case UDP_V6_FLOW:
2162 switch (nfc->data & (RXH_L4_B_0_1 | RXH_L4_B_2_3)) {
2163 case 0:
2164 hena &= ~(BIT_ULL(I40E_FILTER_PCTYPE_NONF_IPV6_UDP) |
2165 BIT_ULL(I40E_FILTER_PCTYPE_FRAG_IPV6));
2166 break;
2167 case (RXH_L4_B_0_1 | RXH_L4_B_2_3):
2168 hena |= (BIT_ULL(I40E_FILTER_PCTYPE_NONF_IPV6_UDP) |
2169 BIT_ULL(I40E_FILTER_PCTYPE_FRAG_IPV6));
2170 break;
2171 default:
2172 return -EINVAL;
2173 }
2174 break;
2175 case AH_ESP_V4_FLOW:
2176 case AH_V4_FLOW:
2177 case ESP_V4_FLOW:
2178 case SCTP_V4_FLOW:
2179 if ((nfc->data & RXH_L4_B_0_1) ||
2180 (nfc->data & RXH_L4_B_2_3))
2181 return -EINVAL;
2182 hena |= BIT_ULL(I40E_FILTER_PCTYPE_NONF_IPV4_OTHER);
2183 break;
2184 case AH_ESP_V6_FLOW:
2185 case AH_V6_FLOW:
2186 case ESP_V6_FLOW:
2187 case SCTP_V6_FLOW:
2188 if ((nfc->data & RXH_L4_B_0_1) ||
2189 (nfc->data & RXH_L4_B_2_3))
2190 return -EINVAL;
2191 hena |= BIT_ULL(I40E_FILTER_PCTYPE_NONF_IPV6_OTHER);
2192 break;
2193 case IPV4_FLOW:
2194 hena |= BIT_ULL(I40E_FILTER_PCTYPE_NONF_IPV4_OTHER) |
2195 BIT_ULL(I40E_FILTER_PCTYPE_FRAG_IPV4);
2196 break;
2197 case IPV6_FLOW:
2198 hena |= BIT_ULL(I40E_FILTER_PCTYPE_NONF_IPV6_OTHER) |
2199 BIT_ULL(I40E_FILTER_PCTYPE_FRAG_IPV6);
2200 break;
2201 default:
2202 return -EINVAL;
2203 }
2204
2205 wr32(hw, I40E_PFQF_HENA(0), (u32)hena);
2206 wr32(hw, I40E_PFQF_HENA(1), (u32)(hena >> 32));
2207 i40e_flush(hw);
2208
2209 /* Save setting for future output/update */
2210 pf->vsi[pf->lan_vsi]->rxnfc = *nfc;
2211
2212 return 0;
2213 }
2214
2215 /**
2216 * i40e_match_fdir_input_set - Match a new filter against an existing one
2217 * @rule: The filter already added
2218 * @input: The new filter to comapre against
2219 *
2220 * Returns true if the two input set match
2221 **/
2222 static bool i40e_match_fdir_input_set(struct i40e_fdir_filter *rule,
2223 struct i40e_fdir_filter *input)
2224 {
2225 if ((rule->dst_ip[0] != input->dst_ip[0]) ||
2226 (rule->src_ip[0] != input->src_ip[0]) ||
2227 (rule->dst_port != input->dst_port) ||
2228 (rule->src_port != input->src_port))
2229 return false;
2230 return true;
2231 }
2232
2233 /**
2234 * i40e_update_ethtool_fdir_entry - Updates the fdir filter entry
2235 * @vsi: Pointer to the targeted VSI
2236 * @input: The filter to update or NULL to indicate deletion
2237 * @sw_idx: Software index to the filter
2238 * @cmd: The command to get or set Rx flow classification rules
2239 *
2240 * This function updates (or deletes) a Flow Director entry from
2241 * the hlist of the corresponding PF
2242 *
2243 * Returns 0 on success
2244 **/
2245 static int i40e_update_ethtool_fdir_entry(struct i40e_vsi *vsi,
2246 struct i40e_fdir_filter *input,
2247 u16 sw_idx,
2248 struct ethtool_rxnfc *cmd)
2249 {
2250 struct i40e_fdir_filter *rule, *parent;
2251 struct i40e_pf *pf = vsi->back;
2252 struct hlist_node *node2;
2253 int err = -EINVAL;
2254
2255 parent = NULL;
2256 rule = NULL;
2257
2258 hlist_for_each_entry_safe(rule, node2,
2259 &pf->fdir_filter_list, fdir_node) {
2260 /* hash found, or no matching entry */
2261 if (rule->fd_id >= sw_idx)
2262 break;
2263 parent = rule;
2264 }
2265
2266 /* if there is an old rule occupying our place remove it */
2267 if (rule && (rule->fd_id == sw_idx)) {
2268 if (input && !i40e_match_fdir_input_set(rule, input))
2269 err = i40e_add_del_fdir(vsi, rule, false);
2270 else if (!input)
2271 err = i40e_add_del_fdir(vsi, rule, false);
2272 hlist_del(&rule->fdir_node);
2273 kfree(rule);
2274 pf->fdir_pf_active_filters--;
2275 }
2276
2277 /* If no input this was a delete, err should be 0 if a rule was
2278 * successfully found and removed from the list else -EINVAL
2279 */
2280 if (!input)
2281 return err;
2282
2283 /* initialize node and set software index */
2284 INIT_HLIST_NODE(&input->fdir_node);
2285
2286 /* add filter to the list */
2287 if (parent)
2288 hlist_add_behind(&input->fdir_node, &parent->fdir_node);
2289 else
2290 hlist_add_head(&input->fdir_node,
2291 &pf->fdir_filter_list);
2292
2293 /* update counts */
2294 pf->fdir_pf_active_filters++;
2295
2296 return 0;
2297 }
2298
2299 /**
2300 * i40e_del_fdir_entry - Deletes a Flow Director filter entry
2301 * @vsi: Pointer to the targeted VSI
2302 * @cmd: The command to get or set Rx flow classification rules
2303 *
2304 * The function removes a Flow Director filter entry from the
2305 * hlist of the corresponding PF
2306 *
2307 * Returns 0 on success
2308 */
2309 static int i40e_del_fdir_entry(struct i40e_vsi *vsi,
2310 struct ethtool_rxnfc *cmd)
2311 {
2312 struct ethtool_rx_flow_spec *fsp =
2313 (struct ethtool_rx_flow_spec *)&cmd->fs;
2314 struct i40e_pf *pf = vsi->back;
2315 int ret = 0;
2316
2317 if (test_bit(__I40E_RESET_RECOVERY_PENDING, &pf->state) ||
2318 test_bit(__I40E_RESET_INTR_RECEIVED, &pf->state))
2319 return -EBUSY;
2320
2321 if (test_bit(__I40E_FD_FLUSH_REQUESTED, &pf->state))
2322 return -EBUSY;
2323
2324 ret = i40e_update_ethtool_fdir_entry(vsi, NULL, fsp->location, cmd);
2325
2326 i40e_fdir_check_and_reenable(pf);
2327 return ret;
2328 }
2329
2330 /**
2331 * i40e_add_fdir_ethtool - Add/Remove Flow Director filters
2332 * @vsi: pointer to the targeted VSI
2333 * @cmd: command to get or set RX flow classification rules
2334 *
2335 * Add Flow Director filters for a specific flow spec based on their
2336 * protocol. Returns 0 if the filters were successfully added.
2337 **/
2338 static int i40e_add_fdir_ethtool(struct i40e_vsi *vsi,
2339 struct ethtool_rxnfc *cmd)
2340 {
2341 struct ethtool_rx_flow_spec *fsp;
2342 struct i40e_fdir_filter *input;
2343 struct i40e_pf *pf;
2344 int ret = -EINVAL;
2345 u16 vf_id;
2346
2347 if (!vsi)
2348 return -EINVAL;
2349
2350 pf = vsi->back;
2351
2352 if (!(pf->flags & I40E_FLAG_FD_SB_ENABLED))
2353 return -EOPNOTSUPP;
2354
2355 if (pf->auto_disable_flags & I40E_FLAG_FD_SB_ENABLED)
2356 return -ENOSPC;
2357
2358 if (test_bit(__I40E_RESET_RECOVERY_PENDING, &pf->state) ||
2359 test_bit(__I40E_RESET_INTR_RECEIVED, &pf->state))
2360 return -EBUSY;
2361
2362 if (test_bit(__I40E_FD_FLUSH_REQUESTED, &pf->state))
2363 return -EBUSY;
2364
2365 fsp = (struct ethtool_rx_flow_spec *)&cmd->fs;
2366
2367 if (fsp->location >= (pf->hw.func_caps.fd_filters_best_effort +
2368 pf->hw.func_caps.fd_filters_guaranteed)) {
2369 return -EINVAL;
2370 }
2371
2372 if ((fsp->ring_cookie != RX_CLS_FLOW_DISC) &&
2373 (fsp->ring_cookie >= vsi->num_queue_pairs))
2374 return -EINVAL;
2375
2376 input = kzalloc(sizeof(*input), GFP_KERNEL);
2377
2378 if (!input)
2379 return -ENOMEM;
2380
2381 input->fd_id = fsp->location;
2382
2383 if (fsp->ring_cookie == RX_CLS_FLOW_DISC)
2384 input->dest_ctl = I40E_FILTER_PROGRAM_DESC_DEST_DROP_PACKET;
2385 else
2386 input->dest_ctl =
2387 I40E_FILTER_PROGRAM_DESC_DEST_DIRECT_PACKET_QINDEX;
2388
2389 input->q_index = fsp->ring_cookie;
2390 input->flex_off = 0;
2391 input->pctype = 0;
2392 input->dest_vsi = vsi->id;
2393 input->fd_status = I40E_FILTER_PROGRAM_DESC_FD_STATUS_FD_ID;
2394 input->cnt_index = I40E_FD_SB_STAT_IDX(pf->hw.pf_id);
2395 input->flow_type = fsp->flow_type;
2396 input->ip4_proto = fsp->h_u.usr_ip4_spec.proto;
2397
2398 /* Reverse the src and dest notion, since the HW expects them to be from
2399 * Tx perspective where as the input from user is from Rx filter view.
2400 */
2401 input->dst_port = fsp->h_u.tcp_ip4_spec.psrc;
2402 input->src_port = fsp->h_u.tcp_ip4_spec.pdst;
2403 input->dst_ip[0] = fsp->h_u.tcp_ip4_spec.ip4src;
2404 input->src_ip[0] = fsp->h_u.tcp_ip4_spec.ip4dst;
2405
2406 if (ntohl(fsp->m_ext.data[1])) {
2407 if (ntohl(fsp->h_ext.data[1]) >= pf->num_alloc_vfs) {
2408 netif_info(pf, drv, vsi->netdev, "Invalid VF id\n");
2409 goto free_input;
2410 }
2411 vf_id = ntohl(fsp->h_ext.data[1]);
2412 /* Find vsi id from vf id and override dest vsi */
2413 input->dest_vsi = pf->vf[vf_id].lan_vsi_id;
2414 if (input->q_index >= pf->vf[vf_id].num_queue_pairs) {
2415 netif_info(pf, drv, vsi->netdev, "Invalid queue id\n");
2416 goto free_input;
2417 }
2418 }
2419
2420 ret = i40e_add_del_fdir(vsi, input, true);
2421 free_input:
2422 if (ret)
2423 kfree(input);
2424 else
2425 i40e_update_ethtool_fdir_entry(vsi, input, fsp->location, NULL);
2426
2427 return ret;
2428 }
2429
2430 /**
2431 * i40e_set_rxnfc - command to set RX flow classification rules
2432 * @netdev: network interface device structure
2433 * @cmd: ethtool rxnfc command
2434 *
2435 * Returns Success if the command is supported.
2436 **/
2437 static int i40e_set_rxnfc(struct net_device *netdev, struct ethtool_rxnfc *cmd)
2438 {
2439 struct i40e_netdev_priv *np = netdev_priv(netdev);
2440 struct i40e_vsi *vsi = np->vsi;
2441 struct i40e_pf *pf = vsi->back;
2442 int ret = -EOPNOTSUPP;
2443
2444 switch (cmd->cmd) {
2445 case ETHTOOL_SRXFH:
2446 ret = i40e_set_rss_hash_opt(pf, cmd);
2447 break;
2448 case ETHTOOL_SRXCLSRLINS:
2449 ret = i40e_add_fdir_ethtool(vsi, cmd);
2450 break;
2451 case ETHTOOL_SRXCLSRLDEL:
2452 ret = i40e_del_fdir_entry(vsi, cmd);
2453 break;
2454 default:
2455 break;
2456 }
2457
2458 return ret;
2459 }
2460
2461 /**
2462 * i40e_max_channels - get Max number of combined channels supported
2463 * @vsi: vsi pointer
2464 **/
2465 static unsigned int i40e_max_channels(struct i40e_vsi *vsi)
2466 {
2467 /* TODO: This code assumes DCB and FD is disabled for now. */
2468 return vsi->alloc_queue_pairs;
2469 }
2470
2471 /**
2472 * i40e_get_channels - Get the current channels enabled and max supported etc.
2473 * @netdev: network interface device structure
2474 * @ch: ethtool channels structure
2475 *
2476 * We don't support separate tx and rx queues as channels. The other count
2477 * represents how many queues are being used for control. max_combined counts
2478 * how many queue pairs we can support. They may not be mapped 1 to 1 with
2479 * q_vectors since we support a lot more queue pairs than q_vectors.
2480 **/
2481 static void i40e_get_channels(struct net_device *dev,
2482 struct ethtool_channels *ch)
2483 {
2484 struct i40e_netdev_priv *np = netdev_priv(dev);
2485 struct i40e_vsi *vsi = np->vsi;
2486 struct i40e_pf *pf = vsi->back;
2487
2488 /* report maximum channels */
2489 ch->max_combined = i40e_max_channels(vsi);
2490
2491 /* report info for other vector */
2492 ch->other_count = (pf->flags & I40E_FLAG_FD_SB_ENABLED) ? 1 : 0;
2493 ch->max_other = ch->other_count;
2494
2495 /* Note: This code assumes DCB is disabled for now. */
2496 ch->combined_count = vsi->num_queue_pairs;
2497 }
2498
2499 /**
2500 * i40e_set_channels - Set the new channels count.
2501 * @netdev: network interface device structure
2502 * @ch: ethtool channels structure
2503 *
2504 * The new channels count may not be the same as requested by the user
2505 * since it gets rounded down to a power of 2 value.
2506 **/
2507 static int i40e_set_channels(struct net_device *dev,
2508 struct ethtool_channels *ch)
2509 {
2510 struct i40e_netdev_priv *np = netdev_priv(dev);
2511 unsigned int count = ch->combined_count;
2512 struct i40e_vsi *vsi = np->vsi;
2513 struct i40e_pf *pf = vsi->back;
2514 int new_count;
2515
2516 /* We do not support setting channels for any other VSI at present */
2517 if (vsi->type != I40E_VSI_MAIN)
2518 return -EINVAL;
2519
2520 /* verify they are not requesting separate vectors */
2521 if (!count || ch->rx_count || ch->tx_count)
2522 return -EINVAL;
2523
2524 /* verify other_count has not changed */
2525 if (ch->other_count != ((pf->flags & I40E_FLAG_FD_SB_ENABLED) ? 1 : 0))
2526 return -EINVAL;
2527
2528 /* verify the number of channels does not exceed hardware limits */
2529 if (count > i40e_max_channels(vsi))
2530 return -EINVAL;
2531
2532 /* update feature limits from largest to smallest supported values */
2533 /* TODO: Flow director limit, DCB etc */
2534
2535 /* use rss_reconfig to rebuild with new queue count and update traffic
2536 * class queue mapping
2537 */
2538 new_count = i40e_reconfig_rss_queues(pf, count);
2539 if (new_count > 0)
2540 return 0;
2541 else
2542 return -EINVAL;
2543 }
2544
2545 #define I40E_HLUT_ARRAY_SIZE ((I40E_PFQF_HLUT_MAX_INDEX + 1) * 4)
2546 /**
2547 * i40e_get_rxfh_key_size - get the RSS hash key size
2548 * @netdev: network interface device structure
2549 *
2550 * Returns the table size.
2551 **/
2552 static u32 i40e_get_rxfh_key_size(struct net_device *netdev)
2553 {
2554 return I40E_HKEY_ARRAY_SIZE;
2555 }
2556
2557 /**
2558 * i40e_get_rxfh_indir_size - get the rx flow hash indirection table size
2559 * @netdev: network interface device structure
2560 *
2561 * Returns the table size.
2562 **/
2563 static u32 i40e_get_rxfh_indir_size(struct net_device *netdev)
2564 {
2565 return I40E_HLUT_ARRAY_SIZE;
2566 }
2567
2568 static int i40e_get_rxfh(struct net_device *netdev, u32 *indir, u8 *key,
2569 u8 *hfunc)
2570 {
2571 struct i40e_netdev_priv *np = netdev_priv(netdev);
2572 struct i40e_vsi *vsi = np->vsi;
2573 struct i40e_pf *pf = vsi->back;
2574 struct i40e_hw *hw = &pf->hw;
2575 u32 reg_val;
2576 int i, j;
2577
2578 if (hfunc)
2579 *hfunc = ETH_RSS_HASH_TOP;
2580
2581 if (!indir)
2582 return 0;
2583
2584 for (i = 0, j = 0; i <= I40E_PFQF_HLUT_MAX_INDEX; i++) {
2585 reg_val = rd32(hw, I40E_PFQF_HLUT(i));
2586 indir[j++] = reg_val & 0xff;
2587 indir[j++] = (reg_val >> 8) & 0xff;
2588 indir[j++] = (reg_val >> 16) & 0xff;
2589 indir[j++] = (reg_val >> 24) & 0xff;
2590 }
2591
2592 if (key) {
2593 for (i = 0, j = 0; i <= I40E_PFQF_HKEY_MAX_INDEX; i++) {
2594 reg_val = rd32(hw, I40E_PFQF_HKEY(i));
2595 key[j++] = (u8)(reg_val & 0xff);
2596 key[j++] = (u8)((reg_val >> 8) & 0xff);
2597 key[j++] = (u8)((reg_val >> 16) & 0xff);
2598 key[j++] = (u8)((reg_val >> 24) & 0xff);
2599 }
2600 }
2601 return 0;
2602 }
2603
2604 /**
2605 * i40e_set_rxfh - set the rx flow hash indirection table
2606 * @netdev: network interface device structure
2607 * @indir: indirection table
2608 * @key: hash key
2609 *
2610 * Returns -EINVAL if the table specifies an invalid queue id, otherwise
2611 * returns 0 after programming the table.
2612 **/
2613 static int i40e_set_rxfh(struct net_device *netdev, const u32 *indir,
2614 const u8 *key, const u8 hfunc)
2615 {
2616 struct i40e_netdev_priv *np = netdev_priv(netdev);
2617 struct i40e_vsi *vsi = np->vsi;
2618 struct i40e_pf *pf = vsi->back;
2619 struct i40e_hw *hw = &pf->hw;
2620 u32 reg_val;
2621 int i, j;
2622
2623 if (hfunc != ETH_RSS_HASH_NO_CHANGE && hfunc != ETH_RSS_HASH_TOP)
2624 return -EOPNOTSUPP;
2625
2626 if (!indir)
2627 return 0;
2628
2629 for (i = 0, j = 0; i <= I40E_PFQF_HLUT_MAX_INDEX; i++) {
2630 reg_val = indir[j++];
2631 reg_val |= indir[j++] << 8;
2632 reg_val |= indir[j++] << 16;
2633 reg_val |= indir[j++] << 24;
2634 wr32(hw, I40E_PFQF_HLUT(i), reg_val);
2635 }
2636
2637 if (key) {
2638 for (i = 0, j = 0; i <= I40E_PFQF_HKEY_MAX_INDEX; i++) {
2639 reg_val = key[j++];
2640 reg_val |= key[j++] << 8;
2641 reg_val |= key[j++] << 16;
2642 reg_val |= key[j++] << 24;
2643 wr32(hw, I40E_PFQF_HKEY(i), reg_val);
2644 }
2645 }
2646 return 0;
2647 }
2648
2649 /**
2650 * i40e_get_priv_flags - report device private flags
2651 * @dev: network interface device structure
2652 *
2653 * The get string set count and the string set should be matched for each
2654 * flag returned. Add new strings for each flag to the i40e_priv_flags_strings
2655 * array.
2656 *
2657 * Returns a u32 bitmap of flags.
2658 **/
2659 static u32 i40e_get_priv_flags(struct net_device *dev)
2660 {
2661 struct i40e_netdev_priv *np = netdev_priv(dev);
2662 struct i40e_vsi *vsi = np->vsi;
2663 struct i40e_pf *pf = vsi->back;
2664 u32 ret_flags = 0;
2665
2666 ret_flags |= pf->hw.func_caps.npar_enable ?
2667 I40E_PRIV_FLAGS_NPAR_FLAG : 0;
2668 ret_flags |= pf->flags & I40E_FLAG_LINK_POLLING_ENABLED ?
2669 I40E_PRIV_FLAGS_LINKPOLL_FLAG : 0;
2670 ret_flags |= pf->flags & I40E_FLAG_FD_ATR_ENABLED ?
2671 I40E_PRIV_FLAGS_FD_ATR : 0;
2672
2673 return ret_flags;
2674 }
2675
2676 /**
2677 * i40e_set_priv_flags - set private flags
2678 * @dev: network interface device structure
2679 * @flags: bit flags to be set
2680 **/
2681 static int i40e_set_priv_flags(struct net_device *dev, u32 flags)
2682 {
2683 struct i40e_netdev_priv *np = netdev_priv(dev);
2684 struct i40e_vsi *vsi = np->vsi;
2685 struct i40e_pf *pf = vsi->back;
2686
2687 if (flags & I40E_PRIV_FLAGS_LINKPOLL_FLAG)
2688 pf->flags |= I40E_FLAG_LINK_POLLING_ENABLED;
2689 else
2690 pf->flags &= ~I40E_FLAG_LINK_POLLING_ENABLED;
2691
2692 /* allow the user to control the state of the Flow
2693 * Director ATR (Application Targeted Routing) feature
2694 * of the driver
2695 */
2696 if (flags & I40E_PRIV_FLAGS_FD_ATR) {
2697 pf->flags |= I40E_FLAG_FD_ATR_ENABLED;
2698 } else {
2699 pf->flags &= ~I40E_FLAG_FD_ATR_ENABLED;
2700 pf->auto_disable_flags |= I40E_FLAG_FD_ATR_ENABLED;
2701 }
2702
2703 return 0;
2704 }
2705
2706 static const struct ethtool_ops i40e_ethtool_ops = {
2707 .get_settings = i40e_get_settings,
2708 .set_settings = i40e_set_settings,
2709 .get_drvinfo = i40e_get_drvinfo,
2710 .get_regs_len = i40e_get_regs_len,
2711 .get_regs = i40e_get_regs,
2712 .nway_reset = i40e_nway_reset,
2713 .get_link = ethtool_op_get_link,
2714 .get_wol = i40e_get_wol,
2715 .set_wol = i40e_set_wol,
2716 .set_eeprom = i40e_set_eeprom,
2717 .get_eeprom_len = i40e_get_eeprom_len,
2718 .get_eeprom = i40e_get_eeprom,
2719 .get_ringparam = i40e_get_ringparam,
2720 .set_ringparam = i40e_set_ringparam,
2721 .get_pauseparam = i40e_get_pauseparam,
2722 .set_pauseparam = i40e_set_pauseparam,
2723 .get_msglevel = i40e_get_msglevel,
2724 .set_msglevel = i40e_set_msglevel,
2725 .get_rxnfc = i40e_get_rxnfc,
2726 .set_rxnfc = i40e_set_rxnfc,
2727 .self_test = i40e_diag_test,
2728 .get_strings = i40e_get_strings,
2729 .set_phys_id = i40e_set_phys_id,
2730 .get_sset_count = i40e_get_sset_count,
2731 .get_ethtool_stats = i40e_get_ethtool_stats,
2732 .get_coalesce = i40e_get_coalesce,
2733 .set_coalesce = i40e_set_coalesce,
2734 .get_rxfh_key_size = i40e_get_rxfh_key_size,
2735 .get_rxfh_indir_size = i40e_get_rxfh_indir_size,
2736 .get_rxfh = i40e_get_rxfh,
2737 .set_rxfh = i40e_set_rxfh,
2738 .get_channels = i40e_get_channels,
2739 .set_channels = i40e_set_channels,
2740 .get_ts_info = i40e_get_ts_info,
2741 .get_priv_flags = i40e_get_priv_flags,
2742 .set_priv_flags = i40e_set_priv_flags,
2743 };
2744
2745 void i40e_set_ethtool_ops(struct net_device *netdev)
2746 {
2747 netdev->ethtool_ops = &i40e_ethtool_ops;
2748 }
This page took 0.103254 seconds and 5 git commands to generate.