Merge branch 'intel'
authorDavid S. Miller <davem@davemloft.net>
Mon, 28 Jan 2013 00:06:42 +0000 (19:06 -0500)
committerDavid S. Miller <davem@davemloft.net>
Mon, 28 Jan 2013 00:06:42 +0000 (19:06 -0500)
Jeff Kirsher says:

====================
This series contains updates to e1000e only.  All the updates come
from Bruce Allan and most of the patch fix or enable features on
i217/i218.  Most notably is patch 03 "e1000e: add support for IEEE-1588
PTP", which is v2 of the patch based on feedback from Stephen Hemminger.

Also patch 04 "e1000e: enable ECC on I217/I218 to catch packet buffer
memory errors" should be queued up for stable (as well as net) trees, but
the patch does not apply cleanly to either of those trees currently.
So I will work with Bruce to provide a version of the patch which will
apply cleanly to net (and stable) and we can queue it up at that point
for stable 3.5 tree.

The remaining patches are general cleanups of the code.
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
16 files changed:
drivers/net/ethernet/intel/Kconfig
drivers/net/ethernet/intel/e1000e/80003es2lan.c
drivers/net/ethernet/intel/e1000e/82571.c
drivers/net/ethernet/intel/e1000e/Makefile
drivers/net/ethernet/intel/e1000e/defines.h
drivers/net/ethernet/intel/e1000e/e1000.h
drivers/net/ethernet/intel/e1000e/ethtool.c
drivers/net/ethernet/intel/e1000e/hw.h
drivers/net/ethernet/intel/e1000e/ich8lan.c
drivers/net/ethernet/intel/e1000e/mac.c
drivers/net/ethernet/intel/e1000e/manage.c
drivers/net/ethernet/intel/e1000e/netdev.c
drivers/net/ethernet/intel/e1000e/nvm.c
drivers/net/ethernet/intel/e1000e/param.c
drivers/net/ethernet/intel/e1000e/phy.c
drivers/net/ethernet/intel/e1000e/ptp.c [new file with mode: 0644]

index 21353f0fef63ecf99384455a90b33399e43185e6..3d5f6d463757ff06d95a88d6fe13b22ec2ff7788 100644 (file)
@@ -74,6 +74,7 @@ config E1000E
        tristate "Intel(R) PRO/1000 PCI-Express Gigabit Ethernet support"
        depends on PCI && (!SPARC32 || BROKEN)
        select CRC32
+       select PTP_1588_CLOCK
        ---help---
          This driver supports the PCI-Express Intel(R) PRO/1000 gigabit
          ethernet family of adapters. For PCI or PCI-X e1000 adapters,
index e73c2c35599375a45bc253783df6cdfd2b91385d..ae96facee8fe96c0dd590e0cbc16d5afb8560d3f 100644 (file)
@@ -1,7 +1,7 @@
 /*******************************************************************************
 
   Intel PRO/1000 Linux driver
-  Copyright(c) 1999 - 2012 Intel Corporation.
+  Copyright(c) 1999 - 2013 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,
@@ -111,11 +111,10 @@ static void e1000_initialize_hw_bits_80003es2lan(struct e1000_hw *hw);
 static void e1000_clear_hw_cntrs_80003es2lan(struct e1000_hw *hw);
 static s32 e1000_cfg_kmrn_1000_80003es2lan(struct e1000_hw *hw);
 static s32 e1000_cfg_kmrn_10_100_80003es2lan(struct e1000_hw *hw, u16 duplex);
-static s32 e1000_cfg_on_link_up_80003es2lan(struct e1000_hw *hw);
-static s32  e1000_read_kmrn_reg_80003es2lan(struct e1000_hw *hw, u32 offset,
-                                            u16 *data);
-static s32  e1000_write_kmrn_reg_80003es2lan(struct e1000_hw *hw, u32 offset,
-                                             u16 data);
+static s32 e1000_read_kmrn_reg_80003es2lan(struct e1000_hw *hw, u32 offset,
+                                          u16 *data);
+static s32 e1000_write_kmrn_reg_80003es2lan(struct e1000_hw *hw, u32 offset,
+                                           u16 data);
 static void e1000_power_down_phy_copper_80003es2lan(struct e1000_hw *hw);
 
 /**
@@ -696,7 +695,7 @@ static s32 e1000_phy_force_speed_duplex_80003es2lan(struct e1000_hw *hw)
 static s32 e1000_get_cable_length_80003es2lan(struct e1000_hw *hw)
 {
        struct e1000_phy_info *phy = &hw->phy;
-       s32 ret_val = 0;
+       s32 ret_val;
        u16 phy_data, index;
 
        ret_val = e1e_rphy(hw, GG82563_PHY_DSP_DISTANCE, &phy_data);
@@ -774,6 +773,9 @@ static s32 e1000_reset_hw_80003es2lan(struct e1000_hw *hw)
        ctrl = er32(CTRL);
 
        ret_val = e1000_acquire_phy_80003es2lan(hw);
+       if (ret_val)
+               return ret_val;
+
        e_dbg("Issuing a global reset to MAC\n");
        ew32(CTRL, ctrl | E1000_CTRL_RST);
        e1000_release_phy_80003es2lan(hw);
@@ -833,6 +835,8 @@ static s32 e1000_init_hw_80003es2lan(struct e1000_hw *hw)
 
        /* Setup link and flow control */
        ret_val = mac->ops.setup_link(hw);
+       if (ret_val)
+               return ret_val;
 
        /* Disable IBIST slave mode (far-end loopback) */
        e1000_read_kmrn_reg_80003es2lan(hw, E1000_KMRNCTRLSTA_INBAND_PARAM,
@@ -1272,7 +1276,7 @@ static s32 e1000_read_kmrn_reg_80003es2lan(struct e1000_hw *hw, u32 offset,
                                           u16 *data)
 {
        u32 kmrnctrlsta;
-       s32 ret_val = 0;
+       s32 ret_val;
 
        ret_val = e1000_acquire_mac_csr_80003es2lan(hw);
        if (ret_val)
@@ -1307,7 +1311,7 @@ static s32 e1000_write_kmrn_reg_80003es2lan(struct e1000_hw *hw, u32 offset,
                                            u16 data)
 {
        u32 kmrnctrlsta;
-       s32 ret_val = 0;
+       s32 ret_val;
 
        ret_val = e1000_acquire_mac_csr_80003es2lan(hw);
        if (ret_val)
@@ -1331,7 +1335,7 @@ static s32 e1000_write_kmrn_reg_80003es2lan(struct e1000_hw *hw, u32 offset,
  **/
 static s32 e1000_read_mac_addr_80003es2lan(struct e1000_hw *hw)
 {
-       s32 ret_val = 0;
+       s32 ret_val;
 
        /* If there's an alternate MAC address place it in RAR0
         * so that it will override the Si installed default perm
index 587890d2d55e35b46f010b3e56adab48b963cf67..0f55d79afe39f394e6ee9b903eca3251fc08fd6b 100644 (file)
@@ -1,7 +1,7 @@
 /*******************************************************************************
 
   Intel PRO/1000 Linux driver
-  Copyright(c) 1999 - 2012 Intel Corporation.
+  Copyright(c) 1999 - 2013 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,
@@ -67,9 +67,7 @@ static s32 e1000_write_nvm_eewr_82571(struct e1000_hw *hw, u16 offset,
                                      u16 words, u16 *data);
 static s32 e1000_fix_nvm_checksum_82571(struct e1000_hw *hw);
 static void e1000_initialize_hw_bits_82571(struct e1000_hw *hw);
-static s32 e1000_setup_link_82571(struct e1000_hw *hw);
 static void e1000_clear_hw_cntrs_82571(struct e1000_hw *hw);
-static void e1000_clear_vfta_82571(struct e1000_hw *hw);
 static bool e1000_check_mng_mode_82574(struct e1000_hw *hw);
 static s32 e1000_led_on_82574(struct e1000_hw *hw);
 static void e1000_put_hw_semaphore_82571(struct e1000_hw *hw);
@@ -556,16 +554,14 @@ static s32 e1000_get_hw_semaphore_82573(struct e1000_hw *hw)
        s32 i = 0;
 
        extcnf_ctrl = er32(EXTCNF_CTRL);
-       extcnf_ctrl |= E1000_EXTCNF_CTRL_MDIO_SW_OWNERSHIP;
        do {
+               extcnf_ctrl |= E1000_EXTCNF_CTRL_MDIO_SW_OWNERSHIP;
                ew32(EXTCNF_CTRL, extcnf_ctrl);
                extcnf_ctrl = er32(EXTCNF_CTRL);
 
                if (extcnf_ctrl & E1000_EXTCNF_CTRL_MDIO_SW_OWNERSHIP)
                        break;
 
-               extcnf_ctrl |= E1000_EXTCNF_CTRL_MDIO_SW_OWNERSHIP;
-
                usleep_range(2000, 4000);
                i++;
        } while (i < MDIO_OWNERSHIP_TIMEOUT);
@@ -937,6 +933,8 @@ static s32 e1000_set_d0_lplu_state_82571(struct e1000_hw *hw, bool active)
 
                /* When LPLU is enabled, we should disable SmartSpeed */
                ret_val = e1e_rphy(hw, IGP01E1000_PHY_PORT_CONFIG, &data);
+               if (ret_val)
+                       return ret_val;
                data &= ~IGP01E1000_PSCFR_SMART_SPEED;
                ret_val = e1e_wphy(hw, IGP01E1000_PHY_PORT_CONFIG, data);
                if (ret_val)
@@ -1399,7 +1397,7 @@ bool e1000_check_phy_82574(struct e1000_hw *hw)
 {
        u16 status_1kbt = 0;
        u16 receive_errors = 0;
-       s32 ret_val = 0;
+       s32 ret_val;
 
        /* Read PHY Receive Error counter first, if its is max - all F's then
         * read the Base1000T status register If both are max then PHY is hung.
@@ -1544,7 +1542,7 @@ static s32 e1000_check_for_serdes_link_82571(struct e1000_hw *hw)
 
        ctrl = er32(CTRL);
        status = er32(STATUS);
-       rxcw = er32(RXCW);
+       er32(RXCW);
        /* SYNCH bit and IV bit are sticky */
        udelay(10);
        rxcw = er32(RXCW);
@@ -1799,6 +1797,8 @@ static s32 e1000_fix_nvm_checksum_82571(struct e1000_hw *hw)
                        if (ret_val)
                                return ret_val;
                        ret_val = e1000e_update_nvm_checksum(hw);
+                       if (ret_val)
+                               return ret_val;
                }
        }
 
@@ -1812,7 +1812,7 @@ static s32 e1000_fix_nvm_checksum_82571(struct e1000_hw *hw)
 static s32 e1000_read_mac_addr_82571(struct e1000_hw *hw)
 {
        if (hw->mac.type == e1000_82571) {
-               s32 ret_val = 0;
+               s32 ret_val;
 
                /* If there's an alternate MAC address place it in RAR0
                 * so that it will override the Si installed default perm
index 591b713245057fc4b2ae2fccf797665090ef972c..c2dcfcc10857fc17608194c0a4c09140f6606143 100644 (file)
@@ -1,7 +1,7 @@
 ################################################################################
 #
 # Intel PRO/1000 Linux driver
-# Copyright(c) 1999 - 2012 Intel Corporation.
+# Copyright(c) 1999 - 2013 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,
@@ -34,5 +34,5 @@ obj-$(CONFIG_E1000E) += e1000e.o
 
 e1000e-objs := 82571.o ich8lan.o 80003es2lan.o \
               mac.o manage.o nvm.o phy.o \
-              param.o ethtool.o netdev.o
+              param.o ethtool.o netdev.o ptp.o
 
index 36f9fad19a7649cb0d5a919219fcef631c8b1e96..3b997194ac3b9919a34d7105758a8e925493e18e 100644 (file)
@@ -1,7 +1,7 @@
 /*******************************************************************************
 
   Intel PRO/1000 Linux driver
-  Copyright(c) 1999 - 2012 Intel Corporation.
+  Copyright(c) 1999 - 2013 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,
 #define E1000_CTRL_FRCDPX   0x00001000  /* Force Duplex */
 #define E1000_CTRL_LANPHYPC_OVERRIDE 0x00010000 /* SW control of LANPHYPC */
 #define E1000_CTRL_LANPHYPC_VALUE    0x00020000 /* SW value of LANPHYPC */
+#define E1000_CTRL_MEHE     0x00080000  /* Memory Error Handling Enable */
 #define E1000_CTRL_SWDPIN0  0x00040000  /* SWDPIN 0 value */
 #define E1000_CTRL_SWDPIN1  0x00080000  /* SWDPIN 1 value */
 #define E1000_CTRL_SWDPIO0  0x00400000  /* SWDPIN 0 Input or output */
 
 #define E1000_PBS_16K E1000_PBA_16K
 
+/* Uncorrectable/correctable ECC Error counts and enable bits */
+#define E1000_PBECCSTS_CORR_ERR_CNT_MASK       0x000000FF
+#define E1000_PBECCSTS_UNCORR_ERR_CNT_MASK     0x0000FF00
+#define E1000_PBECCSTS_UNCORR_ERR_CNT_SHIFT    8
+#define E1000_PBECCSTS_ECC_ENABLE              0x00010000
+
 #define IFS_MAX       80
 #define IFS_MIN       40
 #define IFS_RATIO     4
 #define E1000_ICR_RXSEQ         0x00000008 /* Rx sequence error */
 #define E1000_ICR_RXDMT0        0x00000010 /* Rx desc min. threshold (0) */
 #define E1000_ICR_RXT0          0x00000080 /* Rx timer intr (ring 0) */
+#define E1000_ICR_ECCER         0x00400000 /* Uncorrectable ECC Error */
 #define E1000_ICR_INT_ASSERTED  0x80000000 /* If this bit asserted, the driver should claim the interrupt */
 #define E1000_ICR_RXQ0          0x00100000 /* Rx Queue 0 Interrupt */
 #define E1000_ICR_RXQ1          0x00200000 /* Rx Queue 1 Interrupt */
 #define E1000_IMS_RXSEQ     E1000_ICR_RXSEQ     /* Rx sequence error */
 #define E1000_IMS_RXDMT0    E1000_ICR_RXDMT0    /* Rx desc min. threshold */
 #define E1000_IMS_RXT0      E1000_ICR_RXT0      /* Rx timer intr */
+#define E1000_IMS_ECCER     E1000_ICR_ECCER     /* Uncorrectable ECC Error */
 #define E1000_IMS_RXQ0      E1000_ICR_RXQ0      /* Rx Queue 0 Interrupt */
 #define E1000_IMS_RXQ1      E1000_ICR_RXQ1      /* Rx Queue 1 Interrupt */
 #define E1000_IMS_TXQ0      E1000_ICR_TXQ0      /* Tx Queue 0 Interrupt */
 
 #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_TSYNCRXCTL_SYSCFI                0x00000020 /* Sys clock frequency */
 
+#define E1000_RXMTRL_PTP_V1_SYNC_MESSAGE       0x00000000
+#define E1000_RXMTRL_PTP_V1_DELAY_REQ_MESSAGE  0x00010000
+
+#define E1000_RXMTRL_PTP_V2_SYNC_MESSAGE       0x00000000
+#define E1000_RXMTRL_PTP_V2_DELAY_REQ_MESSAGE  0x01000000
+
 #define E1000_TIMINCA_INCPERIOD_SHIFT  24
 #define E1000_TIMINCA_INCVALUE_MASK    0x00FFFFFF
 
index dea9e5552966868de6bed6c28cedac656d9dfc04..e6b94835291efc4b16a88b9da7d6a5fbfca21a38 100644 (file)
@@ -1,7 +1,7 @@
 /*******************************************************************************
 
   Intel PRO/1000 Linux driver
-  Copyright(c) 1999 - 2012 Intel Corporation.
+  Copyright(c) 1999 - 2013 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,
@@ -43,7 +43,8 @@
 #include <linux/if_vlan.h>
 #include <linux/clocksource.h>
 #include <linux/net_tstamp.h>
-
+#include <linux/ptp_clock_kernel.h>
+#include <linux/ptp_classify.h>
 #include "hw.h"
 
 struct e1000_info;
@@ -311,6 +312,8 @@ struct e1000_adapter {
 
        struct napi_struct napi;
 
+       unsigned int uncorr_errors;     /* uncorrectable ECC errors */
+       unsigned int corr_errors;       /* correctable ECC errors */
        unsigned int restart_queue;
        u32 txd_cmd;
 
@@ -369,7 +372,7 @@ struct e1000_adapter {
        /* structs defined in e1000_hw.h */
        struct e1000_hw hw;
 
-       spinlock_t stats64_lock;
+       spinlock_t stats64_lock;        /* protects statistics counters */
        struct e1000_hw_stats stats;
        struct e1000_phy_info phy_info;
        struct e1000_phy_stats phy_stats;
@@ -413,6 +416,8 @@ struct e1000_adapter {
        spinlock_t systim_lock; /* protects SYSTIML/H regsters */
        struct cyclecounter cc;
        struct timecounter tc;
+       struct ptp_clock *ptp_clock;
+       struct ptp_clock_info ptp_clock_info;
 };
 
 struct e1000_info {
@@ -427,6 +432,8 @@ struct e1000_info {
        const struct e1000_nvm_operations *nvm_ops;
 };
 
+s32 e1000e_get_base_timinca(struct e1000_adapter *adapter, u32 *timinca);
+
 /* The system time is maintained by a 64-bit counter comprised of the 32-bit
  * SYSTIMH and SYSTIML registers.  How the counter increments (and therefore
  * its resolution) is based on the contents of the TIMINCA register - it
@@ -556,8 +563,6 @@ extern void e1000e_write_itr(struct e1000_adapter *adapter, u32 itr);
 
 extern unsigned int copybreak;
 
-extern char *e1000e_get_hw_dev_name(struct e1000_hw *hw);
-
 extern const struct e1000_info e1000_82571_info;
 extern const struct e1000_info e1000_82572_info;
 extern const struct e1000_info e1000_82573_info;
@@ -704,6 +709,8 @@ extern s32 e1000_phy_force_speed_duplex_ife(struct e1000_hw *hw);
 extern s32 e1000_check_polarity_igp(struct e1000_hw *hw);
 extern bool e1000_check_phy_82574(struct e1000_hw *hw);
 extern s32 e1000_read_emi_reg_locked(struct e1000_hw *hw, u16 addr, u16 *data);
+extern void e1000e_ptp_init(struct e1000_adapter *adapter);
+extern void e1000e_ptp_remove(struct e1000_adapter *adapter);
 
 static inline s32 e1000_phy_hw_reset(struct e1000_hw *hw)
 {
index f268cbcb751d93a3e55b6ea1296d6cb053073567..6ab949d0b39b9a0d461cf61096f723e835696c1a 100644 (file)
@@ -1,7 +1,7 @@
 /*******************************************************************************
 
   Intel PRO/1000 Linux driver
-  Copyright(c) 1999 - 2012 Intel Corporation.
+  Copyright(c) 1999 - 2013 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,
@@ -109,6 +109,8 @@ static const struct e1000_stats e1000_gstrings_stats[] = {
        E1000_STAT("rx_dma_failed", rx_dma_failed),
        E1000_STAT("tx_dma_failed", tx_dma_failed),
        E1000_STAT("rx_hwtstamp_cleared", rx_hwtstamp_cleared),
+       E1000_STAT("uncorr_ecc_errors", uncorr_errors),
+       E1000_STAT("corr_ecc_errors", corr_errors),
 };
 
 #define E1000_GLOBAL_STATS_LEN ARRAY_SIZE(e1000_gstrings_stats)
@@ -760,8 +762,9 @@ static bool reg_pattern_test(struct e1000_adapter *adapter, u64 *data,
                                      (test[pat] & write));
                val = E1000_READ_REG_ARRAY(&adapter->hw, reg, offset);
                if (val != (test[pat] & write & mask)) {
-                       e_err("pattern test reg %04X failed: got 0x%08X expected 0x%08X\n",
-                             reg + offset, val, (test[pat] & write & mask));
+                       e_err("pattern test failed (reg 0x%05X): got 0x%08X expected 0x%08X\n",
+                             reg + (offset << 2), val,
+                             (test[pat] & write & mask));
                        *data = reg;
                        return 1;
                }
@@ -776,7 +779,7 @@ static bool reg_set_and_check(struct e1000_adapter *adapter, u64 *data,
        __ew32(&adapter->hw, reg, write & mask);
        val = __er32(&adapter->hw, reg);
        if ((write & mask) != (val & mask)) {
-               e_err("set/check reg %04X test failed: got 0x%08X expected 0x%08X\n",
+               e_err("set/check test failed (reg 0x%05X): got 0x%08X expected 0x%08X\n",
                      reg, (val & mask), (write & mask));
                *data = reg;
                return 1;
@@ -884,12 +887,20 @@ static int e1000_reg_test(struct e1000_adapter *adapter, u64 *data)
                    E1000_FWSM_WLOCK_MAC_SHIFT;
 
        for (i = 0; i < mac->rar_entry_count; i++) {
-               /* Cannot test write-protected SHRAL[n] registers */
-               if ((wlock_mac == 1) || (wlock_mac && (i > wlock_mac)))
-                       continue;
+               if (mac->type == e1000_pch_lpt) {
+                       /* Cannot test write-protected SHRAL[n] registers */
+                       if ((wlock_mac == 1) || (wlock_mac && (i > wlock_mac)))
+                               continue;
+
+                       /* SHRAH[9] different than the others */
+                       if (i == 10)
+                               mask |= (1 << 30);
+                       else
+                               mask &= ~(1 << 30);
+               }
 
-               REG_PATTERN_TEST_ARRAY(E1000_RA, ((i << 1) + 1),
-                                      mask, 0xFFFFFFFF);
+               REG_PATTERN_TEST_ARRAY(E1000_RA, ((i << 1) + 1), mask,
+                                      0xFFFFFFFF);
        }
 
        for (i = 0; i < mac->mta_reg_count; i++)
@@ -1394,7 +1405,7 @@ static int e1000_set_82571_fiber_loopback(struct e1000_adapter *adapter)
 {
        struct e1000_hw *hw = &adapter->hw;
        u32 ctrl = er32(CTRL);
-       int link = 0;
+       int link;
 
        /* special requirements for 82571/82572 fiber adapters */
 
@@ -2200,8 +2211,20 @@ static int e1000e_get_ts_info(struct net_device *netdev,
        info->tx_types = (1 << HWTSTAMP_TX_OFF) | (1 << HWTSTAMP_TX_ON);
 
        info->rx_filters = ((1 << HWTSTAMP_FILTER_NONE) |
+                           (1 << HWTSTAMP_FILTER_PTP_V1_L4_SYNC) |
+                           (1 << HWTSTAMP_FILTER_PTP_V1_L4_DELAY_REQ) |
+                           (1 << HWTSTAMP_FILTER_PTP_V2_L4_SYNC) |
+                           (1 << HWTSTAMP_FILTER_PTP_V2_L4_DELAY_REQ) |
+                           (1 << HWTSTAMP_FILTER_PTP_V2_L2_SYNC) |
+                           (1 << HWTSTAMP_FILTER_PTP_V2_L2_DELAY_REQ) |
+                           (1 << HWTSTAMP_FILTER_PTP_V2_EVENT) |
+                           (1 << HWTSTAMP_FILTER_PTP_V2_SYNC) |
+                           (1 << HWTSTAMP_FILTER_PTP_V2_DELAY_REQ) |
                            (1 << HWTSTAMP_FILTER_ALL));
 
+       if (adapter->ptp_clock)
+               info->phc_index = ptp_clock_index(adapter->ptp_clock);
+
        return 0;
 }
 
index 8e7e80345a601534c33129a24d85566a2128b34a..a10de4d122cc6b80eb82874bae73abf396d0bdde 100644 (file)
@@ -1,7 +1,7 @@
 /*******************************************************************************
 
   Intel PRO/1000 Linux driver
-  Copyright(c) 1999 - 2012 Intel Corporation.
+  Copyright(c) 1999 - 2013 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,
@@ -79,6 +79,7 @@ enum e1e_registers {
 #define E1000_POEMB    E1000_PHY_CTRL  /* PHY OEM Bits */
        E1000_PBA      = 0x01000, /* Packet Buffer Allocation - RW */
        E1000_PBS      = 0x01008, /* Packet Buffer Size */
+       E1000_PBECCSTS = 0x0100C, /* Packet Buffer ECC Status - RW */
        E1000_EEMNGCTL = 0x01010, /* MNG EEprom Control */
        E1000_EEWR     = 0x0102C, /* EEPROM Write Register - RW */
        E1000_FLOP     = 0x0103C, /* FLASH Opcode Register */
@@ -251,6 +252,8 @@ enum e1e_registers {
        E1000_TSYNCRXCTL = 0x0B620, /* Rx Time Sync Control register - RW */
        E1000_RXSTMPL   = 0x0B624, /* Rx timestamp Low - RO */
        E1000_RXSTMPH   = 0x0B628, /* Rx timestamp High - RO */
+       E1000_RXMTRL    = 0x0B634, /* Timesync Rx EtherType and Msg Type - RW */
+       E1000_RXUDP     = 0x0B638, /* Timesync Rx UDP Port - RW */
 };
 
 #define E1000_MAX_PHY_ADDR             4
@@ -539,16 +542,6 @@ enum e1000_serdes_link_state {
        e1000_serdes_link_forced_up
 };
 
-/* Receive Descriptor */
-struct e1000_rx_desc {
-       __le64 buffer_addr; /* Address of the descriptor's data buffer */
-       __le16 length;      /* Length of data DMAed into data buffer */
-       __le16 csum;    /* Packet checksum */
-       u8  status;      /* Descriptor status */
-       u8  errors;      /* Descriptor Errors */
-       __le16 special;
-};
-
 /* Receive Descriptor - Extended */
 union e1000_rx_desc_extended {
        struct {
index 50935ef481713ca15ff69028b0ae30b688163495..87676b652edc3877a9b5223d1d00fdf7c6c70ff5 100644 (file)
@@ -1,7 +1,7 @@
 /*******************************************************************************
 
   Intel PRO/1000 Linux driver
-  Copyright(c) 1999 - 2012 Intel Corporation.
+  Copyright(c) 1999 - 2013 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,
@@ -237,7 +237,6 @@ union ich8_flash_protected_range {
        u32 regval;
 };
 
-static s32 e1000_setup_link_ich8lan(struct e1000_hw *hw);
 static void e1000_clear_hw_cntrs_ich8lan(struct e1000_hw *hw);
 static void e1000_initialize_hw_bits_ich8lan(struct e1000_hw *hw);
 static s32 e1000_erase_flash_bank_ich8lan(struct e1000_hw *hw, u32 bank);
@@ -249,9 +248,7 @@ static s32 e1000_read_flash_word_ich8lan(struct e1000_hw *hw, u32 offset,
                                         u16 *data);
 static s32 e1000_read_flash_data_ich8lan(struct e1000_hw *hw, u32 offset,
                                         u8 size, u16 *data);
-static s32 e1000_setup_copper_link_ich8lan(struct e1000_hw *hw);
 static s32 e1000_kmrn_lock_loss_workaround_ich8lan(struct e1000_hw *hw);
-static s32 e1000_get_cfg_done_ich8lan(struct e1000_hw *hw);
 static s32 e1000_cleanup_led_ich8lan(struct e1000_hw *hw);
 static s32 e1000_led_on_ich8lan(struct e1000_hw *hw);
 static s32 e1000_led_off_ich8lan(struct e1000_hw *hw);
@@ -263,7 +260,7 @@ static s32 e1000_led_off_pchlan(struct e1000_hw *hw);
 static s32 e1000_set_lplu_state_pchlan(struct e1000_hw *hw, bool active);
 static void e1000_power_down_phy_copper_ich8lan(struct e1000_hw *hw);
 static void e1000_lan_init_done_ich8lan(struct e1000_hw *hw);
-static s32  e1000_k1_gig_workaround_hv(struct e1000_hw *hw, bool link);
+static s32 e1000_k1_gig_workaround_hv(struct e1000_hw *hw, bool link);
 static s32 e1000_set_mdio_slow_mode_hv(struct e1000_hw *hw);
 static bool e1000_check_mng_mode_ich8lan(struct e1000_hw *hw);
 static bool e1000_check_mng_mode_pchlan(struct e1000_hw *hw);
@@ -363,10 +360,15 @@ static s32 e1000_init_phy_workarounds_pchlan(struct e1000_hw *hw)
        s32 ret_val;
        u16 phy_reg;
 
+       /* Gate automatic PHY configuration by hardware on managed and
+        * non-managed 82579 and newer adapters.
+        */
+       e1000_gate_hw_phy_config_ich8lan(hw, true);
+
        ret_val = hw->phy.ops.acquire(hw);
        if (ret_val) {
                e_dbg("Failed to initialize PHY flow\n");
-               return ret_val;
+               goto out;
        }
 
        /* The MAC-PHY interconnect may be in SMBus mode.  If the PHY is
@@ -387,13 +389,6 @@ static s32 e1000_init_phy_workarounds_pchlan(struct e1000_hw *hw)
 
                /* fall-through */
        case e1000_pch2lan:
-               /* Gate automatic PHY configuration by hardware on
-                * non-managed 82579
-                */
-               if ((hw->mac.type == e1000_pch2lan) &&
-                   !(fwsm & E1000_ICH_FWSM_FW_VALID))
-                       e1000_gate_hw_phy_config_ich8lan(hw, true);
-
                if (e1000_phy_is_accessible_pchlan(hw)) {
                        if (hw->mac.type == e1000_pch_lpt) {
                                /* Unforce SMBus mode in PHY */
@@ -428,6 +423,15 @@ static s32 e1000_init_phy_workarounds_pchlan(struct e1000_hw *hw)
                mac_reg |= E1000_FEXTNVM3_PHY_CFG_COUNTER_50MSEC;
                ew32(FEXTNVM3, mac_reg);
 
+               if (hw->mac.type == e1000_pch_lpt) {
+                       /* Toggling LANPHYPC brings the PHY out of SMBus mode
+                        * So ensure that the MAC is also out of SMBus mode
+                        */
+                       mac_reg = er32(CTRL_EXT);
+                       mac_reg &= ~E1000_CTRL_EXT_FORCE_SMBUS;
+                       ew32(CTRL_EXT, mac_reg);
+               }
+
                /* Toggle LANPHYPC Value bit */
                mac_reg = er32(CTRL);
                mac_reg |= E1000_CTRL_LANPHYPC_OVERRIDE;
@@ -461,6 +465,7 @@ static s32 e1000_init_phy_workarounds_pchlan(struct e1000_hw *hw)
         */
        ret_val = e1000e_phy_hw_reset_generic(hw);
 
+out:
        /* Ungate automatic PHY configuration on non-managed 82579 */
        if ((hw->mac.type == e1000_pch2lan) &&
            !(fwsm & E1000_ICH_FWSM_FW_VALID)) {
@@ -480,7 +485,7 @@ static s32 e1000_init_phy_workarounds_pchlan(struct e1000_hw *hw)
 static s32 e1000_init_phy_params_pchlan(struct e1000_hw *hw)
 {
        struct e1000_phy_info *phy = &hw->phy;
-       s32 ret_val = 0;
+       s32 ret_val;
 
        phy->addr                     = 1;
        phy->reset_delay_us           = 100;
@@ -763,13 +768,6 @@ static s32 e1000_init_mac_params_ich8lan(struct e1000_hw *hw)
        if (mac->type == e1000_ich8lan)
                e1000e_set_kmrn_lock_loss_workaround_ich8lan(hw, true);
 
-       /* Gate automatic PHY configuration by hardware on managed
-        * 82579 and i217
-        */
-       if ((mac->type == e1000_pch2lan || mac->type == e1000_pch_lpt) &&
-           (er32(FWSM) & E1000_ICH_FWSM_FW_VALID))
-               e1000_gate_hw_phy_config_ich8lan(hw, true);
-
        return 0;
 }
 
@@ -785,7 +783,7 @@ static s32 e1000_init_mac_params_ich8lan(struct e1000_hw *hw)
 static s32 __e1000_access_emi_reg_locked(struct e1000_hw *hw, u16 address,
                                         u16 *data, bool read)
 {
-       s32 ret_val = 0;
+       s32 ret_val;
 
        ret_val = e1e_wphy_locked(hw, I82579_EMI_ADDR, address);
        if (ret_val)
@@ -1389,7 +1387,7 @@ static s32 e1000_write_smbus_addr(struct e1000_hw *hw)
        u32 strap = er32(STRAP);
        u32 freq = (strap & E1000_STRAP_SMT_FREQ_MASK) >>
            E1000_STRAP_SMT_FREQ_SHIFT;
-       s32 ret_val = 0;
+       s32 ret_val;
 
        strap &= E1000_STRAP_SMBUS_ADDRESS_MASK;
 
@@ -1625,7 +1623,7 @@ release:
  **/
 s32 e1000_configure_k1_ich8lan(struct e1000_hw *hw, bool k1_enable)
 {
-       s32 ret_val = 0;
+       s32 ret_val;
        u32 ctrl_reg = 0;
        u32 ctrl_ext = 0;
        u32 reg = 0;
@@ -2286,7 +2284,7 @@ static s32 e1000_phy_hw_reset_ich8lan(struct e1000_hw *hw)
  **/
 static s32 e1000_set_lplu_state_pchlan(struct e1000_hw *hw, bool active)
 {
-       s32 ret_val = 0;
+       s32 ret_val;
        u16 oem_reg;
 
        ret_val = e1e_rphy(hw, HV_OEM_BITS, &oem_reg);
@@ -2344,6 +2342,8 @@ static s32 e1000_set_d0_lplu_state_ich8lan(struct e1000_hw *hw, bool active)
 
                /* When LPLU is enabled, we should disable SmartSpeed */
                ret_val = e1e_rphy(hw, IGP01E1000_PHY_PORT_CONFIG, &data);
+               if (ret_val)
+                       return ret_val;
                data &= ~IGP01E1000_PSCFR_SMART_SPEED;
                ret_val = e1e_wphy(hw, IGP01E1000_PHY_PORT_CONFIG, data);
                if (ret_val)
@@ -3704,6 +3704,17 @@ static void e1000_initialize_hw_bits_ich8lan(struct e1000_hw *hw)
        if (hw->mac.type == e1000_ich8lan)
                reg |= (E1000_RFCTL_IPV6_EX_DIS | E1000_RFCTL_NEW_IPV6_EXT_DIS);
        ew32(RFCTL, reg);
+
+       /* Enable ECC on Lynxpoint */
+       if (hw->mac.type == e1000_pch_lpt) {
+               reg = er32(PBECCSTS);
+               reg |= E1000_PBECCSTS_ECC_ENABLE;
+               ew32(PBECCSTS, reg);
+
+               reg = er32(CTRL);
+               reg |= E1000_CTRL_MEHE;
+               ew32(CTRL, reg);
+       }
 }
 
 /**
@@ -4044,8 +4055,7 @@ void e1000e_gig_downshift_workaround_ich8lan(struct e1000_hw *hw)
        if (ret_val)
                return;
        reg_data &= ~E1000_KMRNCTRLSTA_DIAG_NELPBK;
-       ret_val = e1000e_write_kmrn_reg(hw, E1000_KMRNCTRLSTA_DIAG_OFFSET,
-                                      reg_data);
+       e1000e_write_kmrn_reg(hw, E1000_KMRNCTRLSTA_DIAG_OFFSET, reg_data);
 }
 
 /**
@@ -4630,7 +4640,7 @@ const struct e1000_info e1000_pch_lpt_info = {
        .flags2                 = FLAG2_HAS_PHY_STATS
                                  | FLAG2_HAS_EEE,
        .pba                    = 26,
-       .max_hw_frame_size      = DEFAULT_JUMBO,
+       .max_hw_frame_size      = 9018,
        .get_variants           = e1000_get_variants_ich8lan,
        .mac_ops                = &ich8_mac_ops,
        .phy_ops                = &ich8_phy_ops,
index 0fa4c0656e095002787c9383269fd34e2eb9ed7c..0709f49f03353128ca7358cd1d72c356145bc87d 100644 (file)
@@ -1,7 +1,7 @@
 /*******************************************************************************
 
   Intel PRO/1000 Linux driver
-  Copyright(c) 1999 - 2012 Intel Corporation.
+  Copyright(c) 1999 - 2013 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,
@@ -165,7 +165,7 @@ void e1000e_init_rx_addrs(struct e1000_hw *hw, u16 rar_count)
 s32 e1000_check_alt_mac_addr_generic(struct e1000_hw *hw)
 {
        u32 i;
-       s32 ret_val = 0;
+       s32 ret_val;
        u16 offset, nvm_alt_mac_addr_offset, nvm_data;
        u8 alt_mac_addr[ETH_ALEN];
 
index 6dc47beb3adce59a46116bc37bc5e14ec931e109..4dae0dbda8375ebe9f93e2d3ec9da46f60b1935e 100644 (file)
@@ -1,7 +1,7 @@
 /*******************************************************************************
 
   Intel PRO/1000 Linux driver
-  Copyright(c) 1999 - 2012 Intel Corporation.
+  Copyright(c) 1999 - 2013 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,
index c15b7e438a442a9884433f8183a9a008380d2156..e386e95102f43073cda3762ae41f5e5b575fe913 100644 (file)
@@ -1,7 +1,7 @@
 /*******************************************************************************
 
   Intel PRO/1000 Linux driver
-  Copyright(c) 1999 - 2012 Intel Corporation.
+  Copyright(c) 1999 - 2013 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,
@@ -1780,6 +1780,23 @@ static irqreturn_t e1000_intr_msi(int irq, void *data)
                        mod_timer(&adapter->watchdog_timer, jiffies + 1);
        }
 
+       /* Reset on uncorrectable ECC error */
+       if ((icr & E1000_ICR_ECCER) && (hw->mac.type == e1000_pch_lpt)) {
+               u32 pbeccsts = er32(PBECCSTS);
+
+               adapter->corr_errors +=
+                   pbeccsts & E1000_PBECCSTS_CORR_ERR_CNT_MASK;
+               adapter->uncorr_errors +=
+                   (pbeccsts & E1000_PBECCSTS_UNCORR_ERR_CNT_MASK) >>
+                   E1000_PBECCSTS_UNCORR_ERR_CNT_SHIFT;
+
+               /* Do the reset outside of interrupt context */
+               schedule_work(&adapter->reset_task);
+
+               /* return immediately since reset is imminent */
+               return IRQ_HANDLED;
+       }
+
        if (napi_schedule_prep(&adapter->napi)) {
                adapter->total_tx_bytes = 0;
                adapter->total_tx_packets = 0;
@@ -1843,6 +1860,23 @@ static irqreturn_t e1000_intr(int irq, void *data)
                        mod_timer(&adapter->watchdog_timer, jiffies + 1);
        }
 
+       /* Reset on uncorrectable ECC error */
+       if ((icr & E1000_ICR_ECCER) && (hw->mac.type == e1000_pch_lpt)) {
+               u32 pbeccsts = er32(PBECCSTS);
+
+               adapter->corr_errors +=
+                   pbeccsts & E1000_PBECCSTS_CORR_ERR_CNT_MASK;
+               adapter->uncorr_errors +=
+                   (pbeccsts & E1000_PBECCSTS_UNCORR_ERR_CNT_MASK) >>
+                   E1000_PBECCSTS_UNCORR_ERR_CNT_SHIFT;
+
+               /* Do the reset outside of interrupt context */
+               schedule_work(&adapter->reset_task);
+
+               /* return immediately since reset is imminent */
+               return IRQ_HANDLED;
+       }
+
        if (napi_schedule_prep(&adapter->napi)) {
                adapter->total_tx_bytes = 0;
                adapter->total_tx_packets = 0;
@@ -2206,6 +2240,8 @@ static void e1000_irq_enable(struct e1000_adapter *adapter)
        if (adapter->msix_entries) {
                ew32(EIAC_82574, adapter->eiac_mask & E1000_EIAC_MASK_82574);
                ew32(IMS, adapter->eiac_mask | E1000_IMS_OTHER | E1000_IMS_LSC);
+       } else if (hw->mac.type == e1000_pch_lpt) {
+               ew32(IMS, IMS_ENABLE_MASK | E1000_IMS_ECCER);
        } else {
                ew32(IMS, IMS_ENABLE_MASK);
        }
@@ -3413,7 +3449,7 @@ static void e1000e_setup_rss_hash(struct e1000_adapter *adapter)
  * Get attributes for incrementing the System Time Register SYSTIML/H at
  * the default base frequency, and set the cyclecounter shift value.
  **/
-static s32 e1000e_get_base_timinca(struct e1000_adapter *adapter, u32 *timinca)
+s32 e1000e_get_base_timinca(struct e1000_adapter *adapter, u32 *timinca)
 {
        struct e1000_hw *hw = &adapter->hw;
        u32 incvalue, incperiod, shift;
@@ -3485,6 +3521,10 @@ static int e1000e_config_hwtstamp(struct e1000_adapter *adapter)
        struct hwtstamp_config *config = &adapter->hwtstamp_config;
        u32 tsync_tx_ctl = E1000_TSYNCTXCTL_ENABLED;
        u32 tsync_rx_ctl = E1000_TSYNCRXCTL_ENABLED;
+       u32 rxmtrl = 0;
+       u16 rxudp = 0;
+       bool is_l4 = false;
+       bool is_l2 = false;
        u32 regval;
        s32 ret_val;
 
@@ -3509,7 +3549,69 @@ static int e1000e_config_hwtstamp(struct e1000_adapter *adapter)
        case HWTSTAMP_FILTER_NONE:
                tsync_rx_ctl = 0;
                break;
+       case HWTSTAMP_FILTER_PTP_V1_L4_SYNC:
+               tsync_rx_ctl |= E1000_TSYNCRXCTL_TYPE_L4_V1;
+               rxmtrl = E1000_RXMTRL_PTP_V1_SYNC_MESSAGE;
+               is_l4 = true;
+               break;
+       case HWTSTAMP_FILTER_PTP_V1_L4_DELAY_REQ:
+               tsync_rx_ctl |= E1000_TSYNCRXCTL_TYPE_L4_V1;
+               rxmtrl = E1000_RXMTRL_PTP_V1_DELAY_REQ_MESSAGE;
+               is_l4 = true;
+               break;
+       case HWTSTAMP_FILTER_PTP_V2_L2_SYNC:
+               /* Also time stamps V2 L2 Path Delay Request/Response */
+               tsync_rx_ctl |= E1000_TSYNCRXCTL_TYPE_L2_V2;
+               rxmtrl = E1000_RXMTRL_PTP_V2_SYNC_MESSAGE;
+               is_l2 = true;
+               break;
+       case HWTSTAMP_FILTER_PTP_V2_L2_DELAY_REQ:
+               /* Also time stamps V2 L2 Path Delay Request/Response. */
+               tsync_rx_ctl |= E1000_TSYNCRXCTL_TYPE_L2_V2;
+               rxmtrl = E1000_RXMTRL_PTP_V2_DELAY_REQ_MESSAGE;
+               is_l2 = true;
+               break;
+       case HWTSTAMP_FILTER_PTP_V2_L4_SYNC:
+               /* Hardware cannot filter just V2 L4 Sync messages;
+                * fall-through to V2 (both L2 and L4) Sync.
+                */
+       case HWTSTAMP_FILTER_PTP_V2_SYNC:
+               /* Also time stamps V2 Path Delay Request/Response. */
+               tsync_rx_ctl |= E1000_TSYNCRXCTL_TYPE_L2_L4_V2;
+               rxmtrl = E1000_RXMTRL_PTP_V2_SYNC_MESSAGE;
+               is_l2 = true;
+               is_l4 = true;
+               break;
+       case HWTSTAMP_FILTER_PTP_V2_L4_DELAY_REQ:
+               /* Hardware cannot filter just V2 L4 Delay Request messages;
+                * fall-through to V2 (both L2 and L4) Delay Request.
+                */
+       case HWTSTAMP_FILTER_PTP_V2_DELAY_REQ:
+               /* Also time stamps V2 Path Delay Request/Response. */
+               tsync_rx_ctl |= E1000_TSYNCRXCTL_TYPE_L2_L4_V2;
+               rxmtrl = E1000_RXMTRL_PTP_V2_DELAY_REQ_MESSAGE;
+               is_l2 = true;
+               is_l4 = true;
+               break;
+       case HWTSTAMP_FILTER_PTP_V2_L4_EVENT:
+       case HWTSTAMP_FILTER_PTP_V2_L2_EVENT:
+               /* Hardware cannot filter just V2 L4 or L2 Event messages;
+                * fall-through to all V2 (both L2 and L4) Events.
+                */
+       case HWTSTAMP_FILTER_PTP_V2_EVENT:
+               tsync_rx_ctl |= E1000_TSYNCRXCTL_TYPE_EVENT_V2;
+               config->rx_filter = HWTSTAMP_FILTER_PTP_V2_EVENT;
+               is_l2 = true;
+               is_l4 = true;
+               break;
+       case HWTSTAMP_FILTER_PTP_V1_L4_EVENT:
+               /* For V1, the hardware can only filter Sync messages or
+                * Delay Request messages but not both so fall-through to
+                * time stamp all packets.
+                */
        case HWTSTAMP_FILTER_ALL:
+               is_l2 = true;
+               is_l4 = true;
                tsync_rx_ctl |= E1000_TSYNCRXCTL_TYPE_ALL;
                config->rx_filter = HWTSTAMP_FILTER_ALL;
                break;
@@ -3541,9 +3643,25 @@ static int e1000e_config_hwtstamp(struct e1000_adapter *adapter)
                return -EAGAIN;
        }
 
+       /* L2: define ethertype filter for time stamped packets */
+       if (is_l2)
+               rxmtrl |= ETH_P_1588;
+
+       /* define which PTP packets get time stamped */
+       ew32(RXMTRL, rxmtrl);
+
+       /* Filter by destination port */
+       if (is_l4) {
+               rxudp = PTP_EV_PORT;
+               cpu_to_be16s(&rxudp);
+       }
+       ew32(RXUDP, rxudp);
+
+       e1e_flush();
+
        /* Clear TSYNCRXCTL_VALID & TSYNCTXCTL_VALID bit */
-       regval = er32(RXSTMPH);
-       regval = er32(TXSTMPH);
+       er32(RXSTMPH);
+       er32(TXSTMPH);
 
        /* Get and set the System Time Register SYSTIM base frequency */
        ret_val = e1000e_get_base_timinca(adapter, &regval);
@@ -3724,14 +3842,17 @@ void e1000e_reset(struct e1000_adapter *adapter)
                break;
        case e1000_pch2lan:
        case e1000_pch_lpt:
-               fc->high_water = 0x05C20;
-               fc->low_water = 0x05048;
-               fc->pause_time = 0x0650;
                fc->refresh_time = 0x0400;
-               if (adapter->netdev->mtu > ETH_DATA_LEN) {
-                       pba = 14;
-                       ew32(PBA, pba);
+
+               if (adapter->netdev->mtu <= ETH_DATA_LEN) {
+                       fc->high_water = 0x05C20;
+                       fc->low_water = 0x05048;
+                       fc->pause_time = 0x0650;
+                       break;
                }
+
+               fc->high_water = ((pba << 10) * 9 / 10) & E1000_FCRTH_RTH;
+               fc->low_water = ((pba << 10) * 8 / 10) & E1000_FCRTL_RTL;
                break;
        }
 
@@ -4534,6 +4655,16 @@ static void e1000e_update_stats(struct e1000_adapter *adapter)
        adapter->stats.mgptc += er32(MGTPTC);
        adapter->stats.mgprc += er32(MGTPRC);
        adapter->stats.mgpdc += er32(MGTPDC);
+
+       /* Correctable ECC Errors */
+       if (hw->mac.type == e1000_pch_lpt) {
+               u32 pbeccsts = er32(PBECCSTS);
+               adapter->corr_errors +=
+                   pbeccsts & E1000_PBECCSTS_CORR_ERR_CNT_MASK;
+               adapter->uncorr_errors +=
+                   (pbeccsts & E1000_PBECCSTS_UNCORR_ERR_CNT_MASK) >>
+                   E1000_PBECCSTS_UNCORR_ERR_CNT_SHIFT;
+       }
 }
 
 /**
@@ -5662,6 +5793,24 @@ static int e1000e_hwtstamp_ioctl(struct net_device *netdev, struct ifreq *ifr)
 
        config = adapter->hwtstamp_config;
 
+       switch (config.rx_filter) {
+       case HWTSTAMP_FILTER_PTP_V2_L4_SYNC:
+       case HWTSTAMP_FILTER_PTP_V2_L2_SYNC:
+       case HWTSTAMP_FILTER_PTP_V2_SYNC:
+       case HWTSTAMP_FILTER_PTP_V2_L4_DELAY_REQ:
+       case HWTSTAMP_FILTER_PTP_V2_L2_DELAY_REQ:
+       case HWTSTAMP_FILTER_PTP_V2_DELAY_REQ:
+               /* With V2 type filters which specify a Sync or Delay Request,
+                * Path Delay Request/Response messages are also time stamped
+                * by hardware so notify the caller the requested packets plus
+                * some others are time stamped.
+                */
+               config.rx_filter = HWTSTAMP_FILTER_SOME;
+               break;
+       default:
+               break;
+       }
+
        return copy_to_user(ifr->ifr_data, &config,
                            sizeof(config)) ? -EFAULT : 0;
 }
@@ -5685,7 +5834,7 @@ static int e1000_init_phy_wakeup(struct e1000_adapter *adapter, u32 wufc)
        struct e1000_hw *hw = &adapter->hw;
        u32 i, mac_reg;
        u16 phy_reg, wuc_enable;
-       int retval = 0;
+       int retval;
 
        /* copy MAC RARs to PHY RARs */
        e1000_copy_rx_addrs_to_phy_ich8lan(hw);
@@ -6669,6 +6818,9 @@ static int e1000_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
        /* carrier off reporting is important to ethtool even BEFORE open */
        netif_carrier_off(netdev);
 
+       /* init PTP hardware clock */
+       e1000e_ptp_init(adapter);
+
        e1000_print_device_info(adapter);
 
        if (pci_dev_run_wake(pdev))
@@ -6717,6 +6869,8 @@ static void e1000_remove(struct pci_dev *pdev)
        struct e1000_adapter *adapter = netdev_priv(netdev);
        bool down = test_bit(__E1000_DOWN, &adapter->state);
 
+       e1000e_ptp_remove(adapter);
+
        /* The timers may be rescheduled, so explicitly disable them
         * from being rescheduled.
         */
@@ -6891,7 +7045,7 @@ static int __init e1000_init_module(void)
        int ret;
        pr_info("Intel(R) PRO/1000 Network Driver - %s\n",
                e1000e_driver_version);
-       pr_info("Copyright(c) 1999 - 2012 Intel Corporation.\n");
+       pr_info("Copyright(c) 1999 - 2013 Intel Corporation.\n");
        ret = pci_register_driver(&e1000_driver);
 
        return ret;
index 1e7882c7d6d4aa44e131b05ffd36c9bee5b05471..84fecc268162417b676f65066abc2fb2e4bd20bf 100644 (file)
@@ -1,7 +1,7 @@
 /*******************************************************************************
 
   Intel PRO/1000 Linux driver
-  Copyright(c) 1999 - 2012 Intel Corporation.
+  Copyright(c) 1999 - 2013 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,
index b29a8a5116a821090e2afc1b22b3483f824e2833..19c40d6f53ccb8f2c09bc3918e3917105e9deb74 100644 (file)
@@ -1,7 +1,7 @@
 /*******************************************************************************
 
   Intel PRO/1000 Linux driver
-  Copyright(c) 1999 - 2012 Intel Corporation.
+  Copyright(c) 1999 - 2013 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,
index 28b38ff37e843a028f89d7fab86827a777e5a098..44fb432f3c108c15587ee14f6f640a01142a58b6 100644 (file)
@@ -1,7 +1,7 @@
 /*******************************************************************************
 
   Intel PRO/1000 Linux driver
-  Copyright(c) 1999 - 2012 Intel Corporation.
+  Copyright(c) 1999 - 2013 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,
@@ -32,12 +32,11 @@ static s32 e1000_get_phy_cfg_done(struct e1000_hw *hw);
 static s32 e1000_phy_force_speed_duplex(struct e1000_hw *hw);
 static s32 e1000_set_d0_lplu_state(struct e1000_hw *hw, bool active);
 static s32 e1000_wait_autoneg(struct e1000_hw *hw);
-static u32 e1000_get_phy_addr_for_bm_page(u32 page, u32 reg);
 static s32 e1000_access_phy_wakeup_reg_bm(struct e1000_hw *hw, u32 offset,
                                          u16 *data, bool read, bool page_set);
 static u32 e1000_get_phy_addr_for_hv_page(u32 page);
 static s32 e1000_access_phy_debug_regs_hv(struct e1000_hw *hw, u32 offset,
-                                          u16 *data, bool read);
+                                         u16 *data, bool read);
 
 /* Cable length tables */
 static const u16 e1000_m88_cable_length_table[] = {
@@ -2672,7 +2671,7 @@ s32 e1000_enable_phy_wakeup_reg_access_bm(struct e1000_hw *hw, u16 *phy_reg)
  **/
 s32 e1000_disable_phy_wakeup_reg_access_bm(struct e1000_hw *hw, u16 *phy_reg)
 {
-       s32 ret_val = 0;
+       s32 ret_val;
 
        /* Select Port Control Registers page */
        ret_val = e1000_set_page_igp(hw, (BM_PORT_CTRL_PAGE << IGP_PAGE_SHIFT));
@@ -3104,8 +3103,8 @@ static s32 e1000_access_phy_debug_regs_hv(struct e1000_hw *hw, u32 offset,
                                           u16 *data, bool read)
 {
        s32 ret_val;
-       u32 addr_reg = 0;
-       u32 data_reg = 0;
+       u32 addr_reg;
+       u32 data_reg;
 
        /* This takes care of the difference with desktop vs mobile phy */
        addr_reg = (hw->phy.type == e1000_phy_82578) ?
@@ -3333,7 +3332,7 @@ s32 e1000_get_cable_length_82577(struct e1000_hw *hw)
                 I82577_DSTATUS_CABLE_LENGTH_SHIFT;
 
        if (length == E1000_CABLE_LENGTH_UNDEFINED)
-               ret_val = -E1000_ERR_PHY;
+               return -E1000_ERR_PHY;
 
        phy->cable_length = length;
 
diff --git a/drivers/net/ethernet/intel/e1000e/ptp.c b/drivers/net/ethernet/intel/e1000e/ptp.c
new file mode 100644 (file)
index 0000000..6b8df65
--- /dev/null
@@ -0,0 +1,276 @@
+/*******************************************************************************
+
+  Intel PRO/1000 Linux driver
+  Copyright(c) 1999 - 2013 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
+
+*******************************************************************************/
+
+/* PTP 1588 Hardware Clock (PHC)
+ * Derived from PTP Hardware Clock driver for Intel 82576 and 82580 (igb)
+ * Copyright (C) 2011 Richard Cochran <richardcochran@gmail.com>
+ */
+
+#include "e1000.h"
+
+/**
+ * e1000e_phc_adjfreq - adjust the frequency of the hardware clock
+ * @ptp: ptp clock structure
+ * @delta: Desired frequency change in parts per billion
+ *
+ * Adjust the frequency of the PHC cycle counter by the indicated delta from
+ * the base frequency.
+ **/
+static int e1000e_phc_adjfreq(struct ptp_clock_info *ptp, s32 delta)
+{
+       struct e1000_adapter *adapter = container_of(ptp, struct e1000_adapter,
+                                                    ptp_clock_info);
+       struct e1000_hw *hw = &adapter->hw;
+       bool neg_adj = false;
+       u64 adjustment;
+       u32 timinca, incvalue;
+       s32 ret_val;
+
+       if ((delta > ptp->max_adj) || (delta <= -1000000000))
+               return -EINVAL;
+
+       if (delta < 0) {
+               neg_adj = true;
+               delta = -delta;
+       }
+
+       /* Get the System Time Register SYSTIM base frequency */
+       ret_val = e1000e_get_base_timinca(adapter, &timinca);
+       if (ret_val)
+               return ret_val;
+
+       incvalue = timinca & E1000_TIMINCA_INCVALUE_MASK;
+
+       adjustment = incvalue;
+       adjustment *= delta;
+       adjustment = div_u64(adjustment, 1000000000);
+
+       incvalue = neg_adj ? (incvalue - adjustment) : (incvalue + adjustment);
+
+       timinca &= ~E1000_TIMINCA_INCVALUE_MASK;
+       timinca |= incvalue;
+
+       ew32(TIMINCA, timinca);
+
+       return 0;
+}
+
+/**
+ * e1000e_phc_adjtime - Shift the time of the hardware clock
+ * @ptp: ptp clock structure
+ * @delta: Desired change in nanoseconds
+ *
+ * Adjust the timer by resetting the timecounter structure.
+ **/
+static int e1000e_phc_adjtime(struct ptp_clock_info *ptp, s64 delta)
+{
+       struct e1000_adapter *adapter = container_of(ptp, struct e1000_adapter,
+                                                    ptp_clock_info);
+       unsigned long flags;
+       s64 now;
+
+       spin_lock_irqsave(&adapter->systim_lock, flags);
+       now = timecounter_read(&adapter->tc);
+       now += delta;
+       timecounter_init(&adapter->tc, &adapter->cc, now);
+       spin_unlock_irqrestore(&adapter->systim_lock, flags);
+
+       return 0;
+}
+
+/**
+ * e1000e_phc_gettime - Reads the current time from the hardware clock
+ * @ptp: ptp clock structure
+ * @ts: timespec structure to hold the current time value
+ *
+ * Read the timecounter and return the correct value in ns after converting
+ * it into a struct timespec.
+ **/
+static int e1000e_phc_gettime(struct ptp_clock_info *ptp, struct timespec *ts)
+{
+       struct e1000_adapter *adapter = container_of(ptp, struct e1000_adapter,
+                                                    ptp_clock_info);
+       unsigned long flags;
+       u32 remainder;
+       u64 ns;
+
+       spin_lock_irqsave(&adapter->systim_lock, flags);
+       ns = timecounter_read(&adapter->tc);
+       spin_unlock_irqrestore(&adapter->systim_lock, flags);
+
+       ts->tv_sec = div_u64_rem(ns, NSEC_PER_SEC, &remainder);
+       ts->tv_nsec = remainder;
+
+       return 0;
+}
+
+/**
+ * e1000e_phc_settime - Set the current time on the hardware clock
+ * @ptp: ptp clock structure
+ * @ts: timespec containing the new time for the cycle counter
+ *
+ * Reset the timecounter to use a new base value instead of the kernel
+ * wall timer value.
+ **/
+static int e1000e_phc_settime(struct ptp_clock_info *ptp,
+                             const struct timespec *ts)
+{
+       struct e1000_adapter *adapter = container_of(ptp, struct e1000_adapter,
+                                                    ptp_clock_info);
+       unsigned long flags;
+       u64 ns;
+
+       ns = ts->tv_sec * NSEC_PER_SEC;
+       ns += ts->tv_nsec;
+
+       /* reset the timecounter */
+       spin_lock_irqsave(&adapter->systim_lock, flags);
+       timecounter_init(&adapter->tc, &adapter->cc, ns);
+       spin_unlock_irqrestore(&adapter->systim_lock, flags);
+
+       return 0;
+}
+
+/**
+ * e1000e_phc_enable - enable or disable an ancillary feature
+ * @ptp: ptp clock structure
+ * @request: Desired resource to enable or disable
+ * @on: Caller passes one to enable or zero to disable
+ *
+ * Enable (or disable) ancillary features of the PHC subsystem.
+ * Currently, no ancillary features are supported.
+ **/
+static int e1000e_phc_enable(struct ptp_clock_info *ptp,
+                            struct ptp_clock_request *request, int on)
+{
+       return -EOPNOTSUPP;
+}
+
+static void e1000e_systim_overflow_work(struct work_struct *work)
+{
+       struct e1000_adapter *adapter = container_of(work, struct e1000_adapter,
+                                                    systim_overflow_work.work);
+       struct e1000_hw *hw = &adapter->hw;
+       struct timespec ts;
+
+       adapter->ptp_clock_info.gettime(&adapter->ptp_clock_info, &ts);
+
+       e_dbg("SYSTIM overflow check at %ld.%09lu\n", ts.tv_sec, ts.tv_nsec);
+
+       schedule_delayed_work(&adapter->systim_overflow_work,
+                             E1000_SYSTIM_OVERFLOW_PERIOD);
+}
+
+static const struct ptp_clock_info e1000e_ptp_clock_info = {
+       .owner          = THIS_MODULE,
+       .n_alarm        = 0,
+       .n_ext_ts       = 0,
+       .n_per_out      = 0,
+       .pps            = 0,
+       .adjfreq        = e1000e_phc_adjfreq,
+       .adjtime        = e1000e_phc_adjtime,
+       .gettime        = e1000e_phc_gettime,
+       .settime        = e1000e_phc_settime,
+       .enable         = e1000e_phc_enable,
+};
+
+/**
+ * e1000e_ptp_init - initialize PTP for devices which support it
+ * @adapter: board private structure
+ *
+ * This function performs the required steps for enabling PTP support.
+ * If PTP support has already been loaded it simply calls the cyclecounter
+ * init routine and exits.
+ **/
+void e1000e_ptp_init(struct e1000_adapter *adapter)
+{
+       struct e1000_hw *hw = &adapter->hw;
+
+       adapter->ptp_clock = NULL;
+
+       if (!(adapter->flags & FLAG_HAS_HW_TIMESTAMP))
+               return;
+
+       adapter->ptp_clock_info = e1000e_ptp_clock_info;
+
+       snprintf(adapter->ptp_clock_info.name,
+                sizeof(adapter->ptp_clock_info.name), "%pm",
+                adapter->netdev->perm_addr);
+
+       switch (hw->mac.type) {
+       case e1000_pch2lan:
+       case e1000_pch_lpt:
+               if ((hw->mac.type != e1000_pch_lpt) ||
+                   (er32(TSYNCRXCTL) & E1000_TSYNCRXCTL_SYSCFI)) {
+                       adapter->ptp_clock_info.max_adj = 24000000 - 1;
+                       break;
+               }
+               /* fall-through */
+       case e1000_82574:
+       case e1000_82583:
+               adapter->ptp_clock_info.max_adj = 600000000 - 1;
+               break;
+       default:
+               break;
+       }
+
+       INIT_DELAYED_WORK(&adapter->systim_overflow_work,
+                         e1000e_systim_overflow_work);
+
+       schedule_delayed_work(&adapter->systim_overflow_work,
+                             E1000_SYSTIM_OVERFLOW_PERIOD);
+
+       adapter->ptp_clock = ptp_clock_register(&adapter->ptp_clock_info,
+                                               &adapter->pdev->dev);
+       if (IS_ERR(adapter->ptp_clock)) {
+               adapter->ptp_clock = NULL;
+               e_err("ptp_clock_register failed\n");
+       } else {
+               e_info("registered PHC clock\n");
+       }
+}
+
+/**
+ * e1000e_ptp_remove - disable PTP device and stop the overflow check
+ * @adapter: board private structure
+ *
+ * Stop the PTP support, and cancel the delayed work.
+ **/
+void e1000e_ptp_remove(struct e1000_adapter *adapter)
+{
+       if (!(adapter->flags & FLAG_HAS_HW_TIMESTAMP))
+               return;
+
+       cancel_delayed_work_sync(&adapter->systim_overflow_work);
+
+       if (adapter->ptp_clock) {
+               ptp_clock_unregister(adapter->ptp_clock);
+               adapter->ptp_clock = NULL;
+               e_info("removed PHC\n");
+       }
+}