sfc: Generalise packet hash lookup to support EF10 RX prefix
[deliverable/linux.git] / drivers / net / ethernet / sfc / ethtool.c
CommitLineData
8ceee660
BH
1/****************************************************************************
2 * Driver for Solarflare Solarstorm network controllers and boards
3 * Copyright 2005-2006 Fen Systems Ltd.
0a6f40c6 4 * Copyright 2006-2010 Solarflare Communications Inc.
8ceee660
BH
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 as published
8 * by the Free Software Foundation, incorporated herein by reference.
9 */
10
11#include <linux/netdevice.h>
12#include <linux/ethtool.h>
13#include <linux/rtnetlink.h>
c39d35eb 14#include <linux/in.h>
8ceee660 15#include "net_driver.h"
04cc8cac 16#include "workarounds.h"
3273c2e8 17#include "selftest.h"
8ceee660 18#include "efx.h"
b4187e42 19#include "filter.h"
744093c9 20#include "nic.h"
8ceee660 21
cd0ecc9a 22struct efx_sw_stat_desc {
8ceee660
BH
23 const char *name;
24 enum {
8ceee660 25 EFX_ETHTOOL_STAT_SOURCE_nic,
119226c5
BH
26 EFX_ETHTOOL_STAT_SOURCE_channel,
27 EFX_ETHTOOL_STAT_SOURCE_tx_queue
8ceee660
BH
28 } source;
29 unsigned offset;
30 u64(*get_stat) (void *field); /* Reader function */
31};
32
cd0ecc9a 33/* Initialiser for a struct efx_sw_stat_desc with type-checking */
8ceee660
BH
34#define EFX_ETHTOOL_STAT(stat_name, source_name, field, field_type, \
35 get_stat_function) { \
36 .name = #stat_name, \
37 .source = EFX_ETHTOOL_STAT_SOURCE_##source_name, \
38 .offset = ((((field_type *) 0) == \
39 &((struct efx_##source_name *)0)->field) ? \
40 offsetof(struct efx_##source_name, field) : \
41 offsetof(struct efx_##source_name, field)), \
42 .get_stat = get_stat_function, \
43}
44
45static u64 efx_get_uint_stat(void *field)
46{
47 return *(unsigned int *)field;
48}
49
8ceee660
BH
50static u64 efx_get_atomic_stat(void *field)
51{
52 return atomic_read((atomic_t *) field);
53}
54
8ceee660
BH
55#define EFX_ETHTOOL_ATOMIC_NIC_ERROR_STAT(field) \
56 EFX_ETHTOOL_STAT(field, nic, field, \
57 atomic_t, efx_get_atomic_stat)
58
59#define EFX_ETHTOOL_UINT_CHANNEL_STAT(field) \
60 EFX_ETHTOOL_STAT(field, channel, n_##field, \
61 unsigned int, efx_get_uint_stat)
62
119226c5
BH
63#define EFX_ETHTOOL_UINT_TXQ_STAT(field) \
64 EFX_ETHTOOL_STAT(tx_##field, tx_queue, field, \
65 unsigned int, efx_get_uint_stat)
66
cd0ecc9a 67static const struct efx_sw_stat_desc efx_sw_stat_desc[] = {
119226c5
BH
68 EFX_ETHTOOL_UINT_TXQ_STAT(tso_bursts),
69 EFX_ETHTOOL_UINT_TXQ_STAT(tso_long_headers),
70 EFX_ETHTOOL_UINT_TXQ_STAT(tso_packets),
71 EFX_ETHTOOL_UINT_TXQ_STAT(pushes),
8ceee660
BH
72 EFX_ETHTOOL_ATOMIC_NIC_ERROR_STAT(rx_reset),
73 EFX_ETHTOOL_UINT_CHANNEL_STAT(rx_tobe_disc),
74 EFX_ETHTOOL_UINT_CHANNEL_STAT(rx_ip_hdr_chksum_err),
75 EFX_ETHTOOL_UINT_CHANNEL_STAT(rx_tcp_udp_chksum_err),
c1ac403b 76 EFX_ETHTOOL_UINT_CHANNEL_STAT(rx_mcast_mismatch),
8ceee660 77 EFX_ETHTOOL_UINT_CHANNEL_STAT(rx_frm_trunc),
85740cdf 78 EFX_ETHTOOL_UINT_CHANNEL_STAT(rx_nodesc_trunc),
8ceee660
BH
79};
80
cd0ecc9a 81#define EFX_ETHTOOL_SW_STAT_COUNT ARRAY_SIZE(efx_sw_stat_desc)
8ceee660 82
4a5b504d 83#define EFX_ETHTOOL_EEPROM_MAGIC 0xEFAB
4a5b504d 84
8ceee660
BH
85/**************************************************************************
86 *
87 * Ethtool operations
88 *
89 **************************************************************************
90 */
91
92/* Identify device by flashing LEDs */
c5e129ac
BH
93static int efx_ethtool_phys_id(struct net_device *net_dev,
94 enum ethtool_phys_id_state state)
8ceee660 95{
767e468c 96 struct efx_nic *efx = netdev_priv(net_dev);
fce55922 97 enum efx_led_mode mode = EFX_LED_DEFAULT;
8ceee660 98
c5e129ac
BH
99 switch (state) {
100 case ETHTOOL_ID_ON:
101 mode = EFX_LED_ON;
102 break;
103 case ETHTOOL_ID_OFF:
104 mode = EFX_LED_OFF;
105 break;
106 case ETHTOOL_ID_INACTIVE:
107 mode = EFX_LED_DEFAULT;
108 break;
fce55922
AB
109 case ETHTOOL_ID_ACTIVE:
110 return 1; /* cycle on/off once per second */
c5e129ac 111 }
398468ed 112
c5e129ac 113 efx->type->set_id_led(efx, mode);
8ceee660
BH
114 return 0;
115}
116
117/* This must be called with rtnl_lock held. */
d215697f 118static int efx_ethtool_get_settings(struct net_device *net_dev,
119 struct ethtool_cmd *ecmd)
8ceee660 120{
767e468c 121 struct efx_nic *efx = netdev_priv(net_dev);
d3245b28 122 struct efx_link_state *link_state = &efx->link_state;
8ceee660
BH
123
124 mutex_lock(&efx->mac_lock);
177dfcd8 125 efx->phy_op->get_settings(efx, ecmd);
8ceee660
BH
126 mutex_unlock(&efx->mac_lock);
127
d3245b28
BH
128 /* Both MACs support pause frames (bidirectional and respond-only) */
129 ecmd->supported |= SUPPORTED_Pause | SUPPORTED_Asym_Pause;
130
131 if (LOOPBACK_INTERNAL(efx)) {
70739497 132 ethtool_cmd_speed_set(ecmd, link_state->speed);
d3245b28
BH
133 ecmd->duplex = link_state->fd ? DUPLEX_FULL : DUPLEX_HALF;
134 }
177dfcd8
BH
135
136 return 0;
8ceee660
BH
137}
138
139/* This must be called with rtnl_lock held. */
d215697f 140static int efx_ethtool_set_settings(struct net_device *net_dev,
141 struct ethtool_cmd *ecmd)
8ceee660 142{
767e468c 143 struct efx_nic *efx = netdev_priv(net_dev);
8ceee660
BH
144 int rc;
145
754c653a 146 /* GMAC does not support 1000Mbps HD */
25db0338
DD
147 if ((ethtool_cmd_speed(ecmd) == SPEED_1000) &&
148 (ecmd->duplex != DUPLEX_FULL)) {
62776d03
BH
149 netif_dbg(efx, drv, efx->net_dev,
150 "rejecting unsupported 1000Mbps HD setting\n");
177dfcd8
BH
151 return -EINVAL;
152 }
153
8ceee660 154 mutex_lock(&efx->mac_lock);
177dfcd8 155 rc = efx->phy_op->set_settings(efx, ecmd);
8ceee660 156 mutex_unlock(&efx->mac_lock);
8ceee660
BH
157 return rc;
158}
159
160static void efx_ethtool_get_drvinfo(struct net_device *net_dev,
161 struct ethtool_drvinfo *info)
162{
767e468c 163 struct efx_nic *efx = netdev_priv(net_dev);
8ceee660 164
c5d5f5fd 165 strlcpy(info->driver, KBUILD_MODNAME, sizeof(info->driver));
8ceee660 166 strlcpy(info->version, EFX_DRIVER_VERSION, sizeof(info->version));
8880f4ec 167 if (efx_nic_rev(efx) >= EFX_REV_SIENA_A0)
e5f0fd27
BH
168 efx_mcdi_print_fwver(efx, info->fw_version,
169 sizeof(info->fw_version));
8ceee660
BH
170 strlcpy(info->bus_info, pci_name(efx->pci_dev), sizeof(info->bus_info));
171}
172
5b98c1bf
BH
173static int efx_ethtool_get_regs_len(struct net_device *net_dev)
174{
175 return efx_nic_get_regs_len(netdev_priv(net_dev));
176}
177
178static void efx_ethtool_get_regs(struct net_device *net_dev,
179 struct ethtool_regs *regs, void *buf)
180{
181 struct efx_nic *efx = netdev_priv(net_dev);
182
183 regs->version = efx->type->revision;
184 efx_nic_get_regs(efx, buf);
185}
186
62776d03
BH
187static u32 efx_ethtool_get_msglevel(struct net_device *net_dev)
188{
189 struct efx_nic *efx = netdev_priv(net_dev);
190 return efx->msg_enable;
191}
192
193static void efx_ethtool_set_msglevel(struct net_device *net_dev, u32 msg_enable)
194{
195 struct efx_nic *efx = netdev_priv(net_dev);
196 efx->msg_enable = msg_enable;
197}
198
3273c2e8
BH
199/**
200 * efx_fill_test - fill in an individual self-test entry
201 * @test_index: Index of the test
202 * @strings: Ethtool strings, or %NULL
203 * @data: Ethtool test results, or %NULL
204 * @test: Pointer to test result (used only if data != %NULL)
740ced99
BH
205 * @unit_format: Unit name format (e.g. "chan\%d")
206 * @unit_id: Unit id (e.g. 0 for "chan0")
3273c2e8 207 * @test_format: Test name format (e.g. "loopback.\%s.tx.sent")
740ced99 208 * @test_id: Test id (e.g. "PHYXS" for "loopback.PHYXS.tx_sent")
3273c2e8
BH
209 *
210 * Fill in an individual self-test entry.
211 */
b681e57c 212static void efx_fill_test(unsigned int test_index, u8 *strings, u64 *data,
3273c2e8
BH
213 int *test, const char *unit_format, int unit_id,
214 const char *test_format, const char *test_id)
215{
b681e57c 216 char unit_str[ETH_GSTRING_LEN], test_str[ETH_GSTRING_LEN];
3273c2e8
BH
217
218 /* Fill data value, if applicable */
219 if (data)
220 data[test_index] = *test;
221
222 /* Fill string, if applicable */
223 if (strings) {
11e66966 224 if (strchr(unit_format, '%'))
b681e57c 225 snprintf(unit_str, sizeof(unit_str),
11e66966
BH
226 unit_format, unit_id);
227 else
b681e57c
BH
228 strcpy(unit_str, unit_format);
229 snprintf(test_str, sizeof(test_str), test_format, test_id);
230 snprintf(strings + test_index * ETH_GSTRING_LEN,
231 ETH_GSTRING_LEN,
232 "%-6s %-24s", unit_str, test_str);
3273c2e8
BH
233 }
234}
235
740ced99 236#define EFX_CHANNEL_NAME(_channel) "chan%d", _channel->channel
3273c2e8
BH
237#define EFX_TX_QUEUE_NAME(_tx_queue) "txq%d", _tx_queue->queue
238#define EFX_RX_QUEUE_NAME(_rx_queue) "rxq%d", _rx_queue->queue
239#define EFX_LOOPBACK_NAME(_mode, _counter) \
c459302d 240 "loopback.%s." _counter, STRING_TABLE_LOOKUP(_mode, efx_loopback_mode)
3273c2e8
BH
241
242/**
243 * efx_fill_loopback_test - fill in a block of loopback self-test entries
244 * @efx: Efx NIC
245 * @lb_tests: Efx loopback self-test results structure
246 * @mode: Loopback test mode
247 * @test_index: Starting index of the test
248 * @strings: Ethtool strings, or %NULL
249 * @data: Ethtool test results, or %NULL
250 */
251static int efx_fill_loopback_test(struct efx_nic *efx,
252 struct efx_loopback_self_tests *lb_tests,
253 enum efx_loopback_mode mode,
254 unsigned int test_index,
b681e57c 255 u8 *strings, u64 *data)
3273c2e8 256{
1ac0226e
BH
257 struct efx_channel *channel =
258 efx_get_channel(efx, efx->tx_channel_offset);
3273c2e8
BH
259 struct efx_tx_queue *tx_queue;
260
f7d12cdc 261 efx_for_each_channel_tx_queue(tx_queue, channel) {
3273c2e8
BH
262 efx_fill_test(test_index++, strings, data,
263 &lb_tests->tx_sent[tx_queue->queue],
264 EFX_TX_QUEUE_NAME(tx_queue),
265 EFX_LOOPBACK_NAME(mode, "tx_sent"));
266 efx_fill_test(test_index++, strings, data,
267 &lb_tests->tx_done[tx_queue->queue],
268 EFX_TX_QUEUE_NAME(tx_queue),
269 EFX_LOOPBACK_NAME(mode, "tx_done"));
270 }
271 efx_fill_test(test_index++, strings, data,
272 &lb_tests->rx_good,
11e66966 273 "rx", 0,
3273c2e8
BH
274 EFX_LOOPBACK_NAME(mode, "rx_good"));
275 efx_fill_test(test_index++, strings, data,
276 &lb_tests->rx_bad,
11e66966 277 "rx", 0,
3273c2e8
BH
278 EFX_LOOPBACK_NAME(mode, "rx_bad"));
279
280 return test_index;
281}
282
283/**
284 * efx_ethtool_fill_self_tests - get self-test details
285 * @efx: Efx NIC
286 * @tests: Efx self-test results structure, or %NULL
287 * @strings: Ethtool strings, or %NULL
288 * @data: Ethtool test results, or %NULL
289 */
290static int efx_ethtool_fill_self_tests(struct efx_nic *efx,
291 struct efx_self_tests *tests,
b681e57c 292 u8 *strings, u64 *data)
3273c2e8
BH
293{
294 struct efx_channel *channel;
1796721a 295 unsigned int n = 0, i;
3273c2e8
BH
296 enum efx_loopback_mode mode;
297
4f16c073
BH
298 efx_fill_test(n++, strings, data, &tests->phy_alive,
299 "phy", 0, "alive", NULL);
8c8661e4
BH
300 efx_fill_test(n++, strings, data, &tests->nvram,
301 "core", 0, "nvram", NULL);
3273c2e8
BH
302 efx_fill_test(n++, strings, data, &tests->interrupt,
303 "core", 0, "interrupt", NULL);
304
305 /* Event queues */
306 efx_for_each_channel(channel, efx) {
307 efx_fill_test(n++, strings, data,
308 &tests->eventq_dma[channel->channel],
309 EFX_CHANNEL_NAME(channel),
310 "eventq.dma", NULL);
311 efx_fill_test(n++, strings, data,
312 &tests->eventq_int[channel->channel],
313 EFX_CHANNEL_NAME(channel),
314 "eventq.int", NULL);
3273c2e8
BH
315 }
316
8c8661e4
BH
317 efx_fill_test(n++, strings, data, &tests->registers,
318 "core", 0, "registers", NULL);
1796721a 319
c1c4f453
BH
320 if (efx->phy_op->run_tests != NULL) {
321 EFX_BUG_ON_PARANOID(efx->phy_op->test_name == NULL);
322
323 for (i = 0; true; ++i) {
324 const char *name;
325
326 EFX_BUG_ON_PARANOID(i >= EFX_MAX_PHY_TESTS);
327 name = efx->phy_op->test_name(efx, i);
328 if (name == NULL)
329 break;
330
4f16c073 331 efx_fill_test(n++, strings, data, &tests->phy_ext[i],
c1c4f453
BH
332 "phy", 0, name, NULL);
333 }
334 }
3273c2e8
BH
335
336 /* Loopback tests */
8c8661e4 337 for (mode = LOOPBACK_NONE; mode <= LOOPBACK_TEST_MAX; mode++) {
3273c2e8
BH
338 if (!(efx->loopback_modes & (1 << mode)))
339 continue;
340 n = efx_fill_loopback_test(efx,
341 &tests->loopback[mode], mode, n,
342 strings, data);
343 }
344
345 return n;
346}
347
3594e131
BH
348static int efx_ethtool_get_sset_count(struct net_device *net_dev,
349 int string_set)
8ceee660 350{
cd0ecc9a
BH
351 struct efx_nic *efx = netdev_priv(net_dev);
352
3594e131
BH
353 switch (string_set) {
354 case ETH_SS_STATS:
cd0ecc9a
BH
355 return efx->type->describe_stats(efx, NULL) +
356 EFX_ETHTOOL_SW_STAT_COUNT;
3594e131 357 case ETH_SS_TEST:
cd0ecc9a 358 return efx_ethtool_fill_self_tests(efx, NULL, NULL, NULL);
3594e131
BH
359 default:
360 return -EINVAL;
361 }
3273c2e8
BH
362}
363
8ceee660
BH
364static void efx_ethtool_get_strings(struct net_device *net_dev,
365 u32 string_set, u8 *strings)
366{
767e468c 367 struct efx_nic *efx = netdev_priv(net_dev);
8ceee660
BH
368 int i;
369
3273c2e8
BH
370 switch (string_set) {
371 case ETH_SS_STATS:
cd0ecc9a
BH
372 strings += (efx->type->describe_stats(efx, strings) *
373 ETH_GSTRING_LEN);
374 for (i = 0; i < EFX_ETHTOOL_SW_STAT_COUNT; i++)
b681e57c 375 strlcpy(strings + i * ETH_GSTRING_LEN,
cd0ecc9a 376 efx_sw_stat_desc[i].name, ETH_GSTRING_LEN);
3273c2e8
BH
377 break;
378 case ETH_SS_TEST:
b681e57c 379 efx_ethtool_fill_self_tests(efx, NULL, strings, NULL);
3273c2e8
BH
380 break;
381 default:
382 /* No other string sets */
383 break;
384 }
8ceee660
BH
385}
386
387static void efx_ethtool_get_stats(struct net_device *net_dev,
388 struct ethtool_stats *stats,
389 u64 *data)
390{
767e468c 391 struct efx_nic *efx = netdev_priv(net_dev);
cd0ecc9a 392 const struct efx_sw_stat_desc *stat;
8ceee660 393 struct efx_channel *channel;
119226c5 394 struct efx_tx_queue *tx_queue;
8ceee660
BH
395 int i;
396
1cb34522
BH
397 spin_lock_bh(&efx->stats_lock);
398
cd0ecc9a
BH
399 /* Get NIC statistics */
400 data += efx->type->update_stats(efx, data, NULL);
8ceee660 401
cd0ecc9a
BH
402 /* Get software statistics */
403 for (i = 0; i < EFX_ETHTOOL_SW_STAT_COUNT; i++) {
404 stat = &efx_sw_stat_desc[i];
8ceee660 405 switch (stat->source) {
8ceee660
BH
406 case EFX_ETHTOOL_STAT_SOURCE_nic:
407 data[i] = stat->get_stat((void *)efx + stat->offset);
408 break;
409 case EFX_ETHTOOL_STAT_SOURCE_channel:
410 data[i] = 0;
411 efx_for_each_channel(channel, efx)
412 data[i] += stat->get_stat((void *)channel +
413 stat->offset);
414 break;
119226c5
BH
415 case EFX_ETHTOOL_STAT_SOURCE_tx_queue:
416 data[i] = 0;
417 efx_for_each_channel(channel, efx) {
418 efx_for_each_channel_tx_queue(tx_queue, channel)
419 data[i] +=
420 stat->get_stat((void *)tx_queue
421 + stat->offset);
422 }
423 break;
8ceee660
BH
424 }
425 }
1cb34522
BH
426
427 spin_unlock_bh(&efx->stats_lock);
8ceee660
BH
428}
429
3273c2e8
BH
430static void efx_ethtool_self_test(struct net_device *net_dev,
431 struct ethtool_test *test, u64 *data)
432{
767e468c 433 struct efx_nic *efx = netdev_priv(net_dev);
28801f35 434 struct efx_self_tests *efx_tests;
2ef3068e 435 int already_up;
28801f35
ED
436 int rc = -ENOMEM;
437
438 efx_tests = kzalloc(sizeof(*efx_tests), GFP_KERNEL);
439 if (!efx_tests)
440 goto fail;
441
f16aeea0 442 if (efx->state != STATE_READY) {
3273c2e8
BH
443 rc = -EIO;
444 goto fail1;
445 }
446
ac33ac61
BH
447 netif_info(efx, drv, efx->net_dev, "starting %sline testing\n",
448 (test->flags & ETH_TEST_FL_OFFLINE) ? "off" : "on");
449
3273c2e8
BH
450 /* We need rx buffers and interrupts. */
451 already_up = (efx->net_dev->flags & IFF_UP);
452 if (!already_up) {
453 rc = dev_open(efx->net_dev);
454 if (rc) {
62776d03
BH
455 netif_err(efx, drv, efx->net_dev,
456 "failed opening device.\n");
28801f35 457 goto fail1;
3273c2e8
BH
458 }
459 }
460
28801f35 461 rc = efx_selftest(efx, efx_tests, test->flags);
3273c2e8 462
3273c2e8
BH
463 if (!already_up)
464 dev_close(efx->net_dev);
465
ac33ac61
BH
466 netif_info(efx, drv, efx->net_dev, "%s %sline self-tests\n",
467 rc == 0 ? "passed" : "failed",
468 (test->flags & ETH_TEST_FL_OFFLINE) ? "off" : "on");
3273c2e8 469
28801f35 470fail1:
3273c2e8 471 /* Fill ethtool results structures */
28801f35
ED
472 efx_ethtool_fill_self_tests(efx, efx_tests, NULL, data);
473 kfree(efx_tests);
474fail:
3273c2e8
BH
475 if (rc)
476 test->flags |= ETH_TEST_FL_FAILED;
477}
478
8ceee660
BH
479/* Restart autonegotiation */
480static int efx_ethtool_nway_reset(struct net_device *net_dev)
481{
767e468c 482 struct efx_nic *efx = netdev_priv(net_dev);
8ceee660 483
68e7f45e 484 return mdio45_nway_restart(&efx->mdio);
8ceee660
BH
485}
486
a0c4faf5
BH
487/*
488 * Each channel has a single IRQ and moderation timer, started by any
489 * completion (or other event). Unless the module parameter
490 * separate_tx_channels is set, IRQs and moderation are therefore
491 * shared between RX and TX completions. In this case, when RX IRQ
492 * moderation is explicitly changed then TX IRQ moderation is
493 * automatically changed too, but otherwise we fail if the two values
494 * are requested to be different.
495 *
13225977
BH
496 * The hardware does not support a limit on the number of completions
497 * before an IRQ, so we do not use the max_frames fields. We should
498 * report and require that max_frames == (usecs != 0), but this would
499 * invalidate existing user documentation.
500 *
501 * The hardware does not have distinct settings for interrupt
502 * moderation while the previous IRQ is being handled, so we should
503 * not use the 'irq' fields. However, an earlier developer
504 * misunderstood the meaning of the 'irq' fields and the driver did
505 * not support the standard fields. To avoid invalidating existing
506 * user documentation, we report and accept changes through either the
507 * standard or 'irq' fields. If both are changed at the same time, we
508 * prefer the standard field.
509 *
a0c4faf5
BH
510 * We implement adaptive IRQ moderation, but use a different algorithm
511 * from that assumed in the definition of struct ethtool_coalesce.
512 * Therefore we do not use any of the adaptive moderation parameters
513 * in it.
514 */
515
8ceee660
BH
516static int efx_ethtool_get_coalesce(struct net_device *net_dev,
517 struct ethtool_coalesce *coalesce)
518{
767e468c 519 struct efx_nic *efx = netdev_priv(net_dev);
a0c4faf5
BH
520 unsigned int tx_usecs, rx_usecs;
521 bool rx_adaptive;
8ceee660 522
a0c4faf5 523 efx_get_irq_moderation(efx, &tx_usecs, &rx_usecs, &rx_adaptive);
8ceee660 524
13225977 525 coalesce->tx_coalesce_usecs = tx_usecs;
a0c4faf5 526 coalesce->tx_coalesce_usecs_irq = tx_usecs;
13225977 527 coalesce->rx_coalesce_usecs = rx_usecs;
a0c4faf5
BH
528 coalesce->rx_coalesce_usecs_irq = rx_usecs;
529 coalesce->use_adaptive_rx_coalesce = rx_adaptive;
0d86ebd8 530
8ceee660
BH
531 return 0;
532}
533
8ceee660
BH
534static int efx_ethtool_set_coalesce(struct net_device *net_dev,
535 struct ethtool_coalesce *coalesce)
536{
767e468c 537 struct efx_nic *efx = netdev_priv(net_dev);
8ceee660 538 struct efx_channel *channel;
b548f976 539 unsigned int tx_usecs, rx_usecs;
9e393b30
BH
540 bool adaptive, rx_may_override_tx;
541 int rc;
8ceee660 542
6fb70fd1 543 if (coalesce->use_adaptive_tx_coalesce)
9f85ee9c 544 return -EINVAL;
8ceee660 545
a0c4faf5
BH
546 efx_get_irq_moderation(efx, &tx_usecs, &rx_usecs, &adaptive);
547
13225977
BH
548 if (coalesce->rx_coalesce_usecs != rx_usecs)
549 rx_usecs = coalesce->rx_coalesce_usecs;
550 else
551 rx_usecs = coalesce->rx_coalesce_usecs_irq;
552
6fb70fd1 553 adaptive = coalesce->use_adaptive_rx_coalesce;
8ceee660 554
a0c4faf5
BH
555 /* If channels are shared, TX IRQ moderation can be quietly
556 * overridden unless it is changed from its old value.
557 */
13225977
BH
558 rx_may_override_tx = (coalesce->tx_coalesce_usecs == tx_usecs &&
559 coalesce->tx_coalesce_usecs_irq == tx_usecs);
560 if (coalesce->tx_coalesce_usecs != tx_usecs)
561 tx_usecs = coalesce->tx_coalesce_usecs;
562 else
563 tx_usecs = coalesce->tx_coalesce_usecs_irq;
8ceee660 564
9e393b30
BH
565 rc = efx_init_irq_moderation(efx, tx_usecs, rx_usecs, adaptive,
566 rx_may_override_tx);
567 if (rc != 0)
568 return rc;
569
8ceee660 570 efx_for_each_channel(channel, efx)
ef2b90ee 571 efx->type->push_irq_moderation(channel);
8ceee660
BH
572
573 return 0;
574}
575
4642610c
BH
576static void efx_ethtool_get_ringparam(struct net_device *net_dev,
577 struct ethtool_ringparam *ring)
578{
579 struct efx_nic *efx = netdev_priv(net_dev);
580
581 ring->rx_max_pending = EFX_MAX_DMAQ_SIZE;
582 ring->tx_max_pending = EFX_MAX_DMAQ_SIZE;
4642610c
BH
583 ring->rx_pending = efx->rxq_entries;
584 ring->tx_pending = efx->txq_entries;
4642610c
BH
585}
586
587static int efx_ethtool_set_ringparam(struct net_device *net_dev,
588 struct ethtool_ringparam *ring)
589{
590 struct efx_nic *efx = netdev_priv(net_dev);
7e6d06f0 591 u32 txq_entries;
4642610c
BH
592
593 if (ring->rx_mini_pending || ring->rx_jumbo_pending ||
594 ring->rx_pending > EFX_MAX_DMAQ_SIZE ||
595 ring->tx_pending > EFX_MAX_DMAQ_SIZE)
596 return -EINVAL;
597
7e6d06f0 598 if (ring->rx_pending < EFX_RXQ_MIN_ENT) {
4642610c 599 netif_err(efx, drv, efx->net_dev,
7e6d06f0
BH
600 "RX queues cannot be smaller than %u\n",
601 EFX_RXQ_MIN_ENT);
4642610c
BH
602 return -EINVAL;
603 }
604
7e6d06f0
BH
605 txq_entries = max(ring->tx_pending, EFX_TXQ_MIN_ENT(efx));
606 if (txq_entries != ring->tx_pending)
607 netif_warn(efx, drv, efx->net_dev,
608 "increasing TX queue size to minimum of %u\n",
609 txq_entries);
610
611 return efx_realloc_channels(efx, ring->rx_pending, txq_entries);
4642610c
BH
612}
613
8ceee660
BH
614static int efx_ethtool_set_pauseparam(struct net_device *net_dev,
615 struct ethtool_pauseparam *pause)
616{
767e468c 617 struct efx_nic *efx = netdev_priv(net_dev);
b5626946 618 u8 wanted_fc, old_fc;
d3245b28 619 u32 old_adv;
d3245b28
BH
620 int rc = 0;
621
622 mutex_lock(&efx->mac_lock);
8ceee660 623
04cc8cac
BH
624 wanted_fc = ((pause->rx_pause ? EFX_FC_RX : 0) |
625 (pause->tx_pause ? EFX_FC_TX : 0) |
626 (pause->autoneg ? EFX_FC_AUTO : 0));
627
628 if ((wanted_fc & EFX_FC_TX) && !(wanted_fc & EFX_FC_RX)) {
62776d03
BH
629 netif_dbg(efx, drv, efx->net_dev,
630 "Flow control unsupported: tx ON rx OFF\n");
d3245b28
BH
631 rc = -EINVAL;
632 goto out;
04cc8cac
BH
633 }
634
d3245b28 635 if ((wanted_fc & EFX_FC_AUTO) && !efx->link_advertising) {
62776d03
BH
636 netif_dbg(efx, drv, efx->net_dev,
637 "Autonegotiation is disabled\n");
d3245b28
BH
638 rc = -EINVAL;
639 goto out;
04cc8cac
BH
640 }
641
9dd3a13b
BH
642 /* Hook for Falcon bug 11482 workaround */
643 if (efx->type->prepare_enable_fc_tx &&
644 (wanted_fc & EFX_FC_TX) && !(efx->wanted_fc & EFX_FC_TX))
645 efx->type->prepare_enable_fc_tx(efx);
04cc8cac 646
d3245b28
BH
647 old_adv = efx->link_advertising;
648 old_fc = efx->wanted_fc;
649 efx_link_set_wanted_fc(efx, wanted_fc);
650 if (efx->link_advertising != old_adv ||
651 (efx->wanted_fc ^ old_fc) & EFX_FC_AUTO) {
652 rc = efx->phy_op->reconfigure(efx);
653 if (rc) {
62776d03
BH
654 netif_err(efx, drv, efx->net_dev,
655 "Unable to advertise requested flow "
656 "control setting\n");
d3245b28
BH
657 goto out;
658 }
659 }
04cc8cac 660
d3245b28
BH
661 /* Reconfigure the MAC. The PHY *may* generate a link state change event
662 * if the user just changed the advertised capabilities, but there's no
663 * harm doing this twice */
710b208d 664 efx->type->reconfigure_mac(efx);
04cc8cac 665
d3245b28 666out:
04cc8cac 667 mutex_unlock(&efx->mac_lock);
8ceee660 668
d3245b28 669 return rc;
8ceee660
BH
670}
671
672static void efx_ethtool_get_pauseparam(struct net_device *net_dev,
673 struct ethtool_pauseparam *pause)
674{
767e468c 675 struct efx_nic *efx = netdev_priv(net_dev);
8ceee660 676
04cc8cac
BH
677 pause->rx_pause = !!(efx->wanted_fc & EFX_FC_RX);
678 pause->tx_pause = !!(efx->wanted_fc & EFX_FC_TX);
679 pause->autoneg = !!(efx->wanted_fc & EFX_FC_AUTO);
8ceee660
BH
680}
681
682
89c758fa
BH
683static void efx_ethtool_get_wol(struct net_device *net_dev,
684 struct ethtool_wolinfo *wol)
685{
686 struct efx_nic *efx = netdev_priv(net_dev);
687 return efx->type->get_wol(efx, wol);
688}
689
690
691static int efx_ethtool_set_wol(struct net_device *net_dev,
692 struct ethtool_wolinfo *wol)
693{
694 struct efx_nic *efx = netdev_priv(net_dev);
695 return efx->type->set_wol(efx, wol->wolopts);
696}
697
d215697f 698static int efx_ethtool_reset(struct net_device *net_dev, u32 *flags)
eb9f6744
BH
699{
700 struct efx_nic *efx = netdev_priv(net_dev);
0e2a9c7c 701 int rc;
eb9f6744 702
0e2a9c7c
BH
703 rc = efx->type->map_reset_flags(flags);
704 if (rc < 0)
705 return rc;
eb9f6744 706
0e2a9c7c 707 return efx_reset(efx, rc);
eb9f6744
BH
708}
709
7c460d9b
BH
710/* MAC address mask including only I/G bit */
711static const u8 mac_addr_ig_mask[ETH_ALEN] = { 0x01, 0, 0, 0, 0, 0 };
c274d65c 712
0e0c3408
BH
713#define IP4_ADDR_FULL_MASK ((__force __be32)~0)
714#define PORT_FULL_MASK ((__force __be16)~0)
7c460d9b 715#define ETHER_TYPE_FULL_MASK ((__force __be16)~0)
0e0c3408 716
b2bb7b77
BH
717static int efx_ethtool_get_class_rule(struct efx_nic *efx,
718 struct ethtool_rx_flow_spec *rule)
719{
720 struct ethtool_tcpip4_spec *ip_entry = &rule->h_u.tcp_ip4_spec;
721 struct ethtool_tcpip4_spec *ip_mask = &rule->m_u.tcp_ip4_spec;
c274d65c
BH
722 struct ethhdr *mac_entry = &rule->h_u.ether_spec;
723 struct ethhdr *mac_mask = &rule->m_u.ether_spec;
b2bb7b77 724 struct efx_filter_spec spec;
b2bb7b77
BH
725 int rc;
726
727 rc = efx_filter_get_filter_safe(efx, EFX_FILTER_PRI_MANUAL,
728 rule->location, &spec);
729 if (rc)
730 return rc;
731
f26e958c 732 if (spec.dmaq_id == EFX_FILTER_RX_DMAQ_ID_DROP)
b2bb7b77
BH
733 rule->ring_cookie = RX_CLS_FLOW_DISC;
734 else
735 rule->ring_cookie = spec.dmaq_id;
736
7c460d9b
BH
737 if ((spec.match_flags & EFX_FILTER_MATCH_ETHER_TYPE) &&
738 spec.ether_type == htons(ETH_P_IP) &&
739 (spec.match_flags & EFX_FILTER_MATCH_IP_PROTO) &&
740 (spec.ip_proto == IPPROTO_TCP || spec.ip_proto == IPPROTO_UDP) &&
741 !(spec.match_flags &
742 ~(EFX_FILTER_MATCH_ETHER_TYPE | EFX_FILTER_MATCH_OUTER_VID |
743 EFX_FILTER_MATCH_LOC_HOST | EFX_FILTER_MATCH_REM_HOST |
744 EFX_FILTER_MATCH_IP_PROTO |
745 EFX_FILTER_MATCH_LOC_PORT | EFX_FILTER_MATCH_REM_PORT))) {
746 rule->flow_type = ((spec.ip_proto == IPPROTO_TCP) ?
747 TCP_V4_FLOW : UDP_V4_FLOW);
748 if (spec.match_flags & EFX_FILTER_MATCH_LOC_HOST) {
749 ip_entry->ip4dst = spec.loc_host[0];
750 ip_mask->ip4dst = IP4_ADDR_FULL_MASK;
751 }
752 if (spec.match_flags & EFX_FILTER_MATCH_REM_HOST) {
753 ip_entry->ip4src = spec.rem_host[0];
754 ip_mask->ip4src = IP4_ADDR_FULL_MASK;
755 }
756 if (spec.match_flags & EFX_FILTER_MATCH_LOC_PORT) {
757 ip_entry->pdst = spec.loc_port;
758 ip_mask->pdst = PORT_FULL_MASK;
759 }
760 if (spec.match_flags & EFX_FILTER_MATCH_REM_PORT) {
761 ip_entry->psrc = spec.rem_port;
762 ip_mask->psrc = PORT_FULL_MASK;
763 }
764 } else if (!(spec.match_flags &
765 ~(EFX_FILTER_MATCH_LOC_MAC | EFX_FILTER_MATCH_LOC_MAC_IG |
766 EFX_FILTER_MATCH_REM_MAC | EFX_FILTER_MATCH_ETHER_TYPE |
767 EFX_FILTER_MATCH_OUTER_VID))) {
b2bb7b77 768 rule->flow_type = ETHER_FLOW;
7c460d9b
BH
769 if (spec.match_flags &
770 (EFX_FILTER_MATCH_LOC_MAC | EFX_FILTER_MATCH_LOC_MAC_IG)) {
771 memcpy(mac_entry->h_dest, spec.loc_mac, ETH_ALEN);
772 if (spec.match_flags & EFX_FILTER_MATCH_LOC_MAC)
773 memset(mac_mask->h_dest, ~0, ETH_ALEN);
774 else
775 memcpy(mac_mask->h_dest, mac_addr_ig_mask,
776 ETH_ALEN);
b2bb7b77 777 }
7c460d9b
BH
778 if (spec.match_flags & EFX_FILTER_MATCH_REM_MAC) {
779 memcpy(mac_entry->h_source, spec.rem_mac, ETH_ALEN);
780 memset(mac_mask->h_source, ~0, ETH_ALEN);
781 }
782 if (spec.match_flags & EFX_FILTER_MATCH_ETHER_TYPE) {
783 mac_entry->h_proto = spec.ether_type;
784 mac_mask->h_proto = ETHER_TYPE_FULL_MASK;
785 }
786 } else {
787 /* The above should handle all filters that we insert */
788 WARN_ON(1);
789 return -EINVAL;
b2bb7b77
BH
790 }
791
7c460d9b
BH
792 if (spec.match_flags & EFX_FILTER_MATCH_OUTER_VID) {
793 rule->flow_type |= FLOW_EXT;
794 rule->h_ext.vlan_tci = spec.outer_vid;
795 rule->m_ext.vlan_tci = htons(0xfff);
b2bb7b77 796 }
7c460d9b 797
b2bb7b77
BH
798 return rc;
799}
800
765c9f46
BH
801static int
802efx_ethtool_get_rxnfc(struct net_device *net_dev,
b2bb7b77 803 struct ethtool_rxnfc *info, u32 *rule_locs)
765c9f46
BH
804{
805 struct efx_nic *efx = netdev_priv(net_dev);
806
807 switch (info->cmd) {
808 case ETHTOOL_GRXRINGS:
809 info->data = efx->n_rx_channels;
810 return 0;
811
812 case ETHTOOL_GRXFH: {
813 unsigned min_revision = 0;
814
815 info->data = 0;
816 switch (info->flow_type) {
817 case TCP_V4_FLOW:
818 info->data |= RXH_L4_B_0_1 | RXH_L4_B_2_3;
819 /* fall through */
820 case UDP_V4_FLOW:
821 case SCTP_V4_FLOW:
822 case AH_ESP_V4_FLOW:
823 case IPV4_FLOW:
824 info->data |= RXH_IP_SRC | RXH_IP_DST;
825 min_revision = EFX_REV_FALCON_B0;
826 break;
827 case TCP_V6_FLOW:
828 info->data |= RXH_L4_B_0_1 | RXH_L4_B_2_3;
829 /* fall through */
830 case UDP_V6_FLOW:
831 case SCTP_V6_FLOW:
832 case AH_ESP_V6_FLOW:
833 case IPV6_FLOW:
834 info->data |= RXH_IP_SRC | RXH_IP_DST;
835 min_revision = EFX_REV_SIENA_A0;
836 break;
837 default:
838 break;
839 }
840 if (efx_nic_rev(efx) < min_revision)
841 info->data = 0;
842 return 0;
843 }
844
b2bb7b77
BH
845 case ETHTOOL_GRXCLSRLCNT:
846 info->data = efx_filter_get_rx_id_limit(efx);
847 if (info->data == 0)
848 return -EOPNOTSUPP;
849 info->data |= RX_CLS_LOC_SPECIAL;
850 info->rule_cnt =
851 efx_filter_count_rx_used(efx, EFX_FILTER_PRI_MANUAL);
852 return 0;
853
854 case ETHTOOL_GRXCLSRULE:
855 if (efx_filter_get_rx_id_limit(efx) == 0)
856 return -EOPNOTSUPP;
857 return efx_ethtool_get_class_rule(efx, &info->fs);
858
859 case ETHTOOL_GRXCLSRLALL: {
860 s32 rc;
861 info->data = efx_filter_get_rx_id_limit(efx);
862 if (info->data == 0)
863 return -EOPNOTSUPP;
864 rc = efx_filter_get_rx_ids(efx, EFX_FILTER_PRI_MANUAL,
865 rule_locs, info->rule_cnt);
866 if (rc < 0)
867 return rc;
868 info->rule_cnt = rc;
869 return 0;
870 }
871
765c9f46
BH
872 default:
873 return -EOPNOTSUPP;
874 }
875}
876
b2bb7b77
BH
877static int efx_ethtool_set_class_rule(struct efx_nic *efx,
878 struct ethtool_rx_flow_spec *rule)
b4187e42 879{
b2bb7b77
BH
880 struct ethtool_tcpip4_spec *ip_entry = &rule->h_u.tcp_ip4_spec;
881 struct ethtool_tcpip4_spec *ip_mask = &rule->m_u.tcp_ip4_spec;
882 struct ethhdr *mac_entry = &rule->h_u.ether_spec;
883 struct ethhdr *mac_mask = &rule->m_u.ether_spec;
884 struct efx_filter_spec spec;
c39d35eb 885 int rc;
b4187e42 886
b2bb7b77 887 /* Check that user wants us to choose the location */
9e0f9a10 888 if (rule->location != RX_CLS_LOC_ANY)
b4187e42
BH
889 return -EINVAL;
890
b2bb7b77
BH
891 /* Range-check ring_cookie */
892 if (rule->ring_cookie >= efx->n_rx_channels &&
893 rule->ring_cookie != RX_CLS_FLOW_DISC)
b4187e42
BH
894 return -EINVAL;
895
b2bb7b77
BH
896 /* Check for unsupported extensions */
897 if ((rule->flow_type & FLOW_EXT) &&
0e0c3408 898 (rule->m_ext.vlan_etype || rule->m_ext.data[0] ||
b2bb7b77
BH
899 rule->m_ext.data[1]))
900 return -EINVAL;
901
85740cdf
BH
902 efx_filter_init_rx(&spec, EFX_FILTER_PRI_MANUAL,
903 efx->rx_scatter ? EFX_FILTER_FLAG_RX_SCATTER : 0,
b2bb7b77 904 (rule->ring_cookie == RX_CLS_FLOW_DISC) ?
f26e958c 905 EFX_FILTER_RX_DMAQ_ID_DROP : rule->ring_cookie);
c39d35eb 906
7c460d9b 907 switch (rule->flow_type & ~FLOW_EXT) {
b4187e42 908 case TCP_V4_FLOW:
7c460d9b
BH
909 case UDP_V4_FLOW:
910 spec.match_flags = (EFX_FILTER_MATCH_ETHER_TYPE |
911 EFX_FILTER_MATCH_IP_PROTO);
912 spec.ether_type = htons(ETH_P_IP);
913 spec.ip_proto = ((rule->flow_type & ~FLOW_EXT) == TCP_V4_FLOW ?
914 IPPROTO_TCP : IPPROTO_UDP);
915 if (ip_mask->ip4dst) {
916 if (ip_mask->ip4dst != IP4_ADDR_FULL_MASK)
917 return -EINVAL;
918 spec.match_flags |= EFX_FILTER_MATCH_LOC_HOST;
919 spec.loc_host[0] = ip_entry->ip4dst;
920 }
921 if (ip_mask->ip4src) {
922 if (ip_mask->ip4src != IP4_ADDR_FULL_MASK)
923 return -EINVAL;
924 spec.match_flags |= EFX_FILTER_MATCH_REM_HOST;
925 spec.rem_host[0] = ip_entry->ip4src;
926 }
927 if (ip_mask->pdst) {
928 if (ip_mask->pdst != PORT_FULL_MASK)
929 return -EINVAL;
930 spec.match_flags |= EFX_FILTER_MATCH_LOC_PORT;
931 spec.loc_port = ip_entry->pdst;
932 }
933 if (ip_mask->psrc) {
934 if (ip_mask->psrc != PORT_FULL_MASK)
935 return -EINVAL;
936 spec.match_flags |= EFX_FILTER_MATCH_REM_PORT;
937 spec.rem_port = ip_entry->psrc;
938 }
939 if (ip_mask->tos)
b4187e42
BH
940 return -EINVAL;
941 break;
c274d65c 942
7c460d9b
BH
943 case ETHER_FLOW:
944 if (!is_zero_ether_addr(mac_mask->h_dest)) {
945 if (ether_addr_equal(mac_mask->h_dest,
946 mac_addr_ig_mask))
947 spec.match_flags |= EFX_FILTER_MATCH_LOC_MAC_IG;
948 else if (is_broadcast_ether_addr(mac_mask->h_dest))
949 spec.match_flags |= EFX_FILTER_MATCH_LOC_MAC;
c274d65c 950 else
7c460d9b
BH
951 return -EINVAL;
952 memcpy(spec.loc_mac, mac_entry->h_dest, ETH_ALEN);
c274d65c 953 }
7c460d9b
BH
954 if (!is_zero_ether_addr(mac_mask->h_source)) {
955 if (!is_broadcast_ether_addr(mac_mask->h_source))
956 return -EINVAL;
957 spec.match_flags |= EFX_FILTER_MATCH_REM_MAC;
958 memcpy(spec.rem_mac, mac_entry->h_source, ETH_ALEN);
959 }
960 if (mac_mask->h_proto) {
961 if (mac_mask->h_proto != ETHER_TYPE_FULL_MASK)
962 return -EINVAL;
963 spec.match_flags |= EFX_FILTER_MATCH_ETHER_TYPE;
964 spec.ether_type = mac_entry->h_proto;
c274d65c 965 }
b4187e42 966 break;
c39d35eb 967
b4187e42
BH
968 default:
969 return -EINVAL;
970 }
971
7c460d9b
BH
972 if ((rule->flow_type & FLOW_EXT) && rule->m_ext.vlan_tci) {
973 if (rule->m_ext.vlan_tci != htons(0xfff))
974 return -EINVAL;
975 spec.match_flags |= EFX_FILTER_MATCH_OUTER_VID;
976 spec.outer_vid = rule->h_ext.vlan_tci;
977 }
978
b2bb7b77
BH
979 rc = efx_filter_insert_filter(efx, &spec, true);
980 if (rc < 0)
981 return rc;
47a8467c 982
b2bb7b77
BH
983 rule->location = rc;
984 return 0;
985}
986
987static int efx_ethtool_set_rxnfc(struct net_device *net_dev,
988 struct ethtool_rxnfc *info)
989{
990 struct efx_nic *efx = netdev_priv(net_dev);
991
992 if (efx_filter_get_rx_id_limit(efx) == 0)
993 return -EOPNOTSUPP;
994
995 switch (info->cmd) {
996 case ETHTOOL_SRXCLSRLINS:
997 return efx_ethtool_set_class_rule(efx, &info->fs);
998
999 case ETHTOOL_SRXCLSRLDEL:
1000 return efx_filter_remove_id_safe(efx, EFX_FILTER_PRI_MANUAL,
1001 info->fs.location);
1002
1003 default:
1004 return -EOPNOTSUPP;
1005 }
b4187e42
BH
1006}
1007
7850f63f 1008static u32 efx_ethtool_get_rxfh_indir_size(struct net_device *net_dev)
765c9f46
BH
1009{
1010 struct efx_nic *efx = netdev_priv(net_dev);
765c9f46 1011
cd2d5b52
BH
1012 return ((efx_nic_rev(efx) < EFX_REV_FALCON_B0 ||
1013 efx->n_rx_channels == 1) ?
7850f63f
BH
1014 0 : ARRAY_SIZE(efx->rx_indir_table));
1015}
1016
1017static int efx_ethtool_get_rxfh_indir(struct net_device *net_dev, u32 *indir)
1018{
1019 struct efx_nic *efx = netdev_priv(net_dev);
765c9f46 1020
7850f63f 1021 memcpy(indir, efx->rx_indir_table, sizeof(efx->rx_indir_table));
765c9f46
BH
1022 return 0;
1023}
1024
1025static int efx_ethtool_set_rxfh_indir(struct net_device *net_dev,
7850f63f 1026 const u32 *indir)
765c9f46
BH
1027{
1028 struct efx_nic *efx = netdev_priv(net_dev);
765c9f46 1029
7850f63f 1030 memcpy(efx->rx_indir_table, indir, sizeof(efx->rx_indir_table));
765c9f46
BH
1031 efx_nic_push_rx_indir_table(efx);
1032 return 0;
1033}
1034
62ebac92
BH
1035int efx_ethtool_get_ts_info(struct net_device *net_dev,
1036 struct ethtool_ts_info *ts_info)
1037{
1038 struct efx_nic *efx = netdev_priv(net_dev);
1039
1040 /* Software capabilities */
1041 ts_info->so_timestamping = (SOF_TIMESTAMPING_RX_SOFTWARE |
1042 SOF_TIMESTAMPING_SOFTWARE);
1043 ts_info->phc_index = -1;
1044
1045 efx_ptp_get_ts_info(efx, ts_info);
1046 return 0;
1047}
1048
c087bd2c
SH
1049static int efx_ethtool_get_module_eeprom(struct net_device *net_dev,
1050 struct ethtool_eeprom *ee,
1051 u8 *data)
1052{
1053 struct efx_nic *efx = netdev_priv(net_dev);
1054 int ret;
1055
1056 if (!efx->phy_op || !efx->phy_op->get_module_eeprom)
1057 return -EOPNOTSUPP;
1058
1059 mutex_lock(&efx->mac_lock);
1060 ret = efx->phy_op->get_module_eeprom(efx, ee, data);
1061 mutex_unlock(&efx->mac_lock);
1062
1063 return ret;
1064}
1065
1066static int efx_ethtool_get_module_info(struct net_device *net_dev,
1067 struct ethtool_modinfo *modinfo)
1068{
1069 struct efx_nic *efx = netdev_priv(net_dev);
1070 int ret;
1071
1072 if (!efx->phy_op || !efx->phy_op->get_module_info)
1073 return -EOPNOTSUPP;
1074
1075 mutex_lock(&efx->mac_lock);
1076 ret = efx->phy_op->get_module_info(efx, modinfo);
1077 mutex_unlock(&efx->mac_lock);
1078
1079 return ret;
1080}
1081
0fc0b732 1082const struct ethtool_ops efx_ethtool_ops = {
8ceee660
BH
1083 .get_settings = efx_ethtool_get_settings,
1084 .set_settings = efx_ethtool_set_settings,
1085 .get_drvinfo = efx_ethtool_get_drvinfo,
5b98c1bf
BH
1086 .get_regs_len = efx_ethtool_get_regs_len,
1087 .get_regs = efx_ethtool_get_regs,
62776d03
BH
1088 .get_msglevel = efx_ethtool_get_msglevel,
1089 .set_msglevel = efx_ethtool_set_msglevel,
8ceee660 1090 .nway_reset = efx_ethtool_nway_reset,
ed4ba4b5 1091 .get_link = ethtool_op_get_link,
8ceee660
BH
1092 .get_coalesce = efx_ethtool_get_coalesce,
1093 .set_coalesce = efx_ethtool_set_coalesce,
4642610c
BH
1094 .get_ringparam = efx_ethtool_get_ringparam,
1095 .set_ringparam = efx_ethtool_set_ringparam,
8ceee660
BH
1096 .get_pauseparam = efx_ethtool_get_pauseparam,
1097 .set_pauseparam = efx_ethtool_set_pauseparam,
3594e131 1098 .get_sset_count = efx_ethtool_get_sset_count,
3273c2e8 1099 .self_test = efx_ethtool_self_test,
8ceee660 1100 .get_strings = efx_ethtool_get_strings,
c5e129ac 1101 .set_phys_id = efx_ethtool_phys_id,
8ceee660 1102 .get_ethtool_stats = efx_ethtool_get_stats,
89c758fa
BH
1103 .get_wol = efx_ethtool_get_wol,
1104 .set_wol = efx_ethtool_set_wol,
eb9f6744 1105 .reset = efx_ethtool_reset,
765c9f46 1106 .get_rxnfc = efx_ethtool_get_rxnfc,
b2bb7b77 1107 .set_rxnfc = efx_ethtool_set_rxnfc,
7850f63f 1108 .get_rxfh_indir_size = efx_ethtool_get_rxfh_indir_size,
765c9f46
BH
1109 .get_rxfh_indir = efx_ethtool_get_rxfh_indir,
1110 .set_rxfh_indir = efx_ethtool_set_rxfh_indir,
62ebac92 1111 .get_ts_info = efx_ethtool_get_ts_info,
c087bd2c
SH
1112 .get_module_info = efx_ethtool_get_module_info,
1113 .get_module_eeprom = efx_ethtool_get_module_eeprom,
8ceee660 1114};
This page took 0.653258 seconds and 5 git commands to generate.