| 1 |
// SPDX-License-Identifier: GPL-2.0-only |
| 2 |
/**************************************************************************** |
| 3 |
* Driver for Solarflare network controllers and boards |
| 4 |
* Copyright 2019 Solarflare Communications Inc. |
| 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 |
#include <linux/module.h> |
| 11 |
#include <linux/netdevice.h> |
| 12 |
#include "net_driver.h" |
| 13 |
#include "mcdi.h" |
| 14 |
#include "nic.h" |
| 15 |
#include "selftest.h" |
| 16 |
#include "rx_common.h" |
| 17 |
#include "ethtool_common.h" |
| 18 |
#include "mcdi_port_common.h" |
| 19 |
|
| 20 |
struct efx_sw_stat_desc { |
| 21 |
const char *name; |
| 22 |
enum { |
| 23 |
EFX_ETHTOOL_STAT_SOURCE_nic, |
| 24 |
EFX_ETHTOOL_STAT_SOURCE_channel, |
| 25 |
EFX_ETHTOOL_STAT_SOURCE_tx_queue |
| 26 |
} source; |
| 27 |
unsigned int offset; |
| 28 |
u64 (*get_stat)(void *field); /* Reader function */ |
| 29 |
}; |
| 30 |
|
| 31 |
/* Initialiser for a struct efx_sw_stat_desc with type-checking */ |
| 32 |
#define EFX_ETHTOOL_STAT(stat_name, source_name, field, field_type, \ |
| 33 |
get_stat_function) { \ |
| 34 |
.name = #stat_name, \ |
| 35 |
.source = EFX_ETHTOOL_STAT_SOURCE_##source_name, \ |
| 36 |
.offset = ((((field_type *) 0) == \ |
| 37 |
&((struct efx_##source_name *)0)->field) ? \ |
| 38 |
offsetof(struct efx_##source_name, field) : \ |
| 39 |
offsetof(struct efx_##source_name, field)), \ |
| 40 |
.get_stat = get_stat_function, \ |
| 41 |
} |
| 42 |
|
| 43 |
static u64 efx_get_uint_stat(void *field) |
| 44 |
{ |
| 45 |
return *(unsigned int *)field; |
| 46 |
} |
| 47 |
|
| 48 |
static u64 efx_get_atomic_stat(void *field) |
| 49 |
{ |
| 50 |
return atomic_read((atomic_t *) field); |
| 51 |
} |
| 52 |
|
| 53 |
#define EFX_ETHTOOL_ATOMIC_NIC_ERROR_STAT(field) \ |
| 54 |
EFX_ETHTOOL_STAT(field, nic, field, \ |
| 55 |
atomic_t, efx_get_atomic_stat) |
| 56 |
|
| 57 |
#define EFX_ETHTOOL_UINT_CHANNEL_STAT(field) \ |
| 58 |
EFX_ETHTOOL_STAT(field, channel, n_##field, \ |
| 59 |
unsigned int, efx_get_uint_stat) |
| 60 |
#define EFX_ETHTOOL_UINT_CHANNEL_STAT_NO_N(field) \ |
| 61 |
EFX_ETHTOOL_STAT(field, channel, field, \ |
| 62 |
unsigned int, efx_get_uint_stat) |
| 63 |
|
| 64 |
#define EFX_ETHTOOL_UINT_TXQ_STAT(field) \ |
| 65 |
EFX_ETHTOOL_STAT(tx_##field, tx_queue, field, \ |
| 66 |
unsigned int, efx_get_uint_stat) |
| 67 |
|
| 68 |
static const struct efx_sw_stat_desc efx_sw_stat_desc[] = { |
| 69 |
EFX_ETHTOOL_UINT_TXQ_STAT(merge_events), |
| 70 |
EFX_ETHTOOL_UINT_TXQ_STAT(tso_bursts), |
| 71 |
EFX_ETHTOOL_UINT_TXQ_STAT(tso_long_headers), |
| 72 |
EFX_ETHTOOL_UINT_TXQ_STAT(tso_packets), |
| 73 |
EFX_ETHTOOL_UINT_TXQ_STAT(tso_fallbacks), |
| 74 |
EFX_ETHTOOL_UINT_TXQ_STAT(pushes), |
| 75 |
EFX_ETHTOOL_UINT_TXQ_STAT(pio_packets), |
| 76 |
EFX_ETHTOOL_UINT_TXQ_STAT(cb_packets), |
| 77 |
EFX_ETHTOOL_ATOMIC_NIC_ERROR_STAT(rx_reset), |
| 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_frm_trunc), |
| 86 |
EFX_ETHTOOL_UINT_CHANNEL_STAT(rx_overlength), |
| 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 |
EFX_ETHTOOL_UINT_CHANNEL_STAT(rx_mport_bad), |
| 94 |
#ifdef CONFIG_RFS_ACCEL |
| 95 |
EFX_ETHTOOL_UINT_CHANNEL_STAT_NO_N(rfs_filter_count), |
| 96 |
EFX_ETHTOOL_UINT_CHANNEL_STAT(rfs_succeeded), |
| 97 |
EFX_ETHTOOL_UINT_CHANNEL_STAT(rfs_failed), |
| 98 |
#endif |
| 99 |
}; |
| 100 |
|
| 101 |
#define EFX_ETHTOOL_SW_STAT_COUNT ARRAY_SIZE(efx_sw_stat_desc) |
| 102 |
|
| 103 |
void efx_ethtool_get_drvinfo(struct net_device *net_dev, |
| 104 |
struct ethtool_drvinfo *info) |
| 105 |
{ |
| 106 |
struct efx_nic *efx = efx_netdev_priv(net_dev); |
| 107 |
|
| 108 |
strscpy(info->driver, KBUILD_MODNAME, sizeof(info->driver)); |
| 109 |
efx_mcdi_print_fwver(efx, info->fw_version, |
| 110 |
sizeof(info->fw_version)); |
| 111 |
strscpy(info->bus_info, pci_name(efx->pci_dev), sizeof(info->bus_info)); |
| 112 |
} |
| 113 |
|
| 114 |
u32 efx_ethtool_get_msglevel(struct net_device *net_dev) |
| 115 |
{ |
| 116 |
struct efx_nic *efx = efx_netdev_priv(net_dev); |
| 117 |
|
| 118 |
return efx->msg_enable; |
| 119 |
} |
| 120 |
|
| 121 |
void efx_ethtool_set_msglevel(struct net_device *net_dev, u32 msg_enable) |
| 122 |
{ |
| 123 |
struct efx_nic *efx = efx_netdev_priv(net_dev); |
| 124 |
|
| 125 |
efx->msg_enable = msg_enable; |
| 126 |
} |
| 127 |
|
| 128 |
void efx_ethtool_self_test(struct net_device *net_dev, |
| 129 |
struct ethtool_test *test, u64 *data) |
| 130 |
{ |
| 131 |
struct efx_nic *efx = efx_netdev_priv(net_dev); |
| 132 |
struct efx_self_tests *efx_tests; |
| 133 |
bool already_up; |
| 134 |
int rc = -ENOMEM; |
| 135 |
|
| 136 |
efx_tests = kzalloc_obj(*efx_tests); |
| 137 |
if (!efx_tests) |
| 138 |
goto fail; |
| 139 |
|
| 140 |
if (!efx_net_active(efx->state)) { |
| 141 |
rc = -EBUSY; |
| 142 |
goto out; |
| 143 |
} |
| 144 |
|
| 145 |
netif_info(efx, drv, efx->net_dev, "starting %sline testing\n", |
| 146 |
(test->flags & ETH_TEST_FL_OFFLINE) ? "off" : "on"); |
| 147 |
|
| 148 |
/* We need rx buffers and interrupts. */ |
| 149 |
already_up = (efx->net_dev->flags & IFF_UP); |
| 150 |
if (!already_up) { |
| 151 |
rc = dev_open(efx->net_dev, NULL); |
| 152 |
if (rc) { |
| 153 |
netif_err(efx, drv, efx->net_dev, |
| 154 |
"failed opening device.\n"); |
| 155 |
goto out; |
| 156 |
} |
| 157 |
} |
| 158 |
|
| 159 |
rc = efx_selftest(efx, efx_tests, test->flags); |
| 160 |
|
| 161 |
if (!already_up) |
| 162 |
dev_close(efx->net_dev); |
| 163 |
|
| 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"); |
| 167 |
|
| 168 |
out: |
| 169 |
efx_ethtool_fill_self_tests(efx, efx_tests, NULL, data); |
| 170 |
kfree(efx_tests); |
| 171 |
fail: |
| 172 |
if (rc) |
| 173 |
test->flags |= ETH_TEST_FL_FAILED; |
| 174 |
} |
| 175 |
|
| 176 |
void efx_ethtool_get_pauseparam(struct net_device *net_dev, |
| 177 |
struct ethtool_pauseparam *pause) |
| 178 |
{ |
| 179 |
struct efx_nic *efx = efx_netdev_priv(net_dev); |
| 180 |
|
| 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); |
| 184 |
} |
| 185 |
|
| 186 |
int efx_ethtool_set_pauseparam(struct net_device *net_dev, |
| 187 |
struct ethtool_pauseparam *pause) |
| 188 |
{ |
| 189 |
struct efx_nic *efx = efx_netdev_priv(net_dev); |
| 190 |
u8 wanted_fc, old_fc; |
| 191 |
u32 old_adv; |
| 192 |
int rc = 0; |
| 193 |
|
| 194 |
mutex_lock(&efx->mac_lock); |
| 195 |
|
| 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)); |
| 199 |
|
| 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"); |
| 203 |
rc = -EINVAL; |
| 204 |
goto out; |
| 205 |
} |
| 206 |
|
| 207 |
if ((wanted_fc & EFX_FC_AUTO) && !efx->link_advertising[0]) { |
| 208 |
netif_dbg(efx, drv, efx->net_dev, |
| 209 |
"Autonegotiation is disabled\n"); |
| 210 |
rc = -EINVAL; |
| 211 |
goto out; |
| 212 |
} |
| 213 |
|
| 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); |
| 218 |
|
| 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_mcdi_port_reconfigure(efx); |
| 225 |
if (rc) { |
| 226 |
netif_err(efx, drv, efx->net_dev, |
| 227 |
"Unable to advertise requested flow " |
| 228 |
"control setting\n"); |
| 229 |
goto out; |
| 230 |
} |
| 231 |
} |
| 232 |
|
| 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); |
| 237 |
|
| 238 |
out: |
| 239 |
mutex_unlock(&efx->mac_lock); |
| 240 |
|
| 241 |
return rc; |
| 242 |
} |
| 243 |
|
| 244 |
/** |
| 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") |
| 254 |
* |
| 255 |
* Fill in an individual self-test entry. |
| 256 |
*/ |
| 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) |
| 260 |
{ |
| 261 |
char unit_str[ETH_GSTRING_LEN], test_str[ETH_GSTRING_LEN]; |
| 262 |
|
| 263 |
/* Fill data value, if applicable */ |
| 264 |
if (data) |
| 265 |
data[test_index] = *test; |
| 266 |
|
| 267 |
/* Fill string, if applicable */ |
| 268 |
if (strings) { |
| 269 |
if (strchr(unit_format, '%')) |
| 270 |
snprintf(unit_str, sizeof(unit_str), |
| 271 |
unit_format, unit_id); |
| 272 |
else |
| 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, |
| 276 |
ETH_GSTRING_LEN, |
| 277 |
"%-6s %-24s", unit_str, test_str); |
| 278 |
} |
| 279 |
} |
| 280 |
|
| 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) |
| 285 |
|
| 286 |
/** |
| 287 |
* efx_fill_loopback_test - fill in a block of loopback self-test entries |
| 288 |
* @efx: Efx NIC |
| 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 |
| 294 |
* |
| 295 |
* Fill in a block of loopback self-test entries. Return new test |
| 296 |
* index. |
| 297 |
*/ |
| 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) |
| 303 |
{ |
| 304 |
struct efx_channel *channel = |
| 305 |
efx_get_channel(efx, efx->tx_channel_offset); |
| 306 |
struct efx_tx_queue *tx_queue; |
| 307 |
|
| 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")); |
| 317 |
} |
| 318 |
efx_fill_test(test_index++, strings, data, |
| 319 |
&lb_tests->rx_good, |
| 320 |
"rx", 0, |
| 321 |
EFX_LOOPBACK_NAME(mode, "rx_good")); |
| 322 |
efx_fill_test(test_index++, strings, data, |
| 323 |
&lb_tests->rx_bad, |
| 324 |
"rx", 0, |
| 325 |
EFX_LOOPBACK_NAME(mode, "rx_bad")); |
| 326 |
|
| 327 |
return test_index; |
| 328 |
} |
| 329 |
|
| 330 |
/** |
| 331 |
* efx_ethtool_fill_self_tests - get self-test details |
| 332 |
* @efx: Efx NIC |
| 333 |
* @tests: Efx self-test results structure, or %NULL |
| 334 |
* @strings: Ethtool strings, or %NULL |
| 335 |
* @data: Ethtool test results, or %NULL |
| 336 |
* |
| 337 |
* Get self-test number of strings, strings, and/or test results. |
| 338 |
* Return number of strings (== number of test results). |
| 339 |
* |
| 340 |
* The reason for merging these three functions is to make sure that |
| 341 |
* they can never be inconsistent. |
| 342 |
*/ |
| 343 |
int efx_ethtool_fill_self_tests(struct efx_nic *efx, |
| 344 |
struct efx_self_tests *tests, |
| 345 |
u8 *strings, u64 *data) |
| 346 |
{ |
| 347 |
struct efx_channel *channel; |
| 348 |
unsigned int n = 0, i; |
| 349 |
enum efx_loopback_mode mode; |
| 350 |
|
| 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); |
| 357 |
|
| 358 |
/* Event queues */ |
| 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), |
| 363 |
"eventq.dma", NULL); |
| 364 |
efx_fill_test(n++, strings, data, |
| 365 |
&tests->eventq_int[channel->channel], |
| 366 |
EFX_CHANNEL_NAME(channel), |
| 367 |
"eventq.int", NULL); |
| 368 |
} |
| 369 |
|
| 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); |
| 374 |
|
| 375 |
for (i = 0; true; ++i) { |
| 376 |
const char *name; |
| 377 |
|
| 378 |
EFX_WARN_ON_PARANOID(i >= EFX_MAX_PHY_TESTS); |
| 379 |
name = efx_mcdi_phy_test_name(efx, i); |
| 380 |
if (name == NULL) |
| 381 |
break; |
| 382 |
|
| 383 |
efx_fill_test(n++, strings, data, &tests->phy_ext[i], "phy", 0, name, NULL); |
| 384 |
} |
| 385 |
|
| 386 |
/* Loopback tests */ |
| 387 |
for (mode = LOOPBACK_NONE; mode <= LOOPBACK_TEST_MAX; mode++) { |
| 388 |
if (!(efx->loopback_modes & (1 << mode))) |
| 389 |
continue; |
| 390 |
n = efx_fill_loopback_test(efx, |
| 391 |
&tests->loopback[mode], mode, n, |
| 392 |
strings, data); |
| 393 |
} |
| 394 |
|
| 395 |
return n; |
| 396 |
} |
| 397 |
|
| 398 |
static size_t efx_describe_per_queue_stats(struct efx_nic *efx, u8 **strings) |
| 399 |
{ |
| 400 |
size_t n_stats = 0; |
| 401 |
struct efx_channel *channel; |
| 402 |
|
| 403 |
efx_for_each_channel(channel, efx) { |
| 404 |
if (efx_channel_has_tx_queues(channel)) { |
| 405 |
n_stats++; |
| 406 |
if (!strings) |
| 407 |
continue; |
| 408 |
|
| 409 |
ethtool_sprintf(strings, "tx-%u.tx_packets", |
| 410 |
channel->tx_queue[0].queue / |
| 411 |
EFX_MAX_TXQ_PER_CHANNEL); |
| 412 |
} |
| 413 |
} |
| 414 |
efx_for_each_channel(channel, efx) { |
| 415 |
if (efx_channel_has_rx_queue(channel)) { |
| 416 |
n_stats++; |
| 417 |
if (!strings) |
| 418 |
continue; |
| 419 |
|
| 420 |
ethtool_sprintf(strings, "rx-%d.rx_packets", |
| 421 |
channel->channel); |
| 422 |
} |
| 423 |
} |
| 424 |
if (efx->xdp_tx_queue_count && efx->xdp_tx_queues) { |
| 425 |
unsigned short xdp; |
| 426 |
|
| 427 |
for (xdp = 0; xdp < efx->xdp_tx_queue_count; xdp++) { |
| 428 |
n_stats++; |
| 429 |
if (!strings) |
| 430 |
continue; |
| 431 |
|
| 432 |
ethtool_sprintf(strings, "tx-xdp-cpu-%hu.tx_packets", |
| 433 |
xdp); |
| 434 |
} |
| 435 |
} |
| 436 |
|
| 437 |
return n_stats; |
| 438 |
} |
| 439 |
|
| 440 |
int efx_ethtool_get_sset_count(struct net_device *net_dev, int string_set) |
| 441 |
{ |
| 442 |
struct efx_nic *efx = efx_netdev_priv(net_dev); |
| 443 |
|
| 444 |
switch (string_set) { |
| 445 |
case ETH_SS_STATS: |
| 446 |
return efx->type->describe_stats(efx, NULL) + |
| 447 |
EFX_ETHTOOL_SW_STAT_COUNT + |
| 448 |
efx_describe_per_queue_stats(efx, NULL) + |
| 449 |
efx_ptp_describe_stats(efx, NULL); |
| 450 |
case ETH_SS_TEST: |
| 451 |
return efx_ethtool_fill_self_tests(efx, NULL, NULL, NULL); |
| 452 |
default: |
| 453 |
return -EINVAL; |
| 454 |
} |
| 455 |
} |
| 456 |
|
| 457 |
void efx_ethtool_get_strings(struct net_device *net_dev, |
| 458 |
u32 string_set, u8 *strings) |
| 459 |
{ |
| 460 |
struct efx_nic *efx = efx_netdev_priv(net_dev); |
| 461 |
int i; |
| 462 |
|
| 463 |
switch (string_set) { |
| 464 |
case ETH_SS_STATS: |
| 465 |
efx->type->describe_stats(efx, &strings); |
| 466 |
for (i = 0; i < EFX_ETHTOOL_SW_STAT_COUNT; i++) |
| 467 |
ethtool_puts(&strings, efx_sw_stat_desc[i].name); |
| 468 |
efx_describe_per_queue_stats(efx, &strings); |
| 469 |
efx_ptp_describe_stats(efx, &strings); |
| 470 |
break; |
| 471 |
case ETH_SS_TEST: |
| 472 |
efx_ethtool_fill_self_tests(efx, NULL, strings, NULL); |
| 473 |
break; |
| 474 |
default: |
| 475 |
/* No other string sets */ |
| 476 |
break; |
| 477 |
} |
| 478 |
} |
| 479 |
|
| 480 |
void efx_ethtool_get_stats(struct net_device *net_dev, |
| 481 |
struct ethtool_stats *stats, |
| 482 |
u64 *data) |
| 483 |
{ |
| 484 |
struct efx_nic *efx = efx_netdev_priv(net_dev); |
| 485 |
const struct efx_sw_stat_desc *stat; |
| 486 |
struct efx_channel *channel; |
| 487 |
struct efx_tx_queue *tx_queue; |
| 488 |
struct efx_rx_queue *rx_queue; |
| 489 |
int i; |
| 490 |
|
| 491 |
spin_lock_bh(&efx->stats_lock); |
| 492 |
|
| 493 |
/* Get NIC statistics */ |
| 494 |
data += efx->type->update_stats(efx, data, NULL); |
| 495 |
|
| 496 |
/* Get software statistics */ |
| 497 |
for (i = 0; i < EFX_ETHTOOL_SW_STAT_COUNT; i++) { |
| 498 |
stat = &efx_sw_stat_desc[i]; |
| 499 |
switch (stat->source) { |
| 500 |
case EFX_ETHTOOL_STAT_SOURCE_nic: |
| 501 |
data[i] = stat->get_stat((void *)efx + stat->offset); |
| 502 |
break; |
| 503 |
case EFX_ETHTOOL_STAT_SOURCE_channel: |
| 504 |
data[i] = 0; |
| 505 |
efx_for_each_channel(channel, efx) |
| 506 |
data[i] += stat->get_stat((void *)channel + |
| 507 |
stat->offset); |
| 508 |
break; |
| 509 |
case EFX_ETHTOOL_STAT_SOURCE_tx_queue: |
| 510 |
data[i] = 0; |
| 511 |
efx_for_each_channel(channel, efx) { |
| 512 |
efx_for_each_channel_tx_queue(tx_queue, channel) |
| 513 |
data[i] += |
| 514 |
stat->get_stat((void *)tx_queue |
| 515 |
+ stat->offset); |
| 516 |
} |
| 517 |
break; |
| 518 |
} |
| 519 |
} |
| 520 |
data += EFX_ETHTOOL_SW_STAT_COUNT; |
| 521 |
|
| 522 |
spin_unlock_bh(&efx->stats_lock); |
| 523 |
|
| 524 |
efx_for_each_channel(channel, efx) { |
| 525 |
if (efx_channel_has_tx_queues(channel)) { |
| 526 |
*data = 0; |
| 527 |
efx_for_each_channel_tx_queue(tx_queue, channel) { |
| 528 |
*data += tx_queue->tx_packets; |
| 529 |
} |
| 530 |
data++; |
| 531 |
} |
| 532 |
} |
| 533 |
efx_for_each_channel(channel, efx) { |
| 534 |
if (efx_channel_has_rx_queue(channel)) { |
| 535 |
*data = 0; |
| 536 |
efx_for_each_channel_rx_queue(rx_queue, channel) { |
| 537 |
*data += rx_queue->rx_packets; |
| 538 |
} |
| 539 |
data++; |
| 540 |
} |
| 541 |
} |
| 542 |
if (efx->xdp_tx_queue_count && efx->xdp_tx_queues) { |
| 543 |
int xdp; |
| 544 |
|
| 545 |
for (xdp = 0; xdp < efx->xdp_tx_queue_count; xdp++) { |
| 546 |
data[0] = efx->xdp_tx_queues[xdp]->tx_packets; |
| 547 |
data++; |
| 548 |
} |
| 549 |
} |
| 550 |
|
| 551 |
efx_ptp_update_stats(efx, data); |
| 552 |
} |
| 553 |
|
| 554 |
/* This must be called with rtnl_lock held. */ |
| 555 |
int efx_ethtool_get_link_ksettings(struct net_device *net_dev, |
| 556 |
struct ethtool_link_ksettings *cmd) |
| 557 |
{ |
| 558 |
struct efx_nic *efx = efx_netdev_priv(net_dev); |
| 559 |
struct efx_link_state *link_state = &efx->link_state; |
| 560 |
|
| 561 |
mutex_lock(&efx->mac_lock); |
| 562 |
efx_mcdi_phy_get_link_ksettings(efx, cmd); |
| 563 |
mutex_unlock(&efx->mac_lock); |
| 564 |
|
| 565 |
/* Both MACs support pause frames (bidirectional and respond-only) */ |
| 566 |
ethtool_link_ksettings_add_link_mode(cmd, supported, Pause); |
| 567 |
ethtool_link_ksettings_add_link_mode(cmd, supported, Asym_Pause); |
| 568 |
|
| 569 |
if (LOOPBACK_INTERNAL(efx)) { |
| 570 |
cmd->base.speed = link_state->speed; |
| 571 |
cmd->base.duplex = link_state->fd ? DUPLEX_FULL : DUPLEX_HALF; |
| 572 |
} |
| 573 |
|
| 574 |
return 0; |
| 575 |
} |
| 576 |
|
| 577 |
/* This must be called with rtnl_lock held. */ |
| 578 |
int efx_ethtool_set_link_ksettings(struct net_device *net_dev, |
| 579 |
const struct ethtool_link_ksettings *cmd) |
| 580 |
{ |
| 581 |
struct efx_nic *efx = efx_netdev_priv(net_dev); |
| 582 |
int rc; |
| 583 |
|
| 584 |
/* GMAC does not support 1000Mbps HD */ |
| 585 |
if ((cmd->base.speed == SPEED_1000) && |
| 586 |
(cmd->base.duplex != DUPLEX_FULL)) { |
| 587 |
netif_dbg(efx, drv, efx->net_dev, |
| 588 |
"rejecting unsupported 1000Mbps HD setting\n"); |
| 589 |
return -EINVAL; |
| 590 |
} |
| 591 |
|
| 592 |
mutex_lock(&efx->mac_lock); |
| 593 |
rc = efx_mcdi_phy_set_link_ksettings(efx, cmd); |
| 594 |
mutex_unlock(&efx->mac_lock); |
| 595 |
return rc; |
| 596 |
} |
| 597 |
|
| 598 |
int efx_ethtool_get_fecparam(struct net_device *net_dev, |
| 599 |
struct ethtool_fecparam *fecparam) |
| 600 |
{ |
| 601 |
struct efx_nic *efx = efx_netdev_priv(net_dev); |
| 602 |
int rc; |
| 603 |
|
| 604 |
mutex_lock(&efx->mac_lock); |
| 605 |
rc = efx_mcdi_phy_get_fecparam(efx, fecparam); |
| 606 |
mutex_unlock(&efx->mac_lock); |
| 607 |
|
| 608 |
return rc; |
| 609 |
} |
| 610 |
|
| 611 |
int efx_ethtool_set_fecparam(struct net_device *net_dev, |
| 612 |
struct ethtool_fecparam *fecparam) |
| 613 |
{ |
| 614 |
struct efx_nic *efx = efx_netdev_priv(net_dev); |
| 615 |
int rc; |
| 616 |
|
| 617 |
mutex_lock(&efx->mac_lock); |
| 618 |
rc = efx_mcdi_phy_set_fecparam(efx, fecparam); |
| 619 |
mutex_unlock(&efx->mac_lock); |
| 620 |
|
| 621 |
return rc; |
| 622 |
} |
| 623 |
|
| 624 |
/* MAC address mask including only I/G bit */ |
| 625 |
static const u8 mac_addr_ig_mask[ETH_ALEN] __aligned(2) = {0x01, 0, 0, 0, 0, 0}; |
| 626 |
|
| 627 |
#define IP4_ADDR_FULL_MASK ((__force __be32)~0) |
| 628 |
#define IP_PROTO_FULL_MASK 0xFF |
| 629 |
#define PORT_FULL_MASK ((__force __be16)~0) |
| 630 |
#define ETHER_TYPE_FULL_MASK ((__force __be16)~0) |
| 631 |
|
| 632 |
static inline void ip6_fill_mask(__be32 *mask) |
| 633 |
{ |
| 634 |
mask[0] = mask[1] = mask[2] = mask[3] = ~(__be32)0; |
| 635 |
} |
| 636 |
|
| 637 |
static int efx_ethtool_get_class_rule(struct efx_nic *efx, |
| 638 |
struct ethtool_rx_flow_spec *rule, |
| 639 |
u32 *rss_context) |
| 640 |
{ |
| 641 |
struct ethtool_tcpip4_spec *ip_entry = &rule->h_u.tcp_ip4_spec; |
| 642 |
struct ethtool_tcpip4_spec *ip_mask = &rule->m_u.tcp_ip4_spec; |
| 643 |
struct ethtool_usrip4_spec *uip_entry = &rule->h_u.usr_ip4_spec; |
| 644 |
struct ethtool_usrip4_spec *uip_mask = &rule->m_u.usr_ip4_spec; |
| 645 |
struct ethtool_tcpip6_spec *ip6_entry = &rule->h_u.tcp_ip6_spec; |
| 646 |
struct ethtool_tcpip6_spec *ip6_mask = &rule->m_u.tcp_ip6_spec; |
| 647 |
struct ethtool_usrip6_spec *uip6_entry = &rule->h_u.usr_ip6_spec; |
| 648 |
struct ethtool_usrip6_spec *uip6_mask = &rule->m_u.usr_ip6_spec; |
| 649 |
struct ethhdr *mac_entry = &rule->h_u.ether_spec; |
| 650 |
struct ethhdr *mac_mask = &rule->m_u.ether_spec; |
| 651 |
struct efx_filter_spec spec; |
| 652 |
int rc; |
| 653 |
|
| 654 |
rc = efx_filter_get_filter_safe(efx, EFX_FILTER_PRI_MANUAL, |
| 655 |
rule->location, &spec); |
| 656 |
if (rc) |
| 657 |
return rc; |
| 658 |
|
| 659 |
if (spec.dmaq_id == EFX_FILTER_RX_DMAQ_ID_DROP) |
| 660 |
rule->ring_cookie = RX_CLS_FLOW_DISC; |
| 661 |
else |
| 662 |
rule->ring_cookie = spec.dmaq_id; |
| 663 |
|
| 664 |
if ((spec.match_flags & EFX_FILTER_MATCH_ETHER_TYPE) && |
| 665 |
spec.ether_type == htons(ETH_P_IP) && |
| 666 |
(spec.match_flags & EFX_FILTER_MATCH_IP_PROTO) && |
| 667 |
(spec.ip_proto == IPPROTO_TCP || spec.ip_proto == IPPROTO_UDP) && |
| 668 |
!(spec.match_flags & |
| 669 |
~(EFX_FILTER_MATCH_ETHER_TYPE | EFX_FILTER_MATCH_OUTER_VID | |
| 670 |
EFX_FILTER_MATCH_LOC_HOST | EFX_FILTER_MATCH_REM_HOST | |
| 671 |
EFX_FILTER_MATCH_IP_PROTO | |
| 672 |
EFX_FILTER_MATCH_LOC_PORT | EFX_FILTER_MATCH_REM_PORT))) { |
| 673 |
rule->flow_type = ((spec.ip_proto == IPPROTO_TCP) ? |
| 674 |
TCP_V4_FLOW : UDP_V4_FLOW); |
| 675 |
if (spec.match_flags & EFX_FILTER_MATCH_LOC_HOST) { |
| 676 |
ip_entry->ip4dst = spec.loc_host[0]; |
| 677 |
ip_mask->ip4dst = IP4_ADDR_FULL_MASK; |
| 678 |
} |
| 679 |
if (spec.match_flags & EFX_FILTER_MATCH_REM_HOST) { |
| 680 |
ip_entry->ip4src = spec.rem_host[0]; |
| 681 |
ip_mask->ip4src = IP4_ADDR_FULL_MASK; |
| 682 |
} |
| 683 |
if (spec.match_flags & EFX_FILTER_MATCH_LOC_PORT) { |
| 684 |
ip_entry->pdst = spec.loc_port; |
| 685 |
ip_mask->pdst = PORT_FULL_MASK; |
| 686 |
} |
| 687 |
if (spec.match_flags & EFX_FILTER_MATCH_REM_PORT) { |
| 688 |
ip_entry->psrc = spec.rem_port; |
| 689 |
ip_mask->psrc = PORT_FULL_MASK; |
| 690 |
} |
| 691 |
} else if ((spec.match_flags & EFX_FILTER_MATCH_ETHER_TYPE) && |
| 692 |
spec.ether_type == htons(ETH_P_IPV6) && |
| 693 |
(spec.match_flags & EFX_FILTER_MATCH_IP_PROTO) && |
| 694 |
(spec.ip_proto == IPPROTO_TCP || spec.ip_proto == IPPROTO_UDP) && |
| 695 |
!(spec.match_flags & |
| 696 |
~(EFX_FILTER_MATCH_ETHER_TYPE | EFX_FILTER_MATCH_OUTER_VID | |
| 697 |
EFX_FILTER_MATCH_LOC_HOST | EFX_FILTER_MATCH_REM_HOST | |
| 698 |
EFX_FILTER_MATCH_IP_PROTO | |
| 699 |
EFX_FILTER_MATCH_LOC_PORT | EFX_FILTER_MATCH_REM_PORT))) { |
| 700 |
rule->flow_type = ((spec.ip_proto == IPPROTO_TCP) ? |
| 701 |
TCP_V6_FLOW : UDP_V6_FLOW); |
| 702 |
if (spec.match_flags & EFX_FILTER_MATCH_LOC_HOST) { |
| 703 |
memcpy(ip6_entry->ip6dst, spec.loc_host, |
| 704 |
sizeof(ip6_entry->ip6dst)); |
| 705 |
ip6_fill_mask(ip6_mask->ip6dst); |
| 706 |
} |
| 707 |
if (spec.match_flags & EFX_FILTER_MATCH_REM_HOST) { |
| 708 |
memcpy(ip6_entry->ip6src, spec.rem_host, |
| 709 |
sizeof(ip6_entry->ip6src)); |
| 710 |
ip6_fill_mask(ip6_mask->ip6src); |
| 711 |
} |
| 712 |
if (spec.match_flags & EFX_FILTER_MATCH_LOC_PORT) { |
| 713 |
ip6_entry->pdst = spec.loc_port; |
| 714 |
ip6_mask->pdst = PORT_FULL_MASK; |
| 715 |
} |
| 716 |
if (spec.match_flags & EFX_FILTER_MATCH_REM_PORT) { |
| 717 |
ip6_entry->psrc = spec.rem_port; |
| 718 |
ip6_mask->psrc = PORT_FULL_MASK; |
| 719 |
} |
| 720 |
} else if (!(spec.match_flags & |
| 721 |
~(EFX_FILTER_MATCH_LOC_MAC | EFX_FILTER_MATCH_LOC_MAC_IG | |
| 722 |
EFX_FILTER_MATCH_REM_MAC | EFX_FILTER_MATCH_ETHER_TYPE | |
| 723 |
EFX_FILTER_MATCH_OUTER_VID))) { |
| 724 |
rule->flow_type = ETHER_FLOW; |
| 725 |
if (spec.match_flags & |
| 726 |
(EFX_FILTER_MATCH_LOC_MAC | EFX_FILTER_MATCH_LOC_MAC_IG)) { |
| 727 |
ether_addr_copy(mac_entry->h_dest, spec.loc_mac); |
| 728 |
if (spec.match_flags & EFX_FILTER_MATCH_LOC_MAC) |
| 729 |
eth_broadcast_addr(mac_mask->h_dest); |
| 730 |
else |
| 731 |
ether_addr_copy(mac_mask->h_dest, |
| 732 |
mac_addr_ig_mask); |
| 733 |
} |
| 734 |
if (spec.match_flags & EFX_FILTER_MATCH_REM_MAC) { |
| 735 |
ether_addr_copy(mac_entry->h_source, spec.rem_mac); |
| 736 |
eth_broadcast_addr(mac_mask->h_source); |
| 737 |
} |
| 738 |
if (spec.match_flags & EFX_FILTER_MATCH_ETHER_TYPE) { |
| 739 |
mac_entry->h_proto = spec.ether_type; |
| 740 |
mac_mask->h_proto = ETHER_TYPE_FULL_MASK; |
| 741 |
} |
| 742 |
} else if (spec.match_flags & EFX_FILTER_MATCH_ETHER_TYPE && |
| 743 |
spec.ether_type == htons(ETH_P_IP) && |
| 744 |
!(spec.match_flags & |
| 745 |
~(EFX_FILTER_MATCH_ETHER_TYPE | EFX_FILTER_MATCH_OUTER_VID | |
| 746 |
EFX_FILTER_MATCH_LOC_HOST | EFX_FILTER_MATCH_REM_HOST | |
| 747 |
EFX_FILTER_MATCH_IP_PROTO))) { |
| 748 |
rule->flow_type = IPV4_USER_FLOW; |
| 749 |
uip_entry->ip_ver = ETH_RX_NFC_IP4; |
| 750 |
if (spec.match_flags & EFX_FILTER_MATCH_IP_PROTO) { |
| 751 |
uip_mask->proto = IP_PROTO_FULL_MASK; |
| 752 |
uip_entry->proto = spec.ip_proto; |
| 753 |
} |
| 754 |
if (spec.match_flags & EFX_FILTER_MATCH_LOC_HOST) { |
| 755 |
uip_entry->ip4dst = spec.loc_host[0]; |
| 756 |
uip_mask->ip4dst = IP4_ADDR_FULL_MASK; |
| 757 |
} |
| 758 |
if (spec.match_flags & EFX_FILTER_MATCH_REM_HOST) { |
| 759 |
uip_entry->ip4src = spec.rem_host[0]; |
| 760 |
uip_mask->ip4src = IP4_ADDR_FULL_MASK; |
| 761 |
} |
| 762 |
} else if (spec.match_flags & EFX_FILTER_MATCH_ETHER_TYPE && |
| 763 |
spec.ether_type == htons(ETH_P_IPV6) && |
| 764 |
!(spec.match_flags & |
| 765 |
~(EFX_FILTER_MATCH_ETHER_TYPE | EFX_FILTER_MATCH_OUTER_VID | |
| 766 |
EFX_FILTER_MATCH_LOC_HOST | EFX_FILTER_MATCH_REM_HOST | |
| 767 |
EFX_FILTER_MATCH_IP_PROTO))) { |
| 768 |
rule->flow_type = IPV6_USER_FLOW; |
| 769 |
if (spec.match_flags & EFX_FILTER_MATCH_IP_PROTO) { |
| 770 |
uip6_mask->l4_proto = IP_PROTO_FULL_MASK; |
| 771 |
uip6_entry->l4_proto = spec.ip_proto; |
| 772 |
} |
| 773 |
if (spec.match_flags & EFX_FILTER_MATCH_LOC_HOST) { |
| 774 |
memcpy(uip6_entry->ip6dst, spec.loc_host, |
| 775 |
sizeof(uip6_entry->ip6dst)); |
| 776 |
ip6_fill_mask(uip6_mask->ip6dst); |
| 777 |
} |
| 778 |
if (spec.match_flags & EFX_FILTER_MATCH_REM_HOST) { |
| 779 |
memcpy(uip6_entry->ip6src, spec.rem_host, |
| 780 |
sizeof(uip6_entry->ip6src)); |
| 781 |
ip6_fill_mask(uip6_mask->ip6src); |
| 782 |
} |
| 783 |
} else { |
| 784 |
/* The above should handle all filters that we insert */ |
| 785 |
WARN_ON(1); |
| 786 |
return -EINVAL; |
| 787 |
} |
| 788 |
|
| 789 |
if (spec.match_flags & EFX_FILTER_MATCH_OUTER_VID) { |
| 790 |
rule->flow_type |= FLOW_EXT; |
| 791 |
rule->h_ext.vlan_tci = spec.outer_vid; |
| 792 |
rule->m_ext.vlan_tci = htons(0xfff); |
| 793 |
} |
| 794 |
|
| 795 |
if (spec.flags & EFX_FILTER_FLAG_RX_RSS) { |
| 796 |
rule->flow_type |= FLOW_RSS; |
| 797 |
*rss_context = spec.rss_context; |
| 798 |
} |
| 799 |
|
| 800 |
return rc; |
| 801 |
} |
| 802 |
|
| 803 |
int efx_ethtool_get_rxfh_fields(struct net_device *net_dev, |
| 804 |
struct ethtool_rxfh_fields *info) |
| 805 |
{ |
| 806 |
struct efx_nic *efx = efx_netdev_priv(net_dev); |
| 807 |
struct efx_rss_context_priv *ctx; |
| 808 |
__u64 data; |
| 809 |
int rc = 0; |
| 810 |
|
| 811 |
ctx = &efx->rss_context.priv; |
| 812 |
|
| 813 |
if (info->rss_context) { |
| 814 |
ctx = efx_find_rss_context_entry(efx, info->rss_context); |
| 815 |
if (!ctx) |
| 816 |
return -ENOENT; |
| 817 |
} |
| 818 |
|
| 819 |
data = 0; |
| 820 |
if (!efx_rss_active(ctx)) /* No RSS */ |
| 821 |
goto out_setdata_unlock; |
| 822 |
|
| 823 |
switch (info->flow_type) { |
| 824 |
case UDP_V4_FLOW: |
| 825 |
case UDP_V6_FLOW: |
| 826 |
if (ctx->rx_hash_udp_4tuple) |
| 827 |
data = (RXH_L4_B_0_1 | RXH_L4_B_2_3 | |
| 828 |
RXH_IP_SRC | RXH_IP_DST); |
| 829 |
else |
| 830 |
data = RXH_IP_SRC | RXH_IP_DST; |
| 831 |
break; |
| 832 |
case TCP_V4_FLOW: |
| 833 |
case TCP_V6_FLOW: |
| 834 |
data = (RXH_L4_B_0_1 | RXH_L4_B_2_3 | |
| 835 |
RXH_IP_SRC | RXH_IP_DST); |
| 836 |
break; |
| 837 |
case SCTP_V4_FLOW: |
| 838 |
case SCTP_V6_FLOW: |
| 839 |
case AH_ESP_V4_FLOW: |
| 840 |
case AH_ESP_V6_FLOW: |
| 841 |
case IPV4_FLOW: |
| 842 |
case IPV6_FLOW: |
| 843 |
data = RXH_IP_SRC | RXH_IP_DST; |
| 844 |
break; |
| 845 |
default: |
| 846 |
break; |
| 847 |
} |
| 848 |
out_setdata_unlock: |
| 849 |
info->data = data; |
| 850 |
return rc; |
| 851 |
} |
| 852 |
|
| 853 |
u32 efx_ethtool_get_rx_ring_count(struct net_device *net_dev) |
| 854 |
{ |
| 855 |
struct efx_nic *efx = efx_netdev_priv(net_dev); |
| 856 |
|
| 857 |
return efx->n_rx_channels; |
| 858 |
} |
| 859 |
|
| 860 |
int efx_ethtool_get_rxnfc(struct net_device *net_dev, |
| 861 |
struct ethtool_rxnfc *info, u32 *rule_locs) |
| 862 |
{ |
| 863 |
struct efx_nic *efx = efx_netdev_priv(net_dev); |
| 864 |
u32 rss_context = 0; |
| 865 |
s32 rc = 0; |
| 866 |
|
| 867 |
switch (info->cmd) { |
| 868 |
case ETHTOOL_GRXCLSRLCNT: |
| 869 |
info->data = efx_filter_get_rx_id_limit(efx); |
| 870 |
if (info->data == 0) |
| 871 |
return -EOPNOTSUPP; |
| 872 |
info->data |= RX_CLS_LOC_SPECIAL; |
| 873 |
info->rule_cnt = |
| 874 |
efx_filter_count_rx_used(efx, EFX_FILTER_PRI_MANUAL); |
| 875 |
return 0; |
| 876 |
|
| 877 |
case ETHTOOL_GRXCLSRULE: |
| 878 |
if (efx_filter_get_rx_id_limit(efx) == 0) |
| 879 |
return -EOPNOTSUPP; |
| 880 |
rc = efx_ethtool_get_class_rule(efx, &info->fs, &rss_context); |
| 881 |
if (rc < 0) |
| 882 |
return rc; |
| 883 |
if (info->fs.flow_type & FLOW_RSS) |
| 884 |
info->rss_context = rss_context; |
| 885 |
return 0; |
| 886 |
|
| 887 |
case ETHTOOL_GRXCLSRLALL: |
| 888 |
info->data = efx_filter_get_rx_id_limit(efx); |
| 889 |
if (info->data == 0) |
| 890 |
return -EOPNOTSUPP; |
| 891 |
rc = efx_filter_get_rx_ids(efx, EFX_FILTER_PRI_MANUAL, |
| 892 |
rule_locs, info->rule_cnt); |
| 893 |
if (rc < 0) |
| 894 |
return rc; |
| 895 |
info->rule_cnt = rc; |
| 896 |
return 0; |
| 897 |
|
| 898 |
default: |
| 899 |
return -EOPNOTSUPP; |
| 900 |
} |
| 901 |
} |
| 902 |
|
| 903 |
static inline bool ip6_mask_is_full(__be32 mask[4]) |
| 904 |
{ |
| 905 |
return !~(mask[0] & mask[1] & mask[2] & mask[3]); |
| 906 |
} |
| 907 |
|
| 908 |
static inline bool ip6_mask_is_empty(__be32 mask[4]) |
| 909 |
{ |
| 910 |
return !(mask[0] | mask[1] | mask[2] | mask[3]); |
| 911 |
} |
| 912 |
|
| 913 |
static int efx_ethtool_set_class_rule(struct efx_nic *efx, |
| 914 |
struct ethtool_rx_flow_spec *rule, |
| 915 |
u32 rss_context) |
| 916 |
{ |
| 917 |
struct ethtool_tcpip4_spec *ip_entry = &rule->h_u.tcp_ip4_spec; |
| 918 |
struct ethtool_tcpip4_spec *ip_mask = &rule->m_u.tcp_ip4_spec; |
| 919 |
struct ethtool_usrip4_spec *uip_entry = &rule->h_u.usr_ip4_spec; |
| 920 |
struct ethtool_usrip4_spec *uip_mask = &rule->m_u.usr_ip4_spec; |
| 921 |
struct ethtool_tcpip6_spec *ip6_entry = &rule->h_u.tcp_ip6_spec; |
| 922 |
struct ethtool_tcpip6_spec *ip6_mask = &rule->m_u.tcp_ip6_spec; |
| 923 |
struct ethtool_usrip6_spec *uip6_entry = &rule->h_u.usr_ip6_spec; |
| 924 |
struct ethtool_usrip6_spec *uip6_mask = &rule->m_u.usr_ip6_spec; |
| 925 |
u32 flow_type = rule->flow_type & ~(FLOW_EXT | FLOW_RSS); |
| 926 |
struct ethhdr *mac_entry = &rule->h_u.ether_spec; |
| 927 |
struct ethhdr *mac_mask = &rule->m_u.ether_spec; |
| 928 |
enum efx_filter_flags flags = 0; |
| 929 |
struct efx_filter_spec spec; |
| 930 |
int rc; |
| 931 |
|
| 932 |
/* Check that user wants us to choose the location */ |
| 933 |
if (rule->location != RX_CLS_LOC_ANY) |
| 934 |
return -EINVAL; |
| 935 |
|
| 936 |
/* Range-check ring_cookie */ |
| 937 |
if (rule->ring_cookie >= efx->n_rx_channels && |
| 938 |
rule->ring_cookie != RX_CLS_FLOW_DISC) |
| 939 |
return -EINVAL; |
| 940 |
|
| 941 |
/* Check for unsupported extensions */ |
| 942 |
if ((rule->flow_type & FLOW_EXT) && |
| 943 |
(rule->m_ext.vlan_etype || rule->m_ext.data[0] || |
| 944 |
rule->m_ext.data[1])) |
| 945 |
return -EINVAL; |
| 946 |
|
| 947 |
if (efx->rx_scatter) |
| 948 |
flags |= EFX_FILTER_FLAG_RX_SCATTER; |
| 949 |
if (rule->flow_type & FLOW_RSS) |
| 950 |
flags |= EFX_FILTER_FLAG_RX_RSS; |
| 951 |
|
| 952 |
efx_filter_init_rx(&spec, EFX_FILTER_PRI_MANUAL, flags, |
| 953 |
(rule->ring_cookie == RX_CLS_FLOW_DISC) ? |
| 954 |
EFX_FILTER_RX_DMAQ_ID_DROP : rule->ring_cookie); |
| 955 |
|
| 956 |
if (rule->flow_type & FLOW_RSS) |
| 957 |
spec.rss_context = rss_context; |
| 958 |
|
| 959 |
switch (flow_type) { |
| 960 |
case TCP_V4_FLOW: |
| 961 |
case UDP_V4_FLOW: |
| 962 |
spec.match_flags = (EFX_FILTER_MATCH_ETHER_TYPE | |
| 963 |
EFX_FILTER_MATCH_IP_PROTO); |
| 964 |
spec.ether_type = htons(ETH_P_IP); |
| 965 |
spec.ip_proto = flow_type == TCP_V4_FLOW ? IPPROTO_TCP |
| 966 |
: IPPROTO_UDP; |
| 967 |
if (ip_mask->ip4dst) { |
| 968 |
if (ip_mask->ip4dst != IP4_ADDR_FULL_MASK) |
| 969 |
return -EINVAL; |
| 970 |
spec.match_flags |= EFX_FILTER_MATCH_LOC_HOST; |
| 971 |
spec.loc_host[0] = ip_entry->ip4dst; |
| 972 |
} |
| 973 |
if (ip_mask->ip4src) { |
| 974 |
if (ip_mask->ip4src != IP4_ADDR_FULL_MASK) |
| 975 |
return -EINVAL; |
| 976 |
spec.match_flags |= EFX_FILTER_MATCH_REM_HOST; |
| 977 |
spec.rem_host[0] = ip_entry->ip4src; |
| 978 |
} |
| 979 |
if (ip_mask->pdst) { |
| 980 |
if (ip_mask->pdst != PORT_FULL_MASK) |
| 981 |
return -EINVAL; |
| 982 |
spec.match_flags |= EFX_FILTER_MATCH_LOC_PORT; |
| 983 |
spec.loc_port = ip_entry->pdst; |
| 984 |
} |
| 985 |
if (ip_mask->psrc) { |
| 986 |
if (ip_mask->psrc != PORT_FULL_MASK) |
| 987 |
return -EINVAL; |
| 988 |
spec.match_flags |= EFX_FILTER_MATCH_REM_PORT; |
| 989 |
spec.rem_port = ip_entry->psrc; |
| 990 |
} |
| 991 |
if (ip_mask->tos) |
| 992 |
return -EINVAL; |
| 993 |
break; |
| 994 |
|
| 995 |
case TCP_V6_FLOW: |
| 996 |
case UDP_V6_FLOW: |
| 997 |
spec.match_flags = (EFX_FILTER_MATCH_ETHER_TYPE | |
| 998 |
EFX_FILTER_MATCH_IP_PROTO); |
| 999 |
spec.ether_type = htons(ETH_P_IPV6); |
| 1000 |
spec.ip_proto = flow_type == TCP_V6_FLOW ? IPPROTO_TCP |
| 1001 |
: IPPROTO_UDP; |
| 1002 |
if (!ip6_mask_is_empty(ip6_mask->ip6dst)) { |
| 1003 |
if (!ip6_mask_is_full(ip6_mask->ip6dst)) |
| 1004 |
return -EINVAL; |
| 1005 |
spec.match_flags |= EFX_FILTER_MATCH_LOC_HOST; |
| 1006 |
memcpy(spec.loc_host, ip6_entry->ip6dst, sizeof(spec.loc_host)); |
| 1007 |
} |
| 1008 |
if (!ip6_mask_is_empty(ip6_mask->ip6src)) { |
| 1009 |
if (!ip6_mask_is_full(ip6_mask->ip6src)) |
| 1010 |
return -EINVAL; |
| 1011 |
spec.match_flags |= EFX_FILTER_MATCH_REM_HOST; |
| 1012 |
memcpy(spec.rem_host, ip6_entry->ip6src, sizeof(spec.rem_host)); |
| 1013 |
} |
| 1014 |
if (ip6_mask->pdst) { |
| 1015 |
if (ip6_mask->pdst != PORT_FULL_MASK) |
| 1016 |
return -EINVAL; |
| 1017 |
spec.match_flags |= EFX_FILTER_MATCH_LOC_PORT; |
| 1018 |
spec.loc_port = ip6_entry->pdst; |
| 1019 |
} |
| 1020 |
if (ip6_mask->psrc) { |
| 1021 |
if (ip6_mask->psrc != PORT_FULL_MASK) |
| 1022 |
return -EINVAL; |
| 1023 |
spec.match_flags |= EFX_FILTER_MATCH_REM_PORT; |
| 1024 |
spec.rem_port = ip6_entry->psrc; |
| 1025 |
} |
| 1026 |
if (ip6_mask->tclass) |
| 1027 |
return -EINVAL; |
| 1028 |
break; |
| 1029 |
|
| 1030 |
case IPV4_USER_FLOW: |
| 1031 |
if (uip_mask->l4_4_bytes || uip_mask->tos || uip_mask->ip_ver || |
| 1032 |
uip_entry->ip_ver != ETH_RX_NFC_IP4) |
| 1033 |
return -EINVAL; |
| 1034 |
spec.match_flags = EFX_FILTER_MATCH_ETHER_TYPE; |
| 1035 |
spec.ether_type = htons(ETH_P_IP); |
| 1036 |
if (uip_mask->ip4dst) { |
| 1037 |
if (uip_mask->ip4dst != IP4_ADDR_FULL_MASK) |
| 1038 |
return -EINVAL; |
| 1039 |
spec.match_flags |= EFX_FILTER_MATCH_LOC_HOST; |
| 1040 |
spec.loc_host[0] = uip_entry->ip4dst; |
| 1041 |
} |
| 1042 |
if (uip_mask->ip4src) { |
| 1043 |
if (uip_mask->ip4src != IP4_ADDR_FULL_MASK) |
| 1044 |
return -EINVAL; |
| 1045 |
spec.match_flags |= EFX_FILTER_MATCH_REM_HOST; |
| 1046 |
spec.rem_host[0] = uip_entry->ip4src; |
| 1047 |
} |
| 1048 |
if (uip_mask->proto) { |
| 1049 |
if (uip_mask->proto != IP_PROTO_FULL_MASK) |
| 1050 |
return -EINVAL; |
| 1051 |
spec.match_flags |= EFX_FILTER_MATCH_IP_PROTO; |
| 1052 |
spec.ip_proto = uip_entry->proto; |
| 1053 |
} |
| 1054 |
break; |
| 1055 |
|
| 1056 |
case IPV6_USER_FLOW: |
| 1057 |
if (uip6_mask->l4_4_bytes || uip6_mask->tclass) |
| 1058 |
return -EINVAL; |
| 1059 |
spec.match_flags = EFX_FILTER_MATCH_ETHER_TYPE; |
| 1060 |
spec.ether_type = htons(ETH_P_IPV6); |
| 1061 |
if (!ip6_mask_is_empty(uip6_mask->ip6dst)) { |
| 1062 |
if (!ip6_mask_is_full(uip6_mask->ip6dst)) |
| 1063 |
return -EINVAL; |
| 1064 |
spec.match_flags |= EFX_FILTER_MATCH_LOC_HOST; |
| 1065 |
memcpy(spec.loc_host, uip6_entry->ip6dst, sizeof(spec.loc_host)); |
| 1066 |
} |
| 1067 |
if (!ip6_mask_is_empty(uip6_mask->ip6src)) { |
| 1068 |
if (!ip6_mask_is_full(uip6_mask->ip6src)) |
| 1069 |
return -EINVAL; |
| 1070 |
spec.match_flags |= EFX_FILTER_MATCH_REM_HOST; |
| 1071 |
memcpy(spec.rem_host, uip6_entry->ip6src, sizeof(spec.rem_host)); |
| 1072 |
} |
| 1073 |
if (uip6_mask->l4_proto) { |
| 1074 |
if (uip6_mask->l4_proto != IP_PROTO_FULL_MASK) |
| 1075 |
return -EINVAL; |
| 1076 |
spec.match_flags |= EFX_FILTER_MATCH_IP_PROTO; |
| 1077 |
spec.ip_proto = uip6_entry->l4_proto; |
| 1078 |
} |
| 1079 |
break; |
| 1080 |
|
| 1081 |
case ETHER_FLOW: |
| 1082 |
if (!is_zero_ether_addr(mac_mask->h_dest)) { |
| 1083 |
if (ether_addr_equal(mac_mask->h_dest, |
| 1084 |
mac_addr_ig_mask)) |
| 1085 |
spec.match_flags |= EFX_FILTER_MATCH_LOC_MAC_IG; |
| 1086 |
else if (is_broadcast_ether_addr(mac_mask->h_dest)) |
| 1087 |
spec.match_flags |= EFX_FILTER_MATCH_LOC_MAC; |
| 1088 |
else |
| 1089 |
return -EINVAL; |
| 1090 |
ether_addr_copy(spec.loc_mac, mac_entry->h_dest); |
| 1091 |
} |
| 1092 |
if (!is_zero_ether_addr(mac_mask->h_source)) { |
| 1093 |
if (!is_broadcast_ether_addr(mac_mask->h_source)) |
| 1094 |
return -EINVAL; |
| 1095 |
spec.match_flags |= EFX_FILTER_MATCH_REM_MAC; |
| 1096 |
ether_addr_copy(spec.rem_mac, mac_entry->h_source); |
| 1097 |
} |
| 1098 |
if (mac_mask->h_proto) { |
| 1099 |
if (mac_mask->h_proto != ETHER_TYPE_FULL_MASK) |
| 1100 |
return -EINVAL; |
| 1101 |
spec.match_flags |= EFX_FILTER_MATCH_ETHER_TYPE; |
| 1102 |
spec.ether_type = mac_entry->h_proto; |
| 1103 |
} |
| 1104 |
break; |
| 1105 |
|
| 1106 |
default: |
| 1107 |
return -EINVAL; |
| 1108 |
} |
| 1109 |
|
| 1110 |
if ((rule->flow_type & FLOW_EXT) && rule->m_ext.vlan_tci) { |
| 1111 |
if (rule->m_ext.vlan_tci != htons(0xfff)) |
| 1112 |
return -EINVAL; |
| 1113 |
spec.match_flags |= EFX_FILTER_MATCH_OUTER_VID; |
| 1114 |
spec.outer_vid = rule->h_ext.vlan_tci; |
| 1115 |
} |
| 1116 |
|
| 1117 |
rc = efx_filter_insert_filter(efx, &spec, true); |
| 1118 |
if (rc < 0) |
| 1119 |
return rc; |
| 1120 |
|
| 1121 |
rule->location = rc; |
| 1122 |
return 0; |
| 1123 |
} |
| 1124 |
|
| 1125 |
int efx_ethtool_set_rxnfc(struct net_device *net_dev, |
| 1126 |
struct ethtool_rxnfc *info) |
| 1127 |
{ |
| 1128 |
struct efx_nic *efx = efx_netdev_priv(net_dev); |
| 1129 |
|
| 1130 |
if (efx_filter_get_rx_id_limit(efx) == 0) |
| 1131 |
return -EOPNOTSUPP; |
| 1132 |
|
| 1133 |
switch (info->cmd) { |
| 1134 |
case ETHTOOL_SRXCLSRLINS: |
| 1135 |
return efx_ethtool_set_class_rule(efx, &info->fs, |
| 1136 |
info->rss_context); |
| 1137 |
|
| 1138 |
case ETHTOOL_SRXCLSRLDEL: |
| 1139 |
return efx_filter_remove_id_safe(efx, EFX_FILTER_PRI_MANUAL, |
| 1140 |
info->fs.location); |
| 1141 |
|
| 1142 |
default: |
| 1143 |
return -EOPNOTSUPP; |
| 1144 |
} |
| 1145 |
} |
| 1146 |
|
| 1147 |
u32 efx_ethtool_get_rxfh_indir_size(struct net_device *net_dev) |
| 1148 |
{ |
| 1149 |
struct efx_nic *efx = efx_netdev_priv(net_dev); |
| 1150 |
|
| 1151 |
if (efx->n_rx_channels == 1) |
| 1152 |
return 0; |
| 1153 |
return ARRAY_SIZE(efx->rss_context.rx_indir_table); |
| 1154 |
} |
| 1155 |
|
| 1156 |
u32 efx_ethtool_get_rxfh_key_size(struct net_device *net_dev) |
| 1157 |
{ |
| 1158 |
struct efx_nic *efx = efx_netdev_priv(net_dev); |
| 1159 |
|
| 1160 |
return efx->type->rx_hash_key_size; |
| 1161 |
} |
| 1162 |
|
| 1163 |
int efx_ethtool_get_rxfh(struct net_device *net_dev, |
| 1164 |
struct ethtool_rxfh_param *rxfh) |
| 1165 |
{ |
| 1166 |
struct efx_nic *efx = efx_netdev_priv(net_dev); |
| 1167 |
int rc; |
| 1168 |
|
| 1169 |
if (rxfh->rss_context) /* core should never call us for these */ |
| 1170 |
return -EINVAL; |
| 1171 |
|
| 1172 |
rc = efx->type->rx_pull_rss_config(efx); |
| 1173 |
if (rc) |
| 1174 |
return rc; |
| 1175 |
|
| 1176 |
rxfh->hfunc = ETH_RSS_HASH_TOP; |
| 1177 |
if (rxfh->indir) |
| 1178 |
memcpy(rxfh->indir, efx->rss_context.rx_indir_table, |
| 1179 |
sizeof(efx->rss_context.rx_indir_table)); |
| 1180 |
if (rxfh->key) |
| 1181 |
memcpy(rxfh->key, efx->rss_context.rx_hash_key, |
| 1182 |
efx->type->rx_hash_key_size); |
| 1183 |
return 0; |
| 1184 |
} |
| 1185 |
|
| 1186 |
int efx_ethtool_modify_rxfh_context(struct net_device *net_dev, |
| 1187 |
struct ethtool_rxfh_context *ctx, |
| 1188 |
const struct ethtool_rxfh_param *rxfh, |
| 1189 |
struct netlink_ext_ack *extack) |
| 1190 |
{ |
| 1191 |
struct efx_nic *efx = efx_netdev_priv(net_dev); |
| 1192 |
struct efx_rss_context_priv *priv; |
| 1193 |
const u32 *indir = rxfh->indir; |
| 1194 |
const u8 *key = rxfh->key; |
| 1195 |
|
| 1196 |
if (!efx->type->rx_push_rss_context_config) { |
| 1197 |
NL_SET_ERR_MSG_MOD(extack, |
| 1198 |
"NIC type does not support custom contexts"); |
| 1199 |
return -EOPNOTSUPP; |
| 1200 |
} |
| 1201 |
/* Hash function is Toeplitz, cannot be changed */ |
| 1202 |
if (rxfh->hfunc != ETH_RSS_HASH_NO_CHANGE && |
| 1203 |
rxfh->hfunc != ETH_RSS_HASH_TOP) { |
| 1204 |
NL_SET_ERR_MSG_MOD(extack, "Only Toeplitz hash is supported"); |
| 1205 |
return -EOPNOTSUPP; |
| 1206 |
} |
| 1207 |
|
| 1208 |
priv = ethtool_rxfh_context_priv(ctx); |
| 1209 |
|
| 1210 |
if (!key) |
| 1211 |
key = ethtool_rxfh_context_key(ctx); |
| 1212 |
if (!indir) |
| 1213 |
indir = ethtool_rxfh_context_indir(ctx); |
| 1214 |
|
| 1215 |
return efx->type->rx_push_rss_context_config(efx, priv, indir, key, |
| 1216 |
false); |
| 1217 |
} |
| 1218 |
|
| 1219 |
int efx_ethtool_create_rxfh_context(struct net_device *net_dev, |
| 1220 |
struct ethtool_rxfh_context *ctx, |
| 1221 |
const struct ethtool_rxfh_param *rxfh, |
| 1222 |
struct netlink_ext_ack *extack) |
| 1223 |
{ |
| 1224 |
struct efx_nic *efx = efx_netdev_priv(net_dev); |
| 1225 |
struct efx_rss_context_priv *priv; |
| 1226 |
|
| 1227 |
priv = ethtool_rxfh_context_priv(ctx); |
| 1228 |
|
| 1229 |
priv->context_id = EFX_MCDI_RSS_CONTEXT_INVALID; |
| 1230 |
priv->rx_hash_udp_4tuple = false; |
| 1231 |
/* Generate default indir table and/or key if not specified. |
| 1232 |
* We use ctx as a place to store these; this is fine because |
| 1233 |
* we're doing a create, so if we fail then the ctx will just |
| 1234 |
* be deleted. |
| 1235 |
*/ |
| 1236 |
if (!rxfh->indir) |
| 1237 |
efx_set_default_rx_indir_table(efx, ethtool_rxfh_context_indir(ctx)); |
| 1238 |
if (!rxfh->key) |
| 1239 |
netdev_rss_key_fill(ethtool_rxfh_context_key(ctx), |
| 1240 |
ctx->key_size); |
| 1241 |
if (rxfh->hfunc == ETH_RSS_HASH_NO_CHANGE) |
| 1242 |
ctx->hfunc = ETH_RSS_HASH_TOP; |
| 1243 |
if (rxfh->input_xfrm == RXH_XFRM_NO_CHANGE) |
| 1244 |
ctx->input_xfrm = 0; |
| 1245 |
return efx_ethtool_modify_rxfh_context(net_dev, ctx, rxfh, extack); |
| 1246 |
} |
| 1247 |
|
| 1248 |
int efx_ethtool_remove_rxfh_context(struct net_device *net_dev, |
| 1249 |
struct ethtool_rxfh_context *ctx, |
| 1250 |
u32 rss_context, |
| 1251 |
struct netlink_ext_ack *extack) |
| 1252 |
{ |
| 1253 |
struct efx_nic *efx = efx_netdev_priv(net_dev); |
| 1254 |
struct efx_rss_context_priv *priv; |
| 1255 |
|
| 1256 |
if (!efx->type->rx_push_rss_context_config) { |
| 1257 |
NL_SET_ERR_MSG_MOD(extack, |
| 1258 |
"NIC type does not support custom contexts"); |
| 1259 |
return -EOPNOTSUPP; |
| 1260 |
} |
| 1261 |
|
| 1262 |
priv = ethtool_rxfh_context_priv(ctx); |
| 1263 |
return efx->type->rx_push_rss_context_config(efx, priv, NULL, NULL, |
| 1264 |
true); |
| 1265 |
} |
| 1266 |
|
| 1267 |
int efx_ethtool_set_rxfh(struct net_device *net_dev, |
| 1268 |
struct ethtool_rxfh_param *rxfh, |
| 1269 |
struct netlink_ext_ack *extack) |
| 1270 |
{ |
| 1271 |
struct efx_nic *efx = efx_netdev_priv(net_dev); |
| 1272 |
u32 *indir = rxfh->indir; |
| 1273 |
u8 *key = rxfh->key; |
| 1274 |
|
| 1275 |
/* Hash function is Toeplitz, cannot be changed */ |
| 1276 |
if (rxfh->hfunc != ETH_RSS_HASH_NO_CHANGE && |
| 1277 |
rxfh->hfunc != ETH_RSS_HASH_TOP) |
| 1278 |
return -EOPNOTSUPP; |
| 1279 |
|
| 1280 |
/* Custom contexts should use new API */ |
| 1281 |
if (WARN_ON_ONCE(rxfh->rss_context)) |
| 1282 |
return -EIO; |
| 1283 |
|
| 1284 |
if (!indir && !key) |
| 1285 |
return 0; |
| 1286 |
|
| 1287 |
if (!key) |
| 1288 |
key = efx->rss_context.rx_hash_key; |
| 1289 |
if (!indir) |
| 1290 |
indir = efx->rss_context.rx_indir_table; |
| 1291 |
|
| 1292 |
return efx->type->rx_push_rss_config(efx, true, indir, key); |
| 1293 |
} |
| 1294 |
|
| 1295 |
int efx_ethtool_reset(struct net_device *net_dev, u32 *flags) |
| 1296 |
{ |
| 1297 |
struct efx_nic *efx = efx_netdev_priv(net_dev); |
| 1298 |
int rc; |
| 1299 |
|
| 1300 |
rc = efx->type->map_reset_flags(flags); |
| 1301 |
if (rc < 0) |
| 1302 |
return rc; |
| 1303 |
|
| 1304 |
return efx_reset(efx, rc); |
| 1305 |
} |
| 1306 |
|
| 1307 |
int efx_ethtool_get_module_eeprom(struct net_device *net_dev, |
| 1308 |
struct ethtool_eeprom *ee, |
| 1309 |
u8 *data) |
| 1310 |
{ |
| 1311 |
struct efx_nic *efx = efx_netdev_priv(net_dev); |
| 1312 |
int ret; |
| 1313 |
|
| 1314 |
mutex_lock(&efx->mac_lock); |
| 1315 |
ret = efx_mcdi_phy_get_module_eeprom(efx, ee, data); |
| 1316 |
mutex_unlock(&efx->mac_lock); |
| 1317 |
|
| 1318 |
return ret; |
| 1319 |
} |
| 1320 |
|
| 1321 |
int efx_ethtool_get_module_info(struct net_device *net_dev, |
| 1322 |
struct ethtool_modinfo *modinfo) |
| 1323 |
{ |
| 1324 |
struct efx_nic *efx = efx_netdev_priv(net_dev); |
| 1325 |
int ret; |
| 1326 |
|
| 1327 |
mutex_lock(&efx->mac_lock); |
| 1328 |
ret = efx_mcdi_phy_get_module_info(efx, modinfo); |
| 1329 |
mutex_unlock(&efx->mac_lock); |
| 1330 |
|
| 1331 |
return ret; |
| 1332 |
} |