get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 62563,
    "url": "http://patches.dpdk.org/api/patches/62563/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/1573053090-179521-16-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": "<1573053090-179521-16-git-send-email-suanmingm@mellanox.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/1573053090-179521-16-git-send-email-suanmingm@mellanox.com",
    "date": "2019-11-06T15:11:24",
    "name": "[15/19] net/mlx5: add meter attach and detach",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "ce61e4c34109ac6dff20aea2337ba63cad099789",
    "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/1573053090-179521-16-git-send-email-suanmingm@mellanox.com/mbox/",
    "series": [
        {
            "id": 7297,
            "url": "http://patches.dpdk.org/api/series/7297/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=7297",
            "date": "2019-11-06T15:11:09",
            "name": "net/mlx5: support meter",
            "version": 1,
            "mbox": "http://patches.dpdk.org/series/7297/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/62563/comments/",
    "check": "fail",
    "checks": "http://patches.dpdk.org/api/patches/62563/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 7399DA04AB;\n\tWed,  6 Nov 2019 16:14:07 +0100 (CET)",
            "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id 2ED121C2E9;\n\tWed,  6 Nov 2019 16:12:25 +0100 (CET)",
            "from git-send-mailer.rdmz.labs.mlnx (unknown [37.142.13.130])\n by dpdk.org (Postfix) with ESMTP id A9FC51C1BD\n for <dev@dpdk.org>; Wed,  6 Nov 2019 16:12:00 +0100 (CET)"
        ],
        "From": "Suanming Mou <suanmingm@mellanox.com>",
        "To": "Matan Azrad <matan@mellanox.com>, Shahaf Shuler <shahafs@mellanox.com>,\n Viacheslav Ovsiienko <viacheslavo@mellanox.com>",
        "Cc": "dev@dpdk.org",
        "Date": "Wed,  6 Nov 2019 17:11:24 +0200",
        "Message-Id": "<1573053090-179521-16-git-send-email-suanmingm@mellanox.com>",
        "X-Mailer": "git-send-email 1.8.3.1",
        "In-Reply-To": "<1573053090-179521-1-git-send-email-suanmingm@mellanox.com>",
        "References": "<1573053090-179521-1-git-send-email-suanmingm@mellanox.com>",
        "Subject": "[dpdk-dev] [PATCH 15/19] net/mlx5: add meter attach and detach",
        "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": "Add the meter attach and detach for the flow create.\n\nWhen create the flow with meter, first try to find any created meter\naction matches the flow meter id. If the meter action is already\ncreated, just attach to it and increase the ref_cnt. If not, create\none.\n\nFor the dettach, decrease the ref_cnt, destroy the meter action while\nthe ref_cnt decreased to zero.\n\nSigned-off-by: Suanming Mou <suanmingm@mellanox.com>\n---\n drivers/net/mlx5/mlx5.h            |   6 ++\n drivers/net/mlx5/mlx5_flow.h       |   4 ++\n drivers/net/mlx5/mlx5_flow_meter.c | 140 +++++++++++++++++++++++++++++++++++++\n 3 files changed, 150 insertions(+)",
    "diff": "diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h\nindex 2e35f00..aaf2ed5 100644\n--- a/drivers/net/mlx5/mlx5.h\n+++ b/drivers/net/mlx5/mlx5.h\n@@ -1038,5 +1038,11 @@ struct mlx5_devx_obj *mlx5_devx_cmd_create_tis\n int mlx5_flow_meter_ops_get(struct rte_eth_dev *dev, void *arg);\n struct mlx5_flow_meter *mlx5_flow_meter_find(struct mlx5_priv *priv,\n \t\t\t\t\t     uint32_t meter_id);\n+struct mlx5_flow_meter *mlx5_flow_meter_attach\n+\t\t\t\t\t(struct mlx5_priv *priv,\n+\t\t\t\t\t uint32_t meter_id,\n+\t\t\t\t\t const struct rte_flow_attr *attr,\n+\t\t\t\t\t struct rte_flow_error *error);\n+void mlx5_flow_meter_detach(struct mlx5_flow_meter *fm);\n \n #endif /* RTE_PMD_MLX5_H_ */\ndiff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h\nindex aee340f..ff89ae4 100644\n--- a/drivers/net/mlx5/mlx5_flow.h\n+++ b/drivers/net/mlx5/mlx5_flow.h\n@@ -201,6 +201,7 @@ enum mlx5_feature_name {\n #define MLX5_FLOW_ACTION_SET_TAG (1ull << 32)\n #define MLX5_FLOW_ACTION_MARK_EXT (1ull << 33)\n #define MLX5_FLOW_ACTION_SET_META (1ull << 34)\n+#define MLX5_FLOW_ACTION_METER (1ull << 35)\n \n #define MLX5_FLOW_FATE_ACTIONS \\\n \t(MLX5_FLOW_ACTION_DROP | MLX5_FLOW_ACTION_QUEUE | \\\n@@ -585,6 +586,8 @@ struct mlx5_flow_meter {\n \t/**< Meter rule parameters. */\n \tstruct mlx5_flow_meter_profile *profile;\n \t/**< Meter profile parameters. */\n+\tstruct rte_flow_attr attr;\n+\t/**< Flow attributes. */\n \tstruct mlx5_meter_domains_infos *mfts;\n \t/**< Flow table created for this meter. */\n \tstruct mlx5_flow_policer_stats policer_stats;\n@@ -631,6 +634,7 @@ struct rte_flow {\n \tstruct mlx5_flow_counter *counter; /**< Holds flow counter. */\n \tstruct mlx5_flow_mreg_copy_resource *mreg_copy;\n \t/**< pointer to metadata register copy table resource. */\n+\tstruct mlx5_flow_meter *meter; /**< Holds flow meter. */\n \tLIST_HEAD(dev_flows, mlx5_flow) dev_flows;\n \t/**< Device flows that are part of the flow. */\n \tstruct mlx5_fdir *fdir; /**< Pointer to associated FDIR if any. */\ndiff --git a/drivers/net/mlx5/mlx5_flow_meter.c b/drivers/net/mlx5/mlx5_flow_meter.c\nindex 9efb2d4..bd2bf7c 100644\n--- a/drivers/net/mlx5/mlx5_flow_meter.c\n+++ b/drivers/net/mlx5/mlx5_flow_meter.c\n@@ -12,6 +12,61 @@\n #include \"mlx5_flow.h\"\n \n /**\n+ * Create the meter action.\n+ *\n+ * @param priv\n+ *   Pointer to mlx5_priv.\n+ * @param[in] fm\n+ *   Pointer to flow meter to be converted.\n+ *\n+ * @return\n+ *   Pointer to the meter action on success, NULL otherwise.\n+ */\n+static void *\n+mlx5_flow_meter_action_create(struct mlx5_priv *priv,\n+\t\t\t      struct mlx5_flow_meter *fm)\n+{\n+#ifdef HAVE_MLX5_DR_CREATE_ACTION_FLOW_METER\n+\tstruct mlx5dv_dr_flow_meter_attr mtr_init;\n+\tvoid *attr = fm->mfts->fmp;\n+\tstruct mlx5_flow_meter_srtcm_rfc2697_prm *srtcm =\n+\t\t\t\t\t\t     &fm->profile->srtcm_prm;\n+\n+\tfm->mfts->fmp_size = MLX5_ST_SZ_BYTES(flow_meter_parameters);\n+\tmemset(attr, 0, fm->mfts->fmp_size);\n+\tMLX5_SET(flow_meter_parameters, attr, valid, 1);\n+\tMLX5_SET(flow_meter_parameters, attr, bucket_overflow, 1);\n+\tMLX5_SET(flow_meter_parameters, attr,\n+\t\t start_color, MLX5_FLOW_COLOR_GREEN);\n+\tMLX5_SET(flow_meter_parameters, attr, both_buckets_on_green, 0);\n+\tMLX5_SET(flow_meter_parameters,\n+\t\t attr, cbs_exponent, srtcm->cbs_exponent);\n+\tMLX5_SET(flow_meter_parameters,\n+\t\t attr, cbs_mantissa, srtcm->cbs_mantissa);\n+\tMLX5_SET(flow_meter_parameters,\n+\t\t attr, cir_exponent, srtcm->cir_exponent);\n+\tMLX5_SET(flow_meter_parameters,\n+\t\t attr, cir_mantissa, srtcm->cir_mantissa);\n+\tMLX5_SET(flow_meter_parameters,\n+\t\t attr, ebs_exponent, srtcm->ebs_exponent);\n+\tMLX5_SET(flow_meter_parameters,\n+\t\t attr, ebs_mantissa, srtcm->ebs_mantissa);\n+\tmtr_init.next_table =\n+\t\tfm->attr.transfer ? fm->mfts->transfer.tbl->obj :\n+\t\t    fm->attr.egress ? fm->mfts->egress.tbl->obj :\n+\t\t\t\t       fm->mfts->ingress.tbl->obj;\n+\tmtr_init.reg_c_index = priv->mtr_color_reg - REG_C_0;\n+\tmtr_init.flow_meter_parameter = fm->mfts->fmp;\n+\tmtr_init.flow_meter_parameter_sz = fm->mfts->fmp_size;\n+\tmtr_init.active = fm->active_state;\n+\treturn mlx5_glue->dv_create_flow_action_meter(&mtr_init);\n+#else\n+\t(void)fm;\n+\treturn NULL;\n+#endif\n+}\n+\n+/**\n  * Find meter profile by id.\n  *\n  * @param priv\n@@ -1080,3 +1135,88 @@ struct mlx5_flow_meter *\n \t\t\treturn fm;\n \treturn NULL;\n }\n+\n+/**\n+ * Attach meter to flow.\n+ * Unidirectional Meter creation can only be done\n+ * when flow direction is known, i.e. when calling meter_attach.\n+ *\n+ * @param [in] priv\n+ *  Pointer to mlx5 private data.\n+ * @param [in] meter_id\n+ *  Flow meter id.\n+ * @param [in] attr\n+ *  Pointer to flow attributes.\n+ * @param [out] error\n+ *  Pointer to error structure.\n+ *\n+ * @return the flow meter pointer, NULL otherwise.\n+ */\n+struct mlx5_flow_meter *\n+mlx5_flow_meter_attach(struct mlx5_priv *priv, uint32_t meter_id,\n+\t\t       const struct rte_flow_attr *attr,\n+\t\t       struct rte_flow_error *error)\n+{\n+\tstruct mlx5_flow_meter *fm;\n+\n+\tfm = mlx5_flow_meter_find(priv, meter_id);\n+\tif (fm == NULL) {\n+\t\trte_flow_error_set(error, ENOENT,\n+\t\t\t\t   RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,\n+\t\t\t\t   \"Meter object id not valid\");\n+\t\tgoto error;\n+\t}\n+\tif (!fm->shared && fm->ref_cnt) {\n+\t\tDRV_LOG(ERR, \"Cannot share a non-shared meter.\");\n+\t\trte_flow_error_set(error, EINVAL,\n+\t\t\t\t  RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,\n+\t\t\t\t  \"Meter can't be shared\");\n+\t\tgoto error;\n+\t}\n+\tif (!fm->ref_cnt++) {\n+\t\tRTE_ASSERT(!fm->mfts->meter_action);\n+\t\tfm->attr = *attr;\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\tgoto error_detach;\n+\t} else {\n+\t\tRTE_ASSERT(fm->mfts->meter_action);\n+\t\tif (attr->transfer != fm->attr.transfer ||\n+\t\t    attr->ingress != fm->attr.ingress ||\n+\t\t    attr->egress != fm->attr.egress) {\n+\t\t\tDRV_LOG(ERR, \"meter I/O attributes do not \"\n+\t\t\t\t\"match flow I/O attributes.\");\n+\t\t\tgoto error_detach;\n+\t\t}\n+\t}\n+\treturn fm;\n+error_detach:\n+\tmlx5_flow_meter_detach(fm);\n+\trte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,\n+\t\t\t  fm->mfts->meter_action ? \"Meter attr not match\" :\n+\t\t\t  \"Meter action create failed\");\n+error:\n+\treturn NULL;\n+}\n+\n+/**\n+ * Detach meter from flow.\n+ *\n+ * @param [in] fm\n+ *  Pointer to flow meter.\n+ */\n+void\n+mlx5_flow_meter_detach(struct mlx5_flow_meter *fm)\n+{\n+\tconst struct rte_flow_attr attr = { 0 };\n+\n+\tRTE_ASSERT(fm->ref_cnt);\n+\tif (--fm->ref_cnt)\n+\t\treturn;\n+\tif (fm->mfts->meter_action)\n+\t\tmlx5_glue->destroy_flow_action(fm->mfts->meter_action);\n+\tfm->mfts->meter_action = NULL;\n+\tfm->attr = attr;\n+}\n",
    "prefixes": [
        "15/19"
    ]
}