All of lore.kernel.org
 help / color / mirror / Atom feed
* [net-next 00/14][pull request] Intel Wired LAN Driver Updates
@ 2013-04-20  9:48 Jeff Kirsher
  2013-04-20  9:49 ` [net-next 01/14] ixgbe: fix possible divide by zero in ixgbe_update_itr Jeff Kirsher
                   ` (13 more replies)
  0 siblings, 14 replies; 26+ messages in thread
From: Jeff Kirsher @ 2013-04-20  9:48 UTC (permalink / raw)
  To: davem; +Cc: Jeff Kirsher, netdev, gospo, sassmann

This series contains updates to ixgbe, igb and pci.

The ixgbe changes contains a fix to a possible divide by zero by bailing
out of the ixgbe_update_itr() function if the last interrupt timeslice is
zero.  In addition, support is added for the new OCP x520 adapter as well
as LX support for 82599 devices.  Jacob provides a patch to change
variable wol_supported to wol_enabled to better reflect what the code
is actually doing (i.e. checking if WoL is enabled).

Alex adds SRIOV helper function to pci that will determine if a PF
has any VFs that are currently assigned to a guest.

The remaining 8 patches are against igb and contain the following changes:
* implement SERDES loopback configuration for i210 devices by unsetting
  sigdetect bit, so as to fix Ethtool loopback test failure
* add support for the SMBI semaphore for I210/I211 devices
* implement the new generic pci_vfs_assigned helper function (Alex's PCI
  helper function)
* display warning when link speed is downgraded due to Smartspeed
* ensure that VLAN hardware filtering remains enabled when the device is
  in promiscuous mode and VT mode simultaneously
* cleanup dead code in igb
* bump the driver version

The following are changes since commit 95a06161e6b903ad5b96285cb57c8df3b7c8ad34:
  Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/pablo/nf-next
and are available in the git repository at:
  git://git.kernel.org/pub/scm/linux/kernel/git/jkirsher/net-next master

Akeem G. Abodunrin (1):
  igb: SERDES loopback sigdetect bit on i210 devices

Alexander Duyck (2):
  pci: Add SRIOV helper function to determine if VFs are assigned to
    guest
  igb: Use pci_vfs_assigned instead of igb_vfs_are_assigned

Carolyn Wyborny (2):
  igb: Remove id's that will not be productized for Linux.
  igb: Bump version of driver

Don Skidmore (3):
  ixgbe: fix possible divide by zero in ixgbe_update_itr
  ixgbe: add driver support for x520 OCP adapter.
  ixgbe: add SFP+ LX module support

Emil Tantilov (1):
  ixgbe: add WOL support for new subdevice ID

Greg Rose (1):
  igb: Retain HW VLAN filtering while in promiscuous + VT mode

Jacob Keller (1):
  ixgbe: rename wol_supported to more fitting wol_enabled

Koki Sanagi (1):
  igb: display a warning message when SmartSpeed works

Matthew Vick (2):
  igb: Add SMBI semaphore to I210/I211
  igb: Remove dead code path

 drivers/net/ethernet/intel/igb/e1000_82575.c     |   9 +-
 drivers/net/ethernet/intel/igb/e1000_hw.h        |   3 +-
 drivers/net/ethernet/intel/igb/e1000_i210.c      |  65 ++++++++-----
 drivers/net/ethernet/intel/igb/igb_ethtool.c     |   9 +-
 drivers/net/ethernet/intel/igb/igb_main.c        | 117 +++++++++++++++--------
 drivers/net/ethernet/intel/ixgbe/ixgbe_82599.c   |   4 +-
 drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c |  10 +-
 drivers/net/ethernet/intel/ixgbe/ixgbe_main.c    |  16 +++-
 drivers/net/ethernet/intel/ixgbe/ixgbe_phy.c     |  21 +++-
 drivers/net/ethernet/intel/ixgbe/ixgbe_type.h    |   6 +-
 drivers/pci/iov.c                                |  41 ++++++++
 include/linux/pci.h                              |   5 +
 12 files changed, 212 insertions(+), 94 deletions(-)

-- 
1.7.11.7

^ permalink raw reply	[flat|nested] 26+ messages in thread

* [net-next 01/14] ixgbe: fix possible divide by zero in ixgbe_update_itr
  2013-04-20  9:48 [net-next 00/14][pull request] Intel Wired LAN Driver Updates Jeff Kirsher
@ 2013-04-20  9:49 ` Jeff Kirsher
  2013-04-20  9:49 ` [net-next 02/14] ixgbe: add driver support for x520 OCP adapter Jeff Kirsher
                   ` (12 subsequent siblings)
  13 siblings, 0 replies; 26+ messages in thread
From: Jeff Kirsher @ 2013-04-20  9:49 UTC (permalink / raw)
  To: davem; +Cc: Don Skidmore, netdev, gospo, sassmann, Jeff Kirsher

From: Don Skidmore <donald.c.skidmore@intel.com>

Protect the code by bailing out of ixgbe_update_itr() when this occurs.
The next call to ixgbe_update_itr will continue to dynamically update ITR.

Signed-of-by: Don Skidmore <donald.c.skidmore@intel.com>
Tested-by: Phil Schmitt <phillip.j.schmitt@intel.com>

Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
---
 drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
index 6225f88..9afc959 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
@@ -2095,6 +2095,9 @@ static void ixgbe_update_itr(struct ixgbe_q_vector *q_vector,
 	 */
 	/* what was last interrupt timeslice? */
 	timepassed_us = q_vector->itr >> 2;
+	if (timepassed_us == 0)
+		return;
+
 	bytes_perint = bytes / timepassed_us; /* bytes/usec */
 
 	switch (itr_setting) {
-- 
1.7.11.7

^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [net-next 02/14] ixgbe: add driver support for x520 OCP adapter.
  2013-04-20  9:48 [net-next 00/14][pull request] Intel Wired LAN Driver Updates Jeff Kirsher
  2013-04-20  9:49 ` [net-next 01/14] ixgbe: fix possible divide by zero in ixgbe_update_itr Jeff Kirsher
@ 2013-04-20  9:49 ` Jeff Kirsher
  2013-04-20  9:49 ` [net-next 03/14] ixgbe: rename wol_supported to more fitting wol_enabled Jeff Kirsher
                   ` (11 subsequent siblings)
  13 siblings, 0 replies; 26+ messages in thread
From: Jeff Kirsher @ 2013-04-20  9:49 UTC (permalink / raw)
  To: davem; +Cc: Don Skidmore, netdev, gospo, sassmann, Jeff Kirsher

From: Don Skidmore <donald.c.skidmore@intel.com>

This patch adds support for the new OCP x520 adapter.  This support
includes WoL.

Signed-off-by: Don Skidmore <donald.c.skidmore@intel.com>
Tested-by: Phil Schmitt <phillip.j.schmitt@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
---
 drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 8 ++++++++
 drivers/net/ethernet/intel/ixgbe/ixgbe_type.h | 1 +
 2 files changed, 9 insertions(+)

diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
index 9afc959..783efbb 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
@@ -7216,6 +7216,14 @@ int ixgbe_wol_supported(struct ixgbe_adapter *adapter, u16 device_id,
 			break;
 		}
 		break;
+	case IXGBE_DEV_ID_82599EN_SFP:
+		/* Only this subdevice supports WOL */
+		switch (subdevice_id) {
+		case IXGBE_SUBDEV_ID_82599EN_SFP_OCP1:
+			is_wol_supported = 1;
+			break;
+		}
+		break;
 	case IXGBE_DEV_ID_82599_COMBO_BACKPLANE:
 		/* All except this subdevice support WOL */
 		if (subdevice_id != IXGBE_SUBDEV_ID_82599_KX4_KR_MEZZ)
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_type.h b/drivers/net/ethernet/intel/ixgbe/ixgbe_type.h
index 402f1a2..2661dcf 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_type.h
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_type.h
@@ -61,6 +61,7 @@
 #define IXGBE_DEV_ID_82599_SFP_EM        0x1507
 #define IXGBE_DEV_ID_82599_SFP_SF2       0x154D
 #define IXGBE_DEV_ID_82599EN_SFP         0x1557
+#define IXGBE_SUBDEV_ID_82599EN_SFP_OCP1 0x0001
 #define IXGBE_DEV_ID_82599_XAUI_LOM      0x10FC
 #define IXGBE_DEV_ID_82599_COMBO_BACKPLANE 0x10F8
 #define IXGBE_SUBDEV_ID_82599_KX4_KR_MEZZ  0x000C
-- 
1.7.11.7

^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [net-next 03/14] ixgbe: rename wol_supported to more fitting wol_enabled
  2013-04-20  9:48 [net-next 00/14][pull request] Intel Wired LAN Driver Updates Jeff Kirsher
  2013-04-20  9:49 ` [net-next 01/14] ixgbe: fix possible divide by zero in ixgbe_update_itr Jeff Kirsher
  2013-04-20  9:49 ` [net-next 02/14] ixgbe: add driver support for x520 OCP adapter Jeff Kirsher
@ 2013-04-20  9:49 ` Jeff Kirsher
  2013-04-20  9:49 ` [net-next 04/14] ixgbe: add SFP+ LX module support Jeff Kirsher
                   ` (10 subsequent siblings)
  13 siblings, 0 replies; 26+ messages in thread
From: Jeff Kirsher @ 2013-04-20  9:49 UTC (permalink / raw)
  To: davem; +Cc: Jacob Keller, netdev, gospo, sassmann, Jeff Kirsher

From: Jacob Keller <jacob.e.keller@intel.com>

The variable wol_supported really is just checking whether it is enabled, rather
than whether it is supported. If it is enabled it will be supported, but this
does not necessarily hold true the other way around. This patch renames the
variable to avoid confusion.

Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
Tested-by: Phil Schmitt <phillip.j.schmitt@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
---
 drivers/net/ethernet/intel/ixgbe/ixgbe_82599.c | 2 +-
 drivers/net/ethernet/intel/ixgbe/ixgbe_main.c  | 4 ++--
 drivers/net/ethernet/intel/ixgbe/ixgbe_type.h  | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_82599.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_82599.c
index 7946da9..6dbdd4f 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_82599.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_82599.c
@@ -1055,7 +1055,7 @@ mac_reset_top:
 		 * LMS state either.
 		 */
 		if ((hw->phy.multispeed_fiber && hw->mng_fw_enabled) ||
-		    hw->wol_supported)
+		    hw->wol_enabled)
 			hw->mac.orig_autoc =
 				(hw->mac.orig_autoc & ~IXGBE_AUTOC_LMS_MASK) |
 				curr_lms;
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
index 783efbb..891724a 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
@@ -7540,9 +7540,9 @@ skip_sriov:
 	/* WOL not supported for all devices */
 	adapter->wol = 0;
 	hw->eeprom.ops.read(hw, 0x2c, &adapter->eeprom_cap);
-	hw->wol_supported = ixgbe_wol_supported(adapter, pdev->device,
+	hw->wol_enabled = ixgbe_wol_supported(adapter, pdev->device,
 						pdev->subsystem_device);
-	if (hw->wol_supported)
+	if (hw->wol_enabled)
 		adapter->wol = IXGBE_WUFC_MAG;
 
 	device_set_wakeup_enable(&adapter->pdev->dev, adapter->wol);
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_type.h b/drivers/net/ethernet/intel/ixgbe/ixgbe_type.h
index 2661dcf..100dd92 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_type.h
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_type.h
@@ -3000,7 +3000,7 @@ struct ixgbe_hw {
 	bool				force_full_reset;
 	bool				allow_unsupported_sfp;
 	bool				mng_fw_enabled;
-	bool				wol_supported;
+	bool				wol_enabled;
 };
 
 struct ixgbe_info {
-- 
1.7.11.7

^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [net-next 04/14] ixgbe: add SFP+ LX module support
  2013-04-20  9:48 [net-next 00/14][pull request] Intel Wired LAN Driver Updates Jeff Kirsher
                   ` (2 preceding siblings ...)
  2013-04-20  9:49 ` [net-next 03/14] ixgbe: rename wol_supported to more fitting wol_enabled Jeff Kirsher
@ 2013-04-20  9:49 ` Jeff Kirsher
  2013-04-20  9:49 ` [net-next 05/14] ixgbe: add WOL support for new subdevice ID Jeff Kirsher
                   ` (9 subsequent siblings)
  13 siblings, 0 replies; 26+ messages in thread
From: Jeff Kirsher @ 2013-04-20  9:49 UTC (permalink / raw)
  To: davem; +Cc: Don Skidmore, netdev, gospo, sassmann, Emil Tantilov, Jeff Kirsher

From: Don Skidmore <donald.c.skidmore@intel.com>

This patch adds LX support to 82599 devices. This is an alternate patch to
the one suggested by Stefan Behte <s.behte@babiel.com>

In addition this patch includes some cleanups such as:
- removed parenthesis around "x == y ||" lines inside an if statement for
consistency.
- grouped the sx/lx sfp types along with srlr in ixgbe_get_settings() since
they all have the same supported, advertised and port values.

Signed-off-by: Don Skidmore <donald.c.skidmore@intel.com>
Signed-off-by: Emil Tantilov <emil.s.tantilov@intel.com>
Reported-by: Stefan Behte <s.behte@babiel.com>
Tested-by: Phil Schmitt <phillip.j.schmitt@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
---
 drivers/net/ethernet/intel/ixgbe/ixgbe_82599.c   |  2 ++
 drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c | 10 ++++------
 drivers/net/ethernet/intel/ixgbe/ixgbe_phy.c     | 21 +++++++++++++++++----
 drivers/net/ethernet/intel/ixgbe/ixgbe_type.h    |  2 ++
 4 files changed, 25 insertions(+), 10 deletions(-)

diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_82599.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_82599.c
index 6dbdd4f..3f79242 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_82599.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_82599.c
@@ -266,6 +266,8 @@ static s32 ixgbe_get_link_capabilities_82599(struct ixgbe_hw *hw,
 	/* Determine 1G link capabilities off of SFP+ type */
 	if (hw->phy.sfp_type == ixgbe_sfp_type_1g_cu_core0 ||
 	    hw->phy.sfp_type == ixgbe_sfp_type_1g_cu_core1 ||
+	    hw->phy.sfp_type == ixgbe_sfp_type_1g_lx_core0 ||
+	    hw->phy.sfp_type == ixgbe_sfp_type_1g_lx_core1 ||
 	    hw->phy.sfp_type == ixgbe_sfp_type_1g_sx_core0 ||
 	    hw->phy.sfp_type == ixgbe_sfp_type_1g_sx_core1) {
 		*speed = IXGBE_LINK_SPEED_1GB_FULL;
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c
index c3f1afd..bbe00bc 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c
@@ -231,6 +231,10 @@ static int ixgbe_get_settings(struct net_device *netdev,
 		case ixgbe_sfp_type_lr:
 		case ixgbe_sfp_type_srlr_core0:
 		case ixgbe_sfp_type_srlr_core1:
+		case ixgbe_sfp_type_1g_sx_core0:
+		case ixgbe_sfp_type_1g_sx_core1:
+		case ixgbe_sfp_type_1g_lx_core0:
+		case ixgbe_sfp_type_1g_lx_core1:
 			ecmd->supported |= SUPPORTED_FIBRE;
 			ecmd->advertising |= ADVERTISED_FIBRE;
 			ecmd->port = PORT_FIBRE;
@@ -246,12 +250,6 @@ static int ixgbe_get_settings(struct net_device *netdev,
 			ecmd->advertising |= ADVERTISED_TP;
 			ecmd->port = PORT_TP;
 			break;
-		case ixgbe_sfp_type_1g_sx_core0:
-		case ixgbe_sfp_type_1g_sx_core1:
-			ecmd->supported |= SUPPORTED_FIBRE;
-			ecmd->advertising |= ADVERTISED_FIBRE;
-			ecmd->port = PORT_FIBRE;
-			break;
 		case ixgbe_sfp_type_unknown:
 		default:
 			ecmd->supported |= SUPPORTED_FIBRE;
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_phy.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_phy.c
index 060d2ad..e5691cc 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_phy.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_phy.c
@@ -956,6 +956,13 @@ s32 ixgbe_identify_sfp_module_generic(struct ixgbe_hw *hw)
 				else
 					hw->phy.sfp_type =
 						ixgbe_sfp_type_1g_sx_core1;
+			} else if (comp_codes_1g & IXGBE_SFF_1GBASELX_CAPABLE) {
+				if (hw->bus.lan_id == 0)
+					hw->phy.sfp_type =
+						ixgbe_sfp_type_1g_lx_core0;
+				else
+					hw->phy.sfp_type =
+						ixgbe_sfp_type_1g_lx_core1;
 			} else {
 				hw->phy.sfp_type = ixgbe_sfp_type_unknown;
 			}
@@ -1043,6 +1050,8 @@ s32 ixgbe_identify_sfp_module_generic(struct ixgbe_hw *hw)
 		if (comp_codes_10g == 0 &&
 		    !(hw->phy.sfp_type == ixgbe_sfp_type_1g_cu_core1 ||
 		      hw->phy.sfp_type == ixgbe_sfp_type_1g_cu_core0 ||
+		      hw->phy.sfp_type == ixgbe_sfp_type_1g_lx_core0 ||
+		      hw->phy.sfp_type == ixgbe_sfp_type_1g_lx_core1 ||
 		      hw->phy.sfp_type == ixgbe_sfp_type_1g_sx_core0 ||
 		      hw->phy.sfp_type == ixgbe_sfp_type_1g_sx_core1)) {
 			hw->phy.type = ixgbe_phy_sfp_unsupported;
@@ -1058,10 +1067,12 @@ s32 ixgbe_identify_sfp_module_generic(struct ixgbe_hw *hw)
 
 		hw->mac.ops.get_device_caps(hw, &enforce_sfp);
 		if (!(enforce_sfp & IXGBE_DEVICE_CAPS_ALLOW_ANY_SFP) &&
-		    !((hw->phy.sfp_type == ixgbe_sfp_type_1g_cu_core0) ||
-		      (hw->phy.sfp_type == ixgbe_sfp_type_1g_cu_core1) ||
-		      (hw->phy.sfp_type == ixgbe_sfp_type_1g_sx_core0) ||
-		      (hw->phy.sfp_type == ixgbe_sfp_type_1g_sx_core1))) {
+		    !(hw->phy.sfp_type == ixgbe_sfp_type_1g_cu_core0 ||
+		      hw->phy.sfp_type == ixgbe_sfp_type_1g_cu_core1 ||
+		      hw->phy.sfp_type == ixgbe_sfp_type_1g_lx_core0 ||
+		      hw->phy.sfp_type == ixgbe_sfp_type_1g_lx_core1 ||
+		      hw->phy.sfp_type == ixgbe_sfp_type_1g_sx_core0 ||
+		      hw->phy.sfp_type == ixgbe_sfp_type_1g_sx_core1)) {
 			/* Make sure we're a supported PHY type */
 			if (hw->phy.type == ixgbe_phy_sfp_intel) {
 				status = 0;
@@ -1125,10 +1136,12 @@ s32 ixgbe_get_sfp_init_sequence_offsets(struct ixgbe_hw *hw,
 	 * SR modules
 	 */
 	if (sfp_type == ixgbe_sfp_type_da_act_lmt_core0 ||
+	    sfp_type == ixgbe_sfp_type_1g_lx_core0 ||
 	    sfp_type == ixgbe_sfp_type_1g_cu_core0 ||
 	    sfp_type == ixgbe_sfp_type_1g_sx_core0)
 		sfp_type = ixgbe_sfp_type_srlr_core0;
 	else if (sfp_type == ixgbe_sfp_type_da_act_lmt_core1 ||
+		 sfp_type == ixgbe_sfp_type_1g_lx_core1 ||
 		 sfp_type == ixgbe_sfp_type_1g_cu_core1 ||
 		 sfp_type == ixgbe_sfp_type_1g_sx_core1)
 		sfp_type = ixgbe_sfp_type_srlr_core1;
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_type.h b/drivers/net/ethernet/intel/ixgbe/ixgbe_type.h
index 100dd92..4cbe219 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_type.h
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_type.h
@@ -2611,6 +2611,8 @@ enum ixgbe_sfp_type {
 	ixgbe_sfp_type_1g_cu_core1 = 10,
 	ixgbe_sfp_type_1g_sx_core0 = 11,
 	ixgbe_sfp_type_1g_sx_core1 = 12,
+	ixgbe_sfp_type_1g_lx_core0 = 13,
+	ixgbe_sfp_type_1g_lx_core1 = 14,
 	ixgbe_sfp_type_not_present = 0xFFFE,
 	ixgbe_sfp_type_unknown = 0xFFFF
 };
-- 
1.7.11.7

^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [net-next 05/14] ixgbe: add WOL support for new subdevice ID
  2013-04-20  9:48 [net-next 00/14][pull request] Intel Wired LAN Driver Updates Jeff Kirsher
                   ` (3 preceding siblings ...)
  2013-04-20  9:49 ` [net-next 04/14] ixgbe: add SFP+ LX module support Jeff Kirsher
@ 2013-04-20  9:49 ` Jeff Kirsher
  2013-04-20  9:49 ` [net-next 06/14] igb: SERDES loopback sigdetect bit on i210 devices Jeff Kirsher
                   ` (8 subsequent siblings)
  13 siblings, 0 replies; 26+ messages in thread
From: Jeff Kirsher @ 2013-04-20  9:49 UTC (permalink / raw)
  To: davem; +Cc: Emil Tantilov, netdev, gospo, sassmann, Jeff Kirsher

From: Emil Tantilov <emil.s.tantilov@intel.com>

This patch adds a define and WOL support for a new subdevice ID.

Signed-off-by: Emil Tantilov <emil.s.tantilov@intel.com>
Tested-by: Phil Schmitt <phillip.j.schmitt@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
---
 drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 1 +
 drivers/net/ethernet/intel/ixgbe/ixgbe_type.h | 1 +
 2 files changed, 2 insertions(+)

diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
index 891724a..88f6737 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
@@ -7208,6 +7208,7 @@ int ixgbe_wol_supported(struct ixgbe_adapter *adapter, u16 device_id,
 			/* only support first port */
 			if (hw->bus.func != 0)
 				break;
+		case IXGBE_SUBDEV_ID_82599_SP_560FLR:
 		case IXGBE_SUBDEV_ID_82599_SFP:
 		case IXGBE_SUBDEV_ID_82599_RNDC:
 		case IXGBE_SUBDEV_ID_82599_ECNA_DP:
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_type.h b/drivers/net/ethernet/intel/ixgbe/ixgbe_type.h
index 4cbe219..6d70665 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_type.h
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_type.h
@@ -56,6 +56,7 @@
 #define IXGBE_SUBDEV_ID_82599_SFP        0x11A9
 #define IXGBE_SUBDEV_ID_82599_RNDC       0x1F72
 #define IXGBE_SUBDEV_ID_82599_560FLR     0x17D0
+#define IXGBE_SUBDEV_ID_82599_SP_560FLR  0x211B
 #define IXGBE_SUBDEV_ID_82599_ECNA_DP    0x0470
 #define IXGBE_SUBDEV_ID_82599_LOM_SFP    0x8976
 #define IXGBE_DEV_ID_82599_SFP_EM        0x1507
-- 
1.7.11.7

^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [net-next 06/14] igb: SERDES loopback sigdetect bit on i210 devices
  2013-04-20  9:48 [net-next 00/14][pull request] Intel Wired LAN Driver Updates Jeff Kirsher
                   ` (4 preceding siblings ...)
  2013-04-20  9:49 ` [net-next 05/14] ixgbe: add WOL support for new subdevice ID Jeff Kirsher
@ 2013-04-20  9:49 ` Jeff Kirsher
  2013-04-20  9:49 ` [net-next 07/14] igb: Add SMBI semaphore to I210/I211 Jeff Kirsher
                   ` (7 subsequent siblings)
  13 siblings, 0 replies; 26+ messages in thread
From: Jeff Kirsher @ 2013-04-20  9:49 UTC (permalink / raw)
  To: davem; +Cc: Akeem G. Abodunrin, netdev, gospo, sassmann, Jeff Kirsher

From: "Akeem G. Abodunrin" <akeem.g.abodunrin@intel.com>

This patch implements SERDES loopback configuration for i210 devices by
unsetting sigdetect bit, so as to fix Ethtool loopback test failure. Old
sigdetect code is also simplified to take care of all devices newer than 82580

Signed-off-by: Akeem G Abodunrin <akeem.g.abodunrin@intel.com>
Tested-by: Aaron Brown <aaron.f.brown@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
---
 drivers/net/ethernet/intel/igb/igb_ethtool.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/drivers/net/ethernet/intel/igb/igb_ethtool.c b/drivers/net/ethernet/intel/igb/igb_ethtool.c
index 48b5947..7876240 100644
--- a/drivers/net/ethernet/intel/igb/igb_ethtool.c
+++ b/drivers/net/ethernet/intel/igb/igb_ethtool.c
@@ -1678,17 +1678,12 @@ static int igb_setup_loopback_test(struct igb_adapter *adapter)
 		wr32(E1000_CONNSW, reg);
 
 		/* Unset sigdetect for SERDES loopback on
-		 * 82580 and i350 devices.
+		 * 82580 and newer devices.
 		 */
-		switch (hw->mac.type) {
-		case e1000_82580:
-		case e1000_i350:
+		if (hw->mac.type >= e1000_82580) {
 			reg = rd32(E1000_PCS_CFG0);
 			reg |= E1000_PCS_CFG_IGN_SD;
 			wr32(E1000_PCS_CFG0, reg);
-			break;
-		default:
-			break;
 		}
 
 		/* Set PCS register for forced speed */
-- 
1.7.11.7

^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [net-next 07/14] igb: Add SMBI semaphore to I210/I211
  2013-04-20  9:48 [net-next 00/14][pull request] Intel Wired LAN Driver Updates Jeff Kirsher
                   ` (5 preceding siblings ...)
  2013-04-20  9:49 ` [net-next 06/14] igb: SERDES loopback sigdetect bit on i210 devices Jeff Kirsher
@ 2013-04-20  9:49 ` Jeff Kirsher
  2013-04-20  9:49 ` [net-next 08/14] pci: Add SRIOV helper function to determine if VFs are assigned to guest Jeff Kirsher
                   ` (6 subsequent siblings)
  13 siblings, 0 replies; 26+ messages in thread
From: Jeff Kirsher @ 2013-04-20  9:49 UTC (permalink / raw)
  To: davem; +Cc: Matthew Vick, netdev, gospo, sassmann, Jeff Kirsher

From: Matthew Vick <matthew.vick@intel.com>

It was previously thought that, since I210/I211 are single port devices,
they did not need the SMBI semaphore. This is not the case. Add support for
the SMBI semaphore.

Signed-off-by: Matthew Vick <matthew.vick@intel.com>
Tested-by: Aaron Brown <aaron.f.brown@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
---
 drivers/net/ethernet/intel/igb/e1000_82575.c |  3 ++
 drivers/net/ethernet/intel/igb/e1000_hw.h    |  1 +
 drivers/net/ethernet/intel/igb/e1000_i210.c  | 65 +++++++++++++++++-----------
 3 files changed, 43 insertions(+), 26 deletions(-)

diff --git a/drivers/net/ethernet/intel/igb/e1000_82575.c b/drivers/net/ethernet/intel/igb/e1000_82575.c
index c9bba39d5..6cb0ca2 100644
--- a/drivers/net/ethernet/intel/igb/e1000_82575.c
+++ b/drivers/net/ethernet/intel/igb/e1000_82575.c
@@ -389,6 +389,9 @@ static s32 igb_init_mac_params_82575(struct e1000_hw *hw)
 		dev_spec->eee_disable = false;
 	else
 		dev_spec->eee_disable = true;
+	/* Allow a single clear of the SW semaphore on I210 and newer */
+	if (mac->type >= e1000_i210)
+		dev_spec->clear_semaphore_once = true;
 	/* physical interface link setup */
 	mac->ops.setup_physical_interface =
 		(hw->phy.media_type == e1000_media_type_copper)
diff --git a/drivers/net/ethernet/intel/igb/e1000_hw.h b/drivers/net/ethernet/intel/igb/e1000_hw.h
index 1138cca..f1dbab9 100644
--- a/drivers/net/ethernet/intel/igb/e1000_hw.h
+++ b/drivers/net/ethernet/intel/igb/e1000_hw.h
@@ -529,6 +529,7 @@ struct e1000_dev_spec_82575 {
 	bool sgmii_active;
 	bool global_device_reset;
 	bool eee_disable;
+	bool clear_semaphore_once;
 };
 
 struct e1000_hw {
diff --git a/drivers/net/ethernet/intel/igb/e1000_i210.c b/drivers/net/ethernet/intel/igb/e1000_i210.c
index 9764cd3..ddb3cf5 100644
--- a/drivers/net/ethernet/intel/igb/e1000_i210.c
+++ b/drivers/net/ethernet/intel/igb/e1000_i210.c
@@ -44,10 +44,42 @@
 static s32 igb_get_hw_semaphore_i210(struct e1000_hw *hw)
 {
 	u32 swsm;
-	s32 ret_val = E1000_SUCCESS;
 	s32 timeout = hw->nvm.word_size + 1;
 	s32 i = 0;
 
+	/* Get the SW semaphore */
+	while (i < timeout) {
+		swsm = rd32(E1000_SWSM);
+		if (!(swsm & E1000_SWSM_SMBI))
+			break;
+
+		udelay(50);
+		i++;
+	}
+
+	if (i == timeout) {
+		/* In rare circumstances, the SW semaphore may already be held
+		 * unintentionally. Clear the semaphore once before giving up.
+		 */
+		if (hw->dev_spec._82575.clear_semaphore_once) {
+			hw->dev_spec._82575.clear_semaphore_once = false;
+			igb_put_hw_semaphore(hw);
+			for (i = 0; i < timeout; i++) {
+				swsm = rd32(E1000_SWSM);
+				if (!(swsm & E1000_SWSM_SMBI))
+					break;
+
+				udelay(50);
+			}
+		}
+
+		/* If we do not have the semaphore here, we have to give up. */
+		if (i == timeout) {
+			hw_dbg("Driver can't access device - SMBI bit is set.\n");
+			return -E1000_ERR_NVM;
+		}
+	}
+
 	/* Get the FW semaphore. */
 	for (i = 0; i < timeout; i++) {
 		swsm = rd32(E1000_SWSM);
@@ -64,12 +96,10 @@ static s32 igb_get_hw_semaphore_i210(struct e1000_hw *hw)
 		/* Release semaphores */
 		igb_put_hw_semaphore(hw);
 		hw_dbg("Driver can't access the NVM\n");
-		ret_val = -E1000_ERR_NVM;
-		goto out;
+		return -E1000_ERR_NVM;
 	}
 
-out:
-	return ret_val;
+	return E1000_SUCCESS;
 }
 
 /**
@@ -99,23 +129,6 @@ void igb_release_nvm_i210(struct e1000_hw *hw)
 }
 
 /**
- *  igb_put_hw_semaphore_i210 - Release hardware semaphore
- *  @hw: pointer to the HW structure
- *
- *  Release hardware semaphore used to access the PHY or NVM
- **/
-static void igb_put_hw_semaphore_i210(struct e1000_hw *hw)
-{
-	u32 swsm;
-
-	swsm = rd32(E1000_SWSM);
-
-	swsm &= ~E1000_SWSM_SWESMBI;
-
-	wr32(E1000_SWSM, swsm);
-}
-
-/**
  *  igb_acquire_swfw_sync_i210 - Acquire SW/FW semaphore
  *  @hw: pointer to the HW structure
  *  @mask: specifies which semaphore to acquire
@@ -138,11 +151,11 @@ s32 igb_acquire_swfw_sync_i210(struct e1000_hw *hw, u16 mask)
 		}
 
 		swfw_sync = rd32(E1000_SW_FW_SYNC);
-		if (!(swfw_sync & fwmask))
+		if (!(swfw_sync & (fwmask | swmask)))
 			break;
 
 		/* Firmware currently using resource (fwmask) */
-		igb_put_hw_semaphore_i210(hw);
+		igb_put_hw_semaphore(hw);
 		mdelay(5);
 		i++;
 	}
@@ -156,7 +169,7 @@ s32 igb_acquire_swfw_sync_i210(struct e1000_hw *hw, u16 mask)
 	swfw_sync |= swmask;
 	wr32(E1000_SW_FW_SYNC, swfw_sync);
 
-	igb_put_hw_semaphore_i210(hw);
+	igb_put_hw_semaphore(hw);
 out:
 	return ret_val;
 }
@@ -180,7 +193,7 @@ void igb_release_swfw_sync_i210(struct e1000_hw *hw, u16 mask)
 	swfw_sync &= ~mask;
 	wr32(E1000_SW_FW_SYNC, swfw_sync);
 
-	igb_put_hw_semaphore_i210(hw);
+	igb_put_hw_semaphore(hw);
 }
 
 /**
-- 
1.7.11.7

^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [net-next 08/14] pci: Add SRIOV helper function to determine if VFs are assigned to guest
  2013-04-20  9:48 [net-next 00/14][pull request] Intel Wired LAN Driver Updates Jeff Kirsher
                   ` (6 preceding siblings ...)
  2013-04-20  9:49 ` [net-next 07/14] igb: Add SMBI semaphore to I210/I211 Jeff Kirsher
@ 2013-04-20  9:49 ` Jeff Kirsher
  2013-04-21  0:54   ` David Miller
  2013-04-21  3:31   ` Jeff Kirsher
  2013-04-20  9:49 ` [net-next 09/14] igb: Use pci_vfs_assigned instead of igb_vfs_are_assigned Jeff Kirsher
                   ` (5 subsequent siblings)
  13 siblings, 2 replies; 26+ messages in thread
From: Jeff Kirsher @ 2013-04-20  9:49 UTC (permalink / raw)
  To: davem; +Cc: Alexander Duyck, netdev, gospo, sassmann, Jeff Kirsher

From: Alexander Duyck <alexander.h.duyck@intel.com>

This function is meant to add a helper function that will determine if a PF
has any VFs that are currently assigned to a guest.  We currently have been
implementing this function per driver, and going forward I would like to avoid
that by making this function generic and using this helper.

Signed-off-by: Alexander Duyck <alexander.h.duyck@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
---
 drivers/pci/iov.c   | 41 +++++++++++++++++++++++++++++++++++++++++
 include/linux/pci.h |  5 +++++
 2 files changed, 46 insertions(+)

diff --git a/drivers/pci/iov.c b/drivers/pci/iov.c
index ee599f2..fd99720 100644
--- a/drivers/pci/iov.c
+++ b/drivers/pci/iov.c
@@ -729,6 +729,47 @@ int pci_num_vf(struct pci_dev *dev)
 EXPORT_SYMBOL_GPL(pci_num_vf);
 
 /**
+ * pci_vfs_assigned - returns number of VFs are assigned to a guest
+ * @dev: the PCI device
+ *
+ * Returns number of VFs belonging to this device that are assigned to a guest.
+ * If device is not a physical function returns -ENODEV.
+ */
+int pci_vfs_assigned(struct pci_dev *dev)
+{
+	struct pci_dev *vfdev;
+	unsigned int vfs_assigned = 0;
+	unsigned short dev_id;
+
+	/* only search if we are a PF */
+	if (!dev->is_physfn)
+		return -ENODEV;
+
+	/*
+	 * determine the device ID for the VFs, the vendor ID will be the
+	 * same as the PF so there is no need to check for that one
+	 */
+	pci_read_config_word(dev, dev->sriov->pos + PCI_SRIOV_VF_DID, &dev_id);
+
+	/* loop through all the VFs to see if we own any that are assigned */
+	vfdev = pci_get_device(dev->vendor, dev_id, NULL);
+	while (vfdev) {
+		/*
+		 * It is considered assigned if it is a virtual function with
+		 * our dev as the physical function and the assigned bit is set
+		 */
+		if (vfdev->is_virtfn && (vfdev->physfn == dev) &&
+		    (vfdev->dev_flags & PCI_DEV_FLAGS_ASSIGNED))
+			vfs_assigned++;
+
+		vfdev = pci_get_device(dev->vendor, dev_id, vfdev);
+	}
+
+	return vfs_assigned;
+}
+EXPORT_SYMBOL_GPL(pci_vfs_assigned);
+
+/**
  * pci_sriov_set_totalvfs -- reduce the TotalVFs available
  * @dev: the PCI PF device
  * @numvfs: number that should be used for TotalVFs supported
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 2461033a..03b4d3c 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -1643,6 +1643,7 @@ extern int pci_enable_sriov(struct pci_dev *dev, int nr_virtfn);
 extern void pci_disable_sriov(struct pci_dev *dev);
 extern irqreturn_t pci_sriov_migration(struct pci_dev *dev);
 extern int pci_num_vf(struct pci_dev *dev);
+extern int pci_vfs_assigned(struct pci_dev *dev);
 extern int pci_sriov_set_totalvfs(struct pci_dev *dev, u16 numvfs);
 extern int pci_sriov_get_totalvfs(struct pci_dev *dev);
 #else
@@ -1661,6 +1662,10 @@ static inline int pci_num_vf(struct pci_dev *dev)
 {
 	return 0;
 }
+static inline int pci_vfs_assigned(struct pci_dev *dev)
+{
+	return 0;
+}
 static inline int pci_sriov_set_totalvfs(struct pci_dev *dev, u16 numvfs)
 {
 	return 0;
-- 
1.7.11.7

^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [net-next 09/14] igb: Use pci_vfs_assigned instead of igb_vfs_are_assigned
  2013-04-20  9:48 [net-next 00/14][pull request] Intel Wired LAN Driver Updates Jeff Kirsher
                   ` (7 preceding siblings ...)
  2013-04-20  9:49 ` [net-next 08/14] pci: Add SRIOV helper function to determine if VFs are assigned to guest Jeff Kirsher
@ 2013-04-20  9:49 ` Jeff Kirsher
  2013-04-20  9:49 ` [net-next 10/14] igb: display a warning message when SmartSpeed works Jeff Kirsher
                   ` (4 subsequent siblings)
  13 siblings, 0 replies; 26+ messages in thread
From: Jeff Kirsher @ 2013-04-20  9:49 UTC (permalink / raw)
  To: davem; +Cc: Alexander Duyck, netdev, gospo, sassmann, Jeff Kirsher

From: Alexander Duyck <alexander.h.duyck@intel.com>

This change makes it so that the igb driver uses the generic helper
pci_vfs_assigned instead of the igb specific function igb_vfs_are_assigned.

Signed-off-by: Alexander Duyck <alexander.h.duyck@intel.com>
Tested-by: Sibai Li <sibai.li@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
---
 drivers/net/ethernet/intel/igb/igb_main.c | 36 +------------------------------
 1 file changed, 1 insertion(+), 35 deletions(-)

diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c
index 9bf08b9..388d36f 100644
--- a/drivers/net/ethernet/intel/igb/igb_main.c
+++ b/drivers/net/ethernet/intel/igb/igb_main.c
@@ -180,7 +180,6 @@ static void igb_check_vf_rate_limit(struct igb_adapter *);
 
 #ifdef CONFIG_PCI_IOV
 static int igb_vf_configure(struct igb_adapter *adapter, int vf);
-static bool igb_vfs_are_assigned(struct igb_adapter *adapter);
 #endif
 
 #ifdef CONFIG_PM
@@ -2402,7 +2401,7 @@ static int  igb_disable_sriov(struct pci_dev *pdev)
 	/* reclaim resources allocated to VFs */
 	if (adapter->vf_data) {
 		/* disable iov and allow time for transactions to clear */
-		if (igb_vfs_are_assigned(adapter)) {
+		if (pci_vfs_assigned(pdev)) {
 			dev_warn(&pdev->dev,
 				 "Cannot deallocate SR-IOV virtual functions while they are assigned - VFs will not be deallocated\n");
 			return -EPERM;
@@ -5259,39 +5258,6 @@ static int igb_vf_configure(struct igb_adapter *adapter, int vf)
 	return 0;
 }
 
-static bool igb_vfs_are_assigned(struct igb_adapter *adapter)
-{
-	struct pci_dev *pdev = adapter->pdev;
-	struct pci_dev *vfdev;
-	int dev_id;
-
-	switch (adapter->hw.mac.type) {
-	case e1000_82576:
-		dev_id = IGB_82576_VF_DEV_ID;
-		break;
-	case e1000_i350:
-		dev_id = IGB_I350_VF_DEV_ID;
-		break;
-	default:
-		return false;
-	}
-
-	/* loop through all the VFs to see if we own any that are assigned */
-	vfdev = pci_get_device(PCI_VENDOR_ID_INTEL, dev_id, NULL);
-	while (vfdev) {
-		/* if we don't own it we don't care */
-		if (vfdev->is_virtfn && vfdev->physfn == pdev) {
-			/* if it is assigned we cannot release it */
-			if (vfdev->dev_flags & PCI_DEV_FLAGS_ASSIGNED)
-				return true;
-		}
-
-		vfdev = pci_get_device(PCI_VENDOR_ID_INTEL, dev_id, vfdev);
-	}
-
-	return false;
-}
-
 #endif
 static void igb_ping_all_vfs(struct igb_adapter *adapter)
 {
-- 
1.7.11.7

^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [net-next 10/14] igb: display a warning message when SmartSpeed works
  2013-04-20  9:48 [net-next 00/14][pull request] Intel Wired LAN Driver Updates Jeff Kirsher
                   ` (8 preceding siblings ...)
  2013-04-20  9:49 ` [net-next 09/14] igb: Use pci_vfs_assigned instead of igb_vfs_are_assigned Jeff Kirsher
@ 2013-04-20  9:49 ` Jeff Kirsher
  2013-04-20  9:49 ` [net-next 11/14] igb: Retain HW VLAN filtering while in promiscuous + VT mode Jeff Kirsher
                   ` (3 subsequent siblings)
  13 siblings, 0 replies; 26+ messages in thread
From: Jeff Kirsher @ 2013-04-20  9:49 UTC (permalink / raw)
  To: davem; +Cc: Koki Sanagi, netdev, gospo, sassmann, Jeff Kirsher

From: Koki Sanagi <sanagi.koki@jp.fujitsu.com>

Current igb driver doesn't tell nothing when Link Speed is downgraded due to
SmartSpeed.  As a result, users suspect that there is something wrong with
NIC.  If the cause of it is SmartSpeed, there is no means to replace NIC. This
patch make igb notify users that SmartSpeed worked.

Signed-off-by: Koki Sanagi <sanagi.koki@jp.fujitsu.com>
Tested-by: Aaron Brown <aaron.f.brown@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
---
 drivers/net/ethernet/intel/igb/igb_main.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c
index 388d36f..b90a062 100644
--- a/drivers/net/ethernet/intel/igb/igb_main.c
+++ b/drivers/net/ethernet/intel/igb/igb_main.c
@@ -3918,6 +3918,7 @@ static void igb_watchdog_task(struct work_struct *work)
 						   struct igb_adapter,
 						   watchdog_task);
 	struct e1000_hw *hw = &adapter->hw;
+	struct e1000_phy_info *phy = &hw->phy;
 	struct net_device *netdev = adapter->netdev;
 	u32 link;
 	int i;
@@ -3946,6 +3947,11 @@ static void igb_watchdog_task(struct work_struct *work)
 			       (ctrl & E1000_CTRL_RFCE) ?  "RX" :
 			       (ctrl & E1000_CTRL_TFCE) ?  "TX" : "None");
 
+			/* check if SmartSpeed worked */
+			igb_check_downshift(hw);
+			if (phy->speed_downgraded)
+				netdev_warn(netdev, "Link Speed was downgraded by SmartSpeed\n");
+
 			/* check for thermal sensor event */
 			if (igb_thermal_sensor_event(hw,
 			    E1000_THSTAT_LINK_THROTTLE)) {
-- 
1.7.11.7

^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [net-next 11/14] igb: Retain HW VLAN filtering while in promiscuous + VT mode
  2013-04-20  9:48 [net-next 00/14][pull request] Intel Wired LAN Driver Updates Jeff Kirsher
                   ` (9 preceding siblings ...)
  2013-04-20  9:49 ` [net-next 10/14] igb: display a warning message when SmartSpeed works Jeff Kirsher
@ 2013-04-20  9:49 ` Jeff Kirsher
  2013-04-20  9:49 ` [net-next 12/14] igb: Remove dead code path Jeff Kirsher
                   ` (2 subsequent siblings)
  13 siblings, 0 replies; 26+ messages in thread
From: Jeff Kirsher @ 2013-04-20  9:49 UTC (permalink / raw)
  To: davem; +Cc: Greg Rose, netdev, gospo, sassmann, Jeff Kirsher

From: Greg Rose <gregory.v.rose@intel.com>

When using the new bridge FDB interface to allow SR-IOV virtual function
network devices to communicate with SW bridged network devices the
physical function is placed into promiscuous mode and hardware VLAN
filtering is disabled.  This defeats the ability to use VLAN tagging
to isolate user networks.  When the device is in promiscuous mode and
VT mode simultaneously ensure that VLAN hardware filtering remains
enabled.

Signed-off-by: Greg Rose <gregory.v.rose@intel.com>
Tested-by: Sibai Li <sibai.li@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
---
 drivers/net/ethernet/intel/igb/igb_main.c | 69 ++++++++++++++++++++++++++++++-
 1 file changed, 68 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c
index b90a062..7eb648b 100644
--- a/drivers/net/ethernet/intel/igb/igb_main.c
+++ b/drivers/net/ethernet/intel/igb/igb_main.c
@@ -3753,6 +3753,10 @@ static void igb_set_rx_mode(struct net_device *netdev)
 	rctl &= ~(E1000_RCTL_UPE | E1000_RCTL_MPE | E1000_RCTL_VFE);
 
 	if (netdev->flags & IFF_PROMISC) {
+		u32 mrqc = rd32(E1000_MRQC);
+		/* retain VLAN HW filtering if in VT mode */
+		if (mrqc & E1000_MRQC_ENABLE_VMDQ)
+			rctl |= E1000_RCTL_VFE;
 		rctl |= (E1000_RCTL_UPE | E1000_RCTL_MPE);
 		vmolr |= (E1000_VMOLR_ROPE | E1000_VMOLR_MPME);
 	} else {
@@ -5537,12 +5541,75 @@ out:
 	return err;
 }
 
+static int igb_find_vlvf_entry(struct igb_adapter *adapter, int vid)
+{
+	struct e1000_hw *hw = &adapter->hw;
+	int i;
+	u32 reg;
+
+	/* Find the vlan filter for this id */
+	for (i = 0; i < E1000_VLVF_ARRAY_SIZE; i++) {
+		reg = rd32(E1000_VLVF(i));
+		if ((reg & E1000_VLVF_VLANID_ENABLE) &&
+		    vid == (reg & E1000_VLVF_VLANID_MASK))
+			break;
+	}
+
+	if (i >= E1000_VLVF_ARRAY_SIZE)
+		i = -1;
+
+	return i;
+}
+
 static int igb_set_vf_vlan(struct igb_adapter *adapter, u32 *msgbuf, u32 vf)
 {
+	struct e1000_hw *hw = &adapter->hw;
 	int add = (msgbuf[0] & E1000_VT_MSGINFO_MASK) >> E1000_VT_MSGINFO_SHIFT;
 	int vid = (msgbuf[1] & E1000_VLVF_VLANID_MASK);
+	int err = 0;
 
-	return igb_vlvf_set(adapter, vid, add, vf);
+	/* If in promiscuous mode we need to make sure the PF also has
+	 * the VLAN filter set.
+	 */
+	if (add && (adapter->netdev->flags & IFF_PROMISC))
+		err = igb_vlvf_set(adapter, vid, add,
+				   adapter->vfs_allocated_count);
+	if (err)
+		goto out;
+
+	err = igb_vlvf_set(adapter, vid, add, vf);
+
+	if (err)
+		goto out;
+
+	/* Go through all the checks to see if the VLAN filter should
+	 * be wiped completely.
+	 */
+	if (!add && (adapter->netdev->flags & IFF_PROMISC)) {
+		u32 vlvf, bits;
+
+		int regndx = igb_find_vlvf_entry(adapter, vid);
+		if (regndx < 0)
+			goto out;
+		/* See if any other pools are set for this VLAN filter
+		 * entry other than the PF.
+		 */
+		vlvf = bits = rd32(E1000_VLVF(regndx));
+		bits &= 1 << (E1000_VLVF_POOLSEL_SHIFT +
+			      adapter->vfs_allocated_count);
+		/* If the filter was removed then ensure PF pool bit
+		 * is cleared if the PF only added itself to the pool
+		 * because the PF is in promiscuous mode.
+		 */
+		if ((vlvf & VLAN_VID_MASK) == vid &&
+		    !test_bit(vid, adapter->active_vlans) &&
+		    !bits)
+			igb_vlvf_set(adapter, vid, add,
+				     adapter->vfs_allocated_count);
+	}
+
+out:
+	return err;
 }
 
 static inline void igb_vf_reset(struct igb_adapter *adapter, u32 vf)
-- 
1.7.11.7

^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [net-next 12/14] igb: Remove dead code path
  2013-04-20  9:48 [net-next 00/14][pull request] Intel Wired LAN Driver Updates Jeff Kirsher
                   ` (10 preceding siblings ...)
  2013-04-20  9:49 ` [net-next 11/14] igb: Retain HW VLAN filtering while in promiscuous + VT mode Jeff Kirsher
@ 2013-04-20  9:49 ` Jeff Kirsher
  2013-04-20  9:49 ` [net-next 13/14] igb: Remove id's that will not be productized for Linux Jeff Kirsher
  2013-04-20  9:49 ` [net-next 14/14] igb: Bump version of driver Jeff Kirsher
  13 siblings, 0 replies; 26+ messages in thread
From: Jeff Kirsher @ 2013-04-20  9:49 UTC (permalink / raw)
  To: davem; +Cc: Matthew Vick, netdev, gospo, sassmann, Jeff Kirsher

From: Matthew Vick <matthew.vick@intel.com>

The 82575 manual initialization scripts are not supported on 82580 and
above. Rather than call the function to immediately return, clarify the
code by removing this pointless function call.

Signed-off-by: Matthew Vick <matthew.vick@intel.com>
Tested-by: Aaron Brown <aaron.f.brown@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
---
 drivers/net/ethernet/intel/igb/e1000_82575.c | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/drivers/net/ethernet/intel/igb/e1000_82575.c b/drivers/net/ethernet/intel/igb/e1000_82575.c
index 6cb0ca2..d3d72e0 100644
--- a/drivers/net/ethernet/intel/igb/e1000_82575.c
+++ b/drivers/net/ethernet/intel/igb/e1000_82575.c
@@ -2052,10 +2052,6 @@ static s32 igb_reset_hw_82580(struct e1000_hw *hw)
 		hw_dbg("Auto Read Done did not complete\n");
 	}
 
-	/* If EEPROM is not present, run manual init scripts */
-	if ((rd32(E1000_EECD) & E1000_EECD_PRES) == 0)
-		igb_reset_init_script_82575(hw);
-
 	/* clear global device reset status bit */
 	wr32(E1000_STATUS, E1000_STAT_DEV_RST_SET);
 
-- 
1.7.11.7

^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [net-next 13/14] igb: Remove id's that will not be productized for Linux.
  2013-04-20  9:48 [net-next 00/14][pull request] Intel Wired LAN Driver Updates Jeff Kirsher
                   ` (11 preceding siblings ...)
  2013-04-20  9:49 ` [net-next 12/14] igb: Remove dead code path Jeff Kirsher
@ 2013-04-20  9:49 ` Jeff Kirsher
  2013-04-20  9:49 ` [net-next 14/14] igb: Bump version of driver Jeff Kirsher
  13 siblings, 0 replies; 26+ messages in thread
From: Jeff Kirsher @ 2013-04-20  9:49 UTC (permalink / raw)
  To: davem; +Cc: Carolyn Wyborny, netdev, gospo, sassmann, Jeff Kirsher

From: Carolyn Wyborny <carolyn.wyborny@intel.com>

This patch removes id defines from the hardware files that will not be
productized for Linux.  These id's were not implemented for support in the
base driver itself, they were just available defines.

Signed-off-by: Carolyn Wyborny <carolyn.wyborny@intel.com>
Tested-by: Aaron Brown <aaron.f.brown@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
---
 drivers/net/ethernet/intel/igb/e1000_82575.c | 2 --
 drivers/net/ethernet/intel/igb/e1000_hw.h    | 2 --
 2 files changed, 4 deletions(-)

diff --git a/drivers/net/ethernet/intel/igb/e1000_82575.c b/drivers/net/ethernet/intel/igb/e1000_82575.c
index d3d72e0..ff6a17c 100644
--- a/drivers/net/ethernet/intel/igb/e1000_82575.c
+++ b/drivers/net/ethernet/intel/igb/e1000_82575.c
@@ -443,8 +443,6 @@ static s32 igb_get_invariants_82575(struct e1000_hw *hw)
 		mac->type = e1000_i350;
 		break;
 	case E1000_DEV_ID_I210_COPPER:
-	case E1000_DEV_ID_I210_COPPER_OEM1:
-	case E1000_DEV_ID_I210_COPPER_IT:
 	case E1000_DEV_ID_I210_FIBER:
 	case E1000_DEV_ID_I210_SERDES:
 	case E1000_DEV_ID_I210_SGMII:
diff --git a/drivers/net/ethernet/intel/igb/e1000_hw.h b/drivers/net/ethernet/intel/igb/e1000_hw.h
index f1dbab9..488abb2 100644
--- a/drivers/net/ethernet/intel/igb/e1000_hw.h
+++ b/drivers/net/ethernet/intel/igb/e1000_hw.h
@@ -64,8 +64,6 @@ struct e1000_hw;
 #define E1000_DEV_ID_I350_SERDES		0x1523
 #define E1000_DEV_ID_I350_SGMII			0x1524
 #define E1000_DEV_ID_I210_COPPER		0x1533
-#define E1000_DEV_ID_I210_COPPER_OEM1		0x1534
-#define E1000_DEV_ID_I210_COPPER_IT		0x1535
 #define E1000_DEV_ID_I210_FIBER			0x1536
 #define E1000_DEV_ID_I210_SERDES		0x1537
 #define E1000_DEV_ID_I210_SGMII			0x1538
-- 
1.7.11.7

^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [net-next 14/14] igb: Bump version of driver
  2013-04-20  9:48 [net-next 00/14][pull request] Intel Wired LAN Driver Updates Jeff Kirsher
                   ` (12 preceding siblings ...)
  2013-04-20  9:49 ` [net-next 13/14] igb: Remove id's that will not be productized for Linux Jeff Kirsher
@ 2013-04-20  9:49 ` Jeff Kirsher
  13 siblings, 0 replies; 26+ messages in thread
From: Jeff Kirsher @ 2013-04-20  9:49 UTC (permalink / raw)
  To: davem; +Cc: Carolyn Wyborny, netdev, gospo, sassmann, Jeff Kirsher

From: Carolyn Wyborny <carolyn.wyborny@intel.com>

Signed-off-by: Carolyn Wyborny <carolyn.wyborny@intel.com>
Tested-by: Aaron Brown <aaron.f.brown@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
---
 drivers/net/ethernet/intel/igb/igb_main.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c
index 7eb648b..9d08604 100644
--- a/drivers/net/ethernet/intel/igb/igb_main.c
+++ b/drivers/net/ethernet/intel/igb/igb_main.c
@@ -60,9 +60,9 @@
 #include <linux/i2c.h>
 #include "igb.h"
 
-#define MAJ 4
-#define MIN 1
-#define BUILD 2
+#define MAJ 5
+#define MIN 0
+#define BUILD 3
 #define DRV_VERSION __stringify(MAJ) "." __stringify(MIN) "." \
 __stringify(BUILD) "-k"
 char igb_driver_name[] = "igb";
-- 
1.7.11.7

^ permalink raw reply related	[flat|nested] 26+ messages in thread

* Re: [net-next 08/14] pci: Add SRIOV helper function to determine if VFs are assigned to guest
  2013-04-20  9:49 ` [net-next 08/14] pci: Add SRIOV helper function to determine if VFs are assigned to guest Jeff Kirsher
@ 2013-04-21  0:54   ` David Miller
  2013-04-21  3:31   ` Jeff Kirsher
  1 sibling, 0 replies; 26+ messages in thread
From: David Miller @ 2013-04-21  0:54 UTC (permalink / raw)
  To: jeffrey.t.kirsher; +Cc: alexander.h.duyck, netdev, gospo, sassmann

From: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Date: Sat, 20 Apr 2013 02:49:07 -0700

> From: Alexander Duyck <alexander.h.duyck@intel.com>
> 
> This function is meant to add a helper function that will determine if a PF
> has any VFs that are currently assigned to a guest.  We currently have been
> implementing this function per driver, and going forward I would like to avoid
> that by making this function generic and using this helper.
> 
> Signed-off-by: Alexander Duyck <alexander.h.duyck@intel.com>
> Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>

I will need a signoff on this from one of the PCI maintainers.

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [net-next 08/14] pci: Add SRIOV helper function to determine if VFs are assigned to guest
  2013-04-20  9:49 ` [net-next 08/14] pci: Add SRIOV helper function to determine if VFs are assigned to guest Jeff Kirsher
  2013-04-21  0:54   ` David Miller
@ 2013-04-21  3:31   ` Jeff Kirsher
       [not found]     ` <20130421051423.GA4052@shangw.(null)>
  2013-04-22 20:09     ` Bjorn Helgaas
  1 sibling, 2 replies; 26+ messages in thread
From: Jeff Kirsher @ 2013-04-21  3:31 UTC (permalink / raw)
  To: davem, Bjorn Helgaas; +Cc: Alexander Duyck, netdev, gospo, sassmann, linux-pci

[-- Attachment #1: Type: text/plain, Size: 3463 bytes --]

On Sat, 2013-04-20 at 02:49 -0700, Jeff Kirsher wrote:
> From: Alexander Duyck <alexander.h.duyck@intel.com>
> 
> This function is meant to add a helper function that will determine if a PF
> has any VFs that are currently assigned to a guest.  We currently have been
> implementing this function per driver, and going forward I would like to avoid
> that by making this function generic and using this helper.
> 
> Signed-off-by: Alexander Duyck <alexander.h.duyck@intel.com>
> Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>

Adding linux-pci mailing list and Bjorn to the CC.

Bjorn- David Miller needs a signoff by PCI maintainer. 

> ---
>  drivers/pci/iov.c   | 41 +++++++++++++++++++++++++++++++++++++++++
>  include/linux/pci.h |  5 +++++
>  2 files changed, 46 insertions(+)
> 
> diff --git a/drivers/pci/iov.c b/drivers/pci/iov.c
> index ee599f2..fd99720 100644
> --- a/drivers/pci/iov.c
> +++ b/drivers/pci/iov.c
> @@ -729,6 +729,47 @@ int pci_num_vf(struct pci_dev *dev)
>  EXPORT_SYMBOL_GPL(pci_num_vf);
>  
>  /**
> + * pci_vfs_assigned - returns number of VFs are assigned to a guest
> + * @dev: the PCI device
> + *
> + * Returns number of VFs belonging to this device that are assigned to a guest.
> + * If device is not a physical function returns -ENODEV.
> + */
> +int pci_vfs_assigned(struct pci_dev *dev)
> +{
> +	struct pci_dev *vfdev;
> +	unsigned int vfs_assigned = 0;
> +	unsigned short dev_id;
> +
> +	/* only search if we are a PF */
> +	if (!dev->is_physfn)
> +		return -ENODEV;
> +
> +	/*
> +	 * determine the device ID for the VFs, the vendor ID will be the
> +	 * same as the PF so there is no need to check for that one
> +	 */
> +	pci_read_config_word(dev, dev->sriov->pos + PCI_SRIOV_VF_DID, &dev_id);
> +
> +	/* loop through all the VFs to see if we own any that are assigned */
> +	vfdev = pci_get_device(dev->vendor, dev_id, NULL);
> +	while (vfdev) {
> +		/*
> +		 * It is considered assigned if it is a virtual function with
> +		 * our dev as the physical function and the assigned bit is set
> +		 */
> +		if (vfdev->is_virtfn && (vfdev->physfn == dev) &&
> +		    (vfdev->dev_flags & PCI_DEV_FLAGS_ASSIGNED))
> +			vfs_assigned++;
> +
> +		vfdev = pci_get_device(dev->vendor, dev_id, vfdev);
> +	}
> +
> +	return vfs_assigned;
> +}
> +EXPORT_SYMBOL_GPL(pci_vfs_assigned);
> +
> +/**
>   * pci_sriov_set_totalvfs -- reduce the TotalVFs available
>   * @dev: the PCI PF device
>   * @numvfs: number that should be used for TotalVFs supported
> diff --git a/include/linux/pci.h b/include/linux/pci.h
> index 2461033a..03b4d3c 100644
> --- a/include/linux/pci.h
> +++ b/include/linux/pci.h
> @@ -1643,6 +1643,7 @@ extern int pci_enable_sriov(struct pci_dev *dev, int nr_virtfn);
>  extern void pci_disable_sriov(struct pci_dev *dev);
>  extern irqreturn_t pci_sriov_migration(struct pci_dev *dev);
>  extern int pci_num_vf(struct pci_dev *dev);
> +extern int pci_vfs_assigned(struct pci_dev *dev);
>  extern int pci_sriov_set_totalvfs(struct pci_dev *dev, u16 numvfs);
>  extern int pci_sriov_get_totalvfs(struct pci_dev *dev);
>  #else
> @@ -1661,6 +1662,10 @@ static inline int pci_num_vf(struct pci_dev *dev)
>  {
>  	return 0;
>  }
> +static inline int pci_vfs_assigned(struct pci_dev *dev)
> +{
> +	return 0;
> +}
>  static inline int pci_sriov_set_totalvfs(struct pci_dev *dev, u16 numvfs)
>  {
>  	return 0;



[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [net-next 08/14] pci: Add SRIOV helper function to determine if VFs are assigned to guest
       [not found]     ` <20130421051423.GA4052@shangw.(null)>
@ 2013-04-22 16:13       ` Alexander Duyck
  0 siblings, 0 replies; 26+ messages in thread
From: Alexander Duyck @ 2013-04-22 16:13 UTC (permalink / raw)
  To: Gavin Shan
  Cc: Jeff Kirsher, davem, Bjorn Helgaas, netdev, gospo, sassmann, linux-pci

On 04/20/2013 10:14 PM, Gavin Shan wrote:
> On Sat, Apr 20, 2013 at 08:31:28PM -0700, Jeff Kirsher wrote:
>> On Sat, 2013-04-20 at 02:49 -0700, Jeff Kirsher wrote:
>>> From: Alexander Duyck <alexander.h.duyck@intel.com>
>>>
>>> This function is meant to add a helper function that will determine if a PF
>>> has any VFs that are currently assigned to a guest.  We currently have been
>>> implementing this function per driver, and going forward I would like to avoid
>>> that by making this function generic and using this helper.
>>>
>>> Signed-off-by: Alexander Duyck <alexander.h.duyck@intel.com>
>>> Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
>> Adding linux-pci mailing list and Bjorn to the CC.
>>
>> Bjorn- David Miller needs a signoff by PCI maintainer. 
>>
>>> ---
>>>  drivers/pci/iov.c   | 41 +++++++++++++++++++++++++++++++++++++++++
>>>  include/linux/pci.h |  5 +++++
>>>  2 files changed, 46 insertions(+)
>>>
>>> diff --git a/drivers/pci/iov.c b/drivers/pci/iov.c
>>> index ee599f2..fd99720 100644
>>> --- a/drivers/pci/iov.c
>>> +++ b/drivers/pci/iov.c
>>> @@ -729,6 +729,47 @@ int pci_num_vf(struct pci_dev *dev)
>>>  EXPORT_SYMBOL_GPL(pci_num_vf);
>>>  
>>>  /**
>>> + * pci_vfs_assigned - returns number of VFs are assigned to a guest
>>> + * @dev: the PCI device
>>> + *
>>> + * Returns number of VFs belonging to this device that are assigned to a guest.
>>> + * If device is not a physical function returns -ENODEV.
>>> + */
>>> +int pci_vfs_assigned(struct pci_dev *dev)
>>> +{
>>> +	struct pci_dev *vfdev;
>>> +	unsigned int vfs_assigned = 0;
>>> +	unsigned short dev_id;
>>> +
>>> +	/* only search if we are a PF */
>>> +	if (!dev->is_physfn)
>>> +		return -ENODEV;
> I think it's more reasonable to return zero here?

I suppose that is true, it would be more in keeping with how pci_num_vf
works so I will make that change.

Thanks,

Alex

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [net-next 08/14] pci: Add SRIOV helper function to determine if VFs are assigned to guest
  2013-04-21  3:31   ` Jeff Kirsher
       [not found]     ` <20130421051423.GA4052@shangw.(null)>
@ 2013-04-22 20:09     ` Bjorn Helgaas
  2013-04-22 21:50       ` Alexander Duyck
  1 sibling, 1 reply; 26+ messages in thread
From: Bjorn Helgaas @ 2013-04-22 20:09 UTC (permalink / raw)
  To: Kirsher, Jeffrey T
  Cc: David Miller, Alexander Duyck, netdev, gospo, sassmann, linux-pci

On Sat, Apr 20, 2013 at 9:31 PM, Jeff Kirsher
<jeffrey.t.kirsher@intel.com> wrote:
> On Sat, 2013-04-20 at 02:49 -0700, Jeff Kirsher wrote:
>> From: Alexander Duyck <alexander.h.duyck@intel.com>
>>
>> This function is meant to add a helper function that will determine if a PF
>> has any VFs that are currently assigned to a guest.  We currently have been
>> implementing this function per driver, and going forward I would like to avoid
>> that by making this function generic and using this helper.
>>
>> Signed-off-by: Alexander Duyck <alexander.h.duyck@intel.com>
>> Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
>
> Adding linux-pci mailing list and Bjorn to the CC.
>
> Bjorn- David Miller needs a signoff by PCI maintainer.
>
>> ---
>>  drivers/pci/iov.c   | 41 +++++++++++++++++++++++++++++++++++++++++
>>  include/linux/pci.h |  5 +++++
>>  2 files changed, 46 insertions(+)
>>
>> diff --git a/drivers/pci/iov.c b/drivers/pci/iov.c
>> index ee599f2..fd99720 100644
>> --- a/drivers/pci/iov.c
>> +++ b/drivers/pci/iov.c
>> @@ -729,6 +729,47 @@ int pci_num_vf(struct pci_dev *dev)
>>  EXPORT_SYMBOL_GPL(pci_num_vf);
>>
>>  /**
>> + * pci_vfs_assigned - returns number of VFs are assigned to a guest
>> + * @dev: the PCI device
>> + *
>> + * Returns number of VFs belonging to this device that are assigned to a guest.
>> + * If device is not a physical function returns -ENODEV.
>> + */
>> +int pci_vfs_assigned(struct pci_dev *dev)

I guess the idea here is to replace be_find_vfs(),
igb_vfs_are_assigned(), ixgbe_vfs_are_assigned(), etc.  It does seem
good to reduce duplicated code.

I'm trying to figure out why this is safe -- there's no explicit
synchronization between the iteration through PCI devices looking for
matching VFs and the device assignment/deassignment paths that set or
clear PCI_DEV_FLAGS_ASSIGNED, so on the face of it, it looks like
things could change between calling pci_vfs_assigned() and using the
result to make a decision.

Most of the calls would be in .remove() functions, so maybe there's
some sort of synchronization in that path that  makes this safe.

Bjorn

>> +{
>> +     struct pci_dev *vfdev;
>> +     unsigned int vfs_assigned = 0;
>> +     unsigned short dev_id;
>> +
>> +     /* only search if we are a PF */
>> +     if (!dev->is_physfn)
>> +             return -ENODEV;
>> +
>> +     /*
>> +      * determine the device ID for the VFs, the vendor ID will be the
>> +      * same as the PF so there is no need to check for that one
>> +      */
>> +     pci_read_config_word(dev, dev->sriov->pos + PCI_SRIOV_VF_DID, &dev_id);
>> +
>> +     /* loop through all the VFs to see if we own any that are assigned */
>> +     vfdev = pci_get_device(dev->vendor, dev_id, NULL);
>> +     while (vfdev) {
>> +             /*
>> +              * It is considered assigned if it is a virtual function with
>> +              * our dev as the physical function and the assigned bit is set
>> +              */
>> +             if (vfdev->is_virtfn && (vfdev->physfn == dev) &&
>> +                 (vfdev->dev_flags & PCI_DEV_FLAGS_ASSIGNED))
>> +                     vfs_assigned++;
>> +
>> +             vfdev = pci_get_device(dev->vendor, dev_id, vfdev);
>> +     }
>> +
>> +     return vfs_assigned;
>> +}
>> +EXPORT_SYMBOL_GPL(pci_vfs_assigned);
>> +
>> +/**
>>   * pci_sriov_set_totalvfs -- reduce the TotalVFs available
>>   * @dev: the PCI PF device
>>   * @numvfs: number that should be used for TotalVFs supported
>> diff --git a/include/linux/pci.h b/include/linux/pci.h
>> index 2461033a..03b4d3c 100644
>> --- a/include/linux/pci.h
>> +++ b/include/linux/pci.h
>> @@ -1643,6 +1643,7 @@ extern int pci_enable_sriov(struct pci_dev *dev, int nr_virtfn);
>>  extern void pci_disable_sriov(struct pci_dev *dev);
>>  extern irqreturn_t pci_sriov_migration(struct pci_dev *dev);
>>  extern int pci_num_vf(struct pci_dev *dev);
>> +extern int pci_vfs_assigned(struct pci_dev *dev);
>>  extern int pci_sriov_set_totalvfs(struct pci_dev *dev, u16 numvfs);
>>  extern int pci_sriov_get_totalvfs(struct pci_dev *dev);
>>  #else
>> @@ -1661,6 +1662,10 @@ static inline int pci_num_vf(struct pci_dev *dev)
>>  {
>>       return 0;
>>  }
>> +static inline int pci_vfs_assigned(struct pci_dev *dev)
>> +{
>> +     return 0;
>> +}
>>  static inline int pci_sriov_set_totalvfs(struct pci_dev *dev, u16 numvfs)
>>  {
>>       return 0;
>
>

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [net-next 08/14] pci: Add SRIOV helper function to determine if VFs are assigned to guest
  2013-04-22 20:09     ` Bjorn Helgaas
@ 2013-04-22 21:50       ` Alexander Duyck
  2013-04-23 19:51         ` Greg Rose
  0 siblings, 1 reply; 26+ messages in thread
From: Alexander Duyck @ 2013-04-22 21:50 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Kirsher, Jeffrey T, David Miller, netdev, gospo, sassmann, linux-pci

On 04/22/2013 01:09 PM, Bjorn Helgaas wrote:
> On Sat, Apr 20, 2013 at 9:31 PM, Jeff Kirsher
> <jeffrey.t.kirsher@intel.com> wrote:
>> On Sat, 2013-04-20 at 02:49 -0700, Jeff Kirsher wrote:
>>> From: Alexander Duyck <alexander.h.duyck@intel.com>
>>>
>>> This function is meant to add a helper function that will determine if a PF
>>> has any VFs that are currently assigned to a guest.  We currently have been
>>> implementing this function per driver, and going forward I would like to avoid
>>> that by making this function generic and using this helper.
>>>
>>> Signed-off-by: Alexander Duyck <alexander.h.duyck@intel.com>
>>> Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
>> Adding linux-pci mailing list and Bjorn to the CC.
>>
>> Bjorn- David Miller needs a signoff by PCI maintainer.
>>
>>> ---
>>>  drivers/pci/iov.c   | 41 +++++++++++++++++++++++++++++++++++++++++
>>>  include/linux/pci.h |  5 +++++
>>>  2 files changed, 46 insertions(+)
>>>
>>> diff --git a/drivers/pci/iov.c b/drivers/pci/iov.c
>>> index ee599f2..fd99720 100644
>>> --- a/drivers/pci/iov.c
>>> +++ b/drivers/pci/iov.c
>>> @@ -729,6 +729,47 @@ int pci_num_vf(struct pci_dev *dev)
>>>  EXPORT_SYMBOL_GPL(pci_num_vf);
>>>
>>>  /**
>>> + * pci_vfs_assigned - returns number of VFs are assigned to a guest
>>> + * @dev: the PCI device
>>> + *
>>> + * Returns number of VFs belonging to this device that are assigned to a guest.
>>> + * If device is not a physical function returns -ENODEV.
>>> + */
>>> +int pci_vfs_assigned(struct pci_dev *dev)
> I guess the idea here is to replace be_find_vfs(),
> igb_vfs_are_assigned(), ixgbe_vfs_are_assigned(), etc.  It does seem
> good to reduce duplicated code.

The general idea was just to remove duplicate code.  As is we have a
couple more drivers on the way that would end up needing a similar function.

> I'm trying to figure out why this is safe -- there's no explicit
> synchronization between the iteration through PCI devices looking for
> matching VFs and the device assignment/deassignment paths that set or
> clear PCI_DEV_FLAGS_ASSIGNED, so on the face of it, it looks like
> things could change between calling pci_vfs_assigned() and using the
> result to make a decision.
>
> Most of the calls would be in .remove() functions, so maybe there's
> some sort of synchronization in that path that  makes this safe.
>
> Bjorn

I'm assuming this will be used in regions that are somehow protected
since the main spots where this might be called would be probe, remove,
or when updating the number of VFs.  From what I can tell in the Xen
case there is a driver stub that is loaded that sets the flag so that is
covered by probe/remove.  I don't know about the KVM case.

Thanks,

Alex

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [net-next 08/14] pci: Add SRIOV helper function to determine if VFs are assigned to guest
  2013-04-22 21:50       ` Alexander Duyck
@ 2013-04-23 19:51         ` Greg Rose
  2013-04-23 21:16           ` Don Dutile
  2013-04-24 20:10           ` Bjorn Helgaas
  0 siblings, 2 replies; 26+ messages in thread
From: Greg Rose @ 2013-04-23 19:51 UTC (permalink / raw)
  To: Alexander Duyck
  Cc: Bjorn Helgaas, Kirsher, Jeffrey T, David Miller, netdev, gospo,
	sassmann, linux-pci

On Mon, 22 Apr 2013 14:50:33 -0700
Alexander Duyck <alexander.h.duyck@intel.com> wrote:

> On 04/22/2013 01:09 PM, Bjorn Helgaas wrote:
> > On Sat, Apr 20, 2013 at 9:31 PM, Jeff Kirsher
> > <jeffrey.t.kirsher@intel.com> wrote:
> >> On Sat, 2013-04-20 at 02:49 -0700, Jeff Kirsher wrote:
> >>> From: Alexander Duyck <alexander.h.duyck@intel.com>
> >>>
> >>> This function is meant to add a helper function that will
> >>> determine if a PF has any VFs that are currently assigned to a
> >>> guest.  We currently have been implementing this function per
> >>> driver, and going forward I would like to avoid that by making
> >>> this function generic and using this helper.
> >>>
> >>> Signed-off-by: Alexander Duyck <alexander.h.duyck@intel.com>
> >>> Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
> >> Adding linux-pci mailing list and Bjorn to the CC.
> >>
> >> Bjorn- David Miller needs a signoff by PCI maintainer.
> >>
> >>> ---
> >>>  drivers/pci/iov.c   | 41
> >>> +++++++++++++++++++++++++++++++++++++++++ include/linux/pci.h |
> >>> 5 +++++ 2 files changed, 46 insertions(+)
> >>>
> >>> diff --git a/drivers/pci/iov.c b/drivers/pci/iov.c
> >>> index ee599f2..fd99720 100644
> >>> --- a/drivers/pci/iov.c
> >>> +++ b/drivers/pci/iov.c
> >>> @@ -729,6 +729,47 @@ int pci_num_vf(struct pci_dev *dev)
> >>>  EXPORT_SYMBOL_GPL(pci_num_vf);
> >>>
> >>>  /**
> >>> + * pci_vfs_assigned - returns number of VFs are assigned to a
> >>> guest
> >>> + * @dev: the PCI device
> >>> + *
> >>> + * Returns number of VFs belonging to this device that are
> >>> assigned to a guest.
> >>> + * If device is not a physical function returns -ENODEV.
> >>> + */
> >>> +int pci_vfs_assigned(struct pci_dev *dev)
> > I guess the idea here is to replace be_find_vfs(),
> > igb_vfs_are_assigned(), ixgbe_vfs_are_assigned(), etc.  It does seem
> > good to reduce duplicated code.
> 
> The general idea was just to remove duplicate code.  As is we have a
> couple more drivers on the way that would end up needing a similar
> function.
> 
> > I'm trying to figure out why this is safe -- there's no explicit
> > synchronization between the iteration through PCI devices looking
> > for matching VFs and the device assignment/deassignment paths that
> > set or clear PCI_DEV_FLAGS_ASSIGNED, so on the face of it, it looks
> > like things could change between calling pci_vfs_assigned() and
> > using the result to make a decision.
> >
> > Most of the calls would be in .remove() functions, so maybe there's
> > some sort of synchronization in that path that  makes this safe.
> >
> > Bjorn
> 
> I'm assuming this will be used in regions that are somehow protected
> since the main spots where this might be called would be probe,
> remove, or when updating the number of VFs.  From what I can tell in
> the Xen case there is a driver stub that is loaded that sets the flag
> so that is covered by probe/remove.  I don't know about the KVM case.

KVM should be fine.  Setting/clearing the flag occurs while a device is
being assigned to or removed from a VM - presumably device assignment
is already safe against race conditions.  I'd find it hard to believe
that it's not.  Code is in ../virt/assigned_dev.c and ../virt/iommu.c.

- Greg

> 
> Thanks,
> 
> Alex
> 
> --
> To unsubscribe from this list: send the line "unsubscribe netdev" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [net-next 08/14] pci: Add SRIOV helper function to determine if VFs are assigned to guest
  2013-04-23 19:51         ` Greg Rose
@ 2013-04-23 21:16           ` Don Dutile
  2013-04-24 20:10           ` Bjorn Helgaas
  1 sibling, 0 replies; 26+ messages in thread
From: Don Dutile @ 2013-04-23 21:16 UTC (permalink / raw)
  To: Greg Rose
  Cc: Alexander Duyck, Bjorn Helgaas, Kirsher, Jeffrey T, David Miller,
	netdev, gospo, sassmann, linux-pci, Chris Wright

On 04/23/2013 03:51 PM, Greg Rose wrote:
> On Mon, 22 Apr 2013 14:50:33 -0700
> Alexander Duyck<alexander.h.duyck@intel.com>  wrote:
>
>> On 04/22/2013 01:09 PM, Bjorn Helgaas wrote:
>>> On Sat, Apr 20, 2013 at 9:31 PM, Jeff Kirsher
>>> <jeffrey.t.kirsher@intel.com>  wrote:
>>>> On Sat, 2013-04-20 at 02:49 -0700, Jeff Kirsher wrote:
>>>>> From: Alexander Duyck<alexander.h.duyck@intel.com>
>>>>>
>>>>> This function is meant to add a helper function that will
>>>>> determine if a PF has any VFs that are currently assigned to a
>>>>> guest.  We currently have been implementing this function per
>>>>> driver, and going forward I would like to avoid that by making
>>>>> this function generic and using this helper.
>>>>>
>>>>> Signed-off-by: Alexander Duyck<alexander.h.duyck@intel.com>
>>>>> Signed-off-by: Jeff Kirsher<jeffrey.t.kirsher@intel.com>
>>>> Adding linux-pci mailing list and Bjorn to the CC.
>>>>
>>>> Bjorn- David Miller needs a signoff by PCI maintainer.
>>>>
>>>>> ---
>>>>>   drivers/pci/iov.c   | 41
>>>>> +++++++++++++++++++++++++++++++++++++++++ include/linux/pci.h |
>>>>> 5 +++++ 2 files changed, 46 insertions(+)
>>>>>
>>>>> diff --git a/drivers/pci/iov.c b/drivers/pci/iov.c
>>>>> index ee599f2..fd99720 100644
>>>>> --- a/drivers/pci/iov.c
>>>>> +++ b/drivers/pci/iov.c
>>>>> @@ -729,6 +729,47 @@ int pci_num_vf(struct pci_dev *dev)
>>>>>   EXPORT_SYMBOL_GPL(pci_num_vf);
>>>>>
>>>>>   /**
>>>>> + * pci_vfs_assigned - returns number of VFs are assigned to a
>>>>> guest
>>>>> + * @dev: the PCI device
>>>>> + *
>>>>> + * Returns number of VFs belonging to this device that are
>>>>> assigned to a guest.
>>>>> + * If device is not a physical function returns -ENODEV.
>>>>> + */
>>>>> +int pci_vfs_assigned(struct pci_dev *dev)
>>> I guess the idea here is to replace be_find_vfs(),
>>> igb_vfs_are_assigned(), ixgbe_vfs_are_assigned(), etc.  It does seem
>>> good to reduce duplicated code.
>>
>> The general idea was just to remove duplicate code.  As is we have a
>> couple more drivers on the way that would end up needing a similar
>> function.
>>
>>> I'm trying to figure out why this is safe -- there's no explicit
>>> synchronization between the iteration through PCI devices looking
>>> for matching VFs and the device assignment/deassignment paths that
>>> set or clear PCI_DEV_FLAGS_ASSIGNED, so on the face of it, it looks
>>> like things could change between calling pci_vfs_assigned() and
>>> using the result to make a decision.
>>>
>>> Most of the calls would be in .remove() functions, so maybe there's
>>> some sort of synchronization in that path that  makes this safe.
>>>
>>> Bjorn
>>
>> I'm assuming this will be used in regions that are somehow protected
>> since the main spots where this might be called would be probe,
>> remove, or when updating the number of VFs.  From what I can tell in
>> the Xen case there is a driver stub that is loaded that sets the flag
>> so that is covered by probe/remove.  I don't know about the KVM case.
>
> KVM should be fine.  Setting/clearing the flag occurs while a device is
> being assigned to or removed from a VM - presumably device assignment
> is already safe against race conditions.  I'd find it hard to believe
> that it's not.  Code is in ../virt/assigned_dev.c and ../virt/iommu.c.
>
> - Greg
>
Added Chris to this thread since he has history here...

Q: Why not link-list the VF pci-dev's off the PF's pci-dev when they are created?
    (yes, voices in my head have asked me this question in the past! ;-) )
    -- that way, finding them is easy, and locked down when doing a get on the PF pci-dev.
    a backptr of the VF's pci-dev to it's PF pci-dev would be handy too!
    --> it'd also simplify that rmmod PF driver while VF drivers loaded (& assigned)
        case as well.


>>
>> Thanks,
>>
>> Alex
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe netdev" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-pci" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [net-next 08/14] pci: Add SRIOV helper function to determine if VFs are assigned to guest
  2013-04-23 19:51         ` Greg Rose
  2013-04-23 21:16           ` Don Dutile
@ 2013-04-24 20:10           ` Bjorn Helgaas
  2013-04-24 20:18             ` David Miller
  2013-04-24 21:35             ` Greg Rose
  1 sibling, 2 replies; 26+ messages in thread
From: Bjorn Helgaas @ 2013-04-24 20:10 UTC (permalink / raw)
  To: Greg Rose
  Cc: Alexander Duyck, Kirsher, Jeffrey T, David Miller, netdev, gospo,
	sassmann, linux-pci

On Tue, Apr 23, 2013 at 1:51 PM, Greg Rose <gregory.v.rose@intel.com> wrote:
> On Mon, 22 Apr 2013 14:50:33 -0700
> Alexander Duyck <alexander.h.duyck@intel.com> wrote:
>
>> On 04/22/2013 01:09 PM, Bjorn Helgaas wrote:
>> > On Sat, Apr 20, 2013 at 9:31 PM, Jeff Kirsher
>> > <jeffrey.t.kirsher@intel.com> wrote:
>> >> On Sat, 2013-04-20 at 02:49 -0700, Jeff Kirsher wrote:
>> >>> From: Alexander Duyck <alexander.h.duyck@intel.com>
>> >>>
>> >>> This function is meant to add a helper function that will
>> >>> determine if a PF has any VFs that are currently assigned to a
>> >>> guest.  We currently have been implementing this function per
>> >>> driver, and going forward I would like to avoid that by making
>> >>> this function generic and using this helper.
>> >>>
>> >>> Signed-off-by: Alexander Duyck <alexander.h.duyck@intel.com>
>> >>> Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
>> >> Adding linux-pci mailing list and Bjorn to the CC.
>> >>
>> >> Bjorn- David Miller needs a signoff by PCI maintainer.
>> >>
>> >>> ---
>> >>>  drivers/pci/iov.c   | 41
>> >>> +++++++++++++++++++++++++++++++++++++++++ include/linux/pci.h |
>> >>> 5 +++++ 2 files changed, 46 insertions(+)
>> >>>
>> >>> diff --git a/drivers/pci/iov.c b/drivers/pci/iov.c
>> >>> index ee599f2..fd99720 100644
>> >>> --- a/drivers/pci/iov.c
>> >>> +++ b/drivers/pci/iov.c
>> >>> @@ -729,6 +729,47 @@ int pci_num_vf(struct pci_dev *dev)
>> >>>  EXPORT_SYMBOL_GPL(pci_num_vf);
>> >>>
>> >>>  /**
>> >>> + * pci_vfs_assigned - returns number of VFs are assigned to a
>> >>> guest
>> >>> + * @dev: the PCI device
>> >>> + *
>> >>> + * Returns number of VFs belonging to this device that are
>> >>> assigned to a guest.
>> >>> + * If device is not a physical function returns -ENODEV.
>> >>> + */
>> >>> +int pci_vfs_assigned(struct pci_dev *dev)
>> > I guess the idea here is to replace be_find_vfs(),
>> > igb_vfs_are_assigned(), ixgbe_vfs_are_assigned(), etc.  It does seem
>> > good to reduce duplicated code.
>>
>> The general idea was just to remove duplicate code.  As is we have a
>> couple more drivers on the way that would end up needing a similar
>> function.
>>
>> > I'm trying to figure out why this is safe -- there's no explicit
>> > synchronization between the iteration through PCI devices looking
>> > for matching VFs and the device assignment/deassignment paths that
>> > set or clear PCI_DEV_FLAGS_ASSIGNED, so on the face of it, it looks
>> > like things could change between calling pci_vfs_assigned() and
>> > using the result to make a decision.
>> >
>> > Most of the calls would be in .remove() functions, so maybe there's
>> > some sort of synchronization in that path that  makes this safe.
>> >
>> > Bjorn
>>
>> I'm assuming this will be used in regions that are somehow protected
>> since the main spots where this might be called would be probe,
>> remove, or when updating the number of VFs.  From what I can tell in
>> the Xen case there is a driver stub that is loaded that sets the flag
>> so that is covered by probe/remove.  I don't know about the KVM case.
>
> KVM should be fine.  Setting/clearing the flag occurs while a device is
> being assigned to or removed from a VM - presumably device assignment
> is already safe against race conditions.  I'd find it hard to believe
> that it's not.  Code is in ../virt/assigned_dev.c and ../virt/iommu.c.

That's not a very convincing argument :)

And I don't like having to iterate through all PCI devs in the system
to figure this out.

But this is no worse in either respect than the code it replaces, and
it's certainly better to have it all in one place, so:

Acked-by: Bjorn Helgaas <bhelgaas@google.com>

If you have a chance, you could remove the "extern" from the
declaration in include/linux/pci.h.  There's a mix there right now,
and I have a patch in the queue that removes them all.

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [net-next 08/14] pci: Add SRIOV helper function to determine if VFs are assigned to guest
  2013-04-24 20:10           ` Bjorn Helgaas
@ 2013-04-24 20:18             ` David Miller
  2013-04-24 21:40               ` Jeff Kirsher
  2013-04-24 21:35             ` Greg Rose
  1 sibling, 1 reply; 26+ messages in thread
From: David Miller @ 2013-04-24 20:18 UTC (permalink / raw)
  To: bhelgaas
  Cc: gregory.v.rose, alexander.h.duyck, jeffrey.t.kirsher, netdev,
	gospo, sassmann, linux-pci

From: Bjorn Helgaas <bhelgaas@google.com>
Date: Wed, 24 Apr 2013 14:10:38 -0600

> But this is no worse in either respect than the code it replaces, and
> it's certainly better to have it all in one place, so:
> 
> Acked-by: Bjorn Helgaas <bhelgaas@google.com>
> 
> If you have a chance, you could remove the "extern" from the
> declaration in include/linux/pci.h.  There's a mix there right now,
> and I have a patch in the queue that removes them all.

Jeff please respin your pull request with Bjorn's ACK as well as
the "extern" removal he's asking for.

Thanks.

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [net-next 08/14] pci: Add SRIOV helper function to determine if VFs are assigned to guest
  2013-04-24 20:10           ` Bjorn Helgaas
  2013-04-24 20:18             ` David Miller
@ 2013-04-24 21:35             ` Greg Rose
  1 sibling, 0 replies; 26+ messages in thread
From: Greg Rose @ 2013-04-24 21:35 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Alexander Duyck, Kirsher, Jeffrey T, David Miller, netdev, gospo,
	sassmann, linux-pci

On Wed, 24 Apr 2013 14:10:38 -0600
Bjorn Helgaas <bhelgaas@google.com> wrote:

> On Tue, Apr 23, 2013 at 1:51 PM, Greg Rose <gregory.v.rose@intel.com>
> wrote:
> > On Mon, 22 Apr 2013 14:50:33 -0700
> > Alexander Duyck <alexander.h.duyck@intel.com> wrote:
> >
> >> On 04/22/2013 01:09 PM, Bjorn Helgaas wrote:
> >> > On Sat, Apr 20, 2013 at 9:31 PM, Jeff Kirsher
> >> > <jeffrey.t.kirsher@intel.com> wrote:
> >> >> On Sat, 2013-04-20 at 02:49 -0700, Jeff Kirsher wrote:
> >> >>> From: Alexander Duyck <alexander.h.duyck@intel.com>
> >> >>>
> >> >>> This function is meant to add a helper function that will
> >> >>> determine if a PF has any VFs that are currently assigned to a
> >> >>> guest.  We currently have been implementing this function per
> >> >>> driver, and going forward I would like to avoid that by making
> >> >>> this function generic and using this helper.
> >> >>>
> >> >>> Signed-off-by: Alexander Duyck <alexander.h.duyck@intel.com>
> >> >>> Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
> >> >> Adding linux-pci mailing list and Bjorn to the CC.
> >> >>
> >> >> Bjorn- David Miller needs a signoff by PCI maintainer.
> >> >>
> >> >>> ---
> >> >>>  drivers/pci/iov.c   | 41
> >> >>> +++++++++++++++++++++++++++++++++++++++++ include/linux/pci.h |
> >> >>> 5 +++++ 2 files changed, 46 insertions(+)
> >> >>>
> >> >>> diff --git a/drivers/pci/iov.c b/drivers/pci/iov.c
> >> >>> index ee599f2..fd99720 100644
> >> >>> --- a/drivers/pci/iov.c
> >> >>> +++ b/drivers/pci/iov.c
> >> >>> @@ -729,6 +729,47 @@ int pci_num_vf(struct pci_dev *dev)
> >> >>>  EXPORT_SYMBOL_GPL(pci_num_vf);
> >> >>>
> >> >>>  /**
> >> >>> + * pci_vfs_assigned - returns number of VFs are assigned to a
> >> >>> guest
> >> >>> + * @dev: the PCI device
> >> >>> + *
> >> >>> + * Returns number of VFs belonging to this device that are
> >> >>> assigned to a guest.
> >> >>> + * If device is not a physical function returns -ENODEV.
> >> >>> + */
> >> >>> +int pci_vfs_assigned(struct pci_dev *dev)
> >> > I guess the idea here is to replace be_find_vfs(),
> >> > igb_vfs_are_assigned(), ixgbe_vfs_are_assigned(), etc.  It does
> >> > seem good to reduce duplicated code.
> >>
> >> The general idea was just to remove duplicate code.  As is we have
> >> a couple more drivers on the way that would end up needing a
> >> similar function.
> >>
> >> > I'm trying to figure out why this is safe -- there's no explicit
> >> > synchronization between the iteration through PCI devices looking
> >> > for matching VFs and the device assignment/deassignment paths
> >> > that set or clear PCI_DEV_FLAGS_ASSIGNED, so on the face of it,
> >> > it looks like things could change between calling
> >> > pci_vfs_assigned() and using the result to make a decision.
> >> >
> >> > Most of the calls would be in .remove() functions, so maybe
> >> > there's some sort of synchronization in that path that  makes
> >> > this safe.
> >> >
> >> > Bjorn
> >>
> >> I'm assuming this will be used in regions that are somehow
> >> protected since the main spots where this might be called would be
> >> probe, remove, or when updating the number of VFs.  From what I
> >> can tell in the Xen case there is a driver stub that is loaded
> >> that sets the flag so that is covered by probe/remove.  I don't
> >> know about the KVM case.
> >
> > KVM should be fine.  Setting/clearing the flag occurs while a
> > device is being assigned to or removed from a VM - presumably
> > device assignment is already safe against race conditions.  I'd
> > find it hard to believe that it's not.  Code is
> > in ../virt/assigned_dev.c and ../virt/iommu.c.
> 
> That's not a very convincing argument :)

It's been a long time since I worked on that code.  Sorry, it's the
best I've got, my memory gets real hazy on code that I haven't touched
in a year or two.  But then that's part of my argument - if it were
subject to race conditions it seems like someone would have run into it
in the last couple of years.

But my apologies for the less than convincing argument!

:)

- Greg

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [net-next 08/14] pci: Add SRIOV helper function to determine if VFs are assigned to guest
  2013-04-24 20:18             ` David Miller
@ 2013-04-24 21:40               ` Jeff Kirsher
  0 siblings, 0 replies; 26+ messages in thread
From: Jeff Kirsher @ 2013-04-24 21:40 UTC (permalink / raw)
  To: David Miller
  Cc: bhelgaas, gregory.v.rose, alexander.h.duyck, netdev, gospo,
	sassmann, linux-pci

[-- Attachment #1: Type: text/plain, Size: 756 bytes --]

On Wed, 2013-04-24 at 16:18 -0400, David Miller wrote:
> From: Bjorn Helgaas <bhelgaas@google.com>
> Date: Wed, 24 Apr 2013 14:10:38 -0600
> 
> > But this is no worse in either respect than the code it replaces, and
> > it's certainly better to have it all in one place, so:
> > 
> > Acked-by: Bjorn Helgaas <bhelgaas@google.com>
> > 
> > If you have a chance, you could remove the "extern" from the
> > declaration in include/linux/pci.h.  There's a mix there right now,
> > and I have a patch in the queue that removes them all.
> 
> Jeff please respin your pull request with Bjorn's ACK as well as
> the "extern" removal he's asking for.
> 
> Thanks.

Working on it, I will have a updated patch (and series) submitted later
tonight.

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 26+ messages in thread

end of thread, other threads:[~2013-04-24 21:40 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-04-20  9:48 [net-next 00/14][pull request] Intel Wired LAN Driver Updates Jeff Kirsher
2013-04-20  9:49 ` [net-next 01/14] ixgbe: fix possible divide by zero in ixgbe_update_itr Jeff Kirsher
2013-04-20  9:49 ` [net-next 02/14] ixgbe: add driver support for x520 OCP adapter Jeff Kirsher
2013-04-20  9:49 ` [net-next 03/14] ixgbe: rename wol_supported to more fitting wol_enabled Jeff Kirsher
2013-04-20  9:49 ` [net-next 04/14] ixgbe: add SFP+ LX module support Jeff Kirsher
2013-04-20  9:49 ` [net-next 05/14] ixgbe: add WOL support for new subdevice ID Jeff Kirsher
2013-04-20  9:49 ` [net-next 06/14] igb: SERDES loopback sigdetect bit on i210 devices Jeff Kirsher
2013-04-20  9:49 ` [net-next 07/14] igb: Add SMBI semaphore to I210/I211 Jeff Kirsher
2013-04-20  9:49 ` [net-next 08/14] pci: Add SRIOV helper function to determine if VFs are assigned to guest Jeff Kirsher
2013-04-21  0:54   ` David Miller
2013-04-21  3:31   ` Jeff Kirsher
     [not found]     ` <20130421051423.GA4052@shangw.(null)>
2013-04-22 16:13       ` Alexander Duyck
2013-04-22 20:09     ` Bjorn Helgaas
2013-04-22 21:50       ` Alexander Duyck
2013-04-23 19:51         ` Greg Rose
2013-04-23 21:16           ` Don Dutile
2013-04-24 20:10           ` Bjorn Helgaas
2013-04-24 20:18             ` David Miller
2013-04-24 21:40               ` Jeff Kirsher
2013-04-24 21:35             ` Greg Rose
2013-04-20  9:49 ` [net-next 09/14] igb: Use pci_vfs_assigned instead of igb_vfs_are_assigned Jeff Kirsher
2013-04-20  9:49 ` [net-next 10/14] igb: display a warning message when SmartSpeed works Jeff Kirsher
2013-04-20  9:49 ` [net-next 11/14] igb: Retain HW VLAN filtering while in promiscuous + VT mode Jeff Kirsher
2013-04-20  9:49 ` [net-next 12/14] igb: Remove dead code path Jeff Kirsher
2013-04-20  9:49 ` [net-next 13/14] igb: Remove id's that will not be productized for Linux Jeff Kirsher
2013-04-20  9:49 ` [net-next 14/14] igb: Bump version of driver Jeff Kirsher

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.