get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 44433,
    "url": "http://patches.dpdk.org/api/patches/44433/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/20180907181357.23915-7-jasvinder.singh@intel.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": "<20180907181357.23915-7-jasvinder.singh@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20180907181357.23915-7-jasvinder.singh@intel.com",
    "date": "2018-09-07T18:13:53",
    "name": "[06/10] net/softnic: update meter profile",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "c8f46e02f774b76d4edd7a51c96b1b286aea2345",
    "submitter": {
        "id": 285,
        "url": "http://patches.dpdk.org/api/people/285/?format=api",
        "name": "Jasvinder Singh",
        "email": "jasvinder.singh@intel.com"
    },
    "delegate": {
        "id": 10018,
        "url": "http://patches.dpdk.org/api/users/10018/?format=api",
        "username": "cristian_dumitrescu",
        "first_name": "Cristian",
        "last_name": "Dumitrescu",
        "email": "cristian.dumitrescu@intel.com"
    },
    "mbox": "http://patches.dpdk.org/project/dpdk/patch/20180907181357.23915-7-jasvinder.singh@intel.com/mbox/",
    "series": [
        {
            "id": 1234,
            "url": "http://patches.dpdk.org/api/series/1234/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=1234",
            "date": "2018-09-07T18:13:49",
            "name": "net/softnic: implement metering and policing API",
            "version": 1,
            "mbox": "http://patches.dpdk.org/series/1234/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/44433/comments/",
    "check": "fail",
    "checks": "http://patches.dpdk.org/api/patches/44433/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<dev-bounces@dpdk.org>",
        "X-Original-To": "patchwork@dpdk.org",
        "Delivered-To": "patchwork@dpdk.org",
        "Received": [
            "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id A5FD45F27;\n\tFri,  7 Sep 2018 20:15:13 +0200 (CEST)",
            "from mga05.intel.com (mga05.intel.com [192.55.52.43])\n\tby dpdk.org (Postfix) with ESMTP id BAB495B12\n\tfor <dev@dpdk.org>; Fri,  7 Sep 2018 20:15:05 +0200 (CEST)",
            "from fmsmga005.fm.intel.com ([10.253.24.32])\n\tby fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t07 Sep 2018 11:15:03 -0700",
            "from silpixa00381635.ir.intel.com (HELO\n\tsilpixa00381635.ger.corp.intel.com) ([10.237.222.149])\n\tby fmsmga005.fm.intel.com with ESMTP; 07 Sep 2018 11:14:03 -0700"
        ],
        "X-Amp-Result": "SKIPPED(no attachment in message)",
        "X-Amp-File-Uploaded": "False",
        "X-ExtLoop1": "1",
        "X-IronPort-AV": "E=Sophos;i=\"5.53,343,1531810800\"; d=\"scan'208\";a=\"260757388\"",
        "From": "Jasvinder Singh <jasvinder.singh@intel.com>",
        "To": "dev@dpdk.org",
        "Cc": "cristian.dumitrescu@intel.com",
        "Date": "Fri,  7 Sep 2018 19:13:53 +0100",
        "Message-Id": "<20180907181357.23915-7-jasvinder.singh@intel.com>",
        "X-Mailer": "git-send-email 2.9.3",
        "In-Reply-To": "<20180907181357.23915-1-jasvinder.singh@intel.com>",
        "References": "<20180907181357.23915-1-jasvinder.singh@intel.com>",
        "Subject": "[dpdk-dev] [PATCH 06/10] net/softnic: update meter profile",
        "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\t<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\t<mailto:dev-request@dpdk.org?subject=subscribe>",
        "Errors-To": "dev-bounces@dpdk.org",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>"
    },
    "content": "Implement meter profile update function\n\nSigned-off-by: Jasvinder Singh <jasvinder.singh@intel.com>\n---\n drivers/net/softnic/rte_eth_softnic_internals.h |   5 +\n drivers/net/softnic/rte_eth_softnic_meter.c     | 139 +++++++++++++++++++++++-\n drivers/net/softnic/rte_eth_softnic_pipeline.c  |  12 ++\n 3 files changed, 155 insertions(+), 1 deletion(-)",
    "diff": "diff --git a/drivers/net/softnic/rte_eth_softnic_internals.h b/drivers/net/softnic/rte_eth_softnic_internals.h\nindex 4e2ad56..5995e61 100644\n--- a/drivers/net/softnic/rte_eth_softnic_internals.h\n+++ b/drivers/net/softnic/rte_eth_softnic_internals.h\n@@ -455,6 +455,7 @@ struct softnic_table {\n \tstruct softnic_table_action_profile *ap;\n \tstruct rte_table_action *a;\n \tstruct flow_list flows;\n+\tstruct softnic_mtr_meter_profile_list meter_profiles;\n };\n \n struct pipeline {\n@@ -620,6 +621,10 @@ struct softnic_mtr_meter_profile *\n softnic_mtr_meter_profile_find(struct pmd_internals *p,\n \tuint32_t meter_profile_id);\n \n+struct softnic_mtr_meter_profile *\n+softnic_table_meter_profile_find(struct softnic_table *table,\n+\tuint32_t meter_profile_id);\n+\n extern const struct rte_mtr_ops pmd_mtr_ops;\n \n /**\ndiff --git a/drivers/net/softnic/rte_eth_softnic_meter.c b/drivers/net/softnic/rte_eth_softnic_meter.c\nindex 48ec446..3b05ad6 100644\n--- a/drivers/net/softnic/rte_eth_softnic_meter.c\n+++ b/drivers/net/softnic/rte_eth_softnic_meter.c\n@@ -316,6 +316,143 @@ pmd_mtr_destroy(struct rte_eth_dev *dev,\n \treturn 0;\n }\n \n+struct softnic_mtr_meter_profile *\n+softnic_table_meter_profile_find(struct softnic_table *table,\n+\tuint32_t meter_profile_id)\n+{\n+\tstruct softnic_mtr_meter_profile *mp;\n+\n+\tTAILQ_FOREACH(mp, &table->meter_profiles, node)\n+\t\tif (mp->meter_profile_id == meter_profile_id)\n+\t\t\treturn mp;\n+\n+\treturn NULL;\n+}\n+\n+static int\n+softnic_table_meter_profile_update(struct pmd_internals *p,\n+\tstruct softnic_mtr *mtr,\n+\tuint32_t meter_profile_id,\n+\tstruct rte_mtr_meter_profile *params,\n+\tstruct rte_mtr_error *error)\n+{\n+\tstruct rte_flow *mflow = mtr->flow;\n+\tstruct softnic_table *table = &mflow->pipeline->table[mflow->table_id];\n+\tstruct softnic_mtr_meter_profile *mp;\n+\tint status, mp_mem_alloc = 0;\n+\n+\t/* Find/allocate meter profile for table */\n+\tif (!softnic_table_meter_profile_find(table, meter_profile_id)) {\n+\t\tmp = calloc(1, sizeof(struct softnic_mtr_meter_profile));\n+\t\tif (mp == NULL) {\n+\t\t\trte_mtr_error_set(error,\n+\t\t\t\tENOMEM,\n+\t\t\t\tRTE_MTR_ERROR_TYPE_UNSPECIFIED,\n+\t\t\t\tNULL,\n+\t\t\t\t\"Not enough table memory for meter profile\");\n+\t\t\treturn -1;\n+\t\t}\n+\t\tmp_mem_alloc = 1;\n+\n+\t\t/* Fill in */\n+\t\tmp->meter_profile_id = meter_profile_id;\n+\t\tmemcpy(&mp->params, params, sizeof(mp->params));\n+\n+\t\t/* Add to list */\n+\t\tTAILQ_INSERT_TAIL(&table->meter_profiles, mp, node);\n+\t}\n+\n+\t/* Update meter action */\n+\tmflow->action.mtr.mtr[0].meter_profile_id = meter_profile_id;\n+\n+\t/* Re-add new rule */\n+\tstatus = softnic_pipeline_table_rule_add(p,\n+\t\tmflow->pipeline->name,\n+\t\tmflow->table_id,\n+\t\t&mflow->match,\n+\t\t&mflow->action,\n+\t\t&mflow->data);\n+\tif (status) {\n+\t\tif (mp_mem_alloc)\n+\t\t\tfree(mp);\n+\n+\t\trte_mtr_error_set(error,\n+\t\t\tEINVAL,\n+\t\t\tRTE_MTR_ERROR_TYPE_UNSPECIFIED,\n+\t\t\tNULL,\n+\t\t\t\"Pipeline table rule add failed\");\n+\t\treturn -1;\n+\t}\n+\n+\treturn 0;\n+}\n+\n+/* MTR object meter profile update */\n+static int\n+pmd_mtr_meter_profile_update(struct rte_eth_dev *dev,\n+\tuint32_t mtr_id,\n+\tuint32_t meter_profile_id,\n+\tstruct rte_mtr_error *error)\n+{\n+\tstruct pmd_internals *p = dev->data->dev_private;\n+\tstruct softnic_mtr_meter_profile *mp, *mp_old;\n+\tstruct softnic_mtr *m;\n+\tint status;\n+\n+\t/* MTR object id must be valid */\n+\tm = softnic_mtr_find(p, mtr_id);\n+\tif (m == NULL)\n+\t\treturn -rte_mtr_error_set(error,\n+\t\t\tEEXIST,\n+\t\t\tRTE_MTR_ERROR_TYPE_MTR_ID,\n+\t\t\tNULL,\n+\t\t\trte_strerror(EEXIST));\n+\n+\t/* Meter profile id must be valid */\n+\tmp = softnic_mtr_meter_profile_find(p, meter_profile_id);\n+\tif (mp == NULL)\n+\t\treturn -rte_mtr_error_set(error,\n+\t\t\tEINVAL,\n+\t\t\tRTE_MTR_ERROR_TYPE_METER_PROFILE_ID,\n+\t\t\tNULL,\n+\t\t\trte_strerror(EINVAL));\n+\n+\t/* MTR object already set to meter profile id */\n+\tif (m->params.meter_profile_id == meter_profile_id)\n+\t\treturn 0;\n+\n+\tm->params.meter_profile_id = meter_profile_id;\n+\n+\t/* Update dependencies */\n+\tmp_old = softnic_mtr_meter_profile_find(p, m->params.meter_profile_id);\n+\tif (mp_old == NULL)\n+\t\treturn -rte_mtr_error_set(error,\n+\t\t\tEINVAL,\n+\t\t\tRTE_MTR_ERROR_TYPE_METER_PROFILE_ID,\n+\t\t\tNULL,\n+\t\t\trte_strerror(EINVAL));\n+\n+\tmp_old->n_users--;\n+\tmp->n_users++;\n+\n+\t/*  MTR object owner table update */\n+\tif (m->flow) {\n+\t\tstatus = softnic_table_meter_profile_update(p,\n+\t\t\t\tm,\n+\t\t\t\tmeter_profile_id,\n+\t\t\t\t&mp->params,\n+\t\t\t\terror);\n+\t\tif (status)\n+\t\t\treturn -rte_mtr_error_set(error,\n+\t\t\t\tEINVAL,\n+\t\t\t\tRTE_MTR_ERROR_TYPE_UNSPECIFIED,\n+\t\t\t\tNULL,\n+\t\t\t\trte_strerror(EINVAL));\n+\t}\n+\n+\treturn 0;\n+}\n+\n const struct rte_mtr_ops pmd_mtr_ops = {\n \t.capabilities_get = NULL,\n \n@@ -327,7 +464,7 @@ const struct rte_mtr_ops pmd_mtr_ops = {\n \t.meter_enable = NULL,\n \t.meter_disable = NULL,\n \n-\t.meter_profile_update = NULL,\n+\t.meter_profile_update = pmd_mtr_meter_profile_update,\n \t.meter_dscp_table_update = NULL,\n \t.policer_actions_update = NULL,\n \t.stats_update = NULL,\ndiff --git a/drivers/net/softnic/rte_eth_softnic_pipeline.c b/drivers/net/softnic/rte_eth_softnic_pipeline.c\nindex d1084ea..77911bb 100644\n--- a/drivers/net/softnic/rte_eth_softnic_pipeline.c\n+++ b/drivers/net/softnic/rte_eth_softnic_pipeline.c\n@@ -56,6 +56,17 @@ softnic_pipeline_table_free(struct softnic_table *table)\n \t\tTAILQ_REMOVE(&table->flows, flow, node);\n \t\tfree(flow);\n \t}\n+\n+\tfor ( ; ; ) {\n+\t\tstruct softnic_mtr_meter_profile *mp;\n+\n+\t\tmp = TAILQ_FIRST(&table->meter_profiles);\n+\t\tif (mp == NULL)\n+\t\t\tbreak;\n+\n+\t\tTAILQ_REMOVE(&table->meter_profiles, mp, node);\n+\t\tfree(mp);\n+\t}\n }\n \n void\n@@ -989,6 +1000,7 @@ softnic_pipeline_table_create(struct pmd_internals *softnic,\n \ttable->ap = ap;\n \ttable->a = action;\n \tTAILQ_INIT(&table->flows);\n+\tTAILQ_INIT(&table->meter_profiles);\n \tpipeline->n_tables++;\n \n \treturn 0;\n",
    "prefixes": [
        "06/10"
    ]
}