1 // SPDX-License-Identifier: GPL-2.0-only
2 /****************************************************************************
3 * Driver for Solarflare network controllers and boards
4 * Copyright 2019 Solarflare Communications Inc.
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.
10 #include <linux/module.h>
11 #include <linux/netdevice.h>
12 #include "net_driver.h"
16 #include "rx_common.h"
17 #include "ethtool_common.h"
19 struct efx_sw_stat_desc {
22 EFX_ETHTOOL_STAT_SOURCE_nic,
23 EFX_ETHTOOL_STAT_SOURCE_channel,
24 EFX_ETHTOOL_STAT_SOURCE_tx_queue
27 u64 (*get_stat)(void *field); /* Reader function */
30 /* Initialiser for a struct efx_sw_stat_desc with type-checking */
31 #define EFX_ETHTOOL_STAT(stat_name, source_name, field, field_type, \
32 get_stat_function) { \
34 .source = EFX_ETHTOOL_STAT_SOURCE_##source_name, \
35 .offset = ((((field_type *) 0) == \
36 &((struct efx_##source_name *)0)->field) ? \
37 offsetof(struct efx_##source_name, field) : \
38 offsetof(struct efx_##source_name, field)), \
39 .get_stat = get_stat_function, \
42 static u64 efx_get_uint_stat(void *field)
44 return *(unsigned int *)field;
47 static u64 efx_get_atomic_stat(void *field)
49 return atomic_read((atomic_t *) field);
52 #define EFX_ETHTOOL_ATOMIC_NIC_ERROR_STAT(field) \
53 EFX_ETHTOOL_STAT(field, nic, field, \
54 atomic_t, efx_get_atomic_stat)
56 #define EFX_ETHTOOL_UINT_CHANNEL_STAT(field) \
57 EFX_ETHTOOL_STAT(field, channel, n_##field, \
58 unsigned int, efx_get_uint_stat)
59 #define EFX_ETHTOOL_UINT_CHANNEL_STAT_NO_N(field) \
60 EFX_ETHTOOL_STAT(field, channel, field, \
61 unsigned int, efx_get_uint_stat)
63 #define EFX_ETHTOOL_UINT_TXQ_STAT(field) \
64 EFX_ETHTOOL_STAT(tx_##field, tx_queue, field, \
65 unsigned int, efx_get_uint_stat)
67 static const struct efx_sw_stat_desc efx_sw_stat_desc[] = {
68 EFX_ETHTOOL_UINT_TXQ_STAT(merge_events),
69 EFX_ETHTOOL_UINT_TXQ_STAT(tso_bursts),
70 EFX_ETHTOOL_UINT_TXQ_STAT(tso_long_headers),
71 EFX_ETHTOOL_UINT_TXQ_STAT(tso_packets),
72 EFX_ETHTOOL_UINT_TXQ_STAT(tso_fallbacks),
73 EFX_ETHTOOL_UINT_TXQ_STAT(pushes),
74 EFX_ETHTOOL_UINT_TXQ_STAT(pio_packets),
75 EFX_ETHTOOL_UINT_TXQ_STAT(cb_packets),
76 EFX_ETHTOOL_ATOMIC_NIC_ERROR_STAT(rx_reset),
77 EFX_ETHTOOL_UINT_CHANNEL_STAT(rx_tobe_disc),
78 EFX_ETHTOOL_UINT_CHANNEL_STAT(rx_ip_hdr_chksum_err),
79 EFX_ETHTOOL_UINT_CHANNEL_STAT(rx_tcp_udp_chksum_err),
80 EFX_ETHTOOL_UINT_CHANNEL_STAT(rx_inner_ip_hdr_chksum_err),
81 EFX_ETHTOOL_UINT_CHANNEL_STAT(rx_inner_tcp_udp_chksum_err),
82 EFX_ETHTOOL_UINT_CHANNEL_STAT(rx_outer_ip_hdr_chksum_err),
83 EFX_ETHTOOL_UINT_CHANNEL_STAT(rx_outer_tcp_udp_chksum_err),
84 EFX_ETHTOOL_UINT_CHANNEL_STAT(rx_eth_crc_err),
85 EFX_ETHTOOL_UINT_CHANNEL_STAT(rx_mcast_mismatch),
86 EFX_ETHTOOL_UINT_CHANNEL_STAT(rx_frm_trunc),
87 EFX_ETHTOOL_UINT_CHANNEL_STAT(rx_merge_events),
88 EFX_ETHTOOL_UINT_CHANNEL_STAT(rx_merge_packets),
89 EFX_ETHTOOL_UINT_CHANNEL_STAT(rx_xdp_drops),
90 EFX_ETHTOOL_UINT_CHANNEL_STAT(rx_xdp_bad_drops),
91 EFX_ETHTOOL_UINT_CHANNEL_STAT(rx_xdp_tx),
92 EFX_ETHTOOL_UINT_CHANNEL_STAT(rx_xdp_redirect),
93 #ifdef CONFIG_RFS_ACCEL
94 EFX_ETHTOOL_UINT_CHANNEL_STAT_NO_N(rfs_filter_count),
95 EFX_ETHTOOL_UINT_CHANNEL_STAT(rfs_succeeded),
96 EFX_ETHTOOL_UINT_CHANNEL_STAT(rfs_failed),
100 #define EFX_ETHTOOL_SW_STAT_COUNT ARRAY_SIZE(efx_sw_stat_desc)
102 void efx_ethtool_get_drvinfo(struct net_device *net_dev,
103 struct ethtool_drvinfo *info)
105 struct efx_nic *efx = netdev_priv(net_dev);
107 strlcpy(info->driver, KBUILD_MODNAME, sizeof(info->driver));
108 strlcpy(info->version, EFX_DRIVER_VERSION, sizeof(info->version));
109 efx_mcdi_print_fwver(efx, info->fw_version,
110 sizeof(info->fw_version));
111 strlcpy(info->bus_info, pci_name(efx->pci_dev), sizeof(info->bus_info));
114 u32 efx_ethtool_get_msglevel(struct net_device *net_dev)
116 struct efx_nic *efx = netdev_priv(net_dev);
118 return efx->msg_enable;
121 void efx_ethtool_set_msglevel(struct net_device *net_dev, u32 msg_enable)
123 struct efx_nic *efx = netdev_priv(net_dev);
125 efx->msg_enable = msg_enable;
128 void efx_ethtool_self_test(struct net_device *net_dev,
129 struct ethtool_test *test, u64 *data)
131 struct efx_nic *efx = netdev_priv(net_dev);
132 struct efx_self_tests *efx_tests;
136 efx_tests = kzalloc(sizeof(*efx_tests), GFP_KERNEL);
140 if (efx->state != STATE_READY) {
145 netif_info(efx, drv, efx->net_dev, "starting %sline testing\n",
146 (test->flags & ETH_TEST_FL_OFFLINE) ? "off" : "on");
148 /* We need rx buffers and interrupts. */
149 already_up = (efx->net_dev->flags & IFF_UP);
151 rc = dev_open(efx->net_dev, NULL);
153 netif_err(efx, drv, efx->net_dev,
154 "failed opening device.\n");
159 rc = efx_selftest(efx, efx_tests, test->flags);
162 dev_close(efx->net_dev);
164 netif_info(efx, drv, efx->net_dev, "%s %sline self-tests\n",
165 rc == 0 ? "passed" : "failed",
166 (test->flags & ETH_TEST_FL_OFFLINE) ? "off" : "on");
169 efx_ethtool_fill_self_tests(efx, efx_tests, NULL, data);
173 test->flags |= ETH_TEST_FL_FAILED;
176 void efx_ethtool_get_pauseparam(struct net_device *net_dev,
177 struct ethtool_pauseparam *pause)
179 struct efx_nic *efx = netdev_priv(net_dev);
181 pause->rx_pause = !!(efx->wanted_fc & EFX_FC_RX);
182 pause->tx_pause = !!(efx->wanted_fc & EFX_FC_TX);
183 pause->autoneg = !!(efx->wanted_fc & EFX_FC_AUTO);
186 int efx_ethtool_set_pauseparam(struct net_device *net_dev,
187 struct ethtool_pauseparam *pause)
189 struct efx_nic *efx = netdev_priv(net_dev);
190 u8 wanted_fc, old_fc;
194 mutex_lock(&efx->mac_lock);
196 wanted_fc = ((pause->rx_pause ? EFX_FC_RX : 0) |
197 (pause->tx_pause ? EFX_FC_TX : 0) |
198 (pause->autoneg ? EFX_FC_AUTO : 0));
200 if ((wanted_fc & EFX_FC_TX) && !(wanted_fc & EFX_FC_RX)) {
201 netif_dbg(efx, drv, efx->net_dev,
202 "Flow control unsupported: tx ON rx OFF\n");
207 if ((wanted_fc & EFX_FC_AUTO) && !efx->link_advertising[0]) {
208 netif_dbg(efx, drv, efx->net_dev,
209 "Autonegotiation is disabled\n");
214 /* Hook for Falcon bug 11482 workaround */
215 if (efx->type->prepare_enable_fc_tx &&
216 (wanted_fc & EFX_FC_TX) && !(efx->wanted_fc & EFX_FC_TX))
217 efx->type->prepare_enable_fc_tx(efx);
219 old_adv = efx->link_advertising[0];
220 old_fc = efx->wanted_fc;
221 efx_link_set_wanted_fc(efx, wanted_fc);
222 if (efx->link_advertising[0] != old_adv ||
223 (efx->wanted_fc ^ old_fc) & EFX_FC_AUTO) {
224 rc = efx->phy_op->reconfigure(efx);
226 netif_err(efx, drv, efx->net_dev,
227 "Unable to advertise requested flow "
228 "control setting\n");
233 /* Reconfigure the MAC. The PHY *may* generate a link state change event
234 * if the user just changed the advertised capabilities, but there's no
235 * harm doing this twice */
236 efx_mac_reconfigure(efx, false);
239 mutex_unlock(&efx->mac_lock);
245 * efx_fill_test - fill in an individual self-test entry
246 * @test_index: Index of the test
247 * @strings: Ethtool strings, or %NULL
248 * @data: Ethtool test results, or %NULL
249 * @test: Pointer to test result (used only if data != %NULL)
250 * @unit_format: Unit name format (e.g. "chan\%d")
251 * @unit_id: Unit id (e.g. 0 for "chan0")
252 * @test_format: Test name format (e.g. "loopback.\%s.tx.sent")
253 * @test_id: Test id (e.g. "PHYXS" for "loopback.PHYXS.tx_sent")
255 * Fill in an individual self-test entry.
257 static void efx_fill_test(unsigned int test_index, u8 *strings, u64 *data,
258 int *test, const char *unit_format, int unit_id,
259 const char *test_format, const char *test_id)
261 char unit_str[ETH_GSTRING_LEN], test_str[ETH_GSTRING_LEN];
263 /* Fill data value, if applicable */
265 data[test_index] = *test;
267 /* Fill string, if applicable */
269 if (strchr(unit_format, '%'))
270 snprintf(unit_str, sizeof(unit_str),
271 unit_format, unit_id);
273 strcpy(unit_str, unit_format);
274 snprintf(test_str, sizeof(test_str), test_format, test_id);
275 snprintf(strings + test_index * ETH_GSTRING_LEN,
277 "%-6s %-24s", unit_str, test_str);
281 #define EFX_CHANNEL_NAME(_channel) "chan%d", _channel->channel
282 #define EFX_TX_QUEUE_NAME(_tx_queue) "txq%d", _tx_queue->label
283 #define EFX_LOOPBACK_NAME(_mode, _counter) \
284 "loopback.%s." _counter, STRING_TABLE_LOOKUP(_mode, efx_loopback_mode)
287 * efx_fill_loopback_test - fill in a block of loopback self-test entries
289 * @lb_tests: Efx loopback self-test results structure
290 * @mode: Loopback test mode
291 * @test_index: Starting index of the test
292 * @strings: Ethtool strings, or %NULL
293 * @data: Ethtool test results, or %NULL
295 * Fill in a block of loopback self-test entries. Return new test
298 static int efx_fill_loopback_test(struct efx_nic *efx,
299 struct efx_loopback_self_tests *lb_tests,
300 enum efx_loopback_mode mode,
301 unsigned int test_index,
302 u8 *strings, u64 *data)
304 struct efx_channel *channel =
305 efx_get_channel(efx, efx->tx_channel_offset);
306 struct efx_tx_queue *tx_queue;
308 efx_for_each_channel_tx_queue(tx_queue, channel) {
309 efx_fill_test(test_index++, strings, data,
310 &lb_tests->tx_sent[tx_queue->label],
311 EFX_TX_QUEUE_NAME(tx_queue),
312 EFX_LOOPBACK_NAME(mode, "tx_sent"));
313 efx_fill_test(test_index++, strings, data,
314 &lb_tests->tx_done[tx_queue->label],
315 EFX_TX_QUEUE_NAME(tx_queue),
316 EFX_LOOPBACK_NAME(mode, "tx_done"));
318 efx_fill_test(test_index++, strings, data,
321 EFX_LOOPBACK_NAME(mode, "rx_good"));
322 efx_fill_test(test_index++, strings, data,
325 EFX_LOOPBACK_NAME(mode, "rx_bad"));
331 * efx_ethtool_fill_self_tests - get self-test details
333 * @tests: Efx self-test results structure, or %NULL
334 * @strings: Ethtool strings, or %NULL
335 * @data: Ethtool test results, or %NULL
337 * Get self-test number of strings, strings, and/or test results.
338 * Return number of strings (== number of test results).
340 * The reason for merging these three functions is to make sure that
341 * they can never be inconsistent.
343 int efx_ethtool_fill_self_tests(struct efx_nic *efx,
344 struct efx_self_tests *tests,
345 u8 *strings, u64 *data)
347 struct efx_channel *channel;
348 unsigned int n = 0, i;
349 enum efx_loopback_mode mode;
351 efx_fill_test(n++, strings, data, &tests->phy_alive,
352 "phy", 0, "alive", NULL);
353 efx_fill_test(n++, strings, data, &tests->nvram,
354 "core", 0, "nvram", NULL);
355 efx_fill_test(n++, strings, data, &tests->interrupt,
356 "core", 0, "interrupt", NULL);
359 efx_for_each_channel(channel, efx) {
360 efx_fill_test(n++, strings, data,
361 &tests->eventq_dma[channel->channel],
362 EFX_CHANNEL_NAME(channel),
364 efx_fill_test(n++, strings, data,
365 &tests->eventq_int[channel->channel],
366 EFX_CHANNEL_NAME(channel),
370 efx_fill_test(n++, strings, data, &tests->memory,
371 "core", 0, "memory", NULL);
372 efx_fill_test(n++, strings, data, &tests->registers,
373 "core", 0, "registers", NULL);
375 if (efx->phy_op->run_tests != NULL) {
376 EFX_WARN_ON_PARANOID(efx->phy_op->test_name == NULL);
378 for (i = 0; true; ++i) {
381 EFX_WARN_ON_PARANOID(i >= EFX_MAX_PHY_TESTS);
382 name = efx->phy_op->test_name(efx, i);
386 efx_fill_test(n++, strings, data, &tests->phy_ext[i],
387 "phy", 0, name, NULL);
392 for (mode = LOOPBACK_NONE; mode <= LOOPBACK_TEST_MAX; mode++) {
393 if (!(efx->loopback_modes & (1 << mode)))
395 n = efx_fill_loopback_test(efx,
396 &tests->loopback[mode], mode, n,
403 static size_t efx_describe_per_queue_stats(struct efx_nic *efx, u8 *strings)
406 struct efx_channel *channel;
408 efx_for_each_channel(channel, efx) {
409 if (efx_channel_has_tx_queues(channel)) {
411 if (strings != NULL) {
412 snprintf(strings, ETH_GSTRING_LEN,
414 channel->tx_queue[0].queue /
417 strings += ETH_GSTRING_LEN;
421 efx_for_each_channel(channel, efx) {
422 if (efx_channel_has_rx_queue(channel)) {
424 if (strings != NULL) {
425 snprintf(strings, ETH_GSTRING_LEN,
426 "rx-%d.rx_packets", channel->channel);
427 strings += ETH_GSTRING_LEN;
431 if (efx->xdp_tx_queue_count && efx->xdp_tx_queues) {
434 for (xdp = 0; xdp < efx->xdp_tx_queue_count; xdp++) {
437 snprintf(strings, ETH_GSTRING_LEN,
438 "tx-xdp-cpu-%hu.tx_packets", xdp);
439 strings += ETH_GSTRING_LEN;
447 int efx_ethtool_get_sset_count(struct net_device *net_dev, int string_set)
449 struct efx_nic *efx = netdev_priv(net_dev);
451 switch (string_set) {
453 return efx->type->describe_stats(efx, NULL) +
454 EFX_ETHTOOL_SW_STAT_COUNT +
455 efx_describe_per_queue_stats(efx, NULL) +
456 efx_ptp_describe_stats(efx, NULL);
458 return efx_ethtool_fill_self_tests(efx, NULL, NULL, NULL);
464 void efx_ethtool_get_strings(struct net_device *net_dev,
465 u32 string_set, u8 *strings)
467 struct efx_nic *efx = netdev_priv(net_dev);
470 switch (string_set) {
472 strings += (efx->type->describe_stats(efx, strings) *
474 for (i = 0; i < EFX_ETHTOOL_SW_STAT_COUNT; i++)
475 strlcpy(strings + i * ETH_GSTRING_LEN,
476 efx_sw_stat_desc[i].name, ETH_GSTRING_LEN);
477 strings += EFX_ETHTOOL_SW_STAT_COUNT * ETH_GSTRING_LEN;
478 strings += (efx_describe_per_queue_stats(efx, strings) *
480 efx_ptp_describe_stats(efx, strings);
483 efx_ethtool_fill_self_tests(efx, NULL, strings, NULL);
486 /* No other string sets */
491 void efx_ethtool_get_stats(struct net_device *net_dev,
492 struct ethtool_stats *stats,
495 struct efx_nic *efx = netdev_priv(net_dev);
496 const struct efx_sw_stat_desc *stat;
497 struct efx_channel *channel;
498 struct efx_tx_queue *tx_queue;
499 struct efx_rx_queue *rx_queue;
502 spin_lock_bh(&efx->stats_lock);
504 /* Get NIC statistics */
505 data += efx->type->update_stats(efx, data, NULL);
507 /* Get software statistics */
508 for (i = 0; i < EFX_ETHTOOL_SW_STAT_COUNT; i++) {
509 stat = &efx_sw_stat_desc[i];
510 switch (stat->source) {
511 case EFX_ETHTOOL_STAT_SOURCE_nic:
512 data[i] = stat->get_stat((void *)efx + stat->offset);
514 case EFX_ETHTOOL_STAT_SOURCE_channel:
516 efx_for_each_channel(channel, efx)
517 data[i] += stat->get_stat((void *)channel +
520 case EFX_ETHTOOL_STAT_SOURCE_tx_queue:
522 efx_for_each_channel(channel, efx) {
523 efx_for_each_channel_tx_queue(tx_queue, channel)
525 stat->get_stat((void *)tx_queue
531 data += EFX_ETHTOOL_SW_STAT_COUNT;
533 spin_unlock_bh(&efx->stats_lock);
535 efx_for_each_channel(channel, efx) {
536 if (efx_channel_has_tx_queues(channel)) {
538 efx_for_each_channel_tx_queue(tx_queue, channel) {
539 *data += tx_queue->tx_packets;
544 efx_for_each_channel(channel, efx) {
545 if (efx_channel_has_rx_queue(channel)) {
547 efx_for_each_channel_rx_queue(rx_queue, channel) {
548 *data += rx_queue->rx_packets;
553 if (efx->xdp_tx_queue_count && efx->xdp_tx_queues) {
556 for (xdp = 0; xdp < efx->xdp_tx_queue_count; xdp++) {
557 data[0] = efx->xdp_tx_queues[xdp]->tx_packets;
562 efx_ptp_update_stats(efx, data);
565 /* This must be called with rtnl_lock held. */
566 int efx_ethtool_get_link_ksettings(struct net_device *net_dev,
567 struct ethtool_link_ksettings *cmd)
569 struct efx_nic *efx = netdev_priv(net_dev);
570 struct efx_link_state *link_state = &efx->link_state;
573 mutex_lock(&efx->mac_lock);
574 efx->phy_op->get_link_ksettings(efx, cmd);
575 mutex_unlock(&efx->mac_lock);
577 /* Both MACs support pause frames (bidirectional and respond-only) */
578 ethtool_convert_link_mode_to_legacy_u32(&supported,
579 cmd->link_modes.supported);
581 supported |= SUPPORTED_Pause | SUPPORTED_Asym_Pause;
583 ethtool_convert_legacy_u32_to_link_mode(cmd->link_modes.supported,
586 if (LOOPBACK_INTERNAL(efx)) {
587 cmd->base.speed = link_state->speed;
588 cmd->base.duplex = link_state->fd ? DUPLEX_FULL : DUPLEX_HALF;
594 /* This must be called with rtnl_lock held. */
595 int efx_ethtool_set_link_ksettings(struct net_device *net_dev,
596 const struct ethtool_link_ksettings *cmd)
598 struct efx_nic *efx = netdev_priv(net_dev);
601 /* GMAC does not support 1000Mbps HD */
602 if ((cmd->base.speed == SPEED_1000) &&
603 (cmd->base.duplex != DUPLEX_FULL)) {
604 netif_dbg(efx, drv, efx->net_dev,
605 "rejecting unsupported 1000Mbps HD setting\n");
609 mutex_lock(&efx->mac_lock);
610 rc = efx->phy_op->set_link_ksettings(efx, cmd);
611 mutex_unlock(&efx->mac_lock);
615 int efx_ethtool_get_fecparam(struct net_device *net_dev,
616 struct ethtool_fecparam *fecparam)
618 struct efx_nic *efx = netdev_priv(net_dev);
621 if (!efx->phy_op || !efx->phy_op->get_fecparam)
623 mutex_lock(&efx->mac_lock);
624 rc = efx->phy_op->get_fecparam(efx, fecparam);
625 mutex_unlock(&efx->mac_lock);
630 int efx_ethtool_set_fecparam(struct net_device *net_dev,
631 struct ethtool_fecparam *fecparam)
633 struct efx_nic *efx = netdev_priv(net_dev);
636 if (!efx->phy_op || !efx->phy_op->get_fecparam)
638 mutex_lock(&efx->mac_lock);
639 rc = efx->phy_op->set_fecparam(efx, fecparam);
640 mutex_unlock(&efx->mac_lock);
645 /* MAC address mask including only I/G bit */
646 static const u8 mac_addr_ig_mask[ETH_ALEN] __aligned(2) = {0x01, 0, 0, 0, 0, 0};
648 #define IP4_ADDR_FULL_MASK ((__force __be32)~0)
649 #define IP_PROTO_FULL_MASK 0xFF
650 #define PORT_FULL_MASK ((__force __be16)~0)
651 #define ETHER_TYPE_FULL_MASK ((__force __be16)~0)
653 static inline void ip6_fill_mask(__be32 *mask)
655 mask[0] = mask[1] = mask[2] = mask[3] = ~(__be32)0;
658 static int efx_ethtool_get_class_rule(struct efx_nic *efx,
659 struct ethtool_rx_flow_spec *rule,
662 struct ethtool_tcpip4_spec *ip_entry = &rule->h_u.tcp_ip4_spec;
663 struct ethtool_tcpip4_spec *ip_mask = &rule->m_u.tcp_ip4_spec;
664 struct ethtool_usrip4_spec *uip_entry = &rule->h_u.usr_ip4_spec;
665 struct ethtool_usrip4_spec *uip_mask = &rule->m_u.usr_ip4_spec;
666 struct ethtool_tcpip6_spec *ip6_entry = &rule->h_u.tcp_ip6_spec;
667 struct ethtool_tcpip6_spec *ip6_mask = &rule->m_u.tcp_ip6_spec;
668 struct ethtool_usrip6_spec *uip6_entry = &rule->h_u.usr_ip6_spec;
669 struct ethtool_usrip6_spec *uip6_mask = &rule->m_u.usr_ip6_spec;
670 struct ethhdr *mac_entry = &rule->h_u.ether_spec;
671 struct ethhdr *mac_mask = &rule->m_u.ether_spec;
672 struct efx_filter_spec spec;
675 rc = efx_filter_get_filter_safe(efx, EFX_FILTER_PRI_MANUAL,
676 rule->location, &spec);
680 if (spec.dmaq_id == EFX_FILTER_RX_DMAQ_ID_DROP)
681 rule->ring_cookie = RX_CLS_FLOW_DISC;
683 rule->ring_cookie = spec.dmaq_id;
685 if ((spec.match_flags & EFX_FILTER_MATCH_ETHER_TYPE) &&
686 spec.ether_type == htons(ETH_P_IP) &&
687 (spec.match_flags & EFX_FILTER_MATCH_IP_PROTO) &&
688 (spec.ip_proto == IPPROTO_TCP || spec.ip_proto == IPPROTO_UDP) &&
690 ~(EFX_FILTER_MATCH_ETHER_TYPE | EFX_FILTER_MATCH_OUTER_VID |
691 EFX_FILTER_MATCH_LOC_HOST | EFX_FILTER_MATCH_REM_HOST |
692 EFX_FILTER_MATCH_IP_PROTO |
693 EFX_FILTER_MATCH_LOC_PORT | EFX_FILTER_MATCH_REM_PORT))) {
694 rule->flow_type = ((spec.ip_proto == IPPROTO_TCP) ?
695 TCP_V4_FLOW : UDP_V4_FLOW);
696 if (spec.match_flags & EFX_FILTER_MATCH_LOC_HOST) {
697 ip_entry->ip4dst = spec.loc_host[0];
698 ip_mask->ip4dst = IP4_ADDR_FULL_MASK;
700 if (spec.match_flags & EFX_FILTER_MATCH_REM_HOST) {
701 ip_entry->ip4src = spec.rem_host[0];
702 ip_mask->ip4src = IP4_ADDR_FULL_MASK;
704 if (spec.match_flags & EFX_FILTER_MATCH_LOC_PORT) {
705 ip_entry->pdst = spec.loc_port;
706 ip_mask->pdst = PORT_FULL_MASK;
708 if (spec.match_flags & EFX_FILTER_MATCH_REM_PORT) {
709 ip_entry->psrc = spec.rem_port;
710 ip_mask->psrc = PORT_FULL_MASK;
712 } else if ((spec.match_flags & EFX_FILTER_MATCH_ETHER_TYPE) &&
713 spec.ether_type == htons(ETH_P_IPV6) &&
714 (spec.match_flags & EFX_FILTER_MATCH_IP_PROTO) &&
715 (spec.ip_proto == IPPROTO_TCP || spec.ip_proto == IPPROTO_UDP) &&
717 ~(EFX_FILTER_MATCH_ETHER_TYPE | EFX_FILTER_MATCH_OUTER_VID |
718 EFX_FILTER_MATCH_LOC_HOST | EFX_FILTER_MATCH_REM_HOST |
719 EFX_FILTER_MATCH_IP_PROTO |
720 EFX_FILTER_MATCH_LOC_PORT | EFX_FILTER_MATCH_REM_PORT))) {
721 rule->flow_type = ((spec.ip_proto == IPPROTO_TCP) ?
722 TCP_V6_FLOW : UDP_V6_FLOW);
723 if (spec.match_flags & EFX_FILTER_MATCH_LOC_HOST) {
724 memcpy(ip6_entry->ip6dst, spec.loc_host,
725 sizeof(ip6_entry->ip6dst));
726 ip6_fill_mask(ip6_mask->ip6dst);
728 if (spec.match_flags & EFX_FILTER_MATCH_REM_HOST) {
729 memcpy(ip6_entry->ip6src, spec.rem_host,
730 sizeof(ip6_entry->ip6src));
731 ip6_fill_mask(ip6_mask->ip6src);
733 if (spec.match_flags & EFX_FILTER_MATCH_LOC_PORT) {
734 ip6_entry->pdst = spec.loc_port;
735 ip6_mask->pdst = PORT_FULL_MASK;
737 if (spec.match_flags & EFX_FILTER_MATCH_REM_PORT) {
738 ip6_entry->psrc = spec.rem_port;
739 ip6_mask->psrc = PORT_FULL_MASK;
741 } else if (!(spec.match_flags &
742 ~(EFX_FILTER_MATCH_LOC_MAC | EFX_FILTER_MATCH_LOC_MAC_IG |
743 EFX_FILTER_MATCH_REM_MAC | EFX_FILTER_MATCH_ETHER_TYPE |
744 EFX_FILTER_MATCH_OUTER_VID))) {
745 rule->flow_type = ETHER_FLOW;
746 if (spec.match_flags &
747 (EFX_FILTER_MATCH_LOC_MAC | EFX_FILTER_MATCH_LOC_MAC_IG)) {
748 ether_addr_copy(mac_entry->h_dest, spec.loc_mac);
749 if (spec.match_flags & EFX_FILTER_MATCH_LOC_MAC)
750 eth_broadcast_addr(mac_mask->h_dest);
752 ether_addr_copy(mac_mask->h_dest,
755 if (spec.match_flags & EFX_FILTER_MATCH_REM_MAC) {
756 ether_addr_copy(mac_entry->h_source, spec.rem_mac);
757 eth_broadcast_addr(mac_mask->h_source);
759 if (spec.match_flags & EFX_FILTER_MATCH_ETHER_TYPE) {
760 mac_entry->h_proto = spec.ether_type;
761 mac_mask->h_proto = ETHER_TYPE_FULL_MASK;
763 } else if (spec.match_flags & EFX_FILTER_MATCH_ETHER_TYPE &&
764 spec.ether_type == htons(ETH_P_IP) &&
766 ~(EFX_FILTER_MATCH_ETHER_TYPE | EFX_FILTER_MATCH_OUTER_VID |
767 EFX_FILTER_MATCH_LOC_HOST | EFX_FILTER_MATCH_REM_HOST |
768 EFX_FILTER_MATCH_IP_PROTO))) {
769 rule->flow_type = IPV4_USER_FLOW;
770 uip_entry->ip_ver = ETH_RX_NFC_IP4;
771 if (spec.match_flags & EFX_FILTER_MATCH_IP_PROTO) {
772 uip_mask->proto = IP_PROTO_FULL_MASK;
773 uip_entry->proto = spec.ip_proto;
775 if (spec.match_flags & EFX_FILTER_MATCH_LOC_HOST) {
776 uip_entry->ip4dst = spec.loc_host[0];
777 uip_mask->ip4dst = IP4_ADDR_FULL_MASK;
779 if (spec.match_flags & EFX_FILTER_MATCH_REM_HOST) {
780 uip_entry->ip4src = spec.rem_host[0];
781 uip_mask->ip4src = IP4_ADDR_FULL_MASK;
783 } else if (spec.match_flags & EFX_FILTER_MATCH_ETHER_TYPE &&
784 spec.ether_type == htons(ETH_P_IPV6) &&
786 ~(EFX_FILTER_MATCH_ETHER_TYPE | EFX_FILTER_MATCH_OUTER_VID |
787 EFX_FILTER_MATCH_LOC_HOST | EFX_FILTER_MATCH_REM_HOST |
788 EFX_FILTER_MATCH_IP_PROTO))) {
789 rule->flow_type = IPV6_USER_FLOW;
790 if (spec.match_flags & EFX_FILTER_MATCH_IP_PROTO) {
791 uip6_mask->l4_proto = IP_PROTO_FULL_MASK;
792 uip6_entry->l4_proto = spec.ip_proto;
794 if (spec.match_flags & EFX_FILTER_MATCH_LOC_HOST) {
795 memcpy(uip6_entry->ip6dst, spec.loc_host,
796 sizeof(uip6_entry->ip6dst));
797 ip6_fill_mask(uip6_mask->ip6dst);
799 if (spec.match_flags & EFX_FILTER_MATCH_REM_HOST) {
800 memcpy(uip6_entry->ip6src, spec.rem_host,
801 sizeof(uip6_entry->ip6src));
802 ip6_fill_mask(uip6_mask->ip6src);
805 /* The above should handle all filters that we insert */
810 if (spec.match_flags & EFX_FILTER_MATCH_OUTER_VID) {
811 rule->flow_type |= FLOW_EXT;
812 rule->h_ext.vlan_tci = spec.outer_vid;
813 rule->m_ext.vlan_tci = htons(0xfff);
816 if (spec.flags & EFX_FILTER_FLAG_RX_RSS) {
817 rule->flow_type |= FLOW_RSS;
818 *rss_context = spec.rss_context;
824 int efx_ethtool_get_rxnfc(struct net_device *net_dev,
825 struct ethtool_rxnfc *info, u32 *rule_locs)
827 struct efx_nic *efx = netdev_priv(net_dev);
832 case ETHTOOL_GRXRINGS:
833 info->data = efx->n_rx_channels;
836 case ETHTOOL_GRXFH: {
837 struct efx_rss_context *ctx = &efx->rss_context;
840 mutex_lock(&efx->rss_lock);
841 if (info->flow_type & FLOW_RSS && info->rss_context) {
842 ctx = efx_find_rss_context_entry(efx, info->rss_context);
850 if (!efx_rss_active(ctx)) /* No RSS */
851 goto out_setdata_unlock;
853 switch (info->flow_type & ~FLOW_RSS) {
856 if (ctx->rx_hash_udp_4tuple)
857 data = (RXH_L4_B_0_1 | RXH_L4_B_2_3 |
858 RXH_IP_SRC | RXH_IP_DST);
860 data = RXH_IP_SRC | RXH_IP_DST;
864 data = (RXH_L4_B_0_1 | RXH_L4_B_2_3 |
865 RXH_IP_SRC | RXH_IP_DST);
873 data = RXH_IP_SRC | RXH_IP_DST;
881 mutex_unlock(&efx->rss_lock);
885 case ETHTOOL_GRXCLSRLCNT:
886 info->data = efx_filter_get_rx_id_limit(efx);
889 info->data |= RX_CLS_LOC_SPECIAL;
891 efx_filter_count_rx_used(efx, EFX_FILTER_PRI_MANUAL);
894 case ETHTOOL_GRXCLSRULE:
895 if (efx_filter_get_rx_id_limit(efx) == 0)
897 rc = efx_ethtool_get_class_rule(efx, &info->fs, &rss_context);
900 if (info->fs.flow_type & FLOW_RSS)
901 info->rss_context = rss_context;
904 case ETHTOOL_GRXCLSRLALL:
905 info->data = efx_filter_get_rx_id_limit(efx);
908 rc = efx_filter_get_rx_ids(efx, EFX_FILTER_PRI_MANUAL,
909 rule_locs, info->rule_cnt);
920 static inline bool ip6_mask_is_full(__be32 mask[4])
922 return !~(mask[0] & mask[1] & mask[2] & mask[3]);
925 static inline bool ip6_mask_is_empty(__be32 mask[4])
927 return !(mask[0] | mask[1] | mask[2] | mask[3]);
930 static int efx_ethtool_set_class_rule(struct efx_nic *efx,
931 struct ethtool_rx_flow_spec *rule,
934 struct ethtool_tcpip4_spec *ip_entry = &rule->h_u.tcp_ip4_spec;
935 struct ethtool_tcpip4_spec *ip_mask = &rule->m_u.tcp_ip4_spec;
936 struct ethtool_usrip4_spec *uip_entry = &rule->h_u.usr_ip4_spec;
937 struct ethtool_usrip4_spec *uip_mask = &rule->m_u.usr_ip4_spec;
938 struct ethtool_tcpip6_spec *ip6_entry = &rule->h_u.tcp_ip6_spec;
939 struct ethtool_tcpip6_spec *ip6_mask = &rule->m_u.tcp_ip6_spec;
940 struct ethtool_usrip6_spec *uip6_entry = &rule->h_u.usr_ip6_spec;
941 struct ethtool_usrip6_spec *uip6_mask = &rule->m_u.usr_ip6_spec;
942 u32 flow_type = rule->flow_type & ~(FLOW_EXT | FLOW_RSS);
943 struct ethhdr *mac_entry = &rule->h_u.ether_spec;
944 struct ethhdr *mac_mask = &rule->m_u.ether_spec;
945 enum efx_filter_flags flags = 0;
946 struct efx_filter_spec spec;
949 /* Check that user wants us to choose the location */
950 if (rule->location != RX_CLS_LOC_ANY)
953 /* Range-check ring_cookie */
954 if (rule->ring_cookie >= efx->n_rx_channels &&
955 rule->ring_cookie != RX_CLS_FLOW_DISC)
958 /* Check for unsupported extensions */
959 if ((rule->flow_type & FLOW_EXT) &&
960 (rule->m_ext.vlan_etype || rule->m_ext.data[0] ||
961 rule->m_ext.data[1]))
965 flags |= EFX_FILTER_FLAG_RX_SCATTER;
966 if (rule->flow_type & FLOW_RSS)
967 flags |= EFX_FILTER_FLAG_RX_RSS;
969 efx_filter_init_rx(&spec, EFX_FILTER_PRI_MANUAL, flags,
970 (rule->ring_cookie == RX_CLS_FLOW_DISC) ?
971 EFX_FILTER_RX_DMAQ_ID_DROP : rule->ring_cookie);
973 if (rule->flow_type & FLOW_RSS)
974 spec.rss_context = rss_context;
979 spec.match_flags = (EFX_FILTER_MATCH_ETHER_TYPE |
980 EFX_FILTER_MATCH_IP_PROTO);
981 spec.ether_type = htons(ETH_P_IP);
982 spec.ip_proto = flow_type == TCP_V4_FLOW ? IPPROTO_TCP
984 if (ip_mask->ip4dst) {
985 if (ip_mask->ip4dst != IP4_ADDR_FULL_MASK)
987 spec.match_flags |= EFX_FILTER_MATCH_LOC_HOST;
988 spec.loc_host[0] = ip_entry->ip4dst;
990 if (ip_mask->ip4src) {
991 if (ip_mask->ip4src != IP4_ADDR_FULL_MASK)
993 spec.match_flags |= EFX_FILTER_MATCH_REM_HOST;
994 spec.rem_host[0] = ip_entry->ip4src;
997 if (ip_mask->pdst != PORT_FULL_MASK)
999 spec.match_flags |= EFX_FILTER_MATCH_LOC_PORT;
1000 spec.loc_port = ip_entry->pdst;
1002 if (ip_mask->psrc) {
1003 if (ip_mask->psrc != PORT_FULL_MASK)
1005 spec.match_flags |= EFX_FILTER_MATCH_REM_PORT;
1006 spec.rem_port = ip_entry->psrc;
1014 spec.match_flags = (EFX_FILTER_MATCH_ETHER_TYPE |
1015 EFX_FILTER_MATCH_IP_PROTO);
1016 spec.ether_type = htons(ETH_P_IPV6);
1017 spec.ip_proto = flow_type == TCP_V6_FLOW ? IPPROTO_TCP
1019 if (!ip6_mask_is_empty(ip6_mask->ip6dst)) {
1020 if (!ip6_mask_is_full(ip6_mask->ip6dst))
1022 spec.match_flags |= EFX_FILTER_MATCH_LOC_HOST;
1023 memcpy(spec.loc_host, ip6_entry->ip6dst, sizeof(spec.loc_host));
1025 if (!ip6_mask_is_empty(ip6_mask->ip6src)) {
1026 if (!ip6_mask_is_full(ip6_mask->ip6src))
1028 spec.match_flags |= EFX_FILTER_MATCH_REM_HOST;
1029 memcpy(spec.rem_host, ip6_entry->ip6src, sizeof(spec.rem_host));
1031 if (ip6_mask->pdst) {
1032 if (ip6_mask->pdst != PORT_FULL_MASK)
1034 spec.match_flags |= EFX_FILTER_MATCH_LOC_PORT;
1035 spec.loc_port = ip6_entry->pdst;
1037 if (ip6_mask->psrc) {
1038 if (ip6_mask->psrc != PORT_FULL_MASK)
1040 spec.match_flags |= EFX_FILTER_MATCH_REM_PORT;
1041 spec.rem_port = ip6_entry->psrc;
1043 if (ip6_mask->tclass)
1047 case IPV4_USER_FLOW:
1048 if (uip_mask->l4_4_bytes || uip_mask->tos || uip_mask->ip_ver ||
1049 uip_entry->ip_ver != ETH_RX_NFC_IP4)
1051 spec.match_flags = EFX_FILTER_MATCH_ETHER_TYPE;
1052 spec.ether_type = htons(ETH_P_IP);
1053 if (uip_mask->ip4dst) {
1054 if (uip_mask->ip4dst != IP4_ADDR_FULL_MASK)
1056 spec.match_flags |= EFX_FILTER_MATCH_LOC_HOST;
1057 spec.loc_host[0] = uip_entry->ip4dst;
1059 if (uip_mask->ip4src) {
1060 if (uip_mask->ip4src != IP4_ADDR_FULL_MASK)
1062 spec.match_flags |= EFX_FILTER_MATCH_REM_HOST;
1063 spec.rem_host[0] = uip_entry->ip4src;
1065 if (uip_mask->proto) {
1066 if (uip_mask->proto != IP_PROTO_FULL_MASK)
1068 spec.match_flags |= EFX_FILTER_MATCH_IP_PROTO;
1069 spec.ip_proto = uip_entry->proto;
1073 case IPV6_USER_FLOW:
1074 if (uip6_mask->l4_4_bytes || uip6_mask->tclass)
1076 spec.match_flags = EFX_FILTER_MATCH_ETHER_TYPE;
1077 spec.ether_type = htons(ETH_P_IPV6);
1078 if (!ip6_mask_is_empty(uip6_mask->ip6dst)) {
1079 if (!ip6_mask_is_full(uip6_mask->ip6dst))
1081 spec.match_flags |= EFX_FILTER_MATCH_LOC_HOST;
1082 memcpy(spec.loc_host, uip6_entry->ip6dst, sizeof(spec.loc_host));
1084 if (!ip6_mask_is_empty(uip6_mask->ip6src)) {
1085 if (!ip6_mask_is_full(uip6_mask->ip6src))
1087 spec.match_flags |= EFX_FILTER_MATCH_REM_HOST;
1088 memcpy(spec.rem_host, uip6_entry->ip6src, sizeof(spec.rem_host));
1090 if (uip6_mask->l4_proto) {
1091 if (uip6_mask->l4_proto != IP_PROTO_FULL_MASK)
1093 spec.match_flags |= EFX_FILTER_MATCH_IP_PROTO;
1094 spec.ip_proto = uip6_entry->l4_proto;
1099 if (!is_zero_ether_addr(mac_mask->h_dest)) {
1100 if (ether_addr_equal(mac_mask->h_dest,
1102 spec.match_flags |= EFX_FILTER_MATCH_LOC_MAC_IG;
1103 else if (is_broadcast_ether_addr(mac_mask->h_dest))
1104 spec.match_flags |= EFX_FILTER_MATCH_LOC_MAC;
1107 ether_addr_copy(spec.loc_mac, mac_entry->h_dest);
1109 if (!is_zero_ether_addr(mac_mask->h_source)) {
1110 if (!is_broadcast_ether_addr(mac_mask->h_source))
1112 spec.match_flags |= EFX_FILTER_MATCH_REM_MAC;
1113 ether_addr_copy(spec.rem_mac, mac_entry->h_source);
1115 if (mac_mask->h_proto) {
1116 if (mac_mask->h_proto != ETHER_TYPE_FULL_MASK)
1118 spec.match_flags |= EFX_FILTER_MATCH_ETHER_TYPE;
1119 spec.ether_type = mac_entry->h_proto;
1127 if ((rule->flow_type & FLOW_EXT) && rule->m_ext.vlan_tci) {
1128 if (rule->m_ext.vlan_tci != htons(0xfff))
1130 spec.match_flags |= EFX_FILTER_MATCH_OUTER_VID;
1131 spec.outer_vid = rule->h_ext.vlan_tci;
1134 rc = efx_filter_insert_filter(efx, &spec, true);
1138 rule->location = rc;
1142 int efx_ethtool_set_rxnfc(struct net_device *net_dev,
1143 struct ethtool_rxnfc *info)
1145 struct efx_nic *efx = netdev_priv(net_dev);
1147 if (efx_filter_get_rx_id_limit(efx) == 0)
1150 switch (info->cmd) {
1151 case ETHTOOL_SRXCLSRLINS:
1152 return efx_ethtool_set_class_rule(efx, &info->fs,
1155 case ETHTOOL_SRXCLSRLDEL:
1156 return efx_filter_remove_id_safe(efx, EFX_FILTER_PRI_MANUAL,
1164 u32 efx_ethtool_get_rxfh_indir_size(struct net_device *net_dev)
1166 struct efx_nic *efx = netdev_priv(net_dev);
1168 if (efx->n_rx_channels == 1)
1170 return ARRAY_SIZE(efx->rss_context.rx_indir_table);
1173 u32 efx_ethtool_get_rxfh_key_size(struct net_device *net_dev)
1175 struct efx_nic *efx = netdev_priv(net_dev);
1177 return efx->type->rx_hash_key_size;
1180 int efx_ethtool_get_rxfh(struct net_device *net_dev, u32 *indir, u8 *key,
1183 struct efx_nic *efx = netdev_priv(net_dev);
1186 rc = efx->type->rx_pull_rss_config(efx);
1191 *hfunc = ETH_RSS_HASH_TOP;
1193 memcpy(indir, efx->rss_context.rx_indir_table,
1194 sizeof(efx->rss_context.rx_indir_table));
1196 memcpy(key, efx->rss_context.rx_hash_key,
1197 efx->type->rx_hash_key_size);
1201 int efx_ethtool_set_rxfh(struct net_device *net_dev, const u32 *indir,
1202 const u8 *key, const u8 hfunc)
1204 struct efx_nic *efx = netdev_priv(net_dev);
1206 /* Hash function is Toeplitz, cannot be changed */
1207 if (hfunc != ETH_RSS_HASH_NO_CHANGE && hfunc != ETH_RSS_HASH_TOP)
1213 key = efx->rss_context.rx_hash_key;
1215 indir = efx->rss_context.rx_indir_table;
1217 return efx->type->rx_push_rss_config(efx, true, indir, key);
1220 int efx_ethtool_get_rxfh_context(struct net_device *net_dev, u32 *indir,
1221 u8 *key, u8 *hfunc, u32 rss_context)
1223 struct efx_nic *efx = netdev_priv(net_dev);
1224 struct efx_rss_context *ctx;
1227 if (!efx->type->rx_pull_rss_context_config)
1230 mutex_lock(&efx->rss_lock);
1231 ctx = efx_find_rss_context_entry(efx, rss_context);
1236 rc = efx->type->rx_pull_rss_context_config(efx, ctx);
1241 *hfunc = ETH_RSS_HASH_TOP;
1243 memcpy(indir, ctx->rx_indir_table, sizeof(ctx->rx_indir_table));
1245 memcpy(key, ctx->rx_hash_key, efx->type->rx_hash_key_size);
1247 mutex_unlock(&efx->rss_lock);
1251 int efx_ethtool_set_rxfh_context(struct net_device *net_dev,
1252 const u32 *indir, const u8 *key,
1253 const u8 hfunc, u32 *rss_context,
1256 struct efx_nic *efx = netdev_priv(net_dev);
1257 struct efx_rss_context *ctx;
1258 bool allocated = false;
1261 if (!efx->type->rx_push_rss_context_config)
1263 /* Hash function is Toeplitz, cannot be changed */
1264 if (hfunc != ETH_RSS_HASH_NO_CHANGE && hfunc != ETH_RSS_HASH_TOP)
1267 mutex_lock(&efx->rss_lock);
1269 if (*rss_context == ETH_RXFH_CONTEXT_ALLOC) {
1271 /* alloc + delete == Nothing to do */
1275 ctx = efx_alloc_rss_context_entry(efx);
1280 ctx->context_id = EFX_MCDI_RSS_CONTEXT_INVALID;
1281 /* Initialise indir table and key to defaults */
1282 efx_set_default_rx_indir_table(efx, ctx);
1283 netdev_rss_key_fill(ctx->rx_hash_key, sizeof(ctx->rx_hash_key));
1286 ctx = efx_find_rss_context_entry(efx, *rss_context);
1294 /* delete this context */
1295 rc = efx->type->rx_push_rss_context_config(efx, ctx, NULL, NULL);
1297 efx_free_rss_context_entry(ctx);
1302 key = ctx->rx_hash_key;
1304 indir = ctx->rx_indir_table;
1306 rc = efx->type->rx_push_rss_context_config(efx, ctx, indir, key);
1307 if (rc && allocated)
1308 efx_free_rss_context_entry(ctx);
1310 *rss_context = ctx->user_id;
1312 mutex_unlock(&efx->rss_lock);
1316 int efx_ethtool_reset(struct net_device *net_dev, u32 *flags)
1318 struct efx_nic *efx = netdev_priv(net_dev);
1321 rc = efx->type->map_reset_flags(flags);
1325 return efx_reset(efx, rc);
1328 int efx_ethtool_get_module_eeprom(struct net_device *net_dev,
1329 struct ethtool_eeprom *ee,
1332 struct efx_nic *efx = netdev_priv(net_dev);
1335 if (!efx->phy_op || !efx->phy_op->get_module_eeprom)
1338 mutex_lock(&efx->mac_lock);
1339 ret = efx->phy_op->get_module_eeprom(efx, ee, data);
1340 mutex_unlock(&efx->mac_lock);
1345 int efx_ethtool_get_module_info(struct net_device *net_dev,
1346 struct ethtool_modinfo *modinfo)
1348 struct efx_nic *efx = netdev_priv(net_dev);
1351 if (!efx->phy_op || !efx->phy_op->get_module_info)
1354 mutex_lock(&efx->mac_lock);
1355 ret = efx->phy_op->get_module_info(efx, modinfo);
1356 mutex_unlock(&efx->mac_lock);