aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet/intel
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/ethernet/intel')
-rw-r--r--drivers/net/ethernet/intel/e100.c4
-rw-r--r--drivers/net/ethernet/intel/e1000e/80003es2lan.c47
-rw-r--r--drivers/net/ethernet/intel/e1000e/80003es2lan.h47
-rw-r--r--drivers/net/ethernet/intel/e1000e/82571.c47
-rw-r--r--drivers/net/ethernet/intel/e1000e/82571.h47
-rw-r--r--drivers/net/ethernet/intel/e1000e/Makefile7
-rw-r--r--drivers/net/ethernet/intel/e1000e/defines.h55
-rw-r--r--drivers/net/ethernet/intel/e1000e/e1000.h50
-rw-r--r--drivers/net/ethernet/intel/e1000e/ethtool.c63
-rw-r--r--drivers/net/ethernet/intel/e1000e/hw.h55
-rw-r--r--drivers/net/ethernet/intel/e1000e/ich8lan.c427
-rw-r--r--drivers/net/ethernet/intel/e1000e/ich8lan.h72
-rw-r--r--drivers/net/ethernet/intel/e1000e/mac.c47
-rw-r--r--drivers/net/ethernet/intel/e1000e/mac.h47
-rw-r--r--drivers/net/ethernet/intel/e1000e/manage.c47
-rw-r--r--drivers/net/ethernet/intel/e1000e/manage.h47
-rw-r--r--drivers/net/ethernet/intel/e1000e/netdev.c343
-rw-r--r--drivers/net/ethernet/intel/e1000e/nvm.c47
-rw-r--r--drivers/net/ethernet/intel/e1000e/nvm.h47
-rw-r--r--drivers/net/ethernet/intel/e1000e/param.c53
-rw-r--r--drivers/net/ethernet/intel/e1000e/phy.c47
-rw-r--r--drivers/net/ethernet/intel/e1000e/phy.h47
-rw-r--r--drivers/net/ethernet/intel/e1000e/ptp.c53
-rw-r--r--drivers/net/ethernet/intel/e1000e/regs.h48
-rw-r--r--drivers/net/ethernet/intel/i40e/i40e.h49
-rw-r--r--drivers/net/ethernet/intel/i40e/i40e_adminq.c5
-rw-r--r--drivers/net/ethernet/intel/i40e/i40e_common.c366
-rw-r--r--drivers/net/ethernet/intel/i40e/i40e_dcb.c9
-rw-r--r--drivers/net/ethernet/intel/i40e/i40e_debugfs.c52
-rw-r--r--drivers/net/ethernet/intel/i40e/i40e_ethtool.c465
-rw-r--r--drivers/net/ethernet/intel/i40e/i40e_main.c481
-rw-r--r--drivers/net/ethernet/intel/i40e/i40e_nvm.c117
-rw-r--r--drivers/net/ethernet/intel/i40e/i40e_prototype.h7
-rw-r--r--drivers/net/ethernet/intel/i40e/i40e_txrx.c424
-rw-r--r--drivers/net/ethernet/intel/i40e/i40e_type.h11
-rw-r--r--drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c135
-rw-r--r--drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.h5
-rw-r--r--drivers/net/ethernet/intel/i40evf/i40e_adminq_cmd.h2
-rw-r--r--drivers/net/ethernet/intel/i40evf/i40e_common.c366
-rw-r--r--drivers/net/ethernet/intel/i40evf/i40e_prototype.h7
-rw-r--r--drivers/net/ethernet/intel/i40evf/i40e_txrx.c90
-rw-r--r--drivers/net/ethernet/intel/i40evf/i40e_type.h15
-rw-r--r--drivers/net/ethernet/intel/i40evf/i40evf.h47
-rw-r--r--drivers/net/ethernet/intel/i40evf/i40evf_ethtool.c13
-rw-r--r--drivers/net/ethernet/intel/i40evf/i40evf_main.c292
-rw-r--r--drivers/net/ethernet/intel/i40evf/i40evf_virtchnl.c27
-rw-r--r--drivers/net/ethernet/intel/igb/Makefile5
-rw-r--r--drivers/net/ethernet/intel/igb/e1000_82575.c15
-rw-r--r--drivers/net/ethernet/intel/igb/e1000_82575.h12
-rw-r--r--drivers/net/ethernet/intel/igb/e1000_defines.h75
-rw-r--r--drivers/net/ethernet/intel/igb/e1000_hw.h5
-rw-r--r--drivers/net/ethernet/intel/igb/e1000_i210.c25
-rw-r--r--drivers/net/ethernet/intel/igb/e1000_i210.h14
-rw-r--r--drivers/net/ethernet/intel/igb/e1000_mac.c5
-rw-r--r--drivers/net/ethernet/intel/igb/e1000_mac.h5
-rw-r--r--drivers/net/ethernet/intel/igb/e1000_mbx.c5
-rw-r--r--drivers/net/ethernet/intel/igb/e1000_mbx.h5
-rw-r--r--drivers/net/ethernet/intel/igb/e1000_nvm.c5
-rw-r--r--drivers/net/ethernet/intel/igb/e1000_nvm.h5
-rw-r--r--drivers/net/ethernet/intel/igb/e1000_phy.c76
-rw-r--r--drivers/net/ethernet/intel/igb/e1000_phy.h6
-rw-r--r--drivers/net/ethernet/intel/igb/e1000_regs.h36
-rw-r--r--drivers/net/ethernet/intel/igb/igb.h15
-rw-r--r--drivers/net/ethernet/intel/igb/igb_ethtool.c76
-rw-r--r--drivers/net/ethernet/intel/igb/igb_hwmon.c5
-rw-r--r--drivers/net/ethernet/intel/igb/igb_main.c159
-rw-r--r--drivers/net/ethernet/intel/igb/igb_ptp.c61
-rw-r--r--drivers/net/ethernet/intel/igbvf/netdev.c10
-rw-r--r--drivers/net/ethernet/intel/ixgb/ixgb_main.c6
-rw-r--r--drivers/net/ethernet/intel/ixgbe/ixgbe.h7
-rw-r--r--drivers/net/ethernet/intel/ixgbe/ixgbe_82598.c33
-rw-r--r--drivers/net/ethernet/intel/ixgbe/ixgbe_82599.c360
-rw-r--r--drivers/net/ethernet/intel/ixgbe/ixgbe_common.c200
-rw-r--r--drivers/net/ethernet/intel/ixgbe/ixgbe_common.h14
-rw-r--r--drivers/net/ethernet/intel/ixgbe/ixgbe_dcb_82599.c1
-rw-r--r--drivers/net/ethernet/intel/ixgbe/ixgbe_dcb_82599.h1
-rw-r--r--drivers/net/ethernet/intel/ixgbe/ixgbe_debugfs.c1
-rw-r--r--drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c18
-rw-r--r--drivers/net/ethernet/intel/ixgbe/ixgbe_fcoe.c11
-rw-r--r--drivers/net/ethernet/intel/ixgbe/ixgbe_fcoe.h1
-rw-r--r--drivers/net/ethernet/intel/ixgbe/ixgbe_lib.c17
-rw-r--r--drivers/net/ethernet/intel/ixgbe/ixgbe_main.c181
-rw-r--r--drivers/net/ethernet/intel/ixgbe/ixgbe_mbx.c1
-rw-r--r--drivers/net/ethernet/intel/ixgbe/ixgbe_mbx.h1
-rw-r--r--drivers/net/ethernet/intel/ixgbe/ixgbe_phy.c45
-rw-r--r--drivers/net/ethernet/intel/ixgbe/ixgbe_phy.h8
-rw-r--r--drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c32
-rw-r--r--drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c1
-rw-r--r--drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.h1
-rw-r--r--drivers/net/ethernet/intel/ixgbe/ixgbe_sysfs.c1
-rw-r--r--drivers/net/ethernet/intel/ixgbe/ixgbe_type.h29
-rw-r--r--drivers/net/ethernet/intel/ixgbe/ixgbe_x540.c6
-rw-r--r--drivers/net/ethernet/intel/ixgbevf/ethtool.c141
-rw-r--r--drivers/net/ethernet/intel/ixgbevf/ixgbevf.h11
-rw-r--r--drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c139
-rw-r--r--drivers/net/ethernet/intel/ixgbevf/regs.h12
-rw-r--r--drivers/net/ethernet/intel/ixgbevf/vf.h33
97 files changed, 4482 insertions, 2234 deletions
diff --git a/drivers/net/ethernet/intel/e100.c b/drivers/net/ethernet/intel/e100.c
index bf7a01ef9a57..b56461ce674c 100644
--- a/drivers/net/ethernet/intel/e100.c
+++ b/drivers/net/ethernet/intel/e100.c
@@ -1778,9 +1778,9 @@ static int e100_xmit_prepare(struct nic *nic, struct cb *cb,
1778 * testing, ie sending frames with bad CRC. 1778 * testing, ie sending frames with bad CRC.
1779 */ 1779 */
1780 if (unlikely(skb->no_fcs)) 1780 if (unlikely(skb->no_fcs))
1781 cb->command |= __constant_cpu_to_le16(cb_tx_nc); 1781 cb->command |= cpu_to_le16(cb_tx_nc);
1782 else 1782 else
1783 cb->command &= ~__constant_cpu_to_le16(cb_tx_nc); 1783 cb->command &= ~cpu_to_le16(cb_tx_nc);
1784 1784
1785 /* interrupt every 16 packets regardless of delay */ 1785 /* interrupt every 16 packets regardless of delay */
1786 if ((nic->cbs_avail & ~15) == nic->cbs_avail) 1786 if ((nic->cbs_avail & ~15) == nic->cbs_avail)
diff --git a/drivers/net/ethernet/intel/e1000e/80003es2lan.c b/drivers/net/ethernet/intel/e1000e/80003es2lan.c
index ff2d806eaef7..a5f6b11d6992 100644
--- a/drivers/net/ethernet/intel/e1000e/80003es2lan.c
+++ b/drivers/net/ethernet/intel/e1000e/80003es2lan.c
@@ -1,30 +1,23 @@
1/******************************************************************************* 1/* Intel PRO/1000 Linux driver
2 2 * Copyright(c) 1999 - 2014 Intel Corporation.
3 Intel PRO/1000 Linux driver 3 *
4 Copyright(c) 1999 - 2013 Intel Corporation. 4 * This program is free software; you can redistribute it and/or modify it
5 5 * under the terms and conditions of the GNU General Public License,
6 This program is free software; you can redistribute it and/or modify it 6 * version 2, as published by the Free Software Foundation.
7 under the terms and conditions of the GNU General Public License, 7 *
8 version 2, as published by the Free Software Foundation. 8 * This program is distributed in the hope it will be useful, but WITHOUT
9 9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 This program is distributed in the hope it will be useful, but WITHOUT 10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * more details.
12 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 12 *
13 more details. 13 * The full GNU General Public License is included in this distribution in
14 14 * the file called "COPYING".
15 You should have received a copy of the GNU General Public License along with 15 *
16 this program; if not, write to the Free Software Foundation, Inc., 16 * Contact Information:
17 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. 17 * Linux NICS <linux.nics@intel.com>
18 18 * e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
19 The full GNU General Public License is included in this distribution in 19 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
20 the file called "COPYING". 20 */
21
22 Contact Information:
23 Linux NICS <linux.nics@intel.com>
24 e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
25 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
26
27*******************************************************************************/
28 21
29/* 80003ES2LAN Gigabit Ethernet Controller (Copper) 22/* 80003ES2LAN Gigabit Ethernet Controller (Copper)
30 * 80003ES2LAN Gigabit Ethernet Controller (Serdes) 23 * 80003ES2LAN Gigabit Ethernet Controller (Serdes)
diff --git a/drivers/net/ethernet/intel/e1000e/80003es2lan.h b/drivers/net/ethernet/intel/e1000e/80003es2lan.h
index 90d363b2d280..535a9430976d 100644
--- a/drivers/net/ethernet/intel/e1000e/80003es2lan.h
+++ b/drivers/net/ethernet/intel/e1000e/80003es2lan.h
@@ -1,30 +1,23 @@
1/******************************************************************************* 1/* Intel PRO/1000 Linux driver
2 2 * Copyright(c) 1999 - 2014 Intel Corporation.
3 Intel PRO/1000 Linux driver 3 *
4 Copyright(c) 1999 - 2013 Intel Corporation. 4 * This program is free software; you can redistribute it and/or modify it
5 5 * under the terms and conditions of the GNU General Public License,
6 This program is free software; you can redistribute it and/or modify it 6 * version 2, as published by the Free Software Foundation.
7 under the terms and conditions of the GNU General Public License, 7 *
8 version 2, as published by the Free Software Foundation. 8 * This program is distributed in the hope it will be useful, but WITHOUT
9 9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 This program is distributed in the hope it will be useful, but WITHOUT 10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * more details.
12 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 12 *
13 more details. 13 * The full GNU General Public License is included in this distribution in
14 14 * the file called "COPYING".
15 You should have received a copy of the GNU General Public License along with 15 *
16 this program; if not, write to the Free Software Foundation, Inc., 16 * Contact Information:
17 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. 17 * Linux NICS <linux.nics@intel.com>
18 18 * e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
19 The full GNU General Public License is included in this distribution in 19 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
20 the file called "COPYING". 20 */
21
22 Contact Information:
23 Linux NICS <linux.nics@intel.com>
24 e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
25 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
26
27*******************************************************************************/
28 21
29#ifndef _E1000E_80003ES2LAN_H_ 22#ifndef _E1000E_80003ES2LAN_H_
30#define _E1000E_80003ES2LAN_H_ 23#define _E1000E_80003ES2LAN_H_
diff --git a/drivers/net/ethernet/intel/e1000e/82571.c b/drivers/net/ethernet/intel/e1000e/82571.c
index 8fed74e3fa53..e0aa7f1efb08 100644
--- a/drivers/net/ethernet/intel/e1000e/82571.c
+++ b/drivers/net/ethernet/intel/e1000e/82571.c
@@ -1,30 +1,23 @@
1/******************************************************************************* 1/* Intel PRO/1000 Linux driver
2 2 * Copyright(c) 1999 - 2014 Intel Corporation.
3 Intel PRO/1000 Linux driver 3 *
4 Copyright(c) 1999 - 2013 Intel Corporation. 4 * This program is free software; you can redistribute it and/or modify it
5 5 * under the terms and conditions of the GNU General Public License,
6 This program is free software; you can redistribute it and/or modify it 6 * version 2, as published by the Free Software Foundation.
7 under the terms and conditions of the GNU General Public License, 7 *
8 version 2, as published by the Free Software Foundation. 8 * This program is distributed in the hope it will be useful, but WITHOUT
9 9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 This program is distributed in the hope it will be useful, but WITHOUT 10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * more details.
12 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 12 *
13 more details. 13 * The full GNU General Public License is included in this distribution in
14 14 * the file called "COPYING".
15 You should have received a copy of the GNU General Public License along with 15 *
16 this program; if not, write to the Free Software Foundation, Inc., 16 * Contact Information:
17 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. 17 * Linux NICS <linux.nics@intel.com>
18 18 * e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
19 The full GNU General Public License is included in this distribution in 19 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
20 the file called "COPYING". 20 */
21
22 Contact Information:
23 Linux NICS <linux.nics@intel.com>
24 e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
25 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
26
27*******************************************************************************/
28 21
29/* 82571EB Gigabit Ethernet Controller 22/* 82571EB Gigabit Ethernet Controller
30 * 82571EB Gigabit Ethernet Controller (Copper) 23 * 82571EB Gigabit Ethernet Controller (Copper)
diff --git a/drivers/net/ethernet/intel/e1000e/82571.h b/drivers/net/ethernet/intel/e1000e/82571.h
index 08e24dc3dc0e..2e758f796d60 100644
--- a/drivers/net/ethernet/intel/e1000e/82571.h
+++ b/drivers/net/ethernet/intel/e1000e/82571.h
@@ -1,30 +1,23 @@
1/******************************************************************************* 1/* Intel PRO/1000 Linux driver
2 2 * Copyright(c) 1999 - 2014 Intel Corporation.
3 Intel PRO/1000 Linux driver 3 *
4 Copyright(c) 1999 - 2013 Intel Corporation. 4 * This program is free software; you can redistribute it and/or modify it
5 5 * under the terms and conditions of the GNU General Public License,
6 This program is free software; you can redistribute it and/or modify it 6 * version 2, as published by the Free Software Foundation.
7 under the terms and conditions of the GNU General Public License, 7 *
8 version 2, as published by the Free Software Foundation. 8 * This program is distributed in the hope it will be useful, but WITHOUT
9 9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 This program is distributed in the hope it will be useful, but WITHOUT 10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * more details.
12 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 12 *
13 more details. 13 * The full GNU General Public License is included in this distribution in
14 14 * the file called "COPYING".
15 You should have received a copy of the GNU General Public License along with 15 *
16 this program; if not, write to the Free Software Foundation, Inc., 16 * Contact Information:
17 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. 17 * Linux NICS <linux.nics@intel.com>
18 18 * e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
19 The full GNU General Public License is included in this distribution in 19 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
20 the file called "COPYING". 20 */
21
22 Contact Information:
23 Linux NICS <linux.nics@intel.com>
24 e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
25 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
26
27*******************************************************************************/
28 21
29#ifndef _E1000E_82571_H_ 22#ifndef _E1000E_82571_H_
30#define _E1000E_82571_H_ 23#define _E1000E_82571_H_
diff --git a/drivers/net/ethernet/intel/e1000e/Makefile b/drivers/net/ethernet/intel/e1000e/Makefile
index c2dcfcc10857..106de493373c 100644
--- a/drivers/net/ethernet/intel/e1000e/Makefile
+++ b/drivers/net/ethernet/intel/e1000e/Makefile
@@ -1,7 +1,7 @@
1################################################################################ 1################################################################################
2# 2#
3# Intel PRO/1000 Linux driver 3# Intel PRO/1000 Linux driver
4# Copyright(c) 1999 - 2013 Intel Corporation. 4# Copyright(c) 1999 - 2014 Intel Corporation.
5# 5#
6# This program is free software; you can redistribute it and/or modify it 6# This program is free software; you can redistribute it and/or modify it
7# under the terms and conditions of the GNU General Public License, 7# under the terms and conditions of the GNU General Public License,
@@ -12,9 +12,8 @@
12# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 12# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13# more details. 13# more details.
14# 14#
15# You should have received a copy of the GNU General Public License along with 15# You should have received a copy of the GNU General Public License
16# this program; if not, write to the Free Software Foundation, Inc., 16# along with this program; if not, see <http://www.gnu.org/licenses/>.
17# 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
18# 17#
19# The full GNU General Public License is included in this distribution in 18# The full GNU General Public License is included in this distribution in
20# the file called "COPYING". 19# the file called "COPYING".
diff --git a/drivers/net/ethernet/intel/e1000e/defines.h b/drivers/net/ethernet/intel/e1000e/defines.h
index 351c94a0cf74..d18e89212575 100644
--- a/drivers/net/ethernet/intel/e1000e/defines.h
+++ b/drivers/net/ethernet/intel/e1000e/defines.h
@@ -1,30 +1,23 @@
1/******************************************************************************* 1/* Intel PRO/1000 Linux driver
2 2 * Copyright(c) 1999 - 2014 Intel Corporation.
3 Intel PRO/1000 Linux driver 3 *
4 Copyright(c) 1999 - 2013 Intel Corporation. 4 * This program is free software; you can redistribute it and/or modify it
5 5 * under the terms and conditions of the GNU General Public License,
6 This program is free software; you can redistribute it and/or modify it 6 * version 2, as published by the Free Software Foundation.
7 under the terms and conditions of the GNU General Public License, 7 *
8 version 2, as published by the Free Software Foundation. 8 * This program is distributed in the hope it will be useful, but WITHOUT
9 9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 This program is distributed in the hope it will be useful, but WITHOUT 10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * more details.
12 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 12 *
13 more details. 13 * The full GNU General Public License is included in this distribution in
14 14 * the file called "COPYING".
15 You should have received a copy of the GNU General Public License along with 15 *
16 this program; if not, write to the Free Software Foundation, Inc., 16 * Contact Information:
17 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. 17 * Linux NICS <linux.nics@intel.com>
18 18 * e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
19 The full GNU General Public License is included in this distribution in 19 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
20 the file called "COPYING". 20 */
21
22 Contact Information:
23 Linux NICS <linux.nics@intel.com>
24 e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
25 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
26
27*******************************************************************************/
28 21
29#ifndef _E1000_DEFINES_H_ 22#ifndef _E1000_DEFINES_H_
30#define _E1000_DEFINES_H_ 23#define _E1000_DEFINES_H_
@@ -35,9 +28,11 @@
35 28
36/* Definitions for power management and wakeup registers */ 29/* Definitions for power management and wakeup registers */
37/* Wake Up Control */ 30/* Wake Up Control */
38#define E1000_WUC_APME 0x00000001 /* APM Enable */ 31#define E1000_WUC_APME 0x00000001 /* APM Enable */
39#define E1000_WUC_PME_EN 0x00000002 /* PME Enable */ 32#define E1000_WUC_PME_EN 0x00000002 /* PME Enable */
40#define E1000_WUC_PHY_WAKE 0x00000100 /* if PHY supports wakeup */ 33#define E1000_WUC_PME_STATUS 0x00000004 /* PME Status */
34#define E1000_WUC_APMPME 0x00000008 /* Assert PME on APM Wakeup */
35#define E1000_WUC_PHY_WAKE 0x00000100 /* if PHY supports wakeup */
41 36
42/* Wake Up Filter Control */ 37/* Wake Up Filter Control */
43#define E1000_WUFC_LNKC 0x00000001 /* Link Status Change Wakeup Enable */ 38#define E1000_WUFC_LNKC 0x00000001 /* Link Status Change Wakeup Enable */
diff --git a/drivers/net/ethernet/intel/e1000e/e1000.h b/drivers/net/ethernet/intel/e1000e/e1000.h
index 0150f7fc893d..5325e3e2154e 100644
--- a/drivers/net/ethernet/intel/e1000e/e1000.h
+++ b/drivers/net/ethernet/intel/e1000e/e1000.h
@@ -1,30 +1,23 @@
1/******************************************************************************* 1/* Intel PRO/1000 Linux driver
2 2 * Copyright(c) 1999 - 2014 Intel Corporation.
3 Intel PRO/1000 Linux driver 3 *
4 Copyright(c) 1999 - 2013 Intel Corporation. 4 * This program is free software; you can redistribute it and/or modify it
5 5 * under the terms and conditions of the GNU General Public License,
6 This program is free software; you can redistribute it and/or modify it 6 * version 2, as published by the Free Software Foundation.
7 under the terms and conditions of the GNU General Public License, 7 *
8 version 2, as published by the Free Software Foundation. 8 * This program is distributed in the hope it will be useful, but WITHOUT
9 9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 This program is distributed in the hope it will be useful, but WITHOUT 10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * more details.
12 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 12 *
13 more details. 13 * The full GNU General Public License is included in this distribution in
14 14 * the file called "COPYING".
15 You should have received a copy of the GNU General Public License along with 15 *
16 this program; if not, write to the Free Software Foundation, Inc., 16 * Contact Information:
17 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. 17 * Linux NICS <linux.nics@intel.com>
18 18 * e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
19 The full GNU General Public License is included in this distribution in 19 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
20 the file called "COPYING". 20 */
21
22 Contact Information:
23 Linux NICS <linux.nics@intel.com>
24 e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
25 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
26
27*******************************************************************************/
28 21
29/* Linux PRO/1000 Ethernet Driver main header file */ 22/* Linux PRO/1000 Ethernet Driver main header file */
30 23
@@ -333,7 +326,6 @@ struct e1000_adapter {
333 struct work_struct update_phy_task; 326 struct work_struct update_phy_task;
334 struct work_struct print_hang_task; 327 struct work_struct print_hang_task;
335 328
336 bool idle_check;
337 int phy_hang_count; 329 int phy_hang_count;
338 330
339 u16 tx_ring_count; 331 u16 tx_ring_count;
@@ -476,7 +468,7 @@ void e1000e_check_options(struct e1000_adapter *adapter);
476void e1000e_set_ethtool_ops(struct net_device *netdev); 468void e1000e_set_ethtool_ops(struct net_device *netdev);
477 469
478int e1000e_up(struct e1000_adapter *adapter); 470int e1000e_up(struct e1000_adapter *adapter);
479void e1000e_down(struct e1000_adapter *adapter); 471void e1000e_down(struct e1000_adapter *adapter, bool reset);
480void e1000e_reinit_locked(struct e1000_adapter *adapter); 472void e1000e_reinit_locked(struct e1000_adapter *adapter);
481void e1000e_reset(struct e1000_adapter *adapter); 473void e1000e_reset(struct e1000_adapter *adapter);
482void e1000e_power_up_phy(struct e1000_adapter *adapter); 474void e1000e_power_up_phy(struct e1000_adapter *adapter);
diff --git a/drivers/net/ethernet/intel/e1000e/ethtool.c b/drivers/net/ethernet/intel/e1000e/ethtool.c
index d14c8f53384c..3c2898d0c2aa 100644
--- a/drivers/net/ethernet/intel/e1000e/ethtool.c
+++ b/drivers/net/ethernet/intel/e1000e/ethtool.c
@@ -1,30 +1,23 @@
1/******************************************************************************* 1/* Intel PRO/1000 Linux driver
2 2 * Copyright(c) 1999 - 2014 Intel Corporation.
3 Intel PRO/1000 Linux driver 3 *
4 Copyright(c) 1999 - 2013 Intel Corporation. 4 * This program is free software; you can redistribute it and/or modify it
5 5 * under the terms and conditions of the GNU General Public License,
6 This program is free software; you can redistribute it and/or modify it 6 * version 2, as published by the Free Software Foundation.
7 under the terms and conditions of the GNU General Public License, 7 *
8 version 2, as published by the Free Software Foundation. 8 * This program is distributed in the hope it will be useful, but WITHOUT
9 9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 This program is distributed in the hope it will be useful, but WITHOUT 10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * more details.
12 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 12 *
13 more details. 13 * The full GNU General Public License is included in this distribution in
14 14 * the file called "COPYING".
15 You should have received a copy of the GNU General Public License along with 15 *
16 this program; if not, write to the Free Software Foundation, Inc., 16 * Contact Information:
17 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. 17 * Linux NICS <linux.nics@intel.com>
18 18 * e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
19 The full GNU General Public License is included in this distribution in 19 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
20 the file called "COPYING". 20 */
21
22 Contact Information:
23 Linux NICS <linux.nics@intel.com>
24 e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
25 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
26
27*******************************************************************************/
28 21
29/* ethtool support for e1000 */ 22/* ethtool support for e1000 */
30 23
@@ -332,7 +325,7 @@ static int e1000_set_settings(struct net_device *netdev,
332 325
333 /* reset the link */ 326 /* reset the link */
334 if (netif_running(adapter->netdev)) { 327 if (netif_running(adapter->netdev)) {
335 e1000e_down(adapter); 328 e1000e_down(adapter, true);
336 e1000e_up(adapter); 329 e1000e_up(adapter);
337 } else { 330 } else {
338 e1000e_reset(adapter); 331 e1000e_reset(adapter);
@@ -380,7 +373,7 @@ static int e1000_set_pauseparam(struct net_device *netdev,
380 if (adapter->fc_autoneg == AUTONEG_ENABLE) { 373 if (adapter->fc_autoneg == AUTONEG_ENABLE) {
381 hw->fc.requested_mode = e1000_fc_default; 374 hw->fc.requested_mode = e1000_fc_default;
382 if (netif_running(adapter->netdev)) { 375 if (netif_running(adapter->netdev)) {
383 e1000e_down(adapter); 376 e1000e_down(adapter, true);
384 e1000e_up(adapter); 377 e1000e_up(adapter);
385 } else { 378 } else {
386 e1000e_reset(adapter); 379 e1000e_reset(adapter);
@@ -726,7 +719,7 @@ static int e1000_set_ringparam(struct net_device *netdev,
726 719
727 pm_runtime_get_sync(netdev->dev.parent); 720 pm_runtime_get_sync(netdev->dev.parent);
728 721
729 e1000e_down(adapter); 722 e1000e_down(adapter, true);
730 723
731 /* We can't just free everything and then setup again, because the 724 /* We can't just free everything and then setup again, because the
732 * ISRs in MSI-X mode get passed pointers to the Tx and Rx ring 725 * ISRs in MSI-X mode get passed pointers to the Tx and Rx ring
@@ -924,15 +917,21 @@ static int e1000_reg_test(struct e1000_adapter *adapter, u64 *data)
924 } 917 }
925 if (mac->type == e1000_pch2lan) { 918 if (mac->type == e1000_pch2lan) {
926 /* SHRAH[0,1,2] different than previous */ 919 /* SHRAH[0,1,2] different than previous */
927 if (i == 7) 920 if (i == 1)
928 mask &= 0xFFF4FFFF; 921 mask &= 0xFFF4FFFF;
929 /* SHRAH[3] different than SHRAH[0,1,2] */ 922 /* SHRAH[3] different than SHRAH[0,1,2] */
930 if (i == 10) 923 if (i == 4)
931 mask |= (1 << 30); 924 mask |= (1 << 30);
925 /* RAR[1-6] owned by management engine - skipping */
926 if (i > 0)
927 i += 6;
932 } 928 }
933 929
934 REG_PATTERN_TEST_ARRAY(E1000_RA, ((i << 1) + 1), mask, 930 REG_PATTERN_TEST_ARRAY(E1000_RA, ((i << 1) + 1), mask,
935 0xFFFFFFFF); 931 0xFFFFFFFF);
932 /* reset index to actual value */
933 if ((mac->type == e1000_pch2lan) && (i > 6))
934 i -= 6;
936 } 935 }
937 936
938 for (i = 0; i < mac->mta_reg_count; i++) 937 for (i = 0; i < mac->mta_reg_count; i++)
diff --git a/drivers/net/ethernet/intel/e1000e/hw.h b/drivers/net/ethernet/intel/e1000e/hw.h
index b7f38435d1fd..6b3de5f39a97 100644
--- a/drivers/net/ethernet/intel/e1000e/hw.h
+++ b/drivers/net/ethernet/intel/e1000e/hw.h
@@ -1,30 +1,23 @@
1/******************************************************************************* 1/* Intel PRO/1000 Linux driver
2 2 * Copyright(c) 1999 - 2014 Intel Corporation.
3 Intel PRO/1000 Linux driver 3 *
4 Copyright(c) 1999 - 2013 Intel Corporation. 4 * This program is free software; you can redistribute it and/or modify it
5 5 * under the terms and conditions of the GNU General Public License,
6 This program is free software; you can redistribute it and/or modify it 6 * version 2, as published by the Free Software Foundation.
7 under the terms and conditions of the GNU General Public License, 7 *
8 version 2, as published by the Free Software Foundation. 8 * This program is distributed in the hope it will be useful, but WITHOUT
9 9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 This program is distributed in the hope it will be useful, but WITHOUT 10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * more details.
12 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 12 *
13 more details. 13 * The full GNU General Public License is included in this distribution in
14 14 * the file called "COPYING".
15 You should have received a copy of the GNU General Public License along with 15 *
16 this program; if not, write to the Free Software Foundation, Inc., 16 * Contact Information:
17 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. 17 * Linux NICS <linux.nics@intel.com>
18 18 * e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
19 The full GNU General Public License is included in this distribution in 19 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
20 the file called "COPYING". 20 */
21
22 Contact Information:
23 Linux NICS <linux.nics@intel.com>
24 e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
25 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
26
27*******************************************************************************/
28 21
29#ifndef _E1000_HW_H_ 22#ifndef _E1000_HW_H_
30#define _E1000_HW_H_ 23#define _E1000_HW_H_
@@ -655,12 +648,20 @@ struct e1000_shadow_ram {
655 648
656#define E1000_ICH8_SHADOW_RAM_WORDS 2048 649#define E1000_ICH8_SHADOW_RAM_WORDS 2048
657 650
651/* I218 PHY Ultra Low Power (ULP) states */
652enum e1000_ulp_state {
653 e1000_ulp_state_unknown,
654 e1000_ulp_state_off,
655 e1000_ulp_state_on,
656};
657
658struct e1000_dev_spec_ich8lan { 658struct e1000_dev_spec_ich8lan {
659 bool kmrn_lock_loss_workaround_enabled; 659 bool kmrn_lock_loss_workaround_enabled;
660 struct e1000_shadow_ram shadow_ram[E1000_ICH8_SHADOW_RAM_WORDS]; 660 struct e1000_shadow_ram shadow_ram[E1000_ICH8_SHADOW_RAM_WORDS];
661 bool nvm_k1_enabled; 661 bool nvm_k1_enabled;
662 bool eee_disable; 662 bool eee_disable;
663 u16 eee_lp_ability; 663 u16 eee_lp_ability;
664 enum e1000_ulp_state ulp_state;
664}; 665};
665 666
666struct e1000_hw { 667struct e1000_hw {
diff --git a/drivers/net/ethernet/intel/e1000e/ich8lan.c b/drivers/net/ethernet/intel/e1000e/ich8lan.c
index 42f0f6717511..9866f264f55e 100644
--- a/drivers/net/ethernet/intel/e1000e/ich8lan.c
+++ b/drivers/net/ethernet/intel/e1000e/ich8lan.c
@@ -1,30 +1,23 @@
1/******************************************************************************* 1/* Intel PRO/1000 Linux driver
2 2 * Copyright(c) 1999 - 2014 Intel Corporation.
3 Intel PRO/1000 Linux driver 3 *
4 Copyright(c) 1999 - 2013 Intel Corporation. 4 * This program is free software; you can redistribute it and/or modify it
5 5 * under the terms and conditions of the GNU General Public License,
6 This program is free software; you can redistribute it and/or modify it 6 * version 2, as published by the Free Software Foundation.
7 under the terms and conditions of the GNU General Public License, 7 *
8 version 2, as published by the Free Software Foundation. 8 * This program is distributed in the hope it will be useful, but WITHOUT
9 9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 This program is distributed in the hope it will be useful, but WITHOUT 10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * more details.
12 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 12 *
13 more details. 13 * The full GNU General Public License is included in this distribution in
14 14 * the file called "COPYING".
15 You should have received a copy of the GNU General Public License along with 15 *
16 this program; if not, write to the Free Software Foundation, Inc., 16 * Contact Information:
17 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. 17 * Linux NICS <linux.nics@intel.com>
18 18 * e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
19 The full GNU General Public License is included in this distribution in 19 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
20 the file called "COPYING". 20 */
21
22 Contact Information:
23 Linux NICS <linux.nics@intel.com>
24 e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
25 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
26
27*******************************************************************************/
28 21
29/* 82562G 10/100 Network Connection 22/* 82562G 10/100 Network Connection
30 * 82562G-2 10/100 Network Connection 23 * 82562G-2 10/100 Network Connection
@@ -53,6 +46,14 @@
53 * 82578DC Gigabit Network Connection 46 * 82578DC Gigabit Network Connection
54 * 82579LM Gigabit Network Connection 47 * 82579LM Gigabit Network Connection
55 * 82579V Gigabit Network Connection 48 * 82579V Gigabit Network Connection
49 * Ethernet Connection I217-LM
50 * Ethernet Connection I217-V
51 * Ethernet Connection I218-V
52 * Ethernet Connection I218-LM
53 * Ethernet Connection (2) I218-LM
54 * Ethernet Connection (2) I218-V
55 * Ethernet Connection (3) I218-LM
56 * Ethernet Connection (3) I218-V
56 */ 57 */
57 58
58#include "e1000.h" 59#include "e1000.h"
@@ -142,7 +143,9 @@ static void e1000_rar_set_pch2lan(struct e1000_hw *hw, u8 *addr, u32 index);
142static void e1000_rar_set_pch_lpt(struct e1000_hw *hw, u8 *addr, u32 index); 143static void e1000_rar_set_pch_lpt(struct e1000_hw *hw, u8 *addr, u32 index);
143static s32 e1000_k1_workaround_lv(struct e1000_hw *hw); 144static s32 e1000_k1_workaround_lv(struct e1000_hw *hw);
144static void e1000_gate_hw_phy_config_ich8lan(struct e1000_hw *hw, bool gate); 145static void e1000_gate_hw_phy_config_ich8lan(struct e1000_hw *hw, bool gate);
146static s32 e1000_disable_ulp_lpt_lp(struct e1000_hw *hw, bool force);
145static s32 e1000_setup_copper_link_pch_lpt(struct e1000_hw *hw); 147static s32 e1000_setup_copper_link_pch_lpt(struct e1000_hw *hw);
148static s32 e1000_oem_bits_config_ich8lan(struct e1000_hw *hw, bool d0_state);
146 149
147static inline u16 __er16flash(struct e1000_hw *hw, unsigned long reg) 150static inline u16 __er16flash(struct e1000_hw *hw, unsigned long reg)
148{ 151{
@@ -239,6 +242,47 @@ out:
239} 242}
240 243
241/** 244/**
245 * e1000_toggle_lanphypc_pch_lpt - toggle the LANPHYPC pin value
246 * @hw: pointer to the HW structure
247 *
248 * Toggling the LANPHYPC pin value fully power-cycles the PHY and is
249 * used to reset the PHY to a quiescent state when necessary.
250 **/
251static void e1000_toggle_lanphypc_pch_lpt(struct e1000_hw *hw)
252{
253 u32 mac_reg;
254
255 /* Set Phy Config Counter to 50msec */
256 mac_reg = er32(FEXTNVM3);
257 mac_reg &= ~E1000_FEXTNVM3_PHY_CFG_COUNTER_MASK;
258 mac_reg |= E1000_FEXTNVM3_PHY_CFG_COUNTER_50MSEC;
259 ew32(FEXTNVM3, mac_reg);
260
261 /* Toggle LANPHYPC Value bit */
262 mac_reg = er32(CTRL);
263 mac_reg |= E1000_CTRL_LANPHYPC_OVERRIDE;
264 mac_reg &= ~E1000_CTRL_LANPHYPC_VALUE;
265 ew32(CTRL, mac_reg);
266 e1e_flush();
267 usleep_range(10, 20);
268 mac_reg &= ~E1000_CTRL_LANPHYPC_OVERRIDE;
269 ew32(CTRL, mac_reg);
270 e1e_flush();
271
272 if (hw->mac.type < e1000_pch_lpt) {
273 msleep(50);
274 } else {
275 u16 count = 20;
276
277 do {
278 usleep_range(5000, 10000);
279 } while (!(er32(CTRL_EXT) & E1000_CTRL_EXT_LPCD) && count--);
280
281 msleep(30);
282 }
283}
284
285/**
242 * e1000_init_phy_workarounds_pchlan - PHY initialization workarounds 286 * e1000_init_phy_workarounds_pchlan - PHY initialization workarounds
243 * @hw: pointer to the HW structure 287 * @hw: pointer to the HW structure
244 * 288 *
@@ -247,6 +291,7 @@ out:
247 **/ 291 **/
248static s32 e1000_init_phy_workarounds_pchlan(struct e1000_hw *hw) 292static s32 e1000_init_phy_workarounds_pchlan(struct e1000_hw *hw)
249{ 293{
294 struct e1000_adapter *adapter = hw->adapter;
250 u32 mac_reg, fwsm = er32(FWSM); 295 u32 mac_reg, fwsm = er32(FWSM);
251 s32 ret_val; 296 s32 ret_val;
252 297
@@ -255,6 +300,12 @@ static s32 e1000_init_phy_workarounds_pchlan(struct e1000_hw *hw)
255 */ 300 */
256 e1000_gate_hw_phy_config_ich8lan(hw, true); 301 e1000_gate_hw_phy_config_ich8lan(hw, true);
257 302
303 /* It is not possible to be certain of the current state of ULP
304 * so forcibly disable it.
305 */
306 hw->dev_spec.ich8lan.ulp_state = e1000_ulp_state_unknown;
307 e1000_disable_ulp_lpt_lp(hw, true);
308
258 ret_val = hw->phy.ops.acquire(hw); 309 ret_val = hw->phy.ops.acquire(hw);
259 if (ret_val) { 310 if (ret_val) {
260 e_dbg("Failed to initialize PHY flow\n"); 311 e_dbg("Failed to initialize PHY flow\n");
@@ -300,33 +351,9 @@ static s32 e1000_init_phy_workarounds_pchlan(struct e1000_hw *hw)
300 break; 351 break;
301 } 352 }
302 353
303 e_dbg("Toggling LANPHYPC\n");
304
305 /* Set Phy Config Counter to 50msec */
306 mac_reg = er32(FEXTNVM3);
307 mac_reg &= ~E1000_FEXTNVM3_PHY_CFG_COUNTER_MASK;
308 mac_reg |= E1000_FEXTNVM3_PHY_CFG_COUNTER_50MSEC;
309 ew32(FEXTNVM3, mac_reg);
310
311 /* Toggle LANPHYPC Value bit */ 354 /* Toggle LANPHYPC Value bit */
312 mac_reg = er32(CTRL); 355 e1000_toggle_lanphypc_pch_lpt(hw);
313 mac_reg |= E1000_CTRL_LANPHYPC_OVERRIDE; 356 if (hw->mac.type >= e1000_pch_lpt) {
314 mac_reg &= ~E1000_CTRL_LANPHYPC_VALUE;
315 ew32(CTRL, mac_reg);
316 e1e_flush();
317 usleep_range(10, 20);
318 mac_reg &= ~E1000_CTRL_LANPHYPC_OVERRIDE;
319 ew32(CTRL, mac_reg);
320 e1e_flush();
321 if (hw->mac.type < e1000_pch_lpt) {
322 msleep(50);
323 } else {
324 u16 count = 20;
325 do {
326 usleep_range(5000, 10000);
327 } while (!(er32(CTRL_EXT) &
328 E1000_CTRL_EXT_LPCD) && count--);
329 usleep_range(30000, 60000);
330 if (e1000_phy_is_accessible_pchlan(hw)) 357 if (e1000_phy_is_accessible_pchlan(hw))
331 break; 358 break;
332 359
@@ -349,12 +376,31 @@ static s32 e1000_init_phy_workarounds_pchlan(struct e1000_hw *hw)
349 376
350 hw->phy.ops.release(hw); 377 hw->phy.ops.release(hw);
351 if (!ret_val) { 378 if (!ret_val) {
379
380 /* Check to see if able to reset PHY. Print error if not */
381 if (hw->phy.ops.check_reset_block(hw)) {
382 e_err("Reset blocked by ME\n");
383 goto out;
384 }
385
352 /* Reset the PHY before any access to it. Doing so, ensures 386 /* Reset the PHY before any access to it. Doing so, ensures
353 * that the PHY is in a known good state before we read/write 387 * that the PHY is in a known good state before we read/write
354 * PHY registers. The generic reset is sufficient here, 388 * PHY registers. The generic reset is sufficient here,
355 * because we haven't determined the PHY type yet. 389 * because we haven't determined the PHY type yet.
356 */ 390 */
357 ret_val = e1000e_phy_hw_reset_generic(hw); 391 ret_val = e1000e_phy_hw_reset_generic(hw);
392 if (ret_val)
393 goto out;
394
395 /* On a successful reset, possibly need to wait for the PHY
396 * to quiesce to an accessible state before returning control
397 * to the calling function. If the PHY does not quiesce, then
398 * return E1000E_BLK_PHY_RESET, as this is the condition that
399 * the PHY is in.
400 */
401 ret_val = hw->phy.ops.check_reset_block(hw);
402 if (ret_val)
403 e_err("ME blocked access to PHY after reset\n");
358 } 404 }
359 405
360out: 406out:
@@ -724,8 +770,14 @@ s32 e1000_write_emi_reg_locked(struct e1000_hw *hw, u16 addr, u16 data)
724 * Enable/disable EEE based on setting in dev_spec structure, the duplex of 770 * Enable/disable EEE based on setting in dev_spec structure, the duplex of
725 * the link and the EEE capabilities of the link partner. The LPI Control 771 * the link and the EEE capabilities of the link partner. The LPI Control
726 * register bits will remain set only if/when link is up. 772 * register bits will remain set only if/when link is up.
773 *
774 * EEE LPI must not be asserted earlier than one second after link is up.
775 * On 82579, EEE LPI should not be enabled until such time otherwise there
776 * can be link issues with some switches. Other devices can have EEE LPI
777 * enabled immediately upon link up since they have a timer in hardware which
778 * prevents LPI from being asserted too early.
727 **/ 779 **/
728static s32 e1000_set_eee_pchlan(struct e1000_hw *hw) 780s32 e1000_set_eee_pchlan(struct e1000_hw *hw)
729{ 781{
730 struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan; 782 struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
731 s32 ret_val; 783 s32 ret_val;
@@ -979,6 +1031,253 @@ static s32 e1000_platform_pm_pch_lpt(struct e1000_hw *hw, bool link)
979} 1031}
980 1032
981/** 1033/**
1034 * e1000_enable_ulp_lpt_lp - configure Ultra Low Power mode for LynxPoint-LP
1035 * @hw: pointer to the HW structure
1036 * @to_sx: boolean indicating a system power state transition to Sx
1037 *
1038 * When link is down, configure ULP mode to significantly reduce the power
1039 * to the PHY. If on a Manageability Engine (ME) enabled system, tell the
1040 * ME firmware to start the ULP configuration. If not on an ME enabled
1041 * system, configure the ULP mode by software.
1042 */
1043s32 e1000_enable_ulp_lpt_lp(struct e1000_hw *hw, bool to_sx)
1044{
1045 u32 mac_reg;
1046 s32 ret_val = 0;
1047 u16 phy_reg;
1048
1049 if ((hw->mac.type < e1000_pch_lpt) ||
1050 (hw->adapter->pdev->device == E1000_DEV_ID_PCH_LPT_I217_LM) ||
1051 (hw->adapter->pdev->device == E1000_DEV_ID_PCH_LPT_I217_V) ||
1052 (hw->adapter->pdev->device == E1000_DEV_ID_PCH_I218_LM2) ||
1053 (hw->adapter->pdev->device == E1000_DEV_ID_PCH_I218_V2) ||
1054 (hw->dev_spec.ich8lan.ulp_state == e1000_ulp_state_on))
1055 return 0;
1056
1057 if (er32(FWSM) & E1000_ICH_FWSM_FW_VALID) {
1058 /* Request ME configure ULP mode in the PHY */
1059 mac_reg = er32(H2ME);
1060 mac_reg |= E1000_H2ME_ULP | E1000_H2ME_ENFORCE_SETTINGS;
1061 ew32(H2ME, mac_reg);
1062
1063 goto out;
1064 }
1065
1066 if (!to_sx) {
1067 int i = 0;
1068
1069 /* Poll up to 5 seconds for Cable Disconnected indication */
1070 while (!(er32(FEXT) & E1000_FEXT_PHY_CABLE_DISCONNECTED)) {
1071 /* Bail if link is re-acquired */
1072 if (er32(STATUS) & E1000_STATUS_LU)
1073 return -E1000_ERR_PHY;
1074
1075 if (i++ == 100)
1076 break;
1077
1078 msleep(50);
1079 }
1080 e_dbg("CABLE_DISCONNECTED %s set after %dmsec\n",
1081 (er32(FEXT) &
1082 E1000_FEXT_PHY_CABLE_DISCONNECTED) ? "" : "not", i * 50);
1083 }
1084
1085 ret_val = hw->phy.ops.acquire(hw);
1086 if (ret_val)
1087 goto out;
1088
1089 /* Force SMBus mode in PHY */
1090 ret_val = e1000_read_phy_reg_hv_locked(hw, CV_SMB_CTRL, &phy_reg);
1091 if (ret_val)
1092 goto release;
1093 phy_reg |= CV_SMB_CTRL_FORCE_SMBUS;
1094 e1000_write_phy_reg_hv_locked(hw, CV_SMB_CTRL, phy_reg);
1095
1096 /* Force SMBus mode in MAC */
1097 mac_reg = er32(CTRL_EXT);
1098 mac_reg |= E1000_CTRL_EXT_FORCE_SMBUS;
1099 ew32(CTRL_EXT, mac_reg);
1100
1101 /* Set Inband ULP Exit, Reset to SMBus mode and
1102 * Disable SMBus Release on PERST# in PHY
1103 */
1104 ret_val = e1000_read_phy_reg_hv_locked(hw, I218_ULP_CONFIG1, &phy_reg);
1105 if (ret_val)
1106 goto release;
1107 phy_reg |= (I218_ULP_CONFIG1_RESET_TO_SMBUS |
1108 I218_ULP_CONFIG1_DISABLE_SMB_PERST);
1109 if (to_sx) {
1110 if (er32(WUFC) & E1000_WUFC_LNKC)
1111 phy_reg |= I218_ULP_CONFIG1_WOL_HOST;
1112
1113 phy_reg |= I218_ULP_CONFIG1_STICKY_ULP;
1114 } else {
1115 phy_reg |= I218_ULP_CONFIG1_INBAND_EXIT;
1116 }
1117 e1000_write_phy_reg_hv_locked(hw, I218_ULP_CONFIG1, phy_reg);
1118
1119 /* Set Disable SMBus Release on PERST# in MAC */
1120 mac_reg = er32(FEXTNVM7);
1121 mac_reg |= E1000_FEXTNVM7_DISABLE_SMB_PERST;
1122 ew32(FEXTNVM7, mac_reg);
1123
1124 /* Commit ULP changes in PHY by starting auto ULP configuration */
1125 phy_reg |= I218_ULP_CONFIG1_START;
1126 e1000_write_phy_reg_hv_locked(hw, I218_ULP_CONFIG1, phy_reg);
1127release:
1128 hw->phy.ops.release(hw);
1129out:
1130 if (ret_val)
1131 e_dbg("Error in ULP enable flow: %d\n", ret_val);
1132 else
1133 hw->dev_spec.ich8lan.ulp_state = e1000_ulp_state_on;
1134
1135 return ret_val;
1136}
1137
1138/**
1139 * e1000_disable_ulp_lpt_lp - unconfigure Ultra Low Power mode for LynxPoint-LP
1140 * @hw: pointer to the HW structure
1141 * @force: boolean indicating whether or not to force disabling ULP
1142 *
1143 * Un-configure ULP mode when link is up, the system is transitioned from
1144 * Sx or the driver is unloaded. If on a Manageability Engine (ME) enabled
1145 * system, poll for an indication from ME that ULP has been un-configured.
1146 * If not on an ME enabled system, un-configure the ULP mode by software.
1147 *
1148 * During nominal operation, this function is called when link is acquired
1149 * to disable ULP mode (force=false); otherwise, for example when unloading
1150 * the driver or during Sx->S0 transitions, this is called with force=true
1151 * to forcibly disable ULP.
1152 */
1153static s32 e1000_disable_ulp_lpt_lp(struct e1000_hw *hw, bool force)
1154{
1155 s32 ret_val = 0;
1156 u32 mac_reg;
1157 u16 phy_reg;
1158 int i = 0;
1159
1160 if ((hw->mac.type < e1000_pch_lpt) ||
1161 (hw->adapter->pdev->device == E1000_DEV_ID_PCH_LPT_I217_LM) ||
1162 (hw->adapter->pdev->device == E1000_DEV_ID_PCH_LPT_I217_V) ||
1163 (hw->adapter->pdev->device == E1000_DEV_ID_PCH_I218_LM2) ||
1164 (hw->adapter->pdev->device == E1000_DEV_ID_PCH_I218_V2) ||
1165 (hw->dev_spec.ich8lan.ulp_state == e1000_ulp_state_off))
1166 return 0;
1167
1168 if (er32(FWSM) & E1000_ICH_FWSM_FW_VALID) {
1169 if (force) {
1170 /* Request ME un-configure ULP mode in the PHY */
1171 mac_reg = er32(H2ME);
1172 mac_reg &= ~E1000_H2ME_ULP;
1173 mac_reg |= E1000_H2ME_ENFORCE_SETTINGS;
1174 ew32(H2ME, mac_reg);
1175 }
1176
1177 /* Poll up to 100msec for ME to clear ULP_CFG_DONE */
1178 while (er32(FWSM) & E1000_FWSM_ULP_CFG_DONE) {
1179 if (i++ == 10) {
1180 ret_val = -E1000_ERR_PHY;
1181 goto out;
1182 }
1183
1184 usleep_range(10000, 20000);
1185 }
1186 e_dbg("ULP_CONFIG_DONE cleared after %dmsec\n", i * 10);
1187
1188 if (force) {
1189 mac_reg = er32(H2ME);
1190 mac_reg &= ~E1000_H2ME_ENFORCE_SETTINGS;
1191 ew32(H2ME, mac_reg);
1192 } else {
1193 /* Clear H2ME.ULP after ME ULP configuration */
1194 mac_reg = er32(H2ME);
1195 mac_reg &= ~E1000_H2ME_ULP;
1196 ew32(H2ME, mac_reg);
1197 }
1198
1199 goto out;
1200 }
1201
1202 ret_val = hw->phy.ops.acquire(hw);
1203 if (ret_val)
1204 goto out;
1205
1206 if (force)
1207 /* Toggle LANPHYPC Value bit */
1208 e1000_toggle_lanphypc_pch_lpt(hw);
1209
1210 /* Unforce SMBus mode in PHY */
1211 ret_val = e1000_read_phy_reg_hv_locked(hw, CV_SMB_CTRL, &phy_reg);
1212 if (ret_val) {
1213 /* The MAC might be in PCIe mode, so temporarily force to
1214 * SMBus mode in order to access the PHY.
1215 */
1216 mac_reg = er32(CTRL_EXT);
1217 mac_reg |= E1000_CTRL_EXT_FORCE_SMBUS;
1218 ew32(CTRL_EXT, mac_reg);
1219
1220 msleep(50);
1221
1222 ret_val = e1000_read_phy_reg_hv_locked(hw, CV_SMB_CTRL,
1223 &phy_reg);
1224 if (ret_val)
1225 goto release;
1226 }
1227 phy_reg &= ~CV_SMB_CTRL_FORCE_SMBUS;
1228 e1000_write_phy_reg_hv_locked(hw, CV_SMB_CTRL, phy_reg);
1229
1230 /* Unforce SMBus mode in MAC */
1231 mac_reg = er32(CTRL_EXT);
1232 mac_reg &= ~E1000_CTRL_EXT_FORCE_SMBUS;
1233 ew32(CTRL_EXT, mac_reg);
1234
1235 /* When ULP mode was previously entered, K1 was disabled by the
1236 * hardware. Re-Enable K1 in the PHY when exiting ULP.
1237 */
1238 ret_val = e1000_read_phy_reg_hv_locked(hw, HV_PM_CTRL, &phy_reg);
1239 if (ret_val)
1240 goto release;
1241 phy_reg |= HV_PM_CTRL_K1_ENABLE;
1242 e1000_write_phy_reg_hv_locked(hw, HV_PM_CTRL, phy_reg);
1243
1244 /* Clear ULP enabled configuration */
1245 ret_val = e1000_read_phy_reg_hv_locked(hw, I218_ULP_CONFIG1, &phy_reg);
1246 if (ret_val)
1247 goto release;
1248 phy_reg &= ~(I218_ULP_CONFIG1_IND |
1249 I218_ULP_CONFIG1_STICKY_ULP |
1250 I218_ULP_CONFIG1_RESET_TO_SMBUS |
1251 I218_ULP_CONFIG1_WOL_HOST |
1252 I218_ULP_CONFIG1_INBAND_EXIT |
1253 I218_ULP_CONFIG1_DISABLE_SMB_PERST);
1254 e1000_write_phy_reg_hv_locked(hw, I218_ULP_CONFIG1, phy_reg);
1255
1256 /* Commit ULP changes by starting auto ULP configuration */
1257 phy_reg |= I218_ULP_CONFIG1_START;
1258 e1000_write_phy_reg_hv_locked(hw, I218_ULP_CONFIG1, phy_reg);
1259
1260 /* Clear Disable SMBus Release on PERST# in MAC */
1261 mac_reg = er32(FEXTNVM7);
1262 mac_reg &= ~E1000_FEXTNVM7_DISABLE_SMB_PERST;
1263 ew32(FEXTNVM7, mac_reg);
1264
1265release:
1266 hw->phy.ops.release(hw);
1267 if (force) {
1268 e1000_phy_hw_reset(hw);
1269 msleep(50);
1270 }
1271out:
1272 if (ret_val)
1273 e_dbg("Error in ULP disable flow: %d\n", ret_val);
1274 else
1275 hw->dev_spec.ich8lan.ulp_state = e1000_ulp_state_off;
1276
1277 return ret_val;
1278}
1279
1280/**
982 * e1000_check_for_copper_link_ich8lan - Check for link (Copper) 1281 * e1000_check_for_copper_link_ich8lan - Check for link (Copper)
983 * @hw: pointer to the HW structure 1282 * @hw: pointer to the HW structure
984 * 1283 *
@@ -1106,9 +1405,11 @@ static s32 e1000_check_for_copper_link_ich8lan(struct e1000_hw *hw)
1106 e1000e_check_downshift(hw); 1405 e1000e_check_downshift(hw);
1107 1406
1108 /* Enable/Disable EEE after link up */ 1407 /* Enable/Disable EEE after link up */
1109 ret_val = e1000_set_eee_pchlan(hw); 1408 if (hw->phy.type > e1000_phy_82579) {
1110 if (ret_val) 1409 ret_val = e1000_set_eee_pchlan(hw);
1111 return ret_val; 1410 if (ret_val)
1411 return ret_val;
1412 }
1112 1413
1113 /* If we are forcing speed/duplex, then we simply return since 1414 /* If we are forcing speed/duplex, then we simply return since
1114 * we have already determined whether we have link or not. 1415 * we have already determined whether we have link or not.
@@ -1374,7 +1675,7 @@ static void e1000_rar_set_pch2lan(struct e1000_hw *hw, u8 *addr, u32 index)
1374 /* RAR[1-6] are owned by manageability. Skip those and program the 1675 /* RAR[1-6] are owned by manageability. Skip those and program the
1375 * next address into the SHRA register array. 1676 * next address into the SHRA register array.
1376 */ 1677 */
1377 if (index < (u32)(hw->mac.rar_entry_count - 6)) { 1678 if (index < (u32)(hw->mac.rar_entry_count)) {
1378 s32 ret_val; 1679 s32 ret_val;
1379 1680
1380 ret_val = e1000_acquire_swflag_ich8lan(hw); 1681 ret_val = e1000_acquire_swflag_ich8lan(hw);
@@ -1484,11 +1785,13 @@ out:
1484 **/ 1785 **/
1485static s32 e1000_check_reset_block_ich8lan(struct e1000_hw *hw) 1786static s32 e1000_check_reset_block_ich8lan(struct e1000_hw *hw)
1486{ 1787{
1487 u32 fwsm; 1788 bool blocked = false;
1789 int i = 0;
1488 1790
1489 fwsm = er32(FWSM); 1791 while ((blocked = !(er32(FWSM) & E1000_ICH_FWSM_RSPCIPHY)) &&
1490 1792 (i++ < 10))
1491 return (fwsm & E1000_ICH_FWSM_RSPCIPHY) ? 0 : E1000_BLK_PHY_RESET; 1793 usleep_range(10000, 20000);
1794 return blocked ? E1000_BLK_PHY_RESET : 0;
1492} 1795}
1493 1796
1494/** 1797/**
diff --git a/drivers/net/ethernet/intel/e1000e/ich8lan.h b/drivers/net/ethernet/intel/e1000e/ich8lan.h
index 217090df33e7..bead50f9187b 100644
--- a/drivers/net/ethernet/intel/e1000e/ich8lan.h
+++ b/drivers/net/ethernet/intel/e1000e/ich8lan.h
@@ -1,30 +1,23 @@
1/******************************************************************************* 1/* Intel PRO/1000 Linux driver
2 2 * Copyright(c) 1999 - 2014 Intel Corporation.
3 Intel PRO/1000 Linux driver 3 *
4 Copyright(c) 1999 - 2013 Intel Corporation. 4 * This program is free software; you can redistribute it and/or modify it
5 5 * under the terms and conditions of the GNU General Public License,
6 This program is free software; you can redistribute it and/or modify it 6 * version 2, as published by the Free Software Foundation.
7 under the terms and conditions of the GNU General Public License, 7 *
8 version 2, as published by the Free Software Foundation. 8 * This program is distributed in the hope it will be useful, but WITHOUT
9 9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 This program is distributed in the hope it will be useful, but WITHOUT 10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * more details.
12 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 12 *
13 more details. 13 * The full GNU General Public License is included in this distribution in
14 14 * the file called "COPYING".
15 You should have received a copy of the GNU General Public License along with 15 *
16 this program; if not, write to the Free Software Foundation, Inc., 16 * Contact Information:
17 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. 17 * Linux NICS <linux.nics@intel.com>
18 18 * e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
19 The full GNU General Public License is included in this distribution in 19 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
20 the file called "COPYING". 20 */
21
22 Contact Information:
23 Linux NICS <linux.nics@intel.com>
24 e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
25 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
26
27*******************************************************************************/
28 21
29#ifndef _E1000E_ICH8LAN_H_ 22#ifndef _E1000E_ICH8LAN_H_
30#define _E1000E_ICH8LAN_H_ 23#define _E1000E_ICH8LAN_H_
@@ -65,11 +58,16 @@
65 58
66#define E1000_FWSM_WLOCK_MAC_MASK 0x0380 59#define E1000_FWSM_WLOCK_MAC_MASK 0x0380
67#define E1000_FWSM_WLOCK_MAC_SHIFT 7 60#define E1000_FWSM_WLOCK_MAC_SHIFT 7
61#define E1000_FWSM_ULP_CFG_DONE 0x00000400 /* Low power cfg done */
68 62
69/* Shared Receive Address Registers */ 63/* Shared Receive Address Registers */
70#define E1000_SHRAL_PCH_LPT(_i) (0x05408 + ((_i) * 8)) 64#define E1000_SHRAL_PCH_LPT(_i) (0x05408 + ((_i) * 8))
71#define E1000_SHRAH_PCH_LPT(_i) (0x0540C + ((_i) * 8)) 65#define E1000_SHRAH_PCH_LPT(_i) (0x0540C + ((_i) * 8))
72 66
67#define E1000_H2ME 0x05B50 /* Host to ME */
68#define E1000_H2ME_ULP 0x00000800 /* ULP Indication Bit */
69#define E1000_H2ME_ENFORCE_SETTINGS 0x00001000 /* Enforce Settings */
70
73#define ID_LED_DEFAULT_ICH8LAN ((ID_LED_DEF1_DEF2 << 12) | \ 71#define ID_LED_DEFAULT_ICH8LAN ((ID_LED_DEF1_DEF2 << 12) | \
74 (ID_LED_OFF1_OFF2 << 8) | \ 72 (ID_LED_OFF1_OFF2 << 8) | \
75 (ID_LED_OFF1_ON2 << 4) | \ 73 (ID_LED_OFF1_ON2 << 4) | \
@@ -82,6 +80,9 @@
82 80
83#define E1000_ICH8_LAN_INIT_TIMEOUT 1500 81#define E1000_ICH8_LAN_INIT_TIMEOUT 1500
84 82
83/* FEXT register bit definition */
84#define E1000_FEXT_PHY_CABLE_DISCONNECTED 0x00000004
85
85#define E1000_FEXTNVM_SW_CONFIG 1 86#define E1000_FEXTNVM_SW_CONFIG 1
86#define E1000_FEXTNVM_SW_CONFIG_ICH8M (1 << 27) /* different on ICH8M */ 87#define E1000_FEXTNVM_SW_CONFIG_ICH8M (1 << 27) /* different on ICH8M */
87 88
@@ -95,10 +96,12 @@
95#define E1000_FEXTNVM6_REQ_PLL_CLK 0x00000100 96#define E1000_FEXTNVM6_REQ_PLL_CLK 0x00000100
96#define E1000_FEXTNVM6_ENABLE_K1_ENTRY_CONDITION 0x00000200 97#define E1000_FEXTNVM6_ENABLE_K1_ENTRY_CONDITION 0x00000200
97 98
99#define E1000_FEXTNVM7_DISABLE_SMB_PERST 0x00000020
100
98#define PCIE_ICH8_SNOOP_ALL PCIE_NO_SNOOP_ALL 101#define PCIE_ICH8_SNOOP_ALL PCIE_NO_SNOOP_ALL
99 102
100#define E1000_ICH_RAR_ENTRIES 7 103#define E1000_ICH_RAR_ENTRIES 7
101#define E1000_PCH2_RAR_ENTRIES 11 /* RAR[0-6], SHRA[0-3] */ 104#define E1000_PCH2_RAR_ENTRIES 5 /* RAR[0], SHRA[0-3] */
102#define E1000_PCH_LPT_RAR_ENTRIES 12 /* RAR[0], SHRA[0-10] */ 105#define E1000_PCH_LPT_RAR_ENTRIES 12 /* RAR[0], SHRA[0-10] */
103 106
104#define PHY_PAGE_SHIFT 5 107#define PHY_PAGE_SHIFT 5
@@ -161,6 +164,16 @@
161#define CV_SMB_CTRL PHY_REG(769, 23) 164#define CV_SMB_CTRL PHY_REG(769, 23)
162#define CV_SMB_CTRL_FORCE_SMBUS 0x0001 165#define CV_SMB_CTRL_FORCE_SMBUS 0x0001
163 166
167/* I218 Ultra Low Power Configuration 1 Register */
168#define I218_ULP_CONFIG1 PHY_REG(779, 16)
169#define I218_ULP_CONFIG1_START 0x0001 /* Start auto ULP config */
170#define I218_ULP_CONFIG1_IND 0x0004 /* Pwr up from ULP indication */
171#define I218_ULP_CONFIG1_STICKY_ULP 0x0010 /* Set sticky ULP mode */
172#define I218_ULP_CONFIG1_INBAND_EXIT 0x0020 /* Inband on ULP exit */
173#define I218_ULP_CONFIG1_WOL_HOST 0x0040 /* WoL Host on ULP exit */
174#define I218_ULP_CONFIG1_RESET_TO_SMBUS 0x0100 /* Reset to SMBus mode */
175#define I218_ULP_CONFIG1_DISABLE_SMB_PERST 0x1000 /* Disable on PERST# */
176
164/* SMBus Address Phy Register */ 177/* SMBus Address Phy Register */
165#define HV_SMB_ADDR PHY_REG(768, 26) 178#define HV_SMB_ADDR PHY_REG(768, 26)
166#define HV_SMB_ADDR_MASK 0x007F 179#define HV_SMB_ADDR_MASK 0x007F
@@ -195,6 +208,7 @@
195/* PHY Power Management Control */ 208/* PHY Power Management Control */
196#define HV_PM_CTRL PHY_REG(770, 17) 209#define HV_PM_CTRL PHY_REG(770, 17)
197#define HV_PM_CTRL_PLL_STOP_IN_K1_GIGA 0x100 210#define HV_PM_CTRL_PLL_STOP_IN_K1_GIGA 0x100
211#define HV_PM_CTRL_K1_ENABLE 0x4000
198 212
199#define SW_FLAG_TIMEOUT 1000 /* SW Semaphore flag timeout in ms */ 213#define SW_FLAG_TIMEOUT 1000 /* SW Semaphore flag timeout in ms */
200 214
@@ -268,4 +282,6 @@ void e1000_copy_rx_addrs_to_phy_ich8lan(struct e1000_hw *hw);
268s32 e1000_lv_jumbo_workaround_ich8lan(struct e1000_hw *hw, bool enable); 282s32 e1000_lv_jumbo_workaround_ich8lan(struct e1000_hw *hw, bool enable);
269s32 e1000_read_emi_reg_locked(struct e1000_hw *hw, u16 addr, u16 *data); 283s32 e1000_read_emi_reg_locked(struct e1000_hw *hw, u16 addr, u16 *data);
270s32 e1000_write_emi_reg_locked(struct e1000_hw *hw, u16 addr, u16 data); 284s32 e1000_write_emi_reg_locked(struct e1000_hw *hw, u16 addr, u16 data);
285s32 e1000_set_eee_pchlan(struct e1000_hw *hw);
286s32 e1000_enable_ulp_lpt_lp(struct e1000_hw *hw, bool to_sx);
271#endif /* _E1000E_ICH8LAN_H_ */ 287#endif /* _E1000E_ICH8LAN_H_ */
diff --git a/drivers/net/ethernet/intel/e1000e/mac.c b/drivers/net/ethernet/intel/e1000e/mac.c
index 2480c1091873..baa0a466d1d0 100644
--- a/drivers/net/ethernet/intel/e1000e/mac.c
+++ b/drivers/net/ethernet/intel/e1000e/mac.c
@@ -1,30 +1,23 @@
1/******************************************************************************* 1/* Intel PRO/1000 Linux driver
2 2 * Copyright(c) 1999 - 2014 Intel Corporation.
3 Intel PRO/1000 Linux driver 3 *
4 Copyright(c) 1999 - 2013 Intel Corporation. 4 * This program is free software; you can redistribute it and/or modify it
5 5 * under the terms and conditions of the GNU General Public License,
6 This program is free software; you can redistribute it and/or modify it 6 * version 2, as published by the Free Software Foundation.
7 under the terms and conditions of the GNU General Public License, 7 *
8 version 2, as published by the Free Software Foundation. 8 * This program is distributed in the hope it will be useful, but WITHOUT
9 9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 This program is distributed in the hope it will be useful, but WITHOUT 10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * more details.
12 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 12 *
13 more details. 13 * The full GNU General Public License is included in this distribution in
14 14 * the file called "COPYING".
15 You should have received a copy of the GNU General Public License along with 15 *
16 this program; if not, write to the Free Software Foundation, Inc., 16 * Contact Information:
17 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. 17 * Linux NICS <linux.nics@intel.com>
18 18 * e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
19 The full GNU General Public License is included in this distribution in 19 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
20 the file called "COPYING". 20 */
21
22 Contact Information:
23 Linux NICS <linux.nics@intel.com>
24 e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
25 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
26
27*******************************************************************************/
28 21
29#include "e1000.h" 22#include "e1000.h"
30 23
diff --git a/drivers/net/ethernet/intel/e1000e/mac.h b/drivers/net/ethernet/intel/e1000e/mac.h
index a61fee404ebe..4e81c2825b7a 100644
--- a/drivers/net/ethernet/intel/e1000e/mac.h
+++ b/drivers/net/ethernet/intel/e1000e/mac.h
@@ -1,30 +1,23 @@
1/******************************************************************************* 1/* Intel PRO/1000 Linux driver
2 2 * Copyright(c) 1999 - 2014 Intel Corporation.
3 Intel PRO/1000 Linux driver 3 *
4 Copyright(c) 1999 - 2013 Intel Corporation. 4 * This program is free software; you can redistribute it and/or modify it
5 5 * under the terms and conditions of the GNU General Public License,
6 This program is free software; you can redistribute it and/or modify it 6 * version 2, as published by the Free Software Foundation.
7 under the terms and conditions of the GNU General Public License, 7 *
8 version 2, as published by the Free Software Foundation. 8 * This program is distributed in the hope it will be useful, but WITHOUT
9 9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 This program is distributed in the hope it will be useful, but WITHOUT 10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * more details.
12 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 12 *
13 more details. 13 * The full GNU General Public License is included in this distribution in
14 14 * the file called "COPYING".
15 You should have received a copy of the GNU General Public License along with 15 *
16 this program; if not, write to the Free Software Foundation, Inc., 16 * Contact Information:
17 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. 17 * Linux NICS <linux.nics@intel.com>
18 18 * e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
19 The full GNU General Public License is included in this distribution in 19 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
20 the file called "COPYING". 20 */
21
22 Contact Information:
23 Linux NICS <linux.nics@intel.com>
24 e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
25 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
26
27*******************************************************************************/
28 21
29#ifndef _E1000E_MAC_H_ 22#ifndef _E1000E_MAC_H_
30#define _E1000E_MAC_H_ 23#define _E1000E_MAC_H_
diff --git a/drivers/net/ethernet/intel/e1000e/manage.c b/drivers/net/ethernet/intel/e1000e/manage.c
index e4b0f1ef92f6..cb37ff1f1321 100644
--- a/drivers/net/ethernet/intel/e1000e/manage.c
+++ b/drivers/net/ethernet/intel/e1000e/manage.c
@@ -1,30 +1,23 @@
1/******************************************************************************* 1/* Intel PRO/1000 Linux driver
2 2 * Copyright(c) 1999 - 2014 Intel Corporation.
3 Intel PRO/1000 Linux driver 3 *
4 Copyright(c) 1999 - 2013 Intel Corporation. 4 * This program is free software; you can redistribute it and/or modify it
5 5 * under the terms and conditions of the GNU General Public License,
6 This program is free software; you can redistribute it and/or modify it 6 * version 2, as published by the Free Software Foundation.
7 under the terms and conditions of the GNU General Public License, 7 *
8 version 2, as published by the Free Software Foundation. 8 * This program is distributed in the hope it will be useful, but WITHOUT
9 9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 This program is distributed in the hope it will be useful, but WITHOUT 10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * more details.
12 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 12 *
13 more details. 13 * The full GNU General Public License is included in this distribution in
14 14 * the file called "COPYING".
15 You should have received a copy of the GNU General Public License along with 15 *
16 this program; if not, write to the Free Software Foundation, Inc., 16 * Contact Information:
17 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. 17 * Linux NICS <linux.nics@intel.com>
18 18 * e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
19 The full GNU General Public License is included in this distribution in 19 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
20 the file called "COPYING". 20 */
21
22 Contact Information:
23 Linux NICS <linux.nics@intel.com>
24 e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
25 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
26
27*******************************************************************************/
28 21
29#include "e1000.h" 22#include "e1000.h"
30 23
diff --git a/drivers/net/ethernet/intel/e1000e/manage.h b/drivers/net/ethernet/intel/e1000e/manage.h
index 326897c29ea8..a8c27f98f7b0 100644
--- a/drivers/net/ethernet/intel/e1000e/manage.h
+++ b/drivers/net/ethernet/intel/e1000e/manage.h
@@ -1,30 +1,23 @@
1/******************************************************************************* 1/* Intel PRO/1000 Linux driver
2 2 * Copyright(c) 1999 - 2014 Intel Corporation.
3 Intel PRO/1000 Linux driver 3 *
4 Copyright(c) 1999 - 2013 Intel Corporation. 4 * This program is free software; you can redistribute it and/or modify it
5 5 * under the terms and conditions of the GNU General Public License,
6 This program is free software; you can redistribute it and/or modify it 6 * version 2, as published by the Free Software Foundation.
7 under the terms and conditions of the GNU General Public License, 7 *
8 version 2, as published by the Free Software Foundation. 8 * This program is distributed in the hope it will be useful, but WITHOUT
9 9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 This program is distributed in the hope it will be useful, but WITHOUT 10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * more details.
12 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 12 *
13 more details. 13 * The full GNU General Public License is included in this distribution in
14 14 * the file called "COPYING".
15 You should have received a copy of the GNU General Public License along with 15 *
16 this program; if not, write to the Free Software Foundation, Inc., 16 * Contact Information:
17 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. 17 * Linux NICS <linux.nics@intel.com>
18 18 * e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
19 The full GNU General Public License is included in this distribution in 19 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
20 the file called "COPYING". 20 */
21
22 Contact Information:
23 Linux NICS <linux.nics@intel.com>
24 e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
25 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
26
27*******************************************************************************/
28 21
29#ifndef _E1000E_MANAGE_H_ 22#ifndef _E1000E_MANAGE_H_
30#define _E1000E_MANAGE_H_ 23#define _E1000E_MANAGE_H_
diff --git a/drivers/net/ethernet/intel/e1000e/netdev.c b/drivers/net/ethernet/intel/e1000e/netdev.c
index 6d91933c4cdd..6bd1832e3f3e 100644
--- a/drivers/net/ethernet/intel/e1000e/netdev.c
+++ b/drivers/net/ethernet/intel/e1000e/netdev.c
@@ -1,30 +1,23 @@
1/******************************************************************************* 1/* Intel PRO/1000 Linux driver
2 2 * Copyright(c) 1999 - 2014 Intel Corporation.
3 Intel PRO/1000 Linux driver 3 *
4 Copyright(c) 1999 - 2013 Intel Corporation. 4 * This program is free software; you can redistribute it and/or modify it
5 5 * under the terms and conditions of the GNU General Public License,
6 This program is free software; you can redistribute it and/or modify it 6 * version 2, as published by the Free Software Foundation.
7 under the terms and conditions of the GNU General Public License, 7 *
8 version 2, as published by the Free Software Foundation. 8 * This program is distributed in the hope it will be useful, but WITHOUT
9 9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 This program is distributed in the hope it will be useful, but WITHOUT 10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * more details.
12 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 12 *
13 more details. 13 * The full GNU General Public License is included in this distribution in
14 14 * the file called "COPYING".
15 You should have received a copy of the GNU General Public License along with 15 *
16 this program; if not, write to the Free Software Foundation, Inc., 16 * Contact Information:
17 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. 17 * Linux NICS <linux.nics@intel.com>
18 18 * e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
19 The full GNU General Public License is included in this distribution in 19 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
20 the file called "COPYING". 20 */
21
22 Contact Information:
23 Linux NICS <linux.nics@intel.com>
24 e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
25 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
26
27*******************************************************************************/
28 21
29#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 22#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
30 23
@@ -885,7 +878,7 @@ static inline void e1000_rx_hash(struct net_device *netdev, __le32 rss,
885 struct sk_buff *skb) 878 struct sk_buff *skb)
886{ 879{
887 if (netdev->features & NETIF_F_RXHASH) 880 if (netdev->features & NETIF_F_RXHASH)
888 skb->rxhash = le32_to_cpu(rss); 881 skb_set_hash(skb, le32_to_cpu(rss), PKT_HASH_TYPE_L3);
889} 882}
890 883
891/** 884/**
@@ -1097,8 +1090,14 @@ static void e1000_print_hw_hang(struct work_struct *work)
1097 adapter->tx_hang_recheck = true; 1090 adapter->tx_hang_recheck = true;
1098 return; 1091 return;
1099 } 1092 }
1100 /* Real hang detected */
1101 adapter->tx_hang_recheck = false; 1093 adapter->tx_hang_recheck = false;
1094
1095 if (er32(TDH(0)) == er32(TDT(0))) {
1096 e_dbg("false hang detected, ignoring\n");
1097 return;
1098 }
1099
1100 /* Real hang detected */
1102 netif_stop_queue(netdev); 1101 netif_stop_queue(netdev);
1103 1102
1104 e1e_rphy(hw, MII_BMSR, &phy_status); 1103 e1e_rphy(hw, MII_BMSR, &phy_status);
@@ -1128,6 +1127,8 @@ static void e1000_print_hw_hang(struct work_struct *work)
1128 eop, jiffies, eop_desc->upper.fields.status, er32(STATUS), 1127 eop, jiffies, eop_desc->upper.fields.status, er32(STATUS),
1129 phy_status, phy_1000t_status, phy_ext_status, pci_status); 1128 phy_status, phy_1000t_status, phy_ext_status, pci_status);
1130 1129
1130 e1000e_dump(adapter);
1131
1131 /* Suggest workaround for known h/w issue */ 1132 /* Suggest workaround for known h/w issue */
1132 if ((hw->mac.type == e1000_pchlan) && (er32(CTRL) & E1000_CTRL_TFCE)) 1133 if ((hw->mac.type == e1000_pchlan) && (er32(CTRL) & E1000_CTRL_TFCE))
1133 e_err("Try turning off Tx pause (flow control) via ethtool\n"); 1134 e_err("Try turning off Tx pause (flow control) via ethtool\n");
@@ -1701,7 +1702,7 @@ static void e1000_clean_rx_ring(struct e1000_ring *rx_ring)
1701 adapter->flags2 &= ~FLAG2_IS_DISCARDING; 1702 adapter->flags2 &= ~FLAG2_IS_DISCARDING;
1702 1703
1703 writel(0, rx_ring->head); 1704 writel(0, rx_ring->head);
1704 if (rx_ring->adapter->flags2 & FLAG2_PCIM2PCI_ARBITER_WA) 1705 if (adapter->flags2 & FLAG2_PCIM2PCI_ARBITER_WA)
1705 e1000e_update_rdt_wa(rx_ring, 0); 1706 e1000e_update_rdt_wa(rx_ring, 0);
1706 else 1707 else
1707 writel(0, rx_ring->tail); 1708 writel(0, rx_ring->tail);
@@ -2038,13 +2039,16 @@ void e1000e_set_interrupt_capability(struct e1000_adapter *adapter)
2038 msix_entry), 2039 msix_entry),
2039 GFP_KERNEL); 2040 GFP_KERNEL);
2040 if (adapter->msix_entries) { 2041 if (adapter->msix_entries) {
2042 struct e1000_adapter *a = adapter;
2043
2041 for (i = 0; i < adapter->num_vectors; i++) 2044 for (i = 0; i < adapter->num_vectors; i++)
2042 adapter->msix_entries[i].entry = i; 2045 adapter->msix_entries[i].entry = i;
2043 2046
2044 err = pci_enable_msix(adapter->pdev, 2047 err = pci_enable_msix_range(a->pdev,
2045 adapter->msix_entries, 2048 a->msix_entries,
2046 adapter->num_vectors); 2049 a->num_vectors,
2047 if (err == 0) 2050 a->num_vectors);
2051 if (err > 0)
2048 return; 2052 return;
2049 } 2053 }
2050 /* MSI-X failed, so fall through and try MSI */ 2054 /* MSI-X failed, so fall through and try MSI */
@@ -2402,7 +2406,7 @@ static void e1000_clean_tx_ring(struct e1000_ring *tx_ring)
2402 tx_ring->next_to_clean = 0; 2406 tx_ring->next_to_clean = 0;
2403 2407
2404 writel(0, tx_ring->head); 2408 writel(0, tx_ring->head);
2405 if (tx_ring->adapter->flags2 & FLAG2_PCIM2PCI_ARBITER_WA) 2409 if (adapter->flags2 & FLAG2_PCIM2PCI_ARBITER_WA)
2406 e1000e_update_tdt_wa(tx_ring, 0); 2410 e1000e_update_tdt_wa(tx_ring, 0);
2407 else 2411 else
2408 writel(0, tx_ring->tail); 2412 writel(0, tx_ring->tail);
@@ -2894,7 +2898,7 @@ static void e1000_configure_tx(struct e1000_adapter *adapter)
2894 struct e1000_hw *hw = &adapter->hw; 2898 struct e1000_hw *hw = &adapter->hw;
2895 struct e1000_ring *tx_ring = adapter->tx_ring; 2899 struct e1000_ring *tx_ring = adapter->tx_ring;
2896 u64 tdba; 2900 u64 tdba;
2897 u32 tdlen, tarc; 2901 u32 tdlen, tctl, tarc;
2898 2902
2899 /* Setup the HW Tx Head and Tail descriptor pointers */ 2903 /* Setup the HW Tx Head and Tail descriptor pointers */
2900 tdba = tx_ring->dma; 2904 tdba = tx_ring->dma;
@@ -2931,6 +2935,12 @@ static void e1000_configure_tx(struct e1000_adapter *adapter)
2931 /* erratum work around: set txdctl the same for both queues */ 2935 /* erratum work around: set txdctl the same for both queues */
2932 ew32(TXDCTL(1), er32(TXDCTL(0))); 2936 ew32(TXDCTL(1), er32(TXDCTL(0)));
2933 2937
2938 /* Program the Transmit Control Register */
2939 tctl = er32(TCTL);
2940 tctl &= ~E1000_TCTL_CT;
2941 tctl |= E1000_TCTL_PSP | E1000_TCTL_RTLC |
2942 (E1000_COLLISION_THRESHOLD << E1000_CT_SHIFT);
2943
2934 if (adapter->flags & FLAG_TARC_SPEED_MODE_BIT) { 2944 if (adapter->flags & FLAG_TARC_SPEED_MODE_BIT) {
2935 tarc = er32(TARC(0)); 2945 tarc = er32(TARC(0));
2936 /* set the speed mode bit, we'll clear it if we're not at 2946 /* set the speed mode bit, we'll clear it if we're not at
@@ -2961,6 +2971,8 @@ static void e1000_configure_tx(struct e1000_adapter *adapter)
2961 /* enable Report Status bit */ 2971 /* enable Report Status bit */
2962 adapter->txd_cmd |= E1000_TXD_CMD_RS; 2972 adapter->txd_cmd |= E1000_TXD_CMD_RS;
2963 2973
2974 ew32(TCTL, tctl);
2975
2964 hw->mac.ops.config_collision_dist(hw); 2976 hw->mac.ops.config_collision_dist(hw);
2965} 2977}
2966 2978
@@ -3331,6 +3343,9 @@ static void e1000e_set_rx_mode(struct net_device *netdev)
3331 struct e1000_hw *hw = &adapter->hw; 3343 struct e1000_hw *hw = &adapter->hw;
3332 u32 rctl; 3344 u32 rctl;
3333 3345
3346 if (pm_runtime_suspended(netdev->dev.parent))
3347 return;
3348
3334 /* Check for Promiscuous and All Multicast modes */ 3349 /* Check for Promiscuous and All Multicast modes */
3335 rctl = er32(RCTL); 3350 rctl = er32(RCTL);
3336 3351
@@ -3691,10 +3706,6 @@ void e1000e_power_up_phy(struct e1000_adapter *adapter)
3691 */ 3706 */
3692static void e1000_power_down_phy(struct e1000_adapter *adapter) 3707static void e1000_power_down_phy(struct e1000_adapter *adapter)
3693{ 3708{
3694 /* WoL is enabled */
3695 if (adapter->wol)
3696 return;
3697
3698 if (adapter->hw.phy.ops.power_down) 3709 if (adapter->hw.phy.ops.power_down)
3699 adapter->hw.phy.ops.power_down(&adapter->hw); 3710 adapter->hw.phy.ops.power_down(&adapter->hw);
3700} 3711}
@@ -3911,10 +3922,8 @@ void e1000e_reset(struct e1000_adapter *adapter)
3911 } 3922 }
3912 3923
3913 if (!netif_running(adapter->netdev) && 3924 if (!netif_running(adapter->netdev) &&
3914 !test_bit(__E1000_TESTING, &adapter->state)) { 3925 !test_bit(__E1000_TESTING, &adapter->state))
3915 e1000_power_down_phy(adapter); 3926 e1000_power_down_phy(adapter);
3916 return;
3917 }
3918 3927
3919 e1000_get_phy_info(hw); 3928 e1000_get_phy_info(hw);
3920 3929
@@ -3981,7 +3990,12 @@ static void e1000e_flush_descriptors(struct e1000_adapter *adapter)
3981 3990
3982static void e1000e_update_stats(struct e1000_adapter *adapter); 3991static void e1000e_update_stats(struct e1000_adapter *adapter);
3983 3992
3984void e1000e_down(struct e1000_adapter *adapter) 3993/**
3994 * e1000e_down - quiesce the device and optionally reset the hardware
3995 * @adapter: board private structure
3996 * @reset: boolean flag to reset the hardware or not
3997 */
3998void e1000e_down(struct e1000_adapter *adapter, bool reset)
3985{ 3999{
3986 struct net_device *netdev = adapter->netdev; 4000 struct net_device *netdev = adapter->netdev;
3987 struct e1000_hw *hw = &adapter->hw; 4001 struct e1000_hw *hw = &adapter->hw;
@@ -4035,12 +4049,8 @@ void e1000e_down(struct e1000_adapter *adapter)
4035 e1000_lv_jumbo_workaround_ich8lan(hw, false)) 4049 e1000_lv_jumbo_workaround_ich8lan(hw, false))
4036 e_dbg("failed to disable jumbo frame workaround mode\n"); 4050 e_dbg("failed to disable jumbo frame workaround mode\n");
4037 4051
4038 if (!pci_channel_offline(adapter->pdev)) 4052 if (reset && !pci_channel_offline(adapter->pdev))
4039 e1000e_reset(adapter); 4053 e1000e_reset(adapter);
4040
4041 /* TODO: for power management, we could drop the link and
4042 * pci_disable_device here.
4043 */
4044} 4054}
4045 4055
4046void e1000e_reinit_locked(struct e1000_adapter *adapter) 4056void e1000e_reinit_locked(struct e1000_adapter *adapter)
@@ -4048,7 +4058,7 @@ void e1000e_reinit_locked(struct e1000_adapter *adapter)
4048 might_sleep(); 4058 might_sleep();
4049 while (test_and_set_bit(__E1000_RESETTING, &adapter->state)) 4059 while (test_and_set_bit(__E1000_RESETTING, &adapter->state))
4050 usleep_range(1000, 2000); 4060 usleep_range(1000, 2000);
4051 e1000e_down(adapter); 4061 e1000e_down(adapter, true);
4052 e1000e_up(adapter); 4062 e1000e_up(adapter);
4053 clear_bit(__E1000_RESETTING, &adapter->state); 4063 clear_bit(__E1000_RESETTING, &adapter->state);
4054} 4064}
@@ -4326,7 +4336,6 @@ static int e1000_open(struct net_device *netdev)
4326 adapter->tx_hang_recheck = false; 4336 adapter->tx_hang_recheck = false;
4327 netif_start_queue(netdev); 4337 netif_start_queue(netdev);
4328 4338
4329 adapter->idle_check = true;
4330 hw->mac.get_link_status = true; 4339 hw->mac.get_link_status = true;
4331 pm_runtime_put(&pdev->dev); 4340 pm_runtime_put(&pdev->dev);
4332 4341
@@ -4376,14 +4385,15 @@ static int e1000_close(struct net_device *netdev)
4376 pm_runtime_get_sync(&pdev->dev); 4385 pm_runtime_get_sync(&pdev->dev);
4377 4386
4378 if (!test_bit(__E1000_DOWN, &adapter->state)) { 4387 if (!test_bit(__E1000_DOWN, &adapter->state)) {
4379 e1000e_down(adapter); 4388 e1000e_down(adapter, true);
4380 e1000_free_irq(adapter); 4389 e1000_free_irq(adapter);
4390
4391 /* Link status message must follow this format */
4392 pr_info("%s NIC Link is Down\n", adapter->netdev->name);
4381 } 4393 }
4382 4394
4383 napi_disable(&adapter->napi); 4395 napi_disable(&adapter->napi);
4384 4396
4385 e1000_power_down_phy(adapter);
4386
4387 e1000e_free_tx_resources(adapter->tx_ring); 4397 e1000e_free_tx_resources(adapter->tx_ring);
4388 e1000e_free_rx_resources(adapter->rx_ring); 4398 e1000e_free_rx_resources(adapter->rx_ring);
4389 4399
@@ -4460,11 +4470,16 @@ static void e1000e_update_phy_task(struct work_struct *work)
4460 struct e1000_adapter *adapter = container_of(work, 4470 struct e1000_adapter *adapter = container_of(work,
4461 struct e1000_adapter, 4471 struct e1000_adapter,
4462 update_phy_task); 4472 update_phy_task);
4473 struct e1000_hw *hw = &adapter->hw;
4463 4474
4464 if (test_bit(__E1000_DOWN, &adapter->state)) 4475 if (test_bit(__E1000_DOWN, &adapter->state))
4465 return; 4476 return;
4466 4477
4467 e1000_get_phy_info(&adapter->hw); 4478 e1000_get_phy_info(hw);
4479
4480 /* Enable EEE on 82579 after link up */
4481 if (hw->phy.type == e1000_phy_82579)
4482 e1000_set_eee_pchlan(hw);
4468} 4483}
4469 4484
4470/** 4485/**
@@ -4799,6 +4814,7 @@ static void e1000e_check_82574_phy_workaround(struct e1000_adapter *adapter)
4799 4814
4800 if (adapter->phy_hang_count > 1) { 4815 if (adapter->phy_hang_count > 1) {
4801 adapter->phy_hang_count = 0; 4816 adapter->phy_hang_count = 0;
4817 e_dbg("PHY appears hung - resetting\n");
4802 schedule_work(&adapter->reset_task); 4818 schedule_work(&adapter->reset_task);
4803 } 4819 }
4804} 4820}
@@ -4957,15 +4973,11 @@ static void e1000_watchdog_task(struct work_struct *work)
4957 mod_timer(&adapter->phy_info_timer, 4973 mod_timer(&adapter->phy_info_timer,
4958 round_jiffies(jiffies + 2 * HZ)); 4974 round_jiffies(jiffies + 2 * HZ));
4959 4975
4960 /* The link is lost so the controller stops DMA. 4976 /* 8000ES2LAN requires a Rx packet buffer work-around
4961 * If there is queued Tx work that cannot be done 4977 * on link down event; reset the controller to flush
4962 * or if on an 8000ES2LAN which requires a Rx packet 4978 * the Rx packet buffer.
4963 * buffer work-around on link down event, reset the
4964 * controller to flush the Tx/Rx packet buffers.
4965 * (Do the reset outside of interrupt context).
4966 */ 4979 */
4967 if ((adapter->flags & FLAG_RX_NEEDS_RESTART) || 4980 if (adapter->flags & FLAG_RX_NEEDS_RESTART)
4968 (e1000_desc_unused(tx_ring) + 1 < tx_ring->count))
4969 adapter->flags |= FLAG_RESTART_NOW; 4981 adapter->flags |= FLAG_RESTART_NOW;
4970 else 4982 else
4971 pm_schedule_suspend(netdev->dev.parent, 4983 pm_schedule_suspend(netdev->dev.parent,
@@ -4988,6 +5000,15 @@ link_up:
4988 adapter->gotc_old = adapter->stats.gotc; 5000 adapter->gotc_old = adapter->stats.gotc;
4989 spin_unlock(&adapter->stats64_lock); 5001 spin_unlock(&adapter->stats64_lock);
4990 5002
5003 /* If the link is lost the controller stops DMA, but
5004 * if there is queued Tx work it cannot be done. So
5005 * reset the controller to flush the Tx packet buffers.
5006 */
5007 if (!netif_carrier_ok(netdev) &&
5008 (e1000_desc_unused(tx_ring) + 1 < tx_ring->count))
5009 adapter->flags |= FLAG_RESTART_NOW;
5010
5011 /* If reset is necessary, do it outside of interrupt context. */
4991 if (adapter->flags & FLAG_RESTART_NOW) { 5012 if (adapter->flags & FLAG_RESTART_NOW) {
4992 schedule_work(&adapter->reset_task); 5013 schedule_work(&adapter->reset_task);
4993 /* return immediately since reset is imminent */ 5014 /* return immediately since reset is imminent */
@@ -5684,8 +5705,11 @@ static int e1000_change_mtu(struct net_device *netdev, int new_mtu)
5684 adapter->max_frame_size = max_frame; 5705 adapter->max_frame_size = max_frame;
5685 e_info("changing MTU from %d to %d\n", netdev->mtu, new_mtu); 5706 e_info("changing MTU from %d to %d\n", netdev->mtu, new_mtu);
5686 netdev->mtu = new_mtu; 5707 netdev->mtu = new_mtu;
5708
5709 pm_runtime_get_sync(netdev->dev.parent);
5710
5687 if (netif_running(netdev)) 5711 if (netif_running(netdev))
5688 e1000e_down(adapter); 5712 e1000e_down(adapter, true);
5689 5713
5690 /* NOTE: netdev_alloc_skb reserves 16 bytes, and typically NET_IP_ALIGN 5714 /* NOTE: netdev_alloc_skb reserves 16 bytes, and typically NET_IP_ALIGN
5691 * means we reserve 2 more, this pushes us to allocate from the next 5715 * means we reserve 2 more, this pushes us to allocate from the next
@@ -5711,6 +5735,8 @@ static int e1000_change_mtu(struct net_device *netdev, int new_mtu)
5711 else 5735 else
5712 e1000e_reset(adapter); 5736 e1000e_reset(adapter);
5713 5737
5738 pm_runtime_put_sync(netdev->dev.parent);
5739
5714 clear_bit(__E1000_RESETTING, &adapter->state); 5740 clear_bit(__E1000_RESETTING, &adapter->state);
5715 5741
5716 return 0; 5742 return 0;
@@ -5852,7 +5878,7 @@ static int e1000_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)
5852static int e1000_init_phy_wakeup(struct e1000_adapter *adapter, u32 wufc) 5878static int e1000_init_phy_wakeup(struct e1000_adapter *adapter, u32 wufc)
5853{ 5879{
5854 struct e1000_hw *hw = &adapter->hw; 5880 struct e1000_hw *hw = &adapter->hw;
5855 u32 i, mac_reg; 5881 u32 i, mac_reg, wuc;
5856 u16 phy_reg, wuc_enable; 5882 u16 phy_reg, wuc_enable;
5857 int retval; 5883 int retval;
5858 5884
@@ -5899,13 +5925,18 @@ static int e1000_init_phy_wakeup(struct e1000_adapter *adapter, u32 wufc)
5899 phy_reg |= BM_RCTL_RFCE; 5925 phy_reg |= BM_RCTL_RFCE;
5900 hw->phy.ops.write_reg_page(&adapter->hw, BM_RCTL, phy_reg); 5926 hw->phy.ops.write_reg_page(&adapter->hw, BM_RCTL, phy_reg);
5901 5927
5928 wuc = E1000_WUC_PME_EN;
5929 if (wufc & (E1000_WUFC_MAG | E1000_WUFC_LNKC))
5930 wuc |= E1000_WUC_APME;
5931
5902 /* enable PHY wakeup in MAC register */ 5932 /* enable PHY wakeup in MAC register */
5903 ew32(WUFC, wufc); 5933 ew32(WUFC, wufc);
5904 ew32(WUC, E1000_WUC_PHY_WAKE | E1000_WUC_PME_EN); 5934 ew32(WUC, (E1000_WUC_PHY_WAKE | E1000_WUC_APMPME |
5935 E1000_WUC_PME_STATUS | wuc));
5905 5936
5906 /* configure and enable PHY wakeup in PHY registers */ 5937 /* configure and enable PHY wakeup in PHY registers */
5907 hw->phy.ops.write_reg_page(&adapter->hw, BM_WUFC, wufc); 5938 hw->phy.ops.write_reg_page(&adapter->hw, BM_WUFC, wufc);
5908 hw->phy.ops.write_reg_page(&adapter->hw, BM_WUC, E1000_WUC_PME_EN); 5939 hw->phy.ops.write_reg_page(&adapter->hw, BM_WUC, wuc);
5909 5940
5910 /* activate PHY wakeup */ 5941 /* activate PHY wakeup */
5911 wuc_enable |= BM_WUC_ENABLE_BIT | BM_WUC_HOST_WU_BIT; 5942 wuc_enable |= BM_WUC_ENABLE_BIT | BM_WUC_HOST_WU_BIT;
@@ -5918,15 +5949,10 @@ release:
5918 return retval; 5949 return retval;
5919} 5950}
5920 5951
5921static int __e1000_shutdown(struct pci_dev *pdev, bool runtime) 5952static int e1000e_pm_freeze(struct device *dev)
5922{ 5953{
5923 struct net_device *netdev = pci_get_drvdata(pdev); 5954 struct net_device *netdev = pci_get_drvdata(to_pci_dev(dev));
5924 struct e1000_adapter *adapter = netdev_priv(netdev); 5955 struct e1000_adapter *adapter = netdev_priv(netdev);
5925 struct e1000_hw *hw = &adapter->hw;
5926 u32 ctrl, ctrl_ext, rctl, status;
5927 /* Runtime suspend should only enable wakeup for link changes */
5928 u32 wufc = runtime ? E1000_WUFC_LNKC : adapter->wol;
5929 int retval = 0;
5930 5956
5931 netif_device_detach(netdev); 5957 netif_device_detach(netdev);
5932 5958
@@ -5937,11 +5963,29 @@ static int __e1000_shutdown(struct pci_dev *pdev, bool runtime)
5937 usleep_range(10000, 20000); 5963 usleep_range(10000, 20000);
5938 5964
5939 WARN_ON(test_bit(__E1000_RESETTING, &adapter->state)); 5965 WARN_ON(test_bit(__E1000_RESETTING, &adapter->state));
5940 e1000e_down(adapter); 5966
5967 /* Quiesce the device without resetting the hardware */
5968 e1000e_down(adapter, false);
5941 e1000_free_irq(adapter); 5969 e1000_free_irq(adapter);
5942 } 5970 }
5943 e1000e_reset_interrupt_capability(adapter); 5971 e1000e_reset_interrupt_capability(adapter);
5944 5972
5973 /* Allow time for pending master requests to run */
5974 e1000e_disable_pcie_master(&adapter->hw);
5975
5976 return 0;
5977}
5978
5979static int __e1000_shutdown(struct pci_dev *pdev, bool runtime)
5980{
5981 struct net_device *netdev = pci_get_drvdata(pdev);
5982 struct e1000_adapter *adapter = netdev_priv(netdev);
5983 struct e1000_hw *hw = &adapter->hw;
5984 u32 ctrl, ctrl_ext, rctl, status;
5985 /* Runtime suspend should only enable wakeup for link changes */
5986 u32 wufc = runtime ? E1000_WUFC_LNKC : adapter->wol;
5987 int retval = 0;
5988
5945 status = er32(STATUS); 5989 status = er32(STATUS);
5946 if (status & E1000_STATUS_LU) 5990 if (status & E1000_STATUS_LU)
5947 wufc &= ~E1000_WUFC_LNKC; 5991 wufc &= ~E1000_WUFC_LNKC;
@@ -5972,12 +6016,12 @@ static int __e1000_shutdown(struct pci_dev *pdev, bool runtime)
5972 ew32(CTRL_EXT, ctrl_ext); 6016 ew32(CTRL_EXT, ctrl_ext);
5973 } 6017 }
5974 6018
6019 if (!runtime)
6020 e1000e_power_up_phy(adapter);
6021
5975 if (adapter->flags & FLAG_IS_ICH) 6022 if (adapter->flags & FLAG_IS_ICH)
5976 e1000_suspend_workarounds_ich8lan(&adapter->hw); 6023 e1000_suspend_workarounds_ich8lan(&adapter->hw);
5977 6024
5978 /* Allow time for pending master requests to run */
5979 e1000e_disable_pcie_master(&adapter->hw);
5980
5981 if (adapter->flags2 & FLAG2_HAS_PHY_WAKEUP) { 6025 if (adapter->flags2 & FLAG2_HAS_PHY_WAKEUP) {
5982 /* enable wakeup by the PHY */ 6026 /* enable wakeup by the PHY */
5983 retval = e1000_init_phy_wakeup(adapter, wufc); 6027 retval = e1000_init_phy_wakeup(adapter, wufc);
@@ -5991,10 +6035,23 @@ static int __e1000_shutdown(struct pci_dev *pdev, bool runtime)
5991 } else { 6035 } else {
5992 ew32(WUC, 0); 6036 ew32(WUC, 0);
5993 ew32(WUFC, 0); 6037 ew32(WUFC, 0);
6038
6039 e1000_power_down_phy(adapter);
5994 } 6040 }
5995 6041
5996 if (adapter->hw.phy.type == e1000_phy_igp_3) 6042 if (adapter->hw.phy.type == e1000_phy_igp_3) {
5997 e1000e_igp3_phy_powerdown_workaround_ich8lan(&adapter->hw); 6043 e1000e_igp3_phy_powerdown_workaround_ich8lan(&adapter->hw);
6044 } else if (hw->mac.type == e1000_pch_lpt) {
6045 if (!(wufc & (E1000_WUFC_EX | E1000_WUFC_MC | E1000_WUFC_BC)))
6046 /* ULP does not support wake from unicast, multicast
6047 * or broadcast.
6048 */
6049 retval = e1000_enable_ulp_lpt_lp(hw, !runtime);
6050
6051 if (retval)
6052 return retval;
6053 }
6054
5998 6055
5999 /* Release control of h/w to f/w. If f/w is AMT enabled, this 6056 /* Release control of h/w to f/w. If f/w is AMT enabled, this
6000 * would have already happened in close and is redundant. 6057 * would have already happened in close and is redundant.
@@ -6102,18 +6159,12 @@ static void e1000e_disable_aspm(struct pci_dev *pdev, u16 state)
6102} 6159}
6103 6160
6104#ifdef CONFIG_PM 6161#ifdef CONFIG_PM
6105static bool e1000e_pm_ready(struct e1000_adapter *adapter)
6106{
6107 return !!adapter->tx_ring->buffer_info;
6108}
6109
6110static int __e1000_resume(struct pci_dev *pdev) 6162static int __e1000_resume(struct pci_dev *pdev)
6111{ 6163{
6112 struct net_device *netdev = pci_get_drvdata(pdev); 6164 struct net_device *netdev = pci_get_drvdata(pdev);
6113 struct e1000_adapter *adapter = netdev_priv(netdev); 6165 struct e1000_adapter *adapter = netdev_priv(netdev);
6114 struct e1000_hw *hw = &adapter->hw; 6166 struct e1000_hw *hw = &adapter->hw;
6115 u16 aspm_disable_flag = 0; 6167 u16 aspm_disable_flag = 0;
6116 u32 err;
6117 6168
6118 if (adapter->flags2 & FLAG2_DISABLE_ASPM_L0S) 6169 if (adapter->flags2 & FLAG2_DISABLE_ASPM_L0S)
6119 aspm_disable_flag = PCIE_LINK_STATE_L0S; 6170 aspm_disable_flag = PCIE_LINK_STATE_L0S;
@@ -6124,13 +6175,6 @@ static int __e1000_resume(struct pci_dev *pdev)
6124 6175
6125 pci_set_master(pdev); 6176 pci_set_master(pdev);
6126 6177
6127 e1000e_set_interrupt_capability(adapter);
6128 if (netif_running(netdev)) {
6129 err = e1000_request_irq(adapter);
6130 if (err)
6131 return err;
6132 }
6133
6134 if (hw->mac.type >= e1000_pch2lan) 6178 if (hw->mac.type >= e1000_pch2lan)
6135 e1000_resume_workarounds_pchlan(&adapter->hw); 6179 e1000_resume_workarounds_pchlan(&adapter->hw);
6136 6180
@@ -6169,11 +6213,6 @@ static int __e1000_resume(struct pci_dev *pdev)
6169 6213
6170 e1000_init_manageability_pt(adapter); 6214 e1000_init_manageability_pt(adapter);
6171 6215
6172 if (netif_running(netdev))
6173 e1000e_up(adapter);
6174
6175 netif_device_attach(netdev);
6176
6177 /* If the controller has AMT, do not set DRV_LOAD until the interface 6216 /* If the controller has AMT, do not set DRV_LOAD until the interface
6178 * is up. For all other cases, let the f/w know that the h/w is now 6217 * is up. For all other cases, let the f/w know that the h/w is now
6179 * under the control of the driver. 6218 * under the control of the driver.
@@ -6184,75 +6223,111 @@ static int __e1000_resume(struct pci_dev *pdev)
6184 return 0; 6223 return 0;
6185} 6224}
6186 6225
6226static int e1000e_pm_thaw(struct device *dev)
6227{
6228 struct net_device *netdev = pci_get_drvdata(to_pci_dev(dev));
6229 struct e1000_adapter *adapter = netdev_priv(netdev);
6230
6231 e1000e_set_interrupt_capability(adapter);
6232 if (netif_running(netdev)) {
6233 u32 err = e1000_request_irq(adapter);
6234
6235 if (err)
6236 return err;
6237
6238 e1000e_up(adapter);
6239 }
6240
6241 netif_device_attach(netdev);
6242
6243 return 0;
6244}
6245
6187#ifdef CONFIG_PM_SLEEP 6246#ifdef CONFIG_PM_SLEEP
6188static int e1000_suspend(struct device *dev) 6247static int e1000e_pm_suspend(struct device *dev)
6189{ 6248{
6190 struct pci_dev *pdev = to_pci_dev(dev); 6249 struct pci_dev *pdev = to_pci_dev(dev);
6191 6250
6251 e1000e_pm_freeze(dev);
6252
6192 return __e1000_shutdown(pdev, false); 6253 return __e1000_shutdown(pdev, false);
6193} 6254}
6194 6255
6195static int e1000_resume(struct device *dev) 6256static int e1000e_pm_resume(struct device *dev)
6196{ 6257{
6197 struct pci_dev *pdev = to_pci_dev(dev); 6258 struct pci_dev *pdev = to_pci_dev(dev);
6198 struct net_device *netdev = pci_get_drvdata(pdev); 6259 int rc;
6199 struct e1000_adapter *adapter = netdev_priv(netdev);
6200 6260
6201 if (e1000e_pm_ready(adapter)) 6261 rc = __e1000_resume(pdev);
6202 adapter->idle_check = true; 6262 if (rc)
6263 return rc;
6203 6264
6204 return __e1000_resume(pdev); 6265 return e1000e_pm_thaw(dev);
6205} 6266}
6206#endif /* CONFIG_PM_SLEEP */ 6267#endif /* CONFIG_PM_SLEEP */
6207 6268
6208#ifdef CONFIG_PM_RUNTIME 6269#ifdef CONFIG_PM_RUNTIME
6209static int e1000_runtime_suspend(struct device *dev) 6270static int e1000e_pm_runtime_idle(struct device *dev)
6210{ 6271{
6211 struct pci_dev *pdev = to_pci_dev(dev); 6272 struct pci_dev *pdev = to_pci_dev(dev);
6212 struct net_device *netdev = pci_get_drvdata(pdev); 6273 struct net_device *netdev = pci_get_drvdata(pdev);
6213 struct e1000_adapter *adapter = netdev_priv(netdev); 6274 struct e1000_adapter *adapter = netdev_priv(netdev);
6214 6275
6215 if (!e1000e_pm_ready(adapter)) 6276 if (!e1000e_has_link(adapter))
6216 return 0; 6277 pm_schedule_suspend(dev, 5 * MSEC_PER_SEC);
6217 6278
6218 return __e1000_shutdown(pdev, true); 6279 return -EBUSY;
6219} 6280}
6220 6281
6221static int e1000_idle(struct device *dev) 6282static int e1000e_pm_runtime_resume(struct device *dev)
6222{ 6283{
6223 struct pci_dev *pdev = to_pci_dev(dev); 6284 struct pci_dev *pdev = to_pci_dev(dev);
6224 struct net_device *netdev = pci_get_drvdata(pdev); 6285 struct net_device *netdev = pci_get_drvdata(pdev);
6225 struct e1000_adapter *adapter = netdev_priv(netdev); 6286 struct e1000_adapter *adapter = netdev_priv(netdev);
6287 int rc;
6226 6288
6227 if (!e1000e_pm_ready(adapter)) 6289 rc = __e1000_resume(pdev);
6228 return 0; 6290 if (rc)
6291 return rc;
6229 6292
6230 if (adapter->idle_check) { 6293 if (netdev->flags & IFF_UP)
6231 adapter->idle_check = false; 6294 rc = e1000e_up(adapter);
6232 if (!e1000e_has_link(adapter))
6233 pm_schedule_suspend(dev, MSEC_PER_SEC);
6234 }
6235 6295
6236 return -EBUSY; 6296 return rc;
6237} 6297}
6238 6298
6239static int e1000_runtime_resume(struct device *dev) 6299static int e1000e_pm_runtime_suspend(struct device *dev)
6240{ 6300{
6241 struct pci_dev *pdev = to_pci_dev(dev); 6301 struct pci_dev *pdev = to_pci_dev(dev);
6242 struct net_device *netdev = pci_get_drvdata(pdev); 6302 struct net_device *netdev = pci_get_drvdata(pdev);
6243 struct e1000_adapter *adapter = netdev_priv(netdev); 6303 struct e1000_adapter *adapter = netdev_priv(netdev);
6244 6304
6245 if (!e1000e_pm_ready(adapter)) 6305 if (netdev->flags & IFF_UP) {
6246 return 0; 6306 int count = E1000_CHECK_RESET_COUNT;
6247 6307
6248 adapter->idle_check = !dev->power.runtime_auto; 6308 while (test_bit(__E1000_RESETTING, &adapter->state) && count--)
6249 return __e1000_resume(pdev); 6309 usleep_range(10000, 20000);
6310
6311 WARN_ON(test_bit(__E1000_RESETTING, &adapter->state));
6312
6313 /* Down the device without resetting the hardware */
6314 e1000e_down(adapter, false);
6315 }
6316
6317 if (__e1000_shutdown(pdev, true)) {
6318 e1000e_pm_runtime_resume(dev);
6319 return -EBUSY;
6320 }
6321
6322 return 0;
6250} 6323}
6251#endif /* CONFIG_PM_RUNTIME */ 6324#endif /* CONFIG_PM_RUNTIME */
6252#endif /* CONFIG_PM */ 6325#endif /* CONFIG_PM */
6253 6326
6254static void e1000_shutdown(struct pci_dev *pdev) 6327static void e1000_shutdown(struct pci_dev *pdev)
6255{ 6328{
6329 e1000e_pm_freeze(&pdev->dev);
6330
6256 __e1000_shutdown(pdev, false); 6331 __e1000_shutdown(pdev, false);
6257} 6332}
6258 6333
@@ -6338,7 +6413,7 @@ static pci_ers_result_t e1000_io_error_detected(struct pci_dev *pdev,
6338 return PCI_ERS_RESULT_DISCONNECT; 6413 return PCI_ERS_RESULT_DISCONNECT;
6339 6414
6340 if (netif_running(netdev)) 6415 if (netif_running(netdev))
6341 e1000e_down(adapter); 6416 e1000e_down(adapter, true);
6342 pci_disable_device(pdev); 6417 pci_disable_device(pdev);
6343 6418
6344 /* Request a slot slot reset. */ 6419 /* Request a slot slot reset. */
@@ -6350,7 +6425,7 @@ static pci_ers_result_t e1000_io_error_detected(struct pci_dev *pdev,
6350 * @pdev: Pointer to PCI device 6425 * @pdev: Pointer to PCI device
6351 * 6426 *
6352 * Restart the card from scratch, as if from a cold-boot. Implementation 6427 * Restart the card from scratch, as if from a cold-boot. Implementation
6353 * resembles the first-half of the e1000_resume routine. 6428 * resembles the first-half of the e1000e_pm_resume routine.
6354 */ 6429 */
6355static pci_ers_result_t e1000_io_slot_reset(struct pci_dev *pdev) 6430static pci_ers_result_t e1000_io_slot_reset(struct pci_dev *pdev)
6356{ 6431{
@@ -6397,7 +6472,7 @@ static pci_ers_result_t e1000_io_slot_reset(struct pci_dev *pdev)
6397 * 6472 *
6398 * This callback is called when the error recovery driver tells us that 6473 * This callback is called when the error recovery driver tells us that
6399 * its OK to resume normal operation. Implementation resembles the 6474 * its OK to resume normal operation. Implementation resembles the
6400 * second-half of the e1000_resume routine. 6475 * second-half of the e1000e_pm_resume routine.
6401 */ 6476 */
6402static void e1000_io_resume(struct pci_dev *pdev) 6477static void e1000_io_resume(struct pci_dev *pdev)
6403{ 6478{
@@ -6902,9 +6977,6 @@ static void e1000_remove(struct pci_dev *pdev)
6902 } 6977 }
6903 } 6978 }
6904 6979
6905 if (!(netdev->flags & IFF_UP))
6906 e1000_power_down_phy(adapter);
6907
6908 /* Don't lie to e1000_close() down the road. */ 6980 /* Don't lie to e1000_close() down the road. */
6909 if (!down) 6981 if (!down)
6910 clear_bit(__E1000_DOWN, &adapter->state); 6982 clear_bit(__E1000_DOWN, &adapter->state);
@@ -7026,9 +7098,16 @@ static DEFINE_PCI_DEVICE_TABLE(e1000_pci_tbl) = {
7026MODULE_DEVICE_TABLE(pci, e1000_pci_tbl); 7098MODULE_DEVICE_TABLE(pci, e1000_pci_tbl);
7027 7099
7028static const struct dev_pm_ops e1000_pm_ops = { 7100static const struct dev_pm_ops e1000_pm_ops = {
7029 SET_SYSTEM_SLEEP_PM_OPS(e1000_suspend, e1000_resume) 7101#ifdef CONFIG_PM_SLEEP
7030 SET_RUNTIME_PM_OPS(e1000_runtime_suspend, e1000_runtime_resume, 7102 .suspend = e1000e_pm_suspend,
7031 e1000_idle) 7103 .resume = e1000e_pm_resume,
7104 .freeze = e1000e_pm_freeze,
7105 .thaw = e1000e_pm_thaw,
7106 .poweroff = e1000e_pm_suspend,
7107 .restore = e1000e_pm_resume,
7108#endif
7109 SET_RUNTIME_PM_OPS(e1000e_pm_runtime_suspend, e1000e_pm_runtime_resume,
7110 e1000e_pm_runtime_idle)
7032}; 7111};
7033 7112
7034/* PCI Device API Driver */ 7113/* PCI Device API Driver */
@@ -7055,7 +7134,7 @@ static int __init e1000_init_module(void)
7055 int ret; 7134 int ret;
7056 pr_info("Intel(R) PRO/1000 Network Driver - %s\n", 7135 pr_info("Intel(R) PRO/1000 Network Driver - %s\n",
7057 e1000e_driver_version); 7136 e1000e_driver_version);
7058 pr_info("Copyright(c) 1999 - 2013 Intel Corporation.\n"); 7137 pr_info("Copyright(c) 1999 - 2014 Intel Corporation.\n");
7059 ret = pci_register_driver(&e1000_driver); 7138 ret = pci_register_driver(&e1000_driver);
7060 7139
7061 return ret; 7140 return ret;
diff --git a/drivers/net/ethernet/intel/e1000e/nvm.c b/drivers/net/ethernet/intel/e1000e/nvm.c
index d70a03906ac0..a9a976f04bff 100644
--- a/drivers/net/ethernet/intel/e1000e/nvm.c
+++ b/drivers/net/ethernet/intel/e1000e/nvm.c
@@ -1,30 +1,23 @@
1/******************************************************************************* 1/* Intel PRO/1000 Linux driver
2 2 * Copyright(c) 1999 - 2014 Intel Corporation.
3 Intel PRO/1000 Linux driver 3 *
4 Copyright(c) 1999 - 2013 Intel Corporation. 4 * This program is free software; you can redistribute it and/or modify it
5 5 * under the terms and conditions of the GNU General Public License,
6 This program is free software; you can redistribute it and/or modify it 6 * version 2, as published by the Free Software Foundation.
7 under the terms and conditions of the GNU General Public License, 7 *
8 version 2, as published by the Free Software Foundation. 8 * This program is distributed in the hope it will be useful, but WITHOUT
9 9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 This program is distributed in the hope it will be useful, but WITHOUT 10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * more details.
12 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 12 *
13 more details. 13 * The full GNU General Public License is included in this distribution in
14 14 * the file called "COPYING".
15 You should have received a copy of the GNU General Public License along with 15 *
16 this program; if not, write to the Free Software Foundation, Inc., 16 * Contact Information:
17 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. 17 * Linux NICS <linux.nics@intel.com>
18 18 * e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
19 The full GNU General Public License is included in this distribution in 19 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
20 the file called "COPYING". 20 */
21
22 Contact Information:
23 Linux NICS <linux.nics@intel.com>
24 e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
25 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
26
27*******************************************************************************/
28 21
29#include "e1000.h" 22#include "e1000.h"
30 23
diff --git a/drivers/net/ethernet/intel/e1000e/nvm.h b/drivers/net/ethernet/intel/e1000e/nvm.h
index 45fc69561627..342bf69efab5 100644
--- a/drivers/net/ethernet/intel/e1000e/nvm.h
+++ b/drivers/net/ethernet/intel/e1000e/nvm.h
@@ -1,30 +1,23 @@
1/******************************************************************************* 1/* Intel PRO/1000 Linux driver
2 2 * Copyright(c) 1999 - 2014 Intel Corporation.
3 Intel PRO/1000 Linux driver 3 *
4 Copyright(c) 1999 - 2013 Intel Corporation. 4 * This program is free software; you can redistribute it and/or modify it
5 5 * under the terms and conditions of the GNU General Public License,
6 This program is free software; you can redistribute it and/or modify it 6 * version 2, as published by the Free Software Foundation.
7 under the terms and conditions of the GNU General Public License, 7 *
8 version 2, as published by the Free Software Foundation. 8 * This program is distributed in the hope it will be useful, but WITHOUT
9 9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 This program is distributed in the hope it will be useful, but WITHOUT 10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * more details.
12 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 12 *
13 more details. 13 * The full GNU General Public License is included in this distribution in
14 14 * the file called "COPYING".
15 You should have received a copy of the GNU General Public License along with 15 *
16 this program; if not, write to the Free Software Foundation, Inc., 16 * Contact Information:
17 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. 17 * Linux NICS <linux.nics@intel.com>
18 18 * e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
19 The full GNU General Public License is included in this distribution in 19 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
20 the file called "COPYING". 20 */
21
22 Contact Information:
23 Linux NICS <linux.nics@intel.com>
24 e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
25 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
26
27*******************************************************************************/
28 21
29#ifndef _E1000E_NVM_H_ 22#ifndef _E1000E_NVM_H_
30#define _E1000E_NVM_H_ 23#define _E1000E_NVM_H_
diff --git a/drivers/net/ethernet/intel/e1000e/param.c b/drivers/net/ethernet/intel/e1000e/param.c
index c16bd75b6caa..d0ac0f3249c8 100644
--- a/drivers/net/ethernet/intel/e1000e/param.c
+++ b/drivers/net/ethernet/intel/e1000e/param.c
@@ -1,30 +1,23 @@
1/******************************************************************************* 1/* Intel PRO/1000 Linux driver
2 2 * Copyright(c) 1999 - 2014 Intel Corporation.
3 Intel PRO/1000 Linux driver 3 *
4 Copyright(c) 1999 - 2013 Intel Corporation. 4 * This program is free software; you can redistribute it and/or modify it
5 5 * under the terms and conditions of the GNU General Public License,
6 This program is free software; you can redistribute it and/or modify it 6 * version 2, as published by the Free Software Foundation.
7 under the terms and conditions of the GNU General Public License, 7 *
8 version 2, as published by the Free Software Foundation. 8 * This program is distributed in the hope it will be useful, but WITHOUT
9 9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 This program is distributed in the hope it will be useful, but WITHOUT 10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * more details.
12 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 12 *
13 more details. 13 * The full GNU General Public License is included in this distribution in
14 14 * the file called "COPYING".
15 You should have received a copy of the GNU General Public License along with 15 *
16 this program; if not, write to the Free Software Foundation, Inc., 16 * Contact Information:
17 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. 17 * Linux NICS <linux.nics@intel.com>
18 18 * e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
19 The full GNU General Public License is included in this distribution in 19 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
20 the file called "COPYING". 20 */
21
22 Contact Information:
23 Linux NICS <linux.nics@intel.com>
24 e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
25 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
26
27*******************************************************************************/
28 21
29#include <linux/netdevice.h> 22#include <linux/netdevice.h>
30#include <linux/module.h> 23#include <linux/module.h>
@@ -381,6 +374,12 @@ void e1000e_check_options(struct e1000_adapter *adapter)
381 "%s set to dynamic mode\n", opt.name); 374 "%s set to dynamic mode\n", opt.name);
382 adapter->itr = 20000; 375 adapter->itr = 20000;
383 break; 376 break;
377 case 2:
378 dev_info(&adapter->pdev->dev,
379 "%s Invalid mode - setting default\n",
380 opt.name);
381 adapter->itr_setting = opt.def;
382 /* fall-through */
384 case 3: 383 case 3:
385 dev_info(&adapter->pdev->dev, 384 dev_info(&adapter->pdev->dev,
386 "%s set to dynamic conservative mode\n", 385 "%s set to dynamic conservative mode\n",
diff --git a/drivers/net/ethernet/intel/e1000e/phy.c b/drivers/net/ethernet/intel/e1000e/phy.c
index 20e71f4ca426..00b3fc98bf30 100644
--- a/drivers/net/ethernet/intel/e1000e/phy.c
+++ b/drivers/net/ethernet/intel/e1000e/phy.c
@@ -1,30 +1,23 @@
1/******************************************************************************* 1/* Intel PRO/1000 Linux driver
2 2 * Copyright(c) 1999 - 2014 Intel Corporation.
3 Intel PRO/1000 Linux driver 3 *
4 Copyright(c) 1999 - 2013 Intel Corporation. 4 * This program is free software; you can redistribute it and/or modify it
5 5 * under the terms and conditions of the GNU General Public License,
6 This program is free software; you can redistribute it and/or modify it 6 * version 2, as published by the Free Software Foundation.
7 under the terms and conditions of the GNU General Public License, 7 *
8 version 2, as published by the Free Software Foundation. 8 * This program is distributed in the hope it will be useful, but WITHOUT
9 9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 This program is distributed in the hope it will be useful, but WITHOUT 10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * more details.
12 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 12 *
13 more details. 13 * The full GNU General Public License is included in this distribution in
14 14 * the file called "COPYING".
15 You should have received a copy of the GNU General Public License along with 15 *
16 this program; if not, write to the Free Software Foundation, Inc., 16 * Contact Information:
17 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. 17 * Linux NICS <linux.nics@intel.com>
18 18 * e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
19 The full GNU General Public License is included in this distribution in 19 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
20 the file called "COPYING". 20 */
21
22 Contact Information:
23 Linux NICS <linux.nics@intel.com>
24 e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
25 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
26
27*******************************************************************************/
28 21
29#include "e1000.h" 22#include "e1000.h"
30 23
diff --git a/drivers/net/ethernet/intel/e1000e/phy.h b/drivers/net/ethernet/intel/e1000e/phy.h
index f4f71b9991e3..3841bccf058c 100644
--- a/drivers/net/ethernet/intel/e1000e/phy.h
+++ b/drivers/net/ethernet/intel/e1000e/phy.h
@@ -1,30 +1,23 @@
1/******************************************************************************* 1/* Intel PRO/1000 Linux driver
2 2 * Copyright(c) 1999 - 2014 Intel Corporation.
3 Intel PRO/1000 Linux driver 3 *
4 Copyright(c) 1999 - 2013 Intel Corporation. 4 * This program is free software; you can redistribute it and/or modify it
5 5 * under the terms and conditions of the GNU General Public License,
6 This program is free software; you can redistribute it and/or modify it 6 * version 2, as published by the Free Software Foundation.
7 under the terms and conditions of the GNU General Public License, 7 *
8 version 2, as published by the Free Software Foundation. 8 * This program is distributed in the hope it will be useful, but WITHOUT
9 9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 This program is distributed in the hope it will be useful, but WITHOUT 10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * more details.
12 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 12 *
13 more details. 13 * The full GNU General Public License is included in this distribution in
14 14 * the file called "COPYING".
15 You should have received a copy of the GNU General Public License along with 15 *
16 this program; if not, write to the Free Software Foundation, Inc., 16 * Contact Information:
17 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. 17 * Linux NICS <linux.nics@intel.com>
18 18 * e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
19 The full GNU General Public License is included in this distribution in 19 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
20 the file called "COPYING". 20 */
21
22 Contact Information:
23 Linux NICS <linux.nics@intel.com>
24 e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
25 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
26
27*******************************************************************************/
28 21
29#ifndef _E1000E_PHY_H_ 22#ifndef _E1000E_PHY_H_
30#define _E1000E_PHY_H_ 23#define _E1000E_PHY_H_
diff --git a/drivers/net/ethernet/intel/e1000e/ptp.c b/drivers/net/ethernet/intel/e1000e/ptp.c
index 065f8c80d4f2..fb1a914a3ad4 100644
--- a/drivers/net/ethernet/intel/e1000e/ptp.c
+++ b/drivers/net/ethernet/intel/e1000e/ptp.c
@@ -1,30 +1,23 @@
1/******************************************************************************* 1/* Intel PRO/1000 Linux driver
2 2 * Copyright(c) 1999 - 2014 Intel Corporation.
3 Intel PRO/1000 Linux driver 3 *
4 Copyright(c) 1999 - 2013 Intel Corporation. 4 * This program is free software; you can redistribute it and/or modify it
5 5 * under the terms and conditions of the GNU General Public License,
6 This program is free software; you can redistribute it and/or modify it 6 * version 2, as published by the Free Software Foundation.
7 under the terms and conditions of the GNU General Public License, 7 *
8 version 2, as published by the Free Software Foundation. 8 * This program is distributed in the hope it will be useful, but WITHOUT
9 9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 This program is distributed in the hope it will be useful, but WITHOUT 10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * more details.
12 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 12 *
13 more details. 13 * The full GNU General Public License is included in this distribution in
14 14 * the file called "COPYING".
15 You should have received a copy of the GNU General Public License along with 15 *
16 this program; if not, write to the Free Software Foundation, Inc., 16 * Contact Information:
17 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. 17 * Linux NICS <linux.nics@intel.com>
18 18 * e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
19 The full GNU General Public License is included in this distribution in 19 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
20 the file called "COPYING". 20 */
21
22 Contact Information:
23 Linux NICS <linux.nics@intel.com>
24 e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
25 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
26
27*******************************************************************************/
28 21
29/* PTP 1588 Hardware Clock (PHC) 22/* PTP 1588 Hardware Clock (PHC)
30 * Derived from PTP Hardware Clock driver for Intel 82576 and 82580 (igb) 23 * Derived from PTP Hardware Clock driver for Intel 82576 and 82580 (igb)
@@ -47,6 +40,7 @@ static int e1000e_phc_adjfreq(struct ptp_clock_info *ptp, s32 delta)
47 ptp_clock_info); 40 ptp_clock_info);
48 struct e1000_hw *hw = &adapter->hw; 41 struct e1000_hw *hw = &adapter->hw;
49 bool neg_adj = false; 42 bool neg_adj = false;
43 unsigned long flags;
50 u64 adjustment; 44 u64 adjustment;
51 u32 timinca, incvalue; 45 u32 timinca, incvalue;
52 s32 ret_val; 46 s32 ret_val;
@@ -64,6 +58,8 @@ static int e1000e_phc_adjfreq(struct ptp_clock_info *ptp, s32 delta)
64 if (ret_val) 58 if (ret_val)
65 return ret_val; 59 return ret_val;
66 60
61 spin_lock_irqsave(&adapter->systim_lock, flags);
62
67 incvalue = timinca & E1000_TIMINCA_INCVALUE_MASK; 63 incvalue = timinca & E1000_TIMINCA_INCVALUE_MASK;
68 64
69 adjustment = incvalue; 65 adjustment = incvalue;
@@ -77,6 +73,8 @@ static int e1000e_phc_adjfreq(struct ptp_clock_info *ptp, s32 delta)
77 73
78 ew32(TIMINCA, timinca); 74 ew32(TIMINCA, timinca);
79 75
76 spin_unlock_irqrestore(&adapter->systim_lock, flags);
77
80 return 0; 78 return 0;
81} 79}
82 80
@@ -191,6 +189,7 @@ static const struct ptp_clock_info e1000e_ptp_clock_info = {
191 .n_alarm = 0, 189 .n_alarm = 0,
192 .n_ext_ts = 0, 190 .n_ext_ts = 0,
193 .n_per_out = 0, 191 .n_per_out = 0,
192 .n_pins = 0,
194 .pps = 0, 193 .pps = 0,
195 .adjfreq = e1000e_phc_adjfreq, 194 .adjfreq = e1000e_phc_adjfreq,
196 .adjtime = e1000e_phc_adjtime, 195 .adjtime = e1000e_phc_adjtime,
diff --git a/drivers/net/ethernet/intel/e1000e/regs.h b/drivers/net/ethernet/intel/e1000e/regs.h
index a7e6a3e37257..ea235bbe50d3 100644
--- a/drivers/net/ethernet/intel/e1000e/regs.h
+++ b/drivers/net/ethernet/intel/e1000e/regs.h
@@ -1,30 +1,23 @@
1/******************************************************************************* 1/* Intel PRO/1000 Linux driver
2 2 * Copyright(c) 1999 - 2014 Intel Corporation.
3 Intel PRO/1000 Linux driver 3 *
4 Copyright(c) 1999 - 2013 Intel Corporation. 4 * This program is free software; you can redistribute it and/or modify it
5 5 * under the terms and conditions of the GNU General Public License,
6 This program is free software; you can redistribute it and/or modify it 6 * version 2, as published by the Free Software Foundation.
7 under the terms and conditions of the GNU General Public License, 7 *
8 version 2, as published by the Free Software Foundation. 8 * This program is distributed in the hope it will be useful, but WITHOUT
9 9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 This program is distributed in the hope it will be useful, but WITHOUT 10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * more details.
12 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 12 *
13 more details. 13 * The full GNU General Public License is included in this distribution in
14 14 * the file called "COPYING".
15 You should have received a copy of the GNU General Public License along with 15 *
16 this program; if not, write to the Free Software Foundation, Inc., 16 * Contact Information:
17 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. 17 * Linux NICS <linux.nics@intel.com>
18 18 * e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
19 The full GNU General Public License is included in this distribution in 19 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
20 the file called "COPYING". 20 */
21
22 Contact Information:
23 Linux NICS <linux.nics@intel.com>
24 e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
25 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
26
27*******************************************************************************/
28 21
29#ifndef _E1000E_REGS_H_ 22#ifndef _E1000E_REGS_H_
30#define _E1000E_REGS_H_ 23#define _E1000E_REGS_H_
@@ -39,6 +32,7 @@
39#define E1000_SCTL 0x00024 /* SerDes Control - RW */ 32#define E1000_SCTL 0x00024 /* SerDes Control - RW */
40#define E1000_FCAL 0x00028 /* Flow Control Address Low - RW */ 33#define E1000_FCAL 0x00028 /* Flow Control Address Low - RW */
41#define E1000_FCAH 0x0002C /* Flow Control Address High -RW */ 34#define E1000_FCAH 0x0002C /* Flow Control Address High -RW */
35#define E1000_FEXT 0x0002C /* Future Extended - RW */
42#define E1000_FEXTNVM 0x00028 /* Future Extended NVM - RW */ 36#define E1000_FEXTNVM 0x00028 /* Future Extended NVM - RW */
43#define E1000_FEXTNVM3 0x0003C /* Future Extended NVM 3 - RW */ 37#define E1000_FEXTNVM3 0x0003C /* Future Extended NVM 3 - RW */
44#define E1000_FEXTNVM4 0x00024 /* Future Extended NVM 4 - RW */ 38#define E1000_FEXTNVM4 0x00024 /* Future Extended NVM 4 - RW */
diff --git a/drivers/net/ethernet/intel/i40e/i40e.h b/drivers/net/ethernet/intel/i40e/i40e.h
index 72dae4d97b43..33cd8b67535d 100644
--- a/drivers/net/ethernet/intel/i40e/i40e.h
+++ b/drivers/net/ethernet/intel/i40e/i40e.h
@@ -86,12 +86,12 @@
86 86
87#define I40E_NVM_VERSION_LO_SHIFT 0 87#define I40E_NVM_VERSION_LO_SHIFT 0
88#define I40E_NVM_VERSION_LO_MASK (0xff << I40E_NVM_VERSION_LO_SHIFT) 88#define I40E_NVM_VERSION_LO_MASK (0xff << I40E_NVM_VERSION_LO_SHIFT)
89#define I40E_NVM_VERSION_HI_SHIFT 8 89#define I40E_NVM_VERSION_HI_SHIFT 12
90#define I40E_NVM_VERSION_HI_MASK (0xff << I40E_NVM_VERSION_HI_SHIFT) 90#define I40E_NVM_VERSION_HI_MASK (0xf << I40E_NVM_VERSION_HI_SHIFT)
91 91
92/* The values in here are decimal coded as hex as is the case in the NVM map*/ 92/* The values in here are decimal coded as hex as is the case in the NVM map*/
93#define I40E_CURRENT_NVM_VERSION_HI 0x2 93#define I40E_CURRENT_NVM_VERSION_HI 0x2
94#define I40E_CURRENT_NVM_VERSION_LO 0x30 94#define I40E_CURRENT_NVM_VERSION_LO 0x40
95 95
96/* magic for getting defines into strings */ 96/* magic for getting defines into strings */
97#define STRINGIFY(foo) #foo 97#define STRINGIFY(foo) #foo
@@ -152,8 +152,21 @@ struct i40e_lump_tracking {
152}; 152};
153 153
154#define I40E_DEFAULT_ATR_SAMPLE_RATE 20 154#define I40E_DEFAULT_ATR_SAMPLE_RATE 20
155#define I40E_FDIR_MAX_RAW_PACKET_LOOKUP 512 155#define I40E_FDIR_MAX_RAW_PACKET_SIZE 512
156struct i40e_fdir_data { 156#define I40E_FDIR_BUFFER_FULL_MARGIN 10
157#define I40E_FDIR_BUFFER_HEAD_ROOM 200
158
159struct i40e_fdir_filter {
160 struct hlist_node fdir_node;
161 /* filter ipnut set */
162 u8 flow_type;
163 u8 ip4_proto;
164 __be32 dst_ip[4];
165 __be32 src_ip[4];
166 __be16 src_port;
167 __be16 dst_port;
168 __be32 sctp_v_tag;
169 /* filter control */
157 u16 q_index; 170 u16 q_index;
158 u8 flex_off; 171 u8 flex_off;
159 u8 pctype; 172 u8 pctype;
@@ -162,7 +175,6 @@ struct i40e_fdir_data {
162 u8 fd_status; 175 u8 fd_status;
163 u16 cnt_index; 176 u16 cnt_index;
164 u32 fd_id; 177 u32 fd_id;
165 u8 *raw_packet;
166}; 178};
167 179
168#define I40E_ETH_P_LLDP 0x88cc 180#define I40E_ETH_P_LLDP 0x88cc
@@ -196,7 +208,7 @@ struct i40e_pf {
196 bool fc_autoneg_status; 208 bool fc_autoneg_status;
197 209
198 u16 eeprom_version; 210 u16 eeprom_version;
199 u16 num_vmdq_vsis; /* num vmdq pools this pf has set up */ 211 u16 num_vmdq_vsis; /* num vmdq vsis this pf has set up */
200 u16 num_vmdq_qps; /* num queue pairs per vmdq pool */ 212 u16 num_vmdq_qps; /* num queue pairs per vmdq pool */
201 u16 num_vmdq_msix; /* num queue vectors per vmdq pool */ 213 u16 num_vmdq_msix; /* num queue vectors per vmdq pool */
202 u16 num_req_vfs; /* num vfs requested for this vf */ 214 u16 num_req_vfs; /* num vfs requested for this vf */
@@ -210,6 +222,9 @@ struct i40e_pf {
210 u8 atr_sample_rate; 222 u8 atr_sample_rate;
211 bool wol_en; 223 bool wol_en;
212 224
225 struct hlist_head fdir_filter_list;
226 u16 fdir_pf_active_filters;
227
213#ifdef CONFIG_I40E_VXLAN 228#ifdef CONFIG_I40E_VXLAN
214 __be16 vxlan_ports[I40E_MAX_PF_UDP_OFFLOAD_PORTS]; 229 __be16 vxlan_ports[I40E_MAX_PF_UDP_OFFLOAD_PORTS];
215 u16 pending_vxlan_bitmap; 230 u16 pending_vxlan_bitmap;
@@ -251,6 +266,9 @@ struct i40e_pf {
251#define I40E_FLAG_VXLAN_FILTER_SYNC (u64)(1 << 27) 266#define I40E_FLAG_VXLAN_FILTER_SYNC (u64)(1 << 27)
252#endif 267#endif
253 268
269 /* tracks features that get auto disabled by errors */
270 u64 auto_disable_flags;
271
254 bool stat_offsets_loaded; 272 bool stat_offsets_loaded;
255 struct i40e_hw_port_stats stats; 273 struct i40e_hw_port_stats stats;
256 struct i40e_hw_port_stats stats_offsets; 274 struct i40e_hw_port_stats stats_offsets;
@@ -477,10 +495,10 @@ static inline char *i40e_fw_version_str(struct i40e_hw *hw)
477 "f%d.%d a%d.%d n%02x.%02x e%08x", 495 "f%d.%d a%d.%d n%02x.%02x e%08x",
478 hw->aq.fw_maj_ver, hw->aq.fw_min_ver, 496 hw->aq.fw_maj_ver, hw->aq.fw_min_ver,
479 hw->aq.api_maj_ver, hw->aq.api_min_ver, 497 hw->aq.api_maj_ver, hw->aq.api_min_ver,
480 (hw->nvm.version & I40E_NVM_VERSION_HI_MASK) 498 (hw->nvm.version & I40E_NVM_VERSION_HI_MASK) >>
481 >> I40E_NVM_VERSION_HI_SHIFT, 499 I40E_NVM_VERSION_HI_SHIFT,
482 (hw->nvm.version & I40E_NVM_VERSION_LO_MASK) 500 (hw->nvm.version & I40E_NVM_VERSION_LO_MASK) >>
483 >> I40E_NVM_VERSION_LO_SHIFT, 501 I40E_NVM_VERSION_LO_SHIFT,
484 hw->nvm.eetrack); 502 hw->nvm.eetrack);
485 503
486 return buf; 504 return buf;
@@ -534,9 +552,13 @@ struct rtnl_link_stats64 *i40e_get_vsi_stats_struct(struct i40e_vsi *vsi);
534int i40e_fetch_switch_configuration(struct i40e_pf *pf, 552int i40e_fetch_switch_configuration(struct i40e_pf *pf,
535 bool printconfig); 553 bool printconfig);
536 554
537int i40e_program_fdir_filter(struct i40e_fdir_data *fdir_data, 555int i40e_program_fdir_filter(struct i40e_fdir_filter *fdir_data, u8 *raw_packet,
538 struct i40e_pf *pf, bool add); 556 struct i40e_pf *pf, bool add);
539 557int i40e_add_del_fdir(struct i40e_vsi *vsi,
558 struct i40e_fdir_filter *input, bool add);
559void i40e_fdir_check_and_reenable(struct i40e_pf *pf);
560int i40e_get_current_fd_count(struct i40e_pf *pf);
561bool i40e_set_ntuple(struct i40e_pf *pf, netdev_features_t features);
540void i40e_set_ethtool_ops(struct net_device *netdev); 562void i40e_set_ethtool_ops(struct net_device *netdev);
541struct i40e_mac_filter *i40e_add_filter(struct i40e_vsi *vsi, 563struct i40e_mac_filter *i40e_add_filter(struct i40e_vsi *vsi,
542 u8 *macaddr, s16 vlan, 564 u8 *macaddr, s16 vlan,
@@ -575,6 +597,7 @@ void i40e_irq_dynamic_enable(struct i40e_vsi *vsi, int vector);
575void i40e_irq_dynamic_disable_icr0(struct i40e_pf *pf); 597void i40e_irq_dynamic_disable_icr0(struct i40e_pf *pf);
576void i40e_irq_dynamic_enable_icr0(struct i40e_pf *pf); 598void i40e_irq_dynamic_enable_icr0(struct i40e_pf *pf);
577int i40e_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd); 599int i40e_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd);
600int i40e_vsi_open(struct i40e_vsi *vsi);
578void i40e_vlan_stripping_disable(struct i40e_vsi *vsi); 601void i40e_vlan_stripping_disable(struct i40e_vsi *vsi);
579int i40e_vsi_add_vlan(struct i40e_vsi *vsi, s16 vid); 602int i40e_vsi_add_vlan(struct i40e_vsi *vsi, s16 vid);
580int i40e_vsi_kill_vlan(struct i40e_vsi *vsi, s16 vid); 603int i40e_vsi_kill_vlan(struct i40e_vsi *vsi, s16 vid);
diff --git a/drivers/net/ethernet/intel/i40e/i40e_adminq.c b/drivers/net/ethernet/intel/i40e/i40e_adminq.c
index a50e6b3479ae..ed3902bf249b 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_adminq.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_adminq.c
@@ -647,9 +647,8 @@ static u16 i40e_clean_asq(struct i40e_hw *hw)
647 desc_cb = *desc; 647 desc_cb = *desc;
648 cb_func(hw, &desc_cb); 648 cb_func(hw, &desc_cb);
649 } 649 }
650 memset((void *)desc, 0, sizeof(struct i40e_aq_desc)); 650 memset(desc, 0, sizeof(*desc));
651 memset((void *)details, 0, 651 memset(details, 0, sizeof(*details));
652 sizeof(struct i40e_asq_cmd_details));
653 ntc++; 652 ntc++;
654 if (ntc == asq->count) 653 if (ntc == asq->count)
655 ntc = 0; 654 ntc = 0;
diff --git a/drivers/net/ethernet/intel/i40e/i40e_common.c b/drivers/net/ethernet/intel/i40e/i40e_common.c
index e7f38b57834d..bb948dd92474 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_common.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_common.c
@@ -162,6 +162,372 @@ i40e_status i40e_aq_queue_shutdown(struct i40e_hw *hw,
162 return status; 162 return status;
163} 163}
164 164
165/* The i40e_ptype_lookup table is used to convert from the 8-bit ptype in the
166 * hardware to a bit-field that can be used by SW to more easily determine the
167 * packet type.
168 *
169 * Macros are used to shorten the table lines and make this table human
170 * readable.
171 *
172 * We store the PTYPE in the top byte of the bit field - this is just so that
173 * we can check that the table doesn't have a row missing, as the index into
174 * the table should be the PTYPE.
175 *
176 * Typical work flow:
177 *
178 * IF NOT i40e_ptype_lookup[ptype].known
179 * THEN
180 * Packet is unknown
181 * ELSE IF i40e_ptype_lookup[ptype].outer_ip == I40E_RX_PTYPE_OUTER_IP
182 * Use the rest of the fields to look at the tunnels, inner protocols, etc
183 * ELSE
184 * Use the enum i40e_rx_l2_ptype to decode the packet type
185 * ENDIF
186 */
187
188/* macro to make the table lines short */
189#define I40E_PTT(PTYPE, OUTER_IP, OUTER_IP_VER, OUTER_FRAG, T, TE, TEF, I, PL)\
190 { PTYPE, \
191 1, \
192 I40E_RX_PTYPE_OUTER_##OUTER_IP, \
193 I40E_RX_PTYPE_OUTER_##OUTER_IP_VER, \
194 I40E_RX_PTYPE_##OUTER_FRAG, \
195 I40E_RX_PTYPE_TUNNEL_##T, \
196 I40E_RX_PTYPE_TUNNEL_END_##TE, \
197 I40E_RX_PTYPE_##TEF, \
198 I40E_RX_PTYPE_INNER_PROT_##I, \
199 I40E_RX_PTYPE_PAYLOAD_LAYER_##PL }
200
201#define I40E_PTT_UNUSED_ENTRY(PTYPE) \
202 { PTYPE, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
203
204/* shorter macros makes the table fit but are terse */
205#define I40E_RX_PTYPE_NOF I40E_RX_PTYPE_NOT_FRAG
206#define I40E_RX_PTYPE_FRG I40E_RX_PTYPE_FRAG
207#define I40E_RX_PTYPE_INNER_PROT_TS I40E_RX_PTYPE_INNER_PROT_TIMESYNC
208
209/* Lookup table mapping the HW PTYPE to the bit field for decoding */
210struct i40e_rx_ptype_decoded i40e_ptype_lookup[] = {
211 /* L2 Packet types */
212 I40E_PTT_UNUSED_ENTRY(0),
213 I40E_PTT(1, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY2),
214 I40E_PTT(2, L2, NONE, NOF, NONE, NONE, NOF, TS, PAY2),
215 I40E_PTT(3, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY2),
216 I40E_PTT_UNUSED_ENTRY(4),
217 I40E_PTT_UNUSED_ENTRY(5),
218 I40E_PTT(6, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY2),
219 I40E_PTT(7, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY2),
220 I40E_PTT_UNUSED_ENTRY(8),
221 I40E_PTT_UNUSED_ENTRY(9),
222 I40E_PTT(10, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY2),
223 I40E_PTT(11, L2, NONE, NOF, NONE, NONE, NOF, NONE, NONE),
224 I40E_PTT(12, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3),
225 I40E_PTT(13, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3),
226 I40E_PTT(14, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3),
227 I40E_PTT(15, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3),
228 I40E_PTT(16, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3),
229 I40E_PTT(17, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3),
230 I40E_PTT(18, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3),
231 I40E_PTT(19, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3),
232 I40E_PTT(20, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3),
233 I40E_PTT(21, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3),
234
235 /* Non Tunneled IPv4 */
236 I40E_PTT(22, IP, IPV4, FRG, NONE, NONE, NOF, NONE, PAY3),
237 I40E_PTT(23, IP, IPV4, NOF, NONE, NONE, NOF, NONE, PAY3),
238 I40E_PTT(24, IP, IPV4, NOF, NONE, NONE, NOF, UDP, PAY4),
239 I40E_PTT_UNUSED_ENTRY(25),
240 I40E_PTT(26, IP, IPV4, NOF, NONE, NONE, NOF, TCP, PAY4),
241 I40E_PTT(27, IP, IPV4, NOF, NONE, NONE, NOF, SCTP, PAY4),
242 I40E_PTT(28, IP, IPV4, NOF, NONE, NONE, NOF, ICMP, PAY4),
243
244 /* IPv4 --> IPv4 */
245 I40E_PTT(29, IP, IPV4, NOF, IP_IP, IPV4, FRG, NONE, PAY3),
246 I40E_PTT(30, IP, IPV4, NOF, IP_IP, IPV4, NOF, NONE, PAY3),
247 I40E_PTT(31, IP, IPV4, NOF, IP_IP, IPV4, NOF, UDP, PAY4),
248 I40E_PTT_UNUSED_ENTRY(32),
249 I40E_PTT(33, IP, IPV4, NOF, IP_IP, IPV4, NOF, TCP, PAY4),
250 I40E_PTT(34, IP, IPV4, NOF, IP_IP, IPV4, NOF, SCTP, PAY4),
251 I40E_PTT(35, IP, IPV4, NOF, IP_IP, IPV4, NOF, ICMP, PAY4),
252
253 /* IPv4 --> IPv6 */
254 I40E_PTT(36, IP, IPV4, NOF, IP_IP, IPV6, FRG, NONE, PAY3),
255 I40E_PTT(37, IP, IPV4, NOF, IP_IP, IPV6, NOF, NONE, PAY3),
256 I40E_PTT(38, IP, IPV4, NOF, IP_IP, IPV6, NOF, UDP, PAY4),
257 I40E_PTT_UNUSED_ENTRY(39),
258 I40E_PTT(40, IP, IPV4, NOF, IP_IP, IPV6, NOF, TCP, PAY4),
259 I40E_PTT(41, IP, IPV4, NOF, IP_IP, IPV6, NOF, SCTP, PAY4),
260 I40E_PTT(42, IP, IPV4, NOF, IP_IP, IPV6, NOF, ICMP, PAY4),
261
262 /* IPv4 --> GRE/NAT */
263 I40E_PTT(43, IP, IPV4, NOF, IP_GRENAT, NONE, NOF, NONE, PAY3),
264
265 /* IPv4 --> GRE/NAT --> IPv4 */
266 I40E_PTT(44, IP, IPV4, NOF, IP_GRENAT, IPV4, FRG, NONE, PAY3),
267 I40E_PTT(45, IP, IPV4, NOF, IP_GRENAT, IPV4, NOF, NONE, PAY3),
268 I40E_PTT(46, IP, IPV4, NOF, IP_GRENAT, IPV4, NOF, UDP, PAY4),
269 I40E_PTT_UNUSED_ENTRY(47),
270 I40E_PTT(48, IP, IPV4, NOF, IP_GRENAT, IPV4, NOF, TCP, PAY4),
271 I40E_PTT(49, IP, IPV4, NOF, IP_GRENAT, IPV4, NOF, SCTP, PAY4),
272 I40E_PTT(50, IP, IPV4, NOF, IP_GRENAT, IPV4, NOF, ICMP, PAY4),
273
274 /* IPv4 --> GRE/NAT --> IPv6 */
275 I40E_PTT(51, IP, IPV4, NOF, IP_GRENAT, IPV6, FRG, NONE, PAY3),
276 I40E_PTT(52, IP, IPV4, NOF, IP_GRENAT, IPV6, NOF, NONE, PAY3),
277 I40E_PTT(53, IP, IPV4, NOF, IP_GRENAT, IPV6, NOF, UDP, PAY4),
278 I40E_PTT_UNUSED_ENTRY(54),
279 I40E_PTT(55, IP, IPV4, NOF, IP_GRENAT, IPV6, NOF, TCP, PAY4),
280 I40E_PTT(56, IP, IPV4, NOF, IP_GRENAT, IPV6, NOF, SCTP, PAY4),
281 I40E_PTT(57, IP, IPV4, NOF, IP_GRENAT, IPV6, NOF, ICMP, PAY4),
282
283 /* IPv4 --> GRE/NAT --> MAC */
284 I40E_PTT(58, IP, IPV4, NOF, IP_GRENAT_MAC, NONE, NOF, NONE, PAY3),
285
286 /* IPv4 --> GRE/NAT --> MAC --> IPv4 */
287 I40E_PTT(59, IP, IPV4, NOF, IP_GRENAT_MAC, IPV4, FRG, NONE, PAY3),
288 I40E_PTT(60, IP, IPV4, NOF, IP_GRENAT_MAC, IPV4, NOF, NONE, PAY3),
289 I40E_PTT(61, IP, IPV4, NOF, IP_GRENAT_MAC, IPV4, NOF, UDP, PAY4),
290 I40E_PTT_UNUSED_ENTRY(62),
291 I40E_PTT(63, IP, IPV4, NOF, IP_GRENAT_MAC, IPV4, NOF, TCP, PAY4),
292 I40E_PTT(64, IP, IPV4, NOF, IP_GRENAT_MAC, IPV4, NOF, SCTP, PAY4),
293 I40E_PTT(65, IP, IPV4, NOF, IP_GRENAT_MAC, IPV4, NOF, ICMP, PAY4),
294
295 /* IPv4 --> GRE/NAT -> MAC --> IPv6 */
296 I40E_PTT(66, IP, IPV4, NOF, IP_GRENAT_MAC, IPV6, FRG, NONE, PAY3),
297 I40E_PTT(67, IP, IPV4, NOF, IP_GRENAT_MAC, IPV6, NOF, NONE, PAY3),
298 I40E_PTT(68, IP, IPV4, NOF, IP_GRENAT_MAC, IPV6, NOF, UDP, PAY4),
299 I40E_PTT_UNUSED_ENTRY(69),
300 I40E_PTT(70, IP, IPV4, NOF, IP_GRENAT_MAC, IPV6, NOF, TCP, PAY4),
301 I40E_PTT(71, IP, IPV4, NOF, IP_GRENAT_MAC, IPV6, NOF, SCTP, PAY4),
302 I40E_PTT(72, IP, IPV4, NOF, IP_GRENAT_MAC, IPV6, NOF, ICMP, PAY4),
303
304 /* IPv4 --> GRE/NAT --> MAC/VLAN */
305 I40E_PTT(73, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, NONE, NOF, NONE, PAY3),
306
307 /* IPv4 ---> GRE/NAT -> MAC/VLAN --> IPv4 */
308 I40E_PTT(74, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV4, FRG, NONE, PAY3),
309 I40E_PTT(75, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, NONE, PAY3),
310 I40E_PTT(76, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, UDP, PAY4),
311 I40E_PTT_UNUSED_ENTRY(77),
312 I40E_PTT(78, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, TCP, PAY4),
313 I40E_PTT(79, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, SCTP, PAY4),
314 I40E_PTT(80, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, ICMP, PAY4),
315
316 /* IPv4 -> GRE/NAT -> MAC/VLAN --> IPv6 */
317 I40E_PTT(81, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV6, FRG, NONE, PAY3),
318 I40E_PTT(82, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, NONE, PAY3),
319 I40E_PTT(83, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, UDP, PAY4),
320 I40E_PTT_UNUSED_ENTRY(84),
321 I40E_PTT(85, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, TCP, PAY4),
322 I40E_PTT(86, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, SCTP, PAY4),
323 I40E_PTT(87, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, ICMP, PAY4),
324
325 /* Non Tunneled IPv6 */
326 I40E_PTT(88, IP, IPV6, FRG, NONE, NONE, NOF, NONE, PAY3),
327 I40E_PTT(89, IP, IPV6, NOF, NONE, NONE, NOF, NONE, PAY3),
328 I40E_PTT(90, IP, IPV6, NOF, NONE, NONE, NOF, UDP, PAY3),
329 I40E_PTT_UNUSED_ENTRY(91),
330 I40E_PTT(92, IP, IPV6, NOF, NONE, NONE, NOF, TCP, PAY4),
331 I40E_PTT(93, IP, IPV6, NOF, NONE, NONE, NOF, SCTP, PAY4),
332 I40E_PTT(94, IP, IPV6, NOF, NONE, NONE, NOF, ICMP, PAY4),
333
334 /* IPv6 --> IPv4 */
335 I40E_PTT(95, IP, IPV6, NOF, IP_IP, IPV4, FRG, NONE, PAY3),
336 I40E_PTT(96, IP, IPV6, NOF, IP_IP, IPV4, NOF, NONE, PAY3),
337 I40E_PTT(97, IP, IPV6, NOF, IP_IP, IPV4, NOF, UDP, PAY4),
338 I40E_PTT_UNUSED_ENTRY(98),
339 I40E_PTT(99, IP, IPV6, NOF, IP_IP, IPV4, NOF, TCP, PAY4),
340 I40E_PTT(100, IP, IPV6, NOF, IP_IP, IPV4, NOF, SCTP, PAY4),
341 I40E_PTT(101, IP, IPV6, NOF, IP_IP, IPV4, NOF, ICMP, PAY4),
342
343 /* IPv6 --> IPv6 */
344 I40E_PTT(102, IP, IPV6, NOF, IP_IP, IPV6, FRG, NONE, PAY3),
345 I40E_PTT(103, IP, IPV6, NOF, IP_IP, IPV6, NOF, NONE, PAY3),
346 I40E_PTT(104, IP, IPV6, NOF, IP_IP, IPV6, NOF, UDP, PAY4),
347 I40E_PTT_UNUSED_ENTRY(105),
348 I40E_PTT(106, IP, IPV6, NOF, IP_IP, IPV6, NOF, TCP, PAY4),
349 I40E_PTT(107, IP, IPV6, NOF, IP_IP, IPV6, NOF, SCTP, PAY4),
350 I40E_PTT(108, IP, IPV6, NOF, IP_IP, IPV6, NOF, ICMP, PAY4),
351
352 /* IPv6 --> GRE/NAT */
353 I40E_PTT(109, IP, IPV6, NOF, IP_GRENAT, NONE, NOF, NONE, PAY3),
354
355 /* IPv6 --> GRE/NAT -> IPv4 */
356 I40E_PTT(110, IP, IPV6, NOF, IP_GRENAT, IPV4, FRG, NONE, PAY3),
357 I40E_PTT(111, IP, IPV6, NOF, IP_GRENAT, IPV4, NOF, NONE, PAY3),
358 I40E_PTT(112, IP, IPV6, NOF, IP_GRENAT, IPV4, NOF, UDP, PAY4),
359 I40E_PTT_UNUSED_ENTRY(113),
360 I40E_PTT(114, IP, IPV6, NOF, IP_GRENAT, IPV4, NOF, TCP, PAY4),
361 I40E_PTT(115, IP, IPV6, NOF, IP_GRENAT, IPV4, NOF, SCTP, PAY4),
362 I40E_PTT(116, IP, IPV6, NOF, IP_GRENAT, IPV4, NOF, ICMP, PAY4),
363
364 /* IPv6 --> GRE/NAT -> IPv6 */
365 I40E_PTT(117, IP, IPV6, NOF, IP_GRENAT, IPV6, FRG, NONE, PAY3),
366 I40E_PTT(118, IP, IPV6, NOF, IP_GRENAT, IPV6, NOF, NONE, PAY3),
367 I40E_PTT(119, IP, IPV6, NOF, IP_GRENAT, IPV6, NOF, UDP, PAY4),
368 I40E_PTT_UNUSED_ENTRY(120),
369 I40E_PTT(121, IP, IPV6, NOF, IP_GRENAT, IPV6, NOF, TCP, PAY4),
370 I40E_PTT(122, IP, IPV6, NOF, IP_GRENAT, IPV6, NOF, SCTP, PAY4),
371 I40E_PTT(123, IP, IPV6, NOF, IP_GRENAT, IPV6, NOF, ICMP, PAY4),
372
373 /* IPv6 --> GRE/NAT -> MAC */
374 I40E_PTT(124, IP, IPV6, NOF, IP_GRENAT_MAC, NONE, NOF, NONE, PAY3),
375
376 /* IPv6 --> GRE/NAT -> MAC -> IPv4 */
377 I40E_PTT(125, IP, IPV6, NOF, IP_GRENAT_MAC, IPV4, FRG, NONE, PAY3),
378 I40E_PTT(126, IP, IPV6, NOF, IP_GRENAT_MAC, IPV4, NOF, NONE, PAY3),
379 I40E_PTT(127, IP, IPV6, NOF, IP_GRENAT_MAC, IPV4, NOF, UDP, PAY4),
380 I40E_PTT_UNUSED_ENTRY(128),
381 I40E_PTT(129, IP, IPV6, NOF, IP_GRENAT_MAC, IPV4, NOF, TCP, PAY4),
382 I40E_PTT(130, IP, IPV6, NOF, IP_GRENAT_MAC, IPV4, NOF, SCTP, PAY4),
383 I40E_PTT(131, IP, IPV6, NOF, IP_GRENAT_MAC, IPV4, NOF, ICMP, PAY4),
384
385 /* IPv6 --> GRE/NAT -> MAC -> IPv6 */
386 I40E_PTT(132, IP, IPV6, NOF, IP_GRENAT_MAC, IPV6, FRG, NONE, PAY3),
387 I40E_PTT(133, IP, IPV6, NOF, IP_GRENAT_MAC, IPV6, NOF, NONE, PAY3),
388 I40E_PTT(134, IP, IPV6, NOF, IP_GRENAT_MAC, IPV6, NOF, UDP, PAY4),
389 I40E_PTT_UNUSED_ENTRY(135),
390 I40E_PTT(136, IP, IPV6, NOF, IP_GRENAT_MAC, IPV6, NOF, TCP, PAY4),
391 I40E_PTT(137, IP, IPV6, NOF, IP_GRENAT_MAC, IPV6, NOF, SCTP, PAY4),
392 I40E_PTT(138, IP, IPV6, NOF, IP_GRENAT_MAC, IPV6, NOF, ICMP, PAY4),
393
394 /* IPv6 --> GRE/NAT -> MAC/VLAN */
395 I40E_PTT(139, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, NONE, NOF, NONE, PAY3),
396
397 /* IPv6 --> GRE/NAT -> MAC/VLAN --> IPv4 */
398 I40E_PTT(140, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV4, FRG, NONE, PAY3),
399 I40E_PTT(141, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, NONE, PAY3),
400 I40E_PTT(142, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, UDP, PAY4),
401 I40E_PTT_UNUSED_ENTRY(143),
402 I40E_PTT(144, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, TCP, PAY4),
403 I40E_PTT(145, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, SCTP, PAY4),
404 I40E_PTT(146, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, ICMP, PAY4),
405
406 /* IPv6 --> GRE/NAT -> MAC/VLAN --> IPv6 */
407 I40E_PTT(147, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV6, FRG, NONE, PAY3),
408 I40E_PTT(148, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, NONE, PAY3),
409 I40E_PTT(149, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, UDP, PAY4),
410 I40E_PTT_UNUSED_ENTRY(150),
411 I40E_PTT(151, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, TCP, PAY4),
412 I40E_PTT(152, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, SCTP, PAY4),
413 I40E_PTT(153, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, ICMP, PAY4),
414
415 /* unused entries */
416 I40E_PTT_UNUSED_ENTRY(154),
417 I40E_PTT_UNUSED_ENTRY(155),
418 I40E_PTT_UNUSED_ENTRY(156),
419 I40E_PTT_UNUSED_ENTRY(157),
420 I40E_PTT_UNUSED_ENTRY(158),
421 I40E_PTT_UNUSED_ENTRY(159),
422
423 I40E_PTT_UNUSED_ENTRY(160),
424 I40E_PTT_UNUSED_ENTRY(161),
425 I40E_PTT_UNUSED_ENTRY(162),
426 I40E_PTT_UNUSED_ENTRY(163),
427 I40E_PTT_UNUSED_ENTRY(164),
428 I40E_PTT_UNUSED_ENTRY(165),
429 I40E_PTT_UNUSED_ENTRY(166),
430 I40E_PTT_UNUSED_ENTRY(167),
431 I40E_PTT_UNUSED_ENTRY(168),
432 I40E_PTT_UNUSED_ENTRY(169),
433
434 I40E_PTT_UNUSED_ENTRY(170),
435 I40E_PTT_UNUSED_ENTRY(171),
436 I40E_PTT_UNUSED_ENTRY(172),
437 I40E_PTT_UNUSED_ENTRY(173),
438 I40E_PTT_UNUSED_ENTRY(174),
439 I40E_PTT_UNUSED_ENTRY(175),
440 I40E_PTT_UNUSED_ENTRY(176),
441 I40E_PTT_UNUSED_ENTRY(177),
442 I40E_PTT_UNUSED_ENTRY(178),
443 I40E_PTT_UNUSED_ENTRY(179),
444
445 I40E_PTT_UNUSED_ENTRY(180),
446 I40E_PTT_UNUSED_ENTRY(181),
447 I40E_PTT_UNUSED_ENTRY(182),
448 I40E_PTT_UNUSED_ENTRY(183),
449 I40E_PTT_UNUSED_ENTRY(184),
450 I40E_PTT_UNUSED_ENTRY(185),
451 I40E_PTT_UNUSED_ENTRY(186),
452 I40E_PTT_UNUSED_ENTRY(187),
453 I40E_PTT_UNUSED_ENTRY(188),
454 I40E_PTT_UNUSED_ENTRY(189),
455
456 I40E_PTT_UNUSED_ENTRY(190),
457 I40E_PTT_UNUSED_ENTRY(191),
458 I40E_PTT_UNUSED_ENTRY(192),
459 I40E_PTT_UNUSED_ENTRY(193),
460 I40E_PTT_UNUSED_ENTRY(194),
461 I40E_PTT_UNUSED_ENTRY(195),
462 I40E_PTT_UNUSED_ENTRY(196),
463 I40E_PTT_UNUSED_ENTRY(197),
464 I40E_PTT_UNUSED_ENTRY(198),
465 I40E_PTT_UNUSED_ENTRY(199),
466
467 I40E_PTT_UNUSED_ENTRY(200),
468 I40E_PTT_UNUSED_ENTRY(201),
469 I40E_PTT_UNUSED_ENTRY(202),
470 I40E_PTT_UNUSED_ENTRY(203),
471 I40E_PTT_UNUSED_ENTRY(204),
472 I40E_PTT_UNUSED_ENTRY(205),
473 I40E_PTT_UNUSED_ENTRY(206),
474 I40E_PTT_UNUSED_ENTRY(207),
475 I40E_PTT_UNUSED_ENTRY(208),
476 I40E_PTT_UNUSED_ENTRY(209),
477
478 I40E_PTT_UNUSED_ENTRY(210),
479 I40E_PTT_UNUSED_ENTRY(211),
480 I40E_PTT_UNUSED_ENTRY(212),
481 I40E_PTT_UNUSED_ENTRY(213),
482 I40E_PTT_UNUSED_ENTRY(214),
483 I40E_PTT_UNUSED_ENTRY(215),
484 I40E_PTT_UNUSED_ENTRY(216),
485 I40E_PTT_UNUSED_ENTRY(217),
486 I40E_PTT_UNUSED_ENTRY(218),
487 I40E_PTT_UNUSED_ENTRY(219),
488
489 I40E_PTT_UNUSED_ENTRY(220),
490 I40E_PTT_UNUSED_ENTRY(221),
491 I40E_PTT_UNUSED_ENTRY(222),
492 I40E_PTT_UNUSED_ENTRY(223),
493 I40E_PTT_UNUSED_ENTRY(224),
494 I40E_PTT_UNUSED_ENTRY(225),
495 I40E_PTT_UNUSED_ENTRY(226),
496 I40E_PTT_UNUSED_ENTRY(227),
497 I40E_PTT_UNUSED_ENTRY(228),
498 I40E_PTT_UNUSED_ENTRY(229),
499
500 I40E_PTT_UNUSED_ENTRY(230),
501 I40E_PTT_UNUSED_ENTRY(231),
502 I40E_PTT_UNUSED_ENTRY(232),
503 I40E_PTT_UNUSED_ENTRY(233),
504 I40E_PTT_UNUSED_ENTRY(234),
505 I40E_PTT_UNUSED_ENTRY(235),
506 I40E_PTT_UNUSED_ENTRY(236),
507 I40E_PTT_UNUSED_ENTRY(237),
508 I40E_PTT_UNUSED_ENTRY(238),
509 I40E_PTT_UNUSED_ENTRY(239),
510
511 I40E_PTT_UNUSED_ENTRY(240),
512 I40E_PTT_UNUSED_ENTRY(241),
513 I40E_PTT_UNUSED_ENTRY(242),
514 I40E_PTT_UNUSED_ENTRY(243),
515 I40E_PTT_UNUSED_ENTRY(244),
516 I40E_PTT_UNUSED_ENTRY(245),
517 I40E_PTT_UNUSED_ENTRY(246),
518 I40E_PTT_UNUSED_ENTRY(247),
519 I40E_PTT_UNUSED_ENTRY(248),
520 I40E_PTT_UNUSED_ENTRY(249),
521
522 I40E_PTT_UNUSED_ENTRY(250),
523 I40E_PTT_UNUSED_ENTRY(251),
524 I40E_PTT_UNUSED_ENTRY(252),
525 I40E_PTT_UNUSED_ENTRY(253),
526 I40E_PTT_UNUSED_ENTRY(254),
527 I40E_PTT_UNUSED_ENTRY(255)
528};
529
530
165/** 531/**
166 * i40e_init_shared_code - Initialize the shared code 532 * i40e_init_shared_code - Initialize the shared code
167 * @hw: pointer to hardware structure 533 * @hw: pointer to hardware structure
diff --git a/drivers/net/ethernet/intel/i40e/i40e_dcb.c b/drivers/net/ethernet/intel/i40e/i40e_dcb.c
index 50730141bb7b..036570d76176 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_dcb.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_dcb.c
@@ -332,6 +332,7 @@ i40e_status i40e_lldp_to_dcb_config(u8 *lldpmib,
332 u16 type; 332 u16 type;
333 u16 length; 333 u16 length;
334 u16 typelength; 334 u16 typelength;
335 u16 offset = 0;
335 336
336 if (!lldpmib || !dcbcfg) 337 if (!lldpmib || !dcbcfg)
337 return I40E_ERR_PARAM; 338 return I40E_ERR_PARAM;
@@ -339,15 +340,17 @@ i40e_status i40e_lldp_to_dcb_config(u8 *lldpmib,
339 /* set to the start of LLDPDU */ 340 /* set to the start of LLDPDU */
340 lldpmib += ETH_HLEN; 341 lldpmib += ETH_HLEN;
341 tlv = (struct i40e_lldp_org_tlv *)lldpmib; 342 tlv = (struct i40e_lldp_org_tlv *)lldpmib;
342 while (tlv) { 343 while (1) {
343 typelength = ntohs(tlv->typelength); 344 typelength = ntohs(tlv->typelength);
344 type = (u16)((typelength & I40E_LLDP_TLV_TYPE_MASK) >> 345 type = (u16)((typelength & I40E_LLDP_TLV_TYPE_MASK) >>
345 I40E_LLDP_TLV_TYPE_SHIFT); 346 I40E_LLDP_TLV_TYPE_SHIFT);
346 length = (u16)((typelength & I40E_LLDP_TLV_LEN_MASK) >> 347 length = (u16)((typelength & I40E_LLDP_TLV_LEN_MASK) >>
347 I40E_LLDP_TLV_LEN_SHIFT); 348 I40E_LLDP_TLV_LEN_SHIFT);
349 offset += sizeof(typelength) + length;
348 350
349 if (type == I40E_TLV_TYPE_END) 351 /* END TLV or beyond LLDPDU size */
350 break;/* END TLV break out */ 352 if ((type == I40E_TLV_TYPE_END) || (offset > I40E_LLDPDU_SIZE))
353 break;
351 354
352 switch (type) { 355 switch (type) {
353 case I40E_TLV_TYPE_ORG: 356 case I40E_TLV_TYPE_ORG:
diff --git a/drivers/net/ethernet/intel/i40e/i40e_debugfs.c b/drivers/net/ethernet/intel/i40e/i40e_debugfs.c
index da22c3fa2c00..afd43d7973fa 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_debugfs.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_debugfs.c
@@ -1011,10 +1011,12 @@ static void i40e_dbg_dump_veb_all(struct i40e_pf *pf)
1011 **/ 1011 **/
1012static void i40e_dbg_cmd_fd_ctrl(struct i40e_pf *pf, u64 flag, bool enable) 1012static void i40e_dbg_cmd_fd_ctrl(struct i40e_pf *pf, u64 flag, bool enable)
1013{ 1013{
1014 if (enable) 1014 if (enable) {
1015 pf->flags |= flag; 1015 pf->flags |= flag;
1016 else 1016 } else {
1017 pf->flags &= ~flag; 1017 pf->flags &= ~flag;
1018 pf->auto_disable_flags |= flag;
1019 }
1018 dev_info(&pf->pdev->dev, "requesting a pf reset\n"); 1020 dev_info(&pf->pdev->dev, "requesting a pf reset\n");
1019 i40e_do_reset_safe(pf, (1 << __I40E_PF_RESET_REQUESTED)); 1021 i40e_do_reset_safe(pf, (1 << __I40E_PF_RESET_REQUESTED));
1020} 1022}
@@ -1467,19 +1469,19 @@ static ssize_t i40e_dbg_command_write(struct file *filp,
1467 pf->msg_enable); 1469 pf->msg_enable);
1468 } 1470 }
1469 } else if (strncmp(cmd_buf, "pfr", 3) == 0) { 1471 } else if (strncmp(cmd_buf, "pfr", 3) == 0) {
1470 dev_info(&pf->pdev->dev, "forcing PFR\n"); 1472 dev_info(&pf->pdev->dev, "debugfs: forcing PFR\n");
1471 i40e_do_reset_safe(pf, (1 << __I40E_PF_RESET_REQUESTED)); 1473 i40e_do_reset_safe(pf, (1 << __I40E_PF_RESET_REQUESTED));
1472 1474
1473 } else if (strncmp(cmd_buf, "corer", 5) == 0) { 1475 } else if (strncmp(cmd_buf, "corer", 5) == 0) {
1474 dev_info(&pf->pdev->dev, "forcing CoreR\n"); 1476 dev_info(&pf->pdev->dev, "debugfs: forcing CoreR\n");
1475 i40e_do_reset_safe(pf, (1 << __I40E_CORE_RESET_REQUESTED)); 1477 i40e_do_reset_safe(pf, (1 << __I40E_CORE_RESET_REQUESTED));
1476 1478
1477 } else if (strncmp(cmd_buf, "globr", 5) == 0) { 1479 } else if (strncmp(cmd_buf, "globr", 5) == 0) {
1478 dev_info(&pf->pdev->dev, "forcing GlobR\n"); 1480 dev_info(&pf->pdev->dev, "debugfs: forcing GlobR\n");
1479 i40e_do_reset_safe(pf, (1 << __I40E_GLOBAL_RESET_REQUESTED)); 1481 i40e_do_reset_safe(pf, (1 << __I40E_GLOBAL_RESET_REQUESTED));
1480 1482
1481 } else if (strncmp(cmd_buf, "empr", 4) == 0) { 1483 } else if (strncmp(cmd_buf, "empr", 4) == 0) {
1482 dev_info(&pf->pdev->dev, "forcing EMPR\n"); 1484 dev_info(&pf->pdev->dev, "debugfs: forcing EMPR\n");
1483 i40e_do_reset_safe(pf, (1 << __I40E_EMP_RESET_REQUESTED)); 1485 i40e_do_reset_safe(pf, (1 << __I40E_EMP_RESET_REQUESTED));
1484 1486
1485 } else if (strncmp(cmd_buf, "read", 4) == 0) { 1487 } else if (strncmp(cmd_buf, "read", 4) == 0) {
@@ -1663,28 +1665,36 @@ static ssize_t i40e_dbg_command_write(struct file *filp,
1663 desc = NULL; 1665 desc = NULL;
1664 } else if ((strncmp(cmd_buf, "add fd_filter", 13) == 0) || 1666 } else if ((strncmp(cmd_buf, "add fd_filter", 13) == 0) ||
1665 (strncmp(cmd_buf, "rem fd_filter", 13) == 0)) { 1667 (strncmp(cmd_buf, "rem fd_filter", 13) == 0)) {
1666 struct i40e_fdir_data fd_data; 1668 struct i40e_fdir_filter fd_data;
1667 u16 packet_len, i, j = 0; 1669 u16 packet_len, i, j = 0;
1668 char *asc_packet; 1670 char *asc_packet;
1671 u8 *raw_packet;
1669 bool add = false; 1672 bool add = false;
1670 int ret; 1673 int ret;
1671 1674
1672 asc_packet = kzalloc(I40E_FDIR_MAX_RAW_PACKET_LOOKUP, 1675 if (!(pf->flags & I40E_FLAG_FD_SB_ENABLED))
1676 goto command_write_done;
1677
1678 if (strncmp(cmd_buf, "add", 3) == 0)
1679 add = true;
1680
1681 if (add && (pf->auto_disable_flags & I40E_FLAG_FD_SB_ENABLED))
1682 goto command_write_done;
1683
1684 asc_packet = kzalloc(I40E_FDIR_MAX_RAW_PACKET_SIZE,
1673 GFP_KERNEL); 1685 GFP_KERNEL);
1674 if (!asc_packet) 1686 if (!asc_packet)
1675 goto command_write_done; 1687 goto command_write_done;
1676 1688
1677 fd_data.raw_packet = kzalloc(I40E_FDIR_MAX_RAW_PACKET_LOOKUP, 1689 raw_packet = kzalloc(I40E_FDIR_MAX_RAW_PACKET_SIZE,
1678 GFP_KERNEL); 1690 GFP_KERNEL);
1679 1691
1680 if (!fd_data.raw_packet) { 1692 if (!raw_packet) {
1681 kfree(asc_packet); 1693 kfree(asc_packet);
1682 asc_packet = NULL; 1694 asc_packet = NULL;
1683 goto command_write_done; 1695 goto command_write_done;
1684 } 1696 }
1685 1697
1686 if (strncmp(cmd_buf, "add", 3) == 0)
1687 add = true;
1688 cnt = sscanf(&cmd_buf[13], 1698 cnt = sscanf(&cmd_buf[13],
1689 "%hx %2hhx %2hhx %hx %2hhx %2hhx %hx %x %hd %511s", 1699 "%hx %2hhx %2hhx %hx %2hhx %2hhx %hx %x %hd %511s",
1690 &fd_data.q_index, 1700 &fd_data.q_index,
@@ -1698,36 +1708,36 @@ static ssize_t i40e_dbg_command_write(struct file *filp,
1698 cnt); 1708 cnt);
1699 kfree(asc_packet); 1709 kfree(asc_packet);
1700 asc_packet = NULL; 1710 asc_packet = NULL;
1701 kfree(fd_data.raw_packet); 1711 kfree(raw_packet);
1702 goto command_write_done; 1712 goto command_write_done;
1703 } 1713 }
1704 1714
1705 /* fix packet length if user entered 0 */ 1715 /* fix packet length if user entered 0 */
1706 if (packet_len == 0) 1716 if (packet_len == 0)
1707 packet_len = I40E_FDIR_MAX_RAW_PACKET_LOOKUP; 1717 packet_len = I40E_FDIR_MAX_RAW_PACKET_SIZE;
1708 1718
1709 /* make sure to check the max as well */ 1719 /* make sure to check the max as well */
1710 packet_len = min_t(u16, 1720 packet_len = min_t(u16,
1711 packet_len, I40E_FDIR_MAX_RAW_PACKET_LOOKUP); 1721 packet_len, I40E_FDIR_MAX_RAW_PACKET_SIZE);
1712 1722
1713 for (i = 0; i < packet_len; i++) { 1723 for (i = 0; i < packet_len; i++) {
1714 sscanf(&asc_packet[j], "%2hhx ", 1724 sscanf(&asc_packet[j], "%2hhx ",
1715 &fd_data.raw_packet[i]); 1725 &raw_packet[i]);
1716 j += 3; 1726 j += 3;
1717 } 1727 }
1718 dev_info(&pf->pdev->dev, "FD raw packet dump\n"); 1728 dev_info(&pf->pdev->dev, "FD raw packet dump\n");
1719 print_hex_dump(KERN_INFO, "FD raw packet: ", 1729 print_hex_dump(KERN_INFO, "FD raw packet: ",
1720 DUMP_PREFIX_OFFSET, 16, 1, 1730 DUMP_PREFIX_OFFSET, 16, 1,
1721 fd_data.raw_packet, packet_len, true); 1731 raw_packet, packet_len, true);
1722 ret = i40e_program_fdir_filter(&fd_data, pf, add); 1732 ret = i40e_program_fdir_filter(&fd_data, raw_packet, pf, add);
1723 if (!ret) { 1733 if (!ret) {
1724 dev_info(&pf->pdev->dev, "Filter command send Status : Success\n"); 1734 dev_info(&pf->pdev->dev, "Filter command send Status : Success\n");
1725 } else { 1735 } else {
1726 dev_info(&pf->pdev->dev, 1736 dev_info(&pf->pdev->dev,
1727 "Filter command send failed %d\n", ret); 1737 "Filter command send failed %d\n", ret);
1728 } 1738 }
1729 kfree(fd_data.raw_packet); 1739 kfree(raw_packet);
1730 fd_data.raw_packet = NULL; 1740 raw_packet = NULL;
1731 kfree(asc_packet); 1741 kfree(asc_packet);
1732 asc_packet = NULL; 1742 asc_packet = NULL;
1733 } else if (strncmp(cmd_buf, "fd-atr off", 10) == 0) { 1743 } else if (strncmp(cmd_buf, "fd-atr off", 10) == 0) {
diff --git a/drivers/net/ethernet/intel/i40e/i40e_ethtool.c b/drivers/net/ethernet/intel/i40e/i40e_ethtool.c
index b1d7d8c5cb9b..28da4125c8c9 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_ethtool.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_ethtool.c
@@ -62,6 +62,9 @@ static const struct i40e_stats i40e_gstrings_net_stats[] = {
62 I40E_NETDEV_STAT(rx_crc_errors), 62 I40E_NETDEV_STAT(rx_crc_errors),
63}; 63};
64 64
65static int i40e_add_del_fdir_ethtool(struct i40e_vsi *vsi,
66 struct ethtool_rxnfc *cmd, bool add);
67
65/* These PF_STATs might look like duplicates of some NETDEV_STATs, 68/* These PF_STATs might look like duplicates of some NETDEV_STATs,
66 * but they are separate. This device supports Virtualization, and 69 * but they are separate. This device supports Virtualization, and
67 * as such might have several netdevs supporting VMDq and FCoE going 70 * as such might have several netdevs supporting VMDq and FCoE going
@@ -84,6 +87,7 @@ static struct i40e_stats i40e_gstrings_stats[] = {
84 I40E_PF_STAT("illegal_bytes", stats.illegal_bytes), 87 I40E_PF_STAT("illegal_bytes", stats.illegal_bytes),
85 I40E_PF_STAT("mac_local_faults", stats.mac_local_faults), 88 I40E_PF_STAT("mac_local_faults", stats.mac_local_faults),
86 I40E_PF_STAT("mac_remote_faults", stats.mac_remote_faults), 89 I40E_PF_STAT("mac_remote_faults", stats.mac_remote_faults),
90 I40E_PF_STAT("tx_timeout", tx_timeout_count),
87 I40E_PF_STAT("rx_length_errors", stats.rx_length_errors), 91 I40E_PF_STAT("rx_length_errors", stats.rx_length_errors),
88 I40E_PF_STAT("link_xon_rx", stats.link_xon_rx), 92 I40E_PF_STAT("link_xon_rx", stats.link_xon_rx),
89 I40E_PF_STAT("link_xoff_rx", stats.link_xoff_rx), 93 I40E_PF_STAT("link_xoff_rx", stats.link_xoff_rx),
@@ -110,6 +114,11 @@ static struct i40e_stats i40e_gstrings_stats[] = {
110 I40E_PF_STAT("VF_admin_queue_requests", vf_aq_requests), 114 I40E_PF_STAT("VF_admin_queue_requests", vf_aq_requests),
111 I40E_PF_STAT("tx_hwtstamp_timeouts", tx_hwtstamp_timeouts), 115 I40E_PF_STAT("tx_hwtstamp_timeouts", tx_hwtstamp_timeouts),
112 I40E_PF_STAT("rx_hwtstamp_cleared", rx_hwtstamp_cleared), 116 I40E_PF_STAT("rx_hwtstamp_cleared", rx_hwtstamp_cleared),
117 /* LPI stats */
118 I40E_PF_STAT("tx_lpi_status", stats.tx_lpi_status),
119 I40E_PF_STAT("rx_lpi_status", stats.rx_lpi_status),
120 I40E_PF_STAT("tx_lpi_count", stats.tx_lpi_count),
121 I40E_PF_STAT("rx_lpi_count", stats.rx_lpi_count),
113}; 122};
114 123
115#define I40E_QUEUE_STATS_LEN(n) \ 124#define I40E_QUEUE_STATS_LEN(n) \
@@ -649,18 +658,18 @@ static void i40e_get_ethtool_stats(struct net_device *netdev,
649 658
650 /* process Tx ring statistics */ 659 /* process Tx ring statistics */
651 do { 660 do {
652 start = u64_stats_fetch_begin_bh(&tx_ring->syncp); 661 start = u64_stats_fetch_begin_irq(&tx_ring->syncp);
653 data[i] = tx_ring->stats.packets; 662 data[i] = tx_ring->stats.packets;
654 data[i + 1] = tx_ring->stats.bytes; 663 data[i + 1] = tx_ring->stats.bytes;
655 } while (u64_stats_fetch_retry_bh(&tx_ring->syncp, start)); 664 } while (u64_stats_fetch_retry_irq(&tx_ring->syncp, start));
656 665
657 /* Rx ring is the 2nd half of the queue pair */ 666 /* Rx ring is the 2nd half of the queue pair */
658 rx_ring = &tx_ring[1]; 667 rx_ring = &tx_ring[1];
659 do { 668 do {
660 start = u64_stats_fetch_begin_bh(&rx_ring->syncp); 669 start = u64_stats_fetch_begin_irq(&rx_ring->syncp);
661 data[i + 2] = rx_ring->stats.packets; 670 data[i + 2] = rx_ring->stats.packets;
662 data[i + 3] = rx_ring->stats.bytes; 671 data[i + 3] = rx_ring->stats.bytes;
663 } while (u64_stats_fetch_retry_bh(&rx_ring->syncp, start)); 672 } while (u64_stats_fetch_retry_irq(&rx_ring->syncp, start));
664 } 673 }
665 rcu_read_unlock(); 674 rcu_read_unlock();
666 if (vsi == pf->vsi[pf->lan_vsi]) { 675 if (vsi == pf->vsi[pf->lan_vsi]) {
@@ -1112,6 +1121,84 @@ static int i40e_get_rss_hash_opts(struct i40e_pf *pf, struct ethtool_rxnfc *cmd)
1112} 1121}
1113 1122
1114/** 1123/**
1124 * i40e_get_ethtool_fdir_all - Populates the rule count of a command
1125 * @pf: Pointer to the physical function struct
1126 * @cmd: The command to get or set Rx flow classification rules
1127 * @rule_locs: Array of used rule locations
1128 *
1129 * This function populates both the total and actual rule count of
1130 * the ethtool flow classification command
1131 *
1132 * Returns 0 on success or -EMSGSIZE if entry not found
1133 **/
1134static int i40e_get_ethtool_fdir_all(struct i40e_pf *pf,
1135 struct ethtool_rxnfc *cmd,
1136 u32 *rule_locs)
1137{
1138 struct i40e_fdir_filter *rule;
1139 struct hlist_node *node2;
1140 int cnt = 0;
1141
1142 /* report total rule count */
1143 cmd->data = pf->hw.fdir_shared_filter_count +
1144 pf->fdir_pf_filter_count;
1145
1146 hlist_for_each_entry_safe(rule, node2,
1147 &pf->fdir_filter_list, fdir_node) {
1148 if (cnt == cmd->rule_cnt)
1149 return -EMSGSIZE;
1150
1151 rule_locs[cnt] = rule->fd_id;
1152 cnt++;
1153 }
1154
1155 cmd->rule_cnt = cnt;
1156
1157 return 0;
1158}
1159
1160/**
1161 * i40e_get_ethtool_fdir_entry - Look up a filter based on Rx flow
1162 * @pf: Pointer to the physical function struct
1163 * @cmd: The command to get or set Rx flow classification rules
1164 *
1165 * This function looks up a filter based on the Rx flow classification
1166 * command and fills the flow spec info for it if found
1167 *
1168 * Returns 0 on success or -EINVAL if filter not found
1169 **/
1170static int i40e_get_ethtool_fdir_entry(struct i40e_pf *pf,
1171 struct ethtool_rxnfc *cmd)
1172{
1173 struct ethtool_rx_flow_spec *fsp =
1174 (struct ethtool_rx_flow_spec *)&cmd->fs;
1175 struct i40e_fdir_filter *rule = NULL;
1176 struct hlist_node *node2;
1177
1178 /* report total rule count */
1179 cmd->data = pf->hw.fdir_shared_filter_count +
1180 pf->fdir_pf_filter_count;
1181
1182 hlist_for_each_entry_safe(rule, node2,
1183 &pf->fdir_filter_list, fdir_node) {
1184 if (fsp->location <= rule->fd_id)
1185 break;
1186 }
1187
1188 if (!rule || fsp->location != rule->fd_id)
1189 return -EINVAL;
1190
1191 fsp->flow_type = rule->flow_type;
1192 fsp->h_u.tcp_ip4_spec.psrc = rule->src_port;
1193 fsp->h_u.tcp_ip4_spec.pdst = rule->dst_port;
1194 fsp->h_u.tcp_ip4_spec.ip4src = rule->src_ip[0];
1195 fsp->h_u.tcp_ip4_spec.ip4dst = rule->dst_ip[0];
1196 fsp->ring_cookie = rule->q_index;
1197
1198 return 0;
1199}
1200
1201/**
1115 * i40e_get_rxnfc - command to get RX flow classification rules 1202 * i40e_get_rxnfc - command to get RX flow classification rules
1116 * @netdev: network interface device structure 1203 * @netdev: network interface device structure
1117 * @cmd: ethtool rxnfc command 1204 * @cmd: ethtool rxnfc command
@@ -1135,15 +1222,15 @@ static int i40e_get_rxnfc(struct net_device *netdev, struct ethtool_rxnfc *cmd,
1135 ret = i40e_get_rss_hash_opts(pf, cmd); 1222 ret = i40e_get_rss_hash_opts(pf, cmd);
1136 break; 1223 break;
1137 case ETHTOOL_GRXCLSRLCNT: 1224 case ETHTOOL_GRXCLSRLCNT:
1138 cmd->rule_cnt = 10; 1225 cmd->rule_cnt = pf->fdir_pf_active_filters;
1139 ret = 0; 1226 ret = 0;
1140 break; 1227 break;
1141 case ETHTOOL_GRXCLSRULE: 1228 case ETHTOOL_GRXCLSRULE:
1142 ret = 0; 1229 ret = i40e_get_ethtool_fdir_entry(pf, cmd);
1143 break; 1230 break;
1144 case ETHTOOL_GRXCLSRLALL: 1231 case ETHTOOL_GRXCLSRLALL:
1145 cmd->data = 500; 1232 ret = i40e_get_ethtool_fdir_all(pf, cmd, rule_locs);
1146 ret = 0; 1233 break;
1147 default: 1234 default:
1148 break; 1235 break;
1149 } 1236 }
@@ -1274,289 +1361,183 @@ static int i40e_set_rss_hash_opt(struct i40e_pf *pf, struct ethtool_rxnfc *nfc)
1274 return 0; 1361 return 0;
1275} 1362}
1276 1363
1277#define IP_HEADER_OFFSET 14
1278#define I40E_UDPIP_DUMMY_PACKET_LEN 42
1279/** 1364/**
1280 * i40e_add_del_fdir_udpv4 - Add/Remove UDPv4 Flow Director filters for 1365 * i40e_match_fdir_input_set - Match a new filter against an existing one
1281 * a specific flow spec 1366 * @rule: The filter already added
1282 * @vsi: pointer to the targeted VSI 1367 * @input: The new filter to comapre against
1283 * @fd_data: the flow director data required from the FDir descriptor
1284 * @ethtool_rx_flow_spec: the flow spec
1285 * @add: true adds a filter, false removes it
1286 * 1368 *
1287 * Returns 0 if the filters were successfully added or removed 1369 * Returns true if the two input set match
1288 **/ 1370 **/
1289static int i40e_add_del_fdir_udpv4(struct i40e_vsi *vsi, 1371static bool i40e_match_fdir_input_set(struct i40e_fdir_filter *rule,
1290 struct i40e_fdir_data *fd_data, 1372 struct i40e_fdir_filter *input)
1291 struct ethtool_rx_flow_spec *fsp, bool add)
1292{ 1373{
1293 struct i40e_pf *pf = vsi->back; 1374 if ((rule->dst_ip[0] != input->dst_ip[0]) ||
1294 struct udphdr *udp; 1375 (rule->src_ip[0] != input->src_ip[0]) ||
1295 struct iphdr *ip; 1376 (rule->dst_port != input->dst_port) ||
1296 bool err = false; 1377 (rule->src_port != input->src_port))
1297 int ret; 1378 return false;
1298 int i; 1379 return true;
1299 char packet[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x08, 0,
1300 0x45, 0, 0, 0x1c, 0, 0, 0x40, 0, 0x40, 0x11,
1301 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1302 0, 0, 0, 0, 0, 0, 0, 0};
1303
1304 memcpy(fd_data->raw_packet, packet, I40E_UDPIP_DUMMY_PACKET_LEN);
1305
1306 ip = (struct iphdr *)(fd_data->raw_packet + IP_HEADER_OFFSET);
1307 udp = (struct udphdr *)(fd_data->raw_packet + IP_HEADER_OFFSET
1308 + sizeof(struct iphdr));
1309
1310 ip->saddr = fsp->h_u.tcp_ip4_spec.ip4src;
1311 ip->daddr = fsp->h_u.tcp_ip4_spec.ip4dst;
1312 udp->source = fsp->h_u.tcp_ip4_spec.psrc;
1313 udp->dest = fsp->h_u.tcp_ip4_spec.pdst;
1314
1315 for (i = I40E_FILTER_PCTYPE_NONF_UNICAST_IPV4_UDP;
1316 i <= I40E_FILTER_PCTYPE_NONF_IPV4_UDP; i++) {
1317 fd_data->pctype = i;
1318 ret = i40e_program_fdir_filter(fd_data, pf, add);
1319
1320 if (ret) {
1321 dev_info(&pf->pdev->dev,
1322 "Filter command send failed for PCTYPE %d (ret = %d)\n",
1323 fd_data->pctype, ret);
1324 err = true;
1325 } else {
1326 dev_info(&pf->pdev->dev,
1327 "Filter OK for PCTYPE %d (ret = %d)\n",
1328 fd_data->pctype, ret);
1329 }
1330 }
1331
1332 return err ? -EOPNOTSUPP : 0;
1333} 1380}
1334 1381
1335#define I40E_TCPIP_DUMMY_PACKET_LEN 54
1336/** 1382/**
1337 * i40e_add_del_fdir_tcpv4 - Add/Remove TCPv4 Flow Director filters for 1383 * i40e_update_ethtool_fdir_entry - Updates the fdir filter entry
1338 * a specific flow spec 1384 * @vsi: Pointer to the targeted VSI
1339 * @vsi: pointer to the targeted VSI 1385 * @input: The filter to update or NULL to indicate deletion
1340 * @fd_data: the flow director data required from the FDir descriptor 1386 * @sw_idx: Software index to the filter
1341 * @ethtool_rx_flow_spec: the flow spec 1387 * @cmd: The command to get or set Rx flow classification rules
1342 * @add: true adds a filter, false removes it 1388 *
1389 * This function updates (or deletes) a Flow Director entry from
1390 * the hlist of the corresponding PF
1343 * 1391 *
1344 * Returns 0 if the filters were successfully added or removed 1392 * Returns 0 on success
1345 **/ 1393 **/
1346static int i40e_add_del_fdir_tcpv4(struct i40e_vsi *vsi, 1394static int i40e_update_ethtool_fdir_entry(struct i40e_vsi *vsi,
1347 struct i40e_fdir_data *fd_data, 1395 struct i40e_fdir_filter *input,
1348 struct ethtool_rx_flow_spec *fsp, bool add) 1396 u16 sw_idx,
1397 struct ethtool_rxnfc *cmd)
1349{ 1398{
1399 struct i40e_fdir_filter *rule, *parent;
1350 struct i40e_pf *pf = vsi->back; 1400 struct i40e_pf *pf = vsi->back;
1351 struct tcphdr *tcp; 1401 struct hlist_node *node2;
1352 struct iphdr *ip; 1402 int err = -EINVAL;
1353 bool err = false;
1354 int ret;
1355 /* Dummy packet */
1356 char packet[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x08, 0,
1357 0x45, 0, 0, 0x28, 0, 0, 0x40, 0, 0x40, 0x6,
1358 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1359 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1360 0x80, 0x11, 0x0, 0x72, 0, 0, 0, 0};
1361
1362 memcpy(fd_data->raw_packet, packet, I40E_TCPIP_DUMMY_PACKET_LEN);
1363
1364 ip = (struct iphdr *)(fd_data->raw_packet + IP_HEADER_OFFSET);
1365 tcp = (struct tcphdr *)(fd_data->raw_packet + IP_HEADER_OFFSET
1366 + sizeof(struct iphdr));
1367
1368 ip->daddr = fsp->h_u.tcp_ip4_spec.ip4dst;
1369 tcp->dest = fsp->h_u.tcp_ip4_spec.pdst;
1370 ip->saddr = fsp->h_u.tcp_ip4_spec.ip4src;
1371 tcp->source = fsp->h_u.tcp_ip4_spec.psrc;
1372
1373 if (add) {
1374 if (pf->flags & I40E_FLAG_FD_ATR_ENABLED) {
1375 dev_info(&pf->pdev->dev, "Forcing ATR off, sideband rules for TCP/IPv4 flow being applied\n");
1376 pf->flags &= ~I40E_FLAG_FD_ATR_ENABLED;
1377 }
1378 }
1379 1403
1380 fd_data->pctype = I40E_FILTER_PCTYPE_NONF_IPV4_TCP_SYN; 1404 parent = NULL;
1381 ret = i40e_program_fdir_filter(fd_data, pf, add); 1405 rule = NULL;
1382 1406
1383 if (ret) { 1407 hlist_for_each_entry_safe(rule, node2,
1384 dev_info(&pf->pdev->dev, 1408 &pf->fdir_filter_list, fdir_node) {
1385 "Filter command send failed for PCTYPE %d (ret = %d)\n", 1409 /* hash found, or no matching entry */
1386 fd_data->pctype, ret); 1410 if (rule->fd_id >= sw_idx)
1387 err = true; 1411 break;
1388 } else { 1412 parent = rule;
1389 dev_info(&pf->pdev->dev, "Filter OK for PCTYPE %d (ret = %d)\n",
1390 fd_data->pctype, ret);
1391 } 1413 }
1392 1414
1393 fd_data->pctype = I40E_FILTER_PCTYPE_NONF_IPV4_TCP; 1415 /* if there is an old rule occupying our place remove it */
1394 1416 if (rule && (rule->fd_id == sw_idx)) {
1395 ret = i40e_program_fdir_filter(fd_data, pf, add); 1417 if (input && !i40e_match_fdir_input_set(rule, input))
1396 if (ret) { 1418 err = i40e_add_del_fdir(vsi, rule, false);
1397 dev_info(&pf->pdev->dev, 1419 else if (!input)
1398 "Filter command send failed for PCTYPE %d (ret = %d)\n", 1420 err = i40e_add_del_fdir(vsi, rule, false);
1399 fd_data->pctype, ret); 1421 hlist_del(&rule->fdir_node);
1400 err = true; 1422 kfree(rule);
1401 } else { 1423 pf->fdir_pf_active_filters--;
1402 dev_info(&pf->pdev->dev, "Filter OK for PCTYPE %d (ret = %d)\n",
1403 fd_data->pctype, ret);
1404 } 1424 }
1405 1425
1406 return err ? -EOPNOTSUPP : 0; 1426 /* If no input this was a delete, err should be 0 if a rule was
1407} 1427 * successfully found and removed from the list else -EINVAL
1428 */
1429 if (!input)
1430 return err;
1408 1431
1409/** 1432 /* initialize node and set software index */
1410 * i40e_add_del_fdir_sctpv4 - Add/Remove SCTPv4 Flow Director filters for 1433 INIT_HLIST_NODE(&input->fdir_node);
1411 * a specific flow spec 1434
1412 * @vsi: pointer to the targeted VSI 1435 /* add filter to the list */
1413 * @fd_data: the flow director data required from the FDir descriptor 1436 if (parent)
1414 * @ethtool_rx_flow_spec: the flow spec 1437 hlist_add_after(&parent->fdir_node, &input->fdir_node);
1415 * @add: true adds a filter, false removes it 1438 else
1416 * 1439 hlist_add_head(&input->fdir_node,
1417 * Returns 0 if the filters were successfully added or removed 1440 &pf->fdir_filter_list);
1418 **/ 1441
1419static int i40e_add_del_fdir_sctpv4(struct i40e_vsi *vsi, 1442 /* update counts */
1420 struct i40e_fdir_data *fd_data, 1443 pf->fdir_pf_active_filters++;
1421 struct ethtool_rx_flow_spec *fsp, bool add) 1444
1422{ 1445 return 0;
1423 return -EOPNOTSUPP;
1424} 1446}
1425 1447
1426#define I40E_IP_DUMMY_PACKET_LEN 34
1427/** 1448/**
1428 * i40e_add_del_fdir_ipv4 - Add/Remove IPv4 Flow Director filters for 1449 * i40e_del_fdir_entry - Deletes a Flow Director filter entry
1429 * a specific flow spec 1450 * @vsi: Pointer to the targeted VSI
1430 * @vsi: pointer to the targeted VSI 1451 * @cmd: The command to get or set Rx flow classification rules
1431 * @fd_data: the flow director data required for the FDir descriptor
1432 * @fsp: the ethtool flow spec
1433 * @add: true adds a filter, false removes it
1434 * 1452 *
1435 * Returns 0 if the filters were successfully added or removed 1453 * The function removes a Flow Director filter entry from the
1436 **/ 1454 * hlist of the corresponding PF
1437static int i40e_add_del_fdir_ipv4(struct i40e_vsi *vsi, 1455 *
1438 struct i40e_fdir_data *fd_data, 1456 * Returns 0 on success
1439 struct ethtool_rx_flow_spec *fsp, bool add) 1457 */
1458static int i40e_del_fdir_entry(struct i40e_vsi *vsi,
1459 struct ethtool_rxnfc *cmd)
1440{ 1460{
1461 struct ethtool_rx_flow_spec *fsp =
1462 (struct ethtool_rx_flow_spec *)&cmd->fs;
1441 struct i40e_pf *pf = vsi->back; 1463 struct i40e_pf *pf = vsi->back;
1442 struct iphdr *ip; 1464 int ret = 0;
1443 bool err = false;
1444 int ret;
1445 int i;
1446 char packet[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x08, 0,
1447 0x45, 0, 0, 0x14, 0, 0, 0x40, 0, 0x40, 0x10,
1448 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
1449
1450 memcpy(fd_data->raw_packet, packet, I40E_IP_DUMMY_PACKET_LEN);
1451 ip = (struct iphdr *)(fd_data->raw_packet + IP_HEADER_OFFSET);
1452
1453 ip->saddr = fsp->h_u.usr_ip4_spec.ip4src;
1454 ip->daddr = fsp->h_u.usr_ip4_spec.ip4dst;
1455 ip->protocol = fsp->h_u.usr_ip4_spec.proto;
1456 1465
1457 for (i = I40E_FILTER_PCTYPE_NONF_IPV4_OTHER; 1466 ret = i40e_update_ethtool_fdir_entry(vsi, NULL, fsp->location, cmd);
1458 i <= I40E_FILTER_PCTYPE_FRAG_IPV4; i++) {
1459 fd_data->pctype = i;
1460 ret = i40e_program_fdir_filter(fd_data, pf, add);
1461 1467
1462 if (ret) { 1468 i40e_fdir_check_and_reenable(pf);
1463 dev_info(&pf->pdev->dev, 1469 return ret;
1464 "Filter command send failed for PCTYPE %d (ret = %d)\n",
1465 fd_data->pctype, ret);
1466 err = true;
1467 } else {
1468 dev_info(&pf->pdev->dev,
1469 "Filter OK for PCTYPE %d (ret = %d)\n",
1470 fd_data->pctype, ret);
1471 }
1472 }
1473
1474 return err ? -EOPNOTSUPP : 0;
1475} 1470}
1476 1471
1477/** 1472/**
1478 * i40e_add_del_fdir_ethtool - Add/Remove Flow Director filters for 1473 * i40e_add_del_fdir_ethtool - Add/Remove Flow Director filters
1479 * a specific flow spec based on their protocol
1480 * @vsi: pointer to the targeted VSI 1474 * @vsi: pointer to the targeted VSI
1481 * @cmd: command to get or set RX flow classification rules 1475 * @cmd: command to get or set RX flow classification rules
1482 * @add: true adds a filter, false removes it 1476 * @add: true adds a filter, false removes it
1483 * 1477 *
1484 * Returns 0 if the filters were successfully added or removed 1478 * Add/Remove Flow Director filters for a specific flow spec based on their
1479 * protocol. Returns 0 if the filters were successfully added or removed.
1485 **/ 1480 **/
1486static int i40e_add_del_fdir_ethtool(struct i40e_vsi *vsi, 1481static int i40e_add_del_fdir_ethtool(struct i40e_vsi *vsi,
1487 struct ethtool_rxnfc *cmd, bool add) 1482 struct ethtool_rxnfc *cmd, bool add)
1488{ 1483{
1489 struct i40e_fdir_data fd_data; 1484 struct ethtool_rx_flow_spec *fsp;
1490 int ret = -EINVAL; 1485 struct i40e_fdir_filter *input;
1491 struct i40e_pf *pf; 1486 struct i40e_pf *pf;
1492 struct ethtool_rx_flow_spec *fsp = 1487 int ret = -EINVAL;
1493 (struct ethtool_rx_flow_spec *)&cmd->fs;
1494 1488
1495 if (!vsi) 1489 if (!vsi)
1496 return -EINVAL; 1490 return -EINVAL;
1497 1491
1498 pf = vsi->back; 1492 pf = vsi->back;
1499 1493
1500 if ((fsp->ring_cookie != RX_CLS_FLOW_DISC) && 1494 if (!(pf->flags & I40E_FLAG_FD_SB_ENABLED))
1501 (fsp->ring_cookie >= vsi->num_queue_pairs)) 1495 return -EOPNOTSUPP;
1502 return -EINVAL;
1503 1496
1504 /* Populate the Flow Director that we have at the moment 1497 if (add && (pf->auto_disable_flags & I40E_FLAG_FD_SB_ENABLED))
1505 * and allocate the raw packet buffer for the calling functions 1498 return -ENOSPC;
1506 */
1507 fd_data.raw_packet = kzalloc(I40E_FDIR_MAX_RAW_PACKET_LOOKUP,
1508 GFP_KERNEL);
1509 1499
1510 if (!fd_data.raw_packet) { 1500 fsp = (struct ethtool_rx_flow_spec *)&cmd->fs;
1511 dev_info(&pf->pdev->dev, "Could not allocate memory\n"); 1501
1512 return -ENOMEM; 1502 if (fsp->location >= (pf->hw.func_caps.fd_filters_best_effort +
1503 pf->hw.func_caps.fd_filters_guaranteed)) {
1504 return -EINVAL;
1513 } 1505 }
1514 1506
1515 fd_data.q_index = fsp->ring_cookie; 1507 if ((fsp->ring_cookie >= vsi->num_queue_pairs) && add)
1516 fd_data.flex_off = 0; 1508 return -EINVAL;
1517 fd_data.pctype = 0;
1518 fd_data.dest_vsi = vsi->id;
1519 fd_data.dest_ctl = I40E_FILTER_PROGRAM_DESC_DEST_DIRECT_PACKET_QINDEX;
1520 fd_data.fd_status = I40E_FILTER_PROGRAM_DESC_FD_STATUS_FD_ID;
1521 fd_data.cnt_index = 0;
1522 fd_data.fd_id = 0;
1523 1509
1524 switch (fsp->flow_type & ~FLOW_EXT) { 1510 input = kzalloc(sizeof(*input), GFP_KERNEL);
1525 case TCP_V4_FLOW: 1511
1526 ret = i40e_add_del_fdir_tcpv4(vsi, &fd_data, fsp, add); 1512 if (!input)
1527 break; 1513 return -ENOMEM;
1528 case UDP_V4_FLOW: 1514
1529 ret = i40e_add_del_fdir_udpv4(vsi, &fd_data, fsp, add); 1515 input->fd_id = fsp->location;
1530 break; 1516
1531 case SCTP_V4_FLOW: 1517 input->q_index = fsp->ring_cookie;
1532 ret = i40e_add_del_fdir_sctpv4(vsi, &fd_data, fsp, add); 1518 input->flex_off = 0;
1533 break; 1519 input->pctype = 0;
1534 case IPV4_FLOW: 1520 input->dest_vsi = vsi->id;
1535 ret = i40e_add_del_fdir_ipv4(vsi, &fd_data, fsp, add); 1521 input->dest_ctl = I40E_FILTER_PROGRAM_DESC_DEST_DIRECT_PACKET_QINDEX;
1536 break; 1522 input->fd_status = I40E_FILTER_PROGRAM_DESC_FD_STATUS_FD_ID;
1537 case IP_USER_FLOW: 1523 input->cnt_index = 0;
1538 switch (fsp->h_u.usr_ip4_spec.proto) { 1524 input->flow_type = fsp->flow_type;
1539 case IPPROTO_TCP: 1525 input->ip4_proto = fsp->h_u.usr_ip4_spec.proto;
1540 ret = i40e_add_del_fdir_tcpv4(vsi, &fd_data, fsp, add); 1526 input->src_port = fsp->h_u.tcp_ip4_spec.psrc;
1541 break; 1527 input->dst_port = fsp->h_u.tcp_ip4_spec.pdst;
1542 case IPPROTO_UDP: 1528 input->src_ip[0] = fsp->h_u.tcp_ip4_spec.ip4src;
1543 ret = i40e_add_del_fdir_udpv4(vsi, &fd_data, fsp, add); 1529 input->dst_ip[0] = fsp->h_u.tcp_ip4_spec.ip4dst;
1544 break; 1530
1545 case IPPROTO_SCTP: 1531 ret = i40e_add_del_fdir(vsi, input, add);
1546 ret = i40e_add_del_fdir_sctpv4(vsi, &fd_data, fsp, add); 1532 if (ret) {
1547 break; 1533 kfree(input);
1548 default: 1534 return ret;
1549 ret = i40e_add_del_fdir_ipv4(vsi, &fd_data, fsp, add);
1550 break;
1551 }
1552 break;
1553 default:
1554 dev_info(&pf->pdev->dev, "Could not specify spec type\n");
1555 ret = -EINVAL;
1556 } 1535 }
1557 1536
1558 kfree(fd_data.raw_packet); 1537 if (!ret && add)
1559 fd_data.raw_packet = NULL; 1538 i40e_update_ethtool_fdir_entry(vsi, input, fsp->location, NULL);
1539 else
1540 kfree(input);
1560 1541
1561 return ret; 1542 return ret;
1562} 1543}
@@ -1583,7 +1564,7 @@ static int i40e_set_rxnfc(struct net_device *netdev, struct ethtool_rxnfc *cmd)
1583 ret = i40e_add_del_fdir_ethtool(vsi, cmd, true); 1564 ret = i40e_add_del_fdir_ethtool(vsi, cmd, true);
1584 break; 1565 break;
1585 case ETHTOOL_SRXCLSRLDEL: 1566 case ETHTOOL_SRXCLSRLDEL:
1586 ret = i40e_add_del_fdir_ethtool(vsi, cmd, false); 1567 ret = i40e_del_fdir_entry(vsi, cmd);
1587 break; 1568 break;
1588 default: 1569 default:
1589 break; 1570 break;
diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c
index b901371ca361..28df88ef3c8b 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_main.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_main.c
@@ -38,7 +38,7 @@ static const char i40e_driver_string[] =
38 38
39#define DRV_VERSION_MAJOR 0 39#define DRV_VERSION_MAJOR 0
40#define DRV_VERSION_MINOR 3 40#define DRV_VERSION_MINOR 3
41#define DRV_VERSION_BUILD 30 41#define DRV_VERSION_BUILD 36
42#define DRV_VERSION __stringify(DRV_VERSION_MAJOR) "." \ 42#define DRV_VERSION __stringify(DRV_VERSION_MAJOR) "." \
43 __stringify(DRV_VERSION_MINOR) "." \ 43 __stringify(DRV_VERSION_MINOR) "." \
44 __stringify(DRV_VERSION_BUILD) DRV_KERN 44 __stringify(DRV_VERSION_BUILD) DRV_KERN
@@ -305,6 +305,7 @@ static void i40e_tx_timeout(struct net_device *netdev)
305 break; 305 break;
306 default: 306 default:
307 netdev_err(netdev, "tx_timeout recovery unsuccessful\n"); 307 netdev_err(netdev, "tx_timeout recovery unsuccessful\n");
308 set_bit(__I40E_DOWN, &vsi->state);
308 i40e_down(vsi); 309 i40e_down(vsi);
309 break; 310 break;
310 } 311 }
@@ -375,20 +376,20 @@ static struct rtnl_link_stats64 *i40e_get_netdev_stats_struct(
375 continue; 376 continue;
376 377
377 do { 378 do {
378 start = u64_stats_fetch_begin_bh(&tx_ring->syncp); 379 start = u64_stats_fetch_begin_irq(&tx_ring->syncp);
379 packets = tx_ring->stats.packets; 380 packets = tx_ring->stats.packets;
380 bytes = tx_ring->stats.bytes; 381 bytes = tx_ring->stats.bytes;
381 } while (u64_stats_fetch_retry_bh(&tx_ring->syncp, start)); 382 } while (u64_stats_fetch_retry_irq(&tx_ring->syncp, start));
382 383
383 stats->tx_packets += packets; 384 stats->tx_packets += packets;
384 stats->tx_bytes += bytes; 385 stats->tx_bytes += bytes;
385 rx_ring = &tx_ring[1]; 386 rx_ring = &tx_ring[1];
386 387
387 do { 388 do {
388 start = u64_stats_fetch_begin_bh(&rx_ring->syncp); 389 start = u64_stats_fetch_begin_irq(&rx_ring->syncp);
389 packets = rx_ring->stats.packets; 390 packets = rx_ring->stats.packets;
390 bytes = rx_ring->stats.bytes; 391 bytes = rx_ring->stats.bytes;
391 } while (u64_stats_fetch_retry_bh(&rx_ring->syncp, start)); 392 } while (u64_stats_fetch_retry_irq(&rx_ring->syncp, start));
392 393
393 stats->rx_packets += packets; 394 stats->rx_packets += packets;
394 stats->rx_bytes += bytes; 395 stats->rx_bytes += bytes;
@@ -739,6 +740,7 @@ void i40e_update_stats(struct i40e_vsi *vsi)
739 u32 rx_page, rx_buf; 740 u32 rx_page, rx_buf;
740 u64 rx_p, rx_b; 741 u64 rx_p, rx_b;
741 u64 tx_p, tx_b; 742 u64 tx_p, tx_b;
743 u32 val;
742 int i; 744 int i;
743 u16 q; 745 u16 q;
744 746
@@ -769,10 +771,10 @@ void i40e_update_stats(struct i40e_vsi *vsi)
769 p = ACCESS_ONCE(vsi->tx_rings[q]); 771 p = ACCESS_ONCE(vsi->tx_rings[q]);
770 772
771 do { 773 do {
772 start = u64_stats_fetch_begin_bh(&p->syncp); 774 start = u64_stats_fetch_begin_irq(&p->syncp);
773 packets = p->stats.packets; 775 packets = p->stats.packets;
774 bytes = p->stats.bytes; 776 bytes = p->stats.bytes;
775 } while (u64_stats_fetch_retry_bh(&p->syncp, start)); 777 } while (u64_stats_fetch_retry_irq(&p->syncp, start));
776 tx_b += bytes; 778 tx_b += bytes;
777 tx_p += packets; 779 tx_p += packets;
778 tx_restart += p->tx_stats.restart_queue; 780 tx_restart += p->tx_stats.restart_queue;
@@ -781,10 +783,10 @@ void i40e_update_stats(struct i40e_vsi *vsi)
781 /* Rx queue is part of the same block as Tx queue */ 783 /* Rx queue is part of the same block as Tx queue */
782 p = &p[1]; 784 p = &p[1];
783 do { 785 do {
784 start = u64_stats_fetch_begin_bh(&p->syncp); 786 start = u64_stats_fetch_begin_irq(&p->syncp);
785 packets = p->stats.packets; 787 packets = p->stats.packets;
786 bytes = p->stats.bytes; 788 bytes = p->stats.bytes;
787 } while (u64_stats_fetch_retry_bh(&p->syncp, start)); 789 } while (u64_stats_fetch_retry_irq(&p->syncp, start));
788 rx_b += bytes; 790 rx_b += bytes;
789 rx_p += packets; 791 rx_p += packets;
790 rx_buf += p->rx_stats.alloc_buff_failed; 792 rx_buf += p->rx_stats.alloc_buff_failed;
@@ -971,6 +973,20 @@ void i40e_update_stats(struct i40e_vsi *vsi)
971 i40e_stat_update32(hw, I40E_GLPRT_RJC(hw->port), 973 i40e_stat_update32(hw, I40E_GLPRT_RJC(hw->port),
972 pf->stat_offsets_loaded, 974 pf->stat_offsets_loaded,
973 &osd->rx_jabber, &nsd->rx_jabber); 975 &osd->rx_jabber, &nsd->rx_jabber);
976
977 val = rd32(hw, I40E_PRTPM_EEE_STAT);
978 nsd->tx_lpi_status =
979 (val & I40E_PRTPM_EEE_STAT_TX_LPI_STATUS_MASK) >>
980 I40E_PRTPM_EEE_STAT_TX_LPI_STATUS_SHIFT;
981 nsd->rx_lpi_status =
982 (val & I40E_PRTPM_EEE_STAT_RX_LPI_STATUS_MASK) >>
983 I40E_PRTPM_EEE_STAT_RX_LPI_STATUS_SHIFT;
984 i40e_stat_update32(hw, I40E_PRTPM_TLPIC,
985 pf->stat_offsets_loaded,
986 &osd->tx_lpi_count, &nsd->tx_lpi_count);
987 i40e_stat_update32(hw, I40E_PRTPM_RLPIC,
988 pf->stat_offsets_loaded,
989 &osd->rx_lpi_count, &nsd->rx_lpi_count);
974 } 990 }
975 991
976 pf->stat_offsets_loaded = true; 992 pf->stat_offsets_loaded = true;
@@ -1964,11 +1980,14 @@ static int i40e_vlan_rx_add_vid(struct net_device *netdev,
1964 1980
1965 netdev_info(netdev, "adding %pM vid=%d\n", netdev->dev_addr, vid); 1981 netdev_info(netdev, "adding %pM vid=%d\n", netdev->dev_addr, vid);
1966 1982
1967 /* If the network stack called us with vid = 0, we should 1983 /* If the network stack called us with vid = 0 then
1968 * indicate to i40e_vsi_add_vlan() that we want to receive 1984 * it is asking to receive priority tagged packets with
1969 * any traffic (i.e. with any vlan tag, or untagged) 1985 * vlan id 0. Our HW receives them by default when configured
1986 * to receive untagged packets so there is no need to add an
1987 * extra filter for vlan 0 tagged packets.
1970 */ 1988 */
1971 ret = i40e_vsi_add_vlan(vsi, vid ? vid : I40E_VLAN_ANY); 1989 if (vid)
1990 ret = i40e_vsi_add_vlan(vsi, vid);
1972 1991
1973 if (!ret && (vid < VLAN_N_VID)) 1992 if (!ret && (vid < VLAN_N_VID))
1974 set_bit(vid, vsi->active_vlans); 1993 set_bit(vid, vsi->active_vlans);
@@ -1981,7 +2000,7 @@ static int i40e_vlan_rx_add_vid(struct net_device *netdev,
1981 * @netdev: network interface to be adjusted 2000 * @netdev: network interface to be adjusted
1982 * @vid: vlan id to be removed 2001 * @vid: vlan id to be removed
1983 * 2002 *
1984 * net_device_ops implementation for adding vlan ids 2003 * net_device_ops implementation for removing vlan ids
1985 **/ 2004 **/
1986static int i40e_vlan_rx_kill_vid(struct net_device *netdev, 2005static int i40e_vlan_rx_kill_vid(struct net_device *netdev,
1987 __always_unused __be16 proto, u16 vid) 2006 __always_unused __be16 proto, u16 vid)
@@ -2177,6 +2196,11 @@ static int i40e_configure_tx_ring(struct i40e_ring *ring)
2177 tx_ctx.fd_ena = !!(vsi->back->flags & (I40E_FLAG_FD_SB_ENABLED | 2196 tx_ctx.fd_ena = !!(vsi->back->flags & (I40E_FLAG_FD_SB_ENABLED |
2178 I40E_FLAG_FD_ATR_ENABLED)); 2197 I40E_FLAG_FD_ATR_ENABLED));
2179 tx_ctx.timesync_ena = !!(vsi->back->flags & I40E_FLAG_PTP); 2198 tx_ctx.timesync_ena = !!(vsi->back->flags & I40E_FLAG_PTP);
2199 /* FDIR VSI tx ring can still use RS bit and writebacks */
2200 if (vsi->type != I40E_VSI_FDIR)
2201 tx_ctx.head_wb_ena = 1;
2202 tx_ctx.head_wb_addr = ring->dma +
2203 (ring->count * sizeof(struct i40e_tx_desc));
2180 2204
2181 /* As part of VSI creation/update, FW allocates certain 2205 /* As part of VSI creation/update, FW allocates certain
2182 * Tx arbitration queue sets for each TC enabled for 2206 * Tx arbitration queue sets for each TC enabled for
@@ -2420,6 +2444,28 @@ static void i40e_set_vsi_rx_mode(struct i40e_vsi *vsi)
2420} 2444}
2421 2445
2422/** 2446/**
2447 * i40e_fdir_filter_restore - Restore the Sideband Flow Director filters
2448 * @vsi: Pointer to the targeted VSI
2449 *
2450 * This function replays the hlist on the hw where all the SB Flow Director
2451 * filters were saved.
2452 **/
2453static void i40e_fdir_filter_restore(struct i40e_vsi *vsi)
2454{
2455 struct i40e_fdir_filter *filter;
2456 struct i40e_pf *pf = vsi->back;
2457 struct hlist_node *node;
2458
2459 if (!(pf->flags & I40E_FLAG_FD_SB_ENABLED))
2460 return;
2461
2462 hlist_for_each_entry_safe(filter, node,
2463 &pf->fdir_filter_list, fdir_node) {
2464 i40e_add_del_fdir(vsi, filter, true);
2465 }
2466}
2467
2468/**
2423 * i40e_vsi_configure - Set up the VSI for action 2469 * i40e_vsi_configure - Set up the VSI for action
2424 * @vsi: the VSI being configured 2470 * @vsi: the VSI being configured
2425 **/ 2471 **/
@@ -2557,7 +2603,7 @@ static void i40e_configure_msi_and_legacy(struct i40e_vsi *vsi)
2557 /* FIRSTQ_INDX = 0, FIRSTQ_TYPE = 0 (rx) */ 2603 /* FIRSTQ_INDX = 0, FIRSTQ_TYPE = 0 (rx) */
2558 wr32(hw, I40E_PFINT_LNKLST0, 0); 2604 wr32(hw, I40E_PFINT_LNKLST0, 0);
2559 2605
2560 /* Associate the queue pair to the vector and enable the q int */ 2606 /* Associate the queue pair to the vector and enable the queue int */
2561 val = I40E_QINT_RQCTL_CAUSE_ENA_MASK | 2607 val = I40E_QINT_RQCTL_CAUSE_ENA_MASK |
2562 (I40E_RX_ITR << I40E_QINT_RQCTL_ITR_INDX_SHIFT) | 2608 (I40E_RX_ITR << I40E_QINT_RQCTL_ITR_INDX_SHIFT) |
2563 (I40E_QUEUE_TYPE_TX << I40E_QINT_TQCTL_NEXTQ_TYPE_SHIFT); 2609 (I40E_QUEUE_TYPE_TX << I40E_QINT_TQCTL_NEXTQ_TYPE_SHIFT);
@@ -2866,8 +2912,7 @@ static irqreturn_t i40e_intr(int irq, void *data)
2866 icr0_remaining); 2912 icr0_remaining);
2867 if ((icr0_remaining & I40E_PFINT_ICR0_PE_CRITERR_MASK) || 2913 if ((icr0_remaining & I40E_PFINT_ICR0_PE_CRITERR_MASK) ||
2868 (icr0_remaining & I40E_PFINT_ICR0_PCI_EXCEPTION_MASK) || 2914 (icr0_remaining & I40E_PFINT_ICR0_PCI_EXCEPTION_MASK) ||
2869 (icr0_remaining & I40E_PFINT_ICR0_ECC_ERR_MASK) || 2915 (icr0_remaining & I40E_PFINT_ICR0_ECC_ERR_MASK)) {
2870 (icr0_remaining & I40E_PFINT_ICR0_MAL_DETECT_MASK)) {
2871 dev_info(&pf->pdev->dev, "device will be reset\n"); 2916 dev_info(&pf->pdev->dev, "device will be reset\n");
2872 set_bit(__I40E_PF_RESET_REQUESTED, &pf->state); 2917 set_bit(__I40E_PF_RESET_REQUESTED, &pf->state);
2873 i40e_service_event_schedule(pf); 2918 i40e_service_event_schedule(pf);
@@ -3107,13 +3152,13 @@ static int i40e_vsi_control_tx(struct i40e_vsi *vsi, bool enable)
3107 3152
3108 pf_q = vsi->base_queue; 3153 pf_q = vsi->base_queue;
3109 for (i = 0; i < vsi->num_queue_pairs; i++, pf_q++) { 3154 for (i = 0; i < vsi->num_queue_pairs; i++, pf_q++) {
3110 j = 1000; 3155 for (j = 0; j < 50; j++) {
3111 do {
3112 usleep_range(1000, 2000);
3113 tx_reg = rd32(hw, I40E_QTX_ENA(pf_q)); 3156 tx_reg = rd32(hw, I40E_QTX_ENA(pf_q));
3114 } while (j-- && ((tx_reg >> I40E_QTX_ENA_QENA_REQ_SHIFT) 3157 if (((tx_reg >> I40E_QTX_ENA_QENA_REQ_SHIFT) & 1) ==
3115 ^ (tx_reg >> I40E_QTX_ENA_QENA_STAT_SHIFT)) & 1); 3158 ((tx_reg >> I40E_QTX_ENA_QENA_STAT_SHIFT) & 1))
3116 3159 break;
3160 usleep_range(1000, 2000);
3161 }
3117 /* Skip if the queue is already in the requested state */ 3162 /* Skip if the queue is already in the requested state */
3118 if (enable && (tx_reg & I40E_QTX_ENA_QENA_STAT_MASK)) 3163 if (enable && (tx_reg & I40E_QTX_ENA_QENA_STAT_MASK))
3119 continue; 3164 continue;
@@ -3123,8 +3168,7 @@ static int i40e_vsi_control_tx(struct i40e_vsi *vsi, bool enable)
3123 /* turn on/off the queue */ 3168 /* turn on/off the queue */
3124 if (enable) { 3169 if (enable) {
3125 wr32(hw, I40E_QTX_HEAD(pf_q), 0); 3170 wr32(hw, I40E_QTX_HEAD(pf_q), 0);
3126 tx_reg |= I40E_QTX_ENA_QENA_REQ_MASK | 3171 tx_reg |= I40E_QTX_ENA_QENA_REQ_MASK;
3127 I40E_QTX_ENA_QENA_STAT_MASK;
3128 } else { 3172 } else {
3129 tx_reg &= ~I40E_QTX_ENA_QENA_REQ_MASK; 3173 tx_reg &= ~I40E_QTX_ENA_QENA_REQ_MASK;
3130 } 3174 }
@@ -3171,12 +3215,13 @@ static int i40e_vsi_control_rx(struct i40e_vsi *vsi, bool enable)
3171 3215
3172 pf_q = vsi->base_queue; 3216 pf_q = vsi->base_queue;
3173 for (i = 0; i < vsi->num_queue_pairs; i++, pf_q++) { 3217 for (i = 0; i < vsi->num_queue_pairs; i++, pf_q++) {
3174 j = 1000; 3218 for (j = 0; j < 50; j++) {
3175 do {
3176 usleep_range(1000, 2000);
3177 rx_reg = rd32(hw, I40E_QRX_ENA(pf_q)); 3219 rx_reg = rd32(hw, I40E_QRX_ENA(pf_q));
3178 } while (j-- && ((rx_reg >> I40E_QRX_ENA_QENA_REQ_SHIFT) 3220 if (((rx_reg >> I40E_QRX_ENA_QENA_REQ_SHIFT) & 1) ==
3179 ^ (rx_reg >> I40E_QRX_ENA_QENA_STAT_SHIFT)) & 1); 3221 ((rx_reg >> I40E_QRX_ENA_QENA_STAT_SHIFT) & 1))
3222 break;
3223 usleep_range(1000, 2000);
3224 }
3180 3225
3181 if (enable) { 3226 if (enable) {
3182 /* is STAT set ? */ 3227 /* is STAT set ? */
@@ -3190,11 +3235,9 @@ static int i40e_vsi_control_rx(struct i40e_vsi *vsi, bool enable)
3190 3235
3191 /* turn on/off the queue */ 3236 /* turn on/off the queue */
3192 if (enable) 3237 if (enable)
3193 rx_reg |= I40E_QRX_ENA_QENA_REQ_MASK | 3238 rx_reg |= I40E_QRX_ENA_QENA_REQ_MASK;
3194 I40E_QRX_ENA_QENA_STAT_MASK;
3195 else 3239 else
3196 rx_reg &= ~(I40E_QRX_ENA_QENA_REQ_MASK | 3240 rx_reg &= ~I40E_QRX_ENA_QENA_REQ_MASK;
3197 I40E_QRX_ENA_QENA_STAT_MASK);
3198 wr32(hw, I40E_QRX_ENA(pf_q), rx_reg); 3241 wr32(hw, I40E_QRX_ENA(pf_q), rx_reg);
3199 3242
3200 /* wait for the change to finish */ 3243 /* wait for the change to finish */
@@ -3732,8 +3775,8 @@ static int i40e_vsi_configure_bw_alloc(struct i40e_vsi *vsi, u8 enabled_tc,
3732 NULL); 3775 NULL);
3733 if (aq_ret) { 3776 if (aq_ret) {
3734 dev_info(&vsi->back->pdev->dev, 3777 dev_info(&vsi->back->pdev->dev,
3735 "%s: AQ command Config VSI BW allocation per TC failed = %d\n", 3778 "AQ command Config VSI BW allocation per TC failed = %d\n",
3736 __func__, vsi->back->hw.aq.asq_last_status); 3779 vsi->back->hw.aq.asq_last_status);
3737 return -EINVAL; 3780 return -EINVAL;
3738 } 3781 }
3739 3782
@@ -4062,6 +4105,10 @@ static int i40e_up_complete(struct i40e_vsi *vsi)
4062 } else if (vsi->netdev) { 4105 } else if (vsi->netdev) {
4063 netdev_info(vsi->netdev, "NIC Link is Down\n"); 4106 netdev_info(vsi->netdev, "NIC Link is Down\n");
4064 } 4107 }
4108
4109 /* replay FDIR SB filters */
4110 if (vsi->type == I40E_VSI_FDIR)
4111 i40e_fdir_filter_restore(vsi);
4065 i40e_service_event_schedule(pf); 4112 i40e_service_event_schedule(pf);
4066 4113
4067 return 0; 4114 return 0;
@@ -4208,7 +4255,6 @@ static int i40e_open(struct net_device *netdev)
4208 struct i40e_netdev_priv *np = netdev_priv(netdev); 4255 struct i40e_netdev_priv *np = netdev_priv(netdev);
4209 struct i40e_vsi *vsi = np->vsi; 4256 struct i40e_vsi *vsi = np->vsi;
4210 struct i40e_pf *pf = vsi->back; 4257 struct i40e_pf *pf = vsi->back;
4211 char int_name[IFNAMSIZ];
4212 int err; 4258 int err;
4213 4259
4214 /* disallow open during test */ 4260 /* disallow open during test */
@@ -4217,6 +4263,31 @@ static int i40e_open(struct net_device *netdev)
4217 4263
4218 netif_carrier_off(netdev); 4264 netif_carrier_off(netdev);
4219 4265
4266 err = i40e_vsi_open(vsi);
4267 if (err)
4268 return err;
4269
4270#ifdef CONFIG_I40E_VXLAN
4271 vxlan_get_rx_port(netdev);
4272#endif
4273
4274 return 0;
4275}
4276
4277/**
4278 * i40e_vsi_open -
4279 * @vsi: the VSI to open
4280 *
4281 * Finish initialization of the VSI.
4282 *
4283 * Returns 0 on success, negative value on failure
4284 **/
4285int i40e_vsi_open(struct i40e_vsi *vsi)
4286{
4287 struct i40e_pf *pf = vsi->back;
4288 char int_name[IFNAMSIZ];
4289 int err;
4290
4220 /* allocate descriptors */ 4291 /* allocate descriptors */
4221 err = i40e_vsi_setup_tx_resources(vsi); 4292 err = i40e_vsi_setup_tx_resources(vsi);
4222 if (err) 4293 if (err)
@@ -4229,18 +4300,22 @@ static int i40e_open(struct net_device *netdev)
4229 if (err) 4300 if (err)
4230 goto err_setup_rx; 4301 goto err_setup_rx;
4231 4302
4303 if (!vsi->netdev) {
4304 err = EINVAL;
4305 goto err_setup_rx;
4306 }
4232 snprintf(int_name, sizeof(int_name) - 1, "%s-%s", 4307 snprintf(int_name, sizeof(int_name) - 1, "%s-%s",
4233 dev_driver_string(&pf->pdev->dev), netdev->name); 4308 dev_driver_string(&pf->pdev->dev), vsi->netdev->name);
4234 err = i40e_vsi_request_irq(vsi, int_name); 4309 err = i40e_vsi_request_irq(vsi, int_name);
4235 if (err) 4310 if (err)
4236 goto err_setup_rx; 4311 goto err_setup_rx;
4237 4312
4238 /* Notify the stack of the actual queue counts. */ 4313 /* Notify the stack of the actual queue counts. */
4239 err = netif_set_real_num_tx_queues(netdev, vsi->num_queue_pairs); 4314 err = netif_set_real_num_tx_queues(vsi->netdev, vsi->num_queue_pairs);
4240 if (err) 4315 if (err)
4241 goto err_set_queues; 4316 goto err_set_queues;
4242 4317
4243 err = netif_set_real_num_rx_queues(netdev, vsi->num_queue_pairs); 4318 err = netif_set_real_num_rx_queues(vsi->netdev, vsi->num_queue_pairs);
4244 if (err) 4319 if (err)
4245 goto err_set_queues; 4320 goto err_set_queues;
4246 4321
@@ -4248,10 +4323,6 @@ static int i40e_open(struct net_device *netdev)
4248 if (err) 4323 if (err)
4249 goto err_up_complete; 4324 goto err_up_complete;
4250 4325
4251#ifdef CONFIG_I40E_VXLAN
4252 vxlan_get_rx_port(netdev);
4253#endif
4254
4255 return 0; 4326 return 0;
4256 4327
4257err_up_complete: 4328err_up_complete:
@@ -4269,6 +4340,26 @@ err_setup_tx:
4269} 4340}
4270 4341
4271/** 4342/**
4343 * i40e_fdir_filter_exit - Cleans up the Flow Director accounting
4344 * @pf: Pointer to pf
4345 *
4346 * This function destroys the hlist where all the Flow Director
4347 * filters were saved.
4348 **/
4349static void i40e_fdir_filter_exit(struct i40e_pf *pf)
4350{
4351 struct i40e_fdir_filter *filter;
4352 struct hlist_node *node2;
4353
4354 hlist_for_each_entry_safe(filter, node2,
4355 &pf->fdir_filter_list, fdir_node) {
4356 hlist_del(&filter->fdir_node);
4357 kfree(filter);
4358 }
4359 pf->fdir_pf_active_filters = 0;
4360}
4361
4362/**
4272 * i40e_close - Disables a network interface 4363 * i40e_close - Disables a network interface
4273 * @netdev: network interface device structure 4364 * @netdev: network interface device structure
4274 * 4365 *
@@ -4321,7 +4412,7 @@ void i40e_do_reset(struct i40e_pf *pf, u32 reset_flags)
4321 * for the warning interrupt will deal with the shutdown 4412 * for the warning interrupt will deal with the shutdown
4322 * and recovery of the switch setup. 4413 * and recovery of the switch setup.
4323 */ 4414 */
4324 dev_info(&pf->pdev->dev, "GlobalR requested\n"); 4415 dev_dbg(&pf->pdev->dev, "GlobalR requested\n");
4325 val = rd32(&pf->hw, I40E_GLGEN_RTRIG); 4416 val = rd32(&pf->hw, I40E_GLGEN_RTRIG);
4326 val |= I40E_GLGEN_RTRIG_GLOBR_MASK; 4417 val |= I40E_GLGEN_RTRIG_GLOBR_MASK;
4327 wr32(&pf->hw, I40E_GLGEN_RTRIG, val); 4418 wr32(&pf->hw, I40E_GLGEN_RTRIG, val);
@@ -4332,7 +4423,7 @@ void i40e_do_reset(struct i40e_pf *pf, u32 reset_flags)
4332 * 4423 *
4333 * Same as Global Reset, except does *not* include the MAC/PHY 4424 * Same as Global Reset, except does *not* include the MAC/PHY
4334 */ 4425 */
4335 dev_info(&pf->pdev->dev, "CoreR requested\n"); 4426 dev_dbg(&pf->pdev->dev, "CoreR requested\n");
4336 val = rd32(&pf->hw, I40E_GLGEN_RTRIG); 4427 val = rd32(&pf->hw, I40E_GLGEN_RTRIG);
4337 val |= I40E_GLGEN_RTRIG_CORER_MASK; 4428 val |= I40E_GLGEN_RTRIG_CORER_MASK;
4338 wr32(&pf->hw, I40E_GLGEN_RTRIG, val); 4429 wr32(&pf->hw, I40E_GLGEN_RTRIG, val);
@@ -4366,7 +4457,7 @@ void i40e_do_reset(struct i40e_pf *pf, u32 reset_flags)
4366 * the switch, since we need to do all the recovery as 4457 * the switch, since we need to do all the recovery as
4367 * for the Core Reset. 4458 * for the Core Reset.
4368 */ 4459 */
4369 dev_info(&pf->pdev->dev, "PFR requested\n"); 4460 dev_dbg(&pf->pdev->dev, "PFR requested\n");
4370 i40e_handle_reset_warning(pf); 4461 i40e_handle_reset_warning(pf);
4371 4462
4372 } else if (reset_flags & (1 << __I40E_REINIT_REQUESTED)) { 4463 } else if (reset_flags & (1 << __I40E_REINIT_REQUESTED)) {
@@ -4415,18 +4506,18 @@ bool i40e_dcb_need_reconfig(struct i40e_pf *pf,
4415 &old_cfg->etscfg.prioritytable, 4506 &old_cfg->etscfg.prioritytable,
4416 sizeof(new_cfg->etscfg.prioritytable))) { 4507 sizeof(new_cfg->etscfg.prioritytable))) {
4417 need_reconfig = true; 4508 need_reconfig = true;
4418 dev_info(&pf->pdev->dev, "ETS UP2TC changed.\n"); 4509 dev_dbg(&pf->pdev->dev, "ETS UP2TC changed.\n");
4419 } 4510 }
4420 4511
4421 if (memcmp(&new_cfg->etscfg.tcbwtable, 4512 if (memcmp(&new_cfg->etscfg.tcbwtable,
4422 &old_cfg->etscfg.tcbwtable, 4513 &old_cfg->etscfg.tcbwtable,
4423 sizeof(new_cfg->etscfg.tcbwtable))) 4514 sizeof(new_cfg->etscfg.tcbwtable)))
4424 dev_info(&pf->pdev->dev, "ETS TC BW Table changed.\n"); 4515 dev_dbg(&pf->pdev->dev, "ETS TC BW Table changed.\n");
4425 4516
4426 if (memcmp(&new_cfg->etscfg.tsatable, 4517 if (memcmp(&new_cfg->etscfg.tsatable,
4427 &old_cfg->etscfg.tsatable, 4518 &old_cfg->etscfg.tsatable,
4428 sizeof(new_cfg->etscfg.tsatable))) 4519 sizeof(new_cfg->etscfg.tsatable)))
4429 dev_info(&pf->pdev->dev, "ETS TSA Table changed.\n"); 4520 dev_dbg(&pf->pdev->dev, "ETS TSA Table changed.\n");
4430 } 4521 }
4431 4522
4432 /* Check if PFC configuration has changed */ 4523 /* Check if PFC configuration has changed */
@@ -4434,7 +4525,7 @@ bool i40e_dcb_need_reconfig(struct i40e_pf *pf,
4434 &old_cfg->pfc, 4525 &old_cfg->pfc,
4435 sizeof(new_cfg->pfc))) { 4526 sizeof(new_cfg->pfc))) {
4436 need_reconfig = true; 4527 need_reconfig = true;
4437 dev_info(&pf->pdev->dev, "PFC config change detected.\n"); 4528 dev_dbg(&pf->pdev->dev, "PFC config change detected.\n");
4438 } 4529 }
4439 4530
4440 /* Check if APP Table has changed */ 4531 /* Check if APP Table has changed */
@@ -4442,7 +4533,7 @@ bool i40e_dcb_need_reconfig(struct i40e_pf *pf,
4442 &old_cfg->app, 4533 &old_cfg->app,
4443 sizeof(new_cfg->app))) { 4534 sizeof(new_cfg->app))) {
4444 need_reconfig = true; 4535 need_reconfig = true;
4445 dev_info(&pf->pdev->dev, "APP Table change detected.\n"); 4536 dev_dbg(&pf->pdev->dev, "APP Table change detected.\n");
4446 } 4537 }
4447 4538
4448 return need_reconfig; 4539 return need_reconfig;
@@ -4492,7 +4583,7 @@ static int i40e_handle_lldp_event(struct i40e_pf *pf,
4492 4583
4493 /* No change detected in DCBX configs */ 4584 /* No change detected in DCBX configs */
4494 if (!memcmp(&tmp_dcbx_cfg, dcbx_cfg, sizeof(tmp_dcbx_cfg))) { 4585 if (!memcmp(&tmp_dcbx_cfg, dcbx_cfg, sizeof(tmp_dcbx_cfg))) {
4495 dev_info(&pf->pdev->dev, "No change detected in DCBX configuration.\n"); 4586 dev_dbg(&pf->pdev->dev, "No change detected in DCBX configuration.\n");
4496 goto exit; 4587 goto exit;
4497 } 4588 }
4498 4589
@@ -4550,8 +4641,8 @@ static void i40e_handle_lan_overflow_event(struct i40e_pf *pf,
4550 struct i40e_vf *vf; 4641 struct i40e_vf *vf;
4551 u16 vf_id; 4642 u16 vf_id;
4552 4643
4553 dev_info(&pf->pdev->dev, "%s: Rx Queue Number = %d QTX_CTL=0x%08x\n", 4644 dev_dbg(&pf->pdev->dev, "overflow Rx Queue Number = %d QTX_CTL=0x%08x\n",
4554 __func__, queue, qtx_ctl); 4645 queue, qtx_ctl);
4555 4646
4556 /* Queue belongs to VF, find the VF and issue VF reset */ 4647 /* Queue belongs to VF, find the VF and issue VF reset */
4557 if (((qtx_ctl & I40E_QTX_CTL_PFVF_Q_MASK) 4648 if (((qtx_ctl & I40E_QTX_CTL_PFVF_Q_MASK)
@@ -4581,6 +4672,54 @@ static void i40e_service_event_complete(struct i40e_pf *pf)
4581} 4672}
4582 4673
4583/** 4674/**
4675 * i40e_get_current_fd_count - Get the count of FD filters programmed in the HW
4676 * @pf: board private structure
4677 **/
4678int i40e_get_current_fd_count(struct i40e_pf *pf)
4679{
4680 int val, fcnt_prog;
4681 val = rd32(&pf->hw, I40E_PFQF_FDSTAT);
4682 fcnt_prog = (val & I40E_PFQF_FDSTAT_GUARANT_CNT_MASK) +
4683 ((val & I40E_PFQF_FDSTAT_BEST_CNT_MASK) >>
4684 I40E_PFQF_FDSTAT_BEST_CNT_SHIFT);
4685 return fcnt_prog;
4686}
4687
4688/**
4689 * i40e_fdir_check_and_reenable - Function to reenabe FD ATR or SB if disabled
4690 * @pf: board private structure
4691 **/
4692void i40e_fdir_check_and_reenable(struct i40e_pf *pf)
4693{
4694 u32 fcnt_prog, fcnt_avail;
4695
4696 /* Check if, FD SB or ATR was auto disabled and if there is enough room
4697 * to re-enable
4698 */
4699 if ((pf->flags & I40E_FLAG_FD_ATR_ENABLED) &&
4700 (pf->flags & I40E_FLAG_FD_SB_ENABLED))
4701 return;
4702 fcnt_prog = i40e_get_current_fd_count(pf);
4703 fcnt_avail = pf->hw.fdir_shared_filter_count +
4704 pf->fdir_pf_filter_count;
4705 if (fcnt_prog < (fcnt_avail - I40E_FDIR_BUFFER_HEAD_ROOM)) {
4706 if ((pf->flags & I40E_FLAG_FD_SB_ENABLED) &&
4707 (pf->auto_disable_flags & I40E_FLAG_FD_SB_ENABLED)) {
4708 pf->auto_disable_flags &= ~I40E_FLAG_FD_SB_ENABLED;
4709 dev_info(&pf->pdev->dev, "FD Sideband/ntuple is being enabled since we have space in the table now\n");
4710 }
4711 }
4712 /* Wait for some more space to be available to turn on ATR */
4713 if (fcnt_prog < (fcnt_avail - I40E_FDIR_BUFFER_HEAD_ROOM * 2)) {
4714 if ((pf->flags & I40E_FLAG_FD_ATR_ENABLED) &&
4715 (pf->auto_disable_flags & I40E_FLAG_FD_ATR_ENABLED)) {
4716 pf->auto_disable_flags &= ~I40E_FLAG_FD_ATR_ENABLED;
4717 dev_info(&pf->pdev->dev, "ATR is being enabled since we have space in the table now\n");
4718 }
4719 }
4720}
4721
4722/**
4584 * i40e_fdir_reinit_subtask - Worker thread to reinit FDIR filter table 4723 * i40e_fdir_reinit_subtask - Worker thread to reinit FDIR filter table
4585 * @pf: board private structure 4724 * @pf: board private structure
4586 **/ 4725 **/
@@ -4589,11 +4728,14 @@ static void i40e_fdir_reinit_subtask(struct i40e_pf *pf)
4589 if (!(pf->flags & I40E_FLAG_FDIR_REQUIRES_REINIT)) 4728 if (!(pf->flags & I40E_FLAG_FDIR_REQUIRES_REINIT))
4590 return; 4729 return;
4591 4730
4592 pf->flags &= ~I40E_FLAG_FDIR_REQUIRES_REINIT;
4593
4594 /* if interface is down do nothing */ 4731 /* if interface is down do nothing */
4595 if (test_bit(__I40E_DOWN, &pf->state)) 4732 if (test_bit(__I40E_DOWN, &pf->state))
4596 return; 4733 return;
4734 i40e_fdir_check_and_reenable(pf);
4735
4736 if ((pf->flags & I40E_FLAG_FD_ATR_ENABLED) &&
4737 (pf->flags & I40E_FLAG_FD_SB_ENABLED))
4738 pf->flags &= ~I40E_FLAG_FDIR_REQUIRES_REINIT;
4597} 4739}
4598 4740
4599/** 4741/**
@@ -4903,7 +5045,7 @@ static void i40e_clean_adminq_subtask(struct i40e_pf *pf)
4903 event.msg_size); 5045 event.msg_size);
4904 break; 5046 break;
4905 case i40e_aqc_opc_lldp_update_mib: 5047 case i40e_aqc_opc_lldp_update_mib:
4906 dev_info(&pf->pdev->dev, "ARQ: Update LLDP MIB event received\n"); 5048 dev_dbg(&pf->pdev->dev, "ARQ: Update LLDP MIB event received\n");
4907#ifdef CONFIG_I40E_DCB 5049#ifdef CONFIG_I40E_DCB
4908 rtnl_lock(); 5050 rtnl_lock();
4909 ret = i40e_handle_lldp_event(pf, &event); 5051 ret = i40e_handle_lldp_event(pf, &event);
@@ -4911,7 +5053,7 @@ static void i40e_clean_adminq_subtask(struct i40e_pf *pf)
4911#endif /* CONFIG_I40E_DCB */ 5053#endif /* CONFIG_I40E_DCB */
4912 break; 5054 break;
4913 case i40e_aqc_opc_event_lan_overflow: 5055 case i40e_aqc_opc_event_lan_overflow:
4914 dev_info(&pf->pdev->dev, "ARQ LAN queue overflow event received\n"); 5056 dev_dbg(&pf->pdev->dev, "ARQ LAN queue overflow event received\n");
4915 i40e_handle_lan_overflow_event(pf, &event); 5057 i40e_handle_lan_overflow_event(pf, &event);
4916 break; 5058 break;
4917 case i40e_aqc_opc_send_msg_to_peer: 5059 case i40e_aqc_opc_send_msg_to_peer:
@@ -5053,6 +5195,12 @@ static int i40e_get_capabilities(struct i40e_pf *pf)
5053 /* increment MSI-X count because current FW skips one */ 5195 /* increment MSI-X count because current FW skips one */
5054 pf->hw.func_caps.num_msix_vectors++; 5196 pf->hw.func_caps.num_msix_vectors++;
5055 5197
5198 if (((pf->hw.aq.fw_maj_ver == 2) && (pf->hw.aq.fw_min_ver < 22)) ||
5199 (pf->hw.aq.fw_maj_ver < 2)) {
5200 pf->hw.func_caps.num_msix_vectors++;
5201 pf->hw.func_caps.num_msix_vectors_vf++;
5202 }
5203
5056 if (pf->hw.debug_mask & I40E_DEBUG_USER) 5204 if (pf->hw.debug_mask & I40E_DEBUG_USER)
5057 dev_info(&pf->pdev->dev, 5205 dev_info(&pf->pdev->dev,
5058 "pf=%d, num_vfs=%d, msix_pf=%d, msix_vf=%d, fd_g=%d, fd_b=%d, pf_max_q=%d num_vsi=%d\n", 5206 "pf=%d, num_vfs=%d, msix_pf=%d, msix_vf=%d, fd_g=%d, fd_b=%d, pf_max_q=%d num_vsi=%d\n",
@@ -5132,9 +5280,9 @@ static void i40e_fdir_sb_setup(struct i40e_pf *pf)
5132 err = i40e_up_complete(vsi); 5280 err = i40e_up_complete(vsi);
5133 if (err) 5281 if (err)
5134 goto err_up_complete; 5282 goto err_up_complete;
5283 clear_bit(__I40E_NEEDS_RESTART, &vsi->state);
5135 } 5284 }
5136 5285
5137 clear_bit(__I40E_NEEDS_RESTART, &vsi->state);
5138 return; 5286 return;
5139 5287
5140err_up_complete: 5288err_up_complete:
@@ -5157,6 +5305,7 @@ static void i40e_fdir_teardown(struct i40e_pf *pf)
5157{ 5305{
5158 int i; 5306 int i;
5159 5307
5308 i40e_fdir_filter_exit(pf);
5160 for (i = 0; i < pf->hw.func_caps.num_vsis; i++) { 5309 for (i = 0; i < pf->hw.func_caps.num_vsis; i++) {
5161 if (pf->vsi[i] && pf->vsi[i]->type == I40E_VSI_FDIR) { 5310 if (pf->vsi[i] && pf->vsi[i]->type == I40E_VSI_FDIR) {
5162 i40e_vsi_release(pf->vsi[i]); 5311 i40e_vsi_release(pf->vsi[i]);
@@ -5181,7 +5330,7 @@ static int i40e_prep_for_reset(struct i40e_pf *pf)
5181 if (test_and_set_bit(__I40E_RESET_RECOVERY_PENDING, &pf->state)) 5330 if (test_and_set_bit(__I40E_RESET_RECOVERY_PENDING, &pf->state))
5182 return 0; 5331 return 0;
5183 5332
5184 dev_info(&pf->pdev->dev, "Tearing down internal switch for reset\n"); 5333 dev_dbg(&pf->pdev->dev, "Tearing down internal switch for reset\n");
5185 5334
5186 if (i40e_check_asq_alive(hw)) 5335 if (i40e_check_asq_alive(hw))
5187 i40e_vc_notify_reset(pf); 5336 i40e_vc_notify_reset(pf);
@@ -5228,7 +5377,7 @@ static void i40e_reset_and_rebuild(struct i40e_pf *pf, bool reinit)
5228 5377
5229 if (test_bit(__I40E_DOWN, &pf->state)) 5378 if (test_bit(__I40E_DOWN, &pf->state))
5230 goto end_core_reset; 5379 goto end_core_reset;
5231 dev_info(&pf->pdev->dev, "Rebuilding internal switch\n"); 5380 dev_dbg(&pf->pdev->dev, "Rebuilding internal switch\n");
5232 5381
5233 /* rebuild the basics for the AdminQ, HMC, and initial HW switch */ 5382 /* rebuild the basics for the AdminQ, HMC, and initial HW switch */
5234 ret = i40e_init_adminq(&pf->hw); 5383 ret = i40e_init_adminq(&pf->hw);
@@ -5278,7 +5427,7 @@ static void i40e_reset_and_rebuild(struct i40e_pf *pf, bool reinit)
5278 * try to recover minimal use by getting the basic PF VSI working. 5427 * try to recover minimal use by getting the basic PF VSI working.
5279 */ 5428 */
5280 if (pf->vsi[pf->lan_vsi]->uplink_seid != pf->mac_seid) { 5429 if (pf->vsi[pf->lan_vsi]->uplink_seid != pf->mac_seid) {
5281 dev_info(&pf->pdev->dev, "attempting to rebuild switch\n"); 5430 dev_dbg(&pf->pdev->dev, "attempting to rebuild switch\n");
5282 /* find the one VEB connected to the MAC, and find orphans */ 5431 /* find the one VEB connected to the MAC, and find orphans */
5283 for (v = 0; v < I40E_MAX_VEB; v++) { 5432 for (v = 0; v < I40E_MAX_VEB; v++) {
5284 if (!pf->veb[v]) 5433 if (!pf->veb[v])
@@ -5331,6 +5480,11 @@ static void i40e_reset_and_rebuild(struct i40e_pf *pf, bool reinit)
5331 /* restart the VSIs that were rebuilt and running before the reset */ 5480 /* restart the VSIs that were rebuilt and running before the reset */
5332 i40e_pf_unquiesce_all_vsi(pf); 5481 i40e_pf_unquiesce_all_vsi(pf);
5333 5482
5483 if (pf->num_alloc_vfs) {
5484 for (v = 0; v < pf->num_alloc_vfs; v++)
5485 i40e_reset_vf(&pf->vf[v], true);
5486 }
5487
5334 /* tell the firmware that we're starting */ 5488 /* tell the firmware that we're starting */
5335 dv.major_version = DRV_VERSION_MAJOR; 5489 dv.major_version = DRV_VERSION_MAJOR;
5336 dv.minor_version = DRV_VERSION_MINOR; 5490 dv.minor_version = DRV_VERSION_MINOR;
@@ -5338,7 +5492,7 @@ static void i40e_reset_and_rebuild(struct i40e_pf *pf, bool reinit)
5338 dv.subbuild_version = 0; 5492 dv.subbuild_version = 0;
5339 i40e_aq_send_driver_version(&pf->hw, &dv, NULL); 5493 i40e_aq_send_driver_version(&pf->hw, &dv, NULL);
5340 5494
5341 dev_info(&pf->pdev->dev, "PF reset done\n"); 5495 dev_info(&pf->pdev->dev, "reset complete\n");
5342 5496
5343end_core_reset: 5497end_core_reset:
5344 clear_bit(__I40E_RESET_RECOVERY_PENDING, &pf->state); 5498 clear_bit(__I40E_RESET_RECOVERY_PENDING, &pf->state);
@@ -5387,7 +5541,7 @@ static void i40e_handle_mdd_event(struct i40e_pf *pf)
5387 u8 queue = (reg & I40E_GL_MDET_TX_QUEUE_MASK) 5541 u8 queue = (reg & I40E_GL_MDET_TX_QUEUE_MASK)
5388 >> I40E_GL_MDET_TX_QUEUE_SHIFT; 5542 >> I40E_GL_MDET_TX_QUEUE_SHIFT;
5389 dev_info(&pf->pdev->dev, 5543 dev_info(&pf->pdev->dev,
5390 "Malicious Driver Detection TX event 0x%02x on q %d of function 0x%02x\n", 5544 "Malicious Driver Detection event 0x%02x on TX queue %d of function 0x%02x\n",
5391 event, queue, func); 5545 event, queue, func);
5392 wr32(hw, I40E_GL_MDET_TX, 0xffffffff); 5546 wr32(hw, I40E_GL_MDET_TX, 0xffffffff);
5393 mdd_detected = true; 5547 mdd_detected = true;
@@ -5401,7 +5555,7 @@ static void i40e_handle_mdd_event(struct i40e_pf *pf)
5401 u8 queue = (reg & I40E_GL_MDET_RX_QUEUE_MASK) 5555 u8 queue = (reg & I40E_GL_MDET_RX_QUEUE_MASK)
5402 >> I40E_GL_MDET_RX_QUEUE_SHIFT; 5556 >> I40E_GL_MDET_RX_QUEUE_SHIFT;
5403 dev_info(&pf->pdev->dev, 5557 dev_info(&pf->pdev->dev,
5404 "Malicious Driver Detection RX event 0x%02x on q %d of function 0x%02x\n", 5558 "Malicious Driver Detection event 0x%02x on RX queue %d of function 0x%02x\n",
5405 event, queue, func); 5559 event, queue, func);
5406 wr32(hw, I40E_GL_MDET_RX, 0xffffffff); 5560 wr32(hw, I40E_GL_MDET_RX, 0xffffffff);
5407 mdd_detected = true; 5561 mdd_detected = true;
@@ -5850,37 +6004,16 @@ err_out:
5850 **/ 6004 **/
5851static int i40e_reserve_msix_vectors(struct i40e_pf *pf, int vectors) 6005static int i40e_reserve_msix_vectors(struct i40e_pf *pf, int vectors)
5852{ 6006{
5853 int err = 0; 6007 vectors = pci_enable_msix_range(pf->pdev, pf->msix_entries,
5854 6008 I40E_MIN_MSIX, vectors);
5855 pf->num_msix_entries = 0; 6009 if (vectors < 0) {
5856 while (vectors >= I40E_MIN_MSIX) {
5857 err = pci_enable_msix(pf->pdev, pf->msix_entries, vectors);
5858 if (err == 0) {
5859 /* good to go */
5860 pf->num_msix_entries = vectors;
5861 break;
5862 } else if (err < 0) {
5863 /* total failure */
5864 dev_info(&pf->pdev->dev,
5865 "MSI-X vector reservation failed: %d\n", err);
5866 vectors = 0;
5867 break;
5868 } else {
5869 /* err > 0 is the hint for retry */
5870 dev_info(&pf->pdev->dev,
5871 "MSI-X vectors wanted %d, retrying with %d\n",
5872 vectors, err);
5873 vectors = err;
5874 }
5875 }
5876
5877 if (vectors > 0 && vectors < I40E_MIN_MSIX) {
5878 dev_info(&pf->pdev->dev, 6010 dev_info(&pf->pdev->dev,
5879 "Couldn't get enough vectors, only %d available\n", 6011 "MSI-X vector reservation failed: %d\n", vectors);
5880 vectors);
5881 vectors = 0; 6012 vectors = 0;
5882 } 6013 }
5883 6014
6015 pf->num_msix_entries = vectors;
6016
5884 return vectors; 6017 return vectors;
5885} 6018}
5886 6019
@@ -5942,7 +6075,7 @@ static int i40e_init_msix(struct i40e_pf *pf)
5942 6075
5943 } else if (vec == I40E_MIN_MSIX) { 6076 } else if (vec == I40E_MIN_MSIX) {
5944 /* Adjust for minimal MSIX use */ 6077 /* Adjust for minimal MSIX use */
5945 dev_info(&pf->pdev->dev, "Features disabled, not enough MSIX vectors\n"); 6078 dev_info(&pf->pdev->dev, "Features disabled, not enough MSI-X vectors\n");
5946 pf->flags &= ~I40E_FLAG_VMDQ_ENABLED; 6079 pf->flags &= ~I40E_FLAG_VMDQ_ENABLED;
5947 pf->num_vmdq_vsis = 0; 6080 pf->num_vmdq_vsis = 0;
5948 pf->num_vmdq_qps = 0; 6081 pf->num_vmdq_qps = 0;
@@ -6071,7 +6204,7 @@ static void i40e_init_interrupt_scheme(struct i40e_pf *pf)
6071 6204
6072 if (!(pf->flags & I40E_FLAG_MSIX_ENABLED) && 6205 if (!(pf->flags & I40E_FLAG_MSIX_ENABLED) &&
6073 (pf->flags & I40E_FLAG_MSI_ENABLED)) { 6206 (pf->flags & I40E_FLAG_MSI_ENABLED)) {
6074 dev_info(&pf->pdev->dev, "MSIX not available, trying MSI\n"); 6207 dev_info(&pf->pdev->dev, "MSI-X not available, trying MSI\n");
6075 err = pci_enable_msi(pf->pdev); 6208 err = pci_enable_msi(pf->pdev);
6076 if (err) { 6209 if (err) {
6077 dev_info(&pf->pdev->dev, "MSI init failed - %d\n", err); 6210 dev_info(&pf->pdev->dev, "MSI init failed - %d\n", err);
@@ -6080,7 +6213,7 @@ static void i40e_init_interrupt_scheme(struct i40e_pf *pf)
6080 } 6213 }
6081 6214
6082 if (!(pf->flags & (I40E_FLAG_MSIX_ENABLED | I40E_FLAG_MSI_ENABLED))) 6215 if (!(pf->flags & (I40E_FLAG_MSIX_ENABLED | I40E_FLAG_MSI_ENABLED)))
6083 dev_info(&pf->pdev->dev, "MSIX and MSI not available, falling back to Legacy IRQ\n"); 6216 dev_info(&pf->pdev->dev, "MSI-X and MSI not available, falling back to Legacy IRQ\n");
6084 6217
6085 /* track first vector for misc interrupts */ 6218 /* track first vector for misc interrupts */
6086 err = i40e_get_lump(pf, pf->irq_pile, 1, I40E_PILE_VALID_BIT-1); 6219 err = i40e_get_lump(pf, pf->irq_pile, 1, I40E_PILE_VALID_BIT-1);
@@ -6107,7 +6240,8 @@ static int i40e_setup_misc_vector(struct i40e_pf *pf)
6107 i40e_intr, 0, pf->misc_int_name, pf); 6240 i40e_intr, 0, pf->misc_int_name, pf);
6108 if (err) { 6241 if (err) {
6109 dev_info(&pf->pdev->dev, 6242 dev_info(&pf->pdev->dev,
6110 "request_irq for msix_misc failed: %d\n", err); 6243 "request_irq for %s failed: %d\n",
6244 pf->misc_int_name, err);
6111 return -EFAULT; 6245 return -EFAULT;
6112 } 6246 }
6113 } 6247 }
@@ -6258,15 +6392,11 @@ static int i40e_sw_init(struct i40e_pf *pf)
6258 (pf->hw.func_caps.fd_filters_best_effort > 0)) { 6392 (pf->hw.func_caps.fd_filters_best_effort > 0)) {
6259 pf->flags |= I40E_FLAG_FD_ATR_ENABLED; 6393 pf->flags |= I40E_FLAG_FD_ATR_ENABLED;
6260 pf->atr_sample_rate = I40E_DEFAULT_ATR_SAMPLE_RATE; 6394 pf->atr_sample_rate = I40E_DEFAULT_ATR_SAMPLE_RATE;
6261 dev_info(&pf->pdev->dev,
6262 "Flow Director ATR mode Enabled\n");
6263 if (!(pf->flags & I40E_FLAG_MFP_ENABLED)) { 6395 if (!(pf->flags & I40E_FLAG_MFP_ENABLED)) {
6264 pf->flags |= I40E_FLAG_FD_SB_ENABLED; 6396 pf->flags |= I40E_FLAG_FD_SB_ENABLED;
6265 dev_info(&pf->pdev->dev,
6266 "Flow Director Side Band mode Enabled\n");
6267 } else { 6397 } else {
6268 dev_info(&pf->pdev->dev, 6398 dev_info(&pf->pdev->dev,
6269 "Flow Director Side Band mode Disabled in MFP mode\n"); 6399 "Flow Director Sideband mode Disabled in MFP mode\n");
6270 } 6400 }
6271 pf->fdir_pf_filter_count = 6401 pf->fdir_pf_filter_count =
6272 pf->hw.func_caps.fd_filters_guaranteed; 6402 pf->hw.func_caps.fd_filters_guaranteed;
@@ -6287,9 +6417,6 @@ static int i40e_sw_init(struct i40e_pf *pf)
6287 pf->num_req_vfs = min_t(int, 6417 pf->num_req_vfs = min_t(int,
6288 pf->hw.func_caps.num_vfs, 6418 pf->hw.func_caps.num_vfs,
6289 I40E_MAX_VF_COUNT); 6419 I40E_MAX_VF_COUNT);
6290 dev_info(&pf->pdev->dev,
6291 "Number of VFs being requested for PF[%d] = %d\n",
6292 pf->hw.pf_id, pf->num_req_vfs);
6293 } 6420 }
6294#endif /* CONFIG_PCI_IOV */ 6421#endif /* CONFIG_PCI_IOV */
6295 pf->eeprom_version = 0xDEAD; 6422 pf->eeprom_version = 0xDEAD;
@@ -6326,6 +6453,39 @@ sw_init_done:
6326} 6453}
6327 6454
6328/** 6455/**
6456 * i40e_set_ntuple - set the ntuple feature flag and take action
6457 * @pf: board private structure to initialize
6458 * @features: the feature set that the stack is suggesting
6459 *
6460 * returns a bool to indicate if reset needs to happen
6461 **/
6462bool i40e_set_ntuple(struct i40e_pf *pf, netdev_features_t features)
6463{
6464 bool need_reset = false;
6465
6466 /* Check if Flow Director n-tuple support was enabled or disabled. If
6467 * the state changed, we need to reset.
6468 */
6469 if (features & NETIF_F_NTUPLE) {
6470 /* Enable filters and mark for reset */
6471 if (!(pf->flags & I40E_FLAG_FD_SB_ENABLED))
6472 need_reset = true;
6473 pf->flags |= I40E_FLAG_FD_SB_ENABLED;
6474 } else {
6475 /* turn off filters, mark for reset and clear SW filter list */
6476 if (pf->flags & I40E_FLAG_FD_SB_ENABLED) {
6477 need_reset = true;
6478 i40e_fdir_filter_exit(pf);
6479 }
6480 pf->flags &= ~I40E_FLAG_FD_SB_ENABLED;
6481 /* if ATR was disabled it can be re-enabled. */
6482 if (!(pf->flags & I40E_FLAG_FD_ATR_ENABLED))
6483 pf->flags |= I40E_FLAG_FD_ATR_ENABLED;
6484 }
6485 return need_reset;
6486}
6487
6488/**
6329 * i40e_set_features - set the netdev feature flags 6489 * i40e_set_features - set the netdev feature flags
6330 * @netdev: ptr to the netdev being adjusted 6490 * @netdev: ptr to the netdev being adjusted
6331 * @features: the feature set that the stack is suggesting 6491 * @features: the feature set that the stack is suggesting
@@ -6335,12 +6495,19 @@ static int i40e_set_features(struct net_device *netdev,
6335{ 6495{
6336 struct i40e_netdev_priv *np = netdev_priv(netdev); 6496 struct i40e_netdev_priv *np = netdev_priv(netdev);
6337 struct i40e_vsi *vsi = np->vsi; 6497 struct i40e_vsi *vsi = np->vsi;
6498 struct i40e_pf *pf = vsi->back;
6499 bool need_reset;
6338 6500
6339 if (features & NETIF_F_HW_VLAN_CTAG_RX) 6501 if (features & NETIF_F_HW_VLAN_CTAG_RX)
6340 i40e_vlan_stripping_enable(vsi); 6502 i40e_vlan_stripping_enable(vsi);
6341 else 6503 else
6342 i40e_vlan_stripping_disable(vsi); 6504 i40e_vlan_stripping_disable(vsi);
6343 6505
6506 need_reset = i40e_set_ntuple(pf, features);
6507
6508 if (need_reset)
6509 i40e_do_reset(pf, (1 << __I40E_PF_RESET_REQUESTED));
6510
6344 return 0; 6511 return 0;
6345} 6512}
6346 6513
@@ -6464,6 +6631,7 @@ static const struct net_device_ops i40e_netdev_ops = {
6464 .ndo_set_vf_vlan = i40e_ndo_set_vf_port_vlan, 6631 .ndo_set_vf_vlan = i40e_ndo_set_vf_port_vlan,
6465 .ndo_set_vf_tx_rate = i40e_ndo_set_vf_bw, 6632 .ndo_set_vf_tx_rate = i40e_ndo_set_vf_bw,
6466 .ndo_get_vf_config = i40e_ndo_get_vf_config, 6633 .ndo_get_vf_config = i40e_ndo_get_vf_config,
6634 .ndo_set_vf_link_state = i40e_ndo_set_vf_link_state,
6467#ifdef CONFIG_I40E_VXLAN 6635#ifdef CONFIG_I40E_VXLAN
6468 .ndo_add_vxlan_port = i40e_add_vxlan_port, 6636 .ndo_add_vxlan_port = i40e_add_vxlan_port,
6469 .ndo_del_vxlan_port = i40e_del_vxlan_port, 6637 .ndo_del_vxlan_port = i40e_del_vxlan_port,
@@ -6495,10 +6663,9 @@ static int i40e_config_netdev(struct i40e_vsi *vsi)
6495 np = netdev_priv(netdev); 6663 np = netdev_priv(netdev);
6496 np->vsi = vsi; 6664 np->vsi = vsi;
6497 6665
6498 netdev->hw_enc_features = NETIF_F_IP_CSUM | 6666 netdev->hw_enc_features |= NETIF_F_IP_CSUM |
6499 NETIF_F_GSO_UDP_TUNNEL | 6667 NETIF_F_GSO_UDP_TUNNEL |
6500 NETIF_F_TSO | 6668 NETIF_F_TSO;
6501 NETIF_F_SG;
6502 6669
6503 netdev->features = NETIF_F_SG | 6670 netdev->features = NETIF_F_SG |
6504 NETIF_F_IP_CSUM | 6671 NETIF_F_IP_CSUM |
@@ -6512,6 +6679,7 @@ static int i40e_config_netdev(struct i40e_vsi *vsi)
6512 NETIF_F_TSO | 6679 NETIF_F_TSO |
6513 NETIF_F_TSO6 | 6680 NETIF_F_TSO6 |
6514 NETIF_F_RXCSUM | 6681 NETIF_F_RXCSUM |
6682 NETIF_F_NTUPLE |
6515 NETIF_F_RXHASH | 6683 NETIF_F_RXHASH |
6516 0; 6684 0;
6517 6685
@@ -6771,8 +6939,6 @@ int i40e_vsi_release(struct i40e_vsi *vsi)
6771 if (vsi->netdev) { 6939 if (vsi->netdev) {
6772 /* results in a call to i40e_close() */ 6940 /* results in a call to i40e_close() */
6773 unregister_netdev(vsi->netdev); 6941 unregister_netdev(vsi->netdev);
6774 free_netdev(vsi->netdev);
6775 vsi->netdev = NULL;
6776 } 6942 }
6777 } else { 6943 } else {
6778 if (!test_and_set_bit(__I40E_DOWN, &vsi->state)) 6944 if (!test_and_set_bit(__I40E_DOWN, &vsi->state))
@@ -6791,6 +6957,10 @@ int i40e_vsi_release(struct i40e_vsi *vsi)
6791 6957
6792 i40e_vsi_delete(vsi); 6958 i40e_vsi_delete(vsi);
6793 i40e_vsi_free_q_vectors(vsi); 6959 i40e_vsi_free_q_vectors(vsi);
6960 if (vsi->netdev) {
6961 free_netdev(vsi->netdev);
6962 vsi->netdev = NULL;
6963 }
6794 i40e_vsi_clear_rings(vsi); 6964 i40e_vsi_clear_rings(vsi);
6795 i40e_vsi_clear(vsi); 6965 i40e_vsi_clear(vsi);
6796 6966
@@ -6845,8 +7015,7 @@ static int i40e_vsi_setup_vectors(struct i40e_vsi *vsi)
6845 } 7015 }
6846 7016
6847 if (vsi->base_vector) { 7017 if (vsi->base_vector) {
6848 dev_info(&pf->pdev->dev, 7018 dev_info(&pf->pdev->dev, "VSI %d has non-zero base vector %d\n",
6849 "VSI %d has non-zero base vector %d\n",
6850 vsi->seid, vsi->base_vector); 7019 vsi->seid, vsi->base_vector);
6851 return -EEXIST; 7020 return -EEXIST;
6852 } 7021 }
@@ -6865,7 +7034,7 @@ static int i40e_vsi_setup_vectors(struct i40e_vsi *vsi)
6865 vsi->num_q_vectors, vsi->idx); 7034 vsi->num_q_vectors, vsi->idx);
6866 if (vsi->base_vector < 0) { 7035 if (vsi->base_vector < 0) {
6867 dev_info(&pf->pdev->dev, 7036 dev_info(&pf->pdev->dev,
6868 "failed to get q tracking for VSI %d, err=%d\n", 7037 "failed to get queue tracking for VSI %d, err=%d\n",
6869 vsi->seid, vsi->base_vector); 7038 vsi->seid, vsi->base_vector);
6870 i40e_vsi_free_q_vectors(vsi); 7039 i40e_vsi_free_q_vectors(vsi);
6871 ret = -ENOENT; 7040 ret = -ENOENT;
@@ -7822,6 +7991,44 @@ static int i40e_setup_pf_filter_control(struct i40e_pf *pf)
7822 return 0; 7991 return 0;
7823} 7992}
7824 7993
7994#define INFO_STRING_LEN 255
7995static void i40e_print_features(struct i40e_pf *pf)
7996{
7997 struct i40e_hw *hw = &pf->hw;
7998 char *buf, *string;
7999
8000 string = kzalloc(INFO_STRING_LEN, GFP_KERNEL);
8001 if (!string) {
8002 dev_err(&pf->pdev->dev, "Features string allocation failed\n");
8003 return;
8004 }
8005
8006 buf = string;
8007
8008 buf += sprintf(string, "Features: PF-id[%d] ", hw->pf_id);
8009#ifdef CONFIG_PCI_IOV
8010 buf += sprintf(buf, "VFs: %d ", pf->num_req_vfs);
8011#endif
8012 buf += sprintf(buf, "VSIs: %d QP: %d ", pf->hw.func_caps.num_vsis,
8013 pf->vsi[pf->lan_vsi]->num_queue_pairs);
8014
8015 if (pf->flags & I40E_FLAG_RSS_ENABLED)
8016 buf += sprintf(buf, "RSS ");
8017 buf += sprintf(buf, "FDir ");
8018 if (pf->flags & I40E_FLAG_FD_ATR_ENABLED)
8019 buf += sprintf(buf, "ATR ");
8020 if (pf->flags & I40E_FLAG_FD_SB_ENABLED)
8021 buf += sprintf(buf, "NTUPLE ");
8022 if (pf->flags & I40E_FLAG_DCB_ENABLED)
8023 buf += sprintf(buf, "DCB ");
8024 if (pf->flags & I40E_FLAG_PTP)
8025 buf += sprintf(buf, "PTP ");
8026
8027 BUG_ON(buf > (string + INFO_STRING_LEN));
8028 dev_info(&pf->pdev->dev, "%s\n", string);
8029 kfree(string);
8030}
8031
7825/** 8032/**
7826 * i40e_probe - Device initialization routine 8033 * i40e_probe - Device initialization routine
7827 * @pdev: PCI device information struct 8034 * @pdev: PCI device information struct
@@ -7848,16 +8055,12 @@ static int i40e_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
7848 return err; 8055 return err;
7849 8056
7850 /* set up for high or low dma */ 8057 /* set up for high or low dma */
7851 if (!dma_set_mask(&pdev->dev, DMA_BIT_MASK(64))) { 8058 err = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64));
7852 /* coherent mask for the same size will always succeed if 8059 if (err)
7853 * dma_set_mask does 8060 err = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32));
7854 */ 8061 if (err) {
7855 dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(64)); 8062 dev_err(&pdev->dev,
7856 } else if (!dma_set_mask(&pdev->dev, DMA_BIT_MASK(32))) { 8063 "DMA configuration failed: 0x%x\n", err);
7857 dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(32));
7858 } else {
7859 dev_err(&pdev->dev, "DMA configuration failed: %d\n", err);
7860 err = -EIO;
7861 goto err_dma; 8064 goto err_dma;
7862 } 8065 }
7863 8066
@@ -7946,13 +8149,6 @@ static int i40e_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
7946 8149
7947 err = i40e_init_adminq(hw); 8150 err = i40e_init_adminq(hw);
7948 dev_info(&pdev->dev, "%s\n", i40e_fw_version_str(hw)); 8151 dev_info(&pdev->dev, "%s\n", i40e_fw_version_str(hw));
7949 if (((hw->nvm.version & I40E_NVM_VERSION_HI_MASK)
7950 >> I40E_NVM_VERSION_HI_SHIFT) != I40E_CURRENT_NVM_VERSION_HI) {
7951 dev_info(&pdev->dev,
7952 "warning: NVM version not supported, supported version: %02x.%02x\n",
7953 I40E_CURRENT_NVM_VERSION_HI,
7954 I40E_CURRENT_NVM_VERSION_LO);
7955 }
7956 if (err) { 8152 if (err) {
7957 dev_info(&pdev->dev, 8153 dev_info(&pdev->dev,
7958 "init_adminq failed: %d expecting API %02x.%02x\n", 8154 "init_adminq failed: %d expecting API %02x.%02x\n",
@@ -8070,6 +8266,16 @@ static int i40e_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
8070 val &= ~I40E_PFGEN_PORTMDIO_NUM_VFLINK_STAT_ENA_MASK; 8266 val &= ~I40E_PFGEN_PORTMDIO_NUM_VFLINK_STAT_ENA_MASK;
8071 wr32(hw, I40E_PFGEN_PORTMDIO_NUM, val); 8267 wr32(hw, I40E_PFGEN_PORTMDIO_NUM, val);
8072 i40e_flush(hw); 8268 i40e_flush(hw);
8269
8270 if (pci_num_vf(pdev)) {
8271 dev_info(&pdev->dev,
8272 "Active VFs found, allocating resources.\n");
8273 err = i40e_alloc_vfs(pf, pci_num_vf(pdev));
8274 if (err)
8275 dev_info(&pdev->dev,
8276 "Error %d allocating resources for existing VFs\n",
8277 err);
8278 }
8073 } 8279 }
8074 8280
8075 pfs_found++; 8281 pfs_found++;
@@ -8092,7 +8298,7 @@ static int i40e_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
8092 8298
8093 i40e_set_pci_config_data(hw, link_status); 8299 i40e_set_pci_config_data(hw, link_status);
8094 8300
8095 dev_info(&pdev->dev, "PCI Express: %s %s\n", 8301 dev_info(&pdev->dev, "PCI-Express: %s %s\n",
8096 (hw->bus.speed == i40e_bus_speed_8000 ? "Speed 8.0GT/s" : 8302 (hw->bus.speed == i40e_bus_speed_8000 ? "Speed 8.0GT/s" :
8097 hw->bus.speed == i40e_bus_speed_5000 ? "Speed 5.0GT/s" : 8303 hw->bus.speed == i40e_bus_speed_5000 ? "Speed 5.0GT/s" :
8098 hw->bus.speed == i40e_bus_speed_2500 ? "Speed 2.5GT/s" : 8304 hw->bus.speed == i40e_bus_speed_2500 ? "Speed 2.5GT/s" :
@@ -8109,6 +8315,9 @@ static int i40e_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
8109 dev_warn(&pdev->dev, "Please move the device to a different PCI-e link with more lanes and/or higher transfer rate.\n"); 8315 dev_warn(&pdev->dev, "Please move the device to a different PCI-e link with more lanes and/or higher transfer rate.\n");
8110 } 8316 }
8111 8317
8318 /* print a string summarizing features */
8319 i40e_print_features(pf);
8320
8112 return 0; 8321 return 0;
8113 8322
8114 /* Unwind what we've done if something failed in the setup */ 8323 /* Unwind what we've done if something failed in the setup */
@@ -8165,16 +8374,16 @@ static void i40e_remove(struct pci_dev *pdev)
8165 8374
8166 i40e_ptp_stop(pf); 8375 i40e_ptp_stop(pf);
8167 8376
8168 if (pf->flags & I40E_FLAG_SRIOV_ENABLED) {
8169 i40e_free_vfs(pf);
8170 pf->flags &= ~I40E_FLAG_SRIOV_ENABLED;
8171 }
8172
8173 /* no more scheduling of any task */ 8377 /* no more scheduling of any task */
8174 set_bit(__I40E_DOWN, &pf->state); 8378 set_bit(__I40E_DOWN, &pf->state);
8175 del_timer_sync(&pf->service_timer); 8379 del_timer_sync(&pf->service_timer);
8176 cancel_work_sync(&pf->service_task); 8380 cancel_work_sync(&pf->service_task);
8177 8381
8382 if (pf->flags & I40E_FLAG_SRIOV_ENABLED) {
8383 i40e_free_vfs(pf);
8384 pf->flags &= ~I40E_FLAG_SRIOV_ENABLED;
8385 }
8386
8178 i40e_fdir_teardown(pf); 8387 i40e_fdir_teardown(pf);
8179 8388
8180 /* If there is a switch structure or any orphans, remove them. 8389 /* If there is a switch structure or any orphans, remove them.
diff --git a/drivers/net/ethernet/intel/i40e/i40e_nvm.c b/drivers/net/ethernet/intel/i40e/i40e_nvm.c
index 73f95b081927..262bdf11d221 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_nvm.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_nvm.c
@@ -27,14 +27,14 @@
27#include "i40e_prototype.h" 27#include "i40e_prototype.h"
28 28
29/** 29/**
30 * i40e_init_nvm_ops - Initialize NVM function pointers. 30 * i40e_init_nvm_ops - Initialize NVM function pointers
31 * @hw: pointer to the HW structure. 31 * @hw: pointer to the HW structure
32 * 32 *
33 * Setups the function pointers and the NVM info structure. Should be called 33 * Setup the function pointers and the NVM info structure. Should be called
34 * once per NVM initialization, e.g. inside the i40e_init_shared_code(). 34 * once per NVM initialization, e.g. inside the i40e_init_shared_code().
35 * Please notice that the NVM term is used here (& in all methods covered 35 * Please notice that the NVM term is used here (& in all methods covered
36 * in this file) as an equivalent of the FLASH part mapped into the SR. 36 * in this file) as an equivalent of the FLASH part mapped into the SR.
37 * We are accessing FLASH always thru the Shadow RAM. 37 * We are accessing FLASH always thru the Shadow RAM.
38 **/ 38 **/
39i40e_status i40e_init_nvm(struct i40e_hw *hw) 39i40e_status i40e_init_nvm(struct i40e_hw *hw)
40{ 40{
@@ -49,16 +49,16 @@ i40e_status i40e_init_nvm(struct i40e_hw *hw)
49 gens = rd32(hw, I40E_GLNVM_GENS); 49 gens = rd32(hw, I40E_GLNVM_GENS);
50 sr_size = ((gens & I40E_GLNVM_GENS_SR_SIZE_MASK) >> 50 sr_size = ((gens & I40E_GLNVM_GENS_SR_SIZE_MASK) >>
51 I40E_GLNVM_GENS_SR_SIZE_SHIFT); 51 I40E_GLNVM_GENS_SR_SIZE_SHIFT);
52 /* Switching to words (sr_size contains power of 2KB). */ 52 /* Switching to words (sr_size contains power of 2KB) */
53 nvm->sr_size = (1 << sr_size) * I40E_SR_WORDS_IN_1KB; 53 nvm->sr_size = (1 << sr_size) * I40E_SR_WORDS_IN_1KB;
54 54
55 /* Check if we are in the normal or blank NVM programming mode. */ 55 /* Check if we are in the normal or blank NVM programming mode */
56 fla = rd32(hw, I40E_GLNVM_FLA); 56 fla = rd32(hw, I40E_GLNVM_FLA);
57 if (fla & I40E_GLNVM_FLA_LOCKED_MASK) { /* Normal programming mode. */ 57 if (fla & I40E_GLNVM_FLA_LOCKED_MASK) { /* Normal programming mode */
58 /* Max NVM timeout. */ 58 /* Max NVM timeout */
59 nvm->timeout = I40E_MAX_NVM_TIMEOUT; 59 nvm->timeout = I40E_MAX_NVM_TIMEOUT;
60 nvm->blank_nvm_mode = false; 60 nvm->blank_nvm_mode = false;
61 } else { /* Blank programming mode. */ 61 } else { /* Blank programming mode */
62 nvm->blank_nvm_mode = true; 62 nvm->blank_nvm_mode = true;
63 ret_code = I40E_ERR_NVM_BLANK_MODE; 63 ret_code = I40E_ERR_NVM_BLANK_MODE;
64 hw_dbg(hw, "NVM init error: unsupported blank mode.\n"); 64 hw_dbg(hw, "NVM init error: unsupported blank mode.\n");
@@ -68,12 +68,12 @@ i40e_status i40e_init_nvm(struct i40e_hw *hw)
68} 68}
69 69
70/** 70/**
71 * i40e_acquire_nvm - Generic request for acquiring the NVM ownership. 71 * i40e_acquire_nvm - Generic request for acquiring the NVM ownership
72 * @hw: pointer to the HW structure. 72 * @hw: pointer to the HW structure
73 * @access: NVM access type (read or write). 73 * @access: NVM access type (read or write)
74 * 74 *
75 * This function will request NVM ownership for reading 75 * This function will request NVM ownership for reading
76 * via the proper Admin Command. 76 * via the proper Admin Command.
77 **/ 77 **/
78i40e_status i40e_acquire_nvm(struct i40e_hw *hw, 78i40e_status i40e_acquire_nvm(struct i40e_hw *hw,
79 enum i40e_aq_resource_access_type access) 79 enum i40e_aq_resource_access_type access)
@@ -87,20 +87,20 @@ i40e_status i40e_acquire_nvm(struct i40e_hw *hw,
87 87
88 ret_code = i40e_aq_request_resource(hw, I40E_NVM_RESOURCE_ID, access, 88 ret_code = i40e_aq_request_resource(hw, I40E_NVM_RESOURCE_ID, access,
89 0, &time, NULL); 89 0, &time, NULL);
90 /* Reading the Global Device Timer. */ 90 /* Reading the Global Device Timer */
91 gtime = rd32(hw, I40E_GLVFGEN_TIMER); 91 gtime = rd32(hw, I40E_GLVFGEN_TIMER);
92 92
93 /* Store the timeout. */ 93 /* Store the timeout */
94 hw->nvm.hw_semaphore_timeout = I40E_MS_TO_GTIME(time) + gtime; 94 hw->nvm.hw_semaphore_timeout = I40E_MS_TO_GTIME(time) + gtime;
95 95
96 if (ret_code) { 96 if (ret_code) {
97 /* Set the polling timeout. */ 97 /* Set the polling timeout */
98 if (time > I40E_MAX_NVM_TIMEOUT) 98 if (time > I40E_MAX_NVM_TIMEOUT)
99 timeout = I40E_MS_TO_GTIME(I40E_MAX_NVM_TIMEOUT) 99 timeout = I40E_MS_TO_GTIME(I40E_MAX_NVM_TIMEOUT)
100 + gtime; 100 + gtime;
101 else 101 else
102 timeout = hw->nvm.hw_semaphore_timeout; 102 timeout = hw->nvm.hw_semaphore_timeout;
103 /* Poll until the current NVM owner timeouts. */ 103 /* Poll until the current NVM owner timeouts */
104 while (gtime < timeout) { 104 while (gtime < timeout) {
105 usleep_range(10000, 20000); 105 usleep_range(10000, 20000);
106 ret_code = i40e_aq_request_resource(hw, 106 ret_code = i40e_aq_request_resource(hw,
@@ -128,10 +128,10 @@ i40e_i40e_acquire_nvm_exit:
128} 128}
129 129
130/** 130/**
131 * i40e_release_nvm - Generic request for releasing the NVM ownership. 131 * i40e_release_nvm - Generic request for releasing the NVM ownership
132 * @hw: pointer to the HW structure. 132 * @hw: pointer to the HW structure
133 * 133 *
134 * This function will release NVM resource via the proper Admin Command. 134 * This function will release NVM resource via the proper Admin Command.
135 **/ 135 **/
136void i40e_release_nvm(struct i40e_hw *hw) 136void i40e_release_nvm(struct i40e_hw *hw)
137{ 137{
@@ -140,17 +140,17 @@ void i40e_release_nvm(struct i40e_hw *hw)
140} 140}
141 141
142/** 142/**
143 * i40e_poll_sr_srctl_done_bit - Polls the GLNVM_SRCTL done bit. 143 * i40e_poll_sr_srctl_done_bit - Polls the GLNVM_SRCTL done bit
144 * @hw: pointer to the HW structure. 144 * @hw: pointer to the HW structure
145 * 145 *
146 * Polls the SRCTL Shadow RAM register done bit. 146 * Polls the SRCTL Shadow RAM register done bit.
147 **/ 147 **/
148static i40e_status i40e_poll_sr_srctl_done_bit(struct i40e_hw *hw) 148static i40e_status i40e_poll_sr_srctl_done_bit(struct i40e_hw *hw)
149{ 149{
150 i40e_status ret_code = I40E_ERR_TIMEOUT; 150 i40e_status ret_code = I40E_ERR_TIMEOUT;
151 u32 srctl, wait_cnt; 151 u32 srctl, wait_cnt;
152 152
153 /* Poll the I40E_GLNVM_SRCTL until the done bit is set. */ 153 /* Poll the I40E_GLNVM_SRCTL until the done bit is set */
154 for (wait_cnt = 0; wait_cnt < I40E_SRRD_SRCTL_ATTEMPTS; wait_cnt++) { 154 for (wait_cnt = 0; wait_cnt < I40E_SRRD_SRCTL_ATTEMPTS; wait_cnt++) {
155 srctl = rd32(hw, I40E_GLNVM_SRCTL); 155 srctl = rd32(hw, I40E_GLNVM_SRCTL);
156 if (srctl & I40E_GLNVM_SRCTL_DONE_MASK) { 156 if (srctl & I40E_GLNVM_SRCTL_DONE_MASK) {
@@ -165,12 +165,12 @@ static i40e_status i40e_poll_sr_srctl_done_bit(struct i40e_hw *hw)
165} 165}
166 166
167/** 167/**
168 * i40e_read_nvm_word - Reads Shadow RAM 168 * i40e_read_nvm_word - Reads Shadow RAM
169 * @hw: pointer to the HW structure. 169 * @hw: pointer to the HW structure
170 * @offset: offset of the Shadow RAM word to read (0x000000 - 0x001FFF). 170 * @offset: offset of the Shadow RAM word to read (0x000000 - 0x001FFF)
171 * @data: word read from the Shadow RAM. 171 * @data: word read from the Shadow RAM
172 * 172 *
173 * Reads 16 bit word from the Shadow RAM using the GLNVM_SRCTL register. 173 * Reads one 16 bit word from the Shadow RAM using the GLNVM_SRCTL register.
174 **/ 174 **/
175i40e_status i40e_read_nvm_word(struct i40e_hw *hw, u16 offset, 175i40e_status i40e_read_nvm_word(struct i40e_hw *hw, u16 offset,
176 u16 *data) 176 u16 *data)
@@ -184,15 +184,15 @@ i40e_status i40e_read_nvm_word(struct i40e_hw *hw, u16 offset,
184 goto read_nvm_exit; 184 goto read_nvm_exit;
185 } 185 }
186 186
187 /* Poll the done bit first. */ 187 /* Poll the done bit first */
188 ret_code = i40e_poll_sr_srctl_done_bit(hw); 188 ret_code = i40e_poll_sr_srctl_done_bit(hw);
189 if (!ret_code) { 189 if (!ret_code) {
190 /* Write the address and start reading. */ 190 /* Write the address and start reading */
191 sr_reg = (u32)(offset << I40E_GLNVM_SRCTL_ADDR_SHIFT) | 191 sr_reg = (u32)(offset << I40E_GLNVM_SRCTL_ADDR_SHIFT) |
192 (1 << I40E_GLNVM_SRCTL_START_SHIFT); 192 (1 << I40E_GLNVM_SRCTL_START_SHIFT);
193 wr32(hw, I40E_GLNVM_SRCTL, sr_reg); 193 wr32(hw, I40E_GLNVM_SRCTL, sr_reg);
194 194
195 /* Poll I40E_GLNVM_SRCTL until the done bit is set. */ 195 /* Poll I40E_GLNVM_SRCTL until the done bit is set */
196 ret_code = i40e_poll_sr_srctl_done_bit(hw); 196 ret_code = i40e_poll_sr_srctl_done_bit(hw);
197 if (!ret_code) { 197 if (!ret_code) {
198 sr_reg = rd32(hw, I40E_GLNVM_SRDATA); 198 sr_reg = rd32(hw, I40E_GLNVM_SRDATA);
@@ -210,16 +210,15 @@ read_nvm_exit:
210} 210}
211 211
212/** 212/**
213 * i40e_read_nvm_buffer - Reads Shadow RAM buffer. 213 * i40e_read_nvm_buffer - Reads Shadow RAM buffer
214 * @hw: pointer to the HW structure. 214 * @hw: pointer to the HW structure
215 * @offset: offset of the Shadow RAM word to read (0x000000 - 0x001FFF). 215 * @offset: offset of the Shadow RAM word to read (0x000000 - 0x001FFF).
216 * @words: number of words to read (in) & 216 * @words: (in) number of words to read; (out) number of words actually read
217 * number of words read before the NVM ownership timeout (out). 217 * @data: words read from the Shadow RAM
218 * @data: words read from the Shadow RAM.
219 * 218 *
220 * Reads 16 bit words (data buffer) from the SR using the i40e_read_nvm_srrd() 219 * Reads 16 bit words (data buffer) from the SR using the i40e_read_nvm_srrd()
221 * method. The buffer read is preceded by the NVM ownership take 220 * method. The buffer read is preceded by the NVM ownership take
222 * and followed by the release. 221 * and followed by the release.
223 **/ 222 **/
224i40e_status i40e_read_nvm_buffer(struct i40e_hw *hw, u16 offset, 223i40e_status i40e_read_nvm_buffer(struct i40e_hw *hw, u16 offset,
225 u16 *words, u16 *data) 224 u16 *words, u16 *data)
@@ -227,7 +226,7 @@ i40e_status i40e_read_nvm_buffer(struct i40e_hw *hw, u16 offset,
227 i40e_status ret_code = 0; 226 i40e_status ret_code = 0;
228 u16 index, word; 227 u16 index, word;
229 228
230 /* Loop thru the selected region. */ 229 /* Loop thru the selected region */
231 for (word = 0; word < *words; word++) { 230 for (word = 0; word < *words; word++) {
232 index = offset + word; 231 index = offset + word;
233 ret_code = i40e_read_nvm_word(hw, index, &data[word]); 232 ret_code = i40e_read_nvm_word(hw, index, &data[word]);
@@ -235,21 +234,21 @@ i40e_status i40e_read_nvm_buffer(struct i40e_hw *hw, u16 offset,
235 break; 234 break;
236 } 235 }
237 236
238 /* Update the number of words read from the Shadow RAM. */ 237 /* Update the number of words read from the Shadow RAM */
239 *words = word; 238 *words = word;
240 239
241 return ret_code; 240 return ret_code;
242} 241}
243 242
244/** 243/**
245 * i40e_calc_nvm_checksum - Calculates and returns the checksum 244 * i40e_calc_nvm_checksum - Calculates and returns the checksum
246 * @hw: pointer to hardware structure 245 * @hw: pointer to hardware structure
247 * @checksum: pointer to the checksum 246 * @checksum: pointer to the checksum
248 * 247 *
249 * This function calculate SW Checksum that covers the whole 64kB shadow RAM 248 * This function calculates SW Checksum that covers the whole 64kB shadow RAM
250 * except the VPD and PCIe ALT Auto-load modules. The structure and size of VPD 249 * except the VPD and PCIe ALT Auto-load modules. The structure and size of VPD
251 * is customer specific and unknown. Therefore, this function skips all maximum 250 * is customer specific and unknown. Therefore, this function skips all maximum
252 * possible size of VPD (1kB). 251 * possible size of VPD (1kB).
253 **/ 252 **/
254static i40e_status i40e_calc_nvm_checksum(struct i40e_hw *hw, 253static i40e_status i40e_calc_nvm_checksum(struct i40e_hw *hw,
255 u16 *checksum) 254 u16 *checksum)
@@ -311,12 +310,12 @@ i40e_calc_nvm_checksum_exit:
311} 310}
312 311
313/** 312/**
314 * i40e_validate_nvm_checksum - Validate EEPROM checksum 313 * i40e_validate_nvm_checksum - Validate EEPROM checksum
315 * @hw: pointer to hardware structure 314 * @hw: pointer to hardware structure
316 * @checksum: calculated checksum 315 * @checksum: calculated checksum
317 * 316 *
318 * Performs checksum calculation and validates the NVM SW checksum. If the 317 * Performs checksum calculation and validates the NVM SW checksum. If the
319 * caller does not need checksum, the value can be NULL. 318 * caller does not need checksum, the value can be NULL.
320 **/ 319 **/
321i40e_status i40e_validate_nvm_checksum(struct i40e_hw *hw, 320i40e_status i40e_validate_nvm_checksum(struct i40e_hw *hw,
322 u16 *checksum) 321 u16 *checksum)
diff --git a/drivers/net/ethernet/intel/i40e/i40e_prototype.h b/drivers/net/ethernet/intel/i40e/i40e_prototype.h
index ed91f93ede2b..9cd57e617959 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_prototype.h
+++ b/drivers/net/ethernet/intel/i40e/i40e_prototype.h
@@ -231,6 +231,13 @@ i40e_status i40e_validate_nvm_checksum(struct i40e_hw *hw,
231 u16 *checksum); 231 u16 *checksum);
232void i40e_set_pci_config_data(struct i40e_hw *hw, u16 link_status); 232void i40e_set_pci_config_data(struct i40e_hw *hw, u16 link_status);
233 233
234extern struct i40e_rx_ptype_decoded i40e_ptype_lookup[];
235
236static inline struct i40e_rx_ptype_decoded decode_rx_desc_ptype(u8 ptype)
237{
238 return i40e_ptype_lookup[ptype];
239}
240
234/* prototype for functions used for SW locks */ 241/* prototype for functions used for SW locks */
235 242
236/* i40e_common for VF drivers*/ 243/* i40e_common for VF drivers*/
diff --git a/drivers/net/ethernet/intel/i40e/i40e_txrx.c b/drivers/net/ethernet/intel/i40e/i40e_txrx.c
index d4bb482b1a7f..851f6537a96a 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_txrx.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_txrx.c
@@ -25,6 +25,7 @@
25 ******************************************************************************/ 25 ******************************************************************************/
26 26
27#include "i40e.h" 27#include "i40e.h"
28#include "i40e_prototype.h"
28 29
29static inline __le64 build_ctob(u32 td_cmd, u32 td_offset, unsigned int size, 30static inline __le64 build_ctob(u32 td_cmd, u32 td_offset, unsigned int size,
30 u32 td_tag) 31 u32 td_tag)
@@ -39,11 +40,12 @@ static inline __le64 build_ctob(u32 td_cmd, u32 td_offset, unsigned int size,
39#define I40E_TXD_CMD (I40E_TX_DESC_CMD_EOP | I40E_TX_DESC_CMD_RS) 40#define I40E_TXD_CMD (I40E_TX_DESC_CMD_EOP | I40E_TX_DESC_CMD_RS)
40/** 41/**
41 * i40e_program_fdir_filter - Program a Flow Director filter 42 * i40e_program_fdir_filter - Program a Flow Director filter
42 * @fdir_input: Packet data that will be filter parameters 43 * @fdir_data: Packet data that will be filter parameters
44 * @raw_packet: the pre-allocated packet buffer for FDir
43 * @pf: The pf pointer 45 * @pf: The pf pointer
44 * @add: True for add/update, False for remove 46 * @add: True for add/update, False for remove
45 **/ 47 **/
46int i40e_program_fdir_filter(struct i40e_fdir_data *fdir_data, 48int i40e_program_fdir_filter(struct i40e_fdir_filter *fdir_data, u8 *raw_packet,
47 struct i40e_pf *pf, bool add) 49 struct i40e_pf *pf, bool add)
48{ 50{
49 struct i40e_filter_program_desc *fdir_desc; 51 struct i40e_filter_program_desc *fdir_desc;
@@ -68,8 +70,8 @@ int i40e_program_fdir_filter(struct i40e_fdir_data *fdir_data,
68 tx_ring = vsi->tx_rings[0]; 70 tx_ring = vsi->tx_rings[0];
69 dev = tx_ring->dev; 71 dev = tx_ring->dev;
70 72
71 dma = dma_map_single(dev, fdir_data->raw_packet, 73 dma = dma_map_single(dev, raw_packet,
72 I40E_FDIR_MAX_RAW_PACKET_LOOKUP, DMA_TO_DEVICE); 74 I40E_FDIR_MAX_RAW_PACKET_SIZE, DMA_TO_DEVICE);
73 if (dma_mapping_error(dev, dma)) 75 if (dma_mapping_error(dev, dma))
74 goto dma_fail; 76 goto dma_fail;
75 77
@@ -132,14 +134,14 @@ int i40e_program_fdir_filter(struct i40e_fdir_data *fdir_data,
132 tx_ring->next_to_use = (i + 1 < tx_ring->count) ? i + 1 : 0; 134 tx_ring->next_to_use = (i + 1 < tx_ring->count) ? i + 1 : 0;
133 135
134 /* record length, and DMA address */ 136 /* record length, and DMA address */
135 dma_unmap_len_set(tx_buf, len, I40E_FDIR_MAX_RAW_PACKET_LOOKUP); 137 dma_unmap_len_set(tx_buf, len, I40E_FDIR_MAX_RAW_PACKET_SIZE);
136 dma_unmap_addr_set(tx_buf, dma, dma); 138 dma_unmap_addr_set(tx_buf, dma, dma);
137 139
138 tx_desc->buffer_addr = cpu_to_le64(dma); 140 tx_desc->buffer_addr = cpu_to_le64(dma);
139 td_cmd = I40E_TXD_CMD | I40E_TX_DESC_CMD_DUMMY; 141 td_cmd = I40E_TXD_CMD | I40E_TX_DESC_CMD_DUMMY;
140 142
141 tx_desc->cmd_type_offset_bsz = 143 tx_desc->cmd_type_offset_bsz =
142 build_ctob(td_cmd, 0, I40E_FDIR_MAX_RAW_PACKET_LOOKUP, 0); 144 build_ctob(td_cmd, 0, I40E_FDIR_MAX_RAW_PACKET_SIZE, 0);
143 145
144 /* set the timestamp */ 146 /* set the timestamp */
145 tx_buf->time_stamp = jiffies; 147 tx_buf->time_stamp = jiffies;
@@ -161,26 +163,328 @@ dma_fail:
161 return -1; 163 return -1;
162} 164}
163 165
166#define IP_HEADER_OFFSET 14
167#define I40E_UDPIP_DUMMY_PACKET_LEN 42
168/**
169 * i40e_add_del_fdir_udpv4 - Add/Remove UDPv4 filters
170 * @vsi: pointer to the targeted VSI
171 * @fd_data: the flow director data required for the FDir descriptor
172 * @raw_packet: the pre-allocated packet buffer for FDir
173 * @add: true adds a filter, false removes it
174 *
175 * Returns 0 if the filters were successfully added or removed
176 **/
177static int i40e_add_del_fdir_udpv4(struct i40e_vsi *vsi,
178 struct i40e_fdir_filter *fd_data,
179 u8 *raw_packet, bool add)
180{
181 struct i40e_pf *pf = vsi->back;
182 struct udphdr *udp;
183 struct iphdr *ip;
184 bool err = false;
185 int ret;
186 int i;
187 static char packet[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x08, 0,
188 0x45, 0, 0, 0x1c, 0, 0, 0x40, 0, 0x40, 0x11, 0, 0, 0, 0, 0, 0,
189 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
190
191 memcpy(raw_packet, packet, I40E_UDPIP_DUMMY_PACKET_LEN);
192
193 ip = (struct iphdr *)(raw_packet + IP_HEADER_OFFSET);
194 udp = (struct udphdr *)(raw_packet + IP_HEADER_OFFSET
195 + sizeof(struct iphdr));
196
197 ip->daddr = fd_data->dst_ip[0];
198 udp->dest = fd_data->dst_port;
199 ip->saddr = fd_data->src_ip[0];
200 udp->source = fd_data->src_port;
201
202 for (i = I40E_FILTER_PCTYPE_NONF_UNICAST_IPV4_UDP;
203 i <= I40E_FILTER_PCTYPE_NONF_IPV4_UDP; i++) {
204 fd_data->pctype = i;
205 ret = i40e_program_fdir_filter(fd_data, raw_packet, pf, add);
206
207 if (ret) {
208 dev_info(&pf->pdev->dev,
209 "Filter command send failed for PCTYPE %d (ret = %d)\n",
210 fd_data->pctype, ret);
211 err = true;
212 } else {
213 dev_info(&pf->pdev->dev,
214 "Filter OK for PCTYPE %d (ret = %d)\n",
215 fd_data->pctype, ret);
216 }
217 }
218
219 return err ? -EOPNOTSUPP : 0;
220}
221
222#define I40E_TCPIP_DUMMY_PACKET_LEN 54
223/**
224 * i40e_add_del_fdir_tcpv4 - Add/Remove TCPv4 filters
225 * @vsi: pointer to the targeted VSI
226 * @fd_data: the flow director data required for the FDir descriptor
227 * @raw_packet: the pre-allocated packet buffer for FDir
228 * @add: true adds a filter, false removes it
229 *
230 * Returns 0 if the filters were successfully added or removed
231 **/
232static int i40e_add_del_fdir_tcpv4(struct i40e_vsi *vsi,
233 struct i40e_fdir_filter *fd_data,
234 u8 *raw_packet, bool add)
235{
236 struct i40e_pf *pf = vsi->back;
237 struct tcphdr *tcp;
238 struct iphdr *ip;
239 bool err = false;
240 int ret;
241 /* Dummy packet */
242 static char packet[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x08, 0,
243 0x45, 0, 0, 0x28, 0, 0, 0x40, 0, 0x40, 0x6, 0, 0, 0, 0, 0, 0,
244 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x80, 0x11,
245 0x0, 0x72, 0, 0, 0, 0};
246
247 memcpy(raw_packet, packet, I40E_TCPIP_DUMMY_PACKET_LEN);
248
249 ip = (struct iphdr *)(raw_packet + IP_HEADER_OFFSET);
250 tcp = (struct tcphdr *)(raw_packet + IP_HEADER_OFFSET
251 + sizeof(struct iphdr));
252
253 ip->daddr = fd_data->dst_ip[0];
254 tcp->dest = fd_data->dst_port;
255 ip->saddr = fd_data->src_ip[0];
256 tcp->source = fd_data->src_port;
257
258 if (add) {
259 if (pf->flags & I40E_FLAG_FD_ATR_ENABLED) {
260 dev_info(&pf->pdev->dev, "Forcing ATR off, sideband rules for TCP/IPv4 flow being applied\n");
261 pf->flags &= ~I40E_FLAG_FD_ATR_ENABLED;
262 }
263 }
264
265 fd_data->pctype = I40E_FILTER_PCTYPE_NONF_IPV4_TCP_SYN;
266 ret = i40e_program_fdir_filter(fd_data, raw_packet, pf, add);
267
268 if (ret) {
269 dev_info(&pf->pdev->dev,
270 "Filter command send failed for PCTYPE %d (ret = %d)\n",
271 fd_data->pctype, ret);
272 err = true;
273 } else {
274 dev_info(&pf->pdev->dev, "Filter OK for PCTYPE %d (ret = %d)\n",
275 fd_data->pctype, ret);
276 }
277
278 fd_data->pctype = I40E_FILTER_PCTYPE_NONF_IPV4_TCP;
279
280 ret = i40e_program_fdir_filter(fd_data, raw_packet, pf, add);
281 if (ret) {
282 dev_info(&pf->pdev->dev,
283 "Filter command send failed for PCTYPE %d (ret = %d)\n",
284 fd_data->pctype, ret);
285 err = true;
286 } else {
287 dev_info(&pf->pdev->dev, "Filter OK for PCTYPE %d (ret = %d)\n",
288 fd_data->pctype, ret);
289 }
290
291 return err ? -EOPNOTSUPP : 0;
292}
293
294/**
295 * i40e_add_del_fdir_sctpv4 - Add/Remove SCTPv4 Flow Director filters for
296 * a specific flow spec
297 * @vsi: pointer to the targeted VSI
298 * @fd_data: the flow director data required for the FDir descriptor
299 * @raw_packet: the pre-allocated packet buffer for FDir
300 * @add: true adds a filter, false removes it
301 *
302 * Returns 0 if the filters were successfully added or removed
303 **/
304static int i40e_add_del_fdir_sctpv4(struct i40e_vsi *vsi,
305 struct i40e_fdir_filter *fd_data,
306 u8 *raw_packet, bool add)
307{
308 return -EOPNOTSUPP;
309}
310
311#define I40E_IP_DUMMY_PACKET_LEN 34
312/**
313 * i40e_add_del_fdir_ipv4 - Add/Remove IPv4 Flow Director filters for
314 * a specific flow spec
315 * @vsi: pointer to the targeted VSI
316 * @fd_data: the flow director data required for the FDir descriptor
317 * @raw_packet: the pre-allocated packet buffer for FDir
318 * @add: true adds a filter, false removes it
319 *
320 * Returns 0 if the filters were successfully added or removed
321 **/
322static int i40e_add_del_fdir_ipv4(struct i40e_vsi *vsi,
323 struct i40e_fdir_filter *fd_data,
324 u8 *raw_packet, bool add)
325{
326 struct i40e_pf *pf = vsi->back;
327 struct iphdr *ip;
328 bool err = false;
329 int ret;
330 int i;
331 static char packet[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x08, 0,
332 0x45, 0, 0, 0x14, 0, 0, 0x40, 0, 0x40, 0x10, 0, 0, 0, 0, 0, 0,
333 0, 0, 0, 0};
334
335 memcpy(raw_packet, packet, I40E_IP_DUMMY_PACKET_LEN);
336 ip = (struct iphdr *)(raw_packet + IP_HEADER_OFFSET);
337
338 ip->saddr = fd_data->src_ip[0];
339 ip->daddr = fd_data->dst_ip[0];
340 ip->protocol = 0;
341
342 for (i = I40E_FILTER_PCTYPE_NONF_IPV4_OTHER;
343 i <= I40E_FILTER_PCTYPE_FRAG_IPV4; i++) {
344 fd_data->pctype = i;
345 ret = i40e_program_fdir_filter(fd_data, raw_packet, pf, add);
346
347 if (ret) {
348 dev_info(&pf->pdev->dev,
349 "Filter command send failed for PCTYPE %d (ret = %d)\n",
350 fd_data->pctype, ret);
351 err = true;
352 } else {
353 dev_info(&pf->pdev->dev,
354 "Filter OK for PCTYPE %d (ret = %d)\n",
355 fd_data->pctype, ret);
356 }
357 }
358
359 return err ? -EOPNOTSUPP : 0;
360}
361
362/**
363 * i40e_add_del_fdir - Build raw packets to add/del fdir filter
364 * @vsi: pointer to the targeted VSI
365 * @cmd: command to get or set RX flow classification rules
366 * @add: true adds a filter, false removes it
367 *
368 **/
369int i40e_add_del_fdir(struct i40e_vsi *vsi,
370 struct i40e_fdir_filter *input, bool add)
371{
372 struct i40e_pf *pf = vsi->back;
373 u8 *raw_packet;
374 int ret;
375
376 /* Populate the Flow Director that we have at the moment
377 * and allocate the raw packet buffer for the calling functions
378 */
379 raw_packet = kzalloc(I40E_FDIR_MAX_RAW_PACKET_SIZE, GFP_KERNEL);
380 if (!raw_packet)
381 return -ENOMEM;
382
383 switch (input->flow_type & ~FLOW_EXT) {
384 case TCP_V4_FLOW:
385 ret = i40e_add_del_fdir_tcpv4(vsi, input, raw_packet,
386 add);
387 break;
388 case UDP_V4_FLOW:
389 ret = i40e_add_del_fdir_udpv4(vsi, input, raw_packet,
390 add);
391 break;
392 case SCTP_V4_FLOW:
393 ret = i40e_add_del_fdir_sctpv4(vsi, input, raw_packet,
394 add);
395 break;
396 case IPV4_FLOW:
397 ret = i40e_add_del_fdir_ipv4(vsi, input, raw_packet,
398 add);
399 break;
400 case IP_USER_FLOW:
401 switch (input->ip4_proto) {
402 case IPPROTO_TCP:
403 ret = i40e_add_del_fdir_tcpv4(vsi, input,
404 raw_packet, add);
405 break;
406 case IPPROTO_UDP:
407 ret = i40e_add_del_fdir_udpv4(vsi, input,
408 raw_packet, add);
409 break;
410 case IPPROTO_SCTP:
411 ret = i40e_add_del_fdir_sctpv4(vsi, input,
412 raw_packet, add);
413 break;
414 default:
415 ret = i40e_add_del_fdir_ipv4(vsi, input,
416 raw_packet, add);
417 break;
418 }
419 break;
420 default:
421 dev_info(&pf->pdev->dev, "Could not specify spec type %d",
422 input->flow_type);
423 ret = -EINVAL;
424 }
425
426 kfree(raw_packet);
427 return ret;
428}
429
164/** 430/**
165 * i40e_fd_handle_status - check the Programming Status for FD 431 * i40e_fd_handle_status - check the Programming Status for FD
166 * @rx_ring: the Rx ring for this descriptor 432 * @rx_ring: the Rx ring for this descriptor
167 * @qw: the descriptor data 433 * @rx_desc: the Rx descriptor for programming Status, not a packet descriptor.
168 * @prog_id: the id originally used for programming 434 * @prog_id: the id originally used for programming
169 * 435 *
170 * This is used to verify if the FD programming or invalidation 436 * This is used to verify if the FD programming or invalidation
171 * requested by SW to the HW is successful or not and take actions accordingly. 437 * requested by SW to the HW is successful or not and take actions accordingly.
172 **/ 438 **/
173static void i40e_fd_handle_status(struct i40e_ring *rx_ring, u32 qw, u8 prog_id) 439static void i40e_fd_handle_status(struct i40e_ring *rx_ring,
440 union i40e_rx_desc *rx_desc, u8 prog_id)
174{ 441{
175 struct pci_dev *pdev = rx_ring->vsi->back->pdev; 442 struct i40e_pf *pf = rx_ring->vsi->back;
443 struct pci_dev *pdev = pf->pdev;
444 u32 fcnt_prog, fcnt_avail;
176 u32 error; 445 u32 error;
446 u64 qw;
177 447
448 qw = le64_to_cpu(rx_desc->wb.qword1.status_error_len);
178 error = (qw & I40E_RX_PROG_STATUS_DESC_QW1_ERROR_MASK) >> 449 error = (qw & I40E_RX_PROG_STATUS_DESC_QW1_ERROR_MASK) >>
179 I40E_RX_PROG_STATUS_DESC_QW1_ERROR_SHIFT; 450 I40E_RX_PROG_STATUS_DESC_QW1_ERROR_SHIFT;
180 451
181 /* for now just print the Status */ 452 if (error == (0x1 << I40E_RX_PROG_STATUS_DESC_FD_TBL_FULL_SHIFT)) {
182 dev_info(&pdev->dev, "FD programming id %02x, Status %08x\n", 453 dev_warn(&pdev->dev, "ntuple filter loc = %d, could not be added\n",
183 prog_id, error); 454 rx_desc->wb.qword0.hi_dword.fd_id);
455
456 /* filter programming failed most likely due to table full */
457 fcnt_prog = i40e_get_current_fd_count(pf);
458 fcnt_avail = pf->hw.fdir_shared_filter_count +
459 pf->fdir_pf_filter_count;
460
461 /* If ATR is running fcnt_prog can quickly change,
462 * if we are very close to full, it makes sense to disable
463 * FD ATR/SB and then re-enable it when there is room.
464 */
465 if (fcnt_prog >= (fcnt_avail - I40E_FDIR_BUFFER_FULL_MARGIN)) {
466 /* Turn off ATR first */
467 if (pf->flags | I40E_FLAG_FD_ATR_ENABLED) {
468 pf->flags &= ~I40E_FLAG_FD_ATR_ENABLED;
469 dev_warn(&pdev->dev, "FD filter space full, ATR for further flows will be turned off\n");
470 pf->auto_disable_flags |=
471 I40E_FLAG_FD_ATR_ENABLED;
472 pf->flags |= I40E_FLAG_FDIR_REQUIRES_REINIT;
473 } else if (pf->flags | I40E_FLAG_FD_SB_ENABLED) {
474 pf->flags &= ~I40E_FLAG_FD_SB_ENABLED;
475 dev_warn(&pdev->dev, "FD filter space full, new ntuple rules will not be added\n");
476 pf->auto_disable_flags |=
477 I40E_FLAG_FD_SB_ENABLED;
478 pf->flags |= I40E_FLAG_FDIR_REQUIRES_REINIT;
479 }
480 } else {
481 dev_info(&pdev->dev, "FD filter programming error");
482 }
483 } else if (error ==
484 (0x1 << I40E_RX_PROG_STATUS_DESC_NO_FD_ENTRY_SHIFT)) {
485 netdev_info(rx_ring->vsi->netdev, "ntuple filter loc = %d, could not be removed\n",
486 rx_desc->wb.qword0.hi_dword.fd_id);
487 }
184} 488}
185 489
186/** 490/**
@@ -315,6 +619,20 @@ static bool i40e_check_tx_hang(struct i40e_ring *tx_ring)
315} 619}
316 620
317/** 621/**
622 * i40e_get_head - Retrieve head from head writeback
623 * @tx_ring: tx ring to fetch head of
624 *
625 * Returns value of Tx ring head based on value stored
626 * in head write-back location
627 **/
628static inline u32 i40e_get_head(struct i40e_ring *tx_ring)
629{
630 void *head = (struct i40e_tx_desc *)tx_ring->desc + tx_ring->count;
631
632 return le32_to_cpu(*(volatile __le32 *)head);
633}
634
635/**
318 * i40e_clean_tx_irq - Reclaim resources after transmit completes 636 * i40e_clean_tx_irq - Reclaim resources after transmit completes
319 * @tx_ring: tx ring to clean 637 * @tx_ring: tx ring to clean
320 * @budget: how many cleans we're allowed 638 * @budget: how many cleans we're allowed
@@ -325,6 +643,7 @@ static bool i40e_clean_tx_irq(struct i40e_ring *tx_ring, int budget)
325{ 643{
326 u16 i = tx_ring->next_to_clean; 644 u16 i = tx_ring->next_to_clean;
327 struct i40e_tx_buffer *tx_buf; 645 struct i40e_tx_buffer *tx_buf;
646 struct i40e_tx_desc *tx_head;
328 struct i40e_tx_desc *tx_desc; 647 struct i40e_tx_desc *tx_desc;
329 unsigned int total_packets = 0; 648 unsigned int total_packets = 0;
330 unsigned int total_bytes = 0; 649 unsigned int total_bytes = 0;
@@ -333,6 +652,8 @@ static bool i40e_clean_tx_irq(struct i40e_ring *tx_ring, int budget)
333 tx_desc = I40E_TX_DESC(tx_ring, i); 652 tx_desc = I40E_TX_DESC(tx_ring, i);
334 i -= tx_ring->count; 653 i -= tx_ring->count;
335 654
655 tx_head = I40E_TX_DESC(tx_ring, i40e_get_head(tx_ring));
656
336 do { 657 do {
337 struct i40e_tx_desc *eop_desc = tx_buf->next_to_watch; 658 struct i40e_tx_desc *eop_desc = tx_buf->next_to_watch;
338 659
@@ -343,9 +664,8 @@ static bool i40e_clean_tx_irq(struct i40e_ring *tx_ring, int budget)
343 /* prevent any other reads prior to eop_desc */ 664 /* prevent any other reads prior to eop_desc */
344 read_barrier_depends(); 665 read_barrier_depends();
345 666
346 /* if the descriptor isn't done, no work yet to do */ 667 /* we have caught up to head, no work left to do */
347 if (!(eop_desc->cmd_type_offset_bsz & 668 if (tx_head == tx_desc)
348 cpu_to_le64(I40E_TX_DESC_DTYPE_DESC_DONE)))
349 break; 669 break;
350 670
351 /* clear next_to_watch to prevent false hangs */ 671 /* clear next_to_watch to prevent false hangs */
@@ -577,7 +897,7 @@ static void i40e_clean_programming_status(struct i40e_ring *rx_ring,
577 I40E_RX_PROG_STATUS_DESC_QW1_PROGID_SHIFT; 897 I40E_RX_PROG_STATUS_DESC_QW1_PROGID_SHIFT;
578 898
579 if (id == I40E_RX_PROG_STATUS_DESC_FD_FILTER_STATUS) 899 if (id == I40E_RX_PROG_STATUS_DESC_FD_FILTER_STATUS)
580 i40e_fd_handle_status(rx_ring, qw, id); 900 i40e_fd_handle_status(rx_ring, rx_desc, id);
581} 901}
582 902
583/** 903/**
@@ -601,6 +921,10 @@ int i40e_setup_tx_descriptors(struct i40e_ring *tx_ring)
601 921
602 /* round up to nearest 4K */ 922 /* round up to nearest 4K */
603 tx_ring->size = tx_ring->count * sizeof(struct i40e_tx_desc); 923 tx_ring->size = tx_ring->count * sizeof(struct i40e_tx_desc);
924 /* add u32 for head writeback, align after this takes care of
925 * guaranteeing this is at least one cache line in size
926 */
927 tx_ring->size += sizeof(u32);
604 tx_ring->size = ALIGN(tx_ring->size, 4096); 928 tx_ring->size = ALIGN(tx_ring->size, 4096);
605 tx_ring->desc = dma_alloc_coherent(dev, tx_ring->size, 929 tx_ring->desc = dma_alloc_coherent(dev, tx_ring->size,
606 &tx_ring->dma, GFP_KERNEL); 930 &tx_ring->dma, GFP_KERNEL);
@@ -892,7 +1216,7 @@ static inline void i40e_rx_checksum(struct i40e_vsi *vsi,
892 rx_status & (1 << I40E_RX_DESC_STATUS_L3L4P_SHIFT))) 1216 rx_status & (1 << I40E_RX_DESC_STATUS_L3L4P_SHIFT)))
893 return; 1217 return;
894 1218
895 /* likely incorrect csum if alternate IP extention headers found */ 1219 /* likely incorrect csum if alternate IP extension headers found */
896 if (rx_status & (1 << I40E_RX_DESC_STATUS_IPV6EXADD_SHIFT)) 1220 if (rx_status & (1 << I40E_RX_DESC_STATUS_IPV6EXADD_SHIFT))
897 return; 1221 return;
898 1222
@@ -956,6 +1280,29 @@ static inline u32 i40e_rx_hash(struct i40e_ring *ring,
956} 1280}
957 1281
958/** 1282/**
1283 * i40e_ptype_to_hash - get a hash type
1284 * @ptype: the ptype value from the descriptor
1285 *
1286 * Returns a hash type to be used by skb_set_hash
1287 **/
1288static inline enum pkt_hash_types i40e_ptype_to_hash(u8 ptype)
1289{
1290 struct i40e_rx_ptype_decoded decoded = decode_rx_desc_ptype(ptype);
1291
1292 if (!decoded.known)
1293 return PKT_HASH_TYPE_NONE;
1294
1295 if (decoded.outer_ip == I40E_RX_PTYPE_OUTER_IP &&
1296 decoded.payload_layer == I40E_RX_PTYPE_PAYLOAD_LAYER_PAY4)
1297 return PKT_HASH_TYPE_L4;
1298 else if (decoded.outer_ip == I40E_RX_PTYPE_OUTER_IP &&
1299 decoded.payload_layer == I40E_RX_PTYPE_PAYLOAD_LAYER_PAY3)
1300 return PKT_HASH_TYPE_L3;
1301 else
1302 return PKT_HASH_TYPE_L2;
1303}
1304
1305/**
959 * i40e_clean_rx_irq - Reclaim resources after receive completes 1306 * i40e_clean_rx_irq - Reclaim resources after receive completes
960 * @rx_ring: rx ring to clean 1307 * @rx_ring: rx ring to clean
961 * @budget: how many cleans we're allowed 1308 * @budget: how many cleans we're allowed
@@ -972,8 +1319,11 @@ static int i40e_clean_rx_irq(struct i40e_ring *rx_ring, int budget)
972 u16 i = rx_ring->next_to_clean; 1319 u16 i = rx_ring->next_to_clean;
973 union i40e_rx_desc *rx_desc; 1320 union i40e_rx_desc *rx_desc;
974 u32 rx_error, rx_status; 1321 u32 rx_error, rx_status;
1322 u8 rx_ptype;
975 u64 qword; 1323 u64 qword;
976 u16 rx_ptype; 1324
1325 if (budget <= 0)
1326 return 0;
977 1327
978 rx_desc = I40E_RX_DESC(rx_ring, i); 1328 rx_desc = I40E_RX_DESC(rx_ring, i);
979 qword = le64_to_cpu(rx_desc->wb.qword1.status_error_len); 1329 qword = le64_to_cpu(rx_desc->wb.qword1.status_error_len);
@@ -1087,7 +1437,8 @@ static int i40e_clean_rx_irq(struct i40e_ring *rx_ring, int budget)
1087 goto next_desc; 1437 goto next_desc;
1088 } 1438 }
1089 1439
1090 skb->rxhash = i40e_rx_hash(rx_ring, rx_desc); 1440 skb_set_hash(skb, i40e_rx_hash(rx_ring, rx_desc),
1441 i40e_ptype_to_hash(rx_ptype));
1091 if (unlikely(rx_status & I40E_RXD_QW1_STATUS_TSYNVALID_MASK)) { 1442 if (unlikely(rx_status & I40E_RXD_QW1_STATUS_TSYNVALID_MASK)) {
1092 i40e_ptp_rx_hwtstamp(vsi->back, skb, (rx_status & 1443 i40e_ptp_rx_hwtstamp(vsi->back, skb, (rx_status &
1093 I40E_RXD_QW1_STATUS_TSYNINDX_MASK) >> 1444 I40E_RXD_QW1_STATUS_TSYNINDX_MASK) >>
@@ -1246,8 +1597,6 @@ static void i40e_atr(struct i40e_ring *tx_ring, struct sk_buff *skb,
1246 if (!tx_ring->atr_sample_rate) 1597 if (!tx_ring->atr_sample_rate)
1247 return; 1598 return;
1248 1599
1249 tx_ring->atr_count++;
1250
1251 /* snag network header to get L4 type and address */ 1600 /* snag network header to get L4 type and address */
1252 hdr.network = skb_network_header(skb); 1601 hdr.network = skb_network_header(skb);
1253 1602
@@ -1269,6 +1618,12 @@ static void i40e_atr(struct i40e_ring *tx_ring, struct sk_buff *skb,
1269 1618
1270 th = (struct tcphdr *)(hdr.network + hlen); 1619 th = (struct tcphdr *)(hdr.network + hlen);
1271 1620
1621 /* Due to lack of space, no more new filters can be programmed */
1622 if (th->syn && (pf->auto_disable_flags & I40E_FLAG_FD_ATR_ENABLED))
1623 return;
1624
1625 tx_ring->atr_count++;
1626
1272 /* sample on all syn/fin packets or once every atr sample rate */ 1627 /* sample on all syn/fin packets or once every atr sample rate */
1273 if (!th->fin && !th->syn && (tx_ring->atr_count < tx_ring->atr_sample_rate)) 1628 if (!th->fin && !th->syn && (tx_ring->atr_count < tx_ring->atr_sample_rate))
1274 return; 1629 return;
@@ -1596,7 +1951,8 @@ static void i40e_create_tx_ctx(struct i40e_ring *tx_ring,
1596 struct i40e_tx_context_desc *context_desc; 1951 struct i40e_tx_context_desc *context_desc;
1597 int i = tx_ring->next_to_use; 1952 int i = tx_ring->next_to_use;
1598 1953
1599 if (!cd_type_cmd_tso_mss && !cd_tunneling && !cd_l2tag2) 1954 if ((cd_type_cmd_tso_mss == I40E_TX_DESC_DTYPE_CONTEXT) &&
1955 !cd_tunneling && !cd_l2tag2)
1600 return; 1956 return;
1601 1957
1602 /* grab the next descriptor */ 1958 /* grab the next descriptor */
@@ -1707,9 +2063,23 @@ static void i40e_tx_map(struct i40e_ring *tx_ring, struct sk_buff *skb,
1707 tx_bi = &tx_ring->tx_bi[i]; 2063 tx_bi = &tx_ring->tx_bi[i];
1708 } 2064 }
1709 2065
1710 tx_desc->cmd_type_offset_bsz = 2066 /* Place RS bit on last descriptor of any packet that spans across the
1711 build_ctob(td_cmd, td_offset, size, td_tag) | 2067 * 4th descriptor (WB_STRIDE aka 0x3) in a 64B cacheline.
1712 cpu_to_le64((u64)I40E_TXD_CMD << I40E_TXD_QW1_CMD_SHIFT); 2068 */
2069#define WB_STRIDE 0x3
2070 if (((i & WB_STRIDE) != WB_STRIDE) &&
2071 (first <= &tx_ring->tx_bi[i]) &&
2072 (first >= &tx_ring->tx_bi[i & ~WB_STRIDE])) {
2073 tx_desc->cmd_type_offset_bsz =
2074 build_ctob(td_cmd, td_offset, size, td_tag) |
2075 cpu_to_le64((u64)I40E_TX_DESC_CMD_EOP <<
2076 I40E_TXD_QW1_CMD_SHIFT);
2077 } else {
2078 tx_desc->cmd_type_offset_bsz =
2079 build_ctob(td_cmd, td_offset, size, td_tag) |
2080 cpu_to_le64((u64)I40E_TXD_CMD <<
2081 I40E_TXD_QW1_CMD_SHIFT);
2082 }
1713 2083
1714 netdev_tx_sent_queue(netdev_get_tx_queue(tx_ring->netdev, 2084 netdev_tx_sent_queue(netdev_get_tx_queue(tx_ring->netdev,
1715 tx_ring->queue_index), 2085 tx_ring->queue_index),
@@ -1812,7 +2182,7 @@ static int i40e_xmit_descriptor_count(struct sk_buff *skb,
1812 2182
1813 /* need: 1 descriptor per page * PAGE_SIZE/I40E_MAX_DATA_PER_TXD, 2183 /* need: 1 descriptor per page * PAGE_SIZE/I40E_MAX_DATA_PER_TXD,
1814 * + 1 desc for skb_head_len/I40E_MAX_DATA_PER_TXD, 2184 * + 1 desc for skb_head_len/I40E_MAX_DATA_PER_TXD,
1815 * + 2 desc gap to keep tail from touching head, 2185 * + 4 desc gap to avoid the cache line where head is,
1816 * + 1 desc for context descriptor, 2186 * + 1 desc for context descriptor,
1817 * otherwise try next time 2187 * otherwise try next time
1818 */ 2188 */
@@ -1823,7 +2193,7 @@ static int i40e_xmit_descriptor_count(struct sk_buff *skb,
1823 count += skb_shinfo(skb)->nr_frags; 2193 count += skb_shinfo(skb)->nr_frags;
1824#endif 2194#endif
1825 count += TXD_USE_COUNT(skb_headlen(skb)); 2195 count += TXD_USE_COUNT(skb_headlen(skb));
1826 if (i40e_maybe_stop_tx(tx_ring, count + 3)) { 2196 if (i40e_maybe_stop_tx(tx_ring, count + 4 + 1)) {
1827 tx_ring->tx_stats.tx_busy++; 2197 tx_ring->tx_stats.tx_busy++;
1828 return 0; 2198 return 0;
1829 } 2199 }
diff --git a/drivers/net/ethernet/intel/i40e/i40e_type.h b/drivers/net/ethernet/intel/i40e/i40e_type.h
index 181a825d3160..d2f0b95fd0d7 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_type.h
+++ b/drivers/net/ethernet/intel/i40e/i40e_type.h
@@ -458,6 +458,10 @@ union i40e_32byte_rx_desc {
458 union { 458 union {
459 __le32 rss; /* RSS Hash */ 459 __le32 rss; /* RSS Hash */
460 __le32 fcoe_param; /* FCoE DDP Context id */ 460 __le32 fcoe_param; /* FCoE DDP Context id */
461 /* Flow director filter id in case of
462 * Programming status desc WB
463 */
464 __le32 fd_id;
461 } hi_dword; 465 } hi_dword;
462 } qword0; 466 } qword0;
463 struct { 467 struct {
@@ -698,7 +702,7 @@ enum i40e_rx_prog_status_desc_prog_id_masks {
698enum i40e_rx_prog_status_desc_error_bits { 702enum i40e_rx_prog_status_desc_error_bits {
699 /* Note: These are predefined bit offsets */ 703 /* Note: These are predefined bit offsets */
700 I40E_RX_PROG_STATUS_DESC_FD_TBL_FULL_SHIFT = 0, 704 I40E_RX_PROG_STATUS_DESC_FD_TBL_FULL_SHIFT = 0,
701 I40E_RX_PROG_STATUS_DESC_NO_FD_QUOTA_SHIFT = 1, 705 I40E_RX_PROG_STATUS_DESC_NO_FD_ENTRY_SHIFT = 1,
702 I40E_RX_PROG_STATUS_DESC_FCOE_TBL_FULL_SHIFT = 2, 706 I40E_RX_PROG_STATUS_DESC_FCOE_TBL_FULL_SHIFT = 2,
703 I40E_RX_PROG_STATUS_DESC_FCOE_CONFLICT_SHIFT = 3 707 I40E_RX_PROG_STATUS_DESC_FCOE_CONFLICT_SHIFT = 3
704}; 708};
@@ -1010,6 +1014,11 @@ struct i40e_hw_port_stats {
1010 u64 tx_size_big; /* ptc9522 */ 1014 u64 tx_size_big; /* ptc9522 */
1011 u64 mac_short_packet_dropped; /* mspdc */ 1015 u64 mac_short_packet_dropped; /* mspdc */
1012 u64 checksum_error; /* xec */ 1016 u64 checksum_error; /* xec */
1017 /* EEE LPI */
1018 bool tx_lpi_status;
1019 bool rx_lpi_status;
1020 u64 tx_lpi_count; /* etlpic */
1021 u64 rx_lpi_count; /* erlpic */
1013}; 1022};
1014 1023
1015/* Checksum and Shadow RAM pointers */ 1024/* Checksum and Shadow RAM pointers */
diff --git a/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c b/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c
index b9d1c1c8ca5a..02c11a7f7d29 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c
@@ -69,7 +69,7 @@ static inline bool i40e_vc_isvalid_vector_id(struct i40e_vf *vf, u8 vector_id)
69{ 69{
70 struct i40e_pf *pf = vf->pf; 70 struct i40e_pf *pf = vf->pf;
71 71
72 return vector_id <= pf->hw.func_caps.num_msix_vectors_vf; 72 return vector_id < pf->hw.func_caps.num_msix_vectors_vf;
73} 73}
74 74
75/***********************vf resource mgmt routines*****************/ 75/***********************vf resource mgmt routines*****************/
@@ -126,8 +126,8 @@ static void i40e_config_irq_link_list(struct i40e_vf *vf, u16 vsi_idx,
126 reg_idx = I40E_VPINT_LNKLST0(vf->vf_id); 126 reg_idx = I40E_VPINT_LNKLST0(vf->vf_id);
127 else 127 else
128 reg_idx = I40E_VPINT_LNKLSTN( 128 reg_idx = I40E_VPINT_LNKLSTN(
129 (pf->hw.func_caps.num_msix_vectors_vf 129 ((pf->hw.func_caps.num_msix_vectors_vf - 1) * vf->vf_id) +
130 * vf->vf_id) + (vector_id - 1)); 130 (vector_id - 1));
131 131
132 if (vecmap->rxq_map == 0 && vecmap->txq_map == 0) { 132 if (vecmap->rxq_map == 0 && vecmap->txq_map == 0) {
133 /* Special case - No queues mapped on this vector */ 133 /* Special case - No queues mapped on this vector */
@@ -230,6 +230,9 @@ static int i40e_config_vsi_tx_queue(struct i40e_vf *vf, u16 vsi_idx,
230 tx_ctx.qlen = info->ring_len; 230 tx_ctx.qlen = info->ring_len;
231 tx_ctx.rdylist = le16_to_cpu(pf->vsi[vsi_idx]->info.qs_handle[0]); 231 tx_ctx.rdylist = le16_to_cpu(pf->vsi[vsi_idx]->info.qs_handle[0]);
232 tx_ctx.rdylist_act = 0; 232 tx_ctx.rdylist_act = 0;
233 tx_ctx.head_wb_ena = 1;
234 tx_ctx.head_wb_addr = info->dma_ring_addr +
235 (info->ring_len * sizeof(struct i40e_tx_desc));
233 236
234 /* clear the context in the HMC */ 237 /* clear the context in the HMC */
235 ret = i40e_clear_lan_tx_queue_context(hw, pf_queue_id); 238 ret = i40e_clear_lan_tx_queue_context(hw, pf_queue_id);
@@ -408,18 +411,10 @@ static int i40e_alloc_vsi_res(struct i40e_vf *vf, enum i40e_vsi_type type)
408 "Could not allocate VF broadcast filter\n"); 411 "Could not allocate VF broadcast filter\n");
409 } 412 }
410 413
411 if (!f) {
412 dev_err(&pf->pdev->dev, "Unable to add ucast filter\n");
413 ret = -ENOMEM;
414 goto error_alloc_vsi_res;
415 }
416
417 /* program mac filter */ 414 /* program mac filter */
418 ret = i40e_sync_vsi_filters(vsi); 415 ret = i40e_sync_vsi_filters(vsi);
419 if (ret) { 416 if (ret)
420 dev_err(&pf->pdev->dev, "Unable to program ucast filters\n"); 417 dev_err(&pf->pdev->dev, "Unable to program ucast filters\n");
421 goto error_alloc_vsi_res;
422 }
423 418
424error_alloc_vsi_res: 419error_alloc_vsi_res:
425 return ret; 420 return ret;
@@ -514,7 +509,8 @@ static void i40e_free_vf_res(struct i40e_vf *vf)
514 vf->lan_vsi_index = 0; 509 vf->lan_vsi_index = 0;
515 vf->lan_vsi_id = 0; 510 vf->lan_vsi_id = 0;
516 } 511 }
517 msix_vf = pf->hw.func_caps.num_msix_vectors_vf + 1; 512 msix_vf = pf->hw.func_caps.num_msix_vectors_vf;
513
518 /* disable interrupts so the VF starts in a known state */ 514 /* disable interrupts so the VF starts in a known state */
519 for (i = 0; i < msix_vf; i++) { 515 for (i = 0; i < msix_vf; i++) {
520 /* format is same for both registers */ 516 /* format is same for both registers */
@@ -679,9 +675,9 @@ void i40e_reset_vf(struct i40e_vf *vf, bool flr)
679complete_reset: 675complete_reset:
680 /* reallocate vf resources to reset the VSI state */ 676 /* reallocate vf resources to reset the VSI state */
681 i40e_free_vf_res(vf); 677 i40e_free_vf_res(vf);
682 mdelay(10);
683 i40e_alloc_vf_res(vf); 678 i40e_alloc_vf_res(vf);
684 i40e_enable_vf_mappings(vf); 679 i40e_enable_vf_mappings(vf);
680 set_bit(I40E_VF_STAT_ACTIVE, &vf->vf_states);
685 681
686 /* tell the VF the reset is done */ 682 /* tell the VF the reset is done */
687 wr32(hw, I40E_VFGEN_RSTAT1(vf->vf_id), I40E_VFR_VFACTIVE); 683 wr32(hw, I40E_VFGEN_RSTAT1(vf->vf_id), I40E_VFR_VFACTIVE);
@@ -847,7 +843,7 @@ void i40e_free_vfs(struct i40e_pf *pf)
847 * 843 *
848 * allocate vf resources 844 * allocate vf resources
849 **/ 845 **/
850static int i40e_alloc_vfs(struct i40e_pf *pf, u16 num_alloc_vfs) 846int i40e_alloc_vfs(struct i40e_pf *pf, u16 num_alloc_vfs)
851{ 847{
852 struct i40e_vf *vfs; 848 struct i40e_vf *vfs;
853 int i, ret = 0; 849 int i, ret = 0;
@@ -855,16 +851,18 @@ static int i40e_alloc_vfs(struct i40e_pf *pf, u16 num_alloc_vfs)
855 /* Disable interrupt 0 so we don't try to handle the VFLR. */ 851 /* Disable interrupt 0 so we don't try to handle the VFLR. */
856 i40e_irq_dynamic_disable_icr0(pf); 852 i40e_irq_dynamic_disable_icr0(pf);
857 853
858 ret = pci_enable_sriov(pf->pdev, num_alloc_vfs); 854 /* Check to see if we're just allocating resources for extant VFs */
859 if (ret) { 855 if (pci_num_vf(pf->pdev) != num_alloc_vfs) {
860 dev_err(&pf->pdev->dev, 856 ret = pci_enable_sriov(pf->pdev, num_alloc_vfs);
861 "pci_enable_sriov failed with error %d!\n", ret); 857 if (ret) {
862 pf->num_alloc_vfs = 0; 858 dev_err(&pf->pdev->dev,
863 goto err_iov; 859 "Failed to enable SR-IOV, error %d.\n", ret);
860 pf->num_alloc_vfs = 0;
861 goto err_iov;
862 }
864 } 863 }
865
866 /* allocate memory */ 864 /* allocate memory */
867 vfs = kzalloc(num_alloc_vfs * sizeof(struct i40e_vf), GFP_KERNEL); 865 vfs = kcalloc(num_alloc_vfs, sizeof(struct i40e_vf), GFP_KERNEL);
868 if (!vfs) { 866 if (!vfs) {
869 ret = -ENOMEM; 867 ret = -ENOMEM;
870 goto err_alloc; 868 goto err_alloc;
@@ -1776,7 +1774,7 @@ int i40e_vc_process_vf_msg(struct i40e_pf *pf, u16 vf_id, u32 v_opcode,
1776 u32 v_retval, u8 *msg, u16 msglen) 1774 u32 v_retval, u8 *msg, u16 msglen)
1777{ 1775{
1778 struct i40e_hw *hw = &pf->hw; 1776 struct i40e_hw *hw = &pf->hw;
1779 int local_vf_id = vf_id - hw->func_caps.vf_base_id; 1777 unsigned int local_vf_id = vf_id - hw->func_caps.vf_base_id;
1780 struct i40e_vf *vf; 1778 struct i40e_vf *vf;
1781 int ret; 1779 int ret;
1782 1780
@@ -1873,7 +1871,8 @@ int i40e_vc_process_vflr_event(struct i40e_pf *pf)
1873 /* clear the bit in GLGEN_VFLRSTAT */ 1871 /* clear the bit in GLGEN_VFLRSTAT */
1874 wr32(hw, I40E_GLGEN_VFLRSTAT(reg_idx), (1 << bit_idx)); 1872 wr32(hw, I40E_GLGEN_VFLRSTAT(reg_idx), (1 << bit_idx));
1875 1873
1876 i40e_reset_vf(vf, true); 1874 if (!test_bit(__I40E_DOWN, &pf->state))
1875 i40e_reset_vf(vf, true);
1877 } 1876 }
1878 } 1877 }
1879 1878
@@ -1924,15 +1923,28 @@ static void i40e_vc_vf_broadcast(struct i40e_pf *pf,
1924void i40e_vc_notify_link_state(struct i40e_pf *pf) 1923void i40e_vc_notify_link_state(struct i40e_pf *pf)
1925{ 1924{
1926 struct i40e_virtchnl_pf_event pfe; 1925 struct i40e_virtchnl_pf_event pfe;
1926 struct i40e_hw *hw = &pf->hw;
1927 struct i40e_vf *vf = pf->vf;
1928 struct i40e_link_status *ls = &pf->hw.phy.link_info;
1929 int i;
1927 1930
1928 pfe.event = I40E_VIRTCHNL_EVENT_LINK_CHANGE; 1931 pfe.event = I40E_VIRTCHNL_EVENT_LINK_CHANGE;
1929 pfe.severity = I40E_PF_EVENT_SEVERITY_INFO; 1932 pfe.severity = I40E_PF_EVENT_SEVERITY_INFO;
1930 pfe.event_data.link_event.link_status = 1933 for (i = 0; i < pf->num_alloc_vfs; i++) {
1931 pf->hw.phy.link_info.link_info & I40E_AQ_LINK_UP; 1934 if (vf->link_forced) {
1932 pfe.event_data.link_event.link_speed = pf->hw.phy.link_info.link_speed; 1935 pfe.event_data.link_event.link_status = vf->link_up;
1933 1936 pfe.event_data.link_event.link_speed =
1934 i40e_vc_vf_broadcast(pf, I40E_VIRTCHNL_OP_EVENT, I40E_SUCCESS, 1937 (vf->link_up ? I40E_LINK_SPEED_40GB : 0);
1935 (u8 *)&pfe, sizeof(struct i40e_virtchnl_pf_event)); 1938 } else {
1939 pfe.event_data.link_event.link_status =
1940 ls->link_info & I40E_AQ_LINK_UP;
1941 pfe.event_data.link_event.link_speed = ls->link_speed;
1942 }
1943 i40e_aq_send_msg_to_vf(hw, vf->vf_id, I40E_VIRTCHNL_OP_EVENT,
1944 0, (u8 *)&pfe, sizeof(pfe),
1945 NULL);
1946 vf++;
1947 }
1936} 1948}
1937 1949
1938/** 1950/**
@@ -2197,3 +2209,64 @@ int i40e_ndo_get_vf_config(struct net_device *netdev,
2197error_param: 2209error_param:
2198 return ret; 2210 return ret;
2199} 2211}
2212
2213/**
2214 * i40e_ndo_set_vf_link_state
2215 * @netdev: network interface device structure
2216 * @vf_id: vf identifier
2217 * @link: required link state
2218 *
2219 * Set the link state of a specified VF, regardless of physical link state
2220 **/
2221int i40e_ndo_set_vf_link_state(struct net_device *netdev, int vf_id, int link)
2222{
2223 struct i40e_netdev_priv *np = netdev_priv(netdev);
2224 struct i40e_pf *pf = np->vsi->back;
2225 struct i40e_virtchnl_pf_event pfe;
2226 struct i40e_hw *hw = &pf->hw;
2227 struct i40e_vf *vf;
2228 int ret = 0;
2229
2230 /* validate the request */
2231 if (vf_id >= pf->num_alloc_vfs) {
2232 dev_err(&pf->pdev->dev, "Invalid VF Identifier %d\n", vf_id);
2233 ret = -EINVAL;
2234 goto error_out;
2235 }
2236
2237 vf = &pf->vf[vf_id];
2238
2239 pfe.event = I40E_VIRTCHNL_EVENT_LINK_CHANGE;
2240 pfe.severity = I40E_PF_EVENT_SEVERITY_INFO;
2241
2242 switch (link) {
2243 case IFLA_VF_LINK_STATE_AUTO:
2244 vf->link_forced = false;
2245 pfe.event_data.link_event.link_status =
2246 pf->hw.phy.link_info.link_info & I40E_AQ_LINK_UP;
2247 pfe.event_data.link_event.link_speed =
2248 pf->hw.phy.link_info.link_speed;
2249 break;
2250 case IFLA_VF_LINK_STATE_ENABLE:
2251 vf->link_forced = true;
2252 vf->link_up = true;
2253 pfe.event_data.link_event.link_status = true;
2254 pfe.event_data.link_event.link_speed = I40E_LINK_SPEED_40GB;
2255 break;
2256 case IFLA_VF_LINK_STATE_DISABLE:
2257 vf->link_forced = true;
2258 vf->link_up = false;
2259 pfe.event_data.link_event.link_status = false;
2260 pfe.event_data.link_event.link_speed = 0;
2261 break;
2262 default:
2263 ret = -EINVAL;
2264 goto error_out;
2265 }
2266 /* Notify the VF of its new link state */
2267 i40e_aq_send_msg_to_vf(hw, vf->vf_id, I40E_VIRTCHNL_OP_EVENT,
2268 0, (u8 *)&pfe, sizeof(pfe), NULL);
2269
2270error_out:
2271 return ret;
2272}
diff --git a/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.h b/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.h
index cc1feee36e12..389c47f396d5 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.h
+++ b/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.h
@@ -98,10 +98,13 @@ struct i40e_vf {
98 98
99 unsigned long vf_caps; /* vf's adv. capabilities */ 99 unsigned long vf_caps; /* vf's adv. capabilities */
100 unsigned long vf_states; /* vf's runtime states */ 100 unsigned long vf_states; /* vf's runtime states */
101 bool link_forced;
102 bool link_up; /* only valid if vf link is forced */
101}; 103};
102 104
103void i40e_free_vfs(struct i40e_pf *pf); 105void i40e_free_vfs(struct i40e_pf *pf);
104int i40e_pci_sriov_configure(struct pci_dev *dev, int num_vfs); 106int i40e_pci_sriov_configure(struct pci_dev *dev, int num_vfs);
107int i40e_alloc_vfs(struct i40e_pf *pf, u16 num_alloc_vfs);
105int i40e_vc_process_vf_msg(struct i40e_pf *pf, u16 vf_id, u32 v_opcode, 108int i40e_vc_process_vf_msg(struct i40e_pf *pf, u16 vf_id, u32 v_opcode,
106 u32 v_retval, u8 *msg, u16 msglen); 109 u32 v_retval, u8 *msg, u16 msglen);
107int i40e_vc_process_vflr_event(struct i40e_pf *pf); 110int i40e_vc_process_vflr_event(struct i40e_pf *pf);
@@ -115,6 +118,8 @@ int i40e_ndo_set_vf_port_vlan(struct net_device *netdev,
115int i40e_ndo_set_vf_bw(struct net_device *netdev, int vf_id, int tx_rate); 118int i40e_ndo_set_vf_bw(struct net_device *netdev, int vf_id, int tx_rate);
116int i40e_ndo_get_vf_config(struct net_device *netdev, 119int i40e_ndo_get_vf_config(struct net_device *netdev,
117 int vf_id, struct ifla_vf_info *ivi); 120 int vf_id, struct ifla_vf_info *ivi);
121int i40e_ndo_set_vf_link_state(struct net_device *netdev, int vf_id, int link);
122
118void i40e_vc_notify_link_state(struct i40e_pf *pf); 123void i40e_vc_notify_link_state(struct i40e_pf *pf);
119void i40e_vc_notify_reset(struct i40e_pf *pf); 124void i40e_vc_notify_reset(struct i40e_pf *pf);
120 125
diff --git a/drivers/net/ethernet/intel/i40evf/i40e_adminq_cmd.h b/drivers/net/ethernet/intel/i40evf/i40e_adminq_cmd.h
index f7cea1bca38d..97662b6bd98a 100644
--- a/drivers/net/ethernet/intel/i40evf/i40e_adminq_cmd.h
+++ b/drivers/net/ethernet/intel/i40evf/i40e_adminq_cmd.h
@@ -1229,7 +1229,7 @@ struct i40e_aqc_add_remove_cloud_filters_element_data {
1229#define I40E_AQC_ADD_CLOUD_TNL_TYPE_NGE 2 1229#define I40E_AQC_ADD_CLOUD_TNL_TYPE_NGE 2
1230#define I40E_AQC_ADD_CLOUD_TNL_TYPE_IP 3 1230#define I40E_AQC_ADD_CLOUD_TNL_TYPE_IP 3
1231 1231
1232 __le32 tenant_id ; 1232 __le32 tenant_id;
1233 u8 reserved[4]; 1233 u8 reserved[4];
1234 __le16 queue_number; 1234 __le16 queue_number;
1235#define I40E_AQC_ADD_CLOUD_QUEUE_SHIFT 0 1235#define I40E_AQC_ADD_CLOUD_QUEUE_SHIFT 0
diff --git a/drivers/net/ethernet/intel/i40evf/i40e_common.c b/drivers/net/ethernet/intel/i40evf/i40e_common.c
index 7b13953b28c4..c688a0fc5c29 100644
--- a/drivers/net/ethernet/intel/i40evf/i40e_common.c
+++ b/drivers/net/ethernet/intel/i40evf/i40e_common.c
@@ -160,6 +160,372 @@ i40e_status i40evf_aq_queue_shutdown(struct i40e_hw *hw,
160} 160}
161 161
162 162
163/* The i40evf_ptype_lookup table is used to convert from the 8-bit ptype in the
164 * hardware to a bit-field that can be used by SW to more easily determine the
165 * packet type.
166 *
167 * Macros are used to shorten the table lines and make this table human
168 * readable.
169 *
170 * We store the PTYPE in the top byte of the bit field - this is just so that
171 * we can check that the table doesn't have a row missing, as the index into
172 * the table should be the PTYPE.
173 *
174 * Typical work flow:
175 *
176 * IF NOT i40evf_ptype_lookup[ptype].known
177 * THEN
178 * Packet is unknown
179 * ELSE IF i40evf_ptype_lookup[ptype].outer_ip == I40E_RX_PTYPE_OUTER_IP
180 * Use the rest of the fields to look at the tunnels, inner protocols, etc
181 * ELSE
182 * Use the enum i40e_rx_l2_ptype to decode the packet type
183 * ENDIF
184 */
185
186/* macro to make the table lines short */
187#define I40E_PTT(PTYPE, OUTER_IP, OUTER_IP_VER, OUTER_FRAG, T, TE, TEF, I, PL)\
188 { PTYPE, \
189 1, \
190 I40E_RX_PTYPE_OUTER_##OUTER_IP, \
191 I40E_RX_PTYPE_OUTER_##OUTER_IP_VER, \
192 I40E_RX_PTYPE_##OUTER_FRAG, \
193 I40E_RX_PTYPE_TUNNEL_##T, \
194 I40E_RX_PTYPE_TUNNEL_END_##TE, \
195 I40E_RX_PTYPE_##TEF, \
196 I40E_RX_PTYPE_INNER_PROT_##I, \
197 I40E_RX_PTYPE_PAYLOAD_LAYER_##PL }
198
199#define I40E_PTT_UNUSED_ENTRY(PTYPE) \
200 { PTYPE, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
201
202/* shorter macros makes the table fit but are terse */
203#define I40E_RX_PTYPE_NOF I40E_RX_PTYPE_NOT_FRAG
204#define I40E_RX_PTYPE_FRG I40E_RX_PTYPE_FRAG
205#define I40E_RX_PTYPE_INNER_PROT_TS I40E_RX_PTYPE_INNER_PROT_TIMESYNC
206
207/* Lookup table mapping the HW PTYPE to the bit field for decoding */
208struct i40e_rx_ptype_decoded i40evf_ptype_lookup[] = {
209 /* L2 Packet types */
210 I40E_PTT_UNUSED_ENTRY(0),
211 I40E_PTT(1, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY2),
212 I40E_PTT(2, L2, NONE, NOF, NONE, NONE, NOF, TS, PAY2),
213 I40E_PTT(3, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY2),
214 I40E_PTT_UNUSED_ENTRY(4),
215 I40E_PTT_UNUSED_ENTRY(5),
216 I40E_PTT(6, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY2),
217 I40E_PTT(7, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY2),
218 I40E_PTT_UNUSED_ENTRY(8),
219 I40E_PTT_UNUSED_ENTRY(9),
220 I40E_PTT(10, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY2),
221 I40E_PTT(11, L2, NONE, NOF, NONE, NONE, NOF, NONE, NONE),
222 I40E_PTT(12, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3),
223 I40E_PTT(13, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3),
224 I40E_PTT(14, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3),
225 I40E_PTT(15, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3),
226 I40E_PTT(16, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3),
227 I40E_PTT(17, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3),
228 I40E_PTT(18, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3),
229 I40E_PTT(19, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3),
230 I40E_PTT(20, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3),
231 I40E_PTT(21, L2, NONE, NOF, NONE, NONE, NOF, NONE, PAY3),
232
233 /* Non Tunneled IPv4 */
234 I40E_PTT(22, IP, IPV4, FRG, NONE, NONE, NOF, NONE, PAY3),
235 I40E_PTT(23, IP, IPV4, NOF, NONE, NONE, NOF, NONE, PAY3),
236 I40E_PTT(24, IP, IPV4, NOF, NONE, NONE, NOF, UDP, PAY4),
237 I40E_PTT_UNUSED_ENTRY(25),
238 I40E_PTT(26, IP, IPV4, NOF, NONE, NONE, NOF, TCP, PAY4),
239 I40E_PTT(27, IP, IPV4, NOF, NONE, NONE, NOF, SCTP, PAY4),
240 I40E_PTT(28, IP, IPV4, NOF, NONE, NONE, NOF, ICMP, PAY4),
241
242 /* IPv4 --> IPv4 */
243 I40E_PTT(29, IP, IPV4, NOF, IP_IP, IPV4, FRG, NONE, PAY3),
244 I40E_PTT(30, IP, IPV4, NOF, IP_IP, IPV4, NOF, NONE, PAY3),
245 I40E_PTT(31, IP, IPV4, NOF, IP_IP, IPV4, NOF, UDP, PAY4),
246 I40E_PTT_UNUSED_ENTRY(32),
247 I40E_PTT(33, IP, IPV4, NOF, IP_IP, IPV4, NOF, TCP, PAY4),
248 I40E_PTT(34, IP, IPV4, NOF, IP_IP, IPV4, NOF, SCTP, PAY4),
249 I40E_PTT(35, IP, IPV4, NOF, IP_IP, IPV4, NOF, ICMP, PAY4),
250
251 /* IPv4 --> IPv6 */
252 I40E_PTT(36, IP, IPV4, NOF, IP_IP, IPV6, FRG, NONE, PAY3),
253 I40E_PTT(37, IP, IPV4, NOF, IP_IP, IPV6, NOF, NONE, PAY3),
254 I40E_PTT(38, IP, IPV4, NOF, IP_IP, IPV6, NOF, UDP, PAY4),
255 I40E_PTT_UNUSED_ENTRY(39),
256 I40E_PTT(40, IP, IPV4, NOF, IP_IP, IPV6, NOF, TCP, PAY4),
257 I40E_PTT(41, IP, IPV4, NOF, IP_IP, IPV6, NOF, SCTP, PAY4),
258 I40E_PTT(42, IP, IPV4, NOF, IP_IP, IPV6, NOF, ICMP, PAY4),
259
260 /* IPv4 --> GRE/NAT */
261 I40E_PTT(43, IP, IPV4, NOF, IP_GRENAT, NONE, NOF, NONE, PAY3),
262
263 /* IPv4 --> GRE/NAT --> IPv4 */
264 I40E_PTT(44, IP, IPV4, NOF, IP_GRENAT, IPV4, FRG, NONE, PAY3),
265 I40E_PTT(45, IP, IPV4, NOF, IP_GRENAT, IPV4, NOF, NONE, PAY3),
266 I40E_PTT(46, IP, IPV4, NOF, IP_GRENAT, IPV4, NOF, UDP, PAY4),
267 I40E_PTT_UNUSED_ENTRY(47),
268 I40E_PTT(48, IP, IPV4, NOF, IP_GRENAT, IPV4, NOF, TCP, PAY4),
269 I40E_PTT(49, IP, IPV4, NOF, IP_GRENAT, IPV4, NOF, SCTP, PAY4),
270 I40E_PTT(50, IP, IPV4, NOF, IP_GRENAT, IPV4, NOF, ICMP, PAY4),
271
272 /* IPv4 --> GRE/NAT --> IPv6 */
273 I40E_PTT(51, IP, IPV4, NOF, IP_GRENAT, IPV6, FRG, NONE, PAY3),
274 I40E_PTT(52, IP, IPV4, NOF, IP_GRENAT, IPV6, NOF, NONE, PAY3),
275 I40E_PTT(53, IP, IPV4, NOF, IP_GRENAT, IPV6, NOF, UDP, PAY4),
276 I40E_PTT_UNUSED_ENTRY(54),
277 I40E_PTT(55, IP, IPV4, NOF, IP_GRENAT, IPV6, NOF, TCP, PAY4),
278 I40E_PTT(56, IP, IPV4, NOF, IP_GRENAT, IPV6, NOF, SCTP, PAY4),
279 I40E_PTT(57, IP, IPV4, NOF, IP_GRENAT, IPV6, NOF, ICMP, PAY4),
280
281 /* IPv4 --> GRE/NAT --> MAC */
282 I40E_PTT(58, IP, IPV4, NOF, IP_GRENAT_MAC, NONE, NOF, NONE, PAY3),
283
284 /* IPv4 --> GRE/NAT --> MAC --> IPv4 */
285 I40E_PTT(59, IP, IPV4, NOF, IP_GRENAT_MAC, IPV4, FRG, NONE, PAY3),
286 I40E_PTT(60, IP, IPV4, NOF, IP_GRENAT_MAC, IPV4, NOF, NONE, PAY3),
287 I40E_PTT(61, IP, IPV4, NOF, IP_GRENAT_MAC, IPV4, NOF, UDP, PAY4),
288 I40E_PTT_UNUSED_ENTRY(62),
289 I40E_PTT(63, IP, IPV4, NOF, IP_GRENAT_MAC, IPV4, NOF, TCP, PAY4),
290 I40E_PTT(64, IP, IPV4, NOF, IP_GRENAT_MAC, IPV4, NOF, SCTP, PAY4),
291 I40E_PTT(65, IP, IPV4, NOF, IP_GRENAT_MAC, IPV4, NOF, ICMP, PAY4),
292
293 /* IPv4 --> GRE/NAT -> MAC --> IPv6 */
294 I40E_PTT(66, IP, IPV4, NOF, IP_GRENAT_MAC, IPV6, FRG, NONE, PAY3),
295 I40E_PTT(67, IP, IPV4, NOF, IP_GRENAT_MAC, IPV6, NOF, NONE, PAY3),
296 I40E_PTT(68, IP, IPV4, NOF, IP_GRENAT_MAC, IPV6, NOF, UDP, PAY4),
297 I40E_PTT_UNUSED_ENTRY(69),
298 I40E_PTT(70, IP, IPV4, NOF, IP_GRENAT_MAC, IPV6, NOF, TCP, PAY4),
299 I40E_PTT(71, IP, IPV4, NOF, IP_GRENAT_MAC, IPV6, NOF, SCTP, PAY4),
300 I40E_PTT(72, IP, IPV4, NOF, IP_GRENAT_MAC, IPV6, NOF, ICMP, PAY4),
301
302 /* IPv4 --> GRE/NAT --> MAC/VLAN */
303 I40E_PTT(73, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, NONE, NOF, NONE, PAY3),
304
305 /* IPv4 ---> GRE/NAT -> MAC/VLAN --> IPv4 */
306 I40E_PTT(74, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV4, FRG, NONE, PAY3),
307 I40E_PTT(75, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, NONE, PAY3),
308 I40E_PTT(76, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, UDP, PAY4),
309 I40E_PTT_UNUSED_ENTRY(77),
310 I40E_PTT(78, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, TCP, PAY4),
311 I40E_PTT(79, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, SCTP, PAY4),
312 I40E_PTT(80, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, ICMP, PAY4),
313
314 /* IPv4 -> GRE/NAT -> MAC/VLAN --> IPv6 */
315 I40E_PTT(81, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV6, FRG, NONE, PAY3),
316 I40E_PTT(82, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, NONE, PAY3),
317 I40E_PTT(83, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, UDP, PAY4),
318 I40E_PTT_UNUSED_ENTRY(84),
319 I40E_PTT(85, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, TCP, PAY4),
320 I40E_PTT(86, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, SCTP, PAY4),
321 I40E_PTT(87, IP, IPV4, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, ICMP, PAY4),
322
323 /* Non Tunneled IPv6 */
324 I40E_PTT(88, IP, IPV6, FRG, NONE, NONE, NOF, NONE, PAY3),
325 I40E_PTT(89, IP, IPV6, NOF, NONE, NONE, NOF, NONE, PAY3),
326 I40E_PTT(90, IP, IPV6, NOF, NONE, NONE, NOF, UDP, PAY3),
327 I40E_PTT_UNUSED_ENTRY(91),
328 I40E_PTT(92, IP, IPV6, NOF, NONE, NONE, NOF, TCP, PAY4),
329 I40E_PTT(93, IP, IPV6, NOF, NONE, NONE, NOF, SCTP, PAY4),
330 I40E_PTT(94, IP, IPV6, NOF, NONE, NONE, NOF, ICMP, PAY4),
331
332 /* IPv6 --> IPv4 */
333 I40E_PTT(95, IP, IPV6, NOF, IP_IP, IPV4, FRG, NONE, PAY3),
334 I40E_PTT(96, IP, IPV6, NOF, IP_IP, IPV4, NOF, NONE, PAY3),
335 I40E_PTT(97, IP, IPV6, NOF, IP_IP, IPV4, NOF, UDP, PAY4),
336 I40E_PTT_UNUSED_ENTRY(98),
337 I40E_PTT(99, IP, IPV6, NOF, IP_IP, IPV4, NOF, TCP, PAY4),
338 I40E_PTT(100, IP, IPV6, NOF, IP_IP, IPV4, NOF, SCTP, PAY4),
339 I40E_PTT(101, IP, IPV6, NOF, IP_IP, IPV4, NOF, ICMP, PAY4),
340
341 /* IPv6 --> IPv6 */
342 I40E_PTT(102, IP, IPV6, NOF, IP_IP, IPV6, FRG, NONE, PAY3),
343 I40E_PTT(103, IP, IPV6, NOF, IP_IP, IPV6, NOF, NONE, PAY3),
344 I40E_PTT(104, IP, IPV6, NOF, IP_IP, IPV6, NOF, UDP, PAY4),
345 I40E_PTT_UNUSED_ENTRY(105),
346 I40E_PTT(106, IP, IPV6, NOF, IP_IP, IPV6, NOF, TCP, PAY4),
347 I40E_PTT(107, IP, IPV6, NOF, IP_IP, IPV6, NOF, SCTP, PAY4),
348 I40E_PTT(108, IP, IPV6, NOF, IP_IP, IPV6, NOF, ICMP, PAY4),
349
350 /* IPv6 --> GRE/NAT */
351 I40E_PTT(109, IP, IPV6, NOF, IP_GRENAT, NONE, NOF, NONE, PAY3),
352
353 /* IPv6 --> GRE/NAT -> IPv4 */
354 I40E_PTT(110, IP, IPV6, NOF, IP_GRENAT, IPV4, FRG, NONE, PAY3),
355 I40E_PTT(111, IP, IPV6, NOF, IP_GRENAT, IPV4, NOF, NONE, PAY3),
356 I40E_PTT(112, IP, IPV6, NOF, IP_GRENAT, IPV4, NOF, UDP, PAY4),
357 I40E_PTT_UNUSED_ENTRY(113),
358 I40E_PTT(114, IP, IPV6, NOF, IP_GRENAT, IPV4, NOF, TCP, PAY4),
359 I40E_PTT(115, IP, IPV6, NOF, IP_GRENAT, IPV4, NOF, SCTP, PAY4),
360 I40E_PTT(116, IP, IPV6, NOF, IP_GRENAT, IPV4, NOF, ICMP, PAY4),
361
362 /* IPv6 --> GRE/NAT -> IPv6 */
363 I40E_PTT(117, IP, IPV6, NOF, IP_GRENAT, IPV6, FRG, NONE, PAY3),
364 I40E_PTT(118, IP, IPV6, NOF, IP_GRENAT, IPV6, NOF, NONE, PAY3),
365 I40E_PTT(119, IP, IPV6, NOF, IP_GRENAT, IPV6, NOF, UDP, PAY4),
366 I40E_PTT_UNUSED_ENTRY(120),
367 I40E_PTT(121, IP, IPV6, NOF, IP_GRENAT, IPV6, NOF, TCP, PAY4),
368 I40E_PTT(122, IP, IPV6, NOF, IP_GRENAT, IPV6, NOF, SCTP, PAY4),
369 I40E_PTT(123, IP, IPV6, NOF, IP_GRENAT, IPV6, NOF, ICMP, PAY4),
370
371 /* IPv6 --> GRE/NAT -> MAC */
372 I40E_PTT(124, IP, IPV6, NOF, IP_GRENAT_MAC, NONE, NOF, NONE, PAY3),
373
374 /* IPv6 --> GRE/NAT -> MAC -> IPv4 */
375 I40E_PTT(125, IP, IPV6, NOF, IP_GRENAT_MAC, IPV4, FRG, NONE, PAY3),
376 I40E_PTT(126, IP, IPV6, NOF, IP_GRENAT_MAC, IPV4, NOF, NONE, PAY3),
377 I40E_PTT(127, IP, IPV6, NOF, IP_GRENAT_MAC, IPV4, NOF, UDP, PAY4),
378 I40E_PTT_UNUSED_ENTRY(128),
379 I40E_PTT(129, IP, IPV6, NOF, IP_GRENAT_MAC, IPV4, NOF, TCP, PAY4),
380 I40E_PTT(130, IP, IPV6, NOF, IP_GRENAT_MAC, IPV4, NOF, SCTP, PAY4),
381 I40E_PTT(131, IP, IPV6, NOF, IP_GRENAT_MAC, IPV4, NOF, ICMP, PAY4),
382
383 /* IPv6 --> GRE/NAT -> MAC -> IPv6 */
384 I40E_PTT(132, IP, IPV6, NOF, IP_GRENAT_MAC, IPV6, FRG, NONE, PAY3),
385 I40E_PTT(133, IP, IPV6, NOF, IP_GRENAT_MAC, IPV6, NOF, NONE, PAY3),
386 I40E_PTT(134, IP, IPV6, NOF, IP_GRENAT_MAC, IPV6, NOF, UDP, PAY4),
387 I40E_PTT_UNUSED_ENTRY(135),
388 I40E_PTT(136, IP, IPV6, NOF, IP_GRENAT_MAC, IPV6, NOF, TCP, PAY4),
389 I40E_PTT(137, IP, IPV6, NOF, IP_GRENAT_MAC, IPV6, NOF, SCTP, PAY4),
390 I40E_PTT(138, IP, IPV6, NOF, IP_GRENAT_MAC, IPV6, NOF, ICMP, PAY4),
391
392 /* IPv6 --> GRE/NAT -> MAC/VLAN */
393 I40E_PTT(139, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, NONE, NOF, NONE, PAY3),
394
395 /* IPv6 --> GRE/NAT -> MAC/VLAN --> IPv4 */
396 I40E_PTT(140, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV4, FRG, NONE, PAY3),
397 I40E_PTT(141, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, NONE, PAY3),
398 I40E_PTT(142, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, UDP, PAY4),
399 I40E_PTT_UNUSED_ENTRY(143),
400 I40E_PTT(144, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, TCP, PAY4),
401 I40E_PTT(145, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, SCTP, PAY4),
402 I40E_PTT(146, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV4, NOF, ICMP, PAY4),
403
404 /* IPv6 --> GRE/NAT -> MAC/VLAN --> IPv6 */
405 I40E_PTT(147, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV6, FRG, NONE, PAY3),
406 I40E_PTT(148, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, NONE, PAY3),
407 I40E_PTT(149, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, UDP, PAY4),
408 I40E_PTT_UNUSED_ENTRY(150),
409 I40E_PTT(151, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, TCP, PAY4),
410 I40E_PTT(152, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, SCTP, PAY4),
411 I40E_PTT(153, IP, IPV6, NOF, IP_GRENAT_MAC_VLAN, IPV6, NOF, ICMP, PAY4),
412
413 /* unused entries */
414 I40E_PTT_UNUSED_ENTRY(154),
415 I40E_PTT_UNUSED_ENTRY(155),
416 I40E_PTT_UNUSED_ENTRY(156),
417 I40E_PTT_UNUSED_ENTRY(157),
418 I40E_PTT_UNUSED_ENTRY(158),
419 I40E_PTT_UNUSED_ENTRY(159),
420
421 I40E_PTT_UNUSED_ENTRY(160),
422 I40E_PTT_UNUSED_ENTRY(161),
423 I40E_PTT_UNUSED_ENTRY(162),
424 I40E_PTT_UNUSED_ENTRY(163),
425 I40E_PTT_UNUSED_ENTRY(164),
426 I40E_PTT_UNUSED_ENTRY(165),
427 I40E_PTT_UNUSED_ENTRY(166),
428 I40E_PTT_UNUSED_ENTRY(167),
429 I40E_PTT_UNUSED_ENTRY(168),
430 I40E_PTT_UNUSED_ENTRY(169),
431
432 I40E_PTT_UNUSED_ENTRY(170),
433 I40E_PTT_UNUSED_ENTRY(171),
434 I40E_PTT_UNUSED_ENTRY(172),
435 I40E_PTT_UNUSED_ENTRY(173),
436 I40E_PTT_UNUSED_ENTRY(174),
437 I40E_PTT_UNUSED_ENTRY(175),
438 I40E_PTT_UNUSED_ENTRY(176),
439 I40E_PTT_UNUSED_ENTRY(177),
440 I40E_PTT_UNUSED_ENTRY(178),
441 I40E_PTT_UNUSED_ENTRY(179),
442
443 I40E_PTT_UNUSED_ENTRY(180),
444 I40E_PTT_UNUSED_ENTRY(181),
445 I40E_PTT_UNUSED_ENTRY(182),
446 I40E_PTT_UNUSED_ENTRY(183),
447 I40E_PTT_UNUSED_ENTRY(184),
448 I40E_PTT_UNUSED_ENTRY(185),
449 I40E_PTT_UNUSED_ENTRY(186),
450 I40E_PTT_UNUSED_ENTRY(187),
451 I40E_PTT_UNUSED_ENTRY(188),
452 I40E_PTT_UNUSED_ENTRY(189),
453
454 I40E_PTT_UNUSED_ENTRY(190),
455 I40E_PTT_UNUSED_ENTRY(191),
456 I40E_PTT_UNUSED_ENTRY(192),
457 I40E_PTT_UNUSED_ENTRY(193),
458 I40E_PTT_UNUSED_ENTRY(194),
459 I40E_PTT_UNUSED_ENTRY(195),
460 I40E_PTT_UNUSED_ENTRY(196),
461 I40E_PTT_UNUSED_ENTRY(197),
462 I40E_PTT_UNUSED_ENTRY(198),
463 I40E_PTT_UNUSED_ENTRY(199),
464
465 I40E_PTT_UNUSED_ENTRY(200),
466 I40E_PTT_UNUSED_ENTRY(201),
467 I40E_PTT_UNUSED_ENTRY(202),
468 I40E_PTT_UNUSED_ENTRY(203),
469 I40E_PTT_UNUSED_ENTRY(204),
470 I40E_PTT_UNUSED_ENTRY(205),
471 I40E_PTT_UNUSED_ENTRY(206),
472 I40E_PTT_UNUSED_ENTRY(207),
473 I40E_PTT_UNUSED_ENTRY(208),
474 I40E_PTT_UNUSED_ENTRY(209),
475
476 I40E_PTT_UNUSED_ENTRY(210),
477 I40E_PTT_UNUSED_ENTRY(211),
478 I40E_PTT_UNUSED_ENTRY(212),
479 I40E_PTT_UNUSED_ENTRY(213),
480 I40E_PTT_UNUSED_ENTRY(214),
481 I40E_PTT_UNUSED_ENTRY(215),
482 I40E_PTT_UNUSED_ENTRY(216),
483 I40E_PTT_UNUSED_ENTRY(217),
484 I40E_PTT_UNUSED_ENTRY(218),
485 I40E_PTT_UNUSED_ENTRY(219),
486
487 I40E_PTT_UNUSED_ENTRY(220),
488 I40E_PTT_UNUSED_ENTRY(221),
489 I40E_PTT_UNUSED_ENTRY(222),
490 I40E_PTT_UNUSED_ENTRY(223),
491 I40E_PTT_UNUSED_ENTRY(224),
492 I40E_PTT_UNUSED_ENTRY(225),
493 I40E_PTT_UNUSED_ENTRY(226),
494 I40E_PTT_UNUSED_ENTRY(227),
495 I40E_PTT_UNUSED_ENTRY(228),
496 I40E_PTT_UNUSED_ENTRY(229),
497
498 I40E_PTT_UNUSED_ENTRY(230),
499 I40E_PTT_UNUSED_ENTRY(231),
500 I40E_PTT_UNUSED_ENTRY(232),
501 I40E_PTT_UNUSED_ENTRY(233),
502 I40E_PTT_UNUSED_ENTRY(234),
503 I40E_PTT_UNUSED_ENTRY(235),
504 I40E_PTT_UNUSED_ENTRY(236),
505 I40E_PTT_UNUSED_ENTRY(237),
506 I40E_PTT_UNUSED_ENTRY(238),
507 I40E_PTT_UNUSED_ENTRY(239),
508
509 I40E_PTT_UNUSED_ENTRY(240),
510 I40E_PTT_UNUSED_ENTRY(241),
511 I40E_PTT_UNUSED_ENTRY(242),
512 I40E_PTT_UNUSED_ENTRY(243),
513 I40E_PTT_UNUSED_ENTRY(244),
514 I40E_PTT_UNUSED_ENTRY(245),
515 I40E_PTT_UNUSED_ENTRY(246),
516 I40E_PTT_UNUSED_ENTRY(247),
517 I40E_PTT_UNUSED_ENTRY(248),
518 I40E_PTT_UNUSED_ENTRY(249),
519
520 I40E_PTT_UNUSED_ENTRY(250),
521 I40E_PTT_UNUSED_ENTRY(251),
522 I40E_PTT_UNUSED_ENTRY(252),
523 I40E_PTT_UNUSED_ENTRY(253),
524 I40E_PTT_UNUSED_ENTRY(254),
525 I40E_PTT_UNUSED_ENTRY(255)
526};
527
528
163/** 529/**
164 * i40e_aq_send_msg_to_pf 530 * i40e_aq_send_msg_to_pf
165 * @hw: pointer to the hardware structure 531 * @hw: pointer to the hardware structure
diff --git a/drivers/net/ethernet/intel/i40evf/i40e_prototype.h b/drivers/net/ethernet/intel/i40evf/i40e_prototype.h
index 7841573a58c9..862fcdf52675 100644
--- a/drivers/net/ethernet/intel/i40evf/i40e_prototype.h
+++ b/drivers/net/ethernet/intel/i40evf/i40e_prototype.h
@@ -63,6 +63,13 @@ i40e_status i40evf_aq_queue_shutdown(struct i40e_hw *hw,
63 63
64i40e_status i40e_set_mac_type(struct i40e_hw *hw); 64i40e_status i40e_set_mac_type(struct i40e_hw *hw);
65 65
66extern struct i40e_rx_ptype_decoded i40evf_ptype_lookup[];
67
68static inline struct i40e_rx_ptype_decoded decode_rx_desc_ptype(u8 ptype)
69{
70 return i40evf_ptype_lookup[ptype];
71}
72
66/* prototype for functions used for SW locks */ 73/* prototype for functions used for SW locks */
67 74
68/* i40e_common for VF drivers*/ 75/* i40e_common for VF drivers*/
diff --git a/drivers/net/ethernet/intel/i40evf/i40e_txrx.c b/drivers/net/ethernet/intel/i40evf/i40e_txrx.c
index ffdb01d853db..53be5f44d015 100644
--- a/drivers/net/ethernet/intel/i40evf/i40e_txrx.c
+++ b/drivers/net/ethernet/intel/i40evf/i40e_txrx.c
@@ -1,7 +1,7 @@
1/******************************************************************************* 1/*******************************************************************************
2 * 2 *
3 * Intel Ethernet Controller XL710 Family Linux Virtual Function Driver 3 * Intel Ethernet Controller XL710 Family Linux Virtual Function Driver
4 * Copyright(c) 2013 Intel Corporation. 4 * Copyright(c) 2013 - 2014 Intel Corporation.
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify it 6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms and conditions of the GNU General Public License, 7 * under the terms and conditions of the GNU General Public License,
@@ -24,6 +24,7 @@
24#include <linux/prefetch.h> 24#include <linux/prefetch.h>
25 25
26#include "i40evf.h" 26#include "i40evf.h"
27#include "i40e_prototype.h"
27 28
28static inline __le64 build_ctob(u32 td_cmd, u32 td_offset, unsigned int size, 29static inline __le64 build_ctob(u32 td_cmd, u32 td_offset, unsigned int size,
29 u32 td_tag) 30 u32 td_tag)
@@ -169,6 +170,20 @@ static bool i40e_check_tx_hang(struct i40e_ring *tx_ring)
169} 170}
170 171
171/** 172/**
173 * i40e_get_head - Retrieve head from head writeback
174 * @tx_ring: tx ring to fetch head of
175 *
176 * Returns value of Tx ring head based on value stored
177 * in head write-back location
178 **/
179static inline u32 i40e_get_head(struct i40e_ring *tx_ring)
180{
181 void *head = (struct i40e_tx_desc *)tx_ring->desc + tx_ring->count;
182
183 return le32_to_cpu(*(volatile __le32 *)head);
184}
185
186/**
172 * i40e_clean_tx_irq - Reclaim resources after transmit completes 187 * i40e_clean_tx_irq - Reclaim resources after transmit completes
173 * @tx_ring: tx ring to clean 188 * @tx_ring: tx ring to clean
174 * @budget: how many cleans we're allowed 189 * @budget: how many cleans we're allowed
@@ -179,6 +194,7 @@ static bool i40e_clean_tx_irq(struct i40e_ring *tx_ring, int budget)
179{ 194{
180 u16 i = tx_ring->next_to_clean; 195 u16 i = tx_ring->next_to_clean;
181 struct i40e_tx_buffer *tx_buf; 196 struct i40e_tx_buffer *tx_buf;
197 struct i40e_tx_desc *tx_head;
182 struct i40e_tx_desc *tx_desc; 198 struct i40e_tx_desc *tx_desc;
183 unsigned int total_packets = 0; 199 unsigned int total_packets = 0;
184 unsigned int total_bytes = 0; 200 unsigned int total_bytes = 0;
@@ -187,6 +203,8 @@ static bool i40e_clean_tx_irq(struct i40e_ring *tx_ring, int budget)
187 tx_desc = I40E_TX_DESC(tx_ring, i); 203 tx_desc = I40E_TX_DESC(tx_ring, i);
188 i -= tx_ring->count; 204 i -= tx_ring->count;
189 205
206 tx_head = I40E_TX_DESC(tx_ring, i40e_get_head(tx_ring));
207
190 do { 208 do {
191 struct i40e_tx_desc *eop_desc = tx_buf->next_to_watch; 209 struct i40e_tx_desc *eop_desc = tx_buf->next_to_watch;
192 210
@@ -197,9 +215,8 @@ static bool i40e_clean_tx_irq(struct i40e_ring *tx_ring, int budget)
197 /* prevent any other reads prior to eop_desc */ 215 /* prevent any other reads prior to eop_desc */
198 read_barrier_depends(); 216 read_barrier_depends();
199 217
200 /* if the descriptor isn't done, no work yet to do */ 218 /* we have caught up to head, no work left to do */
201 if (!(eop_desc->cmd_type_offset_bsz & 219 if (tx_head == tx_desc)
202 cpu_to_le64(I40E_TX_DESC_DTYPE_DESC_DONE)))
203 break; 220 break;
204 221
205 /* clear next_to_watch to prevent false hangs */ 222 /* clear next_to_watch to prevent false hangs */
@@ -431,6 +448,10 @@ int i40evf_setup_tx_descriptors(struct i40e_ring *tx_ring)
431 448
432 /* round up to nearest 4K */ 449 /* round up to nearest 4K */
433 tx_ring->size = tx_ring->count * sizeof(struct i40e_tx_desc); 450 tx_ring->size = tx_ring->count * sizeof(struct i40e_tx_desc);
451 /* add u32 for head writeback, align after this takes care of
452 * guaranteeing this is at least one cache line in size
453 */
454 tx_ring->size += sizeof(u32);
434 tx_ring->size = ALIGN(tx_ring->size, 4096); 455 tx_ring->size = ALIGN(tx_ring->size, 4096);
435 tx_ring->desc = dma_alloc_coherent(dev, tx_ring->size, 456 tx_ring->desc = dma_alloc_coherent(dev, tx_ring->size,
436 &tx_ring->dma, GFP_KERNEL); 457 &tx_ring->dma, GFP_KERNEL);
@@ -722,7 +743,7 @@ static inline void i40e_rx_checksum(struct i40e_vsi *vsi,
722 rx_status & (1 << I40E_RX_DESC_STATUS_L3L4P_SHIFT))) 743 rx_status & (1 << I40E_RX_DESC_STATUS_L3L4P_SHIFT)))
723 return; 744 return;
724 745
725 /* likely incorrect csum if alternate IP extention headers found */ 746 /* likely incorrect csum if alternate IP extension headers found */
726 if (rx_status & (1 << I40E_RX_DESC_STATUS_IPV6EXADD_SHIFT)) 747 if (rx_status & (1 << I40E_RX_DESC_STATUS_IPV6EXADD_SHIFT))
727 return; 748 return;
728 749
@@ -786,6 +807,29 @@ static inline u32 i40e_rx_hash(struct i40e_ring *ring,
786} 807}
787 808
788/** 809/**
810 * i40e_ptype_to_hash - get a hash type
811 * @ptype: the ptype value from the descriptor
812 *
813 * Returns a hash type to be used by skb_set_hash
814 **/
815static inline enum pkt_hash_types i40e_ptype_to_hash(u8 ptype)
816{
817 struct i40e_rx_ptype_decoded decoded = decode_rx_desc_ptype(ptype);
818
819 if (!decoded.known)
820 return PKT_HASH_TYPE_NONE;
821
822 if (decoded.outer_ip == I40E_RX_PTYPE_OUTER_IP &&
823 decoded.payload_layer == I40E_RX_PTYPE_PAYLOAD_LAYER_PAY4)
824 return PKT_HASH_TYPE_L4;
825 else if (decoded.outer_ip == I40E_RX_PTYPE_OUTER_IP &&
826 decoded.payload_layer == I40E_RX_PTYPE_PAYLOAD_LAYER_PAY3)
827 return PKT_HASH_TYPE_L3;
828 else
829 return PKT_HASH_TYPE_L2;
830}
831
832/**
789 * i40e_clean_rx_irq - Reclaim resources after receive completes 833 * i40e_clean_rx_irq - Reclaim resources after receive completes
790 * @rx_ring: rx ring to clean 834 * @rx_ring: rx ring to clean
791 * @budget: how many cleans we're allowed 835 * @budget: how many cleans we're allowed
@@ -802,13 +846,13 @@ static int i40e_clean_rx_irq(struct i40e_ring *rx_ring, int budget)
802 u16 i = rx_ring->next_to_clean; 846 u16 i = rx_ring->next_to_clean;
803 union i40e_rx_desc *rx_desc; 847 union i40e_rx_desc *rx_desc;
804 u32 rx_error, rx_status; 848 u32 rx_error, rx_status;
849 u8 rx_ptype;
805 u64 qword; 850 u64 qword;
806 u16 rx_ptype;
807 851
808 rx_desc = I40E_RX_DESC(rx_ring, i); 852 rx_desc = I40E_RX_DESC(rx_ring, i);
809 qword = le64_to_cpu(rx_desc->wb.qword1.status_error_len); 853 qword = le64_to_cpu(rx_desc->wb.qword1.status_error_len);
810 rx_status = (qword & I40E_RXD_QW1_STATUS_MASK) 854 rx_status = (qword & I40E_RXD_QW1_STATUS_MASK) >>
811 >> I40E_RXD_QW1_STATUS_SHIFT; 855 I40E_RXD_QW1_STATUS_SHIFT;
812 856
813 while (rx_status & (1 << I40E_RX_DESC_STATUS_DD_SHIFT)) { 857 while (rx_status & (1 << I40E_RX_DESC_STATUS_DD_SHIFT)) {
814 union i40e_rx_desc *next_rxd; 858 union i40e_rx_desc *next_rxd;
@@ -912,7 +956,8 @@ static int i40e_clean_rx_irq(struct i40e_ring *rx_ring, int budget)
912 goto next_desc; 956 goto next_desc;
913 } 957 }
914 958
915 skb->rxhash = i40e_rx_hash(rx_ring, rx_desc); 959 skb_set_hash(skb, i40e_rx_hash(rx_ring, rx_desc),
960 i40e_ptype_to_hash(rx_ptype));
916 /* probably a little skewed due to removing CRC */ 961 /* probably a little skewed due to removing CRC */
917 total_rx_bytes += skb->len; 962 total_rx_bytes += skb->len;
918 total_rx_packets++; 963 total_rx_packets++;
@@ -1241,7 +1286,8 @@ static void i40e_create_tx_ctx(struct i40e_ring *tx_ring,
1241 struct i40e_tx_context_desc *context_desc; 1286 struct i40e_tx_context_desc *context_desc;
1242 int i = tx_ring->next_to_use; 1287 int i = tx_ring->next_to_use;
1243 1288
1244 if (!cd_type_cmd_tso_mss && !cd_tunneling && !cd_l2tag2) 1289 if ((cd_type_cmd_tso_mss == I40E_TX_DESC_DTYPE_CONTEXT) &&
1290 !cd_tunneling && !cd_l2tag2)
1245 return; 1291 return;
1246 1292
1247 /* grab the next descriptor */ 1293 /* grab the next descriptor */
@@ -1352,9 +1398,23 @@ static void i40e_tx_map(struct i40e_ring *tx_ring, struct sk_buff *skb,
1352 tx_bi = &tx_ring->tx_bi[i]; 1398 tx_bi = &tx_ring->tx_bi[i];
1353 } 1399 }
1354 1400
1355 tx_desc->cmd_type_offset_bsz = 1401 /* Place RS bit on last descriptor of any packet that spans across the
1356 build_ctob(td_cmd, td_offset, size, td_tag) | 1402 * 4th descriptor (WB_STRIDE aka 0x3) in a 64B cacheline.
1357 cpu_to_le64((u64)I40E_TXD_CMD << I40E_TXD_QW1_CMD_SHIFT); 1403 */
1404#define WB_STRIDE 0x3
1405 if (((i & WB_STRIDE) != WB_STRIDE) &&
1406 (first <= &tx_ring->tx_bi[i]) &&
1407 (first >= &tx_ring->tx_bi[i & ~WB_STRIDE])) {
1408 tx_desc->cmd_type_offset_bsz =
1409 build_ctob(td_cmd, td_offset, size, td_tag) |
1410 cpu_to_le64((u64)I40E_TX_DESC_CMD_EOP <<
1411 I40E_TXD_QW1_CMD_SHIFT);
1412 } else {
1413 tx_desc->cmd_type_offset_bsz =
1414 build_ctob(td_cmd, td_offset, size, td_tag) |
1415 cpu_to_le64((u64)I40E_TXD_CMD <<
1416 I40E_TXD_QW1_CMD_SHIFT);
1417 }
1358 1418
1359 netdev_tx_sent_queue(netdev_get_tx_queue(tx_ring->netdev, 1419 netdev_tx_sent_queue(netdev_get_tx_queue(tx_ring->netdev,
1360 tx_ring->queue_index), 1420 tx_ring->queue_index),
@@ -1457,7 +1517,7 @@ static int i40e_xmit_descriptor_count(struct sk_buff *skb,
1457 1517
1458 /* need: 1 descriptor per page * PAGE_SIZE/I40E_MAX_DATA_PER_TXD, 1518 /* need: 1 descriptor per page * PAGE_SIZE/I40E_MAX_DATA_PER_TXD,
1459 * + 1 desc for skb_head_len/I40E_MAX_DATA_PER_TXD, 1519 * + 1 desc for skb_head_len/I40E_MAX_DATA_PER_TXD,
1460 * + 2 desc gap to keep tail from touching head, 1520 * + 4 desc gap to avoid the cache line where head is,
1461 * + 1 desc for context descriptor, 1521 * + 1 desc for context descriptor,
1462 * otherwise try next time 1522 * otherwise try next time
1463 */ 1523 */
@@ -1468,7 +1528,7 @@ static int i40e_xmit_descriptor_count(struct sk_buff *skb,
1468 count += skb_shinfo(skb)->nr_frags; 1528 count += skb_shinfo(skb)->nr_frags;
1469#endif 1529#endif
1470 count += TXD_USE_COUNT(skb_headlen(skb)); 1530 count += TXD_USE_COUNT(skb_headlen(skb));
1471 if (i40e_maybe_stop_tx(tx_ring, count + 3)) { 1531 if (i40e_maybe_stop_tx(tx_ring, count + 4 + 1)) {
1472 tx_ring->tx_stats.tx_busy++; 1532 tx_ring->tx_stats.tx_busy++;
1473 return 0; 1533 return 0;
1474 } 1534 }
diff --git a/drivers/net/ethernet/intel/i40evf/i40e_type.h b/drivers/net/ethernet/intel/i40evf/i40e_type.h
index 3bffac06592f..efe73ad6fdb9 100644
--- a/drivers/net/ethernet/intel/i40evf/i40e_type.h
+++ b/drivers/net/ethernet/intel/i40evf/i40e_type.h
@@ -1,7 +1,7 @@
1/******************************************************************************* 1/*******************************************************************************
2 * 2 *
3 * Intel Ethernet Controller XL710 Family Linux Virtual Function Driver 3 * Intel Ethernet Controller XL710 Family Linux Virtual Function Driver
4 * Copyright(c) 2013 Intel Corporation. 4 * Copyright(c) 2013 - 2014 Intel Corporation.
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify it 6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms and conditions of the GNU General Public License, 7 * under the terms and conditions of the GNU General Public License,
@@ -64,8 +64,6 @@
64struct i40e_hw; 64struct i40e_hw;
65typedef void (*I40E_ADMINQ_CALLBACK)(struct i40e_hw *, struct i40e_aq_desc *); 65typedef void (*I40E_ADMINQ_CALLBACK)(struct i40e_hw *, struct i40e_aq_desc *);
66 66
67#define ETH_ALEN 6
68
69/* Data type manipulation macros. */ 67/* Data type manipulation macros. */
70 68
71#define I40E_DESC_UNUSED(R) \ 69#define I40E_DESC_UNUSED(R) \
@@ -466,6 +464,10 @@ union i40e_32byte_rx_desc {
466 union { 464 union {
467 __le32 rss; /* RSS Hash */ 465 __le32 rss; /* RSS Hash */
468 __le32 fcoe_param; /* FCoE DDP Context id */ 466 __le32 fcoe_param; /* FCoE DDP Context id */
467 /* Flow director filter id in case of
468 * Programming status desc WB
469 */
470 __le32 fd_id;
469 } hi_dword; 471 } hi_dword;
470 } qword0; 472 } qword0;
471 struct { 473 struct {
@@ -706,7 +708,7 @@ enum i40e_rx_prog_status_desc_prog_id_masks {
706enum i40e_rx_prog_status_desc_error_bits { 708enum i40e_rx_prog_status_desc_error_bits {
707 /* Note: These are predefined bit offsets */ 709 /* Note: These are predefined bit offsets */
708 I40E_RX_PROG_STATUS_DESC_FD_TBL_FULL_SHIFT = 0, 710 I40E_RX_PROG_STATUS_DESC_FD_TBL_FULL_SHIFT = 0,
709 I40E_RX_PROG_STATUS_DESC_NO_FD_QUOTA_SHIFT = 1, 711 I40E_RX_PROG_STATUS_DESC_NO_FD_ENTRY_SHIFT = 1,
710 I40E_RX_PROG_STATUS_DESC_FCOE_TBL_FULL_SHIFT = 2, 712 I40E_RX_PROG_STATUS_DESC_FCOE_TBL_FULL_SHIFT = 2,
711 I40E_RX_PROG_STATUS_DESC_FCOE_CONFLICT_SHIFT = 3 713 I40E_RX_PROG_STATUS_DESC_FCOE_CONFLICT_SHIFT = 3
712}; 714};
@@ -1018,6 +1020,11 @@ struct i40e_hw_port_stats {
1018 u64 tx_size_big; /* ptc9522 */ 1020 u64 tx_size_big; /* ptc9522 */
1019 u64 mac_short_packet_dropped; /* mspdc */ 1021 u64 mac_short_packet_dropped; /* mspdc */
1020 u64 checksum_error; /* xec */ 1022 u64 checksum_error; /* xec */
1023 /* EEE LPI */
1024 bool tx_lpi_status;
1025 bool rx_lpi_status;
1026 u64 tx_lpi_count; /* etlpic */
1027 u64 rx_lpi_count; /* erlpic */
1021}; 1028};
1022 1029
1023/* Checksum and Shadow RAM pointers */ 1030/* Checksum and Shadow RAM pointers */
diff --git a/drivers/net/ethernet/intel/i40evf/i40evf.h b/drivers/net/ethernet/intel/i40evf/i40evf.h
index ff6529b288a1..ccb43d343543 100644
--- a/drivers/net/ethernet/intel/i40evf/i40evf.h
+++ b/drivers/net/ethernet/intel/i40evf/i40evf.h
@@ -1,7 +1,7 @@
1/******************************************************************************* 1/*******************************************************************************
2 * 2 *
3 * Intel Ethernet Controller XL710 Family Linux Virtual Function Driver 3 * Intel Ethernet Controller XL710 Family Linux Virtual Function Driver
4 * Copyright(c) 2013 Intel Corporation. 4 * Copyright(c) 2013 - 2014 Intel Corporation.
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify it 6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms and conditions of the GNU General Public License, 7 * under the terms and conditions of the GNU General Public License,
@@ -38,8 +38,6 @@
38#include <linux/ipv6.h> 38#include <linux/ipv6.h>
39#include <net/ip6_checksum.h> 39#include <net/ip6_checksum.h>
40#include <net/udp.h> 40#include <net/udp.h>
41#include <linux/sctp.h>
42
43 41
44#include "i40e_type.h" 42#include "i40e_type.h"
45#include "i40e_virtchnl.h" 43#include "i40e_virtchnl.h"
@@ -164,15 +162,14 @@ struct i40evf_vlan_filter {
164/* Driver state. The order of these is important! */ 162/* Driver state. The order of these is important! */
165enum i40evf_state_t { 163enum i40evf_state_t {
166 __I40EVF_STARTUP, /* driver loaded, probe complete */ 164 __I40EVF_STARTUP, /* driver loaded, probe complete */
167 __I40EVF_FAILED, /* PF communication failed. Fatal. */
168 __I40EVF_REMOVE, /* driver is being unloaded */ 165 __I40EVF_REMOVE, /* driver is being unloaded */
169 __I40EVF_INIT_VERSION_CHECK, /* aq msg sent, awaiting reply */ 166 __I40EVF_INIT_VERSION_CHECK, /* aq msg sent, awaiting reply */
170 __I40EVF_INIT_GET_RESOURCES, /* aq msg sent, awaiting reply */ 167 __I40EVF_INIT_GET_RESOURCES, /* aq msg sent, awaiting reply */
171 __I40EVF_INIT_SW, /* got resources, setting up structs */ 168 __I40EVF_INIT_SW, /* got resources, setting up structs */
169 __I40EVF_RESETTING, /* in reset */
172 /* Below here, watchdog is running */ 170 /* Below here, watchdog is running */
173 __I40EVF_DOWN, /* ready, can be opened */ 171 __I40EVF_DOWN, /* ready, can be opened */
174 __I40EVF_TESTING, /* in ethtool self-test */ 172 __I40EVF_TESTING, /* in ethtool self-test */
175 __I40EVF_RESETTING, /* in reset */
176 __I40EVF_RUNNING, /* opened, working */ 173 __I40EVF_RUNNING, /* opened, working */
177}; 174};
178 175
@@ -185,47 +182,25 @@ enum i40evf_critical_section_t {
185/* board specific private data structure */ 182/* board specific private data structure */
186struct i40evf_adapter { 183struct i40evf_adapter {
187 struct timer_list watchdog_timer; 184 struct timer_list watchdog_timer;
188 struct vlan_group *vlgrp;
189 struct work_struct reset_task; 185 struct work_struct reset_task;
190 struct work_struct adminq_task; 186 struct work_struct adminq_task;
191 struct delayed_work init_task; 187 struct delayed_work init_task;
192 struct i40e_q_vector *q_vector[MAX_MSIX_Q_VECTORS]; 188 struct i40e_q_vector *q_vector[MAX_MSIX_Q_VECTORS];
193 struct list_head vlan_filter_list; 189 struct list_head vlan_filter_list;
194 char name[MAX_MSIX_COUNT][IFNAMSIZ + 9]; 190 char misc_vector_name[IFNAMSIZ + 9];
195
196 /* Interrupt Throttle Rate */
197 u32 itr_setting;
198 u16 eitr_low;
199 u16 eitr_high;
200 191
201 /* TX */ 192 /* TX */
202 struct i40e_ring *tx_rings[I40E_MAX_VSI_QP]; 193 struct i40e_ring *tx_rings[I40E_MAX_VSI_QP];
203 u64 restart_queue;
204 u64 hw_csum_tx_good;
205 u64 lsc_int;
206 u64 hw_tso_ctxt;
207 u64 hw_tso6_ctxt;
208 u32 tx_timeout_count; 194 u32 tx_timeout_count;
209 struct list_head mac_filter_list; 195 struct list_head mac_filter_list;
210#ifdef DEBUG
211 bool detect_tx_hung;
212#endif /* DEBUG */
213 196
214 /* RX */ 197 /* RX */
215 struct i40e_ring *rx_rings[I40E_MAX_VSI_QP]; 198 struct i40e_ring *rx_rings[I40E_MAX_VSI_QP];
216 int txd_count;
217 int rxd_count;
218 u64 hw_csum_rx_error; 199 u64 hw_csum_rx_error;
219 u64 hw_rx_no_dma_resources;
220 u64 hw_csum_rx_good;
221 u64 non_eop_descs;
222 int num_msix_vectors; 200 int num_msix_vectors;
223 struct msix_entry *msix_entries; 201 struct msix_entry *msix_entries;
224 202
225 u64 rx_hdr_split; 203 u32 flags;
226
227 u32 init_state;
228 volatile unsigned long flags;
229#define I40EVF_FLAG_RX_CSUM_ENABLED (u32)(1) 204#define I40EVF_FLAG_RX_CSUM_ENABLED (u32)(1)
230#define I40EVF_FLAG_RX_1BUF_CAPABLE (u32)(1 << 1) 205#define I40EVF_FLAG_RX_1BUF_CAPABLE (u32)(1 << 1)
231#define I40EVF_FLAG_RX_PS_CAPABLE (u32)(1 << 2) 206#define I40EVF_FLAG_RX_PS_CAPABLE (u32)(1 << 2)
@@ -234,6 +209,8 @@ struct i40evf_adapter {
234#define I40EVF_FLAG_IMIR_ENABLED (u32)(1 << 5) 209#define I40EVF_FLAG_IMIR_ENABLED (u32)(1 << 5)
235#define I40EVF_FLAG_MQ_CAPABLE (u32)(1 << 6) 210#define I40EVF_FLAG_MQ_CAPABLE (u32)(1 << 6)
236#define I40EVF_FLAG_NEED_LINK_UPDATE (u32)(1 << 7) 211#define I40EVF_FLAG_NEED_LINK_UPDATE (u32)(1 << 7)
212#define I40EVF_FLAG_PF_COMMS_FAILED (u32)(1 << 8)
213#define I40EVF_FLAG_RESET_PENDING (u32)(1 << 9)
237/* duplcates for common code */ 214/* duplcates for common code */
238#define I40E_FLAG_FDIR_ATR_ENABLED 0 215#define I40E_FLAG_FDIR_ATR_ENABLED 0
239#define I40E_FLAG_DCB_ENABLED 0 216#define I40E_FLAG_DCB_ENABLED 0
@@ -251,21 +228,19 @@ struct i40evf_adapter {
251#define I40EVF_FLAG_AQ_CONFIGURE_QUEUES (u32)(1 << 6) 228#define I40EVF_FLAG_AQ_CONFIGURE_QUEUES (u32)(1 << 6)
252#define I40EVF_FLAG_AQ_MAP_VECTORS (u32)(1 << 7) 229#define I40EVF_FLAG_AQ_MAP_VECTORS (u32)(1 << 7)
253#define I40EVF_FLAG_AQ_HANDLE_RESET (u32)(1 << 8) 230#define I40EVF_FLAG_AQ_HANDLE_RESET (u32)(1 << 8)
231
254 /* OS defined structs */ 232 /* OS defined structs */
255 struct net_device *netdev; 233 struct net_device *netdev;
256 struct pci_dev *pdev; 234 struct pci_dev *pdev;
257 struct net_device_stats net_stats; 235 struct net_device_stats net_stats;
258 236
259 /* structs defined in i40e_vf.h */ 237 struct i40e_hw hw; /* defined in i40e_type.h */
260 struct i40e_hw hw;
261 238
262 enum i40evf_state_t state; 239 enum i40evf_state_t state;
263 volatile unsigned long crit_section; 240 volatile unsigned long crit_section;
264 u64 tx_busy;
265 241
266 struct work_struct watchdog_task; 242 struct work_struct watchdog_task;
267 bool netdev_registered; 243 bool netdev_registered;
268 bool dev_closed;
269 bool link_up; 244 bool link_up;
270 enum i40e_virtchnl_ops current_op; 245 enum i40e_virtchnl_ops current_op;
271 struct i40e_virtchnl_vf_resource *vf_res; /* incl. all VSIs */ 246 struct i40e_virtchnl_vf_resource *vf_res; /* incl. all VSIs */
@@ -276,11 +251,6 @@ struct i40evf_adapter {
276 u32 aq_wait_count; 251 u32 aq_wait_count;
277}; 252};
278 253
279struct i40evf_info {
280 enum i40e_mac_type mac;
281 unsigned int flags;
282};
283
284 254
285/* needed by i40evf_ethtool.c */ 255/* needed by i40evf_ethtool.c */
286extern char i40evf_driver_name[]; 256extern char i40evf_driver_name[];
@@ -315,6 +285,7 @@ void i40evf_add_vlans(struct i40evf_adapter *adapter);
315void i40evf_del_vlans(struct i40evf_adapter *adapter); 285void i40evf_del_vlans(struct i40evf_adapter *adapter);
316void i40evf_set_promiscuous(struct i40evf_adapter *adapter, int flags); 286void i40evf_set_promiscuous(struct i40evf_adapter *adapter, int flags);
317void i40evf_request_stats(struct i40evf_adapter *adapter); 287void i40evf_request_stats(struct i40evf_adapter *adapter);
288void i40evf_request_reset(struct i40evf_adapter *adapter);
318void i40evf_virtchnl_completion(struct i40evf_adapter *adapter, 289void i40evf_virtchnl_completion(struct i40evf_adapter *adapter,
319 enum i40e_virtchnl_ops v_opcode, 290 enum i40e_virtchnl_ops v_opcode,
320 i40e_status v_retval, u8 *msg, u16 msglen); 291 i40e_status v_retval, u8 *msg, u16 msglen);
diff --git a/drivers/net/ethernet/intel/i40evf/i40evf_ethtool.c b/drivers/net/ethernet/intel/i40evf/i40evf_ethtool.c
index b0b1f4bf5ac0..8b0db1ce179c 100644
--- a/drivers/net/ethernet/intel/i40evf/i40evf_ethtool.c
+++ b/drivers/net/ethernet/intel/i40evf/i40evf_ethtool.c
@@ -1,7 +1,7 @@
1/******************************************************************************* 1/*******************************************************************************
2 * 2 *
3 * Intel Ethernet Controller XL710 Family Linux Virtual Function Driver 3 * Intel Ethernet Controller XL710 Family Linux Virtual Function Driver
4 * Copyright(c) 2013 Intel Corporation. 4 * Copyright(c) 2013 - 2014 Intel Corporation.
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify it 6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms and conditions of the GNU General Public License, 7 * under the terms and conditions of the GNU General Public License,
@@ -241,6 +241,7 @@ static int i40evf_set_ringparam(struct net_device *netdev,
241{ 241{
242 struct i40evf_adapter *adapter = netdev_priv(netdev); 242 struct i40evf_adapter *adapter = netdev_priv(netdev);
243 u32 new_rx_count, new_tx_count; 243 u32 new_rx_count, new_tx_count;
244 int i;
244 245
245 if ((ring->rx_mini_pending) || (ring->rx_jumbo_pending)) 246 if ((ring->rx_mini_pending) || (ring->rx_jumbo_pending))
246 return -EINVAL; 247 return -EINVAL;
@@ -256,12 +257,14 @@ static int i40evf_set_ringparam(struct net_device *netdev,
256 new_rx_count = ALIGN(new_rx_count, I40EVF_REQ_DESCRIPTOR_MULTIPLE); 257 new_rx_count = ALIGN(new_rx_count, I40EVF_REQ_DESCRIPTOR_MULTIPLE);
257 258
258 /* if nothing to do return success */ 259 /* if nothing to do return success */
259 if ((new_tx_count == adapter->txd_count) && 260 if ((new_tx_count == adapter->tx_rings[0]->count) &&
260 (new_rx_count == adapter->rxd_count)) 261 (new_rx_count == adapter->rx_rings[0]->count))
261 return 0; 262 return 0;
262 263
263 adapter->txd_count = new_tx_count; 264 for (i = 0; i < adapter->vsi_res->num_queue_pairs; i++) {
264 adapter->rxd_count = new_rx_count; 265 adapter->tx_rings[0]->count = new_tx_count;
266 adapter->rx_rings[0]->count = new_rx_count;
267 }
265 268
266 if (netif_running(netdev)) 269 if (netif_running(netdev))
267 i40evf_reinit_locked(adapter); 270 i40evf_reinit_locked(adapter);
diff --git a/drivers/net/ethernet/intel/i40evf/i40evf_main.c b/drivers/net/ethernet/intel/i40evf/i40evf_main.c
index f5caf4419243..d3eafa320ba9 100644
--- a/drivers/net/ethernet/intel/i40evf/i40evf_main.c
+++ b/drivers/net/ethernet/intel/i40evf/i40evf_main.c
@@ -1,7 +1,7 @@
1/******************************************************************************* 1/*******************************************************************************
2 * 2 *
3 * Intel Ethernet Controller XL710 Family Linux Virtual Function Driver 3 * Intel Ethernet Controller XL710 Family Linux Virtual Function Driver
4 * Copyright(c) 2013 Intel Corporation. 4 * Copyright(c) 2013 - 2014 Intel Corporation.
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify it 6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms and conditions of the GNU General Public License, 7 * under the terms and conditions of the GNU General Public License,
@@ -31,10 +31,10 @@ char i40evf_driver_name[] = "i40evf";
31static const char i40evf_driver_string[] = 31static const char i40evf_driver_string[] =
32 "Intel(R) XL710 X710 Virtual Function Network Driver"; 32 "Intel(R) XL710 X710 Virtual Function Network Driver";
33 33
34#define DRV_VERSION "0.9.11" 34#define DRV_VERSION "0.9.16"
35const char i40evf_driver_version[] = DRV_VERSION; 35const char i40evf_driver_version[] = DRV_VERSION;
36static const char i40evf_copyright[] = 36static const char i40evf_copyright[] =
37 "Copyright (c) 2013 Intel Corporation."; 37 "Copyright (c) 2013 - 2014 Intel Corporation.";
38 38
39/* i40evf_pci_tbl - PCI Device ID Table 39/* i40evf_pci_tbl - PCI Device ID Table
40 * 40 *
@@ -167,9 +167,13 @@ static void i40evf_tx_timeout(struct net_device *netdev)
167 struct i40evf_adapter *adapter = netdev_priv(netdev); 167 struct i40evf_adapter *adapter = netdev_priv(netdev);
168 168
169 adapter->tx_timeout_count++; 169 adapter->tx_timeout_count++;
170 170 dev_info(&adapter->pdev->dev, "TX timeout detected.\n");
171 /* Do the reset outside of interrupt context */ 171 if (!(adapter->flags & I40EVF_FLAG_RESET_PENDING)) {
172 schedule_work(&adapter->reset_task); 172 dev_info(&adapter->pdev->dev, "Requesting reset from PF\n");
173 i40evf_request_reset(adapter);
174 adapter->flags |= I40EVF_FLAG_RESET_PENDING;
175 schedule_work(&adapter->reset_task);
176 }
173} 177}
174 178
175/** 179/**
@@ -211,6 +215,9 @@ static void i40evf_irq_disable(struct i40evf_adapter *adapter)
211 int i; 215 int i;
212 struct i40e_hw *hw = &adapter->hw; 216 struct i40e_hw *hw = &adapter->hw;
213 217
218 if (!adapter->msix_entries)
219 return;
220
214 for (i = 1; i < adapter->num_msix_vectors; i++) { 221 for (i = 1; i < adapter->num_msix_vectors; i++) {
215 wr32(hw, I40E_VFINT_DYN_CTLN1(i - 1), 0); 222 wr32(hw, I40E_VFINT_DYN_CTLN1(i - 1), 0);
216 synchronize_irq(adapter->msix_entries[i].vector); 223 synchronize_irq(adapter->msix_entries[i].vector);
@@ -511,12 +518,14 @@ static int i40evf_request_misc_irq(struct i40evf_adapter *adapter)
511 struct net_device *netdev = adapter->netdev; 518 struct net_device *netdev = adapter->netdev;
512 int err; 519 int err;
513 520
514 sprintf(adapter->name[0], "i40evf:mbx"); 521 sprintf(adapter->misc_vector_name, "i40evf:mbx");
515 err = request_irq(adapter->msix_entries[0].vector, 522 err = request_irq(adapter->msix_entries[0].vector,
516 &i40evf_msix_aq, 0, adapter->name[0], netdev); 523 &i40evf_msix_aq, 0,
524 adapter->misc_vector_name, netdev);
517 if (err) { 525 if (err) {
518 dev_err(&adapter->pdev->dev, 526 dev_err(&adapter->pdev->dev,
519 "request_irq for msix_aq failed: %d\n", err); 527 "request_irq for %s failed: %d\n",
528 adapter->misc_vector_name, err);
520 free_irq(adapter->msix_entries[0].vector, netdev); 529 free_irq(adapter->msix_entries[0].vector, netdev);
521 } 530 }
522 return err; 531 return err;
@@ -963,16 +972,23 @@ void i40evf_down(struct i40evf_adapter *adapter)
963 struct net_device *netdev = adapter->netdev; 972 struct net_device *netdev = adapter->netdev;
964 struct i40evf_mac_filter *f; 973 struct i40evf_mac_filter *f;
965 974
966 /* remove all MAC filters from the VSI */ 975 /* remove all MAC filters */
967 list_for_each_entry(f, &adapter->mac_filter_list, list) { 976 list_for_each_entry(f, &adapter->mac_filter_list, list) {
968 f->remove = true; 977 f->remove = true;
969 } 978 }
970 adapter->aq_required |= I40EVF_FLAG_AQ_DEL_MAC_FILTER; 979 /* remove all VLAN filters */
971 /* disable receives */ 980 list_for_each_entry(f, &adapter->vlan_filter_list, list) {
972 adapter->aq_required |= I40EVF_FLAG_AQ_DISABLE_QUEUES; 981 f->remove = true;
973 mod_timer_pending(&adapter->watchdog_timer, jiffies + 1); 982 }
974 msleep(20); 983 if (!(adapter->flags & I40EVF_FLAG_PF_COMMS_FAILED) &&
975 984 adapter->state != __I40EVF_RESETTING) {
985 adapter->aq_required |= I40EVF_FLAG_AQ_DEL_MAC_FILTER;
986 adapter->aq_required |= I40EVF_FLAG_AQ_DEL_VLAN_FILTER;
987 /* disable receives */
988 adapter->aq_required |= I40EVF_FLAG_AQ_DISABLE_QUEUES;
989 mod_timer_pending(&adapter->watchdog_timer, jiffies + 1);
990 msleep(20);
991 }
976 netif_tx_disable(netdev); 992 netif_tx_disable(netdev);
977 993
978 netif_tx_stop_all_queues(netdev); 994 netif_tx_stop_all_queues(netdev);
@@ -1124,8 +1140,8 @@ static int i40evf_set_interrupt_capability(struct i40evf_adapter *adapter)
1124 * than CPU's. So let's be conservative and only ask for 1140 * than CPU's. So let's be conservative and only ask for
1125 * (roughly) twice the number of vectors as there are CPU's. 1141 * (roughly) twice the number of vectors as there are CPU's.
1126 */ 1142 */
1127 v_budget = min(pairs, (int)(num_online_cpus() * 2)) + NONQ_VECS; 1143 v_budget = min_t(int, pairs, (int)(num_online_cpus() * 2)) + NONQ_VECS;
1128 v_budget = min(v_budget, (int)adapter->vf_res->max_vectors + 1); 1144 v_budget = min_t(int, v_budget, (int)adapter->vf_res->max_vectors);
1129 1145
1130 /* A failure in MSI-X entry allocation isn't fatal, but it does 1146 /* A failure in MSI-X entry allocation isn't fatal, but it does
1131 * mean we disable MSI-X capabilities of the adapter. 1147 * mean we disable MSI-X capabilities of the adapter.
@@ -1291,19 +1307,47 @@ static void i40evf_watchdog_task(struct work_struct *work)
1291 watchdog_task); 1307 watchdog_task);
1292 struct i40e_hw *hw = &adapter->hw; 1308 struct i40e_hw *hw = &adapter->hw;
1293 1309
1294 if (adapter->state < __I40EVF_DOWN) 1310 if (test_and_set_bit(__I40EVF_IN_CRITICAL_TASK, &adapter->crit_section))
1311 goto restart_watchdog;
1312
1313 if (adapter->flags & I40EVF_FLAG_PF_COMMS_FAILED) {
1314 dev_info(&adapter->pdev->dev, "Checking for redemption\n");
1315 if ((rd32(hw, I40E_VFGEN_RSTAT) & 0x3) == I40E_VFR_VFACTIVE) {
1316 /* A chance for redemption! */
1317 dev_err(&adapter->pdev->dev, "Hardware came out of reset. Attempting reinit.\n");
1318 adapter->state = __I40EVF_STARTUP;
1319 adapter->flags &= ~I40EVF_FLAG_PF_COMMS_FAILED;
1320 schedule_delayed_work(&adapter->init_task, 10);
1321 clear_bit(__I40EVF_IN_CRITICAL_TASK,
1322 &adapter->crit_section);
1323 /* Don't reschedule the watchdog, since we've restarted
1324 * the init task. When init_task contacts the PF and
1325 * gets everything set up again, it'll restart the
1326 * watchdog for us. Down, boy. Sit. Stay. Woof.
1327 */
1328 return;
1329 }
1330 adapter->aq_pending = 0;
1331 adapter->aq_required = 0;
1332 adapter->current_op = I40E_VIRTCHNL_OP_UNKNOWN;
1295 goto watchdog_done; 1333 goto watchdog_done;
1334 }
1296 1335
1297 if (test_and_set_bit(__I40EVF_IN_CRITICAL_TASK, &adapter->crit_section)) 1336 if ((adapter->state < __I40EVF_DOWN) ||
1337 (adapter->flags & I40EVF_FLAG_RESET_PENDING))
1298 goto watchdog_done; 1338 goto watchdog_done;
1299 1339
1300 /* check for unannounced reset */ 1340 /* check for reset */
1301 if ((adapter->state != __I40EVF_RESETTING) && 1341 if (!(adapter->flags & I40EVF_FLAG_RESET_PENDING) &&
1302 (rd32(hw, I40E_VFGEN_RSTAT) & 0x3) != I40E_VFR_VFACTIVE) { 1342 (rd32(hw, I40E_VFGEN_RSTAT) & 0x3) != I40E_VFR_VFACTIVE) {
1303 adapter->state = __I40EVF_RESETTING; 1343 adapter->state = __I40EVF_RESETTING;
1344 adapter->flags |= I40EVF_FLAG_RESET_PENDING;
1345 dev_err(&adapter->pdev->dev, "Hardware reset detected.\n");
1346 dev_info(&adapter->pdev->dev, "Scheduling reset task\n");
1304 schedule_work(&adapter->reset_task); 1347 schedule_work(&adapter->reset_task);
1305 dev_info(&adapter->pdev->dev, "%s: hardware reset detected\n", 1348 adapter->aq_pending = 0;
1306 __func__); 1349 adapter->aq_required = 0;
1350 adapter->current_op = I40E_VIRTCHNL_OP_UNKNOWN;
1307 goto watchdog_done; 1351 goto watchdog_done;
1308 } 1352 }
1309 1353
@@ -1358,16 +1402,25 @@ static void i40evf_watchdog_task(struct work_struct *work)
1358 1402
1359 i40evf_irq_enable(adapter, true); 1403 i40evf_irq_enable(adapter, true);
1360 i40evf_fire_sw_int(adapter, 0xFF); 1404 i40evf_fire_sw_int(adapter, 0xFF);
1405
1361watchdog_done: 1406watchdog_done:
1407 clear_bit(__I40EVF_IN_CRITICAL_TASK, &adapter->crit_section);
1408restart_watchdog:
1362 if (adapter->aq_required) 1409 if (adapter->aq_required)
1363 mod_timer(&adapter->watchdog_timer, 1410 mod_timer(&adapter->watchdog_timer,
1364 jiffies + msecs_to_jiffies(20)); 1411 jiffies + msecs_to_jiffies(20));
1365 else 1412 else
1366 mod_timer(&adapter->watchdog_timer, jiffies + (HZ * 2)); 1413 mod_timer(&adapter->watchdog_timer, jiffies + (HZ * 2));
1367 clear_bit(__I40EVF_IN_CRITICAL_TASK, &adapter->crit_section);
1368 schedule_work(&adapter->adminq_task); 1414 schedule_work(&adapter->adminq_task);
1369} 1415}
1370 1416
1417static int next_queue(struct i40evf_adapter *adapter, int j)
1418{
1419 j += 1;
1420
1421 return j >= adapter->vsi_res->num_queue_pairs ? 0 : j;
1422}
1423
1371/** 1424/**
1372 * i40evf_configure_rss - Prepare for RSS if used 1425 * i40evf_configure_rss - Prepare for RSS if used
1373 * @adapter: board private structure 1426 * @adapter: board private structure
@@ -1398,19 +1451,19 @@ static void i40evf_configure_rss(struct i40evf_adapter *adapter)
1398 wr32(hw, I40E_VFQF_HENA(1), (u32)(hena >> 32)); 1451 wr32(hw, I40E_VFQF_HENA(1), (u32)(hena >> 32));
1399 1452
1400 /* Populate the LUT with max no. of queues in round robin fashion */ 1453 /* Populate the LUT with max no. of queues in round robin fashion */
1401 for (i = 0, j = 0; i < I40E_VFQF_HLUT_MAX_INDEX; i++, j++) { 1454 j = adapter->vsi_res->num_queue_pairs;
1402 if (j == adapter->vsi_res->num_queue_pairs) 1455 for (i = 0; i <= I40E_VFQF_HLUT_MAX_INDEX; i++) {
1403 j = 0; 1456 lut = next_queue(adapter, j);
1404 /* lut = 4-byte sliding window of 4 lut entries */ 1457 lut |= next_queue(adapter, j) << 8;
1405 lut = (lut << 8) | (j & 1458 lut |= next_queue(adapter, j) << 16;
1406 ((0x1 << 8) - 1)); 1459 lut |= next_queue(adapter, j) << 24;
1407 /* On i = 3, we have 4 entries in lut; write to the register */ 1460 wr32(hw, I40E_VFQF_HLUT(i), lut);
1408 if ((i & 3) == 3)
1409 wr32(hw, I40E_VFQF_HLUT(i >> 2), lut);
1410 } 1461 }
1411 i40e_flush(hw); 1462 i40e_flush(hw);
1412} 1463}
1413 1464
1465#define I40EVF_RESET_WAIT_MS 100
1466#define I40EVF_RESET_WAIT_COUNT 200
1414/** 1467/**
1415 * i40evf_reset_task - Call-back task to handle hardware reset 1468 * i40evf_reset_task - Call-back task to handle hardware reset
1416 * @work: pointer to work_struct 1469 * @work: pointer to work_struct
@@ -1421,8 +1474,9 @@ static void i40evf_configure_rss(struct i40evf_adapter *adapter)
1421 **/ 1474 **/
1422static void i40evf_reset_task(struct work_struct *work) 1475static void i40evf_reset_task(struct work_struct *work)
1423{ 1476{
1424 struct i40evf_adapter *adapter = 1477 struct i40evf_adapter *adapter = container_of(work,
1425 container_of(work, struct i40evf_adapter, reset_task); 1478 struct i40evf_adapter,
1479 reset_task);
1426 struct i40e_hw *hw = &adapter->hw; 1480 struct i40e_hw *hw = &adapter->hw;
1427 int i = 0, err; 1481 int i = 0, err;
1428 uint32_t rstat_val; 1482 uint32_t rstat_val;
@@ -1430,22 +1484,56 @@ static void i40evf_reset_task(struct work_struct *work)
1430 while (test_and_set_bit(__I40EVF_IN_CRITICAL_TASK, 1484 while (test_and_set_bit(__I40EVF_IN_CRITICAL_TASK,
1431 &adapter->crit_section)) 1485 &adapter->crit_section))
1432 udelay(500); 1486 udelay(500);
1487 /* poll until we see the reset actually happen */
1488 for (i = 0; i < I40EVF_RESET_WAIT_COUNT; i++) {
1489 rstat_val = rd32(hw, I40E_VFGEN_RSTAT) &
1490 I40E_VFGEN_RSTAT_VFR_STATE_MASK;
1491 if (rstat_val != I40E_VFR_VFACTIVE) {
1492 dev_info(&adapter->pdev->dev, "Reset now occurring\n");
1493 break;
1494 } else {
1495 msleep(I40EVF_RESET_WAIT_MS);
1496 }
1497 }
1498 if (i == I40EVF_RESET_WAIT_COUNT) {
1499 dev_err(&adapter->pdev->dev, "Reset was not detected\n");
1500 adapter->flags &= ~I40EVF_FLAG_RESET_PENDING;
1501 goto continue_reset; /* act like the reset happened */
1502 }
1433 1503
1434 /* wait until the reset is complete */ 1504 /* wait until the reset is complete and the PF is responding to us */
1435 for (i = 0; i < 20; i++) { 1505 for (i = 0; i < I40EVF_RESET_WAIT_COUNT; i++) {
1436 rstat_val = rd32(hw, I40E_VFGEN_RSTAT) & 1506 rstat_val = rd32(hw, I40E_VFGEN_RSTAT) &
1437 I40E_VFGEN_RSTAT_VFR_STATE_MASK; 1507 I40E_VFGEN_RSTAT_VFR_STATE_MASK;
1438 if (rstat_val == I40E_VFR_COMPLETED) 1508 if (rstat_val == I40E_VFR_VFACTIVE) {
1509 dev_info(&adapter->pdev->dev, "Reset is complete. Reinitializing.\n");
1439 break; 1510 break;
1440 else 1511 } else {
1441 mdelay(100); 1512 msleep(I40EVF_RESET_WAIT_MS);
1513 }
1442 } 1514 }
1443 if (i == 20) { 1515 if (i == I40EVF_RESET_WAIT_COUNT) {
1444 /* reset never finished */ 1516 /* reset never finished */
1445 dev_info(&adapter->pdev->dev, "%s: reset never finished: %x\n", 1517 dev_err(&adapter->pdev->dev, "Reset never finished (%x). PF driver is dead, and so am I.\n",
1446 __func__, rstat_val); 1518 rstat_val);
1447 /* carry on anyway */ 1519 adapter->flags |= I40EVF_FLAG_PF_COMMS_FAILED;
1520
1521 if (netif_running(adapter->netdev))
1522 i40evf_close(adapter->netdev);
1523
1524 i40evf_free_misc_irq(adapter);
1525 i40evf_reset_interrupt_capability(adapter);
1526 i40evf_free_queues(adapter);
1527 kfree(adapter->vf_res);
1528 i40evf_shutdown_adminq(hw);
1529 adapter->netdev->flags &= ~IFF_UP;
1530 clear_bit(__I40EVF_IN_CRITICAL_TASK, &adapter->crit_section);
1531 return; /* Do not attempt to reinit. It's dead, Jim. */
1448 } 1532 }
1533
1534continue_reset:
1535 adapter->flags &= ~I40EVF_FLAG_RESET_PENDING;
1536
1449 i40evf_down(adapter); 1537 i40evf_down(adapter);
1450 adapter->state = __I40EVF_RESETTING; 1538 adapter->state = __I40EVF_RESETTING;
1451 1539
@@ -1505,6 +1593,9 @@ static void i40evf_adminq_task(struct work_struct *work)
1505 i40e_status ret; 1593 i40e_status ret;
1506 u16 pending; 1594 u16 pending;
1507 1595
1596 if (adapter->flags & I40EVF_FLAG_PF_COMMS_FAILED)
1597 return;
1598
1508 event.msg_size = I40EVF_MAX_AQ_BUF_SIZE; 1599 event.msg_size = I40EVF_MAX_AQ_BUF_SIZE;
1509 event.msg_buf = kzalloc(event.msg_size, GFP_KERNEL); 1600 event.msg_buf = kzalloc(event.msg_size, GFP_KERNEL);
1510 if (!event.msg_buf) { 1601 if (!event.msg_buf) {
@@ -1636,6 +1727,10 @@ static int i40evf_open(struct net_device *netdev)
1636 struct i40evf_adapter *adapter = netdev_priv(netdev); 1727 struct i40evf_adapter *adapter = netdev_priv(netdev);
1637 int err; 1728 int err;
1638 1729
1730 if (adapter->flags & I40EVF_FLAG_PF_COMMS_FAILED) {
1731 dev_err(&adapter->pdev->dev, "Unable to open device due to PF driver failure.\n");
1732 return -EIO;
1733 }
1639 if (adapter->state != __I40EVF_DOWN) 1734 if (adapter->state != __I40EVF_DOWN)
1640 return -EBUSY; 1735 return -EBUSY;
1641 1736
@@ -1690,8 +1785,12 @@ static int i40evf_close(struct net_device *netdev)
1690{ 1785{
1691 struct i40evf_adapter *adapter = netdev_priv(netdev); 1786 struct i40evf_adapter *adapter = netdev_priv(netdev);
1692 1787
1788 if (adapter->state <= __I40EVF_DOWN)
1789 return 0;
1790
1693 /* signal that we are down to the interrupt handler */ 1791 /* signal that we are down to the interrupt handler */
1694 adapter->state = __I40EVF_DOWN; 1792 adapter->state = __I40EVF_DOWN;
1793
1695 set_bit(__I40E_DOWN, &adapter->vsi.state); 1794 set_bit(__I40E_DOWN, &adapter->vsi.state);
1696 1795
1697 i40evf_down(adapter); 1796 i40evf_down(adapter);
@@ -1842,16 +1941,18 @@ static void i40evf_init_task(struct work_struct *work)
1842 switch (adapter->state) { 1941 switch (adapter->state) {
1843 case __I40EVF_STARTUP: 1942 case __I40EVF_STARTUP:
1844 /* driver loaded, probe complete */ 1943 /* driver loaded, probe complete */
1944 adapter->flags &= ~I40EVF_FLAG_PF_COMMS_FAILED;
1945 adapter->flags &= ~I40EVF_FLAG_RESET_PENDING;
1845 err = i40e_set_mac_type(hw); 1946 err = i40e_set_mac_type(hw);
1846 if (err) { 1947 if (err) {
1847 dev_info(&pdev->dev, "%s: set_mac_type failed: %d\n", 1948 dev_err(&pdev->dev, "Failed to set MAC type (%d)\n",
1848 __func__, err); 1949 err);
1849 goto err; 1950 goto err;
1850 } 1951 }
1851 err = i40evf_check_reset_complete(hw); 1952 err = i40evf_check_reset_complete(hw);
1852 if (err) { 1953 if (err) {
1853 dev_info(&pdev->dev, "%s: device is still in reset (%d).\n", 1954 dev_err(&pdev->dev, "Device is still in reset (%d)\n",
1854 __func__, err); 1955 err);
1855 goto err; 1956 goto err;
1856 } 1957 }
1857 hw->aq.num_arq_entries = I40EVF_AQ_LEN; 1958 hw->aq.num_arq_entries = I40EVF_AQ_LEN;
@@ -1861,14 +1962,13 @@ static void i40evf_init_task(struct work_struct *work)
1861 1962
1862 err = i40evf_init_adminq(hw); 1963 err = i40evf_init_adminq(hw);
1863 if (err) { 1964 if (err) {
1864 dev_info(&pdev->dev, "%s: init_adminq failed: %d\n", 1965 dev_err(&pdev->dev, "Failed to init Admin Queue (%d)\n",
1865 __func__, err); 1966 err);
1866 goto err; 1967 goto err;
1867 } 1968 }
1868 err = i40evf_send_api_ver(adapter); 1969 err = i40evf_send_api_ver(adapter);
1869 if (err) { 1970 if (err) {
1870 dev_info(&pdev->dev, "%s: unable to send to PF (%d)\n", 1971 dev_err(&pdev->dev, "Unable to send to PF (%d)\n", err);
1871 __func__, err);
1872 i40evf_shutdown_adminq(hw); 1972 i40evf_shutdown_adminq(hw);
1873 goto err; 1973 goto err;
1874 } 1974 }
@@ -1876,19 +1976,21 @@ static void i40evf_init_task(struct work_struct *work)
1876 goto restart; 1976 goto restart;
1877 break; 1977 break;
1878 case __I40EVF_INIT_VERSION_CHECK: 1978 case __I40EVF_INIT_VERSION_CHECK:
1879 if (!i40evf_asq_done(hw)) 1979 if (!i40evf_asq_done(hw)) {
1980 dev_err(&pdev->dev, "Admin queue command never completed.\n");
1880 goto err; 1981 goto err;
1982 }
1881 1983
1882 /* aq msg sent, awaiting reply */ 1984 /* aq msg sent, awaiting reply */
1883 err = i40evf_verify_api_ver(adapter); 1985 err = i40evf_verify_api_ver(adapter);
1884 if (err) { 1986 if (err) {
1885 dev_err(&pdev->dev, "Unable to verify API version, error %d\n", 1987 dev_err(&pdev->dev, "Unable to verify API version (%d)\n",
1886 err); 1988 err);
1887 goto err; 1989 goto err;
1888 } 1990 }
1889 err = i40evf_send_vf_config_msg(adapter); 1991 err = i40evf_send_vf_config_msg(adapter);
1890 if (err) { 1992 if (err) {
1891 dev_err(&pdev->dev, "Unable send config request, error %d\n", 1993 dev_err(&pdev->dev, "Unable send config request (%d)\n",
1892 err); 1994 err);
1893 goto err; 1995 goto err;
1894 } 1996 }
@@ -1902,18 +2004,15 @@ static void i40evf_init_task(struct work_struct *work)
1902 (I40E_MAX_VF_VSI * 2004 (I40E_MAX_VF_VSI *
1903 sizeof(struct i40e_virtchnl_vsi_resource)); 2005 sizeof(struct i40e_virtchnl_vsi_resource));
1904 adapter->vf_res = kzalloc(bufsz, GFP_KERNEL); 2006 adapter->vf_res = kzalloc(bufsz, GFP_KERNEL);
1905 if (!adapter->vf_res) { 2007 if (!adapter->vf_res)
1906 dev_err(&pdev->dev, "%s: unable to allocate memory\n",
1907 __func__);
1908 goto err; 2008 goto err;
1909 }
1910 } 2009 }
1911 err = i40evf_get_vf_config(adapter); 2010 err = i40evf_get_vf_config(adapter);
1912 if (err == I40E_ERR_ADMIN_QUEUE_NO_WORK) 2011 if (err == I40E_ERR_ADMIN_QUEUE_NO_WORK)
1913 goto restart; 2012 goto restart;
1914 if (err) { 2013 if (err) {
1915 dev_info(&pdev->dev, "%s: unable to get VF config (%d)\n", 2014 dev_err(&pdev->dev, "Unable to get VF config (%d)\n",
1916 __func__, err); 2015 err);
1917 goto err_alloc; 2016 goto err_alloc;
1918 } 2017 }
1919 adapter->state = __I40EVF_INIT_SW; 2018 adapter->state = __I40EVF_INIT_SW;
@@ -1927,25 +2026,23 @@ static void i40evf_init_task(struct work_struct *work)
1927 adapter->vsi_res = &adapter->vf_res->vsi_res[i]; 2026 adapter->vsi_res = &adapter->vf_res->vsi_res[i];
1928 } 2027 }
1929 if (!adapter->vsi_res) { 2028 if (!adapter->vsi_res) {
1930 dev_info(&pdev->dev, "%s: no LAN VSI found\n", __func__); 2029 dev_err(&pdev->dev, "No LAN VSI found\n");
1931 goto err_alloc; 2030 goto err_alloc;
1932 } 2031 }
1933 2032
1934 adapter->flags |= I40EVF_FLAG_RX_CSUM_ENABLED; 2033 adapter->flags |= I40EVF_FLAG_RX_CSUM_ENABLED;
1935 2034
1936 adapter->txd_count = I40EVF_DEFAULT_TXD;
1937 adapter->rxd_count = I40EVF_DEFAULT_RXD;
1938
1939 netdev->netdev_ops = &i40evf_netdev_ops; 2035 netdev->netdev_ops = &i40evf_netdev_ops;
1940 i40evf_set_ethtool_ops(netdev); 2036 i40evf_set_ethtool_ops(netdev);
1941 netdev->watchdog_timeo = 5 * HZ; 2037 netdev->watchdog_timeo = 5 * HZ;
1942 2038 netdev->features |= NETIF_F_HIGHDMA |
1943 netdev->features |= NETIF_F_SG | 2039 NETIF_F_SG |
1944 NETIF_F_IP_CSUM | 2040 NETIF_F_IP_CSUM |
1945 NETIF_F_SCTP_CSUM | 2041 NETIF_F_SCTP_CSUM |
1946 NETIF_F_IPV6_CSUM | 2042 NETIF_F_IPV6_CSUM |
1947 NETIF_F_TSO | 2043 NETIF_F_TSO |
1948 NETIF_F_TSO6 | 2044 NETIF_F_TSO6 |
2045 NETIF_F_RXCSUM |
1949 NETIF_F_GRO; 2046 NETIF_F_GRO;
1950 2047
1951 if (adapter->vf_res->vf_offload_flags 2048 if (adapter->vf_res->vf_offload_flags
@@ -1956,11 +2053,13 @@ static void i40evf_init_task(struct work_struct *work)
1956 NETIF_F_HW_VLAN_CTAG_FILTER; 2053 NETIF_F_HW_VLAN_CTAG_FILTER;
1957 } 2054 }
1958 2055
1959 /* The HW MAC address was set and/or determined in sw_init */ 2056 /* copy netdev features into list of user selectable features */
2057 netdev->hw_features |= netdev->features;
2058 netdev->hw_features &= ~NETIF_F_RXCSUM;
2059
1960 if (!is_valid_ether_addr(adapter->hw.mac.addr)) { 2060 if (!is_valid_ether_addr(adapter->hw.mac.addr)) {
1961 dev_info(&pdev->dev, 2061 dev_info(&pdev->dev, "Invalid MAC address %pMAC, using random\n",
1962 "Invalid MAC address %pMAC, using random\n", 2062 adapter->hw.mac.addr);
1963 adapter->hw.mac.addr);
1964 random_ether_addr(adapter->hw.mac.addr); 2063 random_ether_addr(adapter->hw.mac.addr);
1965 } 2064 }
1966 memcpy(netdev->dev_addr, adapter->hw.mac.addr, netdev->addr_len); 2065 memcpy(netdev->dev_addr, adapter->hw.mac.addr, netdev->addr_len);
@@ -1994,8 +2093,6 @@ static void i40evf_init_task(struct work_struct *work)
1994 2093
1995 netif_carrier_off(netdev); 2094 netif_carrier_off(netdev);
1996 2095
1997 strcpy(netdev->name, "eth%d");
1998
1999 adapter->vsi.id = adapter->vsi_res->vsi_id; 2096 adapter->vsi.id = adapter->vsi_res->vsi_id;
2000 adapter->vsi.seid = adapter->vsi_res->vsi_id; /* dummy */ 2097 adapter->vsi.seid = adapter->vsi_res->vsi_id; /* dummy */
2001 adapter->vsi.back = adapter; 2098 adapter->vsi.back = adapter;
@@ -2005,9 +2102,11 @@ static void i40evf_init_task(struct work_struct *work)
2005 adapter->vsi.tx_itr_setting = I40E_ITR_DYNAMIC; 2102 adapter->vsi.tx_itr_setting = I40E_ITR_DYNAMIC;
2006 adapter->vsi.netdev = adapter->netdev; 2103 adapter->vsi.netdev = adapter->netdev;
2007 2104
2008 err = register_netdev(netdev); 2105 if (!adapter->netdev_registered) {
2009 if (err) 2106 err = register_netdev(netdev);
2010 goto err_register; 2107 if (err)
2108 goto err_register;
2109 }
2011 2110
2012 adapter->netdev_registered = true; 2111 adapter->netdev_registered = true;
2013 2112
@@ -2031,7 +2130,6 @@ err_register:
2031 i40evf_free_misc_irq(adapter); 2130 i40evf_free_misc_irq(adapter);
2032err_sw_init: 2131err_sw_init:
2033 i40evf_reset_interrupt_capability(adapter); 2132 i40evf_reset_interrupt_capability(adapter);
2034 adapter->state = __I40EVF_FAILED;
2035err_alloc: 2133err_alloc:
2036 kfree(adapter->vf_res); 2134 kfree(adapter->vf_res);
2037 adapter->vf_res = NULL; 2135 adapter->vf_res = NULL;
@@ -2039,9 +2137,7 @@ err:
2039 /* Things went into the weeds, so try again later */ 2137 /* Things went into the weeds, so try again later */
2040 if (++adapter->aq_wait_count > I40EVF_AQ_MAX_ERR) { 2138 if (++adapter->aq_wait_count > I40EVF_AQ_MAX_ERR) {
2041 dev_err(&pdev->dev, "Failed to communicate with PF; giving up.\n"); 2139 dev_err(&pdev->dev, "Failed to communicate with PF; giving up.\n");
2042 if (hw->aq.asq.count) 2140 adapter->flags |= I40EVF_FLAG_PF_COMMS_FAILED;
2043 i40evf_shutdown_adminq(hw); /* ignore error */
2044 adapter->state = __I40EVF_FAILED;
2045 return; /* do not reschedule */ 2141 return; /* do not reschedule */
2046 } 2142 }
2047 schedule_delayed_work(&adapter->init_task, HZ * 3); 2143 schedule_delayed_work(&adapter->init_task, HZ * 3);
@@ -2084,25 +2180,18 @@ static int i40evf_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
2084 struct net_device *netdev; 2180 struct net_device *netdev;
2085 struct i40evf_adapter *adapter = NULL; 2181 struct i40evf_adapter *adapter = NULL;
2086 struct i40e_hw *hw = NULL; 2182 struct i40e_hw *hw = NULL;
2087 int err, pci_using_dac; 2183 int err;
2088 2184
2089 err = pci_enable_device(pdev); 2185 err = pci_enable_device(pdev);
2090 if (err) 2186 if (err)
2091 return err; 2187 return err;
2092 2188
2093 if (!dma_set_mask(&pdev->dev, DMA_BIT_MASK(64))) { 2189 err = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64));
2094 pci_using_dac = true; 2190 if (err)
2095 /* coherent mask for the same size will always succeed if 2191 err = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32));
2096 * dma_set_mask does 2192 if (err) {
2097 */ 2193 dev_err(&pdev->dev,
2098 dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(64)); 2194 "DMA configuration failed: 0x%x\n", err);
2099 } else if (!dma_set_mask(&pdev->dev, DMA_BIT_MASK(32))) {
2100 pci_using_dac = false;
2101 dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(32));
2102 } else {
2103 dev_err(&pdev->dev, "%s: DMA configuration failed: %d\n",
2104 __func__, err);
2105 err = -EIO;
2106 goto err_dma; 2195 goto err_dma;
2107 } 2196 }
2108 2197
@@ -2128,8 +2217,6 @@ static int i40evf_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
2128 2217
2129 pci_set_drvdata(pdev, netdev); 2218 pci_set_drvdata(pdev, netdev);
2130 adapter = netdev_priv(netdev); 2219 adapter = netdev_priv(netdev);
2131 if (pci_using_dac)
2132 netdev->features |= NETIF_F_HIGHDMA;
2133 2220
2134 adapter->netdev = netdev; 2221 adapter->netdev = netdev;
2135 adapter->pdev = pdev; 2222 adapter->pdev = pdev;
@@ -2271,6 +2358,7 @@ static void i40evf_remove(struct pci_dev *pdev)
2271 struct i40e_hw *hw = &adapter->hw; 2358 struct i40e_hw *hw = &adapter->hw;
2272 2359
2273 cancel_delayed_work_sync(&adapter->init_task); 2360 cancel_delayed_work_sync(&adapter->init_task);
2361 cancel_work_sync(&adapter->reset_task);
2274 2362
2275 if (adapter->netdev_registered) { 2363 if (adapter->netdev_registered) {
2276 unregister_netdev(netdev); 2364 unregister_netdev(netdev);
@@ -2278,17 +2366,15 @@ static void i40evf_remove(struct pci_dev *pdev)
2278 } 2366 }
2279 adapter->state = __I40EVF_REMOVE; 2367 adapter->state = __I40EVF_REMOVE;
2280 2368
2281 if (adapter->num_msix_vectors) { 2369 if (adapter->msix_entries) {
2282 i40evf_misc_irq_disable(adapter); 2370 i40evf_misc_irq_disable(adapter);
2283 del_timer_sync(&adapter->watchdog_timer);
2284
2285 flush_scheduled_work();
2286
2287 i40evf_free_misc_irq(adapter); 2371 i40evf_free_misc_irq(adapter);
2288
2289 i40evf_reset_interrupt_capability(adapter); 2372 i40evf_reset_interrupt_capability(adapter);
2290 } 2373 }
2291 2374
2375 del_timer_sync(&adapter->watchdog_timer);
2376 flush_scheduled_work();
2377
2292 if (hw->aq.asq.count) 2378 if (hw->aq.asq.count)
2293 i40evf_shutdown_adminq(hw); 2379 i40evf_shutdown_adminq(hw);
2294 2380
diff --git a/drivers/net/ethernet/intel/i40evf/i40evf_virtchnl.c b/drivers/net/ethernet/intel/i40evf/i40evf_virtchnl.c
index e6978d79e62b..e294f012647d 100644
--- a/drivers/net/ethernet/intel/i40evf/i40evf_virtchnl.c
+++ b/drivers/net/ethernet/intel/i40evf/i40evf_virtchnl.c
@@ -1,7 +1,7 @@
1/******************************************************************************* 1/*******************************************************************************
2 * 2 *
3 * Intel Ethernet Controller XL710 Family Linux Virtual Function Driver 3 * Intel Ethernet Controller XL710 Family Linux Virtual Function Driver
4 * Copyright(c) 2013 Intel Corporation. 4 * Copyright(c) 2013 - 2014 Intel Corporation.
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify it 6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms and conditions of the GNU General Public License, 7 * under the terms and conditions of the GNU General Public License,
@@ -43,6 +43,9 @@ static int i40evf_send_pf_msg(struct i40evf_adapter *adapter,
43 struct i40e_hw *hw = &adapter->hw; 43 struct i40e_hw *hw = &adapter->hw;
44 i40e_status err; 44 i40e_status err;
45 45
46 if (adapter->flags & I40EVF_FLAG_PF_COMMS_FAILED)
47 return 0; /* nothing to see here, move along */
48
46 err = i40e_aq_send_msg_to_pf(hw, op, 0, msg, len, NULL); 49 err = i40e_aq_send_msg_to_pf(hw, op, 0, msg, len, NULL);
47 if (err) 50 if (err)
48 dev_err(&adapter->pdev->dev, "Unable to send opcode %d to PF, error %d, aq status %d\n", 51 dev_err(&adapter->pdev->dev, "Unable to send opcode %d to PF, error %d, aq status %d\n",
@@ -651,6 +654,18 @@ void i40evf_request_stats(struct i40evf_adapter *adapter)
651 /* if the request failed, don't lock out others */ 654 /* if the request failed, don't lock out others */
652 adapter->current_op = I40E_VIRTCHNL_OP_UNKNOWN; 655 adapter->current_op = I40E_VIRTCHNL_OP_UNKNOWN;
653} 656}
657/**
658 * i40evf_request_reset
659 * @adapter: adapter structure
660 *
661 * Request that the PF reset this VF. No response is expected.
662 **/
663void i40evf_request_reset(struct i40evf_adapter *adapter)
664{
665 /* Don't check CURRENT_OP - this is always higher priority */
666 i40evf_send_pf_msg(adapter, I40E_VIRTCHNL_OP_RESET_VF, NULL, 0);
667 adapter->current_op = I40E_VIRTCHNL_OP_UNKNOWN;
668}
654 669
655/** 670/**
656 * i40evf_virtchnl_completion 671 * i40evf_virtchnl_completion
@@ -689,10 +704,12 @@ void i40evf_virtchnl_completion(struct i40evf_adapter *adapter,
689 } 704 }
690 break; 705 break;
691 case I40E_VIRTCHNL_EVENT_RESET_IMPENDING: 706 case I40E_VIRTCHNL_EVENT_RESET_IMPENDING:
692 adapter->state = __I40EVF_RESETTING; 707 dev_info(&adapter->pdev->dev, "PF reset warning received\n");
693 schedule_work(&adapter->reset_task); 708 if (!(adapter->flags & I40EVF_FLAG_RESET_PENDING)) {
694 dev_info(&adapter->pdev->dev, 709 adapter->flags |= I40EVF_FLAG_RESET_PENDING;
695 "%s: hardware reset pending\n", __func__); 710 dev_info(&adapter->pdev->dev, "Scheduling reset task\n");
711 schedule_work(&adapter->reset_task);
712 }
696 break; 713 break;
697 default: 714 default:
698 dev_err(&adapter->pdev->dev, 715 dev_err(&adapter->pdev->dev,
diff --git a/drivers/net/ethernet/intel/igb/Makefile b/drivers/net/ethernet/intel/igb/Makefile
index f19700e285bb..5bcb2de75933 100644
--- a/drivers/net/ethernet/intel/igb/Makefile
+++ b/drivers/net/ethernet/intel/igb/Makefile
@@ -1,7 +1,7 @@
1################################################################################ 1################################################################################
2# 2#
3# Intel 82575 PCI-Express Ethernet Linux driver 3# Intel 82575 PCI-Express Ethernet Linux driver
4# Copyright(c) 1999 - 2013 Intel Corporation. 4# Copyright(c) 1999 - 2014 Intel Corporation.
5# 5#
6# This program is free software; you can redistribute it and/or modify it 6# This program is free software; you can redistribute it and/or modify it
7# under the terms and conditions of the GNU General Public License, 7# under the terms and conditions of the GNU General Public License,
@@ -13,8 +13,7 @@
13# more details. 13# more details.
14# 14#
15# You should have received a copy of the GNU General Public License along with 15# You should have received a copy of the GNU General Public License along with
16# this program; if not, write to the Free Software Foundation, Inc., 16# this program; if not, see <http://www.gnu.org/licenses/>.
17# 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
18# 17#
19# The full GNU General Public License is included in this distribution in 18# The full GNU General Public License is included in this distribution in
20# the file called "COPYING". 19# the file called "COPYING".
diff --git a/drivers/net/ethernet/intel/igb/e1000_82575.c b/drivers/net/ethernet/intel/igb/e1000_82575.c
index 06df6928f44c..fa36fe12e775 100644
--- a/drivers/net/ethernet/intel/igb/e1000_82575.c
+++ b/drivers/net/ethernet/intel/igb/e1000_82575.c
@@ -1,7 +1,7 @@
1/******************************************************************************* 1/*******************************************************************************
2 2
3 Intel(R) Gigabit Ethernet Linux driver 3 Intel(R) Gigabit Ethernet Linux driver
4 Copyright(c) 2007-2013 Intel Corporation. 4 Copyright(c) 2007-2014 Intel Corporation.
5 5
6 This program is free software; you can redistribute it and/or modify it 6 This program is free software; you can redistribute it and/or modify it
7 under the terms and conditions of the GNU General Public License, 7 under the terms and conditions of the GNU General Public License,
@@ -13,8 +13,7 @@
13 more details. 13 more details.
14 14
15 You should have received a copy of the GNU General Public License along with 15 You should have received a copy of the GNU General Public License along with
16 this program; if not, write to the Free Software Foundation, Inc., 16 this program; if not, see <http://www.gnu.org/licenses/>.
17 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
18 17
19 The full GNU General Public License is included in this distribution in 18 The full GNU General Public License is included in this distribution in
20 the file called "COPYING". 19 the file called "COPYING".
@@ -77,8 +76,6 @@ static s32 igb_update_nvm_checksum_i350(struct e1000_hw *hw);
77static const u16 e1000_82580_rxpbs_table[] = 76static const u16 e1000_82580_rxpbs_table[] =
78 { 36, 72, 144, 1, 2, 4, 8, 16, 77 { 36, 72, 144, 1, 2, 4, 8, 16,
79 35, 70, 140 }; 78 35, 70, 140 };
80#define E1000_82580_RXPBS_TABLE_SIZE \
81 (sizeof(e1000_82580_rxpbs_table)/sizeof(u16))
82 79
83/** 80/**
84 * igb_sgmii_uses_mdio_82575 - Determine if I2C pins are for external MDIO 81 * igb_sgmii_uses_mdio_82575 - Determine if I2C pins are for external MDIO
@@ -2308,7 +2305,7 @@ u16 igb_rxpbs_adjust_82580(u32 data)
2308{ 2305{
2309 u16 ret_val = 0; 2306 u16 ret_val = 0;
2310 2307
2311 if (data < E1000_82580_RXPBS_TABLE_SIZE) 2308 if (data < ARRAY_SIZE(e1000_82580_rxpbs_table))
2312 ret_val = e1000_82580_rxpbs_table[data]; 2309 ret_val = e1000_82580_rxpbs_table[data];
2313 2310
2314 return ret_val; 2311 return ret_val;
@@ -2714,13 +2711,14 @@ static const u8 e1000_emc_therm_limit[4] = {
2714 E1000_EMC_DIODE3_THERM_LIMIT 2711 E1000_EMC_DIODE3_THERM_LIMIT
2715}; 2712};
2716 2713
2714#ifdef CONFIG_IGB_HWMON
2717/** 2715/**
2718 * igb_get_thermal_sensor_data_generic - Gathers thermal sensor data 2716 * igb_get_thermal_sensor_data_generic - Gathers thermal sensor data
2719 * @hw: pointer to hardware structure 2717 * @hw: pointer to hardware structure
2720 * 2718 *
2721 * Updates the temperatures in mac.thermal_sensor_data 2719 * Updates the temperatures in mac.thermal_sensor_data
2722 **/ 2720 **/
2723s32 igb_get_thermal_sensor_data_generic(struct e1000_hw *hw) 2721static s32 igb_get_thermal_sensor_data_generic(struct e1000_hw *hw)
2724{ 2722{
2725 s32 status = E1000_SUCCESS; 2723 s32 status = E1000_SUCCESS;
2726 u16 ets_offset; 2724 u16 ets_offset;
@@ -2774,7 +2772,7 @@ s32 igb_get_thermal_sensor_data_generic(struct e1000_hw *hw)
2774 * Sets the thermal sensor thresholds according to the NVM map 2772 * Sets the thermal sensor thresholds according to the NVM map
2775 * and save off the threshold and location values into mac.thermal_sensor_data 2773 * and save off the threshold and location values into mac.thermal_sensor_data
2776 **/ 2774 **/
2777s32 igb_init_thermal_sensor_thresh_generic(struct e1000_hw *hw) 2775static s32 igb_init_thermal_sensor_thresh_generic(struct e1000_hw *hw)
2778{ 2776{
2779 s32 status = E1000_SUCCESS; 2777 s32 status = E1000_SUCCESS;
2780 u16 ets_offset; 2778 u16 ets_offset;
@@ -2836,6 +2834,7 @@ s32 igb_init_thermal_sensor_thresh_generic(struct e1000_hw *hw)
2836 return status; 2834 return status;
2837} 2835}
2838 2836
2837#endif
2839static struct e1000_mac_operations e1000_mac_ops_82575 = { 2838static struct e1000_mac_operations e1000_mac_ops_82575 = {
2840 .init_hw = igb_init_hw_82575, 2839 .init_hw = igb_init_hw_82575,
2841 .check_for_link = igb_check_for_link_82575, 2840 .check_for_link = igb_check_for_link_82575,
diff --git a/drivers/net/ethernet/intel/igb/e1000_82575.h b/drivers/net/ethernet/intel/igb/e1000_82575.h
index 8c2437722aad..09d78be72416 100644
--- a/drivers/net/ethernet/intel/igb/e1000_82575.h
+++ b/drivers/net/ethernet/intel/igb/e1000_82575.h
@@ -1,7 +1,7 @@
1/******************************************************************************* 1/*******************************************************************************
2 2
3 Intel(R) Gigabit Ethernet Linux driver 3 Intel(R) Gigabit Ethernet Linux driver
4 Copyright(c) 2007-2013 Intel Corporation. 4 Copyright(c) 2007-2014 Intel Corporation.
5 5
6 This program is free software; you can redistribute it and/or modify it 6 This program is free software; you can redistribute it and/or modify it
7 under the terms and conditions of the GNU General Public License, 7 under the terms and conditions of the GNU General Public License,
@@ -13,8 +13,7 @@
13 more details. 13 more details.
14 14
15 You should have received a copy of the GNU General Public License along with 15 You should have received a copy of the GNU General Public License along with
16 this program; if not, write to the Free Software Foundation, Inc., 16 this program; if not, see <http://www.gnu.org/licenses/>.
17 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
18 17
19 The full GNU General Public License is included in this distribution in 18 The full GNU General Public License is included in this distribution in
20 the file called "COPYING". 19 the file called "COPYING".
@@ -231,6 +230,10 @@ struct e1000_adv_tx_context_desc {
231#define E1000_VMOLR_STRVLAN 0x40000000 /* Vlan stripping enable */ 230#define E1000_VMOLR_STRVLAN 0x40000000 /* Vlan stripping enable */
232#define E1000_VMOLR_STRCRC 0x80000000 /* CRC stripping enable */ 231#define E1000_VMOLR_STRCRC 0x80000000 /* CRC stripping enable */
233 232
233#define E1000_DVMOLR_HIDEVLAN 0x20000000 /* Hide vlan enable */
234#define E1000_DVMOLR_STRVLAN 0x40000000 /* Vlan stripping enable */
235#define E1000_DVMOLR_STRCRC 0x80000000 /* CRC stripping enable */
236
234#define E1000_VLVF_ARRAY_SIZE 32 237#define E1000_VLVF_ARRAY_SIZE 32
235#define E1000_VLVF_VLANID_MASK 0x00000FFF 238#define E1000_VLVF_VLANID_MASK 0x00000FFF
236#define E1000_VLVF_POOLSEL_SHIFT 12 239#define E1000_VLVF_POOLSEL_SHIFT 12
@@ -266,8 +269,7 @@ u16 igb_rxpbs_adjust_82580(u32 data);
266s32 igb_read_emi_reg(struct e1000_hw *, u16 addr, u16 *data); 269s32 igb_read_emi_reg(struct e1000_hw *, u16 addr, u16 *data);
267s32 igb_set_eee_i350(struct e1000_hw *); 270s32 igb_set_eee_i350(struct e1000_hw *);
268s32 igb_set_eee_i354(struct e1000_hw *); 271s32 igb_set_eee_i354(struct e1000_hw *);
269s32 igb_init_thermal_sensor_thresh_generic(struct e1000_hw *); 272s32 igb_get_eee_status_i354(struct e1000_hw *hw, bool *status);
270s32 igb_get_thermal_sensor_data_generic(struct e1000_hw *hw);
271 273
272#define E1000_I2C_THERMAL_SENSOR_ADDR 0xF8 274#define E1000_I2C_THERMAL_SENSOR_ADDR 0xF8
273#define E1000_EMC_INTERNAL_DATA 0x00 275#define E1000_EMC_INTERNAL_DATA 0x00
diff --git a/drivers/net/ethernet/intel/igb/e1000_defines.h b/drivers/net/ethernet/intel/igb/e1000_defines.h
index 0571b973be80..b05bf925ac72 100644
--- a/drivers/net/ethernet/intel/igb/e1000_defines.h
+++ b/drivers/net/ethernet/intel/igb/e1000_defines.h
@@ -1,7 +1,7 @@
1/******************************************************************************* 1/*******************************************************************************
2 2
3 Intel(R) Gigabit Ethernet Linux driver 3 Intel(R) Gigabit Ethernet Linux driver
4 Copyright(c) 2007-2013 Intel Corporation. 4 Copyright(c) 2007-2014 Intel Corporation.
5 5
6 This program is free software; you can redistribute it and/or modify it 6 This program is free software; you can redistribute it and/or modify it
7 under the terms and conditions of the GNU General Public License, 7 under the terms and conditions of the GNU General Public License,
@@ -13,8 +13,7 @@
13 more details. 13 more details.
14 14
15 You should have received a copy of the GNU General Public License along with 15 You should have received a copy of the GNU General Public License along with
16 this program; if not, write to the Free Software Foundation, Inc., 16 this program; if not, see <http://www.gnu.org/licenses/>.
17 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
18 17
19 The full GNU General Public License is included in this distribution in 18 The full GNU General Public License is included in this distribution in
20 the file called "COPYING". 19 the file called "COPYING".
@@ -44,7 +43,11 @@
44#define E1000_WUFC_BC 0x00000010 /* Broadcast Wakeup Enable */ 43#define E1000_WUFC_BC 0x00000010 /* Broadcast Wakeup Enable */
45 44
46/* Extended Device Control */ 45/* Extended Device Control */
46#define E1000_CTRL_EXT_SDP2_DATA 0x00000040 /* Value of SW Defineable Pin 2 */
47#define E1000_CTRL_EXT_SDP3_DATA 0x00000080 /* Value of SW Defineable Pin 3 */ 47#define E1000_CTRL_EXT_SDP3_DATA 0x00000080 /* Value of SW Defineable Pin 3 */
48#define E1000_CTRL_EXT_SDP2_DIR 0x00000400 /* SDP2 Data direction */
49#define E1000_CTRL_EXT_SDP3_DIR 0x00000800 /* SDP3 Data direction */
50
48/* Physical Func Reset Done Indication */ 51/* Physical Func Reset Done Indication */
49#define E1000_CTRL_EXT_PFRSTD 0x00004000 52#define E1000_CTRL_EXT_PFRSTD 0x00004000
50#define E1000_CTRL_EXT_LINK_MODE_MASK 0x00C00000 53#define E1000_CTRL_EXT_LINK_MODE_MASK 0x00C00000
@@ -191,7 +194,8 @@
191/* enable link status from external LINK_0 and LINK_1 pins */ 194/* enable link status from external LINK_0 and LINK_1 pins */
192#define E1000_CTRL_SWDPIN0 0x00040000 /* SWDPIN 0 value */ 195#define E1000_CTRL_SWDPIN0 0x00040000 /* SWDPIN 0 value */
193#define E1000_CTRL_SWDPIN1 0x00080000 /* SWDPIN 1 value */ 196#define E1000_CTRL_SWDPIN1 0x00080000 /* SWDPIN 1 value */
194#define E1000_CTRL_SWDPIO0 0x00400000 /* SWDPIN 0 Input or output */ 197#define E1000_CTRL_SDP0_DIR 0x00400000 /* SDP0 Data direction */
198#define E1000_CTRL_SDP1_DIR 0x00800000 /* SDP1 Data direction */
195#define E1000_CTRL_RST 0x04000000 /* Global reset */ 199#define E1000_CTRL_RST 0x04000000 /* Global reset */
196#define E1000_CTRL_RFCE 0x08000000 /* Receive Flow Control enable */ 200#define E1000_CTRL_RFCE 0x08000000 /* Receive Flow Control enable */
197#define E1000_CTRL_TFCE 0x10000000 /* Transmit flow control enable */ 201#define E1000_CTRL_TFCE 0x10000000 /* Transmit flow control enable */
@@ -529,8 +533,67 @@
529 533
530#define E1000_TIMINCA_16NS_SHIFT 24 534#define E1000_TIMINCA_16NS_SHIFT 24
531 535
532#define E1000_TSICR_TXTS 0x00000002 536/* Time Sync Interrupt Cause/Mask Register Bits */
533#define E1000_TSIM_TXTS 0x00000002 537
538#define TSINTR_SYS_WRAP (1 << 0) /* SYSTIM Wrap around. */
539#define TSINTR_TXTS (1 << 1) /* Transmit Timestamp. */
540#define TSINTR_RXTS (1 << 2) /* Receive Timestamp. */
541#define TSINTR_TT0 (1 << 3) /* Target Time 0 Trigger. */
542#define TSINTR_TT1 (1 << 4) /* Target Time 1 Trigger. */
543#define TSINTR_AUTT0 (1 << 5) /* Auxiliary Timestamp 0 Taken. */
544#define TSINTR_AUTT1 (1 << 6) /* Auxiliary Timestamp 1 Taken. */
545#define TSINTR_TADJ (1 << 7) /* Time Adjust Done. */
546
547#define TSYNC_INTERRUPTS TSINTR_TXTS
548#define E1000_TSICR_TXTS TSINTR_TXTS
549
550/* TSAUXC Configuration Bits */
551#define TSAUXC_EN_TT0 (1 << 0) /* Enable target time 0. */
552#define TSAUXC_EN_TT1 (1 << 1) /* Enable target time 1. */
553#define TSAUXC_EN_CLK0 (1 << 2) /* Enable Configurable Frequency Clock 0. */
554#define TSAUXC_SAMP_AUT0 (1 << 3) /* Latch SYSTIML/H into AUXSTMPL/0. */
555#define TSAUXC_ST0 (1 << 4) /* Start Clock 0 Toggle on Target Time 0. */
556#define TSAUXC_EN_CLK1 (1 << 5) /* Enable Configurable Frequency Clock 1. */
557#define TSAUXC_SAMP_AUT1 (1 << 6) /* Latch SYSTIML/H into AUXSTMPL/1. */
558#define TSAUXC_ST1 (1 << 7) /* Start Clock 1 Toggle on Target Time 1. */
559#define TSAUXC_EN_TS0 (1 << 8) /* Enable hardware timestamp 0. */
560#define TSAUXC_AUTT0 (1 << 9) /* Auxiliary Timestamp Taken. */
561#define TSAUXC_EN_TS1 (1 << 10) /* Enable hardware timestamp 0. */
562#define TSAUXC_AUTT1 (1 << 11) /* Auxiliary Timestamp Taken. */
563#define TSAUXC_PLSG (1 << 17) /* Generate a pulse. */
564#define TSAUXC_DISABLE (1 << 31) /* Disable SYSTIM Count Operation. */
565
566/* SDP Configuration Bits */
567#define AUX0_SEL_SDP0 (0 << 0) /* Assign SDP0 to auxiliary time stamp 0. */
568#define AUX0_SEL_SDP1 (1 << 0) /* Assign SDP1 to auxiliary time stamp 0. */
569#define AUX0_SEL_SDP2 (2 << 0) /* Assign SDP2 to auxiliary time stamp 0. */
570#define AUX0_SEL_SDP3 (3 << 0) /* Assign SDP3 to auxiliary time stamp 0. */
571#define AUX0_TS_SDP_EN (1 << 2) /* Enable auxiliary time stamp trigger 0. */
572#define AUX1_SEL_SDP0 (0 << 3) /* Assign SDP0 to auxiliary time stamp 1. */
573#define AUX1_SEL_SDP1 (1 << 3) /* Assign SDP1 to auxiliary time stamp 1. */
574#define AUX1_SEL_SDP2 (2 << 3) /* Assign SDP2 to auxiliary time stamp 1. */
575#define AUX1_SEL_SDP3 (3 << 3) /* Assign SDP3 to auxiliary time stamp 1. */
576#define AUX1_TS_SDP_EN (1 << 5) /* Enable auxiliary time stamp trigger 1. */
577#define TS_SDP0_SEL_TT0 (0 << 6) /* Target time 0 is output on SDP0. */
578#define TS_SDP0_SEL_TT1 (1 << 6) /* Target time 1 is output on SDP0. */
579#define TS_SDP0_SEL_FC0 (2 << 6) /* Freq clock 0 is output on SDP0. */
580#define TS_SDP0_SEL_FC1 (3 << 6) /* Freq clock 1 is output on SDP0. */
581#define TS_SDP0_EN (1 << 8) /* SDP0 is assigned to Tsync. */
582#define TS_SDP1_SEL_TT0 (0 << 9) /* Target time 0 is output on SDP1. */
583#define TS_SDP1_SEL_TT1 (1 << 9) /* Target time 1 is output on SDP1. */
584#define TS_SDP1_SEL_FC0 (2 << 9) /* Freq clock 0 is output on SDP1. */
585#define TS_SDP1_SEL_FC1 (3 << 9) /* Freq clock 1 is output on SDP1. */
586#define TS_SDP1_EN (1 << 11) /* SDP1 is assigned to Tsync. */
587#define TS_SDP2_SEL_TT0 (0 << 12) /* Target time 0 is output on SDP2. */
588#define TS_SDP2_SEL_TT1 (1 << 12) /* Target time 1 is output on SDP2. */
589#define TS_SDP2_SEL_FC0 (2 << 12) /* Freq clock 0 is output on SDP2. */
590#define TS_SDP2_SEL_FC1 (3 << 12) /* Freq clock 1 is output on SDP2. */
591#define TS_SDP2_EN (1 << 14) /* SDP2 is assigned to Tsync. */
592#define TS_SDP3_SEL_TT0 (0 << 15) /* Target time 0 is output on SDP3. */
593#define TS_SDP3_SEL_TT1 (1 << 15) /* Target time 1 is output on SDP3. */
594#define TS_SDP3_SEL_FC0 (2 << 15) /* Freq clock 0 is output on SDP3. */
595#define TS_SDP3_SEL_FC1 (3 << 15) /* Freq clock 1 is output on SDP3. */
596#define TS_SDP3_EN (1 << 17) /* SDP3 is assigned to Tsync. */
534 597
535#define E1000_MDICNFG_EXT_MDIO 0x80000000 /* MDI ext/int destination */ 598#define E1000_MDICNFG_EXT_MDIO 0x80000000 /* MDI ext/int destination */
536#define E1000_MDICNFG_COM_MDIO 0x40000000 /* MDI shared w/ lan 0 */ 599#define E1000_MDICNFG_COM_MDIO 0x40000000 /* MDI shared w/ lan 0 */
diff --git a/drivers/net/ethernet/intel/igb/e1000_hw.h b/drivers/net/ethernet/intel/igb/e1000_hw.h
index ab99e2b582a8..10741d170f2d 100644
--- a/drivers/net/ethernet/intel/igb/e1000_hw.h
+++ b/drivers/net/ethernet/intel/igb/e1000_hw.h
@@ -1,7 +1,7 @@
1/******************************************************************************* 1/*******************************************************************************
2 2
3 Intel(R) Gigabit Ethernet Linux driver 3 Intel(R) Gigabit Ethernet Linux driver
4 Copyright(c) 2007-2013 Intel Corporation. 4 Copyright(c) 2007-2014 Intel Corporation.
5 5
6 This program is free software; you can redistribute it and/or modify it 6 This program is free software; you can redistribute it and/or modify it
7 under the terms and conditions of the GNU General Public License, 7 under the terms and conditions of the GNU General Public License,
@@ -13,8 +13,7 @@
13 more details. 13 more details.
14 14
15 You should have received a copy of the GNU General Public License along with 15 You should have received a copy of the GNU General Public License along with
16 this program; if not, write to the Free Software Foundation, Inc., 16 this program; if not, see <http://www.gnu.org/licenses/>.
17 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
18 17
19 The full GNU General Public License is included in this distribution in 18 The full GNU General Public License is included in this distribution in
20 the file called "COPYING". 19 the file called "COPYING".
diff --git a/drivers/net/ethernet/intel/igb/e1000_i210.c b/drivers/net/ethernet/intel/igb/e1000_i210.c
index 0c0393316a3a..db963397cc27 100644
--- a/drivers/net/ethernet/intel/igb/e1000_i210.c
+++ b/drivers/net/ethernet/intel/igb/e1000_i210.c
@@ -1,7 +1,7 @@
1/******************************************************************************* 1/*******************************************************************************
2 2
3 Intel(R) Gigabit Ethernet Linux driver 3 Intel(R) Gigabit Ethernet Linux driver
4 Copyright(c) 2007-2013 Intel Corporation. 4 Copyright(c) 2007-2014 Intel Corporation.
5 5
6 This program is free software; you can redistribute it and/or modify it 6 This program is free software; you can redistribute it and/or modify it
7 under the terms and conditions of the GNU General Public License, 7 under the terms and conditions of the GNU General Public License,
@@ -13,8 +13,7 @@
13 more details. 13 more details.
14 14
15 You should have received a copy of the GNU General Public License along with 15 You should have received a copy of the GNU General Public License along with
16 this program; if not, write to the Free Software Foundation, Inc., 16 this program; if not, see <http://www.gnu.org/licenses/>.
17 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
18 17
19 The full GNU General Public License is included in this distribution in 18 The full GNU General Public License is included in this distribution in
20 the file called "COPYING". 19 the file called "COPYING".
@@ -35,6 +34,8 @@
35#include "e1000_hw.h" 34#include "e1000_hw.h"
36#include "e1000_i210.h" 35#include "e1000_i210.h"
37 36
37static s32 igb_update_flash_i210(struct e1000_hw *hw);
38
38/** 39/**
39 * igb_get_hw_semaphore_i210 - Acquire hardware semaphore 40 * igb_get_hw_semaphore_i210 - Acquire hardware semaphore
40 * @hw: pointer to the HW structure 41 * @hw: pointer to the HW structure
@@ -111,7 +112,7 @@ static s32 igb_get_hw_semaphore_i210(struct e1000_hw *hw)
111 * Return successful if access grant bit set, else clear the request for 112 * Return successful if access grant bit set, else clear the request for
112 * EEPROM access and return -E1000_ERR_NVM (-1). 113 * EEPROM access and return -E1000_ERR_NVM (-1).
113 **/ 114 **/
114s32 igb_acquire_nvm_i210(struct e1000_hw *hw) 115static s32 igb_acquire_nvm_i210(struct e1000_hw *hw)
115{ 116{
116 return igb_acquire_swfw_sync_i210(hw, E1000_SWFW_EEP_SM); 117 return igb_acquire_swfw_sync_i210(hw, E1000_SWFW_EEP_SM);
117} 118}
@@ -123,7 +124,7 @@ s32 igb_acquire_nvm_i210(struct e1000_hw *hw)
123 * Stop any current commands to the EEPROM and clear the EEPROM request bit, 124 * Stop any current commands to the EEPROM and clear the EEPROM request bit,
124 * then release the semaphores acquired. 125 * then release the semaphores acquired.
125 **/ 126 **/
126void igb_release_nvm_i210(struct e1000_hw *hw) 127static void igb_release_nvm_i210(struct e1000_hw *hw)
127{ 128{
128 igb_release_swfw_sync_i210(hw, E1000_SWFW_EEP_SM); 129 igb_release_swfw_sync_i210(hw, E1000_SWFW_EEP_SM);
129} 130}
@@ -206,8 +207,8 @@ void igb_release_swfw_sync_i210(struct e1000_hw *hw, u16 mask)
206 * Reads a 16 bit word from the Shadow Ram using the EERD register. 207 * Reads a 16 bit word from the Shadow Ram using the EERD register.
207 * Uses necessary synchronization semaphores. 208 * Uses necessary synchronization semaphores.
208 **/ 209 **/
209s32 igb_read_nvm_srrd_i210(struct e1000_hw *hw, u16 offset, u16 words, 210static s32 igb_read_nvm_srrd_i210(struct e1000_hw *hw, u16 offset, u16 words,
210 u16 *data) 211 u16 *data)
211{ 212{
212 s32 status = E1000_SUCCESS; 213 s32 status = E1000_SUCCESS;
213 u16 i, count; 214 u16 i, count;
@@ -306,8 +307,8 @@ out:
306 * If error code is returned, data and Shadow RAM may be inconsistent - buffer 307 * If error code is returned, data and Shadow RAM may be inconsistent - buffer
307 * partially written. 308 * partially written.
308 **/ 309 **/
309s32 igb_write_nvm_srwr_i210(struct e1000_hw *hw, u16 offset, u16 words, 310static s32 igb_write_nvm_srwr_i210(struct e1000_hw *hw, u16 offset, u16 words,
310 u16 *data) 311 u16 *data)
311{ 312{
312 s32 status = E1000_SUCCESS; 313 s32 status = E1000_SUCCESS;
313 u16 i, count; 314 u16 i, count;
@@ -555,7 +556,7 @@ s32 igb_read_invm_version(struct e1000_hw *hw,
555 * Calculates the EEPROM checksum by reading/adding each word of the EEPROM 556 * Calculates the EEPROM checksum by reading/adding each word of the EEPROM
556 * and then verifies that the sum of the EEPROM is equal to 0xBABA. 557 * and then verifies that the sum of the EEPROM is equal to 0xBABA.
557 **/ 558 **/
558s32 igb_validate_nvm_checksum_i210(struct e1000_hw *hw) 559static s32 igb_validate_nvm_checksum_i210(struct e1000_hw *hw)
559{ 560{
560 s32 status = E1000_SUCCESS; 561 s32 status = E1000_SUCCESS;
561 s32 (*read_op_ptr)(struct e1000_hw *, u16, u16, u16 *); 562 s32 (*read_op_ptr)(struct e1000_hw *, u16, u16, u16 *);
@@ -590,7 +591,7 @@ s32 igb_validate_nvm_checksum_i210(struct e1000_hw *hw)
590 * up to the checksum. Then calculates the EEPROM checksum and writes the 591 * up to the checksum. Then calculates the EEPROM checksum and writes the
591 * value to the EEPROM. Next commit EEPROM data onto the Flash. 592 * value to the EEPROM. Next commit EEPROM data onto the Flash.
592 **/ 593 **/
593s32 igb_update_nvm_checksum_i210(struct e1000_hw *hw) 594static s32 igb_update_nvm_checksum_i210(struct e1000_hw *hw)
594{ 595{
595 s32 ret_val = E1000_SUCCESS; 596 s32 ret_val = E1000_SUCCESS;
596 u16 checksum = 0; 597 u16 checksum = 0;
@@ -684,7 +685,7 @@ bool igb_get_flash_presence_i210(struct e1000_hw *hw)
684 * @hw: pointer to the HW structure 685 * @hw: pointer to the HW structure
685 * 686 *
686 **/ 687 **/
687s32 igb_update_flash_i210(struct e1000_hw *hw) 688static s32 igb_update_flash_i210(struct e1000_hw *hw)
688{ 689{
689 s32 ret_val = E1000_SUCCESS; 690 s32 ret_val = E1000_SUCCESS;
690 u32 flup; 691 u32 flup;
diff --git a/drivers/net/ethernet/intel/igb/e1000_i210.h b/drivers/net/ethernet/intel/igb/e1000_i210.h
index 2d913716573a..907fe99a9813 100644
--- a/drivers/net/ethernet/intel/igb/e1000_i210.h
+++ b/drivers/net/ethernet/intel/igb/e1000_i210.h
@@ -1,7 +1,7 @@
1/******************************************************************************* 1/*******************************************************************************
2 2
3 Intel(R) Gigabit Ethernet Linux driver 3 Intel(R) Gigabit Ethernet Linux driver
4 Copyright(c) 2007-2013 Intel Corporation. 4 Copyright(c) 2007-2014 Intel Corporation.
5 5
6 This program is free software; you can redistribute it and/or modify it 6 This program is free software; you can redistribute it and/or modify it
7 under the terms and conditions of the GNU General Public License, 7 under the terms and conditions of the GNU General Public License,
@@ -13,8 +13,7 @@
13 more details. 13 more details.
14 14
15 You should have received a copy of the GNU General Public License along with 15 You should have received a copy of the GNU General Public License along with
16 this program; if not, write to the Free Software Foundation, Inc., 16 this program; if not, see <http://www.gnu.org/licenses/>.
17 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
18 17
19 The full GNU General Public License is included in this distribution in 18 The full GNU General Public License is included in this distribution in
20 the file called "COPYING". 19 the file called "COPYING".
@@ -28,17 +27,8 @@
28#ifndef _E1000_I210_H_ 27#ifndef _E1000_I210_H_
29#define _E1000_I210_H_ 28#define _E1000_I210_H_
30 29
31s32 igb_update_flash_i210(struct e1000_hw *hw);
32s32 igb_update_nvm_checksum_i210(struct e1000_hw *hw);
33s32 igb_validate_nvm_checksum_i210(struct e1000_hw *hw);
34s32 igb_write_nvm_srwr_i210(struct e1000_hw *hw, u16 offset, u16 words,
35 u16 *data);
36s32 igb_read_nvm_srrd_i210(struct e1000_hw *hw, u16 offset, u16 words,
37 u16 *data);
38s32 igb_acquire_swfw_sync_i210(struct e1000_hw *hw, u16 mask); 30s32 igb_acquire_swfw_sync_i210(struct e1000_hw *hw, u16 mask);
39void igb_release_swfw_sync_i210(struct e1000_hw *hw, u16 mask); 31void igb_release_swfw_sync_i210(struct e1000_hw *hw, u16 mask);
40s32 igb_acquire_nvm_i210(struct e1000_hw *hw);
41void igb_release_nvm_i210(struct e1000_hw *hw);
42s32 igb_valid_led_default_i210(struct e1000_hw *hw, u16 *data); 32s32 igb_valid_led_default_i210(struct e1000_hw *hw, u16 *data);
43s32 igb_read_invm_version(struct e1000_hw *hw, 33s32 igb_read_invm_version(struct e1000_hw *hw,
44 struct e1000_fw_version *invm_ver); 34 struct e1000_fw_version *invm_ver);
diff --git a/drivers/net/ethernet/intel/igb/e1000_mac.c b/drivers/net/ethernet/intel/igb/e1000_mac.c
index 298f0ed50670..5910a932ea7c 100644
--- a/drivers/net/ethernet/intel/igb/e1000_mac.c
+++ b/drivers/net/ethernet/intel/igb/e1000_mac.c
@@ -1,7 +1,7 @@
1/******************************************************************************* 1/*******************************************************************************
2 2
3 Intel(R) Gigabit Ethernet Linux driver 3 Intel(R) Gigabit Ethernet Linux driver
4 Copyright(c) 2007-2013 Intel Corporation. 4 Copyright(c) 2007-2014 Intel Corporation.
5 5
6 This program is free software; you can redistribute it and/or modify it 6 This program is free software; you can redistribute it and/or modify it
7 under the terms and conditions of the GNU General Public License, 7 under the terms and conditions of the GNU General Public License,
@@ -13,8 +13,7 @@
13 more details. 13 more details.
14 14
15 You should have received a copy of the GNU General Public License along with 15 You should have received a copy of the GNU General Public License along with
16 this program; if not, write to the Free Software Foundation, Inc., 16 this program; if not, see <http://www.gnu.org/licenses/>.
17 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
18 17
19 The full GNU General Public License is included in this distribution in 18 The full GNU General Public License is included in this distribution in
20 the file called "COPYING". 19 the file called "COPYING".
diff --git a/drivers/net/ethernet/intel/igb/e1000_mac.h b/drivers/net/ethernet/intel/igb/e1000_mac.h
index e4cbe8ef67b3..99299ba8ee3a 100644
--- a/drivers/net/ethernet/intel/igb/e1000_mac.h
+++ b/drivers/net/ethernet/intel/igb/e1000_mac.h
@@ -1,7 +1,7 @@
1/******************************************************************************* 1/*******************************************************************************
2 2
3 Intel(R) Gigabit Ethernet Linux driver 3 Intel(R) Gigabit Ethernet Linux driver
4 Copyright(c) 2007-2013 Intel Corporation. 4 Copyright(c) 2007-2014 Intel Corporation.
5 5
6 This program is free software; you can redistribute it and/or modify it 6 This program is free software; you can redistribute it and/or modify it
7 under the terms and conditions of the GNU General Public License, 7 under the terms and conditions of the GNU General Public License,
@@ -13,8 +13,7 @@
13 more details. 13 more details.
14 14
15 You should have received a copy of the GNU General Public License along with 15 You should have received a copy of the GNU General Public License along with
16 this program; if not, write to the Free Software Foundation, Inc., 16 this program; if not, see <http://www.gnu.org/licenses/>.
17 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
18 17
19 The full GNU General Public License is included in this distribution in 18 The full GNU General Public License is included in this distribution in
20 the file called "COPYING". 19 the file called "COPYING".
diff --git a/drivers/net/ethernet/intel/igb/e1000_mbx.c b/drivers/net/ethernet/intel/igb/e1000_mbx.c
index dac1447fabf7..d5b121771c31 100644
--- a/drivers/net/ethernet/intel/igb/e1000_mbx.c
+++ b/drivers/net/ethernet/intel/igb/e1000_mbx.c
@@ -1,7 +1,7 @@
1/******************************************************************************* 1/*******************************************************************************
2 2
3 Intel(R) Gigabit Ethernet Linux driver 3 Intel(R) Gigabit Ethernet Linux driver
4 Copyright(c) 2007-2013 Intel Corporation. 4 Copyright(c) 2007-2014 Intel Corporation.
5 5
6 This program is free software; you can redistribute it and/or modify it 6 This program is free software; you can redistribute it and/or modify it
7 under the terms and conditions of the GNU General Public License, 7 under the terms and conditions of the GNU General Public License,
@@ -13,8 +13,7 @@
13 more details. 13 more details.
14 14
15 You should have received a copy of the GNU General Public License along with 15 You should have received a copy of the GNU General Public License along with
16 this program; if not, write to the Free Software Foundation, Inc., 16 this program; if not, see <http://www.gnu.org/licenses/>.
17 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
18 17
19 The full GNU General Public License is included in this distribution in 18 The full GNU General Public License is included in this distribution in
20 the file called "COPYING". 19 the file called "COPYING".
diff --git a/drivers/net/ethernet/intel/igb/e1000_mbx.h b/drivers/net/ethernet/intel/igb/e1000_mbx.h
index de9bba41acf3..f52f5515e5a8 100644
--- a/drivers/net/ethernet/intel/igb/e1000_mbx.h
+++ b/drivers/net/ethernet/intel/igb/e1000_mbx.h
@@ -1,7 +1,7 @@
1/******************************************************************************* 1/*******************************************************************************
2 2
3 Intel(R) Gigabit Ethernet Linux driver 3 Intel(R) Gigabit Ethernet Linux driver
4 Copyright(c) 2007-2013 Intel Corporation. 4 Copyright(c) 2007-2014 Intel Corporation.
5 5
6 This program is free software; you can redistribute it and/or modify it 6 This program is free software; you can redistribute it and/or modify it
7 under the terms and conditions of the GNU General Public License, 7 under the terms and conditions of the GNU General Public License,
@@ -13,8 +13,7 @@
13 more details. 13 more details.
14 14
15 You should have received a copy of the GNU General Public License along with 15 You should have received a copy of the GNU General Public License along with
16 this program; if not, write to the Free Software Foundation, Inc., 16 this program; if not, see <http://www.gnu.org/licenses/>.
17 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
18 17
19 The full GNU General Public License is included in this distribution in 18 The full GNU General Public License is included in this distribution in
20 the file called "COPYING". 19 the file called "COPYING".
diff --git a/drivers/net/ethernet/intel/igb/e1000_nvm.c b/drivers/net/ethernet/intel/igb/e1000_nvm.c
index a7db7f3db914..9abf82919c65 100644
--- a/drivers/net/ethernet/intel/igb/e1000_nvm.c
+++ b/drivers/net/ethernet/intel/igb/e1000_nvm.c
@@ -1,7 +1,7 @@
1/******************************************************************************* 1/*******************************************************************************
2 2
3 Intel(R) Gigabit Ethernet Linux driver 3 Intel(R) Gigabit Ethernet Linux driver
4 Copyright(c) 2007-2013 Intel Corporation. 4 Copyright(c) 2007-2014 Intel Corporation.
5 5
6 This program is free software; you can redistribute it and/or modify it 6 This program is free software; you can redistribute it and/or modify it
7 under the terms and conditions of the GNU General Public License, 7 under the terms and conditions of the GNU General Public License,
@@ -13,8 +13,7 @@
13 more details. 13 more details.
14 14
15 You should have received a copy of the GNU General Public License along with 15 You should have received a copy of the GNU General Public License along with
16 this program; if not, write to the Free Software Foundation, Inc., 16 this program; if not, see <http://www.gnu.org/licenses/>.
17 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
18 17
19 The full GNU General Public License is included in this distribution in 18 The full GNU General Public License is included in this distribution in
20 the file called "COPYING". 19 the file called "COPYING".
diff --git a/drivers/net/ethernet/intel/igb/e1000_nvm.h b/drivers/net/ethernet/intel/igb/e1000_nvm.h
index 433b7419cb98..5b101170b17e 100644
--- a/drivers/net/ethernet/intel/igb/e1000_nvm.h
+++ b/drivers/net/ethernet/intel/igb/e1000_nvm.h
@@ -1,7 +1,7 @@
1/******************************************************************************* 1/*******************************************************************************
2 2
3 Intel(R) Gigabit Ethernet Linux driver 3 Intel(R) Gigabit Ethernet Linux driver
4 Copyright(c) 2013 Intel Corporation. 4 Copyright(c) 2007-2014 Intel Corporation.
5 5
6 This program is free software; you can redistribute it and/or modify it 6 This program is free software; you can redistribute it and/or modify it
7 under the terms and conditions of the GNU General Public License, 7 under the terms and conditions of the GNU General Public License,
@@ -13,8 +13,7 @@
13 more details. 13 more details.
14 14
15 You should have received a copy of the GNU General Public License along with 15 You should have received a copy of the GNU General Public License along with
16 this program; if not, write to the Free Software Foundation, Inc., 16 this program; if not, see <http://www.gnu.org/licenses/>.
17 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
18 17
19 The full GNU General Public License is included in this distribution in 18 The full GNU General Public License is included in this distribution in
20 the file called "COPYING". 19 the file called "COPYING".
diff --git a/drivers/net/ethernet/intel/igb/e1000_phy.c b/drivers/net/ethernet/intel/igb/e1000_phy.c
index ad2b74d95138..4009bbab7407 100644
--- a/drivers/net/ethernet/intel/igb/e1000_phy.c
+++ b/drivers/net/ethernet/intel/igb/e1000_phy.c
@@ -1,7 +1,7 @@
1/******************************************************************************* 1/*******************************************************************************
2 2
3 Intel(R) Gigabit Ethernet Linux driver 3 Intel(R) Gigabit Ethernet Linux driver
4 Copyright(c) 2007-2013 Intel Corporation. 4 Copyright(c) 2007-2014 Intel Corporation.
5 5
6 This program is free software; you can redistribute it and/or modify it 6 This program is free software; you can redistribute it and/or modify it
7 under the terms and conditions of the GNU General Public License, 7 under the terms and conditions of the GNU General Public License,
@@ -13,8 +13,7 @@
13 more details. 13 more details.
14 14
15 You should have received a copy of the GNU General Public License along with 15 You should have received a copy of the GNU General Public License along with
16 this program; if not, write to the Free Software Foundation, Inc., 16 this program; if not, see <http://www.gnu.org/licenses/>.
17 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
18 17
19 The full GNU General Public License is included in this distribution in 18 The full GNU General Public License is included in this distribution in
20 the file called "COPYING". 19 the file called "COPYING".
@@ -394,77 +393,6 @@ s32 igb_read_sfp_data_byte(struct e1000_hw *hw, u16 offset, u8 *data)
394} 393}
395 394
396/** 395/**
397 * e1000_write_sfp_data_byte - Writes SFP module data.
398 * @hw: pointer to the HW structure
399 * @offset: byte location offset to write to
400 * @data: data to write
401 *
402 * Writes one byte to SFP module data stored
403 * in SFP resided EEPROM memory or SFP diagnostic area.
404 * Function should be called with
405 * E1000_I2CCMD_SFP_DATA_ADDR(<byte offset>) for SFP module database access
406 * E1000_I2CCMD_SFP_DIAG_ADDR(<byte offset>) for SFP diagnostics parameters
407 * access
408 **/
409s32 e1000_write_sfp_data_byte(struct e1000_hw *hw, u16 offset, u8 data)
410{
411 u32 i = 0;
412 u32 i2ccmd = 0;
413 u32 data_local = 0;
414
415 if (offset > E1000_I2CCMD_SFP_DIAG_ADDR(255)) {
416 hw_dbg("I2CCMD command address exceeds upper limit\n");
417 return -E1000_ERR_PHY;
418 }
419 /* The programming interface is 16 bits wide
420 * so we need to read the whole word first
421 * then update appropriate byte lane and write
422 * the updated word back.
423 */
424 /* Set up Op-code, EEPROM Address,in the I2CCMD
425 * register. The MAC will take care of interfacing
426 * with an EEPROM to write the data given.
427 */
428 i2ccmd = ((offset << E1000_I2CCMD_REG_ADDR_SHIFT) |
429 E1000_I2CCMD_OPCODE_READ);
430 /* Set a command to read single word */
431 wr32(E1000_I2CCMD, i2ccmd);
432 for (i = 0; i < E1000_I2CCMD_PHY_TIMEOUT; i++) {
433 udelay(50);
434 /* Poll the ready bit to see if lastly
435 * launched I2C operation completed
436 */
437 i2ccmd = rd32(E1000_I2CCMD);
438 if (i2ccmd & E1000_I2CCMD_READY) {
439 /* Check if this is READ or WRITE phase */
440 if ((i2ccmd & E1000_I2CCMD_OPCODE_READ) ==
441 E1000_I2CCMD_OPCODE_READ) {
442 /* Write the selected byte
443 * lane and update whole word
444 */
445 data_local = i2ccmd & 0xFF00;
446 data_local |= data;
447 i2ccmd = ((offset <<
448 E1000_I2CCMD_REG_ADDR_SHIFT) |
449 E1000_I2CCMD_OPCODE_WRITE | data_local);
450 wr32(E1000_I2CCMD, i2ccmd);
451 } else {
452 break;
453 }
454 }
455 }
456 if (!(i2ccmd & E1000_I2CCMD_READY)) {
457 hw_dbg("I2CCMD Write did not complete\n");
458 return -E1000_ERR_PHY;
459 }
460 if (i2ccmd & E1000_I2CCMD_ERROR) {
461 hw_dbg("I2CCMD Error bit set\n");
462 return -E1000_ERR_PHY;
463 }
464 return 0;
465}
466
467/**
468 * igb_read_phy_reg_igp - Read igp PHY register 396 * igb_read_phy_reg_igp - Read igp PHY register
469 * @hw: pointer to the HW structure 397 * @hw: pointer to the HW structure
470 * @offset: register offset to be read 398 * @offset: register offset to be read
diff --git a/drivers/net/ethernet/intel/igb/e1000_phy.h b/drivers/net/ethernet/intel/igb/e1000_phy.h
index 6a0873f2095a..4c2c36c46a73 100644
--- a/drivers/net/ethernet/intel/igb/e1000_phy.h
+++ b/drivers/net/ethernet/intel/igb/e1000_phy.h
@@ -1,7 +1,7 @@
1/******************************************************************************* 1/*******************************************************************************
2 2
3 Intel(R) Gigabit Ethernet Linux driver 3 Intel(R) Gigabit Ethernet Linux driver
4 Copyright(c) 2007-2013 Intel Corporation. 4 Copyright(c) 2007-2014 Intel Corporation.
5 5
6 This program is free software; you can redistribute it and/or modify it 6 This program is free software; you can redistribute it and/or modify it
7 under the terms and conditions of the GNU General Public License, 7 under the terms and conditions of the GNU General Public License,
@@ -13,8 +13,7 @@
13 more details. 13 more details.
14 14
15 You should have received a copy of the GNU General Public License along with 15 You should have received a copy of the GNU General Public License along with
16 this program; if not, write to the Free Software Foundation, Inc., 16 this program; if not, see <http://www.gnu.org/licenses/>.
17 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
18 17
19 The full GNU General Public License is included in this distribution in 18 The full GNU General Public License is included in this distribution in
20 the file called "COPYING". 19 the file called "COPYING".
@@ -70,7 +69,6 @@ s32 igb_write_phy_reg_mdic(struct e1000_hw *hw, u32 offset, u16 data);
70s32 igb_read_phy_reg_i2c(struct e1000_hw *hw, u32 offset, u16 *data); 69s32 igb_read_phy_reg_i2c(struct e1000_hw *hw, u32 offset, u16 *data);
71s32 igb_write_phy_reg_i2c(struct e1000_hw *hw, u32 offset, u16 data); 70s32 igb_write_phy_reg_i2c(struct e1000_hw *hw, u32 offset, u16 data);
72s32 igb_read_sfp_data_byte(struct e1000_hw *hw, u16 offset, u8 *data); 71s32 igb_read_sfp_data_byte(struct e1000_hw *hw, u16 offset, u8 *data);
73s32 e1000_write_sfp_data_byte(struct e1000_hw *hw, u16 offset, u8 data);
74s32 igb_copper_link_setup_82580(struct e1000_hw *hw); 72s32 igb_copper_link_setup_82580(struct e1000_hw *hw);
75s32 igb_get_phy_info_82580(struct e1000_hw *hw); 73s32 igb_get_phy_info_82580(struct e1000_hw *hw);
76s32 igb_phy_force_speed_duplex_82580(struct e1000_hw *hw); 74s32 igb_phy_force_speed_duplex_82580(struct e1000_hw *hw);
diff --git a/drivers/net/ethernet/intel/igb/e1000_regs.h b/drivers/net/ethernet/intel/igb/e1000_regs.h
index 82632c6c53af..bdb246e848e1 100644
--- a/drivers/net/ethernet/intel/igb/e1000_regs.h
+++ b/drivers/net/ethernet/intel/igb/e1000_regs.h
@@ -1,7 +1,7 @@
1/******************************************************************************* 1/*******************************************************************************
2 2
3 Intel(R) Gigabit Ethernet Linux driver 3 Intel(R) Gigabit Ethernet Linux driver
4 Copyright(c) 2007-2013 Intel Corporation. 4 Copyright(c) 2007-2014 Intel Corporation.
5 5
6 This program is free software; you can redistribute it and/or modify it 6 This program is free software; you can redistribute it and/or modify it
7 under the terms and conditions of the GNU General Public License, 7 under the terms and conditions of the GNU General Public License,
@@ -13,8 +13,7 @@
13 more details. 13 more details.
14 14
15 You should have received a copy of the GNU General Public License along with 15 You should have received a copy of the GNU General Public License along with
16 this program; if not, write to the Free Software Foundation, Inc., 16 this program; if not, see <http://www.gnu.org/licenses/>.
17 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
18 17
19 The full GNU General Public License is included in this distribution in 18 The full GNU General Public License is included in this distribution in
20 the file called "COPYING". 19 the file called "COPYING".
@@ -41,6 +40,7 @@
41#define E1000_FCT 0x00030 /* Flow Control Type - RW */ 40#define E1000_FCT 0x00030 /* Flow Control Type - RW */
42#define E1000_CONNSW 0x00034 /* Copper/Fiber switch control - RW */ 41#define E1000_CONNSW 0x00034 /* Copper/Fiber switch control - RW */
43#define E1000_VET 0x00038 /* VLAN Ether Type - RW */ 42#define E1000_VET 0x00038 /* VLAN Ether Type - RW */
43#define E1000_TSSDP 0x0003C /* Time Sync SDP Configuration Register - RW */
44#define E1000_ICR 0x000C0 /* Interrupt Cause Read - R/clr */ 44#define E1000_ICR 0x000C0 /* Interrupt Cause Read - R/clr */
45#define E1000_ITR 0x000C4 /* Interrupt Throttling Rate - RW */ 45#define E1000_ITR 0x000C4 /* Interrupt Throttling Rate - RW */
46#define E1000_ICS 0x000C8 /* Interrupt Cause Set - WO */ 46#define E1000_ICS 0x000C8 /* Interrupt Cause Set - WO */
@@ -102,6 +102,14 @@
102#define E1000_SYSTIMH 0x0B604 /* System time register High - RO */ 102#define E1000_SYSTIMH 0x0B604 /* System time register High - RO */
103#define E1000_TIMINCA 0x0B608 /* Increment attributes register - RW */ 103#define E1000_TIMINCA 0x0B608 /* Increment attributes register - RW */
104#define E1000_TSAUXC 0x0B640 /* Timesync Auxiliary Control register */ 104#define E1000_TSAUXC 0x0B640 /* Timesync Auxiliary Control register */
105#define E1000_TRGTTIML0 0x0B644 /* Target Time Register 0 Low - RW */
106#define E1000_TRGTTIMH0 0x0B648 /* Target Time Register 0 High - RW */
107#define E1000_TRGTTIML1 0x0B64C /* Target Time Register 1 Low - RW */
108#define E1000_TRGTTIMH1 0x0B650 /* Target Time Register 1 High - RW */
109#define E1000_AUXSTMPL0 0x0B65C /* Auxiliary Time Stamp 0 Register Low - RO */
110#define E1000_AUXSTMPH0 0x0B660 /* Auxiliary Time Stamp 0 Register High - RO */
111#define E1000_AUXSTMPL1 0x0B664 /* Auxiliary Time Stamp 1 Register Low - RO */
112#define E1000_AUXSTMPH1 0x0B668 /* Auxiliary Time Stamp 1 Register High - RO */
105#define E1000_SYSTIMR 0x0B6F8 /* System time register Residue */ 113#define E1000_SYSTIMR 0x0B6F8 /* System time register Residue */
106#define E1000_TSICR 0x0B66C /* Interrupt Cause Register */ 114#define E1000_TSICR 0x0B66C /* Interrupt Cause Register */
107#define E1000_TSIM 0x0B674 /* Interrupt Mask Register */ 115#define E1000_TSIM 0x0B674 /* Interrupt Mask Register */
@@ -349,16 +357,30 @@
349#define E1000_P2VMAILBOX(_n) (0x00C00 + (4 * (_n))) 357#define E1000_P2VMAILBOX(_n) (0x00C00 + (4 * (_n)))
350#define E1000_VMBMEM(_n) (0x00800 + (64 * (_n))) 358#define E1000_VMBMEM(_n) (0x00800 + (64 * (_n)))
351#define E1000_VMOLR(_n) (0x05AD0 + (4 * (_n))) 359#define E1000_VMOLR(_n) (0x05AD0 + (4 * (_n)))
360#define E1000_DVMOLR(_n) (0x0C038 + (64 * (_n)))
352#define E1000_VLVF(_n) (0x05D00 + (4 * (_n))) /* VLAN Virtual Machine 361#define E1000_VLVF(_n) (0x05D00 + (4 * (_n))) /* VLAN Virtual Machine
353 * Filter - RW */ 362 * Filter - RW */
354#define E1000_VMVIR(_n) (0x03700 + (4 * (_n))) 363#define E1000_VMVIR(_n) (0x03700 + (4 * (_n)))
355 364
356#define wr32(reg, value) (writel(value, hw->hw_addr + reg)) 365struct e1000_hw;
357#define rd32(reg) (readl(hw->hw_addr + reg)) 366
367u32 igb_rd32(struct e1000_hw *hw, u32 reg);
368
369/* write operations, indexed using DWORDS */
370#define wr32(reg, val) \
371do { \
372 u8 __iomem *hw_addr = ACCESS_ONCE((hw)->hw_addr); \
373 if (!E1000_REMOVED(hw_addr)) \
374 writel((val), &hw_addr[(reg)]); \
375} while (0)
376
377#define rd32(reg) (igb_rd32(hw, reg))
378
358#define wrfl() ((void)rd32(E1000_STATUS)) 379#define wrfl() ((void)rd32(E1000_STATUS))
359 380
360#define array_wr32(reg, offset, value) \ 381#define array_wr32(reg, offset, value) \
361 (writel(value, hw->hw_addr + reg + ((offset) << 2))) 382 wr32((reg) + ((offset) << 2), (value))
383
362#define array_rd32(reg, offset) \ 384#define array_rd32(reg, offset) \
363 (readl(hw->hw_addr + reg + ((offset) << 2))) 385 (readl(hw->hw_addr + reg + ((offset) << 2)))
364 386
@@ -397,4 +419,6 @@
397#define E1000_INVM_DATA_REG(_n) (0x12120 + 4*(_n)) 419#define E1000_INVM_DATA_REG(_n) (0x12120 + 4*(_n))
398#define E1000_INVM_SIZE 64 /* Number of INVM Data Registers */ 420#define E1000_INVM_SIZE 64 /* Number of INVM Data Registers */
399 421
422#define E1000_REMOVED(h) unlikely(!(h))
423
400#endif 424#endif
diff --git a/drivers/net/ethernet/intel/igb/igb.h b/drivers/net/ethernet/intel/igb/igb.h
index ccf472f073dd..411b213c63be 100644
--- a/drivers/net/ethernet/intel/igb/igb.h
+++ b/drivers/net/ethernet/intel/igb/igb.h
@@ -1,7 +1,7 @@
1/******************************************************************************* 1/*******************************************************************************
2 2
3 Intel(R) Gigabit Ethernet Linux driver 3 Intel(R) Gigabit Ethernet Linux driver
4 Copyright(c) 2007-2013 Intel Corporation. 4 Copyright(c) 2007-2014 Intel Corporation.
5 5
6 This program is free software; you can redistribute it and/or modify it 6 This program is free software; you can redistribute it and/or modify it
7 under the terms and conditions of the GNU General Public License, 7 under the terms and conditions of the GNU General Public License,
@@ -13,8 +13,7 @@
13 more details. 13 more details.
14 14
15 You should have received a copy of the GNU General Public License along with 15 You should have received a copy of the GNU General Public License along with
16 this program; if not, write to the Free Software Foundation, Inc., 16 this program; if not, see <http://www.gnu.org/licenses/>.
17 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
18 17
19 The full GNU General Public License is included in this distribution in 18 The full GNU General Public License is included in this distribution in
20 the file called "COPYING". 19 the file called "COPYING".
@@ -42,6 +41,7 @@
42#include <linux/i2c.h> 41#include <linux/i2c.h>
43#include <linux/i2c-algo-bit.h> 42#include <linux/i2c-algo-bit.h>
44#include <linux/pci.h> 43#include <linux/pci.h>
44#include <linux/mdio.h>
45 45
46struct igb_adapter; 46struct igb_adapter;
47 47
@@ -434,6 +434,7 @@ struct igb_adapter {
434 struct delayed_work ptp_overflow_work; 434 struct delayed_work ptp_overflow_work;
435 struct work_struct ptp_tx_work; 435 struct work_struct ptp_tx_work;
436 struct sk_buff *ptp_tx_skb; 436 struct sk_buff *ptp_tx_skb;
437 struct hwtstamp_config tstamp_config;
437 unsigned long ptp_tx_start; 438 unsigned long ptp_tx_start;
438 unsigned long last_rx_ptp_check; 439 unsigned long last_rx_ptp_check;
439 spinlock_t tmreg_lock; 440 spinlock_t tmreg_lock;
@@ -456,6 +457,7 @@ struct igb_adapter {
456 unsigned long link_check_timeout; 457 unsigned long link_check_timeout;
457 int copper_tries; 458 int copper_tries;
458 struct e1000_info ei; 459 struct e1000_info ei;
460 u16 eee_advert;
459}; 461};
460 462
461#define IGB_FLAG_HAS_MSI (1 << 0) 463#define IGB_FLAG_HAS_MSI (1 << 0)
@@ -472,6 +474,7 @@ struct igb_adapter {
472#define IGB_FLAG_MAS_CAPABLE (1 << 11) 474#define IGB_FLAG_MAS_CAPABLE (1 << 11)
473#define IGB_FLAG_MAS_ENABLE (1 << 12) 475#define IGB_FLAG_MAS_ENABLE (1 << 12)
474#define IGB_FLAG_HAS_MSIX (1 << 13) 476#define IGB_FLAG_HAS_MSIX (1 << 13)
477#define IGB_FLAG_EEE (1 << 14)
475 478
476/* Media Auto Sense */ 479/* Media Auto Sense */
477#define IGB_MAS_ENABLE_0 0X0001 480#define IGB_MAS_ENABLE_0 0X0001
@@ -525,9 +528,7 @@ void igb_set_fw_version(struct igb_adapter *);
525void igb_ptp_init(struct igb_adapter *adapter); 528void igb_ptp_init(struct igb_adapter *adapter);
526void igb_ptp_stop(struct igb_adapter *adapter); 529void igb_ptp_stop(struct igb_adapter *adapter);
527void igb_ptp_reset(struct igb_adapter *adapter); 530void igb_ptp_reset(struct igb_adapter *adapter);
528void igb_ptp_tx_work(struct work_struct *work);
529void igb_ptp_rx_hang(struct igb_adapter *adapter); 531void igb_ptp_rx_hang(struct igb_adapter *adapter);
530void igb_ptp_tx_hwtstamp(struct igb_adapter *adapter);
531void igb_ptp_rx_rgtstamp(struct igb_q_vector *q_vector, struct sk_buff *skb); 532void igb_ptp_rx_rgtstamp(struct igb_q_vector *q_vector, struct sk_buff *skb);
532void igb_ptp_rx_pktstamp(struct igb_q_vector *q_vector, unsigned char *va, 533void igb_ptp_rx_pktstamp(struct igb_q_vector *q_vector, unsigned char *va,
533 struct sk_buff *skb); 534 struct sk_buff *skb);
@@ -545,8 +546,8 @@ static inline void igb_ptp_rx_hwtstamp(struct igb_ring *rx_ring,
545 rx_ring->last_rx_timestamp = jiffies; 546 rx_ring->last_rx_timestamp = jiffies;
546} 547}
547 548
548int igb_ptp_hwtstamp_ioctl(struct net_device *netdev, struct ifreq *ifr, 549int igb_ptp_set_ts_config(struct net_device *netdev, struct ifreq *ifr);
549 int cmd); 550int igb_ptp_get_ts_config(struct net_device *netdev, struct ifreq *ifr);
550#ifdef CONFIG_IGB_HWMON 551#ifdef CONFIG_IGB_HWMON
551void igb_sysfs_exit(struct igb_adapter *adapter); 552void igb_sysfs_exit(struct igb_adapter *adapter);
552int igb_sysfs_init(struct igb_adapter *adapter); 553int igb_sysfs_init(struct igb_adapter *adapter);
diff --git a/drivers/net/ethernet/intel/igb/igb_ethtool.c b/drivers/net/ethernet/intel/igb/igb_ethtool.c
index 1df02378de69..e5570acbeea8 100644
--- a/drivers/net/ethernet/intel/igb/igb_ethtool.c
+++ b/drivers/net/ethernet/intel/igb/igb_ethtool.c
@@ -1,7 +1,7 @@
1/******************************************************************************* 1/*******************************************************************************
2 2
3 Intel(R) Gigabit Ethernet Linux driver 3 Intel(R) Gigabit Ethernet Linux driver
4 Copyright(c) 2007-2013 Intel Corporation. 4 Copyright(c) 2007-2014 Intel Corporation.
5 5
6 This program is free software; you can redistribute it and/or modify it 6 This program is free software; you can redistribute it and/or modify it
7 under the terms and conditions of the GNU General Public License, 7 under the terms and conditions of the GNU General Public License,
@@ -13,8 +13,7 @@
13 more details. 13 more details.
14 14
15 You should have received a copy of the GNU General Public License along with 15 You should have received a copy of the GNU General Public License along with
16 this program; if not, write to the Free Software Foundation, Inc., 16 this program; if not, see <http://www.gnu.org/licenses/>.
17 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
18 17
19 The full GNU General Public License is included in this distribution in 18 The full GNU General Public License is included in this distribution in
20 the file called "COPYING". 19 the file called "COPYING".
@@ -2274,15 +2273,15 @@ static void igb_get_ethtool_stats(struct net_device *netdev,
2274 2273
2275 ring = adapter->tx_ring[j]; 2274 ring = adapter->tx_ring[j];
2276 do { 2275 do {
2277 start = u64_stats_fetch_begin_bh(&ring->tx_syncp); 2276 start = u64_stats_fetch_begin_irq(&ring->tx_syncp);
2278 data[i] = ring->tx_stats.packets; 2277 data[i] = ring->tx_stats.packets;
2279 data[i+1] = ring->tx_stats.bytes; 2278 data[i+1] = ring->tx_stats.bytes;
2280 data[i+2] = ring->tx_stats.restart_queue; 2279 data[i+2] = ring->tx_stats.restart_queue;
2281 } while (u64_stats_fetch_retry_bh(&ring->tx_syncp, start)); 2280 } while (u64_stats_fetch_retry_irq(&ring->tx_syncp, start));
2282 do { 2281 do {
2283 start = u64_stats_fetch_begin_bh(&ring->tx_syncp2); 2282 start = u64_stats_fetch_begin_irq(&ring->tx_syncp2);
2284 restart2 = ring->tx_stats.restart_queue2; 2283 restart2 = ring->tx_stats.restart_queue2;
2285 } while (u64_stats_fetch_retry_bh(&ring->tx_syncp2, start)); 2284 } while (u64_stats_fetch_retry_irq(&ring->tx_syncp2, start));
2286 data[i+2] += restart2; 2285 data[i+2] += restart2;
2287 2286
2288 i += IGB_TX_QUEUE_STATS_LEN; 2287 i += IGB_TX_QUEUE_STATS_LEN;
@@ -2290,13 +2289,13 @@ static void igb_get_ethtool_stats(struct net_device *netdev,
2290 for (j = 0; j < adapter->num_rx_queues; j++) { 2289 for (j = 0; j < adapter->num_rx_queues; j++) {
2291 ring = adapter->rx_ring[j]; 2290 ring = adapter->rx_ring[j];
2292 do { 2291 do {
2293 start = u64_stats_fetch_begin_bh(&ring->rx_syncp); 2292 start = u64_stats_fetch_begin_irq(&ring->rx_syncp);
2294 data[i] = ring->rx_stats.packets; 2293 data[i] = ring->rx_stats.packets;
2295 data[i+1] = ring->rx_stats.bytes; 2294 data[i+1] = ring->rx_stats.bytes;
2296 data[i+2] = ring->rx_stats.drops; 2295 data[i+2] = ring->rx_stats.drops;
2297 data[i+3] = ring->rx_stats.csum_err; 2296 data[i+3] = ring->rx_stats.csum_err;
2298 data[i+4] = ring->rx_stats.alloc_failed; 2297 data[i+4] = ring->rx_stats.alloc_failed;
2299 } while (u64_stats_fetch_retry_bh(&ring->rx_syncp, start)); 2298 } while (u64_stats_fetch_retry_irq(&ring->rx_syncp, start));
2300 i += IGB_RX_QUEUE_STATS_LEN; 2299 i += IGB_RX_QUEUE_STATS_LEN;
2301 } 2300 }
2302 spin_unlock(&adapter->stats64_lock); 2301 spin_unlock(&adapter->stats64_lock);
@@ -2354,6 +2353,11 @@ static int igb_get_ts_info(struct net_device *dev,
2354{ 2353{
2355 struct igb_adapter *adapter = netdev_priv(dev); 2354 struct igb_adapter *adapter = netdev_priv(dev);
2356 2355
2356 if (adapter->ptp_clock)
2357 info->phc_index = ptp_clock_index(adapter->ptp_clock);
2358 else
2359 info->phc_index = -1;
2360
2357 switch (adapter->hw.mac.type) { 2361 switch (adapter->hw.mac.type) {
2358 case e1000_82575: 2362 case e1000_82575:
2359 info->so_timestamping = 2363 info->so_timestamping =
@@ -2375,11 +2379,6 @@ static int igb_get_ts_info(struct net_device *dev,
2375 SOF_TIMESTAMPING_RX_HARDWARE | 2379 SOF_TIMESTAMPING_RX_HARDWARE |
2376 SOF_TIMESTAMPING_RAW_HARDWARE; 2380 SOF_TIMESTAMPING_RAW_HARDWARE;
2377 2381
2378 if (adapter->ptp_clock)
2379 info->phc_index = ptp_clock_index(adapter->ptp_clock);
2380 else
2381 info->phc_index = -1;
2382
2383 info->tx_types = 2382 info->tx_types =
2384 (1 << HWTSTAMP_TX_OFF) | 2383 (1 << HWTSTAMP_TX_OFF) |
2385 (1 << HWTSTAMP_TX_ON); 2384 (1 << HWTSTAMP_TX_ON);
@@ -2588,7 +2587,7 @@ static int igb_get_eee(struct net_device *netdev, struct ethtool_eee *edata)
2588{ 2587{
2589 struct igb_adapter *adapter = netdev_priv(netdev); 2588 struct igb_adapter *adapter = netdev_priv(netdev);
2590 struct e1000_hw *hw = &adapter->hw; 2589 struct e1000_hw *hw = &adapter->hw;
2591 u32 ipcnfg, eeer, ret_val; 2590 u32 ret_val;
2592 u16 phy_data; 2591 u16 phy_data;
2593 2592
2594 if ((hw->mac.type < e1000_i350) || 2593 if ((hw->mac.type < e1000_i350) ||
@@ -2597,16 +2596,25 @@ static int igb_get_eee(struct net_device *netdev, struct ethtool_eee *edata)
2597 2596
2598 edata->supported = (SUPPORTED_1000baseT_Full | 2597 edata->supported = (SUPPORTED_1000baseT_Full |
2599 SUPPORTED_100baseT_Full); 2598 SUPPORTED_100baseT_Full);
2599 if (!hw->dev_spec._82575.eee_disable)
2600 edata->advertised =
2601 mmd_eee_adv_to_ethtool_adv_t(adapter->eee_advert);
2602
2603 /* The IPCNFG and EEER registers are not supported on I354. */
2604 if (hw->mac.type == e1000_i354) {
2605 igb_get_eee_status_i354(hw, (bool *)&edata->eee_active);
2606 } else {
2607 u32 eeer;
2600 2608
2601 ipcnfg = rd32(E1000_IPCNFG); 2609 eeer = rd32(E1000_EEER);
2602 eeer = rd32(E1000_EEER);
2603 2610
2604 /* EEE status on negotiated link */ 2611 /* EEE status on negotiated link */
2605 if (ipcnfg & E1000_IPCNFG_EEE_1G_AN) 2612 if (eeer & E1000_EEER_EEE_NEG)
2606 edata->advertised = ADVERTISED_1000baseT_Full; 2613 edata->eee_active = true;
2607 2614
2608 if (ipcnfg & E1000_IPCNFG_EEE_100M_AN) 2615 if (eeer & E1000_EEER_TX_LPI_EN)
2609 edata->advertised |= ADVERTISED_100baseT_Full; 2616 edata->tx_lpi_enabled = true;
2617 }
2610 2618
2611 /* EEE Link Partner Advertised */ 2619 /* EEE Link Partner Advertised */
2612 switch (hw->mac.type) { 2620 switch (hw->mac.type) {
@@ -2617,8 +2625,8 @@ static int igb_get_eee(struct net_device *netdev, struct ethtool_eee *edata)
2617 return -ENODATA; 2625 return -ENODATA;
2618 2626
2619 edata->lp_advertised = mmd_eee_adv_to_ethtool_adv_t(phy_data); 2627 edata->lp_advertised = mmd_eee_adv_to_ethtool_adv_t(phy_data);
2620
2621 break; 2628 break;
2629 case e1000_i354:
2622 case e1000_i210: 2630 case e1000_i210:
2623 case e1000_i211: 2631 case e1000_i211:
2624 ret_val = igb_read_xmdio_reg(hw, E1000_EEE_LP_ADV_ADDR_I210, 2632 ret_val = igb_read_xmdio_reg(hw, E1000_EEE_LP_ADV_ADDR_I210,
@@ -2634,12 +2642,10 @@ static int igb_get_eee(struct net_device *netdev, struct ethtool_eee *edata)
2634 break; 2642 break;
2635 } 2643 }
2636 2644
2637 if (eeer & E1000_EEER_EEE_NEG)
2638 edata->eee_active = true;
2639
2640 edata->eee_enabled = !hw->dev_spec._82575.eee_disable; 2645 edata->eee_enabled = !hw->dev_spec._82575.eee_disable;
2641 2646
2642 if (eeer & E1000_EEER_TX_LPI_EN) 2647 if ((hw->mac.type == e1000_i354) &&
2648 (edata->eee_enabled))
2643 edata->tx_lpi_enabled = true; 2649 edata->tx_lpi_enabled = true;
2644 2650
2645 /* Report correct negotiated EEE status for devices that 2651 /* Report correct negotiated EEE status for devices that
@@ -2687,9 +2693,10 @@ static int igb_set_eee(struct net_device *netdev,
2687 return -EINVAL; 2693 return -EINVAL;
2688 } 2694 }
2689 2695
2690 if (eee_curr.advertised != edata->advertised) { 2696 if (edata->advertised &
2697 ~(ADVERTISE_100_FULL | ADVERTISE_1000_FULL)) {
2691 dev_err(&adapter->pdev->dev, 2698 dev_err(&adapter->pdev->dev,
2692 "Setting EEE Advertisement is not supported\n"); 2699 "EEE Advertisement supports only 100Tx and or 100T full duplex\n");
2693 return -EINVAL; 2700 return -EINVAL;
2694 } 2701 }
2695 2702
@@ -2699,9 +2706,14 @@ static int igb_set_eee(struct net_device *netdev,
2699 return -EINVAL; 2706 return -EINVAL;
2700 } 2707 }
2701 2708
2709 adapter->eee_advert = ethtool_adv_to_mmd_eee_adv_t(edata->advertised);
2702 if (hw->dev_spec._82575.eee_disable != !edata->eee_enabled) { 2710 if (hw->dev_spec._82575.eee_disable != !edata->eee_enabled) {
2703 hw->dev_spec._82575.eee_disable = !edata->eee_enabled; 2711 hw->dev_spec._82575.eee_disable = !edata->eee_enabled;
2704 igb_set_eee_i350(hw); 2712 adapter->flags |= IGB_FLAG_EEE;
2713 if (hw->mac.type == e1000_i350)
2714 igb_set_eee_i350(hw);
2715 else
2716 igb_set_eee_i354(hw);
2705 2717
2706 /* reset link */ 2718 /* reset link */
2707 if (netif_running(netdev)) 2719 if (netif_running(netdev))
@@ -2779,9 +2791,11 @@ static int igb_get_module_eeprom(struct net_device *netdev,
2779 /* Read EEPROM block, SFF-8079/SFF-8472, word at a time */ 2791 /* Read EEPROM block, SFF-8079/SFF-8472, word at a time */
2780 for (i = 0; i < last_word - first_word + 1; i++) { 2792 for (i = 0; i < last_word - first_word + 1; i++) {
2781 status = igb_read_phy_reg_i2c(hw, first_word + i, &dataword[i]); 2793 status = igb_read_phy_reg_i2c(hw, first_word + i, &dataword[i]);
2782 if (status != E1000_SUCCESS) 2794 if (status != E1000_SUCCESS) {
2783 /* Error occurred while reading module */ 2795 /* Error occurred while reading module */
2796 kfree(dataword);
2784 return -EIO; 2797 return -EIO;
2798 }
2785 2799
2786 be16_to_cpus(&dataword[i]); 2800 be16_to_cpus(&dataword[i]);
2787 } 2801 }
diff --git a/drivers/net/ethernet/intel/igb/igb_hwmon.c b/drivers/net/ethernet/intel/igb/igb_hwmon.c
index e0af5bc61613..8333f67acf96 100644
--- a/drivers/net/ethernet/intel/igb/igb_hwmon.c
+++ b/drivers/net/ethernet/intel/igb/igb_hwmon.c
@@ -1,7 +1,7 @@
1/******************************************************************************* 1/*******************************************************************************
2 2
3 Intel(R) Gigabit Ethernet Linux driver 3 Intel(R) Gigabit Ethernet Linux driver
4 Copyright(c) 2007-2013 Intel Corporation. 4 Copyright(c) 2007-2014 Intel Corporation.
5 5
6 This program is free software; you can redistribute it and/or modify it 6 This program is free software; you can redistribute it and/or modify it
7 under the terms and conditions of the GNU General Public License, 7 under the terms and conditions of the GNU General Public License,
@@ -13,8 +13,7 @@
13 more details. 13 more details.
14 14
15 You should have received a copy of the GNU General Public License along with 15 You should have received a copy of the GNU General Public License along with
16 this program; if not, write to the Free Software Foundation, Inc., 16 this program; if not, see <http://www.gnu.org/licenses/>.
17 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
18 17
19 The full GNU General Public License is included in this distribution in 18 The full GNU General Public License is included in this distribution in
20 the file called "COPYING". 19 the file called "COPYING".
diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c
index 46d31a49f5ea..cd20409858d1 100644
--- a/drivers/net/ethernet/intel/igb/igb_main.c
+++ b/drivers/net/ethernet/intel/igb/igb_main.c
@@ -1,7 +1,7 @@
1/******************************************************************************* 1/*******************************************************************************
2 2
3 Intel(R) Gigabit Ethernet Linux driver 3 Intel(R) Gigabit Ethernet Linux driver
4 Copyright(c) 2007-2013 Intel Corporation. 4 Copyright(c) 2007-2014 Intel Corporation.
5 5
6 This program is free software; you can redistribute it and/or modify it 6 This program is free software; you can redistribute it and/or modify it
7 under the terms and conditions of the GNU General Public License, 7 under the terms and conditions of the GNU General Public License,
@@ -13,8 +13,7 @@
13 more details. 13 more details.
14 14
15 You should have received a copy of the GNU General Public License along with 15 You should have received a copy of the GNU General Public License along with
16 this program; if not, write to the Free Software Foundation, Inc., 16 this program; if not, see <http://www.gnu.org/licenses/>.
17 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
18 17
19 The full GNU General Public License is included in this distribution in 18 The full GNU General Public License is included in this distribution in
20 the file called "COPYING". 19 the file called "COPYING".
@@ -70,7 +69,7 @@ char igb_driver_version[] = DRV_VERSION;
70static const char igb_driver_string[] = 69static const char igb_driver_string[] =
71 "Intel(R) Gigabit Ethernet Network Driver"; 70 "Intel(R) Gigabit Ethernet Network Driver";
72static const char igb_copyright[] = 71static const char igb_copyright[] =
73 "Copyright (c) 2007-2013 Intel Corporation."; 72 "Copyright (c) 2007-2014 Intel Corporation.";
74 73
75static const struct e1000_info *igb_info_tbl[] = { 74static const struct e1000_info *igb_info_tbl[] = {
76 [board_82575] = &e1000_82575_info, 75 [board_82575] = &e1000_82575_info,
@@ -752,6 +751,28 @@ static void igb_cache_ring_register(struct igb_adapter *adapter)
752 } 751 }
753} 752}
754 753
754u32 igb_rd32(struct e1000_hw *hw, u32 reg)
755{
756 struct igb_adapter *igb = container_of(hw, struct igb_adapter, hw);
757 u8 __iomem *hw_addr = ACCESS_ONCE(hw->hw_addr);
758 u32 value = 0;
759
760 if (E1000_REMOVED(hw_addr))
761 return ~value;
762
763 value = readl(&hw_addr[reg]);
764
765 /* reads should not return all F's */
766 if (!(~value) && (!reg || !(~readl(hw_addr)))) {
767 struct net_device *netdev = igb->netdev;
768 hw->hw_addr = NULL;
769 netif_device_detach(netdev);
770 netdev_err(netdev, "PCIe link lost, device now detached\n");
771 }
772
773 return value;
774}
775
755/** 776/**
756 * igb_write_ivar - configure ivar for given MSI-X vector 777 * igb_write_ivar - configure ivar for given MSI-X vector
757 * @hw: pointer to the HW structure 778 * @hw: pointer to the HW structure
@@ -1014,6 +1035,12 @@ static void igb_reset_q_vector(struct igb_adapter *adapter, int v_idx)
1014{ 1035{
1015 struct igb_q_vector *q_vector = adapter->q_vector[v_idx]; 1036 struct igb_q_vector *q_vector = adapter->q_vector[v_idx];
1016 1037
1038 /* Coming from igb_set_interrupt_capability, the vectors are not yet
1039 * allocated. So, q_vector is NULL so we should stop here.
1040 */
1041 if (!q_vector)
1042 return;
1043
1017 if (q_vector->tx.ring) 1044 if (q_vector->tx.ring)
1018 adapter->tx_ring[q_vector->tx.ring->queue_index] = NULL; 1045 adapter->tx_ring[q_vector->tx.ring->queue_index] = NULL;
1019 1046
@@ -1111,16 +1138,18 @@ static void igb_set_interrupt_capability(struct igb_adapter *adapter, bool msix)
1111 for (i = 0; i < numvecs; i++) 1138 for (i = 0; i < numvecs; i++)
1112 adapter->msix_entries[i].entry = i; 1139 adapter->msix_entries[i].entry = i;
1113 1140
1114 err = pci_enable_msix(adapter->pdev, 1141 err = pci_enable_msix_range(adapter->pdev,
1115 adapter->msix_entries, 1142 adapter->msix_entries,
1116 numvecs); 1143 numvecs,
1117 if (err == 0) 1144 numvecs);
1145 if (err > 0)
1118 return; 1146 return;
1119 1147
1120 igb_reset_interrupt_capability(adapter); 1148 igb_reset_interrupt_capability(adapter);
1121 1149
1122 /* If we can't do MSI-X, try MSI */ 1150 /* If we can't do MSI-X, try MSI */
1123msi_only: 1151msi_only:
1152 adapter->flags &= ~IGB_FLAG_HAS_MSIX;
1124#ifdef CONFIG_PCI_IOV 1153#ifdef CONFIG_PCI_IOV
1125 /* disable SR-IOV for non MSI-X configurations */ 1154 /* disable SR-IOV for non MSI-X configurations */
1126 if (adapter->vf_data) { 1155 if (adapter->vf_data) {
@@ -1726,6 +1755,10 @@ int igb_up(struct igb_adapter *adapter)
1726 hw->mac.get_link_status = 1; 1755 hw->mac.get_link_status = 1;
1727 schedule_work(&adapter->watchdog_task); 1756 schedule_work(&adapter->watchdog_task);
1728 1757
1758 if ((adapter->flags & IGB_FLAG_EEE) &&
1759 (!hw->dev_spec._82575.eee_disable))
1760 adapter->eee_advert = MDIO_EEE_100TX | MDIO_EEE_1000T;
1761
1729 return 0; 1762 return 0;
1730} 1763}
1731 1764
@@ -1974,6 +2007,21 @@ void igb_reset(struct igb_adapter *adapter)
1974 } 2007 }
1975 } 2008 }
1976#endif 2009#endif
2010 /* Re-establish EEE setting */
2011 if (hw->phy.media_type == e1000_media_type_copper) {
2012 switch (mac->type) {
2013 case e1000_i350:
2014 case e1000_i210:
2015 case e1000_i211:
2016 igb_set_eee_i350(hw);
2017 break;
2018 case e1000_i354:
2019 igb_set_eee_i354(hw);
2020 break;
2021 default:
2022 break;
2023 }
2024 }
1977 if (!netif_running(adapter->netdev)) 2025 if (!netif_running(adapter->netdev))
1978 igb_power_down_link(adapter); 2026 igb_power_down_link(adapter);
1979 2027
@@ -2560,23 +2608,36 @@ static int igb_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
2560 (adapter->flags & IGB_FLAG_HAS_MSIX) ? "MSI-X" : 2608 (adapter->flags & IGB_FLAG_HAS_MSIX) ? "MSI-X" :
2561 (adapter->flags & IGB_FLAG_HAS_MSI) ? "MSI" : "legacy", 2609 (adapter->flags & IGB_FLAG_HAS_MSI) ? "MSI" : "legacy",
2562 adapter->num_rx_queues, adapter->num_tx_queues); 2610 adapter->num_rx_queues, adapter->num_tx_queues);
2563 switch (hw->mac.type) { 2611 if (hw->phy.media_type == e1000_media_type_copper) {
2564 case e1000_i350: 2612 switch (hw->mac.type) {
2565 case e1000_i210: 2613 case e1000_i350:
2566 case e1000_i211: 2614 case e1000_i210:
2567 igb_set_eee_i350(hw); 2615 case e1000_i211:
2568 break; 2616 /* Enable EEE for internal copper PHY devices */
2569 case e1000_i354: 2617 err = igb_set_eee_i350(hw);
2570 if (hw->phy.media_type == e1000_media_type_copper) { 2618 if ((!err) &&
2619 (!hw->dev_spec._82575.eee_disable)) {
2620 adapter->eee_advert =
2621 MDIO_EEE_100TX | MDIO_EEE_1000T;
2622 adapter->flags |= IGB_FLAG_EEE;
2623 }
2624 break;
2625 case e1000_i354:
2571 if ((rd32(E1000_CTRL_EXT) & 2626 if ((rd32(E1000_CTRL_EXT) &
2572 E1000_CTRL_EXT_LINK_MODE_SGMII)) 2627 E1000_CTRL_EXT_LINK_MODE_SGMII)) {
2573 igb_set_eee_i354(hw); 2628 err = igb_set_eee_i354(hw);
2629 if ((!err) &&
2630 (!hw->dev_spec._82575.eee_disable)) {
2631 adapter->eee_advert =
2632 MDIO_EEE_100TX | MDIO_EEE_1000T;
2633 adapter->flags |= IGB_FLAG_EEE;
2634 }
2635 }
2636 break;
2637 default:
2638 break;
2574 } 2639 }
2575 break;
2576 default:
2577 break;
2578 } 2640 }
2579
2580 pm_runtime_put_noidle(&pdev->dev); 2641 pm_runtime_put_noidle(&pdev->dev);
2581 return 0; 2642 return 0;
2582 2643
@@ -3510,6 +3571,13 @@ static inline void igb_set_vmolr(struct igb_adapter *adapter,
3510 3571
3511 vmolr = rd32(E1000_VMOLR(vfn)); 3572 vmolr = rd32(E1000_VMOLR(vfn));
3512 vmolr |= E1000_VMOLR_STRVLAN; /* Strip vlan tags */ 3573 vmolr |= E1000_VMOLR_STRVLAN; /* Strip vlan tags */
3574 if (hw->mac.type == e1000_i350) {
3575 u32 dvmolr;
3576
3577 dvmolr = rd32(E1000_DVMOLR(vfn));
3578 dvmolr |= E1000_DVMOLR_STRVLAN;
3579 wr32(E1000_DVMOLR(vfn), dvmolr);
3580 }
3513 if (aupe) 3581 if (aupe)
3514 vmolr |= E1000_VMOLR_AUPE; /* Accept untagged packets */ 3582 vmolr |= E1000_VMOLR_AUPE; /* Accept untagged packets */
3515 else 3583 else
@@ -4158,6 +4226,15 @@ static void igb_watchdog_task(struct work_struct *work)
4158 (ctrl & E1000_CTRL_RFCE) ? "RX" : 4226 (ctrl & E1000_CTRL_RFCE) ? "RX" :
4159 (ctrl & E1000_CTRL_TFCE) ? "TX" : "None"); 4227 (ctrl & E1000_CTRL_TFCE) ? "TX" : "None");
4160 4228
4229 /* disable EEE if enabled */
4230 if ((adapter->flags & IGB_FLAG_EEE) &&
4231 (adapter->link_duplex == HALF_DUPLEX)) {
4232 dev_info(&adapter->pdev->dev,
4233 "EEE Disabled: unsupported at half duplex. Re-enable using ethtool when at full duplex.\n");
4234 adapter->hw.dev_spec._82575.eee_disable = true;
4235 adapter->flags &= ~IGB_FLAG_EEE;
4236 }
4237
4161 /* check if SmartSpeed worked */ 4238 /* check if SmartSpeed worked */
4162 igb_check_downshift(hw); 4239 igb_check_downshift(hw);
4163 if (phy->speed_downgraded) 4240 if (phy->speed_downgraded)
@@ -4306,8 +4383,7 @@ enum latency_range {
4306 * were determined based on theoretical maximum wire speed and testing 4383 * were determined based on theoretical maximum wire speed and testing
4307 * data, in order to minimize response time while increasing bulk 4384 * data, in order to minimize response time while increasing bulk
4308 * throughput. 4385 * throughput.
4309 * This functionality is controlled by the InterruptThrottleRate module 4386 * This functionality is controlled by ethtool's coalescing settings.
4310 * parameter (see igb_param.c)
4311 * NOTE: This function is called only when operating in a multiqueue 4387 * NOTE: This function is called only when operating in a multiqueue
4312 * receive environment. 4388 * receive environment.
4313 **/ 4389 **/
@@ -4381,8 +4457,7 @@ clear_counts:
4381 * based on theoretical maximum wire speed and thresholds were set based 4457 * based on theoretical maximum wire speed and thresholds were set based
4382 * on testing data as well as attempting to minimize response time 4458 * on testing data as well as attempting to minimize response time
4383 * while increasing bulk throughput. 4459 * while increasing bulk throughput.
4384 * this functionality is controlled by the InterruptThrottleRate module 4460 * This functionality is controlled by ethtool's coalescing settings.
4385 * parameter (see igb_param.c)
4386 * NOTE: These calculations are only valid when operating in a single- 4461 * NOTE: These calculations are only valid when operating in a single-
4387 * queue environment. 4462 * queue environment.
4388 **/ 4463 **/
@@ -4546,7 +4621,7 @@ static int igb_tso(struct igb_ring *tx_ring,
4546 /* ADV DTYP TUCMD MKRLOC/ISCSIHEDLEN */ 4621 /* ADV DTYP TUCMD MKRLOC/ISCSIHEDLEN */
4547 type_tucmd = E1000_ADVTXD_TUCMD_L4T_TCP; 4622 type_tucmd = E1000_ADVTXD_TUCMD_L4T_TCP;
4548 4623
4549 if (first->protocol == __constant_htons(ETH_P_IP)) { 4624 if (first->protocol == htons(ETH_P_IP)) {
4550 struct iphdr *iph = ip_hdr(skb); 4625 struct iphdr *iph = ip_hdr(skb);
4551 iph->tot_len = 0; 4626 iph->tot_len = 0;
4552 iph->check = 0; 4627 iph->check = 0;
@@ -4602,12 +4677,12 @@ static void igb_tx_csum(struct igb_ring *tx_ring, struct igb_tx_buffer *first)
4602 } else { 4677 } else {
4603 u8 l4_hdr = 0; 4678 u8 l4_hdr = 0;
4604 switch (first->protocol) { 4679 switch (first->protocol) {
4605 case __constant_htons(ETH_P_IP): 4680 case htons(ETH_P_IP):
4606 vlan_macip_lens |= skb_network_header_len(skb); 4681 vlan_macip_lens |= skb_network_header_len(skb);
4607 type_tucmd |= E1000_ADVTXD_TUCMD_IPV4; 4682 type_tucmd |= E1000_ADVTXD_TUCMD_IPV4;
4608 l4_hdr = ip_hdr(skb)->protocol; 4683 l4_hdr = ip_hdr(skb)->protocol;
4609 break; 4684 break;
4610 case __constant_htons(ETH_P_IPV6): 4685 case htons(ETH_P_IPV6):
4611 vlan_macip_lens |= skb_network_header_len(skb); 4686 vlan_macip_lens |= skb_network_header_len(skb);
4612 l4_hdr = ipv6_hdr(skb)->nexthdr; 4687 l4_hdr = ipv6_hdr(skb)->nexthdr;
4613 break; 4688 break;
@@ -5127,10 +5202,10 @@ void igb_update_stats(struct igb_adapter *adapter,
5127 } 5202 }
5128 5203
5129 do { 5204 do {
5130 start = u64_stats_fetch_begin_bh(&ring->rx_syncp); 5205 start = u64_stats_fetch_begin_irq(&ring->rx_syncp);
5131 _bytes = ring->rx_stats.bytes; 5206 _bytes = ring->rx_stats.bytes;
5132 _packets = ring->rx_stats.packets; 5207 _packets = ring->rx_stats.packets;
5133 } while (u64_stats_fetch_retry_bh(&ring->rx_syncp, start)); 5208 } while (u64_stats_fetch_retry_irq(&ring->rx_syncp, start));
5134 bytes += _bytes; 5209 bytes += _bytes;
5135 packets += _packets; 5210 packets += _packets;
5136 } 5211 }
@@ -5143,10 +5218,10 @@ void igb_update_stats(struct igb_adapter *adapter,
5143 for (i = 0; i < adapter->num_tx_queues; i++) { 5218 for (i = 0; i < adapter->num_tx_queues; i++) {
5144 struct igb_ring *ring = adapter->tx_ring[i]; 5219 struct igb_ring *ring = adapter->tx_ring[i];
5145 do { 5220 do {
5146 start = u64_stats_fetch_begin_bh(&ring->tx_syncp); 5221 start = u64_stats_fetch_begin_irq(&ring->tx_syncp);
5147 _bytes = ring->tx_stats.bytes; 5222 _bytes = ring->tx_stats.bytes;
5148 _packets = ring->tx_stats.packets; 5223 _packets = ring->tx_stats.packets;
5149 } while (u64_stats_fetch_retry_bh(&ring->tx_syncp, start)); 5224 } while (u64_stats_fetch_retry_irq(&ring->tx_syncp, start));
5150 bytes += _bytes; 5225 bytes += _bytes;
5151 packets += _packets; 5226 packets += _packets;
5152 } 5227 }
@@ -6620,7 +6695,9 @@ static inline void igb_rx_hash(struct igb_ring *ring,
6620 struct sk_buff *skb) 6695 struct sk_buff *skb)
6621{ 6696{
6622 if (ring->netdev->features & NETIF_F_RXHASH) 6697 if (ring->netdev->features & NETIF_F_RXHASH)
6623 skb->rxhash = le32_to_cpu(rx_desc->wb.lower.hi_dword.rss); 6698 skb_set_hash(skb,
6699 le32_to_cpu(rx_desc->wb.lower.hi_dword.rss),
6700 PKT_HASH_TYPE_L3);
6624} 6701}
6625 6702
6626/** 6703/**
@@ -6690,7 +6767,7 @@ static unsigned int igb_get_headlen(unsigned char *data,
6690 hdr.network += ETH_HLEN; 6767 hdr.network += ETH_HLEN;
6691 6768
6692 /* handle any vlan tag if present */ 6769 /* handle any vlan tag if present */
6693 if (protocol == __constant_htons(ETH_P_8021Q)) { 6770 if (protocol == htons(ETH_P_8021Q)) {
6694 if ((hdr.network - data) > (max_len - VLAN_HLEN)) 6771 if ((hdr.network - data) > (max_len - VLAN_HLEN))
6695 return max_len; 6772 return max_len;
6696 6773
@@ -6699,7 +6776,7 @@ static unsigned int igb_get_headlen(unsigned char *data,
6699 } 6776 }
6700 6777
6701 /* handle L3 protocols */ 6778 /* handle L3 protocols */
6702 if (protocol == __constant_htons(ETH_P_IP)) { 6779 if (protocol == htons(ETH_P_IP)) {
6703 if ((hdr.network - data) > (max_len - sizeof(struct iphdr))) 6780 if ((hdr.network - data) > (max_len - sizeof(struct iphdr)))
6704 return max_len; 6781 return max_len;
6705 6782
@@ -6713,7 +6790,7 @@ static unsigned int igb_get_headlen(unsigned char *data,
6713 /* record next protocol if header is present */ 6790 /* record next protocol if header is present */
6714 if (!(hdr.ipv4->frag_off & htons(IP_OFFSET))) 6791 if (!(hdr.ipv4->frag_off & htons(IP_OFFSET)))
6715 nexthdr = hdr.ipv4->protocol; 6792 nexthdr = hdr.ipv4->protocol;
6716 } else if (protocol == __constant_htons(ETH_P_IPV6)) { 6793 } else if (protocol == htons(ETH_P_IPV6)) {
6717 if ((hdr.network - data) > (max_len - sizeof(struct ipv6hdr))) 6794 if ((hdr.network - data) > (max_len - sizeof(struct ipv6hdr)))
6718 return max_len; 6795 return max_len;
6719 6796
@@ -6903,7 +6980,7 @@ static bool igb_clean_rx_irq(struct igb_q_vector *q_vector, const int budget)
6903 unsigned int total_bytes = 0, total_packets = 0; 6980 unsigned int total_bytes = 0, total_packets = 0;
6904 u16 cleaned_count = igb_desc_unused(rx_ring); 6981 u16 cleaned_count = igb_desc_unused(rx_ring);
6905 6982
6906 do { 6983 while (likely(total_packets < budget)) {
6907 union e1000_adv_rx_desc *rx_desc; 6984 union e1000_adv_rx_desc *rx_desc;
6908 6985
6909 /* return some buffers to hardware, one at a time is too slow */ 6986 /* return some buffers to hardware, one at a time is too slow */
@@ -6955,7 +7032,7 @@ static bool igb_clean_rx_irq(struct igb_q_vector *q_vector, const int budget)
6955 7032
6956 /* update budget accounting */ 7033 /* update budget accounting */
6957 total_packets++; 7034 total_packets++;
6958 } while (likely(total_packets < budget)); 7035 }
6959 7036
6960 /* place incomplete frames back on ring for completion */ 7037 /* place incomplete frames back on ring for completion */
6961 rx_ring->skb = skb; 7038 rx_ring->skb = skb;
@@ -7114,8 +7191,10 @@ static int igb_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)
7114 case SIOCGMIIREG: 7191 case SIOCGMIIREG:
7115 case SIOCSMIIREG: 7192 case SIOCSMIIREG:
7116 return igb_mii_ioctl(netdev, ifr, cmd); 7193 return igb_mii_ioctl(netdev, ifr, cmd);
7194 case SIOCGHWTSTAMP:
7195 return igb_ptp_get_ts_config(netdev, ifr);
7117 case SIOCSHWTSTAMP: 7196 case SIOCSHWTSTAMP:
7118 return igb_ptp_hwtstamp_ioctl(netdev, ifr, cmd); 7197 return igb_ptp_set_ts_config(netdev, ifr);
7119 default: 7198 default:
7120 return -EOPNOTSUPP; 7199 return -EOPNOTSUPP;
7121 } 7200 }
diff --git a/drivers/net/ethernet/intel/igb/igb_ptp.c b/drivers/net/ethernet/intel/igb/igb_ptp.c
index 5a54e3dc535d..da55fbb090b2 100644
--- a/drivers/net/ethernet/intel/igb/igb_ptp.c
+++ b/drivers/net/ethernet/intel/igb/igb_ptp.c
@@ -12,9 +12,8 @@
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details. 13 * GNU General Public License for more details.
14 * 14 *
15 * You should have received a copy of the GNU General Public License along 15 * You should have received a copy of the GNU General Public License along with
16 * with this program; if not, write to the Free Software Foundation, Inc., 16 * this program; if not, see <http://www.gnu.org/licenses/>.
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */ 17 */
19#include <linux/module.h> 18#include <linux/module.h>
20#include <linux/device.h> 19#include <linux/device.h>
@@ -75,6 +74,8 @@
75#define INCVALUE_82576 (16 << IGB_82576_TSYNC_SHIFT) 74#define INCVALUE_82576 (16 << IGB_82576_TSYNC_SHIFT)
76#define IGB_NBITS_82580 40 75#define IGB_NBITS_82580 40
77 76
77static void igb_ptp_tx_hwtstamp(struct igb_adapter *adapter);
78
78/* SYSTIM read access for the 82576 */ 79/* SYSTIM read access for the 82576 */
79static cycle_t igb_ptp_read_82576(const struct cyclecounter *cc) 80static cycle_t igb_ptp_read_82576(const struct cyclecounter *cc)
80{ 81{
@@ -372,7 +373,7 @@ static int igb_ptp_enable(struct ptp_clock_info *ptp,
372 * This work function polls the TSYNCTXCTL valid bit to determine when a 373 * This work function polls the TSYNCTXCTL valid bit to determine when a
373 * timestamp has been taken for the current stored skb. 374 * timestamp has been taken for the current stored skb.
374 **/ 375 **/
375void igb_ptp_tx_work(struct work_struct *work) 376static void igb_ptp_tx_work(struct work_struct *work)
376{ 377{
377 struct igb_adapter *adapter = container_of(work, struct igb_adapter, 378 struct igb_adapter *adapter = container_of(work, struct igb_adapter,
378 ptp_tx_work); 379 ptp_tx_work);
@@ -466,7 +467,7 @@ void igb_ptp_rx_hang(struct igb_adapter *adapter)
466 * available, then it must have been for this skb here because we only 467 * available, then it must have been for this skb here because we only
467 * allow only one such packet into the queue. 468 * allow only one such packet into the queue.
468 **/ 469 **/
469void igb_ptp_tx_hwtstamp(struct igb_adapter *adapter) 470static void igb_ptp_tx_hwtstamp(struct igb_adapter *adapter)
470{ 471{
471 struct e1000_hw *hw = &adapter->hw; 472 struct e1000_hw *hw = &adapter->hw;
472 struct skb_shared_hwtstamps shhwtstamps; 473 struct skb_shared_hwtstamps shhwtstamps;
@@ -540,10 +541,26 @@ void igb_ptp_rx_rgtstamp(struct igb_q_vector *q_vector,
540} 541}
541 542
542/** 543/**
543 * igb_ptp_hwtstamp_ioctl - control hardware time stamping 544 * igb_ptp_get_ts_config - get hardware time stamping config
545 * @netdev:
546 * @ifreq:
547 *
548 * Get the hwtstamp_config settings to return to the user. Rather than attempt
549 * to deconstruct the settings from the registers, just return a shadow copy
550 * of the last known settings.
551 **/
552int igb_ptp_get_ts_config(struct net_device *netdev, struct ifreq *ifr)
553{
554 struct igb_adapter *adapter = netdev_priv(netdev);
555 struct hwtstamp_config *config = &adapter->tstamp_config;
556
557 return copy_to_user(ifr->ifr_data, config, sizeof(*config)) ?
558 -EFAULT : 0;
559}
560/**
561 * igb_ptp_set_ts_config - control hardware time stamping
544 * @netdev: 562 * @netdev:
545 * @ifreq: 563 * @ifreq:
546 * @cmd:
547 * 564 *
548 * Outgoing time stamping can be enabled and disabled. Play nice and 565 * Outgoing time stamping can be enabled and disabled. Play nice and
549 * disable it when requested, although it shouldn't case any overhead 566 * disable it when requested, although it shouldn't case any overhead
@@ -557,12 +574,11 @@ void igb_ptp_rx_rgtstamp(struct igb_q_vector *q_vector,
557 * not supported, with the exception of "all V2 events regardless of 574 * not supported, with the exception of "all V2 events regardless of
558 * level 2 or 4". 575 * level 2 or 4".
559 **/ 576 **/
560int igb_ptp_hwtstamp_ioctl(struct net_device *netdev, 577int igb_ptp_set_ts_config(struct net_device *netdev, struct ifreq *ifr)
561 struct ifreq *ifr, int cmd)
562{ 578{
563 struct igb_adapter *adapter = netdev_priv(netdev); 579 struct igb_adapter *adapter = netdev_priv(netdev);
564 struct e1000_hw *hw = &adapter->hw; 580 struct e1000_hw *hw = &adapter->hw;
565 struct hwtstamp_config config; 581 struct hwtstamp_config *config = &adapter->tstamp_config;
566 u32 tsync_tx_ctl = E1000_TSYNCTXCTL_ENABLED; 582 u32 tsync_tx_ctl = E1000_TSYNCTXCTL_ENABLED;
567 u32 tsync_rx_ctl = E1000_TSYNCRXCTL_ENABLED; 583 u32 tsync_rx_ctl = E1000_TSYNCRXCTL_ENABLED;
568 u32 tsync_rx_cfg = 0; 584 u32 tsync_rx_cfg = 0;
@@ -570,14 +586,14 @@ int igb_ptp_hwtstamp_ioctl(struct net_device *netdev,
570 bool is_l2 = false; 586 bool is_l2 = false;
571 u32 regval; 587 u32 regval;
572 588
573 if (copy_from_user(&config, ifr->ifr_data, sizeof(config))) 589 if (copy_from_user(config, ifr->ifr_data, sizeof(*config)))
574 return -EFAULT; 590 return -EFAULT;
575 591
576 /* reserved for future extensions */ 592 /* reserved for future extensions */
577 if (config.flags) 593 if (config->flags)
578 return -EINVAL; 594 return -EINVAL;
579 595
580 switch (config.tx_type) { 596 switch (config->tx_type) {
581 case HWTSTAMP_TX_OFF: 597 case HWTSTAMP_TX_OFF:
582 tsync_tx_ctl = 0; 598 tsync_tx_ctl = 0;
583 case HWTSTAMP_TX_ON: 599 case HWTSTAMP_TX_ON:
@@ -586,7 +602,7 @@ int igb_ptp_hwtstamp_ioctl(struct net_device *netdev,
586 return -ERANGE; 602 return -ERANGE;
587 } 603 }
588 604
589 switch (config.rx_filter) { 605 switch (config->rx_filter) {
590 case HWTSTAMP_FILTER_NONE: 606 case HWTSTAMP_FILTER_NONE:
591 tsync_rx_ctl = 0; 607 tsync_rx_ctl = 0;
592 break; 608 break;
@@ -610,7 +626,7 @@ int igb_ptp_hwtstamp_ioctl(struct net_device *netdev,
610 case HWTSTAMP_FILTER_PTP_V2_L2_DELAY_REQ: 626 case HWTSTAMP_FILTER_PTP_V2_L2_DELAY_REQ:
611 case HWTSTAMP_FILTER_PTP_V2_L4_DELAY_REQ: 627 case HWTSTAMP_FILTER_PTP_V2_L4_DELAY_REQ:
612 tsync_rx_ctl |= E1000_TSYNCRXCTL_TYPE_EVENT_V2; 628 tsync_rx_ctl |= E1000_TSYNCRXCTL_TYPE_EVENT_V2;
613 config.rx_filter = HWTSTAMP_FILTER_PTP_V2_EVENT; 629 config->rx_filter = HWTSTAMP_FILTER_PTP_V2_EVENT;
614 is_l2 = true; 630 is_l2 = true;
615 is_l4 = true; 631 is_l4 = true;
616 break; 632 break;
@@ -621,12 +637,12 @@ int igb_ptp_hwtstamp_ioctl(struct net_device *netdev,
621 */ 637 */
622 if (hw->mac.type != e1000_82576) { 638 if (hw->mac.type != e1000_82576) {
623 tsync_rx_ctl |= E1000_TSYNCRXCTL_TYPE_ALL; 639 tsync_rx_ctl |= E1000_TSYNCRXCTL_TYPE_ALL;
624 config.rx_filter = HWTSTAMP_FILTER_ALL; 640 config->rx_filter = HWTSTAMP_FILTER_ALL;
625 break; 641 break;
626 } 642 }
627 /* fall through */ 643 /* fall through */
628 default: 644 default:
629 config.rx_filter = HWTSTAMP_FILTER_NONE; 645 config->rx_filter = HWTSTAMP_FILTER_NONE;
630 return -ERANGE; 646 return -ERANGE;
631 } 647 }
632 648
@@ -643,7 +659,7 @@ int igb_ptp_hwtstamp_ioctl(struct net_device *netdev,
643 if ((hw->mac.type >= e1000_82580) && tsync_rx_ctl) { 659 if ((hw->mac.type >= e1000_82580) && tsync_rx_ctl) {
644 tsync_rx_ctl = E1000_TSYNCRXCTL_ENABLED; 660 tsync_rx_ctl = E1000_TSYNCRXCTL_ENABLED;
645 tsync_rx_ctl |= E1000_TSYNCRXCTL_TYPE_ALL; 661 tsync_rx_ctl |= E1000_TSYNCRXCTL_TYPE_ALL;
646 config.rx_filter = HWTSTAMP_FILTER_ALL; 662 config->rx_filter = HWTSTAMP_FILTER_ALL;
647 is_l2 = true; 663 is_l2 = true;
648 is_l4 = true; 664 is_l4 = true;
649 665
@@ -707,7 +723,7 @@ int igb_ptp_hwtstamp_ioctl(struct net_device *netdev,
707 regval = rd32(E1000_RXSTMPL); 723 regval = rd32(E1000_RXSTMPL);
708 regval = rd32(E1000_RXSTMPH); 724 regval = rd32(E1000_RXSTMPH);
709 725
710 return copy_to_user(ifr->ifr_data, &config, sizeof(config)) ? 726 return copy_to_user(ifr->ifr_data, config, sizeof(*config)) ?
711 -EFAULT : 0; 727 -EFAULT : 0;
712} 728}
713 729
@@ -798,7 +814,7 @@ void igb_ptp_init(struct igb_adapter *adapter)
798 814
799 /* Initialize the time sync interrupts for devices that support it. */ 815 /* Initialize the time sync interrupts for devices that support it. */
800 if (hw->mac.type >= e1000_82580) { 816 if (hw->mac.type >= e1000_82580) {
801 wr32(E1000_TSIM, E1000_TSIM_TXTS); 817 wr32(E1000_TSIM, TSYNC_INTERRUPTS);
802 wr32(E1000_IMS, E1000_IMS_TS); 818 wr32(E1000_IMS, E1000_IMS_TS);
803 } 819 }
804 820
@@ -864,6 +880,9 @@ void igb_ptp_reset(struct igb_adapter *adapter)
864 if (!(adapter->flags & IGB_FLAG_PTP)) 880 if (!(adapter->flags & IGB_FLAG_PTP))
865 return; 881 return;
866 882
883 /* reset the tstamp_config */
884 memset(&adapter->tstamp_config, 0, sizeof(adapter->tstamp_config));
885
867 switch (adapter->hw.mac.type) { 886 switch (adapter->hw.mac.type) {
868 case e1000_82576: 887 case e1000_82576:
869 /* Dial the nominal frequency. */ 888 /* Dial the nominal frequency. */
@@ -876,7 +895,7 @@ void igb_ptp_reset(struct igb_adapter *adapter)
876 case e1000_i211: 895 case e1000_i211:
877 /* Enable the timer functions and interrupts. */ 896 /* Enable the timer functions and interrupts. */
878 wr32(E1000_TSAUXC, 0x0); 897 wr32(E1000_TSAUXC, 0x0);
879 wr32(E1000_TSIM, E1000_TSIM_TXTS); 898 wr32(E1000_TSIM, TSYNC_INTERRUPTS);
880 wr32(E1000_IMS, E1000_IMS_TS); 899 wr32(E1000_IMS, E1000_IMS_TS);
881 break; 900 break;
882 default: 901 default:
diff --git a/drivers/net/ethernet/intel/igbvf/netdev.c b/drivers/net/ethernet/intel/igbvf/netdev.c
index 675435fc2e53..b7ab03a2f28f 100644
--- a/drivers/net/ethernet/intel/igbvf/netdev.c
+++ b/drivers/net/ethernet/intel/igbvf/netdev.c
@@ -1043,11 +1043,11 @@ static void igbvf_set_interrupt_capability(struct igbvf_adapter *adapter)
1043 for (i = 0; i < 3; i++) 1043 for (i = 0; i < 3; i++)
1044 adapter->msix_entries[i].entry = i; 1044 adapter->msix_entries[i].entry = i;
1045 1045
1046 err = pci_enable_msix(adapter->pdev, 1046 err = pci_enable_msix_range(adapter->pdev,
1047 adapter->msix_entries, 3); 1047 adapter->msix_entries, 3, 3);
1048 } 1048 }
1049 1049
1050 if (err) { 1050 if (err < 0) {
1051 /* MSI-X failed */ 1051 /* MSI-X failed */
1052 dev_err(&adapter->pdev->dev, 1052 dev_err(&adapter->pdev->dev,
1053 "Failed to initialize MSI-X interrupts.\n"); 1053 "Failed to initialize MSI-X interrupts.\n");
@@ -2014,12 +2014,12 @@ static inline bool igbvf_tx_csum(struct igbvf_adapter *adapter,
2014 2014
2015 if (skb->ip_summed == CHECKSUM_PARTIAL) { 2015 if (skb->ip_summed == CHECKSUM_PARTIAL) {
2016 switch (skb->protocol) { 2016 switch (skb->protocol) {
2017 case __constant_htons(ETH_P_IP): 2017 case htons(ETH_P_IP):
2018 tu_cmd |= E1000_ADVTXD_TUCMD_IPV4; 2018 tu_cmd |= E1000_ADVTXD_TUCMD_IPV4;
2019 if (ip_hdr(skb)->protocol == IPPROTO_TCP) 2019 if (ip_hdr(skb)->protocol == IPPROTO_TCP)
2020 tu_cmd |= E1000_ADVTXD_TUCMD_L4T_TCP; 2020 tu_cmd |= E1000_ADVTXD_TUCMD_L4T_TCP;
2021 break; 2021 break;
2022 case __constant_htons(ETH_P_IPV6): 2022 case htons(ETH_P_IPV6):
2023 if (ipv6_hdr(skb)->nexthdr == IPPROTO_TCP) 2023 if (ipv6_hdr(skb)->nexthdr == IPPROTO_TCP)
2024 tu_cmd |= E1000_ADVTXD_TUCMD_L4T_TCP; 2024 tu_cmd |= E1000_ADVTXD_TUCMD_L4T_TCP;
2025 break; 2025 break;
diff --git a/drivers/net/ethernet/intel/ixgb/ixgb_main.c b/drivers/net/ethernet/intel/ixgb/ixgb_main.c
index 57e390cbe6d0..f42c201f727f 100644
--- a/drivers/net/ethernet/intel/ixgb/ixgb_main.c
+++ b/drivers/net/ethernet/intel/ixgb/ixgb_main.c
@@ -1521,12 +1521,12 @@ ixgb_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
1521 int tso; 1521 int tso;
1522 1522
1523 if (test_bit(__IXGB_DOWN, &adapter->flags)) { 1523 if (test_bit(__IXGB_DOWN, &adapter->flags)) {
1524 dev_kfree_skb(skb); 1524 dev_kfree_skb_any(skb);
1525 return NETDEV_TX_OK; 1525 return NETDEV_TX_OK;
1526 } 1526 }
1527 1527
1528 if (skb->len <= 0) { 1528 if (skb->len <= 0) {
1529 dev_kfree_skb(skb); 1529 dev_kfree_skb_any(skb);
1530 return NETDEV_TX_OK; 1530 return NETDEV_TX_OK;
1531 } 1531 }
1532 1532
@@ -1543,7 +1543,7 @@ ixgb_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
1543 1543
1544 tso = ixgb_tso(adapter, skb); 1544 tso = ixgb_tso(adapter, skb);
1545 if (tso < 0) { 1545 if (tso < 0) {
1546 dev_kfree_skb(skb); 1546 dev_kfree_skb_any(skb);
1547 return NETDEV_TX_OK; 1547 return NETDEV_TX_OK;
1548 } 1548 }
1549 1549
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe.h b/drivers/net/ethernet/intel/ixgbe/ixgbe.h
index 0186ea2969fe..2fff0fc4e6e8 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe.h
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe.h
@@ -20,6 +20,7 @@
20 the file called "COPYING". 20 the file called "COPYING".
21 21
22 Contact Information: 22 Contact Information:
23 Linux NICS <linux.nics@intel.com>
23 e1000-devel Mailing List <e1000-devel@lists.sourceforge.net> 24 e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
24 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 25 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
25 26
@@ -765,6 +766,7 @@ struct ixgbe_adapter {
765 struct ptp_clock_info ptp_caps; 766 struct ptp_clock_info ptp_caps;
766 struct work_struct ptp_tx_work; 767 struct work_struct ptp_tx_work;
767 struct sk_buff *ptp_tx_skb; 768 struct sk_buff *ptp_tx_skb;
769 struct hwtstamp_config tstamp_config;
768 unsigned long ptp_tx_start; 770 unsigned long ptp_tx_start;
769 unsigned long last_overflow_check; 771 unsigned long last_overflow_check;
770 unsigned long last_rx_ptp_check; 772 unsigned long last_rx_ptp_check;
@@ -884,7 +886,6 @@ s32 ixgbe_fdir_erase_perfect_filter_82599(struct ixgbe_hw *hw,
884 u16 soft_id); 886 u16 soft_id);
885void ixgbe_atr_compute_perfect_hash_82599(union ixgbe_atr_input *input, 887void ixgbe_atr_compute_perfect_hash_82599(union ixgbe_atr_input *input,
886 union ixgbe_atr_input *mask); 888 union ixgbe_atr_input *mask);
887bool ixgbe_verify_lesm_fw_enabled_82599(struct ixgbe_hw *hw);
888void ixgbe_set_rx_mode(struct net_device *netdev); 889void ixgbe_set_rx_mode(struct net_device *netdev);
889#ifdef CONFIG_IXGBE_DCB 890#ifdef CONFIG_IXGBE_DCB
890void ixgbe_set_rx_drop_en(struct ixgbe_adapter *adapter); 891void ixgbe_set_rx_drop_en(struct ixgbe_adapter *adapter);
@@ -958,8 +959,8 @@ static inline void ixgbe_ptp_rx_hwtstamp(struct ixgbe_ring *rx_ring,
958 rx_ring->last_rx_timestamp = jiffies; 959 rx_ring->last_rx_timestamp = jiffies;
959} 960}
960 961
961int ixgbe_ptp_hwtstamp_ioctl(struct ixgbe_adapter *adapter, struct ifreq *ifr, 962int ixgbe_ptp_set_ts_config(struct ixgbe_adapter *adapter, struct ifreq *ifr);
962 int cmd); 963int ixgbe_ptp_get_ts_config(struct ixgbe_adapter *adapter, struct ifreq *ifr);
963void ixgbe_ptp_start_cyclecounter(struct ixgbe_adapter *adapter); 964void ixgbe_ptp_start_cyclecounter(struct ixgbe_adapter *adapter);
964void ixgbe_ptp_reset(struct ixgbe_adapter *adapter); 965void ixgbe_ptp_reset(struct ixgbe_adapter *adapter);
965void ixgbe_ptp_check_pps_event(struct ixgbe_adapter *adapter, u32 eicr); 966void ixgbe_ptp_check_pps_event(struct ixgbe_adapter *adapter, u32 eicr);
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_82598.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_82598.c
index a26f3fee4f35..4c78ea8946c1 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_82598.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_82598.c
@@ -1,7 +1,7 @@
1/******************************************************************************* 1/*******************************************************************************
2 2
3 Intel 10 Gigabit PCI Express Linux driver 3 Intel 10 Gigabit PCI Express Linux driver
4 Copyright(c) 1999 - 2013 Intel Corporation. 4 Copyright(c) 1999 - 2014 Intel Corporation.
5 5
6 This program is free software; you can redistribute it and/or modify it 6 This program is free software; you can redistribute it and/or modify it
7 under the terms and conditions of the GNU General Public License, 7 under the terms and conditions of the GNU General Public License,
@@ -20,6 +20,7 @@
20 the file called "COPYING". 20 the file called "COPYING".
21 21
22 Contact Information: 22 Contact Information:
23 Linux NICS <linux.nics@intel.com>
23 e1000-devel Mailing List <e1000-devel@lists.sourceforge.net> 24 e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
24 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 25 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
25 26
@@ -57,10 +58,12 @@ static s32 ixgbe_read_i2c_eeprom_82598(struct ixgbe_hw *hw, u8 byte_offset,
57 **/ 58 **/
58static void ixgbe_set_pcie_completion_timeout(struct ixgbe_hw *hw) 59static void ixgbe_set_pcie_completion_timeout(struct ixgbe_hw *hw)
59{ 60{
60 struct ixgbe_adapter *adapter = hw->back;
61 u32 gcr = IXGBE_READ_REG(hw, IXGBE_GCR); 61 u32 gcr = IXGBE_READ_REG(hw, IXGBE_GCR);
62 u16 pcie_devctl2; 62 u16 pcie_devctl2;
63 63
64 if (ixgbe_removed(hw->hw_addr))
65 return;
66
64 /* only take action if timeout value is defaulted to 0 */ 67 /* only take action if timeout value is defaulted to 0 */
65 if (gcr & IXGBE_GCR_CMPL_TMOUT_MASK) 68 if (gcr & IXGBE_GCR_CMPL_TMOUT_MASK)
66 goto out; 69 goto out;
@@ -79,11 +82,9 @@ static void ixgbe_set_pcie_completion_timeout(struct ixgbe_hw *hw)
79 * directly in order to set the completion timeout value for 82 * directly in order to set the completion timeout value for
80 * 16ms to 55ms 83 * 16ms to 55ms
81 */ 84 */
82 pci_read_config_word(adapter->pdev, 85 pcie_devctl2 = ixgbe_read_pci_cfg_word(hw, IXGBE_PCI_DEVICE_CONTROL2);
83 IXGBE_PCI_DEVICE_CONTROL2, &pcie_devctl2);
84 pcie_devctl2 |= IXGBE_PCI_DEVICE_CONTROL2_16ms; 86 pcie_devctl2 |= IXGBE_PCI_DEVICE_CONTROL2_16ms;
85 pci_write_config_word(adapter->pdev, 87 ixgbe_write_pci_cfg_word(hw, IXGBE_PCI_DEVICE_CONTROL2, pcie_devctl2);
86 IXGBE_PCI_DEVICE_CONTROL2, pcie_devctl2);
87out: 88out:
88 /* disable completion timeout resend */ 89 /* disable completion timeout resend */
89 gcr &= ~IXGBE_GCR_CMPL_TMOUT_RESEND; 90 gcr &= ~IXGBE_GCR_CMPL_TMOUT_RESEND;
@@ -100,6 +101,7 @@ static s32 ixgbe_get_invariants_82598(struct ixgbe_hw *hw)
100 mac->mcft_size = IXGBE_82598_MC_TBL_SIZE; 101 mac->mcft_size = IXGBE_82598_MC_TBL_SIZE;
101 mac->vft_size = IXGBE_82598_VFT_TBL_SIZE; 102 mac->vft_size = IXGBE_82598_VFT_TBL_SIZE;
102 mac->num_rar_entries = IXGBE_82598_RAR_ENTRIES; 103 mac->num_rar_entries = IXGBE_82598_RAR_ENTRIES;
104 mac->rx_pb_size = IXGBE_82598_RX_PB_SIZE;
103 mac->max_rx_queues = IXGBE_82598_MAX_RX_QUEUES; 105 mac->max_rx_queues = IXGBE_82598_MAX_RX_QUEUES;
104 mac->max_tx_queues = IXGBE_82598_MAX_TX_QUEUES; 106 mac->max_tx_queues = IXGBE_82598_MAX_TX_QUEUES;
105 mac->max_msix_vectors = ixgbe_get_pcie_msix_count_generic(hw); 107 mac->max_msix_vectors = ixgbe_get_pcie_msix_count_generic(hw);
@@ -201,8 +203,6 @@ static s32 ixgbe_start_hw_82598(struct ixgbe_hw *hw)
201 IXGBE_WRITE_REG(hw, IXGBE_DCA_RXCTRL(i), regval); 203 IXGBE_WRITE_REG(hw, IXGBE_DCA_RXCTRL(i), regval);
202 } 204 }
203 205
204 hw->mac.rx_pb_size = IXGBE_82598_RX_PB_SIZE;
205
206 /* set the completion timeout for interface */ 206 /* set the completion timeout for interface */
207 if (ret_val == 0) 207 if (ret_val == 0)
208 ixgbe_set_pcie_completion_timeout(hw); 208 ixgbe_set_pcie_completion_timeout(hw);
@@ -1237,14 +1237,14 @@ static void ixgbe_set_lan_id_multi_port_pcie_82598(struct ixgbe_hw *hw)
1237} 1237}
1238 1238
1239/** 1239/**
1240 * ixgbe_set_rxpba_82598 - Configure packet buffers 1240 * ixgbe_set_rxpba_82598 - Initialize RX packet buffer
1241 * @hw: pointer to hardware structure 1241 * @hw: pointer to hardware structure
1242 * @dcb_config: pointer to ixgbe_dcb_config structure 1242 * @num_pb: number of packet buffers to allocate
1243 * 1243 * @headroom: reserve n KB of headroom
1244 * Configure packet buffers. 1244 * @strategy: packet buffer allocation strategy
1245 */ 1245 **/
1246static void ixgbe_set_rxpba_82598(struct ixgbe_hw *hw, int num_pb, u32 headroom, 1246static void ixgbe_set_rxpba_82598(struct ixgbe_hw *hw, int num_pb,
1247 int strategy) 1247 u32 headroom, int strategy)
1248{ 1248{
1249 u32 rxpktsize = IXGBE_RXPBSIZE_64KB; 1249 u32 rxpktsize = IXGBE_RXPBSIZE_64KB;
1250 u8 i = 0; 1250 u8 i = 0;
@@ -1315,7 +1315,8 @@ static struct ixgbe_mac_operations mac_ops_82598 = {
1315 .release_swfw_sync = &ixgbe_release_swfw_sync, 1315 .release_swfw_sync = &ixgbe_release_swfw_sync,
1316 .get_thermal_sensor_data = NULL, 1316 .get_thermal_sensor_data = NULL,
1317 .init_thermal_sensor_thresh = NULL, 1317 .init_thermal_sensor_thresh = NULL,
1318 .mng_fw_enabled = NULL, 1318 .prot_autoc_read = &prot_autoc_read_generic,
1319 .prot_autoc_write = &prot_autoc_write_generic,
1319}; 1320};
1320 1321
1321static struct ixgbe_eeprom_operations eeprom_ops_82598 = { 1322static struct ixgbe_eeprom_operations eeprom_ops_82598 = {
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_82599.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_82599.c
index edda6814108c..f32b3dd1ba8e 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_82599.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_82599.c
@@ -1,7 +1,7 @@
1/******************************************************************************* 1/*******************************************************************************
2 2
3 Intel 10 Gigabit PCI Express Linux driver 3 Intel 10 Gigabit PCI Express Linux driver
4 Copyright(c) 1999 - 2013 Intel Corporation. 4 Copyright(c) 1999 - 2014 Intel Corporation.
5 5
6 This program is free software; you can redistribute it and/or modify it 6 This program is free software; you can redistribute it and/or modify it
7 under the terms and conditions of the GNU General Public License, 7 under the terms and conditions of the GNU General Public License,
@@ -20,6 +20,7 @@
20 the file called "COPYING". 20 the file called "COPYING".
21 21
22 Contact Information: 22 Contact Information:
23 Linux NICS <linux.nics@intel.com>
23 e1000-devel Mailing List <e1000-devel@lists.sourceforge.net> 24 e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
24 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 25 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
25 26
@@ -63,8 +64,10 @@ static s32 ixgbe_read_i2c_byte_82599(struct ixgbe_hw *hw, u8 byte_offset,
63 u8 dev_addr, u8 *data); 64 u8 dev_addr, u8 *data);
64static s32 ixgbe_write_i2c_byte_82599(struct ixgbe_hw *hw, u8 byte_offset, 65static s32 ixgbe_write_i2c_byte_82599(struct ixgbe_hw *hw, u8 byte_offset,
65 u8 dev_addr, u8 data); 66 u8 dev_addr, u8 data);
67static s32 ixgbe_reset_pipeline_82599(struct ixgbe_hw *hw);
68static bool ixgbe_verify_lesm_fw_enabled_82599(struct ixgbe_hw *hw);
66 69
67static bool ixgbe_mng_enabled(struct ixgbe_hw *hw) 70bool ixgbe_mng_enabled(struct ixgbe_hw *hw)
68{ 71{
69 u32 fwsm, manc, factps; 72 u32 fwsm, manc, factps;
70 73
@@ -91,7 +94,7 @@ static void ixgbe_init_mac_link_ops_82599(struct ixgbe_hw *hw)
91 * and MNG not enabled 94 * and MNG not enabled
92 */ 95 */
93 if ((mac->ops.get_media_type(hw) == ixgbe_media_type_fiber) && 96 if ((mac->ops.get_media_type(hw) == ixgbe_media_type_fiber) &&
94 !hw->mng_fw_enabled) { 97 !ixgbe_mng_enabled(hw)) {
95 mac->ops.disable_tx_laser = 98 mac->ops.disable_tx_laser =
96 &ixgbe_disable_tx_laser_multispeed_fiber; 99 &ixgbe_disable_tx_laser_multispeed_fiber;
97 mac->ops.enable_tx_laser = 100 mac->ops.enable_tx_laser =
@@ -122,7 +125,6 @@ static s32 ixgbe_setup_sfp_modules_82599(struct ixgbe_hw *hw)
122{ 125{
123 s32 ret_val = 0; 126 s32 ret_val = 0;
124 u16 list_offset, data_offset, data_value; 127 u16 list_offset, data_offset, data_value;
125 bool got_lock = false;
126 128
127 if (hw->phy.sfp_type != ixgbe_sfp_type_unknown) { 129 if (hw->phy.sfp_type != ixgbe_sfp_type_unknown) {
128 ixgbe_init_mac_link_ops_82599(hw); 130 ixgbe_init_mac_link_ops_82599(hw);
@@ -160,30 +162,10 @@ static s32 ixgbe_setup_sfp_modules_82599(struct ixgbe_hw *hw)
160 usleep_range(hw->eeprom.semaphore_delay * 1000, 162 usleep_range(hw->eeprom.semaphore_delay * 1000,
161 hw->eeprom.semaphore_delay * 2000); 163 hw->eeprom.semaphore_delay * 2000);
162 164
163 /* Need SW/FW semaphore around AUTOC writes if LESM on,
164 * likewise reset_pipeline requires lock as it also writes
165 * AUTOC.
166 */
167 if (ixgbe_verify_lesm_fw_enabled_82599(hw)) {
168 ret_val = hw->mac.ops.acquire_swfw_sync(hw,
169 IXGBE_GSSR_MAC_CSR_SM);
170 if (ret_val)
171 goto setup_sfp_out;
172
173 got_lock = true;
174 }
175
176 /* Restart DSP and set SFI mode */ 165 /* Restart DSP and set SFI mode */
177 IXGBE_WRITE_REG(hw, IXGBE_AUTOC, ((hw->mac.orig_autoc) | 166 ret_val = hw->mac.ops.prot_autoc_write(hw,
178 IXGBE_AUTOC_LMS_10G_SERIAL)); 167 hw->mac.orig_autoc | IXGBE_AUTOC_LMS_10G_SERIAL,
179 hw->mac.cached_autoc = IXGBE_READ_REG(hw, IXGBE_AUTOC); 168 false);
180 ret_val = ixgbe_reset_pipeline_82599(hw);
181
182 if (got_lock) {
183 hw->mac.ops.release_swfw_sync(hw,
184 IXGBE_GSSR_MAC_CSR_SM);
185 got_lock = false;
186 }
187 169
188 if (ret_val) { 170 if (ret_val) {
189 hw_dbg(hw, " sfp module setup not complete\n"); 171 hw_dbg(hw, " sfp module setup not complete\n");
@@ -207,6 +189,81 @@ setup_sfp_err:
207 return IXGBE_ERR_SFP_SETUP_NOT_COMPLETE; 189 return IXGBE_ERR_SFP_SETUP_NOT_COMPLETE;
208} 190}
209 191
192/**
193 * prot_autoc_read_82599 - Hides MAC differences needed for AUTOC read
194 * @hw: pointer to hardware structure
195 * @locked: Return the if we locked for this read.
196 * @reg_val: Value we read from AUTOC
197 *
198 * For this part (82599) we need to wrap read-modify-writes with a possible
199 * FW/SW lock. It is assumed this lock will be freed with the next
200 * prot_autoc_write_82599(). Note, that locked can only be true in cases
201 * where this function doesn't return an error.
202 **/
203static s32 prot_autoc_read_82599(struct ixgbe_hw *hw, bool *locked,
204 u32 *reg_val)
205{
206 s32 ret_val;
207
208 *locked = false;
209 /* If LESM is on then we need to hold the SW/FW semaphore. */
210 if (ixgbe_verify_lesm_fw_enabled_82599(hw)) {
211 ret_val = hw->mac.ops.acquire_swfw_sync(hw,
212 IXGBE_GSSR_MAC_CSR_SM);
213 if (ret_val)
214 return IXGBE_ERR_SWFW_SYNC;
215
216 *locked = true;
217 }
218
219 *reg_val = IXGBE_READ_REG(hw, IXGBE_AUTOC);
220 return 0;
221}
222
223/**
224 * prot_autoc_write_82599 - Hides MAC differences needed for AUTOC write
225 * @hw: pointer to hardware structure
226 * @reg_val: value to write to AUTOC
227 * @locked: bool to indicate whether the SW/FW lock was already taken by
228 * previous proc_autoc_read_82599.
229 *
230 * This part (82599) may need to hold a the SW/FW lock around all writes to
231 * AUTOC. Likewise after a write we need to do a pipeline reset.
232 **/
233static s32 prot_autoc_write_82599(struct ixgbe_hw *hw, u32 autoc, bool locked)
234{
235 s32 ret_val = 0;
236
237 /* Blocked by MNG FW so bail */
238 if (ixgbe_check_reset_blocked(hw))
239 goto out;
240
241 /* We only need to get the lock if:
242 * - We didn't do it already (in the read part of a read-modify-write)
243 * - LESM is enabled.
244 */
245 if (!locked && ixgbe_verify_lesm_fw_enabled_82599(hw)) {
246 ret_val = hw->mac.ops.acquire_swfw_sync(hw,
247 IXGBE_GSSR_MAC_CSR_SM);
248 if (ret_val)
249 return IXGBE_ERR_SWFW_SYNC;
250
251 locked = true;
252 }
253
254 IXGBE_WRITE_REG(hw, IXGBE_AUTOC, autoc);
255 ret_val = ixgbe_reset_pipeline_82599(hw);
256
257out:
258 /* Free the SW/FW semaphore as we either grabbed it here or
259 * already had it when this function was called.
260 */
261 if (locked)
262 hw->mac.ops.release_swfw_sync(hw, IXGBE_GSSR_MAC_CSR_SM);
263
264 return ret_val;
265}
266
210static s32 ixgbe_get_invariants_82599(struct ixgbe_hw *hw) 267static s32 ixgbe_get_invariants_82599(struct ixgbe_hw *hw)
211{ 268{
212 struct ixgbe_mac_info *mac = &hw->mac; 269 struct ixgbe_mac_info *mac = &hw->mac;
@@ -216,6 +273,7 @@ static s32 ixgbe_get_invariants_82599(struct ixgbe_hw *hw)
216 mac->mcft_size = IXGBE_82599_MC_TBL_SIZE; 273 mac->mcft_size = IXGBE_82599_MC_TBL_SIZE;
217 mac->vft_size = IXGBE_82599_VFT_TBL_SIZE; 274 mac->vft_size = IXGBE_82599_VFT_TBL_SIZE;
218 mac->num_rar_entries = IXGBE_82599_RAR_ENTRIES; 275 mac->num_rar_entries = IXGBE_82599_RAR_ENTRIES;
276 mac->rx_pb_size = IXGBE_82599_RX_PB_SIZE;
219 mac->max_rx_queues = IXGBE_82599_MAX_RX_QUEUES; 277 mac->max_rx_queues = IXGBE_82599_MAX_RX_QUEUES;
220 mac->max_tx_queues = IXGBE_82599_MAX_TX_QUEUES; 278 mac->max_tx_queues = IXGBE_82599_MAX_TX_QUEUES;
221 mac->max_msix_vectors = ixgbe_get_pcie_msix_count_generic(hw); 279 mac->max_msix_vectors = ixgbe_get_pcie_msix_count_generic(hw);
@@ -456,12 +514,20 @@ out:
456 * 514 *
457 * Disables link, should be called during D3 power down sequence. 515 * Disables link, should be called during D3 power down sequence.
458 * 516 *
459 */ 517 **/
460static void ixgbe_stop_mac_link_on_d3_82599(struct ixgbe_hw *hw) 518static void ixgbe_stop_mac_link_on_d3_82599(struct ixgbe_hw *hw)
461{ 519{
462 u32 autoc2_reg; 520 u32 autoc2_reg, fwsm;
521 u16 ee_ctrl_2 = 0;
522
523 hw->eeprom.ops.read(hw, IXGBE_EEPROM_CTRL_2, &ee_ctrl_2);
463 524
464 if (!hw->mng_fw_enabled && !hw->wol_enabled) { 525 /* Check to see if MNG FW could be enabled */
526 fwsm = IXGBE_READ_REG(hw, IXGBE_FWSM);
527
528 if (((fwsm & IXGBE_FWSM_MODE_MASK) != IXGBE_FWSM_FW_MODE_PT) &&
529 !hw->wol_enabled &&
530 ee_ctrl_2 & IXGBE_EEPROM_CCD_BIT) {
465 autoc2_reg = IXGBE_READ_REG(hw, IXGBE_AUTOC2); 531 autoc2_reg = IXGBE_READ_REG(hw, IXGBE_AUTOC2);
466 autoc2_reg |= IXGBE_AUTOC2_LINK_DISABLE_ON_D3_MASK; 532 autoc2_reg |= IXGBE_AUTOC2_LINK_DISABLE_ON_D3_MASK;
467 IXGBE_WRITE_REG(hw, IXGBE_AUTOC2, autoc2_reg); 533 IXGBE_WRITE_REG(hw, IXGBE_AUTOC2, autoc2_reg);
@@ -542,6 +608,10 @@ static void ixgbe_disable_tx_laser_multispeed_fiber(struct ixgbe_hw *hw)
542{ 608{
543 u32 esdp_reg = IXGBE_READ_REG(hw, IXGBE_ESDP); 609 u32 esdp_reg = IXGBE_READ_REG(hw, IXGBE_ESDP);
544 610
611 /* Blocked by MNG FW so bail */
612 if (ixgbe_check_reset_blocked(hw))
613 return;
614
545 /* Disable tx laser; allow 100us to go dark per spec */ 615 /* Disable tx laser; allow 100us to go dark per spec */
546 esdp_reg |= IXGBE_ESDP_SDP3; 616 esdp_reg |= IXGBE_ESDP_SDP3;
547 IXGBE_WRITE_REG(hw, IXGBE_ESDP, esdp_reg); 617 IXGBE_WRITE_REG(hw, IXGBE_ESDP, esdp_reg);
@@ -582,6 +652,10 @@ static void ixgbe_enable_tx_laser_multispeed_fiber(struct ixgbe_hw *hw)
582 **/ 652 **/
583static void ixgbe_flap_tx_laser_multispeed_fiber(struct ixgbe_hw *hw) 653static void ixgbe_flap_tx_laser_multispeed_fiber(struct ixgbe_hw *hw)
584{ 654{
655 /* Blocked by MNG FW so bail */
656 if (ixgbe_check_reset_blocked(hw))
657 return;
658
585 if (hw->mac.autotry_restart) { 659 if (hw->mac.autotry_restart) {
586 ixgbe_disable_tx_laser_multispeed_fiber(hw); 660 ixgbe_disable_tx_laser_multispeed_fiber(hw);
587 ixgbe_enable_tx_laser_multispeed_fiber(hw); 661 ixgbe_enable_tx_laser_multispeed_fiber(hw);
@@ -590,75 +664,6 @@ static void ixgbe_flap_tx_laser_multispeed_fiber(struct ixgbe_hw *hw)
590} 664}
591 665
592/** 666/**
593 * ixgbe_set_fiber_fixed_speed - Set module link speed for fixed fiber
594 * @hw: pointer to hardware structure
595 * @speed: link speed to set
596 *
597 * We set the module speed differently for fixed fiber. For other
598 * multi-speed devices we don't have an error value so here if we
599 * detect an error we just log it and exit.
600 */
601static void ixgbe_set_fiber_fixed_speed(struct ixgbe_hw *hw,
602 ixgbe_link_speed speed)
603{
604 s32 status;
605 u8 rs, eeprom_data;
606
607 switch (speed) {
608 case IXGBE_LINK_SPEED_10GB_FULL:
609 /* one bit mask same as setting on */
610 rs = IXGBE_SFF_SOFT_RS_SELECT_10G;
611 break;
612 case IXGBE_LINK_SPEED_1GB_FULL:
613 rs = IXGBE_SFF_SOFT_RS_SELECT_1G;
614 break;
615 default:
616 hw_dbg(hw, "Invalid fixed module speed\n");
617 return;
618 }
619
620 /* Set RS0 */
621 status = hw->phy.ops.read_i2c_byte(hw, IXGBE_SFF_SFF_8472_OSCB,
622 IXGBE_I2C_EEPROM_DEV_ADDR2,
623 &eeprom_data);
624 if (status) {
625 hw_dbg(hw, "Failed to read Rx Rate Select RS0\n");
626 goto out;
627 }
628
629 eeprom_data = (eeprom_data & ~IXGBE_SFF_SOFT_RS_SELECT_MASK) | rs;
630
631 status = hw->phy.ops.write_i2c_byte(hw, IXGBE_SFF_SFF_8472_OSCB,
632 IXGBE_I2C_EEPROM_DEV_ADDR2,
633 eeprom_data);
634 if (status) {
635 hw_dbg(hw, "Failed to write Rx Rate Select RS0\n");
636 goto out;
637 }
638
639 /* Set RS1 */
640 status = hw->phy.ops.read_i2c_byte(hw, IXGBE_SFF_SFF_8472_ESCB,
641 IXGBE_I2C_EEPROM_DEV_ADDR2,
642 &eeprom_data);
643 if (status) {
644 hw_dbg(hw, "Failed to read Rx Rate Select RS1\n");
645 goto out;
646 }
647
648 eeprom_data = (eeprom_data & ~IXGBE_SFF_SOFT_RS_SELECT_MASK) & rs;
649
650 status = hw->phy.ops.write_i2c_byte(hw, IXGBE_SFF_SFF_8472_ESCB,
651 IXGBE_I2C_EEPROM_DEV_ADDR2,
652 eeprom_data);
653 if (status) {
654 hw_dbg(hw, "Failed to write Rx Rate Select RS1\n");
655 goto out;
656 }
657out:
658 return;
659}
660
661/**
662 * ixgbe_setup_mac_link_multispeed_fiber - Set MAC link speed 667 * ixgbe_setup_mac_link_multispeed_fiber - Set MAC link speed
663 * @hw: pointer to hardware structure 668 * @hw: pointer to hardware structure
664 * @speed: new link speed 669 * @speed: new link speed
@@ -768,10 +773,6 @@ static s32 ixgbe_setup_mac_link_multispeed_fiber(struct ixgbe_hw *hw,
768 773
769 /* Set the module link speed */ 774 /* Set the module link speed */
770 switch (hw->phy.media_type) { 775 switch (hw->phy.media_type) {
771 case ixgbe_media_type_fiber_fixed:
772 ixgbe_set_fiber_fixed_speed(hw,
773 IXGBE_LINK_SPEED_1GB_FULL);
774 break;
775 case ixgbe_media_type_fiber: 776 case ixgbe_media_type_fiber:
776 esdp_reg &= ~IXGBE_ESDP_SDP5; 777 esdp_reg &= ~IXGBE_ESDP_SDP5;
777 esdp_reg |= IXGBE_ESDP_SDP5_DIR; 778 esdp_reg |= IXGBE_ESDP_SDP5_DIR;
@@ -941,8 +942,7 @@ static s32 ixgbe_setup_mac_link_smartspeed(struct ixgbe_hw *hw,
941 942
942out: 943out:
943 if (link_up && (link_speed == IXGBE_LINK_SPEED_1GB_FULL)) 944 if (link_up && (link_speed == IXGBE_LINK_SPEED_1GB_FULL))
944 hw_dbg(hw, "Smartspeed has downgraded the link speed from " 945 hw_dbg(hw, "Smartspeed has downgraded the link speed from the maximum advertised\n");
945 "the maximum advertised\n");
946 return status; 946 return status;
947} 947}
948 948
@@ -958,16 +958,19 @@ static s32 ixgbe_setup_mac_link_82599(struct ixgbe_hw *hw,
958 ixgbe_link_speed speed, 958 ixgbe_link_speed speed,
959 bool autoneg_wait_to_complete) 959 bool autoneg_wait_to_complete)
960{ 960{
961 bool autoneg = false;
961 s32 status = 0; 962 s32 status = 0;
962 u32 autoc, pma_pmd_1g, link_mode, start_autoc; 963 u32 pma_pmd_1g, link_mode, links_reg, i;
963 u32 autoc2 = IXGBE_READ_REG(hw, IXGBE_AUTOC2); 964 u32 autoc2 = IXGBE_READ_REG(hw, IXGBE_AUTOC2);
964 u32 orig_autoc = 0;
965 u32 pma_pmd_10g_serial = autoc2 & IXGBE_AUTOC2_10G_SERIAL_PMA_PMD_MASK; 965 u32 pma_pmd_10g_serial = autoc2 & IXGBE_AUTOC2_10G_SERIAL_PMA_PMD_MASK;
966 u32 links_reg;
967 u32 i;
968 ixgbe_link_speed link_capabilities = IXGBE_LINK_SPEED_UNKNOWN; 966 ixgbe_link_speed link_capabilities = IXGBE_LINK_SPEED_UNKNOWN;
969 bool got_lock = false; 967
970 bool autoneg = false; 968 /* holds the value of AUTOC register at this current point in time */
969 u32 current_autoc = IXGBE_READ_REG(hw, IXGBE_AUTOC);
970 /* holds the cached value of AUTOC register */
971 u32 orig_autoc = 0;
972 /* temporary variable used for comparison purposes */
973 u32 autoc = current_autoc;
971 974
972 /* Check to see if speed passed in is supported. */ 975 /* Check to see if speed passed in is supported. */
973 status = hw->mac.ops.get_link_capabilities(hw, &link_capabilities, 976 status = hw->mac.ops.get_link_capabilities(hw, &link_capabilities,
@@ -984,12 +987,10 @@ static s32 ixgbe_setup_mac_link_82599(struct ixgbe_hw *hw,
984 987
985 /* Use stored value (EEPROM defaults) of AUTOC to find KR/KX4 support*/ 988 /* Use stored value (EEPROM defaults) of AUTOC to find KR/KX4 support*/
986 if (hw->mac.orig_link_settings_stored) 989 if (hw->mac.orig_link_settings_stored)
987 autoc = hw->mac.orig_autoc; 990 orig_autoc = hw->mac.orig_autoc;
988 else 991 else
989 autoc = IXGBE_READ_REG(hw, IXGBE_AUTOC); 992 orig_autoc = autoc;
990 993
991 orig_autoc = autoc;
992 start_autoc = hw->mac.cached_autoc;
993 link_mode = autoc & IXGBE_AUTOC_LMS_MASK; 994 link_mode = autoc & IXGBE_AUTOC_LMS_MASK;
994 pma_pmd_1g = autoc & IXGBE_AUTOC_1G_PMA_PMD_MASK; 995 pma_pmd_1g = autoc & IXGBE_AUTOC_1G_PMA_PMD_MASK;
995 996
@@ -1029,28 +1030,11 @@ static s32 ixgbe_setup_mac_link_82599(struct ixgbe_hw *hw,
1029 } 1030 }
1030 } 1031 }
1031 1032
1032 if (autoc != start_autoc) { 1033 if (autoc != current_autoc) {
1033 /* Need SW/FW semaphore around AUTOC writes if LESM is on,
1034 * likewise reset_pipeline requires us to hold this lock as
1035 * it also writes to AUTOC.
1036 */
1037 if (ixgbe_verify_lesm_fw_enabled_82599(hw)) {
1038 status = hw->mac.ops.acquire_swfw_sync(hw,
1039 IXGBE_GSSR_MAC_CSR_SM);
1040 if (status != 0)
1041 goto out;
1042
1043 got_lock = true;
1044 }
1045
1046 /* Restart link */ 1034 /* Restart link */
1047 IXGBE_WRITE_REG(hw, IXGBE_AUTOC, autoc); 1035 status = hw->mac.ops.prot_autoc_write(hw, autoc, false);
1048 hw->mac.cached_autoc = autoc; 1036 if (status)
1049 ixgbe_reset_pipeline_82599(hw); 1037 goto out;
1050
1051 if (got_lock)
1052 hw->mac.ops.release_swfw_sync(hw,
1053 IXGBE_GSSR_MAC_CSR_SM);
1054 1038
1055 /* Only poll for autoneg to complete if specified to do so */ 1039 /* Only poll for autoneg to complete if specified to do so */
1056 if (autoneg_wait_to_complete) { 1040 if (autoneg_wait_to_complete) {
@@ -1068,8 +1052,7 @@ static s32 ixgbe_setup_mac_link_82599(struct ixgbe_hw *hw,
1068 if (!(links_reg & IXGBE_LINKS_KX_AN_COMP)) { 1052 if (!(links_reg & IXGBE_LINKS_KX_AN_COMP)) {
1069 status = 1053 status =
1070 IXGBE_ERR_AUTONEG_NOT_COMPLETE; 1054 IXGBE_ERR_AUTONEG_NOT_COMPLETE;
1071 hw_dbg(hw, "Autoneg did not " 1055 hw_dbg(hw, "Autoneg did not complete.\n");
1072 "complete.\n");
1073 } 1056 }
1074 } 1057 }
1075 } 1058 }
@@ -1117,7 +1100,7 @@ static s32 ixgbe_reset_hw_82599(struct ixgbe_hw *hw)
1117{ 1100{
1118 ixgbe_link_speed link_speed; 1101 ixgbe_link_speed link_speed;
1119 s32 status; 1102 s32 status;
1120 u32 ctrl, i, autoc2; 1103 u32 ctrl, i, autoc, autoc2;
1121 u32 curr_lms; 1104 u32 curr_lms;
1122 bool link_up = false; 1105 bool link_up = false;
1123 1106
@@ -1151,11 +1134,7 @@ static s32 ixgbe_reset_hw_82599(struct ixgbe_hw *hw)
1151 hw->phy.ops.reset(hw); 1134 hw->phy.ops.reset(hw);
1152 1135
1153 /* remember AUTOC from before we reset */ 1136 /* remember AUTOC from before we reset */
1154 if (hw->mac.cached_autoc) 1137 curr_lms = IXGBE_READ_REG(hw, IXGBE_AUTOC) & IXGBE_AUTOC_LMS_MASK;
1155 curr_lms = hw->mac.cached_autoc & IXGBE_AUTOC_LMS_MASK;
1156 else
1157 curr_lms = IXGBE_READ_REG(hw, IXGBE_AUTOC) &
1158 IXGBE_AUTOC_LMS_MASK;
1159 1138
1160mac_reset_top: 1139mac_reset_top:
1161 /* 1140 /*
@@ -1205,7 +1184,7 @@ mac_reset_top:
1205 * stored off yet. Otherwise restore the stored original 1184 * stored off yet. Otherwise restore the stored original
1206 * values since the reset operation sets back to defaults. 1185 * values since the reset operation sets back to defaults.
1207 */ 1186 */
1208 hw->mac.cached_autoc = IXGBE_READ_REG(hw, IXGBE_AUTOC); 1187 autoc = IXGBE_READ_REG(hw, IXGBE_AUTOC);
1209 autoc2 = IXGBE_READ_REG(hw, IXGBE_AUTOC2); 1188 autoc2 = IXGBE_READ_REG(hw, IXGBE_AUTOC2);
1210 1189
1211 /* Enable link if disabled in NVM */ 1190 /* Enable link if disabled in NVM */
@@ -1216,7 +1195,7 @@ mac_reset_top:
1216 } 1195 }
1217 1196
1218 if (hw->mac.orig_link_settings_stored == false) { 1197 if (hw->mac.orig_link_settings_stored == false) {
1219 hw->mac.orig_autoc = hw->mac.cached_autoc; 1198 hw->mac.orig_autoc = autoc;
1220 hw->mac.orig_autoc2 = autoc2; 1199 hw->mac.orig_autoc2 = autoc2;
1221 hw->mac.orig_link_settings_stored = true; 1200 hw->mac.orig_link_settings_stored = true;
1222 } else { 1201 } else {
@@ -1227,34 +1206,18 @@ mac_reset_top:
1227 * Likewise if we support WoL we don't want change the 1206 * Likewise if we support WoL we don't want change the
1228 * LMS state either. 1207 * LMS state either.
1229 */ 1208 */
1230 if ((hw->phy.multispeed_fiber && hw->mng_fw_enabled) || 1209 if ((hw->phy.multispeed_fiber && ixgbe_mng_enabled(hw)) ||
1231 hw->wol_enabled) 1210 hw->wol_enabled)
1232 hw->mac.orig_autoc = 1211 hw->mac.orig_autoc =
1233 (hw->mac.orig_autoc & ~IXGBE_AUTOC_LMS_MASK) | 1212 (hw->mac.orig_autoc & ~IXGBE_AUTOC_LMS_MASK) |
1234 curr_lms; 1213 curr_lms;
1235 1214
1236 if (hw->mac.cached_autoc != hw->mac.orig_autoc) { 1215 if (autoc != hw->mac.orig_autoc) {
1237 /* Need SW/FW semaphore around AUTOC writes if LESM is 1216 status = hw->mac.ops.prot_autoc_write(hw,
1238 * on, likewise reset_pipeline requires us to hold 1217 hw->mac.orig_autoc,
1239 * this lock as it also writes to AUTOC. 1218 false);
1240 */ 1219 if (status)
1241 bool got_lock = false; 1220 goto reset_hw_out;
1242 if (ixgbe_verify_lesm_fw_enabled_82599(hw)) {
1243 status = hw->mac.ops.acquire_swfw_sync(hw,
1244 IXGBE_GSSR_MAC_CSR_SM);
1245 if (status)
1246 goto reset_hw_out;
1247
1248 got_lock = true;
1249 }
1250
1251 IXGBE_WRITE_REG(hw, IXGBE_AUTOC, hw->mac.orig_autoc);
1252 hw->mac.cached_autoc = hw->mac.orig_autoc;
1253 ixgbe_reset_pipeline_82599(hw);
1254
1255 if (got_lock)
1256 hw->mac.ops.release_swfw_sync(hw,
1257 IXGBE_GSSR_MAC_CSR_SM);
1258 } 1221 }
1259 1222
1260 if ((autoc2 & IXGBE_AUTOC2_UPPER_MASK) != 1223 if ((autoc2 & IXGBE_AUTOC2_UPPER_MASK) !=
@@ -1634,35 +1597,20 @@ void ixgbe_atr_compute_perfect_hash_82599(union ixgbe_atr_input *input,
1634{ 1597{
1635 1598
1636 u32 hi_hash_dword, lo_hash_dword, flow_vm_vlan; 1599 u32 hi_hash_dword, lo_hash_dword, flow_vm_vlan;
1637 u32 bucket_hash = 0; 1600 u32 bucket_hash = 0, hi_dword = 0;
1601 int i;
1638 1602
1639 /* Apply masks to input data */ 1603 /* Apply masks to input data */
1640 input->dword_stream[0] &= input_mask->dword_stream[0]; 1604 for (i = 0; i <= 10; i++)
1641 input->dword_stream[1] &= input_mask->dword_stream[1]; 1605 input->dword_stream[i] &= input_mask->dword_stream[i];
1642 input->dword_stream[2] &= input_mask->dword_stream[2];
1643 input->dword_stream[3] &= input_mask->dword_stream[3];
1644 input->dword_stream[4] &= input_mask->dword_stream[4];
1645 input->dword_stream[5] &= input_mask->dword_stream[5];
1646 input->dword_stream[6] &= input_mask->dword_stream[6];
1647 input->dword_stream[7] &= input_mask->dword_stream[7];
1648 input->dword_stream[8] &= input_mask->dword_stream[8];
1649 input->dword_stream[9] &= input_mask->dword_stream[9];
1650 input->dword_stream[10] &= input_mask->dword_stream[10];
1651 1606
1652 /* record the flow_vm_vlan bits as they are a key part to the hash */ 1607 /* record the flow_vm_vlan bits as they are a key part to the hash */
1653 flow_vm_vlan = ntohl(input->dword_stream[0]); 1608 flow_vm_vlan = ntohl(input->dword_stream[0]);
1654 1609
1655 /* generate common hash dword */ 1610 /* generate common hash dword */
1656 hi_hash_dword = ntohl(input->dword_stream[1] ^ 1611 for (i = 1; i <= 10; i++)
1657 input->dword_stream[2] ^ 1612 hi_dword ^= input->dword_stream[i];
1658 input->dword_stream[3] ^ 1613 hi_hash_dword = ntohl(hi_dword);
1659 input->dword_stream[4] ^
1660 input->dword_stream[5] ^
1661 input->dword_stream[6] ^
1662 input->dword_stream[7] ^
1663 input->dword_stream[8] ^
1664 input->dword_stream[9] ^
1665 input->dword_stream[10]);
1666 1614
1667 /* low dword is word swapped version of common */ 1615 /* low dword is word swapped version of common */
1668 lo_hash_dword = (hi_hash_dword >> 16) | (hi_hash_dword << 16); 1616 lo_hash_dword = (hi_hash_dword >> 16) | (hi_hash_dword << 16);
@@ -1681,21 +1629,8 @@ void ixgbe_atr_compute_perfect_hash_82599(union ixgbe_atr_input *input,
1681 lo_hash_dword ^= flow_vm_vlan ^ (flow_vm_vlan << 16); 1629 lo_hash_dword ^= flow_vm_vlan ^ (flow_vm_vlan << 16);
1682 1630
1683 /* Process remaining 30 bit of the key */ 1631 /* Process remaining 30 bit of the key */
1684 IXGBE_COMPUTE_BKT_HASH_ITERATION(1); 1632 for (i = 1; i <= 15; i++)
1685 IXGBE_COMPUTE_BKT_HASH_ITERATION(2); 1633 IXGBE_COMPUTE_BKT_HASH_ITERATION(i);
1686 IXGBE_COMPUTE_BKT_HASH_ITERATION(3);
1687 IXGBE_COMPUTE_BKT_HASH_ITERATION(4);
1688 IXGBE_COMPUTE_BKT_HASH_ITERATION(5);
1689 IXGBE_COMPUTE_BKT_HASH_ITERATION(6);
1690 IXGBE_COMPUTE_BKT_HASH_ITERATION(7);
1691 IXGBE_COMPUTE_BKT_HASH_ITERATION(8);
1692 IXGBE_COMPUTE_BKT_HASH_ITERATION(9);
1693 IXGBE_COMPUTE_BKT_HASH_ITERATION(10);
1694 IXGBE_COMPUTE_BKT_HASH_ITERATION(11);
1695 IXGBE_COMPUTE_BKT_HASH_ITERATION(12);
1696 IXGBE_COMPUTE_BKT_HASH_ITERATION(13);
1697 IXGBE_COMPUTE_BKT_HASH_ITERATION(14);
1698 IXGBE_COMPUTE_BKT_HASH_ITERATION(15);
1699 1634
1700 /* 1635 /*
1701 * Limit hash to 13 bits since max bucket count is 8K. 1636 * Limit hash to 13 bits since max bucket count is 8K.
@@ -2001,7 +1936,6 @@ static s32 ixgbe_start_hw_82599(struct ixgbe_hw *hw)
2001 1936
2002 /* We need to run link autotry after the driver loads */ 1937 /* We need to run link autotry after the driver loads */
2003 hw->mac.autotry_restart = true; 1938 hw->mac.autotry_restart = true;
2004 hw->mac.rx_pb_size = IXGBE_82599_RX_PB_SIZE;
2005 1939
2006 if (ret_val == 0) 1940 if (ret_val == 0)
2007 ret_val = ixgbe_verify_fw_version_82599(hw); 1941 ret_val = ixgbe_verify_fw_version_82599(hw);
@@ -2260,7 +2194,7 @@ fw_version_err:
2260 * Returns true if the LESM FW module is present and enabled. Otherwise 2194 * Returns true if the LESM FW module is present and enabled. Otherwise
2261 * returns false. Smart Speed must be disabled if LESM FW module is enabled. 2195 * returns false. Smart Speed must be disabled if LESM FW module is enabled.
2262 **/ 2196 **/
2263bool ixgbe_verify_lesm_fw_enabled_82599(struct ixgbe_hw *hw) 2197static bool ixgbe_verify_lesm_fw_enabled_82599(struct ixgbe_hw *hw)
2264{ 2198{
2265 bool lesm_enabled = false; 2199 bool lesm_enabled = false;
2266 u16 fw_offset, fw_lesm_param_offset, fw_lesm_state; 2200 u16 fw_offset, fw_lesm_param_offset, fw_lesm_state;
@@ -2366,7 +2300,7 @@ static s32 ixgbe_read_eeprom_82599(struct ixgbe_hw *hw,
2366 * full pipeline reset. Note - We must hold the SW/FW semaphore before writing 2300 * full pipeline reset. Note - We must hold the SW/FW semaphore before writing
2367 * to AUTOC, so this function assumes the semaphore is held. 2301 * to AUTOC, so this function assumes the semaphore is held.
2368 **/ 2302 **/
2369s32 ixgbe_reset_pipeline_82599(struct ixgbe_hw *hw) 2303static s32 ixgbe_reset_pipeline_82599(struct ixgbe_hw *hw)
2370{ 2304{
2371 s32 ret_val; 2305 s32 ret_val;
2372 u32 anlp1_reg = 0; 2306 u32 anlp1_reg = 0;
@@ -2380,11 +2314,12 @@ s32 ixgbe_reset_pipeline_82599(struct ixgbe_hw *hw)
2380 IXGBE_WRITE_FLUSH(hw); 2314 IXGBE_WRITE_FLUSH(hw);
2381 } 2315 }
2382 2316
2383 autoc_reg = hw->mac.cached_autoc; 2317 autoc_reg = IXGBE_READ_REG(hw, IXGBE_AUTOC);
2384 autoc_reg |= IXGBE_AUTOC_AN_RESTART; 2318 autoc_reg |= IXGBE_AUTOC_AN_RESTART;
2385 2319
2386 /* Write AUTOC register with toggled LMS[2] bit and Restart_AN */ 2320 /* Write AUTOC register with toggled LMS[2] bit and Restart_AN */
2387 IXGBE_WRITE_REG(hw, IXGBE_AUTOC, autoc_reg ^ IXGBE_AUTOC_LMS_1G_AN); 2321 IXGBE_WRITE_REG(hw, IXGBE_AUTOC,
2322 autoc_reg ^ (0x4 << IXGBE_AUTOC_LMS_SHIFT));
2388 2323
2389 /* Wait for AN to leave state 0 */ 2324 /* Wait for AN to leave state 0 */
2390 for (i = 0; i < 10; i++) { 2325 for (i = 0; i < 10; i++) {
@@ -2565,7 +2500,8 @@ static struct ixgbe_mac_operations mac_ops_82599 = {
2565 .release_swfw_sync = &ixgbe_release_swfw_sync, 2500 .release_swfw_sync = &ixgbe_release_swfw_sync,
2566 .get_thermal_sensor_data = &ixgbe_get_thermal_sensor_data_generic, 2501 .get_thermal_sensor_data = &ixgbe_get_thermal_sensor_data_generic,
2567 .init_thermal_sensor_thresh = &ixgbe_init_thermal_sensor_thresh_generic, 2502 .init_thermal_sensor_thresh = &ixgbe_init_thermal_sensor_thresh_generic,
2568 .mng_fw_enabled = &ixgbe_mng_enabled, 2503 .prot_autoc_read = &prot_autoc_read_82599,
2504 .prot_autoc_write = &prot_autoc_write_82599,
2569}; 2505};
2570 2506
2571static struct ixgbe_eeprom_operations eeprom_ops_82599 = { 2507static struct ixgbe_eeprom_operations eeprom_ops_82599 = {
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_common.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_common.c
index b5c434b617b1..24fba39e194e 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_common.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_common.c
@@ -1,7 +1,7 @@
1/******************************************************************************* 1/*******************************************************************************
2 2
3 Intel 10 Gigabit PCI Express Linux driver 3 Intel 10 Gigabit PCI Express Linux driver
4 Copyright(c) 1999 - 2013 Intel Corporation. 4 Copyright(c) 1999 - 2014 Intel Corporation.
5 5
6 This program is free software; you can redistribute it and/or modify it 6 This program is free software; you can redistribute it and/or modify it
7 under the terms and conditions of the GNU General Public License, 7 under the terms and conditions of the GNU General Public License,
@@ -20,6 +20,7 @@
20 the file called "COPYING". 20 the file called "COPYING".
21 21
22 Contact Information: 22 Contact Information:
23 Linux NICS <linux.nics@intel.com>
23 e1000-devel Mailing List <e1000-devel@lists.sourceforge.net> 24 e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
24 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 25 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
25 26
@@ -72,7 +73,6 @@ bool ixgbe_device_supports_autoneg_fc(struct ixgbe_hw *hw)
72 bool link_up; 73 bool link_up;
73 74
74 switch (hw->phy.media_type) { 75 switch (hw->phy.media_type) {
75 case ixgbe_media_type_fiber_fixed:
76 case ixgbe_media_type_fiber: 76 case ixgbe_media_type_fiber:
77 hw->mac.ops.check_link(hw, &speed, &link_up, false); 77 hw->mac.ops.check_link(hw, &speed, &link_up, false);
78 /* if link is down, assume supported */ 78 /* if link is down, assume supported */
@@ -114,7 +114,7 @@ static s32 ixgbe_setup_fc(struct ixgbe_hw *hw)
114 s32 ret_val = 0; 114 s32 ret_val = 0;
115 u32 reg = 0, reg_bp = 0; 115 u32 reg = 0, reg_bp = 0;
116 u16 reg_cu = 0; 116 u16 reg_cu = 0;
117 bool got_lock = false; 117 bool locked = false;
118 118
119 /* 119 /*
120 * Validate the requested mode. Strict IEEE mode does not allow 120 * Validate the requested mode. Strict IEEE mode does not allow
@@ -139,11 +139,16 @@ static s32 ixgbe_setup_fc(struct ixgbe_hw *hw)
139 * we link at 10G, the 1G advertisement is harmless and vice versa. 139 * we link at 10G, the 1G advertisement is harmless and vice versa.
140 */ 140 */
141 switch (hw->phy.media_type) { 141 switch (hw->phy.media_type) {
142 case ixgbe_media_type_fiber_fixed:
143 case ixgbe_media_type_fiber:
144 case ixgbe_media_type_backplane: 142 case ixgbe_media_type_backplane:
143 /* some MAC's need RMW protection on AUTOC */
144 ret_val = hw->mac.ops.prot_autoc_read(hw, &locked, &reg_bp);
145 if (ret_val)
146 goto out;
147
148 /* only backplane uses autoc so fall though */
149 case ixgbe_media_type_fiber:
145 reg = IXGBE_READ_REG(hw, IXGBE_PCS1GANA); 150 reg = IXGBE_READ_REG(hw, IXGBE_PCS1GANA);
146 reg_bp = IXGBE_READ_REG(hw, IXGBE_AUTOC); 151
147 break; 152 break;
148 case ixgbe_media_type_copper: 153 case ixgbe_media_type_copper:
149 hw->phy.ops.read_reg(hw, MDIO_AN_ADVERTISE, 154 hw->phy.ops.read_reg(hw, MDIO_AN_ADVERTISE,
@@ -240,27 +245,12 @@ static s32 ixgbe_setup_fc(struct ixgbe_hw *hw)
240 * LESM is on, likewise reset_pipeline requries the lock as 245 * LESM is on, likewise reset_pipeline requries the lock as
241 * it also writes AUTOC. 246 * it also writes AUTOC.
242 */ 247 */
243 if ((hw->mac.type == ixgbe_mac_82599EB) && 248 ret_val = hw->mac.ops.prot_autoc_write(hw, reg_bp, locked);
244 ixgbe_verify_lesm_fw_enabled_82599(hw)) { 249 if (ret_val)
245 ret_val = hw->mac.ops.acquire_swfw_sync(hw, 250 goto out;
246 IXGBE_GSSR_MAC_CSR_SM);
247 if (ret_val)
248 goto out;
249
250 got_lock = true;
251 }
252
253 IXGBE_WRITE_REG(hw, IXGBE_AUTOC, reg_bp);
254
255 if (hw->mac.type == ixgbe_mac_82599EB)
256 ixgbe_reset_pipeline_82599(hw);
257
258 if (got_lock)
259 hw->mac.ops.release_swfw_sync(hw,
260 IXGBE_GSSR_MAC_CSR_SM);
261 251
262 } else if ((hw->phy.media_type == ixgbe_media_type_copper) && 252 } else if ((hw->phy.media_type == ixgbe_media_type_copper) &&
263 ixgbe_device_supports_autoneg_fc(hw)) { 253 ixgbe_device_supports_autoneg_fc(hw)) {
264 hw->phy.ops.write_reg(hw, MDIO_AN_ADVERTISE, 254 hw->phy.ops.write_reg(hw, MDIO_AN_ADVERTISE,
265 MDIO_MMD_AN, reg_cu); 255 MDIO_MMD_AN, reg_cu);
266 } 256 }
@@ -656,20 +646,17 @@ enum ixgbe_bus_speed ixgbe_convert_bus_speed(u16 link_status)
656 **/ 646 **/
657s32 ixgbe_get_bus_info_generic(struct ixgbe_hw *hw) 647s32 ixgbe_get_bus_info_generic(struct ixgbe_hw *hw)
658{ 648{
659 struct ixgbe_adapter *adapter = hw->back;
660 struct ixgbe_mac_info *mac = &hw->mac;
661 u16 link_status; 649 u16 link_status;
662 650
663 hw->bus.type = ixgbe_bus_type_pci_express; 651 hw->bus.type = ixgbe_bus_type_pci_express;
664 652
665 /* Get the negotiated link width and speed from PCI config space */ 653 /* Get the negotiated link width and speed from PCI config space */
666 pci_read_config_word(adapter->pdev, IXGBE_PCI_LINK_STATUS, 654 link_status = ixgbe_read_pci_cfg_word(hw, IXGBE_PCI_LINK_STATUS);
667 &link_status);
668 655
669 hw->bus.width = ixgbe_convert_bus_width(link_status); 656 hw->bus.width = ixgbe_convert_bus_width(link_status);
670 hw->bus.speed = ixgbe_convert_bus_speed(link_status); 657 hw->bus.speed = ixgbe_convert_bus_speed(link_status);
671 658
672 mac->ops.set_lan_id(hw); 659 hw->mac.ops.set_lan_id(hw);
673 660
674 return 0; 661 return 0;
675} 662}
@@ -2406,7 +2393,6 @@ void ixgbe_fc_autoneg(struct ixgbe_hw *hw)
2406 2393
2407 switch (hw->phy.media_type) { 2394 switch (hw->phy.media_type) {
2408 /* Autoneg flow control on fiber adapters */ 2395 /* Autoneg flow control on fiber adapters */
2409 case ixgbe_media_type_fiber_fixed:
2410 case ixgbe_media_type_fiber: 2396 case ixgbe_media_type_fiber:
2411 if (speed == IXGBE_LINK_SPEED_1GB_FULL) 2397 if (speed == IXGBE_LINK_SPEED_1GB_FULL)
2412 ret_val = ixgbe_fc_autoneg_fiber(hw); 2398 ret_val = ixgbe_fc_autoneg_fiber(hw);
@@ -2437,6 +2423,53 @@ out:
2437} 2423}
2438 2424
2439/** 2425/**
2426 * ixgbe_pcie_timeout_poll - Return number of times to poll for completion
2427 * @hw: pointer to hardware structure
2428 *
2429 * System-wide timeout range is encoded in PCIe Device Control2 register.
2430 *
2431 * Add 10% to specified maximum and return the number of times to poll for
2432 * completion timeout, in units of 100 microsec. Never return less than
2433 * 800 = 80 millisec.
2434 **/
2435static u32 ixgbe_pcie_timeout_poll(struct ixgbe_hw *hw)
2436{
2437 s16 devctl2;
2438 u32 pollcnt;
2439
2440 devctl2 = ixgbe_read_pci_cfg_word(hw, IXGBE_PCI_DEVICE_CONTROL2);
2441 devctl2 &= IXGBE_PCIDEVCTRL2_TIMEO_MASK;
2442
2443 switch (devctl2) {
2444 case IXGBE_PCIDEVCTRL2_65_130ms:
2445 pollcnt = 1300; /* 130 millisec */
2446 break;
2447 case IXGBE_PCIDEVCTRL2_260_520ms:
2448 pollcnt = 5200; /* 520 millisec */
2449 break;
2450 case IXGBE_PCIDEVCTRL2_1_2s:
2451 pollcnt = 20000; /* 2 sec */
2452 break;
2453 case IXGBE_PCIDEVCTRL2_4_8s:
2454 pollcnt = 80000; /* 8 sec */
2455 break;
2456 case IXGBE_PCIDEVCTRL2_17_34s:
2457 pollcnt = 34000; /* 34 sec */
2458 break;
2459 case IXGBE_PCIDEVCTRL2_50_100us: /* 100 microsecs */
2460 case IXGBE_PCIDEVCTRL2_1_2ms: /* 2 millisecs */
2461 case IXGBE_PCIDEVCTRL2_16_32ms: /* 32 millisec */
2462 case IXGBE_PCIDEVCTRL2_16_32ms_def: /* 32 millisec default */
2463 default:
2464 pollcnt = 800; /* 80 millisec minimum */
2465 break;
2466 }
2467
2468 /* add 10% to spec maximum */
2469 return (pollcnt * 11) / 10;
2470}
2471
2472/**
2440 * ixgbe_disable_pcie_master - Disable PCI-express master access 2473 * ixgbe_disable_pcie_master - Disable PCI-express master access
2441 * @hw: pointer to hardware structure 2474 * @hw: pointer to hardware structure
2442 * 2475 *
@@ -2447,16 +2480,16 @@ out:
2447 **/ 2480 **/
2448static s32 ixgbe_disable_pcie_master(struct ixgbe_hw *hw) 2481static s32 ixgbe_disable_pcie_master(struct ixgbe_hw *hw)
2449{ 2482{
2450 struct ixgbe_adapter *adapter = hw->back;
2451 s32 status = 0; 2483 s32 status = 0;
2452 u32 i; 2484 u32 i, poll;
2453 u16 value; 2485 u16 value;
2454 2486
2455 /* Always set this bit to ensure any future transactions are blocked */ 2487 /* Always set this bit to ensure any future transactions are blocked */
2456 IXGBE_WRITE_REG(hw, IXGBE_CTRL, IXGBE_CTRL_GIO_DIS); 2488 IXGBE_WRITE_REG(hw, IXGBE_CTRL, IXGBE_CTRL_GIO_DIS);
2457 2489
2458 /* Exit if master requests are blocked */ 2490 /* Exit if master requests are blocked */
2459 if (!(IXGBE_READ_REG(hw, IXGBE_STATUS) & IXGBE_STATUS_GIO)) 2491 if (!(IXGBE_READ_REG(hw, IXGBE_STATUS) & IXGBE_STATUS_GIO) ||
2492 ixgbe_removed(hw->hw_addr))
2460 goto out; 2493 goto out;
2461 2494
2462 /* Poll for master request bit to clear */ 2495 /* Poll for master request bit to clear */
@@ -2481,10 +2514,12 @@ static s32 ixgbe_disable_pcie_master(struct ixgbe_hw *hw)
2481 * Before proceeding, make sure that the PCIe block does not have 2514 * Before proceeding, make sure that the PCIe block does not have
2482 * transactions pending. 2515 * transactions pending.
2483 */ 2516 */
2484 for (i = 0; i < IXGBE_PCI_MASTER_DISABLE_TIMEOUT; i++) { 2517 poll = ixgbe_pcie_timeout_poll(hw);
2518 for (i = 0; i < poll; i++) {
2485 udelay(100); 2519 udelay(100);
2486 pci_read_config_word(adapter->pdev, IXGBE_PCI_DEVICE_STATUS, 2520 value = ixgbe_read_pci_cfg_word(hw, IXGBE_PCI_DEVICE_STATUS);
2487 &value); 2521 if (ixgbe_removed(hw->hw_addr))
2522 goto out;
2488 if (!(value & IXGBE_PCI_DEVICE_STATUS_TRANSACTION_PENDING)) 2523 if (!(value & IXGBE_PCI_DEVICE_STATUS_TRANSACTION_PENDING))
2489 goto out; 2524 goto out;
2490 } 2525 }
@@ -2564,6 +2599,35 @@ void ixgbe_release_swfw_sync(struct ixgbe_hw *hw, u16 mask)
2564} 2599}
2565 2600
2566/** 2601/**
2602 * prot_autoc_read_generic - Hides MAC differences needed for AUTOC read
2603 * @hw: pointer to hardware structure
2604 * @reg_val: Value we read from AUTOC
2605 * @locked: bool to indicate whether the SW/FW lock should be taken. Never
2606 * true in this the generic case.
2607 *
2608 * The default case requires no protection so just to the register read.
2609 **/
2610s32 prot_autoc_read_generic(struct ixgbe_hw *hw, bool *locked, u32 *reg_val)
2611{
2612 *locked = false;
2613 *reg_val = IXGBE_READ_REG(hw, IXGBE_AUTOC);
2614 return 0;
2615}
2616
2617/**
2618 * prot_autoc_write_generic - Hides MAC differences needed for AUTOC write
2619 * @hw: pointer to hardware structure
2620 * @reg_val: value to write to AUTOC
2621 * @locked: bool to indicate whether the SW/FW lock was already taken by
2622 * previous read.
2623 **/
2624s32 prot_autoc_write_generic(struct ixgbe_hw *hw, u32 reg_val, bool locked)
2625{
2626 IXGBE_WRITE_REG(hw, IXGBE_AUTOC, reg_val);
2627 return 0;
2628}
2629
2630/**
2567 * ixgbe_disable_rx_buff_generic - Stops the receive data path 2631 * ixgbe_disable_rx_buff_generic - Stops the receive data path
2568 * @hw: pointer to hardware structure 2632 * @hw: pointer to hardware structure
2569 * 2633 *
@@ -2641,6 +2705,7 @@ s32 ixgbe_blink_led_start_generic(struct ixgbe_hw *hw, u32 index)
2641 u32 autoc_reg = IXGBE_READ_REG(hw, IXGBE_AUTOC); 2705 u32 autoc_reg = IXGBE_READ_REG(hw, IXGBE_AUTOC);
2642 u32 led_reg = IXGBE_READ_REG(hw, IXGBE_LEDCTL); 2706 u32 led_reg = IXGBE_READ_REG(hw, IXGBE_LEDCTL);
2643 s32 ret_val = 0; 2707 s32 ret_val = 0;
2708 bool locked = false;
2644 2709
2645 /* 2710 /*
2646 * Link must be up to auto-blink the LEDs; 2711 * Link must be up to auto-blink the LEDs;
@@ -2649,28 +2714,19 @@ s32 ixgbe_blink_led_start_generic(struct ixgbe_hw *hw, u32 index)
2649 hw->mac.ops.check_link(hw, &speed, &link_up, false); 2714 hw->mac.ops.check_link(hw, &speed, &link_up, false);
2650 2715
2651 if (!link_up) { 2716 if (!link_up) {
2652 /* Need the SW/FW semaphore around AUTOC writes if 82599 and 2717 ret_val = hw->mac.ops.prot_autoc_read(hw, &locked, &autoc_reg);
2653 * LESM is on. 2718 if (ret_val)
2654 */ 2719 goto out;
2655 bool got_lock = false;
2656
2657 if ((hw->mac.type == ixgbe_mac_82599EB) &&
2658 ixgbe_verify_lesm_fw_enabled_82599(hw)) {
2659 ret_val = hw->mac.ops.acquire_swfw_sync(hw,
2660 IXGBE_GSSR_MAC_CSR_SM);
2661 if (ret_val)
2662 goto out;
2663 2720
2664 got_lock = true;
2665 }
2666 autoc_reg |= IXGBE_AUTOC_AN_RESTART; 2721 autoc_reg |= IXGBE_AUTOC_AN_RESTART;
2667 autoc_reg |= IXGBE_AUTOC_FLU; 2722 autoc_reg |= IXGBE_AUTOC_FLU;
2668 IXGBE_WRITE_REG(hw, IXGBE_AUTOC, autoc_reg); 2723
2724 ret_val = hw->mac.ops.prot_autoc_write(hw, autoc_reg, locked);
2725 if (ret_val)
2726 goto out;
2727
2669 IXGBE_WRITE_FLUSH(hw); 2728 IXGBE_WRITE_FLUSH(hw);
2670 2729
2671 if (got_lock)
2672 hw->mac.ops.release_swfw_sync(hw,
2673 IXGBE_GSSR_MAC_CSR_SM);
2674 usleep_range(10000, 20000); 2730 usleep_range(10000, 20000);
2675 } 2731 }
2676 2732
@@ -2690,33 +2746,21 @@ out:
2690 **/ 2746 **/
2691s32 ixgbe_blink_led_stop_generic(struct ixgbe_hw *hw, u32 index) 2747s32 ixgbe_blink_led_stop_generic(struct ixgbe_hw *hw, u32 index)
2692{ 2748{
2693 u32 autoc_reg = IXGBE_READ_REG(hw, IXGBE_AUTOC); 2749 u32 autoc_reg = 0;
2694 u32 led_reg = IXGBE_READ_REG(hw, IXGBE_LEDCTL); 2750 u32 led_reg = IXGBE_READ_REG(hw, IXGBE_LEDCTL);
2695 s32 ret_val = 0; 2751 s32 ret_val = 0;
2696 bool got_lock = false; 2752 bool locked = false;
2697 2753
2698 /* Need the SW/FW semaphore around AUTOC writes if 82599 and 2754 ret_val = hw->mac.ops.prot_autoc_read(hw, &locked, &autoc_reg);
2699 * LESM is on. 2755 if (ret_val)
2700 */ 2756 goto out;
2701 if ((hw->mac.type == ixgbe_mac_82599EB) &&
2702 ixgbe_verify_lesm_fw_enabled_82599(hw)) {
2703 ret_val = hw->mac.ops.acquire_swfw_sync(hw,
2704 IXGBE_GSSR_MAC_CSR_SM);
2705 if (ret_val)
2706 goto out;
2707
2708 got_lock = true;
2709 }
2710 2757
2711 autoc_reg &= ~IXGBE_AUTOC_FLU; 2758 autoc_reg &= ~IXGBE_AUTOC_FLU;
2712 autoc_reg |= IXGBE_AUTOC_AN_RESTART; 2759 autoc_reg |= IXGBE_AUTOC_AN_RESTART;
2713 IXGBE_WRITE_REG(hw, IXGBE_AUTOC, autoc_reg);
2714
2715 if (hw->mac.type == ixgbe_mac_82599EB)
2716 ixgbe_reset_pipeline_82599(hw);
2717 2760
2718 if (got_lock) 2761 ret_val = hw->mac.ops.prot_autoc_write(hw, autoc_reg, locked);
2719 hw->mac.ops.release_swfw_sync(hw, IXGBE_GSSR_MAC_CSR_SM); 2762 if (ret_val)
2763 goto out;
2720 2764
2721 led_reg &= ~IXGBE_LED_MODE_MASK(index); 2765 led_reg &= ~IXGBE_LED_MODE_MASK(index);
2722 led_reg &= ~IXGBE_LED_BLINK(index); 2766 led_reg &= ~IXGBE_LED_BLINK(index);
@@ -2817,7 +2861,6 @@ san_mac_addr_clr:
2817 **/ 2861 **/
2818u16 ixgbe_get_pcie_msix_count_generic(struct ixgbe_hw *hw) 2862u16 ixgbe_get_pcie_msix_count_generic(struct ixgbe_hw *hw)
2819{ 2863{
2820 struct ixgbe_adapter *adapter = hw->back;
2821 u16 msix_count = 1; 2864 u16 msix_count = 1;
2822 u16 max_msix_count; 2865 u16 max_msix_count;
2823 u16 pcie_offset; 2866 u16 pcie_offset;
@@ -2836,7 +2879,9 @@ u16 ixgbe_get_pcie_msix_count_generic(struct ixgbe_hw *hw)
2836 return msix_count; 2879 return msix_count;
2837 } 2880 }
2838 2881
2839 pci_read_config_word(adapter->pdev, pcie_offset, &msix_count); 2882 msix_count = ixgbe_read_pci_cfg_word(hw, pcie_offset);
2883 if (ixgbe_removed(hw->hw_addr))
2884 msix_count = 0;
2840 msix_count &= IXGBE_PCIE_MSIX_TBL_SZ_MASK; 2885 msix_count &= IXGBE_PCIE_MSIX_TBL_SZ_MASK;
2841 2886
2842 /* MSI-X count is zero-based in HW */ 2887 /* MSI-X count is zero-based in HW */
@@ -2868,6 +2913,9 @@ s32 ixgbe_clear_vmdq_generic(struct ixgbe_hw *hw, u32 rar, u32 vmdq)
2868 mpsar_lo = IXGBE_READ_REG(hw, IXGBE_MPSAR_LO(rar)); 2913 mpsar_lo = IXGBE_READ_REG(hw, IXGBE_MPSAR_LO(rar));
2869 mpsar_hi = IXGBE_READ_REG(hw, IXGBE_MPSAR_HI(rar)); 2914 mpsar_hi = IXGBE_READ_REG(hw, IXGBE_MPSAR_HI(rar));
2870 2915
2916 if (ixgbe_removed(hw->hw_addr))
2917 goto done;
2918
2871 if (!mpsar_lo && !mpsar_hi) 2919 if (!mpsar_lo && !mpsar_hi)
2872 goto done; 2920 goto done;
2873 2921
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_common.h b/drivers/net/ethernet/intel/ixgbe/ixgbe_common.h
index f2e3919750ec..f12c40fb5537 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_common.h
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_common.h
@@ -1,7 +1,7 @@
1/******************************************************************************* 1/*******************************************************************************
2 2
3 Intel 10 Gigabit PCI Express Linux driver 3 Intel 10 Gigabit PCI Express Linux driver
4 Copyright(c) 1999 - 2013 Intel Corporation. 4 Copyright(c) 1999 - 2014 Intel Corporation.
5 5
6 This program is free software; you can redistribute it and/or modify it 6 This program is free software; you can redistribute it and/or modify it
7 under the terms and conditions of the GNU General Public License, 7 under the terms and conditions of the GNU General Public License,
@@ -20,6 +20,7 @@
20 the file called "COPYING". 20 the file called "COPYING".
21 21
22 Contact Information: 22 Contact Information:
23 Linux NICS <linux.nics@intel.com>
23 e1000-devel Mailing List <e1000-devel@lists.sourceforge.net> 24 e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
24 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 25 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
25 26
@@ -98,6 +99,10 @@ s32 ixgbe_check_mac_link_generic(struct ixgbe_hw *hw,
98 bool *link_up, bool link_up_wait_to_complete); 99 bool *link_up, bool link_up_wait_to_complete);
99s32 ixgbe_get_wwn_prefix_generic(struct ixgbe_hw *hw, u16 *wwnn_prefix, 100s32 ixgbe_get_wwn_prefix_generic(struct ixgbe_hw *hw, u16 *wwnn_prefix,
100 u16 *wwpn_prefix); 101 u16 *wwpn_prefix);
102
103s32 prot_autoc_read_generic(struct ixgbe_hw *hw, bool *, u32 *reg_val);
104s32 prot_autoc_write_generic(struct ixgbe_hw *hw, u32 reg_val, bool locked);
105
101s32 ixgbe_blink_led_start_generic(struct ixgbe_hw *hw, u32 index); 106s32 ixgbe_blink_led_start_generic(struct ixgbe_hw *hw, u32 index);
102s32 ixgbe_blink_led_stop_generic(struct ixgbe_hw *hw, u32 index); 107s32 ixgbe_blink_led_stop_generic(struct ixgbe_hw *hw, u32 index);
103void ixgbe_set_mac_anti_spoofing(struct ixgbe_hw *hw, bool enable, int pf); 108void ixgbe_set_mac_anti_spoofing(struct ixgbe_hw *hw, bool enable, int pf);
@@ -106,10 +111,10 @@ s32 ixgbe_get_device_caps_generic(struct ixgbe_hw *hw, u16 *device_caps);
106s32 ixgbe_set_fw_drv_ver_generic(struct ixgbe_hw *hw, u8 maj, u8 min, 111s32 ixgbe_set_fw_drv_ver_generic(struct ixgbe_hw *hw, u8 maj, u8 min,
107 u8 build, u8 ver); 112 u8 build, u8 ver);
108void ixgbe_clear_tx_pending(struct ixgbe_hw *hw); 113void ixgbe_clear_tx_pending(struct ixgbe_hw *hw);
114bool ixgbe_mng_enabled(struct ixgbe_hw *hw);
109 115
110void ixgbe_set_rxpba_generic(struct ixgbe_hw *hw, int num_pb, 116void ixgbe_set_rxpba_generic(struct ixgbe_hw *hw, int num_pb,
111 u32 headroom, int strategy); 117 u32 headroom, int strategy);
112s32 ixgbe_reset_pipeline_82599(struct ixgbe_hw *hw);
113 118
114#define IXGBE_I2C_THERMAL_SENSOR_ADDR 0xF8 119#define IXGBE_I2C_THERMAL_SENSOR_ADDR 0xF8
115#define IXGBE_EMC_INTERNAL_DATA 0x00 120#define IXGBE_EMC_INTERNAL_DATA 0x00
@@ -125,6 +130,11 @@ s32 ixgbe_get_thermal_sensor_data_generic(struct ixgbe_hw *hw);
125s32 ixgbe_init_thermal_sensor_thresh_generic(struct ixgbe_hw *hw); 130s32 ixgbe_init_thermal_sensor_thresh_generic(struct ixgbe_hw *hw);
126 131
127#define IXGBE_FAILED_READ_REG 0xffffffffU 132#define IXGBE_FAILED_READ_REG 0xffffffffU
133#define IXGBE_FAILED_READ_CFG_DWORD 0xffffffffU
134#define IXGBE_FAILED_READ_CFG_WORD 0xffffU
135
136u16 ixgbe_read_pci_cfg_word(struct ixgbe_hw *hw, u32 reg);
137void ixgbe_write_pci_cfg_word(struct ixgbe_hw *hw, u32 reg, u16 value);
128 138
129static inline bool ixgbe_removed(void __iomem *addr) 139static inline bool ixgbe_removed(void __iomem *addr)
130{ 140{
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_dcb_82599.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_dcb_82599.c
index 05e23b80b5e3..bdb99b3b0f30 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_dcb_82599.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_dcb_82599.c
@@ -20,6 +20,7 @@
20 the file called "COPYING". 20 the file called "COPYING".
21 21
22 Contact Information: 22 Contact Information:
23 Linux NICS <linux.nics@intel.com>
23 e1000-devel Mailing List <e1000-devel@lists.sourceforge.net> 24 e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
24 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 25 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
25 26
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_dcb_82599.h b/drivers/net/ethernet/intel/ixgbe/ixgbe_dcb_82599.h
index d71d9ce3e394..d5a1e3db0774 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_dcb_82599.h
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_dcb_82599.h
@@ -20,6 +20,7 @@
20 the file called "COPYING". 20 the file called "COPYING".
21 21
22 Contact Information: 22 Contact Information:
23 Linux NICS <linux.nics@intel.com>
23 e1000-devel Mailing List <e1000-devel@lists.sourceforge.net> 24 e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
24 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 25 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
25 26
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_debugfs.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_debugfs.c
index c5933f6dceee..472b0f450bf9 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_debugfs.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_debugfs.c
@@ -20,6 +20,7 @@
20 the file called "COPYING". 20 the file called "COPYING".
21 21
22 Contact Information: 22 Contact Information:
23 Linux NICS <linux.nics@intel.com>
23 e1000-devel Mailing List <e1000-devel@lists.sourceforge.net> 24 e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
24 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 25 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
25 26
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c
index 043307024c4a..6c55c14d082a 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c
@@ -1,7 +1,7 @@
1/******************************************************************************* 1/*******************************************************************************
2 2
3 Intel 10 Gigabit PCI Express Linux driver 3 Intel 10 Gigabit PCI Express Linux driver
4 Copyright(c) 1999 - 2013 Intel Corporation. 4 Copyright(c) 1999 - 2014 Intel Corporation.
5 5
6 This program is free software; you can redistribute it and/or modify it 6 This program is free software; you can redistribute it and/or modify it
7 under the terms and conditions of the GNU General Public License, 7 under the terms and conditions of the GNU General Public License,
@@ -20,6 +20,7 @@
20 the file called "COPYING". 20 the file called "COPYING".
21 21
22 Contact Information: 22 Contact Information:
23 Linux NICS <linux.nics@intel.com>
23 e1000-devel Mailing List <e1000-devel@lists.sourceforge.net> 24 e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
24 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 25 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
25 26
@@ -1127,10 +1128,10 @@ static void ixgbe_get_ethtool_stats(struct net_device *netdev,
1127 } 1128 }
1128 1129
1129 do { 1130 do {
1130 start = u64_stats_fetch_begin_bh(&ring->syncp); 1131 start = u64_stats_fetch_begin_irq(&ring->syncp);
1131 data[i] = ring->stats.packets; 1132 data[i] = ring->stats.packets;
1132 data[i+1] = ring->stats.bytes; 1133 data[i+1] = ring->stats.bytes;
1133 } while (u64_stats_fetch_retry_bh(&ring->syncp, start)); 1134 } while (u64_stats_fetch_retry_irq(&ring->syncp, start));
1134 i += 2; 1135 i += 2;
1135#ifdef BP_EXTENDED_STATS 1136#ifdef BP_EXTENDED_STATS
1136 data[i] = ring->stats.yields; 1137 data[i] = ring->stats.yields;
@@ -1155,10 +1156,10 @@ static void ixgbe_get_ethtool_stats(struct net_device *netdev,
1155 } 1156 }
1156 1157
1157 do { 1158 do {
1158 start = u64_stats_fetch_begin_bh(&ring->syncp); 1159 start = u64_stats_fetch_begin_irq(&ring->syncp);
1159 data[i] = ring->stats.packets; 1160 data[i] = ring->stats.packets;
1160 data[i+1] = ring->stats.bytes; 1161 data[i+1] = ring->stats.bytes;
1161 } while (u64_stats_fetch_retry_bh(&ring->syncp, start)); 1162 } while (u64_stats_fetch_retry_irq(&ring->syncp, start));
1162 i += 2; 1163 i += 2;
1163#ifdef BP_EXTENDED_STATS 1164#ifdef BP_EXTENDED_STATS
1164 data[i] = ring->stats.yields; 1165 data[i] = ring->stats.yields;
@@ -1247,6 +1248,11 @@ static int ixgbe_link_test(struct ixgbe_adapter *adapter, u64 *data)
1247 struct ixgbe_hw *hw = &adapter->hw; 1248 struct ixgbe_hw *hw = &adapter->hw;
1248 bool link_up; 1249 bool link_up;
1249 u32 link_speed = 0; 1250 u32 link_speed = 0;
1251
1252 if (ixgbe_removed(hw->hw_addr)) {
1253 *data = 1;
1254 return 1;
1255 }
1250 *data = 0; 1256 *data = 0;
1251 1257
1252 hw->mac.ops.check_link(hw, &link_speed, &link_up, true); 1258 hw->mac.ops.check_link(hw, &link_speed, &link_up, true);
@@ -1969,6 +1975,7 @@ static void ixgbe_diag_test(struct net_device *netdev,
1969 data[1] = 1; 1975 data[1] = 1;
1970 data[2] = 1; 1976 data[2] = 1;
1971 data[3] = 1; 1977 data[3] = 1;
1978 data[4] = 1;
1972 eth_test->flags |= ETH_TEST_FL_FAILED; 1979 eth_test->flags |= ETH_TEST_FL_FAILED;
1973 return; 1980 return;
1974 } 1981 }
@@ -1988,6 +1995,7 @@ static void ixgbe_diag_test(struct net_device *netdev,
1988 data[1] = 1; 1995 data[1] = 1;
1989 data[2] = 1; 1996 data[2] = 1;
1990 data[3] = 1; 1997 data[3] = 1;
1998 data[4] = 1;
1991 eth_test->flags |= ETH_TEST_FL_FAILED; 1999 eth_test->flags |= ETH_TEST_FL_FAILED;
1992 clear_bit(__IXGBE_TESTING, 2000 clear_bit(__IXGBE_TESTING,
1993 &adapter->state); 2001 &adapter->state);
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_fcoe.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_fcoe.c
index f58db453a97e..25a3dfef33e8 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_fcoe.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_fcoe.c
@@ -20,6 +20,7 @@
20 the file called "COPYING". 20 the file called "COPYING".
21 21
22 Contact Information: 22 Contact Information:
23 Linux NICS <linux.nics@intel.com>
23 e1000-devel Mailing List <e1000-devel@lists.sourceforge.net> 24 e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
24 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 25 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
25 26
@@ -407,13 +408,13 @@ int ixgbe_fcoe_ddp(struct ixgbe_adapter *adapter,
407 408
408 switch (ixgbe_test_staterr(rx_desc, IXGBE_RXDADV_STAT_FCSTAT)) { 409 switch (ixgbe_test_staterr(rx_desc, IXGBE_RXDADV_STAT_FCSTAT)) {
409 /* return 0 to bypass going to ULD for DDPed data */ 410 /* return 0 to bypass going to ULD for DDPed data */
410 case __constant_cpu_to_le32(IXGBE_RXDADV_STAT_FCSTAT_DDP): 411 case cpu_to_le32(IXGBE_RXDADV_STAT_FCSTAT_DDP):
411 /* update length of DDPed data */ 412 /* update length of DDPed data */
412 ddp->len = le32_to_cpu(rx_desc->wb.lower.hi_dword.rss); 413 ddp->len = le32_to_cpu(rx_desc->wb.lower.hi_dword.rss);
413 rc = 0; 414 rc = 0;
414 break; 415 break;
415 /* unmap the sg list when FCPRSP is received */ 416 /* unmap the sg list when FCPRSP is received */
416 case __constant_cpu_to_le32(IXGBE_RXDADV_STAT_FCSTAT_FCPRSP): 417 case cpu_to_le32(IXGBE_RXDADV_STAT_FCSTAT_FCPRSP):
417 dma_unmap_sg(&adapter->pdev->dev, ddp->sgl, 418 dma_unmap_sg(&adapter->pdev->dev, ddp->sgl,
418 ddp->sgc, DMA_FROM_DEVICE); 419 ddp->sgc, DMA_FROM_DEVICE);
419 ddp->err = ddp_err; 420 ddp->err = ddp_err;
@@ -421,14 +422,14 @@ int ixgbe_fcoe_ddp(struct ixgbe_adapter *adapter,
421 ddp->sgc = 0; 422 ddp->sgc = 0;
422 /* fall through */ 423 /* fall through */
423 /* if DDP length is present pass it through to ULD */ 424 /* if DDP length is present pass it through to ULD */
424 case __constant_cpu_to_le32(IXGBE_RXDADV_STAT_FCSTAT_NODDP): 425 case cpu_to_le32(IXGBE_RXDADV_STAT_FCSTAT_NODDP):
425 /* update length of DDPed data */ 426 /* update length of DDPed data */
426 ddp->len = le32_to_cpu(rx_desc->wb.lower.hi_dword.rss); 427 ddp->len = le32_to_cpu(rx_desc->wb.lower.hi_dword.rss);
427 if (ddp->len) 428 if (ddp->len)
428 rc = ddp->len; 429 rc = ddp->len;
429 break; 430 break;
430 /* no match will return as an error */ 431 /* no match will return as an error */
431 case __constant_cpu_to_le32(IXGBE_RXDADV_STAT_FCSTAT_NOMTCH): 432 case cpu_to_le32(IXGBE_RXDADV_STAT_FCSTAT_NOMTCH):
432 default: 433 default:
433 break; 434 break;
434 } 435 }
@@ -585,7 +586,7 @@ static int ixgbe_fcoe_dma_pool_alloc(struct ixgbe_fcoe *fcoe,
585 struct dma_pool *pool; 586 struct dma_pool *pool;
586 char pool_name[32]; 587 char pool_name[32];
587 588
588 snprintf(pool_name, 32, "ixgbe_fcoe_ddp_%d", cpu); 589 snprintf(pool_name, 32, "ixgbe_fcoe_ddp_%u", cpu);
589 590
590 pool = dma_pool_create(pool_name, dev, IXGBE_FCPTR_MAX, 591 pool = dma_pool_create(pool_name, dev, IXGBE_FCPTR_MAX,
591 IXGBE_FCPTR_ALIGN, PAGE_SIZE); 592 IXGBE_FCPTR_ALIGN, PAGE_SIZE);
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_fcoe.h b/drivers/net/ethernet/intel/ixgbe/ixgbe_fcoe.h
index 3a02759b5e95..b16cc786750d 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_fcoe.h
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_fcoe.h
@@ -20,6 +20,7 @@
20 the file called "COPYING". 20 the file called "COPYING".
21 21
22 Contact Information: 22 Contact Information:
23 Linux NICS <linux.nics@intel.com>
23 e1000-devel Mailing List <e1000-devel@lists.sourceforge.net> 24 e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
24 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 25 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
25 26
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_lib.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_lib.c
index 32e3eaaa160a..2067d392cc3d 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_lib.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_lib.c
@@ -20,6 +20,7 @@
20 the file called "COPYING". 20 the file called "COPYING".
21 21
22 Contact Information: 22 Contact Information:
23 Linux NICS <linux.nics@intel.com>
23 e1000-devel Mailing List <e1000-devel@lists.sourceforge.net> 24 e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
24 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 25 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
25 26
@@ -698,7 +699,7 @@ static void ixgbe_set_num_queues(struct ixgbe_adapter *adapter)
698static void ixgbe_acquire_msix_vectors(struct ixgbe_adapter *adapter, 699static void ixgbe_acquire_msix_vectors(struct ixgbe_adapter *adapter,
699 int vectors) 700 int vectors)
700{ 701{
701 int err, vector_threshold; 702 int vector_threshold;
702 703
703 /* We'll want at least 2 (vector_threshold): 704 /* We'll want at least 2 (vector_threshold):
704 * 1) TxQ[0] + RxQ[0] handler 705 * 1) TxQ[0] + RxQ[0] handler
@@ -712,18 +713,10 @@ static void ixgbe_acquire_msix_vectors(struct ixgbe_adapter *adapter,
712 * Right now, we simply care about how many we'll get; we'll 713 * Right now, we simply care about how many we'll get; we'll
713 * set them up later while requesting irq's. 714 * set them up later while requesting irq's.
714 */ 715 */
715 while (vectors >= vector_threshold) { 716 vectors = pci_enable_msix_range(adapter->pdev, adapter->msix_entries,
716 err = pci_enable_msix(adapter->pdev, adapter->msix_entries, 717 vector_threshold, vectors);
717 vectors);
718 if (!err) /* Success in acquiring all requested vectors. */
719 break;
720 else if (err < 0)
721 vectors = 0; /* Nasty failure, quit now */
722 else /* err == number of vectors we should try again with */
723 vectors = err;
724 }
725 718
726 if (vectors < vector_threshold) { 719 if (vectors < 0) {
727 /* Can't allocate enough MSI-X interrupts? Oh well. 720 /* Can't allocate enough MSI-X interrupts? Oh well.
728 * This just means we'll go with either a single MSI 721 * This just means we'll go with either a single MSI
729 * vector or fall back to legacy interrupts. 722 * vector or fall back to legacy interrupts.
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
index 18076c4178b4..9e5a36612432 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
@@ -1,7 +1,7 @@
1/******************************************************************************* 1/*******************************************************************************
2 2
3 Intel 10 Gigabit PCI Express Linux driver 3 Intel 10 Gigabit PCI Express Linux driver
4 Copyright(c) 1999 - 2013 Intel Corporation. 4 Copyright(c) 1999 - 2014 Intel Corporation.
5 5
6 This program is free software; you can redistribute it and/or modify it 6 This program is free software; you can redistribute it and/or modify it
7 under the terms and conditions of the GNU General Public License, 7 under the terms and conditions of the GNU General Public License,
@@ -20,6 +20,7 @@
20 the file called "COPYING". 20 the file called "COPYING".
21 21
22 Contact Information: 22 Contact Information:
23 Linux NICS <linux.nics@intel.com>
23 e1000-devel Mailing List <e1000-devel@lists.sourceforge.net> 24 e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
24 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 25 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
25 26
@@ -67,7 +68,7 @@ static char ixgbe_default_device_descr[] =
67#define DRV_VERSION "3.19.1-k" 68#define DRV_VERSION "3.19.1-k"
68const char ixgbe_driver_version[] = DRV_VERSION; 69const char ixgbe_driver_version[] = DRV_VERSION;
69static const char ixgbe_copyright[] = 70static const char ixgbe_copyright[] =
70 "Copyright (c) 1999-2013 Intel Corporation."; 71 "Copyright (c) 1999-2014 Intel Corporation.";
71 72
72static const struct ixgbe_info *ixgbe_info_tbl[] = { 73static const struct ixgbe_info *ixgbe_info_tbl[] = {
73 [board_82598] = &ixgbe_82598_info, 74 [board_82598] = &ixgbe_82598_info,
@@ -151,6 +152,8 @@ MODULE_DESCRIPTION("Intel(R) 10 Gigabit PCI Express Network Driver");
151MODULE_LICENSE("GPL"); 152MODULE_LICENSE("GPL");
152MODULE_VERSION(DRV_VERSION); 153MODULE_VERSION(DRV_VERSION);
153 154
155static bool ixgbe_check_cfg_remove(struct ixgbe_hw *hw, struct pci_dev *pdev);
156
154static int ixgbe_read_pci_cfg_word_parent(struct ixgbe_adapter *adapter, 157static int ixgbe_read_pci_cfg_word_parent(struct ixgbe_adapter *adapter,
155 u32 reg, u16 *value) 158 u32 reg, u16 *value)
156{ 159{
@@ -169,6 +172,9 @@ static int ixgbe_read_pci_cfg_word_parent(struct ixgbe_adapter *adapter,
169 return -1; 172 return -1;
170 173
171 pcie_capability_read_word(parent_dev, reg, value); 174 pcie_capability_read_word(parent_dev, reg, value);
175 if (*value == IXGBE_FAILED_READ_CFG_WORD &&
176 ixgbe_check_cfg_remove(&adapter->hw, parent_dev))
177 return -1;
172 return 0; 178 return 0;
173} 179}
174 180
@@ -313,6 +319,57 @@ void ixgbe_check_remove(struct ixgbe_hw *hw, u32 reg)
313 ixgbe_remove_adapter(hw); 319 ixgbe_remove_adapter(hw);
314} 320}
315 321
322static bool ixgbe_check_cfg_remove(struct ixgbe_hw *hw, struct pci_dev *pdev)
323{
324 u16 value;
325
326 pci_read_config_word(pdev, PCI_VENDOR_ID, &value);
327 if (value == IXGBE_FAILED_READ_CFG_WORD) {
328 ixgbe_remove_adapter(hw);
329 return true;
330 }
331 return false;
332}
333
334u16 ixgbe_read_pci_cfg_word(struct ixgbe_hw *hw, u32 reg)
335{
336 struct ixgbe_adapter *adapter = hw->back;
337 u16 value;
338
339 if (ixgbe_removed(hw->hw_addr))
340 return IXGBE_FAILED_READ_CFG_WORD;
341 pci_read_config_word(adapter->pdev, reg, &value);
342 if (value == IXGBE_FAILED_READ_CFG_WORD &&
343 ixgbe_check_cfg_remove(hw, adapter->pdev))
344 return IXGBE_FAILED_READ_CFG_WORD;
345 return value;
346}
347
348#ifdef CONFIG_PCI_IOV
349static u32 ixgbe_read_pci_cfg_dword(struct ixgbe_hw *hw, u32 reg)
350{
351 struct ixgbe_adapter *adapter = hw->back;
352 u32 value;
353
354 if (ixgbe_removed(hw->hw_addr))
355 return IXGBE_FAILED_READ_CFG_DWORD;
356 pci_read_config_dword(adapter->pdev, reg, &value);
357 if (value == IXGBE_FAILED_READ_CFG_DWORD &&
358 ixgbe_check_cfg_remove(hw, adapter->pdev))
359 return IXGBE_FAILED_READ_CFG_DWORD;
360 return value;
361}
362#endif /* CONFIG_PCI_IOV */
363
364void ixgbe_write_pci_cfg_word(struct ixgbe_hw *hw, u32 reg, u16 value)
365{
366 struct ixgbe_adapter *adapter = hw->back;
367
368 if (ixgbe_removed(hw->hw_addr))
369 return;
370 pci_write_config_word(adapter->pdev, reg, value);
371}
372
316static void ixgbe_service_event_complete(struct ixgbe_adapter *adapter) 373static void ixgbe_service_event_complete(struct ixgbe_adapter *adapter)
317{ 374{
318 BUG_ON(!test_bit(__IXGBE_SERVICE_SCHED, &adapter->state)); 375 BUG_ON(!test_bit(__IXGBE_SERVICE_SCHED, &adapter->state));
@@ -1264,7 +1321,9 @@ static inline void ixgbe_rx_hash(struct ixgbe_ring *ring,
1264 struct sk_buff *skb) 1321 struct sk_buff *skb)
1265{ 1322{
1266 if (ring->netdev->features & NETIF_F_RXHASH) 1323 if (ring->netdev->features & NETIF_F_RXHASH)
1267 skb->rxhash = le32_to_cpu(rx_desc->wb.lower.hi_dword.rss); 1324 skb_set_hash(skb,
1325 le32_to_cpu(rx_desc->wb.lower.hi_dword.rss),
1326 PKT_HASH_TYPE_L3);
1268} 1327}
1269 1328
1270#ifdef IXGBE_FCOE 1329#ifdef IXGBE_FCOE
@@ -1480,7 +1539,7 @@ static unsigned int ixgbe_get_headlen(unsigned char *data,
1480 hdr.network += ETH_HLEN; 1539 hdr.network += ETH_HLEN;
1481 1540
1482 /* handle any vlan tag if present */ 1541 /* handle any vlan tag if present */
1483 if (protocol == __constant_htons(ETH_P_8021Q)) { 1542 if (protocol == htons(ETH_P_8021Q)) {
1484 if ((hdr.network - data) > (max_len - VLAN_HLEN)) 1543 if ((hdr.network - data) > (max_len - VLAN_HLEN))
1485 return max_len; 1544 return max_len;
1486 1545
@@ -1489,7 +1548,7 @@ static unsigned int ixgbe_get_headlen(unsigned char *data,
1489 } 1548 }
1490 1549
1491 /* handle L3 protocols */ 1550 /* handle L3 protocols */
1492 if (protocol == __constant_htons(ETH_P_IP)) { 1551 if (protocol == htons(ETH_P_IP)) {
1493 if ((hdr.network - data) > (max_len - sizeof(struct iphdr))) 1552 if ((hdr.network - data) > (max_len - sizeof(struct iphdr)))
1494 return max_len; 1553 return max_len;
1495 1554
@@ -1503,7 +1562,7 @@ static unsigned int ixgbe_get_headlen(unsigned char *data,
1503 /* record next protocol if header is present */ 1562 /* record next protocol if header is present */
1504 if (!(hdr.ipv4->frag_off & htons(IP_OFFSET))) 1563 if (!(hdr.ipv4->frag_off & htons(IP_OFFSET)))
1505 nexthdr = hdr.ipv4->protocol; 1564 nexthdr = hdr.ipv4->protocol;
1506 } else if (protocol == __constant_htons(ETH_P_IPV6)) { 1565 } else if (protocol == htons(ETH_P_IPV6)) {
1507 if ((hdr.network - data) > (max_len - sizeof(struct ipv6hdr))) 1566 if ((hdr.network - data) > (max_len - sizeof(struct ipv6hdr)))
1508 return max_len; 1567 return max_len;
1509 1568
@@ -1511,7 +1570,7 @@ static unsigned int ixgbe_get_headlen(unsigned char *data,
1511 nexthdr = hdr.ipv6->nexthdr; 1570 nexthdr = hdr.ipv6->nexthdr;
1512 hlen = sizeof(struct ipv6hdr); 1571 hlen = sizeof(struct ipv6hdr);
1513#ifdef IXGBE_FCOE 1572#ifdef IXGBE_FCOE
1514 } else if (protocol == __constant_htons(ETH_P_FCOE)) { 1573 } else if (protocol == htons(ETH_P_FCOE)) {
1515 if ((hdr.network - data) > (max_len - FCOE_HEADER_LEN)) 1574 if ((hdr.network - data) > (max_len - FCOE_HEADER_LEN))
1516 return max_len; 1575 return max_len;
1517 hlen = FCOE_HEADER_LEN; 1576 hlen = FCOE_HEADER_LEN;
@@ -2026,7 +2085,7 @@ static int ixgbe_clean_rx_irq(struct ixgbe_q_vector *q_vector,
2026#endif /* IXGBE_FCOE */ 2085#endif /* IXGBE_FCOE */
2027 u16 cleaned_count = ixgbe_desc_unused(rx_ring); 2086 u16 cleaned_count = ixgbe_desc_unused(rx_ring);
2028 2087
2029 do { 2088 while (likely(total_rx_packets < budget)) {
2030 union ixgbe_adv_rx_desc *rx_desc; 2089 union ixgbe_adv_rx_desc *rx_desc;
2031 struct sk_buff *skb; 2090 struct sk_buff *skb;
2032 2091
@@ -2101,7 +2160,7 @@ static int ixgbe_clean_rx_irq(struct ixgbe_q_vector *q_vector,
2101 2160
2102 /* update budget accounting */ 2161 /* update budget accounting */
2103 total_rx_packets++; 2162 total_rx_packets++;
2104 } while (likely(total_rx_packets < budget)); 2163 }
2105 2164
2106 u64_stats_update_begin(&rx_ring->syncp); 2165 u64_stats_update_begin(&rx_ring->syncp);
2107 rx_ring->stats.packets += total_rx_packets; 2166 rx_ring->stats.packets += total_rx_packets;
@@ -2630,9 +2689,12 @@ static irqreturn_t ixgbe_msix_other(int irq, void *data)
2630 switch (hw->mac.type) { 2689 switch (hw->mac.type) {
2631 case ixgbe_mac_82599EB: 2690 case ixgbe_mac_82599EB:
2632 case ixgbe_mac_X540: 2691 case ixgbe_mac_X540:
2633 if (eicr & IXGBE_EICR_ECC) 2692 if (eicr & IXGBE_EICR_ECC) {
2634 e_info(link, "Received unrecoverable ECC Err, please " 2693 e_info(link, "Received ECC Err, initiating reset\n");
2635 "reboot\n"); 2694 adapter->flags2 |= IXGBE_FLAG2_RESET_REQUESTED;
2695 ixgbe_service_event_schedule(adapter);
2696 IXGBE_WRITE_REG(hw, IXGBE_EICR, IXGBE_EICR_ECC);
2697 }
2636 /* Handle Flow Director Full threshold interrupt */ 2698 /* Handle Flow Director Full threshold interrupt */
2637 if (eicr & IXGBE_EICR_FLOW_DIR) { 2699 if (eicr & IXGBE_EICR_FLOW_DIR) {
2638 int reinit_count = 0; 2700 int reinit_count = 0;
@@ -2846,9 +2908,12 @@ static irqreturn_t ixgbe_intr(int irq, void *data)
2846 ixgbe_check_sfp_event(adapter, eicr); 2908 ixgbe_check_sfp_event(adapter, eicr);
2847 /* Fall through */ 2909 /* Fall through */
2848 case ixgbe_mac_X540: 2910 case ixgbe_mac_X540:
2849 if (eicr & IXGBE_EICR_ECC) 2911 if (eicr & IXGBE_EICR_ECC) {
2850 e_info(link, "Received unrecoverable ECC err, please " 2912 e_info(link, "Received ECC Err, initiating reset\n");
2851 "reboot\n"); 2913 adapter->flags2 |= IXGBE_FLAG2_RESET_REQUESTED;
2914 ixgbe_service_event_schedule(adapter);
2915 IXGBE_WRITE_REG(hw, IXGBE_EICR, IXGBE_EICR_ECC);
2916 }
2852 ixgbe_check_overtemp_event(adapter, eicr); 2917 ixgbe_check_overtemp_event(adapter, eicr);
2853 break; 2918 break;
2854 default: 2919 default:
@@ -4590,8 +4655,6 @@ static void ixgbe_setup_gpie(struct ixgbe_adapter *adapter)
4590static void ixgbe_up_complete(struct ixgbe_adapter *adapter) 4655static void ixgbe_up_complete(struct ixgbe_adapter *adapter)
4591{ 4656{
4592 struct ixgbe_hw *hw = &adapter->hw; 4657 struct ixgbe_hw *hw = &adapter->hw;
4593 struct net_device *upper;
4594 struct list_head *iter;
4595 int err; 4658 int err;
4596 u32 ctrl_ext; 4659 u32 ctrl_ext;
4597 4660
@@ -4633,19 +4696,6 @@ static void ixgbe_up_complete(struct ixgbe_adapter *adapter)
4633 e_crit(drv, "Fan has stopped, replace the adapter\n"); 4696 e_crit(drv, "Fan has stopped, replace the adapter\n");
4634 } 4697 }
4635 4698
4636 /* enable transmits */
4637 netif_tx_start_all_queues(adapter->netdev);
4638
4639 /* enable any upper devices */
4640 netdev_for_each_all_upper_dev_rcu(adapter->netdev, upper, iter) {
4641 if (netif_is_macvlan(upper)) {
4642 struct macvlan_dev *vlan = netdev_priv(upper);
4643
4644 if (vlan->fwd_priv)
4645 netif_tx_start_all_queues(upper);
4646 }
4647 }
4648
4649 /* bring the link up in the watchdog, this could race with our first 4699 /* bring the link up in the watchdog, this could race with our first
4650 * link up interrupt but shouldn't be a problem */ 4700 * link up interrupt but shouldn't be a problem */
4651 adapter->flags |= IXGBE_FLAG_NEED_LINK_UPDATE; 4701 adapter->flags |= IXGBE_FLAG_NEED_LINK_UPDATE;
@@ -5502,6 +5552,7 @@ static int ixgbe_resume(struct pci_dev *pdev)
5502 struct net_device *netdev = adapter->netdev; 5552 struct net_device *netdev = adapter->netdev;
5503 u32 err; 5553 u32 err;
5504 5554
5555 adapter->hw.hw_addr = adapter->io_addr;
5505 pci_set_power_state(pdev, PCI_D0); 5556 pci_set_power_state(pdev, PCI_D0);
5506 pci_restore_state(pdev); 5557 pci_restore_state(pdev);
5507 /* 5558 /*
@@ -6016,6 +6067,8 @@ static void ixgbe_watchdog_link_is_up(struct ixgbe_adapter *adapter)
6016{ 6067{
6017 struct net_device *netdev = adapter->netdev; 6068 struct net_device *netdev = adapter->netdev;
6018 struct ixgbe_hw *hw = &adapter->hw; 6069 struct ixgbe_hw *hw = &adapter->hw;
6070 struct net_device *upper;
6071 struct list_head *iter;
6019 u32 link_speed = adapter->link_speed; 6072 u32 link_speed = adapter->link_speed;
6020 bool flow_rx, flow_tx; 6073 bool flow_rx, flow_tx;
6021 6074
@@ -6067,6 +6120,21 @@ static void ixgbe_watchdog_link_is_up(struct ixgbe_adapter *adapter)
6067 netif_carrier_on(netdev); 6120 netif_carrier_on(netdev);
6068 ixgbe_check_vf_rate_limit(adapter); 6121 ixgbe_check_vf_rate_limit(adapter);
6069 6122
6123 /* enable transmits */
6124 netif_tx_wake_all_queues(adapter->netdev);
6125
6126 /* enable any upper devices */
6127 rtnl_lock();
6128 netdev_for_each_all_upper_dev_rcu(adapter->netdev, upper, iter) {
6129 if (netif_is_macvlan(upper)) {
6130 struct macvlan_dev *vlan = netdev_priv(upper);
6131
6132 if (vlan->fwd_priv)
6133 netif_tx_wake_all_queues(upper);
6134 }
6135 }
6136 rtnl_unlock();
6137
6070 /* update the default user priority for VFs */ 6138 /* update the default user priority for VFs */
6071 ixgbe_update_default_up(adapter); 6139 ixgbe_update_default_up(adapter);
6072 6140
@@ -6454,7 +6522,7 @@ static int ixgbe_tso(struct ixgbe_ring *tx_ring,
6454 /* ADV DTYP TUCMD MKRLOC/ISCSIHEDLEN */ 6522 /* ADV DTYP TUCMD MKRLOC/ISCSIHEDLEN */
6455 type_tucmd = IXGBE_ADVTXD_TUCMD_L4T_TCP; 6523 type_tucmd = IXGBE_ADVTXD_TUCMD_L4T_TCP;
6456 6524
6457 if (first->protocol == __constant_htons(ETH_P_IP)) { 6525 if (first->protocol == htons(ETH_P_IP)) {
6458 struct iphdr *iph = ip_hdr(skb); 6526 struct iphdr *iph = ip_hdr(skb);
6459 iph->tot_len = 0; 6527 iph->tot_len = 0;
6460 iph->check = 0; 6528 iph->check = 0;
@@ -6514,12 +6582,12 @@ static void ixgbe_tx_csum(struct ixgbe_ring *tx_ring,
6514 } else { 6582 } else {
6515 u8 l4_hdr = 0; 6583 u8 l4_hdr = 0;
6516 switch (first->protocol) { 6584 switch (first->protocol) {
6517 case __constant_htons(ETH_P_IP): 6585 case htons(ETH_P_IP):
6518 vlan_macip_lens |= skb_network_header_len(skb); 6586 vlan_macip_lens |= skb_network_header_len(skb);
6519 type_tucmd |= IXGBE_ADVTXD_TUCMD_IPV4; 6587 type_tucmd |= IXGBE_ADVTXD_TUCMD_IPV4;
6520 l4_hdr = ip_hdr(skb)->protocol; 6588 l4_hdr = ip_hdr(skb)->protocol;
6521 break; 6589 break;
6522 case __constant_htons(ETH_P_IPV6): 6590 case htons(ETH_P_IPV6):
6523 vlan_macip_lens |= skb_network_header_len(skb); 6591 vlan_macip_lens |= skb_network_header_len(skb);
6524 l4_hdr = ipv6_hdr(skb)->nexthdr; 6592 l4_hdr = ipv6_hdr(skb)->nexthdr;
6525 break; 6593 break;
@@ -6794,9 +6862,9 @@ static void ixgbe_atr(struct ixgbe_ring *ring,
6794 hdr.network = skb_network_header(first->skb); 6862 hdr.network = skb_network_header(first->skb);
6795 6863
6796 /* Currently only IPv4/IPv6 with TCP is supported */ 6864 /* Currently only IPv4/IPv6 with TCP is supported */
6797 if ((first->protocol != __constant_htons(ETH_P_IPV6) || 6865 if ((first->protocol != htons(ETH_P_IPV6) ||
6798 hdr.ipv6->nexthdr != IPPROTO_TCP) && 6866 hdr.ipv6->nexthdr != IPPROTO_TCP) &&
6799 (first->protocol != __constant_htons(ETH_P_IP) || 6867 (first->protocol != htons(ETH_P_IP) ||
6800 hdr.ipv4->protocol != IPPROTO_TCP)) 6868 hdr.ipv4->protocol != IPPROTO_TCP))
6801 return; 6869 return;
6802 6870
@@ -6829,12 +6897,12 @@ static void ixgbe_atr(struct ixgbe_ring *ring,
6829 * and write the value to source port portion of compressed dword 6897 * and write the value to source port portion of compressed dword
6830 */ 6898 */
6831 if (first->tx_flags & (IXGBE_TX_FLAGS_SW_VLAN | IXGBE_TX_FLAGS_HW_VLAN)) 6899 if (first->tx_flags & (IXGBE_TX_FLAGS_SW_VLAN | IXGBE_TX_FLAGS_HW_VLAN))
6832 common.port.src ^= th->dest ^ __constant_htons(ETH_P_8021Q); 6900 common.port.src ^= th->dest ^ htons(ETH_P_8021Q);
6833 else 6901 else
6834 common.port.src ^= th->dest ^ first->protocol; 6902 common.port.src ^= th->dest ^ first->protocol;
6835 common.port.dst ^= th->source; 6903 common.port.dst ^= th->source;
6836 6904
6837 if (first->protocol == __constant_htons(ETH_P_IP)) { 6905 if (first->protocol == htons(ETH_P_IP)) {
6838 input.formatted.flow_type = IXGBE_ATR_FLOW_TYPE_TCPV4; 6906 input.formatted.flow_type = IXGBE_ATR_FLOW_TYPE_TCPV4;
6839 common.ip ^= hdr.ipv4->saddr ^ hdr.ipv4->daddr; 6907 common.ip ^= hdr.ipv4->saddr ^ hdr.ipv4->daddr;
6840 } else { 6908 } else {
@@ -6900,8 +6968,8 @@ static u16 ixgbe_select_queue(struct net_device *dev, struct sk_buff *skb,
6900 * or FIP and we have FCoE enabled on the adapter 6968 * or FIP and we have FCoE enabled on the adapter
6901 */ 6969 */
6902 switch (vlan_get_protocol(skb)) { 6970 switch (vlan_get_protocol(skb)) {
6903 case __constant_htons(ETH_P_FCOE): 6971 case htons(ETH_P_FCOE):
6904 case __constant_htons(ETH_P_FIP): 6972 case htons(ETH_P_FIP):
6905 adapter = netdev_priv(dev); 6973 adapter = netdev_priv(dev);
6906 6974
6907 if (adapter->flags & IXGBE_FLAG_FCOE_ENABLED) 6975 if (adapter->flags & IXGBE_FLAG_FCOE_ENABLED)
@@ -6962,7 +7030,7 @@ netdev_tx_t ixgbe_xmit_frame_ring(struct sk_buff *skb,
6962 tx_flags |= vlan_tx_tag_get(skb) << IXGBE_TX_FLAGS_VLAN_SHIFT; 7030 tx_flags |= vlan_tx_tag_get(skb) << IXGBE_TX_FLAGS_VLAN_SHIFT;
6963 tx_flags |= IXGBE_TX_FLAGS_HW_VLAN; 7031 tx_flags |= IXGBE_TX_FLAGS_HW_VLAN;
6964 /* else if it is a SW VLAN check the next protocol and store the tag */ 7032 /* else if it is a SW VLAN check the next protocol and store the tag */
6965 } else if (protocol == __constant_htons(ETH_P_8021Q)) { 7033 } else if (protocol == htons(ETH_P_8021Q)) {
6966 struct vlan_hdr *vhdr, _vhdr; 7034 struct vlan_hdr *vhdr, _vhdr;
6967 vhdr = skb_header_pointer(skb, ETH_HLEN, sizeof(_vhdr), &_vhdr); 7035 vhdr = skb_header_pointer(skb, ETH_HLEN, sizeof(_vhdr), &_vhdr);
6968 if (!vhdr) 7036 if (!vhdr)
@@ -7021,7 +7089,7 @@ netdev_tx_t ixgbe_xmit_frame_ring(struct sk_buff *skb,
7021 7089
7022#ifdef IXGBE_FCOE 7090#ifdef IXGBE_FCOE
7023 /* setup tx offload for FCoE */ 7091 /* setup tx offload for FCoE */
7024 if ((protocol == __constant_htons(ETH_P_FCOE)) && 7092 if ((protocol == htons(ETH_P_FCOE)) &&
7025 (tx_ring->netdev->features & (NETIF_F_FSO | NETIF_F_FCOE_CRC))) { 7093 (tx_ring->netdev->features & (NETIF_F_FSO | NETIF_F_FCOE_CRC))) {
7026 tso = ixgbe_fso(tx_ring, first, &hdr_len); 7094 tso = ixgbe_fso(tx_ring, first, &hdr_len);
7027 if (tso < 0) 7095 if (tso < 0)
@@ -7143,7 +7211,9 @@ static int ixgbe_ioctl(struct net_device *netdev, struct ifreq *req, int cmd)
7143 7211
7144 switch (cmd) { 7212 switch (cmd) {
7145 case SIOCSHWTSTAMP: 7213 case SIOCSHWTSTAMP:
7146 return ixgbe_ptp_hwtstamp_ioctl(adapter, req, cmd); 7214 return ixgbe_ptp_set_ts_config(adapter, req);
7215 case SIOCGHWTSTAMP:
7216 return ixgbe_ptp_get_ts_config(adapter, req);
7147 default: 7217 default:
7148 return mdio_mii_ioctl(&adapter->hw.phy.mdio, if_mii(req), cmd); 7218 return mdio_mii_ioctl(&adapter->hw.phy.mdio, if_mii(req), cmd);
7149 } 7219 }
@@ -7234,10 +7304,10 @@ static struct rtnl_link_stats64 *ixgbe_get_stats64(struct net_device *netdev,
7234 7304
7235 if (ring) { 7305 if (ring) {
7236 do { 7306 do {
7237 start = u64_stats_fetch_begin_bh(&ring->syncp); 7307 start = u64_stats_fetch_begin_irq(&ring->syncp);
7238 packets = ring->stats.packets; 7308 packets = ring->stats.packets;
7239 bytes = ring->stats.bytes; 7309 bytes = ring->stats.bytes;
7240 } while (u64_stats_fetch_retry_bh(&ring->syncp, start)); 7310 } while (u64_stats_fetch_retry_irq(&ring->syncp, start));
7241 stats->rx_packets += packets; 7311 stats->rx_packets += packets;
7242 stats->rx_bytes += bytes; 7312 stats->rx_bytes += bytes;
7243 } 7313 }
@@ -7250,10 +7320,10 @@ static struct rtnl_link_stats64 *ixgbe_get_stats64(struct net_device *netdev,
7250 7320
7251 if (ring) { 7321 if (ring) {
7252 do { 7322 do {
7253 start = u64_stats_fetch_begin_bh(&ring->syncp); 7323 start = u64_stats_fetch_begin_irq(&ring->syncp);
7254 packets = ring->stats.packets; 7324 packets = ring->stats.packets;
7255 bytes = ring->stats.bytes; 7325 bytes = ring->stats.bytes;
7256 } while (u64_stats_fetch_retry_bh(&ring->syncp, start)); 7326 } while (u64_stats_fetch_retry_irq(&ring->syncp, start));
7257 stats->tx_packets += packets; 7327 stats->tx_packets += packets;
7258 stats->tx_bytes += bytes; 7328 stats->tx_bytes += bytes;
7259 } 7329 }
@@ -7792,6 +7862,7 @@ int ixgbe_wol_supported(struct ixgbe_adapter *adapter, u16 device_id,
7792 case IXGBE_DEV_ID_82599_SFP: 7862 case IXGBE_DEV_ID_82599_SFP:
7793 /* Only these subdevices could supports WOL */ 7863 /* Only these subdevices could supports WOL */
7794 switch (subdevice_id) { 7864 switch (subdevice_id) {
7865 case IXGBE_SUBDEV_ID_82599_SFP_WOL0:
7795 case IXGBE_SUBDEV_ID_82599_560FLR: 7866 case IXGBE_SUBDEV_ID_82599_560FLR:
7796 /* only support first port */ 7867 /* only support first port */
7797 if (hw->bus.func != 0) 7868 if (hw->bus.func != 0)
@@ -7969,10 +8040,6 @@ static int ixgbe_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
7969 if (err) 8040 if (err)
7970 goto err_sw_init; 8041 goto err_sw_init;
7971 8042
7972 /* Cache if MNG FW is up so we don't have to read the REG later */
7973 if (hw->mac.ops.mng_fw_enabled)
7974 hw->mng_fw_enabled = hw->mac.ops.mng_fw_enabled(hw);
7975
7976 /* Make it possible the adapter to be woken up via WOL */ 8043 /* Make it possible the adapter to be woken up via WOL */
7977 switch (adapter->hw.mac.type) { 8044 switch (adapter->hw.mac.type) {
7978 case ixgbe_mac_82599EB: 8045 case ixgbe_mac_82599EB:
@@ -8223,7 +8290,7 @@ skip_sriov:
8223 ixgbe_dbg_adapter_init(adapter); 8290 ixgbe_dbg_adapter_init(adapter);
8224 8291
8225 /* Need link setup for MNG FW, else wait for IXGBE_UP */ 8292 /* Need link setup for MNG FW, else wait for IXGBE_UP */
8226 if (hw->mng_fw_enabled && hw->mac.ops.setup_link) 8293 if (ixgbe_mng_enabled(hw) && hw->mac.ops.setup_link)
8227 hw->mac.ops.setup_link(hw, 8294 hw->mac.ops.setup_link(hw,
8228 IXGBE_LINK_SPEED_10GB_FULL | IXGBE_LINK_SPEED_1GB_FULL, 8295 IXGBE_LINK_SPEED_10GB_FULL | IXGBE_LINK_SPEED_1GB_FULL,
8229 true); 8296 true);
@@ -8331,6 +8398,7 @@ static pci_ers_result_t ixgbe_io_error_detected(struct pci_dev *pdev,
8331 struct net_device *netdev = adapter->netdev; 8398 struct net_device *netdev = adapter->netdev;
8332 8399
8333#ifdef CONFIG_PCI_IOV 8400#ifdef CONFIG_PCI_IOV
8401 struct ixgbe_hw *hw = &adapter->hw;
8334 struct pci_dev *bdev, *vfdev; 8402 struct pci_dev *bdev, *vfdev;
8335 u32 dw0, dw1, dw2, dw3; 8403 u32 dw0, dw1, dw2, dw3;
8336 int vf, pos; 8404 int vf, pos;
@@ -8351,10 +8419,12 @@ static pci_ers_result_t ixgbe_io_error_detected(struct pci_dev *pdev,
8351 if (!pos) 8419 if (!pos)
8352 goto skip_bad_vf_detection; 8420 goto skip_bad_vf_detection;
8353 8421
8354 pci_read_config_dword(bdev, pos + PCI_ERR_HEADER_LOG, &dw0); 8422 dw0 = ixgbe_read_pci_cfg_dword(hw, pos + PCI_ERR_HEADER_LOG);
8355 pci_read_config_dword(bdev, pos + PCI_ERR_HEADER_LOG + 4, &dw1); 8423 dw1 = ixgbe_read_pci_cfg_dword(hw, pos + PCI_ERR_HEADER_LOG + 4);
8356 pci_read_config_dword(bdev, pos + PCI_ERR_HEADER_LOG + 8, &dw2); 8424 dw2 = ixgbe_read_pci_cfg_dword(hw, pos + PCI_ERR_HEADER_LOG + 8);
8357 pci_read_config_dword(bdev, pos + PCI_ERR_HEADER_LOG + 12, &dw3); 8425 dw3 = ixgbe_read_pci_cfg_dword(hw, pos + PCI_ERR_HEADER_LOG + 12);
8426 if (ixgbe_removed(hw->hw_addr))
8427 goto skip_bad_vf_detection;
8358 8428
8359 req_id = dw1 >> 16; 8429 req_id = dw1 >> 16;
8360 /* On the 82599 if bit 7 of the requestor ID is set then it's a VF */ 8430 /* On the 82599 if bit 7 of the requestor ID is set then it's a VF */
@@ -8446,6 +8516,7 @@ static pci_ers_result_t ixgbe_io_slot_reset(struct pci_dev *pdev)
8446 e_err(probe, "Cannot re-enable PCI device after reset.\n"); 8516 e_err(probe, "Cannot re-enable PCI device after reset.\n");
8447 result = PCI_ERS_RESULT_DISCONNECT; 8517 result = PCI_ERS_RESULT_DISCONNECT;
8448 } else { 8518 } else {
8519 adapter->hw.hw_addr = adapter->io_addr;
8449 pci_set_master(pdev); 8520 pci_set_master(pdev);
8450 pci_restore_state(pdev); 8521 pci_restore_state(pdev);
8451 pci_save_state(pdev); 8522 pci_save_state(pdev);
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_mbx.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_mbx.c
index cc3101afd29f..f5c6af2b891b 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_mbx.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_mbx.c
@@ -20,6 +20,7 @@
20 the file called "COPYING". 20 the file called "COPYING".
21 21
22 Contact Information: 22 Contact Information:
23 Linux NICS <linux.nics@intel.com>
23 e1000-devel Mailing List <e1000-devel@lists.sourceforge.net> 24 e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
24 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 25 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
25 26
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_mbx.h b/drivers/net/ethernet/intel/ixgbe/ixgbe_mbx.h
index e44ff47659b5..a9b9ad69ed0e 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_mbx.h
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_mbx.h
@@ -20,6 +20,7 @@
20 the file called "COPYING". 20 the file called "COPYING".
21 21
22 Contact Information: 22 Contact Information:
23 Linux NICS <linux.nics@intel.com>
23 e1000-devel Mailing List <e1000-devel@lists.sourceforge.net> 24 e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
24 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 25 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
25 26
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_phy.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_phy.c
index 132557c318f8..ad51c12cb26a 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_phy.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_phy.c
@@ -1,7 +1,7 @@
1/******************************************************************************* 1/*******************************************************************************
2 2
3 Intel 10 Gigabit PCI Express Linux driver 3 Intel 10 Gigabit PCI Express Linux driver
4 Copyright(c) 1999 - 2013 Intel Corporation. 4 Copyright(c) 1999 - 2014 Intel Corporation.
5 5
6 This program is free software; you can redistribute it and/or modify it 6 This program is free software; you can redistribute it and/or modify it
7 under the terms and conditions of the GNU General Public License, 7 under the terms and conditions of the GNU General Public License,
@@ -20,6 +20,7 @@
20 the file called "COPYING". 20 the file called "COPYING".
21 21
22 Contact Information: 22 Contact Information:
23 Linux NICS <linux.nics@intel.com>
23 e1000-devel Mailing List <e1000-devel@lists.sourceforge.net> 24 e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
24 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 25 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
25 26
@@ -98,6 +99,32 @@ s32 ixgbe_identify_phy_generic(struct ixgbe_hw *hw)
98} 99}
99 100
100/** 101/**
102 * ixgbe_check_reset_blocked - check status of MNG FW veto bit
103 * @hw: pointer to the hardware structure
104 *
105 * This function checks the MMNGC.MNG_VETO bit to see if there are
106 * any constraints on link from manageability. For MAC's that don't
107 * have this bit just return false since the link can not be blocked
108 * via this method.
109 **/
110s32 ixgbe_check_reset_blocked(struct ixgbe_hw *hw)
111{
112 u32 mmngc;
113
114 /* If we don't have this bit, it can't be blocking */
115 if (hw->mac.type == ixgbe_mac_82598EB)
116 return false;
117
118 mmngc = IXGBE_READ_REG(hw, IXGBE_MMNGC);
119 if (mmngc & IXGBE_MMNGC_MNG_VETO) {
120 hw_dbg(hw, "MNG_VETO bit detected.\n");
121 return true;
122 }
123
124 return false;
125}
126
127/**
101 * ixgbe_get_phy_id - Get the phy type 128 * ixgbe_get_phy_id - Get the phy type
102 * @hw: pointer to hardware structure 129 * @hw: pointer to hardware structure
103 * 130 *
@@ -172,6 +199,10 @@ s32 ixgbe_reset_phy_generic(struct ixgbe_hw *hw)
172 (IXGBE_ERR_OVERTEMP == hw->phy.ops.check_overtemp(hw))) 199 (IXGBE_ERR_OVERTEMP == hw->phy.ops.check_overtemp(hw)))
173 goto out; 200 goto out;
174 201
202 /* Blocked by MNG FW so bail */
203 if (ixgbe_check_reset_blocked(hw))
204 goto out;
205
175 /* 206 /*
176 * Perform soft PHY reset to the PHY_XS. 207 * Perform soft PHY reset to the PHY_XS.
177 * This will cause a soft reset to the PHY 208 * This will cause a soft reset to the PHY
@@ -476,6 +507,10 @@ s32 ixgbe_setup_phy_link_generic(struct ixgbe_hw *hw)
476 autoneg_reg); 507 autoneg_reg);
477 } 508 }
478 509
510 /* Blocked by MNG FW so don't reset PHY */
511 if (ixgbe_check_reset_blocked(hw))
512 return status;
513
479 /* Restart PHY autonegotiation and wait for completion */ 514 /* Restart PHY autonegotiation and wait for completion */
480 hw->phy.ops.read_reg(hw, MDIO_CTRL1, 515 hw->phy.ops.read_reg(hw, MDIO_CTRL1,
481 MDIO_MMD_AN, &autoneg_reg); 516 MDIO_MMD_AN, &autoneg_reg);
@@ -682,6 +717,10 @@ s32 ixgbe_setup_phy_link_tnx(struct ixgbe_hw *hw)
682 autoneg_reg); 717 autoneg_reg);
683 } 718 }
684 719
720 /* Blocked by MNG FW so don't reset PHY */
721 if (ixgbe_check_reset_blocked(hw))
722 return status;
723
685 /* Restart PHY autonegotiation and wait for completion */ 724 /* Restart PHY autonegotiation and wait for completion */
686 hw->phy.ops.read_reg(hw, MDIO_CTRL1, 725 hw->phy.ops.read_reg(hw, MDIO_CTRL1,
687 MDIO_MMD_AN, &autoneg_reg); 726 MDIO_MMD_AN, &autoneg_reg);
@@ -759,6 +798,10 @@ s32 ixgbe_reset_phy_nl(struct ixgbe_hw *hw)
759 s32 ret_val = 0; 798 s32 ret_val = 0;
760 u32 i; 799 u32 i;
761 800
801 /* Blocked by MNG FW so bail */
802 if (ixgbe_check_reset_blocked(hw))
803 goto out;
804
762 hw->phy.ops.read_reg(hw, MDIO_CTRL1, MDIO_MMD_PHYXS, &phy_data); 805 hw->phy.ops.read_reg(hw, MDIO_CTRL1, MDIO_MMD_PHYXS, &phy_data);
763 806
764 /* reset the PHY and poll for completion */ 807 /* reset the PHY and poll for completion */
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_phy.h b/drivers/net/ethernet/intel/ixgbe/ixgbe_phy.h
index fffcbdd2bf0e..4a456c974ef2 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_phy.h
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_phy.h
@@ -1,7 +1,7 @@
1/******************************************************************************* 1/*******************************************************************************
2 2
3 Intel 10 Gigabit PCI Express Linux driver 3 Intel 10 Gigabit PCI Express Linux driver
4 Copyright(c) 1999 - 2013 Intel Corporation. 4 Copyright(c) 1999 - 2014 Intel Corporation.
5 5
6 This program is free software; you can redistribute it and/or modify it 6 This program is free software; you can redistribute it and/or modify it
7 under the terms and conditions of the GNU General Public License, 7 under the terms and conditions of the GNU General Public License,
@@ -20,6 +20,7 @@
20 the file called "COPYING". 20 the file called "COPYING".
21 21
22 Contact Information: 22 Contact Information:
23 Linux NICS <linux.nics@intel.com>
23 e1000-devel Mailing List <e1000-devel@lists.sourceforge.net> 24 e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
24 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 25 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
25 26
@@ -65,9 +66,6 @@
65#define IXGBE_SFF_1GBASET_CAPABLE 0x8 66#define IXGBE_SFF_1GBASET_CAPABLE 0x8
66#define IXGBE_SFF_10GBASESR_CAPABLE 0x10 67#define IXGBE_SFF_10GBASESR_CAPABLE 0x10
67#define IXGBE_SFF_10GBASELR_CAPABLE 0x20 68#define IXGBE_SFF_10GBASELR_CAPABLE 0x20
68#define IXGBE_SFF_SOFT_RS_SELECT_MASK 0x8
69#define IXGBE_SFF_SOFT_RS_SELECT_10G 0x8
70#define IXGBE_SFF_SOFT_RS_SELECT_1G 0x0
71#define IXGBE_SFF_ADDRESSING_MODE 0x4 69#define IXGBE_SFF_ADDRESSING_MODE 0x4
72#define IXGBE_SFF_QSFP_DA_ACTIVE_CABLE 0x1 70#define IXGBE_SFF_QSFP_DA_ACTIVE_CABLE 0x1
73#define IXGBE_SFF_QSFP_DA_PASSIVE_CABLE 0x8 71#define IXGBE_SFF_QSFP_DA_PASSIVE_CABLE 0x8
@@ -79,7 +77,6 @@
79#define IXGBE_I2C_EEPROM_STATUS_PASS 0x1 77#define IXGBE_I2C_EEPROM_STATUS_PASS 0x1
80#define IXGBE_I2C_EEPROM_STATUS_FAIL 0x2 78#define IXGBE_I2C_EEPROM_STATUS_FAIL 0x2
81#define IXGBE_I2C_EEPROM_STATUS_IN_PROGRESS 0x3 79#define IXGBE_I2C_EEPROM_STATUS_IN_PROGRESS 0x3
82
83/* Flow control defines */ 80/* Flow control defines */
84#define IXGBE_TAF_SYM_PAUSE 0x400 81#define IXGBE_TAF_SYM_PAUSE 0x400
85#define IXGBE_TAF_ASM_PAUSE 0x800 82#define IXGBE_TAF_ASM_PAUSE 0x800
@@ -131,6 +128,7 @@ s32 ixgbe_setup_phy_link_speed_generic(struct ixgbe_hw *hw,
131s32 ixgbe_get_copper_link_capabilities_generic(struct ixgbe_hw *hw, 128s32 ixgbe_get_copper_link_capabilities_generic(struct ixgbe_hw *hw,
132 ixgbe_link_speed *speed, 129 ixgbe_link_speed *speed,
133 bool *autoneg); 130 bool *autoneg);
131s32 ixgbe_check_reset_blocked(struct ixgbe_hw *hw);
134 132
135/* PHY specific */ 133/* PHY specific */
136s32 ixgbe_check_phy_link_tnx(struct ixgbe_hw *hw, 134s32 ixgbe_check_phy_link_tnx(struct ixgbe_hw *hw,
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
index 5184e2a1a7d8..44ac9aef6a8d 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
@@ -20,6 +20,7 @@
20 the file called "COPYING". 20 the file called "COPYING".
21 21
22 Contact Information: 22 Contact Information:
23 Linux NICS <linux.nics@intel.com>
23 e1000-devel Mailing List <e1000-devel@lists.sourceforge.net> 24 e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
24 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 25 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
25 26
@@ -576,14 +577,21 @@ void __ixgbe_ptp_rx_hwtstamp(struct ixgbe_q_vector *q_vector,
576 shhwtstamps->hwtstamp = ns_to_ktime(ns); 577 shhwtstamps->hwtstamp = ns_to_ktime(ns);
577} 578}
578 579
580int ixgbe_ptp_get_ts_config(struct ixgbe_adapter *adapter, struct ifreq *ifr)
581{
582 struct hwtstamp_config *config = &adapter->tstamp_config;
583
584 return copy_to_user(ifr->ifr_data, config,
585 sizeof(*config)) ? -EFAULT : 0;
586}
587
579/** 588/**
580 * ixgbe_ptp_hwtstamp_ioctl - control hardware time stamping 589 * ixgbe_ptp_set_ts_config - control hardware time stamping
581 * @adapter: pointer to adapter struct 590 * @adapter: pointer to adapter struct
582 * @ifreq: ioctl data 591 * @ifreq: ioctl data
583 * @cmd: particular ioctl requested
584 * 592 *
585 * Outgoing time stamping can be enabled and disabled. Play nice and 593 * Outgoing time stamping can be enabled and disabled. Play nice and
586 * disable it when requested, although it shouldn't case any overhead 594 * disable it when requested, although it shouldn't cause any overhead
587 * when no packet needs it. At most one packet in the queue may be 595 * when no packet needs it. At most one packet in the queue may be
588 * marked for time stamping, otherwise it would be impossible to tell 596 * marked for time stamping, otherwise it would be impossible to tell
589 * for sure to which packet the hardware time stamp belongs. 597 * for sure to which packet the hardware time stamp belongs.
@@ -599,8 +607,7 @@ void __ixgbe_ptp_rx_hwtstamp(struct ixgbe_q_vector *q_vector,
599 * Event mode. This more accurately tells the user what the hardware is going 607 * Event mode. This more accurately tells the user what the hardware is going
600 * to do anyways. 608 * to do anyways.
601 */ 609 */
602int ixgbe_ptp_hwtstamp_ioctl(struct ixgbe_adapter *adapter, 610int ixgbe_ptp_set_ts_config(struct ixgbe_adapter *adapter, struct ifreq *ifr)
603 struct ifreq *ifr, int cmd)
604{ 611{
605 struct ixgbe_hw *hw = &adapter->hw; 612 struct ixgbe_hw *hw = &adapter->hw;
606 struct hwtstamp_config config; 613 struct hwtstamp_config config;
@@ -702,6 +709,10 @@ int ixgbe_ptp_hwtstamp_ioctl(struct ixgbe_adapter *adapter,
702 regval = IXGBE_READ_REG(hw, IXGBE_TXSTMPH); 709 regval = IXGBE_READ_REG(hw, IXGBE_TXSTMPH);
703 regval = IXGBE_READ_REG(hw, IXGBE_RXSTMPH); 710 regval = IXGBE_READ_REG(hw, IXGBE_RXSTMPH);
704 711
712 /* save these settings for future reference */
713 memcpy(&adapter->tstamp_config, &config,
714 sizeof(adapter->tstamp_config));
715
705 return copy_to_user(ifr->ifr_data, &config, sizeof(config)) ? 716 return copy_to_user(ifr->ifr_data, &config, sizeof(config)) ?
706 -EFAULT : 0; 717 -EFAULT : 0;
707} 718}
@@ -809,6 +820,9 @@ void ixgbe_ptp_reset(struct ixgbe_adapter *adapter)
809 IXGBE_WRITE_REG(hw, IXGBE_SYSTIMH, 0x00000000); 820 IXGBE_WRITE_REG(hw, IXGBE_SYSTIMH, 0x00000000);
810 IXGBE_WRITE_FLUSH(hw); 821 IXGBE_WRITE_FLUSH(hw);
811 822
823 /* Reset the saved tstamp_config */
824 memset(&adapter->tstamp_config, 0, sizeof(adapter->tstamp_config));
825
812 ixgbe_ptp_start_cyclecounter(adapter); 826 ixgbe_ptp_start_cyclecounter(adapter);
813 827
814 spin_lock_irqsave(&adapter->tmreg_lock, flags); 828 spin_lock_irqsave(&adapter->tmreg_lock, flags);
@@ -840,7 +854,9 @@ void ixgbe_ptp_init(struct ixgbe_adapter *adapter)
840 854
841 switch (adapter->hw.mac.type) { 855 switch (adapter->hw.mac.type) {
842 case ixgbe_mac_X540: 856 case ixgbe_mac_X540:
843 snprintf(adapter->ptp_caps.name, 16, "%s", netdev->name); 857 snprintf(adapter->ptp_caps.name,
858 sizeof(adapter->ptp_caps.name),
859 "%s", netdev->name);
844 adapter->ptp_caps.owner = THIS_MODULE; 860 adapter->ptp_caps.owner = THIS_MODULE;
845 adapter->ptp_caps.max_adj = 250000000; 861 adapter->ptp_caps.max_adj = 250000000;
846 adapter->ptp_caps.n_alarm = 0; 862 adapter->ptp_caps.n_alarm = 0;
@@ -854,7 +870,9 @@ void ixgbe_ptp_init(struct ixgbe_adapter *adapter)
854 adapter->ptp_caps.enable = ixgbe_ptp_enable; 870 adapter->ptp_caps.enable = ixgbe_ptp_enable;
855 break; 871 break;
856 case ixgbe_mac_82599EB: 872 case ixgbe_mac_82599EB:
857 snprintf(adapter->ptp_caps.name, 16, "%s", netdev->name); 873 snprintf(adapter->ptp_caps.name,
874 sizeof(adapter->ptp_caps.name),
875 "%s", netdev->name);
858 adapter->ptp_caps.owner = THIS_MODULE; 876 adapter->ptp_caps.owner = THIS_MODULE;
859 adapter->ptp_caps.max_adj = 250000000; 877 adapter->ptp_caps.max_adj = 250000000;
860 adapter->ptp_caps.n_alarm = 0; 878 adapter->ptp_caps.n_alarm = 0;
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c
index dff0977876f7..e6c68d396c99 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c
@@ -20,6 +20,7 @@
20 the file called "COPYING". 20 the file called "COPYING".
21 21
22 Contact Information: 22 Contact Information:
23 Linux NICS <linux.nics@intel.com>
23 e1000-devel Mailing List <e1000-devel@lists.sourceforge.net> 24 e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
24 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 25 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
25 26
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.h b/drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.h
index 8bd29190514e..139eaddfb2ed 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.h
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.h
@@ -20,6 +20,7 @@
20 the file called "COPYING". 20 the file called "COPYING".
21 21
22 Contact Information: 22 Contact Information:
23 Linux NICS <linux.nics@intel.com>
23 e1000-devel Mailing List <e1000-devel@lists.sourceforge.net> 24 e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
24 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 25 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
25 26
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_sysfs.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_sysfs.c
index e74ae3682733..ef6df3d6437e 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_sysfs.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_sysfs.c
@@ -20,6 +20,7 @@
20 the file called "COPYING". 20 the file called "COPYING".
21 21
22 Contact Information: 22 Contact Information:
23 Linux NICS <linux.nics@intel.com>
23 e1000-devel Mailing List <e1000-devel@lists.sourceforge.net> 24 e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
24 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 25 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
25 26
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_type.h b/drivers/net/ethernet/intel/ixgbe/ixgbe_type.h
index 0d39cfc4a3bf..8a6ff2423f07 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_type.h
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_type.h
@@ -1,7 +1,7 @@
1/******************************************************************************* 1/*******************************************************************************
2 2
3 Intel 10 Gigabit PCI Express Linux driver 3 Intel 10 Gigabit PCI Express Linux driver
4 Copyright(c) 1999 - 2013 Intel Corporation. 4 Copyright(c) 1999 - 2014 Intel Corporation.
5 5
6 This program is free software; you can redistribute it and/or modify it 6 This program is free software; you can redistribute it and/or modify it
7 under the terms and conditions of the GNU General Public License, 7 under the terms and conditions of the GNU General Public License,
@@ -20,6 +20,7 @@
20 the file called "COPYING". 20 the file called "COPYING".
21 21
22 Contact Information: 22 Contact Information:
23 Linux NICS <linux.nics@intel.com>
23 e1000-devel Mailing List <e1000-devel@lists.sourceforge.net> 24 e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
24 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 25 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
25 26
@@ -54,6 +55,7 @@
54#define IXGBE_DEV_ID_82599_BACKPLANE_FCOE 0x152a 55#define IXGBE_DEV_ID_82599_BACKPLANE_FCOE 0x152a
55#define IXGBE_DEV_ID_82599_SFP_FCOE 0x1529 56#define IXGBE_DEV_ID_82599_SFP_FCOE 0x1529
56#define IXGBE_SUBDEV_ID_82599_SFP 0x11A9 57#define IXGBE_SUBDEV_ID_82599_SFP 0x11A9
58#define IXGBE_SUBDEV_ID_82599_SFP_WOL0 0x1071
57#define IXGBE_SUBDEV_ID_82599_RNDC 0x1F72 59#define IXGBE_SUBDEV_ID_82599_RNDC 0x1F72
58#define IXGBE_SUBDEV_ID_82599_560FLR 0x17D0 60#define IXGBE_SUBDEV_ID_82599_560FLR 0x17D0
59#define IXGBE_SUBDEV_ID_82599_SP_560FLR 0x211B 61#define IXGBE_SUBDEV_ID_82599_SP_560FLR 0x211B
@@ -1609,6 +1611,9 @@ enum {
1609#define IXGBE_MACC_FS 0x00040000 1611#define IXGBE_MACC_FS 0x00040000
1610#define IXGBE_MAC_RX2TX_LPBK 0x00000002 1612#define IXGBE_MAC_RX2TX_LPBK 0x00000002
1611 1613
1614/* Veto Bit definiton */
1615#define IXGBE_MMNGC_MNG_VETO 0x00000001
1616
1612/* LINKS Bit Masks */ 1617/* LINKS Bit Masks */
1613#define IXGBE_LINKS_KX_AN_COMP 0x80000000 1618#define IXGBE_LINKS_KX_AN_COMP 0x80000000
1614#define IXGBE_LINKS_UP 0x40000000 1619#define IXGBE_LINKS_UP 0x40000000
@@ -1788,6 +1793,9 @@ enum {
1788#define IXGBE_EEPROM_RD_BUFFER_MAX_COUNT 512 /* EEPROM words # read in burst */ 1793#define IXGBE_EEPROM_RD_BUFFER_MAX_COUNT 512 /* EEPROM words # read in burst */
1789#define IXGBE_EEPROM_WR_BUFFER_MAX_COUNT 256 /* EEPROM words # wr in burst */ 1794#define IXGBE_EEPROM_WR_BUFFER_MAX_COUNT 256 /* EEPROM words # wr in burst */
1790 1795
1796#define IXGBE_EEPROM_CTRL_2 1 /* EEPROM CTRL word 2 */
1797#define IXGBE_EEPROM_CCD_BIT 2 /* EEPROM Core Clock Disable bit */
1798
1791#ifndef IXGBE_EEPROM_GRANT_ATTEMPTS 1799#ifndef IXGBE_EEPROM_GRANT_ATTEMPTS
1792#define IXGBE_EEPROM_GRANT_ATTEMPTS 1000 /* EEPROM # attempts to gain grant */ 1800#define IXGBE_EEPROM_GRANT_ATTEMPTS 1000 /* EEPROM # attempts to gain grant */
1793#endif 1801#endif
@@ -1853,8 +1861,19 @@ enum {
1853#define IXGBE_PCI_HEADER_TYPE_MULTIFUNC 0x80 1861#define IXGBE_PCI_HEADER_TYPE_MULTIFUNC 0x80
1854#define IXGBE_PCI_DEVICE_CONTROL2_16ms 0x0005 1862#define IXGBE_PCI_DEVICE_CONTROL2_16ms 0x0005
1855 1863
1864#define IXGBE_PCIDEVCTRL2_TIMEO_MASK 0xf
1865#define IXGBE_PCIDEVCTRL2_16_32ms_def 0x0
1866#define IXGBE_PCIDEVCTRL2_50_100us 0x1
1867#define IXGBE_PCIDEVCTRL2_1_2ms 0x2
1868#define IXGBE_PCIDEVCTRL2_16_32ms 0x5
1869#define IXGBE_PCIDEVCTRL2_65_130ms 0x6
1870#define IXGBE_PCIDEVCTRL2_260_520ms 0x9
1871#define IXGBE_PCIDEVCTRL2_1_2s 0xa
1872#define IXGBE_PCIDEVCTRL2_4_8s 0xd
1873#define IXGBE_PCIDEVCTRL2_17_34s 0xe
1874
1856/* Number of 100 microseconds we wait for PCI Express master disable */ 1875/* Number of 100 microseconds we wait for PCI Express master disable */
1857#define IXGBE_PCI_MASTER_DISABLE_TIMEOUT 800 1876#define IXGBE_PCI_MASTER_DISABLE_TIMEOUT 800
1858 1877
1859/* RAH */ 1878/* RAH */
1860#define IXGBE_RAH_VIND_MASK 0x003C0000 1879#define IXGBE_RAH_VIND_MASK 0x003C0000
@@ -2645,7 +2664,6 @@ enum ixgbe_sfp_type {
2645enum ixgbe_media_type { 2664enum ixgbe_media_type {
2646 ixgbe_media_type_unknown = 0, 2665 ixgbe_media_type_unknown = 0,
2647 ixgbe_media_type_fiber, 2666 ixgbe_media_type_fiber,
2648 ixgbe_media_type_fiber_fixed,
2649 ixgbe_media_type_fiber_qsfp, 2667 ixgbe_media_type_fiber_qsfp,
2650 ixgbe_media_type_fiber_lco, 2668 ixgbe_media_type_fiber_lco,
2651 ixgbe_media_type_copper, 2669 ixgbe_media_type_copper,
@@ -2858,6 +2876,8 @@ struct ixgbe_mac_operations {
2858 s32 (*enable_rx_dma)(struct ixgbe_hw *, u32); 2876 s32 (*enable_rx_dma)(struct ixgbe_hw *, u32);
2859 s32 (*acquire_swfw_sync)(struct ixgbe_hw *, u16); 2877 s32 (*acquire_swfw_sync)(struct ixgbe_hw *, u16);
2860 void (*release_swfw_sync)(struct ixgbe_hw *, u16); 2878 void (*release_swfw_sync)(struct ixgbe_hw *, u16);
2879 s32 (*prot_autoc_read)(struct ixgbe_hw *, bool *, u32 *);
2880 s32 (*prot_autoc_write)(struct ixgbe_hw *, u32, bool);
2861 2881
2862 /* Link */ 2882 /* Link */
2863 void (*disable_tx_laser)(struct ixgbe_hw *); 2883 void (*disable_tx_laser)(struct ixgbe_hw *);
@@ -2901,7 +2921,6 @@ struct ixgbe_mac_operations {
2901 s32 (*set_fw_drv_ver)(struct ixgbe_hw *, u8, u8, u8, u8); 2921 s32 (*set_fw_drv_ver)(struct ixgbe_hw *, u8, u8, u8, u8);
2902 s32 (*get_thermal_sensor_data)(struct ixgbe_hw *); 2922 s32 (*get_thermal_sensor_data)(struct ixgbe_hw *);
2903 s32 (*init_thermal_sensor_thresh)(struct ixgbe_hw *hw); 2923 s32 (*init_thermal_sensor_thresh)(struct ixgbe_hw *hw);
2904 bool (*mng_fw_enabled)(struct ixgbe_hw *hw);
2905}; 2924};
2906 2925
2907struct ixgbe_phy_operations { 2926struct ixgbe_phy_operations {
@@ -2957,7 +2976,6 @@ struct ixgbe_mac_info {
2957 u32 max_tx_queues; 2976 u32 max_tx_queues;
2958 u32 max_rx_queues; 2977 u32 max_rx_queues;
2959 u32 orig_autoc; 2978 u32 orig_autoc;
2960 u32 cached_autoc;
2961 u32 orig_autoc2; 2979 u32 orig_autoc2;
2962 bool orig_link_settings_stored; 2980 bool orig_link_settings_stored;
2963 bool autotry_restart; 2981 bool autotry_restart;
@@ -3033,7 +3051,6 @@ struct ixgbe_hw {
3033 bool adapter_stopped; 3051 bool adapter_stopped;
3034 bool force_full_reset; 3052 bool force_full_reset;
3035 bool allow_unsupported_sfp; 3053 bool allow_unsupported_sfp;
3036 bool mng_fw_enabled;
3037 bool wol_enabled; 3054 bool wol_enabled;
3038}; 3055};
3039 3056
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_x540.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_x540.c
index 24b80a6cfca4..188a5974b85c 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_x540.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_x540.c
@@ -20,6 +20,7 @@
20 the file called "COPYING". 20 the file called "COPYING".
21 21
22 Contact Information: 22 Contact Information:
23 Linux NICS <linux.nics@intel.com>
23 e1000-devel Mailing List <e1000-devel@lists.sourceforge.net> 24 e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
24 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 25 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
25 26
@@ -61,6 +62,7 @@ static s32 ixgbe_get_invariants_X540(struct ixgbe_hw *hw)
61 mac->mcft_size = IXGBE_X540_MC_TBL_SIZE; 62 mac->mcft_size = IXGBE_X540_MC_TBL_SIZE;
62 mac->vft_size = IXGBE_X540_VFT_TBL_SIZE; 63 mac->vft_size = IXGBE_X540_VFT_TBL_SIZE;
63 mac->num_rar_entries = IXGBE_X540_RAR_ENTRIES; 64 mac->num_rar_entries = IXGBE_X540_RAR_ENTRIES;
65 mac->rx_pb_size = IXGBE_X540_RX_PB_SIZE;
64 mac->max_rx_queues = IXGBE_X540_MAX_RX_QUEUES; 66 mac->max_rx_queues = IXGBE_X540_MAX_RX_QUEUES;
65 mac->max_tx_queues = IXGBE_X540_MAX_TX_QUEUES; 67 mac->max_tx_queues = IXGBE_X540_MAX_TX_QUEUES;
66 mac->max_msix_vectors = ixgbe_get_pcie_msix_count_generic(hw); 68 mac->max_msix_vectors = ixgbe_get_pcie_msix_count_generic(hw);
@@ -187,7 +189,6 @@ static s32 ixgbe_start_hw_X540(struct ixgbe_hw *hw)
187 goto out; 189 goto out;
188 190
189 ret_val = ixgbe_start_hw_gen2(hw); 191 ret_val = ixgbe_start_hw_gen2(hw);
190 hw->mac.rx_pb_size = IXGBE_X540_RX_PB_SIZE;
191out: 192out:
192 return ret_val; 193 return ret_val;
193} 194}
@@ -854,7 +855,8 @@ static struct ixgbe_mac_operations mac_ops_X540 = {
854 .enable_rx_buff = &ixgbe_enable_rx_buff_generic, 855 .enable_rx_buff = &ixgbe_enable_rx_buff_generic,
855 .get_thermal_sensor_data = NULL, 856 .get_thermal_sensor_data = NULL,
856 .init_thermal_sensor_thresh = NULL, 857 .init_thermal_sensor_thresh = NULL,
857 .mng_fw_enabled = NULL, 858 .prot_autoc_read = &prot_autoc_read_generic,
859 .prot_autoc_write = &prot_autoc_write_generic,
858}; 860};
859 861
860static struct ixgbe_eeprom_operations eeprom_ops_X540 = { 862static struct ixgbe_eeprom_operations eeprom_ops_X540 = {
diff --git a/drivers/net/ethernet/intel/ixgbevf/ethtool.c b/drivers/net/ethernet/intel/ixgbevf/ethtool.c
index f68b78c732a8..b2d002394e5d 100644
--- a/drivers/net/ethernet/intel/ixgbevf/ethtool.c
+++ b/drivers/net/ethernet/intel/ixgbevf/ethtool.c
@@ -1,7 +1,7 @@
1/******************************************************************************* 1/*******************************************************************************
2 2
3 Intel 82599 Virtual Function driver 3 Intel 82599 Virtual Function driver
4 Copyright(c) 1999 - 2012 Intel Corporation. 4 Copyright(c) 1999 - 2014 Intel Corporation.
5 5
6 This program is free software; you can redistribute it and/or modify it 6 This program is free software; you can redistribute it and/or modify it
7 under the terms and conditions of the GNU General Public License, 7 under the terms and conditions of the GNU General Public License,
@@ -530,41 +530,55 @@ static const u32 register_test_patterns[] = {
530 0x5A5A5A5A, 0xA5A5A5A5, 0x00000000, 0xFFFFFFFF 530 0x5A5A5A5A, 0xA5A5A5A5, 0x00000000, 0xFFFFFFFF
531}; 531};
532 532
533#define REG_PATTERN_TEST(R, M, W) \ 533static bool reg_pattern_test(struct ixgbevf_adapter *adapter, u64 *data,
534{ \ 534 int reg, u32 mask, u32 write)
535 u32 pat, val, before; \ 535{
536 for (pat = 0; pat < ARRAY_SIZE(register_test_patterns); pat++) { \ 536 u32 pat, val, before;
537 before = readl(adapter->hw.hw_addr + R); \ 537
538 writel((register_test_patterns[pat] & W), \ 538 if (IXGBE_REMOVED(adapter->hw.hw_addr)) {
539 (adapter->hw.hw_addr + R)); \ 539 *data = 1;
540 val = readl(adapter->hw.hw_addr + R); \ 540 return true;
541 if (val != (register_test_patterns[pat] & W & M)) { \ 541 }
542 hw_dbg(&adapter->hw, \ 542 for (pat = 0; pat < ARRAY_SIZE(register_test_patterns); pat++) {
543 "pattern test reg %04X failed: got " \ 543 before = ixgbe_read_reg(&adapter->hw, reg);
544 "0x%08X expected 0x%08X\n", \ 544 ixgbe_write_reg(&adapter->hw, reg,
545 R, val, (register_test_patterns[pat] & W & M)); \ 545 register_test_patterns[pat] & write);
546 *data = R; \ 546 val = ixgbe_read_reg(&adapter->hw, reg);
547 writel(before, adapter->hw.hw_addr + R); \ 547 if (val != (register_test_patterns[pat] & write & mask)) {
548 return 1; \ 548 hw_dbg(&adapter->hw,
549 } \ 549 "pattern test reg %04X failed: got 0x%08X expected 0x%08X\n",
550 writel(before, adapter->hw.hw_addr + R); \ 550 reg, val,
551 } \ 551 register_test_patterns[pat] & write & mask);
552 *data = reg;
553 ixgbe_write_reg(&adapter->hw, reg, before);
554 return true;
555 }
556 ixgbe_write_reg(&adapter->hw, reg, before);
557 }
558 return false;
552} 559}
553 560
554#define REG_SET_AND_CHECK(R, M, W) \ 561static bool reg_set_and_check(struct ixgbevf_adapter *adapter, u64 *data,
555{ \ 562 int reg, u32 mask, u32 write)
556 u32 val, before; \ 563{
557 before = readl(adapter->hw.hw_addr + R); \ 564 u32 val, before;
558 writel((W & M), (adapter->hw.hw_addr + R)); \ 565
559 val = readl(adapter->hw.hw_addr + R); \ 566 if (IXGBE_REMOVED(adapter->hw.hw_addr)) {
560 if ((W & M) != (val & M)) { \ 567 *data = 1;
561 pr_err("set/check reg %04X test failed: got 0x%08X expected " \ 568 return true;
562 "0x%08X\n", R, (val & M), (W & M)); \ 569 }
563 *data = R; \ 570 before = ixgbe_read_reg(&adapter->hw, reg);
564 writel(before, (adapter->hw.hw_addr + R)); \ 571 ixgbe_write_reg(&adapter->hw, reg, write & mask);
565 return 1; \ 572 val = ixgbe_read_reg(&adapter->hw, reg);
566 } \ 573 if ((write & mask) != (val & mask)) {
567 writel(before, (adapter->hw.hw_addr + R)); \ 574 pr_err("set/check reg %04X test failed: got 0x%08X expected 0x%08X\n",
575 reg, (val & mask), write & mask);
576 *data = reg;
577 ixgbe_write_reg(&adapter->hw, reg, before);
578 return true;
579 }
580 ixgbe_write_reg(&adapter->hw, reg, before);
581 return false;
568} 582}
569 583
570static int ixgbevf_reg_test(struct ixgbevf_adapter *adapter, u64 *data) 584static int ixgbevf_reg_test(struct ixgbevf_adapter *adapter, u64 *data)
@@ -572,6 +586,12 @@ static int ixgbevf_reg_test(struct ixgbevf_adapter *adapter, u64 *data)
572 const struct ixgbevf_reg_test *test; 586 const struct ixgbevf_reg_test *test;
573 u32 i; 587 u32 i;
574 588
589 if (IXGBE_REMOVED(adapter->hw.hw_addr)) {
590 dev_err(&adapter->pdev->dev,
591 "Adapter removed - register test blocked\n");
592 *data = 1;
593 return 1;
594 }
575 test = reg_test_vf; 595 test = reg_test_vf;
576 596
577 /* 597 /*
@@ -580,38 +600,47 @@ static int ixgbevf_reg_test(struct ixgbevf_adapter *adapter, u64 *data)
580 */ 600 */
581 while (test->reg) { 601 while (test->reg) {
582 for (i = 0; i < test->array_len; i++) { 602 for (i = 0; i < test->array_len; i++) {
603 bool b = false;
604
583 switch (test->test_type) { 605 switch (test->test_type) {
584 case PATTERN_TEST: 606 case PATTERN_TEST:
585 REG_PATTERN_TEST(test->reg + (i * 0x40), 607 b = reg_pattern_test(adapter, data,
586 test->mask, 608 test->reg + (i * 0x40),
587 test->write); 609 test->mask,
610 test->write);
588 break; 611 break;
589 case SET_READ_TEST: 612 case SET_READ_TEST:
590 REG_SET_AND_CHECK(test->reg + (i * 0x40), 613 b = reg_set_and_check(adapter, data,
591 test->mask, 614 test->reg + (i * 0x40),
592 test->write); 615 test->mask,
616 test->write);
593 break; 617 break;
594 case WRITE_NO_TEST: 618 case WRITE_NO_TEST:
595 writel(test->write, 619 ixgbe_write_reg(&adapter->hw,
596 (adapter->hw.hw_addr + test->reg) 620 test->reg + (i * 0x40),
597 + (i * 0x40)); 621 test->write);
598 break; 622 break;
599 case TABLE32_TEST: 623 case TABLE32_TEST:
600 REG_PATTERN_TEST(test->reg + (i * 4), 624 b = reg_pattern_test(adapter, data,
601 test->mask, 625 test->reg + (i * 4),
602 test->write); 626 test->mask,
627 test->write);
603 break; 628 break;
604 case TABLE64_TEST_LO: 629 case TABLE64_TEST_LO:
605 REG_PATTERN_TEST(test->reg + (i * 8), 630 b = reg_pattern_test(adapter, data,
606 test->mask, 631 test->reg + (i * 8),
607 test->write); 632 test->mask,
633 test->write);
608 break; 634 break;
609 case TABLE64_TEST_HI: 635 case TABLE64_TEST_HI:
610 REG_PATTERN_TEST((test->reg + 4) + (i * 8), 636 b = reg_pattern_test(adapter, data,
611 test->mask, 637 test->reg + 4 + (i * 8),
612 test->write); 638 test->mask,
639 test->write);
613 break; 640 break;
614 } 641 }
642 if (b)
643 return 1;
615 } 644 }
616 test++; 645 test++;
617 } 646 }
@@ -626,6 +655,14 @@ static void ixgbevf_diag_test(struct net_device *netdev,
626 struct ixgbevf_adapter *adapter = netdev_priv(netdev); 655 struct ixgbevf_adapter *adapter = netdev_priv(netdev);
627 bool if_running = netif_running(netdev); 656 bool if_running = netif_running(netdev);
628 657
658 if (IXGBE_REMOVED(adapter->hw.hw_addr)) {
659 dev_err(&adapter->pdev->dev,
660 "Adapter removed - test blocked\n");
661 data[0] = 1;
662 data[1] = 1;
663 eth_test->flags |= ETH_TEST_FL_FAILED;
664 return;
665 }
629 set_bit(__IXGBEVF_TESTING, &adapter->state); 666 set_bit(__IXGBEVF_TESTING, &adapter->state);
630 if (eth_test->flags == ETH_TEST_FL_OFFLINE) { 667 if (eth_test->flags == ETH_TEST_FL_OFFLINE) {
631 /* Offline tests */ 668 /* Offline tests */
diff --git a/drivers/net/ethernet/intel/ixgbevf/ixgbevf.h b/drivers/net/ethernet/intel/ixgbevf/ixgbevf.h
index 54829326bb09..a08bd7c46766 100644
--- a/drivers/net/ethernet/intel/ixgbevf/ixgbevf.h
+++ b/drivers/net/ethernet/intel/ixgbevf/ixgbevf.h
@@ -1,7 +1,7 @@
1/******************************************************************************* 1/*******************************************************************************
2 2
3 Intel 82599 Virtual Function driver 3 Intel 82599 Virtual Function driver
4 Copyright(c) 1999 - 2012 Intel Corporation. 4 Copyright(c) 1999 - 2014 Intel Corporation.
5 5
6 This program is free software; you can redistribute it and/or modify it 6 This program is free software; you can redistribute it and/or modify it
7 under the terms and conditions of the GNU General Public License, 7 under the terms and conditions of the GNU General Public License,
@@ -315,6 +315,11 @@ static inline u16 ixgbevf_desc_unused(struct ixgbevf_ring *ring)
315 return ((ntc > ntu) ? 0 : ring->count) + ntc - ntu - 1; 315 return ((ntc > ntu) ? 0 : ring->count) + ntc - ntu - 1;
316} 316}
317 317
318static inline void ixgbevf_write_tail(struct ixgbevf_ring *ring, u32 value)
319{
320 writel(value, ring->tail);
321}
322
318#define IXGBEVF_RX_DESC(R, i) \ 323#define IXGBEVF_RX_DESC(R, i) \
319 (&(((union ixgbe_adv_rx_desc *)((R)->desc))[i])) 324 (&(((union ixgbe_adv_rx_desc *)((R)->desc))[i]))
320#define IXGBEVF_TX_DESC(R, i) \ 325#define IXGBEVF_TX_DESC(R, i) \
@@ -401,6 +406,7 @@ struct ixgbevf_adapter {
401 u64 bp_tx_missed; 406 u64 bp_tx_missed;
402#endif 407#endif
403 408
409 u8 __iomem *io_addr; /* Mainly for iounmap use */
404 u32 link_speed; 410 u32 link_speed;
405 bool link_up; 411 bool link_up;
406 412
@@ -412,7 +418,8 @@ struct ixgbevf_adapter {
412enum ixbgevf_state_t { 418enum ixbgevf_state_t {
413 __IXGBEVF_TESTING, 419 __IXGBEVF_TESTING,
414 __IXGBEVF_RESETTING, 420 __IXGBEVF_RESETTING,
415 __IXGBEVF_DOWN 421 __IXGBEVF_DOWN,
422 __IXGBEVF_REMOVING,
416}; 423};
417 424
418struct ixgbevf_cb { 425struct ixgbevf_cb {
diff --git a/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c b/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c
index 9df28985eba7..a50e892a5d21 100644
--- a/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c
+++ b/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c
@@ -1,7 +1,7 @@
1/******************************************************************************* 1/*******************************************************************************
2 2
3 Intel 82599 Virtual Function driver 3 Intel 82599 Virtual Function driver
4 Copyright(c) 1999 - 2012 Intel Corporation. 4 Copyright(c) 1999 - 2014 Intel Corporation.
5 5
6 This program is free software; you can redistribute it and/or modify it 6 This program is free software; you can redistribute it and/or modify it
7 under the terms and conditions of the GNU General Public License, 7 under the terms and conditions of the GNU General Public License,
@@ -99,6 +99,49 @@ static void ixgbevf_queue_reset_subtask(struct ixgbevf_adapter *adapter);
99static void ixgbevf_set_itr(struct ixgbevf_q_vector *q_vector); 99static void ixgbevf_set_itr(struct ixgbevf_q_vector *q_vector);
100static void ixgbevf_free_all_rx_resources(struct ixgbevf_adapter *adapter); 100static void ixgbevf_free_all_rx_resources(struct ixgbevf_adapter *adapter);
101 101
102static void ixgbevf_remove_adapter(struct ixgbe_hw *hw)
103{
104 struct ixgbevf_adapter *adapter = hw->back;
105
106 if (!hw->hw_addr)
107 return;
108 hw->hw_addr = NULL;
109 dev_err(&adapter->pdev->dev, "Adapter removed\n");
110 schedule_work(&adapter->watchdog_task);
111}
112
113static void ixgbevf_check_remove(struct ixgbe_hw *hw, u32 reg)
114{
115 u32 value;
116
117 /* The following check not only optimizes a bit by not
118 * performing a read on the status register when the
119 * register just read was a status register read that
120 * returned IXGBE_FAILED_READ_REG. It also blocks any
121 * potential recursion.
122 */
123 if (reg == IXGBE_VFSTATUS) {
124 ixgbevf_remove_adapter(hw);
125 return;
126 }
127 value = ixgbe_read_reg(hw, IXGBE_VFSTATUS);
128 if (value == IXGBE_FAILED_READ_REG)
129 ixgbevf_remove_adapter(hw);
130}
131
132u32 ixgbe_read_reg(struct ixgbe_hw *hw, u32 reg)
133{
134 u8 __iomem *reg_addr = ACCESS_ONCE(hw->hw_addr);
135 u32 value;
136
137 if (IXGBE_REMOVED(reg_addr))
138 return IXGBE_FAILED_READ_REG;
139 value = readl(reg_addr + reg);
140 if (unlikely(value == IXGBE_FAILED_READ_REG))
141 ixgbevf_check_remove(hw, reg);
142 return value;
143}
144
102static inline void ixgbevf_release_rx_desc(struct ixgbevf_ring *rx_ring, 145static inline void ixgbevf_release_rx_desc(struct ixgbevf_ring *rx_ring,
103 u32 val) 146 u32 val)
104{ 147{
@@ -111,7 +154,7 @@ static inline void ixgbevf_release_rx_desc(struct ixgbevf_ring *rx_ring,
111 * such as IA-64). 154 * such as IA-64).
112 */ 155 */
113 wmb(); 156 wmb();
114 writel(val, rx_ring->tail); 157 ixgbevf_write_tail(rx_ring, val);
115} 158}
116 159
117/** 160/**
@@ -516,7 +559,8 @@ static int ixgbevf_clean_rx_irq(struct ixgbevf_q_vector *q_vector,
516 /* Workaround hardware that can't do proper VEPA multicast 559 /* Workaround hardware that can't do proper VEPA multicast
517 * source pruning. 560 * source pruning.
518 */ 561 */
519 if ((skb->pkt_type & (PACKET_BROADCAST | PACKET_MULTICAST)) && 562 if ((skb->pkt_type == PACKET_BROADCAST ||
563 skb->pkt_type == PACKET_MULTICAST) &&
520 ether_addr_equal(rx_ring->netdev->dev_addr, 564 ether_addr_equal(rx_ring->netdev->dev_addr,
521 eth_hdr(skb)->h_source)) { 565 eth_hdr(skb)->h_source)) {
522 dev_kfree_skb_irq(skb); 566 dev_kfree_skb_irq(skb);
@@ -607,7 +651,8 @@ static int ixgbevf_poll(struct napi_struct *napi, int budget)
607 napi_complete(napi); 651 napi_complete(napi);
608 if (adapter->rx_itr_setting & 1) 652 if (adapter->rx_itr_setting & 1)
609 ixgbevf_set_itr(q_vector); 653 ixgbevf_set_itr(q_vector);
610 if (!test_bit(__IXGBEVF_DOWN, &adapter->state)) 654 if (!test_bit(__IXGBEVF_DOWN, &adapter->state) &&
655 !test_bit(__IXGBEVF_REMOVING, &adapter->state))
611 ixgbevf_irq_enable_queues(adapter, 656 ixgbevf_irq_enable_queues(adapter,
612 1 << q_vector->v_idx); 657 1 << q_vector->v_idx);
613 658
@@ -832,7 +877,8 @@ static irqreturn_t ixgbevf_msix_other(int irq, void *data)
832 877
833 hw->mac.get_link_status = 1; 878 hw->mac.get_link_status = 1;
834 879
835 if (!test_bit(__IXGBEVF_DOWN, &adapter->state)) 880 if (!test_bit(__IXGBEVF_DOWN, &adapter->state) &&
881 !test_bit(__IXGBEVF_REMOVING, &adapter->state))
836 mod_timer(&adapter->watchdog_timer, jiffies); 882 mod_timer(&adapter->watchdog_timer, jiffies);
837 883
838 IXGBE_WRITE_REG(hw, IXGBE_VTEIMS, adapter->eims_other); 884 IXGBE_WRITE_REG(hw, IXGBE_VTEIMS, adapter->eims_other);
@@ -1136,7 +1182,7 @@ static void ixgbevf_configure_tx_ring(struct ixgbevf_adapter *adapter,
1136 /* reset head and tail pointers */ 1182 /* reset head and tail pointers */
1137 IXGBE_WRITE_REG(hw, IXGBE_VFTDH(reg_idx), 0); 1183 IXGBE_WRITE_REG(hw, IXGBE_VFTDH(reg_idx), 0);
1138 IXGBE_WRITE_REG(hw, IXGBE_VFTDT(reg_idx), 0); 1184 IXGBE_WRITE_REG(hw, IXGBE_VFTDT(reg_idx), 0);
1139 ring->tail = hw->hw_addr + IXGBE_VFTDT(reg_idx); 1185 ring->tail = adapter->io_addr + IXGBE_VFTDT(reg_idx);
1140 1186
1141 /* reset ntu and ntc to place SW in sync with hardwdare */ 1187 /* reset ntu and ntc to place SW in sync with hardwdare */
1142 ring->next_to_clean = 0; 1188 ring->next_to_clean = 0;
@@ -1256,6 +1302,8 @@ static void ixgbevf_disable_rx_queue(struct ixgbevf_adapter *adapter,
1256 u32 rxdctl; 1302 u32 rxdctl;
1257 u8 reg_idx = ring->reg_idx; 1303 u8 reg_idx = ring->reg_idx;
1258 1304
1305 if (IXGBE_REMOVED(hw->hw_addr))
1306 return;
1259 rxdctl = IXGBE_READ_REG(hw, IXGBE_VFRXDCTL(reg_idx)); 1307 rxdctl = IXGBE_READ_REG(hw, IXGBE_VFRXDCTL(reg_idx));
1260 rxdctl &= ~IXGBE_RXDCTL_ENABLE; 1308 rxdctl &= ~IXGBE_RXDCTL_ENABLE;
1261 1309
@@ -1281,6 +1329,8 @@ static void ixgbevf_rx_desc_queue_enable(struct ixgbevf_adapter *adapter,
1281 u32 rxdctl; 1329 u32 rxdctl;
1282 u8 reg_idx = ring->reg_idx; 1330 u8 reg_idx = ring->reg_idx;
1283 1331
1332 if (IXGBE_REMOVED(hw->hw_addr))
1333 return;
1284 do { 1334 do {
1285 usleep_range(1000, 2000); 1335 usleep_range(1000, 2000);
1286 rxdctl = IXGBE_READ_REG(hw, IXGBE_VFRXDCTL(reg_idx)); 1336 rxdctl = IXGBE_READ_REG(hw, IXGBE_VFRXDCTL(reg_idx));
@@ -1315,7 +1365,7 @@ static void ixgbevf_configure_rx_ring(struct ixgbevf_adapter *adapter,
1315 /* reset head and tail pointers */ 1365 /* reset head and tail pointers */
1316 IXGBE_WRITE_REG(hw, IXGBE_VFRDH(reg_idx), 0); 1366 IXGBE_WRITE_REG(hw, IXGBE_VFRDH(reg_idx), 0);
1317 IXGBE_WRITE_REG(hw, IXGBE_VFRDT(reg_idx), 0); 1367 IXGBE_WRITE_REG(hw, IXGBE_VFRDT(reg_idx), 0);
1318 ring->tail = hw->hw_addr + IXGBE_VFRDT(reg_idx); 1368 ring->tail = adapter->io_addr + IXGBE_VFRDT(reg_idx);
1319 1369
1320 /* reset ntu and ntc to place SW in sync with hardwdare */ 1370 /* reset ntu and ntc to place SW in sync with hardwdare */
1321 ring->next_to_clean = 0; 1371 ring->next_to_clean = 0;
@@ -1617,6 +1667,7 @@ static void ixgbevf_up_complete(struct ixgbevf_adapter *adapter)
1617 1667
1618 spin_unlock_bh(&adapter->mbx_lock); 1668 spin_unlock_bh(&adapter->mbx_lock);
1619 1669
1670 smp_mb__before_clear_bit();
1620 clear_bit(__IXGBEVF_DOWN, &adapter->state); 1671 clear_bit(__IXGBEVF_DOWN, &adapter->state);
1621 ixgbevf_napi_enable_all(adapter); 1672 ixgbevf_napi_enable_all(adapter);
1622 1673
@@ -1741,7 +1792,8 @@ void ixgbevf_down(struct ixgbevf_adapter *adapter)
1741 int i; 1792 int i;
1742 1793
1743 /* signal that we are down to the interrupt handler */ 1794 /* signal that we are down to the interrupt handler */
1744 set_bit(__IXGBEVF_DOWN, &adapter->state); 1795 if (test_and_set_bit(__IXGBEVF_DOWN, &adapter->state))
1796 return; /* do nothing if already down */
1745 1797
1746 /* disable all enabled rx queues */ 1798 /* disable all enabled rx queues */
1747 for (i = 0; i < adapter->num_rx_queues; i++) 1799 for (i = 0; i < adapter->num_rx_queues; i++)
@@ -1817,7 +1869,6 @@ void ixgbevf_reset(struct ixgbevf_adapter *adapter)
1817static int ixgbevf_acquire_msix_vectors(struct ixgbevf_adapter *adapter, 1869static int ixgbevf_acquire_msix_vectors(struct ixgbevf_adapter *adapter,
1818 int vectors) 1870 int vectors)
1819{ 1871{
1820 int err = 0;
1821 int vector_threshold; 1872 int vector_threshold;
1822 1873
1823 /* We'll want at least 2 (vector_threshold): 1874 /* We'll want at least 2 (vector_threshold):
@@ -1831,33 +1882,24 @@ static int ixgbevf_acquire_msix_vectors(struct ixgbevf_adapter *adapter,
1831 * Right now, we simply care about how many we'll get; we'll 1882 * Right now, we simply care about how many we'll get; we'll
1832 * set them up later while requesting irq's. 1883 * set them up later while requesting irq's.
1833 */ 1884 */
1834 while (vectors >= vector_threshold) { 1885 vectors = pci_enable_msix_range(adapter->pdev, adapter->msix_entries,
1835 err = pci_enable_msix(adapter->pdev, adapter->msix_entries, 1886 vector_threshold, vectors);
1836 vectors);
1837 if (!err || err < 0) /* Success or a nasty failure. */
1838 break;
1839 else /* err == number of vectors we should try again with */
1840 vectors = err;
1841 }
1842
1843 if (vectors < vector_threshold)
1844 err = -ENOMEM;
1845 1887
1846 if (err) { 1888 if (vectors < 0) {
1847 dev_err(&adapter->pdev->dev, 1889 dev_err(&adapter->pdev->dev,
1848 "Unable to allocate MSI-X interrupts\n"); 1890 "Unable to allocate MSI-X interrupts\n");
1849 kfree(adapter->msix_entries); 1891 kfree(adapter->msix_entries);
1850 adapter->msix_entries = NULL; 1892 adapter->msix_entries = NULL;
1851 } else { 1893 return vectors;
1852 /*
1853 * Adjust for only the vectors we'll use, which is minimum
1854 * of max_msix_q_vectors + NON_Q_VECTORS, or the number of
1855 * vectors we were allocated.
1856 */
1857 adapter->num_msix_vectors = vectors;
1858 } 1894 }
1859 1895
1860 return err; 1896 /* Adjust for only the vectors we'll use, which is minimum
1897 * of max_msix_q_vectors + NON_Q_VECTORS, or the number of
1898 * vectors we were allocated.
1899 */
1900 adapter->num_msix_vectors = vectors;
1901
1902 return 0;
1861} 1903}
1862 1904
1863/** 1905/**
@@ -2338,6 +2380,7 @@ static void ixgbevf_reset_task(struct work_struct *work)
2338 2380
2339 /* If we're already down or resetting, just bail */ 2381 /* If we're already down or resetting, just bail */
2340 if (test_bit(__IXGBEVF_DOWN, &adapter->state) || 2382 if (test_bit(__IXGBEVF_DOWN, &adapter->state) ||
2383 test_bit(__IXGBEVF_REMOVING, &adapter->state) ||
2341 test_bit(__IXGBEVF_RESETTING, &adapter->state)) 2384 test_bit(__IXGBEVF_RESETTING, &adapter->state))
2342 return; 2385 return;
2343 2386
@@ -2361,6 +2404,14 @@ static void ixgbevf_watchdog_task(struct work_struct *work)
2361 bool link_up = adapter->link_up; 2404 bool link_up = adapter->link_up;
2362 s32 need_reset; 2405 s32 need_reset;
2363 2406
2407 if (IXGBE_REMOVED(hw->hw_addr)) {
2408 if (!test_bit(__IXGBEVF_DOWN, &adapter->state)) {
2409 rtnl_lock();
2410 ixgbevf_down(adapter);
2411 rtnl_unlock();
2412 }
2413 return;
2414 }
2364 ixgbevf_queue_reset_subtask(adapter); 2415 ixgbevf_queue_reset_subtask(adapter);
2365 2416
2366 adapter->flags |= IXGBE_FLAG_IN_WATCHDOG_TASK; 2417 adapter->flags |= IXGBE_FLAG_IN_WATCHDOG_TASK;
@@ -2422,7 +2473,8 @@ static void ixgbevf_watchdog_task(struct work_struct *work)
2422 2473
2423pf_has_reset: 2474pf_has_reset:
2424 /* Reset the timer */ 2475 /* Reset the timer */
2425 if (!test_bit(__IXGBEVF_DOWN, &adapter->state)) 2476 if (!test_bit(__IXGBEVF_DOWN, &adapter->state) &&
2477 !test_bit(__IXGBEVF_REMOVING, &adapter->state))
2426 mod_timer(&adapter->watchdog_timer, 2478 mod_timer(&adapter->watchdog_timer,
2427 round_jiffies(jiffies + (2 * HZ))); 2479 round_jiffies(jiffies + (2 * HZ)));
2428 2480
@@ -2787,6 +2839,9 @@ static int ixgbevf_tso(struct ixgbevf_ring *tx_ring,
2787 u32 vlan_macip_lens, type_tucmd; 2839 u32 vlan_macip_lens, type_tucmd;
2788 u32 mss_l4len_idx, l4len; 2840 u32 mss_l4len_idx, l4len;
2789 2841
2842 if (skb->ip_summed != CHECKSUM_PARTIAL)
2843 return 0;
2844
2790 if (!skb_is_gso(skb)) 2845 if (!skb_is_gso(skb))
2791 return 0; 2846 return 0;
2792 2847
@@ -2857,12 +2912,12 @@ static void ixgbevf_tx_csum(struct ixgbevf_ring *tx_ring,
2857 if (skb->ip_summed == CHECKSUM_PARTIAL) { 2912 if (skb->ip_summed == CHECKSUM_PARTIAL) {
2858 u8 l4_hdr = 0; 2913 u8 l4_hdr = 0;
2859 switch (skb->protocol) { 2914 switch (skb->protocol) {
2860 case __constant_htons(ETH_P_IP): 2915 case htons(ETH_P_IP):
2861 vlan_macip_lens |= skb_network_header_len(skb); 2916 vlan_macip_lens |= skb_network_header_len(skb);
2862 type_tucmd |= IXGBE_ADVTXD_TUCMD_IPV4; 2917 type_tucmd |= IXGBE_ADVTXD_TUCMD_IPV4;
2863 l4_hdr = ip_hdr(skb)->protocol; 2918 l4_hdr = ip_hdr(skb)->protocol;
2864 break; 2919 break;
2865 case __constant_htons(ETH_P_IPV6): 2920 case htons(ETH_P_IPV6):
2866 vlan_macip_lens |= skb_network_header_len(skb); 2921 vlan_macip_lens |= skb_network_header_len(skb);
2867 l4_hdr = ipv6_hdr(skb)->nexthdr; 2922 l4_hdr = ipv6_hdr(skb)->nexthdr;
2868 break; 2923 break;
@@ -3060,7 +3115,7 @@ static void ixgbevf_tx_map(struct ixgbevf_ring *tx_ring,
3060 tx_ring->next_to_use = i; 3115 tx_ring->next_to_use = i;
3061 3116
3062 /* notify HW of packet */ 3117 /* notify HW of packet */
3063 writel(i, tx_ring->tail); 3118 ixgbevf_write_tail(tx_ring, i);
3064 3119
3065 return; 3120 return;
3066dma_error: 3121dma_error:
@@ -3165,7 +3220,7 @@ static int ixgbevf_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
3165 tso = ixgbevf_tso(tx_ring, first, &hdr_len); 3220 tso = ixgbevf_tso(tx_ring, first, &hdr_len);
3166 if (tso < 0) 3221 if (tso < 0)
3167 goto out_drop; 3222 goto out_drop;
3168 else 3223 else if (!tso)
3169 ixgbevf_tx_csum(tx_ring, first); 3224 ixgbevf_tx_csum(tx_ring, first);
3170 3225
3171 ixgbevf_tx_map(tx_ring, first, hdr_len); 3226 ixgbevf_tx_map(tx_ring, first, hdr_len);
@@ -3286,7 +3341,6 @@ static int ixgbevf_resume(struct pci_dev *pdev)
3286 struct ixgbevf_adapter *adapter = netdev_priv(netdev); 3341 struct ixgbevf_adapter *adapter = netdev_priv(netdev);
3287 u32 err; 3342 u32 err;
3288 3343
3289 pci_set_power_state(pdev, PCI_D0);
3290 pci_restore_state(pdev); 3344 pci_restore_state(pdev);
3291 /* 3345 /*
3292 * pci_restore_state clears dev->state_saved so call 3346 * pci_restore_state clears dev->state_saved so call
@@ -3344,10 +3398,10 @@ static struct rtnl_link_stats64 *ixgbevf_get_stats(struct net_device *netdev,
3344 for (i = 0; i < adapter->num_rx_queues; i++) { 3398 for (i = 0; i < adapter->num_rx_queues; i++) {
3345 ring = adapter->rx_ring[i]; 3399 ring = adapter->rx_ring[i];
3346 do { 3400 do {
3347 start = u64_stats_fetch_begin_bh(&ring->syncp); 3401 start = u64_stats_fetch_begin_irq(&ring->syncp);
3348 bytes = ring->stats.bytes; 3402 bytes = ring->stats.bytes;
3349 packets = ring->stats.packets; 3403 packets = ring->stats.packets;
3350 } while (u64_stats_fetch_retry_bh(&ring->syncp, start)); 3404 } while (u64_stats_fetch_retry_irq(&ring->syncp, start));
3351 stats->rx_bytes += bytes; 3405 stats->rx_bytes += bytes;
3352 stats->rx_packets += packets; 3406 stats->rx_packets += packets;
3353 } 3407 }
@@ -3355,10 +3409,10 @@ static struct rtnl_link_stats64 *ixgbevf_get_stats(struct net_device *netdev,
3355 for (i = 0; i < adapter->num_tx_queues; i++) { 3409 for (i = 0; i < adapter->num_tx_queues; i++) {
3356 ring = adapter->tx_ring[i]; 3410 ring = adapter->tx_ring[i];
3357 do { 3411 do {
3358 start = u64_stats_fetch_begin_bh(&ring->syncp); 3412 start = u64_stats_fetch_begin_irq(&ring->syncp);
3359 bytes = ring->stats.bytes; 3413 bytes = ring->stats.bytes;
3360 packets = ring->stats.packets; 3414 packets = ring->stats.packets;
3361 } while (u64_stats_fetch_retry_bh(&ring->syncp, start)); 3415 } while (u64_stats_fetch_retry_irq(&ring->syncp, start));
3362 stats->tx_bytes += bytes; 3416 stats->tx_bytes += bytes;
3363 stats->tx_packets += packets; 3417 stats->tx_packets += packets;
3364 } 3418 }
@@ -3460,6 +3514,7 @@ static int ixgbevf_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
3460 3514
3461 hw->hw_addr = ioremap(pci_resource_start(pdev, 0), 3515 hw->hw_addr = ioremap(pci_resource_start(pdev, 0),
3462 pci_resource_len(pdev, 0)); 3516 pci_resource_len(pdev, 0));
3517 adapter->io_addr = hw->hw_addr;
3463 if (!hw->hw_addr) { 3518 if (!hw->hw_addr) {
3464 err = -EIO; 3519 err = -EIO;
3465 goto err_ioremap; 3520 goto err_ioremap;
@@ -3545,7 +3600,7 @@ err_register:
3545 ixgbevf_clear_interrupt_scheme(adapter); 3600 ixgbevf_clear_interrupt_scheme(adapter);
3546err_sw_init: 3601err_sw_init:
3547 ixgbevf_reset_interrupt_capability(adapter); 3602 ixgbevf_reset_interrupt_capability(adapter);
3548 iounmap(hw->hw_addr); 3603 iounmap(adapter->io_addr);
3549err_ioremap: 3604err_ioremap:
3550 free_netdev(netdev); 3605 free_netdev(netdev);
3551err_alloc_etherdev: 3606err_alloc_etherdev:
@@ -3570,7 +3625,7 @@ static void ixgbevf_remove(struct pci_dev *pdev)
3570 struct net_device *netdev = pci_get_drvdata(pdev); 3625 struct net_device *netdev = pci_get_drvdata(pdev);
3571 struct ixgbevf_adapter *adapter = netdev_priv(netdev); 3626 struct ixgbevf_adapter *adapter = netdev_priv(netdev);
3572 3627
3573 set_bit(__IXGBEVF_DOWN, &adapter->state); 3628 set_bit(__IXGBEVF_REMOVING, &adapter->state);
3574 3629
3575 del_timer_sync(&adapter->watchdog_timer); 3630 del_timer_sync(&adapter->watchdog_timer);
3576 3631
@@ -3583,7 +3638,7 @@ static void ixgbevf_remove(struct pci_dev *pdev)
3583 ixgbevf_clear_interrupt_scheme(adapter); 3638 ixgbevf_clear_interrupt_scheme(adapter);
3584 ixgbevf_reset_interrupt_capability(adapter); 3639 ixgbevf_reset_interrupt_capability(adapter);
3585 3640
3586 iounmap(adapter->hw.hw_addr); 3641 iounmap(adapter->io_addr);
3587 pci_release_regions(pdev); 3642 pci_release_regions(pdev);
3588 3643
3589 hw_dbg(&adapter->hw, "Remove complete\n"); 3644 hw_dbg(&adapter->hw, "Remove complete\n");
diff --git a/drivers/net/ethernet/intel/ixgbevf/regs.h b/drivers/net/ethernet/intel/ixgbevf/regs.h
index debd8c0e1f28..09dd8f698bea 100644
--- a/drivers/net/ethernet/intel/ixgbevf/regs.h
+++ b/drivers/net/ethernet/intel/ixgbevf/regs.h
@@ -1,7 +1,7 @@
1/******************************************************************************* 1/*******************************************************************************
2 2
3 Intel 82599 Virtual Function driver 3 Intel 82599 Virtual Function driver
4 Copyright(c) 1999 - 2012 Intel Corporation. 4 Copyright(c) 1999 - 2014 Intel Corporation.
5 5
6 This program is free software; you can redistribute it and/or modify it 6 This program is free software; you can redistribute it and/or modify it
7 under the terms and conditions of the GNU General Public License, 7 under the terms and conditions of the GNU General Public License,
@@ -70,16 +70,6 @@
70#define IXGBE_VFGOTC_MSB 0x02024 70#define IXGBE_VFGOTC_MSB 0x02024
71#define IXGBE_VFMPRC 0x01034 71#define IXGBE_VFMPRC 0x01034
72 72
73#define IXGBE_WRITE_REG(a, reg, value) writel((value), ((a)->hw_addr + (reg)))
74
75#define IXGBE_READ_REG(a, reg) readl((a)->hw_addr + (reg))
76
77#define IXGBE_WRITE_REG_ARRAY(a, reg, offset, value) ( \
78 writel((value), ((a)->hw_addr + (reg) + ((offset) << 2))))
79
80#define IXGBE_READ_REG_ARRAY(a, reg, offset) ( \
81 readl((a)->hw_addr + (reg) + ((offset) << 2)))
82
83#define IXGBE_WRITE_FLUSH(a) (IXGBE_READ_REG(a, IXGBE_VFSTATUS)) 73#define IXGBE_WRITE_FLUSH(a) (IXGBE_READ_REG(a, IXGBE_VFSTATUS))
84 74
85#endif /* _IXGBEVF_REGS_H_ */ 75#endif /* _IXGBEVF_REGS_H_ */
diff --git a/drivers/net/ethernet/intel/ixgbevf/vf.h b/drivers/net/ethernet/intel/ixgbevf/vf.h
index 7b1f502d1716..096d33a59def 100644
--- a/drivers/net/ethernet/intel/ixgbevf/vf.h
+++ b/drivers/net/ethernet/intel/ixgbevf/vf.h
@@ -1,7 +1,7 @@
1/******************************************************************************* 1/*******************************************************************************
2 2
3 Intel 82599 Virtual Function driver 3 Intel 82599 Virtual Function driver
4 Copyright(c) 1999 - 2012 Intel Corporation. 4 Copyright(c) 1999 - 2014 Intel Corporation.
5 5
6 This program is free software; you can redistribute it and/or modify it 6 This program is free software; you can redistribute it and/or modify it
7 under the terms and conditions of the GNU General Public License, 7 under the terms and conditions of the GNU General Public License,
@@ -172,6 +172,37 @@ struct ixgbevf_info {
172 const struct ixgbe_mac_operations *mac_ops; 172 const struct ixgbe_mac_operations *mac_ops;
173}; 173};
174 174
175#define IXGBE_FAILED_READ_REG 0xffffffffU
176
177#define IXGBE_REMOVED(a) unlikely(!(a))
178
179static inline void ixgbe_write_reg(struct ixgbe_hw *hw, u32 reg, u32 value)
180{
181 u8 __iomem *reg_addr = ACCESS_ONCE(hw->hw_addr);
182
183 if (IXGBE_REMOVED(reg_addr))
184 return;
185 writel(value, reg_addr + reg);
186}
187#define IXGBE_WRITE_REG(h, r, v) ixgbe_write_reg(h, r, v)
188
189u32 ixgbe_read_reg(struct ixgbe_hw *hw, u32 reg);
190#define IXGBE_READ_REG(h, r) ixgbe_read_reg(h, r)
191
192static inline void ixgbe_write_reg_array(struct ixgbe_hw *hw, u32 reg,
193 u32 offset, u32 value)
194{
195 ixgbe_write_reg(hw, reg + (offset << 2), value);
196}
197#define IXGBE_WRITE_REG_ARRAY(h, r, o, v) ixgbe_write_reg_array(h, r, o, v)
198
199static inline u32 ixgbe_read_reg_array(struct ixgbe_hw *hw, u32 reg,
200 u32 offset)
201{
202 return ixgbe_read_reg(hw, reg + (offset << 2));
203}
204#define IXGBE_READ_REG_ARRAY(h, r, o) ixgbe_read_reg_array(h, r, o)
205
175void ixgbevf_rlpml_set_vf(struct ixgbe_hw *hw, u16 max_size); 206void ixgbevf_rlpml_set_vf(struct ixgbe_hw *hw, u16 max_size);
176int ixgbevf_negotiate_api_version(struct ixgbe_hw *hw, int api); 207int ixgbevf_negotiate_api_version(struct ixgbe_hw *hw, int api);
177int ixgbevf_get_queues(struct ixgbe_hw *hw, unsigned int *num_tcs, 208int ixgbevf_get_queues(struct ixgbe_hw *hw, unsigned int *num_tcs,