Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/44576/?format=api
http://patchwork.dpdk.org/api/patches/44576/?format=api", "web_url": "http://patchwork.dpdk.org/project/dpdk/patch/1536675645-10105-9-git-send-email-reshma.pattan@intel.com/", "project": { "id": 1, "url": "http://patchwork.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": "<1536675645-10105-9-git-send-email-reshma.pattan@intel.com>", "list_archive_url": "https://inbox.dpdk.org/dev/1536675645-10105-9-git-send-email-reshma.pattan@intel.com", "date": "2018-09-11T14:20:38", "name": "[v2,08/15] net/softnic: validate and map flow rule with acl table match", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": true, "hash": "d2a728bb3042b53b3522963793581da90353ab0a", "submitter": { "id": 70, "url": "http://patchwork.dpdk.org/api/people/70/?format=api", "name": "Pattan, Reshma", "email": "reshma.pattan@intel.com" }, "delegate": { "id": 10018, "url": "http://patchwork.dpdk.org/api/users/10018/?format=api", "username": "cristian_dumitrescu", "first_name": "Cristian", "last_name": "Dumitrescu", "email": "cristian.dumitrescu@intel.com" }, "mbox": "http://patchwork.dpdk.org/project/dpdk/patch/1536675645-10105-9-git-send-email-reshma.pattan@intel.com/mbox/", "series": [ { "id": 1274, "url": "http://patchwork.dpdk.org/api/series/1274/?format=api", "web_url": "http://patchwork.dpdk.org/project/dpdk/list/?series=1274", "date": "2018-09-11T14:20:38", "name": null, "version": 2, "mbox": "http://patchwork.dpdk.org/series/1274/mbox/" } ], "comments": "http://patchwork.dpdk.org/api/patches/44576/comments/", "check": "success", "checks": "http://patchwork.dpdk.org/api/patches/44576/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 A0B2D5B32;\n\tTue, 11 Sep 2018 16:21:06 +0200 (CEST)", "from mga01.intel.com (mga01.intel.com [192.55.52.88])\n\tby dpdk.org (Postfix) with ESMTP id 0112D568A\n\tfor <dev@dpdk.org>; Tue, 11 Sep 2018 16:20:57 +0200 (CEST)", "from fmsmga007.fm.intel.com ([10.253.24.52])\n\tby fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t11 Sep 2018 07:20:57 -0700", "from sivswdev02.ir.intel.com (HELO localhost.localdomain)\n\t([10.237.217.46])\n\tby fmsmga007.fm.intel.com with ESMTP; 11 Sep 2018 07:20:56 -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,360,1531810800\"; d=\"scan'208\";a=\"69156883\"", "From": "Reshma Pattan <reshma.pattan@intel.com>", "To": "dev@dpdk.org", "Cc": "Cristian Dumitrescu <cristian.dumitrescu@intel.com>,\n\tReshma Pattan <reshma.pattan@intel.com>", "Date": "Tue, 11 Sep 2018 15:20:38 +0100", "Message-Id": "<1536675645-10105-9-git-send-email-reshma.pattan@intel.com>", "X-Mailer": "git-send-email 1.7.0.7", "In-Reply-To": "<1536251222-17275-1-git-send-email-reshma.pattan@intel.com>", "References": "<1536251222-17275-1-git-send-email-reshma.pattan@intel.com>", "Subject": "[dpdk-dev] [PATCH v2 08/15] net/softnic: validate and map flow rule\n\twith acl table match", "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": "Support for validating and mapping rte flow rule with\nACL table match is added.\n\nAs part of this support below utility functions\nbeen added\nflow_rule_match_get()\nflow_rule_match_acl_get()\nflow_item_skip_disabled_protos()\nflow_item_proto_preprocess()\nflow_item_is_proto()\nflow_item_raw_preprocess()\n\nSigned-off-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>\nSigned-off-by: Reshma Pattan <reshma.pattan@intel.com>\n---\n drivers/net/softnic/rte_eth_softnic_flow.c | 386 +++++++++++++++++++++++++++++\n 1 file changed, 386 insertions(+)", "diff": "diff --git a/drivers/net/softnic/rte_eth_softnic_flow.c b/drivers/net/softnic/rte_eth_softnic_flow.c\nindex f37890333..022d41775 100644\n--- a/drivers/net/softnic/rte_eth_softnic_flow.c\n+++ b/drivers/net/softnic/rte_eth_softnic_flow.c\n@@ -95,6 +95,375 @@ flow_pipeline_table_get(struct pmd_internals *softnic,\n \treturn 0;\n }\n \n+union flow_item {\n+\tuint8_t raw[TABLE_RULE_MATCH_SIZE_MAX];\n+\tstruct rte_flow_item_eth eth;\n+\tstruct rte_flow_item_vlan vlan;\n+\tstruct rte_flow_item_ipv4 ipv4;\n+\tstruct rte_flow_item_ipv6 ipv6;\n+\tstruct rte_flow_item_icmp icmp;\n+\tstruct rte_flow_item_udp udp;\n+\tstruct rte_flow_item_tcp tcp;\n+\tstruct rte_flow_item_sctp sctp;\n+\tstruct rte_flow_item_vxlan vxlan;\n+\tstruct rte_flow_item_e_tag e_tag;\n+\tstruct rte_flow_item_nvgre nvgre;\n+\tstruct rte_flow_item_mpls mpls;\n+\tstruct rte_flow_item_gre gre;\n+\tstruct rte_flow_item_gtp gtp;\n+\tstruct rte_flow_item_esp esp;\n+\tstruct rte_flow_item_geneve geneve;\n+\tstruct rte_flow_item_vxlan_gpe vxlan_gpe;\n+\tstruct rte_flow_item_arp_eth_ipv4 arp_eth_ipv4;\n+\tstruct rte_flow_item_ipv6_ext ipv6_ext;\n+\tstruct rte_flow_item_icmp6 icmp6;\n+\tstruct rte_flow_item_icmp6_nd_ns icmp6_nd_ns;\n+\tstruct rte_flow_item_icmp6_nd_na icmp6_nd_na;\n+\tstruct rte_flow_item_icmp6_nd_opt icmp6_nd_opt;\n+\tstruct rte_flow_item_icmp6_nd_opt_sla_eth icmp6_nd_opt_sla_eth;\n+\tstruct rte_flow_item_icmp6_nd_opt_tla_eth icmp6_nd_opt_tla_eth;\n+};\n+\n+static const union flow_item flow_item_raw_mask;\n+\n+static int\n+flow_item_is_proto(enum rte_flow_item_type type,\n+\tconst void **mask,\n+\tsize_t *size)\n+{\n+\tswitch (type) {\n+\tcase RTE_FLOW_ITEM_TYPE_RAW:\n+\t\t*mask = &flow_item_raw_mask;\n+\t\t*size = sizeof(flow_item_raw_mask);\n+\t\treturn 1; /* TRUE */\n+\n+\tcase RTE_FLOW_ITEM_TYPE_ETH:\n+\t\t*mask = &rte_flow_item_eth_mask;\n+\t\t*size = sizeof(struct rte_flow_item_eth);\n+\t\treturn 1; /* TRUE */\n+\n+\tcase RTE_FLOW_ITEM_TYPE_VLAN:\n+\t\t*mask = &rte_flow_item_vlan_mask;\n+\t\t*size = sizeof(struct rte_flow_item_vlan);\n+\t\treturn 1;\n+\n+\tcase RTE_FLOW_ITEM_TYPE_IPV4:\n+\t\t*mask = &rte_flow_item_ipv4_mask;\n+\t\t*size = sizeof(struct rte_flow_item_ipv4);\n+\t\treturn 1;\n+\n+\tcase RTE_FLOW_ITEM_TYPE_IPV6:\n+\t\t*mask = &rte_flow_item_ipv6_mask;\n+\t\t*size = sizeof(struct rte_flow_item_ipv6);\n+\t\treturn 1;\n+\n+\tcase RTE_FLOW_ITEM_TYPE_ICMP:\n+\t\t*mask = &rte_flow_item_icmp_mask;\n+\t\t*size = sizeof(struct rte_flow_item_icmp);\n+\t\treturn 1;\n+\n+\tcase RTE_FLOW_ITEM_TYPE_UDP:\n+\t\t*mask = &rte_flow_item_udp_mask;\n+\t\t*size = sizeof(struct rte_flow_item_udp);\n+\t\treturn 1;\n+\n+\tcase RTE_FLOW_ITEM_TYPE_TCP:\n+\t\t*mask = &rte_flow_item_tcp_mask;\n+\t\t*size = sizeof(struct rte_flow_item_tcp);\n+\t\treturn 1;\n+\n+\tcase RTE_FLOW_ITEM_TYPE_SCTP:\n+\t\t*mask = &rte_flow_item_sctp_mask;\n+\t\t*size = sizeof(struct rte_flow_item_sctp);\n+\t\treturn 1;\n+\n+\tcase RTE_FLOW_ITEM_TYPE_VXLAN:\n+\t\t*mask = &rte_flow_item_vxlan_mask;\n+\t\t*size = sizeof(struct rte_flow_item_vxlan);\n+\t\treturn 1;\n+\n+\tcase RTE_FLOW_ITEM_TYPE_E_TAG:\n+\t\t*mask = &rte_flow_item_e_tag_mask;\n+\t\t*size = sizeof(struct rte_flow_item_e_tag);\n+\t\treturn 1;\n+\n+\tcase RTE_FLOW_ITEM_TYPE_NVGRE:\n+\t\t*mask = &rte_flow_item_nvgre_mask;\n+\t\t*size = sizeof(struct rte_flow_item_nvgre);\n+\t\treturn 1;\n+\n+\tcase RTE_FLOW_ITEM_TYPE_MPLS:\n+\t\t*mask = &rte_flow_item_mpls_mask;\n+\t\t*size = sizeof(struct rte_flow_item_mpls);\n+\t\treturn 1;\n+\n+\tcase RTE_FLOW_ITEM_TYPE_GRE:\n+\t\t*mask = &rte_flow_item_gre_mask;\n+\t\t*size = sizeof(struct rte_flow_item_gre);\n+\t\treturn 1;\n+\n+\tcase RTE_FLOW_ITEM_TYPE_GTP:\n+\tcase RTE_FLOW_ITEM_TYPE_GTPC:\n+\tcase RTE_FLOW_ITEM_TYPE_GTPU:\n+\t\t*mask = &rte_flow_item_gtp_mask;\n+\t\t*size = sizeof(struct rte_flow_item_gtp);\n+\t\treturn 1;\n+\n+\tcase RTE_FLOW_ITEM_TYPE_ESP:\n+\t\t*mask = &rte_flow_item_esp_mask;\n+\t\t*size = sizeof(struct rte_flow_item_esp);\n+\t\treturn 1;\n+\n+\tcase RTE_FLOW_ITEM_TYPE_GENEVE:\n+\t\t*mask = &rte_flow_item_geneve_mask;\n+\t\t*size = sizeof(struct rte_flow_item_geneve);\n+\t\treturn 1;\n+\n+\tcase RTE_FLOW_ITEM_TYPE_VXLAN_GPE:\n+\t\t*mask = &rte_flow_item_vxlan_gpe_mask;\n+\t\t*size = sizeof(struct rte_flow_item_vxlan_gpe);\n+\t\treturn 1;\n+\n+\tcase RTE_FLOW_ITEM_TYPE_ARP_ETH_IPV4:\n+\t\t*mask = &rte_flow_item_arp_eth_ipv4_mask;\n+\t\t*size = sizeof(struct rte_flow_item_arp_eth_ipv4);\n+\t\treturn 1;\n+\n+\tcase RTE_FLOW_ITEM_TYPE_IPV6_EXT:\n+\t\t*mask = &rte_flow_item_ipv6_ext_mask;\n+\t\t*size = sizeof(struct rte_flow_item_ipv6_ext);\n+\t\treturn 1;\n+\n+\tcase RTE_FLOW_ITEM_TYPE_ICMP6:\n+\t\t*mask = &rte_flow_item_icmp6_mask;\n+\t\t*size = sizeof(struct rte_flow_item_icmp6);\n+\t\treturn 1;\n+\n+\tcase RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS:\n+\t\t*mask = &rte_flow_item_icmp6_nd_ns_mask;\n+\t\t*size = sizeof(struct rte_flow_item_icmp6_nd_ns);\n+\t\treturn 1;\n+\n+\tcase RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA:\n+\t\t*mask = &rte_flow_item_icmp6_nd_na_mask;\n+\t\t*size = sizeof(struct rte_flow_item_icmp6_nd_na);\n+\t\treturn 1;\n+\n+\tcase RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT:\n+\t\t*mask = &rte_flow_item_icmp6_nd_opt_mask;\n+\t\t*size = sizeof(struct rte_flow_item_icmp6_nd_opt);\n+\t\treturn 1;\n+\n+\tcase RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_SLA_ETH:\n+\t\t*mask = &rte_flow_item_icmp6_nd_opt_sla_eth_mask;\n+\t\t*size = sizeof(struct rte_flow_item_icmp6_nd_opt_sla_eth);\n+\t\treturn 1;\n+\n+\tcase RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_TLA_ETH:\n+\t\t*mask = &rte_flow_item_icmp6_nd_opt_tla_eth_mask;\n+\t\t*size = sizeof(struct rte_flow_item_icmp6_nd_opt_tla_eth);\n+\t\treturn 1;\n+\n+\tdefault: return 0; /* FALSE */\n+\t}\n+}\n+\n+static int\n+flow_item_proto_preprocess(const struct rte_flow_item *item,\n+\tunion flow_item *item_spec,\n+\tunion flow_item *item_mask,\n+\tsize_t *item_size,\n+\tint *item_disabled,\n+\tstruct rte_flow_error *error)\n+{\n+\tconst void *mask_default;\n+\tuint8_t *spec = (uint8_t *)item_spec;\n+\tuint8_t *mask = (uint8_t *)item_mask;\n+\tsize_t size, i;\n+\n+\tif (!flow_item_is_proto(item->type, &mask_default, &size))\n+\t\treturn rte_flow_error_set(error,\n+\t\t\tENOTSUP,\n+\t\t\tRTE_FLOW_ERROR_TYPE_ITEM,\n+\t\t\titem,\n+\t\t\t\"Item type not supported\");\n+\n+\t/* spec */\n+\tif (!item->spec) {\n+\t\t/* If spec is NULL, then last and mask also have to be NULL. */\n+\t\tif (item->last || item->mask)\n+\t\t\treturn rte_flow_error_set(error,\n+\t\t\t\tEINVAL,\n+\t\t\t\tRTE_FLOW_ERROR_TYPE_ITEM,\n+\t\t\t\titem,\n+\t\t\t\t\"Invalid item (NULL spec with non-NULL last or mask)\");\n+\n+\t\tmemset(item_spec, 0, size);\n+\t\tmemset(item_mask, 0, size);\n+\t\t*item_size = size;\n+\t\t*item_disabled = 1; /* TRUE */\n+\t\treturn 0;\n+\t}\n+\n+\tmemcpy(spec, item->spec, size);\n+\t*item_size = size;\n+\n+\t/* mask */\n+\tif (item->mask)\n+\t\tmemcpy(mask, item->mask, size);\n+\telse\n+\t\tmemcpy(mask, mask_default, size);\n+\n+\t/* disabled */\n+\tfor (i = 0; i < size; i++)\n+\t\tif (mask[i])\n+\t\t\tbreak;\n+\t*item_disabled = (i == size) ? 1 : 0;\n+\n+\t/* Apply mask over spec. */\n+\tfor (i = 0; i < size; i++)\n+\t\tspec[i] &= mask[i];\n+\n+\t/* last */\n+\tif (item->last) {\n+\t\tuint8_t last[size];\n+\n+\t\t/* init last */\n+\t\tmemcpy(last, item->last, size);\n+\t\tfor (i = 0; i < size; i++)\n+\t\t\tlast[i] &= mask[i];\n+\n+\t\t/* check for range */\n+\t\tfor (i = 0; i < size; i++)\n+\t\t\tif (last[i] != spec[i])\n+\t\t\t\treturn rte_flow_error_set(error,\n+\t\t\t\t\tENOTSUP,\n+\t\t\t\t\tRTE_FLOW_ERROR_TYPE_ITEM,\n+\t\t\t\t\titem,\n+\t\t\t\t\t\"Range not supported\");\n+\t}\n+\n+\treturn 0;\n+}\n+\n+/***\n+ * Skip disabled protocol items and VOID items\n+ * until any of the mutually exclusive conditions\n+ * from the list below takes place:\n+ * (A) A protocol present in the proto_mask\n+ * is met (either ENABLED or DISABLED);\n+ * (B) A protocol NOT present in the proto_mask is met in ENABLED state;\n+ * (C) The END item is met.\n+ */\n+static int\n+flow_item_skip_disabled_protos(const struct rte_flow_item **item,\n+\tuint64_t proto_mask,\n+\tsize_t *length,\n+\tstruct rte_flow_error *error)\n+{\n+\tsize_t len = 0;\n+\n+\tfor ( ; (*item)->type != RTE_FLOW_ITEM_TYPE_END; (*item)++) {\n+\t\tunion flow_item spec, mask;\n+\t\tsize_t size;\n+\t\tint disabled = 0, status;\n+\n+\t\tif ((*item)->type == RTE_FLOW_ITEM_TYPE_VOID)\n+\t\t\tcontinue;\n+\n+\t\tstatus = flow_item_proto_preprocess(*item,\n+\t\t\t\t&spec,\n+\t\t\t\t&mask,\n+\t\t\t\t&size,\n+\t\t\t\t&disabled,\n+\t\t\t\terror);\n+\t\tif (status)\n+\t\t\treturn status;\n+\n+\t\tif ((proto_mask & (1LLU << (*item)->type)) ||\n+\t\t\t\t!disabled)\n+\t\t\tbreak;\n+\n+\t\tlen += size;\n+\t}\n+\n+\tif (length)\n+\t\t*length = len;\n+\n+\treturn 0;\n+}\n+\n+#define FLOW_ITEM_PROTO_IP \\\n+\t((1LLU << RTE_FLOW_ITEM_TYPE_IPV4) | \\\n+\t (1LLU << RTE_FLOW_ITEM_TYPE_IPV6))\n+\n+static int\n+flow_rule_match_acl_get(struct pmd_internals *softnic __rte_unused,\n+\t\tstruct pipeline *pipeline __rte_unused,\n+\t\tstruct softnic_table *table __rte_unused,\n+\t\tconst struct rte_flow_attr *attr,\n+\t\tconst struct rte_flow_item *item,\n+\t\tstruct softnic_table_rule_match *rule_match,\n+\t\tstruct rte_flow_error *error)\n+{\n+\tunion flow_item spec, mask;\n+\tsize_t size, length = 0;\n+\tint disabled = 0, status;\n+\n+\tmemset(rule_match, 0, sizeof(*rule_match));\n+\trule_match->match_type = TABLE_ACL;\n+\trule_match->match.acl.priority = attr->priority;\n+\n+\t/* VOID or disabled protos only, if any. */\n+\tstatus = flow_item_skip_disabled_protos(&item,\n+\t\t\tFLOW_ITEM_PROTO_IP, &length, error);\n+\tif (status)\n+\t\treturn status;\n+\n+\t/* IP only. */\n+\tstatus = flow_item_proto_preprocess(item, &spec, &mask,\n+\t\t\t&size, &disabled, error);\n+\tif (status)\n+\t\treturn status;\n+\n+\tswitch (item->type) {\n+\tdefault:\n+\t\treturn rte_flow_error_set(error,\n+\t\t\tENOTSUP,\n+\t\t\tRTE_FLOW_ERROR_TYPE_ITEM,\n+\t\t\titem,\n+\t\t\t\"ACL: IP protocol required\");\n+\t} /* switch */\n+}\n+\n+static int\n+flow_rule_match_get(struct pmd_internals *softnic,\n+\t\tstruct pipeline *pipeline,\n+\t\tstruct softnic_table *table,\n+\t\tconst struct rte_flow_attr *attr,\n+\t\tconst struct rte_flow_item *item,\n+\t\tstruct softnic_table_rule_match *rule_match,\n+\t\tstruct rte_flow_error *error)\n+{\n+\tswitch (table->params.match_type) {\n+\tcase TABLE_ACL:\n+\t\treturn flow_rule_match_acl_get(softnic,\n+\t\t\tpipeline,\n+\t\t\ttable,\n+\t\t\tattr,\n+\t\t\titem,\n+\t\t\trule_match,\n+\t\t\terror);\n+\t\t/* FALLTHROUGH */\n+\tdefault:\n+\t\treturn rte_flow_error_set(error,\n+\t\t\tENOTSUP,\n+\t\t\tRTE_FLOW_ERROR_TYPE_UNSPECIFIED,\n+\t\t\tNULL,\n+\t\t\t\"Unsupported pipeline table match type\");\n+\t}\n+}\n+\n static int\n pmd_flow_validate(struct rte_eth_dev *dev,\n \t\tconst struct rte_flow_attr *attr,\n@@ -102,8 +471,11 @@ pmd_flow_validate(struct rte_eth_dev *dev,\n \t\tconst struct rte_flow_action action[],\n \t\tstruct rte_flow_error *error)\n {\n+\tstruct softnic_table_rule_match rule_match;\n+\n \tstruct pmd_internals *softnic = dev->data->dev_private;\n \tstruct pipeline *pipeline;\n+\tstruct softnic_table *table;\n \tconst char *pipeline_name = NULL;\n \tuint32_t table_id = 0;\n \tint status;\n@@ -150,6 +522,20 @@ pmd_flow_validate(struct rte_eth_dev *dev,\n \t\t\t\tNULL,\n \t\t\t\t\"Invalid pipeline table ID\");\n \n+\ttable = &pipeline->table[table_id];\n+\n+\t/* Rule match. */\n+\tmemset(&rule_match, 0, sizeof(rule_match));\n+\tstatus = flow_rule_match_get(softnic,\n+\t\t\tpipeline,\n+\t\t\ttable,\n+\t\t\tattr,\n+\t\t\titem,\n+\t\t\t&rule_match,\n+\t\t\terror);\n+\tif (status)\n+\t\treturn status;\n+\n \treturn 0;\n }\n \n", "prefixes": [ "v2", "08/15" ] }{ "id": 44576, "url": "