1 // SPDX-License-Identifier: GPL-2.0-only
2 /****************************************************************************
3 * Driver for Solarflare network controllers and boards
4 * Copyright 2005-2006 Fen Systems Ltd.
5 * Copyright 2006-2013 Solarflare Communications Inc.
8 #include <linux/netdevice.h>
9 #include <linux/ethtool.h>
10 #include <linux/rtnetlink.h>
12 #include "net_driver.h"
13 #include "workarounds.h"
19 struct ef4_sw_stat_desc {
22 EF4_ETHTOOL_STAT_SOURCE_nic,
23 EF4_ETHTOOL_STAT_SOURCE_channel,
24 EF4_ETHTOOL_STAT_SOURCE_tx_queue
27 u64(*get_stat) (void *field); /* Reader function */
30 /* Initialiser for a struct ef4_sw_stat_desc with type-checking */
31 #define EF4_ETHTOOL_STAT(stat_name, source_name, field, field_type, \
32 get_stat_function) { \
34 .source = EF4_ETHTOOL_STAT_SOURCE_##source_name, \
35 .offset = ((((field_type *) 0) == \
36 &((struct ef4_##source_name *)0)->field) ? \
37 offsetof(struct ef4_##source_name, field) : \
38 offsetof(struct ef4_##source_name, field)), \
39 .get_stat = get_stat_function, \
42 static u64 ef4_get_uint_stat(void *field)
44 return *(unsigned int *)field;
47 static u64 ef4_get_atomic_stat(void *field)
49 return atomic_read((atomic_t *) field);
52 #define EF4_ETHTOOL_ATOMIC_NIC_ERROR_STAT(field) \
53 EF4_ETHTOOL_STAT(field, nic, field, \
54 atomic_t, ef4_get_atomic_stat)
56 #define EF4_ETHTOOL_UINT_CHANNEL_STAT(field) \
57 EF4_ETHTOOL_STAT(field, channel, n_##field, \
58 unsigned int, ef4_get_uint_stat)
60 #define EF4_ETHTOOL_UINT_TXQ_STAT(field) \
61 EF4_ETHTOOL_STAT(tx_##field, tx_queue, field, \
62 unsigned int, ef4_get_uint_stat)
64 static const struct ef4_sw_stat_desc ef4_sw_stat_desc[] = {
65 EF4_ETHTOOL_UINT_TXQ_STAT(merge_events),
66 EF4_ETHTOOL_UINT_TXQ_STAT(pushes),
67 EF4_ETHTOOL_UINT_TXQ_STAT(cb_packets),
68 EF4_ETHTOOL_ATOMIC_NIC_ERROR_STAT(rx_reset),
69 EF4_ETHTOOL_UINT_CHANNEL_STAT(rx_tobe_disc),
70 EF4_ETHTOOL_UINT_CHANNEL_STAT(rx_ip_hdr_chksum_err),
71 EF4_ETHTOOL_UINT_CHANNEL_STAT(rx_tcp_udp_chksum_err),
72 EF4_ETHTOOL_UINT_CHANNEL_STAT(rx_mcast_mismatch),
73 EF4_ETHTOOL_UINT_CHANNEL_STAT(rx_frm_trunc),
74 EF4_ETHTOOL_UINT_CHANNEL_STAT(rx_merge_events),
75 EF4_ETHTOOL_UINT_CHANNEL_STAT(rx_merge_packets),
78 #define EF4_ETHTOOL_SW_STAT_COUNT ARRAY_SIZE(ef4_sw_stat_desc)
80 #define EF4_ETHTOOL_EEPROM_MAGIC 0xEFAB
82 /**************************************************************************
86 **************************************************************************
89 /* Identify device by flashing LEDs */
90 static int ef4_ethtool_phys_id(struct net_device *net_dev,
91 enum ethtool_phys_id_state state)
93 struct ef4_nic *efx = netdev_priv(net_dev);
94 enum ef4_led_mode mode = EF4_LED_DEFAULT;
103 case ETHTOOL_ID_INACTIVE:
104 mode = EF4_LED_DEFAULT;
106 case ETHTOOL_ID_ACTIVE:
107 return 1; /* cycle on/off once per second */
110 efx->type->set_id_led(efx, mode);
114 /* This must be called with rtnl_lock held. */
116 ef4_ethtool_get_link_ksettings(struct net_device *net_dev,
117 struct ethtool_link_ksettings *cmd)
119 struct ef4_nic *efx = netdev_priv(net_dev);
120 struct ef4_link_state *link_state = &efx->link_state;
122 mutex_lock(&efx->mac_lock);
123 efx->phy_op->get_link_ksettings(efx, cmd);
124 mutex_unlock(&efx->mac_lock);
126 /* Both MACs support pause frames (bidirectional and respond-only) */
127 ethtool_link_ksettings_add_link_mode(cmd, supported, Pause);
128 ethtool_link_ksettings_add_link_mode(cmd, supported, Asym_Pause);
130 if (LOOPBACK_INTERNAL(efx)) {
131 cmd->base.speed = link_state->speed;
132 cmd->base.duplex = link_state->fd ? DUPLEX_FULL : DUPLEX_HALF;
138 /* This must be called with rtnl_lock held. */
140 ef4_ethtool_set_link_ksettings(struct net_device *net_dev,
141 const struct ethtool_link_ksettings *cmd)
143 struct ef4_nic *efx = netdev_priv(net_dev);
146 /* GMAC does not support 1000Mbps HD */
147 if ((cmd->base.speed == SPEED_1000) &&
148 (cmd->base.duplex != DUPLEX_FULL)) {
149 netif_dbg(efx, drv, efx->net_dev,
150 "rejecting unsupported 1000Mbps HD setting\n");
154 mutex_lock(&efx->mac_lock);
155 rc = efx->phy_op->set_link_ksettings(efx, cmd);
156 mutex_unlock(&efx->mac_lock);
160 static void ef4_ethtool_get_drvinfo(struct net_device *net_dev,
161 struct ethtool_drvinfo *info)
163 struct ef4_nic *efx = netdev_priv(net_dev);
165 strscpy(info->driver, KBUILD_MODNAME, sizeof(info->driver));
166 strscpy(info->version, EF4_DRIVER_VERSION, sizeof(info->version));
167 strscpy(info->bus_info, pci_name(efx->pci_dev), sizeof(info->bus_info));
170 static int ef4_ethtool_get_regs_len(struct net_device *net_dev)
172 return ef4_nic_get_regs_len(netdev_priv(net_dev));
175 static void ef4_ethtool_get_regs(struct net_device *net_dev,
176 struct ethtool_regs *regs, void *buf)
178 struct ef4_nic *efx = netdev_priv(net_dev);
180 regs->version = efx->type->revision;
181 ef4_nic_get_regs(efx, buf);
184 static u32 ef4_ethtool_get_msglevel(struct net_device *net_dev)
186 struct ef4_nic *efx = netdev_priv(net_dev);
187 return efx->msg_enable;
190 static void ef4_ethtool_set_msglevel(struct net_device *net_dev, u32 msg_enable)
192 struct ef4_nic *efx = netdev_priv(net_dev);
193 efx->msg_enable = msg_enable;
197 * ef4_fill_test - fill in an individual self-test entry
198 * @test_index: Index of the test
199 * @strings: Ethtool strings, or %NULL
200 * @data: Ethtool test results, or %NULL
201 * @test: Pointer to test result (used only if data != %NULL)
202 * @unit_format: Unit name format (e.g. "chan\%d")
203 * @unit_id: Unit id (e.g. 0 for "chan0")
204 * @test_format: Test name format (e.g. "loopback.\%s.tx.sent")
205 * @test_id: Test id (e.g. "PHYXS" for "loopback.PHYXS.tx_sent")
207 * Fill in an individual self-test entry.
209 static void ef4_fill_test(unsigned int test_index, u8 *strings, u64 *data,
210 int *test, const char *unit_format, int unit_id,
211 const char *test_format, const char *test_id)
213 char unit_str[ETH_GSTRING_LEN], test_str[ETH_GSTRING_LEN];
215 /* Fill data value, if applicable */
217 data[test_index] = *test;
219 /* Fill string, if applicable */
221 if (strchr(unit_format, '%'))
222 snprintf(unit_str, sizeof(unit_str),
223 unit_format, unit_id);
225 strcpy(unit_str, unit_format);
226 snprintf(test_str, sizeof(test_str), test_format, test_id);
227 snprintf(strings + test_index * ETH_GSTRING_LEN,
229 "%-6s %-24s", unit_str, test_str);
233 #define EF4_CHANNEL_NAME(_channel) "chan%d", _channel->channel
234 #define EF4_TX_QUEUE_NAME(_tx_queue) "txq%d", _tx_queue->queue
235 #define EF4_RX_QUEUE_NAME(_rx_queue) "rxq%d", _rx_queue->queue
236 #define EF4_LOOPBACK_NAME(_mode, _counter) \
237 "loopback.%s." _counter, STRING_TABLE_LOOKUP(_mode, ef4_loopback_mode)
240 * ef4_fill_loopback_test - fill in a block of loopback self-test entries
242 * @lb_tests: Efx loopback self-test results structure
243 * @mode: Loopback test mode
244 * @test_index: Starting index of the test
245 * @strings: Ethtool strings, or %NULL
246 * @data: Ethtool test results, or %NULL
248 * Fill in a block of loopback self-test entries. Return new test
251 static int ef4_fill_loopback_test(struct ef4_nic *efx,
252 struct ef4_loopback_self_tests *lb_tests,
253 enum ef4_loopback_mode mode,
254 unsigned int test_index,
255 u8 *strings, u64 *data)
257 struct ef4_channel *channel =
258 ef4_get_channel(efx, efx->tx_channel_offset);
259 struct ef4_tx_queue *tx_queue;
261 ef4_for_each_channel_tx_queue(tx_queue, channel) {
262 ef4_fill_test(test_index++, strings, data,
263 &lb_tests->tx_sent[tx_queue->queue],
264 EF4_TX_QUEUE_NAME(tx_queue),
265 EF4_LOOPBACK_NAME(mode, "tx_sent"));
266 ef4_fill_test(test_index++, strings, data,
267 &lb_tests->tx_done[tx_queue->queue],
268 EF4_TX_QUEUE_NAME(tx_queue),
269 EF4_LOOPBACK_NAME(mode, "tx_done"));
271 ef4_fill_test(test_index++, strings, data,
274 EF4_LOOPBACK_NAME(mode, "rx_good"));
275 ef4_fill_test(test_index++, strings, data,
278 EF4_LOOPBACK_NAME(mode, "rx_bad"));
284 * ef4_ethtool_fill_self_tests - get self-test details
286 * @tests: Efx self-test results structure, or %NULL
287 * @strings: Ethtool strings, or %NULL
288 * @data: Ethtool test results, or %NULL
290 * Get self-test number of strings, strings, and/or test results.
291 * Return number of strings (== number of test results).
293 * The reason for merging these three functions is to make sure that
294 * they can never be inconsistent.
296 static int ef4_ethtool_fill_self_tests(struct ef4_nic *efx,
297 struct ef4_self_tests *tests,
298 u8 *strings, u64 *data)
300 struct ef4_channel *channel;
301 unsigned int n = 0, i;
302 enum ef4_loopback_mode mode;
304 ef4_fill_test(n++, strings, data, &tests->phy_alive,
305 "phy", 0, "alive", NULL);
306 ef4_fill_test(n++, strings, data, &tests->nvram,
307 "core", 0, "nvram", NULL);
308 ef4_fill_test(n++, strings, data, &tests->interrupt,
309 "core", 0, "interrupt", NULL);
312 ef4_for_each_channel(channel, efx) {
313 ef4_fill_test(n++, strings, data,
314 &tests->eventq_dma[channel->channel],
315 EF4_CHANNEL_NAME(channel),
317 ef4_fill_test(n++, strings, data,
318 &tests->eventq_int[channel->channel],
319 EF4_CHANNEL_NAME(channel),
323 ef4_fill_test(n++, strings, data, &tests->memory,
324 "core", 0, "memory", NULL);
325 ef4_fill_test(n++, strings, data, &tests->registers,
326 "core", 0, "registers", NULL);
328 if (efx->phy_op->run_tests != NULL) {
329 EF4_BUG_ON_PARANOID(efx->phy_op->test_name == NULL);
331 for (i = 0; true; ++i) {
334 EF4_BUG_ON_PARANOID(i >= EF4_MAX_PHY_TESTS);
335 name = efx->phy_op->test_name(efx, i);
339 ef4_fill_test(n++, strings, data, &tests->phy_ext[i],
340 "phy", 0, name, NULL);
345 for (mode = LOOPBACK_NONE; mode <= LOOPBACK_TEST_MAX; mode++) {
346 if (!(efx->loopback_modes & (1 << mode)))
348 n = ef4_fill_loopback_test(efx,
349 &tests->loopback[mode], mode, n,
356 static size_t ef4_describe_per_queue_stats(struct ef4_nic *efx, u8 *strings)
359 struct ef4_channel *channel;
361 ef4_for_each_channel(channel, efx) {
362 if (ef4_channel_has_tx_queues(channel)) {
364 if (strings != NULL) {
365 snprintf(strings, ETH_GSTRING_LEN,
367 channel->tx_queue[0].queue /
370 strings += ETH_GSTRING_LEN;
374 ef4_for_each_channel(channel, efx) {
375 if (ef4_channel_has_rx_queue(channel)) {
377 if (strings != NULL) {
378 snprintf(strings, ETH_GSTRING_LEN,
379 "rx-%d.rx_packets", channel->channel);
380 strings += ETH_GSTRING_LEN;
387 static int ef4_ethtool_get_sset_count(struct net_device *net_dev,
390 struct ef4_nic *efx = netdev_priv(net_dev);
392 switch (string_set) {
394 return efx->type->describe_stats(efx, NULL) +
395 EF4_ETHTOOL_SW_STAT_COUNT +
396 ef4_describe_per_queue_stats(efx, NULL);
398 return ef4_ethtool_fill_self_tests(efx, NULL, NULL, NULL);
404 static void ef4_ethtool_get_strings(struct net_device *net_dev,
405 u32 string_set, u8 *strings)
407 struct ef4_nic *efx = netdev_priv(net_dev);
410 switch (string_set) {
412 strings += (efx->type->describe_stats(efx, strings) *
414 for (i = 0; i < EF4_ETHTOOL_SW_STAT_COUNT; i++)
415 strscpy(strings + i * ETH_GSTRING_LEN,
416 ef4_sw_stat_desc[i].name, ETH_GSTRING_LEN);
417 strings += EF4_ETHTOOL_SW_STAT_COUNT * ETH_GSTRING_LEN;
418 strings += (ef4_describe_per_queue_stats(efx, strings) *
422 ef4_ethtool_fill_self_tests(efx, NULL, strings, NULL);
425 /* No other string sets */
430 static void ef4_ethtool_get_stats(struct net_device *net_dev,
431 struct ethtool_stats *stats,
434 struct ef4_nic *efx = netdev_priv(net_dev);
435 const struct ef4_sw_stat_desc *stat;
436 struct ef4_channel *channel;
437 struct ef4_tx_queue *tx_queue;
438 struct ef4_rx_queue *rx_queue;
441 spin_lock_bh(&efx->stats_lock);
443 /* Get NIC statistics */
444 data += efx->type->update_stats(efx, data, NULL);
446 /* Get software statistics */
447 for (i = 0; i < EF4_ETHTOOL_SW_STAT_COUNT; i++) {
448 stat = &ef4_sw_stat_desc[i];
449 switch (stat->source) {
450 case EF4_ETHTOOL_STAT_SOURCE_nic:
451 data[i] = stat->get_stat((void *)efx + stat->offset);
453 case EF4_ETHTOOL_STAT_SOURCE_channel:
455 ef4_for_each_channel(channel, efx)
456 data[i] += stat->get_stat((void *)channel +
459 case EF4_ETHTOOL_STAT_SOURCE_tx_queue:
461 ef4_for_each_channel(channel, efx) {
462 ef4_for_each_channel_tx_queue(tx_queue, channel)
464 stat->get_stat((void *)tx_queue
470 data += EF4_ETHTOOL_SW_STAT_COUNT;
472 spin_unlock_bh(&efx->stats_lock);
474 ef4_for_each_channel(channel, efx) {
475 if (ef4_channel_has_tx_queues(channel)) {
477 ef4_for_each_channel_tx_queue(tx_queue, channel) {
478 *data += tx_queue->tx_packets;
483 ef4_for_each_channel(channel, efx) {
484 if (ef4_channel_has_rx_queue(channel)) {
486 ef4_for_each_channel_rx_queue(rx_queue, channel) {
487 *data += rx_queue->rx_packets;
494 static void ef4_ethtool_self_test(struct net_device *net_dev,
495 struct ethtool_test *test, u64 *data)
497 struct ef4_nic *efx = netdev_priv(net_dev);
498 struct ef4_self_tests *ef4_tests;
502 ef4_tests = kzalloc(sizeof(*ef4_tests), GFP_KERNEL);
506 if (efx->state != STATE_READY) {
511 netif_info(efx, drv, efx->net_dev, "starting %sline testing\n",
512 (test->flags & ETH_TEST_FL_OFFLINE) ? "off" : "on");
514 /* We need rx buffers and interrupts. */
515 already_up = (efx->net_dev->flags & IFF_UP);
517 rc = dev_open(efx->net_dev, NULL);
519 netif_err(efx, drv, efx->net_dev,
520 "failed opening device.\n");
525 rc = ef4_selftest(efx, ef4_tests, test->flags);
528 dev_close(efx->net_dev);
530 netif_info(efx, drv, efx->net_dev, "%s %sline self-tests\n",
531 rc == 0 ? "passed" : "failed",
532 (test->flags & ETH_TEST_FL_OFFLINE) ? "off" : "on");
535 ef4_ethtool_fill_self_tests(efx, ef4_tests, NULL, data);
539 test->flags |= ETH_TEST_FL_FAILED;
542 /* Restart autonegotiation */
543 static int ef4_ethtool_nway_reset(struct net_device *net_dev)
545 struct ef4_nic *efx = netdev_priv(net_dev);
547 return mdio45_nway_restart(&efx->mdio);
551 * Each channel has a single IRQ and moderation timer, started by any
552 * completion (or other event). Unless the module parameter
553 * separate_tx_channels is set, IRQs and moderation are therefore
554 * shared between RX and TX completions. In this case, when RX IRQ
555 * moderation is explicitly changed then TX IRQ moderation is
556 * automatically changed too, but otherwise we fail if the two values
557 * are requested to be different.
559 * The hardware does not support a limit on the number of completions
560 * before an IRQ, so we do not use the max_frames fields. We should
561 * report and require that max_frames == (usecs != 0), but this would
562 * invalidate existing user documentation.
564 * The hardware does not have distinct settings for interrupt
565 * moderation while the previous IRQ is being handled, so we should
566 * not use the 'irq' fields. However, an earlier developer
567 * misunderstood the meaning of the 'irq' fields and the driver did
568 * not support the standard fields. To avoid invalidating existing
569 * user documentation, we report and accept changes through either the
570 * standard or 'irq' fields. If both are changed at the same time, we
571 * prefer the standard field.
573 * We implement adaptive IRQ moderation, but use a different algorithm
574 * from that assumed in the definition of struct ethtool_coalesce.
575 * Therefore we do not use any of the adaptive moderation parameters
579 static int ef4_ethtool_get_coalesce(struct net_device *net_dev,
580 struct ethtool_coalesce *coalesce,
581 struct kernel_ethtool_coalesce *kernel_coal,
582 struct netlink_ext_ack *extack)
584 struct ef4_nic *efx = netdev_priv(net_dev);
585 unsigned int tx_usecs, rx_usecs;
588 ef4_get_irq_moderation(efx, &tx_usecs, &rx_usecs, &rx_adaptive);
590 coalesce->tx_coalesce_usecs = tx_usecs;
591 coalesce->tx_coalesce_usecs_irq = tx_usecs;
592 coalesce->rx_coalesce_usecs = rx_usecs;
593 coalesce->rx_coalesce_usecs_irq = rx_usecs;
594 coalesce->use_adaptive_rx_coalesce = rx_adaptive;
599 static int ef4_ethtool_set_coalesce(struct net_device *net_dev,
600 struct ethtool_coalesce *coalesce,
601 struct kernel_ethtool_coalesce *kernel_coal,
602 struct netlink_ext_ack *extack)
604 struct ef4_nic *efx = netdev_priv(net_dev);
605 struct ef4_channel *channel;
606 unsigned int tx_usecs, rx_usecs;
607 bool adaptive, rx_may_override_tx;
610 ef4_get_irq_moderation(efx, &tx_usecs, &rx_usecs, &adaptive);
612 if (coalesce->rx_coalesce_usecs != rx_usecs)
613 rx_usecs = coalesce->rx_coalesce_usecs;
615 rx_usecs = coalesce->rx_coalesce_usecs_irq;
617 adaptive = coalesce->use_adaptive_rx_coalesce;
619 /* If channels are shared, TX IRQ moderation can be quietly
620 * overridden unless it is changed from its old value.
622 rx_may_override_tx = (coalesce->tx_coalesce_usecs == tx_usecs &&
623 coalesce->tx_coalesce_usecs_irq == tx_usecs);
624 if (coalesce->tx_coalesce_usecs != tx_usecs)
625 tx_usecs = coalesce->tx_coalesce_usecs;
627 tx_usecs = coalesce->tx_coalesce_usecs_irq;
629 rc = ef4_init_irq_moderation(efx, tx_usecs, rx_usecs, adaptive,
634 ef4_for_each_channel(channel, efx)
635 efx->type->push_irq_moderation(channel);
641 ef4_ethtool_get_ringparam(struct net_device *net_dev,
642 struct ethtool_ringparam *ring,
643 struct kernel_ethtool_ringparam *kernel_ring,
644 struct netlink_ext_ack *extack)
646 struct ef4_nic *efx = netdev_priv(net_dev);
648 ring->rx_max_pending = EF4_MAX_DMAQ_SIZE;
649 ring->tx_max_pending = EF4_MAX_DMAQ_SIZE;
650 ring->rx_pending = efx->rxq_entries;
651 ring->tx_pending = efx->txq_entries;
655 ef4_ethtool_set_ringparam(struct net_device *net_dev,
656 struct ethtool_ringparam *ring,
657 struct kernel_ethtool_ringparam *kernel_ring,
658 struct netlink_ext_ack *extack)
660 struct ef4_nic *efx = netdev_priv(net_dev);
663 if (ring->rx_mini_pending || ring->rx_jumbo_pending ||
664 ring->rx_pending > EF4_MAX_DMAQ_SIZE ||
665 ring->tx_pending > EF4_MAX_DMAQ_SIZE)
668 if (ring->rx_pending < EF4_RXQ_MIN_ENT) {
669 netif_err(efx, drv, efx->net_dev,
670 "RX queues cannot be smaller than %u\n",
675 txq_entries = max(ring->tx_pending, EF4_TXQ_MIN_ENT(efx));
676 if (txq_entries != ring->tx_pending)
677 netif_warn(efx, drv, efx->net_dev,
678 "increasing TX queue size to minimum of %u\n",
681 return ef4_realloc_channels(efx, ring->rx_pending, txq_entries);
684 static int ef4_ethtool_set_pauseparam(struct net_device *net_dev,
685 struct ethtool_pauseparam *pause)
687 struct ef4_nic *efx = netdev_priv(net_dev);
688 u8 wanted_fc, old_fc;
692 mutex_lock(&efx->mac_lock);
694 wanted_fc = ((pause->rx_pause ? EF4_FC_RX : 0) |
695 (pause->tx_pause ? EF4_FC_TX : 0) |
696 (pause->autoneg ? EF4_FC_AUTO : 0));
698 if ((wanted_fc & EF4_FC_TX) && !(wanted_fc & EF4_FC_RX)) {
699 netif_dbg(efx, drv, efx->net_dev,
700 "Flow control unsupported: tx ON rx OFF\n");
705 if ((wanted_fc & EF4_FC_AUTO) && !efx->link_advertising) {
706 netif_dbg(efx, drv, efx->net_dev,
707 "Autonegotiation is disabled\n");
712 /* Hook for Falcon bug 11482 workaround */
713 if (efx->type->prepare_enable_fc_tx &&
714 (wanted_fc & EF4_FC_TX) && !(efx->wanted_fc & EF4_FC_TX))
715 efx->type->prepare_enable_fc_tx(efx);
717 old_adv = efx->link_advertising;
718 old_fc = efx->wanted_fc;
719 ef4_link_set_wanted_fc(efx, wanted_fc);
720 if (efx->link_advertising != old_adv ||
721 (efx->wanted_fc ^ old_fc) & EF4_FC_AUTO) {
722 rc = efx->phy_op->reconfigure(efx);
724 netif_err(efx, drv, efx->net_dev,
725 "Unable to advertise requested flow "
726 "control setting\n");
731 /* Reconfigure the MAC. The PHY *may* generate a link state change event
732 * if the user just changed the advertised capabilities, but there's no
733 * harm doing this twice */
734 ef4_mac_reconfigure(efx);
737 mutex_unlock(&efx->mac_lock);
742 static void ef4_ethtool_get_pauseparam(struct net_device *net_dev,
743 struct ethtool_pauseparam *pause)
745 struct ef4_nic *efx = netdev_priv(net_dev);
747 pause->rx_pause = !!(efx->wanted_fc & EF4_FC_RX);
748 pause->tx_pause = !!(efx->wanted_fc & EF4_FC_TX);
749 pause->autoneg = !!(efx->wanted_fc & EF4_FC_AUTO);
752 static void ef4_ethtool_get_wol(struct net_device *net_dev,
753 struct ethtool_wolinfo *wol)
755 struct ef4_nic *efx = netdev_priv(net_dev);
756 return efx->type->get_wol(efx, wol);
760 static int ef4_ethtool_set_wol(struct net_device *net_dev,
761 struct ethtool_wolinfo *wol)
763 struct ef4_nic *efx = netdev_priv(net_dev);
764 return efx->type->set_wol(efx, wol->wolopts);
767 static int ef4_ethtool_reset(struct net_device *net_dev, u32 *flags)
769 struct ef4_nic *efx = netdev_priv(net_dev);
772 rc = efx->type->map_reset_flags(flags);
776 return ef4_reset(efx, rc);
779 /* MAC address mask including only I/G bit */
780 static const u8 mac_addr_ig_mask[ETH_ALEN] __aligned(2) = {0x01, 0, 0, 0, 0, 0};
782 #define IP4_ADDR_FULL_MASK ((__force __be32)~0)
783 #define IP_PROTO_FULL_MASK 0xFF
784 #define PORT_FULL_MASK ((__force __be16)~0)
785 #define ETHER_TYPE_FULL_MASK ((__force __be16)~0)
787 static inline void ip6_fill_mask(__be32 *mask)
789 mask[0] = mask[1] = mask[2] = mask[3] = ~(__be32)0;
792 static int ef4_ethtool_get_class_rule(struct ef4_nic *efx,
793 struct ethtool_rx_flow_spec *rule)
795 struct ethtool_tcpip4_spec *ip_entry = &rule->h_u.tcp_ip4_spec;
796 struct ethtool_tcpip4_spec *ip_mask = &rule->m_u.tcp_ip4_spec;
797 struct ethtool_usrip4_spec *uip_entry = &rule->h_u.usr_ip4_spec;
798 struct ethtool_usrip4_spec *uip_mask = &rule->m_u.usr_ip4_spec;
799 struct ethtool_tcpip6_spec *ip6_entry = &rule->h_u.tcp_ip6_spec;
800 struct ethtool_tcpip6_spec *ip6_mask = &rule->m_u.tcp_ip6_spec;
801 struct ethtool_usrip6_spec *uip6_entry = &rule->h_u.usr_ip6_spec;
802 struct ethtool_usrip6_spec *uip6_mask = &rule->m_u.usr_ip6_spec;
803 struct ethhdr *mac_entry = &rule->h_u.ether_spec;
804 struct ethhdr *mac_mask = &rule->m_u.ether_spec;
805 struct ef4_filter_spec spec;
808 rc = ef4_filter_get_filter_safe(efx, EF4_FILTER_PRI_MANUAL,
809 rule->location, &spec);
813 if (spec.dmaq_id == EF4_FILTER_RX_DMAQ_ID_DROP)
814 rule->ring_cookie = RX_CLS_FLOW_DISC;
816 rule->ring_cookie = spec.dmaq_id;
818 if ((spec.match_flags & EF4_FILTER_MATCH_ETHER_TYPE) &&
819 spec.ether_type == htons(ETH_P_IP) &&
820 (spec.match_flags & EF4_FILTER_MATCH_IP_PROTO) &&
821 (spec.ip_proto == IPPROTO_TCP || spec.ip_proto == IPPROTO_UDP) &&
823 ~(EF4_FILTER_MATCH_ETHER_TYPE | EF4_FILTER_MATCH_OUTER_VID |
824 EF4_FILTER_MATCH_LOC_HOST | EF4_FILTER_MATCH_REM_HOST |
825 EF4_FILTER_MATCH_IP_PROTO |
826 EF4_FILTER_MATCH_LOC_PORT | EF4_FILTER_MATCH_REM_PORT))) {
827 rule->flow_type = ((spec.ip_proto == IPPROTO_TCP) ?
828 TCP_V4_FLOW : UDP_V4_FLOW);
829 if (spec.match_flags & EF4_FILTER_MATCH_LOC_HOST) {
830 ip_entry->ip4dst = spec.loc_host[0];
831 ip_mask->ip4dst = IP4_ADDR_FULL_MASK;
833 if (spec.match_flags & EF4_FILTER_MATCH_REM_HOST) {
834 ip_entry->ip4src = spec.rem_host[0];
835 ip_mask->ip4src = IP4_ADDR_FULL_MASK;
837 if (spec.match_flags & EF4_FILTER_MATCH_LOC_PORT) {
838 ip_entry->pdst = spec.loc_port;
839 ip_mask->pdst = PORT_FULL_MASK;
841 if (spec.match_flags & EF4_FILTER_MATCH_REM_PORT) {
842 ip_entry->psrc = spec.rem_port;
843 ip_mask->psrc = PORT_FULL_MASK;
845 } else if ((spec.match_flags & EF4_FILTER_MATCH_ETHER_TYPE) &&
846 spec.ether_type == htons(ETH_P_IPV6) &&
847 (spec.match_flags & EF4_FILTER_MATCH_IP_PROTO) &&
848 (spec.ip_proto == IPPROTO_TCP || spec.ip_proto == IPPROTO_UDP) &&
850 ~(EF4_FILTER_MATCH_ETHER_TYPE | EF4_FILTER_MATCH_OUTER_VID |
851 EF4_FILTER_MATCH_LOC_HOST | EF4_FILTER_MATCH_REM_HOST |
852 EF4_FILTER_MATCH_IP_PROTO |
853 EF4_FILTER_MATCH_LOC_PORT | EF4_FILTER_MATCH_REM_PORT))) {
854 rule->flow_type = ((spec.ip_proto == IPPROTO_TCP) ?
855 TCP_V6_FLOW : UDP_V6_FLOW);
856 if (spec.match_flags & EF4_FILTER_MATCH_LOC_HOST) {
857 memcpy(ip6_entry->ip6dst, spec.loc_host,
858 sizeof(ip6_entry->ip6dst));
859 ip6_fill_mask(ip6_mask->ip6dst);
861 if (spec.match_flags & EF4_FILTER_MATCH_REM_HOST) {
862 memcpy(ip6_entry->ip6src, spec.rem_host,
863 sizeof(ip6_entry->ip6src));
864 ip6_fill_mask(ip6_mask->ip6src);
866 if (spec.match_flags & EF4_FILTER_MATCH_LOC_PORT) {
867 ip6_entry->pdst = spec.loc_port;
868 ip6_mask->pdst = PORT_FULL_MASK;
870 if (spec.match_flags & EF4_FILTER_MATCH_REM_PORT) {
871 ip6_entry->psrc = spec.rem_port;
872 ip6_mask->psrc = PORT_FULL_MASK;
874 } else if (!(spec.match_flags &
875 ~(EF4_FILTER_MATCH_LOC_MAC | EF4_FILTER_MATCH_LOC_MAC_IG |
876 EF4_FILTER_MATCH_REM_MAC | EF4_FILTER_MATCH_ETHER_TYPE |
877 EF4_FILTER_MATCH_OUTER_VID))) {
878 rule->flow_type = ETHER_FLOW;
879 if (spec.match_flags &
880 (EF4_FILTER_MATCH_LOC_MAC | EF4_FILTER_MATCH_LOC_MAC_IG)) {
881 ether_addr_copy(mac_entry->h_dest, spec.loc_mac);
882 if (spec.match_flags & EF4_FILTER_MATCH_LOC_MAC)
883 eth_broadcast_addr(mac_mask->h_dest);
885 ether_addr_copy(mac_mask->h_dest,
888 if (spec.match_flags & EF4_FILTER_MATCH_REM_MAC) {
889 ether_addr_copy(mac_entry->h_source, spec.rem_mac);
890 eth_broadcast_addr(mac_mask->h_source);
892 if (spec.match_flags & EF4_FILTER_MATCH_ETHER_TYPE) {
893 mac_entry->h_proto = spec.ether_type;
894 mac_mask->h_proto = ETHER_TYPE_FULL_MASK;
896 } else if (spec.match_flags & EF4_FILTER_MATCH_ETHER_TYPE &&
897 spec.ether_type == htons(ETH_P_IP) &&
899 ~(EF4_FILTER_MATCH_ETHER_TYPE | EF4_FILTER_MATCH_OUTER_VID |
900 EF4_FILTER_MATCH_LOC_HOST | EF4_FILTER_MATCH_REM_HOST |
901 EF4_FILTER_MATCH_IP_PROTO))) {
902 rule->flow_type = IPV4_USER_FLOW;
903 uip_entry->ip_ver = ETH_RX_NFC_IP4;
904 if (spec.match_flags & EF4_FILTER_MATCH_IP_PROTO) {
905 uip_mask->proto = IP_PROTO_FULL_MASK;
906 uip_entry->proto = spec.ip_proto;
908 if (spec.match_flags & EF4_FILTER_MATCH_LOC_HOST) {
909 uip_entry->ip4dst = spec.loc_host[0];
910 uip_mask->ip4dst = IP4_ADDR_FULL_MASK;
912 if (spec.match_flags & EF4_FILTER_MATCH_REM_HOST) {
913 uip_entry->ip4src = spec.rem_host[0];
914 uip_mask->ip4src = IP4_ADDR_FULL_MASK;
916 } else if (spec.match_flags & EF4_FILTER_MATCH_ETHER_TYPE &&
917 spec.ether_type == htons(ETH_P_IPV6) &&
919 ~(EF4_FILTER_MATCH_ETHER_TYPE | EF4_FILTER_MATCH_OUTER_VID |
920 EF4_FILTER_MATCH_LOC_HOST | EF4_FILTER_MATCH_REM_HOST |
921 EF4_FILTER_MATCH_IP_PROTO))) {
922 rule->flow_type = IPV6_USER_FLOW;
923 if (spec.match_flags & EF4_FILTER_MATCH_IP_PROTO) {
924 uip6_mask->l4_proto = IP_PROTO_FULL_MASK;
925 uip6_entry->l4_proto = spec.ip_proto;
927 if (spec.match_flags & EF4_FILTER_MATCH_LOC_HOST) {
928 memcpy(uip6_entry->ip6dst, spec.loc_host,
929 sizeof(uip6_entry->ip6dst));
930 ip6_fill_mask(uip6_mask->ip6dst);
932 if (spec.match_flags & EF4_FILTER_MATCH_REM_HOST) {
933 memcpy(uip6_entry->ip6src, spec.rem_host,
934 sizeof(uip6_entry->ip6src));
935 ip6_fill_mask(uip6_mask->ip6src);
938 /* The above should handle all filters that we insert */
943 if (spec.match_flags & EF4_FILTER_MATCH_OUTER_VID) {
944 rule->flow_type |= FLOW_EXT;
945 rule->h_ext.vlan_tci = spec.outer_vid;
946 rule->m_ext.vlan_tci = htons(0xfff);
953 ef4_ethtool_get_rxnfc(struct net_device *net_dev,
954 struct ethtool_rxnfc *info, u32 *rule_locs)
956 struct ef4_nic *efx = netdev_priv(net_dev);
959 case ETHTOOL_GRXRINGS:
960 info->data = efx->n_rx_channels;
963 case ETHTOOL_GRXFH: {
964 unsigned min_revision = 0;
967 switch (info->flow_type) {
969 info->data |= RXH_L4_B_0_1 | RXH_L4_B_2_3;
975 info->data |= RXH_IP_SRC | RXH_IP_DST;
976 min_revision = EF4_REV_FALCON_B0;
981 if (ef4_nic_rev(efx) < min_revision)
986 case ETHTOOL_GRXCLSRLCNT:
987 info->data = ef4_filter_get_rx_id_limit(efx);
990 info->data |= RX_CLS_LOC_SPECIAL;
992 ef4_filter_count_rx_used(efx, EF4_FILTER_PRI_MANUAL);
995 case ETHTOOL_GRXCLSRULE:
996 if (ef4_filter_get_rx_id_limit(efx) == 0)
998 return ef4_ethtool_get_class_rule(efx, &info->fs);
1000 case ETHTOOL_GRXCLSRLALL: {
1002 info->data = ef4_filter_get_rx_id_limit(efx);
1003 if (info->data == 0)
1005 rc = ef4_filter_get_rx_ids(efx, EF4_FILTER_PRI_MANUAL,
1006 rule_locs, info->rule_cnt);
1009 info->rule_cnt = rc;
1018 static inline bool ip6_mask_is_full(__be32 mask[4])
1020 return !~(mask[0] & mask[1] & mask[2] & mask[3]);
1023 static inline bool ip6_mask_is_empty(__be32 mask[4])
1025 return !(mask[0] | mask[1] | mask[2] | mask[3]);
1028 static int ef4_ethtool_set_class_rule(struct ef4_nic *efx,
1029 struct ethtool_rx_flow_spec *rule)
1031 struct ethtool_tcpip4_spec *ip_entry = &rule->h_u.tcp_ip4_spec;
1032 struct ethtool_tcpip4_spec *ip_mask = &rule->m_u.tcp_ip4_spec;
1033 struct ethtool_usrip4_spec *uip_entry = &rule->h_u.usr_ip4_spec;
1034 struct ethtool_usrip4_spec *uip_mask = &rule->m_u.usr_ip4_spec;
1035 struct ethtool_tcpip6_spec *ip6_entry = &rule->h_u.tcp_ip6_spec;
1036 struct ethtool_tcpip6_spec *ip6_mask = &rule->m_u.tcp_ip6_spec;
1037 struct ethtool_usrip6_spec *uip6_entry = &rule->h_u.usr_ip6_spec;
1038 struct ethtool_usrip6_spec *uip6_mask = &rule->m_u.usr_ip6_spec;
1039 struct ethhdr *mac_entry = &rule->h_u.ether_spec;
1040 struct ethhdr *mac_mask = &rule->m_u.ether_spec;
1041 struct ef4_filter_spec spec;
1044 /* Check that user wants us to choose the location */
1045 if (rule->location != RX_CLS_LOC_ANY)
1048 /* Range-check ring_cookie */
1049 if (rule->ring_cookie >= efx->n_rx_channels &&
1050 rule->ring_cookie != RX_CLS_FLOW_DISC)
1053 /* Check for unsupported extensions */
1054 if ((rule->flow_type & FLOW_EXT) &&
1055 (rule->m_ext.vlan_etype || rule->m_ext.data[0] ||
1056 rule->m_ext.data[1]))
1059 ef4_filter_init_rx(&spec, EF4_FILTER_PRI_MANUAL,
1060 efx->rx_scatter ? EF4_FILTER_FLAG_RX_SCATTER : 0,
1061 (rule->ring_cookie == RX_CLS_FLOW_DISC) ?
1062 EF4_FILTER_RX_DMAQ_ID_DROP : rule->ring_cookie);
1064 switch (rule->flow_type & ~FLOW_EXT) {
1067 spec.match_flags = (EF4_FILTER_MATCH_ETHER_TYPE |
1068 EF4_FILTER_MATCH_IP_PROTO);
1069 spec.ether_type = htons(ETH_P_IP);
1070 spec.ip_proto = ((rule->flow_type & ~FLOW_EXT) == TCP_V4_FLOW ?
1071 IPPROTO_TCP : IPPROTO_UDP);
1072 if (ip_mask->ip4dst) {
1073 if (ip_mask->ip4dst != IP4_ADDR_FULL_MASK)
1075 spec.match_flags |= EF4_FILTER_MATCH_LOC_HOST;
1076 spec.loc_host[0] = ip_entry->ip4dst;
1078 if (ip_mask->ip4src) {
1079 if (ip_mask->ip4src != IP4_ADDR_FULL_MASK)
1081 spec.match_flags |= EF4_FILTER_MATCH_REM_HOST;
1082 spec.rem_host[0] = ip_entry->ip4src;
1084 if (ip_mask->pdst) {
1085 if (ip_mask->pdst != PORT_FULL_MASK)
1087 spec.match_flags |= EF4_FILTER_MATCH_LOC_PORT;
1088 spec.loc_port = ip_entry->pdst;
1090 if (ip_mask->psrc) {
1091 if (ip_mask->psrc != PORT_FULL_MASK)
1093 spec.match_flags |= EF4_FILTER_MATCH_REM_PORT;
1094 spec.rem_port = ip_entry->psrc;
1102 spec.match_flags = (EF4_FILTER_MATCH_ETHER_TYPE |
1103 EF4_FILTER_MATCH_IP_PROTO);
1104 spec.ether_type = htons(ETH_P_IPV6);
1105 spec.ip_proto = ((rule->flow_type & ~FLOW_EXT) == TCP_V6_FLOW ?
1106 IPPROTO_TCP : IPPROTO_UDP);
1107 if (!ip6_mask_is_empty(ip6_mask->ip6dst)) {
1108 if (!ip6_mask_is_full(ip6_mask->ip6dst))
1110 spec.match_flags |= EF4_FILTER_MATCH_LOC_HOST;
1111 memcpy(spec.loc_host, ip6_entry->ip6dst, sizeof(spec.loc_host));
1113 if (!ip6_mask_is_empty(ip6_mask->ip6src)) {
1114 if (!ip6_mask_is_full(ip6_mask->ip6src))
1116 spec.match_flags |= EF4_FILTER_MATCH_REM_HOST;
1117 memcpy(spec.rem_host, ip6_entry->ip6src, sizeof(spec.rem_host));
1119 if (ip6_mask->pdst) {
1120 if (ip6_mask->pdst != PORT_FULL_MASK)
1122 spec.match_flags |= EF4_FILTER_MATCH_LOC_PORT;
1123 spec.loc_port = ip6_entry->pdst;
1125 if (ip6_mask->psrc) {
1126 if (ip6_mask->psrc != PORT_FULL_MASK)
1128 spec.match_flags |= EF4_FILTER_MATCH_REM_PORT;
1129 spec.rem_port = ip6_entry->psrc;
1131 if (ip6_mask->tclass)
1135 case IPV4_USER_FLOW:
1136 if (uip_mask->l4_4_bytes || uip_mask->tos || uip_mask->ip_ver ||
1137 uip_entry->ip_ver != ETH_RX_NFC_IP4)
1139 spec.match_flags = EF4_FILTER_MATCH_ETHER_TYPE;
1140 spec.ether_type = htons(ETH_P_IP);
1141 if (uip_mask->ip4dst) {
1142 if (uip_mask->ip4dst != IP4_ADDR_FULL_MASK)
1144 spec.match_flags |= EF4_FILTER_MATCH_LOC_HOST;
1145 spec.loc_host[0] = uip_entry->ip4dst;
1147 if (uip_mask->ip4src) {
1148 if (uip_mask->ip4src != IP4_ADDR_FULL_MASK)
1150 spec.match_flags |= EF4_FILTER_MATCH_REM_HOST;
1151 spec.rem_host[0] = uip_entry->ip4src;
1153 if (uip_mask->proto) {
1154 if (uip_mask->proto != IP_PROTO_FULL_MASK)
1156 spec.match_flags |= EF4_FILTER_MATCH_IP_PROTO;
1157 spec.ip_proto = uip_entry->proto;
1161 case IPV6_USER_FLOW:
1162 if (uip6_mask->l4_4_bytes || uip6_mask->tclass)
1164 spec.match_flags = EF4_FILTER_MATCH_ETHER_TYPE;
1165 spec.ether_type = htons(ETH_P_IPV6);
1166 if (!ip6_mask_is_empty(uip6_mask->ip6dst)) {
1167 if (!ip6_mask_is_full(uip6_mask->ip6dst))
1169 spec.match_flags |= EF4_FILTER_MATCH_LOC_HOST;
1170 memcpy(spec.loc_host, uip6_entry->ip6dst, sizeof(spec.loc_host));
1172 if (!ip6_mask_is_empty(uip6_mask->ip6src)) {
1173 if (!ip6_mask_is_full(uip6_mask->ip6src))
1175 spec.match_flags |= EF4_FILTER_MATCH_REM_HOST;
1176 memcpy(spec.rem_host, uip6_entry->ip6src, sizeof(spec.rem_host));
1178 if (uip6_mask->l4_proto) {
1179 if (uip6_mask->l4_proto != IP_PROTO_FULL_MASK)
1181 spec.match_flags |= EF4_FILTER_MATCH_IP_PROTO;
1182 spec.ip_proto = uip6_entry->l4_proto;
1187 if (!is_zero_ether_addr(mac_mask->h_dest)) {
1188 if (ether_addr_equal(mac_mask->h_dest,
1190 spec.match_flags |= EF4_FILTER_MATCH_LOC_MAC_IG;
1191 else if (is_broadcast_ether_addr(mac_mask->h_dest))
1192 spec.match_flags |= EF4_FILTER_MATCH_LOC_MAC;
1195 ether_addr_copy(spec.loc_mac, mac_entry->h_dest);
1197 if (!is_zero_ether_addr(mac_mask->h_source)) {
1198 if (!is_broadcast_ether_addr(mac_mask->h_source))
1200 spec.match_flags |= EF4_FILTER_MATCH_REM_MAC;
1201 ether_addr_copy(spec.rem_mac, mac_entry->h_source);
1203 if (mac_mask->h_proto) {
1204 if (mac_mask->h_proto != ETHER_TYPE_FULL_MASK)
1206 spec.match_flags |= EF4_FILTER_MATCH_ETHER_TYPE;
1207 spec.ether_type = mac_entry->h_proto;
1215 if ((rule->flow_type & FLOW_EXT) && rule->m_ext.vlan_tci) {
1216 if (rule->m_ext.vlan_tci != htons(0xfff))
1218 spec.match_flags |= EF4_FILTER_MATCH_OUTER_VID;
1219 spec.outer_vid = rule->h_ext.vlan_tci;
1222 rc = ef4_filter_insert_filter(efx, &spec, true);
1226 rule->location = rc;
1230 static int ef4_ethtool_set_rxnfc(struct net_device *net_dev,
1231 struct ethtool_rxnfc *info)
1233 struct ef4_nic *efx = netdev_priv(net_dev);
1235 if (ef4_filter_get_rx_id_limit(efx) == 0)
1238 switch (info->cmd) {
1239 case ETHTOOL_SRXCLSRLINS:
1240 return ef4_ethtool_set_class_rule(efx, &info->fs);
1242 case ETHTOOL_SRXCLSRLDEL:
1243 return ef4_filter_remove_id_safe(efx, EF4_FILTER_PRI_MANUAL,
1251 static u32 ef4_ethtool_get_rxfh_indir_size(struct net_device *net_dev)
1253 struct ef4_nic *efx = netdev_priv(net_dev);
1255 return ((ef4_nic_rev(efx) < EF4_REV_FALCON_B0 ||
1256 efx->n_rx_channels == 1) ?
1257 0 : ARRAY_SIZE(efx->rx_indir_table));
1260 static int ef4_ethtool_get_rxfh(struct net_device *net_dev,
1261 struct ethtool_rxfh_param *rxfh)
1263 struct ef4_nic *efx = netdev_priv(net_dev);
1265 rxfh->hfunc = ETH_RSS_HASH_TOP;
1267 memcpy(rxfh->indir, efx->rx_indir_table,
1268 sizeof(efx->rx_indir_table));
1272 static int ef4_ethtool_set_rxfh(struct net_device *net_dev,
1273 struct ethtool_rxfh_param *rxfh,
1274 struct netlink_ext_ack *extack)
1276 struct ef4_nic *efx = netdev_priv(net_dev);
1278 /* We do not allow change in unsupported parameters */
1280 (rxfh->hfunc != ETH_RSS_HASH_NO_CHANGE &&
1281 rxfh->hfunc != ETH_RSS_HASH_TOP))
1286 return efx->type->rx_push_rss_config(efx, true, rxfh->indir);
1289 static int ef4_ethtool_get_module_eeprom(struct net_device *net_dev,
1290 struct ethtool_eeprom *ee,
1293 struct ef4_nic *efx = netdev_priv(net_dev);
1296 if (!efx->phy_op || !efx->phy_op->get_module_eeprom)
1299 mutex_lock(&efx->mac_lock);
1300 ret = efx->phy_op->get_module_eeprom(efx, ee, data);
1301 mutex_unlock(&efx->mac_lock);
1306 static int ef4_ethtool_get_module_info(struct net_device *net_dev,
1307 struct ethtool_modinfo *modinfo)
1309 struct ef4_nic *efx = netdev_priv(net_dev);
1312 if (!efx->phy_op || !efx->phy_op->get_module_info)
1315 mutex_lock(&efx->mac_lock);
1316 ret = efx->phy_op->get_module_info(efx, modinfo);
1317 mutex_unlock(&efx->mac_lock);
1322 const struct ethtool_ops ef4_ethtool_ops = {
1323 .supported_coalesce_params = ETHTOOL_COALESCE_USECS |
1324 ETHTOOL_COALESCE_USECS_IRQ |
1325 ETHTOOL_COALESCE_USE_ADAPTIVE_RX,
1326 .get_drvinfo = ef4_ethtool_get_drvinfo,
1327 .get_regs_len = ef4_ethtool_get_regs_len,
1328 .get_regs = ef4_ethtool_get_regs,
1329 .get_msglevel = ef4_ethtool_get_msglevel,
1330 .set_msglevel = ef4_ethtool_set_msglevel,
1331 .nway_reset = ef4_ethtool_nway_reset,
1332 .get_link = ethtool_op_get_link,
1333 .get_coalesce = ef4_ethtool_get_coalesce,
1334 .set_coalesce = ef4_ethtool_set_coalesce,
1335 .get_ringparam = ef4_ethtool_get_ringparam,
1336 .set_ringparam = ef4_ethtool_set_ringparam,
1337 .get_pauseparam = ef4_ethtool_get_pauseparam,
1338 .set_pauseparam = ef4_ethtool_set_pauseparam,
1339 .get_sset_count = ef4_ethtool_get_sset_count,
1340 .self_test = ef4_ethtool_self_test,
1341 .get_strings = ef4_ethtool_get_strings,
1342 .set_phys_id = ef4_ethtool_phys_id,
1343 .get_ethtool_stats = ef4_ethtool_get_stats,
1344 .get_wol = ef4_ethtool_get_wol,
1345 .set_wol = ef4_ethtool_set_wol,
1346 .reset = ef4_ethtool_reset,
1347 .get_rxnfc = ef4_ethtool_get_rxnfc,
1348 .set_rxnfc = ef4_ethtool_set_rxnfc,
1349 .get_rxfh_indir_size = ef4_ethtool_get_rxfh_indir_size,
1350 .get_rxfh = ef4_ethtool_get_rxfh,
1351 .set_rxfh = ef4_ethtool_set_rxfh,
1352 .get_module_info = ef4_ethtool_get_module_info,
1353 .get_module_eeprom = ef4_ethtool_get_module_eeprom,
1354 .get_link_ksettings = ef4_ethtool_get_link_ksettings,
1355 .set_link_ksettings = ef4_ethtool_set_link_ksettings,