get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 44741,
    "url": "http://patches.dpdk.org/api/patches/44741/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/20180914174554.90135-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": "<20180914174554.90135-7-jasvinder.singh@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20180914174554.90135-7-jasvinder.singh@intel.com",
    "date": "2018-09-14T17:45:50",
    "name": "[v3,06/10] net/softnic: update meter profile",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "0cf1ad11905533ec587de1f4d5abd4c09073c99b",
    "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/20180914174554.90135-7-jasvinder.singh@intel.com/mbox/",
    "series": [
        {
            "id": 1328,
            "url": "http://patches.dpdk.org/api/series/1328/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=1328",
            "date": "2018-09-14T17:45:44",
            "name": "net/softnic: implement metering and policing API",
            "version": 3,
            "mbox": "http://patches.dpdk.org/series/1328/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/44741/comments/",
    "check": "fail",
    "checks": "http://patches.dpdk.org/api/patches/44741/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 E84DC6CC7;\n\tFri, 14 Sep 2018 19:46:23 +0200 (CEST)",
            "from mga14.intel.com (mga14.intel.com [192.55.52.115])\n\tby dpdk.org (Postfix) with ESMTP id F30165F2C\n\tfor <dev@dpdk.org>; Fri, 14 Sep 2018 19:46:11 +0200 (CEST)",
            "from orsmga008.jf.intel.com ([10.7.209.65])\n\tby fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t14 Sep 2018 10:46:08 -0700",
            "from silpixa00381635.ir.intel.com (HELO\n\tsilpixa00381635.ger.corp.intel.com) ([10.237.222.149])\n\tby orsmga008.jf.intel.com with ESMTP; 14 Sep 2018 10:45:59 -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,374,1531810800\"; d=\"scan'208\";a=\"73280017\"",
        "From": "Jasvinder Singh <jasvinder.singh@intel.com>",
        "To": "dev@dpdk.org",
        "Cc": "cristian.dumitrescu@intel.com",
        "Date": "Fri, 14 Sep 2018 18:45:50 +0100",
        "Message-Id": "<20180914174554.90135-7-jasvinder.singh@intel.com>",
        "X-Mailer": "git-send-email 2.9.3",
        "In-Reply-To": "<20180914174554.90135-1-jasvinder.singh@intel.com>",
        "References": "<20180912164138.55800-2-jasvinder.singh@intel.com>\n\t<20180914174554.90135-1-jasvinder.singh@intel.com>",
        "Subject": "[dpdk-dev] [PATCH v3 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 |  14 ++++\n drivers/net/softnic/rte_eth_softnic_meter.c     | 103 +++++++++++++++++++++++-\n drivers/net/softnic/rte_eth_softnic_pipeline.c  |  25 ++++++\n drivers/net/softnic/rte_eth_softnic_thread.c    |  23 ++++++\n 4 files changed, 164 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 50b7295..4b0f54c 100644\n--- a/drivers/net/softnic/rte_eth_softnic_internals.h\n+++ b/drivers/net/softnic/rte_eth_softnic_internals.h\n@@ -320,6 +320,15 @@ struct softnic_table_action_profile {\n \n TAILQ_HEAD(softnic_table_action_profile_list, softnic_table_action_profile);\n \n+struct softnic_table_meter_profile {\n+\tTAILQ_ENTRY(softnic_table_meter_profile) node;\n+\tuint32_t meter_profile_id;\n+\tstruct rte_table_action_meter_profile profile;\n+};\n+\n+TAILQ_HEAD(softnic_table_meter_profile_list,\n+\tsoftnic_table_meter_profile);\n+\n /**\n  * Pipeline\n  */\n@@ -455,6 +464,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_table_meter_profile_list meter_profiles;\n };\n \n struct pipeline {\n@@ -813,6 +823,10 @@ softnic_pipeline_table_create(struct pmd_internals *p,\n \tconst char *pipeline_name,\n \tstruct softnic_table_params *params);\n \n+struct softnic_table_meter_profile *\n+softnic_pipeline_table_meter_profile_find(struct softnic_table *table,\n+\tuint32_t meter_profile_id);\n+\n struct softnic_table_rule_match_acl {\n \tint ip_version;\n \ndiff --git a/drivers/net/softnic/rte_eth_softnic_meter.c b/drivers/net/softnic/rte_eth_softnic_meter.c\nindex 5103bda..5ce5037 100644\n--- a/drivers/net/softnic/rte_eth_softnic_meter.c\n+++ b/drivers/net/softnic/rte_eth_softnic_meter.c\n@@ -332,6 +332,107 @@ pmd_mtr_destroy(struct rte_eth_dev *dev,\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 *mp0, *mp1;\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\t\"MTR object id not valid\");\n+\n+\t/* Meter profile id must be valid */\n+\tmp0 = softnic_mtr_meter_profile_find(p, meter_profile_id);\n+\tif (mp0 == 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\t\"Meter profile not valid\");\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+\t/*  MTR object owner table update */\n+\tif (m->flow) {\n+\t\tuint32_t table_id = m->flow->table_id;\n+\t\tstruct softnic_table *table = &m->flow->pipeline->table[table_id];\n+\t\tstruct softnic_table_rule_action action;\n+\n+\t\tif (!softnic_pipeline_table_meter_profile_find(table,\n+\t\t\tmeter_profile_id)) {\n+\t\t\tstruct rte_table_action_meter_profile profile;\n+\n+\t\t\tmemset(&profile, 0, sizeof(profile));\n+\n+\t\t\tprofile.alg = RTE_TABLE_ACTION_METER_TRTCM;\n+\t\t\tprofile.trtcm.cir = mp0->params.trtcm_rfc2698.cir;\n+\t\t\tprofile.trtcm.pir = mp0->params.trtcm_rfc2698.pir;\n+\t\t\tprofile.trtcm.cbs = mp0->params.trtcm_rfc2698.cbs;\n+\t\t\tprofile.trtcm.pbs = mp0->params.trtcm_rfc2698.pbs;\n+\n+\t\t\t/* Add meter profile to pipeline table */\n+\t\t\tstatus = softnic_pipeline_table_mtr_profile_add(p,\n+\t\t\t\t\tm->flow->pipeline->name,\n+\t\t\t\t\ttable_id,\n+\t\t\t\t\tmeter_profile_id,\n+\t\t\t\t\t&profile);\n+\t\t\tif (status)\n+\t\t\t\treturn -rte_mtr_error_set(error,\n+\t\t\t\t\tEINVAL,\n+\t\t\t\t\tRTE_MTR_ERROR_TYPE_UNSPECIFIED,\n+\t\t\t\t\tNULL,\n+\t\t\t\t\t\"Table meter profile add failed\");\n+\t\t}\n+\n+\t\t/* Set meter action */\n+\t\tmemcpy(&action, &m->flow->action, sizeof(action));\n+\n+\t\taction.mtr.mtr[0].meter_profile_id = meter_profile_id;\n+\n+\t\t/* Re-add rule */\n+\t\tstatus = softnic_pipeline_table_rule_add(p,\n+\t\t\tm->flow->pipeline->name,\n+\t\t\ttable_id,\n+\t\t\t&m->flow->match,\n+\t\t\t&action,\n+\t\t\t&m->flow->data);\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\t\"Pipeline table rule add failed\");\n+\n+\t\t/* Flow: update meter action */\n+\t\tmemcpy(&m->flow->action, &action, sizeof(m->flow->action));\n+\t}\n+\n+\tmp1 = softnic_mtr_meter_profile_find(p, m->params.meter_profile_id);\n+\n+\t/* Meter: Set meter profile */\n+\tm->params.meter_profile_id = meter_profile_id;\n+\n+\t/* Update dependencies*/\n+\tmp1->n_users--;\n+\tmp0->n_users++;\n+\n+\treturn 0;\n+}\n+\n const struct rte_mtr_ops pmd_mtr_ops = {\n \t.capabilities_get = NULL,\n \n@@ -343,7 +444,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 d1127a1..9c544f4 100644\n--- a/drivers/net/softnic/rte_eth_softnic_pipeline.c\n+++ b/drivers/net/softnic/rte_eth_softnic_pipeline.c\n@@ -55,6 +55,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_table_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@@ -988,6 +999,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@@ -1020,3 +1032,16 @@ softnic_pipeline_port_out_find(struct pmd_internals *softnic,\n \n \treturn -1;\n }\n+\n+struct softnic_table_meter_profile *\n+softnic_pipeline_table_meter_profile_find(struct softnic_table *table,\n+\tuint32_t meter_profile_id)\n+{\n+\tstruct softnic_table_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\\ No newline at end of file\ndiff --git a/drivers/net/softnic/rte_eth_softnic_thread.c b/drivers/net/softnic/rte_eth_softnic_thread.c\nindex 8a15090..df61832 100644\n--- a/drivers/net/softnic/rte_eth_softnic_thread.c\n+++ b/drivers/net/softnic/rte_eth_softnic_thread.c\n@@ -1680,6 +1680,7 @@ softnic_pipeline_table_mtr_profile_add(struct pmd_internals *softnic,\n \tstruct pipeline *p;\n \tstruct pipeline_msg_req *req;\n \tstruct pipeline_msg_rsp *rsp;\n+\tstruct softnic_table_meter_profile *mp;\n \tint status;\n \n \t/* Check input params */\n@@ -1692,12 +1693,25 @@ softnic_pipeline_table_mtr_profile_add(struct pmd_internals *softnic,\n \t\ttable_id >= p->n_tables)\n \t\treturn -1;\n \n+\t/* Resource Allocation */\n+\tmp = calloc(1, sizeof(struct softnic_table_meter_profile));\n+\tif (mp == NULL)\n+\t\treturn -1;\n+\n \tif (!pipeline_is_running(p)) {\n \t\tstruct rte_table_action *a = p->table[table_id].a;\n \n \t\tstatus = rte_table_action_meter_profile_add(a,\n \t\t\tmeter_profile_id,\n \t\t\tprofile);\n+\t\tif (status)\n+\t\t\tfree(mp);\n+\t\telse {\n+\t\t\t/* Add profile to the list */\n+\t\t\tmp->meter_profile_id = meter_profile_id;\n+\t\t\tmemcpy(&mp->profile, &profile, sizeof(mp->profile));\n+\t\t\tTAILQ_INSERT_TAIL(&p->table[table_id].meter_profiles, mp, node);\n+\t\t}\n \n \t\treturn status;\n \t}\n@@ -1721,6 +1735,15 @@ softnic_pipeline_table_mtr_profile_add(struct pmd_internals *softnic,\n \t/* Read response */\n \tstatus = rsp->status;\n \n+\tif (status)\n+\t\tfree(mp);\n+\telse {\n+\t\t/* Add profile to the list */\n+\t\tmp->meter_profile_id = meter_profile_id;\n+\t\tmemcpy(&mp->profile, &profile, sizeof(mp->profile));\n+\t\tTAILQ_INSERT_TAIL(&p->table[table_id].meter_profiles, mp, node);\n+\t}\n+\n \t/* Free response */\n \tpipeline_msg_free(rsp);\n \n",
    "prefixes": [
        "v3",
        "06/10"
    ]
}