aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/sky2.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/sky2.c')
-rw-r--r--drivers/net/sky2.c116
1 files changed, 76 insertions, 40 deletions
diff --git a/drivers/net/sky2.c b/drivers/net/sky2.c
index 0a3203465415..7967240534d5 100644
--- a/drivers/net/sky2.c
+++ b/drivers/net/sky2.c
@@ -52,7 +52,7 @@
52#include "sky2.h" 52#include "sky2.h"
53 53
54#define DRV_NAME "sky2" 54#define DRV_NAME "sky2"
55#define DRV_VERSION "1.18" 55#define DRV_VERSION "1.19"
56#define PFX DRV_NAME " " 56#define PFX DRV_NAME " "
57 57
58/* 58/*
@@ -296,10 +296,10 @@ static const u16 copper_fc_adv[] = {
296 296
297/* flow control to advertise bits when using 1000BaseX */ 297/* flow control to advertise bits when using 1000BaseX */
298static const u16 fiber_fc_adv[] = { 298static const u16 fiber_fc_adv[] = {
299 [FC_BOTH] = PHY_M_P_BOTH_MD_X, 299 [FC_NONE] = PHY_M_P_NO_PAUSE_X,
300 [FC_TX] = PHY_M_P_ASYM_MD_X, 300 [FC_TX] = PHY_M_P_ASYM_MD_X,
301 [FC_RX] = PHY_M_P_SYM_MD_X, 301 [FC_RX] = PHY_M_P_SYM_MD_X,
302 [FC_NONE] = PHY_M_P_NO_PAUSE_X, 302 [FC_BOTH] = PHY_M_P_BOTH_MD_X,
303}; 303};
304 304
305/* flow control to GMA disable bits */ 305/* flow control to GMA disable bits */
@@ -606,20 +606,19 @@ static void sky2_phy_power(struct sky2_hw *hw, unsigned port, int onoff)
606{ 606{
607 struct pci_dev *pdev = hw->pdev; 607 struct pci_dev *pdev = hw->pdev;
608 u32 reg1; 608 u32 reg1;
609 static const u32 phy_power[] 609 static const u32 phy_power[] = { PCI_Y2_PHY1_POWD, PCI_Y2_PHY2_POWD };
610 = { PCI_Y2_PHY1_POWD, PCI_Y2_PHY2_POWD }; 610 static const u32 coma_mode[] = { PCI_Y2_PHY1_COMA, PCI_Y2_PHY2_COMA };
611
612 /* looks like this XL is back asswards .. */
613 if (hw->chip_id == CHIP_ID_YUKON_XL && hw->chip_rev > 1)
614 onoff = !onoff;
615 611
616 pci_read_config_dword(pdev, PCI_DEV_REG1, &reg1); 612 pci_read_config_dword(pdev, PCI_DEV_REG1, &reg1);
613 /* Turn on/off phy power saving */
617 if (onoff) 614 if (onoff)
618 /* Turn off phy power saving */
619 reg1 &= ~phy_power[port]; 615 reg1 &= ~phy_power[port];
620 else 616 else
621 reg1 |= phy_power[port]; 617 reg1 |= phy_power[port];
622 618
619 if (onoff && hw->chip_id == CHIP_ID_YUKON_XL && hw->chip_rev > 1)
620 reg1 |= coma_mode[port];
621
623 pci_write_config_dword(pdev, PCI_DEV_REG1, reg1); 622 pci_write_config_dword(pdev, PCI_DEV_REG1, reg1);
624 pci_read_config_dword(pdev, PCI_DEV_REG1, &reg1); 623 pci_read_config_dword(pdev, PCI_DEV_REG1, &reg1);
625 624
@@ -1636,8 +1635,8 @@ static void sky2_tx_complete(struct sky2_port *sky2, u16 done)
1636 printk(KERN_DEBUG "%s: tx done %u\n", 1635 printk(KERN_DEBUG "%s: tx done %u\n",
1637 dev->name, idx); 1636 dev->name, idx);
1638 1637
1639 sky2->net_stats.tx_packets++; 1638 dev->stats.tx_packets++;
1640 sky2->net_stats.tx_bytes += re->skb->len; 1639 dev->stats.tx_bytes += re->skb->len;
1641 1640
1642 dev_kfree_skb_any(re->skb); 1641 dev_kfree_skb_any(re->skb);
1643 sky2->tx_next = RING_NEXT(idx, TX_RING_SIZE); 1642 sky2->tx_next = RING_NEXT(idx, TX_RING_SIZE);
@@ -2205,16 +2204,16 @@ resubmit:
2205len_error: 2204len_error:
2206 /* Truncation of overlength packets 2205 /* Truncation of overlength packets
2207 causes PHY length to not match MAC length */ 2206 causes PHY length to not match MAC length */
2208 ++sky2->net_stats.rx_length_errors; 2207 ++dev->stats.rx_length_errors;
2209 if (netif_msg_rx_err(sky2) && net_ratelimit()) 2208 if (netif_msg_rx_err(sky2) && net_ratelimit())
2210 pr_info(PFX "%s: rx length error: status %#x length %d\n", 2209 pr_info(PFX "%s: rx length error: status %#x length %d\n",
2211 dev->name, status, length); 2210 dev->name, status, length);
2212 goto resubmit; 2211 goto resubmit;
2213 2212
2214error: 2213error:
2215 ++sky2->net_stats.rx_errors; 2214 ++dev->stats.rx_errors;
2216 if (status & GMR_FS_RX_FF_OV) { 2215 if (status & GMR_FS_RX_FF_OV) {
2217 sky2->net_stats.rx_over_errors++; 2216 dev->stats.rx_over_errors++;
2218 goto resubmit; 2217 goto resubmit;
2219 } 2218 }
2220 2219
@@ -2223,11 +2222,11 @@ error:
2223 dev->name, status, length); 2222 dev->name, status, length);
2224 2223
2225 if (status & (GMR_FS_LONG_ERR | GMR_FS_UN_SIZE)) 2224 if (status & (GMR_FS_LONG_ERR | GMR_FS_UN_SIZE))
2226 sky2->net_stats.rx_length_errors++; 2225 dev->stats.rx_length_errors++;
2227 if (status & GMR_FS_FRAGMENT) 2226 if (status & GMR_FS_FRAGMENT)
2228 sky2->net_stats.rx_frame_errors++; 2227 dev->stats.rx_frame_errors++;
2229 if (status & GMR_FS_CRC_ERR) 2228 if (status & GMR_FS_CRC_ERR)
2230 sky2->net_stats.rx_crc_errors++; 2229 dev->stats.rx_crc_errors++;
2231 2230
2232 goto resubmit; 2231 goto resubmit;
2233} 2232}
@@ -2272,7 +2271,7 @@ static int sky2_status_intr(struct sky2_hw *hw, int to_do, u16 idx)
2272 ++rx[port]; 2271 ++rx[port];
2273 skb = sky2_receive(dev, length, status); 2272 skb = sky2_receive(dev, length, status);
2274 if (unlikely(!skb)) { 2273 if (unlikely(!skb)) {
2275 sky2->net_stats.rx_dropped++; 2274 dev->stats.rx_dropped++;
2276 break; 2275 break;
2277 } 2276 }
2278 2277
@@ -2287,8 +2286,8 @@ static int sky2_status_intr(struct sky2_hw *hw, int to_do, u16 idx)
2287 } 2286 }
2288 2287
2289 skb->protocol = eth_type_trans(skb, dev); 2288 skb->protocol = eth_type_trans(skb, dev);
2290 sky2->net_stats.rx_packets++; 2289 dev->stats.rx_packets++;
2291 sky2->net_stats.rx_bytes += skb->len; 2290 dev->stats.rx_bytes += skb->len;
2292 dev->last_rx = jiffies; 2291 dev->last_rx = jiffies;
2293 2292
2294#ifdef SKY2_VLAN_TAG_USED 2293#ifdef SKY2_VLAN_TAG_USED
@@ -2479,12 +2478,12 @@ static void sky2_mac_intr(struct sky2_hw *hw, unsigned port)
2479 gma_read16(hw, port, GM_TX_IRQ_SRC); 2478 gma_read16(hw, port, GM_TX_IRQ_SRC);
2480 2479
2481 if (status & GM_IS_RX_FF_OR) { 2480 if (status & GM_IS_RX_FF_OR) {
2482 ++sky2->net_stats.rx_fifo_errors; 2481 ++dev->stats.rx_fifo_errors;
2483 sky2_write8(hw, SK_REG(port, RX_GMF_CTRL_T), GMF_CLI_RX_FO); 2482 sky2_write8(hw, SK_REG(port, RX_GMF_CTRL_T), GMF_CLI_RX_FO);
2484 } 2483 }
2485 2484
2486 if (status & GM_IS_TX_FF_UR) { 2485 if (status & GM_IS_TX_FF_UR) {
2487 ++sky2->net_stats.tx_fifo_errors; 2486 ++dev->stats.tx_fifo_errors;
2488 sky2_write8(hw, SK_REG(port, TX_GMF_CTRL_T), GMF_CLI_TX_FU); 2487 sky2_write8(hw, SK_REG(port, TX_GMF_CTRL_T), GMF_CLI_TX_FU);
2489 } 2488 }
2490} 2489}
@@ -3223,12 +3222,6 @@ static void sky2_get_strings(struct net_device *dev, u32 stringset, u8 * data)
3223 } 3222 }
3224} 3223}
3225 3224
3226static struct net_device_stats *sky2_get_stats(struct net_device *dev)
3227{
3228 struct sky2_port *sky2 = netdev_priv(dev);
3229 return &sky2->net_stats;
3230}
3231
3232static int sky2_set_mac_address(struct net_device *dev, void *p) 3225static int sky2_set_mac_address(struct net_device *dev, void *p)
3233{ 3226{
3234 struct sky2_port *sky2 = netdev_priv(dev); 3227 struct sky2_port *sky2 = netdev_priv(dev);
@@ -3569,20 +3562,64 @@ static void sky2_get_regs(struct net_device *dev, struct ethtool_regs *regs,
3569{ 3562{
3570 const struct sky2_port *sky2 = netdev_priv(dev); 3563 const struct sky2_port *sky2 = netdev_priv(dev);
3571 const void __iomem *io = sky2->hw->regs; 3564 const void __iomem *io = sky2->hw->regs;
3565 unsigned int b;
3572 3566
3573 regs->version = 1; 3567 regs->version = 1;
3574 memset(p, 0, regs->len);
3575
3576 memcpy_fromio(p, io, B3_RAM_ADDR);
3577 3568
3578 /* skip diagnostic ram region */ 3569 for (b = 0; b < 128; b++) {
3579 memcpy_fromio(p + B3_RI_WTO_R1, io + B3_RI_WTO_R1, 0x2000 - B3_RI_WTO_R1); 3570 /* This complicated switch statement is to make sure and
3571 * only access regions that are unreserved.
3572 * Some blocks are only valid on dual port cards.
3573 * and block 3 has some special diagnostic registers that
3574 * are poison.
3575 */
3576 switch (b) {
3577 case 3:
3578 /* skip diagnostic ram region */
3579 memcpy_fromio(p + 0x10, io + 0x10, 128 - 0x10);
3580 break;
3580 3581
3581 /* copy GMAC registers */ 3582 /* dual port cards only */
3582 memcpy_fromio(p + BASE_GMAC_1, io + BASE_GMAC_1, 0x1000); 3583 case 5: /* Tx Arbiter 2 */
3583 if (sky2->hw->ports > 1) 3584 case 9: /* RX2 */
3584 memcpy_fromio(p + BASE_GMAC_2, io + BASE_GMAC_2, 0x1000); 3585 case 14 ... 15: /* TX2 */
3586 case 17: case 19: /* Ram Buffer 2 */
3587 case 22 ... 23: /* Tx Ram Buffer 2 */
3588 case 25: /* Rx MAC Fifo 1 */
3589 case 27: /* Tx MAC Fifo 2 */
3590 case 31: /* GPHY 2 */
3591 case 40 ... 47: /* Pattern Ram 2 */
3592 case 52: case 54: /* TCP Segmentation 2 */
3593 case 112 ... 116: /* GMAC 2 */
3594 if (sky2->hw->ports == 1)
3595 goto reserved;
3596 /* fall through */
3597 case 0: /* Control */
3598 case 2: /* Mac address */
3599 case 4: /* Tx Arbiter 1 */
3600 case 7: /* PCI express reg */
3601 case 8: /* RX1 */
3602 case 12 ... 13: /* TX1 */
3603 case 16: case 18:/* Rx Ram Buffer 1 */
3604 case 20 ... 21: /* Tx Ram Buffer 1 */
3605 case 24: /* Rx MAC Fifo 1 */
3606 case 26: /* Tx MAC Fifo 1 */
3607 case 28 ... 29: /* Descriptor and status unit */
3608 case 30: /* GPHY 1*/
3609 case 32 ... 39: /* Pattern Ram 1 */
3610 case 48: case 50: /* TCP Segmentation 1 */
3611 case 56 ... 60: /* PCI space */
3612 case 80 ... 84: /* GMAC 1 */
3613 memcpy_fromio(p, io, 128);
3614 break;
3615 default:
3616reserved:
3617 memset(p, 0, 128);
3618 }
3585 3619
3620 p += 128;
3621 io += 128;
3622 }
3586} 3623}
3587 3624
3588/* In order to do Jumbo packets on these chips, need to turn off the 3625/* In order to do Jumbo packets on these chips, need to turn off the
@@ -3934,7 +3971,6 @@ static __devinit struct net_device *sky2_init_netdev(struct sky2_hw *hw,
3934 dev->stop = sky2_down; 3971 dev->stop = sky2_down;
3935 dev->do_ioctl = sky2_ioctl; 3972 dev->do_ioctl = sky2_ioctl;
3936 dev->hard_start_xmit = sky2_xmit_frame; 3973 dev->hard_start_xmit = sky2_xmit_frame;
3937 dev->get_stats = sky2_get_stats;
3938 dev->set_multicast_list = sky2_set_multicast; 3974 dev->set_multicast_list = sky2_set_multicast;
3939 dev->set_mac_address = sky2_set_mac_address; 3975 dev->set_mac_address = sky2_set_mac_address;
3940 dev->change_mtu = sky2_change_mtu; 3976 dev->change_mtu = sky2_change_mtu;
@@ -4360,7 +4396,7 @@ static void sky2_shutdown(struct pci_dev *pdev)
4360 if (!hw) 4396 if (!hw)
4361 return; 4397 return;
4362 4398
4363 napi_disable(&hw->napi); 4399 del_timer_sync(&hw->watchdog_timer);
4364 4400
4365 for (i = 0; i < hw->ports; i++) { 4401 for (i = 0; i < hw->ports; i++) {
4366 struct net_device *dev = hw->dev[i]; 4402 struct net_device *dev = hw->dev[i];