get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 44438,
    "url": "http://patches.dpdk.org/api/patches/44438/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/20180907181357.23915-11-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-11-jasvinder.singh@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20180907181357.23915-11-jasvinder.singh@intel.com",
    "date": "2018-09-07T18:13:57",
    "name": "[10/10] net/softnic: enable meter action using flow rule",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "09687a377a303e90b9b2157ceaf243af62e7c337",
    "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-11-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/44438/comments/",
    "check": "fail",
    "checks": "http://patches.dpdk.org/api/patches/44438/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 CAB286CC3;\n\tFri,  7 Sep 2018 20:15:19 +0200 (CEST)",
            "from mga05.intel.com (mga05.intel.com [192.55.52.43])\n\tby dpdk.org (Postfix) with ESMTP id 105285B12\n\tfor <dev@dpdk.org>; Fri,  7 Sep 2018 20:15:06 +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:07 -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=\"260757401\"",
        "From": "Jasvinder Singh <jasvinder.singh@intel.com>",
        "To": "dev@dpdk.org",
        "Cc": "cristian.dumitrescu@intel.com",
        "Date": "Fri,  7 Sep 2018 19:13:57 +0100",
        "Message-Id": "<20180907181357.23915-11-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 10/10] net/softnic: enable meter action using\n\tflow rule",
        "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 enablement through flow rules.\n\nSigned-off-by: Jasvinder Singh <jasvinder.singh@intel.com>\n---\n drivers/net/softnic/rte_eth_softnic_flow.c | 170 +++++++++++++++++++++++++++++\n 1 file changed, 170 insertions(+)",
    "diff": "diff --git a/drivers/net/softnic/rte_eth_softnic_flow.c b/drivers/net/softnic/rte_eth_softnic_flow.c\nindex 6562004..0f33381 100644\n--- a/drivers/net/softnic/rte_eth_softnic_flow.c\n+++ b/drivers/net/softnic/rte_eth_softnic_flow.c\n@@ -1459,6 +1459,117 @@ flow_rule_action_get(struct pmd_internals *softnic,\n \t\t\tbreak;\n \t\t} /* RTE_FLOW_ACTION_TYPE_COUNT */\n \n+\t\tcase RTE_FLOW_ACTION_TYPE_METER:\n+\t\t{\n+\t\t\tstruct rte_table_action_mtr_tc_params mtr_tc_params;\n+\t\t\tconst struct rte_flow_action_meter *conf = action->conf;\n+\t\t\tstruct softnic_mtr *m;\n+\t\t\tstruct softnic_mtr_meter_profile *mp;\n+\t\t\tuint32_t meter_profile_id;\n+\n+\t\t\tif (conf == NULL)\n+\t\t\t\treturn rte_flow_error_set(error,\n+\t\t\t\t\tEINVAL,\n+\t\t\t\t\tRTE_FLOW_ERROR_TYPE_ACTION,\n+\t\t\t\t\taction,\n+\t\t\t\t\t\"COUNT: Null configuration\");\n+\n+\t\t\tif ((params->action_mask & (1LLU << RTE_TABLE_ACTION_MTR)) == 0)\n+\t\t\t\treturn rte_flow_error_set(error,\n+\t\t\t\t\tEINVAL,\n+\t\t\t\t\tRTE_FLOW_ERROR_TYPE_UNSPECIFIED,\n+\t\t\t\t\tNULL,\n+\t\t\t\t\t\"METER action not supported by this table\");\n+\n+\t\t\tm = softnic_mtr_find(softnic, conf->mtr_id);\n+\t\t\tif (m == NULL)\n+\t\t\t\treturn -rte_flow_error_set(error,\n+\t\t\t\t\tEINVAL,\n+\t\t\t\t\tRTE_FLOW_ERROR_TYPE_ACTION_CONF,\n+\t\t\t\t\tNULL,\n+\t\t\t\t\trte_strerror(EINVAL));\n+\n+\t\t\tif (params->mtr.n_tc != 1)\n+\t\t\t\treturn -rte_flow_error_set(error,\n+\t\t\t\t\tEINVAL,\n+\t\t\t\t\tRTE_FLOW_ERROR_TYPE_UNSPECIFIED,\n+\t\t\t\t\tNULL,\n+\t\t\t\t\trte_strerror(EINVAL));\n+\n+\t\t\tmeter_profile_id = m->params.meter_profile_id;\n+\n+\t\t\tmp = softnic_table_meter_profile_find(table, meter_profile_id);\n+\t\t\tif (mp == NULL) {\n+\t\t\t\tstruct softnic_mtr_meter_profile *mtr_meter_profile;\n+\t\t\t\tstruct rte_table_action_meter_profile profile;\n+\t\t\t\tint status;\n+\n+\t\t\t\tmp = calloc(1, sizeof(struct softnic_mtr_meter_profile));\n+\t\t\t\tif (mp == NULL) {\n+\t\t\t\t\trte_flow_error_set(error,\n+\t\t\t\t\t\tENOMEM,\n+\t\t\t\t\t\tRTE_FLOW_ERROR_TYPE_UNSPECIFIED,\n+\t\t\t\t\t\tNULL,\n+\t\t\t\t\t\t\"Not enough table memory for meter profile\");\n+\t\t\t\t\treturn -1;\n+\t\t\t\t}\n+\n+\t\t\t\tmtr_meter_profile = softnic_mtr_meter_profile_find(softnic,\n+\t\t\t\t\tmeter_profile_id);\n+\t\t\t\tif (mtr_meter_profile == NULL) {\n+\t\t\t\t\tfree(mp);\n+\n+\t\t\t\t\trte_flow_error_set(error,\n+\t\t\t\t\t\tEINVAL,\n+\t\t\t\t\t\tRTE_FLOW_ERROR_TYPE_UNSPECIFIED,\n+\t\t\t\t\t\tNULL,\n+\t\t\t\t\t\trte_strerror(EINVAL));\n+\t\t\t\t\treturn -1;\n+\t\t\t\t}\n+\n+\t\t\t\tmp->meter_profile_id = meter_profile_id;\n+\t\t\t\tmp->n_users = mtr_meter_profile->n_users;\n+\t\t\t\tmemcpy(&mp->params, &mtr_meter_profile->params,\n+\t\t\t\t\tsizeof(mp->params));\n+\n+\t\t\t\tprofile.alg = RTE_TABLE_ACTION_METER_TRTCM;\n+\t\t\t\tmemcpy(&profile.trtcm, &mp->params.trtcm_rfc2698,\n+\t\t\t\t\tsizeof(profile.trtcm));\n+\n+\t\t\t\tstatus = rte_table_action_meter_profile_add(table->a,\n+\t\t\t\t\tmeter_profile_id,\n+\t\t\t\t\t&profile);\n+\t\t\t\tif (status) {\n+\t\t\t\t\t\tfree(mp);\n+\n+\t\t\t\t\trte_flow_error_set(error,\n+\t\t\t\t\t\tEINVAL,\n+\t\t\t\t\t\tRTE_FLOW_ERROR_TYPE_UNSPECIFIED,\n+\t\t\t\t\t\tNULL,\n+\t\t\t\t\t\trte_strerror(EINVAL));\n+\t\t\t\t\treturn -1;\n+\t\t\t\t}\n+\n+\t\t\t\t/* Add to table meter profile list */\n+\t\t\t\tTAILQ_INSERT_TAIL(&table->meter_profiles, mp, node);\n+\t\t\t}\n+\n+\t\t\tmtr_tc_params.meter_profile_id = meter_profile_id;\n+\t\t\tmtr_tc_params.policer[e_RTE_METER_GREEN] =\n+\t\t\t\t(enum rte_table_action_policer)m->params.action[RTE_MTR_GREEN];\n+\t\t\tmtr_tc_params.policer[e_RTE_METER_YELLOW] =\n+\t\t\t\t(enum rte_table_action_policer)m->params.action[RTE_MTR_YELLOW];\n+\t\t\tmtr_tc_params.policer[e_RTE_METER_RED] =\n+\t\t\t\t(enum rte_table_action_policer)m->params.action[RTE_MTR_RED];\n+\n+\t\t\t/* RTE_TABLE_ACTION_METER */\n+\t\t\tmemcpy(&rule_action->mtr.mtr[0], &mtr_tc_params,\n+\t\t\t\tsizeof(rule_action->mtr.mtr[0]));\n+\t\t\trule_action->mtr.tc_mask = 1 << 0;\n+\t\t\trule_action->action_mask |= 1 << RTE_TABLE_ACTION_MTR;\n+\t\t\tbreak;\n+\t\t} /* RTE_FLOW_ACTION_TYPE_METER */\n+\n \t\tdefault:\n \t\t\treturn -ENOTSUP;\n \t\t}\n@@ -1562,6 +1673,35 @@ pmd_flow_validate(struct rte_eth_dev *dev,\n \treturn 0;\n }\n \n+static void set_meter_owner_to_flow(struct pmd_internals *softnic,\n+\tstruct rte_flow *flow,\n+\tconst struct rte_flow_action *action)\n+{\n+\tfor ( ; action->type != RTE_FLOW_ACTION_TYPE_END; action++) {\n+\n+\t\tif (action->type == RTE_FLOW_ACTION_TYPE_VOID)\n+\t\t\tcontinue;\n+\n+\t\tif (action->type == RTE_FLOW_ACTION_TYPE_METER) {\n+\t\t\tconst struct rte_flow_action_meter *conf = action->conf;\n+\t\t\tstruct softnic_mtr_list *ml = &softnic->mtr.mtrs;\n+\t\t\tstruct softnic_mtr *m;\n+\n+\t\t\tTAILQ_FOREACH(m, ml, node) {\n+\t\t\t\tif (m->flow == flow) {\n+\t\t\t\t\tm->flow = NULL;\n+\t\t\t\t\tbreak;\n+\t\t\t\t}\n+\t\t\t}\n+\n+\t\t\tm = softnic_mtr_find(softnic, conf->mtr_id);\n+\t\t\tm->flow = flow;\n+\n+\t\t\tbreak;\n+\t\t}\n+\t}\n+}\n+\n static struct rte_flow *\n pmd_flow_create(struct rte_eth_dev *dev,\n \tconst struct rte_flow_attr *attr,\n@@ -1702,6 +1842,8 @@ pmd_flow_create(struct rte_eth_dev *dev,\n \tflow->pipeline = pipeline;\n \tflow->table_id = table_id;\n \n+\tset_meter_owner_to_flow(softnic, flow, action);\n+\n \t/* Flow add to list. */\n \tif (new_flow)\n \t\tTAILQ_INSERT_TAIL(&table->flows, flow, node);\n@@ -1709,6 +1851,31 @@ pmd_flow_create(struct rte_eth_dev *dev,\n \treturn flow;\n }\n \n+static void reset_meter_owner(struct pmd_internals *softnic,\n+\tstruct softnic_table *table,\n+\tstruct rte_flow *flow)\n+{\n+\tstruct softnic_table_action_profile *profile;\n+\tstruct softnic_table_action_profile_params *params;\n+\n+\tprofile = softnic_table_action_profile_find(softnic,\n+\t\ttable->params.action_profile_name);\n+\n+\tparams = &profile->params;\n+\n+\tif ((params->action_mask & (1LLU << RTE_TABLE_ACTION_MTR)) == 0) {\n+\t\tstruct softnic_mtr_list *ml = &softnic->mtr.mtrs;\n+\t\tstruct softnic_mtr *m;\n+\n+\t\tTAILQ_FOREACH(m, ml, node) {\n+\t\t\tif (m->flow == flow) {\n+\t\t\t\tm->flow = NULL;\n+\t\t\t\tbreak;\n+\t\t\t}\n+\t\t}\n+\t}\n+}\n+\n static int\n pmd_flow_destroy(struct rte_eth_dev *dev,\n \tstruct rte_flow *flow,\n@@ -1744,6 +1911,9 @@ pmd_flow_destroy(struct rte_eth_dev *dev,\n \tTAILQ_REMOVE(&table->flows, flow, node);\n \tfree(flow);\n \n+\t/* Update dependencies */\n+\treset_meter_owner(softnic, table, flow);\n+\n \treturn 0;\n }\n \n",
    "prefixes": [
        "10/10"
    ]
}