All of lore.kernel.org
 help / color / mirror / Atom feed
* [Intel-wired-lan] [PATCH iwl-net v1] i40e: Fix VF reset recognition
@ 2023-07-11  7:37 Kamil Maziarz
  2023-07-14 15:50 ` Romanowski, Rafal
  0 siblings, 1 reply; 2+ messages in thread
From: Kamil Maziarz @ 2023-07-11  7:37 UTC (permalink / raw)
  To: intel-wired-lan; +Cc: Dawid Wesierski, Kamil Maziarz

From: Dawid Wesierski <dawidx.wesierski@intel.com>

Fix the issue with i40e_trigger_vf_reset() by preventing it from
resetting the VF while it is still resetting itself and initializing
adminq's. This will avoid a series of -53 errors (failed to init adminq)
from the IAVF.

Change the state of the vf_state field to not be active when the IAVF
requests a reset. This will prevent any potential issues caused by
resetting the VF too early, as we cannot know the exact state
of the IAVF driver until we receive the message on the message box.

Fixes: 2d166c304065 ("i40e: change log messages and error returns")
Signed-off-by: Dawid Wesierski <dawidx.wesierski@intel.com>
Signed-off-by: Kamil Maziarz <kamil.maziarz@intel.com>
---
 .../net/ethernet/intel/i40e/i40e_virtchnl_pf.c   | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c b/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c
index 8a4587585acd..3fb550cf4e17 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c
@@ -1502,7 +1502,6 @@ static void i40e_cleanup_reset_vf(struct i40e_vf *vf)
 	if (!i40e_alloc_vf_res(vf)) {
 		int abs_vf_id = vf->vf_id + hw->func_caps.vf_base_id;
 		i40e_enable_vf_mappings(vf);
-		set_bit(I40E_VF_STATE_ACTIVE, &vf->vf_states);
 		clear_bit(I40E_VF_STATE_DISABLED, &vf->vf_states);
 		/* Do not notify the client during VF init */
 		if (!test_and_clear_bit(I40E_VF_STATE_PRE_ENABLE,
@@ -4079,6 +4078,7 @@ int i40e_vc_process_vf_msg(struct i40e_pf *pf, s16 vf_id, u32 v_opcode,
 		i40e_vc_notify_vf_link_state(vf);
 		break;
 	case VIRTCHNL_OP_RESET_VF:
+		clear_bit(I40E_VF_STATE_ACTIVE, &pf->vf->vf_states);
 		i40e_vc_reset_vf(vf, false);
 		ret = 0;
 		break;
@@ -4281,12 +4281,14 @@ int i40e_ndo_set_vf_mac(struct net_device *netdev, int vf_id, u8 *mac)
 			break;
 		msleep(20);
 	}
-	if (!test_bit(I40E_VF_STATE_INIT, &vf->vf_states)) {
+	if (!test_bit(I40E_VF_STATE_INIT, &vf->vf_states) ||
+	    !test_bit(I40E_VF_STATE_ACTIVE, &vf->vf_states)) {
 		dev_err(&pf->pdev->dev, "VF %d still in reset. Try again.\n",
 			vf_id);
 		ret = -EAGAIN;
 		goto error_param;
 	}
+
 	vsi = pf->vsi[vf->lan_vsi_idx];
 
 	if (is_multicast_ether_addr(mac)) {
@@ -4386,7 +4388,8 @@ int i40e_ndo_set_vf_port_vlan(struct net_device *netdev, int vf_id,
 
 	vf = &pf->vf[vf_id];
 	vsi = pf->vsi[vf->lan_vsi_idx];
-	if (!test_bit(I40E_VF_STATE_INIT, &vf->vf_states)) {
+	if (!test_bit(I40E_VF_STATE_INIT, &vf->vf_states) ||
+	    !test_bit(I40E_VF_STATE_ACTIVE, &vf->vf_states)) {
 		dev_err(&pf->pdev->dev, "VF %d still in reset. Try again.\n",
 			vf_id);
 		ret = -EAGAIN;
@@ -4775,6 +4778,13 @@ int i40e_ndo_set_vf_trust(struct net_device *netdev, int vf_id, bool setting)
 	if (setting == vf->trusted)
 		goto out;
 
+	if (!test_bit(I40E_VF_STATE_ACTIVE, &vf->vf_states)) {
+		dev_err(&pf->pdev->dev, "VF %d still in reset. Try again.\n",
+			vf_id);
+		ret = -EAGAIN;
+		goto out;
+	}
+
 	vf->trusted = setting;
 
 	/* request PF to sync mac/vlan filters for the VF */
-- 
2.31.1

_______________________________________________
Intel-wired-lan mailing list
Intel-wired-lan@osuosl.org
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan

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

* Re: [Intel-wired-lan] [PATCH iwl-net v1] i40e: Fix VF reset recognition
  2023-07-11  7:37 [Intel-wired-lan] [PATCH iwl-net v1] i40e: Fix VF reset recognition Kamil Maziarz
@ 2023-07-14 15:50 ` Romanowski, Rafal
  0 siblings, 0 replies; 2+ messages in thread
From: Romanowski, Rafal @ 2023-07-14 15:50 UTC (permalink / raw)
  To: Maziarz, Kamil, intel-wired-lan; +Cc: Dawid Wesierski, Maziarz, Kamil

> -----Original Message-----
> From: Intel-wired-lan <intel-wired-lan-bounces@osuosl.org> On Behalf Of
> Kamil Maziarz
> Sent: wtorek, 11 lipca 2023 09:38
> To: intel-wired-lan@lists.osuosl.org
> Cc: Dawid Wesierski <dawidx.wesierski@intel.com>; Maziarz, Kamil
> <kamil.maziarz@intel.com>
> Subject: [Intel-wired-lan] [PATCH iwl-net v1] i40e: Fix VF reset recognition
> 
> From: Dawid Wesierski <dawidx.wesierski@intel.com>
> 
> Fix the issue with i40e_trigger_vf_reset() by preventing it from resetting the
> VF while it is still resetting itself and initializing adminq's. This will avoid a
> series of -53 errors (failed to init adminq) from the IAVF.
> 
> Change the state of the vf_state field to not be active when the IAVF
> requests a reset. This will prevent any potential issues caused by resetting
> the VF too early, as we cannot know the exact state of the IAVF driver until
> we receive the message on the message box.
> 
> Fixes: 2d166c304065 ("i40e: change log messages and error returns")
> Signed-off-by: Dawid Wesierski <dawidx.wesierski@intel.com>
> Signed-off-by: Kamil Maziarz <kamil.maziarz@intel.com>
> ---
>  .../net/ethernet/intel/i40e/i40e_virtchnl_pf.c   | 16 +++++++++++++---
>  1 file changed, 13 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c
> b/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c
> index 8a4587585acd..3fb550cf4e17 100644
> --- a/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c
> +++ b/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c
> @@ -1502,7 +1502,6 @@ static void i40e_cleanup_reset_vf(struct i40e_vf
> *vf)
>  	if (!i40e_alloc_vf_res(vf)) {
>  		int abs_vf_id = vf->vf_id + hw->func_caps.vf_base_id;
>  		i40e_enable_vf_mappings(vf);
> -		set_bit(I40E_VF_STATE_ACTIVE, &vf->vf_states);
>  		clear_bit(I40E_VF_STATE_DISABLED, &vf->vf_states);
>  		/* Do not notify the client during VF init */
>  		if (!test_and_clear_bit(I40E_VF_STATE_PRE_ENABLE,
> @@ -4079,6 +4078,7 @@ int i40e_vc_process_vf_msg(struct i40e_pf *pf, s16
> vf_id, u32 v_opcode,
>  		i40e_vc_notify_vf_link_state(vf);
>  		break;
>  	case VIRTCHNL_OP_RESET_VF:
> +		clear_bit(I40E_VF_STATE_ACTIVE, &pf->vf->vf_states);
>  		i40e_vc_reset_vf(vf, false);
>  		ret = 0;
>  		break;
> @@ -4281,12 +4281,14 @@ int i40e_ndo_set_vf_mac(struct net_device
> *netdev, int vf_id, u8 *mac)
>  			break;
>  		msleep(20);
>  	}
> -	if (!test_bit(I40E_VF_STATE_INIT, &vf->vf_states)) {
> +	if (!test_bit(I40E_VF_STATE_INIT, &vf->vf_states) ||
> +	    !test_bit(I40E_VF_STATE_ACTIVE, &vf->vf_states)) {
>  		dev_err(&pf->pdev->dev, "VF %d still in reset. Try again.\n",
>  			vf_id);
>  		ret = -EAGAIN;
>  		goto error_param;
>  	}
> +
>  	vsi = pf->vsi[vf->lan_vsi_idx];
> 
>  	if (is_multicast_ether_addr(mac)) {
> @@ -4386,7 +4388,8 @@ int i40e_ndo_set_vf_port_vlan(struct net_device
> *netdev, int vf_id,
> 
>  	vf = &pf->vf[vf_id];
>  	vsi = pf->vsi[vf->lan_vsi_idx];
> -	if (!test_bit(I40E_VF_STATE_INIT, &vf->vf_states)) {
> +	if (!test_bit(I40E_VF_STATE_INIT, &vf->vf_states) ||
> +	    !test_bit(I40E_VF_STATE_ACTIVE, &vf->vf_states)) {
>  		dev_err(&pf->pdev->dev, "VF %d still in reset. Try again.\n",
>  			vf_id);
>  		ret = -EAGAIN;
> @@ -4775,6 +4778,13 @@ int i40e_ndo_set_vf_trust(struct net_device
> *netdev, int vf_id, bool setting)
>  	if (setting == vf->trusted)
>  		goto out;
> 
> +	if (!test_bit(I40E_VF_STATE_ACTIVE, &vf->vf_states)) {
> +		dev_err(&pf->pdev->dev, "VF %d still in reset. Try again.\n",
> +			vf_id);
> +		ret = -EAGAIN;
> +		goto out;
> +	}
> +
>  	vf->trusted = setting;
> 
>  	/* request PF to sync mac/vlan filters for the VF */
> --
> 2.31.1
> 
> _______________________________________________
> Intel-wired-lan mailing list
> Intel-wired-lan@osuosl.org
> https://lists.osuosl.org/mailman/listinfo/intel-wired-lan


Tested-by: Rafal Romanowski <rafal.romanowski@intel.com>




_______________________________________________
Intel-wired-lan mailing list
Intel-wired-lan@osuosl.org
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan

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

end of thread, other threads:[~2023-07-14 15:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-11  7:37 [Intel-wired-lan] [PATCH iwl-net v1] i40e: Fix VF reset recognition Kamil Maziarz
2023-07-14 15:50 ` Romanowski, Rafal

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.