aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/igb
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/igb')
-rw-r--r--drivers/net/igb/e1000_82575.c296
-rw-r--r--drivers/net/igb/e1000_82575.h1
-rw-r--r--drivers/net/igb/e1000_defines.h52
-rw-r--r--drivers/net/igb/e1000_hw.h9
-rw-r--r--drivers/net/igb/e1000_mbx.c38
-rw-r--r--drivers/net/igb/e1000_nvm.c64
-rw-r--r--drivers/net/igb/e1000_nvm.h1
-rw-r--r--drivers/net/igb/e1000_regs.h27
-rw-r--r--drivers/net/igb/igb.h8
-rw-r--r--drivers/net/igb/igb_ethtool.c30
-rw-r--r--drivers/net/igb/igb_main.c232
11 files changed, 710 insertions, 48 deletions
diff --git a/drivers/net/igb/e1000_82575.c b/drivers/net/igb/e1000_82575.c
index 0a2368fa6bc6..6b256c275e10 100644
--- a/drivers/net/igb/e1000_82575.c
+++ b/drivers/net/igb/e1000_82575.c
@@ -64,7 +64,14 @@ static s32 igb_reset_init_script_82575(struct e1000_hw *);
64static s32 igb_read_mac_addr_82575(struct e1000_hw *); 64static s32 igb_read_mac_addr_82575(struct e1000_hw *);
65static s32 igb_set_pcie_completion_timeout(struct e1000_hw *hw); 65static s32 igb_set_pcie_completion_timeout(struct e1000_hw *hw);
66static s32 igb_reset_mdicnfg_82580(struct e1000_hw *hw); 66static s32 igb_reset_mdicnfg_82580(struct e1000_hw *hw);
67 67static s32 igb_validate_nvm_checksum_82580(struct e1000_hw *hw);
68static s32 igb_update_nvm_checksum_82580(struct e1000_hw *hw);
69static s32 igb_update_nvm_checksum_with_offset(struct e1000_hw *hw,
70 u16 offset);
71static s32 igb_validate_nvm_checksum_with_offset(struct e1000_hw *hw,
72 u16 offset);
73static s32 igb_validate_nvm_checksum_i350(struct e1000_hw *hw);
74static s32 igb_update_nvm_checksum_i350(struct e1000_hw *hw);
68static const u16 e1000_82580_rxpbs_table[] = 75static const u16 e1000_82580_rxpbs_table[] =
69 { 36, 72, 144, 1, 2, 4, 8, 16, 76 { 36, 72, 144, 1, 2, 4, 8, 16,
70 35, 70, 140 }; 77 35, 70, 140 };
@@ -129,6 +136,7 @@ static s32 igb_get_invariants_82575(struct e1000_hw *hw)
129 break; 136 break;
130 case E1000_DEV_ID_82580_COPPER: 137 case E1000_DEV_ID_82580_COPPER:
131 case E1000_DEV_ID_82580_FIBER: 138 case E1000_DEV_ID_82580_FIBER:
139 case E1000_DEV_ID_82580_QUAD_FIBER:
132 case E1000_DEV_ID_82580_SERDES: 140 case E1000_DEV_ID_82580_SERDES:
133 case E1000_DEV_ID_82580_SGMII: 141 case E1000_DEV_ID_82580_SGMII:
134 case E1000_DEV_ID_82580_COPPER_DUAL: 142 case E1000_DEV_ID_82580_COPPER_DUAL:
@@ -194,7 +202,11 @@ static s32 igb_get_invariants_82575(struct e1000_hw *hw)
194 mac->arc_subsystem_valid = 202 mac->arc_subsystem_valid =
195 (rd32(E1000_FWSM) & E1000_FWSM_MODE_MASK) 203 (rd32(E1000_FWSM) & E1000_FWSM_MODE_MASK)
196 ? true : false; 204 ? true : false;
197 205 /* enable EEE on i350 parts */
206 if (mac->type == e1000_i350)
207 dev_spec->eee_disable = false;
208 else
209 dev_spec->eee_disable = true;
198 /* physical interface link setup */ 210 /* physical interface link setup */
199 mac->ops.setup_physical_interface = 211 mac->ops.setup_physical_interface =
200 (hw->phy.media_type == e1000_media_type_copper) 212 (hw->phy.media_type == e1000_media_type_copper)
@@ -232,14 +244,42 @@ static s32 igb_get_invariants_82575(struct e1000_hw *hw)
232 */ 244 */
233 size += NVM_WORD_SIZE_BASE_SHIFT; 245 size += NVM_WORD_SIZE_BASE_SHIFT;
234 246
235 /* EEPROM access above 16k is unsupported */
236 if (size > 14)
237 size = 14;
238 nvm->word_size = 1 << size; 247 nvm->word_size = 1 << size;
248 if (nvm->word_size == (1 << 15))
249 nvm->page_size = 128;
239 250
240 /* if 82576 then initialize mailbox parameters */ 251 /* NVM Function Pointers */
241 if (mac->type == e1000_82576) 252 nvm->ops.acquire = igb_acquire_nvm_82575;
253 if (nvm->word_size < (1 << 15))
254 nvm->ops.read = igb_read_nvm_eerd;
255 else
256 nvm->ops.read = igb_read_nvm_spi;
257
258 nvm->ops.release = igb_release_nvm_82575;
259 switch (hw->mac.type) {
260 case e1000_82580:
261 nvm->ops.validate = igb_validate_nvm_checksum_82580;
262 nvm->ops.update = igb_update_nvm_checksum_82580;
263 break;
264 case e1000_i350:
265 nvm->ops.validate = igb_validate_nvm_checksum_i350;
266 nvm->ops.update = igb_update_nvm_checksum_i350;
267 break;
268 default:
269 nvm->ops.validate = igb_validate_nvm_checksum;
270 nvm->ops.update = igb_update_nvm_checksum;
271 }
272 nvm->ops.write = igb_write_nvm_spi;
273
274 /* if part supports SR-IOV then initialize mailbox parameters */
275 switch (mac->type) {
276 case e1000_82576:
277 case e1000_i350:
242 igb_init_mbx_params_pf(hw); 278 igb_init_mbx_params_pf(hw);
279 break;
280 default:
281 break;
282 }
243 283
244 /* setup PHY parameters */ 284 /* setup PHY parameters */
245 if (phy->media_type != e1000_media_type_copper) { 285 if (phy->media_type != e1000_media_type_copper) {
@@ -1747,6 +1787,248 @@ u16 igb_rxpbs_adjust_82580(u32 data)
1747 return ret_val; 1787 return ret_val;
1748} 1788}
1749 1789
1790/**
1791 * igb_validate_nvm_checksum_with_offset - Validate EEPROM
1792 * checksum
1793 * @hw: pointer to the HW structure
1794 * @offset: offset in words of the checksum protected region
1795 *
1796 * Calculates the EEPROM checksum by reading/adding each word of the EEPROM
1797 * and then verifies that the sum of the EEPROM is equal to 0xBABA.
1798 **/
1799s32 igb_validate_nvm_checksum_with_offset(struct e1000_hw *hw, u16 offset)
1800{
1801 s32 ret_val = 0;
1802 u16 checksum = 0;
1803 u16 i, nvm_data;
1804
1805 for (i = offset; i < ((NVM_CHECKSUM_REG + offset) + 1); i++) {
1806 ret_val = hw->nvm.ops.read(hw, i, 1, &nvm_data);
1807 if (ret_val) {
1808 hw_dbg("NVM Read Error\n");
1809 goto out;
1810 }
1811 checksum += nvm_data;
1812 }
1813
1814 if (checksum != (u16) NVM_SUM) {
1815 hw_dbg("NVM Checksum Invalid\n");
1816 ret_val = -E1000_ERR_NVM;
1817 goto out;
1818 }
1819
1820out:
1821 return ret_val;
1822}
1823
1824/**
1825 * igb_update_nvm_checksum_with_offset - Update EEPROM
1826 * checksum
1827 * @hw: pointer to the HW structure
1828 * @offset: offset in words of the checksum protected region
1829 *
1830 * Updates the EEPROM checksum by reading/adding each word of the EEPROM
1831 * up to the checksum. Then calculates the EEPROM checksum and writes the
1832 * value to the EEPROM.
1833 **/
1834s32 igb_update_nvm_checksum_with_offset(struct e1000_hw *hw, u16 offset)
1835{
1836 s32 ret_val;
1837 u16 checksum = 0;
1838 u16 i, nvm_data;
1839
1840 for (i = offset; i < (NVM_CHECKSUM_REG + offset); i++) {
1841 ret_val = hw->nvm.ops.read(hw, i, 1, &nvm_data);
1842 if (ret_val) {
1843 hw_dbg("NVM Read Error while updating checksum.\n");
1844 goto out;
1845 }
1846 checksum += nvm_data;
1847 }
1848 checksum = (u16) NVM_SUM - checksum;
1849 ret_val = hw->nvm.ops.write(hw, (NVM_CHECKSUM_REG + offset), 1,
1850 &checksum);
1851 if (ret_val)
1852 hw_dbg("NVM Write Error while updating checksum.\n");
1853
1854out:
1855 return ret_val;
1856}
1857
1858/**
1859 * igb_validate_nvm_checksum_82580 - Validate EEPROM checksum
1860 * @hw: pointer to the HW structure
1861 *
1862 * Calculates the EEPROM section checksum by reading/adding each word of
1863 * the EEPROM and then verifies that the sum of the EEPROM is
1864 * equal to 0xBABA.
1865 **/
1866static s32 igb_validate_nvm_checksum_82580(struct e1000_hw *hw)
1867{
1868 s32 ret_val = 0;
1869 u16 eeprom_regions_count = 1;
1870 u16 j, nvm_data;
1871 u16 nvm_offset;
1872
1873 ret_val = hw->nvm.ops.read(hw, NVM_COMPATIBILITY_REG_3, 1, &nvm_data);
1874 if (ret_val) {
1875 hw_dbg("NVM Read Error\n");
1876 goto out;
1877 }
1878
1879 if (nvm_data & NVM_COMPATIBILITY_BIT_MASK) {
1880 /* if chekcsums compatibility bit is set validate checksums
1881 * for all 4 ports. */
1882 eeprom_regions_count = 4;
1883 }
1884
1885 for (j = 0; j < eeprom_regions_count; j++) {
1886 nvm_offset = NVM_82580_LAN_FUNC_OFFSET(j);
1887 ret_val = igb_validate_nvm_checksum_with_offset(hw,
1888 nvm_offset);
1889 if (ret_val != 0)
1890 goto out;
1891 }
1892
1893out:
1894 return ret_val;
1895}
1896
1897/**
1898 * igb_update_nvm_checksum_82580 - Update EEPROM checksum
1899 * @hw: pointer to the HW structure
1900 *
1901 * Updates the EEPROM section checksums for all 4 ports by reading/adding
1902 * each word of the EEPROM up to the checksum. Then calculates the EEPROM
1903 * checksum and writes the value to the EEPROM.
1904 **/
1905static s32 igb_update_nvm_checksum_82580(struct e1000_hw *hw)
1906{
1907 s32 ret_val;
1908 u16 j, nvm_data;
1909 u16 nvm_offset;
1910
1911 ret_val = hw->nvm.ops.read(hw, NVM_COMPATIBILITY_REG_3, 1, &nvm_data);
1912 if (ret_val) {
1913 hw_dbg("NVM Read Error while updating checksum"
1914 " compatibility bit.\n");
1915 goto out;
1916 }
1917
1918 if ((nvm_data & NVM_COMPATIBILITY_BIT_MASK) == 0) {
1919 /* set compatibility bit to validate checksums appropriately */
1920 nvm_data = nvm_data | NVM_COMPATIBILITY_BIT_MASK;
1921 ret_val = hw->nvm.ops.write(hw, NVM_COMPATIBILITY_REG_3, 1,
1922 &nvm_data);
1923 if (ret_val) {
1924 hw_dbg("NVM Write Error while updating checksum"
1925 " compatibility bit.\n");
1926 goto out;
1927 }
1928 }
1929
1930 for (j = 0; j < 4; j++) {
1931 nvm_offset = NVM_82580_LAN_FUNC_OFFSET(j);
1932 ret_val = igb_update_nvm_checksum_with_offset(hw, nvm_offset);
1933 if (ret_val)
1934 goto out;
1935 }
1936
1937out:
1938 return ret_val;
1939}
1940
1941/**
1942 * igb_validate_nvm_checksum_i350 - Validate EEPROM checksum
1943 * @hw: pointer to the HW structure
1944 *
1945 * Calculates the EEPROM section checksum by reading/adding each word of
1946 * the EEPROM and then verifies that the sum of the EEPROM is
1947 * equal to 0xBABA.
1948 **/
1949static s32 igb_validate_nvm_checksum_i350(struct e1000_hw *hw)
1950{
1951 s32 ret_val = 0;
1952 u16 j;
1953 u16 nvm_offset;
1954
1955 for (j = 0; j < 4; j++) {
1956 nvm_offset = NVM_82580_LAN_FUNC_OFFSET(j);
1957 ret_val = igb_validate_nvm_checksum_with_offset(hw,
1958 nvm_offset);
1959 if (ret_val != 0)
1960 goto out;
1961 }
1962
1963out:
1964 return ret_val;
1965}
1966
1967/**
1968 * igb_update_nvm_checksum_i350 - Update EEPROM checksum
1969 * @hw: pointer to the HW structure
1970 *
1971 * Updates the EEPROM section checksums for all 4 ports by reading/adding
1972 * each word of the EEPROM up to the checksum. Then calculates the EEPROM
1973 * checksum and writes the value to the EEPROM.
1974 **/
1975static s32 igb_update_nvm_checksum_i350(struct e1000_hw *hw)
1976{
1977 s32 ret_val = 0;
1978 u16 j;
1979 u16 nvm_offset;
1980
1981 for (j = 0; j < 4; j++) {
1982 nvm_offset = NVM_82580_LAN_FUNC_OFFSET(j);
1983 ret_val = igb_update_nvm_checksum_with_offset(hw, nvm_offset);
1984 if (ret_val != 0)
1985 goto out;
1986 }
1987
1988out:
1989 return ret_val;
1990}
1991/**
1992 * igb_set_eee_i350 - Enable/disable EEE support
1993 * @hw: pointer to the HW structure
1994 *
1995 * Enable/disable EEE based on setting in dev_spec structure.
1996 *
1997 **/
1998s32 igb_set_eee_i350(struct e1000_hw *hw)
1999{
2000 s32 ret_val = 0;
2001 u32 ipcnfg, eeer, ctrl_ext;
2002
2003 ctrl_ext = rd32(E1000_CTRL_EXT);
2004 if ((hw->mac.type != e1000_i350) ||
2005 (ctrl_ext & E1000_CTRL_EXT_LINK_MODE_MASK))
2006 goto out;
2007 ipcnfg = rd32(E1000_IPCNFG);
2008 eeer = rd32(E1000_EEER);
2009
2010 /* enable or disable per user setting */
2011 if (!(hw->dev_spec._82575.eee_disable)) {
2012 ipcnfg |= (E1000_IPCNFG_EEE_1G_AN |
2013 E1000_IPCNFG_EEE_100M_AN);
2014 eeer |= (E1000_EEER_TX_LPI_EN |
2015 E1000_EEER_RX_LPI_EN |
2016 E1000_EEER_LPI_FC);
2017
2018 } else {
2019 ipcnfg &= ~(E1000_IPCNFG_EEE_1G_AN |
2020 E1000_IPCNFG_EEE_100M_AN);
2021 eeer &= ~(E1000_EEER_TX_LPI_EN |
2022 E1000_EEER_RX_LPI_EN |
2023 E1000_EEER_LPI_FC);
2024 }
2025 wr32(E1000_IPCNFG, ipcnfg);
2026 wr32(E1000_EEER, eeer);
2027out:
2028
2029 return ret_val;
2030}
2031
1750static struct e1000_mac_operations e1000_mac_ops_82575 = { 2032static struct e1000_mac_operations e1000_mac_ops_82575 = {
1751 .init_hw = igb_init_hw_82575, 2033 .init_hw = igb_init_hw_82575,
1752 .check_for_link = igb_check_for_link_82575, 2034 .check_for_link = igb_check_for_link_82575,
diff --git a/drivers/net/igb/e1000_82575.h b/drivers/net/igb/e1000_82575.h
index 1d01af2472e7..dd6df3498998 100644
--- a/drivers/net/igb/e1000_82575.h
+++ b/drivers/net/igb/e1000_82575.h
@@ -251,5 +251,6 @@ void igb_vmdq_set_anti_spoofing_pf(struct e1000_hw *, bool, int);
251void igb_vmdq_set_loopback_pf(struct e1000_hw *, bool); 251void igb_vmdq_set_loopback_pf(struct e1000_hw *, bool);
252void igb_vmdq_set_replication_pf(struct e1000_hw *, bool); 252void igb_vmdq_set_replication_pf(struct e1000_hw *, bool);
253u16 igb_rxpbs_adjust_82580(u32 data); 253u16 igb_rxpbs_adjust_82580(u32 data);
254s32 igb_set_eee_i350(struct e1000_hw *);
254 255
255#endif 256#endif
diff --git a/drivers/net/igb/e1000_defines.h b/drivers/net/igb/e1000_defines.h
index 6319ed902bc0..6b80d40110ca 100644
--- a/drivers/net/igb/e1000_defines.h
+++ b/drivers/net/igb/e1000_defines.h
@@ -51,6 +51,7 @@
51#define E1000_CTRL_EXT_LINK_MODE_PCIE_SERDES 0x00C00000 51#define E1000_CTRL_EXT_LINK_MODE_PCIE_SERDES 0x00C00000
52#define E1000_CTRL_EXT_LINK_MODE_1000BASE_KX 0x00400000 52#define E1000_CTRL_EXT_LINK_MODE_1000BASE_KX 0x00400000
53#define E1000_CTRL_EXT_LINK_MODE_SGMII 0x00800000 53#define E1000_CTRL_EXT_LINK_MODE_SGMII 0x00800000
54#define E1000_CTRL_EXT_LINK_MODE_GMII 0x00000000
54#define E1000_CTRL_EXT_EIAME 0x01000000 55#define E1000_CTRL_EXT_EIAME 0x01000000
55#define E1000_CTRL_EXT_IRCA 0x00000001 56#define E1000_CTRL_EXT_IRCA 0x00000001
56/* Interrupt delay cancellation */ 57/* Interrupt delay cancellation */
@@ -110,6 +111,7 @@
110/* Management Control */ 111/* Management Control */
111#define E1000_MANC_SMBUS_EN 0x00000001 /* SMBus Enabled - RO */ 112#define E1000_MANC_SMBUS_EN 0x00000001 /* SMBus Enabled - RO */
112#define E1000_MANC_ASF_EN 0x00000002 /* ASF Enabled - RO */ 113#define E1000_MANC_ASF_EN 0x00000002 /* ASF Enabled - RO */
114#define E1000_MANC_EN_BMC2OS 0x10000000 /* OSBMC is Enabled or not */
113/* Enable Neighbor Discovery Filtering */ 115/* Enable Neighbor Discovery Filtering */
114#define E1000_MANC_RCV_TCO_EN 0x00020000 /* Receive TCO Packets Enabled */ 116#define E1000_MANC_RCV_TCO_EN 0x00020000 /* Receive TCO Packets Enabled */
115#define E1000_MANC_BLK_PHY_RST_ON_IDE 0x00040000 /* Block phy resets */ 117#define E1000_MANC_BLK_PHY_RST_ON_IDE 0x00040000 /* Block phy resets */
@@ -286,7 +288,34 @@
286#define E1000_TCTL_COLD 0x003ff000 /* collision distance */ 288#define E1000_TCTL_COLD 0x003ff000 /* collision distance */
287#define E1000_TCTL_RTLC 0x01000000 /* Re-transmit on late collision */ 289#define E1000_TCTL_RTLC 0x01000000 /* Re-transmit on late collision */
288 290
289/* Transmit Arbitration Count */ 291/* DMA Coalescing register fields */
292#define E1000_DMACR_DMACWT_MASK 0x00003FFF /* DMA Coalescing
293 * Watchdog Timer */
294#define E1000_DMACR_DMACTHR_MASK 0x00FF0000 /* DMA Coalescing Receive
295 * Threshold */
296#define E1000_DMACR_DMACTHR_SHIFT 16
297#define E1000_DMACR_DMAC_LX_MASK 0x30000000 /* Lx when no PCIe
298 * transactions */
299#define E1000_DMACR_DMAC_LX_SHIFT 28
300#define E1000_DMACR_DMAC_EN 0x80000000 /* Enable DMA Coalescing */
301
302#define E1000_DMCTXTH_DMCTTHR_MASK 0x00000FFF /* DMA Coalescing Transmit
303 * Threshold */
304
305#define E1000_DMCTLX_TTLX_MASK 0x00000FFF /* Time to LX request */
306
307#define E1000_DMCRTRH_UTRESH_MASK 0x0007FFFF /* Receive Traffic Rate
308 * Threshold */
309#define E1000_DMCRTRH_LRPRCW 0x80000000 /* Rcv packet rate in
310 * current window */
311
312#define E1000_DMCCNT_CCOUNT_MASK 0x01FFFFFF /* DMA Coal Rcv Traffic
313 * Current Cnt */
314
315#define E1000_FCRTC_RTH_COAL_MASK 0x0003FFF0 /* Flow ctrl Rcv Threshold
316 * High val */
317#define E1000_FCRTC_RTH_COAL_SHIFT 4
318#define E1000_PCIEMISC_LX_DECISION 0x00000080 /* Lx power decision */
290 319
291/* SerDes Control */ 320/* SerDes Control */
292#define E1000_SCTL_DISABLE_SERDES_LOOPBACK 0x0400 321#define E1000_SCTL_DISABLE_SERDES_LOOPBACK 0x0400
@@ -565,6 +594,8 @@
565#define NVM_INIT_CONTROL3_PORT_A 0x0024 594#define NVM_INIT_CONTROL3_PORT_A 0x0024
566#define NVM_ALT_MAC_ADDR_PTR 0x0037 595#define NVM_ALT_MAC_ADDR_PTR 0x0037
567#define NVM_CHECKSUM_REG 0x003F 596#define NVM_CHECKSUM_REG 0x003F
597#define NVM_COMPATIBILITY_REG_3 0x0003
598#define NVM_COMPATIBILITY_BIT_MASK 0x8000
568 599
569#define E1000_NVM_CFG_DONE_PORT_0 0x040000 /* MNG config cycle done */ 600#define E1000_NVM_CFG_DONE_PORT_0 0x040000 /* MNG config cycle done */
570#define E1000_NVM_CFG_DONE_PORT_1 0x080000 /* ...for second port */ 601#define E1000_NVM_CFG_DONE_PORT_1 0x080000 /* ...for second port */
@@ -599,6 +630,7 @@
599/* NVM Commands - SPI */ 630/* NVM Commands - SPI */
600#define NVM_MAX_RETRY_SPI 5000 /* Max wait of 5ms, for RDY signal */ 631#define NVM_MAX_RETRY_SPI 5000 /* Max wait of 5ms, for RDY signal */
601#define NVM_WRITE_OPCODE_SPI 0x02 /* NVM write opcode */ 632#define NVM_WRITE_OPCODE_SPI 0x02 /* NVM write opcode */
633#define NVM_READ_OPCODE_SPI 0x03 /* NVM read opcode */
602#define NVM_A8_OPCODE_SPI 0x08 /* opcode bit-3 = address bit-8 */ 634#define NVM_A8_OPCODE_SPI 0x08 /* opcode bit-3 = address bit-8 */
603#define NVM_WREN_OPCODE_SPI 0x06 /* NVM set Write Enable latch */ 635#define NVM_WREN_OPCODE_SPI 0x06 /* NVM set Write Enable latch */
604#define NVM_RDSR_OPCODE_SPI 0x05 /* NVM read Status register */ 636#define NVM_RDSR_OPCODE_SPI 0x05 /* NVM read Status register */
@@ -757,6 +789,17 @@
757#define E1000_MDIC_ERROR 0x40000000 789#define E1000_MDIC_ERROR 0x40000000
758#define E1000_MDIC_DEST 0x80000000 790#define E1000_MDIC_DEST 0x80000000
759 791
792/* Thermal Sensor */
793#define E1000_THSTAT_PWR_DOWN 0x00000001 /* Power Down Event */
794#define E1000_THSTAT_LINK_THROTTLE 0x00000002 /* Link Speed Throttle Event */
795
796/* Energy Efficient Ethernet */
797#define E1000_IPCNFG_EEE_1G_AN 0x00000008 /* EEE Enable 1G AN */
798#define E1000_IPCNFG_EEE_100M_AN 0x00000004 /* EEE Enable 100M AN */
799#define E1000_EEER_TX_LPI_EN 0x00010000 /* EEE Tx LPI Enable */
800#define E1000_EEER_RX_LPI_EN 0x00020000 /* EEE Rx LPI Enable */
801#define E1000_EEER_LPI_FC 0x00040000 /* EEE Enable on FC */
802
760/* SerDes Control */ 803/* SerDes Control */
761#define E1000_GEN_CTL_READY 0x80000000 804#define E1000_GEN_CTL_READY 0x80000000
762#define E1000_GEN_CTL_ADDRESS_SHIFT 8 805#define E1000_GEN_CTL_ADDRESS_SHIFT 8
@@ -770,4 +813,11 @@
770#define E1000_PCIEMISC_LX_DECISION 0x00000080 /* Lx power decision based 813#define E1000_PCIEMISC_LX_DECISION 0x00000080 /* Lx power decision based
771 on DMA coal */ 814 on DMA coal */
772 815
816/* Tx Rate-Scheduler Config fields */
817#define E1000_RTTBCNRC_RS_ENA 0x80000000
818#define E1000_RTTBCNRC_RF_DEC_MASK 0x00003FFF
819#define E1000_RTTBCNRC_RF_INT_SHIFT 14
820#define E1000_RTTBCNRC_RF_INT_MASK \
821 (E1000_RTTBCNRC_RF_DEC_MASK << E1000_RTTBCNRC_RF_INT_SHIFT)
822
773#endif 823#endif
diff --git a/drivers/net/igb/e1000_hw.h b/drivers/net/igb/e1000_hw.h
index e2638afb8cdc..27153e8d7b16 100644
--- a/drivers/net/igb/e1000_hw.h
+++ b/drivers/net/igb/e1000_hw.h
@@ -54,6 +54,7 @@ struct e1000_hw;
54#define E1000_DEV_ID_82580_SERDES 0x1510 54#define E1000_DEV_ID_82580_SERDES 0x1510
55#define E1000_DEV_ID_82580_SGMII 0x1511 55#define E1000_DEV_ID_82580_SGMII 0x1511
56#define E1000_DEV_ID_82580_COPPER_DUAL 0x1516 56#define E1000_DEV_ID_82580_COPPER_DUAL 0x1516
57#define E1000_DEV_ID_82580_QUAD_FIBER 0x1527
57#define E1000_DEV_ID_DH89XXCC_SGMII 0x0438 58#define E1000_DEV_ID_DH89XXCC_SGMII 0x0438
58#define E1000_DEV_ID_DH89XXCC_SERDES 0x043A 59#define E1000_DEV_ID_DH89XXCC_SERDES 0x043A
59#define E1000_DEV_ID_DH89XXCC_BACKPLANE 0x043C 60#define E1000_DEV_ID_DH89XXCC_BACKPLANE 0x043C
@@ -247,6 +248,10 @@ struct e1000_hw_stats {
247 u64 scvpc; 248 u64 scvpc;
248 u64 hrmpc; 249 u64 hrmpc;
249 u64 doosync; 250 u64 doosync;
251 u64 o2bgptc;
252 u64 o2bspc;
253 u64 b2ospc;
254 u64 b2ogprc;
250}; 255};
251 256
252struct e1000_phy_stats { 257struct e1000_phy_stats {
@@ -331,6 +336,8 @@ struct e1000_nvm_operations {
331 s32 (*read)(struct e1000_hw *, u16, u16, u16 *); 336 s32 (*read)(struct e1000_hw *, u16, u16, u16 *);
332 void (*release)(struct e1000_hw *); 337 void (*release)(struct e1000_hw *);
333 s32 (*write)(struct e1000_hw *, u16, u16, u16 *); 338 s32 (*write)(struct e1000_hw *, u16, u16, u16 *);
339 s32 (*update)(struct e1000_hw *);
340 s32 (*validate)(struct e1000_hw *);
334}; 341};
335 342
336struct e1000_info { 343struct e1000_info {
@@ -417,7 +424,6 @@ struct e1000_phy_info {
417 424
418struct e1000_nvm_info { 425struct e1000_nvm_info {
419 struct e1000_nvm_operations ops; 426 struct e1000_nvm_operations ops;
420
421 enum e1000_nvm_type type; 427 enum e1000_nvm_type type;
422 enum e1000_nvm_override override; 428 enum e1000_nvm_override override;
423 429
@@ -483,6 +489,7 @@ struct e1000_mbx_info {
483struct e1000_dev_spec_82575 { 489struct e1000_dev_spec_82575 {
484 bool sgmii_active; 490 bool sgmii_active;
485 bool global_device_reset; 491 bool global_device_reset;
492 bool eee_disable;
486}; 493};
487 494
488struct e1000_hw { 495struct e1000_hw {
diff --git a/drivers/net/igb/e1000_mbx.c b/drivers/net/igb/e1000_mbx.c
index c474cdb70047..78d48c7fa859 100644
--- a/drivers/net/igb/e1000_mbx.c
+++ b/drivers/net/igb/e1000_mbx.c
@@ -422,26 +422,24 @@ s32 igb_init_mbx_params_pf(struct e1000_hw *hw)
422{ 422{
423 struct e1000_mbx_info *mbx = &hw->mbx; 423 struct e1000_mbx_info *mbx = &hw->mbx;
424 424
425 if (hw->mac.type == e1000_82576) { 425 mbx->timeout = 0;
426 mbx->timeout = 0; 426 mbx->usec_delay = 0;
427 mbx->usec_delay = 0; 427
428 428 mbx->size = E1000_VFMAILBOX_SIZE;
429 mbx->size = E1000_VFMAILBOX_SIZE; 429
430 430 mbx->ops.read = igb_read_mbx_pf;
431 mbx->ops.read = igb_read_mbx_pf; 431 mbx->ops.write = igb_write_mbx_pf;
432 mbx->ops.write = igb_write_mbx_pf; 432 mbx->ops.read_posted = igb_read_posted_mbx;
433 mbx->ops.read_posted = igb_read_posted_mbx; 433 mbx->ops.write_posted = igb_write_posted_mbx;
434 mbx->ops.write_posted = igb_write_posted_mbx; 434 mbx->ops.check_for_msg = igb_check_for_msg_pf;
435 mbx->ops.check_for_msg = igb_check_for_msg_pf; 435 mbx->ops.check_for_ack = igb_check_for_ack_pf;
436 mbx->ops.check_for_ack = igb_check_for_ack_pf; 436 mbx->ops.check_for_rst = igb_check_for_rst_pf;
437 mbx->ops.check_for_rst = igb_check_for_rst_pf; 437
438 438 mbx->stats.msgs_tx = 0;
439 mbx->stats.msgs_tx = 0; 439 mbx->stats.msgs_rx = 0;
440 mbx->stats.msgs_rx = 0; 440 mbx->stats.reqs = 0;
441 mbx->stats.reqs = 0; 441 mbx->stats.acks = 0;
442 mbx->stats.acks = 0; 442 mbx->stats.rsts = 0;
443 mbx->stats.rsts = 0;
444 }
445 443
446 return 0; 444 return 0;
447} 445}
diff --git a/drivers/net/igb/e1000_nvm.c b/drivers/net/igb/e1000_nvm.c
index 6b5cc2cc453d..75bf36a4baee 100644
--- a/drivers/net/igb/e1000_nvm.c
+++ b/drivers/net/igb/e1000_nvm.c
@@ -318,6 +318,68 @@ out:
318} 318}
319 319
320/** 320/**
321 * igb_read_nvm_spi - Read EEPROM's using SPI
322 * @hw: pointer to the HW structure
323 * @offset: offset of word in the EEPROM to read
324 * @words: number of words to read
325 * @data: word read from the EEPROM
326 *
327 * Reads a 16 bit word from the EEPROM.
328 **/
329s32 igb_read_nvm_spi(struct e1000_hw *hw, u16 offset, u16 words, u16 *data)
330{
331 struct e1000_nvm_info *nvm = &hw->nvm;
332 u32 i = 0;
333 s32 ret_val;
334 u16 word_in;
335 u8 read_opcode = NVM_READ_OPCODE_SPI;
336
337 /*
338 * A check for invalid values: offset too large, too many words,
339 * and not enough words.
340 */
341 if ((offset >= nvm->word_size) || (words > (nvm->word_size - offset)) ||
342 (words == 0)) {
343 hw_dbg("nvm parameter(s) out of bounds\n");
344 ret_val = -E1000_ERR_NVM;
345 goto out;
346 }
347
348 ret_val = nvm->ops.acquire(hw);
349 if (ret_val)
350 goto out;
351
352 ret_val = igb_ready_nvm_eeprom(hw);
353 if (ret_val)
354 goto release;
355
356 igb_standby_nvm(hw);
357
358 if ((nvm->address_bits == 8) && (offset >= 128))
359 read_opcode |= NVM_A8_OPCODE_SPI;
360
361 /* Send the READ command (opcode + addr) */
362 igb_shift_out_eec_bits(hw, read_opcode, nvm->opcode_bits);
363 igb_shift_out_eec_bits(hw, (u16)(offset*2), nvm->address_bits);
364
365 /*
366 * Read the data. SPI NVMs increment the address with each byte
367 * read and will roll over if reading beyond the end. This allows
368 * us to read the whole NVM from any offset
369 */
370 for (i = 0; i < words; i++) {
371 word_in = igb_shift_in_eec_bits(hw, 16);
372 data[i] = (word_in >> 8) | (word_in << 8);
373 }
374
375release:
376 nvm->ops.release(hw);
377
378out:
379 return ret_val;
380}
381
382/**
321 * igb_read_nvm_eerd - Reads EEPROM using EERD register 383 * igb_read_nvm_eerd - Reads EEPROM using EERD register
322 * @hw: pointer to the HW structure 384 * @hw: pointer to the HW structure
323 * @offset: offset of word in the EEPROM to read 385 * @offset: offset of word in the EEPROM to read
@@ -353,7 +415,7 @@ s32 igb_read_nvm_eerd(struct e1000_hw *hw, u16 offset, u16 words, u16 *data)
353 break; 415 break;
354 416
355 data[i] = (rd32(E1000_EERD) >> 417 data[i] = (rd32(E1000_EERD) >>
356 E1000_NVM_RW_REG_DATA); 418 E1000_NVM_RW_REG_DATA);
357 } 419 }
358 420
359out: 421out:
diff --git a/drivers/net/igb/e1000_nvm.h b/drivers/net/igb/e1000_nvm.h
index 29c956a84bd0..7f43564c4bcc 100644
--- a/drivers/net/igb/e1000_nvm.h
+++ b/drivers/net/igb/e1000_nvm.h
@@ -35,6 +35,7 @@ s32 igb_read_part_num(struct e1000_hw *hw, u32 *part_num);
35s32 igb_read_part_string(struct e1000_hw *hw, u8 *part_num, 35s32 igb_read_part_string(struct e1000_hw *hw, u8 *part_num,
36 u32 part_num_size); 36 u32 part_num_size);
37s32 igb_read_nvm_eerd(struct e1000_hw *hw, u16 offset, u16 words, u16 *data); 37s32 igb_read_nvm_eerd(struct e1000_hw *hw, u16 offset, u16 words, u16 *data);
38s32 igb_read_nvm_spi(struct e1000_hw *hw, u16 offset, u16 words, u16 *data);
38s32 igb_write_nvm_spi(struct e1000_hw *hw, u16 offset, u16 words, u16 *data); 39s32 igb_write_nvm_spi(struct e1000_hw *hw, u16 offset, u16 words, u16 *data);
39s32 igb_validate_nvm_checksum(struct e1000_hw *hw); 40s32 igb_validate_nvm_checksum(struct e1000_hw *hw);
40s32 igb_update_nvm_checksum(struct e1000_hw *hw); 41s32 igb_update_nvm_checksum(struct e1000_hw *hw);
diff --git a/drivers/net/igb/e1000_regs.h b/drivers/net/igb/e1000_regs.h
index 8ac83c5190d5..958ca3bda482 100644
--- a/drivers/net/igb/e1000_regs.h
+++ b/drivers/net/igb/e1000_regs.h
@@ -106,6 +106,19 @@
106 106
107#define E1000_RQDPC(_n) (0x0C030 + ((_n) * 0x40)) 107#define E1000_RQDPC(_n) (0x0C030 + ((_n) * 0x40))
108 108
109/* DMA Coalescing registers */
110#define E1000_DMACR 0x02508 /* Control Register */
111#define E1000_DMCTXTH 0x03550 /* Transmit Threshold */
112#define E1000_DMCTLX 0x02514 /* Time to Lx Request */
113#define E1000_DMCRTRH 0x05DD0 /* Receive Packet Rate Threshold */
114#define E1000_DMCCNT 0x05DD4 /* Current Rx Count */
115#define E1000_FCRTC 0x02170 /* Flow Control Rx high watermark */
116#define E1000_PCIEMISC 0x05BB8 /* PCIE misc config register */
117
118/* TX Rate Limit Registers */
119#define E1000_RTTDQSEL 0x3604 /* Tx Desc Plane Queue Select - WO */
120#define E1000_RTTBCNRC 0x36B0 /* Tx BCN Rate-Scheduler Config - WO */
121
109/* Split and Replication RX Control - RW */ 122/* Split and Replication RX Control - RW */
110#define E1000_RXPBS 0x02404 /* Rx Packet Buffer Size - RW */ 123#define E1000_RXPBS 0x02404 /* Rx Packet Buffer Size - RW */
111/* 124/*
@@ -324,4 +337,18 @@
324 337
325/* DMA Coalescing registers */ 338/* DMA Coalescing registers */
326#define E1000_PCIEMISC 0x05BB8 /* PCIE misc config register */ 339#define E1000_PCIEMISC 0x05BB8 /* PCIE misc config register */
340
341/* Energy Efficient Ethernet "EEE" register */
342#define E1000_IPCNFG 0x0E38 /* Internal PHY Configuration */
343#define E1000_EEER 0x0E30 /* Energy Efficient Ethernet */
344
345/* Thermal Sensor Register */
346#define E1000_THSTAT 0x08110 /* Thermal Sensor Status */
347
348/* OS2BMC Registers */
349#define E1000_B2OSPC 0x08FE0 /* BMC2OS packets sent by BMC */
350#define E1000_B2OGPRC 0x04158 /* BMC2OS packets received by host */
351#define E1000_O2BGPTC 0x08FE4 /* OS2BMC packets received by BMC */
352#define E1000_O2BSPC 0x0415C /* OS2BMC packets transmitted by host */
353
327#endif 354#endif
diff --git a/drivers/net/igb/igb.h b/drivers/net/igb/igb.h
index 92a4ef09e55c..1c687e298d5e 100644
--- a/drivers/net/igb/igb.h
+++ b/drivers/net/igb/igb.h
@@ -77,6 +77,7 @@ struct vf_data_storage {
77 unsigned long last_nack; 77 unsigned long last_nack;
78 u16 pf_vlan; /* When set, guest VLAN config not allowed. */ 78 u16 pf_vlan; /* When set, guest VLAN config not allowed. */
79 u16 pf_qos; 79 u16 pf_qos;
80 u16 tx_rate;
80}; 81};
81 82
82#define IGB_VF_FLAG_CTS 0x00000001 /* VF is clear to send data */ 83#define IGB_VF_FLAG_CTS 0x00000001 /* VF is clear to send data */
@@ -323,6 +324,7 @@ struct igb_adapter {
323 u16 rx_ring_count; 324 u16 rx_ring_count;
324 unsigned int vfs_allocated_count; 325 unsigned int vfs_allocated_count;
325 struct vf_data_storage *vf_data; 326 struct vf_data_storage *vf_data;
327 int vf_rate_link_speed;
326 u32 rss_queues; 328 u32 rss_queues;
327 u32 wvbr; 329 u32 wvbr;
328}; 330};
@@ -331,6 +333,12 @@ struct igb_adapter {
331#define IGB_FLAG_DCA_ENABLED (1 << 1) 333#define IGB_FLAG_DCA_ENABLED (1 << 1)
332#define IGB_FLAG_QUAD_PORT_A (1 << 2) 334#define IGB_FLAG_QUAD_PORT_A (1 << 2)
333#define IGB_FLAG_QUEUE_PAIRS (1 << 3) 335#define IGB_FLAG_QUEUE_PAIRS (1 << 3)
336#define IGB_FLAG_DMAC (1 << 4)
337
338/* DMA Coalescing defines */
339#define IGB_MIN_TXPBSIZE 20408
340#define IGB_TX_BUF_4096 4096
341#define IGB_DMCTLX_DCFLUSH_DIS 0x80000000 /* Disable DMA Coal Flush */
334 342
335#define IGB_82576_TSYNC_SHIFT 19 343#define IGB_82576_TSYNC_SHIFT 19
336#define IGB_82580_TSYNC_SHIFT 24 344#define IGB_82580_TSYNC_SHIFT 24
diff --git a/drivers/net/igb/igb_ethtool.c b/drivers/net/igb/igb_ethtool.c
index a70e16bcfa7e..d976733bbcc2 100644
--- a/drivers/net/igb/igb_ethtool.c
+++ b/drivers/net/igb/igb_ethtool.c
@@ -86,6 +86,10 @@ static const struct igb_stats igb_gstrings_stats[] = {
86 IGB_STAT("tx_smbus", stats.mgptc), 86 IGB_STAT("tx_smbus", stats.mgptc),
87 IGB_STAT("rx_smbus", stats.mgprc), 87 IGB_STAT("rx_smbus", stats.mgprc),
88 IGB_STAT("dropped_smbus", stats.mgpdc), 88 IGB_STAT("dropped_smbus", stats.mgpdc),
89 IGB_STAT("os2bmc_rx_by_bmc", stats.o2bgptc),
90 IGB_STAT("os2bmc_tx_by_bmc", stats.b2ospc),
91 IGB_STAT("os2bmc_tx_by_host", stats.o2bspc),
92 IGB_STAT("os2bmc_rx_by_host", stats.b2ogprc),
89}; 93};
90 94
91#define IGB_NETDEV_STAT(_net_stat) { \ 95#define IGB_NETDEV_STAT(_net_stat) { \
@@ -603,7 +607,10 @@ static void igb_get_regs(struct net_device *netdev,
603 regs_buff[548] = rd32(E1000_TDFT); 607 regs_buff[548] = rd32(E1000_TDFT);
604 regs_buff[549] = rd32(E1000_TDFHS); 608 regs_buff[549] = rd32(E1000_TDFHS);
605 regs_buff[550] = rd32(E1000_TDFPC); 609 regs_buff[550] = rd32(E1000_TDFPC);
606 610 regs_buff[551] = adapter->stats.o2bgptc;
611 regs_buff[552] = adapter->stats.b2ospc;
612 regs_buff[553] = adapter->stats.o2bspc;
613 regs_buff[554] = adapter->stats.b2ogprc;
607} 614}
608 615
609static int igb_get_eeprom_len(struct net_device *netdev) 616static int igb_get_eeprom_len(struct net_device *netdev)
@@ -714,7 +721,7 @@ static int igb_set_eeprom(struct net_device *netdev,
714 /* Update the checksum over the first part of the EEPROM if needed 721 /* Update the checksum over the first part of the EEPROM if needed
715 * and flush shadow RAM for 82573 controllers */ 722 * and flush shadow RAM for 82573 controllers */
716 if ((ret_val == 0) && ((first_word <= NVM_CHECKSUM_REG))) 723 if ((ret_val == 0) && ((first_word <= NVM_CHECKSUM_REG)))
717 igb_update_nvm_checksum(hw); 724 hw->nvm.ops.update(hw);
718 725
719 kfree(eeprom_buff); 726 kfree(eeprom_buff);
720 return ret_val; 727 return ret_val;
@@ -727,8 +734,9 @@ static void igb_get_drvinfo(struct net_device *netdev,
727 char firmware_version[32]; 734 char firmware_version[32];
728 u16 eeprom_data; 735 u16 eeprom_data;
729 736
730 strncpy(drvinfo->driver, igb_driver_name, 32); 737 strncpy(drvinfo->driver, igb_driver_name, sizeof(drvinfo->driver) - 1);
731 strncpy(drvinfo->version, igb_driver_version, 32); 738 strncpy(drvinfo->version, igb_driver_version,
739 sizeof(drvinfo->version) - 1);
732 740
733 /* EEPROM image version # is reported as firmware version # for 741 /* EEPROM image version # is reported as firmware version # for
734 * 82575 controllers */ 742 * 82575 controllers */
@@ -738,8 +746,10 @@ static void igb_get_drvinfo(struct net_device *netdev,
738 (eeprom_data & 0x0FF0) >> 4, 746 (eeprom_data & 0x0FF0) >> 4,
739 eeprom_data & 0x000F); 747 eeprom_data & 0x000F);
740 748
741 strncpy(drvinfo->fw_version, firmware_version, 32); 749 strncpy(drvinfo->fw_version, firmware_version,
742 strncpy(drvinfo->bus_info, pci_name(adapter->pdev), 32); 750 sizeof(drvinfo->fw_version) - 1);
751 strncpy(drvinfo->bus_info, pci_name(adapter->pdev),
752 sizeof(drvinfo->bus_info) - 1);
743 drvinfo->n_stats = IGB_STATS_LEN; 753 drvinfo->n_stats = IGB_STATS_LEN;
744 drvinfo->testinfo_len = IGB_TEST_LEN; 754 drvinfo->testinfo_len = IGB_TEST_LEN;
745 drvinfo->regdump_len = igb_get_regs_len(netdev); 755 drvinfo->regdump_len = igb_get_regs_len(netdev);
@@ -1070,7 +1080,7 @@ static bool reg_pattern_test(struct igb_adapter *adapter, u64 *data,
1070 {0x5A5A5A5A, 0xA5A5A5A5, 0x00000000, 0xFFFFFFFF}; 1080 {0x5A5A5A5A, 0xA5A5A5A5, 0x00000000, 0xFFFFFFFF};
1071 for (pat = 0; pat < ARRAY_SIZE(_test); pat++) { 1081 for (pat = 0; pat < ARRAY_SIZE(_test); pat++) {
1072 wr32(reg, (_test[pat] & write)); 1082 wr32(reg, (_test[pat] & write));
1073 val = rd32(reg); 1083 val = rd32(reg) & mask;
1074 if (val != (_test[pat] & write & mask)) { 1084 if (val != (_test[pat] & write & mask)) {
1075 dev_err(&adapter->pdev->dev, "pattern test reg %04X " 1085 dev_err(&adapter->pdev->dev, "pattern test reg %04X "
1076 "failed: got 0x%08X expected 0x%08X\n", 1086 "failed: got 0x%08X expected 0x%08X\n",
@@ -1999,6 +2009,12 @@ static int igb_set_coalesce(struct net_device *netdev,
1999 if ((adapter->flags & IGB_FLAG_QUEUE_PAIRS) && ec->tx_coalesce_usecs) 2009 if ((adapter->flags & IGB_FLAG_QUEUE_PAIRS) && ec->tx_coalesce_usecs)
2000 return -EINVAL; 2010 return -EINVAL;
2001 2011
2012 /* If ITR is disabled, disable DMAC */
2013 if (ec->rx_coalesce_usecs == 0) {
2014 if (adapter->flags & IGB_FLAG_DMAC)
2015 adapter->flags &= ~IGB_FLAG_DMAC;
2016 }
2017
2002 /* convert to rate of irq's per second */ 2018 /* convert to rate of irq's per second */
2003 if (ec->rx_coalesce_usecs && ec->rx_coalesce_usecs <= 3) 2019 if (ec->rx_coalesce_usecs && ec->rx_coalesce_usecs <= 3)
2004 adapter->rx_itr_setting = ec->rx_coalesce_usecs; 2020 adapter->rx_itr_setting = ec->rx_coalesce_usecs;
diff --git a/drivers/net/igb/igb_main.c b/drivers/net/igb/igb_main.c
index 58c665b7513d..3d850af0cdda 100644
--- a/drivers/net/igb/igb_main.c
+++ b/drivers/net/igb/igb_main.c
@@ -50,12 +50,17 @@
50#endif 50#endif
51#include "igb.h" 51#include "igb.h"
52 52
53#define DRV_VERSION "2.1.0-k2" 53#define MAJ 3
54#define MIN 0
55#define BUILD 6
56#define KFIX 2
57#define DRV_VERSION __stringify(MAJ) "." __stringify(MIN) "." \
58__stringify(BUILD) "-k" __stringify(KFIX)
54char igb_driver_name[] = "igb"; 59char igb_driver_name[] = "igb";
55char igb_driver_version[] = DRV_VERSION; 60char igb_driver_version[] = DRV_VERSION;
56static const char igb_driver_string[] = 61static const char igb_driver_string[] =
57 "Intel(R) Gigabit Ethernet Network Driver"; 62 "Intel(R) Gigabit Ethernet Network Driver";
58static const char igb_copyright[] = "Copyright (c) 2007-2009 Intel Corporation."; 63static const char igb_copyright[] = "Copyright (c) 2007-2011 Intel Corporation.";
59 64
60static const struct e1000_info *igb_info_tbl[] = { 65static const struct e1000_info *igb_info_tbl[] = {
61 [board_82575] = &e1000_82575_info, 66 [board_82575] = &e1000_82575_info,
@@ -68,6 +73,7 @@ static DEFINE_PCI_DEVICE_TABLE(igb_pci_tbl) = {
68 { PCI_VDEVICE(INTEL, E1000_DEV_ID_I350_SGMII), board_82575 }, 73 { PCI_VDEVICE(INTEL, E1000_DEV_ID_I350_SGMII), board_82575 },
69 { PCI_VDEVICE(INTEL, E1000_DEV_ID_82580_COPPER), board_82575 }, 74 { PCI_VDEVICE(INTEL, E1000_DEV_ID_82580_COPPER), board_82575 },
70 { PCI_VDEVICE(INTEL, E1000_DEV_ID_82580_FIBER), board_82575 }, 75 { PCI_VDEVICE(INTEL, E1000_DEV_ID_82580_FIBER), board_82575 },
76 { PCI_VDEVICE(INTEL, E1000_DEV_ID_82580_QUAD_FIBER), board_82575 },
71 { PCI_VDEVICE(INTEL, E1000_DEV_ID_82580_SERDES), board_82575 }, 77 { PCI_VDEVICE(INTEL, E1000_DEV_ID_82580_SERDES), board_82575 },
72 { PCI_VDEVICE(INTEL, E1000_DEV_ID_82580_SGMII), board_82575 }, 78 { PCI_VDEVICE(INTEL, E1000_DEV_ID_82580_SGMII), board_82575 },
73 { PCI_VDEVICE(INTEL, E1000_DEV_ID_82580_COPPER_DUAL), board_82575 }, 79 { PCI_VDEVICE(INTEL, E1000_DEV_ID_82580_COPPER_DUAL), board_82575 },
@@ -100,6 +106,7 @@ static void igb_free_all_rx_resources(struct igb_adapter *);
100static void igb_setup_mrqc(struct igb_adapter *); 106static void igb_setup_mrqc(struct igb_adapter *);
101static int igb_probe(struct pci_dev *, const struct pci_device_id *); 107static int igb_probe(struct pci_dev *, const struct pci_device_id *);
102static void __devexit igb_remove(struct pci_dev *pdev); 108static void __devexit igb_remove(struct pci_dev *pdev);
109static void igb_init_hw_timer(struct igb_adapter *adapter);
103static int igb_sw_init(struct igb_adapter *); 110static int igb_sw_init(struct igb_adapter *);
104static int igb_open(struct net_device *); 111static int igb_open(struct net_device *);
105static int igb_close(struct net_device *); 112static int igb_close(struct net_device *);
@@ -149,6 +156,7 @@ static int igb_ndo_set_vf_vlan(struct net_device *netdev,
149static int igb_ndo_set_vf_bw(struct net_device *netdev, int vf, int tx_rate); 156static int igb_ndo_set_vf_bw(struct net_device *netdev, int vf, int tx_rate);
150static int igb_ndo_get_vf_config(struct net_device *netdev, int vf, 157static int igb_ndo_get_vf_config(struct net_device *netdev, int vf,
151 struct ifla_vf_info *ivi); 158 struct ifla_vf_info *ivi);
159static void igb_check_vf_rate_limit(struct igb_adapter *);
152 160
153#ifdef CONFIG_PM 161#ifdef CONFIG_PM
154static int igb_suspend(struct pci_dev *, pm_message_t); 162static int igb_suspend(struct pci_dev *, pm_message_t);
@@ -1672,7 +1680,58 @@ void igb_reset(struct igb_adapter *adapter)
1672 1680
1673 if (hw->mac.ops.init_hw(hw)) 1681 if (hw->mac.ops.init_hw(hw))
1674 dev_err(&pdev->dev, "Hardware Error\n"); 1682 dev_err(&pdev->dev, "Hardware Error\n");
1683 if (hw->mac.type > e1000_82580) {
1684 if (adapter->flags & IGB_FLAG_DMAC) {
1685 u32 reg;
1675 1686
1687 /*
1688 * DMA Coalescing high water mark needs to be higher
1689 * than * the * Rx threshold. The Rx threshold is
1690 * currently * pba - 6, so we * should use a high water
1691 * mark of pba * - 4. */
1692 hwm = (pba - 4) << 10;
1693
1694 reg = (((pba-6) << E1000_DMACR_DMACTHR_SHIFT)
1695 & E1000_DMACR_DMACTHR_MASK);
1696
1697 /* transition to L0x or L1 if available..*/
1698 reg |= (E1000_DMACR_DMAC_EN | E1000_DMACR_DMAC_LX_MASK);
1699
1700 /* watchdog timer= +-1000 usec in 32usec intervals */
1701 reg |= (1000 >> 5);
1702 wr32(E1000_DMACR, reg);
1703
1704 /* no lower threshold to disable coalescing(smart fifb)
1705 * -UTRESH=0*/
1706 wr32(E1000_DMCRTRH, 0);
1707
1708 /* set hwm to PBA - 2 * max frame size */
1709 wr32(E1000_FCRTC, hwm);
1710
1711 /*
1712 * This sets the time to wait before requesting tran-
1713 * sition to * low power state to number of usecs needed
1714 * to receive 1 512 * byte frame at gigabit line rate
1715 */
1716 reg = rd32(E1000_DMCTLX);
1717 reg |= IGB_DMCTLX_DCFLUSH_DIS;
1718
1719 /* Delay 255 usec before entering Lx state. */
1720 reg |= 0xFF;
1721 wr32(E1000_DMCTLX, reg);
1722
1723 /* free space in Tx packet buffer to wake from DMAC */
1724 wr32(E1000_DMCTXTH,
1725 (IGB_MIN_TXPBSIZE -
1726 (IGB_TX_BUF_4096 + adapter->max_frame_size))
1727 >> 6);
1728
1729 /* make low power state decision controlled by DMAC */
1730 reg = rd32(E1000_PCIEMISC);
1731 reg |= E1000_PCIEMISC_LX_DECISION;
1732 wr32(E1000_PCIEMISC, reg);
1733 } /* end if IGB_FLAG_DMAC set */
1734 }
1676 if (hw->mac.type == e1000_82580) { 1735 if (hw->mac.type == e1000_82580) {
1677 u32 reg = rd32(E1000_PCIEMISC); 1736 u32 reg = rd32(E1000_PCIEMISC);
1678 wr32(E1000_PCIEMISC, 1737 wr32(E1000_PCIEMISC,
@@ -1882,7 +1941,7 @@ static int __devinit igb_probe(struct pci_dev *pdev,
1882 hw->mac.ops.reset_hw(hw); 1941 hw->mac.ops.reset_hw(hw);
1883 1942
1884 /* make sure the NVM is good */ 1943 /* make sure the NVM is good */
1885 if (igb_validate_nvm_checksum(hw) < 0) { 1944 if (hw->nvm.ops.validate(hw) < 0) {
1886 dev_err(&pdev->dev, "The NVM Checksum Is Not Valid\n"); 1945 dev_err(&pdev->dev, "The NVM Checksum Is Not Valid\n");
1887 err = -EIO; 1946 err = -EIO;
1888 goto err_eeprom; 1947 goto err_eeprom;
@@ -1990,6 +2049,9 @@ static int __devinit igb_probe(struct pci_dev *pdev,
1990 } 2049 }
1991 2050
1992#endif 2051#endif
2052 /* do hw tstamp init after resetting */
2053 igb_init_hw_timer(adapter);
2054
1993 dev_info(&pdev->dev, "Intel(R) Gigabit Ethernet Network Connection\n"); 2055 dev_info(&pdev->dev, "Intel(R) Gigabit Ethernet Network Connection\n");
1994 /* print bus type/speed/width info */ 2056 /* print bus type/speed/width info */
1995 dev_info(&pdev->dev, "%s: (PCIe:%s:%s) %pM\n", 2057 dev_info(&pdev->dev, "%s: (PCIe:%s:%s) %pM\n",
@@ -2012,7 +2074,13 @@ static int __devinit igb_probe(struct pci_dev *pdev,
2012 adapter->msix_entries ? "MSI-X" : 2074 adapter->msix_entries ? "MSI-X" :
2013 (adapter->flags & IGB_FLAG_HAS_MSI) ? "MSI" : "legacy", 2075 (adapter->flags & IGB_FLAG_HAS_MSI) ? "MSI" : "legacy",
2014 adapter->num_rx_queues, adapter->num_tx_queues); 2076 adapter->num_rx_queues, adapter->num_tx_queues);
2015 2077 switch (hw->mac.type) {
2078 case e1000_i350:
2079 igb_set_eee_i350(hw);
2080 break;
2081 default:
2082 break;
2083 }
2016 return 0; 2084 return 0;
2017 2085
2018err_register: 2086err_register:
@@ -2149,6 +2217,9 @@ static void __devinit igb_probe_vfs(struct igb_adapter * adapter)
2149 random_ether_addr(mac_addr); 2217 random_ether_addr(mac_addr);
2150 igb_set_vf_mac(adapter, i, mac_addr); 2218 igb_set_vf_mac(adapter, i, mac_addr);
2151 } 2219 }
2220 /* DMA Coalescing is not supported in IOV mode. */
2221 if (adapter->flags & IGB_FLAG_DMAC)
2222 adapter->flags &= ~IGB_FLAG_DMAC;
2152 } 2223 }
2153#endif /* CONFIG_PCI_IOV */ 2224#endif /* CONFIG_PCI_IOV */
2154} 2225}
@@ -2286,9 +2357,19 @@ static int __devinit igb_sw_init(struct igb_adapter *adapter)
2286 2357
2287 spin_lock_init(&adapter->stats64_lock); 2358 spin_lock_init(&adapter->stats64_lock);
2288#ifdef CONFIG_PCI_IOV 2359#ifdef CONFIG_PCI_IOV
2289 if (hw->mac.type == e1000_82576) 2360 switch (hw->mac.type) {
2290 adapter->vfs_allocated_count = (max_vfs > 7) ? 7 : max_vfs; 2361 case e1000_82576:
2291 2362 case e1000_i350:
2363 if (max_vfs > 7) {
2364 dev_warn(&pdev->dev,
2365 "Maximum of 7 VFs per PF, using max\n");
2366 adapter->vfs_allocated_count = 7;
2367 } else
2368 adapter->vfs_allocated_count = max_vfs;
2369 break;
2370 default:
2371 break;
2372 }
2292#endif /* CONFIG_PCI_IOV */ 2373#endif /* CONFIG_PCI_IOV */
2293 adapter->rss_queues = min_t(u32, IGB_MAX_RX_QUEUES, num_online_cpus()); 2374 adapter->rss_queues = min_t(u32, IGB_MAX_RX_QUEUES, num_online_cpus());
2294 2375
@@ -2307,12 +2388,14 @@ static int __devinit igb_sw_init(struct igb_adapter *adapter)
2307 return -ENOMEM; 2388 return -ENOMEM;
2308 } 2389 }
2309 2390
2310 igb_init_hw_timer(adapter);
2311 igb_probe_vfs(adapter); 2391 igb_probe_vfs(adapter);
2312 2392
2313 /* Explicitly disable IRQ since the NIC can be in any state. */ 2393 /* Explicitly disable IRQ since the NIC can be in any state. */
2314 igb_irq_disable(adapter); 2394 igb_irq_disable(adapter);
2315 2395
2396 if (hw->mac.type == e1000_i350)
2397 adapter->flags &= ~IGB_FLAG_DMAC;
2398
2316 set_bit(__IGB_DOWN, &adapter->state); 2399 set_bit(__IGB_DOWN, &adapter->state);
2317 return 0; 2400 return 0;
2318} 2401}
@@ -3467,7 +3550,7 @@ static void igb_watchdog_task(struct work_struct *work)
3467 watchdog_task); 3550 watchdog_task);
3468 struct e1000_hw *hw = &adapter->hw; 3551 struct e1000_hw *hw = &adapter->hw;
3469 struct net_device *netdev = adapter->netdev; 3552 struct net_device *netdev = adapter->netdev;
3470 u32 link; 3553 u32 link, ctrl_ext, thstat;
3471 int i; 3554 int i;
3472 3555
3473 link = igb_has_link(adapter); 3556 link = igb_has_link(adapter);
@@ -3491,6 +3574,25 @@ static void igb_watchdog_task(struct work_struct *work)
3491 ((ctrl & E1000_CTRL_RFCE) ? "RX" : 3574 ((ctrl & E1000_CTRL_RFCE) ? "RX" :
3492 ((ctrl & E1000_CTRL_TFCE) ? "TX" : "None"))); 3575 ((ctrl & E1000_CTRL_TFCE) ? "TX" : "None")));
3493 3576
3577 /* check for thermal sensor event on i350,
3578 * copper only */
3579 if (hw->mac.type == e1000_i350) {
3580 thstat = rd32(E1000_THSTAT);
3581 ctrl_ext = rd32(E1000_CTRL_EXT);
3582 if ((hw->phy.media_type ==
3583 e1000_media_type_copper) && !(ctrl_ext &
3584 E1000_CTRL_EXT_LINK_MODE_SGMII)) {
3585 if (thstat &
3586 E1000_THSTAT_LINK_THROTTLE) {
3587 printk(KERN_INFO "igb: %s The "
3588 "network adapter link "
3589 "speed was downshifted "
3590 "because it "
3591 "overheated.\n",
3592 netdev->name);
3593 }
3594 }
3595 }
3494 /* adjust timeout factor according to speed/duplex */ 3596 /* adjust timeout factor according to speed/duplex */
3495 adapter->tx_timeout_factor = 1; 3597 adapter->tx_timeout_factor = 1;
3496 switch (adapter->link_speed) { 3598 switch (adapter->link_speed) {
@@ -3505,6 +3607,7 @@ static void igb_watchdog_task(struct work_struct *work)
3505 netif_carrier_on(netdev); 3607 netif_carrier_on(netdev);
3506 3608
3507 igb_ping_all_vfs(adapter); 3609 igb_ping_all_vfs(adapter);
3610 igb_check_vf_rate_limit(adapter);
3508 3611
3509 /* link state has changed, schedule phy info update */ 3612 /* link state has changed, schedule phy info update */
3510 if (!test_bit(__IGB_DOWN, &adapter->state)) 3613 if (!test_bit(__IGB_DOWN, &adapter->state))
@@ -3515,6 +3618,22 @@ static void igb_watchdog_task(struct work_struct *work)
3515 if (netif_carrier_ok(netdev)) { 3618 if (netif_carrier_ok(netdev)) {
3516 adapter->link_speed = 0; 3619 adapter->link_speed = 0;
3517 adapter->link_duplex = 0; 3620 adapter->link_duplex = 0;
3621 /* check for thermal sensor event on i350
3622 * copper only*/
3623 if (hw->mac.type == e1000_i350) {
3624 thstat = rd32(E1000_THSTAT);
3625 ctrl_ext = rd32(E1000_CTRL_EXT);
3626 if ((hw->phy.media_type ==
3627 e1000_media_type_copper) && !(ctrl_ext &
3628 E1000_CTRL_EXT_LINK_MODE_SGMII)) {
3629 if (thstat & E1000_THSTAT_PWR_DOWN) {
3630 printk(KERN_ERR "igb: %s The "
3631 "network adapter was stopped "
3632 "because it overheated.\n",
3633 netdev->name);
3634 }
3635 }
3636 }
3518 /* Links status message must follow this format */ 3637 /* Links status message must follow this format */
3519 printk(KERN_INFO "igb: %s NIC Link is Down\n", 3638 printk(KERN_INFO "igb: %s NIC Link is Down\n",
3520 netdev->name); 3639 netdev->name);
@@ -4547,6 +4666,15 @@ void igb_update_stats(struct igb_adapter *adapter,
4547 adapter->stats.mgptc += rd32(E1000_MGTPTC); 4666 adapter->stats.mgptc += rd32(E1000_MGTPTC);
4548 adapter->stats.mgprc += rd32(E1000_MGTPRC); 4667 adapter->stats.mgprc += rd32(E1000_MGTPRC);
4549 adapter->stats.mgpdc += rd32(E1000_MGTPDC); 4668 adapter->stats.mgpdc += rd32(E1000_MGTPDC);
4669
4670 /* OS2BMC Stats */
4671 reg = rd32(E1000_MANC);
4672 if (reg & E1000_MANC_EN_BMC2OS) {
4673 adapter->stats.o2bgptc += rd32(E1000_O2BGPTC);
4674 adapter->stats.o2bspc += rd32(E1000_O2BSPC);
4675 adapter->stats.b2ospc += rd32(E1000_B2OSPC);
4676 adapter->stats.b2ogprc += rd32(E1000_B2OGPRC);
4677 }
4550} 4678}
4551 4679
4552static irqreturn_t igb_msix_other(int irq, void *data) 4680static irqreturn_t igb_msix_other(int irq, void *data)
@@ -6593,9 +6721,91 @@ static int igb_ndo_set_vf_mac(struct net_device *netdev, int vf, u8 *mac)
6593 return igb_set_vf_mac(adapter, vf, mac); 6721 return igb_set_vf_mac(adapter, vf, mac);
6594} 6722}
6595 6723
6724static int igb_link_mbps(int internal_link_speed)
6725{
6726 switch (internal_link_speed) {
6727 case SPEED_100:
6728 return 100;
6729 case SPEED_1000:
6730 return 1000;
6731 default:
6732 return 0;
6733 }
6734}
6735
6736static void igb_set_vf_rate_limit(struct e1000_hw *hw, int vf, int tx_rate,
6737 int link_speed)
6738{
6739 int rf_dec, rf_int;
6740 u32 bcnrc_val;
6741
6742 if (tx_rate != 0) {
6743 /* Calculate the rate factor values to set */
6744 rf_int = link_speed / tx_rate;
6745 rf_dec = (link_speed - (rf_int * tx_rate));
6746 rf_dec = (rf_dec * (1<<E1000_RTTBCNRC_RF_INT_SHIFT)) / tx_rate;
6747
6748 bcnrc_val = E1000_RTTBCNRC_RS_ENA;
6749 bcnrc_val |= ((rf_int<<E1000_RTTBCNRC_RF_INT_SHIFT) &
6750 E1000_RTTBCNRC_RF_INT_MASK);
6751 bcnrc_val |= (rf_dec & E1000_RTTBCNRC_RF_DEC_MASK);
6752 } else {
6753 bcnrc_val = 0;
6754 }
6755
6756 wr32(E1000_RTTDQSEL, vf); /* vf X uses queue X */
6757 wr32(E1000_RTTBCNRC, bcnrc_val);
6758}
6759
6760static void igb_check_vf_rate_limit(struct igb_adapter *adapter)
6761{
6762 int actual_link_speed, i;
6763 bool reset_rate = false;
6764
6765 /* VF TX rate limit was not set or not supported */
6766 if ((adapter->vf_rate_link_speed == 0) ||
6767 (adapter->hw.mac.type != e1000_82576))
6768 return;
6769
6770 actual_link_speed = igb_link_mbps(adapter->link_speed);
6771 if (actual_link_speed != adapter->vf_rate_link_speed) {
6772 reset_rate = true;
6773 adapter->vf_rate_link_speed = 0;
6774 dev_info(&adapter->pdev->dev,
6775 "Link speed has been changed. VF Transmit "
6776 "rate is disabled\n");
6777 }
6778
6779 for (i = 0; i < adapter->vfs_allocated_count; i++) {
6780 if (reset_rate)
6781 adapter->vf_data[i].tx_rate = 0;
6782
6783 igb_set_vf_rate_limit(&adapter->hw, i,
6784 adapter->vf_data[i].tx_rate,
6785 actual_link_speed);
6786 }
6787}
6788
6596static int igb_ndo_set_vf_bw(struct net_device *netdev, int vf, int tx_rate) 6789static int igb_ndo_set_vf_bw(struct net_device *netdev, int vf, int tx_rate)
6597{ 6790{
6598 return -EOPNOTSUPP; 6791 struct igb_adapter *adapter = netdev_priv(netdev);
6792 struct e1000_hw *hw = &adapter->hw;
6793 int actual_link_speed;
6794
6795 if (hw->mac.type != e1000_82576)
6796 return -EOPNOTSUPP;
6797
6798 actual_link_speed = igb_link_mbps(adapter->link_speed);
6799 if ((vf >= adapter->vfs_allocated_count) ||
6800 (!(rd32(E1000_STATUS) & E1000_STATUS_LU)) ||
6801 (tx_rate < 0) || (tx_rate > actual_link_speed))
6802 return -EINVAL;
6803
6804 adapter->vf_rate_link_speed = actual_link_speed;
6805 adapter->vf_data[vf].tx_rate = (u16)tx_rate;
6806 igb_set_vf_rate_limit(hw, vf, tx_rate, actual_link_speed);
6807
6808 return 0;
6599} 6809}
6600 6810
6601static int igb_ndo_get_vf_config(struct net_device *netdev, 6811static int igb_ndo_get_vf_config(struct net_device *netdev,
@@ -6606,7 +6816,7 @@ static int igb_ndo_get_vf_config(struct net_device *netdev,
6606 return -EINVAL; 6816 return -EINVAL;
6607 ivi->vf = vf; 6817 ivi->vf = vf;
6608 memcpy(&ivi->mac, adapter->vf_data[vf].vf_mac_addresses, ETH_ALEN); 6818 memcpy(&ivi->mac, adapter->vf_data[vf].vf_mac_addresses, ETH_ALEN);
6609 ivi->tx_rate = 0; 6819 ivi->tx_rate = adapter->vf_data[vf].tx_rate;
6610 ivi->vlan = adapter->vf_data[vf].pf_vlan; 6820 ivi->vlan = adapter->vf_data[vf].pf_vlan;
6611 ivi->qos = adapter->vf_data[vf].pf_qos; 6821 ivi->qos = adapter->vf_data[vf].pf_qos;
6612 return 0; 6822 return 0;