]> bbs.cooldavid.org Git - jme.git/blobdiff - jme.c
Adding eeprom info bash script
[jme.git] / jme.c
diff --git a/jme.c b/jme.c
index 83eb75a1d6a04ce5df1f605871a25d4232a80100..1fb72775c0f672688ccd3407d74d7c7614df7076 100644 (file)
--- a/jme.c
+++ b/jme.c
@@ -37,6 +37,7 @@
 #include <linux/tcp.h>
 #include <linux/udp.h>
 #include <linux/if_vlan.h>
+#include <linux/slab.h>
 #include <net/ip6_checksum.h>
 #include "jme.h"
 
@@ -102,8 +103,6 @@ jme_mdio_write(struct net_device *netdev,
 
        if (i == 0)
                jeprintk(jme->pdev, "phy(%d) write timeout : %d\n", phy, reg);
-
-       return;
 }
 
 static inline void
@@ -129,8 +128,6 @@ jme_reset_phy_processor(struct jme_adapter *jme)
        jme_mdio_write(jme->dev,
                        jme->mii_if.phy_id,
                        MII_BMCR, val | BMCR_RESET);
-
-       return;
 }
 
 static void
@@ -288,7 +285,11 @@ jme_set_rx_pcc(struct jme_adapter *jme, int p)
        wmb();
 
        if (!(test_bit(JME_FLAG_POLL, &jme->flags)))
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,33)
                msg_rx_status(jme, "Switched to PCC_P%d\n", p);
+#else
+               netif_info(jme, rx_status, jme->dev, "Switched to PCC_P%d\n", p);
+#endif
 }
 
 static void
@@ -322,20 +323,6 @@ jme_stop_irq(struct jme_adapter *jme)
        jwrite32f(jme, JME_IENC, INTR_ENABLE);
 }
 
-static inline void
-jme_enable_shadow(struct jme_adapter *jme)
-{
-       jwrite32(jme,
-                JME_SHBA_LO,
-                ((u32)jme->shadow_dma & ~((u32)0x1F)) | SHBA_POSTEN);
-}
-
-static inline void
-jme_disable_shadow(struct jme_adapter *jme)
-{
-       jwrite32(jme, JME_SHBA_LO, 0x0);
-}
-
 static u32
 jme_linkstat_from_phy(struct jme_adapter *jme)
 {
@@ -497,13 +484,21 @@ jme_check_link(struct net_device *netdev, int testonly)
                strcat(linkmsg, (phylink & PHY_LINK_MDI_STAT) ?
                                        "MDI-X" :
                                        "MDI");
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,33)
                msg_link(jme, "Link is up at %s.\n", linkmsg);
+#else
+               netif_info(jme, link, jme->dev, "Link is up at %s.\n", linkmsg);
+#endif
                netif_carrier_on(netdev);
        } else {
                if (testonly)
                        goto out;
 
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,33)
                msg_link(jme, "Link is down.\n");
+#else
+               netif_info(jme, link, jme->dev, "Link is down.\n");
+#endif
                jme->phylink = 0;
                netif_carrier_off(netdev);
        }
@@ -522,12 +517,8 @@ jme_setup_tx_resources(struct jme_adapter *jme)
                                   &(txring->dmaalloc),
                                   GFP_ATOMIC);
 
-       if (!txring->alloc) {
-               txring->desc = NULL;
-               txring->dmaalloc = 0;
-               txring->dma = 0;
-               return -ENOMEM;
-       }
+       if (!txring->alloc)
+               goto err_set_null;
 
        /*
         * 16 Bytes align
@@ -539,6 +530,11 @@ jme_setup_tx_resources(struct jme_adapter *jme)
        atomic_set(&txring->next_to_clean, 0);
        atomic_set(&txring->nr_free, jme->tx_ring_size);
 
+       txring->bufinf          = kmalloc(sizeof(struct jme_buffer_info) *
+                                       jme->tx_ring_size, GFP_ATOMIC);
+       if (unlikely(!(txring->bufinf)))
+               goto err_free_txring;
+
        /*
         * Initialize Transmit Descriptors
         */
@@ -547,6 +543,20 @@ jme_setup_tx_resources(struct jme_adapter *jme)
                sizeof(struct jme_buffer_info) * jme->tx_ring_size);
 
        return 0;
+
+err_free_txring:
+       dma_free_coherent(&(jme->pdev->dev),
+                         TX_RING_ALLOC_SIZE(jme->tx_ring_size),
+                         txring->alloc,
+                         txring->dmaalloc);
+
+err_set_null:
+       txring->desc = NULL;
+       txring->dmaalloc = 0;
+       txring->dma = 0;
+       txring->bufinf = NULL;
+
+       return -ENOMEM;
 }
 
 static void
@@ -554,19 +564,22 @@ jme_free_tx_resources(struct jme_adapter *jme)
 {
        int i;
        struct jme_ring *txring = &(jme->txring[0]);
-       struct jme_buffer_info *txbi = txring->bufinf;
+       struct jme_buffer_info *txbi;
 
        if (txring->alloc) {
-               for (i = 0 ; i < jme->tx_ring_size ; ++i) {
-                       txbi = txring->bufinf + i;
-                       if (txbi->skb) {
-                               dev_kfree_skb(txbi->skb);
-                               txbi->skb = NULL;
+               if (txring->bufinf) {
+                       for (i = 0 ; i < jme->tx_ring_size ; ++i) {
+                               txbi = txring->bufinf + i;
+                               if (txbi->skb) {
+                                       dev_kfree_skb(txbi->skb);
+                                       txbi->skb = NULL;
+                               }
+                               txbi->mapping           = 0;
+                               txbi->len               = 0;
+                               txbi->nr_desc           = 0;
+                               txbi->start_xmit        = 0;
                        }
-                       txbi->mapping           = 0;
-                       txbi->len               = 0;
-                       txbi->nr_desc           = 0;
-                       txbi->start_xmit        = 0;
+                       kfree(txring->bufinf);
                }
 
                dma_free_coherent(&(jme->pdev->dev),
@@ -578,11 +591,11 @@ jme_free_tx_resources(struct jme_adapter *jme)
                txring->desc            = NULL;
                txring->dmaalloc        = 0;
                txring->dma             = 0;
+               txring->bufinf          = NULL;
        }
        txring->next_to_use     = 0;
        atomic_set(&txring->next_to_clean, 0);
        atomic_set(&txring->nr_free, 0);
-
 }
 
 static inline void
@@ -653,7 +666,7 @@ jme_disable_tx_engine(struct jme_adapter *jme)
 static void
 jme_set_clean_rxdesc(struct jme_adapter *jme, int i)
 {
-       struct jme_ring *rxring = jme->rxring;
+       struct jme_ring *rxring = &(jme->rxring[0]);
        register struct rxdesc *rxdesc = rxring->desc;
        struct jme_buffer_info *rxbi = rxring->bufinf;
        rxdesc += i;
@@ -723,8 +736,11 @@ jme_free_rx_resources(struct jme_adapter *jme)
        struct jme_ring *rxring = &(jme->rxring[0]);
 
        if (rxring->alloc) {
-               for (i = 0 ; i < jme->rx_ring_size ; ++i)
-                       jme_free_rx_buf(jme, i);
+               if (rxring->bufinf) {
+                       for (i = 0 ; i < jme->rx_ring_size ; ++i)
+                               jme_free_rx_buf(jme, i);
+                       kfree(rxring->bufinf);
+               }
 
                dma_free_coherent(&(jme->pdev->dev),
                                  RX_RING_ALLOC_SIZE(jme->rx_ring_size),
@@ -734,6 +750,7 @@ jme_free_rx_resources(struct jme_adapter *jme)
                rxring->desc     = NULL;
                rxring->dmaalloc = 0;
                rxring->dma      = 0;
+               rxring->bufinf   = NULL;
        }
        rxring->next_to_use   = 0;
        atomic_set(&rxring->next_to_clean, 0);
@@ -749,12 +766,8 @@ jme_setup_rx_resources(struct jme_adapter *jme)
                                   RX_RING_ALLOC_SIZE(jme->rx_ring_size),
                                   &(rxring->dmaalloc),
                                   GFP_ATOMIC);
-       if (!rxring->alloc) {
-               rxring->desc = NULL;
-               rxring->dmaalloc = 0;
-               rxring->dma = 0;
-               return -ENOMEM;
-       }
+       if (!rxring->alloc)
+               goto err_set_null;
 
        /*
         * 16 Bytes align
@@ -765,9 +778,16 @@ jme_setup_rx_resources(struct jme_adapter *jme)
        rxring->next_to_use     = 0;
        atomic_set(&rxring->next_to_clean, 0);
 
+       rxring->bufinf          = kmalloc(sizeof(struct jme_buffer_info) *
+                                       jme->rx_ring_size, GFP_ATOMIC);
+       if (unlikely(!(rxring->bufinf)))
+               goto err_free_rxring;
+
        /*
         * Initiallize Receive Descriptors
         */
+       memset(rxring->bufinf, 0,
+               sizeof(struct jme_buffer_info) * jme->rx_ring_size);
        for (i = 0 ; i < jme->rx_ring_size ; ++i) {
                if (unlikely(jme_make_new_rx_buf(jme, i))) {
                        jme_free_rx_resources(jme);
@@ -778,6 +798,19 @@ jme_setup_rx_resources(struct jme_adapter *jme)
        }
 
        return 0;
+
+err_free_rxring:
+       dma_free_coherent(&(jme->pdev->dev),
+                         RX_RING_ALLOC_SIZE(jme->rx_ring_size),
+                         rxring->alloc,
+                         rxring->dmaalloc);
+err_set_null:
+       rxring->desc = NULL;
+       rxring->dmaalloc = 0;
+       rxring->dma = 0;
+       rxring->bufinf = NULL;
+
+       return -ENOMEM;
 }
 
 static inline void
@@ -793,9 +826,9 @@ jme_enable_rx_engine(struct jme_adapter *jme)
        /*
         * Setup RX DMA Bass Address
         */
-       jwrite32(jme, JME_RXDBA_LO, (__u64)jme->rxring[0].dma & 0xFFFFFFFFUL);
+       jwrite32(jme, JME_RXDBA_LO, (__u64)(jme->rxring[0].dma) & 0xFFFFFFFFUL);
        jwrite32(jme, JME_RXDBA_HI, (__u64)(jme->rxring[0].dma) >> 32);
-       jwrite32(jme, JME_RXNDA, (__u64)jme->rxring[0].dma & 0xFFFFFFFFUL);
+       jwrite32(jme, JME_RXNDA, (__u64)(jme->rxring[0].dma) & 0xFFFFFFFFUL);
 
        /*
         * Setup RX Descriptor Count
@@ -859,27 +892,39 @@ jme_rxsum_ok(struct jme_adapter *jme, u16 flags)
        if (!(flags & (RXWBFLAG_TCPON | RXWBFLAG_UDPON | RXWBFLAG_IPV4)))
                return false;
 
-       if (unlikely(!(flags & RXWBFLAG_MF) &&
-       (flags & RXWBFLAG_TCPON) && !(flags & RXWBFLAG_TCPCS))) {
-               msg_rx_err(jme, "TCP Checksum error.\n");
-               goto out_sumerr;
+       if (unlikely((flags & (RXWBFLAG_MF | RXWBFLAG_TCPON | RXWBFLAG_TCPCS))
+                       == RXWBFLAG_TCPON)) {
+               if (flags & RXWBFLAG_IPV4)
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,33)
+                       msg_rx_err(jme, "TCP Checksum error\n");
+#else
+                       netif_err(jme, rx_err, jme->dev, "TCP Checksum error\n");
+#endif
+               return false;
        }
 
-       if (unlikely(!(flags & RXWBFLAG_MF) &&
-       (flags & RXWBFLAG_UDPON) && !(flags & RXWBFLAG_UDPCS))) {
-               msg_rx_err(jme, "UDP Checksum error.\n");
-               goto out_sumerr;
+       if (unlikely((flags & (RXWBFLAG_MF | RXWBFLAG_UDPON | RXWBFLAG_UDPCS))
+                       == RXWBFLAG_UDPON)) {
+               if (flags & RXWBFLAG_IPV4)
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,33)
+                       msg_rx_err(jme, "UDP Checksum error.\n");
+#else
+                       netif_err(jme, rx_err, jme->dev, "UDP Checksum error.\n");
+#endif
+               return false;
        }
 
-       if (unlikely((flags & RXWBFLAG_IPV4) && !(flags & RXWBFLAG_IPCS))) {
+       if (unlikely((flags & (RXWBFLAG_IPV4 | RXWBFLAG_IPCS))
+                       == RXWBFLAG_IPV4)) {
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,33)
                msg_rx_err(jme, "IPv4 Checksum error.\n");
-               goto out_sumerr;
+#else
+               netif_err(jme, rx_err, jme->dev, "IPv4 Checksum error.\n");
+#endif
+               return false;
        }
 
        return true;
-
-out_sumerr:
-       return false;
 }
 
 static void
@@ -925,6 +970,8 @@ jme_alloc_and_feed_skb(struct jme_adapter *jme, int idx)
                                jme->jme_vlan_rx(skb, jme->vlgrp,
                                        le16_to_cpu(rxdesc->descwb.vlan));
                                NET_STAT(jme).rx_bytes += 4;
+                       } else {
+                               dev_kfree_skb(skb);
                        }
                } else {
                        jme->jme_rx(skb);
@@ -959,13 +1006,14 @@ jme_process_receive(struct jme_adapter *jme, int limit)
                goto out_inc;
 
        i = atomic_read(&rxring->next_to_clean);
-       while (limit-- > 0) {
+       while (limit > 0) {
                rxdesc = rxring->desc;
                rxdesc += i;
 
                if ((rxdesc->descwb.flags & cpu_to_le16(RXWBFLAG_OWN)) ||
                !(rxdesc->descwb.desccnt & RXWBDCNT_WBCPL))
                        goto out;
+               --limit;
 
                desccnt = rxdesc->descwb.desccnt & RXWBDCNT_DCNT;
 
@@ -1028,8 +1076,8 @@ jme_dynamic_pcc(struct jme_adapter *jme)
 
        if ((NET_STAT(jme).rx_bytes - dpi->last_bytes) > PCC_P3_THRESHOLD)
                jme_attempt_pcc(dpi, PCC_P3);
-       else if ((NET_STAT(jme).rx_packets - dpi->last_pkts) > PCC_P2_THRESHOLD
-       || dpi->intr_cnt > PCC_INTR_THRESHOLD)
+       else if ((NET_STAT(jme).rx_packets - dpi->last_pkts) > PCC_P2_THRESHOLD ||
+                dpi->intr_cnt > PCC_INTR_THRESHOLD)
                jme_attempt_pcc(dpi, PCC_P2);
        else
                jme_attempt_pcc(dpi, PCC_P1);
@@ -1164,9 +1212,17 @@ jme_link_change_tasklet(unsigned long arg)
 
        while (!atomic_dec_and_test(&jme->link_changing)) {
                atomic_inc(&jme->link_changing);
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,33)
                msg_intr(jme, "Get link change lock failed.\n");
+#else
+               netif_info(jme, intr, jme->dev, "Get link change lock failed.\n");
+#endif
                while (atomic_read(&jme->link_changing) != 1)
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,33)
                        msg_intr(jme, "Waiting link change lock.\n");
+#else
+                       netif_info(jme, intr, jme->dev, "Waiting link change lock.\n");
+#endif
        }
 
        if (jme_check_link(netdev, 1) && jme->old_mtu == netdev->mtu)
@@ -1284,7 +1340,11 @@ jme_rx_empty_tasklet(unsigned long arg)
        if (unlikely(!netif_carrier_ok(jme->dev)))
                return;
 
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,33)
        msg_rx_status(jme, "RX Queue Full!\n");
+#else
+       netif_info(jme, rx_status, jme->dev, "RX Queue Full!\n");
+#endif
 
        jme_rx_clean_tasklet(arg);
 
@@ -1299,12 +1359,16 @@ jme_rx_empty_tasklet(unsigned long arg)
 static void
 jme_wake_queue_if_stopped(struct jme_adapter *jme)
 {
-       struct jme_ring *txring = jme->txring;
+       struct jme_ring *txring = &(jme->txring[0]);
 
        smp_wmb();
        if (unlikely(netif_queue_stopped(jme->dev) &&
        atomic_read(&txring->nr_free) >= (jme->tx_wake_threshold))) {
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,33)
                msg_tx_done(jme, "TX Queue Waked.\n");
+#else
+               netif_info(jme, tx_done, jme->dev, "TX Queue Waked.\n");
+#endif
                netif_wake_queue(jme->dev);
        }
 
@@ -1496,12 +1560,7 @@ jme_msi(int irq, void *dev_id)
        struct jme_adapter *jme = netdev_priv(netdev);
        u32 intrstat;
 
-       pci_dma_sync_single_for_cpu(jme->pdev,
-                                   jme->shadow_dma,
-                                   sizeof(u32) * SHADOW_REG_NR,
-                                   PCI_DMA_FROMDEVICE);
-       intrstat = jme->shadow_regs[SHADOW_IEVE];
-       jme->shadow_regs[SHADOW_IEVE] = 0;
+       intrstat = jread32(jme, JME_IEVE);
 
        jme_intr_msi(jme, intrstat);
 
@@ -1584,6 +1643,7 @@ jme_open(struct net_device *netdev)
        jme_clear_pm(jme);
        JME_NAPI_ENABLE(jme);
 
+       tasklet_enable(&jme->linkch_task);
        tasklet_enable(&jme->txclean_task);
        tasklet_hi_enable(&jme->rxclean_task);
        tasklet_hi_enable(&jme->rxempty_task);
@@ -1592,7 +1652,6 @@ jme_open(struct net_device *netdev)
        if (rc)
                goto err_out;
 
-       jme_enable_shadow(jme);
        jme_start_irq(jme);
 
        if (test_bit(JME_FLAG_SSET, &jme->flags))
@@ -1660,15 +1719,14 @@ jme_close(struct net_device *netdev)
        netif_carrier_off(netdev);
 
        jme_stop_irq(jme);
-       jme_disable_shadow(jme);
        jme_free_irq(jme);
 
        JME_NAPI_DISABLE(jme);
 
-       tasklet_kill(&jme->linkch_task);
-       tasklet_kill(&jme->txclean_task);
-       tasklet_kill(&jme->rxclean_task);
-       tasklet_kill(&jme->rxempty_task);
+       tasklet_disable(&jme->linkch_task);
+       tasklet_disable(&jme->txclean_task);
+       tasklet_disable(&jme->rxclean_task);
+       tasklet_disable(&jme->rxempty_task);
 
        jme_reset_ghc_speed(jme);
        jme_disable_rx_engine(jme);
@@ -1686,7 +1744,7 @@ static int
 jme_alloc_txdesc(struct jme_adapter *jme,
                        struct sk_buff *skb)
 {
-       struct jme_ring *txring = jme->txring;
+       struct jme_ring *txring = &(jme->txring[0]);
        int idx, nr_alloc, mask = jme->tx_ring_mask;
 
        idx = txring->next_to_use;
@@ -1740,7 +1798,7 @@ jme_fill_tx_map(struct pci_dev *pdev,
 static void
 jme_map_tx_skb(struct jme_adapter *jme, struct sk_buff *skb, int idx)
 {
-       struct jme_ring *txring = jme->txring;
+       struct jme_ring *txring = &(jme->txring[0]);
        struct txdesc *txdesc = txring->desc, *ctxdesc;
        struct jme_buffer_info *txbi = txring->bufinf, *ctxbi;
        u8 hidma = jme->dev->features & NETIF_F_HIGHDMA;
@@ -1770,7 +1828,7 @@ static int
 jme_expand_header(struct jme_adapter *jme, struct sk_buff *skb)
 {
        if (unlikely(
-#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,16)
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,17)
        skb_shinfo(skb)->tso_size
 #else
        skb_shinfo(skb)->gso_size
@@ -1787,7 +1845,7 @@ jme_expand_header(struct jme_adapter *jme, struct sk_buff *skb)
 static int
 jme_tx_tso(struct sk_buff *skb, __le16 *mss, u8 *flags)
 {
-#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,16)
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,17)
        *mss = cpu_to_le16(skb_shinfo(skb)->tso_size << TXDESC_MSS_SHIFT);
 #else
        *mss = cpu_to_le16(skb_shinfo(skb)->gso_size << TXDESC_MSS_SHIFT);
@@ -1858,7 +1916,11 @@ jme_tx_csum(struct jme_adapter *jme, struct sk_buff *skb, u8 *flags)
                        *flags |= TXFLAG_UDPCS;
                        break;
                default:
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,33)
                        msg_tx_err(jme, "Error upper layer protocol.\n");
+#else
+                       netif_err(jme, tx_err, jme->dev, "Error upper layer protocol.\n");
+#endif
                        break;
                }
        }
@@ -1876,7 +1938,7 @@ jme_tx_vlan(struct sk_buff *skb, __le16 *vlan, u8 *flags)
 static int
 jme_fill_tx_desc(struct jme_adapter *jme, struct sk_buff *skb, int idx)
 {
-       struct jme_ring *txring = jme->txring;
+       struct jme_ring *txring = &(jme->txring[0]);
        struct txdesc *txdesc;
        struct jme_buffer_info *txbi;
        u8 flags;
@@ -1924,7 +1986,7 @@ jme_fill_tx_desc(struct jme_adapter *jme, struct sk_buff *skb, int idx)
 static void
 jme_stop_queue_if_full(struct jme_adapter *jme)
 {
-       struct jme_ring *txring = jme->txring;
+       struct jme_ring *txring = &(jme->txring[0]);
        struct jme_buffer_info *txbi = txring->bufinf;
        int idx = atomic_read(&txring->next_to_clean);
 
@@ -1933,12 +1995,20 @@ jme_stop_queue_if_full(struct jme_adapter *jme)
        smp_wmb();
        if (unlikely(atomic_read(&txring->nr_free) < (MAX_SKB_FRAGS+2))) {
                netif_stop_queue(jme->dev);
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,33)
                msg_tx_queued(jme, "TX Queue Paused.\n");
+#else
+               netif_info(jme, tx_queued, jme->dev, "TX Queue Paused.\n");
+#endif
                smp_wmb();
                if (atomic_read(&txring->nr_free)
                        >= (jme->tx_wake_threshold)) {
                        netif_wake_queue(jme->dev);
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,33)
                        msg_tx_queued(jme, "TX Queue Fast Waked.\n");
+#else
+                       netif_info(jme, tx_queued, jme->dev, "TX Queue Fast Waked.\n");
+#endif
                }
        }
 
@@ -1946,7 +2016,11 @@ jme_stop_queue_if_full(struct jme_adapter *jme)
                        (jiffies - txbi->start_xmit) >= TX_TIMEOUT &&
                        txbi->skb)) {
                netif_stop_queue(jme->dev);
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,33)
                msg_tx_queued(jme, "TX Queue Stopped %d@%lu.\n", idx, jiffies);
+#else
+               netif_info(jme, tx_queued, jme->dev, "TX Queue Stopped %d@%lu.\n", idx, jiffies);
+#endif
        }
 }
 
@@ -1954,7 +2028,11 @@ jme_stop_queue_if_full(struct jme_adapter *jme)
  * This function is already protected by netif_tx_lock()
  */
 
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,31)
 static int
+#else
+static netdev_tx_t
+#endif
 jme_start_xmit(struct sk_buff *skb, struct net_device *netdev)
 {
        struct jme_adapter *jme = netdev_priv(netdev);
@@ -1969,7 +2047,11 @@ jme_start_xmit(struct sk_buff *skb, struct net_device *netdev)
 
        if (unlikely(idx < 0)) {
                netif_stop_queue(netdev);
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,33)
                msg_tx_err(jme, "BUG! Tx ring full when queue awake!\n");
+#else
+               netif_err(jme, tx_err, jme->dev, "BUG! Tx ring full when queue awake!\n");
+#endif
 
                return NETDEV_TX_BUSY;
        }
@@ -1980,7 +2062,9 @@ jme_start_xmit(struct sk_buff *skb, struct net_device *netdev)
                                TXCS_SELECT_QUEUE0 |
                                TXCS_QUEUE0S |
                                TXCS_ENABLE);
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,29)
        netdev->trans_start = jiffies;
+#endif
 
        tx_dbg(jme, "xmit: %d+%d@%lu\n", idx,
                        skb_shinfo(skb)->nr_frags + 2,
@@ -2021,7 +2105,9 @@ jme_set_multi(struct net_device *netdev)
 {
        struct jme_adapter *jme = netdev_priv(netdev);
        u32 mc_hash[2] = {};
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,33)
        int i;
+#endif
 
        spin_lock_bh(&jme->rxmcs_lock);
 
@@ -2032,15 +2118,28 @@ jme_set_multi(struct net_device *netdev)
        } else if (netdev->flags & IFF_ALLMULTI) {
                jme->reg_rxmcs |= RXMCS_ALLMULFRAME;
        } else if (netdev->flags & IFF_MULTICAST) {
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,34)
                struct dev_mc_list *mclist;
+#else
+               struct netdev_hw_addr *ha;
+#endif
                int bit_nr;
 
                jme->reg_rxmcs |= RXMCS_MULFRAME | RXMCS_MULFILTERED;
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,33)
                for (i = 0, mclist = netdev->mc_list;
                        mclist && i < netdev->mc_count;
                        ++i, mclist = mclist->next) {
-
+#elif LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,34)
+               netdev_for_each_mc_addr(mclist, netdev) {
+#else
+               netdev_for_each_mc_addr(ha, netdev) {
+#endif
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,34)
                        bit_nr = ether_crc(ETH_ALEN, mclist->dmi_addr) & 0x3F;
+#else
+                       bit_nr = ether_crc(ETH_ALEN, ha->addr) & 0x3F;
+#endif
                        mc_hash[bit_nr >> 5] |= 1 << (bit_nr & 0x1F);
                }
 
@@ -2116,13 +2215,64 @@ jme_tx_timeout(struct net_device *netdev)
        jme_reset_link(jme);
 }
 
+static inline void jme_pause_rx(struct jme_adapter *jme)
+{
+       atomic_dec(&jme->link_changing);
+
+       jme_set_rx_pcc(jme, PCC_OFF);
+       if (test_bit(JME_FLAG_POLL, &jme->flags)) {
+               JME_NAPI_DISABLE(jme);
+       } else {
+               tasklet_disable(&jme->rxclean_task);
+               tasklet_disable(&jme->rxempty_task);
+       }
+}
+
+static inline void jme_resume_rx(struct jme_adapter *jme)
+{
+       struct dynpcc_info *dpi = &(jme->dpi);
+
+       if (test_bit(JME_FLAG_POLL, &jme->flags)) {
+               JME_NAPI_ENABLE(jme);
+       } else {
+               tasklet_hi_enable(&jme->rxclean_task);
+               tasklet_hi_enable(&jme->rxempty_task);
+       }
+       dpi->cur                = PCC_P1;
+       dpi->attempt            = PCC_P1;
+       dpi->cnt                = 0;
+       jme_set_rx_pcc(jme, PCC_P1);
+
+       atomic_inc(&jme->link_changing);
+}
+
 static void
 jme_vlan_rx_register(struct net_device *netdev, struct vlan_group *grp)
 {
        struct jme_adapter *jme = netdev_priv(netdev);
 
+       jme_pause_rx(jme);
        jme->vlgrp = grp;
+       jme_resume_rx(jme);
+}
+
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,21)
+static void
+jme_vlan_rx_kill_vid(struct net_device *netdev, unsigned short vid)
+{
+       struct jme_adapter *jme = netdev_priv(netdev);
+
+       if(jme->vlgrp) {
+               jme_pause_rx(jme);
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,20)
+               jme->vlgrp->vlan_devices[vid] = NULL;
+#else
+               vlan_group_set_device(jme->vlgrp, vid, NULL);
+#endif
+               jme_resume_rx(jme);
+       }
 }
+#endif
 
 static void
 jme_get_drvinfo(struct net_device *netdev,
@@ -2230,8 +2380,8 @@ jme_set_coalesce(struct net_device *netdev, struct ethtool_coalesce *ecmd)
        if (netif_running(netdev))
                return -EBUSY;
 
-       if (ecmd->use_adaptive_rx_coalesce
-       && test_bit(JME_FLAG_POLL, &jme->flags)) {
+       if (ecmd->use_adaptive_rx_coalesce &&
+           test_bit(JME_FLAG_POLL, &jme->flags)) {
                clear_bit(JME_FLAG_POLL, &jme->flags);
                jme->jme_rx = netif_rx;
                jme->jme_vlan_rx = vlan_hwaccel_rx;
@@ -2240,8 +2390,8 @@ jme_set_coalesce(struct net_device *netdev, struct ethtool_coalesce *ecmd)
                dpi->cnt                = 0;
                jme_set_rx_pcc(jme, PCC_P1);
                jme_interrupt_mode(jme);
-       } else if (!(ecmd->use_adaptive_rx_coalesce)
-       && !(test_bit(JME_FLAG_POLL, &jme->flags))) {
+       } else if (!(ecmd->use_adaptive_rx_coalesce) &&
+                  !(test_bit(JME_FLAG_POLL, &jme->flags))) {
                set_bit(JME_FLAG_POLL, &jme->flags);
                jme->jme_rx = netif_receive_skb;
                jme->jme_vlan_rx = vlan_hwaccel_receive_skb;
@@ -2512,7 +2662,11 @@ jme_smb_read(struct jme_adapter *jme, unsigned int addr)
                val = jread32(jme, JME_SMBCSR);
        }
        if (!to) {
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,33)
                msg_hw(jme, "SMB Bus Busy.\n");
+#else
+               netif_err(jme, hw, jme->dev, "SMB Bus Busy.\n");
+#endif
                return 0xFF;
        }
 
@@ -2528,7 +2682,11 @@ jme_smb_read(struct jme_adapter *jme, unsigned int addr)
                val = jread32(jme, JME_SMBINTF);
        }
        if (!to) {
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,33)
                msg_hw(jme, "SMB Bus Busy.\n");
+#else
+               netif_err(jme, hw, jme->dev, "SMB Bus Busy.\n");
+#endif
                return 0xFF;
        }
 
@@ -2548,7 +2706,11 @@ jme_smb_write(struct jme_adapter *jme, unsigned int addr, u8 data)
                val = jread32(jme, JME_SMBCSR);
        }
        if (!to) {
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,33)
                msg_hw(jme, "SMB Bus Busy.\n");
+#else
+               netif_err(jme, hw, jme->dev, "SMB Bus Busy.\n");
+#endif
                return;
        }
 
@@ -2565,7 +2727,11 @@ jme_smb_write(struct jme_adapter *jme, unsigned int addr, u8 data)
                val = jread32(jme, JME_SMBINTF);
        }
        if (!to) {
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,33)
                msg_hw(jme, "SMB Bus Busy.\n");
+#else
+               netif_err(jme, hw, jme->dev, "SMB Bus Busy.\n");
+#endif
                return;
        }
 
@@ -2651,17 +2817,40 @@ static int
 jme_pci_dma64(struct pci_dev *pdev)
 {
        if (pdev->device == PCI_DEVICE_ID_JMICRON_JMC250 &&
-           !pci_set_dma_mask(pdev, DMA_64BIT_MASK))
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,29)
+           !pci_set_dma_mask(pdev, DMA_BIT_MASK(64))
+#else
+           !pci_set_dma_mask(pdev, DMA_64BIT_MASK)
+#endif
+          )
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,29)
+               if (!pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(64)))
+#else
                if (!pci_set_consistent_dma_mask(pdev, DMA_64BIT_MASK))
+#endif
                        return 1;
 
        if (pdev->device == PCI_DEVICE_ID_JMICRON_JMC250 &&
-           !pci_set_dma_mask(pdev, DMA_40BIT_MASK))
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,29)
+           !pci_set_dma_mask(pdev, DMA_BIT_MASK(40))
+#else
+           !pci_set_dma_mask(pdev, DMA_40BIT_MASK)
+#endif
+          )
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,29)
+               if (!pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(40)))
+#else
                if (!pci_set_consistent_dma_mask(pdev, DMA_40BIT_MASK))
+#endif
                        return 1;
 
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,29)
+       if (!pci_set_dma_mask(pdev, DMA_BIT_MASK(32)))
+               if (!pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32)))
+#else
        if (!pci_set_dma_mask(pdev, DMA_32BIT_MASK))
                if (!pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK))
+#endif
                        return 0;
 
        return -1;
@@ -2761,6 +2950,9 @@ jme_init_one(struct pci_dev *pdev,
        netdev->change_mtu              = jme_change_mtu;
        netdev->tx_timeout              = jme_tx_timeout;
        netdev->vlan_rx_register        = jme_vlan_rx_register;
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,21)
+       netdev->vlan_rx_kill_vid        = jme_vlan_rx_kill_vid;
+#endif
        NETDEV_GET_STATS(netdev, &jme_get_stats);
 #endif
        netdev->ethtool_ops             = &jme_ethtool_ops;
@@ -2789,16 +2981,10 @@ jme_init_one(struct pci_dev *pdev,
        jme->jme_vlan_rx = vlan_hwaccel_rx;
        jme->old_mtu = netdev->mtu = 1500;
        jme->phylink = 0;
-#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,21)
-       jme->tx_ring_size = 1 << 9;
-       jme->tx_wake_threshold = 1 << 8;
-       jme->rx_ring_size = 1 << 8;
-#else
        jme->tx_ring_size = 1 << 10;
+       jme->tx_ring_mask = jme->tx_ring_size - 1;
        jme->tx_wake_threshold = 1 << 9;
        jme->rx_ring_size = 1 << 9;
-#endif
-       jme->tx_ring_mask = jme->tx_ring_size - 1;
        jme->rx_ring_mask = jme->rx_ring_size - 1;
        jme->msg_enable = JME_DEF_MSG_ENABLE;
        jme->regs = ioremap(pci_resource_start(pdev, 0),
@@ -2808,14 +2994,6 @@ jme_init_one(struct pci_dev *pdev,
                rc = -ENOMEM;
                goto err_out_free_netdev;
        }
-       jme->shadow_regs = pci_alloc_consistent(pdev,
-                                               sizeof(u32) * SHADOW_REG_NR,
-                                               &(jme->shadow_dma));
-       if (!(jme->shadow_regs)) {
-               jeprintk(pdev, "Allocating shadow register mapping error.\n");
-               rc = -ENOMEM;
-               goto err_out_unmap;
-       }
 
        if (no_pseudohp) {
                apmc = jread32(jme, JME_APMC) & ~JME_APMC_PSEUDO_HP_EN;
@@ -2837,20 +3015,21 @@ jme_init_one(struct pci_dev *pdev,
        atomic_set(&jme->rx_empty, 1);
 
        tasklet_init(&jme->pcc_task,
-                    &jme_pcc_tasklet,
+                    jme_pcc_tasklet,
                     (unsigned long) jme);
        tasklet_init(&jme->linkch_task,
-                    &jme_link_change_tasklet,
+                    jme_link_change_tasklet,
                     (unsigned long) jme);
        tasklet_init(&jme->txclean_task,
-                    &jme_tx_clean_tasklet,
+                    jme_tx_clean_tasklet,
                     (unsigned long) jme);
        tasklet_init(&jme->rxclean_task,
-                    &jme_rx_clean_tasklet,
+                    jme_rx_clean_tasklet,
                     (unsigned long) jme);
        tasklet_init(&jme->rxempty_task,
-                    &jme_rx_empty_tasklet,
+                    jme_rx_empty_tasklet,
                     (unsigned long) jme);
+       tasklet_disable_nosync(&jme->linkch_task);
        tasklet_disable_nosync(&jme->txclean_task);
        tasklet_disable_nosync(&jme->rxclean_task);
        tasklet_disable_nosync(&jme->rxempty_task);
@@ -2879,7 +3058,7 @@ jme_init_one(struct pci_dev *pdev,
        default:
                jme->reg_txcs = TXCS_DEFAULT | TXCS_DMASIZE_512B;
                break;
-       };
+       }
 
        /*
         * Must check before reset_mac_processor
@@ -2900,7 +3079,7 @@ jme_init_one(struct pci_dev *pdev,
                if (!jme->mii_if.phy_id) {
                        rc = -EIO;
                        jeprintk(pdev, "Can not find phy_id.\n");
-                        goto err_out_free_shadow;
+                        goto err_out_unmap;
                }
 
                jme->reg_ghc |= GHC_LINK_POLL;
@@ -2929,7 +3108,7 @@ jme_init_one(struct pci_dev *pdev,
        if (rc) {
                jeprintk(pdev,
                        "Reload eeprom for reading MAC Address error.\n");
-               goto err_out_free_shadow;
+               goto err_out_unmap;
        }
        jme_load_macaddr(netdev);
 
@@ -2945,25 +3124,38 @@ jme_init_one(struct pci_dev *pdev,
        rc = register_netdev(netdev);
        if (rc) {
                jeprintk(pdev, "Cannot register net device.\n");
-               goto err_out_free_shadow;
+               goto err_out_unmap;
        }
 
-       msg_probe(jme, "%s%s ver:%x rev:%x macaddr:%pM\n",
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,33)
+       msg_probe(jme, "%s%s ver:%x rev:%x "
+                       "macaddr: %02x:%02x:%02x:%02x:%02x:%02x\n",
                (jme->pdev->device == PCI_DEVICE_ID_JMICRON_JMC250) ?
                        "JMC250 Gigabit Ethernet" :
                        (jme->pdev->device == PCI_DEVICE_ID_JMICRON_JMC260) ?
                                "JMC260 Fast Ethernet" : "Unknown",
                (jme->fpgaver != 0) ? " (FPGA)" : "",
                (jme->fpgaver != 0) ? jme->fpgaver : jme->chiprev,
-               jme->rev, netdev->dev_addr);
+               jme->rev,
+               netdev->dev_addr[0],
+               netdev->dev_addr[1],
+               netdev->dev_addr[2],
+               netdev->dev_addr[3],
+               netdev->dev_addr[4],
+               netdev->dev_addr[5]);
+#else
+       netif_info(jme, probe, jme->dev, "%s%s ver:%x rev:%x macaddr:%pM\n",
+                  (jme->pdev->device == PCI_DEVICE_ID_JMICRON_JMC250) ?
+                  "JMC250 Gigabit Ethernet" :
+                  (jme->pdev->device == PCI_DEVICE_ID_JMICRON_JMC260) ?
+                  "JMC260 Fast Ethernet" : "Unknown",
+                  (jme->fpgaver != 0) ? " (FPGA)" : "",
+                  (jme->fpgaver != 0) ? jme->fpgaver : jme->chiprev,
+                  jme->rev, netdev->dev_addr);
+#endif
 
        return 0;
 
-err_out_free_shadow:
-       pci_free_consistent(pdev,
-                           sizeof(u32) * SHADOW_REG_NR,
-                           jme->shadow_regs,
-                           jme->shadow_dma);
 err_out_unmap:
        iounmap(jme->regs);
 err_out_free_netdev:
@@ -2984,10 +3176,6 @@ jme_remove_one(struct pci_dev *pdev)
        struct jme_adapter *jme = netdev_priv(netdev);
 
        unregister_netdev(netdev);
-       pci_free_consistent(pdev,
-                           sizeof(u32) * SHADOW_REG_NR,
-                           jme->shadow_regs,
-                           jme->shadow_dma);
        iounmap(jme->regs);
        pci_set_drvdata(pdev, NULL);
        free_netdev(netdev);
@@ -3013,8 +3201,6 @@ jme_suspend(struct pci_dev *pdev, pm_message_t state)
        tasklet_disable(&jme->rxclean_task);
        tasklet_disable(&jme->rxempty_task);
 
-       jme_disable_shadow(jme);
-
        if (netif_carrier_ok(netdev)) {
                if (test_bit(JME_FLAG_POLL, &jme->flags))
                        jme_polling_mode(jme);
@@ -3066,7 +3252,6 @@ jme_resume(struct pci_dev *pdev)
        else
                jme_reset_phy_processor(jme);
 
-       jme_enable_shadow(jme);
        jme_start_irq(jme);
        netif_device_attach(netdev);
 
@@ -3078,7 +3263,11 @@ jme_resume(struct pci_dev *pdev)
 }
 #endif
 
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,24)
 static struct pci_device_id jme_pci_tbl[] = {
+#else
+static DEFINE_PCI_DEVICE_TABLE(jme_pci_tbl) = {
+#endif
        { PCI_VDEVICE(JMICRON, PCI_DEVICE_ID_JMICRON_JMC250) },
        { PCI_VDEVICE(JMICRON, PCI_DEVICE_ID_JMICRON_JMC260) },
        { }