efx.c 32.8 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 2005-2013 Solarflare Communications Inc.
6 7
 */

8
#include <linux/filter.h>
9 10 11 12 13 14 15 16 17 18
#include <linux/module.h>
#include <linux/pci.h>
#include <linux/netdevice.h>
#include <linux/etherdevice.h>
#include <linux/delay.h>
#include <linux/notifier.h>
#include <linux/ip.h>
#include <linux/tcp.h>
#include <linux/in.h>
#include <linux/ethtool.h>
19
#include <linux/topology.h>
20
#include <linux/gfp.h>
21
#include <linux/aer.h>
22
#include <linux/interrupt.h>
23
#include "net_driver.h"
24 25
#include <net/gre.h>
#include <net/udp_tunnel.h>
26
#include "efx.h"
27 28
#include "efx_common.h"
#include "efx_channels.h"
E
Edward Cree 已提交
29
#include "ef100.h"
30 31
#include "rx_common.h"
#include "tx_common.h"
B
Ben Hutchings 已提交
32
#include "nic.h"
33
#include "io.h"
34
#include "selftest.h"
35
#include "sriov.h"
36

E
Edward Cree 已提交
37
#include "mcdi_port_common.h"
38
#include "mcdi_pcol.h"
39
#include "workarounds.h"
40

41 42 43 44 45 46
/**************************************************************************
 *
 * Configurable values
 *
 *************************************************************************/

47 48 49 50
module_param_named(interrupt_mode, efx_interrupt_mode, uint, 0444);
MODULE_PARM_DESC(interrupt_mode,
		 "Interrupt mode (0=>MSIX 1=>MSI 2=>legacy)");

51 52 53
module_param(rss_cpus, uint, 0444);
MODULE_PARM_DESC(rss_cpus, "Number of CPUs to use for Receive-Side Scaling");

54 55 56
/*
 * Use separate channels for TX and RX events
 *
57 58
 * Set this to 1 to use separate channels for TX and RX. It allows us
 * to control interrupt affinity separately for TX and RX.
59
 *
60
 * This is only used in MSI-X interrupt mode
61
 */
62 63 64
bool efx_separate_tx_channels;
module_param(efx_separate_tx_channels, bool, 0444);
MODULE_PARM_DESC(efx_separate_tx_channels,
65
		 "Use separate channels for TX and RX");
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85

/* Initial interrupt moderation settings.  They can be modified after
 * module load with ethtool.
 *
 * The default for RX should strike a balance between increasing the
 * round-trip latency and reducing overhead.
 */
static unsigned int rx_irq_mod_usec = 60;

/* Initial interrupt moderation settings.  They can be modified after
 * module load with ethtool.
 *
 * This default is chosen to ensure that a 10G link does not go idle
 * while a TX queue is stopped after it has become full.  A queue is
 * restarted when it drops below half full.  The time this takes (assuming
 * worst case 3 descriptors per packet and 1024 descriptors) is
 *   512 / 3 * 1.2 = 205 usec.
 */
static unsigned int tx_irq_mod_usec = 150;

86 87
static bool phy_flash_cfg;
module_param(phy_flash_cfg, bool, 0644);
88 89
MODULE_PARM_DESC(phy_flash_cfg, "Set PHYs into reflash mode initially");

90 91 92 93 94 95 96
static unsigned debug = (NETIF_MSG_DRV | NETIF_MSG_PROBE |
			 NETIF_MSG_LINK | NETIF_MSG_IFDOWN |
			 NETIF_MSG_IFUP | NETIF_MSG_RX_ERR |
			 NETIF_MSG_TX_ERR | NETIF_MSG_HW);
module_param(debug, uint, 0);
MODULE_PARM_DESC(debug, "Bitmapped debugging message enable value");

97 98 99 100 101
/**************************************************************************
 *
 * Utility functions and prototypes
 *
 *************************************************************************/
102

103
static void efx_remove_port(struct efx_nic *efx);
104 105
static int efx_xdp_setup_prog(struct efx_nic *efx, struct bpf_prog *prog);
static int efx_xdp(struct net_device *dev, struct netdev_bpf *xdp);
106 107
static int efx_xdp_xmit(struct net_device *dev, int n, struct xdp_frame **xdpfs,
			u32 flags);
108 109 110 111 112 113 114

/**************************************************************************
 *
 * Port handling
 *
 **************************************************************************/

115 116
static void efx_fini_port(struct efx_nic *efx);

117 118 119 120
static int efx_probe_port(struct efx_nic *efx)
{
	int rc;

121
	netif_dbg(efx, probe, efx->net_dev, "create port\n");
122

123 124 125
	if (phy_flash_cfg)
		efx->phy_mode = PHY_MODE_SPECIAL;

126 127
	/* Connect up MAC/PHY operations table */
	rc = efx->type->probe_port(efx);
128
	if (rc)
129
		return rc;
130

131
	/* Initialise MAC address to permanent address */
132
	eth_hw_addr_set(efx->net_dev, efx->net_dev->perm_addr);
133 134 135 136 137 138 139 140

	return 0;
}

static int efx_init_port(struct efx_nic *efx)
{
	int rc;

141
	netif_dbg(efx, drv, efx->net_dev, "init port\n");
142

143 144
	mutex_lock(&efx->mac_lock);

145
	efx->port_initialized = true;
146

B
Ben Hutchings 已提交
147
	/* Ensure the PHY advertises the correct flow control settings */
E
Edward Cree 已提交
148
	rc = efx_mcdi_port_reconfigure(efx);
149
	if (rc && rc != -EPERM)
E
Edward Cree 已提交
150
		goto fail;
B
Ben Hutchings 已提交
151

152
	mutex_unlock(&efx->mac_lock);
153
	return 0;
154

E
Edward Cree 已提交
155
fail:
156
	mutex_unlock(&efx->mac_lock);
157
	return rc;
158 159 160 161
}

static void efx_fini_port(struct efx_nic *efx)
{
162
	netif_dbg(efx, drv, efx->net_dev, "shut down port\n");
163 164 165 166

	if (!efx->port_initialized)
		return;

167
	efx->port_initialized = false;
168

169
	efx->link_state.up = false;
170 171 172 173 174
	efx_link_status_changed(efx);
}

static void efx_remove_port(struct efx_nic *efx)
{
175
	netif_dbg(efx, drv, efx->net_dev, "destroying port\n");
176

177
	efx->type->remove_port(efx);
178 179 180 181 182 183 184 185
}

/**************************************************************************
 *
 * NIC handling
 *
 **************************************************************************/

186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256
static LIST_HEAD(efx_primary_list);
static LIST_HEAD(efx_unassociated_list);

static bool efx_same_controller(struct efx_nic *left, struct efx_nic *right)
{
	return left->type == right->type &&
		left->vpd_sn && right->vpd_sn &&
		!strcmp(left->vpd_sn, right->vpd_sn);
}

static void efx_associate(struct efx_nic *efx)
{
	struct efx_nic *other, *next;

	if (efx->primary == efx) {
		/* Adding primary function; look for secondaries */

		netif_dbg(efx, probe, efx->net_dev, "adding to primary list\n");
		list_add_tail(&efx->node, &efx_primary_list);

		list_for_each_entry_safe(other, next, &efx_unassociated_list,
					 node) {
			if (efx_same_controller(efx, other)) {
				list_del(&other->node);
				netif_dbg(other, probe, other->net_dev,
					  "moving to secondary list of %s %s\n",
					  pci_name(efx->pci_dev),
					  efx->net_dev->name);
				list_add_tail(&other->node,
					      &efx->secondary_list);
				other->primary = efx;
			}
		}
	} else {
		/* Adding secondary function; look for primary */

		list_for_each_entry(other, &efx_primary_list, node) {
			if (efx_same_controller(efx, other)) {
				netif_dbg(efx, probe, efx->net_dev,
					  "adding to secondary list of %s %s\n",
					  pci_name(other->pci_dev),
					  other->net_dev->name);
				list_add_tail(&efx->node,
					      &other->secondary_list);
				efx->primary = other;
				return;
			}
		}

		netif_dbg(efx, probe, efx->net_dev,
			  "adding to unassociated list\n");
		list_add_tail(&efx->node, &efx_unassociated_list);
	}
}

static void efx_dissociate(struct efx_nic *efx)
{
	struct efx_nic *other, *next;

	list_del(&efx->node);
	efx->primary = NULL;

	list_for_each_entry_safe(other, next, &efx->secondary_list, node) {
		list_del(&other->node);
		netif_dbg(other, probe, other->net_dev,
			  "moving to unassociated list\n");
		list_add_tail(&other->node, &efx_unassociated_list);
		other->primary = NULL;
	}
}

257 258 259 260
static int efx_probe_nic(struct efx_nic *efx)
{
	int rc;

261
	netif_dbg(efx, probe, efx->net_dev, "creating NIC\n");
262 263

	/* Carry out hardware-type specific initialisation */
264
	rc = efx->type->probe(efx);
265 266 267
	if (rc)
		return rc;

268 269 270 271 272 273 274 275
	do {
		if (!efx->max_channels || !efx->max_tx_channels) {
			netif_err(efx, drv, efx->net_dev,
				  "Insufficient resources to allocate"
				  " any channels\n");
			rc = -ENOSPC;
			goto fail1;
		}
276

277 278 279 280 281 282
		/* Determine the number of channels and queues by trying
		 * to hook in MSI-X interrupts.
		 */
		rc = efx_probe_interrupts(efx);
		if (rc)
			goto fail1;
283

284 285 286
		rc = efx_set_channels(efx);
		if (rc)
			goto fail1;
287 288 289 290 291 292 293 294 295 296 297

		/* dimension_resources can fail with EAGAIN */
		rc = efx->type->dimension_resources(efx);
		if (rc != 0 && rc != -EAGAIN)
			goto fail2;

		if (rc == -EAGAIN)
			/* try again with new max_channels */
			efx_remove_interrupts(efx);

	} while (rc == -EAGAIN);
298

299
	if (efx->n_channels > 1)
300 301 302
		netdev_rss_key_fill(efx->rss_context.rx_hash_key,
				    sizeof(efx->rss_context.rx_hash_key));
	efx_set_default_rx_indir_table(efx, &efx->rss_context);
303

304
	/* Initialise the interrupt moderation settings */
305
	efx->irq_mod_step_us = DIV_ROUND_UP(efx->timer_quantum_ns, 1000);
306 307
	efx_init_irq_moderation(efx, tx_irq_mod_usec, rx_irq_mod_usec, true,
				true);
308 309

	return 0;
310

311 312 313
fail2:
	efx_remove_interrupts(efx);
fail1:
314 315
	efx->type->remove(efx);
	return rc;
316 317 318 319
}

static void efx_remove_nic(struct efx_nic *efx)
{
320
	netif_dbg(efx, drv, efx->net_dev, "destroying NIC\n");
321 322

	efx_remove_interrupts(efx);
323
	efx->type->remove(efx);
324 325 326 327 328 329 330 331 332 333 334 335 336 337
}

/**************************************************************************
 *
 * NIC startup/shutdown
 *
 *************************************************************************/

static int efx_probe_all(struct efx_nic *efx)
{
	int rc;

	rc = efx_probe_nic(efx);
	if (rc) {
338
		netif_err(efx, probe, efx->net_dev, "failed to create NIC\n");
339 340 341 342 343
		goto fail1;
	}

	rc = efx_probe_port(efx);
	if (rc) {
344
		netif_err(efx, probe, efx->net_dev, "failed to create port\n");
345 346 347
		goto fail2;
	}

348 349 350 351 352
	BUILD_BUG_ON(EFX_DEFAULT_DMAQ_SIZE < EFX_RXQ_MIN_ENT);
	if (WARN_ON(EFX_DEFAULT_DMAQ_SIZE < EFX_TXQ_MIN_ENT(efx))) {
		rc = -EINVAL;
		goto fail3;
	}
353

354 355 356 357 358 359 360 361
#ifdef CONFIG_SFC_SRIOV
	rc = efx->type->vswitching_probe(efx);
	if (rc) /* not fatal; the PF will still work fine */
		netif_warn(efx, probe, efx->net_dev,
			   "failed to setup vswitching rc=%d;"
			   " VFs may not function\n", rc);
#endif

B
Ben Hutchings 已提交
362 363 364 365
	rc = efx_probe_filters(efx);
	if (rc) {
		netif_err(efx, probe, efx->net_dev,
			  "failed to create filter tables\n");
366
		goto fail4;
B
Ben Hutchings 已提交
367 368
	}

369 370
	rc = efx_probe_channels(efx);
	if (rc)
371
		goto fail5;
372

373 374
	efx->state = STATE_NET_DOWN;

375 376
	return 0;

377
 fail5:
378
	efx_remove_filters(efx);
379 380 381 382
 fail4:
#ifdef CONFIG_SFC_SRIOV
	efx->type->vswitching_remove(efx);
#endif
383 384 385 386 387 388 389 390 391 392
 fail3:
	efx_remove_port(efx);
 fail2:
	efx_remove_nic(efx);
 fail1:
	return rc;
}

static void efx_remove_all(struct efx_nic *efx)
{
393 394 395 396
	rtnl_lock();
	efx_xdp_setup_prog(efx, NULL);
	rtnl_unlock();

397
	efx_remove_channels(efx);
398
	efx_remove_filters(efx);
399 400 401
#ifdef CONFIG_SFC_SRIOV
	efx->type->vswitching_remove(efx);
#endif
402 403 404 405 406 407 408 409 410
	efx_remove_port(efx);
	efx_remove_nic(efx);
}

/**************************************************************************
 *
 * Interrupt moderation
 *
 **************************************************************************/
411
unsigned int efx_usecs_to_ticks(struct efx_nic *efx, unsigned int usecs)
412
{
413 414
	if (usecs == 0)
		return 0;
415
	if (usecs * 1000 < efx->timer_quantum_ns)
416
		return 1; /* never round down to 0 */
417 418 419 420 421 422 423 424 425
	return usecs * 1000 / efx->timer_quantum_ns;
}

unsigned int efx_ticks_to_usecs(struct efx_nic *efx, unsigned int ticks)
{
	/* We must round up when converting ticks to microseconds
	 * because we round down when converting the other way.
	 */
	return DIV_ROUND_UP(ticks * efx->timer_quantum_ns, 1000);
426 427
}

428
/* Set interrupt moderation parameters */
429 430 431
int efx_init_irq_moderation(struct efx_nic *efx, unsigned int tx_usecs,
			    unsigned int rx_usecs, bool rx_adaptive,
			    bool rx_may_override_tx)
432
{
433
	struct efx_channel *channel;
434 435
	unsigned int timer_max_us;

436 437
	EFX_ASSERT_RESET_SERIALISED(efx);

438 439 440
	timer_max_us = efx->timer_max_ns / 1000;

	if (tx_usecs > timer_max_us || rx_usecs > timer_max_us)
441 442
		return -EINVAL;

443
	if (tx_usecs != rx_usecs && efx->tx_channel_offset == 0 &&
444 445 446 447 448 449
	    !rx_may_override_tx) {
		netif_err(efx, drv, efx->net_dev, "Channels are shared. "
			  "RX and TX IRQ moderation must be equal\n");
		return -EINVAL;
	}

450
	efx->irq_rx_adaptive = rx_adaptive;
451
	efx->irq_rx_moderation_us = rx_usecs;
452
	efx_for_each_channel(channel, efx) {
453
		if (efx_channel_has_rx_queue(channel))
454
			channel->irq_moderation_us = rx_usecs;
455
		else if (efx_channel_has_tx_queues(channel))
456
			channel->irq_moderation_us = tx_usecs;
457 458
		else if (efx_channel_is_xdp_tx(channel))
			channel->irq_moderation_us = tx_usecs;
459
	}
460 461

	return 0;
462 463
}

464 465 466 467
void efx_get_irq_moderation(struct efx_nic *efx, unsigned int *tx_usecs,
			    unsigned int *rx_usecs, bool *rx_adaptive)
{
	*rx_adaptive = efx->irq_rx_adaptive;
468
	*rx_usecs = efx->irq_rx_moderation_us;
469 470 471 472 473

	/* If channels are shared between RX and TX, so is IRQ
	 * moderation.  Otherwise, IRQ moderation is the same for all
	 * TX channels and is not adaptive.
	 */
474
	if (efx->tx_channel_offset == 0) {
475
		*tx_usecs = *rx_usecs;
476 477 478 479 480 481
	} else {
		struct efx_channel *tx_channel;

		tx_channel = efx->channel[efx->tx_channel_offset];
		*tx_usecs = tx_channel->irq_moderation_us;
	}
482 483
}

484 485 486 487 488 489 490 491 492 493 494
/**************************************************************************
 *
 * ioctls
 *
 *************************************************************************/

/* Net device ioctl
 * Context: process, rtnl_lock() held.
 */
static int efx_ioctl(struct net_device *net_dev, struct ifreq *ifr, int cmd)
{
495
	struct efx_nic *efx = efx_netdev_priv(net_dev);
496
	struct mii_ioctl_data *data = if_mii(ifr);
497

498
	if (cmd == SIOCSHWTSTAMP)
499 500 501
		return efx_ptp_set_ts_config(efx, ifr);
	if (cmd == SIOCGHWTSTAMP)
		return efx_ptp_get_ts_config(efx, ifr);
502

503 504 505 506 507 508
	/* Convert phy_id from older PRTAD/DEVAD format */
	if ((cmd == SIOCGMIIREG || cmd == SIOCSMIIREG) &&
	    (data->phy_id & 0xfc00) == 0x0400)
		data->phy_id ^= MDIO_PHY_ID_C45 | 0x0400;

	return mdio_mii_ioctl(&efx->mdio, data, cmd);
509 510 511 512 513 514 515 516 517
}

/**************************************************************************
 *
 * Kernel net device interface
 *
 *************************************************************************/

/* Context: process, rtnl_lock() held. */
518
int efx_net_open(struct net_device *net_dev)
519
{
520
	struct efx_nic *efx = efx_netdev_priv(net_dev);
521 522
	int rc;

523 524
	netif_dbg(efx, ifup, efx->net_dev, "opening device on CPU %d\n",
		  raw_smp_processor_id());
525

526 527 528
	rc = efx_check_disabled(efx);
	if (rc)
		return rc;
529 530
	if (efx->phy_mode & PHY_MODE_SPECIAL)
		return -EBUSY;
531 532
	if (efx_mcdi_poll_reboot(efx) && efx_reset(efx, RESET_TYPE_ALL))
		return -EIO;
533

534 535 536 537
	/* Notify the kernel of the link state polled during driver load,
	 * before the monitor starts running */
	efx_link_status_changed(efx);

538
	efx_start_all(efx);
539 540
	if (efx->state == STATE_DISABLED || efx->reset_pending)
		netif_device_detach(efx->net_dev);
541 542 543
	else
		efx->state = STATE_NET_UP;

544
	efx_selftest_async_start(efx);
545 546 547 548 549 550 551
	return 0;
}

/* Context: process, rtnl_lock() held.
 * Note that the kernel will ignore our return code; this method
 * should really be a void.
 */
552
int efx_net_stop(struct net_device *net_dev)
553
{
554
	struct efx_nic *efx = efx_netdev_priv(net_dev);
555

556 557
	netif_dbg(efx, ifdown, efx->net_dev, "closing on CPU %d\n",
		  raw_smp_processor_id());
558

559 560
	/* Stop the device and flush all the channels */
	efx_stop_all(efx);
561 562 563 564

	return 0;
}

565 566
static int efx_vlan_rx_add_vid(struct net_device *net_dev, __be16 proto, u16 vid)
{
567
	struct efx_nic *efx = efx_netdev_priv(net_dev);
568 569 570 571 572 573 574 575 576

	if (efx->type->vlan_rx_add_vid)
		return efx->type->vlan_rx_add_vid(efx, proto, vid);
	else
		return -EOPNOTSUPP;
}

static int efx_vlan_rx_kill_vid(struct net_device *net_dev, __be16 proto, u16 vid)
{
577
	struct efx_nic *efx = efx_netdev_priv(net_dev);
578 579 580 581 582 583 584

	if (efx->type->vlan_rx_kill_vid)
		return efx->type->vlan_rx_kill_vid(efx, proto, vid);
	else
		return -EOPNOTSUPP;
}

585
static const struct net_device_ops efx_netdev_ops = {
S
Stephen Hemminger 已提交
586 587
	.ndo_open		= efx_net_open,
	.ndo_stop		= efx_net_stop,
588
	.ndo_get_stats64	= efx_net_stats,
S
Stephen Hemminger 已提交
589 590 591
	.ndo_tx_timeout		= efx_watchdog,
	.ndo_start_xmit		= efx_hard_start_xmit,
	.ndo_validate_addr	= eth_validate_addr,
592
	.ndo_eth_ioctl		= efx_ioctl,
S
Stephen Hemminger 已提交
593 594
	.ndo_change_mtu		= efx_change_mtu,
	.ndo_set_mac_address	= efx_set_mac_address,
595
	.ndo_set_rx_mode	= efx_set_rx_mode,
596
	.ndo_set_features	= efx_set_features,
597
	.ndo_features_check	= efx_features_check,
598 599
	.ndo_vlan_rx_add_vid	= efx_vlan_rx_add_vid,
	.ndo_vlan_rx_kill_vid	= efx_vlan_rx_kill_vid,
600
#ifdef CONFIG_SFC_SRIOV
601 602 603 604
	.ndo_set_vf_mac		= efx_sriov_set_vf_mac,
	.ndo_set_vf_vlan	= efx_sriov_set_vf_vlan,
	.ndo_set_vf_spoofchk	= efx_sriov_set_vf_spoofchk,
	.ndo_get_vf_config	= efx_sriov_get_vf_config,
605
	.ndo_set_vf_link_state  = efx_sriov_set_vf_link_state,
606
#endif
607
	.ndo_get_phys_port_id   = efx_get_phys_port_id,
608
	.ndo_get_phys_port_name	= efx_get_phys_port_name,
609
	.ndo_setup_tc		= efx_setup_tc,
610 611 612
#ifdef CONFIG_RFS_ACCEL
	.ndo_rx_flow_steer	= efx_filter_rfs,
#endif
613
	.ndo_xdp_xmit		= efx_xdp_xmit,
614
	.ndo_bpf		= efx_xdp
S
Stephen Hemminger 已提交
615 616
};

617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645
static int efx_xdp_setup_prog(struct efx_nic *efx, struct bpf_prog *prog)
{
	struct bpf_prog *old_prog;

	if (efx->xdp_rxq_info_failed) {
		netif_err(efx, drv, efx->net_dev,
			  "Unable to bind XDP program due to previous failure of rxq_info\n");
		return -EINVAL;
	}

	if (prog && efx->net_dev->mtu > efx_xdp_max_mtu(efx)) {
		netif_err(efx, drv, efx->net_dev,
			  "Unable to configure XDP with MTU of %d (max: %d)\n",
			  efx->net_dev->mtu, efx_xdp_max_mtu(efx));
		return -EINVAL;
	}

	old_prog = rtnl_dereference(efx->xdp_prog);
	rcu_assign_pointer(efx->xdp_prog, prog);
	/* Release the reference that was originally passed by the caller. */
	if (old_prog)
		bpf_prog_put(old_prog);

	return 0;
}

/* Context: process, rtnl_lock() held. */
static int efx_xdp(struct net_device *dev, struct netdev_bpf *xdp)
{
646
	struct efx_nic *efx = efx_netdev_priv(dev);
647 648 649 650 651 652 653 654 655

	switch (xdp->command) {
	case XDP_SETUP_PROG:
		return efx_xdp_setup_prog(efx, xdp->prog);
	default:
		return -EINVAL;
	}
}

656 657 658
static int efx_xdp_xmit(struct net_device *dev, int n, struct xdp_frame **xdpfs,
			u32 flags)
{
659
	struct efx_nic *efx = efx_netdev_priv(dev);
660 661 662 663 664 665 666

	if (!netif_running(dev))
		return -EINVAL;

	return efx_xdp_tx_buffers(efx, n, xdpfs, flags & XDP_XMIT_FLUSH);
}

667 668 669 670 671 672 673
static void efx_update_name(struct efx_nic *efx)
{
	strcpy(efx->name, efx->net_dev->name);
	efx_mtd_rename(efx);
	efx_set_channel_names(efx);
}

674 675 676
static int efx_netdev_event(struct notifier_block *this,
			    unsigned long event, void *ptr)
{
677
	struct net_device *net_dev = netdev_notifier_info_to_dev(ptr);
678

679
	if ((net_dev->netdev_ops == &efx_netdev_ops) &&
680
	    event == NETDEV_CHANGENAME)
681
		efx_update_name(efx_netdev_priv(net_dev));
682 683 684 685 686 687 688 689

	return NOTIFY_DONE;
}

static struct notifier_block efx_netdev_notifier = {
	.notifier_call = efx_netdev_event,
};

Y
YueHaibing 已提交
690 691
static ssize_t phy_type_show(struct device *dev,
			     struct device_attribute *attr, char *buf)
B
Ben Hutchings 已提交
692
{
693
	struct efx_nic *efx = dev_get_drvdata(dev);
B
Ben Hutchings 已提交
694 695
	return sprintf(buf, "%d\n", efx->phy_type);
}
Y
YueHaibing 已提交
696
static DEVICE_ATTR_RO(phy_type);
B
Ben Hutchings 已提交
697

698 699 700
static int efx_register_netdev(struct efx_nic *efx)
{
	struct net_device *net_dev = efx->net_dev;
701
	struct efx_channel *channel;
702 703 704 705
	int rc;

	net_dev->watchdog_timeo = 5 * HZ;
	net_dev->irq = efx->pci_dev->irq;
706 707
	net_dev->netdev_ops = &efx_netdev_ops;
	if (efx_nic_rev(efx) >= EFX_REV_HUNT_A0)
708
		net_dev->priv_flags |= IFF_UNICAST_FLT;
709
	net_dev->ethtool_ops = &efx_ethtool_ops;
710
	netif_set_tso_max_segs(net_dev, EFX_TSO_MAX_SEGS);
711 712
	net_dev->min_mtu = EFX_MIN_MTU;
	net_dev->max_mtu = EFX_MAX_MTU;
713

714
	rtnl_lock();
715

716 717 718 719 720
	/* Enable resets to be scheduled and check whether any were
	 * already requested.  If so, the NIC is probably hosed so we
	 * abort.
	 */
	if (efx->reset_pending) {
721
		pci_err(efx->pci_dev, "aborting probe due to scheduled reset\n");
722 723 724 725
		rc = -EIO;
		goto fail_locked;
	}

726 727 728
	rc = dev_alloc_name(net_dev, net_dev->name);
	if (rc < 0)
		goto fail_locked;
729
	efx_update_name(efx);
730

731 732 733
	/* Always start with carrier off; PHY events will detect the link */
	netif_carrier_off(net_dev);

734 735 736 737
	rc = register_netdevice(net_dev);
	if (rc)
		goto fail_locked;

738 739
	efx_for_each_channel(channel, efx) {
		struct efx_tx_queue *tx_queue;
740 741
		efx_for_each_channel_tx_queue(tx_queue, channel)
			efx_init_tx_queue_core_txq(tx_queue);
742 743
	}

744 745
	efx_associate(efx);

746 747
	efx->state = STATE_NET_DOWN;

748
	rtnl_unlock();
749

B
Ben Hutchings 已提交
750 751
	rc = device_create_file(&efx->pci_dev->dev, &dev_attr_phy_type);
	if (rc) {
752 753
		netif_err(efx, drv, efx->net_dev,
			  "failed to init net dev attributes\n");
B
Ben Hutchings 已提交
754 755
		goto fail_registered;
	}
756 757

	efx_init_mcdi_logging(efx);
B
Ben Hutchings 已提交
758

759
	return 0;
B
Ben Hutchings 已提交
760

761 762
fail_registered:
	rtnl_lock();
763
	efx_dissociate(efx);
764
	unregister_netdevice(net_dev);
765
fail_locked:
766
	efx->state = STATE_UNINIT;
767
	rtnl_unlock();
768
	netif_err(efx, drv, efx->net_dev, "could not register net dev\n");
769
	return rc;
770 771 772 773 774 775 776
}

static void efx_unregister_netdev(struct efx_nic *efx)
{
	if (!efx->net_dev)
		return;

777
	if (WARN_ON(efx_netdev_priv(efx->net_dev) != efx))
778
		return;
779

780 781
	if (efx_dev_registered(efx)) {
		strlcpy(efx->name, pci_name(efx->pci_dev), sizeof(efx->name));
782
		efx_fini_mcdi_logging(efx);
783 784 785
		device_remove_file(&efx->pci_dev->dev, &dev_attr_phy_type);
		unregister_netdev(efx->net_dev);
	}
786 787 788 789 790 791 792 793 794
}

/**************************************************************************
 *
 * List of NICs we support
 *
 **************************************************************************/

/* PCI device ID table */
795
static const struct pci_device_id efx_pci_table[] = {
796 797
	{PCI_DEVICE(PCI_VENDOR_ID_SOLARFLARE, 0x0903),  /* SFC9120 PF */
	 .driver_data = (unsigned long) &efx_hunt_a0_nic_type},
798 799
	{PCI_DEVICE(PCI_VENDOR_ID_SOLARFLARE, 0x1903),  /* SFC9120 VF */
	 .driver_data = (unsigned long) &efx_hunt_a0_vf_nic_type},
800 801
	{PCI_DEVICE(PCI_VENDOR_ID_SOLARFLARE, 0x0923),  /* SFC9140 PF */
	 .driver_data = (unsigned long) &efx_hunt_a0_nic_type},
802 803 804 805 806 807
	{PCI_DEVICE(PCI_VENDOR_ID_SOLARFLARE, 0x1923),  /* SFC9140 VF */
	 .driver_data = (unsigned long) &efx_hunt_a0_vf_nic_type},
	{PCI_DEVICE(PCI_VENDOR_ID_SOLARFLARE, 0x0a03),  /* SFC9220 PF */
	 .driver_data = (unsigned long) &efx_hunt_a0_nic_type},
	{PCI_DEVICE(PCI_VENDOR_ID_SOLARFLARE, 0x1a03),  /* SFC9220 VF */
	 .driver_data = (unsigned long) &efx_hunt_a0_vf_nic_type},
808 809 810 811
	{PCI_DEVICE(PCI_VENDOR_ID_SOLARFLARE, 0x0b03),  /* SFC9250 PF */
	 .driver_data = (unsigned long) &efx_hunt_a0_nic_type},
	{PCI_DEVICE(PCI_VENDOR_ID_SOLARFLARE, 0x1b03),  /* SFC9250 VF */
	 .driver_data = (unsigned long) &efx_hunt_a0_vf_nic_type},
812 813 814 815 816 817 818 819 820
	{0}			/* end of list */
};

/**************************************************************************
 *
 * Data housekeeping
 *
 **************************************************************************/

821 822 823 824 825 826 827 828 829 830 831
void efx_update_sw_stats(struct efx_nic *efx, u64 *stats)
{
	u64 n_rx_nodesc_trunc = 0;
	struct efx_channel *channel;

	efx_for_each_channel(channel, efx)
		n_rx_nodesc_trunc += channel->n_rx_nodesc_trunc;
	stats[GENERIC_STAT_rx_nodesc_trunc] = n_rx_nodesc_trunc;
	stats[GENERIC_STAT_rx_noskb_drops] = atomic_read(&efx->n_rx_noskb_drops);
}

832 833 834 835 836 837 838 839 840 841 842
/**************************************************************************
 *
 * PCI interface
 *
 **************************************************************************/

/* Main body of final NIC shutdown code
 * This is called only at module unload (or hotplug removal).
 */
static void efx_pci_remove_main(struct efx_nic *efx)
{
843 844 845
	/* Flush reset_work. It can no longer be scheduled since we
	 * are not READY.
	 */
846
	WARN_ON(efx_net_active(efx->state));
847
	efx_flush_reset_workqueue(efx);
848

B
Ben Hutchings 已提交
849
	efx_disable_interrupts(efx);
850
	efx_clear_interrupt_affinity(efx);
851
	efx_nic_fini_interrupt(efx);
852
	efx_fini_port(efx);
853
	efx->type->fini(efx);
854 855 856 857 858
	efx_fini_napi(efx);
	efx_remove_all(efx);
}

/* Final NIC shutdown
859 860
 * This is called only at module unload (or hotplug removal).  A PF can call
 * this on its VFs to ensure they are unbound first.
861 862 863 864 865 866 867 868 869 870 871
 */
static void efx_pci_remove(struct pci_dev *pci_dev)
{
	struct efx_nic *efx;

	efx = pci_get_drvdata(pci_dev);
	if (!efx)
		return;

	/* Mark the NIC as fini, then stop the interface */
	rtnl_lock();
872
	efx_dissociate(efx);
873
	dev_close(efx->net_dev);
B
Ben Hutchings 已提交
874
	efx_disable_interrupts(efx);
875
	efx->state = STATE_UNINIT;
876 877
	rtnl_unlock();

878 879 880
	if (efx->type->sriov_fini)
		efx->type->sriov_fini(efx);

881 882
	efx_unregister_netdev(efx);

883 884
	efx_mtd_remove(efx);

885 886
	efx_pci_remove_main(efx);

E
Edward Cree 已提交
887
	efx_fini_io(efx);
888
	netif_dbg(efx, drv, efx->net_dev, "shutdown successful\n");
889 890 891

	efx_fini_struct(efx);
	free_netdev(efx->net_dev);
892 893

	pci_disable_pcie_error_reporting(pci_dev);
894 895
};

896 897
/* NIC VPD information
 * Called during probe to display the part number of the
898
 * installed NIC.
899
 */
900
static void efx_probe_vpd_strings(struct efx_nic *efx)
901 902
{
	struct pci_dev *dev = efx->pci_dev;
903
	unsigned int vpd_size, kw_len;
904
	u8 *vpd_data;
905
	int start;
906

907 908 909
	vpd_data = pci_vpd_alloc(dev, &vpd_size);
	if (IS_ERR(vpd_data)) {
		pci_warn(dev, "Unable to read VPD\n");
910 911 912
		return;
	}

913 914 915 916 917 918
	start = pci_vpd_find_ro_info_keyword(vpd_data, vpd_size,
					     PCI_VPD_RO_KEYWORD_PARTNO, &kw_len);
	if (start < 0)
		pci_err(dev, "Part number not found or incomplete\n");
	else
		pci_info(dev, "Part Number : %.*s\n", kw_len, vpd_data + start);
919

920 921 922 923 924 925
	start = pci_vpd_find_ro_info_keyword(vpd_data, vpd_size,
					     PCI_VPD_RO_KEYWORD_SERIALNO, &kw_len);
	if (start < 0)
		pci_err(dev, "Serial number not found or incomplete\n");
	else
		efx->vpd_sn = kmemdup_nul(vpd_data + start, kw_len, GFP_KERNEL);
926

927
	kfree(vpd_data);
928 929 930
}


931 932 933 934 935 936 937 938 939 940 941 942
/* Main body of NIC initialisation
 * This is called at module load (or hotplug insertion, theoretically).
 */
static int efx_pci_probe_main(struct efx_nic *efx)
{
	int rc;

	/* Do start-of-day initialisation */
	rc = efx_probe_all(efx);
	if (rc)
		goto fail1;

943
	efx_init_napi(efx);
944

945
	down_write(&efx->filter_sem);
946
	rc = efx->type->init(efx);
947
	up_write(&efx->filter_sem);
948
	if (rc) {
949
		pci_err(efx->pci_dev, "failed to initialise NIC\n");
950
		goto fail3;
951 952 953 954
	}

	rc = efx_init_port(efx);
	if (rc) {
955 956
		netif_err(efx, probe, efx->net_dev,
			  "failed to initialise port\n");
957
		goto fail4;
958 959
	}

960
	rc = efx_nic_init_interrupt(efx);
961
	if (rc)
962
		goto fail5;
963 964

	efx_set_interrupt_affinity(efx);
965 966 967
	rc = efx_enable_interrupts(efx);
	if (rc)
		goto fail6;
968 969 970

	return 0;

971
 fail6:
972
	efx_clear_interrupt_affinity(efx);
973
	efx_nic_fini_interrupt(efx);
974
 fail5:
975 976
	efx_fini_port(efx);
 fail4:
977
	efx->type->fini(efx);
978 979 980 981 982 983 984
 fail3:
	efx_fini_napi(efx);
	efx_remove_all(efx);
 fail1:
	return rc;
}

985 986 987 988 989 990 991 992 993 994 995
static int efx_pci_probe_post_io(struct efx_nic *efx)
{
	struct net_device *net_dev = efx->net_dev;
	int rc = efx_pci_probe_main(efx);

	if (rc)
		return rc;

	if (efx->type->sriov_init) {
		rc = efx->type->sriov_init(efx);
		if (rc)
996 997
			pci_err(efx->pci_dev, "SR-IOV can't be enabled rc %d\n",
				rc);
998 999 1000 1001
	}

	/* Determine netdevice features */
	net_dev->features |= (efx->type->offload_features | NETIF_F_SG |
E
Edward Cree 已提交
1002
			      NETIF_F_TSO | NETIF_F_RXCSUM | NETIF_F_RXALL);
1003 1004 1005 1006 1007 1008 1009 1010 1011 1012
	if (efx->type->offload_features & (NETIF_F_IPV6_CSUM | NETIF_F_HW_CSUM))
		net_dev->features |= NETIF_F_TSO6;
	/* Check whether device supports TSO */
	if (!efx->type->tso_versions || !efx->type->tso_versions(efx))
		net_dev->features &= ~NETIF_F_ALL_TSO;
	/* Mask for features that also apply to VLAN devices */
	net_dev->vlan_features |= (NETIF_F_HW_CSUM | NETIF_F_SG |
				   NETIF_F_HIGHDMA | NETIF_F_ALL_TSO |
				   NETIF_F_RXCSUM);

E
Edward Cree 已提交
1013 1014 1015 1016
	net_dev->hw_features |= net_dev->features & ~efx->fixed_features;

	/* Disable receiving frames with bad FCS, by default. */
	net_dev->features &= ~NETIF_F_RXALL;
1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032

	/* Disable VLAN filtering by default.  It may be enforced if
	 * the feature is fixed (i.e. VLAN filters are required to
	 * receive VLAN tagged packets due to vPort restrictions).
	 */
	net_dev->features &= ~NETIF_F_HW_VLAN_CTAG_FILTER;
	net_dev->features |= efx->fixed_features;

	rc = efx_register_netdev(efx);
	if (!rc)
		return 0;

	efx_pci_remove_main(efx);
	return rc;
}

1033 1034 1035
/* NIC initialisation
 *
 * This is called at module load (or hotplug insertion,
1036
 * theoretically).  It sets up PCI mappings, resets the NIC,
1037 1038 1039 1040 1041
 * sets up and registers the network devices with the kernel and hooks
 * the interrupt service routine.  It does not prepare the device for
 * transmission; this is left to the first time one of the network
 * interfaces is brought up (i.e. efx_net_open).
 */
B
Bill Pemberton 已提交
1042
static int efx_pci_probe(struct pci_dev *pci_dev,
1043
			 const struct pci_device_id *entry)
1044 1045 1046
{
	struct net_device *net_dev;
	struct efx_nic *efx;
1047
	int rc;
1048 1049

	/* Allocate and initialise a struct net_device and struct efx_nic */
1050 1051
	net_dev = alloc_etherdev_mqs(sizeof(*efx), EFX_MAX_CORE_TX_QUEUES,
				     EFX_MAX_RX_QUEUES);
1052 1053
	if (!net_dev)
		return -ENOMEM;
1054
	efx = efx_netdev_priv(net_dev);
1055
	efx->type = (const struct efx_nic_type *) entry->driver_data;
1056
	efx->fixed_features |= NETIF_F_HIGHDMA;
1057

1058
	pci_set_drvdata(pci_dev, efx);
1059
	SET_NETDEV_DEV(net_dev, &pci_dev->dev);
1060
	rc = efx_init_struct(efx, pci_dev);
1061 1062
	if (rc)
		goto fail1;
1063
	efx->mdio.dev = net_dev;
1064

1065
	pci_info(pci_dev, "Solarflare NIC detected\n");
1066

1067 1068
	if (!efx->type->is_vf)
		efx_probe_vpd_strings(efx);
1069

1070
	/* Set up basic I/O (BAR mappings etc) */
1071 1072
	rc = efx_init_io(efx, efx->type->mem_bar(efx), efx->type->max_dma_mask,
			 efx->type->mem_map_size(efx));
1073 1074 1075
	if (rc)
		goto fail2;

1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094
	rc = efx_pci_probe_post_io(efx);
	if (rc) {
		/* On failure, retry once immediately.
		 * If we aborted probe due to a scheduled reset, dismiss it.
		 */
		efx->reset_pending = 0;
		rc = efx_pci_probe_post_io(efx);
		if (rc) {
			/* On another failure, retry once more
			 * after a 50-305ms delay.
			 */
			unsigned char r;

			get_random_bytes(&r, 1);
			msleep((unsigned int)r + 50);
			efx->reset_pending = 0;
			rc = efx_pci_probe_post_io(efx);
		}
	}
1095 1096
	if (rc)
		goto fail3;
1097

1098
	netif_dbg(efx, probe, efx->net_dev, "initialisation successful\n");
1099

1100
	/* Try to create MTDs, but allow this to fail */
1101
	rtnl_lock();
1102
	rc = efx_mtd_probe(efx);
1103
	rtnl_unlock();
1104
	if (rc && rc != -EPERM)
1105 1106 1107
		netif_warn(efx, probe, efx->net_dev,
			   "failed to create MTDs (%d)\n", rc);

1108
	(void)pci_enable_pcie_error_reporting(pci_dev);
1109

1110 1111 1112
	if (efx->type->udp_tnl_push_ports)
		efx->type->udp_tnl_push_ports(efx);

1113 1114 1115
	return 0;

 fail3:
E
Edward Cree 已提交
1116
	efx_fini_io(efx);
1117 1118 1119
 fail2:
	efx_fini_struct(efx);
 fail1:
S
Steve Hodgson 已提交
1120
	WARN_ON(rc > 0);
1121
	netif_dbg(efx, drv, efx->net_dev, "initialisation failed. rc=%d\n", rc);
1122 1123 1124 1125
	free_netdev(net_dev);
	return rc;
}

1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145
/* efx_pci_sriov_configure returns the actual number of Virtual Functions
 * enabled on success
 */
#ifdef CONFIG_SFC_SRIOV
static int efx_pci_sriov_configure(struct pci_dev *dev, int num_vfs)
{
	int rc;
	struct efx_nic *efx = pci_get_drvdata(dev);

	if (efx->type->sriov_configure) {
		rc = efx->type->sriov_configure(efx, num_vfs);
		if (rc)
			return rc;
		else
			return num_vfs;
	} else
		return -EOPNOTSUPP;
}
#endif

1146 1147
static int efx_pm_freeze(struct device *dev)
{
1148
	struct efx_nic *efx = dev_get_drvdata(dev);
1149

1150 1151
	rtnl_lock();

1152
	if (efx_net_active(efx->state)) {
1153
		efx_device_detach_sync(efx);
1154

1155
		efx_stop_all(efx);
B
Ben Hutchings 已提交
1156
		efx_disable_interrupts(efx);
1157 1158

		efx->state = efx_freeze(efx->state);
1159
	}
1160

1161 1162
	rtnl_unlock();

1163 1164 1165 1166 1167
	return 0;
}

static int efx_pm_thaw(struct device *dev)
{
1168
	int rc;
1169
	struct efx_nic *efx = dev_get_drvdata(dev);
1170

1171 1172
	rtnl_lock();

1173
	if (efx_frozen(efx->state)) {
1174 1175 1176
		rc = efx_enable_interrupts(efx);
		if (rc)
			goto fail;
1177

1178
		mutex_lock(&efx->mac_lock);
E
Edward Cree 已提交
1179
		efx_mcdi_port_reconfigure(efx);
1180
		mutex_unlock(&efx->mac_lock);
1181

1182
		efx_start_all(efx);
1183

1184
		efx_device_attach_if_not_resetting(efx);
1185

1186
		efx->state = efx_thaw(efx->state);
1187

1188 1189
		efx->type->resume_wol(efx);
	}
1190

1191 1192
	rtnl_unlock();

1193
	/* Reschedule any quenched resets scheduled during efx_pm_freeze() */
1194
	efx_queue_reset_work(efx);
1195

1196
	return 0;
1197 1198 1199 1200 1201

fail:
	rtnl_unlock();

	return rc;
1202 1203 1204 1205 1206 1207 1208 1209 1210
}

static int efx_pm_poweroff(struct device *dev)
{
	struct pci_dev *pci_dev = to_pci_dev(dev);
	struct efx_nic *efx = pci_get_drvdata(pci_dev);

	efx->type->fini(efx);

1211
	efx->reset_pending = 0;
1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234

	pci_save_state(pci_dev);
	return pci_set_power_state(pci_dev, PCI_D3hot);
}

/* Used for both resume and restore */
static int efx_pm_resume(struct device *dev)
{
	struct pci_dev *pci_dev = to_pci_dev(dev);
	struct efx_nic *efx = pci_get_drvdata(pci_dev);
	int rc;

	rc = pci_set_power_state(pci_dev, PCI_D0);
	if (rc)
		return rc;
	pci_restore_state(pci_dev);
	rc = pci_enable_device(pci_dev);
	if (rc)
		return rc;
	pci_set_master(efx->pci_dev);
	rc = efx->type->reset(efx, RESET_TYPE_ALL);
	if (rc)
		return rc;
1235
	down_write(&efx->filter_sem);
1236
	rc = efx->type->init(efx);
1237
	up_write(&efx->filter_sem);
1238 1239
	if (rc)
		return rc;
1240 1241
	rc = efx_pm_thaw(dev);
	return rc;
1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254
}

static int efx_pm_suspend(struct device *dev)
{
	int rc;

	efx_pm_freeze(dev);
	rc = efx_pm_poweroff(dev);
	if (rc)
		efx_pm_resume(dev);
	return rc;
}

1255
static const struct dev_pm_ops efx_pm_ops = {
1256 1257 1258 1259 1260 1261 1262 1263
	.suspend	= efx_pm_suspend,
	.resume		= efx_pm_resume,
	.freeze		= efx_pm_freeze,
	.thaw		= efx_pm_thaw,
	.poweroff	= efx_pm_poweroff,
	.restore	= efx_pm_resume,
};

1264
static struct pci_driver efx_pci_driver = {
1265
	.name		= KBUILD_MODNAME,
1266 1267 1268
	.id_table	= efx_pci_table,
	.probe		= efx_pci_probe,
	.remove		= efx_pci_remove,
1269
	.driver.pm	= &efx_pm_ops,
1270
	.err_handler	= &efx_err_handlers,
1271 1272 1273
#ifdef CONFIG_SFC_SRIOV
	.sriov_configure = efx_pci_sriov_configure,
#endif
1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285
};

/**************************************************************************
 *
 * Kernel module interface
 *
 *************************************************************************/

static int __init efx_init_module(void)
{
	int rc;

E
Edward Cree 已提交
1286
	printk(KERN_INFO "Solarflare NET driver\n");
1287 1288 1289 1290 1291

	rc = register_netdevice_notifier(&efx_netdev_notifier);
	if (rc)
		goto err_notifier;

1292 1293
	rc = efx_create_reset_workqueue();
	if (rc)
1294
		goto err_reset;
1295 1296 1297 1298 1299

	rc = pci_register_driver(&efx_pci_driver);
	if (rc < 0)
		goto err_pci;

E
Edward Cree 已提交
1300 1301 1302 1303
	rc = pci_register_driver(&ef100_pci_driver);
	if (rc < 0)
		goto err_pci_ef100;

1304 1305
	return 0;

E
Edward Cree 已提交
1306 1307
 err_pci_ef100:
	pci_unregister_driver(&efx_pci_driver);
1308
 err_pci:
1309
	efx_destroy_reset_workqueue();
1310
 err_reset:
1311 1312 1313 1314 1315 1316 1317 1318 1319
	unregister_netdevice_notifier(&efx_netdev_notifier);
 err_notifier:
	return rc;
}

static void __exit efx_exit_module(void)
{
	printk(KERN_INFO "Solarflare NET driver unloading\n");

E
Edward Cree 已提交
1320
	pci_unregister_driver(&ef100_pci_driver);
1321
	pci_unregister_driver(&efx_pci_driver);
1322
	efx_destroy_reset_workqueue();
1323 1324 1325 1326 1327 1328 1329
	unregister_netdevice_notifier(&efx_netdev_notifier);

}

module_init(efx_init_module);
module_exit(efx_exit_module);

1330 1331
MODULE_AUTHOR("Solarflare Communications and "
	      "Michael Brown <mbrown@fensystems.co.uk>");
B
Ben Hutchings 已提交
1332
MODULE_DESCRIPTION("Solarflare network driver");
1333 1334
MODULE_LICENSE("GPL");
MODULE_DEVICE_TABLE(pci, efx_pci_table);