r8169: print errors when dma mapping fail
[linux-2.6.git] / drivers / net / ipg.c
index 6b64bc5..dc01980 100644 (file)
@@ -22,6 +22,7 @@
  */
 #include <linux/crc32.h>
 #include <linux/ethtool.h>
+#include <linux/gfp.h>
 #include <linux/mii.h>
 #include <linux/mutex.h>
 
         IPG_AC_DMA | IPG_AC_FIFO | IPG_AC_NETWORK | IPG_AC_HOST | \
         IPG_AC_AUTO_INIT)
 
-#define ipg_w32(val32,reg)     iowrite32((val32), ioaddr + (reg))
-#define ipg_w16(val16,reg)     iowrite16((val16), ioaddr + (reg))
-#define ipg_w8(val8,reg)       iowrite8((val8), ioaddr + (reg))
+#define ipg_w32(val32, reg)    iowrite32((val32), ioaddr + (reg))
+#define ipg_w16(val16, reg)    iowrite16((val16), ioaddr + (reg))
+#define ipg_w8(val8, reg)      iowrite8((val8), ioaddr + (reg))
 
 #define ipg_r32(reg)           ioread32(ioaddr + (reg))
 #define ipg_r16(reg)           ioread16(ioaddr + (reg))
 #define ipg_r8(reg)            ioread8(ioaddr + (reg))
 
-#define JUMBO_FRAME_4k_ONLY
 enum {
        netdev_io_size = 128
 };
@@ -54,20 +54,30 @@ MODULE_AUTHOR("IC Plus Corp. 2003");
 MODULE_DESCRIPTION("IC Plus IP1000 Gigabit Ethernet Adapter Linux Driver");
 MODULE_LICENSE("GPL");
 
-//variable record -- index by leading revision/length
-//Revision/Length(=N*4), Address1, Data1, Address2, Data2,...,AddressN,DataN
+/*
+ * Defaults
+ */
+#define IPG_MAX_RXFRAME_SIZE   0x0600
+#define IPG_RXFRAG_SIZE                0x0600
+#define IPG_RXSUPPORT_SIZE     0x0600
+#define IPG_IS_JUMBO           false
+
+/*
+ * Variable record -- index by leading revision/length
+ * Revision/Length(=N*4), Address1, Data1, Address2, Data2,...,AddressN,DataN
+ */
 static unsigned short DefaultPhyParam[] = {
-       // 11/12/03 IP1000A v1-3 rev=0x40
+       /* 11/12/03 IP1000A v1-3 rev=0x40 */
        /*--------------------------------------------------------------------------
        (0x4000|(15*4)), 31, 0x0001, 27, 0x01e0, 31, 0x0002, 22, 0x85bd, 24, 0xfff2,
                                 27, 0x0c10, 28, 0x0c10, 29, 0x2c10, 31, 0x0003, 23, 0x92f6,
                                 31, 0x0000, 23, 0x003d, 30, 0x00de, 20, 0x20e7,  9, 0x0700,
          --------------------------------------------------------------------------*/
-       // 12/17/03 IP1000A v1-4 rev=0x40
+       /* 12/17/03 IP1000A v1-4 rev=0x40 */
        (0x4000 | (07 * 4)), 31, 0x0001, 27, 0x01e0, 31, 0x0002, 27, 0xeb8e, 31,
            0x0000,
        30, 0x005e, 9, 0x0700,
-       // 01/09/04 IP1000A v1-5 rev=0x41
+       /* 01/09/04 IP1000A v1-5 rev=0x41 */
        (0x4100 | (07 * 4)), 31, 0x0001, 27, 0x01e0, 31, 0x0002, 27, 0xeb8e, 31,
            0x0000,
        30, 0x005e, 9, 0x0700,
@@ -79,17 +89,15 @@ static const char *ipg_brand_name[] = {
        "Sundance Technology ST2021 based NIC",
        "Tamarack Microelectronics TC9020/9021 based NIC",
        "Tamarack Microelectronics TC9020/9021 based NIC",
-       "D-Link NIC",
        "D-Link NIC IP1000A"
 };
 
-static struct pci_device_id ipg_pci_tbl[] __devinitdata = {
+static DEFINE_PCI_DEVICE_TABLE(ipg_pci_tbl) = {
        { PCI_VDEVICE(SUNDANCE, 0x1023), 0 },
        { PCI_VDEVICE(SUNDANCE, 0x2021), 1 },
        { PCI_VDEVICE(SUNDANCE, 0x1021), 2 },
        { PCI_VDEVICE(DLINK,    0x9021), 3 },
-       { PCI_VDEVICE(DLINK,    0x4000), 4 },
-       { PCI_VDEVICE(DLINK,    0x4020), 5 },
+       { PCI_VDEVICE(DLINK,    0x4020), 4 },
        { 0, }
 };
 
@@ -187,7 +195,7 @@ static void send_end(void __iomem *ioaddr, u8 phyctrlpolarity)
                phyctrlpolarity) & IPG_PC_RSVD_MASK, PHY_CTRL);
 }
 
-static u16 read_phy_bit(void __iomem * ioaddr, u8 phyctrlpolarity)
+static u16 read_phy_bit(void __iomem *ioaddr, u8 phyctrlpolarity)
 {
        u16 bit_data;
 
@@ -204,7 +212,7 @@ static u16 read_phy_bit(void __iomem * ioaddr, u8 phyctrlpolarity)
  * Read a register from the Physical Layer device located
  * on the IPG NIC, using the IPG PHYCTRL register.
  */
-static int mdio_read(struct net_device * dev, int phy_id, int phy_reg)
+static int mdio_read(struct net_device *dev, int phy_id, int phy_reg)
 {
        void __iomem *ioaddr = ipg_ioaddr(dev);
        /*
@@ -382,13 +390,13 @@ static void ipg_set_led_mode(struct net_device *dev)
        mode = ipg_r32(ASIC_CTRL);
        mode &= ~(IPG_AC_LED_MODE_BIT_1 | IPG_AC_LED_MODE | IPG_AC_LED_SPEED);
 
-       if ((sp->LED_Mode & 0x03) > 1)
+       if ((sp->led_mode & 0x03) > 1)
                mode |= IPG_AC_LED_MODE_BIT_1;  /* Write Asic Control Bit 29 */
 
-       if ((sp->LED_Mode & 0x01) == 1)
+       if ((sp->led_mode & 0x01) == 1)
                mode |= IPG_AC_LED_MODE;        /* Write Asic Control Bit 14 */
 
-       if ((sp->LED_Mode & 0x08) == 8)
+       if ((sp->led_mode & 0x08) == 8)
                mode |= IPG_AC_LED_SPEED;       /* Write Asic Control Bit 27 */
 
        ipg_w32(mode, ASIC_CTRL);
@@ -402,7 +410,7 @@ static void ipg_set_phy_set(struct net_device *dev)
 
        physet = ipg_r8(PHY_SET);
        physet &= ~(IPG_PS_MEM_LENB9B | IPG_PS_MEM_LEN9 | IPG_PS_NON_COMPDET);
-       physet |= ((sp->LED_Mode & 0x70) >> 4);
+       physet |= ((sp->led_mode & 0x70) >> 4);
        ipg_w8(physet, PHY_SET);
 }
 
@@ -470,7 +478,6 @@ static int ipg_config_autoneg(struct net_device *dev)
        unsigned int txflowcontrol;
        unsigned int rxflowcontrol;
        unsigned int fullduplex;
-       unsigned int gig;
        u32 mac_ctrl_val;
        u32 asicctrl;
        u8 phyctrl;
@@ -487,7 +494,6 @@ static int ipg_config_autoneg(struct net_device *dev)
        fullduplex = 0;
        txflowcontrol = 0;
        rxflowcontrol = 0;
-       gig = 0;
 
        /* To accomodate a problem in 10Mbps operation,
         * set a global flag if PHY running in 10Mbps mode.
@@ -509,7 +515,6 @@ static int ipg_config_autoneg(struct net_device *dev)
                break;
        case IPG_PC_LINK_SPEED_1000MBPS:
                printk("1000Mbps.\n");
-               gig = 1;
                break;
        default:
                printk("undefined!\n");
@@ -548,7 +553,7 @@ static int ipg_config_autoneg(struct net_device *dev)
                printk("\n");
        } else {
                /* Configure IPG for half duplex operation. */
-               printk(KERN_INFO "%s: setting half duplex, "
+               printk(KERN_INFO "%s: setting half duplex, "
                       "no TX flow control, no RX flow control.\n", dev->name);
 
                mac_ctrl_val &= ~IPG_MC_DUPLEX_SELECT_FD &
@@ -565,7 +570,7 @@ static int ipg_config_autoneg(struct net_device *dev)
 static void ipg_nic_set_multicast_list(struct net_device *dev)
 {
        void __iomem *ioaddr = ipg_ioaddr(dev);
-       struct dev_mc_list *mc_list_ptr;
+       struct netdev_hw_addr *ha;
        unsigned int hashindex;
        u32 hashtable[2];
        u8 receivemode;
@@ -578,12 +583,12 @@ static void ipg_nic_set_multicast_list(struct net_device *dev)
                /* NIC to be configured in promiscuous mode. */
                receivemode = IPG_RM_RECEIVEALLFRAMES;
        } else if ((dev->flags & IFF_ALLMULTI) ||
-                  (dev->flags & IFF_MULTICAST &
-                   (dev->mc_count > IPG_MULTICAST_HASHTABLE_SIZE))) {
+                  ((dev->flags & IFF_MULTICAST) &&
+                   (netdev_mc_count(dev) > IPG_MULTICAST_HASHTABLE_SIZE))) {
                /* NIC to be configured to receive all multicast
                 * frames. */
                receivemode |= IPG_RM_RECEIVEMULTICAST;
-       } else if (dev->flags & IFF_MULTICAST & (dev->mc_count > 0)) {
+       } else if ((dev->flags & IFF_MULTICAST) && !netdev_mc_empty(dev)) {
                /* NIC to be configured to receive selected
                 * multicast addresses. */
                receivemode |= IPG_RM_RECEIVEMULTICASTHASH;
@@ -604,10 +609,9 @@ static void ipg_nic_set_multicast_list(struct net_device *dev)
        hashtable[1] = 0x00000000;
 
        /* Cycle through all multicast addresses to filter. */
-       for (mc_list_ptr = dev->mc_list;
-            mc_list_ptr != NULL; mc_list_ptr = mc_list_ptr->next) {
+       netdev_for_each_mc_addr(ha, dev) {
                /* Calculate CRC result for each multicast address. */
-               hashindex = crc32_le(0xffffffff, mc_list_ptr->dmi_addr,
+               hashindex = crc32_le(0xffffffff, ha->addr,
                                     ETH_ALEN);
 
                /* Use only the least significant 6 bits. */
@@ -632,6 +636,7 @@ static void ipg_nic_set_multicast_list(struct net_device *dev)
 
 static int ipg_io_config(struct net_device *dev)
 {
+       struct ipg_nic_private *sp = netdev_priv(dev);
        void __iomem *ioaddr = ipg_ioaddr(dev);
        u32 origmacctrl;
        u32 restoremacctrl;
@@ -671,7 +676,7 @@ static int ipg_io_config(struct net_device *dev)
        /* Set RECEIVEMODE register. */
        ipg_nic_set_multicast_list(dev);
 
-       ipg_w16(IPG_MAX_RXFRAME_SIZE, MAX_FRAME_SIZE);
+       ipg_w16(sp->max_rxframe_size, MAX_FRAME_SIZE);
 
        ipg_w8(IPG_RXDMAPOLLPERIOD_VALUE,   RX_DMA_POLL_PERIOD);
        ipg_w8(IPG_RXDMAURGENTTHRESH_VALUE, RX_DMA_URGENT_THRESH);
@@ -731,28 +736,23 @@ static int ipg_get_rxbuff(struct net_device *dev, int entry)
 
        IPG_DEBUG_MSG("_get_rxbuff\n");
 
-       skb = netdev_alloc_skb(dev, IPG_RXSUPPORT_SIZE + NET_IP_ALIGN);
+       skb = netdev_alloc_skb_ip_align(dev, sp->rxsupport_size);
        if (!skb) {
-               sp->RxBuff[entry] = NULL;
+               sp->rx_buff[entry] = NULL;
                return -ENOMEM;
        }
 
-       /* Adjust the data start location within the buffer to
-        * align IP address field to a 16 byte boundary.
-        */
-       skb_reserve(skb, NET_IP_ALIGN);
-
        /* Associate the receive buffer with the IPG NIC. */
        skb->dev = dev;
 
        /* Save the address of the sk_buff structure. */
-       sp->RxBuff[entry] = skb;
+       sp->rx_buff[entry] = skb;
 
        rxfd->frag_info = cpu_to_le64(pci_map_single(sp->pdev, skb->data,
                sp->rx_buf_sz, PCI_DMA_FROMDEVICE));
 
        /* Set the RFD fragment length. */
-       rxfragsize = IPG_RXFRAG_SIZE;
+       rxfragsize = sp->rxfrag_size;
        rxfd->frag_info |= cpu_to_le64((rxfragsize << 48) & IPG_RFI_FRAGLEN);
 
        return 0;
@@ -769,12 +769,12 @@ static int init_rfdlist(struct net_device *dev)
        for (i = 0; i < IPG_RFDLIST_LENGTH; i++) {
                struct ipg_rx *rxfd = sp->rxd + i;
 
-               if (sp->RxBuff[i]) {
+               if (sp->rx_buff[i]) {
                        pci_unmap_single(sp->pdev,
                                le64_to_cpu(rxfd->frag_info) & ~IPG_RFI_FRAGLEN,
                                sp->rx_buf_sz, PCI_DMA_FROMDEVICE);
-                       dev_kfree_skb_irq(sp->RxBuff[i]);
-                       sp->RxBuff[i] = NULL;
+                       dev_kfree_skb_irq(sp->rx_buff[i]);
+                       sp->rx_buff[i] = NULL;
                }
 
                /* Clear out the RFS field. */
@@ -825,9 +825,9 @@ static void init_tfdlist(struct net_device *dev)
 
                txfd->tfc = cpu_to_le64(IPG_TFC_TFDDONE);
 
-               if (sp->TxBuff[i]) {
-                       dev_kfree_skb_irq(sp->TxBuff[i]);
-                       sp->TxBuff[i] = NULL;
+               if (sp->tx_buff[i]) {
+                       dev_kfree_skb_irq(sp->tx_buff[i]);
+                       sp->tx_buff[i] = NULL;
                }
 
                txfd->next_desc = cpu_to_le64(sp->txd_map +
@@ -844,7 +844,7 @@ static void init_tfdlist(struct net_device *dev)
        ipg_w32((u32) sp->txd_map, TFD_LIST_PTR_0);
        ipg_w32(0x00000000, TFD_LIST_PTR_1);
 
-       sp->ResetCurrentTFD = 1;
+       sp->reset_current_tfd = 1;
 }
 
 /*
@@ -862,7 +862,7 @@ static void ipg_nic_txfree(struct net_device *dev)
        dirty = sp->tx_dirty % IPG_TFDLIST_LENGTH;
 
        for (released = 0; released < pending; released++) {
-               struct sk_buff *skb = sp->TxBuff[dirty];
+               struct sk_buff *skb = sp->tx_buff[dirty];
                struct ipg_tx *txfd = sp->txd + dirty;
 
                IPG_DEBUG_MSG("TFC = %16.16lx\n", (unsigned long) txfd->tfc);
@@ -883,7 +883,7 @@ static void ipg_nic_txfree(struct net_device *dev)
 
                        dev_kfree_skb_irq(skb);
 
-                       sp->TxBuff[dirty] = NULL;
+                       sp->tx_buff[dirty] = NULL;
                }
                dirty = (dirty + 1) % IPG_TFDLIST_LENGTH;
        }
@@ -1056,7 +1056,7 @@ static int ipg_nic_rxrestore(struct net_device *dev)
                unsigned int entry = dirty % IPG_RFDLIST_LENGTH;
 
                /* rx_copybreak may poke hole here and there. */
-               if (sp->RxBuff[entry])
+               if (sp->rx_buff[entry])
                        continue;
 
                /* Generate a new receive buffer to replace the
@@ -1077,57 +1077,55 @@ static int ipg_nic_rxrestore(struct net_device *dev)
        return 0;
 }
 
-#ifdef JUMBO_FRAME
-
 /* use jumboindex and jumbosize to control jumbo frame status
-   initial status is jumboindex=-1 and jumbosize=0
-   1. jumboindex = -1 and jumbosize=0 : previous jumbo frame has been done.
-   2. jumboindex != -1 and jumbosize != 0 : jumbo frame is not over size and receiving
-   3. jumboindex = -1 and jumbosize != 0 : jumbo frame is over size, already dump
-                previous receiving and need to continue dumping the current one
-*/
+ * initial status is jumboindex=-1 and jumbosize=0
+ * 1. jumboindex = -1 and jumbosize=0 : previous jumbo frame has been done.
+ * 2. jumboindex != -1 and jumbosize != 0 : jumbo frame is not over size and receiving
+ * 3. jumboindex = -1 and jumbosize != 0 : jumbo frame is over size, already dump
+ *               previous receiving and need to continue dumping the current one
+ */
 enum {
-       NormalPacket,
-       ErrorPacket
+       NORMAL_PACKET,
+       ERROR_PACKET
 };
 
 enum {
-       Frame_NoStart_NoEnd     = 0,
-       Frame_WithStart         = 1,
-       Frame_WithEnd           = 10,
-       Frame_WithStart_WithEnd = 11
+       FRAME_NO_START_NO_END   = 0,
+       FRAME_WITH_START                = 1,
+       FRAME_WITH_END          = 10,
+       FRAME_WITH_START_WITH_END = 11
 };
 
-inline void ipg_nic_rx_free_skb(struct net_device *dev)
+static void ipg_nic_rx_free_skb(struct net_device *dev)
 {
        struct ipg_nic_private *sp = netdev_priv(dev);
        unsigned int entry = sp->rx_current % IPG_RFDLIST_LENGTH;
 
-       if (sp->RxBuff[entry]) {
+       if (sp->rx_buff[entry]) {
                struct ipg_rx *rxfd = sp->rxd + entry;
 
                pci_unmap_single(sp->pdev,
-                       le64_to_cpu(rxfd->frag_info & ~IPG_RFI_FRAGLEN),
+                       le64_to_cpu(rxfd->frag_info) & ~IPG_RFI_FRAGLEN,
                        sp->rx_buf_sz, PCI_DMA_FROMDEVICE);
-               dev_kfree_skb_irq(sp->RxBuff[entry]);
-               sp->RxBuff[entry] = NULL;
+               dev_kfree_skb_irq(sp->rx_buff[entry]);
+               sp->rx_buff[entry] = NULL;
        }
 }
 
-inline int ipg_nic_rx_check_frame_type(struct net_device *dev)
+static int ipg_nic_rx_check_frame_type(struct net_device *dev)
 {
        struct ipg_nic_private *sp = netdev_priv(dev);
        struct ipg_rx *rxfd = sp->rxd + (sp->rx_current % IPG_RFDLIST_LENGTH);
-       int type = Frame_NoStart_NoEnd;
+       int type = FRAME_NO_START_NO_END;
 
        if (le64_to_cpu(rxfd->rfs) & IPG_RFS_FRAMESTART)
-               type += Frame_WithStart;
+               type += FRAME_WITH_START;
        if (le64_to_cpu(rxfd->rfs) & IPG_RFS_FRAMEEND)
-               type += Frame_WithEnd;
+               type += FRAME_WITH_END;
        return type;
 }
 
-inline int ipg_nic_rx_check_error(struct net_device *dev)
+static int ipg_nic_rx_check_error(struct net_device *dev)
 {
        struct ipg_nic_private *sp = netdev_priv(dev);
        unsigned int entry = sp->rx_current % IPG_RFDLIST_LENGTH;
@@ -1172,135 +1170,128 @@ inline int ipg_nic_rx_check_error(struct net_device *dev)
                 * buffer since it is erroneous and we will
                 * not pass it to higher layer processes.
                 */
-               if (sp->RxBuff[entry]) {
+               if (sp->rx_buff[entry]) {
                        pci_unmap_single(sp->pdev,
-                               le64_to_cpu(rxfd->frag_info & ~IPG_RFI_FRAGLEN),
+                               le64_to_cpu(rxfd->frag_info) & ~IPG_RFI_FRAGLEN,
                                sp->rx_buf_sz, PCI_DMA_FROMDEVICE);
 
-                       dev_kfree_skb_irq(sp->RxBuff[entry]);
-                       sp->RxBuff[entry] = NULL;
+                       dev_kfree_skb_irq(sp->rx_buff[entry]);
+                       sp->rx_buff[entry] = NULL;
                }
-               return ErrorPacket;
+               return ERROR_PACKET;
        }
-       return NormalPacket;
+       return NORMAL_PACKET;
 }
 
 static void ipg_nic_rx_with_start_and_end(struct net_device *dev,
                                          struct ipg_nic_private *sp,
                                          struct ipg_rx *rxfd, unsigned entry)
 {
-       struct SJumbo *jumbo = &sp->Jumbo;
+       struct ipg_jumbo *jumbo = &sp->jumbo;
        struct sk_buff *skb;
        int framelen;
 
-       if (jumbo->FoundStart) {
+       if (jumbo->found_start) {
                dev_kfree_skb_irq(jumbo->skb);
-               jumbo->FoundStart = 0;
-               jumbo->CurrentSize = 0;
+               jumbo->found_start = 0;
+               jumbo->current_size = 0;
                jumbo->skb = NULL;
        }
 
-       // 1: found error, 0 no error
-       if (ipg_nic_rx_check_error(dev) != NormalPacket)
+       /* 1: found error, 0 no error */
+       if (ipg_nic_rx_check_error(dev) != NORMAL_PACKET)
                return;
 
-       skb = sp->RxBuff[entry];
+       skb = sp->rx_buff[entry];
        if (!skb)
                return;
 
-       // accept this frame and send to upper layer
+       /* accept this frame and send to upper layer */
        framelen = le64_to_cpu(rxfd->rfs) & IPG_RFS_RXFRAMELEN;
-       if (framelen > IPG_RXFRAG_SIZE)
-               framelen = IPG_RXFRAG_SIZE;
+       if (framelen > sp->rxfrag_size)
+               framelen = sp->rxfrag_size;
 
        skb_put(skb, framelen);
        skb->protocol = eth_type_trans(skb, dev);
-       skb->ip_summed = CHECKSUM_NONE;
+       skb_checksum_none_assert(skb);
        netif_rx(skb);
-       dev->last_rx = jiffies;
-       sp->RxBuff[entry] = NULL;
+       sp->rx_buff[entry] = NULL;
 }
 
 static void ipg_nic_rx_with_start(struct net_device *dev,
                                  struct ipg_nic_private *sp,
                                  struct ipg_rx *rxfd, unsigned entry)
 {
-       struct SJumbo *jumbo = &sp->Jumbo;
+       struct ipg_jumbo *jumbo = &sp->jumbo;
        struct pci_dev *pdev = sp->pdev;
        struct sk_buff *skb;
 
-       // 1: found error, 0 no error
-       if (ipg_nic_rx_check_error(dev) != NormalPacket)
+       /* 1: found error, 0 no error */
+       if (ipg_nic_rx_check_error(dev) != NORMAL_PACKET)
                return;
 
-       // accept this frame and send to upper layer
-       skb = sp->RxBuff[entry];
+       /* accept this frame and send to upper layer */
+       skb = sp->rx_buff[entry];
        if (!skb)
                return;
 
-       if (jumbo->FoundStart)
+       if (jumbo->found_start)
                dev_kfree_skb_irq(jumbo->skb);
 
-       pci_unmap_single(pdev, le64_to_cpu(rxfd->frag_info & ~IPG_RFI_FRAGLEN),
+       pci_unmap_single(pdev, le64_to_cpu(rxfd->frag_info) & ~IPG_RFI_FRAGLEN,
                         sp->rx_buf_sz, PCI_DMA_FROMDEVICE);
 
-       skb_put(skb, IPG_RXFRAG_SIZE);
+       skb_put(skb, sp->rxfrag_size);
 
-       jumbo->FoundStart = 1;
-       jumbo->CurrentSize = IPG_RXFRAG_SIZE;
+       jumbo->found_start = 1;
+       jumbo->current_size = sp->rxfrag_size;
        jumbo->skb = skb;
 
-       sp->RxBuff[entry] = NULL;
-       dev->last_rx = jiffies;
+       sp->rx_buff[entry] = NULL;
 }
 
 static void ipg_nic_rx_with_end(struct net_device *dev,
                                struct ipg_nic_private *sp,
                                struct ipg_rx *rxfd, unsigned entry)
 {
-       struct SJumbo *jumbo = &sp->Jumbo;
+       struct ipg_jumbo *jumbo = &sp->jumbo;
 
-       //1: found error, 0 no error
-       if (ipg_nic_rx_check_error(dev) == NormalPacket) {
-               struct sk_buff *skb = sp->RxBuff[entry];
+       /* 1: found error, 0 no error */
+       if (ipg_nic_rx_check_error(dev) == NORMAL_PACKET) {
+               struct sk_buff *skb = sp->rx_buff[entry];
 
                if (!skb)
                        return;
 
-               if (jumbo->FoundStart) {
+               if (jumbo->found_start) {
                        int framelen, endframelen;
 
                        framelen = le64_to_cpu(rxfd->rfs) & IPG_RFS_RXFRAMELEN;
 
-                       endframeLen = framelen - jumbo->CurrentSize;
-                       /*
-                       if (framelen > IPG_RXFRAG_SIZE)
-                               framelen=IPG_RXFRAG_SIZE;
-                        */
-                       if (framelen > IPG_RXSUPPORT_SIZE)
+                       endframelen = framelen - jumbo->current_size;
+                       if (framelen > sp->rxsupport_size)
                                dev_kfree_skb_irq(jumbo->skb);
                        else {
-                               memcpy(skb_put(jumbo->skb, endframeLen),
-                                      skb->data, endframeLen);
+                               memcpy(skb_put(jumbo->skb, endframelen),
+                                      skb->data, endframelen);
 
                                jumbo->skb->protocol =
                                    eth_type_trans(jumbo->skb, dev);
 
-                               jumbo->skb->ip_summed = CHECKSUM_NONE;
+                               skb_checksum_none_assert(jumbo->skb);
                                netif_rx(jumbo->skb);
                        }
                }
 
-               dev->last_rx = jiffies;
-               jumbo->FoundStart = 0;
-               jumbo->CurrentSize = 0;
+               jumbo->found_start = 0;
+               jumbo->current_size = 0;
                jumbo->skb = NULL;
 
                ipg_nic_rx_free_skb(dev);
        } else {
                dev_kfree_skb_irq(jumbo->skb);
-               jumbo->FoundStart = 0;
-               jumbo->CurrentSize = 0;
+               jumbo->found_start = 0;
+               jumbo->current_size = 0;
                jumbo->skb = NULL;
        }
 }
@@ -1309,33 +1300,32 @@ static void ipg_nic_rx_no_start_no_end(struct net_device *dev,
                                       struct ipg_nic_private *sp,
                                       struct ipg_rx *rxfd, unsigned entry)
 {
-       struct SJumbo *jumbo = &sp->Jumbo;
+       struct ipg_jumbo *jumbo = &sp->jumbo;
 
-       //1: found error, 0 no error
-       if (ipg_nic_rx_check_error(dev) == NormalPacket) {
-               struct sk_buff *skb = sp->RxBuff[entry];
+       /* 1: found error, 0 no error */
+       if (ipg_nic_rx_check_error(dev) == NORMAL_PACKET) {
+               struct sk_buff *skb = sp->rx_buff[entry];
 
                if (skb) {
-                       if (jumbo->FoundStart) {
-                               jumbo->CurrentSize += IPG_RXFRAG_SIZE;
-                               if (jumbo->CurrentSize <= IPG_RXSUPPORT_SIZE) {
+                       if (jumbo->found_start) {
+                               jumbo->current_size += sp->rxfrag_size;
+                               if (jumbo->current_size <= sp->rxsupport_size) {
                                        memcpy(skb_put(jumbo->skb,
-                                                      IPG_RXFRAG_SIZE),
-                                              skb->data, IPG_RXFRAG_SIZE);
+                                                      sp->rxfrag_size),
+                                              skb->data, sp->rxfrag_size);
                                }
                        }
-                       dev->last_rx = jiffies;
                        ipg_nic_rx_free_skb(dev);
                }
        } else {
                dev_kfree_skb_irq(jumbo->skb);
-               jumbo->FoundStart = 0;
-               jumbo->CurrentSize = 0;
+               jumbo->found_start = 0;
+               jumbo->current_size = 0;
                jumbo->skb = NULL;
        }
 }
 
-static int ipg_nic_rx(struct net_device *dev)
+static int ipg_nic_rx_jumbo(struct net_device *dev)
 {
        struct ipg_nic_private *sp = netdev_priv(dev);
        unsigned int curr = sp->rx_current;
@@ -1348,21 +1338,21 @@ static int ipg_nic_rx(struct net_device *dev)
                unsigned int entry = curr % IPG_RFDLIST_LENGTH;
                struct ipg_rx *rxfd = sp->rxd + entry;
 
-               if (!(rxfd->rfs & le64_to_cpu(IPG_RFS_RFDDONE)))
+               if (!(rxfd->rfs & cpu_to_le64(IPG_RFS_RFDDONE)))
                        break;
 
                switch (ipg_nic_rx_check_frame_type(dev)) {
-               case Frame_WithStart_WithEnd:
-                       ipg_nic_rx_with_start_and_end(dev, tp, rxfd, entry);
+               case FRAME_WITH_START_WITH_END:
+                       ipg_nic_rx_with_start_and_end(dev, sp, rxfd, entry);
                        break;
-               case Frame_WithStart:
-                       ipg_nic_rx_with_start(dev, tp, rxfd, entry);
+               case FRAME_WITH_START:
+                       ipg_nic_rx_with_start(dev, sp, rxfd, entry);
                        break;
-               case Frame_WithEnd:
-                       ipg_nic_rx_with_end(dev, tp, rxfd, entry);
+               case FRAME_WITH_END:
+                       ipg_nic_rx_with_end(dev, sp, rxfd, entry);
                        break;
-               case Frame_NoStart_NoEnd:
-                       ipg_nic_rx_no_start_no_end(dev, tp, rxfd, entry);
+               case FRAME_NO_START_NO_END:
+                       ipg_nic_rx_no_start_no_end(dev, sp, rxfd, entry);
                        break;
                }
        }
@@ -1383,7 +1373,6 @@ static int ipg_nic_rx(struct net_device *dev)
        return 0;
 }
 
-#else
 static int ipg_nic_rx(struct net_device *dev)
 {
        /* Transfer received Ethernet frames to higher network layers. */
@@ -1400,7 +1389,7 @@ static int ipg_nic_rx(struct net_device *dev)
 
        for (i = 0; i < IPG_MAXRFDPROCESS_COUNT; i++, curr++) {
                unsigned int entry = curr % IPG_RFDLIST_LENGTH;
-               struct sk_buff *skb = sp->RxBuff[entry];
+               struct sk_buff *skb = sp->rx_buff[entry];
                unsigned int framelen;
 
                rxfd = sp->rxd + entry;
@@ -1414,11 +1403,11 @@ static int ipg_nic_rx(struct net_device *dev)
                /* Check for jumbo frame arrival with too small
                 * RXFRAG_SIZE.
                 */
-               if (framelen > IPG_RXFRAG_SIZE) {
+               if (framelen > sp->rxfrag_size) {
                        IPG_DEBUG_MSG
                            ("RFS FrameLen > allocated fragment size.\n");
 
-                       framelen = IPG_RXFRAG_SIZE;
+                       framelen = sp->rxfrag_size;
                }
 
                if ((IPG_DROP_ON_RX_ETH_ERRORS && (le64_to_cpu(rxfd->rfs) &
@@ -1487,22 +1476,17 @@ static int ipg_nic_rx(struct net_device *dev)
                         * IP/TCP/UDP frame was received. Let the
                         * upper layer decide.
                         */
-                       skb->ip_summed = CHECKSUM_NONE;
+                       skb_checksum_none_assert(skb);
 
                        /* Hand off frame for higher layer processing.
                         * The function netif_rx() releases the sk_buff
                         * when processing completes.
                         */
                        netif_rx(skb);
-
-                       /* Record frame receive time (jiffies = Linux
-                        * kernel current time stamp).
-                        */
-                       dev->last_rx = jiffies;
                }
 
                /* Assure RX buffer is not reused by IPG. */
-               sp->RxBuff[entry] = NULL;
+               sp->rx_buff[entry] = NULL;
        }
 
        /*
@@ -1536,15 +1520,15 @@ static int ipg_nic_rx(struct net_device *dev)
                 * buffer since it is erroneous and we will
                 * not pass it to higher layer processes.
                 */
-               if (sp->RxBuff[entry]) {
+               if (sp->rx_buff[entry]) {
                        pci_unmap_single(sp->pdev,
                                le64_to_cpu(rxfd->frag_info) & ~IPG_RFI_FRAGLEN,
                                sp->rx_buf_sz, PCI_DMA_FROMDEVICE);
-                       dev_kfree_skb_irq(sp->RxBuff[entry]);
+                       dev_kfree_skb_irq(sp->rx_buff[entry]);
                }
 
                /* Assure RX buffer is not reused by IPG. */
-               sp->RxBuff[entry] = NULL;
+               sp->rx_buff[entry] = NULL;
        }
 
        sp->rx_current = curr;
@@ -1557,7 +1541,6 @@ static int ipg_nic_rx(struct net_device *dev)
 
        return 0;
 }
-#endif
 
 static void ipg_reset_after_host_error(struct work_struct *work)
 {
@@ -1565,8 +1548,6 @@ static void ipg_reset_after_host_error(struct work_struct *work)
                container_of(work, struct ipg_nic_private, task.work);
        struct net_device *dev = sp->dev;
 
-       IPG_DDEBUG_MSG("DMACtrl = %8.8x\n", ioread32(sp->ioaddr + IPG_DMACTRL));
-
        /*
         * Acknowledge HostError interrupt by resetting
         * IPG DMA and HOST.
@@ -1593,9 +1574,9 @@ static irqreturn_t ipg_interrupt_handler(int irq, void *dev_inst)
 
        IPG_DEBUG_MSG("_interrupt_handler\n");
 
-#ifdef JUMBO_FRAME
-       ipg_nic_rxrestore(dev);
-#endif
+       if (sp->is_jumbo)
+               ipg_nic_rxrestore(dev);
+
        spin_lock(&sp->lock);
 
        /* Get interrupt source information, and acknowledge
@@ -1651,7 +1632,10 @@ static irqreturn_t ipg_interrupt_handler(int irq, void *dev_inst)
                        sp->RFDListCheckedCount++;
 #endif
 
-               ipg_nic_rx(dev);
+               if (sp->is_jumbo)
+                       ipg_nic_rx_jumbo(dev);
+               else
+                       ipg_nic_rx(dev);
        }
 
        /* If TxDMAComplete interrupt, free used TFDs. */
@@ -1710,11 +1694,11 @@ static void ipg_rx_clear(struct ipg_nic_private *sp)
        unsigned int i;
 
        for (i = 0; i < IPG_RFDLIST_LENGTH; i++) {
-               if (sp->RxBuff[i]) {
+               if (sp->rx_buff[i]) {
                        struct ipg_rx *rxfd = sp->rxd + i;
 
-                       dev_kfree_skb_irq(sp->RxBuff[i]);
-                       sp->RxBuff[i] = NULL;
+                       dev_kfree_skb_irq(sp->rx_buff[i]);
+                       sp->rx_buff[i] = NULL;
                        pci_unmap_single(sp->pdev,
                                le64_to_cpu(rxfd->frag_info) & ~IPG_RFI_FRAGLEN,
                                sp->rx_buf_sz, PCI_DMA_FROMDEVICE);
@@ -1727,16 +1711,16 @@ static void ipg_tx_clear(struct ipg_nic_private *sp)
        unsigned int i;
 
        for (i = 0; i < IPG_TFDLIST_LENGTH; i++) {
-               if (sp->TxBuff[i]) {
+               if (sp->tx_buff[i]) {
                        struct ipg_tx *txfd = sp->txd + i;
 
                        pci_unmap_single(sp->pdev,
                                le64_to_cpu(txfd->frag_info) & ~IPG_TFI_FRAGLEN,
-                               sp->TxBuff[i]->len, PCI_DMA_TODEVICE);
+                               sp->tx_buff[i]->len, PCI_DMA_TODEVICE);
 
-                       dev_kfree_skb_irq(sp->TxBuff[i]);
+                       dev_kfree_skb_irq(sp->tx_buff[i]);
 
-                       sp->TxBuff[i] = NULL;
+                       sp->tx_buff[i] = NULL;
                }
        }
 }
@@ -1750,7 +1734,7 @@ static int ipg_nic_open(struct net_device *dev)
 
        IPG_DEBUG_MSG("_nic_open\n");
 
-       sp->rx_buf_sz = IPG_RXSUPPORT_SIZE;
+       sp->rx_buf_sz = sp->rxsupport_size;
 
        /* Check for interrupt line conflicts, and request interrupt
         * line for IPG.
@@ -1763,7 +1747,7 @@ static int ipg_nic_open(struct net_device *dev)
        /* Register the interrupt line to be used by the IPG within
         * the Linux system.
         */
-       rc = request_irq(pdev->irq, &ipg_interrupt_handler, IRQF_SHARED,
+       rc = request_irq(pdev->irq, ipg_interrupt_handler, IRQF_SHARED,
                         dev->name, dev);
        if (rc < 0) {
                printk(KERN_INFO "%s: Error when requesting interrupt.\n",
@@ -1805,13 +1789,10 @@ static int ipg_nic_open(struct net_device *dev)
        if (ipg_config_autoneg(dev) < 0)
                printk(KERN_INFO "%s: Auto-negotiation error.\n", dev->name);
 
-#ifdef JUMBO_FRAME
        /* initialize JUMBO Frame control variable */
-       sp->Jumbo.FoundStart = 0;
-       sp->Jumbo.CurrentSize = 0;
-       sp->Jumbo.skb = 0;
-       dev->mtu = IPG_TXFRAG_SIZE;
-#endif
+       sp->jumbo.found_start = 0;
+       sp->jumbo.current_size = 0;
+       sp->jumbo.skb = NULL;
 
        /* Enable transmit and receive operation of the IPG. */
        ipg_w32((ipg_r32(MAC_CTRL) | IPG_MC_RX_ENABLE | IPG_MC_TX_ENABLE) &
@@ -1843,9 +1824,6 @@ static int ipg_nic_stop(struct net_device *dev)
 
        netif_stop_queue(dev);
 
-       IPG_DDEBUG_MSG("RFDlistendCount = %i\n", sp->RFDlistendCount);
-       IPG_DDEBUG_MSG("RFDListCheckedCount = %i\n", sp->rxdCheckedCount);
-       IPG_DDEBUG_MSG("EmptyRFDListCount = %i\n", sp->EmptyRFDListCount);
        IPG_DUMPTFDLIST(dev);
 
        do {
@@ -1868,7 +1846,8 @@ static int ipg_nic_stop(struct net_device *dev)
        return 0;
 }
 
-static int ipg_nic_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
+static netdev_tx_t ipg_nic_hard_start_xmit(struct sk_buff *skb,
+                                          struct net_device *dev)
 {
        struct ipg_nic_private *sp = netdev_priv(dev);
        void __iomem *ioaddr = sp->ioaddr;
@@ -1884,22 +1863,27 @@ static int ipg_nic_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
        if (sp->tenmbpsmode)
                netif_stop_queue(dev);
 
-       if (sp->ResetCurrentTFD) {
-               sp->ResetCurrentTFD = 0;
+       if (sp->reset_current_tfd) {
+               sp->reset_current_tfd = 0;
                entry = 0;
        }
 
        txfd = sp->txd + entry;
 
-       sp->TxBuff[entry] = skb;
+       sp->tx_buff[entry] = skb;
 
        /* Clear all TFC fields, except TFDDONE. */
        txfd->tfc = cpu_to_le64(IPG_TFC_TFDDONE);
 
        /* Specify the TFC field within the TFD. */
        txfd->tfc |= cpu_to_le64(IPG_TFC_WORDALIGNDISABLED |
-               (IPG_TFC_FRAMEID & cpu_to_le64(sp->tx_current)) |
+               (IPG_TFC_FRAMEID & sp->tx_current) |
                (IPG_TFC_FRAGCOUNT & (1 << 24)));
+       /*
+        * 16--17 (WordAlign) <- 3 (disable),
+        * 0--15 (FrameId) <- sp->tx_current,
+        * 24--27 (FragCount) <- 1
+        */
 
        /* Request TxComplete interrupts at an interval defined
         * by the constant IPG_FRAMESBETWEENTXCOMPLETES.
@@ -2072,7 +2056,7 @@ static int ipg_hw_init(struct net_device *dev)
 
        /* Read/Write and Reset EEPROM Value */
        /* Read LED Mode Configuration from EEPROM */
-       sp->LED_Mode = read_eeprom(dev, 6);
+       sp->led_mode = read_eeprom(dev, 6);
 
        /* Reset all functions within the IPG. Do not assert
         * RST_OUT as not compatible with some PHYs.
@@ -2115,6 +2099,9 @@ static int ipg_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
 
 static int ipg_nic_change_mtu(struct net_device *dev, int new_mtu)
 {
+       struct ipg_nic_private *sp = netdev_priv(dev);
+       int err;
+
        /* Function to accomodate changes to Maximum Transfer Unit
         * (or MTU) of IPG NIC. Cannot use default function since
         * the default will not allow for MTU > 1500 bytes.
@@ -2122,16 +2109,33 @@ static int ipg_nic_change_mtu(struct net_device *dev, int new_mtu)
 
        IPG_DEBUG_MSG("_nic_change_mtu\n");
 
-       /* Check that the new MTU value is between 68 (14 byte header, 46
-        * byte payload, 4 byte FCS) and IPG_MAX_RXFRAME_SIZE, which
-        * corresponds to the MAXFRAMESIZE register in the IPG.
+       /*
+        * Check that the new MTU value is between 68 (14 byte header, 46 byte
+        * payload, 4 byte FCS) and 10 KB, which is the largest supported MTU.
         */
-       if ((new_mtu < 68) || (new_mtu > IPG_MAX_RXFRAME_SIZE))
+       if (new_mtu < 68 || new_mtu > 10240)
                return -EINVAL;
 
+       err = ipg_nic_stop(dev);
+       if (err)
+               return err;
+
        dev->mtu = new_mtu;
 
-       return 0;
+       sp->max_rxframe_size = new_mtu;
+
+       sp->rxfrag_size = new_mtu;
+       if (sp->rxfrag_size > 4088)
+               sp->rxfrag_size = 4088;
+
+       sp->rxsupport_size = sp->max_rxframe_size;
+
+       if (new_mtu > 0x0600)
+               sp->is_jumbo = true;
+       else
+               sp->is_jumbo = false;
+
+       return ipg_nic_open(dev);
 }
 
 static int ipg_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
@@ -2170,13 +2174,13 @@ static int ipg_nway_reset(struct net_device *dev)
        return rc;
 }
 
-static struct ethtool_ops ipg_ethtool_ops = {
+static const struct ethtool_ops ipg_ethtool_ops = {
        .get_settings = ipg_get_settings,
        .set_settings = ipg_set_settings,
        .nway_reset   = ipg_nway_reset,
 };
 
-static void ipg_remove(struct pci_dev *pdev)
+static void __devexit ipg_remove(struct pci_dev *pdev)
 {
        struct net_device *dev = pci_get_drvdata(pdev);
        struct ipg_nic_private *sp = netdev_priv(dev);
@@ -2195,6 +2199,19 @@ static void ipg_remove(struct pci_dev *pdev)
        pci_set_drvdata(pdev, NULL);
 }
 
+static const struct net_device_ops ipg_netdev_ops = {
+       .ndo_open               = ipg_nic_open,
+       .ndo_stop               = ipg_nic_stop,
+       .ndo_start_xmit         = ipg_nic_hard_start_xmit,
+       .ndo_get_stats          = ipg_nic_get_stats,
+       .ndo_set_multicast_list = ipg_nic_set_multicast_list,
+       .ndo_do_ioctl           = ipg_ioctl,
+       .ndo_tx_timeout         = ipg_tx_timeout,
+       .ndo_change_mtu         = ipg_nic_change_mtu,
+       .ndo_set_mac_address    = eth_mac_addr,
+       .ndo_validate_addr      = eth_validate_addr,
+};
+
 static int __devinit ipg_probe(struct pci_dev *pdev,
                               const struct pci_device_id *id)
 {
@@ -2212,9 +2229,9 @@ static int __devinit ipg_probe(struct pci_dev *pdev,
 
        pci_set_master(pdev);
 
-       rc = pci_set_dma_mask(pdev, DMA_40BIT_MASK);
+       rc = pci_set_dma_mask(pdev, DMA_BIT_MASK(40));
        if (rc < 0) {
-               rc = pci_set_dma_mask(pdev, DMA_32BIT_MASK);
+               rc = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));
                if (rc < 0) {
                        printk(KERN_ERR "%s: DMA config failed.\n",
                               pci_name(pdev));
@@ -2236,17 +2253,14 @@ static int __devinit ipg_probe(struct pci_dev *pdev,
        spin_lock_init(&sp->lock);
        mutex_init(&sp->mii_mutex);
 
+       sp->is_jumbo = IPG_IS_JUMBO;
+       sp->rxfrag_size = IPG_RXFRAG_SIZE;
+       sp->rxsupport_size = IPG_RXSUPPORT_SIZE;
+       sp->max_rxframe_size = IPG_MAX_RXFRAME_SIZE;
+
        /* Declare IPG NIC functions for Ethernet device methods.
         */
-       dev->open = &ipg_nic_open;
-       dev->stop = &ipg_nic_stop;
-       dev->hard_start_xmit = &ipg_nic_hard_start_xmit;
-       dev->get_stats = &ipg_nic_get_stats;
-       dev->set_multicast_list = &ipg_nic_set_multicast_list;
-       dev->do_ioctl = ipg_ioctl;
-       dev->tx_timeout = ipg_tx_timeout;
-       dev->change_mtu = &ipg_nic_change_mtu;
-
+       dev->netdev_ops = &ipg_netdev_ops;
        SET_NETDEV_DEV(dev, &pdev->dev);
        SET_ETHTOOL_OPS(dev, &ipg_ethtool_ops);