Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/62723/?format=api
https://patches.dpdk.org/api/patches/62723/?format=api", "web_url": "https://patches.dpdk.org/project/dpdk/patch/1573184965-49691-13-git-send-email-suanmingm@mellanox.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": "<1573184965-49691-13-git-send-email-suanmingm@mellanox.com>", "list_archive_url": "https://inbox.dpdk.org/dev/1573184965-49691-13-git-send-email-suanmingm@mellanox.com", "date": "2019-11-08T03:49:18", "name": "[v2,12/19] net/mlx5: expose flow counters management", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": true, "hash": "799d9ada8b272788342dc57298e9b7fa5792a2d0", "submitter": { "id": 1358, "url": "https://patches.dpdk.org/api/people/1358/?format=api", "name": "Suanming Mou", "email": "suanmingm@mellanox.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/1573184965-49691-13-git-send-email-suanmingm@mellanox.com/mbox/", "series": [ { "id": 7343, "url": "https://patches.dpdk.org/api/series/7343/?format=api", "web_url": "https://patches.dpdk.org/project/dpdk/list/?series=7343", "date": "2019-11-08T03:49:07", "name": "net/mlx5: support meter", "version": 2, "mbox": "https://patches.dpdk.org/series/7343/mbox/" } ], "comments": "https://patches.dpdk.org/api/patches/62723/comments/", "check": "fail", "checks": "https://patches.dpdk.org/api/patches/62723/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 dpdk.org (dpdk.org [92.243.14.124])\n\tby inbox.dpdk.org (Postfix) with ESMTP id 5F175A04AB;\n\tFri, 8 Nov 2019 04:51:15 +0100 (CET)", "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id 9C8341BFEE;\n\tFri, 8 Nov 2019 04:49:57 +0100 (CET)", "from git-send-mailer.rdmz.labs.mlnx (unknown [37.142.13.130])\n by dpdk.org (Postfix) with ESMTP id 566581BF4C\n for <dev@dpdk.org>; Fri, 8 Nov 2019 04:49:33 +0100 (CET)" ], "From": "Suanming Mou <suanmingm@mellanox.com>", "To": "viacheslavo@mellanox.com,\n\tmatan@mellanox.com", "Cc": "orika@mellanox.com,\n\trasland@mellanox.com,\n\tdev@dpdk.org", "Date": "Fri, 8 Nov 2019 05:49:18 +0200", "Message-Id": "<1573184965-49691-13-git-send-email-suanmingm@mellanox.com>", "X-Mailer": "git-send-email 1.8.3.1", "In-Reply-To": "<1573184965-49691-1-git-send-email-suanmingm@mellanox.com>", "References": "<1573053090-179521-1-git-send-email-suanmingm@mellanox.com>\n <1573184965-49691-1-git-send-email-suanmingm@mellanox.com>", "Subject": "[dpdk-dev] [PATCH v2 12/19] net/mlx5: expose flow counters\n\tmanagement", "X-BeenThere": "dev@dpdk.org", "X-Mailman-Version": "2.1.15", "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": "Expose the flow counter management mechanism for other components to\nuse.\n\nSigned-off-by: Suanming Mou <suanmingm@mellanox.com>\n---\n drivers/net/mlx5/mlx5.h | 4 ++\n drivers/net/mlx5/mlx5_flow.c | 83 +++++++++++++++++++++++++++++++++++++++++\n drivers/net/mlx5/mlx5_flow.h | 11 ++++++\n drivers/net/mlx5/mlx5_flow_dv.c | 68 +++++++++++++++++++++++++++++++++\n 4 files changed, 166 insertions(+)", "diff": "diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h\nindex d8a3d40..f9e1396 100644\n--- a/drivers/net/mlx5/mlx5.h\n+++ b/drivers/net/mlx5/mlx5.h\n@@ -959,6 +959,10 @@ void mlx5_flow_async_pool_query_handle(struct mlx5_ibv_shared *sh,\n \t\t\t\t uint64_t async_id, int status);\n void mlx5_set_query_alarm(struct mlx5_ibv_shared *sh);\n void mlx5_flow_query_alarm(void *arg);\n+struct mlx5_flow_counter *mlx5_counter_alloc(struct rte_eth_dev *dev);\n+void mlx5_counter_free(struct rte_eth_dev *dev, struct mlx5_flow_counter *cnt);\n+int mlx5_counter_query(struct rte_eth_dev *dev, struct mlx5_flow_counter *cnt,\n+\t\t bool clear, uint64_t *pkts, uint64_t *bytes);\n \n /* mlx5_mp.c */\n void mlx5_mp_req_start_rxtx(struct rte_eth_dev *dev);\ndiff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c\nindex 2016ead..750e58e 100644\n--- a/drivers/net/mlx5/mlx5_flow.c\n+++ b/drivers/net/mlx5/mlx5_flow.c\n@@ -4996,6 +4996,89 @@ struct mlx5_meter_domains_infos *\n \treturn fops->destroy_policer_rules(dev, fm, attr);\n }\n \n+/**\n+ * Allocate a counter.\n+ *\n+ * @param[in] dev\n+ * Pointer to Ethernet device structure.\n+ *\n+ * @return\n+ * Pointer to allocated counter on success, NULL otherwise.\n+ */\n+struct mlx5_flow_counter *\n+mlx5_counter_alloc(struct rte_eth_dev *dev)\n+{\n+\tconst struct mlx5_flow_driver_ops *fops;\n+\tstruct rte_flow_attr attr = { .transfer = 0 };\n+\n+\tif (flow_get_drv_type(dev, &attr) == MLX5_FLOW_TYPE_DV) {\n+\t\tfops = flow_get_drv_ops(MLX5_FLOW_TYPE_DV);\n+\t\treturn fops->counter_alloc(dev);\n+\t}\n+\tDRV_LOG(ERR,\n+\t\t\"port %u counter allocate is not supported.\",\n+\t\t dev->data->port_id);\n+\treturn NULL;\n+}\n+\n+/**\n+ * Free a counter.\n+ *\n+ * @param[in] dev\n+ * Pointer to Ethernet device structure.\n+ * @param[in] cnt\n+ * Pointer to counter to be free.\n+ */\n+void\n+mlx5_counter_free(struct rte_eth_dev *dev, struct mlx5_flow_counter *cnt)\n+{\n+\tconst struct mlx5_flow_driver_ops *fops;\n+\tstruct rte_flow_attr attr = { .transfer = 0 };\n+\n+\tif (flow_get_drv_type(dev, &attr) == MLX5_FLOW_TYPE_DV) {\n+\t\tfops = flow_get_drv_ops(MLX5_FLOW_TYPE_DV);\n+\t\tfops->counter_free(dev, cnt);\n+\t\treturn;\n+\t}\n+\tDRV_LOG(ERR,\n+\t\t\"port %u counter free is not supported.\",\n+\t\t dev->data->port_id);\n+}\n+\n+/**\n+ * Query counter statistics.\n+ *\n+ * @param[in] dev\n+ * Pointer to Ethernet device structure.\n+ * @param[in] cnt\n+ * Pointer to counter to query.\n+ * @param[in] clear\n+ * Set to clear counter statistics.\n+ * @param[out] pkts\n+ * The counter hits packets number to save.\n+ * @param[out] bytes\n+ * The counter hits bytes number to save.\n+ *\n+ * @return\n+ * 0 on success, a negative errno value otherwise.\n+ */\n+int\n+mlx5_counter_query(struct rte_eth_dev *dev, struct mlx5_flow_counter *cnt,\n+\t\t bool clear, uint64_t *pkts, uint64_t *bytes)\n+{\n+\tconst struct mlx5_flow_driver_ops *fops;\n+\tstruct rte_flow_attr attr = { .transfer = 0 };\n+\n+\tif (flow_get_drv_type(dev, &attr) == MLX5_FLOW_TYPE_DV) {\n+\t\tfops = flow_get_drv_ops(MLX5_FLOW_TYPE_DV);\n+\t\treturn fops->counter_query(dev, cnt, clear, pkts, bytes);\n+\t}\n+\tDRV_LOG(ERR,\n+\t\t\"port %u counter query is not supported.\",\n+\t\t dev->data->port_id);\n+\treturn -ENOTSUP;\n+}\n+\n #define MLX5_POOL_QUERY_FREQ_US 1000000\n \n /**\ndiff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h\nindex 672552b..0326330 100644\n--- a/drivers/net/mlx5/mlx5_flow.h\n+++ b/drivers/net/mlx5/mlx5_flow.h\n@@ -664,6 +664,14 @@ typedef int (*mlx5_flow_destroy_policer_rules_t)\n \t\t\t\t\t(struct rte_eth_dev *dev,\n \t\t\t\t\t const struct mlx5_flow_meter *fm,\n \t\t\t\t\t const struct rte_flow_attr *attr);\n+typedef struct mlx5_flow_counter * (*mlx5_flow_counter_alloc_t)\n+\t\t\t\t (struct rte_eth_dev *dev);\n+typedef void (*mlx5_flow_counter_free_t)(struct rte_eth_dev *dev,\n+\t\t\t\t\t struct mlx5_flow_counter *cnt);\n+typedef int (*mlx5_flow_counter_query_t)(struct rte_eth_dev *dev,\n+\t\t\t\t\t struct mlx5_flow_counter *cnt,\n+\t\t\t\t\t bool clear, uint64_t *pkts,\n+\t\t\t\t\t uint64_t *bytes);\n struct mlx5_flow_driver_ops {\n \tmlx5_flow_validate_t validate;\n \tmlx5_flow_prepare_t prepare;\n@@ -676,6 +684,9 @@ struct mlx5_flow_driver_ops {\n \tmlx5_flow_destroy_mtr_tbls_t destroy_mtr_tbls;\n \tmlx5_flow_create_policer_rules_t create_policer_rules;\n \tmlx5_flow_destroy_policer_rules_t destroy_policer_rules;\n+\tmlx5_flow_counter_alloc_t counter_alloc;\n+\tmlx5_flow_counter_free_t counter_free;\n+\tmlx5_flow_counter_query_t counter_query;\n };\n \n \ndiff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c\nindex aa00b3e..b273b6c 100644\n--- a/drivers/net/mlx5/mlx5_flow_dv.c\n+++ b/drivers/net/mlx5/mlx5_flow_dv.c\n@@ -8005,6 +8005,46 @@ struct field_modify_info modify_tcp[] = {\n \treturn -1;\n }\n \n+/**\n+ * Query a devx counter.\n+ *\n+ * @param[in] dev\n+ * Pointer to the Ethernet device structure.\n+ * @param[in] cnt\n+ * Pointer to the flow counter.\n+ * @param[in] clear\n+ * Set to clear the counter statistics.\n+ * @param[out] pkts\n+ * The statistics value of packets.\n+ * @param[out] bytes\n+ * The statistics value of bytes.\n+ *\n+ * @return\n+ * 0 on success, otherwise return -1.\n+ */\n+static int\n+flow_dv_counter_query(struct rte_eth_dev *dev,\n+\t\t struct mlx5_flow_counter *cnt, bool clear,\n+\t\t uint64_t *pkts, uint64_t *bytes)\n+{\n+\tstruct mlx5_priv *priv = dev->data->dev_private;\n+\tuint64_t inn_pkts, inn_bytes;\n+\tint ret;\n+\n+\tif (!priv->config.devx)\n+\t\treturn -1;\n+\tret = _flow_dv_query_count(dev, cnt, &inn_pkts, &inn_bytes);\n+\tif (ret)\n+\t\treturn -1;\n+\t*pkts = inn_pkts - cnt->hits;\n+\t*bytes = inn_bytes - cnt->bytes;\n+\tif (clear) {\n+\t\tcnt->hits = inn_pkts;\n+\t\tcnt->bytes = inn_bytes;\n+\t}\n+\treturn 0;\n+}\n+\n /*\n * Mutex-protected thunk to lock-free __flow_dv_translate().\n */\n@@ -8062,6 +8102,31 @@ struct field_modify_info modify_tcp[] = {\n \tflow_dv_shared_unlock(dev);\n }\n \n+/*\n+ * Mutex-protected thunk to lock-free flow_dv_counter_alloc().\n+ */\n+static struct mlx5_flow_counter *\n+flow_dv_counter_allocate(struct rte_eth_dev *dev)\n+{\n+\tstruct mlx5_flow_counter *cnt;\n+\n+\tflow_dv_shared_lock(dev);\n+\tcnt = flow_dv_counter_alloc(dev, 0, 0, 1);\n+\tflow_dv_shared_unlock(dev);\n+\treturn cnt;\n+}\n+\n+/*\n+ * Mutex-protected thunk to lock-free flow_dv_counter_release().\n+ */\n+static void\n+flow_dv_counter_free(struct rte_eth_dev *dev, struct mlx5_flow_counter *cnt)\n+{\n+\tflow_dv_shared_lock(dev);\n+\tflow_dv_counter_release(dev, cnt);\n+\tflow_dv_shared_unlock(dev);\n+}\n+\n const struct mlx5_flow_driver_ops mlx5_flow_dv_drv_ops = {\n \t.validate = flow_dv_validate,\n \t.prepare = flow_dv_prepare,\n@@ -8074,6 +8139,9 @@ struct field_modify_info modify_tcp[] = {\n \t.destroy_mtr_tbls = flow_dv_destroy_mtr_tbl,\n \t.create_policer_rules = flow_dv_create_policer_rules,\n \t.destroy_policer_rules = flow_dv_destroy_policer_rules,\n+\t.counter_alloc = flow_dv_counter_allocate,\n+\t.counter_free = flow_dv_counter_free,\n+\t.counter_query = flow_dv_counter_query,\n };\n \n #endif /* HAVE_IBV_FLOW_DV_SUPPORT */\n", "prefixes": [ "v2", "12/19" ] }{ "id": 62723, "url": "