]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
igbvf: upgrade to 2.0.4
authorJoe Jin <joe.jin@oracle.com>
Tue, 28 Aug 2012 05:52:43 +0000 (13:52 +0800)
committerJoe Jin <joe.jin@oracle.com>
Tue, 28 Aug 2012 07:20:55 +0000 (15:20 +0800)
Signed-off-by: Joe Jin <joe.jin@oracle.com>
19 files changed:
drivers/net/igbvf/Makefile
drivers/net/igbvf/defines.h [deleted file]
drivers/net/igbvf/e1000_defines.h [new file with mode: 0644]
drivers/net/igbvf/e1000_mbx.c [moved from drivers/net/igbvf/mbx.c with 72% similarity]
drivers/net/igbvf/e1000_mbx.h [new file with mode: 0644]
drivers/net/igbvf/e1000_osdep.h [new file with mode: 0644]
drivers/net/igbvf/e1000_regs.h [new file with mode: 0644]
drivers/net/igbvf/e1000_vf.c [moved from drivers/net/igbvf/vf.c with 68% similarity]
drivers/net/igbvf/e1000_vf.h [new file with mode: 0644]
drivers/net/igbvf/ethtool.c
drivers/net/igbvf/igbvf.h
drivers/net/igbvf/kcompat.c [new file with mode: 0644]
drivers/net/igbvf/kcompat.h [new file with mode: 0644]
drivers/net/igbvf/kcompat_ethtool.c [new file with mode: 0644]
drivers/net/igbvf/mbx.h [deleted file]
drivers/net/igbvf/netdev.c
drivers/net/igbvf/param.c [new file with mode: 0644]
drivers/net/igbvf/regs.h [deleted file]
drivers/net/igbvf/vf.h [deleted file]

index 044b0ad5fcb948298861bdafb905b9797a7f1f3f..80aba05dc1863acc8f76f1fb4cb20ad175dcd47a 100644 (file)
@@ -1,7 +1,7 @@
 ################################################################################
 #
 # Intel(R) 82576 Virtual Function Linux driver
-# Copyright(c) 2009 - 2012 Intel Corporation.
+# Copyright(c) 1999 - 2012 Intel Corporation.
 #
 # This program is free software; you can redistribute it and/or modify it
 # under the terms and conditions of the GNU General Public License,
@@ -20,6 +20,7 @@
 # the file called "COPYING".
 #
 # Contact Information:
+# Linux NICS <linux.nics@intel.com>
 # e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
 # Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
 #
@@ -31,8 +32,4 @@
 
 obj-$(CONFIG_IGBVF) += igbvf.o
 
-igbvf-objs := vf.o \
-              mbx.o \
-              ethtool.o \
-              netdev.o
-
+igbvf-objs := netdev.o ethtool.o param.o e1000_vf.o kcompat.o e1000_mbx.o
diff --git a/drivers/net/igbvf/defines.h b/drivers/net/igbvf/defines.h
deleted file mode 100644 (file)
index 3e18045..0000000
+++ /dev/null
@@ -1,121 +0,0 @@
-/*******************************************************************************
-
-  Intel(R) 82576 Virtual Function Linux driver
-  Copyright(c) 1999 - 2012 Intel Corporation.
-
-  This program is free software; you can redistribute it and/or modify it
-  under the terms and conditions of the GNU General Public License,
-  version 2, as published by the Free Software Foundation.
-
-  This program is distributed in the hope it will be useful, but WITHOUT
-  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
-  more details.
-
-  You should have received a copy of the GNU General Public License along with
-  this program; if not, write to the Free Software Foundation, Inc.,
-  51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
-
-  The full GNU General Public License is included in this distribution in
-  the file called "COPYING".
-
-  Contact Information:
-  e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
-  Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
-
-*******************************************************************************/
-
-#ifndef _E1000_DEFINES_H_
-#define _E1000_DEFINES_H_
-
-/* Number of Transmit and Receive Descriptors must be a multiple of 8 */
-#define REQ_TX_DESCRIPTOR_MULTIPLE  8
-#define REQ_RX_DESCRIPTOR_MULTIPLE  8
-
-/* IVAR valid bit */
-#define E1000_IVAR_VALID        0x80
-
-/* Receive Descriptor bit definitions */
-#define E1000_RXD_STAT_DD       0x01    /* Descriptor Done */
-#define E1000_RXD_STAT_EOP      0x02    /* End of Packet */
-#define E1000_RXD_STAT_IXSM     0x04    /* Ignore checksum */
-#define E1000_RXD_STAT_VP       0x08    /* IEEE VLAN Packet */
-#define E1000_RXD_STAT_UDPCS    0x10    /* UDP xsum calculated */
-#define E1000_RXD_STAT_TCPCS    0x20    /* TCP xsum calculated */
-#define E1000_RXD_STAT_IPCS     0x40    /* IP xsum calculated */
-#define E1000_RXD_ERR_SE        0x02    /* Symbol Error */
-#define E1000_RXD_SPC_VLAN_MASK 0x0FFF  /* VLAN ID is in lower 12 bits */
-
-#define E1000_RXDEXT_STATERR_CE    0x01000000
-#define E1000_RXDEXT_STATERR_SE    0x02000000
-#define E1000_RXDEXT_STATERR_SEQ   0x04000000
-#define E1000_RXDEXT_STATERR_CXE   0x10000000
-#define E1000_RXDEXT_STATERR_TCPE  0x20000000
-#define E1000_RXDEXT_STATERR_IPE   0x40000000
-#define E1000_RXDEXT_STATERR_RXE   0x80000000
-
-
-/* Same mask, but for extended and packet split descriptors */
-#define E1000_RXDEXT_ERR_FRAME_ERR_MASK ( \
-    E1000_RXDEXT_STATERR_CE  |            \
-    E1000_RXDEXT_STATERR_SE  |            \
-    E1000_RXDEXT_STATERR_SEQ |            \
-    E1000_RXDEXT_STATERR_CXE |            \
-    E1000_RXDEXT_STATERR_RXE)
-
-/* Device Control */
-#define E1000_CTRL_RST      0x04000000  /* Global reset */
-
-/* Device Status */
-#define E1000_STATUS_FD         0x00000001      /* Full duplex.0=half,1=full */
-#define E1000_STATUS_LU         0x00000002      /* Link up.0=no,1=link */
-#define E1000_STATUS_TXOFF      0x00000010      /* transmission paused */
-#define E1000_STATUS_SPEED_10   0x00000000      /* Speed 10Mb/s */
-#define E1000_STATUS_SPEED_100  0x00000040      /* Speed 100Mb/s */
-#define E1000_STATUS_SPEED_1000 0x00000080      /* Speed 1000Mb/s */
-
-#define SPEED_10    10
-#define SPEED_100   100
-#define SPEED_1000  1000
-#define HALF_DUPLEX 1
-#define FULL_DUPLEX 2
-
-/* Transmit Descriptor bit definitions */
-#define E1000_TXD_POPTS_IXSM 0x01       /* Insert IP checksum */
-#define E1000_TXD_POPTS_TXSM 0x02       /* Insert TCP/UDP checksum */
-#define E1000_TXD_CMD_DEXT   0x20000000 /* Descriptor extension (0 = legacy) */
-#define E1000_TXD_STAT_DD    0x00000001 /* Descriptor Done */
-
-#define MAX_JUMBO_FRAME_SIZE    0x3F00
-
-/* 802.1q VLAN Packet Size */
-#define VLAN_TAG_SIZE              4    /* 802.3ac tag (not DMA'd) */
-
-/* Error Codes */
-#define E1000_SUCCESS      0
-#define E1000_ERR_CONFIG   3
-#define E1000_ERR_MAC_INIT 5
-#define E1000_ERR_MBX      15
-
-/* SRRCTL bit definitions */
-#define E1000_SRRCTL_BSIZEPKT_SHIFT                     10 /* Shift _right_ */
-#define E1000_SRRCTL_BSIZEHDRSIZE_MASK                  0x00000F00
-#define E1000_SRRCTL_BSIZEHDRSIZE_SHIFT                 2  /* Shift _left_ */
-#define E1000_SRRCTL_DESCTYPE_ADV_ONEBUF                0x02000000
-#define E1000_SRRCTL_DESCTYPE_HDR_SPLIT_ALWAYS          0x0A000000
-#define E1000_SRRCTL_DESCTYPE_MASK                      0x0E000000
-#define E1000_SRRCTL_DROP_EN                            0x80000000
-
-#define E1000_SRRCTL_BSIZEPKT_MASK      0x0000007F
-#define E1000_SRRCTL_BSIZEHDR_MASK      0x00003F00
-
-/* Additional Descriptor Control definitions */
-#define E1000_TXDCTL_QUEUE_ENABLE  0x02000000 /* Enable specific Tx Queue */
-#define E1000_RXDCTL_QUEUE_ENABLE  0x02000000 /* Enable specific Rx Queue */
-
-/* Direct Cache Access (DCA) definitions */
-#define E1000_DCA_TXCTRL_TX_WB_RO_EN (1 << 11) /* Tx Desc writeback RO bit */
-
-#define E1000_VF_INIT_TIMEOUT 200 /* Number of retries to clear RSTI */
-
-#endif /* _E1000_DEFINES_H_ */
diff --git a/drivers/net/igbvf/e1000_defines.h b/drivers/net/igbvf/e1000_defines.h
new file mode 100644 (file)
index 0000000..ba71d1d
--- /dev/null
@@ -0,0 +1,1453 @@
+/*******************************************************************************
+
+  Intel(R) 82576 Virtual Function Linux driver
+  Copyright(c) 1999 - 2012 Intel Corporation.
+
+  This program is free software; you can redistribute it and/or modify it
+  under the terms and conditions of the GNU General Public License,
+  version 2, as published by the Free Software Foundation.
+
+  This program is distributed in the hope it will be useful, but WITHOUT
+  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+  more details.
+
+  You should have received a copy of the GNU General Public License along with
+  this program; if not, write to the Free Software Foundation, Inc.,
+  51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
+
+  The full GNU General Public License is included in this distribution in
+  the file called "COPYING".
+
+  Contact Information:
+  Linux NICS <linux.nics@intel.com>
+  e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
+  Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
+
+*******************************************************************************/
+
+#ifndef _E1000_DEFINES_H_
+#define _E1000_DEFINES_H_
+
+/* Number of Transmit and Receive Descriptors must be a multiple of 8 */
+#define REQ_TX_DESCRIPTOR_MULTIPLE  8
+#define REQ_RX_DESCRIPTOR_MULTIPLE  8
+
+/* Definitions for power management and wakeup registers */
+/* Wake Up Control */
+#define E1000_WUC_APME         0x00000001 /* APM Enable */
+#define E1000_WUC_PME_EN       0x00000002 /* PME Enable */
+#define E1000_WUC_PME_STATUS   0x00000004 /* PME Status */
+#define E1000_WUC_APMPME       0x00000008 /* Assert PME on APM Wakeup */
+#define E1000_WUC_LSCWE                0x00000010 /* Link Status wake up enable */
+#define E1000_WUC_LSCWO                0x00000020 /* Link Status wake up override */
+#define E1000_WUC_SPM          0x80000000 /* Enable SPM */
+#define E1000_WUC_PHY_WAKE     0x00000100 /* if PHY supports wakeup */
+
+/* Wake Up Filter Control */
+#define E1000_WUFC_LNKC        0x00000001 /* Link Status Change Wakeup Enable */
+#define E1000_WUFC_MAG 0x00000002 /* Magic Packet Wakeup Enable */
+#define E1000_WUFC_EX  0x00000004 /* Directed Exact Wakeup Enable */
+#define E1000_WUFC_MC  0x00000008 /* Directed Multicast Wakeup Enable */
+#define E1000_WUFC_BC  0x00000010 /* Broadcast Wakeup Enable */
+#define E1000_WUFC_ARP 0x00000020 /* ARP Request Packet Wakeup Enable */
+#define E1000_WUFC_IPV4        0x00000040 /* Directed IPv4 Packet Wakeup Enable */
+#define E1000_WUFC_IPV6        0x00000080 /* Directed IPv6 Packet Wakeup Enable */
+#define E1000_WUFC_IGNORE_TCO  0x00008000 /* Ignore WakeOn TCO packets */
+#define E1000_WUFC_FLX0                0x00010000 /* Flexible Filter 0 Enable */
+#define E1000_WUFC_FLX1                0x00020000 /* Flexible Filter 1 Enable */
+#define E1000_WUFC_FLX2                0x00040000 /* Flexible Filter 2 Enable */
+#define E1000_WUFC_FLX3                0x00080000 /* Flexible Filter 3 Enable */
+#define E1000_WUFC_ALL_FILTERS         0x000F00FF /* all wakeup filters mask */
+#define E1000_WUFC_FLX_OFFSET          16 /* Flexible Filters bits offset */
+#define E1000_WUFC_FLX_FILTERS         0x000F0000 /* 4 flexible filters mask */
+
+/* Wake Up Status */
+#define E1000_WUS_LNKC         E1000_WUFC_LNKC
+#define E1000_WUS_MAG          E1000_WUFC_MAG
+#define E1000_WUS_EX           E1000_WUFC_EX
+#define E1000_WUS_MC           E1000_WUFC_MC
+#define E1000_WUS_BC           E1000_WUFC_BC
+#define E1000_WUS_ARP          E1000_WUFC_ARP
+#define E1000_WUS_IPV4         E1000_WUFC_IPV4
+#define E1000_WUS_IPV6         E1000_WUFC_IPV6
+#define E1000_WUS_FLX0         E1000_WUFC_FLX0
+#define E1000_WUS_FLX1         E1000_WUFC_FLX1
+#define E1000_WUS_FLX2         E1000_WUFC_FLX2
+#define E1000_WUS_FLX3         E1000_WUFC_FLX3
+#define E1000_WUS_FLX_FILTERS  E1000_WUFC_FLX_FILTERS
+
+/* Wake Up Packet Length */
+#define E1000_WUPL_LENGTH_MASK 0x0FFF   /* Only the lower 12 bits are valid */
+
+/* Four Flexible Filters are supported */
+#define E1000_FLEXIBLE_FILTER_COUNT_MAX                4
+
+/* Each Flexible Filter is at most 128 (0x80) bytes in length */
+#define E1000_FLEXIBLE_FILTER_SIZE_MAX 128
+
+#define E1000_FFLT_SIZE                E1000_FLEXIBLE_FILTER_COUNT_MAX
+#define E1000_FFMT_SIZE                E1000_FLEXIBLE_FILTER_SIZE_MAX
+#define E1000_FFVT_SIZE                E1000_FLEXIBLE_FILTER_SIZE_MAX
+
+/* Extended Device Control */
+#define E1000_CTRL_EXT_GPI0_EN         0x00000001 /* Maps SDP4 to GPI0 */
+#define E1000_CTRL_EXT_GPI1_EN         0x00000002 /* Maps SDP5 to GPI1 */
+#define E1000_CTRL_EXT_PHYINT_EN       E1000_CTRL_EXT_GPI1_EN
+#define E1000_CTRL_EXT_GPI2_EN         0x00000004 /* Maps SDP6 to GPI2 */
+#define E1000_CTRL_EXT_GPI3_EN         0x00000008 /* Maps SDP7 to GPI3 */
+/* Reserved (bits 4,5) in >= 82575 */
+#define E1000_CTRL_EXT_SDP4_DATA       0x00000010 /* SW Definable Pin 4 data */
+#define E1000_CTRL_EXT_SDP5_DATA       0x00000020 /* SW Definable Pin 5 data */
+#define E1000_CTRL_EXT_PHY_INT         E1000_CTRL_EXT_SDP5_DATA
+#define E1000_CTRL_EXT_SDP6_DATA       0x00000040 /* SW Definable Pin 6 data */
+#define E1000_CTRL_EXT_SDP3_DATA       0x00000080 /* SW Definable Pin 3 data */
+/* SDP 4/5 (bits 8,9) are reserved in >= 82575 */
+#define E1000_CTRL_EXT_SDP4_DIR        0x00000100 /* Direction of SDP4 0=in 1=out */
+#define E1000_CTRL_EXT_SDP5_DIR        0x00000200 /* Direction of SDP5 0=in 1=out */
+#define E1000_CTRL_EXT_SDP6_DIR        0x00000400 /* Direction of SDP6 0=in 1=out */
+#define E1000_CTRL_EXT_SDP3_DIR        0x00000800 /* Direction of SDP3 0=in 1=out */
+#define E1000_CTRL_EXT_ASDCHK  0x00001000 /* Initiate an ASD sequence */
+#define E1000_CTRL_EXT_EE_RST  0x00002000 /* Reinitialize from EEPROM */
+#define E1000_CTRL_EXT_IPS     0x00004000 /* Invert Power State */
+#define E1000_CTRL_EXT_SPD_BYPS        0x00008000 /* Speed Select Bypass */
+#define E1000_CTRL_EXT_RO_DIS  0x00020000 /* Relaxed Ordering disable */
+#define E1000_CTRL_EXT_DMA_DYN_CLK_EN  0x00080000 /* DMA Dynamic Clk Gating */
+#define E1000_CTRL_EXT_LINK_MODE_MASK  0x00C00000
+/* Offset of the link mode field in Ctrl Ext register */
+#define E1000_CTRL_EXT_LINK_MODE_OFFSET        22
+#define E1000_CTRL_EXT_LINK_MODE_GMII  0x00000000
+#define E1000_CTRL_EXT_LINK_MODE_TBI   0x00C00000
+#define E1000_CTRL_EXT_LINK_MODE_KMRN  0x00000000
+#define E1000_CTRL_EXT_LINK_MODE_PCIE_SERDES   0x00C00000
+#define E1000_CTRL_EXT_LINK_MODE_PCIX_SERDES   0x00800000
+#define E1000_CTRL_EXT_LINK_MODE_SGMII 0x00800000
+#define E1000_CTRL_EXT_EIAME           0x01000000
+#define E1000_CTRL_EXT_IRCA            0x00000001
+#define E1000_CTRL_EXT_WR_WMARK_MASK   0x03000000
+#define E1000_CTRL_EXT_WR_WMARK_256    0x00000000
+#define E1000_CTRL_EXT_WR_WMARK_320    0x01000000
+#define E1000_CTRL_EXT_WR_WMARK_384    0x02000000
+#define E1000_CTRL_EXT_WR_WMARK_448    0x03000000
+#define E1000_CTRL_EXT_CANC            0x04000000 /* Int delay cancellation */
+#define E1000_CTRL_EXT_DRV_LOAD                0x10000000 /* Drv loaded bit for FW */
+/* IAME enable bit (27) was removed in >= 82575 */
+#define E1000_CTRL_EXT_IAME            0x08000000 /* Int ACK Auto-mask */
+/* packet buffer parity error detection enabled */
+#define E1000_CRTL_EXT_PB_PAREN                0x01000000
+/* descriptor FIFO parity error detection enable */
+#define E1000_CTRL_EXT_DF_PAREN                0x02000000
+#define E1000_CTRL_EXT_GHOST_PAREN     0x40000000
+#define E1000_CTRL_EXT_PBA_CLR         0x80000000 /* PBA Clear */
+#define E1000_I2CCMD_REG_ADDR_SHIFT    16
+#define E1000_I2CCMD_REG_ADDR          0x00FF0000
+#define E1000_I2CCMD_PHY_ADDR_SHIFT    24
+#define E1000_I2CCMD_PHY_ADDR          0x07000000
+#define E1000_I2CCMD_OPCODE_READ       0x08000000
+#define E1000_I2CCMD_OPCODE_WRITE      0x00000000
+#define E1000_I2CCMD_RESET             0x10000000
+#define E1000_I2CCMD_READY             0x20000000
+#define E1000_I2CCMD_INTERRUPT_ENA     0x40000000
+#define E1000_I2CCMD_ERROR             0x80000000
+#define E1000_I2CCMD_SFP_DATA_ADDR(a)  (0x0000 + (a))
+#define E1000_I2CCMD_SFP_DIAG_ADDR(a)  (0x0100 + (a))
+#define E1000_MAX_SGMII_PHY_REG_ADDR   255
+#define E1000_I2CCMD_PHY_TIMEOUT       200
+
+/* Receive Descriptor bit definitions */
+#define E1000_RXD_STAT_DD      0x01    /* Descriptor Done */
+#define E1000_RXD_STAT_EOP     0x02    /* End of Packet */
+#define E1000_RXD_STAT_IXSM    0x04    /* Ignore checksum */
+#define E1000_RXD_STAT_VP      0x08    /* IEEE VLAN Packet */
+#define E1000_RXD_STAT_UDPCS   0x10    /* UDP xsum calculated */
+#define E1000_RXD_STAT_TCPCS   0x20    /* TCP xsum calculated */
+#define E1000_RXD_STAT_IPCS    0x40    /* IP xsum calculated */
+#define E1000_RXD_STAT_PIF     0x80    /* passed in-exact filter */
+#define E1000_RXD_STAT_CRCV    0x100   /* Speculative CRC Valid */
+#define E1000_RXD_STAT_IPIDV   0x200   /* IP identification valid */
+#define E1000_RXD_STAT_UDPV    0x400   /* Valid UDP checksum */
+#define E1000_RXD_STAT_DYNINT  0x800   /* Pkt caused INT via DYNINT */
+#define E1000_RXD_STAT_ACK     0x8000  /* ACK Packet indication */
+#define E1000_RXD_ERR_CE       0x01    /* CRC Error */
+#define E1000_RXD_ERR_SE       0x02    /* Symbol Error */
+#define E1000_RXD_ERR_SEQ      0x04    /* Sequence Error */
+#define E1000_RXD_ERR_CXE      0x10    /* Carrier Extension Error */
+#define E1000_RXD_ERR_TCPE     0x20    /* TCP/UDP Checksum Error */
+#define E1000_RXD_ERR_IPE      0x40    /* IP Checksum Error */
+#define E1000_RXD_ERR_RXE      0x80    /* Rx Data Error */
+#define E1000_RXD_SPC_VLAN_MASK        0x0FFF  /* VLAN ID is in lower 12 bits */
+#define E1000_RXD_SPC_PRI_MASK 0xE000  /* Priority is in upper 3 bits */
+#define E1000_RXD_SPC_PRI_SHIFT        13
+#define E1000_RXD_SPC_CFI_MASK 0x1000  /* CFI is bit 12 */
+#define E1000_RXD_SPC_CFI_SHIFT        12
+
+#define E1000_RXDEXT_STATERR_LB                0x00040000
+#define E1000_RXDEXT_STATERR_CE                0x01000000
+#define E1000_RXDEXT_STATERR_SE                0x02000000
+#define E1000_RXDEXT_STATERR_SEQ       0x04000000
+#define E1000_RXDEXT_STATERR_CXE       0x10000000
+#define E1000_RXDEXT_STATERR_TCPE      0x20000000
+#define E1000_RXDEXT_STATERR_IPE       0x40000000
+#define E1000_RXDEXT_STATERR_RXE       0x80000000
+
+/* mask to determine if packets should be dropped due to frame errors */
+#define E1000_RXD_ERR_FRAME_ERR_MASK ( \
+       E1000_RXD_ERR_CE  |             \
+       E1000_RXD_ERR_SE  |             \
+       E1000_RXD_ERR_SEQ |             \
+       E1000_RXD_ERR_CXE |             \
+       E1000_RXD_ERR_RXE)
+
+/* Same mask, but for extended and packet split descriptors */
+#define E1000_RXDEXT_ERR_FRAME_ERR_MASK ( \
+       E1000_RXDEXT_STATERR_CE  |      \
+       E1000_RXDEXT_STATERR_SE  |      \
+       E1000_RXDEXT_STATERR_SEQ |      \
+       E1000_RXDEXT_STATERR_CXE |      \
+       E1000_RXDEXT_STATERR_RXE)
+
+#define E1000_MRQC_ENABLE_MASK                 0x00000007
+#define E1000_MRQC_ENABLE_RSS_2Q               0x00000001
+#define E1000_MRQC_ENABLE_RSS_INT              0x00000004
+#define E1000_MRQC_RSS_FIELD_MASK              0xFFFF0000
+#define E1000_MRQC_RSS_FIELD_IPV4_TCP          0x00010000
+#define E1000_MRQC_RSS_FIELD_IPV4              0x00020000
+#define E1000_MRQC_RSS_FIELD_IPV6_TCP_EX       0x00040000
+#define E1000_MRQC_RSS_FIELD_IPV6_EX           0x00080000
+#define E1000_MRQC_RSS_FIELD_IPV6              0x00100000
+#define E1000_MRQC_RSS_FIELD_IPV6_TCP          0x00200000
+
+#define E1000_RXDPS_HDRSTAT_HDRSP              0x00008000
+#define E1000_RXDPS_HDRSTAT_HDRLEN_MASK                0x000003FF
+
+/* Management Control */
+#define E1000_MANC_SMBUS_EN    0x00000001 /* SMBus Enabled - RO */
+#define E1000_MANC_ASF_EN      0x00000002 /* ASF Enabled - RO */
+#define E1000_MANC_R_ON_FORCE  0x00000004 /* Reset on Force TCO - RO */
+#define E1000_MANC_RMCP_EN     0x00000100 /* Enable RCMP 026Fh Filtering */
+#define E1000_MANC_0298_EN     0x00000200 /* Enable RCMP 0298h Filtering */
+#define E1000_MANC_IPV4_EN     0x00000400 /* Enable IPv4 */
+#define E1000_MANC_IPV6_EN     0x00000800 /* Enable IPv6 */
+#define E1000_MANC_SNAP_EN     0x00001000 /* Accept LLC/SNAP */
+#define E1000_MANC_ARP_EN      0x00002000 /* Enable ARP Request Filtering */
+/* Enable Neighbor Discovery Filtering */
+#define E1000_MANC_NEIGHBOR_EN 0x00004000
+#define E1000_MANC_ARP_RES_EN  0x00008000 /* Enable ARP response Filtering */
+#define E1000_MANC_TCO_RESET   0x00010000 /* TCO Reset Occurred */
+#define E1000_MANC_RCV_TCO_EN  0x00020000 /* Receive TCO Packets Enabled */
+#define E1000_MANC_REPORT_STATUS 0x00040000 /* Status Reporting Enabled */
+#define E1000_MANC_RCV_ALL     0x00080000 /* Receive All Enabled */
+#define E1000_MANC_BLK_PHY_RST_ON_IDE  0x00040000 /* Block phy resets */
+/* Enable MAC address filtering */
+#define E1000_MANC_EN_MAC_ADDR_FILTER  0x00100000
+/* Enable MNG packets to host memory */
+#define E1000_MANC_EN_MNG2HOST         0x00200000
+/* Enable IP address filtering */
+#define E1000_MANC_EN_IP_ADDR_FILTER   0x00400000
+#define E1000_MANC_EN_XSUM_FILTER      0x00800000 /* Ena checksum filtering */
+#define E1000_MANC_BR_EN               0x01000000 /* Ena broadcast filtering */
+#define E1000_MANC_SMB_REQ             0x01000000 /* SMBus Request */
+#define E1000_MANC_SMB_GNT             0x02000000 /* SMBus Grant */
+#define E1000_MANC_SMB_CLK_IN          0x04000000 /* SMBus Clock In */
+#define E1000_MANC_SMB_DATA_IN         0x08000000 /* SMBus Data In */
+#define E1000_MANC_SMB_DATA_OUT                0x10000000 /* SMBus Data Out */
+#define E1000_MANC_SMB_CLK_OUT         0x20000000 /* SMBus Clock Out */
+
+#define E1000_MANC_SMB_DATA_OUT_SHIFT  28 /* SMBus Data Out Shift */
+#define E1000_MANC_SMB_CLK_OUT_SHIFT   29 /* SMBus Clock Out Shift */
+
+#define E1000_MANC2H_PORT_623          0x00000020 /* Port 0x26f */
+#define E1000_MANC2H_PORT_664          0x00000040 /* Port 0x298 */
+#define E1000_MDEF_PORT_623            0x00000800 /* Port 0x26f */
+#define E1000_MDEF_PORT_664            0x00000400 /* Port 0x298 */
+
+/* Receive Control */
+#define E1000_RCTL_RST         0x00000001 /* Software reset */
+#define E1000_RCTL_EN          0x00000002 /* enable */
+#define E1000_RCTL_SBP         0x00000004 /* store bad packet */
+#define E1000_RCTL_UPE         0x00000008 /* unicast promisc enable */
+#define E1000_RCTL_MPE         0x00000010 /* multicast promisc enable */
+#define E1000_RCTL_LPE         0x00000020 /* long packet enable */
+#define E1000_RCTL_LBM_NO      0x00000000 /* no loopback mode */
+#define E1000_RCTL_LBM_MAC     0x00000040 /* MAC loopback mode */
+#define E1000_RCTL_LBM_SLP     0x00000080 /* serial link loopback mode */
+#define E1000_RCTL_LBM_TCVR    0x000000C0 /* tcvr loopback mode */
+#define E1000_RCTL_DTYP_MASK   0x00000C00 /* Descriptor type mask */
+#define E1000_RCTL_DTYP_PS     0x00000400 /* Packet Split descriptor */
+#define E1000_RCTL_RDMTS_HALF  0x00000000 /* Rx desc min thresh size */
+#define E1000_RCTL_RDMTS_QUAT  0x00000100 /* Rx desc min thresh size */
+#define E1000_RCTL_RDMTS_EIGTH 0x00000200 /* Rx desc min thresh size */
+#define E1000_RCTL_MO_SHIFT    12 /* multicast offset shift */
+#define E1000_RCTL_MO_0                0x00000000 /* multicast offset 11:0 */
+#define E1000_RCTL_MO_1                0x00001000 /* multicast offset 12:1 */
+#define E1000_RCTL_MO_2                0x00002000 /* multicast offset 13:2 */
+#define E1000_RCTL_MO_3                0x00003000 /* multicast offset 15:4 */
+#define E1000_RCTL_MDR         0x00004000 /* multicast desc ring 0 */
+#define E1000_RCTL_BAM         0x00008000 /* broadcast enable */
+/* these buffer sizes are valid if E1000_RCTL_BSEX is 0 */
+#define E1000_RCTL_SZ_2048     0x00000000 /* Rx buffer size 2048 */
+#define E1000_RCTL_SZ_1024     0x00010000 /* Rx buffer size 1024 */
+#define E1000_RCTL_SZ_512      0x00020000 /* Rx buffer size 512 */
+#define E1000_RCTL_SZ_256      0x00030000 /* Rx buffer size 256 */
+/* these buffer sizes are valid if E1000_RCTL_BSEX is 1 */
+#define E1000_RCTL_SZ_16384    0x00010000 /* Rx buffer size 16384 */
+#define E1000_RCTL_SZ_8192     0x00020000 /* Rx buffer size 8192 */
+#define E1000_RCTL_SZ_4096     0x00030000 /* Rx buffer size 4096 */
+#define E1000_RCTL_VFE         0x00040000 /* vlan filter enable */
+#define E1000_RCTL_CFIEN       0x00080000 /* canonical form enable */
+#define E1000_RCTL_CFI         0x00100000 /* canonical form indicator */
+#define E1000_RCTL_DPF         0x00400000 /* discard pause frames */
+#define E1000_RCTL_PMCF                0x00800000 /* pass MAC control frames */
+#define E1000_RCTL_BSEX                0x02000000 /* Buffer size extension */
+#define E1000_RCTL_SECRC       0x04000000 /* Strip Ethernet CRC */
+#define E1000_RCTL_FLXBUF_MASK 0x78000000 /* Flexible buffer size */
+#define E1000_RCTL_FLXBUF_SHIFT        27 /* Flexible buffer shift */
+
+/*
+ * Use byte values for the following shift parameters
+ * Usage:
+ *     psrctl |= (((ROUNDUP(value0, 128) >> E1000_PSRCTL_BSIZE0_SHIFT) &
+ *               E1000_PSRCTL_BSIZE0_MASK) |
+ *             ((ROUNDUP(value1, 1024) >> E1000_PSRCTL_BSIZE1_SHIFT) &
+ *               E1000_PSRCTL_BSIZE1_MASK) |
+ *             ((ROUNDUP(value2, 1024) << E1000_PSRCTL_BSIZE2_SHIFT) &
+ *               E1000_PSRCTL_BSIZE2_MASK) |
+ *             ((ROUNDUP(value3, 1024) << E1000_PSRCTL_BSIZE3_SHIFT) |;
+ *               E1000_PSRCTL_BSIZE3_MASK))
+ * where value0 = [128..16256],  default=256
+ *       value1 = [1024..64512], default=4096
+ *       value2 = [0..64512],    default=4096
+ *       value3 = [0..64512],    default=0
+ */
+
+#define E1000_PSRCTL_BSIZE0_MASK       0x0000007F
+#define E1000_PSRCTL_BSIZE1_MASK       0x00003F00
+#define E1000_PSRCTL_BSIZE2_MASK       0x003F0000
+#define E1000_PSRCTL_BSIZE3_MASK       0x3F000000
+
+#define E1000_PSRCTL_BSIZE0_SHIFT      7    /* Shift _right_ 7 */
+#define E1000_PSRCTL_BSIZE1_SHIFT      2    /* Shift _right_ 2 */
+#define E1000_PSRCTL_BSIZE2_SHIFT      6    /* Shift _left_ 6 */
+#define E1000_PSRCTL_BSIZE3_SHIFT      14   /* Shift _left_ 14 */
+
+/* SWFW_SYNC Definitions */
+#define E1000_SWFW_EEP_SM      0x01
+#define E1000_SWFW_PHY0_SM     0x02
+#define E1000_SWFW_PHY1_SM     0x04
+#define E1000_SWFW_CSR_SM      0x08
+
+/* FACTPS Definitions */
+#define E1000_FACTPS_LFS       0x40000000  /* LAN Function Select */
+/* Device Control */
+#define E1000_CTRL_FD          0x00000001  /* Full duplex.0=half; 1=full */
+#define E1000_CTRL_BEM         0x00000002  /* Endian Mode.0=little,1=big */
+#define E1000_CTRL_PRIOR       0x00000004  /* Priority on PCI. 0=rx,1=fair */
+#define E1000_CTRL_GIO_MASTER_DISABLE 0x00000004 /*Blocks new Master reqs */
+#define E1000_CTRL_LRST                0x00000008  /* Link reset. 0=normal,1=reset */
+#define E1000_CTRL_TME         0x00000010  /* Test mode. 0=normal,1=test */
+#define E1000_CTRL_SLE         0x00000020  /* Serial Link on 0=dis,1=en */
+#define E1000_CTRL_ASDE                0x00000020  /* Auto-speed detect enable */
+#define E1000_CTRL_SLU         0x00000040  /* Set link up (Force Link) */
+#define E1000_CTRL_ILOS                0x00000080  /* Invert Loss-Of Signal */
+#define E1000_CTRL_SPD_SEL     0x00000300  /* Speed Select Mask */
+#define E1000_CTRL_SPD_10      0x00000000  /* Force 10Mb */
+#define E1000_CTRL_SPD_100     0x00000100  /* Force 100Mb */
+#define E1000_CTRL_SPD_1000    0x00000200  /* Force 1Gb */
+#define E1000_CTRL_BEM32       0x00000400  /* Big Endian 32 mode */
+#define E1000_CTRL_FRCSPD      0x00000800  /* Force Speed */
+#define E1000_CTRL_FRCDPX      0x00001000  /* Force Duplex */
+#define E1000_CTRL_D_UD_EN     0x00002000  /* Dock/Undock enable */
+/* Defined polarity of Dock/Undock indication in SDP[0] */
+#define E1000_CTRL_D_UD_POLARITY       0x00004000
+/* Reset both PHY ports, through PHYRST_N pin */
+#define E1000_CTRL_FORCE_PHY_RESET     0x00008000
+/* enable link status from external LINK_0 and LINK_1 pins */
+#define E1000_CTRL_EXT_LINK_EN         0x00010000
+#define E1000_CTRL_SWDPIN0     0x00040000 /* SWDPIN 0 value */
+#define E1000_CTRL_SWDPIN1     0x00080000 /* SWDPIN 1 value */
+#define E1000_CTRL_SWDPIN2     0x00100000 /* SWDPIN 2 value */
+#define E1000_CTRL_SWDPIN3     0x00200000 /* SWDPIN 3 value */
+#define E1000_CTRL_SWDPIO0     0x00400000 /* SWDPIN 0 Input or output */
+#define E1000_CTRL_SWDPIO1     0x00800000 /* SWDPIN 1 input or output */
+#define E1000_CTRL_SWDPIO2     0x01000000 /* SWDPIN 2 input or output */
+#define E1000_CTRL_SWDPIO3     0x02000000 /* SWDPIN 3 input or output */
+#define E1000_CTRL_RST         0x04000000 /* Global reset */
+#define E1000_CTRL_RFCE                0x08000000 /* Receive Flow Control enable */
+#define E1000_CTRL_TFCE                0x10000000 /* Transmit flow control enable */
+#define E1000_CTRL_RTE         0x20000000 /* Routing tag enable */
+#define E1000_CTRL_VME         0x40000000 /* IEEE VLAN mode enable */
+#define E1000_CTRL_PHY_RST     0x80000000 /* PHY Reset */
+#define E1000_CTRL_SW2FW_INT   0x02000000 /* Initiate an interrupt to ME */
+#define E1000_CTRL_I2C_ENA     0x02000000 /* I2C enable */
+
+/*
+ * Bit definitions for the Management Data IO (MDIO) and Management Data
+ * Clock (MDC) pins in the Device Control Register.
+ */
+#define E1000_CTRL_PHY_RESET_DIR       E1000_CTRL_SWDPIO0
+#define E1000_CTRL_PHY_RESET           E1000_CTRL_SWDPIN0
+#define E1000_CTRL_MDIO_DIR            E1000_CTRL_SWDPIO2
+#define E1000_CTRL_MDIO                        E1000_CTRL_SWDPIN2
+#define E1000_CTRL_MDC_DIR             E1000_CTRL_SWDPIO3
+#define E1000_CTRL_MDC                 E1000_CTRL_SWDPIN3
+#define E1000_CTRL_PHY_RESET_DIR4      E1000_CTRL_EXT_SDP4_DIR
+#define E1000_CTRL_PHY_RESET4          E1000_CTRL_EXT_SDP4_DATA
+
+#define E1000_CONNSW_ENRGSRC           0x4
+#define E1000_PCS_CFG_PCS_EN           8
+#define E1000_PCS_LCTL_FLV_LINK_UP     1
+#define E1000_PCS_LCTL_FSV_10          0
+#define E1000_PCS_LCTL_FSV_100         2
+#define E1000_PCS_LCTL_FSV_1000                4
+#define E1000_PCS_LCTL_FDV_FULL                8
+#define E1000_PCS_LCTL_FSD             0x10
+#define E1000_PCS_LCTL_FORCE_LINK      0x20
+#define E1000_PCS_LCTL_LOW_LINK_LATCH  0x40
+#define E1000_PCS_LCTL_FORCE_FCTRL     0x80
+#define E1000_PCS_LCTL_AN_ENABLE       0x10000
+#define E1000_PCS_LCTL_AN_RESTART      0x20000
+#define E1000_PCS_LCTL_AN_TIMEOUT      0x40000
+#define E1000_PCS_LCTL_AN_SGMII_BYPASS 0x80000
+#define E1000_PCS_LCTL_AN_SGMII_TRIGGER        0x100000
+#define E1000_PCS_LCTL_FAST_LINK_TIMER 0x1000000
+#define E1000_PCS_LCTL_LINK_OK_FIX     0x2000000
+#define E1000_PCS_LCTL_CRS_ON_NI       0x4000000
+#define E1000_ENABLE_SERDES_LOOPBACK   0x0410
+
+#define E1000_PCS_LSTS_LINK_OK         1
+#define E1000_PCS_LSTS_SPEED_10                0
+#define E1000_PCS_LSTS_SPEED_100       2
+#define E1000_PCS_LSTS_SPEED_1000      4
+#define E1000_PCS_LSTS_DUPLEX_FULL     8
+#define E1000_PCS_LSTS_SYNK_OK         0x10
+#define E1000_PCS_LSTS_AN_COMPLETE     0x10000
+#define E1000_PCS_LSTS_AN_PAGE_RX      0x20000
+#define E1000_PCS_LSTS_AN_TIMED_OUT    0x40000
+#define E1000_PCS_LSTS_AN_REMOTE_FAULT 0x80000
+#define E1000_PCS_LSTS_AN_ERROR_RWS    0x100000
+
+/* Device Status */
+#define E1000_STATUS_FD                        0x00000001 /* Duplex 0=half 1=full */
+#define E1000_STATUS_LU                        0x00000002 /* Link up.0=no,1=link */
+#define E1000_STATUS_FUNC_MASK         0x0000000C /* PCI Function Mask */
+#define E1000_STATUS_FUNC_SHIFT                2
+#define E1000_STATUS_FUNC_0            0x00000000 /* Function 0 */
+#define E1000_STATUS_FUNC_1            0x00000004 /* Function 1 */
+#define E1000_STATUS_TXOFF             0x00000010 /* transmission paused */
+#define E1000_STATUS_TBIMODE           0x00000020 /* TBI mode */
+#define E1000_STATUS_SPEED_MASK                0x000000C0
+#define E1000_STATUS_SPEED_10          0x00000000 /* Speed 10Mb/s */
+#define E1000_STATUS_SPEED_100         0x00000040 /* Speed 100Mb/s */
+#define E1000_STATUS_SPEED_1000                0x00000080 /* Speed 1000Mb/s */
+#define E1000_STATUS_LAN_INIT_DONE     0x00000200 /* Lan Init Compltn by NVM */
+#define E1000_STATUS_ASDV              0x00000300 /* Auto speed detect value */
+#define E1000_STATUS_PHYRA             0x00000400 /* PHY Reset Asserted */
+/* Change in Dock/Undock state clear on write '0'. */
+#define E1000_STATUS_DOCK_CI           0x00000800
+#define E1000_STATUS_GIO_MASTER_ENABLE 0x00080000 /* Master request status */
+#define E1000_STATUS_MTXCKOK           0x00000400 /* MTX clock running OK */
+#define E1000_STATUS_PCI66             0x00000800 /* In 66Mhz slot */
+#define E1000_STATUS_BUS64             0x00001000 /* In 64 bit slot */
+#define E1000_STATUS_PCIX_MODE         0x00002000 /* PCI-X mode */
+#define E1000_STATUS_PCIX_SPEED                0x0000C000 /* PCI-X bus speed */
+#define E1000_STATUS_BMC_SKU_0         0x00100000 /* BMC USB redirect disbld */
+#define E1000_STATUS_BMC_SKU_1         0x00200000 /* BMC SRAM disabled */
+#define E1000_STATUS_BMC_SKU_2         0x00400000 /* BMC SDRAM disabled */
+#define E1000_STATUS_BMC_CRYPTO                0x00800000 /* BMC crypto disabled */
+/* BMC external code execution disabled */
+#define E1000_STATUS_BMC_LITE          0x01000000
+#define E1000_STATUS_RGMII_ENABLE      0x02000000 /* RGMII disabled */
+#define E1000_STATUS_FUSE_8            0x04000000
+#define E1000_STATUS_FUSE_9            0x08000000
+#define E1000_STATUS_SERDES0_DIS       0x10000000 /* SERDES disbld on port 0 */
+#define E1000_STATUS_SERDES1_DIS       0x20000000 /* SERDES disbld on port 1 */
+
+/* Constants used to interpret the masked PCI-X bus speed. */
+#define E1000_STATUS_PCIX_SPEED_66     0x00000000 /* PCI-X bus spd 50-66MHz */
+#define E1000_STATUS_PCIX_SPEED_100    0x00004000 /* PCI-X bus spd 66-100MHz */
+#define E1000_STATUS_PCIX_SPEED_133    0x00008000 /* PCI-X bus spd 100-133MHz*/
+
+#define SPEED_10       10
+#define SPEED_100      100
+#define SPEED_1000     1000
+#define HALF_DUPLEX    1
+#define FULL_DUPLEX    2
+
+#define PHY_FORCE_TIME 20
+
+#define ADVERTISE_10_HALF              0x0001
+#define ADVERTISE_10_FULL              0x0002
+#define ADVERTISE_100_HALF             0x0004
+#define ADVERTISE_100_FULL             0x0008
+#define ADVERTISE_1000_HALF            0x0010 /* Not used, just FYI */
+#define ADVERTISE_1000_FULL            0x0020
+
+/* 1000/H is not supported, nor spec-compliant. */
+#define E1000_ALL_SPEED_DUPLEX ( \
+       ADVERTISE_10_HALF | ADVERTISE_10_FULL | ADVERTISE_100_HALF | \
+       ADVERTISE_100_FULL | ADVERTISE_1000_FULL)
+#define E1000_ALL_NOT_GIG      ( \
+       ADVERTISE_10_HALF | ADVERTISE_10_FULL | ADVERTISE_100_HALF | \
+       ADVERTISE_100_FULL)
+#define E1000_ALL_100_SPEED    (ADVERTISE_100_HALF | ADVERTISE_100_FULL)
+#define E1000_ALL_10_SPEED     (ADVERTISE_10_HALF | ADVERTISE_10_FULL)
+#define E1000_ALL_FULL_DUPLEX  ( \
+       ADVERTISE_10_FULL | ADVERTISE_100_FULL | ADVERTISE_1000_FULL)
+#define E1000_ALL_HALF_DUPLEX  (ADVERTISE_10_HALF | ADVERTISE_100_HALF)
+
+#define AUTONEG_ADVERTISE_SPEED_DEFAULT                E1000_ALL_SPEED_DUPLEX
+
+/* LED Control */
+#define E1000_LEDCTL_LED0_MODE_MASK    0x0000000F
+#define E1000_LEDCTL_LED0_MODE_SHIFT   0
+#define E1000_LEDCTL_LED0_BLINK_RATE   0x00000020
+#define E1000_LEDCTL_LED0_IVRT         0x00000040
+#define E1000_LEDCTL_LED0_BLINK                0x00000080
+#define E1000_LEDCTL_LED1_MODE_MASK    0x00000F00
+#define E1000_LEDCTL_LED1_MODE_SHIFT   8
+#define E1000_LEDCTL_LED1_BLINK_RATE   0x00002000
+#define E1000_LEDCTL_LED1_IVRT         0x00004000
+#define E1000_LEDCTL_LED1_BLINK                0x00008000
+#define E1000_LEDCTL_LED2_MODE_MASK    0x000F0000
+#define E1000_LEDCTL_LED2_MODE_SHIFT   16
+#define E1000_LEDCTL_LED2_BLINK_RATE   0x00200000
+#define E1000_LEDCTL_LED2_IVRT         0x00400000
+#define E1000_LEDCTL_LED2_BLINK                0x00800000
+#define E1000_LEDCTL_LED3_MODE_MASK    0x0F000000
+#define E1000_LEDCTL_LED3_MODE_SHIFT   24
+#define E1000_LEDCTL_LED3_BLINK_RATE   0x20000000
+#define E1000_LEDCTL_LED3_IVRT         0x40000000
+#define E1000_LEDCTL_LED3_BLINK                0x80000000
+
+#define E1000_LEDCTL_MODE_LINK_10_1000 0x0
+#define E1000_LEDCTL_MODE_LINK_100_1000        0x1
+#define E1000_LEDCTL_MODE_LINK_UP      0x2
+#define E1000_LEDCTL_MODE_ACTIVITY     0x3
+#define E1000_LEDCTL_MODE_LINK_ACTIVITY        0x4
+#define E1000_LEDCTL_MODE_LINK_10      0x5
+#define E1000_LEDCTL_MODE_LINK_100     0x6
+#define E1000_LEDCTL_MODE_LINK_1000    0x7
+#define E1000_LEDCTL_MODE_PCIX_MODE    0x8
+#define E1000_LEDCTL_MODE_FULL_DUPLEX  0x9
+#define E1000_LEDCTL_MODE_COLLISION    0xA
+#define E1000_LEDCTL_MODE_BUS_SPEED    0xB
+#define E1000_LEDCTL_MODE_BUS_SIZE     0xC
+#define E1000_LEDCTL_MODE_PAUSED       0xD
+#define E1000_LEDCTL_MODE_LED_ON       0xE
+#define E1000_LEDCTL_MODE_LED_OFF      0xF
+
+/* Transmit Descriptor bit definitions */
+#define E1000_TXD_DTYP_D       0x00100000 /* Data Descriptor */
+#define E1000_TXD_DTYP_C       0x00000000 /* Context Descriptor */
+#define E1000_TXD_POPTS_SHIFT  8          /* POPTS shift */
+#define E1000_TXD_POPTS_IXSM   0x01       /* Insert IP checksum */
+#define E1000_TXD_POPTS_TXSM   0x02       /* Insert TCP/UDP checksum */
+#define E1000_TXD_CMD_EOP      0x01000000 /* End of Packet */
+#define E1000_TXD_CMD_IFCS     0x02000000 /* Insert FCS (Ethernet CRC) */
+#define E1000_TXD_CMD_IC       0x04000000 /* Insert Checksum */
+#define E1000_TXD_CMD_RS       0x08000000 /* Report Status */
+#define E1000_TXD_CMD_RPS      0x10000000 /* Report Packet Sent */
+#define E1000_TXD_CMD_DEXT     0x20000000 /* Desc extension (0 = legacy) */
+#define E1000_TXD_CMD_VLE      0x40000000 /* Add VLAN tag */
+#define E1000_TXD_CMD_IDE      0x80000000 /* Enable Tidv register */
+#define E1000_TXD_STAT_DD      0x00000001 /* Descriptor Done */
+#define E1000_TXD_STAT_EC      0x00000002 /* Excess Collisions */
+#define E1000_TXD_STAT_LC      0x00000004 /* Late Collisions */
+#define E1000_TXD_STAT_TU      0x00000008 /* Transmit underrun */
+#define E1000_TXD_CMD_TCP      0x01000000 /* TCP packet */
+#define E1000_TXD_CMD_IP       0x02000000 /* IP packet */
+#define E1000_TXD_CMD_TSE      0x04000000 /* TCP Seg enable */
+#define E1000_TXD_STAT_TC      0x00000004 /* Tx Underrun */
+/* Extended desc bits for Linksec and timesync */
+
+/* Transmit Control */
+#define E1000_TCTL_RST         0x00000001 /* software reset */
+#define E1000_TCTL_EN          0x00000002 /* enable Tx */
+#define E1000_TCTL_BCE         0x00000004 /* busy check enable */
+#define E1000_TCTL_PSP         0x00000008 /* pad short packets */
+#define E1000_TCTL_CT          0x00000ff0 /* collision threshold */
+#define E1000_TCTL_COLD                0x003ff000 /* collision distance */
+#define E1000_TCTL_SWXOFF      0x00400000 /* SW Xoff transmission */
+#define E1000_TCTL_PBE         0x00800000 /* Packet Burst Enable */
+#define E1000_TCTL_RTLC                0x01000000 /* Re-transmit on late collision */
+#define E1000_TCTL_NRTU                0x02000000 /* No Re-transmit on underrun */
+#define E1000_TCTL_MULR                0x10000000 /* Multiple request support */
+
+/* Transmit Arbitration Count */
+#define E1000_TARC0_ENABLE     0x00000400 /* Enable Tx Queue 0 */
+
+/* SerDes Control */
+#define E1000_SCTL_DISABLE_SERDES_LOOPBACK     0x0400
+
+/* Receive Checksum Control */
+#define E1000_RXCSUM_PCSS_MASK 0x000000FF /* Packet Checksum Start */
+#define E1000_RXCSUM_IPOFL     0x00000100 /* IPv4 checksum offload */
+#define E1000_RXCSUM_TUOFL     0x00000200 /* TCP / UDP checksum offload */
+#define E1000_RXCSUM_IPV6OFL   0x00000400 /* IPv6 checksum offload */
+#define E1000_RXCSUM_CRCOFL    0x00000800 /* CRC32 offload enable */
+#define E1000_RXCSUM_IPPCSE    0x00001000 /* IP payload checksum enable */
+#define E1000_RXCSUM_PCSD      0x00002000 /* packet checksum disabled */
+
+/* Header split receive */
+#define E1000_RFCTL_ISCSI_DIS          0x00000001
+#define E1000_RFCTL_ISCSI_DWC_MASK     0x0000003E
+#define E1000_RFCTL_ISCSI_DWC_SHIFT    1
+#define E1000_RFCTL_NFSW_DIS           0x00000040
+#define E1000_RFCTL_NFSR_DIS           0x00000080
+#define E1000_RFCTL_NFS_VER_MASK       0x00000300
+#define E1000_RFCTL_NFS_VER_SHIFT      8
+#define E1000_RFCTL_IPV6_DIS           0x00000400
+#define E1000_RFCTL_IPV6_XSUM_DIS      0x00000800
+#define E1000_RFCTL_ACK_DIS            0x00001000
+#define E1000_RFCTL_ACKD_DIS           0x00002000
+#define E1000_RFCTL_IPFRSP_DIS         0x00004000
+#define E1000_RFCTL_EXTEN              0x00008000
+#define E1000_RFCTL_IPV6_EX_DIS                0x00010000
+#define E1000_RFCTL_NEW_IPV6_EXT_DIS   0x00020000
+#define E1000_RFCTL_LEF                        0x00040000
+
+/* Collision related configuration parameters */
+#define E1000_COLLISION_THRESHOLD      15
+#define E1000_CT_SHIFT                 4
+#define E1000_COLLISION_DISTANCE       63
+#define E1000_COLD_SHIFT               12
+
+/* Default values for the transmit IPG register */
+#define DEFAULT_82543_TIPG_IPGT_FIBER  9
+#define DEFAULT_82543_TIPG_IPGT_COPPER 8
+
+#define E1000_TIPG_IPGT_MASK           0x000003FF
+#define E1000_TIPG_IPGR1_MASK          0x000FFC00
+#define E1000_TIPG_IPGR2_MASK          0x3FF00000
+
+#define DEFAULT_82543_TIPG_IPGR1       8
+#define E1000_TIPG_IPGR1_SHIFT         10
+
+#define DEFAULT_82543_TIPG_IPGR2       6
+#define DEFAULT_80003ES2LAN_TIPG_IPGR2 7
+#define E1000_TIPG_IPGR2_SHIFT         20
+
+/* Ethertype field values */
+#define ETHERNET_IEEE_VLAN_TYPE                0x8100  /* 802.3ac packet */
+
+#define ETHERNET_FCS_SIZE              4
+#define MAX_JUMBO_FRAME_SIZE           0x3F00
+
+/* Extended Configuration Control and Size */
+#define E1000_EXTCNF_CTRL_MDIO_SW_OWNERSHIP    0x00000020
+#define E1000_EXTCNF_CTRL_LCD_WRITE_ENABLE     0x00000001
+#define E1000_EXTCNF_CTRL_OEM_WRITE_ENABLE     0x00000008
+#define E1000_EXTCNF_CTRL_SWFLAG               0x00000020
+#define E1000_EXTCNF_CTRL_GATE_PHY_CFG         0x00000080
+#define E1000_EXTCNF_SIZE_EXT_PCIE_LENGTH_MASK 0x00FF0000
+#define E1000_EXTCNF_SIZE_EXT_PCIE_LENGTH_SHIFT        16
+#define E1000_EXTCNF_CTRL_EXT_CNF_POINTER_MASK 0x0FFF0000
+#define E1000_EXTCNF_CTRL_EXT_CNF_POINTER_SHIFT        16
+
+#define E1000_PHY_CTRL_SPD_EN                  0x00000001
+#define E1000_PHY_CTRL_D0A_LPLU                        0x00000002
+#define E1000_PHY_CTRL_NOND0A_LPLU             0x00000004
+#define E1000_PHY_CTRL_NOND0A_GBE_DISABLE      0x00000008
+#define E1000_PHY_CTRL_GBE_DISABLE             0x00000040
+
+#define E1000_KABGTXD_BGSQLBIAS                        0x00050000
+
+/* PBA constants */
+#define E1000_PBA_6K           0x0006    /* 6KB */
+#define E1000_PBA_8K           0x0008    /* 8KB */
+#define E1000_PBA_10K          0x000A    /* 10KB */
+#define E1000_PBA_12K          0x000C    /* 12KB */
+#define E1000_PBA_14K          0x000E    /* 14KB */
+#define E1000_PBA_16K          0x0010    /* 16KB */
+#define E1000_PBA_18K          0x0012
+#define E1000_PBA_20K          0x0014
+#define E1000_PBA_22K          0x0016
+#define E1000_PBA_24K          0x0018
+#define E1000_PBA_26K          0x001A
+#define E1000_PBA_30K          0x001E
+#define E1000_PBA_32K          0x0020
+#define E1000_PBA_34K          0x0022
+#define E1000_PBA_35K          0x0023
+#define E1000_PBA_38K          0x0026
+#define E1000_PBA_40K          0x0028
+#define E1000_PBA_48K          0x0030    /* 48KB */
+#define E1000_PBA_64K          0x0040    /* 64KB */
+
+#define E1000_PBA_RXA_MASK     0xFFFF;
+
+#define E1000_PBS_16K          E1000_PBA_16K
+#define E1000_PBS_24K          E1000_PBA_24K
+
+#define IFS_MAX                        80
+#define IFS_MIN                        40
+#define IFS_RATIO              4
+#define IFS_STEP               10
+#define MIN_NUM_XMITS          1000
+
+/* SW Semaphore Register */
+#define E1000_SWSM_SMBI                0x00000001 /* Driver Semaphore bit */
+#define E1000_SWSM_SWESMBI     0x00000002 /* FW Semaphore bit */
+#define E1000_SWSM_WMNG                0x00000004 /* Wake MNG Clock */
+#define E1000_SWSM_DRV_LOAD    0x00000008 /* Driver Loaded Bit */
+
+#define E1000_SWSM2_LOCK       0x00000002 /* Secondary driver semaphore bit */
+
+/* Interrupt Cause Read */
+#define E1000_ICR_TXDW         0x00000001 /* Transmit desc written back */
+#define E1000_ICR_TXQE         0x00000002 /* Transmit Queue empty */
+#define E1000_ICR_LSC          0x00000004 /* Link Status Change */
+#define E1000_ICR_RXSEQ                0x00000008 /* Rx sequence error */
+#define E1000_ICR_RXDMT0       0x00000010 /* Rx desc min. threshold (0) */
+#define E1000_ICR_RXO          0x00000040 /* Rx overrun */
+#define E1000_ICR_RXT0         0x00000080 /* Rx timer intr (ring 0) */
+#define E1000_ICR_VMMB         0x00000100 /* VM MB event */
+#define E1000_ICR_MDAC         0x00000200 /* MDIO access complete */
+#define E1000_ICR_RXCFG                0x00000400 /* Rx /c/ ordered set */
+#define E1000_ICR_GPI_EN0      0x00000800 /* GP Int 0 */
+#define E1000_ICR_GPI_EN1      0x00001000 /* GP Int 1 */
+#define E1000_ICR_GPI_EN2      0x00002000 /* GP Int 2 */
+#define E1000_ICR_GPI_EN3      0x00004000 /* GP Int 3 */
+#define E1000_ICR_TXD_LOW      0x00008000
+#define E1000_ICR_SRPD         0x00010000
+#define E1000_ICR_ACK          0x00020000 /* Receive Ack frame */
+#define E1000_ICR_MNG          0x00040000 /* Manageability event */
+#define E1000_ICR_DOCK         0x00080000 /* Dock/Undock */
+/* If this bit asserted, the driver should claim the interrupt */
+#define E1000_ICR_INT_ASSERTED 0x80000000
+#define E1000_ICR_RXD_FIFO_PAR0        0x00100000 /* Q0 Rx desc FIFO parity error */
+#define E1000_ICR_TXD_FIFO_PAR0        0x00200000 /* Q0 Tx desc FIFO parity error */
+#define E1000_ICR_HOST_ARB_PAR 0x00400000 /* host arb read buffer parity err */
+#define E1000_ICR_PB_PAR       0x00800000 /* packet buffer parity error */
+#define E1000_ICR_RXD_FIFO_PAR1        0x01000000 /* Q1 Rx desc FIFO parity error */
+#define E1000_ICR_TXD_FIFO_PAR1        0x02000000 /* Q1 Tx desc FIFO parity error */
+#define E1000_ICR_ALL_PARITY   0x03F00000 /* all parity error bits */
+/* FW changed the status of DISSW bit in the FWSM */
+#define E1000_ICR_DSW          0x00000020
+/* LAN connected device generates an interrupt */
+#define E1000_ICR_PHYINT       0x00001000
+#define E1000_ICR_DOUTSYNC     0x10000000 /* NIC DMA out of sync */
+#define E1000_ICR_EPRST                0x00100000 /* ME hardware reset occurs */
+
+
+#define E1000_ITR_MASK         0x000FFFFF /* ITR value bitfield */
+#define E1000_ITR_MULT         256 /* ITR mulitplier in nsec */
+
+
+/*
+ * This defines the bits that are set in the Interrupt Mask
+ * Set/Read Register.  Each bit is documented below:
+ *   o RXDMT0 = Receive Descriptor Minimum Threshold hit (ring 0)
+ *   o RXSEQ  = Receive Sequence Error
+ */
+#define POLL_IMS_ENABLE_MASK ( \
+       E1000_IMS_RXDMT0 |    \
+       E1000_IMS_RXSEQ)
+
+/*
+ * This defines the bits that are set in the Interrupt Mask
+ * Set/Read Register.  Each bit is documented below:
+ *   o RXT0   = Receiver Timer Interrupt (ring 0)
+ *   o TXDW   = Transmit Descriptor Written Back
+ *   o RXDMT0 = Receive Descriptor Minimum Threshold hit (ring 0)
+ *   o RXSEQ  = Receive Sequence Error
+ *   o LSC    = Link Status Change
+ */
+#define IMS_ENABLE_MASK ( \
+       E1000_IMS_RXT0   |    \
+       E1000_IMS_TXDW   |    \
+       E1000_IMS_RXDMT0 |    \
+       E1000_IMS_RXSEQ  |    \
+       E1000_IMS_LSC)
+
+/* Interrupt Mask Set */
+#define E1000_IMS_TXDW         E1000_ICR_TXDW    /* Tx desc written back */
+#define E1000_IMS_TXQE         E1000_ICR_TXQE    /* Transmit Queue empty */
+#define E1000_IMS_LSC          E1000_ICR_LSC     /* Link Status Change */
+#define E1000_IMS_VMMB         E1000_ICR_VMMB    /* Mail box activity */
+#define E1000_IMS_RXSEQ                E1000_ICR_RXSEQ   /* Rx sequence error */
+#define E1000_IMS_RXDMT0       E1000_ICR_RXDMT0  /* Rx desc min. threshold */
+#define E1000_IMS_RXO          E1000_ICR_RXO     /* Rx overrun */
+#define E1000_IMS_RXT0         E1000_ICR_RXT0    /* Rx timer intr */
+#define E1000_IMS_MDAC         E1000_ICR_MDAC    /* MDIO access complete */
+#define E1000_IMS_RXCFG                E1000_ICR_RXCFG   /* Rx /c/ ordered set */
+#define E1000_IMS_GPI_EN0      E1000_ICR_GPI_EN0 /* GP Int 0 */
+#define E1000_IMS_GPI_EN1      E1000_ICR_GPI_EN1 /* GP Int 1 */
+#define E1000_IMS_GPI_EN2      E1000_ICR_GPI_EN2 /* GP Int 2 */
+#define E1000_IMS_GPI_EN3      E1000_ICR_GPI_EN3 /* GP Int 3 */
+#define E1000_IMS_TXD_LOW      E1000_ICR_TXD_LOW
+#define E1000_IMS_SRPD         E1000_ICR_SRPD
+#define E1000_IMS_ACK          E1000_ICR_ACK     /* Receive Ack frame */
+#define E1000_IMS_MNG          E1000_ICR_MNG     /* Manageability event */
+#define E1000_IMS_DOCK         E1000_ICR_DOCK    /* Dock/Undock */
+/* Q0 Rx desc FIFO parity error */
+#define E1000_IMS_RXD_FIFO_PAR0        E1000_ICR_RXD_FIFO_PAR0
+/* Q0 Tx desc FIFO parity error */
+#define E1000_IMS_TXD_FIFO_PAR0        E1000_ICR_TXD_FIFO_PAR0
+/* host arb read buffer parity error */
+#define E1000_IMS_HOST_ARB_PAR E1000_ICR_HOST_ARB_PAR
+/* packet buffer parity error */
+#define E1000_IMS_PB_PAR       E1000_ICR_PB_PAR
+/* Q1 Rx desc FIFO parity error */
+#define E1000_IMS_RXD_FIFO_PAR1        E1000_ICR_RXD_FIFO_PAR1
+/* Q1 Tx desc FIFO parity error */
+#define E1000_IMS_TXD_FIFO_PAR1        E1000_ICR_TXD_FIFO_PAR1
+#define E1000_IMS_DSW          E1000_ICR_DSW
+#define E1000_IMS_PHYINT       E1000_ICR_PHYINT
+#define E1000_IMS_DOUTSYNC     E1000_ICR_DOUTSYNC /* NIC DMA out of sync */
+#define E1000_IMS_EPRST                E1000_ICR_EPRST
+
+/* Interrupt Cause Set */
+#define E1000_ICS_TXDW         E1000_ICR_TXDW      /* Tx desc written back */
+#define E1000_ICS_TXQE         E1000_ICR_TXQE      /* Transmit Queue empty */
+#define E1000_ICS_LSC          E1000_ICR_LSC       /* Link Status Change */
+#define E1000_ICS_RXSEQ                E1000_ICR_RXSEQ     /* Rx sequence error */
+#define E1000_ICS_RXDMT0       E1000_ICR_RXDMT0    /* Rx desc min. threshold */
+#define E1000_ICS_RXO          E1000_ICR_RXO       /* Rx overrun */
+#define E1000_ICS_RXT0         E1000_ICR_RXT0      /* Rx timer intr */
+#define E1000_ICS_MDAC         E1000_ICR_MDAC      /* MDIO access complete */
+#define E1000_ICS_RXCFG                E1000_ICR_RXCFG     /* Rx /c/ ordered set */
+#define E1000_ICS_GPI_EN0      E1000_ICR_GPI_EN0   /* GP Int 0 */
+#define E1000_ICS_GPI_EN1      E1000_ICR_GPI_EN1   /* GP Int 1 */
+#define E1000_ICS_GPI_EN2      E1000_ICR_GPI_EN2   /* GP Int 2 */
+#define E1000_ICS_GPI_EN3      E1000_ICR_GPI_EN3   /* GP Int 3 */
+#define E1000_ICS_TXD_LOW      E1000_ICR_TXD_LOW
+#define E1000_ICS_SRPD         E1000_ICR_SRPD
+#define E1000_ICS_ACK          E1000_ICR_ACK       /* Receive Ack frame */
+#define E1000_ICS_MNG          E1000_ICR_MNG       /* Manageability event */
+#define E1000_ICS_DOCK         E1000_ICR_DOCK      /* Dock/Undock */
+/* Q0 Rx desc FIFO parity error */
+#define E1000_ICS_RXD_FIFO_PAR0        E1000_ICR_RXD_FIFO_PAR0
+/* Q0 Tx desc FIFO parity error */
+#define E1000_ICS_TXD_FIFO_PAR0        E1000_ICR_TXD_FIFO_PAR0
+/* host arb read buffer parity error */
+#define E1000_ICS_HOST_ARB_PAR E1000_ICR_HOST_ARB_PAR
+/* packet buffer parity error */
+#define E1000_ICS_PB_PAR       E1000_ICR_PB_PAR
+/* Q1 Rx desc FIFO parity error */
+#define E1000_ICS_RXD_FIFO_PAR1        E1000_ICR_RXD_FIFO_PAR1
+/* Q1 Tx desc FIFO parity error */
+#define E1000_ICS_TXD_FIFO_PAR1        E1000_ICR_TXD_FIFO_PAR1
+#define E1000_ICS_DSW          E1000_ICR_DSW
+#define E1000_ICS_DOUTSYNC     E1000_ICR_DOUTSYNC /* NIC DMA out of sync */
+#define E1000_ICS_PHYINT       E1000_ICR_PHYINT
+#define E1000_ICS_EPRST                E1000_ICR_EPRST
+
+/* Transmit Descriptor Control */
+#define E1000_TXDCTL_PTHRESH   0x0000003F /* TXDCTL Prefetch Threshold */
+#define E1000_TXDCTL_HTHRESH   0x00003F00 /* TXDCTL Host Threshold */
+#define E1000_TXDCTL_WTHRESH   0x003F0000 /* TXDCTL Writeback Threshold */
+#define E1000_TXDCTL_GRAN      0x01000000 /* TXDCTL Granularity */
+#define E1000_TXDCTL_LWTHRESH  0xFE000000 /* TXDCTL Low Threshold */
+#define E1000_TXDCTL_FULL_TX_DESC_WB   0x01010000 /* GRAN=1, WTHRESH=1 */
+#define E1000_TXDCTL_MAX_TX_DESC_PREFETCH 0x0100001F /* GRAN=1, PTHRESH=31 */
+/* Enable the counting of descriptors still to be processed. */
+#define E1000_TXDCTL_COUNT_DESC        0x00400000
+
+/* Flow Control Constants */
+#define FLOW_CONTROL_ADDRESS_LOW       0x00C28001
+#define FLOW_CONTROL_ADDRESS_HIGH      0x00000100
+#define FLOW_CONTROL_TYPE              0x8808
+
+/* 802.1q VLAN Packet Size */
+#define VLAN_TAG_SIZE                  4    /* 802.3ac tag (not DMA'd) */
+#define E1000_VLAN_FILTER_TBL_SIZE     128  /* VLAN Filter Table (4096 bits) */
+
+/* Receive Address */
+/*
+ * Number of high/low register pairs in the RAR. The RAR (Receive Address
+ * Registers) holds the directed and multicast addresses that we monitor.
+ * Technically, we have 16 spots.  However, we reserve one of these spots
+ * (RAR[15]) for our directed address used by controllers with
+ * manageability enabled, allowing us room for 15 multicast addresses.
+ */
+#define E1000_RAR_ENTRIES      15
+#define E1000_RAH_AV           0x80000000 /* Receive descriptor valid */
+#define E1000_RAL_MAC_ADDR_LEN 4
+#define E1000_RAH_MAC_ADDR_LEN 2
+#define E1000_RAH_POOL_MASK    0x03FC0000
+#define E1000_RAH_POOL_SHIFT   18
+#define E1000_RAH_POOL_1       0x00040000
+
+/* Error Codes */
+#define E1000_SUCCESS                  0
+#define E1000_ERR_NVM                  1
+#define E1000_ERR_PHY                  2
+#define E1000_ERR_CONFIG               3
+#define E1000_ERR_PARAM                        4
+#define E1000_ERR_MAC_INIT             5
+#define E1000_ERR_PHY_TYPE             6
+#define E1000_ERR_RESET                        9
+#define E1000_ERR_MASTER_REQUESTS_PENDING      10
+#define E1000_ERR_HOST_INTERFACE_COMMAND       11
+#define E1000_BLK_PHY_RESET            12
+#define E1000_ERR_SWFW_SYNC            13
+#define E1000_NOT_IMPLEMENTED          14
+#define E1000_ERR_MBX                  15
+#define E1000_ERR_INVALID_ARGUMENT     16
+#define E1000_ERR_NO_SPACE             17
+#define E1000_ERR_NVM_PBA_SECTION      18
+#define E1000_ERR_INVM_VALUE_NOT_FOUND 20
+
+/* Loop limit on how long we wait for auto-negotiation to complete */
+#define FIBER_LINK_UP_LIMIT            50
+#define COPPER_LINK_UP_LIMIT           10
+#define PHY_AUTO_NEG_LIMIT             45
+#define PHY_FORCE_LIMIT                        20
+/* Number of 100 microseconds we wait for PCI Express master disable */
+#define MASTER_DISABLE_TIMEOUT         800
+/* Number of milliseconds we wait for PHY configuration done after MAC reset */
+#define PHY_CFG_TIMEOUT                        100
+/* Number of 2 milliseconds we wait for acquiring MDIO ownership. */
+#define MDIO_OWNERSHIP_TIMEOUT         10
+/* Number of milliseconds for NVM auto read done after MAC reset. */
+#define AUTO_READ_DONE_TIMEOUT         10
+
+/* Flow Control */
+#define E1000_FCRTH_RTH                0x0000FFF8 /* Mask Bits[15:3] for RTH */
+#define E1000_FCRTH_XFCE       0x80000000 /* External Flow Control Enable */
+#define E1000_FCRTL_RTL                0x0000FFF8 /* Mask Bits[15:3] for RTL */
+#define E1000_FCRTL_XONE       0x80000000 /* Enable XON frame transmission */
+
+/* Transmit Configuration Word */
+#define E1000_TXCW_FD          0x00000020 /* TXCW full duplex */
+#define E1000_TXCW_HD          0x00000040 /* TXCW half duplex */
+#define E1000_TXCW_PAUSE       0x00000080 /* TXCW sym pause request */
+#define E1000_TXCW_ASM_DIR     0x00000100 /* TXCW astm pause direction */
+#define E1000_TXCW_PAUSE_MASK  0x00000180 /* TXCW pause request mask */
+#define E1000_TXCW_RF          0x00003000 /* TXCW remote fault */
+#define E1000_TXCW_NP          0x00008000 /* TXCW next page */
+#define E1000_TXCW_CW          0x0000ffff /* TxConfigWord mask */
+#define E1000_TXCW_TXC         0x40000000 /* Transmit Config control */
+#define E1000_TXCW_ANE         0x80000000 /* Auto-neg enable */
+
+/* Receive Configuration Word */
+#define E1000_RXCW_CW          0x0000ffff /* RxConfigWord mask */
+#define E1000_RXCW_NC          0x04000000 /* Receive config no carrier */
+#define E1000_RXCW_IV          0x08000000 /* Receive config invalid */
+#define E1000_RXCW_CC          0x10000000 /* Receive config change */
+#define E1000_RXCW_C           0x20000000 /* Receive config */
+#define E1000_RXCW_SYNCH       0x40000000 /* Receive config synch */
+#define E1000_RXCW_ANC         0x80000000 /* Auto-neg complete */
+
+#define E1000_TSYNCTXCTL_VALID         0x00000001 /* Tx timestamp valid */
+#define E1000_TSYNCTXCTL_ENABLED       0x00000010 /* enable Tx timestamping */
+
+#define E1000_TSYNCRXCTL_VALID         0x00000001 /* Rx timestamp valid */
+#define E1000_TSYNCRXCTL_TYPE_MASK     0x0000000E /* Rx type mask */
+#define E1000_TSYNCRXCTL_TYPE_L2_V2    0x00
+#define E1000_TSYNCRXCTL_TYPE_L4_V1    0x02
+#define E1000_TSYNCRXCTL_TYPE_L2_L4_V2 0x04
+#define E1000_TSYNCRXCTL_TYPE_ALL      0x08
+#define E1000_TSYNCRXCTL_TYPE_EVENT_V2 0x0A
+#define E1000_TSYNCRXCTL_ENABLED       0x00000010 /* enable Rx timestamping */
+
+#define E1000_TSYNCRXCFG_PTP_V1_CTRLT_MASK             0x000000FF
+#define E1000_TSYNCRXCFG_PTP_V1_SYNC_MESSAGE           0x00
+#define E1000_TSYNCRXCFG_PTP_V1_DELAY_REQ_MESSAGE      0x01
+#define E1000_TSYNCRXCFG_PTP_V1_FOLLOWUP_MESSAGE       0x02
+#define E1000_TSYNCRXCFG_PTP_V1_DELAY_RESP_MESSAGE     0x03
+#define E1000_TSYNCRXCFG_PTP_V1_MANAGEMENT_MESSAGE     0x04
+
+#define E1000_TSYNCRXCFG_PTP_V2_MSGID_MASK             0x00000F00
+#define E1000_TSYNCRXCFG_PTP_V2_SYNC_MESSAGE           0x0000
+#define E1000_TSYNCRXCFG_PTP_V2_DELAY_REQ_MESSAGE      0x0100
+#define E1000_TSYNCRXCFG_PTP_V2_PATH_DELAY_REQ_MESSAGE 0x0200
+#define E1000_TSYNCRXCFG_PTP_V2_PATH_DELAY_RESP_MESSAGE        0x0300
+#define E1000_TSYNCRXCFG_PTP_V2_FOLLOWUP_MESSAGE       0x0800
+#define E1000_TSYNCRXCFG_PTP_V2_DELAY_RESP_MESSAGE     0x0900
+#define E1000_TSYNCRXCFG_PTP_V2_PATH_DELAY_FOLLOWUP_MESSAGE 0x0A00
+#define E1000_TSYNCRXCFG_PTP_V2_ANNOUNCE_MESSAGE       0x0B00
+#define E1000_TSYNCRXCFG_PTP_V2_SIGNALLING_MESSAGE     0x0C00
+#define E1000_TSYNCRXCFG_PTP_V2_MANAGEMENT_MESSAGE     0x0D00
+
+#define E1000_TIMINCA_16NS_SHIFT       24
+
+/* PCI Express Control */
+#define E1000_GCR_RXD_NO_SNOOP         0x00000001
+#define E1000_GCR_RXDSCW_NO_SNOOP      0x00000002
+#define E1000_GCR_RXDSCR_NO_SNOOP      0x00000004
+#define E1000_GCR_TXD_NO_SNOOP         0x00000008
+#define E1000_GCR_TXDSCW_NO_SNOOP      0x00000010
+#define E1000_GCR_TXDSCR_NO_SNOOP      0x00000020
+#define E1000_GCR_CMPL_TMOUT_MASK      0x0000F000
+#define E1000_GCR_CMPL_TMOUT_10ms      0x00001000
+#define E1000_GCR_CMPL_TMOUT_RESEND    0x00010000
+#define E1000_GCR_CAP_VER2             0x00040000
+
+#define PCIE_NO_SNOOP_ALL      (E1000_GCR_RXD_NO_SNOOP | \
+                                E1000_GCR_RXDSCW_NO_SNOOP | \
+                                E1000_GCR_RXDSCR_NO_SNOOP | \
+                                E1000_GCR_TXD_NO_SNOOP    | \
+                                E1000_GCR_TXDSCW_NO_SNOOP | \
+                                E1000_GCR_TXDSCR_NO_SNOOP)
+
+/* PHY Control Register */
+#define MII_CR_SPEED_SELECT_MSB        0x0040  /* bits 6,13: 10=1000, 01=100, 00=10 */
+#define MII_CR_COLL_TEST_ENABLE        0x0080  /* Collision test enable */
+#define MII_CR_FULL_DUPLEX     0x0100  /* FDX =1, half duplex =0 */
+#define MII_CR_RESTART_AUTO_NEG        0x0200  /* Restart auto negotiation */
+#define MII_CR_ISOLATE         0x0400  /* Isolate PHY from MII */
+#define MII_CR_POWER_DOWN      0x0800  /* Power down */
+#define MII_CR_AUTO_NEG_EN     0x1000  /* Auto Neg Enable */
+#define MII_CR_SPEED_SELECT_LSB        0x2000  /* bits 6,13: 10=1000, 01=100, 00=10 */
+#define MII_CR_LOOPBACK                0x4000  /* 0 = normal, 1 = loopback */
+#define MII_CR_RESET           0x8000  /* 0 = normal, 1 = PHY reset */
+#define MII_CR_SPEED_1000      0x0040
+#define MII_CR_SPEED_100       0x2000
+#define MII_CR_SPEED_10                0x0000
+
+/* PHY Status Register */
+#define MII_SR_EXTENDED_CAPS   0x0001 /* Extended register capabilities */
+#define MII_SR_JABBER_DETECT   0x0002 /* Jabber Detected */
+#define MII_SR_LINK_STATUS     0x0004 /* Link Status 1 = link */
+#define MII_SR_AUTONEG_CAPS    0x0008 /* Auto Neg Capable */
+#define MII_SR_REMOTE_FAULT    0x0010 /* Remote Fault Detect */
+#define MII_SR_AUTONEG_COMPLETE        0x0020 /* Auto Neg Complete */
+#define MII_SR_PREAMBLE_SUPPRESS 0x0040 /* Preamble may be suppressed */
+#define MII_SR_EXTENDED_STATUS 0x0100 /* Ext. status info in Reg 0x0F */
+#define MII_SR_100T2_HD_CAPS   0x0200 /* 100T2 Half Duplex Capable */
+#define MII_SR_100T2_FD_CAPS   0x0400 /* 100T2 Full Duplex Capable */
+#define MII_SR_10T_HD_CAPS     0x0800 /* 10T   Half Duplex Capable */
+#define MII_SR_10T_FD_CAPS     0x1000 /* 10T   Full Duplex Capable */
+#define MII_SR_100X_HD_CAPS    0x2000 /* 100X  Half Duplex Capable */
+#define MII_SR_100X_FD_CAPS    0x4000 /* 100X  Full Duplex Capable */
+#define MII_SR_100T4_CAPS      0x8000 /* 100T4 Capable */
+
+/* Autoneg Advertisement Register */
+#define NWAY_AR_SELECTOR_FIELD 0x0001   /* indicates IEEE 802.3 CSMA/CD */
+#define NWAY_AR_10T_HD_CAPS    0x0020   /* 10T   Half Duplex Capable */
+#define NWAY_AR_10T_FD_CAPS    0x0040   /* 10T   Full Duplex Capable */
+#define NWAY_AR_100TX_HD_CAPS  0x0080   /* 100TX Half Duplex Capable */
+#define NWAY_AR_100TX_FD_CAPS  0x0100   /* 100TX Full Duplex Capable */
+#define NWAY_AR_100T4_CAPS     0x0200   /* 100T4 Capable */
+#define NWAY_AR_PAUSE          0x0400   /* Pause operation desired */
+#define NWAY_AR_ASM_DIR                0x0800   /* Asymmetric Pause Direction bit */
+#define NWAY_AR_REMOTE_FAULT   0x2000   /* Remote Fault detected */
+#define NWAY_AR_NEXT_PAGE      0x8000   /* Next Page ability supported */
+
+/* Link Partner Ability Register (Base Page) */
+#define NWAY_LPAR_SELECTOR_FIELD       0x0000 /* LP protocol selector field */
+#define NWAY_LPAR_10T_HD_CAPS          0x0020 /* LP 10T Half Dplx Capable */
+#define NWAY_LPAR_10T_FD_CAPS          0x0040 /* LP 10T Full Dplx Capable */
+#define NWAY_LPAR_100TX_HD_CAPS                0x0080 /* LP 100TX Half Dplx Capable */
+#define NWAY_LPAR_100TX_FD_CAPS                0x0100 /* LP 100TX Full Dplx Capable */
+#define NWAY_LPAR_100T4_CAPS           0x0200 /* LP is 100T4 Capable */
+#define NWAY_LPAR_PAUSE                        0x0400 /* LP Pause operation desired */
+#define NWAY_LPAR_ASM_DIR              0x0800 /* LP Asym Pause Direction bit */
+#define NWAY_LPAR_REMOTE_FAULT         0x2000 /* LP detected Remote Fault */
+#define NWAY_LPAR_ACKNOWLEDGE          0x4000 /* LP rx'd link code word */
+#define NWAY_LPAR_NEXT_PAGE            0x8000 /* Next Page ability supported */
+
+/* Autoneg Expansion Register */
+#define NWAY_ER_LP_NWAY_CAPS           0x0001 /* LP has Auto Neg Capability */
+#define NWAY_ER_PAGE_RXD               0x0002 /* LP 10T Half Dplx Capable */
+#define NWAY_ER_NEXT_PAGE_CAPS         0x0004 /* LP 10T Full Dplx Capable */
+#define NWAY_ER_LP_NEXT_PAGE_CAPS      0x0008 /* LP 100TX Half Dplx Capable */
+#define NWAY_ER_PAR_DETECT_FAULT       0x0010 /* LP 100TX Full Dplx Capable */
+
+/* 1000BASE-T Control Register */
+#define CR_1000T_ASYM_PAUSE    0x0080 /* Advertise asymmetric pause bit */
+#define CR_1000T_HD_CAPS       0x0100 /* Advertise 1000T HD capability */
+#define CR_1000T_FD_CAPS       0x0200 /* Advertise 1000T FD capability  */
+/* 1=Repeater/switch device port 0=DTE device */
+#define CR_1000T_REPEATER_DTE  0x0400
+/* 1=Configure PHY as Master 0=Configure PHY as Slave */
+#define CR_1000T_MS_VALUE      0x0800
+/* 1=Master/Slave manual config value 0=Automatic Master/Slave config */
+#define CR_1000T_MS_ENABLE     0x1000
+#define CR_1000T_TEST_MODE_NORMAL 0x0000 /* Normal Operation */
+#define CR_1000T_TEST_MODE_1   0x2000 /* Transmit Waveform test */
+#define CR_1000T_TEST_MODE_2   0x4000 /* Master Transmit Jitter test */
+#define CR_1000T_TEST_MODE_3   0x6000 /* Slave Transmit Jitter test */
+#define CR_1000T_TEST_MODE_4   0x8000 /* Transmitter Distortion test */
+
+/* 1000BASE-T Status Register */
+#define SR_1000T_IDLE_ERROR_CNT                0x00FF /* Num idle err since last rd */
+#define SR_1000T_ASYM_PAUSE_DIR                0x0100 /* LP asym pause direction bit */
+#define SR_1000T_LP_HD_CAPS            0x0400 /* LP is 1000T HD capable */
+#define SR_1000T_LP_FD_CAPS            0x0800 /* LP is 1000T FD capable */
+#define SR_1000T_REMOTE_RX_STATUS      0x1000 /* Remote receiver OK */
+#define SR_1000T_LOCAL_RX_STATUS       0x2000 /* Local receiver OK */
+#define SR_1000T_MS_CONFIG_RES         0x4000 /* 1=Local Tx Master, 0=Slave */
+#define SR_1000T_MS_CONFIG_FAULT       0x8000 /* Master/Slave config fault */
+
+#define SR_1000T_PHY_EXCESSIVE_IDLE_ERR_COUNT  5
+
+/* PHY 1000 MII Register/Bit Definitions */
+/* PHY Registers defined by IEEE */
+#define PHY_CONTROL            0x00 /* Control Register */
+#define PHY_STATUS             0x01 /* Status Register */
+#define PHY_ID1                        0x02 /* Phy Id Reg (word 1) */
+#define PHY_ID2                        0x03 /* Phy Id Reg (word 2) */
+#define PHY_AUTONEG_ADV                0x04 /* Autoneg Advertisement */
+#define PHY_LP_ABILITY         0x05 /* Link Partner Ability (Base Page) */
+#define PHY_AUTONEG_EXP                0x06 /* Autoneg Expansion Reg */
+#define PHY_NEXT_PAGE_TX       0x07 /* Next Page Tx */
+#define PHY_LP_NEXT_PAGE       0x08 /* Link Partner Next Page */
+#define PHY_1000T_CTRL         0x09 /* 1000Base-T Control Reg */
+#define PHY_1000T_STATUS       0x0A /* 1000Base-T Status Reg */
+#define PHY_EXT_STATUS         0x0F /* Extended Status Reg */
+
+#define PHY_CONTROL_LB         0x4000 /* PHY Loopback bit */
+
+/* NVM Control */
+#define E1000_EECD_SK          0x00000001 /* NVM Clock */
+#define E1000_EECD_CS          0x00000002 /* NVM Chip Select */
+#define E1000_EECD_DI          0x00000004 /* NVM Data In */
+#define E1000_EECD_DO          0x00000008 /* NVM Data Out */
+#define E1000_EECD_FWE_MASK    0x00000030
+#define E1000_EECD_FWE_DIS     0x00000010 /* Disable FLASH writes */
+#define E1000_EECD_FWE_EN      0x00000020 /* Enable FLASH writes */
+#define E1000_EECD_FWE_SHIFT   4
+#define E1000_EECD_REQ         0x00000040 /* NVM Access Request */
+#define E1000_EECD_GNT         0x00000080 /* NVM Access Grant */
+#define E1000_EECD_PRES                0x00000100 /* NVM Present */
+#define E1000_EECD_SIZE                0x00000200 /* NVM Size (0=64 word 1=256 word) */
+#define E1000_EECD_BLOCKED     0x00008000 /* Bit banging access blocked flag */
+#define E1000_EECD_ABORT       0x00010000 /* NVM operation aborted flag */
+#define E1000_EECD_TIMEOUT     0x00020000 /* NVM read operation timeout flag */
+#define E1000_EECD_ERROR_CLR   0x00040000 /* NVM error status clear bit */
+/* NVM Addressing bits based on type 0=small, 1=large */
+#define E1000_EECD_ADDR_BITS   0x00000400
+#define E1000_EECD_TYPE                0x00002000 /* NVM Type (1-SPI, 0-Microwire) */
+#define E1000_NVM_GRANT_ATTEMPTS       1000 /* NVM # attempts to gain grant */
+#define E1000_EECD_AUTO_RD             0x00000200  /* NVM Auto Read done */
+#define E1000_EECD_SIZE_EX_MASK                0x00007800  /* NVM Size */
+#define E1000_EECD_SIZE_EX_SHIFT       11
+#define E1000_EECD_NVADDS              0x00018000 /* NVM Address Size */
+#define E1000_EECD_SELSHAD             0x00020000 /* Select Shadow RAM */
+#define E1000_EECD_INITSRAM            0x00040000 /* Initialize Shadow RAM */
+#define E1000_EECD_FLUPD               0x00080000 /* Update FLASH */
+#define E1000_EECD_AUPDEN              0x00100000 /* Ena Auto FLASH update */
+#define E1000_EECD_SHADV               0x00200000 /* Shadow RAM Data Valid */
+#define E1000_EECD_SEC1VAL             0x00400000 /* Sector One Valid */
+#define E1000_EECD_SECVAL_SHIFT                22
+#define E1000_EECD_SEC1VAL_VALID_MASK  (E1000_EECD_AUTO_RD | E1000_EECD_PRES)
+
+#define E1000_NVM_SWDPIN0      0x0001 /* SWDPIN 0 NVM Value */
+#define E1000_NVM_LED_LOGIC    0x0020 /* Led Logic Word */
+#define E1000_NVM_RW_REG_DATA  16  /* Offset to data in NVM read/write regs */
+#define E1000_NVM_RW_REG_DONE  2   /* Offset to READ/WRITE done bit */
+#define E1000_NVM_RW_REG_START 1   /* Start operation */
+#define E1000_NVM_RW_ADDR_SHIFT        2   /* Shift to the address bits */
+#define E1000_NVM_POLL_WRITE   1   /* Flag for polling for write complete */
+#define E1000_NVM_POLL_READ    0   /* Flag for polling for read complete */
+#define E1000_FLASH_UPDATES    2000
+
+/* NVM Word Offsets */
+#define NVM_COMPAT                     0x0003
+#define NVM_ID_LED_SETTINGS            0x0004
+#define NVM_VERSION                    0x0005
+#define NVM_SERDES_AMPLITUDE           0x0006 /* SERDES output amplitude */
+#define NVM_PHY_CLASS_WORD             0x0007
+
+#define NVM_INIT_CONTROL1_REG          0x000A
+#define NVM_INIT_CONTROL2_REG          0x000F
+#define NVM_SWDEF_PINS_CTRL_PORT_1     0x0010
+#define NVM_INIT_CONTROL3_PORT_B       0x0014
+#define NVM_INIT_3GIO_3                        0x001A
+#define NVM_SWDEF_PINS_CTRL_PORT_0     0x0020
+#define NVM_INIT_CONTROL3_PORT_A       0x0024
+#define NVM_CFG                                0x0012
+#define NVM_FLASH_VERSION              0x0032
+#define NVM_ALT_MAC_ADDR_PTR           0x0037
+#define NVM_CHECKSUM_REG               0x003F
+
+#define E1000_NVM_CFG_DONE_PORT_0      0x040000 /* MNG config cycle done */
+#define E1000_NVM_CFG_DONE_PORT_1      0x080000 /* ...for second port */
+
+/* Mask bits for fields in Word 0x0f of the NVM */
+#define NVM_WORD0F_PAUSE_MASK          0x3000
+#define NVM_WORD0F_PAUSE               0x1000
+#define NVM_WORD0F_ASM_DIR             0x2000
+#define NVM_WORD0F_ANE                 0x0800
+#define NVM_WORD0F_SWPDIO_EXT_MASK     0x00F0
+#define NVM_WORD0F_LPLU                        0x0001
+
+/* Mask bits for fields in Word 0x1a of the NVM */
+#define NVM_WORD1A_ASPM_MASK           0x000C
+
+/* Mask bits for fields in Word 0x03 of the EEPROM */
+#define NVM_COMPAT_LOM                 0x0800
+
+/* length of string needed to store PBA number */
+#define E1000_PBANUM_LENGTH            11
+
+/* For checksumming, the sum of all words in the NVM should equal 0xBABA. */
+#define NVM_SUM                                0xBABA
+
+#define NVM_MAC_ADDR_OFFSET            0
+#define NVM_PBA_OFFSET_0               8
+#define NVM_PBA_OFFSET_1               9
+#define NVM_PBA_PTR_GUARD              0xFAFA
+#define NVM_RESERVED_WORD              0xFFFF
+#define NVM_PHY_CLASS_A                        0x8000
+#define NVM_SERDES_AMPLITUDE_MASK      0x000F
+#define NVM_SIZE_MASK                  0x1C00
+#define NVM_SIZE_SHIFT                 10
+#define NVM_WORD_SIZE_BASE_SHIFT       6
+#define NVM_SWDPIO_EXT_SHIFT           4
+
+/* NVM Commands - SPI */
+#define NVM_MAX_RETRY_SPI      5000 /* Max wait of 5ms, for RDY signal */
+#define NVM_READ_OPCODE_SPI    0x03 /* NVM read opcode */
+#define NVM_WRITE_OPCODE_SPI   0x02 /* NVM write opcode */
+#define NVM_A8_OPCODE_SPI      0x08 /* opcode bit-3 = address bit-8 */
+#define NVM_WREN_OPCODE_SPI    0x06 /* NVM set Write Enable latch */
+#define NVM_WRDI_OPCODE_SPI    0x04 /* NVM reset Write Enable latch */
+#define NVM_RDSR_OPCODE_SPI    0x05 /* NVM read Status register */
+#define NVM_WRSR_OPCODE_SPI    0x01 /* NVM write Status register */
+
+/* SPI NVM Status Register */
+#define NVM_STATUS_RDY_SPI     0x01
+#define NVM_STATUS_WEN_SPI     0x02
+#define NVM_STATUS_BP0_SPI     0x04
+#define NVM_STATUS_BP1_SPI     0x08
+#define NVM_STATUS_WPEN_SPI    0x80
+
+/* Word definitions for ID LED Settings */
+#define ID_LED_RESERVED_0000   0x0000
+#define ID_LED_RESERVED_FFFF   0xFFFF
+#define ID_LED_DEFAULT         ((ID_LED_OFF1_ON2  << 12) | \
+                                (ID_LED_OFF1_OFF2 <<  8) | \
+                                (ID_LED_DEF1_DEF2 <<  4) | \
+                                (ID_LED_DEF1_DEF2))
+#define ID_LED_DEF1_DEF2       0x1
+#define ID_LED_DEF1_ON2                0x2
+#define ID_LED_DEF1_OFF2       0x3
+#define ID_LED_ON1_DEF2                0x4
+#define ID_LED_ON1_ON2         0x5
+#define ID_LED_ON1_OFF2                0x6
+#define ID_LED_OFF1_DEF2       0x7
+#define ID_LED_OFF1_ON2                0x8
+#define ID_LED_OFF1_OFF2       0x9
+
+#define IGP_ACTIVITY_LED_MASK  0xFFFFF0FF
+#define IGP_ACTIVITY_LED_ENABLE        0x0300
+#define IGP_LED3_MODE          0x07000000
+
+/* PCI/PCI-X/PCI-EX Config space */
+#define PCI_HEADER_TYPE_REGISTER       0x0E
+#define PCIE_LINK_STATUS               0x12
+#define PCIE_DEVICE_CONTROL2           0x28
+
+#define PCI_HEADER_TYPE_MULTIFUNC      0x80
+#define PCIE_LINK_WIDTH_MASK           0x3F0
+#define PCIE_LINK_WIDTH_SHIFT          4
+#define PCIE_LINK_SPEED_MASK           0x0F
+#define PCIE_LINK_SPEED_2500           0x01
+#define PCIE_LINK_SPEED_5000           0x02
+#define PCIE_DEVICE_CONTROL2_16ms      0x0005
+
+#ifndef ETH_ADDR_LEN
+#define ETH_ADDR_LEN                   6
+#endif
+
+#define PHY_REVISION_MASK              0xFFFFFFF0
+#define MAX_PHY_REG_ADDRESS            0x1F  /* 5 bit address bus (0-0x1F) */
+#define MAX_PHY_MULTI_PAGE_REG         0xF
+
+/* Bit definitions for valid PHY IDs. */
+/*
+ * I = Integrated
+ * E = External
+ */
+#define M88E1000_E_PHY_ID      0x01410C50
+#define M88E1000_I_PHY_ID      0x01410C30
+#define M88E1011_I_PHY_ID      0x01410C20
+#define IGP01E1000_I_PHY_ID    0x02A80380
+#define M88E1011_I_REV_4       0x04
+#define M88E1111_I_PHY_ID      0x01410CC0
+#define GG82563_E_PHY_ID       0x01410CA0
+#define IGP03E1000_E_PHY_ID    0x02A80390
+#define IFE_E_PHY_ID           0x02A80330
+#define IFE_PLUS_E_PHY_ID      0x02A80320
+#define IFE_C_E_PHY_ID         0x02A80310
+#define M88_VENDOR             0x0141
+
+/* M88E1000 Specific Registers */
+#define M88E1000_PHY_SPEC_CTRL         0x10  /* PHY Specific Control Reg */
+#define M88E1000_PHY_SPEC_STATUS       0x11  /* PHY Specific Status Reg */
+#define M88E1000_INT_ENABLE            0x12  /* Interrupt Enable Reg */
+#define M88E1000_INT_STATUS            0x13  /* Interrupt Status Reg */
+#define M88E1000_EXT_PHY_SPEC_CTRL     0x14  /* Extended PHY Specific Cntrl */
+#define M88E1000_RX_ERR_CNTR           0x15  /* Receive Error Counter */
+
+#define M88E1000_PHY_EXT_CTRL          0x1A  /* PHY extend control register */
+#define M88E1000_PHY_PAGE_SELECT       0x1D  /* Reg 29 for pg number setting */
+#define M88E1000_PHY_GEN_CONTROL       0x1E  /* meaning depends on reg 29 */
+#define M88E1000_PHY_VCO_REG_BIT8      0x100 /* Bits 8 & 11 are adjusted for */
+#define M88E1000_PHY_VCO_REG_BIT11     0x800 /* improved BER performance */
+
+/* M88E1000 PHY Specific Control Register */
+#define M88E1000_PSCR_JABBER_DISABLE   0x0001 /* 1=Jabber Function disabled */
+#define M88E1000_PSCR_POLARITY_REVERSAL        0x0002 /* 1=Polarity Reverse enabled */
+#define M88E1000_PSCR_SQE_TEST         0x0004 /* 1=SQE Test enabled */
+/* 1=CLK125 low, 0=CLK125 toggling */
+#define M88E1000_PSCR_CLK125_DISABLE   0x0010
+/* MDI Crossover Mode bits 6:5 Manual MDI configuration */
+#define M88E1000_PSCR_MDI_MANUAL_MODE  0x0000
+#define M88E1000_PSCR_MDIX_MANUAL_MODE 0x0020  /* Manual MDIX configuration */
+/* 1000BASE-T: Auto crossover, 100BASE-TX/10BASE-T: MDI Mode */
+#define M88E1000_PSCR_AUTO_X_1000T     0x0040
+/* Auto crossover enabled all speeds */
+#define M88E1000_PSCR_AUTO_X_MODE      0x0060
+/*
+ * 1=Enable Extended 10BASE-T distance (Lower 10BASE-T Rx Threshold
+ * 0=Normal 10BASE-T Rx Threshold
+ */
+#define M88E1000_PSCR_EN_10BT_EXT_DIST 0x0080
+/* 1=5-bit interface in 100BASE-TX, 0=MII interface in 100BASE-TX */
+#define M88E1000_PSCR_MII_5BIT_ENABLE  0x0100
+#define M88E1000_PSCR_SCRAMBLER_DISABLE        0x0200 /* 1=Scrambler disable */
+#define M88E1000_PSCR_FORCE_LINK_GOOD  0x0400 /* 1=Force link good */
+#define M88E1000_PSCR_ASSERT_CRS_ON_TX 0x0800 /* 1=Assert CRS on Tx */
+
+/* M88E1000 PHY Specific Status Register */
+#define M88E1000_PSSR_JABBER           0x0001 /* 1=Jabber */
+#define M88E1000_PSSR_REV_POLARITY     0x0002 /* 1=Polarity reversed */
+#define M88E1000_PSSR_DOWNSHIFT                0x0020 /* 1=Downshifted */
+#define M88E1000_PSSR_MDIX             0x0040 /* 1=MDIX; 0=MDI */
+/*
+ * 0 = <50M
+ * 1 = 50-80M
+ * 2 = 80-110M
+ * 3 = 110-140M
+ * 4 = >140M
+ */
+#define M88E1000_PSSR_CABLE_LENGTH     0x0380
+#define M88E1000_PSSR_LINK             0x0400 /* 1=Link up, 0=Link down */
+#define M88E1000_PSSR_SPD_DPLX_RESOLVED        0x0800 /* 1=Speed & Duplex resolved */
+#define M88E1000_PSSR_PAGE_RCVD                0x1000 /* 1=Page received */
+#define M88E1000_PSSR_DPLX             0x2000 /* 1=Duplex 0=Half Duplex */
+#define M88E1000_PSSR_SPEED            0xC000 /* Speed, bits 14:15 */
+#define M88E1000_PSSR_10MBS            0x0000 /* 00=10Mbs */
+#define M88E1000_PSSR_100MBS           0x4000 /* 01=100Mbs */
+#define M88E1000_PSSR_1000MBS          0x8000 /* 10=1000Mbs */
+
+#define M88E1000_PSSR_CABLE_LENGTH_SHIFT       7
+
+/* M88E1000 Extended PHY Specific Control Register */
+#define M88E1000_EPSCR_FIBER_LOOPBACK  0x4000 /* 1=Fiber loopback */
+/*
+ * 1 = Lost lock detect enabled.
+ * Will assert lost lock and bring
+ * link down if idle not seen
+ * within 1ms in 1000BASE-T
+ */
+#define M88E1000_EPSCR_DOWN_NO_IDLE    0x8000
+/*
+ * Number of times we will attempt to autonegotiate before downshifting if we
+ * are the master
+ */
+#define M88E1000_EPSCR_MASTER_DOWNSHIFT_MASK   0x0C00
+#define M88E1000_EPSCR_MASTER_DOWNSHIFT_1X     0x0000
+#define M88E1000_EPSCR_MASTER_DOWNSHIFT_2X     0x0400
+#define M88E1000_EPSCR_MASTER_DOWNSHIFT_3X     0x0800
+#define M88E1000_EPSCR_MASTER_DOWNSHIFT_4X     0x0C00
+/*
+ * Number of times we will attempt to autonegotiate before downshifting if we
+ * are the slave
+ */
+#define M88E1000_EPSCR_SLAVE_DOWNSHIFT_MASK    0x0300
+#define M88E1000_EPSCR_SLAVE_DOWNSHIFT_DIS     0x0000
+#define M88E1000_EPSCR_SLAVE_DOWNSHIFT_1X      0x0100
+#define M88E1000_EPSCR_SLAVE_DOWNSHIFT_2X      0x0200
+#define M88E1000_EPSCR_SLAVE_DOWNSHIFT_3X      0x0300
+#define M88E1000_EPSCR_TX_CLK_2_5      0x0060 /* 2.5 MHz TX_CLK */
+#define M88E1000_EPSCR_TX_CLK_25       0x0070 /* 25  MHz TX_CLK */
+#define M88E1000_EPSCR_TX_CLK_0                0x0000 /* NO  TX_CLK */
+
+/* M88E1111 Specific Registers */
+#define M88E1111_PHY_PAGE_SELECT1      0x16  /* for registers 0-28 */
+#define M88E1111_PHY_PAGE_SELECT2      0x1D  /* for registers 30-31 */
+
+/* M88E1111 page select register mask */
+#define M88E1111_PHY_PAGE_SELECT_MASK1 0xFF
+#define M88E1111_PHY_PAGE_SELECT_MASK2 0x3F
+
+
+/* M88EC018 Rev 2 specific DownShift settings */
+#define M88EC018_EPSCR_DOWNSHIFT_COUNTER_MASK  0x0E00
+#define M88EC018_EPSCR_DOWNSHIFT_COUNTER_1X    0x0000
+#define M88EC018_EPSCR_DOWNSHIFT_COUNTER_2X    0x0200
+#define M88EC018_EPSCR_DOWNSHIFT_COUNTER_3X    0x0400
+#define M88EC018_EPSCR_DOWNSHIFT_COUNTER_4X    0x0600
+#define M88EC018_EPSCR_DOWNSHIFT_COUNTER_5X    0x0800
+#define M88EC018_EPSCR_DOWNSHIFT_COUNTER_6X    0x0A00
+#define M88EC018_EPSCR_DOWNSHIFT_COUNTER_7X    0x0C00
+#define M88EC018_EPSCR_DOWNSHIFT_COUNTER_8X    0x0E00
+
+/*
+ * Bits...
+ * 15-5: page
+ * 4-0: register offset
+ */
+#define GG82563_PAGE_SHIFT     5
+#define GG82563_REG(page, reg) \
+       (((page) << GG82563_PAGE_SHIFT) | ((reg) & MAX_PHY_REG_ADDRESS))
+#define GG82563_MIN_ALT_REG    30
+
+/* GG82563 Specific Registers */
+#define GG82563_PHY_SPEC_CTRL          GG82563_REG(0, 16) /* PHY Spec Cntrl */
+#define GG82563_PHY_SPEC_STATUS                GG82563_REG(0, 17) /* PHY Spec Status */
+#define GG82563_PHY_INT_ENABLE         GG82563_REG(0, 18) /* Interrupt Ena */
+#define GG82563_PHY_SPEC_STATUS_2      GG82563_REG(0, 19) /* PHY Spec Stat2 */
+#define GG82563_PHY_RX_ERR_CNTR                GG82563_REG(0, 21) /* Rx Err Counter */
+#define GG82563_PHY_PAGE_SELECT                GG82563_REG(0, 22) /* Page Select */
+#define GG82563_PHY_SPEC_CTRL_2                GG82563_REG(0, 26) /* PHY Spec Cntrl2 */
+#define GG82563_PHY_PAGE_SELECT_ALT    GG82563_REG(0, 29) /* Alt Page Select */
+/* Test Clock Control (use reg. 29 to select) */
+#define GG82563_PHY_TEST_CLK_CTRL      GG82563_REG(0, 30)
+
+/* MAC Specific Control Register */
+#define GG82563_PHY_MAC_SPEC_CTRL      GG82563_REG(2, 21)
+#define GG82563_PHY_MAC_SPEC_CTRL_2    GG82563_REG(2, 26) /* MAC Spec Ctrl 2 */
+
+#define GG82563_PHY_DSP_DISTANCE       GG82563_REG(5, 26) /* DSP Distance */
+
+/* Page 193 - Port Control Registers */
+/* Kumeran Mode Control */
+#define GG82563_PHY_KMRN_MODE_CTRL     GG82563_REG(193, 16)
+#define GG82563_PHY_PORT_RESET         GG82563_REG(193, 17) /* Port Reset */
+#define GG82563_PHY_REVISION_ID                GG82563_REG(193, 18) /* Revision ID */
+#define GG82563_PHY_DEVICE_ID          GG82563_REG(193, 19) /* Device ID */
+#define GG82563_PHY_PWR_MGMT_CTRL      GG82563_REG(193, 20) /* Pwr Mgt Ctrl */
+/* Rate Adaptation Control */
+#define GG82563_PHY_RATE_ADAPT_CTRL    GG82563_REG(193, 25)
+
+/* Page 194 - KMRN Registers */
+/* FIFO's Control/Status */
+#define GG82563_PHY_KMRN_FIFO_CTRL_STAT        GG82563_REG(194, 16)
+#define GG82563_PHY_KMRN_CTRL          GG82563_REG(194, 17) /* Control */
+#define GG82563_PHY_INBAND_CTRL                GG82563_REG(194, 18) /* Inband Ctrl */
+#define GG82563_PHY_KMRN_DIAGNOSTIC    GG82563_REG(194, 19) /* Diagnostic */
+#define GG82563_PHY_ACK_TIMEOUTS       GG82563_REG(194, 20) /* Ack Timeouts */
+#define GG82563_PHY_ADV_ABILITY                GG82563_REG(194, 21) /* Adver Ability */
+/* Link Partner Advertised Ability */
+#define GG82563_PHY_LINK_PARTNER_ADV_ABILITY   GG82563_REG(194, 23)
+#define GG82563_PHY_ADV_NEXT_PAGE      GG82563_REG(194, 24) /* Adver Next Pg */
+/* Link Partner Advertised Next page */
+#define GG82563_PHY_LINK_PARTNER_ADV_NEXT_PAGE GG82563_REG(194, 25)
+#define GG82563_PHY_KMRN_MISC          GG82563_REG(194, 26) /* Misc. */
+
+/* MDI Control */
+#define E1000_MDIC_DATA_MASK   0x0000FFFF
+#define E1000_MDIC_REG_MASK    0x001F0000
+#define E1000_MDIC_REG_SHIFT   16
+#define E1000_MDIC_PHY_MASK    0x03E00000
+#define E1000_MDIC_PHY_SHIFT   21
+#define E1000_MDIC_OP_WRITE    0x04000000
+#define E1000_MDIC_OP_READ     0x08000000
+#define E1000_MDIC_READY       0x10000000
+#define E1000_MDIC_INT_EN      0x20000000
+#define E1000_MDIC_ERROR       0x40000000
+#define E1000_MDIC_DEST                0x80000000
+
+/* SerDes Control */
+#define E1000_GEN_CTL_READY            0x80000000
+#define E1000_GEN_CTL_ADDRESS_SHIFT    8
+#define E1000_GEN_POLL_TIMEOUT         640
+
+
+#endif /* _E1000_DEFINES_H_ */
similarity index 72%
rename from drivers/net/igbvf/mbx.c
rename to drivers/net/igbvf/e1000_mbx.c
index a1dc0a8ae5ffa9d7b73d1e28d96b20cec0a02b18..09f4db98960865dff814bd8fc8e7aca961ded2a6 100644 (file)
@@ -1,7 +1,7 @@
 /*******************************************************************************
 
   Intel(R) 82576 Virtual Function Linux driver
-  Copyright(c) 2009 - 2012 Intel Corporation.
+  Copyright(c) 1999 - 2012 Intel Corporation.
 
   This program is free software; you can redistribute it and/or modify it
   under the terms and conditions of the GNU General Public License,
   the file called "COPYING".
 
   Contact Information:
+  Linux NICS <linux.nics@intel.com>
   e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
   Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
 
 *******************************************************************************/
 
-#include "mbx.h"
+#include "e1000_mbx.h"
 
 /**
  *  e1000_poll_for_msg - Wait for message notification
  *  @hw: pointer to the HW structure
+ *  @mbx_id: id of mailbox to write
  *
  *  returns SUCCESS if it successfully received a message notification
  **/
-static s32 e1000_poll_for_msg(struct e1000_hw *hw)
+static s32 e1000_poll_for_msg(struct e1000_hw *hw, u16 mbx_id)
 {
        struct e1000_mbx_info *mbx = &hw->mbx;
        int countdown = mbx->timeout;
 
-       if (!mbx->ops.check_for_msg)
+       DEBUGFUNC("e1000_poll_for_msg");
+
+       if (!countdown || !mbx->ops.check_for_msg)
                goto out;
 
-       while (countdown && mbx->ops.check_for_msg(hw)) {
+       while (countdown && mbx->ops.check_for_msg(hw, mbx_id)) {
                countdown--;
-               udelay(mbx->usec_delay);
+               if (!countdown)
+                       break;
+               usec_delay(mbx->usec_delay);
        }
 
        /* if we failed, all future posted messages fail until reset */
@@ -56,20 +62,25 @@ out:
 /**
  *  e1000_poll_for_ack - Wait for message acknowledgement
  *  @hw: pointer to the HW structure
+ *  @mbx_id: id of mailbox to write
  *
  *  returns SUCCESS if it successfully received a message acknowledgement
  **/
-static s32 e1000_poll_for_ack(struct e1000_hw *hw)
+static s32 e1000_poll_for_ack(struct e1000_hw *hw, u16 mbx_id)
 {
        struct e1000_mbx_info *mbx = &hw->mbx;
        int countdown = mbx->timeout;
 
-       if (!mbx->ops.check_for_ack)
+       DEBUGFUNC("e1000_poll_for_ack");
+
+       if (!countdown || !mbx->ops.check_for_ack)
                goto out;
 
-       while (countdown && mbx->ops.check_for_ack(hw)) {
+       while (countdown && mbx->ops.check_for_ack(hw, mbx_id)) {
                countdown--;
-               udelay(mbx->usec_delay);
+               if (!countdown)
+                       break;
+               usec_delay(mbx->usec_delay);
        }
 
        /* if we failed, all future posted messages fail until reset */
@@ -84,23 +95,27 @@ out:
  *  @hw: pointer to the HW structure
  *  @msg: The message buffer
  *  @size: Length of buffer
+ *  @mbx_id: id of mailbox to write
  *
  *  returns SUCCESS if it successfully received a message notification and
  *  copied it into the receive buffer.
  **/
-static s32 e1000_read_posted_mbx(struct e1000_hw *hw, u32 *msg, u16 size)
+static s32 e1000_read_posted_mbx(struct e1000_hw *hw, u32 *msg, u16 size,
+                                u16 mbx_id)
 {
        struct e1000_mbx_info *mbx = &hw->mbx;
        s32 ret_val = -E1000_ERR_MBX;
 
+       DEBUGFUNC("e1000_read_posted_mbx");
+
        if (!mbx->ops.read)
                goto out;
 
-       ret_val = e1000_poll_for_msg(hw);
+       ret_val = e1000_poll_for_msg(hw, mbx_id);
 
        /* if ack received read message, otherwise we timed out */
        if (!ret_val)
-               ret_val = mbx->ops.read(hw, msg, size);
+               ret_val = mbx->ops.read(hw, msg, size, mbx_id);
 out:
        return ret_val;
 }
@@ -110,29 +125,46 @@ out:
  *  @hw: pointer to the HW structure
  *  @msg: The message buffer
  *  @size: Length of buffer
+ *  @mbx_id: id of mailbox to write
  *
  *  returns SUCCESS if it successfully copied message into the buffer and
  *  received an ack to that message within delay * timeout period
  **/
-static s32 e1000_write_posted_mbx(struct e1000_hw *hw, u32 *msg, u16 size)
+static s32 e1000_write_posted_mbx(struct e1000_hw *hw, u32 *msg, u16 size,
+                                 u16 mbx_id)
 {
        struct e1000_mbx_info *mbx = &hw->mbx;
        s32 ret_val = -E1000_ERR_MBX;
 
-       /* exit if we either can't write or there isn't a defined timeout */
+       DEBUGFUNC("e1000_write_posted_mbx");
+
+       /* exit if either we can't write or there isn't a defined timeout */
        if (!mbx->ops.write || !mbx->timeout)
                goto out;
 
-       /* send msg*/
-       ret_val = mbx->ops.write(hw, msg, size);
+       /* send msg */
+       ret_val = mbx->ops.write(hw, msg, size, mbx_id);
 
        /* if msg sent wait until we receive an ack */
        if (!ret_val)
-               ret_val = e1000_poll_for_ack(hw);
+               ret_val = e1000_poll_for_ack(hw, mbx_id);
 out:
        return ret_val;
 }
 
+/**
+ *  e1000_init_mbx_ops_generic - Initialize mbx function pointers
+ *  @hw: pointer to the HW structure
+ *
+ *  Sets the function pointers to no-op functions
+ **/
+void e1000_init_mbx_ops_generic(struct e1000_hw *hw)
+{
+       struct e1000_mbx_info *mbx = &hw->mbx;
+       mbx->ops.read_posted = e1000_read_posted_mbx;
+       mbx->ops.write_posted = e1000_write_posted_mbx;
+}
+
 /**
  *  e1000_read_v2p_mailbox - read v2p mailbox
  *  @hw: pointer to the HW structure
@@ -142,7 +174,7 @@ out:
  **/
 static u32 e1000_read_v2p_mailbox(struct e1000_hw *hw)
 {
-       u32 v2p_mailbox = er32(V2PMAILBOX(0));
+       u32 v2p_mailbox = E1000_READ_REG(hw, E1000_V2PMAILBOX(0));
 
        v2p_mailbox |= hw->dev_spec.vf.v2p_mailbox;
        hw->dev_spec.vf.v2p_mailbox |= v2p_mailbox & E1000_V2PMAILBOX_R2C_BITS;
@@ -174,13 +206,16 @@ static s32 e1000_check_for_bit_vf(struct e1000_hw *hw, u32 mask)
 /**
  *  e1000_check_for_msg_vf - checks to see if the PF has sent mail
  *  @hw: pointer to the HW structure
+ *  @mbx_id: id of mailbox to check
  *
  *  returns SUCCESS if the PF has set the Status bit or else ERR_MBX
  **/
-static s32 e1000_check_for_msg_vf(struct e1000_hw *hw)
+static s32 e1000_check_for_msg_vf(struct e1000_hw *hw, u16 mbx_id)
 {
        s32 ret_val = -E1000_ERR_MBX;
 
+       DEBUGFUNC("e1000_check_for_msg_vf");
+
        if (!e1000_check_for_bit_vf(hw, E1000_V2PMAILBOX_PFSTS)) {
                ret_val = E1000_SUCCESS;
                hw->mbx.stats.reqs++;
@@ -192,13 +227,16 @@ static s32 e1000_check_for_msg_vf(struct e1000_hw *hw)
 /**
  *  e1000_check_for_ack_vf - checks to see if the PF has ACK'd
  *  @hw: pointer to the HW structure
+ *  @mbx_id: id of mailbox to check
  *
  *  returns SUCCESS if the PF has set the ACK bit or else ERR_MBX
  **/
-static s32 e1000_check_for_ack_vf(struct e1000_hw *hw)
+static s32 e1000_check_for_ack_vf(struct e1000_hw *hw, u16 mbx_id)
 {
        s32 ret_val = -E1000_ERR_MBX;
 
+       DEBUGFUNC("e1000_check_for_ack_vf");
+
        if (!e1000_check_for_bit_vf(hw, E1000_V2PMAILBOX_PFACK)) {
                ret_val = E1000_SUCCESS;
                hw->mbx.stats.acks++;
@@ -210,15 +248,18 @@ static s32 e1000_check_for_ack_vf(struct e1000_hw *hw)
 /**
  *  e1000_check_for_rst_vf - checks to see if the PF has reset
  *  @hw: pointer to the HW structure
+ *  @mbx_id: id of mailbox to check
  *
  *  returns true if the PF has set the reset done bit or else false
  **/
-static s32 e1000_check_for_rst_vf(struct e1000_hw *hw)
+static s32 e1000_check_for_rst_vf(struct e1000_hw *hw, u16 mbx_id)
 {
        s32 ret_val = -E1000_ERR_MBX;
 
+       DEBUGFUNC("e1000_check_for_rst_vf");
+
        if (!e1000_check_for_bit_vf(hw, (E1000_V2PMAILBOX_RSTD |
-                                        E1000_V2PMAILBOX_RSTI))) {
+                                        E1000_V2PMAILBOX_RSTI))) {
                ret_val = E1000_SUCCESS;
                hw->mbx.stats.rsts++;
        }
@@ -236,8 +277,10 @@ static s32 e1000_obtain_mbx_lock_vf(struct e1000_hw *hw)
 {
        s32 ret_val = -E1000_ERR_MBX;
 
+       DEBUGFUNC("e1000_obtain_mbx_lock_vf");
+
        /* Take ownership of the buffer */
-       ew32(V2PMAILBOX(0), E1000_V2PMAILBOX_VFU);
+       E1000_WRITE_REG(hw, E1000_V2PMAILBOX(0), E1000_V2PMAILBOX_VFU);
 
        /* reserve mailbox for vf use */
        if (e1000_read_v2p_mailbox(hw) & E1000_V2PMAILBOX_VFU)
@@ -251,35 +294,40 @@ static s32 e1000_obtain_mbx_lock_vf(struct e1000_hw *hw)
  *  @hw: pointer to the HW structure
  *  @msg: The message buffer
  *  @size: Length of buffer
+ *  @mbx_id: id of mailbox to write
  *
  *  returns SUCCESS if it successfully copied message into the buffer
  **/
-static s32 e1000_write_mbx_vf(struct e1000_hw *hw, u32 *msg, u16 size)
+static s32 e1000_write_mbx_vf(struct e1000_hw *hw, u32 *msg, u16 size,
+                             u16 mbx_id)
 {
-       s32 err;
+       s32 ret_val;
        u16 i;
 
+
+       DEBUGFUNC("e1000_write_mbx_vf");
+
        /* lock the mailbox to prevent pf/vf race condition */
-       err = e1000_obtain_mbx_lock_vf(hw);
-       if (err)
+       ret_val = e1000_obtain_mbx_lock_vf(hw);
+       if (ret_val)
                goto out_no_write;
 
-       /* flush any ack or msg as we are going to overwrite mailbox */
-       e1000_check_for_ack_vf(hw);
-       e1000_check_for_msg_vf(hw);
+       /* flush msg and acks as we are overwriting the message buffer */
+       e1000_check_for_msg_vf(hw, 0);
+       e1000_check_for_ack_vf(hw, 0);
 
        /* copy the caller specified message to the mailbox memory buffer */
        for (i = 0; i < size; i++)
-               array_ew32(VMBMEM(0), i, msg[i]);
+               E1000_WRITE_REG_ARRAY(hw, E1000_VMBMEM(0), i, msg[i]);
 
        /* update stats */
        hw->mbx.stats.msgs_tx++;
 
        /* Drop VFU and interrupt the PF to tell it a message has been sent */
-       ew32(V2PMAILBOX(0), E1000_V2PMAILBOX_REQ);
+       E1000_WRITE_REG(hw, E1000_V2PMAILBOX(0), E1000_V2PMAILBOX_REQ);
 
 out_no_write:
-       return err;
+       return ret_val;
 }
 
 /**
@@ -287,31 +335,35 @@ out_no_write:
  *  @hw: pointer to the HW structure
  *  @msg: The message buffer
  *  @size: Length of buffer
+ *  @mbx_id: id of mailbox to read
  *
  *  returns SUCCESS if it successfuly read message from buffer
  **/
-static s32 e1000_read_mbx_vf(struct e1000_hw *hw, u32 *msg, u16 size)
+static s32 e1000_read_mbx_vf(struct e1000_hw *hw, u32 *msg, u16 size,
+                            u16 mbx_id)
 {
-       s32 err;
+       s32 ret_val = E1000_SUCCESS;
        u16 i;
 
+       DEBUGFUNC("e1000_read_mbx_vf");
+
        /* lock the mailbox to prevent pf/vf race condition */
-       err = e1000_obtain_mbx_lock_vf(hw);
-       if (err)
+       ret_val = e1000_obtain_mbx_lock_vf(hw);
+       if (ret_val)
                goto out_no_read;
 
        /* copy the message from the mailbox memory buffer */
        for (i = 0; i < size; i++)
-               msg[i] = array_er32(VMBMEM(0), i);
+               msg[i] = E1000_READ_REG_ARRAY(hw, E1000_VMBMEM(0), i);
 
        /* Acknowledge receipt and release mailbox, then we're done */
-       ew32(V2PMAILBOX(0), E1000_V2PMAILBOX_ACK);
+       E1000_WRITE_REG(hw, E1000_V2PMAILBOX(0), E1000_V2PMAILBOX_ACK);
 
        /* update stats */
        hw->mbx.stats.msgs_rx++;
 
 out_no_read:
-       return err;
+       return ret_val;
 }
 
 /**
@@ -325,7 +377,7 @@ s32 e1000_init_mbx_params_vf(struct e1000_hw *hw)
        struct e1000_mbx_info *mbx = &hw->mbx;
 
        /* start mailbox as timed out and let the reset_hw call set the timeout
-        * value to being communications */
+        * value to begin communications */
        mbx->timeout = 0;
        mbx->usec_delay = E1000_VF_MBX_INIT_DELAY;
 
diff --git a/drivers/net/igbvf/e1000_mbx.h b/drivers/net/igbvf/e1000_mbx.h
new file mode 100644 (file)
index 0000000..d3e713c
--- /dev/null
@@ -0,0 +1,85 @@
+/*******************************************************************************
+
+  Intel(R) 82576 Virtual Function Linux driver
+  Copyright(c) 1999 - 2012 Intel Corporation.
+
+  This program is free software; you can redistribute it and/or modify it
+  under the terms and conditions of the GNU General Public License,
+  version 2, as published by the Free Software Foundation.
+
+  This program is distributed in the hope it will be useful, but WITHOUT
+  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+  more details.
+
+  You should have received a copy of the GNU General Public License along with
+  this program; if not, write to the Free Software Foundation, Inc.,
+  51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
+
+  The full GNU General Public License is included in this distribution in
+  the file called "COPYING".
+
+  Contact Information:
+  Linux NICS <linux.nics@intel.com>
+  e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
+  Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
+
+*******************************************************************************/
+
+#ifndef _E1000_MBX_H_
+#define _E1000_MBX_H_
+
+#include "e1000_vf.h"
+
+/* Define mailbox specific registers */
+#define E1000_V2PMAILBOX(_n)   (0x00C40 + (4 * (_n)))
+#define E1000_VMBMEM(_n)       (0x00800 + (64 * (_n)))
+
+/* Define mailbox register bits */
+#define E1000_V2PMAILBOX_REQ   0x00000001 /* Request for PF Ready bit */
+#define E1000_V2PMAILBOX_ACK   0x00000002 /* Ack PF message received */
+#define E1000_V2PMAILBOX_VFU   0x00000004 /* VF owns the mailbox buffer */
+#define E1000_V2PMAILBOX_PFU   0x00000008 /* PF owns the mailbox buffer */
+#define E1000_V2PMAILBOX_PFSTS 0x00000010 /* PF wrote a message in the MB */
+#define E1000_V2PMAILBOX_PFACK 0x00000020 /* PF ack the previous VF msg */
+#define E1000_V2PMAILBOX_RSTI  0x00000040 /* PF has reset indication */
+#define E1000_V2PMAILBOX_RSTD  0x00000080 /* PF has indicated reset done */
+#define E1000_V2PMAILBOX_R2C_BITS 0x000000B0 /* All read to clear bits */
+
+#define E1000_VFMAILBOX_SIZE   16 /* 16 32 bit words - 64 bytes */
+
+/* If it's a E1000_VF_* msg then it originates in the VF and is sent to the
+ * PF.  The reverse is true if it is E1000_PF_*.
+ * Message ACK's are the value or'd with 0xF0000000
+ */
+/* Msgs below or'd with this are the ACK */
+#define E1000_VT_MSGTYPE_ACK   0x80000000
+/* Msgs below or'd with this are the NACK */
+#define E1000_VT_MSGTYPE_NACK  0x40000000
+/* Indicates that VF is still clear to send requests */
+#define E1000_VT_MSGTYPE_CTS   0x20000000
+#define E1000_VT_MSGINFO_SHIFT 16
+/* bits 23:16 are used for extra info for certain messages */
+#define E1000_VT_MSGINFO_MASK  (0xFF << E1000_VT_MSGINFO_SHIFT)
+
+#define E1000_VF_RESET                 0x01 /* VF requests reset */
+#define E1000_VF_SET_MAC_ADDR          0x02 /* VF requests to set MAC addr */
+#define E1000_VF_SET_MULTICAST         0x03 /* VF requests to set MC addr */
+#define E1000_VF_SET_MULTICAST_COUNT_MASK (0x1F << E1000_VT_MSGINFO_SHIFT)
+#define E1000_VF_SET_MULTICAST_OVERFLOW        (0x80 << E1000_VT_MSGINFO_SHIFT)
+#define E1000_VF_SET_VLAN              0x04 /* VF requests to set VLAN */
+#define E1000_VF_SET_VLAN_ADD          (0x01 << E1000_VT_MSGINFO_SHIFT)
+#define E1000_VF_SET_LPE               0x05 /* reqs to set VMOLR.LPE */
+#define E1000_VF_SET_PROMISC           0x06 /* reqs to clear VMOLR.ROPE/MPME*/
+#define E1000_VF_SET_PROMISC_UNICAST   (0x01 << E1000_VT_MSGINFO_SHIFT)
+#define E1000_VF_SET_PROMISC_MULTICAST (0x02 << E1000_VT_MSGINFO_SHIFT)
+
+#define E1000_PF_CONTROL_MSG           0x0100 /* PF control message */
+
+#define E1000_VF_MBX_INIT_TIMEOUT      2000 /* number of retries on mailbox */
+#define E1000_VF_MBX_INIT_DELAY                500  /* microseconds between retries */
+
+void e1000_init_mbx_ops_generic(struct e1000_hw *hw);
+s32 e1000_init_mbx_params_vf(struct e1000_hw *);
+
+#endif /* _E1000_MBX_H_ */
diff --git a/drivers/net/igbvf/e1000_osdep.h b/drivers/net/igbvf/e1000_osdep.h
new file mode 100644 (file)
index 0000000..1c4a79f
--- /dev/null
@@ -0,0 +1,116 @@
+/*******************************************************************************
+
+  Intel(R) 82576 Virtual Function Linux driver
+  Copyright(c) 1999 - 2012 Intel Corporation.
+
+  This program is free software; you can redistribute it and/or modify it
+  under the terms and conditions of the GNU General Public License,
+  version 2, as published by the Free Software Foundation.
+
+  This program is distributed in the hope it will be useful, but WITHOUT
+  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+  more details.
+
+  You should have received a copy of the GNU General Public License along with
+  this program; if not, write to the Free Software Foundation, Inc.,
+  51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
+
+  The full GNU General Public License is included in this distribution in
+  the file called "COPYING".
+
+  Contact Information:
+  Linux NICS <linux.nics@intel.com>
+  e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
+  Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
+
+*******************************************************************************/
+
+
+/* glue for the OS-dependent part of igbvf
+ * includes register access macros
+ */
+
+#ifndef _E1000_OSDEP_H_
+#define _E1000_OSDEP_H_
+
+#include <linux/pci.h>
+#include <linux/delay.h>
+#include <linux/interrupt.h>
+#include <linux/if_ether.h>
+
+#include "kcompat.h"
+
+#define usec_delay(x) udelay(x)
+#ifndef msec_delay
+#define msec_delay(x)  do { if(in_interrupt()) { \
+                               /* Don't sleep in interrupt context! */ \
+                               BUG(); \
+                       } else { \
+                               msleep(x); \
+                       } } while (0)
+
+/* Some workarounds require millisecond delays and are run during interrupt
+ * context.  Most notably, when establishing link, the phy may need tweaking
+ * but cannot process phy register reads/writes faster than millisecond
+ * intervals...and we establish link due to a "link status change" interrupt.
+ */
+#define msec_delay_irq(x) mdelay(x)
+#endif
+
+#define PCI_COMMAND_REGISTER   PCI_COMMAND
+#define CMD_MEM_WRT_INVALIDATE PCI_COMMAND_INVALIDATE
+#define ETH_ADDR_LEN           ETH_ALEN
+
+
+#define DEBUGOUT(S)
+#define DEBUGOUT1(S, A...)
+
+#define DEBUGFUNC(F) DEBUGOUT(F "\n")
+#define DEBUGOUT2 DEBUGOUT1
+#define DEBUGOUT3 DEBUGOUT2
+#define DEBUGOUT7 DEBUGOUT3
+
+#define E1000_WRITE_REG(a, reg, value) ( \
+    writel((value), ((a)->hw_addr + reg)))
+
+#define E1000_READ_REG(a, reg) (readl((a)->hw_addr + reg))
+
+#define E1000_WRITE_REG_ARRAY(a, reg, offset, value) ( \
+    writel((value), ((a)->hw_addr + reg + ((offset) << 2))))
+
+#define E1000_READ_REG_ARRAY(a, reg, offset) ( \
+    readl((a)->hw_addr + reg + ((offset) << 2)))
+
+#define E1000_READ_REG_ARRAY_DWORD E1000_READ_REG_ARRAY
+#define E1000_WRITE_REG_ARRAY_DWORD E1000_WRITE_REG_ARRAY
+
+#define E1000_WRITE_REG_ARRAY_WORD(a, reg, offset, value) ( \
+    writew((value), ((a)->hw_addr + reg + ((offset) << 1))))
+
+#define E1000_READ_REG_ARRAY_WORD(a, reg, offset) ( \
+    readw((a)->hw_addr + reg + ((offset) << 1)))
+
+#define E1000_WRITE_REG_ARRAY_BYTE(a, reg, offset, value) ( \
+    writeb((value), ((a)->hw_addr + reg + (offset))))
+
+#define E1000_READ_REG_ARRAY_BYTE(a, reg, offset) ( \
+    readb((a)->hw_addr + reg + (offset)))
+
+#define E1000_WRITE_REG_IO(a, reg, offset) do { \
+    outl(reg, ((a)->io_base));                  \
+    outl(offset, ((a)->io_base + 4));      } while(0)
+
+#define E1000_WRITE_FLUSH(a) E1000_READ_REG(a, E1000_STATUS)
+
+#define E1000_WRITE_FLASH_REG(a, reg, value) ( \
+    writel((value), ((a)->flash_address + reg)))
+
+#define E1000_WRITE_FLASH_REG16(a, reg, value) ( \
+    writew((value), ((a)->flash_address + reg)))
+
+#define E1000_READ_FLASH_REG(a, reg) (readl((a)->flash_address + reg))
+
+#define E1000_READ_FLASH_REG16(a, reg) (readw((a)->flash_address + reg))
+
+#endif /* _E1000_OSDEP_H_ */
diff --git a/drivers/net/igbvf/e1000_regs.h b/drivers/net/igbvf/e1000_regs.h
new file mode 100644 (file)
index 0000000..82a0f9f
--- /dev/null
@@ -0,0 +1,360 @@
+/*******************************************************************************
+
+  Intel(R) 82576 Virtual Function Linux driver
+  Copyright(c) 1999 - 2012 Intel Corporation.
+
+  This program is free software; you can redistribute it and/or modify it
+  under the terms and conditions of the GNU General Public License,
+  version 2, as published by the Free Software Foundation.
+
+  This program is distributed in the hope it will be useful, but WITHOUT
+  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+  more details.
+
+  You should have received a copy of the GNU General Public License along with
+  this program; if not, write to the Free Software Foundation, Inc.,
+  51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
+
+  The full GNU General Public License is included in this distribution in
+  the file called "COPYING".
+
+  Contact Information:
+  Linux NICS <linux.nics@intel.com>
+  e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
+  Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
+
+*******************************************************************************/
+
+#ifndef _E1000_REGS_H_
+#define _E1000_REGS_H_
+
+#define E1000_CTRL     0x00000  /* Device Control - RW */
+#define E1000_CTRL_DUP 0x00004  /* Device Control Duplicate (Shadow) - RW */
+#define E1000_STATUS   0x00008  /* Device Status - RO */
+#define E1000_EECD     0x00010  /* EEPROM/Flash Control - RW */
+#define E1000_EERD     0x00014  /* EEPROM Read - RW */
+#define E1000_CTRL_EXT 0x00018  /* Extended Device Control - RW */
+#define E1000_FLA      0x0001C  /* Flash Access - RW */
+#define E1000_MDIC     0x00020  /* MDI Control - RW */
+#define E1000_SCTL     0x00024  /* SerDes Control - RW */
+#define E1000_FCAL     0x00028  /* Flow Control Address Low - RW */
+#define E1000_FCAH     0x0002C  /* Flow Control Address High -RW */
+#define E1000_FEXT     0x0002C  /* Future Extended - RW */
+#define E1000_FEXTNVM4 0x00024  /* Future Extended NVM 4 - RW */
+#define E1000_FEXTNVM  0x00028  /* Future Extended NVM - RW */
+#define E1000_FCT      0x00030  /* Flow Control Type - RW */
+#define E1000_CONNSW   0x00034  /* Copper/Fiber switch control - RW */
+#define E1000_VET      0x00038  /* VLAN Ether Type - RW */
+#define E1000_ICR      0x000C0  /* Interrupt Cause Read - R/clr */
+#define E1000_ITR      0x000C4  /* Interrupt Throttling Rate - RW */
+#define E1000_ICS      0x000C8  /* Interrupt Cause Set - WO */
+#define E1000_IMS      0x000D0  /* Interrupt Mask Set - RW */
+#define E1000_IMC      0x000D8  /* Interrupt Mask Clear - WO */
+#define E1000_IAM      0x000E0  /* Interrupt Acknowledge Auto Mask */
+#define E1000_RCTL     0x00100  /* Rx Control - RW */
+#define E1000_FCTTV    0x00170  /* Flow Control Transmit Timer Value - RW */
+#define E1000_TXCW     0x00178  /* Tx Configuration Word - RW */
+#define E1000_RXCW     0x00180  /* Rx Configuration Word - RO */
+#define E1000_TCTL     0x00400  /* Tx Control - RW */
+#define E1000_TCTL_EXT 0x00404  /* Extended Tx Control - RW */
+#define E1000_TIPG     0x00410  /* Tx Inter-packet gap -RW */
+#define E1000_TBT      0x00448  /* Tx Burst Timer - RW */
+#define E1000_AIT      0x00458  /* Adaptive Interframe Spacing Throttle - RW */
+#define E1000_LEDCTL   0x00E00  /* LED Control - RW */
+#define E1000_EXTCNF_CTRL      0x00F00  /* Extended Configuration Control */
+#define E1000_EXTCNF_SIZE      0x00F08  /* Extended Configuration Size */
+#define E1000_PHY_CTRL 0x00F10  /* PHY Control Register in CSR */
+#define E1000_PBA      0x01000  /* Packet Buffer Allocation - RW */
+#define E1000_PBS      0x01008  /* Packet Buffer Size */
+#define E1000_EEMNGCTL 0x01010  /* MNG EEprom Control */
+#define E1000_EEARBC   0x01024  /* EEPROM Auto Read Bus Control */
+#define E1000_FLASHT   0x01028  /* FLASH Timer Register */
+#define E1000_EEWR     0x0102C  /* EEPROM Write Register - RW */
+#define E1000_FLSWCTL  0x01030  /* FLASH control register */
+#define E1000_FLSWDATA 0x01034  /* FLASH data register */
+#define E1000_FLSWCNT  0x01038  /* FLASH Access Counter */
+#define E1000_FLOP     0x0103C  /* FLASH Opcode Register */
+#define E1000_I2CCMD   0x01028  /* SFPI2C Command Register - RW */
+#define E1000_I2CPARAMS        0x0102C /* SFPI2C Parameters Register - RW */
+#define E1000_WDSTP    0x01040  /* Watchdog Setup - RW */
+#define E1000_SWDSTS   0x01044  /* SW Device Status - RW */
+#define E1000_FRTIMER  0x01048  /* Free Running Timer - RW */
+#define E1000_ERT      0x02008  /* Early Rx Threshold - RW */
+#define E1000_FCRTL    0x02160  /* Flow Control Receive Threshold Low - RW */
+#define E1000_FCRTH    0x02168  /* Flow Control Receive Threshold High - RW */
+#define E1000_PSRCTL   0x02170  /* Packet Split Receive Control - RW */
+#define E1000_RDFPCQ(_n)       (0x02430 + (0x4 * (_n)))
+#define E1000_PBRTH    0x02458  /* PB Rx Arbitration Threshold - RW */
+#define E1000_FCRTV    0x02460  /* Flow Control Refresh Timer Value - RW */
+/* Split and Replication Rx Control - RW */
+#define E1000_RDPUMB   0x025CC  /* DMA Rx Descriptor uC Mailbox - RW */
+#define E1000_RDPUAD   0x025D0  /* DMA Rx Descriptor uC Addr Command - RW */
+#define E1000_RDPUWD   0x025D4  /* DMA Rx Descriptor uC Data Write - RW */
+#define E1000_RDPURD   0x025D8  /* DMA Rx Descriptor uC Data Read - RW */
+#define E1000_RDPUCTL  0x025DC  /* DMA Rx Descriptor uC Control - RW */
+#define E1000_RDTR     0x02820  /* Rx Delay Timer - RW */
+#define E1000_RADV     0x0282C  /* Rx Interrupt Absolute Delay Timer - RW */
+/*
+ * Convenience macros
+ *
+ * Note: "_n" is the queue number of the register to be written to.
+ *
+ * Example usage:
+ * E1000_RDBAL_REG(current_rx_queue)
+ */
+#define E1000_RDBAL(_n)        ((_n) < 4 ? (0x02800 + ((_n) * 0x100)) : \
+                        (0x0C000 + ((_n) * 0x40)))
+#define E1000_RDBAH(_n)        ((_n) < 4 ? (0x02804 + ((_n) * 0x100)) : \
+                        (0x0C004 + ((_n) * 0x40)))
+#define E1000_RDLEN(_n)        ((_n) < 4 ? (0x02808 + ((_n) * 0x100)) : \
+                        (0x0C008 + ((_n) * 0x40)))
+#define E1000_SRRCTL(_n)       ((_n) < 4 ? (0x0280C + ((_n) * 0x100)) : \
+                                (0x0C00C + ((_n) * 0x40)))
+#define E1000_RDH(_n)  ((_n) < 4 ? (0x02810 + ((_n) * 0x100)) : \
+                        (0x0C010 + ((_n) * 0x40)))
+#define E1000_RXCTL(_n)        ((_n) < 4 ? (0x02814 + ((_n) * 0x100)) : \
+                        (0x0C014 + ((_n) * 0x40)))
+#define E1000_DCA_RXCTRL(_n)   E1000_RXCTL(_n)
+#define E1000_RDT(_n)  ((_n) < 4 ? (0x02818 + ((_n) * 0x100)) : \
+                        (0x0C018 + ((_n) * 0x40)))
+#define E1000_RXDCTL(_n)       ((_n) < 4 ? (0x02828 + ((_n) * 0x100)) : \
+                                (0x0C028 + ((_n) * 0x40)))
+#define E1000_RQDPC(_n)        ((_n) < 4 ? (0x02830 + ((_n) * 0x100)) : \
+                        (0x0C030 + ((_n) * 0x40)))
+#define E1000_TDBAL(_n)        ((_n) < 4 ? (0x03800 + ((_n) * 0x100)) : \
+                        (0x0E000 + ((_n) * 0x40)))
+#define E1000_TDBAH(_n)        ((_n) < 4 ? (0x03804 + ((_n) * 0x100)) : \
+                        (0x0E004 + ((_n) * 0x40)))
+#define E1000_TDLEN(_n)        ((_n) < 4 ? (0x03808 + ((_n) * 0x100)) : \
+                        (0x0E008 + ((_n) * 0x40)))
+#define E1000_TDH(_n)  ((_n) < 4 ? (0x03810 + ((_n) * 0x100)) : \
+                        (0x0E010 + ((_n) * 0x40)))
+#define E1000_TXCTL(_n)        ((_n) < 4 ? (0x03814 + ((_n) * 0x100)) : \
+                        (0x0E014 + ((_n) * 0x40)))
+#define E1000_DCA_TXCTRL(_n) E1000_TXCTL(_n)
+#define E1000_TDT(_n)  ((_n) < 4 ? (0x03818 + ((_n) * 0x100)) : \
+                        (0x0E018 + ((_n) * 0x40)))
+#define E1000_TXDCTL(_n)       ((_n) < 4 ? (0x03828 + ((_n) * 0x100)) : \
+                                (0x0E028 + ((_n) * 0x40)))
+#define E1000_TDWBAL(_n)       ((_n) < 4 ? (0x03838 + ((_n) * 0x100)) : \
+                                (0x0E038 + ((_n) * 0x40)))
+#define E1000_TDWBAH(_n)       ((_n) < 4 ? (0x0383C + ((_n) * 0x100)) : \
+                                (0x0E03C + ((_n) * 0x40)))
+#define E1000_TARC(_n)         (0x03840 + ((_n) * 0x100))
+#define E1000_RSRPD            0x02C00  /* Rx Small Packet Detect - RW */
+#define E1000_RAID             0x02C08  /* Receive Ack Interrupt Delay - RW */
+#define E1000_TXDMAC           0x03000  /* Tx DMA Control - RW */
+#define E1000_KABGTXD          0x03004  /* AFE Band Gap Transmit Ref Data */
+#define E1000_PSRTYPE(_i)      (0x05480 + ((_i) * 4))
+#define E1000_RAL(_i)          (((_i) <= 15) ? (0x05400 + ((_i) * 8)) : \
+                                (0x054E0 + ((_i - 16) * 8)))
+#define E1000_RAH(_i)          (((_i) <= 15) ? (0x05404 + ((_i) * 8)) : \
+                                (0x054E4 + ((_i - 16) * 8)))
+#define E1000_SHRAL(_i)                (0x05438 + ((_i) * 8))
+#define E1000_SHRAH(_i)                (0x0543C + ((_i) * 8))
+#define E1000_IP4AT_REG(_i)    (0x05840 + ((_i) * 8))
+#define E1000_IP6AT_REG(_i)    (0x05880 + ((_i) * 4))
+#define E1000_WUPM_REG(_i)     (0x05A00 + ((_i) * 4))
+#define E1000_FFMT_REG(_i)     (0x09000 + ((_i) * 8))
+#define E1000_FFVT_REG(_i)     (0x09800 + ((_i) * 8))
+#define E1000_FFLT_REG(_i)     (0x05F00 + ((_i) * 8))
+#define E1000_TDFH             0x03410  /* Tx Data FIFO Head - RW */
+#define E1000_TDFT             0x03418  /* Tx Data FIFO Tail - RW */
+#define E1000_TDFHS            0x03420  /* Tx Data FIFO Head Saved - RW */
+#define E1000_TDFTS            0x03428  /* Tx Data FIFO Tail Saved - RW */
+#define E1000_TDFPC            0x03430  /* Tx Data FIFO Packet Count - RW */
+#define E1000_TDPUMB           0x0357C  /* DMA Tx Desc uC Mail Box - RW */
+#define E1000_TDPUAD           0x03580  /* DMA Tx Desc uC Addr Command - RW */
+#define E1000_TDPUWD           0x03584  /* DMA Tx Desc uC Data Write - RW */
+#define E1000_TDPURD           0x03588  /* DMA Tx Desc uC Data  Read  - RW */
+#define E1000_TDPUCTL          0x0358C  /* DMA Tx Desc uC Control - RW */
+#define E1000_DTXCTL           0x03590  /* DMA Tx Control - RW */
+#define E1000_TIDV     0x03820  /* Tx Interrupt Delay Value - RW */
+#define E1000_TADV     0x0382C  /* Tx Interrupt Absolute Delay Val - RW */
+#define E1000_TSPMT    0x03830  /* TCP Segmentation PAD & Min Threshold - RW */
+#define E1000_CRCERRS  0x04000  /* CRC Error Count - R/clr */
+#define E1000_ALGNERRC 0x04004  /* Alignment Error Count - R/clr */
+#define E1000_SYMERRS  0x04008  /* Symbol Error Count - R/clr */
+#define E1000_RXERRC   0x0400C  /* Receive Error Count - R/clr */
+#define E1000_MPC      0x04010  /* Missed Packet Count - R/clr */
+#define E1000_SCC      0x04014  /* Single Collision Count - R/clr */
+#define E1000_ECOL     0x04018  /* Excessive Collision Count - R/clr */
+#define E1000_MCC      0x0401C  /* Multiple Collision Count - R/clr */
+#define E1000_LATECOL  0x04020  /* Late Collision Count - R/clr */
+#define E1000_COLC     0x04028  /* Collision Count - R/clr */
+#define E1000_DC       0x04030  /* Defer Count - R/clr */
+#define E1000_TNCRS    0x04034  /* Tx-No CRS - R/clr */
+#define E1000_SEC      0x04038  /* Sequence Error Count - R/clr */
+#define E1000_CEXTERR  0x0403C  /* Carrier Extension Error Count - R/clr */
+#define E1000_RLEC     0x04040  /* Receive Length Error Count - R/clr */
+#define E1000_XONRXC   0x04048  /* XON Rx Count - R/clr */
+#define E1000_XONTXC   0x0404C  /* XON Tx Count - R/clr */
+#define E1000_XOFFRXC  0x04050  /* XOFF Rx Count - R/clr */
+#define E1000_XOFFTXC  0x04054  /* XOFF Tx Count - R/clr */
+#define E1000_FCRUC    0x04058  /* Flow Control Rx Unsupported Count- R/clr */
+#define E1000_PRC64    0x0405C  /* Packets Rx (64 bytes) - R/clr */
+#define E1000_PRC127   0x04060  /* Packets Rx (65-127 bytes) - R/clr */
+#define E1000_PRC255   0x04064  /* Packets Rx (128-255 bytes) - R/clr */
+#define E1000_PRC511   0x04068  /* Packets Rx (255-511 bytes) - R/clr */
+#define E1000_PRC1023  0x0406C  /* Packets Rx (512-1023 bytes) - R/clr */
+#define E1000_PRC1522  0x04070  /* Packets Rx (1024-1522 bytes) - R/clr */
+#define E1000_GPRC     0x04074  /* Good Packets Rx Count - R/clr */
+#define E1000_BPRC     0x04078  /* Broadcast Packets Rx Count - R/clr */
+#define E1000_MPRC     0x0407C  /* Multicast Packets Rx Count - R/clr */
+#define E1000_GPTC     0x04080  /* Good Packets Tx Count - R/clr */
+#define E1000_GORCL    0x04088  /* Good Octets Rx Count Low - R/clr */
+#define E1000_GORCH    0x0408C  /* Good Octets Rx Count High - R/clr */
+#define E1000_GOTCL    0x04090  /* Good Octets Tx Count Low - R/clr */
+#define E1000_GOTCH    0x04094  /* Good Octets Tx Count High - R/clr */
+#define E1000_RNBC     0x040A0  /* Rx No Buffers Count - R/clr */
+#define E1000_RUC      0x040A4  /* Rx Undersize Count - R/clr */
+#define E1000_RFC      0x040A8  /* Rx Fragment Count - R/clr */
+#define E1000_ROC      0x040AC  /* Rx Oversize Count - R/clr */
+#define E1000_RJC      0x040B0  /* Rx Jabber Count - R/clr */
+#define E1000_MGTPRC   0x040B4  /* Management Packets Rx Count - R/clr */
+#define E1000_MGTPDC   0x040B8  /* Management Packets Dropped Count - R/clr */
+#define E1000_MGTPTC   0x040BC  /* Management Packets Tx Count - R/clr */
+#define E1000_TORL     0x040C0  /* Total Octets Rx Low - R/clr */
+#define E1000_TORH     0x040C4  /* Total Octets Rx High - R/clr */
+#define E1000_TOTL     0x040C8  /* Total Octets Tx Low - R/clr */
+#define E1000_TOTH     0x040CC  /* Total Octets Tx High - R/clr */
+#define E1000_TPR      0x040D0  /* Total Packets Rx - R/clr */
+#define E1000_TPT      0x040D4  /* Total Packets Tx - R/clr */
+#define E1000_PTC64    0x040D8  /* Packets Tx (64 bytes) - R/clr */
+#define E1000_PTC127   0x040DC  /* Packets Tx (65-127 bytes) - R/clr */
+#define E1000_PTC255   0x040E0  /* Packets Tx (128-255 bytes) - R/clr */
+#define E1000_PTC511   0x040E4  /* Packets Tx (256-511 bytes) - R/clr */
+#define E1000_PTC1023  0x040E8  /* Packets Tx (512-1023 bytes) - R/clr */
+#define E1000_PTC1522  0x040EC  /* Packets Tx (1024-1522 Bytes) - R/clr */
+#define E1000_MPTC     0x040F0  /* Multicast Packets Tx Count - R/clr */
+#define E1000_BPTC     0x040F4  /* Broadcast Packets Tx Count - R/clr */
+#define E1000_TSCTC    0x040F8  /* TCP Segmentation Context Tx - R/clr */
+#define E1000_TSCTFC   0x040FC  /* TCP Segmentation Context Tx Fail - R/clr */
+#define E1000_IAC      0x04100  /* Interrupt Assertion Count */
+#define E1000_ICRXPTC  0x04104  /* Interrupt Cause Rx Pkt Timer Expire Count */
+#define E1000_ICRXATC  0x04108  /* Interrupt Cause Rx Abs Timer Expire Count */
+#define E1000_ICTXPTC  0x0410C  /* Interrupt Cause Tx Pkt Timer Expire Count */
+#define E1000_ICTXATC  0x04110  /* Interrupt Cause Tx Abs Timer Expire Count */
+#define E1000_ICTXQEC  0x04118  /* Interrupt Cause Tx Queue Empty Count */
+#define E1000_ICTXQMTC 0x0411C  /* Interrupt Cause Tx Queue Min Thresh Count */
+#define E1000_ICRXDMTC 0x04120  /* Interrupt Cause Rx Desc Min Thresh Count */
+#define E1000_ICRXOC   0x04124  /* Interrupt Cause Receiver Overrun Count */
+
+#define E1000_VFGPRC   0x00F10
+#define E1000_VFGORC   0x00F18
+#define E1000_VFMPRC   0x00F3C
+#define E1000_VFGPTC   0x00F14
+#define E1000_VFGOTC   0x00F34
+#define E1000_VFGOTLBC 0x00F50
+#define E1000_VFGPTLBC 0x00F44
+#define E1000_VFGORLBC 0x00F48
+#define E1000_VFGPRLBC 0x00F40
+#define E1000_PCS_CFG0 0x04200  /* PCS Configuration 0 - RW */
+#define E1000_PCS_LCTL 0x04208  /* PCS Link Control - RW */
+#define E1000_PCS_LSTAT        0x0420C  /* PCS Link Status - RO */
+#define E1000_CBTMPC   0x0402C  /* Circuit Breaker Tx Packet Count */
+#define E1000_HTDPMC   0x0403C  /* Host Transmit Discarded Packets */
+#define E1000_CBRDPC   0x04044  /* Circuit Breaker Rx Dropped Count */
+#define E1000_CBRMPC   0x040FC  /* Circuit Breaker Rx Packet Count */
+#define E1000_RPTHC    0x04104  /* Rx Packets To Host */
+#define E1000_HGPTC    0x04118  /* Host Good Packets Tx Count */
+#define E1000_HTCBDPC  0x04124  /* Host Tx Circuit Breaker Dropped Count */
+#define E1000_HGORCL   0x04128  /* Host Good Octets Received Count Low */
+#define E1000_HGORCH   0x0412C  /* Host Good Octets Received Count High */
+#define E1000_HGOTCL   0x04130  /* Host Good Octets Transmit Count Low */
+#define E1000_HGOTCH   0x04134  /* Host Good Octets Transmit Count High */
+#define E1000_LENERRS  0x04138  /* Length Errors Count */
+#define E1000_SCVPC    0x04228  /* SerDes/SGMII Code Violation Pkt Count */
+#define E1000_HRMPC    0x0A018  /* Header Redirection Missed Packet Count */
+#define E1000_PCS_ANADV        0x04218  /* AN advertisement - RW */
+#define E1000_PCS_LPAB 0x0421C  /* Link Partner Ability - RW */
+#define E1000_PCS_NPTX 0x04220  /* AN Next Page Transmit - RW */
+#define E1000_PCS_LPABNP       0x04224 /* Link Partner Ability Next Pg - RW */
+#define E1000_1GSTAT_RCV       0x04228 /* 1GSTAT Code Violation Pkt Cnt - RW */
+#define E1000_RXCSUM   0x05000  /* Rx Checksum Control - RW */
+#define E1000_RLPML    0x05004  /* Rx Long Packet Max Length */
+#define E1000_RFCTL    0x05008  /* Receive Filter Control*/
+#define E1000_MTA      0x05200  /* Multicast Table Array - RW Array */
+#define E1000_RA       0x05400  /* Receive Address - RW Array */
+#define E1000_VFTA     0x05600  /* VLAN Filter Table Array - RW Array */
+#define E1000_VT_CTL   0x0581C  /* VMDq Control - RW */
+#define E1000_CIAA     0x05B88  /* Config Indirect Access Address - RW */
+#define E1000_CIAD     0x05B8C  /* Config Indirect Access Data - RW */
+#define E1000_VFQA0    0x0B000  /* VLAN Filter Queue Array 0 - RW Array */
+#define E1000_VFQA1    0x0B200  /* VLAN Filter Queue Array 1 - RW Array */
+#define E1000_WUC      0x05800  /* Wakeup Control - RW */
+#define E1000_WUFC     0x05808  /* Wakeup Filter Control - RW */
+#define E1000_WUS      0x05810  /* Wakeup Status - RO */
+#define E1000_MANC     0x05820  /* Management Control - RW */
+#define E1000_IPAV     0x05838  /* IP Address Valid - RW */
+#define E1000_IP4AT    0x05840  /* IPv4 Address Table - RW Array */
+#define E1000_IP6AT    0x05880  /* IPv6 Address Table - RW Array */
+#define E1000_WUPL     0x05900  /* Wakeup Packet Length - RW */
+#define E1000_WUPM     0x05A00  /* Wakeup Packet Memory - RO A */
+#define E1000_PBACL    0x05B68  /* MSIx PBA Clear - Read/Write 1's to clear */
+#define E1000_FFLT     0x05F00  /* Flexible Filter Length Table - RW Array */
+#define E1000_HOST_IF  0x08800  /* Host Interface */
+#define E1000_FFMT     0x09000  /* Flexible Filter Mask Table - RW Array */
+#define E1000_FFVT     0x09800  /* Flexible Filter Value Table - RW Array */
+
+#define E1000_KMRNCTRLSTA      0x00034 /* MAC-PHY interface - RW */
+#define E1000_MDPHYA           0x0003C /* PHY address - RW */
+#define E1000_MANC2H           0x05860 /* Management Control To Host - RW */
+/* Management Decision Filters */
+#define E1000_MDEF(_n)         (0x05890 + (4 * (_n)))
+#define E1000_SW_FW_SYNC       0x05B5C /* SW-FW Synchronization - RW */
+#define E1000_CCMCTL   0x05B48 /* CCM Control Register */
+#define E1000_GIOCTL   0x05B44 /* GIO Analog Control Register */
+#define E1000_SCCTL    0x05B4C /* PCIc PLL Configuration Register */
+#define E1000_GCR      0x05B00 /* PCI-Ex Control */
+#define E1000_GCR2     0x05B64 /* PCI-Ex Control #2 */
+#define E1000_GSCL_1   0x05B10 /* PCI-Ex Statistic Control #1 */
+#define E1000_GSCL_2   0x05B14 /* PCI-Ex Statistic Control #2 */
+#define E1000_GSCL_3   0x05B18 /* PCI-Ex Statistic Control #3 */
+#define E1000_GSCL_4   0x05B1C /* PCI-Ex Statistic Control #4 */
+#define E1000_FACTPS   0x05B30 /* Function Active and Power State to MNG */
+#define E1000_SWSM     0x05B50 /* SW Semaphore */
+#define E1000_FWSM     0x05B54 /* FW Semaphore */
+/* Driver-only SW semaphore (not used by BOOT agents) */
+#define E1000_SWSM2    0x05B58
+#define E1000_DCA_ID   0x05B70 /* DCA Requester ID Information - RO */
+#define E1000_DCA_CTRL 0x05B74 /* DCA Control - RW */
+#define E1000_FFLT_DBG 0x05F04 /* Debug Register */
+#define E1000_HICR     0x08F00 /* Host Interface Control */
+
+/* RSS registers */
+#define E1000_CPUVEC   0x02C10 /* CPU Vector Register - RW */
+#define E1000_MRQC     0x05818 /* Multiple Receive Control - RW */
+#define E1000_IMIR(_i) (0x05A80 + ((_i) * 4))  /* Immediate Interrupt */
+#define E1000_IMIREXT(_i)      (0x05AA0 + ((_i) * 4)) /* Immediate INTR Ext*/
+#define E1000_IMIRVP           0x05AC0 /* Immediate INT Rx VLAN Priority -RW */
+#define E1000_MSIXBM(_i)       (0x01600 + ((_i) * 4)) /* MSI-X Alloc Reg -RW */
+/* MSI-X Table entry addr low reg - RW */
+#define E1000_MSIXTADD(_i)     (0x0C000 + ((_i) * 0x10))
+/* MSI-X Table entry addr upper reg - RW */
+#define E1000_MSIXTUADD(_i)    (0x0C004 + ((_i) * 0x10))
+/* MSI-X Table entry message reg - RW */
+#define E1000_MSIXTMSG(_i)     (0x0C008 + ((_i) * 0x10))
+/* MSI-X Table entry vector ctrl reg - RW */
+#define E1000_MSIXVCTRL(_i)    (0x0C00C + ((_i) * 0x10))
+#define E1000_MSIXPBA  0x0E000 /* MSI-X Pending bit array */
+#define E1000_RETA(_i) (0x05C00 + ((_i) * 4)) /* Redirection Table - RW */
+#define E1000_RSSRK(_i)        (0x05C80 + ((_i) * 4)) /* RSS Random Key - RW */
+#define E1000_RSSIM    0x05864 /* RSS Interrupt Mask */
+#define E1000_RSSIR    0x05868 /* RSS Interrupt Request */
+#define E1000_TSYNCRXCTL       0x0B620 /* Rx Time Sync Control register - RW */
+#define E1000_TSYNCTXCTL       0x0B614 /* Tx Time Sync Control register - RW */
+#define E1000_TSYNCRXCFG       0x05F50 /* Time Sync Rx Configuration - RW */
+#define E1000_RXSTMPL  0x0B624 /* Rx timestamp Low - RO */
+#define E1000_RXSTMPH  0x0B628 /* Rx timestamp High - RO */
+#define E1000_RXSATRL  0x0B62C /* Rx timestamp attribute low - RO */
+#define E1000_RXSATRH  0x0B630 /* Rx timestamp attribute high - RO */
+#define E1000_TXSTMPL  0x0B618 /* Tx timestamp value Low - RO */
+#define E1000_TXSTMPH  0x0B61C /* Tx timestamp value High - RO */
+#define E1000_SYSTIML  0x0B600 /* System time register Low - RO */
+#define E1000_SYSTIMH  0x0B604 /* System time register High - RO */
+#define E1000_TIMINCA  0x0B608 /* Increment attributes register - RW */
+
+
+#endif
similarity index 68%
rename from drivers/net/igbvf/vf.c
rename to drivers/net/igbvf/e1000_vf.c
index 30a6cc426037db58b214aed762f635c496ea0ca3..e036661829561a5cf94c3f33ff94d121a79a7f8b 100644 (file)
@@ -1,7 +1,7 @@
 /*******************************************************************************
 
   Intel(R) 82576 Virtual Function Linux driver
-  Copyright(c) 2009 - 2012 Intel Corporation.
+  Copyright(c) 1999 - 2012 Intel Corporation.
 
   This program is free software; you can redistribute it and/or modify it
   under the terms and conditions of the GNU General Public License,
   the file called "COPYING".
 
   Contact Information:
+  Linux NICS <linux.nics@intel.com>
   e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
   Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
 
 *******************************************************************************/
 
 
-#include "vf.h"
+#include "e1000_vf.h"
 
+
+static s32 e1000_init_mac_params_vf(struct e1000_hw *hw);
 static s32 e1000_check_for_link_vf(struct e1000_hw *hw);
 static s32 e1000_get_link_up_info_vf(struct e1000_hw *hw, u16 *speed,
-                                     u16 *duplex);
+                                    u16 *duplex);
 static s32 e1000_init_hw_vf(struct e1000_hw *hw);
 static s32 e1000_reset_hw_vf(struct e1000_hw *hw);
-
-static void e1000_update_mc_addr_list_vf(struct e1000_hw *hw, u8 *,
-                                         u32, u32, u32);
+static void e1000_update_mc_addr_list_vf(struct e1000_hw *hw, u8 *, u32);
 static void e1000_rar_set_vf(struct e1000_hw *, u8 *, u32);
 static s32 e1000_read_mac_addr_vf(struct e1000_hw *);
-static s32 e1000_set_vfta_vf(struct e1000_hw *, u16, bool);
 
 /**
  *  e1000_init_mac_params_vf - Inits MAC params
@@ -48,6 +48,8 @@ static s32 e1000_init_mac_params_vf(struct e1000_hw *hw)
 {
        struct e1000_mac_info *mac = &hw->mac;
 
+       DEBUGFUNC("e1000_init_mac_params_vf");
+
        /* VF's have no MTA Registers - PF feature only */
        mac->mta_reg_count = 128;
        /* VF's have no access to RAR entries  */
@@ -68,8 +70,7 @@ static s32 e1000_init_mac_params_vf(struct e1000_hw *hw)
        mac->ops.rar_set = e1000_rar_set_vf;
        /* read mac address */
        mac->ops.read_mac_addr = e1000_read_mac_addr_vf;
-       /* set vlan filter table array */
-       mac->ops.set_vfta = e1000_set_vfta_vf;
+
 
        return E1000_SUCCESS;
 }
@@ -80,6 +81,8 @@ static s32 e1000_init_mac_params_vf(struct e1000_hw *hw)
  **/
 void e1000_init_function_pointers_vf(struct e1000_hw *hw)
 {
+       DEBUGFUNC("e1000_init_function_pointers_vf");
+
        hw->mac.ops.init_params = e1000_init_mac_params_vf;
        hw->mbx.ops.init_params = e1000_init_mbx_params_vf;
 }
@@ -94,22 +97,31 @@ void e1000_init_function_pointers_vf(struct e1000_hw *hw)
  *  the status register's data which is often stale and inaccurate.
  **/
 static s32 e1000_get_link_up_info_vf(struct e1000_hw *hw, u16 *speed,
-                                     u16 *duplex)
+                                    u16 *duplex)
 {
        s32 status;
 
-       status = er32(STATUS);
-       if (status & E1000_STATUS_SPEED_1000)
+       DEBUGFUNC("e1000_get_link_up_info_vf");
+
+       status = E1000_READ_REG(hw, E1000_STATUS);
+       if (status & E1000_STATUS_SPEED_1000) {
                *speed = SPEED_1000;
-       else if (status & E1000_STATUS_SPEED_100)
+               DEBUGOUT("1000 Mbs, ");
+       } else if (status & E1000_STATUS_SPEED_100) {
                *speed = SPEED_100;
-       else
+               DEBUGOUT("100 Mbs, ");
+       } else {
                *speed = SPEED_10;
+               DEBUGOUT("10 Mbs, ");
+       }
 
-       if (status & E1000_STATUS_FD)
+       if (status & E1000_STATUS_FD) {
                *duplex = FULL_DUPLEX;
-       else
+               DEBUGOUT("Full Duplex\n");
+       } else {
                *duplex = HALF_DUPLEX;
+               DEBUGOUT("Half Duplex\n");
+       }
 
        return E1000_SUCCESS;
 }
@@ -125,35 +137,36 @@ static s32 e1000_reset_hw_vf(struct e1000_hw *hw)
 {
        struct e1000_mbx_info *mbx = &hw->mbx;
        u32 timeout = E1000_VF_INIT_TIMEOUT;
-       u32 ret_val = -E1000_ERR_MAC_INIT;
-       u32 msgbuf[3];
+       s32 ret_val = -E1000_ERR_MAC_INIT;
+       u32 ctrl, msgbuf[3];
        u8 *addr = (u8 *)(&msgbuf[1]);
-       u32 ctrl;
 
-       /* assert vf queue/interrupt reset */
-       ctrl = er32(CTRL);
-       ew32(CTRL, ctrl | E1000_CTRL_RST);
+       DEBUGFUNC("e1000_reset_hw_vf");
+
+       DEBUGOUT("Issuing a function level reset to MAC\n");
+       ctrl = E1000_READ_REG(hw, E1000_CTRL);
+       E1000_WRITE_REG(hw, E1000_CTRL, ctrl | E1000_CTRL_RST);
 
-       /* we cannot initialize while the RSTI / RSTD bits are asserted */
-       while (!mbx->ops.check_for_rst(hw) && timeout) {
+       /* we cannot reset while the RSTI / RSTD bits are asserted */
+       while (!mbx->ops.check_for_rst(hw, 0) && timeout) {
                timeout--;
-               udelay(5);
+               usec_delay(5);
        }
 
        if (timeout) {
                /* mailbox timeout can now become active */
                mbx->timeout = E1000_VF_MBX_INIT_TIMEOUT;
 
-               /* notify pf of vf reset completion */
                msgbuf[0] = E1000_VF_RESET;
-               mbx->ops.write_posted(hw, msgbuf, 1);
+               mbx->ops.write_posted(hw, msgbuf, 1, 0);
 
-               msleep(10);
+               msec_delay(10);
 
                /* set our "perm_addr" based on info provided by PF */
-               ret_val = mbx->ops.read_posted(hw, msgbuf, 3);
+               ret_val = mbx->ops.read_posted(hw, msgbuf, 3, 0);
                if (!ret_val) {
-                       if (msgbuf[0] == (E1000_VF_RESET | E1000_VT_MSGTYPE_ACK))
+                       if (msgbuf[0] == (E1000_VF_RESET |
+                           E1000_VT_MSGTYPE_ACK))
                                memcpy(hw->mac.perm_addr, addr, 6);
                        else
                                ret_val = -E1000_ERR_MAC_INIT;
@@ -171,26 +184,58 @@ static s32 e1000_reset_hw_vf(struct e1000_hw *hw)
  **/
 static s32 e1000_init_hw_vf(struct e1000_hw *hw)
 {
+       DEBUGFUNC("e1000_init_hw_vf");
+
        /* attempt to set and restore our mac address */
        e1000_rar_set_vf(hw, hw->mac.addr, 0);
 
        return E1000_SUCCESS;
 }
 
+/**
+ *  e1000_rar_set_vf - set device MAC address
+ *  @hw: pointer to the HW structure
+ *  @addr: pointer to the receive address
+ *  @index receive address array register
+ **/
+static void e1000_rar_set_vf(struct e1000_hw *hw, u8 * addr, u32 index)
+{
+       struct e1000_mbx_info *mbx = &hw->mbx;
+       u32 msgbuf[3];
+       u8 *msg_addr = (u8 *)(&msgbuf[1]);
+       s32 ret_val;
+
+       memset(msgbuf, 0, 12);
+       msgbuf[0] = E1000_VF_SET_MAC_ADDR;
+       memcpy(msg_addr, addr, 6);
+       ret_val = mbx->ops.write_posted(hw, msgbuf, 3, 0);
+
+       if (!ret_val)
+               ret_val = mbx->ops.read_posted(hw, msgbuf, 3, 0);
+
+       msgbuf[0] &= ~E1000_VT_MSGTYPE_CTS;
+
+       /* if nacked the address was rejected, use "perm_addr" */
+       if (!ret_val &&
+           (msgbuf[0] == (E1000_VF_SET_MAC_ADDR | E1000_VT_MSGTYPE_NACK)))
+               e1000_read_mac_addr_vf(hw);
+}
+
 /**
  *  e1000_hash_mc_addr_vf - Generate a multicast hash value
  *  @hw: pointer to the HW structure
  *  @mc_addr: pointer to a multicast address
  *
  *  Generates a multicast address hash value which is used to determine
- *  the multicast filter table array address and new table value.  See
- *  e1000_mta_set_generic()
+ *  the multicast filter table array address and new table value.
  **/
 static u32 e1000_hash_mc_addr_vf(struct e1000_hw *hw, u8 *mc_addr)
 {
        u32 hash_value, hash_mask;
        u8 bit_shift = 0;
 
+       DEBUGFUNC("e1000_hash_mc_addr_generic");
+
        /* Register count multiplied by bits per register */
        hash_mask = (hw->mac.mta_reg_count * 32) - 1;
 
@@ -202,33 +247,40 @@ static u32 e1000_hash_mc_addr_vf(struct e1000_hw *hw, u8 *mc_addr)
                bit_shift++;
 
        hash_value = hash_mask & (((mc_addr[4] >> (8 - bit_shift)) |
-                                 (((u16) mc_addr[5]) << bit_shift)));
+                                 (((u16) mc_addr[5]) << bit_shift)));
 
        return hash_value;
 }
 
+static void e1000_write_msg_read_ack(struct e1000_hw *hw,
+                                    u32 *msg, u16 size)
+{
+       struct e1000_mbx_info *mbx = &hw->mbx;
+       u32 retmsg[E1000_VFMAILBOX_SIZE];
+       s32 retval = mbx->ops.write_posted(hw, msg, size, 0);
+
+       if (!retval)
+               mbx->ops.read_posted(hw, retmsg, E1000_VFMAILBOX_SIZE, 0);
+}
+
 /**
  *  e1000_update_mc_addr_list_vf - Update Multicast addresses
  *  @hw: pointer to the HW structure
  *  @mc_addr_list: array of multicast addresses to program
  *  @mc_addr_count: number of multicast addresses to program
- *  @rar_used_count: the first RAR register free to program
- *  @rar_count: total number of supported Receive Address Registers
  *
- *  Updates the Receive Address Registers and Multicast Table Array.
+ *  Updates the Multicast Table Array.
  *  The caller must have a packed mc_addr_list of multicast addresses.
- *  The parameter rar_count will usually be hw->mac.rar_entry_count
- *  unless there are workarounds that change this.
  **/
-static void e1000_update_mc_addr_list_vf(struct e1000_hw *hw,
-                                  u8 *mc_addr_list, u32 mc_addr_count,
-                                  u32 rar_used_count, u32 rar_count)
+void e1000_update_mc_addr_list_vf(struct e1000_hw *hw,
+                                 u8 *mc_addr_list, u32 mc_addr_count)
 {
-       struct e1000_mbx_info *mbx = &hw->mbx;
        u32 msgbuf[E1000_VFMAILBOX_SIZE];
        u16 *hash_list = (u16 *)&msgbuf[1];
        u32 hash_value;
-       u32 cnt, i;
+       u32 i;
+
+       DEBUGFUNC("e1000_update_mc_addr_list_vf");
 
        /* Each entry in the list uses 1 16 bit word.  We have 30
         * 16 bit words available in our HW msg buffer (minus 1 for the
@@ -239,48 +291,43 @@ static void e1000_update_mc_addr_list_vf(struct e1000_hw *hw,
         * addresses except for in large enterprise network environments.
         */
 
-       cnt = (mc_addr_count > 30) ? 30 : mc_addr_count;
+       DEBUGOUT1("MC Addr Count = %d\n", mc_addr_count);
+
+       if (mc_addr_count > 30) {
+               msgbuf[0] |= E1000_VF_SET_MULTICAST_OVERFLOW;
+               mc_addr_count = 30;
+       }
+
        msgbuf[0] = E1000_VF_SET_MULTICAST;
-       msgbuf[0] |= cnt << E1000_VT_MSGINFO_SHIFT;
+       msgbuf[0] |= mc_addr_count << E1000_VT_MSGINFO_SHIFT;
 
-       for (i = 0; i < cnt; i++) {
+       for (i = 0; i < mc_addr_count; i++) {
                hash_value = e1000_hash_mc_addr_vf(hw, mc_addr_list);
-               hash_list[i] = hash_value & 0x0FFFF;
-               mc_addr_list += ETH_ALEN;
+               DEBUGOUT1("Hash value = 0x%03X\n", hash_value);
+               hash_list[i] = hash_value & 0x0FFF;
+               mc_addr_list += ETH_ADDR_LEN;
        }
 
-       mbx->ops.write_posted(hw, msgbuf, E1000_VFMAILBOX_SIZE);
+       e1000_write_msg_read_ack(hw, msgbuf, E1000_VFMAILBOX_SIZE);
 }
 
 /**
- *  e1000_set_vfta_vf - Set/Unset vlan filter table address
+ *  e1000_vfta_set_vf - Set/Unset vlan filter table address
  *  @hw: pointer to the HW structure
  *  @vid: determines the vfta register and bit to set/unset
  *  @set: if true then set bit, else clear bit
  **/
-static s32 e1000_set_vfta_vf(struct e1000_hw *hw, u16 vid, bool set)
+void e1000_vfta_set_vf(struct e1000_hw *hw, u16 vid, bool set)
 {
-       struct e1000_mbx_info *mbx = &hw->mbx;
        u32 msgbuf[2];
-       s32 err;
 
        msgbuf[0] = E1000_VF_SET_VLAN;
        msgbuf[1] = vid;
-       /* Setting the 8 bit field MSG INFO to true indicates "add" */
+       /* Setting the 8 bit field MSG INFO to TRUE indicates "add" */
        if (set)
-               msgbuf[0] |= 1 << E1000_VT_MSGINFO_SHIFT;
-
-       mbx->ops.write_posted(hw, msgbuf, 2);
+               msgbuf[0] |= E1000_VF_SET_VLAN_ADD;
 
-       err = mbx->ops.read_posted(hw, msgbuf, 2);
-
-       msgbuf[0] &= ~E1000_VT_MSGTYPE_CTS;
-
-       /* if nacked the vlan was rejected */
-       if (!err && (msgbuf[0] == (E1000_VF_SET_VLAN | E1000_VT_MSGTYPE_NACK)))
-               err = -E1000_ERR_MAC_INIT;
-
-       return err;
+       e1000_write_msg_read_ack(hw, msgbuf, 2);
 }
 
 /** e1000_rlpml_set_vf - Set the maximum receive packet length
@@ -289,42 +336,49 @@ static s32 e1000_set_vfta_vf(struct e1000_hw *hw, u16 vid, bool set)
  **/
 void e1000_rlpml_set_vf(struct e1000_hw *hw, u16 max_size)
 {
-       struct e1000_mbx_info *mbx = &hw->mbx;
        u32 msgbuf[2];
 
        msgbuf[0] = E1000_VF_SET_LPE;
        msgbuf[1] = max_size;
 
-       mbx->ops.write_posted(hw, msgbuf, 2);
+       e1000_write_msg_read_ack(hw, msgbuf, 2);
 }
 
 /**
- *  e1000_rar_set_vf - set device MAC address
+ *  e1000_promisc_set_vf - Set flags for Unicast or Multicast promisc
  *  @hw: pointer to the HW structure
- *  @addr: pointer to the receive address
- *  @index receive address array register
+ *  @uni: boolean indicating unicast promisc status
+ *  @multi: boolean indicating multicast promisc status
  **/
-static void e1000_rar_set_vf(struct e1000_hw *hw, u8 * addr, u32 index)
+s32 e1000_promisc_set_vf(struct e1000_hw *hw, enum e1000_promisc_type type)
 {
        struct e1000_mbx_info *mbx = &hw->mbx;
-       u32 msgbuf[3];
-       u8 *msg_addr = (u8 *)(&msgbuf[1]);
+       u32 msgbuf = E1000_VF_SET_PROMISC;
        s32 ret_val;
 
-       memset(msgbuf, 0, 12);
-       msgbuf[0] = E1000_VF_SET_MAC_ADDR;
-       memcpy(msg_addr, addr, 6);
-       ret_val = mbx->ops.write_posted(hw, msgbuf, 3);
+       switch (type) {
+       case e1000_promisc_multicast:
+               msgbuf |= E1000_VF_SET_PROMISC_MULTICAST;
+               break;
+       case e1000_promisc_enabled:
+               msgbuf |= E1000_VF_SET_PROMISC_MULTICAST;
+       case e1000_promisc_unicast:
+               msgbuf |= E1000_VF_SET_PROMISC_UNICAST;
+       case e1000_promisc_disabled:
+               break;
+       default:
+               return -E1000_ERR_MAC_INIT;
+       }
+
+        ret_val = mbx->ops.write_posted(hw, &msgbuf, 1, 0);
 
        if (!ret_val)
-               ret_val = mbx->ops.read_posted(hw, msgbuf, 3);
+               ret_val = mbx->ops.read_posted(hw, &msgbuf, 1, 0);
 
-       msgbuf[0] &= ~E1000_VT_MSGTYPE_CTS;
+       if (!ret_val && !(msgbuf & E1000_VT_MSGTYPE_ACK))
+               ret_val = -E1000_ERR_MAC_INIT;
 
-       /* if nacked the address was rejected, use "perm_addr" */
-       if (!ret_val &&
-           (msgbuf[0] == (E1000_VF_SET_MAC_ADDR | E1000_VT_MSGTYPE_NACK)))
-               e1000_read_mac_addr_vf(hw);
+       return ret_val;
 }
 
 /**
@@ -333,7 +387,10 @@ static void e1000_rar_set_vf(struct e1000_hw *hw, u8 * addr, u32 index)
  **/
 static s32 e1000_read_mac_addr_vf(struct e1000_hw *hw)
 {
-       memcpy(hw->mac.addr, hw->mac.perm_addr, ETH_ALEN);
+       int i;
+
+       for (i = 0; i < ETH_ADDR_LEN; i++)
+               hw->mac.addr[i] = hw->mac.perm_addr[i];
 
        return E1000_SUCCESS;
 }
@@ -353,6 +410,8 @@ static s32 e1000_check_for_link_vf(struct e1000_hw *hw)
        s32 ret_val = E1000_SUCCESS;
        u32 in_msg = 0;
 
+       DEBUGFUNC("e1000_check_for_link_vf");
+
        /*
         * We only want to run this if there has been a rst asserted.
         * in this case that could mean a link change, device reset,
@@ -360,30 +419,32 @@ static s32 e1000_check_for_link_vf(struct e1000_hw *hw)
         */
 
        /* If we were hit with a reset or timeout drop the link */
-       if (!mbx->ops.check_for_rst(hw) || !mbx->timeout)
+       if (!mbx->ops.check_for_rst(hw, 0) || !mbx->timeout)
                mac->get_link_status = true;
 
        if (!mac->get_link_status)
                goto out;
 
        /* if link status is down no point in checking to see if pf is up */
-       if (!(er32(STATUS) & E1000_STATUS_LU))
+       if (!(E1000_READ_REG(hw, E1000_STATUS) & E1000_STATUS_LU))
                goto out;
 
        /* if the read failed it could just be a mailbox collision, best wait
         * until we are called again and don't report an error */
-       if (mbx->ops.read(hw, &in_msg, 1))
+       if (mbx->ops.read(hw, &in_msg, 1, 0))
                goto out;
 
        /* if incoming message isn't clear to send we are waiting on response */
        if (!(in_msg & E1000_VT_MSGTYPE_CTS)) {
-               /* message is not CTS and is NACK we must have lost CTS status */
+               /* message is not CTS and is NACK we have lost CTS status */
                if (in_msg & E1000_VT_MSGTYPE_NACK)
                        ret_val = -E1000_ERR_MAC_INIT;
                goto out;
        }
 
-       /* the pf is talking, if we timed out in the past we reinit */
+       /* at this point we know the PF is talking to us, check and see if
+        * we are still accepting timeout or if we had a timeout failure.
+        * if we failed then we will need to reinit */
        if (!mbx->timeout) {
                ret_val = -E1000_ERR_MAC_INIT;
                goto out;
diff --git a/drivers/net/igbvf/e1000_vf.h b/drivers/net/igbvf/e1000_vf.h
new file mode 100644 (file)
index 0000000..f990ef6
--- /dev/null
@@ -0,0 +1,288 @@
+/*******************************************************************************
+
+  Intel(R) 82576 Virtual Function Linux driver
+  Copyright(c) 1999 - 2012 Intel Corporation.
+
+  This program is free software; you can redistribute it and/or modify it
+  under the terms and conditions of the GNU General Public License,
+  version 2, as published by the Free Software Foundation.
+
+  This program is distributed in the hope it will be useful, but WITHOUT
+  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+  more details.
+
+  You should have received a copy of the GNU General Public License along with
+  this program; if not, write to the Free Software Foundation, Inc.,
+  51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
+
+  The full GNU General Public License is included in this distribution in
+  the file called "COPYING".
+
+  Contact Information:
+  Linux NICS <linux.nics@intel.com>
+  e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
+  Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
+
+*******************************************************************************/
+
+#ifndef _E1000_VF_H_
+#define _E1000_VF_H_
+
+#include "e1000_osdep.h"
+#include "e1000_regs.h"
+#include "e1000_defines.h"
+
+struct e1000_hw;
+
+#define E1000_DEV_ID_82576_VF          0x10CA
+#define E1000_DEV_ID_I350_VF           0x1520
+
+#define E1000_VF_INIT_TIMEOUT          200 /* Num of retries to clear RSTI */
+
+/* Additional Descriptor Control definitions */
+#define E1000_TXDCTL_QUEUE_ENABLE      0x02000000 /* Ena specific Tx Queue */
+#define E1000_RXDCTL_QUEUE_ENABLE      0x02000000 /* Ena specific Rx Queue */
+
+/* SRRCTL bit definitions */
+#define E1000_SRRCTL_BSIZEPKT_SHIFT            10 /* Shift _right_ */
+#define E1000_SRRCTL_BSIZEHDRSIZE_MASK         0x00000F00
+#define E1000_SRRCTL_BSIZEHDRSIZE_SHIFT                2  /* Shift _left_ */
+#define E1000_SRRCTL_DESCTYPE_LEGACY           0x00000000
+#define E1000_SRRCTL_DESCTYPE_ADV_ONEBUF       0x02000000
+#define E1000_SRRCTL_DESCTYPE_HDR_SPLIT                0x04000000
+#define E1000_SRRCTL_DESCTYPE_HDR_SPLIT_ALWAYS 0x0A000000
+#define E1000_SRRCTL_DESCTYPE_HDR_REPLICATION  0x06000000
+#define E1000_SRRCTL_DESCTYPE_HDR_REPLICATION_LARGE_PKT 0x08000000
+#define E1000_SRRCTL_DESCTYPE_MASK             0x0E000000
+#define E1000_SRRCTL_DROP_EN                   0x80000000
+
+#define E1000_SRRCTL_BSIZEPKT_MASK     0x0000007F
+#define E1000_SRRCTL_BSIZEHDR_MASK     0x00003F00
+
+/* Interrupt Defines */
+#define E1000_EICR             0x01580 /* Ext. Interrupt Cause Read - R/clr */
+#define E1000_EITR(_n)         (0x01680 + ((_n) << 2))
+#define E1000_EICS             0x01520 /* Ext. Intr Cause Set -W0 */
+#define E1000_EIMS             0x01524 /* Ext. Intr Mask Set/Read -RW */
+#define E1000_EIMC             0x01528 /* Ext. Intr Mask Clear -WO */
+#define E1000_EIAC             0x0152C /* Ext. Intr Auto Clear -RW */
+#define E1000_EIAM             0x01530 /* Ext. Intr Ack Auto Clear Mask -RW */
+#define E1000_IVAR0            0x01700 /* Intr Vector Alloc (array) -RW */
+#define E1000_IVAR_MISC                0x01740 /* IVAR for "other" causes -RW */
+#define E1000_IVAR_VALID       0x80
+
+/* Receive Descriptor - Advanced */
+union e1000_adv_rx_desc {
+       struct {
+               u64 pkt_addr; /* Packet buffer address */
+               u64 hdr_addr; /* Header buffer address */
+       } read;
+       struct {
+               struct {
+                       union {
+                               u32 data;
+                               struct {
+                                       /* RSS type, Packet type */
+                                       u16 pkt_info;
+                                       /* Split Header, header buffer len */
+                                       u16 hdr_info;
+                               } hs_rss;
+                       } lo_dword;
+                       union {
+                               u32 rss; /* RSS Hash */
+                               struct {
+                                       u16 ip_id; /* IP id */
+                                       u16 csum; /* Packet Checksum */
+                               } csum_ip;
+                       } hi_dword;
+               } lower;
+               struct {
+                       u32 status_error; /* ext status/error */
+                       u16 length; /* Packet length */
+                       u16 vlan; /* VLAN tag */
+               } upper;
+       } wb;  /* writeback */
+};
+
+#define E1000_RXDADV_HDRBUFLEN_MASK    0x7FE0
+#define E1000_RXDADV_HDRBUFLEN_SHIFT   5
+
+/* Transmit Descriptor - Advanced */
+union e1000_adv_tx_desc {
+       struct {
+               u64 buffer_addr;    /* Address of descriptor's data buf */
+               u32 cmd_type_len;
+               u32 olinfo_status;
+       } read;
+       struct {
+               u64 rsvd;       /* Reserved */
+               u32 nxtseq_seed;
+               u32 status;
+       } wb;
+};
+
+/* Adv Transmit Descriptor Config Masks */
+#define E1000_ADVTXD_DTYP_CTXT 0x00200000 /* Advanced Context Descriptor */
+#define E1000_ADVTXD_DTYP_DATA 0x00300000 /* Advanced Data Descriptor */
+#define E1000_ADVTXD_DCMD_EOP  0x01000000 /* End of Packet */
+#define E1000_ADVTXD_DCMD_IFCS 0x02000000 /* Insert FCS (Ethernet CRC) */
+#define E1000_ADVTXD_DCMD_RS   0x08000000 /* Report Status */
+#define E1000_ADVTXD_DCMD_DEXT 0x20000000 /* Descriptor extension (1=Adv) */
+#define E1000_ADVTXD_DCMD_VLE  0x40000000 /* VLAN pkt enable */
+#define E1000_ADVTXD_DCMD_TSE  0x80000000 /* TCP Seg enable */
+#define E1000_ADVTXD_PAYLEN_SHIFT      14 /* Adv desc PAYLEN shift */
+
+/* Context descriptors */
+struct e1000_adv_tx_context_desc {
+       u32 vlan_macip_lens;
+       u32 seqnum_seed;
+       u32 type_tucmd_mlhl;
+       u32 mss_l4len_idx;
+};
+
+#define E1000_ADVTXD_MACLEN_SHIFT      9  /* Adv ctxt desc mac len shift */
+#define E1000_ADVTXD_TUCMD_IPV4                0x00000400  /* IP Packet Type: 1=IPv4 */
+#define E1000_ADVTXD_TUCMD_L4T_TCP     0x00000800  /* L4 Packet TYPE of TCP */
+#define E1000_ADVTXD_L4LEN_SHIFT       8  /* Adv ctxt L4LEN shift */
+#define E1000_ADVTXD_MSS_SHIFT         16  /* Adv ctxt MSS shift */
+
+enum e1000_mac_type {
+       e1000_undefined = 0,
+       e1000_vfadapt,
+       e1000_vfadapt_i350,
+       e1000_num_macs  /* List is 1-based, so subtract 1 for true count. */
+};
+
+struct e1000_vf_stats {
+       u64 base_gprc;
+       u64 base_gptc;
+       u64 base_gorc;
+       u64 base_gotc;
+       u64 base_mprc;
+       u64 base_gotlbc;
+       u64 base_gptlbc;
+       u64 base_gorlbc;
+       u64 base_gprlbc;
+
+       u32 last_gprc;
+       u32 last_gptc;
+       u32 last_gorc;
+       u32 last_gotc;
+       u32 last_mprc;
+       u32 last_gotlbc;
+       u32 last_gptlbc;
+       u32 last_gorlbc;
+       u32 last_gprlbc;
+
+       u64 gprc;
+       u64 gptc;
+       u64 gorc;
+       u64 gotc;
+       u64 mprc;
+       u64 gotlbc;
+       u64 gptlbc;
+       u64 gorlbc;
+       u64 gprlbc;
+};
+
+#include "e1000_mbx.h"
+
+struct e1000_mac_operations {
+       /* Function pointers for the MAC. */
+       s32  (*init_params)(struct e1000_hw *);
+       s32  (*check_for_link)(struct e1000_hw *);
+       void (*clear_vfta)(struct e1000_hw *);
+       s32  (*get_bus_info)(struct e1000_hw *);
+       s32  (*get_link_up_info)(struct e1000_hw *, u16 *, u16 *);
+       void (*update_mc_addr_list)(struct e1000_hw *, u8 *, u32);
+       s32  (*reset_hw)(struct e1000_hw *);
+       s32  (*init_hw)(struct e1000_hw *);
+       s32  (*setup_link)(struct e1000_hw *);
+       void (*write_vfta)(struct e1000_hw *, u32, u32);
+       void (*rar_set)(struct e1000_hw *, u8*, u32);
+       s32  (*read_mac_addr)(struct e1000_hw *);
+};
+
+struct e1000_mac_info {
+       struct e1000_mac_operations ops;
+       u8 addr[6];
+       u8 perm_addr[6];
+
+       enum e1000_mac_type type;
+
+       u16 mta_reg_count;
+       u16 rar_entry_count;
+
+       bool get_link_status;
+};
+
+struct e1000_mbx_operations {
+       s32 (*init_params)(struct e1000_hw *hw);
+       s32 (*read)(struct e1000_hw *, u32 *, u16,  u16);
+       s32 (*write)(struct e1000_hw *, u32 *, u16, u16);
+       s32 (*read_posted)(struct e1000_hw *, u32 *, u16,  u16);
+       s32 (*write_posted)(struct e1000_hw *, u32 *, u16, u16);
+       s32 (*check_for_msg)(struct e1000_hw *, u16);
+       s32 (*check_for_ack)(struct e1000_hw *, u16);
+       s32 (*check_for_rst)(struct e1000_hw *, u16);
+};
+
+struct e1000_mbx_stats {
+       u32 msgs_tx;
+       u32 msgs_rx;
+
+       u32 acks;
+       u32 reqs;
+       u32 rsts;
+};
+
+struct e1000_mbx_info {
+       struct e1000_mbx_operations ops;
+       struct e1000_mbx_stats stats;
+       u32 timeout;
+       u32 usec_delay;
+       u16 size;
+};
+
+struct e1000_dev_spec_vf {
+       u32 vf_number;
+       u32 v2p_mailbox;
+};
+
+struct e1000_hw {
+       void *back;
+
+       u8 __iomem *hw_addr;
+       u8 __iomem *flash_address;
+       unsigned long io_base;
+
+       struct e1000_mac_info  mac;
+       struct e1000_mbx_info mbx;
+
+       union {
+               struct e1000_dev_spec_vf vf;
+       } dev_spec;
+
+       u16 device_id;
+       u16 subsystem_vendor_id;
+       u16 subsystem_device_id;
+       u16 vendor_id;
+
+       u8  revision_id;
+};
+
+enum e1000_promisc_type {
+       e1000_promisc_disabled = 0,   /* all promisc modes disabled */
+       e1000_promisc_unicast = 1,    /* unicast promiscuous enabled */
+       e1000_promisc_multicast = 2,  /* multicast promiscuous enabled */
+       e1000_promisc_enabled = 3,    /* both uni and multicast promisc */
+       e1000_num_promisc_types
+};
+
+/* These functions must be implemented by drivers */
+s32  e1000_read_pcie_cap_reg(struct e1000_hw *hw, u32 reg, u16 *value);
+void e1000_vfta_set_vf(struct e1000_hw *, u16, bool);
+void e1000_rlpml_set_vf(struct e1000_hw *, u16);
+s32 e1000_promisc_set_vf(struct e1000_hw *, enum e1000_promisc_type);
+#endif /* _E1000_VF_H_ */
index abccbd3096add8a1c613cb5e83ff6a5e3f666b68..2821cd82dd8155cf3e72e9815f7a060438dd204c 100644 (file)
@@ -1,7 +1,7 @@
 /*******************************************************************************
 
   Intel(R) 82576 Virtual Function Linux driver
-  Copyright(c) 2009 - 2012 Intel Corporation.
+  Copyright(c) 1999 - 2012 Intel Corporation.
 
   This program is free software; you can redistribute it and/or modify it
   under the terms and conditions of the GNU General Public License,
@@ -20,6 +20,7 @@
   the file called "COPYING".
 
   Contact Information:
+  Linux NICS <linux.nics@intel.com>
   e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
   Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
 
 /* ethtool support for igbvf */
 
 #include <linux/netdevice.h>
+#ifdef SIOCETHTOOL
 #include <linux/ethtool.h>
 #include <linux/pci.h>
-#include <linux/vmalloc.h>
 #include <linux/delay.h>
 
 #include "igbvf.h"
+#ifdef NETIF_F_HW_VLAN_TX
 #include <linux/if_vlan.h>
+#endif
 
+#ifdef ETHTOOL_OPS_COMPAT
+#include "kcompat_ethtool.c"
+#endif
 
 struct igbvf_stats {
        char stat_string[ETH_GSTRING_LEN];
@@ -44,11 +50,9 @@ struct igbvf_stats {
        int base_stat_offset;
 };
 
-#define IGBVF_STAT(current, base) \
-               sizeof(((struct igbvf_adapter *)0)->current), \
-               offsetof(struct igbvf_adapter, current), \
-               offsetof(struct igbvf_adapter, base)
-
+#define IGBVF_STAT(m, b) sizeof(((struct igbvf_adapter *)0)->m), \
+               offsetof(struct igbvf_adapter, m), \
+               offsetof(struct igbvf_adapter, b)
 static const struct igbvf_stats igbvf_gstrings_stats[] = {
        { "rx_packets", IGBVF_STAT(stats.gprc, stats.base_gprc) },
        { "tx_packets", IGBVF_STAT(stats.gptc, stats.base_gptc) },
@@ -65,8 +69,8 @@ static const struct igbvf_stats igbvf_gstrings_stats[] = {
        { "alloc_rx_buff_failed", IGBVF_STAT(alloc_rx_buff_failed, zero_base) },
 };
 
-#define IGBVF_GLOBAL_STATS_LEN ARRAY_SIZE(igbvf_gstrings_stats)
-
+#define IGBVF_GLOBAL_STATS_LEN \
+       sizeof(igbvf_gstrings_stats) / sizeof(struct igbvf_stats)
 static const char igbvf_gstrings_test[][ETH_GSTRING_LEN] = {
        "Link test   (on/offline)"
 };
@@ -74,7 +78,7 @@ static const char igbvf_gstrings_test[][ETH_GSTRING_LEN] = {
 #define IGBVF_TEST_LEN ARRAY_SIZE(igbvf_gstrings_test)
 
 static int igbvf_get_settings(struct net_device *netdev,
-                              struct ethtool_cmd *ecmd)
+                             struct ethtool_cmd *ecmd)
 {
        struct igbvf_adapter *adapter = netdev_priv(netdev);
        struct e1000_hw *hw = &adapter->hw;
@@ -90,18 +94,18 @@ static int igbvf_get_settings(struct net_device *netdev,
        status = er32(STATUS);
        if (status & E1000_STATUS_LU) {
                if (status & E1000_STATUS_SPEED_1000)
-                       ethtool_cmd_speed_set(ecmd, SPEED_1000);
+                       ecmd->speed = 1000;
                else if (status & E1000_STATUS_SPEED_100)
-                       ethtool_cmd_speed_set(ecmd, SPEED_100);
+                       ecmd->speed = 100;
                else
-                       ethtool_cmd_speed_set(ecmd, SPEED_10);
+                       ecmd->speed = 10;
 
                if (status & E1000_STATUS_FD)
                        ecmd->duplex = DUPLEX_FULL;
                else
                        ecmd->duplex = DUPLEX_HALF;
        } else {
-               ethtool_cmd_speed_set(ecmd, -1);
+               ecmd->speed = -1;
                ecmd->duplex = -1;
        }
 
@@ -110,24 +114,112 @@ static int igbvf_get_settings(struct net_device *netdev,
        return 0;
 }
 
+static u32 igbvf_get_link(struct net_device *netdev)
+{
+       return netif_carrier_ok(netdev);
+}
+
 static int igbvf_set_settings(struct net_device *netdev,
-                              struct ethtool_cmd *ecmd)
+                             struct ethtool_cmd *ecmd)
 {
        return -EOPNOTSUPP;
 }
 
 static void igbvf_get_pauseparam(struct net_device *netdev,
-                                 struct ethtool_pauseparam *pause)
+                                struct ethtool_pauseparam *pause)
 {
        return;
 }
 
 static int igbvf_set_pauseparam(struct net_device *netdev,
-                                struct ethtool_pauseparam *pause)
+                               struct ethtool_pauseparam *pause)
 {
        return -EOPNOTSUPP;
 }
 
+static u32 igbvf_get_rx_csum(struct net_device *netdev)
+{
+       struct igbvf_adapter *adapter = netdev_priv(netdev);
+       return !(adapter->flags & IGBVF_FLAG_RX_CSUM_DISABLED);
+}
+
+static int igbvf_set_rx_csum(struct net_device *netdev, u32 data)
+{
+       struct igbvf_adapter *adapter = netdev_priv(netdev);
+
+       if (data)
+               adapter->flags &= ~IGBVF_FLAG_RX_CSUM_DISABLED;
+       else
+               adapter->flags |= IGBVF_FLAG_RX_CSUM_DISABLED;
+
+       return 0;
+}
+
+static u32 igbvf_get_tx_csum(struct net_device *netdev)
+{
+       return ((netdev->features & NETIF_F_IP_CSUM) != 0);
+}
+
+static int igbvf_set_tx_csum(struct net_device *netdev, u32 data)
+{
+       if (data)
+#ifdef NETIF_F_IPV6_CSUM
+               netdev->features |= (NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM);
+       else
+               netdev->features &= ~(NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM);
+#else
+               netdev->features |= NETIF_F_IP_CSUM;
+       else
+               netdev->features &= ~NETIF_F_IP_CSUM;
+#endif
+       return 0;
+}
+
+#ifdef NETIF_F_TSO
+static int igbvf_set_tso(struct net_device *netdev, u32 data)
+{
+       struct igbvf_adapter *adapter = netdev_priv(netdev);
+#ifndef HAVE_NETDEV_VLAN_FEATURES
+       struct net_device *v_netdev;
+       int i;
+#endif
+
+       if (data) {
+               netdev->features |= NETIF_F_TSO;
+#ifdef NETIF_F_TSO6
+               netdev->features |= NETIF_F_TSO6;
+#endif
+       } else {
+               netdev->features &= ~NETIF_F_TSO;
+#ifdef NETIF_F_TSO6
+               netdev->features &= ~NETIF_F_TSO6;
+#endif
+#ifndef HAVE_NETDEV_VLAN_FEATURES
+               /* disable TSO on all VLANs if they're present */
+               if (adapter->vlgrp) {
+                       for (i = 0; i < VLAN_GROUP_ARRAY_LEN; i++) {
+                               v_netdev =
+                                       vlan_group_get_device(adapter->vlgrp,
+                                                             i);
+                               if (!v_netdev)
+                                       continue;
+
+                               v_netdev->features &= ~NETIF_F_TSO;
+#ifdef NETIF_F_TSO6
+                               v_netdev->features &= ~NETIF_F_TSO6;
+#endif
+                               vlan_group_set_device(adapter->vlgrp, i,
+                                                     v_netdev);
+                       }
+               }
+#endif /* HAVE_NETDEV_VLAN_FEATURES */
+       }
+
+       e_info("TSO is %s\n", data ? "Enabled" : "Disabled");
+       return 0;
+}
+#endif
+
 static u32 igbvf_get_msglevel(struct net_device *netdev)
 {
        struct igbvf_adapter *adapter = netdev_priv(netdev);
@@ -142,32 +234,38 @@ static void igbvf_set_msglevel(struct net_device *netdev, u32 data)
 
 static int igbvf_get_regs_len(struct net_device *netdev)
 {
-#define IGBVF_REGS_LEN 8
+#define IGBVF_REGS_LEN 32 /* overestimate */
        return IGBVF_REGS_LEN * sizeof(u32);
 }
 
 static void igbvf_get_regs(struct net_device *netdev,
-                           struct ethtool_regs *regs, void *p)
+                          struct ethtool_regs *regs, void *p)
 {
        struct igbvf_adapter *adapter = netdev_priv(netdev);
        struct e1000_hw *hw = &adapter->hw;
        u32 *regs_buff = p;
+       u8 revision_id;
 
        memset(p, 0, IGBVF_REGS_LEN * sizeof(u32));
 
-       regs->version = (1 << 24) | (adapter->pdev->revision << 16) |
-                       adapter->pdev->device;
+       pci_read_config_byte(adapter->pdev, PCI_REVISION_ID, &revision_id);
 
-       regs_buff[0] = er32(CTRL);
-       regs_buff[1] = er32(STATUS);
+       regs->version = (1 << 24) | (revision_id << 16) | adapter->pdev->device;
 
-       regs_buff[2] = er32(RDLEN(0));
-       regs_buff[3] = er32(RDH(0));
-       regs_buff[4] = er32(RDT(0));
+       regs_buff[0]  = er32(CTRL);
+       regs_buff[1]  = er32(STATUS);
 
-       regs_buff[5] = er32(TDLEN(0));
-       regs_buff[6] = er32(TDH(0));
-       regs_buff[7] = er32(TDT(0));
+       regs_buff[2]  = er32(RCTL);
+       regs_buff[3]  = er32(RDLEN(0));
+       regs_buff[4]  = er32(RDH(0));
+       regs_buff[5]  = er32(RDT(0));
+       regs_buff[6]  = er32(RDTR);
+
+       regs_buff[7]  = er32(TCTL);
+       regs_buff[8]  = er32(TDLEN(0));
+       regs_buff[9]  = er32(TDH(0));
+       regs_buff[10] = er32(TDT(0));
+       regs_buff[11] = er32(TIDV);
 }
 
 static int igbvf_get_eeprom_len(struct net_device *netdev)
@@ -176,19 +274,19 @@ static int igbvf_get_eeprom_len(struct net_device *netdev)
 }
 
 static int igbvf_get_eeprom(struct net_device *netdev,
-                            struct ethtool_eeprom *eeprom, u8 *bytes)
+                           struct ethtool_eeprom *eeprom, u8 *bytes)
 {
        return -EOPNOTSUPP;
 }
 
 static int igbvf_set_eeprom(struct net_device *netdev,
-                            struct ethtool_eeprom *eeprom, u8 *bytes)
+                           struct ethtool_eeprom *eeprom, u8 *bytes)
 {
        return -EOPNOTSUPP;
 }
 
 static void igbvf_get_drvinfo(struct net_device *netdev,
-                              struct ethtool_drvinfo *drvinfo)
+                             struct ethtool_drvinfo *drvinfo)
 {
        struct igbvf_adapter *adapter = netdev_priv(netdev);
        char firmware_version[32] = "N/A";
@@ -202,7 +300,7 @@ static void igbvf_get_drvinfo(struct net_device *netdev,
 }
 
 static void igbvf_get_ringparam(struct net_device *netdev,
-                                struct ethtool_ringparam *ring)
+                               struct ethtool_ringparam *ring)
 {
        struct igbvf_adapter *adapter = netdev_priv(netdev);
        struct igbvf_ring *tx_ring = adapter->tx_ring;
@@ -210,12 +308,16 @@ static void igbvf_get_ringparam(struct net_device *netdev,
 
        ring->rx_max_pending = IGBVF_MAX_RXD;
        ring->tx_max_pending = IGBVF_MAX_TXD;
+       ring->rx_mini_max_pending = 0;
+       ring->rx_jumbo_max_pending = 0;
        ring->rx_pending = rx_ring->count;
        ring->tx_pending = tx_ring->count;
+       ring->rx_mini_pending = 0;
+       ring->rx_jumbo_pending = 0;
 }
 
 static int igbvf_set_ringparam(struct net_device *netdev,
-                               struct ethtool_ringparam *ring)
+                              struct ethtool_ringparam *ring)
 {
        struct igbvf_adapter *adapter = netdev_priv(netdev);
        struct igbvf_ring *temp_ring;
@@ -308,7 +410,7 @@ static int igbvf_link_test(struct igbvf_adapter *adapter, u64 *data)
 }
 
 static void igbvf_diag_test(struct net_device *netdev,
-                            struct ethtool_test *eth_test, u64 *data)
+                           struct ethtool_test *eth_test, u64 *data)
 {
        struct igbvf_adapter *adapter = netdev_priv(netdev);
 
@@ -326,20 +428,22 @@ static void igbvf_diag_test(struct net_device *netdev,
 }
 
 static void igbvf_get_wol(struct net_device *netdev,
-                          struct ethtool_wolinfo *wol)
+                         struct ethtool_wolinfo *wol)
 {
        wol->supported = 0;
        wol->wolopts = 0;
+
+       return;
 }
 
 static int igbvf_set_wol(struct net_device *netdev,
-                         struct ethtool_wolinfo *wol)
+                        struct ethtool_wolinfo *wol)
 {
        return -EOPNOTSUPP;
 }
 
 static int igbvf_get_coalesce(struct net_device *netdev,
-                              struct ethtool_coalesce *ec)
+                             struct ethtool_coalesce *ec)
 {
        struct igbvf_adapter *adapter = netdev_priv(netdev);
 
@@ -352,7 +456,7 @@ static int igbvf_get_coalesce(struct net_device *netdev,
 }
 
 static int igbvf_set_coalesce(struct net_device *netdev,
-                              struct ethtool_coalesce *ec)
+                             struct ethtool_coalesce *ec)
 {
        struct igbvf_adapter *adapter = netdev_priv(netdev);
        struct e1000_hw *hw = &adapter->hw;
@@ -389,25 +493,25 @@ static int igbvf_nway_reset(struct net_device *netdev)
 
 
 static void igbvf_get_ethtool_stats(struct net_device *netdev,
-                                    struct ethtool_stats *stats,
-                                    u64 *data)
+                                   struct ethtool_stats *stats,
+                                   u64 *data)
 {
        struct igbvf_adapter *adapter = netdev_priv(netdev);
        int i;
 
        igbvf_update_stats(adapter);
        for (i = 0; i < IGBVF_GLOBAL_STATS_LEN; i++) {
-               char *p = (char *)adapter +
-                         igbvf_gstrings_stats[i].stat_offset;
-               char *b = (char *)adapter +
-                         igbvf_gstrings_stats[i].base_stat_offset;
+               char *p = (char *)adapter+igbvf_gstrings_stats[i].stat_offset;
+               char *b = (char *)adapter+igbvf_gstrings_stats[i].base_stat_offset;
                data[i] = ((igbvf_gstrings_stats[i].sizeof_stat ==
-                           sizeof(u64)) ? (*(u64 *)p - *(u64 *)b) :
-                           (*(u32 *)p - *(u32 *)b));
+                           sizeof(u64)) ? *(u64 *)p : *(u32 *)p) -
+                         ((igbvf_gstrings_stats[i].sizeof_stat ==
+                           sizeof(u64)) ? *(u64 *)b : *(u32 *)b);
        }
 
 }
 
+#ifdef HAVE_ETHTOOL_GET_SSET_COUNT
 static int igbvf_get_sset_count(struct net_device *dev, int stringset)
 {
        switch(stringset) {
@@ -419,9 +523,20 @@ static int igbvf_get_sset_count(struct net_device *dev, int stringset)
                return -EINVAL;
        }
 }
+#else
+static int igbvf_get_self_test_count(struct net_device *netdev)
+{
+       return IGBVF_TEST_LEN;
+}
+
+static int igbvf_get_stats_count(struct net_device *netdev)
+{
+       return IGBVF_GLOBAL_STATS_LEN;
+}
+#endif
 
 static void igbvf_get_strings(struct net_device *netdev, u32 stringset,
-                              u8 *data)
+                             u8 *data)
 {
        u8 *p = data;
        int i;
@@ -451,7 +566,7 @@ static const struct ethtool_ops igbvf_ethtool_ops = {
        .get_msglevel           = igbvf_get_msglevel,
        .set_msglevel           = igbvf_set_msglevel,
        .nway_reset             = igbvf_nway_reset,
-       .get_link               = ethtool_op_get_link,
+       .get_link               = igbvf_get_link,
        .get_eeprom_len         = igbvf_get_eeprom_len,
        .get_eeprom             = igbvf_get_eeprom,
        .set_eeprom             = igbvf_set_eeprom,
@@ -459,8 +574,23 @@ static const struct ethtool_ops igbvf_ethtool_ops = {
        .set_ringparam          = igbvf_set_ringparam,
        .get_pauseparam         = igbvf_get_pauseparam,
        .set_pauseparam         = igbvf_set_pauseparam,
+       .get_rx_csum            = igbvf_get_rx_csum,
+       .set_rx_csum            = igbvf_set_rx_csum,
+       .get_tx_csum            = igbvf_get_tx_csum,
+       .set_tx_csum            = igbvf_set_tx_csum,
+       .get_sg                 = ethtool_op_get_sg,
+       .set_sg                 = ethtool_op_set_sg,
+#ifdef NETIF_F_TSO
+       .get_tso                = ethtool_op_get_tso,
+       .set_tso                = igbvf_set_tso,
+#endif
        .self_test              = igbvf_diag_test,
+#ifdef HAVE_ETHTOOL_GET_SSET_COUNT
        .get_sset_count         = igbvf_get_sset_count,
+#else
+       .self_test_count        = igbvf_get_self_test_count,
+       .get_stats_count        = igbvf_get_stats_count,
+#endif
        .get_strings            = igbvf_get_strings,
        .get_ethtool_stats      = igbvf_get_ethtool_stats,
        .get_coalesce           = igbvf_get_coalesce,
@@ -469,5 +599,7 @@ static const struct ethtool_ops igbvf_ethtool_ops = {
 
 void igbvf_set_ethtool_ops(struct net_device *netdev)
 {
-       SET_ETHTOOL_OPS(netdev, &igbvf_ethtool_ops);
+       /* have to "undeclare" const on this struct to remove warnings */
+       SET_ETHTOOL_OPS(netdev, (struct ethtool_ops *)&igbvf_ethtool_ops);
 }
+#endif /* SIOCETHTOOL */
index a895e2f7b34d99b4afa870cfaab801b1061ab9db..14ed8e52dec33735a8e2f5121b5ef99ca711dfbe 100644 (file)
@@ -1,7 +1,7 @@
 /*******************************************************************************
 
   Intel(R) 82576 Virtual Function Linux driver
-  Copyright(c) 2009 - 2012 Intel Corporation.
+  Copyright(c) 1999 - 2012 Intel Corporation.
 
   This program is free software; you can redistribute it and/or modify it
   under the terms and conditions of the GNU General Public License,
@@ -20,6 +20,7 @@
   the file called "COPYING".
 
   Contact Information:
+  Linux NICS <linux.nics@intel.com>
   e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
   Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
 
 
 #include <linux/types.h>
 #include <linux/timer.h>
-#include <linux/io.h>
+#include <asm/io.h>
 #include <linux/netdevice.h>
-#include <linux/if_vlan.h>
 
-#include "vf.h"
+#include "kcompat.h"
+
+#include "e1000_vf.h"
 
 /* Forward declarations */
 struct igbvf_info;
 struct igbvf_adapter;
 
+#define e_printk(level, adapter, format, arg...) \
+       printk(level "%s: %s: " format, pci_name(adapter->pdev), \
+              adapter->netdev->name, ## arg)
+
+#define e_dbg(format, arg...) do { (void)(adapter); } while (0)
+
+#define e_err(format, arg...) \
+       e_printk(KERN_ERR, adapter, format, ## arg)
+#define e_info(format, arg...) \
+       e_printk(KERN_INFO, adapter, format, ## arg)
+#define e_warn(format, arg...) \
+       e_printk(KERN_WARNING, adapter, format, ## arg)
+#define e_notice(format, arg...) \
+       e_printk(KERN_NOTICE, adapter, format, ## arg)
+
+/* Use these macros early in probe, before the netdev is registered. */
+#define e_early_printk(level, adapter, format, arg...) \
+       printk(level "%s: " format, pci_name(adapter->pdev), ## arg)
+
+#define e_early_notice(format, arg...) \
+       e_early_printk(KERN_NOTICE, adapter, format, ## arg)
+#define e_early_info(format, arg...) \
+       e_early_printk(KERN_INFO, adapter, format, ## arg)
+#define e_early_err(format, arg...) \
+       e_early_printk(KERN_ERR, adapter, format, ## arg)
+
+
 /* Interrupt defines */
 #define IGBVF_START_ITR                    488 /* ~8000 ints/sec */
 #define IGBVF_4K_ITR                       980
@@ -55,23 +84,17 @@ enum latency_range {
        latency_invalid = 255
 };
 
-
-/* Interrupt modes, as used by the IntMode parameter */
-#define IGBVF_INT_MODE_LEGACY           0
-#define IGBVF_INT_MODE_MSI              1
-#define IGBVF_INT_MODE_MSIX             2
-
 /* Tx/Rx descriptor defines */
-#define IGBVF_DEFAULT_TXD               256
-#define IGBVF_MAX_TXD                   4096
-#define IGBVF_MIN_TXD                   80
+#define IGBVF_DEFAULT_TXD              256
+#define IGBVF_MAX_TXD                  4096
+#define IGBVF_MIN_TXD                  80
 
-#define IGBVF_DEFAULT_RXD               256
-#define IGBVF_MAX_RXD                   4096
-#define IGBVF_MIN_RXD                   80
+#define IGBVF_DEFAULT_RXD              256
+#define IGBVF_MAX_RXD                  4096
+#define IGBVF_MIN_RXD                  80
 
-#define IGBVF_MIN_ITR_USECS             10 /* 100000 irq/sec */
-#define IGBVF_MAX_ITR_USECS             10000 /* 100    irq/sec */
+#define IGBVF_MIN_ITR_USECS            10 /* 100000 irq/sec */
+#define IGBVF_MAX_ITR_USECS            10000 /* 100    irq/sec */
 
 /* RX descriptor control thresholds.
  * PTHRESH - MAC will consider prefetch if it has fewer than this number of
@@ -84,27 +107,28 @@ enum latency_range {
  *           descriptors until either it has this many to write back, or the
  *           ITR timer expires.
  */
-#define IGBVF_RX_PTHRESH                16
-#define IGBVF_RX_HTHRESH                8
-#define IGBVF_RX_WTHRESH                1
+#define IGBVF_RX_PTHRESH                    16
+#define IGBVF_RX_HTHRESH                     8
+#define IGBVF_RX_WTHRESH                     1
+
+#define IGBVF_TX_PTHRESH                     8
+#define IGBVF_TX_HTHRESH                     1
+#define IGBVF_TX_WTHRESH                     1
 
 /* this is the size past which hardware will drop packets when setting LPE=0 */
-#define MAXIMUM_ETHERNET_VLAN_SIZE      1522
+#define MAXIMUM_ETHERNET_VLAN_SIZE 1522
 
-#define IGBVF_FC_PAUSE_TIME             0x0680 /* 858 usec */
+#define IGBVF_FC_PAUSE_TIME            0x0680 /* 858 usec */
 
 /* How many Tx Descriptors do we need to call netif_wake_queue ? */
-#define IGBVF_TX_QUEUE_WAKE             32
+#define IGBVF_TX_QUEUE_WAKE    32
 /* How many Rx Buffers do we bundle into one write to the hardware ? */
-#define IGBVF_RX_BUFFER_WRITE           16 /* Must be power of 2 */
-
-#define AUTO_ALL_MODES                  0
-#define IGBVF_EEPROM_APME               0x0400
+#define IGBVF_RX_BUFFER_WRITE          16 /* Must be power of 2 */
 
-#define IGBVF_MNG_VLAN_NONE             (-1)
+#define AUTO_ALL_MODES                 0
+#define IGBVF_EEPROM_APME              0x0400
 
-/* Number of packet split data buffers (not including the header buffer) */
-#define PS_PAGE_BUFFERS                 (MAX_PS_BUFFERS - 1)
+#define IGBVF_MNG_VLAN_NONE            (-1)
 
 enum igbvf_boards {
        board_vf,
@@ -122,6 +146,7 @@ struct igbvf_queue_stats {
  */
 struct igbvf_buffer {
        dma_addr_t dma;
+       dma_addr_t page_dma;
        struct sk_buff *skb;
        union {
                /* Tx */
@@ -129,29 +154,21 @@ struct igbvf_buffer {
                        unsigned long time_stamp;
                        u16 length;
                        u16 next_to_watch;
-                       u16 mapped_as_page;
                };
                /* Rx */
                struct {
-                       struct page *page;
-                       u64 page_dma;
                        unsigned int page_offset;
                };
        };
-};
-
-union igbvf_desc {
-       union e1000_adv_rx_desc rx_desc;
-       union e1000_adv_tx_desc tx_desc;
-       struct e1000_adv_tx_context_desc tx_context_desc;
+       struct page *page;
 };
 
 struct igbvf_ring {
        struct igbvf_adapter *adapter;  /* backlink */
-       union igbvf_desc *desc;         /* pointer to ring memory  */
-       dma_addr_t dma;                 /* phys address of ring    */
-       unsigned int size;              /* length of ring in bytes */
-       unsigned int count;             /* number of desc. in ring */
+       void *desc;                     /* pointer to ring memory  */
+       dma_addr_t dma;                 /* phys address of ring    */
+       unsigned int size;              /* length of ring in bytes */
+       unsigned int count;             /* number of desc. in ring */
 
        u16 next_to_use;
        u16 next_to_clean;
@@ -184,7 +201,9 @@ struct igbvf_adapter {
        struct work_struct watchdog_task;
 
        const struct igbvf_info *ei;
-
+#ifdef HAVE_VLAN_RX_REGISTER
+       struct vlan_group *vlgrp;
+#endif
        unsigned long active_vlans[BITS_TO_LONGS(VLAN_N_VID)];
        u32 bd_number;
        u32 rx_buffer_len;
@@ -206,13 +225,12 @@ struct igbvf_adapter {
         * Tx
         */
        struct igbvf_ring *tx_ring /* One per active queue */
-       ____cacheline_aligned_in_smp;
+                                               ____cacheline_aligned_in_smp;
 
+       unsigned long tx_queue_len;
        unsigned int restart_queue;
        u32 txd_cmd;
 
-       u32 tx_int_delay;
-       u32 tx_abs_int_delay;
 
        unsigned int total_tx_bytes;
        unsigned int total_tx_packets;
@@ -231,9 +249,6 @@ struct igbvf_adapter {
         */
        struct igbvf_ring *rx_ring;
 
-       u32 rx_int_delay;
-       u32 rx_abs_int_delay;
-
        /* Rx stats */
        u64 hw_csum_err;
        u64 hw_csum_good;
@@ -283,25 +298,31 @@ struct igbvf_adapter {
 
        unsigned int flags;
        unsigned long last_reset;
+       u32 *config_space;
 };
 
 struct igbvf_info {
-       enum e1000_mac_type     mac;
-       unsigned int            flags;
-       u32                     pba;
-       void                    (*init_ops)(struct e1000_hw *);
-       s32                     (*get_variants)(struct igbvf_adapter *);
+       enum e1000_mac_type     mac;
+       unsigned int            flags;
+       u32                     pba;
+       void                    (*init_ops)(struct e1000_hw *);
+       s32                     (*get_variants)(struct igbvf_adapter *);
 };
 
 /* hardware capability, feature, and workaround flags */
-#define IGBVF_FLAG_RX_CSUM_DISABLED             (1 << 0)
+#define IGBVF_FLAG_RX_CSUM_DISABLED       (1 << 0)
+#define IGBVF_FLAG_RX_LB_VLAN_BSWAP       (1 << 1)
 
-#define IGBVF_RX_DESC_ADV(R, i)     \
-       (&((((R).desc))[i].rx_desc))
-#define IGBVF_TX_DESC_ADV(R, i)     \
-       (&((((R).desc))[i].tx_desc))
-#define IGBVF_TX_CTXTDESC_ADV(R, i) \
-       (&((((R).desc))[i].tx_context_desc))
+#define IGBVF_DESC_UNUSED(R) \
+       ((((R)->next_to_clean > (R)->next_to_use) ? 0 : (R)->count) + \
+       (R)->next_to_clean - (R)->next_to_use - 1)
+
+#define IGBVF_RX_DESC_ADV(R, i)            \
+       (&(((union e1000_adv_rx_desc *)((R).desc))[i]))
+#define IGBVF_TX_DESC_ADV(R, i)            \
+       (&(((union e1000_adv_tx_desc *)((R).desc))[i]))
+#define IGBVF_TX_CTXTDESC_ADV(R, i)        \
+       (&(((struct e1000_adv_tx_context_desc *)((R).desc))[i]))
 
 enum igbvf_state_t {
        __IGBVF_TESTING,
@@ -312,18 +333,37 @@ enum igbvf_state_t {
 extern char igbvf_driver_name[];
 extern const char igbvf_driver_version[];
 
-extern void igbvf_check_options(struct igbvf_adapter *);
-extern void igbvf_set_ethtool_ops(struct net_device *);
+extern void igbvf_check_options(struct igbvf_adapter *adapter);
+extern void igbvf_set_ethtool_ops(struct net_device *netdev);
+#ifdef ETHTOOL_OPS_COMPAT
+extern int ethtool_ioctl(struct ifreq *ifr);
+#endif
 
-extern int igbvf_up(struct igbvf_adapter *);
-extern void igbvf_down(struct igbvf_adapter *);
-extern void igbvf_reinit_locked(struct igbvf_adapter *);
+extern int igbvf_up(struct igbvf_adapter *adapter);
+extern void igbvf_down(struct igbvf_adapter *adapter);
+extern void igbvf_reinit_locked(struct igbvf_adapter *adapter);
+extern void igbvf_reset(struct igbvf_adapter *adapter);
 extern int igbvf_setup_rx_resources(struct igbvf_adapter *, struct igbvf_ring *);
 extern int igbvf_setup_tx_resources(struct igbvf_adapter *, struct igbvf_ring *);
 extern void igbvf_free_rx_resources(struct igbvf_ring *);
 extern void igbvf_free_tx_resources(struct igbvf_ring *);
-extern void igbvf_update_stats(struct igbvf_adapter *);
+extern void igbvf_update_stats(struct igbvf_adapter *adapter);
+extern void igbvf_set_interrupt_capability(struct igbvf_adapter *adapter);
+extern void igbvf_reset_interrupt_capability(struct igbvf_adapter *adapter);
 
 extern unsigned int copybreak;
 
+static inline u32 __er32(struct e1000_hw *hw, unsigned long reg)
+{
+       return readl(hw->hw_addr + reg);
+}
+
+static inline void __ew32(struct e1000_hw *hw, unsigned long reg, u32 val)
+{
+       writel(val, hw->hw_addr + reg);
+}
+#define er32(reg)      E1000_READ_REG(hw, E1000_##reg)
+#define ew32(reg,val)  E1000_WRITE_REG(hw, E1000_##reg, (val))
+#define e1e_flush()    er32(STATUS)
+
 #endif /* _IGBVF_H_ */
diff --git a/drivers/net/igbvf/kcompat.c b/drivers/net/igbvf/kcompat.c
new file mode 100644 (file)
index 0000000..bd68418
--- /dev/null
@@ -0,0 +1,1064 @@
+/*******************************************************************************
+
+  Intel(R) 82576 Virtual Function Linux driver
+  Copyright(c) 1999 - 2012 Intel Corporation.
+
+  This program is free software; you can redistribute it and/or modify it
+  under the terms and conditions of the GNU General Public License,
+  version 2, as published by the Free Software Foundation.
+
+  This program is distributed in the hope it will be useful, but WITHOUT
+  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+  more details.
+
+  You should have received a copy of the GNU General Public License along with
+  this program; if not, write to the Free Software Foundation, Inc.,
+  51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
+
+  The full GNU General Public License is included in this distribution in
+  the file called "COPYING".
+
+  Contact Information:
+  Linux NICS <linux.nics@intel.com>
+  e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
+  Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
+
+*******************************************************************************/
+
+#include "igbvf.h"
+#include "kcompat.h"
+
+/*****************************************************************************/
+#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,4,8) )
+/* From lib/vsprintf.c */
+#include <asm/div64.h>
+
+static int skip_atoi(const char **s)
+{
+       int i=0;
+
+       while (isdigit(**s))
+               i = i*10 + *((*s)++) - '0';
+       return i;
+}
+
+#define _kc_ZEROPAD    1               /* pad with zero */
+#define _kc_SIGN       2               /* unsigned/signed long */
+#define _kc_PLUS       4               /* show plus */
+#define _kc_SPACE      8               /* space if plus */
+#define _kc_LEFT       16              /* left justified */
+#define _kc_SPECIAL    32              /* 0x */
+#define _kc_LARGE      64              /* use 'ABCDEF' instead of 'abcdef' */
+
+static char * number(char * buf, char * end, long long num, int base, int size, int precision, int type)
+{
+       char c,sign,tmp[66];
+       const char *digits;
+       const char small_digits[] = "0123456789abcdefghijklmnopqrstuvwxyz";
+       const char large_digits[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
+       int i;
+
+       digits = (type & _kc_LARGE) ? large_digits : small_digits;
+       if (type & _kc_LEFT)
+               type &= ~_kc_ZEROPAD;
+       if (base < 2 || base > 36)
+               return 0;
+       c = (type & _kc_ZEROPAD) ? '0' : ' ';
+       sign = 0;
+       if (type & _kc_SIGN) {
+               if (num < 0) {
+                       sign = '-';
+                       num = -num;
+                       size--;
+               } else if (type & _kc_PLUS) {
+                       sign = '+';
+                       size--;
+               } else if (type & _kc_SPACE) {
+                       sign = ' ';
+                       size--;
+               }
+       }
+       if (type & _kc_SPECIAL) {
+               if (base == 16)
+                       size -= 2;
+               else if (base == 8)
+                       size--;
+       }
+       i = 0;
+       if (num == 0)
+               tmp[i++]='0';
+       else while (num != 0)
+               tmp[i++] = digits[do_div(num,base)];
+       if (i > precision)
+               precision = i;
+       size -= precision;
+       if (!(type&(_kc_ZEROPAD+_kc_LEFT))) {
+               while(size-->0) {
+                       if (buf <= end)
+                               *buf = ' ';
+                       ++buf;
+               }
+       }
+       if (sign) {
+               if (buf <= end)
+                       *buf = sign;
+               ++buf;
+       }
+       if (type & _kc_SPECIAL) {
+               if (base==8) {
+                       if (buf <= end)
+                               *buf = '0';
+                       ++buf;
+               } else if (base==16) {
+                       if (buf <= end)
+                               *buf = '0';
+                       ++buf;
+                       if (buf <= end)
+                               *buf = digits[33];
+                       ++buf;
+               }
+       }
+       if (!(type & _kc_LEFT)) {
+               while (size-- > 0) {
+                       if (buf <= end)
+                               *buf = c;
+                       ++buf;
+               }
+       }
+       while (i < precision--) {
+               if (buf <= end)
+                       *buf = '0';
+               ++buf;
+       }
+       while (i-- > 0) {
+               if (buf <= end)
+                       *buf = tmp[i];
+               ++buf;
+       }
+       while (size-- > 0) {
+               if (buf <= end)
+                       *buf = ' ';
+               ++buf;
+       }
+       return buf;
+}
+
+int _kc_vsnprintf(char *buf, size_t size, const char *fmt, va_list args)
+{
+       int len;
+       unsigned long long num;
+       int i, base;
+       char *str, *end, c;
+       const char *s;
+
+       int flags;              /* flags to number() */
+
+       int field_width;        /* width of output field */
+       int precision;          /* min. # of digits for integers; max
+                                  number of chars for from string */
+       int qualifier;          /* 'h', 'l', or 'L' for integer fields */
+                               /* 'z' support added 23/7/1999 S.H.    */
+                               /* 'z' changed to 'Z' --davidm 1/25/99 */
+
+       str = buf;
+       end = buf + size - 1;
+
+       if (end < buf - 1) {
+               end = ((void *) -1);
+               size = end - buf + 1;
+       }
+
+       for (; *fmt ; ++fmt) {
+               if (*fmt != '%') {
+                       if (str <= end)
+                               *str = *fmt;
+                       ++str;
+                       continue;
+               }
+
+               /* process flags */
+               flags = 0;
+               repeat:
+                       ++fmt;          /* this also skips first '%' */
+                       switch (*fmt) {
+                               case '-': flags |= _kc_LEFT; goto repeat;
+                               case '+': flags |= _kc_PLUS; goto repeat;
+                               case ' ': flags |= _kc_SPACE; goto repeat;
+                               case '#': flags |= _kc_SPECIAL; goto repeat;
+                               case '0': flags |= _kc_ZEROPAD; goto repeat;
+                       }
+
+               /* get field width */
+               field_width = -1;
+               if (isdigit(*fmt))
+                       field_width = skip_atoi(&fmt);
+               else if (*fmt == '*') {
+                       ++fmt;
+                       /* it's the next argument */
+                       field_width = va_arg(args, int);
+                       if (field_width < 0) {
+                               field_width = -field_width;
+                               flags |= _kc_LEFT;
+                       }
+               }
+
+               /* get the precision */
+               precision = -1;
+               if (*fmt == '.') {
+                       ++fmt;  
+                       if (isdigit(*fmt))
+                               precision = skip_atoi(&fmt);
+                       else if (*fmt == '*') {
+                               ++fmt;
+                               /* it's the next argument */
+                               precision = va_arg(args, int);
+                       }
+                       if (precision < 0)
+                               precision = 0;
+               }
+
+               /* get the conversion qualifier */
+               qualifier = -1;
+               if (*fmt == 'h' || *fmt == 'l' || *fmt == 'L' || *fmt =='Z') {
+                       qualifier = *fmt;
+                       ++fmt;
+               }
+
+               /* default base */
+               base = 10;
+
+               switch (*fmt) {
+                       case 'c':
+                               if (!(flags & _kc_LEFT)) {
+                                       while (--field_width > 0) {
+                                               if (str <= end)
+                                                       *str = ' ';
+                                               ++str;
+                                       }
+                               }
+                               c = (unsigned char) va_arg(args, int);
+                               if (str <= end)
+                                       *str = c;
+                               ++str;
+                               while (--field_width > 0) {
+                                       if (str <= end)
+                                               *str = ' ';
+                                       ++str;
+                               }
+                               continue;
+
+                       case 's':
+                               s = va_arg(args, char *);
+                               if (!s)
+                                       s = "<NULL>";
+
+                               len = strnlen(s, precision);
+
+                               if (!(flags & _kc_LEFT)) {
+                                       while (len < field_width--) {
+                                               if (str <= end)
+                                                       *str = ' ';
+                                               ++str;
+                                       }
+                               }
+                               for (i = 0; i < len; ++i) {
+                                       if (str <= end)
+                                               *str = *s;
+                                       ++str; ++s;
+                               }
+                               while (len < field_width--) {
+                                       if (str <= end)
+                                               *str = ' ';
+                                       ++str;
+                               }
+                               continue;
+
+                       case 'p':
+                               if (field_width == -1) {
+                                       field_width = 2*sizeof(void *);
+                                       flags |= _kc_ZEROPAD;
+                               }
+                               str = number(str, end,
+                                               (unsigned long) va_arg(args, void *),
+                                               16, field_width, precision, flags);
+                               continue;
+
+
+                       case 'n':
+                               /* FIXME:
+                               * What does C99 say about the overflow case here? */
+                               if (qualifier == 'l') {
+                                       long * ip = va_arg(args, long *);
+                                       *ip = (str - buf);
+                               } else if (qualifier == 'Z') {
+                                       size_t * ip = va_arg(args, size_t *);
+                                       *ip = (str - buf);
+                               } else {
+                                       int * ip = va_arg(args, int *);
+                                       *ip = (str - buf);
+                               }
+                               continue;
+
+                       case '%':
+                               if (str <= end)
+                                       *str = '%';
+                               ++str;
+                               continue;
+
+                               /* integer number formats - set up the flags and "break" */
+                       case 'o':
+                               base = 8;
+                               break;
+
+                       case 'X':
+                               flags |= _kc_LARGE;
+                       case 'x':
+                               base = 16;
+                               break;
+
+                       case 'd':
+                       case 'i':
+                               flags |= _kc_SIGN;
+                       case 'u':
+                               break;
+
+                       default:
+                               if (str <= end)
+                                       *str = '%';
+                               ++str;
+                               if (*fmt) {
+                                       if (str <= end)
+                                               *str = *fmt;
+                                       ++str;
+                               } else {
+                                       --fmt;
+                               }
+                               continue;
+               }
+               if (qualifier == 'L')
+                       num = va_arg(args, long long);
+               else if (qualifier == 'l') {
+                       num = va_arg(args, unsigned long);
+                       if (flags & _kc_SIGN)
+                               num = (signed long) num;
+               } else if (qualifier == 'Z') {
+                       num = va_arg(args, size_t);
+               } else if (qualifier == 'h') {
+                       num = (unsigned short) va_arg(args, int);
+                       if (flags & _kc_SIGN)
+                               num = (signed short) num;
+               } else {
+                       num = va_arg(args, unsigned int);
+                       if (flags & _kc_SIGN)
+                               num = (signed int) num;
+               }
+               str = number(str, end, num, base,
+                               field_width, precision, flags);
+       }
+       if (str <= end)
+               *str = '\0';
+       else if (size > 0)
+               /* don't write out a null byte if the buf size is zero */
+               *end = '\0';
+       /* the trailing null byte doesn't count towards the total
+       * ++str;
+       */
+       return str-buf;
+}
+
+int _kc_snprintf(char * buf, size_t size, const char *fmt, ...)
+{
+       va_list args;
+       int i;
+
+       va_start(args, fmt);
+       i = _kc_vsnprintf(buf,size,fmt,args);
+       va_end(args);
+       return i;
+}
+#endif /* < 2.4.8 */
+
+/*****************************************************************************/
+#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,4,13) )
+
+/**************************************/
+/* PCI DMA MAPPING */
+
+#if defined(CONFIG_HIGHMEM)
+
+#ifndef PCI_DRAM_OFFSET
+#define PCI_DRAM_OFFSET 0
+#endif
+
+u64
+_kc_pci_map_page(struct pci_dev *dev, struct page *page, unsigned long offset,
+                 size_t size, int direction)
+{
+       return (((u64) (page - mem_map) << PAGE_SHIFT) + offset +
+               PCI_DRAM_OFFSET);
+}
+
+#else /* CONFIG_HIGHMEM */
+
+u64
+_kc_pci_map_page(struct pci_dev *dev, struct page *page, unsigned long offset,
+                 size_t size, int direction)
+{
+       return pci_map_single(dev, (void *)page_address(page) + offset, size,
+                             direction);
+}
+
+#endif /* CONFIG_HIGHMEM */
+
+void
+_kc_pci_unmap_page(struct pci_dev *dev, u64 dma_addr, size_t size,
+                   int direction)
+{
+       return pci_unmap_single(dev, dma_addr, size, direction);
+}
+
+#endif /* 2.4.13 => 2.4.3 */
+
+/*****************************************************************************/
+#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,4,3) )
+
+/**************************************/
+/* PCI DRIVER API */
+
+int
+_kc_pci_set_dma_mask(struct pci_dev *dev, dma_addr_t mask)
+{
+       if (!pci_dma_supported(dev, mask))
+               return -EIO;
+       dev->dma_mask = mask;
+       return 0;
+}
+
+int
+_kc_pci_request_regions(struct pci_dev *dev, char *res_name)
+{
+       int i;
+
+       for (i = 0; i < 6; i++) {
+               if (pci_resource_len(dev, i) == 0)
+                       continue;
+
+               if (pci_resource_flags(dev, i) & IORESOURCE_IO) {
+                       if (!request_region(pci_resource_start(dev, i), pci_resource_len(dev, i), res_name)) {
+                               pci_release_regions(dev);
+                               return -EBUSY;
+                       }
+               } else if (pci_resource_flags(dev, i) & IORESOURCE_MEM) {
+                       if (!request_mem_region(pci_resource_start(dev, i), pci_resource_len(dev, i), res_name)) {
+                               pci_release_regions(dev);
+                               return -EBUSY;
+                       }
+               }
+       }
+       return 0;
+}
+
+void
+_kc_pci_release_regions(struct pci_dev *dev)
+{
+       int i;
+
+       for (i = 0; i < 6; i++) {
+               if (pci_resource_len(dev, i) == 0)
+                       continue;
+
+               if (pci_resource_flags(dev, i) & IORESOURCE_IO)
+                       release_region(pci_resource_start(dev, i), pci_resource_len(dev, i));
+
+               else if (pci_resource_flags(dev, i) & IORESOURCE_MEM)
+                       release_mem_region(pci_resource_start(dev, i), pci_resource_len(dev, i));
+       }
+}
+
+/**************************************/
+/* NETWORK DRIVER API */
+
+struct net_device *
+_kc_alloc_etherdev(int sizeof_priv)
+{
+       struct net_device *dev;
+       int alloc_size;
+
+       alloc_size = sizeof(*dev) + sizeof_priv + IFNAMSIZ + 31;
+       dev = kzalloc(alloc_size, GFP_KERNEL);
+       if (!dev)
+               return NULL;
+
+       if (sizeof_priv)
+               dev->priv = (void *) (((unsigned long)(dev + 1) + 31) & ~31);
+       dev->name[0] = '\0';
+       ether_setup(dev);
+
+       return dev;
+}
+
+int
+_kc_is_valid_ether_addr(u8 *addr)
+{
+       const char zaddr[6] = { 0, };
+
+       return !(addr[0] & 1) && memcmp(addr, zaddr, 6);
+}
+
+#endif /* 2.4.3 => 2.4.0 */
+
+/*****************************************************************************/
+#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,4,6) )
+
+int
+_kc_pci_set_power_state(struct pci_dev *dev, int state)
+{
+       return 0;
+}
+
+int
+_kc_pci_enable_wake(struct pci_dev *pdev, u32 state, int enable)
+{
+       return 0;
+}
+
+#endif /* 2.4.6 => 2.4.3 */
+
+/*****************************************************************************/
+#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) )
+void _kc_skb_fill_page_desc(struct sk_buff *skb, int i, struct page *page,
+                            int off, int size)
+{
+       skb_frag_t *frag = &skb_shinfo(skb)->frags[i];
+       frag->page = page;
+       frag->page_offset = off;
+       frag->size = size;
+       skb_shinfo(skb)->nr_frags = i + 1;
+}
+
+/*
+ * Original Copyright:
+ * find_next_bit.c: fallback find next bit implementation
+ *
+ * Copyright (C) 2004 Red Hat, Inc. All Rights Reserved.
+ * Written by David Howells (dhowells@redhat.com)
+ */
+
+/**
+ * find_next_bit - find the next set bit in a memory region
+ * @addr: The address to base the search on
+ * @offset: The bitnumber to start searching at
+ * @size: The maximum size to search
+ */
+unsigned long find_next_bit(const unsigned long *addr, unsigned long size,
+                            unsigned long offset)
+{
+       const unsigned long *p = addr + BITOP_WORD(offset);
+       unsigned long result = offset & ~(BITS_PER_LONG-1);
+       unsigned long tmp;
+
+       if (offset >= size)
+               return size;
+       size -= result;
+       offset %= BITS_PER_LONG;
+       if (offset) {
+               tmp = *(p++);
+               tmp &= (~0UL << offset);
+               if (size < BITS_PER_LONG)
+                       goto found_first;
+               if (tmp)
+                       goto found_middle;
+               size -= BITS_PER_LONG;
+               result += BITS_PER_LONG;
+       }
+       while (size & ~(BITS_PER_LONG-1)) {
+               if ((tmp = *(p++)))
+                       goto found_middle;
+               result += BITS_PER_LONG;
+               size -= BITS_PER_LONG;
+       }
+       if (!size)
+               return result;
+       tmp = *p;
+
+found_first:
+       tmp &= (~0UL >> (BITS_PER_LONG - size));
+       if (tmp == 0UL)         /* Are any bits set? */
+               return result + size;   /* Nope. */
+found_middle:
+       return result + ffs(tmp);
+}
+
+size_t _kc_strlcpy(char *dest, const char *src, size_t size)
+{
+       size_t ret = strlen(src);
+
+       if (size) {
+               size_t len = (ret >= size) ? size - 1 : ret;
+               memcpy(dest, src, len);
+               dest[len] = '\0';
+       }
+       return ret;
+}
+
+#endif /* 2.6.0 => 2.4.6 */
+
+/*****************************************************************************/
+#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,4) )
+int _kc_scnprintf(char * buf, size_t size, const char *fmt, ...)
+{
+       va_list args;
+       int i;
+
+       va_start(args, fmt);
+       i = vsnprintf(buf, size, fmt, args);
+       va_end(args);
+       return (i >= size) ? (size - 1) : i;
+}
+#endif /* < 2.6.4 */
+
+/*****************************************************************************/
+#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,10) )
+DECLARE_BITMAP(_kcompat_node_online_map, MAX_NUMNODES) = {1};
+#endif /* < 2.6.10 */
+
+/*****************************************************************************/
+#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,13) )
+char *_kc_kstrdup(const char *s, unsigned int gfp)
+{
+       size_t len;
+       char *buf;
+
+       if (!s)
+               return NULL;
+
+       len = strlen(s) + 1;
+       buf = kmalloc(len, gfp);
+       if (buf)
+               memcpy(buf, s, len);
+       return buf;
+}
+#endif /* < 2.6.13 */
+
+/*****************************************************************************/
+#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,14) )
+void *_kc_kzalloc(size_t size, int flags)
+{
+       void *ret = kmalloc(size, flags);
+       if (ret)
+               memset(ret, 0, size);
+       return ret;
+}
+#endif /* <= 2.6.13 */
+
+/*****************************************************************************/
+#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) )
+int _kc_skb_pad(struct sk_buff *skb, int pad)
+{
+       int ntail;
+        
+        /* If the skbuff is non linear tailroom is always zero.. */
+        if(!skb_cloned(skb) && skb_tailroom(skb) >= pad) {
+               memset(skb->data+skb->len, 0, pad);
+               return 0;
+        }
+        
+       ntail = skb->data_len + pad - (skb->end - skb->tail);
+       if (likely(skb_cloned(skb) || ntail > 0)) {
+               if (pskb_expand_head(skb, 0, ntail, GFP_ATOMIC));
+                       goto free_skb;
+       }
+
+#ifdef MAX_SKB_FRAGS
+       if (skb_is_nonlinear(skb) &&
+           !__pskb_pull_tail(skb, skb->data_len))
+               goto free_skb;
+
+#endif
+       memset(skb->data + skb->len, 0, pad);
+        return 0;
+
+free_skb:
+       kfree_skb(skb);
+       return -ENOMEM;
+} 
+
+#if (!(RHEL_RELEASE_CODE && RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(5,4)))
+int _kc_pci_save_state(struct pci_dev *pdev)
+{
+       struct net_device *netdev = pci_get_drvdata(pdev);
+       struct adapter_struct *adapter = netdev_priv(netdev);
+       int size = PCI_CONFIG_SPACE_LEN, i;
+       u16 pcie_cap_offset, pcie_link_status;
+
+#if ( LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) )
+       /* no ->dev for 2.4 kernels */
+       WARN_ON(pdev->dev.driver_data == NULL);
+#endif
+       pcie_cap_offset = pci_find_capability(pdev, PCI_CAP_ID_EXP);
+       if (pcie_cap_offset) {
+               if (!pci_read_config_word(pdev,
+                                         pcie_cap_offset + PCIE_LINK_STATUS,
+                                         &pcie_link_status))
+               size = PCIE_CONFIG_SPACE_LEN;
+       }
+       pci_config_space_ich8lan();
+#ifdef HAVE_PCI_ERS
+       if (adapter->config_space == NULL)
+#else
+       WARN_ON(adapter->config_space != NULL);
+#endif
+               adapter->config_space = kmalloc(size, GFP_KERNEL);
+       if (!adapter->config_space) {
+               printk(KERN_ERR "Out of memory in pci_save_state\n");
+               return -ENOMEM;
+       }
+       for (i = 0; i < (size / 4); i++)
+               pci_read_config_dword(pdev, i * 4, &adapter->config_space[i]);
+       return 0;
+}
+
+void _kc_pci_restore_state(struct pci_dev *pdev)
+{
+       struct net_device *netdev = pci_get_drvdata(pdev);
+       struct adapter_struct *adapter = netdev_priv(netdev);
+       int size = PCI_CONFIG_SPACE_LEN, i;
+       u16 pcie_cap_offset;
+       u16 pcie_link_status;
+
+       if (adapter->config_space != NULL) {
+               pcie_cap_offset = pci_find_capability(pdev, PCI_CAP_ID_EXP);
+               if (pcie_cap_offset &&
+                   !pci_read_config_word(pdev,
+                                         pcie_cap_offset + PCIE_LINK_STATUS,
+                                         &pcie_link_status))
+                       size = PCIE_CONFIG_SPACE_LEN;
+
+               pci_config_space_ich8lan();
+               for (i = 0; i < (size / 4); i++)
+               pci_write_config_dword(pdev, i * 4, adapter->config_space[i]);
+#ifndef HAVE_PCI_ERS
+               kfree(adapter->config_space);
+               adapter->config_space = NULL;
+#endif
+       }
+}
+#endif /* !(RHEL_RELEASE_CODE >= RHEL 5.4) */
+
+#ifdef HAVE_PCI_ERS
+void _kc_free_netdev(struct net_device *netdev)
+{
+       struct adapter_struct *adapter = netdev_priv(netdev);
+
+       if (adapter->config_space != NULL)
+               kfree(adapter->config_space);
+#ifdef CONFIG_SYSFS
+       if (netdev->reg_state == NETREG_UNINITIALIZED) {
+               kfree((char *)netdev - netdev->padded);
+       } else {
+               BUG_ON(netdev->reg_state != NETREG_UNREGISTERED);
+               netdev->reg_state = NETREG_RELEASED;
+               class_device_put(&netdev->class_dev);
+       }
+#else
+       kfree((char *)netdev - netdev->padded);
+#endif
+}
+#endif
+
+void *_kc_kmemdup(const void *src, size_t len, unsigned gfp)
+{
+       void *p;
+
+       p = kzalloc(len, gfp);
+       if (p)
+               memcpy(p, src, len);
+       return p;
+}
+#endif /* <= 2.6.19 */
+
+/*****************************************************************************/
+#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22) )
+/* hexdump code taken from lib/hexdump.c */
+static void _kc_hex_dump_to_buffer(const void *buf, size_t len, int rowsize,
+                       int groupsize, unsigned char *linebuf,
+                       size_t linebuflen, bool ascii)
+{
+       const u8 *ptr = buf;
+       u8 ch;
+       int j, lx = 0;
+       int ascii_column;
+
+       if (rowsize != 16 && rowsize != 32)
+               rowsize = 16;
+
+       if (!len)
+               goto nil;
+       if (len > rowsize)              /* limit to one line at a time */
+               len = rowsize;
+       if ((len % groupsize) != 0)     /* no mixed size output */
+               groupsize = 1;
+
+       switch (groupsize) {
+       case 8: {
+               const u64 *ptr8 = buf;
+               int ngroups = len / groupsize;
+
+               for (j = 0; j < ngroups; j++)
+                       lx += scnprintf((char *)(linebuf + lx), linebuflen - lx,
+                               "%s%16.16llx", j ? " " : "",
+                               (unsigned long long)*(ptr8 + j));
+               ascii_column = 17 * ngroups + 2;
+               break;
+       }
+
+       case 4: {
+               const u32 *ptr4 = buf;
+               int ngroups = len / groupsize;
+
+               for (j = 0; j < ngroups; j++)
+                       lx += scnprintf((char *)(linebuf + lx), linebuflen - lx,
+                               "%s%8.8x", j ? " " : "", *(ptr4 + j));
+               ascii_column = 9 * ngroups + 2;
+               break;
+       }
+
+       case 2: {
+               const u16 *ptr2 = buf;
+               int ngroups = len / groupsize;
+
+               for (j = 0; j < ngroups; j++)
+                       lx += scnprintf((char *)(linebuf + lx), linebuflen - lx,
+                               "%s%4.4x", j ? " " : "", *(ptr2 + j));
+               ascii_column = 5 * ngroups + 2;
+               break;
+       }
+
+       default:
+               for (j = 0; (j < len) && (lx + 3) <= linebuflen; j++) {
+                       ch = ptr[j];
+                       linebuf[lx++] = hex_asc(ch >> 4);
+                       linebuf[lx++] = hex_asc(ch & 0x0f);
+                       linebuf[lx++] = ' ';
+               }
+               if (j)
+                       lx--;
+
+               ascii_column = 3 * rowsize + 2;
+               break;
+       }
+       if (!ascii)
+               goto nil;
+
+       while (lx < (linebuflen - 1) && lx < (ascii_column - 1))
+               linebuf[lx++] = ' ';
+       for (j = 0; (j < len) && (lx + 2) < linebuflen; j++)
+               linebuf[lx++] = (isascii(ptr[j]) && isprint(ptr[j])) ? ptr[j]
+                               : '.';
+nil:
+       linebuf[lx++] = '\0';
+}
+
+void _kc_print_hex_dump(const char *level,
+                       const char *prefix_str, int prefix_type,
+                       int rowsize, int groupsize,
+                       const void *buf, size_t len, bool ascii)
+{
+       const u8 *ptr = buf;
+       int i, linelen, remaining = len;
+       unsigned char linebuf[200];
+
+       if (rowsize != 16 && rowsize != 32)
+               rowsize = 16;
+
+       for (i = 0; i < len; i += rowsize) {
+               linelen = min(remaining, rowsize);
+               remaining -= rowsize;
+               _kc_hex_dump_to_buffer(ptr + i, linelen, rowsize, groupsize,
+                               linebuf, sizeof(linebuf), ascii);
+
+               switch (prefix_type) {
+               case DUMP_PREFIX_ADDRESS:
+                       printk("%s%s%*p: %s\n", level, prefix_str,
+                               (int)(2 * sizeof(void *)), ptr + i, linebuf);
+                       break;
+               case DUMP_PREFIX_OFFSET:
+                       printk("%s%s%.8x: %s\n", level, prefix_str, i, linebuf);
+                       break;
+               default:
+                       printk("%s%s%s\n", level, prefix_str, linebuf);
+                       break;
+               }
+       }
+}
+#endif /* < 2.6.22 */
+
+/*****************************************************************************/
+#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24) )
+#ifdef NAPI
+
+int __kc_adapter_clean(struct net_device *netdev, int *budget)
+{
+       int work_done;
+       int work_to_do = min(*budget, netdev->quota);
+       struct adapter_struct *adapter = netdev_priv(netdev);
+       struct napi_struct *napi = &adapter->rx_ring[0].napi;
+       work_done = napi->poll(napi, work_to_do);
+       *budget -= work_done;
+       netdev->quota -= work_done;
+       return (work_done >= work_to_do) ? 1 : 0;
+}
+#endif /* NAPI */
+#endif /* <= 2.6.24 */
+
+/*****************************************************************************/
+#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,26) )
+void _kc_pci_disable_link_state(struct pci_dev *pdev, int state)
+{
+       struct pci_dev *parent = pdev->bus->self;
+       u16 link_state;
+       int pos;
+
+       if (!parent)
+               return;
+
+       pos = pci_find_capability(parent, PCI_CAP_ID_EXP);
+       if (pos) {
+               pci_read_config_word(parent, pos + PCI_EXP_LNKCTL, &link_state);
+               link_state &= ~state;
+               pci_write_config_word(parent, pos + PCI_EXP_LNKCTL, link_state);
+       }
+}
+#endif /* < 2.6.26 */
+
+/*****************************************************************************/
+#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27) )
+#ifdef HAVE_TX_MQ
+void _kc_netif_tx_stop_all_queues(struct net_device *netdev)
+{
+       struct adapter_struct *adapter = netdev_priv(netdev);
+       int i;
+
+       netif_stop_queue(netdev);
+       if (netif_is_multiqueue(netdev))
+               for (i = 0; i < adapter->num_tx_queues; i++)
+                       netif_stop_subqueue(netdev, i);
+}
+void _kc_netif_tx_wake_all_queues(struct net_device *netdev)
+{
+       struct adapter_struct *adapter = netdev_priv(netdev);
+       int i;
+
+       netif_wake_queue(netdev);
+       if (netif_is_multiqueue(netdev))
+               for (i = 0; i < adapter->num_tx_queues; i++)
+                       netif_wake_subqueue(netdev, i);
+}
+void _kc_netif_tx_start_all_queues(struct net_device *netdev)
+{
+       struct adapter_struct *adapter = netdev_priv(netdev);
+       int i;
+
+       netif_start_queue(netdev);
+       if (netif_is_multiqueue(netdev))
+               for (i = 0; i < adapter->num_tx_queues; i++)
+                       netif_start_subqueue(netdev, i);
+}
+#endif /* HAVE_TX_MQ */
+
+#ifndef __WARN_printf
+void __kc_warn_slowpath(const char *file, int line, const char *fmt, ...)
+{
+       va_list args;
+
+       printk(KERN_WARNING "------------[ cut here ]------------\n");
+       printk(KERN_WARNING "WARNING: at %s:%d %s()\n", file, line);
+       va_start(args, fmt);
+       vprintk(fmt, args);
+       va_end(args);
+
+       dump_stack();
+}
+#endif /* __WARN_printf */
+#endif /* < 2.6.27 */
+
+/*****************************************************************************/
+#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,28) )
+
+int
+_kc_pci_prepare_to_sleep(struct pci_dev *dev)
+{
+       pci_power_t target_state;
+       int error;
+
+       target_state = pci_choose_state(dev, PMSG_SUSPEND);
+
+       pci_enable_wake(dev, target_state, true);
+
+       error = pci_set_power_state(dev, target_state);
+
+       if (error)
+               pci_enable_wake(dev, target_state, false);
+
+       return error;
+}
+
+int
+_kc_pci_wake_from_d3(struct pci_dev *dev, bool enable)
+{
+       int err;
+
+       err = pci_enable_wake(dev, PCI_D3cold, enable);
+       if (err)
+               goto out;
+
+       err = pci_enable_wake(dev, PCI_D3hot, enable);
+
+out:
+       return err;
+}
+
+void _kc_skb_add_rx_frag(struct sk_buff *skb, int i, struct page *page,
+                        int off, int size)
+{
+       skb_fill_page_desc(skb, i, page, off, size);
+       skb->len += size;
+       skb->data_len += size;
+       skb->truesize += size;
+}
+#endif /* < 2.6.28 */
+
+/*****************************************************************************/
+#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30) )
+#endif /* < 2.6.30 */
+
+#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,35) )
+#endif /* < 2.6.35 */
+
+/*****************************************************************************/
+#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,36) )
+static const u32 _kc_flags_dup_features =
+       (ETH_FLAG_LRO | ETH_FLAG_NTUPLE | ETH_FLAG_RXHASH);
+
+u32 _kc_ethtool_op_get_flags(struct net_device *dev)
+{
+       return dev->features & _kc_flags_dup_features;
+}
+
+int _kc_ethtool_op_set_flags(struct net_device *dev, u32 data, u32 supported)
+{
+       if (data & ~supported)
+               return -EINVAL;
+
+       dev->features = ((dev->features & ~_kc_flags_dup_features) |
+                        (data & _kc_flags_dup_features));
+       return 0;
+}
+#endif /* < 2.6.36 */
+
+/******************************************************************************/
+#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,39) )
+#if (!(RHEL_RELEASE_CODE && RHEL_RELEASE_CODE > RHEL_RELEASE_VERSION(6,0)))
+#endif /* !(RHEL_RELEASE_CODE > RHEL_RELEASE_VERSION(6,0)) */
+#endif /* < 2.6.39 */
diff --git a/drivers/net/igbvf/kcompat.h b/drivers/net/igbvf/kcompat.h
new file mode 100644 (file)
index 0000000..c0bb944
--- /dev/null
@@ -0,0 +1,2913 @@
+/*******************************************************************************
+
+  Intel(R) 82576 Virtual Function Linux driver
+  Copyright(c) 1999 - 2012 Intel Corporation.
+
+  This program is free software; you can redistribute it and/or modify it
+  under the terms and conditions of the GNU General Public License,
+  version 2, as published by the Free Software Foundation.
+
+  This program is distributed in the hope it will be useful, but WITHOUT
+  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+  more details.
+
+  You should have received a copy of the GNU General Public License along with
+  this program; if not, write to the Free Software Foundation, Inc.,
+  51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
+
+  The full GNU General Public License is included in this distribution in
+  the file called "COPYING".
+
+  Contact Information:
+  Linux NICS <linux.nics@intel.com>
+  e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
+  Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
+
+*******************************************************************************/
+
+#ifndef _KCOMPAT_H_
+#define _KCOMPAT_H_
+
+#ifndef LINUX_VERSION_CODE
+#include <linux/version.h>
+#else
+#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))
+#endif
+#include <linux/init.h>
+#include <linux/types.h>
+#include <linux/errno.h>
+#include <linux/module.h>
+#include <linux/pci.h>
+#include <linux/netdevice.h>
+#include <linux/etherdevice.h>
+#include <linux/skbuff.h>
+#include <linux/ioport.h>
+#include <linux/slab.h>
+#include <linux/list.h>
+#include <linux/delay.h>
+#include <linux/sched.h>
+#include <linux/in.h>
+#include <linux/ip.h>
+#include <linux/udp.h>
+#include <linux/mii.h>
+#include <linux/vmalloc.h>
+#include <asm/io.h>
+#include <linux/ethtool.h>
+#include <linux/if_vlan.h>
+
+/* NAPI enable/disable flags here */
+#define CONFIG_IGBVF_NAPI
+#define NAPI
+
+#define adapter_struct igbvf_adapter
+#define adapter_q_vector igbvf_ring
+#define CONFIG_IGBVF_MSIX
+
+/* and finally set defines so that the code sees the changes */
+#ifdef NAPI
+#else
+#endif /* NAPI */
+
+/* packet split disable/enable */
+#ifdef DISABLE_PACKET_SPLIT
+#endif /* DISABLE_PACKET_SPLIT */
+
+/* MSI compatibility code for all kernels and drivers */
+#ifdef DISABLE_PCI_MSI
+#undef CONFIG_PCI_MSI
+#endif
+#ifndef CONFIG_PCI_MSI
+#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,8) )
+struct msix_entry {
+       u16 vector; /* kernel uses to write allocated vector */
+       u16 entry;  /* driver uses to specify entry, OS writes */
+};
+#endif
+#undef pci_enable_msi
+#define pci_enable_msi(a) -ENOTSUPP
+#undef pci_disable_msi
+#define pci_disable_msi(a) do {} while (0)
+#undef pci_enable_msix
+#define pci_enable_msix(a, b, c) -ENOTSUPP
+#undef pci_disable_msix
+#define pci_disable_msix(a) do {} while (0)
+#define msi_remove_pci_irq_vectors(a) do {} while (0)
+#endif /* CONFIG_PCI_MSI */
+#ifdef DISABLE_PM
+#undef CONFIG_PM
+#endif
+
+#ifdef DISABLE_NET_POLL_CONTROLLER
+#undef CONFIG_NET_POLL_CONTROLLER
+#endif
+
+#ifndef PMSG_SUSPEND
+#define PMSG_SUSPEND 3
+#endif
+
+/* generic boolean compatibility */
+#undef TRUE
+#undef FALSE
+#define TRUE true
+#define FALSE false
+#ifdef GCC_VERSION
+#if ( GCC_VERSION < 3000 )
+#define _Bool char
+#endif
+#else
+#define _Bool char
+#endif
+
+/* kernels less than 2.4.14 don't have this */
+#ifndef ETH_P_8021Q
+#define ETH_P_8021Q 0x8100
+#endif
+
+#ifndef module_param
+#define module_param(v,t,p) MODULE_PARM(v, "i");
+#endif
+
+#ifndef DMA_64BIT_MASK
+#define DMA_64BIT_MASK  0xffffffffffffffffULL
+#endif
+
+#ifndef DMA_32BIT_MASK
+#define DMA_32BIT_MASK  0x00000000ffffffffULL
+#endif
+
+#ifndef PCI_CAP_ID_EXP
+#define PCI_CAP_ID_EXP 0x10
+#endif
+
+#ifndef PCIE_LINK_STATE_L0S
+#define PCIE_LINK_STATE_L0S 1
+#endif
+#ifndef PCIE_LINK_STATE_L1
+#define PCIE_LINK_STATE_L1 2
+#endif
+
+#ifndef mmiowb
+#ifdef CONFIG_IA64
+#define mmiowb() asm volatile ("mf.a" ::: "memory")
+#else
+#define mmiowb()
+#endif
+#endif
+
+#ifndef SET_NETDEV_DEV
+#define SET_NETDEV_DEV(net, pdev)
+#endif
+
+#if !defined(HAVE_FREE_NETDEV) && ( LINUX_VERSION_CODE < KERNEL_VERSION(3,1,0) )
+#define free_netdev(x) kfree(x)
+#endif
+
+#ifdef HAVE_POLL_CONTROLLER
+#define CONFIG_NET_POLL_CONTROLLER
+#endif
+
+#ifndef SKB_DATAREF_SHIFT
+/* if we do not have the infrastructure to detect if skb_header is cloned
+   just return false in all cases */
+#define skb_header_cloned(x) 0
+#endif
+
+#ifndef NETIF_F_GSO
+#define gso_size tso_size
+#define gso_segs tso_segs
+#endif
+
+#ifndef NETIF_F_GRO
+#define vlan_gro_receive(_napi, _vlgrp, _vlan, _skb) \
+               vlan_hwaccel_receive_skb(_skb, _vlgrp, _vlan)
+#define napi_gro_receive(_napi, _skb) netif_receive_skb(_skb)
+#endif
+
+#ifndef NETIF_F_SCTP_CSUM
+#define NETIF_F_SCTP_CSUM 0
+#endif
+
+#ifndef NETIF_F_LRO
+#define NETIF_F_LRO (1 << 15)
+#endif
+
+#ifndef NETIF_F_NTUPLE
+#define NETIF_F_NTUPLE (1 << 27)
+#endif
+
+#ifndef IPPROTO_SCTP
+#define IPPROTO_SCTP 132
+#endif
+
+#ifndef CHECKSUM_PARTIAL
+#define CHECKSUM_PARTIAL CHECKSUM_HW
+#define CHECKSUM_COMPLETE CHECKSUM_HW
+#endif
+
+#ifndef __read_mostly
+#define __read_mostly
+#endif
+
+#ifndef MII_RESV1
+#define MII_RESV1              0x17            /* Reserved...          */
+#endif
+
+#ifndef unlikely
+#define unlikely(_x) _x
+#define likely(_x) _x
+#endif
+
+#ifndef WARN_ON
+#define WARN_ON(x)
+#endif
+
+#ifndef PCI_DEVICE
+#define PCI_DEVICE(vend,dev) \
+       .vendor = (vend), .device = (dev), \
+       .subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID
+#endif
+
+#ifndef node_online
+#define node_online(node) ((node) == 0)
+#endif
+
+#ifndef num_online_cpus
+#define num_online_cpus() smp_num_cpus
+#endif
+
+#ifndef _LINUX_RANDOM_H
+#include <linux/random.h>
+#endif
+
+#ifndef DECLARE_BITMAP
+#ifndef BITS_TO_LONGS
+#define BITS_TO_LONGS(bits) (((bits)+BITS_PER_LONG-1)/BITS_PER_LONG)
+#endif
+#define DECLARE_BITMAP(name,bits) long name[BITS_TO_LONGS(bits)]
+#endif
+
+#ifndef VLAN_HLEN
+#define VLAN_HLEN 4
+#endif
+
+#ifndef VLAN_ETH_HLEN
+#define VLAN_ETH_HLEN 18
+#endif
+
+#ifndef VLAN_ETH_FRAME_LEN
+#define VLAN_ETH_FRAME_LEN 1518
+#endif
+
+#if !defined(IXGBE_DCA) && !defined(IGB_DCA)
+#define dca_get_tag(b) 0
+#define dca_add_requester(a) -1
+#define dca_remove_requester(b) do { } while(0) 
+#define DCA_PROVIDER_ADD     0x0001
+#define DCA_PROVIDER_REMOVE  0x0002
+#endif
+
+#ifndef DCA_GET_TAG_TWO_ARGS
+#define dca3_get_tag(a,b) dca_get_tag(b)
+#endif
+
+#ifndef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS
+#if defined(__i386__) || defined(__x86_64__)
+#define CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS
+#endif
+#endif
+
+/* taken from 2.6.24 definition in linux/kernel.h */
+#ifndef IS_ALIGNED
+#define IS_ALIGNED(x,a)         (((x) % ((typeof(x))(a))) == 0)
+#endif
+
+#ifndef NETIF_F_HW_VLAN_TX
+struct _kc_vlan_ethhdr {
+       unsigned char   h_dest[ETH_ALEN];
+       unsigned char   h_source[ETH_ALEN];
+       __be16          h_vlan_proto;
+       __be16          h_vlan_TCI;
+       __be16          h_vlan_encapsulated_proto;
+};
+#define vlan_ethhdr _kc_vlan_ethhdr
+struct _kc_vlan_hdr {
+       __be16          h_vlan_TCI;
+       __be16          h_vlan_encapsulated_proto;
+};
+#define vlan_hdr _kc_vlan_hdr
+#define vlan_tx_tag_present(_skb) 0
+#define vlan_tx_tag_get(_skb) 0
+#endif
+
+#ifndef VLAN_PRIO_SHIFT
+#define VLAN_PRIO_SHIFT 13
+#endif
+
+
+#ifndef __GFP_COLD
+#define __GFP_COLD 0
+#endif
+
+/*****************************************************************************/
+/* Installations with ethtool version without eeprom, adapter id, or statistics
+ * support */
+
+#ifndef ETH_GSTRING_LEN
+#define ETH_GSTRING_LEN 32
+#endif
+
+#ifndef ETHTOOL_GSTATS
+#define ETHTOOL_GSTATS 0x1d
+#undef ethtool_drvinfo
+#define ethtool_drvinfo k_ethtool_drvinfo
+struct k_ethtool_drvinfo {
+       u32 cmd;
+       char driver[32];
+       char version[32];
+       char fw_version[32];
+       char bus_info[32];
+       char reserved1[32];
+       char reserved2[16];
+       u32 n_stats;
+       u32 testinfo_len;
+       u32 eedump_len;
+       u32 regdump_len;
+};
+
+struct ethtool_stats {
+       u32 cmd;
+       u32 n_stats;
+       u64 data[0];
+};
+#endif /* ETHTOOL_GSTATS */
+
+#ifndef ETHTOOL_PHYS_ID
+#define ETHTOOL_PHYS_ID 0x1c
+#endif /* ETHTOOL_PHYS_ID */
+
+#ifndef ETHTOOL_GSTRINGS
+#define ETHTOOL_GSTRINGS 0x1b
+enum ethtool_stringset {
+       ETH_SS_TEST             = 0,
+       ETH_SS_STATS,
+};
+struct ethtool_gstrings {
+       u32 cmd;            /* ETHTOOL_GSTRINGS */
+       u32 string_set;     /* string set id e.c. ETH_SS_TEST, etc*/
+       u32 len;            /* number of strings in the string set */
+       u8 data[0];
+};
+#endif /* ETHTOOL_GSTRINGS */
+
+#ifndef ETHTOOL_TEST
+#define ETHTOOL_TEST 0x1a
+enum ethtool_test_flags {
+       ETH_TEST_FL_OFFLINE     = (1 << 0),
+       ETH_TEST_FL_FAILED      = (1 << 1),
+};
+struct ethtool_test {
+       u32 cmd;
+       u32 flags;
+       u32 reserved;
+       u32 len;
+       u64 data[0];
+};
+#endif /* ETHTOOL_TEST */
+
+#ifndef ETHTOOL_GEEPROM
+#define ETHTOOL_GEEPROM 0xb
+#undef ETHTOOL_GREGS
+struct ethtool_eeprom {
+       u32 cmd;
+       u32 magic;
+       u32 offset;
+       u32 len;
+       u8 data[0];
+};
+
+struct ethtool_value {
+       u32 cmd;
+       u32 data;
+};
+#endif /* ETHTOOL_GEEPROM */
+
+#ifndef ETHTOOL_GLINK
+#define ETHTOOL_GLINK 0xa
+#endif /* ETHTOOL_GLINK */
+
+#ifndef ETHTOOL_GWOL
+#define ETHTOOL_GWOL 0x5
+#define ETHTOOL_SWOL 0x6
+#define SOPASS_MAX      6
+struct ethtool_wolinfo {
+       u32 cmd;
+       u32 supported;
+       u32 wolopts;
+       u8 sopass[SOPASS_MAX]; /* SecureOn(tm) password */
+};
+#endif /* ETHTOOL_GWOL */
+
+#ifndef ETHTOOL_GREGS
+#define ETHTOOL_GREGS          0x00000004 /* Get NIC registers */
+#define ethtool_regs _kc_ethtool_regs
+/* for passing big chunks of data */
+struct _kc_ethtool_regs {
+       u32 cmd;
+       u32 version; /* driver-specific, indicates different chips/revs */
+       u32 len; /* bytes */
+       u8 data[0];
+};
+#endif /* ETHTOOL_GREGS */
+
+#ifndef ETHTOOL_GMSGLVL
+#define ETHTOOL_GMSGLVL                0x00000007 /* Get driver message level */
+#endif
+#ifndef ETHTOOL_SMSGLVL
+#define ETHTOOL_SMSGLVL                0x00000008 /* Set driver msg level, priv. */
+#endif
+#ifndef ETHTOOL_NWAY_RST
+#define ETHTOOL_NWAY_RST       0x00000009 /* Restart autonegotiation, priv */
+#endif
+#ifndef ETHTOOL_GLINK
+#define ETHTOOL_GLINK          0x0000000a /* Get link status */
+#endif
+#ifndef ETHTOOL_GEEPROM
+#define ETHTOOL_GEEPROM                0x0000000b /* Get EEPROM data */
+#endif
+#ifndef ETHTOOL_SEEPROM
+#define ETHTOOL_SEEPROM                0x0000000c /* Set EEPROM data */
+#endif
+#ifndef ETHTOOL_GCOALESCE
+#define ETHTOOL_GCOALESCE      0x0000000e /* Get coalesce config */
+/* for configuring coalescing parameters of chip */
+#define ethtool_coalesce _kc_ethtool_coalesce
+struct _kc_ethtool_coalesce {
+       u32     cmd;    /* ETHTOOL_{G,S}COALESCE */
+
+       /* How many usecs to delay an RX interrupt after
+        * a packet arrives.  If 0, only rx_max_coalesced_frames
+        * is used.
+        */
+       u32     rx_coalesce_usecs;
+
+       /* How many packets to delay an RX interrupt after
+        * a packet arrives.  If 0, only rx_coalesce_usecs is
+        * used.  It is illegal to set both usecs and max frames
+        * to zero as this would cause RX interrupts to never be
+        * generated.
+        */
+       u32     rx_max_coalesced_frames;
+
+       /* Same as above two parameters, except that these values
+        * apply while an IRQ is being serviced by the host.  Not
+        * all cards support this feature and the values are ignored
+        * in that case.
+        */
+       u32     rx_coalesce_usecs_irq;
+       u32     rx_max_coalesced_frames_irq;
+
+       /* How many usecs to delay a TX interrupt after
+        * a packet is sent.  If 0, only tx_max_coalesced_frames
+        * is used.
+        */
+       u32     tx_coalesce_usecs;
+
+       /* How many packets to delay a TX interrupt after
+        * a packet is sent.  If 0, only tx_coalesce_usecs is
+        * used.  It is illegal to set both usecs and max frames
+        * to zero as this would cause TX interrupts to never be
+        * generated.
+        */
+       u32     tx_max_coalesced_frames;
+
+       /* Same as above two parameters, except that these values
+        * apply while an IRQ is being serviced by the host.  Not
+        * all cards support this feature and the values are ignored
+        * in that case.
+        */
+       u32     tx_coalesce_usecs_irq;
+       u32     tx_max_coalesced_frames_irq;
+
+       /* How many usecs to delay in-memory statistics
+        * block updates.  Some drivers do not have an in-memory
+        * statistic block, and in such cases this value is ignored.
+        * This value must not be zero.
+        */
+       u32     stats_block_coalesce_usecs;
+
+       /* Adaptive RX/TX coalescing is an algorithm implemented by
+        * some drivers to improve latency under low packet rates and
+        * improve throughput under high packet rates.  Some drivers
+        * only implement one of RX or TX adaptive coalescing.  Anything
+        * not implemented by the driver causes these values to be
+        * silently ignored.
+        */
+       u32     use_adaptive_rx_coalesce;
+       u32     use_adaptive_tx_coalesce;
+
+       /* When the packet rate (measured in packets per second)
+        * is below pkt_rate_low, the {rx,tx}_*_low parameters are
+        * used.
+        */
+       u32     pkt_rate_low;
+       u32     rx_coalesce_usecs_low;
+       u32     rx_max_coalesced_frames_low;
+       u32     tx_coalesce_usecs_low;
+       u32     tx_max_coalesced_frames_low;
+
+       /* When the packet rate is below pkt_rate_high but above
+        * pkt_rate_low (both measured in packets per second) the
+        * normal {rx,tx}_* coalescing parameters are used.
+        */
+
+       /* When the packet rate is (measured in packets per second)
+        * is above pkt_rate_high, the {rx,tx}_*_high parameters are
+        * used.
+        */
+       u32     pkt_rate_high;
+       u32     rx_coalesce_usecs_high;
+       u32     rx_max_coalesced_frames_high;
+       u32     tx_coalesce_usecs_high;
+       u32     tx_max_coalesced_frames_high;
+
+       /* How often to do adaptive coalescing packet rate sampling,
+        * measured in seconds.  Must not be zero.
+        */
+       u32     rate_sample_interval;
+};
+#endif /* ETHTOOL_GCOALESCE */
+
+#ifndef ETHTOOL_SCOALESCE
+#define ETHTOOL_SCOALESCE      0x0000000f /* Set coalesce config. */
+#endif
+#ifndef ETHTOOL_GRINGPARAM
+#define ETHTOOL_GRINGPARAM     0x00000010 /* Get ring parameters */
+/* for configuring RX/TX ring parameters */
+#define ethtool_ringparam _kc_ethtool_ringparam
+struct _kc_ethtool_ringparam {
+       u32     cmd;    /* ETHTOOL_{G,S}RINGPARAM */
+
+       /* Read only attributes.  These indicate the maximum number
+        * of pending RX/TX ring entries the driver will allow the
+        * user to set.
+        */
+       u32     rx_max_pending;
+       u32     rx_mini_max_pending;
+       u32     rx_jumbo_max_pending;
+       u32     tx_max_pending;
+
+       /* Values changeable by the user.  The valid values are
+        * in the range 1 to the "*_max_pending" counterpart above.
+        */
+       u32     rx_pending;
+       u32     rx_mini_pending;
+       u32     rx_jumbo_pending;
+       u32     tx_pending;
+};
+#endif /* ETHTOOL_GRINGPARAM */
+
+#ifndef ETHTOOL_SRINGPARAM
+#define ETHTOOL_SRINGPARAM     0x00000011 /* Set ring parameters, priv. */
+#endif
+#ifndef ETHTOOL_GPAUSEPARAM
+#define ETHTOOL_GPAUSEPARAM    0x00000012 /* Get pause parameters */
+/* for configuring link flow control parameters */
+#define ethtool_pauseparam _kc_ethtool_pauseparam
+struct _kc_ethtool_pauseparam {
+       u32     cmd;    /* ETHTOOL_{G,S}PAUSEPARAM */
+
+       /* If the link is being auto-negotiated (via ethtool_cmd.autoneg
+        * being true) the user may set 'autoneg' here non-zero to have the
+        * pause parameters be auto-negotiated too.  In such a case, the
+        * {rx,tx}_pause values below determine what capabilities are
+        * advertised.
+        *
+        * If 'autoneg' is zero or the link is not being auto-negotiated,
+        * then {rx,tx}_pause force the driver to use/not-use pause
+        * flow control.
+        */
+       u32     autoneg;
+       u32     rx_pause;
+       u32     tx_pause;
+};
+#endif /* ETHTOOL_GPAUSEPARAM */
+
+#ifndef ETHTOOL_SPAUSEPARAM
+#define ETHTOOL_SPAUSEPARAM    0x00000013 /* Set pause parameters. */
+#endif
+#ifndef ETHTOOL_GRXCSUM
+#define ETHTOOL_GRXCSUM                0x00000014 /* Get RX hw csum enable (ethtool_value) */
+#endif
+#ifndef ETHTOOL_SRXCSUM
+#define ETHTOOL_SRXCSUM                0x00000015 /* Set RX hw csum enable (ethtool_value) */
+#endif
+#ifndef ETHTOOL_GTXCSUM
+#define ETHTOOL_GTXCSUM                0x00000016 /* Get TX hw csum enable (ethtool_value) */
+#endif
+#ifndef ETHTOOL_STXCSUM
+#define ETHTOOL_STXCSUM                0x00000017 /* Set TX hw csum enable (ethtool_value) */
+#endif
+#ifndef ETHTOOL_GSG
+#define ETHTOOL_GSG            0x00000018 /* Get scatter-gather enable
+                                           * (ethtool_value) */
+#endif
+#ifndef ETHTOOL_SSG
+#define ETHTOOL_SSG            0x00000019 /* Set scatter-gather enable
+                                           * (ethtool_value). */
+#endif
+#ifndef ETHTOOL_TEST
+#define ETHTOOL_TEST           0x0000001a /* execute NIC self-test, priv. */
+#endif
+#ifndef ETHTOOL_GSTRINGS
+#define ETHTOOL_GSTRINGS       0x0000001b /* get specified string set */
+#endif
+#ifndef ETHTOOL_PHYS_ID
+#define ETHTOOL_PHYS_ID                0x0000001c /* identify the NIC */
+#endif
+#ifndef ETHTOOL_GSTATS
+#define ETHTOOL_GSTATS         0x0000001d /* get NIC-specific statistics */
+#endif
+#ifndef ETHTOOL_GTSO
+#define ETHTOOL_GTSO           0x0000001e /* Get TSO enable (ethtool_value) */
+#endif
+#ifndef ETHTOOL_STSO
+#define ETHTOOL_STSO           0x0000001f /* Set TSO enable (ethtool_value) */
+#endif
+
+#ifndef ETHTOOL_BUSINFO_LEN
+#define ETHTOOL_BUSINFO_LEN    32
+#endif
+
+#ifndef RHEL_RELEASE_CODE
+/* NOTE: RHEL_RELEASE_* introduced in RHEL4.5 */
+#define RHEL_RELEASE_CODE 0
+#endif
+#ifndef RHEL_RELEASE_VERSION
+#define RHEL_RELEASE_VERSION(a,b) (((a) << 8) + (b))
+#endif
+#ifndef AX_RELEASE_CODE
+#define AX_RELEASE_CODE 0
+#endif
+#ifndef AX_RELEASE_VERSION
+#define AX_RELEASE_VERSION(a,b) (((a) << 8) + (b))
+#endif
+
+/* SuSE version macro is the same as Linux kernel version */
+#ifndef SLE_VERSION
+#define SLE_VERSION(a,b,c) KERNEL_VERSION(a,b,c)
+#endif
+#ifndef SLE_VERSION_CODE
+#ifdef CONFIG_SUSE_KERNEL
+/* SLES11 GA is 2.6.27 based */
+#if ( LINUX_VERSION_CODE == KERNEL_VERSION(2,6,27) )
+#define SLE_VERSION_CODE SLE_VERSION(11,0,0)
+#elif ( LINUX_VERSION_CODE == KERNEL_VERSION(2,6,32) )
+/* SLES11 SP1 is 2.6.32 based */
+#define SLE_VERSION_CODE SLE_VERSION(11,1,0)
+#else
+#define SLE_VERSION_CODE 0
+#endif
+#else /* CONFIG_SUSE_KERNEL */
+#define SLE_VERSION_CODE 0
+#endif /* CONFIG_SUSE_KERNEL */
+#endif /* SLE_VERSION_CODE */
+
+#ifdef __KLOCWORK__
+#ifdef ARRAY_SIZE
+#undef ARRAY_SIZE
+#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
+#endif
+#endif /* __KLOCWORK__ */
+
+/*****************************************************************************/
+/* 2.4.3 => 2.4.0 */
+#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,4,3) )
+
+/**************************************/
+/* PCI DRIVER API */
+
+#ifndef pci_set_dma_mask
+#define pci_set_dma_mask _kc_pci_set_dma_mask
+extern int _kc_pci_set_dma_mask(struct pci_dev *dev, dma_addr_t mask);
+#endif
+
+#ifndef pci_request_regions
+#define pci_request_regions _kc_pci_request_regions
+extern int _kc_pci_request_regions(struct pci_dev *pdev, char *res_name);
+#endif
+
+#ifndef pci_release_regions
+#define pci_release_regions _kc_pci_release_regions
+extern void _kc_pci_release_regions(struct pci_dev *pdev);
+#endif
+
+/**************************************/
+/* NETWORK DRIVER API */
+
+#ifndef alloc_etherdev
+#define alloc_etherdev _kc_alloc_etherdev
+extern struct net_device * _kc_alloc_etherdev(int sizeof_priv);
+#endif
+
+#ifndef is_valid_ether_addr
+#define is_valid_ether_addr _kc_is_valid_ether_addr
+extern int _kc_is_valid_ether_addr(u8 *addr);
+#endif
+
+/**************************************/
+/* MISCELLANEOUS */
+
+#ifndef INIT_TQUEUE
+#define INIT_TQUEUE(_tq, _routine, _data)              \
+       do {                                            \
+               INIT_LIST_HEAD(&(_tq)->list);           \
+               (_tq)->sync = 0;                        \
+               (_tq)->routine = _routine;              \
+               (_tq)->data = _data;                    \
+       } while (0)
+#endif
+
+#endif /* 2.4.3 => 2.4.0 */
+
+/*****************************************************************************/
+#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,4,5) )
+/* Generic MII registers. */
+#define MII_BMCR            0x00        /* Basic mode control register */
+#define MII_BMSR            0x01        /* Basic mode status register  */
+#define MII_PHYSID1         0x02        /* PHYS ID 1                   */
+#define MII_PHYSID2         0x03        /* PHYS ID 2                   */
+#define MII_ADVERTISE       0x04        /* Advertisement control reg   */
+#define MII_LPA             0x05        /* Link partner ability reg    */
+#define MII_EXPANSION       0x06        /* Expansion register          */
+/* Basic mode control register. */
+#define BMCR_FULLDPLX           0x0100  /* Full duplex                 */
+#define BMCR_ANENABLE           0x1000  /* Enable auto negotiation     */
+/* Basic mode status register. */
+#define BMSR_ERCAP              0x0001  /* Ext-reg capability          */
+#define BMSR_ANEGCAPABLE        0x0008  /* Able to do auto-negotiation */
+#define BMSR_10HALF             0x0800  /* Can do 10mbps, half-duplex  */
+#define BMSR_10FULL             0x1000  /* Can do 10mbps, full-duplex  */
+#define BMSR_100HALF            0x2000  /* Can do 100mbps, half-duplex */
+#define BMSR_100FULL            0x4000  /* Can do 100mbps, full-duplex */
+/* Advertisement control register. */
+#define ADVERTISE_CSMA          0x0001  /* Only selector supported     */
+#define ADVERTISE_10HALF        0x0020  /* Try for 10mbps half-duplex  */
+#define ADVERTISE_10FULL        0x0040  /* Try for 10mbps full-duplex  */
+#define ADVERTISE_100HALF       0x0080  /* Try for 100mbps half-duplex */
+#define ADVERTISE_100FULL       0x0100  /* Try for 100mbps full-duplex */
+#define ADVERTISE_ALL (ADVERTISE_10HALF | ADVERTISE_10FULL | \
+                       ADVERTISE_100HALF | ADVERTISE_100FULL)
+/* Expansion register for auto-negotiation. */
+#define EXPANSION_ENABLENPAGE   0x0004  /* This enables npage words    */
+#endif
+
+/*****************************************************************************/
+/* 2.4.6 => 2.4.3 */
+#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,4,6) )
+
+#ifndef pci_set_power_state
+#define pci_set_power_state _kc_pci_set_power_state
+extern int _kc_pci_set_power_state(struct pci_dev *dev, int state);
+#endif
+
+#ifndef pci_enable_wake
+#define pci_enable_wake _kc_pci_enable_wake
+extern int _kc_pci_enable_wake(struct pci_dev *pdev, u32 state, int enable);
+#endif
+
+#ifndef pci_disable_device
+#define pci_disable_device _kc_pci_disable_device
+extern void _kc_pci_disable_device(struct pci_dev *pdev);
+#endif
+
+/* PCI PM entry point syntax changed, so don't support suspend/resume */
+#undef CONFIG_PM
+
+#endif /* 2.4.6 => 2.4.3 */
+
+#ifndef HAVE_PCI_SET_MWI
+#define pci_set_mwi(X) pci_write_config_word(X, \
+                              PCI_COMMAND, adapter->hw.bus.pci_cmd_word | \
+                              PCI_COMMAND_INVALIDATE);
+#define pci_clear_mwi(X) pci_write_config_word(X, \
+                              PCI_COMMAND, adapter->hw.bus.pci_cmd_word & \
+                              ~PCI_COMMAND_INVALIDATE);
+#endif
+
+/*****************************************************************************/
+/* 2.4.10 => 2.4.9 */
+#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,4,10) )
+
+/**************************************/
+/* MODULE API */
+
+#ifndef MODULE_LICENSE
+       #define MODULE_LICENSE(X)
+#endif
+
+/**************************************/
+/* OTHER */
+
+#undef min
+#define min(x,y) ({ \
+       const typeof(x) _x = (x);       \
+       const typeof(y) _y = (y);       \
+       (void) (&_x == &_y);            \
+       _x < _y ? _x : _y; })
+
+#undef max
+#define max(x,y) ({ \
+       const typeof(x) _x = (x);       \
+       const typeof(y) _y = (y);       \
+       (void) (&_x == &_y);            \
+       _x > _y ? _x : _y; })
+
+#define min_t(type,x,y) ({ \
+       type _x = (x); \
+       type _y = (y); \
+       _x < _y ? _x : _y; })
+
+#define max_t(type,x,y) ({ \
+       type _x = (x); \
+       type _y = (y); \
+       _x > _y ? _x : _y; })
+
+#ifndef list_for_each_safe
+#define list_for_each_safe(pos, n, head) \
+       for (pos = (head)->next, n = pos->next; pos != (head); \
+               pos = n, n = pos->next)
+#endif
+
+#ifndef ____cacheline_aligned_in_smp
+#ifdef CONFIG_SMP
+#define ____cacheline_aligned_in_smp ____cacheline_aligned
+#else
+#define ____cacheline_aligned_in_smp
+#endif /* CONFIG_SMP */
+#endif
+
+#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,4,8) )
+extern int _kc_snprintf(char * buf, size_t size, const char *fmt, ...);
+#define snprintf(buf, size, fmt, args...) _kc_snprintf(buf, size, fmt, ##args)
+extern int _kc_vsnprintf(char *buf, size_t size, const char *fmt, va_list args);
+#define vsnprintf(buf, size, fmt, args) _kc_vsnprintf(buf, size, fmt, args)
+#else /* 2.4.8 => 2.4.9 */
+extern int snprintf(char * buf, size_t size, const char *fmt, ...);
+extern int vsnprintf(char *buf, size_t size, const char *fmt, va_list args);
+#endif
+#endif /* 2.4.10 -> 2.4.6 */
+
+
+/*****************************************************************************/
+/* 2.4.12 => 2.4.10 */
+#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,4,12) )
+#ifndef HAVE_NETIF_MSG
+#define HAVE_NETIF_MSG 1
+enum {
+       NETIF_MSG_DRV           = 0x0001,
+       NETIF_MSG_PROBE         = 0x0002,
+       NETIF_MSG_LINK          = 0x0004,
+       NETIF_MSG_TIMER         = 0x0008,
+       NETIF_MSG_IFDOWN        = 0x0010,
+       NETIF_MSG_IFUP          = 0x0020,
+       NETIF_MSG_RX_ERR        = 0x0040,
+       NETIF_MSG_TX_ERR        = 0x0080,
+       NETIF_MSG_TX_QUEUED     = 0x0100,
+       NETIF_MSG_INTR          = 0x0200,
+       NETIF_MSG_TX_DONE       = 0x0400,
+       NETIF_MSG_RX_STATUS     = 0x0800,
+       NETIF_MSG_PKTDATA       = 0x1000,
+       NETIF_MSG_HW            = 0x2000,
+       NETIF_MSG_WOL           = 0x4000,
+};
+
+#define netif_msg_drv(p)       ((p)->msg_enable & NETIF_MSG_DRV)
+#define netif_msg_probe(p)     ((p)->msg_enable & NETIF_MSG_PROBE)
+#define netif_msg_link(p)      ((p)->msg_enable & NETIF_MSG_LINK)
+#define netif_msg_timer(p)     ((p)->msg_enable & NETIF_MSG_TIMER)
+#define netif_msg_ifdown(p)    ((p)->msg_enable & NETIF_MSG_IFDOWN)
+#define netif_msg_ifup(p)      ((p)->msg_enable & NETIF_MSG_IFUP)
+#define netif_msg_rx_err(p)    ((p)->msg_enable & NETIF_MSG_RX_ERR)
+#define netif_msg_tx_err(p)    ((p)->msg_enable & NETIF_MSG_TX_ERR)
+#define netif_msg_tx_queued(p) ((p)->msg_enable & NETIF_MSG_TX_QUEUED)
+#define netif_msg_intr(p)      ((p)->msg_enable & NETIF_MSG_INTR)
+#define netif_msg_tx_done(p)   ((p)->msg_enable & NETIF_MSG_TX_DONE)
+#define netif_msg_rx_status(p) ((p)->msg_enable & NETIF_MSG_RX_STATUS)
+#define netif_msg_pktdata(p)   ((p)->msg_enable & NETIF_MSG_PKTDATA)
+#endif /* !HAVE_NETIF_MSG */
+#endif /* 2.4.12 => 2.4.10 */
+
+/*****************************************************************************/
+/* 2.4.13 => 2.4.12 */
+#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,4,13) )
+
+/**************************************/
+/* PCI DMA MAPPING */
+
+#ifndef virt_to_page
+       #define virt_to_page(v) (mem_map + (virt_to_phys(v) >> PAGE_SHIFT))
+#endif
+
+#ifndef pci_map_page
+#define pci_map_page _kc_pci_map_page
+extern u64 _kc_pci_map_page(struct pci_dev *dev, struct page *page, unsigned long offset, size_t size, int direction);
+#endif
+
+#ifndef pci_unmap_page
+#define pci_unmap_page _kc_pci_unmap_page
+extern void _kc_pci_unmap_page(struct pci_dev *dev, u64 dma_addr, size_t size, int direction);
+#endif
+
+/* pci_set_dma_mask takes dma_addr_t, which is only 32-bits prior to 2.4.13 */
+
+#undef DMA_32BIT_MASK
+#define DMA_32BIT_MASK 0xffffffff
+#undef DMA_64BIT_MASK
+#define DMA_64BIT_MASK 0xffffffff
+
+/**************************************/
+/* OTHER */
+
+#ifndef cpu_relax
+#define cpu_relax()    rep_nop()
+#endif
+
+struct vlan_ethhdr {
+       unsigned char h_dest[ETH_ALEN];
+       unsigned char h_source[ETH_ALEN];
+       unsigned short h_vlan_proto;
+       unsigned short h_vlan_TCI;
+       unsigned short h_vlan_encapsulated_proto;
+};
+#endif /* 2.4.13 => 2.4.12 */
+
+/*****************************************************************************/
+/* 2.4.17 => 2.4.12 */
+#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,4,17) )
+
+#ifndef __devexit_p
+       #define __devexit_p(x) &(x)
+#endif
+
+#endif /* 2.4.17 => 2.4.13 */
+
+/*****************************************************************************/
+#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,4,18) )
+#define NETIF_MSG_HW   0x2000
+#define NETIF_MSG_WOL  0x4000
+
+#ifndef netif_msg_hw
+#define netif_msg_hw(p)                ((p)->msg_enable & NETIF_MSG_HW)
+#endif
+#ifndef netif_msg_wol
+#define netif_msg_wol(p)       ((p)->msg_enable & NETIF_MSG_WOL)
+#endif
+#endif /* 2.4.18 */
+
+/*****************************************************************************/
+
+/*****************************************************************************/
+/* 2.4.20 => 2.4.19 */
+#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,4,20) )
+
+/* we won't support NAPI on less than 2.4.20 */
+#ifdef NAPI
+#undef NAPI
+#endif
+
+#endif /* 2.4.20 => 2.4.19 */
+
+/*****************************************************************************/
+/* 2.4.22 => 2.4.17 */
+#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,4,22) )
+#define pci_name(x)    ((x)->slot_name)
+#endif
+
+/*****************************************************************************/
+/*****************************************************************************/
+/* 2.4.23 => 2.4.22 */
+#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,4,23) )
+/*****************************************************************************/
+#ifdef NAPI
+#ifndef netif_poll_disable
+#define netif_poll_disable(x) _kc_netif_poll_disable(x)
+static inline void _kc_netif_poll_disable(struct net_device *netdev)
+{
+       while (test_and_set_bit(__LINK_STATE_RX_SCHED, &netdev->state)) {
+               /* No hurry */
+               current->state = TASK_INTERRUPTIBLE;
+               schedule_timeout(1);
+       }
+}
+#endif
+#ifndef netif_poll_enable
+#define netif_poll_enable(x) _kc_netif_poll_enable(x)
+static inline void _kc_netif_poll_enable(struct net_device *netdev)
+{
+       clear_bit(__LINK_STATE_RX_SCHED, &netdev->state);
+}
+#endif
+#endif /* NAPI */
+#ifndef netif_tx_disable
+#define netif_tx_disable(x) _kc_netif_tx_disable(x)
+static inline void _kc_netif_tx_disable(struct net_device *dev)
+{
+       spin_lock_bh(&dev->xmit_lock);
+       netif_stop_queue(dev);
+       spin_unlock_bh(&dev->xmit_lock);
+}
+#endif
+#else /* 2.4.23 => 2.4.22 */
+#define HAVE_SCTP
+#endif /* 2.4.23 => 2.4.22 */
+
+/*****************************************************************************/
+/* 2.6.4 => 2.6.0 */
+#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,4,25) || \
+    ( LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) && \
+      LINUX_VERSION_CODE < KERNEL_VERSION(2,6,4) ) )
+#define ETHTOOL_OPS_COMPAT
+#endif /* 2.6.4 => 2.6.0 */
+
+/*****************************************************************************/
+/* 2.5.71 => 2.4.x */
+#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,5,71) )
+#define sk_protocol protocol
+#define pci_get_device pci_find_device
+#endif /* 2.5.70 => 2.4.x */
+
+/*****************************************************************************/
+/* < 2.4.27 or 2.6.0 <= 2.6.5 */
+#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,4,27) || \
+    ( LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) && \
+      LINUX_VERSION_CODE < KERNEL_VERSION(2,6,5) ) )
+
+#ifndef netif_msg_init
+#define netif_msg_init _kc_netif_msg_init
+static inline u32 _kc_netif_msg_init(int debug_value, int default_msg_enable_bits)
+{
+       /* use default */
+       if (debug_value < 0 || debug_value >= (sizeof(u32) * 8))
+               return default_msg_enable_bits;
+       if (debug_value == 0) /* no output */
+               return 0;
+       /* set low N bits */
+       return (1 << debug_value) -1;
+}
+#endif
+
+#endif /* < 2.4.27 or 2.6.0 <= 2.6.5 */
+/*****************************************************************************/
+#if (( LINUX_VERSION_CODE < KERNEL_VERSION(2,4,27) ) || \
+     (( LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) ) && \
+      ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,3) )))
+#define netdev_priv(x) x->priv
+#endif
+
+/*****************************************************************************/
+/* <= 2.5.0 */
+#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) )
+#include <linux/rtnetlink.h>
+#undef pci_register_driver
+#define pci_register_driver pci_module_init
+
+/*
+ * Most of the dma compat code is copied/modifed from the 2.4.37
+ * /include/linux/libata-compat.h header file
+ */
+/* These definitions mirror those in pci.h, so they can be used
+ * interchangeably with their PCI_ counterparts */
+enum dma_data_direction {
+       DMA_BIDIRECTIONAL = 0,
+       DMA_TO_DEVICE = 1,
+       DMA_FROM_DEVICE = 2,
+       DMA_NONE = 3,
+};
+
+struct device {
+       struct pci_dev pdev;
+};
+
+static inline struct pci_dev *to_pci_dev (struct device *dev)
+{
+       return (struct pci_dev *) dev;
+}
+static inline struct device *pci_dev_to_dev(struct pci_dev *pdev)
+{
+       return (struct device *) pdev;
+}
+
+#define pdev_printk(lvl, pdev, fmt, args...)   \
+       printk("%s %s: " fmt, lvl, pci_name(pdev), ## args)
+#define dev_err(dev, fmt, args...)            \
+       pdev_printk(KERN_ERR, to_pci_dev(dev), fmt, ## args)
+#define dev_info(dev, fmt, args...)            \
+       pdev_printk(KERN_INFO, to_pci_dev(dev), fmt, ## args)
+#define dev_warn(dev, fmt, args...)            \
+       pdev_printk(KERN_WARNING, to_pci_dev(dev), fmt, ## args)
+
+/* NOTE: dangerous! we ignore the 'gfp' argument */
+#define dma_alloc_coherent(dev,sz,dma,gfp) \
+       pci_alloc_consistent(to_pci_dev(dev),(sz),(dma))
+#define dma_free_coherent(dev,sz,addr,dma_addr) \
+       pci_free_consistent(to_pci_dev(dev),(sz),(addr),(dma_addr))
+
+#define dma_map_page(dev,a,b,c,d) \
+       pci_map_page(to_pci_dev(dev),(a),(b),(c),(d))
+#define dma_unmap_page(dev,a,b,c) \
+       pci_unmap_page(to_pci_dev(dev),(a),(b),(c))
+
+#define dma_map_single(dev,a,b,c) \
+       pci_map_single(to_pci_dev(dev),(a),(b),(c))
+#define dma_unmap_single(dev,a,b,c) \
+       pci_unmap_single(to_pci_dev(dev),(a),(b),(c))
+
+#define dma_sync_single(dev,a,b,c) \
+       pci_dma_sync_single(to_pci_dev(dev),(a),(b),(c))
+
+/* for range just sync everything, that's all the pci API can do */
+#define dma_sync_single_range(dev,addr,off,sz,dir) \
+       pci_dma_sync_single(to_pci_dev(dev),(addr),(off)+(sz),(dir))
+
+#define dma_set_mask(dev,mask) \
+       pci_set_dma_mask(to_pci_dev(dev),(mask))
+
+/* hlist_* code - double linked lists */
+struct hlist_head {
+       struct hlist_node *first;
+};
+
+struct hlist_node {
+       struct hlist_node *next, **pprev;
+};
+
+static inline void __hlist_del(struct hlist_node *n)
+{
+       struct hlist_node *next = n->next;
+       struct hlist_node **pprev = n->pprev;
+       *pprev = next;
+       if (next)
+       next->pprev = pprev;
+}
+
+static inline void hlist_del(struct hlist_node *n)
+{
+       __hlist_del(n);
+       n->next = NULL;
+       n->pprev = NULL;
+}
+
+static inline void hlist_add_head(struct hlist_node *n, struct hlist_head *h)
+{
+       struct hlist_node *first = h->first;
+       n->next = first;
+       if (first)
+               first->pprev = &n->next;
+       h->first = n;
+       n->pprev = &h->first;
+}
+
+static inline int hlist_empty(const struct hlist_head *h)
+{
+       return !h->first;
+}
+#define HLIST_HEAD_INIT { .first = NULL }
+#define HLIST_HEAD(name) struct hlist_head name = {  .first = NULL }
+#define INIT_HLIST_HEAD(ptr) ((ptr)->first = NULL)
+static inline void INIT_HLIST_NODE(struct hlist_node *h)
+{
+       h->next = NULL;
+       h->pprev = NULL;
+}
+#define hlist_entry(ptr, type, member) container_of(ptr,type,member)
+
+#define hlist_for_each_entry(tpos, pos, head, member)                    \
+       for (pos = (head)->first;                                        \
+            pos && ({ prefetch(pos->next); 1;}) &&                      \
+               ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \
+            pos = pos->next)
+
+#define hlist_for_each_entry_safe(tpos, pos, n, head, member)            \
+       for (pos = (head)->first;                                        \
+            pos && ({ n = pos->next; 1; }) &&                           \
+               ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \
+            pos = n)
+
+#ifndef might_sleep
+#define might_sleep()
+#endif
+#else
+static inline struct device *pci_dev_to_dev(struct pci_dev *pdev)
+{
+       return &pdev->dev;
+}
+#endif /* <= 2.5.0 */
+
+/*****************************************************************************/
+/* 2.5.28 => 2.4.23 */
+#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,5,28) )
+
+static inline void _kc_synchronize_irq(void)
+{
+       synchronize_irq();
+}
+#undef synchronize_irq
+#define synchronize_irq(X) _kc_synchronize_irq()
+
+#include <linux/tqueue.h>
+#define work_struct tq_struct
+#undef INIT_WORK
+#define INIT_WORK(a,b) INIT_TQUEUE(a,(void (*)(void *))b,a)
+#undef container_of
+#define container_of list_entry
+#define schedule_work schedule_task
+#define flush_scheduled_work flush_scheduled_tasks
+#define cancel_work_sync(x) flush_scheduled_work()
+
+#endif /* 2.5.28 => 2.4.17 */
+
+/*****************************************************************************/
+/* 2.6.0 => 2.5.28 */
+#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) )
+#undef get_cpu
+#define get_cpu() smp_processor_id()
+#undef put_cpu
+#define put_cpu() do { } while(0)
+#define MODULE_INFO(version, _version)
+#ifndef CONFIG_E1000_DISABLE_PACKET_SPLIT
+#define CONFIG_E1000_DISABLE_PACKET_SPLIT 1
+#endif
+#ifndef CONFIG_IGB_DISABLE_PACKET_SPLIT
+#define CONFIG_IGB_DISABLE_PACKET_SPLIT 1
+#endif
+
+#define dma_set_coherent_mask(dev,mask) 1
+
+#undef dev_put
+#define dev_put(dev) __dev_put(dev)
+
+#ifndef skb_fill_page_desc
+#define skb_fill_page_desc _kc_skb_fill_page_desc
+extern void _kc_skb_fill_page_desc(struct sk_buff *skb, int i, struct page *page, int off, int size);
+#endif
+
+#undef ALIGN
+#define ALIGN(x,a) (((x)+(a)-1)&~((a)-1))
+
+#ifndef page_count
+#define page_count(p) atomic_read(&(p)->count)
+#endif
+
+#ifdef MAX_NUMNODES
+#undef MAX_NUMNODES
+#endif
+#define MAX_NUMNODES 1
+
+/* find_first_bit and find_next bit are not defined for most
+ * 2.4 kernels (except for the redhat 2.4.21 kernels
+ */
+#include <linux/bitops.h>
+#define BITOP_WORD(nr)          ((nr) / BITS_PER_LONG)
+#undef find_next_bit
+#define find_next_bit _kc_find_next_bit
+extern unsigned long _kc_find_next_bit(const unsigned long *addr,
+                                       unsigned long size,
+                                       unsigned long offset);
+#define find_first_bit(addr, size) find_next_bit((addr), (size), 0)
+
+
+#ifndef netdev_name
+static inline const char *_kc_netdev_name(const struct net_device *dev)
+{
+       if (strchr(dev->name, '%'))
+               return "(unregistered net_device)";
+       return dev->name;
+}
+#define netdev_name(netdev)    _kc_netdev_name(netdev)
+#endif /* netdev_name */
+
+#ifndef strlcpy
+#define strlcpy _kc_strlcpy
+extern size_t _kc_strlcpy(char *dest, const char *src, size_t size);
+#endif /* strlcpy */
+
+#endif /* 2.6.0 => 2.5.28 */
+
+/*****************************************************************************/
+/* 2.6.4 => 2.6.0 */
+#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,4) )
+#define MODULE_VERSION(_version) MODULE_INFO(version, _version)
+#endif /* 2.6.4 => 2.6.0 */
+
+/*****************************************************************************/
+/* 2.6.5 => 2.6.0 */
+#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,5) )
+#define dma_sync_single_for_cpu                dma_sync_single
+#define dma_sync_single_for_device     dma_sync_single
+#define dma_sync_single_range_for_cpu          dma_sync_single_range
+#define dma_sync_single_range_for_device       dma_sync_single_range
+#ifndef pci_dma_mapping_error
+#define pci_dma_mapping_error _kc_pci_dma_mapping_error
+static inline int _kc_pci_dma_mapping_error(dma_addr_t dma_addr)
+{
+       return dma_addr == 0;
+}
+#endif
+#endif /* 2.6.5 => 2.6.0 */
+
+/*****************************************************************************/
+#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,4) )
+extern int _kc_scnprintf(char * buf, size_t size, const char *fmt, ...);
+#define scnprintf(buf, size, fmt, args...) _kc_scnprintf(buf, size, fmt, ##args)
+#endif /* < 2.6.4 */
+
+/*****************************************************************************/
+#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,6) )
+/* taken from 2.6 include/linux/bitmap.h */
+#undef bitmap_zero
+#define bitmap_zero _kc_bitmap_zero
+static inline void _kc_bitmap_zero(unsigned long *dst, int nbits)
+{
+        if (nbits <= BITS_PER_LONG)
+                *dst = 0UL;
+        else {
+                int len = BITS_TO_LONGS(nbits) * sizeof(unsigned long);
+                memset(dst, 0, len);
+        }
+}
+#define random_ether_addr _kc_random_ether_addr
+static inline void _kc_random_ether_addr(u8 *addr)
+{
+        get_random_bytes(addr, ETH_ALEN);
+        addr[0] &= 0xfe; /* clear multicast */
+        addr[0] |= 0x02; /* set local assignment */
+}
+#define page_to_nid(x) 0
+
+#endif /* < 2.6.6 */
+
+/*****************************************************************************/
+#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,7) )
+#undef if_mii
+#define if_mii _kc_if_mii
+static inline struct mii_ioctl_data *_kc_if_mii(struct ifreq *rq)
+{
+       return (struct mii_ioctl_data *) &rq->ifr_ifru;
+}
+
+#ifndef __force
+#define __force
+#endif
+#endif /* < 2.6.7 */
+
+/*****************************************************************************/
+#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,8) )
+#ifndef PCI_EXP_DEVCTL
+#define PCI_EXP_DEVCTL 8
+#endif
+#ifndef PCI_EXP_DEVCTL_CERE
+#define PCI_EXP_DEVCTL_CERE 0x0001
+#endif
+#define msleep(x)      do { set_current_state(TASK_UNINTERRUPTIBLE); \
+                               schedule_timeout((x * HZ)/1000 + 2); \
+                       } while (0)
+
+#endif /* < 2.6.8 */
+
+/*****************************************************************************/
+#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,9))
+#include <net/dsfield.h>
+#define __iomem
+
+#ifndef kcalloc
+#define kcalloc(n, size, flags) _kc_kzalloc(((n) * (size)), flags)
+extern void *_kc_kzalloc(size_t size, int flags);
+#endif
+#define MSEC_PER_SEC    1000L
+static inline unsigned int _kc_jiffies_to_msecs(const unsigned long j)
+{
+#if HZ <= MSEC_PER_SEC && !(MSEC_PER_SEC % HZ)
+       return (MSEC_PER_SEC / HZ) * j;
+#elif HZ > MSEC_PER_SEC && !(HZ % MSEC_PER_SEC)
+       return (j + (HZ / MSEC_PER_SEC) - 1)/(HZ / MSEC_PER_SEC);
+#else
+       return (j * MSEC_PER_SEC) / HZ;
+#endif
+}
+static inline unsigned long _kc_msecs_to_jiffies(const unsigned int m)
+{
+       if (m > _kc_jiffies_to_msecs(MAX_JIFFY_OFFSET))
+               return MAX_JIFFY_OFFSET;
+#if HZ <= MSEC_PER_SEC && !(MSEC_PER_SEC % HZ)
+       return (m + (MSEC_PER_SEC / HZ) - 1) / (MSEC_PER_SEC / HZ);
+#elif HZ > MSEC_PER_SEC && !(HZ % MSEC_PER_SEC)
+       return m * (HZ / MSEC_PER_SEC);
+#else
+       return (m * HZ + MSEC_PER_SEC - 1) / MSEC_PER_SEC;
+#endif
+}
+
+#define msleep_interruptible _kc_msleep_interruptible
+static inline unsigned long _kc_msleep_interruptible(unsigned int msecs)
+{
+       unsigned long timeout = _kc_msecs_to_jiffies(msecs) + 1;
+
+       while (timeout && !signal_pending(current)) {
+               __set_current_state(TASK_INTERRUPTIBLE);
+               timeout = schedule_timeout(timeout);
+       }
+       return _kc_jiffies_to_msecs(timeout);
+}
+
+/* Basic mode control register. */
+#define BMCR_SPEED1000         0x0040  /* MSB of Speed (1000)         */
+
+#ifndef __le16
+#define __le16 u16
+#endif
+#ifndef __le32
+#define __le32 u32
+#endif
+#ifndef __le64
+#define __le64 u64
+#endif
+#ifndef __be16
+#define __be16 u16
+#endif
+#ifndef __be32
+#define __be32 u32
+#endif
+#ifndef __be64
+#define __be64 u64
+#endif
+
+static inline struct vlan_ethhdr *vlan_eth_hdr(const struct sk_buff *skb)
+{
+       return (struct vlan_ethhdr *)skb->mac.raw;
+}
+
+/* Wake-On-Lan options. */
+#define WAKE_PHY               (1 << 0)
+#define WAKE_UCAST             (1 << 1)
+#define WAKE_MCAST             (1 << 2)
+#define WAKE_BCAST             (1 << 3)
+#define WAKE_ARP               (1 << 4)
+#define WAKE_MAGIC             (1 << 5)
+#define WAKE_MAGICSECURE       (1 << 6) /* only meaningful if WAKE_MAGIC */
+
+#define skb_header_pointer _kc_skb_header_pointer
+static inline void *_kc_skb_header_pointer(const struct sk_buff *skb,
+                                           int offset, int len, void *buffer)
+{
+       int hlen = skb_headlen(skb);
+
+       if (hlen - offset >= len)
+               return skb->data + offset;
+
+#ifdef MAX_SKB_FRAGS
+       if (skb_copy_bits(skb, offset, buffer, len) < 0)
+               return NULL;
+
+       return buffer;
+#else
+       return NULL;
+#endif
+
+#ifndef NETDEV_TX_OK
+#define NETDEV_TX_OK 0
+#endif
+#ifndef NETDEV_TX_BUSY
+#define NETDEV_TX_BUSY 1
+#endif
+#ifndef NETDEV_TX_LOCKED
+#define NETDEV_TX_LOCKED -1
+#endif
+}
+
+#ifndef __bitwise
+#define __bitwise
+#endif
+#endif /* < 2.6.9 */
+
+/*****************************************************************************/
+#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,10) )
+#ifdef module_param_array_named
+#undef module_param_array_named
+#define module_param_array_named(name, array, type, nump, perm)          \
+       static struct kparam_array __param_arr_##name                    \
+       = { ARRAY_SIZE(array), nump, param_set_##type, param_get_##type, \
+           sizeof(array[0]), array };                                   \
+       module_param_call(name, param_array_set, param_array_get,        \
+                         &__param_arr_##name, perm)
+#endif /* module_param_array_named */
+/*
+ * num_online is broken for all < 2.6.10 kernels.  This is needed to support
+ * Node module parameter of ixgbe.
+ */
+#undef num_online_nodes
+#define num_online_nodes(n) 1
+extern DECLARE_BITMAP(_kcompat_node_online_map, MAX_NUMNODES);
+#undef node_online_map
+#define node_online_map _kcompat_node_online_map
+#endif /* < 2.6.10 */
+
+/*****************************************************************************/
+#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,11) )
+#define PCI_D0      0
+#define PCI_D1      1
+#define PCI_D2      2
+#define PCI_D3hot   3
+#define PCI_D3cold  4
+typedef int pci_power_t;
+#define pci_choose_state(pdev,state) state
+#define PMSG_SUSPEND 3
+#define PCI_EXP_LNKCTL 16
+
+#undef NETIF_F_LLTX
+
+#ifndef ARCH_HAS_PREFETCH
+#define prefetch(X)
+#endif
+
+#ifndef NET_IP_ALIGN
+#define NET_IP_ALIGN 2
+#endif
+
+#define KC_USEC_PER_SEC        1000000L
+#define usecs_to_jiffies _kc_usecs_to_jiffies
+static inline unsigned int _kc_jiffies_to_usecs(const unsigned long j)
+{
+#if HZ <= KC_USEC_PER_SEC && !(KC_USEC_PER_SEC % HZ)
+       return (KC_USEC_PER_SEC / HZ) * j;
+#elif HZ > KC_USEC_PER_SEC && !(HZ % KC_USEC_PER_SEC)
+       return (j + (HZ / KC_USEC_PER_SEC) - 1)/(HZ / KC_USEC_PER_SEC);
+#else
+       return (j * KC_USEC_PER_SEC) / HZ;
+#endif
+}
+static inline unsigned long _kc_usecs_to_jiffies(const unsigned int m)
+{
+       if (m > _kc_jiffies_to_usecs(MAX_JIFFY_OFFSET))
+               return MAX_JIFFY_OFFSET;
+#if HZ <= KC_USEC_PER_SEC && !(KC_USEC_PER_SEC % HZ)
+       return (m + (KC_USEC_PER_SEC / HZ) - 1) / (KC_USEC_PER_SEC / HZ);
+#elif HZ > KC_USEC_PER_SEC && !(HZ % KC_USEC_PER_SEC)
+       return m * (HZ / KC_USEC_PER_SEC);
+#else
+       return (m * HZ + KC_USEC_PER_SEC - 1) / KC_USEC_PER_SEC;
+#endif
+}
+#endif /* < 2.6.11 */
+
+/*****************************************************************************/
+#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,12) )
+#include <linux/reboot.h>
+#define USE_REBOOT_NOTIFIER
+
+/* Generic MII registers. */
+#define MII_CTRL1000        0x09        /* 1000BASE-T control          */
+#define MII_STAT1000        0x0a        /* 1000BASE-T status           */
+/* Advertisement control register. */
+#define ADVERTISE_PAUSE_CAP     0x0400  /* Try for pause               */
+#define ADVERTISE_PAUSE_ASYM    0x0800  /* Try for asymmetric pause     */
+/* 1000BASE-T Control register */
+#define ADVERTISE_1000FULL      0x0200  /* Advertise 1000BASE-T full duplex */
+#ifndef is_zero_ether_addr
+#define is_zero_ether_addr _kc_is_zero_ether_addr
+static inline int _kc_is_zero_ether_addr(const u8 *addr)
+{
+       return !(addr[0] | addr[1] | addr[2] | addr[3] | addr[4] | addr[5]);
+}
+#endif /* is_zero_ether_addr */
+#ifndef is_multicast_ether_addr
+#define is_multicast_ether_addr _kc_is_multicast_ether_addr
+static inline int _kc_is_multicast_ether_addr(const u8 *addr)
+{
+       return addr[0] & 0x01;
+}
+#endif /* is_multicast_ether_addr */
+#endif /* < 2.6.12 */
+
+/*****************************************************************************/
+#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,13) )
+#ifndef kstrdup
+#define kstrdup _kc_kstrdup
+extern char *_kc_kstrdup(const char *s, unsigned int gfp);
+#endif
+#endif /* < 2.6.13 */
+
+/*****************************************************************************/
+#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,14) )
+#define pm_message_t u32
+#ifndef kzalloc
+#define kzalloc _kc_kzalloc
+extern void *_kc_kzalloc(size_t size, int flags);
+#endif
+
+/* Generic MII registers. */
+#define MII_ESTATUS        0x0f        /* Extended Status */
+/* Basic mode status register. */
+#define BMSR_ESTATEN           0x0100  /* Extended Status in R15 */
+/* Extended status register. */
+#define ESTATUS_1000_TFULL     0x2000  /* Can do 1000BT Full */
+#define ESTATUS_1000_THALF     0x1000  /* Can do 1000BT Half */
+
+#define ADVERTISED_Pause       (1 << 13)
+#define ADVERTISED_Asym_Pause  (1 << 14)
+
+#if (!(RHEL_RELEASE_CODE && \
+       (RHEL_RELEASE_CODE > RHEL_RELEASE_VERSION(4,3)) && \
+       (RHEL_RELEASE_CODE < RHEL_RELEASE_VERSION(5,0))))
+#if ((LINUX_VERSION_CODE == KERNEL_VERSION(2,6,9)) && !defined(gfp_t))
+#define gfp_t unsigned
+#else
+typedef unsigned gfp_t;
+#endif
+#endif /* !RHEL4.3->RHEL5.0 */
+#endif /* < 2.6.14 */
+
+/*****************************************************************************/
+#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,15) )
+#ifndef vmalloc_node
+#define vmalloc_node(a,b) vmalloc(a)
+#endif /* vmalloc_node*/
+
+#define setup_timer(_timer, _function, _data) \
+do { \
+       (_timer)->function = _function; \
+       (_timer)->data = _data; \
+       init_timer(_timer); \
+} while (0)
+#ifndef device_can_wakeup
+#define device_can_wakeup(dev) (1)
+#endif
+#ifndef device_set_wakeup_enable
+#define device_set_wakeup_enable(dev, val)     do{}while(0)
+#endif
+#ifndef device_init_wakeup
+#define device_init_wakeup(dev,val) do {} while (0)
+#endif
+static inline unsigned _kc_compare_ether_addr(const u8 *addr1, const u8 *addr2)
+{
+       const u16 *a = (const u16 *) addr1;
+       const u16 *b = (const u16 *) addr2;
+
+       return ((a[0] ^ b[0]) | (a[1] ^ b[1]) | (a[2] ^ b[2])) != 0;
+}
+#undef compare_ether_addr
+#define compare_ether_addr(addr1, addr2) _kc_compare_ether_addr(addr1, addr2)
+#endif /* < 2.6.15 */
+
+/*****************************************************************************/
+#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,16) )
+#undef DEFINE_MUTEX
+#define DEFINE_MUTEX(x)        DECLARE_MUTEX(x)
+#define mutex_lock(x)  down_interruptible(x)
+#define mutex_unlock(x)        up(x)
+
+#ifndef ____cacheline_internodealigned_in_smp
+#ifdef CONFIG_SMP
+#define ____cacheline_internodealigned_in_smp ____cacheline_aligned_in_smp
+#else
+#define ____cacheline_internodealigned_in_smp
+#endif /* CONFIG_SMP */
+#endif /* ____cacheline_internodealigned_in_smp */
+#undef HAVE_PCI_ERS
+#else /* 2.6.16 and above */
+#undef HAVE_PCI_ERS
+#define HAVE_PCI_ERS
+#endif /* < 2.6.16 */
+
+/*****************************************************************************/
+#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,17) )
+#ifndef first_online_node
+#define first_online_node 0
+#endif
+#ifndef NET_SKB_PAD
+#define NET_SKB_PAD 16
+#endif
+#endif /* < 2.6.17 */
+
+/*****************************************************************************/
+#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18) )
+
+#ifndef IRQ_HANDLED
+#define irqreturn_t void
+#define IRQ_HANDLED
+#define IRQ_NONE
+#endif
+
+#ifndef IRQF_PROBE_SHARED
+#ifdef SA_PROBEIRQ
+#define IRQF_PROBE_SHARED SA_PROBEIRQ
+#else
+#define IRQF_PROBE_SHARED 0
+#endif
+#endif
+
+#ifndef IRQF_SHARED
+#define IRQF_SHARED SA_SHIRQ
+#endif
+
+#ifndef ARRAY_SIZE
+#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
+#endif
+
+#ifndef FIELD_SIZEOF
+#define FIELD_SIZEOF(t, f) (sizeof(((t*)0)->f))
+#endif
+
+#ifndef skb_is_gso
+#ifdef NETIF_F_TSO
+#define skb_is_gso _kc_skb_is_gso
+static inline int _kc_skb_is_gso(const struct sk_buff *skb)
+{
+       return skb_shinfo(skb)->gso_size;
+}
+#else
+#define skb_is_gso(a) 0
+#endif
+#endif
+
+#ifndef resource_size_t
+#define resource_size_t unsigned long
+#endif
+
+#ifdef skb_pad
+#undef skb_pad
+#endif
+#define skb_pad(x,y) _kc_skb_pad(x, y)
+int _kc_skb_pad(struct sk_buff *skb, int pad);
+#ifdef skb_padto
+#undef skb_padto
+#endif
+#define skb_padto(x,y) _kc_skb_padto(x, y)
+static inline int _kc_skb_padto(struct sk_buff *skb, unsigned int len)
+{
+       unsigned int size = skb->len;
+       if(likely(size >= len))
+               return 0;
+       return _kc_skb_pad(skb, len - size);
+}
+#endif /* < 2.6.18 */
+
+/*****************************************************************************/
+#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) )
+
+#ifndef DIV_ROUND_UP
+#define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d))
+#endif
+#if ( LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) )
+#if (!((RHEL_RELEASE_CODE && \
+        ((RHEL_RELEASE_CODE > RHEL_RELEASE_VERSION(4,4) && \
+          RHEL_RELEASE_CODE < RHEL_RELEASE_VERSION(5,0)) || \
+         (RHEL_RELEASE_CODE > RHEL_RELEASE_VERSION(5,0)))) || \
+       (AX_RELEASE_CODE && AX_RELEASE_CODE > AX_RELEASE_VERSION(3,0))))
+typedef irqreturn_t (*irq_handler_t)(int, void*, struct pt_regs *);
+#endif
+#if (RHEL_RELEASE_CODE && RHEL_RELEASE_CODE < RHEL_RELEASE_VERSION(6,0))
+#undef CONFIG_INET_LRO
+#undef CONFIG_INET_LRO_MODULE
+#ifdef IXGBE_FCOE
+#undef CONFIG_FCOE
+#undef CONFIG_FCOE_MODULE
+#endif /* IXGBE_FCOE */
+#endif
+typedef irqreturn_t (*new_handler_t)(int, void*);
+static inline irqreturn_t _kc_request_irq(unsigned int irq, new_handler_t handler, unsigned long flags, const char *devname, void *dev_id)
+#else /* 2.4.x */
+typedef void (*irq_handler_t)(int, void*, struct pt_regs *);
+typedef void (*new_handler_t)(int, void*);
+static inline int _kc_request_irq(unsigned int irq, new_handler_t handler, unsigned long flags, const char *devname, void *dev_id)
+#endif /* >= 2.5.x */
+{
+       irq_handler_t new_handler = (irq_handler_t) handler;
+       return request_irq(irq, new_handler, flags, devname, dev_id);
+}
+
+#undef request_irq
+#define request_irq(irq, handler, flags, devname, dev_id) _kc_request_irq((irq), (handler), (flags), (devname), (dev_id))
+
+#define irq_handler_t new_handler_t
+/* pci_restore_state and pci_save_state handles MSI/PCIE from 2.6.19 */
+#if (!(RHEL_RELEASE_CODE && RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(5,4)))
+#define PCIE_CONFIG_SPACE_LEN 256
+#define PCI_CONFIG_SPACE_LEN 64
+#define PCIE_LINK_STATUS 0x12
+#define pci_config_space_ich8lan() do {} while(0)
+#undef pci_save_state
+extern int _kc_pci_save_state(struct pci_dev *);
+#define pci_save_state(pdev) _kc_pci_save_state(pdev)
+#undef pci_restore_state
+extern void _kc_pci_restore_state(struct pci_dev *);
+#define pci_restore_state(pdev) _kc_pci_restore_state(pdev)
+#endif /* !(RHEL_RELEASE_CODE >= RHEL 5.4) */
+
+#ifdef HAVE_PCI_ERS
+#undef free_netdev
+extern void _kc_free_netdev(struct net_device *);
+#define free_netdev(netdev) _kc_free_netdev(netdev)
+#endif
+static inline int pci_enable_pcie_error_reporting(struct pci_dev *dev)
+{
+       return 0;
+}
+#define pci_disable_pcie_error_reporting(dev) do {} while (0)
+#define pci_cleanup_aer_uncorrect_error_status(dev) do {} while (0)
+
+extern void *_kc_kmemdup(const void *src, size_t len, unsigned gfp);
+#define kmemdup(src, len, gfp) _kc_kmemdup(src, len, gfp)
+#ifndef bool
+#define bool _Bool
+#define true 1
+#define false 0
+#endif
+#else /* 2.6.19 */
+#include <linux/aer.h>
+#include <linux/string.h>
+#endif /* < 2.6.19 */
+
+/*****************************************************************************/
+#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20) )
+#if ( LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,28) )
+#undef INIT_WORK
+#define INIT_WORK(_work, _func) \
+do { \
+       INIT_LIST_HEAD(&(_work)->entry); \
+       (_work)->pending = 0; \
+       (_work)->func = (void (*)(void *))_func; \
+       (_work)->data = _work; \
+       init_timer(&(_work)->timer); \
+} while (0)
+#endif
+
+#ifndef PCI_VDEVICE
+#define PCI_VDEVICE(ven, dev)        \
+       PCI_VENDOR_ID_##ven, (dev),  \
+       PCI_ANY_ID, PCI_ANY_ID, 0, 0
+#endif
+
+#ifndef round_jiffies
+#define round_jiffies(x) x
+#endif
+
+#define csum_offset csum
+
+#define HAVE_EARLY_VMALLOC_NODE
+#define dev_to_node(dev) -1
+#undef set_dev_node
+/* remove compiler warning with b=b, for unused variable */
+#define set_dev_node(a, b) do { (b) = (b); } while(0)
+
+#if (!(RHEL_RELEASE_CODE && \
+       (((RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(4,7)) && \
+         (RHEL_RELEASE_CODE < RHEL_RELEASE_VERSION(5,0))) || \
+        (RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(5,6)))) && \
+     !(SLE_VERSION_CODE && SLE_VERSION_CODE >= SLE_VERSION(10,2,0)))
+typedef __u16 __bitwise __sum16;
+typedef __u32 __bitwise __wsum;
+#endif
+
+#if (!(RHEL_RELEASE_CODE && \
+       (((RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(4,7)) && \
+         (RHEL_RELEASE_CODE < RHEL_RELEASE_VERSION(5,0))) || \
+        (RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(5,4)))) && \
+     !(SLE_VERSION_CODE && SLE_VERSION_CODE >= SLE_VERSION(10,2,0)))
+static inline __wsum csum_unfold(__sum16 n)
+{
+       return (__force __wsum)n;
+}
+#endif
+
+#else /* < 2.6.20 */
+#define HAVE_DEVICE_NUMA_NODE
+#endif /* < 2.6.20 */
+
+/*****************************************************************************/
+#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21) )
+#define to_net_dev(class) container_of(class, struct net_device, class_dev)
+#define NETDEV_CLASS_DEV
+#if (!(RHEL_RELEASE_CODE && RHEL_RELEASE_CODE > RHEL_RELEASE_VERSION(5,5)))
+#define vlan_group_get_device(vg, id) (vg->vlan_devices[id])
+#define vlan_group_set_device(vg, id, dev)             \
+       do {                                            \
+               if (vg) vg->vlan_devices[id] = dev;     \
+       } while (0)
+#endif /* !(RHEL_RELEASE_CODE > RHEL_RELEASE_VERSION(5,5)) */
+#define pci_channel_offline(pdev) (pdev->error_state && \
+       pdev->error_state != pci_channel_io_normal)
+#define pci_request_selected_regions(pdev, bars, name) \
+        pci_request_regions(pdev, name)
+#define pci_release_selected_regions(pdev, bars) pci_release_regions(pdev);
+#endif /* < 2.6.21 */
+
+/*****************************************************************************/
+#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22) )
+#define tcp_hdr(skb) (skb->h.th)
+#define tcp_hdrlen(skb) (skb->h.th->doff << 2)
+#define skb_transport_offset(skb) (skb->h.raw - skb->data)
+#define skb_transport_header(skb) (skb->h.raw)
+#define ipv6_hdr(skb) (skb->nh.ipv6h)
+#define ip_hdr(skb) (skb->nh.iph)
+#define skb_network_offset(skb) (skb->nh.raw - skb->data)
+#define skb_network_header(skb) (skb->nh.raw)
+#define skb_tail_pointer(skb) skb->tail
+#define skb_reset_tail_pointer(skb) \
+       do { \
+               skb->tail = skb->data; \
+       } while (0)
+#define skb_copy_to_linear_data(skb, from, len) \
+                               memcpy(skb->data, from, len)
+#define skb_copy_to_linear_data_offset(skb, offset, from, len) \
+                               memcpy(skb->data + offset, from, len)
+#define skb_network_header_len(skb) (skb->h.raw - skb->nh.raw)
+#define pci_register_driver pci_module_init
+#define skb_mac_header(skb) skb->mac.raw
+
+#ifdef NETIF_F_MULTI_QUEUE
+#ifndef alloc_etherdev_mq
+#define alloc_etherdev_mq(_a, _b) alloc_etherdev(_a)
+#endif
+#endif /* NETIF_F_MULTI_QUEUE */
+
+#ifndef ETH_FCS_LEN
+#define ETH_FCS_LEN 4
+#endif
+#define cancel_work_sync(x) flush_scheduled_work()
+#ifndef udp_hdr
+#define udp_hdr _udp_hdr
+static inline struct udphdr *_udp_hdr(const struct sk_buff *skb)
+{
+       return (struct udphdr *)skb_transport_header(skb);
+}
+#endif
+
+#ifdef cpu_to_be16
+#undef cpu_to_be16
+#endif
+#define cpu_to_be16(x) __constant_htons(x)
+
+#if (!(RHEL_RELEASE_CODE && RHEL_RELEASE_CODE > RHEL_RELEASE_VERSION(5,1)))
+enum {
+       DUMP_PREFIX_NONE,
+       DUMP_PREFIX_ADDRESS,
+       DUMP_PREFIX_OFFSET
+};
+#endif /* !(RHEL_RELEASE_CODE > RHEL_RELEASE_VERSION(5,1)) */
+#ifndef hex_asc
+#define hex_asc(x)     "0123456789abcdef"[x]
+#endif
+#include <linux/ctype.h>
+extern void _kc_print_hex_dump(const char *level, const char *prefix_str,
+                              int prefix_type, int rowsize, int groupsize,
+                              const void *buf, size_t len, bool ascii);
+#define print_hex_dump(lvl, s, t, r, g, b, l, a) \
+               _kc_print_hex_dump(lvl, s, t, r, g, b, l, a)
+#else /* 2.6.22 */
+#define ETH_TYPE_TRANS_SETS_DEV
+#define HAVE_NETDEV_STATS_IN_NETDEV
+#endif /* < 2.6.22 */
+
+/*****************************************************************************/
+#if ( LINUX_VERSION_CODE > KERNEL_VERSION(2,6,22) )
+#undef SET_MODULE_OWNER
+#define SET_MODULE_OWNER(dev) do { } while (0)
+#endif /* > 2.6.22 */
+
+/*****************************************************************************/
+#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23) )
+#define netif_subqueue_stopped(_a, _b) 0
+#ifndef PTR_ALIGN
+#define PTR_ALIGN(p, a)         ((typeof(p))ALIGN((unsigned long)(p), (a)))
+#endif
+
+#ifndef CONFIG_PM_SLEEP
+#define CONFIG_PM_SLEEP        CONFIG_PM
+#endif
+
+#if ( LINUX_VERSION_CODE > KERNEL_VERSION(2,6,13) )
+#define HAVE_ETHTOOL_GET_PERM_ADDR
+#endif /* 2.6.14 through 2.6.22 */
+#endif /* < 2.6.23 */
+
+/*****************************************************************************/
+#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24) )
+#ifndef ETH_FLAG_LRO
+#define ETH_FLAG_LRO NETIF_F_LRO
+#endif
+
+/* if GRO is supported then the napi struct must already exist */
+#ifndef NETIF_F_GRO
+/* NAPI API changes in 2.6.24 break everything */
+struct napi_struct {
+       /* used to look up the real NAPI polling routine */
+       int (*poll)(struct napi_struct *, int);
+       struct net_device *dev;
+       int weight;
+};
+#endif
+
+#ifdef NAPI
+extern int __kc_adapter_clean(struct net_device *, int *);
+#define napi_to_poll_dev(_napi) (_napi)->dev
+#define netif_napi_add(_netdev, _napi, _poll, _weight) \
+       do { \
+               struct napi_struct *__napi = (_napi); \
+               _netdev->poll = &(__kc_adapter_clean); \
+               _netdev->weight = (_weight); \
+               __napi->poll = &(_poll); \
+               __napi->weight = (_weight); \
+               __napi->dev = (_netdev); \
+               netif_poll_disable(_netdev); \
+       } while (0)
+#define netif_napi_del(_a) do {} while (0)
+#define napi_schedule_prep(_napi) netif_rx_schedule_prep((_napi)->dev)
+#define napi_schedule(_napi) netif_rx_schedule((_napi)->dev)
+#define napi_enable(_napi) netif_poll_enable(napi_to_poll_dev(_napi))
+#define napi_disable(_napi) netif_poll_disable(napi_to_poll_dev(_napi))
+#define __napi_schedule(_napi) __netif_rx_schedule(napi_to_poll_dev(_napi))
+#ifndef NETIF_F_GRO
+#define napi_complete(_napi) netif_rx_complete(napi_to_poll_dev(_napi))
+#else
+#define napi_complete(_napi) \
+       do { \
+               napi_gro_flush(_napi); \
+               netif_rx_complete(napi_to_poll_dev(_napi)); \
+       } while (0)
+#endif /* NETIF_F_GRO */
+#else /* NAPI */
+#define netif_napi_add(_netdev, _napi, _poll, _weight) \
+       do { \
+               struct napi_struct *__napi = _napi; \
+               _netdev->poll = &(_poll); \
+               _netdev->weight = (_weight); \
+               __napi->poll = &(_poll); \
+               __napi->weight = (_weight); \
+               __napi->dev = (_netdev); \
+       } while (0)
+#define netif_napi_del(_a) do {} while (0)
+#endif /* NAPI */
+
+#undef dev_get_by_name
+#define dev_get_by_name(_a, _b) dev_get_by_name(_b)
+#define __netif_subqueue_stopped(_a, _b) netif_subqueue_stopped(_a, _b)
+#ifndef DMA_BIT_MASK
+#define DMA_BIT_MASK(n)        (((n) == 64) ? DMA_64BIT_MASK : ((1ULL<<(n))-1))
+#endif
+
+#ifdef NETIF_F_TSO6
+#define skb_is_gso_v6 _kc_skb_is_gso_v6
+static inline int _kc_skb_is_gso_v6(const struct sk_buff *skb)
+{
+       return skb_shinfo(skb)->gso_type & SKB_GSO_TCPV6;
+}
+#endif /* NETIF_F_TSO6 */
+
+#ifndef KERN_CONT
+#define KERN_CONT      ""
+#endif
+#else /* < 2.6.24 */
+#define HAVE_ETHTOOL_GET_SSET_COUNT
+#define HAVE_NETDEV_NAPI_LIST
+#endif /* < 2.6.24 */
+
+/*****************************************************************************/
+#if ( LINUX_VERSION_CODE > KERNEL_VERSION(2,6,24) )
+#if ( LINUX_VERSION_CODE < KERNEL_VERSION(3,2,0) )
+#include <linux/pm_qos_params.h>
+#else /* >= 3.2.0 */
+#include <linux/pm_qos.h>
+#endif /* else >= 3.2.0 */
+#endif /* > 2.6.24 */
+
+/*****************************************************************************/
+#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25) )
+#define PM_QOS_CPU_DMA_LATENCY 1
+
+#if ( LINUX_VERSION_CODE > KERNEL_VERSION(2,6,18) )
+#include <linux/latency.h>
+#define PM_QOS_DEFAULT_VALUE   INFINITE_LATENCY
+#define pm_qos_add_requirement(pm_qos_class, name, value) \
+               set_acceptable_latency(name, value)
+#define pm_qos_remove_requirement(pm_qos_class, name) \
+               remove_acceptable_latency(name)
+#define pm_qos_update_requirement(pm_qos_class, name, value) \
+               modify_acceptable_latency(name, value)
+#else
+#define PM_QOS_DEFAULT_VALUE   -1
+#define pm_qos_add_requirement(pm_qos_class, name, value)
+#define pm_qos_remove_requirement(pm_qos_class, name)
+#define pm_qos_update_requirement(pm_qos_class, name, value) { \
+       if (value != PM_QOS_DEFAULT_VALUE) { \
+               printk(KERN_WARNING "%s: unable to set PM QoS requirement\n", \
+                       pci_name(adapter->pdev)); \
+       } \
+}
+
+#endif /* > 2.6.18 */
+
+#define pci_enable_device_mem(pdev) pci_enable_device(pdev)
+
+#ifndef DEFINE_PCI_DEVICE_TABLE
+#define DEFINE_PCI_DEVICE_TABLE(_table) struct pci_device_id _table[]
+#endif /* DEFINE_PCI_DEVICE_TABLE */
+
+
+
+#else /* < 2.6.25 */
+
+
+
+#endif /* < 2.6.25 */
+
+/*****************************************************************************/
+#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,26) )
+#ifndef clamp_t
+#define clamp_t(type, val, min, max) ({                \
+       type __val = (val);                     \
+       type __min = (min);                     \
+       type __max = (max);                     \
+       __val = __val < __min ? __min : __val;  \
+       __val > __max ? __max : __val; })
+#endif /* clamp_t */
+#undef kzalloc_node
+#define kzalloc_node(_size, _flags, _node) kzalloc(_size, _flags)
+
+extern void _kc_pci_disable_link_state(struct pci_dev *dev, int state);
+#define pci_disable_link_state(p, s) _kc_pci_disable_link_state(p, s)
+#else /* < 2.6.26 */
+#include <linux/pci-aspm.h>
+#define HAVE_NETDEV_VLAN_FEATURES
+#endif /* < 2.6.26 */
+/*****************************************************************************/
+#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27) )
+static inline void _kc_ethtool_cmd_speed_set(struct ethtool_cmd *ep,
+                                            __u32 speed)
+{
+       ep->speed = (__u16)speed;
+       /* ep->speed_hi = (__u16)(speed >> 16); */
+}
+#define ethtool_cmd_speed_set _kc_ethtool_cmd_speed_set
+
+static inline __u32 _kc_ethtool_cmd_speed(struct ethtool_cmd *ep)
+{
+       /* no speed_hi before 2.6.27, and probably no need for it yet */
+       return (__u32)ep->speed;
+}
+#define ethtool_cmd_speed _kc_ethtool_cmd_speed
+
+#if ( LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,15) )
+#if ((LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23)) && defined(CONFIG_PM))
+#define ANCIENT_PM 1
+#elif ((LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,23)) && \
+       (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,26)) && \
+       defined(CONFIG_PM_SLEEP))
+#define NEWER_PM 1
+#endif
+#if defined(ANCIENT_PM) || defined(NEWER_PM)
+#undef device_set_wakeup_enable
+#define device_set_wakeup_enable(dev, val) \
+       do { \
+               u16 pmc = 0; \
+               int pm = pci_find_capability(adapter->pdev, PCI_CAP_ID_PM); \
+               if (pm) { \
+                       pci_read_config_word(adapter->pdev, pm + PCI_PM_PMC, \
+                               &pmc); \
+               } \
+               (dev)->power.can_wakeup = !!(pmc >> 11); \
+               (dev)->power.should_wakeup = (val && (pmc >> 11)); \
+       } while (0)
+#endif /* 2.6.15-2.6.22 and CONFIG_PM or 2.6.23-2.6.25 and CONFIG_PM_SLEEP */
+#endif /* 2.6.15 through 2.6.27 */
+#ifndef netif_napi_del
+#define netif_napi_del(_a) do {} while (0)
+#ifdef NAPI
+#ifdef CONFIG_NETPOLL
+#undef netif_napi_del
+#define netif_napi_del(_a) list_del(&(_a)->dev_list);
+#endif
+#endif
+#endif /* netif_napi_del */
+#ifdef dma_mapping_error
+#undef dma_mapping_error
+#endif
+#define dma_mapping_error(dev, dma_addr) pci_dma_mapping_error(dma_addr)
+
+
+#ifdef HAVE_TX_MQ
+extern void _kc_netif_tx_stop_all_queues(struct net_device *);
+extern void _kc_netif_tx_wake_all_queues(struct net_device *);
+extern void _kc_netif_tx_start_all_queues(struct net_device *);
+#define netif_tx_stop_all_queues(a) _kc_netif_tx_stop_all_queues(a)
+#define netif_tx_wake_all_queues(a) _kc_netif_tx_wake_all_queues(a)
+#define netif_tx_start_all_queues(a) _kc_netif_tx_start_all_queues(a)
+#undef netif_stop_subqueue
+#define netif_stop_subqueue(_ndev,_qi) do { \
+       if (netif_is_multiqueue((_ndev))) \
+               netif_stop_subqueue((_ndev), (_qi)); \
+       else \
+               netif_stop_queue((_ndev)); \
+       } while (0)
+#undef netif_start_subqueue
+#define netif_start_subqueue(_ndev,_qi) do { \
+       if (netif_is_multiqueue((_ndev))) \
+               netif_start_subqueue((_ndev), (_qi)); \
+       else \
+               netif_start_queue((_ndev)); \
+       } while (0)
+#else /* HAVE_TX_MQ */
+#define netif_tx_stop_all_queues(a) netif_stop_queue(a)
+#define netif_tx_wake_all_queues(a) netif_wake_queue(a)
+#if ( LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,12) )
+#define netif_tx_start_all_queues(a) netif_start_queue(a)
+#else
+#define netif_tx_start_all_queues(a) do {} while (0)
+#endif
+#define netif_stop_subqueue(_ndev,_qi) netif_stop_queue((_ndev))
+#define netif_start_subqueue(_ndev,_qi) netif_start_queue((_ndev))
+#endif /* HAVE_TX_MQ */
+#ifndef NETIF_F_MULTI_QUEUE
+#define NETIF_F_MULTI_QUEUE 0
+#define netif_is_multiqueue(a) 0
+#define netif_wake_subqueue(a, b)
+#endif /* NETIF_F_MULTI_QUEUE */
+
+#ifndef __WARN_printf
+extern void __kc_warn_slowpath(const char *file, const int line,
+               const char *fmt, ...) __attribute__((format(printf, 3, 4)));
+#define __WARN_printf(arg...) __kc_warn_slowpath(__FILE__, __LINE__, arg)
+#endif /* __WARN_printf */
+
+#ifndef WARN
+#define WARN(condition, format...) ({                                          \
+       int __ret_warn_on = !!(condition);                              \
+       if (unlikely(__ret_warn_on))                                    \
+               __WARN_printf(format);                                  \
+       unlikely(__ret_warn_on);                                        \
+})
+#endif /* WARN */
+#else /* < 2.6.27 */
+#define HAVE_TX_MQ
+#define HAVE_NETDEV_SELECT_QUEUE
+#endif /* < 2.6.27 */
+
+/*****************************************************************************/
+#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,28) )
+#define pci_ioremap_bar(pdev, bar)     ioremap(pci_resource_start(pdev, bar), \
+                                               pci_resource_len(pdev, bar))
+#define pci_wake_from_d3 _kc_pci_wake_from_d3
+#define pci_prepare_to_sleep _kc_pci_prepare_to_sleep
+extern int _kc_pci_wake_from_d3(struct pci_dev *dev, bool enable);
+extern int _kc_pci_prepare_to_sleep(struct pci_dev *dev);
+#define netdev_alloc_page(a) alloc_page(GFP_ATOMIC)
+#ifndef __skb_queue_head_init
+static inline void __kc_skb_queue_head_init(struct sk_buff_head *list)
+{
+       list->prev = list->next = (struct sk_buff *)list;
+       list->qlen = 0;
+}
+#define __skb_queue_head_init(_q) __kc_skb_queue_head_init(_q)
+#endif
+#ifndef skb_add_rx_frag
+#define skb_add_rx_frag _kc_skb_add_rx_frag
+extern void _kc_skb_add_rx_frag(struct sk_buff *, int, struct page *, int, int);
+#endif
+#endif /* < 2.6.28 */
+
+/*****************************************************************************/
+#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29) )
+#ifndef swap
+#define swap(a, b) \
+       do { typeof(a) __tmp = (a); (a) = (b); (b) = __tmp; } while (0)
+#endif
+#define pci_request_selected_regions_exclusive(pdev, bars, name) \
+               pci_request_selected_regions(pdev, bars, name)
+#ifndef CONFIG_NR_CPUS
+#define CONFIG_NR_CPUS 1
+#endif /* CONFIG_NR_CPUS */
+#ifndef pcie_aspm_enabled
+#define pcie_aspm_enabled()   (1)
+#endif /* pcie_aspm_enabled */
+#else /* < 2.6.29 */
+#ifndef HAVE_NET_DEVICE_OPS
+#define HAVE_NET_DEVICE_OPS
+#endif
+#endif /* < 2.6.29 */
+
+/*****************************************************************************/
+#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30) )
+#define skb_rx_queue_recorded(a) false
+#define skb_get_rx_queue(a) 0
+#ifdef IXGBE_FCOE
+#undef CONFIG_FCOE
+#undef CONFIG_FCOE_MODULE
+#endif /* IXGBE_FCOE */
+extern u16 _kc_skb_tx_hash(struct net_device *dev, struct sk_buff *skb);
+#define skb_tx_hash(n, s) _kc_skb_tx_hash(n, s)
+#define skb_record_rx_queue(a, b) do {} while (0)
+#undef pci_enable_sriov
+#define pci_enable_sriov(a, b) -ENOTSUPP
+#undef pci_disable_sriov
+#define pci_disable_sriov(a) do {} while (0)
+#ifndef pr_cont
+#define pr_cont(fmt, ...) \
+       printk(KERN_CONT fmt, ##__VA_ARGS__)
+#endif /* pr_cont */
+#else
+#define HAVE_ASPM_QUIRKS
+#endif /* < 2.6.30 */
+
+/*****************************************************************************/
+#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,31) )
+#define ETH_P_1588 0x88F7
+#define ETH_P_FIP  0x8914
+#ifndef netdev_uc_count
+#define netdev_uc_count(dev) ((dev)->uc_count)
+#endif
+#ifndef netdev_for_each_uc_addr
+#define netdev_for_each_uc_addr(uclist, dev) \
+       for (uclist = dev->uc_list; uclist; uclist = uclist->next)
+#endif
+#else
+#ifndef HAVE_NETDEV_STORAGE_ADDRESS
+#define HAVE_NETDEV_STORAGE_ADDRESS
+#endif
+#ifndef HAVE_NETDEV_HW_ADDR
+#define HAVE_NETDEV_HW_ADDR
+#endif
+#ifndef HAVE_TRANS_START_IN_QUEUE
+#define HAVE_TRANS_START_IN_QUEUE
+#endif
+#endif /* < 2.6.31 */
+
+/*****************************************************************************/
+#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,32) )
+#undef netdev_tx_t
+#define netdev_tx_t int
+#if defined(CONFIG_FCOE) || defined(CONFIG_FCOE_MODULE)
+#ifndef NETIF_F_FCOE_MTU
+#define NETIF_F_FCOE_MTU       (1 << 26)
+#endif
+#endif /* CONFIG_FCOE || CONFIG_FCOE_MODULE */
+
+#ifndef pm_runtime_get_sync
+#define pm_runtime_get_sync(dev)       do {} while (0)
+#endif
+#ifndef pm_runtime_put
+#define pm_runtime_put(dev)            do {} while (0)
+#endif
+#ifndef pm_runtime_put_sync
+#define pm_runtime_put_sync(dev)       do {} while (0)
+#endif
+#ifndef pm_runtime_resume
+#define pm_runtime_resume(dev)         do {} while (0)
+#endif
+#ifndef pm_schedule_suspend
+#define pm_schedule_suspend(dev, t)    do {} while (0)
+#endif
+#ifndef pm_runtime_set_suspended
+#define pm_runtime_set_suspended(dev)  do {} while (0)
+#endif
+#ifndef pm_runtime_disable
+#define pm_runtime_disable(dev)                do {} while (0)
+#endif
+#ifndef pm_runtime_put_noidle
+#define pm_runtime_put_noidle(dev)     do {} while (0)
+#endif
+#ifndef pm_runtime_set_active
+#define pm_runtime_set_active(dev)     do {} while (0)
+#endif
+#ifndef pm_runtime_enable
+#define pm_runtime_enable(dev) do {} while (0)
+#endif
+#ifndef pm_runtime_get_noresume
+#define pm_runtime_get_noresume(dev)   do {} while (0)
+#endif
+#else /* < 2.6.32 */
+#if defined(CONFIG_FCOE) || defined(CONFIG_FCOE_MODULE)
+#ifndef HAVE_NETDEV_OPS_FCOE_ENABLE
+#define HAVE_NETDEV_OPS_FCOE_ENABLE
+#endif
+#endif /* CONFIG_FCOE || CONFIG_FCOE_MODULE */
+#include <linux/pm_runtime.h>
+/* IOV bad DMA target work arounds require at least this kernel rev support */
+#define HAVE_PCIE_TYPE
+#endif /* < 2.6.32 */
+
+/*****************************************************************************/
+#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33) )
+#ifndef pci_pcie_cap
+#define pci_pcie_cap(pdev) pci_find_capability(pdev, PCI_CAP_ID_EXP)
+#endif
+#ifndef IPV4_FLOW
+#define IPV4_FLOW 0x10
+#endif /* IPV4_FLOW */
+#ifndef IPV6_FLOW
+#define IPV6_FLOW 0x11
+#endif /* IPV6_FLOW */
+/* Features back-ported to RHEL6 or SLES11 SP1 after 2.6.32 */
+#if ( (RHEL_RELEASE_CODE && RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(6,0)) || \
+      (SLE_VERSION_CODE && SLE_VERSION_CODE >= SLE_VERSION(11,1,0)) )
+#if defined(CONFIG_FCOE) || defined(CONFIG_FCOE_MODULE)
+#ifndef HAVE_NETDEV_OPS_FCOE_GETWWN
+#define HAVE_NETDEV_OPS_FCOE_GETWWN
+#endif
+#endif /* CONFIG_FCOE || CONFIG_FCOE_MODULE */
+#endif /* RHEL6 or SLES11 SP1 */
+#ifndef __percpu
+#define __percpu
+#endif /* __percpu */
+#else /* < 2.6.33 */
+#if defined(CONFIG_FCOE) || defined(CONFIG_FCOE_MODULE)
+#ifndef HAVE_NETDEV_OPS_FCOE_GETWWN
+#define HAVE_NETDEV_OPS_FCOE_GETWWN
+#endif
+#endif /* CONFIG_FCOE || CONFIG_FCOE_MODULE */
+#define HAVE_ETHTOOL_SFP_DISPLAY_PORT
+#endif /* < 2.6.33 */
+
+/*****************************************************************************/
+#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,34) )
+#ifndef ETH_FLAG_NTUPLE
+#define ETH_FLAG_NTUPLE NETIF_F_NTUPLE
+#endif
+
+#ifndef netdev_mc_count
+#define netdev_mc_count(dev) ((dev)->mc_count)
+#endif
+#ifndef netdev_mc_empty
+#define netdev_mc_empty(dev) (netdev_mc_count(dev) == 0)
+#endif
+#ifndef netdev_for_each_mc_addr
+#define netdev_for_each_mc_addr(mclist, dev) \
+       for (mclist = dev->mc_list; mclist; mclist = mclist->next)
+#endif
+#ifndef netdev_uc_count
+#define netdev_uc_count(dev) ((dev)->uc.count)
+#endif
+#ifndef netdev_uc_empty
+#define netdev_uc_empty(dev) (netdev_uc_count(dev) == 0)
+#endif
+#ifndef netdev_for_each_uc_addr
+#define netdev_for_each_uc_addr(ha, dev) \
+       list_for_each_entry(ha, &dev->uc.list, list)
+#endif
+#ifndef dma_set_coherent_mask
+#define dma_set_coherent_mask(dev,mask) \
+       pci_set_consistent_dma_mask(to_pci_dev(dev),(mask))
+#endif
+#ifndef pci_dev_run_wake
+#define pci_dev_run_wake(pdev) (0)
+#endif
+
+/* netdev logging taken from include/linux/netdevice.h */
+#ifndef netdev_name
+static inline const char *_kc_netdev_name(const struct net_device *dev)
+{
+       if (dev->reg_state != NETREG_REGISTERED)
+               return "(unregistered net_device)";
+       return dev->name;
+}
+#define netdev_name(netdev)    _kc_netdev_name(netdev)
+#endif /* netdev_name */
+
+#undef netdev_printk
+#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) )
+#define netdev_printk(level, netdev, format, args...)          \
+do {                                                           \
+       struct adapter_struct *kc_adapter = netdev_priv(netdev);\
+       struct pci_dev *pdev = kc_adapter->pdev;                \
+       printk("%s %s: " format, level, pci_name(pdev),         \
+              ##args);                                         \
+} while(0)
+#elif ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21) )
+#define netdev_printk(level, netdev, format, args...)          \
+do {                                                           \
+       struct adapter_struct *kc_adapter = netdev_priv(netdev);\
+       struct pci_dev *pdev = kc_adapter->pdev;                \
+       struct device *dev = pci_dev_to_dev(pdev);              \
+       dev_printk(level, dev, "%s: " format,                   \
+                  netdev_name(netdev), ##args);                \
+} while(0)
+#else /* 2.6.21 => 2.6.34 */
+#define netdev_printk(level, netdev, format, args...)          \
+       dev_printk(level, (netdev)->dev.parent,                 \
+                  "%s: " format,                               \
+                  netdev_name(netdev), ##args)
+#endif /* <2.6.0 <2.6.21 <2.6.34 */
+#undef netdev_emerg
+#define netdev_emerg(dev, format, args...)                     \
+       netdev_printk(KERN_EMERG, dev, format, ##args)
+#undef netdev_alert
+#define netdev_alert(dev, format, args...)                     \
+       netdev_printk(KERN_ALERT, dev, format, ##args)
+#undef netdev_crit
+#define netdev_crit(dev, format, args...)                      \
+       netdev_printk(KERN_CRIT, dev, format, ##args)
+#undef netdev_err
+#define netdev_err(dev, format, args...)                       \
+       netdev_printk(KERN_ERR, dev, format, ##args)
+#undef netdev_warn
+#define netdev_warn(dev, format, args...)                      \
+       netdev_printk(KERN_WARNING, dev, format, ##args)
+#undef netdev_notice
+#define netdev_notice(dev, format, args...)                    \
+       netdev_printk(KERN_NOTICE, dev, format, ##args)
+#undef netdev_info
+#define netdev_info(dev, format, args...)                      \
+       netdev_printk(KERN_INFO, dev, format, ##args)
+#undef netdev_dbg
+#if   defined(CONFIG_DYNAMIC_DEBUG)
+#define netdev_dbg(__dev, format, args...)                     \
+do {                                                           \
+       dynamic_dev_dbg((__dev)->dev.parent, "%s: " format,     \
+                       netdev_name(__dev), ##args);            \
+} while (0)
+#else /* DEBUG */
+#define netdev_dbg(__dev, format, args...)                     \
+({                                                             \
+       if (0)                                                  \
+               netdev_printk(KERN_DEBUG, __dev, format, ##args); \
+       0;                                                      \
+})
+#endif /* DEBUG */
+
+#undef netif_printk
+#define netif_printk(priv, type, level, dev, fmt, args...)     \
+do {                                                           \
+       if (netif_msg_##type(priv))                             \
+               netdev_printk(level, (dev), fmt, ##args);       \
+} while (0)
+
+#undef netif_emerg
+#define netif_emerg(priv, type, dev, fmt, args...)             \
+       netif_level(emerg, priv, type, dev, fmt, ##args)
+#undef netif_alert
+#define netif_alert(priv, type, dev, fmt, args...)             \
+       netif_level(alert, priv, type, dev, fmt, ##args)
+#undef netif_crit
+#define netif_crit(priv, type, dev, fmt, args...)              \
+       netif_level(crit, priv, type, dev, fmt, ##args)
+#undef netif_err
+#define netif_err(priv, type, dev, fmt, args...)               \
+       netif_level(err, priv, type, dev, fmt, ##args)
+#undef netif_warn
+#define netif_warn(priv, type, dev, fmt, args...)              \
+       netif_level(warn, priv, type, dev, fmt, ##args)
+#undef netif_notice
+#define netif_notice(priv, type, dev, fmt, args...)            \
+       netif_level(notice, priv, type, dev, fmt, ##args)
+#undef netif_info
+#define netif_info(priv, type, dev, fmt, args...)              \
+       netif_level(info, priv, type, dev, fmt, ##args)
+
+#ifdef SET_SYSTEM_SLEEP_PM_OPS
+#define HAVE_SYSTEM_SLEEP_PM_OPS
+#endif
+
+#ifndef for_each_set_bit
+#define for_each_set_bit(bit, addr, size) \
+       for ((bit) = find_first_bit((addr), (size)); \
+               (bit) < (size); \
+               (bit) = find_next_bit((addr), (size), (bit) + 1))
+#endif /* for_each_set_bit */
+
+#else /* < 2.6.34 */
+#define HAVE_SYSTEM_SLEEP_PM_OPS
+#ifndef HAVE_SET_RX_MODE
+#define HAVE_SET_RX_MODE
+#endif
+#endif /* < 2.6.34 */
+
+/*****************************************************************************/
+#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,35) )
+#ifndef numa_node_id
+#define numa_node_id() 0
+#endif
+#ifdef HAVE_TX_MQ
+#include <net/sch_generic.h>
+#ifndef CONFIG_NETDEVICES_MULTIQUEUE
+void _kc_netif_set_real_num_tx_queues(struct net_device *, unsigned int);
+#define netif_set_real_num_tx_queues  _kc_netif_set_real_num_tx_queues
+#else /* CONFIG_NETDEVICES_MULTI_QUEUE */
+#define netif_set_real_num_tx_queues(_netdev, _count) \
+       do { \
+               (_netdev)->egress_subqueue_count = _count; \
+       } while (0)
+#endif /* CONFIG_NETDEVICES_MULTI_QUEUE */
+#else
+#define netif_set_real_num_tx_queues(_netdev, _count) do {} while(0)
+#endif /* HAVE_TX_MQ */
+#ifndef ETH_FLAG_RXHASH
+#define ETH_FLAG_RXHASH (1<<28)
+#endif /* ETH_FLAG_RXHASH */
+#else /* < 2.6.35 */
+#define HAVE_PM_QOS_REQUEST_LIST
+#define HAVE_IRQ_AFFINITY_HINT
+#endif /* < 2.6.35 */
+
+/*****************************************************************************/
+#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,36) )
+extern int _kc_ethtool_op_set_flags(struct net_device *, u32, u32);
+#define ethtool_op_set_flags _kc_ethtool_op_set_flags
+extern u32 _kc_ethtool_op_get_flags(struct net_device *);
+#define ethtool_op_get_flags _kc_ethtool_op_get_flags
+
+#ifdef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS
+#ifdef NET_IP_ALIGN
+#undef NET_IP_ALIGN
+#endif
+#define NET_IP_ALIGN 0
+#endif /* CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS */
+
+#ifdef NET_SKB_PAD
+#undef NET_SKB_PAD
+#endif
+
+#if (L1_CACHE_BYTES > 32)
+#define NET_SKB_PAD L1_CACHE_BYTES
+#else
+#define NET_SKB_PAD 32
+#endif
+
+static inline struct sk_buff *_kc_netdev_alloc_skb_ip_align(struct net_device *dev,
+                                                           unsigned int length)
+{
+       struct sk_buff *skb;
+
+       skb = alloc_skb(length + NET_SKB_PAD + NET_IP_ALIGN, GFP_ATOMIC);
+       if (skb) {
+#if (NET_IP_ALIGN + NET_SKB_PAD)
+               skb_reserve(skb, NET_IP_ALIGN + NET_SKB_PAD);
+#endif
+               skb->dev = dev;
+       }
+       return skb;
+}
+
+#ifdef netdev_alloc_skb_ip_align
+#undef netdev_alloc_skb_ip_align
+#endif
+#define netdev_alloc_skb_ip_align(n, l) _kc_netdev_alloc_skb_ip_align(n, l)
+
+#undef netif_level
+#define netif_level(level, priv, type, dev, fmt, args...)      \
+do {                                                           \
+       if (netif_msg_##type(priv))                             \
+               netdev_##level(dev, fmt, ##args);               \
+} while (0)
+
+#undef usleep_range
+#define usleep_range(min, max) msleep(DIV_ROUND_UP(min, 1000)) 
+
+#else /* < 2.6.36 */
+#define HAVE_PM_QOS_REQUEST_ACTIVE
+#define HAVE_8021P_SUPPORT
+#define HAVE_NDO_GET_STATS64
+#endif /* < 2.6.36 */
+
+/*****************************************************************************/
+#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,37) )
+#ifndef ETHTOOL_RXNTUPLE_ACTION_CLEAR
+#define ETHTOOL_RXNTUPLE_ACTION_CLEAR (-2)
+#endif
+#ifndef VLAN_N_VID
+#define VLAN_N_VID     VLAN_GROUP_ARRAY_LEN
+#endif /* VLAN_N_VID */
+#ifndef ETH_FLAG_TXVLAN
+#define ETH_FLAG_TXVLAN (1 << 7)
+#endif /* ETH_FLAG_TXVLAN */
+#ifndef ETH_FLAG_RXVLAN
+#define ETH_FLAG_RXVLAN (1 << 8)
+#endif /* ETH_FLAG_RXVLAN */
+
+static inline void _kc_skb_checksum_none_assert(struct sk_buff *skb)
+{
+       WARN_ON(skb->ip_summed != CHECKSUM_NONE);
+}
+#define skb_checksum_none_assert(skb) _kc_skb_checksum_none_assert(skb)
+
+static inline void *_kc_vzalloc_node(unsigned long size, int node)
+{
+       void *addr = vmalloc_node(size, node);
+       if (addr)
+               memset(addr, 0, size);
+       return addr;
+}
+#define vzalloc_node(_size, _node) _kc_vzalloc_node(_size, _node)
+
+static inline void *_kc_vzalloc(unsigned long size)
+{
+       void *addr = vmalloc(size);
+       if (addr)
+               memset(addr, 0, size);
+       return addr;
+}
+#define vzalloc(_size) _kc_vzalloc(_size)
+
+#ifndef vlan_get_protocol
+static inline __be16 __kc_vlan_get_protocol(const struct sk_buff *skb)
+{
+       if (vlan_tx_tag_present(skb) ||
+           skb->protocol != cpu_to_be16(ETH_P_8021Q))
+               return skb->protocol;
+
+       if (skb_headlen(skb) < sizeof(struct vlan_ethhdr))
+               return 0;
+
+       return ((struct vlan_ethhdr*)skb->data)->h_vlan_encapsulated_proto;
+}
+#define vlan_get_protocol(_skb) __kc_vlan_get_protocol(_skb)
+#endif
+#ifdef HAVE_HW_TIME_STAMP
+#define SKBTX_HW_TSTAMP (1 << 0)
+#define SKBTX_IN_PROGRESS (1 << 2)
+#define SKB_SHARED_TX_IS_UNION
+#endif
+#if ( LINUX_VERSION_CODE > KERNEL_VERSION(2,4,18) )
+#ifndef HAVE_VLAN_RX_REGISTER
+#define HAVE_VLAN_RX_REGISTER
+#endif
+#endif /* > 2.4.18 */
+#endif /* < 2.6.37 */
+
+/*****************************************************************************/
+#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,38) )
+#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22) )
+#define skb_checksum_start_offset(skb) skb_transport_offset(skb)
+#else /* 2.6.22 -> 2.6.37 */
+static inline int _kc_skb_checksum_start_offset(const struct sk_buff *skb)
+{
+        return skb->csum_start - skb_headroom(skb);
+}
+#define skb_checksum_start_offset(skb) _kc_skb_checksum_start_offset(skb)
+#endif /* 2.6.22 -> 2.6.37 */
+#else /* < 2.6.38 */
+#endif /* < 2.6.38 */
+
+/*****************************************************************************/
+#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,39) )
+#ifndef skb_queue_reverse_walk_safe
+#define skb_queue_reverse_walk_safe(queue, skb, tmp)                           \
+               for (skb = (queue)->prev, tmp = skb->prev;                      \
+                    skb != (struct sk_buff *)(queue);                          \
+                    skb = tmp, tmp = skb->prev)
+#endif
+#else /* < 2.6.39 */
+#if defined(CONFIG_FCOE) || defined(CONFIG_FCOE_MODULE)
+#ifndef HAVE_NETDEV_OPS_FCOE_DDP_TARGET
+#define HAVE_NETDEV_OPS_FCOE_DDP_TARGET
+#endif
+#endif /* CONFIG_FCOE || CONFIG_FCOE_MODULE */
+#ifndef HAVE_MQPRIO
+#define HAVE_MQPRIO
+#endif
+#ifndef HAVE_SETUP_TC
+#define HAVE_SETUP_TC
+#endif
+#ifndef HAVE_NDO_SET_FEATURES
+#define HAVE_NDO_SET_FEATURES
+#endif
+#endif /* < 2.6.39 */
+
+/*****************************************************************************/
+/* use < 2.6.40 because of a Fedora 15 kernel update where they
+ * updated the kernel version to 2.6.40.x and they back-ported 3.0 features
+ * like set_phys_id for ethtool.
+ */ 
+#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,40) )
+#ifdef ETHTOOL_GRXRINGS
+#ifndef FLOW_EXT
+#define        FLOW_EXT        0x80000000
+union _kc_ethtool_flow_union {
+       struct ethtool_tcpip4_spec              tcp_ip4_spec;
+       struct ethtool_usrip4_spec              usr_ip4_spec;
+       __u8                                    hdata[60];
+};
+struct _kc_ethtool_flow_ext {
+       __be16  vlan_etype;
+       __be16  vlan_tci;
+       __be32  data[2];
+};
+struct _kc_ethtool_rx_flow_spec {
+       __u32           flow_type;
+       union _kc_ethtool_flow_union h_u;
+       struct _kc_ethtool_flow_ext h_ext;
+       union _kc_ethtool_flow_union m_u;
+       struct _kc_ethtool_flow_ext m_ext;
+       __u64           ring_cookie;
+       __u32           location;
+};
+#define ethtool_rx_flow_spec _kc_ethtool_rx_flow_spec
+#endif /* FLOW_EXT */
+#endif
+
+#define pci_disable_link_state_locked pci_disable_link_state
+
+#ifndef PCI_LTR_VALUE_MASK
+#define  PCI_LTR_VALUE_MASK    0x000003ff
+#endif
+#ifndef PCI_LTR_SCALE_MASK
+#define  PCI_LTR_SCALE_MASK    0x00001c00
+#endif
+#ifndef PCI_LTR_SCALE_SHIFT
+#define  PCI_LTR_SCALE_SHIFT   10
+#endif
+
+#else /* < 2.6.40 */
+#define HAVE_ETHTOOL_SET_PHYS_ID
+#endif /* < 2.6.40 */
+
+/*****************************************************************************/
+#if ( LINUX_VERSION_CODE < KERNEL_VERSION(3,1,0) )
+#ifndef __netdev_alloc_skb_ip_align
+#define __netdev_alloc_skb_ip_align(d,l,_g) netdev_alloc_skb_ip_align(d,l)
+#endif /* __netdev_alloc_skb_ip_align */
+#define dcb_ieee_setapp(dev, app) dcb_setapp(dev, app)
+#define dcb_ieee_delapp(dev, app) 0
+#define dcb_ieee_getapp_mask(dev, app) (1 << app->priority)
+#else /* < 3.1.0 */
+#ifndef HAVE_DCBNL_IEEE_DELAPP
+#define HAVE_DCBNL_IEEE_DELAPP
+#endif
+#endif /* < 3.1.0 */
+
+/*****************************************************************************/
+#if ( LINUX_VERSION_CODE < KERNEL_VERSION(3,2,0) )
+#ifdef ETHTOOL_GRXRINGS
+#define HAVE_ETHTOOL_GET_RXNFC_VOID_RULE_LOCS
+#endif /* ETHTOOL_GRXRINGS */
+
+#ifndef skb_frag_size
+#define skb_frag_size(frag)    _kc_skb_frag_size(frag)
+static inline unsigned int _kc_skb_frag_size(const skb_frag_t *frag)
+{
+       return frag->size;
+}
+#endif /* skb_frag_size */
+
+#ifndef skb_frag_size_sub
+#define skb_frag_size_sub(frag, delta) _kc_skb_frag_size_sub(frag, delta)
+static inline void _kc_skb_frag_size_sub(skb_frag_t *frag, int delta)
+{
+       frag->size -= delta;
+}
+#endif /* skb_frag_size_sub */
+
+#ifndef skb_frag_page
+#define skb_frag_page(frag)    _kc_skb_frag_page(frag)
+static inline struct page *_kc_skb_frag_page(const skb_frag_t *frag)
+{
+       return frag->page;
+}
+#endif /* skb_frag_page */
+
+#ifndef skb_frag_address
+#define skb_frag_address(frag) _kc_skb_frag_address(frag)
+static inline void *_kc_skb_frag_address(const skb_frag_t *frag)
+{
+       return page_address(skb_frag_page(frag)) + frag->page_offset;
+}
+#endif /* skb_frag_address */
+
+#ifndef skb_frag_dma_map
+#define skb_frag_dma_map(dev,frag,offset,size,dir) \
+               _kc_skb_frag_dma_map(dev,frag,offset,size,dir)
+static inline dma_addr_t _kc_skb_frag_dma_map(struct device *dev,
+                                             const skb_frag_t *frag,
+                                             size_t offset, size_t size,
+                                             enum dma_data_direction dir)
+{
+       return dma_map_page(dev, skb_frag_page(frag),
+                           frag->page_offset + offset, size, dir);
+}
+#endif /* skb_frag_dma_map */
+
+#ifndef __skb_frag_unref
+#define __skb_frag_unref(frag) __kc_skb_frag_unref(frag)
+static inline void __kc_skb_frag_unref(skb_frag_t *frag)
+{
+       put_page(skb_frag_page(frag));
+}
+#endif /* __skb_frag_unref */
+#else /* < 3.2.0 */
+#ifndef HAVE_PCI_DEV_FLAGS_ASSIGNED
+#define HAVE_PCI_DEV_FLAGS_ASSIGNED
+#define HAVE_VF_SPOOFCHK_CONFIGURE
+#endif
+#endif /* < 3.2.0 */
+
+#if (RHEL_RELEASE_CODE && RHEL_RELEASE_CODE == RHEL_RELEASE_VERSION(6,2))
+#undef ixgbe_get_netdev_tc_txq
+#define ixgbe_get_netdev_tc_txq(dev, tc) (&netdev_extended(dev)->qos_data.tc_to_txq[tc])
+#endif
+
+/*****************************************************************************/
+#if ( LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0) )
+//typedef u32 netdev_features_t;
+#else /* ! < 3.3.0 */
+#define HAVE_INT_NDO_VLAN_RX_ADD_VID
+#endif /* < 3.3.0 */
+
+#endif /* _KCOMPAT_H_ */
diff --git a/drivers/net/igbvf/kcompat_ethtool.c b/drivers/net/igbvf/kcompat_ethtool.c
new file mode 100644 (file)
index 0000000..7ebbcc3
--- /dev/null
@@ -0,0 +1,1173 @@
+/*******************************************************************************
+
+  Intel(R) 82576 Virtual Function Linux driver
+  Copyright(c) 1999 - 2012 Intel Corporation.
+
+  This program is free software; you can redistribute it and/or modify it
+  under the terms and conditions of the GNU General Public License,
+  version 2, as published by the Free Software Foundation.
+
+  This program is distributed in the hope it will be useful, but WITHOUT
+  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+  more details.
+
+  You should have received a copy of the GNU General Public License along with
+  this program; if not, write to the Free Software Foundation, Inc.,
+  51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
+
+  The full GNU General Public License is included in this distribution in
+  the file called "COPYING".
+
+  Contact Information:
+  Linux NICS <linux.nics@intel.com>
+  e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
+  Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
+
+*******************************************************************************/
+
+/*
+ * net/core/ethtool.c - Ethtool ioctl handler
+ * Copyright (c) 2003 Matthew Wilcox <matthew@wil.cx>
+ *
+ * This file is where we call all the ethtool_ops commands to get
+ * the information ethtool needs.  We fall back to calling do_ioctl()
+ * for drivers which haven't been converted to ethtool_ops yet.
+ *
+ * It's GPL, stupid.
+ *
+ * Modification by sfeldma@pobox.com to work as backward compat
+ * solution for pre-ethtool_ops kernels.
+ *     - copied struct ethtool_ops from ethtool.h
+ *     - defined SET_ETHTOOL_OPS
+ *     - put in some #ifndef NETIF_F_xxx wrappers
+ *     - changes refs to dev->ethtool_ops to ethtool_ops
+ *     - changed dev_ethtool to ethtool_ioctl
+ *      - remove EXPORT_SYMBOL()s
+ *      - added _kc_ prefix in built-in ethtool_op_xxx ops.
+ */
+
+#include <linux/module.h>
+#include <linux/types.h>
+#include <linux/errno.h>
+#include <linux/mii.h>
+#include <linux/ethtool.h>
+#include <linux/netdevice.h>
+#include <asm/uaccess.h>
+
+#include "kcompat.h"
+
+#undef SUPPORTED_10000baseT_Full
+#define SUPPORTED_10000baseT_Full      (1 << 12)
+#undef ADVERTISED_10000baseT_Full
+#define ADVERTISED_10000baseT_Full     (1 << 12)
+#undef SPEED_10000
+#define SPEED_10000            10000
+
+#undef ethtool_ops
+#define ethtool_ops _kc_ethtool_ops
+
+struct _kc_ethtool_ops {
+       int  (*get_settings)(struct net_device *, struct ethtool_cmd *);
+       int  (*set_settings)(struct net_device *, struct ethtool_cmd *);
+       void (*get_drvinfo)(struct net_device *, struct ethtool_drvinfo *);
+       int  (*get_regs_len)(struct net_device *);
+       void (*get_regs)(struct net_device *, struct ethtool_regs *, void *);
+       void (*get_wol)(struct net_device *, struct ethtool_wolinfo *);
+       int  (*set_wol)(struct net_device *, struct ethtool_wolinfo *);
+       u32  (*get_msglevel)(struct net_device *);
+       void (*set_msglevel)(struct net_device *, u32);
+       int  (*nway_reset)(struct net_device *);
+       u32  (*get_link)(struct net_device *);
+       int  (*get_eeprom_len)(struct net_device *);
+       int  (*get_eeprom)(struct net_device *, struct ethtool_eeprom *, u8 *);
+       int  (*set_eeprom)(struct net_device *, struct ethtool_eeprom *, u8 *);
+       int  (*get_coalesce)(struct net_device *, struct ethtool_coalesce *);
+       int  (*set_coalesce)(struct net_device *, struct ethtool_coalesce *);
+       void (*get_ringparam)(struct net_device *, struct ethtool_ringparam *);
+       int  (*set_ringparam)(struct net_device *, struct ethtool_ringparam *);
+       void (*get_pauseparam)(struct net_device *,
+                              struct ethtool_pauseparam*);
+       int  (*set_pauseparam)(struct net_device *,
+                              struct ethtool_pauseparam*);
+       u32  (*get_rx_csum)(struct net_device *);
+       int  (*set_rx_csum)(struct net_device *, u32);
+       u32  (*get_tx_csum)(struct net_device *);
+       int  (*set_tx_csum)(struct net_device *, u32);
+       u32  (*get_sg)(struct net_device *);
+       int  (*set_sg)(struct net_device *, u32);
+       u32  (*get_tso)(struct net_device *);
+       int  (*set_tso)(struct net_device *, u32);
+       int  (*self_test_count)(struct net_device *);
+       void (*self_test)(struct net_device *, struct ethtool_test *, u64 *);
+       void (*get_strings)(struct net_device *, u32 stringset, u8 *);
+       int  (*phys_id)(struct net_device *, u32);
+       int  (*get_stats_count)(struct net_device *);
+       void (*get_ethtool_stats)(struct net_device *, struct ethtool_stats *,
+                                 u64 *);
+} *ethtool_ops = NULL;
+
+#undef SET_ETHTOOL_OPS
+#define SET_ETHTOOL_OPS(netdev, ops) (ethtool_ops = (ops))
+
+/*
+ * Some useful ethtool_ops methods that are device independent. If we find that
+ * all drivers want to do the same thing here, we can turn these into dev_()
+ * function calls.
+ */
+
+#undef ethtool_op_get_link
+#define ethtool_op_get_link _kc_ethtool_op_get_link
+u32 _kc_ethtool_op_get_link(struct net_device *dev)
+{
+       return netif_carrier_ok(dev) ? 1 : 0;
+}
+
+#undef ethtool_op_get_tx_csum
+#define ethtool_op_get_tx_csum _kc_ethtool_op_get_tx_csum
+u32 _kc_ethtool_op_get_tx_csum(struct net_device *dev)
+{
+#ifdef NETIF_F_IP_CSUM
+       return (dev->features & NETIF_F_IP_CSUM) != 0;
+#else
+       return 0;
+#endif
+}
+
+#undef ethtool_op_set_tx_csum
+#define ethtool_op_set_tx_csum _kc_ethtool_op_set_tx_csum
+int _kc_ethtool_op_set_tx_csum(struct net_device *dev, u32 data)
+{
+#ifdef NETIF_F_IP_CSUM
+       if (data)
+#ifdef NETIF_F_IPV6_CSUM
+               dev->features |= (NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM);
+       else
+               dev->features &= ~(NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM);
+#else
+               dev->features |= NETIF_F_IP_CSUM;
+       else
+               dev->features &= ~NETIF_F_IP_CSUM;
+#endif
+#endif
+
+       return 0;
+}
+
+#undef ethtool_op_get_sg
+#define ethtool_op_get_sg _kc_ethtool_op_get_sg
+u32 _kc_ethtool_op_get_sg(struct net_device *dev)
+{
+#ifdef NETIF_F_SG
+       return (dev->features & NETIF_F_SG) != 0;
+#else
+       return 0;
+#endif
+}
+
+#undef ethtool_op_set_sg
+#define ethtool_op_set_sg _kc_ethtool_op_set_sg
+int _kc_ethtool_op_set_sg(struct net_device *dev, u32 data)
+{
+#ifdef NETIF_F_SG
+       if (data)
+               dev->features |= NETIF_F_SG;
+       else
+               dev->features &= ~NETIF_F_SG;
+#endif
+
+       return 0;
+}
+
+#undef ethtool_op_get_tso
+#define ethtool_op_get_tso _kc_ethtool_op_get_tso
+u32 _kc_ethtool_op_get_tso(struct net_device *dev)
+{
+#ifdef NETIF_F_TSO
+       return (dev->features & NETIF_F_TSO) != 0;
+#else
+       return 0;
+#endif
+}
+
+#undef ethtool_op_set_tso
+#define ethtool_op_set_tso _kc_ethtool_op_set_tso
+int _kc_ethtool_op_set_tso(struct net_device *dev, u32 data)
+{
+#ifdef NETIF_F_TSO
+       if (data)
+               dev->features |= NETIF_F_TSO;
+       else
+               dev->features &= ~NETIF_F_TSO;
+#endif
+
+       return 0;
+}
+
+/* Handlers for each ethtool command */
+
+static int ethtool_get_settings(struct net_device *dev, void *useraddr)
+{
+       struct ethtool_cmd cmd = { ETHTOOL_GSET };
+       int err;
+
+       if (!ethtool_ops->get_settings)
+               return -EOPNOTSUPP;
+
+       err = ethtool_ops->get_settings(dev, &cmd);
+       if (err < 0)
+               return err;
+
+       if (copy_to_user(useraddr, &cmd, sizeof(cmd)))
+               return -EFAULT;
+       return 0;
+}
+
+static int ethtool_set_settings(struct net_device *dev, void *useraddr)
+{
+       struct ethtool_cmd cmd;
+
+       if (!ethtool_ops->set_settings)
+               return -EOPNOTSUPP;
+
+       if (copy_from_user(&cmd, useraddr, sizeof(cmd)))
+               return -EFAULT;
+
+       return ethtool_ops->set_settings(dev, &cmd);
+}
+
+static int ethtool_get_drvinfo(struct net_device *dev, void *useraddr)
+{
+       struct ethtool_drvinfo info;
+       struct ethtool_ops *ops = ethtool_ops;
+
+       if (!ops->get_drvinfo)
+               return -EOPNOTSUPP;
+
+       memset(&info, 0, sizeof(info));
+       info.cmd = ETHTOOL_GDRVINFO;
+       ops->get_drvinfo(dev, &info);
+
+       if (ops->self_test_count)
+               info.testinfo_len = ops->self_test_count(dev);
+       if (ops->get_stats_count)
+               info.n_stats = ops->get_stats_count(dev);
+       if (ops->get_regs_len)
+               info.regdump_len = ops->get_regs_len(dev);
+       if (ops->get_eeprom_len)
+               info.eedump_len = ops->get_eeprom_len(dev);
+
+       if (copy_to_user(useraddr, &info, sizeof(info)))
+               return -EFAULT;
+       return 0;
+}
+
+static int ethtool_get_regs(struct net_device *dev, char *useraddr)
+{
+       struct ethtool_regs regs;
+       struct ethtool_ops *ops = ethtool_ops;
+       void *regbuf;
+       int reglen, ret;
+
+       if (!ops->get_regs || !ops->get_regs_len)
+               return -EOPNOTSUPP;
+
+       if (copy_from_user(&regs, useraddr, sizeof(regs)))
+               return -EFAULT;
+
+       reglen = ops->get_regs_len(dev);
+       if (regs.len > reglen)
+               regs.len = reglen;
+
+       regbuf = kmalloc(reglen, GFP_USER);
+       if (!regbuf)
+               return -ENOMEM;
+
+       ops->get_regs(dev, &regs, regbuf);
+
+       ret = -EFAULT;
+       if (copy_to_user(useraddr, &regs, sizeof(regs)))
+               goto out;
+       useraddr += offsetof(struct ethtool_regs, data);
+       if (copy_to_user(useraddr, regbuf, reglen))
+               goto out;
+       ret = 0;
+
+out:
+       kfree(regbuf);
+       return ret;
+}
+
+static int ethtool_get_wol(struct net_device *dev, char *useraddr)
+{
+       struct ethtool_wolinfo wol = { ETHTOOL_GWOL };
+
+       if (!ethtool_ops->get_wol)
+               return -EOPNOTSUPP;
+
+       ethtool_ops->get_wol(dev, &wol);
+
+       if (copy_to_user(useraddr, &wol, sizeof(wol)))
+               return -EFAULT;
+       return 0;
+}
+
+static int ethtool_set_wol(struct net_device *dev, char *useraddr)
+{
+       struct ethtool_wolinfo wol;
+
+       if (!ethtool_ops->set_wol)
+               return -EOPNOTSUPP;
+
+       if (copy_from_user(&wol, useraddr, sizeof(wol)))
+               return -EFAULT;
+
+       return ethtool_ops->set_wol(dev, &wol);
+}
+
+static int ethtool_get_msglevel(struct net_device *dev, char *useraddr)
+{
+       struct ethtool_value edata = { ETHTOOL_GMSGLVL };
+
+       if (!ethtool_ops->get_msglevel)
+               return -EOPNOTSUPP;
+
+       edata.data = ethtool_ops->get_msglevel(dev);
+
+       if (copy_to_user(useraddr, &edata, sizeof(edata)))
+               return -EFAULT;
+       return 0;
+}
+
+static int ethtool_set_msglevel(struct net_device *dev, char *useraddr)
+{
+       struct ethtool_value edata;
+
+       if (!ethtool_ops->set_msglevel)
+               return -EOPNOTSUPP;
+
+       if (copy_from_user(&edata, useraddr, sizeof(edata)))
+               return -EFAULT;
+
+       ethtool_ops->set_msglevel(dev, edata.data);
+       return 0;
+}
+
+static int ethtool_nway_reset(struct net_device *dev)
+{
+       if (!ethtool_ops->nway_reset)
+               return -EOPNOTSUPP;
+
+       return ethtool_ops->nway_reset(dev);
+}
+
+static int ethtool_get_link(struct net_device *dev, void *useraddr)
+{
+       struct ethtool_value edata = { ETHTOOL_GLINK };
+
+       if (!ethtool_ops->get_link)
+               return -EOPNOTSUPP;
+
+       edata.data = ethtool_ops->get_link(dev);
+
+       if (copy_to_user(useraddr, &edata, sizeof(edata)))
+               return -EFAULT;
+       return 0;
+}
+
+static int ethtool_get_eeprom(struct net_device *dev, void *useraddr)
+{
+       struct ethtool_eeprom eeprom;
+       struct ethtool_ops *ops = ethtool_ops;
+       u8 *data;
+       int ret;
+
+       if (!ops->get_eeprom || !ops->get_eeprom_len)
+               return -EOPNOTSUPP;
+
+       if (copy_from_user(&eeprom, useraddr, sizeof(eeprom)))
+               return -EFAULT;
+
+       /* Check for wrap and zero */
+       if (eeprom.offset + eeprom.len <= eeprom.offset)
+               return -EINVAL;
+
+       /* Check for exceeding total eeprom len */
+       if (eeprom.offset + eeprom.len > ops->get_eeprom_len(dev))
+               return -EINVAL;
+
+       data = kmalloc(eeprom.len, GFP_USER);
+       if (!data)
+               return -ENOMEM;
+
+       ret = -EFAULT;
+       if (copy_from_user(data, useraddr + sizeof(eeprom), eeprom.len))
+               goto out;
+
+       ret = ops->get_eeprom(dev, &eeprom, data);
+       if (ret)
+               goto out;
+
+       ret = -EFAULT;
+       if (copy_to_user(useraddr, &eeprom, sizeof(eeprom)))
+               goto out;
+       if (copy_to_user(useraddr + sizeof(eeprom), data, eeprom.len))
+               goto out;
+       ret = 0;
+
+out:
+       kfree(data);
+       return ret;
+}
+
+static int ethtool_set_eeprom(struct net_device *dev, void *useraddr)
+{
+       struct ethtool_eeprom eeprom;
+       struct ethtool_ops *ops = ethtool_ops;
+       u8 *data;
+       int ret;
+
+       if (!ops->set_eeprom || !ops->get_eeprom_len)
+               return -EOPNOTSUPP;
+
+       if (copy_from_user(&eeprom, useraddr, sizeof(eeprom)))
+               return -EFAULT;
+
+       /* Check for wrap and zero */
+       if (eeprom.offset + eeprom.len <= eeprom.offset)
+               return -EINVAL;
+
+       /* Check for exceeding total eeprom len */
+       if (eeprom.offset + eeprom.len > ops->get_eeprom_len(dev))
+               return -EINVAL;
+
+       data = kmalloc(eeprom.len, GFP_USER);
+       if (!data)
+               return -ENOMEM;
+
+       ret = -EFAULT;
+       if (copy_from_user(data, useraddr + sizeof(eeprom), eeprom.len))
+               goto out;
+
+       ret = ops->set_eeprom(dev, &eeprom, data);
+       if (ret)
+               goto out;
+
+       if (copy_to_user(useraddr + sizeof(eeprom), data, eeprom.len))
+               ret = -EFAULT;
+
+out:
+       kfree(data);
+       return ret;
+}
+
+static int ethtool_get_coalesce(struct net_device *dev, void *useraddr)
+{
+       struct ethtool_coalesce coalesce = { ETHTOOL_GCOALESCE };
+
+       if (!ethtool_ops->get_coalesce)
+               return -EOPNOTSUPP;
+
+       ethtool_ops->get_coalesce(dev, &coalesce);
+
+       if (copy_to_user(useraddr, &coalesce, sizeof(coalesce)))
+               return -EFAULT;
+       return 0;
+}
+
+static int ethtool_set_coalesce(struct net_device *dev, void *useraddr)
+{
+       struct ethtool_coalesce coalesce;
+
+       if (!ethtool_ops->get_coalesce)
+               return -EOPNOTSUPP;
+
+       if (copy_from_user(&coalesce, useraddr, sizeof(coalesce)))
+               return -EFAULT;
+
+       return ethtool_ops->set_coalesce(dev, &coalesce);
+}
+
+static int ethtool_get_ringparam(struct net_device *dev, void *useraddr)
+{
+       struct ethtool_ringparam ringparam = { ETHTOOL_GRINGPARAM };
+
+       if (!ethtool_ops->get_ringparam)
+               return -EOPNOTSUPP;
+
+       ethtool_ops->get_ringparam(dev, &ringparam);
+
+       if (copy_to_user(useraddr, &ringparam, sizeof(ringparam)))
+               return -EFAULT;
+       return 0;
+}
+
+static int ethtool_set_ringparam(struct net_device *dev, void *useraddr)
+{
+       struct ethtool_ringparam ringparam;
+
+       if (!ethtool_ops->get_ringparam)
+               return -EOPNOTSUPP;
+
+       if (copy_from_user(&ringparam, useraddr, sizeof(ringparam)))
+               return -EFAULT;
+
+       return ethtool_ops->set_ringparam(dev, &ringparam);
+}
+
+static int ethtool_get_pauseparam(struct net_device *dev, void *useraddr)
+{
+       struct ethtool_pauseparam pauseparam = { ETHTOOL_GPAUSEPARAM };
+
+       if (!ethtool_ops->get_pauseparam)
+               return -EOPNOTSUPP;
+
+       ethtool_ops->get_pauseparam(dev, &pauseparam);
+
+       if (copy_to_user(useraddr, &pauseparam, sizeof(pauseparam)))
+               return -EFAULT;
+       return 0;
+}
+
+static int ethtool_set_pauseparam(struct net_device *dev, void *useraddr)
+{
+       struct ethtool_pauseparam pauseparam;
+
+       if (!ethtool_ops->get_pauseparam)
+               return -EOPNOTSUPP;
+
+       if (copy_from_user(&pauseparam, useraddr, sizeof(pauseparam)))
+               return -EFAULT;
+
+       return ethtool_ops->set_pauseparam(dev, &pauseparam);
+}
+
+static int ethtool_get_rx_csum(struct net_device *dev, char *useraddr)
+{
+       struct ethtool_value edata = { ETHTOOL_GRXCSUM };
+
+       if (!ethtool_ops->get_rx_csum)
+               return -EOPNOTSUPP;
+
+       edata.data = ethtool_ops->get_rx_csum(dev);
+
+       if (copy_to_user(useraddr, &edata, sizeof(edata)))
+               return -EFAULT;
+       return 0;
+}
+
+static int ethtool_set_rx_csum(struct net_device *dev, char *useraddr)
+{
+       struct ethtool_value edata;
+
+       if (!ethtool_ops->set_rx_csum)
+               return -EOPNOTSUPP;
+
+       if (copy_from_user(&edata, useraddr, sizeof(edata)))
+               return -EFAULT;
+
+       ethtool_ops->set_rx_csum(dev, edata.data);
+       return 0;
+}
+
+static int ethtool_get_tx_csum(struct net_device *dev, char *useraddr)
+{
+       struct ethtool_value edata = { ETHTOOL_GTXCSUM };
+
+       if (!ethtool_ops->get_tx_csum)
+               return -EOPNOTSUPP;
+
+       edata.data = ethtool_ops->get_tx_csum(dev);
+
+       if (copy_to_user(useraddr, &edata, sizeof(edata)))
+               return -EFAULT;
+       return 0;
+}
+
+static int ethtool_set_tx_csum(struct net_device *dev, char *useraddr)
+{
+       struct ethtool_value edata;
+
+       if (!ethtool_ops->set_tx_csum)
+               return -EOPNOTSUPP;
+
+       if (copy_from_user(&edata, useraddr, sizeof(edata)))
+               return -EFAULT;
+
+       return ethtool_ops->set_tx_csum(dev, edata.data);
+}
+
+static int ethtool_get_sg(struct net_device *dev, char *useraddr)
+{
+       struct ethtool_value edata = { ETHTOOL_GSG };
+
+       if (!ethtool_ops->get_sg)
+               return -EOPNOTSUPP;
+
+       edata.data = ethtool_ops->get_sg(dev);
+
+       if (copy_to_user(useraddr, &edata, sizeof(edata)))
+               return -EFAULT;
+       return 0;
+}
+
+static int ethtool_set_sg(struct net_device *dev, char *useraddr)
+{
+       struct ethtool_value edata;
+
+       if (!ethtool_ops->set_sg)
+               return -EOPNOTSUPP;
+
+       if (copy_from_user(&edata, useraddr, sizeof(edata)))
+               return -EFAULT;
+
+       return ethtool_ops->set_sg(dev, edata.data);
+}
+
+static int ethtool_get_tso(struct net_device *dev, char *useraddr)
+{
+       struct ethtool_value edata = { ETHTOOL_GTSO };
+
+       if (!ethtool_ops->get_tso)
+               return -EOPNOTSUPP;
+
+       edata.data = ethtool_ops->get_tso(dev);
+
+       if (copy_to_user(useraddr, &edata, sizeof(edata)))
+               return -EFAULT;
+       return 0;
+}
+
+static int ethtool_set_tso(struct net_device *dev, char *useraddr)
+{
+       struct ethtool_value edata;
+
+       if (!ethtool_ops->set_tso)
+               return -EOPNOTSUPP;
+
+       if (copy_from_user(&edata, useraddr, sizeof(edata)))
+               return -EFAULT;
+
+       return ethtool_ops->set_tso(dev, edata.data);
+}
+
+static int ethtool_self_test(struct net_device *dev, char *useraddr)
+{
+       struct ethtool_test test;
+       struct ethtool_ops *ops = ethtool_ops;
+       u64 *data;
+       int ret;
+
+       if (!ops->self_test || !ops->self_test_count)
+               return -EOPNOTSUPP;
+
+       if (copy_from_user(&test, useraddr, sizeof(test)))
+               return -EFAULT;
+
+       test.len = ops->self_test_count(dev);
+       data = kmalloc(test.len * sizeof(u64), GFP_USER);
+       if (!data)
+               return -ENOMEM;
+
+       ops->self_test(dev, &test, data);
+
+       ret = -EFAULT;
+       if (copy_to_user(useraddr, &test, sizeof(test)))
+               goto out;
+       useraddr += sizeof(test);
+       if (copy_to_user(useraddr, data, test.len * sizeof(u64)))
+               goto out;
+       ret = 0;
+
+out:
+       kfree(data);
+       return ret;
+}
+
+static int ethtool_get_strings(struct net_device *dev, void *useraddr)
+{
+       struct ethtool_gstrings gstrings;
+       struct ethtool_ops *ops = ethtool_ops;
+       u8 *data;
+       int ret;
+
+       if (!ops->get_strings)
+               return -EOPNOTSUPP;
+
+       if (copy_from_user(&gstrings, useraddr, sizeof(gstrings)))
+               return -EFAULT;
+
+       switch (gstrings.string_set) {
+       case ETH_SS_TEST:
+               if (!ops->self_test_count)
+                       return -EOPNOTSUPP;
+               gstrings.len = ops->self_test_count(dev);
+               break;
+       case ETH_SS_STATS:
+               if (!ops->get_stats_count)
+                       return -EOPNOTSUPP;
+               gstrings.len = ops->get_stats_count(dev);
+               break;
+       default:
+               return -EINVAL;
+       }
+
+       data = kmalloc(gstrings.len * ETH_GSTRING_LEN, GFP_USER);
+       if (!data)
+               return -ENOMEM;
+
+       ops->get_strings(dev, gstrings.string_set, data);
+
+       ret = -EFAULT;
+       if (copy_to_user(useraddr, &gstrings, sizeof(gstrings)))
+               goto out;
+       useraddr += sizeof(gstrings);
+       if (copy_to_user(useraddr, data, gstrings.len * ETH_GSTRING_LEN))
+               goto out;
+       ret = 0;
+
+out:
+       kfree(data);
+       return ret;
+}
+
+static int ethtool_phys_id(struct net_device *dev, void *useraddr)
+{
+       struct ethtool_value id;
+
+       if (!ethtool_ops->phys_id)
+               return -EOPNOTSUPP;
+
+       if (copy_from_user(&id, useraddr, sizeof(id)))
+               return -EFAULT;
+
+       return ethtool_ops->phys_id(dev, id.data);
+}
+
+static int ethtool_get_stats(struct net_device *dev, void *useraddr)
+{
+       struct ethtool_stats stats;
+       struct ethtool_ops *ops = ethtool_ops;
+       u64 *data;
+       int ret;
+
+       if (!ops->get_ethtool_stats || !ops->get_stats_count)
+               return -EOPNOTSUPP;
+
+       if (copy_from_user(&stats, useraddr, sizeof(stats)))
+               return -EFAULT;
+
+       stats.n_stats = ops->get_stats_count(dev);
+       data = kmalloc(stats.n_stats * sizeof(u64), GFP_USER);
+       if (!data)
+               return -ENOMEM;
+
+       ops->get_ethtool_stats(dev, &stats, data);
+
+       ret = -EFAULT;
+       if (copy_to_user(useraddr, &stats, sizeof(stats)))
+               goto out;
+       useraddr += sizeof(stats);
+       if (copy_to_user(useraddr, data, stats.n_stats * sizeof(u64)))
+               goto out;
+       ret = 0;
+
+out:
+       kfree(data);
+       return ret;
+}
+
+/* The main entry point in this file.  Called from net/core/dev.c */
+
+#define ETHTOOL_OPS_COMPAT
+int ethtool_ioctl(struct ifreq *ifr)
+{
+       struct net_device *dev = __dev_get_by_name(ifr->ifr_name);
+       void *useraddr = (void *) ifr->ifr_data;
+       u32 ethcmd;
+
+       /*
+        * XXX: This can be pushed down into the ethtool_* handlers that
+        * need it.  Keep existing behavior for the moment.
+        */
+       if (!capable(CAP_NET_ADMIN))
+               return -EPERM;
+
+       if (!dev || !netif_device_present(dev))
+               return -ENODEV;
+
+       if (copy_from_user(&ethcmd, useraddr, sizeof (ethcmd)))
+               return -EFAULT;
+
+       switch (ethcmd) {
+       case ETHTOOL_GSET:
+               return ethtool_get_settings(dev, useraddr);
+       case ETHTOOL_SSET:
+               return ethtool_set_settings(dev, useraddr);
+       case ETHTOOL_GDRVINFO:
+               return ethtool_get_drvinfo(dev, useraddr);
+       case ETHTOOL_GREGS:
+               return ethtool_get_regs(dev, useraddr);
+       case ETHTOOL_GWOL:
+               return ethtool_get_wol(dev, useraddr);
+       case ETHTOOL_SWOL:
+               return ethtool_set_wol(dev, useraddr);
+       case ETHTOOL_GMSGLVL:
+               return ethtool_get_msglevel(dev, useraddr);
+       case ETHTOOL_SMSGLVL:
+               return ethtool_set_msglevel(dev, useraddr);
+       case ETHTOOL_NWAY_RST:
+               return ethtool_nway_reset(dev);
+       case ETHTOOL_GLINK:
+               return ethtool_get_link(dev, useraddr);
+       case ETHTOOL_GEEPROM:
+               return ethtool_get_eeprom(dev, useraddr);
+       case ETHTOOL_SEEPROM:
+               return ethtool_set_eeprom(dev, useraddr);
+       case ETHTOOL_GCOALESCE:
+               return ethtool_get_coalesce(dev, useraddr);
+       case ETHTOOL_SCOALESCE:
+               return ethtool_set_coalesce(dev, useraddr);
+       case ETHTOOL_GRINGPARAM:
+               return ethtool_get_ringparam(dev, useraddr);
+       case ETHTOOL_SRINGPARAM:
+               return ethtool_set_ringparam(dev, useraddr);
+       case ETHTOOL_GPAUSEPARAM:
+               return ethtool_get_pauseparam(dev, useraddr);
+       case ETHTOOL_SPAUSEPARAM:
+               return ethtool_set_pauseparam(dev, useraddr);
+       case ETHTOOL_GRXCSUM:
+               return ethtool_get_rx_csum(dev, useraddr);
+       case ETHTOOL_SRXCSUM:
+               return ethtool_set_rx_csum(dev, useraddr);
+       case ETHTOOL_GTXCSUM:
+               return ethtool_get_tx_csum(dev, useraddr);
+       case ETHTOOL_STXCSUM:
+               return ethtool_set_tx_csum(dev, useraddr);
+       case ETHTOOL_GSG:
+               return ethtool_get_sg(dev, useraddr);
+       case ETHTOOL_SSG:
+               return ethtool_set_sg(dev, useraddr);
+       case ETHTOOL_GTSO:
+               return ethtool_get_tso(dev, useraddr);
+       case ETHTOOL_STSO:
+               return ethtool_set_tso(dev, useraddr);
+       case ETHTOOL_TEST:
+               return ethtool_self_test(dev, useraddr);
+       case ETHTOOL_GSTRINGS:
+               return ethtool_get_strings(dev, useraddr);
+       case ETHTOOL_PHYS_ID:
+               return ethtool_phys_id(dev, useraddr);
+       case ETHTOOL_GSTATS:
+               return ethtool_get_stats(dev, useraddr);
+       default:
+               return -EOPNOTSUPP;
+       }
+
+       return -EOPNOTSUPP;
+}
+
+#define mii_if_info _kc_mii_if_info
+struct _kc_mii_if_info {
+       int phy_id;
+       int advertising;
+       int phy_id_mask;
+       int reg_num_mask;
+
+       unsigned int full_duplex : 1;   /* is full duplex? */
+       unsigned int force_media : 1;   /* is autoneg. disabled? */
+
+       struct net_device *dev;
+       int (*mdio_read) (struct net_device *dev, int phy_id, int location);
+       void (*mdio_write) (struct net_device *dev, int phy_id, int location, int val);
+};
+
+struct ethtool_cmd;
+struct mii_ioctl_data;
+
+#undef mii_link_ok
+#define mii_link_ok _kc_mii_link_ok
+#undef mii_nway_restart
+#define mii_nway_restart _kc_mii_nway_restart
+#undef mii_ethtool_gset
+#define mii_ethtool_gset _kc_mii_ethtool_gset
+#undef mii_ethtool_sset
+#define mii_ethtool_sset _kc_mii_ethtool_sset
+#undef mii_check_link
+#define mii_check_link _kc_mii_check_link
+extern int _kc_mii_link_ok (struct mii_if_info *mii);
+extern int _kc_mii_nway_restart (struct mii_if_info *mii);
+extern int _kc_mii_ethtool_gset(struct mii_if_info *mii,
+                                struct ethtool_cmd *ecmd);
+extern int _kc_mii_ethtool_sset(struct mii_if_info *mii,
+                                struct ethtool_cmd *ecmd);
+extern void _kc_mii_check_link (struct mii_if_info *mii);
+#if ( LINUX_VERSION_CODE > KERNEL_VERSION(2,4,6) )
+#undef generic_mii_ioctl
+#define generic_mii_ioctl _kc_generic_mii_ioctl
+extern int _kc_generic_mii_ioctl(struct mii_if_info *mii_if,
+                                 struct mii_ioctl_data *mii_data, int cmd,
+                                 unsigned int *duplex_changed);
+#endif /* > 2.4.6 */
+
+
+struct _kc_pci_dev_ext {
+       struct pci_dev *dev;
+       void *pci_drvdata;
+       struct pci_driver *driver;
+};
+
+struct _kc_net_dev_ext {
+       struct net_device *dev;
+       unsigned int carrier;
+};
+
+
+/**************************************/
+/* mii support */
+
+int _kc_mii_ethtool_gset(struct mii_if_info *mii, struct ethtool_cmd *ecmd)
+{
+       struct net_device *dev = mii->dev;
+       u32 advert, bmcr, lpa, nego;
+
+       ecmd->supported =
+           (SUPPORTED_10baseT_Half | SUPPORTED_10baseT_Full |
+            SUPPORTED_100baseT_Half | SUPPORTED_100baseT_Full |
+            SUPPORTED_Autoneg | SUPPORTED_TP | SUPPORTED_MII);
+
+       /* only supports twisted-pair */
+       ecmd->port = PORT_MII;
+
+       /* only supports internal transceiver */
+       ecmd->transceiver = XCVR_INTERNAL;
+
+       /* this isn't fully supported at higher layers */
+       ecmd->phy_address = mii->phy_id;
+
+       ecmd->advertising = ADVERTISED_TP | ADVERTISED_MII;
+       advert = mii->mdio_read(dev, mii->phy_id, MII_ADVERTISE);
+       if (advert & ADVERTISE_10HALF)
+               ecmd->advertising |= ADVERTISED_10baseT_Half;
+       if (advert & ADVERTISE_10FULL)
+               ecmd->advertising |= ADVERTISED_10baseT_Full;
+       if (advert & ADVERTISE_100HALF)
+               ecmd->advertising |= ADVERTISED_100baseT_Half;
+       if (advert & ADVERTISE_100FULL)
+               ecmd->advertising |= ADVERTISED_100baseT_Full;
+
+       bmcr = mii->mdio_read(dev, mii->phy_id, MII_BMCR);
+       lpa = mii->mdio_read(dev, mii->phy_id, MII_LPA);
+       if (bmcr & BMCR_ANENABLE) {
+               ecmd->advertising |= ADVERTISED_Autoneg;
+               ecmd->autoneg = AUTONEG_ENABLE;
+
+               nego = mii_nway_result(advert & lpa);
+               if (nego == LPA_100FULL || nego == LPA_100HALF)
+                       ecmd->speed = SPEED_100;
+               else
+                       ecmd->speed = SPEED_10;
+               if (nego == LPA_100FULL || nego == LPA_10FULL) {
+                       ecmd->duplex = DUPLEX_FULL;
+                       mii->full_duplex = 1;
+               } else {
+                       ecmd->duplex = DUPLEX_HALF;
+                       mii->full_duplex = 0;
+               }
+       } else {
+               ecmd->autoneg = AUTONEG_DISABLE;
+
+               ecmd->speed = (bmcr & BMCR_SPEED100) ? SPEED_100 : SPEED_10;
+               ecmd->duplex = (bmcr & BMCR_FULLDPLX) ? DUPLEX_FULL : DUPLEX_HALF;
+       }
+
+       /* ignore maxtxpkt, maxrxpkt for now */
+
+       return 0;
+}
+
+int _kc_mii_ethtool_sset(struct mii_if_info *mii, struct ethtool_cmd *ecmd)
+{
+       struct net_device *dev = mii->dev;
+
+       if (ecmd->speed != SPEED_10 && ecmd->speed != SPEED_100)
+               return -EINVAL;
+       if (ecmd->duplex != DUPLEX_HALF && ecmd->duplex != DUPLEX_FULL)
+               return -EINVAL;
+       if (ecmd->port != PORT_MII)
+               return -EINVAL;
+       if (ecmd->transceiver != XCVR_INTERNAL)
+               return -EINVAL;
+       if (ecmd->phy_address != mii->phy_id)
+               return -EINVAL;
+       if (ecmd->autoneg != AUTONEG_DISABLE && ecmd->autoneg != AUTONEG_ENABLE)
+               return -EINVAL;
+
+       /* ignore supported, maxtxpkt, maxrxpkt */
+
+       if (ecmd->autoneg == AUTONEG_ENABLE) {
+               u32 bmcr, advert, tmp;
+
+               if ((ecmd->advertising & (ADVERTISED_10baseT_Half |
+                                         ADVERTISED_10baseT_Full |
+                                         ADVERTISED_100baseT_Half |
+                                         ADVERTISED_100baseT_Full)) == 0)
+                       return -EINVAL;
+
+               /* advertise only what has been requested */
+               advert = mii->mdio_read(dev, mii->phy_id, MII_ADVERTISE);
+               tmp = advert & ~(ADVERTISE_ALL | ADVERTISE_100BASE4);
+               if (ADVERTISED_10baseT_Half)
+                       tmp |= ADVERTISE_10HALF;
+               if (ADVERTISED_10baseT_Full)
+                       tmp |= ADVERTISE_10FULL;
+               if (ADVERTISED_100baseT_Half)
+                       tmp |= ADVERTISE_100HALF;
+               if (ADVERTISED_100baseT_Full)
+                       tmp |= ADVERTISE_100FULL;
+               if (advert != tmp) {
+                       mii->mdio_write(dev, mii->phy_id, MII_ADVERTISE, tmp);
+                       mii->advertising = tmp;
+               }
+
+               /* turn on autonegotiation, and force a renegotiate */
+               bmcr = mii->mdio_read(dev, mii->phy_id, MII_BMCR);
+               bmcr |= (BMCR_ANENABLE | BMCR_ANRESTART);
+               mii->mdio_write(dev, mii->phy_id, MII_BMCR, bmcr);
+
+               mii->force_media = 0;
+       } else {
+               u32 bmcr, tmp;
+
+               /* turn off auto negotiation, set speed and duplexity */
+               bmcr = mii->mdio_read(dev, mii->phy_id, MII_BMCR);
+               tmp = bmcr & ~(BMCR_ANENABLE | BMCR_SPEED100 | BMCR_FULLDPLX);
+               if (ecmd->speed == SPEED_100)
+                       tmp |= BMCR_SPEED100;
+               if (ecmd->duplex == DUPLEX_FULL) {
+                       tmp |= BMCR_FULLDPLX;
+                       mii->full_duplex = 1;
+               } else
+                       mii->full_duplex = 0;
+               if (bmcr != tmp)
+                       mii->mdio_write(dev, mii->phy_id, MII_BMCR, tmp);
+
+               mii->force_media = 1;
+       }
+       return 0;
+}
+
+int _kc_mii_link_ok (struct mii_if_info *mii)
+{
+       /* first, a dummy read, needed to latch some MII phys */
+       mii->mdio_read(mii->dev, mii->phy_id, MII_BMSR);
+       if (mii->mdio_read(mii->dev, mii->phy_id, MII_BMSR) & BMSR_LSTATUS)
+               return 1;
+       return 0;
+}
+
+int _kc_mii_nway_restart (struct mii_if_info *mii)
+{
+       int bmcr;
+       int r = -EINVAL;
+
+       /* if autoneg is off, it's an error */
+       bmcr = mii->mdio_read(mii->dev, mii->phy_id, MII_BMCR);
+
+       if (bmcr & BMCR_ANENABLE) {
+               bmcr |= BMCR_ANRESTART;
+               mii->mdio_write(mii->dev, mii->phy_id, MII_BMCR, bmcr);
+               r = 0;
+       }
+
+       return r;
+}
+
+void _kc_mii_check_link (struct mii_if_info *mii)
+{
+       int cur_link = mii_link_ok(mii);
+       int prev_link = netif_carrier_ok(mii->dev);
+
+       if (cur_link && !prev_link)
+               netif_carrier_on(mii->dev);
+       else if (prev_link && !cur_link)
+               netif_carrier_off(mii->dev);
+}
+
+#if ( LINUX_VERSION_CODE > KERNEL_VERSION(2,4,6) )
+int _kc_generic_mii_ioctl(struct mii_if_info *mii_if,
+                          struct mii_ioctl_data *mii_data, int cmd,
+                          unsigned int *duplex_chg_out)
+{
+       int rc = 0;
+       unsigned int duplex_changed = 0;
+
+       if (duplex_chg_out)
+               *duplex_chg_out = 0;
+
+       mii_data->phy_id &= mii_if->phy_id_mask;
+       mii_data->reg_num &= mii_if->reg_num_mask;
+
+       switch(cmd) {
+       case SIOCDEVPRIVATE:    /* binary compat, remove in 2.5 */
+       case SIOCGMIIPHY:
+               mii_data->phy_id = mii_if->phy_id;
+               /* fall through */
+
+       case SIOCDEVPRIVATE + 1:/* binary compat, remove in 2.5 */
+       case SIOCGMIIREG:
+               mii_data->val_out =
+                       mii_if->mdio_read(mii_if->dev, mii_data->phy_id,
+                                         mii_data->reg_num);
+               break;
+
+       case SIOCDEVPRIVATE + 2:/* binary compat, remove in 2.5 */
+       case SIOCSMIIREG: {
+               u16 val = mii_data->val_in;
+
+               if (!capable(CAP_NET_ADMIN))
+                       return -EPERM;
+
+               if (mii_data->phy_id == mii_if->phy_id) {
+                       switch(mii_data->reg_num) {
+                       case MII_BMCR: {
+                               unsigned int new_duplex = 0;
+                               if (val & (BMCR_RESET|BMCR_ANENABLE))
+                                       mii_if->force_media = 0;
+                               else
+                                       mii_if->force_media = 1;
+                               if (mii_if->force_media &&
+                                   (val & BMCR_FULLDPLX))
+                                       new_duplex = 1;
+                               if (mii_if->full_duplex != new_duplex) {
+                                       duplex_changed = 1;
+                                       mii_if->full_duplex = new_duplex;
+                               }
+                               break;
+                       }
+                       case MII_ADVERTISE:
+                               mii_if->advertising = val;
+                               break;
+                       default:
+                               /* do nothing */
+                               break;
+                       }
+               }
+
+               mii_if->mdio_write(mii_if->dev, mii_data->phy_id,
+                                  mii_data->reg_num, val);
+               break;
+       }
+
+       default:
+               rc = -EOPNOTSUPP;
+               break;
+       }
+
+       if ((rc == 0) && (duplex_chg_out) && (duplex_changed))
+               *duplex_chg_out = 1;
+
+       return rc;
+}
+#endif /* > 2.4.6 */
+
diff --git a/drivers/net/igbvf/mbx.h b/drivers/net/igbvf/mbx.h
deleted file mode 100644 (file)
index 24370bc..0000000
+++ /dev/null
@@ -1,75 +0,0 @@
-/*******************************************************************************
-
-  Intel(R) 82576 Virtual Function Linux driver
-  Copyright(c) 1999 - 2012 Intel Corporation.
-
-  This program is free software; you can redistribute it and/or modify it
-  under the terms and conditions of the GNU General Public License,
-  version 2, as published by the Free Software Foundation.
-
-  This program is distributed in the hope it will be useful, but WITHOUT
-  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
-  more details.
-
-  You should have received a copy of the GNU General Public License along with
-  this program; if not, write to the Free Software Foundation, Inc.,
-  51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
-
-  The full GNU General Public License is included in this distribution in
-  the file called "COPYING".
-
-  Contact Information:
-  e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
-  Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
-
-*******************************************************************************/
-
-#ifndef _E1000_MBX_H_
-#define _E1000_MBX_H_
-
-#include "vf.h"
-
-#define E1000_V2PMAILBOX_REQ   0x00000001 /* Request for PF Ready bit */
-#define E1000_V2PMAILBOX_ACK   0x00000002 /* Ack PF message received */
-#define E1000_V2PMAILBOX_VFU   0x00000004 /* VF owns the mailbox buffer */
-#define E1000_V2PMAILBOX_PFU   0x00000008 /* PF owns the mailbox buffer */
-#define E1000_V2PMAILBOX_PFSTS 0x00000010 /* PF wrote a message in the MB */
-#define E1000_V2PMAILBOX_PFACK 0x00000020 /* PF ack the previous VF msg */
-#define E1000_V2PMAILBOX_RSTI  0x00000040 /* PF has reset indication */
-#define E1000_V2PMAILBOX_RSTD  0x00000080 /* PF has indicated reset done */
-#define E1000_V2PMAILBOX_R2C_BITS 0x000000B0 /* All read to clear bits */
-
-#define E1000_VFMAILBOX_SIZE   16 /* 16 32 bit words - 64 bytes */
-
-/* If it's a E1000_VF_* msg then it originates in the VF and is sent to the
- * PF.  The reverse is true if it is E1000_PF_*.
- * Message ACK's are the value or'd with 0xF0000000
- */
-#define E1000_VT_MSGTYPE_ACK      0x80000000  /* Messages below or'd with
-                                               * this are the ACK */
-#define E1000_VT_MSGTYPE_NACK     0x40000000  /* Messages below or'd with
-                                               * this are the NACK */
-#define E1000_VT_MSGTYPE_CTS      0x20000000  /* Indicates that VF is still
-                                                 clear to send requests */
-
-/* We have a total wait time of 1s for vf mailbox posted messages */
-#define E1000_VF_MBX_INIT_TIMEOUT 2000 /* retry count for mailbox timeout */
-#define E1000_VF_MBX_INIT_DELAY   500  /* usec delay between retries */
-
-#define E1000_VT_MSGINFO_SHIFT    16
-/* bits 23:16 are used for exra info for certain messages */
-#define E1000_VT_MSGINFO_MASK     (0xFF << E1000_VT_MSGINFO_SHIFT)
-
-#define E1000_VF_RESET            0x01 /* VF requests reset */
-#define E1000_VF_SET_MAC_ADDR     0x02 /* VF requests PF to set MAC addr */
-#define E1000_VF_SET_MULTICAST    0x03 /* VF requests PF to set MC addr */
-#define E1000_VF_SET_VLAN         0x04 /* VF requests PF to set VLAN */
-#define E1000_VF_SET_LPE          0x05 /* VF requests PF to set VMOLR.LPE */
-
-#define E1000_PF_CONTROL_MSG      0x0100 /* PF control message */
-
-void e1000_init_mbx_ops_generic(struct e1000_hw *hw);
-s32 e1000_init_mbx_params_vf(struct e1000_hw *);
-
-#endif /* _E1000_MBX_H_ */
index 6a1d7179c44177ff7cc39b579bc17e581db0ef0d..a18f0000ad0e8f6d59dc8b043ec3d673f5aee969 100644 (file)
@@ -1,7 +1,7 @@
 /*******************************************************************************
 
   Intel(R) 82576 Virtual Function Linux driver
-  Copyright(c) 2009 - 2012 Intel Corporation.
+  Copyright(c) 1999 - 2012 Intel Corporation.
 
   This program is free software; you can redistribute it and/or modify it
   under the terms and conditions of the GNU General Public License,
   the file called "COPYING".
 
   Contact Information:
+  Linux NICS <linux.nics@intel.com>
   e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
   Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
 
 *******************************************************************************/
 
-#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
-
 #include <linux/module.h>
 #include <linux/types.h>
 #include <linux/init.h>
 #include <linux/netdevice.h>
 #include <linux/tcp.h>
 #include <linux/ipv6.h>
-#include <linux/slab.h>
+#ifdef NETIF_F_TSO
 #include <net/checksum.h>
+#ifdef NETIF_F_TSO6
 #include <net/ip6_checksum.h>
+#endif
+#endif
 #include <linux/mii.h>
 #include <linux/ethtool.h>
 #include <linux/if_vlan.h>
-#include <linux/prefetch.h>
 
 #include "igbvf.h"
 
-#define DRV_VERSION "2.0.1-k"
+#define DRV_DEBUG ""
+
+#define DRV_VERSION "2.0.4" DRV_DEBUG
 char igbvf_driver_name[] = "igbvf";
 const char igbvf_driver_version[] = DRV_VERSION;
-static const char igbvf_driver_string[] =
-                 "Intel(R) Gigabit Virtual Function Network Driver";
-static const char igbvf_copyright[] =
-                 "Copyright (c) 2009 - 2012 Intel Corporation.";
+
+extern void      e1000_init_function_pointers_vf(struct e1000_hw *hw);
+extern s32       e1000_init_mac_params_vf(struct e1000_hw *hw);
 
 static int igbvf_poll(struct napi_struct *napi, int budget);
-static void igbvf_reset(struct igbvf_adapter *);
-static void igbvf_set_interrupt_capability(struct igbvf_adapter *);
-static void igbvf_reset_interrupt_capability(struct igbvf_adapter *);
 
 static struct igbvf_info igbvf_vf_info = {
-       .mac                    = e1000_vfadapt,
-       .flags                  = 0,
-       .pba                    = 10,
-       .init_ops               = e1000_init_function_pointers_vf,
+       .mac                    = e1000_vfadapt,
+       .flags                  = 0,
+       .pba                    = 10,
+       .init_ops               = e1000_init_function_pointers_vf,
 };
 
 static struct igbvf_info igbvf_i350_vf_info = {
@@ -79,6 +78,27 @@ static const struct igbvf_info *igbvf_info_tbl[] = {
        [board_i350_vf]         = &igbvf_i350_vf_info,
 };
 
+void e1000_read_pci_cfg(struct e1000_hw *hw, u32 reg, u16 *value)
+{
+       struct igbvf_adapter *adapter = hw->back;
+
+       pci_read_config_word(adapter->pdev, reg, value);
+}
+
+s32 e1000_read_pcie_cap_reg(struct e1000_hw *hw, u32 reg, u16 *value)
+{
+       struct igbvf_adapter *adapter = hw->back;
+       u32 cap_offset;
+
+       cap_offset = pci_find_capability(adapter->pdev, PCI_CAP_ID_EXP);
+       if (!cap_offset)
+               return -E1000_ERR_CONFIG;
+
+       pci_read_config_word(adapter->pdev, cap_offset + reg, value);
+
+       return E1000_SUCCESS;
+}
+
 /**
  * igbvf_desc_unused - calculate if we have unused descriptors
  **/
@@ -98,22 +118,43 @@ static int igbvf_desc_unused(struct igbvf_ring *ring)
  * @skb: pointer to sk_buff to be indicated to stack
  **/
 static void igbvf_receive_skb(struct igbvf_adapter *adapter,
-                              struct net_device *netdev,
-                              struct sk_buff *skb,
-                              u32 status, u16 vlan)
+                             struct net_device *netdev,
+                             struct sk_buff *skb,
+                             u32 status, u16 vlan)
 {
+       u16 vid = 0;
+
        if (status & E1000_RXD_STAT_VP) {
-               u16 vid = le16_to_cpu(vlan) & E1000_RXD_SPC_VLAN_MASK;
-               if (test_bit(vid, adapter->active_vlans))
-                       __vlan_hwaccel_put_tag(skb, vid);
+               if ((adapter->flags & IGBVF_FLAG_RX_LB_VLAN_BSWAP) &&
+                   (status & E1000_RXDEXT_STATERR_LB))
+                       vid = be16_to_cpu(vlan & E1000_RXD_SPC_VLAN_MASK);
+               else
+                       vid = le16_to_cpu(vlan & E1000_RXD_SPC_VLAN_MASK);
        }
-       netif_receive_skb(skb);
+       /*
+        * On some adapters, trunk VLANs are incorrectly indicated in the
+        * rx descriptor, so check for this.
+        */
+       if (!test_bit(vid, adapter->active_vlans))
+               vid = 0;
+
+#ifndef HAVE_VLAN_RX_REGISTER
+       __vlan_hwaccel_put_tag(skb, vid);
+#else
+       if (vid)
+               vlan_gro_receive(&adapter->rx_ring->napi, adapter->vlgrp,
+                                vid, skb);
+       else
+#endif
+       napi_gro_receive(&adapter->rx_ring->napi, skb);
+
+       netdev->last_rx = jiffies;
 }
 
 static inline void igbvf_rx_checksum_adv(struct igbvf_adapter *adapter,
-                                         u32 status_err, struct sk_buff *skb)
+                                        u32 status_err, struct sk_buff *skb)
 {
-       skb_checksum_none_assert(skb);
+       skb->ip_summed = CHECKSUM_NONE;
 
        /* Ignore Checksum bit is set or checksum is disabled through ethtool */
        if ((status_err & E1000_RXD_STAT_IXSM) ||
@@ -127,7 +168,6 @@ static inline void igbvf_rx_checksum_adv(struct igbvf_adapter *adapter,
                adapter->hw_csum_err++;
                return;
        }
-
        /* It must be a TCP or UDP packet with a valid checksum */
        if (status_err & (E1000_RXD_STAT_TCPCS | E1000_RXD_STAT_UDPCS))
                skb->ip_summed = CHECKSUM_UNNECESSARY;
@@ -140,8 +180,9 @@ static inline void igbvf_rx_checksum_adv(struct igbvf_adapter *adapter,
  * @rx_ring: address of ring structure to repopulate
  * @cleaned_count: number of buffers to repopulate
  **/
+
 static void igbvf_alloc_rx_buffers(struct igbvf_ring *rx_ring,
-                                   int cleaned_count)
+                                  int cleaned_count)
 {
        struct igbvf_adapter *adapter = rx_ring->adapter;
        struct net_device *netdev = adapter->netdev;
@@ -175,10 +216,11 @@ static void igbvf_alloc_rx_buffers(struct igbvf_ring *rx_ring,
                                buffer_info->page_offset ^= PAGE_SIZE / 2;
                        }
                        buffer_info->page_dma =
-                               dma_map_page(&pdev->dev, buffer_info->page,
+                               dma_map_page(pci_dev_to_dev(pdev),
+                                            buffer_info->page,
                                             buffer_info->page_offset,
                                             PAGE_SIZE / 2,
-                                            DMA_FROM_DEVICE);
+                                            DMA_FROM_DEVICE);
                }
 
                if (!buffer_info->skb) {
@@ -189,9 +231,9 @@ static void igbvf_alloc_rx_buffers(struct igbvf_ring *rx_ring,
                        }
 
                        buffer_info->skb = skb;
-                       buffer_info->dma = dma_map_single(&pdev->dev, skb->data,
-                                                         bufsz,
-                                                         DMA_FROM_DEVICE);
+                       buffer_info->dma = dma_map_single(pci_dev_to_dev(pdev),
+                                                         skb->data, bufsz,
+                                                         DMA_FROM_DEVICE);
                }
                /* Refresh the desc even if buffer_addrs didn't change because
                 * each write-back erases this info. */
@@ -228,6 +270,20 @@ no_buffers:
        }
 }
 
+static inline u16 igbvf_get_hlen(struct igbvf_adapter *adapter,
+                                 union e1000_adv_rx_desc *rx_desc)
+{
+       /* HW will not DMA in data larger than the given buffer, even if it
+        * parses the (NFS, of course) header to be larger.  In that case, it
+        * fills the header buffer and spills the rest into the page.
+        */
+       u16 hlen = (le16_to_cpu(rx_desc->wb.lower.lo_dword.hs_rss.hdr_info) &
+                  E1000_RXDADV_HDRBUFLEN_MASK) >> E1000_RXDADV_HDRBUFLEN_SHIFT;
+       if (hlen > adapter->rx_ps_hdr_size)
+               hlen = adapter->rx_ps_hdr_size;
+       return hlen;
+}
+
 /**
  * igbvf_clean_rx_irq - Send received data up the network stack; legacy
  * @adapter: board private structure
@@ -236,7 +292,7 @@ no_buffers:
  * is no guarantee that everything was cleaned
  **/
 static bool igbvf_clean_rx_irq(struct igbvf_adapter *adapter,
-                               int *work_done, int work_to_do)
+                              int *work_done, int work_to_do)
 {
        struct igbvf_ring *rx_ring = adapter->rx_ring;
        struct net_device *netdev = adapter->netdev;
@@ -244,13 +300,15 @@ static bool igbvf_clean_rx_irq(struct igbvf_adapter *adapter,
        union e1000_adv_rx_desc *rx_desc, *next_rxd;
        struct igbvf_buffer *buffer_info, *next_buffer;
        struct sk_buff *skb;
-       bool cleaned = false;
+       bool cleaned = FALSE;
        int cleaned_count = 0;
        unsigned int total_bytes = 0, total_packets = 0;
        unsigned int i;
-       u32 length, hlen, staterr;
+       u32 staterr;
+       u16 length;
 
        i = rx_ring->next_to_clean;
+       buffer_info = &rx_ring->buffer_info[i];
        rx_desc = IGBVF_RX_DESC_ADV(*rx_ring, i);
        staterr = le32_to_cpu(rx_desc->wb.upper.status_error);
 
@@ -258,50 +316,48 @@ static bool igbvf_clean_rx_irq(struct igbvf_adapter *adapter,
                if (*work_done >= work_to_do)
                        break;
                (*work_done)++;
-               rmb(); /* read descriptor and rx_buffer_info after status DD */
 
-               buffer_info = &rx_ring->buffer_info[i];
+               skb = buffer_info->skb;
+               prefetch(skb->data - NET_IP_ALIGN);
+               buffer_info->skb = NULL;
 
-               /* HW will not DMA in data larger than the given buffer, even
-                * if it parses the (NFS, of course) header to be larger.  In
-                * that case, it fills the header buffer and spills the rest
-                * into the page.
-                */
-               hlen = (le16_to_cpu(rx_desc->wb.lower.lo_dword.hs_rss.hdr_info) &
-                 E1000_RXDADV_HDRBUFLEN_MASK) >> E1000_RXDADV_HDRBUFLEN_SHIFT;
-               if (hlen > adapter->rx_ps_hdr_size)
-                       hlen = adapter->rx_ps_hdr_size;
+               i++;
+               if (i == rx_ring->count)
+                       i = 0;
+               next_rxd = IGBVF_RX_DESC_ADV(*rx_ring, i);
+               prefetch(next_rxd);
+               next_buffer = &rx_ring->buffer_info[i];
 
                length = le16_to_cpu(rx_desc->wb.upper.length);
-               cleaned = true;
+               cleaned = TRUE;
                cleaned_count++;
 
-               skb = buffer_info->skb;
-               prefetch(skb->data - NET_IP_ALIGN);
-               buffer_info->skb = NULL;
                if (!adapter->rx_ps_hdr_size) {
-                       dma_unmap_single(&pdev->dev, buffer_info->dma,
-                                        adapter->rx_buffer_len,
+                       dma_unmap_single(pci_dev_to_dev(pdev), buffer_info->dma,
+                                        adapter->rx_buffer_len,
                                         DMA_FROM_DEVICE);
                        buffer_info->dma = 0;
                        skb_put(skb, length);
                        goto send_up;
                }
 
-               if (!skb_shinfo(skb)->nr_frags) {
-                       dma_unmap_single(&pdev->dev, buffer_info->dma,
-                                        adapter->rx_ps_hdr_size,
+               if (buffer_info->dma) {
+                       u16 hlen = igbvf_get_hlen(adapter, rx_desc);
+                       dma_unmap_single(pci_dev_to_dev(pdev), buffer_info->dma,
+                                        adapter->rx_ps_hdr_size,
                                         DMA_FROM_DEVICE);
+                       buffer_info->dma = 0;
                        skb_put(skb, hlen);
                }
 
                if (length) {
-                       dma_unmap_page(&pdev->dev, buffer_info->page_dma,
+                       dma_unmap_page(pci_dev_to_dev(pdev),
+                                      buffer_info->page_dma,
                                       PAGE_SIZE / 2,
-                                      DMA_FROM_DEVICE);
+                                      DMA_FROM_DEVICE);
                        buffer_info->page_dma = 0;
 
-                       skb_fill_page_desc(skb, skb_shinfo(skb)->nr_frags,
+                       skb_fill_page_desc(skb, skb_shinfo(skb)->nr_frags++,
                                           buffer_info->page,
                                           buffer_info->page_offset,
                                           length);
@@ -314,15 +370,8 @@ static bool igbvf_clean_rx_irq(struct igbvf_adapter *adapter,
 
                        skb->len += length;
                        skb->data_len += length;
-                       skb->truesize += PAGE_SIZE / 2;
+                       skb->truesize += length;
                }
-send_up:
-               i++;
-               if (i == rx_ring->count)
-                       i = 0;
-               next_rxd = IGBVF_RX_DESC_ADV(*rx_ring, i);
-               prefetch(next_rxd);
-               next_buffer = &rx_ring->buffer_info[i];
 
                if (!(staterr & E1000_RXD_STAT_EOP)) {
                        buffer_info->skb = next_buffer->skb;
@@ -331,7 +380,7 @@ send_up:
                        next_buffer->dma = 0;
                        goto next_desc;
                }
-
+send_up:
                if (staterr & E1000_RXDEXT_ERR_FRAME_ERR_MASK) {
                        dev_kfree_skb_irq(skb);
                        goto next_desc;
@@ -345,7 +394,9 @@ send_up:
                skb->protocol = eth_type_trans(skb, netdev);
 
                igbvf_receive_skb(adapter, netdev, skb, staterr,
-                                 rx_desc->wb.upper.vlan);
+                                 rx_desc->wb.upper.vlan);
+
+               netdev->last_rx = jiffies;
 
 next_desc:
                rx_desc->wb.upper.status_error = 0;
@@ -377,19 +428,20 @@ next_desc:
 }
 
 static void igbvf_put_txbuf(struct igbvf_adapter *adapter,
-                            struct igbvf_buffer *buffer_info)
-{
+                            struct igbvf_buffer *buffer_info)
+{
+       if (buffer_info->page_dma) {
+               dma_unmap_page(pci_dev_to_dev(adapter->pdev),
+                              buffer_info->page_dma,
+                              buffer_info->length,
+                              DMA_TO_DEVICE);
+               buffer_info->page_dma = 0;
+       }
        if (buffer_info->dma) {
-               if (buffer_info->mapped_as_page)
-                       dma_unmap_page(&adapter->pdev->dev,
-                                      buffer_info->dma,
-                                      buffer_info->length,
-                                      DMA_TO_DEVICE);
-               else
-                       dma_unmap_single(&adapter->pdev->dev,
-                                        buffer_info->dma,
-                                        buffer_info->length,
-                                        DMA_TO_DEVICE);
+               dma_unmap_single(pci_dev_to_dev(adapter->pdev),
+                                buffer_info->dma,
+                                buffer_info->length,
+                                DMA_TO_DEVICE);
                buffer_info->dma = 0;
        }
        if (buffer_info->skb) {
@@ -412,15 +464,16 @@ int igbvf_setup_tx_resources(struct igbvf_adapter *adapter,
        int size;
 
        size = sizeof(struct igbvf_buffer) * tx_ring->count;
-       tx_ring->buffer_info = vzalloc(size);
+       tx_ring->buffer_info = vmalloc(size);
        if (!tx_ring->buffer_info)
                goto err;
+       memset(tx_ring->buffer_info, 0, size);
 
        /* round up to nearest 4K */
        tx_ring->size = tx_ring->count * sizeof(union e1000_adv_tx_desc);
        tx_ring->size = ALIGN(tx_ring->size, 4096);
 
-       tx_ring->desc = dma_alloc_coherent(&pdev->dev, tx_ring->size,
+       tx_ring->desc = dma_alloc_coherent(pci_dev_to_dev(pdev), tx_ring->size,
                                           &tx_ring->dma, GFP_KERNEL);
 
        if (!tx_ring->desc)
@@ -429,12 +482,12 @@ int igbvf_setup_tx_resources(struct igbvf_adapter *adapter,
        tx_ring->adapter = adapter;
        tx_ring->next_to_use = 0;
        tx_ring->next_to_clean = 0;
+       spin_lock_init(&adapter->tx_queue_lock);
 
        return 0;
 err:
        vfree(tx_ring->buffer_info);
-       dev_err(&adapter->pdev->dev,
-               "Unable to allocate memory for the transmit descriptor ring\n");
+       e_err("Unable to allocate memory for the transmit descriptor ring\n");
        return -ENOMEM;
 }
 
@@ -451,9 +504,10 @@ int igbvf_setup_rx_resources(struct igbvf_adapter *adapter,
        int size, desc_len;
 
        size = sizeof(struct igbvf_buffer) * rx_ring->count;
-       rx_ring->buffer_info = vzalloc(size);
+       rx_ring->buffer_info = vmalloc(size);
        if (!rx_ring->buffer_info)
                goto err;
+       memset(rx_ring->buffer_info, 0, size);
 
        desc_len = sizeof(union e1000_adv_rx_desc);
 
@@ -461,8 +515,8 @@ int igbvf_setup_rx_resources(struct igbvf_adapter *adapter,
        rx_ring->size = rx_ring->count * desc_len;
        rx_ring->size = ALIGN(rx_ring->size, 4096);
 
-       rx_ring->desc = dma_alloc_coherent(&pdev->dev, rx_ring->size,
-                                          &rx_ring->dma, GFP_KERNEL);
+       rx_ring->desc = dma_alloc_coherent(pci_dev_to_dev(pdev), rx_ring->size,
+                                          &rx_ring->dma, GFP_KERNEL);
 
        if (!rx_ring->desc)
                goto err;
@@ -470,15 +524,12 @@ int igbvf_setup_rx_resources(struct igbvf_adapter *adapter,
        rx_ring->next_to_clean = 0;
        rx_ring->next_to_use = 0;
 
-       rx_ring->adapter = adapter;
-
        return 0;
 
 err:
        vfree(rx_ring->buffer_info);
        rx_ring->buffer_info = NULL;
-       dev_err(&adapter->pdev->dev,
-               "Unable to allocate memory for the receive descriptor ring\n");
+       e_err("Unable to allocate memory for the receive descriptor ring\n");
        return -ENOMEM;
 }
 
@@ -530,7 +581,7 @@ void igbvf_free_tx_resources(struct igbvf_ring *tx_ring)
        vfree(tx_ring->buffer_info);
        tx_ring->buffer_info = NULL;
 
-       dma_free_coherent(&pdev->dev, tx_ring->size, tx_ring->desc,
+       dma_free_coherent(pci_dev_to_dev(pdev), tx_ring->size, tx_ring->desc,
                          tx_ring->dma);
 
        tx_ring->desc = NULL;
@@ -545,24 +596,22 @@ static void igbvf_clean_rx_ring(struct igbvf_ring *rx_ring)
        struct igbvf_adapter *adapter = rx_ring->adapter;
        struct igbvf_buffer *buffer_info;
        struct pci_dev *pdev = adapter->pdev;
-       unsigned long size;
        unsigned int i;
 
-       if (!rx_ring->buffer_info)
-               return;
-
        /* Free all the Rx ring sk_buffs */
        for (i = 0; i < rx_ring->count; i++) {
                buffer_info = &rx_ring->buffer_info[i];
                if (buffer_info->dma) {
                        if (adapter->rx_ps_hdr_size){
-                               dma_unmap_single(&pdev->dev, buffer_info->dma,
+                               dma_unmap_single(pci_dev_to_dev(pdev),
+                                                buffer_info->dma,
                                                 adapter->rx_ps_hdr_size,
-                                                DMA_FROM_DEVICE);
+                                                DMA_FROM_DEVICE);
                        } else {
-                               dma_unmap_single(&pdev->dev, buffer_info->dma,
+                               dma_unmap_single(pci_dev_to_dev(pdev),
+                                                buffer_info->dma,
                                                 adapter->rx_buffer_len,
-                                                DMA_FROM_DEVICE);
+                                                DMA_FROM_DEVICE);
                        }
                        buffer_info->dma = 0;
                }
@@ -574,10 +623,10 @@ static void igbvf_clean_rx_ring(struct igbvf_ring *rx_ring)
 
                if (buffer_info->page) {
                        if (buffer_info->page_dma)
-                               dma_unmap_page(&pdev->dev,
+                               dma_unmap_page(pci_dev_to_dev(pdev),
                                               buffer_info->page_dma,
                                               PAGE_SIZE / 2,
-                                              DMA_FROM_DEVICE);
+                                              DMA_FROM_DEVICE);
                        put_page(buffer_info->page);
                        buffer_info->page = NULL;
                        buffer_info->page_dma = 0;
@@ -585,9 +634,6 @@ static void igbvf_clean_rx_ring(struct igbvf_ring *rx_ring)
                }
        }
 
-       size = sizeof(struct igbvf_buffer) * rx_ring->count;
-       memset(rx_ring->buffer_info, 0, size);
-
        /* Zero out the descriptor ring */
        memset(rx_ring->desc, 0, rx_ring->size);
 
@@ -614,8 +660,8 @@ void igbvf_free_rx_resources(struct igbvf_ring *rx_ring)
        vfree(rx_ring->buffer_info);
        rx_ring->buffer_info = NULL;
 
-       dma_free_coherent(&pdev->dev, rx_ring->size, rx_ring->desc,
-                         rx_ring->dma);
+       dma_free_coherent(pci_dev_to_dev(pdev), rx_ring->size, rx_ring->desc,
+                         rx_ring->dma);
        rx_ring->desc = NULL;
 }
 
@@ -632,11 +678,12 @@ void igbvf_free_rx_resources(struct igbvf_ring *rx_ring)
  *      traffic pattern.  Constants in this function were computed
  *      based on theoretical maximum wire speed and thresholds were set based
  *      on testing data as well as attempting to minimize response time
- *      while increasing bulk throughput.
+ *      while increasing bulk throughput.  This functionality is controlled
+ *      by the InterruptThrottleRate module parameter.
  **/
 static enum latency_range igbvf_update_itr(struct igbvf_adapter *adapter,
-                                          enum latency_range itr_setting,
-                                          int packets, int bytes)
+                                    enum latency_range itr_setting,
+                                    int packets, int bytes)
 {
        enum latency_range retval = itr_setting;
 
@@ -648,18 +695,20 @@ static enum latency_range igbvf_update_itr(struct igbvf_adapter *adapter,
                /* handle TSO and jumbo frames */
                if (bytes/packets > 8000)
                        retval = bulk_latency;
-               else if ((packets < 5) && (bytes > 512))
+               else if ((packets < 5) && (bytes > 512)) {
                        retval = low_latency;
+               }
                break;
        case low_latency:  /* 50 usec aka 20000 ints/s */
                if (bytes > 10000) {
                        /* this if handles the TSO accounting */
-                       if (bytes/packets > 8000)
+                       if (bytes/packets > 8000) {
                                retval = bulk_latency;
-                       else if ((packets < 10) || ((bytes/packets) > 1200))
+                       } else if ((packets < 10) || ((bytes/packets) > 1200)) {
                                retval = bulk_latency;
-                       else if ((packets > 35))
+                       } else if ((packets > 35)) {
                                retval = lowest_latency;
+                       }
                } else if (bytes/packets > 2000) {
                        retval = bulk_latency;
                } else if (packets <= 2 && bytes < 512) {
@@ -668,8 +717,9 @@ static enum latency_range igbvf_update_itr(struct igbvf_adapter *adapter,
                break;
        case bulk_latency: /* 250 usec aka 4000 ints/s */
                if (bytes > 25000) {
-                       if (packets > 35)
+                       if (packets > 35) {
                                retval = low_latency;
+                       }
                } else if (bytes < 6000) {
                        retval = low_latency;
                }
@@ -706,7 +756,7 @@ static int igbvf_range_to_itr(enum latency_range current_range)
 
 static void igbvf_set_itr(struct igbvf_adapter *adapter)
 {
-       u32 new_itr;
+       u32 new_itr = adapter->rx_ring->itr_val;
 
        adapter->tx_ring->itr_range =
                        igbvf_update_itr(adapter,
@@ -714,12 +764,12 @@ static void igbvf_set_itr(struct igbvf_adapter *adapter)
                                         adapter->total_tx_packets,
                                         adapter->total_tx_bytes);
 
-       /* conservative mode (itr 3) eliminates the lowest_latency setting */
        if (adapter->requested_itr == 3 &&
            adapter->tx_ring->itr_range == lowest_latency)
                adapter->tx_ring->itr_range = low_latency;
 
-       new_itr = igbvf_range_to_itr(adapter->tx_ring->itr_range);
+#ifdef CONFIG_IGBVF_SEPARATE_TX_HANDLER
+       new_itr = igbvf_range_to_itr(adapter->rx_ring->itr_range);
 
 
        if (new_itr != adapter->tx_ring->itr_val) {
@@ -736,19 +786,30 @@ static void igbvf_set_itr(struct igbvf_adapter *adapter)
 
                adapter->tx_ring->set_itr = 1;
        }
-
+#endif
        adapter->rx_ring->itr_range =
-                       igbvf_update_itr(adapter, adapter->rx_ring->itr_val,
+                       igbvf_update_itr(adapter,
+                                        adapter->rx_ring->itr_val,
                                         adapter->total_rx_packets,
                                         adapter->total_rx_bytes);
+       /* conservative mode (itr 3) eliminates the lowest_latency setting */
        if (adapter->requested_itr == 3 &&
            adapter->rx_ring->itr_range == lowest_latency)
                adapter->rx_ring->itr_range = low_latency;
 
+#ifndef CONFIG_IGBVF_SEPARATE_TX_HANDLER
+       new_itr = igbvf_range_to_itr(max(adapter->rx_ring->itr_range,
+                         adapter->tx_ring->itr_range));
+#else
        new_itr = igbvf_range_to_itr(adapter->rx_ring->itr_range);
-
+#endif
        if (new_itr != adapter->rx_ring->itr_val) {
                u32 current_itr = adapter->rx_ring->itr_val;
+               /*
+                * this attempts to bias the interrupt rate towards Bulk
+                * by adding intermediate steps when interrupt rate is
+                * increasing
+                */
                new_itr = new_itr > current_itr ?
                             min(current_itr + (new_itr >> 2), new_itr) :
                             new_itr;
@@ -761,7 +822,7 @@ static void igbvf_set_itr(struct igbvf_adapter *adapter)
 /**
  * igbvf_clean_tx_irq - Reclaim resources after transmit completes
  * @adapter: board private structure
- * returns true if ring is completely cleaned
+ * returns TRUE if ring is completely cleaned
  **/
 static bool igbvf_clean_tx_irq(struct igbvf_ring *tx_ring)
 {
@@ -780,7 +841,6 @@ static bool igbvf_clean_tx_irq(struct igbvf_ring *tx_ring)
 
        while ((eop_desc->wb.status & cpu_to_le32(E1000_TXD_STAT_DD)) &&
               (count < tx_ring->count)) {
-               rmb();  /* read buffer_info after eop_desc status */
                for (cleaned = false; !cleaned; count++) {
                        tx_desc = IGBVF_TX_DESC_ADV(*tx_ring, i);
                        buffer_info = &tx_ring->buffer_info[i];
@@ -788,6 +848,7 @@ static bool igbvf_clean_tx_irq(struct igbvf_ring *tx_ring)
                        skb = buffer_info->skb;
 
                        if (skb) {
+#ifdef NETIF_F_TSO
                                unsigned int segs, bytecount;
 
                                /* gso_segs is currently only valid for tcp */
@@ -797,6 +858,10 @@ static bool igbvf_clean_tx_irq(struct igbvf_ring *tx_ring)
                                            skb->len;
                                total_packets += segs;
                                total_bytes += bytecount;
+#else
+                               total_packets++;
+                               total_bytes += skb->len;
+#endif
                        }
 
                        igbvf_put_txbuf(adapter, buffer_info);
@@ -828,7 +893,7 @@ static bool igbvf_clean_tx_irq(struct igbvf_ring *tx_ring)
 
        adapter->net_stats.tx_bytes += total_bytes;
        adapter->net_stats.tx_packets += total_packets;
-       return count < tx_ring->count;
+       return (count < tx_ring->count);
 }
 
 static irqreturn_t igbvf_msix_other(int irq, void *data)
@@ -839,7 +904,6 @@ static irqreturn_t igbvf_msix_other(int irq, void *data)
 
        adapter->int_counter1++;
 
-       netif_carrier_off(netdev);
        hw->mac.get_link_status = 1;
        if (!test_bit(__IGBVF_DOWN, &adapter->state))
                mod_timer(&adapter->watchdog_timer, jiffies + 1);
@@ -849,6 +913,7 @@ static irqreturn_t igbvf_msix_other(int irq, void *data)
        return IRQ_HANDLED;
 }
 
+#ifdef CONFIG_IGBVF_SEPARATE_TX_HANDLER
 static irqreturn_t igbvf_intr_msix_tx(int irq, void *data)
 {
        struct net_device *netdev = data;
@@ -859,7 +924,7 @@ static irqreturn_t igbvf_intr_msix_tx(int irq, void *data)
        if (tx_ring->set_itr) {
                writel(tx_ring->itr_val,
                       adapter->hw.hw_addr + tx_ring->itr_register);
-               adapter->tx_ring->set_itr = 0;
+               adapter->rx_ring->set_itr = 0;
        }
 
        adapter->total_tx_bytes = 0;
@@ -876,6 +941,7 @@ static irqreturn_t igbvf_intr_msix_tx(int irq, void *data)
        return IRQ_HANDLED;
 }
 
+#endif  /* CONFIG_IGBVF_SEPARATE_TX_HANDLER */
 static irqreturn_t igbvf_intr_msix_rx(int irq, void *data)
 {
        struct net_device *netdev = data;
@@ -895,6 +961,10 @@ static irqreturn_t igbvf_intr_msix_rx(int irq, void *data)
        if (napi_schedule_prep(&adapter->rx_ring->napi)) {
                adapter->total_rx_bytes = 0;
                adapter->total_rx_packets = 0;
+#ifndef CONFIG_IGBVF_SEPARATE_TX_HANDLER
+               adapter->total_tx_bytes = 0;
+               adapter->total_tx_packets = 0;
+#endif /* CONFIG_IGBVF_SEPARATE_TX_HANDLER */
                __napi_schedule(&adapter->rx_ring->napi);
        }
 
@@ -904,7 +974,7 @@ static irqreturn_t igbvf_intr_msix_rx(int irq, void *data)
 #define IGBVF_NO_QUEUE -1
 
 static void igbvf_assign_vector(struct igbvf_adapter *adapter, int rx_queue,
-                                int tx_queue, int msix_vector)
+                              int tx_queue, int msix_vector)
 {
        struct e1000_hw *hw = &adapter->hw;
        u32 ivar, index;
@@ -915,7 +985,7 @@ static void igbvf_assign_vector(struct igbvf_adapter *adapter, int rx_queue,
           of the table is somewhat counterintuitive. */
        if (rx_queue > IGBVF_NO_QUEUE) {
                index = (rx_queue >> 1);
-               ivar = array_er32(IVAR0, index);
+               ivar = E1000_READ_REG_ARRAY(hw, E1000_IVAR0, index);
                if (rx_queue & 0x1) {
                        /* vector goes into third byte of register */
                        ivar = ivar & 0xFF00FFFF;
@@ -926,11 +996,11 @@ static void igbvf_assign_vector(struct igbvf_adapter *adapter, int rx_queue,
                        ivar |= msix_vector | E1000_IVAR_VALID;
                }
                adapter->rx_ring[rx_queue].eims_value = 1 << msix_vector;
-               array_ew32(IVAR0, index, ivar);
+               E1000_WRITE_REG_ARRAY(hw, E1000_IVAR0, index, ivar);
        }
        if (tx_queue > IGBVF_NO_QUEUE) {
                index = (tx_queue >> 1);
-               ivar = array_er32(IVAR0, index);
+               ivar = E1000_READ_REG_ARRAY(hw, E1000_IVAR0, index);
                if (tx_queue & 0x1) {
                        /* vector goes into high byte of register */
                        ivar = ivar & 0x00FFFFFF;
@@ -941,7 +1011,7 @@ static void igbvf_assign_vector(struct igbvf_adapter *adapter, int rx_queue,
                        ivar |= (msix_vector | E1000_IVAR_VALID) << 8;
                }
                adapter->tx_ring[tx_queue].eims_value = 1 << msix_vector;
-               array_ew32(IVAR0, index, ivar);
+               E1000_WRITE_REG_ARRAY(hw, E1000_IVAR0, index, ivar);
        }
 }
 
@@ -954,38 +1024,48 @@ static void igbvf_assign_vector(struct igbvf_adapter *adapter, int rx_queue,
 static void igbvf_configure_msix(struct igbvf_adapter *adapter)
 {
        u32 tmp;
+       int vector = 0;
        struct e1000_hw *hw = &adapter->hw;
-       struct igbvf_ring *tx_ring = adapter->tx_ring;
        struct igbvf_ring *rx_ring = adapter->rx_ring;
-       int vector = 0;
+#ifdef CONFIG_IGBVF_SEPARATE_TX_HANDLER
+       struct igbvf_ring *tx_ring = adapter->tx_ring;
+#endif
 
        adapter->eims_enable_mask = 0;
 
+#ifdef CONFIG_IGBVF_SEPARATE_TX_HANDLER
        igbvf_assign_vector(adapter, IGBVF_NO_QUEUE, 0, vector++);
        adapter->eims_enable_mask |= tx_ring->eims_value;
        writel(tx_ring->itr_val, hw->hw_addr + tx_ring->itr_register);
        igbvf_assign_vector(adapter, 0, IGBVF_NO_QUEUE, vector++);
        adapter->eims_enable_mask |= rx_ring->eims_value;
        writel(rx_ring->itr_val, hw->hw_addr + rx_ring->itr_register);
+#else
+       igbvf_assign_vector(adapter, 0, 0, vector++);
+       adapter->eims_enable_mask |= rx_ring->eims_value;
+       writel(rx_ring->itr_val, hw->hw_addr + rx_ring->itr_register);
+#endif
 
        /* set vector for other causes, i.e. link changes */
 
        tmp = (vector++ | E1000_IVAR_VALID);
 
-       ew32(IVAR_MISC, tmp);
+       E1000_WRITE_REG(hw, E1000_IVAR_MISC, tmp);
 
        adapter->eims_enable_mask = (1 << (vector)) - 1;
        adapter->eims_other = 1 << (vector - 1);
-       e1e_flush();
+       E1000_WRITE_FLUSH(hw);
 }
 
-static void igbvf_reset_interrupt_capability(struct igbvf_adapter *adapter)
+void igbvf_reset_interrupt_capability(struct igbvf_adapter *adapter)
 {
        if (adapter->msix_entries) {
                pci_disable_msix(adapter->pdev);
                kfree(adapter->msix_entries);
                adapter->msix_entries = NULL;
        }
+
+       return;
 }
 
 /**
@@ -994,28 +1074,36 @@ static void igbvf_reset_interrupt_capability(struct igbvf_adapter *adapter)
  * Attempt to configure interrupts using the best available
  * capabilities of the hardware and kernel.
  **/
-static void igbvf_set_interrupt_capability(struct igbvf_adapter *adapter)
+void igbvf_set_interrupt_capability(struct igbvf_adapter *adapter)
 {
-       int err = -ENOMEM;
-       int i;
+       int err;
+       int numvecs, i;
 
-       /* we allocate 3 vectors, 1 for tx, 1 for rx, one for pf messages */
-       adapter->msix_entries = kcalloc(3, sizeof(struct msix_entry),
-                                       GFP_KERNEL);
+#ifdef CONFIG_IGBVF_SEPARATE_TX_HANDLER
+       numvecs = 3;
+#else
+       numvecs = 2;
+#endif
+       adapter->msix_entries = kcalloc(numvecs,
+                                       sizeof(struct msix_entry),
+                                       GFP_KERNEL);
        if (adapter->msix_entries) {
-               for (i = 0; i < 3; i++)
+               for (i=0; i < numvecs; i++)
                        adapter->msix_entries[i].entry = i;
 
                err = pci_enable_msix(adapter->pdev,
-                                     adapter->msix_entries, 3);
+                                     adapter->msix_entries, numvecs);
+               if (err == 0) {
+                       goto msix_enabled;
+               }
        }
+       /* MSI-X failed - we're screwed */
+       printk(KERN_ERR "Failed to initialize MSI-X interrupts.\n");
+       igbvf_reset_interrupt_capability(adapter);
 
-       if (err) {
-               /* MSI-X failed */
-               dev_err(&adapter->pdev->dev,
-                       "Failed to initialize MSI-X interrupts.\n");
-               igbvf_reset_interrupt_capability(adapter);
-       }
+msix_enabled:
+
+       return;
 }
 
 /**
@@ -1030,15 +1118,22 @@ static int igbvf_request_msix(struct igbvf_adapter *adapter)
        int err = 0, vector = 0;
 
        if (strlen(netdev->name) < (IFNAMSIZ - 5)) {
+#ifdef CONFIG_IGBVF_SEPARATE_TX_HANDLER
                sprintf(adapter->tx_ring->name, "%s-tx-0", netdev->name);
                sprintf(adapter->rx_ring->name, "%s-rx-0", netdev->name);
+#else
+               sprintf(adapter->rx_ring->name, "%s-TxRx0", netdev->name);
+#endif
        } else {
+#ifdef CONFIG_IGBVF_SEPARATE_TX_HANDLER
                memcpy(adapter->tx_ring->name, netdev->name, IFNAMSIZ);
+#endif
                memcpy(adapter->rx_ring->name, netdev->name, IFNAMSIZ);
        }
 
+#ifdef CONFIG_IGBVF_SEPARATE_TX_HANDLER
        err = request_irq(adapter->msix_entries[vector].vector,
-                         igbvf_intr_msix_tx, 0, adapter->tx_ring->name,
+                         &igbvf_intr_msix_tx, 0, adapter->tx_ring->name,
                          netdev);
        if (err)
                goto out;
@@ -1047,8 +1142,9 @@ static int igbvf_request_msix(struct igbvf_adapter *adapter)
        adapter->tx_ring->itr_val = adapter->current_itr;
        vector++;
 
+#endif
        err = request_irq(adapter->msix_entries[vector].vector,
-                         igbvf_intr_msix_rx, 0, adapter->rx_ring->name,
+                         &igbvf_intr_msix_rx, 0, adapter->rx_ring->name,
                          netdev);
        if (err)
                goto out;
@@ -1058,7 +1154,7 @@ static int igbvf_request_msix(struct igbvf_adapter *adapter)
        vector++;
 
        err = request_irq(adapter->msix_entries[vector].vector,
-                         igbvf_msix_other, 0, netdev->name, netdev);
+                         &igbvf_msix_other, 0, netdev->name, netdev);
        if (err)
                goto out;
 
@@ -1074,21 +1170,24 @@ out:
  **/
 static int __devinit igbvf_alloc_queues(struct igbvf_adapter *adapter)
 {
-       struct net_device *netdev = adapter->netdev;
-
        adapter->tx_ring = kzalloc(sizeof(struct igbvf_ring), GFP_KERNEL);
        if (!adapter->tx_ring)
-               return -ENOMEM;
+               goto tx_err;
+       adapter->tx_ring->adapter = adapter;
 
        adapter->rx_ring = kzalloc(sizeof(struct igbvf_ring), GFP_KERNEL);
-       if (!adapter->rx_ring) {
-               kfree(adapter->tx_ring);
-               return -ENOMEM;
-       }
-
-       netif_napi_add(netdev, &adapter->rx_ring->napi, igbvf_poll, 64);
+       if (!adapter->rx_ring)
+               goto err;
+       adapter->rx_ring->adapter = adapter;
+       netif_napi_add(adapter->netdev, &adapter->rx_ring->napi, igbvf_poll, 64);
 
        return 0;
+err:
+       e_err("Unable to allocate memory for queues\n");
+       kfree(adapter->rx_ring);
+tx_err:
+       kfree(adapter->tx_ring);
+       return -ENOMEM;
 }
 
 /**
@@ -1101,15 +1200,15 @@ static int igbvf_request_irq(struct igbvf_adapter *adapter)
 {
        int err = -1;
 
-       /* igbvf supports msi-x only */
-       if (adapter->msix_entries)
+       if (adapter->msix_entries) {
                err = igbvf_request_msix(adapter);
+               if (!err)
+                       return err;
+               else
+                       e_err("Unable to allocate interrupt, Error: %d\n", err);
+       }
 
-       if (!err)
-               return err;
-
-       dev_err(&adapter->pdev->dev,
-               "Unable to allocate interrupt, Error: %d\n", err);
+       e_err("MSI-X Allocation failed, Error: %d\n", err);
 
        return err;
 }
@@ -1117,11 +1216,20 @@ static int igbvf_request_irq(struct igbvf_adapter *adapter)
 static void igbvf_free_irq(struct igbvf_adapter *adapter)
 {
        struct net_device *netdev = adapter->netdev;
-       int vector;
 
        if (adapter->msix_entries) {
-               for (vector = 0; vector < 3; vector++)
-                       free_irq(adapter->msix_entries[vector].vector, netdev);
+               int vector = 0;
+
+#ifdef CONFIG_IGBVF_SEPARATE_TX_HANDLER
+               free_irq(adapter->msix_entries[vector].vector, netdev);
+               vector++;
+#endif
+               free_irq(adapter->msix_entries[vector].vector, netdev);
+               vector++;
+
+               /* Other Causes interrupt vector */
+               free_irq(adapter->msix_entries[vector].vector, netdev);
+               return;
        }
 }
 
@@ -1134,8 +1242,9 @@ static void igbvf_irq_disable(struct igbvf_adapter *adapter)
 
        ew32(EIMC, ~0);
 
-       if (adapter->msix_entries)
+       if (adapter->msix_entries) {
                ew32(EIAC, 0);
+       }
 }
 
 /**
@@ -1159,12 +1268,23 @@ static int igbvf_poll(struct napi_struct *napi, int budget)
 {
        struct igbvf_ring *rx_ring = container_of(napi, struct igbvf_ring, napi);
        struct igbvf_adapter *adapter = rx_ring->adapter;
-       struct e1000_hw *hw = &adapter->hw;
        int work_done = 0;
+       struct e1000_hw *hw = &adapter->hw;
 
        igbvf_clean_rx_irq(adapter, &work_done, budget);
 
-       /* If not enough Rx work done, exit the polling mode */
+#ifndef CONFIG_IGBVF_SEPARATE_TX_HANDLER
+       if (!igbvf_clean_tx_irq(adapter->tx_ring))
+               work_done = budget;
+
+#endif
+#ifndef HAVE_NETDEV_NAPI_LIST
+       /* if netdev is disabled we need to stop polling */
+       if (!netif_running(adapter->netdev))
+               work_done = 0;
+
+#endif
+       /* If no Tx and not enough Rx work done, exit the polling mode */
        if (work_done < budget) {
                napi_complete(napi);
 
@@ -1172,56 +1292,82 @@ static int igbvf_poll(struct napi_struct *napi, int budget)
                        igbvf_set_itr(adapter);
 
                if (!test_bit(__IGBVF_DOWN, &adapter->state))
-                       ew32(EIMS, adapter->rx_ring->eims_value);
+                       ew32(EIMS, rx_ring->eims_value);
        }
 
        return work_done;
 }
 
-/**
- * igbvf_set_rlpml - set receive large packet maximum length
- * @adapter: board private structure
- *
- * Configure the maximum size of packets that will be received
- */
-static void igbvf_set_rlpml(struct igbvf_adapter *adapter)
+static void igbvf_vlan_rx_add_vid(struct net_device *netdev, u16 vid)
 {
-       int max_frame_size;
-       struct e1000_hw *hw = &adapter->hw;
+       struct igbvf_adapter *adapter = netdev_priv(netdev);
+#ifndef HAVE_NETDEV_VLAN_FEATURES
+       struct net_device *v_netdev;
+#endif
+
+       e1000_vfta_set_vf(&adapter->hw, vid, TRUE);
+       set_bit(vid, adapter->active_vlans);
+
+#ifndef HAVE_NETDEV_VLAN_FEATURES
 
-       max_frame_size = adapter->max_frame_size + VLAN_TAG_SIZE;
-       e1000_rlpml_set_vf(hw, max_frame_size);
+       /*
+        * Copy feature flags from netdev to the vlan netdev for this vid.
+        * This allows things like TSO to bubble down to our vlan device.
+        */
+       v_netdev = vlan_group_get_device(adapter->vlgrp, vid);
+       v_netdev->features |= adapter->netdev->features;
+       vlan_group_set_device(adapter->vlgrp, vid, v_netdev);
+#endif
 }
 
-static void igbvf_vlan_rx_add_vid(struct net_device *netdev, u16 vid)
+static void igbvf_vlan_rx_kill_vid(struct net_device *netdev, u16 vid)
 {
        struct igbvf_adapter *adapter = netdev_priv(netdev);
-       struct e1000_hw *hw = &adapter->hw;
 
-       if (hw->mac.ops.set_vfta(hw, vid, true))
-               dev_err(&adapter->pdev->dev, "Failed to add vlan id %d\n", vid);
-       else
-               set_bit(vid, adapter->active_vlans);
+#ifdef HAVE_VLAN_RX_REGISTER
+       igbvf_irq_disable(adapter);
+       vlan_group_set_device(adapter->vlgrp, vid, NULL);
+
+       if (!test_bit(__IGBVF_DOWN, &adapter->state))
+               igbvf_irq_enable(adapter);
+#endif
+       e1000_vfta_set_vf(&adapter->hw, vid, FALSE);
+       clear_bit(vid, adapter->active_vlans);
 }
 
-static void igbvf_vlan_rx_kill_vid(struct net_device *netdev, u16 vid)
+#ifdef HAVE_VLAN_RX_REGISTER
+static void igbvf_vlan_rx_register(struct net_device *netdev,
+                                  struct vlan_group *grp)
 {
        struct igbvf_adapter *adapter = netdev_priv(netdev);
-       struct e1000_hw *hw = &adapter->hw;
 
-       if (hw->mac.ops.set_vfta(hw, vid, false))
-               dev_err(&adapter->pdev->dev,
-                       "Failed to remove vlan id %d\n", vid);
-       else
-               clear_bit(vid, adapter->active_vlans);
+       adapter->vlgrp = grp;
+
+       e1000_rlpml_set_vf(&adapter->hw, adapter->max_frame_size);
 }
+#endif
 
 static void igbvf_restore_vlan(struct igbvf_adapter *adapter)
 {
        u16 vid;
 
-       for_each_set_bit(vid, adapter->active_vlans, VLAN_N_VID)
+#ifdef HAVE_VLAN_RX_REGISTER
+       igbvf_vlan_rx_register(adapter->netdev, adapter->vlgrp);
+
+       if (!adapter->vlgrp)
+               return;
+#endif
+
+       for (vid = 0; vid < VLAN_N_VID; vid++) {
+#ifdef HAVE_VLAN_RX_REGISTER
+               if (!vlan_group_get_device(adapter->vlgrp, vid))
+                       continue;
+#else
+               if (!test_bit(vid, adapter->active_vlans))
+                       continue;
+#endif
                igbvf_vlan_rx_add_vid(adapter->netdev, vid);
+       }
 }
 
 /**
@@ -1235,12 +1381,10 @@ static void igbvf_configure_tx(struct igbvf_adapter *adapter)
        struct e1000_hw *hw = &adapter->hw;
        struct igbvf_ring *tx_ring = adapter->tx_ring;
        u64 tdba;
-       u32 txdctl, dca_txctrl;
+       u32 txdctl = 0;
 
        /* disable transmits */
-       txdctl = er32(TXDCTL(0));
-       ew32(TXDCTL(0), txdctl & ~E1000_TXDCTL_QUEUE_ENABLE);
-       e1e_flush();
+       ew32(TXDCTL(0), 0);
        msleep(10);
 
        /* Setup the HW Tx Head and Tail descriptor pointers */
@@ -1253,23 +1397,19 @@ static void igbvf_configure_tx(struct igbvf_adapter *adapter)
        tx_ring->head = E1000_TDH(0);
        tx_ring->tail = E1000_TDT(0);
 
-       /* Turn off Relaxed Ordering on head write-backs.  The writebacks
-        * MUST be delivered in order or it will completely screw up
-        * our bookeeping.
-        */
-       dca_txctrl = er32(DCA_TXCTRL(0));
-       dca_txctrl &= ~E1000_DCA_TXCTRL_TX_WB_RO_EN;
-       ew32(DCA_TXCTRL(0), dca_txctrl);
+       txdctl |= IGBVF_TX_PTHRESH;
+       txdctl |= IGBVF_TX_HTHRESH << 8;
+       txdctl |= IGBVF_TX_WTHRESH << 16;
 
        /* enable transmits */
        txdctl |= E1000_TXDCTL_QUEUE_ENABLE;
        ew32(TXDCTL(0), txdctl);
 
-       /* Setup Transmit Descriptor Settings for eop descriptor */
-       adapter->txd_cmd = E1000_ADVTXD_DCMD_EOP | E1000_ADVTXD_DCMD_IFCS;
+       /* Setup Transmit Descriptor Settings for eop descriptor and
+        * enable Report Status bit */
+       adapter->txd_cmd = E1000_ADVTXD_DCMD_EOP | E1000_ADVTXD_DCMD_RS;
 
-       /* enable Report Status bit */
-       adapter->txd_cmd |= E1000_ADVTXD_DCMD_RS;
+       adapter->tx_queue_len = adapter->netdev->tx_queue_len;
 }
 
 /**
@@ -1282,8 +1422,8 @@ static void igbvf_setup_srrctl(struct igbvf_adapter *adapter)
        u32 srrctl = 0;
 
        srrctl &= ~(E1000_SRRCTL_DESCTYPE_MASK |
-                   E1000_SRRCTL_BSIZEHDR_MASK |
-                   E1000_SRRCTL_BSIZEPKT_MASK);
+                   E1000_SRRCTL_BSIZEHDR_MASK |
+                   E1000_SRRCTL_BSIZEPKT_MASK);
 
        /* Enable queue drop to avoid head of line blocking */
        srrctl |= E1000_SRRCTL_DROP_EN;
@@ -1316,16 +1456,12 @@ static void igbvf_configure_rx(struct igbvf_adapter *adapter)
        struct e1000_hw *hw = &adapter->hw;
        struct igbvf_ring *rx_ring = adapter->rx_ring;
        u64 rdba;
-       u32 rdlen, rxdctl;
+       u32 rxdctl = 0;
 
        /* disable receives */
-       rxdctl = er32(RXDCTL(0));
-       ew32(RXDCTL(0), rxdctl & ~E1000_RXDCTL_QUEUE_ENABLE);
-       e1e_flush();
+       ew32(RXDCTL(0), 0);
        msleep(10);
 
-       rdlen = rx_ring->count * sizeof(union e1000_adv_rx_desc);
-
        /*
         * Setup the HW Rx Head and Tail Descriptor Pointers and
         * the Base and Length of the Rx Descriptor Ring
@@ -1339,15 +1475,14 @@ static void igbvf_configure_rx(struct igbvf_adapter *adapter)
        ew32(RDH(0), 0);
        ew32(RDT(0), 0);
 
-       rxdctl |= E1000_RXDCTL_QUEUE_ENABLE;
-       rxdctl &= 0xFFF00000;
        rxdctl |= IGBVF_RX_PTHRESH;
        rxdctl |= IGBVF_RX_HTHRESH << 8;
        rxdctl |= IGBVF_RX_WTHRESH << 16;
 
-       igbvf_set_rlpml(adapter);
+       e1000_rlpml_set_vf(hw, adapter->max_frame_size);
 
        /* enable receives */
+       rxdctl |= E1000_RXDCTL_QUEUE_ENABLE;
        ew32(RXDCTL(0), rxdctl);
 }
 
@@ -1364,9 +1499,23 @@ static void igbvf_set_multi(struct net_device *netdev)
 {
        struct igbvf_adapter *adapter = netdev_priv(netdev);
        struct e1000_hw *hw = &adapter->hw;
+#ifdef NETDEV_HW_ADDR_T_MULTICAST
        struct netdev_hw_addr *ha;
+#else
+       struct dev_mc_list *ha;
+#endif
        u8  *mta_list = NULL;
-       int i;
+       int i, err;
+
+       if (netdev->flags & IFF_PROMISC)
+               err = e1000_promisc_set_vf(hw, e1000_promisc_enabled);
+       else if (netdev->flags & IFF_ALLMULTI)
+               err = e1000_promisc_set_vf(hw, e1000_promisc_multicast);
+       else
+               err = e1000_promisc_set_vf(hw, e1000_promisc_disabled);
+
+       if (err && (netdev->flags & (IFF_PROMISC | IFF_ALLMULTI)))
+               printk(KERN_ERR "PF may not support PROMISC/ALLMULTI\n");
 
        if (!netdev_mc_empty(netdev)) {
                mta_list = kmalloc(netdev_mc_count(netdev) * 6, GFP_ATOMIC);
@@ -1380,9 +1529,13 @@ static void igbvf_set_multi(struct net_device *netdev)
        /* prepare a packed array of only addresses. */
        i = 0;
        netdev_for_each_mc_addr(ha, netdev)
+#ifdef NETDEV_HW_ADDR_T_MULTICAST
                memcpy(mta_list + (i++ * ETH_ALEN), ha->addr, ETH_ALEN);
+#else
+               memcpy(mta_list + (i++ * ETH_ALEN), ha->dmi_addr, ETH_ALEN);
+#endif
 
-       hw->mac.ops.update_mc_addr_list(hw, mta_list, i, 0, 0);
+       hw->mac.ops.update_mc_addr_list(hw, mta_list, i);
        kfree(mta_list);
 }
 
@@ -1399,8 +1552,7 @@ static void igbvf_configure(struct igbvf_adapter *adapter)
        igbvf_configure_tx(adapter);
        igbvf_setup_srrctl(adapter);
        igbvf_configure_rx(adapter);
-       igbvf_alloc_rx_buffers(adapter->rx_ring,
-                              igbvf_desc_unused(adapter->rx_ring));
+       igbvf_alloc_rx_buffers(adapter->rx_ring, igbvf_desc_unused(adapter->rx_ring));
 }
 
 /* igbvf_reset - bring the hardware into a known good state
@@ -1410,7 +1562,7 @@ static void igbvf_configure(struct igbvf_adapter *adapter)
  * set/changed during runtime. After reset the device needs to be
  * properly configured for Rx, Tx etc.
  */
-static void igbvf_reset(struct igbvf_adapter *adapter)
+void igbvf_reset(struct igbvf_adapter *adapter)
 {
        struct e1000_mac_info *mac = &adapter->hw.mac;
        struct net_device *netdev = adapter->netdev;
@@ -1418,15 +1570,29 @@ static void igbvf_reset(struct igbvf_adapter *adapter)
 
        /* Allow time for pending master requests to run */
        if (mac->ops.reset_hw(hw))
-               dev_err(&adapter->pdev->dev, "PF still resetting\n");
+               e_err("PF still resetting\n");
 
-       mac->ops.init_hw(hw);
+       /*
+        * Init HW just tries to set the MAC Address so skip if we've got
+        * a good one already - avoid extraneous warning on the PF driver
+        * side about how the VF is trying to override its administratively
+        * set MAC address.
+        */
+       if (!is_valid_ether_addr(adapter->hw.mac.addr)) {
+               if (mac->ops.init_hw(hw))
+                       e_err("Hardware Error\n");
+       }
 
        if (is_valid_ether_addr(adapter->hw.mac.addr)) {
-               memcpy(netdev->dev_addr, adapter->hw.mac.addr,
-                      netdev->addr_len);
-               memcpy(netdev->perm_addr, adapter->hw.mac.addr,
-                      netdev->addr_len);
+               memcpy(netdev->dev_addr, adapter->hw.mac.addr, netdev->addr_len);
+#ifdef ETHTOOL_GPERMADDR
+               memcpy(netdev->perm_addr, adapter->hw.mac.addr, netdev->addr_len);
+#endif
+       } else {
+               e_err("Invalid MAC Address: %02x:%02x:%02x:%02x:%02x:%02x\n",
+                     adapter->hw.mac.addr[0], adapter->hw.mac.addr[1],
+                     adapter->hw.mac.addr[2], adapter->hw.mac.addr[3],
+                     adapter->hw.mac.addr[4], adapter->hw.mac.addr[5]);
        }
 
        adapter->last_reset = jiffies;
@@ -1453,15 +1619,12 @@ int igbvf_up(struct igbvf_adapter *adapter)
        hw->mac.get_link_status = 1;
        mod_timer(&adapter->watchdog_timer, jiffies + 1);
 
-
        return 0;
 }
 
 void igbvf_down(struct igbvf_adapter *adapter)
 {
        struct net_device *netdev = adapter->netdev;
-       struct e1000_hw *hw = &adapter->hw;
-       u32 rxdctl, txdctl;
 
        /*
         * signal that we're down so the interrupt handler does not
@@ -1469,18 +1632,11 @@ void igbvf_down(struct igbvf_adapter *adapter)
         */
        set_bit(__IGBVF_DOWN, &adapter->state);
 
-       /* disable receives in the hardware */
-       rxdctl = er32(RXDCTL(0));
-       ew32(RXDCTL(0), rxdctl & ~E1000_RXDCTL_QUEUE_ENABLE);
-
        netif_stop_queue(netdev);
 
-       /* disable transmits in the hardware */
-       txdctl = er32(TXDCTL(0));
-       ew32(TXDCTL(0), txdctl & ~E1000_TXDCTL_QUEUE_ENABLE);
+       /* FIX ME!!!! */
+       /* need to disable local queue transmit and receive */
 
-       /* flush both disables and wait for them to finish */
-       e1e_flush();
        msleep(10);
 
        napi_disable(&adapter->rx_ring->napi);
@@ -1489,11 +1645,8 @@ void igbvf_down(struct igbvf_adapter *adapter)
 
        del_timer_sync(&adapter->watchdog_timer);
 
+       netdev->tx_queue_len = adapter->tx_queue_len;
        netif_carrier_off(netdev);
-
-       /* record the stats before reset*/
-       igbvf_update_stats(adapter);
-
        adapter->link_speed = 0;
        adapter->link_duplex = 0;
 
@@ -1530,13 +1683,6 @@ static int __devinit igbvf_sw_init(struct igbvf_adapter *adapter)
        adapter->max_frame_size = netdev->mtu + ETH_HLEN + ETH_FCS_LEN;
        adapter->min_frame_size = ETH_ZLEN + ETH_FCS_LEN;
 
-       adapter->tx_int_delay = 8;
-       adapter->tx_abs_int_delay = 32;
-       adapter->rx_int_delay = 0;
-       adapter->rx_abs_int_delay = 8;
-       adapter->requested_itr = 3;
-       adapter->current_itr = IGBVF_START_ITR;
-
        /* Set various function pointers */
        adapter->ei->init_ops(&adapter->hw);
 
@@ -1564,6 +1710,7 @@ static int __devinit igbvf_sw_init(struct igbvf_adapter *adapter)
        return 0;
 }
 
+
 static void igbvf_initialize_last_counter_stats(struct igbvf_adapter *adapter)
 {
        struct e1000_hw *hw = &adapter->hw;
@@ -1643,6 +1790,7 @@ static int igbvf_open(struct net_device *netdev)
 
        igbvf_irq_enable(adapter);
 
+
        /* start the watchdog */
        hw->mac.get_link_status = 1;
        mod_timer(&adapter->watchdog_timer, jiffies + 1);
@@ -1708,19 +1856,18 @@ static int igbvf_set_mac(struct net_device *netdev, void *p)
                return -EADDRNOTAVAIL;
 
        memcpy(netdev->dev_addr, addr->sa_data, netdev->addr_len);
-       netdev->addr_assign_type &= ~NET_ADDR_RANDOM;
 
        return 0;
 }
 
-#define UPDATE_VF_COUNTER(reg, name)                                    \
-       {                                                               \
-               u32 current_counter = er32(reg);                        \
-               if (current_counter < adapter->stats.last_##name)       \
-                       adapter->stats.name += 0x100000000LL;           \
-               adapter->stats.last_##name = current_counter;           \
-               adapter->stats.name &= 0xFFFFFFFF00000000LL;            \
-               adapter->stats.name |= current_counter;                 \
+#define UPDATE_VF_COUNTER(reg, last_counter, counter)  \
+       {                                               \
+               u32 current_counter = er32(reg);        \
+               if (current_counter < last_counter)     \
+                       counter += 0x100000000LL;       \
+               last_counter = current_counter;         \
+               counter &= 0xFFFFFFFF00000000LL;        \
+               counter |= current_counter;             \
        }
 
 /**
@@ -1730,7 +1877,9 @@ static int igbvf_set_mac(struct net_device *netdev, void *p)
 void igbvf_update_stats(struct igbvf_adapter *adapter)
 {
        struct e1000_hw *hw = &adapter->hw;
+#ifdef HAVE_PCI_ERS
        struct pci_dev *pdev = adapter->pdev;
+#endif
 
        /*
         * Prevent stats update while adapter is being reset, link is down
@@ -1742,18 +1891,20 @@ void igbvf_update_stats(struct igbvf_adapter *adapter)
        if (test_bit(__IGBVF_RESETTING, &adapter->state))
                return;
 
+#ifdef HAVE_PCI_ERS
        if (pci_channel_offline(pdev))
                return;
+#endif
 
-       UPDATE_VF_COUNTER(VFGPRC, gprc);
-       UPDATE_VF_COUNTER(VFGORC, gorc);
-       UPDATE_VF_COUNTER(VFGPTC, gptc);
-       UPDATE_VF_COUNTER(VFGOTC, gotc);
-       UPDATE_VF_COUNTER(VFMPRC, mprc);
-       UPDATE_VF_COUNTER(VFGOTLBC, gotlbc);
-       UPDATE_VF_COUNTER(VFGPTLBC, gptlbc);
-       UPDATE_VF_COUNTER(VFGORLBC, gorlbc);
-       UPDATE_VF_COUNTER(VFGPRLBC, gprlbc);
+       UPDATE_VF_COUNTER(VFGPRC, adapter->stats.last_gprc, adapter->stats.gprc);
+       UPDATE_VF_COUNTER(VFGORC, adapter->stats.last_gorc, adapter->stats.gorc);
+       UPDATE_VF_COUNTER(VFGPTC, adapter->stats.last_gptc, adapter->stats.gptc);
+       UPDATE_VF_COUNTER(VFGOTC, adapter->stats.last_gotc, adapter->stats.gotc);
+       UPDATE_VF_COUNTER(VFMPRC, adapter->stats.last_mprc, adapter->stats.mprc);
+       UPDATE_VF_COUNTER(VFGOTLBC, adapter->stats.last_gotlbc, adapter->stats.gotlbc);
+       UPDATE_VF_COUNTER(VFGPTLBC, adapter->stats.last_gptlbc, adapter->stats.gptlbc);
+       UPDATE_VF_COUNTER(VFGORLBC, adapter->stats.last_gorlbc, adapter->stats.gorlbc);
+       UPDATE_VF_COUNTER(VFGPRLBC, adapter->stats.last_gprlbc, adapter->stats.gprlbc);
 
        /* Fill out the OS statistics structure */
        adapter->net_stats.multicast = adapter->stats.mprc;
@@ -1761,9 +1912,10 @@ void igbvf_update_stats(struct igbvf_adapter *adapter)
 
 static void igbvf_print_link_info(struct igbvf_adapter *adapter)
 {
-       dev_info(&adapter->pdev->dev, "Link is Up %d Mbps %s Duplex\n",
-                adapter->link_speed,
-                adapter->link_duplex == FULL_DUPLEX ? "Full" : "Half");
+       e_info("Link is Up %d Mbps %s\n",
+              adapter->link_speed,
+              ((adapter->link_duplex == FULL_DUPLEX) ?
+               "Full Duplex" : "Half Duplex"));
 }
 
 static bool igbvf_has_link(struct igbvf_adapter *adapter)
@@ -1796,13 +1948,14 @@ static void igbvf_watchdog(unsigned long data)
 
        /* Do the rest outside of interrupt context */
        schedule_work(&adapter->watchdog_task);
+
+       /* TODO: make this use queue_delayed_work() */
 }
 
 static void igbvf_watchdog_task(struct work_struct *work)
 {
        struct igbvf_adapter *adapter = container_of(work,
-                                                    struct igbvf_adapter,
-                                                    watchdog_task);
+                                       struct igbvf_adapter, watchdog_task);
        struct net_device *netdev = adapter->netdev;
        struct e1000_mac_info *mac = &adapter->hw.mac;
        struct igbvf_ring *tx_ring = adapter->tx_ring;
@@ -1814,11 +1967,25 @@ static void igbvf_watchdog_task(struct work_struct *work)
 
        if (link) {
                if (!netif_carrier_ok(netdev)) {
+
                        mac->ops.get_link_up_info(&adapter->hw,
-                                                 &adapter->link_speed,
-                                                 &adapter->link_duplex);
+                                                  &adapter->link_speed,
+                                                  &adapter->link_duplex);
                        igbvf_print_link_info(adapter);
 
+                       /*
+                        * tweak tx_queue_len according to speed/duplex
+                        */
+                       netdev->tx_queue_len = adapter->tx_queue_len;
+                       switch (adapter->link_speed) {
+                       case SPEED_10:
+                               netdev->tx_queue_len = 10;
+                               break;
+                       case SPEED_100:
+                               netdev->tx_queue_len = 100;
+                               break;
+                       }
+
                        netif_carrier_on(netdev);
                        netif_wake_queue(netdev);
                }
@@ -1826,7 +1993,7 @@ static void igbvf_watchdog_task(struct work_struct *work)
                if (netif_carrier_ok(netdev)) {
                        adapter->link_speed = 0;
                        adapter->link_duplex = 0;
-                       dev_info(&adapter->pdev->dev, "Link is Down\n");
+                       e_info("Link is Down\n");
                        netif_carrier_off(netdev);
                        netif_stop_queue(netdev);
                }
@@ -1836,7 +2003,7 @@ static void igbvf_watchdog_task(struct work_struct *work)
                igbvf_update_stats(adapter);
        } else {
                tx_pending = (igbvf_desc_unused(tx_ring) + 1 <
-                             tx_ring->count);
+                              tx_ring->count);
                if (tx_pending) {
                        /*
                         * We've lost link, so the controller stops DMA,
@@ -1858,17 +2025,18 @@ static void igbvf_watchdog_task(struct work_struct *work)
                          round_jiffies(jiffies + (2 * HZ)));
 }
 
-#define IGBVF_TX_FLAGS_CSUM             0x00000001
-#define IGBVF_TX_FLAGS_VLAN             0x00000002
-#define IGBVF_TX_FLAGS_TSO              0x00000004
-#define IGBVF_TX_FLAGS_IPV4             0x00000008
-#define IGBVF_TX_FLAGS_VLAN_MASK        0xffff0000
-#define IGBVF_TX_FLAGS_VLAN_SHIFT       16
+#define IGBVF_TX_FLAGS_CSUM            0x00000001
+#define IGBVF_TX_FLAGS_VLAN            0x00000002
+#define IGBVF_TX_FLAGS_TSO             0x00000004
+#define IGBVF_TX_FLAGS_IPV4            0x00000008
+#define IGBVF_TX_FLAGS_VLAN_MASK       0xffff0000
+#define IGBVF_TX_FLAGS_VLAN_SHIFT      16
 
 static int igbvf_tso(struct igbvf_adapter *adapter,
-                     struct igbvf_ring *tx_ring,
-                     struct sk_buff *skb, u32 tx_flags, u8 *hdr_len)
+                    struct igbvf_ring *tx_ring,
+                    struct sk_buff *skb, u32 tx_flags, u8 *hdr_len)
 {
+#ifdef NETIF_F_TSO
        struct e1000_adv_tx_context_desc *context_desc;
        unsigned int i;
        int err;
@@ -1880,8 +2048,7 @@ static int igbvf_tso(struct igbvf_adapter *adapter,
        if (skb_header_cloned(skb)) {
                err = pskb_expand_head(skb, 0, 0, GFP_ATOMIC);
                if (err) {
-                       dev_err(&adapter->pdev->dev,
-                               "igbvf_tso returning an error\n");
+                       printk("igbvf_tso returning an error\n");
                        return err;
                }
        }
@@ -1894,14 +2061,16 @@ static int igbvf_tso(struct igbvf_adapter *adapter,
                iph->tot_len = 0;
                iph->check = 0;
                tcp_hdr(skb)->check = ~csum_tcpudp_magic(iph->saddr,
-                                                        iph->daddr, 0,
-                                                        IPPROTO_TCP,
-                                                        0);
-       } else if (skb_is_gso_v6(skb)) {
+                                                        iph->daddr, 0,
+                                                        IPPROTO_TCP,
+                                                        0);
+#ifdef NETIF_F_TSO6
+       } else if (skb_shinfo(skb)->gso_type == SKB_GSO_TCPV6) {
                ipv6_hdr(skb)->payload_len = 0;
                tcp_hdr(skb)->check = ~csum_ipv6_magic(&ipv6_hdr(skb)->saddr,
-                                                      &ipv6_hdr(skb)->daddr,
-                                                      0, IPPROTO_TCP, 0);
+                                                      &ipv6_hdr(skb)->daddr,
+                                                      0, IPPROTO_TCP, 0);
+#endif
        }
 
        i = tx_ring->next_to_use;
@@ -1934,7 +2103,6 @@ static int igbvf_tso(struct igbvf_adapter *adapter,
        context_desc->seqnum_seed = 0;
 
        buffer_info->time_stamp = jiffies;
-       buffer_info->next_to_watch = i;
        buffer_info->dma = 0;
        i++;
        if (i == tx_ring->count)
@@ -1942,12 +2110,15 @@ static int igbvf_tso(struct igbvf_adapter *adapter,
 
        tx_ring->next_to_use = i;
 
-       return true;
+       return TRUE;
+#else
+       return FALSE;
+#endif  /* NETIF_F_TSO */
 }
 
 static inline bool igbvf_tx_csum(struct igbvf_adapter *adapter,
-                                 struct igbvf_ring *tx_ring,
-                                 struct sk_buff *skb, u32 tx_flags)
+                                struct igbvf_ring *tx_ring,
+                                struct sk_buff *skb, u32 tx_flags)
 {
        struct e1000_adv_tx_context_desc *context_desc;
        unsigned int i;
@@ -1980,10 +2151,13 @@ static inline bool igbvf_tx_csum(struct igbvf_adapter *adapter,
                                if (ip_hdr(skb)->protocol == IPPROTO_TCP)
                                        tu_cmd |= E1000_ADVTXD_TUCMD_L4T_TCP;
                                break;
+#ifdef NETIF_F_IPV6_CSUM
                        case __constant_htons(ETH_P_IPV6):
+                               /* XXX what about other V6 headers?? */
                                if (ipv6_hdr(skb)->nexthdr == IPPROTO_TCP)
                                        tu_cmd |= E1000_ADVTXD_TUCMD_L4T_TCP;
                                break;
+#endif
                        default:
                                break;
                        }
@@ -1994,17 +2168,16 @@ static inline bool igbvf_tx_csum(struct igbvf_adapter *adapter,
                context_desc->mss_l4len_idx = 0;
 
                buffer_info->time_stamp = jiffies;
-               buffer_info->next_to_watch = i;
                buffer_info->dma = 0;
                i++;
                if (i == tx_ring->count)
                        i = 0;
                tx_ring->next_to_use = i;
 
-               return true;
+               return TRUE;
        }
 
-       return false;
+       return FALSE;
 }
 
 static int igbvf_maybe_stop_tx(struct net_device *netdev, int size)
@@ -2029,16 +2202,15 @@ static int igbvf_maybe_stop_tx(struct net_device *netdev, int size)
        return 0;
 }
 
-#define IGBVF_MAX_TXD_PWR       16
-#define IGBVF_MAX_DATA_PER_TXD  (1 << IGBVF_MAX_TXD_PWR)
+#define IGBVF_MAX_TXD_PWR      16
+#define IGBVF_MAX_DATA_PER_TXD (1 << IGBVF_MAX_TXD_PWR)
 
 static inline int igbvf_tx_map_adv(struct igbvf_adapter *adapter,
-                                   struct igbvf_ring *tx_ring,
-                                   struct sk_buff *skb,
-                                   unsigned int first)
+                                  struct igbvf_ring *tx_ring,
+                                  struct sk_buff *skb,
+                                  unsigned int first)
 {
        struct igbvf_buffer *buffer_info;
-       struct pci_dev *pdev = adapter->pdev;
        unsigned int len = skb_headlen(skb);
        unsigned int count = 0, i;
        unsigned int f;
@@ -2050,13 +2222,10 @@ static inline int igbvf_tx_map_adv(struct igbvf_adapter *adapter,
        buffer_info->length = len;
        /* set time_stamp *before* dma to help avoid a possible race */
        buffer_info->time_stamp = jiffies;
-       buffer_info->next_to_watch = i;
-       buffer_info->mapped_as_page = false;
-       buffer_info->dma = dma_map_single(&pdev->dev, skb->data, len,
-                                         DMA_TO_DEVICE);
-       if (dma_mapping_error(&pdev->dev, buffer_info->dma))
-               goto dma_error;
 
+       buffer_info->dma =
+               dma_map_single(pci_dev_to_dev(adapter->pdev), skb->data,
+                              len, DMA_TO_DEVICE);
 
        for (f = 0; f < skb_shinfo(skb)->nr_frags; f++) {
                struct skb_frag_struct *frag;
@@ -2073,52 +2242,29 @@ static inline int igbvf_tx_map_adv(struct igbvf_adapter *adapter,
                BUG_ON(len >= IGBVF_MAX_DATA_PER_TXD);
                buffer_info->length = len;
                buffer_info->time_stamp = jiffies;
-               buffer_info->next_to_watch = i;
-               buffer_info->mapped_as_page = true;
-               buffer_info->dma = skb_frag_dma_map(&pdev->dev, frag, 0, len,
-                                               DMA_TO_DEVICE);
-               if (dma_mapping_error(&pdev->dev, buffer_info->dma))
-                       goto dma_error;
+               buffer_info->page_dma =
+                       dma_map_page(pci_dev_to_dev(adapter->pdev),
+                                    frag->page,
+                                    frag->page_offset,
+                                    len,
+                                    DMA_TO_DEVICE);
        }
 
        tx_ring->buffer_info[i].skb = skb;
        tx_ring->buffer_info[first].next_to_watch = i;
 
        return ++count;
-
-dma_error:
-       dev_err(&pdev->dev, "TX DMA map failed\n");
-
-       /* clear timestamp and dma mappings for failed buffer_info mapping */
-       buffer_info->dma = 0;
-       buffer_info->time_stamp = 0;
-       buffer_info->length = 0;
-       buffer_info->next_to_watch = 0;
-       buffer_info->mapped_as_page = false;
-       if (count)
-               count--;
-
-       /* clear timestamp and dma mappings for remaining portion of packet */
-       while (count--) {
-               if (i==0)
-                       i += tx_ring->count;
-               i--;
-               buffer_info = &tx_ring->buffer_info[i];
-               igbvf_put_txbuf(adapter, buffer_info);
-       }
-
-       return 0;
 }
 
 static inline void igbvf_tx_queue_adv(struct igbvf_adapter *adapter,
-                                      struct igbvf_ring *tx_ring,
-                                      int tx_flags, int count, u32 paylen,
-                                      u8 hdr_len)
+                                     struct igbvf_ring *tx_ring,
+                                     int tx_flags, int count, u32 paylen,
+                                     u8 hdr_len)
 {
        union e1000_adv_tx_desc *tx_desc = NULL;
        struct igbvf_buffer *buffer_info;
        u32 olinfo_status = 0, cmd_type_len;
-       unsigned int i;
+       unsigned int i = tx_ring->next_to_use;
 
        cmd_type_len = (E1000_ADVTXD_DTYP_DATA | E1000_ADVTXD_DCMD_IFCS |
                        E1000_ADVTXD_DCMD_DEXT);
@@ -2142,18 +2288,20 @@ static inline void igbvf_tx_queue_adv(struct igbvf_adapter *adapter,
 
        olinfo_status |= ((paylen - hdr_len) << E1000_ADVTXD_PAYLEN_SHIFT);
 
-       i = tx_ring->next_to_use;
-       while (count--) {
+       do {
                buffer_info = &tx_ring->buffer_info[i];
                tx_desc = IGBVF_TX_DESC_ADV(*tx_ring, i);
-               tx_desc->read.buffer_addr = cpu_to_le64(buffer_info->dma);
+               tx_desc->read.buffer_addr = buffer_info->dma ?
+                                           cpu_to_le64(buffer_info->dma) :
+                                           cpu_to_le64(buffer_info->page_dma);
                tx_desc->read.cmd_type_len =
-                        cpu_to_le32(cmd_type_len | buffer_info->length);
+                       cpu_to_le32(cmd_type_len | buffer_info->length);
                tx_desc->read.olinfo_status = cpu_to_le32(olinfo_status);
+               count--;
                i++;
                if (i == tx_ring->count)
                        i = 0;
-       }
+       } while (count > 0);
 
        tx_desc->read.cmd_type_len |= cpu_to_le32(adapter->txd_cmd);
        /* Force memory writes to complete before letting h/w
@@ -2169,16 +2317,16 @@ static inline void igbvf_tx_queue_adv(struct igbvf_adapter *adapter,
        mmiowb();
 }
 
-static netdev_tx_t igbvf_xmit_frame_ring_adv(struct sk_buff *skb,
-                                            struct net_device *netdev,
-                                            struct igbvf_ring *tx_ring)
+static int igbvf_xmit_frame_ring_adv(struct sk_buff *skb,
+                                   struct net_device *netdev,
+                                   struct igbvf_ring *tx_ring)
 {
        struct igbvf_adapter *adapter = netdev_priv(netdev);
        unsigned int first, tx_flags = 0;
        u8 hdr_len = 0;
-       int count = 0;
        int tso = 0;
 
+
        if (test_bit(__IGBVF_DOWN, &adapter->state)) {
                dev_kfree_skb_any(skb);
                return NETDEV_TX_OK;
@@ -2211,53 +2359,46 @@ static netdev_tx_t igbvf_xmit_frame_ring_adv(struct sk_buff *skb,
 
        first = tx_ring->next_to_use;
 
-       tso = skb_is_gso(skb) ?
-               igbvf_tso(adapter, tx_ring, skb, tx_flags, &hdr_len) : 0;
-       if (unlikely(tso < 0)) {
-               dev_kfree_skb_any(skb);
-               return NETDEV_TX_OK;
+       if (skb_is_gso(skb)) {
+               tso = igbvf_tso(adapter, tx_ring, skb, tx_flags, &hdr_len);
+               if (unlikely(tso < 0)) {
+                       dev_kfree_skb_any(skb);
+                       return NETDEV_TX_OK;
+               }
        }
 
        if (tso)
                tx_flags |= IGBVF_TX_FLAGS_TSO;
        else if (igbvf_tx_csum(adapter, tx_ring, skb, tx_flags) &&
-                (skb->ip_summed == CHECKSUM_PARTIAL))
+                (skb->ip_summed == CHECKSUM_PARTIAL))
                tx_flags |= IGBVF_TX_FLAGS_CSUM;
 
-       /*
-        * count reflects descriptors mapped, if 0 then mapping error
-        * has occurred and we need to rewind the descriptor queue
-        */
-       count = igbvf_tx_map_adv(adapter, tx_ring, skb, first);
+       igbvf_tx_queue_adv(adapter, tx_ring, tx_flags,
+                          igbvf_tx_map_adv(adapter, tx_ring, skb, first),
+                          skb->len, hdr_len);
 
-       if (count) {
-               igbvf_tx_queue_adv(adapter, tx_ring, tx_flags, count,
-                                  skb->len, hdr_len);
-               /* Make sure there is space in the ring for the next send. */
-               igbvf_maybe_stop_tx(netdev, MAX_SKB_FRAGS + 4);
-       } else {
-               dev_kfree_skb_any(skb);
-               tx_ring->buffer_info[first].time_stamp = 0;
-               tx_ring->next_to_use = first;
-       }
+       netdev->trans_start = jiffies;
+
+       /* Make sure there is space in the ring for the next send. */
+       igbvf_maybe_stop_tx(netdev, MAX_SKB_FRAGS + 4);
 
        return NETDEV_TX_OK;
 }
 
-static netdev_tx_t igbvf_xmit_frame(struct sk_buff *skb,
-                                   struct net_device *netdev)
+static int igbvf_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
 {
        struct igbvf_adapter *adapter = netdev_priv(netdev);
        struct igbvf_ring *tx_ring;
+       int retval;
 
-       if (test_bit(__IGBVF_DOWN, &adapter->state)) {
-               dev_kfree_skb_any(skb);
-               return NETDEV_TX_OK;
-       }
+       if (test_bit(__IGBVF_RESETTING, &adapter->state))
+               return NETDEV_TX_BUSY;
 
        tx_ring = &adapter->tx_ring[0];
 
-       return igbvf_xmit_frame_ring_adv(skb, netdev, tx_ring);
+       retval = igbvf_xmit_frame_ring_adv(skb, netdev, tx_ring);
+
+       return retval;
 }
 
 /**
@@ -2309,13 +2450,13 @@ static int igbvf_change_mtu(struct net_device *netdev, int new_mtu)
        int max_frame = new_mtu + ETH_HLEN + ETH_FCS_LEN;
 
        if ((new_mtu < 68) || (max_frame > MAX_JUMBO_FRAME_SIZE)) {
-               dev_err(&adapter->pdev->dev, "Invalid MTU setting\n");
+               e_err("Invalid MTU setting\n");
                return -EINVAL;
        }
 
 #define MAX_STD_JUMBO_FRAME_SIZE 9234
        if (max_frame > MAX_STD_JUMBO_FRAME_SIZE) {
-               dev_err(&adapter->pdev->dev, "MTU > 9216 not supported.\n");
+               e_err("MTU > 9216 not supported.\n");
                return -EINVAL;
        }
 
@@ -2350,11 +2491,10 @@ static int igbvf_change_mtu(struct net_device *netdev, int new_mtu)
        /* adjust allocation if LPE protects us, and we aren't using SBP */
        if ((max_frame == ETH_FRAME_LEN + ETH_FCS_LEN) ||
             (max_frame == ETH_FRAME_LEN + VLAN_HLEN + ETH_FCS_LEN))
-               adapter->rx_buffer_len = ETH_FRAME_LEN + VLAN_HLEN +
-                                        ETH_FCS_LEN;
+               adapter->rx_buffer_len = ETH_FRAME_LEN + VLAN_HLEN
+                                        ETH_FCS_LEN;
 
-       dev_info(&adapter->pdev->dev, "changing MTU from %d to %d\n",
-                netdev->mtu, new_mtu);
+       e_info("changing MTU from %d to %d\n", netdev->mtu, new_mtu);
        netdev->mtu = new_mtu;
 
        if (netif_running(netdev))
@@ -2370,6 +2510,10 @@ static int igbvf_change_mtu(struct net_device *netdev, int new_mtu)
 static int igbvf_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)
 {
        switch (cmd) {
+#ifdef ETHTOOL_OPS_COMPAT
+       case SIOCETHTOOL:
+               return ethtool_ioctl(ifr);
+#endif
        default:
                return -EOPNOTSUPP;
        }
@@ -2399,6 +2543,8 @@ static int igbvf_suspend(struct pci_dev *pdev, pm_message_t state)
 
        pci_disable_device(pdev);
 
+       pci_set_power_state(pdev, pci_choose_state(pdev, state));
+
        return 0;
 }
 
@@ -2409,10 +2555,12 @@ static int igbvf_resume(struct pci_dev *pdev)
        struct igbvf_adapter *adapter = netdev_priv(netdev);
        u32 err;
 
+       pci_set_power_state(pdev, PCI_D0);
        pci_restore_state(pdev);
-       err = pci_enable_device_mem(pdev);
+       err = pci_enable_device(pdev);
        if (err) {
-               dev_err(&pdev->dev, "Cannot enable PCI device from suspend\n");
+               dev_err(pci_dev_to_dev(pdev),
+                       "Cannot enable PCI device from suspend\n");
                return err;
        }
 
@@ -2435,10 +2583,37 @@ static int igbvf_resume(struct pci_dev *pdev)
 }
 #endif
 
+#ifndef USE_REBOOT_NOTIFIER
 static void igbvf_shutdown(struct pci_dev *pdev)
 {
        igbvf_suspend(pdev, PMSG_SUSPEND);
 }
+#else
+static struct pci_driver igbvf_driver;
+static int igbvf_notify_reboot(struct notifier_block *nb, unsigned long event,
+                              void *ptr)
+{
+       struct pci_dev *pdev = NULL;
+
+       switch (event) {
+       case SYS_DOWN:
+       case SYS_HALT:
+       case SYS_POWER_OFF:
+               while ((pdev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, pdev))) {
+                       if (pci_dev_driver(pdev) == &igbvf_driver)
+                               igbvf_suspend(pdev, PMSG_SUSPEND);
+               }
+               break;
+       }
+       return NOTIFY_DONE;
+}
+
+static struct notifier_block igbvf_notifier_reboot = {
+       .notifier_call  = igbvf_notify_reboot,
+       .next           = NULL,
+       .priority       = 0
+};
+#endif
 
 #ifdef CONFIG_NET_POLL_CONTROLLER
 /*
@@ -2458,6 +2633,7 @@ static void igbvf_netpoll(struct net_device *netdev)
 }
 #endif
 
+#ifdef HAVE_PCI_ERS
 /**
  * igbvf_io_error_detected - called when PCI error is detected
  * @pdev: Pointer to PCI device
@@ -2467,16 +2643,13 @@ static void igbvf_netpoll(struct net_device *netdev)
  * this device has been detected.
  */
 static pci_ers_result_t igbvf_io_error_detected(struct pci_dev *pdev,
-                                                pci_channel_state_t state)
+                                               pci_channel_state_t state)
 {
        struct net_device *netdev = pci_get_drvdata(pdev);
        struct igbvf_adapter *adapter = netdev_priv(netdev);
 
        netif_device_detach(netdev);
 
-       if (state == pci_channel_io_perm_failure)
-               return PCI_ERS_RESULT_DISCONNECT;
-
        if (netif_running(netdev))
                igbvf_down(adapter);
        pci_disable_device(pdev);
@@ -2497,8 +2670,8 @@ static pci_ers_result_t igbvf_io_slot_reset(struct pci_dev *pdev)
        struct net_device *netdev = pci_get_drvdata(pdev);
        struct igbvf_adapter *adapter = netdev_priv(netdev);
 
-       if (pci_enable_device_mem(pdev)) {
-               dev_err(&pdev->dev,
+       if (pci_enable_device(pdev)) {
+               dev_err(pci_dev_to_dev(pdev),
                        "Cannot re-enable PCI device after reset.\n");
                return PCI_ERS_RESULT_DISCONNECT;
        }
@@ -2524,7 +2697,7 @@ static void igbvf_io_resume(struct pci_dev *pdev)
 
        if (netif_running(netdev)) {
                if (igbvf_up(adapter)) {
-                       dev_err(&pdev->dev,
+                       dev_err(pci_dev_to_dev(pdev),
                                "can't bring device back up after reset\n");
                        return;
                }
@@ -2532,50 +2705,46 @@ static void igbvf_io_resume(struct pci_dev *pdev)
 
        netif_device_attach(netdev);
 }
+#endif /* HAVE_PCI_ERS */
 
 static void igbvf_print_device_info(struct igbvf_adapter *adapter)
 {
        struct e1000_hw *hw = &adapter->hw;
        struct net_device *netdev = adapter->netdev;
-       struct pci_dev *pdev = adapter->pdev;
 
        if (hw->mac.type == e1000_vfadapt_i350)
-               dev_info(&pdev->dev, "Intel(R) I350 Virtual Function\n");
-       else
-               dev_info(&pdev->dev, "Intel(R) 82576 Virtual Function\n");
-       dev_info(&pdev->dev, "Address: %pM\n", netdev->dev_addr);
-}
-
-static int igbvf_set_features(struct net_device *netdev, u32 features)
-{
-       struct igbvf_adapter *adapter = netdev_priv(netdev);
-
-       if (features & NETIF_F_RXCSUM)
-               adapter->flags &= ~IGBVF_FLAG_RX_CSUM_DISABLED;
+               e_info("Intel(R) I350 Virtual Function\n");
        else
-               adapter->flags |= IGBVF_FLAG_RX_CSUM_DISABLED;
-
-       return 0;
+               e_info("Intel(R) 82576 Virtual Function\n");
+       e_info("Address: %02x:%02x:%02x:%02x:%02x:%02x\n",
+              /* MAC address */
+              netdev->dev_addr[0], netdev->dev_addr[1],
+              netdev->dev_addr[2], netdev->dev_addr[3],
+              netdev->dev_addr[4], netdev->dev_addr[5]);
 }
 
+#ifdef HAVE_NET_DEVICE_OPS
 static const struct net_device_ops igbvf_netdev_ops = {
-       .ndo_open                       = igbvf_open,
-       .ndo_stop                       = igbvf_close,
-       .ndo_start_xmit                 = igbvf_xmit_frame,
-       .ndo_get_stats                  = igbvf_get_stats,
-       .ndo_set_multicast_list         = igbvf_set_multi,
-       .ndo_set_mac_address            = igbvf_set_mac,
-       .ndo_change_mtu                 = igbvf_change_mtu,
-       .ndo_do_ioctl                   = igbvf_ioctl,
-       .ndo_tx_timeout                 = igbvf_tx_timeout,
-       .ndo_vlan_rx_add_vid            = igbvf_vlan_rx_add_vid,
-       .ndo_vlan_rx_kill_vid           = igbvf_vlan_rx_kill_vid,
+       .ndo_open                       = igbvf_open,
+       .ndo_stop                       = igbvf_close,
+       .ndo_start_xmit                 = igbvf_xmit_frame,
+       .ndo_get_stats                  = igbvf_get_stats,
+       .ndo_set_multicast_list         = igbvf_set_multi,
+       .ndo_set_mac_address            = igbvf_set_mac,
+       .ndo_change_mtu                 = igbvf_change_mtu,
+       .ndo_do_ioctl                   = igbvf_ioctl,
+       .ndo_tx_timeout                 = igbvf_tx_timeout,
+#ifdef HAVE_VLAN_RX_REGISTER
+       .ndo_vlan_rx_register           = igbvf_vlan_rx_register,
+#endif
+       .ndo_vlan_rx_add_vid            = igbvf_vlan_rx_add_vid,
+       .ndo_vlan_rx_kill_vid           = igbvf_vlan_rx_kill_vid,
 #ifdef CONFIG_NET_POLL_CONTROLLER
-       .ndo_poll_controller            = igbvf_netpoll,
+       .ndo_poll_controller            = igbvf_netpoll,
 #endif
-       .ndo_set_features               = igbvf_set_features,
 };
 
+#endif /* HAVE_NET_DEVICE_OPS */
 /**
  * igbvf_probe - Device Initialization Routine
  * @pdev: PCI device information struct
@@ -2588,7 +2757,7 @@ static const struct net_device_ops igbvf_netdev_ops = {
  * and a hardware reset occur.
  **/
 static int __devinit igbvf_probe(struct pci_dev *pdev,
-                                 const struct pci_device_id *ent)
+                                const struct pci_device_id *ent)
 {
        struct net_device *netdev;
        struct igbvf_adapter *adapter;
@@ -2598,23 +2767,24 @@ static int __devinit igbvf_probe(struct pci_dev *pdev,
        static int cards_found;
        int err, pci_using_dac;
 
-       err = pci_enable_device_mem(pdev);
+       err = pci_enable_device(pdev);
        if (err)
                return err;
 
        pci_using_dac = 0;
-       err = dma_set_mask(&pdev->dev, DMA_BIT_MASK(64));
+       err = dma_set_mask(pci_dev_to_dev(pdev), DMA_BIT_MASK(64));
        if (!err) {
-               err = dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(64));
+               err = dma_set_coherent_mask(pci_dev_to_dev(pdev),
+                                           DMA_BIT_MASK(64));
                if (!err)
                        pci_using_dac = 1;
        } else {
-               err = dma_set_mask(&pdev->dev, DMA_BIT_MASK(32));
+               err = dma_set_mask(pci_dev_to_dev(pdev), DMA_BIT_MASK(32));
                if (err) {
-                       err = dma_set_coherent_mask(&pdev->dev,
-                                                   DMA_BIT_MASK(32));
+                       err = dma_set_coherent_mask(pci_dev_to_dev(pdev),
+                                                         DMA_BIT_MASK(32));
                        if (err) {
-                               dev_err(&pdev->dev, "No usable DMA "
+                               dev_err(pci_dev_to_dev(pdev), "No usable DMA "
                                        "configuration, aborting\n");
                                goto err_dma;
                        }
@@ -2632,6 +2802,7 @@ static int __devinit igbvf_probe(struct pci_dev *pdev,
        if (!netdev)
                goto err_alloc_etherdev;
 
+       SET_MODULE_OWNER(netdev);
        SET_NETDEV_DEV(netdev, &pdev->dev);
 
        pci_set_drvdata(pdev, netdev);
@@ -2652,11 +2823,12 @@ static int __devinit igbvf_probe(struct pci_dev *pdev,
        hw->device_id = pdev->device;
        hw->subsystem_vendor_id = pdev->subsystem_vendor;
        hw->subsystem_device_id = pdev->subsystem_device;
-       hw->revision_id = pdev->revision;
+
+       pci_read_config_byte(pdev, PCI_REVISION_ID, &hw->revision_id);
 
        err = -EIO;
        adapter->hw.hw_addr = ioremap(pci_resource_start(pdev, 0),
-                                     pci_resource_len(pdev, 0));
+                                     pci_resource_len(pdev, 0));
 
        if (!adapter->hw.hw_addr)
                goto err_ioremap;
@@ -2664,7 +2836,7 @@ static int __devinit igbvf_probe(struct pci_dev *pdev,
        if (ei->get_variants) {
                err = ei->get_variants(adapter);
                if (err)
-                       goto err_ioremap;
+                       goto err_hw_init;
        }
 
        /* setup adapter struct */
@@ -2673,69 +2845,98 @@ static int __devinit igbvf_probe(struct pci_dev *pdev,
                goto err_sw_init;
 
        /* construct the net_device struct */
+#ifdef HAVE_NET_DEVICE_OPS
        netdev->netdev_ops = &igbvf_netdev_ops;
-
+#else
+       netdev->open                    = &igbvf_open;
+       netdev->stop                    = &igbvf_close;
+       netdev->hard_start_xmit         = &igbvf_xmit_frame;
+       netdev->get_stats               = &igbvf_get_stats;
+       netdev->set_multicast_list      = &igbvf_set_multi;
+       netdev->set_mac_address         = &igbvf_set_mac;
+       netdev->change_mtu              = &igbvf_change_mtu;
+       netdev->do_ioctl                = &igbvf_ioctl;
+       netdev->tx_timeout              = &igbvf_tx_timeout;
+#ifdef HAVE_VLAN_RX_REGISTER
+       netdev->vlan_rx_register        = igbvf_vlan_rx_register;
+#endif
+       netdev->vlan_rx_add_vid         = igbvf_vlan_rx_add_vid;
+       netdev->vlan_rx_kill_vid        = igbvf_vlan_rx_kill_vid;
+#ifdef CONFIG_NET_POLL_CONTROLLER
+       netdev->poll_controller         = igbvf_netpoll;
+#endif
+#endif /* HAVE_NET_DEVICE_OPS */
        igbvf_set_ethtool_ops(netdev);
-       netdev->watchdog_timeo = 5 * HZ;
+       netdev->watchdog_timeo          = 5 * HZ;
        strncpy(netdev->name, pci_name(pdev), sizeof(netdev->name) - 1);
 
        adapter->bd_number = cards_found++;
 
-       netdev->hw_features = NETIF_F_SG |
-                          NETIF_F_IP_CSUM |
-                          NETIF_F_IPV6_CSUM |
-                          NETIF_F_TSO |
-                          NETIF_F_TSO6 |
-                          NETIF_F_RXCSUM;
+       netdev->features = NETIF_F_SG |
+                          NETIF_F_IP_CSUM |
+                          NETIF_F_HW_VLAN_TX |
+                          NETIF_F_HW_VLAN_RX |
+                          NETIF_F_HW_VLAN_FILTER;
 
-       netdev->features = netdev->hw_features |
-                          NETIF_F_HW_VLAN_TX |
-                          NETIF_F_HW_VLAN_RX |
-                          NETIF_F_HW_VLAN_FILTER;
+#ifdef NETIF_F_IPV6_CSUM
+       netdev->features |= NETIF_F_IPV6_CSUM;
+#endif
+#ifdef NETIF_F_TSO
+       netdev->features |= NETIF_F_TSO;
+#ifdef NETIF_F_TSO6
+       netdev->features |= NETIF_F_TSO6;
+#endif
+#endif
 
        if (pci_using_dac)
                netdev->features |= NETIF_F_HIGHDMA;
 
+#ifdef HAVE_NETDEV_VLAN_FEATURES
        netdev->vlan_features |= NETIF_F_TSO;
        netdev->vlan_features |= NETIF_F_TSO6;
        netdev->vlan_features |= NETIF_F_IP_CSUM;
        netdev->vlan_features |= NETIF_F_IPV6_CSUM;
        netdev->vlan_features |= NETIF_F_SG;
 
+#endif
        /*reset the controller to put the device in a known good state */
        err = hw->mac.ops.reset_hw(hw);
        if (err) {
-               dev_info(&pdev->dev,
-                        "PF still in reset state, assigning new address."
-                        " Is the PF interface up?\n");
-               eth_hw_addr_random(netdev);
-               memcpy(adapter->hw.mac.addr, netdev->dev_addr,
-                       netdev->addr_len);
+               e_early_info("PF still in reset state\n");
+               random_ether_addr(hw->mac.addr);
        } else {
                err = hw->mac.ops.read_mac_addr(hw);
                if (err) {
-                       dev_err(&pdev->dev, "Error reading MAC address\n");
+                       e_early_err("Error reading MAC address\n");
                        goto err_hw_init;
                }
-               memcpy(netdev->dev_addr, adapter->hw.mac.addr,
-                       netdev->addr_len);
        }
 
+       memcpy(netdev->dev_addr, adapter->hw.mac.addr, netdev->addr_len);
+#ifdef ETHTOOL_GPERMADDR
+       memcpy(netdev->perm_addr, adapter->hw.mac.addr, netdev->addr_len);
+
+       if (!is_valid_ether_addr(netdev->perm_addr)) {
+#else
        if (!is_valid_ether_addr(netdev->dev_addr)) {
-               dev_err(&pdev->dev, "Invalid MAC Address: %pM\n",
-                       netdev->dev_addr);
+#endif
+               e_err("Invalid MAC Address: %02x:%02x:%02x:%02x:%02x:%02x\n",
+                     netdev->dev_addr[0], netdev->dev_addr[1],
+                     netdev->dev_addr[2], netdev->dev_addr[3],
+                     netdev->dev_addr[4], netdev->dev_addr[5]);
                err = -EIO;
                goto err_hw_init;
        }
 
-       memcpy(netdev->perm_addr, netdev->dev_addr, netdev->addr_len);
-
-       setup_timer(&adapter->watchdog_timer, &igbvf_watchdog,
-                   (unsigned long) adapter);
+       init_timer(&adapter->watchdog_timer);
+       adapter->watchdog_timer.function = &igbvf_watchdog;
+       adapter->watchdog_timer.data = (unsigned long) adapter;
 
        INIT_WORK(&adapter->reset_task, igbvf_reset_task);
        INIT_WORK(&adapter->watchdog_task, igbvf_watchdog_task);
 
+       igbvf_check_options(adapter);
+
        /* ring size defaults */
        adapter->rx_ring->count = 1024;
        adapter->tx_ring->count = 1024;
@@ -2743,15 +2944,19 @@ static int __devinit igbvf_probe(struct pci_dev *pdev,
        /* reset the hardware with the new settings */
        igbvf_reset(adapter);
 
-       strcpy(netdev->name, "eth%d");
-       err = register_netdev(netdev);
-       if (err)
-               goto err_hw_init;
+       /* set hardware-specific flags */
+       if (adapter->hw.mac.type == e1000_vfadapt_i350)
+               adapter->flags |= IGBVF_FLAG_RX_LB_VLAN_BSWAP;
 
        /* tell the stack to leave us alone until igbvf_open() is called */
        netif_carrier_off(netdev);
        netif_stop_queue(netdev);
 
+       strcpy(netdev->name, "eth%d");
+       err = register_netdev(netdev);
+       if (err)
+               goto err_hw_init;
+
        igbvf_print_device_info(adapter);
 
        igbvf_initialize_last_counter_stats(adapter);
@@ -2761,8 +2966,8 @@ static int __devinit igbvf_probe(struct pci_dev *pdev,
 err_hw_init:
        kfree(adapter->tx_ring);
        kfree(adapter->rx_ring);
-err_sw_init:
        igbvf_reset_interrupt_capability(adapter);
+err_sw_init:
        iounmap(adapter->hw.hw_addr);
 err_ioremap:
        free_netdev(netdev);
@@ -2790,24 +2995,17 @@ static void __devexit igbvf_remove(struct pci_dev *pdev)
        struct e1000_hw *hw = &adapter->hw;
 
        /*
-        * The watchdog timer may be rescheduled, so explicitly
-        * disable it from being rescheduled.
+        * flush_scheduled work may reschedule our watchdog task, so
+        * explicitly disable watchdog tasks from being rescheduled
         */
        set_bit(__IGBVF_DOWN, &adapter->state);
        del_timer_sync(&adapter->watchdog_timer);
 
-       cancel_work_sync(&adapter->reset_task);
-       cancel_work_sync(&adapter->watchdog_task);
+       flush_scheduled_work();
 
        unregister_netdev(netdev);
 
        igbvf_reset_interrupt_capability(adapter);
-
-       /*
-        * it is important to delete the napi struct prior to freeing the
-        * rx ring so that you do not end up with null pointer refs
-        */
-       netif_napi_del(&adapter->rx_ring->napi);
        kfree(adapter->tx_ring);
        kfree(adapter->rx_ring);
 
@@ -2821,17 +3019,19 @@ static void __devexit igbvf_remove(struct pci_dev *pdev)
        pci_disable_device(pdev);
 }
 
+#ifdef HAVE_PCI_ERS
 /* PCI Error Recovery (ERS) */
 static struct pci_error_handlers igbvf_err_handler = {
        .error_detected = igbvf_io_error_detected,
        .slot_reset = igbvf_io_slot_reset,
        .resume = igbvf_io_resume,
 };
+#endif
 
-static DEFINE_PCI_DEVICE_TABLE(igbvf_pci_tbl) = {
+static struct pci_device_id igbvf_pci_tbl[] = {
        { PCI_VDEVICE(INTEL, E1000_DEV_ID_82576_VF), board_vf },
        { PCI_VDEVICE(INTEL, E1000_DEV_ID_I350_VF), board_i350_vf },
-       { } /* terminate list */
+       { }     /* terminate list */
 };
 MODULE_DEVICE_TABLE(pci, igbvf_pci_tbl);
 
@@ -2846,23 +3046,31 @@ static struct pci_driver igbvf_driver = {
        .suspend  = igbvf_suspend,
        .resume   = igbvf_resume,
 #endif
+#ifndef USE_REBOOT_NOTIFIER
        .shutdown = igbvf_shutdown,
+#endif
+#ifdef HAVE_PCI_ERS
        .err_handler = &igbvf_err_handler
+#endif
 };
 
 /**
  * igbvf_init_module - Driver Registration Routine
  *
- * igbvf_init_module is the first routine called when the driver is
- * loaded. All it does is register with the PCI subsystem.
+ * igbvf_init_module is the first routine called when the driver is * loaded. All it does is register with the PCI subsystem.
  **/
 static int __init igbvf_init_module(void)
 {
        int ret;
-       pr_info("%s - version %s\n", igbvf_driver_string, igbvf_driver_version);
-       pr_info("%s\n", igbvf_copyright);
-
+       printk(KERN_INFO "%s: Intel(R) Gigabit Virtual Function Driver - %s\n",
+              igbvf_driver_name, igbvf_driver_version);
+       printk(KERN_INFO "%s: Copyright (c) 1999-2012 Intel Corporation.\n",
+              igbvf_driver_name);
        ret = pci_register_driver(&igbvf_driver);
+#ifdef USE_REBOOT_NOTIFIER
+       if (ret >= 0)
+               register_reboot_notifier(&igbvf_notifier_reboot);
+#endif
 
        return ret;
 }
@@ -2876,13 +3084,16 @@ module_init(igbvf_init_module);
  **/
 static void __exit igbvf_exit_module(void)
 {
+#ifdef USE_REBOOT_NOTIFIER
+       unregister_reboot_notifier(&igbvf_notifier_reboot);
+#endif
        pci_unregister_driver(&igbvf_driver);
 }
 module_exit(igbvf_exit_module);
 
 
-MODULE_AUTHOR("Intel Corporation, <e1000-devel@lists.sourceforge.net>");
-MODULE_DESCRIPTION("Intel(R) Gigabit Virtual Function Network Driver");
+MODULE_AUTHOR("Intel Corporation, <linux.nics@intel.com>");
+MODULE_DESCRIPTION("Intel(R) Gigabit Virtual Function Driver");
 MODULE_LICENSE("GPL");
 MODULE_VERSION(DRV_VERSION);
 
diff --git a/drivers/net/igbvf/param.c b/drivers/net/igbvf/param.c
new file mode 100644 (file)
index 0000000..f576722
--- /dev/null
@@ -0,0 +1,211 @@
+/*******************************************************************************
+
+  Intel(R) 82576 Virtual Function Linux driver
+  Copyright(c) 1999 - 2012 Intel Corporation.
+
+  This program is free software; you can redistribute it and/or modify it
+  under the terms and conditions of the GNU General Public License,
+  version 2, as published by the Free Software Foundation.
+
+  This program is distributed in the hope it will be useful, but WITHOUT
+  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+  more details.
+
+  You should have received a copy of the GNU General Public License along with
+  this program; if not, write to the Free Software Foundation, Inc.,
+  51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
+
+  The full GNU General Public License is included in this distribution in
+  the file called "COPYING".
+
+  Contact Information:
+  Linux NICS <linux.nics@intel.com>
+  e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
+  Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
+
+*******************************************************************************/
+
+#include <linux/netdevice.h>
+
+#include "igbvf.h"
+
+/*
+ * This is the only thing that needs to be changed to adjust the
+ * maximum number of ports that the driver can manage.
+ */
+
+#define IGBVF_MAX_NIC 7
+
+#define OPTION_UNSET   -1
+#define OPTION_DISABLED 0
+#define OPTION_ENABLED  1
+
+/*
+ * All parameters are treated the same, as an integer array of values.
+ * This macro just reduces the need to repeat the same declaration code
+ * over and over (plus this helps to avoid typo bugs).
+ */
+
+#define IGBVF_PARAM_INIT { [0 ... IGBVF_MAX_NIC] = OPTION_UNSET }
+#ifndef module_param_array
+/* Module Parameters are always initialized to -1, so that the driver
+ * can tell the difference between no user specified value or the
+ * user asking for the default value.
+ * The true default values are loaded in when igbvf_check_options is called.
+ *
+ * This is a GCC extension to ANSI C.
+ * See the item "Labeled Elements in Initializers" in the section
+ * "Extensions to the C Language Family" of the GCC documentation.
+ */
+#define IGBVF_PARAM(X, desc) \
+       static const int __devinitdata X[IGBVF_MAX_NIC+1] = IGBVF_PARAM_INIT; \
+       static unsigned int num_##X;                             \
+       MODULE_PARM(X, "1-" __MODULE_STRING(IGBVF_MAX_NIC) "i"); \
+       MODULE_PARM_DESC(X, desc);
+#else
+#define IGBVF_PARAM(X, desc)                                   \
+       static int __devinitdata X[IGBVF_MAX_NIC+1]             \
+               = IGBVF_PARAM_INIT;                             \
+       static unsigned int num_##X;                            \
+       module_param_array_named(X, X, int, &num_##X, 0);       \
+       MODULE_PARM_DESC(X, desc);
+#endif
+
+/*
+ * Interrupt Throttle Rate (interrupts/sec)
+ *
+ * Valid Range: 100-100000 (0=off, 1=dynamic, 3=dynamic conservative)
+ */
+IGBVF_PARAM(InterruptThrottleRate, "Interrupt Throttling Rate");
+#define DEFAULT_ITR 3
+#define MAX_ITR 100000
+#define MIN_ITR 100
+
+struct igbvf_option {
+       enum { enable_option, range_option, list_option } type;
+       const char *name;
+       const char *err;
+       int def;
+       union {
+               struct { /* range_option info */
+                       int min;
+                       int max;
+               } r;
+               struct { /* list_option info */
+                       int nr;
+                       struct igbvf_opt_list { int i; char *str; } *p;
+               } l;
+       } arg;
+};
+
+static int __devinit igbvf_validate_option(unsigned int *value,
+                                          const struct igbvf_option *opt,
+                                          struct igbvf_adapter *adapter)
+{
+       if (((int)(*value)) == OPTION_UNSET) {
+               *value = opt->def;
+               return 0;
+       }
+
+       switch (opt->type) {
+       case enable_option:
+               switch (*value) {
+               case OPTION_ENABLED:
+                       e_early_info("%s Enabled\n", opt->name);
+                       return 0;
+               case OPTION_DISABLED:
+                       e_early_info("%s Disabled\n", opt->name);
+                       return 0;
+               }
+               break;
+       case range_option:
+               if (*value >= opt->arg.r.min && *value <= opt->arg.r.max) {
+                       e_early_info("%s set to %i\n", opt->name, *value);
+                       return 0;
+               }
+               break;
+       case list_option: {
+               int i;
+               struct igbvf_opt_list *ent;
+
+               for (i = 0; i < opt->arg.l.nr; i++) {
+                       ent = &opt->arg.l.p[i];
+                       if (*value == ent->i) {
+                               if (ent->str[0] != '\0')
+                                       e_early_info("%s\n", ent->str);
+                               return 0;
+                       }
+               }
+       }
+               break;
+       default:
+               BUG();
+       }
+
+       e_early_info("Invalid %s value specified (%i) %s\n", opt->name, *value,
+              opt->err);
+       *value = opt->def;
+       return -1;
+}
+
+/**
+ * igbvf_check_options - Range Checking for Command Line Parameters
+ * @adapter: board private structure
+ *
+ * This routine checks all command line parameters for valid user
+ * input.  If an invalid value is given, or if no user specified
+ * value exists, a default value is used.  The final value is stored
+ * in a variable in the adapter structure.
+ **/
+void __devinit igbvf_check_options(struct igbvf_adapter *adapter)
+{
+       int bd = adapter->bd_number;
+
+       if (bd >= IGBVF_MAX_NIC) {
+               e_early_notice("Warning: no configuration for board #%i\n", bd);
+               e_early_notice("Using defaults for all values\n");
+       }
+
+       { /* Interrupt Throttling Rate */
+               const struct igbvf_option opt = {
+                       .type = range_option,
+                       .name = "Interrupt Throttling Rate (ints/sec)",
+                       .err  = "using default of "
+                               __MODULE_STRING(DEFAULT_ITR),
+                       .def  = DEFAULT_ITR,
+                       .arg  = { .r = { .min = MIN_ITR,
+                                        .max = MAX_ITR } }
+               };
+
+               if (num_InterruptThrottleRate > bd) {
+                       adapter->requested_itr = InterruptThrottleRate[bd];
+                       switch (adapter->requested_itr) {
+                       case 0:
+                               e_early_info("%s turned off\n", opt.name);
+                               break;
+                       case 1:
+                               e_early_info("%s set to dynamic mode\n",
+                                            opt.name);
+                               adapter->current_itr = IGBVF_START_ITR;
+                               break;
+                       case 3:
+                               e_early_info("%s set to dynamic conservative mode\n",
+                                       opt.name);
+                               adapter->current_itr = IGBVF_START_ITR;
+                               break;
+                       default:
+                               igbvf_validate_option(&adapter->requested_itr,
+                                                     &opt, adapter);
+                               adapter->current_itr = 1000000000 /
+                                               (adapter->requested_itr * 256);
+                               /* lower two bits used as control */
+                               adapter->requested_itr &= ~3;
+                               break;
+                       }
+               } else {
+                       adapter->requested_itr = opt.def;
+                       adapter->current_itr = IGBVF_START_ITR;
+               }
+       }
+}
diff --git a/drivers/net/igbvf/regs.h b/drivers/net/igbvf/regs.h
deleted file mode 100644 (file)
index 7dc6341..0000000
+++ /dev/null
@@ -1,108 +0,0 @@
-/*******************************************************************************
-
-  Intel(R) 82576 Virtual Function Linux driver
-  Copyright(c) 2009 - 2012 Intel Corporation.
-
-  This program is free software; you can redistribute it and/or modify it
-  under the terms and conditions of the GNU General Public License,
-  version 2, as published by the Free Software Foundation.
-
-  This program is distributed in the hope it will be useful, but WITHOUT
-  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
-  more details.
-
-  You should have received a copy of the GNU General Public License along with
-  this program; if not, write to the Free Software Foundation, Inc.,
-  51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
-
-  The full GNU General Public License is included in this distribution in
-  the file called "COPYING".
-
-  Contact Information:
-  e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
-  Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
-
-*******************************************************************************/
-
-#ifndef _E1000_REGS_H_
-#define _E1000_REGS_H_
-
-#define E1000_CTRL      0x00000 /* Device Control - RW */
-#define E1000_STATUS    0x00008 /* Device Status - RO */
-#define E1000_ITR       0x000C4 /* Interrupt Throttling Rate - RW */
-#define E1000_EICR      0x01580 /* Ext. Interrupt Cause Read - R/clr */
-#define E1000_EITR(_n)  (0x01680 + (0x4 * (_n)))
-#define E1000_EICS      0x01520 /* Ext. Interrupt Cause Set - W0 */
-#define E1000_EIMS      0x01524 /* Ext. Interrupt Mask Set/Read - RW */
-#define E1000_EIMC      0x01528 /* Ext. Interrupt Mask Clear - WO */
-#define E1000_EIAC      0x0152C /* Ext. Interrupt Auto Clear - RW */
-#define E1000_EIAM      0x01530 /* Ext. Interrupt Ack Auto Clear Mask - RW */
-#define E1000_IVAR0     0x01700 /* Interrupt Vector Allocation (array) - RW */
-#define E1000_IVAR_MISC 0x01740 /* IVAR for "other" causes - RW */
-/*
- * Convenience macros
- *
- * Note: "_n" is the queue number of the register to be written to.
- *
- * Example usage:
- * E1000_RDBAL_REG(current_rx_queue)
- */
-#define E1000_RDBAL(_n)      ((_n) < 4 ? (0x02800 + ((_n) * 0x100)) : \
-                                         (0x0C000 + ((_n) * 0x40)))
-#define E1000_RDBAH(_n)      ((_n) < 4 ? (0x02804 + ((_n) * 0x100)) : \
-                                         (0x0C004 + ((_n) * 0x40)))
-#define E1000_RDLEN(_n)      ((_n) < 4 ? (0x02808 + ((_n) * 0x100)) : \
-                                         (0x0C008 + ((_n) * 0x40)))
-#define E1000_SRRCTL(_n)     ((_n) < 4 ? (0x0280C + ((_n) * 0x100)) : \
-                                         (0x0C00C + ((_n) * 0x40)))
-#define E1000_RDH(_n)        ((_n) < 4 ? (0x02810 + ((_n) * 0x100)) : \
-                                         (0x0C010 + ((_n) * 0x40)))
-#define E1000_RDT(_n)        ((_n) < 4 ? (0x02818 + ((_n) * 0x100)) : \
-                                         (0x0C018 + ((_n) * 0x40)))
-#define E1000_RXDCTL(_n)     ((_n) < 4 ? (0x02828 + ((_n) * 0x100)) : \
-                                         (0x0C028 + ((_n) * 0x40)))
-#define E1000_TDBAL(_n)      ((_n) < 4 ? (0x03800 + ((_n) * 0x100)) : \
-                                         (0x0E000 + ((_n) * 0x40)))
-#define E1000_TDBAH(_n)      ((_n) < 4 ? (0x03804 + ((_n) * 0x100)) : \
-                                         (0x0E004 + ((_n) * 0x40)))
-#define E1000_TDLEN(_n)      ((_n) < 4 ? (0x03808 + ((_n) * 0x100)) : \
-                                         (0x0E008 + ((_n) * 0x40)))
-#define E1000_TDH(_n)        ((_n) < 4 ? (0x03810 + ((_n) * 0x100)) : \
-                                         (0x0E010 + ((_n) * 0x40)))
-#define E1000_TDT(_n)        ((_n) < 4 ? (0x03818 + ((_n) * 0x100)) : \
-                                         (0x0E018 + ((_n) * 0x40)))
-#define E1000_TXDCTL(_n)     ((_n) < 4 ? (0x03828 + ((_n) * 0x100)) : \
-                                         (0x0E028 + ((_n) * 0x40)))
-#define E1000_DCA_TXCTRL(_n) (0x03814 + (_n << 8))
-#define E1000_DCA_RXCTRL(_n) (0x02814 + (_n << 8))
-#define E1000_RAL(_i)  (((_i) <= 15) ? (0x05400 + ((_i) * 8)) : \
-                                       (0x054E0 + ((_i - 16) * 8)))
-#define E1000_RAH(_i)  (((_i) <= 15) ? (0x05404 + ((_i) * 8)) : \
-                                       (0x054E4 + ((_i - 16) * 8)))
-
-/* Statistics registers */
-#define E1000_VFGPRC    0x00F10
-#define E1000_VFGORC    0x00F18
-#define E1000_VFMPRC    0x00F3C
-#define E1000_VFGPTC    0x00F14
-#define E1000_VFGOTC    0x00F34
-#define E1000_VFGOTLBC  0x00F50
-#define E1000_VFGPTLBC  0x00F44
-#define E1000_VFGORLBC  0x00F48
-#define E1000_VFGPRLBC  0x00F40
-
-/* These act per VF so an array friendly macro is used */
-#define E1000_V2PMAILBOX(_n)   (0x00C40 + (4 * (_n)))
-#define E1000_VMBMEM(_n)       (0x00800 + (64 * (_n)))
-
-/* Define macros for handling registers */
-#define er32(reg) readl(hw->hw_addr + E1000_##reg)
-#define ew32(reg, val) writel((val), hw->hw_addr +  E1000_##reg)
-#define array_er32(reg, offset) \
-       readl(hw->hw_addr + E1000_##reg + (offset << 2))
-#define array_ew32(reg, offset, val) \
-       writel((val), hw->hw_addr +  E1000_##reg + (offset << 2))
-#define e1e_flush() er32(STATUS)
-
-#endif
diff --git a/drivers/net/igbvf/vf.h b/drivers/net/igbvf/vf.h
deleted file mode 100644 (file)
index 57db3c6..0000000
+++ /dev/null
@@ -1,266 +0,0 @@
-/*******************************************************************************
-
-  Intel(R) 82576 Virtual Function Linux driver
-  Copyright(c) 2009 - 2012 Intel Corporation.
-
-  This program is free software; you can redistribute it and/or modify it
-  under the terms and conditions of the GNU General Public License,
-  version 2, as published by the Free Software Foundation.
-
-  This program is distributed in the hope it will be useful, but WITHOUT
-  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
-  more details.
-
-  You should have received a copy of the GNU General Public License along with
-  this program; if not, write to the Free Software Foundation, Inc.,
-  51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
-
-  The full GNU General Public License is included in this distribution in
-  the file called "COPYING".
-
-  Contact Information:
-  e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
-  Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
-
-*******************************************************************************/
-
-#ifndef _E1000_VF_H_
-#define _E1000_VF_H_
-
-#include <linux/pci.h>
-#include <linux/delay.h>
-#include <linux/interrupt.h>
-#include <linux/if_ether.h>
-
-#include "regs.h"
-#include "defines.h"
-
-struct e1000_hw;
-
-#define E1000_DEV_ID_82576_VF                 0x10CA
-#define E1000_DEV_ID_I350_VF                  0x1520
-#define E1000_REVISION_0 0
-#define E1000_REVISION_1 1
-#define E1000_REVISION_2 2
-#define E1000_REVISION_3 3
-#define E1000_REVISION_4 4
-
-#define E1000_FUNC_0     0
-#define E1000_FUNC_1     1
-
-/*
- * Receive Address Register Count
- * Number of high/low register pairs in the RAR.  The RAR (Receive Address
- * Registers) holds the directed and multicast addresses that we monitor.
- * These entries are also used for MAC-based filtering.
- */
-#define E1000_RAR_ENTRIES_VF      1
-
-/* Receive Descriptor - Advanced */
-union e1000_adv_rx_desc {
-       struct {
-               u64 pkt_addr;             /* Packet buffer address */
-               u64 hdr_addr;             /* Header buffer address */
-       } read;
-       struct {
-               struct {
-                       union {
-                               u32 data;
-                               struct {
-                                       u16 pkt_info; /* RSS/Packet type */
-                                       u16 hdr_info; /* Split Header,
-                                                      * hdr buffer length */
-                               } hs_rss;
-                       } lo_dword;
-                       union {
-                               u32 rss;          /* RSS Hash */
-                               struct {
-                                       u16 ip_id;    /* IP id */
-                                       u16 csum;     /* Packet Checksum */
-                               } csum_ip;
-                       } hi_dword;
-               } lower;
-               struct {
-                       u32 status_error;     /* ext status/error */
-                       u16 length;           /* Packet length */
-                       u16 vlan;             /* VLAN tag */
-               } upper;
-       } wb;  /* writeback */
-};
-
-#define E1000_RXDADV_HDRBUFLEN_MASK      0x7FE0
-#define E1000_RXDADV_HDRBUFLEN_SHIFT     5
-
-/* Transmit Descriptor - Advanced */
-union e1000_adv_tx_desc {
-       struct {
-               u64 buffer_addr;    /* Address of descriptor's data buf */
-               u32 cmd_type_len;
-               u32 olinfo_status;
-       } read;
-       struct {
-               u64 rsvd;       /* Reserved */
-               u32 nxtseq_seed;
-               u32 status;
-       } wb;
-};
-
-/* Adv Transmit Descriptor Config Masks */
-#define E1000_ADVTXD_DTYP_CTXT    0x00200000 /* Advanced Context Descriptor */
-#define E1000_ADVTXD_DTYP_DATA    0x00300000 /* Advanced Data Descriptor */
-#define E1000_ADVTXD_DCMD_EOP     0x01000000 /* End of Packet */
-#define E1000_ADVTXD_DCMD_IFCS    0x02000000 /* Insert FCS (Ethernet CRC) */
-#define E1000_ADVTXD_DCMD_RS      0x08000000 /* Report Status */
-#define E1000_ADVTXD_DCMD_DEXT    0x20000000 /* Descriptor extension (1=Adv) */
-#define E1000_ADVTXD_DCMD_VLE     0x40000000 /* VLAN pkt enable */
-#define E1000_ADVTXD_DCMD_TSE     0x80000000 /* TCP Seg enable */
-#define E1000_ADVTXD_PAYLEN_SHIFT    14 /* Adv desc PAYLEN shift */
-
-/* Context descriptors */
-struct e1000_adv_tx_context_desc {
-       u32 vlan_macip_lens;
-       u32 seqnum_seed;
-       u32 type_tucmd_mlhl;
-       u32 mss_l4len_idx;
-};
-
-#define E1000_ADVTXD_MACLEN_SHIFT    9  /* Adv ctxt desc mac len shift */
-#define E1000_ADVTXD_TUCMD_IPV4    0x00000400  /* IP Packet Type: 1=IPv4 */
-#define E1000_ADVTXD_TUCMD_L4T_TCP 0x00000800  /* L4 Packet TYPE of TCP */
-#define E1000_ADVTXD_L4LEN_SHIFT     8  /* Adv ctxt L4LEN shift */
-#define E1000_ADVTXD_MSS_SHIFT      16  /* Adv ctxt MSS shift */
-
-enum e1000_mac_type {
-       e1000_undefined = 0,
-       e1000_vfadapt,
-       e1000_vfadapt_i350,
-       e1000_num_macs  /* List is 1-based, so subtract 1 for true count. */
-};
-
-struct e1000_vf_stats {
-       u64 base_gprc;
-       u64 base_gptc;
-       u64 base_gorc;
-       u64 base_gotc;
-       u64 base_mprc;
-       u64 base_gotlbc;
-       u64 base_gptlbc;
-       u64 base_gorlbc;
-       u64 base_gprlbc;
-
-       u32 last_gprc;
-       u32 last_gptc;
-       u32 last_gorc;
-       u32 last_gotc;
-       u32 last_mprc;
-       u32 last_gotlbc;
-       u32 last_gptlbc;
-       u32 last_gorlbc;
-       u32 last_gprlbc;
-
-       u64 gprc;
-       u64 gptc;
-       u64 gorc;
-       u64 gotc;
-       u64 mprc;
-       u64 gotlbc;
-       u64 gptlbc;
-       u64 gorlbc;
-       u64 gprlbc;
-};
-
-#include "mbx.h"
-
-struct e1000_mac_operations {
-       /* Function pointers for the MAC. */
-       s32  (*init_params)(struct e1000_hw *);
-       s32  (*check_for_link)(struct e1000_hw *);
-       void (*clear_vfta)(struct e1000_hw *);
-       s32  (*get_bus_info)(struct e1000_hw *);
-       s32  (*get_link_up_info)(struct e1000_hw *, u16 *, u16 *);
-       void (*update_mc_addr_list)(struct e1000_hw *, u8 *, u32, u32, u32);
-       s32  (*reset_hw)(struct e1000_hw *);
-       s32  (*init_hw)(struct e1000_hw *);
-       s32  (*setup_link)(struct e1000_hw *);
-       void (*write_vfta)(struct e1000_hw *, u32, u32);
-       void (*mta_set)(struct e1000_hw *, u32);
-       void (*rar_set)(struct e1000_hw *, u8*, u32);
-       s32  (*read_mac_addr)(struct e1000_hw *);
-       s32  (*set_vfta)(struct e1000_hw *, u16, bool);
-};
-
-struct e1000_mac_info {
-       struct e1000_mac_operations ops;
-       u8 addr[6];
-       u8 perm_addr[6];
-
-       enum e1000_mac_type type;
-
-       u16 mta_reg_count;
-       u16 rar_entry_count;
-
-       bool get_link_status;
-};
-
-struct e1000_mbx_operations {
-       s32 (*init_params)(struct e1000_hw *hw);
-       s32 (*read)(struct e1000_hw *, u32 *, u16);
-       s32 (*write)(struct e1000_hw *, u32 *, u16);
-       s32 (*read_posted)(struct e1000_hw *, u32 *, u16);
-       s32 (*write_posted)(struct e1000_hw *, u32 *, u16);
-       s32 (*check_for_msg)(struct e1000_hw *);
-       s32 (*check_for_ack)(struct e1000_hw *);
-       s32 (*check_for_rst)(struct e1000_hw *);
-};
-
-struct e1000_mbx_stats {
-       u32 msgs_tx;
-       u32 msgs_rx;
-
-       u32 acks;
-       u32 reqs;
-       u32 rsts;
-};
-
-struct e1000_mbx_info {
-       struct e1000_mbx_operations ops;
-       struct e1000_mbx_stats stats;
-       u32 timeout;
-       u32 usec_delay;
-       u16 size;
-};
-
-struct e1000_dev_spec_vf {
-       u32 vf_number;
-       u32 v2p_mailbox;
-};
-
-struct e1000_hw {
-       void *back;
-
-       u8 __iomem *hw_addr;
-       u8 __iomem *flash_address;
-       unsigned long io_base;
-
-       struct e1000_mac_info  mac;
-       struct e1000_mbx_info mbx;
-
-       union {
-               struct e1000_dev_spec_vf vf;
-       } dev_spec;
-
-       u16 device_id;
-       u16 subsystem_vendor_id;
-       u16 subsystem_device_id;
-       u16 vendor_id;
-
-       u8  revision_id;
-};
-
-/* These functions must be implemented by drivers */
-void e1000_rlpml_set_vf(struct e1000_hw *, u16);
-void e1000_init_function_pointers_vf(struct e1000_hw *hw);
-
-
-#endif /* _E1000_VF_H_ */