aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/bnx2.c
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2008-10-11 15:39:35 -0400
committerDavid S. Miller <davem@davemloft.net>2008-10-11 15:39:35 -0400
commit56c5d900dbb8e042bfad035d18433476931d8f93 (patch)
tree00b793965beeef10db03e0ff021d2d965c410759 /drivers/net/bnx2.c
parent4dd95b63ae25c5cad6986829b5e8788e9faa0330 (diff)
parentead9d23d803ea3a73766c3cb27bf7563ac8d7266 (diff)
Merge branch 'master' of master.kernel.org:/pub/scm/linux/kernel/git/torvalds/linux-2.6
Conflicts: sound/core/memalloc.c
Diffstat (limited to 'drivers/net/bnx2.c')
-rw-r--r--drivers/net/bnx2.c229
1 files changed, 122 insertions, 107 deletions
diff --git a/drivers/net/bnx2.c b/drivers/net/bnx2.c
index 2486a656f12d..430d430bce29 100644
--- a/drivers/net/bnx2.c
+++ b/drivers/net/bnx2.c
@@ -57,8 +57,8 @@
57 57
58#define DRV_MODULE_NAME "bnx2" 58#define DRV_MODULE_NAME "bnx2"
59#define PFX DRV_MODULE_NAME ": " 59#define PFX DRV_MODULE_NAME ": "
60#define DRV_MODULE_VERSION "1.8.0" 60#define DRV_MODULE_VERSION "1.8.1"
61#define DRV_MODULE_RELDATE "Aug 14, 2008" 61#define DRV_MODULE_RELDATE "Oct 7, 2008"
62 62
63#define RUN_AT(x) (jiffies + (x)) 63#define RUN_AT(x) (jiffies + (x))
64 64
@@ -69,7 +69,7 @@ static char version[] __devinitdata =
69 "Broadcom NetXtreme II Gigabit Ethernet Driver " DRV_MODULE_NAME " v" DRV_MODULE_VERSION " (" DRV_MODULE_RELDATE ")\n"; 69 "Broadcom NetXtreme II Gigabit Ethernet Driver " DRV_MODULE_NAME " v" DRV_MODULE_VERSION " (" DRV_MODULE_RELDATE ")\n";
70 70
71MODULE_AUTHOR("Michael Chan <mchan@broadcom.com>"); 71MODULE_AUTHOR("Michael Chan <mchan@broadcom.com>");
72MODULE_DESCRIPTION("Broadcom NetXtreme II BCM5706/5708/5709 Driver"); 72MODULE_DESCRIPTION("Broadcom NetXtreme II BCM5706/5708/5709/5716 Driver");
73MODULE_LICENSE("GPL"); 73MODULE_LICENSE("GPL");
74MODULE_VERSION(DRV_MODULE_VERSION); 74MODULE_VERSION(DRV_MODULE_VERSION);
75 75
@@ -1127,7 +1127,7 @@ bnx2_init_all_rx_contexts(struct bnx2 *bp)
1127 } 1127 }
1128} 1128}
1129 1129
1130static int 1130static void
1131bnx2_set_mac_link(struct bnx2 *bp) 1131bnx2_set_mac_link(struct bnx2 *bp)
1132{ 1132{
1133 u32 val; 1133 u32 val;
@@ -1193,8 +1193,6 @@ bnx2_set_mac_link(struct bnx2 *bp)
1193 1193
1194 if (CHIP_NUM(bp) == CHIP_NUM_5709) 1194 if (CHIP_NUM(bp) == CHIP_NUM_5709)
1195 bnx2_init_all_rx_contexts(bp); 1195 bnx2_init_all_rx_contexts(bp);
1196
1197 return 0;
1198} 1196}
1199 1197
1200static void 1198static void
@@ -2478,6 +2476,11 @@ bnx2_alloc_rx_page(struct bnx2 *bp, struct bnx2_rx_ring_info *rxr, u16 index)
2478 return -ENOMEM; 2476 return -ENOMEM;
2479 mapping = pci_map_page(bp->pdev, page, 0, PAGE_SIZE, 2477 mapping = pci_map_page(bp->pdev, page, 0, PAGE_SIZE,
2480 PCI_DMA_FROMDEVICE); 2478 PCI_DMA_FROMDEVICE);
2479 if (pci_dma_mapping_error(bp->pdev, mapping)) {
2480 __free_page(page);
2481 return -EIO;
2482 }
2483
2481 rx_pg->page = page; 2484 rx_pg->page = page;
2482 pci_unmap_addr_set(rx_pg, mapping, mapping); 2485 pci_unmap_addr_set(rx_pg, mapping, mapping);
2483 rxbd->rx_bd_haddr_hi = (u64) mapping >> 32; 2486 rxbd->rx_bd_haddr_hi = (u64) mapping >> 32;
@@ -2520,6 +2523,10 @@ bnx2_alloc_rx_skb(struct bnx2 *bp, struct bnx2_rx_ring_info *rxr, u16 index)
2520 2523
2521 mapping = pci_map_single(bp->pdev, skb->data, bp->rx_buf_use_size, 2524 mapping = pci_map_single(bp->pdev, skb->data, bp->rx_buf_use_size,
2522 PCI_DMA_FROMDEVICE); 2525 PCI_DMA_FROMDEVICE);
2526 if (pci_dma_mapping_error(bp->pdev, mapping)) {
2527 dev_kfree_skb(skb);
2528 return -EIO;
2529 }
2523 2530
2524 rx_buf->skb = skb; 2531 rx_buf->skb = skb;
2525 pci_unmap_addr_set(rx_buf, mapping, mapping); 2532 pci_unmap_addr_set(rx_buf, mapping, mapping);
@@ -2594,7 +2601,7 @@ bnx2_tx_int(struct bnx2 *bp, struct bnx2_napi *bnapi, int budget)
2594 sw_cons = txr->tx_cons; 2601 sw_cons = txr->tx_cons;
2595 2602
2596 while (sw_cons != hw_cons) { 2603 while (sw_cons != hw_cons) {
2597 struct sw_bd *tx_buf; 2604 struct sw_tx_bd *tx_buf;
2598 struct sk_buff *skb; 2605 struct sk_buff *skb;
2599 int i, last; 2606 int i, last;
2600 2607
@@ -2619,21 +2626,13 @@ bnx2_tx_int(struct bnx2 *bp, struct bnx2_napi *bnapi, int budget)
2619 } 2626 }
2620 } 2627 }
2621 2628
2622 pci_unmap_single(bp->pdev, pci_unmap_addr(tx_buf, mapping), 2629 skb_dma_unmap(&bp->pdev->dev, skb, DMA_TO_DEVICE);
2623 skb_headlen(skb), PCI_DMA_TODEVICE);
2624 2630
2625 tx_buf->skb = NULL; 2631 tx_buf->skb = NULL;
2626 last = skb_shinfo(skb)->nr_frags; 2632 last = skb_shinfo(skb)->nr_frags;
2627 2633
2628 for (i = 0; i < last; i++) { 2634 for (i = 0; i < last; i++) {
2629 sw_cons = NEXT_TX_BD(sw_cons); 2635 sw_cons = NEXT_TX_BD(sw_cons);
2630
2631 pci_unmap_page(bp->pdev,
2632 pci_unmap_addr(
2633 &txr->tx_buf_ring[TX_RING_IDX(sw_cons)],
2634 mapping),
2635 skb_shinfo(skb)->frags[i].size,
2636 PCI_DMA_TODEVICE);
2637 } 2636 }
2638 2637
2639 sw_cons = NEXT_TX_BD(sw_cons); 2638 sw_cons = NEXT_TX_BD(sw_cons);
@@ -2674,11 +2673,31 @@ bnx2_reuse_rx_skb_pages(struct bnx2 *bp, struct bnx2_rx_ring_info *rxr,
2674{ 2673{
2675 struct sw_pg *cons_rx_pg, *prod_rx_pg; 2674 struct sw_pg *cons_rx_pg, *prod_rx_pg;
2676 struct rx_bd *cons_bd, *prod_bd; 2675 struct rx_bd *cons_bd, *prod_bd;
2677 dma_addr_t mapping;
2678 int i; 2676 int i;
2679 u16 hw_prod = rxr->rx_pg_prod, prod; 2677 u16 hw_prod, prod;
2680 u16 cons = rxr->rx_pg_cons; 2678 u16 cons = rxr->rx_pg_cons;
2681 2679
2680 cons_rx_pg = &rxr->rx_pg_ring[cons];
2681
2682 /* The caller was unable to allocate a new page to replace the
2683 * last one in the frags array, so we need to recycle that page
2684 * and then free the skb.
2685 */
2686 if (skb) {
2687 struct page *page;
2688 struct skb_shared_info *shinfo;
2689
2690 shinfo = skb_shinfo(skb);
2691 shinfo->nr_frags--;
2692 page = shinfo->frags[shinfo->nr_frags].page;
2693 shinfo->frags[shinfo->nr_frags].page = NULL;
2694
2695 cons_rx_pg->page = page;
2696 dev_kfree_skb(skb);
2697 }
2698
2699 hw_prod = rxr->rx_pg_prod;
2700
2682 for (i = 0; i < count; i++) { 2701 for (i = 0; i < count; i++) {
2683 prod = RX_PG_RING_IDX(hw_prod); 2702 prod = RX_PG_RING_IDX(hw_prod);
2684 2703
@@ -2687,20 +2706,6 @@ bnx2_reuse_rx_skb_pages(struct bnx2 *bp, struct bnx2_rx_ring_info *rxr,
2687 cons_bd = &rxr->rx_pg_desc_ring[RX_RING(cons)][RX_IDX(cons)]; 2706 cons_bd = &rxr->rx_pg_desc_ring[RX_RING(cons)][RX_IDX(cons)];
2688 prod_bd = &rxr->rx_pg_desc_ring[RX_RING(prod)][RX_IDX(prod)]; 2707 prod_bd = &rxr->rx_pg_desc_ring[RX_RING(prod)][RX_IDX(prod)];
2689 2708
2690 if (i == 0 && skb) {
2691 struct page *page;
2692 struct skb_shared_info *shinfo;
2693
2694 shinfo = skb_shinfo(skb);
2695 shinfo->nr_frags--;
2696 page = shinfo->frags[shinfo->nr_frags].page;
2697 shinfo->frags[shinfo->nr_frags].page = NULL;
2698 mapping = pci_map_page(bp->pdev, page, 0, PAGE_SIZE,
2699 PCI_DMA_FROMDEVICE);
2700 cons_rx_pg->page = page;
2701 pci_unmap_addr_set(cons_rx_pg, mapping, mapping);
2702 dev_kfree_skb(skb);
2703 }
2704 if (prod != cons) { 2709 if (prod != cons) {
2705 prod_rx_pg->page = cons_rx_pg->page; 2710 prod_rx_pg->page = cons_rx_pg->page;
2706 cons_rx_pg->page = NULL; 2711 cons_rx_pg->page = NULL;
@@ -2786,6 +2791,8 @@ bnx2_rx_skb(struct bnx2 *bp, struct bnx2_rx_ring_info *rxr, struct sk_buff *skb,
2786 skb_put(skb, hdr_len); 2791 skb_put(skb, hdr_len);
2787 2792
2788 for (i = 0; i < pages; i++) { 2793 for (i = 0; i < pages; i++) {
2794 dma_addr_t mapping_old;
2795
2789 frag_len = min(frag_size, (unsigned int) PAGE_SIZE); 2796 frag_len = min(frag_size, (unsigned int) PAGE_SIZE);
2790 if (unlikely(frag_len <= 4)) { 2797 if (unlikely(frag_len <= 4)) {
2791 unsigned int tail = 4 - frag_len; 2798 unsigned int tail = 4 - frag_len;
@@ -2808,9 +2815,10 @@ bnx2_rx_skb(struct bnx2 *bp, struct bnx2_rx_ring_info *rxr, struct sk_buff *skb,
2808 } 2815 }
2809 rx_pg = &rxr->rx_pg_ring[pg_cons]; 2816 rx_pg = &rxr->rx_pg_ring[pg_cons];
2810 2817
2811 pci_unmap_page(bp->pdev, pci_unmap_addr(rx_pg, mapping), 2818 /* Don't unmap yet. If we're unable to allocate a new
2812 PAGE_SIZE, PCI_DMA_FROMDEVICE); 2819 * page, we need to recycle the page and the DMA addr.
2813 2820 */
2821 mapping_old = pci_unmap_addr(rx_pg, mapping);
2814 if (i == pages - 1) 2822 if (i == pages - 1)
2815 frag_len -= 4; 2823 frag_len -= 4;
2816 2824
@@ -2827,6 +2835,9 @@ bnx2_rx_skb(struct bnx2 *bp, struct bnx2_rx_ring_info *rxr, struct sk_buff *skb,
2827 return err; 2835 return err;
2828 } 2836 }
2829 2837
2838 pci_unmap_page(bp->pdev, mapping_old,
2839 PAGE_SIZE, PCI_DMA_FROMDEVICE);
2840
2830 frag_size -= frag_len; 2841 frag_size -= frag_len;
2831 skb->data_len += frag_len; 2842 skb->data_len += frag_len;
2832 skb->truesize += frag_len; 2843 skb->truesize += frag_len;
@@ -3250,6 +3261,9 @@ bnx2_set_rx_mode(struct net_device *dev)
3250 struct dev_addr_list *uc_ptr; 3261 struct dev_addr_list *uc_ptr;
3251 int i; 3262 int i;
3252 3263
3264 if (!netif_running(dev))
3265 return;
3266
3253 spin_lock_bh(&bp->phy_lock); 3267 spin_lock_bh(&bp->phy_lock);
3254 3268
3255 rx_mode = bp->rx_mode & ~(BNX2_EMAC_RX_MODE_PROMISCUOUS | 3269 rx_mode = bp->rx_mode & ~(BNX2_EMAC_RX_MODE_PROMISCUOUS |
@@ -4970,31 +4984,20 @@ bnx2_free_tx_skbs(struct bnx2 *bp)
4970 continue; 4984 continue;
4971 4985
4972 for (j = 0; j < TX_DESC_CNT; ) { 4986 for (j = 0; j < TX_DESC_CNT; ) {
4973 struct sw_bd *tx_buf = &txr->tx_buf_ring[j]; 4987 struct sw_tx_bd *tx_buf = &txr->tx_buf_ring[j];
4974 struct sk_buff *skb = tx_buf->skb; 4988 struct sk_buff *skb = tx_buf->skb;
4975 int k, last;
4976 4989
4977 if (skb == NULL) { 4990 if (skb == NULL) {
4978 j++; 4991 j++;
4979 continue; 4992 continue;
4980 } 4993 }
4981 4994
4982 pci_unmap_single(bp->pdev, 4995 skb_dma_unmap(&bp->pdev->dev, skb, DMA_TO_DEVICE);
4983 pci_unmap_addr(tx_buf, mapping),
4984 skb_headlen(skb), PCI_DMA_TODEVICE);
4985 4996
4986 tx_buf->skb = NULL; 4997 tx_buf->skb = NULL;
4987 4998
4988 last = skb_shinfo(skb)->nr_frags; 4999 j += skb_shinfo(skb)->nr_frags + 1;
4989 for (k = 0; k < last; k++) {
4990 tx_buf = &txr->tx_buf_ring[j + k + 1];
4991 pci_unmap_page(bp->pdev,
4992 pci_unmap_addr(tx_buf, mapping),
4993 skb_shinfo(skb)->frags[j].size,
4994 PCI_DMA_TODEVICE);
4995 }
4996 dev_kfree_skb(skb); 5000 dev_kfree_skb(skb);
4997 j += k + 1;
4998 } 5001 }
4999 } 5002 }
5000} 5003}
@@ -5075,6 +5078,21 @@ bnx2_init_nic(struct bnx2 *bp, int reset_phy)
5075} 5078}
5076 5079
5077static int 5080static int
5081bnx2_shutdown_chip(struct bnx2 *bp)
5082{
5083 u32 reset_code;
5084
5085 if (bp->flags & BNX2_FLAG_NO_WOL)
5086 reset_code = BNX2_DRV_MSG_CODE_UNLOAD_LNK_DN;
5087 else if (bp->wol)
5088 reset_code = BNX2_DRV_MSG_CODE_SUSPEND_WOL;
5089 else
5090 reset_code = BNX2_DRV_MSG_CODE_SUSPEND_NO_WOL;
5091
5092 return bnx2_reset_chip(bp, reset_code);
5093}
5094
5095static int
5078bnx2_test_registers(struct bnx2 *bp) 5096bnx2_test_registers(struct bnx2 *bp)
5079{ 5097{
5080 int ret; 5098 int ret;
@@ -5357,8 +5375,11 @@ bnx2_run_loopback(struct bnx2 *bp, int loopback_mode)
5357 for (i = 14; i < pkt_size; i++) 5375 for (i = 14; i < pkt_size; i++)
5358 packet[i] = (unsigned char) (i & 0xff); 5376 packet[i] = (unsigned char) (i & 0xff);
5359 5377
5360 map = pci_map_single(bp->pdev, skb->data, pkt_size, 5378 if (skb_dma_map(&bp->pdev->dev, skb, DMA_TO_DEVICE)) {
5361 PCI_DMA_TODEVICE); 5379 dev_kfree_skb(skb);
5380 return -EIO;
5381 }
5382 map = skb_shinfo(skb)->dma_maps[0];
5362 5383
5363 REG_WR(bp, BNX2_HC_COMMAND, 5384 REG_WR(bp, BNX2_HC_COMMAND,
5364 bp->hc_cmd | BNX2_HC_COMMAND_COAL_NOW_WO_INT); 5385 bp->hc_cmd | BNX2_HC_COMMAND_COAL_NOW_WO_INT);
@@ -5393,7 +5414,7 @@ bnx2_run_loopback(struct bnx2 *bp, int loopback_mode)
5393 5414
5394 udelay(5); 5415 udelay(5);
5395 5416
5396 pci_unmap_single(bp->pdev, map, pkt_size, PCI_DMA_TODEVICE); 5417 skb_dma_unmap(&bp->pdev->dev, skb, DMA_TO_DEVICE);
5397 dev_kfree_skb(skb); 5418 dev_kfree_skb(skb);
5398 5419
5399 if (bnx2_get_hw_tx_cons(tx_napi) != txr->tx_prod) 5420 if (bnx2_get_hw_tx_cons(tx_napi) != txr->tx_prod)
@@ -5508,6 +5529,9 @@ bnx2_test_link(struct bnx2 *bp)
5508{ 5529{
5509 u32 bmsr; 5530 u32 bmsr;
5510 5531
5532 if (!netif_running(bp->dev))
5533 return -ENODEV;
5534
5511 if (bp->phy_flags & BNX2_PHY_FLAG_REMOTE_PHY_CAP) { 5535 if (bp->phy_flags & BNX2_PHY_FLAG_REMOTE_PHY_CAP) {
5512 if (bp->link_up) 5536 if (bp->link_up)
5513 return 0; 5537 return 0;
@@ -5600,7 +5624,7 @@ bnx2_5706_serdes_timer(struct bnx2 *bp)
5600 } else if ((bp->link_up == 0) && (bp->autoneg & AUTONEG_SPEED)) { 5624 } else if ((bp->link_up == 0) && (bp->autoneg & AUTONEG_SPEED)) {
5601 u32 bmcr; 5625 u32 bmcr;
5602 5626
5603 bp->current_interval = bp->timer_interval; 5627 bp->current_interval = BNX2_TIMER_INTERVAL;
5604 5628
5605 bnx2_read_phy(bp, bp->mii_bmcr, &bmcr); 5629 bnx2_read_phy(bp, bp->mii_bmcr, &bmcr);
5606 5630
@@ -5629,7 +5653,7 @@ bnx2_5706_serdes_timer(struct bnx2 *bp)
5629 bp->phy_flags &= ~BNX2_PHY_FLAG_PARALLEL_DETECT; 5653 bp->phy_flags &= ~BNX2_PHY_FLAG_PARALLEL_DETECT;
5630 } 5654 }
5631 } else 5655 } else
5632 bp->current_interval = bp->timer_interval; 5656 bp->current_interval = BNX2_TIMER_INTERVAL;
5633 5657
5634 if (check_link) { 5658 if (check_link) {
5635 u32 val; 5659 u32 val;
@@ -5674,11 +5698,11 @@ bnx2_5708_serdes_timer(struct bnx2 *bp)
5674 } else { 5698 } else {
5675 bnx2_disable_forced_2g5(bp); 5699 bnx2_disable_forced_2g5(bp);
5676 bp->serdes_an_pending = 2; 5700 bp->serdes_an_pending = 2;
5677 bp->current_interval = bp->timer_interval; 5701 bp->current_interval = BNX2_TIMER_INTERVAL;
5678 } 5702 }
5679 5703
5680 } else 5704 } else
5681 bp->current_interval = bp->timer_interval; 5705 bp->current_interval = BNX2_TIMER_INTERVAL;
5682 5706
5683 spin_unlock(&bp->phy_lock); 5707 spin_unlock(&bp->phy_lock);
5684} 5708}
@@ -5951,13 +5975,14 @@ bnx2_start_xmit(struct sk_buff *skb, struct net_device *dev)
5951 struct bnx2 *bp = netdev_priv(dev); 5975 struct bnx2 *bp = netdev_priv(dev);
5952 dma_addr_t mapping; 5976 dma_addr_t mapping;
5953 struct tx_bd *txbd; 5977 struct tx_bd *txbd;
5954 struct sw_bd *tx_buf; 5978 struct sw_tx_bd *tx_buf;
5955 u32 len, vlan_tag_flags, last_frag, mss; 5979 u32 len, vlan_tag_flags, last_frag, mss;
5956 u16 prod, ring_prod; 5980 u16 prod, ring_prod;
5957 int i; 5981 int i;
5958 struct bnx2_napi *bnapi; 5982 struct bnx2_napi *bnapi;
5959 struct bnx2_tx_ring_info *txr; 5983 struct bnx2_tx_ring_info *txr;
5960 struct netdev_queue *txq; 5984 struct netdev_queue *txq;
5985 struct skb_shared_info *sp;
5961 5986
5962 /* Determine which tx ring we will be placed on */ 5987 /* Determine which tx ring we will be placed on */
5963 i = skb_get_queue_mapping(skb); 5988 i = skb_get_queue_mapping(skb);
@@ -5989,7 +6014,7 @@ bnx2_start_xmit(struct sk_buff *skb, struct net_device *dev)
5989 } 6014 }
5990#endif 6015#endif
5991 if ((mss = skb_shinfo(skb)->gso_size)) { 6016 if ((mss = skb_shinfo(skb)->gso_size)) {
5992 u32 tcp_opt_len, ip_tcp_len; 6017 u32 tcp_opt_len;
5993 struct iphdr *iph; 6018 struct iphdr *iph;
5994 6019
5995 vlan_tag_flags |= TX_BD_FLAGS_SW_LSO; 6020 vlan_tag_flags |= TX_BD_FLAGS_SW_LSO;
@@ -6013,21 +6038,7 @@ bnx2_start_xmit(struct sk_buff *skb, struct net_device *dev)
6013 mss |= (tcp_off & 0xc) << TX_BD_TCP6_OFF2_SHL; 6038 mss |= (tcp_off & 0xc) << TX_BD_TCP6_OFF2_SHL;
6014 } 6039 }
6015 } else { 6040 } else {
6016 if (skb_header_cloned(skb) &&
6017 pskb_expand_head(skb, 0, 0, GFP_ATOMIC)) {
6018 dev_kfree_skb(skb);
6019 return NETDEV_TX_OK;
6020 }
6021
6022 ip_tcp_len = ip_hdrlen(skb) + sizeof(struct tcphdr);
6023
6024 iph = ip_hdr(skb); 6041 iph = ip_hdr(skb);
6025 iph->check = 0;
6026 iph->tot_len = htons(mss + ip_tcp_len + tcp_opt_len);
6027 tcp_hdr(skb)->check = ~csum_tcpudp_magic(iph->saddr,
6028 iph->daddr, 0,
6029 IPPROTO_TCP,
6030 0);
6031 if (tcp_opt_len || (iph->ihl > 5)) { 6042 if (tcp_opt_len || (iph->ihl > 5)) {
6032 vlan_tag_flags |= ((iph->ihl - 5) + 6043 vlan_tag_flags |= ((iph->ihl - 5) +
6033 (tcp_opt_len >> 2)) << 8; 6044 (tcp_opt_len >> 2)) << 8;
@@ -6036,11 +6047,16 @@ bnx2_start_xmit(struct sk_buff *skb, struct net_device *dev)
6036 } else 6047 } else
6037 mss = 0; 6048 mss = 0;
6038 6049
6039 mapping = pci_map_single(bp->pdev, skb->data, len, PCI_DMA_TODEVICE); 6050 if (skb_dma_map(&bp->pdev->dev, skb, DMA_TO_DEVICE)) {
6051 dev_kfree_skb(skb);
6052 return NETDEV_TX_OK;
6053 }
6054
6055 sp = skb_shinfo(skb);
6056 mapping = sp->dma_maps[0];
6040 6057
6041 tx_buf = &txr->tx_buf_ring[ring_prod]; 6058 tx_buf = &txr->tx_buf_ring[ring_prod];
6042 tx_buf->skb = skb; 6059 tx_buf->skb = skb;
6043 pci_unmap_addr_set(tx_buf, mapping, mapping);
6044 6060
6045 txbd = &txr->tx_desc_ring[ring_prod]; 6061 txbd = &txr->tx_desc_ring[ring_prod];
6046 6062
@@ -6059,10 +6075,7 @@ bnx2_start_xmit(struct sk_buff *skb, struct net_device *dev)
6059 txbd = &txr->tx_desc_ring[ring_prod]; 6075 txbd = &txr->tx_desc_ring[ring_prod];
6060 6076
6061 len = frag->size; 6077 len = frag->size;
6062 mapping = pci_map_page(bp->pdev, frag->page, frag->page_offset, 6078 mapping = sp->dma_maps[i + 1];
6063 len, PCI_DMA_TODEVICE);
6064 pci_unmap_addr_set(&txr->tx_buf_ring[ring_prod],
6065 mapping, mapping);
6066 6079
6067 txbd->tx_bd_haddr_hi = (u64) mapping >> 32; 6080 txbd->tx_bd_haddr_hi = (u64) mapping >> 32;
6068 txbd->tx_bd_haddr_lo = (u64) mapping & 0xffffffff; 6081 txbd->tx_bd_haddr_lo = (u64) mapping & 0xffffffff;
@@ -6097,20 +6110,13 @@ static int
6097bnx2_close(struct net_device *dev) 6110bnx2_close(struct net_device *dev)
6098{ 6111{
6099 struct bnx2 *bp = netdev_priv(dev); 6112 struct bnx2 *bp = netdev_priv(dev);
6100 u32 reset_code;
6101 6113
6102 cancel_work_sync(&bp->reset_task); 6114 cancel_work_sync(&bp->reset_task);
6103 6115
6104 bnx2_disable_int_sync(bp); 6116 bnx2_disable_int_sync(bp);
6105 bnx2_napi_disable(bp); 6117 bnx2_napi_disable(bp);
6106 del_timer_sync(&bp->timer); 6118 del_timer_sync(&bp->timer);
6107 if (bp->flags & BNX2_FLAG_NO_WOL) 6119 bnx2_shutdown_chip(bp);
6108 reset_code = BNX2_DRV_MSG_CODE_UNLOAD_LNK_DN;
6109 else if (bp->wol)
6110 reset_code = BNX2_DRV_MSG_CODE_SUSPEND_WOL;
6111 else
6112 reset_code = BNX2_DRV_MSG_CODE_SUSPEND_NO_WOL;
6113 bnx2_reset_chip(bp, reset_code);
6114 bnx2_free_irq(bp); 6120 bnx2_free_irq(bp);
6115 bnx2_free_skbs(bp); 6121 bnx2_free_skbs(bp);
6116 bnx2_free_mem(bp); 6122 bnx2_free_mem(bp);
@@ -6479,6 +6485,9 @@ bnx2_nway_reset(struct net_device *dev)
6479 struct bnx2 *bp = netdev_priv(dev); 6485 struct bnx2 *bp = netdev_priv(dev);
6480 u32 bmcr; 6486 u32 bmcr;
6481 6487
6488 if (!netif_running(dev))
6489 return -EAGAIN;
6490
6482 if (!(bp->autoneg & AUTONEG_SPEED)) { 6491 if (!(bp->autoneg & AUTONEG_SPEED)) {
6483 return -EINVAL; 6492 return -EINVAL;
6484 } 6493 }
@@ -6534,6 +6543,9 @@ bnx2_get_eeprom(struct net_device *dev, struct ethtool_eeprom *eeprom,
6534 struct bnx2 *bp = netdev_priv(dev); 6543 struct bnx2 *bp = netdev_priv(dev);
6535 int rc; 6544 int rc;
6536 6545
6546 if (!netif_running(dev))
6547 return -EAGAIN;
6548
6537 /* parameters already validated in ethtool_get_eeprom */ 6549 /* parameters already validated in ethtool_get_eeprom */
6538 6550
6539 rc = bnx2_nvram_read(bp, eeprom->offset, eebuf, eeprom->len); 6551 rc = bnx2_nvram_read(bp, eeprom->offset, eebuf, eeprom->len);
@@ -6548,6 +6560,9 @@ bnx2_set_eeprom(struct net_device *dev, struct ethtool_eeprom *eeprom,
6548 struct bnx2 *bp = netdev_priv(dev); 6560 struct bnx2 *bp = netdev_priv(dev);
6549 int rc; 6561 int rc;
6550 6562
6563 if (!netif_running(dev))
6564 return -EAGAIN;
6565
6551 /* parameters already validated in ethtool_set_eeprom */ 6566 /* parameters already validated in ethtool_set_eeprom */
6552 6567
6553 rc = bnx2_nvram_write(bp, eeprom->offset, eebuf, eeprom->len); 6568 rc = bnx2_nvram_write(bp, eeprom->offset, eebuf, eeprom->len);
@@ -6712,11 +6727,11 @@ bnx2_set_pauseparam(struct net_device *dev, struct ethtool_pauseparam *epause)
6712 bp->autoneg &= ~AUTONEG_FLOW_CTRL; 6727 bp->autoneg &= ~AUTONEG_FLOW_CTRL;
6713 } 6728 }
6714 6729
6715 spin_lock_bh(&bp->phy_lock); 6730 if (netif_running(dev)) {
6716 6731 spin_lock_bh(&bp->phy_lock);
6717 bnx2_setup_phy(bp, bp->phy_port); 6732 bnx2_setup_phy(bp, bp->phy_port);
6718 6733 spin_unlock_bh(&bp->phy_lock);
6719 spin_unlock_bh(&bp->phy_lock); 6734 }
6720 6735
6721 return 0; 6736 return 0;
6722} 6737}
@@ -6907,6 +6922,8 @@ bnx2_self_test(struct net_device *dev, struct ethtool_test *etest, u64 *buf)
6907{ 6922{
6908 struct bnx2 *bp = netdev_priv(dev); 6923 struct bnx2 *bp = netdev_priv(dev);
6909 6924
6925 bnx2_set_power_state(bp, PCI_D0);
6926
6910 memset(buf, 0, sizeof(u64) * BNX2_NUM_TESTS); 6927 memset(buf, 0, sizeof(u64) * BNX2_NUM_TESTS);
6911 if (etest->flags & ETH_TEST_FL_OFFLINE) { 6928 if (etest->flags & ETH_TEST_FL_OFFLINE) {
6912 int i; 6929 int i;
@@ -6926,9 +6943,8 @@ bnx2_self_test(struct net_device *dev, struct ethtool_test *etest, u64 *buf)
6926 if ((buf[2] = bnx2_test_loopback(bp)) != 0) 6943 if ((buf[2] = bnx2_test_loopback(bp)) != 0)
6927 etest->flags |= ETH_TEST_FL_FAILED; 6944 etest->flags |= ETH_TEST_FL_FAILED;
6928 6945
6929 if (!netif_running(bp->dev)) { 6946 if (!netif_running(bp->dev))
6930 bnx2_reset_chip(bp, BNX2_DRV_MSG_CODE_RESET); 6947 bnx2_shutdown_chip(bp);
6931 }
6932 else { 6948 else {
6933 bnx2_init_nic(bp, 1); 6949 bnx2_init_nic(bp, 1);
6934 bnx2_netif_start(bp); 6950 bnx2_netif_start(bp);
@@ -6956,6 +6972,8 @@ bnx2_self_test(struct net_device *dev, struct ethtool_test *etest, u64 *buf)
6956 etest->flags |= ETH_TEST_FL_FAILED; 6972 etest->flags |= ETH_TEST_FL_FAILED;
6957 6973
6958 } 6974 }
6975 if (!netif_running(bp->dev))
6976 bnx2_set_power_state(bp, PCI_D3hot);
6959} 6977}
6960 6978
6961static void 6979static void
@@ -7021,6 +7039,8 @@ bnx2_phys_id(struct net_device *dev, u32 data)
7021 int i; 7039 int i;
7022 u32 save; 7040 u32 save;
7023 7041
7042 bnx2_set_power_state(bp, PCI_D0);
7043
7024 if (data == 0) 7044 if (data == 0)
7025 data = 2; 7045 data = 2;
7026 7046
@@ -7045,6 +7065,10 @@ bnx2_phys_id(struct net_device *dev, u32 data)
7045 } 7065 }
7046 REG_WR(bp, BNX2_EMAC_LED, 0); 7066 REG_WR(bp, BNX2_EMAC_LED, 0);
7047 REG_WR(bp, BNX2_MISC_CFG, save); 7067 REG_WR(bp, BNX2_MISC_CFG, save);
7068
7069 if (!netif_running(dev))
7070 bnx2_set_power_state(bp, PCI_D3hot);
7071
7048 return 0; 7072 return 0;
7049} 7073}
7050 7074
@@ -7516,8 +7540,7 @@ bnx2_init_board(struct pci_dev *pdev, struct net_device *dev)
7516 7540
7517 bp->stats_ticks = USEC_PER_SEC & BNX2_HC_STATS_TICKS_HC_STAT_TICKS; 7541 bp->stats_ticks = USEC_PER_SEC & BNX2_HC_STATS_TICKS_HC_STAT_TICKS;
7518 7542
7519 bp->timer_interval = HZ; 7543 bp->current_interval = BNX2_TIMER_INTERVAL;
7520 bp->current_interval = HZ;
7521 7544
7522 bp->phy_addr = 1; 7545 bp->phy_addr = 1;
7523 7546
@@ -7607,7 +7630,7 @@ bnx2_init_board(struct pci_dev *pdev, struct net_device *dev)
7607 bp->req_flow_ctrl = FLOW_CTRL_RX | FLOW_CTRL_TX; 7630 bp->req_flow_ctrl = FLOW_CTRL_RX | FLOW_CTRL_TX;
7608 7631
7609 init_timer(&bp->timer); 7632 init_timer(&bp->timer);
7610 bp->timer.expires = RUN_AT(bp->timer_interval); 7633 bp->timer.expires = RUN_AT(BNX2_TIMER_INTERVAL);
7611 bp->timer.data = (unsigned long) bp; 7634 bp->timer.data = (unsigned long) bp;
7612 bp->timer.function = bnx2_timer; 7635 bp->timer.function = bnx2_timer;
7613 7636
@@ -7720,7 +7743,6 @@ bnx2_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
7720 7743
7721 memcpy(dev->dev_addr, bp->mac_addr, 6); 7744 memcpy(dev->dev_addr, bp->mac_addr, 6);
7722 memcpy(dev->perm_addr, bp->mac_addr, 6); 7745 memcpy(dev->perm_addr, bp->mac_addr, 6);
7723 bp->name = board_info[ent->driver_data].name;
7724 7746
7725 dev->features |= NETIF_F_IP_CSUM | NETIF_F_SG; 7747 dev->features |= NETIF_F_IP_CSUM | NETIF_F_SG;
7726 if (CHIP_NUM(bp) == CHIP_NUM_5709) 7748 if (CHIP_NUM(bp) == CHIP_NUM_5709)
@@ -7747,7 +7769,7 @@ bnx2_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
7747 printk(KERN_INFO "%s: %s (%c%d) %s found at mem %lx, " 7769 printk(KERN_INFO "%s: %s (%c%d) %s found at mem %lx, "
7748 "IRQ %d, node addr %s\n", 7770 "IRQ %d, node addr %s\n",
7749 dev->name, 7771 dev->name,
7750 bp->name, 7772 board_info[ent->driver_data].name,
7751 ((CHIP_ID(bp) & 0xf000) >> 12) + 'A', 7773 ((CHIP_ID(bp) & 0xf000) >> 12) + 'A',
7752 ((CHIP_ID(bp) & 0x0ff0) >> 4), 7774 ((CHIP_ID(bp) & 0x0ff0) >> 4),
7753 bnx2_bus_string(bp, str), 7775 bnx2_bus_string(bp, str),
@@ -7781,7 +7803,6 @@ bnx2_suspend(struct pci_dev *pdev, pm_message_t state)
7781{ 7803{
7782 struct net_device *dev = pci_get_drvdata(pdev); 7804 struct net_device *dev = pci_get_drvdata(pdev);
7783 struct bnx2 *bp = netdev_priv(dev); 7805 struct bnx2 *bp = netdev_priv(dev);
7784 u32 reset_code;
7785 7806
7786 /* PCI register 4 needs to be saved whether netif_running() or not. 7807 /* PCI register 4 needs to be saved whether netif_running() or not.
7787 * MSI address and data need to be saved if using MSI and 7808 * MSI address and data need to be saved if using MSI and
@@ -7795,13 +7816,7 @@ bnx2_suspend(struct pci_dev *pdev, pm_message_t state)
7795 bnx2_netif_stop(bp); 7816 bnx2_netif_stop(bp);
7796 netif_device_detach(dev); 7817 netif_device_detach(dev);
7797 del_timer_sync(&bp->timer); 7818 del_timer_sync(&bp->timer);
7798 if (bp->flags & BNX2_FLAG_NO_WOL) 7819 bnx2_shutdown_chip(bp);
7799 reset_code = BNX2_DRV_MSG_CODE_UNLOAD_LNK_DN;
7800 else if (bp->wol)
7801 reset_code = BNX2_DRV_MSG_CODE_SUSPEND_WOL;
7802 else
7803 reset_code = BNX2_DRV_MSG_CODE_SUSPEND_NO_WOL;
7804 bnx2_reset_chip(bp, reset_code);
7805 bnx2_free_skbs(bp); 7820 bnx2_free_skbs(bp);
7806 bnx2_set_power_state(bp, pci_choose_state(pdev, state)); 7821 bnx2_set_power_state(bp, pci_choose_state(pdev, state));
7807 return 0; 7822 return 0;