Skip to contentSkip to conversation

Intel Wired LAN Driver Updates 2021-11-15

GIT PULL In review Tony Nguyen 4 participants 16 messages Nov 16, 2021 – Nov 17, 2021

Subsystems (3)
lore
Share & tools
lore

Tony Nguyen

author maintainer
#0 lore raw

This series contains updates to iavf driver only.

Mateusz adds a wait for reset completion when changing queue count which could otherwise cause issues with VF reset.

Nick adds a null check for vf_res in iavf_fix_features(), corrects ordering of function calls to resolve dependency issues, and prevents possible freeing of a lock which isn't being held.

Piotr fixes logic that did not allow setting all multicast mode without promiscuous mode.

Jake prevents possible accidental freeing of filter structure.

Mitch adds null checks for key and indir parameters in iavf_get_rxfh().

Surabhi adds an additional check that would, previously, cause the driver to print a false error due to values obtained while the VF is in reset.

Grzegorz prevents a queue request of 0 which would cause queue count to reset to default values.

Akeem restores VLAN filters when bringing the interface back up.

The following are changes since commit cf4f5530bb55ef7d5a91036b26676643b80b1616:
net/smc: Make sure the link_id is unique
and are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/tnguy/net-queue 40GbE

Akeem G Abodunrin (1):
iavf: Restore VLAN filters after link down

Grzegorz Szczurek (1):
iavf: Fix for setting queues to 0

Jacob Keller (1):
iavf: prevent accidental free of filter structure

Mateusz Palczewski (1):
iavf: Fix return of set the new channel count

Mitch Williams (1):
iavf: validate pointers

Nicholas Nunley (3):
iavf: check for null in iavf_fix_features
iavf: free q_vectors before queues in iavf_disable_vf
iavf: don't clear a lock we don't hold

Piotr Marczak (1):
iavf: Fix failure to exit out from last all-multicast mode

Surabhi Boob (1):
iavf: Fix for the false positive ASQ/ARQ errors while issuing VF reset

 drivers/net/ethernet/intel/iavf/iavf.h        |  1 +
 .../net/ethernet/intel/iavf/iavf_ethtool.c    | 30 +++++++---
 drivers/net/ethernet/intel/iavf/iavf_main.c   | 55 ++++++++++++++-----
 3 files changed, 64 insertions(+), 22 deletions(-)
Signature · 1 line
2.31.1
author maintainer
#1 lore raw

PATCH 1/10 iavf: Fix return of set the new channel count

From: Mateusz Palczewski <[email protected]>

Fixed return correct code from set the new channel count. Implemented by check if reset is done in appropriate time. This solution give a extra time to pf for reset vf in case when user want set new channel count for all vfs. Without this patch it is possible to return misleading output code to user and vf reset not to be correctly performed by pf.

Fixes 5520deb15326 ("iavf: Enable support for up to 16 queues")
---
 drivers/net/ethernet/intel/iavf/iavf_ethtool.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
drivers/net/ethernet/intel/iavf/iavf_ethtool.c +15 -0
index 5a359a0a20ec..136c801f5584 100644
@@ -1776,6 +1776,7 @@ static int iavf_set_channels(struct net_device *netdev,
 {
 	struct iavf_adapter *adapter = netdev_priv(netdev);
 	u32 num_req = ch->combined_count;
+	int i;
 
 	if ((adapter->vf_res->vf_cap_flags & VIRTCHNL_VF_OFFLOAD_ADQ) &&
 	    adapter->num_tc) {
@@ -1798,6 +1799,20 @@ static int iavf_set_channels(struct net_device *netdev,
 	adapter->num_req_queues = num_req;
 	adapter->flags |= IAVF_FLAG_REINIT_ITR_NEEDED;
 	iavf_schedule_reset(adapter);
+
+	/* wait for the reset is done */
+	for (i = 0; i < IAVF_RESET_WAIT_COMPLETE_COUNT; i++) {
+		msleep(IAVF_RESET_WAIT_MS);
+		if (adapter->flags & IAVF_FLAG_RESET_PENDING)
+			continue;
+		break;
+	}
+	if (i == IAVF_RESET_WAIT_COMPLETE_COUNT) {
+		adapter->flags &= ~IAVF_FLAG_REINIT_ITR_NEEDED;
+		adapter->num_active_queues = num_req;
+		return -EOPNOTSUPP;
+	}
+
 	return 0;
 }
 
Signature · 1 line
2.31.1
#2 lore raw

Re: [PATCH net 01/10] iavf: Fix return of set the new channel count

Quoted 35 lines · Tony Nguyen

From: Mateusz Palczewski <[email protected]>

Fixed return correct code from set the new channel count. Implemented by check if reset is done in appropriate time. This solution give a extra time to pf for reset vf in case when user want set new channel count for all vfs. Without this patch it is possible to return misleading output code to user and vf reset not to be correctly performed by pf.

Fixes 5520deb15326 ("iavf: Enable support for up to 16 queues")
---
 drivers/net/ethernet/intel/iavf/iavf_ethtool.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
drivers/net/ethernet/intel/iavf/iavf_ethtool.c +2 -0
index 5a359a0a20ec..136c801f5584 100644
@@ -1776,6 +1776,7 @@ static int iavf_set_channels(struct net_device *netdev,
 {
 	struct iavf_adapter *adapter = netdev_priv(netdev);
 	u32 num_req = ch->combined_count;
+	int i;
 
 	if ((adapter->vf_res->vf_cap_flags & VIRTCHNL_VF_OFFLOAD_ADQ) &&
 	    adapter->num_tc) {
@@ -1798,6 +1799,20 @@ static int iavf_set_channels(struct net_device *netdev,
 	adapter->num_req_queues = num_req;
 	adapter->flags |= IAVF_FLAG_REINIT_ITR_NEEDED;
 	iavf_schedule_reset(adapter);
+

drivers/net/ethernet/intel/iavf/iavf_ethtool.c static int iavf_set_channels(struct net_device *netdev, · line 1812

Quoted 10 lines
drivers/net/ethernet/intel/iavf/iavf_ethtool.c +10 -0
+	/* wait for the reset is done */
+	for (i = 0; i < IAVF_RESET_WAIT_COMPLETE_COUNT; i++) {
+		msleep(IAVF_RESET_WAIT_MS);
+		if (adapter->flags & IAVF_FLAG_RESET_PENDING)
+			continue;
+		break;
+	}
+	if (i == IAVF_RESET_WAIT_COMPLETE_COUNT) {
+		adapter->flags &= ~IAVF_FLAG_REINIT_ITR_NEEDED;
+		adapter->num_active_queues = num_req;

Hi Mateusz,

I'm not sure I understand why you touch flags and num_active_queues here even though the reset is still in progress? Shouldn't we just bail out and report the error?

drivers/net/ethernet/intel/iavf/iavf_ethtool.c static int iavf_set_channels(struct net_device *netdev, · line 1813

Quoted 1 line
drivers/net/ethernet/intel/iavf/iavf_ethtool.c +1 -0
+		return -EOPNOTSUPP;

Is this really the correct thing to report? Setting the queue count is supported, the device is just busy, so isn't EAGAIN a better way to express this?

Stefan

Quoted 8 lines
drivers/net/ethernet/intel/iavf/iavf_ethtool.c +2 -0
+	}
+
 	return 0;
 }
 
Signature · 1 line
2.31.1
author maintainer
#3 lore raw

PATCH 2/10 iavf: check for null in iavf_fix_features

In reply to Tony Nguyen

From: Nicholas Nunley <[email protected]>

If the driver has lost contact with the PF then it enters a disabled state and frees adapter->vf_res. However, ndo_fix_features can still be called on the interface, so we need to check for this condition first. Since we have no information on the features at this time simply leave them unmodified and return.

Fixes c4445aedfe09 ("i40evf: Fix VLAN features")
---
 drivers/net/ethernet/intel/iavf/iavf_main.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/ethernet/intel/iavf/iavf_main.c +2 -1
index 847d67e32a54..561171507cda 100644
@@ -3503,7 +3503,8 @@ static netdev_features_t iavf_fix_features(struct net_device *netdev,
 {
 	struct iavf_adapter *adapter = netdev_priv(netdev);
 
-	if (!(adapter->vf_res->vf_cap_flags & VIRTCHNL_VF_OFFLOAD_VLAN))
+	if (adapter->vf_res &&
+	    !(adapter->vf_res->vf_cap_flags & VIRTCHNL_VF_OFFLOAD_VLAN))
 		features &= ~(NETIF_F_HW_VLAN_CTAG_TX |
 			      NETIF_F_HW_VLAN_CTAG_RX |
 			      NETIF_F_HW_VLAN_CTAG_FILTER);
Signature · 1 line
2.31.1
author maintainer
#4 lore raw

PATCH 3/10 iavf: free q_vectors before queues in iavf_disable_vf

In reply to Tony Nguyen

From: Nicholas Nunley <[email protected]>

iavf_free_queues() clears adapter->num_active_queues, which iavf_free_q_vectors() relies on, so swap the order of these two function calls in iavf_disable_vf(). This resolves a panic encountered when the interface is disabled and then later brought up again after PF communication is restored.

Fixes 65c7006f234c ("i40evf: assign num_active_queues inside i40evf_alloc_queues")
---
 drivers/net/ethernet/intel/iavf/iavf_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/intel/iavf/iavf_main.c +1 -1
index 561171507cda..c23fff5a4bd9 100644
@@ -2123,8 +2123,8 @@ static void iavf_disable_vf(struct iavf_adapter *adapter)
 
 	iavf_free_misc_irq(adapter);
 	iavf_reset_interrupt_capability(adapter);
-	iavf_free_queues(adapter);
 	iavf_free_q_vectors(adapter);
+	iavf_free_queues(adapter);
 	memset(adapter->vf_res, 0, IAVF_VIRTCHNL_VF_RESOURCE_SIZE);
 	iavf_shutdown_adminq(&adapter->hw);
 	adapter->netdev->flags &= ~IFF_UP;
Signature · 1 line
2.31.1
author maintainer
#5 lore raw

PATCH 4/10 iavf: don't clear a lock we don't hold

In reply to Tony Nguyen

From: Nicholas Nunley <[email protected]>

In iavf_configure_clsflower() the function will bail out if it is unable to obtain the crit_section lock in a reasonable time. However, it will clear the lock when exiting, so fix this.

Fixes 640a8af5841f ("i40evf: Reorder configure_clsflower to avoid deadlock on error")
---
 drivers/net/ethernet/intel/iavf/iavf_main.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/net/ethernet/intel/iavf/iavf_main.c +4 -2
index c23fff5a4bd9..28661e4425f1 100644
@@ -3095,8 +3095,10 @@ static int iavf_configure_clsflower(struct iavf_adapter *adapter,
 		return -ENOMEM;
 
 	while (!mutex_trylock(&adapter->crit_lock)) {
-		if (--count == 0)
-			goto err;
+		if (--count == 0) {
+			kfree(filter);
+			return err;
+		}
 		udelay(1);
 	}
 
Signature · 1 line
2.31.1
author maintainer
#6 lore raw

PATCH 5/10 iavf: Fix failure to exit out from last all-multicast mode

In reply to Tony Nguyen

From: Piotr Marczak <[email protected]>

The driver could only quit allmulti when allmulti and promisc modes are turn on at the same time. If promisc had been off there was no way to turn off allmulti mode.
The patch corrects this behavior. Switching allmulti does not depends on promisc state mode anymore

Fixes f42a5c74da99 ("i40e: Add allmulti support for the VF")
---
 drivers/net/ethernet/intel/iavf/iavf_main.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/ethernet/intel/iavf/iavf_main.c +1 -2
index 28661e4425f1..76c4ca0f055e 100644
@@ -1639,8 +1639,7 @@ static int iavf_process_aq_command(struct iavf_adapter *adapter)
 		iavf_set_promiscuous(adapter, FLAG_VF_MULTICAST_PROMISC);
 		return 0;
 	}
-
-	if ((adapter->aq_required & IAVF_FLAG_AQ_RELEASE_PROMISC) &&
+	if ((adapter->aq_required & IAVF_FLAG_AQ_RELEASE_PROMISC) ||
 	    (adapter->aq_required & IAVF_FLAG_AQ_RELEASE_ALLMULTI)) {
 		iavf_set_promiscuous(adapter, 0);
 		return 0;
Signature · 1 line
2.31.1
author maintainer
#7 lore raw

PATCH 6/10 iavf: prevent accidental free of filter structure

In reply to Tony Nguyen

From: Jacob Keller <[email protected]>

In iavf_config_clsflower, the filter structure could be accidentally released at the end, if iavf_parse_cls_flower or iavf_handle_tclass ever return a non-zero but positive value.

In this case, the function continues through to the end, and will call kfree() on the filter structure even though it has been added to the linked list.

This can actually happen because iavf_parse_cls_flower will return a positive IAVF_ERR_CONFIG value instead of the traditional negative error codes.

Fix this by ensuring that the kfree() check and error checks are similar. Use the more idiomatic "if (err)" to catch all non-zero error codes.

Fixes 0075fa0fadd0 ("i40evf: Add support to apply cloud filters")
---
 drivers/net/ethernet/intel/iavf/iavf_main.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/intel/iavf/iavf_main.c +2 -2
index 76c4ca0f055e..9c68c8628512 100644
@@ -3108,11 +3108,11 @@ static int iavf_configure_clsflower(struct iavf_adapter *adapter,
 	/* start out with flow type and eth type IPv4 to begin with */
 	filter->f.flow_type = VIRTCHNL_TCP_V4_FLOW;
 	err = iavf_parse_cls_flower(adapter, cls_flower, filter);
-	if (err < 0)
+	if (err)
 		goto err;
 
 	err = iavf_handle_tclass(adapter, tc, filter);
-	if (err < 0)
+	if (err)
 		goto err;
 
 	/* add filter to the list */
Signature · 1 line
2.31.1
#8 lore raw

Re: [PATCH net 06/10] iavf: prevent accidental free of filter structure

Quoted 6 lines · Tony Nguyen

From: Jacob Keller <[email protected]>

In iavf_config_clsflower, the filter structure could be accidentally released at the end, if iavf_parse_cls_flower or iavf_handle_tclass ever return a non-zero but positive value.

Quoted 7 lines

In this case, the function continues through to the end, and will call kfree() on the filter structure even though it has been added to the linked list.

This can actually happen because iavf_parse_cls_flower will return a positive IAVF_ERR_CONFIG value instead of the traditional negative error codes.

Hi Jacob,

where exactly does this happen?
Looking at iavf_parse_cls_flower() I see all returns of IAVF_ERR_CONFIG as "return IAVF_ERR_CONFIG;" while IAVF_ERR_CONFIG is defined as
IAVF_ERR_CONFIG = -4,

I'm not opposed to this change, just wondering what's going on.

Stefan

Quoted 33 lines

Fix this by ensuring that the kfree() check and error checks are similar. Use the more idiomatic "if (err)" to catch all non-zero error codes.

Fixes 0075fa0fadd0 ("i40evf: Add support to apply cloud filters")
---
 drivers/net/ethernet/intel/iavf/iavf_main.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/intel/iavf/iavf_main.c +2 -2
index 76c4ca0f055e..9c68c8628512 100644
@@ -3108,11 +3108,11 @@ static int iavf_configure_clsflower(struct iavf_adapter *adapter,
 	/* start out with flow type and eth type IPv4 to begin with */
 	filter->f.flow_type = VIRTCHNL_TCP_V4_FLOW;
 	err = iavf_parse_cls_flower(adapter, cls_flower, filter);
-	if (err < 0)
+	if (err)
 		goto err;
 
 	err = iavf_handle_tclass(adapter, tc, filter);
-	if (err < 0)
+	if (err)
 		goto err;
 
 	/* add filter to the list */
Signature · 1 line
2.31.1
#9 lore raw

Re: [PATCH net 06/10] iavf: prevent accidental free of filter structure

Quoted 17 lines · Stefan Assmann
Quoted 6 lines · Tony Nguyen

From: Jacob Keller <[email protected]>

In iavf_config_clsflower, the filter structure could be accidentally released at the end, if iavf_parse_cls_flower or iavf_handle_tclass ever return a non-zero but positive value.

Quoted 7 lines

In this case, the function continues through to the end, and will call kfree() on the filter structure even though it has been added to the linked list.

This can actually happen because iavf_parse_cls_flower will return a positive IAVF_ERR_CONFIG value instead of the traditional negative error codes.

Hi Jacob,

Quoted 9 lines

where exactly does this happen?
Looking at iavf_parse_cls_flower() I see all returns of IAVF_ERR_CONFIG as "return IAVF_ERR_CONFIG;" while IAVF_ERR_CONFIG is defined as
IAVF_ERR_CONFIG = -4,

I'm not opposed to this change, just wondering what's going on.

Stefan

Heh.

I don't have memory of the full context for the original work. We've been going through and trying to pull in fixes that we've done for our out-of-tree driver and get everything upstream.

At first I thought this might be because of some history where these values used to be positive in the out-of-tree history at some point... But I think this wasn't true. It is possible that some other flow accidentally sends a positive value, but I've long since lost memory of if I had an example of that. You're correct that IAVF_ERR_CONFIG is (and has been in both upstream and out-of-tree code since its inception) negative.

I don't think this change is harmful, but I think you're right in pointing out the description isn't really valid.

I'm happy to re-write this commit message for clarity.

I do think switching to "if (err)" is more idiomatic and the correct thing to do.

Thanks,
Jake

Quoted 34 lines
Quoted 33 lines

Fix this by ensuring that the kfree() check and error checks are similar. Use the more idiomatic "if (err)" to catch all non-zero error codes.

Fixes 0075fa0fadd0 ("i40evf: Add support to apply cloud filters")
---
 drivers/net/ethernet/intel/iavf/iavf_main.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/intel/iavf/iavf_main.c +2 -2
index 76c4ca0f055e..9c68c8628512 100644
@@ -3108,11 +3108,11 @@ static int iavf_configure_clsflower(struct iavf_adapter *adapter,
 	/* start out with flow type and eth type IPv4 to begin with */
 	filter->f.flow_type = VIRTCHNL_TCP_V4_FLOW;
 	err = iavf_parse_cls_flower(adapter, cls_flower, filter);
-	if (err < 0)
+	if (err)
 		goto err;
 
 	err = iavf_handle_tclass(adapter, tc, filter);
-	if (err < 0)
+	if (err)
 		goto err;
 
 	/* add filter to the list */
Signature · 1 line
2.31.1
#10 lore raw

Re: [PATCH net 06/10] iavf: prevent accidental free of filter structure

Quoted 42 lines · Jacob E
Quoted 17 lines · Stefan Assmann
Quoted 6 lines · Tony Nguyen

From: Jacob Keller <[email protected]>

In iavf_config_clsflower, the filter structure could be accidentally released at the end, if iavf_parse_cls_flower or iavf_handle_tclass ever return a non-zero but positive value.

Quoted 7 lines

In this case, the function continues through to the end, and will call kfree() on the filter structure even though it has been added to the linked list.

This can actually happen because iavf_parse_cls_flower will return a positive IAVF_ERR_CONFIG value instead of the traditional negative error codes.

Hi Jacob,

Quoted 9 lines

where exactly does this happen?
Looking at iavf_parse_cls_flower() I see all returns of IAVF_ERR_CONFIG as "return IAVF_ERR_CONFIG;" while IAVF_ERR_CONFIG is defined as
IAVF_ERR_CONFIG = -4,

I'm not opposed to this change, just wondering what's going on.

Stefan

Heh.

I don't have memory of the full context for the original work. We've been going through and trying to pull in fixes that we've done for our out-of-tree driver and get everything upstream.

At first I thought this might be because of some history where these values used to be positive in the out-of-tree history at some point... But I think this wasn't true. It is possible that some other flow accidentally sends a positive value, but I've long since lost memory of if I had an example of that. You're correct that IAVF_ERR_CONFIG is (and has been in both upstream and out-of-tree code since its inception) negative.

Quoted 7 lines

I don't think this change is harmful, but I think you're right in pointing out the description isn't really valid.

I'm happy to re-write this commit message for clarity.

I do think switching to "if (err)" is more idiomatic and the correct thing to do.

Great feedback thanks, I totally agree.

Stefan

author maintainer
#11 lore raw

PATCH 7/10 iavf: validate pointers

In reply to Tony Nguyen

From: Mitch Williams <[email protected]>

In some cases, the ethtool get_rxfh handler may be called with a null key or indir parameter. So check these pointers, or you will have a very bad day.

Fixes 43a3d9ba34c9 ("i40evf: Allow PF driver to configure RSS")
---
 drivers/net/ethernet/intel/iavf/iavf_ethtool.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)
drivers/net/ethernet/intel/iavf/iavf_ethtool.c +6 -7
index 136c801f5584..25ee0606e625 100644
@@ -1859,14 +1859,13 @@ static int iavf_get_rxfh(struct net_device *netdev, u32 *indir, u8 *key,
 
 	if (hfunc)
 		*hfunc = ETH_RSS_HASH_TOP;
-	if (!indir)
-		return 0;
-
-	memcpy(key, adapter->rss_key, adapter->rss_key_size);
+	if (key)
+		memcpy(key, adapter->rss_key, adapter->rss_key_size);
 
-	/* Each 32 bits pointed by 'indir' is stored with a lut entry */
-	for (i = 0; i < adapter->rss_lut_size; i++)
-		indir[i] = (u32)adapter->rss_lut[i];
+	if (indir)
+		/* Each 32 bits pointed by 'indir' is stored with a lut entry */
+		for (i = 0; i < adapter->rss_lut_size; i++)
+			indir[i] = (u32)adapter->rss_lut[i];
 
 	return 0;
 }
Signature · 1 line
2.31.1
author maintainer
#12 lore raw

PATCH 8/10 iavf: Fix for the false positive ASQ/ARQ errors while issuing VF reset

In reply to Tony Nguyen

From: Surabhi Boob <[email protected]>

While issuing VF Reset from the guest OS, the VF driver prints logs about critical / Overflow error detection. This is not an actual error since the VF_MBX_ARQLEN register is set to all FF's for a short period of time and the VF would catch the bits set if it was reading the register during that spike of time. This patch introduces an additional check to ignore this condition since the VF is in reset.

Fixes 19b73d8efaa4 ("i40evf: Add additional check for reset")
---
 drivers/net/ethernet/intel/iavf/iavf_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/intel/iavf/iavf_main.c +1 -1
index 9c68c8628512..9ca9208aa896 100644
@@ -2409,7 +2409,7 @@ static void iavf_adminq_task(struct work_struct *work)
 
 	/* check for error indications */
 	val = rd32(hw, hw->aq.arq.len);
-	if (val == 0xdeadbeef) /* indicates device in reset */
+	if (val == 0xdeadbeef || val == 0xffffffff) /* device in reset */
 		goto freedom;
 	oldval = val;
 	if (val & IAVF_VF_ARQLEN1_ARQVFE_MASK) {
Signature · 1 line
2.31.1
author maintainer
#13 lore raw

PATCH 9/10 iavf: Fix for setting queues to 0

In reply to Tony Nguyen

From: Grzegorz Szczurek <[email protected]>

Now setting combine to 0 will be rejected with the appropriate error code.
This has been implemented by adding a condition that checks the value of combine equal to zero.
Without this patch, when the user requested it, no error was returned and combine was set to the default value for VF.

Fixes 5520deb15326 ("iavf: Enable support for up to 16 queues")
---
 drivers/net/ethernet/intel/iavf/iavf_ethtool.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/intel/iavf/iavf_ethtool.c +1 -1
index 25ee0606e625..144a77679359 100644
@@ -1787,7 +1787,7 @@ static int iavf_set_channels(struct net_device *netdev,
 	/* All of these should have already been checked by ethtool before this
 	 * even gets to us, but just to be sure.
 	 */
-	if (num_req > adapter->vsi_res->num_queue_pairs)
+	if (num_req == 0 || num_req > adapter->vsi_res->num_queue_pairs)
 		return -EINVAL;
 
 	if (num_req == adapter->num_active_queues)
Signature · 1 line
2.31.1
author maintainer
#14 lore raw

PATCH 10/10 iavf: Restore VLAN filters after link down

In reply to Tony Nguyen

From: Akeem G Abodunrin <[email protected]>

Restore VLAN filters after the link is brought down, and up - since all filters are deleted from HW during the netdev link down routine.

Fixes ed1f5b58ea01 ("i40evf: remove VLAN filters on close")
---
 drivers/net/ethernet/intel/iavf/iavf.h      |  1 +
 drivers/net/ethernet/intel/iavf/iavf_main.c | 35 ++++++++++++++++++---
 2 files changed, 31 insertions(+), 5 deletions(-)
drivers/net/ethernet/intel/iavf/iavf.h +1 -0
index e6e7c1da47fb..75635bd57cf6 100644
@@ -39,6 +39,7 @@
 #include "iavf_txrx.h"
 #include "iavf_fdir.h"
 #include "iavf_adv_rss.h"
+#include <linux/bitmap.h>
 
 #define DEFAULT_DEBUG_LEVEL_SHIFT 3
 #define PFX "iavf: "
drivers/net/ethernet/intel/iavf/iavf_main.c +30 -5
index 9ca9208aa896..336e6bf95e48 100644
@@ -696,6 +696,23 @@ static void iavf_del_vlan(struct iavf_adapter *adapter, u16 vlan)
 	spin_unlock_bh(&adapter->mac_vlan_list_lock);
 }
 
+/**
+ * iavf_restore_filters
+ * @adapter: board private structure
+ *
+ * Restore existing non MAC filters when VF netdev comes back up
+ **/
+static void iavf_restore_filters(struct iavf_adapter *adapter)
+{
+	/* re-add all VLAN filters */
+	if (VLAN_ALLOWED(adapter)) {
+		u16 vid;
+
+		for_each_set_bit(vid, adapter->vsi.active_vlans, VLAN_N_VID)
+			iavf_add_vlan(adapter, vid);
+	}
+}
+
 /**
  * iavf_vlan_rx_add_vid - Add a VLAN filter to a device
  * @netdev: network device struct
@@ -709,8 +726,11 @@ static int iavf_vlan_rx_add_vid(struct net_device *netdev,
 
 	if (!VLAN_ALLOWED(adapter))
 		return -EIO;
+
 	if (iavf_add_vlan(adapter, vid) == NULL)
 		return -ENOMEM;
+
+	set_bit(vid, adapter->vsi.active_vlans);
 	return 0;
 }
 
@@ -725,11 +745,13 @@ static int iavf_vlan_rx_kill_vid(struct net_device *netdev,
 {
 	struct iavf_adapter *adapter = netdev_priv(netdev);
 
-	if (VLAN_ALLOWED(adapter)) {
-		iavf_del_vlan(adapter, vid);
-		return 0;
-	}
-	return -EIO;
+	if (!VLAN_ALLOWED(adapter))
+		return -EIO;
+
+	iavf_del_vlan(adapter, vid);
+	clear_bit(vid, adapter->vsi.active_vlans);
+
+	return 0;
 }
 
 /**
@@ -3309,6 +3331,9 @@ static int iavf_open(struct net_device *netdev)
 
 	spin_unlock_bh(&adapter->mac_vlan_list_lock);
 
+	/* Restore VLAN filters that were removed with IFF_DOWN */
+	iavf_restore_filters(adapter);
+
 	iavf_configure(adapter);
 
 	iavf_up_complete(adapter);
Signature · 1 line
2.31.1
#15 lore raw
In reply to Tony Nguyen
This series was applied to netdev/net.git (master) by Tony Nguyen <[email protected]>:

Hello:

This series was applied to netdev/net.git (master) by Tony Nguyen <[email protected]>:

Quoted 10 lines · On Mon, 15 Nov 2021 15:59:24 -0800 you wrote:

This series contains updates to iavf driver only.

Mateusz adds a wait for reset completion when changing queue count which could otherwise cause issues with VF reset.

Nick adds a null check for vf_res in iavf_fix_features(), corrects ordering of function calls to resolve dependency issues, and prevents possible freeing of a lock which isn't being held.

[...]

Here is the summary with links:
- [net,01/10] iavf: Fix return of set the new channel count

    https://git.kernel.org/netdev/net/c/4e5e6b5d9d13
  - [net,02/10] iavf: check for null in iavf_fix_features
    https://git.kernel.org/netdev/net/c/8a4a126f4be8
  - [net,03/10] iavf: free q_vectors before queues in iavf_disable_vf
    https://git.kernel.org/netdev/net/c/89f22f129696
  - [net,04/10] iavf: don't clear a lock we don't hold
    https://git.kernel.org/netdev/net/c/2135a8d5c818
  - [net,05/10] iavf: Fix failure to exit out from last all-multicast mode
    https://git.kernel.org/netdev/net/c/8905072a192f
  - [net,06/10] iavf: prevent accidental free of filter structure
    https://git.kernel.org/netdev/net/c/4f0400803818
  - [net,07/10] iavf: validate pointers
    https://git.kernel.org/netdev/net/c/131b0edc4028
  - [net,08/10] iavf: Fix for the false positive ASQ/ARQ errors while issuing VF reset
    https://git.kernel.org/netdev/net/c/321421b57a12
  - [net,09/10] iavf: Fix for setting queues to 0
    https://git.kernel.org/netdev/net/c/9a6e9e483a96
  - [net,10/10] iavf: Restore VLAN filters after link down
    https://git.kernel.org/netdev/net/c/4293014230b8

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html