net/ice: redirect switch rule with to VSI list action
authorWei Zhao <wei.zhao1@intel.com>
Wed, 17 Jun 2020 06:14:27 +0000 (14:14 +0800)
committerFerruh Yigit <ferruh.yigit@intel.com>
Tue, 7 Jul 2020 21:38:26 +0000 (23:38 +0200)
Support redirect a switch rule if its action is to VSI list.

Fixes: 397b4b3c5095 ("net/ice: enable flow redirect on switch")
Cc: stable@dpdk.org
Signed-off-by: Wei Zhao <wei.zhao1@intel.com>
Acked-by: Qi Zhang <qi.z.zhang@intel.com>
drivers/net/ice/ice_switch_filter.c

index 33327e9..cc0af23 100644 (file)
@@ -1584,6 +1584,9 @@ ice_switch_redirect(struct ice_adapter *ad,
        uint16_t lkups_cnt;
        int ret;
 
+       if (rdata->vsi_handle != rd->vsi_handle)
+               return 0;
+
        sw = hw->switch_info;
        if (!sw->recp_list[rdata->rid].recp_created)
                return -EINVAL;
@@ -1595,25 +1598,32 @@ ice_switch_redirect(struct ice_adapter *ad,
        LIST_FOR_EACH_ENTRY(list_itr, list_head, ice_adv_fltr_mgmt_list_entry,
                            list_entry) {
                rinfo = list_itr->rule_info;
-               if (rinfo.fltr_rule_id == rdata->rule_id &&
+               if ((rinfo.fltr_rule_id == rdata->rule_id &&
                    rinfo.sw_act.fltr_act == ICE_FWD_TO_VSI &&
-                   rinfo.sw_act.vsi_handle == rd->vsi_handle) {
+                   rinfo.sw_act.vsi_handle == rd->vsi_handle) ||
+                   (rinfo.fltr_rule_id == rdata->rule_id &&
+                   rinfo.sw_act.fltr_act == ICE_FWD_TO_VSI_LIST)){
                        lkups_cnt = list_itr->lkups_cnt;
                        lkups_dp = (struct ice_adv_lkup_elem *)
                                ice_memdup(hw, list_itr->lkups,
                                           sizeof(*list_itr->lkups) *
                                           lkups_cnt, ICE_NONDMA_TO_NONDMA);
+
                        if (!lkups_dp) {
                                PMD_DRV_LOG(ERR, "Failed to allocate memory.");
                                return -EINVAL;
                        }
 
+                       if (rinfo.sw_act.fltr_act == ICE_FWD_TO_VSI_LIST) {
+                               rinfo.sw_act.vsi_handle = rd->vsi_handle;
+                               rinfo.sw_act.fltr_act = ICE_FWD_TO_VSI;
+                       }
                        break;
                }
        }
 
        if (!lkups_dp)
-               return 0;
+               return -EINVAL;
 
        /* Remove the old rule */
        ret = ice_rem_adv_rule(hw, list_itr->lkups,