diff mbox series

[net-next] i40e: Fix correct max_pkt_size on VF RX queue

Message ID 20210121161722.1875-1-eryk.roch.rybak@intel.com
State Accepted
Delegated to: Anthony Nguyen
Headers show
Series [net-next] i40e: Fix correct max_pkt_size on VF RX queue | expand

Commit Message

Eryk Rybak Jan. 21, 2021, 4:17 p.m. UTC
Setting VLAN port increasing RX queue max_pkt_size
by 4 bytes to take VLAN tag into account.
Trigger the VF reset when setting port VLAN for
VF to renegotiate its capabilities and reinitialize.

Fixes: ba4e003d29c1("i40e: don't hold spinlock while resetting VF")
Signed-off-by: Sylwester Dziedziuch <sylwesterx.dziedziuch@intel.com>
Signed-off-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com>
Signed-off-by: Eryk Rybak <eryk.roch.rybak@intel.com>
---
 .../ethernet/intel/i40e/i40e_virtchnl_pf.c    | 53 ++++---------------
 1 file changed, 9 insertions(+), 44 deletions(-)


base-commit: 53959a962308c53a02a89dab13e42c3b69f8c51c

Comments

Jankowski, Konrad0 Oct. 21, 2021, 10:23 a.m. UTC | #1
> -----Original Message-----
> From: Intel-wired-lan <intel-wired-lan-bounces@osuosl.org> On Behalf Of
> Eryk Rybak
> Sent: czwartek, 21 stycznia 2021 17:17
> To: intel-wired-lan@lists.osuosl.org
> Cc: Rybak, Eryk Roch <eryk.roch.rybak@intel.com>; Dziedziuch, SylwesterX
> <sylwesterx.dziedziuch@intel.com>; Loktionov, Aleksandr
> <aleksandr.loktionov@intel.com>
> Subject: [Intel-wired-lan] [PATCH net-next] i40e: Fix correct max_pkt_size on
> VF RX queue
> 
> Setting VLAN port increasing RX queue max_pkt_size by 4 bytes to take
> VLAN tag into account.
> Trigger the VF reset when setting port VLAN for VF to renegotiate its
> capabilities and reinitialize.
> 
> Fixes: ba4e003d29c1("i40e: don't hold spinlock while resetting VF")
> Signed-off-by: Sylwester Dziedziuch <sylwesterx.dziedziuch@intel.com>
> Signed-off-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com>
> Signed-off-by: Eryk Rybak <eryk.roch.rybak@intel.com>
> ---
>  .../ethernet/intel/i40e/i40e_virtchnl_pf.c    | 53 ++++---------------
>  1 file changed, 9 insertions(+), 44 deletions(-)
> 
> diff --git a/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c
> b/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c
> index 7efc61a..4a4be04 100644
> --- a/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c
> +++ b/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c
> @@ -621,14 +621,13 @@ static int i40e_config_vsi_rx_queue(struct i40e_vf
> *vf, u16 vsi_id,
>  				    u16 vsi_queue_id,
>  				    struct virtchnl_rxq_info *info)  {
> +	u16 pf_queue_id = i40e_vc_get_pf_queue_id(vf, vsi_id,
> vsi_queue_id);
>  	struct i40e_pf *pf = vf->pf;
>  	struct i40e_hw *hw = &pf->hw;
> +	struct i40e_vsi *vsi = pf->vsi[vf->lan_vsi_idx];
>  	struct i40e_hmc_obj_rxq rx_ctx;
> -	u16 pf_queue_id;
>  	int ret = 0;
> 
> -	pf_queue_id = i40e_vc_get_pf_queue_id(vf, vsi_id, vsi_queue_id);
> -
>  	/* clear the context structure first */
>  	memset(&rx_ctx, 0, sizeof(struct i40e_hmc_obj_rxq));
> 
> @@ -666,6 +665,10 @@ static int i40e_config_vsi_rx_queue(struct i40e_vf
> *vf, u16 vsi_id,
>  	}
>  	rx_ctx.rxmax = info->max_pkt_size;
> 
> +	/* if port VLAN is configured increase the max packet size */
> +	if (vsi->info.pvid)
> +		rx_ctx.rxmax += VLAN_HLEN;
> +
>  	/* enable 32bytes desc always */
>  	rx_ctx.dsize = 1;
> 
> @@ -4118,34 +4121,6 @@ int i40e_ndo_set_vf_mac(struct net_device
> *netdev, int vf_id, u8 *mac)
>  	return ret;
>  }
> 
> -/**
> - * i40e_vsi_has_vlans - True if VSI has configured VLANs
> - * @vsi: pointer to the vsi
> - *
> - * Check if a VSI has configured any VLANs. False if we have a port VLAN or if
> - * we have no configured VLANs. Do not call while holding the
> - * mac_filter_hash_lock.
> - */
> -static bool i40e_vsi_has_vlans(struct i40e_vsi *vsi) -{
> -	bool have_vlans;
> -
> -	/* If we have a port VLAN, then the VSI cannot have any VLANs
> -	 * configured, as all MAC/VLAN filters will be assigned to the PVID.
> -	 */
> -	if (vsi->info.pvid)
> -		return false;
> -
> -	/* Since we don't have a PVID, we know that if the device is in VLAN
> -	 * mode it must be because of a VLAN filter configured on this VSI.
> -	 */
> -	spin_lock_bh(&vsi->mac_filter_hash_lock);
> -	have_vlans = i40e_is_vsi_in_vlan(vsi);
> -	spin_unlock_bh(&vsi->mac_filter_hash_lock);
> -
> -	return have_vlans;
> -}
> -
>  /**
>   * i40e_ndo_set_vf_port_vlan
>   * @netdev: network interface device structure @@ -4202,19 +4177,9 @@
> int i40e_ndo_set_vf_port_vlan(struct net_device *netdev, int vf_id,
>  		/* duplicate request, so just return success */
>  		goto error_pvid;
> 
> -	if (i40e_vsi_has_vlans(vsi)) {
> -		dev_err(&pf->pdev->dev,
> -			"VF %d has already configured VLAN filters and the
> administrator is requesting a port VLAN override.\nPlease unload and reload
> the VF driver for this change to take effect.\n",
> -			vf_id);
> -		/* Administrator Error - knock the VF offline until he does
> -		 * the right thing by reconfiguring his network correctly
> -		 * and then reloading the VF driver.
> -		 */
> -		i40e_vc_disable_vf(vf);
> -		/* During reset the VF got a new VSI, so refresh the pointer.
> */
> -		vsi = pf->vsi[vf->lan_vsi_idx];
> -	}
> -
> +	i40e_vc_disable_vf(vf);
> +	/* During reset the VF got a new VSI, so refresh a pointer. */
> +	vsi = pf->vsi[vf->lan_vsi_idx];
>  	/* Locked once because multiple functions below iterate list */
>  	spin_lock_bh(&vsi->mac_filter_hash_lock);
> 
> 

Tested-by: Konrad Jankowski <konrad0.jankowski@intel.com>
diff mbox series

Patch

diff --git a/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c b/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c
index 7efc61a..4a4be04 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c
@@ -621,14 +621,13 @@  static int i40e_config_vsi_rx_queue(struct i40e_vf *vf, u16 vsi_id,
 				    u16 vsi_queue_id,
 				    struct virtchnl_rxq_info *info)
 {
+	u16 pf_queue_id = i40e_vc_get_pf_queue_id(vf, vsi_id, vsi_queue_id);
 	struct i40e_pf *pf = vf->pf;
 	struct i40e_hw *hw = &pf->hw;
+	struct i40e_vsi *vsi = pf->vsi[vf->lan_vsi_idx];
 	struct i40e_hmc_obj_rxq rx_ctx;
-	u16 pf_queue_id;
 	int ret = 0;
 
-	pf_queue_id = i40e_vc_get_pf_queue_id(vf, vsi_id, vsi_queue_id);
-
 	/* clear the context structure first */
 	memset(&rx_ctx, 0, sizeof(struct i40e_hmc_obj_rxq));
 
@@ -666,6 +665,10 @@  static int i40e_config_vsi_rx_queue(struct i40e_vf *vf, u16 vsi_id,
 	}
 	rx_ctx.rxmax = info->max_pkt_size;
 
+	/* if port VLAN is configured increase the max packet size */
+	if (vsi->info.pvid)
+		rx_ctx.rxmax += VLAN_HLEN;
+
 	/* enable 32bytes desc always */
 	rx_ctx.dsize = 1;
 
@@ -4118,34 +4121,6 @@  int i40e_ndo_set_vf_mac(struct net_device *netdev, int vf_id, u8 *mac)
 	return ret;
 }
 
-/**
- * i40e_vsi_has_vlans - True if VSI has configured VLANs
- * @vsi: pointer to the vsi
- *
- * Check if a VSI has configured any VLANs. False if we have a port VLAN or if
- * we have no configured VLANs. Do not call while holding the
- * mac_filter_hash_lock.
- */
-static bool i40e_vsi_has_vlans(struct i40e_vsi *vsi)
-{
-	bool have_vlans;
-
-	/* If we have a port VLAN, then the VSI cannot have any VLANs
-	 * configured, as all MAC/VLAN filters will be assigned to the PVID.
-	 */
-	if (vsi->info.pvid)
-		return false;
-
-	/* Since we don't have a PVID, we know that if the device is in VLAN
-	 * mode it must be because of a VLAN filter configured on this VSI.
-	 */
-	spin_lock_bh(&vsi->mac_filter_hash_lock);
-	have_vlans = i40e_is_vsi_in_vlan(vsi);
-	spin_unlock_bh(&vsi->mac_filter_hash_lock);
-
-	return have_vlans;
-}
-
 /**
  * i40e_ndo_set_vf_port_vlan
  * @netdev: network interface device structure
@@ -4202,19 +4177,9 @@  int i40e_ndo_set_vf_port_vlan(struct net_device *netdev, int vf_id,
 		/* duplicate request, so just return success */
 		goto error_pvid;
 
-	if (i40e_vsi_has_vlans(vsi)) {
-		dev_err(&pf->pdev->dev,
-			"VF %d has already configured VLAN filters and the administrator is requesting a port VLAN override.\nPlease unload and reload the VF driver for this change to take effect.\n",
-			vf_id);
-		/* Administrator Error - knock the VF offline until he does
-		 * the right thing by reconfiguring his network correctly
-		 * and then reloading the VF driver.
-		 */
-		i40e_vc_disable_vf(vf);
-		/* During reset the VF got a new VSI, so refresh the pointer. */
-		vsi = pf->vsi[vf->lan_vsi_idx];
-	}
-
+	i40e_vc_disable_vf(vf);
+	/* During reset the VF got a new VSI, so refresh a pointer. */
+	vsi = pf->vsi[vf->lan_vsi_idx];
 	/* Locked once because multiple functions below iterate list */
 	spin_lock_bh(&vsi->mac_filter_hash_lock);