blob: df3917b68c99a19256c3dcf8c433ea9dc0763917 [file] [log] [blame]
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00001/*******************************************************************************
2 *
3 * Intel Ethernet Controller XL710 Family Linux Driver
Greg Rosedc641b72013-12-18 13:45:51 +00004 * Copyright(c) 2013 - 2014 Intel Corporation.
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00005 *
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 *
Greg Rosedc641b72013-12-18 13:45:51 +000015 * 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/>.
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +000017 *
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
32struct 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#define I40E_NETDEV_STAT(_net_stat) \
44 I40E_STAT(struct net_device_stats, #_net_stat, _net_stat)
45#define I40E_PF_STAT(_name, _stat) \
46 I40E_STAT(struct i40e_pf, _name, _stat)
47#define I40E_VSI_STAT(_name, _stat) \
48 I40E_STAT(struct i40e_vsi, _name, _stat)
Shannon Nelson8eab9cf2014-04-23 04:49:55 +000049#define I40E_VEB_STAT(_name, _stat) \
50 I40E_STAT(struct i40e_veb, _name, _stat)
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +000051
52static const struct i40e_stats i40e_gstrings_net_stats[] = {
53 I40E_NETDEV_STAT(rx_packets),
54 I40E_NETDEV_STAT(tx_packets),
55 I40E_NETDEV_STAT(rx_bytes),
56 I40E_NETDEV_STAT(tx_bytes),
57 I40E_NETDEV_STAT(rx_errors),
58 I40E_NETDEV_STAT(tx_errors),
59 I40E_NETDEV_STAT(rx_dropped),
60 I40E_NETDEV_STAT(tx_dropped),
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +000061 I40E_NETDEV_STAT(collisions),
62 I40E_NETDEV_STAT(rx_length_errors),
63 I40E_NETDEV_STAT(rx_crc_errors),
64};
65
Shannon Nelson8eab9cf2014-04-23 04:49:55 +000066static const struct i40e_stats i40e_gstrings_veb_stats[] = {
67 I40E_VEB_STAT("rx_bytes", stats.rx_bytes),
68 I40E_VEB_STAT("tx_bytes", stats.tx_bytes),
69 I40E_VEB_STAT("rx_unicast", stats.rx_unicast),
70 I40E_VEB_STAT("tx_unicast", stats.tx_unicast),
71 I40E_VEB_STAT("rx_multicast", stats.rx_multicast),
72 I40E_VEB_STAT("tx_multicast", stats.tx_multicast),
73 I40E_VEB_STAT("rx_broadcast", stats.rx_broadcast),
74 I40E_VEB_STAT("tx_broadcast", stats.tx_broadcast),
75 I40E_VEB_STAT("rx_discards", stats.rx_discards),
76 I40E_VEB_STAT("tx_discards", stats.tx_discards),
77 I40E_VEB_STAT("tx_errors", stats.tx_errors),
78 I40E_VEB_STAT("rx_unknown_protocol", stats.rx_unknown_protocol),
79};
80
Shannon Nelson41a9e552014-04-23 04:50:20 +000081static const struct i40e_stats i40e_gstrings_misc_stats[] = {
Shannon Nelson418631d2014-04-23 04:50:07 +000082 I40E_VSI_STAT("rx_unicast", eth_stats.rx_unicast),
83 I40E_VSI_STAT("tx_unicast", eth_stats.tx_unicast),
84 I40E_VSI_STAT("rx_multicast", eth_stats.rx_multicast),
85 I40E_VSI_STAT("tx_multicast", eth_stats.tx_multicast),
Shannon Nelson41a9e552014-04-23 04:50:20 +000086 I40E_VSI_STAT("rx_broadcast", eth_stats.rx_broadcast),
87 I40E_VSI_STAT("tx_broadcast", eth_stats.tx_broadcast),
Shannon Nelson418631d2014-04-23 04:50:07 +000088 I40E_VSI_STAT("rx_unknown_protocol", eth_stats.rx_unknown_protocol),
Shannon Nelson41a9e552014-04-23 04:50:20 +000089};
90
Anjali Singhai Jain1eaa3842014-03-06 08:59:59 +000091static int i40e_add_fdir_ethtool(struct i40e_vsi *vsi,
92 struct ethtool_rxnfc *cmd);
Joseph Gasparakis17a73f62014-02-12 01:45:30 +000093
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +000094/* These PF_STATs might look like duplicates of some NETDEV_STATs,
95 * but they are separate. This device supports Virtualization, and
96 * as such might have several netdevs supporting VMDq and FCoE going
97 * through a single port. The NETDEV_STATs are for individual netdevs
98 * seen at the top of the stack, and the PF_STATs are for the physical
99 * function at the bottom of the stack hosting those netdevs.
100 *
101 * The PF_STATs are appended to the netdev stats only when ethtool -S
102 * is queried on the base PF netdev, not on the VMDq or FCoE netdev.
103 */
104static struct i40e_stats i40e_gstrings_stats[] = {
105 I40E_PF_STAT("rx_bytes", stats.eth.rx_bytes),
106 I40E_PF_STAT("tx_bytes", stats.eth.tx_bytes),
Shannon Nelson532d2832014-04-23 04:50:09 +0000107 I40E_PF_STAT("rx_unicast", stats.eth.rx_unicast),
108 I40E_PF_STAT("tx_unicast", stats.eth.tx_unicast),
109 I40E_PF_STAT("rx_multicast", stats.eth.rx_multicast),
110 I40E_PF_STAT("tx_multicast", stats.eth.tx_multicast),
111 I40E_PF_STAT("rx_broadcast", stats.eth.rx_broadcast),
112 I40E_PF_STAT("tx_broadcast", stats.eth.tx_broadcast),
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +0000113 I40E_PF_STAT("tx_errors", stats.eth.tx_errors),
114 I40E_PF_STAT("rx_dropped", stats.eth.rx_discards),
115 I40E_PF_STAT("tx_dropped", stats.eth.tx_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),
Jesse Brandeburga47a15f2014-02-06 05:51:09 +0000121 I40E_PF_STAT("tx_timeout", tx_timeout_count),
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +0000122 I40E_PF_STAT("rx_length_errors", stats.rx_length_errors),
123 I40E_PF_STAT("link_xon_rx", stats.link_xon_rx),
124 I40E_PF_STAT("link_xoff_rx", stats.link_xoff_rx),
125 I40E_PF_STAT("link_xon_tx", stats.link_xon_tx),
126 I40E_PF_STAT("link_xoff_tx", stats.link_xoff_tx),
127 I40E_PF_STAT("rx_size_64", stats.rx_size_64),
128 I40E_PF_STAT("rx_size_127", stats.rx_size_127),
129 I40E_PF_STAT("rx_size_255", stats.rx_size_255),
130 I40E_PF_STAT("rx_size_511", stats.rx_size_511),
131 I40E_PF_STAT("rx_size_1023", stats.rx_size_1023),
132 I40E_PF_STAT("rx_size_1522", stats.rx_size_1522),
133 I40E_PF_STAT("rx_size_big", stats.rx_size_big),
134 I40E_PF_STAT("tx_size_64", stats.tx_size_64),
135 I40E_PF_STAT("tx_size_127", stats.tx_size_127),
136 I40E_PF_STAT("tx_size_255", stats.tx_size_255),
137 I40E_PF_STAT("tx_size_511", stats.tx_size_511),
138 I40E_PF_STAT("tx_size_1023", stats.tx_size_1023),
139 I40E_PF_STAT("tx_size_1522", stats.tx_size_1522),
140 I40E_PF_STAT("tx_size_big", stats.tx_size_big),
141 I40E_PF_STAT("rx_undersize", stats.rx_undersize),
142 I40E_PF_STAT("rx_fragments", stats.rx_fragments),
143 I40E_PF_STAT("rx_oversize", stats.rx_oversize),
144 I40E_PF_STAT("rx_jabber", stats.rx_jabber),
145 I40E_PF_STAT("VF_admin_queue_requests", vf_aq_requests),
Jacob Kellerbeb0dff2014-01-11 05:43:19 +0000146 I40E_PF_STAT("rx_hwtstamp_cleared", rx_hwtstamp_cleared),
Anjali Singhai Jainbee5af72014-03-06 08:59:50 +0000147 /* LPI stats */
148 I40E_PF_STAT("tx_lpi_status", stats.tx_lpi_status),
149 I40E_PF_STAT("rx_lpi_status", stats.rx_lpi_status),
150 I40E_PF_STAT("tx_lpi_count", stats.tx_lpi_count),
151 I40E_PF_STAT("rx_lpi_count", stats.rx_lpi_count),
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +0000152};
153
154#define I40E_QUEUE_STATS_LEN(n) \
Shannon Nelson31cd8402014-04-04 04:43:12 +0000155 (((struct i40e_netdev_priv *)netdev_priv((n)))->vsi->num_queue_pairs \
156 * 2 /* Tx and Rx together */ \
157 * (sizeof(struct i40e_queue_stats) / sizeof(u64)))
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +0000158#define I40E_GLOBAL_STATS_LEN ARRAY_SIZE(i40e_gstrings_stats)
159#define I40E_NETDEV_STATS_LEN ARRAY_SIZE(i40e_gstrings_net_stats)
Shannon Nelson41a9e552014-04-23 04:50:20 +0000160#define I40E_MISC_STATS_LEN ARRAY_SIZE(i40e_gstrings_misc_stats)
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +0000161#define I40E_VSI_STATS_LEN(n) (I40E_NETDEV_STATS_LEN + \
Shannon Nelson41a9e552014-04-23 04:50:20 +0000162 I40E_MISC_STATS_LEN + \
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +0000163 I40E_QUEUE_STATS_LEN((n)))
164#define I40E_PFC_STATS_LEN ( \
165 (FIELD_SIZEOF(struct i40e_pf, stats.priority_xoff_rx) + \
166 FIELD_SIZEOF(struct i40e_pf, stats.priority_xon_rx) + \
167 FIELD_SIZEOF(struct i40e_pf, stats.priority_xoff_tx) + \
168 FIELD_SIZEOF(struct i40e_pf, stats.priority_xon_tx) + \
169 FIELD_SIZEOF(struct i40e_pf, stats.priority_xon_2_xoff)) \
170 / sizeof(u64))
Shannon Nelson8eab9cf2014-04-23 04:49:55 +0000171#define I40E_VEB_STATS_LEN ARRAY_SIZE(i40e_gstrings_veb_stats)
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +0000172#define I40E_PF_STATS_LEN(n) (I40E_GLOBAL_STATS_LEN + \
173 I40E_PFC_STATS_LEN + \
174 I40E_VSI_STATS_LEN((n)))
175
176enum i40e_ethtool_test_id {
177 I40E_ETH_TEST_REG = 0,
178 I40E_ETH_TEST_EEPROM,
179 I40E_ETH_TEST_INTR,
180 I40E_ETH_TEST_LOOPBACK,
181 I40E_ETH_TEST_LINK,
182};
183
184static const char i40e_gstrings_test[][ETH_GSTRING_LEN] = {
185 "Register test (offline)",
186 "Eeprom test (offline)",
187 "Interrupt test (offline)",
188 "Loopback test (offline)",
189 "Link test (on/offline)"
190};
191
192#define I40E_TEST_LEN (sizeof(i40e_gstrings_test) / ETH_GSTRING_LEN)
193
194/**
195 * i40e_get_settings - Get Link Speed and Duplex settings
196 * @netdev: network interface device structure
197 * @ecmd: ethtool command
198 *
199 * Reports speed/duplex settings based on media_type
200 **/
201static int i40e_get_settings(struct net_device *netdev,
202 struct ethtool_cmd *ecmd)
203{
204 struct i40e_netdev_priv *np = netdev_priv(netdev);
205 struct i40e_pf *pf = np->vsi->back;
206 struct i40e_hw *hw = &pf->hw;
207 struct i40e_link_status *hw_link_info = &hw->phy.link_info;
208 bool link_up = hw_link_info->link_info & I40E_AQ_LINK_UP;
209 u32 link_speed = hw_link_info->link_speed;
210
211 /* hardware is either in 40G mode or 10G mode
212 * NOTE: this section initializes supported and advertising
213 */
214 switch (hw_link_info->phy_type) {
215 case I40E_PHY_TYPE_40GBASE_CR4:
216 case I40E_PHY_TYPE_40GBASE_CR4_CU:
217 ecmd->supported = SUPPORTED_40000baseCR4_Full;
218 ecmd->advertising = ADVERTISED_40000baseCR4_Full;
219 break;
220 case I40E_PHY_TYPE_40GBASE_KR4:
221 ecmd->supported = SUPPORTED_40000baseKR4_Full;
222 ecmd->advertising = ADVERTISED_40000baseKR4_Full;
223 break;
224 case I40E_PHY_TYPE_40GBASE_SR4:
225 ecmd->supported = SUPPORTED_40000baseSR4_Full;
226 ecmd->advertising = ADVERTISED_40000baseSR4_Full;
227 break;
228 case I40E_PHY_TYPE_40GBASE_LR4:
229 ecmd->supported = SUPPORTED_40000baseLR4_Full;
230 ecmd->advertising = ADVERTISED_40000baseLR4_Full;
231 break;
232 case I40E_PHY_TYPE_10GBASE_KX4:
233 ecmd->supported = SUPPORTED_10000baseKX4_Full;
234 ecmd->advertising = ADVERTISED_10000baseKX4_Full;
235 break;
236 case I40E_PHY_TYPE_10GBASE_KR:
237 ecmd->supported = SUPPORTED_10000baseKR_Full;
238 ecmd->advertising = ADVERTISED_10000baseKR_Full;
239 break;
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +0000240 default:
Jesse Brandeburgc9a3d472013-11-26 10:49:10 +0000241 if (i40e_is_40G_device(hw->device_id)) {
242 ecmd->supported = SUPPORTED_40000baseSR4_Full;
243 ecmd->advertising = ADVERTISED_40000baseSR4_Full;
244 } else {
245 ecmd->supported = SUPPORTED_10000baseT_Full;
246 ecmd->advertising = ADVERTISED_10000baseT_Full;
247 }
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +0000248 break;
249 }
250
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +0000251 ecmd->supported |= SUPPORTED_Autoneg;
Jesse Brandeburgc9a3d472013-11-26 10:49:10 +0000252 ecmd->advertising |= ADVERTISED_Autoneg;
253 ecmd->autoneg = ((hw_link_info->an_info & I40E_AQ_AN_COMPLETED) ?
254 AUTONEG_ENABLE : AUTONEG_DISABLE);
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +0000255
Jesse Brandeburgc9a3d472013-11-26 10:49:10 +0000256 switch (hw->phy.media_type) {
257 case I40E_MEDIA_TYPE_BACKPLANE:
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +0000258 ecmd->supported |= SUPPORTED_Backplane;
259 ecmd->advertising |= ADVERTISED_Backplane;
260 ecmd->port = PORT_NONE;
Jesse Brandeburgc9a3d472013-11-26 10:49:10 +0000261 break;
262 case I40E_MEDIA_TYPE_BASET:
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +0000263 ecmd->supported |= SUPPORTED_TP;
264 ecmd->advertising |= ADVERTISED_TP;
265 ecmd->port = PORT_TP;
Jesse Brandeburgc9a3d472013-11-26 10:49:10 +0000266 break;
267 case I40E_MEDIA_TYPE_DA:
268 case I40E_MEDIA_TYPE_CX4:
Jesse Brandeburgbe405eb2013-11-20 10:02:50 +0000269 ecmd->supported |= SUPPORTED_FIBRE;
270 ecmd->advertising |= ADVERTISED_FIBRE;
271 ecmd->port = PORT_DA;
Jesse Brandeburgc9a3d472013-11-26 10:49:10 +0000272 break;
273 case I40E_MEDIA_TYPE_FIBER:
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +0000274 ecmd->supported |= SUPPORTED_FIBRE;
275 ecmd->advertising |= ADVERTISED_FIBRE;
276 ecmd->port = PORT_FIBRE;
Jesse Brandeburgc9a3d472013-11-26 10:49:10 +0000277 break;
278 case I40E_MEDIA_TYPE_UNKNOWN:
279 default:
280 ecmd->port = PORT_OTHER;
281 break;
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +0000282 }
283
284 ecmd->transceiver = XCVR_EXTERNAL;
285
286 if (link_up) {
287 switch (link_speed) {
288 case I40E_LINK_SPEED_40GB:
289 /* need a SPEED_40000 in ethtool.h */
290 ethtool_cmd_speed_set(ecmd, 40000);
291 break;
292 case I40E_LINK_SPEED_10GB:
293 ethtool_cmd_speed_set(ecmd, SPEED_10000);
294 break;
295 default:
296 break;
297 }
298 ecmd->duplex = DUPLEX_FULL;
299 } else {
300 ethtool_cmd_speed_set(ecmd, SPEED_UNKNOWN);
301 ecmd->duplex = DUPLEX_UNKNOWN;
302 }
303
304 return 0;
305}
306
307/**
308 * i40e_get_pauseparam - Get Flow Control status
309 * Return tx/rx-pause status
310 **/
311static void i40e_get_pauseparam(struct net_device *netdev,
312 struct ethtool_pauseparam *pause)
313{
314 struct i40e_netdev_priv *np = netdev_priv(netdev);
315 struct i40e_pf *pf = np->vsi->back;
316 struct i40e_hw *hw = &pf->hw;
317 struct i40e_link_status *hw_link_info = &hw->phy.link_info;
318
319 pause->autoneg =
320 ((hw_link_info->an_info & I40E_AQ_AN_COMPLETED) ?
321 AUTONEG_ENABLE : AUTONEG_DISABLE);
322
Jesse Brandeburgd52c20b2013-11-26 10:49:15 +0000323 if (hw->fc.current_mode == I40E_FC_RX_PAUSE) {
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +0000324 pause->rx_pause = 1;
Jesse Brandeburgd52c20b2013-11-26 10:49:15 +0000325 } else if (hw->fc.current_mode == I40E_FC_TX_PAUSE) {
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +0000326 pause->tx_pause = 1;
Jesse Brandeburgd52c20b2013-11-26 10:49:15 +0000327 } else if (hw->fc.current_mode == I40E_FC_FULL) {
328 pause->rx_pause = 1;
329 pause->tx_pause = 1;
330 }
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +0000331}
332
333static u32 i40e_get_msglevel(struct net_device *netdev)
334{
335 struct i40e_netdev_priv *np = netdev_priv(netdev);
336 struct i40e_pf *pf = np->vsi->back;
337
338 return pf->msg_enable;
339}
340
341static void i40e_set_msglevel(struct net_device *netdev, u32 data)
342{
343 struct i40e_netdev_priv *np = netdev_priv(netdev);
344 struct i40e_pf *pf = np->vsi->back;
345
346 if (I40E_DEBUG_USER & data)
347 pf->hw.debug_mask = data;
348 pf->msg_enable = data;
349}
350
351static int i40e_get_regs_len(struct net_device *netdev)
352{
353 int reg_count = 0;
354 int i;
355
356 for (i = 0; i40e_reg_list[i].offset != 0; i++)
357 reg_count += i40e_reg_list[i].elements;
358
359 return reg_count * sizeof(u32);
360}
361
362static void i40e_get_regs(struct net_device *netdev, struct ethtool_regs *regs,
363 void *p)
364{
365 struct i40e_netdev_priv *np = netdev_priv(netdev);
366 struct i40e_pf *pf = np->vsi->back;
367 struct i40e_hw *hw = &pf->hw;
368 u32 *reg_buf = p;
369 int i, j, ri;
370 u32 reg;
371
372 /* Tell ethtool which driver-version-specific regs output we have.
373 *
374 * At some point, if we have ethtool doing special formatting of
375 * this data, it will rely on this version number to know how to
376 * interpret things. Hence, this needs to be updated if/when the
377 * diags register table is changed.
378 */
379 regs->version = 1;
380
381 /* loop through the diags reg table for what to print */
382 ri = 0;
383 for (i = 0; i40e_reg_list[i].offset != 0; i++) {
384 for (j = 0; j < i40e_reg_list[i].elements; j++) {
385 reg = i40e_reg_list[i].offset
386 + (j * i40e_reg_list[i].stride);
387 reg_buf[ri++] = rd32(hw, reg);
388 }
389 }
390
391}
392
393static int i40e_get_eeprom(struct net_device *netdev,
394 struct ethtool_eeprom *eeprom, u8 *bytes)
395{
396 struct i40e_netdev_priv *np = netdev_priv(netdev);
397 struct i40e_hw *hw = &np->vsi->back->hw;
Anjali Singhai Jaine5e0a5d2013-11-28 06:39:28 +0000398 struct i40e_pf *pf = np->vsi->back;
399 int ret_val = 0, len;
400 u8 *eeprom_buff;
401 u16 i, sectors;
402 bool last;
403#define I40E_NVM_SECTOR_SIZE 4096
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +0000404 if (eeprom->len == 0)
405 return -EINVAL;
406
407 eeprom->magic = hw->vendor_id | (hw->device_id << 16);
408
Anjali Singhai Jaine5e0a5d2013-11-28 06:39:28 +0000409 eeprom_buff = kzalloc(eeprom->len, GFP_KERNEL);
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +0000410 if (!eeprom_buff)
411 return -ENOMEM;
412
Anjali Singhai Jaine5e0a5d2013-11-28 06:39:28 +0000413 ret_val = i40e_acquire_nvm(hw, I40E_RESOURCE_READ);
414 if (ret_val) {
415 dev_info(&pf->pdev->dev,
416 "Failed Acquiring NVM resource for read err=%d status=0x%x\n",
417 ret_val, hw->aq.asq_last_status);
418 goto free_buff;
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +0000419 }
420
Anjali Singhai Jaine5e0a5d2013-11-28 06:39:28 +0000421 sectors = eeprom->len / I40E_NVM_SECTOR_SIZE;
422 sectors += (eeprom->len % I40E_NVM_SECTOR_SIZE) ? 1 : 0;
423 len = I40E_NVM_SECTOR_SIZE;
424 last = false;
425 for (i = 0; i < sectors; i++) {
426 if (i == (sectors - 1)) {
427 len = eeprom->len - (I40E_NVM_SECTOR_SIZE * i);
428 last = true;
429 }
430 ret_val = i40e_aq_read_nvm(hw, 0x0,
431 eeprom->offset + (I40E_NVM_SECTOR_SIZE * i),
432 len,
Joe Perches3dbb7fd2014-03-25 04:30:38 +0000433 eeprom_buff + (I40E_NVM_SECTOR_SIZE * i),
Anjali Singhai Jaine5e0a5d2013-11-28 06:39:28 +0000434 last, NULL);
435 if (ret_val) {
436 dev_info(&pf->pdev->dev,
437 "read NVM failed err=%d status=0x%x\n",
438 ret_val, hw->aq.asq_last_status);
439 goto release_nvm;
440 }
441 }
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +0000442
Anjali Singhai Jaine5e0a5d2013-11-28 06:39:28 +0000443release_nvm:
444 i40e_release_nvm(hw);
Joe Perches3dbb7fd2014-03-25 04:30:38 +0000445 memcpy(bytes, eeprom_buff, eeprom->len);
Anjali Singhai Jaine5e0a5d2013-11-28 06:39:28 +0000446free_buff:
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +0000447 kfree(eeprom_buff);
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +0000448 return ret_val;
449}
450
451static int i40e_get_eeprom_len(struct net_device *netdev)
452{
453 struct i40e_netdev_priv *np = netdev_priv(netdev);
454 struct i40e_hw *hw = &np->vsi->back->hw;
Anjali Singhai Jaine5e0a5d2013-11-28 06:39:28 +0000455 u32 val;
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +0000456
Anjali Singhai Jaine5e0a5d2013-11-28 06:39:28 +0000457 val = (rd32(hw, I40E_GLPCI_LBARCTRL)
458 & I40E_GLPCI_LBARCTRL_FL_SIZE_MASK)
459 >> I40E_GLPCI_LBARCTRL_FL_SIZE_SHIFT;
460 /* register returns value in power of 2, 64Kbyte chunks. */
461 val = (64 * 1024) * (1 << val);
462 return val;
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +0000463}
464
465static void i40e_get_drvinfo(struct net_device *netdev,
466 struct ethtool_drvinfo *drvinfo)
467{
468 struct i40e_netdev_priv *np = netdev_priv(netdev);
469 struct i40e_vsi *vsi = np->vsi;
470 struct i40e_pf *pf = vsi->back;
471
472 strlcpy(drvinfo->driver, i40e_driver_name, sizeof(drvinfo->driver));
473 strlcpy(drvinfo->version, i40e_driver_version_str,
474 sizeof(drvinfo->version));
475 strlcpy(drvinfo->fw_version, i40e_fw_version_str(&pf->hw),
476 sizeof(drvinfo->fw_version));
477 strlcpy(drvinfo->bus_info, pci_name(pf->pdev),
478 sizeof(drvinfo->bus_info));
479}
480
481static void i40e_get_ringparam(struct net_device *netdev,
482 struct ethtool_ringparam *ring)
483{
484 struct i40e_netdev_priv *np = netdev_priv(netdev);
485 struct i40e_pf *pf = np->vsi->back;
486 struct i40e_vsi *vsi = pf->vsi[pf->lan_vsi];
487
488 ring->rx_max_pending = I40E_MAX_NUM_DESCRIPTORS;
489 ring->tx_max_pending = I40E_MAX_NUM_DESCRIPTORS;
490 ring->rx_mini_max_pending = 0;
491 ring->rx_jumbo_max_pending = 0;
Alexander Duyck9f65e152013-09-28 06:00:58 +0000492 ring->rx_pending = vsi->rx_rings[0]->count;
493 ring->tx_pending = vsi->tx_rings[0]->count;
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +0000494 ring->rx_mini_pending = 0;
495 ring->rx_jumbo_pending = 0;
496}
497
498static int i40e_set_ringparam(struct net_device *netdev,
499 struct ethtool_ringparam *ring)
500{
501 struct i40e_ring *tx_rings = NULL, *rx_rings = NULL;
502 struct i40e_netdev_priv *np = netdev_priv(netdev);
503 struct i40e_vsi *vsi = np->vsi;
504 struct i40e_pf *pf = vsi->back;
505 u32 new_rx_count, new_tx_count;
506 int i, err = 0;
507
508 if ((ring->rx_mini_pending) || (ring->rx_jumbo_pending))
509 return -EINVAL;
510
Shannon Nelson1fa18372013-11-20 10:03:08 +0000511 if (ring->tx_pending > I40E_MAX_NUM_DESCRIPTORS ||
512 ring->tx_pending < I40E_MIN_NUM_DESCRIPTORS ||
513 ring->rx_pending > I40E_MAX_NUM_DESCRIPTORS ||
514 ring->rx_pending < I40E_MIN_NUM_DESCRIPTORS) {
515 netdev_info(netdev,
516 "Descriptors requested (Tx: %d / Rx: %d) out of range [%d-%d]\n",
517 ring->tx_pending, ring->rx_pending,
518 I40E_MIN_NUM_DESCRIPTORS, I40E_MAX_NUM_DESCRIPTORS);
519 return -EINVAL;
520 }
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +0000521
Shannon Nelson1fa18372013-11-20 10:03:08 +0000522 new_tx_count = ALIGN(ring->tx_pending, I40E_REQ_DESCRIPTOR_MULTIPLE);
523 new_rx_count = ALIGN(ring->rx_pending, I40E_REQ_DESCRIPTOR_MULTIPLE);
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +0000524
525 /* if nothing to do return success */
Alexander Duyck9f65e152013-09-28 06:00:58 +0000526 if ((new_tx_count == vsi->tx_rings[0]->count) &&
527 (new_rx_count == vsi->rx_rings[0]->count))
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +0000528 return 0;
529
530 while (test_and_set_bit(__I40E_CONFIG_BUSY, &pf->state))
531 usleep_range(1000, 2000);
532
533 if (!netif_running(vsi->netdev)) {
534 /* simple case - set for the next time the netdev is started */
535 for (i = 0; i < vsi->num_queue_pairs; i++) {
Alexander Duyck9f65e152013-09-28 06:00:58 +0000536 vsi->tx_rings[i]->count = new_tx_count;
537 vsi->rx_rings[i]->count = new_rx_count;
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +0000538 }
539 goto done;
540 }
541
542 /* We can't just free everything and then setup again,
543 * because the ISRs in MSI-X mode get passed pointers
544 * to the Tx and Rx ring structs.
545 */
546
547 /* alloc updated Tx resources */
Alexander Duyck9f65e152013-09-28 06:00:58 +0000548 if (new_tx_count != vsi->tx_rings[0]->count) {
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +0000549 netdev_info(netdev,
550 "Changing Tx descriptor count from %d to %d.\n",
Alexander Duyck9f65e152013-09-28 06:00:58 +0000551 vsi->tx_rings[0]->count, new_tx_count);
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +0000552 tx_rings = kcalloc(vsi->alloc_queue_pairs,
553 sizeof(struct i40e_ring), GFP_KERNEL);
554 if (!tx_rings) {
555 err = -ENOMEM;
556 goto done;
557 }
558
559 for (i = 0; i < vsi->num_queue_pairs; i++) {
560 /* clone ring and setup updated count */
Alexander Duyck9f65e152013-09-28 06:00:58 +0000561 tx_rings[i] = *vsi->tx_rings[i];
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +0000562 tx_rings[i].count = new_tx_count;
563 err = i40e_setup_tx_descriptors(&tx_rings[i]);
564 if (err) {
565 while (i) {
566 i--;
567 i40e_free_tx_resources(&tx_rings[i]);
568 }
569 kfree(tx_rings);
570 tx_rings = NULL;
571
572 goto done;
573 }
574 }
575 }
576
577 /* alloc updated Rx resources */
Alexander Duyck9f65e152013-09-28 06:00:58 +0000578 if (new_rx_count != vsi->rx_rings[0]->count) {
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +0000579 netdev_info(netdev,
580 "Changing Rx descriptor count from %d to %d\n",
Alexander Duyck9f65e152013-09-28 06:00:58 +0000581 vsi->rx_rings[0]->count, new_rx_count);
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +0000582 rx_rings = kcalloc(vsi->alloc_queue_pairs,
583 sizeof(struct i40e_ring), GFP_KERNEL);
584 if (!rx_rings) {
585 err = -ENOMEM;
586 goto free_tx;
587 }
588
589 for (i = 0; i < vsi->num_queue_pairs; i++) {
590 /* clone ring and setup updated count */
Alexander Duyck9f65e152013-09-28 06:00:58 +0000591 rx_rings[i] = *vsi->rx_rings[i];
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +0000592 rx_rings[i].count = new_rx_count;
593 err = i40e_setup_rx_descriptors(&rx_rings[i]);
594 if (err) {
595 while (i) {
596 i--;
597 i40e_free_rx_resources(&rx_rings[i]);
598 }
599 kfree(rx_rings);
600 rx_rings = NULL;
601
602 goto free_tx;
603 }
604 }
605 }
606
607 /* Bring interface down, copy in the new ring info,
608 * then restore the interface
609 */
610 i40e_down(vsi);
611
612 if (tx_rings) {
613 for (i = 0; i < vsi->num_queue_pairs; i++) {
Alexander Duyck9f65e152013-09-28 06:00:58 +0000614 i40e_free_tx_resources(vsi->tx_rings[i]);
615 *vsi->tx_rings[i] = tx_rings[i];
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +0000616 }
617 kfree(tx_rings);
618 tx_rings = NULL;
619 }
620
621 if (rx_rings) {
622 for (i = 0; i < vsi->num_queue_pairs; i++) {
Alexander Duyck9f65e152013-09-28 06:00:58 +0000623 i40e_free_rx_resources(vsi->rx_rings[i]);
624 *vsi->rx_rings[i] = rx_rings[i];
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +0000625 }
626 kfree(rx_rings);
627 rx_rings = NULL;
628 }
629
630 i40e_up(vsi);
631
632free_tx:
633 /* error cleanup if the Rx allocations failed after getting Tx */
634 if (tx_rings) {
635 for (i = 0; i < vsi->num_queue_pairs; i++)
636 i40e_free_tx_resources(&tx_rings[i]);
637 kfree(tx_rings);
638 tx_rings = NULL;
639 }
640
641done:
642 clear_bit(__I40E_CONFIG_BUSY, &pf->state);
643
644 return err;
645}
646
647static int i40e_get_sset_count(struct net_device *netdev, int sset)
648{
649 struct i40e_netdev_priv *np = netdev_priv(netdev);
650 struct i40e_vsi *vsi = np->vsi;
651 struct i40e_pf *pf = vsi->back;
652
653 switch (sset) {
654 case ETH_SS_TEST:
655 return I40E_TEST_LEN;
656 case ETH_SS_STATS:
Shannon Nelson8eab9cf2014-04-23 04:49:55 +0000657 if (vsi == pf->vsi[pf->lan_vsi]) {
658 int len = I40E_PF_STATS_LEN(netdev);
659
660 if (pf->lan_veb != I40E_NO_VEB)
661 len += I40E_VEB_STATS_LEN;
662 return len;
663 } else {
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +0000664 return I40E_VSI_STATS_LEN(netdev);
Shannon Nelson8eab9cf2014-04-23 04:49:55 +0000665 }
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +0000666 default:
667 return -EOPNOTSUPP;
668 }
669}
670
671static void i40e_get_ethtool_stats(struct net_device *netdev,
672 struct ethtool_stats *stats, u64 *data)
673{
674 struct i40e_netdev_priv *np = netdev_priv(netdev);
Akeem G Abodunrine7046ee2014-04-09 05:58:58 +0000675 struct i40e_ring *tx_ring, *rx_ring;
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +0000676 struct i40e_vsi *vsi = np->vsi;
677 struct i40e_pf *pf = vsi->back;
678 int i = 0;
679 char *p;
680 int j;
681 struct rtnl_link_stats64 *net_stats = i40e_get_vsi_stats_struct(vsi);
Alexander Duyck980e9b12013-09-28 06:01:03 +0000682 unsigned int start;
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +0000683
684 i40e_update_stats(vsi);
685
686 for (j = 0; j < I40E_NETDEV_STATS_LEN; j++) {
687 p = (char *)net_stats + i40e_gstrings_net_stats[j].stat_offset;
688 data[i++] = (i40e_gstrings_net_stats[j].sizeof_stat ==
689 sizeof(u64)) ? *(u64 *)p : *(u32 *)p;
690 }
Shannon Nelson41a9e552014-04-23 04:50:20 +0000691 for (j = 0; j < I40E_MISC_STATS_LEN; j++) {
692 p = (char *)vsi + i40e_gstrings_misc_stats[j].stat_offset;
693 data[i++] = (i40e_gstrings_misc_stats[j].sizeof_stat ==
694 sizeof(u64)) ? *(u64 *)p : *(u32 *)p;
695 }
Alexander Duyck980e9b12013-09-28 06:01:03 +0000696 rcu_read_lock();
Catherine Sullivan99c472a2014-03-14 07:32:30 +0000697 for (j = 0; j < vsi->num_queue_pairs; j++) {
Akeem G Abodunrine7046ee2014-04-09 05:58:58 +0000698 tx_ring = ACCESS_ONCE(vsi->tx_rings[j]);
Alexander Duyck980e9b12013-09-28 06:01:03 +0000699
700 if (!tx_ring)
701 continue;
702
703 /* process Tx ring statistics */
704 do {
Eric W. Biederman57a77442014-03-13 21:26:42 -0700705 start = u64_stats_fetch_begin_irq(&tx_ring->syncp);
Alexander Duyck980e9b12013-09-28 06:01:03 +0000706 data[i] = tx_ring->stats.packets;
707 data[i + 1] = tx_ring->stats.bytes;
Eric W. Biederman57a77442014-03-13 21:26:42 -0700708 } while (u64_stats_fetch_retry_irq(&tx_ring->syncp, start));
Catherine Sullivan99c472a2014-03-14 07:32:30 +0000709 i += 2;
Alexander Duyck980e9b12013-09-28 06:01:03 +0000710
711 /* Rx ring is the 2nd half of the queue pair */
712 rx_ring = &tx_ring[1];
713 do {
Eric W. Biederman57a77442014-03-13 21:26:42 -0700714 start = u64_stats_fetch_begin_irq(&rx_ring->syncp);
Catherine Sullivan99c472a2014-03-14 07:32:30 +0000715 data[i] = rx_ring->stats.packets;
716 data[i + 1] = rx_ring->stats.bytes;
Eric W. Biederman57a77442014-03-13 21:26:42 -0700717 } while (u64_stats_fetch_retry_irq(&rx_ring->syncp, start));
Catherine Sullivan99c472a2014-03-14 07:32:30 +0000718 i += 2;
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +0000719 }
Alexander Duyck980e9b12013-09-28 06:01:03 +0000720 rcu_read_unlock();
Shannon Nelson8eab9cf2014-04-23 04:49:55 +0000721 if (vsi != pf->vsi[pf->lan_vsi])
722 return;
723
724 if (pf->lan_veb != I40E_NO_VEB) {
725 struct i40e_veb *veb = pf->veb[pf->lan_veb];
726 for (j = 0; j < I40E_VEB_STATS_LEN; j++) {
727 p = (char *)veb;
728 p += i40e_gstrings_veb_stats[j].stat_offset;
729 data[i++] = (i40e_gstrings_veb_stats[j].sizeof_stat ==
730 sizeof(u64)) ? *(u64 *)p : *(u32 *)p;
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +0000731 }
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +0000732 }
Shannon Nelson8eab9cf2014-04-23 04:49:55 +0000733 for (j = 0; j < I40E_GLOBAL_STATS_LEN; j++) {
734 p = (char *)pf + i40e_gstrings_stats[j].stat_offset;
735 data[i++] = (i40e_gstrings_stats[j].sizeof_stat ==
736 sizeof(u64)) ? *(u64 *)p : *(u32 *)p;
737 }
738 for (j = 0; j < I40E_MAX_USER_PRIORITY; j++) {
739 data[i++] = pf->stats.priority_xon_tx[j];
740 data[i++] = pf->stats.priority_xoff_tx[j];
741 }
742 for (j = 0; j < I40E_MAX_USER_PRIORITY; j++) {
743 data[i++] = pf->stats.priority_xon_rx[j];
744 data[i++] = pf->stats.priority_xoff_rx[j];
745 }
746 for (j = 0; j < I40E_MAX_USER_PRIORITY; j++)
747 data[i++] = pf->stats.priority_xon_2_xoff[j];
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +0000748}
749
750static void i40e_get_strings(struct net_device *netdev, u32 stringset,
751 u8 *data)
752{
753 struct i40e_netdev_priv *np = netdev_priv(netdev);
754 struct i40e_vsi *vsi = np->vsi;
755 struct i40e_pf *pf = vsi->back;
756 char *p = (char *)data;
757 int i;
758
759 switch (stringset) {
760 case ETH_SS_TEST:
761 for (i = 0; i < I40E_TEST_LEN; i++) {
762 memcpy(data, i40e_gstrings_test[i], ETH_GSTRING_LEN);
763 data += ETH_GSTRING_LEN;
764 }
765 break;
766 case ETH_SS_STATS:
767 for (i = 0; i < I40E_NETDEV_STATS_LEN; i++) {
768 snprintf(p, ETH_GSTRING_LEN, "%s",
769 i40e_gstrings_net_stats[i].stat_string);
770 p += ETH_GSTRING_LEN;
771 }
Shannon Nelson41a9e552014-04-23 04:50:20 +0000772 for (i = 0; i < I40E_MISC_STATS_LEN; i++) {
773 snprintf(p, ETH_GSTRING_LEN, "%s",
774 i40e_gstrings_misc_stats[i].stat_string);
775 p += ETH_GSTRING_LEN;
776 }
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +0000777 for (i = 0; i < vsi->num_queue_pairs; i++) {
778 snprintf(p, ETH_GSTRING_LEN, "tx-%u.tx_packets", i);
779 p += ETH_GSTRING_LEN;
780 snprintf(p, ETH_GSTRING_LEN, "tx-%u.tx_bytes", i);
781 p += ETH_GSTRING_LEN;
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +0000782 snprintf(p, ETH_GSTRING_LEN, "rx-%u.rx_packets", i);
783 p += ETH_GSTRING_LEN;
784 snprintf(p, ETH_GSTRING_LEN, "rx-%u.rx_bytes", i);
785 p += ETH_GSTRING_LEN;
786 }
Shannon Nelson8eab9cf2014-04-23 04:49:55 +0000787 if (vsi != pf->vsi[pf->lan_vsi])
788 return;
789
790 if (pf->lan_veb != I40E_NO_VEB) {
791 for (i = 0; i < I40E_VEB_STATS_LEN; i++) {
792 snprintf(p, ETH_GSTRING_LEN, "veb.%s",
793 i40e_gstrings_veb_stats[i].stat_string);
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +0000794 p += ETH_GSTRING_LEN;
795 }
Shannon Nelson8eab9cf2014-04-23 04:49:55 +0000796 }
797 for (i = 0; i < I40E_GLOBAL_STATS_LEN; i++) {
798 snprintf(p, ETH_GSTRING_LEN, "port.%s",
799 i40e_gstrings_stats[i].stat_string);
800 p += ETH_GSTRING_LEN;
801 }
802 for (i = 0; i < I40E_MAX_USER_PRIORITY; i++) {
803 snprintf(p, ETH_GSTRING_LEN,
804 "port.tx_priority_%u_xon", i);
805 p += ETH_GSTRING_LEN;
806 snprintf(p, ETH_GSTRING_LEN,
807 "port.tx_priority_%u_xoff", i);
808 p += ETH_GSTRING_LEN;
809 }
810 for (i = 0; i < I40E_MAX_USER_PRIORITY; i++) {
811 snprintf(p, ETH_GSTRING_LEN,
812 "port.rx_priority_%u_xon", i);
813 p += ETH_GSTRING_LEN;
814 snprintf(p, ETH_GSTRING_LEN,
815 "port.rx_priority_%u_xoff", i);
816 p += ETH_GSTRING_LEN;
817 }
818 for (i = 0; i < I40E_MAX_USER_PRIORITY; i++) {
819 snprintf(p, ETH_GSTRING_LEN,
820 "port.rx_priority_%u_xon_2_xoff", i);
821 p += ETH_GSTRING_LEN;
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +0000822 }
823 /* BUG_ON(p - data != I40E_STATS_LEN * ETH_GSTRING_LEN); */
824 break;
825 }
826}
827
828static int i40e_get_ts_info(struct net_device *dev,
829 struct ethtool_ts_info *info)
830{
Jacob Kellerbeb0dff2014-01-11 05:43:19 +0000831 struct i40e_pf *pf = i40e_netdev_to_pf(dev);
832
833 info->so_timestamping = SOF_TIMESTAMPING_TX_SOFTWARE |
834 SOF_TIMESTAMPING_RX_SOFTWARE |
835 SOF_TIMESTAMPING_SOFTWARE |
836 SOF_TIMESTAMPING_TX_HARDWARE |
837 SOF_TIMESTAMPING_RX_HARDWARE |
838 SOF_TIMESTAMPING_RAW_HARDWARE;
839
840 if (pf->ptp_clock)
841 info->phc_index = ptp_clock_index(pf->ptp_clock);
842 else
843 info->phc_index = -1;
844
845 info->tx_types = (1 << HWTSTAMP_TX_OFF) | (1 << HWTSTAMP_TX_ON);
846
847 info->rx_filters = (1 << HWTSTAMP_FILTER_NONE) |
848 (1 << HWTSTAMP_FILTER_PTP_V1_L4_SYNC) |
849 (1 << HWTSTAMP_FILTER_PTP_V1_L4_DELAY_REQ) |
850 (1 << HWTSTAMP_FILTER_PTP_V2_EVENT) |
851 (1 << HWTSTAMP_FILTER_PTP_V2_L2_EVENT) |
852 (1 << HWTSTAMP_FILTER_PTP_V2_L4_EVENT) |
853 (1 << HWTSTAMP_FILTER_PTP_V2_SYNC) |
854 (1 << HWTSTAMP_FILTER_PTP_V2_L2_SYNC) |
855 (1 << HWTSTAMP_FILTER_PTP_V2_L4_SYNC) |
856 (1 << HWTSTAMP_FILTER_PTP_V2_DELAY_REQ) |
857 (1 << HWTSTAMP_FILTER_PTP_V2_L2_DELAY_REQ) |
858 (1 << HWTSTAMP_FILTER_PTP_V2_L4_DELAY_REQ);
859
860 return 0;
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +0000861}
862
Shannon Nelson7b086392013-11-20 10:02:59 +0000863static int i40e_link_test(struct net_device *netdev, u64 *data)
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +0000864{
Shannon Nelson7b086392013-11-20 10:02:59 +0000865 struct i40e_netdev_priv *np = netdev_priv(netdev);
866 struct i40e_pf *pf = np->vsi->back;
867
Shannon Nelsonb03aaa92013-11-20 10:03:06 +0000868 netif_info(pf, hw, netdev, "link test\n");
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +0000869 if (i40e_get_link_status(&pf->hw))
870 *data = 0;
871 else
872 *data = 1;
873
874 return *data;
875}
876
Shannon Nelson7b086392013-11-20 10:02:59 +0000877static int i40e_reg_test(struct net_device *netdev, u64 *data)
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +0000878{
Shannon Nelson7b086392013-11-20 10:02:59 +0000879 struct i40e_netdev_priv *np = netdev_priv(netdev);
880 struct i40e_pf *pf = np->vsi->back;
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +0000881
Shannon Nelsonb03aaa92013-11-20 10:03:06 +0000882 netif_info(pf, hw, netdev, "register test\n");
Shannon Nelson7b086392013-11-20 10:02:59 +0000883 *data = i40e_diag_reg_test(&pf->hw);
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +0000884
Shannon Nelson7b086392013-11-20 10:02:59 +0000885 return *data;
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +0000886}
887
Shannon Nelson7b086392013-11-20 10:02:59 +0000888static int i40e_eeprom_test(struct net_device *netdev, u64 *data)
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +0000889{
Shannon Nelson7b086392013-11-20 10:02:59 +0000890 struct i40e_netdev_priv *np = netdev_priv(netdev);
891 struct i40e_pf *pf = np->vsi->back;
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +0000892
Shannon Nelsonb03aaa92013-11-20 10:03:06 +0000893 netif_info(pf, hw, netdev, "eeprom test\n");
Shannon Nelson7b086392013-11-20 10:02:59 +0000894 *data = i40e_diag_eeprom_test(&pf->hw);
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +0000895
Shannon Nelson7b086392013-11-20 10:02:59 +0000896 return *data;
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +0000897}
898
Shannon Nelson7b086392013-11-20 10:02:59 +0000899static int i40e_intr_test(struct net_device *netdev, u64 *data)
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +0000900{
Shannon Nelson7b086392013-11-20 10:02:59 +0000901 struct i40e_netdev_priv *np = netdev_priv(netdev);
902 struct i40e_pf *pf = np->vsi->back;
Shannon Nelsoncd92e722013-11-16 10:00:44 +0000903 u16 swc_old = pf->sw_int_count;
904
Shannon Nelsonb03aaa92013-11-20 10:03:06 +0000905 netif_info(pf, hw, netdev, "interrupt test\n");
Shannon Nelsoncd92e722013-11-16 10:00:44 +0000906 wr32(&pf->hw, I40E_PFINT_DYN_CTL0,
907 (I40E_PFINT_DYN_CTL0_INTENA_MASK |
908 I40E_PFINT_DYN_CTL0_SWINT_TRIG_MASK));
909 usleep_range(1000, 2000);
910 *data = (swc_old == pf->sw_int_count);
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +0000911
912 return *data;
913}
914
Shannon Nelson7b086392013-11-20 10:02:59 +0000915static int i40e_loopback_test(struct net_device *netdev, u64 *data)
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +0000916{
Shannon Nelsonb03aaa92013-11-20 10:03:06 +0000917 struct i40e_netdev_priv *np = netdev_priv(netdev);
918 struct i40e_pf *pf = np->vsi->back;
919
920 netif_info(pf, hw, netdev, "loopback test not implemented\n");
Shannon Nelsoncd92e722013-11-16 10:00:44 +0000921 *data = 0;
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +0000922
923 return *data;
924}
925
926static void i40e_diag_test(struct net_device *netdev,
927 struct ethtool_test *eth_test, u64 *data)
928{
929 struct i40e_netdev_priv *np = netdev_priv(netdev);
930 struct i40e_pf *pf = np->vsi->back;
931
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +0000932 if (eth_test->flags == ETH_TEST_FL_OFFLINE) {
933 /* Offline tests */
Shannon Nelsonb03aaa92013-11-20 10:03:06 +0000934 netif_info(pf, drv, netdev, "offline testing starting\n");
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +0000935
Shannon Nelsonf551b432013-11-26 10:49:12 +0000936 set_bit(__I40E_TESTING, &pf->state);
937
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +0000938 /* Link test performed before hardware reset
939 * so autoneg doesn't interfere with test result
940 */
Shannon Nelson7b086392013-11-20 10:02:59 +0000941 if (i40e_link_test(netdev, &data[I40E_ETH_TEST_LINK]))
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +0000942 eth_test->flags |= ETH_TEST_FL_FAILED;
943
Shannon Nelson7b086392013-11-20 10:02:59 +0000944 if (i40e_eeprom_test(netdev, &data[I40E_ETH_TEST_EEPROM]))
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +0000945 eth_test->flags |= ETH_TEST_FL_FAILED;
946
Shannon Nelson7b086392013-11-20 10:02:59 +0000947 if (i40e_intr_test(netdev, &data[I40E_ETH_TEST_INTR]))
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +0000948 eth_test->flags |= ETH_TEST_FL_FAILED;
949
Shannon Nelson7b086392013-11-20 10:02:59 +0000950 if (i40e_loopback_test(netdev, &data[I40E_ETH_TEST_LOOPBACK]))
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +0000951 eth_test->flags |= ETH_TEST_FL_FAILED;
952
Shannon Nelsonf551b432013-11-26 10:49:12 +0000953 /* run reg test last, a reset is required after it */
954 if (i40e_reg_test(netdev, &data[I40E_ETH_TEST_REG]))
955 eth_test->flags |= ETH_TEST_FL_FAILED;
956
957 clear_bit(__I40E_TESTING, &pf->state);
958 i40e_do_reset(pf, (1 << __I40E_PF_RESET_REQUESTED));
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +0000959 } else {
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +0000960 /* Online tests */
Shannon Nelsonb03aaa92013-11-20 10:03:06 +0000961 netif_info(pf, drv, netdev, "online testing starting\n");
962
Shannon Nelson7b086392013-11-20 10:02:59 +0000963 if (i40e_link_test(netdev, &data[I40E_ETH_TEST_LINK]))
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +0000964 eth_test->flags |= ETH_TEST_FL_FAILED;
965
966 /* Offline only tests, not run in online; pass by default */
967 data[I40E_ETH_TEST_REG] = 0;
968 data[I40E_ETH_TEST_EEPROM] = 0;
969 data[I40E_ETH_TEST_INTR] = 0;
970 data[I40E_ETH_TEST_LOOPBACK] = 0;
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +0000971 }
Shannon Nelsonc140c172013-11-20 10:02:58 +0000972
Shannon Nelsonb03aaa92013-11-20 10:03:06 +0000973 netif_info(pf, drv, netdev, "testing finished\n");
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +0000974}
975
976static void i40e_get_wol(struct net_device *netdev,
977 struct ethtool_wolinfo *wol)
978{
Shannon Nelson8e2773a2013-11-28 06:39:22 +0000979 struct i40e_netdev_priv *np = netdev_priv(netdev);
980 struct i40e_pf *pf = np->vsi->back;
981 struct i40e_hw *hw = &pf->hw;
982 u16 wol_nvm_bits;
983
984 /* NVM bit on means WoL disabled for the port */
985 i40e_read_nvm_word(hw, I40E_SR_NVM_WAKE_ON_LAN, &wol_nvm_bits);
986 if ((1 << hw->port) & wol_nvm_bits) {
987 wol->supported = 0;
988 wol->wolopts = 0;
989 } else {
990 wol->supported = WAKE_MAGIC;
991 wol->wolopts = (pf->wol_en ? WAKE_MAGIC : 0);
992 }
993}
994
995static int i40e_set_wol(struct net_device *netdev, struct ethtool_wolinfo *wol)
996{
997 struct i40e_netdev_priv *np = netdev_priv(netdev);
998 struct i40e_pf *pf = np->vsi->back;
999 struct i40e_hw *hw = &pf->hw;
1000 u16 wol_nvm_bits;
1001
1002 /* NVM bit on means WoL disabled for the port */
1003 i40e_read_nvm_word(hw, I40E_SR_NVM_WAKE_ON_LAN, &wol_nvm_bits);
1004 if (((1 << hw->port) & wol_nvm_bits))
1005 return -EOPNOTSUPP;
1006
1007 /* only magic packet is supported */
1008 if (wol->wolopts && (wol->wolopts != WAKE_MAGIC))
1009 return -EOPNOTSUPP;
1010
1011 /* is this a new value? */
1012 if (pf->wol_en != !!wol->wolopts) {
1013 pf->wol_en = !!wol->wolopts;
1014 device_set_wakeup_enable(&pf->pdev->dev, pf->wol_en);
1015 }
1016
1017 return 0;
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00001018}
1019
1020static int i40e_nway_reset(struct net_device *netdev)
1021{
1022 /* restart autonegotiation */
1023 struct i40e_netdev_priv *np = netdev_priv(netdev);
1024 struct i40e_pf *pf = np->vsi->back;
1025 struct i40e_hw *hw = &pf->hw;
1026 i40e_status ret = 0;
1027
1028 ret = i40e_aq_set_link_restart_an(hw, NULL);
1029 if (ret) {
1030 netdev_info(netdev, "link restart failed, aq_err=%d\n",
1031 pf->hw.aq.asq_last_status);
1032 return -EIO;
1033 }
1034
1035 return 0;
1036}
1037
1038static int i40e_set_phys_id(struct net_device *netdev,
1039 enum ethtool_phys_id_state state)
1040{
1041 struct i40e_netdev_priv *np = netdev_priv(netdev);
1042 struct i40e_pf *pf = np->vsi->back;
1043 struct i40e_hw *hw = &pf->hw;
1044 int blink_freq = 2;
1045
1046 switch (state) {
1047 case ETHTOOL_ID_ACTIVE:
1048 pf->led_status = i40e_led_get(hw);
1049 return blink_freq;
1050 case ETHTOOL_ID_ON:
Jesse Brandeburg0556a9e2013-11-28 06:39:33 +00001051 i40e_led_set(hw, 0xF, false);
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00001052 break;
1053 case ETHTOOL_ID_OFF:
Jesse Brandeburg0556a9e2013-11-28 06:39:33 +00001054 i40e_led_set(hw, 0x0, false);
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00001055 break;
1056 case ETHTOOL_ID_INACTIVE:
Jesse Brandeburg0556a9e2013-11-28 06:39:33 +00001057 i40e_led_set(hw, pf->led_status, false);
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00001058 break;
1059 }
1060
1061 return 0;
1062}
1063
1064/* NOTE: i40e hardware uses a conversion factor of 2 for Interrupt
1065 * Throttle Rate (ITR) ie. ITR(1) = 2us ITR(10) = 20 us, and also
1066 * 125us (8000 interrupts per second) == ITR(62)
1067 */
1068
1069static int i40e_get_coalesce(struct net_device *netdev,
1070 struct ethtool_coalesce *ec)
1071{
1072 struct i40e_netdev_priv *np = netdev_priv(netdev);
1073 struct i40e_vsi *vsi = np->vsi;
1074
1075 ec->tx_max_coalesced_frames_irq = vsi->work_limit;
1076 ec->rx_max_coalesced_frames_irq = vsi->work_limit;
1077
1078 if (ITR_IS_DYNAMIC(vsi->rx_itr_setting))
Mitch Williams32f5f542014-04-04 04:43:10 +00001079 ec->use_adaptive_rx_coalesce = 1;
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00001080
1081 if (ITR_IS_DYNAMIC(vsi->tx_itr_setting))
Mitch Williams32f5f542014-04-04 04:43:10 +00001082 ec->use_adaptive_tx_coalesce = 1;
1083
1084 ec->rx_coalesce_usecs = vsi->rx_itr_setting & ~I40E_ITR_DYNAMIC;
1085 ec->tx_coalesce_usecs = vsi->tx_itr_setting & ~I40E_ITR_DYNAMIC;
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00001086
1087 return 0;
1088}
1089
1090static int i40e_set_coalesce(struct net_device *netdev,
1091 struct ethtool_coalesce *ec)
1092{
1093 struct i40e_netdev_priv *np = netdev_priv(netdev);
1094 struct i40e_q_vector *q_vector;
1095 struct i40e_vsi *vsi = np->vsi;
1096 struct i40e_pf *pf = vsi->back;
1097 struct i40e_hw *hw = &pf->hw;
1098 u16 vector;
1099 int i;
1100
1101 if (ec->tx_max_coalesced_frames_irq || ec->rx_max_coalesced_frames_irq)
1102 vsi->work_limit = ec->tx_max_coalesced_frames_irq;
1103
Mitch Williams32f5f542014-04-04 04:43:10 +00001104 if ((ec->rx_coalesce_usecs >= (I40E_MIN_ITR << 1)) &&
1105 (ec->rx_coalesce_usecs <= (I40E_MAX_ITR << 1)))
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00001106 vsi->rx_itr_setting = ec->rx_coalesce_usecs;
Mitch Williams32f5f542014-04-04 04:43:10 +00001107 else
1108 return -EINVAL;
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00001109
Mitch Williams32f5f542014-04-04 04:43:10 +00001110 if ((ec->tx_coalesce_usecs >= (I40E_MIN_ITR << 1)) &&
1111 (ec->tx_coalesce_usecs <= (I40E_MAX_ITR << 1)))
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00001112 vsi->tx_itr_setting = ec->tx_coalesce_usecs;
Mitch Williams32f5f542014-04-04 04:43:10 +00001113 else
1114 return -EINVAL;
1115
1116 if (ec->use_adaptive_rx_coalesce)
1117 vsi->rx_itr_setting |= I40E_ITR_DYNAMIC;
1118 else
1119 vsi->rx_itr_setting &= ~I40E_ITR_DYNAMIC;
1120
1121 if (ec->use_adaptive_tx_coalesce)
1122 vsi->tx_itr_setting |= I40E_ITR_DYNAMIC;
1123 else
1124 vsi->tx_itr_setting &= ~I40E_ITR_DYNAMIC;
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00001125
1126 vector = vsi->base_vector;
Alexander Duyck493fb302013-09-28 07:01:44 +00001127 for (i = 0; i < vsi->num_q_vectors; i++, vector++) {
1128 q_vector = vsi->q_vectors[i];
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00001129 q_vector->rx.itr = ITR_TO_REG(vsi->rx_itr_setting);
1130 wr32(hw, I40E_PFINT_ITRN(0, vector - 1), q_vector->rx.itr);
1131 q_vector->tx.itr = ITR_TO_REG(vsi->tx_itr_setting);
1132 wr32(hw, I40E_PFINT_ITRN(1, vector - 1), q_vector->tx.itr);
1133 i40e_flush(hw);
1134 }
1135
1136 return 0;
1137}
1138
1139/**
1140 * i40e_get_rss_hash_opts - Get RSS hash Input Set for each flow type
1141 * @pf: pointer to the physical function struct
1142 * @cmd: ethtool rxnfc command
1143 *
1144 * Returns Success if the flow is supported, else Invalid Input.
1145 **/
1146static int i40e_get_rss_hash_opts(struct i40e_pf *pf, struct ethtool_rxnfc *cmd)
1147{
1148 cmd->data = 0;
1149
1150 /* Report default options for RSS on i40e */
1151 switch (cmd->flow_type) {
1152 case TCP_V4_FLOW:
1153 case UDP_V4_FLOW:
1154 cmd->data |= RXH_L4_B_0_1 | RXH_L4_B_2_3;
1155 /* fall through to add IP fields */
1156 case SCTP_V4_FLOW:
1157 case AH_ESP_V4_FLOW:
1158 case AH_V4_FLOW:
1159 case ESP_V4_FLOW:
1160 case IPV4_FLOW:
1161 cmd->data |= RXH_IP_SRC | RXH_IP_DST;
1162 break;
1163 case TCP_V6_FLOW:
1164 case UDP_V6_FLOW:
1165 cmd->data |= RXH_L4_B_0_1 | RXH_L4_B_2_3;
1166 /* fall through to add IP fields */
1167 case SCTP_V6_FLOW:
1168 case AH_ESP_V6_FLOW:
1169 case AH_V6_FLOW:
1170 case ESP_V6_FLOW:
1171 case IPV6_FLOW:
1172 cmd->data |= RXH_IP_SRC | RXH_IP_DST;
1173 break;
1174 default:
1175 return -EINVAL;
1176 }
1177
1178 return 0;
1179}
1180
1181/**
Joseph Gasparakis17a73f62014-02-12 01:45:30 +00001182 * i40e_get_ethtool_fdir_all - Populates the rule count of a command
1183 * @pf: Pointer to the physical function struct
1184 * @cmd: The command to get or set Rx flow classification rules
1185 * @rule_locs: Array of used rule locations
1186 *
1187 * This function populates both the total and actual rule count of
1188 * the ethtool flow classification command
1189 *
1190 * Returns 0 on success or -EMSGSIZE if entry not found
1191 **/
1192static int i40e_get_ethtool_fdir_all(struct i40e_pf *pf,
1193 struct ethtool_rxnfc *cmd,
1194 u32 *rule_locs)
1195{
1196 struct i40e_fdir_filter *rule;
1197 struct hlist_node *node2;
1198 int cnt = 0;
1199
1200 /* report total rule count */
Anjali Singhai Jain082def12014-04-09 05:59:00 +00001201 cmd->data = i40e_get_fd_cnt_all(pf);
Joseph Gasparakis17a73f62014-02-12 01:45:30 +00001202
1203 hlist_for_each_entry_safe(rule, node2,
1204 &pf->fdir_filter_list, fdir_node) {
1205 if (cnt == cmd->rule_cnt)
1206 return -EMSGSIZE;
1207
1208 rule_locs[cnt] = rule->fd_id;
1209 cnt++;
1210 }
1211
1212 cmd->rule_cnt = cnt;
1213
1214 return 0;
1215}
1216
1217/**
1218 * i40e_get_ethtool_fdir_entry - Look up a filter based on Rx flow
1219 * @pf: Pointer to the physical function struct
1220 * @cmd: The command to get or set Rx flow classification rules
1221 *
1222 * This function looks up a filter based on the Rx flow classification
1223 * command and fills the flow spec info for it if found
1224 *
1225 * Returns 0 on success or -EINVAL if filter not found
1226 **/
1227static int i40e_get_ethtool_fdir_entry(struct i40e_pf *pf,
1228 struct ethtool_rxnfc *cmd)
1229{
1230 struct ethtool_rx_flow_spec *fsp =
1231 (struct ethtool_rx_flow_spec *)&cmd->fs;
1232 struct i40e_fdir_filter *rule = NULL;
1233 struct hlist_node *node2;
1234
Joseph Gasparakis17a73f62014-02-12 01:45:30 +00001235 hlist_for_each_entry_safe(rule, node2,
1236 &pf->fdir_filter_list, fdir_node) {
1237 if (fsp->location <= rule->fd_id)
1238 break;
1239 }
1240
1241 if (!rule || fsp->location != rule->fd_id)
1242 return -EINVAL;
1243
1244 fsp->flow_type = rule->flow_type;
Anjali Singhai Jain7d54eb22014-03-14 07:32:21 +00001245 if (fsp->flow_type == IP_USER_FLOW) {
1246 fsp->h_u.usr_ip4_spec.ip_ver = ETH_RX_NFC_IP4;
1247 fsp->h_u.usr_ip4_spec.proto = 0;
1248 fsp->m_u.usr_ip4_spec.proto = 0;
1249 }
1250
Joseph Gasparakis17a73f62014-02-12 01:45:30 +00001251 fsp->h_u.tcp_ip4_spec.psrc = rule->src_port;
1252 fsp->h_u.tcp_ip4_spec.pdst = rule->dst_port;
1253 fsp->h_u.tcp_ip4_spec.ip4src = rule->src_ip[0];
1254 fsp->h_u.tcp_ip4_spec.ip4dst = rule->dst_ip[0];
1255 fsp->ring_cookie = rule->q_index;
1256
1257 return 0;
1258}
1259
1260/**
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00001261 * i40e_get_rxnfc - command to get RX flow classification rules
1262 * @netdev: network interface device structure
1263 * @cmd: ethtool rxnfc command
1264 *
1265 * Returns Success if the command is supported.
1266 **/
1267static int i40e_get_rxnfc(struct net_device *netdev, struct ethtool_rxnfc *cmd,
1268 u32 *rule_locs)
1269{
1270 struct i40e_netdev_priv *np = netdev_priv(netdev);
1271 struct i40e_vsi *vsi = np->vsi;
1272 struct i40e_pf *pf = vsi->back;
1273 int ret = -EOPNOTSUPP;
1274
1275 switch (cmd->cmd) {
1276 case ETHTOOL_GRXRINGS:
1277 cmd->data = vsi->alloc_queue_pairs;
1278 ret = 0;
1279 break;
1280 case ETHTOOL_GRXFH:
1281 ret = i40e_get_rss_hash_opts(pf, cmd);
1282 break;
1283 case ETHTOOL_GRXCLSRLCNT:
Joseph Gasparakis17a73f62014-02-12 01:45:30 +00001284 cmd->rule_cnt = pf->fdir_pf_active_filters;
Anjali Singhai Jain082def12014-04-09 05:59:00 +00001285 /* report total rule count */
1286 cmd->data = i40e_get_fd_cnt_all(pf);
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00001287 ret = 0;
1288 break;
1289 case ETHTOOL_GRXCLSRULE:
Joseph Gasparakis17a73f62014-02-12 01:45:30 +00001290 ret = i40e_get_ethtool_fdir_entry(pf, cmd);
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00001291 break;
1292 case ETHTOOL_GRXCLSRLALL:
Joseph Gasparakis17a73f62014-02-12 01:45:30 +00001293 ret = i40e_get_ethtool_fdir_all(pf, cmd, rule_locs);
1294 break;
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00001295 default:
1296 break;
1297 }
1298
1299 return ret;
1300}
1301
1302/**
1303 * i40e_set_rss_hash_opt - Enable/Disable flow types for RSS hash
1304 * @pf: pointer to the physical function struct
1305 * @cmd: ethtool rxnfc command
1306 *
1307 * Returns Success if the flow input set is supported.
1308 **/
1309static int i40e_set_rss_hash_opt(struct i40e_pf *pf, struct ethtool_rxnfc *nfc)
1310{
1311 struct i40e_hw *hw = &pf->hw;
1312 u64 hena = (u64)rd32(hw, I40E_PFQF_HENA(0)) |
1313 ((u64)rd32(hw, I40E_PFQF_HENA(1)) << 32);
1314
1315 /* RSS does not support anything other than hashing
1316 * to queues on src and dst IPs and ports
1317 */
1318 if (nfc->data & ~(RXH_IP_SRC | RXH_IP_DST |
1319 RXH_L4_B_0_1 | RXH_L4_B_2_3))
1320 return -EINVAL;
1321
1322 /* We need at least the IP SRC and DEST fields for hashing */
1323 if (!(nfc->data & RXH_IP_SRC) ||
1324 !(nfc->data & RXH_IP_DST))
1325 return -EINVAL;
1326
1327 switch (nfc->flow_type) {
1328 case TCP_V4_FLOW:
1329 switch (nfc->data & (RXH_L4_B_0_1 | RXH_L4_B_2_3)) {
1330 case 0:
1331 hena &= ~((u64)1 << I40E_FILTER_PCTYPE_NONF_IPV4_TCP);
1332 break;
1333 case (RXH_L4_B_0_1 | RXH_L4_B_2_3):
1334 hena |= ((u64)1 << I40E_FILTER_PCTYPE_NONF_IPV4_TCP);
1335 break;
1336 default:
1337 return -EINVAL;
1338 }
1339 break;
1340 case TCP_V6_FLOW:
1341 switch (nfc->data & (RXH_L4_B_0_1 | RXH_L4_B_2_3)) {
1342 case 0:
1343 hena &= ~((u64)1 << I40E_FILTER_PCTYPE_NONF_IPV6_TCP);
1344 break;
1345 case (RXH_L4_B_0_1 | RXH_L4_B_2_3):
1346 hena |= ((u64)1 << I40E_FILTER_PCTYPE_NONF_IPV6_TCP);
1347 break;
1348 default:
1349 return -EINVAL;
1350 }
1351 break;
1352 case UDP_V4_FLOW:
1353 switch (nfc->data & (RXH_L4_B_0_1 | RXH_L4_B_2_3)) {
1354 case 0:
Kevin Scottb2d36c02014-04-09 05:58:59 +00001355 hena &= ~(((u64)1 << I40E_FILTER_PCTYPE_NONF_IPV4_UDP) |
1356 ((u64)1 << I40E_FILTER_PCTYPE_FRAG_IPV4));
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00001357 break;
1358 case (RXH_L4_B_0_1 | RXH_L4_B_2_3):
Kevin Scottb2d36c02014-04-09 05:58:59 +00001359 hena |= (((u64)1 << I40E_FILTER_PCTYPE_NONF_IPV4_UDP) |
1360 ((u64)1 << I40E_FILTER_PCTYPE_FRAG_IPV4));
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00001361 break;
1362 default:
1363 return -EINVAL;
1364 }
1365 break;
1366 case UDP_V6_FLOW:
1367 switch (nfc->data & (RXH_L4_B_0_1 | RXH_L4_B_2_3)) {
1368 case 0:
Kevin Scottb2d36c02014-04-09 05:58:59 +00001369 hena &= ~(((u64)1 << I40E_FILTER_PCTYPE_NONF_IPV6_UDP) |
1370 ((u64)1 << I40E_FILTER_PCTYPE_FRAG_IPV6));
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00001371 break;
1372 case (RXH_L4_B_0_1 | RXH_L4_B_2_3):
Kevin Scottb2d36c02014-04-09 05:58:59 +00001373 hena |= (((u64)1 << I40E_FILTER_PCTYPE_NONF_IPV6_UDP) |
1374 ((u64)1 << I40E_FILTER_PCTYPE_FRAG_IPV6));
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00001375 break;
1376 default:
1377 return -EINVAL;
1378 }
1379 break;
1380 case AH_ESP_V4_FLOW:
1381 case AH_V4_FLOW:
1382 case ESP_V4_FLOW:
1383 case SCTP_V4_FLOW:
1384 if ((nfc->data & RXH_L4_B_0_1) ||
1385 (nfc->data & RXH_L4_B_2_3))
1386 return -EINVAL;
1387 hena |= ((u64)1 << I40E_FILTER_PCTYPE_NONF_IPV4_OTHER);
1388 break;
1389 case AH_ESP_V6_FLOW:
1390 case AH_V6_FLOW:
1391 case ESP_V6_FLOW:
1392 case SCTP_V6_FLOW:
1393 if ((nfc->data & RXH_L4_B_0_1) ||
1394 (nfc->data & RXH_L4_B_2_3))
1395 return -EINVAL;
1396 hena |= ((u64)1 << I40E_FILTER_PCTYPE_NONF_IPV6_OTHER);
1397 break;
1398 case IPV4_FLOW:
1399 hena |= ((u64)1 << I40E_FILTER_PCTYPE_NONF_IPV4_OTHER) |
1400 ((u64)1 << I40E_FILTER_PCTYPE_FRAG_IPV4);
1401 break;
1402 case IPV6_FLOW:
1403 hena |= ((u64)1 << I40E_FILTER_PCTYPE_NONF_IPV6_OTHER) |
1404 ((u64)1 << I40E_FILTER_PCTYPE_FRAG_IPV6);
1405 break;
1406 default:
1407 return -EINVAL;
1408 }
1409
1410 wr32(hw, I40E_PFQF_HENA(0), (u32)hena);
1411 wr32(hw, I40E_PFQF_HENA(1), (u32)(hena >> 32));
1412 i40e_flush(hw);
1413
1414 return 0;
1415}
1416
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00001417/**
Anjali Singhai Jain43fddb72014-02-11 08:24:09 +00001418 * i40e_match_fdir_input_set - Match a new filter against an existing one
1419 * @rule: The filter already added
1420 * @input: The new filter to comapre against
1421 *
1422 * Returns true if the two input set match
1423 **/
1424static bool i40e_match_fdir_input_set(struct i40e_fdir_filter *rule,
1425 struct i40e_fdir_filter *input)
1426{
1427 if ((rule->dst_ip[0] != input->dst_ip[0]) ||
1428 (rule->src_ip[0] != input->src_ip[0]) ||
1429 (rule->dst_port != input->dst_port) ||
1430 (rule->src_port != input->src_port))
1431 return false;
1432 return true;
1433}
1434
1435/**
Joseph Gasparakis17a73f62014-02-12 01:45:30 +00001436 * i40e_update_ethtool_fdir_entry - Updates the fdir filter entry
1437 * @vsi: Pointer to the targeted VSI
1438 * @input: The filter to update or NULL to indicate deletion
1439 * @sw_idx: Software index to the filter
1440 * @cmd: The command to get or set Rx flow classification rules
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00001441 *
Joseph Gasparakis17a73f62014-02-12 01:45:30 +00001442 * This function updates (or deletes) a Flow Director entry from
1443 * the hlist of the corresponding PF
1444 *
1445 * Returns 0 on success
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00001446 **/
Joseph Gasparakis17a73f62014-02-12 01:45:30 +00001447static int i40e_update_ethtool_fdir_entry(struct i40e_vsi *vsi,
1448 struct i40e_fdir_filter *input,
1449 u16 sw_idx,
1450 struct ethtool_rxnfc *cmd)
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00001451{
Joseph Gasparakis17a73f62014-02-12 01:45:30 +00001452 struct i40e_fdir_filter *rule, *parent;
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00001453 struct i40e_pf *pf = vsi->back;
Joseph Gasparakis17a73f62014-02-12 01:45:30 +00001454 struct hlist_node *node2;
1455 int err = -EINVAL;
Jesse Brandeburgc35a1d72013-12-18 13:46:02 +00001456
Joseph Gasparakis17a73f62014-02-12 01:45:30 +00001457 parent = NULL;
1458 rule = NULL;
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00001459
Joseph Gasparakis17a73f62014-02-12 01:45:30 +00001460 hlist_for_each_entry_safe(rule, node2,
1461 &pf->fdir_filter_list, fdir_node) {
1462 /* hash found, or no matching entry */
1463 if (rule->fd_id >= sw_idx)
1464 break;
1465 parent = rule;
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00001466 }
1467
Joseph Gasparakis17a73f62014-02-12 01:45:30 +00001468 /* if there is an old rule occupying our place remove it */
1469 if (rule && (rule->fd_id == sw_idx)) {
Anjali Singhai Jain43fddb72014-02-11 08:24:09 +00001470 if (input && !i40e_match_fdir_input_set(rule, input))
1471 err = i40e_add_del_fdir(vsi, rule, false);
1472 else if (!input)
1473 err = i40e_add_del_fdir(vsi, rule, false);
Joseph Gasparakis17a73f62014-02-12 01:45:30 +00001474 hlist_del(&rule->fdir_node);
1475 kfree(rule);
1476 pf->fdir_pf_active_filters--;
1477 }
1478
1479 /* If no input this was a delete, err should be 0 if a rule was
1480 * successfully found and removed from the list else -EINVAL
1481 */
1482 if (!input)
1483 return err;
1484
1485 /* initialize node and set software index */
1486 INIT_HLIST_NODE(&input->fdir_node);
1487
1488 /* add filter to the list */
1489 if (parent)
1490 hlist_add_after(&parent->fdir_node, &input->fdir_node);
1491 else
1492 hlist_add_head(&input->fdir_node,
1493 &pf->fdir_filter_list);
1494
1495 /* update counts */
1496 pf->fdir_pf_active_filters++;
1497
1498 return 0;
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00001499}
1500
1501/**
Joseph Gasparakis17a73f62014-02-12 01:45:30 +00001502 * i40e_del_fdir_entry - Deletes a Flow Director filter entry
1503 * @vsi: Pointer to the targeted VSI
1504 * @cmd: The command to get or set Rx flow classification rules
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00001505 *
Joseph Gasparakis17a73f62014-02-12 01:45:30 +00001506 * The function removes a Flow Director filter entry from the
1507 * hlist of the corresponding PF
1508 *
1509 * Returns 0 on success
1510 */
1511static int i40e_del_fdir_entry(struct i40e_vsi *vsi,
1512 struct ethtool_rxnfc *cmd)
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00001513{
Joseph Gasparakis17a73f62014-02-12 01:45:30 +00001514 struct ethtool_rx_flow_spec *fsp =
1515 (struct ethtool_rx_flow_spec *)&cmd->fs;
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00001516 struct i40e_pf *pf = vsi->back;
Joseph Gasparakis17a73f62014-02-12 01:45:30 +00001517 int ret = 0;
Jesse Brandeburgc35a1d72013-12-18 13:46:02 +00001518
Joseph Gasparakis17a73f62014-02-12 01:45:30 +00001519 ret = i40e_update_ethtool_fdir_entry(vsi, NULL, fsp->location, cmd);
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00001520
Anjali Singhai Jain55a5e602014-02-12 06:33:25 +00001521 i40e_fdir_check_and_reenable(pf);
Joseph Gasparakis17a73f62014-02-12 01:45:30 +00001522 return ret;
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00001523}
1524
1525/**
Anjali Singhai Jain1eaa3842014-03-06 08:59:59 +00001526 * i40e_add_fdir_ethtool - Add/Remove Flow Director filters
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00001527 * @vsi: pointer to the targeted VSI
1528 * @cmd: command to get or set RX flow classification rules
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00001529 *
Anjali Singhai Jain1eaa3842014-03-06 08:59:59 +00001530 * Add Flow Director filters for a specific flow spec based on their
1531 * protocol. Returns 0 if the filters were successfully added.
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00001532 **/
Anjali Singhai Jain1eaa3842014-03-06 08:59:59 +00001533static int i40e_add_fdir_ethtool(struct i40e_vsi *vsi,
1534 struct ethtool_rxnfc *cmd)
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00001535{
Joseph Gasparakis17a73f62014-02-12 01:45:30 +00001536 struct ethtool_rx_flow_spec *fsp;
1537 struct i40e_fdir_filter *input;
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00001538 struct i40e_pf *pf;
Joseph Gasparakis17a73f62014-02-12 01:45:30 +00001539 int ret = -EINVAL;
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00001540
1541 if (!vsi)
1542 return -EINVAL;
1543
1544 pf = vsi->back;
1545
Anjali Singhai Jain55a5e602014-02-12 06:33:25 +00001546 if (!(pf->flags & I40E_FLAG_FD_SB_ENABLED))
1547 return -EOPNOTSUPP;
1548
Anjali Singhai Jain1eaa3842014-03-06 08:59:59 +00001549 if (pf->auto_disable_flags & I40E_FLAG_FD_SB_ENABLED)
Anjali Singhai Jain55a5e602014-02-12 06:33:25 +00001550 return -ENOSPC;
1551
1552 fsp = (struct ethtool_rx_flow_spec *)&cmd->fs;
1553
Joseph Gasparakis17a73f62014-02-12 01:45:30 +00001554 if (fsp->location >= (pf->hw.func_caps.fd_filters_best_effort +
1555 pf->hw.func_caps.fd_filters_guaranteed)) {
1556 return -EINVAL;
1557 }
1558
Anjali Singhai Jain1eaa3842014-03-06 08:59:59 +00001559 if (fsp->ring_cookie >= vsi->num_queue_pairs)
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00001560 return -EINVAL;
1561
Joseph Gasparakis17a73f62014-02-12 01:45:30 +00001562 input = kzalloc(sizeof(*input), GFP_KERNEL);
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00001563
Joseph Gasparakis17a73f62014-02-12 01:45:30 +00001564 if (!input)
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00001565 return -ENOMEM;
Joseph Gasparakis17a73f62014-02-12 01:45:30 +00001566
1567 input->fd_id = fsp->location;
1568
Anjali Singhai Jain35a91fd2014-03-06 09:00:00 +00001569 if (fsp->ring_cookie == RX_CLS_FLOW_DISC)
1570 input->dest_ctl = I40E_FILTER_PROGRAM_DESC_DEST_DROP_PACKET;
1571 else
1572 input->dest_ctl =
1573 I40E_FILTER_PROGRAM_DESC_DEST_DIRECT_PACKET_QINDEX;
1574
Joseph Gasparakis17a73f62014-02-12 01:45:30 +00001575 input->q_index = fsp->ring_cookie;
1576 input->flex_off = 0;
1577 input->pctype = 0;
1578 input->dest_vsi = vsi->id;
Joseph Gasparakis17a73f62014-02-12 01:45:30 +00001579 input->fd_status = I40E_FILTER_PROGRAM_DESC_FD_STATUS_FD_ID;
1580 input->cnt_index = 0;
1581 input->flow_type = fsp->flow_type;
1582 input->ip4_proto = fsp->h_u.usr_ip4_spec.proto;
1583 input->src_port = fsp->h_u.tcp_ip4_spec.psrc;
1584 input->dst_port = fsp->h_u.tcp_ip4_spec.pdst;
1585 input->src_ip[0] = fsp->h_u.tcp_ip4_spec.ip4src;
1586 input->dst_ip[0] = fsp->h_u.tcp_ip4_spec.ip4dst;
1587
Anjali Singhai Jain1eaa3842014-03-06 08:59:59 +00001588 ret = i40e_add_del_fdir(vsi, input, true);
1589 if (ret)
Joseph Gasparakis17a73f62014-02-12 01:45:30 +00001590 kfree(input);
Joseph Gasparakis17a73f62014-02-12 01:45:30 +00001591 else
Anjali Singhai Jain1eaa3842014-03-06 08:59:59 +00001592 i40e_update_ethtool_fdir_entry(vsi, input, fsp->location, NULL);
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00001593
1594 return ret;
1595}
Jesse Brandeburg8fb905b2014-01-17 15:36:33 -08001596
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00001597/**
1598 * i40e_set_rxnfc - command to set RX flow classification rules
1599 * @netdev: network interface device structure
1600 * @cmd: ethtool rxnfc command
1601 *
1602 * Returns Success if the command is supported.
1603 **/
1604static int i40e_set_rxnfc(struct net_device *netdev, struct ethtool_rxnfc *cmd)
1605{
1606 struct i40e_netdev_priv *np = netdev_priv(netdev);
1607 struct i40e_vsi *vsi = np->vsi;
1608 struct i40e_pf *pf = vsi->back;
1609 int ret = -EOPNOTSUPP;
1610
1611 switch (cmd->cmd) {
1612 case ETHTOOL_SRXFH:
1613 ret = i40e_set_rss_hash_opt(pf, cmd);
1614 break;
1615 case ETHTOOL_SRXCLSRLINS:
Anjali Singhai Jain1eaa3842014-03-06 08:59:59 +00001616 ret = i40e_add_fdir_ethtool(vsi, cmd);
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00001617 break;
1618 case ETHTOOL_SRXCLSRLDEL:
Joseph Gasparakis17a73f62014-02-12 01:45:30 +00001619 ret = i40e_del_fdir_entry(vsi, cmd);
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00001620 break;
1621 default:
1622 break;
1623 }
1624
1625 return ret;
1626}
1627
Anjali Singhai Jain4b7820c2013-11-26 11:59:30 +00001628/**
1629 * i40e_max_channels - get Max number of combined channels supported
1630 * @vsi: vsi pointer
1631 **/
1632static unsigned int i40e_max_channels(struct i40e_vsi *vsi)
1633{
1634 /* TODO: This code assumes DCB and FD is disabled for now. */
1635 return vsi->alloc_queue_pairs;
1636}
1637
1638/**
1639 * i40e_get_channels - Get the current channels enabled and max supported etc.
1640 * @netdev: network interface device structure
1641 * @ch: ethtool channels structure
1642 *
1643 * We don't support separate tx and rx queues as channels. The other count
1644 * represents how many queues are being used for control. max_combined counts
1645 * how many queue pairs we can support. They may not be mapped 1 to 1 with
1646 * q_vectors since we support a lot more queue pairs than q_vectors.
1647 **/
1648static void i40e_get_channels(struct net_device *dev,
1649 struct ethtool_channels *ch)
1650{
1651 struct i40e_netdev_priv *np = netdev_priv(dev);
1652 struct i40e_vsi *vsi = np->vsi;
1653 struct i40e_pf *pf = vsi->back;
1654
1655 /* report maximum channels */
1656 ch->max_combined = i40e_max_channels(vsi);
1657
1658 /* report info for other vector */
Jesse Brandeburg60ea5f82014-01-17 15:36:34 -08001659 ch->other_count = (pf->flags & I40E_FLAG_FD_SB_ENABLED) ? 1 : 0;
Anjali Singhai Jain4b7820c2013-11-26 11:59:30 +00001660 ch->max_other = ch->other_count;
1661
1662 /* Note: This code assumes DCB is disabled for now. */
1663 ch->combined_count = vsi->num_queue_pairs;
1664}
1665
1666/**
1667 * i40e_set_channels - Set the new channels count.
1668 * @netdev: network interface device structure
1669 * @ch: ethtool channels structure
1670 *
1671 * The new channels count may not be the same as requested by the user
1672 * since it gets rounded down to a power of 2 value.
1673 **/
1674static int i40e_set_channels(struct net_device *dev,
1675 struct ethtool_channels *ch)
1676{
1677 struct i40e_netdev_priv *np = netdev_priv(dev);
1678 unsigned int count = ch->combined_count;
1679 struct i40e_vsi *vsi = np->vsi;
1680 struct i40e_pf *pf = vsi->back;
1681 int new_count;
1682
1683 /* We do not support setting channels for any other VSI at present */
1684 if (vsi->type != I40E_VSI_MAIN)
1685 return -EINVAL;
1686
1687 /* verify they are not requesting separate vectors */
1688 if (!count || ch->rx_count || ch->tx_count)
1689 return -EINVAL;
1690
1691 /* verify other_count has not changed */
Jesse Brandeburg60ea5f82014-01-17 15:36:34 -08001692 if (ch->other_count != ((pf->flags & I40E_FLAG_FD_SB_ENABLED) ? 1 : 0))
Anjali Singhai Jain4b7820c2013-11-26 11:59:30 +00001693 return -EINVAL;
1694
1695 /* verify the number of channels does not exceed hardware limits */
1696 if (count > i40e_max_channels(vsi))
1697 return -EINVAL;
1698
1699 /* update feature limits from largest to smallest supported values */
1700 /* TODO: Flow director limit, DCB etc */
1701
1702 /* cap RSS limit */
1703 if (count > pf->rss_size_max)
1704 count = pf->rss_size_max;
1705
1706 /* use rss_reconfig to rebuild with new queue count and update traffic
1707 * class queue mapping
1708 */
1709 new_count = i40e_reconfig_rss_queues(pf, count);
Anjali Singhai Jain5f90f422013-12-21 05:44:43 +00001710 if (new_count > 0)
Anjali Singhai Jain4b7820c2013-11-26 11:59:30 +00001711 return 0;
1712 else
1713 return -EINVAL;
1714}
1715
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00001716static const struct ethtool_ops i40e_ethtool_ops = {
1717 .get_settings = i40e_get_settings,
1718 .get_drvinfo = i40e_get_drvinfo,
1719 .get_regs_len = i40e_get_regs_len,
1720 .get_regs = i40e_get_regs,
1721 .nway_reset = i40e_nway_reset,
1722 .get_link = ethtool_op_get_link,
1723 .get_wol = i40e_get_wol,
Shannon Nelson8e2773a2013-11-28 06:39:22 +00001724 .set_wol = i40e_set_wol,
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00001725 .get_eeprom_len = i40e_get_eeprom_len,
1726 .get_eeprom = i40e_get_eeprom,
1727 .get_ringparam = i40e_get_ringparam,
1728 .set_ringparam = i40e_set_ringparam,
1729 .get_pauseparam = i40e_get_pauseparam,
1730 .get_msglevel = i40e_get_msglevel,
1731 .set_msglevel = i40e_set_msglevel,
1732 .get_rxnfc = i40e_get_rxnfc,
1733 .set_rxnfc = i40e_set_rxnfc,
1734 .self_test = i40e_diag_test,
1735 .get_strings = i40e_get_strings,
1736 .set_phys_id = i40e_set_phys_id,
1737 .get_sset_count = i40e_get_sset_count,
1738 .get_ethtool_stats = i40e_get_ethtool_stats,
1739 .get_coalesce = i40e_get_coalesce,
1740 .set_coalesce = i40e_set_coalesce,
Anjali Singhai Jain4b7820c2013-11-26 11:59:30 +00001741 .get_channels = i40e_get_channels,
1742 .set_channels = i40e_set_channels,
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00001743 .get_ts_info = i40e_get_ts_info,
1744};
1745
1746void i40e_set_ethtool_ops(struct net_device *netdev)
1747{
Wilfried Klaebe7ad24ea2014-05-11 00:12:32 +00001748 netdev->ethtool_ops = &i40e_ethtool_ops;
Jesse Brandeburgc7d05ca2013-09-11 08:39:56 +00001749}