net/mlx5: fix RSS RETA update
[dpdk.git] / drivers / net / mlx5 / mlx5_flow_dv.c
index 23ee6a2..a5ced50 100644 (file)
@@ -15,6 +15,7 @@
 #include <rte_flow_driver.h>
 #include <rte_malloc.h>
 #include <rte_cycles.h>
+#include <rte_bus_pci.h>
 #include <rte_ip.h>
 #include <rte_gre.h>
 #include <rte_vxlan.h>
@@ -92,6 +93,23 @@ static int
 flow_dv_jump_tbl_resource_release(struct rte_eth_dev *dev,
                                  uint32_t rix_jump);
 
+static int16_t
+flow_dv_get_esw_manager_vport_id(struct rte_eth_dev *dev)
+{
+       struct mlx5_priv *priv = dev->data->dev_private;
+
+       if (priv->pci_dev == NULL)
+               return 0;
+       switch (priv->pci_dev->id.device_id) {
+       case PCI_DEVICE_ID_MELLANOX_CONNECTX5BF:
+       case PCI_DEVICE_ID_MELLANOX_CONNECTX6DXBF:
+       case PCI_DEVICE_ID_MELLANOX_CONNECTX7BF:
+               return (int16_t)0xfffe;
+       default:
+               return 0;
+       }
+}
+
 /**
  * Initialize flow attributes structure according to flow items' types.
  *
@@ -269,31 +287,6 @@ struct field_modify_info modify_tcp[] = {
        {0, 0, 0},
 };
 
-static const struct rte_flow_item *
-mlx5_flow_find_tunnel_item(const struct rte_flow_item *item)
-{
-       for (; item->type != RTE_FLOW_ITEM_TYPE_END; item++) {
-               switch (item->type) {
-               default:
-                       break;
-               case RTE_FLOW_ITEM_TYPE_VXLAN:
-               case RTE_FLOW_ITEM_TYPE_VXLAN_GPE:
-               case RTE_FLOW_ITEM_TYPE_GRE:
-               case RTE_FLOW_ITEM_TYPE_MPLS:
-               case RTE_FLOW_ITEM_TYPE_NVGRE:
-               case RTE_FLOW_ITEM_TYPE_GENEVE:
-                       return item;
-               case RTE_FLOW_ITEM_TYPE_IPV4:
-               case RTE_FLOW_ITEM_TYPE_IPV6:
-                       if (item[1].type == RTE_FLOW_ITEM_TYPE_IPV4 ||
-                           item[1].type == RTE_FLOW_ITEM_TYPE_IPV6)
-                               return item;
-                       break;
-               }
-       }
-       return NULL;
-}
-
 static void
 mlx5_flow_tunnel_ip_check(const struct rte_flow_item *item __rte_unused,
                          uint8_t next_protocol, uint64_t *item_flags,
@@ -2184,6 +2177,8 @@ flow_dv_validate_item_port_id(struct rte_eth_dev *dev,
                return ret;
        if (!spec)
                return 0;
+       if (spec->id == MLX5_PORT_ESW_MGR)
+               return 0;
        esw_priv = mlx5_port_to_eswitch_info(spec->id, false);
        if (!esw_priv)
                return rte_flow_error_set(error, rte_errno,
@@ -3290,7 +3285,7 @@ flow_dv_validate_action_count(struct rte_eth_dev *dev, bool shared,
 {
        struct mlx5_priv *priv = dev->data->dev_private;
 
-       if (!priv->config.devx)
+       if (!priv->sh->devx)
                goto notsup_err;
        if (action_flags & MLX5_FLOW_ACTION_COUNT)
                return rte_flow_error_set(error, EINVAL,
@@ -3618,8 +3613,8 @@ flow_dv_encap_decap_create_cb(void *tool_ctx, void *cb_ctx)
        }
        *resource = *ctx_resource;
        resource->idx = idx;
-       ret = mlx5_flow_os_create_flow_action_packet_reformat(sh->ctx, domain,
-                                                             resource,
+       ret = mlx5_flow_os_create_flow_action_packet_reformat(sh->cdev->ctx,
+                                                             domain, resource,
                                                             &resource->action);
        if (ret) {
                mlx5_ipool_free(sh->ipool[MLX5_IPOOL_DECAP_ENCAP], idx);
@@ -5252,7 +5247,7 @@ flow_dv_validate_action_age(uint64_t action_flags,
        struct mlx5_priv *priv = dev->data->dev_private;
        const struct rte_flow_action_age *age = action->conf;
 
-       if (!priv->config.devx || (priv->sh->cmng.counter_fallback &&
+       if (!priv->sh->devx || (priv->sh->cmng.counter_fallback &&
            !priv->sh->aso_age_mng))
                return rte_flow_error_set(error, ENOTSUP,
                                          RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
@@ -5434,7 +5429,7 @@ flow_dv_modify_create_cb(void *tool_ctx, void *cb_ctx)
        else
                ns = sh->rx_domain;
        ret = mlx5_flow_os_create_flow_action_modify_header
-                                       (sh->ctx, ns, entry,
+                                       (sh->cdev->ctx, ns, entry,
                                         data_len, &entry->action);
        if (ret) {
                mlx5_ipool_free(sh->mdh_ipools[ref->actions_num - 1], idx);
@@ -5537,7 +5532,7 @@ flow_dv_validate_action_sample(uint64_t *action_flags,
                return rte_flow_error_set(error, EINVAL,
                                          RTE_FLOW_ERROR_TYPE_ACTION, action,
                                          "ratio value starts from 1");
-       if (!priv->config.devx || (sample->ratio > 0 && !priv->sampler_en))
+       if (!priv->sh->devx || (sample->ratio > 0 && !priv->sampler_en))
                return rte_flow_error_set(error, ENOTSUP,
                                          RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
                                          NULL,
@@ -6056,7 +6051,7 @@ flow_dv_counter_pool_prepare(struct rte_eth_dev *dev,
 
        if (fallback) {
                /* bulk_bitmap must be 0 for single counter allocation. */
-               dcs = mlx5_devx_cmd_flow_counter_alloc(priv->sh->ctx, 0);
+               dcs = mlx5_devx_cmd_flow_counter_alloc(priv->sh->cdev->ctx, 0);
                if (!dcs)
                        return NULL;
                pool = flow_dv_find_pool_by_id(cmng, dcs->id);
@@ -6074,7 +6069,7 @@ flow_dv_counter_pool_prepare(struct rte_eth_dev *dev,
                *cnt_free = cnt;
                return pool;
        }
-       dcs = mlx5_devx_cmd_flow_counter_alloc(priv->sh->ctx, 0x4);
+       dcs = mlx5_devx_cmd_flow_counter_alloc(priv->sh->cdev->ctx, 0x4);
        if (!dcs) {
                rte_errno = ENODATA;
                return NULL;
@@ -6121,7 +6116,7 @@ flow_dv_counter_alloc(struct rte_eth_dev *dev, uint32_t age)
                        age ? MLX5_COUNTER_TYPE_AGE : MLX5_COUNTER_TYPE_ORIGIN;
        uint32_t cnt_idx;
 
-       if (!priv->config.devx) {
+       if (!priv->sh->devx) {
                rte_errno = ENOTSUP;
                return 0;
        }
@@ -6357,20 +6352,19 @@ flow_dv_mtr_container_resize(struct rte_eth_dev *dev)
  *   NULL otherwise and rte_errno is set.
  */
 static struct mlx5_aso_mtr_pool *
-flow_dv_mtr_pool_create(struct rte_eth_dev *dev,
-                            struct mlx5_aso_mtr **mtr_free)
+flow_dv_mtr_pool_create(struct rte_eth_dev *dev, struct mlx5_aso_mtr **mtr_free)
 {
        struct mlx5_priv *priv = dev->data->dev_private;
-       struct mlx5_aso_mtr_pools_mng *pools_mng =
-                               &priv->sh->mtrmng->pools_mng;
+       struct mlx5_aso_mtr_pools_mng *pools_mng = &priv->sh->mtrmng->pools_mng;
        struct mlx5_aso_mtr_pool *pool = NULL;
        struct mlx5_devx_obj *dcs = NULL;
        uint32_t i;
        uint32_t log_obj_size;
 
        log_obj_size = rte_log2_u32(MLX5_ASO_MTRS_PER_POOL >> 1);
-       dcs = mlx5_devx_cmd_create_flow_meter_aso_obj(priv->sh->ctx,
-                       priv->sh->pdn, log_obj_size);
+       dcs = mlx5_devx_cmd_create_flow_meter_aso_obj(priv->sh->cdev->ctx,
+                                                     priv->sh->cdev->pdn,
+                                                     log_obj_size);
        if (!dcs) {
                rte_errno = ENODATA;
                return NULL;
@@ -6392,8 +6386,7 @@ flow_dv_mtr_pool_create(struct rte_eth_dev *dev,
        pools_mng->n_valid++;
        for (i = 1; i < MLX5_ASO_MTRS_PER_POOL; ++i) {
                pool->mtrs[i].offset = i;
-               LIST_INSERT_HEAD(&pools_mng->meters,
-                                               &pool->mtrs[i], next);
+               LIST_INSERT_HEAD(&pools_mng->meters, &pool->mtrs[i], next);
        }
        pool->mtrs[0].offset = 0;
        *mtr_free = &pool->mtrs[0];
@@ -6443,7 +6436,7 @@ flow_dv_mtr_alloc(struct rte_eth_dev *dev)
        struct mlx5_aso_mtr_pool *pool;
        uint32_t mtr_idx = 0;
 
-       if (!priv->config.devx) {
+       if (!priv->sh->devx) {
                rte_errno = ENOTSUP;
                return 0;
        }
@@ -6563,119 +6556,85 @@ flow_dv_validate_attributes(struct rte_eth_dev *dev,
        return ret;
 }
 
-static uint16_t
-mlx5_flow_locate_proto_l3(const struct rte_flow_item **head,
-                         const struct rte_flow_item *end)
+static int
+validate_integrity_bits(const struct rte_flow_item_integrity *mask,
+                       int64_t pattern_flags, uint64_t l3_flags,
+                       uint64_t l4_flags, uint64_t ip4_flag,
+                       struct rte_flow_error *error)
 {
-       const struct rte_flow_item *item = *head;
-       uint16_t l3_protocol;
+       if (mask->l3_ok && !(pattern_flags & l3_flags))
+               return rte_flow_error_set(error, EINVAL,
+                                         RTE_FLOW_ERROR_TYPE_ITEM,
+                                         NULL, "missing L3 protocol");
+
+       if (mask->ipv4_csum_ok && !(pattern_flags & ip4_flag))
+               return rte_flow_error_set(error, EINVAL,
+                                         RTE_FLOW_ERROR_TYPE_ITEM,
+                                         NULL, "missing IPv4 protocol");
+
+       if ((mask->l4_ok || mask->l4_csum_ok) && !(pattern_flags & l4_flags))
+               return rte_flow_error_set(error, EINVAL,
+                                         RTE_FLOW_ERROR_TYPE_ITEM,
+                                         NULL, "missing L4 protocol");
 
-       for (; item != end; item++) {
-               switch (item->type) {
-               default:
-                       break;
-               case RTE_FLOW_ITEM_TYPE_IPV4:
-                       l3_protocol = RTE_ETHER_TYPE_IPV4;
-                       goto l3_ok;
-               case RTE_FLOW_ITEM_TYPE_IPV6:
-                       l3_protocol = RTE_ETHER_TYPE_IPV6;
-                       goto l3_ok;
-               case RTE_FLOW_ITEM_TYPE_ETH:
-                       if (item->mask && item->spec) {
-                               MLX5_ETHER_TYPE_FROM_HEADER(rte_flow_item_eth,
-                                                           type, item,
-                                                           l3_protocol);
-                               if (l3_protocol == RTE_ETHER_TYPE_IPV4 ||
-                                   l3_protocol == RTE_ETHER_TYPE_IPV6)
-                                       goto l3_ok;
-                       }
-                       break;
-               case RTE_FLOW_ITEM_TYPE_VLAN:
-                       if (item->mask && item->spec) {
-                               MLX5_ETHER_TYPE_FROM_HEADER(rte_flow_item_vlan,
-                                                           inner_type, item,
-                                                           l3_protocol);
-                               if (l3_protocol == RTE_ETHER_TYPE_IPV4 ||
-                                   l3_protocol == RTE_ETHER_TYPE_IPV6)
-                                       goto l3_ok;
-                       }
-                       break;
-               }
-       }
        return 0;
-l3_ok:
-       *head = item;
-       return l3_protocol;
 }
 
-static uint8_t
-mlx5_flow_locate_proto_l4(const struct rte_flow_item **head,
-                         const struct rte_flow_item *end)
+static int
+flow_dv_validate_item_integrity_post(const struct
+                                    rte_flow_item *integrity_items[2],
+                                    int64_t pattern_flags,
+                                    struct rte_flow_error *error)
 {
-       const struct rte_flow_item *item = *head;
-       uint8_t l4_protocol;
+       const struct rte_flow_item_integrity *mask;
+       int ret;
 
-       for (; item != end; item++) {
-               switch (item->type) {
-               default:
-                       break;
-               case RTE_FLOW_ITEM_TYPE_TCP:
-                       l4_protocol = IPPROTO_TCP;
-                       goto l4_ok;
-               case RTE_FLOW_ITEM_TYPE_UDP:
-                       l4_protocol = IPPROTO_UDP;
-                       goto l4_ok;
-               case RTE_FLOW_ITEM_TYPE_IPV4:
-                       if (item->mask && item->spec) {
-                               const struct rte_flow_item_ipv4 *mask, *spec;
-
-                               mask = (typeof(mask))item->mask;
-                               spec = (typeof(spec))item->spec;
-                               l4_protocol = mask->hdr.next_proto_id &
-                                             spec->hdr.next_proto_id;
-                               if (l4_protocol == IPPROTO_TCP ||
-                                   l4_protocol == IPPROTO_UDP)
-                                       goto l4_ok;
-                       }
-                       break;
-               case RTE_FLOW_ITEM_TYPE_IPV6:
-                       if (item->mask && item->spec) {
-                               const struct rte_flow_item_ipv6 *mask, *spec;
-                               mask = (typeof(mask))item->mask;
-                               spec = (typeof(spec))item->spec;
-                               l4_protocol = mask->hdr.proto & spec->hdr.proto;
-                               if (l4_protocol == IPPROTO_TCP ||
-                                   l4_protocol == IPPROTO_UDP)
-                                       goto l4_ok;
-                       }
-                       break;
-               }
+       if (pattern_flags & MLX5_FLOW_ITEM_OUTER_INTEGRITY) {
+               mask = (typeof(mask))integrity_items[0]->mask;
+               ret = validate_integrity_bits(mask, pattern_flags,
+                                             MLX5_FLOW_LAYER_OUTER_L3,
+                                             MLX5_FLOW_LAYER_OUTER_L4,
+                                             MLX5_FLOW_LAYER_OUTER_L3_IPV4,
+                                             error);
+               if (ret)
+                       return ret;
+       }
+       if (pattern_flags & MLX5_FLOW_ITEM_INNER_INTEGRITY) {
+               mask = (typeof(mask))integrity_items[1]->mask;
+               ret = validate_integrity_bits(mask, pattern_flags,
+                                             MLX5_FLOW_LAYER_INNER_L3,
+                                             MLX5_FLOW_LAYER_INNER_L4,
+                                             MLX5_FLOW_LAYER_INNER_L3_IPV4,
+                                             error);
+               if (ret)
+                       return ret;
        }
        return 0;
-l4_ok:
-       *head = item;
-       return l4_protocol;
 }
 
 static int
 flow_dv_validate_item_integrity(struct rte_eth_dev *dev,
-                               const struct rte_flow_item *rule_items,
                                const struct rte_flow_item *integrity_item,
+                               uint64_t pattern_flags, uint64_t *last_item,
+                               const struct rte_flow_item *integrity_items[2],
                                struct rte_flow_error *error)
 {
        struct mlx5_priv *priv = dev->data->dev_private;
-       const struct rte_flow_item *tunnel_item, *end_item, *item = rule_items;
        const struct rte_flow_item_integrity *mask = (typeof(mask))
                                                     integrity_item->mask;
        const struct rte_flow_item_integrity *spec = (typeof(spec))
                                                     integrity_item->spec;
-       uint32_t protocol;
 
        if (!priv->config.hca_attr.pkt_integrity_match)
                return rte_flow_error_set(error, ENOTSUP,
                                          RTE_FLOW_ERROR_TYPE_ITEM,
                                          integrity_item,
                                          "packet integrity integrity_item not supported");
+       if (!spec)
+               return rte_flow_error_set(error, ENOTSUP,
+                                         RTE_FLOW_ERROR_TYPE_ITEM,
+                                         integrity_item,
+                                         "no spec for integrity item");
        if (!mask)
                mask = &rte_flow_item_integrity_mask;
        if (!mlx5_validate_integrity_item(mask))
@@ -6683,34 +6642,22 @@ flow_dv_validate_item_integrity(struct rte_eth_dev *dev,
                                          RTE_FLOW_ERROR_TYPE_ITEM,
                                          integrity_item,
                                          "unsupported integrity filter");
-       tunnel_item = mlx5_flow_find_tunnel_item(rule_items);
        if (spec->level > 1) {
-               if (!tunnel_item)
-                       return rte_flow_error_set(error, ENOTSUP,
-                                                 RTE_FLOW_ERROR_TYPE_ITEM,
-                                                 integrity_item,
-                                                 "missing tunnel item");
-               item = tunnel_item;
-               end_item = mlx5_find_end_item(tunnel_item);
+               if (pattern_flags & MLX5_FLOW_ITEM_INNER_INTEGRITY)
+                       return rte_flow_error_set
+                               (error, ENOTSUP,
+                                RTE_FLOW_ERROR_TYPE_ITEM,
+                                NULL, "multiple inner integrity items not supported");
+               integrity_items[1] = integrity_item;
+               *last_item |= MLX5_FLOW_ITEM_INNER_INTEGRITY;
        } else {
-               end_item = tunnel_item ? tunnel_item :
-                          mlx5_find_end_item(integrity_item);
-       }
-       if (mask->l3_ok || mask->ipv4_csum_ok) {
-               protocol = mlx5_flow_locate_proto_l3(&item, end_item);
-               if (!protocol)
-                       return rte_flow_error_set(error, EINVAL,
-                                                 RTE_FLOW_ERROR_TYPE_ITEM,
-                                                 integrity_item,
-                                                 "missing L3 protocol");
-       }
-       if (mask->l4_ok || mask->l4_csum_ok) {
-               protocol = mlx5_flow_locate_proto_l4(&item, end_item);
-               if (!protocol)
-                       return rte_flow_error_set(error, EINVAL,
-                                                 RTE_FLOW_ERROR_TYPE_ITEM,
-                                                 integrity_item,
-                                                 "missing L4 protocol");
+               if (pattern_flags & MLX5_FLOW_ITEM_OUTER_INTEGRITY)
+                       return rte_flow_error_set
+                               (error, ENOTSUP,
+                                RTE_FLOW_ERROR_TYPE_ITEM,
+                                NULL, "multiple outer integrity items not supported");
+               integrity_items[0] = integrity_item;
+               *last_item |= MLX5_FLOW_ITEM_OUTER_INTEGRITY;
        }
        return 0;
 }
@@ -6807,7 +6754,7 @@ flow_dv_validate(struct rte_eth_dev *dev, const struct rte_flow_attr *attr,
                .std_tbl_fix = true,
        };
        const struct rte_eth_hairpin_conf *conf;
-       const struct rte_flow_item *rule_items = items;
+       const struct rte_flow_item *integrity_items[2] = {NULL, NULL};
        const struct rte_flow_item *port_id_item = NULL;
        bool def_policy = false;
        uint16_t udp_dport = 0;
@@ -7134,16 +7081,13 @@ flow_dv_validate(struct rte_eth_dev *dev, const struct rte_flow_attr *attr,
                        last_item = MLX5_FLOW_LAYER_ECPRI;
                        break;
                case RTE_FLOW_ITEM_TYPE_INTEGRITY:
-                       if (item_flags & MLX5_FLOW_ITEM_INTEGRITY)
-                               return rte_flow_error_set
-                                       (error, ENOTSUP,
-                                        RTE_FLOW_ERROR_TYPE_ITEM,
-                                        NULL, "multiple integrity items not supported");
-                       ret = flow_dv_validate_item_integrity(dev, rule_items,
-                                                             items, error);
+                       ret = flow_dv_validate_item_integrity(dev, items,
+                                                             item_flags,
+                                                             &last_item,
+                                                             integrity_items,
+                                                             error);
                        if (ret < 0)
                                return ret;
-                       last_item = MLX5_FLOW_ITEM_INTEGRITY;
                        break;
                case RTE_FLOW_ITEM_TYPE_CONNTRACK:
                        ret = flow_dv_validate_item_aso_ct(dev, items,
@@ -7163,6 +7107,12 @@ flow_dv_validate(struct rte_eth_dev *dev, const struct rte_flow_attr *attr,
                }
                item_flags |= last_item;
        }
+       if (item_flags & MLX5_FLOW_ITEM_INTEGRITY) {
+               ret = flow_dv_validate_item_integrity_post(integrity_items,
+                                                          item_flags, error);
+               if (ret)
+                       return ret;
+       }
        for (; actions->type != RTE_FLOW_ACTION_TYPE_END; actions++) {
                int type = actions->type;
                bool shared_count = false;
@@ -9067,7 +9017,7 @@ flow_dev_geneve_tlv_option_resource_register(struct rte_eth_dev *dev,
                }
        } else {
                /* Create a GENEVE TLV object and resource. */
-               obj = mlx5_devx_cmd_create_geneve_tlv_option(sh->ctx,
+               obj = mlx5_devx_cmd_create_geneve_tlv_option(sh->cdev->ctx,
                                geneve_opt_v->option_class,
                                geneve_opt_v->option_type,
                                geneve_opt_v->option_len);
@@ -9577,6 +9527,11 @@ flow_dv_translate_item_port_id(struct rte_eth_dev *dev, void *matcher,
        struct mlx5_priv *priv;
        uint16_t mask, id;
 
+       if (pid_v && pid_v->id == MLX5_PORT_ESW_MGR) {
+               flow_dv_translate_item_source_vport(matcher, key,
+                       flow_dv_get_esw_manager_vport_id(dev), 0xffff);
+               return 0;
+       }
        mask = pid_m ? pid_m->id : 0xffff;
        id = pid_v ? pid_v->id : dev->data->port_id;
        priv = mlx5_port_to_eswitch_info(id, item == NULL);
@@ -10427,7 +10382,8 @@ flow_dv_matcher_create_cb(void *tool_ctx, void *cb_ctx)
        dv_attr.priority = ref->priority;
        if (tbl->is_egress)
                dv_attr.flags |= IBV_FLOW_ATTR_FLAGS_EGRESS;
-       ret = mlx5_flow_os_create_flow_matcher(sh->ctx, &dv_attr, tbl->tbl.obj,
+       ret = mlx5_flow_os_create_flow_matcher(sh->cdev->ctx, &dv_attr,
+                                              tbl->tbl.obj,
                                               &resource->matcher_object);
        if (ret) {
                mlx5_free(resource);
@@ -10794,22 +10750,22 @@ flow_dv_translate_item_tx_queue(struct rte_eth_dev *dev,
        void *misc_v =
                MLX5_ADDR_OF(fte_match_param, key, misc_parameters);
        struct mlx5_txq_ctrl *txq;
-       uint32_t queue;
-
+       uint32_t queue, mask;
 
        queue_m = (const void *)item->mask;
-       if (!queue_m)
-               return;
        queue_v = (const void *)item->spec;
        if (!queue_v)
                return;
        txq = mlx5_txq_get(dev, queue_v->queue);
        if (!txq)
                return;
-       queue = txq->obj->sq->id;
-       MLX5_SET(fte_match_set_misc, misc_m, source_sqn, queue_m->queue);
-       MLX5_SET(fte_match_set_misc, misc_v, source_sqn,
-                queue & queue_m->queue);
+       if (txq->type == MLX5_TXQ_TYPE_HAIRPIN)
+               queue = txq->obj->sq->id;
+       else
+               queue = txq->obj->sq_obj.sq->id;
+       mask = queue_m == NULL ? UINT32_MAX : queue_m->queue;
+       MLX5_SET(fte_match_set_misc, misc_m, source_sqn, mask);
+       MLX5_SET(fte_match_set_misc, misc_v, source_sqn, queue & mask);
        mlx5_txq_release(dev, queue_v->queue);
 }
 
@@ -10837,9 +10793,9 @@ flow_dv_hashfields_set(struct mlx5_flow *dev_flow,
        if ((rss_inner && (items & MLX5_FLOW_LAYER_INNER_L3_IPV4)) ||
            (!rss_inner && (items & MLX5_FLOW_LAYER_OUTER_L3_IPV4))) {
                if (rss_types & MLX5_IPV4_LAYER_TYPES) {
-                       if (rss_types & ETH_RSS_L3_SRC_ONLY)
+                       if (rss_types & RTE_ETH_RSS_L3_SRC_ONLY)
                                dev_flow->hash_fields |= IBV_RX_HASH_SRC_IPV4;
-                       else if (rss_types & ETH_RSS_L3_DST_ONLY)
+                       else if (rss_types & RTE_ETH_RSS_L3_DST_ONLY)
                                dev_flow->hash_fields |= IBV_RX_HASH_DST_IPV4;
                        else
                                dev_flow->hash_fields |= MLX5_IPV4_IBV_RX_HASH;
@@ -10847,9 +10803,9 @@ flow_dv_hashfields_set(struct mlx5_flow *dev_flow,
        } else if ((rss_inner && (items & MLX5_FLOW_LAYER_INNER_L3_IPV6)) ||
                   (!rss_inner && (items & MLX5_FLOW_LAYER_OUTER_L3_IPV6))) {
                if (rss_types & MLX5_IPV6_LAYER_TYPES) {
-                       if (rss_types & ETH_RSS_L3_SRC_ONLY)
+                       if (rss_types & RTE_ETH_RSS_L3_SRC_ONLY)
                                dev_flow->hash_fields |= IBV_RX_HASH_SRC_IPV6;
-                       else if (rss_types & ETH_RSS_L3_DST_ONLY)
+                       else if (rss_types & RTE_ETH_RSS_L3_DST_ONLY)
                                dev_flow->hash_fields |= IBV_RX_HASH_DST_IPV6;
                        else
                                dev_flow->hash_fields |= MLX5_IPV6_IBV_RX_HASH;
@@ -10863,11 +10819,11 @@ flow_dv_hashfields_set(struct mlx5_flow *dev_flow,
                return;
        if ((rss_inner && (items & MLX5_FLOW_LAYER_INNER_L4_UDP)) ||
            (!rss_inner && (items & MLX5_FLOW_LAYER_OUTER_L4_UDP))) {
-               if (rss_types & ETH_RSS_UDP) {
-                       if (rss_types & ETH_RSS_L4_SRC_ONLY)
+               if (rss_types & RTE_ETH_RSS_UDP) {
+                       if (rss_types & RTE_ETH_RSS_L4_SRC_ONLY)
                                dev_flow->hash_fields |=
                                                IBV_RX_HASH_SRC_PORT_UDP;
-                       else if (rss_types & ETH_RSS_L4_DST_ONLY)
+                       else if (rss_types & RTE_ETH_RSS_L4_DST_ONLY)
                                dev_flow->hash_fields |=
                                                IBV_RX_HASH_DST_PORT_UDP;
                        else
@@ -10875,11 +10831,11 @@ flow_dv_hashfields_set(struct mlx5_flow *dev_flow,
                }
        } else if ((rss_inner && (items & MLX5_FLOW_LAYER_INNER_L4_TCP)) ||
                   (!rss_inner && (items & MLX5_FLOW_LAYER_OUTER_L4_TCP))) {
-               if (rss_types & ETH_RSS_TCP) {
-                       if (rss_types & ETH_RSS_L4_SRC_ONLY)
+               if (rss_types & RTE_ETH_RSS_TCP) {
+                       if (rss_types & RTE_ETH_RSS_L4_SRC_ONLY)
                                dev_flow->hash_fields |=
                                                IBV_RX_HASH_SRC_PORT_TCP;
-                       else if (rss_types & ETH_RSS_L4_DST_ONLY)
+                       else if (rss_types & RTE_ETH_RSS_L4_DST_ONLY)
                                dev_flow->hash_fields |=
                                                IBV_RX_HASH_DST_PORT_TCP;
                        else
@@ -11864,8 +11820,8 @@ flow_dv_age_pool_create(struct rte_eth_dev *dev,
        struct mlx5_devx_obj *obj = NULL;
        uint32_t i;
 
-       obj = mlx5_devx_cmd_create_flow_hit_aso_obj(priv->sh->ctx,
-                                                   priv->sh->pdn);
+       obj = mlx5_devx_cmd_create_flow_hit_aso_obj(priv->sh->cdev->ctx,
+                                                   priv->sh->cdev->pdn);
        if (!obj) {
                rte_errno = ENODATA;
                DRV_LOG(ERR, "Failed to create flow_hit_aso_obj using DevX.");
@@ -12044,8 +12000,7 @@ flow_dv_translate_integrity_l4(const struct rte_flow_item_integrity *mask,
 static void
 flow_dv_translate_integrity_l3(const struct rte_flow_item_integrity *mask,
                               const struct rte_flow_item_integrity *value,
-                              void *headers_m, void *headers_v,
-                              bool is_ipv4)
+                              void *headers_m, void *headers_v, bool is_ipv4)
 {
        if (mask->l3_ok) {
                /* application l3_ok filter aggregates all hardware l3 filters
@@ -12076,45 +12031,66 @@ flow_dv_translate_integrity_l3(const struct rte_flow_item_integrity *mask,
 }
 
 static void
-flow_dv_translate_item_integrity(void *matcher, void *key,
-                                const struct rte_flow_item *head_item,
-                                const struct rte_flow_item *integrity_item)
+set_integrity_bits(void *headers_m, void *headers_v,
+                  const struct rte_flow_item *integrity_item, bool is_l3_ip4)
 {
+       const struct rte_flow_item_integrity *spec = integrity_item->spec;
        const struct rte_flow_item_integrity *mask = integrity_item->mask;
-       const struct rte_flow_item_integrity *value = integrity_item->spec;
-       const struct rte_flow_item *tunnel_item, *end_item, *item;
-       void *headers_m;
-       void *headers_v;
-       uint32_t l3_protocol;
 
-       if (!value)
-               return;
+       /* Integrity bits validation cleared spec pointer */
+       MLX5_ASSERT(spec != NULL);
        if (!mask)
                mask = &rte_flow_item_integrity_mask;
-       if (value->level > 1) {
+       flow_dv_translate_integrity_l3(mask, spec, headers_m, headers_v,
+                                      is_l3_ip4);
+       flow_dv_translate_integrity_l4(mask, spec, headers_m, headers_v);
+}
+
+static void
+flow_dv_translate_item_integrity_post(void *matcher, void *key,
+                                     const
+                                     struct rte_flow_item *integrity_items[2],
+                                     uint64_t pattern_flags)
+{
+       void *headers_m, *headers_v;
+       bool is_l3_ip4;
+
+       if (pattern_flags & MLX5_FLOW_ITEM_INNER_INTEGRITY) {
                headers_m = MLX5_ADDR_OF(fte_match_param, matcher,
                                         inner_headers);
                headers_v = MLX5_ADDR_OF(fte_match_param, key, inner_headers);
-       } else {
+               is_l3_ip4 = (pattern_flags & MLX5_FLOW_LAYER_INNER_L3_IPV4) !=
+                           0;
+               set_integrity_bits(headers_m, headers_v,
+                                  integrity_items[1], is_l3_ip4);
+       }
+       if (pattern_flags & MLX5_FLOW_ITEM_OUTER_INTEGRITY) {
                headers_m = MLX5_ADDR_OF(fte_match_param, matcher,
                                         outer_headers);
                headers_v = MLX5_ADDR_OF(fte_match_param, key, outer_headers);
+               is_l3_ip4 = (pattern_flags & MLX5_FLOW_LAYER_OUTER_L3_IPV4) !=
+                           0;
+               set_integrity_bits(headers_m, headers_v,
+                                  integrity_items[0], is_l3_ip4);
        }
-       tunnel_item = mlx5_flow_find_tunnel_item(head_item);
-       if (value->level > 1) {
-               /* tunnel item was verified during the item validation */
-               item = tunnel_item;
-               end_item = mlx5_find_end_item(tunnel_item);
+}
+
+static void
+flow_dv_translate_item_integrity(const struct rte_flow_item *item,
+                                const struct rte_flow_item *integrity_items[2],
+                                uint64_t *last_item)
+{
+       const struct rte_flow_item_integrity *spec = (typeof(spec))item->spec;
+
+       /* integrity bits validation cleared spec pointer */
+       MLX5_ASSERT(spec != NULL);
+       if (spec->level > 1) {
+               integrity_items[1] = item;
+               *last_item |= MLX5_FLOW_ITEM_INNER_INTEGRITY;
        } else {
-               item = head_item;
-               end_item = tunnel_item ? tunnel_item :
-                          mlx5_find_end_item(integrity_item);
+               integrity_items[0] = item;
+               *last_item |= MLX5_FLOW_ITEM_OUTER_INTEGRITY;
        }
-       l3_protocol = mask->l3_ok ?
-                     mlx5_flow_locate_proto_l3(&item, end_item) : 0;
-       flow_dv_translate_integrity_l3(mask, value, headers_m, headers_v,
-                                      l3_protocol == RTE_ETHER_TYPE_IPV4);
-       flow_dv_translate_integrity_l4(mask, value, headers_m, headers_v);
 }
 
 /**
@@ -12292,8 +12268,9 @@ flow_dv_ct_pool_create(struct rte_eth_dev *dev,
        uint32_t i;
        uint32_t log_obj_size = rte_log2_u32(MLX5_ASO_CT_ACTIONS_PER_POOL);
 
-       obj = mlx5_devx_cmd_create_conn_track_offload_obj(priv->sh->ctx,
-                                               priv->sh->pdn, log_obj_size);
+       obj = mlx5_devx_cmd_create_conn_track_offload_obj(priv->sh->cdev->ctx,
+                                                         priv->sh->cdev->pdn,
+                                                         log_obj_size);
        if (!obj) {
                rte_errno = ENODATA;
                DRV_LOG(ERR, "Failed to create conn_track_offload_obj using DevX.");
@@ -12348,7 +12325,7 @@ flow_dv_aso_ct_alloc(struct rte_eth_dev *dev, struct rte_flow_error *error)
        uint32_t ct_idx;
 
        MLX5_ASSERT(mng);
-       if (!priv->config.devx) {
+       if (!priv->sh->devx) {
                rte_errno = ENOTSUP;
                return 0;
        }
@@ -12529,7 +12506,7 @@ flow_dv_translate(struct rte_eth_dev *dev,
                        (1 << MLX5_SCALE_FLOW_GROUP_BIT),
                .std_tbl_fix = true,
        };
-       const struct rte_flow_item *head_item = items;
+       const struct rte_flow_item *integrity_items[2] = {NULL, NULL};
 
        if (!wks)
                return rte_flow_error_set(error, ENOMEM,
@@ -12785,7 +12762,7 @@ flow_dv_translate(struct rte_eth_dev *dev,
                        }
                        break;
                case RTE_FLOW_ACTION_TYPE_COUNT:
-                       if (!dev_conf->devx) {
+                       if (!priv->sh->devx) {
                                return rte_flow_error_set
                                              (error, ENOTSUP,
                                               RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
@@ -13422,9 +13399,8 @@ flow_dv_translate(struct rte_eth_dev *dev,
                        last_item = MLX5_FLOW_LAYER_ECPRI;
                        break;
                case RTE_FLOW_ITEM_TYPE_INTEGRITY:
-                       flow_dv_translate_item_integrity(match_mask,
-                                                        match_value,
-                                                        head_item, items);
+                       flow_dv_translate_item_integrity(items, integrity_items,
+                                                        &last_item);
                        break;
                case RTE_FLOW_ITEM_TYPE_CONNTRACK:
                        flow_dv_translate_item_aso_ct(dev, match_mask,
@@ -13448,6 +13424,11 @@ flow_dv_translate(struct rte_eth_dev *dev,
                                                   match_value, NULL, attr))
                        return -rte_errno;
        }
+       if (item_flags & MLX5_FLOW_ITEM_INTEGRITY) {
+               flow_dv_translate_item_integrity_post(match_mask, match_value,
+                                                     integrity_items,
+                                                     item_flags);
+       }
 #ifdef RTE_LIBRTE_MLX5_DEBUG
        MLX5_ASSERT(!flow_dv_check_valid_spec(matcher.mask.buf,
                                              dev_flow->dv.value.buf));
@@ -13531,7 +13512,8 @@ flow_dv_translate(struct rte_eth_dev *dev,
        matcher.crc = rte_raw_cksum((const void *)matcher.mask.buf,
                                    matcher.mask.size);
        matcher.priority = mlx5_get_matcher_priority(dev, attr,
-                                       matcher.priority);
+                                                    matcher.priority,
+                                                    dev_flow->external);
        /**
         * When creating meter drop flow in drop table, using original
         * 5-tuple match, the matcher priority should be lower than
@@ -14418,9 +14400,9 @@ __flow_dv_action_rss_l34_hash_adjust(struct mlx5_shared_action_rss *rss,
        case MLX5_RSS_HASH_IPV4:
                if (rss_types & MLX5_IPV4_LAYER_TYPES) {
                        *hash_field &= ~MLX5_RSS_HASH_IPV4;
-                       if (rss_types & ETH_RSS_L3_DST_ONLY)
+                       if (rss_types & RTE_ETH_RSS_L3_DST_ONLY)
                                *hash_field |= IBV_RX_HASH_DST_IPV4;
-                       else if (rss_types & ETH_RSS_L3_SRC_ONLY)
+                       else if (rss_types & RTE_ETH_RSS_L3_SRC_ONLY)
                                *hash_field |= IBV_RX_HASH_SRC_IPV4;
                        else
                                *hash_field |= MLX5_RSS_HASH_IPV4;
@@ -14429,9 +14411,9 @@ __flow_dv_action_rss_l34_hash_adjust(struct mlx5_shared_action_rss *rss,
        case MLX5_RSS_HASH_IPV6:
                if (rss_types & MLX5_IPV6_LAYER_TYPES) {
                        *hash_field &= ~MLX5_RSS_HASH_IPV6;
-                       if (rss_types & ETH_RSS_L3_DST_ONLY)
+                       if (rss_types & RTE_ETH_RSS_L3_DST_ONLY)
                                *hash_field |= IBV_RX_HASH_DST_IPV6;
-                       else if (rss_types & ETH_RSS_L3_SRC_ONLY)
+                       else if (rss_types & RTE_ETH_RSS_L3_SRC_ONLY)
                                *hash_field |= IBV_RX_HASH_SRC_IPV6;
                        else
                                *hash_field |= MLX5_RSS_HASH_IPV6;
@@ -14440,11 +14422,11 @@ __flow_dv_action_rss_l34_hash_adjust(struct mlx5_shared_action_rss *rss,
        case MLX5_RSS_HASH_IPV4_UDP:
                /* fall-through. */
        case MLX5_RSS_HASH_IPV6_UDP:
-               if (rss_types & ETH_RSS_UDP) {
+               if (rss_types & RTE_ETH_RSS_UDP) {
                        *hash_field &= ~MLX5_UDP_IBV_RX_HASH;
-                       if (rss_types & ETH_RSS_L4_DST_ONLY)
+                       if (rss_types & RTE_ETH_RSS_L4_DST_ONLY)
                                *hash_field |= IBV_RX_HASH_DST_PORT_UDP;
-                       else if (rss_types & ETH_RSS_L4_SRC_ONLY)
+                       else if (rss_types & RTE_ETH_RSS_L4_SRC_ONLY)
                                *hash_field |= IBV_RX_HASH_SRC_PORT_UDP;
                        else
                                *hash_field |= MLX5_UDP_IBV_RX_HASH;
@@ -14453,11 +14435,11 @@ __flow_dv_action_rss_l34_hash_adjust(struct mlx5_shared_action_rss *rss,
        case MLX5_RSS_HASH_IPV4_TCP:
                /* fall-through. */
        case MLX5_RSS_HASH_IPV6_TCP:
-               if (rss_types & ETH_RSS_TCP) {
+               if (rss_types & RTE_ETH_RSS_TCP) {
                        *hash_field &= ~MLX5_TCP_IBV_RX_HASH;
-                       if (rss_types & ETH_RSS_L4_DST_ONLY)
+                       if (rss_types & RTE_ETH_RSS_L4_DST_ONLY)
                                *hash_field |= IBV_RX_HASH_DST_PORT_TCP;
-                       else if (rss_types & ETH_RSS_L4_SRC_ONLY)
+                       else if (rss_types & RTE_ETH_RSS_L4_SRC_ONLY)
                                *hash_field |= IBV_RX_HASH_SRC_PORT_TCP;
                        else
                                *hash_field |= MLX5_TCP_IBV_RX_HASH;
@@ -14605,8 +14587,8 @@ __flow_dv_action_rss_create(struct rte_eth_dev *dev,
        origin = &shared_rss->origin;
        origin->func = rss->func;
        origin->level = rss->level;
-       /* RSS type 0 indicates default RSS type (ETH_RSS_IP). */
-       origin->types = !rss->types ? ETH_RSS_IP : rss->types;
+       /* RSS type 0 indicates default RSS type (RTE_ETH_RSS_IP). */
+       origin->types = !rss->types ? RTE_ETH_RSS_IP : rss->types;
        /* NULL RSS key indicates default RSS key. */
        rss_key = !rss->key ? rss_hash_default_key : rss->key;
        memcpy(shared_rss->key, rss_key, MLX5_RSS_HASH_KEY_LEN);
@@ -15622,14 +15604,14 @@ flow_dv_create_mtr_policy_acts(struct rte_eth_dev *dev,
  * @return
  *   0 on success, a negative errno value otherwise and rte_errno is set.
  */
-static int
+int
 flow_dv_query_count(struct rte_eth_dev *dev, uint32_t cnt_idx, void *data,
                    struct rte_flow_error *error)
 {
        struct mlx5_priv *priv = dev->data->dev_private;
        struct rte_flow_query_count *qc = data;
 
-       if (!priv->config.devx)
+       if (!priv->sh->devx)
                return rte_flow_error_set(error, ENOTSUP,
                                          RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
                                          NULL,
@@ -15660,6 +15642,48 @@ flow_dv_query_count(struct rte_eth_dev *dev, uint32_t cnt_idx, void *data,
                                  "counters are not available");
 }
 
+
+/**
+ * Query counter's action pointer for a DV flow rule via DevX.
+ *
+ * @param[in] dev
+ *   Pointer to Ethernet device.
+ * @param[in] cnt_idx
+ *   Index to the flow counter.
+ * @param[out] action_ptr
+ *   Action pointer for counter.
+ * @param[out] error
+ *   Perform verbose error reporting if not NULL.
+ *
+ * @return
+ *   0 on success, a negative errno value otherwise and rte_errno is set.
+ */
+int
+flow_dv_query_count_ptr(struct rte_eth_dev *dev, uint32_t cnt_idx,
+       void **action_ptr, struct rte_flow_error *error)
+{
+       struct mlx5_priv *priv = dev->data->dev_private;
+
+       if (!priv->sh->devx || !action_ptr)
+               return rte_flow_error_set(error, ENOTSUP,
+                                         RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
+                                         NULL,
+                                         "counters are not supported");
+
+       if (cnt_idx) {
+               struct mlx5_flow_counter *cnt = NULL;
+               cnt = flow_dv_counter_get_by_idx(dev, cnt_idx, NULL);
+               if (cnt) {
+                       *action_ptr = cnt->action;
+                       return 0;
+               }
+       }
+       return rte_flow_error_set(error, EINVAL,
+                                 RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
+                                 NULL,
+                                 "counters are not available");
+}
+
 static int
 flow_dv_action_query(struct rte_eth_dev *dev,
                     const struct rte_flow_action_handle *handle, void *data,
@@ -17099,8 +17123,8 @@ mlx5_flow_discover_dr_action_support(struct rte_eth_dev *dev)
                goto err;
        dv_attr.match_criteria_enable = flow_dv_matcher_enable(mask.buf);
        __flow_dv_adjust_buf_size(&mask.size, dv_attr.match_criteria_enable);
-       ret = mlx5_flow_os_create_flow_matcher(sh->ctx, &dv_attr, tbl->obj,
-                                              &matcher);
+       ret = mlx5_flow_os_create_flow_matcher(sh->cdev->ctx, &dv_attr,
+                                              tbl->obj, &matcher);
        if (ret)
                goto err;
        __flow_dv_adjust_buf_size(&value.size, dv_attr.match_criteria_enable);
@@ -17168,7 +17192,7 @@ mlx5_flow_dv_discover_counter_offset_support(struct rte_eth_dev *dev)
                                        0, 0, 0, NULL);
        if (!tbl)
                goto err;
-       dcs = mlx5_devx_cmd_flow_counter_alloc(priv->sh->ctx, 0x4);
+       dcs = mlx5_devx_cmd_flow_counter_alloc(priv->sh->cdev->ctx, 0x4);
        if (!dcs)
                goto err;
        ret = mlx5_flow_os_create_flow_action_count(dcs->obj, UINT16_MAX,
@@ -17177,8 +17201,8 @@ mlx5_flow_dv_discover_counter_offset_support(struct rte_eth_dev *dev)
                goto err;
        dv_attr.match_criteria_enable = flow_dv_matcher_enable(mask.buf);
        __flow_dv_adjust_buf_size(&mask.size, dv_attr.match_criteria_enable);
-       ret = mlx5_flow_os_create_flow_matcher(sh->ctx, &dv_attr, tbl->obj,
-                                              &matcher);
+       ret = mlx5_flow_os_create_flow_matcher(sh->cdev->ctx, &dv_attr,
+                                              tbl->obj, &matcher);
        if (ret)
                goto err;
        __flow_dv_adjust_buf_size(&value.size, dv_attr.match_criteria_enable);
@@ -17242,7 +17266,7 @@ flow_dv_counter_query(struct rte_eth_dev *dev, uint32_t counter, bool clear,
        uint64_t inn_pkts, inn_bytes;
        int ret;
 
-       if (!priv->config.devx)
+       if (!priv->sh->devx)
                return -1;
 
        ret = _flow_dv_query_count(dev, counter, &inn_pkts, &inn_bytes);
@@ -17756,18 +17780,23 @@ flow_dv_validate_mtr_policy_acts(struct rte_eth_dev *dev,
                                        "Doesn't support optional action");
                        }
                }
-               if (action_flags[i] & MLX5_FLOW_ACTION_PORT_ID)
+               if (action_flags[i] & MLX5_FLOW_ACTION_PORT_ID) {
                        domain_color[i] = MLX5_MTR_DOMAIN_TRANSFER_BIT;
-               else if ((action_flags[i] &
+               else if ((action_flags[i] &
                          (MLX5_FLOW_ACTION_RSS | MLX5_FLOW_ACTION_QUEUE)) ||
-                        (action_flags[i] & MLX5_FLOW_ACTION_MARK))
+                         (action_flags[i] & MLX5_FLOW_ACTION_MARK)) {
                        /*
                         * Only support MLX5_XMETA_MODE_LEGACY
                         * so MARK action is only in ingress domain.
                         */
                        domain_color[i] = MLX5_MTR_DOMAIN_INGRESS_BIT;
-               else
+               } else {
                        domain_color[i] = def_domain;
+                       if (action_flags[i] &&
+                           !(action_flags[i] & MLX5_FLOW_FATE_ESWITCH_ACTIONS))
+                               domain_color[i] &=
+                               ~MLX5_MTR_DOMAIN_TRANSFER_BIT;
+               }
                if (action_flags[i] &
                    MLX5_FLOW_ACTION_METER_WITH_TERMINATED_POLICY)
                        domain_color[i] &= hierarchy_domain;