Commit | Line | Data |
---|---|---|
8ceee660 BH |
1 | /**************************************************************************** |
2 | * Driver for Solarflare Solarstorm network controllers and boards | |
3 | * Copyright 2005-2006 Fen Systems Ltd. | |
4 | * Copyright 2005-2008 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/module.h> | |
12 | #include <linux/pci.h> | |
13 | #include <linux/netdevice.h> | |
14 | #include <linux/etherdevice.h> | |
15 | #include <linux/delay.h> | |
16 | #include <linux/notifier.h> | |
17 | #include <linux/ip.h> | |
18 | #include <linux/tcp.h> | |
19 | #include <linux/in.h> | |
20 | #include <linux/crc32.h> | |
21 | #include <linux/ethtool.h> | |
aa6ef27e | 22 | #include <linux/topology.h> |
8ceee660 BH |
23 | #include "net_driver.h" |
24 | #include "gmii.h" | |
25 | #include "ethtool.h" | |
26 | #include "tx.h" | |
27 | #include "rx.h" | |
28 | #include "efx.h" | |
29 | #include "mdio_10g.h" | |
30 | #include "falcon.h" | |
8ceee660 BH |
31 | #include "mac.h" |
32 | ||
33 | #define EFX_MAX_MTU (9 * 1024) | |
34 | ||
35 | /* RX slow fill workqueue. If memory allocation fails in the fast path, | |
36 | * a work item is pushed onto this work queue to retry the allocation later, | |
37 | * to avoid the NIC being starved of RX buffers. Since this is a per cpu | |
38 | * workqueue, there is nothing to be gained in making it per NIC | |
39 | */ | |
40 | static struct workqueue_struct *refill_workqueue; | |
41 | ||
42 | /************************************************************************** | |
43 | * | |
44 | * Configurable values | |
45 | * | |
46 | *************************************************************************/ | |
47 | ||
48 | /* | |
49 | * Enable large receive offload (LRO) aka soft segment reassembly (SSR) | |
50 | * | |
51 | * This sets the default for new devices. It can be controlled later | |
52 | * using ethtool. | |
53 | */ | |
dc8cfa55 | 54 | static int lro = true; |
8ceee660 BH |
55 | module_param(lro, int, 0644); |
56 | MODULE_PARM_DESC(lro, "Large receive offload acceleration"); | |
57 | ||
58 | /* | |
59 | * Use separate channels for TX and RX events | |
60 | * | |
61 | * Set this to 1 to use separate channels for TX and RX. It allows us to | |
62 | * apply a higher level of interrupt moderation to TX events. | |
63 | * | |
64 | * This is forced to 0 for MSI interrupt mode as the interrupt vector | |
65 | * is not written | |
66 | */ | |
dc8cfa55 | 67 | static unsigned int separate_tx_and_rx_channels = true; |
8ceee660 BH |
68 | |
69 | /* This is the weight assigned to each of the (per-channel) virtual | |
70 | * NAPI devices. | |
71 | */ | |
72 | static int napi_weight = 64; | |
73 | ||
74 | /* This is the time (in jiffies) between invocations of the hardware | |
75 | * monitor, which checks for known hardware bugs and resets the | |
76 | * hardware and driver as necessary. | |
77 | */ | |
78 | unsigned int efx_monitor_interval = 1 * HZ; | |
79 | ||
8ceee660 BH |
80 | /* This controls whether or not the driver will initialise devices |
81 | * with invalid MAC addresses stored in the EEPROM or flash. If true, | |
82 | * such devices will be initialised with a random locally-generated | |
83 | * MAC address. This allows for loading the sfc_mtd driver to | |
84 | * reprogram the flash, even if the flash contents (including the MAC | |
85 | * address) have previously been erased. | |
86 | */ | |
87 | static unsigned int allow_bad_hwaddr; | |
88 | ||
89 | /* Initial interrupt moderation settings. They can be modified after | |
90 | * module load with ethtool. | |
91 | * | |
92 | * The default for RX should strike a balance between increasing the | |
93 | * round-trip latency and reducing overhead. | |
94 | */ | |
95 | static unsigned int rx_irq_mod_usec = 60; | |
96 | ||
97 | /* Initial interrupt moderation settings. They can be modified after | |
98 | * module load with ethtool. | |
99 | * | |
100 | * This default is chosen to ensure that a 10G link does not go idle | |
101 | * while a TX queue is stopped after it has become full. A queue is | |
102 | * restarted when it drops below half full. The time this takes (assuming | |
103 | * worst case 3 descriptors per packet and 1024 descriptors) is | |
104 | * 512 / 3 * 1.2 = 205 usec. | |
105 | */ | |
106 | static unsigned int tx_irq_mod_usec = 150; | |
107 | ||
108 | /* This is the first interrupt mode to try out of: | |
109 | * 0 => MSI-X | |
110 | * 1 => MSI | |
111 | * 2 => legacy | |
112 | */ | |
113 | static unsigned int interrupt_mode; | |
114 | ||
115 | /* This is the requested number of CPUs to use for Receive-Side Scaling (RSS), | |
116 | * i.e. the number of CPUs among which we may distribute simultaneous | |
117 | * interrupt handling. | |
118 | * | |
119 | * Cards without MSI-X will only target one CPU via legacy or MSI interrupt. | |
120 | * The default (0) means to assign an interrupt to each package (level II cache) | |
121 | */ | |
122 | static unsigned int rss_cpus; | |
123 | module_param(rss_cpus, uint, 0444); | |
124 | MODULE_PARM_DESC(rss_cpus, "Number of CPUs to use for Receive-Side Scaling"); | |
125 | ||
126 | /************************************************************************** | |
127 | * | |
128 | * Utility functions and prototypes | |
129 | * | |
130 | *************************************************************************/ | |
131 | static void efx_remove_channel(struct efx_channel *channel); | |
132 | static void efx_remove_port(struct efx_nic *efx); | |
133 | static void efx_fini_napi(struct efx_nic *efx); | |
134 | static void efx_fini_channels(struct efx_nic *efx); | |
135 | ||
136 | #define EFX_ASSERT_RESET_SERIALISED(efx) \ | |
137 | do { \ | |
3c78708f | 138 | if (efx->state == STATE_RUNNING) \ |
8ceee660 BH |
139 | ASSERT_RTNL(); \ |
140 | } while (0) | |
141 | ||
142 | /************************************************************************** | |
143 | * | |
144 | * Event queue processing | |
145 | * | |
146 | *************************************************************************/ | |
147 | ||
148 | /* Process channel's event queue | |
149 | * | |
150 | * This function is responsible for processing the event queue of a | |
151 | * single channel. The caller must guarantee that this function will | |
152 | * never be concurrently called more than once on the same channel, | |
153 | * though different channels may be being processed concurrently. | |
154 | */ | |
4d566063 | 155 | static int efx_process_channel(struct efx_channel *channel, int rx_quota) |
8ceee660 | 156 | { |
42cbe2d7 BH |
157 | struct efx_nic *efx = channel->efx; |
158 | int rx_packets; | |
8ceee660 | 159 | |
42cbe2d7 | 160 | if (unlikely(efx->reset_pending != RESET_TYPE_NONE || |
8ceee660 | 161 | !channel->enabled)) |
42cbe2d7 | 162 | return 0; |
8ceee660 | 163 | |
42cbe2d7 BH |
164 | rx_packets = falcon_process_eventq(channel, rx_quota); |
165 | if (rx_packets == 0) | |
166 | return 0; | |
8ceee660 BH |
167 | |
168 | /* Deliver last RX packet. */ | |
169 | if (channel->rx_pkt) { | |
170 | __efx_rx_packet(channel, channel->rx_pkt, | |
171 | channel->rx_pkt_csummed); | |
172 | channel->rx_pkt = NULL; | |
173 | } | |
174 | ||
175 | efx_flush_lro(channel); | |
176 | efx_rx_strategy(channel); | |
177 | ||
42cbe2d7 | 178 | efx_fast_push_rx_descriptors(&efx->rx_queue[channel->channel]); |
8ceee660 | 179 | |
42cbe2d7 | 180 | return rx_packets; |
8ceee660 BH |
181 | } |
182 | ||
183 | /* Mark channel as finished processing | |
184 | * | |
185 | * Note that since we will not receive further interrupts for this | |
186 | * channel before we finish processing and call the eventq_read_ack() | |
187 | * method, there is no need to use the interrupt hold-off timers. | |
188 | */ | |
189 | static inline void efx_channel_processed(struct efx_channel *channel) | |
190 | { | |
5b9e207c BH |
191 | /* The interrupt handler for this channel may set work_pending |
192 | * as soon as we acknowledge the events we've seen. Make sure | |
193 | * it's cleared before then. */ | |
dc8cfa55 | 194 | channel->work_pending = false; |
5b9e207c BH |
195 | smp_wmb(); |
196 | ||
8ceee660 BH |
197 | falcon_eventq_read_ack(channel); |
198 | } | |
199 | ||
200 | /* NAPI poll handler | |
201 | * | |
202 | * NAPI guarantees serialisation of polls of the same device, which | |
203 | * provides the guarantee required by efx_process_channel(). | |
204 | */ | |
205 | static int efx_poll(struct napi_struct *napi, int budget) | |
206 | { | |
207 | struct efx_channel *channel = | |
208 | container_of(napi, struct efx_channel, napi_str); | |
209 | struct net_device *napi_dev = channel->napi_dev; | |
8ceee660 BH |
210 | int rx_packets; |
211 | ||
212 | EFX_TRACE(channel->efx, "channel %d NAPI poll executing on CPU %d\n", | |
213 | channel->channel, raw_smp_processor_id()); | |
214 | ||
42cbe2d7 | 215 | rx_packets = efx_process_channel(channel, budget); |
8ceee660 BH |
216 | |
217 | if (rx_packets < budget) { | |
218 | /* There is no race here; although napi_disable() will | |
219 | * only wait for netif_rx_complete(), this isn't a problem | |
220 | * since efx_channel_processed() will have no effect if | |
221 | * interrupts have already been disabled. | |
222 | */ | |
223 | netif_rx_complete(napi_dev, napi); | |
224 | efx_channel_processed(channel); | |
225 | } | |
226 | ||
227 | return rx_packets; | |
228 | } | |
229 | ||
230 | /* Process the eventq of the specified channel immediately on this CPU | |
231 | * | |
232 | * Disable hardware generated interrupts, wait for any existing | |
233 | * processing to finish, then directly poll (and ack ) the eventq. | |
234 | * Finally reenable NAPI and interrupts. | |
235 | * | |
236 | * Since we are touching interrupts the caller should hold the suspend lock | |
237 | */ | |
238 | void efx_process_channel_now(struct efx_channel *channel) | |
239 | { | |
240 | struct efx_nic *efx = channel->efx; | |
241 | ||
242 | BUG_ON(!channel->used_flags); | |
243 | BUG_ON(!channel->enabled); | |
244 | ||
245 | /* Disable interrupts and wait for ISRs to complete */ | |
246 | falcon_disable_interrupts(efx); | |
247 | if (efx->legacy_irq) | |
248 | synchronize_irq(efx->legacy_irq); | |
64ee3120 | 249 | if (channel->irq) |
8ceee660 BH |
250 | synchronize_irq(channel->irq); |
251 | ||
252 | /* Wait for any NAPI processing to complete */ | |
253 | napi_disable(&channel->napi_str); | |
254 | ||
255 | /* Poll the channel */ | |
91ad757c | 256 | efx_process_channel(channel, efx->type->evq_size); |
8ceee660 BH |
257 | |
258 | /* Ack the eventq. This may cause an interrupt to be generated | |
259 | * when they are reenabled */ | |
260 | efx_channel_processed(channel); | |
261 | ||
262 | napi_enable(&channel->napi_str); | |
263 | falcon_enable_interrupts(efx); | |
264 | } | |
265 | ||
266 | /* Create event queue | |
267 | * Event queue memory allocations are done only once. If the channel | |
268 | * is reset, the memory buffer will be reused; this guards against | |
269 | * errors during channel reset and also simplifies interrupt handling. | |
270 | */ | |
271 | static int efx_probe_eventq(struct efx_channel *channel) | |
272 | { | |
273 | EFX_LOG(channel->efx, "chan %d create event queue\n", channel->channel); | |
274 | ||
275 | return falcon_probe_eventq(channel); | |
276 | } | |
277 | ||
278 | /* Prepare channel's event queue */ | |
bc3c90a2 | 279 | static void efx_init_eventq(struct efx_channel *channel) |
8ceee660 BH |
280 | { |
281 | EFX_LOG(channel->efx, "chan %d init event queue\n", channel->channel); | |
282 | ||
283 | channel->eventq_read_ptr = 0; | |
284 | ||
bc3c90a2 | 285 | falcon_init_eventq(channel); |
8ceee660 BH |
286 | } |
287 | ||
288 | static void efx_fini_eventq(struct efx_channel *channel) | |
289 | { | |
290 | EFX_LOG(channel->efx, "chan %d fini event queue\n", channel->channel); | |
291 | ||
292 | falcon_fini_eventq(channel); | |
293 | } | |
294 | ||
295 | static void efx_remove_eventq(struct efx_channel *channel) | |
296 | { | |
297 | EFX_LOG(channel->efx, "chan %d remove event queue\n", channel->channel); | |
298 | ||
299 | falcon_remove_eventq(channel); | |
300 | } | |
301 | ||
302 | /************************************************************************** | |
303 | * | |
304 | * Channel handling | |
305 | * | |
306 | *************************************************************************/ | |
307 | ||
8ceee660 BH |
308 | static int efx_probe_channel(struct efx_channel *channel) |
309 | { | |
310 | struct efx_tx_queue *tx_queue; | |
311 | struct efx_rx_queue *rx_queue; | |
312 | int rc; | |
313 | ||
314 | EFX_LOG(channel->efx, "creating channel %d\n", channel->channel); | |
315 | ||
316 | rc = efx_probe_eventq(channel); | |
317 | if (rc) | |
318 | goto fail1; | |
319 | ||
320 | efx_for_each_channel_tx_queue(tx_queue, channel) { | |
321 | rc = efx_probe_tx_queue(tx_queue); | |
322 | if (rc) | |
323 | goto fail2; | |
324 | } | |
325 | ||
326 | efx_for_each_channel_rx_queue(rx_queue, channel) { | |
327 | rc = efx_probe_rx_queue(rx_queue); | |
328 | if (rc) | |
329 | goto fail3; | |
330 | } | |
331 | ||
332 | channel->n_rx_frm_trunc = 0; | |
333 | ||
334 | return 0; | |
335 | ||
336 | fail3: | |
337 | efx_for_each_channel_rx_queue(rx_queue, channel) | |
338 | efx_remove_rx_queue(rx_queue); | |
339 | fail2: | |
340 | efx_for_each_channel_tx_queue(tx_queue, channel) | |
341 | efx_remove_tx_queue(tx_queue); | |
342 | fail1: | |
343 | return rc; | |
344 | } | |
345 | ||
346 | ||
347 | /* Channels are shutdown and reinitialised whilst the NIC is running | |
348 | * to propagate configuration changes (mtu, checksum offload), or | |
349 | * to clear hardware error conditions | |
350 | */ | |
bc3c90a2 | 351 | static void efx_init_channels(struct efx_nic *efx) |
8ceee660 BH |
352 | { |
353 | struct efx_tx_queue *tx_queue; | |
354 | struct efx_rx_queue *rx_queue; | |
355 | struct efx_channel *channel; | |
8ceee660 | 356 | |
f7f13b0b BH |
357 | /* Calculate the rx buffer allocation parameters required to |
358 | * support the current MTU, including padding for header | |
359 | * alignment and overruns. | |
360 | */ | |
361 | efx->rx_buffer_len = (max(EFX_PAGE_IP_ALIGN, NET_IP_ALIGN) + | |
362 | EFX_MAX_FRAME_LEN(efx->net_dev->mtu) + | |
363 | efx->type->rx_buffer_padding); | |
364 | efx->rx_buffer_order = get_order(efx->rx_buffer_len); | |
8ceee660 BH |
365 | |
366 | /* Initialise the channels */ | |
367 | efx_for_each_channel(channel, efx) { | |
368 | EFX_LOG(channel->efx, "init chan %d\n", channel->channel); | |
369 | ||
bc3c90a2 | 370 | efx_init_eventq(channel); |
8ceee660 | 371 | |
bc3c90a2 BH |
372 | efx_for_each_channel_tx_queue(tx_queue, channel) |
373 | efx_init_tx_queue(tx_queue); | |
8ceee660 BH |
374 | |
375 | /* The rx buffer allocation strategy is MTU dependent */ | |
376 | efx_rx_strategy(channel); | |
377 | ||
bc3c90a2 BH |
378 | efx_for_each_channel_rx_queue(rx_queue, channel) |
379 | efx_init_rx_queue(rx_queue); | |
8ceee660 BH |
380 | |
381 | WARN_ON(channel->rx_pkt != NULL); | |
382 | efx_rx_strategy(channel); | |
383 | } | |
8ceee660 BH |
384 | } |
385 | ||
386 | /* This enables event queue processing and packet transmission. | |
387 | * | |
388 | * Note that this function is not allowed to fail, since that would | |
389 | * introduce too much complexity into the suspend/resume path. | |
390 | */ | |
391 | static void efx_start_channel(struct efx_channel *channel) | |
392 | { | |
393 | struct efx_rx_queue *rx_queue; | |
394 | ||
395 | EFX_LOG(channel->efx, "starting chan %d\n", channel->channel); | |
396 | ||
397 | if (!(channel->efx->net_dev->flags & IFF_UP)) | |
398 | netif_napi_add(channel->napi_dev, &channel->napi_str, | |
399 | efx_poll, napi_weight); | |
400 | ||
5b9e207c BH |
401 | /* The interrupt handler for this channel may set work_pending |
402 | * as soon as we enable it. Make sure it's cleared before | |
403 | * then. Similarly, make sure it sees the enabled flag set. */ | |
dc8cfa55 BH |
404 | channel->work_pending = false; |
405 | channel->enabled = true; | |
5b9e207c | 406 | smp_wmb(); |
8ceee660 BH |
407 | |
408 | napi_enable(&channel->napi_str); | |
409 | ||
410 | /* Load up RX descriptors */ | |
411 | efx_for_each_channel_rx_queue(rx_queue, channel) | |
412 | efx_fast_push_rx_descriptors(rx_queue); | |
413 | } | |
414 | ||
415 | /* This disables event queue processing and packet transmission. | |
416 | * This function does not guarantee that all queue processing | |
417 | * (e.g. RX refill) is complete. | |
418 | */ | |
419 | static void efx_stop_channel(struct efx_channel *channel) | |
420 | { | |
421 | struct efx_rx_queue *rx_queue; | |
422 | ||
423 | if (!channel->enabled) | |
424 | return; | |
425 | ||
426 | EFX_LOG(channel->efx, "stop chan %d\n", channel->channel); | |
427 | ||
dc8cfa55 | 428 | channel->enabled = false; |
8ceee660 BH |
429 | napi_disable(&channel->napi_str); |
430 | ||
431 | /* Ensure that any worker threads have exited or will be no-ops */ | |
432 | efx_for_each_channel_rx_queue(rx_queue, channel) { | |
433 | spin_lock_bh(&rx_queue->add_lock); | |
434 | spin_unlock_bh(&rx_queue->add_lock); | |
435 | } | |
436 | } | |
437 | ||
438 | static void efx_fini_channels(struct efx_nic *efx) | |
439 | { | |
440 | struct efx_channel *channel; | |
441 | struct efx_tx_queue *tx_queue; | |
442 | struct efx_rx_queue *rx_queue; | |
6bc5d3a9 | 443 | int rc; |
8ceee660 BH |
444 | |
445 | EFX_ASSERT_RESET_SERIALISED(efx); | |
446 | BUG_ON(efx->port_enabled); | |
447 | ||
6bc5d3a9 BH |
448 | rc = falcon_flush_queues(efx); |
449 | if (rc) | |
450 | EFX_ERR(efx, "failed to flush queues\n"); | |
451 | else | |
452 | EFX_LOG(efx, "successfully flushed all queues\n"); | |
453 | ||
8ceee660 BH |
454 | efx_for_each_channel(channel, efx) { |
455 | EFX_LOG(channel->efx, "shut down chan %d\n", channel->channel); | |
456 | ||
457 | efx_for_each_channel_rx_queue(rx_queue, channel) | |
458 | efx_fini_rx_queue(rx_queue); | |
459 | efx_for_each_channel_tx_queue(tx_queue, channel) | |
460 | efx_fini_tx_queue(tx_queue); | |
8ceee660 BH |
461 | efx_fini_eventq(channel); |
462 | } | |
463 | } | |
464 | ||
465 | static void efx_remove_channel(struct efx_channel *channel) | |
466 | { | |
467 | struct efx_tx_queue *tx_queue; | |
468 | struct efx_rx_queue *rx_queue; | |
469 | ||
470 | EFX_LOG(channel->efx, "destroy chan %d\n", channel->channel); | |
471 | ||
472 | efx_for_each_channel_rx_queue(rx_queue, channel) | |
473 | efx_remove_rx_queue(rx_queue); | |
474 | efx_for_each_channel_tx_queue(tx_queue, channel) | |
475 | efx_remove_tx_queue(tx_queue); | |
476 | efx_remove_eventq(channel); | |
477 | ||
478 | channel->used_flags = 0; | |
479 | } | |
480 | ||
481 | void efx_schedule_slow_fill(struct efx_rx_queue *rx_queue, int delay) | |
482 | { | |
483 | queue_delayed_work(refill_workqueue, &rx_queue->work, delay); | |
484 | } | |
485 | ||
486 | /************************************************************************** | |
487 | * | |
488 | * Port handling | |
489 | * | |
490 | **************************************************************************/ | |
491 | ||
492 | /* This ensures that the kernel is kept informed (via | |
493 | * netif_carrier_on/off) of the link status, and also maintains the | |
494 | * link status's stop on the port's TX queue. | |
495 | */ | |
496 | static void efx_link_status_changed(struct efx_nic *efx) | |
497 | { | |
8ceee660 BH |
498 | /* SFC Bug 5356: A net_dev notifier is registered, so we must ensure |
499 | * that no events are triggered between unregister_netdev() and the | |
500 | * driver unloading. A more general condition is that NETDEV_CHANGE | |
501 | * can only be generated between NETDEV_UP and NETDEV_DOWN */ | |
502 | if (!netif_running(efx->net_dev)) | |
503 | return; | |
504 | ||
8c8661e4 BH |
505 | if (efx->port_inhibited) { |
506 | netif_carrier_off(efx->net_dev); | |
507 | return; | |
508 | } | |
509 | ||
dc8cfa55 | 510 | if (efx->link_up != netif_carrier_ok(efx->net_dev)) { |
8ceee660 BH |
511 | efx->n_link_state_changes++; |
512 | ||
513 | if (efx->link_up) | |
514 | netif_carrier_on(efx->net_dev); | |
515 | else | |
516 | netif_carrier_off(efx->net_dev); | |
517 | } | |
518 | ||
519 | /* Status message for kernel log */ | |
520 | if (efx->link_up) { | |
521 | struct mii_if_info *gmii = &efx->mii; | |
522 | unsigned adv, lpa; | |
523 | /* NONE here means direct XAUI from the controller, with no | |
524 | * MDIO-attached device we can query. */ | |
525 | if (efx->phy_type != PHY_TYPE_NONE) { | |
526 | adv = gmii_advertised(gmii); | |
527 | lpa = gmii_lpa(gmii); | |
528 | } else { | |
529 | lpa = GM_LPA_10000 | LPA_DUPLEX; | |
530 | adv = lpa; | |
531 | } | |
532 | EFX_INFO(efx, "link up at %dMbps %s-duplex " | |
533 | "(adv %04x lpa %04x) (MTU %d)%s\n", | |
534 | (efx->link_options & GM_LPA_10000 ? 10000 : | |
535 | (efx->link_options & GM_LPA_1000 ? 1000 : | |
536 | (efx->link_options & GM_LPA_100 ? 100 : | |
537 | 10))), | |
538 | (efx->link_options & GM_LPA_DUPLEX ? | |
539 | "full" : "half"), | |
540 | adv, lpa, | |
541 | efx->net_dev->mtu, | |
542 | (efx->promiscuous ? " [PROMISC]" : "")); | |
543 | } else { | |
544 | EFX_INFO(efx, "link down\n"); | |
545 | } | |
546 | ||
547 | } | |
548 | ||
549 | /* This call reinitialises the MAC to pick up new PHY settings. The | |
550 | * caller must hold the mac_lock */ | |
8c8661e4 | 551 | void __efx_reconfigure_port(struct efx_nic *efx) |
8ceee660 BH |
552 | { |
553 | WARN_ON(!mutex_is_locked(&efx->mac_lock)); | |
554 | ||
555 | EFX_LOG(efx, "reconfiguring MAC from PHY settings on CPU %d\n", | |
556 | raw_smp_processor_id()); | |
557 | ||
a816f75a BH |
558 | /* Serialise the promiscuous flag with efx_set_multicast_list. */ |
559 | if (efx_dev_registered(efx)) { | |
560 | netif_addr_lock_bh(efx->net_dev); | |
561 | netif_addr_unlock_bh(efx->net_dev); | |
562 | } | |
563 | ||
8ceee660 BH |
564 | falcon_reconfigure_xmac(efx); |
565 | ||
566 | /* Inform kernel of loss/gain of carrier */ | |
567 | efx_link_status_changed(efx); | |
568 | } | |
569 | ||
570 | /* Reinitialise the MAC to pick up new PHY settings, even if the port is | |
571 | * disabled. */ | |
572 | void efx_reconfigure_port(struct efx_nic *efx) | |
573 | { | |
574 | EFX_ASSERT_RESET_SERIALISED(efx); | |
575 | ||
576 | mutex_lock(&efx->mac_lock); | |
577 | __efx_reconfigure_port(efx); | |
578 | mutex_unlock(&efx->mac_lock); | |
579 | } | |
580 | ||
581 | /* Asynchronous efx_reconfigure_port work item. To speed up efx_flush_all() | |
582 | * we don't efx_reconfigure_port() if the port is disabled. Care is taken | |
583 | * in efx_stop_all() and efx_start_port() to prevent PHY events being lost */ | |
584 | static void efx_reconfigure_work(struct work_struct *data) | |
585 | { | |
586 | struct efx_nic *efx = container_of(data, struct efx_nic, | |
587 | reconfigure_work); | |
588 | ||
589 | mutex_lock(&efx->mac_lock); | |
590 | if (efx->port_enabled) | |
591 | __efx_reconfigure_port(efx); | |
592 | mutex_unlock(&efx->mac_lock); | |
593 | } | |
594 | ||
595 | static int efx_probe_port(struct efx_nic *efx) | |
596 | { | |
597 | int rc; | |
598 | ||
599 | EFX_LOG(efx, "create port\n"); | |
600 | ||
601 | /* Connect up MAC/PHY operations table and read MAC address */ | |
602 | rc = falcon_probe_port(efx); | |
603 | if (rc) | |
604 | goto err; | |
605 | ||
606 | /* Sanity check MAC address */ | |
607 | if (is_valid_ether_addr(efx->mac_address)) { | |
608 | memcpy(efx->net_dev->dev_addr, efx->mac_address, ETH_ALEN); | |
609 | } else { | |
e174961c JB |
610 | EFX_ERR(efx, "invalid MAC address %pM\n", |
611 | efx->mac_address); | |
8ceee660 BH |
612 | if (!allow_bad_hwaddr) { |
613 | rc = -EINVAL; | |
614 | goto err; | |
615 | } | |
616 | random_ether_addr(efx->net_dev->dev_addr); | |
e174961c JB |
617 | EFX_INFO(efx, "using locally-generated MAC %pM\n", |
618 | efx->net_dev->dev_addr); | |
8ceee660 BH |
619 | } |
620 | ||
621 | return 0; | |
622 | ||
623 | err: | |
624 | efx_remove_port(efx); | |
625 | return rc; | |
626 | } | |
627 | ||
628 | static int efx_init_port(struct efx_nic *efx) | |
629 | { | |
630 | int rc; | |
631 | ||
632 | EFX_LOG(efx, "init port\n"); | |
633 | ||
634 | /* Initialise the MAC and PHY */ | |
635 | rc = falcon_init_xmac(efx); | |
636 | if (rc) | |
637 | return rc; | |
638 | ||
dc8cfa55 | 639 | efx->port_initialized = true; |
8c8661e4 | 640 | efx->stats_enabled = true; |
8ceee660 BH |
641 | |
642 | /* Reconfigure port to program MAC registers */ | |
643 | falcon_reconfigure_xmac(efx); | |
644 | ||
645 | return 0; | |
646 | } | |
647 | ||
648 | /* Allow efx_reconfigure_port() to be scheduled, and close the window | |
649 | * between efx_stop_port and efx_flush_all whereby a previously scheduled | |
650 | * efx_reconfigure_port() may have been cancelled */ | |
651 | static void efx_start_port(struct efx_nic *efx) | |
652 | { | |
653 | EFX_LOG(efx, "start port\n"); | |
654 | BUG_ON(efx->port_enabled); | |
655 | ||
656 | mutex_lock(&efx->mac_lock); | |
dc8cfa55 | 657 | efx->port_enabled = true; |
8ceee660 BH |
658 | __efx_reconfigure_port(efx); |
659 | mutex_unlock(&efx->mac_lock); | |
660 | } | |
661 | ||
662 | /* Prevent efx_reconfigure_work and efx_monitor() from executing, and | |
663 | * efx_set_multicast_list() from scheduling efx_reconfigure_work. | |
664 | * efx_reconfigure_work can still be scheduled via NAPI processing | |
665 | * until efx_flush_all() is called */ | |
666 | static void efx_stop_port(struct efx_nic *efx) | |
667 | { | |
668 | EFX_LOG(efx, "stop port\n"); | |
669 | ||
670 | mutex_lock(&efx->mac_lock); | |
dc8cfa55 | 671 | efx->port_enabled = false; |
8ceee660 BH |
672 | mutex_unlock(&efx->mac_lock); |
673 | ||
674 | /* Serialise against efx_set_multicast_list() */ | |
55668611 | 675 | if (efx_dev_registered(efx)) { |
b9e40857 DM |
676 | netif_addr_lock_bh(efx->net_dev); |
677 | netif_addr_unlock_bh(efx->net_dev); | |
8ceee660 BH |
678 | } |
679 | } | |
680 | ||
681 | static void efx_fini_port(struct efx_nic *efx) | |
682 | { | |
683 | EFX_LOG(efx, "shut down port\n"); | |
684 | ||
685 | if (!efx->port_initialized) | |
686 | return; | |
687 | ||
688 | falcon_fini_xmac(efx); | |
dc8cfa55 | 689 | efx->port_initialized = false; |
8ceee660 | 690 | |
dc8cfa55 | 691 | efx->link_up = false; |
8ceee660 BH |
692 | efx_link_status_changed(efx); |
693 | } | |
694 | ||
695 | static void efx_remove_port(struct efx_nic *efx) | |
696 | { | |
697 | EFX_LOG(efx, "destroying port\n"); | |
698 | ||
699 | falcon_remove_port(efx); | |
700 | } | |
701 | ||
702 | /************************************************************************** | |
703 | * | |
704 | * NIC handling | |
705 | * | |
706 | **************************************************************************/ | |
707 | ||
708 | /* This configures the PCI device to enable I/O and DMA. */ | |
709 | static int efx_init_io(struct efx_nic *efx) | |
710 | { | |
711 | struct pci_dev *pci_dev = efx->pci_dev; | |
712 | dma_addr_t dma_mask = efx->type->max_dma_mask; | |
713 | int rc; | |
714 | ||
715 | EFX_LOG(efx, "initialising I/O\n"); | |
716 | ||
717 | rc = pci_enable_device(pci_dev); | |
718 | if (rc) { | |
719 | EFX_ERR(efx, "failed to enable PCI device\n"); | |
720 | goto fail1; | |
721 | } | |
722 | ||
723 | pci_set_master(pci_dev); | |
724 | ||
725 | /* Set the PCI DMA mask. Try all possibilities from our | |
726 | * genuine mask down to 32 bits, because some architectures | |
727 | * (e.g. x86_64 with iommu_sac_force set) will allow 40 bit | |
728 | * masks event though they reject 46 bit masks. | |
729 | */ | |
730 | while (dma_mask > 0x7fffffffUL) { | |
731 | if (pci_dma_supported(pci_dev, dma_mask) && | |
732 | ((rc = pci_set_dma_mask(pci_dev, dma_mask)) == 0)) | |
733 | break; | |
734 | dma_mask >>= 1; | |
735 | } | |
736 | if (rc) { | |
737 | EFX_ERR(efx, "could not find a suitable DMA mask\n"); | |
738 | goto fail2; | |
739 | } | |
740 | EFX_LOG(efx, "using DMA mask %llx\n", (unsigned long long) dma_mask); | |
741 | rc = pci_set_consistent_dma_mask(pci_dev, dma_mask); | |
742 | if (rc) { | |
743 | /* pci_set_consistent_dma_mask() is not *allowed* to | |
744 | * fail with a mask that pci_set_dma_mask() accepted, | |
745 | * but just in case... | |
746 | */ | |
747 | EFX_ERR(efx, "failed to set consistent DMA mask\n"); | |
748 | goto fail2; | |
749 | } | |
750 | ||
751 | efx->membase_phys = pci_resource_start(efx->pci_dev, | |
752 | efx->type->mem_bar); | |
753 | rc = pci_request_region(pci_dev, efx->type->mem_bar, "sfc"); | |
754 | if (rc) { | |
755 | EFX_ERR(efx, "request for memory BAR failed\n"); | |
756 | rc = -EIO; | |
757 | goto fail3; | |
758 | } | |
759 | efx->membase = ioremap_nocache(efx->membase_phys, | |
760 | efx->type->mem_map_size); | |
761 | if (!efx->membase) { | |
086ea356 BH |
762 | EFX_ERR(efx, "could not map memory BAR %d at %llx+%x\n", |
763 | efx->type->mem_bar, | |
764 | (unsigned long long)efx->membase_phys, | |
8ceee660 BH |
765 | efx->type->mem_map_size); |
766 | rc = -ENOMEM; | |
767 | goto fail4; | |
768 | } | |
086ea356 BH |
769 | EFX_LOG(efx, "memory BAR %u at %llx+%x (virtual %p)\n", |
770 | efx->type->mem_bar, (unsigned long long)efx->membase_phys, | |
771 | efx->type->mem_map_size, efx->membase); | |
8ceee660 BH |
772 | |
773 | return 0; | |
774 | ||
775 | fail4: | |
e1074a0d | 776 | pci_release_region(efx->pci_dev, efx->type->mem_bar); |
8ceee660 | 777 | fail3: |
2c118e0f | 778 | efx->membase_phys = 0; |
8ceee660 BH |
779 | fail2: |
780 | pci_disable_device(efx->pci_dev); | |
781 | fail1: | |
782 | return rc; | |
783 | } | |
784 | ||
785 | static void efx_fini_io(struct efx_nic *efx) | |
786 | { | |
787 | EFX_LOG(efx, "shutting down I/O\n"); | |
788 | ||
789 | if (efx->membase) { | |
790 | iounmap(efx->membase); | |
791 | efx->membase = NULL; | |
792 | } | |
793 | ||
794 | if (efx->membase_phys) { | |
795 | pci_release_region(efx->pci_dev, efx->type->mem_bar); | |
2c118e0f | 796 | efx->membase_phys = 0; |
8ceee660 BH |
797 | } |
798 | ||
799 | pci_disable_device(efx->pci_dev); | |
800 | } | |
801 | ||
46123d04 BH |
802 | /* Get number of RX queues wanted. Return number of online CPU |
803 | * packages in the expectation that an IRQ balancer will spread | |
804 | * interrupts across them. */ | |
805 | static int efx_wanted_rx_queues(void) | |
806 | { | |
807 | cpumask_t core_mask; | |
808 | int count; | |
809 | int cpu; | |
810 | ||
811 | cpus_clear(core_mask); | |
812 | count = 0; | |
813 | for_each_online_cpu(cpu) { | |
814 | if (!cpu_isset(cpu, core_mask)) { | |
815 | ++count; | |
816 | cpus_or(core_mask, core_mask, | |
817 | topology_core_siblings(cpu)); | |
818 | } | |
819 | } | |
820 | ||
821 | return count; | |
822 | } | |
823 | ||
824 | /* Probe the number and type of interrupts we are able to obtain, and | |
825 | * the resulting numbers of channels and RX queues. | |
826 | */ | |
8ceee660 BH |
827 | static void efx_probe_interrupts(struct efx_nic *efx) |
828 | { | |
46123d04 BH |
829 | int max_channels = |
830 | min_t(int, efx->type->phys_addr_channels, EFX_MAX_CHANNELS); | |
8ceee660 BH |
831 | int rc, i; |
832 | ||
833 | if (efx->interrupt_mode == EFX_INT_MODE_MSIX) { | |
46123d04 BH |
834 | struct msix_entry xentries[EFX_MAX_CHANNELS]; |
835 | int wanted_ints; | |
aa6ef27e | 836 | |
46123d04 BH |
837 | /* We want one RX queue and interrupt per CPU package |
838 | * (or as specified by the rss_cpus module parameter). | |
839 | * We will need one channel per interrupt. | |
840 | */ | |
841 | wanted_ints = rss_cpus ? rss_cpus : efx_wanted_rx_queues(); | |
8831da7b | 842 | efx->n_rx_queues = min(wanted_ints, max_channels); |
8ceee660 | 843 | |
8831da7b | 844 | for (i = 0; i < efx->n_rx_queues; i++) |
8ceee660 | 845 | xentries[i].entry = i; |
8831da7b | 846 | rc = pci_enable_msix(efx->pci_dev, xentries, efx->n_rx_queues); |
8ceee660 | 847 | if (rc > 0) { |
8831da7b BH |
848 | EFX_BUG_ON_PARANOID(rc >= efx->n_rx_queues); |
849 | efx->n_rx_queues = rc; | |
8ceee660 | 850 | rc = pci_enable_msix(efx->pci_dev, xentries, |
8831da7b | 851 | efx->n_rx_queues); |
8ceee660 BH |
852 | } |
853 | ||
854 | if (rc == 0) { | |
8831da7b | 855 | for (i = 0; i < efx->n_rx_queues; i++) |
8ceee660 | 856 | efx->channel[i].irq = xentries[i].vector; |
8ceee660 BH |
857 | } else { |
858 | /* Fall back to single channel MSI */ | |
859 | efx->interrupt_mode = EFX_INT_MODE_MSI; | |
860 | EFX_ERR(efx, "could not enable MSI-X\n"); | |
861 | } | |
862 | } | |
863 | ||
864 | /* Try single interrupt MSI */ | |
865 | if (efx->interrupt_mode == EFX_INT_MODE_MSI) { | |
8831da7b | 866 | efx->n_rx_queues = 1; |
8ceee660 BH |
867 | rc = pci_enable_msi(efx->pci_dev); |
868 | if (rc == 0) { | |
869 | efx->channel[0].irq = efx->pci_dev->irq; | |
8ceee660 BH |
870 | } else { |
871 | EFX_ERR(efx, "could not enable MSI\n"); | |
872 | efx->interrupt_mode = EFX_INT_MODE_LEGACY; | |
873 | } | |
874 | } | |
875 | ||
876 | /* Assume legacy interrupts */ | |
877 | if (efx->interrupt_mode == EFX_INT_MODE_LEGACY) { | |
8831da7b | 878 | efx->n_rx_queues = 1; |
8ceee660 BH |
879 | efx->legacy_irq = efx->pci_dev->irq; |
880 | } | |
881 | } | |
882 | ||
883 | static void efx_remove_interrupts(struct efx_nic *efx) | |
884 | { | |
885 | struct efx_channel *channel; | |
886 | ||
887 | /* Remove MSI/MSI-X interrupts */ | |
64ee3120 | 888 | efx_for_each_channel(channel, efx) |
8ceee660 BH |
889 | channel->irq = 0; |
890 | pci_disable_msi(efx->pci_dev); | |
891 | pci_disable_msix(efx->pci_dev); | |
892 | ||
893 | /* Remove legacy interrupt */ | |
894 | efx->legacy_irq = 0; | |
895 | } | |
896 | ||
8831da7b | 897 | static void efx_set_channels(struct efx_nic *efx) |
8ceee660 BH |
898 | { |
899 | struct efx_tx_queue *tx_queue; | |
900 | struct efx_rx_queue *rx_queue; | |
8ceee660 | 901 | |
60ac1065 BH |
902 | efx_for_each_tx_queue(tx_queue, efx) { |
903 | if (!EFX_INT_MODE_USE_MSI(efx) && separate_tx_and_rx_channels) | |
904 | tx_queue->channel = &efx->channel[1]; | |
905 | else | |
906 | tx_queue->channel = &efx->channel[0]; | |
907 | tx_queue->channel->used_flags |= EFX_USED_BY_TX; | |
908 | } | |
8ceee660 | 909 | |
8831da7b BH |
910 | efx_for_each_rx_queue(rx_queue, efx) { |
911 | rx_queue->channel = &efx->channel[rx_queue->queue]; | |
912 | rx_queue->channel->used_flags |= EFX_USED_BY_RX; | |
8ceee660 BH |
913 | } |
914 | } | |
915 | ||
916 | static int efx_probe_nic(struct efx_nic *efx) | |
917 | { | |
918 | int rc; | |
919 | ||
920 | EFX_LOG(efx, "creating NIC\n"); | |
921 | ||
922 | /* Carry out hardware-type specific initialisation */ | |
923 | rc = falcon_probe_nic(efx); | |
924 | if (rc) | |
925 | return rc; | |
926 | ||
927 | /* Determine the number of channels and RX queues by trying to hook | |
928 | * in MSI-X interrupts. */ | |
929 | efx_probe_interrupts(efx); | |
930 | ||
8831da7b | 931 | efx_set_channels(efx); |
8ceee660 BH |
932 | |
933 | /* Initialise the interrupt moderation settings */ | |
934 | efx_init_irq_moderation(efx, tx_irq_mod_usec, rx_irq_mod_usec); | |
935 | ||
936 | return 0; | |
937 | } | |
938 | ||
939 | static void efx_remove_nic(struct efx_nic *efx) | |
940 | { | |
941 | EFX_LOG(efx, "destroying NIC\n"); | |
942 | ||
943 | efx_remove_interrupts(efx); | |
944 | falcon_remove_nic(efx); | |
945 | } | |
946 | ||
947 | /************************************************************************** | |
948 | * | |
949 | * NIC startup/shutdown | |
950 | * | |
951 | *************************************************************************/ | |
952 | ||
953 | static int efx_probe_all(struct efx_nic *efx) | |
954 | { | |
955 | struct efx_channel *channel; | |
956 | int rc; | |
957 | ||
958 | /* Create NIC */ | |
959 | rc = efx_probe_nic(efx); | |
960 | if (rc) { | |
961 | EFX_ERR(efx, "failed to create NIC\n"); | |
962 | goto fail1; | |
963 | } | |
964 | ||
965 | /* Create port */ | |
966 | rc = efx_probe_port(efx); | |
967 | if (rc) { | |
968 | EFX_ERR(efx, "failed to create port\n"); | |
969 | goto fail2; | |
970 | } | |
971 | ||
972 | /* Create channels */ | |
973 | efx_for_each_channel(channel, efx) { | |
974 | rc = efx_probe_channel(channel); | |
975 | if (rc) { | |
976 | EFX_ERR(efx, "failed to create channel %d\n", | |
977 | channel->channel); | |
978 | goto fail3; | |
979 | } | |
980 | } | |
981 | ||
982 | return 0; | |
983 | ||
984 | fail3: | |
985 | efx_for_each_channel(channel, efx) | |
986 | efx_remove_channel(channel); | |
987 | efx_remove_port(efx); | |
988 | fail2: | |
989 | efx_remove_nic(efx); | |
990 | fail1: | |
991 | return rc; | |
992 | } | |
993 | ||
994 | /* Called after previous invocation(s) of efx_stop_all, restarts the | |
995 | * port, kernel transmit queue, NAPI processing and hardware interrupts, | |
996 | * and ensures that the port is scheduled to be reconfigured. | |
997 | * This function is safe to call multiple times when the NIC is in any | |
998 | * state. */ | |
999 | static void efx_start_all(struct efx_nic *efx) | |
1000 | { | |
1001 | struct efx_channel *channel; | |
1002 | ||
1003 | EFX_ASSERT_RESET_SERIALISED(efx); | |
1004 | ||
1005 | /* Check that it is appropriate to restart the interface. All | |
1006 | * of these flags are safe to read under just the rtnl lock */ | |
1007 | if (efx->port_enabled) | |
1008 | return; | |
1009 | if ((efx->state != STATE_RUNNING) && (efx->state != STATE_INIT)) | |
1010 | return; | |
55668611 | 1011 | if (efx_dev_registered(efx) && !netif_running(efx->net_dev)) |
8ceee660 BH |
1012 | return; |
1013 | ||
1014 | /* Mark the port as enabled so port reconfigurations can start, then | |
1015 | * restart the transmit interface early so the watchdog timer stops */ | |
1016 | efx_start_port(efx); | |
dacccc74 SH |
1017 | if (efx_dev_registered(efx)) |
1018 | efx_wake_queue(efx); | |
8ceee660 BH |
1019 | |
1020 | efx_for_each_channel(channel, efx) | |
1021 | efx_start_channel(channel); | |
1022 | ||
1023 | falcon_enable_interrupts(efx); | |
1024 | ||
1025 | /* Start hardware monitor if we're in RUNNING */ | |
1026 | if (efx->state == STATE_RUNNING) | |
1027 | queue_delayed_work(efx->workqueue, &efx->monitor_work, | |
1028 | efx_monitor_interval); | |
1029 | } | |
1030 | ||
1031 | /* Flush all delayed work. Should only be called when no more delayed work | |
1032 | * will be scheduled. This doesn't flush pending online resets (efx_reset), | |
1033 | * since we're holding the rtnl_lock at this point. */ | |
1034 | static void efx_flush_all(struct efx_nic *efx) | |
1035 | { | |
1036 | struct efx_rx_queue *rx_queue; | |
1037 | ||
1038 | /* Make sure the hardware monitor is stopped */ | |
1039 | cancel_delayed_work_sync(&efx->monitor_work); | |
1040 | ||
1041 | /* Ensure that all RX slow refills are complete. */ | |
b3475645 | 1042 | efx_for_each_rx_queue(rx_queue, efx) |
8ceee660 | 1043 | cancel_delayed_work_sync(&rx_queue->work); |
8ceee660 BH |
1044 | |
1045 | /* Stop scheduled port reconfigurations */ | |
1046 | cancel_work_sync(&efx->reconfigure_work); | |
1047 | ||
1048 | } | |
1049 | ||
1050 | /* Quiesce hardware and software without bringing the link down. | |
1051 | * Safe to call multiple times, when the nic and interface is in any | |
1052 | * state. The caller is guaranteed to subsequently be in a position | |
1053 | * to modify any hardware and software state they see fit without | |
1054 | * taking locks. */ | |
1055 | static void efx_stop_all(struct efx_nic *efx) | |
1056 | { | |
1057 | struct efx_channel *channel; | |
1058 | ||
1059 | EFX_ASSERT_RESET_SERIALISED(efx); | |
1060 | ||
1061 | /* port_enabled can be read safely under the rtnl lock */ | |
1062 | if (!efx->port_enabled) | |
1063 | return; | |
1064 | ||
1065 | /* Disable interrupts and wait for ISR to complete */ | |
1066 | falcon_disable_interrupts(efx); | |
1067 | if (efx->legacy_irq) | |
1068 | synchronize_irq(efx->legacy_irq); | |
64ee3120 | 1069 | efx_for_each_channel(channel, efx) { |
8ceee660 BH |
1070 | if (channel->irq) |
1071 | synchronize_irq(channel->irq); | |
b3475645 | 1072 | } |
8ceee660 BH |
1073 | |
1074 | /* Stop all NAPI processing and synchronous rx refills */ | |
1075 | efx_for_each_channel(channel, efx) | |
1076 | efx_stop_channel(channel); | |
1077 | ||
1078 | /* Stop all asynchronous port reconfigurations. Since all | |
1079 | * event processing has already been stopped, there is no | |
1080 | * window to loose phy events */ | |
1081 | efx_stop_port(efx); | |
1082 | ||
1083 | /* Flush reconfigure_work, refill_workqueue, monitor_work */ | |
1084 | efx_flush_all(efx); | |
1085 | ||
1086 | /* Isolate the MAC from the TX and RX engines, so that queue | |
1087 | * flushes will complete in a timely fashion. */ | |
8ceee660 BH |
1088 | falcon_drain_tx_fifo(efx); |
1089 | ||
1090 | /* Stop the kernel transmit interface late, so the watchdog | |
1091 | * timer isn't ticking over the flush */ | |
55668611 | 1092 | if (efx_dev_registered(efx)) { |
dacccc74 | 1093 | efx_stop_queue(efx); |
8ceee660 BH |
1094 | netif_tx_lock_bh(efx->net_dev); |
1095 | netif_tx_unlock_bh(efx->net_dev); | |
1096 | } | |
1097 | } | |
1098 | ||
1099 | static void efx_remove_all(struct efx_nic *efx) | |
1100 | { | |
1101 | struct efx_channel *channel; | |
1102 | ||
1103 | efx_for_each_channel(channel, efx) | |
1104 | efx_remove_channel(channel); | |
1105 | efx_remove_port(efx); | |
1106 | efx_remove_nic(efx); | |
1107 | } | |
1108 | ||
1109 | /* A convinience function to safely flush all the queues */ | |
bc3c90a2 | 1110 | void efx_flush_queues(struct efx_nic *efx) |
8ceee660 | 1111 | { |
8ceee660 BH |
1112 | EFX_ASSERT_RESET_SERIALISED(efx); |
1113 | ||
1114 | efx_stop_all(efx); | |
1115 | ||
1116 | efx_fini_channels(efx); | |
bc3c90a2 | 1117 | efx_init_channels(efx); |
8ceee660 BH |
1118 | |
1119 | efx_start_all(efx); | |
8ceee660 BH |
1120 | } |
1121 | ||
1122 | /************************************************************************** | |
1123 | * | |
1124 | * Interrupt moderation | |
1125 | * | |
1126 | **************************************************************************/ | |
1127 | ||
1128 | /* Set interrupt moderation parameters */ | |
1129 | void efx_init_irq_moderation(struct efx_nic *efx, int tx_usecs, int rx_usecs) | |
1130 | { | |
1131 | struct efx_tx_queue *tx_queue; | |
1132 | struct efx_rx_queue *rx_queue; | |
1133 | ||
1134 | EFX_ASSERT_RESET_SERIALISED(efx); | |
1135 | ||
1136 | efx_for_each_tx_queue(tx_queue, efx) | |
1137 | tx_queue->channel->irq_moderation = tx_usecs; | |
1138 | ||
1139 | efx_for_each_rx_queue(rx_queue, efx) | |
1140 | rx_queue->channel->irq_moderation = rx_usecs; | |
1141 | } | |
1142 | ||
1143 | /************************************************************************** | |
1144 | * | |
1145 | * Hardware monitor | |
1146 | * | |
1147 | **************************************************************************/ | |
1148 | ||
1149 | /* Run periodically off the general workqueue. Serialised against | |
1150 | * efx_reconfigure_port via the mac_lock */ | |
1151 | static void efx_monitor(struct work_struct *data) | |
1152 | { | |
1153 | struct efx_nic *efx = container_of(data, struct efx_nic, | |
1154 | monitor_work.work); | |
1155 | int rc = 0; | |
1156 | ||
1157 | EFX_TRACE(efx, "hardware monitor executing on CPU %d\n", | |
1158 | raw_smp_processor_id()); | |
1159 | ||
1160 | ||
1161 | /* If the mac_lock is already held then it is likely a port | |
1162 | * reconfiguration is already in place, which will likely do | |
1163 | * most of the work of check_hw() anyway. */ | |
1164 | if (!mutex_trylock(&efx->mac_lock)) { | |
1165 | queue_delayed_work(efx->workqueue, &efx->monitor_work, | |
1166 | efx_monitor_interval); | |
1167 | return; | |
1168 | } | |
1169 | ||
1170 | if (efx->port_enabled) | |
1171 | rc = falcon_check_xmac(efx); | |
1172 | mutex_unlock(&efx->mac_lock); | |
1173 | ||
8ceee660 BH |
1174 | queue_delayed_work(efx->workqueue, &efx->monitor_work, |
1175 | efx_monitor_interval); | |
1176 | } | |
1177 | ||
1178 | /************************************************************************** | |
1179 | * | |
1180 | * ioctls | |
1181 | * | |
1182 | *************************************************************************/ | |
1183 | ||
1184 | /* Net device ioctl | |
1185 | * Context: process, rtnl_lock() held. | |
1186 | */ | |
1187 | static int efx_ioctl(struct net_device *net_dev, struct ifreq *ifr, int cmd) | |
1188 | { | |
767e468c | 1189 | struct efx_nic *efx = netdev_priv(net_dev); |
8ceee660 BH |
1190 | |
1191 | EFX_ASSERT_RESET_SERIALISED(efx); | |
1192 | ||
1193 | return generic_mii_ioctl(&efx->mii, if_mii(ifr), cmd, NULL); | |
1194 | } | |
1195 | ||
1196 | /************************************************************************** | |
1197 | * | |
1198 | * NAPI interface | |
1199 | * | |
1200 | **************************************************************************/ | |
1201 | ||
1202 | static int efx_init_napi(struct efx_nic *efx) | |
1203 | { | |
1204 | struct efx_channel *channel; | |
1205 | int rc; | |
1206 | ||
1207 | efx_for_each_channel(channel, efx) { | |
1208 | channel->napi_dev = efx->net_dev; | |
1209 | rc = efx_lro_init(&channel->lro_mgr, efx); | |
1210 | if (rc) | |
1211 | goto err; | |
1212 | } | |
1213 | return 0; | |
1214 | err: | |
1215 | efx_fini_napi(efx); | |
1216 | return rc; | |
1217 | } | |
1218 | ||
1219 | static void efx_fini_napi(struct efx_nic *efx) | |
1220 | { | |
1221 | struct efx_channel *channel; | |
1222 | ||
1223 | efx_for_each_channel(channel, efx) { | |
1224 | efx_lro_fini(&channel->lro_mgr); | |
1225 | channel->napi_dev = NULL; | |
1226 | } | |
1227 | } | |
1228 | ||
1229 | /************************************************************************** | |
1230 | * | |
1231 | * Kernel netpoll interface | |
1232 | * | |
1233 | *************************************************************************/ | |
1234 | ||
1235 | #ifdef CONFIG_NET_POLL_CONTROLLER | |
1236 | ||
1237 | /* Although in the common case interrupts will be disabled, this is not | |
1238 | * guaranteed. However, all our work happens inside the NAPI callback, | |
1239 | * so no locking is required. | |
1240 | */ | |
1241 | static void efx_netpoll(struct net_device *net_dev) | |
1242 | { | |
767e468c | 1243 | struct efx_nic *efx = netdev_priv(net_dev); |
8ceee660 BH |
1244 | struct efx_channel *channel; |
1245 | ||
64ee3120 | 1246 | efx_for_each_channel(channel, efx) |
8ceee660 BH |
1247 | efx_schedule_channel(channel); |
1248 | } | |
1249 | ||
1250 | #endif | |
1251 | ||
1252 | /************************************************************************** | |
1253 | * | |
1254 | * Kernel net device interface | |
1255 | * | |
1256 | *************************************************************************/ | |
1257 | ||
1258 | /* Context: process, rtnl_lock() held. */ | |
1259 | static int efx_net_open(struct net_device *net_dev) | |
1260 | { | |
767e468c | 1261 | struct efx_nic *efx = netdev_priv(net_dev); |
8ceee660 BH |
1262 | EFX_ASSERT_RESET_SERIALISED(efx); |
1263 | ||
1264 | EFX_LOG(efx, "opening device %s on CPU %d\n", net_dev->name, | |
1265 | raw_smp_processor_id()); | |
1266 | ||
f8b87c17 BH |
1267 | if (efx->phy_mode & PHY_MODE_SPECIAL) |
1268 | return -EBUSY; | |
1269 | ||
8ceee660 BH |
1270 | efx_start_all(efx); |
1271 | return 0; | |
1272 | } | |
1273 | ||
1274 | /* Context: process, rtnl_lock() held. | |
1275 | * Note that the kernel will ignore our return code; this method | |
1276 | * should really be a void. | |
1277 | */ | |
1278 | static int efx_net_stop(struct net_device *net_dev) | |
1279 | { | |
767e468c | 1280 | struct efx_nic *efx = netdev_priv(net_dev); |
8ceee660 BH |
1281 | |
1282 | EFX_LOG(efx, "closing %s on CPU %d\n", net_dev->name, | |
1283 | raw_smp_processor_id()); | |
1284 | ||
1285 | /* Stop the device and flush all the channels */ | |
1286 | efx_stop_all(efx); | |
1287 | efx_fini_channels(efx); | |
bc3c90a2 | 1288 | efx_init_channels(efx); |
8ceee660 BH |
1289 | |
1290 | return 0; | |
1291 | } | |
1292 | ||
5b9e207c | 1293 | /* Context: process, dev_base_lock or RTNL held, non-blocking. */ |
8ceee660 BH |
1294 | static struct net_device_stats *efx_net_stats(struct net_device *net_dev) |
1295 | { | |
767e468c | 1296 | struct efx_nic *efx = netdev_priv(net_dev); |
8ceee660 BH |
1297 | struct efx_mac_stats *mac_stats = &efx->mac_stats; |
1298 | struct net_device_stats *stats = &net_dev->stats; | |
1299 | ||
5b9e207c BH |
1300 | /* Update stats if possible, but do not wait if another thread |
1301 | * is updating them (or resetting the NIC); slightly stale | |
1302 | * stats are acceptable. | |
1303 | */ | |
8ceee660 BH |
1304 | if (!spin_trylock(&efx->stats_lock)) |
1305 | return stats; | |
8c8661e4 | 1306 | if (efx->stats_enabled) { |
8ceee660 BH |
1307 | falcon_update_stats_xmac(efx); |
1308 | falcon_update_nic_stats(efx); | |
1309 | } | |
1310 | spin_unlock(&efx->stats_lock); | |
1311 | ||
1312 | stats->rx_packets = mac_stats->rx_packets; | |
1313 | stats->tx_packets = mac_stats->tx_packets; | |
1314 | stats->rx_bytes = mac_stats->rx_bytes; | |
1315 | stats->tx_bytes = mac_stats->tx_bytes; | |
1316 | stats->multicast = mac_stats->rx_multicast; | |
1317 | stats->collisions = mac_stats->tx_collision; | |
1318 | stats->rx_length_errors = (mac_stats->rx_gtjumbo + | |
1319 | mac_stats->rx_length_error); | |
1320 | stats->rx_over_errors = efx->n_rx_nodesc_drop_cnt; | |
1321 | stats->rx_crc_errors = mac_stats->rx_bad; | |
1322 | stats->rx_frame_errors = mac_stats->rx_align_error; | |
1323 | stats->rx_fifo_errors = mac_stats->rx_overflow; | |
1324 | stats->rx_missed_errors = mac_stats->rx_missed; | |
1325 | stats->tx_window_errors = mac_stats->tx_late_collision; | |
1326 | ||
1327 | stats->rx_errors = (stats->rx_length_errors + | |
1328 | stats->rx_over_errors + | |
1329 | stats->rx_crc_errors + | |
1330 | stats->rx_frame_errors + | |
1331 | stats->rx_fifo_errors + | |
1332 | stats->rx_missed_errors + | |
1333 | mac_stats->rx_symbol_error); | |
1334 | stats->tx_errors = (stats->tx_window_errors + | |
1335 | mac_stats->tx_bad); | |
1336 | ||
1337 | return stats; | |
1338 | } | |
1339 | ||
1340 | /* Context: netif_tx_lock held, BHs disabled. */ | |
1341 | static void efx_watchdog(struct net_device *net_dev) | |
1342 | { | |
767e468c | 1343 | struct efx_nic *efx = netdev_priv(net_dev); |
8ceee660 | 1344 | |
739bb23d BH |
1345 | EFX_ERR(efx, "TX stuck with stop_count=%d port_enabled=%d:" |
1346 | " resetting channels\n", | |
1347 | atomic_read(&efx->netif_stop_count), efx->port_enabled); | |
8ceee660 | 1348 | |
739bb23d | 1349 | efx_schedule_reset(efx, RESET_TYPE_TX_WATCHDOG); |
8ceee660 BH |
1350 | } |
1351 | ||
1352 | ||
1353 | /* Context: process, rtnl_lock() held. */ | |
1354 | static int efx_change_mtu(struct net_device *net_dev, int new_mtu) | |
1355 | { | |
767e468c | 1356 | struct efx_nic *efx = netdev_priv(net_dev); |
8ceee660 BH |
1357 | int rc = 0; |
1358 | ||
1359 | EFX_ASSERT_RESET_SERIALISED(efx); | |
1360 | ||
1361 | if (new_mtu > EFX_MAX_MTU) | |
1362 | return -EINVAL; | |
1363 | ||
1364 | efx_stop_all(efx); | |
1365 | ||
1366 | EFX_LOG(efx, "changing MTU to %d\n", new_mtu); | |
1367 | ||
1368 | efx_fini_channels(efx); | |
1369 | net_dev->mtu = new_mtu; | |
bc3c90a2 | 1370 | efx_init_channels(efx); |
8ceee660 BH |
1371 | |
1372 | efx_start_all(efx); | |
1373 | return rc; | |
8ceee660 BH |
1374 | } |
1375 | ||
1376 | static int efx_set_mac_address(struct net_device *net_dev, void *data) | |
1377 | { | |
767e468c | 1378 | struct efx_nic *efx = netdev_priv(net_dev); |
8ceee660 BH |
1379 | struct sockaddr *addr = data; |
1380 | char *new_addr = addr->sa_data; | |
1381 | ||
1382 | EFX_ASSERT_RESET_SERIALISED(efx); | |
1383 | ||
1384 | if (!is_valid_ether_addr(new_addr)) { | |
e174961c JB |
1385 | EFX_ERR(efx, "invalid ethernet MAC address requested: %pM\n", |
1386 | new_addr); | |
8ceee660 BH |
1387 | return -EINVAL; |
1388 | } | |
1389 | ||
1390 | memcpy(net_dev->dev_addr, new_addr, net_dev->addr_len); | |
1391 | ||
1392 | /* Reconfigure the MAC */ | |
1393 | efx_reconfigure_port(efx); | |
1394 | ||
1395 | return 0; | |
1396 | } | |
1397 | ||
a816f75a | 1398 | /* Context: netif_addr_lock held, BHs disabled. */ |
8ceee660 BH |
1399 | static void efx_set_multicast_list(struct net_device *net_dev) |
1400 | { | |
767e468c | 1401 | struct efx_nic *efx = netdev_priv(net_dev); |
8ceee660 BH |
1402 | struct dev_mc_list *mc_list = net_dev->mc_list; |
1403 | union efx_multicast_hash *mc_hash = &efx->multicast_hash; | |
a816f75a BH |
1404 | bool promiscuous = !!(net_dev->flags & IFF_PROMISC); |
1405 | bool changed = (efx->promiscuous != promiscuous); | |
8ceee660 BH |
1406 | u32 crc; |
1407 | int bit; | |
1408 | int i; | |
1409 | ||
a816f75a | 1410 | efx->promiscuous = promiscuous; |
8ceee660 BH |
1411 | |
1412 | /* Build multicast hash table */ | |
1413 | if (promiscuous || (net_dev->flags & IFF_ALLMULTI)) { | |
1414 | memset(mc_hash, 0xff, sizeof(*mc_hash)); | |
1415 | } else { | |
1416 | memset(mc_hash, 0x00, sizeof(*mc_hash)); | |
1417 | for (i = 0; i < net_dev->mc_count; i++) { | |
1418 | crc = ether_crc_le(ETH_ALEN, mc_list->dmi_addr); | |
1419 | bit = crc & (EFX_MCAST_HASH_ENTRIES - 1); | |
1420 | set_bit_le(bit, mc_hash->byte); | |
1421 | mc_list = mc_list->next; | |
1422 | } | |
1423 | } | |
1424 | ||
a816f75a BH |
1425 | if (!efx->port_enabled) |
1426 | /* Delay pushing settings until efx_start_port() */ | |
1427 | return; | |
1428 | ||
1429 | if (changed) | |
1430 | queue_work(efx->workqueue, &efx->reconfigure_work); | |
1431 | ||
8ceee660 BH |
1432 | /* Create and activate new global multicast hash table */ |
1433 | falcon_set_multicast_hash(efx); | |
1434 | } | |
1435 | ||
c3ecb9f3 SH |
1436 | static const struct net_device_ops efx_netdev_ops = { |
1437 | .ndo_open = efx_net_open, | |
1438 | .ndo_stop = efx_net_stop, | |
1439 | .ndo_get_stats = efx_net_stats, | |
1440 | .ndo_tx_timeout = efx_watchdog, | |
1441 | .ndo_start_xmit = efx_hard_start_xmit, | |
1442 | .ndo_validate_addr = eth_validate_addr, | |
1443 | .ndo_do_ioctl = efx_ioctl, | |
1444 | .ndo_change_mtu = efx_change_mtu, | |
1445 | .ndo_set_mac_address = efx_set_mac_address, | |
1446 | .ndo_set_multicast_list = efx_set_multicast_list, | |
1447 | #ifdef CONFIG_NET_POLL_CONTROLLER | |
1448 | .ndo_poll_controller = efx_netpoll, | |
1449 | #endif | |
1450 | }; | |
1451 | ||
8ceee660 BH |
1452 | static int efx_netdev_event(struct notifier_block *this, |
1453 | unsigned long event, void *ptr) | |
1454 | { | |
d3208b5e | 1455 | struct net_device *net_dev = ptr; |
8ceee660 | 1456 | |
c3ecb9f3 | 1457 | if (net_dev->netdev_ops == &efx_netdev_ops && event == NETDEV_CHANGENAME) { |
767e468c | 1458 | struct efx_nic *efx = netdev_priv(net_dev); |
8ceee660 BH |
1459 | |
1460 | strcpy(efx->name, net_dev->name); | |
f4150724 | 1461 | efx_mtd_rename(efx); |
8ceee660 BH |
1462 | } |
1463 | ||
1464 | return NOTIFY_DONE; | |
1465 | } | |
1466 | ||
1467 | static struct notifier_block efx_netdev_notifier = { | |
1468 | .notifier_call = efx_netdev_event, | |
1469 | }; | |
1470 | ||
1471 | static int efx_register_netdev(struct efx_nic *efx) | |
1472 | { | |
1473 | struct net_device *net_dev = efx->net_dev; | |
1474 | int rc; | |
1475 | ||
1476 | net_dev->watchdog_timeo = 5 * HZ; | |
1477 | net_dev->irq = efx->pci_dev->irq; | |
c3ecb9f3 | 1478 | net_dev->netdev_ops = &efx_netdev_ops; |
8ceee660 BH |
1479 | SET_NETDEV_DEV(net_dev, &efx->pci_dev->dev); |
1480 | SET_ETHTOOL_OPS(net_dev, &efx_ethtool_ops); | |
1481 | ||
1482 | /* Always start with carrier off; PHY events will detect the link */ | |
1483 | netif_carrier_off(efx->net_dev); | |
1484 | ||
1485 | /* Clear MAC statistics */ | |
1486 | falcon_update_stats_xmac(efx); | |
1487 | memset(&efx->mac_stats, 0, sizeof(efx->mac_stats)); | |
1488 | ||
1489 | rc = register_netdev(net_dev); | |
1490 | if (rc) { | |
1491 | EFX_ERR(efx, "could not register net dev\n"); | |
1492 | return rc; | |
1493 | } | |
1494 | strcpy(efx->name, net_dev->name); | |
1495 | ||
1496 | return 0; | |
1497 | } | |
1498 | ||
1499 | static void efx_unregister_netdev(struct efx_nic *efx) | |
1500 | { | |
1501 | struct efx_tx_queue *tx_queue; | |
1502 | ||
1503 | if (!efx->net_dev) | |
1504 | return; | |
1505 | ||
767e468c | 1506 | BUG_ON(netdev_priv(efx->net_dev) != efx); |
8ceee660 BH |
1507 | |
1508 | /* Free up any skbs still remaining. This has to happen before | |
1509 | * we try to unregister the netdev as running their destructors | |
1510 | * may be needed to get the device ref. count to 0. */ | |
1511 | efx_for_each_tx_queue(tx_queue, efx) | |
1512 | efx_release_tx_buffers(tx_queue); | |
1513 | ||
55668611 | 1514 | if (efx_dev_registered(efx)) { |
8ceee660 BH |
1515 | strlcpy(efx->name, pci_name(efx->pci_dev), sizeof(efx->name)); |
1516 | unregister_netdev(efx->net_dev); | |
1517 | } | |
1518 | } | |
1519 | ||
1520 | /************************************************************************** | |
1521 | * | |
1522 | * Device reset and suspend | |
1523 | * | |
1524 | **************************************************************************/ | |
1525 | ||
2467ca46 BH |
1526 | /* Tears down the entire software state and most of the hardware state |
1527 | * before reset. */ | |
8c8661e4 | 1528 | void efx_reset_down(struct efx_nic *efx, struct ethtool_cmd *ecmd) |
8ceee660 BH |
1529 | { |
1530 | int rc; | |
1531 | ||
1532 | EFX_ASSERT_RESET_SERIALISED(efx); | |
1533 | ||
2467ca46 BH |
1534 | /* The net_dev->get_stats handler is quite slow, and will fail |
1535 | * if a fetch is pending over reset. Serialise against it. */ | |
1536 | spin_lock(&efx->stats_lock); | |
8c8661e4 | 1537 | efx->stats_enabled = false; |
2467ca46 BH |
1538 | spin_unlock(&efx->stats_lock); |
1539 | ||
1540 | efx_stop_all(efx); | |
1541 | mutex_lock(&efx->mac_lock); | |
f4150724 | 1542 | mutex_lock(&efx->spi_lock); |
2467ca46 | 1543 | |
8ceee660 | 1544 | rc = falcon_xmac_get_settings(efx, ecmd); |
2467ca46 | 1545 | if (rc) |
8ceee660 | 1546 | EFX_ERR(efx, "could not back up PHY settings\n"); |
8ceee660 BH |
1547 | |
1548 | efx_fini_channels(efx); | |
8ceee660 BH |
1549 | } |
1550 | ||
2467ca46 BH |
1551 | /* This function will always ensure that the locks acquired in |
1552 | * efx_reset_down() are released. A failure return code indicates | |
1553 | * that we were unable to reinitialise the hardware, and the | |
1554 | * driver should be disabled. If ok is false, then the rx and tx | |
1555 | * engines are not restarted, pending a RESET_DISABLE. */ | |
8c8661e4 | 1556 | int efx_reset_up(struct efx_nic *efx, struct ethtool_cmd *ecmd, bool ok) |
8ceee660 BH |
1557 | { |
1558 | int rc; | |
1559 | ||
2467ca46 | 1560 | EFX_ASSERT_RESET_SERIALISED(efx); |
8ceee660 | 1561 | |
2467ca46 | 1562 | rc = falcon_init_nic(efx); |
8ceee660 | 1563 | if (rc) { |
2467ca46 BH |
1564 | EFX_ERR(efx, "failed to initialise NIC\n"); |
1565 | ok = false; | |
8ceee660 BH |
1566 | } |
1567 | ||
2467ca46 BH |
1568 | if (ok) { |
1569 | efx_init_channels(efx); | |
8ceee660 | 1570 | |
2467ca46 BH |
1571 | if (falcon_xmac_set_settings(efx, ecmd)) |
1572 | EFX_ERR(efx, "could not restore PHY settings\n"); | |
1573 | } | |
1574 | ||
f4150724 | 1575 | mutex_unlock(&efx->spi_lock); |
2467ca46 BH |
1576 | mutex_unlock(&efx->mac_lock); |
1577 | ||
8c8661e4 | 1578 | if (ok) { |
2467ca46 | 1579 | efx_start_all(efx); |
8c8661e4 BH |
1580 | efx->stats_enabled = true; |
1581 | } | |
8ceee660 BH |
1582 | return rc; |
1583 | } | |
1584 | ||
1585 | /* Reset the NIC as transparently as possible. Do not reset the PHY | |
1586 | * Note that the reset may fail, in which case the card will be left | |
1587 | * in a most-probably-unusable state. | |
1588 | * | |
1589 | * This function will sleep. You cannot reset from within an atomic | |
1590 | * state; use efx_schedule_reset() instead. | |
1591 | * | |
1592 | * Grabs the rtnl_lock. | |
1593 | */ | |
1594 | static int efx_reset(struct efx_nic *efx) | |
1595 | { | |
1596 | struct ethtool_cmd ecmd; | |
1597 | enum reset_type method = efx->reset_pending; | |
1598 | int rc; | |
1599 | ||
1600 | /* Serialise with kernel interfaces */ | |
1601 | rtnl_lock(); | |
1602 | ||
1603 | /* If we're not RUNNING then don't reset. Leave the reset_pending | |
1604 | * flag set so that efx_pci_probe_main will be retried */ | |
1605 | if (efx->state != STATE_RUNNING) { | |
1606 | EFX_INFO(efx, "scheduled reset quenched. NIC not RUNNING\n"); | |
1607 | goto unlock_rtnl; | |
1608 | } | |
1609 | ||
8ceee660 BH |
1610 | EFX_INFO(efx, "resetting (%d)\n", method); |
1611 | ||
2467ca46 | 1612 | efx_reset_down(efx, &ecmd); |
8ceee660 BH |
1613 | |
1614 | rc = falcon_reset_hw(efx, method); | |
1615 | if (rc) { | |
1616 | EFX_ERR(efx, "failed to reset hardware\n"); | |
2467ca46 | 1617 | goto fail; |
8ceee660 BH |
1618 | } |
1619 | ||
1620 | /* Allow resets to be rescheduled. */ | |
1621 | efx->reset_pending = RESET_TYPE_NONE; | |
1622 | ||
1623 | /* Reinitialise bus-mastering, which may have been turned off before | |
1624 | * the reset was scheduled. This is still appropriate, even in the | |
1625 | * RESET_TYPE_DISABLE since this driver generally assumes the hardware | |
1626 | * can respond to requests. */ | |
1627 | pci_set_master(efx->pci_dev); | |
1628 | ||
8ceee660 BH |
1629 | /* Leave device stopped if necessary */ |
1630 | if (method == RESET_TYPE_DISABLE) { | |
8ceee660 | 1631 | rc = -EIO; |
2467ca46 | 1632 | goto fail; |
8ceee660 BH |
1633 | } |
1634 | ||
2467ca46 | 1635 | rc = efx_reset_up(efx, &ecmd, true); |
8ceee660 | 1636 | if (rc) |
2467ca46 | 1637 | goto disable; |
8ceee660 | 1638 | |
8ceee660 | 1639 | EFX_LOG(efx, "reset complete\n"); |
8ceee660 BH |
1640 | unlock_rtnl: |
1641 | rtnl_unlock(); | |
1642 | return 0; | |
1643 | ||
2467ca46 BH |
1644 | fail: |
1645 | efx_reset_up(efx, &ecmd, false); | |
1646 | disable: | |
8ceee660 BH |
1647 | EFX_ERR(efx, "has been disabled\n"); |
1648 | efx->state = STATE_DISABLED; | |
1649 | ||
8ceee660 BH |
1650 | rtnl_unlock(); |
1651 | efx_unregister_netdev(efx); | |
1652 | efx_fini_port(efx); | |
1653 | return rc; | |
1654 | } | |
1655 | ||
1656 | /* The worker thread exists so that code that cannot sleep can | |
1657 | * schedule a reset for later. | |
1658 | */ | |
1659 | static void efx_reset_work(struct work_struct *data) | |
1660 | { | |
1661 | struct efx_nic *nic = container_of(data, struct efx_nic, reset_work); | |
1662 | ||
1663 | efx_reset(nic); | |
1664 | } | |
1665 | ||
1666 | void efx_schedule_reset(struct efx_nic *efx, enum reset_type type) | |
1667 | { | |
1668 | enum reset_type method; | |
1669 | ||
1670 | if (efx->reset_pending != RESET_TYPE_NONE) { | |
1671 | EFX_INFO(efx, "quenching already scheduled reset\n"); | |
1672 | return; | |
1673 | } | |
1674 | ||
1675 | switch (type) { | |
1676 | case RESET_TYPE_INVISIBLE: | |
1677 | case RESET_TYPE_ALL: | |
1678 | case RESET_TYPE_WORLD: | |
1679 | case RESET_TYPE_DISABLE: | |
1680 | method = type; | |
1681 | break; | |
1682 | case RESET_TYPE_RX_RECOVERY: | |
1683 | case RESET_TYPE_RX_DESC_FETCH: | |
1684 | case RESET_TYPE_TX_DESC_FETCH: | |
1685 | case RESET_TYPE_TX_SKIP: | |
1686 | method = RESET_TYPE_INVISIBLE; | |
1687 | break; | |
1688 | default: | |
1689 | method = RESET_TYPE_ALL; | |
1690 | break; | |
1691 | } | |
1692 | ||
1693 | if (method != type) | |
1694 | EFX_LOG(efx, "scheduling reset (%d:%d)\n", type, method); | |
1695 | else | |
1696 | EFX_LOG(efx, "scheduling reset (%d)\n", method); | |
1697 | ||
1698 | efx->reset_pending = method; | |
1699 | ||
8d9853d9 | 1700 | queue_work(efx->reset_workqueue, &efx->reset_work); |
8ceee660 BH |
1701 | } |
1702 | ||
1703 | /************************************************************************** | |
1704 | * | |
1705 | * List of NICs we support | |
1706 | * | |
1707 | **************************************************************************/ | |
1708 | ||
1709 | /* PCI device ID table */ | |
1710 | static struct pci_device_id efx_pci_table[] __devinitdata = { | |
1711 | {PCI_DEVICE(EFX_VENDID_SFC, FALCON_A_P_DEVID), | |
1712 | .driver_data = (unsigned long) &falcon_a_nic_type}, | |
1713 | {PCI_DEVICE(EFX_VENDID_SFC, FALCON_B_P_DEVID), | |
1714 | .driver_data = (unsigned long) &falcon_b_nic_type}, | |
1715 | {0} /* end of list */ | |
1716 | }; | |
1717 | ||
1718 | /************************************************************************** | |
1719 | * | |
1720 | * Dummy PHY/MAC/Board operations | |
1721 | * | |
01aad7b6 | 1722 | * Can be used for some unimplemented operations |
8ceee660 BH |
1723 | * Needed so all function pointers are valid and do not have to be tested |
1724 | * before use | |
1725 | * | |
1726 | **************************************************************************/ | |
1727 | int efx_port_dummy_op_int(struct efx_nic *efx) | |
1728 | { | |
1729 | return 0; | |
1730 | } | |
1731 | void efx_port_dummy_op_void(struct efx_nic *efx) {} | |
dc8cfa55 | 1732 | void efx_port_dummy_op_blink(struct efx_nic *efx, bool blink) {} |
8ceee660 BH |
1733 | |
1734 | static struct efx_phy_operations efx_dummy_phy_operations = { | |
1735 | .init = efx_port_dummy_op_int, | |
1736 | .reconfigure = efx_port_dummy_op_void, | |
1737 | .check_hw = efx_port_dummy_op_int, | |
1738 | .fini = efx_port_dummy_op_void, | |
1739 | .clear_interrupt = efx_port_dummy_op_void, | |
8ceee660 BH |
1740 | }; |
1741 | ||
8ceee660 | 1742 | static struct efx_board efx_dummy_board_info = { |
01aad7b6 BH |
1743 | .init = efx_port_dummy_op_int, |
1744 | .init_leds = efx_port_dummy_op_int, | |
1745 | .set_fault_led = efx_port_dummy_op_blink, | |
a17102b1 | 1746 | .monitor = efx_port_dummy_op_int, |
01aad7b6 BH |
1747 | .blink = efx_port_dummy_op_blink, |
1748 | .fini = efx_port_dummy_op_void, | |
8ceee660 BH |
1749 | }; |
1750 | ||
1751 | /************************************************************************** | |
1752 | * | |
1753 | * Data housekeeping | |
1754 | * | |
1755 | **************************************************************************/ | |
1756 | ||
1757 | /* This zeroes out and then fills in the invariants in a struct | |
1758 | * efx_nic (including all sub-structures). | |
1759 | */ | |
1760 | static int efx_init_struct(struct efx_nic *efx, struct efx_nic_type *type, | |
1761 | struct pci_dev *pci_dev, struct net_device *net_dev) | |
1762 | { | |
1763 | struct efx_channel *channel; | |
1764 | struct efx_tx_queue *tx_queue; | |
1765 | struct efx_rx_queue *rx_queue; | |
1766 | int i, rc; | |
1767 | ||
1768 | /* Initialise common structures */ | |
1769 | memset(efx, 0, sizeof(*efx)); | |
1770 | spin_lock_init(&efx->biu_lock); | |
1771 | spin_lock_init(&efx->phy_lock); | |
f4150724 | 1772 | mutex_init(&efx->spi_lock); |
8ceee660 BH |
1773 | INIT_WORK(&efx->reset_work, efx_reset_work); |
1774 | INIT_DELAYED_WORK(&efx->monitor_work, efx_monitor); | |
1775 | efx->pci_dev = pci_dev; | |
1776 | efx->state = STATE_INIT; | |
1777 | efx->reset_pending = RESET_TYPE_NONE; | |
1778 | strlcpy(efx->name, pci_name(pci_dev), sizeof(efx->name)); | |
1779 | efx->board_info = efx_dummy_board_info; | |
1780 | ||
1781 | efx->net_dev = net_dev; | |
dc8cfa55 | 1782 | efx->rx_checksum_enabled = true; |
8ceee660 BH |
1783 | spin_lock_init(&efx->netif_stop_lock); |
1784 | spin_lock_init(&efx->stats_lock); | |
1785 | mutex_init(&efx->mac_lock); | |
1786 | efx->phy_op = &efx_dummy_phy_operations; | |
1787 | efx->mii.dev = net_dev; | |
1788 | INIT_WORK(&efx->reconfigure_work, efx_reconfigure_work); | |
1789 | atomic_set(&efx->netif_stop_count, 1); | |
1790 | ||
1791 | for (i = 0; i < EFX_MAX_CHANNELS; i++) { | |
1792 | channel = &efx->channel[i]; | |
1793 | channel->efx = efx; | |
1794 | channel->channel = i; | |
dc8cfa55 | 1795 | channel->work_pending = false; |
8ceee660 | 1796 | } |
60ac1065 | 1797 | for (i = 0; i < EFX_TX_QUEUE_COUNT; i++) { |
8ceee660 BH |
1798 | tx_queue = &efx->tx_queue[i]; |
1799 | tx_queue->efx = efx; | |
1800 | tx_queue->queue = i; | |
1801 | tx_queue->buffer = NULL; | |
1802 | tx_queue->channel = &efx->channel[0]; /* for safety */ | |
b9b39b62 | 1803 | tx_queue->tso_headers_free = NULL; |
8ceee660 BH |
1804 | } |
1805 | for (i = 0; i < EFX_MAX_RX_QUEUES; i++) { | |
1806 | rx_queue = &efx->rx_queue[i]; | |
1807 | rx_queue->efx = efx; | |
1808 | rx_queue->queue = i; | |
1809 | rx_queue->channel = &efx->channel[0]; /* for safety */ | |
1810 | rx_queue->buffer = NULL; | |
1811 | spin_lock_init(&rx_queue->add_lock); | |
1812 | INIT_DELAYED_WORK(&rx_queue->work, efx_rx_work); | |
1813 | } | |
1814 | ||
1815 | efx->type = type; | |
1816 | ||
1817 | /* Sanity-check NIC type */ | |
1818 | EFX_BUG_ON_PARANOID(efx->type->txd_ring_mask & | |
1819 | (efx->type->txd_ring_mask + 1)); | |
1820 | EFX_BUG_ON_PARANOID(efx->type->rxd_ring_mask & | |
1821 | (efx->type->rxd_ring_mask + 1)); | |
1822 | EFX_BUG_ON_PARANOID(efx->type->evq_size & | |
1823 | (efx->type->evq_size - 1)); | |
1824 | /* As close as we can get to guaranteeing that we don't overflow */ | |
1825 | EFX_BUG_ON_PARANOID(efx->type->evq_size < | |
1826 | (efx->type->txd_ring_mask + 1 + | |
1827 | efx->type->rxd_ring_mask + 1)); | |
1828 | EFX_BUG_ON_PARANOID(efx->type->phys_addr_channels > EFX_MAX_CHANNELS); | |
1829 | ||
1830 | /* Higher numbered interrupt modes are less capable! */ | |
1831 | efx->interrupt_mode = max(efx->type->max_interrupt_mode, | |
1832 | interrupt_mode); | |
1833 | ||
1834 | efx->workqueue = create_singlethread_workqueue("sfc_work"); | |
1835 | if (!efx->workqueue) { | |
1836 | rc = -ENOMEM; | |
1837 | goto fail1; | |
1838 | } | |
1839 | ||
8d9853d9 BH |
1840 | efx->reset_workqueue = create_singlethread_workqueue("sfc_reset"); |
1841 | if (!efx->reset_workqueue) { | |
1842 | rc = -ENOMEM; | |
1843 | goto fail2; | |
1844 | } | |
1845 | ||
8ceee660 BH |
1846 | return 0; |
1847 | ||
8d9853d9 BH |
1848 | fail2: |
1849 | destroy_workqueue(efx->workqueue); | |
1850 | efx->workqueue = NULL; | |
1851 | ||
8ceee660 BH |
1852 | fail1: |
1853 | return rc; | |
1854 | } | |
1855 | ||
1856 | static void efx_fini_struct(struct efx_nic *efx) | |
1857 | { | |
8d9853d9 BH |
1858 | if (efx->reset_workqueue) { |
1859 | destroy_workqueue(efx->reset_workqueue); | |
1860 | efx->reset_workqueue = NULL; | |
1861 | } | |
8ceee660 BH |
1862 | if (efx->workqueue) { |
1863 | destroy_workqueue(efx->workqueue); | |
1864 | efx->workqueue = NULL; | |
1865 | } | |
1866 | } | |
1867 | ||
1868 | /************************************************************************** | |
1869 | * | |
1870 | * PCI interface | |
1871 | * | |
1872 | **************************************************************************/ | |
1873 | ||
1874 | /* Main body of final NIC shutdown code | |
1875 | * This is called only at module unload (or hotplug removal). | |
1876 | */ | |
1877 | static void efx_pci_remove_main(struct efx_nic *efx) | |
1878 | { | |
1879 | EFX_ASSERT_RESET_SERIALISED(efx); | |
1880 | ||
1881 | /* Skip everything if we never obtained a valid membase */ | |
1882 | if (!efx->membase) | |
1883 | return; | |
1884 | ||
1885 | efx_fini_channels(efx); | |
1886 | efx_fini_port(efx); | |
1887 | ||
1888 | /* Shutdown the board, then the NIC and board state */ | |
37b5a603 | 1889 | efx->board_info.fini(efx); |
8ceee660 BH |
1890 | falcon_fini_interrupt(efx); |
1891 | ||
1892 | efx_fini_napi(efx); | |
1893 | efx_remove_all(efx); | |
1894 | } | |
1895 | ||
1896 | /* Final NIC shutdown | |
1897 | * This is called only at module unload (or hotplug removal). | |
1898 | */ | |
1899 | static void efx_pci_remove(struct pci_dev *pci_dev) | |
1900 | { | |
1901 | struct efx_nic *efx; | |
1902 | ||
1903 | efx = pci_get_drvdata(pci_dev); | |
1904 | if (!efx) | |
1905 | return; | |
1906 | ||
f4150724 BH |
1907 | efx_mtd_remove(efx); |
1908 | ||
8ceee660 BH |
1909 | /* Mark the NIC as fini, then stop the interface */ |
1910 | rtnl_lock(); | |
1911 | efx->state = STATE_FINI; | |
1912 | dev_close(efx->net_dev); | |
1913 | ||
1914 | /* Allow any queued efx_resets() to complete */ | |
1915 | rtnl_unlock(); | |
1916 | ||
1917 | if (efx->membase == NULL) | |
1918 | goto out; | |
1919 | ||
1920 | efx_unregister_netdev(efx); | |
1921 | ||
1922 | /* Wait for any scheduled resets to complete. No more will be | |
1923 | * scheduled from this point because efx_stop_all() has been | |
1924 | * called, we are no longer registered with driverlink, and | |
1925 | * the net_device's have been removed. */ | |
8d9853d9 | 1926 | flush_workqueue(efx->reset_workqueue); |
8ceee660 BH |
1927 | |
1928 | efx_pci_remove_main(efx); | |
1929 | ||
1930 | out: | |
1931 | efx_fini_io(efx); | |
1932 | EFX_LOG(efx, "shutdown successful\n"); | |
1933 | ||
1934 | pci_set_drvdata(pci_dev, NULL); | |
1935 | efx_fini_struct(efx); | |
1936 | free_netdev(efx->net_dev); | |
1937 | }; | |
1938 | ||
1939 | /* Main body of NIC initialisation | |
1940 | * This is called at module load (or hotplug insertion, theoretically). | |
1941 | */ | |
1942 | static int efx_pci_probe_main(struct efx_nic *efx) | |
1943 | { | |
1944 | int rc; | |
1945 | ||
1946 | /* Do start-of-day initialisation */ | |
1947 | rc = efx_probe_all(efx); | |
1948 | if (rc) | |
1949 | goto fail1; | |
1950 | ||
1951 | rc = efx_init_napi(efx); | |
1952 | if (rc) | |
1953 | goto fail2; | |
1954 | ||
1955 | /* Initialise the board */ | |
1956 | rc = efx->board_info.init(efx); | |
1957 | if (rc) { | |
1958 | EFX_ERR(efx, "failed to initialise board\n"); | |
1959 | goto fail3; | |
1960 | } | |
1961 | ||
1962 | rc = falcon_init_nic(efx); | |
1963 | if (rc) { | |
1964 | EFX_ERR(efx, "failed to initialise NIC\n"); | |
1965 | goto fail4; | |
1966 | } | |
1967 | ||
1968 | rc = efx_init_port(efx); | |
1969 | if (rc) { | |
1970 | EFX_ERR(efx, "failed to initialise port\n"); | |
1971 | goto fail5; | |
1972 | } | |
1973 | ||
bc3c90a2 | 1974 | efx_init_channels(efx); |
8ceee660 BH |
1975 | |
1976 | rc = falcon_init_interrupt(efx); | |
1977 | if (rc) | |
bc3c90a2 | 1978 | goto fail6; |
8ceee660 BH |
1979 | |
1980 | return 0; | |
1981 | ||
8ceee660 | 1982 | fail6: |
bc3c90a2 | 1983 | efx_fini_channels(efx); |
8ceee660 BH |
1984 | efx_fini_port(efx); |
1985 | fail5: | |
1986 | fail4: | |
a17102b1 | 1987 | efx->board_info.fini(efx); |
8ceee660 BH |
1988 | fail3: |
1989 | efx_fini_napi(efx); | |
1990 | fail2: | |
1991 | efx_remove_all(efx); | |
1992 | fail1: | |
1993 | return rc; | |
1994 | } | |
1995 | ||
1996 | /* NIC initialisation | |
1997 | * | |
1998 | * This is called at module load (or hotplug insertion, | |
1999 | * theoretically). It sets up PCI mappings, tests and resets the NIC, | |
2000 | * sets up and registers the network devices with the kernel and hooks | |
2001 | * the interrupt service routine. It does not prepare the device for | |
2002 | * transmission; this is left to the first time one of the network | |
2003 | * interfaces is brought up (i.e. efx_net_open). | |
2004 | */ | |
2005 | static int __devinit efx_pci_probe(struct pci_dev *pci_dev, | |
2006 | const struct pci_device_id *entry) | |
2007 | { | |
2008 | struct efx_nic_type *type = (struct efx_nic_type *) entry->driver_data; | |
2009 | struct net_device *net_dev; | |
2010 | struct efx_nic *efx; | |
2011 | int i, rc; | |
2012 | ||
2013 | /* Allocate and initialise a struct net_device and struct efx_nic */ | |
2014 | net_dev = alloc_etherdev(sizeof(*efx)); | |
2015 | if (!net_dev) | |
2016 | return -ENOMEM; | |
b9b39b62 BH |
2017 | net_dev->features |= (NETIF_F_IP_CSUM | NETIF_F_SG | |
2018 | NETIF_F_HIGHDMA | NETIF_F_TSO); | |
8ceee660 BH |
2019 | if (lro) |
2020 | net_dev->features |= NETIF_F_LRO; | |
28506563 BH |
2021 | /* Mask for features that also apply to VLAN devices */ |
2022 | net_dev->vlan_features |= (NETIF_F_ALL_CSUM | NETIF_F_SG | | |
740847da | 2023 | NETIF_F_HIGHDMA | NETIF_F_TSO); |
767e468c | 2024 | efx = netdev_priv(net_dev); |
8ceee660 BH |
2025 | pci_set_drvdata(pci_dev, efx); |
2026 | rc = efx_init_struct(efx, type, pci_dev, net_dev); | |
2027 | if (rc) | |
2028 | goto fail1; | |
2029 | ||
2030 | EFX_INFO(efx, "Solarflare Communications NIC detected\n"); | |
2031 | ||
2032 | /* Set up basic I/O (BAR mappings etc) */ | |
2033 | rc = efx_init_io(efx); | |
2034 | if (rc) | |
2035 | goto fail2; | |
2036 | ||
2037 | /* No serialisation is required with the reset path because | |
2038 | * we're in STATE_INIT. */ | |
2039 | for (i = 0; i < 5; i++) { | |
2040 | rc = efx_pci_probe_main(efx); | |
2041 | if (rc == 0) | |
2042 | break; | |
2043 | ||
2044 | /* Serialise against efx_reset(). No more resets will be | |
2045 | * scheduled since efx_stop_all() has been called, and we | |
2046 | * have not and never have been registered with either | |
2047 | * the rtnetlink or driverlink layers. */ | |
8d9853d9 | 2048 | flush_workqueue(efx->reset_workqueue); |
8ceee660 BH |
2049 | |
2050 | /* Retry if a recoverably reset event has been scheduled */ | |
2051 | if ((efx->reset_pending != RESET_TYPE_INVISIBLE) && | |
2052 | (efx->reset_pending != RESET_TYPE_ALL)) | |
2053 | goto fail3; | |
2054 | ||
2055 | efx->reset_pending = RESET_TYPE_NONE; | |
2056 | } | |
2057 | ||
2058 | if (rc) { | |
2059 | EFX_ERR(efx, "Could not reset NIC\n"); | |
2060 | goto fail4; | |
2061 | } | |
2062 | ||
2063 | /* Switch to the running state before we expose the device to | |
2064 | * the OS. This is to ensure that the initial gathering of | |
2065 | * MAC stats succeeds. */ | |
2066 | rtnl_lock(); | |
2067 | efx->state = STATE_RUNNING; | |
2068 | rtnl_unlock(); | |
2069 | ||
2070 | rc = efx_register_netdev(efx); | |
2071 | if (rc) | |
2072 | goto fail5; | |
2073 | ||
2074 | EFX_LOG(efx, "initialisation successful\n"); | |
2075 | ||
f4150724 | 2076 | efx_mtd_probe(efx); /* allowed to fail */ |
8ceee660 BH |
2077 | return 0; |
2078 | ||
2079 | fail5: | |
2080 | efx_pci_remove_main(efx); | |
2081 | fail4: | |
2082 | fail3: | |
2083 | efx_fini_io(efx); | |
2084 | fail2: | |
2085 | efx_fini_struct(efx); | |
2086 | fail1: | |
2087 | EFX_LOG(efx, "initialisation failed. rc=%d\n", rc); | |
2088 | free_netdev(net_dev); | |
2089 | return rc; | |
2090 | } | |
2091 | ||
2092 | static struct pci_driver efx_pci_driver = { | |
2093 | .name = EFX_DRIVER_NAME, | |
2094 | .id_table = efx_pci_table, | |
2095 | .probe = efx_pci_probe, | |
2096 | .remove = efx_pci_remove, | |
2097 | }; | |
2098 | ||
2099 | /************************************************************************** | |
2100 | * | |
2101 | * Kernel module interface | |
2102 | * | |
2103 | *************************************************************************/ | |
2104 | ||
2105 | module_param(interrupt_mode, uint, 0444); | |
2106 | MODULE_PARM_DESC(interrupt_mode, | |
2107 | "Interrupt mode (0=>MSIX 1=>MSI 2=>legacy)"); | |
2108 | ||
2109 | static int __init efx_init_module(void) | |
2110 | { | |
2111 | int rc; | |
2112 | ||
2113 | printk(KERN_INFO "Solarflare NET driver v" EFX_DRIVER_VERSION "\n"); | |
2114 | ||
2115 | rc = register_netdevice_notifier(&efx_netdev_notifier); | |
2116 | if (rc) | |
2117 | goto err_notifier; | |
2118 | ||
2119 | refill_workqueue = create_workqueue("sfc_refill"); | |
2120 | if (!refill_workqueue) { | |
2121 | rc = -ENOMEM; | |
2122 | goto err_refill; | |
2123 | } | |
2124 | ||
2125 | rc = pci_register_driver(&efx_pci_driver); | |
2126 | if (rc < 0) | |
2127 | goto err_pci; | |
2128 | ||
2129 | return 0; | |
2130 | ||
2131 | err_pci: | |
2132 | destroy_workqueue(refill_workqueue); | |
2133 | err_refill: | |
2134 | unregister_netdevice_notifier(&efx_netdev_notifier); | |
2135 | err_notifier: | |
2136 | return rc; | |
2137 | } | |
2138 | ||
2139 | static void __exit efx_exit_module(void) | |
2140 | { | |
2141 | printk(KERN_INFO "Solarflare NET driver unloading\n"); | |
2142 | ||
2143 | pci_unregister_driver(&efx_pci_driver); | |
2144 | destroy_workqueue(refill_workqueue); | |
2145 | unregister_netdevice_notifier(&efx_netdev_notifier); | |
2146 | ||
2147 | } | |
2148 | ||
2149 | module_init(efx_init_module); | |
2150 | module_exit(efx_exit_module); | |
2151 | ||
2152 | MODULE_AUTHOR("Michael Brown <mbrown@fensystems.co.uk> and " | |
2153 | "Solarflare Communications"); | |
2154 | MODULE_DESCRIPTION("Solarflare Communications network driver"); | |
2155 | MODULE_LICENSE("GPL"); | |
2156 | MODULE_DEVICE_TABLE(pci, efx_pci_table); |