ethtool.c 45.7 KB
Newer Older
1
// SPDX-License-Identifier: GPL-2.0-only
2
/****************************************************************************
B
Ben Hutchings 已提交
3
 * Driver for Solarflare network controllers and boards
4
 * Copyright 2005-2006 Fen Systems Ltd.
B
Ben Hutchings 已提交
5
 * Copyright 2006-2013 Solarflare Communications Inc.
6 7 8 9 10
 */

#include <linux/netdevice.h>
#include <linux/ethtool.h>
#include <linux/rtnetlink.h>
11
#include <linux/in.h>
12
#include "net_driver.h"
B
Ben Hutchings 已提交
13
#include "workarounds.h"
14
#include "selftest.h"
15
#include "efx.h"
16
#include "filter.h"
B
Ben Hutchings 已提交
17
#include "nic.h"
18

19
struct efx_sw_stat_desc {
20 21 22
	const char *name;
	enum {
		EFX_ETHTOOL_STAT_SOURCE_nic,
23 24
		EFX_ETHTOOL_STAT_SOURCE_channel,
		EFX_ETHTOOL_STAT_SOURCE_tx_queue
25 26 27 28 29
	} source;
	unsigned offset;
	u64(*get_stat) (void *field); /* Reader function */
};

30
/* Initialiser for a struct efx_sw_stat_desc with type-checking */
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
#define EFX_ETHTOOL_STAT(stat_name, source_name, field, field_type, \
				get_stat_function) {			\
	.name = #stat_name,						\
	.source = EFX_ETHTOOL_STAT_SOURCE_##source_name,		\
	.offset = ((((field_type *) 0) ==				\
		      &((struct efx_##source_name *)0)->field) ?	\
		    offsetof(struct efx_##source_name, field) :		\
		    offsetof(struct efx_##source_name, field)),		\
	.get_stat = get_stat_function,					\
}

static u64 efx_get_uint_stat(void *field)
{
	return *(unsigned int *)field;
}

static u64 efx_get_atomic_stat(void *field)
{
	return atomic_read((atomic_t *) field);
}

#define EFX_ETHTOOL_ATOMIC_NIC_ERROR_STAT(field)		\
	EFX_ETHTOOL_STAT(field, nic, field,			\
			 atomic_t, efx_get_atomic_stat)

#define EFX_ETHTOOL_UINT_CHANNEL_STAT(field)			\
	EFX_ETHTOOL_STAT(field, channel, n_##field,		\
			 unsigned int, efx_get_uint_stat)

60 61 62 63
#define EFX_ETHTOOL_UINT_TXQ_STAT(field)			\
	EFX_ETHTOOL_STAT(tx_##field, tx_queue, field,		\
			 unsigned int, efx_get_uint_stat)

64
static const struct efx_sw_stat_desc efx_sw_stat_desc[] = {
65
	EFX_ETHTOOL_UINT_TXQ_STAT(merge_events),
66 67 68
	EFX_ETHTOOL_UINT_TXQ_STAT(tso_bursts),
	EFX_ETHTOOL_UINT_TXQ_STAT(tso_long_headers),
	EFX_ETHTOOL_UINT_TXQ_STAT(tso_packets),
E
Edward Cree 已提交
69
	EFX_ETHTOOL_UINT_TXQ_STAT(tso_fallbacks),
70
	EFX_ETHTOOL_UINT_TXQ_STAT(pushes),
71
	EFX_ETHTOOL_UINT_TXQ_STAT(pio_packets),
72
	EFX_ETHTOOL_UINT_TXQ_STAT(cb_packets),
73 74 75 76
	EFX_ETHTOOL_ATOMIC_NIC_ERROR_STAT(rx_reset),
	EFX_ETHTOOL_UINT_CHANNEL_STAT(rx_tobe_disc),
	EFX_ETHTOOL_UINT_CHANNEL_STAT(rx_ip_hdr_chksum_err),
	EFX_ETHTOOL_UINT_CHANNEL_STAT(rx_tcp_udp_chksum_err),
77 78 79 80 81
	EFX_ETHTOOL_UINT_CHANNEL_STAT(rx_inner_ip_hdr_chksum_err),
	EFX_ETHTOOL_UINT_CHANNEL_STAT(rx_inner_tcp_udp_chksum_err),
	EFX_ETHTOOL_UINT_CHANNEL_STAT(rx_outer_ip_hdr_chksum_err),
	EFX_ETHTOOL_UINT_CHANNEL_STAT(rx_outer_tcp_udp_chksum_err),
	EFX_ETHTOOL_UINT_CHANNEL_STAT(rx_eth_crc_err),
B
Ben Hutchings 已提交
82
	EFX_ETHTOOL_UINT_CHANNEL_STAT(rx_mcast_mismatch),
83
	EFX_ETHTOOL_UINT_CHANNEL_STAT(rx_frm_trunc),
84 85
	EFX_ETHTOOL_UINT_CHANNEL_STAT(rx_merge_events),
	EFX_ETHTOOL_UINT_CHANNEL_STAT(rx_merge_packets),
86 87 88 89
	EFX_ETHTOOL_UINT_CHANNEL_STAT(rx_xdp_drops),
	EFX_ETHTOOL_UINT_CHANNEL_STAT(rx_xdp_bad_drops),
	EFX_ETHTOOL_UINT_CHANNEL_STAT(rx_xdp_tx),
	EFX_ETHTOOL_UINT_CHANNEL_STAT(rx_xdp_redirect),
90 91
};

92
#define EFX_ETHTOOL_SW_STAT_COUNT ARRAY_SIZE(efx_sw_stat_desc)
93

94 95
#define EFX_ETHTOOL_EEPROM_MAGIC 0xEFAB

96 97 98 99 100 101 102 103
/**************************************************************************
 *
 * Ethtool operations
 *
 **************************************************************************
 */

/* Identify device by flashing LEDs */
104 105
static int efx_ethtool_phys_id(struct net_device *net_dev,
			       enum ethtool_phys_id_state state)
106
{
107
	struct efx_nic *efx = netdev_priv(net_dev);
108
	enum efx_led_mode mode = EFX_LED_DEFAULT;
109

110 111 112 113 114 115 116 117 118 119
	switch (state) {
	case ETHTOOL_ID_ON:
		mode = EFX_LED_ON;
		break;
	case ETHTOOL_ID_OFF:
		mode = EFX_LED_OFF;
		break;
	case ETHTOOL_ID_INACTIVE:
		mode = EFX_LED_DEFAULT;
		break;
120 121
	case ETHTOOL_ID_ACTIVE:
		return 1;	/* cycle on/off once per second */
122
	}
123

124
	efx->type->set_id_led(efx, mode);
125 126 127 128
	return 0;
}

/* This must be called with rtnl_lock held. */
129 130 131
static int
efx_ethtool_get_link_ksettings(struct net_device *net_dev,
			       struct ethtool_link_ksettings *cmd)
132
{
133
	struct efx_nic *efx = netdev_priv(net_dev);
B
Ben Hutchings 已提交
134
	struct efx_link_state *link_state = &efx->link_state;
135
	u32 supported;
136 137

	mutex_lock(&efx->mac_lock);
138
	efx->phy_op->get_link_ksettings(efx, cmd);
139 140
	mutex_unlock(&efx->mac_lock);

B
Ben Hutchings 已提交
141
	/* Both MACs support pause frames (bidirectional and respond-only) */
142 143 144 145 146 147 148
	ethtool_convert_link_mode_to_legacy_u32(&supported,
						cmd->link_modes.supported);

	supported |= SUPPORTED_Pause | SUPPORTED_Asym_Pause;

	ethtool_convert_legacy_u32_to_link_mode(cmd->link_modes.supported,
						supported);
B
Ben Hutchings 已提交
149 150

	if (LOOPBACK_INTERNAL(efx)) {
151 152
		cmd->base.speed = link_state->speed;
		cmd->base.duplex = link_state->fd ? DUPLEX_FULL : DUPLEX_HALF;
B
Ben Hutchings 已提交
153
	}
154 155

	return 0;
156 157 158
}

/* This must be called with rtnl_lock held. */
159 160 161
static int
efx_ethtool_set_link_ksettings(struct net_device *net_dev,
			       const struct ethtool_link_ksettings *cmd)
162
{
163
	struct efx_nic *efx = netdev_priv(net_dev);
164 165
	int rc;

166
	/* GMAC does not support 1000Mbps HD */
167 168
	if ((cmd->base.speed == SPEED_1000) &&
	    (cmd->base.duplex != DUPLEX_FULL)) {
169 170
		netif_dbg(efx, drv, efx->net_dev,
			  "rejecting unsupported 1000Mbps HD setting\n");
171 172 173
		return -EINVAL;
	}

174
	mutex_lock(&efx->mac_lock);
175
	rc = efx->phy_op->set_link_ksettings(efx, cmd);
176 177 178 179 180 181 182
	mutex_unlock(&efx->mac_lock);
	return rc;
}

static void efx_ethtool_get_drvinfo(struct net_device *net_dev,
				    struct ethtool_drvinfo *info)
{
183
	struct efx_nic *efx = netdev_priv(net_dev);
184

185
	strlcpy(info->driver, KBUILD_MODNAME, sizeof(info->driver));
186
	strlcpy(info->version, EFX_DRIVER_VERSION, sizeof(info->version));
187 188
	efx_mcdi_print_fwver(efx, info->fw_version,
			     sizeof(info->fw_version));
189 190 191
	strlcpy(info->bus_info, pci_name(efx->pci_dev), sizeof(info->bus_info));
}

192 193 194 195 196 197 198 199 200 201 202 203 204 205
static int efx_ethtool_get_regs_len(struct net_device *net_dev)
{
	return efx_nic_get_regs_len(netdev_priv(net_dev));
}

static void efx_ethtool_get_regs(struct net_device *net_dev,
				 struct ethtool_regs *regs, void *buf)
{
	struct efx_nic *efx = netdev_priv(net_dev);

	regs->version = efx->type->revision;
	efx_nic_get_regs(efx, buf);
}

206 207 208 209 210 211 212 213 214 215 216 217
static u32 efx_ethtool_get_msglevel(struct net_device *net_dev)
{
	struct efx_nic *efx = netdev_priv(net_dev);
	return efx->msg_enable;
}

static void efx_ethtool_set_msglevel(struct net_device *net_dev, u32 msg_enable)
{
	struct efx_nic *efx = netdev_priv(net_dev);
	efx->msg_enable = msg_enable;
}

218 219 220 221 222 223
/**
 * efx_fill_test - fill in an individual self-test entry
 * @test_index:		Index of the test
 * @strings:		Ethtool strings, or %NULL
 * @data:		Ethtool test results, or %NULL
 * @test:		Pointer to test result (used only if data != %NULL)
224 225
 * @unit_format:	Unit name format (e.g. "chan\%d")
 * @unit_id:		Unit id (e.g. 0 for "chan0")
226
 * @test_format:	Test name format (e.g. "loopback.\%s.tx.sent")
227
 * @test_id:		Test id (e.g. "PHYXS" for "loopback.PHYXS.tx_sent")
228 229 230
 *
 * Fill in an individual self-test entry.
 */
231
static void efx_fill_test(unsigned int test_index, u8 *strings, u64 *data,
232 233 234
			  int *test, const char *unit_format, int unit_id,
			  const char *test_format, const char *test_id)
{
235
	char unit_str[ETH_GSTRING_LEN], test_str[ETH_GSTRING_LEN];
236 237 238 239 240 241 242

	/* Fill data value, if applicable */
	if (data)
		data[test_index] = *test;

	/* Fill string, if applicable */
	if (strings) {
243
		if (strchr(unit_format, '%'))
244
			snprintf(unit_str, sizeof(unit_str),
245 246
				 unit_format, unit_id);
		else
247 248 249 250 251
			strcpy(unit_str, unit_format);
		snprintf(test_str, sizeof(test_str), test_format, test_id);
		snprintf(strings + test_index * ETH_GSTRING_LEN,
			 ETH_GSTRING_LEN,
			 "%-6s %-24s", unit_str, test_str);
252 253 254
	}
}

255
#define EFX_CHANNEL_NAME(_channel) "chan%d", _channel->channel
256 257 258
#define EFX_TX_QUEUE_NAME(_tx_queue) "txq%d", _tx_queue->queue
#define EFX_RX_QUEUE_NAME(_rx_queue) "rxq%d", _rx_queue->queue
#define EFX_LOOPBACK_NAME(_mode, _counter)			\
259
	"loopback.%s." _counter, STRING_TABLE_LOOKUP(_mode, efx_loopback_mode)
260 261 262 263 264 265 266 267 268

/**
 * efx_fill_loopback_test - fill in a block of loopback self-test entries
 * @efx:		Efx NIC
 * @lb_tests:		Efx loopback self-test results structure
 * @mode:		Loopback test mode
 * @test_index:		Starting index of the test
 * @strings:		Ethtool strings, or %NULL
 * @data:		Ethtool test results, or %NULL
269 270 271
 *
 * Fill in a block of loopback self-test entries.  Return new test
 * index.
272 273 274 275 276
 */
static int efx_fill_loopback_test(struct efx_nic *efx,
				  struct efx_loopback_self_tests *lb_tests,
				  enum efx_loopback_mode mode,
				  unsigned int test_index,
277
				  u8 *strings, u64 *data)
278
{
279 280
	struct efx_channel *channel =
		efx_get_channel(efx, efx->tx_channel_offset);
281 282
	struct efx_tx_queue *tx_queue;

283
	efx_for_each_channel_tx_queue(tx_queue, channel) {
284 285 286 287 288 289 290 291 292 293 294
		efx_fill_test(test_index++, strings, data,
			      &lb_tests->tx_sent[tx_queue->queue],
			      EFX_TX_QUEUE_NAME(tx_queue),
			      EFX_LOOPBACK_NAME(mode, "tx_sent"));
		efx_fill_test(test_index++, strings, data,
			      &lb_tests->tx_done[tx_queue->queue],
			      EFX_TX_QUEUE_NAME(tx_queue),
			      EFX_LOOPBACK_NAME(mode, "tx_done"));
	}
	efx_fill_test(test_index++, strings, data,
		      &lb_tests->rx_good,
295
		      "rx", 0,
296 297 298
		      EFX_LOOPBACK_NAME(mode, "rx_good"));
	efx_fill_test(test_index++, strings, data,
		      &lb_tests->rx_bad,
299
		      "rx", 0,
300 301 302 303 304 305 306 307 308 309 310
		      EFX_LOOPBACK_NAME(mode, "rx_bad"));

	return test_index;
}

/**
 * efx_ethtool_fill_self_tests - get self-test details
 * @efx:		Efx NIC
 * @tests:		Efx self-test results structure, or %NULL
 * @strings:		Ethtool strings, or %NULL
 * @data:		Ethtool test results, or %NULL
311 312 313 314 315 316
 *
 * Get self-test number of strings, strings, and/or test results.
 * Return number of strings (== number of test results).
 *
 * The reason for merging these three functions is to make sure that
 * they can never be inconsistent.
317 318 319
 */
static int efx_ethtool_fill_self_tests(struct efx_nic *efx,
				       struct efx_self_tests *tests,
320
				       u8 *strings, u64 *data)
321 322
{
	struct efx_channel *channel;
323
	unsigned int n = 0, i;
324 325
	enum efx_loopback_mode mode;

326 327
	efx_fill_test(n++, strings, data, &tests->phy_alive,
		      "phy", 0, "alive", NULL);
B
Ben Hutchings 已提交
328 329
	efx_fill_test(n++, strings, data, &tests->nvram,
		      "core", 0, "nvram", NULL);
330 331 332 333 334 335 336 337 338 339 340 341 342 343 344
	efx_fill_test(n++, strings, data, &tests->interrupt,
		      "core", 0, "interrupt", NULL);

	/* Event queues */
	efx_for_each_channel(channel, efx) {
		efx_fill_test(n++, strings, data,
			      &tests->eventq_dma[channel->channel],
			      EFX_CHANNEL_NAME(channel),
			      "eventq.dma", NULL);
		efx_fill_test(n++, strings, data,
			      &tests->eventq_int[channel->channel],
			      EFX_CHANNEL_NAME(channel),
			      "eventq.int", NULL);
	}

345 346
	efx_fill_test(n++, strings, data, &tests->memory,
		      "core", 0, "memory", NULL);
B
Ben Hutchings 已提交
347 348
	efx_fill_test(n++, strings, data, &tests->registers,
		      "core", 0, "registers", NULL);
349

350
	if (efx->phy_op->run_tests != NULL) {
351
		EFX_WARN_ON_PARANOID(efx->phy_op->test_name == NULL);
352 353 354 355

		for (i = 0; true; ++i) {
			const char *name;

356
			EFX_WARN_ON_PARANOID(i >= EFX_MAX_PHY_TESTS);
357 358 359 360
			name = efx->phy_op->test_name(efx, i);
			if (name == NULL)
				break;

361
			efx_fill_test(n++, strings, data, &tests->phy_ext[i],
362 363 364
				      "phy", 0, name, NULL);
		}
	}
365 366

	/* Loopback tests */
B
Ben Hutchings 已提交
367
	for (mode = LOOPBACK_NONE; mode <= LOOPBACK_TEST_MAX; mode++) {
368 369 370 371 372 373 374 375 376 377
		if (!(efx->loopback_modes & (1 << mode)))
			continue;
		n = efx_fill_loopback_test(efx,
					   &tests->loopback[mode], mode, n,
					   strings, data);
	}

	return n;
}

378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405
static size_t efx_describe_per_queue_stats(struct efx_nic *efx, u8 *strings)
{
	size_t n_stats = 0;
	struct efx_channel *channel;

	efx_for_each_channel(channel, efx) {
		if (efx_channel_has_tx_queues(channel)) {
			n_stats++;
			if (strings != NULL) {
				snprintf(strings, ETH_GSTRING_LEN,
					 "tx-%u.tx_packets",
					 channel->tx_queue[0].queue /
					 EFX_TXQ_TYPES);

				strings += ETH_GSTRING_LEN;
			}
		}
	}
	efx_for_each_channel(channel, efx) {
		if (efx_channel_has_rx_queue(channel)) {
			n_stats++;
			if (strings != NULL) {
				snprintf(strings, ETH_GSTRING_LEN,
					 "rx-%d.rx_packets", channel->channel);
				strings += ETH_GSTRING_LEN;
			}
		}
	}
406 407 408 409 410 411 412 413 414 415 416 417 418
	if (efx->xdp_tx_queue_count && efx->xdp_tx_queues) {
		unsigned short xdp;

		for (xdp = 0; xdp < efx->xdp_tx_queue_count; xdp++) {
			n_stats++;
			if (strings) {
				snprintf(strings, ETH_GSTRING_LEN,
					 "tx-xdp-cpu-%hu.tx_packets", xdp);
				strings += ETH_GSTRING_LEN;
			}
		}
	}

419 420 421
	return n_stats;
}

422 423
static int efx_ethtool_get_sset_count(struct net_device *net_dev,
				      int string_set)
424
{
425 426
	struct efx_nic *efx = netdev_priv(net_dev);

427 428
	switch (string_set) {
	case ETH_SS_STATS:
429
		return efx->type->describe_stats(efx, NULL) +
430 431 432
		       EFX_ETHTOOL_SW_STAT_COUNT +
		       efx_describe_per_queue_stats(efx, NULL) +
		       efx_ptp_describe_stats(efx, NULL);
433
	case ETH_SS_TEST:
434
		return efx_ethtool_fill_self_tests(efx, NULL, NULL, NULL);
435 436 437
	default:
		return -EINVAL;
	}
438 439
}

440 441 442
static void efx_ethtool_get_strings(struct net_device *net_dev,
				    u32 string_set, u8 *strings)
{
443
	struct efx_nic *efx = netdev_priv(net_dev);
444 445
	int i;

446 447
	switch (string_set) {
	case ETH_SS_STATS:
448 449 450
		strings += (efx->type->describe_stats(efx, strings) *
			    ETH_GSTRING_LEN);
		for (i = 0; i < EFX_ETHTOOL_SW_STAT_COUNT; i++)
451
			strlcpy(strings + i * ETH_GSTRING_LEN,
452
				efx_sw_stat_desc[i].name, ETH_GSTRING_LEN);
453
		strings += EFX_ETHTOOL_SW_STAT_COUNT * ETH_GSTRING_LEN;
454 455
		strings += (efx_describe_per_queue_stats(efx, strings) *
			    ETH_GSTRING_LEN);
456
		efx_ptp_describe_stats(efx, strings);
457 458
		break;
	case ETH_SS_TEST:
459
		efx_ethtool_fill_self_tests(efx, NULL, strings, NULL);
460 461 462 463 464
		break;
	default:
		/* No other string sets */
		break;
	}
465 466 467 468 469 470
}

static void efx_ethtool_get_stats(struct net_device *net_dev,
				  struct ethtool_stats *stats,
				  u64 *data)
{
471
	struct efx_nic *efx = netdev_priv(net_dev);
472
	const struct efx_sw_stat_desc *stat;
473
	struct efx_channel *channel;
474
	struct efx_tx_queue *tx_queue;
475
	struct efx_rx_queue *rx_queue;
476 477
	int i;

478 479
	spin_lock_bh(&efx->stats_lock);

480 481
	/* Get NIC statistics */
	data += efx->type->update_stats(efx, data, NULL);
482

483 484 485
	/* Get software statistics */
	for (i = 0; i < EFX_ETHTOOL_SW_STAT_COUNT; i++) {
		stat = &efx_sw_stat_desc[i];
486 487 488 489 490 491 492 493 494 495
		switch (stat->source) {
		case EFX_ETHTOOL_STAT_SOURCE_nic:
			data[i] = stat->get_stat((void *)efx + stat->offset);
			break;
		case EFX_ETHTOOL_STAT_SOURCE_channel:
			data[i] = 0;
			efx_for_each_channel(channel, efx)
				data[i] += stat->get_stat((void *)channel +
							  stat->offset);
			break;
496 497 498 499 500 501 502 503 504
		case EFX_ETHTOOL_STAT_SOURCE_tx_queue:
			data[i] = 0;
			efx_for_each_channel(channel, efx) {
				efx_for_each_channel_tx_queue(tx_queue, channel)
					data[i] +=
						stat->get_stat((void *)tx_queue
							       + stat->offset);
			}
			break;
505 506
		}
	}
507
	data += EFX_ETHTOOL_SW_STAT_COUNT;
508 509

	spin_unlock_bh(&efx->stats_lock);
510

511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528
	efx_for_each_channel(channel, efx) {
		if (efx_channel_has_tx_queues(channel)) {
			*data = 0;
			efx_for_each_channel_tx_queue(tx_queue, channel) {
				*data += tx_queue->tx_packets;
			}
			data++;
		}
	}
	efx_for_each_channel(channel, efx) {
		if (efx_channel_has_rx_queue(channel)) {
			*data = 0;
			efx_for_each_channel_rx_queue(rx_queue, channel) {
				*data += rx_queue->rx_packets;
			}
			data++;
		}
	}
529 530 531 532 533 534 535 536
	if (efx->xdp_tx_queue_count && efx->xdp_tx_queues) {
		int xdp;

		for (xdp = 0; xdp < efx->xdp_tx_queue_count; xdp++) {
			data[0] = efx->xdp_tx_queues[xdp]->tx_packets;
			data++;
		}
	}
537

538
	efx_ptp_update_stats(efx, data);
539 540
}

541 542 543
static void efx_ethtool_self_test(struct net_device *net_dev,
				  struct ethtool_test *test, u64 *data)
{
544
	struct efx_nic *efx = netdev_priv(net_dev);
545
	struct efx_self_tests *efx_tests;
546
	bool already_up;
547 548 549 550 551 552
	int rc = -ENOMEM;

	efx_tests = kzalloc(sizeof(*efx_tests), GFP_KERNEL);
	if (!efx_tests)
		goto fail;

553
	if (efx->state != STATE_READY) {
554
		rc = -EBUSY;
555
		goto out;
556 557
	}

558 559 560
	netif_info(efx, drv, efx->net_dev, "starting %sline testing\n",
		   (test->flags & ETH_TEST_FL_OFFLINE) ? "off" : "on");

561 562 563
	/* We need rx buffers and interrupts. */
	already_up = (efx->net_dev->flags & IFF_UP);
	if (!already_up) {
564
		rc = dev_open(efx->net_dev, NULL);
565
		if (rc) {
566 567
			netif_err(efx, drv, efx->net_dev,
				  "failed opening device.\n");
568
			goto out;
569 570 571
		}
	}

572
	rc = efx_selftest(efx, efx_tests, test->flags);
573 574 575 576

	if (!already_up)
		dev_close(efx->net_dev);

577 578 579
	netif_info(efx, drv, efx->net_dev, "%s %sline self-tests\n",
		   rc == 0 ? "passed" : "failed",
		   (test->flags & ETH_TEST_FL_OFFLINE) ? "off" : "on");
580

581
out:
582 583 584
	efx_ethtool_fill_self_tests(efx, efx_tests, NULL, data);
	kfree(efx_tests);
fail:
585 586 587 588
	if (rc)
		test->flags |= ETH_TEST_FL_FAILED;
}

589 590 591
/* Restart autonegotiation */
static int efx_ethtool_nway_reset(struct net_device *net_dev)
{
592
	struct efx_nic *efx = netdev_priv(net_dev);
593

594
	return mdio45_nway_restart(&efx->mdio);
595 596
}

597 598 599 600 601 602 603 604 605
/*
 * Each channel has a single IRQ and moderation timer, started by any
 * completion (or other event).  Unless the module parameter
 * separate_tx_channels is set, IRQs and moderation are therefore
 * shared between RX and TX completions.  In this case, when RX IRQ
 * moderation is explicitly changed then TX IRQ moderation is
 * automatically changed too, but otherwise we fail if the two values
 * are requested to be different.
 *
606 607 608 609 610 611 612 613 614 615 616 617 618 619
 * The hardware does not support a limit on the number of completions
 * before an IRQ, so we do not use the max_frames fields.  We should
 * report and require that max_frames == (usecs != 0), but this would
 * invalidate existing user documentation.
 *
 * The hardware does not have distinct settings for interrupt
 * moderation while the previous IRQ is being handled, so we should
 * not use the 'irq' fields.  However, an earlier developer
 * misunderstood the meaning of the 'irq' fields and the driver did
 * not support the standard fields.  To avoid invalidating existing
 * user documentation, we report and accept changes through either the
 * standard or 'irq' fields.  If both are changed at the same time, we
 * prefer the standard field.
 *
620 621 622 623 624 625
 * We implement adaptive IRQ moderation, but use a different algorithm
 * from that assumed in the definition of struct ethtool_coalesce.
 * Therefore we do not use any of the adaptive moderation parameters
 * in it.
 */

626 627 628
static int efx_ethtool_get_coalesce(struct net_device *net_dev,
				    struct ethtool_coalesce *coalesce)
{
629
	struct efx_nic *efx = netdev_priv(net_dev);
630 631
	unsigned int tx_usecs, rx_usecs;
	bool rx_adaptive;
632

633
	efx_get_irq_moderation(efx, &tx_usecs, &rx_usecs, &rx_adaptive);
634

635
	coalesce->tx_coalesce_usecs = tx_usecs;
636
	coalesce->tx_coalesce_usecs_irq = tx_usecs;
637
	coalesce->rx_coalesce_usecs = rx_usecs;
638 639
	coalesce->rx_coalesce_usecs_irq = rx_usecs;
	coalesce->use_adaptive_rx_coalesce = rx_adaptive;
640

641 642 643 644 645 646
	return 0;
}

static int efx_ethtool_set_coalesce(struct net_device *net_dev,
				    struct ethtool_coalesce *coalesce)
{
647
	struct efx_nic *efx = netdev_priv(net_dev);
648
	struct efx_channel *channel;
649
	unsigned int tx_usecs, rx_usecs;
650 651
	bool adaptive, rx_may_override_tx;
	int rc;
652

653
	if (coalesce->use_adaptive_tx_coalesce)
654
		return -EINVAL;
655

656 657
	efx_get_irq_moderation(efx, &tx_usecs, &rx_usecs, &adaptive);

658 659 660 661 662
	if (coalesce->rx_coalesce_usecs != rx_usecs)
		rx_usecs = coalesce->rx_coalesce_usecs;
	else
		rx_usecs = coalesce->rx_coalesce_usecs_irq;

663
	adaptive = coalesce->use_adaptive_rx_coalesce;
664

665 666 667
	/* If channels are shared, TX IRQ moderation can be quietly
	 * overridden unless it is changed from its old value.
	 */
668 669 670 671 672 673
	rx_may_override_tx = (coalesce->tx_coalesce_usecs == tx_usecs &&
			      coalesce->tx_coalesce_usecs_irq == tx_usecs);
	if (coalesce->tx_coalesce_usecs != tx_usecs)
		tx_usecs = coalesce->tx_coalesce_usecs;
	else
		tx_usecs = coalesce->tx_coalesce_usecs_irq;
674

675 676 677 678 679
	rc = efx_init_irq_moderation(efx, tx_usecs, rx_usecs, adaptive,
				     rx_may_override_tx);
	if (rc != 0)
		return rc;

680
	efx_for_each_channel(channel, efx)
681
		efx->type->push_irq_moderation(channel);
682 683 684 685

	return 0;
}

686 687 688 689 690 691
static void efx_ethtool_get_ringparam(struct net_device *net_dev,
				      struct ethtool_ringparam *ring)
{
	struct efx_nic *efx = netdev_priv(net_dev);

	ring->rx_max_pending = EFX_MAX_DMAQ_SIZE;
692
	ring->tx_max_pending = EFX_TXQ_MAX_ENT(efx);
693 694 695 696 697 698 699 700
	ring->rx_pending = efx->rxq_entries;
	ring->tx_pending = efx->txq_entries;
}

static int efx_ethtool_set_ringparam(struct net_device *net_dev,
				     struct ethtool_ringparam *ring)
{
	struct efx_nic *efx = netdev_priv(net_dev);
701
	u32 txq_entries;
702 703 704

	if (ring->rx_mini_pending || ring->rx_jumbo_pending ||
	    ring->rx_pending > EFX_MAX_DMAQ_SIZE ||
705
	    ring->tx_pending > EFX_TXQ_MAX_ENT(efx))
706 707
		return -EINVAL;

708
	if (ring->rx_pending < EFX_RXQ_MIN_ENT) {
709
		netif_err(efx, drv, efx->net_dev,
710 711
			  "RX queues cannot be smaller than %u\n",
			  EFX_RXQ_MIN_ENT);
712 713 714
		return -EINVAL;
	}

715 716 717 718 719 720 721
	txq_entries = max(ring->tx_pending, EFX_TXQ_MIN_ENT(efx));
	if (txq_entries != ring->tx_pending)
		netif_warn(efx, drv, efx->net_dev,
			   "increasing TX queue size to minimum of %u\n",
			   txq_entries);

	return efx_realloc_channels(efx, ring->rx_pending, txq_entries);
722 723
}

724 725 726
static int efx_ethtool_set_pauseparam(struct net_device *net_dev,
				      struct ethtool_pauseparam *pause)
{
727
	struct efx_nic *efx = netdev_priv(net_dev);
728
	u8 wanted_fc, old_fc;
B
Ben Hutchings 已提交
729 730 731 732
	u32 old_adv;
	int rc = 0;

	mutex_lock(&efx->mac_lock);
733

B
Ben Hutchings 已提交
734 735 736 737 738
	wanted_fc = ((pause->rx_pause ? EFX_FC_RX : 0) |
		     (pause->tx_pause ? EFX_FC_TX : 0) |
		     (pause->autoneg ? EFX_FC_AUTO : 0));

	if ((wanted_fc & EFX_FC_TX) && !(wanted_fc & EFX_FC_RX)) {
739 740
		netif_dbg(efx, drv, efx->net_dev,
			  "Flow control unsupported: tx ON rx OFF\n");
B
Ben Hutchings 已提交
741 742
		rc = -EINVAL;
		goto out;
B
Ben Hutchings 已提交
743 744
	}

745
	if ((wanted_fc & EFX_FC_AUTO) && !efx->link_advertising[0]) {
746 747
		netif_dbg(efx, drv, efx->net_dev,
			  "Autonegotiation is disabled\n");
B
Ben Hutchings 已提交
748 749
		rc = -EINVAL;
		goto out;
B
Ben Hutchings 已提交
750 751
	}

752 753 754 755
	/* Hook for Falcon bug 11482 workaround */
	if (efx->type->prepare_enable_fc_tx &&
	    (wanted_fc & EFX_FC_TX) && !(efx->wanted_fc & EFX_FC_TX))
		efx->type->prepare_enable_fc_tx(efx);
B
Ben Hutchings 已提交
756

757
	old_adv = efx->link_advertising[0];
B
Ben Hutchings 已提交
758 759
	old_fc = efx->wanted_fc;
	efx_link_set_wanted_fc(efx, wanted_fc);
760
	if (efx->link_advertising[0] != old_adv ||
B
Ben Hutchings 已提交
761 762 763
	    (efx->wanted_fc ^ old_fc) & EFX_FC_AUTO) {
		rc = efx->phy_op->reconfigure(efx);
		if (rc) {
764 765 766
			netif_err(efx, drv, efx->net_dev,
				  "Unable to advertise requested flow "
				  "control setting\n");
B
Ben Hutchings 已提交
767 768 769
			goto out;
		}
	}
B
Ben Hutchings 已提交
770

B
Ben Hutchings 已提交
771 772 773
	/* Reconfigure the MAC. The PHY *may* generate a link state change event
	 * if the user just changed the advertised capabilities, but there's no
	 * harm doing this twice */
774
	efx_mac_reconfigure(efx);
B
Ben Hutchings 已提交
775

B
Ben Hutchings 已提交
776
out:
B
Ben Hutchings 已提交
777
	mutex_unlock(&efx->mac_lock);
778

B
Ben Hutchings 已提交
779
	return rc;
780 781 782 783 784
}

static void efx_ethtool_get_pauseparam(struct net_device *net_dev,
				       struct ethtool_pauseparam *pause)
{
785
	struct efx_nic *efx = netdev_priv(net_dev);
786

B
Ben Hutchings 已提交
787 788 789
	pause->rx_pause = !!(efx->wanted_fc & EFX_FC_RX);
	pause->tx_pause = !!(efx->wanted_fc & EFX_FC_TX);
	pause->autoneg = !!(efx->wanted_fc & EFX_FC_AUTO);
790 791
}

792 793 794 795 796 797 798 799 800 801 802 803 804 805 806
static void efx_ethtool_get_wol(struct net_device *net_dev,
				struct ethtool_wolinfo *wol)
{
	struct efx_nic *efx = netdev_priv(net_dev);
	return efx->type->get_wol(efx, wol);
}


static int efx_ethtool_set_wol(struct net_device *net_dev,
			       struct ethtool_wolinfo *wol)
{
	struct efx_nic *efx = netdev_priv(net_dev);
	return efx->type->set_wol(efx, wol->wolopts);
}

S
stephen hemminger 已提交
807
static int efx_ethtool_reset(struct net_device *net_dev, u32 *flags)
808 809
{
	struct efx_nic *efx = netdev_priv(net_dev);
810
	int rc;
811

812 813 814
	rc = efx->type->map_reset_flags(flags);
	if (rc < 0)
		return rc;
815

816
	return efx_reset(efx, rc);
817 818
}

819
/* MAC address mask including only I/G bit */
820
static const u8 mac_addr_ig_mask[ETH_ALEN] __aligned(2) = {0x01, 0, 0, 0, 0, 0};
821

822
#define IP4_ADDR_FULL_MASK	((__force __be32)~0)
823
#define IP_PROTO_FULL_MASK	0xFF
824
#define PORT_FULL_MASK		((__force __be16)~0)
825
#define ETHER_TYPE_FULL_MASK	((__force __be16)~0)
826

827 828 829 830 831
static inline void ip6_fill_mask(__be32 *mask)
{
	mask[0] = mask[1] = mask[2] = mask[3] = ~(__be32)0;
}

832
static int efx_ethtool_get_class_rule(struct efx_nic *efx,
833 834
				      struct ethtool_rx_flow_spec *rule,
				      u32 *rss_context)
835 836 837
{
	struct ethtool_tcpip4_spec *ip_entry = &rule->h_u.tcp_ip4_spec;
	struct ethtool_tcpip4_spec *ip_mask = &rule->m_u.tcp_ip4_spec;
838 839 840 841 842 843
	struct ethtool_usrip4_spec *uip_entry = &rule->h_u.usr_ip4_spec;
	struct ethtool_usrip4_spec *uip_mask = &rule->m_u.usr_ip4_spec;
	struct ethtool_tcpip6_spec *ip6_entry = &rule->h_u.tcp_ip6_spec;
	struct ethtool_tcpip6_spec *ip6_mask = &rule->m_u.tcp_ip6_spec;
	struct ethtool_usrip6_spec *uip6_entry = &rule->h_u.usr_ip6_spec;
	struct ethtool_usrip6_spec *uip6_mask = &rule->m_u.usr_ip6_spec;
844 845
	struct ethhdr *mac_entry = &rule->h_u.ether_spec;
	struct ethhdr *mac_mask = &rule->m_u.ether_spec;
846 847 848 849 850 851 852 853
	struct efx_filter_spec spec;
	int rc;

	rc = efx_filter_get_filter_safe(efx, EFX_FILTER_PRI_MANUAL,
					rule->location, &spec);
	if (rc)
		return rc;

B
Ben Hutchings 已提交
854
	if (spec.dmaq_id == EFX_FILTER_RX_DMAQ_ID_DROP)
855 856 857 858
		rule->ring_cookie = RX_CLS_FLOW_DISC;
	else
		rule->ring_cookie = spec.dmaq_id;

859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885
	if ((spec.match_flags & EFX_FILTER_MATCH_ETHER_TYPE) &&
	    spec.ether_type == htons(ETH_P_IP) &&
	    (spec.match_flags & EFX_FILTER_MATCH_IP_PROTO) &&
	    (spec.ip_proto == IPPROTO_TCP || spec.ip_proto == IPPROTO_UDP) &&
	    !(spec.match_flags &
	      ~(EFX_FILTER_MATCH_ETHER_TYPE | EFX_FILTER_MATCH_OUTER_VID |
		EFX_FILTER_MATCH_LOC_HOST | EFX_FILTER_MATCH_REM_HOST |
		EFX_FILTER_MATCH_IP_PROTO |
		EFX_FILTER_MATCH_LOC_PORT | EFX_FILTER_MATCH_REM_PORT))) {
		rule->flow_type = ((spec.ip_proto == IPPROTO_TCP) ?
				   TCP_V4_FLOW : UDP_V4_FLOW);
		if (spec.match_flags & EFX_FILTER_MATCH_LOC_HOST) {
			ip_entry->ip4dst = spec.loc_host[0];
			ip_mask->ip4dst = IP4_ADDR_FULL_MASK;
		}
		if (spec.match_flags & EFX_FILTER_MATCH_REM_HOST) {
			ip_entry->ip4src = spec.rem_host[0];
			ip_mask->ip4src = IP4_ADDR_FULL_MASK;
		}
		if (spec.match_flags & EFX_FILTER_MATCH_LOC_PORT) {
			ip_entry->pdst = spec.loc_port;
			ip_mask->pdst = PORT_FULL_MASK;
		}
		if (spec.match_flags & EFX_FILTER_MATCH_REM_PORT) {
			ip_entry->psrc = spec.rem_port;
			ip_mask->psrc = PORT_FULL_MASK;
		}
886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914
	} else if ((spec.match_flags & EFX_FILTER_MATCH_ETHER_TYPE) &&
	    spec.ether_type == htons(ETH_P_IPV6) &&
	    (spec.match_flags & EFX_FILTER_MATCH_IP_PROTO) &&
	    (spec.ip_proto == IPPROTO_TCP || spec.ip_proto == IPPROTO_UDP) &&
	    !(spec.match_flags &
	      ~(EFX_FILTER_MATCH_ETHER_TYPE | EFX_FILTER_MATCH_OUTER_VID |
		EFX_FILTER_MATCH_LOC_HOST | EFX_FILTER_MATCH_REM_HOST |
		EFX_FILTER_MATCH_IP_PROTO |
		EFX_FILTER_MATCH_LOC_PORT | EFX_FILTER_MATCH_REM_PORT))) {
		rule->flow_type = ((spec.ip_proto == IPPROTO_TCP) ?
				   TCP_V6_FLOW : UDP_V6_FLOW);
		if (spec.match_flags & EFX_FILTER_MATCH_LOC_HOST) {
			memcpy(ip6_entry->ip6dst, spec.loc_host,
			       sizeof(ip6_entry->ip6dst));
			ip6_fill_mask(ip6_mask->ip6dst);
		}
		if (spec.match_flags & EFX_FILTER_MATCH_REM_HOST) {
			memcpy(ip6_entry->ip6src, spec.rem_host,
			       sizeof(ip6_entry->ip6src));
			ip6_fill_mask(ip6_mask->ip6src);
		}
		if (spec.match_flags & EFX_FILTER_MATCH_LOC_PORT) {
			ip6_entry->pdst = spec.loc_port;
			ip6_mask->pdst = PORT_FULL_MASK;
		}
		if (spec.match_flags & EFX_FILTER_MATCH_REM_PORT) {
			ip6_entry->psrc = spec.rem_port;
			ip6_mask->psrc = PORT_FULL_MASK;
		}
915 916 917 918
	} else if (!(spec.match_flags &
		     ~(EFX_FILTER_MATCH_LOC_MAC | EFX_FILTER_MATCH_LOC_MAC_IG |
		       EFX_FILTER_MATCH_REM_MAC | EFX_FILTER_MATCH_ETHER_TYPE |
		       EFX_FILTER_MATCH_OUTER_VID))) {
919
		rule->flow_type = ETHER_FLOW;
920 921
		if (spec.match_flags &
		    (EFX_FILTER_MATCH_LOC_MAC | EFX_FILTER_MATCH_LOC_MAC_IG)) {
922
			ether_addr_copy(mac_entry->h_dest, spec.loc_mac);
923
			if (spec.match_flags & EFX_FILTER_MATCH_LOC_MAC)
924
				eth_broadcast_addr(mac_mask->h_dest);
925
			else
926 927
				ether_addr_copy(mac_mask->h_dest,
						mac_addr_ig_mask);
928
		}
929
		if (spec.match_flags & EFX_FILTER_MATCH_REM_MAC) {
930 931
			ether_addr_copy(mac_entry->h_source, spec.rem_mac);
			eth_broadcast_addr(mac_mask->h_source);
932 933 934 935 936
		}
		if (spec.match_flags & EFX_FILTER_MATCH_ETHER_TYPE) {
			mac_entry->h_proto = spec.ether_type;
			mac_mask->h_proto = ETHER_TYPE_FULL_MASK;
		}
937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977
	} else if (spec.match_flags & EFX_FILTER_MATCH_ETHER_TYPE &&
		   spec.ether_type == htons(ETH_P_IP) &&
		   !(spec.match_flags &
		     ~(EFX_FILTER_MATCH_ETHER_TYPE | EFX_FILTER_MATCH_OUTER_VID |
		       EFX_FILTER_MATCH_LOC_HOST | EFX_FILTER_MATCH_REM_HOST |
		       EFX_FILTER_MATCH_IP_PROTO))) {
		rule->flow_type = IPV4_USER_FLOW;
		uip_entry->ip_ver = ETH_RX_NFC_IP4;
		if (spec.match_flags & EFX_FILTER_MATCH_IP_PROTO) {
			uip_mask->proto = IP_PROTO_FULL_MASK;
			uip_entry->proto = spec.ip_proto;
		}
		if (spec.match_flags & EFX_FILTER_MATCH_LOC_HOST) {
			uip_entry->ip4dst = spec.loc_host[0];
			uip_mask->ip4dst = IP4_ADDR_FULL_MASK;
		}
		if (spec.match_flags & EFX_FILTER_MATCH_REM_HOST) {
			uip_entry->ip4src = spec.rem_host[0];
			uip_mask->ip4src = IP4_ADDR_FULL_MASK;
		}
	} else if (spec.match_flags & EFX_FILTER_MATCH_ETHER_TYPE &&
		   spec.ether_type == htons(ETH_P_IPV6) &&
		   !(spec.match_flags &
		     ~(EFX_FILTER_MATCH_ETHER_TYPE | EFX_FILTER_MATCH_OUTER_VID |
		       EFX_FILTER_MATCH_LOC_HOST | EFX_FILTER_MATCH_REM_HOST |
		       EFX_FILTER_MATCH_IP_PROTO))) {
		rule->flow_type = IPV6_USER_FLOW;
		if (spec.match_flags & EFX_FILTER_MATCH_IP_PROTO) {
			uip6_mask->l4_proto = IP_PROTO_FULL_MASK;
			uip6_entry->l4_proto = spec.ip_proto;
		}
		if (spec.match_flags & EFX_FILTER_MATCH_LOC_HOST) {
			memcpy(uip6_entry->ip6dst, spec.loc_host,
			       sizeof(uip6_entry->ip6dst));
			ip6_fill_mask(uip6_mask->ip6dst);
		}
		if (spec.match_flags & EFX_FILTER_MATCH_REM_HOST) {
			memcpy(uip6_entry->ip6src, spec.rem_host,
			       sizeof(uip6_entry->ip6src));
			ip6_fill_mask(uip6_mask->ip6src);
		}
978 979 980 981
	} else {
		/* The above should handle all filters that we insert */
		WARN_ON(1);
		return -EINVAL;
982 983
	}

984 985 986 987
	if (spec.match_flags & EFX_FILTER_MATCH_OUTER_VID) {
		rule->flow_type |= FLOW_EXT;
		rule->h_ext.vlan_tci = spec.outer_vid;
		rule->m_ext.vlan_tci = htons(0xfff);
988
	}
989

990 991 992 993 994
	if (spec.flags & EFX_FILTER_FLAG_RX_RSS) {
		rule->flow_type |= FLOW_RSS;
		*rss_context = spec.rss_context;
	}

995 996 997
	return rc;
}

998 999
static int
efx_ethtool_get_rxnfc(struct net_device *net_dev,
1000
		      struct ethtool_rxnfc *info, u32 *rule_locs)
1001 1002
{
	struct efx_nic *efx = netdev_priv(net_dev);
1003
	u32 rss_context = 0;
1004
	s32 rc = 0;
1005 1006 1007 1008 1009 1010 1011

	switch (info->cmd) {
	case ETHTOOL_GRXRINGS:
		info->data = efx->n_rx_channels;
		return 0;

	case ETHTOOL_GRXFH: {
1012 1013
		struct efx_rss_context *ctx = &efx->rss_context;

1014
		mutex_lock(&efx->rss_lock);
1015
		if (info->flow_type & FLOW_RSS && info->rss_context) {
1016 1017 1018 1019 1020
			ctx = efx_find_rss_context_entry(efx, info->rss_context);
			if (!ctx) {
				rc = -ENOENT;
				goto out_unlock;
			}
1021
		}
1022
		info->data = 0;
1023
		if (!efx_rss_active(ctx)) /* No RSS */
1024
			goto out_unlock;
1025
		switch (info->flow_type & ~FLOW_RSS) {
1026
		case UDP_V4_FLOW:
1027
			if (ctx->rx_hash_udp_4tuple)
1028
				/* fall through */
1029
		case TCP_V4_FLOW:
1030
				info->data |= RXH_L4_B_0_1 | RXH_L4_B_2_3;
1031 1032 1033 1034 1035 1036
			/* fall through */
		case SCTP_V4_FLOW:
		case AH_ESP_V4_FLOW:
		case IPV4_FLOW:
			info->data |= RXH_IP_SRC | RXH_IP_DST;
			break;
1037
		case UDP_V6_FLOW:
1038
			if (ctx->rx_hash_udp_4tuple)
1039
				/* fall through */
1040
		case TCP_V6_FLOW:
1041
				info->data |= RXH_L4_B_0_1 | RXH_L4_B_2_3;
1042 1043 1044 1045 1046 1047 1048 1049 1050
			/* fall through */
		case SCTP_V6_FLOW:
		case AH_ESP_V6_FLOW:
		case IPV6_FLOW:
			info->data |= RXH_IP_SRC | RXH_IP_DST;
			break;
		default:
			break;
		}
1051 1052 1053
out_unlock:
		mutex_unlock(&efx->rss_lock);
		return rc;
1054 1055
	}

1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067
	case ETHTOOL_GRXCLSRLCNT:
		info->data = efx_filter_get_rx_id_limit(efx);
		if (info->data == 0)
			return -EOPNOTSUPP;
		info->data |= RX_CLS_LOC_SPECIAL;
		info->rule_cnt =
			efx_filter_count_rx_used(efx, EFX_FILTER_PRI_MANUAL);
		return 0;

	case ETHTOOL_GRXCLSRULE:
		if (efx_filter_get_rx_id_limit(efx) == 0)
			return -EOPNOTSUPP;
1068 1069 1070 1071 1072 1073
		rc = efx_ethtool_get_class_rule(efx, &info->fs, &rss_context);
		if (rc < 0)
			return rc;
		if (info->fs.flow_type & FLOW_RSS)
			info->rss_context = rss_context;
		return 0;
1074

1075
	case ETHTOOL_GRXCLSRLALL:
1076 1077 1078 1079 1080 1081 1082 1083 1084 1085
		info->data = efx_filter_get_rx_id_limit(efx);
		if (info->data == 0)
			return -EOPNOTSUPP;
		rc = efx_filter_get_rx_ids(efx, EFX_FILTER_PRI_MANUAL,
					   rule_locs, info->rule_cnt);
		if (rc < 0)
			return rc;
		info->rule_cnt = rc;
		return 0;

1086 1087 1088 1089 1090
	default:
		return -EOPNOTSUPP;
	}
}

1091 1092 1093 1094 1095 1096 1097 1098 1099 1100
static inline bool ip6_mask_is_full(__be32 mask[4])
{
	return !~(mask[0] & mask[1] & mask[2] & mask[3]);
}

static inline bool ip6_mask_is_empty(__be32 mask[4])
{
	return !(mask[0] | mask[1] | mask[2] | mask[3]);
}

1101
static int efx_ethtool_set_class_rule(struct efx_nic *efx,
1102 1103
				      struct ethtool_rx_flow_spec *rule,
				      u32 rss_context)
1104
{
1105 1106
	struct ethtool_tcpip4_spec *ip_entry = &rule->h_u.tcp_ip4_spec;
	struct ethtool_tcpip4_spec *ip_mask = &rule->m_u.tcp_ip4_spec;
1107 1108 1109 1110 1111 1112
	struct ethtool_usrip4_spec *uip_entry = &rule->h_u.usr_ip4_spec;
	struct ethtool_usrip4_spec *uip_mask = &rule->m_u.usr_ip4_spec;
	struct ethtool_tcpip6_spec *ip6_entry = &rule->h_u.tcp_ip6_spec;
	struct ethtool_tcpip6_spec *ip6_mask = &rule->m_u.tcp_ip6_spec;
	struct ethtool_usrip6_spec *uip6_entry = &rule->h_u.usr_ip6_spec;
	struct ethtool_usrip6_spec *uip6_mask = &rule->m_u.usr_ip6_spec;
1113
	u32 flow_type = rule->flow_type & ~(FLOW_EXT | FLOW_RSS);
1114 1115
	struct ethhdr *mac_entry = &rule->h_u.ether_spec;
	struct ethhdr *mac_mask = &rule->m_u.ether_spec;
1116
	enum efx_filter_flags flags = 0;
1117
	struct efx_filter_spec spec;
1118
	int rc;
1119

1120
	/* Check that user wants us to choose the location */
1121
	if (rule->location != RX_CLS_LOC_ANY)
1122 1123
		return -EINVAL;

1124 1125 1126
	/* Range-check ring_cookie */
	if (rule->ring_cookie >= efx->n_rx_channels &&
	    rule->ring_cookie != RX_CLS_FLOW_DISC)
1127 1128
		return -EINVAL;

1129 1130
	/* Check for unsupported extensions */
	if ((rule->flow_type & FLOW_EXT) &&
1131
	    (rule->m_ext.vlan_etype || rule->m_ext.data[0] ||
1132 1133 1134
	     rule->m_ext.data[1]))
		return -EINVAL;

1135 1136 1137 1138 1139 1140
	if (efx->rx_scatter)
		flags |= EFX_FILTER_FLAG_RX_SCATTER;
	if (rule->flow_type & FLOW_RSS)
		flags |= EFX_FILTER_FLAG_RX_RSS;

	efx_filter_init_rx(&spec, EFX_FILTER_PRI_MANUAL, flags,
1141
			   (rule->ring_cookie == RX_CLS_FLOW_DISC) ?
B
Ben Hutchings 已提交
1142
			   EFX_FILTER_RX_DMAQ_ID_DROP : rule->ring_cookie);
1143

1144 1145 1146
	if (rule->flow_type & FLOW_RSS)
		spec.rss_context = rss_context;

1147
	switch (flow_type) {
1148
	case TCP_V4_FLOW:
1149 1150 1151 1152
	case UDP_V4_FLOW:
		spec.match_flags = (EFX_FILTER_MATCH_ETHER_TYPE |
				    EFX_FILTER_MATCH_IP_PROTO);
		spec.ether_type = htons(ETH_P_IP);
1153 1154
		spec.ip_proto = flow_type == TCP_V4_FLOW ? IPPROTO_TCP
							 : IPPROTO_UDP;
1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179
		if (ip_mask->ip4dst) {
			if (ip_mask->ip4dst != IP4_ADDR_FULL_MASK)
				return -EINVAL;
			spec.match_flags |= EFX_FILTER_MATCH_LOC_HOST;
			spec.loc_host[0] = ip_entry->ip4dst;
		}
		if (ip_mask->ip4src) {
			if (ip_mask->ip4src != IP4_ADDR_FULL_MASK)
				return -EINVAL;
			spec.match_flags |= EFX_FILTER_MATCH_REM_HOST;
			spec.rem_host[0] = ip_entry->ip4src;
		}
		if (ip_mask->pdst) {
			if (ip_mask->pdst != PORT_FULL_MASK)
				return -EINVAL;
			spec.match_flags |= EFX_FILTER_MATCH_LOC_PORT;
			spec.loc_port = ip_entry->pdst;
		}
		if (ip_mask->psrc) {
			if (ip_mask->psrc != PORT_FULL_MASK)
				return -EINVAL;
			spec.match_flags |= EFX_FILTER_MATCH_REM_PORT;
			spec.rem_port = ip_entry->psrc;
		}
		if (ip_mask->tos)
1180 1181
			return -EINVAL;
		break;
1182

1183 1184 1185 1186 1187
	case TCP_V6_FLOW:
	case UDP_V6_FLOW:
		spec.match_flags = (EFX_FILTER_MATCH_ETHER_TYPE |
				    EFX_FILTER_MATCH_IP_PROTO);
		spec.ether_type = htons(ETH_P_IPV6);
1188 1189
		spec.ip_proto = flow_type == TCP_V6_FLOW ? IPPROTO_TCP
							 : IPPROTO_UDP;
1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268
		if (!ip6_mask_is_empty(ip6_mask->ip6dst)) {
			if (!ip6_mask_is_full(ip6_mask->ip6dst))
				return -EINVAL;
			spec.match_flags |= EFX_FILTER_MATCH_LOC_HOST;
			memcpy(spec.loc_host, ip6_entry->ip6dst, sizeof(spec.loc_host));
		}
		if (!ip6_mask_is_empty(ip6_mask->ip6src)) {
			if (!ip6_mask_is_full(ip6_mask->ip6src))
				return -EINVAL;
			spec.match_flags |= EFX_FILTER_MATCH_REM_HOST;
			memcpy(spec.rem_host, ip6_entry->ip6src, sizeof(spec.rem_host));
		}
		if (ip6_mask->pdst) {
			if (ip6_mask->pdst != PORT_FULL_MASK)
				return -EINVAL;
			spec.match_flags |= EFX_FILTER_MATCH_LOC_PORT;
			spec.loc_port = ip6_entry->pdst;
		}
		if (ip6_mask->psrc) {
			if (ip6_mask->psrc != PORT_FULL_MASK)
				return -EINVAL;
			spec.match_flags |= EFX_FILTER_MATCH_REM_PORT;
			spec.rem_port = ip6_entry->psrc;
		}
		if (ip6_mask->tclass)
			return -EINVAL;
		break;

	case IPV4_USER_FLOW:
		if (uip_mask->l4_4_bytes || uip_mask->tos || uip_mask->ip_ver ||
		    uip_entry->ip_ver != ETH_RX_NFC_IP4)
			return -EINVAL;
		spec.match_flags = EFX_FILTER_MATCH_ETHER_TYPE;
		spec.ether_type = htons(ETH_P_IP);
		if (uip_mask->ip4dst) {
			if (uip_mask->ip4dst != IP4_ADDR_FULL_MASK)
				return -EINVAL;
			spec.match_flags |= EFX_FILTER_MATCH_LOC_HOST;
			spec.loc_host[0] = uip_entry->ip4dst;
		}
		if (uip_mask->ip4src) {
			if (uip_mask->ip4src != IP4_ADDR_FULL_MASK)
				return -EINVAL;
			spec.match_flags |= EFX_FILTER_MATCH_REM_HOST;
			spec.rem_host[0] = uip_entry->ip4src;
		}
		if (uip_mask->proto) {
			if (uip_mask->proto != IP_PROTO_FULL_MASK)
				return -EINVAL;
			spec.match_flags |= EFX_FILTER_MATCH_IP_PROTO;
			spec.ip_proto = uip_entry->proto;
		}
		break;

	case IPV6_USER_FLOW:
		if (uip6_mask->l4_4_bytes || uip6_mask->tclass)
			return -EINVAL;
		spec.match_flags = EFX_FILTER_MATCH_ETHER_TYPE;
		spec.ether_type = htons(ETH_P_IPV6);
		if (!ip6_mask_is_empty(uip6_mask->ip6dst)) {
			if (!ip6_mask_is_full(uip6_mask->ip6dst))
				return -EINVAL;
			spec.match_flags |= EFX_FILTER_MATCH_LOC_HOST;
			memcpy(spec.loc_host, uip6_entry->ip6dst, sizeof(spec.loc_host));
		}
		if (!ip6_mask_is_empty(uip6_mask->ip6src)) {
			if (!ip6_mask_is_full(uip6_mask->ip6src))
				return -EINVAL;
			spec.match_flags |= EFX_FILTER_MATCH_REM_HOST;
			memcpy(spec.rem_host, uip6_entry->ip6src, sizeof(spec.rem_host));
		}
		if (uip6_mask->l4_proto) {
			if (uip6_mask->l4_proto != IP_PROTO_FULL_MASK)
				return -EINVAL;
			spec.match_flags |= EFX_FILTER_MATCH_IP_PROTO;
			spec.ip_proto = uip6_entry->l4_proto;
		}
		break;

1269 1270 1271 1272 1273 1274 1275
	case ETHER_FLOW:
		if (!is_zero_ether_addr(mac_mask->h_dest)) {
			if (ether_addr_equal(mac_mask->h_dest,
					     mac_addr_ig_mask))
				spec.match_flags |= EFX_FILTER_MATCH_LOC_MAC_IG;
			else if (is_broadcast_ether_addr(mac_mask->h_dest))
				spec.match_flags |= EFX_FILTER_MATCH_LOC_MAC;
1276
			else
1277
				return -EINVAL;
1278
			ether_addr_copy(spec.loc_mac, mac_entry->h_dest);
1279
		}
1280 1281 1282 1283
		if (!is_zero_ether_addr(mac_mask->h_source)) {
			if (!is_broadcast_ether_addr(mac_mask->h_source))
				return -EINVAL;
			spec.match_flags |= EFX_FILTER_MATCH_REM_MAC;
1284
			ether_addr_copy(spec.rem_mac, mac_entry->h_source);
1285 1286 1287 1288 1289 1290
		}
		if (mac_mask->h_proto) {
			if (mac_mask->h_proto != ETHER_TYPE_FULL_MASK)
				return -EINVAL;
			spec.match_flags |= EFX_FILTER_MATCH_ETHER_TYPE;
			spec.ether_type = mac_entry->h_proto;
1291
		}
1292
		break;
1293

1294 1295 1296 1297
	default:
		return -EINVAL;
	}

1298 1299 1300 1301 1302 1303 1304
	if ((rule->flow_type & FLOW_EXT) && rule->m_ext.vlan_tci) {
		if (rule->m_ext.vlan_tci != htons(0xfff))
			return -EINVAL;
		spec.match_flags |= EFX_FILTER_MATCH_OUTER_VID;
		spec.outer_vid = rule->h_ext.vlan_tci;
	}

1305 1306 1307
	rc = efx_filter_insert_filter(efx, &spec, true);
	if (rc < 0)
		return rc;
1308

1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322
	rule->location = rc;
	return 0;
}

static int efx_ethtool_set_rxnfc(struct net_device *net_dev,
				 struct ethtool_rxnfc *info)
{
	struct efx_nic *efx = netdev_priv(net_dev);

	if (efx_filter_get_rx_id_limit(efx) == 0)
		return -EOPNOTSUPP;

	switch (info->cmd) {
	case ETHTOOL_SRXCLSRLINS:
1323 1324
		return efx_ethtool_set_class_rule(efx, &info->fs,
						  info->rss_context);
1325 1326 1327 1328 1329 1330 1331 1332

	case ETHTOOL_SRXCLSRLDEL:
		return efx_filter_remove_id_safe(efx, EFX_FILTER_PRI_MANUAL,
						 info->fs.location);

	default:
		return -EOPNOTSUPP;
	}
1333 1334
}

1335
static u32 efx_ethtool_get_rxfh_indir_size(struct net_device *net_dev)
1336 1337 1338
{
	struct efx_nic *efx = netdev_priv(net_dev);

1339 1340 1341
	if (efx->n_rx_channels == 1)
		return 0;
	return ARRAY_SIZE(efx->rss_context.rx_indir_table);
1342 1343
}

1344 1345 1346 1347 1348 1349 1350
static u32 efx_ethtool_get_rxfh_key_size(struct net_device *net_dev)
{
	struct efx_nic *efx = netdev_priv(net_dev);

	return efx->type->rx_hash_key_size;
}

1351 1352
static int efx_ethtool_get_rxfh(struct net_device *net_dev, u32 *indir, u8 *key,
				u8 *hfunc)
1353 1354
{
	struct efx_nic *efx = netdev_priv(net_dev);
1355 1356 1357 1358 1359
	int rc;

	rc = efx->type->rx_pull_rss_config(efx);
	if (rc)
		return rc;
1360

1361 1362 1363
	if (hfunc)
		*hfunc = ETH_RSS_HASH_TOP;
	if (indir)
1364 1365
		memcpy(indir, efx->rss_context.rx_indir_table,
		       sizeof(efx->rss_context.rx_indir_table));
1366
	if (key)
1367 1368
		memcpy(key, efx->rss_context.rx_hash_key,
		       efx->type->rx_hash_key_size);
1369 1370 1371
	return 0;
}

1372 1373
static int efx_ethtool_set_rxfh(struct net_device *net_dev, const u32 *indir,
				const u8 *key, const u8 hfunc)
1374 1375 1376
{
	struct efx_nic *efx = netdev_priv(net_dev);

1377 1378
	/* Hash function is Toeplitz, cannot be changed */
	if (hfunc != ETH_RSS_HASH_NO_CHANGE && hfunc != ETH_RSS_HASH_TOP)
1379
		return -EOPNOTSUPP;
1380
	if (!indir && !key)
1381
		return 0;
1382

1383
	if (!key)
1384
		key = efx->rss_context.rx_hash_key;
1385
	if (!indir)
1386
		indir = efx->rss_context.rx_indir_table;
1387 1388

	return efx->type->rx_push_rss_config(efx, true, indir, key);
1389 1390
}

1391 1392 1393 1394 1395
static int efx_ethtool_get_rxfh_context(struct net_device *net_dev, u32 *indir,
					u8 *key, u8 *hfunc, u32 rss_context)
{
	struct efx_nic *efx = netdev_priv(net_dev);
	struct efx_rss_context *ctx;
1396
	int rc = 0;
1397 1398 1399

	if (!efx->type->rx_pull_rss_context_config)
		return -EOPNOTSUPP;
1400 1401 1402 1403 1404 1405 1406

	mutex_lock(&efx->rss_lock);
	ctx = efx_find_rss_context_entry(efx, rss_context);
	if (!ctx) {
		rc = -ENOENT;
		goto out_unlock;
	}
1407 1408
	rc = efx->type->rx_pull_rss_context_config(efx, ctx);
	if (rc)
1409
		goto out_unlock;
1410 1411 1412 1413 1414 1415 1416

	if (hfunc)
		*hfunc = ETH_RSS_HASH_TOP;
	if (indir)
		memcpy(indir, ctx->rx_indir_table, sizeof(ctx->rx_indir_table));
	if (key)
		memcpy(key, ctx->rx_hash_key, efx->type->rx_hash_key_size);
1417 1418 1419
out_unlock:
	mutex_unlock(&efx->rss_lock);
	return rc;
1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436
}

static int efx_ethtool_set_rxfh_context(struct net_device *net_dev,
					const u32 *indir, const u8 *key,
					const u8 hfunc, u32 *rss_context,
					bool delete)
{
	struct efx_nic *efx = netdev_priv(net_dev);
	struct efx_rss_context *ctx;
	bool allocated = false;
	int rc;

	if (!efx->type->rx_push_rss_context_config)
		return -EOPNOTSUPP;
	/* Hash function is Toeplitz, cannot be changed */
	if (hfunc != ETH_RSS_HASH_NO_CHANGE && hfunc != ETH_RSS_HASH_TOP)
		return -EOPNOTSUPP;
1437 1438 1439

	mutex_lock(&efx->rss_lock);

1440
	if (*rss_context == ETH_RXFH_CONTEXT_ALLOC) {
1441
		if (delete) {
1442
			/* alloc + delete == Nothing to do */
1443 1444 1445 1446 1447 1448 1449 1450
			rc = -EINVAL;
			goto out_unlock;
		}
		ctx = efx_alloc_rss_context_entry(efx);
		if (!ctx) {
			rc = -ENOMEM;
			goto out_unlock;
		}
1451 1452 1453 1454 1455 1456
		ctx->context_id = EFX_EF10_RSS_CONTEXT_INVALID;
		/* Initialise indir table and key to defaults */
		efx_set_default_rx_indir_table(efx, ctx);
		netdev_rss_key_fill(ctx->rx_hash_key, sizeof(ctx->rx_hash_key));
		allocated = true;
	} else {
1457 1458 1459 1460 1461
		ctx = efx_find_rss_context_entry(efx, *rss_context);
		if (!ctx) {
			rc = -ENOENT;
			goto out_unlock;
		}
1462 1463 1464 1465 1466 1467 1468
	}

	if (delete) {
		/* delete this context */
		rc = efx->type->rx_push_rss_context_config(efx, ctx, NULL, NULL);
		if (!rc)
			efx_free_rss_context_entry(ctx);
1469
		goto out_unlock;
1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481
	}

	if (!key)
		key = ctx->rx_hash_key;
	if (!indir)
		indir = ctx->rx_indir_table;

	rc = efx->type->rx_push_rss_context_config(efx, ctx, indir, key);
	if (rc && allocated)
		efx_free_rss_context_entry(ctx);
	else
		*rss_context = ctx->user_id;
1482 1483
out_unlock:
	mutex_unlock(&efx->rss_lock);
1484 1485 1486
	return rc;
}

1487 1488
static int efx_ethtool_get_ts_info(struct net_device *net_dev,
				   struct ethtool_ts_info *ts_info)
1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500
{
	struct efx_nic *efx = netdev_priv(net_dev);

	/* Software capabilities */
	ts_info->so_timestamping = (SOF_TIMESTAMPING_RX_SOFTWARE |
				    SOF_TIMESTAMPING_SOFTWARE);
	ts_info->phc_index = -1;

	efx_ptp_get_ts_info(efx, ts_info);
	return 0;
}

1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533
static int efx_ethtool_get_module_eeprom(struct net_device *net_dev,
					 struct ethtool_eeprom *ee,
					 u8 *data)
{
	struct efx_nic *efx = netdev_priv(net_dev);
	int ret;

	if (!efx->phy_op || !efx->phy_op->get_module_eeprom)
		return -EOPNOTSUPP;

	mutex_lock(&efx->mac_lock);
	ret = efx->phy_op->get_module_eeprom(efx, ee, data);
	mutex_unlock(&efx->mac_lock);

	return ret;
}

static int efx_ethtool_get_module_info(struct net_device *net_dev,
				       struct ethtool_modinfo *modinfo)
{
	struct efx_nic *efx = netdev_priv(net_dev);
	int ret;

	if (!efx->phy_op || !efx->phy_op->get_module_info)
		return -EOPNOTSUPP;

	mutex_lock(&efx->mac_lock);
	ret = efx->phy_op->get_module_info(efx, modinfo);
	mutex_unlock(&efx->mac_lock);

	return ret;
}

1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563
static int efx_ethtool_get_fecparam(struct net_device *net_dev,
				    struct ethtool_fecparam *fecparam)
{
	struct efx_nic *efx = netdev_priv(net_dev);
	int rc;

	if (!efx->phy_op || !efx->phy_op->get_fecparam)
		return -EOPNOTSUPP;
	mutex_lock(&efx->mac_lock);
	rc = efx->phy_op->get_fecparam(efx, fecparam);
	mutex_unlock(&efx->mac_lock);

	return rc;
}

static int efx_ethtool_set_fecparam(struct net_device *net_dev,
				    struct ethtool_fecparam *fecparam)
{
	struct efx_nic *efx = netdev_priv(net_dev);
	int rc;

	if (!efx->phy_op || !efx->phy_op->get_fecparam)
		return -EOPNOTSUPP;
	mutex_lock(&efx->mac_lock);
	rc = efx->phy_op->set_fecparam(efx, fecparam);
	mutex_unlock(&efx->mac_lock);

	return rc;
}

1564
const struct ethtool_ops efx_ethtool_ops = {
1565
	.get_drvinfo		= efx_ethtool_get_drvinfo,
1566 1567
	.get_regs_len		= efx_ethtool_get_regs_len,
	.get_regs		= efx_ethtool_get_regs,
1568 1569
	.get_msglevel		= efx_ethtool_get_msglevel,
	.set_msglevel		= efx_ethtool_set_msglevel,
1570
	.nway_reset		= efx_ethtool_nway_reset,
1571
	.get_link		= ethtool_op_get_link,
1572 1573
	.get_coalesce		= efx_ethtool_get_coalesce,
	.set_coalesce		= efx_ethtool_set_coalesce,
1574 1575
	.get_ringparam		= efx_ethtool_get_ringparam,
	.set_ringparam		= efx_ethtool_set_ringparam,
1576 1577
	.get_pauseparam         = efx_ethtool_get_pauseparam,
	.set_pauseparam         = efx_ethtool_set_pauseparam,
1578
	.get_sset_count		= efx_ethtool_get_sset_count,
1579
	.self_test		= efx_ethtool_self_test,
1580
	.get_strings		= efx_ethtool_get_strings,
1581
	.set_phys_id		= efx_ethtool_phys_id,
1582
	.get_ethtool_stats	= efx_ethtool_get_stats,
1583 1584
	.get_wol                = efx_ethtool_get_wol,
	.set_wol                = efx_ethtool_set_wol,
1585
	.reset			= efx_ethtool_reset,
1586
	.get_rxnfc		= efx_ethtool_get_rxnfc,
1587
	.set_rxnfc		= efx_ethtool_set_rxnfc,
1588
	.get_rxfh_indir_size	= efx_ethtool_get_rxfh_indir_size,
1589
	.get_rxfh_key_size	= efx_ethtool_get_rxfh_key_size,
1590 1591
	.get_rxfh		= efx_ethtool_get_rxfh,
	.set_rxfh		= efx_ethtool_set_rxfh,
1592 1593
	.get_rxfh_context	= efx_ethtool_get_rxfh_context,
	.set_rxfh_context	= efx_ethtool_set_rxfh_context,
1594
	.get_ts_info		= efx_ethtool_get_ts_info,
1595 1596
	.get_module_info	= efx_ethtool_get_module_info,
	.get_module_eeprom	= efx_ethtool_get_module_eeprom,
1597 1598
	.get_link_ksettings	= efx_ethtool_get_link_ksettings,
	.set_link_ksettings	= efx_ethtool_set_link_ksettings,
1599 1600
	.get_fecparam		= efx_ethtool_get_fecparam,
	.set_fecparam		= efx_ethtool_set_fecparam,
1601
};