[v2,13/13] net/ice: redirect switch rule to new VSI

Message ID 20200402064620.47668-14-wei.zhao1@intel.com (mailing list archive)
State Superseded, archived
Delegated to: xiaolong ye
Headers
Series add switch filter support for intel DCF |

Checks

Context Check Description
ci/checkpatch warning coding style issues
ci/Intel-compilation success Compilation OK

Commit Message

Zhao1, Wei April 2, 2020, 6:46 a.m. UTC
  After VF reset, VF's VSI number may be changed,
the switch rule which forwards packet to the old
VSI number should be redirected to the new VSI
number.

Signed-off-by: Beilei Xing <beilei.xing@intel.com>
---
 drivers/net/ice/ice_dcf_parent.c | 22 +++++++++++++++++++---
 1 file changed, 19 insertions(+), 3 deletions(-)
  

Comments

Wang, Haiyue April 2, 2020, 7:32 a.m. UTC | #1
> -----Original Message-----
> From: Zhao1, Wei <wei.zhao1@intel.com>
> Sent: Thursday, April 2, 2020 14:46
> To: dev@dpdk.org
> Cc: Zhang, Qi Z <qi.z.zhang@intel.com>; Peng, Yuan <yuan.peng@intel.com>; Lu, Nannan
> <nannan.lu@intel.com>; Fu, Qi <qi.fu@intel.com>; Wang, Haiyue <haiyue.wang@intel.com>; Xing, Beilei
> <beilei.xing@intel.com>
> Subject: [PATCH v2 13/13] net/ice: redirect switch rule to new VSI
> 
> After VF reset, VF's VSI number may be changed,
> the switch rule which forwards packet to the old
> VSI number should be redirected to the new VSI
> number.
> 
> Signed-off-by: Beilei Xing <beilei.xing@intel.com>
> ---
>  drivers/net/ice/ice_dcf_parent.c | 22 +++++++++++++++++++---
>  1 file changed, 19 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/net/ice/ice_dcf_parent.c b/drivers/net/ice/ice_dcf_parent.c
> index 37f0e2be2..e05b6b3e5 100644
> --- a/drivers/net/ice/ice_dcf_parent.c
> +++ b/drivers/net/ice/ice_dcf_parent.c
> @@ -19,6 +19,8 @@ ice_dcf_update_vsi_ctx(struct ice_hw *hw, uint16_t vsi_handle,
>  		       uint16_t vsi_map)
>  {
>  	struct ice_vsi_ctx *vsi_ctx;
> +	bool first_update = false;
> +	uint16_t new_vsi_num;
> 
>  	if (unlikely(vsi_handle >= ICE_MAX_VSI)) {
>  		PMD_DRV_LOG(ERR, "Invalid vsi handle %u", vsi_handle);
> @@ -35,11 +37,25 @@ ice_dcf_update_vsi_ctx(struct ice_hw *hw, uint16_t vsi_handle,
>  					    vsi_handle);
>  				return;
>  			}
> +			hw->vsi_ctx[vsi_handle] = vsi_ctx;
> +			first_update = true;
>  		}
> 
> -		vsi_ctx->vsi_num = (vsi_map & VIRTCHNL_DCF_VF_VSI_ID_M) >>
> -					      VIRTCHNL_DCF_VF_VSI_ID_S;
> -		hw->vsi_ctx[vsi_handle] = vsi_ctx;
> +		new_vsi_num = (vsi_map & VIRTCHNL_DCF_VF_VSI_ID_M) >>
> +			VIRTCHNL_DCF_VF_VSI_ID_S;
> +
> +		/* Redirect rules if vsi mapping table changes. */
> +		if (!first_update && vsi_ctx->vsi_num != new_vsi_num) {
> +			struct ice_flow_redirect rd;
> +
> +			memset(&rd, 0, sizeof(struct ice_flow_redirect));
> +			rd.type = ICE_FLOW_REDIRECT_VSI;
> +			rd.vsi_handle = vsi_handle;
> +			rd.new_vsi_num = new_vsi_num;
> +			ice_flow_redirect((struct ice_adapter *)hw->back, &rd);
> +		} else {
> +			vsi_ctx->vsi_num = new_vsi_num;
> +		}
> 
>  		PMD_DRV_LOG(DEBUG, "VF%u is assigned with vsi number %u",
>  			    vsi_handle, vsi_ctx->vsi_num);
> --
> 2.19.1

Acked-by: Haiyue Wang <haiyue.wang@intel.com>
  

Patch

diff --git a/drivers/net/ice/ice_dcf_parent.c b/drivers/net/ice/ice_dcf_parent.c
index 37f0e2be2..e05b6b3e5 100644
--- a/drivers/net/ice/ice_dcf_parent.c
+++ b/drivers/net/ice/ice_dcf_parent.c
@@ -19,6 +19,8 @@  ice_dcf_update_vsi_ctx(struct ice_hw *hw, uint16_t vsi_handle,
 		       uint16_t vsi_map)
 {
 	struct ice_vsi_ctx *vsi_ctx;
+	bool first_update = false;
+	uint16_t new_vsi_num;
 
 	if (unlikely(vsi_handle >= ICE_MAX_VSI)) {
 		PMD_DRV_LOG(ERR, "Invalid vsi handle %u", vsi_handle);
@@ -35,11 +37,25 @@  ice_dcf_update_vsi_ctx(struct ice_hw *hw, uint16_t vsi_handle,
 					    vsi_handle);
 				return;
 			}
+			hw->vsi_ctx[vsi_handle] = vsi_ctx;
+			first_update = true;
 		}
 
-		vsi_ctx->vsi_num = (vsi_map & VIRTCHNL_DCF_VF_VSI_ID_M) >>
-					      VIRTCHNL_DCF_VF_VSI_ID_S;
-		hw->vsi_ctx[vsi_handle] = vsi_ctx;
+		new_vsi_num = (vsi_map & VIRTCHNL_DCF_VF_VSI_ID_M) >>
+			VIRTCHNL_DCF_VF_VSI_ID_S;
+
+		/* Redirect rules if vsi mapping table changes. */
+		if (!first_update && vsi_ctx->vsi_num != new_vsi_num) {
+			struct ice_flow_redirect rd;
+
+			memset(&rd, 0, sizeof(struct ice_flow_redirect));
+			rd.type = ICE_FLOW_REDIRECT_VSI;
+			rd.vsi_handle = vsi_handle;
+			rd.new_vsi_num = new_vsi_num;
+			ice_flow_redirect((struct ice_adapter *)hw->back, &rd);
+		} else {
+			vsi_ctx->vsi_num = new_vsi_num;
+		}
 
 		PMD_DRV_LOG(DEBUG, "VF%u is assigned with vsi number %u",
 			    vsi_handle, vsi_ctx->vsi_num);