aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/sfc/efx.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/sfc/efx.c')
-rw-r--r--drivers/net/sfc/efx.c793
1 files changed, 466 insertions, 327 deletions
diff --git a/drivers/net/sfc/efx.c b/drivers/net/sfc/efx.c
index cc4b2f99989d..f983e3b507cc 100644
--- a/drivers/net/sfc/efx.c
+++ b/drivers/net/sfc/efx.c
@@ -1,7 +1,7 @@
1/**************************************************************************** 1/****************************************************************************
2 * Driver for Solarflare Solarstorm network controllers and boards 2 * Driver for Solarflare Solarstorm network controllers and boards
3 * Copyright 2005-2006 Fen Systems Ltd. 3 * Copyright 2005-2006 Fen Systems Ltd.
4 * Copyright 2005-2008 Solarflare Communications Inc. 4 * Copyright 2005-2009 Solarflare Communications Inc.
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify it 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 7 * under the terms of the GNU General Public License version 2 as published
@@ -21,12 +21,73 @@
21#include <linux/ethtool.h> 21#include <linux/ethtool.h>
22#include <linux/topology.h> 22#include <linux/topology.h>
23#include "net_driver.h" 23#include "net_driver.h"
24#include "ethtool.h"
25#include "tx.h"
26#include "rx.h"
27#include "efx.h" 24#include "efx.h"
28#include "mdio_10g.h" 25#include "mdio_10g.h"
29#include "falcon.h" 26#include "nic.h"
27
28#include "mcdi.h"
29
30/**************************************************************************
31 *
32 * Type name strings
33 *
34 **************************************************************************
35 */
36
37/* Loopback mode names (see LOOPBACK_MODE()) */
38const unsigned int efx_loopback_mode_max = LOOPBACK_MAX;
39const char *efx_loopback_mode_names[] = {
40 [LOOPBACK_NONE] = "NONE",
41 [LOOPBACK_DATA] = "DATAPATH",
42 [LOOPBACK_GMAC] = "GMAC",
43 [LOOPBACK_XGMII] = "XGMII",
44 [LOOPBACK_XGXS] = "XGXS",
45 [LOOPBACK_XAUI] = "XAUI",
46 [LOOPBACK_GMII] = "GMII",
47 [LOOPBACK_SGMII] = "SGMII",
48 [LOOPBACK_XGBR] = "XGBR",
49 [LOOPBACK_XFI] = "XFI",
50 [LOOPBACK_XAUI_FAR] = "XAUI_FAR",
51 [LOOPBACK_GMII_FAR] = "GMII_FAR",
52 [LOOPBACK_SGMII_FAR] = "SGMII_FAR",
53 [LOOPBACK_XFI_FAR] = "XFI_FAR",
54 [LOOPBACK_GPHY] = "GPHY",
55 [LOOPBACK_PHYXS] = "PHYXS",
56 [LOOPBACK_PCS] = "PCS",
57 [LOOPBACK_PMAPMD] = "PMA/PMD",
58 [LOOPBACK_XPORT] = "XPORT",
59 [LOOPBACK_XGMII_WS] = "XGMII_WS",
60 [LOOPBACK_XAUI_WS] = "XAUI_WS",
61 [LOOPBACK_XAUI_WS_FAR] = "XAUI_WS_FAR",
62 [LOOPBACK_XAUI_WS_NEAR] = "XAUI_WS_NEAR",
63 [LOOPBACK_GMII_WS] = "GMII_WS",
64 [LOOPBACK_XFI_WS] = "XFI_WS",
65 [LOOPBACK_XFI_WS_FAR] = "XFI_WS_FAR",
66 [LOOPBACK_PHYXS_WS] = "PHYXS_WS",
67};
68
69/* Interrupt mode names (see INT_MODE())) */
70const unsigned int efx_interrupt_mode_max = EFX_INT_MODE_MAX;
71const char *efx_interrupt_mode_names[] = {
72 [EFX_INT_MODE_MSIX] = "MSI-X",
73 [EFX_INT_MODE_MSI] = "MSI",
74 [EFX_INT_MODE_LEGACY] = "legacy",
75};
76
77const unsigned int efx_reset_type_max = RESET_TYPE_MAX;
78const char *efx_reset_type_names[] = {
79 [RESET_TYPE_INVISIBLE] = "INVISIBLE",
80 [RESET_TYPE_ALL] = "ALL",
81 [RESET_TYPE_WORLD] = "WORLD",
82 [RESET_TYPE_DISABLE] = "DISABLE",
83 [RESET_TYPE_TX_WATCHDOG] = "TX_WATCHDOG",
84 [RESET_TYPE_INT_ERROR] = "INT_ERROR",
85 [RESET_TYPE_RX_RECOVERY] = "RX_RECOVERY",
86 [RESET_TYPE_RX_DESC_FETCH] = "RX_DESC_FETCH",
87 [RESET_TYPE_TX_DESC_FETCH] = "TX_DESC_FETCH",
88 [RESET_TYPE_TX_SKIP] = "TX_SKIP",
89 [RESET_TYPE_MC_FAILURE] = "MC_FAILURE",
90};
30 91
31#define EFX_MAX_MTU (9 * 1024) 92#define EFX_MAX_MTU (9 * 1024)
32 93
@@ -145,7 +206,8 @@ static void efx_fini_channels(struct efx_nic *efx);
145 206
146#define EFX_ASSERT_RESET_SERIALISED(efx) \ 207#define EFX_ASSERT_RESET_SERIALISED(efx) \
147 do { \ 208 do { \
148 if (efx->state == STATE_RUNNING) \ 209 if ((efx->state == STATE_RUNNING) || \
210 (efx->state == STATE_DISABLED)) \
149 ASSERT_RTNL(); \ 211 ASSERT_RTNL(); \
150 } while (0) 212 } while (0)
151 213
@@ -171,7 +233,7 @@ static int efx_process_channel(struct efx_channel *channel, int rx_quota)
171 !channel->enabled)) 233 !channel->enabled))
172 return 0; 234 return 0;
173 235
174 rx_packets = falcon_process_eventq(channel, rx_quota); 236 rx_packets = efx_nic_process_eventq(channel, rx_quota);
175 if (rx_packets == 0) 237 if (rx_packets == 0)
176 return 0; 238 return 0;
177 239
@@ -203,7 +265,7 @@ static inline void efx_channel_processed(struct efx_channel *channel)
203 channel->work_pending = false; 265 channel->work_pending = false;
204 smp_wmb(); 266 smp_wmb();
205 267
206 falcon_eventq_read_ack(channel); 268 efx_nic_eventq_read_ack(channel);
207} 269}
208 270
209/* NAPI poll handler 271/* NAPI poll handler
@@ -228,26 +290,20 @@ static int efx_poll(struct napi_struct *napi, int budget)
228 if (channel->used_flags & EFX_USED_BY_RX && 290 if (channel->used_flags & EFX_USED_BY_RX &&
229 efx->irq_rx_adaptive && 291 efx->irq_rx_adaptive &&
230 unlikely(++channel->irq_count == 1000)) { 292 unlikely(++channel->irq_count == 1000)) {
231 unsigned old_irq_moderation = channel->irq_moderation;
232
233 if (unlikely(channel->irq_mod_score < 293 if (unlikely(channel->irq_mod_score <
234 irq_adapt_low_thresh)) { 294 irq_adapt_low_thresh)) {
235 channel->irq_moderation = 295 if (channel->irq_moderation > 1) {
236 max_t(int, 296 channel->irq_moderation -= 1;
237 channel->irq_moderation - 297 efx->type->push_irq_moderation(channel);
238 FALCON_IRQ_MOD_RESOLUTION, 298 }
239 FALCON_IRQ_MOD_RESOLUTION);
240 } else if (unlikely(channel->irq_mod_score > 299 } else if (unlikely(channel->irq_mod_score >
241 irq_adapt_high_thresh)) { 300 irq_adapt_high_thresh)) {
242 channel->irq_moderation = 301 if (channel->irq_moderation <
243 min(channel->irq_moderation + 302 efx->irq_rx_moderation) {
244 FALCON_IRQ_MOD_RESOLUTION, 303 channel->irq_moderation += 1;
245 efx->irq_rx_moderation); 304 efx->type->push_irq_moderation(channel);
305 }
246 } 306 }
247
248 if (channel->irq_moderation != old_irq_moderation)
249 falcon_set_int_moderation(channel);
250
251 channel->irq_count = 0; 307 channel->irq_count = 0;
252 channel->irq_mod_score = 0; 308 channel->irq_mod_score = 0;
253 } 309 }
@@ -280,7 +336,7 @@ void efx_process_channel_now(struct efx_channel *channel)
280 BUG_ON(!channel->enabled); 336 BUG_ON(!channel->enabled);
281 337
282 /* Disable interrupts and wait for ISRs to complete */ 338 /* Disable interrupts and wait for ISRs to complete */
283 falcon_disable_interrupts(efx); 339 efx_nic_disable_interrupts(efx);
284 if (efx->legacy_irq) 340 if (efx->legacy_irq)
285 synchronize_irq(efx->legacy_irq); 341 synchronize_irq(efx->legacy_irq);
286 if (channel->irq) 342 if (channel->irq)
@@ -290,14 +346,14 @@ void efx_process_channel_now(struct efx_channel *channel)
290 napi_disable(&channel->napi_str); 346 napi_disable(&channel->napi_str);
291 347
292 /* Poll the channel */ 348 /* Poll the channel */
293 efx_process_channel(channel, efx->type->evq_size); 349 efx_process_channel(channel, EFX_EVQ_SIZE);
294 350
295 /* Ack the eventq. This may cause an interrupt to be generated 351 /* Ack the eventq. This may cause an interrupt to be generated
296 * when they are reenabled */ 352 * when they are reenabled */
297 efx_channel_processed(channel); 353 efx_channel_processed(channel);
298 354
299 napi_enable(&channel->napi_str); 355 napi_enable(&channel->napi_str);
300 falcon_enable_interrupts(efx); 356 efx_nic_enable_interrupts(efx);
301} 357}
302 358
303/* Create event queue 359/* Create event queue
@@ -309,7 +365,7 @@ static int efx_probe_eventq(struct efx_channel *channel)
309{ 365{
310 EFX_LOG(channel->efx, "chan %d create event queue\n", channel->channel); 366 EFX_LOG(channel->efx, "chan %d create event queue\n", channel->channel);
311 367
312 return falcon_probe_eventq(channel); 368 return efx_nic_probe_eventq(channel);
313} 369}
314 370
315/* Prepare channel's event queue */ 371/* Prepare channel's event queue */
@@ -319,21 +375,21 @@ static void efx_init_eventq(struct efx_channel *channel)
319 375
320 channel->eventq_read_ptr = 0; 376 channel->eventq_read_ptr = 0;
321 377
322 falcon_init_eventq(channel); 378 efx_nic_init_eventq(channel);
323} 379}
324 380
325static void efx_fini_eventq(struct efx_channel *channel) 381static void efx_fini_eventq(struct efx_channel *channel)
326{ 382{
327 EFX_LOG(channel->efx, "chan %d fini event queue\n", channel->channel); 383 EFX_LOG(channel->efx, "chan %d fini event queue\n", channel->channel);
328 384
329 falcon_fini_eventq(channel); 385 efx_nic_fini_eventq(channel);
330} 386}
331 387
332static void efx_remove_eventq(struct efx_channel *channel) 388static void efx_remove_eventq(struct efx_channel *channel)
333{ 389{
334 EFX_LOG(channel->efx, "chan %d remove event queue\n", channel->channel); 390 EFX_LOG(channel->efx, "chan %d remove event queue\n", channel->channel);
335 391
336 falcon_remove_eventq(channel); 392 efx_nic_remove_eventq(channel);
337} 393}
338 394
339/************************************************************************** 395/**************************************************************************
@@ -499,7 +555,7 @@ static void efx_fini_channels(struct efx_nic *efx)
499 EFX_ASSERT_RESET_SERIALISED(efx); 555 EFX_ASSERT_RESET_SERIALISED(efx);
500 BUG_ON(efx->port_enabled); 556 BUG_ON(efx->port_enabled);
501 557
502 rc = falcon_flush_queues(efx); 558 rc = efx_nic_flush_queues(efx);
503 if (rc) 559 if (rc)
504 EFX_ERR(efx, "failed to flush queues\n"); 560 EFX_ERR(efx, "failed to flush queues\n");
505 else 561 else
@@ -547,8 +603,10 @@ void efx_schedule_slow_fill(struct efx_rx_queue *rx_queue, int delay)
547 * netif_carrier_on/off) of the link status, and also maintains the 603 * netif_carrier_on/off) of the link status, and also maintains the
548 * link status's stop on the port's TX queue. 604 * link status's stop on the port's TX queue.
549 */ 605 */
550static void efx_link_status_changed(struct efx_nic *efx) 606void efx_link_status_changed(struct efx_nic *efx)
551{ 607{
608 struct efx_link_state *link_state = &efx->link_state;
609
552 /* SFC Bug 5356: A net_dev notifier is registered, so we must ensure 610 /* SFC Bug 5356: A net_dev notifier is registered, so we must ensure
553 * that no events are triggered between unregister_netdev() and the 611 * that no events are triggered between unregister_netdev() and the
554 * driver unloading. A more general condition is that NETDEV_CHANGE 612 * driver unloading. A more general condition is that NETDEV_CHANGE
@@ -561,19 +619,19 @@ static void efx_link_status_changed(struct efx_nic *efx)
561 return; 619 return;
562 } 620 }
563 621
564 if (efx->link_up != netif_carrier_ok(efx->net_dev)) { 622 if (link_state->up != netif_carrier_ok(efx->net_dev)) {
565 efx->n_link_state_changes++; 623 efx->n_link_state_changes++;
566 624
567 if (efx->link_up) 625 if (link_state->up)
568 netif_carrier_on(efx->net_dev); 626 netif_carrier_on(efx->net_dev);
569 else 627 else
570 netif_carrier_off(efx->net_dev); 628 netif_carrier_off(efx->net_dev);
571 } 629 }
572 630
573 /* Status message for kernel log */ 631 /* Status message for kernel log */
574 if (efx->link_up) { 632 if (link_state->up) {
575 EFX_INFO(efx, "link up at %uMbps %s-duplex (MTU %d)%s\n", 633 EFX_INFO(efx, "link up at %uMbps %s-duplex (MTU %d)%s\n",
576 efx->link_speed, efx->link_fd ? "full" : "half", 634 link_state->speed, link_state->fd ? "full" : "half",
577 efx->net_dev->mtu, 635 efx->net_dev->mtu,
578 (efx->promiscuous ? " [PROMISC]" : "")); 636 (efx->promiscuous ? " [PROMISC]" : ""));
579 } else { 637 } else {
@@ -582,16 +640,49 @@ static void efx_link_status_changed(struct efx_nic *efx)
582 640
583} 641}
584 642
643void efx_link_set_advertising(struct efx_nic *efx, u32 advertising)
644{
645 efx->link_advertising = advertising;
646 if (advertising) {
647 if (advertising & ADVERTISED_Pause)
648 efx->wanted_fc |= (EFX_FC_TX | EFX_FC_RX);
649 else
650 efx->wanted_fc &= ~(EFX_FC_TX | EFX_FC_RX);
651 if (advertising & ADVERTISED_Asym_Pause)
652 efx->wanted_fc ^= EFX_FC_TX;
653 }
654}
655
656void efx_link_set_wanted_fc(struct efx_nic *efx, enum efx_fc_type wanted_fc)
657{
658 efx->wanted_fc = wanted_fc;
659 if (efx->link_advertising) {
660 if (wanted_fc & EFX_FC_RX)
661 efx->link_advertising |= (ADVERTISED_Pause |
662 ADVERTISED_Asym_Pause);
663 else
664 efx->link_advertising &= ~(ADVERTISED_Pause |
665 ADVERTISED_Asym_Pause);
666 if (wanted_fc & EFX_FC_TX)
667 efx->link_advertising ^= ADVERTISED_Asym_Pause;
668 }
669}
670
585static void efx_fini_port(struct efx_nic *efx); 671static void efx_fini_port(struct efx_nic *efx);
586 672
587/* This call reinitialises the MAC to pick up new PHY settings. The 673/* Push loopback/power/transmit disable settings to the PHY, and reconfigure
588 * caller must hold the mac_lock */ 674 * the MAC appropriately. All other PHY configuration changes are pushed
589void __efx_reconfigure_port(struct efx_nic *efx) 675 * through phy_op->set_settings(), and pushed asynchronously to the MAC
676 * through efx_monitor().
677 *
678 * Callers must hold the mac_lock
679 */
680int __efx_reconfigure_port(struct efx_nic *efx)
590{ 681{
591 WARN_ON(!mutex_is_locked(&efx->mac_lock)); 682 enum efx_phy_mode phy_mode;
683 int rc;
592 684
593 EFX_LOG(efx, "reconfiguring MAC from PHY settings on CPU %d\n", 685 WARN_ON(!mutex_is_locked(&efx->mac_lock));
594 raw_smp_processor_id());
595 686
596 /* Serialise the promiscuous flag with efx_set_multicast_list. */ 687 /* Serialise the promiscuous flag with efx_set_multicast_list. */
597 if (efx_dev_registered(efx)) { 688 if (efx_dev_registered(efx)) {
@@ -599,61 +690,48 @@ void __efx_reconfigure_port(struct efx_nic *efx)
599 netif_addr_unlock_bh(efx->net_dev); 690 netif_addr_unlock_bh(efx->net_dev);
600 } 691 }
601 692
602 falcon_deconfigure_mac_wrapper(efx); 693 /* Disable PHY transmit in mac level loopbacks */
603 694 phy_mode = efx->phy_mode;
604 /* Reconfigure the PHY, disabling transmit in mac level loopback. */
605 if (LOOPBACK_INTERNAL(efx)) 695 if (LOOPBACK_INTERNAL(efx))
606 efx->phy_mode |= PHY_MODE_TX_DISABLED; 696 efx->phy_mode |= PHY_MODE_TX_DISABLED;
607 else 697 else
608 efx->phy_mode &= ~PHY_MODE_TX_DISABLED; 698 efx->phy_mode &= ~PHY_MODE_TX_DISABLED;
609 efx->phy_op->reconfigure(efx);
610 699
611 if (falcon_switch_mac(efx)) 700 rc = efx->type->reconfigure_port(efx);
612 goto fail;
613 701
614 efx->mac_op->reconfigure(efx); 702 if (rc)
615 703 efx->phy_mode = phy_mode;
616 /* Inform kernel of loss/gain of carrier */
617 efx_link_status_changed(efx);
618 return;
619 704
620fail: 705 return rc;
621 EFX_ERR(efx, "failed to reconfigure MAC\n");
622 efx->port_enabled = false;
623 efx_fini_port(efx);
624} 706}
625 707
626/* Reinitialise the MAC to pick up new PHY settings, even if the port is 708/* Reinitialise the MAC to pick up new PHY settings, even if the port is
627 * disabled. */ 709 * disabled. */
628void efx_reconfigure_port(struct efx_nic *efx) 710int efx_reconfigure_port(struct efx_nic *efx)
629{ 711{
712 int rc;
713
630 EFX_ASSERT_RESET_SERIALISED(efx); 714 EFX_ASSERT_RESET_SERIALISED(efx);
631 715
632 mutex_lock(&efx->mac_lock); 716 mutex_lock(&efx->mac_lock);
633 __efx_reconfigure_port(efx); 717 rc = __efx_reconfigure_port(efx);
634 mutex_unlock(&efx->mac_lock); 718 mutex_unlock(&efx->mac_lock);
635}
636
637/* Asynchronous efx_reconfigure_port work item. To speed up efx_flush_all()
638 * we don't efx_reconfigure_port() if the port is disabled. Care is taken
639 * in efx_stop_all() and efx_start_port() to prevent PHY events being lost */
640static void efx_phy_work(struct work_struct *data)
641{
642 struct efx_nic *efx = container_of(data, struct efx_nic, phy_work);
643 719
644 mutex_lock(&efx->mac_lock); 720 return rc;
645 if (efx->port_enabled)
646 __efx_reconfigure_port(efx);
647 mutex_unlock(&efx->mac_lock);
648} 721}
649 722
723/* Asynchronous work item for changing MAC promiscuity and multicast
724 * hash. Avoid a drain/rx_ingress enable by reconfiguring the current
725 * MAC directly. */
650static void efx_mac_work(struct work_struct *data) 726static void efx_mac_work(struct work_struct *data)
651{ 727{
652 struct efx_nic *efx = container_of(data, struct efx_nic, mac_work); 728 struct efx_nic *efx = container_of(data, struct efx_nic, mac_work);
653 729
654 mutex_lock(&efx->mac_lock); 730 mutex_lock(&efx->mac_lock);
655 if (efx->port_enabled) 731 if (efx->port_enabled) {
656 efx->mac_op->irq(efx); 732 efx->type->push_multicast_hash(efx);
733 efx->mac_op->reconfigure(efx);
734 }
657 mutex_unlock(&efx->mac_lock); 735 mutex_unlock(&efx->mac_lock);
658} 736}
659 737
@@ -663,8 +741,8 @@ static int efx_probe_port(struct efx_nic *efx)
663 741
664 EFX_LOG(efx, "create port\n"); 742 EFX_LOG(efx, "create port\n");
665 743
666 /* Connect up MAC/PHY operations table and read MAC address */ 744 /* Connect up MAC/PHY operations table */
667 rc = falcon_probe_port(efx); 745 rc = efx->type->probe_port(efx);
668 if (rc) 746 if (rc)
669 goto err; 747 goto err;
670 748
@@ -699,29 +777,33 @@ static int efx_init_port(struct efx_nic *efx)
699 777
700 EFX_LOG(efx, "init port\n"); 778 EFX_LOG(efx, "init port\n");
701 779
702 rc = efx->phy_op->init(efx);
703 if (rc)
704 return rc;
705 mutex_lock(&efx->mac_lock); 780 mutex_lock(&efx->mac_lock);
706 efx->phy_op->reconfigure(efx); 781
707 rc = falcon_switch_mac(efx); 782 rc = efx->phy_op->init(efx);
708 mutex_unlock(&efx->mac_lock);
709 if (rc) 783 if (rc)
710 goto fail; 784 goto fail1;
711 efx->mac_op->reconfigure(efx);
712 785
713 efx->port_initialized = true; 786 efx->port_initialized = true;
714 efx_stats_enable(efx); 787
788 /* Reconfigure the MAC before creating dma queues (required for
789 * Falcon/A1 where RX_INGR_EN/TX_DRAIN_EN isn't supported) */
790 efx->mac_op->reconfigure(efx);
791
792 /* Ensure the PHY advertises the correct flow control settings */
793 rc = efx->phy_op->reconfigure(efx);
794 if (rc)
795 goto fail2;
796
797 mutex_unlock(&efx->mac_lock);
715 return 0; 798 return 0;
716 799
717fail: 800fail2:
718 efx->phy_op->fini(efx); 801 efx->phy_op->fini(efx);
802fail1:
803 mutex_unlock(&efx->mac_lock);
719 return rc; 804 return rc;
720} 805}
721 806
722/* Allow efx_reconfigure_port() to be scheduled, and close the window
723 * between efx_stop_port and efx_flush_all whereby a previously scheduled
724 * efx_phy_work()/efx_mac_work() may have been cancelled */
725static void efx_start_port(struct efx_nic *efx) 807static void efx_start_port(struct efx_nic *efx)
726{ 808{
727 EFX_LOG(efx, "start port\n"); 809 EFX_LOG(efx, "start port\n");
@@ -729,15 +811,16 @@ static void efx_start_port(struct efx_nic *efx)
729 811
730 mutex_lock(&efx->mac_lock); 812 mutex_lock(&efx->mac_lock);
731 efx->port_enabled = true; 813 efx->port_enabled = true;
732 __efx_reconfigure_port(efx); 814
733 efx->mac_op->irq(efx); 815 /* efx_mac_work() might have been scheduled after efx_stop_port(),
816 * and then cancelled by efx_flush_all() */
817 efx->type->push_multicast_hash(efx);
818 efx->mac_op->reconfigure(efx);
819
734 mutex_unlock(&efx->mac_lock); 820 mutex_unlock(&efx->mac_lock);
735} 821}
736 822
737/* Prevent efx_phy_work, efx_mac_work, and efx_monitor() from executing, 823/* Prevent efx_mac_work() and efx_monitor() from working */
738 * and efx_set_multicast_list() from scheduling efx_phy_work. efx_phy_work
739 * and efx_mac_work may still be scheduled via NAPI processing until
740 * efx_flush_all() is called */
741static void efx_stop_port(struct efx_nic *efx) 824static void efx_stop_port(struct efx_nic *efx)
742{ 825{
743 EFX_LOG(efx, "stop port\n"); 826 EFX_LOG(efx, "stop port\n");
@@ -760,11 +843,10 @@ static void efx_fini_port(struct efx_nic *efx)
760 if (!efx->port_initialized) 843 if (!efx->port_initialized)
761 return; 844 return;
762 845
763 efx_stats_disable(efx);
764 efx->phy_op->fini(efx); 846 efx->phy_op->fini(efx);
765 efx->port_initialized = false; 847 efx->port_initialized = false;
766 848
767 efx->link_up = false; 849 efx->link_state.up = false;
768 efx_link_status_changed(efx); 850 efx_link_status_changed(efx);
769} 851}
770 852
@@ -772,7 +854,7 @@ static void efx_remove_port(struct efx_nic *efx)
772{ 854{
773 EFX_LOG(efx, "destroying port\n"); 855 EFX_LOG(efx, "destroying port\n");
774 856
775 falcon_remove_port(efx); 857 efx->type->remove_port(efx);
776} 858}
777 859
778/************************************************************************** 860/**************************************************************************
@@ -824,9 +906,8 @@ static int efx_init_io(struct efx_nic *efx)
824 goto fail2; 906 goto fail2;
825 } 907 }
826 908
827 efx->membase_phys = pci_resource_start(efx->pci_dev, 909 efx->membase_phys = pci_resource_start(efx->pci_dev, EFX_MEM_BAR);
828 efx->type->mem_bar); 910 rc = pci_request_region(pci_dev, EFX_MEM_BAR, "sfc");
829 rc = pci_request_region(pci_dev, efx->type->mem_bar, "sfc");
830 if (rc) { 911 if (rc) {
831 EFX_ERR(efx, "request for memory BAR failed\n"); 912 EFX_ERR(efx, "request for memory BAR failed\n");
832 rc = -EIO; 913 rc = -EIO;
@@ -835,21 +916,20 @@ static int efx_init_io(struct efx_nic *efx)
835 efx->membase = ioremap_nocache(efx->membase_phys, 916 efx->membase = ioremap_nocache(efx->membase_phys,
836 efx->type->mem_map_size); 917 efx->type->mem_map_size);
837 if (!efx->membase) { 918 if (!efx->membase) {
838 EFX_ERR(efx, "could not map memory BAR %d at %llx+%x\n", 919 EFX_ERR(efx, "could not map memory BAR at %llx+%x\n",
839 efx->type->mem_bar,
840 (unsigned long long)efx->membase_phys, 920 (unsigned long long)efx->membase_phys,
841 efx->type->mem_map_size); 921 efx->type->mem_map_size);
842 rc = -ENOMEM; 922 rc = -ENOMEM;
843 goto fail4; 923 goto fail4;
844 } 924 }
845 EFX_LOG(efx, "memory BAR %u at %llx+%x (virtual %p)\n", 925 EFX_LOG(efx, "memory BAR at %llx+%x (virtual %p)\n",
846 efx->type->mem_bar, (unsigned long long)efx->membase_phys, 926 (unsigned long long)efx->membase_phys,
847 efx->type->mem_map_size, efx->membase); 927 efx->type->mem_map_size, efx->membase);
848 928
849 return 0; 929 return 0;
850 930
851 fail4: 931 fail4:
852 pci_release_region(efx->pci_dev, efx->type->mem_bar); 932 pci_release_region(efx->pci_dev, EFX_MEM_BAR);
853 fail3: 933 fail3:
854 efx->membase_phys = 0; 934 efx->membase_phys = 0;
855 fail2: 935 fail2:
@@ -868,7 +948,7 @@ static void efx_fini_io(struct efx_nic *efx)
868 } 948 }
869 949
870 if (efx->membase_phys) { 950 if (efx->membase_phys) {
871 pci_release_region(efx->pci_dev, efx->type->mem_bar); 951 pci_release_region(efx->pci_dev, EFX_MEM_BAR);
872 efx->membase_phys = 0; 952 efx->membase_phys = 0;
873 } 953 }
874 954
@@ -1011,7 +1091,7 @@ static int efx_probe_nic(struct efx_nic *efx)
1011 EFX_LOG(efx, "creating NIC\n"); 1091 EFX_LOG(efx, "creating NIC\n");
1012 1092
1013 /* Carry out hardware-type specific initialisation */ 1093 /* Carry out hardware-type specific initialisation */
1014 rc = falcon_probe_nic(efx); 1094 rc = efx->type->probe(efx);
1015 if (rc) 1095 if (rc)
1016 return rc; 1096 return rc;
1017 1097
@@ -1032,7 +1112,7 @@ static void efx_remove_nic(struct efx_nic *efx)
1032 EFX_LOG(efx, "destroying NIC\n"); 1112 EFX_LOG(efx, "destroying NIC\n");
1033 1113
1034 efx_remove_interrupts(efx); 1114 efx_remove_interrupts(efx);
1035 falcon_remove_nic(efx); 1115 efx->type->remove(efx);
1036} 1116}
1037 1117
1038/************************************************************************** 1118/**************************************************************************
@@ -1112,12 +1192,31 @@ static void efx_start_all(struct efx_nic *efx)
1112 efx_for_each_channel(channel, efx) 1192 efx_for_each_channel(channel, efx)
1113 efx_start_channel(channel); 1193 efx_start_channel(channel);
1114 1194
1115 falcon_enable_interrupts(efx); 1195 efx_nic_enable_interrupts(efx);
1116 1196
1117 /* Start hardware monitor if we're in RUNNING */ 1197 /* Switch to event based MCDI completions after enabling interrupts.
1118 if (efx->state == STATE_RUNNING) 1198 * If a reset has been scheduled, then we need to stay in polled mode.
1199 * Rather than serialising efx_mcdi_mode_event() [which sleeps] and
1200 * reset_pending [modified from an atomic context], we instead guarantee
1201 * that efx_mcdi_mode_poll() isn't reverted erroneously */
1202 efx_mcdi_mode_event(efx);
1203 if (efx->reset_pending != RESET_TYPE_NONE)
1204 efx_mcdi_mode_poll(efx);
1205
1206 /* Start the hardware monitor if there is one. Otherwise (we're link
1207 * event driven), we have to poll the PHY because after an event queue
1208 * flush, we could have a missed a link state change */
1209 if (efx->type->monitor != NULL) {
1119 queue_delayed_work(efx->workqueue, &efx->monitor_work, 1210 queue_delayed_work(efx->workqueue, &efx->monitor_work,
1120 efx_monitor_interval); 1211 efx_monitor_interval);
1212 } else {
1213 mutex_lock(&efx->mac_lock);
1214 if (efx->phy_op->poll(efx))
1215 efx_link_status_changed(efx);
1216 mutex_unlock(&efx->mac_lock);
1217 }
1218
1219 efx->type->start_stats(efx);
1121} 1220}
1122 1221
1123/* Flush all delayed work. Should only be called when no more delayed work 1222/* Flush all delayed work. Should only be called when no more delayed work
@@ -1136,8 +1235,6 @@ static void efx_flush_all(struct efx_nic *efx)
1136 1235
1137 /* Stop scheduled port reconfigurations */ 1236 /* Stop scheduled port reconfigurations */
1138 cancel_work_sync(&efx->mac_work); 1237 cancel_work_sync(&efx->mac_work);
1139 cancel_work_sync(&efx->phy_work);
1140
1141} 1238}
1142 1239
1143/* Quiesce hardware and software without bringing the link down. 1240/* Quiesce hardware and software without bringing the link down.
@@ -1155,8 +1252,13 @@ static void efx_stop_all(struct efx_nic *efx)
1155 if (!efx->port_enabled) 1252 if (!efx->port_enabled)
1156 return; 1253 return;
1157 1254
1255 efx->type->stop_stats(efx);
1256
1257 /* Switch to MCDI polling on Siena before disabling interrupts */
1258 efx_mcdi_mode_poll(efx);
1259
1158 /* Disable interrupts and wait for ISR to complete */ 1260 /* Disable interrupts and wait for ISR to complete */
1159 falcon_disable_interrupts(efx); 1261 efx_nic_disable_interrupts(efx);
1160 if (efx->legacy_irq) 1262 if (efx->legacy_irq)
1161 synchronize_irq(efx->legacy_irq); 1263 synchronize_irq(efx->legacy_irq);
1162 efx_for_each_channel(channel, efx) { 1264 efx_for_each_channel(channel, efx) {
@@ -1173,15 +1275,9 @@ static void efx_stop_all(struct efx_nic *efx)
1173 * window to loose phy events */ 1275 * window to loose phy events */
1174 efx_stop_port(efx); 1276 efx_stop_port(efx);
1175 1277
1176 /* Flush efx_phy_work, efx_mac_work, refill_workqueue, monitor_work */ 1278 /* Flush efx_mac_work(), refill_workqueue, monitor_work */
1177 efx_flush_all(efx); 1279 efx_flush_all(efx);
1178 1280
1179 /* Isolate the MAC from the TX and RX engines, so that queue
1180 * flushes will complete in a timely fashion. */
1181 falcon_deconfigure_mac_wrapper(efx);
1182 msleep(10); /* Let the Rx FIFO drain */
1183 falcon_drain_tx_fifo(efx);
1184
1185 /* Stop the kernel transmit interface late, so the watchdog 1281 /* Stop the kernel transmit interface late, so the watchdog
1186 * timer isn't ticking over the flush */ 1282 * timer isn't ticking over the flush */
1187 if (efx_dev_registered(efx)) { 1283 if (efx_dev_registered(efx)) {
@@ -1201,41 +1297,39 @@ static void efx_remove_all(struct efx_nic *efx)
1201 efx_remove_nic(efx); 1297 efx_remove_nic(efx);
1202} 1298}
1203 1299
1204/* A convinience function to safely flush all the queues */
1205void efx_flush_queues(struct efx_nic *efx)
1206{
1207 EFX_ASSERT_RESET_SERIALISED(efx);
1208
1209 efx_stop_all(efx);
1210
1211 efx_fini_channels(efx);
1212 efx_init_channels(efx);
1213
1214 efx_start_all(efx);
1215}
1216
1217/************************************************************************** 1300/**************************************************************************
1218 * 1301 *
1219 * Interrupt moderation 1302 * Interrupt moderation
1220 * 1303 *
1221 **************************************************************************/ 1304 **************************************************************************/
1222 1305
1306static unsigned irq_mod_ticks(int usecs, int resolution)
1307{
1308 if (usecs <= 0)
1309 return 0; /* cannot receive interrupts ahead of time :-) */
1310 if (usecs < resolution)
1311 return 1; /* never round down to 0 */
1312 return usecs / resolution;
1313}
1314
1223/* Set interrupt moderation parameters */ 1315/* Set interrupt moderation parameters */
1224void efx_init_irq_moderation(struct efx_nic *efx, int tx_usecs, int rx_usecs, 1316void efx_init_irq_moderation(struct efx_nic *efx, int tx_usecs, int rx_usecs,
1225 bool rx_adaptive) 1317 bool rx_adaptive)
1226{ 1318{
1227 struct efx_tx_queue *tx_queue; 1319 struct efx_tx_queue *tx_queue;
1228 struct efx_rx_queue *rx_queue; 1320 struct efx_rx_queue *rx_queue;
1321 unsigned tx_ticks = irq_mod_ticks(tx_usecs, EFX_IRQ_MOD_RESOLUTION);
1322 unsigned rx_ticks = irq_mod_ticks(rx_usecs, EFX_IRQ_MOD_RESOLUTION);
1229 1323
1230 EFX_ASSERT_RESET_SERIALISED(efx); 1324 EFX_ASSERT_RESET_SERIALISED(efx);
1231 1325
1232 efx_for_each_tx_queue(tx_queue, efx) 1326 efx_for_each_tx_queue(tx_queue, efx)
1233 tx_queue->channel->irq_moderation = tx_usecs; 1327 tx_queue->channel->irq_moderation = tx_ticks;
1234 1328
1235 efx->irq_rx_adaptive = rx_adaptive; 1329 efx->irq_rx_adaptive = rx_adaptive;
1236 efx->irq_rx_moderation = rx_usecs; 1330 efx->irq_rx_moderation = rx_ticks;
1237 efx_for_each_rx_queue(rx_queue, efx) 1331 efx_for_each_rx_queue(rx_queue, efx)
1238 rx_queue->channel->irq_moderation = rx_usecs; 1332 rx_queue->channel->irq_moderation = rx_ticks;
1239} 1333}
1240 1334
1241/************************************************************************** 1335/**************************************************************************
@@ -1250,10 +1344,10 @@ static void efx_monitor(struct work_struct *data)
1250{ 1344{
1251 struct efx_nic *efx = container_of(data, struct efx_nic, 1345 struct efx_nic *efx = container_of(data, struct efx_nic,
1252 monitor_work.work); 1346 monitor_work.work);
1253 int rc;
1254 1347
1255 EFX_TRACE(efx, "hardware monitor executing on CPU %d\n", 1348 EFX_TRACE(efx, "hardware monitor executing on CPU %d\n",
1256 raw_smp_processor_id()); 1349 raw_smp_processor_id());
1350 BUG_ON(efx->type->monitor == NULL);
1257 1351
1258 /* If the mac_lock is already held then it is likely a port 1352 /* If the mac_lock is already held then it is likely a port
1259 * reconfiguration is already in place, which will likely do 1353 * reconfiguration is already in place, which will likely do
@@ -1262,15 +1356,7 @@ static void efx_monitor(struct work_struct *data)
1262 goto out_requeue; 1356 goto out_requeue;
1263 if (!efx->port_enabled) 1357 if (!efx->port_enabled)
1264 goto out_unlock; 1358 goto out_unlock;
1265 rc = efx->board_info.monitor(efx); 1359 efx->type->monitor(efx);
1266 if (rc) {
1267 EFX_ERR(efx, "Board sensor %s; shutting down PHY\n",
1268 (rc == -ERANGE) ? "reported fault" : "failed");
1269 efx->phy_mode |= PHY_MODE_LOW_POWER;
1270 falcon_sim_phy_event(efx);
1271 }
1272 efx->phy_op->poll(efx);
1273 efx->mac_op->poll(efx);
1274 1360
1275out_unlock: 1361out_unlock:
1276 mutex_unlock(&efx->mac_lock); 1362 mutex_unlock(&efx->mac_lock);
@@ -1374,6 +1460,12 @@ static int efx_net_open(struct net_device *net_dev)
1374 return -EIO; 1460 return -EIO;
1375 if (efx->phy_mode & PHY_MODE_SPECIAL) 1461 if (efx->phy_mode & PHY_MODE_SPECIAL)
1376 return -EBUSY; 1462 return -EBUSY;
1463 if (efx_mcdi_poll_reboot(efx) && efx_reset(efx, RESET_TYPE_ALL))
1464 return -EIO;
1465
1466 /* Notify the kernel of the link state polled during driver load,
1467 * before the monitor starts running */
1468 efx_link_status_changed(efx);
1377 1469
1378 efx_start_all(efx); 1470 efx_start_all(efx);
1379 return 0; 1471 return 0;
@@ -1400,20 +1492,6 @@ static int efx_net_stop(struct net_device *net_dev)
1400 return 0; 1492 return 0;
1401} 1493}
1402 1494
1403void efx_stats_disable(struct efx_nic *efx)
1404{
1405 spin_lock(&efx->stats_lock);
1406 ++efx->stats_disable_count;
1407 spin_unlock(&efx->stats_lock);
1408}
1409
1410void efx_stats_enable(struct efx_nic *efx)
1411{
1412 spin_lock(&efx->stats_lock);
1413 --efx->stats_disable_count;
1414 spin_unlock(&efx->stats_lock);
1415}
1416
1417/* Context: process, dev_base_lock or RTNL held, non-blocking. */ 1495/* Context: process, dev_base_lock or RTNL held, non-blocking. */
1418static struct net_device_stats *efx_net_stats(struct net_device *net_dev) 1496static struct net_device_stats *efx_net_stats(struct net_device *net_dev)
1419{ 1497{
@@ -1421,17 +1499,9 @@ static struct net_device_stats *efx_net_stats(struct net_device *net_dev)
1421 struct efx_mac_stats *mac_stats = &efx->mac_stats; 1499 struct efx_mac_stats *mac_stats = &efx->mac_stats;
1422 struct net_device_stats *stats = &net_dev->stats; 1500 struct net_device_stats *stats = &net_dev->stats;
1423 1501
1424 /* Update stats if possible, but do not wait if another thread 1502 spin_lock_bh(&efx->stats_lock);
1425 * is updating them or if MAC stats fetches are temporarily 1503 efx->type->update_stats(efx);
1426 * disabled; slightly stale stats are acceptable. 1504 spin_unlock_bh(&efx->stats_lock);
1427 */
1428 if (!spin_trylock(&efx->stats_lock))
1429 return stats;
1430 if (!efx->stats_disable_count) {
1431 efx->mac_op->update_stats(efx);
1432 falcon_update_nic_stats(efx);
1433 }
1434 spin_unlock(&efx->stats_lock);
1435 1505
1436 stats->rx_packets = mac_stats->rx_packets; 1506 stats->rx_packets = mac_stats->rx_packets;
1437 stats->tx_packets = mac_stats->tx_packets; 1507 stats->tx_packets = mac_stats->tx_packets;
@@ -1490,7 +1560,14 @@ static int efx_change_mtu(struct net_device *net_dev, int new_mtu)
1490 EFX_LOG(efx, "changing MTU to %d\n", new_mtu); 1560 EFX_LOG(efx, "changing MTU to %d\n", new_mtu);
1491 1561
1492 efx_fini_channels(efx); 1562 efx_fini_channels(efx);
1563
1564 mutex_lock(&efx->mac_lock);
1565 /* Reconfigure the MAC before enabling the dma queues so that
1566 * the RX buffers don't overflow */
1493 net_dev->mtu = new_mtu; 1567 net_dev->mtu = new_mtu;
1568 efx->mac_op->reconfigure(efx);
1569 mutex_unlock(&efx->mac_lock);
1570
1494 efx_init_channels(efx); 1571 efx_init_channels(efx);
1495 1572
1496 efx_start_all(efx); 1573 efx_start_all(efx);
@@ -1514,7 +1591,9 @@ static int efx_set_mac_address(struct net_device *net_dev, void *data)
1514 memcpy(net_dev->dev_addr, new_addr, net_dev->addr_len); 1591 memcpy(net_dev->dev_addr, new_addr, net_dev->addr_len);
1515 1592
1516 /* Reconfigure the MAC */ 1593 /* Reconfigure the MAC */
1517 efx_reconfigure_port(efx); 1594 mutex_lock(&efx->mac_lock);
1595 efx->mac_op->reconfigure(efx);
1596 mutex_unlock(&efx->mac_lock);
1518 1597
1519 return 0; 1598 return 0;
1520} 1599}
@@ -1525,16 +1604,14 @@ static void efx_set_multicast_list(struct net_device *net_dev)
1525 struct efx_nic *efx = netdev_priv(net_dev); 1604 struct efx_nic *efx = netdev_priv(net_dev);
1526 struct dev_mc_list *mc_list = net_dev->mc_list; 1605 struct dev_mc_list *mc_list = net_dev->mc_list;
1527 union efx_multicast_hash *mc_hash = &efx->multicast_hash; 1606 union efx_multicast_hash *mc_hash = &efx->multicast_hash;
1528 bool promiscuous = !!(net_dev->flags & IFF_PROMISC);
1529 bool changed = (efx->promiscuous != promiscuous);
1530 u32 crc; 1607 u32 crc;
1531 int bit; 1608 int bit;
1532 int i; 1609 int i;
1533 1610
1534 efx->promiscuous = promiscuous; 1611 efx->promiscuous = !!(net_dev->flags & IFF_PROMISC);
1535 1612
1536 /* Build multicast hash table */ 1613 /* Build multicast hash table */
1537 if (promiscuous || (net_dev->flags & IFF_ALLMULTI)) { 1614 if (efx->promiscuous || (net_dev->flags & IFF_ALLMULTI)) {
1538 memset(mc_hash, 0xff, sizeof(*mc_hash)); 1615 memset(mc_hash, 0xff, sizeof(*mc_hash));
1539 } else { 1616 } else {
1540 memset(mc_hash, 0x00, sizeof(*mc_hash)); 1617 memset(mc_hash, 0x00, sizeof(*mc_hash));
@@ -1544,17 +1621,17 @@ static void efx_set_multicast_list(struct net_device *net_dev)
1544 set_bit_le(bit, mc_hash->byte); 1621 set_bit_le(bit, mc_hash->byte);
1545 mc_list = mc_list->next; 1622 mc_list = mc_list->next;
1546 } 1623 }
1547 }
1548
1549 if (!efx->port_enabled)
1550 /* Delay pushing settings until efx_start_port() */
1551 return;
1552 1624
1553 if (changed) 1625 /* Broadcast packets go through the multicast hash filter.
1554 queue_work(efx->workqueue, &efx->phy_work); 1626 * ether_crc_le() of the broadcast address is 0xbe2612ff
1627 * so we always add bit 0xff to the mask.
1628 */
1629 set_bit_le(0xff, mc_hash->byte);
1630 }
1555 1631
1556 /* Create and activate new global multicast hash table */ 1632 if (efx->port_enabled)
1557 falcon_set_multicast_hash(efx); 1633 queue_work(efx->workqueue, &efx->mac_work);
1634 /* Otherwise efx_start_port() will do this */
1558} 1635}
1559 1636
1560static const struct net_device_ops efx_netdev_ops = { 1637static const struct net_device_ops efx_netdev_ops = {
@@ -1683,21 +1760,18 @@ static void efx_unregister_netdev(struct efx_nic *efx)
1683 1760
1684/* Tears down the entire software state and most of the hardware state 1761/* Tears down the entire software state and most of the hardware state
1685 * before reset. */ 1762 * before reset. */
1686void efx_reset_down(struct efx_nic *efx, enum reset_type method, 1763void efx_reset_down(struct efx_nic *efx, enum reset_type method)
1687 struct ethtool_cmd *ecmd)
1688{ 1764{
1689 EFX_ASSERT_RESET_SERIALISED(efx); 1765 EFX_ASSERT_RESET_SERIALISED(efx);
1690 1766
1691 efx_stats_disable(efx);
1692 efx_stop_all(efx); 1767 efx_stop_all(efx);
1693 mutex_lock(&efx->mac_lock); 1768 mutex_lock(&efx->mac_lock);
1694 mutex_lock(&efx->spi_lock); 1769 mutex_lock(&efx->spi_lock);
1695 1770
1696 efx->phy_op->get_settings(efx, ecmd);
1697
1698 efx_fini_channels(efx); 1771 efx_fini_channels(efx);
1699 if (efx->port_initialized && method != RESET_TYPE_INVISIBLE) 1772 if (efx->port_initialized && method != RESET_TYPE_INVISIBLE)
1700 efx->phy_op->fini(efx); 1773 efx->phy_op->fini(efx);
1774 efx->type->fini(efx);
1701} 1775}
1702 1776
1703/* This function will always ensure that the locks acquired in 1777/* This function will always ensure that the locks acquired in
@@ -1705,79 +1779,67 @@ void efx_reset_down(struct efx_nic *efx, enum reset_type method,
1705 * that we were unable to reinitialise the hardware, and the 1779 * that we were unable to reinitialise the hardware, and the
1706 * driver should be disabled. If ok is false, then the rx and tx 1780 * driver should be disabled. If ok is false, then the rx and tx
1707 * engines are not restarted, pending a RESET_DISABLE. */ 1781 * engines are not restarted, pending a RESET_DISABLE. */
1708int efx_reset_up(struct efx_nic *efx, enum reset_type method, 1782int efx_reset_up(struct efx_nic *efx, enum reset_type method, bool ok)
1709 struct ethtool_cmd *ecmd, bool ok)
1710{ 1783{
1711 int rc; 1784 int rc;
1712 1785
1713 EFX_ASSERT_RESET_SERIALISED(efx); 1786 EFX_ASSERT_RESET_SERIALISED(efx);
1714 1787
1715 rc = falcon_init_nic(efx); 1788 rc = efx->type->init(efx);
1716 if (rc) { 1789 if (rc) {
1717 EFX_ERR(efx, "failed to initialise NIC\n"); 1790 EFX_ERR(efx, "failed to initialise NIC\n");
1718 ok = false; 1791 goto fail;
1719 } 1792 }
1720 1793
1794 if (!ok)
1795 goto fail;
1796
1721 if (efx->port_initialized && method != RESET_TYPE_INVISIBLE) { 1797 if (efx->port_initialized && method != RESET_TYPE_INVISIBLE) {
1722 if (ok) { 1798 rc = efx->phy_op->init(efx);
1723 rc = efx->phy_op->init(efx); 1799 if (rc)
1724 if (rc) 1800 goto fail;
1725 ok = false; 1801 if (efx->phy_op->reconfigure(efx))
1726 } 1802 EFX_ERR(efx, "could not restore PHY settings\n");
1727 if (!ok)
1728 efx->port_initialized = false;
1729 } 1803 }
1730 1804
1731 if (ok) { 1805 efx->mac_op->reconfigure(efx);
1732 efx_init_channels(efx);
1733 1806
1734 if (efx->phy_op->set_settings(efx, ecmd)) 1807 efx_init_channels(efx);
1735 EFX_ERR(efx, "could not restore PHY settings\n"); 1808
1736 } 1809 mutex_unlock(&efx->spi_lock);
1810 mutex_unlock(&efx->mac_lock);
1811
1812 efx_start_all(efx);
1813
1814 return 0;
1815
1816fail:
1817 efx->port_initialized = false;
1737 1818
1738 mutex_unlock(&efx->spi_lock); 1819 mutex_unlock(&efx->spi_lock);
1739 mutex_unlock(&efx->mac_lock); 1820 mutex_unlock(&efx->mac_lock);
1740 1821
1741 if (ok) {
1742 efx_start_all(efx);
1743 efx_stats_enable(efx);
1744 }
1745 return rc; 1822 return rc;
1746} 1823}
1747 1824
1748/* Reset the NIC as transparently as possible. Do not reset the PHY 1825/* Reset the NIC using the specified method. Note that the reset may
1749 * Note that the reset may fail, in which case the card will be left 1826 * fail, in which case the card will be left in an unusable state.
1750 * in a most-probably-unusable state.
1751 * 1827 *
1752 * This function will sleep. You cannot reset from within an atomic 1828 * Caller must hold the rtnl_lock.
1753 * state; use efx_schedule_reset() instead.
1754 *
1755 * Grabs the rtnl_lock.
1756 */ 1829 */
1757static int efx_reset(struct efx_nic *efx) 1830int efx_reset(struct efx_nic *efx, enum reset_type method)
1758{ 1831{
1759 struct ethtool_cmd ecmd; 1832 int rc, rc2;
1760 enum reset_type method = efx->reset_pending; 1833 bool disabled;
1761 int rc = 0;
1762 1834
1763 /* Serialise with kernel interfaces */ 1835 EFX_INFO(efx, "resetting (%s)\n", RESET_TYPE(method));
1764 rtnl_lock();
1765 1836
1766 /* If we're not RUNNING then don't reset. Leave the reset_pending 1837 efx_reset_down(efx, method);
1767 * flag set so that efx_pci_probe_main will be retried */
1768 if (efx->state != STATE_RUNNING) {
1769 EFX_INFO(efx, "scheduled reset quenched. NIC not RUNNING\n");
1770 goto out_unlock;
1771 }
1772 1838
1773 EFX_INFO(efx, "resetting (%d)\n", method); 1839 rc = efx->type->reset(efx, method);
1774
1775 efx_reset_down(efx, method, &ecmd);
1776
1777 rc = falcon_reset_hw(efx, method);
1778 if (rc) { 1840 if (rc) {
1779 EFX_ERR(efx, "failed to reset hardware\n"); 1841 EFX_ERR(efx, "failed to reset hardware\n");
1780 goto out_disable; 1842 goto out;
1781 } 1843 }
1782 1844
1783 /* Allow resets to be rescheduled. */ 1845 /* Allow resets to be rescheduled. */
@@ -1789,25 +1851,22 @@ static int efx_reset(struct efx_nic *efx)
1789 * can respond to requests. */ 1851 * can respond to requests. */
1790 pci_set_master(efx->pci_dev); 1852 pci_set_master(efx->pci_dev);
1791 1853
1854out:
1792 /* Leave device stopped if necessary */ 1855 /* Leave device stopped if necessary */
1793 if (method == RESET_TYPE_DISABLE) { 1856 disabled = rc || method == RESET_TYPE_DISABLE;
1794 efx_reset_up(efx, method, &ecmd, false); 1857 rc2 = efx_reset_up(efx, method, !disabled);
1795 rc = -EIO; 1858 if (rc2) {
1796 } else { 1859 disabled = true;
1797 rc = efx_reset_up(efx, method, &ecmd, true); 1860 if (!rc)
1861 rc = rc2;
1798 } 1862 }
1799 1863
1800out_disable: 1864 if (disabled) {
1801 if (rc) {
1802 EFX_ERR(efx, "has been disabled\n"); 1865 EFX_ERR(efx, "has been disabled\n");
1803 efx->state = STATE_DISABLED; 1866 efx->state = STATE_DISABLED;
1804 dev_close(efx->net_dev);
1805 } else { 1867 } else {
1806 EFX_LOG(efx, "reset complete\n"); 1868 EFX_LOG(efx, "reset complete\n");
1807 } 1869 }
1808
1809out_unlock:
1810 rtnl_unlock();
1811 return rc; 1870 return rc;
1812} 1871}
1813 1872
@@ -1816,9 +1875,19 @@ out_unlock:
1816 */ 1875 */
1817static void efx_reset_work(struct work_struct *data) 1876static void efx_reset_work(struct work_struct *data)
1818{ 1877{
1819 struct efx_nic *nic = container_of(data, struct efx_nic, reset_work); 1878 struct efx_nic *efx = container_of(data, struct efx_nic, reset_work);
1879
1880 /* If we're not RUNNING then don't reset. Leave the reset_pending
1881 * flag set so that efx_pci_probe_main will be retried */
1882 if (efx->state != STATE_RUNNING) {
1883 EFX_INFO(efx, "scheduled reset quenched. NIC not RUNNING\n");
1884 return;
1885 }
1820 1886
1821 efx_reset(nic); 1887 rtnl_lock();
1888 if (efx_reset(efx, efx->reset_pending))
1889 dev_close(efx->net_dev);
1890 rtnl_unlock();
1822} 1891}
1823 1892
1824void efx_schedule_reset(struct efx_nic *efx, enum reset_type type) 1893void efx_schedule_reset(struct efx_nic *efx, enum reset_type type)
@@ -1843,18 +1912,24 @@ void efx_schedule_reset(struct efx_nic *efx, enum reset_type type)
1843 case RESET_TYPE_TX_SKIP: 1912 case RESET_TYPE_TX_SKIP:
1844 method = RESET_TYPE_INVISIBLE; 1913 method = RESET_TYPE_INVISIBLE;
1845 break; 1914 break;
1915 case RESET_TYPE_MC_FAILURE:
1846 default: 1916 default:
1847 method = RESET_TYPE_ALL; 1917 method = RESET_TYPE_ALL;
1848 break; 1918 break;
1849 } 1919 }
1850 1920
1851 if (method != type) 1921 if (method != type)
1852 EFX_LOG(efx, "scheduling reset (%d:%d)\n", type, method); 1922 EFX_LOG(efx, "scheduling %s reset for %s\n",
1923 RESET_TYPE(method), RESET_TYPE(type));
1853 else 1924 else
1854 EFX_LOG(efx, "scheduling reset (%d)\n", method); 1925 EFX_LOG(efx, "scheduling %s reset\n", RESET_TYPE(method));
1855 1926
1856 efx->reset_pending = method; 1927 efx->reset_pending = method;
1857 1928
1929 /* efx_process_channel() will no longer read events once a
1930 * reset is scheduled. So switch back to poll'd MCDI completions. */
1931 efx_mcdi_mode_poll(efx);
1932
1858 queue_work(reset_workqueue, &efx->reset_work); 1933 queue_work(reset_workqueue, &efx->reset_work);
1859} 1934}
1860 1935
@@ -1867,15 +1942,19 @@ void efx_schedule_reset(struct efx_nic *efx, enum reset_type type)
1867/* PCI device ID table */ 1942/* PCI device ID table */
1868static struct pci_device_id efx_pci_table[] __devinitdata = { 1943static struct pci_device_id efx_pci_table[] __devinitdata = {
1869 {PCI_DEVICE(EFX_VENDID_SFC, FALCON_A_P_DEVID), 1944 {PCI_DEVICE(EFX_VENDID_SFC, FALCON_A_P_DEVID),
1870 .driver_data = (unsigned long) &falcon_a_nic_type}, 1945 .driver_data = (unsigned long) &falcon_a1_nic_type},
1871 {PCI_DEVICE(EFX_VENDID_SFC, FALCON_B_P_DEVID), 1946 {PCI_DEVICE(EFX_VENDID_SFC, FALCON_B_P_DEVID),
1872 .driver_data = (unsigned long) &falcon_b_nic_type}, 1947 .driver_data = (unsigned long) &falcon_b0_nic_type},
1948 {PCI_DEVICE(EFX_VENDID_SFC, BETHPAGE_A_P_DEVID),
1949 .driver_data = (unsigned long) &siena_a0_nic_type},
1950 {PCI_DEVICE(EFX_VENDID_SFC, SIENA_A_P_DEVID),
1951 .driver_data = (unsigned long) &siena_a0_nic_type},
1873 {0} /* end of list */ 1952 {0} /* end of list */
1874}; 1953};
1875 1954
1876/************************************************************************** 1955/**************************************************************************
1877 * 1956 *
1878 * Dummy PHY/MAC/Board operations 1957 * Dummy PHY/MAC operations
1879 * 1958 *
1880 * Can be used for some unimplemented operations 1959 * Can be used for some unimplemented operations
1881 * Needed so all function pointers are valid and do not have to be tested 1960 * Needed so all function pointers are valid and do not have to be tested
@@ -1887,29 +1966,19 @@ int efx_port_dummy_op_int(struct efx_nic *efx)
1887 return 0; 1966 return 0;
1888} 1967}
1889void efx_port_dummy_op_void(struct efx_nic *efx) {} 1968void efx_port_dummy_op_void(struct efx_nic *efx) {}
1890void efx_port_dummy_op_blink(struct efx_nic *efx, bool blink) {} 1969void efx_port_dummy_op_set_id_led(struct efx_nic *efx, enum efx_led_mode mode)
1891 1970{
1892static struct efx_mac_operations efx_dummy_mac_operations = { 1971}
1893 .reconfigure = efx_port_dummy_op_void, 1972bool efx_port_dummy_op_poll(struct efx_nic *efx)
1894 .poll = efx_port_dummy_op_void, 1973{
1895 .irq = efx_port_dummy_op_void, 1974 return false;
1896}; 1975}
1897 1976
1898static struct efx_phy_operations efx_dummy_phy_operations = { 1977static struct efx_phy_operations efx_dummy_phy_operations = {
1899 .init = efx_port_dummy_op_int, 1978 .init = efx_port_dummy_op_int,
1900 .reconfigure = efx_port_dummy_op_void, 1979 .reconfigure = efx_port_dummy_op_int,
1901 .poll = efx_port_dummy_op_void, 1980 .poll = efx_port_dummy_op_poll,
1902 .fini = efx_port_dummy_op_void, 1981 .fini = efx_port_dummy_op_void,
1903 .clear_interrupt = efx_port_dummy_op_void,
1904};
1905
1906static struct efx_board efx_dummy_board_info = {
1907 .init = efx_port_dummy_op_int,
1908 .init_leds = efx_port_dummy_op_void,
1909 .set_id_led = efx_port_dummy_op_blink,
1910 .monitor = efx_port_dummy_op_int,
1911 .blink = efx_port_dummy_op_blink,
1912 .fini = efx_port_dummy_op_void,
1913}; 1982};
1914 1983
1915/************************************************************************** 1984/**************************************************************************
@@ -1932,26 +2001,26 @@ static int efx_init_struct(struct efx_nic *efx, struct efx_nic_type *type,
1932 /* Initialise common structures */ 2001 /* Initialise common structures */
1933 memset(efx, 0, sizeof(*efx)); 2002 memset(efx, 0, sizeof(*efx));
1934 spin_lock_init(&efx->biu_lock); 2003 spin_lock_init(&efx->biu_lock);
1935 spin_lock_init(&efx->phy_lock); 2004 mutex_init(&efx->mdio_lock);
1936 mutex_init(&efx->spi_lock); 2005 mutex_init(&efx->spi_lock);
2006#ifdef CONFIG_SFC_MTD
2007 INIT_LIST_HEAD(&efx->mtd_list);
2008#endif
1937 INIT_WORK(&efx->reset_work, efx_reset_work); 2009 INIT_WORK(&efx->reset_work, efx_reset_work);
1938 INIT_DELAYED_WORK(&efx->monitor_work, efx_monitor); 2010 INIT_DELAYED_WORK(&efx->monitor_work, efx_monitor);
1939 efx->pci_dev = pci_dev; 2011 efx->pci_dev = pci_dev;
1940 efx->state = STATE_INIT; 2012 efx->state = STATE_INIT;
1941 efx->reset_pending = RESET_TYPE_NONE; 2013 efx->reset_pending = RESET_TYPE_NONE;
1942 strlcpy(efx->name, pci_name(pci_dev), sizeof(efx->name)); 2014 strlcpy(efx->name, pci_name(pci_dev), sizeof(efx->name));
1943 efx->board_info = efx_dummy_board_info;
1944 2015
1945 efx->net_dev = net_dev; 2016 efx->net_dev = net_dev;
1946 efx->rx_checksum_enabled = true; 2017 efx->rx_checksum_enabled = true;
1947 spin_lock_init(&efx->netif_stop_lock); 2018 spin_lock_init(&efx->netif_stop_lock);
1948 spin_lock_init(&efx->stats_lock); 2019 spin_lock_init(&efx->stats_lock);
1949 efx->stats_disable_count = 1;
1950 mutex_init(&efx->mac_lock); 2020 mutex_init(&efx->mac_lock);
1951 efx->mac_op = &efx_dummy_mac_operations; 2021 efx->mac_op = type->default_mac_ops;
1952 efx->phy_op = &efx_dummy_phy_operations; 2022 efx->phy_op = &efx_dummy_phy_operations;
1953 efx->mdio.dev = net_dev; 2023 efx->mdio.dev = net_dev;
1954 INIT_WORK(&efx->phy_work, efx_phy_work);
1955 INIT_WORK(&efx->mac_work, efx_mac_work); 2024 INIT_WORK(&efx->mac_work, efx_mac_work);
1956 atomic_set(&efx->netif_stop_count, 1); 2025 atomic_set(&efx->netif_stop_count, 1);
1957 2026
@@ -1981,17 +2050,9 @@ static int efx_init_struct(struct efx_nic *efx, struct efx_nic_type *type,
1981 2050
1982 efx->type = type; 2051 efx->type = type;
1983 2052
1984 /* Sanity-check NIC type */
1985 EFX_BUG_ON_PARANOID(efx->type->txd_ring_mask &
1986 (efx->type->txd_ring_mask + 1));
1987 EFX_BUG_ON_PARANOID(efx->type->rxd_ring_mask &
1988 (efx->type->rxd_ring_mask + 1));
1989 EFX_BUG_ON_PARANOID(efx->type->evq_size &
1990 (efx->type->evq_size - 1));
1991 /* As close as we can get to guaranteeing that we don't overflow */ 2053 /* As close as we can get to guaranteeing that we don't overflow */
1992 EFX_BUG_ON_PARANOID(efx->type->evq_size < 2054 BUILD_BUG_ON(EFX_EVQ_SIZE < EFX_TXQ_SIZE + EFX_RXQ_SIZE);
1993 (efx->type->txd_ring_mask + 1 + 2055
1994 efx->type->rxd_ring_mask + 1));
1995 EFX_BUG_ON_PARANOID(efx->type->phys_addr_channels > EFX_MAX_CHANNELS); 2056 EFX_BUG_ON_PARANOID(efx->type->phys_addr_channels > EFX_MAX_CHANNELS);
1996 2057
1997 /* Higher numbered interrupt modes are less capable! */ 2058 /* Higher numbered interrupt modes are less capable! */
@@ -2027,19 +2088,10 @@ static void efx_fini_struct(struct efx_nic *efx)
2027 */ 2088 */
2028static void efx_pci_remove_main(struct efx_nic *efx) 2089static void efx_pci_remove_main(struct efx_nic *efx)
2029{ 2090{
2030 EFX_ASSERT_RESET_SERIALISED(efx); 2091 efx_nic_fini_interrupt(efx);
2031
2032 /* Skip everything if we never obtained a valid membase */
2033 if (!efx->membase)
2034 return;
2035
2036 efx_fini_channels(efx); 2092 efx_fini_channels(efx);
2037 efx_fini_port(efx); 2093 efx_fini_port(efx);
2038 2094 efx->type->fini(efx);
2039 /* Shutdown the board, then the NIC and board state */
2040 efx->board_info.fini(efx);
2041 falcon_fini_interrupt(efx);
2042
2043 efx_fini_napi(efx); 2095 efx_fini_napi(efx);
2044 efx_remove_all(efx); 2096 efx_remove_all(efx);
2045} 2097}
@@ -2063,9 +2115,6 @@ static void efx_pci_remove(struct pci_dev *pci_dev)
2063 /* Allow any queued efx_resets() to complete */ 2115 /* Allow any queued efx_resets() to complete */
2064 rtnl_unlock(); 2116 rtnl_unlock();
2065 2117
2066 if (efx->membase == NULL)
2067 goto out;
2068
2069 efx_unregister_netdev(efx); 2118 efx_unregister_netdev(efx);
2070 2119
2071 efx_mtd_remove(efx); 2120 efx_mtd_remove(efx);
@@ -2078,7 +2127,6 @@ static void efx_pci_remove(struct pci_dev *pci_dev)
2078 2127
2079 efx_pci_remove_main(efx); 2128 efx_pci_remove_main(efx);
2080 2129
2081out:
2082 efx_fini_io(efx); 2130 efx_fini_io(efx);
2083 EFX_LOG(efx, "shutdown successful\n"); 2131 EFX_LOG(efx, "shutdown successful\n");
2084 2132
@@ -2103,39 +2151,31 @@ static int efx_pci_probe_main(struct efx_nic *efx)
2103 if (rc) 2151 if (rc)
2104 goto fail2; 2152 goto fail2;
2105 2153
2106 /* Initialise the board */ 2154 rc = efx->type->init(efx);
2107 rc = efx->board_info.init(efx);
2108 if (rc) {
2109 EFX_ERR(efx, "failed to initialise board\n");
2110 goto fail3;
2111 }
2112
2113 rc = falcon_init_nic(efx);
2114 if (rc) { 2155 if (rc) {
2115 EFX_ERR(efx, "failed to initialise NIC\n"); 2156 EFX_ERR(efx, "failed to initialise NIC\n");
2116 goto fail4; 2157 goto fail3;
2117 } 2158 }
2118 2159
2119 rc = efx_init_port(efx); 2160 rc = efx_init_port(efx);
2120 if (rc) { 2161 if (rc) {
2121 EFX_ERR(efx, "failed to initialise port\n"); 2162 EFX_ERR(efx, "failed to initialise port\n");
2122 goto fail5; 2163 goto fail4;
2123 } 2164 }
2124 2165
2125 efx_init_channels(efx); 2166 efx_init_channels(efx);
2126 2167
2127 rc = falcon_init_interrupt(efx); 2168 rc = efx_nic_init_interrupt(efx);
2128 if (rc) 2169 if (rc)
2129 goto fail6; 2170 goto fail5;
2130 2171
2131 return 0; 2172 return 0;
2132 2173
2133 fail6: 2174 fail5:
2134 efx_fini_channels(efx); 2175 efx_fini_channels(efx);
2135 efx_fini_port(efx); 2176 efx_fini_port(efx);
2136 fail5:
2137 fail4: 2177 fail4:
2138 efx->board_info.fini(efx); 2178 efx->type->fini(efx);
2139 fail3: 2179 fail3:
2140 efx_fini_napi(efx); 2180 efx_fini_napi(efx);
2141 fail2: 2181 fail2:
@@ -2165,9 +2205,11 @@ static int __devinit efx_pci_probe(struct pci_dev *pci_dev,
2165 net_dev = alloc_etherdev(sizeof(*efx)); 2205 net_dev = alloc_etherdev(sizeof(*efx));
2166 if (!net_dev) 2206 if (!net_dev)
2167 return -ENOMEM; 2207 return -ENOMEM;
2168 net_dev->features |= (NETIF_F_IP_CSUM | NETIF_F_SG | 2208 net_dev->features |= (type->offload_features | NETIF_F_SG |
2169 NETIF_F_HIGHDMA | NETIF_F_TSO | 2209 NETIF_F_HIGHDMA | NETIF_F_TSO |
2170 NETIF_F_GRO); 2210 NETIF_F_GRO);
2211 if (type->offload_features & NETIF_F_V6_CSUM)
2212 net_dev->features |= NETIF_F_TSO6;
2171 /* Mask for features that also apply to VLAN devices */ 2213 /* Mask for features that also apply to VLAN devices */
2172 net_dev->vlan_features |= (NETIF_F_ALL_CSUM | NETIF_F_SG | 2214 net_dev->vlan_features |= (NETIF_F_ALL_CSUM | NETIF_F_SG |
2173 NETIF_F_HIGHDMA | NETIF_F_TSO); 2215 NETIF_F_HIGHDMA | NETIF_F_TSO);
@@ -2219,18 +2261,19 @@ static int __devinit efx_pci_probe(struct pci_dev *pci_dev,
2219 goto fail4; 2261 goto fail4;
2220 } 2262 }
2221 2263
2222 /* Switch to the running state before we expose the device to 2264 /* Switch to the running state before we expose the device to the OS,
2223 * the OS. This is to ensure that the initial gathering of 2265 * so that dev_open()|efx_start_all() will actually start the device */
2224 * MAC stats succeeds. */
2225 efx->state = STATE_RUNNING; 2266 efx->state = STATE_RUNNING;
2226 2267
2227 efx_mtd_probe(efx); /* allowed to fail */
2228
2229 rc = efx_register_netdev(efx); 2268 rc = efx_register_netdev(efx);
2230 if (rc) 2269 if (rc)
2231 goto fail5; 2270 goto fail5;
2232 2271
2233 EFX_LOG(efx, "initialisation successful\n"); 2272 EFX_LOG(efx, "initialisation successful\n");
2273
2274 rtnl_lock();
2275 efx_mtd_probe(efx); /* allowed to fail */
2276 rtnl_unlock();
2234 return 0; 2277 return 0;
2235 2278
2236 fail5: 2279 fail5:
@@ -2246,11 +2289,107 @@ static int __devinit efx_pci_probe(struct pci_dev *pci_dev,
2246 return rc; 2289 return rc;
2247} 2290}
2248 2291
2292static int efx_pm_freeze(struct device *dev)
2293{
2294 struct efx_nic *efx = pci_get_drvdata(to_pci_dev(dev));
2295
2296 efx->state = STATE_FINI;
2297
2298 netif_device_detach(efx->net_dev);
2299
2300 efx_stop_all(efx);
2301 efx_fini_channels(efx);
2302
2303 return 0;
2304}
2305
2306static int efx_pm_thaw(struct device *dev)
2307{
2308 struct efx_nic *efx = pci_get_drvdata(to_pci_dev(dev));
2309
2310 efx->state = STATE_INIT;
2311
2312 efx_init_channels(efx);
2313
2314 mutex_lock(&efx->mac_lock);
2315 efx->phy_op->reconfigure(efx);
2316 mutex_unlock(&efx->mac_lock);
2317
2318 efx_start_all(efx);
2319
2320 netif_device_attach(efx->net_dev);
2321
2322 efx->state = STATE_RUNNING;
2323
2324 efx->type->resume_wol(efx);
2325
2326 return 0;
2327}
2328
2329static int efx_pm_poweroff(struct device *dev)
2330{
2331 struct pci_dev *pci_dev = to_pci_dev(dev);
2332 struct efx_nic *efx = pci_get_drvdata(pci_dev);
2333
2334 efx->type->fini(efx);
2335
2336 efx->reset_pending = RESET_TYPE_NONE;
2337
2338 pci_save_state(pci_dev);
2339 return pci_set_power_state(pci_dev, PCI_D3hot);
2340}
2341
2342/* Used for both resume and restore */
2343static int efx_pm_resume(struct device *dev)
2344{
2345 struct pci_dev *pci_dev = to_pci_dev(dev);
2346 struct efx_nic *efx = pci_get_drvdata(pci_dev);
2347 int rc;
2348
2349 rc = pci_set_power_state(pci_dev, PCI_D0);
2350 if (rc)
2351 return rc;
2352 pci_restore_state(pci_dev);
2353 rc = pci_enable_device(pci_dev);
2354 if (rc)
2355 return rc;
2356 pci_set_master(efx->pci_dev);
2357 rc = efx->type->reset(efx, RESET_TYPE_ALL);
2358 if (rc)
2359 return rc;
2360 rc = efx->type->init(efx);
2361 if (rc)
2362 return rc;
2363 efx_pm_thaw(dev);
2364 return 0;
2365}
2366
2367static int efx_pm_suspend(struct device *dev)
2368{
2369 int rc;
2370
2371 efx_pm_freeze(dev);
2372 rc = efx_pm_poweroff(dev);
2373 if (rc)
2374 efx_pm_resume(dev);
2375 return rc;
2376}
2377
2378static struct dev_pm_ops efx_pm_ops = {
2379 .suspend = efx_pm_suspend,
2380 .resume = efx_pm_resume,
2381 .freeze = efx_pm_freeze,
2382 .thaw = efx_pm_thaw,
2383 .poweroff = efx_pm_poweroff,
2384 .restore = efx_pm_resume,
2385};
2386
2249static struct pci_driver efx_pci_driver = { 2387static struct pci_driver efx_pci_driver = {
2250 .name = EFX_DRIVER_NAME, 2388 .name = EFX_DRIVER_NAME,
2251 .id_table = efx_pci_table, 2389 .id_table = efx_pci_table,
2252 .probe = efx_pci_probe, 2390 .probe = efx_pci_probe,
2253 .remove = efx_pci_remove, 2391 .remove = efx_pci_remove,
2392 .driver.pm = &efx_pm_ops,
2254}; 2393};
2255 2394
2256/************************************************************************** 2395/**************************************************************************
@@ -2314,8 +2453,8 @@ static void __exit efx_exit_module(void)
2314module_init(efx_init_module); 2453module_init(efx_init_module);
2315module_exit(efx_exit_module); 2454module_exit(efx_exit_module);
2316 2455
2317MODULE_AUTHOR("Michael Brown <mbrown@fensystems.co.uk> and " 2456MODULE_AUTHOR("Solarflare Communications and "
2318 "Solarflare Communications"); 2457 "Michael Brown <mbrown@fensystems.co.uk>");
2319MODULE_DESCRIPTION("Solarflare Communications network driver"); 2458MODULE_DESCRIPTION("Solarflare Communications network driver");
2320MODULE_LICENSE("GPL"); 2459MODULE_LICENSE("GPL");
2321MODULE_DEVICE_TABLE(pci, efx_pci_table); 2460MODULE_DEVICE_TABLE(pci, efx_pci_table);