net/ice/base: add command to LLDP
[dpdk.git] / drivers / net / ice / ice_switch_filter.c
index d9bdf96..20e8187 100644 (file)
        ICE_INSET_VLAN_OUTER | ICE_INSET_VLAN_INNER | \
        ICE_INSET_DMAC | ICE_INSET_ETHERTYPE | ICE_INSET_PPPOE_SESSION | \
        ICE_INSET_PPPOE_PROTO)
+#define ICE_SW_INSET_MAC_IPV4_ESP ( \
+       ICE_SW_INSET_MAC_IPV4 | ICE_INSET_ESP_SPI)
+#define ICE_SW_INSET_MAC_IPV6_ESP ( \
+       ICE_SW_INSET_MAC_IPV6 | ICE_INSET_ESP_SPI)
+#define ICE_SW_INSET_MAC_IPV4_AH ( \
+       ICE_SW_INSET_MAC_IPV4 | ICE_INSET_AH_SPI)
+#define ICE_SW_INSET_MAC_IPV6_AH ( \
+       ICE_SW_INSET_MAC_IPV6 | ICE_INSET_AH_SPI)
+#define ICE_SW_INSET_MAC_IPV4_L2TP ( \
+       ICE_SW_INSET_MAC_IPV4 | ICE_INSET_L2TPV3OIP_SESSION_ID)
+#define ICE_SW_INSET_MAC_IPV6_L2TP ( \
+       ICE_SW_INSET_MAC_IPV6 | ICE_INSET_L2TPV3OIP_SESSION_ID)
+#define ICE_SW_INSET_MAC_IPV4_PFCP ( \
+       ICE_SW_INSET_MAC_IPV4 | \
+       ICE_INSET_PFCP_S_FIELD | ICE_INSET_PFCP_SEID)
+#define ICE_SW_INSET_MAC_IPV6_PFCP ( \
+       ICE_SW_INSET_MAC_IPV6 | \
+       ICE_INSET_PFCP_S_FIELD | ICE_INSET_PFCP_SEID)
 
 struct sw_meta {
        struct ice_adv_lkup_elem *list;
@@ -148,6 +166,28 @@ ice_pattern_match_item ice_switch_pattern_dist_comms[] = {
                        ICE_SW_INSET_MAC_PPPOE_PROTO, ICE_INSET_NONE},
        {pattern_eth_vlan_pppoes_proto,
                        ICE_SW_INSET_MAC_PPPOE_PROTO, ICE_INSET_NONE},
+       {pattern_eth_ipv4_esp,
+                       ICE_SW_INSET_MAC_IPV4_ESP, ICE_INSET_NONE},
+       {pattern_eth_ipv4_udp_esp,
+                       ICE_SW_INSET_MAC_IPV4_ESP, ICE_INSET_NONE},
+       {pattern_eth_ipv6_esp,
+                       ICE_SW_INSET_MAC_IPV6_ESP, ICE_INSET_NONE},
+       {pattern_eth_ipv6_udp_esp,
+                       ICE_SW_INSET_MAC_IPV6_ESP, ICE_INSET_NONE},
+       {pattern_eth_ipv4_ah,
+                       ICE_SW_INSET_MAC_IPV4_AH, ICE_INSET_NONE},
+       {pattern_eth_ipv6_ah,
+                       ICE_SW_INSET_MAC_IPV6_AH, ICE_INSET_NONE},
+       {pattern_eth_ipv6_udp_ah,
+                       ICE_INSET_NONE, ICE_INSET_NONE},
+       {pattern_eth_ipv4_l2tp,
+                       ICE_SW_INSET_MAC_IPV4_L2TP, ICE_INSET_NONE},
+       {pattern_eth_ipv6_l2tp,
+                       ICE_SW_INSET_MAC_IPV6_L2TP, ICE_INSET_NONE},
+       {pattern_eth_ipv4_pfcp,
+                       ICE_INSET_NONE, ICE_INSET_NONE},
+       {pattern_eth_ipv6_pfcp,
+                       ICE_INSET_NONE, ICE_INSET_NONE},
 };
 
 static struct
@@ -186,6 +226,8 @@ ice_pattern_match_item ice_switch_pattern_dist_os[] = {
 
 static struct
 ice_pattern_match_item ice_switch_pattern_perm[] = {
+       {pattern_ethertype,
+                       ICE_SW_INSET_ETHER, ICE_INSET_NONE},
        {pattern_ethertype_vlan,
                        ICE_SW_INSET_MAC_VLAN, ICE_INSET_NONE},
        {pattern_eth_ipv4,
@@ -212,6 +254,40 @@ ice_pattern_match_item ice_switch_pattern_perm[] = {
                        ICE_SW_INSET_PERM_TUNNEL_IPV4_UDP, ICE_INSET_NONE},
        {pattern_eth_ipv4_nvgre_eth_ipv4_tcp,
                        ICE_SW_INSET_PERM_TUNNEL_IPV4_TCP, ICE_INSET_NONE},
+       {pattern_eth_pppoed,
+                       ICE_SW_INSET_MAC_PPPOE, ICE_INSET_NONE},
+       {pattern_eth_vlan_pppoed,
+                       ICE_SW_INSET_MAC_PPPOE, ICE_INSET_NONE},
+       {pattern_eth_pppoes,
+                       ICE_SW_INSET_MAC_PPPOE, ICE_INSET_NONE},
+       {pattern_eth_vlan_pppoes,
+                       ICE_SW_INSET_MAC_PPPOE, ICE_INSET_NONE},
+       {pattern_eth_pppoes_proto,
+                       ICE_SW_INSET_MAC_PPPOE_PROTO, ICE_INSET_NONE},
+       {pattern_eth_vlan_pppoes_proto,
+                       ICE_SW_INSET_MAC_PPPOE_PROTO, ICE_INSET_NONE},
+       {pattern_eth_ipv4_esp,
+                       ICE_SW_INSET_MAC_IPV4_ESP, ICE_INSET_NONE},
+       {pattern_eth_ipv4_udp_esp,
+                       ICE_SW_INSET_MAC_IPV4_ESP, ICE_INSET_NONE},
+       {pattern_eth_ipv6_esp,
+                       ICE_SW_INSET_MAC_IPV6_ESP, ICE_INSET_NONE},
+       {pattern_eth_ipv6_udp_esp,
+                       ICE_SW_INSET_MAC_IPV6_ESP, ICE_INSET_NONE},
+       {pattern_eth_ipv4_ah,
+                       ICE_SW_INSET_MAC_IPV4_AH, ICE_INSET_NONE},
+       {pattern_eth_ipv6_ah,
+                       ICE_SW_INSET_MAC_IPV6_AH, ICE_INSET_NONE},
+       {pattern_eth_ipv6_udp_ah,
+                       ICE_INSET_NONE, ICE_INSET_NONE},
+       {pattern_eth_ipv4_l2tp,
+                       ICE_SW_INSET_MAC_IPV4_L2TP, ICE_INSET_NONE},
+       {pattern_eth_ipv6_l2tp,
+                       ICE_SW_INSET_MAC_IPV6_L2TP, ICE_INSET_NONE},
+       {pattern_eth_ipv4_pfcp,
+                       ICE_INSET_NONE, ICE_INSET_NONE},
+       {pattern_eth_ipv6_pfcp,
+                       ICE_INSET_NONE, ICE_INSET_NONE},
 };
 
 static int
@@ -319,7 +395,7 @@ ice_switch_inset_get(const struct rte_flow_item pattern[],
                struct rte_flow_error *error,
                struct ice_adv_lkup_elem *list,
                uint16_t *lkups_num,
-               enum ice_sw_tunnel_type tun_type)
+               enum ice_sw_tunnel_type *tun_type)
 {
        const struct rte_flow_item *item = pattern;
        enum rte_flow_item_type item_type;
@@ -335,11 +411,18 @@ ice_switch_inset_get(const struct rte_flow_item pattern[],
        const struct rte_flow_item_pppoe *pppoe_spec, *pppoe_mask;
        const struct rte_flow_item_pppoe_proto_id *pppoe_proto_spec,
                                *pppoe_proto_mask;
+       const struct rte_flow_item_esp *esp_spec, *esp_mask;
+       const struct rte_flow_item_ah *ah_spec, *ah_mask;
+       const struct rte_flow_item_l2tpv3oip *l2tp_spec, *l2tp_mask;
+       const struct rte_flow_item_pfcp *pfcp_spec, *pfcp_mask;
        uint64_t input_set = ICE_INSET_NONE;
        uint16_t j, t = 0;
-       uint16_t tunnel_valid = 0;
-       uint16_t pppoe_valid = 0;
-
+       bool profile_rule = 0;
+       bool tunnel_valid = 0;
+       bool pppoe_valid = 0;
+       bool ipv6_valiad = 0;
+       bool ipv4_valiad = 0;
+       bool udp_valiad = 0;
 
        for (item = pattern; item->type !=
                        RTE_FLOW_ITEM_TYPE_END; item++) {
@@ -422,6 +505,7 @@ ice_switch_inset_get(const struct rte_flow_item pattern[],
                case RTE_FLOW_ITEM_TYPE_IPV4:
                        ipv4_spec = item->spec;
                        ipv4_mask = item->mask;
+                       ipv4_valiad = 1;
                        if (ipv4_spec && ipv4_mask) {
                                /* Check IPv4 mask and update input set */
                                if (ipv4_mask->hdr.version_ihl ||
@@ -504,6 +588,7 @@ ice_switch_inset_get(const struct rte_flow_item pattern[],
                case RTE_FLOW_ITEM_TYPE_IPV6:
                        ipv6_spec = item->spec;
                        ipv6_mask = item->mask;
+                       ipv6_valiad = 1;
                        if (ipv6_spec && ipv6_mask) {
                                if (ipv6_mask->hdr.payload_len) {
                                        rte_flow_error_set(error, EINVAL,
@@ -616,6 +701,7 @@ ice_switch_inset_get(const struct rte_flow_item pattern[],
                case RTE_FLOW_ITEM_TYPE_UDP:
                        udp_spec = item->spec;
                        udp_mask = item->mask;
+                       udp_valiad = 1;
                        if (udp_spec && udp_mask) {
                                /* Check UDP mask and update input set*/
                                if (udp_mask->hdr.dgram_len ||
@@ -642,7 +728,7 @@ ice_switch_inset_get(const struct rte_flow_item pattern[],
                                                input_set |=
                                                ICE_INSET_UDP_DST_PORT;
                                }
-                               if (tun_type == ICE_SW_TUN_VXLAN &&
+                               if (*tun_type == ICE_SW_TUN_VXLAN &&
                                                tunnel_valid == 0)
                                        list[t].type = ICE_UDP_OF;
                                else
@@ -861,7 +947,7 @@ ice_switch_inset_get(const struct rte_flow_item pattern[],
                                                vlan_spec->inner_type;
                                        list[t].m_u.vlan_hdr.type =
                                                vlan_mask->inner_type;
-                                       input_set |= ICE_INSET_VLAN_OUTER;
+                                       input_set |= ICE_INSET_ETHERTYPE;
                                }
                                t++;
                        }
@@ -938,6 +1024,203 @@ ice_switch_inset_get(const struct rte_flow_item pattern[],
                        }
                        break;
 
+               case RTE_FLOW_ITEM_TYPE_ESP:
+                       esp_spec = item->spec;
+                       esp_mask = item->mask;
+                       if ((esp_spec && !esp_mask) ||
+                               (!esp_spec && esp_mask)) {
+                               rte_flow_error_set(error, EINVAL,
+                                          RTE_FLOW_ERROR_TYPE_ITEM,
+                                          item,
+                                          "Invalid esp item");
+                               return 0;
+                       }
+                       /* Check esp mask and update input set */
+                       if (esp_mask && esp_mask->hdr.seq) {
+                               rte_flow_error_set(error, EINVAL,
+                                               RTE_FLOW_ERROR_TYPE_ITEM,
+                                               item,
+                                               "Invalid esp mask");
+                               return 0;
+                       }
+
+                       if (!esp_spec && !esp_mask && !input_set) {
+                               profile_rule = 1;
+                               if (ipv6_valiad && udp_valiad)
+                                       *tun_type =
+                                       ICE_SW_TUN_PROFID_IPV6_NAT_T;
+                               else if (ipv6_valiad)
+                                       *tun_type = ICE_SW_TUN_PROFID_IPV6_ESP;
+                               else if (ipv4_valiad)
+                                       return 0;
+                       } else if (esp_spec && esp_mask &&
+                                               esp_mask->hdr.spi){
+                               if (udp_valiad)
+                                       list[t].type = ICE_NAT_T;
+                               else
+                                       list[t].type = ICE_ESP;
+                               list[t].h_u.esp_hdr.spi =
+                                       esp_spec->hdr.spi;
+                               list[t].m_u.esp_hdr.spi =
+                                       esp_mask->hdr.spi;
+                               input_set |= ICE_INSET_ESP_SPI;
+                               t++;
+                       }
+
+                       if (!profile_rule) {
+                               if (ipv6_valiad && udp_valiad)
+                                       *tun_type = ICE_SW_TUN_IPV6_NAT_T;
+                               else if (ipv4_valiad && udp_valiad)
+                                       *tun_type = ICE_SW_TUN_IPV4_NAT_T;
+                               else if (ipv6_valiad)
+                                       *tun_type = ICE_SW_TUN_IPV6_ESP;
+                               else if (ipv4_valiad)
+                                       *tun_type = ICE_SW_TUN_IPV4_ESP;
+                       }
+                       break;
+
+               case RTE_FLOW_ITEM_TYPE_AH:
+                       ah_spec = item->spec;
+                       ah_mask = item->mask;
+                       if ((ah_spec && !ah_mask) ||
+                               (!ah_spec && ah_mask)) {
+                               rte_flow_error_set(error, EINVAL,
+                                          RTE_FLOW_ERROR_TYPE_ITEM,
+                                          item,
+                                          "Invalid ah item");
+                               return 0;
+                       }
+                       /* Check ah mask and update input set */
+                       if (ah_mask &&
+                               (ah_mask->next_hdr ||
+                               ah_mask->payload_len ||
+                               ah_mask->seq_num ||
+                               ah_mask->reserved)) {
+                               rte_flow_error_set(error, EINVAL,
+                                               RTE_FLOW_ERROR_TYPE_ITEM,
+                                               item,
+                                               "Invalid ah mask");
+                               return 0;
+                       }
+
+                       if (!ah_spec && !ah_mask && !input_set) {
+                               profile_rule = 1;
+                               if (ipv6_valiad && udp_valiad)
+                                       *tun_type =
+                                       ICE_SW_TUN_PROFID_IPV6_NAT_T;
+                               else if (ipv6_valiad)
+                                       *tun_type = ICE_SW_TUN_PROFID_IPV6_AH;
+                               else if (ipv4_valiad)
+                                       return 0;
+                       } else if (ah_spec && ah_mask &&
+                                               ah_mask->spi){
+                               list[t].type = ICE_AH;
+                               list[t].h_u.ah_hdr.spi =
+                                       ah_spec->spi;
+                               list[t].m_u.ah_hdr.spi =
+                                       ah_mask->spi;
+                               input_set |= ICE_INSET_AH_SPI;
+                               t++;
+                       }
+
+                       if (!profile_rule) {
+                               if (udp_valiad)
+                                       return 0;
+                               else if (ipv6_valiad)
+                                       *tun_type = ICE_SW_TUN_IPV6_AH;
+                               else if (ipv4_valiad)
+                                       *tun_type = ICE_SW_TUN_IPV4_AH;
+                       }
+                       break;
+
+               case RTE_FLOW_ITEM_TYPE_L2TPV3OIP:
+                       l2tp_spec = item->spec;
+                       l2tp_mask = item->mask;
+                       if ((l2tp_spec && !l2tp_mask) ||
+                               (!l2tp_spec && l2tp_mask)) {
+                               rte_flow_error_set(error, EINVAL,
+                                          RTE_FLOW_ERROR_TYPE_ITEM,
+                                          item,
+                                          "Invalid l2tp item");
+                               return 0;
+                       }
+
+                       if (!l2tp_spec && !l2tp_mask && !input_set) {
+                               if (ipv6_valiad)
+                                       *tun_type =
+                                       ICE_SW_TUN_PROFID_MAC_IPV6_L2TPV3;
+                               else if (ipv4_valiad)
+                                       return 0;
+                       } else if (l2tp_spec && l2tp_mask &&
+                                               l2tp_mask->session_id){
+                               list[t].type = ICE_L2TPV3;
+                               list[t].h_u.l2tpv3_sess_hdr.session_id =
+                                       l2tp_spec->session_id;
+                               list[t].m_u.l2tpv3_sess_hdr.session_id =
+                                       l2tp_mask->session_id;
+                               input_set |= ICE_INSET_L2TPV3OIP_SESSION_ID;
+                               t++;
+                       }
+
+                       if (!profile_rule) {
+                               if (ipv6_valiad)
+                                       *tun_type =
+                                       ICE_SW_TUN_IPV6_L2TPV3;
+                               else if (ipv4_valiad)
+                                       *tun_type =
+                                       ICE_SW_TUN_IPV4_L2TPV3;
+                       }
+                       break;
+
+               case RTE_FLOW_ITEM_TYPE_PFCP:
+                       pfcp_spec = item->spec;
+                       pfcp_mask = item->mask;
+                       /* Check if PFCP item is used to describe protocol.
+                        * If yes, both spec and mask should be NULL.
+                        * If no, both spec and mask shouldn't be NULL.
+                        */
+                       if ((!pfcp_spec && pfcp_mask) ||
+                           (pfcp_spec && !pfcp_mask)) {
+                               rte_flow_error_set(error, EINVAL,
+                                          RTE_FLOW_ERROR_TYPE_ITEM,
+                                          item,
+                                          "Invalid PFCP item");
+                               return -ENOTSUP;
+                       }
+                       if (pfcp_spec && pfcp_mask) {
+                               /* Check pfcp mask and update input set */
+                               if (pfcp_mask->msg_type ||
+                                       pfcp_mask->msg_len ||
+                                       pfcp_mask->seid) {
+                                       rte_flow_error_set(error, EINVAL,
+                                               RTE_FLOW_ERROR_TYPE_ITEM,
+                                               item,
+                                               "Invalid pfcp mask");
+                                       return -ENOTSUP;
+                               }
+                               if (pfcp_mask->s_field &&
+                                       pfcp_spec->s_field == 0x01 &&
+                                       ipv6_valiad)
+                                       *tun_type =
+                                       ICE_SW_TUN_PROFID_IPV6_PFCP_SESSION;
+                               else if (pfcp_mask->s_field &&
+                                       pfcp_spec->s_field == 0x01)
+                                       *tun_type =
+                                       ICE_SW_TUN_PROFID_IPV4_PFCP_SESSION;
+                               else if (pfcp_mask->s_field &&
+                                       !pfcp_spec->s_field &&
+                                       ipv6_valiad)
+                                       *tun_type =
+                                       ICE_SW_TUN_PROFID_IPV6_PFCP_NODE;
+                               else if (pfcp_mask->s_field &&
+                                       !pfcp_spec->s_field)
+                                       *tun_type =
+                                       ICE_SW_TUN_PROFID_IPV4_PFCP_NODE;
+                               else
+                                       return -ENOTSUP;
+                       }
+                       break;
+
                case RTE_FLOW_ITEM_TYPE_VOID:
                        break;
 
@@ -984,6 +1267,7 @@ ice_switch_parse_dcf_action(const struct rte_flow_action *actions,
        }
 
        rule_info->sw_act.src = rule_info->sw_act.vsi_handle;
+       rule_info->sw_act.flag = ICE_FLTR_RX;
        rule_info->rx = 1;
        rule_info->priority = 5;
 
@@ -1013,6 +1297,8 @@ ice_switch_parse_action(struct ice_pf *pf,
                switch (action_type) {
                case RTE_FLOW_ACTION_TYPE_RSS:
                        act_qgrop = action->conf;
+                       if (act_qgrop->queue_num <= 1)
+                               goto error;
                        rule_info->sw_act.fltr_act =
                                ICE_FWD_TO_QGRP;
                        rule_info->sw_act.fwd_id.q_id =
@@ -1073,6 +1359,66 @@ error:
        return -rte_errno;
 }
 
+static int
+ice_switch_check_action(const struct rte_flow_action *actions,
+                           struct rte_flow_error *error)
+{
+       const struct rte_flow_action *action;
+       enum rte_flow_action_type action_type;
+       uint16_t actions_num = 0;
+
+       for (action = actions; action->type !=
+                               RTE_FLOW_ACTION_TYPE_END; action++) {
+               action_type = action->type;
+               switch (action_type) {
+               case RTE_FLOW_ACTION_TYPE_VF:
+               case RTE_FLOW_ACTION_TYPE_RSS:
+               case RTE_FLOW_ACTION_TYPE_QUEUE:
+               case RTE_FLOW_ACTION_TYPE_DROP:
+                       actions_num++;
+                       break;
+               case RTE_FLOW_ACTION_TYPE_VOID:
+                       continue;
+               default:
+                       rte_flow_error_set(error,
+                                          EINVAL, RTE_FLOW_ERROR_TYPE_ACTION,
+                                          actions,
+                                          "Invalid action type");
+                       return -rte_errno;
+               }
+       }
+
+       if (actions_num != 1) {
+               rte_flow_error_set(error,
+                                  EINVAL, RTE_FLOW_ERROR_TYPE_ACTION,
+                                  actions,
+                                  "Invalid action number");
+               return -rte_errno;
+       }
+
+       return 0;
+}
+
+static bool
+ice_is_profile_rule(enum ice_sw_tunnel_type tun_type)
+{
+       switch (tun_type) {
+       case ICE_SW_TUN_PROFID_IPV6_ESP:
+       case ICE_SW_TUN_PROFID_IPV6_AH:
+       case ICE_SW_TUN_PROFID_MAC_IPV6_L2TPV3:
+       case ICE_SW_TUN_PROFID_IPV6_NAT_T:
+       case ICE_SW_TUN_PROFID_IPV4_PFCP_NODE:
+       case ICE_SW_TUN_PROFID_IPV4_PFCP_SESSION:
+       case ICE_SW_TUN_PROFID_IPV6_PFCP_NODE:
+       case ICE_SW_TUN_PROFID_IPV6_PFCP_SESSION:
+               return true;
+       default:
+               break;
+       }
+
+       return false;
+}
+
 static int
 ice_switch_parse_pattern_action(struct ice_adapter *ad,
                struct ice_pattern_match_item *array,
@@ -1128,8 +1474,6 @@ ice_switch_parse_pattern_action(struct ice_adapter *ad,
                return -rte_errno;
        }
 
-       rule_info.tun_type = tun_type;
-
        sw_meta_ptr =
                rte_zmalloc(NULL, sizeof(*sw_meta_ptr), 0);
        if (!sw_meta_ptr) {
@@ -1149,8 +1493,9 @@ ice_switch_parse_pattern_action(struct ice_adapter *ad,
        }
 
        inputset = ice_switch_inset_get
-               (pattern, error, list, &lkups_num, tun_type);
-       if (!inputset || (inputset & ~pattern_match_item->input_set_mask)) {
+               (pattern, error, list, &lkups_num, &tun_type);
+       if ((!inputset && !ice_is_profile_rule(tun_type)) ||
+               (inputset & ~pattern_match_item->input_set_mask)) {
                rte_flow_error_set(error, EINVAL,
                                   RTE_FLOW_ERROR_TYPE_ITEM_SPEC,
                                   pattern,
@@ -1158,6 +1503,17 @@ ice_switch_parse_pattern_action(struct ice_adapter *ad,
                goto error;
        }
 
+       memset(&rule_info, 0, sizeof(rule_info));
+       rule_info.tun_type = tun_type;
+
+       ret = ice_switch_check_action(actions, error);
+       if (ret) {
+               rte_flow_error_set(error, EINVAL,
+                                  RTE_FLOW_ERROR_TYPE_HANDLE, NULL,
+                                  "Invalid input action number");
+               goto error;
+       }
+
        if (ad->hw.dcf_enabled)
                ret = ice_switch_parse_dcf_action(actions, error, &rule_info);
        else
@@ -1206,6 +1562,78 @@ ice_switch_query(struct ice_adapter *ad __rte_unused,
        return -rte_errno;
 }
 
+static int
+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_adv_fltr_mgmt_list_entry *list_itr;
+       struct ice_adv_lkup_elem *lkups_dp = NULL;
+       struct LIST_HEAD_TYPE *list_head;
+       struct ice_adv_rule_info rinfo;
+       struct ice_hw *hw = &ad->hw;
+       struct ice_switch_info *sw;
+       uint16_t lkups_cnt;
+       int ret;
+
+       sw = hw->switch_info;
+       if (!sw->recp_list[rdata->rid].recp_created)
+               return -EINVAL;
+
+       if (rd->type != ICE_FLOW_REDIRECT_VSI)
+               return -ENOTSUP;
+
+       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) {
+               rinfo = list_itr->rule_info;
+               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) {
+                       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;
+                       }
+
+                       break;
+               }
+       }
+
+       if (!lkups_dp)
+               return 0;
+
+       /* 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);
+               ret = -EINVAL;
+               goto out;
+       }
+
+       /* Update VSI context */
+       hw->vsi_ctx[rd->vsi_handle]->vsi_num = rd->new_vsi_num;
+
+       /* Replay the rule */
+       ret = ice_add_adv_rule(hw, lkups_dp, lkups_cnt,
+                              &rinfo, rdata);
+       if (ret) {
+               PMD_DRV_LOG(ERR, "Failed to replay the rule");
+               ret = -EINVAL;
+       }
+
+out:
+       ice_free(hw, lkups_dp);
+       return ret;
+}
+
 static int
 ice_switch_init(struct ice_adapter *ad)
 {
@@ -1251,6 +1679,7 @@ ice_flow_engine ice_switch_engine = {
        .create = ice_switch_create,
        .destroy = ice_switch_destroy,
        .query_count = ice_switch_query,
+       .redirect = ice_switch_redirect,
        .free = ice_switch_filter_rule_free,
        .type = ICE_FLOW_ENGINE_SWITCH,
 };