Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/44745/?format=api
http://patches.dpdk.org/api/patches/44745/?format=api", "web_url": "http://patches.dpdk.org/project/dpdk/patch/20180914174554.90135-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": "<20180914174554.90135-11-jasvinder.singh@intel.com>", "list_archive_url": "https://inbox.dpdk.org/dev/20180914174554.90135-11-jasvinder.singh@intel.com", "date": "2018-09-14T17:45:54", "name": "[v3,10/10] net/softnic: enable flow rule with meter action", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": true, "hash": "52ac51691856d33c9395a99db307c90733e9ad0d", "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-11-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/44745/comments/", "check": "fail", "checks": "http://patches.dpdk.org/api/patches/44745/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 394EC8DAF;\n\tFri, 14 Sep 2018 19:46:31 +0200 (CEST)", "from mga14.intel.com (mga14.intel.com [192.55.52.115])\n\tby dpdk.org (Postfix) with ESMTP id EE77A5F22\n\tfor <dev@dpdk.org>; Fri, 14 Sep 2018 19:46:12 +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:09 -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:46: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,374,1531810800\"; d=\"scan'208\";a=\"73280026\"", "From": "Jasvinder Singh <jasvinder.singh@intel.com>", "To": "dev@dpdk.org", "Cc": "cristian.dumitrescu@intel.com", "Date": "Fri, 14 Sep 2018 18:45:54 +0100", "Message-Id": "<20180914174554.90135-11-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 10/10] net/softnic: enable flow rule with\n\tmeter action", "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 flow rules with meter action.\n\nSigned-off-by: Jasvinder Singh <jasvinder.singh@intel.com>\n---\n drivers/net/softnic/rte_eth_softnic_flow.c | 155 ++++++++++++++++++++++++++++-\n 1 file changed, 154 insertions(+), 1 deletion(-)", "diff": "diff --git a/drivers/net/softnic/rte_eth_softnic_flow.c b/drivers/net/softnic/rte_eth_softnic_flow.c\nindex 6562004..b7d2626 100644\n--- a/drivers/net/softnic/rte_eth_softnic_flow.c\n+++ b/drivers/net/softnic/rte_eth_softnic_flow.c\n@@ -1146,7 +1146,7 @@ flow_rule_action_get(struct pmd_internals *softnic,\n \tconst struct rte_flow_attr *attr,\n \tconst struct rte_flow_action *action,\n \tstruct softnic_table_rule_action *rule_action,\n-\tstruct rte_flow_error *error __rte_unused)\n+\tstruct rte_flow_error *error)\n {\n \tstruct softnic_table_action_profile *profile;\n \tstruct softnic_table_action_profile_params *params;\n@@ -1459,6 +1459,95 @@ 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\tconst struct rte_flow_action_meter *conf = action->conf;\n+\t\t\tstruct softnic_mtr_meter_profile *mp;\n+\t\t\tstruct softnic_mtr *m;\n+\t\t\tuint32_t table_id = table - pipeline->table;\n+\t\t\tuint32_t meter_profile_id;\n+\t\t\tint status;\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: Table action not supported\");\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\t\"METER: Multiple TCs not supported\");\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\"METER: Null configuration\");\n+\n+\t\t\tm = softnic_mtr_find(softnic, conf->mtr_id);\n+\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\t\"METER: Invalid meter ID\");\n+\n+\t\t\tif (m->flow)\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\t\"METER: Meter already attached to a flow\");\n+\n+\t\t\tmeter_profile_id = m->params.meter_profile_id;\n+\t\t\tmp = softnic_mtr_meter_profile_find(softnic, meter_profile_id);\n+\n+\t\t\t/* Add meter profile to pipeline table */\n+\t\t\tif (!softnic_pipeline_table_meter_profile_find(table,\n+\t\t\t\t\tmeter_profile_id)) {\n+\t\t\t\tstruct rte_table_action_meter_profile profile;\n+\n+\t\t\t\tmemset(&profile, 0, sizeof(profile));\n+\t\t\t\tprofile.alg = RTE_TABLE_ACTION_METER_TRTCM;\n+\t\t\t\tprofile.trtcm.cir = mp->params.trtcm_rfc2698.cir;\n+\t\t\t\tprofile.trtcm.pir = mp->params.trtcm_rfc2698.pir;\n+\t\t\t\tprofile.trtcm.cbs = mp->params.trtcm_rfc2698.cbs;\n+\t\t\t\tprofile.trtcm.pbs = mp->params.trtcm_rfc2698.pbs;\n+\n+\t\t\t\tstatus = softnic_pipeline_table_mtr_profile_add(softnic,\n+\t\t\t\t\t\tpipeline->name,\n+\t\t\t\t\t\ttable_id,\n+\t\t\t\t\t\tmeter_profile_id,\n+\t\t\t\t\t\t&profile);\n+\t\t\t\tif (status) {\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\t\"METER: Table meter profile add failed\");\n+\t\t\t\t\treturn -1;\n+\t\t\t\t}\n+\t\t\t}\n+\n+\t\t\t/* RTE_TABLE_ACTION_METER */\n+\t\t\trule_action->mtr.mtr[0].meter_profile_id = meter_profile_id;\n+\t\t\trule_action->mtr.mtr[0].policer[e_RTE_METER_GREEN] =\n+\t\t\t\t(enum rte_table_action_policer)m->params.action[RTE_MTR_GREEN];\n+\t\t\trule_action->mtr.mtr[0].policer[e_RTE_METER_YELLOW] =\n+\t\t\t\t(enum rte_table_action_policer)m->params.action[RTE_MTR_YELLOW];\n+\t\t\trule_action->mtr.mtr[0].policer[e_RTE_METER_RED] =\n+\t\t\t\t(enum rte_table_action_policer)m->params.action[RTE_MTR_RED];\n+\t\t\trule_action->mtr.tc_mask = 1;\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 +1651,61 @@ pmd_flow_validate(struct rte_eth_dev *dev,\n \treturn 0;\n }\n \n+static struct softnic_mtr *\n+flow_action_meter_get(struct pmd_internals *softnic,\n+\tconst struct rte_flow_action *action)\n+{\n+\tfor ( ; action->type != RTE_FLOW_ACTION_TYPE_END; action++)\n+\t\tif (action->type == RTE_FLOW_ACTION_TYPE_METER) {\n+\t\t\tconst struct rte_flow_action_meter *conf = action->conf;\n+\n+\t\t\tif (conf == NULL)\n+\t\t\t\treturn NULL;\n+\n+\t\t\treturn softnic_mtr_find(softnic, conf->mtr_id);\n+\t\t}\n+\n+\treturn NULL;\n+}\n+\n+static void\n+flow_meter_owner_reset(struct pmd_internals *softnic,\n+\tstruct rte_flow *flow)\n+{\n+\tstruct softnic_mtr_list *ml = &softnic->mtr.mtrs;\n+\tstruct softnic_mtr *m;\n+\n+\tTAILQ_FOREACH(m, ml, node)\n+\t\tif (m->flow == flow) {\n+\t\t\tm->flow = NULL;\n+\t\t\tbreak;\n+\t\t}\n+}\n+\n+static void\n+flow_meter_owner_set(struct pmd_internals *softnic,\n+\tstruct rte_flow *flow,\n+\tstruct softnic_mtr *mtr)\n+{\n+\t/* Reset current flow meter */\n+\tflow_meter_owner_reset(softnic, flow);\n+\n+\t/* Set new flow meter */\n+\tmtr->flow = flow;\n+}\n+\n+static int\n+is_meter_action_enable(struct pmd_internals *softnic,\n+\tstruct softnic_table *table)\n+{\n+\tstruct softnic_table_action_profile *profile =\n+\t\tsoftnic_table_action_profile_find(softnic,\n+\t\t\ttable->params.action_profile_name);\n+\tstruct softnic_table_action_profile_params *params = &profile->params;\n+\n+\treturn (params->action_mask & (1LLU << RTE_TABLE_ACTION_MTR)) ? 1 : 0;\n+}\n+\n static struct rte_flow *\n pmd_flow_create(struct rte_eth_dev *dev,\n \tconst struct rte_flow_attr *attr,\n@@ -1577,6 +1721,7 @@ pmd_flow_create(struct rte_eth_dev *dev,\n \tstruct pipeline *pipeline;\n \tstruct softnic_table *table;\n \tstruct rte_flow *flow;\n+\tstruct softnic_mtr *mtr;\n \tconst char *pipeline_name = NULL;\n \tuint32_t table_id = 0;\n \tint new_flow, status;\n@@ -1702,6 +1847,10 @@ pmd_flow_create(struct rte_eth_dev *dev,\n \tflow->pipeline = pipeline;\n \tflow->table_id = table_id;\n \n+\tmtr = flow_action_meter_get(softnic, action);\n+\tif (mtr)\n+\t\tflow_meter_owner_set(softnic, flow, mtr);\n+\n \t/* Flow add to list. */\n \tif (new_flow)\n \t\tTAILQ_INSERT_TAIL(&table->flows, flow, node);\n@@ -1740,6 +1889,10 @@ pmd_flow_destroy(struct rte_eth_dev *dev,\n \t\t\tNULL,\n \t\t\t\"Pipeline table rule delete failed\");\n \n+\t/* Update dependencies */\n+\tif (is_meter_action_enable(softnic, table))\n+\t\tflow_meter_owner_reset(softnic, flow);\n+\n \t/* Flow delete. */\n \tTAILQ_REMOVE(&table->flows, flow, node);\n \tfree(flow);\n", "prefixes": [ "v3", "10/10" ] }{ "id": 44745, "url": "