Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/90496/?format=api
https://patches.dpdk.org/api/patches/90496/?format=api", "web_url": "https://patches.dpdk.org/project/dpdk/patch/20210402151627.1531623-12-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": "<20210402151627.1531623-12-lizh@nvidia.com>", "list_archive_url": "https://inbox.dpdk.org/dev/20210402151627.1531623-12-lizh@nvidia.com", "date": "2021-04-02T15:16:25", "name": "[v2,11/13] net/mlx5: add support of ASO meter action", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": true, "hash": "1e52d266630ca645aea6f7f1cd8c8e620c5c42ed", "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/20210402151627.1531623-12-lizh@nvidia.com/mbox/", "series": [ { "id": 16087, "url": "https://patches.dpdk.org/api/series/16087/?format=api", "web_url": "https://patches.dpdk.org/project/dpdk/list/?series=16087", "date": "2021-04-02T15:16:20", "name": "Add ASO meter support in MLX5 PMD", "version": 2, "mbox": "https://patches.dpdk.org/series/16087/mbox/" } ], "comments": "https://patches.dpdk.org/api/patches/90496/comments/", "check": "success", "checks": "https://patches.dpdk.org/api/patches/90496/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 5A8C6A0548;\n\tFri, 2 Apr 2021 17:18:21 +0200 (CEST)", "from [217.70.189.124] (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id 2289114110D;\n\tFri, 2 Apr 2021 17:16:54 +0200 (CEST)", "from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129])\n by mails.dpdk.org (Postfix) with ESMTP id 3A97B141092\n for <dev@dpdk.org>; Fri, 2 Apr 2021 17:16:40 +0200 (CEST)", "from Internal Mail-Server by MTLPINE1 (envelope-from\n lizh@nvidia.com)\n with SMTP; 2 Apr 2021 18:16:35 +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 132FGWdY028272;\n Fri, 2 Apr 2021 18:16:34 +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": "Fri, 2 Apr 2021 18:16:25 +0300", "Message-Id": "<20210402151627.1531623-12-lizh@nvidia.com>", "X-Mailer": "git-send-email 2.21.0", "In-Reply-To": "<20210402151627.1531623-1-lizh@nvidia.com>", "References": "<20210331073632.1443011-1-lizh@nvidia.com>\n <20210402151627.1531623-1-lizh@nvidia.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[dpdk-dev] [PATCH v2 11/13] 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>\n---\n drivers/net/mlx5/linux/mlx5_os.c | 7 ++-\n drivers/net/mlx5/mlx5.c | 10 +++\n drivers/net/mlx5/mlx5.h | 7 ++-\n drivers/net/mlx5/mlx5_flow.c | 69 +++++++++++++++------\n drivers/net/mlx5/mlx5_flow_dv.c | 30 +++++++--\n drivers/net/mlx5/mlx5_flow_meter.c | 97 +++++++++++++++++++-----------\n 6 files changed, 158 insertions(+), 62 deletions(-)", "diff": "diff --git a/drivers/net/mlx5/linux/mlx5_os.c b/drivers/net/mlx5/linux/mlx5_os.c\nindex bd08fe55ab..772feff598 100644\n--- a/drivers/net/mlx5/linux/mlx5_os.c\n+++ b/drivers/net/mlx5/linux/mlx5_os.c\n@@ -741,7 +741,6 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev,\n \tint own_domain_id = 0;\n \tuint16_t port_id;\n \tunsigned int i;\n-\tuint32_t log_obj_size;\n #ifdef HAVE_MLX5DV_DR_DEVX_PORT\n \tstruct mlx5dv_devx_port devx_port = { .comp_mask = 0 };\n #endif\n@@ -1201,7 +1200,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) {\n@@ -1238,7 +1239,7 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev,\n \t\t}\n \t\tif (config->hca_attr.qos.sup &&\n \t\t\tconfig->hca_attr.qos.flow_meter_aso_sup) {\n-\t\t\tlog_obj_size =\n+\t\t\tuint32_t log_obj_size =\n \t\t\t\trte_log2_u32(MLX5_ASO_MTRS_PER_POOL >> 1);\n \t\t\tif (log_obj_size >=\n \t\t\tconfig->hca_attr.qos.log_meter_aso_granularity &&\ndiff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c\nindex 915cf995e0..a9f4d75dd2 100644\n--- a/drivers/net/mlx5/mlx5.c\n+++ b/drivers/net/mlx5/mlx5.c\n@@ -585,13 +585,23 @@ static void\n mlx5_aso_flow_mtrs_mng_close(struct mlx5_dev_ctx_shared *sh)\n {\n \tstruct mlx5_aso_mtr_pool *mtr_pool;\n+\tstruct mlx5_aso_mtr *aso_mtr;\n \tstruct mlx5_aso_mtr_pools_mng *mtrmng = sh->mtrmng;\n \tuint32_t idx;\n+\tint i;\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 94010d2cdd..10570ec274 100644\n--- a/drivers/net/mlx5/mlx5.h\n+++ b/drivers/net/mlx5/mlx5.h\n@@ -634,8 +634,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@@ -698,6 +696,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@@ -1463,7 +1463,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 a3c1034b53..9922731188 100644\n--- a/drivers/net/mlx5/mlx5_flow.c\n+++ b/drivers/net/mlx5/mlx5_flow.c\n@@ -4379,6 +4379,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@@ -4399,6 +4401,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@@ -4416,6 +4419,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 != -1));\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@@ -4423,29 +4432,39 @@ flow_meter_split_prep(struct rte_eth_dev *dev,\n \tint shift;\n \tuint32_t flow_id_val = 0;\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@@ -4455,14 +4474,30 @@ 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/** 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@@ -5278,10 +5313,10 @@ 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/* 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/* The suffix items: tag, vlan, port id, end. */\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@@ -5295,8 +5330,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 03dcc2bfd4..07e381b072 100644\n--- a/drivers/net/mlx5/mlx5_flow_dv.c\n+++ b/drivers/net/mlx5/mlx5_flow_dv.c\n@@ -4887,9 +4887,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@@ -6058,6 +6060,8 @@ flow_dv_mtr_alloc(struct rte_eth_dev *dev)\n \tstruct mlx5_aso_mtr *mtr_free = NULL;\n \tstruct mlx5_aso_mtr_pools_mng *mtrmng = priv->sh->mtrmng;\n \tstruct mlx5_aso_mtr_pool *pool;\n+\tstruct rte_flow_error error;\n+\tuint8_t reg_id;\n \tuint32_t mtr_idx = 0;\n \n \tif (!priv->config.devx) {\n@@ -6080,6 +6084,22 @@ 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\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@@ -11579,7 +11599,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@@ -12688,7 +12708,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)\n@@ -13879,7 +13899,7 @@ flow_dv_prepare_policer_rules(struct rte_eth_dev *dev,\n \t\tmtb->drop_count = NULL;\n \t}\n \t/**\n-\t * If flow meter has been initilized, all policer rules\n+\t * If flow meter has been initialized, all policer rules\n \t * are created. So can get if meter initialized by checking\n \t * any policer rule.\n \t */\ndiff --git a/drivers/net/mlx5/mlx5_flow_meter.c b/drivers/net/mlx5/mlx5_flow_meter.c\nindex bb36696172..c2a063abdb 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": [ "v2", "11/13" ] }{ "id": 90496, "url": "