Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/44577/?format=api
http://patches.dpdk.org/api/patches/44577/?format=api", "web_url": "http://patches.dpdk.org/project/dpdk/patch/1536675645-10105-10-git-send-email-reshma.pattan@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": "<1536675645-10105-10-git-send-email-reshma.pattan@intel.com>", "list_archive_url": "https://inbox.dpdk.org/dev/1536675645-10105-10-git-send-email-reshma.pattan@intel.com", "date": "2018-09-11T14:20:39", "name": "[v2,09/15] net/softnic: parse flow protocol for acl table match", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": true, "hash": "2eb746a9ee18f834fd57abf395bf326d9bcf808a", "submitter": { "id": 70, "url": "http://patches.dpdk.org/api/people/70/?format=api", "name": "Pattan, Reshma", "email": "reshma.pattan@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/1536675645-10105-10-git-send-email-reshma.pattan@intel.com/mbox/", "series": [ { "id": 1275, "url": "http://patches.dpdk.org/api/series/1275/?format=api", "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=1275", "date": "2018-09-11T14:20:39", "name": null, "version": 2, "mbox": "http://patches.dpdk.org/series/1275/mbox/" } ], "comments": "http://patches.dpdk.org/api/patches/44577/comments/", "check": "success", "checks": "http://patches.dpdk.org/api/patches/44577/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 285675B3E;\n\tTue, 11 Sep 2018 16:21:08 +0200 (CEST)", "from mga01.intel.com (mga01.intel.com [192.55.52.88])\n\tby dpdk.org (Postfix) with ESMTP id 14C11569B\n\tfor <dev@dpdk.org>; Tue, 11 Sep 2018 16:20:58 +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:58 -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:57 -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=\"69156889\"", "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:39 +0100", "Message-Id": "<1536675645-10105-10-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 09/15] net/softnic: parse flow protocol for\n\tacl 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": "Added flow protocol parsing for IPV4/IPV6 and\nTCP/UDP/SCTP for ACL table rule match.\n\nAdded below helper functions for doing the same.\nport_mask_to_range()\nipv6_mask_to_depth()\nipv4_mask_to_depth()\nmask_to_depth()\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 | 359 ++++++++++++++++++++++++++++-\n 1 file changed, 357 insertions(+), 2 deletions(-)", "diff": "diff --git a/drivers/net/softnic/rte_eth_softnic_flow.c b/drivers/net/softnic/rte_eth_softnic_flow.c\nindex 022d41775..94af66391 100644\n--- a/drivers/net/softnic/rte_eth_softnic_flow.c\n+++ b/drivers/net/softnic/rte_eth_softnic_flow.c\n@@ -1,10 +1,13 @@\n /* SPDX-License-Identifier: BSD-3-Clause\n- * Copyright(c) 2017 Intel Corporation\n+ * Copyright(c) 2018 Intel Corporation\n */\n \n #include \"rte_eth_softnic_internals.h\"\n #include \"rte_eth_softnic.h\"\n \n+#define rte_ntohs rte_be_to_cpu_16\n+#define rte_ntohl rte_be_to_cpu_32\n+\n int\n flow_attr_map_set(struct pmd_internals *softnic,\n \t\tuint32_t group_id,\n@@ -397,6 +400,113 @@ flow_item_skip_disabled_protos(const struct rte_flow_item **item,\n \t((1LLU << RTE_FLOW_ITEM_TYPE_IPV4) | \\\n \t (1LLU << RTE_FLOW_ITEM_TYPE_IPV6))\n \n+static void\n+flow_item_skip_void(const struct rte_flow_item **item)\n+{\n+\tfor ( ; ; (*item)++)\n+\t\tif ((*item)->type != RTE_FLOW_ITEM_TYPE_VOID)\n+\t\t\treturn;\n+}\n+\n+#define IP_PROTOCOL_TCP 0x06\n+#define IP_PROTOCOL_UDP 0x11\n+#define IP_PROTOCOL_SCTP 0x84\n+\n+static int\n+mask_to_depth(uint64_t mask,\n+\t\tuint32_t *depth)\n+{\n+\tuint64_t n;\n+\n+\tif (mask == UINT64_MAX) {\n+\t\tif (depth)\n+\t\t\t*depth = 64;\n+\n+\t\treturn 0;\n+\t}\n+\n+\tmask = ~mask;\n+\n+\tif (mask & (mask + 1))\n+\t\treturn -1;\n+\n+\tn = __builtin_popcountll(mask);\n+\tif (depth)\n+\t\t*depth = (uint32_t)(64 - n);\n+\n+\treturn 0;\n+}\n+\n+static int\n+ipv4_mask_to_depth(uint32_t mask,\n+\t\tuint32_t *depth)\n+{\n+\tuint32_t d;\n+\tint status;\n+\n+\tstatus = mask_to_depth(mask | (UINT64_MAX << 32), &d);\n+\tif (status)\n+\t\treturn status;\n+\n+\td -= 32;\n+\tif (depth)\n+\t\t*depth = d;\n+\n+\treturn 0;\n+}\n+\n+static int\n+ipv6_mask_to_depth(uint8_t *mask,\n+\tuint32_t *depth)\n+{\n+\tuint64_t *m = (uint64_t *)mask;\n+\tuint64_t m0 = rte_be_to_cpu_64(m[0]);\n+\tuint64_t m1 = rte_be_to_cpu_64(m[1]);\n+\tuint32_t d0, d1;\n+\tint status;\n+\n+\tstatus = mask_to_depth(m0, &d0);\n+\tif (status)\n+\t\treturn status;\n+\n+\tstatus = mask_to_depth(m1, &d1);\n+\tif (status)\n+\t\treturn status;\n+\n+\tif (d0 < 64 && d1)\n+\t\treturn -1;\n+\n+\tif (depth)\n+\t\t*depth = d0 + d1;\n+\n+\treturn 0;\n+}\n+\n+static int\n+port_mask_to_range(uint16_t port,\n+\tuint16_t port_mask,\n+\tuint16_t *port0,\n+\tuint16_t *port1)\n+{\n+\tint status;\n+\tuint16_t p0, p1;\n+\n+\tstatus = mask_to_depth(port_mask | (UINT64_MAX << 16), NULL);\n+\tif (status)\n+\t\treturn -1;\n+\n+\tp0 = port & port_mask;\n+\tp1 = p0 | ~port_mask;\n+\n+\tif (port0)\n+\t\t*port0 = p0;\n+\n+\tif (port1)\n+\t\t*port1 = p1;\n+\n+\treturn 0;\n+}\n+\n static int\n flow_rule_match_acl_get(struct pmd_internals *softnic __rte_unused,\n \t\tstruct pipeline *pipeline __rte_unused,\n@@ -409,6 +519,7 @@ flow_rule_match_acl_get(struct pmd_internals *softnic __rte_unused,\n \tunion flow_item spec, mask;\n \tsize_t size, length = 0;\n \tint disabled = 0, status;\n+\tuint8_t ip_proto, ip_proto_mask;\n \n \tmemset(rule_match, 0, sizeof(*rule_match));\n \trule_match->match_type = TABLE_ACL;\n@@ -427,6 +538,80 @@ flow_rule_match_acl_get(struct pmd_internals *softnic __rte_unused,\n \t\treturn status;\n \n \tswitch (item->type) {\n+\tcase RTE_FLOW_ITEM_TYPE_IPV4:\n+\t{\n+\t\tuint32_t sa_depth, da_depth;\n+\n+\t\tstatus = ipv4_mask_to_depth(rte_ntohl(mask.ipv4.hdr.src_addr),\n+\t\t\t\t&sa_depth);\n+\t\tif (status)\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\"ACL: Illegal IPv4 header source address mask\");\n+\n+\t\tstatus = ipv4_mask_to_depth(rte_ntohl(mask.ipv4.hdr.dst_addr),\n+\t\t\t\t&da_depth);\n+\t\tif (status)\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\"ACL: Illegal IPv4 header destination address mask\");\n+\n+\t\tip_proto = spec.ipv4.hdr.next_proto_id;\n+\t\tip_proto_mask = mask.ipv4.hdr.next_proto_id;\n+\n+\t\trule_match->match.acl.ip_version = 1;\n+\t\trule_match->match.acl.ipv4.sa =\n+\t\t\trte_ntohl(spec.ipv4.hdr.src_addr);\n+\t\trule_match->match.acl.ipv4.da =\n+\t\t\trte_ntohl(spec.ipv4.hdr.dst_addr);\n+\t\trule_match->match.acl.sa_depth = sa_depth;\n+\t\trule_match->match.acl.da_depth = da_depth;\n+\t\trule_match->match.acl.proto = ip_proto;\n+\t\trule_match->match.acl.proto_mask = ip_proto_mask;\n+\t\tbreak;\n+\t} /* RTE_FLOW_ITEM_TYPE_IPV4 */\n+\n+\tcase RTE_FLOW_ITEM_TYPE_IPV6:\n+\t{\n+\t\tuint32_t sa_depth, da_depth;\n+\n+\t\tstatus = ipv6_mask_to_depth(mask.ipv6.hdr.src_addr, &sa_depth);\n+\t\tif (status)\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\"ACL: Illegal IPv6 header source address mask\");\n+\n+\t\tstatus = ipv6_mask_to_depth(mask.ipv6.hdr.dst_addr, &da_depth);\n+\t\tif (status)\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\"ACL: Illegal IPv6 header destination address mask\");\n+\n+\t\tip_proto = spec.ipv6.hdr.proto;\n+\t\tip_proto_mask = mask.ipv6.hdr.proto;\n+\n+\t\trule_match->match.acl.ip_version = 0;\n+\t\tmemcpy(rule_match->match.acl.ipv6.sa,\n+\t\t\tspec.ipv6.hdr.src_addr,\n+\t\t\tsizeof(spec.ipv6.hdr.src_addr));\n+\t\tmemcpy(rule_match->match.acl.ipv6.da,\n+\t\t\tspec.ipv6.hdr.dst_addr,\n+\t\t\tsizeof(spec.ipv6.hdr.dst_addr));\n+\t\trule_match->match.acl.sa_depth = sa_depth;\n+\t\trule_match->match.acl.da_depth = da_depth;\n+\t\trule_match->match.acl.proto = ip_proto;\n+\t\trule_match->match.acl.proto_mask = ip_proto_mask;\n+\t\tbreak;\n+\t} /* RTE_FLOW_ITEM_TYPE_IPV6 */\n+\n \tdefault:\n \t\treturn rte_flow_error_set(error,\n \t\t\tENOTSUP,\n@@ -434,9 +619,179 @@ flow_rule_match_acl_get(struct pmd_internals *softnic __rte_unused,\n \t\t\titem,\n \t\t\t\"ACL: IP protocol required\");\n \t} /* switch */\n+\n+\tif (ip_proto_mask != UINT8_MAX)\n+\t\treturn rte_flow_error_set(error,\n+\t\t\tEINVAL,\n+\t\t\tRTE_FLOW_ERROR_TYPE_ITEM,\n+\t\t\titem,\n+\t\t\t\"ACL: Illegal IP protocol mask\");\n+\n+\titem++;\n+\n+\t/* VOID only, if any. */\n+\tflow_item_skip_void(&item);\n+\n+\t/* TCP/UDP/SCTP 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+\tcase RTE_FLOW_ITEM_TYPE_TCP:\n+\t{\n+\t\tuint16_t sp0, sp1, dp0, dp1;\n+\n+\t\tif (ip_proto != IP_PROTOCOL_TCP)\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\"ACL: Item type is TCP, but IP protocol is not\");\n+\n+\t\tstatus = port_mask_to_range(rte_ntohs(spec.tcp.hdr.src_port),\n+\t\t\t\trte_ntohs(mask.tcp.hdr.src_port),\n+\t\t\t\t&sp0,\n+\t\t\t\t&sp1);\n+\n+\t\tif (status)\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\"ACL: Illegal TCP source port mask\");\n+\n+\t\tstatus = port_mask_to_range(rte_ntohs(spec.tcp.hdr.dst_port),\n+\t\t\t\trte_ntohs(mask.tcp.hdr.dst_port),\n+\t\t\t\t&dp0,\n+\t\t\t\t&dp1);\n+\n+\t\tif (status)\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\"ACL: Illegal TCP destination port mask\");\n+\n+\t\trule_match->match.acl.sp0 = sp0;\n+\t\trule_match->match.acl.sp1 = sp1;\n+\t\trule_match->match.acl.dp0 = dp0;\n+\t\trule_match->match.acl.dp1 = dp1;\n+\n+\t\tbreak;\n+\t} /* RTE_FLOW_ITEM_TYPE_TCP */\n+\n+\tcase RTE_FLOW_ITEM_TYPE_UDP:\n+\t{\n+\t\tuint16_t sp0, sp1, dp0, dp1;\n+\n+\t\tif (ip_proto != IP_PROTOCOL_UDP)\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\"ACL: Item type is UDP, but IP protocol is not\");\n+\n+\t\tstatus = port_mask_to_range(rte_ntohs(spec.udp.hdr.src_port),\n+\t\t\trte_ntohs(mask.udp.hdr.src_port),\n+\t\t\t&sp0,\n+\t\t\t&sp1);\n+\t\tif (status)\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\"ACL: Illegal UDP source port mask\");\n+\n+\t\tstatus = port_mask_to_range(rte_ntohs(spec.udp.hdr.dst_port),\n+\t\t\trte_ntohs(mask.udp.hdr.dst_port),\n+\t\t\t&dp0,\n+\t\t\t&dp1);\n+\t\tif (status)\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\"ACL: Illegal UDP destination port mask\");\n+\n+\t\trule_match->match.acl.sp0 = sp0;\n+\t\trule_match->match.acl.sp1 = sp1;\n+\t\trule_match->match.acl.dp0 = dp0;\n+\t\trule_match->match.acl.dp1 = dp1;\n+\n+\t\tbreak;\n+\t} /* RTE_FLOW_ITEM_TYPE_UDP */\n+\n+\tcase RTE_FLOW_ITEM_TYPE_SCTP:\n+\t{\n+\t\tuint16_t sp0, sp1, dp0, dp1;\n+\n+\t\tif (ip_proto != IP_PROTOCOL_SCTP)\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\"ACL: Item type is SCTP, but IP protocol is not\");\n+\n+\t\tstatus = port_mask_to_range(rte_ntohs(spec.sctp.hdr.src_port),\n+\t\t\trte_ntohs(mask.sctp.hdr.src_port),\n+\t\t\t&sp0,\n+\t\t\t&sp1);\n+\n+\t\tif (status)\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\"ACL: Illegal SCTP source port mask\");\n+\n+\t\tstatus = port_mask_to_range(rte_ntohs(spec.sctp.hdr.dst_port),\n+\t\t\trte_ntohs(mask.sctp.hdr.dst_port),\n+\t\t\t&dp0,\n+\t\t\t&dp1);\n+\t\tif (status)\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\"ACL: Illegal SCTP destination port mask\");\n+\n+\t\trule_match->match.acl.sp0 = sp0;\n+\t\trule_match->match.acl.sp1 = sp1;\n+\t\trule_match->match.acl.dp0 = dp0;\n+\t\trule_match->match.acl.dp1 = dp1;\n+\n+\t\tbreak;\n+\t} /* RTE_FLOW_ITEM_TYPE_SCTP */\n+\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: TCP/UDP/SCTP required\");\n+\t} /* switch */\n+\n+\titem++;\n+\n+\t/* VOID or disabled protos only, if any. */\n+\tstatus = flow_item_skip_disabled_protos(&item, 0, NULL, error);\n+\tif (status)\n+\t\treturn status;\n+\n+\t/* END only. */\n+\tif (item->type != RTE_FLOW_ITEM_TYPE_END)\n+\t\treturn rte_flow_error_set(error,\n+\t\t\tEINVAL,\n+\t\t\tRTE_FLOW_ERROR_TYPE_ITEM,\n+\t\t\titem,\n+\t\t\t\"ACL: Expecting END item\");\n+\n+\treturn 0;\n }\n \n-static int\n+\tstatic int\n flow_rule_match_get(struct pmd_internals *softnic,\n \t\tstruct pipeline *pipeline,\n \t\tstruct softnic_table *table,\n", "prefixes": [ "v2", "09/15" ] }{ "id": 44577, "url": "