diff options
Diffstat (limited to 'drivers/net/sky2.c')
-rw-r--r-- | drivers/net/sky2.c | 219 |
1 files changed, 136 insertions, 83 deletions
diff --git a/drivers/net/sky2.c b/drivers/net/sky2.c index f5d697c0c031..f8b973a04b65 100644 --- a/drivers/net/sky2.c +++ b/drivers/net/sky2.c | |||
@@ -57,7 +57,7 @@ | |||
57 | #include "sky2.h" | 57 | #include "sky2.h" |
58 | 58 | ||
59 | #define DRV_NAME "sky2" | 59 | #define DRV_NAME "sky2" |
60 | #define DRV_VERSION "0.11" | 60 | #define DRV_VERSION "0.13" |
61 | #define PFX DRV_NAME " " | 61 | #define PFX DRV_NAME " " |
62 | 62 | ||
63 | /* | 63 | /* |
@@ -75,6 +75,7 @@ | |||
75 | #define RX_LE_BYTES (RX_LE_SIZE*sizeof(struct sky2_rx_le)) | 75 | #define RX_LE_BYTES (RX_LE_SIZE*sizeof(struct sky2_rx_le)) |
76 | #define RX_MAX_PENDING (RX_LE_SIZE/2 - 2) | 76 | #define RX_MAX_PENDING (RX_LE_SIZE/2 - 2) |
77 | #define RX_DEF_PENDING RX_MAX_PENDING | 77 | #define RX_DEF_PENDING RX_MAX_PENDING |
78 | #define RX_SKB_ALIGN 8 | ||
78 | 79 | ||
79 | #define TX_RING_SIZE 512 | 80 | #define TX_RING_SIZE 512 |
80 | #define TX_DEF_PENDING (TX_RING_SIZE - 1) | 81 | #define TX_DEF_PENDING (TX_RING_SIZE - 1) |
@@ -91,7 +92,7 @@ | |||
91 | static const u32 default_msg = | 92 | static const u32 default_msg = |
92 | NETIF_MSG_DRV | NETIF_MSG_PROBE | NETIF_MSG_LINK | 93 | NETIF_MSG_DRV | NETIF_MSG_PROBE | NETIF_MSG_LINK |
93 | | NETIF_MSG_TIMER | NETIF_MSG_TX_ERR | NETIF_MSG_RX_ERR | 94 | | NETIF_MSG_TIMER | NETIF_MSG_TX_ERR | NETIF_MSG_RX_ERR |
94 | | NETIF_MSG_IFUP | NETIF_MSG_IFDOWN | NETIF_MSG_INTR; | 95 | | NETIF_MSG_IFUP | NETIF_MSG_IFDOWN; |
95 | 96 | ||
96 | static int debug = -1; /* defaults above */ | 97 | static int debug = -1; /* defaults above */ |
97 | module_param(debug, int, 0); | 98 | module_param(debug, int, 0); |
@@ -624,13 +625,16 @@ static void sky2_mac_init(struct sky2_hw *hw, unsigned port) | |||
624 | 625 | ||
625 | } | 626 | } |
626 | 627 | ||
627 | static void sky2_ramset(struct sky2_hw *hw, u16 q, u32 start, size_t len) | 628 | /* Assign Ram Buffer allocation. |
629 | * start and end are in units of 4k bytes | ||
630 | * ram registers are in units of 64bit words | ||
631 | */ | ||
632 | static void sky2_ramset(struct sky2_hw *hw, u16 q, u8 startk, u8 endk) | ||
628 | { | 633 | { |
629 | u32 end; | 634 | u32 start, end; |
630 | 635 | ||
631 | start /= 8; | 636 | start = startk * 4096/8; |
632 | len /= 8; | 637 | end = (endk * 4096/8) - 1; |
633 | end = start + len - 1; | ||
634 | 638 | ||
635 | sky2_write8(hw, RB_ADDR(q, RB_CTRL), RB_RST_CLR); | 639 | sky2_write8(hw, RB_ADDR(q, RB_CTRL), RB_RST_CLR); |
636 | sky2_write32(hw, RB_ADDR(q, RB_START), start); | 640 | sky2_write32(hw, RB_ADDR(q, RB_START), start); |
@@ -639,14 +643,19 @@ static void sky2_ramset(struct sky2_hw *hw, u16 q, u32 start, size_t len) | |||
639 | sky2_write32(hw, RB_ADDR(q, RB_RP), start); | 643 | sky2_write32(hw, RB_ADDR(q, RB_RP), start); |
640 | 644 | ||
641 | if (q == Q_R1 || q == Q_R2) { | 645 | if (q == Q_R1 || q == Q_R2) { |
642 | u32 rxup, rxlo; | 646 | u32 space = (endk - startk) * 4096/8; |
647 | u32 tp = space - space/4; | ||
643 | 648 | ||
644 | rxlo = len/2; | 649 | /* On receive queue's set the thresholds |
645 | rxup = rxlo + len/4; | 650 | * give receiver priority when > 3/4 full |
651 | * send pause when down to 2K | ||
652 | */ | ||
653 | sky2_write32(hw, RB_ADDR(q, RB_RX_UTHP), tp); | ||
654 | sky2_write32(hw, RB_ADDR(q, RB_RX_LTHP), space/2); | ||
646 | 655 | ||
647 | /* Set thresholds on receive queue's */ | 656 | tp = space - 2048/8; |
648 | sky2_write32(hw, RB_ADDR(q, RB_RX_UTPP), rxup); | 657 | sky2_write32(hw, RB_ADDR(q, RB_RX_UTPP), tp); |
649 | sky2_write32(hw, RB_ADDR(q, RB_RX_LTPP), rxlo); | 658 | sky2_write32(hw, RB_ADDR(q, RB_RX_LTPP), space/4); |
650 | } else { | 659 | } else { |
651 | /* Enable store & forward on Tx queue's because | 660 | /* Enable store & forward on Tx queue's because |
652 | * Tx FIFO is only 1K on Yukon | 661 | * Tx FIFO is only 1K on Yukon |
@@ -695,9 +704,10 @@ static inline struct sky2_tx_le *get_tx_le(struct sky2_port *sky2) | |||
695 | * This is a workaround code taken from SysKonnect sk98lin driver | 704 | * This is a workaround code taken from SysKonnect sk98lin driver |
696 | * to deal with chip bug on Yukon EC rev 0 in the wraparound case. | 705 | * to deal with chip bug on Yukon EC rev 0 in the wraparound case. |
697 | */ | 706 | */ |
698 | static inline void sky2_put_idx(struct sky2_hw *hw, unsigned q, | 707 | static void sky2_put_idx(struct sky2_hw *hw, unsigned q, |
699 | u16 idx, u16 *last, u16 size) | 708 | u16 idx, u16 *last, u16 size) |
700 | { | 709 | { |
710 | wmb(); | ||
701 | if (is_ec_a1(hw) && idx < *last) { | 711 | if (is_ec_a1(hw) && idx < *last) { |
702 | u16 hwget = sky2_read16(hw, Y2_QADDR(q, PREF_UNIT_GET_IDX)); | 712 | u16 hwget = sky2_read16(hw, Y2_QADDR(q, PREF_UNIT_GET_IDX)); |
703 | 713 | ||
@@ -721,6 +731,7 @@ setnew: | |||
721 | sky2_write16(hw, Y2_QADDR(q, PREF_UNIT_PUT_IDX), idx); | 731 | sky2_write16(hw, Y2_QADDR(q, PREF_UNIT_PUT_IDX), idx); |
722 | } | 732 | } |
723 | *last = idx; | 733 | *last = idx; |
734 | mmiowb(); | ||
724 | } | 735 | } |
725 | 736 | ||
726 | 737 | ||
@@ -734,11 +745,11 @@ static inline struct sky2_rx_le *sky2_next_rx(struct sky2_port *sky2) | |||
734 | /* Return high part of DMA address (could be 32 or 64 bit) */ | 745 | /* Return high part of DMA address (could be 32 or 64 bit) */ |
735 | static inline u32 high32(dma_addr_t a) | 746 | static inline u32 high32(dma_addr_t a) |
736 | { | 747 | { |
737 | return (a >> 16) >> 16; | 748 | return sizeof(a) > sizeof(u32) ? (a >> 16) >> 16 : 0; |
738 | } | 749 | } |
739 | 750 | ||
740 | /* Build description to hardware about buffer */ | 751 | /* Build description to hardware about buffer */ |
741 | static inline void sky2_rx_add(struct sky2_port *sky2, dma_addr_t map) | 752 | static void sky2_rx_add(struct sky2_port *sky2, dma_addr_t map) |
742 | { | 753 | { |
743 | struct sky2_rx_le *le; | 754 | struct sky2_rx_le *le; |
744 | u32 hi = high32(map); | 755 | u32 hi = high32(map); |
@@ -878,13 +889,13 @@ static void sky2_vlan_rx_register(struct net_device *dev, struct vlan_group *grp | |||
878 | struct sky2_hw *hw = sky2->hw; | 889 | struct sky2_hw *hw = sky2->hw; |
879 | u16 port = sky2->port; | 890 | u16 port = sky2->port; |
880 | 891 | ||
881 | spin_lock(&sky2->tx_lock); | 892 | spin_lock_bh(&sky2->tx_lock); |
882 | 893 | ||
883 | sky2_write32(hw, SK_REG(port, RX_GMF_CTRL_T), RX_VLAN_STRIP_ON); | 894 | sky2_write32(hw, SK_REG(port, RX_GMF_CTRL_T), RX_VLAN_STRIP_ON); |
884 | sky2_write32(hw, SK_REG(port, TX_GMF_CTRL_T), TX_VLAN_TAG_ON); | 895 | sky2_write32(hw, SK_REG(port, TX_GMF_CTRL_T), TX_VLAN_TAG_ON); |
885 | sky2->vlgrp = grp; | 896 | sky2->vlgrp = grp; |
886 | 897 | ||
887 | spin_unlock(&sky2->tx_lock); | 898 | spin_unlock_bh(&sky2->tx_lock); |
888 | } | 899 | } |
889 | 900 | ||
890 | static void sky2_vlan_rx_kill_vid(struct net_device *dev, unsigned short vid) | 901 | static void sky2_vlan_rx_kill_vid(struct net_device *dev, unsigned short vid) |
@@ -893,27 +904,42 @@ static void sky2_vlan_rx_kill_vid(struct net_device *dev, unsigned short vid) | |||
893 | struct sky2_hw *hw = sky2->hw; | 904 | struct sky2_hw *hw = sky2->hw; |
894 | u16 port = sky2->port; | 905 | u16 port = sky2->port; |
895 | 906 | ||
896 | spin_lock(&sky2->tx_lock); | 907 | spin_lock_bh(&sky2->tx_lock); |
897 | 908 | ||
898 | sky2_write32(hw, SK_REG(port, RX_GMF_CTRL_T), RX_VLAN_STRIP_OFF); | 909 | sky2_write32(hw, SK_REG(port, RX_GMF_CTRL_T), RX_VLAN_STRIP_OFF); |
899 | sky2_write32(hw, SK_REG(port, TX_GMF_CTRL_T), TX_VLAN_TAG_OFF); | 910 | sky2_write32(hw, SK_REG(port, TX_GMF_CTRL_T), TX_VLAN_TAG_OFF); |
900 | if (sky2->vlgrp) | 911 | if (sky2->vlgrp) |
901 | sky2->vlgrp->vlan_devices[vid] = NULL; | 912 | sky2->vlgrp->vlan_devices[vid] = NULL; |
902 | 913 | ||
903 | spin_unlock(&sky2->tx_lock); | 914 | spin_unlock_bh(&sky2->tx_lock); |
904 | } | 915 | } |
905 | #endif | 916 | #endif |
906 | 917 | ||
907 | /* | 918 | /* |
919 | * It appears the hardware has a bug in the FIFO logic that | ||
920 | * cause it to hang if the FIFO gets overrun and the receive buffer | ||
921 | * is not aligned. ALso alloc_skb() won't align properly if slab | ||
922 | * debugging is enabled. | ||
923 | */ | ||
924 | static inline struct sk_buff *sky2_alloc_skb(unsigned int size, gfp_t gfp_mask) | ||
925 | { | ||
926 | struct sk_buff *skb; | ||
927 | |||
928 | skb = alloc_skb(size + RX_SKB_ALIGN, gfp_mask); | ||
929 | if (likely(skb)) { | ||
930 | unsigned long p = (unsigned long) skb->data; | ||
931 | skb_reserve(skb, | ||
932 | ((p + RX_SKB_ALIGN - 1) & ~(RX_SKB_ALIGN - 1)) - p); | ||
933 | } | ||
934 | |||
935 | return skb; | ||
936 | } | ||
937 | |||
938 | /* | ||
908 | * Allocate and setup receiver buffer pool. | 939 | * Allocate and setup receiver buffer pool. |
909 | * In case of 64 bit dma, there are 2X as many list elements | 940 | * In case of 64 bit dma, there are 2X as many list elements |
910 | * available as ring entries | 941 | * available as ring entries |
911 | * and need to reserve one list element so we don't wrap around. | 942 | * and need to reserve one list element so we don't wrap around. |
912 | * | ||
913 | * It appears the hardware has a bug in the FIFO logic that | ||
914 | * cause it to hang if the FIFO gets overrun and the receive buffer | ||
915 | * is not aligned. This means we can't use skb_reserve to align | ||
916 | * the IP header. | ||
917 | */ | 943 | */ |
918 | static int sky2_rx_start(struct sky2_port *sky2) | 944 | static int sky2_rx_start(struct sky2_port *sky2) |
919 | { | 945 | { |
@@ -929,7 +955,7 @@ static int sky2_rx_start(struct sky2_port *sky2) | |||
929 | for (i = 0; i < sky2->rx_pending; i++) { | 955 | for (i = 0; i < sky2->rx_pending; i++) { |
930 | struct ring_info *re = sky2->rx_ring + i; | 956 | struct ring_info *re = sky2->rx_ring + i; |
931 | 957 | ||
932 | re->skb = dev_alloc_skb(sky2->rx_bufsize); | 958 | re->skb = sky2_alloc_skb(sky2->rx_bufsize, GFP_KERNEL); |
933 | if (!re->skb) | 959 | if (!re->skb) |
934 | goto nomem; | 960 | goto nomem; |
935 | 961 | ||
@@ -986,19 +1012,19 @@ static int sky2_up(struct net_device *dev) | |||
986 | 1012 | ||
987 | sky2_mac_init(hw, port); | 1013 | sky2_mac_init(hw, port); |
988 | 1014 | ||
989 | /* Configure RAM buffers */ | 1015 | /* Determine available ram buffer space (in 4K blocks). |
990 | if (hw->chip_id == CHIP_ID_YUKON_FE || | 1016 | * Note: not sure about the FE setting below yet |
991 | (hw->chip_id == CHIP_ID_YUKON_EC && hw->chip_rev == 2)) | 1017 | */ |
992 | ramsize = 4096; | 1018 | if (hw->chip_id == CHIP_ID_YUKON_FE) |
993 | else { | 1019 | ramsize = 4; |
994 | u8 e0 = sky2_read8(hw, B2_E_0); | 1020 | else |
995 | ramsize = (e0 == 0) ? (128 * 1024) : (e0 * 4096); | 1021 | ramsize = sky2_read8(hw, B2_E_0); |
996 | } | 1022 | |
1023 | /* Give transmitter one third (rounded up) */ | ||
1024 | rxspace = ramsize - (ramsize + 2) / 3; | ||
997 | 1025 | ||
998 | /* 2/3 for Rx */ | ||
999 | rxspace = (2 * ramsize) / 3; | ||
1000 | sky2_ramset(hw, rxqaddr[port], 0, rxspace); | 1026 | sky2_ramset(hw, rxqaddr[port], 0, rxspace); |
1001 | sky2_ramset(hw, txqaddr[port], rxspace, ramsize - rxspace); | 1027 | sky2_ramset(hw, txqaddr[port], rxspace, ramsize); |
1002 | 1028 | ||
1003 | /* Make sure SyncQ is disabled */ | 1029 | /* Make sure SyncQ is disabled */ |
1004 | sky2_write8(hw, RB_ADDR(port == 0 ? Q_XS1 : Q_XS2, RB_CTRL), | 1030 | sky2_write8(hw, RB_ADDR(port == 0 ? Q_XS1 : Q_XS2, RB_CTRL), |
@@ -1054,7 +1080,7 @@ static inline int tx_avail(const struct sky2_port *sky2) | |||
1054 | } | 1080 | } |
1055 | 1081 | ||
1056 | /* Estimate of number of transmit list elements required */ | 1082 | /* Estimate of number of transmit list elements required */ |
1057 | static inline unsigned tx_le_req(const struct sk_buff *skb) | 1083 | static unsigned tx_le_req(const struct sk_buff *skb) |
1058 | { | 1084 | { |
1059 | unsigned count; | 1085 | unsigned count; |
1060 | 1086 | ||
@@ -1090,6 +1116,10 @@ static int sky2_xmit_frame(struct sk_buff *skb, struct net_device *dev) | |||
1090 | u16 mss; | 1116 | u16 mss; |
1091 | u8 ctrl; | 1117 | u8 ctrl; |
1092 | 1118 | ||
1119 | /* No BH disabling for tx_lock here. We are running in BH disabled | ||
1120 | * context and TX reclaim runs via poll inside of a software | ||
1121 | * interrupt, and no related locks in IRQ processing. | ||
1122 | */ | ||
1093 | if (!spin_trylock(&sky2->tx_lock)) | 1123 | if (!spin_trylock(&sky2->tx_lock)) |
1094 | return NETDEV_TX_LOCKED; | 1124 | return NETDEV_TX_LOCKED; |
1095 | 1125 | ||
@@ -1099,8 +1129,9 @@ static int sky2_xmit_frame(struct sk_buff *skb, struct net_device *dev) | |||
1099 | */ | 1129 | */ |
1100 | if (!netif_queue_stopped(dev)) { | 1130 | if (!netif_queue_stopped(dev)) { |
1101 | netif_stop_queue(dev); | 1131 | netif_stop_queue(dev); |
1102 | printk(KERN_WARNING PFX "%s: ring full when queue awake!\n", | 1132 | if (net_ratelimit()) |
1103 | dev->name); | 1133 | printk(KERN_WARNING PFX "%s: ring full when queue awake!\n", |
1134 | dev->name); | ||
1104 | } | 1135 | } |
1105 | spin_unlock(&sky2->tx_lock); | 1136 | spin_unlock(&sky2->tx_lock); |
1106 | 1137 | ||
@@ -1199,7 +1230,7 @@ static int sky2_xmit_frame(struct sk_buff *skb, struct net_device *dev) | |||
1199 | 1230 | ||
1200 | mapping = pci_map_page(hw->pdev, frag->page, frag->page_offset, | 1231 | mapping = pci_map_page(hw->pdev, frag->page, frag->page_offset, |
1201 | frag->size, PCI_DMA_TODEVICE); | 1232 | frag->size, PCI_DMA_TODEVICE); |
1202 | addr64 = (mapping >> 16) >> 16; | 1233 | addr64 = high32(mapping); |
1203 | if (addr64 != sky2->tx_addr64) { | 1234 | if (addr64 != sky2->tx_addr64) { |
1204 | le = get_tx_le(sky2); | 1235 | le = get_tx_le(sky2); |
1205 | le->tx.addr = cpu_to_le32(addr64); | 1236 | le->tx.addr = cpu_to_le32(addr64); |
@@ -1229,7 +1260,6 @@ static int sky2_xmit_frame(struct sk_buff *skb, struct net_device *dev) | |||
1229 | netif_stop_queue(dev); | 1260 | netif_stop_queue(dev); |
1230 | 1261 | ||
1231 | out_unlock: | 1262 | out_unlock: |
1232 | mmiowb(); | ||
1233 | spin_unlock(&sky2->tx_lock); | 1263 | spin_unlock(&sky2->tx_lock); |
1234 | 1264 | ||
1235 | dev->trans_start = jiffies; | 1265 | dev->trans_start = jiffies; |
@@ -1282,17 +1312,17 @@ static void sky2_tx_complete(struct sky2_port *sky2, u16 done) | |||
1282 | dev_kfree_skb_any(skb); | 1312 | dev_kfree_skb_any(skb); |
1283 | } | 1313 | } |
1284 | 1314 | ||
1285 | spin_lock(&sky2->tx_lock); | ||
1286 | sky2->tx_cons = put; | 1315 | sky2->tx_cons = put; |
1287 | if (netif_queue_stopped(dev) && tx_avail(sky2) > MAX_SKB_TX_LE) | 1316 | if (netif_queue_stopped(dev) && tx_avail(sky2) > MAX_SKB_TX_LE) |
1288 | netif_wake_queue(dev); | 1317 | netif_wake_queue(dev); |
1289 | spin_unlock(&sky2->tx_lock); | ||
1290 | } | 1318 | } |
1291 | 1319 | ||
1292 | /* Cleanup all untransmitted buffers, assume transmitter not running */ | 1320 | /* Cleanup all untransmitted buffers, assume transmitter not running */ |
1293 | static void sky2_tx_clean(struct sky2_port *sky2) | 1321 | static void sky2_tx_clean(struct sky2_port *sky2) |
1294 | { | 1322 | { |
1323 | spin_lock_bh(&sky2->tx_lock); | ||
1295 | sky2_tx_complete(sky2, sky2->tx_prod); | 1324 | sky2_tx_complete(sky2, sky2->tx_prod); |
1325 | spin_unlock_bh(&sky2->tx_lock); | ||
1296 | } | 1326 | } |
1297 | 1327 | ||
1298 | /* Network shutdown */ | 1328 | /* Network shutdown */ |
@@ -1582,28 +1612,40 @@ out: | |||
1582 | local_irq_enable(); | 1612 | local_irq_enable(); |
1583 | } | 1613 | } |
1584 | 1614 | ||
1615 | |||
1616 | /* Transmit timeout is only called if we are running, carries is up | ||
1617 | * and tx queue is full (stopped). | ||
1618 | */ | ||
1585 | static void sky2_tx_timeout(struct net_device *dev) | 1619 | static void sky2_tx_timeout(struct net_device *dev) |
1586 | { | 1620 | { |
1587 | struct sky2_port *sky2 = netdev_priv(dev); | 1621 | struct sky2_port *sky2 = netdev_priv(dev); |
1588 | struct sky2_hw *hw = sky2->hw; | 1622 | struct sky2_hw *hw = sky2->hw; |
1589 | unsigned txq = txqaddr[sky2->port]; | 1623 | unsigned txq = txqaddr[sky2->port]; |
1624 | u16 ridx; | ||
1625 | |||
1626 | /* Maybe we just missed an status interrupt */ | ||
1627 | spin_lock(&sky2->tx_lock); | ||
1628 | ridx = sky2_read16(hw, | ||
1629 | sky2->port == 0 ? STAT_TXA1_RIDX : STAT_TXA2_RIDX); | ||
1630 | sky2_tx_complete(sky2, ridx); | ||
1631 | spin_unlock(&sky2->tx_lock); | ||
1632 | |||
1633 | if (!netif_queue_stopped(dev)) { | ||
1634 | if (net_ratelimit()) | ||
1635 | pr_info(PFX "transmit interrupt missed? recovered\n"); | ||
1636 | return; | ||
1637 | } | ||
1590 | 1638 | ||
1591 | if (netif_msg_timer(sky2)) | 1639 | if (netif_msg_timer(sky2)) |
1592 | printk(KERN_ERR PFX "%s: tx timeout\n", dev->name); | 1640 | printk(KERN_ERR PFX "%s: tx timeout\n", dev->name); |
1593 | 1641 | ||
1594 | netif_stop_queue(dev); | ||
1595 | |||
1596 | sky2_write32(hw, Q_ADDR(txq, Q_CSR), BMU_STOP); | 1642 | sky2_write32(hw, Q_ADDR(txq, Q_CSR), BMU_STOP); |
1597 | sky2_read32(hw, Q_ADDR(txq, Q_CSR)); | ||
1598 | |||
1599 | sky2_write32(hw, Y2_QADDR(txq, PREF_UNIT_CTRL), PREF_UNIT_RST_SET); | 1643 | sky2_write32(hw, Y2_QADDR(txq, PREF_UNIT_CTRL), PREF_UNIT_RST_SET); |
1600 | 1644 | ||
1601 | sky2_tx_clean(sky2); | 1645 | sky2_tx_clean(sky2); |
1602 | 1646 | ||
1603 | sky2_qset(hw, txq); | 1647 | sky2_qset(hw, txq); |
1604 | sky2_prefetch_init(hw, txq, sky2->tx_le_map, TX_RING_SIZE - 1); | 1648 | sky2_prefetch_init(hw, txq, sky2->tx_le_map, TX_RING_SIZE - 1); |
1605 | |||
1606 | netif_wake_queue(dev); | ||
1607 | } | 1649 | } |
1608 | 1650 | ||
1609 | 1651 | ||
@@ -1713,7 +1755,7 @@ static struct sk_buff *sky2_receive(struct sky2_port *sky2, | |||
1713 | } else { | 1755 | } else { |
1714 | struct sk_buff *nskb; | 1756 | struct sk_buff *nskb; |
1715 | 1757 | ||
1716 | nskb = dev_alloc_skb(sky2->rx_bufsize); | 1758 | nskb = sky2_alloc_skb(sky2->rx_bufsize, GFP_ATOMIC); |
1717 | if (!nskb) | 1759 | if (!nskb) |
1718 | goto resubmit; | 1760 | goto resubmit; |
1719 | 1761 | ||
@@ -1745,7 +1787,7 @@ oversize: | |||
1745 | error: | 1787 | error: |
1746 | ++sky2->net_stats.rx_errors; | 1788 | ++sky2->net_stats.rx_errors; |
1747 | 1789 | ||
1748 | if (netif_msg_rx_err(sky2)) | 1790 | if (netif_msg_rx_err(sky2) && net_ratelimit()) |
1749 | printk(KERN_INFO PFX "%s: rx error, status 0x%x length %d\n", | 1791 | printk(KERN_INFO PFX "%s: rx error, status 0x%x length %d\n", |
1750 | sky2->netdev->name, status, length); | 1792 | sky2->netdev->name, status, length); |
1751 | 1793 | ||
@@ -1766,13 +1808,16 @@ error: | |||
1766 | */ | 1808 | */ |
1767 | #define TX_NO_STATUS 0xffff | 1809 | #define TX_NO_STATUS 0xffff |
1768 | 1810 | ||
1769 | static inline void sky2_tx_check(struct sky2_hw *hw, int port, u16 last) | 1811 | static void sky2_tx_check(struct sky2_hw *hw, int port, u16 last) |
1770 | { | 1812 | { |
1771 | if (last != TX_NO_STATUS) { | 1813 | if (last != TX_NO_STATUS) { |
1772 | struct net_device *dev = hw->dev[port]; | 1814 | struct net_device *dev = hw->dev[port]; |
1773 | if (dev && netif_running(dev)) { | 1815 | if (dev && netif_running(dev)) { |
1774 | struct sky2_port *sky2 = netdev_priv(dev); | 1816 | struct sky2_port *sky2 = netdev_priv(dev); |
1817 | |||
1818 | spin_lock(&sky2->tx_lock); | ||
1775 | sky2_tx_complete(sky2, last); | 1819 | sky2_tx_complete(sky2, last); |
1820 | spin_unlock(&sky2->tx_lock); | ||
1776 | } | 1821 | } |
1777 | } | 1822 | } |
1778 | } | 1823 | } |
@@ -1800,7 +1845,6 @@ static int sky2_poll(struct net_device *dev0, int *budget) | |||
1800 | struct sk_buff *skb; | 1845 | struct sk_buff *skb; |
1801 | u32 status; | 1846 | u32 status; |
1802 | u16 length; | 1847 | u16 length; |
1803 | u8 op; | ||
1804 | 1848 | ||
1805 | le = hw->st_le + hw->st_idx; | 1849 | le = hw->st_le + hw->st_idx; |
1806 | hw->st_idx = (hw->st_idx + 1) % STATUS_RING_SIZE; | 1850 | hw->st_idx = (hw->st_idx + 1) % STATUS_RING_SIZE; |
@@ -1814,10 +1858,8 @@ static int sky2_poll(struct net_device *dev0, int *budget) | |||
1814 | sky2 = netdev_priv(dev); | 1858 | sky2 = netdev_priv(dev); |
1815 | status = le32_to_cpu(le->status); | 1859 | status = le32_to_cpu(le->status); |
1816 | length = le16_to_cpu(le->length); | 1860 | length = le16_to_cpu(le->length); |
1817 | op = le->opcode & ~HW_OWNER; | ||
1818 | le->opcode = 0; | ||
1819 | 1861 | ||
1820 | switch (op) { | 1862 | switch (le->opcode & ~HW_OWNER) { |
1821 | case OP_RXSTAT: | 1863 | case OP_RXSTAT: |
1822 | skb = sky2_receive(sky2, length, status); | 1864 | skb = sky2_receive(sky2, length, status); |
1823 | if (!skb) | 1865 | if (!skb) |
@@ -1865,14 +1907,13 @@ static int sky2_poll(struct net_device *dev0, int *budget) | |||
1865 | default: | 1907 | default: |
1866 | if (net_ratelimit()) | 1908 | if (net_ratelimit()) |
1867 | printk(KERN_WARNING PFX | 1909 | printk(KERN_WARNING PFX |
1868 | "unknown status opcode 0x%x\n", op); | 1910 | "unknown status opcode 0x%x\n", le->opcode); |
1869 | break; | 1911 | break; |
1870 | } | 1912 | } |
1871 | } | 1913 | } |
1872 | 1914 | ||
1873 | exit_loop: | 1915 | exit_loop: |
1874 | sky2_write32(hw, STAT_CTRL, SC_STAT_CLR_IRQ); | 1916 | sky2_write32(hw, STAT_CTRL, SC_STAT_CLR_IRQ); |
1875 | mmiowb(); | ||
1876 | 1917 | ||
1877 | sky2_tx_check(hw, 0, tx_done[0]); | 1918 | sky2_tx_check(hw, 0, tx_done[0]); |
1878 | sky2_tx_check(hw, 1, tx_done[1]); | 1919 | sky2_tx_check(hw, 1, tx_done[1]); |
@@ -1887,7 +1928,6 @@ exit_loop: | |||
1887 | netif_rx_complete(dev0); | 1928 | netif_rx_complete(dev0); |
1888 | hw->intr_mask |= Y2_IS_STAT_BMU; | 1929 | hw->intr_mask |= Y2_IS_STAT_BMU; |
1889 | sky2_write32(hw, B0_IMSK, hw->intr_mask); | 1930 | sky2_write32(hw, B0_IMSK, hw->intr_mask); |
1890 | mmiowb(); | ||
1891 | return 0; | 1931 | return 0; |
1892 | } else { | 1932 | } else { |
1893 | *budget -= work_done; | 1933 | *budget -= work_done; |
@@ -1900,35 +1940,42 @@ static void sky2_hw_error(struct sky2_hw *hw, unsigned port, u32 status) | |||
1900 | { | 1940 | { |
1901 | struct net_device *dev = hw->dev[port]; | 1941 | struct net_device *dev = hw->dev[port]; |
1902 | 1942 | ||
1903 | printk(KERN_INFO PFX "%s: hw error interrupt status 0x%x\n", | 1943 | if (net_ratelimit()) |
1904 | dev->name, status); | 1944 | printk(KERN_INFO PFX "%s: hw error interrupt status 0x%x\n", |
1945 | dev->name, status); | ||
1905 | 1946 | ||
1906 | if (status & Y2_IS_PAR_RD1) { | 1947 | if (status & Y2_IS_PAR_RD1) { |
1907 | printk(KERN_ERR PFX "%s: ram data read parity error\n", | 1948 | if (net_ratelimit()) |
1908 | dev->name); | 1949 | printk(KERN_ERR PFX "%s: ram data read parity error\n", |
1950 | dev->name); | ||
1909 | /* Clear IRQ */ | 1951 | /* Clear IRQ */ |
1910 | sky2_write16(hw, RAM_BUFFER(port, B3_RI_CTRL), RI_CLR_RD_PERR); | 1952 | sky2_write16(hw, RAM_BUFFER(port, B3_RI_CTRL), RI_CLR_RD_PERR); |
1911 | } | 1953 | } |
1912 | 1954 | ||
1913 | if (status & Y2_IS_PAR_WR1) { | 1955 | if (status & Y2_IS_PAR_WR1) { |
1914 | printk(KERN_ERR PFX "%s: ram data write parity error\n", | 1956 | if (net_ratelimit()) |
1915 | dev->name); | 1957 | printk(KERN_ERR PFX "%s: ram data write parity error\n", |
1958 | dev->name); | ||
1916 | 1959 | ||
1917 | sky2_write16(hw, RAM_BUFFER(port, B3_RI_CTRL), RI_CLR_WR_PERR); | 1960 | sky2_write16(hw, RAM_BUFFER(port, B3_RI_CTRL), RI_CLR_WR_PERR); |
1918 | } | 1961 | } |
1919 | 1962 | ||
1920 | if (status & Y2_IS_PAR_MAC1) { | 1963 | if (status & Y2_IS_PAR_MAC1) { |
1921 | printk(KERN_ERR PFX "%s: MAC parity error\n", dev->name); | 1964 | if (net_ratelimit()) |
1965 | printk(KERN_ERR PFX "%s: MAC parity error\n", dev->name); | ||
1922 | sky2_write8(hw, SK_REG(port, TX_GMF_CTRL_T), GMF_CLI_TX_PE); | 1966 | sky2_write8(hw, SK_REG(port, TX_GMF_CTRL_T), GMF_CLI_TX_PE); |
1923 | } | 1967 | } |
1924 | 1968 | ||
1925 | if (status & Y2_IS_PAR_RX1) { | 1969 | if (status & Y2_IS_PAR_RX1) { |
1926 | printk(KERN_ERR PFX "%s: RX parity error\n", dev->name); | 1970 | if (net_ratelimit()) |
1971 | printk(KERN_ERR PFX "%s: RX parity error\n", dev->name); | ||
1927 | sky2_write32(hw, Q_ADDR(rxqaddr[port], Q_CSR), BMU_CLR_IRQ_PAR); | 1972 | sky2_write32(hw, Q_ADDR(rxqaddr[port], Q_CSR), BMU_CLR_IRQ_PAR); |
1928 | } | 1973 | } |
1929 | 1974 | ||
1930 | if (status & Y2_IS_TCP_TXA1) { | 1975 | if (status & Y2_IS_TCP_TXA1) { |
1931 | printk(KERN_ERR PFX "%s: TCP segmentation error\n", dev->name); | 1976 | if (net_ratelimit()) |
1977 | printk(KERN_ERR PFX "%s: TCP segmentation error\n", | ||
1978 | dev->name); | ||
1932 | sky2_write32(hw, Q_ADDR(txqaddr[port], Q_CSR), BMU_CLR_IRQ_TCP); | 1979 | sky2_write32(hw, Q_ADDR(txqaddr[port], Q_CSR), BMU_CLR_IRQ_TCP); |
1933 | } | 1980 | } |
1934 | } | 1981 | } |
@@ -1944,8 +1991,9 @@ static void sky2_hw_intr(struct sky2_hw *hw) | |||
1944 | u16 pci_err; | 1991 | u16 pci_err; |
1945 | 1992 | ||
1946 | pci_read_config_word(hw->pdev, PCI_STATUS, &pci_err); | 1993 | pci_read_config_word(hw->pdev, PCI_STATUS, &pci_err); |
1947 | printk(KERN_ERR PFX "%s: pci hw error (0x%x)\n", | 1994 | if (net_ratelimit()) |
1948 | pci_name(hw->pdev), pci_err); | 1995 | printk(KERN_ERR PFX "%s: pci hw error (0x%x)\n", |
1996 | pci_name(hw->pdev), pci_err); | ||
1949 | 1997 | ||
1950 | sky2_write8(hw, B2_TST_CTRL1, TST_CFG_WRITE_ON); | 1998 | sky2_write8(hw, B2_TST_CTRL1, TST_CFG_WRITE_ON); |
1951 | pci_write_config_word(hw->pdev, PCI_STATUS, | 1999 | pci_write_config_word(hw->pdev, PCI_STATUS, |
@@ -1959,8 +2007,9 @@ static void sky2_hw_intr(struct sky2_hw *hw) | |||
1959 | 2007 | ||
1960 | pci_read_config_dword(hw->pdev, PEX_UNC_ERR_STAT, &pex_err); | 2008 | pci_read_config_dword(hw->pdev, PEX_UNC_ERR_STAT, &pex_err); |
1961 | 2009 | ||
1962 | printk(KERN_ERR PFX "%s: pci express error (0x%x)\n", | 2010 | if (net_ratelimit()) |
1963 | pci_name(hw->pdev), pex_err); | 2011 | printk(KERN_ERR PFX "%s: pci express error (0x%x)\n", |
2012 | pci_name(hw->pdev), pex_err); | ||
1964 | 2013 | ||
1965 | /* clear the interrupt */ | 2014 | /* clear the interrupt */ |
1966 | sky2_write32(hw, B2_TST_CTRL1, TST_CFG_WRITE_ON); | 2015 | sky2_write32(hw, B2_TST_CTRL1, TST_CFG_WRITE_ON); |
@@ -2250,7 +2299,7 @@ static int sky2_reset(struct sky2_hw *hw) | |||
2250 | return 0; | 2299 | return 0; |
2251 | } | 2300 | } |
2252 | 2301 | ||
2253 | static inline u32 sky2_supported_modes(const struct sky2_hw *hw) | 2302 | static u32 sky2_supported_modes(const struct sky2_hw *hw) |
2254 | { | 2303 | { |
2255 | u32 modes; | 2304 | u32 modes; |
2256 | if (hw->copper) { | 2305 | if (hw->copper) { |
@@ -2995,7 +3044,7 @@ static __devinit struct net_device *sky2_init_netdev(struct sky2_hw *hw, | |||
2995 | return dev; | 3044 | return dev; |
2996 | } | 3045 | } |
2997 | 3046 | ||
2998 | static inline void sky2_show_addr(struct net_device *dev) | 3047 | static void __devinit sky2_show_addr(struct net_device *dev) |
2999 | { | 3048 | { |
3000 | const struct sky2_port *sky2 = netdev_priv(dev); | 3049 | const struct sky2_port *sky2 = netdev_priv(dev); |
3001 | 3050 | ||
@@ -3038,13 +3087,17 @@ static int __devinit sky2_probe(struct pci_dev *pdev, | |||
3038 | goto err_out_free_regions; | 3087 | goto err_out_free_regions; |
3039 | } | 3088 | } |
3040 | 3089 | ||
3041 | if (sizeof(dma_addr_t) > sizeof(u32)) { | 3090 | if (sizeof(dma_addr_t) > sizeof(u32) && |
3042 | err = pci_set_dma_mask(pdev, DMA_64BIT_MASK); | 3091 | !(err = pci_set_dma_mask(pdev, DMA_64BIT_MASK))) { |
3043 | if (!err) | 3092 | using_dac = 1; |
3044 | using_dac = 1; | 3093 | err = pci_set_consistent_dma_mask(pdev, DMA_64BIT_MASK); |
3045 | } | 3094 | if (err < 0) { |
3095 | printk(KERN_ERR PFX "%s unable to obtain 64 bit DMA " | ||
3096 | "for consistent allocations\n", pci_name(pdev)); | ||
3097 | goto err_out_free_regions; | ||
3098 | } | ||
3046 | 3099 | ||
3047 | if (!using_dac) { | 3100 | } else { |
3048 | err = pci_set_dma_mask(pdev, DMA_32BIT_MASK); | 3101 | err = pci_set_dma_mask(pdev, DMA_32BIT_MASK); |
3049 | if (err) { | 3102 | if (err) { |
3050 | printk(KERN_ERR PFX "%s no usable DMA configuration\n", | 3103 | printk(KERN_ERR PFX "%s no usable DMA configuration\n", |
@@ -3052,6 +3105,7 @@ static int __devinit sky2_probe(struct pci_dev *pdev, | |||
3052 | goto err_out_free_regions; | 3105 | goto err_out_free_regions; |
3053 | } | 3106 | } |
3054 | } | 3107 | } |
3108 | |||
3055 | #ifdef __BIG_ENDIAN | 3109 | #ifdef __BIG_ENDIAN |
3056 | /* byte swap descriptors in hardware */ | 3110 | /* byte swap descriptors in hardware */ |
3057 | { | 3111 | { |
@@ -3064,14 +3118,13 @@ static int __devinit sky2_probe(struct pci_dev *pdev, | |||
3064 | #endif | 3118 | #endif |
3065 | 3119 | ||
3066 | err = -ENOMEM; | 3120 | err = -ENOMEM; |
3067 | hw = kmalloc(sizeof(*hw), GFP_KERNEL); | 3121 | hw = kzalloc(sizeof(*hw), GFP_KERNEL); |
3068 | if (!hw) { | 3122 | if (!hw) { |
3069 | printk(KERN_ERR PFX "%s: cannot allocate hardware struct\n", | 3123 | printk(KERN_ERR PFX "%s: cannot allocate hardware struct\n", |
3070 | pci_name(pdev)); | 3124 | pci_name(pdev)); |
3071 | goto err_out_free_regions; | 3125 | goto err_out_free_regions; |
3072 | } | 3126 | } |
3073 | 3127 | ||
3074 | memset(hw, 0, sizeof(*hw)); | ||
3075 | hw->pdev = pdev; | 3128 | hw->pdev = pdev; |
3076 | 3129 | ||
3077 | hw->regs = ioremap_nocache(pci_resource_start(pdev, 0), 0x4000); | 3130 | hw->regs = ioremap_nocache(pci_resource_start(pdev, 0), 0x4000); |