xref: /openbmc/linux/drivers/net/ethernet/sfc/efx.c (revision 31eeb6b0)
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 2005-2013 Solarflare Communications Inc.
6  */
7 
8 #include <linux/filter.h>
9 #include <linux/module.h>
10 #include <linux/pci.h>
11 #include <linux/netdevice.h>
12 #include <linux/etherdevice.h>
13 #include <linux/delay.h>
14 #include <linux/notifier.h>
15 #include <linux/ip.h>
16 #include <linux/tcp.h>
17 #include <linux/in.h>
18 #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 #include <net/gre.h>
25 #include <net/udp_tunnel.h>
26 #include "efx.h"
27 #include "efx_common.h"
28 #include "efx_channels.h"
29 #include "ef100.h"
30 #include "rx_common.h"
31 #include "tx_common.h"
32 #include "nic.h"
33 #include "io.h"
34 #include "selftest.h"
35 #include "sriov.h"
36 
37 #include "mcdi_port_common.h"
38 #include "mcdi_pcol.h"
39 #include "workarounds.h"
40 
41 /**************************************************************************
42  *
43  * Configurable values
44  *
45  *************************************************************************/
46 
47 module_param_named(interrupt_mode, efx_interrupt_mode, uint, 0444);
48 MODULE_PARM_DESC(interrupt_mode,
49 		 "Interrupt mode (0=>MSIX 1=>MSI 2=>legacy)");
50 
51 module_param(rss_cpus, uint, 0444);
52 MODULE_PARM_DESC(rss_cpus, "Number of CPUs to use for Receive-Side Scaling");
53 
54 /*
55  * Use separate channels for TX and RX events
56  *
57  * Set this to 1 to use separate channels for TX and RX. It allows us
58  * to control interrupt affinity separately for TX and RX.
59  *
60  * This is only used in MSI-X interrupt mode
61  */
62 bool efx_separate_tx_channels;
63 module_param(efx_separate_tx_channels, bool, 0444);
64 MODULE_PARM_DESC(efx_separate_tx_channels,
65 		 "Use separate channels for TX and RX");
66 
67 /* Initial interrupt moderation settings.  They can be modified after
68  * module load with ethtool.
69  *
70  * The default for RX should strike a balance between increasing the
71  * round-trip latency and reducing overhead.
72  */
73 static unsigned int rx_irq_mod_usec = 60;
74 
75 /* Initial interrupt moderation settings.  They can be modified after
76  * module load with ethtool.
77  *
78  * This default is chosen to ensure that a 10G link does not go idle
79  * while a TX queue is stopped after it has become full.  A queue is
80  * restarted when it drops below half full.  The time this takes (assuming
81  * worst case 3 descriptors per packet and 1024 descriptors) is
82  *   512 / 3 * 1.2 = 205 usec.
83  */
84 static unsigned int tx_irq_mod_usec = 150;
85 
86 static bool phy_flash_cfg;
87 module_param(phy_flash_cfg, bool, 0644);
88 MODULE_PARM_DESC(phy_flash_cfg, "Set PHYs into reflash mode initially");
89 
90 static unsigned debug = (NETIF_MSG_DRV | NETIF_MSG_PROBE |
91 			 NETIF_MSG_LINK | NETIF_MSG_IFDOWN |
92 			 NETIF_MSG_IFUP | NETIF_MSG_RX_ERR |
93 			 NETIF_MSG_TX_ERR | NETIF_MSG_HW);
94 module_param(debug, uint, 0);
95 MODULE_PARM_DESC(debug, "Bitmapped debugging message enable value");
96 
97 /**************************************************************************
98  *
99  * Utility functions and prototypes
100  *
101  *************************************************************************/
102 
103 static void efx_remove_port(struct efx_nic *efx);
104 static int efx_xdp_setup_prog(struct efx_nic *efx, struct bpf_prog *prog);
105 static int efx_xdp(struct net_device *dev, struct netdev_bpf *xdp);
106 static int efx_xdp_xmit(struct net_device *dev, int n, struct xdp_frame **xdpfs,
107 			u32 flags);
108 
109 #define EFX_ASSERT_RESET_SERIALISED(efx)		\
110 	do {						\
111 		if ((efx->state == STATE_READY) ||	\
112 		    (efx->state == STATE_RECOVERY) ||	\
113 		    (efx->state == STATE_DISABLED))	\
114 			ASSERT_RTNL();			\
115 	} while (0)
116 
117 /**************************************************************************
118  *
119  * Port handling
120  *
121  **************************************************************************/
122 
123 static void efx_fini_port(struct efx_nic *efx);
124 
125 static int efx_probe_port(struct efx_nic *efx)
126 {
127 	int rc;
128 
129 	netif_dbg(efx, probe, efx->net_dev, "create port\n");
130 
131 	if (phy_flash_cfg)
132 		efx->phy_mode = PHY_MODE_SPECIAL;
133 
134 	/* Connect up MAC/PHY operations table */
135 	rc = efx->type->probe_port(efx);
136 	if (rc)
137 		return rc;
138 
139 	/* Initialise MAC address to permanent address */
140 	eth_hw_addr_set(efx->net_dev, efx->net_dev->perm_addr);
141 
142 	return 0;
143 }
144 
145 static int efx_init_port(struct efx_nic *efx)
146 {
147 	int rc;
148 
149 	netif_dbg(efx, drv, efx->net_dev, "init port\n");
150 
151 	mutex_lock(&efx->mac_lock);
152 
153 	efx->port_initialized = true;
154 
155 	/* Ensure the PHY advertises the correct flow control settings */
156 	rc = efx_mcdi_port_reconfigure(efx);
157 	if (rc && rc != -EPERM)
158 		goto fail;
159 
160 	mutex_unlock(&efx->mac_lock);
161 	return 0;
162 
163 fail:
164 	mutex_unlock(&efx->mac_lock);
165 	return rc;
166 }
167 
168 static void efx_fini_port(struct efx_nic *efx)
169 {
170 	netif_dbg(efx, drv, efx->net_dev, "shut down port\n");
171 
172 	if (!efx->port_initialized)
173 		return;
174 
175 	efx->port_initialized = false;
176 
177 	efx->link_state.up = false;
178 	efx_link_status_changed(efx);
179 }
180 
181 static void efx_remove_port(struct efx_nic *efx)
182 {
183 	netif_dbg(efx, drv, efx->net_dev, "destroying port\n");
184 
185 	efx->type->remove_port(efx);
186 }
187 
188 /**************************************************************************
189  *
190  * NIC handling
191  *
192  **************************************************************************/
193 
194 static LIST_HEAD(efx_primary_list);
195 static LIST_HEAD(efx_unassociated_list);
196 
197 static bool efx_same_controller(struct efx_nic *left, struct efx_nic *right)
198 {
199 	return left->type == right->type &&
200 		left->vpd_sn && right->vpd_sn &&
201 		!strcmp(left->vpd_sn, right->vpd_sn);
202 }
203 
204 static void efx_associate(struct efx_nic *efx)
205 {
206 	struct efx_nic *other, *next;
207 
208 	if (efx->primary == efx) {
209 		/* Adding primary function; look for secondaries */
210 
211 		netif_dbg(efx, probe, efx->net_dev, "adding to primary list\n");
212 		list_add_tail(&efx->node, &efx_primary_list);
213 
214 		list_for_each_entry_safe(other, next, &efx_unassociated_list,
215 					 node) {
216 			if (efx_same_controller(efx, other)) {
217 				list_del(&other->node);
218 				netif_dbg(other, probe, other->net_dev,
219 					  "moving to secondary list of %s %s\n",
220 					  pci_name(efx->pci_dev),
221 					  efx->net_dev->name);
222 				list_add_tail(&other->node,
223 					      &efx->secondary_list);
224 				other->primary = efx;
225 			}
226 		}
227 	} else {
228 		/* Adding secondary function; look for primary */
229 
230 		list_for_each_entry(other, &efx_primary_list, node) {
231 			if (efx_same_controller(efx, other)) {
232 				netif_dbg(efx, probe, efx->net_dev,
233 					  "adding to secondary list of %s %s\n",
234 					  pci_name(other->pci_dev),
235 					  other->net_dev->name);
236 				list_add_tail(&efx->node,
237 					      &other->secondary_list);
238 				efx->primary = other;
239 				return;
240 			}
241 		}
242 
243 		netif_dbg(efx, probe, efx->net_dev,
244 			  "adding to unassociated list\n");
245 		list_add_tail(&efx->node, &efx_unassociated_list);
246 	}
247 }
248 
249 static void efx_dissociate(struct efx_nic *efx)
250 {
251 	struct efx_nic *other, *next;
252 
253 	list_del(&efx->node);
254 	efx->primary = NULL;
255 
256 	list_for_each_entry_safe(other, next, &efx->secondary_list, node) {
257 		list_del(&other->node);
258 		netif_dbg(other, probe, other->net_dev,
259 			  "moving to unassociated list\n");
260 		list_add_tail(&other->node, &efx_unassociated_list);
261 		other->primary = NULL;
262 	}
263 }
264 
265 static int efx_probe_nic(struct efx_nic *efx)
266 {
267 	int rc;
268 
269 	netif_dbg(efx, probe, efx->net_dev, "creating NIC\n");
270 
271 	/* Carry out hardware-type specific initialisation */
272 	rc = efx->type->probe(efx);
273 	if (rc)
274 		return rc;
275 
276 	do {
277 		if (!efx->max_channels || !efx->max_tx_channels) {
278 			netif_err(efx, drv, efx->net_dev,
279 				  "Insufficient resources to allocate"
280 				  " any channels\n");
281 			rc = -ENOSPC;
282 			goto fail1;
283 		}
284 
285 		/* Determine the number of channels and queues by trying
286 		 * to hook in MSI-X interrupts.
287 		 */
288 		rc = efx_probe_interrupts(efx);
289 		if (rc)
290 			goto fail1;
291 
292 		rc = efx_set_channels(efx);
293 		if (rc)
294 			goto fail1;
295 
296 		/* dimension_resources can fail with EAGAIN */
297 		rc = efx->type->dimension_resources(efx);
298 		if (rc != 0 && rc != -EAGAIN)
299 			goto fail2;
300 
301 		if (rc == -EAGAIN)
302 			/* try again with new max_channels */
303 			efx_remove_interrupts(efx);
304 
305 	} while (rc == -EAGAIN);
306 
307 	if (efx->n_channels > 1)
308 		netdev_rss_key_fill(efx->rss_context.rx_hash_key,
309 				    sizeof(efx->rss_context.rx_hash_key));
310 	efx_set_default_rx_indir_table(efx, &efx->rss_context);
311 
312 	/* Initialise the interrupt moderation settings */
313 	efx->irq_mod_step_us = DIV_ROUND_UP(efx->timer_quantum_ns, 1000);
314 	efx_init_irq_moderation(efx, tx_irq_mod_usec, rx_irq_mod_usec, true,
315 				true);
316 
317 	return 0;
318 
319 fail2:
320 	efx_remove_interrupts(efx);
321 fail1:
322 	efx->type->remove(efx);
323 	return rc;
324 }
325 
326 static void efx_remove_nic(struct efx_nic *efx)
327 {
328 	netif_dbg(efx, drv, efx->net_dev, "destroying NIC\n");
329 
330 	efx_remove_interrupts(efx);
331 	efx->type->remove(efx);
332 }
333 
334 /**************************************************************************
335  *
336  * NIC startup/shutdown
337  *
338  *************************************************************************/
339 
340 static int efx_probe_all(struct efx_nic *efx)
341 {
342 	int rc;
343 
344 	rc = efx_probe_nic(efx);
345 	if (rc) {
346 		netif_err(efx, probe, efx->net_dev, "failed to create NIC\n");
347 		goto fail1;
348 	}
349 
350 	rc = efx_probe_port(efx);
351 	if (rc) {
352 		netif_err(efx, probe, efx->net_dev, "failed to create port\n");
353 		goto fail2;
354 	}
355 
356 	BUILD_BUG_ON(EFX_DEFAULT_DMAQ_SIZE < EFX_RXQ_MIN_ENT);
357 	if (WARN_ON(EFX_DEFAULT_DMAQ_SIZE < EFX_TXQ_MIN_ENT(efx))) {
358 		rc = -EINVAL;
359 		goto fail3;
360 	}
361 
362 #ifdef CONFIG_SFC_SRIOV
363 	rc = efx->type->vswitching_probe(efx);
364 	if (rc) /* not fatal; the PF will still work fine */
365 		netif_warn(efx, probe, efx->net_dev,
366 			   "failed to setup vswitching rc=%d;"
367 			   " VFs may not function\n", rc);
368 #endif
369 
370 	rc = efx_probe_filters(efx);
371 	if (rc) {
372 		netif_err(efx, probe, efx->net_dev,
373 			  "failed to create filter tables\n");
374 		goto fail4;
375 	}
376 
377 	rc = efx_probe_channels(efx);
378 	if (rc)
379 		goto fail5;
380 
381 	return 0;
382 
383  fail5:
384 	efx_remove_filters(efx);
385  fail4:
386 #ifdef CONFIG_SFC_SRIOV
387 	efx->type->vswitching_remove(efx);
388 #endif
389  fail3:
390 	efx_remove_port(efx);
391  fail2:
392 	efx_remove_nic(efx);
393  fail1:
394 	return rc;
395 }
396 
397 static void efx_remove_all(struct efx_nic *efx)
398 {
399 	rtnl_lock();
400 	efx_xdp_setup_prog(efx, NULL);
401 	rtnl_unlock();
402 
403 	efx_remove_channels(efx);
404 	efx_remove_filters(efx);
405 #ifdef CONFIG_SFC_SRIOV
406 	efx->type->vswitching_remove(efx);
407 #endif
408 	efx_remove_port(efx);
409 	efx_remove_nic(efx);
410 }
411 
412 /**************************************************************************
413  *
414  * Interrupt moderation
415  *
416  **************************************************************************/
417 unsigned int efx_usecs_to_ticks(struct efx_nic *efx, unsigned int usecs)
418 {
419 	if (usecs == 0)
420 		return 0;
421 	if (usecs * 1000 < efx->timer_quantum_ns)
422 		return 1; /* never round down to 0 */
423 	return usecs * 1000 / efx->timer_quantum_ns;
424 }
425 
426 unsigned int efx_ticks_to_usecs(struct efx_nic *efx, unsigned int ticks)
427 {
428 	/* We must round up when converting ticks to microseconds
429 	 * because we round down when converting the other way.
430 	 */
431 	return DIV_ROUND_UP(ticks * efx->timer_quantum_ns, 1000);
432 }
433 
434 /* Set interrupt moderation parameters */
435 int efx_init_irq_moderation(struct efx_nic *efx, unsigned int tx_usecs,
436 			    unsigned int rx_usecs, bool rx_adaptive,
437 			    bool rx_may_override_tx)
438 {
439 	struct efx_channel *channel;
440 	unsigned int timer_max_us;
441 
442 	EFX_ASSERT_RESET_SERIALISED(efx);
443 
444 	timer_max_us = efx->timer_max_ns / 1000;
445 
446 	if (tx_usecs > timer_max_us || rx_usecs > timer_max_us)
447 		return -EINVAL;
448 
449 	if (tx_usecs != rx_usecs && efx->tx_channel_offset == 0 &&
450 	    !rx_may_override_tx) {
451 		netif_err(efx, drv, efx->net_dev, "Channels are shared. "
452 			  "RX and TX IRQ moderation must be equal\n");
453 		return -EINVAL;
454 	}
455 
456 	efx->irq_rx_adaptive = rx_adaptive;
457 	efx->irq_rx_moderation_us = rx_usecs;
458 	efx_for_each_channel(channel, efx) {
459 		if (efx_channel_has_rx_queue(channel))
460 			channel->irq_moderation_us = rx_usecs;
461 		else if (efx_channel_has_tx_queues(channel))
462 			channel->irq_moderation_us = tx_usecs;
463 		else if (efx_channel_is_xdp_tx(channel))
464 			channel->irq_moderation_us = tx_usecs;
465 	}
466 
467 	return 0;
468 }
469 
470 void efx_get_irq_moderation(struct efx_nic *efx, unsigned int *tx_usecs,
471 			    unsigned int *rx_usecs, bool *rx_adaptive)
472 {
473 	*rx_adaptive = efx->irq_rx_adaptive;
474 	*rx_usecs = efx->irq_rx_moderation_us;
475 
476 	/* If channels are shared between RX and TX, so is IRQ
477 	 * moderation.  Otherwise, IRQ moderation is the same for all
478 	 * TX channels and is not adaptive.
479 	 */
480 	if (efx->tx_channel_offset == 0) {
481 		*tx_usecs = *rx_usecs;
482 	} else {
483 		struct efx_channel *tx_channel;
484 
485 		tx_channel = efx->channel[efx->tx_channel_offset];
486 		*tx_usecs = tx_channel->irq_moderation_us;
487 	}
488 }
489 
490 /**************************************************************************
491  *
492  * ioctls
493  *
494  *************************************************************************/
495 
496 /* Net device ioctl
497  * Context: process, rtnl_lock() held.
498  */
499 static int efx_ioctl(struct net_device *net_dev, struct ifreq *ifr, int cmd)
500 {
501 	struct efx_nic *efx = netdev_priv(net_dev);
502 	struct mii_ioctl_data *data = if_mii(ifr);
503 
504 	if (cmd == SIOCSHWTSTAMP)
505 		return efx_ptp_set_ts_config(efx, ifr);
506 	if (cmd == SIOCGHWTSTAMP)
507 		return efx_ptp_get_ts_config(efx, ifr);
508 
509 	/* Convert phy_id from older PRTAD/DEVAD format */
510 	if ((cmd == SIOCGMIIREG || cmd == SIOCSMIIREG) &&
511 	    (data->phy_id & 0xfc00) == 0x0400)
512 		data->phy_id ^= MDIO_PHY_ID_C45 | 0x0400;
513 
514 	return mdio_mii_ioctl(&efx->mdio, data, cmd);
515 }
516 
517 /**************************************************************************
518  *
519  * Kernel net device interface
520  *
521  *************************************************************************/
522 
523 /* Context: process, rtnl_lock() held. */
524 int efx_net_open(struct net_device *net_dev)
525 {
526 	struct efx_nic *efx = netdev_priv(net_dev);
527 	int rc;
528 
529 	netif_dbg(efx, ifup, efx->net_dev, "opening device on CPU %d\n",
530 		  raw_smp_processor_id());
531 
532 	rc = efx_check_disabled(efx);
533 	if (rc)
534 		return rc;
535 	if (efx->phy_mode & PHY_MODE_SPECIAL)
536 		return -EBUSY;
537 	if (efx_mcdi_poll_reboot(efx) && efx_reset(efx, RESET_TYPE_ALL))
538 		return -EIO;
539 
540 	/* Notify the kernel of the link state polled during driver load,
541 	 * before the monitor starts running */
542 	efx_link_status_changed(efx);
543 
544 	efx_start_all(efx);
545 	if (efx->state == STATE_DISABLED || efx->reset_pending)
546 		netif_device_detach(efx->net_dev);
547 	efx_selftest_async_start(efx);
548 	return 0;
549 }
550 
551 /* Context: process, rtnl_lock() held.
552  * Note that the kernel will ignore our return code; this method
553  * should really be a void.
554  */
555 int efx_net_stop(struct net_device *net_dev)
556 {
557 	struct efx_nic *efx = netdev_priv(net_dev);
558 
559 	netif_dbg(efx, ifdown, efx->net_dev, "closing on CPU %d\n",
560 		  raw_smp_processor_id());
561 
562 	/* Stop the device and flush all the channels */
563 	efx_stop_all(efx);
564 
565 	return 0;
566 }
567 
568 static int efx_vlan_rx_add_vid(struct net_device *net_dev, __be16 proto, u16 vid)
569 {
570 	struct efx_nic *efx = netdev_priv(net_dev);
571 
572 	if (efx->type->vlan_rx_add_vid)
573 		return efx->type->vlan_rx_add_vid(efx, proto, vid);
574 	else
575 		return -EOPNOTSUPP;
576 }
577 
578 static int efx_vlan_rx_kill_vid(struct net_device *net_dev, __be16 proto, u16 vid)
579 {
580 	struct efx_nic *efx = netdev_priv(net_dev);
581 
582 	if (efx->type->vlan_rx_kill_vid)
583 		return efx->type->vlan_rx_kill_vid(efx, proto, vid);
584 	else
585 		return -EOPNOTSUPP;
586 }
587 
588 static const struct net_device_ops efx_netdev_ops = {
589 	.ndo_open		= efx_net_open,
590 	.ndo_stop		= efx_net_stop,
591 	.ndo_get_stats64	= efx_net_stats,
592 	.ndo_tx_timeout		= efx_watchdog,
593 	.ndo_start_xmit		= efx_hard_start_xmit,
594 	.ndo_validate_addr	= eth_validate_addr,
595 	.ndo_eth_ioctl		= efx_ioctl,
596 	.ndo_change_mtu		= efx_change_mtu,
597 	.ndo_set_mac_address	= efx_set_mac_address,
598 	.ndo_set_rx_mode	= efx_set_rx_mode,
599 	.ndo_set_features	= efx_set_features,
600 	.ndo_features_check	= efx_features_check,
601 	.ndo_vlan_rx_add_vid	= efx_vlan_rx_add_vid,
602 	.ndo_vlan_rx_kill_vid	= efx_vlan_rx_kill_vid,
603 #ifdef CONFIG_SFC_SRIOV
604 	.ndo_set_vf_mac		= efx_sriov_set_vf_mac,
605 	.ndo_set_vf_vlan	= efx_sriov_set_vf_vlan,
606 	.ndo_set_vf_spoofchk	= efx_sriov_set_vf_spoofchk,
607 	.ndo_get_vf_config	= efx_sriov_get_vf_config,
608 	.ndo_set_vf_link_state  = efx_sriov_set_vf_link_state,
609 #endif
610 	.ndo_get_phys_port_id   = efx_get_phys_port_id,
611 	.ndo_get_phys_port_name	= efx_get_phys_port_name,
612 	.ndo_setup_tc		= efx_setup_tc,
613 #ifdef CONFIG_RFS_ACCEL
614 	.ndo_rx_flow_steer	= efx_filter_rfs,
615 #endif
616 	.ndo_xdp_xmit		= efx_xdp_xmit,
617 	.ndo_bpf		= efx_xdp
618 };
619 
620 static int efx_xdp_setup_prog(struct efx_nic *efx, struct bpf_prog *prog)
621 {
622 	struct bpf_prog *old_prog;
623 
624 	if (efx->xdp_rxq_info_failed) {
625 		netif_err(efx, drv, efx->net_dev,
626 			  "Unable to bind XDP program due to previous failure of rxq_info\n");
627 		return -EINVAL;
628 	}
629 
630 	if (prog && efx->net_dev->mtu > efx_xdp_max_mtu(efx)) {
631 		netif_err(efx, drv, efx->net_dev,
632 			  "Unable to configure XDP with MTU of %d (max: %d)\n",
633 			  efx->net_dev->mtu, efx_xdp_max_mtu(efx));
634 		return -EINVAL;
635 	}
636 
637 	old_prog = rtnl_dereference(efx->xdp_prog);
638 	rcu_assign_pointer(efx->xdp_prog, prog);
639 	/* Release the reference that was originally passed by the caller. */
640 	if (old_prog)
641 		bpf_prog_put(old_prog);
642 
643 	return 0;
644 }
645 
646 /* Context: process, rtnl_lock() held. */
647 static int efx_xdp(struct net_device *dev, struct netdev_bpf *xdp)
648 {
649 	struct efx_nic *efx = netdev_priv(dev);
650 
651 	switch (xdp->command) {
652 	case XDP_SETUP_PROG:
653 		return efx_xdp_setup_prog(efx, xdp->prog);
654 	default:
655 		return -EINVAL;
656 	}
657 }
658 
659 static int efx_xdp_xmit(struct net_device *dev, int n, struct xdp_frame **xdpfs,
660 			u32 flags)
661 {
662 	struct efx_nic *efx = netdev_priv(dev);
663 
664 	if (!netif_running(dev))
665 		return -EINVAL;
666 
667 	return efx_xdp_tx_buffers(efx, n, xdpfs, flags & XDP_XMIT_FLUSH);
668 }
669 
670 static void efx_update_name(struct efx_nic *efx)
671 {
672 	strcpy(efx->name, efx->net_dev->name);
673 	efx_mtd_rename(efx);
674 	efx_set_channel_names(efx);
675 }
676 
677 static int efx_netdev_event(struct notifier_block *this,
678 			    unsigned long event, void *ptr)
679 {
680 	struct net_device *net_dev = netdev_notifier_info_to_dev(ptr);
681 
682 	if ((net_dev->netdev_ops == &efx_netdev_ops) &&
683 	    event == NETDEV_CHANGENAME)
684 		efx_update_name(netdev_priv(net_dev));
685 
686 	return NOTIFY_DONE;
687 }
688 
689 static struct notifier_block efx_netdev_notifier = {
690 	.notifier_call = efx_netdev_event,
691 };
692 
693 static ssize_t phy_type_show(struct device *dev,
694 			     struct device_attribute *attr, char *buf)
695 {
696 	struct efx_nic *efx = dev_get_drvdata(dev);
697 	return sprintf(buf, "%d\n", efx->phy_type);
698 }
699 static DEVICE_ATTR_RO(phy_type);
700 
701 static int efx_register_netdev(struct efx_nic *efx)
702 {
703 	struct net_device *net_dev = efx->net_dev;
704 	struct efx_channel *channel;
705 	int rc;
706 
707 	net_dev->watchdog_timeo = 5 * HZ;
708 	net_dev->irq = efx->pci_dev->irq;
709 	net_dev->netdev_ops = &efx_netdev_ops;
710 	if (efx_nic_rev(efx) >= EFX_REV_HUNT_A0)
711 		net_dev->priv_flags |= IFF_UNICAST_FLT;
712 	net_dev->ethtool_ops = &efx_ethtool_ops;
713 	netif_set_gso_max_segs(net_dev, EFX_TSO_MAX_SEGS);
714 	net_dev->min_mtu = EFX_MIN_MTU;
715 	net_dev->max_mtu = EFX_MAX_MTU;
716 
717 	rtnl_lock();
718 
719 	/* Enable resets to be scheduled and check whether any were
720 	 * already requested.  If so, the NIC is probably hosed so we
721 	 * abort.
722 	 */
723 	efx->state = STATE_READY;
724 	smp_mb(); /* ensure we change state before checking reset_pending */
725 	if (efx->reset_pending) {
726 		pci_err(efx->pci_dev, "aborting probe due to scheduled reset\n");
727 		rc = -EIO;
728 		goto fail_locked;
729 	}
730 
731 	rc = dev_alloc_name(net_dev, net_dev->name);
732 	if (rc < 0)
733 		goto fail_locked;
734 	efx_update_name(efx);
735 
736 	/* Always start with carrier off; PHY events will detect the link */
737 	netif_carrier_off(net_dev);
738 
739 	rc = register_netdevice(net_dev);
740 	if (rc)
741 		goto fail_locked;
742 
743 	efx_for_each_channel(channel, efx) {
744 		struct efx_tx_queue *tx_queue;
745 		efx_for_each_channel_tx_queue(tx_queue, channel)
746 			efx_init_tx_queue_core_txq(tx_queue);
747 	}
748 
749 	efx_associate(efx);
750 
751 	rtnl_unlock();
752 
753 	rc = device_create_file(&efx->pci_dev->dev, &dev_attr_phy_type);
754 	if (rc) {
755 		netif_err(efx, drv, efx->net_dev,
756 			  "failed to init net dev attributes\n");
757 		goto fail_registered;
758 	}
759 
760 	efx_init_mcdi_logging(efx);
761 
762 	return 0;
763 
764 fail_registered:
765 	rtnl_lock();
766 	efx_dissociate(efx);
767 	unregister_netdevice(net_dev);
768 fail_locked:
769 	efx->state = STATE_UNINIT;
770 	rtnl_unlock();
771 	netif_err(efx, drv, efx->net_dev, "could not register net dev\n");
772 	return rc;
773 }
774 
775 static void efx_unregister_netdev(struct efx_nic *efx)
776 {
777 	if (!efx->net_dev)
778 		return;
779 
780 	BUG_ON(netdev_priv(efx->net_dev) != efx);
781 
782 	if (efx_dev_registered(efx)) {
783 		strlcpy(efx->name, pci_name(efx->pci_dev), sizeof(efx->name));
784 		efx_fini_mcdi_logging(efx);
785 		device_remove_file(&efx->pci_dev->dev, &dev_attr_phy_type);
786 		unregister_netdev(efx->net_dev);
787 	}
788 }
789 
790 /**************************************************************************
791  *
792  * List of NICs we support
793  *
794  **************************************************************************/
795 
796 /* PCI device ID table */
797 static const struct pci_device_id efx_pci_table[] = {
798 	{PCI_DEVICE(PCI_VENDOR_ID_SOLARFLARE, 0x0803),	/* SFC9020 */
799 	 .driver_data = (unsigned long) &siena_a0_nic_type},
800 	{PCI_DEVICE(PCI_VENDOR_ID_SOLARFLARE, 0x0813),	/* SFL9021 */
801 	 .driver_data = (unsigned long) &siena_a0_nic_type},
802 	{PCI_DEVICE(PCI_VENDOR_ID_SOLARFLARE, 0x0903),  /* SFC9120 PF */
803 	 .driver_data = (unsigned long) &efx_hunt_a0_nic_type},
804 	{PCI_DEVICE(PCI_VENDOR_ID_SOLARFLARE, 0x1903),  /* SFC9120 VF */
805 	 .driver_data = (unsigned long) &efx_hunt_a0_vf_nic_type},
806 	{PCI_DEVICE(PCI_VENDOR_ID_SOLARFLARE, 0x0923),  /* SFC9140 PF */
807 	 .driver_data = (unsigned long) &efx_hunt_a0_nic_type},
808 	{PCI_DEVICE(PCI_VENDOR_ID_SOLARFLARE, 0x1923),  /* SFC9140 VF */
809 	 .driver_data = (unsigned long) &efx_hunt_a0_vf_nic_type},
810 	{PCI_DEVICE(PCI_VENDOR_ID_SOLARFLARE, 0x0a03),  /* SFC9220 PF */
811 	 .driver_data = (unsigned long) &efx_hunt_a0_nic_type},
812 	{PCI_DEVICE(PCI_VENDOR_ID_SOLARFLARE, 0x1a03),  /* SFC9220 VF */
813 	 .driver_data = (unsigned long) &efx_hunt_a0_vf_nic_type},
814 	{PCI_DEVICE(PCI_VENDOR_ID_SOLARFLARE, 0x0b03),  /* SFC9250 PF */
815 	 .driver_data = (unsigned long) &efx_hunt_a0_nic_type},
816 	{PCI_DEVICE(PCI_VENDOR_ID_SOLARFLARE, 0x1b03),  /* SFC9250 VF */
817 	 .driver_data = (unsigned long) &efx_hunt_a0_vf_nic_type},
818 	{0}			/* end of list */
819 };
820 
821 /**************************************************************************
822  *
823  * Data housekeeping
824  *
825  **************************************************************************/
826 
827 void efx_update_sw_stats(struct efx_nic *efx, u64 *stats)
828 {
829 	u64 n_rx_nodesc_trunc = 0;
830 	struct efx_channel *channel;
831 
832 	efx_for_each_channel(channel, efx)
833 		n_rx_nodesc_trunc += channel->n_rx_nodesc_trunc;
834 	stats[GENERIC_STAT_rx_nodesc_trunc] = n_rx_nodesc_trunc;
835 	stats[GENERIC_STAT_rx_noskb_drops] = atomic_read(&efx->n_rx_noskb_drops);
836 }
837 
838 /**************************************************************************
839  *
840  * PCI interface
841  *
842  **************************************************************************/
843 
844 /* Main body of final NIC shutdown code
845  * This is called only at module unload (or hotplug removal).
846  */
847 static void efx_pci_remove_main(struct efx_nic *efx)
848 {
849 	/* Flush reset_work. It can no longer be scheduled since we
850 	 * are not READY.
851 	 */
852 	BUG_ON(efx->state == STATE_READY);
853 	efx_flush_reset_workqueue(efx);
854 
855 	efx_disable_interrupts(efx);
856 	efx_clear_interrupt_affinity(efx);
857 	efx_nic_fini_interrupt(efx);
858 	efx_fini_port(efx);
859 	efx->type->fini(efx);
860 	efx_fini_napi(efx);
861 	efx_remove_all(efx);
862 }
863 
864 /* Final NIC shutdown
865  * This is called only at module unload (or hotplug removal).  A PF can call
866  * this on its VFs to ensure they are unbound first.
867  */
868 static void efx_pci_remove(struct pci_dev *pci_dev)
869 {
870 	struct efx_nic *efx;
871 
872 	efx = pci_get_drvdata(pci_dev);
873 	if (!efx)
874 		return;
875 
876 	/* Mark the NIC as fini, then stop the interface */
877 	rtnl_lock();
878 	efx_dissociate(efx);
879 	dev_close(efx->net_dev);
880 	efx_disable_interrupts(efx);
881 	efx->state = STATE_UNINIT;
882 	rtnl_unlock();
883 
884 	if (efx->type->sriov_fini)
885 		efx->type->sriov_fini(efx);
886 
887 	efx_unregister_netdev(efx);
888 
889 	efx_mtd_remove(efx);
890 
891 	efx_pci_remove_main(efx);
892 
893 	efx_fini_io(efx);
894 	netif_dbg(efx, drv, efx->net_dev, "shutdown successful\n");
895 
896 	efx_fini_struct(efx);
897 	free_netdev(efx->net_dev);
898 
899 	pci_disable_pcie_error_reporting(pci_dev);
900 };
901 
902 /* NIC VPD information
903  * Called during probe to display the part number of the
904  * installed NIC.
905  */
906 static void efx_probe_vpd_strings(struct efx_nic *efx)
907 {
908 	struct pci_dev *dev = efx->pci_dev;
909 	unsigned int vpd_size, kw_len;
910 	u8 *vpd_data;
911 	int start;
912 
913 	vpd_data = pci_vpd_alloc(dev, &vpd_size);
914 	if (IS_ERR(vpd_data)) {
915 		pci_warn(dev, "Unable to read VPD\n");
916 		return;
917 	}
918 
919 	start = pci_vpd_find_ro_info_keyword(vpd_data, vpd_size,
920 					     PCI_VPD_RO_KEYWORD_PARTNO, &kw_len);
921 	if (start < 0)
922 		pci_err(dev, "Part number not found or incomplete\n");
923 	else
924 		pci_info(dev, "Part Number : %.*s\n", kw_len, vpd_data + start);
925 
926 	start = pci_vpd_find_ro_info_keyword(vpd_data, vpd_size,
927 					     PCI_VPD_RO_KEYWORD_SERIALNO, &kw_len);
928 	if (start < 0)
929 		pci_err(dev, "Serial number not found or incomplete\n");
930 	else
931 		efx->vpd_sn = kmemdup_nul(vpd_data + start, kw_len, GFP_KERNEL);
932 
933 	kfree(vpd_data);
934 }
935 
936 
937 /* Main body of NIC initialisation
938  * This is called at module load (or hotplug insertion, theoretically).
939  */
940 static int efx_pci_probe_main(struct efx_nic *efx)
941 {
942 	int rc;
943 
944 	/* Do start-of-day initialisation */
945 	rc = efx_probe_all(efx);
946 	if (rc)
947 		goto fail1;
948 
949 	efx_init_napi(efx);
950 
951 	down_write(&efx->filter_sem);
952 	rc = efx->type->init(efx);
953 	up_write(&efx->filter_sem);
954 	if (rc) {
955 		pci_err(efx->pci_dev, "failed to initialise NIC\n");
956 		goto fail3;
957 	}
958 
959 	rc = efx_init_port(efx);
960 	if (rc) {
961 		netif_err(efx, probe, efx->net_dev,
962 			  "failed to initialise port\n");
963 		goto fail4;
964 	}
965 
966 	rc = efx_nic_init_interrupt(efx);
967 	if (rc)
968 		goto fail5;
969 
970 	efx_set_interrupt_affinity(efx);
971 	rc = efx_enable_interrupts(efx);
972 	if (rc)
973 		goto fail6;
974 
975 	return 0;
976 
977  fail6:
978 	efx_clear_interrupt_affinity(efx);
979 	efx_nic_fini_interrupt(efx);
980  fail5:
981 	efx_fini_port(efx);
982  fail4:
983 	efx->type->fini(efx);
984  fail3:
985 	efx_fini_napi(efx);
986 	efx_remove_all(efx);
987  fail1:
988 	return rc;
989 }
990 
991 static int efx_pci_probe_post_io(struct efx_nic *efx)
992 {
993 	struct net_device *net_dev = efx->net_dev;
994 	int rc = efx_pci_probe_main(efx);
995 
996 	if (rc)
997 		return rc;
998 
999 	if (efx->type->sriov_init) {
1000 		rc = efx->type->sriov_init(efx);
1001 		if (rc)
1002 			pci_err(efx->pci_dev, "SR-IOV can't be enabled rc %d\n",
1003 				rc);
1004 	}
1005 
1006 	/* Determine netdevice features */
1007 	net_dev->features |= (efx->type->offload_features | NETIF_F_SG |
1008 			      NETIF_F_TSO | NETIF_F_RXCSUM | NETIF_F_RXALL);
1009 	if (efx->type->offload_features & (NETIF_F_IPV6_CSUM | NETIF_F_HW_CSUM))
1010 		net_dev->features |= NETIF_F_TSO6;
1011 	/* Check whether device supports TSO */
1012 	if (!efx->type->tso_versions || !efx->type->tso_versions(efx))
1013 		net_dev->features &= ~NETIF_F_ALL_TSO;
1014 	/* Mask for features that also apply to VLAN devices */
1015 	net_dev->vlan_features |= (NETIF_F_HW_CSUM | NETIF_F_SG |
1016 				   NETIF_F_HIGHDMA | NETIF_F_ALL_TSO |
1017 				   NETIF_F_RXCSUM);
1018 
1019 	net_dev->hw_features |= net_dev->features & ~efx->fixed_features;
1020 
1021 	/* Disable receiving frames with bad FCS, by default. */
1022 	net_dev->features &= ~NETIF_F_RXALL;
1023 
1024 	/* Disable VLAN filtering by default.  It may be enforced if
1025 	 * the feature is fixed (i.e. VLAN filters are required to
1026 	 * receive VLAN tagged packets due to vPort restrictions).
1027 	 */
1028 	net_dev->features &= ~NETIF_F_HW_VLAN_CTAG_FILTER;
1029 	net_dev->features |= efx->fixed_features;
1030 
1031 	rc = efx_register_netdev(efx);
1032 	if (!rc)
1033 		return 0;
1034 
1035 	efx_pci_remove_main(efx);
1036 	return rc;
1037 }
1038 
1039 /* NIC initialisation
1040  *
1041  * This is called at module load (or hotplug insertion,
1042  * theoretically).  It sets up PCI mappings, resets the NIC,
1043  * sets up and registers the network devices with the kernel and hooks
1044  * the interrupt service routine.  It does not prepare the device for
1045  * transmission; this is left to the first time one of the network
1046  * interfaces is brought up (i.e. efx_net_open).
1047  */
1048 static int efx_pci_probe(struct pci_dev *pci_dev,
1049 			 const struct pci_device_id *entry)
1050 {
1051 	struct net_device *net_dev;
1052 	struct efx_nic *efx;
1053 	int rc;
1054 
1055 	/* Allocate and initialise a struct net_device and struct efx_nic */
1056 	net_dev = alloc_etherdev_mqs(sizeof(*efx), EFX_MAX_CORE_TX_QUEUES,
1057 				     EFX_MAX_RX_QUEUES);
1058 	if (!net_dev)
1059 		return -ENOMEM;
1060 	efx = netdev_priv(net_dev);
1061 	efx->type = (const struct efx_nic_type *) entry->driver_data;
1062 	efx->fixed_features |= NETIF_F_HIGHDMA;
1063 
1064 	pci_set_drvdata(pci_dev, efx);
1065 	SET_NETDEV_DEV(net_dev, &pci_dev->dev);
1066 	rc = efx_init_struct(efx, pci_dev, net_dev);
1067 	if (rc)
1068 		goto fail1;
1069 
1070 	pci_info(pci_dev, "Solarflare NIC detected\n");
1071 
1072 	if (!efx->type->is_vf)
1073 		efx_probe_vpd_strings(efx);
1074 
1075 	/* Set up basic I/O (BAR mappings etc) */
1076 	rc = efx_init_io(efx, efx->type->mem_bar(efx), efx->type->max_dma_mask,
1077 			 efx->type->mem_map_size(efx));
1078 	if (rc)
1079 		goto fail2;
1080 
1081 	rc = efx_pci_probe_post_io(efx);
1082 	if (rc) {
1083 		/* On failure, retry once immediately.
1084 		 * If we aborted probe due to a scheduled reset, dismiss it.
1085 		 */
1086 		efx->reset_pending = 0;
1087 		rc = efx_pci_probe_post_io(efx);
1088 		if (rc) {
1089 			/* On another failure, retry once more
1090 			 * after a 50-305ms delay.
1091 			 */
1092 			unsigned char r;
1093 
1094 			get_random_bytes(&r, 1);
1095 			msleep((unsigned int)r + 50);
1096 			efx->reset_pending = 0;
1097 			rc = efx_pci_probe_post_io(efx);
1098 		}
1099 	}
1100 	if (rc)
1101 		goto fail3;
1102 
1103 	netif_dbg(efx, probe, efx->net_dev, "initialisation successful\n");
1104 
1105 	/* Try to create MTDs, but allow this to fail */
1106 	rtnl_lock();
1107 	rc = efx_mtd_probe(efx);
1108 	rtnl_unlock();
1109 	if (rc && rc != -EPERM)
1110 		netif_warn(efx, probe, efx->net_dev,
1111 			   "failed to create MTDs (%d)\n", rc);
1112 
1113 	(void)pci_enable_pcie_error_reporting(pci_dev);
1114 
1115 	if (efx->type->udp_tnl_push_ports)
1116 		efx->type->udp_tnl_push_ports(efx);
1117 
1118 	return 0;
1119 
1120  fail3:
1121 	efx_fini_io(efx);
1122  fail2:
1123 	efx_fini_struct(efx);
1124  fail1:
1125 	WARN_ON(rc > 0);
1126 	netif_dbg(efx, drv, efx->net_dev, "initialisation failed. rc=%d\n", rc);
1127 	free_netdev(net_dev);
1128 	return rc;
1129 }
1130 
1131 /* efx_pci_sriov_configure returns the actual number of Virtual Functions
1132  * enabled on success
1133  */
1134 #ifdef CONFIG_SFC_SRIOV
1135 static int efx_pci_sriov_configure(struct pci_dev *dev, int num_vfs)
1136 {
1137 	int rc;
1138 	struct efx_nic *efx = pci_get_drvdata(dev);
1139 
1140 	if (efx->type->sriov_configure) {
1141 		rc = efx->type->sriov_configure(efx, num_vfs);
1142 		if (rc)
1143 			return rc;
1144 		else
1145 			return num_vfs;
1146 	} else
1147 		return -EOPNOTSUPP;
1148 }
1149 #endif
1150 
1151 static int efx_pm_freeze(struct device *dev)
1152 {
1153 	struct efx_nic *efx = dev_get_drvdata(dev);
1154 
1155 	rtnl_lock();
1156 
1157 	if (efx->state != STATE_DISABLED) {
1158 		efx->state = STATE_UNINIT;
1159 
1160 		efx_device_detach_sync(efx);
1161 
1162 		efx_stop_all(efx);
1163 		efx_disable_interrupts(efx);
1164 	}
1165 
1166 	rtnl_unlock();
1167 
1168 	return 0;
1169 }
1170 
1171 static int efx_pm_thaw(struct device *dev)
1172 {
1173 	int rc;
1174 	struct efx_nic *efx = dev_get_drvdata(dev);
1175 
1176 	rtnl_lock();
1177 
1178 	if (efx->state != STATE_DISABLED) {
1179 		rc = efx_enable_interrupts(efx);
1180 		if (rc)
1181 			goto fail;
1182 
1183 		mutex_lock(&efx->mac_lock);
1184 		efx_mcdi_port_reconfigure(efx);
1185 		mutex_unlock(&efx->mac_lock);
1186 
1187 		efx_start_all(efx);
1188 
1189 		efx_device_attach_if_not_resetting(efx);
1190 
1191 		efx->state = STATE_READY;
1192 
1193 		efx->type->resume_wol(efx);
1194 	}
1195 
1196 	rtnl_unlock();
1197 
1198 	/* Reschedule any quenched resets scheduled during efx_pm_freeze() */
1199 	efx_queue_reset_work(efx);
1200 
1201 	return 0;
1202 
1203 fail:
1204 	rtnl_unlock();
1205 
1206 	return rc;
1207 }
1208 
1209 static int efx_pm_poweroff(struct device *dev)
1210 {
1211 	struct pci_dev *pci_dev = to_pci_dev(dev);
1212 	struct efx_nic *efx = pci_get_drvdata(pci_dev);
1213 
1214 	efx->type->fini(efx);
1215 
1216 	efx->reset_pending = 0;
1217 
1218 	pci_save_state(pci_dev);
1219 	return pci_set_power_state(pci_dev, PCI_D3hot);
1220 }
1221 
1222 /* Used for both resume and restore */
1223 static int efx_pm_resume(struct device *dev)
1224 {
1225 	struct pci_dev *pci_dev = to_pci_dev(dev);
1226 	struct efx_nic *efx = pci_get_drvdata(pci_dev);
1227 	int rc;
1228 
1229 	rc = pci_set_power_state(pci_dev, PCI_D0);
1230 	if (rc)
1231 		return rc;
1232 	pci_restore_state(pci_dev);
1233 	rc = pci_enable_device(pci_dev);
1234 	if (rc)
1235 		return rc;
1236 	pci_set_master(efx->pci_dev);
1237 	rc = efx->type->reset(efx, RESET_TYPE_ALL);
1238 	if (rc)
1239 		return rc;
1240 	down_write(&efx->filter_sem);
1241 	rc = efx->type->init(efx);
1242 	up_write(&efx->filter_sem);
1243 	if (rc)
1244 		return rc;
1245 	rc = efx_pm_thaw(dev);
1246 	return rc;
1247 }
1248 
1249 static int efx_pm_suspend(struct device *dev)
1250 {
1251 	int rc;
1252 
1253 	efx_pm_freeze(dev);
1254 	rc = efx_pm_poweroff(dev);
1255 	if (rc)
1256 		efx_pm_resume(dev);
1257 	return rc;
1258 }
1259 
1260 static const struct dev_pm_ops efx_pm_ops = {
1261 	.suspend	= efx_pm_suspend,
1262 	.resume		= efx_pm_resume,
1263 	.freeze		= efx_pm_freeze,
1264 	.thaw		= efx_pm_thaw,
1265 	.poweroff	= efx_pm_poweroff,
1266 	.restore	= efx_pm_resume,
1267 };
1268 
1269 static struct pci_driver efx_pci_driver = {
1270 	.name		= KBUILD_MODNAME,
1271 	.id_table	= efx_pci_table,
1272 	.probe		= efx_pci_probe,
1273 	.remove		= efx_pci_remove,
1274 	.driver.pm	= &efx_pm_ops,
1275 	.err_handler	= &efx_err_handlers,
1276 #ifdef CONFIG_SFC_SRIOV
1277 	.sriov_configure = efx_pci_sriov_configure,
1278 #endif
1279 };
1280 
1281 /**************************************************************************
1282  *
1283  * Kernel module interface
1284  *
1285  *************************************************************************/
1286 
1287 static int __init efx_init_module(void)
1288 {
1289 	int rc;
1290 
1291 	printk(KERN_INFO "Solarflare NET driver\n");
1292 
1293 	rc = register_netdevice_notifier(&efx_netdev_notifier);
1294 	if (rc)
1295 		goto err_notifier;
1296 
1297 #ifdef CONFIG_SFC_SRIOV
1298 	rc = efx_init_sriov();
1299 	if (rc)
1300 		goto err_sriov;
1301 #endif
1302 
1303 	rc = efx_create_reset_workqueue();
1304 	if (rc)
1305 		goto err_reset;
1306 
1307 	rc = pci_register_driver(&efx_pci_driver);
1308 	if (rc < 0)
1309 		goto err_pci;
1310 
1311 	rc = pci_register_driver(&ef100_pci_driver);
1312 	if (rc < 0)
1313 		goto err_pci_ef100;
1314 
1315 	return 0;
1316 
1317  err_pci_ef100:
1318 	pci_unregister_driver(&efx_pci_driver);
1319  err_pci:
1320 	efx_destroy_reset_workqueue();
1321  err_reset:
1322 #ifdef CONFIG_SFC_SRIOV
1323 	efx_fini_sriov();
1324  err_sriov:
1325 #endif
1326 	unregister_netdevice_notifier(&efx_netdev_notifier);
1327  err_notifier:
1328 	return rc;
1329 }
1330 
1331 static void __exit efx_exit_module(void)
1332 {
1333 	printk(KERN_INFO "Solarflare NET driver unloading\n");
1334 
1335 	pci_unregister_driver(&ef100_pci_driver);
1336 	pci_unregister_driver(&efx_pci_driver);
1337 	efx_destroy_reset_workqueue();
1338 #ifdef CONFIG_SFC_SRIOV
1339 	efx_fini_sriov();
1340 #endif
1341 	unregister_netdevice_notifier(&efx_netdev_notifier);
1342 
1343 }
1344 
1345 module_init(efx_init_module);
1346 module_exit(efx_exit_module);
1347 
1348 MODULE_AUTHOR("Solarflare Communications and "
1349 	      "Michael Brown <mbrown@fensystems.co.uk>");
1350 MODULE_DESCRIPTION("Solarflare network driver");
1351 MODULE_LICENSE("GPL");
1352 MODULE_DEVICE_TABLE(pci, efx_pci_table);
1353