Skip to contentSkip to conversation

i40e/i40evf updates

PATCH New Bimmy Pujari 2 participants 31 messages Nov 8, 2016 – Nov 21, 2016

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover i40e/i40evf updates

Alan Brady adds check for msix_entries null dereference.

Alexander Duyck fixes napi_poll function to return the actual the work done.

Bimmy Pujari changes version from 1.6.21 to 1.6.25.

Carolyn Wyborny adds code for change message to only appear when extra debug info is wanted.

Filip Sadowski adds code to make driver prints log message on link speed change.

Harshitha Ramamurthy adds fix for ethtool Supported link modes.

Henry Tieman removes unreachable code, adds code to pass unknown PHY type for unknown PHYs and adds code to link LED on 1G BaseT boards.

Jacob Keller adds code to protect against NULL msix_entries and q_vectors pointers, sets broadcast promiscuous mode for each active VLAN, replaces memcpy with single memcpy call in ethtool, restores workaround for removing default MAC filter and removes code to handle dev_addr specially.

Mitch Williams adds code to simplify txd use count calculation.

 drivers/net/ethernet/intel/i40e/i40e.h             |   4 +-
 drivers/net/ethernet/intel/i40e/i40e_common.c      |  46 ++++-
 drivers/net/ethernet/intel/i40e/i40e_ethtool.c     |  50 +++--
 drivers/net/ethernet/intel/i40e/i40e_main.c        | 207 ++++++++++++++-------
 drivers/net/ethernet/intel/i40e/i40e_prototype.h   |   3 +
 drivers/net/ethernet/intel/i40e/i40e_txrx.c        |   2 +-
 drivers/net/ethernet/intel/i40e/i40e_txrx.h        |  45 +++--
 drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c |   7 +
 drivers/net/ethernet/intel/i40evf/i40e_txrx.c      |   2 +-
 drivers/net/ethernet/intel/i40evf/i40e_txrx.h      |  45 +++--
 drivers/net/ethernet/intel/i40evf/i40evf_main.c    |  28 ++-
 11 files changed, 296 insertions(+), 143 deletions(-)
Signature · 1 line
2.4.11
#1 lore raw

PATCH 1/15 i40evf: check for msix_entries null dereference

From: Alan Brady <[email protected]>

It is possible for msix_entries to be freed by a previous suspend/remove before a VF is closed. This patch fixes the issue by checking for NULL before dereferencing msix_entries and returning early in the case where it is NULL within the i40evf_close code path. Without this patch it is possible to trigger a kernel panic through NULL dereference.

Change-ID I92a2746e82533a889e25f91578eac9abd0388ae2

---
Testing-hints:
Create lots of VFs and bring themm up on the host, assign them and
the PF to namespaces, then shut the system down.

 drivers/net/ethernet/intel/i40evf/i40evf_main.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/net/ethernet/intel/i40evf/i40evf_main.c +6 -0
index f04ac36..420e545 100644
@@ -631,6 +631,9 @@ static void i40evf_free_traffic_irqs(struct i40evf_adapter *adapter)
 {
 	int vector, irq_num, q_vectors;
 
+	if (!adapter->msix_entries)
+		return;
+
 	q_vectors = adapter->num_msix_vectors - NONQ_VECS;
 
 	for (vector = 0; vector < q_vectors; vector++) {
@@ -1443,6 +1446,9 @@ static void i40evf_free_q_vectors(struct i40evf_adapter *adapter)
  **/
 void i40evf_reset_interrupt_capability(struct i40evf_adapter *adapter)
 {
+	if (!adapter->msix_entries)
+		return;
+
 	pci_disable_msix(adapter->pdev);
 	kfree(adapter->msix_entries);
 	adapter->msix_entries = NULL;
Signature · 1 line
2.4.11
#2 lore raw

PATCH 1/15 i40evf: check for msix_entries null dereference

Quoted 19 lines

-----Original Message-----
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at lists.osuosl.org] On Behalf Of Bimmy Pujari
Sent: Tuesday, November 08, 2016 1:05 PM
To: intel-wired-lan at lists.osuosl.org
Cc: Brady, Alan <[email protected]>
Subject: [Intel-wired-lan] [next PATCH S52-V2 01/15] i40evf: check for msix_entries null dereference

From: Alan Brady <[email protected]>

It is possible for msix_entries to be freed by a previous suspend/remove before a VF is closed. This patch fixes the issue by checking for NULL before dereferencing msix_entries and returning early in the case where it is NULL within the i40evf_close code path. Without this patch it is possible to trigger a kernel panic through NULL dereference.

Change-ID I92a2746e82533a889e25f91578eac9abd0388ae2
Quoted 7 lines

---
Testing-hints:
Create lots of VFs and bring themm up on the host, assign them and the PF
to namespaces, then shut the system down.

 drivers/net/ethernet/intel/i40evf/i40evf_main.c | 6 ++++++
 1 file changed, 6 insertions(+)

Was able to shut system down with many VFs assigned to namespaces, no kernel panic

#3 lore raw

PATCH 2/15 i40e: Remove unreachable code

In reply to Bimmy Pujari

From: Henry Tieman <[email protected]>

The code at the end of i40e_read_phy_register_clause22() contained unreachable code and redundant control statements.

This change removes the unreachable code. And deletes the redundant goto statement and if statement.

Change-ID I713032b1585396f40f903cbcfdea987abd874400

---
Testing Hints:
Found by static analysis. Test by code inspection.

 drivers/net/ethernet/intel/i40e/i40e_common.c | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)
drivers/net/ethernet/intel/i40e/i40e_common.c +1 -8
index 4672bf1..b0358c0 100644
@@ -4439,19 +4439,12 @@ i40e_status i40e_read_phy_register_clause22(struct i40e_hw *hw, u16 reg,
 	if (status) {
 		i40e_debug(hw, I40E_DEBUG_PHY,
 			   "PHY: Can't write command to external PHY.\n");
-		goto phy_read_end;
-	}
-
-	if (!status) {
+	} else {
 		command = rd32(hw, I40E_GLGEN_MSRWD(port_num));
 		*value = (command & I40E_GLGEN_MSRWD_MDIRDDATA_MASK) >>
 			 I40E_GLGEN_MSRWD_MDIRDDATA_SHIFT;
-	} else {
-		i40e_debug(hw, I40E_DEBUG_PHY,
-			   "PHY: Can't read register value from external PHY.\n");
 	}
 
-phy_read_end:
 	return status;
 }
 
Signature · 1 line
2.4.11
#4 lore raw

PATCH 2/15 i40e: Remove unreachable code

Quoted 17 lines

-----Original Message-----
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at lists.osuosl.org] On Behalf Of Bimmy Pujari
Sent: Tuesday, November 08, 2016 1:05 PM
To: intel-wired-lan at lists.osuosl.org
Cc: Tieman, Henry W <[email protected]>
Subject: [Intel-wired-lan] [next PATCH S52-V2 02/15] i40e: Remove unreachable code

From: Henry Tieman <[email protected]>

The code at the end of i40e_read_phy_register_clause22() contained unreachable code and redundant control statements.

This change removes the unreachable code. And deletes the redundant goto statement and if statement.

Quoted 8 lines
Change-ID I713032b1585396f40f903cbcfdea987abd874400

---
Testing Hints:
Found by static analysis. Test by code inspection.

 drivers/net/ethernet/intel/i40e/i40e_common.c | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)

Code changes properly applied

#5 lore raw

PATCH 3/15 i40e: Pass unknown PHY type for unknown PHYs

In reply to Bimmy Pujari

From: Henry Tieman <[email protected]>

The PHY type value for unrecognized PHYs and cables was changed based on firmware version number. Newer hardware use lower firmware version numbers and this was causing some PHYs to be identified as type 0x16 instead of 0xe (unknown).

Without this patch, newer card will incorrectly identify unknown PHYs and cables.

This change adds hardware type to the check for firmware version so the PHY type is reported correctly.

Change-ID I0723cbfd263c76fc73ff1a5275d1639051376c9a
---
 drivers/net/ethernet/intel/i40e/i40e_common.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/ethernet/intel/i40e/i40e_common.c +2 -1
index b0358c0..33bcf23 100644
@@ -1854,7 +1854,8 @@ i40e_status i40e_aq_get_link_info(struct i40e_hw *hw,
 	else
 		hw_link_info->lse_enable = false;
 
-	if ((hw->aq.fw_maj_ver < 4 || (hw->aq.fw_maj_ver == 4 &&
+	if ((hw->mac.type == I40E_MAC_XL710) &&
+	    (hw->aq.fw_maj_ver < 4 || (hw->aq.fw_maj_ver == 4 &&
 	     hw->aq.fw_min_ver < 40)) && hw_link_info->phy_type == 0xE)
 		hw_link_info->phy_type = I40E_PHY_TYPE_10GBASE_SFPP_CU;
 
Signature · 1 line
2.4.11
#6 lore raw

PATCH 3/15 i40e: Pass unknown PHY type for unknown PHYs

Quoted 19 lines

-----Original Message-----
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at lists.osuosl.org] On Behalf Of Bimmy Pujari
Sent: Tuesday, November 08, 2016 1:05 PM
To: intel-wired-lan at lists.osuosl.org
Cc: Tieman, Henry W <[email protected]>
Subject: [Intel-wired-lan] [next PATCH S52-V2 03/15] i40e: Pass unknown PHY type for unknown PHYs

From: Henry Tieman <[email protected]>

The PHY type value for unrecognized PHYs and cables was changed based on firmware version number. Newer hardware use lower firmware version numbers and this was causing some PHYs to be identified as type 0x16 instead of 0xe (unknown).

Without this patch, newer card will incorrectly identify unknown PHYs and cables.

Quoted 8 lines

This change adds hardware type to the check for firmware version so the PHY type is reported correctly.

Change-ID I0723cbfd263c76fc73ff1a5275d1639051376c9a
---
 drivers/net/ethernet/intel/i40e/i40e_common.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
#7 lore raw

PATCH 4/15 i40evf: protect against NULL msix_entries and q_vectors pointers

In reply to Bimmy Pujari

From: Jacob Keller <[email protected]>

Update the functions which free msix_entries and q_vectors so that they are safe against NULL values. This allows calling code to not care whether these have already been freed when disabling and freeing them.

Change-ID I31bfd1c0da18023d971b618edc6fb049721f3298
---
 drivers/net/ethernet/intel/i40evf/i40evf_main.c | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)
drivers/net/ethernet/intel/i40evf/i40evf_main.c +14 -6
index 420e545..ca85021 100644
@@ -207,6 +207,9 @@ static void i40evf_misc_irq_disable(struct i40evf_adapter *adapter)
 {
 	struct i40e_hw *hw = &adapter->hw;
 
+	if (!adapter->msix_entries)
+		return;
+
 	wr32(hw, I40E_VFINT_DYN_CTL01, 0);
 
 	/* read flush */
@@ -654,6 +657,9 @@ static void i40evf_free_misc_irq(struct i40evf_adapter *adapter)
 {
 	struct net_device *netdev = adapter->netdev;
 
+	if (!adapter->msix_entries)
+		return;
+
 	free_irq(adapter->msix_entries[0].vector, netdev);
 }
 
@@ -1428,6 +1434,9 @@ static void i40evf_free_q_vectors(struct i40evf_adapter *adapter)
 	int q_idx, num_q_vectors;
 	int napi_vectors;
 
+	if (!adapter->q_vectors)
+		return;
+
 	num_q_vectors = adapter->num_msix_vectors - NONQ_VECS;
 	napi_vectors = adapter->num_active_queues;
 
@@ -1437,6 +1446,7 @@ static void i40evf_free_q_vectors(struct i40evf_adapter *adapter)
 			netif_napi_del(&q_vector->napi);
 	}
 	kfree(adapter->q_vectors);
+	adapter->q_vectors = NULL;
 }
 
 /**
@@ -2862,12 +2872,10 @@ static void i40evf_remove(struct pci_dev *pdev)
 		msleep(50);
 	}
 
-	if (adapter->msix_entries) {
-		i40evf_misc_irq_disable(adapter);
-		i40evf_free_misc_irq(adapter);
-		i40evf_reset_interrupt_capability(adapter);
-		i40evf_free_q_vectors(adapter);
-	}
+	i40evf_misc_irq_disable(adapter);
+	i40evf_free_misc_irq(adapter);
+	i40evf_reset_interrupt_capability(adapter);
+	i40evf_free_q_vectors(adapter);
 
 	if (adapter->watchdog_timer.function)
 		del_timer_sync(&adapter->watchdog_timer);
Signature · 1 line
2.4.11
#8 lore raw

PATCH 4/15 i40evf: protect against NULL msix_entries and q_vectors pointers

Quoted 14 lines

-----Original Message-----
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at lists.osuosl.org] On Behalf Of Bimmy Pujari
Sent: Tuesday, November 08, 2016 1:05 PM
To: intel-wired-lan at lists.osuosl.org
Subject: [Intel-wired-lan] [next PATCH S52-V2 04/15] i40evf: protect against NULL msix_entries and q_vectors pointers

From: Jacob Keller <[email protected]>

Update the functions which free msix_entries and q_vectors so that they are safe against NULL values. This allows calling code to not care whether these have already been freed when disabling and freeing them.

Quoted 6 lines
Change-ID I31bfd1c0da18023d971b618edc6fb049721f3298
---
 drivers/net/ethernet/intel/i40evf/i40evf_main.c | 20 ++++++++++++++-----
-
 1 file changed, 14 insertions(+), 6 deletions(-)
#9 lore raw

PATCH 5/15 i40e: Fix for ethtool Supported link modes

In reply to Bimmy Pujari

From: Harshitha Ramamurthy <[email protected]>

This patch fixes the problem where the ethtool Supported link modes list backplane interfaces on X722 devices for 10GbE with SFP+ and Cortina retimer. This patch fixes the problem by setting and using a flag for this particular device since the backplane interface is only between the internal PHY and the retimer and it should not be seen by the user as they cannont use it. Without this patch, the user wrongly thinks that backplane interfaces are supported on their device when they actually are not.

Change-ID I3882bc2928431d48a2db03a51a713a1f681a79e9
---
 drivers/net/ethernet/intel/i40e/i40e.h         |  1 +
 drivers/net/ethernet/intel/i40e/i40e_ethtool.c | 16 ++++++++++------
 drivers/net/ethernet/intel/i40e/i40e_main.c    |  3 ++-
 3 files changed, 13 insertions(+), 7 deletions(-)
drivers/net/ethernet/intel/i40e/i40e.h +1 -0
index 29c2318..4cb8fb3 100644
@@ -359,6 +359,7 @@ struct i40e_pf {
 #define I40E_FLAG_HAVE_10GBASET_PHY		BIT_ULL(48)
 #define I40E_FLAG_PF_MAC			BIT_ULL(50)
 #define I40E_FLAG_TRUE_PROMISC_SUPPORT		BIT_ULL(51)
+#define I40E_FLAG_HAVE_CRT_RETIMER		BIT_ULL(52)
 
 	/* tracks features that get auto disabled by errors */
 	u64 auto_disable_flags;
drivers/net/ethernet/intel/i40e/i40e_ethtool.c +10 -6
index 92a2f03..9500e7b 100644
@@ -345,11 +345,13 @@ static void i40e_phy_type_to_ethtool(struct i40e_pf *pf, u32 *supported,
 			*advertising |= ADVERTISED_20000baseKR2_Full;
 	}
 	if (phy_types & I40E_CAP_PHY_TYPE_10GBASE_KR) {
-		*supported |= SUPPORTED_10000baseKR_Full |
-			      SUPPORTED_Autoneg;
+		if (!(pf->flags & I40E_FLAG_HAVE_CRT_RETIMER))
+			*supported |= SUPPORTED_10000baseKR_Full |
+				      SUPPORTED_Autoneg;
 		*advertising |= ADVERTISED_Autoneg;
 		if (hw_link_info->requested_speeds & I40E_LINK_SPEED_10GB)
-			*advertising |= ADVERTISED_10000baseKR_Full;
+			if (!(pf->flags & I40E_FLAG_HAVE_CRT_RETIMER))
+				*advertising |= ADVERTISED_10000baseKR_Full;
 	}
 	if (phy_types & I40E_CAP_PHY_TYPE_10GBASE_KX4) {
 		*supported |= SUPPORTED_10000baseKX4_Full |
@@ -359,11 +361,13 @@ static void i40e_phy_type_to_ethtool(struct i40e_pf *pf, u32 *supported,
 			*advertising |= ADVERTISED_10000baseKX4_Full;
 	}
 	if (phy_types & I40E_CAP_PHY_TYPE_1000BASE_KX) {
-		*supported |= SUPPORTED_1000baseKX_Full |
-			      SUPPORTED_Autoneg;
+		if (!(pf->flags & I40E_FLAG_HAVE_CRT_RETIMER))
+			*supported |= SUPPORTED_1000baseKX_Full |
+				      SUPPORTED_Autoneg;
 		*advertising |= ADVERTISED_Autoneg;
 		if (hw_link_info->requested_speeds & I40E_LINK_SPEED_1GB)
-			*advertising |= ADVERTISED_1000baseKX_Full;
+			if (!(pf->flags & I40E_FLAG_HAVE_CRT_RETIMER))
+				*advertising |= ADVERTISED_1000baseKX_Full;
 	}
 }
 
drivers/net/ethernet/intel/i40e/i40e_main.c +2 -1
index bae168c..3886119 100644
@@ -11290,7 +11290,8 @@ static int i40e_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 	if ((pf->hw.device_id == I40E_DEV_ID_10G_BASE_T) ||
 	    (pf->hw.device_id == I40E_DEV_ID_10G_BASE_T4))
 		pf->flags |= I40E_FLAG_HAVE_10GBASET_PHY;
-
+	if (pf->hw.device_id == I40E_DEV_ID_SFP_I_X722)
+		pf->flags |= I40E_FLAG_HAVE_CRT_RETIMER;
 	/* print a string summarizing features */
 	i40e_print_features(pf);
 
Signature · 1 line
2.4.11
#10 lore raw

PATCH 5/15 i40e: Fix for ethtool Supported link modes

Quoted 19 lines

-----Original Message-----
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at lists.osuosl.org] On Behalf Of Bimmy Pujari
Sent: Tuesday, November 08, 2016 1:05 PM
To: intel-wired-lan at lists.osuosl.org
Subject: [Intel-wired-lan] [next PATCH S52-V2 05/15] i40e: Fix for ethtool Supported link modes

From: Harshitha Ramamurthy <[email protected]>

This patch fixes the problem where the ethtool Supported link modes list backplane interfaces on X722 devices for 10GbE with
SFP+ and Cortina retimer. This patch fixes the problem by setting and using a flag for this particular device since the backplane interface is only between the internal PHY and the retimer and it should not be seen by the user as they cannont use it.
Without this patch, the user wrongly thinks that backplane interfaces are supported on their device when they actually are not.

Quoted 7 lines
Change-ID I3882bc2928431d48a2db03a51a713a1f681a79e9
---
 drivers/net/ethernet/intel/i40e/i40e.h         |  1 +
 drivers/net/ethernet/intel/i40e/i40e_ethtool.c | 16 ++++++++++------
 drivers/net/ethernet/intel/i40e/i40e_main.c    |  3 ++-
 3 files changed, 13 insertions(+), 7 deletions(-)

Ethtool no longer shows backplane for X722 with 10GbE SFP+

#11 lore raw

PATCH 6/15 i40e: set broadcast promiscuous mode for each active VLAN

In reply to Bimmy Pujari

From: Jacob Keller <[email protected]>

A previous workaround added to ensure receipt of all broadcast frames incorrectly set the broadcast promiscuous mode unconditionally regardless of active VLAN status.

Replace this partial workaround with a complete solution that sets the broadcast promiscuous filters in i40e_sync_vsi_filters. This new method sets the promiscuous mode based on when broadcast filters are added or removed.

I40E_VLAN_ANY will request a broadcast filter for all VLANs, (as we're in untagged mode) while a broadcast filter on a specific VLAN will only request broadcast for that VLAN.

Thus, we restore addition of broadcast filter to the array, but we add special handling for these such that they enable the broadcast promiscuous mode instead of being sent as regular filters.

The end result is that we will correctly receive all broadcast packets (even those with a *source* address equal to the broadcast address) but will not receive packets for which we don't have an active VLAN filter.

Change-ID I7d0585c5cec1a5bf55bf533b42e5e817d5db6a2d

---
Testing-hints:
Ensure that we do not receive broadcast packets for VLANs which are not configured. That is, when we no VLANs configured we need to receive broadcast packets on all VLANs. When we have added a VLAN filter, we need to receive broadcasts only on VID=0 and any active VLANs, but *not* any in-actve VLANs.

Additionally we need to ensure that we do not break the receipt of broadcast filters with a *source* address equal to the broadcast address. This can be tested using scapy or similar tools. Ensure that these packets follow the same receipt rules as above.

Additionally it may be worth checking whether adding many VLANs rapidly does not cause any driver stability issues and that the broadcast packets are still correctly received.

 drivers/net/ethernet/intel/i40e/i40e_common.c      |  34 +++++++
 drivers/net/ethernet/intel/i40e/i40e_main.c        | 106 +++++++++++++++++----
 drivers/net/ethernet/intel/i40e/i40e_prototype.h   |   3 +
 drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c |   7 ++
 4 files changed, 129 insertions(+), 21 deletions(-)
drivers/net/ethernet/intel/i40e/i40e_common.c +34 -0
index 33bcf23..d1dcd4f 100644
@@ -2170,6 +2170,40 @@ enum i40e_status_code i40e_aq_set_vsi_uc_promisc_on_vlan(struct i40e_hw *hw,
 }
 
 /**
+ * i40e_aq_set_vsi_bc_promisc_on_vlan
+ * @hw: pointer to the hw struct
+ * @seid: vsi number
+ * @enable: set broadcast promiscuous enable/disable for a given VLAN
+ * @vid: The VLAN tag filter - capture any broadcast packet with this VLAN tag
+ * @cmd_details: pointer to command details structure or NULL
+ **/
+i40e_status i40e_aq_set_vsi_bc_promisc_on_vlan(struct i40e_hw *hw,
+				u16 seid, bool enable, u16 vid,
+				struct i40e_asq_cmd_details *cmd_details)
+{
+	struct i40e_aq_desc desc;
+	struct i40e_aqc_set_vsi_promiscuous_modes *cmd =
+		(struct i40e_aqc_set_vsi_promiscuous_modes *)&desc.params.raw;
+	i40e_status status;
+	u16 flags = 0;
+
+	i40e_fill_default_direct_cmd_desc(&desc,
+					i40e_aqc_opc_set_vsi_promiscuous_modes);
+
+	if (enable)
+		flags |= I40E_AQC_SET_VSI_PROMISC_BROADCAST;
+
+	cmd->promiscuous_flags = cpu_to_le16(flags);
+	cmd->valid_flags = cpu_to_le16(I40E_AQC_SET_VSI_PROMISC_BROADCAST);
+	cmd->seid = cpu_to_le16(seid);
+	cmd->vlan_tag = cpu_to_le16(vid | I40E_AQC_SET_VSI_VLAN_VALID);
+
+	status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details);
+
+	return status;
+}
+
+/**
  * i40e_aq_set_vsi_broadcast
  * @hw: pointer to the hw struct
  * @seid: vsi number
drivers/net/ethernet/intel/i40e/i40e_main.c +85 -21

159 lines not on this page · raw message

drivers/net/ethernet/intel/i40e/i40e_prototype.h +3 -0
index b1bf64e..4e641a6 100644
@@ -144,6 +144,9 @@ enum i40e_status_code i40e_aq_set_vsi_uc_promisc_on_vlan(struct i40e_hw *hw,
 							 u16 seid, bool enable,
 							 u16 vid,
 				struct i40e_asq_cmd_details *cmd_details);
+i40e_status i40e_aq_set_vsi_bc_promisc_on_vlan(struct i40e_hw *hw,
+				u16 seid, bool enable, u16 vid,
+				struct i40e_asq_cmd_details *cmd_details);
 i40e_status i40e_aq_set_vsi_vlan_promisc(struct i40e_hw *hw,
 				u16 seid, bool enable,
 				struct i40e_asq_cmd_details *cmd_details);
drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c +7 -0
index 46908c0..05ed49b 100644
@@ -674,6 +674,7 @@ static int i40e_alloc_vsi_res(struct i40e_vf *vf, enum i40e_vsi_type type)
 	}
 	if (type == I40E_VSI_SRIOV) {
 		u64 hena = i40e_pf_get_default_rss_hena(pf);
+		u8 broadcast[ETH_ALEN];
 
 		vf->lan_vsi_idx = vsi->idx;
 		vf->lan_vsi_id = vsi->id;
@@ -696,6 +697,12 @@ static int i40e_alloc_vsi_res(struct i40e_vf *vf, enum i40e_vsi_type type)
 					 "Could not add MAC filter %pM for VF %d\n",
 					vf->default_lan_addr.addr, vf->vf_id);
 		}
+		eth_broadcast_addr(broadcast);
+		f = i40e_add_filter(vsi, broadcast,
+				    vf->port_vlan_id ? vf->port_vlan_id : -1);
+		if (!f)
+			dev_info(&pf->pdev->dev,
+				 "Could not allocate VF broadcast filter\n");
 		spin_unlock_bh(&vsi->mac_filter_hash_lock);
 		i40e_write_rx_ctl(&pf->hw, I40E_VFQF_HENA1(0, vf->vf_id),
 				  (u32)hena);
Signature · 1 line
2.4.11
#12 lore raw

PATCH 6/15 i40e: set broadcast promiscuous mode for each active VLAN

Quoted 50 lines

-----Original Message-----
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at lists.osuosl.org] On Behalf Of Bimmy Pujari
Sent: Tuesday, November 08, 2016 1:05 PM
To: intel-wired-lan at lists.osuosl.org
Subject: [Intel-wired-lan] [next PATCH S52-V2 06/15] i40e: set broadcast promiscuous mode for each active VLAN

From: Jacob Keller <[email protected]>

A previous workaround added to ensure receipt of all broadcast frames incorrectly set the broadcast promiscuous mode unconditionally regardless of active VLAN status.

Replace this partial workaround with a complete solution that sets the broadcast promiscuous filters in i40e_sync_vsi_filters. This new method sets the promiscuous mode based on when broadcast filters are added or removed.

I40E_VLAN_ANY will request a broadcast filter for all VLANs, (as we're in untagged mode) while a broadcast filter on a specific VLAN will only request broadcast for that VLAN.

Thus, we restore addition of broadcast filter to the array, but we add special handling for these such that they enable the broadcast promiscuous mode instead of being sent as regular filters.

The end result is that we will correctly receive all broadcast packets (even those with a *source* address equal to the broadcast address) but will not receive packets for which we don't have an active VLAN filter.

Change-ID I7d0585c5cec1a5bf55bf533b42e5e817d5db6a2d

---
Testing-hints:
Ensure that we do not receive broadcast packets for VLANs which are not configured. That is, when we no VLANs configured we need to receive broadcast packets on all VLANs. When we have added a VLAN filter, we need to receive broadcasts only on VID=0 and any active VLANs, but *not* any in-actve VLANs.

Additionally we need to ensure that we do not break the receipt of broadcast filters with a *source* address equal to the broadcast address. This can be tested using scapy or similar tools. Ensure that these packets follow the same receipt rules as above.

Additionally it may be worth checking whether adding many VLANs rapidly does not cause any driver stability issues and that the broadcast packets are still correctly received.

Quoted 6 lines
 drivers/net/ethernet/intel/i40e/i40e_common.c      |  34 +++++++
 drivers/net/ethernet/intel/i40e/i40e_main.c        | 106
+++++++++++++++++----
 drivers/net/ethernet/intel/i40e/i40e_prototype.h   |   3 +
 drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c |   7 ++
 4 files changed, 129 insertions(+), 21 deletions(-)
#13 lore raw

PATCH 7/15 i40e/i40evf: replace for memcpy with single memcpy call in ethtool

In reply to Bimmy Pujari

From: Jacob Keller <[email protected]>

memcpy replaced with single memcpy call in ethtool.

Change-ID I3f5bef6bcc593412c56592c6459784db41575a0a
---
 drivers/net/ethernet/intel/i40e/i40e_ethtool.c | 24 ++++++++----------------
 1 file changed, 8 insertions(+), 16 deletions(-)
drivers/net/ethernet/intel/i40e/i40e_ethtool.c +8 -16
index 9500e7b..76753e1 100644
@@ -1536,10 +1536,8 @@ static void i40e_get_strings(struct net_device *netdev, u32 stringset,
 
 	switch (stringset) {
 	case ETH_SS_TEST:
-		for (i = 0; i < I40E_TEST_LEN; i++) {
-			memcpy(data, i40e_gstrings_test[i], ETH_GSTRING_LEN);
-			data += ETH_GSTRING_LEN;
-		}
+		memcpy(data, i40e_gstrings_test,
+		       I40E_TEST_LEN * ETH_GSTRING_LEN);
 		break;
 	case ETH_SS_STATS:
 		for (i = 0; i < I40E_NETDEV_STATS_LEN; i++) {
@@ -1623,18 +1621,12 @@ static void i40e_get_strings(struct net_device *netdev, u32 stringset,
 		/* BUG_ON(p - data != I40E_STATS_LEN * ETH_GSTRING_LEN); */
 		break;
 	case ETH_SS_PRIV_FLAGS:
-		for (i = 0; i < I40E_PRIV_FLAGS_STR_LEN; i++) {
-			memcpy(data, i40e_priv_flags_strings[i],
-			       ETH_GSTRING_LEN);
-			data += ETH_GSTRING_LEN;
-		}
-		if (pf->hw.pf_id == 0) {
-			for (i = 0; i < I40E_GL_PRIV_FLAGS_STR_LEN; i++) {
-				memcpy(data, i40e_gl_priv_flags_strings[i],
-				       ETH_GSTRING_LEN);
-				data += ETH_GSTRING_LEN;
-			}
-		}
+		memcpy(data, i40e_priv_flags_strings,
+		       I40E_PRIV_FLAGS_STR_LEN * ETH_GSTRING_LEN);
+		data += I40E_PRIV_FLAGS_STR_LEN * ETH_GSTRING_LEN;
+		if (pf->hw.pf_id == 0)
+			memcpy(data, i40e_gl_priv_flags_strings,
+			       I40E_GL_PRIV_FLAGS_STR_LEN * ETH_GSTRING_LEN);
 		break;
 	default:
 		break;
Signature · 1 line
2.4.11
#14 lore raw

PATCH 7/15 i40e/i40evf: replace for memcpy with single memcpy call in ethtool

Quoted 10 lines

-----Original Message-----
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at lists.osuosl.org] On Behalf Of Bimmy Pujari
Sent: Tuesday, November 08, 2016 1:05 PM
To: intel-wired-lan at lists.osuosl.org
Subject: [Intel-wired-lan] [next PATCH S52-V2 07/15] i40e/i40evf: replace for memcpy with single memcpy call in ethtool

From: Jacob Keller <[email protected]>

Quoted 7 lines

memcpy replaced with single memcpy call in ethtool.

Change-ID I3f5bef6bcc593412c56592c6459784db41575a0a
---
 drivers/net/ethernet/intel/i40e/i40e_ethtool.c | 24 ++++++++----------------
 1 file changed, 8 insertions(+), 16 deletions(-)
#15 lore raw

PATCH 8/15 i40e: change message to only appear when extra debug info is wanted

In reply to Bimmy Pujari

From: Carolyn Wyborny <[email protected]>

This patch changes an X722 informational message so that it only appears when extra messages are desired. Without this patch, on X722 devices, this message appears at load, potentially causing unnecessary alarm.

Change-ID I94f7aae15dc5b2723cc9728c630c72538a3e670e

---
Testing Hints : "cleared PE_CRITERR message
should no longer appear.

 drivers/net/ethernet/intel/i40e/i40e_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/intel/i40e/i40e_main.c +1 -1
index 8187d32..548cbe0 100644
@@ -3567,7 +3567,7 @@ static irqreturn_t i40e_intr(int irq, void *data)
 	    (ena_mask & I40E_PFINT_ICR0_ENA_PE_CRITERR_MASK)) {
 		ena_mask &= ~I40E_PFINT_ICR0_ENA_PE_CRITERR_MASK;
 		icr0 &= ~I40E_PFINT_ICR0_ENA_PE_CRITERR_MASK;
-		dev_info(&pf->pdev->dev, "cleared PE_CRITERR\n");
+		dev_dbg(&pf->pdev->dev, "cleared PE_CRITERR\n");
 	}
 
 	/* only q0 is used in MSI/Legacy mode, and none are used in MSIX */
Signature · 1 line
2.4.11
#16 lore raw

PATCH 8/15 i40e: change message to only appear when extra debug info is wanted

Quoted 14 lines

-----Original Message-----
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at lists.osuosl.org] On Behalf Of Bimmy Pujari
Sent: Tuesday, November 08, 2016 1:05 PM
To: intel-wired-lan at lists.osuosl.org
Subject: [Intel-wired-lan] [next PATCH S52-V2 08/15] i40e: change message to only appear when extra debug info is wanted

From: Carolyn Wyborny <[email protected]>

This patch changes an X722 informational message so that it only appears when extra messages are desired. Without this patch, on X722 devices, this message appears at load, potentially causing unnecessary alarm.

Quoted 7 lines
Change-ID I94f7aae15dc5b2723cc9728c630c72538a3e670e

---
Testing Hints : "cleared PE_CRITERR message should no longer appear.

 drivers/net/ethernet/intel/i40e/i40e_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Message no longer appears on init

#17 lore raw

PATCH 9/15 i40e: Driver prints log message on link speed change

In reply to Bimmy Pujari

From: Filip Sadowski <[email protected]>

This patch makes the driver log link speed change. Before applying the patch link messages were printed only on state change. Now message is printed when link is brought up or down and when speed changes.

Change-ID Ifbee14b4b16c24967450b3cecac6e8351dcc8f74

---
Testing-hints:
Check that link message is logged in system log when link speed changes. Use lanconf and a device with backplane NVM image.

 drivers/net/ethernet/intel/i40e/i40e.h      | 1 +
 drivers/net/ethernet/intel/i40e/i40e_main.c | 6 +++++-
 2 files changed, 6 insertions(+), 1 deletion(-)
drivers/net/ethernet/intel/i40e/i40e.h +1 -0
index 4cb8fb3..06e3c23 100644
@@ -596,6 +596,7 @@ struct i40e_vsi {
 	u16 veb_idx;		/* index of VEB parent */
 	struct kobject *kobj;	/* sysfs object */
 	bool current_isup;	/* Sync 'link up' logging */
+	enum i40e_aq_link_speed current_speed;	/* Sync link speed logging */
 
 	void *priv;	/* client driver data reference. */
 
drivers/net/ethernet/intel/i40e/i40e_main.c +5 -1
index 548cbe0..161f512 100644
@@ -5213,12 +5213,16 @@ static int i40e_init_pf_dcb(struct i40e_pf *pf)
  */
 void i40e_print_link_message(struct i40e_vsi *vsi, bool isup)
 {
+	enum i40e_aq_link_speed new_speed;
 	char *speed = "Unknown";
 	char *fc = "Unknown";
 
-	if (vsi->current_isup == isup)
+	new_speed = vsi->back->hw.phy.link_info.link_speed;
+
+	if ((vsi->current_isup == isup) && (vsi->current_speed == new_speed))
 		return;
 	vsi->current_isup = isup;
+	vsi->current_speed = new_speed;
 	if (!isup) {
 		netdev_info(vsi->netdev, "NIC Link is Down\n");
 		return;
Signature · 1 line
2.4.11
#18 lore raw

PATCH 9/15 i40e: Driver prints log message on link speed change

Quoted 17 lines

-----Original Message-----
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at lists.osuosl.org] On Behalf Of Bimmy Pujari
Sent: Tuesday, November 08, 2016 1:05 PM
To: intel-wired-lan at lists.osuosl.org
Cc: Sadowski, Filip <[email protected]>
Subject: [Intel-wired-lan] [next PATCH S52-V2 09/15] i40e: Driver prints log message on link speed change

From: Filip Sadowski <[email protected]>

This patch makes the driver log link speed change. Before applying the patch link messages were printed only on state change. Now message is printed when link is brought up or down and when speed changes.

Change-ID Ifbee14b4b16c24967450b3cecac6e8351dcc8f74
Quoted 8 lines

---
Testing-hints:
Check that link message is logged in system log when link speed changes. Use lanconf and a device with backplane NVM image.

 drivers/net/ethernet/intel/i40e/i40e.h      | 1 +
 drivers/net/ethernet/intel/i40e/i40e_main.c | 6 +++++-
 2 files changed, 6 insertions(+), 1 deletion(-)
#19 lore raw

PATCH 10/15 i40e: simplify txd use count calculation

In reply to Bimmy Pujari

From: Mitch Williams <[email protected]>

The i40e_txd_use_count function was fast but confusing. In the comments, it even admits that it's ugly. So replace it with a new function that is (very) slightly faster and has extensive commenting to help the thicker among us (including the author, who will forget in a week) understand how it works.

Change-ID Ifb533f13786a0bf39cb29f77969a5be2c83d9a87

---
Testing Hints : Lots and lots of TSO with various
data sizes. This should operate exactly as before, with no noticeable performance change.

 drivers/net/ethernet/intel/i40e/i40e_txrx.h   | 45 +++++++++++++++++----------
 drivers/net/ethernet/intel/i40evf/i40e_txrx.h | 45 +++++++++++++++++----------
 2 files changed, 56 insertions(+), 34 deletions(-)
drivers/net/ethernet/intel/i40e/i40e_txrx.h +28 -17
index de8550f..e065321 100644
@@ -173,26 +173,37 @@ static inline bool i40e_test_staterr(union i40e_rx_desc *rx_desc,
 #define I40E_MAX_DATA_PER_TXD_ALIGNED \
 	(I40E_MAX_DATA_PER_TXD & ~(I40E_MAX_READ_REQ_SIZE - 1))
 
-/* This ugly bit of math is equivalent to DIV_ROUNDUP(size, X) where X is
- * the value I40E_MAX_DATA_PER_TXD_ALIGNED.  It is needed due to the fact
- * that 12K is not a power of 2 and division is expensive.  It is used to
- * approximate the number of descriptors used per linear buffer.  Note
- * that this will overestimate in some cases as it doesn't account for the
- * fact that we will add up to 4K - 1 in aligning the 12K buffer, however
- * the error should not impact things much as large buffers usually mean
- * we will use fewer descriptors then there are frags in an skb.
+/**
+ * i40e_txd_use_count  - estimate the number of descriptors needed for Tx
+ * @size: transmit request size in bytes
+ *
+ * Due to hardware alignment restrictions (4K alignment), we need to
+ * assume that we can have no more than 12K of data per descriptor, even
+ * though each descriptor can take up to 16K - 1 bytes of aligned memory.
+ * Thus, we need to divide by 12K. But division is slow! Instead,
+ * we decompose the operation into shifts and one relatively cheap
+ * multiply operation.
+ *
+ * To divide by 12K, we first divide by 4K, then divide by 3:
+ *     To divide by 4K, shift right by 12 bits
+ *     To divide by 3, multiply by 85, then divide by 256
+ *     (Divide by 256 is done by shifting right by 8 bits)
+ * Finally, we add one to round up. Because 256 isn't an exact multiple of
+ * 3, we'll underestimate near each multiple of 12K. This is actually more
+ * accurate as we have 4K - 1 of wiggle room that we can fit into the last
+ * segment.  For our purposes this is accurate out to 1M which is orders of
+ * magnitude greater than our largest possible GSO size.
+ *
+ * This would then be implemented as:
+ *     return (((size >> 12) * 85) >> 8) + 1;
+ *
+ * Since multiplication and division are commutative, we can reorder
+ * operations into:
+ *     return ((size * 85) >> 20) + 1;
  */
 static inline unsigned int i40e_txd_use_count(unsigned int size)
 {
-	const unsigned int max = I40E_MAX_DATA_PER_TXD_ALIGNED;
-	const unsigned int reciprocal = ((1ull << 32) - 1 + (max / 2)) / max;
-	unsigned int adjust = ~(u32)0;
-
-	/* if we rounded up on the reciprocal pull down the adjustment */
-	if ((max * reciprocal) > adjust)
-		adjust = ~(u32)(reciprocal - 1);
-
-	return (u32)((((u64)size * reciprocal) + adjust) >> 32);
+	return ((size * 85) >> 20) + 1;
 }
 
 /* Tx Descriptors needed, worst case */
drivers/net/ethernet/intel/i40evf/i40e_txrx.h +28 -17

54 lines not on this page · raw message

Signature · 1 line
2.4.11
#20 lore raw

PATCH 10/15 i40e: simplify txd use count calculation

Quoted 23 lines

-----Original Message-----
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at lists.osuosl.org] On Behalf Of Bimmy Pujari
Sent: Tuesday, November 08, 2016 1:05 PM
To: intel-wired-lan at lists.osuosl.org
Subject: [Intel-wired-lan] [next PATCH S52-V2 10/15] i40e: simplify txd use count calculation

From: Mitch Williams <[email protected]>

The i40e_txd_use_count function was fast but confusing. In the comments, it even admits that it's ugly. So replace it with a new function that is (very) slightly faster and has extensive commenting to help the thicker among us (including the author, who will forget in a week) understand how it works.

Change-ID Ifb533f13786a0bf39cb29f77969a5be2c83d9a87

---
Testing Hints : Lots and lots of TSO with various data sizes. This should operate exactly as before, with no noticeable performance change.

Quoted 5 lines
 drivers/net/ethernet/intel/i40e/i40e_txrx.h   | 45 +++++++++++++++++-----
-----
 drivers/net/ethernet/intel/i40evf/i40e_txrx.h | 45 +++++++++++++++++----
------
 2 files changed, 56 insertions(+), 34 deletions(-)

No performance degradation with various packet sizes

#21 lore raw

PATCH 11/15 i40e: restore workaround for removing default MAC filter

In reply to Bimmy Pujari

From: Jacob Keller <[email protected]>

A previous commit 53cb6e9e8949 ("i40e: Removal of workaround for simple MAC address filter deletion") removed a workaround for some firmware versions which was reported to not be necessary in production NICs. Unfortunately this workaround is necessary in some configurations, specifically the Ethernet Controller XL710 for 40GbE QSFP+ (8086:1583).

Without this patch, the mentioned NICs with current firmware exhibit issues when adding VLANs, as outlined by the following reproduction:

$modprobe i40e
$ip link set <device> up
$ip link add link <device> vlan100 type vlan id 100 $dmesg | tail
<snip>
kernel: i40e 0000:82:00.0: Error I40E_AQ_RC_EINVAL adding RX
filters on PF, promiscuous mode forced on

This results in filters being marked as FAILED and setting the device in promiscuous mode.

The root cause of receiving the -EINVAL error response appears to be due to a conflict with the default MAC filter which still exists on the default firmware for this device. Attempting to add a new VLAN filter on the default MAC address conflicts with the IGNORE_VLAN setting on the default rule.

Change-ID I4d8f6d48ac5f60cfe981b3baad30eb4d7c170d61
---
 drivers/net/ethernet/intel/i40e/i40e_main.c | 41 +++++++++++++++++++++++++++++
 1 file changed, 41 insertions(+)
drivers/net/ethernet/intel/i40e/i40e_main.c +41 -0
index 161f512..ef6eb19 100644
@@ -1226,6 +1226,39 @@ bool i40e_is_vsi_in_vlan(struct i40e_vsi *vsi)
 }
 
 /**
+ * i40e_rm_default_mac_filter - Remove the default MAC filter set by NVM
+ * @vsi: the PF Main VSI - inappropriate for any other VSI
+ * @macaddr: the MAC address
+ *
+ * Remove whatever filter the firmware set up so the driver can manage
+ * its own filtering intelligently.
+ **/
+static void i40e_rm_default_mac_filter(struct i40e_vsi *vsi, u8 *macaddr)
+{
+	struct i40e_aqc_remove_macvlan_element_data element;
+	struct i40e_pf *pf = vsi->back;
+
+	/* Only appropriate for the PF main VSI */
+	if (vsi->type != I40E_VSI_MAIN)
+		return;
+
+	memset(&element, 0, sizeof(element));
+	ether_addr_copy(element.mac_addr, macaddr);
+	element.vlan_tag = 0;
+	/* Ignore error returns, some firmware does it this way... */
+	element.flags = I40E_AQC_MACVLAN_DEL_PERFECT_MATCH;
+	i40e_aq_remove_macvlan(&pf->hw, vsi->seid, &element, 1, NULL);
+
+	memset(&element, 0, sizeof(element));
+	ether_addr_copy(element.mac_addr, macaddr);
+	element.vlan_tag = 0;
+	/* ...and some firmware does it this way. */
+	element.flags = I40E_AQC_MACVLAN_DEL_PERFECT_MATCH |
+			I40E_AQC_MACVLAN_DEL_IGNORE_VLAN;
+	i40e_aq_remove_macvlan(&pf->hw, vsi->seid, &element, 1, NULL);
+}
+
+/**
  * i40e_add_filter - Add a mac/vlan filter to the VSI
  * @vsi: the VSI to be searched
  * @macaddr: the MAC address
@@ -9283,6 +9316,12 @@ static int i40e_config_netdev(struct i40e_vsi *vsi)
 	if (vsi->type == I40E_VSI_MAIN) {
 		SET_NETDEV_DEV(netdev, &pf->pdev->dev);
 		ether_addr_copy(mac_addr, hw->mac.perm_addr);
+		/* The following steps are necessary to prevent reception
+		 * of tagged packets - some older NVM configurations load a
+		 * default a MAC-VLAN filter that accepts any tagged packet
+		 * which must be replaced by a normal filter.
+		 */
+		i40e_rm_default_mac_filter(vsi, mac_addr);
 		spin_lock_bh(&vsi->mac_filter_hash_lock);
 		i40e_add_filter(vsi, mac_addr, I40E_VLAN_ANY);
 		spin_unlock_bh(&vsi->mac_filter_hash_lock);
@@ -9816,6 +9855,8 @@ static struct i40e_vsi *i40e_vsi_reinit_setup(struct i40e_vsi *vsi)
 	pf->vsi[pf->lan_vsi]->tc_config.enabled_tc = 0;
 	pf->vsi[pf->lan_vsi]->seid = pf->main_vsi_seid;
 	i40e_vsi_config_tc(pf->vsi[pf->lan_vsi], enabled_tc);
+	if (vsi->type == I40E_VSI_MAIN)
+		i40e_rm_default_mac_filter(vsi, pf->hw.mac.perm_addr);
 
 	/* assign it some queues */
 	ret = i40e_alloc_rings(vsi);
Signature · 1 line
2.4.11
#22 lore raw

PATCH 11/15 i40e: restore workaround for removing default MAC filter

Quoted 35 lines

-----Original Message-----
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at lists.osuosl.org] On Behalf Of Bimmy Pujari
Sent: Tuesday, November 08, 2016 1:05 PM
To: intel-wired-lan at lists.osuosl.org
Subject: [Intel-wired-lan] [next PATCH S52-V2 11/15] i40e: restore workaround for removing default MAC filter

From: Jacob Keller <[email protected]>

A previous commit 53cb6e9e8949 ("i40e: Removal of workaround for simple MAC address filter deletion") removed a workaround for some firmware versions which was reported to not be necessary in production NICs. Unfortunately this workaround is necessary in some configurations, specifically the Ethernet Controller XL710 for 40GbE QSFP+ (8086:1583).

Without this patch, the mentioned NICs with current firmware exhibit issues when adding VLANs, as outlined by the following reproduction:

$modprobe i40e
$ip link set <device> up
$ip link add link <device> vlan100 type vlan id 100
$dmesg | tail
<snip>
kernel: i40e 0000:82:00.0: Error I40E_AQ_RC_EINVAL adding RX filters on PF,
promiscuous mode forced on

This results in filters being marked as FAILED and setting the device in promiscuous mode.

The root cause of receiving the -EINVAL error response appears to be due to a conflict with the default MAC filter which still exists on the default firmware for this device. Attempting to add a new VLAN filter on the default MAC address conflicts with the IGNORE_VLAN setting on the default rule.

Quoted 6 lines
Change-ID I4d8f6d48ac5f60cfe981b3baad30eb4d7c170d61
---
 drivers/net/ethernet/intel/i40e/i40e_main.c | 41
+++++++++++++++++++++++++++++
 1 file changed, 41 insertions(+)

Adding VLAN with device 1583 successful, no error message recorded

#23 lore raw

PATCH 12/15 i40e/i40evf: napi_poll must return the work done

In reply to Bimmy Pujari

From: Alexander Duyck <[email protected]>

Currently the function i40e_napi-poll() returns 0 when it clean completely the rx rings, but this foul budget accounting in core code.

Fix this by returning the actual work done, capped to budget - 1, since the core doesn't allow to return the full budget when the driver modifies the napi status

This is based on a similar change that was made for the ixgbe driver by Paolo Abeni.

Change-ID Ic3d93ad2fa2fc8ce3164bc461e69367da0f9173b

---
Testing Hints:
This may slightly improve the responsiveness of the system, but the big gain for us is actually when using i40e to perform busy polling since the return value is used to verify if we have received any packets.

For our purposes the best test is probably just an Rx performance test to make sure we didn't cause a regression.

 drivers/net/ethernet/intel/i40e/i40e_txrx.c   | 2 +-
 drivers/net/ethernet/intel/i40evf/i40e_txrx.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/intel/i40e/i40e_txrx.c +1 -1
index 5544b50..352cf7c 100644
@@ -2027,7 +2027,7 @@ int i40e_napi_poll(struct napi_struct *napi, int budget)
 	else
 		i40e_update_enable_itr(vsi, q_vector);
 
-	return 0;
+	return min(work_done, budget - 1);
 }
 
 /**
drivers/net/ethernet/intel/i40evf/i40e_txrx.c +1 -1
index c4b174a..df67ef3 100644
@@ -1490,7 +1490,7 @@ int i40evf_napi_poll(struct napi_struct *napi, int budget)
 	else
 		i40e_update_enable_itr(vsi, q_vector);
 
-	return 0;
+	return min(work_done, budget - 1);
 }
 
 /**
Signature · 1 line
2.4.11
#24 lore raw

PATCH 12/15 i40e/i40evf: napi_poll must return the work done

Quoted 29 lines

-----Original Message-----
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at lists.osuosl.org] On Behalf Of Bimmy Pujari
Sent: Tuesday, November 08, 2016 1:05 PM
To: intel-wired-lan at lists.osuosl.org
Subject: [Intel-wired-lan] [next PATCH S52-V2 12/15] i40e/i40evf: napi_poll must return the work done

From: Alexander Duyck <[email protected]>

Currently the function i40e_napi-poll() returns 0 when it clean completely the rx rings, but this foul budget accounting in core code.

Fix this by returning the actual work done, capped to budget - 1, since the core doesn't allow to return the full budget when the driver modifies the napi status

This is based on a similar change that was made for the ixgbe driver by Paolo Abeni.

Change-ID Ic3d93ad2fa2fc8ce3164bc461e69367da0f9173b

---
Testing Hints:
This may slightly improve the responsiveness of the system, but the big gain for us is actually when using i40e to perform busy polling since the return value is used to verify if we have received any packets.

Quoted 6 lines

For our purposes the best test is probably just an Rx performance test to make sure we didn't cause a regression.

 drivers/net/ethernet/intel/i40e/i40e_txrx.c   | 2 +-
 drivers/net/ethernet/intel/i40evf/i40e_txrx.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
#25 lore raw

PATCH 13/15 i40e: remove code to handle dev_addr specially

In reply to Bimmy Pujari

From: Jacob Keller <[email protected]>

The netdev->dev_addr MAC filter already exists in the MAC/VLAN hash table, as it is added when we configure the netdev in i40e_configure_netdev. Because we already know that this address will be updated in the hash_for_each loops, we do not need to handle it specially. This removes duplicate code and simplifies the i40e_vsi_add_vlan and i40e_vsi_kill_vlan functions. Because we know these filters must be part of the MAC/VLAN hash table, this should not have any functional impact on what filters are included and is merely a code simplification.

Change-ID I5e648302dbdd7cc29efc6d203b7019c11f0b5705

---
Testing-hints:
Ensure that adding and removing VLANs correctly updates the filters for the MAC address of the device.

 drivers/net/ethernet/intel/i40e/i40e_main.c | 43 +++++------------------------
 1 file changed, 7 insertions(+), 36 deletions(-)
drivers/net/ethernet/intel/i40e/i40e_main.c +7 -36
index ef6eb19..eddb14c 100644
@@ -2503,17 +2503,6 @@ int i40e_vsi_add_vlan(struct i40e_vsi *vsi, s16 vid)
 	/* Locked once because all functions invoked below iterates list*/
 	spin_lock_bh(&vsi->mac_filter_hash_lock);
 
-	if (vsi->netdev) {
-		add_f = i40e_add_filter(vsi, vsi->netdev->dev_addr, vid);
-		if (!add_f) {
-			dev_info(&vsi->back->pdev->dev,
-				 "Could not add vlan filter %d for %pM\n",
-				 vid, vsi->netdev->dev_addr);
-			spin_unlock_bh(&vsi->mac_filter_hash_lock);
-			return -ENOMEM;
-		}
-	}
-
 	hash_for_each_safe(vsi->mac_filter_hash, bkt, h, f, hlist) {
 		if (f->state == I40E_FILTER_REMOVE)
 			continue;
@@ -2527,28 +2516,14 @@ int i40e_vsi_add_vlan(struct i40e_vsi *vsi, s16 vid)
 		}
 	}
 
-	/* Now if we add a vlan tag, make sure to check if it is the first
-	 * tag (i.e. a "tag" -1 does exist) and if so replace the -1 "tag"
-	 * with 0, so we now accept untagged and specified tagged traffic
-	 * (and not all tags along with untagged)
+	/* When we add a new VLAN filter, we need to make sure that all existing
+	 * filters which are marked as vid=-1 (I40E_VLAN_ANY) are converted to
+	 * vid=0. The simplest way is just search for all filters marked as
+	 * vid=-1 and replace them with vid=0. This converts all filters that
+	 * were marked to receive all traffic (tagged or untagged) into
+	 * filters to receive only untagged traffic, so that we don't receive
+	 * tagged traffic for VLANs which we have not configured.
 	 */
-	if (vid > 0 && vsi->netdev) {
-		del_f = i40e_find_filter(vsi, vsi->netdev->dev_addr,
-					 I40E_VLAN_ANY);
-		if (del_f) {
-			__i40e_del_filter(vsi, del_f);
-			add_f = i40e_add_filter(vsi, vsi->netdev->dev_addr, 0);
-			if (!add_f) {
-				dev_info(&vsi->back->pdev->dev,
-					 "Could not add filter 0 for %pM\n",
-					 vsi->netdev->dev_addr);
-				spin_unlock_bh(&vsi->mac_filter_hash_lock);
-				return -ENOMEM;
-			}
-		}
-	}
-
-	/* Do not assume that I40E_VLAN_ANY should be reset to VLAN 0 */
 	if (vid > 0 && !vsi->info.pvid) {
 		hash_for_each_safe(vsi->mac_filter_hash, bkt, h, f, hlist) {
 			if (f->state == I40E_FILTER_REMOVE)
@@ -2585,7 +2560,6 @@ int i40e_vsi_add_vlan(struct i40e_vsi *vsi, s16 vid)
  **/
 void i40e_vsi_kill_vlan(struct i40e_vsi *vsi, s16 vid)
 {
-	struct net_device *netdev = vsi->netdev;
 	struct i40e_mac_filter *f;
 	struct hlist_node *h;
 	int bkt;
@@ -2593,9 +2567,6 @@ void i40e_vsi_kill_vlan(struct i40e_vsi *vsi, s16 vid)
 	/* Locked once because all functions invoked below iterates list */
 	spin_lock_bh(&vsi->mac_filter_hash_lock);
 
-	if (vsi->netdev)
-		i40e_del_filter(vsi, netdev->dev_addr, vid);
-
 	hash_for_each_safe(vsi->mac_filter_hash, bkt, h, f, hlist) {
 		if (f->vlan == vid)
 			__i40e_del_filter(vsi, f);
Signature · 1 line
2.4.11
#26 lore raw

PATCH 13/15 i40e: remove code to handle dev_addr specially

Quoted 22 lines

-----Original Message-----
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at lists.osuosl.org] On Behalf Of Bimmy Pujari
Sent: Tuesday, November 08, 2016 1:05 PM
To: intel-wired-lan at lists.osuosl.org
Subject: [Intel-wired-lan] [next PATCH S52-V2 13/15] i40e: remove code to handle dev_addr specially

From: Jacob Keller <[email protected]>

The netdev->dev_addr MAC filter already exists in the MAC/VLAN hash table, as it is added when we configure the netdev in i40e_configure_netdev. Because we already know that this address will be updated in the hash_for_each loops, we do not need to handle it specially. This removes duplicate code and simplifies the i40e_vsi_add_vlan and i40e_vsi_kill_vlan functions.
Because we know these filters must be part of the MAC/VLAN hash table, this should not have any functional impact on what filters are included and is merely a code simplification.

Change-ID I5e648302dbdd7cc29efc6d203b7019c11f0b5705
Quoted 7 lines

---
Testing-hints:
Ensure that adding and removing VLANs correctly updates the filters for the MAC address of the device.

 drivers/net/ethernet/intel/i40e/i40e_main.c | 43 +++++------------------------
 1 file changed, 7 insertions(+), 36 deletions(-)

Adding/removing VLANs correctly updates MAC filter table

#27 lore raw

PATCH 14/15 i40e: Blink LED on 1G BaseT boards

In reply to Bimmy Pujari

From: Henry Tieman <[email protected]>

Before this patch "ethtool -p" was not blinking the LEDs on boards with 1G BaseT PHYs.

This commit identifies 1G BaseT boards as having the LEDs connected to the MAC. Also, renamed the flag to be more descriptive of usage. The flag is now I40E_FLAG_PHY_CONTROLS_LEDS.

Change-ID I4eb741da9780da7849ddf2dc4c0cb27ffa42a801
---
 drivers/net/ethernet/intel/i40e/i40e.h         |  2 +-
 drivers/net/ethernet/intel/i40e/i40e_ethtool.c | 10 +++++-----
 drivers/net/ethernet/intel/i40e/i40e_main.c    |  4 ++--
 3 files changed, 8 insertions(+), 8 deletions(-)
drivers/net/ethernet/intel/i40e/i40e.h +1 -1
index 06e3c23..b8f2978 100644
@@ -356,7 +356,7 @@ struct i40e_pf {
 #define I40E_FLAG_NO_DCB_SUPPORT		BIT_ULL(45)
 #define I40E_FLAG_USE_SET_LLDP_MIB		BIT_ULL(46)
 #define I40E_FLAG_STOP_FW_LLDP			BIT_ULL(47)
-#define I40E_FLAG_HAVE_10GBASET_PHY		BIT_ULL(48)
+#define I40E_FLAG_PHY_CONTROLS_LEDS		BIT_ULL(48)
 #define I40E_FLAG_PF_MAC			BIT_ULL(50)
 #define I40E_FLAG_TRUE_PROMISC_SUPPORT		BIT_ULL(51)
 #define I40E_FLAG_HAVE_CRT_RETIMER		BIT_ULL(52)
drivers/net/ethernet/intel/i40e/i40e_ethtool.c +5 -5
index 76753e1..6ba0035 100644
@@ -1890,7 +1890,7 @@ static int i40e_set_phys_id(struct net_device *netdev,
 
 	switch (state) {
 	case ETHTOOL_ID_ACTIVE:
-		if (!(pf->flags & I40E_FLAG_HAVE_10GBASET_PHY)) {
+		if (!(pf->flags & I40E_FLAG_PHY_CONTROLS_LEDS)) {
 			pf->led_status = i40e_led_get(hw);
 		} else {
 			i40e_aq_set_phy_debug(hw, I40E_PHY_DEBUG_ALL, NULL);
@@ -1900,20 +1900,20 @@ static int i40e_set_phys_id(struct net_device *netdev,
 		}
 		return blink_freq;
 	case ETHTOOL_ID_ON:
-		if (!(pf->flags & I40E_FLAG_HAVE_10GBASET_PHY))
+		if (!(pf->flags & I40E_FLAG_PHY_CONTROLS_LEDS))
 			i40e_led_set(hw, 0xf, false);
 		else
 			ret = i40e_led_set_phy(hw, true, pf->led_status, 0);
 		break;
 	case ETHTOOL_ID_OFF:
-		if (!(pf->flags & I40E_FLAG_HAVE_10GBASET_PHY))
+		if (!(pf->flags & I40E_FLAG_PHY_CONTROLS_LEDS))
 			i40e_led_set(hw, 0x0, false);
 		else
 			ret = i40e_led_set_phy(hw, false, pf->led_status, 0);
 		break;
 	case ETHTOOL_ID_INACTIVE:
-		if (!(pf->flags & I40E_FLAG_HAVE_10GBASET_PHY)) {
-			i40e_led_set(hw, false, pf->led_status);
+		if (!(pf->flags & I40E_FLAG_PHY_CONTROLS_LEDS)) {
+			i40e_led_set(hw, pf->led_status, false);
 		} else {
 			ret = i40e_led_set_phy(hw, false, pf->led_status,
 					       (pf->phy_led_val |
drivers/net/ethernet/intel/i40e/i40e_main.c +2 -2
index eddb14c..8443e8c 100644
@@ -11368,8 +11368,8 @@ static int i40e_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 						       pf->main_vsi_seid);
 
 	if ((pf->hw.device_id == I40E_DEV_ID_10G_BASE_T) ||
-	    (pf->hw.device_id == I40E_DEV_ID_10G_BASE_T4))
-		pf->flags |= I40E_FLAG_HAVE_10GBASET_PHY;
+		(pf->hw.device_id == I40E_DEV_ID_10G_BASE_T4))
+		pf->flags |= I40E_FLAG_PHY_CONTROLS_LEDS;
 	if (pf->hw.device_id == I40E_DEV_ID_SFP_I_X722)
 		pf->flags |= I40E_FLAG_HAVE_CRT_RETIMER;
 	/* print a string summarizing features */
Signature · 1 line
2.4.11
#28 lore raw

PATCH 14/15 i40e: Blink LED on 1G BaseT boards

Quoted 18 lines

-----Original Message-----
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at lists.osuosl.org] On Behalf Of Bimmy Pujari
Sent: Tuesday, November 08, 2016 1:05 PM
To: intel-wired-lan at lists.osuosl.org
Cc: Tieman, Henry W <[email protected]>
Subject: [Intel-wired-lan] [next PATCH S52-V2 14/15] i40e: Blink LED on 1G BaseT boards

From: Henry Tieman <[email protected]>

Before this patch "ethtool -p" was not blinking the LEDs on boards with 1G BaseT PHYs.

This commit identifies 1G BaseT boards as having the LEDs connected to the MAC. Also, renamed the flag to be more descriptive of usage. The flag is now I40E_FLAG_PHY_CONTROLS_LEDS.

Quoted 8 lines
Change-ID I4eb741da9780da7849ddf2dc4c0cb27ffa42a801
---
 drivers/net/ethernet/intel/i40e/i40e.h         |  2 +-
 drivers/net/ethernet/intel/i40e/i40e_ethtool.c | 10 +++++-----
 drivers/net/ethernet/intel/i40e/i40e_main.c    |  4 ++--
 3 files changed, 8 insertions(+), 8 deletions(-)
#29 lore raw

PATCH 15/15 Changed version from 1.6.21 to 1.6.25

In reply to Bimmy Pujari
---
 drivers/net/ethernet/intel/i40e/i40e_main.c     | 2 +-
 drivers/net/ethernet/intel/i40evf/i40evf_main.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/intel/i40e/i40e_main.c +1 -1
index 8443e8c..a032dfd 100644
@@ -41,7 +41,7 @@ static const char i40e_driver_string[] =
 
 #define DRV_VERSION_MAJOR 1
 #define DRV_VERSION_MINOR 6
-#define DRV_VERSION_BUILD 21
+#define DRV_VERSION_BUILD 25
 #define DRV_VERSION __stringify(DRV_VERSION_MAJOR) "." \
 	     __stringify(DRV_VERSION_MINOR) "." \
 	     __stringify(DRV_VERSION_BUILD)    DRV_KERN
drivers/net/ethernet/intel/i40evf/i40evf_main.c +1 -1
index ca85021..c0fc533 100644
@@ -38,7 +38,7 @@ static const char i40evf_driver_string[] =
 
 #define DRV_VERSION_MAJOR 1
 #define DRV_VERSION_MINOR 6
-#define DRV_VERSION_BUILD 21
+#define DRV_VERSION_BUILD 25
 #define DRV_VERSION __stringify(DRV_VERSION_MAJOR) "." \
 	     __stringify(DRV_VERSION_MINOR) "." \
 	     __stringify(DRV_VERSION_BUILD) \
Signature · 1 line
2.4.11
#30 lore raw

PATCH 15/15 Changed version from 1.6.21 to 1.6.25

Quoted 8 lines

-----Original Message-----
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at lists.osuosl.org] On Behalf Of Bimmy Pujari
Sent: Tuesday, November 08, 2016 1:05 PM
To: intel-wired-lan at lists.osuosl.org
Subject: [Intel-wired-lan] [next PATCH S52-V2 15/15] Changed version from 1.6.21 to 1.6.25

Quoted 5 lines
---
 drivers/net/ethernet/intel/i40e/i40e_main.c     | 2 +-
 drivers/net/ethernet/intel/i40evf/i40evf_main.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

Driver reports correct version