get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 62724,
    "url": "http://patches.dpdk.org/api/patches/62724/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/1573184965-49691-8-git-send-email-suanmingm@mellanox.com/",
    "project": {
        "id": 1,
        "url": "http://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-8-git-send-email-suanmingm@mellanox.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/1573184965-49691-8-git-send-email-suanmingm@mellanox.com",
    "date": "2019-11-08T03:49:13",
    "name": "[v2,07/19] net/mlx5: add policer rules operations",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": true,
    "hash": "c54eedba2dd58d1bb80f26582d42a0a6dd32085c",
    "submitter": {
        "id": 1358,
        "url": "http://patches.dpdk.org/api/people/1358/?format=api",
        "name": "Suanming Mou",
        "email": "suanmingm@mellanox.com"
    },
    "delegate": {
        "id": 3268,
        "url": "http://patches.dpdk.org/api/users/3268/?format=api",
        "username": "rasland",
        "first_name": "Raslan",
        "last_name": "Darawsheh",
        "email": "rasland@nvidia.com"
    },
    "mbox": "http://patches.dpdk.org/project/dpdk/patch/1573184965-49691-8-git-send-email-suanmingm@mellanox.com/mbox/",
    "series": [
        {
            "id": 7343,
            "url": "http://patches.dpdk.org/api/series/7343/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=7343",
            "date": "2019-11-08T03:49:07",
            "name": "net/mlx5: support meter",
            "version": 2,
            "mbox": "http://patches.dpdk.org/series/7343/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/62724/comments/",
    "check": "fail",
    "checks": "http://patches.dpdk.org/api/patches/62724/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 BEB6CA04AB;\n\tFri,  8 Nov 2019 04:51:24 +0100 (CET)",
            "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id 2D5A41BFF4;\n\tFri,  8 Nov 2019 04:49:59 +0100 (CET)",
            "from git-send-mailer.rdmz.labs.mlnx (unknown [37.142.13.130])\n by dpdk.org (Postfix) with ESMTP id 6881B1BF5B\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:13 +0200",
        "Message-Id": "<1573184965-49691-8-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 07/19] net/mlx5: add policer rules operations",
        "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": "This commit create the color rules on the meter table for the packets.\n\nAs the prefix flow with meter action colors the packets, the packets\nare transferred to the meter table with meter color match flows. Here\nwe create the flow rules  with green yellow red actions on the meter\ntable. Packets match the color will be processed by the related color\nflow rule.\n\nSigned-off-by: Suanming Mou <suanmingm@mellanox.com>\n---\n drivers/net/mlx5/mlx5_flow.c    |  46 ++++++++++\n drivers/net/mlx5/mlx5_flow.h    |  18 ++++\n drivers/net/mlx5/mlx5_flow_dv.c | 187 ++++++++++++++++++++++++++++++++++++++--\n 3 files changed, 245 insertions(+), 6 deletions(-)",
    "diff": "diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c\nindex 6e34c7a..2016ead 100644\n--- a/drivers/net/mlx5/mlx5_flow.c\n+++ b/drivers/net/mlx5/mlx5_flow.c\n@@ -4950,6 +4950,52 @@ struct mlx5_meter_domains_infos *\n \treturn fops->destroy_mtr_tbls(dev, tbls);\n }\n \n+/**\n+ * Create policer rules.\n+ *\n+ * @param[in] dev\n+ *   Pointer to Ethernet device.\n+ * @param[in] fm\n+ *   Pointer to flow meter structure.\n+ * @param[in] attr\n+ *   Pointer to flow attributes.\n+ *\n+ * @return\n+ *   0 on success, -1 otherwise.\n+ */\n+int\n+mlx5_flow_create_policer_rules(struct rte_eth_dev *dev,\n+\t\t\t       struct mlx5_flow_meter *fm,\n+\t\t\t       const struct rte_flow_attr *attr)\n+{\n+\tconst struct mlx5_flow_driver_ops *fops;\n+\n+\tfops = flow_get_drv_ops(MLX5_FLOW_TYPE_DV);\n+\treturn fops->create_policer_rules(dev, fm, attr);\n+}\n+\n+/**\n+ * Destroy policer rules.\n+ *\n+ * @param[in] fm\n+ *   Pointer to flow meter structure.\n+ * @param[in] attr\n+ *   Pointer to flow attributes.\n+ *\n+ * @return\n+ *   0 on success, -1 otherwise.\n+ */\n+int\n+mlx5_flow_destroy_policer_rules(struct rte_eth_dev *dev,\n+\t\t\t\tstruct mlx5_flow_meter *fm,\n+\t\t\t\tconst struct rte_flow_attr *attr)\n+{\n+\tconst struct mlx5_flow_driver_ops *fops;\n+\n+\tfops = flow_get_drv_ops(MLX5_FLOW_TYPE_DV);\n+\treturn fops->destroy_policer_rules(dev, fm, attr);\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 d8f1537..489d7c0 100644\n--- a/drivers/net/mlx5/mlx5_flow.h\n+++ b/drivers/net/mlx5/mlx5_flow.h\n@@ -559,6 +559,8 @@ struct mlx5_meter_domains_infos {\n struct mlx5_flow_meter {\n \tuint32_t meter_id;\n \t/**< Meter id. */\n+\tstruct rte_mtr_params params;\n+\t/**< Meter rule parameters. */\n \tstruct mlx5_meter_domains_infos *mfts;\n \t/**< Flow table created for this meter. */\n \tuint32_t ref_cnt;\n@@ -636,6 +638,14 @@ typedef int (*mlx5_flow_query_t)(struct rte_eth_dev *dev,\n \t\t\t\t\t    (struct rte_eth_dev *dev);\n typedef int (*mlx5_flow_destroy_mtr_tbls_t)(struct rte_eth_dev *dev,\n \t\t\t\t\tstruct mlx5_meter_domains_infos *tbls);\n+typedef int (*mlx5_flow_create_policer_rules_t)\n+\t\t\t\t\t(struct rte_eth_dev *dev,\n+\t\t\t\t\t struct mlx5_flow_meter *fm,\n+\t\t\t\t\t const struct rte_flow_attr *attr);\n+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 struct mlx5_flow_driver_ops {\n \tmlx5_flow_validate_t validate;\n \tmlx5_flow_prepare_t prepare;\n@@ -646,6 +656,8 @@ struct mlx5_flow_driver_ops {\n \tmlx5_flow_query_t query;\n \tmlx5_flow_create_mtr_tbls_t create_mtr_tbls;\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 };\n \n \n@@ -776,4 +788,10 @@ struct mlx5_meter_domains_infos *mlx5_flow_create_mtr_tbls\n \t\t\t\t\t(struct rte_eth_dev *dev);\n int mlx5_flow_destroy_mtr_tbls(struct rte_eth_dev *dev,\n \t\t\t       struct mlx5_meter_domains_infos *tbl);\n+int mlx5_flow_create_policer_rules(struct rte_eth_dev *dev,\n+\t\t\t\t   struct mlx5_flow_meter *fm,\n+\t\t\t\t   const struct rte_flow_attr *attr);\n+int mlx5_flow_destroy_policer_rules(struct rte_eth_dev *dev,\n+\t\t\t\t    struct mlx5_flow_meter *fm,\n+\t\t\t\t    const struct rte_flow_attr *attr);\n #endif /* RTE_PMD_MLX5_FLOW_H_ */\ndiff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c\nindex c0e5470..aa00b3e 100644\n--- a/drivers/net/mlx5/mlx5_flow_dv.c\n+++ b/drivers/net/mlx5/mlx5_flow_dv.c\n@@ -7660,6 +7660,9 @@ struct field_modify_info modify_tcp[] = {\n \treturn 0;\n }\n \n+/* Number of meter flow actions, count and jump or count and drop. */\n+#define METER_ACTIONS 2\n+\n /**\n  * Create specify domain meter table and suffix table.\n  *\n@@ -7697,12 +7700,6 @@ struct field_modify_info modify_tcp[] = {\n \t\t.match_criteria_enable = 0,\n \t\t.match_mask = (void *)&mask,\n \t};\n-\t/*\n-\t * Need reserve two actions here. As for the meter flow, the action\n-\t * to be performed will be jump or drop. The other reserve action is\n-\t * for count.\n-\t */\n-#define METER_ACTIONS 2\n \tvoid *actions[METER_ACTIONS];\n \tstruct mlx5_flow_tbl_resource **sfx_tbl;\n \tstruct mlx5_meter_domain_info *dtb;\n@@ -7832,6 +7829,182 @@ struct field_modify_info modify_tcp[] = {\n \treturn NULL;\n }\n \n+/**\n+ * Destroy domain policer rule.\n+ *\n+ * @param[in] dt\n+ *   Pointer to domain table.\n+ */\n+static void\n+flow_dv_destroy_domain_policer_rule(struct mlx5_meter_domain_info *dt)\n+{\n+\tint i;\n+\n+\tfor (i = 0; i < RTE_MTR_DROPPED; i++) {\n+\t\tif (dt->policer_rules[i]) {\n+\t\t\tclaim_zero(mlx5_glue->dv_destroy_flow\n+\t\t\t\t  (dt->policer_rules[i]));\n+\t\t\tdt->policer_rules[i] = NULL;\n+\t\t}\n+\t}\n+\tif (dt->jump_actn) {\n+\t\tclaim_zero(mlx5_glue->destroy_flow_action(dt->jump_actn));\n+\t\tdt->jump_actn = NULL;\n+\t}\n+}\n+\n+/**\n+ * Destroy policer rules.\n+ *\n+ * @param[in] dev\n+ *   Pointer to Ethernet device.\n+ * @param[in] fm\n+ *   Pointer to flow meter structure.\n+ * @param[in] attr\n+ *   Pointer to flow attributes.\n+ *\n+ * @return\n+ *   Always 0.\n+ */\n+static int\n+flow_dv_destroy_policer_rules(struct rte_eth_dev *dev __rte_unused,\n+\t\t\t      const struct mlx5_flow_meter *fm,\n+\t\t\t      const struct rte_flow_attr *attr)\n+{\n+\tstruct mlx5_meter_domains_infos *mtb = fm ? fm->mfts : NULL;\n+\n+\tif (!mtb)\n+\t\treturn 0;\n+\tif (attr->egress)\n+\t\tflow_dv_destroy_domain_policer_rule(&mtb->egress);\n+\tif (attr->ingress)\n+\t\tflow_dv_destroy_domain_policer_rule(&mtb->ingress);\n+\tif (attr->transfer)\n+\t\tflow_dv_destroy_domain_policer_rule(&mtb->transfer);\n+\treturn 0;\n+}\n+\n+/**\n+ * Create specify domain meter policer rule.\n+ *\n+ * @param[in] fm\n+ *   Pointer to flow meter structure.\n+ * @param[in] mtb\n+ *   Pointer to DV meter table set.\n+ * @param[in] sfx_tb\n+ *   Pointer to suffix table.\n+ * @param[in] mtr_reg_c\n+ *   Color match REG_C.\n+ *\n+ * @return\n+ *   0 on success, -1 otherwise.\n+ */\n+static int\n+flow_dv_create_policer_forward_rule(struct mlx5_flow_meter *fm,\n+\t\t\t\t    struct mlx5_meter_domain_info *dtb,\n+\t\t\t\t    struct mlx5_flow_tbl_resource *sfx_tb,\n+\t\t\t\t    uint8_t mtr_reg_c)\n+{\n+\tstruct mlx5_flow_dv_match_params matcher = {\n+\t\t.size = sizeof(matcher.buf),\n+\t};\n+\tstruct mlx5_flow_dv_match_params value = {\n+\t\t.size = sizeof(value.buf),\n+\t};\n+\tstruct mlx5_meter_domains_infos *mtb = fm->mfts;\n+\tvoid *actions[METER_ACTIONS];\n+\tint i;\n+\n+\t/* Create jump action. */\n+\tif (!sfx_tb)\n+\t\treturn -1;\n+\tif (!dtb->jump_actn)\n+\t\tdtb->jump_actn =\n+\t\t\tmlx5_glue->dr_create_flow_action_dest_flow_tbl\n+\t\t\t\t\t\t\t(sfx_tb->obj);\n+\tif (!dtb->jump_actn) {\n+\t\tDRV_LOG(ERR, \"Failed to create policer jump action.\");\n+\t\tgoto error;\n+\t}\n+\tfor (i = 0; i < RTE_MTR_DROPPED; i++) {\n+\t\tint j = 0;\n+\n+\t\tflow_dv_match_meta_reg(matcher.buf, value.buf, mtr_reg_c,\n+\t\t\t\t       rte_col_2_mlx5_col(i), UINT32_MAX);\n+\t\tif (fm->params.action[i] == MTR_POLICER_ACTION_DROP)\n+\t\t\tactions[j++] = mtb->drop_actn;\n+\t\telse\n+\t\t\tactions[j++] = dtb->jump_actn;\n+\t\tdtb->policer_rules[i] =\n+\t\t\tmlx5_glue->dv_create_flow(dtb->color_matcher,\n+\t\t\t\t\t\t (void *)&value,\n+\t\t\t\t\t\t  j, actions);\n+\t\tif (!dtb->policer_rules[i]) {\n+\t\t\tDRV_LOG(ERR, \"Failed to create policer rule.\");\n+\t\t\tgoto error;\n+\t\t}\n+\t}\n+\treturn 0;\n+error:\n+\trte_errno = errno;\n+\treturn -1;\n+}\n+\n+/**\n+ * Create policer rules.\n+ *\n+ * @param[in] dev\n+ *   Pointer to Ethernet device.\n+ * @param[in] fm\n+ *   Pointer to flow meter structure.\n+ * @param[in] attr\n+ *   Pointer to flow attributes.\n+ *\n+ * @return\n+ *   0 on success, -1 otherwise.\n+ */\n+static int\n+flow_dv_create_policer_rules(struct rte_eth_dev *dev,\n+\t\t\t     struct mlx5_flow_meter *fm,\n+\t\t\t     const struct rte_flow_attr *attr)\n+{\n+\tstruct mlx5_priv *priv = dev->data->dev_private;\n+\tstruct mlx5_meter_domains_infos *mtb = fm->mfts;\n+\tint ret;\n+\n+\tif (attr->egress) {\n+\t\tret = flow_dv_create_policer_forward_rule(fm, &mtb->egress,\n+\t\t\t\t\t\tpriv->sh->tx_mtr_sfx_tbl,\n+\t\t\t\t\t\tpriv->mtr_color_reg);\n+\t\tif (ret) {\n+\t\t\tDRV_LOG(ERR, \"Failed to create egress policer.\");\n+\t\t\tgoto error;\n+\t\t}\n+\t}\n+\tif (attr->ingress) {\n+\t\tret = flow_dv_create_policer_forward_rule(fm, &mtb->ingress,\n+\t\t\t\t\t\tpriv->sh->rx_mtr_sfx_tbl,\n+\t\t\t\t\t\tpriv->mtr_color_reg);\n+\t\tif (ret) {\n+\t\t\tDRV_LOG(ERR, \"Failed to create ingress policer.\");\n+\t\t\tgoto error;\n+\t\t}\n+\t}\n+\tif (attr->transfer) {\n+\t\tret = flow_dv_create_policer_forward_rule(fm, &mtb->transfer,\n+\t\t\t\t\t\tpriv->sh->fdb_mtr_sfx_tbl,\n+\t\t\t\t\t\tpriv->mtr_color_reg);\n+\t\tif (ret) {\n+\t\t\tDRV_LOG(ERR, \"Failed to create transfer policer.\");\n+\t\t\tgoto error;\n+\t\t}\n+\t}\n+\treturn 0;\n+error:\n+\tflow_dv_destroy_policer_rules(dev, fm, attr);\n+\treturn -1;\n+}\n+\n /*\n  * Mutex-protected thunk to lock-free  __flow_dv_translate().\n  */\n@@ -7899,6 +8072,8 @@ struct field_modify_info modify_tcp[] = {\n \t.query = flow_dv_query,\n \t.create_mtr_tbls = flow_dv_create_mtr_tbl,\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 };\n \n #endif /* HAVE_IBV_FLOW_DV_SUPPORT */\n",
    "prefixes": [
        "v2",
        "07/19"
    ]
}