From: Dapeng Yu <dapengx...@intel.com> It's possible that a switch rule can't be redirect successfully due to kernel driver is busy to handle an ongoing VF reset, so the redirect action need to be deferred into next redirect request which is promised by kernel driver after VF reset done.
This patch uses the saved flow rule's meta to replay switch rule remove/add during next flow redirect. Fixes: 397b4b3c5095 ("net/ice: enable flow redirect on switch") Cc: sta...@dpdk.org Signed-off-by: Dapeng Yu <dapengx...@intel.com> --- V2: * Add more filter status and VSI number --- drivers/net/ice/ice_switch_filter.c | 47 +++++++++++++++++++++++++++-- 1 file changed, 45 insertions(+), 2 deletions(-) diff --git a/drivers/net/ice/ice_switch_filter.c b/drivers/net/ice/ice_switch_filter.c index d5add64c53..5d7cdd7583 100644 --- a/drivers/net/ice/ice_switch_filter.c +++ b/drivers/net/ice/ice_switch_filter.c @@ -1926,7 +1926,10 @@ ice_switch_redirect(struct ice_adapter *ad, struct rte_flow *flow, struct ice_flow_redirect *rd) { - struct ice_rule_query_data *rdata = flow->rule; + struct ice_rule_query_data *rdata; + struct ice_switch_filter_conf *filter_conf_ptr = + (struct ice_switch_filter_conf *)flow->rule; + struct ice_rule_query_data added_rdata = { 0 }; struct ice_adv_fltr_mgmt_list_entry *list_itr; struct ice_adv_lkup_elem *lkups_dp = NULL; struct LIST_HEAD_TYPE *list_head; @@ -1936,6 +1939,8 @@ ice_switch_redirect(struct ice_adapter *ad, uint16_t lkups_cnt; int ret; + rdata = &filter_conf_ptr->sw_query_data; + if (rdata->vsi_handle != rd->vsi_handle) return 0; @@ -1946,6 +1951,33 @@ ice_switch_redirect(struct ice_adapter *ad, if (rd->type != ICE_FLOW_REDIRECT_VSI) return -ENOTSUP; + if (filter_conf_ptr->fltr_status == ICE_SW_FLTR_ADD_FAILED_ON_RIDRECT) { + /* Save VSI number for failure recover */ + filter_conf_ptr->vsi_num = rd->new_vsi_num; + + /* Update VSI context */ + hw->vsi_ctx[rd->vsi_handle]->vsi_num = rd->new_vsi_num; + + ret = ice_add_adv_rule(hw, filter_conf_ptr->lkups, + filter_conf_ptr->lkups_num, + &filter_conf_ptr->rule_info, + &added_rdata); + + if (ret) { + PMD_DRV_LOG(ERR, "Failed to replay the rule again"); + return -EINVAL; + } + + filter_conf_ptr->sw_query_data = added_rdata; + filter_conf_ptr->fltr_status = ICE_SW_FLTR_ADDED; + return 0; + } + + if (filter_conf_ptr->fltr_status == ICE_SW_FLTR_RMV_FAILED_ON_RIDRECT) { + /* Recover VSI context */ + hw->vsi_ctx[rd->vsi_handle]->vsi_num = filter_conf_ptr->vsi_num; + } + list_head = &sw->recp_list[rdata->rid].filt_rules; LIST_FOR_EACH_ENTRY(list_itr, list_head, ice_adv_fltr_mgmt_list_entry, list_entry) { @@ -1977,12 +2009,17 @@ ice_switch_redirect(struct ice_adapter *ad, if (!lkups_dp) return -EINVAL; + /* Save VSI number for failure recover */ + filter_conf_ptr->vsi_num = rd->new_vsi_num; + /* Remove the old rule */ ret = ice_rem_adv_rule(hw, list_itr->lkups, lkups_cnt, &rinfo); if (ret) { PMD_DRV_LOG(ERR, "Failed to delete the old rule %d", rdata->rule_id); + filter_conf_ptr->fltr_status = + ICE_SW_FLTR_RMV_FAILED_ON_RIDRECT; ret = -EINVAL; goto out; } @@ -1992,10 +2029,16 @@ ice_switch_redirect(struct ice_adapter *ad, /* Replay the rule */ ret = ice_add_adv_rule(hw, lkups_dp, lkups_cnt, - &rinfo, rdata); + &rinfo, &added_rdata); if (ret) { PMD_DRV_LOG(ERR, "Failed to replay the rule"); + filter_conf_ptr->fltr_status = + ICE_SW_FLTR_ADD_FAILED_ON_RIDRECT; ret = -EINVAL; + } else { + filter_conf_ptr->sw_query_data = added_rdata; + filter_conf_ptr->fltr_status = + ICE_SW_FLTR_ADDED; } out: -- 2.27.0