1 // SPDX-License-Identifier: GPL-2.0
2 /* Copyright(c) 2013 - 2018 Intel Corporation. */
3 
4 #include <linux/vmalloc.h>
5 
6 #include "fm10k.h"
7 
8 struct fm10k_stats {
9 	/* The stat_string is expected to be a format string formatted using
10 	 * vsnprintf by fm10k_add_stat_strings. Every member of a stats array
11 	 * should use the same format specifiers as they will be formatted
12 	 * using the same variadic arguments.
13 	 */
14 	char stat_string[ETH_GSTRING_LEN];
15 	int sizeof_stat;
16 	int stat_offset;
17 };
18 
19 #define FM10K_STAT_FIELDS(_type, _name, _stat) { \
20 	.stat_string = _name, \
21 	.sizeof_stat = FIELD_SIZEOF(_type, _stat), \
22 	.stat_offset = offsetof(_type, _stat) \
23 }
24 
25 /* netdevice statistics */
26 #define FM10K_NETDEV_STAT(_net_stat) \
27 	FM10K_STAT_FIELDS(struct net_device_stats, __stringify(_net_stat), \
28 			  _net_stat)
29 
30 static const struct fm10k_stats fm10k_gstrings_net_stats[] = {
31 	FM10K_NETDEV_STAT(tx_packets),
32 	FM10K_NETDEV_STAT(tx_bytes),
33 	FM10K_NETDEV_STAT(tx_errors),
34 	FM10K_NETDEV_STAT(rx_packets),
35 	FM10K_NETDEV_STAT(rx_bytes),
36 	FM10K_NETDEV_STAT(rx_errors),
37 	FM10K_NETDEV_STAT(rx_dropped),
38 
39 	/* detailed Rx errors */
40 	FM10K_NETDEV_STAT(rx_length_errors),
41 	FM10K_NETDEV_STAT(rx_crc_errors),
42 	FM10K_NETDEV_STAT(rx_fifo_errors),
43 };
44 
45 #define FM10K_NETDEV_STATS_LEN	ARRAY_SIZE(fm10k_gstrings_net_stats)
46 
47 /* General interface statistics */
48 #define FM10K_STAT(_name, _stat) \
49 	FM10K_STAT_FIELDS(struct fm10k_intfc, _name, _stat)
50 
51 static const struct fm10k_stats fm10k_gstrings_global_stats[] = {
52 	FM10K_STAT("tx_restart_queue", restart_queue),
53 	FM10K_STAT("tx_busy", tx_busy),
54 	FM10K_STAT("tx_csum_errors", tx_csum_errors),
55 	FM10K_STAT("rx_alloc_failed", alloc_failed),
56 	FM10K_STAT("rx_csum_errors", rx_csum_errors),
57 
58 	FM10K_STAT("tx_packets_nic", tx_packets_nic),
59 	FM10K_STAT("tx_bytes_nic", tx_bytes_nic),
60 	FM10K_STAT("rx_packets_nic", rx_packets_nic),
61 	FM10K_STAT("rx_bytes_nic", rx_bytes_nic),
62 	FM10K_STAT("rx_drops_nic", rx_drops_nic),
63 	FM10K_STAT("rx_overrun_pf", rx_overrun_pf),
64 	FM10K_STAT("rx_overrun_vf", rx_overrun_vf),
65 
66 	FM10K_STAT("swapi_status", hw.swapi.status),
67 	FM10K_STAT("mac_rules_used", hw.swapi.mac.used),
68 	FM10K_STAT("mac_rules_avail", hw.swapi.mac.avail),
69 
70 	FM10K_STAT("reset_while_pending", hw.mac.reset_while_pending),
71 
72 	FM10K_STAT("tx_hang_count", tx_timeout_count),
73 };
74 
75 static const struct fm10k_stats fm10k_gstrings_pf_stats[] = {
76 	FM10K_STAT("timeout", stats.timeout.count),
77 	FM10K_STAT("ur", stats.ur.count),
78 	FM10K_STAT("ca", stats.ca.count),
79 	FM10K_STAT("um", stats.um.count),
80 	FM10K_STAT("xec", stats.xec.count),
81 	FM10K_STAT("vlan_drop", stats.vlan_drop.count),
82 	FM10K_STAT("loopback_drop", stats.loopback_drop.count),
83 	FM10K_STAT("nodesc_drop", stats.nodesc_drop.count),
84 };
85 
86 /* mailbox statistics */
87 #define FM10K_MBX_STAT(_name, _stat) \
88 	FM10K_STAT_FIELDS(struct fm10k_mbx_info, _name, _stat)
89 
90 static const struct fm10k_stats fm10k_gstrings_mbx_stats[] = {
91 	FM10K_MBX_STAT("mbx_tx_busy", tx_busy),
92 	FM10K_MBX_STAT("mbx_tx_dropped", tx_dropped),
93 	FM10K_MBX_STAT("mbx_tx_messages", tx_messages),
94 	FM10K_MBX_STAT("mbx_tx_dwords", tx_dwords),
95 	FM10K_MBX_STAT("mbx_tx_mbmem_pulled", tx_mbmem_pulled),
96 	FM10K_MBX_STAT("mbx_rx_messages", rx_messages),
97 	FM10K_MBX_STAT("mbx_rx_dwords", rx_dwords),
98 	FM10K_MBX_STAT("mbx_rx_parse_err", rx_parse_err),
99 	FM10K_MBX_STAT("mbx_rx_mbmem_pushed", rx_mbmem_pushed),
100 };
101 
102 /* per-queue ring statistics */
103 #define FM10K_QUEUE_STAT(_name, _stat) \
104 	FM10K_STAT_FIELDS(struct fm10k_ring, _name, _stat)
105 
106 static const struct fm10k_stats fm10k_gstrings_queue_stats[] = {
107 	FM10K_QUEUE_STAT("%s_queue_%u_packets", stats.packets),
108 	FM10K_QUEUE_STAT("%s_queue_%u_bytes", stats.bytes),
109 };
110 
111 #define FM10K_GLOBAL_STATS_LEN ARRAY_SIZE(fm10k_gstrings_global_stats)
112 #define FM10K_PF_STATS_LEN ARRAY_SIZE(fm10k_gstrings_pf_stats)
113 #define FM10K_MBX_STATS_LEN ARRAY_SIZE(fm10k_gstrings_mbx_stats)
114 #define FM10K_QUEUE_STATS_LEN ARRAY_SIZE(fm10k_gstrings_queue_stats)
115 
116 #define FM10K_STATIC_STATS_LEN (FM10K_GLOBAL_STATS_LEN + \
117 				FM10K_NETDEV_STATS_LEN + \
118 				FM10K_MBX_STATS_LEN)
119 
120 static const char fm10k_gstrings_test[][ETH_GSTRING_LEN] = {
121 	"Mailbox test (on/offline)"
122 };
123 
124 #define FM10K_TEST_LEN (sizeof(fm10k_gstrings_test) / ETH_GSTRING_LEN)
125 
126 enum fm10k_self_test_types {
127 	FM10K_TEST_MBX,
128 	FM10K_TEST_MAX = FM10K_TEST_LEN
129 };
130 
131 enum {
132 	FM10K_PRV_FLAG_LEN,
133 };
134 
135 static const char fm10k_prv_flags[FM10K_PRV_FLAG_LEN][ETH_GSTRING_LEN] = {
136 };
137 
138 static void __fm10k_add_stat_strings(u8 **p, const struct fm10k_stats stats[],
139 				     const unsigned int size, ...)
140 {
141 	unsigned int i;
142 
143 	for (i = 0; i < size; i++) {
144 		va_list args;
145 
146 		va_start(args, size);
147 		vsnprintf(*p, ETH_GSTRING_LEN, stats[i].stat_string, args);
148 		*p += ETH_GSTRING_LEN;
149 		va_end(args);
150 	}
151 }
152 
153 #define fm10k_add_stat_strings(p, stats, ...) \
154 	__fm10k_add_stat_strings(p, stats, ARRAY_SIZE(stats), ## __VA_ARGS__)
155 
156 static void fm10k_get_stat_strings(struct net_device *dev, u8 *data)
157 {
158 	struct fm10k_intfc *interface = netdev_priv(dev);
159 	unsigned int i;
160 
161 	fm10k_add_stat_strings(&data, fm10k_gstrings_net_stats);
162 
163 	fm10k_add_stat_strings(&data, fm10k_gstrings_global_stats);
164 
165 	fm10k_add_stat_strings(&data, fm10k_gstrings_mbx_stats);
166 
167 	if (interface->hw.mac.type != fm10k_mac_vf)
168 		fm10k_add_stat_strings(&data, fm10k_gstrings_pf_stats);
169 
170 	for (i = 0; i < interface->hw.mac.max_queues; i++) {
171 		fm10k_add_stat_strings(&data, fm10k_gstrings_queue_stats,
172 				       "tx", i);
173 
174 		fm10k_add_stat_strings(&data, fm10k_gstrings_queue_stats,
175 				       "rx", i);
176 	}
177 }
178 
179 static void fm10k_get_strings(struct net_device *dev,
180 			      u32 stringset, u8 *data)
181 {
182 	switch (stringset) {
183 	case ETH_SS_TEST:
184 		memcpy(data, fm10k_gstrings_test,
185 		       FM10K_TEST_LEN * ETH_GSTRING_LEN);
186 		break;
187 	case ETH_SS_STATS:
188 		fm10k_get_stat_strings(dev, data);
189 		break;
190 	case ETH_SS_PRIV_FLAGS:
191 		memcpy(data, fm10k_prv_flags,
192 		       FM10K_PRV_FLAG_LEN * ETH_GSTRING_LEN);
193 		break;
194 	}
195 }
196 
197 static int fm10k_get_sset_count(struct net_device *dev, int sset)
198 {
199 	struct fm10k_intfc *interface = netdev_priv(dev);
200 	struct fm10k_hw *hw = &interface->hw;
201 	int stats_len = FM10K_STATIC_STATS_LEN;
202 
203 	switch (sset) {
204 	case ETH_SS_TEST:
205 		return FM10K_TEST_LEN;
206 	case ETH_SS_STATS:
207 		stats_len += hw->mac.max_queues * 2 * FM10K_QUEUE_STATS_LEN;
208 
209 		if (hw->mac.type != fm10k_mac_vf)
210 			stats_len += FM10K_PF_STATS_LEN;
211 
212 		return stats_len;
213 	case ETH_SS_PRIV_FLAGS:
214 		return FM10K_PRV_FLAG_LEN;
215 	default:
216 		return -EOPNOTSUPP;
217 	}
218 }
219 
220 static void __fm10k_add_ethtool_stats(u64 **data, void *pointer,
221 				      const struct fm10k_stats stats[],
222 				      const unsigned int size)
223 {
224 	unsigned int i;
225 	char *p;
226 
227 	if (!pointer) {
228 		/* memory is not zero allocated so we have to clear it */
229 		for (i = 0; i < size; i++)
230 			*((*data)++) = 0;
231 		return;
232 	}
233 
234 	for (i = 0; i < size; i++) {
235 		p = (char *)pointer + stats[i].stat_offset;
236 
237 		switch (stats[i].sizeof_stat) {
238 		case sizeof(u64):
239 			*((*data)++) = *(u64 *)p;
240 			break;
241 		case sizeof(u32):
242 			*((*data)++) = *(u32 *)p;
243 			break;
244 		case sizeof(u16):
245 			*((*data)++) = *(u16 *)p;
246 			break;
247 		case sizeof(u8):
248 			*((*data)++) = *(u8 *)p;
249 			break;
250 		default:
251 			WARN_ONCE(1, "unexpected stat size for %s",
252 				  stats[i].stat_string);
253 			*((*data)++) = 0;
254 		}
255 	}
256 }
257 
258 #define fm10k_add_ethtool_stats(data, pointer, stats) \
259 	__fm10k_add_ethtool_stats(data, pointer, stats, ARRAY_SIZE(stats))
260 
261 static void fm10k_get_ethtool_stats(struct net_device *netdev,
262 				    struct ethtool_stats __always_unused *stats,
263 				    u64 *data)
264 {
265 	struct fm10k_intfc *interface = netdev_priv(netdev);
266 	struct net_device_stats *net_stats = &netdev->stats;
267 	int i;
268 
269 	fm10k_update_stats(interface);
270 
271 	fm10k_add_ethtool_stats(&data, net_stats, fm10k_gstrings_net_stats);
272 
273 	fm10k_add_ethtool_stats(&data, interface, fm10k_gstrings_global_stats);
274 
275 	fm10k_add_ethtool_stats(&data, &interface->hw.mbx,
276 				fm10k_gstrings_mbx_stats);
277 
278 	if (interface->hw.mac.type != fm10k_mac_vf) {
279 		fm10k_add_ethtool_stats(&data, interface,
280 					fm10k_gstrings_pf_stats);
281 	}
282 
283 	for (i = 0; i < interface->hw.mac.max_queues; i++) {
284 		struct fm10k_ring *ring;
285 
286 		ring = interface->tx_ring[i];
287 		fm10k_add_ethtool_stats(&data, ring,
288 					fm10k_gstrings_queue_stats);
289 
290 		ring = interface->rx_ring[i];
291 		fm10k_add_ethtool_stats(&data, ring,
292 					fm10k_gstrings_queue_stats);
293 	}
294 }
295 
296 /* If function below adds more registers this define needs to be updated */
297 #define FM10K_REGS_LEN_Q 29
298 
299 static void fm10k_get_reg_q(struct fm10k_hw *hw, u32 *buff, int i)
300 {
301 	int idx = 0;
302 
303 	buff[idx++] = fm10k_read_reg(hw, FM10K_RDBAL(i));
304 	buff[idx++] = fm10k_read_reg(hw, FM10K_RDBAH(i));
305 	buff[idx++] = fm10k_read_reg(hw, FM10K_RDLEN(i));
306 	buff[idx++] = fm10k_read_reg(hw, FM10K_TPH_RXCTRL(i));
307 	buff[idx++] = fm10k_read_reg(hw, FM10K_RDH(i));
308 	buff[idx++] = fm10k_read_reg(hw, FM10K_RDT(i));
309 	buff[idx++] = fm10k_read_reg(hw, FM10K_RXQCTL(i));
310 	buff[idx++] = fm10k_read_reg(hw, FM10K_RXDCTL(i));
311 	buff[idx++] = fm10k_read_reg(hw, FM10K_RXINT(i));
312 	buff[idx++] = fm10k_read_reg(hw, FM10K_SRRCTL(i));
313 	buff[idx++] = fm10k_read_reg(hw, FM10K_QPRC(i));
314 	buff[idx++] = fm10k_read_reg(hw, FM10K_QPRDC(i));
315 	buff[idx++] = fm10k_read_reg(hw, FM10K_QBRC_L(i));
316 	buff[idx++] = fm10k_read_reg(hw, FM10K_QBRC_H(i));
317 	buff[idx++] = fm10k_read_reg(hw, FM10K_TDBAL(i));
318 	buff[idx++] = fm10k_read_reg(hw, FM10K_TDBAH(i));
319 	buff[idx++] = fm10k_read_reg(hw, FM10K_TDLEN(i));
320 	buff[idx++] = fm10k_read_reg(hw, FM10K_TPH_TXCTRL(i));
321 	buff[idx++] = fm10k_read_reg(hw, FM10K_TDH(i));
322 	buff[idx++] = fm10k_read_reg(hw, FM10K_TDT(i));
323 	buff[idx++] = fm10k_read_reg(hw, FM10K_TXDCTL(i));
324 	buff[idx++] = fm10k_read_reg(hw, FM10K_TXQCTL(i));
325 	buff[idx++] = fm10k_read_reg(hw, FM10K_TXINT(i));
326 	buff[idx++] = fm10k_read_reg(hw, FM10K_QPTC(i));
327 	buff[idx++] = fm10k_read_reg(hw, FM10K_QBTC_L(i));
328 	buff[idx++] = fm10k_read_reg(hw, FM10K_QBTC_H(i));
329 	buff[idx++] = fm10k_read_reg(hw, FM10K_TQDLOC(i));
330 	buff[idx++] = fm10k_read_reg(hw, FM10K_TX_SGLORT(i));
331 	buff[idx++] = fm10k_read_reg(hw, FM10K_PFVTCTL(i));
332 
333 	BUG_ON(idx != FM10K_REGS_LEN_Q);
334 }
335 
336 /* If function above adds more registers this define needs to be updated */
337 #define FM10K_REGS_LEN_VSI 43
338 
339 static void fm10k_get_reg_vsi(struct fm10k_hw *hw, u32 *buff, int i)
340 {
341 	int idx = 0, j;
342 
343 	buff[idx++] = fm10k_read_reg(hw, FM10K_MRQC(i));
344 	for (j = 0; j < 10; j++)
345 		buff[idx++] = fm10k_read_reg(hw, FM10K_RSSRK(i, j));
346 	for (j = 0; j < 32; j++)
347 		buff[idx++] = fm10k_read_reg(hw, FM10K_RETA(i, j));
348 
349 	BUG_ON(idx != FM10K_REGS_LEN_VSI);
350 }
351 
352 static void fm10k_get_regs(struct net_device *netdev,
353 			   struct ethtool_regs *regs, void *p)
354 {
355 	struct fm10k_intfc *interface = netdev_priv(netdev);
356 	struct fm10k_hw *hw = &interface->hw;
357 	u32 *buff = p;
358 	u16 i;
359 
360 	regs->version = BIT(24) | (hw->revision_id << 16) | hw->device_id;
361 
362 	switch (hw->mac.type) {
363 	case fm10k_mac_pf:
364 		/* General PF Registers */
365 		*(buff++) = fm10k_read_reg(hw, FM10K_CTRL);
366 		*(buff++) = fm10k_read_reg(hw, FM10K_CTRL_EXT);
367 		*(buff++) = fm10k_read_reg(hw, FM10K_GCR);
368 		*(buff++) = fm10k_read_reg(hw, FM10K_GCR_EXT);
369 
370 		for (i = 0; i < 8; i++) {
371 			*(buff++) = fm10k_read_reg(hw, FM10K_DGLORTMAP(i));
372 			*(buff++) = fm10k_read_reg(hw, FM10K_DGLORTDEC(i));
373 		}
374 
375 		for (i = 0; i < 65; i++) {
376 			fm10k_get_reg_vsi(hw, buff, i);
377 			buff += FM10K_REGS_LEN_VSI;
378 		}
379 
380 		*(buff++) = fm10k_read_reg(hw, FM10K_DMA_CTRL);
381 		*(buff++) = fm10k_read_reg(hw, FM10K_DMA_CTRL2);
382 
383 		for (i = 0; i < FM10K_MAX_QUEUES_PF; i++) {
384 			fm10k_get_reg_q(hw, buff, i);
385 			buff += FM10K_REGS_LEN_Q;
386 		}
387 
388 		*(buff++) = fm10k_read_reg(hw, FM10K_TPH_CTRL);
389 
390 		for (i = 0; i < 8; i++)
391 			*(buff++) = fm10k_read_reg(hw, FM10K_INT_MAP(i));
392 
393 		/* Interrupt Throttling Registers */
394 		for (i = 0; i < 130; i++)
395 			*(buff++) = fm10k_read_reg(hw, FM10K_ITR(i));
396 
397 		break;
398 	case fm10k_mac_vf:
399 		/* General VF registers */
400 		*(buff++) = fm10k_read_reg(hw, FM10K_VFCTRL);
401 		*(buff++) = fm10k_read_reg(hw, FM10K_VFINT_MAP);
402 		*(buff++) = fm10k_read_reg(hw, FM10K_VFSYSTIME);
403 
404 		/* Interrupt Throttling Registers */
405 		for (i = 0; i < 8; i++)
406 			*(buff++) = fm10k_read_reg(hw, FM10K_VFITR(i));
407 
408 		fm10k_get_reg_vsi(hw, buff, 0);
409 		buff += FM10K_REGS_LEN_VSI;
410 
411 		for (i = 0; i < FM10K_MAX_QUEUES_POOL; i++) {
412 			if (i < hw->mac.max_queues)
413 				fm10k_get_reg_q(hw, buff, i);
414 			else
415 				memset(buff, 0, sizeof(u32) * FM10K_REGS_LEN_Q);
416 			buff += FM10K_REGS_LEN_Q;
417 		}
418 
419 		break;
420 	default:
421 		return;
422 	}
423 }
424 
425 /* If function above adds more registers these define need to be updated */
426 #define FM10K_REGS_LEN_PF \
427 (162 + (65 * FM10K_REGS_LEN_VSI) + (FM10K_MAX_QUEUES_PF * FM10K_REGS_LEN_Q))
428 #define FM10K_REGS_LEN_VF \
429 (11 + FM10K_REGS_LEN_VSI + (FM10K_MAX_QUEUES_POOL * FM10K_REGS_LEN_Q))
430 
431 static int fm10k_get_regs_len(struct net_device *netdev)
432 {
433 	struct fm10k_intfc *interface = netdev_priv(netdev);
434 	struct fm10k_hw *hw = &interface->hw;
435 
436 	switch (hw->mac.type) {
437 	case fm10k_mac_pf:
438 		return FM10K_REGS_LEN_PF * sizeof(u32);
439 	case fm10k_mac_vf:
440 		return FM10K_REGS_LEN_VF * sizeof(u32);
441 	default:
442 		return 0;
443 	}
444 }
445 
446 static void fm10k_get_drvinfo(struct net_device *dev,
447 			      struct ethtool_drvinfo *info)
448 {
449 	struct fm10k_intfc *interface = netdev_priv(dev);
450 
451 	strncpy(info->driver, fm10k_driver_name,
452 		sizeof(info->driver) - 1);
453 	strncpy(info->version, fm10k_driver_version,
454 		sizeof(info->version) - 1);
455 	strncpy(info->bus_info, pci_name(interface->pdev),
456 		sizeof(info->bus_info) - 1);
457 }
458 
459 static void fm10k_get_pauseparam(struct net_device *dev,
460 				 struct ethtool_pauseparam *pause)
461 {
462 	struct fm10k_intfc *interface = netdev_priv(dev);
463 
464 	/* record fixed values for autoneg and tx pause */
465 	pause->autoneg = 0;
466 	pause->tx_pause = 1;
467 
468 	pause->rx_pause = interface->rx_pause ? 1 : 0;
469 }
470 
471 static int fm10k_set_pauseparam(struct net_device *dev,
472 				struct ethtool_pauseparam *pause)
473 {
474 	struct fm10k_intfc *interface = netdev_priv(dev);
475 	struct fm10k_hw *hw = &interface->hw;
476 
477 	if (pause->autoneg || !pause->tx_pause)
478 		return -EINVAL;
479 
480 	/* we can only support pause on the PF to avoid head-of-line blocking */
481 	if (hw->mac.type == fm10k_mac_pf)
482 		interface->rx_pause = pause->rx_pause ? ~0 : 0;
483 	else if (pause->rx_pause)
484 		return -EINVAL;
485 
486 	if (netif_running(dev))
487 		fm10k_update_rx_drop_en(interface);
488 
489 	return 0;
490 }
491 
492 static u32 fm10k_get_msglevel(struct net_device *netdev)
493 {
494 	struct fm10k_intfc *interface = netdev_priv(netdev);
495 
496 	return interface->msg_enable;
497 }
498 
499 static void fm10k_set_msglevel(struct net_device *netdev, u32 data)
500 {
501 	struct fm10k_intfc *interface = netdev_priv(netdev);
502 
503 	interface->msg_enable = data;
504 }
505 
506 static void fm10k_get_ringparam(struct net_device *netdev,
507 				struct ethtool_ringparam *ring)
508 {
509 	struct fm10k_intfc *interface = netdev_priv(netdev);
510 
511 	ring->rx_max_pending = FM10K_MAX_RXD;
512 	ring->tx_max_pending = FM10K_MAX_TXD;
513 	ring->rx_mini_max_pending = 0;
514 	ring->rx_jumbo_max_pending = 0;
515 	ring->rx_pending = interface->rx_ring_count;
516 	ring->tx_pending = interface->tx_ring_count;
517 	ring->rx_mini_pending = 0;
518 	ring->rx_jumbo_pending = 0;
519 }
520 
521 static int fm10k_set_ringparam(struct net_device *netdev,
522 			       struct ethtool_ringparam *ring)
523 {
524 	struct fm10k_intfc *interface = netdev_priv(netdev);
525 	struct fm10k_ring *temp_ring;
526 	int i, err = 0;
527 	u32 new_rx_count, new_tx_count;
528 
529 	if ((ring->rx_mini_pending) || (ring->rx_jumbo_pending))
530 		return -EINVAL;
531 
532 	new_tx_count = clamp_t(u32, ring->tx_pending,
533 			       FM10K_MIN_TXD, FM10K_MAX_TXD);
534 	new_tx_count = ALIGN(new_tx_count, FM10K_REQ_TX_DESCRIPTOR_MULTIPLE);
535 
536 	new_rx_count = clamp_t(u32, ring->rx_pending,
537 			       FM10K_MIN_RXD, FM10K_MAX_RXD);
538 	new_rx_count = ALIGN(new_rx_count, FM10K_REQ_RX_DESCRIPTOR_MULTIPLE);
539 
540 	if ((new_tx_count == interface->tx_ring_count) &&
541 	    (new_rx_count == interface->rx_ring_count)) {
542 		/* nothing to do */
543 		return 0;
544 	}
545 
546 	while (test_and_set_bit(__FM10K_RESETTING, interface->state))
547 		usleep_range(1000, 2000);
548 
549 	if (!netif_running(interface->netdev)) {
550 		for (i = 0; i < interface->num_tx_queues; i++)
551 			interface->tx_ring[i]->count = new_tx_count;
552 		for (i = 0; i < interface->num_rx_queues; i++)
553 			interface->rx_ring[i]->count = new_rx_count;
554 		interface->tx_ring_count = new_tx_count;
555 		interface->rx_ring_count = new_rx_count;
556 		goto clear_reset;
557 	}
558 
559 	/* allocate temporary buffer to store rings in */
560 	i = max_t(int, interface->num_tx_queues, interface->num_rx_queues);
561 	temp_ring = vmalloc(array_size(i, sizeof(struct fm10k_ring)));
562 
563 	if (!temp_ring) {
564 		err = -ENOMEM;
565 		goto clear_reset;
566 	}
567 
568 	fm10k_down(interface);
569 
570 	/* Setup new Tx resources and free the old Tx resources in that order.
571 	 * We can then assign the new resources to the rings via a memcpy.
572 	 * The advantage to this approach is that we are guaranteed to still
573 	 * have resources even in the case of an allocation failure.
574 	 */
575 	if (new_tx_count != interface->tx_ring_count) {
576 		for (i = 0; i < interface->num_tx_queues; i++) {
577 			memcpy(&temp_ring[i], interface->tx_ring[i],
578 			       sizeof(struct fm10k_ring));
579 
580 			temp_ring[i].count = new_tx_count;
581 			err = fm10k_setup_tx_resources(&temp_ring[i]);
582 			if (err) {
583 				while (i) {
584 					i--;
585 					fm10k_free_tx_resources(&temp_ring[i]);
586 				}
587 				goto err_setup;
588 			}
589 		}
590 
591 		for (i = 0; i < interface->num_tx_queues; i++) {
592 			fm10k_free_tx_resources(interface->tx_ring[i]);
593 
594 			memcpy(interface->tx_ring[i], &temp_ring[i],
595 			       sizeof(struct fm10k_ring));
596 		}
597 
598 		interface->tx_ring_count = new_tx_count;
599 	}
600 
601 	/* Repeat the process for the Rx rings if needed */
602 	if (new_rx_count != interface->rx_ring_count) {
603 		for (i = 0; i < interface->num_rx_queues; i++) {
604 			memcpy(&temp_ring[i], interface->rx_ring[i],
605 			       sizeof(struct fm10k_ring));
606 
607 			temp_ring[i].count = new_rx_count;
608 			err = fm10k_setup_rx_resources(&temp_ring[i]);
609 			if (err) {
610 				while (i) {
611 					i--;
612 					fm10k_free_rx_resources(&temp_ring[i]);
613 				}
614 				goto err_setup;
615 			}
616 		}
617 
618 		for (i = 0; i < interface->num_rx_queues; i++) {
619 			fm10k_free_rx_resources(interface->rx_ring[i]);
620 
621 			memcpy(interface->rx_ring[i], &temp_ring[i],
622 			       sizeof(struct fm10k_ring));
623 		}
624 
625 		interface->rx_ring_count = new_rx_count;
626 	}
627 
628 err_setup:
629 	fm10k_up(interface);
630 	vfree(temp_ring);
631 clear_reset:
632 	clear_bit(__FM10K_RESETTING, interface->state);
633 	return err;
634 }
635 
636 static int fm10k_get_coalesce(struct net_device *dev,
637 			      struct ethtool_coalesce *ec)
638 {
639 	struct fm10k_intfc *interface = netdev_priv(dev);
640 
641 	ec->use_adaptive_tx_coalesce = ITR_IS_ADAPTIVE(interface->tx_itr);
642 	ec->tx_coalesce_usecs = interface->tx_itr & ~FM10K_ITR_ADAPTIVE;
643 
644 	ec->use_adaptive_rx_coalesce = ITR_IS_ADAPTIVE(interface->rx_itr);
645 	ec->rx_coalesce_usecs = interface->rx_itr & ~FM10K_ITR_ADAPTIVE;
646 
647 	return 0;
648 }
649 
650 static int fm10k_set_coalesce(struct net_device *dev,
651 			      struct ethtool_coalesce *ec)
652 {
653 	struct fm10k_intfc *interface = netdev_priv(dev);
654 	struct fm10k_q_vector *qv;
655 	u16 tx_itr, rx_itr;
656 	int i;
657 
658 	/* verify limits */
659 	if ((ec->rx_coalesce_usecs > FM10K_ITR_MAX) ||
660 	    (ec->tx_coalesce_usecs > FM10K_ITR_MAX))
661 		return -EINVAL;
662 
663 	/* record settings */
664 	tx_itr = ec->tx_coalesce_usecs;
665 	rx_itr = ec->rx_coalesce_usecs;
666 
667 	/* set initial values for adaptive ITR */
668 	if (ec->use_adaptive_tx_coalesce)
669 		tx_itr = FM10K_ITR_ADAPTIVE | FM10K_TX_ITR_DEFAULT;
670 
671 	if (ec->use_adaptive_rx_coalesce)
672 		rx_itr = FM10K_ITR_ADAPTIVE | FM10K_RX_ITR_DEFAULT;
673 
674 	/* update interface */
675 	interface->tx_itr = tx_itr;
676 	interface->rx_itr = rx_itr;
677 
678 	/* update q_vectors */
679 	for (i = 0; i < interface->num_q_vectors; i++) {
680 		qv = interface->q_vector[i];
681 		qv->tx.itr = tx_itr;
682 		qv->rx.itr = rx_itr;
683 	}
684 
685 	return 0;
686 }
687 
688 static int fm10k_get_rss_hash_opts(struct fm10k_intfc *interface,
689 				   struct ethtool_rxnfc *cmd)
690 {
691 	cmd->data = 0;
692 
693 	/* Report default options for RSS on fm10k */
694 	switch (cmd->flow_type) {
695 	case TCP_V4_FLOW:
696 	case TCP_V6_FLOW:
697 		cmd->data |= RXH_L4_B_0_1 | RXH_L4_B_2_3;
698 		/* fall through */
699 	case UDP_V4_FLOW:
700 		if (test_bit(FM10K_FLAG_RSS_FIELD_IPV4_UDP,
701 			     interface->flags))
702 			cmd->data |= RXH_L4_B_0_1 | RXH_L4_B_2_3;
703 		/* fall through */
704 	case SCTP_V4_FLOW:
705 	case SCTP_V6_FLOW:
706 	case AH_ESP_V4_FLOW:
707 	case AH_ESP_V6_FLOW:
708 	case AH_V4_FLOW:
709 	case AH_V6_FLOW:
710 	case ESP_V4_FLOW:
711 	case ESP_V6_FLOW:
712 	case IPV4_FLOW:
713 	case IPV6_FLOW:
714 		cmd->data |= RXH_IP_SRC | RXH_IP_DST;
715 		break;
716 	case UDP_V6_FLOW:
717 		if (test_bit(FM10K_FLAG_RSS_FIELD_IPV6_UDP,
718 			     interface->flags))
719 			cmd->data |= RXH_L4_B_0_1 | RXH_L4_B_2_3;
720 		cmd->data |= RXH_IP_SRC | RXH_IP_DST;
721 		break;
722 	default:
723 		return -EINVAL;
724 	}
725 
726 	return 0;
727 }
728 
729 static int fm10k_get_rxnfc(struct net_device *dev, struct ethtool_rxnfc *cmd,
730 			   u32 __always_unused *rule_locs)
731 {
732 	struct fm10k_intfc *interface = netdev_priv(dev);
733 	int ret = -EOPNOTSUPP;
734 
735 	switch (cmd->cmd) {
736 	case ETHTOOL_GRXRINGS:
737 		cmd->data = interface->num_rx_queues;
738 		ret = 0;
739 		break;
740 	case ETHTOOL_GRXFH:
741 		ret = fm10k_get_rss_hash_opts(interface, cmd);
742 		break;
743 	default:
744 		break;
745 	}
746 
747 	return ret;
748 }
749 
750 static int fm10k_set_rss_hash_opt(struct fm10k_intfc *interface,
751 				  struct ethtool_rxnfc *nfc)
752 {
753 	int rss_ipv4_udp = test_bit(FM10K_FLAG_RSS_FIELD_IPV4_UDP,
754 				    interface->flags);
755 	int rss_ipv6_udp = test_bit(FM10K_FLAG_RSS_FIELD_IPV6_UDP,
756 				    interface->flags);
757 
758 	/* RSS does not support anything other than hashing
759 	 * to queues on src and dst IPs and ports
760 	 */
761 	if (nfc->data & ~(RXH_IP_SRC | RXH_IP_DST |
762 			  RXH_L4_B_0_1 | RXH_L4_B_2_3))
763 		return -EINVAL;
764 
765 	switch (nfc->flow_type) {
766 	case TCP_V4_FLOW:
767 	case TCP_V6_FLOW:
768 		if (!(nfc->data & RXH_IP_SRC) ||
769 		    !(nfc->data & RXH_IP_DST) ||
770 		    !(nfc->data & RXH_L4_B_0_1) ||
771 		    !(nfc->data & RXH_L4_B_2_3))
772 			return -EINVAL;
773 		break;
774 	case UDP_V4_FLOW:
775 		if (!(nfc->data & RXH_IP_SRC) ||
776 		    !(nfc->data & RXH_IP_DST))
777 			return -EINVAL;
778 		switch (nfc->data & (RXH_L4_B_0_1 | RXH_L4_B_2_3)) {
779 		case 0:
780 			clear_bit(FM10K_FLAG_RSS_FIELD_IPV4_UDP,
781 				  interface->flags);
782 			break;
783 		case (RXH_L4_B_0_1 | RXH_L4_B_2_3):
784 			set_bit(FM10K_FLAG_RSS_FIELD_IPV4_UDP,
785 				interface->flags);
786 			break;
787 		default:
788 			return -EINVAL;
789 		}
790 		break;
791 	case UDP_V6_FLOW:
792 		if (!(nfc->data & RXH_IP_SRC) ||
793 		    !(nfc->data & RXH_IP_DST))
794 			return -EINVAL;
795 		switch (nfc->data & (RXH_L4_B_0_1 | RXH_L4_B_2_3)) {
796 		case 0:
797 			clear_bit(FM10K_FLAG_RSS_FIELD_IPV6_UDP,
798 				  interface->flags);
799 			break;
800 		case (RXH_L4_B_0_1 | RXH_L4_B_2_3):
801 			set_bit(FM10K_FLAG_RSS_FIELD_IPV6_UDP,
802 				interface->flags);
803 			break;
804 		default:
805 			return -EINVAL;
806 		}
807 		break;
808 	case AH_ESP_V4_FLOW:
809 	case AH_V4_FLOW:
810 	case ESP_V4_FLOW:
811 	case SCTP_V4_FLOW:
812 	case AH_ESP_V6_FLOW:
813 	case AH_V6_FLOW:
814 	case ESP_V6_FLOW:
815 	case SCTP_V6_FLOW:
816 		if (!(nfc->data & RXH_IP_SRC) ||
817 		    !(nfc->data & RXH_IP_DST) ||
818 		    (nfc->data & RXH_L4_B_0_1) ||
819 		    (nfc->data & RXH_L4_B_2_3))
820 			return -EINVAL;
821 		break;
822 	default:
823 		return -EINVAL;
824 	}
825 
826 	/* If something changed we need to update the MRQC register. Note that
827 	 * test_bit() is guaranteed to return strictly 0 or 1, so testing for
828 	 * equality is safe.
829 	 */
830 	if ((rss_ipv4_udp != test_bit(FM10K_FLAG_RSS_FIELD_IPV4_UDP,
831 				      interface->flags)) ||
832 	    (rss_ipv6_udp != test_bit(FM10K_FLAG_RSS_FIELD_IPV6_UDP,
833 				      interface->flags))) {
834 		struct fm10k_hw *hw = &interface->hw;
835 		bool warn = false;
836 		u32 mrqc;
837 
838 		/* Perform hash on these packet types */
839 		mrqc = FM10K_MRQC_IPV4 |
840 		       FM10K_MRQC_TCP_IPV4 |
841 		       FM10K_MRQC_IPV6 |
842 		       FM10K_MRQC_TCP_IPV6;
843 
844 		if (test_bit(FM10K_FLAG_RSS_FIELD_IPV4_UDP,
845 			     interface->flags)) {
846 			mrqc |= FM10K_MRQC_UDP_IPV4;
847 			warn = true;
848 		}
849 		if (test_bit(FM10K_FLAG_RSS_FIELD_IPV6_UDP,
850 			     interface->flags)) {
851 			mrqc |= FM10K_MRQC_UDP_IPV6;
852 			warn = true;
853 		}
854 
855 		/* If we enable UDP RSS display a warning that this may cause
856 		 * fragmented UDP packets to arrive out of order.
857 		 */
858 		if (warn)
859 			netif_warn(interface, drv, interface->netdev,
860 				   "enabling UDP RSS: fragmented packets may arrive out of order to the stack above\n");
861 
862 		fm10k_write_reg(hw, FM10K_MRQC(0), mrqc);
863 	}
864 
865 	return 0;
866 }
867 
868 static int fm10k_set_rxnfc(struct net_device *dev, struct ethtool_rxnfc *cmd)
869 {
870 	struct fm10k_intfc *interface = netdev_priv(dev);
871 	int ret = -EOPNOTSUPP;
872 
873 	switch (cmd->cmd) {
874 	case ETHTOOL_SRXFH:
875 		ret = fm10k_set_rss_hash_opt(interface, cmd);
876 		break;
877 	default:
878 		break;
879 	}
880 
881 	return ret;
882 }
883 
884 static int fm10k_mbx_test(struct fm10k_intfc *interface, u64 *data)
885 {
886 	struct fm10k_hw *hw = &interface->hw;
887 	struct fm10k_mbx_info *mbx = &hw->mbx;
888 	u32 attr_flag, test_msg[6];
889 	unsigned long timeout;
890 	int err = -EINVAL;
891 
892 	/* For now this is a VF only feature */
893 	if (hw->mac.type != fm10k_mac_vf)
894 		return 0;
895 
896 	/* loop through both nested and unnested attribute types */
897 	for (attr_flag = BIT(FM10K_TEST_MSG_UNSET);
898 	     attr_flag < BIT(2 * FM10K_TEST_MSG_NESTED);
899 	     attr_flag += attr_flag) {
900 		/* generate message to be tested */
901 		fm10k_tlv_msg_test_create(test_msg, attr_flag);
902 
903 		fm10k_mbx_lock(interface);
904 		mbx->test_result = FM10K_NOT_IMPLEMENTED;
905 		err = mbx->ops.enqueue_tx(hw, mbx, test_msg);
906 		fm10k_mbx_unlock(interface);
907 
908 		/* wait up to 1 second for response */
909 		timeout = jiffies + HZ;
910 		do {
911 			if (err < 0)
912 				goto err_out;
913 
914 			usleep_range(500, 1000);
915 
916 			fm10k_mbx_lock(interface);
917 			mbx->ops.process(hw, mbx);
918 			fm10k_mbx_unlock(interface);
919 
920 			err = mbx->test_result;
921 			if (!err)
922 				break;
923 		} while (time_is_after_jiffies(timeout));
924 
925 		/* reporting errors */
926 		if (err)
927 			goto err_out;
928 	}
929 
930 err_out:
931 	*data = err < 0 ? (attr_flag) : (err > 0);
932 	return err;
933 }
934 
935 static void fm10k_self_test(struct net_device *dev,
936 			    struct ethtool_test *eth_test, u64 *data)
937 {
938 	struct fm10k_intfc *interface = netdev_priv(dev);
939 	struct fm10k_hw *hw = &interface->hw;
940 
941 	memset(data, 0, sizeof(*data) * FM10K_TEST_LEN);
942 
943 	if (FM10K_REMOVED(hw->hw_addr)) {
944 		netif_err(interface, drv, dev,
945 			  "Interface removed - test blocked\n");
946 		eth_test->flags |= ETH_TEST_FL_FAILED;
947 		return;
948 	}
949 
950 	if (fm10k_mbx_test(interface, &data[FM10K_TEST_MBX]))
951 		eth_test->flags |= ETH_TEST_FL_FAILED;
952 }
953 
954 static u32 fm10k_get_priv_flags(struct net_device *netdev)
955 {
956 	return 0;
957 }
958 
959 static int fm10k_set_priv_flags(struct net_device *netdev, u32 priv_flags)
960 {
961 	if (priv_flags >= BIT(FM10K_PRV_FLAG_LEN))
962 		return -EINVAL;
963 
964 	return 0;
965 }
966 
967 static u32 fm10k_get_reta_size(struct net_device __always_unused *netdev)
968 {
969 	return FM10K_RETA_SIZE * FM10K_RETA_ENTRIES_PER_REG;
970 }
971 
972 void fm10k_write_reta(struct fm10k_intfc *interface, const u32 *indir)
973 {
974 	u16 rss_i = interface->ring_feature[RING_F_RSS].indices;
975 	struct fm10k_hw *hw = &interface->hw;
976 	u32 table[4];
977 	int i, j;
978 
979 	/* record entries to reta table */
980 	for (i = 0; i < FM10K_RETA_SIZE; i++) {
981 		u32 reta, n;
982 
983 		/* generate a new table if we weren't given one */
984 		for (j = 0; j < 4; j++) {
985 			if (indir)
986 				n = indir[4 * i + j];
987 			else
988 				n = ethtool_rxfh_indir_default(4 * i + j,
989 							       rss_i);
990 
991 			table[j] = n;
992 		}
993 
994 		reta = table[0] |
995 			(table[1] << 8) |
996 			(table[2] << 16) |
997 			(table[3] << 24);
998 
999 		if (interface->reta[i] == reta)
1000 			continue;
1001 
1002 		interface->reta[i] = reta;
1003 		fm10k_write_reg(hw, FM10K_RETA(0, i), reta);
1004 	}
1005 }
1006 
1007 static int fm10k_get_reta(struct net_device *netdev, u32 *indir)
1008 {
1009 	struct fm10k_intfc *interface = netdev_priv(netdev);
1010 	int i;
1011 
1012 	if (!indir)
1013 		return 0;
1014 
1015 	for (i = 0; i < FM10K_RETA_SIZE; i++, indir += 4) {
1016 		u32 reta = interface->reta[i];
1017 
1018 		indir[0] = (reta << 24) >> 24;
1019 		indir[1] = (reta << 16) >> 24;
1020 		indir[2] = (reta <<  8) >> 24;
1021 		indir[3] = (reta) >> 24;
1022 	}
1023 
1024 	return 0;
1025 }
1026 
1027 static int fm10k_set_reta(struct net_device *netdev, const u32 *indir)
1028 {
1029 	struct fm10k_intfc *interface = netdev_priv(netdev);
1030 	int i;
1031 	u16 rss_i;
1032 
1033 	if (!indir)
1034 		return 0;
1035 
1036 	/* Verify user input. */
1037 	rss_i = interface->ring_feature[RING_F_RSS].indices;
1038 	for (i = fm10k_get_reta_size(netdev); i--;) {
1039 		if (indir[i] < rss_i)
1040 			continue;
1041 		return -EINVAL;
1042 	}
1043 
1044 	fm10k_write_reta(interface, indir);
1045 
1046 	return 0;
1047 }
1048 
1049 static u32 fm10k_get_rssrk_size(struct net_device __always_unused *netdev)
1050 {
1051 	return FM10K_RSSRK_SIZE * FM10K_RSSRK_ENTRIES_PER_REG;
1052 }
1053 
1054 static int fm10k_get_rssh(struct net_device *netdev, u32 *indir, u8 *key,
1055 			  u8 *hfunc)
1056 {
1057 	struct fm10k_intfc *interface = netdev_priv(netdev);
1058 	int i, err;
1059 
1060 	if (hfunc)
1061 		*hfunc = ETH_RSS_HASH_TOP;
1062 
1063 	err = fm10k_get_reta(netdev, indir);
1064 	if (err || !key)
1065 		return err;
1066 
1067 	for (i = 0; i < FM10K_RSSRK_SIZE; i++, key += 4)
1068 		*(__le32 *)key = cpu_to_le32(interface->rssrk[i]);
1069 
1070 	return 0;
1071 }
1072 
1073 static int fm10k_set_rssh(struct net_device *netdev, const u32 *indir,
1074 			  const u8 *key, const u8 hfunc)
1075 {
1076 	struct fm10k_intfc *interface = netdev_priv(netdev);
1077 	struct fm10k_hw *hw = &interface->hw;
1078 	int i, err;
1079 
1080 	/* We do not allow change in unsupported parameters */
1081 	if (hfunc != ETH_RSS_HASH_NO_CHANGE && hfunc != ETH_RSS_HASH_TOP)
1082 		return -EOPNOTSUPP;
1083 
1084 	err = fm10k_set_reta(netdev, indir);
1085 	if (err || !key)
1086 		return err;
1087 
1088 	for (i = 0; i < FM10K_RSSRK_SIZE; i++, key += 4) {
1089 		u32 rssrk = le32_to_cpu(*(__le32 *)key);
1090 
1091 		if (interface->rssrk[i] == rssrk)
1092 			continue;
1093 
1094 		interface->rssrk[i] = rssrk;
1095 		fm10k_write_reg(hw, FM10K_RSSRK(0, i), rssrk);
1096 	}
1097 
1098 	return 0;
1099 }
1100 
1101 static unsigned int fm10k_max_channels(struct net_device *dev)
1102 {
1103 	struct fm10k_intfc *interface = netdev_priv(dev);
1104 	unsigned int max_combined = interface->hw.mac.max_queues;
1105 	u8 tcs = netdev_get_num_tc(dev);
1106 
1107 	/* For QoS report channels per traffic class */
1108 	if (tcs > 1)
1109 		max_combined = BIT((fls(max_combined / tcs) - 1));
1110 
1111 	return max_combined;
1112 }
1113 
1114 static void fm10k_get_channels(struct net_device *dev,
1115 			       struct ethtool_channels *ch)
1116 {
1117 	struct fm10k_intfc *interface = netdev_priv(dev);
1118 	struct fm10k_hw *hw = &interface->hw;
1119 
1120 	/* report maximum channels */
1121 	ch->max_combined = fm10k_max_channels(dev);
1122 
1123 	/* report info for other vector */
1124 	ch->max_other = NON_Q_VECTORS(hw);
1125 	ch->other_count = ch->max_other;
1126 
1127 	/* record RSS queues */
1128 	ch->combined_count = interface->ring_feature[RING_F_RSS].indices;
1129 }
1130 
1131 static int fm10k_set_channels(struct net_device *dev,
1132 			      struct ethtool_channels *ch)
1133 {
1134 	struct fm10k_intfc *interface = netdev_priv(dev);
1135 	unsigned int count = ch->combined_count;
1136 	struct fm10k_hw *hw = &interface->hw;
1137 
1138 	/* verify they are not requesting separate vectors */
1139 	if (!count || ch->rx_count || ch->tx_count)
1140 		return -EINVAL;
1141 
1142 	/* verify other_count has not changed */
1143 	if (ch->other_count != NON_Q_VECTORS(hw))
1144 		return -EINVAL;
1145 
1146 	/* verify the number of channels does not exceed hardware limits */
1147 	if (count > fm10k_max_channels(dev))
1148 		return -EINVAL;
1149 
1150 	interface->ring_feature[RING_F_RSS].limit = count;
1151 
1152 	/* use setup TC to update any traffic class queue mapping */
1153 	return fm10k_setup_tc(dev, netdev_get_num_tc(dev));
1154 }
1155 
1156 static const struct ethtool_ops fm10k_ethtool_ops = {
1157 	.get_strings		= fm10k_get_strings,
1158 	.get_sset_count		= fm10k_get_sset_count,
1159 	.get_ethtool_stats      = fm10k_get_ethtool_stats,
1160 	.get_drvinfo		= fm10k_get_drvinfo,
1161 	.get_link		= ethtool_op_get_link,
1162 	.get_pauseparam		= fm10k_get_pauseparam,
1163 	.set_pauseparam		= fm10k_set_pauseparam,
1164 	.get_msglevel		= fm10k_get_msglevel,
1165 	.set_msglevel		= fm10k_set_msglevel,
1166 	.get_ringparam		= fm10k_get_ringparam,
1167 	.set_ringparam		= fm10k_set_ringparam,
1168 	.get_coalesce		= fm10k_get_coalesce,
1169 	.set_coalesce		= fm10k_set_coalesce,
1170 	.get_rxnfc		= fm10k_get_rxnfc,
1171 	.set_rxnfc		= fm10k_set_rxnfc,
1172 	.get_regs               = fm10k_get_regs,
1173 	.get_regs_len           = fm10k_get_regs_len,
1174 	.self_test		= fm10k_self_test,
1175 	.get_priv_flags		= fm10k_get_priv_flags,
1176 	.set_priv_flags		= fm10k_set_priv_flags,
1177 	.get_rxfh_indir_size	= fm10k_get_reta_size,
1178 	.get_rxfh_key_size	= fm10k_get_rssrk_size,
1179 	.get_rxfh		= fm10k_get_rssh,
1180 	.set_rxfh		= fm10k_set_rssh,
1181 	.get_channels		= fm10k_get_channels,
1182 	.set_channels		= fm10k_set_channels,
1183 	.get_ts_info		= ethtool_op_get_ts_info,
1184 };
1185 
1186 void fm10k_set_ethtool_ops(struct net_device *dev)
1187 {
1188 	dev->ethtool_ops = &fm10k_ethtool_ops;
1189 }
1190