get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 62558,
    "url": "http://patches.dpdk.org/api/patches/62558/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/1573053090-179521-11-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-11-git-send-email-suanmingm@mellanox.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/1573053090-179521-11-git-send-email-suanmingm@mellanox.com",
    "date": "2019-11-06T15:11:19",
    "name": "[10/19] net/mlx5: support meter modification operations",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "90d7b5810a01966b10b9939b6870b2d3faf799da",
    "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-11-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/62558/comments/",
    "check": "fail",
    "checks": "http://patches.dpdk.org/api/patches/62558/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 29473A04AB;\n\tWed,  6 Nov 2019 16:13:23 +0100 (CET)",
            "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id 40B0D1C298;\n\tWed,  6 Nov 2019 16:12:17 +0100 (CET)",
            "from git-send-mailer.rdmz.labs.mlnx (unknown [37.142.13.130])\n by dpdk.org (Postfix) with ESMTP id 32D1F1C195\n for <dev@dpdk.org>; Wed,  6 Nov 2019 16:11:59 +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:19 +0200",
        "Message-Id": "<1573053090-179521-11-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 10/19] net/mlx5: support meter modification\n\toperations",
        "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 add meter enable and disable supoort.\n\nNew internal functions in rte_mtr_ops callback:\n1. meter_enable()\n2. meter_disable()\n\nThe meter_enable() enables the meter action and the meter_disable()\ndisables the meter action.\n\nSigned-off-by: Suanming Mou <suanmingm@mellanox.com>\n---\n drivers/net/mlx5/mlx5_flow.h       |  10 ++\n drivers/net/mlx5/mlx5_flow_meter.c | 232 ++++++++++++++++++++++++++++++++++++-\n drivers/net/mlx5/mlx5_prm.h        |  32 +++++\n 3 files changed, 272 insertions(+), 2 deletions(-)",
    "diff": "diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h\nindex e7bd787..c613019 100644\n--- a/drivers/net/mlx5/mlx5_flow.h\n+++ b/drivers/net/mlx5/mlx5_flow.h\n@@ -523,6 +523,10 @@ struct mlx5_flow {\n \tbool external; /**< true if the flow is created external to PMD. */\n };\n \n+/* Flow meter state. */\n+#define MLX5_FLOW_METER_DISABLE 0\n+#define MLX5_FLOW_METER_ENABLE 1\n+\n #define MLX5_MAN_WIDTH 8\n /* Modify this value if enum rte_mtr_color changes. */\n #define RTE_MTR_DROPPED RTE_COLORS\n@@ -553,6 +557,12 @@ struct mlx5_meter_domains_infos {\n \t/**< FDB meter table. */\n \tvoid *drop_actn;\n \t/**< Drop action as not matched. */\n+\tuint32_t fmp[MLX5_ST_SZ_DW(flow_meter_parameters)];\n+\t/**< Flow meter parameter. */\n+\tsize_t fmp_size;\n+\t/**< Flow meter parameter size. */\n+\tvoid *meter_action;\n+\t/**< Flow meter action. */\n };\n \n /* Meter parameter structure. */\ndiff --git a/drivers/net/mlx5/mlx5_flow_meter.c b/drivers/net/mlx5/mlx5_flow_meter.c\nindex 76a3180..7efb669 100644\n--- a/drivers/net/mlx5/mlx5_flow_meter.c\n+++ b/drivers/net/mlx5/mlx5_flow_meter.c\n@@ -443,6 +443,102 @@\n }\n \n /**\n+ * Modify the flow meter action.\n+ *\n+ * @param[in] priv\n+ *   Pointer to mlx5 private data structure.\n+ * @param[in] fm\n+ *   Pointer to flow meter to be modified.\n+ * @param[in] srtcm\n+ *   Pointer to meter srtcm description parameter.\n+ * @param[in] modify_bits\n+ *   The bit in srtcm to be updated.\n+ * @param[in] active_state\n+ *   The state to be updated.\n+ * @return\n+ *   0 on success, o negative value otherwise.\n+ */\n+static int\n+mlx5_flow_meter_action_modify(struct mlx5_priv *priv,\n+\t\tstruct mlx5_flow_meter *fm,\n+\t\tconst struct mlx5_flow_meter_srtcm_rfc2697_prm *srtcm,\n+\t\tuint64_t modify_bits, uint32_t active_state)\n+{\n+#ifdef HAVE_MLX5_DR_CREATE_ACTION_FLOW_METER\n+\tuint32_t in[MLX5_ST_SZ_DW(flow_meter_parameters)] = { 0 };\n+\tuint32_t *attr;\n+\tstruct mlx5dv_dr_flow_meter_attr mod_attr = { 0 };\n+\tint ret;\n+\n+\t/* Fill command parameters. */\n+\tmod_attr.reg_c_index = priv->mtr_color_reg - REG_C_0;\n+\tmod_attr.flow_meter_parameter = in;\n+\tmod_attr.flow_meter_parameter_sz = fm->mfts->fmp_size;\n+\tif (modify_bits & MLX5_FLOW_METER_OBJ_MODIFY_FIELD_ACTIVE)\n+\t\tmod_attr.active = !!active_state;\n+\telse\n+\t\tmod_attr.active = 0;\n+\tattr = in;\n+\tif (modify_bits & MLX5_FLOW_METER_OBJ_MODIFY_FIELD_CBS) {\n+\t\tMLX5_SET(flow_meter_parameters,\n+\t\t\t attr, cbs_exponent, srtcm->cbs_exponent);\n+\t\tMLX5_SET(flow_meter_parameters,\n+\t\t\t attr, cbs_mantissa, srtcm->cbs_mantissa);\n+\t}\n+\tif (modify_bits & MLX5_FLOW_METER_OBJ_MODIFY_FIELD_CIR) {\n+\t\tMLX5_SET(flow_meter_parameters,\n+\t\t\t attr, cir_exponent, srtcm->cir_exponent);\n+\t\tMLX5_SET(flow_meter_parameters,\n+\t\t\t attr, cir_mantissa, srtcm->cir_mantissa);\n+\t}\n+\tif (modify_bits & MLX5_FLOW_METER_OBJ_MODIFY_FIELD_EBS) {\n+\t\tMLX5_SET(flow_meter_parameters,\n+\t\t\t attr, ebs_exponent, srtcm->ebs_exponent);\n+\t\tMLX5_SET(flow_meter_parameters,\n+\t\t\t attr, ebs_mantissa, srtcm->ebs_mantissa);\n+\t}\n+\t/* Apply modifications to meter only if it was created. */\n+\tif (fm->mfts->meter_action) {\n+\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\trte_cpu_to_be_64(modify_bits));\n+\t\tif (ret)\n+\t\t\treturn ret;\n+\t}\n+\t/* Update succeedded modify meter parameters. */\n+\tif (modify_bits & MLX5_FLOW_METER_OBJ_MODIFY_FIELD_ACTIVE)\n+\t\tfm->active_state = !!active_state;\n+\tattr = fm->mfts->fmp;\n+\tif (modify_bits & MLX5_FLOW_METER_OBJ_MODIFY_FIELD_CBS) {\n+\t\tMLX5_SET(flow_meter_parameters,\n+\t\t\t attr, cbs_exponent, srtcm->cbs_exponent);\n+\t\tMLX5_SET(flow_meter_parameters,\n+\t\t\t attr, cbs_mantissa, srtcm->cbs_mantissa);\n+\t}\n+\tif (modify_bits & MLX5_FLOW_METER_OBJ_MODIFY_FIELD_CIR) {\n+\t\tMLX5_SET(flow_meter_parameters,\n+\t\t\t attr, cir_exponent, srtcm->cir_exponent);\n+\t\tMLX5_SET(flow_meter_parameters,\n+\t\t\t attr, cir_mantissa, srtcm->cir_mantissa);\n+\t}\n+\tif (modify_bits & MLX5_FLOW_METER_OBJ_MODIFY_FIELD_EBS) {\n+\t\tMLX5_SET(flow_meter_parameters,\n+\t\t\t attr, ebs_exponent, srtcm->ebs_exponent);\n+\t\tMLX5_SET(flow_meter_parameters,\n+\t\t\t attr, ebs_mantissa, srtcm->ebs_mantissa);\n+\t}\n+\n+\treturn 0;\n+#else\n+\t(void)fm;\n+\t(void)srtcm;\n+\t(void)modify_bits;\n+\t(void)active_state;\n+\treturn -ENOTSUP;\n+#endif\n+}\n+\n+/**\n  * Create meter rules.\n  *\n  * @param[in] dev\n@@ -577,14 +673,146 @@\n \treturn 0;\n }\n \n+/**\n+ * Modify meter state.\n+ *\n+ * @param[in] priv\n+ *   Pointer to mlx5 private data structure.\n+ * @param[in] fm\n+ *   Pointer to flow meter.\n+ * @param[in] new_state\n+ *   New state to update.\n+ * @param[out] error\n+ *   Pointer to rte meter error structure.\n+ *\n+ * @return\n+ *   0 on success, a negative errno value otherwise and rte_errno is set.\n+ */\n+static int\n+mlx5_flow_meter_modify_state(struct mlx5_priv *priv,\n+\t\t\t     struct mlx5_flow_meter *fm,\n+\t\t\t     uint32_t new_state,\n+\t\t\t     struct rte_mtr_error *error)\n+{\n+\tstatic const struct mlx5_flow_meter_srtcm_rfc2697_prm srtcm = {\n+\t\t.cbs_exponent = 20,\n+\t\t.cbs_mantissa = 191,\n+\t\t.cir_exponent = 0,\n+\t\t.cir_mantissa = 200,\n+\t\t.ebs_exponent = 0,\n+\t\t.ebs_mantissa = 0,\n+\t};\n+\tuint64_t modify_bits = MLX5_FLOW_METER_OBJ_MODIFY_FIELD_CBS |\n+\t\t\t       MLX5_FLOW_METER_OBJ_MODIFY_FIELD_CIR;\n+\tint ret;\n+\n+\tif (new_state == MLX5_FLOW_METER_DISABLE)\n+\t\tret = mlx5_flow_meter_action_modify(priv, fm, &srtcm,\n+\t\t\t\t\t\t    modify_bits, 0);\n+\telse\n+\t\tret = mlx5_flow_meter_action_modify(priv, fm,\n+\t\t\t\t\t\t   &fm->profile->srtcm_prm,\n+\t\t\t\t\t\t    modify_bits, 0);\n+\tif (ret)\n+\t\treturn -rte_mtr_error_set(error, -ret,\n+\t\t\t\t\t  RTE_MTR_ERROR_TYPE_MTR_PARAMS,\n+\t\t\t\t\t  NULL,\n+\t\t\t\t\t  new_state ?\n+\t\t\t\t\t  \"Failed to enable meter.\" :\n+\t\t\t\t\t  \"Failed to disable meter.\");\n+\treturn 0;\n+}\n+\n+/**\n+ * Callback to enable flow meter.\n+ *\n+ * @param[in] dev\n+ *   Pointer to Ethernet device.\n+ * @param[in] meter_id\n+ *   Meter id.\n+ * @param[out] error\n+ *   Pointer to rte meter error structure.\n+ *\n+ * @return\n+ *   0 on success, a negative errno value otherwise and rte_errno is set.\n+ */\n+static int\n+mlx5_flow_meter_enable(struct rte_eth_dev *dev,\n+\t\t       uint32_t meter_id,\n+\t\t       struct rte_mtr_error *error)\n+{\n+\tstruct mlx5_priv *priv = dev->data->dev_private;\n+\tstruct mlx5_flow_meter *fm;\n+\tint ret;\n+\n+\tif (!priv->mtr_en)\n+\t\treturn -rte_mtr_error_set(error, ENOTSUP,\n+\t\t\t\t\t  RTE_MTR_ERROR_TYPE_UNSPECIFIED, NULL,\n+\t\t\t\t\t  \"Meter is not support\");\n+\t/* Meter object must exist. */\n+\tfm = mlx5_flow_meter_find(priv, meter_id);\n+\tif (fm == NULL)\n+\t\treturn -rte_mtr_error_set(error, ENOENT,\n+\t\t\t\t\t  RTE_MTR_ERROR_TYPE_MTR_ID,\n+\t\t\t\t\t  NULL, \"Meter not found.\");\n+\tif (fm->active_state == MLX5_FLOW_METER_ENABLE)\n+\t\treturn 0;\n+\tret = mlx5_flow_meter_modify_state(priv, fm, MLX5_FLOW_METER_ENABLE,\n+\t\t\t\t\t   error);\n+\tif (!ret)\n+\t\tfm->active_state = MLX5_FLOW_METER_ENABLE;\n+\treturn ret;\n+}\n+\n+/**\n+ * Callback to disable flow meter.\n+ *\n+ * @param[in] dev\n+ *   Pointer to Ethernet device.\n+ * @param[in] meter_id\n+ *   Meter id.\n+ * @param[out] error\n+ *   Pointer to rte meter error structure.\n+ *\n+ * @return\n+ *   0 on success, a negative errno value otherwise and rte_errno is set.\n+ */\n+static int\n+mlx5_flow_meter_disable(struct rte_eth_dev *dev,\n+\t\t\tuint32_t meter_id,\n+\t\t\tstruct rte_mtr_error *error)\n+{\n+\tstruct mlx5_priv *priv = dev->data->dev_private;\n+\tstruct mlx5_flow_meter *fm;\n+\tint ret;\n+\n+\tif (!priv->mtr_en)\n+\t\treturn -rte_mtr_error_set(error, ENOTSUP,\n+\t\t\t\t\t  RTE_MTR_ERROR_TYPE_UNSPECIFIED, NULL,\n+\t\t\t\t\t  \"Meter is not support\");\n+\t/* Meter object must exist. */\n+\tfm = mlx5_flow_meter_find(priv, meter_id);\n+\tif (fm == NULL)\n+\t\treturn -rte_mtr_error_set(error, ENOENT,\n+\t\t\t\t\t  RTE_MTR_ERROR_TYPE_MTR_ID,\n+\t\t\t\t\t  NULL, \"Meter not found.\");\n+\tif (fm->active_state == MLX5_FLOW_METER_DISABLE)\n+\t\treturn 0;\n+\tret = mlx5_flow_meter_modify_state(priv, fm, MLX5_FLOW_METER_DISABLE,\n+\t\t\t\t\t   error);\n+\tif (!ret)\n+\t\tfm->active_state = MLX5_FLOW_METER_DISABLE;\n+\treturn ret;\n+}\n+\n static const struct rte_mtr_ops mlx5_flow_mtr_ops = {\n \t.capabilities_get = mlx5_flow_mtr_cap_get,\n \t.meter_profile_add = mlx5_flow_meter_profile_add,\n \t.meter_profile_delete = mlx5_flow_meter_profile_delete,\n \t.create = mlx5_flow_meter_create,\n \t.destroy = mlx5_flow_meter_destroy,\n-\t.meter_enable = NULL,\n-\t.meter_disable = NULL,\n+\t.meter_enable = mlx5_flow_meter_enable,\n+\t.meter_disable = mlx5_flow_meter_disable,\n \t.meter_profile_update = NULL,\n \t.meter_dscp_table_update = NULL,\n \t.policer_actions_update = NULL,\ndiff --git a/drivers/net/mlx5/mlx5_prm.h b/drivers/net/mlx5/mlx5_prm.h\nindex ebedc90..651006b 100644\n--- a/drivers/net/mlx5/mlx5_prm.h\n+++ b/drivers/net/mlx5/mlx5_prm.h\n@@ -1745,6 +1745,38 @@ struct mlx5_ifc_create_sq_in_bits {\n \tstruct mlx5_ifc_sqc_bits ctx;\n };\n \n+enum {\n+\tMLX5_FLOW_METER_OBJ_MODIFY_FIELD_ACTIVE = (1ULL << 0),\n+\tMLX5_FLOW_METER_OBJ_MODIFY_FIELD_CBS = (1ULL << 1),\n+\tMLX5_FLOW_METER_OBJ_MODIFY_FIELD_CIR = (1ULL << 2),\n+\tMLX5_FLOW_METER_OBJ_MODIFY_FIELD_EBS = (1ULL << 3),\n+\tMLX5_FLOW_METER_OBJ_MODIFY_FIELD_EIR = (1ULL << 4),\n+};\n+\n+struct mlx5_ifc_flow_meter_parameters_bits {\n+\tu8         valid[0x1];\t\t\t// 00h\n+\tu8         bucket_overflow[0x1];\n+\tu8         start_color[0x2];\n+\tu8         both_buckets_on_green[0x1];\n+\tu8         meter_mode[0x2];\n+\tu8         reserved_at_1[0x19];\n+\tu8         reserved_at_2[0x20]; //04h\n+\tu8         reserved_at_3[0x3];\n+\tu8         cbs_exponent[0x5];\t\t// 08h\n+\tu8         cbs_mantissa[0x8];\n+\tu8         reserved_at_4[0x3];\n+\tu8         cir_exponent[0x5];\n+\tu8         cir_mantissa[0x8];\n+\tu8         reserved_at_5[0x20];\t\t// 0Ch\n+\tu8         reserved_at_6[0x3];\n+\tu8         ebs_exponent[0x5];\t\t// 10h\n+\tu8         ebs_mantissa[0x8];\n+\tu8         reserved_at_7[0x3];\n+\tu8         eir_exponent[0x5];\n+\tu8         eir_mantissa[0x8];\n+\tu8         reserved_at_8[0x60];\t\t// 14h-1Ch\n+};\n+\n /* CQE format mask. */\n #define MLX5E_CQE_FORMAT_MASK 0xc\n \n",
    "prefixes": [
        "10/19"
    ]
}