Show a patch.

GET /api/patches/73535/
Content-Type: application/json
Vary: Accept

    "id": 73535,
    "url": "",
    "web_url": "",
    "project": {
        "id": 1,
        "url": "",
        "name": "DPDK",
        "link_name": "dpdk",
        "list_id": "",
        "list_email": "",
        "web_url": "",
        "scm_url": "git://",
        "webscm_url": ""
    "msgid": "<>",
    "date": "2020-07-08T14:43:07",
    "name": "[5/5] net/mlx5: create and destroy eCPRI flex parser",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "b68b3e8f3469e3671c3a2ae8bbac4b571a1c25bd",
    "submitter": {
        "id": 1357,
        "url": "",
        "name": "Bing Zhao",
        "email": ""
    "delegate": {
        "id": 3268,
        "url": "",
        "username": "rasland",
        "first_name": "Raslan",
        "last_name": "Darawsheh",
        "email": ""
    "mbox": "",
    "series": [
            "id": 10893,
            "url": "",
            "web_url": "",
            "date": "2020-07-08T14:43:02",
            "name": "add eCPRI support in mlx5 driver",
            "version": 1,
            "mbox": ""
    "comments": "",
    "check": "warning",
    "checks": "",
    "tags": {},
    "headers": {
        "X-Mailman-Version": "2.1.15",
        "In-Reply-To": "<>",
        "Errors-To": "",
        "X-Mailer": "git-send-email",
        "Received": [
            "from ( [])\n\tby (Postfix) with ESMTP id 521FAA0527;\n\tWed,  8 Jul 2020 16:44:07 +0200 (CEST)",
            "from [] (localhost [])\n\tby (Postfix) with ESMTP id E61E51E4A8;\n\tWed,  8 Jul 2020 16:43:34 +0200 (CEST)",
            "from git-send-mailer.rdmz.labs.mlnx (unknown [])\n by (Postfix) with ESMTP id 9B52E2C4F\n for <>; Wed,  8 Jul 2020 16:43:32 +0200 (CEST)"
        "References": "<>",
        "Delivered-To": "",
        "X-BeenThere": "",
        "Message-Id": "<>",
        "List-Post": "<>",
        "Precedence": "list",
        "From": "Bing Zhao <>",
        "X-Original-To": "",
        "Return-Path": "<>",
        "Sender": "\"dev\" <>",
        "List-Help": "<>",
        "List-Subscribe": "<>,\n <>",
        "To": ",\n\",
        "List-Id": "DPDK patches and discussions <>",
        "List-Unsubscribe": "<>,\n <>",
        "Date": "Wed,  8 Jul 2020 22:43:07 +0800",
        "Cc": ",\n\,\n\",
        "List-Archive": "<>",
        "Subject": "[dpdk-dev] [PATCH 5/5] net/mlx5: create and destroy eCPRI flex\n\tparser"
    "content": "eCPRI protocol has unified format layout for the variants, over\nETH layer (including .1Q) and UDP layer.\n\nThe common header of the message has 4 bytes fixed length, and the\nmessage payload layers are different based on the type field. Now\nonly type #0, #2 and #5 will be supported, and 2 bytes are needed.\n\nWhen creating the flex parser, the header will be extended to 8\nbytes and 2 DW samples are needed. The 1st DW starts from offset 0\nand will be used for the type field of the common header. The 2nd\nDW starts from offset 4 and will be used for the physical channel\nID, real-time control ID or measurement ID fields.\n\nThe parser will be created once a flow with eCPRI item is observed\nfor the first time. After creating, it will remain in the system\nand HW until the device is stopped. Right now, there is no need to\ndestroy the eCPRI flex parser after the last flow with eCPRI item\nis destroyed. This is to get rid of the alternate states of creating\nand destroying eCPRI flex parser with a single eCPRI flow.\n\nSigned-off-by: Bing Zhao <>\n---\n drivers/net/mlx5/mlx5.c         | 76 +++++++++++++++++++++++++++++++++++++++++\n drivers/net/mlx5/mlx5.h         |  3 ++\n drivers/net/mlx5/mlx5_flow_dv.c | 35 +++----------------\n 3 files changed, 83 insertions(+), 31 deletions(-)",
    "diff": "diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c\nindex 07c6add..4f6274d 100644\n--- a/drivers/net/mlx5/mlx5.c\n+++ b/drivers/net/mlx5/mlx5.c\n@@ -597,6 +597,80 @@ struct mlx5_flow_id_pool *\n \t\tmlx5_ipool_destroy(sh->ipool[i]);\n }\n \n+bool\n+mlx5_flex_parser_ecpri_exist(struct rte_eth_dev *dev)\n+{\n+\tstruct mlx5_priv *priv = dev->data->dev_private;\n+\tstruct mlx5_flex_parser_profiles *prf =\n+\t\t\t\t&priv->sh->fp[MLX5_FLEX_PARSER_ECPRI_0];\n+\n+\treturn !!prf->obj;\n+}\n+\n+int\n+mlx5_flex_parser_ecpri_alloc(struct rte_eth_dev *dev)\n+{\n+\tstruct mlx5_priv *priv = dev->data->dev_private;\n+\tstruct mlx5_flex_parser_profiles *prf =\n+\t\t\t\t&priv->sh->fp[MLX5_FLEX_PARSER_ECPRI_0];\n+\tstruct mlx5_devx_graph_node_attr node = {\n+\t\t.modify_field_select = 0,\n+\t};\n+\tuint32_t ids[8];\n+\tint ret;\n+\n+\tnode.header_length_mode = MLX5_GRAPH_NODE_LEN_FIXED;\n+\t/* 8 bytes now: 4B common header + 4B message body header. */\n+\tnode.header_length_base_value = 0x8;\n+\t/* After MAC layer: Ether / VLAN. */\n+\[0].arc_parse_graph_node = 0x2;\n+\t/* Type of compared condition should be 0xAEFE in the L2 layer. */\n+\[0].compare_condition_value = RTE_ETHER_TYPE_ECPRI;\n+\t/* Sample #0: type in common header. */\n+\tnode.sample[0].flow_match_sample_en = 1;\n+\t/* Fixed offset. */\n+\tnode.sample[0].flow_match_sample_offset_mode = 0x0;\n+\t/* Only the 2nd byte will be used. */\n+\tnode.sample[0].flow_match_sample_field_base_offset = 0x0;\n+\t/* Sample #1: message payload. */\n+\tnode.sample[1].flow_match_sample_en = 1;\n+\t/* Fixed offset. */\n+\tnode.sample[1].flow_match_sample_offset_mode = 0x0;\n+\t/* Only the first two bytes will be used. */\n+\tnode.sample[1].flow_match_sample_field_base_offset = 0x4;\n+\tprf->obj = mlx5_devx_cmd_create_flex_parser(priv->sh->ctx, &node);\n+\tif (!prf->obj) {\n+\t\tDRV_LOG(ERR, \"Failed to create flex parser node object.\");\n+\t\treturn (rte_errno == 0) ? -ENODEV : -rte_errno;\n+\t}\n+\tprf->num = 2;\n+\tret = mlx5_devx_cmd_query_parse_samples(prf->obj, ids, prf->num);\n+\tif (ret) {\n+\t\tDRV_LOG(ERR, \"Failed to query sample IDs.\");\n+\t\treturn (rte_errno == 0) ? -ENODEV : -rte_errno;\n+\t}\n+\tprf->offset[0] = 0x0;\n+\tprf->offset[1] = 0x4;\n+\tprf->ids[0] = ids[0];\n+\tprf->ids[1] = ids[1];\n+\treturn 0;\n+}\n+\n+static void\n+mlx5_flex_parser_ecpri_release(struct rte_eth_dev *dev)\n+{\n+\tstruct mlx5_priv *priv = dev->data->dev_private;\n+\n+\tstruct mlx5_flex_parser_profiles *prf =\n+\t\t\t\t&priv->sh->fp[MLX5_FLEX_PARSER_ECPRI_0];\n+\n+\tif (prf->obj)\n+\t\tmlx5_devx_cmd_destroy(prf->obj);\n+\tprf->obj = NULL;\n+\treturn;\n+}\n+\n+\n /**\n  * Allocate shared device context. If there is multiport device the\n  * master and representors will share this context, if there is single\n@@ -1158,6 +1232,8 @@ struct mlx5_dev_ctx_shared *\n \trte_wmb();\n \t/* Disable datapath on secondary process. */\n \tmlx5_mp_req_stop_rxtx(dev);\n+\t/* Free the eCPRI flex parser resource. */\n+\tmlx5_flex_parser_ecpri_release(dev);\n \tif (priv->rxqs != NULL) {\n \t\t/* XXX race condition if mlx5_rx_burst() is still running. */\n \t\tusleep(1000);\ndiff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h\nindex 07cbaf4..42a8bd5 100644\n--- a/drivers/net/mlx5/mlx5.h\n+++ b/drivers/net/mlx5/mlx5.h\n@@ -734,6 +734,8 @@ int mlx5_dev_check_sibling_config(struct mlx5_priv *priv,\n int mlx5_dev_set_mtu(struct rte_eth_dev *dev, uint16_t mtu);\n int mlx5_hairpin_cap_get(struct rte_eth_dev *dev,\n \t\t\t struct rte_eth_hairpin_cap *cap);\n+bool mlx5_flex_parser_ecpri_exist(struct rte_eth_dev *dev);\n+int mlx5_flex_parser_ecpri_alloc(struct rte_eth_dev *dev);\n \n /* mlx5_ethdev.c */\n \n@@ -957,4 +959,5 @@ int mlx5_os_read_dev_stat(struct mlx5_priv *priv,\n void mlx5_os_stats_init(struct rte_eth_dev *dev);\n void mlx5_os_set_reg_mr_cb(mlx5_reg_mr_t *reg_mr_cb,\n \t\t\t   mlx5_dereg_mr_t *dereg_mr_cb);\n+\n #endif /* RTE_PMD_MLX5_H_ */\ndiff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c\nindex 523d778..987c635 100644\n--- a/drivers/net/mlx5/mlx5_flow_dv.c\n+++ b/drivers/net/mlx5/mlx5_flow_dv.c\n@@ -4779,34 +4779,6 @@ struct field_modify_info modify_tcp[] = {\n \t\t\t\t  cnt, next);\n }\n \n-static inline bool\n-flow_dv_flex_parser_ecpri_exist(struct rte_eth_dev *dev)\n-{\n-\tstruct mlx5_priv *priv = dev->data->dev_private;\n-\tstruct mlx5_flex_parser_profiles *prf =\n-\t\t\t\t&priv->sh->fp[MLX5_FLEX_PARSER_ECPRI_0];\n-\n-\treturn !!prf->obj;\n-}\n-\n-\n-static int\n-flow_dv_flex_parser_ecpri_alloc(struct rte_eth_dev *dev)\n-{\n-\tstruct mlx5_priv *priv = dev->data->dev_private;\n-\tstruct mlx5_flex_parser_profiles *prf =\n-\t\t\t\t&priv->sh->fp[MLX5_FLEX_PARSER_ECPRI_0];\n-\n-\treturn 0;\n-}\n-\n-static void\n-flow_dv_flex_parser_ecpri_release(struct rte_eth_dev *dev)\n-{\n-\t(void)dev;\n-\treturn;\n-}\n-\n /**\n  * Verify the @p attributes will be correctly understood by the NIC and store\n  * them in the @p flow if everything is correct.\n@@ -8688,11 +8660,12 @@ struct field_modify_info modify_tcp[] = {\n \t\t\tlast_item = MLX5_FLOW_LAYER_GTP;\n \t\t\tbreak;\n \t\tcase RTE_FLOW_ITEM_TYPE_ECPRI:\n-\t\t\tif (!flow_dv_flex_parser_ecpri_exist(dev)) {\n-\t\t\t\tret = flow_dv_flex_parser_ecpri_alloc(dev);\n+\t\t\tif (!mlx5_flex_parser_ecpri_exist(dev)) {\n+\t\t\t\t/* Create it only the first time to be used. */\n+\t\t\t\tret = mlx5_flex_parser_ecpri_alloc(dev);\n \t\t\t\tif (ret)\n \t\t\t\t\treturn rte_flow_error_set\n-\t\t\t\t\t\t(error, ret,\n+\t\t\t\t\t\t(error, -ret,\n \t\t\t\t\t\tRTE_FLOW_ERROR_TYPE_ITEM,\n \t\t\t\t\t\tNULL,\n \t\t\t\t\t\t\"cannot create eCPRI parser\");\n",
    "prefixes": [