get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/patches/91589/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 91589,
    "url": "https://patches.dpdk.org/api/patches/91589/?format=api",
    "web_url": "https://patches.dpdk.org/project/dpdk/patch/20210415151135.2098674-13-lizh@nvidia.com/",
    "project": {
        "id": 1,
        "url": "https://patches.dpdk.org/api/projects/1/?format=api",
        "name": "DPDK",
        "link_name": "dpdk",
        "list_id": "dev.dpdk.org",
        "list_email": "dev@dpdk.org",
        "web_url": "http://core.dpdk.org",
        "scm_url": "git://dpdk.org/dpdk",
        "webscm_url": "http://git.dpdk.org/dpdk",
        "list_archive_url": "https://inbox.dpdk.org/dev",
        "list_archive_url_format": "https://inbox.dpdk.org/dev/{}",
        "commit_url_format": ""
    },
    "msgid": "<20210415151135.2098674-13-lizh@nvidia.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20210415151135.2098674-13-lizh@nvidia.com",
    "date": "2021-04-15T15:11:32",
    "name": "[v5,12/14] net/mlx5: add support of ASO meter action",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "653f92bd81f513283215b6cfd361b9d515b5de04",
    "submitter": {
        "id": 1967,
        "url": "https://patches.dpdk.org/api/people/1967/?format=api",
        "name": "Li Zhang",
        "email": "lizh@nvidia.com"
    },
    "delegate": {
        "id": 3268,
        "url": "https://patches.dpdk.org/api/users/3268/?format=api",
        "username": "rasland",
        "first_name": "Raslan",
        "last_name": "Darawsheh",
        "email": "rasland@nvidia.com"
    },
    "mbox": "https://patches.dpdk.org/project/dpdk/patch/20210415151135.2098674-13-lizh@nvidia.com/mbox/",
    "series": [
        {
            "id": 16417,
            "url": "https://patches.dpdk.org/api/series/16417/?format=api",
            "web_url": "https://patches.dpdk.org/project/dpdk/list/?series=16417",
            "date": "2021-04-15T15:11:20",
            "name": "Add ASO meter support in MLX5 PMD",
            "version": 5,
            "mbox": "https://patches.dpdk.org/series/16417/mbox/"
        }
    ],
    "comments": "https://patches.dpdk.org/api/patches/91589/comments/",
    "check": "success",
    "checks": "https://patches.dpdk.org/api/patches/91589/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<dev-bounces@dpdk.org>",
        "X-Original-To": "patchwork@inbox.dpdk.org",
        "Delivered-To": "patchwork@inbox.dpdk.org",
        "Received": [
            "from mails.dpdk.org (mails.dpdk.org [217.70.189.124])\n\tby inbox.dpdk.org (Postfix) with ESMTP id 92E61A0C3F;\n\tThu, 15 Apr 2021 17:13:06 +0200 (CEST)",
            "from [217.70.189.124] (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id A3A99162347;\n\tThu, 15 Apr 2021 17:12:05 +0200 (CEST)",
            "from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129])\n by mails.dpdk.org (Postfix) with ESMTP id 736E4162306\n for <dev@dpdk.org>; Thu, 15 Apr 2021 17:11:51 +0200 (CEST)",
            "from Internal Mail-Server by MTLPINE1 (envelope-from\n lizh@nvidia.com)\n with SMTP; 15 Apr 2021 18:11:48 +0300",
            "from nvidia.com (c-235-17-1-009.mtl.labs.mlnx [10.235.17.9])\n by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id 13FFBjPR032677;\n Thu, 15 Apr 2021 18:11:48 +0300"
        ],
        "From": "Li Zhang <lizh@nvidia.com>",
        "To": "dekelp@nvidia.com, orika@nvidia.com, viacheslavo@nvidia.com,\n matan@nvidia.com, shahafs@nvidia.com",
        "Cc": "dev@dpdk.org, thomas@monjalon.net, rasland@nvidia.com, roniba@nvidia.com,\n Shun Hao <shunh@nvidia.com>",
        "Date": "Thu, 15 Apr 2021 18:11:32 +0300",
        "Message-Id": "<20210415151135.2098674-13-lizh@nvidia.com>",
        "X-Mailer": "git-send-email 2.21.0",
        "In-Reply-To": "<20210415151135.2098674-1-lizh@nvidia.com>",
        "References": "<20210331073632.1443011-1-lizh@nvidia.com>\n <20210415151135.2098674-1-lizh@nvidia.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[dpdk-dev] [PATCH v5 12/14] net/mlx5: add support of ASO meter\n action",
        "X-BeenThere": "dev@dpdk.org",
        "X-Mailman-Version": "2.1.29",
        "Precedence": "list",
        "List-Id": "DPDK patches and discussions <dev.dpdk.org>",
        "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n <mailto:dev-request@dpdk.org?subject=unsubscribe>",
        "List-Archive": "<http://mails.dpdk.org/archives/dev/>",
        "List-Post": "<mailto:dev@dpdk.org>",
        "List-Help": "<mailto:dev-request@dpdk.org?subject=help>",
        "List-Subscribe": "<https://mails.dpdk.org/listinfo/dev>,\n <mailto:dev-request@dpdk.org?subject=subscribe>",
        "Errors-To": "dev-bounces@dpdk.org",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>"
    },
    "content": "When ASO action is available, use it as the meter action\n\nSigned-off-by: Shun Hao <shunh@nvidia.com>\nSigned-off-by: Li Zhang <lizh@nvidia.com>\nAcked-by: Matan Azrad <matan@nvidia.com>\n---\n drivers/net/mlx5/linux/mlx5_os.c   |  4 +-\n drivers/net/mlx5/mlx5.c            | 12 ++++\n drivers/net/mlx5/mlx5.h            |  7 ++-\n drivers/net/mlx5/mlx5_flow.c       | 74 +++++++++++++++++------\n drivers/net/mlx5/mlx5_flow_dv.c    | 29 +++++++--\n drivers/net/mlx5/mlx5_flow_meter.c | 97 +++++++++++++++++++-----------\n 6 files changed, 163 insertions(+), 60 deletions(-)",
    "diff": "diff --git a/drivers/net/mlx5/linux/mlx5_os.c b/drivers/net/mlx5/linux/mlx5_os.c\nindex 336cdbe3a8..41622c1bf7 100644\n--- a/drivers/net/mlx5/linux/mlx5_os.c\n+++ b/drivers/net/mlx5/linux/mlx5_os.c\n@@ -1255,7 +1255,9 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev,\n \t\t\t\t\"required for coalescing is %d bytes\",\n \t\t\t\tconfig->hca_attr.lro_min_mss_size);\n \t\t}\n-#if defined(HAVE_MLX5DV_DR) && defined(HAVE_MLX5_DR_CREATE_ACTION_FLOW_METER)\n+#if defined(HAVE_MLX5DV_DR) && \\\n+\t(defined(HAVE_MLX5_DR_CREATE_ACTION_FLOW_METER) || \\\n+\t defined(HAVE_MLX5_DR_CREATE_ACTION_ASO))\n \t\tif (config->hca_attr.qos.sup &&\n \t\t    config->hca_attr.qos.flow_meter_old &&\n \t\t    config->dv_flow_en) {\ndiff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c\nindex 0c6d4e34c9..b24ce8f745 100644\n--- a/drivers/net/mlx5/mlx5.c\n+++ b/drivers/net/mlx5/mlx5.c\n@@ -609,11 +609,23 @@ mlx5_aso_flow_mtrs_mng_close(struct mlx5_dev_ctx_shared *sh)\n \tstruct mlx5_aso_mtr_pool *mtr_pool;\n \tstruct mlx5_aso_mtr_pools_mng *mtrmng = sh->mtrmng;\n \tuint32_t idx;\n+#ifdef HAVE_MLX5_DR_CREATE_ACTION_ASO\n+\tstruct mlx5_aso_mtr *aso_mtr;\n+\tint i;\n+#endif /* HAVE_MLX5_DR_CREATE_ACTION_ASO */\n \n \tmlx5_aso_queue_uninit(sh, ASO_OPC_MOD_POLICER);\n \tidx = mtrmng->n_valid;\n \twhile (idx--) {\n \t\tmtr_pool = mtrmng->pools[idx];\n+#ifdef HAVE_MLX5_DR_CREATE_ACTION_ASO\n+\t\tfor (i = 0; i < MLX5_ASO_MTRS_PER_POOL; i++) {\n+\t\t\taso_mtr = &mtr_pool->mtrs[i];\n+\t\t\tif (aso_mtr->fm.meter_action)\n+\t\t\t\tclaim_zero(mlx5_glue->destroy_flow_action\n+\t\t\t\t\t\t(aso_mtr->fm.meter_action));\n+\t\t}\n+#endif /* HAVE_MLX5_DR_CREATE_ACTION_ASO */\n \t\tclaim_zero(mlx5_devx_cmd_destroy\n \t\t\t\t\t\t(mtr_pool->devx_obj));\n \t\tmtrmng->n_valid--;\ndiff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h\nindex a4b3597365..d2ae69f209 100644\n--- a/drivers/net/mlx5/mlx5.h\n+++ b/drivers/net/mlx5/mlx5.h\n@@ -625,8 +625,6 @@ struct mlx5_meter_domains_infos {\n \t/**< Counters for green rule. */\n \tvoid *drop_count;\n \t/**< Counters for green rule. */\n-\tvoid *meter_action;\n-\t/**< Flow meter action. */\n };\n \n /* Meter parameter structure. */\n@@ -689,6 +687,8 @@ struct mlx5_flow_meter_info {\n \t/**< Use count. */\n \tstruct mlx5_indexed_pool *flow_ipool;\n \t/**< Index pool for flow id. */\n+\tvoid *meter_action;\n+\t/**< Flow meter action. */\n };\n \n /* RFC2697 parameter structure. */\n@@ -1478,7 +1478,8 @@ int mlx5_flow_meter_attach(struct mlx5_priv *priv,\n \t\t\t   struct mlx5_flow_meter_info *fm,\n \t\t\t   const struct rte_flow_attr *attr,\n \t\t\t   struct rte_flow_error *error);\n-void mlx5_flow_meter_detach(struct mlx5_flow_meter_info *fm);\n+void mlx5_flow_meter_detach(struct mlx5_priv *priv,\n+\t\t\t    struct mlx5_flow_meter_info *fm);\n \n /* mlx5_os.c */\n struct rte_pci_driver;\ndiff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c\nindex 7f34f47e9f..6ff58468f9 100644\n--- a/drivers/net/mlx5/mlx5_flow.c\n+++ b/drivers/net/mlx5/mlx5_flow.c\n@@ -4364,6 +4364,8 @@ flow_create_split_inner(struct rte_eth_dev *dev,\n  *   Parent flow structure pointer.\n  * @param[in] fm\n  *   Pointer to flow meter structure.\n+ * @param[in] attr\n+ *   Flow rule attributes.\n  * @param[in] items\n  *   Pattern specification (list terminated by the END pattern item).\n  * @param[out] sfx_items\n@@ -4384,6 +4386,7 @@ static uint32_t\n flow_meter_split_prep(struct rte_eth_dev *dev,\n \t\t      struct rte_flow *flow,\n \t\t      struct mlx5_flow_meter_info *fm,\n+\t\t      const struct rte_flow_attr *attr,\n \t\t      const struct rte_flow_item items[],\n \t\t      struct rte_flow_item sfx_items[],\n \t\t      const struct rte_flow_action actions[],\n@@ -4401,6 +4404,12 @@ flow_meter_split_prep(struct rte_eth_dev *dev,\n \tstruct mlx5_rte_flow_item_tag *tag_item_mask;\n \tuint32_t tag_id = 0;\n \tbool copy_vlan = false;\n+\tstruct rte_flow_action *hw_mtr_action;\n+\tstruct rte_flow_action_jump *jump_data;\n+\tstruct rte_flow_action *action_pre_head = NULL;\n+\tbool mtr_first = priv->sh->meter_aso_en &&\n+\t\t\t(attr->egress ||\n+\t\t\t(attr->transfer && priv->representor_id != UINT16_MAX));\n \tuint8_t mtr_id_offset = priv->mtr_reg_share ? MLX5_MTR_COLOR_BITS : 0;\n \tuint8_t mtr_reg_bits = priv->mtr_reg_share ?\n \t\t\t\tMLX5_MTR_IDLE_BITS_IN_COLOR_REG : MLX5_REG_BITS;\n@@ -4409,29 +4418,39 @@ flow_meter_split_prep(struct rte_eth_dev *dev,\n \tuint8_t flow_id_bits = 0;\n \tint shift;\n \n+\t/* For ASO meter, meter must be before tag in TX direction. */\n+\tif (mtr_first) {\n+\t\taction_pre_head = actions_pre++;\n+\t\t/* Leave space for tag action. */\n+\t\ttag_action = actions_pre++;\n+\t}\n \t/* Prepare the actions for prefix and suffix flow. */\n \tfor (; actions->type != RTE_FLOW_ACTION_TYPE_END; actions++) {\n-\t\tstruct rte_flow_action **action_cur = NULL;\n+\t\tstruct rte_flow_action *action_cur = NULL;\n \n \t\tswitch (actions->type) {\n \t\tcase RTE_FLOW_ACTION_TYPE_METER:\n-\t\t\t/* Add the extra tag action first. */\n-\t\t\ttag_action = actions_pre++;\n-\t\t\taction_cur = &actions_pre;\n+\t\t\tif (mtr_first) {\n+\t\t\t\taction_cur = action_pre_head;\n+\t\t\t} else {\n+\t\t\t\t/* Leave space for tag action. */\n+\t\t\t\ttag_action = actions_pre++;\n+\t\t\t\taction_cur = actions_pre++;\n+\t\t\t}\n \t\t\tbreak;\n \t\tcase RTE_FLOW_ACTION_TYPE_VXLAN_DECAP:\n \t\tcase RTE_FLOW_ACTION_TYPE_NVGRE_DECAP:\n-\t\t\taction_cur = &actions_pre;\n+\t\t\taction_cur = actions_pre++;\n \t\t\tbreak;\n \t\tcase RTE_FLOW_ACTION_TYPE_RAW_ENCAP:\n \t\t\traw_encap = actions->conf;\n \t\t\tif (raw_encap->size < MLX5_ENCAPSULATION_DECISION_SIZE)\n-\t\t\t\taction_cur = &actions_pre;\n+\t\t\t\taction_cur = actions_pre++;\n \t\t\tbreak;\n \t\tcase RTE_FLOW_ACTION_TYPE_RAW_DECAP:\n \t\t\traw_decap = actions->conf;\n \t\t\tif (raw_decap->size > MLX5_ENCAPSULATION_DECISION_SIZE)\n-\t\t\t\taction_cur = &actions_pre;\n+\t\t\t\taction_cur = actions_pre++;\n \t\t\tbreak;\n \t\tcase RTE_FLOW_ACTION_TYPE_OF_PUSH_VLAN:\n \t\tcase RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_VID:\n@@ -4441,14 +4460,32 @@ flow_meter_split_prep(struct rte_eth_dev *dev,\n \t\t\tbreak;\n \t\t}\n \t\tif (!action_cur)\n-\t\t\taction_cur = &actions_sfx;\n-\t\tmemcpy(*action_cur, actions, sizeof(struct rte_flow_action));\n-\t\t(*action_cur)++;\n+\t\t\taction_cur = actions_sfx++;\n+\t\tmemcpy(action_cur, actions, sizeof(struct rte_flow_action));\n \t}\n \t/* Add end action to the actions. */\n \tactions_sfx->type = RTE_FLOW_ACTION_TYPE_END;\n-\tactions_pre->type = RTE_FLOW_ACTION_TYPE_END;\n-\tactions_pre++;\n+\tif (priv->sh->meter_aso_en) {\n+\t\t/**\n+\t\t * For ASO meter, need to add an extra jump action explicitly,\n+\t\t * to jump from meter to policer table.\n+\t\t */\n+\t\thw_mtr_action = actions_pre;\n+\t\thw_mtr_action->type = RTE_FLOW_ACTION_TYPE_JUMP;\n+\t\tactions_pre++;\n+\t\tactions_pre->type = RTE_FLOW_ACTION_TYPE_END;\n+\t\tactions_pre++;\n+\t\tjump_data = (struct rte_flow_action_jump *)actions_pre;\n+\t\tjump_data->group = attr->transfer ?\n+\t\t\t\t(MLX5_FLOW_TABLE_LEVEL_METER - 1) :\n+\t\t\t\t MLX5_FLOW_TABLE_LEVEL_METER;\n+\t\thw_mtr_action->conf = jump_data;\n+\t\tactions_pre = (struct rte_flow_action *)(jump_data + 1);\n+\t} else {\n+\t\tactions_pre->type = RTE_FLOW_ACTION_TYPE_END;\n+\t\tactions_pre++;\n+\t}\n+\t/* Generate meter flow_id only if support multiple flows per meter. */\n \tmlx5_ipool_malloc(fm->flow_ipool, &tag_id);\n \tif (!tag_id)\n \t\treturn rte_flow_error_set(error, ENOMEM,\n@@ -5265,10 +5302,11 @@ flow_create_split_meter(struct rte_eth_dev *dev,\n \t\t\tflow->meter = mtr_idx;\n \t\t}\n \t\twks->fm = fm;\n-\t\t/* The prefix actions: meter, decap, encap, tag, end. */\n-\t\tact_size = sizeof(struct rte_flow_action) * (actions_n + 5) +\n-\t\t\t   sizeof(struct mlx5_rte_flow_action_set_tag);\n-\t\t/* The suffix items: tag, vlan, port id, end. */\n+\t\t/* Prefix actions: meter, decap, encap, tag, jump, end. */\n+\t\tact_size = sizeof(struct rte_flow_action) * (actions_n + 6) +\n+\t\t\t   sizeof(struct mlx5_rte_flow_action_set_tag) +\n+\t\t\t   sizeof(struct rte_flow_action_jump);\n+\t\t/* Suffix items: tag, vlan, port id, end. */\n #define METER_SUFFIX_ITEM 4\n \t\titem_size = sizeof(struct rte_flow_item) * METER_SUFFIX_ITEM +\n \t\t\t    sizeof(struct mlx5_rte_flow_item_tag) * 2;\n@@ -5282,8 +5320,8 @@ flow_create_split_meter(struct rte_eth_dev *dev,\n \t\tsfx_items = (struct rte_flow_item *)((char *)sfx_actions +\n \t\t\t     act_size);\n \t\tpre_actions = sfx_actions + actions_n;\n-\t\tmtr_tag_id = flow_meter_split_prep(dev, flow, fm, items,\n-\t\t\t\t\t\t   sfx_items, actions,\n+\t\tmtr_tag_id = flow_meter_split_prep(dev, flow, fm, &sfx_attr,\n+\t\t\t\t\t\t   items, sfx_items, actions,\n \t\t\t\t\t\t   sfx_actions, pre_actions,\n \t\t\t\t\t\t   error);\n \t\tif (!mtr_tag_id) {\ndiff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c\nindex fbec818c64..2793e9dfda 100644\n--- a/drivers/net/mlx5/mlx5_flow_dv.c\n+++ b/drivers/net/mlx5/mlx5_flow_dv.c\n@@ -4891,9 +4891,11 @@ mlx5_flow_validate_action_meter(struct rte_eth_dev *dev,\n \t\treturn rte_flow_error_set(error, EINVAL,\n \t\t\t\t\t  RTE_FLOW_ERROR_TYPE_ACTION, NULL,\n \t\t\t\t\t  \"Meter not found\");\n-\tif (fm->ref_cnt && (!(fm->transfer == attr->transfer ||\n+\t/* aso meter can always be shared by different domains */\n+\tif (fm->ref_cnt && !priv->sh->meter_aso_en &&\n+\t    !(fm->transfer == attr->transfer ||\n \t      (!fm->ingress && !attr->ingress && attr->egress) ||\n-\t      (!fm->egress && !attr->egress && attr->ingress))))\n+\t      (!fm->egress && !attr->egress && attr->ingress)))\n \t\treturn rte_flow_error_set(error, EINVAL,\n \t\t\t\t\t  RTE_FLOW_ERROR_TYPE_ACTION, NULL,\n \t\t\t\t\t  \"Flow attributes are either invalid \"\n@@ -6096,6 +6098,25 @@ flow_dv_mtr_alloc(struct rte_eth_dev *dev)\n \t\t\t\t\tstruct mlx5_aso_mtr_pool,\n \t\t\t\t\tmtrs[mtr_free->offset]);\n \tmtr_idx = MLX5_MAKE_MTR_IDX(pool->index, mtr_free->offset);\n+\tif (!mtr_free->fm.meter_action) {\n+#ifdef HAVE_MLX5_DR_CREATE_ACTION_ASO\n+\t\tstruct rte_flow_error error;\n+\t\tuint8_t reg_id;\n+\n+\t\treg_id = mlx5_flow_get_reg_id(dev, MLX5_MTR_COLOR, 0, &error);\n+\t\tmtr_free->fm.meter_action =\n+\t\t\tmlx5_glue->dv_create_flow_action_aso\n+\t\t\t\t\t\t(priv->sh->rx_domain,\n+\t\t\t\t\t\t pool->devx_obj->obj,\n+\t\t\t\t\t\t mtr_free->offset,\n+\t\t\t\t\t\t (1 << MLX5_FLOW_COLOR_GREEN),\n+\t\t\t\t\t\t reg_id - REG_C_0);\n+#endif /* HAVE_MLX5_DR_CREATE_ACTION_ASO */\n+\t\tif (!mtr_free->fm.meter_action) {\n+\t\t\tflow_dv_aso_mtr_release_to_pool(dev, mtr_idx);\n+\t\t\treturn 0;\n+\t\t}\n+\t}\n \treturn mtr_idx;\n }\n \n@@ -11580,7 +11601,7 @@ flow_dv_translate(struct rte_eth_dev *dev,\n \t\t\t\t\tNULL, \"Failed to get meter in flow.\");\n \t\t\t/* Set the meter action. */\n \t\t\tdev_flow->dv.actions[actions_n++] =\n-\t\t\t\twks->fm->mfts->meter_action;\n+\t\t\t\twks->fm->meter_action;\n \t\t\taction_flags |= MLX5_FLOW_ACTION_METER;\n \t\t\tbreak;\n \t\tcase RTE_FLOW_ACTION_TYPE_SET_IPV4_DSCP:\n@@ -12742,7 +12763,7 @@ flow_dv_destroy(struct rte_eth_dev *dev, struct rte_flow *flow)\n \tif (flow->meter) {\n \t\tfm = flow_dv_meter_find_by_idx(priv, flow->meter);\n \t\tif (fm)\n-\t\t\tmlx5_flow_meter_detach(fm);\n+\t\t\tmlx5_flow_meter_detach(priv, fm);\n \t\tflow->meter = 0;\n \t}\n \tif (flow->age)\ndiff --git a/drivers/net/mlx5/mlx5_flow_meter.c b/drivers/net/mlx5/mlx5_flow_meter.c\nindex fcefc135b4..714b382d55 100644\n--- a/drivers/net/mlx5/mlx5_flow_meter.c\n+++ b/drivers/net/mlx5/mlx5_flow_meter.c\n@@ -602,9 +602,9 @@ mlx5_flow_meter_action_modify(struct mlx5_priv *priv,\n \t\t\t\tebs_mantissa, val);\n \t\t}\n \t\t/* Apply modifications to meter only if it was created. */\n-\t\tif (fm->mfts->meter_action) {\n+\t\tif (fm->meter_action) {\n \t\t\tret = mlx5_glue->dv_modify_flow_action_meter\n-\t\t\t\t\t(fm->mfts->meter_action, &mod_attr,\n+\t\t\t\t\t(fm->meter_action, &mod_attr,\n \t\t\t\t\trte_cpu_to_be_64(modify_bits));\n \t\t\tif (ret)\n \t\t\t\treturn ret;\n@@ -620,6 +620,7 @@ mlx5_flow_meter_action_modify(struct mlx5_priv *priv,\n \t(void)srtcm;\n \t(void)modify_bits;\n \t(void)active_state;\n+\t(void)is_enable;\n \treturn -ENOTSUP;\n #endif\n }\n@@ -1405,63 +1406,91 @@ mlx5_flow_meter_attach(struct mlx5_priv *priv,\n {\n \tint ret = 0;\n \n-\trte_spinlock_lock(&fm->sl);\n-\tif (fm->mfts->meter_action) {\n-\t\tif (fm->shared &&\n-\t\t    attr->transfer == fm->transfer &&\n-\t\t    attr->ingress == fm->ingress &&\n-\t\t    attr->egress == fm->egress)\n+\tif (priv->sh->meter_aso_en) {\n+\t\tstruct mlx5_aso_mtr *aso_mtr;\n+\n+\t\taso_mtr = container_of(fm, struct mlx5_aso_mtr, fm);\n+\t\tif (mlx5_aso_mtr_wait(priv->sh, aso_mtr)) {\n+\t\t\treturn rte_flow_error_set(error, ENOENT,\n+\t\t\t\t\tRTE_FLOW_ERROR_TYPE_UNSPECIFIED,\n+\t\t\t\t\tNULL,\n+\t\t\t\t\t\"Timeout in meter configuration\");\n+\t\t}\n+\t\trte_spinlock_lock(&fm->sl);\n+\t\tif (fm->shared || !fm->ref_cnt) {\n \t\t\tfm->ref_cnt++;\n-\t\telse\n+\t\t} else {\n+\t\t\trte_flow_error_set(error, EINVAL,\n+\t\t\t\t   RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,\n+\t\t\t\t   \"Meter cannot be shared\");\n \t\t\tret = -1;\n+\t\t}\n+\t\trte_spinlock_unlock(&fm->sl);\n \t} else {\n-\t\tfm->ingress = attr->ingress;\n-\t\tfm->egress = attr->egress;\n-\t\tfm->transfer = attr->transfer;\n-\t\t fm->ref_cnt = 1;\n-\t\t/* This also creates the meter object. */\n-\t\tfm->mfts->meter_action = mlx5_flow_meter_action_create(priv,\n-\t\t\t\t\t\t\t\t       fm);\n-\t\tif (!fm->mfts->meter_action) {\n-\t\t\tfm->ref_cnt = 0;\n-\t\t\tfm->ingress = 0;\n-\t\t\tfm->egress = 0;\n-\t\t\tfm->transfer = 0;\n-\t\t\tret = -1;\n-\t\t\tDRV_LOG(ERR, \"Meter action create failed.\");\n+\t\trte_spinlock_lock(&fm->sl);\n+\t\tif (fm->meter_action) {\n+\t\t\tif (fm->shared &&\n+\t\t\t    attr->transfer == fm->transfer &&\n+\t\t\t    attr->ingress == fm->ingress &&\n+\t\t\t    attr->egress == fm->egress) {\n+\t\t\t\tfm->ref_cnt++;\n+\t\t\t} else {\n+\t\t\t\trte_flow_error_set(error, EINVAL,\n+\t\t\t\t\tRTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,\n+\t\t\t\t\tfm->shared ?\n+\t\t\t\t\t\"Meter attr not match.\" :\n+\t\t\t\t\t\"Meter cannot be shared.\");\n+\t\t\t\tret = -1;\n+\t\t\t}\n+\t\t} else {\n+\t\t\tfm->ingress = attr->ingress;\n+\t\t\tfm->egress = attr->egress;\n+\t\t\tfm->transfer = attr->transfer;\n+\t\t\tfm->ref_cnt = 1;\n+\t\t\t/* This also creates the meter object. */\n+\t\t\tfm->meter_action = mlx5_flow_meter_action_create(priv,\n+\t\t\t\t\t\t\t\t\t fm);\n+\t\t\tif (!fm->meter_action) {\n+\t\t\t\tfm->ref_cnt = 0;\n+\t\t\t\tfm->ingress = 0;\n+\t\t\t\tfm->egress = 0;\n+\t\t\t\tfm->transfer = 0;\n+\t\t\t\trte_flow_error_set(error, EINVAL,\n+\t\t\t\t\tRTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,\n+\t\t\t\t\t\"Meter action create failed.\");\n+\t\t\t\tret = -1;\n+\t\t\t}\n \t\t}\n+\t\trte_spinlock_unlock(&fm->sl);\n \t}\n-\trte_spinlock_unlock(&fm->sl);\n-\tif (ret)\n-\t\trte_flow_error_set(error, EINVAL,\n-\t\t\t\t   RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,\n-\t\t\t\t   fm->mfts->meter_action ?\n-\t\t\t\t   \"Meter attr not match\" :\n-\t\t\t\t   \"Meter action create failed\");\n \treturn ret ? -rte_errno : 0;\n }\n \n /**\n  * Detach meter from flow.\n  *\n+ * @param [in] priv\n+ *  Pointer to mlx5 private data.\n  * @param [in] fm\n  *  Pointer to flow meter.\n  */\n void\n-mlx5_flow_meter_detach(struct mlx5_flow_meter_info *fm)\n+mlx5_flow_meter_detach(struct mlx5_priv *priv,\n+\t\t       struct mlx5_flow_meter_info *fm)\n {\n #ifdef HAVE_MLX5_DR_CREATE_ACTION_FLOW_METER\n \trte_spinlock_lock(&fm->sl);\n \tMLX5_ASSERT(fm->ref_cnt);\n-\tif (--fm->ref_cnt == 0) {\n-\t\tmlx5_glue->destroy_flow_action(fm->mfts->meter_action);\n-\t\tfm->mfts->meter_action = NULL;\n+\tif (--fm->ref_cnt == 0 && !priv->sh->meter_aso_en) {\n+\t\tmlx5_glue->destroy_flow_action(fm->meter_action);\n+\t\tfm->meter_action = NULL;\n \t\tfm->ingress = 0;\n \t\tfm->egress = 0;\n \t\tfm->transfer = 0;\n \t}\n \trte_spinlock_unlock(&fm->sl);\n #else\n+\t(void)priv;\n \t(void)fm;\n #endif\n }\n",
    "prefixes": [
        "v5",
        "12/14"
    ]
}