Linux Audio

Check our new training course

Buildroot integration, development and maintenance

Need a Buildroot system for your embedded project?
Loading...
v3.15
 
   1/****************************************************************************
   2 * Driver for Solarflare network controllers and boards
   3 * Copyright 2005-2006 Fen Systems Ltd.
   4 * Copyright 2006-2013 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
  11#include <linux/netdevice.h>
  12#include <linux/ethtool.h>
  13#include <linux/rtnetlink.h>
  14#include <linux/in.h>
  15#include "net_driver.h"
  16#include "workarounds.h"
  17#include "selftest.h"
  18#include "efx.h"
  19#include "filter.h"
  20#include "nic.h"
  21
  22struct efx_sw_stat_desc {
  23	const char *name;
  24	enum {
  25		EFX_ETHTOOL_STAT_SOURCE_nic,
  26		EFX_ETHTOOL_STAT_SOURCE_channel,
  27		EFX_ETHTOOL_STAT_SOURCE_tx_queue
  28	} source;
  29	unsigned offset;
  30	u64(*get_stat) (void *field); /* Reader function */
  31};
  32
  33/* Initialiser for a struct efx_sw_stat_desc with type-checking */
  34#define EFX_ETHTOOL_STAT(stat_name, source_name, field, field_type, \
  35				get_stat_function) {			\
  36	.name = #stat_name,						\
  37	.source = EFX_ETHTOOL_STAT_SOURCE_##source_name,		\
  38	.offset = ((((field_type *) 0) ==				\
  39		      &((struct efx_##source_name *)0)->field) ?	\
  40		    offsetof(struct efx_##source_name, field) :		\
  41		    offsetof(struct efx_##source_name, field)),		\
  42	.get_stat = get_stat_function,					\
  43}
  44
  45static u64 efx_get_uint_stat(void *field)
  46{
  47	return *(unsigned int *)field;
  48}
  49
  50static u64 efx_get_atomic_stat(void *field)
  51{
  52	return atomic_read((atomic_t *) field);
  53}
  54
  55#define EFX_ETHTOOL_ATOMIC_NIC_ERROR_STAT(field)		\
  56	EFX_ETHTOOL_STAT(field, nic, field,			\
  57			 atomic_t, efx_get_atomic_stat)
  58
  59#define EFX_ETHTOOL_UINT_CHANNEL_STAT(field)			\
  60	EFX_ETHTOOL_STAT(field, channel, n_##field,		\
  61			 unsigned int, efx_get_uint_stat)
  62
  63#define EFX_ETHTOOL_UINT_TXQ_STAT(field)			\
  64	EFX_ETHTOOL_STAT(tx_##field, tx_queue, field,		\
  65			 unsigned int, efx_get_uint_stat)
  66
  67static const struct efx_sw_stat_desc efx_sw_stat_desc[] = {
  68	EFX_ETHTOOL_UINT_TXQ_STAT(merge_events),
  69	EFX_ETHTOOL_UINT_TXQ_STAT(tso_bursts),
  70	EFX_ETHTOOL_UINT_TXQ_STAT(tso_long_headers),
  71	EFX_ETHTOOL_UINT_TXQ_STAT(tso_packets),
 
  72	EFX_ETHTOOL_UINT_TXQ_STAT(pushes),
  73	EFX_ETHTOOL_UINT_TXQ_STAT(pio_packets),
 
  74	EFX_ETHTOOL_ATOMIC_NIC_ERROR_STAT(rx_reset),
  75	EFX_ETHTOOL_UINT_CHANNEL_STAT(rx_tobe_disc),
  76	EFX_ETHTOOL_UINT_CHANNEL_STAT(rx_ip_hdr_chksum_err),
  77	EFX_ETHTOOL_UINT_CHANNEL_STAT(rx_tcp_udp_chksum_err),
 
 
 
 
 
  78	EFX_ETHTOOL_UINT_CHANNEL_STAT(rx_mcast_mismatch),
  79	EFX_ETHTOOL_UINT_CHANNEL_STAT(rx_frm_trunc),
  80	EFX_ETHTOOL_UINT_CHANNEL_STAT(rx_nodesc_trunc),
  81	EFX_ETHTOOL_UINT_CHANNEL_STAT(rx_merge_events),
  82	EFX_ETHTOOL_UINT_CHANNEL_STAT(rx_merge_packets),
  83};
  84
  85#define EFX_ETHTOOL_SW_STAT_COUNT ARRAY_SIZE(efx_sw_stat_desc)
  86
  87#define EFX_ETHTOOL_EEPROM_MAGIC 0xEFAB
  88
  89/**************************************************************************
  90 *
  91 * Ethtool operations
  92 *
  93 **************************************************************************
  94 */
  95
  96/* Identify device by flashing LEDs */
  97static int efx_ethtool_phys_id(struct net_device *net_dev,
  98			       enum ethtool_phys_id_state state)
  99{
 100	struct efx_nic *efx = netdev_priv(net_dev);
 101	enum efx_led_mode mode = EFX_LED_DEFAULT;
 102
 103	switch (state) {
 104	case ETHTOOL_ID_ON:
 105		mode = EFX_LED_ON;
 106		break;
 107	case ETHTOOL_ID_OFF:
 108		mode = EFX_LED_OFF;
 109		break;
 110	case ETHTOOL_ID_INACTIVE:
 111		mode = EFX_LED_DEFAULT;
 112		break;
 113	case ETHTOOL_ID_ACTIVE:
 114		return 1;	/* cycle on/off once per second */
 115	}
 116
 117	efx->type->set_id_led(efx, mode);
 118	return 0;
 119}
 120
 121/* This must be called with rtnl_lock held. */
 122static int efx_ethtool_get_settings(struct net_device *net_dev,
 123				    struct ethtool_cmd *ecmd)
 
 124{
 125	struct efx_nic *efx = netdev_priv(net_dev);
 126	struct efx_link_state *link_state = &efx->link_state;
 
 127
 128	mutex_lock(&efx->mac_lock);
 129	efx->phy_op->get_settings(efx, ecmd);
 130	mutex_unlock(&efx->mac_lock);
 131
 132	/* Both MACs support pause frames (bidirectional and respond-only) */
 133	ecmd->supported |= SUPPORTED_Pause | SUPPORTED_Asym_Pause;
 
 
 
 
 
 
 134
 135	if (LOOPBACK_INTERNAL(efx)) {
 136		ethtool_cmd_speed_set(ecmd, link_state->speed);
 137		ecmd->duplex = link_state->fd ? DUPLEX_FULL : DUPLEX_HALF;
 138	}
 139
 140	return 0;
 141}
 142
 143/* This must be called with rtnl_lock held. */
 144static int efx_ethtool_set_settings(struct net_device *net_dev,
 145				    struct ethtool_cmd *ecmd)
 
 146{
 147	struct efx_nic *efx = netdev_priv(net_dev);
 148	int rc;
 149
 150	/* GMAC does not support 1000Mbps HD */
 151	if ((ethtool_cmd_speed(ecmd) == SPEED_1000) &&
 152	    (ecmd->duplex != DUPLEX_FULL)) {
 153		netif_dbg(efx, drv, efx->net_dev,
 154			  "rejecting unsupported 1000Mbps HD setting\n");
 155		return -EINVAL;
 156	}
 157
 158	mutex_lock(&efx->mac_lock);
 159	rc = efx->phy_op->set_settings(efx, ecmd);
 160	mutex_unlock(&efx->mac_lock);
 161	return rc;
 162}
 163
 164static void efx_ethtool_get_drvinfo(struct net_device *net_dev,
 165				    struct ethtool_drvinfo *info)
 166{
 167	struct efx_nic *efx = netdev_priv(net_dev);
 168
 169	strlcpy(info->driver, KBUILD_MODNAME, sizeof(info->driver));
 170	strlcpy(info->version, EFX_DRIVER_VERSION, sizeof(info->version));
 171	if (efx_nic_rev(efx) >= EFX_REV_SIENA_A0)
 172		efx_mcdi_print_fwver(efx, info->fw_version,
 173				     sizeof(info->fw_version));
 174	strlcpy(info->bus_info, pci_name(efx->pci_dev), sizeof(info->bus_info));
 175}
 176
 177static int efx_ethtool_get_regs_len(struct net_device *net_dev)
 178{
 179	return efx_nic_get_regs_len(netdev_priv(net_dev));
 180}
 181
 182static void efx_ethtool_get_regs(struct net_device *net_dev,
 183				 struct ethtool_regs *regs, void *buf)
 184{
 185	struct efx_nic *efx = netdev_priv(net_dev);
 186
 187	regs->version = efx->type->revision;
 188	efx_nic_get_regs(efx, buf);
 189}
 190
 191static u32 efx_ethtool_get_msglevel(struct net_device *net_dev)
 192{
 193	struct efx_nic *efx = netdev_priv(net_dev);
 194	return efx->msg_enable;
 195}
 196
 197static void efx_ethtool_set_msglevel(struct net_device *net_dev, u32 msg_enable)
 198{
 199	struct efx_nic *efx = netdev_priv(net_dev);
 200	efx->msg_enable = msg_enable;
 201}
 202
 203/**
 204 * efx_fill_test - fill in an individual self-test entry
 205 * @test_index:		Index of the test
 206 * @strings:		Ethtool strings, or %NULL
 207 * @data:		Ethtool test results, or %NULL
 208 * @test:		Pointer to test result (used only if data != %NULL)
 209 * @unit_format:	Unit name format (e.g. "chan\%d")
 210 * @unit_id:		Unit id (e.g. 0 for "chan0")
 211 * @test_format:	Test name format (e.g. "loopback.\%s.tx.sent")
 212 * @test_id:		Test id (e.g. "PHYXS" for "loopback.PHYXS.tx_sent")
 213 *
 214 * Fill in an individual self-test entry.
 215 */
 216static void efx_fill_test(unsigned int test_index, u8 *strings, u64 *data,
 217			  int *test, const char *unit_format, int unit_id,
 218			  const char *test_format, const char *test_id)
 219{
 220	char unit_str[ETH_GSTRING_LEN], test_str[ETH_GSTRING_LEN];
 221
 222	/* Fill data value, if applicable */
 223	if (data)
 224		data[test_index] = *test;
 225
 226	/* Fill string, if applicable */
 227	if (strings) {
 228		if (strchr(unit_format, '%'))
 229			snprintf(unit_str, sizeof(unit_str),
 230				 unit_format, unit_id);
 231		else
 232			strcpy(unit_str, unit_format);
 233		snprintf(test_str, sizeof(test_str), test_format, test_id);
 234		snprintf(strings + test_index * ETH_GSTRING_LEN,
 235			 ETH_GSTRING_LEN,
 236			 "%-6s %-24s", unit_str, test_str);
 237	}
 238}
 239
 240#define EFX_CHANNEL_NAME(_channel) "chan%d", _channel->channel
 241#define EFX_TX_QUEUE_NAME(_tx_queue) "txq%d", _tx_queue->queue
 242#define EFX_RX_QUEUE_NAME(_rx_queue) "rxq%d", _rx_queue->queue
 243#define EFX_LOOPBACK_NAME(_mode, _counter)			\
 244	"loopback.%s." _counter, STRING_TABLE_LOOKUP(_mode, efx_loopback_mode)
 245
 246/**
 247 * efx_fill_loopback_test - fill in a block of loopback self-test entries
 248 * @efx:		Efx NIC
 249 * @lb_tests:		Efx loopback self-test results structure
 250 * @mode:		Loopback test mode
 251 * @test_index:		Starting index of the test
 252 * @strings:		Ethtool strings, or %NULL
 253 * @data:		Ethtool test results, or %NULL
 254 *
 255 * Fill in a block of loopback self-test entries.  Return new test
 256 * index.
 257 */
 258static int efx_fill_loopback_test(struct efx_nic *efx,
 259				  struct efx_loopback_self_tests *lb_tests,
 260				  enum efx_loopback_mode mode,
 261				  unsigned int test_index,
 262				  u8 *strings, u64 *data)
 263{
 264	struct efx_channel *channel =
 265		efx_get_channel(efx, efx->tx_channel_offset);
 266	struct efx_tx_queue *tx_queue;
 267
 268	efx_for_each_channel_tx_queue(tx_queue, channel) {
 269		efx_fill_test(test_index++, strings, data,
 270			      &lb_tests->tx_sent[tx_queue->queue],
 271			      EFX_TX_QUEUE_NAME(tx_queue),
 272			      EFX_LOOPBACK_NAME(mode, "tx_sent"));
 273		efx_fill_test(test_index++, strings, data,
 274			      &lb_tests->tx_done[tx_queue->queue],
 275			      EFX_TX_QUEUE_NAME(tx_queue),
 276			      EFX_LOOPBACK_NAME(mode, "tx_done"));
 277	}
 278	efx_fill_test(test_index++, strings, data,
 279		      &lb_tests->rx_good,
 280		      "rx", 0,
 281		      EFX_LOOPBACK_NAME(mode, "rx_good"));
 282	efx_fill_test(test_index++, strings, data,
 283		      &lb_tests->rx_bad,
 284		      "rx", 0,
 285		      EFX_LOOPBACK_NAME(mode, "rx_bad"));
 286
 287	return test_index;
 288}
 289
 290/**
 291 * efx_ethtool_fill_self_tests - get self-test details
 292 * @efx:		Efx NIC
 293 * @tests:		Efx self-test results structure, or %NULL
 294 * @strings:		Ethtool strings, or %NULL
 295 * @data:		Ethtool test results, or %NULL
 296 *
 297 * Get self-test number of strings, strings, and/or test results.
 298 * Return number of strings (== number of test results).
 299 *
 300 * The reason for merging these three functions is to make sure that
 301 * they can never be inconsistent.
 302 */
 303static int efx_ethtool_fill_self_tests(struct efx_nic *efx,
 304				       struct efx_self_tests *tests,
 305				       u8 *strings, u64 *data)
 306{
 307	struct efx_channel *channel;
 308	unsigned int n = 0, i;
 309	enum efx_loopback_mode mode;
 310
 311	efx_fill_test(n++, strings, data, &tests->phy_alive,
 312		      "phy", 0, "alive", NULL);
 313	efx_fill_test(n++, strings, data, &tests->nvram,
 314		      "core", 0, "nvram", NULL);
 315	efx_fill_test(n++, strings, data, &tests->interrupt,
 316		      "core", 0, "interrupt", NULL);
 317
 318	/* Event queues */
 319	efx_for_each_channel(channel, efx) {
 320		efx_fill_test(n++, strings, data,
 321			      &tests->eventq_dma[channel->channel],
 322			      EFX_CHANNEL_NAME(channel),
 323			      "eventq.dma", NULL);
 324		efx_fill_test(n++, strings, data,
 325			      &tests->eventq_int[channel->channel],
 326			      EFX_CHANNEL_NAME(channel),
 327			      "eventq.int", NULL);
 328	}
 329
 330	efx_fill_test(n++, strings, data, &tests->memory,
 331		      "core", 0, "memory", NULL);
 332	efx_fill_test(n++, strings, data, &tests->registers,
 333		      "core", 0, "registers", NULL);
 334
 335	if (efx->phy_op->run_tests != NULL) {
 336		EFX_BUG_ON_PARANOID(efx->phy_op->test_name == NULL);
 337
 338		for (i = 0; true; ++i) {
 339			const char *name;
 340
 341			EFX_BUG_ON_PARANOID(i >= EFX_MAX_PHY_TESTS);
 342			name = efx->phy_op->test_name(efx, i);
 343			if (name == NULL)
 344				break;
 345
 346			efx_fill_test(n++, strings, data, &tests->phy_ext[i],
 347				      "phy", 0, name, NULL);
 348		}
 349	}
 350
 351	/* Loopback tests */
 352	for (mode = LOOPBACK_NONE; mode <= LOOPBACK_TEST_MAX; mode++) {
 353		if (!(efx->loopback_modes & (1 << mode)))
 354			continue;
 355		n = efx_fill_loopback_test(efx,
 356					   &tests->loopback[mode], mode, n,
 357					   strings, data);
 358	}
 359
 360	return n;
 361}
 362
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 363static int efx_ethtool_get_sset_count(struct net_device *net_dev,
 364				      int string_set)
 365{
 366	struct efx_nic *efx = netdev_priv(net_dev);
 367
 368	switch (string_set) {
 369	case ETH_SS_STATS:
 370		return efx->type->describe_stats(efx, NULL) +
 371			EFX_ETHTOOL_SW_STAT_COUNT +
 372			efx_ptp_describe_stats(efx, NULL);
 
 373	case ETH_SS_TEST:
 374		return efx_ethtool_fill_self_tests(efx, NULL, NULL, NULL);
 375	default:
 376		return -EINVAL;
 377	}
 378}
 379
 380static void efx_ethtool_get_strings(struct net_device *net_dev,
 381				    u32 string_set, u8 *strings)
 382{
 383	struct efx_nic *efx = netdev_priv(net_dev);
 384	int i;
 385
 386	switch (string_set) {
 387	case ETH_SS_STATS:
 388		strings += (efx->type->describe_stats(efx, strings) *
 389			    ETH_GSTRING_LEN);
 390		for (i = 0; i < EFX_ETHTOOL_SW_STAT_COUNT; i++)
 391			strlcpy(strings + i * ETH_GSTRING_LEN,
 392				efx_sw_stat_desc[i].name, ETH_GSTRING_LEN);
 393		strings += EFX_ETHTOOL_SW_STAT_COUNT * ETH_GSTRING_LEN;
 
 
 394		efx_ptp_describe_stats(efx, strings);
 395		break;
 396	case ETH_SS_TEST:
 397		efx_ethtool_fill_self_tests(efx, NULL, strings, NULL);
 398		break;
 399	default:
 400		/* No other string sets */
 401		break;
 402	}
 403}
 404
 405static void efx_ethtool_get_stats(struct net_device *net_dev,
 406				  struct ethtool_stats *stats,
 407				  u64 *data)
 408{
 409	struct efx_nic *efx = netdev_priv(net_dev);
 410	const struct efx_sw_stat_desc *stat;
 411	struct efx_channel *channel;
 412	struct efx_tx_queue *tx_queue;
 
 413	int i;
 414
 415	spin_lock_bh(&efx->stats_lock);
 416
 417	/* Get NIC statistics */
 418	data += efx->type->update_stats(efx, data, NULL);
 419
 420	/* Get software statistics */
 421	for (i = 0; i < EFX_ETHTOOL_SW_STAT_COUNT; i++) {
 422		stat = &efx_sw_stat_desc[i];
 423		switch (stat->source) {
 424		case EFX_ETHTOOL_STAT_SOURCE_nic:
 425			data[i] = stat->get_stat((void *)efx + stat->offset);
 426			break;
 427		case EFX_ETHTOOL_STAT_SOURCE_channel:
 428			data[i] = 0;
 429			efx_for_each_channel(channel, efx)
 430				data[i] += stat->get_stat((void *)channel +
 431							  stat->offset);
 432			break;
 433		case EFX_ETHTOOL_STAT_SOURCE_tx_queue:
 434			data[i] = 0;
 435			efx_for_each_channel(channel, efx) {
 436				efx_for_each_channel_tx_queue(tx_queue, channel)
 437					data[i] +=
 438						stat->get_stat((void *)tx_queue
 439							       + stat->offset);
 440			}
 441			break;
 442		}
 443	}
 444	data += EFX_ETHTOOL_SW_STAT_COUNT;
 445
 446	spin_unlock_bh(&efx->stats_lock);
 447
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 448	efx_ptp_update_stats(efx, data);
 449}
 450
 451static void efx_ethtool_self_test(struct net_device *net_dev,
 452				  struct ethtool_test *test, u64 *data)
 453{
 454	struct efx_nic *efx = netdev_priv(net_dev);
 455	struct efx_self_tests *efx_tests;
 456	bool already_up;
 457	int rc = -ENOMEM;
 458
 459	efx_tests = kzalloc(sizeof(*efx_tests), GFP_KERNEL);
 460	if (!efx_tests)
 461		goto fail;
 462
 463	if (efx->state != STATE_READY) {
 464		rc = -EBUSY;
 465		goto out;
 466	}
 467
 468	netif_info(efx, drv, efx->net_dev, "starting %sline testing\n",
 469		   (test->flags & ETH_TEST_FL_OFFLINE) ? "off" : "on");
 470
 471	/* We need rx buffers and interrupts. */
 472	already_up = (efx->net_dev->flags & IFF_UP);
 473	if (!already_up) {
 474		rc = dev_open(efx->net_dev);
 475		if (rc) {
 476			netif_err(efx, drv, efx->net_dev,
 477				  "failed opening device.\n");
 478			goto out;
 479		}
 480	}
 481
 482	rc = efx_selftest(efx, efx_tests, test->flags);
 483
 484	if (!already_up)
 485		dev_close(efx->net_dev);
 486
 487	netif_info(efx, drv, efx->net_dev, "%s %sline self-tests\n",
 488		   rc == 0 ? "passed" : "failed",
 489		   (test->flags & ETH_TEST_FL_OFFLINE) ? "off" : "on");
 490
 491out:
 492	efx_ethtool_fill_self_tests(efx, efx_tests, NULL, data);
 493	kfree(efx_tests);
 494fail:
 495	if (rc)
 496		test->flags |= ETH_TEST_FL_FAILED;
 497}
 498
 499/* Restart autonegotiation */
 500static int efx_ethtool_nway_reset(struct net_device *net_dev)
 501{
 502	struct efx_nic *efx = netdev_priv(net_dev);
 503
 504	return mdio45_nway_restart(&efx->mdio);
 505}
 506
 507/*
 508 * Each channel has a single IRQ and moderation timer, started by any
 509 * completion (or other event).  Unless the module parameter
 510 * separate_tx_channels is set, IRQs and moderation are therefore
 511 * shared between RX and TX completions.  In this case, when RX IRQ
 512 * moderation is explicitly changed then TX IRQ moderation is
 513 * automatically changed too, but otherwise we fail if the two values
 514 * are requested to be different.
 515 *
 516 * The hardware does not support a limit on the number of completions
 517 * before an IRQ, so we do not use the max_frames fields.  We should
 518 * report and require that max_frames == (usecs != 0), but this would
 519 * invalidate existing user documentation.
 520 *
 521 * The hardware does not have distinct settings for interrupt
 522 * moderation while the previous IRQ is being handled, so we should
 523 * not use the 'irq' fields.  However, an earlier developer
 524 * misunderstood the meaning of the 'irq' fields and the driver did
 525 * not support the standard fields.  To avoid invalidating existing
 526 * user documentation, we report and accept changes through either the
 527 * standard or 'irq' fields.  If both are changed at the same time, we
 528 * prefer the standard field.
 529 *
 530 * We implement adaptive IRQ moderation, but use a different algorithm
 531 * from that assumed in the definition of struct ethtool_coalesce.
 532 * Therefore we do not use any of the adaptive moderation parameters
 533 * in it.
 534 */
 535
 536static int efx_ethtool_get_coalesce(struct net_device *net_dev,
 537				    struct ethtool_coalesce *coalesce)
 538{
 539	struct efx_nic *efx = netdev_priv(net_dev);
 540	unsigned int tx_usecs, rx_usecs;
 541	bool rx_adaptive;
 542
 543	efx_get_irq_moderation(efx, &tx_usecs, &rx_usecs, &rx_adaptive);
 544
 545	coalesce->tx_coalesce_usecs = tx_usecs;
 546	coalesce->tx_coalesce_usecs_irq = tx_usecs;
 547	coalesce->rx_coalesce_usecs = rx_usecs;
 548	coalesce->rx_coalesce_usecs_irq = rx_usecs;
 549	coalesce->use_adaptive_rx_coalesce = rx_adaptive;
 550
 551	return 0;
 552}
 553
 554static int efx_ethtool_set_coalesce(struct net_device *net_dev,
 555				    struct ethtool_coalesce *coalesce)
 556{
 557	struct efx_nic *efx = netdev_priv(net_dev);
 558	struct efx_channel *channel;
 559	unsigned int tx_usecs, rx_usecs;
 560	bool adaptive, rx_may_override_tx;
 561	int rc;
 562
 563	if (coalesce->use_adaptive_tx_coalesce)
 564		return -EINVAL;
 565
 566	efx_get_irq_moderation(efx, &tx_usecs, &rx_usecs, &adaptive);
 567
 568	if (coalesce->rx_coalesce_usecs != rx_usecs)
 569		rx_usecs = coalesce->rx_coalesce_usecs;
 570	else
 571		rx_usecs = coalesce->rx_coalesce_usecs_irq;
 572
 573	adaptive = coalesce->use_adaptive_rx_coalesce;
 574
 575	/* If channels are shared, TX IRQ moderation can be quietly
 576	 * overridden unless it is changed from its old value.
 577	 */
 578	rx_may_override_tx = (coalesce->tx_coalesce_usecs == tx_usecs &&
 579			      coalesce->tx_coalesce_usecs_irq == tx_usecs);
 580	if (coalesce->tx_coalesce_usecs != tx_usecs)
 581		tx_usecs = coalesce->tx_coalesce_usecs;
 582	else
 583		tx_usecs = coalesce->tx_coalesce_usecs_irq;
 584
 585	rc = efx_init_irq_moderation(efx, tx_usecs, rx_usecs, adaptive,
 586				     rx_may_override_tx);
 587	if (rc != 0)
 588		return rc;
 589
 590	efx_for_each_channel(channel, efx)
 591		efx->type->push_irq_moderation(channel);
 592
 593	return 0;
 594}
 595
 596static void efx_ethtool_get_ringparam(struct net_device *net_dev,
 597				      struct ethtool_ringparam *ring)
 598{
 599	struct efx_nic *efx = netdev_priv(net_dev);
 600
 601	ring->rx_max_pending = EFX_MAX_DMAQ_SIZE;
 602	ring->tx_max_pending = EFX_TXQ_MAX_ENT(efx);
 603	ring->rx_pending = efx->rxq_entries;
 604	ring->tx_pending = efx->txq_entries;
 605}
 606
 607static int efx_ethtool_set_ringparam(struct net_device *net_dev,
 608				     struct ethtool_ringparam *ring)
 609{
 610	struct efx_nic *efx = netdev_priv(net_dev);
 611	u32 txq_entries;
 612
 613	if (ring->rx_mini_pending || ring->rx_jumbo_pending ||
 614	    ring->rx_pending > EFX_MAX_DMAQ_SIZE ||
 615	    ring->tx_pending > EFX_TXQ_MAX_ENT(efx))
 616		return -EINVAL;
 617
 618	if (ring->rx_pending < EFX_RXQ_MIN_ENT) {
 619		netif_err(efx, drv, efx->net_dev,
 620			  "RX queues cannot be smaller than %u\n",
 621			  EFX_RXQ_MIN_ENT);
 622		return -EINVAL;
 623	}
 624
 625	txq_entries = max(ring->tx_pending, EFX_TXQ_MIN_ENT(efx));
 626	if (txq_entries != ring->tx_pending)
 627		netif_warn(efx, drv, efx->net_dev,
 628			   "increasing TX queue size to minimum of %u\n",
 629			   txq_entries);
 630
 631	return efx_realloc_channels(efx, ring->rx_pending, txq_entries);
 632}
 633
 634static int efx_ethtool_set_pauseparam(struct net_device *net_dev,
 635				      struct ethtool_pauseparam *pause)
 636{
 637	struct efx_nic *efx = netdev_priv(net_dev);
 638	u8 wanted_fc, old_fc;
 639	u32 old_adv;
 640	int rc = 0;
 641
 642	mutex_lock(&efx->mac_lock);
 643
 644	wanted_fc = ((pause->rx_pause ? EFX_FC_RX : 0) |
 645		     (pause->tx_pause ? EFX_FC_TX : 0) |
 646		     (pause->autoneg ? EFX_FC_AUTO : 0));
 647
 648	if ((wanted_fc & EFX_FC_TX) && !(wanted_fc & EFX_FC_RX)) {
 649		netif_dbg(efx, drv, efx->net_dev,
 650			  "Flow control unsupported: tx ON rx OFF\n");
 651		rc = -EINVAL;
 652		goto out;
 653	}
 654
 655	if ((wanted_fc & EFX_FC_AUTO) && !efx->link_advertising) {
 656		netif_dbg(efx, drv, efx->net_dev,
 657			  "Autonegotiation is disabled\n");
 658		rc = -EINVAL;
 659		goto out;
 660	}
 661
 662	/* Hook for Falcon bug 11482 workaround */
 663	if (efx->type->prepare_enable_fc_tx &&
 664	    (wanted_fc & EFX_FC_TX) && !(efx->wanted_fc & EFX_FC_TX))
 665		efx->type->prepare_enable_fc_tx(efx);
 666
 667	old_adv = efx->link_advertising;
 668	old_fc = efx->wanted_fc;
 669	efx_link_set_wanted_fc(efx, wanted_fc);
 670	if (efx->link_advertising != old_adv ||
 671	    (efx->wanted_fc ^ old_fc) & EFX_FC_AUTO) {
 672		rc = efx->phy_op->reconfigure(efx);
 673		if (rc) {
 674			netif_err(efx, drv, efx->net_dev,
 675				  "Unable to advertise requested flow "
 676				  "control setting\n");
 677			goto out;
 678		}
 679	}
 680
 681	/* Reconfigure the MAC. The PHY *may* generate a link state change event
 682	 * if the user just changed the advertised capabilities, but there's no
 683	 * harm doing this twice */
 684	efx->type->reconfigure_mac(efx);
 685
 686out:
 687	mutex_unlock(&efx->mac_lock);
 688
 689	return rc;
 690}
 691
 692static void efx_ethtool_get_pauseparam(struct net_device *net_dev,
 693				       struct ethtool_pauseparam *pause)
 694{
 695	struct efx_nic *efx = netdev_priv(net_dev);
 696
 697	pause->rx_pause = !!(efx->wanted_fc & EFX_FC_RX);
 698	pause->tx_pause = !!(efx->wanted_fc & EFX_FC_TX);
 699	pause->autoneg = !!(efx->wanted_fc & EFX_FC_AUTO);
 700}
 701
 702static void efx_ethtool_get_wol(struct net_device *net_dev,
 703				struct ethtool_wolinfo *wol)
 704{
 705	struct efx_nic *efx = netdev_priv(net_dev);
 706	return efx->type->get_wol(efx, wol);
 707}
 708
 709
 710static int efx_ethtool_set_wol(struct net_device *net_dev,
 711			       struct ethtool_wolinfo *wol)
 712{
 713	struct efx_nic *efx = netdev_priv(net_dev);
 714	return efx->type->set_wol(efx, wol->wolopts);
 715}
 716
 717static int efx_ethtool_reset(struct net_device *net_dev, u32 *flags)
 718{
 719	struct efx_nic *efx = netdev_priv(net_dev);
 720	int rc;
 721
 722	rc = efx->type->map_reset_flags(flags);
 723	if (rc < 0)
 724		return rc;
 725
 726	return efx_reset(efx, rc);
 727}
 728
 729/* MAC address mask including only I/G bit */
 730static const u8 mac_addr_ig_mask[ETH_ALEN] __aligned(2) = {0x01, 0, 0, 0, 0, 0};
 731
 732#define IP4_ADDR_FULL_MASK	((__force __be32)~0)
 
 733#define PORT_FULL_MASK		((__force __be16)~0)
 734#define ETHER_TYPE_FULL_MASK	((__force __be16)~0)
 735
 
 
 
 
 
 736static int efx_ethtool_get_class_rule(struct efx_nic *efx,
 737				      struct ethtool_rx_flow_spec *rule)
 
 738{
 739	struct ethtool_tcpip4_spec *ip_entry = &rule->h_u.tcp_ip4_spec;
 740	struct ethtool_tcpip4_spec *ip_mask = &rule->m_u.tcp_ip4_spec;
 
 
 
 
 
 
 741	struct ethhdr *mac_entry = &rule->h_u.ether_spec;
 742	struct ethhdr *mac_mask = &rule->m_u.ether_spec;
 743	struct efx_filter_spec spec;
 744	int rc;
 745
 746	rc = efx_filter_get_filter_safe(efx, EFX_FILTER_PRI_MANUAL,
 747					rule->location, &spec);
 748	if (rc)
 749		return rc;
 750
 751	if (spec.dmaq_id == EFX_FILTER_RX_DMAQ_ID_DROP)
 752		rule->ring_cookie = RX_CLS_FLOW_DISC;
 753	else
 754		rule->ring_cookie = spec.dmaq_id;
 755
 756	if ((spec.match_flags & EFX_FILTER_MATCH_ETHER_TYPE) &&
 757	    spec.ether_type == htons(ETH_P_IP) &&
 758	    (spec.match_flags & EFX_FILTER_MATCH_IP_PROTO) &&
 759	    (spec.ip_proto == IPPROTO_TCP || spec.ip_proto == IPPROTO_UDP) &&
 760	    !(spec.match_flags &
 761	      ~(EFX_FILTER_MATCH_ETHER_TYPE | EFX_FILTER_MATCH_OUTER_VID |
 762		EFX_FILTER_MATCH_LOC_HOST | EFX_FILTER_MATCH_REM_HOST |
 763		EFX_FILTER_MATCH_IP_PROTO |
 764		EFX_FILTER_MATCH_LOC_PORT | EFX_FILTER_MATCH_REM_PORT))) {
 765		rule->flow_type = ((spec.ip_proto == IPPROTO_TCP) ?
 766				   TCP_V4_FLOW : UDP_V4_FLOW);
 767		if (spec.match_flags & EFX_FILTER_MATCH_LOC_HOST) {
 768			ip_entry->ip4dst = spec.loc_host[0];
 769			ip_mask->ip4dst = IP4_ADDR_FULL_MASK;
 770		}
 771		if (spec.match_flags & EFX_FILTER_MATCH_REM_HOST) {
 772			ip_entry->ip4src = spec.rem_host[0];
 773			ip_mask->ip4src = IP4_ADDR_FULL_MASK;
 774		}
 775		if (spec.match_flags & EFX_FILTER_MATCH_LOC_PORT) {
 776			ip_entry->pdst = spec.loc_port;
 777			ip_mask->pdst = PORT_FULL_MASK;
 778		}
 779		if (spec.match_flags & EFX_FILTER_MATCH_REM_PORT) {
 780			ip_entry->psrc = spec.rem_port;
 781			ip_mask->psrc = PORT_FULL_MASK;
 782		}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 783	} else if (!(spec.match_flags &
 784		     ~(EFX_FILTER_MATCH_LOC_MAC | EFX_FILTER_MATCH_LOC_MAC_IG |
 785		       EFX_FILTER_MATCH_REM_MAC | EFX_FILTER_MATCH_ETHER_TYPE |
 786		       EFX_FILTER_MATCH_OUTER_VID))) {
 787		rule->flow_type = ETHER_FLOW;
 788		if (spec.match_flags &
 789		    (EFX_FILTER_MATCH_LOC_MAC | EFX_FILTER_MATCH_LOC_MAC_IG)) {
 790			ether_addr_copy(mac_entry->h_dest, spec.loc_mac);
 791			if (spec.match_flags & EFX_FILTER_MATCH_LOC_MAC)
 792				eth_broadcast_addr(mac_mask->h_dest);
 793			else
 794				ether_addr_copy(mac_mask->h_dest,
 795						mac_addr_ig_mask);
 796		}
 797		if (spec.match_flags & EFX_FILTER_MATCH_REM_MAC) {
 798			ether_addr_copy(mac_entry->h_source, spec.rem_mac);
 799			eth_broadcast_addr(mac_mask->h_source);
 800		}
 801		if (spec.match_flags & EFX_FILTER_MATCH_ETHER_TYPE) {
 802			mac_entry->h_proto = spec.ether_type;
 803			mac_mask->h_proto = ETHER_TYPE_FULL_MASK;
 804		}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 805	} else {
 806		/* The above should handle all filters that we insert */
 807		WARN_ON(1);
 808		return -EINVAL;
 809	}
 810
 811	if (spec.match_flags & EFX_FILTER_MATCH_OUTER_VID) {
 812		rule->flow_type |= FLOW_EXT;
 813		rule->h_ext.vlan_tci = spec.outer_vid;
 814		rule->m_ext.vlan_tci = htons(0xfff);
 815	}
 816
 
 
 
 
 
 817	return rc;
 818}
 819
 820static int
 821efx_ethtool_get_rxnfc(struct net_device *net_dev,
 822		      struct ethtool_rxnfc *info, u32 *rule_locs)
 823{
 824	struct efx_nic *efx = netdev_priv(net_dev);
 
 
 825
 826	switch (info->cmd) {
 827	case ETHTOOL_GRXRINGS:
 828		info->data = efx->n_rx_channels;
 829		return 0;
 830
 831	case ETHTOOL_GRXFH: {
 832		unsigned min_revision = 0;
 833
 
 
 
 
 
 
 
 
 834		info->data = 0;
 835		switch (info->flow_type) {
 
 
 
 
 
 836		case TCP_V4_FLOW:
 837			info->data |= RXH_L4_B_0_1 | RXH_L4_B_2_3;
 838			/* fall through */
 839		case UDP_V4_FLOW:
 840		case SCTP_V4_FLOW:
 841		case AH_ESP_V4_FLOW:
 842		case IPV4_FLOW:
 843			info->data |= RXH_IP_SRC | RXH_IP_DST;
 844			min_revision = EFX_REV_FALCON_B0;
 845			break;
 
 
 
 846		case TCP_V6_FLOW:
 847			info->data |= RXH_L4_B_0_1 | RXH_L4_B_2_3;
 848			/* fall through */
 849		case UDP_V6_FLOW:
 850		case SCTP_V6_FLOW:
 851		case AH_ESP_V6_FLOW:
 852		case IPV6_FLOW:
 853			info->data |= RXH_IP_SRC | RXH_IP_DST;
 854			min_revision = EFX_REV_SIENA_A0;
 855			break;
 856		default:
 857			break;
 858		}
 859		if (efx_nic_rev(efx) < min_revision)
 860			info->data = 0;
 861		return 0;
 862	}
 863
 864	case ETHTOOL_GRXCLSRLCNT:
 865		info->data = efx_filter_get_rx_id_limit(efx);
 866		if (info->data == 0)
 867			return -EOPNOTSUPP;
 868		info->data |= RX_CLS_LOC_SPECIAL;
 869		info->rule_cnt =
 870			efx_filter_count_rx_used(efx, EFX_FILTER_PRI_MANUAL);
 871		return 0;
 872
 873	case ETHTOOL_GRXCLSRULE:
 874		if (efx_filter_get_rx_id_limit(efx) == 0)
 875			return -EOPNOTSUPP;
 876		return efx_ethtool_get_class_rule(efx, &info->fs);
 
 
 
 
 
 877
 878	case ETHTOOL_GRXCLSRLALL: {
 879		s32 rc;
 880		info->data = efx_filter_get_rx_id_limit(efx);
 881		if (info->data == 0)
 882			return -EOPNOTSUPP;
 883		rc = efx_filter_get_rx_ids(efx, EFX_FILTER_PRI_MANUAL,
 884					   rule_locs, info->rule_cnt);
 885		if (rc < 0)
 886			return rc;
 887		info->rule_cnt = rc;
 888		return 0;
 889	}
 890
 891	default:
 892		return -EOPNOTSUPP;
 893	}
 894}
 895
 
 
 
 
 
 
 
 
 
 
 896static int efx_ethtool_set_class_rule(struct efx_nic *efx,
 897				      struct ethtool_rx_flow_spec *rule)
 
 898{
 899	struct ethtool_tcpip4_spec *ip_entry = &rule->h_u.tcp_ip4_spec;
 900	struct ethtool_tcpip4_spec *ip_mask = &rule->m_u.tcp_ip4_spec;
 
 
 
 
 
 
 
 901	struct ethhdr *mac_entry = &rule->h_u.ether_spec;
 902	struct ethhdr *mac_mask = &rule->m_u.ether_spec;
 
 903	struct efx_filter_spec spec;
 904	int rc;
 905
 906	/* Check that user wants us to choose the location */
 907	if (rule->location != RX_CLS_LOC_ANY)
 908		return -EINVAL;
 909
 910	/* Range-check ring_cookie */
 911	if (rule->ring_cookie >= efx->n_rx_channels &&
 912	    rule->ring_cookie != RX_CLS_FLOW_DISC)
 913		return -EINVAL;
 914
 915	/* Check for unsupported extensions */
 916	if ((rule->flow_type & FLOW_EXT) &&
 917	    (rule->m_ext.vlan_etype || rule->m_ext.data[0] ||
 918	     rule->m_ext.data[1]))
 919		return -EINVAL;
 920
 921	efx_filter_init_rx(&spec, EFX_FILTER_PRI_MANUAL,
 922			   efx->rx_scatter ? EFX_FILTER_FLAG_RX_SCATTER : 0,
 
 
 
 
 923			   (rule->ring_cookie == RX_CLS_FLOW_DISC) ?
 924			   EFX_FILTER_RX_DMAQ_ID_DROP : rule->ring_cookie);
 925
 926	switch (rule->flow_type & ~FLOW_EXT) {
 
 
 
 927	case TCP_V4_FLOW:
 928	case UDP_V4_FLOW:
 929		spec.match_flags = (EFX_FILTER_MATCH_ETHER_TYPE |
 930				    EFX_FILTER_MATCH_IP_PROTO);
 931		spec.ether_type = htons(ETH_P_IP);
 932		spec.ip_proto = ((rule->flow_type & ~FLOW_EXT) == TCP_V4_FLOW ?
 933				 IPPROTO_TCP : IPPROTO_UDP);
 934		if (ip_mask->ip4dst) {
 935			if (ip_mask->ip4dst != IP4_ADDR_FULL_MASK)
 936				return -EINVAL;
 937			spec.match_flags |= EFX_FILTER_MATCH_LOC_HOST;
 938			spec.loc_host[0] = ip_entry->ip4dst;
 939		}
 940		if (ip_mask->ip4src) {
 941			if (ip_mask->ip4src != IP4_ADDR_FULL_MASK)
 942				return -EINVAL;
 943			spec.match_flags |= EFX_FILTER_MATCH_REM_HOST;
 944			spec.rem_host[0] = ip_entry->ip4src;
 945		}
 946		if (ip_mask->pdst) {
 947			if (ip_mask->pdst != PORT_FULL_MASK)
 948				return -EINVAL;
 949			spec.match_flags |= EFX_FILTER_MATCH_LOC_PORT;
 950			spec.loc_port = ip_entry->pdst;
 951		}
 952		if (ip_mask->psrc) {
 953			if (ip_mask->psrc != PORT_FULL_MASK)
 954				return -EINVAL;
 955			spec.match_flags |= EFX_FILTER_MATCH_REM_PORT;
 956			spec.rem_port = ip_entry->psrc;
 957		}
 958		if (ip_mask->tos)
 959			return -EINVAL;
 960		break;
 961
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 962	case ETHER_FLOW:
 963		if (!is_zero_ether_addr(mac_mask->h_dest)) {
 964			if (ether_addr_equal(mac_mask->h_dest,
 965					     mac_addr_ig_mask))
 966				spec.match_flags |= EFX_FILTER_MATCH_LOC_MAC_IG;
 967			else if (is_broadcast_ether_addr(mac_mask->h_dest))
 968				spec.match_flags |= EFX_FILTER_MATCH_LOC_MAC;
 969			else
 970				return -EINVAL;
 971			ether_addr_copy(spec.loc_mac, mac_entry->h_dest);
 972		}
 973		if (!is_zero_ether_addr(mac_mask->h_source)) {
 974			if (!is_broadcast_ether_addr(mac_mask->h_source))
 975				return -EINVAL;
 976			spec.match_flags |= EFX_FILTER_MATCH_REM_MAC;
 977			ether_addr_copy(spec.rem_mac, mac_entry->h_source);
 978		}
 979		if (mac_mask->h_proto) {
 980			if (mac_mask->h_proto != ETHER_TYPE_FULL_MASK)
 981				return -EINVAL;
 982			spec.match_flags |= EFX_FILTER_MATCH_ETHER_TYPE;
 983			spec.ether_type = mac_entry->h_proto;
 984		}
 985		break;
 986
 987	default:
 988		return -EINVAL;
 989	}
 990
 991	if ((rule->flow_type & FLOW_EXT) && rule->m_ext.vlan_tci) {
 992		if (rule->m_ext.vlan_tci != htons(0xfff))
 993			return -EINVAL;
 994		spec.match_flags |= EFX_FILTER_MATCH_OUTER_VID;
 995		spec.outer_vid = rule->h_ext.vlan_tci;
 996	}
 997
 998	rc = efx_filter_insert_filter(efx, &spec, true);
 999	if (rc < 0)
1000		return rc;
1001
1002	rule->location = rc;
1003	return 0;
1004}
1005
1006static int efx_ethtool_set_rxnfc(struct net_device *net_dev,
1007				 struct ethtool_rxnfc *info)
1008{
1009	struct efx_nic *efx = netdev_priv(net_dev);
1010
1011	if (efx_filter_get_rx_id_limit(efx) == 0)
1012		return -EOPNOTSUPP;
1013
1014	switch (info->cmd) {
1015	case ETHTOOL_SRXCLSRLINS:
1016		return efx_ethtool_set_class_rule(efx, &info->fs);
 
1017
1018	case ETHTOOL_SRXCLSRLDEL:
1019		return efx_filter_remove_id_safe(efx, EFX_FILTER_PRI_MANUAL,
1020						 info->fs.location);
1021
1022	default:
1023		return -EOPNOTSUPP;
1024	}
1025}
1026
1027static u32 efx_ethtool_get_rxfh_indir_size(struct net_device *net_dev)
1028{
1029	struct efx_nic *efx = netdev_priv(net_dev);
1030
1031	return ((efx_nic_rev(efx) < EFX_REV_FALCON_B0 ||
1032		 efx->n_rx_channels == 1) ?
1033		0 : ARRAY_SIZE(efx->rx_indir_table));
1034}
1035
1036static int efx_ethtool_get_rxfh_indir(struct net_device *net_dev, u32 *indir)
1037{
1038	struct efx_nic *efx = netdev_priv(net_dev);
1039
1040	memcpy(indir, efx->rx_indir_table, sizeof(efx->rx_indir_table));
1041	return 0;
1042}
1043
1044static int efx_ethtool_set_rxfh_indir(struct net_device *net_dev,
1045				      const u32 *indir)
1046{
1047	struct efx_nic *efx = netdev_priv(net_dev);
 
 
 
 
 
1048
1049	memcpy(efx->rx_indir_table, indir, sizeof(efx->rx_indir_table));
1050	efx->type->rx_push_rss_config(efx);
 
 
 
 
 
 
1051	return 0;
1052}
1053
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1054static int efx_ethtool_get_ts_info(struct net_device *net_dev,
1055				   struct ethtool_ts_info *ts_info)
1056{
1057	struct efx_nic *efx = netdev_priv(net_dev);
1058
1059	/* Software capabilities */
1060	ts_info->so_timestamping = (SOF_TIMESTAMPING_RX_SOFTWARE |
1061				    SOF_TIMESTAMPING_SOFTWARE);
1062	ts_info->phc_index = -1;
1063
1064	efx_ptp_get_ts_info(efx, ts_info);
1065	return 0;
1066}
1067
1068static int efx_ethtool_get_module_eeprom(struct net_device *net_dev,
1069					 struct ethtool_eeprom *ee,
1070					 u8 *data)
1071{
1072	struct efx_nic *efx = netdev_priv(net_dev);
1073	int ret;
1074
1075	if (!efx->phy_op || !efx->phy_op->get_module_eeprom)
1076		return -EOPNOTSUPP;
1077
1078	mutex_lock(&efx->mac_lock);
1079	ret = efx->phy_op->get_module_eeprom(efx, ee, data);
1080	mutex_unlock(&efx->mac_lock);
1081
1082	return ret;
1083}
1084
1085static int efx_ethtool_get_module_info(struct net_device *net_dev,
1086				       struct ethtool_modinfo *modinfo)
1087{
1088	struct efx_nic *efx = netdev_priv(net_dev);
1089	int ret;
1090
1091	if (!efx->phy_op || !efx->phy_op->get_module_info)
1092		return -EOPNOTSUPP;
1093
1094	mutex_lock(&efx->mac_lock);
1095	ret = efx->phy_op->get_module_info(efx, modinfo);
1096	mutex_unlock(&efx->mac_lock);
1097
1098	return ret;
1099}
1100
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1101const struct ethtool_ops efx_ethtool_ops = {
1102	.get_settings		= efx_ethtool_get_settings,
1103	.set_settings		= efx_ethtool_set_settings,
1104	.get_drvinfo		= efx_ethtool_get_drvinfo,
1105	.get_regs_len		= efx_ethtool_get_regs_len,
1106	.get_regs		= efx_ethtool_get_regs,
1107	.get_msglevel		= efx_ethtool_get_msglevel,
1108	.set_msglevel		= efx_ethtool_set_msglevel,
1109	.nway_reset		= efx_ethtool_nway_reset,
1110	.get_link		= ethtool_op_get_link,
1111	.get_coalesce		= efx_ethtool_get_coalesce,
1112	.set_coalesce		= efx_ethtool_set_coalesce,
1113	.get_ringparam		= efx_ethtool_get_ringparam,
1114	.set_ringparam		= efx_ethtool_set_ringparam,
1115	.get_pauseparam         = efx_ethtool_get_pauseparam,
1116	.set_pauseparam         = efx_ethtool_set_pauseparam,
1117	.get_sset_count		= efx_ethtool_get_sset_count,
1118	.self_test		= efx_ethtool_self_test,
1119	.get_strings		= efx_ethtool_get_strings,
1120	.set_phys_id		= efx_ethtool_phys_id,
1121	.get_ethtool_stats	= efx_ethtool_get_stats,
1122	.get_wol                = efx_ethtool_get_wol,
1123	.set_wol                = efx_ethtool_set_wol,
1124	.reset			= efx_ethtool_reset,
1125	.get_rxnfc		= efx_ethtool_get_rxnfc,
1126	.set_rxnfc		= efx_ethtool_set_rxnfc,
1127	.get_rxfh_indir_size	= efx_ethtool_get_rxfh_indir_size,
1128	.get_rxfh_indir		= efx_ethtool_get_rxfh_indir,
1129	.set_rxfh_indir		= efx_ethtool_set_rxfh_indir,
 
 
 
1130	.get_ts_info		= efx_ethtool_get_ts_info,
1131	.get_module_info	= efx_ethtool_get_module_info,
1132	.get_module_eeprom	= efx_ethtool_get_module_eeprom,
 
 
 
 
1133};
v5.4
   1// SPDX-License-Identifier: GPL-2.0-only
   2/****************************************************************************
   3 * Driver for Solarflare network controllers and boards
   4 * Copyright 2005-2006 Fen Systems Ltd.
   5 * Copyright 2006-2013 Solarflare Communications Inc.
 
 
 
 
   6 */
   7
   8#include <linux/netdevice.h>
   9#include <linux/ethtool.h>
  10#include <linux/rtnetlink.h>
  11#include <linux/in.h>
  12#include "net_driver.h"
  13#include "workarounds.h"
  14#include "selftest.h"
  15#include "efx.h"
  16#include "filter.h"
  17#include "nic.h"
  18
  19struct efx_sw_stat_desc {
  20	const char *name;
  21	enum {
  22		EFX_ETHTOOL_STAT_SOURCE_nic,
  23		EFX_ETHTOOL_STAT_SOURCE_channel,
  24		EFX_ETHTOOL_STAT_SOURCE_tx_queue
  25	} source;
  26	unsigned offset;
  27	u64(*get_stat) (void *field); /* Reader function */
  28};
  29
  30/* Initialiser for a struct efx_sw_stat_desc with type-checking */
  31#define EFX_ETHTOOL_STAT(stat_name, source_name, field, field_type, \
  32				get_stat_function) {			\
  33	.name = #stat_name,						\
  34	.source = EFX_ETHTOOL_STAT_SOURCE_##source_name,		\
  35	.offset = ((((field_type *) 0) ==				\
  36		      &((struct efx_##source_name *)0)->field) ?	\
  37		    offsetof(struct efx_##source_name, field) :		\
  38		    offsetof(struct efx_##source_name, field)),		\
  39	.get_stat = get_stat_function,					\
  40}
  41
  42static u64 efx_get_uint_stat(void *field)
  43{
  44	return *(unsigned int *)field;
  45}
  46
  47static u64 efx_get_atomic_stat(void *field)
  48{
  49	return atomic_read((atomic_t *) field);
  50}
  51
  52#define EFX_ETHTOOL_ATOMIC_NIC_ERROR_STAT(field)		\
  53	EFX_ETHTOOL_STAT(field, nic, field,			\
  54			 atomic_t, efx_get_atomic_stat)
  55
  56#define EFX_ETHTOOL_UINT_CHANNEL_STAT(field)			\
  57	EFX_ETHTOOL_STAT(field, channel, n_##field,		\
  58			 unsigned int, efx_get_uint_stat)
  59
  60#define EFX_ETHTOOL_UINT_TXQ_STAT(field)			\
  61	EFX_ETHTOOL_STAT(tx_##field, tx_queue, field,		\
  62			 unsigned int, efx_get_uint_stat)
  63
  64static const struct efx_sw_stat_desc efx_sw_stat_desc[] = {
  65	EFX_ETHTOOL_UINT_TXQ_STAT(merge_events),
  66	EFX_ETHTOOL_UINT_TXQ_STAT(tso_bursts),
  67	EFX_ETHTOOL_UINT_TXQ_STAT(tso_long_headers),
  68	EFX_ETHTOOL_UINT_TXQ_STAT(tso_packets),
  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	EFX_ETHTOOL_ATOMIC_NIC_ERROR_STAT(rx_reset),
  74	EFX_ETHTOOL_UINT_CHANNEL_STAT(rx_tobe_disc),
  75	EFX_ETHTOOL_UINT_CHANNEL_STAT(rx_ip_hdr_chksum_err),
  76	EFX_ETHTOOL_UINT_CHANNEL_STAT(rx_tcp_udp_chksum_err),
  77	EFX_ETHTOOL_UINT_CHANNEL_STAT(rx_inner_ip_hdr_chksum_err),
  78	EFX_ETHTOOL_UINT_CHANNEL_STAT(rx_inner_tcp_udp_chksum_err),
  79	EFX_ETHTOOL_UINT_CHANNEL_STAT(rx_outer_ip_hdr_chksum_err),
  80	EFX_ETHTOOL_UINT_CHANNEL_STAT(rx_outer_tcp_udp_chksum_err),
  81	EFX_ETHTOOL_UINT_CHANNEL_STAT(rx_eth_crc_err),
  82	EFX_ETHTOOL_UINT_CHANNEL_STAT(rx_mcast_mismatch),
  83	EFX_ETHTOOL_UINT_CHANNEL_STAT(rx_frm_trunc),
 
  84	EFX_ETHTOOL_UINT_CHANNEL_STAT(rx_merge_events),
  85	EFX_ETHTOOL_UINT_CHANNEL_STAT(rx_merge_packets),
  86};
  87
  88#define EFX_ETHTOOL_SW_STAT_COUNT ARRAY_SIZE(efx_sw_stat_desc)
  89
  90#define EFX_ETHTOOL_EEPROM_MAGIC 0xEFAB
  91
  92/**************************************************************************
  93 *
  94 * Ethtool operations
  95 *
  96 **************************************************************************
  97 */
  98
  99/* Identify device by flashing LEDs */
 100static int efx_ethtool_phys_id(struct net_device *net_dev,
 101			       enum ethtool_phys_id_state state)
 102{
 103	struct efx_nic *efx = netdev_priv(net_dev);
 104	enum efx_led_mode mode = EFX_LED_DEFAULT;
 105
 106	switch (state) {
 107	case ETHTOOL_ID_ON:
 108		mode = EFX_LED_ON;
 109		break;
 110	case ETHTOOL_ID_OFF:
 111		mode = EFX_LED_OFF;
 112		break;
 113	case ETHTOOL_ID_INACTIVE:
 114		mode = EFX_LED_DEFAULT;
 115		break;
 116	case ETHTOOL_ID_ACTIVE:
 117		return 1;	/* cycle on/off once per second */
 118	}
 119
 120	efx->type->set_id_led(efx, mode);
 121	return 0;
 122}
 123
 124/* This must be called with rtnl_lock held. */
 125static int
 126efx_ethtool_get_link_ksettings(struct net_device *net_dev,
 127			       struct ethtool_link_ksettings *cmd)
 128{
 129	struct efx_nic *efx = netdev_priv(net_dev);
 130	struct efx_link_state *link_state = &efx->link_state;
 131	u32 supported;
 132
 133	mutex_lock(&efx->mac_lock);
 134	efx->phy_op->get_link_ksettings(efx, cmd);
 135	mutex_unlock(&efx->mac_lock);
 136
 137	/* Both MACs support pause frames (bidirectional and respond-only) */
 138	ethtool_convert_link_mode_to_legacy_u32(&supported,
 139						cmd->link_modes.supported);
 140
 141	supported |= SUPPORTED_Pause | SUPPORTED_Asym_Pause;
 142
 143	ethtool_convert_legacy_u32_to_link_mode(cmd->link_modes.supported,
 144						supported);
 145
 146	if (LOOPBACK_INTERNAL(efx)) {
 147		cmd->base.speed = link_state->speed;
 148		cmd->base.duplex = link_state->fd ? DUPLEX_FULL : DUPLEX_HALF;
 149	}
 150
 151	return 0;
 152}
 153
 154/* This must be called with rtnl_lock held. */
 155static int
 156efx_ethtool_set_link_ksettings(struct net_device *net_dev,
 157			       const struct ethtool_link_ksettings *cmd)
 158{
 159	struct efx_nic *efx = netdev_priv(net_dev);
 160	int rc;
 161
 162	/* GMAC does not support 1000Mbps HD */
 163	if ((cmd->base.speed == SPEED_1000) &&
 164	    (cmd->base.duplex != DUPLEX_FULL)) {
 165		netif_dbg(efx, drv, efx->net_dev,
 166			  "rejecting unsupported 1000Mbps HD setting\n");
 167		return -EINVAL;
 168	}
 169
 170	mutex_lock(&efx->mac_lock);
 171	rc = efx->phy_op->set_link_ksettings(efx, cmd);
 172	mutex_unlock(&efx->mac_lock);
 173	return rc;
 174}
 175
 176static void efx_ethtool_get_drvinfo(struct net_device *net_dev,
 177				    struct ethtool_drvinfo *info)
 178{
 179	struct efx_nic *efx = netdev_priv(net_dev);
 180
 181	strlcpy(info->driver, KBUILD_MODNAME, sizeof(info->driver));
 182	strlcpy(info->version, EFX_DRIVER_VERSION, sizeof(info->version));
 183	efx_mcdi_print_fwver(efx, info->fw_version,
 184			     sizeof(info->fw_version));
 
 185	strlcpy(info->bus_info, pci_name(efx->pci_dev), sizeof(info->bus_info));
 186}
 187
 188static int efx_ethtool_get_regs_len(struct net_device *net_dev)
 189{
 190	return efx_nic_get_regs_len(netdev_priv(net_dev));
 191}
 192
 193static void efx_ethtool_get_regs(struct net_device *net_dev,
 194				 struct ethtool_regs *regs, void *buf)
 195{
 196	struct efx_nic *efx = netdev_priv(net_dev);
 197
 198	regs->version = efx->type->revision;
 199	efx_nic_get_regs(efx, buf);
 200}
 201
 202static u32 efx_ethtool_get_msglevel(struct net_device *net_dev)
 203{
 204	struct efx_nic *efx = netdev_priv(net_dev);
 205	return efx->msg_enable;
 206}
 207
 208static void efx_ethtool_set_msglevel(struct net_device *net_dev, u32 msg_enable)
 209{
 210	struct efx_nic *efx = netdev_priv(net_dev);
 211	efx->msg_enable = msg_enable;
 212}
 213
 214/**
 215 * efx_fill_test - fill in an individual self-test entry
 216 * @test_index:		Index of the test
 217 * @strings:		Ethtool strings, or %NULL
 218 * @data:		Ethtool test results, or %NULL
 219 * @test:		Pointer to test result (used only if data != %NULL)
 220 * @unit_format:	Unit name format (e.g. "chan\%d")
 221 * @unit_id:		Unit id (e.g. 0 for "chan0")
 222 * @test_format:	Test name format (e.g. "loopback.\%s.tx.sent")
 223 * @test_id:		Test id (e.g. "PHYXS" for "loopback.PHYXS.tx_sent")
 224 *
 225 * Fill in an individual self-test entry.
 226 */
 227static void efx_fill_test(unsigned int test_index, u8 *strings, u64 *data,
 228			  int *test, const char *unit_format, int unit_id,
 229			  const char *test_format, const char *test_id)
 230{
 231	char unit_str[ETH_GSTRING_LEN], test_str[ETH_GSTRING_LEN];
 232
 233	/* Fill data value, if applicable */
 234	if (data)
 235		data[test_index] = *test;
 236
 237	/* Fill string, if applicable */
 238	if (strings) {
 239		if (strchr(unit_format, '%'))
 240			snprintf(unit_str, sizeof(unit_str),
 241				 unit_format, unit_id);
 242		else
 243			strcpy(unit_str, unit_format);
 244		snprintf(test_str, sizeof(test_str), test_format, test_id);
 245		snprintf(strings + test_index * ETH_GSTRING_LEN,
 246			 ETH_GSTRING_LEN,
 247			 "%-6s %-24s", unit_str, test_str);
 248	}
 249}
 250
 251#define EFX_CHANNEL_NAME(_channel) "chan%d", _channel->channel
 252#define EFX_TX_QUEUE_NAME(_tx_queue) "txq%d", _tx_queue->queue
 253#define EFX_RX_QUEUE_NAME(_rx_queue) "rxq%d", _rx_queue->queue
 254#define EFX_LOOPBACK_NAME(_mode, _counter)			\
 255	"loopback.%s." _counter, STRING_TABLE_LOOKUP(_mode, efx_loopback_mode)
 256
 257/**
 258 * efx_fill_loopback_test - fill in a block of loopback self-test entries
 259 * @efx:		Efx NIC
 260 * @lb_tests:		Efx loopback self-test results structure
 261 * @mode:		Loopback test mode
 262 * @test_index:		Starting index of the test
 263 * @strings:		Ethtool strings, or %NULL
 264 * @data:		Ethtool test results, or %NULL
 265 *
 266 * Fill in a block of loopback self-test entries.  Return new test
 267 * index.
 268 */
 269static int efx_fill_loopback_test(struct efx_nic *efx,
 270				  struct efx_loopback_self_tests *lb_tests,
 271				  enum efx_loopback_mode mode,
 272				  unsigned int test_index,
 273				  u8 *strings, u64 *data)
 274{
 275	struct efx_channel *channel =
 276		efx_get_channel(efx, efx->tx_channel_offset);
 277	struct efx_tx_queue *tx_queue;
 278
 279	efx_for_each_channel_tx_queue(tx_queue, channel) {
 280		efx_fill_test(test_index++, strings, data,
 281			      &lb_tests->tx_sent[tx_queue->queue],
 282			      EFX_TX_QUEUE_NAME(tx_queue),
 283			      EFX_LOOPBACK_NAME(mode, "tx_sent"));
 284		efx_fill_test(test_index++, strings, data,
 285			      &lb_tests->tx_done[tx_queue->queue],
 286			      EFX_TX_QUEUE_NAME(tx_queue),
 287			      EFX_LOOPBACK_NAME(mode, "tx_done"));
 288	}
 289	efx_fill_test(test_index++, strings, data,
 290		      &lb_tests->rx_good,
 291		      "rx", 0,
 292		      EFX_LOOPBACK_NAME(mode, "rx_good"));
 293	efx_fill_test(test_index++, strings, data,
 294		      &lb_tests->rx_bad,
 295		      "rx", 0,
 296		      EFX_LOOPBACK_NAME(mode, "rx_bad"));
 297
 298	return test_index;
 299}
 300
 301/**
 302 * efx_ethtool_fill_self_tests - get self-test details
 303 * @efx:		Efx NIC
 304 * @tests:		Efx self-test results structure, or %NULL
 305 * @strings:		Ethtool strings, or %NULL
 306 * @data:		Ethtool test results, or %NULL
 307 *
 308 * Get self-test number of strings, strings, and/or test results.
 309 * Return number of strings (== number of test results).
 310 *
 311 * The reason for merging these three functions is to make sure that
 312 * they can never be inconsistent.
 313 */
 314static int efx_ethtool_fill_self_tests(struct efx_nic *efx,
 315				       struct efx_self_tests *tests,
 316				       u8 *strings, u64 *data)
 317{
 318	struct efx_channel *channel;
 319	unsigned int n = 0, i;
 320	enum efx_loopback_mode mode;
 321
 322	efx_fill_test(n++, strings, data, &tests->phy_alive,
 323		      "phy", 0, "alive", NULL);
 324	efx_fill_test(n++, strings, data, &tests->nvram,
 325		      "core", 0, "nvram", NULL);
 326	efx_fill_test(n++, strings, data, &tests->interrupt,
 327		      "core", 0, "interrupt", NULL);
 328
 329	/* Event queues */
 330	efx_for_each_channel(channel, efx) {
 331		efx_fill_test(n++, strings, data,
 332			      &tests->eventq_dma[channel->channel],
 333			      EFX_CHANNEL_NAME(channel),
 334			      "eventq.dma", NULL);
 335		efx_fill_test(n++, strings, data,
 336			      &tests->eventq_int[channel->channel],
 337			      EFX_CHANNEL_NAME(channel),
 338			      "eventq.int", NULL);
 339	}
 340
 341	efx_fill_test(n++, strings, data, &tests->memory,
 342		      "core", 0, "memory", NULL);
 343	efx_fill_test(n++, strings, data, &tests->registers,
 344		      "core", 0, "registers", NULL);
 345
 346	if (efx->phy_op->run_tests != NULL) {
 347		EFX_WARN_ON_PARANOID(efx->phy_op->test_name == NULL);
 348
 349		for (i = 0; true; ++i) {
 350			const char *name;
 351
 352			EFX_WARN_ON_PARANOID(i >= EFX_MAX_PHY_TESTS);
 353			name = efx->phy_op->test_name(efx, i);
 354			if (name == NULL)
 355				break;
 356
 357			efx_fill_test(n++, strings, data, &tests->phy_ext[i],
 358				      "phy", 0, name, NULL);
 359		}
 360	}
 361
 362	/* Loopback tests */
 363	for (mode = LOOPBACK_NONE; mode <= LOOPBACK_TEST_MAX; mode++) {
 364		if (!(efx->loopback_modes & (1 << mode)))
 365			continue;
 366		n = efx_fill_loopback_test(efx,
 367					   &tests->loopback[mode], mode, n,
 368					   strings, data);
 369	}
 370
 371	return n;
 372}
 373
 374static size_t efx_describe_per_queue_stats(struct efx_nic *efx, u8 *strings)
 375{
 376	size_t n_stats = 0;
 377	struct efx_channel *channel;
 378
 379	efx_for_each_channel(channel, efx) {
 380		if (efx_channel_has_tx_queues(channel)) {
 381			n_stats++;
 382			if (strings != NULL) {
 383				snprintf(strings, ETH_GSTRING_LEN,
 384					 "tx-%u.tx_packets",
 385					 channel->tx_queue[0].queue /
 386					 EFX_TXQ_TYPES);
 387
 388				strings += ETH_GSTRING_LEN;
 389			}
 390		}
 391	}
 392	efx_for_each_channel(channel, efx) {
 393		if (efx_channel_has_rx_queue(channel)) {
 394			n_stats++;
 395			if (strings != NULL) {
 396				snprintf(strings, ETH_GSTRING_LEN,
 397					 "rx-%d.rx_packets", channel->channel);
 398				strings += ETH_GSTRING_LEN;
 399			}
 400		}
 401	}
 402	return n_stats;
 403}
 404
 405static int efx_ethtool_get_sset_count(struct net_device *net_dev,
 406				      int string_set)
 407{
 408	struct efx_nic *efx = netdev_priv(net_dev);
 409
 410	switch (string_set) {
 411	case ETH_SS_STATS:
 412		return efx->type->describe_stats(efx, NULL) +
 413		       EFX_ETHTOOL_SW_STAT_COUNT +
 414		       efx_describe_per_queue_stats(efx, NULL) +
 415		       efx_ptp_describe_stats(efx, NULL);
 416	case ETH_SS_TEST:
 417		return efx_ethtool_fill_self_tests(efx, NULL, NULL, NULL);
 418	default:
 419		return -EINVAL;
 420	}
 421}
 422
 423static void efx_ethtool_get_strings(struct net_device *net_dev,
 424				    u32 string_set, u8 *strings)
 425{
 426	struct efx_nic *efx = netdev_priv(net_dev);
 427	int i;
 428
 429	switch (string_set) {
 430	case ETH_SS_STATS:
 431		strings += (efx->type->describe_stats(efx, strings) *
 432			    ETH_GSTRING_LEN);
 433		for (i = 0; i < EFX_ETHTOOL_SW_STAT_COUNT; i++)
 434			strlcpy(strings + i * ETH_GSTRING_LEN,
 435				efx_sw_stat_desc[i].name, ETH_GSTRING_LEN);
 436		strings += EFX_ETHTOOL_SW_STAT_COUNT * ETH_GSTRING_LEN;
 437		strings += (efx_describe_per_queue_stats(efx, strings) *
 438			    ETH_GSTRING_LEN);
 439		efx_ptp_describe_stats(efx, strings);
 440		break;
 441	case ETH_SS_TEST:
 442		efx_ethtool_fill_self_tests(efx, NULL, strings, NULL);
 443		break;
 444	default:
 445		/* No other string sets */
 446		break;
 447	}
 448}
 449
 450static void efx_ethtool_get_stats(struct net_device *net_dev,
 451				  struct ethtool_stats *stats,
 452				  u64 *data)
 453{
 454	struct efx_nic *efx = netdev_priv(net_dev);
 455	const struct efx_sw_stat_desc *stat;
 456	struct efx_channel *channel;
 457	struct efx_tx_queue *tx_queue;
 458	struct efx_rx_queue *rx_queue;
 459	int i;
 460
 461	spin_lock_bh(&efx->stats_lock);
 462
 463	/* Get NIC statistics */
 464	data += efx->type->update_stats(efx, data, NULL);
 465
 466	/* Get software statistics */
 467	for (i = 0; i < EFX_ETHTOOL_SW_STAT_COUNT; i++) {
 468		stat = &efx_sw_stat_desc[i];
 469		switch (stat->source) {
 470		case EFX_ETHTOOL_STAT_SOURCE_nic:
 471			data[i] = stat->get_stat((void *)efx + stat->offset);
 472			break;
 473		case EFX_ETHTOOL_STAT_SOURCE_channel:
 474			data[i] = 0;
 475			efx_for_each_channel(channel, efx)
 476				data[i] += stat->get_stat((void *)channel +
 477							  stat->offset);
 478			break;
 479		case EFX_ETHTOOL_STAT_SOURCE_tx_queue:
 480			data[i] = 0;
 481			efx_for_each_channel(channel, efx) {
 482				efx_for_each_channel_tx_queue(tx_queue, channel)
 483					data[i] +=
 484						stat->get_stat((void *)tx_queue
 485							       + stat->offset);
 486			}
 487			break;
 488		}
 489	}
 490	data += EFX_ETHTOOL_SW_STAT_COUNT;
 491
 492	spin_unlock_bh(&efx->stats_lock);
 493
 494	efx_for_each_channel(channel, efx) {
 495		if (efx_channel_has_tx_queues(channel)) {
 496			*data = 0;
 497			efx_for_each_channel_tx_queue(tx_queue, channel) {
 498				*data += tx_queue->tx_packets;
 499			}
 500			data++;
 501		}
 502	}
 503	efx_for_each_channel(channel, efx) {
 504		if (efx_channel_has_rx_queue(channel)) {
 505			*data = 0;
 506			efx_for_each_channel_rx_queue(rx_queue, channel) {
 507				*data += rx_queue->rx_packets;
 508			}
 509			data++;
 510		}
 511	}
 512
 513	efx_ptp_update_stats(efx, data);
 514}
 515
 516static void efx_ethtool_self_test(struct net_device *net_dev,
 517				  struct ethtool_test *test, u64 *data)
 518{
 519	struct efx_nic *efx = netdev_priv(net_dev);
 520	struct efx_self_tests *efx_tests;
 521	bool already_up;
 522	int rc = -ENOMEM;
 523
 524	efx_tests = kzalloc(sizeof(*efx_tests), GFP_KERNEL);
 525	if (!efx_tests)
 526		goto fail;
 527
 528	if (efx->state != STATE_READY) {
 529		rc = -EBUSY;
 530		goto out;
 531	}
 532
 533	netif_info(efx, drv, efx->net_dev, "starting %sline testing\n",
 534		   (test->flags & ETH_TEST_FL_OFFLINE) ? "off" : "on");
 535
 536	/* We need rx buffers and interrupts. */
 537	already_up = (efx->net_dev->flags & IFF_UP);
 538	if (!already_up) {
 539		rc = dev_open(efx->net_dev, NULL);
 540		if (rc) {
 541			netif_err(efx, drv, efx->net_dev,
 542				  "failed opening device.\n");
 543			goto out;
 544		}
 545	}
 546
 547	rc = efx_selftest(efx, efx_tests, test->flags);
 548
 549	if (!already_up)
 550		dev_close(efx->net_dev);
 551
 552	netif_info(efx, drv, efx->net_dev, "%s %sline self-tests\n",
 553		   rc == 0 ? "passed" : "failed",
 554		   (test->flags & ETH_TEST_FL_OFFLINE) ? "off" : "on");
 555
 556out:
 557	efx_ethtool_fill_self_tests(efx, efx_tests, NULL, data);
 558	kfree(efx_tests);
 559fail:
 560	if (rc)
 561		test->flags |= ETH_TEST_FL_FAILED;
 562}
 563
 564/* Restart autonegotiation */
 565static int efx_ethtool_nway_reset(struct net_device *net_dev)
 566{
 567	struct efx_nic *efx = netdev_priv(net_dev);
 568
 569	return mdio45_nway_restart(&efx->mdio);
 570}
 571
 572/*
 573 * Each channel has a single IRQ and moderation timer, started by any
 574 * completion (or other event).  Unless the module parameter
 575 * separate_tx_channels is set, IRQs and moderation are therefore
 576 * shared between RX and TX completions.  In this case, when RX IRQ
 577 * moderation is explicitly changed then TX IRQ moderation is
 578 * automatically changed too, but otherwise we fail if the two values
 579 * are requested to be different.
 580 *
 581 * The hardware does not support a limit on the number of completions
 582 * before an IRQ, so we do not use the max_frames fields.  We should
 583 * report and require that max_frames == (usecs != 0), but this would
 584 * invalidate existing user documentation.
 585 *
 586 * The hardware does not have distinct settings for interrupt
 587 * moderation while the previous IRQ is being handled, so we should
 588 * not use the 'irq' fields.  However, an earlier developer
 589 * misunderstood the meaning of the 'irq' fields and the driver did
 590 * not support the standard fields.  To avoid invalidating existing
 591 * user documentation, we report and accept changes through either the
 592 * standard or 'irq' fields.  If both are changed at the same time, we
 593 * prefer the standard field.
 594 *
 595 * We implement adaptive IRQ moderation, but use a different algorithm
 596 * from that assumed in the definition of struct ethtool_coalesce.
 597 * Therefore we do not use any of the adaptive moderation parameters
 598 * in it.
 599 */
 600
 601static int efx_ethtool_get_coalesce(struct net_device *net_dev,
 602				    struct ethtool_coalesce *coalesce)
 603{
 604	struct efx_nic *efx = netdev_priv(net_dev);
 605	unsigned int tx_usecs, rx_usecs;
 606	bool rx_adaptive;
 607
 608	efx_get_irq_moderation(efx, &tx_usecs, &rx_usecs, &rx_adaptive);
 609
 610	coalesce->tx_coalesce_usecs = tx_usecs;
 611	coalesce->tx_coalesce_usecs_irq = tx_usecs;
 612	coalesce->rx_coalesce_usecs = rx_usecs;
 613	coalesce->rx_coalesce_usecs_irq = rx_usecs;
 614	coalesce->use_adaptive_rx_coalesce = rx_adaptive;
 615
 616	return 0;
 617}
 618
 619static int efx_ethtool_set_coalesce(struct net_device *net_dev,
 620				    struct ethtool_coalesce *coalesce)
 621{
 622	struct efx_nic *efx = netdev_priv(net_dev);
 623	struct efx_channel *channel;
 624	unsigned int tx_usecs, rx_usecs;
 625	bool adaptive, rx_may_override_tx;
 626	int rc;
 627
 628	if (coalesce->use_adaptive_tx_coalesce)
 629		return -EINVAL;
 630
 631	efx_get_irq_moderation(efx, &tx_usecs, &rx_usecs, &adaptive);
 632
 633	if (coalesce->rx_coalesce_usecs != rx_usecs)
 634		rx_usecs = coalesce->rx_coalesce_usecs;
 635	else
 636		rx_usecs = coalesce->rx_coalesce_usecs_irq;
 637
 638	adaptive = coalesce->use_adaptive_rx_coalesce;
 639
 640	/* If channels are shared, TX IRQ moderation can be quietly
 641	 * overridden unless it is changed from its old value.
 642	 */
 643	rx_may_override_tx = (coalesce->tx_coalesce_usecs == tx_usecs &&
 644			      coalesce->tx_coalesce_usecs_irq == tx_usecs);
 645	if (coalesce->tx_coalesce_usecs != tx_usecs)
 646		tx_usecs = coalesce->tx_coalesce_usecs;
 647	else
 648		tx_usecs = coalesce->tx_coalesce_usecs_irq;
 649
 650	rc = efx_init_irq_moderation(efx, tx_usecs, rx_usecs, adaptive,
 651				     rx_may_override_tx);
 652	if (rc != 0)
 653		return rc;
 654
 655	efx_for_each_channel(channel, efx)
 656		efx->type->push_irq_moderation(channel);
 657
 658	return 0;
 659}
 660
 661static void efx_ethtool_get_ringparam(struct net_device *net_dev,
 662				      struct ethtool_ringparam *ring)
 663{
 664	struct efx_nic *efx = netdev_priv(net_dev);
 665
 666	ring->rx_max_pending = EFX_MAX_DMAQ_SIZE;
 667	ring->tx_max_pending = EFX_TXQ_MAX_ENT(efx);
 668	ring->rx_pending = efx->rxq_entries;
 669	ring->tx_pending = efx->txq_entries;
 670}
 671
 672static int efx_ethtool_set_ringparam(struct net_device *net_dev,
 673				     struct ethtool_ringparam *ring)
 674{
 675	struct efx_nic *efx = netdev_priv(net_dev);
 676	u32 txq_entries;
 677
 678	if (ring->rx_mini_pending || ring->rx_jumbo_pending ||
 679	    ring->rx_pending > EFX_MAX_DMAQ_SIZE ||
 680	    ring->tx_pending > EFX_TXQ_MAX_ENT(efx))
 681		return -EINVAL;
 682
 683	if (ring->rx_pending < EFX_RXQ_MIN_ENT) {
 684		netif_err(efx, drv, efx->net_dev,
 685			  "RX queues cannot be smaller than %u\n",
 686			  EFX_RXQ_MIN_ENT);
 687		return -EINVAL;
 688	}
 689
 690	txq_entries = max(ring->tx_pending, EFX_TXQ_MIN_ENT(efx));
 691	if (txq_entries != ring->tx_pending)
 692		netif_warn(efx, drv, efx->net_dev,
 693			   "increasing TX queue size to minimum of %u\n",
 694			   txq_entries);
 695
 696	return efx_realloc_channels(efx, ring->rx_pending, txq_entries);
 697}
 698
 699static int efx_ethtool_set_pauseparam(struct net_device *net_dev,
 700				      struct ethtool_pauseparam *pause)
 701{
 702	struct efx_nic *efx = netdev_priv(net_dev);
 703	u8 wanted_fc, old_fc;
 704	u32 old_adv;
 705	int rc = 0;
 706
 707	mutex_lock(&efx->mac_lock);
 708
 709	wanted_fc = ((pause->rx_pause ? EFX_FC_RX : 0) |
 710		     (pause->tx_pause ? EFX_FC_TX : 0) |
 711		     (pause->autoneg ? EFX_FC_AUTO : 0));
 712
 713	if ((wanted_fc & EFX_FC_TX) && !(wanted_fc & EFX_FC_RX)) {
 714		netif_dbg(efx, drv, efx->net_dev,
 715			  "Flow control unsupported: tx ON rx OFF\n");
 716		rc = -EINVAL;
 717		goto out;
 718	}
 719
 720	if ((wanted_fc & EFX_FC_AUTO) && !efx->link_advertising[0]) {
 721		netif_dbg(efx, drv, efx->net_dev,
 722			  "Autonegotiation is disabled\n");
 723		rc = -EINVAL;
 724		goto out;
 725	}
 726
 727	/* Hook for Falcon bug 11482 workaround */
 728	if (efx->type->prepare_enable_fc_tx &&
 729	    (wanted_fc & EFX_FC_TX) && !(efx->wanted_fc & EFX_FC_TX))
 730		efx->type->prepare_enable_fc_tx(efx);
 731
 732	old_adv = efx->link_advertising[0];
 733	old_fc = efx->wanted_fc;
 734	efx_link_set_wanted_fc(efx, wanted_fc);
 735	if (efx->link_advertising[0] != old_adv ||
 736	    (efx->wanted_fc ^ old_fc) & EFX_FC_AUTO) {
 737		rc = efx->phy_op->reconfigure(efx);
 738		if (rc) {
 739			netif_err(efx, drv, efx->net_dev,
 740				  "Unable to advertise requested flow "
 741				  "control setting\n");
 742			goto out;
 743		}
 744	}
 745
 746	/* Reconfigure the MAC. The PHY *may* generate a link state change event
 747	 * if the user just changed the advertised capabilities, but there's no
 748	 * harm doing this twice */
 749	efx_mac_reconfigure(efx);
 750
 751out:
 752	mutex_unlock(&efx->mac_lock);
 753
 754	return rc;
 755}
 756
 757static void efx_ethtool_get_pauseparam(struct net_device *net_dev,
 758				       struct ethtool_pauseparam *pause)
 759{
 760	struct efx_nic *efx = netdev_priv(net_dev);
 761
 762	pause->rx_pause = !!(efx->wanted_fc & EFX_FC_RX);
 763	pause->tx_pause = !!(efx->wanted_fc & EFX_FC_TX);
 764	pause->autoneg = !!(efx->wanted_fc & EFX_FC_AUTO);
 765}
 766
 767static void efx_ethtool_get_wol(struct net_device *net_dev,
 768				struct ethtool_wolinfo *wol)
 769{
 770	struct efx_nic *efx = netdev_priv(net_dev);
 771	return efx->type->get_wol(efx, wol);
 772}
 773
 774
 775static int efx_ethtool_set_wol(struct net_device *net_dev,
 776			       struct ethtool_wolinfo *wol)
 777{
 778	struct efx_nic *efx = netdev_priv(net_dev);
 779	return efx->type->set_wol(efx, wol->wolopts);
 780}
 781
 782static int efx_ethtool_reset(struct net_device *net_dev, u32 *flags)
 783{
 784	struct efx_nic *efx = netdev_priv(net_dev);
 785	int rc;
 786
 787	rc = efx->type->map_reset_flags(flags);
 788	if (rc < 0)
 789		return rc;
 790
 791	return efx_reset(efx, rc);
 792}
 793
 794/* MAC address mask including only I/G bit */
 795static const u8 mac_addr_ig_mask[ETH_ALEN] __aligned(2) = {0x01, 0, 0, 0, 0, 0};
 796
 797#define IP4_ADDR_FULL_MASK	((__force __be32)~0)
 798#define IP_PROTO_FULL_MASK	0xFF
 799#define PORT_FULL_MASK		((__force __be16)~0)
 800#define ETHER_TYPE_FULL_MASK	((__force __be16)~0)
 801
 802static inline void ip6_fill_mask(__be32 *mask)
 803{
 804	mask[0] = mask[1] = mask[2] = mask[3] = ~(__be32)0;
 805}
 806
 807static int efx_ethtool_get_class_rule(struct efx_nic *efx,
 808				      struct ethtool_rx_flow_spec *rule,
 809				      u32 *rss_context)
 810{
 811	struct ethtool_tcpip4_spec *ip_entry = &rule->h_u.tcp_ip4_spec;
 812	struct ethtool_tcpip4_spec *ip_mask = &rule->m_u.tcp_ip4_spec;
 813	struct ethtool_usrip4_spec *uip_entry = &rule->h_u.usr_ip4_spec;
 814	struct ethtool_usrip4_spec *uip_mask = &rule->m_u.usr_ip4_spec;
 815	struct ethtool_tcpip6_spec *ip6_entry = &rule->h_u.tcp_ip6_spec;
 816	struct ethtool_tcpip6_spec *ip6_mask = &rule->m_u.tcp_ip6_spec;
 817	struct ethtool_usrip6_spec *uip6_entry = &rule->h_u.usr_ip6_spec;
 818	struct ethtool_usrip6_spec *uip6_mask = &rule->m_u.usr_ip6_spec;
 819	struct ethhdr *mac_entry = &rule->h_u.ether_spec;
 820	struct ethhdr *mac_mask = &rule->m_u.ether_spec;
 821	struct efx_filter_spec spec;
 822	int rc;
 823
 824	rc = efx_filter_get_filter_safe(efx, EFX_FILTER_PRI_MANUAL,
 825					rule->location, &spec);
 826	if (rc)
 827		return rc;
 828
 829	if (spec.dmaq_id == EFX_FILTER_RX_DMAQ_ID_DROP)
 830		rule->ring_cookie = RX_CLS_FLOW_DISC;
 831	else
 832		rule->ring_cookie = spec.dmaq_id;
 833
 834	if ((spec.match_flags & EFX_FILTER_MATCH_ETHER_TYPE) &&
 835	    spec.ether_type == htons(ETH_P_IP) &&
 836	    (spec.match_flags & EFX_FILTER_MATCH_IP_PROTO) &&
 837	    (spec.ip_proto == IPPROTO_TCP || spec.ip_proto == IPPROTO_UDP) &&
 838	    !(spec.match_flags &
 839	      ~(EFX_FILTER_MATCH_ETHER_TYPE | EFX_FILTER_MATCH_OUTER_VID |
 840		EFX_FILTER_MATCH_LOC_HOST | EFX_FILTER_MATCH_REM_HOST |
 841		EFX_FILTER_MATCH_IP_PROTO |
 842		EFX_FILTER_MATCH_LOC_PORT | EFX_FILTER_MATCH_REM_PORT))) {
 843		rule->flow_type = ((spec.ip_proto == IPPROTO_TCP) ?
 844				   TCP_V4_FLOW : UDP_V4_FLOW);
 845		if (spec.match_flags & EFX_FILTER_MATCH_LOC_HOST) {
 846			ip_entry->ip4dst = spec.loc_host[0];
 847			ip_mask->ip4dst = IP4_ADDR_FULL_MASK;
 848		}
 849		if (spec.match_flags & EFX_FILTER_MATCH_REM_HOST) {
 850			ip_entry->ip4src = spec.rem_host[0];
 851			ip_mask->ip4src = IP4_ADDR_FULL_MASK;
 852		}
 853		if (spec.match_flags & EFX_FILTER_MATCH_LOC_PORT) {
 854			ip_entry->pdst = spec.loc_port;
 855			ip_mask->pdst = PORT_FULL_MASK;
 856		}
 857		if (spec.match_flags & EFX_FILTER_MATCH_REM_PORT) {
 858			ip_entry->psrc = spec.rem_port;
 859			ip_mask->psrc = PORT_FULL_MASK;
 860		}
 861	} else if ((spec.match_flags & EFX_FILTER_MATCH_ETHER_TYPE) &&
 862	    spec.ether_type == htons(ETH_P_IPV6) &&
 863	    (spec.match_flags & EFX_FILTER_MATCH_IP_PROTO) &&
 864	    (spec.ip_proto == IPPROTO_TCP || spec.ip_proto == IPPROTO_UDP) &&
 865	    !(spec.match_flags &
 866	      ~(EFX_FILTER_MATCH_ETHER_TYPE | EFX_FILTER_MATCH_OUTER_VID |
 867		EFX_FILTER_MATCH_LOC_HOST | EFX_FILTER_MATCH_REM_HOST |
 868		EFX_FILTER_MATCH_IP_PROTO |
 869		EFX_FILTER_MATCH_LOC_PORT | EFX_FILTER_MATCH_REM_PORT))) {
 870		rule->flow_type = ((spec.ip_proto == IPPROTO_TCP) ?
 871				   TCP_V6_FLOW : UDP_V6_FLOW);
 872		if (spec.match_flags & EFX_FILTER_MATCH_LOC_HOST) {
 873			memcpy(ip6_entry->ip6dst, spec.loc_host,
 874			       sizeof(ip6_entry->ip6dst));
 875			ip6_fill_mask(ip6_mask->ip6dst);
 876		}
 877		if (spec.match_flags & EFX_FILTER_MATCH_REM_HOST) {
 878			memcpy(ip6_entry->ip6src, spec.rem_host,
 879			       sizeof(ip6_entry->ip6src));
 880			ip6_fill_mask(ip6_mask->ip6src);
 881		}
 882		if (spec.match_flags & EFX_FILTER_MATCH_LOC_PORT) {
 883			ip6_entry->pdst = spec.loc_port;
 884			ip6_mask->pdst = PORT_FULL_MASK;
 885		}
 886		if (spec.match_flags & EFX_FILTER_MATCH_REM_PORT) {
 887			ip6_entry->psrc = spec.rem_port;
 888			ip6_mask->psrc = PORT_FULL_MASK;
 889		}
 890	} else if (!(spec.match_flags &
 891		     ~(EFX_FILTER_MATCH_LOC_MAC | EFX_FILTER_MATCH_LOC_MAC_IG |
 892		       EFX_FILTER_MATCH_REM_MAC | EFX_FILTER_MATCH_ETHER_TYPE |
 893		       EFX_FILTER_MATCH_OUTER_VID))) {
 894		rule->flow_type = ETHER_FLOW;
 895		if (spec.match_flags &
 896		    (EFX_FILTER_MATCH_LOC_MAC | EFX_FILTER_MATCH_LOC_MAC_IG)) {
 897			ether_addr_copy(mac_entry->h_dest, spec.loc_mac);
 898			if (spec.match_flags & EFX_FILTER_MATCH_LOC_MAC)
 899				eth_broadcast_addr(mac_mask->h_dest);
 900			else
 901				ether_addr_copy(mac_mask->h_dest,
 902						mac_addr_ig_mask);
 903		}
 904		if (spec.match_flags & EFX_FILTER_MATCH_REM_MAC) {
 905			ether_addr_copy(mac_entry->h_source, spec.rem_mac);
 906			eth_broadcast_addr(mac_mask->h_source);
 907		}
 908		if (spec.match_flags & EFX_FILTER_MATCH_ETHER_TYPE) {
 909			mac_entry->h_proto = spec.ether_type;
 910			mac_mask->h_proto = ETHER_TYPE_FULL_MASK;
 911		}
 912	} else if (spec.match_flags & EFX_FILTER_MATCH_ETHER_TYPE &&
 913		   spec.ether_type == htons(ETH_P_IP) &&
 914		   !(spec.match_flags &
 915		     ~(EFX_FILTER_MATCH_ETHER_TYPE | EFX_FILTER_MATCH_OUTER_VID |
 916		       EFX_FILTER_MATCH_LOC_HOST | EFX_FILTER_MATCH_REM_HOST |
 917		       EFX_FILTER_MATCH_IP_PROTO))) {
 918		rule->flow_type = IPV4_USER_FLOW;
 919		uip_entry->ip_ver = ETH_RX_NFC_IP4;
 920		if (spec.match_flags & EFX_FILTER_MATCH_IP_PROTO) {
 921			uip_mask->proto = IP_PROTO_FULL_MASK;
 922			uip_entry->proto = spec.ip_proto;
 923		}
 924		if (spec.match_flags & EFX_FILTER_MATCH_LOC_HOST) {
 925			uip_entry->ip4dst = spec.loc_host[0];
 926			uip_mask->ip4dst = IP4_ADDR_FULL_MASK;
 927		}
 928		if (spec.match_flags & EFX_FILTER_MATCH_REM_HOST) {
 929			uip_entry->ip4src = spec.rem_host[0];
 930			uip_mask->ip4src = IP4_ADDR_FULL_MASK;
 931		}
 932	} else if (spec.match_flags & EFX_FILTER_MATCH_ETHER_TYPE &&
 933		   spec.ether_type == htons(ETH_P_IPV6) &&
 934		   !(spec.match_flags &
 935		     ~(EFX_FILTER_MATCH_ETHER_TYPE | EFX_FILTER_MATCH_OUTER_VID |
 936		       EFX_FILTER_MATCH_LOC_HOST | EFX_FILTER_MATCH_REM_HOST |
 937		       EFX_FILTER_MATCH_IP_PROTO))) {
 938		rule->flow_type = IPV6_USER_FLOW;
 939		if (spec.match_flags & EFX_FILTER_MATCH_IP_PROTO) {
 940			uip6_mask->l4_proto = IP_PROTO_FULL_MASK;
 941			uip6_entry->l4_proto = spec.ip_proto;
 942		}
 943		if (spec.match_flags & EFX_FILTER_MATCH_LOC_HOST) {
 944			memcpy(uip6_entry->ip6dst, spec.loc_host,
 945			       sizeof(uip6_entry->ip6dst));
 946			ip6_fill_mask(uip6_mask->ip6dst);
 947		}
 948		if (spec.match_flags & EFX_FILTER_MATCH_REM_HOST) {
 949			memcpy(uip6_entry->ip6src, spec.rem_host,
 950			       sizeof(uip6_entry->ip6src));
 951			ip6_fill_mask(uip6_mask->ip6src);
 952		}
 953	} else {
 954		/* The above should handle all filters that we insert */
 955		WARN_ON(1);
 956		return -EINVAL;
 957	}
 958
 959	if (spec.match_flags & EFX_FILTER_MATCH_OUTER_VID) {
 960		rule->flow_type |= FLOW_EXT;
 961		rule->h_ext.vlan_tci = spec.outer_vid;
 962		rule->m_ext.vlan_tci = htons(0xfff);
 963	}
 964
 965	if (spec.flags & EFX_FILTER_FLAG_RX_RSS) {
 966		rule->flow_type |= FLOW_RSS;
 967		*rss_context = spec.rss_context;
 968	}
 969
 970	return rc;
 971}
 972
 973static int
 974efx_ethtool_get_rxnfc(struct net_device *net_dev,
 975		      struct ethtool_rxnfc *info, u32 *rule_locs)
 976{
 977	struct efx_nic *efx = netdev_priv(net_dev);
 978	u32 rss_context = 0;
 979	s32 rc = 0;
 980
 981	switch (info->cmd) {
 982	case ETHTOOL_GRXRINGS:
 983		info->data = efx->n_rx_channels;
 984		return 0;
 985
 986	case ETHTOOL_GRXFH: {
 987		struct efx_rss_context *ctx = &efx->rss_context;
 988
 989		mutex_lock(&efx->rss_lock);
 990		if (info->flow_type & FLOW_RSS && info->rss_context) {
 991			ctx = efx_find_rss_context_entry(efx, info->rss_context);
 992			if (!ctx) {
 993				rc = -ENOENT;
 994				goto out_unlock;
 995			}
 996		}
 997		info->data = 0;
 998		if (!efx_rss_active(ctx)) /* No RSS */
 999			goto out_unlock;
1000		switch (info->flow_type & ~FLOW_RSS) {
1001		case UDP_V4_FLOW:
1002			if (ctx->rx_hash_udp_4tuple)
1003				/* fall through */
1004		case TCP_V4_FLOW:
1005				info->data |= RXH_L4_B_0_1 | RXH_L4_B_2_3;
1006			/* fall through */
 
1007		case SCTP_V4_FLOW:
1008		case AH_ESP_V4_FLOW:
1009		case IPV4_FLOW:
1010			info->data |= RXH_IP_SRC | RXH_IP_DST;
 
1011			break;
1012		case UDP_V6_FLOW:
1013			if (ctx->rx_hash_udp_4tuple)
1014				/* fall through */
1015		case TCP_V6_FLOW:
1016				info->data |= RXH_L4_B_0_1 | RXH_L4_B_2_3;
1017			/* fall through */
 
1018		case SCTP_V6_FLOW:
1019		case AH_ESP_V6_FLOW:
1020		case IPV6_FLOW:
1021			info->data |= RXH_IP_SRC | RXH_IP_DST;
 
1022			break;
1023		default:
1024			break;
1025		}
1026out_unlock:
1027		mutex_unlock(&efx->rss_lock);
1028		return rc;
1029	}
1030
1031	case ETHTOOL_GRXCLSRLCNT:
1032		info->data = efx_filter_get_rx_id_limit(efx);
1033		if (info->data == 0)
1034			return -EOPNOTSUPP;
1035		info->data |= RX_CLS_LOC_SPECIAL;
1036		info->rule_cnt =
1037			efx_filter_count_rx_used(efx, EFX_FILTER_PRI_MANUAL);
1038		return 0;
1039
1040	case ETHTOOL_GRXCLSRULE:
1041		if (efx_filter_get_rx_id_limit(efx) == 0)
1042			return -EOPNOTSUPP;
1043		rc = efx_ethtool_get_class_rule(efx, &info->fs, &rss_context);
1044		if (rc < 0)
1045			return rc;
1046		if (info->fs.flow_type & FLOW_RSS)
1047			info->rss_context = rss_context;
1048		return 0;
1049
1050	case ETHTOOL_GRXCLSRLALL:
 
1051		info->data = efx_filter_get_rx_id_limit(efx);
1052		if (info->data == 0)
1053			return -EOPNOTSUPP;
1054		rc = efx_filter_get_rx_ids(efx, EFX_FILTER_PRI_MANUAL,
1055					   rule_locs, info->rule_cnt);
1056		if (rc < 0)
1057			return rc;
1058		info->rule_cnt = rc;
1059		return 0;
 
1060
1061	default:
1062		return -EOPNOTSUPP;
1063	}
1064}
1065
1066static inline bool ip6_mask_is_full(__be32 mask[4])
1067{
1068	return !~(mask[0] & mask[1] & mask[2] & mask[3]);
1069}
1070
1071static inline bool ip6_mask_is_empty(__be32 mask[4])
1072{
1073	return !(mask[0] | mask[1] | mask[2] | mask[3]);
1074}
1075
1076static int efx_ethtool_set_class_rule(struct efx_nic *efx,
1077				      struct ethtool_rx_flow_spec *rule,
1078				      u32 rss_context)
1079{
1080	struct ethtool_tcpip4_spec *ip_entry = &rule->h_u.tcp_ip4_spec;
1081	struct ethtool_tcpip4_spec *ip_mask = &rule->m_u.tcp_ip4_spec;
1082	struct ethtool_usrip4_spec *uip_entry = &rule->h_u.usr_ip4_spec;
1083	struct ethtool_usrip4_spec *uip_mask = &rule->m_u.usr_ip4_spec;
1084	struct ethtool_tcpip6_spec *ip6_entry = &rule->h_u.tcp_ip6_spec;
1085	struct ethtool_tcpip6_spec *ip6_mask = &rule->m_u.tcp_ip6_spec;
1086	struct ethtool_usrip6_spec *uip6_entry = &rule->h_u.usr_ip6_spec;
1087	struct ethtool_usrip6_spec *uip6_mask = &rule->m_u.usr_ip6_spec;
1088	u32 flow_type = rule->flow_type & ~(FLOW_EXT | FLOW_RSS);
1089	struct ethhdr *mac_entry = &rule->h_u.ether_spec;
1090	struct ethhdr *mac_mask = &rule->m_u.ether_spec;
1091	enum efx_filter_flags flags = 0;
1092	struct efx_filter_spec spec;
1093	int rc;
1094
1095	/* Check that user wants us to choose the location */
1096	if (rule->location != RX_CLS_LOC_ANY)
1097		return -EINVAL;
1098
1099	/* Range-check ring_cookie */
1100	if (rule->ring_cookie >= efx->n_rx_channels &&
1101	    rule->ring_cookie != RX_CLS_FLOW_DISC)
1102		return -EINVAL;
1103
1104	/* Check for unsupported extensions */
1105	if ((rule->flow_type & FLOW_EXT) &&
1106	    (rule->m_ext.vlan_etype || rule->m_ext.data[0] ||
1107	     rule->m_ext.data[1]))
1108		return -EINVAL;
1109
1110	if (efx->rx_scatter)
1111		flags |= EFX_FILTER_FLAG_RX_SCATTER;
1112	if (rule->flow_type & FLOW_RSS)
1113		flags |= EFX_FILTER_FLAG_RX_RSS;
1114
1115	efx_filter_init_rx(&spec, EFX_FILTER_PRI_MANUAL, flags,
1116			   (rule->ring_cookie == RX_CLS_FLOW_DISC) ?
1117			   EFX_FILTER_RX_DMAQ_ID_DROP : rule->ring_cookie);
1118
1119	if (rule->flow_type & FLOW_RSS)
1120		spec.rss_context = rss_context;
1121
1122	switch (flow_type) {
1123	case TCP_V4_FLOW:
1124	case UDP_V4_FLOW:
1125		spec.match_flags = (EFX_FILTER_MATCH_ETHER_TYPE |
1126				    EFX_FILTER_MATCH_IP_PROTO);
1127		spec.ether_type = htons(ETH_P_IP);
1128		spec.ip_proto = flow_type == TCP_V4_FLOW ? IPPROTO_TCP
1129							 : IPPROTO_UDP;
1130		if (ip_mask->ip4dst) {
1131			if (ip_mask->ip4dst != IP4_ADDR_FULL_MASK)
1132				return -EINVAL;
1133			spec.match_flags |= EFX_FILTER_MATCH_LOC_HOST;
1134			spec.loc_host[0] = ip_entry->ip4dst;
1135		}
1136		if (ip_mask->ip4src) {
1137			if (ip_mask->ip4src != IP4_ADDR_FULL_MASK)
1138				return -EINVAL;
1139			spec.match_flags |= EFX_FILTER_MATCH_REM_HOST;
1140			spec.rem_host[0] = ip_entry->ip4src;
1141		}
1142		if (ip_mask->pdst) {
1143			if (ip_mask->pdst != PORT_FULL_MASK)
1144				return -EINVAL;
1145			spec.match_flags |= EFX_FILTER_MATCH_LOC_PORT;
1146			spec.loc_port = ip_entry->pdst;
1147		}
1148		if (ip_mask->psrc) {
1149			if (ip_mask->psrc != PORT_FULL_MASK)
1150				return -EINVAL;
1151			spec.match_flags |= EFX_FILTER_MATCH_REM_PORT;
1152			spec.rem_port = ip_entry->psrc;
1153		}
1154		if (ip_mask->tos)
1155			return -EINVAL;
1156		break;
1157
1158	case TCP_V6_FLOW:
1159	case UDP_V6_FLOW:
1160		spec.match_flags = (EFX_FILTER_MATCH_ETHER_TYPE |
1161				    EFX_FILTER_MATCH_IP_PROTO);
1162		spec.ether_type = htons(ETH_P_IPV6);
1163		spec.ip_proto = flow_type == TCP_V6_FLOW ? IPPROTO_TCP
1164							 : IPPROTO_UDP;
1165		if (!ip6_mask_is_empty(ip6_mask->ip6dst)) {
1166			if (!ip6_mask_is_full(ip6_mask->ip6dst))
1167				return -EINVAL;
1168			spec.match_flags |= EFX_FILTER_MATCH_LOC_HOST;
1169			memcpy(spec.loc_host, ip6_entry->ip6dst, sizeof(spec.loc_host));
1170		}
1171		if (!ip6_mask_is_empty(ip6_mask->ip6src)) {
1172			if (!ip6_mask_is_full(ip6_mask->ip6src))
1173				return -EINVAL;
1174			spec.match_flags |= EFX_FILTER_MATCH_REM_HOST;
1175			memcpy(spec.rem_host, ip6_entry->ip6src, sizeof(spec.rem_host));
1176		}
1177		if (ip6_mask->pdst) {
1178			if (ip6_mask->pdst != PORT_FULL_MASK)
1179				return -EINVAL;
1180			spec.match_flags |= EFX_FILTER_MATCH_LOC_PORT;
1181			spec.loc_port = ip6_entry->pdst;
1182		}
1183		if (ip6_mask->psrc) {
1184			if (ip6_mask->psrc != PORT_FULL_MASK)
1185				return -EINVAL;
1186			spec.match_flags |= EFX_FILTER_MATCH_REM_PORT;
1187			spec.rem_port = ip6_entry->psrc;
1188		}
1189		if (ip6_mask->tclass)
1190			return -EINVAL;
1191		break;
1192
1193	case IPV4_USER_FLOW:
1194		if (uip_mask->l4_4_bytes || uip_mask->tos || uip_mask->ip_ver ||
1195		    uip_entry->ip_ver != ETH_RX_NFC_IP4)
1196			return -EINVAL;
1197		spec.match_flags = EFX_FILTER_MATCH_ETHER_TYPE;
1198		spec.ether_type = htons(ETH_P_IP);
1199		if (uip_mask->ip4dst) {
1200			if (uip_mask->ip4dst != IP4_ADDR_FULL_MASK)
1201				return -EINVAL;
1202			spec.match_flags |= EFX_FILTER_MATCH_LOC_HOST;
1203			spec.loc_host[0] = uip_entry->ip4dst;
1204		}
1205		if (uip_mask->ip4src) {
1206			if (uip_mask->ip4src != IP4_ADDR_FULL_MASK)
1207				return -EINVAL;
1208			spec.match_flags |= EFX_FILTER_MATCH_REM_HOST;
1209			spec.rem_host[0] = uip_entry->ip4src;
1210		}
1211		if (uip_mask->proto) {
1212			if (uip_mask->proto != IP_PROTO_FULL_MASK)
1213				return -EINVAL;
1214			spec.match_flags |= EFX_FILTER_MATCH_IP_PROTO;
1215			spec.ip_proto = uip_entry->proto;
1216		}
1217		break;
1218
1219	case IPV6_USER_FLOW:
1220		if (uip6_mask->l4_4_bytes || uip6_mask->tclass)
1221			return -EINVAL;
1222		spec.match_flags = EFX_FILTER_MATCH_ETHER_TYPE;
1223		spec.ether_type = htons(ETH_P_IPV6);
1224		if (!ip6_mask_is_empty(uip6_mask->ip6dst)) {
1225			if (!ip6_mask_is_full(uip6_mask->ip6dst))
1226				return -EINVAL;
1227			spec.match_flags |= EFX_FILTER_MATCH_LOC_HOST;
1228			memcpy(spec.loc_host, uip6_entry->ip6dst, sizeof(spec.loc_host));
1229		}
1230		if (!ip6_mask_is_empty(uip6_mask->ip6src)) {
1231			if (!ip6_mask_is_full(uip6_mask->ip6src))
1232				return -EINVAL;
1233			spec.match_flags |= EFX_FILTER_MATCH_REM_HOST;
1234			memcpy(spec.rem_host, uip6_entry->ip6src, sizeof(spec.rem_host));
1235		}
1236		if (uip6_mask->l4_proto) {
1237			if (uip6_mask->l4_proto != IP_PROTO_FULL_MASK)
1238				return -EINVAL;
1239			spec.match_flags |= EFX_FILTER_MATCH_IP_PROTO;
1240			spec.ip_proto = uip6_entry->l4_proto;
1241		}
1242		break;
1243
1244	case ETHER_FLOW:
1245		if (!is_zero_ether_addr(mac_mask->h_dest)) {
1246			if (ether_addr_equal(mac_mask->h_dest,
1247					     mac_addr_ig_mask))
1248				spec.match_flags |= EFX_FILTER_MATCH_LOC_MAC_IG;
1249			else if (is_broadcast_ether_addr(mac_mask->h_dest))
1250				spec.match_flags |= EFX_FILTER_MATCH_LOC_MAC;
1251			else
1252				return -EINVAL;
1253			ether_addr_copy(spec.loc_mac, mac_entry->h_dest);
1254		}
1255		if (!is_zero_ether_addr(mac_mask->h_source)) {
1256			if (!is_broadcast_ether_addr(mac_mask->h_source))
1257				return -EINVAL;
1258			spec.match_flags |= EFX_FILTER_MATCH_REM_MAC;
1259			ether_addr_copy(spec.rem_mac, mac_entry->h_source);
1260		}
1261		if (mac_mask->h_proto) {
1262			if (mac_mask->h_proto != ETHER_TYPE_FULL_MASK)
1263				return -EINVAL;
1264			spec.match_flags |= EFX_FILTER_MATCH_ETHER_TYPE;
1265			spec.ether_type = mac_entry->h_proto;
1266		}
1267		break;
1268
1269	default:
1270		return -EINVAL;
1271	}
1272
1273	if ((rule->flow_type & FLOW_EXT) && rule->m_ext.vlan_tci) {
1274		if (rule->m_ext.vlan_tci != htons(0xfff))
1275			return -EINVAL;
1276		spec.match_flags |= EFX_FILTER_MATCH_OUTER_VID;
1277		spec.outer_vid = rule->h_ext.vlan_tci;
1278	}
1279
1280	rc = efx_filter_insert_filter(efx, &spec, true);
1281	if (rc < 0)
1282		return rc;
1283
1284	rule->location = rc;
1285	return 0;
1286}
1287
1288static int efx_ethtool_set_rxnfc(struct net_device *net_dev,
1289				 struct ethtool_rxnfc *info)
1290{
1291	struct efx_nic *efx = netdev_priv(net_dev);
1292
1293	if (efx_filter_get_rx_id_limit(efx) == 0)
1294		return -EOPNOTSUPP;
1295
1296	switch (info->cmd) {
1297	case ETHTOOL_SRXCLSRLINS:
1298		return efx_ethtool_set_class_rule(efx, &info->fs,
1299						  info->rss_context);
1300
1301	case ETHTOOL_SRXCLSRLDEL:
1302		return efx_filter_remove_id_safe(efx, EFX_FILTER_PRI_MANUAL,
1303						 info->fs.location);
1304
1305	default:
1306		return -EOPNOTSUPP;
1307	}
1308}
1309
1310static u32 efx_ethtool_get_rxfh_indir_size(struct net_device *net_dev)
1311{
1312	struct efx_nic *efx = netdev_priv(net_dev);
1313
1314	if (efx->n_rx_channels == 1)
1315		return 0;
1316	return ARRAY_SIZE(efx->rss_context.rx_indir_table);
1317}
1318
1319static u32 efx_ethtool_get_rxfh_key_size(struct net_device *net_dev)
1320{
1321	struct efx_nic *efx = netdev_priv(net_dev);
1322
1323	return efx->type->rx_hash_key_size;
 
1324}
1325
1326static int efx_ethtool_get_rxfh(struct net_device *net_dev, u32 *indir, u8 *key,
1327				u8 *hfunc)
1328{
1329	struct efx_nic *efx = netdev_priv(net_dev);
1330	int rc;
1331
1332	rc = efx->type->rx_pull_rss_config(efx);
1333	if (rc)
1334		return rc;
1335
1336	if (hfunc)
1337		*hfunc = ETH_RSS_HASH_TOP;
1338	if (indir)
1339		memcpy(indir, efx->rss_context.rx_indir_table,
1340		       sizeof(efx->rss_context.rx_indir_table));
1341	if (key)
1342		memcpy(key, efx->rss_context.rx_hash_key,
1343		       efx->type->rx_hash_key_size);
1344	return 0;
1345}
1346
1347static int efx_ethtool_set_rxfh(struct net_device *net_dev, const u32 *indir,
1348				const u8 *key, const u8 hfunc)
1349{
1350	struct efx_nic *efx = netdev_priv(net_dev);
1351
1352	/* Hash function is Toeplitz, cannot be changed */
1353	if (hfunc != ETH_RSS_HASH_NO_CHANGE && hfunc != ETH_RSS_HASH_TOP)
1354		return -EOPNOTSUPP;
1355	if (!indir && !key)
1356		return 0;
1357
1358	if (!key)
1359		key = efx->rss_context.rx_hash_key;
1360	if (!indir)
1361		indir = efx->rss_context.rx_indir_table;
1362
1363	return efx->type->rx_push_rss_config(efx, true, indir, key);
1364}
1365
1366static int efx_ethtool_get_rxfh_context(struct net_device *net_dev, u32 *indir,
1367					u8 *key, u8 *hfunc, u32 rss_context)
1368{
1369	struct efx_nic *efx = netdev_priv(net_dev);
1370	struct efx_rss_context *ctx;
1371	int rc = 0;
1372
1373	if (!efx->type->rx_pull_rss_context_config)
1374		return -EOPNOTSUPP;
1375
1376	mutex_lock(&efx->rss_lock);
1377	ctx = efx_find_rss_context_entry(efx, rss_context);
1378	if (!ctx) {
1379		rc = -ENOENT;
1380		goto out_unlock;
1381	}
1382	rc = efx->type->rx_pull_rss_context_config(efx, ctx);
1383	if (rc)
1384		goto out_unlock;
1385
1386	if (hfunc)
1387		*hfunc = ETH_RSS_HASH_TOP;
1388	if (indir)
1389		memcpy(indir, ctx->rx_indir_table, sizeof(ctx->rx_indir_table));
1390	if (key)
1391		memcpy(key, ctx->rx_hash_key, efx->type->rx_hash_key_size);
1392out_unlock:
1393	mutex_unlock(&efx->rss_lock);
1394	return rc;
1395}
1396
1397static int efx_ethtool_set_rxfh_context(struct net_device *net_dev,
1398					const u32 *indir, const u8 *key,
1399					const u8 hfunc, u32 *rss_context,
1400					bool delete)
1401{
1402	struct efx_nic *efx = netdev_priv(net_dev);
1403	struct efx_rss_context *ctx;
1404	bool allocated = false;
1405	int rc;
1406
1407	if (!efx->type->rx_push_rss_context_config)
1408		return -EOPNOTSUPP;
1409	/* Hash function is Toeplitz, cannot be changed */
1410	if (hfunc != ETH_RSS_HASH_NO_CHANGE && hfunc != ETH_RSS_HASH_TOP)
1411		return -EOPNOTSUPP;
1412
1413	mutex_lock(&efx->rss_lock);
1414
1415	if (*rss_context == ETH_RXFH_CONTEXT_ALLOC) {
1416		if (delete) {
1417			/* alloc + delete == Nothing to do */
1418			rc = -EINVAL;
1419			goto out_unlock;
1420		}
1421		ctx = efx_alloc_rss_context_entry(efx);
1422		if (!ctx) {
1423			rc = -ENOMEM;
1424			goto out_unlock;
1425		}
1426		ctx->context_id = EFX_EF10_RSS_CONTEXT_INVALID;
1427		/* Initialise indir table and key to defaults */
1428		efx_set_default_rx_indir_table(efx, ctx);
1429		netdev_rss_key_fill(ctx->rx_hash_key, sizeof(ctx->rx_hash_key));
1430		allocated = true;
1431	} else {
1432		ctx = efx_find_rss_context_entry(efx, *rss_context);
1433		if (!ctx) {
1434			rc = -ENOENT;
1435			goto out_unlock;
1436		}
1437	}
1438
1439	if (delete) {
1440		/* delete this context */
1441		rc = efx->type->rx_push_rss_context_config(efx, ctx, NULL, NULL);
1442		if (!rc)
1443			efx_free_rss_context_entry(ctx);
1444		goto out_unlock;
1445	}
1446
1447	if (!key)
1448		key = ctx->rx_hash_key;
1449	if (!indir)
1450		indir = ctx->rx_indir_table;
1451
1452	rc = efx->type->rx_push_rss_context_config(efx, ctx, indir, key);
1453	if (rc && allocated)
1454		efx_free_rss_context_entry(ctx);
1455	else
1456		*rss_context = ctx->user_id;
1457out_unlock:
1458	mutex_unlock(&efx->rss_lock);
1459	return rc;
1460}
1461
1462static int efx_ethtool_get_ts_info(struct net_device *net_dev,
1463				   struct ethtool_ts_info *ts_info)
1464{
1465	struct efx_nic *efx = netdev_priv(net_dev);
1466
1467	/* Software capabilities */
1468	ts_info->so_timestamping = (SOF_TIMESTAMPING_RX_SOFTWARE |
1469				    SOF_TIMESTAMPING_SOFTWARE);
1470	ts_info->phc_index = -1;
1471
1472	efx_ptp_get_ts_info(efx, ts_info);
1473	return 0;
1474}
1475
1476static int efx_ethtool_get_module_eeprom(struct net_device *net_dev,
1477					 struct ethtool_eeprom *ee,
1478					 u8 *data)
1479{
1480	struct efx_nic *efx = netdev_priv(net_dev);
1481	int ret;
1482
1483	if (!efx->phy_op || !efx->phy_op->get_module_eeprom)
1484		return -EOPNOTSUPP;
1485
1486	mutex_lock(&efx->mac_lock);
1487	ret = efx->phy_op->get_module_eeprom(efx, ee, data);
1488	mutex_unlock(&efx->mac_lock);
1489
1490	return ret;
1491}
1492
1493static int efx_ethtool_get_module_info(struct net_device *net_dev,
1494				       struct ethtool_modinfo *modinfo)
1495{
1496	struct efx_nic *efx = netdev_priv(net_dev);
1497	int ret;
1498
1499	if (!efx->phy_op || !efx->phy_op->get_module_info)
1500		return -EOPNOTSUPP;
1501
1502	mutex_lock(&efx->mac_lock);
1503	ret = efx->phy_op->get_module_info(efx, modinfo);
1504	mutex_unlock(&efx->mac_lock);
1505
1506	return ret;
1507}
1508
1509static int efx_ethtool_get_fecparam(struct net_device *net_dev,
1510				    struct ethtool_fecparam *fecparam)
1511{
1512	struct efx_nic *efx = netdev_priv(net_dev);
1513	int rc;
1514
1515	if (!efx->phy_op || !efx->phy_op->get_fecparam)
1516		return -EOPNOTSUPP;
1517	mutex_lock(&efx->mac_lock);
1518	rc = efx->phy_op->get_fecparam(efx, fecparam);
1519	mutex_unlock(&efx->mac_lock);
1520
1521	return rc;
1522}
1523
1524static int efx_ethtool_set_fecparam(struct net_device *net_dev,
1525				    struct ethtool_fecparam *fecparam)
1526{
1527	struct efx_nic *efx = netdev_priv(net_dev);
1528	int rc;
1529
1530	if (!efx->phy_op || !efx->phy_op->get_fecparam)
1531		return -EOPNOTSUPP;
1532	mutex_lock(&efx->mac_lock);
1533	rc = efx->phy_op->set_fecparam(efx, fecparam);
1534	mutex_unlock(&efx->mac_lock);
1535
1536	return rc;
1537}
1538
1539const struct ethtool_ops efx_ethtool_ops = {
 
 
1540	.get_drvinfo		= efx_ethtool_get_drvinfo,
1541	.get_regs_len		= efx_ethtool_get_regs_len,
1542	.get_regs		= efx_ethtool_get_regs,
1543	.get_msglevel		= efx_ethtool_get_msglevel,
1544	.set_msglevel		= efx_ethtool_set_msglevel,
1545	.nway_reset		= efx_ethtool_nway_reset,
1546	.get_link		= ethtool_op_get_link,
1547	.get_coalesce		= efx_ethtool_get_coalesce,
1548	.set_coalesce		= efx_ethtool_set_coalesce,
1549	.get_ringparam		= efx_ethtool_get_ringparam,
1550	.set_ringparam		= efx_ethtool_set_ringparam,
1551	.get_pauseparam         = efx_ethtool_get_pauseparam,
1552	.set_pauseparam         = efx_ethtool_set_pauseparam,
1553	.get_sset_count		= efx_ethtool_get_sset_count,
1554	.self_test		= efx_ethtool_self_test,
1555	.get_strings		= efx_ethtool_get_strings,
1556	.set_phys_id		= efx_ethtool_phys_id,
1557	.get_ethtool_stats	= efx_ethtool_get_stats,
1558	.get_wol                = efx_ethtool_get_wol,
1559	.set_wol                = efx_ethtool_set_wol,
1560	.reset			= efx_ethtool_reset,
1561	.get_rxnfc		= efx_ethtool_get_rxnfc,
1562	.set_rxnfc		= efx_ethtool_set_rxnfc,
1563	.get_rxfh_indir_size	= efx_ethtool_get_rxfh_indir_size,
1564	.get_rxfh_key_size	= efx_ethtool_get_rxfh_key_size,
1565	.get_rxfh		= efx_ethtool_get_rxfh,
1566	.set_rxfh		= efx_ethtool_set_rxfh,
1567	.get_rxfh_context	= efx_ethtool_get_rxfh_context,
1568	.set_rxfh_context	= efx_ethtool_set_rxfh_context,
1569	.get_ts_info		= efx_ethtool_get_ts_info,
1570	.get_module_info	= efx_ethtool_get_module_info,
1571	.get_module_eeprom	= efx_ethtool_get_module_eeprom,
1572	.get_link_ksettings	= efx_ethtool_get_link_ksettings,
1573	.set_link_ksettings	= efx_ethtool_set_link_ksettings,
1574	.get_fecparam		= efx_ethtool_get_fecparam,
1575	.set_fecparam		= efx_ethtool_set_fecparam,
1576};