Import jme 1.0.4-backport source
authorGuo-Fu Tseng <cooldavid@cooldavid.org>
Tue, 3 Aug 2010 09:19:37 +0000 (17:19 +0800)
committerGuo-Fu Tseng <cooldavid@cooldavid.org>
Tue, 3 Aug 2010 09:19:37 +0000 (17:19 +0800)
Makefile
jme.c
jme.h

index 8116d04..7aa314f 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -28,6 +28,9 @@ namespacecheck:
        perl $(KSRC)/scripts/namespace.pl
        @rm -rf $(TEMPFILES)
 
+patch:
+       @/usr/bin/diff -uarN -X dontdiff ../mod ./ > bc.patch || echo > /dev/null
+
 clean:
        @rm -rf $(MODNAME).ko $(TEMPFILES)
 
diff --git a/jme.c b/jme.c
index 5f9a131..83eb75a 100644 (file)
--- a/jme.c
+++ b/jme.c
@@ -21,7 +21,6 @@
  *
  */
 
-#include <linux/version.h>
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/pci.h>
@@ -38,6 +37,7 @@
 #include <linux/tcp.h>
 #include <linux/udp.h>
 #include <linux/if_vlan.h>
+#include <net/ip6_checksum.h>
 #include "jme.h"
 
 static int force_pseudohp = -1;
@@ -429,21 +429,23 @@ jme_check_link(struct net_device *netdev, int testonly)
 
                jme->phylink = phylink;
 
-               ghc = jme->reg_ghc & ~(GHC_SPEED_10M |
-                                       GHC_SPEED_100M |
-                                       GHC_SPEED_1000M |
-                                       GHC_DPX);
+               ghc = jme->reg_ghc & ~(GHC_SPEED | GHC_DPX |
+                               GHC_TO_CLK_PCIE | GHC_TXMAC_CLK_PCIE |
+                               GHC_TO_CLK_GPHY | GHC_TXMAC_CLK_GPHY);
                switch (phylink & PHY_LINK_SPEED_MASK) {
                case PHY_LINK_SPEED_10M:
-                       ghc |= GHC_SPEED_10M;
+                       ghc |= GHC_SPEED_10M |
+                               GHC_TO_CLK_PCIE | GHC_TXMAC_CLK_PCIE;
                        strcat(linkmsg, "10 Mbps, ");
                        break;
                case PHY_LINK_SPEED_100M:
-                       ghc |= GHC_SPEED_100M;
+                       ghc |= GHC_SPEED_100M |
+                               GHC_TO_CLK_PCIE | GHC_TXMAC_CLK_PCIE;
                        strcat(linkmsg, "100 Mbps, ");
                        break;
                case PHY_LINK_SPEED_1000M:
-                       ghc |= GHC_SPEED_1000M;
+                       ghc |= GHC_SPEED_1000M |
+                               GHC_TO_CLK_GPHY | GHC_TXMAC_CLK_GPHY;
                        strcat(linkmsg, "1000 Mbps, ");
                        break;
                default:
@@ -463,14 +465,6 @@ jme_check_link(struct net_device *netdev, int testonly)
                                TXTRHD_TXREN |
                                ((8 << TXTRHD_TXRL_SHIFT) & TXTRHD_TXRL));
                }
-               strcat(linkmsg, (phylink & PHY_LINK_DUPLEX) ?
-                                       "Full-Duplex, " :
-                                       "Half-Duplex, ");
-
-               if (phylink & PHY_LINK_MDI_STAT)
-                       strcat(linkmsg, "MDI-X");
-               else
-                       strcat(linkmsg, "MDI");
 
                gpreg1 = GPREG1_DEFAULT;
                if (is_buggy250(jme->pdev->device, jme->chiprev)) {
@@ -492,11 +486,17 @@ jme_check_link(struct net_device *netdev, int testonly)
                                break;
                        }
                }
-               jwrite32(jme, JME_GPREG1, gpreg1);
 
-               jme->reg_ghc = ghc;
+               jwrite32(jme, JME_GPREG1, gpreg1);
                jwrite32(jme, JME_GHC, ghc);
+               jme->reg_ghc = ghc;
 
+               strcat(linkmsg, (phylink & PHY_LINK_DUPLEX) ?
+                                       "Full-Duplex, " :
+                                       "Half-Duplex, ");
+               strcat(linkmsg, (phylink & PHY_LINK_MDI_STAT) ?
+                                       "MDI-X" :
+                                       "MDI");
                msg_link(jme, "Link is up at %s.\n", linkmsg);
                netif_carrier_on(netdev);
        } else {
@@ -682,6 +682,9 @@ jme_make_new_rx_buf(struct jme_adapter *jme, int i)
                jme->dev->mtu + RX_EXTRA_LEN);
        if (unlikely(!skb))
                return -ENOMEM;
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)
+       skb->dev = jme->dev;
+#endif
 
        rxbi->skb = skb;
        rxbi->len = skb_tailroom(skb);
@@ -912,26 +915,25 @@ jme_alloc_and_feed_skb(struct jme_adapter *jme, int idx)
                skb_put(skb, framesize);
                skb->protocol = eth_type_trans(skb, jme->dev);
 
-               if (jme_rxsum_ok(jme, rxdesc->descwb.flags))
+               if (jme_rxsum_ok(jme, le16_to_cpu(rxdesc->descwb.flags)))
                        skb->ip_summed = CHECKSUM_UNNECESSARY;
                else
                        skb->ip_summed = CHECKSUM_NONE;
 
-               if (rxdesc->descwb.flags & RXWBFLAG_TAGON) {
+               if (rxdesc->descwb.flags & cpu_to_le16(RXWBFLAG_TAGON)) {
                        if (jme->vlgrp) {
                                jme->jme_vlan_rx(skb, jme->vlgrp,
-                                       le32_to_cpu(rxdesc->descwb.vlan));
+                                       le16_to_cpu(rxdesc->descwb.vlan));
                                NET_STAT(jme).rx_bytes += 4;
                        }
                } else {
                        jme->jme_rx(skb);
                }
 
-               if ((le16_to_cpu(rxdesc->descwb.flags) & RXWBFLAG_DEST) ==
-                               RXWBFLAG_DEST_MUL)
+               if ((rxdesc->descwb.flags & cpu_to_le16(RXWBFLAG_DEST)) ==
+                   cpu_to_le16(RXWBFLAG_DEST_MUL))
                        ++(NET_STAT(jme).multicast);
 
-               jme->dev->last_rx = jiffies;
                NET_STAT(jme).rx_bytes += framesize;
                ++(NET_STAT(jme).rx_packets);
        }
@@ -961,7 +963,7 @@ jme_process_receive(struct jme_adapter *jme, int limit)
                rxdesc = rxring->desc;
                rxdesc += i;
 
-               if ((rxdesc->descwb.flags & RXWBFLAG_OWN) ||
+               if ((rxdesc->descwb.flags & cpu_to_le16(RXWBFLAG_OWN)) ||
                !(rxdesc->descwb.desccnt & RXWBDCNT_WBCPL))
                        goto out;
 
@@ -1250,7 +1252,7 @@ static int
 jme_poll(JME_NAPI_HOLDER(holder), JME_NAPI_WEIGHT(budget))
 {
        struct jme_adapter *jme = jme_napi_priv(holder);
-       struct net_device *netdev = jme->dev;
+       DECLARE_NETDEV
        int rest;
 
        rest = jme_process_receive(jme, JME_NAPI_WEIGHT_VAL(budget));
@@ -1451,8 +1453,13 @@ out_reenable:
        jwrite32f(jme, JME_IENS, INTR_ENABLE);
 }
 
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,18)
+static irqreturn_t
+jme_intr(int irq, void *dev_id, struct pt_regs *regs)
+#else
 static irqreturn_t
 jme_intr(int irq, void *dev_id)
+#endif
 {
        struct net_device *netdev = dev_id;
        struct jme_adapter *jme = netdev_priv(netdev);
@@ -1477,8 +1484,13 @@ jme_intr(int irq, void *dev_id)
        return IRQ_HANDLED;
 }
 
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,18)
+static irqreturn_t
+jme_msi(int irq, void *dev_id, struct pt_regs *regs)
+#else
 static irqreturn_t
 jme_msi(int irq, void *dev_id)
+#endif
 {
        struct net_device *netdev = dev_id;
        struct jme_adapter *jme = netdev_priv(netdev);
@@ -1519,8 +1531,13 @@ jme_request_irq(struct jme_adapter *jme)
 {
        int rc;
        struct net_device *netdev = jme->dev;
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,18)
+       irqreturn_t (*handler)(int, void *, struct pt_regs *) = jme_intr;
+       int irq_flags = SA_SHIRQ;
+#else
        irq_handler_t handler = jme_intr;
        int irq_flags = IRQF_SHARED;
+#endif
 
        if (!pci_enable_msi(jme->pdev)) {
                set_bit(JME_FLAG_MSI, &jme->flags);
@@ -1752,8 +1769,13 @@ jme_map_tx_skb(struct jme_adapter *jme, struct sk_buff *skb, int idx)
 static int
 jme_expand_header(struct jme_adapter *jme, struct sk_buff *skb)
 {
-       if (unlikely(skb_shinfo(skb)->gso_size &&
-                       skb_header_cloned(skb) &&
+       if (unlikely(
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,16)
+       skb_shinfo(skb)->tso_size
+#else
+       skb_shinfo(skb)->gso_size
+#endif
+                       && skb_header_cloned(skb) &&
                        pskb_expand_head(skb, 0, 0, GFP_ATOMIC))) {
                dev_kfree_skb(skb);
                return -1;
@@ -1763,10 +1785,13 @@ jme_expand_header(struct jme_adapter *jme, struct sk_buff *skb)
 }
 
 static int
-jme_tx_tso(struct sk_buff *skb,
-               u16 *mss, u8 *flags)
+jme_tx_tso(struct sk_buff *skb, __le16 *mss, u8 *flags)
 {
-       *mss = skb_shinfo(skb)->gso_size << TXDESC_MSS_SHIFT;
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,16)
+       *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);
+#endif
        if (*mss) {
                *flags |= TXFLAG_LSEN;
 
@@ -1796,9 +1821,22 @@ jme_tx_tso(struct sk_buff *skb,
 static void
 jme_tx_csum(struct jme_adapter *jme, struct sk_buff *skb, u8 *flags)
 {
-       if (skb->ip_summed == CHECKSUM_PARTIAL) {
+#ifdef CHECKSUM_PARTIAL
+       if (skb->ip_summed == CHECKSUM_PARTIAL)
+#else
+       if (skb->ip_summed == CHECKSUM_HW)
+#endif
+       {
                u8 ip_proto;
 
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,21)
+               if (skb->protocol == htons(ETH_P_IP))
+                       ip_proto = ip_hdr(skb)->protocol;
+               else if (skb->protocol == htons(ETH_P_IPV6))
+                       ip_proto = ipv6_hdr(skb)->nexthdr;
+               else
+                       ip_proto = 0;
+#else
                switch (skb->protocol) {
                case htons(ETH_P_IP):
                        ip_proto = ip_hdr(skb)->protocol;
@@ -1810,6 +1848,7 @@ jme_tx_csum(struct jme_adapter *jme, struct sk_buff *skb, u8 *flags)
                        ip_proto = 0;
                        break;
                }
+#endif
 
                switch (ip_proto) {
                case IPPROTO_TCP:
@@ -1826,16 +1865,16 @@ jme_tx_csum(struct jme_adapter *jme, struct sk_buff *skb, u8 *flags)
 }
 
 static inline void
-jme_tx_vlan(struct sk_buff *skb, u16 *vlan, u8 *flags)
+jme_tx_vlan(struct sk_buff *skb, __le16 *vlan, u8 *flags)
 {
        if (vlan_tx_tag_present(skb)) {
                *flags |= TXFLAG_TAGON;
-               *vlan = vlan_tx_tag_get(skb);
+               *vlan = cpu_to_le16(vlan_tx_tag_get(skb));
        }
 }
 
 static int
-jme_fill_first_tx_desc(struct jme_adapter *jme, struct sk_buff *skb, int idx)
+jme_fill_tx_desc(struct jme_adapter *jme, struct sk_buff *skb, int idx)
 {
        struct jme_ring *txring = jme->txring;
        struct txdesc *txdesc;
@@ -1865,6 +1904,7 @@ jme_fill_first_tx_desc(struct jme_adapter *jme, struct sk_buff *skb, int idx)
        if (jme_tx_tso(skb, &txdesc->desc1.mss, &flags))
                jme_tx_csum(jme, skb, &flags);
        jme_tx_vlan(skb, &txdesc->desc1.vlan, &flags);
+       jme_map_tx_skb(jme, skb, idx);
        txdesc->desc1.flags = flags;
        /*
         * Set tx buffer info after telling NIC to send
@@ -1934,8 +1974,7 @@ jme_start_xmit(struct sk_buff *skb, struct net_device *netdev)
                return NETDEV_TX_BUSY;
        }
 
-       jme_map_tx_skb(jme, skb, idx);
-       jme_fill_first_tx_desc(jme, skb, idx);
+       jme_fill_tx_desc(jme, skb, idx);
 
        jwrite32(jme, JME_TXCS, jme->reg_txcs |
                                TXCS_SELECT_QUEUE0 |
@@ -2039,13 +2078,20 @@ jme_change_mtu(struct net_device *netdev, int new_mtu)
 
        if (new_mtu > 1900) {
                netdev->features &= ~(NETIF_F_HW_CSUM |
-                               NETIF_F_TSO |
-                               NETIF_F_TSO6);
+                               NETIF_F_TSO
+#ifdef NETIF_F_TSO6
+                               | NETIF_F_TSO6
+#endif
+                               );
        } else {
                if (test_bit(JME_FLAG_TXCSUM, &jme->flags))
                        netdev->features |= NETIF_F_HW_CSUM;
                if (test_bit(JME_FLAG_TSO, &jme->flags))
-                       netdev->features |= NETIF_F_TSO | NETIF_F_TSO6;
+                       netdev->features |= NETIF_F_TSO
+#ifdef NETIF_F_TSO6
+                               | NETIF_F_TSO6
+#endif
+                               ;
        }
 
        netdev->mtu = new_mtu;
@@ -2428,10 +2474,18 @@ jme_set_tso(struct net_device *netdev, u32 on)
        if (on) {
                set_bit(JME_FLAG_TSO, &jme->flags);
                if (netdev->mtu <= 1900)
-                       netdev->features |= NETIF_F_TSO | NETIF_F_TSO6;
+                       netdev->features |= NETIF_F_TSO
+#ifdef NETIF_F_TSO6
+                               | NETIF_F_TSO6
+#endif
+                               ;
        } else {
                clear_bit(JME_FLAG_TSO, &jme->flags);
-               netdev->features &= ~(NETIF_F_TSO | NETIF_F_TSO6);
+               netdev->features &= ~(NETIF_F_TSO
+#ifdef NETIF_F_TSO6
+                               | NETIF_F_TSO6
+#endif
+                               );
        }
 
        return 0;
@@ -2563,7 +2617,11 @@ jme_set_eeprom(struct net_device *netdev,
        return 0;
 }
 
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,18)
+static struct ethtool_ops jme_ethtool_ops = {
+#else
 static const struct ethtool_ops jme_ethtool_ops = {
+#endif
        .get_drvinfo            = jme_get_drvinfo,
        .get_regs_len           = jme_get_regs_len,
        .get_regs               = jme_get_regs,
@@ -2592,11 +2650,13 @@ static const struct ethtool_ops jme_ethtool_ops = {
 static int
 jme_pci_dma64(struct pci_dev *pdev)
 {
-       if (!pci_set_dma_mask(pdev, DMA_64BIT_MASK))
+       if (pdev->device == PCI_DEVICE_ID_JMICRON_JMC250 &&
+           !pci_set_dma_mask(pdev, DMA_64BIT_MASK))
                if (!pci_set_consistent_dma_mask(pdev, DMA_64BIT_MASK))
                        return 1;
 
-       if (!pci_set_dma_mask(pdev, DMA_40BIT_MASK))
+       if (pdev->device == PCI_DEVICE_ID_JMICRON_JMC250 &&
+           !pci_set_dma_mask(pdev, DMA_40BIT_MASK))
                if (!pci_set_consistent_dma_mask(pdev, DMA_40BIT_MASK))
                        return 1;
 
@@ -2627,6 +2687,20 @@ jme_check_hw_ver(struct jme_adapter *jme)
        jme->chiprev = (chipmode & CM_CHIPREV_MASK) >> CM_CHIPREV_SHIFT;
 }
 
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,29)
+static const struct net_device_ops jme_netdev_ops = {
+       .ndo_open               = jme_open,
+       .ndo_stop               = jme_close,
+       .ndo_validate_addr      = eth_validate_addr,
+       .ndo_start_xmit         = jme_start_xmit,
+       .ndo_set_mac_address    = jme_set_macaddr,
+       .ndo_set_multicast_list = jme_set_multi,
+       .ndo_change_mtu         = jme_change_mtu,
+       .ndo_tx_timeout         = jme_tx_timeout,
+       .ndo_vlan_rx_register   = jme_vlan_rx_register,
+};
+#endif
+
 static int __devinit
 jme_init_one(struct pci_dev *pdev,
             const struct pci_device_id *ent)
@@ -2676,21 +2750,27 @@ jme_init_one(struct pci_dev *pdev,
                rc = -ENOMEM;
                goto err_out_release_regions;
        }
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,29)
+       netdev->netdev_ops = &jme_netdev_ops;
+#else
        netdev->open                    = jme_open;
        netdev->stop                    = jme_close;
        netdev->hard_start_xmit         = jme_start_xmit;
        netdev->set_mac_address         = jme_set_macaddr;
        netdev->set_multicast_list      = jme_set_multi;
        netdev->change_mtu              = jme_change_mtu;
-       netdev->ethtool_ops             = &jme_ethtool_ops;
        netdev->tx_timeout              = jme_tx_timeout;
-       netdev->watchdog_timeo          = TX_TIMEOUT;
        netdev->vlan_rx_register        = jme_vlan_rx_register;
        NETDEV_GET_STATS(netdev, &jme_get_stats);
+#endif
+       netdev->ethtool_ops             = &jme_ethtool_ops;
+       netdev->watchdog_timeo          = TX_TIMEOUT;
        netdev->features                =       NETIF_F_HW_CSUM |
                                                NETIF_F_SG |
                                                NETIF_F_TSO |
+#ifdef NETIF_F_TSO6
                                                NETIF_F_TSO6 |
+#endif
                                                NETIF_F_HW_VLAN_TX |
                                                NETIF_F_HW_VLAN_RX;
        if (using_dac)
@@ -2709,10 +2789,16 @@ 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),
@@ -2862,18 +2948,14 @@ jme_init_one(struct pci_dev *pdev,
                goto err_out_free_shadow;
        }
 
-       msg_probe(jme,
-               "JMC250 gigabit%s ver:%x rev:%x "
-               "macaddr:%02x:%02x:%02x:%02x:%02x:%02x\n",
+       msg_probe(jme, "%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[0],
-               netdev->dev_addr[1],
-               netdev->dev_addr[2],
-               netdev->dev_addr[3],
-               netdev->dev_addr[4],
-               netdev->dev_addr[5]);
+               jme->rev, netdev->dev_addr);
 
        return 0;
 
@@ -3016,7 +3098,7 @@ static struct pci_driver jme_driver = {
 static int __init
 jme_init_module(void)
 {
-       printk(KERN_INFO PFX "JMicron JMC250 gigabit ethernet "
+       printk(KERN_INFO PFX "JMicron JMC2XX ethernet "
               "driver version %s\n", DRV_VERSION);
        return pci_register_driver(&jme_driver);
 }
diff --git a/jme.h b/jme.h
index 3d33ac9..7eb2d97 100644 (file)
--- a/jme.h
+++ b/jme.h
  */
 
 #ifndef __JME_H_INCLUDED__
-#define __JME_H_INCLUDEE__
+#define __JME_H_INCLUDED__
 
 #define DRV_NAME       "jme"
-#define DRV_VERSION    "1.0.3"
+#define DRV_VERSION    "1.0.4"
 #define PFX            DRV_NAME ": "
 
 #define PCI_DEVICE_ID_JMICRON_JMC250   0x0250
@@ -372,7 +372,13 @@ struct jme_buffer_info {
 /*
  * The structure holding buffer information and ring descriptors all together.
  */
+#include <linux/version.h>
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,21)
+#define MAX_RING_DESC_NR       512
+#else
 #define MAX_RING_DESC_NR       1024
+#endif
+
 struct jme_ring {
        void *alloc;            /* pointer to allocated memory */
        void *desc;             /* pointer to ring memory  */
@@ -387,11 +393,38 @@ struct jme_ring {
        atomic_t nr_free;
 };
 
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,18)
+#define false 0
+#define true 0
+#define netdev_alloc_skb(dev, len) dev_alloc_skb(len)
+#define PCI_VENDOR_ID_JMICRON           0x197B
+#endif
+
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,19)
+#define PCI_VDEVICE(vendor, device)             \
+        PCI_VENDOR_ID_##vendor, (device),       \
+        PCI_ANY_ID, PCI_ANY_ID, 0, 0
+#endif
+
 #if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,21)
 #define NET_STAT(priv) priv->stats
 #define NETDEV_GET_STATS(netdev, fun_ptr) \
        netdev->get_stats = fun_ptr
 #define DECLARE_NET_DEVICE_STATS struct net_device_stats stats;
+static inline struct iphdr *ip_hdr(const struct sk_buff *skb)
+{
+       return skb->nh.iph;
+}
+
+static inline struct ipv6hdr *ipv6_hdr(const struct sk_buff *skb)
+{
+       return skb->nh.ipv6h;
+}
+
+static inline struct tcphdr *tcp_hdr(const struct sk_buff *skb)
+{
+       return skb->h.th;
+}
 #else
 #define NET_STAT(priv) priv->dev->stats
 #define NETDEV_GET_STATS(netdev, fun_ptr)
@@ -407,6 +440,7 @@ struct jme_ring {
 #define JME_NAPI_WEIGHT(w) int *w
 #define JME_NAPI_WEIGHT_VAL(w) *w
 #define JME_NAPI_WEIGHT_SET(w, r) *w = r
+#define DECLARE_NETDEV struct net_device *netdev = jme->dev;
 #define JME_RX_COMPLETE(dev, napis) netif_rx_complete(dev)
 #define JME_NAPI_ENABLE(priv) netif_poll_enable(priv->dev);
 #define JME_NAPI_DISABLE(priv) netif_poll_disable(priv->dev);
@@ -414,6 +448,24 @@ struct jme_ring {
        netif_rx_schedule_prep(priv->dev)
 #define JME_RX_SCHEDULE(priv) \
        __netif_rx_schedule(priv->dev);
+#elif LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,28)
+#define DECLARE_NAPI_STRUCT struct napi_struct napi;
+#define NETIF_NAPI_SET(dev, napis, pollfn, q) \
+       netif_napi_add(dev, napis, pollfn, q);
+#define JME_NAPI_HOLDER(holder) struct napi_struct *holder
+#define JME_NAPI_WEIGHT(w) int w
+#define JME_NAPI_WEIGHT_VAL(w) w
+#define JME_NAPI_WEIGHT_SET(w, r)
+#define DECLARE_NETDEV
+#define JME_RX_COMPLETE(dev, napis) napi_complete(napis)
+#define JME_NAPI_ENABLE(priv) napi_enable(&priv->napi);
+#define JME_NAPI_DISABLE(priv) \
+       if (!napi_disable_pending(&priv->napi)) \
+               napi_disable(&priv->napi);
+#define JME_RX_SCHEDULE_PREP(priv) \
+       napi_schedule_prep(&priv->napi)
+#define JME_RX_SCHEDULE(priv) \
+       __napi_schedule(&priv->napi);
 #else
 #define DECLARE_NAPI_STRUCT struct napi_struct napi;
 #define NETIF_NAPI_SET(dev, napis, pollfn, q) \
@@ -422,6 +474,7 @@ struct jme_ring {
 #define JME_NAPI_WEIGHT(w) int w
 #define JME_NAPI_WEIGHT_VAL(w) w
 #define JME_NAPI_WEIGHT_SET(w, r)
+#define DECLARE_NETDEV struct net_device *netdev = jme->dev;
 #define JME_RX_COMPLETE(dev, napis) netif_rx_complete(dev, napis)
 #define JME_NAPI_ENABLE(priv) napi_enable(&priv->napi);
 #define JME_NAPI_DISABLE(priv) \
@@ -489,6 +542,15 @@ struct jme_adapter {
        DECLARE_NET_DEVICE_STATS
 };
 
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,21)
+static struct net_device_stats *
+jme_get_stats(struct net_device *netdev)
+{
+       struct jme_adapter *jme = netdev_priv(netdev);
+       return &jme->stats;
+}
+#endif
+
 enum shadow_reg_val {
        SHADOW_IEVE = 0,
 };
@@ -850,16 +912,30 @@ static inline u32 smi_phy_addr(int x)
  * Global Host Control
  */
 enum jme_ghc_bit_mask {
-       GHC_SWRST       = 0x40000000,
-       GHC_DPX         = 0x00000040,
-       GHC_SPEED       = 0x00000030,
-       GHC_LINK_POLL   = 0x00000001,
+       GHC_SWRST               = 0x40000000,
+       GHC_DPX                 = 0x00000040,
+       GHC_SPEED               = 0x00000030,
+       GHC_LINK_POLL           = 0x00000001,
 };
 
 enum jme_ghc_speed_val {
-       GHC_SPEED_10M   = 0x00000010,
-       GHC_SPEED_100M  = 0x00000020,
-       GHC_SPEED_1000M = 0x00000030,
+       GHC_SPEED_10M           = 0x00000010,
+       GHC_SPEED_100M          = 0x00000020,
+       GHC_SPEED_1000M         = 0x00000030,
+};
+
+enum jme_ghc_to_clk {
+       GHC_TO_CLK_OFF          = 0x00000000,
+       GHC_TO_CLK_GPHY         = 0x00400000,
+       GHC_TO_CLK_PCIE         = 0x00800000,
+       GHC_TO_CLK_INVALID      = 0x00C00000,
+};
+
+enum jme_ghc_txmac_clk {
+       GHC_TXMAC_CLK_OFF       = 0x00000000,
+       GHC_TXMAC_CLK_GPHY      = 0x00100000,
+       GHC_TXMAC_CLK_PCIE      = 0x00200000,
+       GHC_TXMAC_CLK_INVALID   = 0x00300000,
 };
 
 /*