diff options
Diffstat (limited to 'drivers/net/sky2.c')
-rw-r--r-- | drivers/net/sky2.c | 235 |
1 files changed, 132 insertions, 103 deletions
diff --git a/drivers/net/sky2.c b/drivers/net/sky2.c index 227df9876a2c..62be6d99d05c 100644 --- a/drivers/net/sky2.c +++ b/drivers/net/sky2.c | |||
@@ -51,7 +51,7 @@ | |||
51 | #include "sky2.h" | 51 | #include "sky2.h" |
52 | 52 | ||
53 | #define DRV_NAME "sky2" | 53 | #define DRV_NAME "sky2" |
54 | #define DRV_VERSION "1.2" | 54 | #define DRV_VERSION "1.3" |
55 | #define PFX DRV_NAME " " | 55 | #define PFX DRV_NAME " " |
56 | 56 | ||
57 | /* | 57 | /* |
@@ -79,6 +79,8 @@ | |||
79 | #define NAPI_WEIGHT 64 | 79 | #define NAPI_WEIGHT 64 |
80 | #define PHY_RETRIES 1000 | 80 | #define PHY_RETRIES 1000 |
81 | 81 | ||
82 | #define RING_NEXT(x,s) (((x)+1) & ((s)-1)) | ||
83 | |||
82 | static const u32 default_msg = | 84 | static const u32 default_msg = |
83 | NETIF_MSG_DRV | NETIF_MSG_PROBE | NETIF_MSG_LINK | 85 | NETIF_MSG_DRV | NETIF_MSG_PROBE | NETIF_MSG_LINK |
84 | | NETIF_MSG_TIMER | NETIF_MSG_TX_ERR | NETIF_MSG_RX_ERR | 86 | | NETIF_MSG_TIMER | NETIF_MSG_TX_ERR | NETIF_MSG_RX_ERR |
@@ -96,6 +98,10 @@ static int disable_msi = 0; | |||
96 | module_param(disable_msi, int, 0); | 98 | module_param(disable_msi, int, 0); |
97 | MODULE_PARM_DESC(disable_msi, "Disable Message Signaled Interrupt (MSI)"); | 99 | MODULE_PARM_DESC(disable_msi, "Disable Message Signaled Interrupt (MSI)"); |
98 | 100 | ||
101 | static int idle_timeout = 100; | ||
102 | module_param(idle_timeout, int, 0); | ||
103 | MODULE_PARM_DESC(idle_timeout, "Idle timeout workaround for lost interrupts (ms)"); | ||
104 | |||
99 | static const struct pci_device_id sky2_id_table[] = { | 105 | static const struct pci_device_id sky2_id_table[] = { |
100 | { PCI_DEVICE(PCI_VENDOR_ID_SYSKONNECT, 0x9000) }, | 106 | { PCI_DEVICE(PCI_VENDOR_ID_SYSKONNECT, 0x9000) }, |
101 | { PCI_DEVICE(PCI_VENDOR_ID_SYSKONNECT, 0x9E00) }, | 107 | { PCI_DEVICE(PCI_VENDOR_ID_SYSKONNECT, 0x9E00) }, |
@@ -122,6 +128,7 @@ MODULE_DEVICE_TABLE(pci, sky2_id_table); | |||
122 | /* Avoid conditionals by using array */ | 128 | /* Avoid conditionals by using array */ |
123 | static const unsigned txqaddr[] = { Q_XA1, Q_XA2 }; | 129 | static const unsigned txqaddr[] = { Q_XA1, Q_XA2 }; |
124 | static const unsigned rxqaddr[] = { Q_R1, Q_R2 }; | 130 | static const unsigned rxqaddr[] = { Q_R1, Q_R2 }; |
131 | static const u32 portirq_msk[] = { Y2_IS_PORT_1, Y2_IS_PORT_2 }; | ||
125 | 132 | ||
126 | /* This driver supports yukon2 chipset only */ | 133 | /* This driver supports yukon2 chipset only */ |
127 | static const char *yukon2_name[] = { | 134 | static const char *yukon2_name[] = { |
@@ -298,7 +305,8 @@ static void sky2_phy_init(struct sky2_hw *hw, unsigned port) | |||
298 | struct sky2_port *sky2 = netdev_priv(hw->dev[port]); | 305 | struct sky2_port *sky2 = netdev_priv(hw->dev[port]); |
299 | u16 ctrl, ct1000, adv, pg, ledctrl, ledover; | 306 | u16 ctrl, ct1000, adv, pg, ledctrl, ledover; |
300 | 307 | ||
301 | if (sky2->autoneg == AUTONEG_ENABLE && hw->chip_id != CHIP_ID_YUKON_XL) { | 308 | if (sky2->autoneg == AUTONEG_ENABLE && |
309 | (hw->chip_id != CHIP_ID_YUKON_XL || hw->chip_id == CHIP_ID_YUKON_EC_U)) { | ||
302 | u16 ectrl = gm_phy_read(hw, port, PHY_MARV_EXT_CTRL); | 310 | u16 ectrl = gm_phy_read(hw, port, PHY_MARV_EXT_CTRL); |
303 | 311 | ||
304 | ectrl &= ~(PHY_M_EC_M_DSC_MSK | PHY_M_EC_S_DSC_MSK | | 312 | ectrl &= ~(PHY_M_EC_M_DSC_MSK | PHY_M_EC_S_DSC_MSK | |
@@ -326,7 +334,7 @@ static void sky2_phy_init(struct sky2_hw *hw, unsigned port) | |||
326 | ctrl |= PHY_M_PC_MDI_XMODE(PHY_M_PC_ENA_AUTO); | 334 | ctrl |= PHY_M_PC_MDI_XMODE(PHY_M_PC_ENA_AUTO); |
327 | 335 | ||
328 | if (sky2->autoneg == AUTONEG_ENABLE && | 336 | if (sky2->autoneg == AUTONEG_ENABLE && |
329 | hw->chip_id == CHIP_ID_YUKON_XL) { | 337 | (hw->chip_id == CHIP_ID_YUKON_XL || hw->chip_id == CHIP_ID_YUKON_EC_U)) { |
330 | ctrl &= ~PHY_M_PC_DSC_MSK; | 338 | ctrl &= ~PHY_M_PC_DSC_MSK; |
331 | ctrl |= PHY_M_PC_DSC(2) | PHY_M_PC_DOWN_S_ENA; | 339 | ctrl |= PHY_M_PC_DSC(2) | PHY_M_PC_DOWN_S_ENA; |
332 | } | 340 | } |
@@ -442,10 +450,11 @@ static void sky2_phy_init(struct sky2_hw *hw, unsigned port) | |||
442 | gm_phy_write(hw, port, PHY_MARV_EXT_ADR, 3); | 450 | gm_phy_write(hw, port, PHY_MARV_EXT_ADR, 3); |
443 | 451 | ||
444 | /* set LED Function Control register */ | 452 | /* set LED Function Control register */ |
445 | gm_phy_write(hw, port, PHY_MARV_PHY_CTRL, (PHY_M_LEDC_LOS_CTRL(1) | /* LINK/ACT */ | 453 | gm_phy_write(hw, port, PHY_MARV_PHY_CTRL, |
446 | PHY_M_LEDC_INIT_CTRL(7) | /* 10 Mbps */ | 454 | (PHY_M_LEDC_LOS_CTRL(1) | /* LINK/ACT */ |
447 | PHY_M_LEDC_STA1_CTRL(7) | /* 100 Mbps */ | 455 | PHY_M_LEDC_INIT_CTRL(7) | /* 10 Mbps */ |
448 | PHY_M_LEDC_STA0_CTRL(7))); /* 1000 Mbps */ | 456 | PHY_M_LEDC_STA1_CTRL(7) | /* 100 Mbps */ |
457 | PHY_M_LEDC_STA0_CTRL(7))); /* 1000 Mbps */ | ||
449 | 458 | ||
450 | /* set Polarity Control register */ | 459 | /* set Polarity Control register */ |
451 | gm_phy_write(hw, port, PHY_MARV_PHY_STAT, | 460 | gm_phy_write(hw, port, PHY_MARV_PHY_STAT, |
@@ -459,6 +468,25 @@ static void sky2_phy_init(struct sky2_hw *hw, unsigned port) | |||
459 | /* restore page register */ | 468 | /* restore page register */ |
460 | gm_phy_write(hw, port, PHY_MARV_EXT_ADR, pg); | 469 | gm_phy_write(hw, port, PHY_MARV_EXT_ADR, pg); |
461 | break; | 470 | break; |
471 | case CHIP_ID_YUKON_EC_U: | ||
472 | pg = gm_phy_read(hw, port, PHY_MARV_EXT_ADR); | ||
473 | |||
474 | /* select page 3 to access LED control register */ | ||
475 | gm_phy_write(hw, port, PHY_MARV_EXT_ADR, 3); | ||
476 | |||
477 | /* set LED Function Control register */ | ||
478 | gm_phy_write(hw, port, PHY_MARV_PHY_CTRL, | ||
479 | (PHY_M_LEDC_LOS_CTRL(1) | /* LINK/ACT */ | ||
480 | PHY_M_LEDC_INIT_CTRL(8) | /* 10 Mbps */ | ||
481 | PHY_M_LEDC_STA1_CTRL(7) | /* 100 Mbps */ | ||
482 | PHY_M_LEDC_STA0_CTRL(7)));/* 1000 Mbps */ | ||
483 | |||
484 | /* set Blink Rate in LED Timer Control Register */ | ||
485 | gm_phy_write(hw, port, PHY_MARV_INT_MASK, | ||
486 | ledctrl | PHY_M_LED_BLINK_RT(BLINK_84MS)); | ||
487 | /* restore page register */ | ||
488 | gm_phy_write(hw, port, PHY_MARV_EXT_ADR, pg); | ||
489 | break; | ||
462 | 490 | ||
463 | default: | 491 | default: |
464 | /* set Tx LED (LED_TX) to blink mode on Rx OR Tx activity */ | 492 | /* set Tx LED (LED_TX) to blink mode on Rx OR Tx activity */ |
@@ -467,19 +495,21 @@ static void sky2_phy_init(struct sky2_hw *hw, unsigned port) | |||
467 | ledover |= PHY_M_LED_MO_RX(MO_LED_OFF); | 495 | ledover |= PHY_M_LED_MO_RX(MO_LED_OFF); |
468 | } | 496 | } |
469 | 497 | ||
470 | if (hw->chip_id == CHIP_ID_YUKON_EC_U && hw->chip_rev >= 2) { | 498 | if (hw->chip_id == CHIP_ID_YUKON_EC_U && hw->chip_rev == CHIP_REV_YU_EC_A1) { |
471 | /* apply fixes in PHY AFE */ | 499 | /* apply fixes in PHY AFE */ |
472 | gm_phy_write(hw, port, 22, 255); | 500 | pg = gm_phy_read(hw, port, PHY_MARV_EXT_ADR); |
501 | gm_phy_write(hw, port, PHY_MARV_EXT_ADR, 255); | ||
502 | |||
473 | /* increase differential signal amplitude in 10BASE-T */ | 503 | /* increase differential signal amplitude in 10BASE-T */ |
474 | gm_phy_write(hw, port, 24, 0xaa99); | 504 | gm_phy_write(hw, port, 0x18, 0xaa99); |
475 | gm_phy_write(hw, port, 23, 0x2011); | 505 | gm_phy_write(hw, port, 0x17, 0x2011); |
476 | 506 | ||
477 | /* fix for IEEE A/B Symmetry failure in 1000BASE-T */ | 507 | /* fix for IEEE A/B Symmetry failure in 1000BASE-T */ |
478 | gm_phy_write(hw, port, 24, 0xa204); | 508 | gm_phy_write(hw, port, 0x18, 0xa204); |
479 | gm_phy_write(hw, port, 23, 0x2002); | 509 | gm_phy_write(hw, port, 0x17, 0x2002); |
480 | 510 | ||
481 | /* set page register to 0 */ | 511 | /* set page register to 0 */ |
482 | gm_phy_write(hw, port, 22, 0); | 512 | gm_phy_write(hw, port, PHY_MARV_EXT_ADR, pg); |
483 | } else { | 513 | } else { |
484 | gm_phy_write(hw, port, PHY_MARV_LED_CTRL, ledctrl); | 514 | gm_phy_write(hw, port, PHY_MARV_LED_CTRL, ledctrl); |
485 | 515 | ||
@@ -553,6 +583,11 @@ static void sky2_mac_init(struct sky2_hw *hw, unsigned port) | |||
553 | 583 | ||
554 | if (sky2->duplex == DUPLEX_FULL) | 584 | if (sky2->duplex == DUPLEX_FULL) |
555 | reg |= GM_GPCR_DUP_FULL; | 585 | reg |= GM_GPCR_DUP_FULL; |
586 | |||
587 | /* turn off pause in 10/100mbps half duplex */ | ||
588 | else if (sky2->speed != SPEED_1000 && | ||
589 | hw->chip_id != CHIP_ID_YUKON_EC_U) | ||
590 | sky2->tx_pause = sky2->rx_pause = 0; | ||
556 | } else | 591 | } else |
557 | reg = GM_GPCR_SPEED_1000 | GM_GPCR_SPEED_100 | GM_GPCR_DUP_FULL; | 592 | reg = GM_GPCR_SPEED_1000 | GM_GPCR_SPEED_100 | GM_GPCR_DUP_FULL; |
558 | 593 | ||
@@ -719,7 +754,7 @@ static inline struct sky2_tx_le *get_tx_le(struct sky2_port *sky2) | |||
719 | { | 754 | { |
720 | struct sky2_tx_le *le = sky2->tx_le + sky2->tx_prod; | 755 | struct sky2_tx_le *le = sky2->tx_le + sky2->tx_prod; |
721 | 756 | ||
722 | sky2->tx_prod = (sky2->tx_prod + 1) % TX_RING_SIZE; | 757 | sky2->tx_prod = RING_NEXT(sky2->tx_prod, TX_RING_SIZE); |
723 | return le; | 758 | return le; |
724 | } | 759 | } |
725 | 760 | ||
@@ -735,7 +770,7 @@ static inline void sky2_put_idx(struct sky2_hw *hw, unsigned q, u16 idx) | |||
735 | static inline struct sky2_rx_le *sky2_next_rx(struct sky2_port *sky2) | 770 | static inline struct sky2_rx_le *sky2_next_rx(struct sky2_port *sky2) |
736 | { | 771 | { |
737 | struct sky2_rx_le *le = sky2->rx_le + sky2->rx_put; | 772 | struct sky2_rx_le *le = sky2->rx_le + sky2->rx_put; |
738 | sky2->rx_put = (sky2->rx_put + 1) % RX_LE_SIZE; | 773 | sky2->rx_put = RING_NEXT(sky2->rx_put, RX_LE_SIZE); |
739 | return le; | 774 | return le; |
740 | } | 775 | } |
741 | 776 | ||
@@ -985,8 +1020,19 @@ static int sky2_up(struct net_device *dev) | |||
985 | struct sky2_hw *hw = sky2->hw; | 1020 | struct sky2_hw *hw = sky2->hw; |
986 | unsigned port = sky2->port; | 1021 | unsigned port = sky2->port; |
987 | u32 ramsize, rxspace, imask; | 1022 | u32 ramsize, rxspace, imask; |
988 | int err = -ENOMEM; | 1023 | int err; |
1024 | struct net_device *otherdev = hw->dev[sky2->port^1]; | ||
989 | 1025 | ||
1026 | /* Block bringing up both ports at the same time on a dual port card. | ||
1027 | * There is an unfixed bug where receiver gets confused and picks up | ||
1028 | * packets out of order. Until this is fixed, prevent data corruption. | ||
1029 | */ | ||
1030 | if (otherdev && netif_running(otherdev)) { | ||
1031 | printk(KERN_INFO PFX "dual port support is disabled.\n"); | ||
1032 | return -EBUSY; | ||
1033 | } | ||
1034 | |||
1035 | err = -ENOMEM; | ||
990 | if (netif_msg_ifup(sky2)) | 1036 | if (netif_msg_ifup(sky2)) |
991 | printk(KERN_INFO PFX "%s: enabling interface\n", dev->name); | 1037 | printk(KERN_INFO PFX "%s: enabling interface\n", dev->name); |
992 | 1038 | ||
@@ -1050,7 +1096,7 @@ static int sky2_up(struct net_device *dev) | |||
1050 | 1096 | ||
1051 | /* Enable interrupts from phy/mac for port */ | 1097 | /* Enable interrupts from phy/mac for port */ |
1052 | imask = sky2_read32(hw, B0_IMSK); | 1098 | imask = sky2_read32(hw, B0_IMSK); |
1053 | imask |= (port == 0) ? Y2_IS_PORT_1 : Y2_IS_PORT_2; | 1099 | imask |= portirq_msk[port]; |
1054 | sky2_write32(hw, B0_IMSK, imask); | 1100 | sky2_write32(hw, B0_IMSK, imask); |
1055 | 1101 | ||
1056 | return 0; | 1102 | return 0; |
@@ -1078,7 +1124,7 @@ err_out: | |||
1078 | /* Modular subtraction in ring */ | 1124 | /* Modular subtraction in ring */ |
1079 | static inline int tx_dist(unsigned tail, unsigned head) | 1125 | static inline int tx_dist(unsigned tail, unsigned head) |
1080 | { | 1126 | { |
1081 | return (head - tail) % TX_RING_SIZE; | 1127 | return (head - tail) & (TX_RING_SIZE - 1); |
1082 | } | 1128 | } |
1083 | 1129 | ||
1084 | /* Number of list elements available for next tx */ | 1130 | /* Number of list elements available for next tx */ |
@@ -1255,7 +1301,7 @@ static int sky2_xmit_frame(struct sk_buff *skb, struct net_device *dev) | |||
1255 | le->opcode = OP_BUFFER | HW_OWNER; | 1301 | le->opcode = OP_BUFFER | HW_OWNER; |
1256 | 1302 | ||
1257 | fre = sky2->tx_ring | 1303 | fre = sky2->tx_ring |
1258 | + ((re - sky2->tx_ring) + i + 1) % TX_RING_SIZE; | 1304 | + RING_NEXT((re - sky2->tx_ring) + i, TX_RING_SIZE); |
1259 | pci_unmap_addr_set(fre, mapaddr, mapping); | 1305 | pci_unmap_addr_set(fre, mapaddr, mapping); |
1260 | } | 1306 | } |
1261 | 1307 | ||
@@ -1315,7 +1361,7 @@ static void sky2_tx_complete(struct sky2_port *sky2, u16 done) | |||
1315 | 1361 | ||
1316 | for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) { | 1362 | for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) { |
1317 | struct tx_ring_info *fre; | 1363 | struct tx_ring_info *fre; |
1318 | fre = sky2->tx_ring + (put + i + 1) % TX_RING_SIZE; | 1364 | fre = sky2->tx_ring + RING_NEXT(put + i, TX_RING_SIZE); |
1319 | pci_unmap_page(pdev, pci_unmap_addr(fre, mapaddr), | 1365 | pci_unmap_page(pdev, pci_unmap_addr(fre, mapaddr), |
1320 | skb_shinfo(skb)->frags[i].size, | 1366 | skb_shinfo(skb)->frags[i].size, |
1321 | PCI_DMA_TODEVICE); | 1367 | PCI_DMA_TODEVICE); |
@@ -1401,7 +1447,7 @@ static int sky2_down(struct net_device *dev) | |||
1401 | 1447 | ||
1402 | /* Disable port IRQ */ | 1448 | /* Disable port IRQ */ |
1403 | imask = sky2_read32(hw, B0_IMSK); | 1449 | imask = sky2_read32(hw, B0_IMSK); |
1404 | imask &= ~(sky2->port == 0) ? Y2_IS_PORT_1 : Y2_IS_PORT_2; | 1450 | imask &= ~portirq_msk[port]; |
1405 | sky2_write32(hw, B0_IMSK, imask); | 1451 | sky2_write32(hw, B0_IMSK, imask); |
1406 | 1452 | ||
1407 | /* turn off LED's */ | 1453 | /* turn off LED's */ |
@@ -1498,17 +1544,26 @@ static void sky2_link_up(struct sky2_port *sky2) | |||
1498 | sky2_write8(hw, SK_REG(port, LNK_LED_REG), | 1544 | sky2_write8(hw, SK_REG(port, LNK_LED_REG), |
1499 | LINKLED_ON | LINKLED_BLINK_OFF | LINKLED_LINKSYNC_OFF); | 1545 | LINKLED_ON | LINKLED_BLINK_OFF | LINKLED_LINKSYNC_OFF); |
1500 | 1546 | ||
1501 | if (hw->chip_id == CHIP_ID_YUKON_XL) { | 1547 | if (hw->chip_id == CHIP_ID_YUKON_XL || hw->chip_id == CHIP_ID_YUKON_EC_U) { |
1502 | u16 pg = gm_phy_read(hw, port, PHY_MARV_EXT_ADR); | 1548 | u16 pg = gm_phy_read(hw, port, PHY_MARV_EXT_ADR); |
1549 | u16 led = PHY_M_LEDC_LOS_CTRL(1); /* link active */ | ||
1550 | |||
1551 | switch(sky2->speed) { | ||
1552 | case SPEED_10: | ||
1553 | led |= PHY_M_LEDC_INIT_CTRL(7); | ||
1554 | break; | ||
1555 | |||
1556 | case SPEED_100: | ||
1557 | led |= PHY_M_LEDC_STA1_CTRL(7); | ||
1558 | break; | ||
1559 | |||
1560 | case SPEED_1000: | ||
1561 | led |= PHY_M_LEDC_STA0_CTRL(7); | ||
1562 | break; | ||
1563 | } | ||
1503 | 1564 | ||
1504 | gm_phy_write(hw, port, PHY_MARV_EXT_ADR, 3); | 1565 | gm_phy_write(hw, port, PHY_MARV_EXT_ADR, 3); |
1505 | gm_phy_write(hw, port, PHY_MARV_PHY_CTRL, PHY_M_LEDC_LOS_CTRL(1) | /* LINK/ACT */ | 1566 | gm_phy_write(hw, port, PHY_MARV_PHY_CTRL, led); |
1506 | PHY_M_LEDC_INIT_CTRL(sky2->speed == | ||
1507 | SPEED_10 ? 7 : 0) | | ||
1508 | PHY_M_LEDC_STA1_CTRL(sky2->speed == | ||
1509 | SPEED_100 ? 7 : 0) | | ||
1510 | PHY_M_LEDC_STA0_CTRL(sky2->speed == | ||
1511 | SPEED_1000 ? 7 : 0)); | ||
1512 | gm_phy_write(hw, port, PHY_MARV_EXT_ADR, pg); | 1567 | gm_phy_write(hw, port, PHY_MARV_EXT_ADR, pg); |
1513 | } | 1568 | } |
1514 | 1569 | ||
@@ -1583,7 +1638,7 @@ static int sky2_autoneg_done(struct sky2_port *sky2, u16 aux) | |||
1583 | sky2->speed = sky2_phy_speed(hw, aux); | 1638 | sky2->speed = sky2_phy_speed(hw, aux); |
1584 | 1639 | ||
1585 | /* Pause bits are offset (9..8) */ | 1640 | /* Pause bits are offset (9..8) */ |
1586 | if (hw->chip_id == CHIP_ID_YUKON_XL) | 1641 | if (hw->chip_id == CHIP_ID_YUKON_XL || hw->chip_id == CHIP_ID_YUKON_EC_U) |
1587 | aux >>= 6; | 1642 | aux >>= 6; |
1588 | 1643 | ||
1589 | sky2->rx_pause = (aux & PHY_M_PS_RX_P_EN) != 0; | 1644 | sky2->rx_pause = (aux & PHY_M_PS_RX_P_EN) != 0; |
@@ -1859,35 +1914,28 @@ static inline void sky2_tx_done(struct net_device *dev, u16 last) | |||
1859 | static int sky2_status_intr(struct sky2_hw *hw, int to_do) | 1914 | static int sky2_status_intr(struct sky2_hw *hw, int to_do) |
1860 | { | 1915 | { |
1861 | int work_done = 0; | 1916 | int work_done = 0; |
1917 | u16 hwidx = sky2_read16(hw, STAT_PUT_IDX); | ||
1862 | 1918 | ||
1863 | rmb(); | 1919 | rmb(); |
1864 | 1920 | ||
1865 | for(;;) { | 1921 | while (hw->st_idx != hwidx) { |
1866 | struct sky2_status_le *le = hw->st_le + hw->st_idx; | 1922 | struct sky2_status_le *le = hw->st_le + hw->st_idx; |
1867 | struct net_device *dev; | 1923 | struct net_device *dev; |
1868 | struct sky2_port *sky2; | 1924 | struct sky2_port *sky2; |
1869 | struct sk_buff *skb; | 1925 | struct sk_buff *skb; |
1870 | u32 status; | 1926 | u32 status; |
1871 | u16 length; | 1927 | u16 length; |
1872 | u8 link, opcode; | ||
1873 | |||
1874 | opcode = le->opcode; | ||
1875 | if (!opcode) | ||
1876 | break; | ||
1877 | opcode &= ~HW_OWNER; | ||
1878 | 1928 | ||
1879 | hw->st_idx = (hw->st_idx + 1) % STATUS_RING_SIZE; | 1929 | hw->st_idx = RING_NEXT(hw->st_idx, STATUS_RING_SIZE); |
1880 | le->opcode = 0; | ||
1881 | 1930 | ||
1882 | link = le->link; | 1931 | BUG_ON(le->link >= 2); |
1883 | BUG_ON(link >= 2); | 1932 | dev = hw->dev[le->link]; |
1884 | dev = hw->dev[link]; | ||
1885 | 1933 | ||
1886 | sky2 = netdev_priv(dev); | 1934 | sky2 = netdev_priv(dev); |
1887 | length = le->length; | 1935 | length = le->length; |
1888 | status = le->status; | 1936 | status = le->status; |
1889 | 1937 | ||
1890 | switch (opcode) { | 1938 | switch (le->opcode & ~HW_OWNER) { |
1891 | case OP_RXSTAT: | 1939 | case OP_RXSTAT: |
1892 | skb = sky2_receive(sky2, length, status); | 1940 | skb = sky2_receive(sky2, length, status); |
1893 | if (!skb) | 1941 | if (!skb) |
@@ -1927,7 +1975,8 @@ static int sky2_status_intr(struct sky2_hw *hw, int to_do) | |||
1927 | 1975 | ||
1928 | case OP_TXINDEXLE: | 1976 | case OP_TXINDEXLE: |
1929 | /* TX index reports status for both ports */ | 1977 | /* TX index reports status for both ports */ |
1930 | sky2_tx_done(hw->dev[0], status & 0xffff); | 1978 | BUILD_BUG_ON(TX_RING_SIZE > 0x1000); |
1979 | sky2_tx_done(hw->dev[0], status & 0xfff); | ||
1931 | if (hw->dev[1]) | 1980 | if (hw->dev[1]) |
1932 | sky2_tx_done(hw->dev[1], | 1981 | sky2_tx_done(hw->dev[1], |
1933 | ((status >> 24) & 0xff) | 1982 | ((status >> 24) & 0xff) |
@@ -1937,8 +1986,8 @@ static int sky2_status_intr(struct sky2_hw *hw, int to_do) | |||
1937 | default: | 1986 | default: |
1938 | if (net_ratelimit()) | 1987 | if (net_ratelimit()) |
1939 | printk(KERN_WARNING PFX | 1988 | printk(KERN_WARNING PFX |
1940 | "unknown status opcode 0x%x\n", opcode); | 1989 | "unknown status opcode 0x%x\n", le->opcode); |
1941 | break; | 1990 | goto exit_loop; |
1942 | } | 1991 | } |
1943 | } | 1992 | } |
1944 | 1993 | ||
@@ -2089,12 +2138,13 @@ static void sky2_descriptor_error(struct sky2_hw *hw, unsigned port, | |||
2089 | */ | 2138 | */ |
2090 | static void sky2_idle(unsigned long arg) | 2139 | static void sky2_idle(unsigned long arg) |
2091 | { | 2140 | { |
2092 | struct net_device *dev = (struct net_device *) arg; | 2141 | struct sky2_hw *hw = (struct sky2_hw *) arg; |
2142 | struct net_device *dev = hw->dev[0]; | ||
2093 | 2143 | ||
2094 | local_irq_disable(); | ||
2095 | if (__netif_rx_schedule_prep(dev)) | 2144 | if (__netif_rx_schedule_prep(dev)) |
2096 | __netif_rx_schedule(dev); | 2145 | __netif_rx_schedule(dev); |
2097 | local_irq_enable(); | 2146 | |
2147 | mod_timer(&hw->idle_timer, jiffies + msecs_to_jiffies(idle_timeout)); | ||
2098 | } | 2148 | } |
2099 | 2149 | ||
2100 | 2150 | ||
@@ -2105,65 +2155,46 @@ static int sky2_poll(struct net_device *dev0, int *budget) | |||
2105 | int work_done = 0; | 2155 | int work_done = 0; |
2106 | u32 status = sky2_read32(hw, B0_Y2_SP_EISR); | 2156 | u32 status = sky2_read32(hw, B0_Y2_SP_EISR); |
2107 | 2157 | ||
2108 | restart_poll: | 2158 | if (status & Y2_IS_HW_ERR) |
2109 | if (unlikely(status & ~Y2_IS_STAT_BMU)) { | 2159 | sky2_hw_intr(hw); |
2110 | if (status & Y2_IS_HW_ERR) | ||
2111 | sky2_hw_intr(hw); | ||
2112 | |||
2113 | if (status & Y2_IS_IRQ_PHY1) | ||
2114 | sky2_phy_intr(hw, 0); | ||
2115 | 2160 | ||
2116 | if (status & Y2_IS_IRQ_PHY2) | 2161 | if (status & Y2_IS_IRQ_PHY1) |
2117 | sky2_phy_intr(hw, 1); | 2162 | sky2_phy_intr(hw, 0); |
2118 | 2163 | ||
2119 | if (status & Y2_IS_IRQ_MAC1) | 2164 | if (status & Y2_IS_IRQ_PHY2) |
2120 | sky2_mac_intr(hw, 0); | 2165 | sky2_phy_intr(hw, 1); |
2121 | 2166 | ||
2122 | if (status & Y2_IS_IRQ_MAC2) | 2167 | if (status & Y2_IS_IRQ_MAC1) |
2123 | sky2_mac_intr(hw, 1); | 2168 | sky2_mac_intr(hw, 0); |
2124 | 2169 | ||
2125 | if (status & Y2_IS_CHK_RX1) | 2170 | if (status & Y2_IS_IRQ_MAC2) |
2126 | sky2_descriptor_error(hw, 0, "receive", Y2_IS_CHK_RX1); | 2171 | sky2_mac_intr(hw, 1); |
2127 | 2172 | ||
2128 | if (status & Y2_IS_CHK_RX2) | 2173 | if (status & Y2_IS_CHK_RX1) |
2129 | sky2_descriptor_error(hw, 1, "receive", Y2_IS_CHK_RX2); | 2174 | sky2_descriptor_error(hw, 0, "receive", Y2_IS_CHK_RX1); |
2130 | 2175 | ||
2131 | if (status & Y2_IS_CHK_TXA1) | 2176 | if (status & Y2_IS_CHK_RX2) |
2132 | sky2_descriptor_error(hw, 0, "transmit", Y2_IS_CHK_TXA1); | 2177 | sky2_descriptor_error(hw, 1, "receive", Y2_IS_CHK_RX2); |
2133 | 2178 | ||
2134 | if (status & Y2_IS_CHK_TXA2) | 2179 | if (status & Y2_IS_CHK_TXA1) |
2135 | sky2_descriptor_error(hw, 1, "transmit", Y2_IS_CHK_TXA2); | 2180 | sky2_descriptor_error(hw, 0, "transmit", Y2_IS_CHK_TXA1); |
2136 | } | ||
2137 | |||
2138 | if (status & Y2_IS_STAT_BMU) { | ||
2139 | work_done += sky2_status_intr(hw, work_limit - work_done); | ||
2140 | *budget -= work_done; | ||
2141 | dev0->quota -= work_done; | ||
2142 | 2181 | ||
2143 | if (work_done >= work_limit) | 2182 | if (status & Y2_IS_CHK_TXA2) |
2144 | return 1; | 2183 | sky2_descriptor_error(hw, 1, "transmit", Y2_IS_CHK_TXA2); |
2145 | 2184 | ||
2185 | if (status & Y2_IS_STAT_BMU) | ||
2146 | sky2_write32(hw, STAT_CTRL, SC_STAT_CLR_IRQ); | 2186 | sky2_write32(hw, STAT_CTRL, SC_STAT_CLR_IRQ); |
2147 | } | ||
2148 | 2187 | ||
2149 | mod_timer(&hw->idle_timer, jiffies + HZ); | 2188 | work_done = sky2_status_intr(hw, work_limit); |
2189 | *budget -= work_done; | ||
2190 | dev0->quota -= work_done; | ||
2150 | 2191 | ||
2151 | local_irq_disable(); | 2192 | if (work_done >= work_limit) |
2152 | __netif_rx_complete(dev0); | 2193 | return 1; |
2153 | 2194 | ||
2154 | status = sky2_read32(hw, B0_Y2_SP_LISR); | 2195 | netif_rx_complete(dev0); |
2155 | |||
2156 | if (unlikely(status)) { | ||
2157 | /* More work pending, try and keep going */ | ||
2158 | if (__netif_rx_schedule_prep(dev0)) { | ||
2159 | __netif_rx_reschedule(dev0, work_done); | ||
2160 | status = sky2_read32(hw, B0_Y2_SP_EISR); | ||
2161 | local_irq_enable(); | ||
2162 | goto restart_poll; | ||
2163 | } | ||
2164 | } | ||
2165 | 2196 | ||
2166 | local_irq_enable(); | 2197 | status = sky2_read32(hw, B0_Y2_SP_LISR); |
2167 | return 0; | 2198 | return 0; |
2168 | } | 2199 | } |
2169 | 2200 | ||
@@ -2244,13 +2275,6 @@ static int __devinit sky2_reset(struct sky2_hw *hw) | |||
2244 | return -EOPNOTSUPP; | 2275 | return -EOPNOTSUPP; |
2245 | } | 2276 | } |
2246 | 2277 | ||
2247 | /* This chip is new and not tested yet */ | ||
2248 | if (hw->chip_id == CHIP_ID_YUKON_EC_U) { | ||
2249 | pr_info(PFX "%s: is a version of Yukon 2 chipset that has not been tested yet.\n", | ||
2250 | pci_name(hw->pdev)); | ||
2251 | pr_info("Please report success/failure to maintainer <shemminger@osdl.org>\n"); | ||
2252 | } | ||
2253 | |||
2254 | /* disable ASF */ | 2278 | /* disable ASF */ |
2255 | if (hw->chip_id <= CHIP_ID_YUKON_EC) { | 2279 | if (hw->chip_id <= CHIP_ID_YUKON_EC) { |
2256 | sky2_write8(hw, B28_Y2_ASF_STAT_CMD, Y2_ASF_RESET); | 2280 | sky2_write8(hw, B28_Y2_ASF_STAT_CMD, Y2_ASF_RESET); |
@@ -3302,7 +3326,10 @@ static int __devinit sky2_probe(struct pci_dev *pdev, | |||
3302 | 3326 | ||
3303 | sky2_write32(hw, B0_IMSK, Y2_IS_BASE); | 3327 | sky2_write32(hw, B0_IMSK, Y2_IS_BASE); |
3304 | 3328 | ||
3305 | setup_timer(&hw->idle_timer, sky2_idle, (unsigned long) dev); | 3329 | setup_timer(&hw->idle_timer, sky2_idle, (unsigned long) hw); |
3330 | if (idle_timeout > 0) | ||
3331 | mod_timer(&hw->idle_timer, | ||
3332 | jiffies + msecs_to_jiffies(idle_timeout)); | ||
3306 | 3333 | ||
3307 | pci_set_drvdata(pdev, hw); | 3334 | pci_set_drvdata(pdev, hw); |
3308 | 3335 | ||
@@ -3342,6 +3369,8 @@ static void __devexit sky2_remove(struct pci_dev *pdev) | |||
3342 | del_timer_sync(&hw->idle_timer); | 3369 | del_timer_sync(&hw->idle_timer); |
3343 | 3370 | ||
3344 | sky2_write32(hw, B0_IMSK, 0); | 3371 | sky2_write32(hw, B0_IMSK, 0); |
3372 | synchronize_irq(hw->pdev->irq); | ||
3373 | |||
3345 | dev0 = hw->dev[0]; | 3374 | dev0 = hw->dev[0]; |
3346 | dev1 = hw->dev[1]; | 3375 | dev1 = hw->dev[1]; |
3347 | if (dev1) | 3376 | if (dev1) |