Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/54730/?format=api
http://patches.dpdk.org/api/patches/54730/?format=api", "web_url": "http://patches.dpdk.org/project/dpdk/patch/20190612075029.109914-2-qiming.yang@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": "<20190612075029.109914-2-qiming.yang@intel.com>", "list_archive_url": "https://inbox.dpdk.org/dev/20190612075029.109914-2-qiming.yang@intel.com", "date": "2019-06-12T07:50:27", "name": "[v2,1/3] net/ice: enable switch filter", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": true, "hash": "a7ecce2413ff08e404a40138365756469eee6d31", "submitter": { "id": 522, "url": "http://patches.dpdk.org/api/people/522/?format=api", "name": "Qiming Yang", "email": "qiming.yang@intel.com" }, "delegate": { "id": 1540, "url": "http://patches.dpdk.org/api/users/1540/?format=api", "username": "qzhan15", "first_name": "Qi", "last_name": "Zhang", "email": "qi.z.zhang@intel.com" }, "mbox": "http://patches.dpdk.org/project/dpdk/patch/20190612075029.109914-2-qiming.yang@intel.com/mbox/", "series": [ { "id": 4987, "url": "http://patches.dpdk.org/api/series/4987/?format=api", "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=4987", "date": "2019-06-12T07:50:26", "name": "Enable rte_flow API in ice driver", "version": 2, "mbox": "http://patches.dpdk.org/series/4987/mbox/" } ], "comments": "http://patches.dpdk.org/api/patches/54730/comments/", "check": "fail", "checks": "http://patches.dpdk.org/api/patches/54730/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 6B9161D162;\n\tWed, 12 Jun 2019 09:52:30 +0200 (CEST)", "from mga06.intel.com (mga06.intel.com [134.134.136.31])\n\tby dpdk.org (Postfix) with ESMTP id 856D91D15A\n\tfor <dev@dpdk.org>; Wed, 12 Jun 2019 09:52:26 +0200 (CEST)", "from orsmga003.jf.intel.com ([10.7.209.27])\n\tby orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t12 Jun 2019 00:52:24 -0700", "from map1.sh.intel.com ([10.67.111.124])\n\tby orsmga003.jf.intel.com with ESMTP; 12 Jun 2019 00:52:24 -0700" ], "X-Amp-Result": "SKIPPED(no attachment in message)", "X-Amp-File-Uploaded": "False", "X-ExtLoop1": "1", "From": "Qiming Yang <qiming.yang@intel.com>", "To": "dev@dpdk.org", "Cc": "wei zhao <wei.zhao1@intel.com>", "Date": "Wed, 12 Jun 2019 15:50:27 +0800", "Message-Id": "<20190612075029.109914-2-qiming.yang@intel.com>", "X-Mailer": "git-send-email 2.9.5", "In-Reply-To": "<20190612075029.109914-1-qiming.yang@intel.com>", "References": "<1559552722-8970-1-git-send-email-qiming.yang@intel.com>\n\t<20190612075029.109914-1-qiming.yang@intel.com>", "Subject": "[dpdk-dev] [PATCH v2 1/3] net/ice: enable switch filter", "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": "From: wei zhao <wei.zhao1@intel.com>\n\nThe patch enables the backend of rte_flow. It transfers\nrte_flow_xxx to device specific data structure and\nconfigures packet process engine's binary classifier\n(switch) properly.\n\nSigned-off-by: Wei Zhao <wei.zhao1@intel.com>\n---\n drivers/net/ice/Makefile | 1 +\n drivers/net/ice/ice_ethdev.h | 6 +\n drivers/net/ice/ice_switch_filter.c | 502 ++++++++++++++++++++++++++++++++++++\n drivers/net/ice/ice_switch_filter.h | 28 ++\n drivers/net/ice/meson.build | 3 +-\n 5 files changed, 539 insertions(+), 1 deletion(-)\n create mode 100644 drivers/net/ice/ice_switch_filter.c\n create mode 100644 drivers/net/ice/ice_switch_filter.h", "diff": "diff --git a/drivers/net/ice/Makefile b/drivers/net/ice/Makefile\nindex 0e5c55e..b10d826 100644\n--- a/drivers/net/ice/Makefile\n+++ b/drivers/net/ice/Makefile\n@@ -60,6 +60,7 @@ ifeq ($(CONFIG_RTE_ARCH_X86), y)\n SRCS-$(CONFIG_RTE_LIBRTE_ICE_PMD) += ice_rxtx_vec_sse.c\n endif\n \n+SRCS-$(CONFIG_RTE_LIBRTE_ICE_PMD) += ice_switch_filter.c\n ifeq ($(findstring RTE_MACHINE_CPUFLAG_AVX2,$(CFLAGS)),RTE_MACHINE_CPUFLAG_AVX2)\n \tCC_AVX2_SUPPORT=1\n else\ndiff --git a/drivers/net/ice/ice_ethdev.h b/drivers/net/ice/ice_ethdev.h\nindex 1385afa..67a358a 100644\n--- a/drivers/net/ice/ice_ethdev.h\n+++ b/drivers/net/ice/ice_ethdev.h\n@@ -234,6 +234,12 @@ struct ice_vsi {\n \tbool offset_loaded;\n };\n \n+/* Struct to store flow created. */\n+struct rte_flow {\n+\tTAILQ_ENTRY(rte_flow) node;\n+void *rule;\n+};\n+\n struct ice_pf {\n \tstruct ice_adapter *adapter; /* The adapter this PF associate to */\n \tstruct ice_vsi *main_vsi; /* pointer to main VSI structure */\ndiff --git a/drivers/net/ice/ice_switch_filter.c b/drivers/net/ice/ice_switch_filter.c\nnew file mode 100644\nindex 0000000..e679675\n--- /dev/null\n+++ b/drivers/net/ice/ice_switch_filter.c\n@@ -0,0 +1,502 @@\n+#include <sys/queue.h>\n+#include <stdio.h>\n+#include <errno.h>\n+#include <stdint.h>\n+#include <string.h>\n+#include <unistd.h>\n+#include <stdarg.h>\n+\n+#include <rte_debug.h>\n+#include <rte_ether.h>\n+#include <rte_ethdev_driver.h>\n+#include <rte_log.h>\n+#include <rte_malloc.h>\n+#include <rte_eth_ctrl.h>\n+#include <rte_tailq.h>\n+#include <rte_flow_driver.h>\n+\n+#include \"ice_logs.h\"\n+#include \"base/ice_type.h\"\n+#include \"ice_switch_filter.h\"\n+\n+static int\n+ice_parse_switch_filter(\n+\t\t\tconst struct rte_flow_item pattern[],\n+\t\t\tconst struct rte_flow_action actions[],\n+\t\t\tstruct rte_flow_error *error,\n+\t\t\tstruct ice_adv_rule_info *rule_info,\n+\t\t\tstruct ice_adv_lkup_elem **lkup_list,\n+\t\t\tuint16_t *lkups_num)\n+{\n+\tconst struct rte_flow_item *item = pattern;\n+\tenum rte_flow_item_type item_type;\n+\tconst struct rte_flow_item_eth *eth_spec, *eth_mask;\n+\tconst struct rte_flow_item_ipv4 *ipv4_spec, *ipv4_mask;\n+\tconst struct rte_flow_item_ipv6 *ipv6_spec, *ipv6_mask;\n+\tconst struct rte_flow_item_tcp *tcp_spec, *tcp_mask;\n+\tconst struct rte_flow_item_udp *udp_spec, *udp_mask;\n+\tconst struct rte_flow_item_sctp *sctp_spec, *sctp_mask;\n+\tconst struct rte_flow_item_nvgre *nvgre_spec, *nvgre_mask;\n+\tconst struct rte_flow_item_vxlan *vxlan_spec, *vxlan_mask;\n+\tstruct ice_adv_lkup_elem *list;\n+\tuint16_t i, j, t = 0;\n+\tuint16_t item_num = 0;\n+\tenum ice_sw_tunnel_type tun_type = ICE_NON_TUN;\n+\n+\tfor (; item->type != RTE_FLOW_ITEM_TYPE_END; item++) {\n+\t\tif (item->type == RTE_FLOW_ITEM_TYPE_ETH ||\n+\t\t\titem->type == RTE_FLOW_ITEM_TYPE_IPV4 ||\n+\t\t\titem->type == RTE_FLOW_ITEM_TYPE_IPV6 ||\n+\t\t\titem->type == RTE_FLOW_ITEM_TYPE_UDP ||\n+\t\t\titem->type == RTE_FLOW_ITEM_TYPE_TCP ||\n+\t\t\titem->type == RTE_FLOW_ITEM_TYPE_SCTP ||\n+\t\t\titem->type == RTE_FLOW_ITEM_TYPE_VXLAN ||\n+\t\t\titem->type == RTE_FLOW_ITEM_TYPE_NVGRE)\n+\t\t\titem_num++;\n+\t}\n+\n+\tlist = rte_zmalloc(NULL, item_num * sizeof(*list), 0);\n+\tif (!list) {\n+\t\trte_flow_error_set(error, EINVAL,\n+\t\t\t\t RTE_FLOW_ERROR_TYPE_ITEM, actions,\n+\t\t\t\t \"no memory malloc\");\n+\t\tgoto out;\n+\t}\n+\t*lkup_list = list;\n+\n+\tfor (item = pattern, i = 0; item->type !=\n+\t\t\tRTE_FLOW_ITEM_TYPE_END; item++, i++) {\n+\t\titem_type = item->type;\n+\n+\t\tswitch (item_type) {\n+\t\tcase RTE_FLOW_ITEM_TYPE_ETH:\n+\t\t\teth_spec = item->spec;\n+\t\t\teth_mask = item->mask;\n+\t\t\tif (eth_spec && eth_mask) {\n+\t\t\t\tlist[t].type = (tun_type == ICE_NON_TUN) ?\n+\t\t\t\t\tICE_MAC_OFOS : ICE_MAC_IL;\n+\t\t\t\tfor (j = 0; j < RTE_ETHER_ADDR_LEN; j++) {\n+\t\t\t\t\tif (eth_mask->src.addr_bytes[j] ==\n+\t\t\t\t\t\t\t\tUINT8_MAX) {\n+\t\t\t\t\t\tlist[t].h_u.eth_hdr.\n+\t\t\t\t\t\t\tsrc_addr[j] =\n+\t\t\t\t\t\teth_spec->src.addr_bytes[j];\n+\t\t\t\t\t\tlist[t].m_u.eth_hdr.\n+\t\t\t\t\t\t\tsrc_addr[j] =\n+\t\t\t\t\t\teth_mask->src.addr_bytes[j];\n+\t\t\t\t\t}\n+\t\t\t\t\tif (eth_mask->dst.addr_bytes[j] ==\n+\t\t\t\t\t\t\t\tUINT8_MAX) {\n+\t\t\t\t\t\tlist[t].h_u.eth_hdr.\n+\t\t\t\t\t\t\tdst_addr[j] =\n+\t\t\t\t\t\teth_spec->dst.addr_bytes[j];\n+\t\t\t\t\t\tlist[t].m_u.eth_hdr.\n+\t\t\t\t\t\t\tdst_addr[j] =\n+\t\t\t\t\t\teth_mask->dst.addr_bytes[j];\n+\t\t\t\t\t}\n+\t\t\t\t}\n+\t\t\t\tif (eth_mask->type == UINT16_MAX) {\n+\t\t\t\t\tlist[t].h_u.eth_hdr.ethtype_id =\n+\t\t\t\t\trte_be_to_cpu_16(eth_spec->type);\n+\t\t\t\t\tlist[t].m_u.eth_hdr.ethtype_id =\n+\t\t\t\t\t\tUINT16_MAX;\n+\t\t\t\t}\n+\t\t\t\tt++;\n+\t\t\t} else if (!eth_spec && !eth_mask) {\n+\t\t\t\tlist[t].type = (tun_type == ICE_NON_TUN) ?\n+\t\t\t\t\tICE_MAC_OFOS : ICE_MAC_IL;\n+\t\t\t}\n+\t\t\tbreak;\n+\n+\t\tcase RTE_FLOW_ITEM_TYPE_IPV4:\n+\t\t\tipv4_spec = item->spec;\n+\t\t\tipv4_mask = item->mask;\n+\t\t\tif (ipv4_spec && ipv4_mask) {\n+\t\t\t\tlist[t].type = (tun_type == ICE_NON_TUN) ?\n+\t\t\t\t\tICE_IPV4_OFOS : ICE_IPV4_IL;\n+\t\t\t\tif (ipv4_mask->hdr.src_addr == UINT32_MAX) {\n+\t\t\t\t\tlist[t].h_u.ipv4_hdr.src_addr =\n+\t\t\t\t\t\tipv4_spec->hdr.src_addr;\n+\t\t\t\t\tlist[t].m_u.ipv4_hdr.src_addr =\n+\t\t\t\t\t\tUINT32_MAX;\n+\t\t\t\t}\n+\t\t\t\tif (ipv4_mask->hdr.dst_addr == UINT32_MAX) {\n+\t\t\t\t\tlist[t].h_u.ipv4_hdr.dst_addr =\n+\t\t\t\t\t\tipv4_spec->hdr.dst_addr;\n+\t\t\t\t\tlist[t].m_u.ipv4_hdr.dst_addr =\n+\t\t\t\t\t\tUINT32_MAX;\n+\t\t\t\t}\n+\t\t\t\tif (ipv4_mask->hdr.time_to_live == UINT8_MAX) {\n+\t\t\t\t\tlist[t].h_u.ipv4_hdr.time_to_live =\n+\t\t\t\t\t\tipv4_spec->hdr.time_to_live;\n+\t\t\t\t\tlist[t].m_u.ipv4_hdr.time_to_live =\n+\t\t\t\t\t\tUINT8_MAX;\n+\t\t\t\t}\n+\t\t\t\tif (ipv4_mask->hdr.next_proto_id == UINT8_MAX) {\n+\t\t\t\t\tlist[t].h_u.ipv4_hdr.protocol =\n+\t\t\t\t\t\tipv4_spec->hdr.next_proto_id;\n+\t\t\t\t\tlist[t].m_u.ipv4_hdr.protocol =\n+\t\t\t\t\t\tUINT8_MAX;\n+\t\t\t\t}\n+\t\t\t\tif (ipv4_mask->hdr.type_of_service ==\n+\t\t\t\t\t\tUINT8_MAX) {\n+\t\t\t\t\tlist[t].h_u.ipv4_hdr.tos =\n+\t\t\t\t\t\tipv4_spec->hdr.type_of_service;\n+\t\t\t\t\tlist[t].m_u.ipv4_hdr.tos = UINT8_MAX;\n+\t\t\t\t}\n+\t\t\t\tt++;\n+\t\t\t} else if (!ipv4_spec && !ipv4_mask) {\n+\t\t\t\tlist[t].type = (tun_type == ICE_NON_TUN) ?\n+\t\t\t\t\tICE_IPV4_OFOS : ICE_IPV4_IL;\n+\t\t\t}\n+\t\t\tbreak;\n+\n+\t\tcase RTE_FLOW_ITEM_TYPE_IPV6:\n+\t\t\tipv6_spec = item->spec;\n+\t\t\tipv6_mask = item->mask;\n+\t\t\tif (ipv6_spec && ipv6_mask) {\n+\t\t\t\tlist[t].type = (tun_type == ICE_NON_TUN) ?\n+\t\t\t\t\tICE_IPV6_OFOS : ICE_IPV6_IL;\n+\t\t\t\tfor (j = 0; j < ICE_IPV6_ADDR_LENGTH; j++) {\n+\t\t\t\t\tif (ipv6_mask->hdr.src_addr[j] ==\n+\t\t\t\t\t\t\t\tUINT8_MAX) {\n+\t\t\t\t\t\tlist[t].h_u.ice_ipv6_ofos_hdr.\n+\t\t\t\t\t\t\tsrc_addr[j] =\n+\t\t\t\t\t\tipv6_spec->hdr.src_addr[j];\n+\t\t\t\t\t\tlist[t].m_u.ice_ipv6_ofos_hdr.\n+\t\t\t\t\t\t\tsrc_addr[j] =\n+\t\t\t\t\t\tipv6_mask->hdr.src_addr[j];\n+\t\t\t\t\t}\n+\t\t\t\t\tif (ipv6_mask->hdr.dst_addr[j] ==\n+\t\t\t\t\t\t\t\tUINT8_MAX) {\n+\t\t\t\t\t\tlist[t].h_u.ice_ipv6_ofos_hdr.\n+\t\t\t\t\t\t\tdst_addr[j] =\n+\t\t\t\t\t\tipv6_spec->hdr.dst_addr[j];\n+\t\t\t\t\t\tlist[t].m_u.ice_ipv6_ofos_hdr.\n+\t\t\t\t\t\t\tdst_addr[j] =\n+\t\t\t\t\t\tipv6_mask->hdr.dst_addr[j];\n+\t\t\t\t\t}\n+\t\t\t\t}\n+\t\t\t\tif (ipv6_mask->hdr.proto == UINT8_MAX) {\n+\t\t\t\t\tlist[t].h_u.ice_ipv6_ofos_hdr.next_hdr =\n+\t\t\t\t\t\tipv6_spec->hdr.proto;\n+\t\t\t\t\tlist[t].m_u.ice_ipv6_ofos_hdr.next_hdr =\n+\t\t\t\t\t\tUINT8_MAX;\n+\t\t\t\t}\n+\t\t\t\tif (ipv6_mask->hdr.hop_limits == UINT8_MAX) {\n+\t\t\t\t\tlist[t].h_u.ice_ipv6_ofos_hdr.\n+\t\t\t\t\thop_limit = ipv6_spec->hdr.hop_limits;\n+\t\t\t\t\tlist[t].m_u.ice_ipv6_ofos_hdr.\n+\t\t\t\t\t\thop_limit = UINT8_MAX;\n+\t\t\t\t}\n+\t\t\t\tt++;\n+\t\t\t} else if (!ipv6_spec && !ipv6_mask) {\n+\t\t\t\tlist[t].type = (tun_type == ICE_NON_TUN) ?\n+\t\t\t\t\tICE_IPV4_OFOS : ICE_IPV4_IL;\n+\t\t\t}\n+\t\t\tbreak;\n+\n+\t\tcase RTE_FLOW_ITEM_TYPE_UDP:\n+\t\t\tudp_spec = item->spec;\n+\t\t\tudp_mask = item->mask;\n+\t\t\tif (udp_spec && udp_mask) {\n+\t\t\t\tlist[t].type = ICE_UDP_ILOS;\n+\t\t\t\tif (udp_mask->hdr.src_port == UINT16_MAX) {\n+\t\t\t\t\tlist[t].h_u.l4_hdr.src_port =\n+\t\t\t\t\t\tudp_spec->hdr.src_port;\n+\t\t\t\t\tlist[t].m_u.l4_hdr.src_port =\n+\t\t\t\t\t\tudp_mask->hdr.src_port;\n+\t\t\t\t}\n+\t\t\t\tif (udp_mask->hdr.dst_port == UINT16_MAX) {\n+\t\t\t\t\tlist[t].h_u.l4_hdr.dst_port =\n+\t\t\t\t\t\tudp_spec->hdr.dst_port;\n+\t\t\t\t\tlist[t].m_u.l4_hdr.dst_port =\n+\t\t\t\t\t\tudp_mask->hdr.dst_port;\n+\t\t\t\t}\n+\t\t\t\tt++;\n+\t\t\t} else if (!udp_spec && !udp_mask) {\n+\t\t\t\tlist[t].type = ICE_UDP_ILOS;\n+\t\t\t}\n+\t\t\tbreak;\n+\n+\t\tcase RTE_FLOW_ITEM_TYPE_TCP:\n+\t\t\ttcp_spec = item->spec;\n+\t\t\ttcp_mask = item->mask;\n+\t\t\tif (tcp_spec && tcp_mask) {\n+\t\t\t\tlist[t].type = ICE_TCP_IL;\n+\t\t\t\tif (tcp_mask->hdr.src_port == UINT16_MAX) {\n+\t\t\t\t\tlist[t].h_u.l4_hdr.src_port =\n+\t\t\t\t\t\ttcp_spec->hdr.src_port;\n+\t\t\t\t\tlist[t].m_u.l4_hdr.src_port =\n+\t\t\t\t\t\ttcp_mask->hdr.src_port;\n+\t\t\t\t}\n+\t\t\t\tif (tcp_mask->hdr.dst_port == UINT16_MAX) {\n+\t\t\t\t\tlist[t].h_u.l4_hdr.dst_port =\n+\t\t\t\t\t\ttcp_spec->hdr.dst_port;\n+\t\t\t\t\tlist[t].m_u.l4_hdr.dst_port =\n+\t\t\t\t\t\ttcp_mask->hdr.dst_port;\n+\t\t\t\t}\n+\t\t\t\tt++;\n+\t\t\t} else if (!tcp_spec && !tcp_mask) {\n+\t\t\t\tlist[t].type = ICE_TCP_IL;\n+\t\t\t}\n+\t\t\tbreak;\n+\n+\t\tcase RTE_FLOW_ITEM_TYPE_SCTP:\n+\t\t\tsctp_spec = item->spec;\n+\t\t\tsctp_mask = item->mask;\n+\t\t\tif (sctp_spec && sctp_mask) {\n+\t\t\t\tlist[t].type = ICE_SCTP_IL;\n+\t\t\t\tif (sctp_mask->hdr.src_port == UINT16_MAX) {\n+\t\t\t\t\tlist[t].h_u.sctp_hdr.src_port =\n+\t\t\t\t\t\tsctp_spec->hdr.src_port;\n+\t\t\t\t\tlist[t].m_u.sctp_hdr.src_port =\n+\t\t\t\t\t\tsctp_mask->hdr.src_port;\n+\t\t\t\t}\n+\t\t\t\tif (sctp_mask->hdr.dst_port == UINT16_MAX) {\n+\t\t\t\t\tlist[t].h_u.sctp_hdr.dst_port =\n+\t\t\t\t\t\tsctp_spec->hdr.dst_port;\n+\t\t\t\t\tlist[t].m_u.sctp_hdr.dst_port =\n+\t\t\t\t\t\tsctp_mask->hdr.dst_port;\n+\t\t\t\t}\n+\t\t\t\tt++;\n+\t\t\t} else if (!sctp_spec && !sctp_mask) {\n+\t\t\t\tlist[t].type = ICE_SCTP_IL;\n+\t\t\t}\n+\t\t\tbreak;\n+\n+\t\tcase RTE_FLOW_ITEM_TYPE_VXLAN:\n+\t\t\tvxlan_spec = item->spec;\n+\t\t\tvxlan_mask = item->mask;\n+\t\t\ttun_type = ICE_SW_TUN_VXLAN;\n+\t\t\tif (vxlan_spec && vxlan_mask) {\n+\t\t\t\tlist[t].type = ICE_VXLAN;\n+\t\t\t\tif (vxlan_mask->vni[0] == UINT8_MAX &&\n+\t\t\t\t\tvxlan_mask->vni[1] == UINT8_MAX &&\n+\t\t\t\t\tvxlan_mask->vni[2] == UINT8_MAX) {\n+\t\t\t\t\tlist[t].h_u.tnl_hdr.vni =\n+\t\t\t\t\t\t(vxlan_spec->vni[1] << 8) |\n+\t\t\t\t\t\tvxlan_spec->vni[0];\n+\t\t\t\t\tlist[t].m_u.tnl_hdr.vni =\n+\t\t\t\t\t\tUINT16_MAX;\n+\t\t\t\t}\n+\t\t\t\tt++;\n+\t\t\t} else if (!vxlan_spec && !vxlan_mask) {\n+\t\t\t\tlist[t].type = ICE_VXLAN;\n+\t\t\t}\n+\t\t\tbreak;\n+\n+\t\tcase RTE_FLOW_ITEM_TYPE_NVGRE:\n+\t\t\tnvgre_spec = item->spec;\n+\t\t\tnvgre_mask = item->mask;\n+\t\t\ttun_type = ICE_SW_TUN_NVGRE;\n+\t\t\tif (nvgre_spec && nvgre_mask) {\n+\t\t\t\tlist[t].type = ICE_NVGRE;\n+\t\t\t\tif (nvgre_mask->tni[0] == UINT8_MAX &&\n+\t\t\t\t\tnvgre_mask->tni[1] == UINT8_MAX &&\n+\t\t\t\t\tnvgre_mask->tni[2] == UINT8_MAX) {\n+\t\t\t\t\tlist[t].h_u.nvgre_hdr.tni =\n+\t\t\t\t\t\t(nvgre_spec->tni[1] << 8) |\n+\t\t\t\t\t\tnvgre_spec->tni[0];\n+\t\t\t\t\tlist[t].m_u.nvgre_hdr.tni =\n+\t\t\t\t\t\tUINT16_MAX;\n+\t\t\t\t}\n+\t\t\t\tt++;\n+\t\t\t} else if (!nvgre_spec && !nvgre_mask) {\n+\t\t\t\tlist[t].type = ICE_NVGRE;\n+\t\t\t}\n+\t\t\tbreak;\n+\n+\t\tcase RTE_FLOW_ITEM_TYPE_VOID:\n+\t\tcase RTE_FLOW_ITEM_TYPE_END:\n+\t\t\tbreak;\n+\n+\t\tdefault:\n+\t\t\trte_flow_error_set(error, EINVAL,\n+\t\t\t\t RTE_FLOW_ERROR_TYPE_ITEM, actions,\n+\t\t\t\t \"Invalid pattern item.\");\n+\t\t\tgoto out;\n+\t\t}\n+\t}\n+\n+\trule_info->tun_type = tun_type;\n+\t*lkups_num = t;\n+\n+\treturn 0;\n+out:\n+\treturn -rte_errno;\n+}\n+\n+/* By now ice switch filter action code implement only\n+* supports QUEUE or DROP.\n+*/\n+static int\n+ice_parse_switch_action(struct ice_pf *pf,\n+\t\t\t\t const struct rte_flow_action *actions,\n+\t\t\t\t struct rte_flow_error *error,\n+\t\t\t\t struct ice_adv_rule_info *rule_info)\n+{\n+\tstruct ice_hw *hw = ICE_PF_TO_HW(pf);\n+\tstruct ice_vsi *vsi = pf->main_vsi;\n+\tconst struct rte_flow_action *act;\n+\tconst struct rte_flow_action_queue *act_q;\n+\tuint16_t base_queue, index = 0;\n+\tuint32_t reg;\n+\n+\t/* Check if the first non-void action is QUEUE or DROP. */\n+\tNEXT_ITEM_OF_ACTION(act, actions, index);\n+\tif (act->type != RTE_FLOW_ACTION_TYPE_QUEUE &&\n+\t act->type != RTE_FLOW_ACTION_TYPE_DROP) {\n+\t\trte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION,\n+\t\t\t\t act, \"Not supported action.\");\n+\t\treturn -rte_errno;\n+\t}\n+\treg = ICE_READ_REG(hw, PFLAN_RX_QALLOC);\n+\tif (reg & PFLAN_RX_QALLOC_VALID_M) {\n+\t\tbase_queue = reg & PFLAN_RX_QALLOC_FIRSTQ_M;\n+\t} else {\n+\t\trte_flow_error_set(error, EINVAL,\n+\t\t\tRTE_FLOW_ERROR_TYPE_ACTION,\n+\t\t\tact, \"Invalid queue register\");\n+\t\treturn -rte_errno;\n+\t}\n+\tif (act->type == RTE_FLOW_ACTION_TYPE_QUEUE) {\n+\t\tact_q = act->conf;\n+\t\trule_info->sw_act.fltr_act = ICE_FWD_TO_Q;\n+\t\trule_info->sw_act.fwd_id.q_id = base_queue + act_q->index;\n+\t\tif (act_q->index >= pf->dev_data->nb_rx_queues) {\n+\t\t\trte_flow_error_set(error, EINVAL,\n+\t\t\t\tRTE_FLOW_ERROR_TYPE_ACTION,\n+\t\t\t\tact, \"Invalid queue ID for\"\n+\t\t\t\t\" switch filter.\");\n+\t\t\treturn -rte_errno;\n+\t\t}\n+\t} else {\n+\t\trule_info->sw_act.fltr_act = ICE_DROP_PACKET;\n+\t}\n+\n+\trule_info->sw_act.vsi_handle = vsi->idx;\n+\trule_info->rx = 1;\n+\trule_info->sw_act.src = vsi->idx;\n+\n+\t/* Check if the next non-void item is END */\n+\tindex++;\n+\tNEXT_ITEM_OF_ACTION(act, actions, index);\n+\tif (act->type != RTE_FLOW_ACTION_TYPE_END) {\n+\t\trte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION,\n+\t\t\t\t act, \"Not supported action.\");\n+\t\treturn -rte_errno;\n+\t}\n+\n+\treturn 0;\n+}\n+\n+static int\n+ice_switch_rule_set(struct ice_pf *pf,\n+\t\t\tstruct ice_adv_lkup_elem *list,\n+\t\t\tuint16_t lkups_cnt,\n+\t\t\tstruct ice_adv_rule_info *rule_info,\n+\t\t\tstruct rte_flow *flow)\n+{\n+\tstruct ice_hw *hw = ICE_PF_TO_HW(pf);\n+\tint ret;\n+\tstruct ice_rule_query_data rule_added = {0};\n+\tstruct ice_rule_query_data *filter_ptr;\n+\n+\tif (lkups_cnt > ICE_MAX_CHAIN_WORDS) {\n+\t\tPMD_DRV_LOG(ERR, \"item number too large for rule\");\n+\t\treturn -ENOTSUP;\n+\t}\n+\tif (!list) {\n+\t\tPMD_DRV_LOG(ERR, \"lookup list should not be NULL\");\n+\t\treturn -ENOTSUP;\n+\t}\n+\n+\tret = ice_add_adv_rule(hw, list, lkups_cnt, rule_info, &rule_added);\n+\n+\tif (!ret) {\n+\t\tfilter_ptr = rte_zmalloc(\"ice_switch_filter\",\n+\t\t\tsizeof(struct ice_rule_query_data), 0);\n+\t\tif (!filter_ptr) {\n+\t\t\tPMD_DRV_LOG(ERR, \"failed to allocate memory\");\n+\t\t\treturn -EINVAL;\n+\t\t}\n+\t\tflow->rule = filter_ptr;\n+\t\trte_memcpy(filter_ptr,\n+\t\t\t&rule_added,\n+\t\t\tsizeof(struct ice_rule_query_data));\n+\t}\n+\n+\treturn ret;\n+}\n+\n+int\n+ice_create_switch_filter(struct ice_pf *pf,\n+\t\t\tconst struct rte_flow_item pattern[],\n+\t\t\tconst struct rte_flow_action actions[],\n+\t\t\tstruct rte_flow *flow,\n+\t\t\tstruct rte_flow_error *error)\n+{\n+\tint ret = 0;\n+\tstruct ice_adv_rule_info rule_info = {0};\n+\tstruct ice_adv_lkup_elem *list = NULL;\n+\tuint16_t lkups_num = 0;\n+\n+\tret = ice_parse_switch_filter(pattern, actions, error,\n+\t\t\t&rule_info, &list, &lkups_num);\n+\tif (ret)\n+\t\tgoto out;\n+\n+\tret = ice_parse_switch_action(pf, actions, error, &rule_info);\n+\tif (ret)\n+\t\tgoto out;\n+\n+\tret = ice_switch_rule_set(pf, list, lkups_num, &rule_info, flow);\n+\tif (ret)\n+\t\tgoto out;\n+\n+\trte_free(list);\n+\treturn 0;\n+\n+out:\n+\trte_free(list);\n+\n+\treturn -rte_errno;\n+}\n+\n+int\n+ice_destroy_switch_filter(struct ice_pf *pf,\n+\t\t\tstruct rte_flow *flow)\n+{\n+\tstruct ice_hw *hw = ICE_PF_TO_HW(pf);\n+\tint ret;\n+\tstruct ice_rule_query_data *filter_ptr;\n+\tstruct ice_rule_query_data rule_added;\n+\n+\tfilter_ptr = (struct ice_rule_query_data *)\n+\t\t\tflow->rule;\n+\trte_memcpy(&rule_added, filter_ptr,\n+\t\tsizeof(struct ice_rule_query_data));\n+\n+\tif (!filter_ptr) {\n+\t\tPMD_DRV_LOG(ERR, \"no such flow\"\n+\t\t\t \" create by switch filter\");\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tret = ice_rem_adv_rule_by_id(hw, &rule_added);\n+\n+\trte_free(filter_ptr);\n+\n+\treturn ret;\n+}\n+\n+void\n+ice_free_switch_filter_rule(void *rule)\n+{\n+\tstruct ice_rule_query_data *filter_ptr;\n+\n+\tfilter_ptr = (struct ice_rule_query_data *)rule;\n+\n+\trte_free(filter_ptr);\n+}\ndiff --git a/drivers/net/ice/ice_switch_filter.h b/drivers/net/ice/ice_switch_filter.h\nnew file mode 100644\nindex 0000000..957d0d1\n--- /dev/null\n+++ b/drivers/net/ice/ice_switch_filter.h\n@@ -0,0 +1,28 @@\n+#ifndef _ICE_SWITCH_FILTER_H_\n+#define _ICE_SWITCH_FILTER_H_\n+\n+#include \"base/ice_switch.h\"\n+#include \"base/ice_type.h\"\n+#include \"ice_ethdev.h\"\n+\n+#define NEXT_ITEM_OF_ACTION(act, actions, index) \\\n+\tdo { \\\n+\t\tact = actions + index; \\\n+\t\twhile (act->type == RTE_FLOW_ACTION_TYPE_VOID) { \\\n+\t\t\tindex++; \\\n+\t\t\tact = actions + index; \\\n+\t\t} \\\n+\t} while (0)\n+\n+int\n+ice_create_switch_filter(struct ice_pf *pf,\n+\t\t\tconst struct rte_flow_item pattern[],\n+\t\t\tconst struct rte_flow_action actions[],\n+\t\t\tstruct rte_flow *flow,\n+\t\t\tstruct rte_flow_error *error);\n+int\n+ice_destroy_switch_filter(struct ice_pf *pf,\n+\t\t\tstruct rte_flow *flow);\n+void\n+ice_free_switch_filter_rule(void *rule);\n+#endif /* _ICE_SWITCH_FILTER_H_ */\ndiff --git a/drivers/net/ice/meson.build b/drivers/net/ice/meson.build\nindex 2bec688..8697676 100644\n--- a/drivers/net/ice/meson.build\n+++ b/drivers/net/ice/meson.build\n@@ -6,7 +6,8 @@ objs = [base_objs]\n \n sources = files(\n \t'ice_ethdev.c',\n-\t'ice_rxtx.c'\n+\t'ice_rxtx.c',\n+\t'ice_switch_filter.c'\n \t)\n \n deps += ['hash']\n", "prefixes": [ "v2", "1/3" ] }{ "id": 54730, "url": "