get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 29466,
    "url": "http://patches.dpdk.org/api/patches/29466/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/1506936668-31197-3-git-send-email-bernard.iremonger@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": "<1506936668-31197-3-git-send-email-bernard.iremonger@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/1506936668-31197-3-git-send-email-bernard.iremonger@intel.com",
    "date": "2017-10-02T09:31:06",
    "name": "[dpdk-dev,v7,2/4] examples/flow_classify: flow classify sample application",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "a20938ff70cb17c3ea23dd8efe5e11e45cc22b22",
    "submitter": {
        "id": 91,
        "url": "http://patches.dpdk.org/api/people/91/?format=api",
        "name": "Iremonger, Bernard",
        "email": "bernard.iremonger@intel.com"
    },
    "delegate": null,
    "mbox": "http://patches.dpdk.org/project/dpdk/patch/1506936668-31197-3-git-send-email-bernard.iremonger@intel.com/mbox/",
    "series": [],
    "comments": "http://patches.dpdk.org/api/patches/29466/comments/",
    "check": "success",
    "checks": "http://patches.dpdk.org/api/patches/29466/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 9A6C81B1EF;\n\tMon,  2 Oct 2017 11:31:29 +0200 (CEST)",
            "from mga07.intel.com (mga07.intel.com [134.134.136.100])\n\tby dpdk.org (Postfix) with ESMTP id 6A5261B1AB\n\tfor <dev@dpdk.org>; Mon,  2 Oct 2017 11:31:27 +0200 (CEST)",
            "from fmsmga002.fm.intel.com ([10.253.24.26])\n\tby orsmga105.jf.intel.com with ESMTP; 02 Oct 2017 02:31:26 -0700",
            "from sivswdev01.ir.intel.com (HELO localhost.localdomain)\n\t([10.237.217.45])\n\tby fmsmga002.fm.intel.com with ESMTP; 02 Oct 2017 02:31:25 -0700"
        ],
        "X-ExtLoop1": "1",
        "X-IronPort-AV": "E=Sophos; i=\"5.42,468,1500966000\"; d=\"scan'208\";\n\ta=\"1225973799\"",
        "From": "Bernard Iremonger <bernard.iremonger@intel.com>",
        "To": "dev@dpdk.org, ferruh.yigit@intel.com, konstantin.ananyev@intel.com,\n\tcristian.dumitrescu@intel.com, adrien.mazarguil@6wind.com",
        "Cc": "Bernard Iremonger <bernard.iremonger@intel.com>",
        "Date": "Mon,  2 Oct 2017 10:31:06 +0100",
        "Message-Id": "<1506936668-31197-3-git-send-email-bernard.iremonger@intel.com>",
        "X-Mailer": "git-send-email 1.7.0.7",
        "In-Reply-To": "<1506676737-23900-1-git-send-email-bernard.iremonger@intel.com>",
        "References": "<1506676737-23900-1-git-send-email-bernard.iremonger@intel.com>",
        "Subject": "[dpdk-dev] [PATCH v7 2/4] examples/flow_classify: flow classify\n\tsample application",
        "X-BeenThere": "dev@dpdk.org",
        "X-Mailman-Version": "2.1.15",
        "Precedence": "list",
        "List-Id": "DPDK patches and discussions <dev.dpdk.org>",
        "List-Unsubscribe": "<http://dpdk.org/ml/options/dev>,\n\t<mailto:dev-request@dpdk.org?subject=unsubscribe>",
        "List-Archive": "<http://dpdk.org/ml/archives/dev/>",
        "List-Post": "<mailto:dev@dpdk.org>",
        "List-Help": "<mailto:dev-request@dpdk.org?subject=help>",
        "List-Subscribe": "<http://dpdk.org/ml/listinfo/dev>,\n\t<mailto:dev-request@dpdk.org?subject=subscribe>",
        "Errors-To": "dev-bounces@dpdk.org",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>"
    },
    "content": "The flow_classify sample application exercises the following\nlibrte_flow_classify API's:\n\nrte_flow_classify_create\nrte_flow_classify_validate\nrte_flow_classify_destroy\nrte_flow_classify_query\n\nIt sets up the IPv4 ACL field definitions.\nIt creates table_acl and adds and deletes rules using the\nlibrte_table API.\n\nIt uses a file of IPv4 five tuple rules for input.\n\nSigned-off-by: Bernard Iremonger <bernard.iremonger@intel.com>\n---\n examples/flow_classify/Makefile            |  57 ++\n examples/flow_classify/flow_classify.c     | 897 +++++++++++++++++++++++++++++\n examples/flow_classify/ipv4_rules_file.txt |  14 +\n 3 files changed, 968 insertions(+)\n create mode 100644 examples/flow_classify/Makefile\n create mode 100644 examples/flow_classify/flow_classify.c\n create mode 100644 examples/flow_classify/ipv4_rules_file.txt",
    "diff": "diff --git a/examples/flow_classify/Makefile b/examples/flow_classify/Makefile\nnew file mode 100644\nindex 0000000..eecdde1\n--- /dev/null\n+++ b/examples/flow_classify/Makefile\n@@ -0,0 +1,57 @@\n+#   BSD LICENSE\n+#\n+#   Copyright(c) 2017 Intel Corporation. All rights reserved.\n+#   All rights reserved.\n+#\n+#   Redistribution and use in source and binary forms, with or without\n+#   modification, are permitted provided that the following conditions\n+#   are met:\n+#\n+#     * Redistributions of source code must retain the above copyright\n+#       notice, this list of conditions and the following disclaimer.\n+#     * Redistributions in binary form must reproduce the above copyright\n+#       notice, this list of conditions and the following disclaimer in\n+#       the documentation and/or other materials provided with the\n+#       distribution.\n+#     * Neither the name of Intel Corporation nor the names of its\n+#       contributors may be used to endorse or promote products derived\n+#       from this software without specific prior written permission.\n+#\n+#   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n+#   \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n+#   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n+#   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n+#   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n+#   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n+#   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n+#   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n+#   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n+#   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n+#   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n+\n+ifeq ($(RTE_SDK),)\n+$(error \"Please define RTE_SDK environment variable\")\n+endif\n+\n+# Default target, can be overridden by command line or environment\n+RTE_TARGET ?= x86_64-native-linuxapp-gcc\n+\n+include $(RTE_SDK)/mk/rte.vars.mk\n+\n+# binary name\n+APP = flow_classify\n+\n+\n+# all source are stored in SRCS-y\n+SRCS-y := flow_classify.c\n+\n+CFLAGS += -O3\n+CFLAGS += $(WERROR_FLAGS)\n+\n+# workaround for a gcc bug with noreturn attribute\n+# http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12603\n+ifeq ($(CONFIG_RTE_TOOLCHAIN_GCC),y)\n+CFLAGS_main.o += -Wno-return-type\n+endif\n+\n+include $(RTE_SDK)/mk/rte.extapp.mk\ndiff --git a/examples/flow_classify/flow_classify.c b/examples/flow_classify/flow_classify.c\nnew file mode 100644\nindex 0000000..651fa8f\n--- /dev/null\n+++ b/examples/flow_classify/flow_classify.c\n@@ -0,0 +1,897 @@\n+/*-\n+ *   BSD LICENSE\n+ *\n+ *   Copyright(c) 2017 Intel Corporation. All rights reserved.\n+ *   All rights reserved.\n+ *\n+ *   Redistribution and use in source and binary forms, with or without\n+ *   modification, are permitted provided that the following conditions\n+ *   are met:\n+ *\n+ *     * Redistributions of source code must retain the above copyright\n+ *       notice, this list of conditions and the following disclaimer.\n+ *     * Redistributions in binary form must reproduce the above copyright\n+ *       notice, this list of conditions and the following disclaimer in\n+ *       the documentation and/or other materials provided with the\n+ *       distribution.\n+ *     * Neither the name of Intel Corporation nor the names of its\n+ *       contributors may be used to endorse or promote products derived\n+ *       from this software without specific prior written permission.\n+ *\n+ *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n+ *   \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n+ *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n+ *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n+ *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n+ *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n+ *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n+ *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n+ *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n+ *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n+ *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n+ */\n+\n+#include <stdint.h>\n+#include <inttypes.h>\n+#include <getopt.h>\n+\n+#include <rte_eal.h>\n+#include <rte_ethdev.h>\n+#include <rte_cycles.h>\n+#include <rte_lcore.h>\n+#include <rte_mbuf.h>\n+#include <rte_flow.h>\n+#include <rte_flow_classify.h>\n+#include <rte_table_acl.h>\n+\n+#define RX_RING_SIZE 128\n+#define TX_RING_SIZE 512\n+\n+#define NUM_MBUFS 8191\n+#define MBUF_CACHE_SIZE 250\n+#define BURST_SIZE 32\n+#define MAX_NUM_CLASSIFY 30\n+#define FLOW_CLASSIFY_MAX_RULE_NUM 91\n+#define FLOW_CLASSIFY_MAX_PRIORITY 8\n+#define PROTO_TCP 6\n+#define PROTO_UDP 17\n+#define PROTO_SCTP 132\n+\n+#define COMMENT_LEAD_CHAR\t('#')\n+#define OPTION_RULE_IPV4\t\"rule_ipv4\"\n+#define RTE_LOGTYPE_FLOW_CLASSIFY\tRTE_LOGTYPE_USER3\n+#define flow_classify_log(format, ...) \\\n+\t\tRTE_LOG(ERR, FLOW_CLASSIFY, format, ##__VA_ARGS__)\n+\n+#define uint32_t_to_char(ip, a, b, c, d) do {\\\n+\t\t*a = (unsigned char)(ip >> 24 & 0xff);\\\n+\t\t*b = (unsigned char)(ip >> 16 & 0xff);\\\n+\t\t*c = (unsigned char)(ip >> 8 & 0xff);\\\n+\t\t*d = (unsigned char)(ip & 0xff);\\\n+\t} while (0)\n+\n+enum {\n+\tCB_FLD_SRC_ADDR,\n+\tCB_FLD_DST_ADDR,\n+\tCB_FLD_SRC_PORT,\n+\tCB_FLD_SRC_PORT_DLM,\n+\tCB_FLD_SRC_PORT_MASK,\n+\tCB_FLD_DST_PORT,\n+\tCB_FLD_DST_PORT_DLM,\n+\tCB_FLD_DST_PORT_MASK,\n+\tCB_FLD_PROTO,\n+\tCB_FLD_PRIORITY,\n+\tCB_FLD_NUM,\n+};\n+\n+static struct{\n+\tconst char *rule_ipv4_name;\n+} parm_config;\n+const char cb_port_delim[] = \":\";\n+\n+static const struct rte_eth_conf port_conf_default = {\n+\t.rxmode = { .max_rx_pkt_len = ETHER_MAX_LEN }\n+};\n+\n+static void *table_acl;\n+uint32_t entry_size;\n+static int udp_num_classify;\n+static int tcp_num_classify;\n+static int sctp_num_classify;\n+\n+/* ACL field definitions for IPv4 5 tuple rule */\n+\n+enum {\n+\tPROTO_FIELD_IPV4,\n+\tSRC_FIELD_IPV4,\n+\tDST_FIELD_IPV4,\n+\tSRCP_FIELD_IPV4,\n+\tDSTP_FIELD_IPV4,\n+\tNUM_FIELDS_IPV4\n+};\n+\n+enum {\n+\tPROTO_INPUT_IPV4,\n+\tSRC_INPUT_IPV4,\n+\tDST_INPUT_IPV4,\n+\tSRCP_DESTP_INPUT_IPV4\n+};\n+\n+static struct rte_acl_field_def ipv4_defs[NUM_FIELDS_IPV4] = {\n+\t/* first input field - always one byte long. */\n+\t{\n+\t\t.type = RTE_ACL_FIELD_TYPE_BITMASK,\n+\t\t.size = sizeof(uint8_t),\n+\t\t.field_index = PROTO_FIELD_IPV4,\n+\t\t.input_index = PROTO_INPUT_IPV4,\n+\t\t.offset = sizeof(struct ether_hdr) +\n+\t\t\toffsetof(struct ipv4_hdr, next_proto_id),\n+\t},\n+\t/* next input field (IPv4 source address) - 4 consecutive bytes. */\n+\t{\n+\t\t/* rte_flow uses a bit mask for IPv4 addresses */\n+\t\t.type = RTE_ACL_FIELD_TYPE_BITMASK,\n+\t\t.size = sizeof(uint32_t),\n+\t\t.field_index = SRC_FIELD_IPV4,\n+\t\t.input_index = SRC_INPUT_IPV4,\n+\t\t.offset = sizeof(struct ether_hdr) +\n+\t\t\toffsetof(struct ipv4_hdr, src_addr),\n+\t},\n+\t/* next input field (IPv4 destination address) - 4 consecutive bytes. */\n+\t{\n+\t\t/* rte_flow uses a bit mask for IPv4 addresses */\n+\t\t.type = RTE_ACL_FIELD_TYPE_BITMASK,\n+\t\t.size = sizeof(uint32_t),\n+\t\t.field_index = DST_FIELD_IPV4,\n+\t\t.input_index = DST_INPUT_IPV4,\n+\t\t.offset = sizeof(struct ether_hdr) +\n+\t\t\toffsetof(struct ipv4_hdr, dst_addr),\n+\t},\n+\t/*\n+\t * Next 2 fields (src & dst ports) form 4 consecutive bytes.\n+\t * They share the same input index.\n+\t */\n+\t{\n+\t\t/* rte_flow uses a bit mask for protocol ports */\n+\t\t.type = RTE_ACL_FIELD_TYPE_BITMASK,\n+\t\t.size = sizeof(uint16_t),\n+\t\t.field_index = SRCP_FIELD_IPV4,\n+\t\t.input_index = SRCP_DESTP_INPUT_IPV4,\n+\t\t.offset = sizeof(struct ether_hdr) +\n+\t\t\tsizeof(struct ipv4_hdr) +\n+\t\t\toffsetof(struct tcp_hdr, src_port),\n+\t},\n+\t{\n+\t\t/* rte_flow uses a bit mask for protocol ports */\n+\t\t.type = RTE_ACL_FIELD_TYPE_BITMASK,\n+\t\t.size = sizeof(uint16_t),\n+\t\t.field_index = DSTP_FIELD_IPV4,\n+\t\t.input_index = SRCP_DESTP_INPUT_IPV4,\n+\t\t.offset = sizeof(struct ether_hdr) +\n+\t\t\tsizeof(struct ipv4_hdr) +\n+\t\t\toffsetof(struct tcp_hdr, dst_port),\n+\t},\n+};\n+\n+/* flow classify data */\n+static struct rte_flow_classify *udp_flow_classify[MAX_NUM_CLASSIFY];\n+static struct rte_flow_classify *tcp_flow_classify[MAX_NUM_CLASSIFY];\n+static struct rte_flow_classify *sctp_flow_classify[MAX_NUM_CLASSIFY];\n+\n+static struct rte_flow_classify_5tuple_stats udp_ntuple_stats;\n+static struct rte_flow_classify_stats udp_classify_stats = {\n+\t\t.available_space = BURST_SIZE,\n+\t\t.used_space = 0,\n+\t\t.stats = (void **)&udp_ntuple_stats\n+};\n+\n+static struct rte_flow_classify_5tuple_stats tcp_ntuple_stats;\n+static struct rte_flow_classify_stats tcp_classify_stats = {\n+\t\t.available_space = BURST_SIZE,\n+\t\t.used_space = 0,\n+\t\t.stats = (void **)&tcp_ntuple_stats\n+};\n+\n+static struct rte_flow_classify_5tuple_stats sctp_ntuple_stats;\n+static struct rte_flow_classify_stats sctp_classify_stats = {\n+\t\t.available_space = BURST_SIZE,\n+\t\t.used_space = 0,\n+\t\t.stats = (void **)&sctp_ntuple_stats\n+};\n+\n+/* parameters for rte_flow_classify_validate and rte_flow_classify_create */\n+\n+static struct rte_flow_item  eth_item = { RTE_FLOW_ITEM_TYPE_ETH,\n+\t0, 0, 0 };\n+static struct rte_flow_item  end_item = { RTE_FLOW_ITEM_TYPE_END,\n+\t0, 0, 0 };\n+\n+/* sample actions:\n+ * \"actions count / end\"\n+ */\n+static struct rte_flow_action count_action = { RTE_FLOW_ACTION_TYPE_COUNT, 0};\n+static struct rte_flow_action end_action = { RTE_FLOW_ACTION_TYPE_END, 0};\n+static struct rte_flow_action actions[2];\n+\n+/* sample attributes */\n+static struct rte_flow_attr attr;\n+\n+/* flow_classify.c: * Based on DPDK skeleton forwarding example. */\n+\n+/*\n+ * Initializes a given port using global settings and with the RX buffers\n+ * coming from the mbuf_pool passed as a parameter.\n+ */\n+static inline int\n+port_init(uint8_t port, struct rte_mempool *mbuf_pool)\n+{\n+\tstruct rte_eth_conf port_conf = port_conf_default;\n+\tstruct ether_addr addr;\n+\tconst uint16_t rx_rings = 1, tx_rings = 1;\n+\tint retval;\n+\tuint16_t q;\n+\n+\tif (port >= rte_eth_dev_count())\n+\t\treturn -1;\n+\n+\t/* Configure the Ethernet device. */\n+\tretval = rte_eth_dev_configure(port, rx_rings, tx_rings, &port_conf);\n+\tif (retval != 0)\n+\t\treturn retval;\n+\n+\t/* Allocate and set up 1 RX queue per Ethernet port. */\n+\tfor (q = 0; q < rx_rings; q++) {\n+\t\tretval = rte_eth_rx_queue_setup(port, q, RX_RING_SIZE,\n+\t\t\t\trte_eth_dev_socket_id(port), NULL, mbuf_pool);\n+\t\tif (retval < 0)\n+\t\t\treturn retval;\n+\t}\n+\n+\t/* Allocate and set up 1 TX queue per Ethernet port. */\n+\tfor (q = 0; q < tx_rings; q++) {\n+\t\tretval = rte_eth_tx_queue_setup(port, q, TX_RING_SIZE,\n+\t\t\t\trte_eth_dev_socket_id(port), NULL);\n+\t\tif (retval < 0)\n+\t\t\treturn retval;\n+\t}\n+\n+\t/* Start the Ethernet port. */\n+\tretval = rte_eth_dev_start(port);\n+\tif (retval < 0)\n+\t\treturn retval;\n+\n+\t/* Display the port MAC address. */\n+\trte_eth_macaddr_get(port, &addr);\n+\tprintf(\"Port %u MAC: %02\" PRIx8 \" %02\" PRIx8 \" %02\" PRIx8\n+\t\t\t   \" %02\" PRIx8 \" %02\" PRIx8 \" %02\" PRIx8 \"\\n\",\n+\t\t\tport,\n+\t\t\taddr.addr_bytes[0], addr.addr_bytes[1],\n+\t\t\taddr.addr_bytes[2], addr.addr_bytes[3],\n+\t\t\taddr.addr_bytes[4], addr.addr_bytes[5]);\n+\n+\t/* Enable RX in promiscuous mode for the Ethernet device. */\n+\trte_eth_promiscuous_enable(port);\n+\n+\treturn 0;\n+}\n+\n+/*\n+ * The lcore main. This is the main thread that does the work, reading from\n+ * an input port classifying the packets and writing to an output port.\n+ */\n+static __attribute__((noreturn)) void\n+lcore_main(void)\n+{\n+\tstruct rte_flow_error error;\n+\tconst uint8_t nb_ports = rte_eth_dev_count();\n+\tuint8_t port;\n+\tint ret;\n+\tint i;\n+\n+\t/*\n+\t * Check that the port is on the same NUMA node as the polling thread\n+\t * for best performance.\n+\t */\n+\tfor (port = 0; port < nb_ports; port++)\n+\t\tif (rte_eth_dev_socket_id(port) > 0 &&\n+\t\t\t\trte_eth_dev_socket_id(port) !=\n+\t\t\t\t\t\t(int)rte_socket_id())\n+\t\t\tprintf(\"\\n\\n\");\n+\t\t\tprintf(\"WARNING: port %u is on remote NUMA node\\n\",\n+\t\t\t       port);\n+\t\t\tprintf(\"to polling thread.\\n\");\n+\t\t\tprintf(\"Performance will not be optimal.\\n\");\n+\n+\tprintf(\"\\nCore %u forwarding packets. [Ctrl+C to quit]\\n\",\n+\t\t\trte_lcore_id());\n+\n+\t/* Run until the application is quit or killed. */\n+\tfor (;;) {\n+\t\t/*\n+\t\t * Receive packets on a port, classify them and forward them\n+\t\t * on the paired port.\n+\t\t * The mapping is 0 -> 1, 1 -> 0, 2 -> 3, 3 -> 2, etc.\n+\t\t */\n+\t\tfor (port = 0; port < nb_ports; port++) {\n+\n+\t\t\t/* Get burst of RX packets, from first port of pair. */\n+\t\t\tstruct rte_mbuf *bufs[BURST_SIZE];\n+\t\t\tconst uint16_t nb_rx = rte_eth_rx_burst(port, 0,\n+\t\t\t\t\tbufs, BURST_SIZE);\n+\n+\t\t\tif (unlikely(nb_rx == 0))\n+\t\t\t\tcontinue;\n+\n+\t\t\tfor (i = 0; i < MAX_NUM_CLASSIFY; i++) {\n+\t\t\t\tif (udp_flow_classify[i]) {\n+\t\t\t\t\tret = rte_flow_classify_query(\n+\t\t\t\t\t\ttable_acl,\n+\t\t\t\t\t\tudp_flow_classify[i],\n+\t\t\t\t\t\tbufs, nb_rx,\n+\t\t\t\t\t\t&udp_classify_stats, &error);\n+\t\t\t\t\tif (ret)\n+\t\t\t\t\t\tprintf(\n+\t\t\t\t\t\t\"udp flow classify[%d] query failed port=%u\\n\\n\",\n+\t\t\t\t\t\ti, port);\n+\t\t\t\t\telse\n+\t\t\t\t\t\tprintf(\n+\t\t\t\t\t\t\"udp rule [%d] counter1=%lu used_space=%d\\n\\n\",\n+\t\t\t\t\t\ti, udp_ntuple_stats.counter1,\n+\t\t\t\t\t\tudp_classify_stats.used_space);\n+\t\t\t\t}\n+\t\t\t}\n+\n+\t\t\tfor (i = 0; i < MAX_NUM_CLASSIFY; i++) {\n+\t\t\t\tif (tcp_flow_classify[i]) {\n+\t\t\t\t\tret = rte_flow_classify_query(\n+\t\t\t\t\t\ttable_acl,\n+\t\t\t\t\t\ttcp_flow_classify[i],\n+\t\t\t\t\t\tbufs, nb_rx,\n+\t\t\t\t\t\t&tcp_classify_stats, &error);\n+\t\t\t\t\tif (ret)\n+\t\t\t\t\t\tprintf(\n+\t\t\t\t\t\t\"tcp flow classify[%d] query failed port=%u\\n\\n\",\n+\t\t\t\t\t\ti, port);\n+\t\t\t\t\telse\n+\t\t\t\t\t\tprintf(\n+\t\t\t\t\t\t\"tcp rule [%d] counter1=%lu used_space=%d\\n\\n\",\n+\t\t\t\t\t\ti, tcp_ntuple_stats.counter1,\n+\t\t\t\t\t\ttcp_classify_stats.used_space);\n+\t\t\t\t}\n+\t\t\t}\n+\n+\t\t\tfor (i = 0; i < MAX_NUM_CLASSIFY; i++) {\n+\t\t\t\tif (sctp_flow_classify[i]) {\n+\t\t\t\t\tret = rte_flow_classify_query(\n+\t\t\t\t\t\ttable_acl,\n+\t\t\t\t\t\tsctp_flow_classify[i],\n+\t\t\t\t\t\tbufs, nb_rx,\n+\t\t\t\t\t\t&sctp_classify_stats, &error);\n+\t\t\t\t\tif (ret)\n+\t\t\t\t\t\tprintf(\n+\t\t\t\t\t\t\"sctp flow classify[%d] query failed port=%u\\n\\n\",\n+\t\t\t\t\t\ti, port);\n+\t\t\t\t\telse\n+\t\t\t\t\t\tprintf(\n+\t\t\t\t\t\t\"sctp rule [%d] counter1=%lu used_space=%d\\n\\n\",\n+\t\t\t\t\t\ti, sctp_ntuple_stats.counter1,\n+\t\t\t\t\t\tsctp_classify_stats.used_space);\n+\t\t\t\t}\n+\t\t\t}\n+\n+\t\t\t/* Send burst of TX packets, to second port of pair. */\n+\t\t\tconst uint16_t nb_tx = rte_eth_tx_burst(port ^ 1, 0,\n+\t\t\t\t\tbufs, nb_rx);\n+\n+\t\t\t/* Free any unsent packets. */\n+\t\t\tif (unlikely(nb_tx < nb_rx)) {\n+\t\t\t\tuint16_t buf;\n+\n+\t\t\t\tfor (buf = nb_tx; buf < nb_rx; buf++)\n+\t\t\t\t\trte_pktmbuf_free(bufs[buf]);\n+\t\t\t}\n+\t\t}\n+\t}\n+}\n+\n+/*\n+ * Parse IPv4 5 tuple rules file, ipv4_rules_file.txt.\n+ * Expected format:\n+ * <src_ipv4_addr>'/'<masklen> <space> \\\n+ * <dst_ipv4_addr>'/'<masklen> <space> \\\n+ * <src_port> <space> \":\" <src_port_mask> <space> \\\n+ * <dst_port> <space> \":\" <dst_port_mask> <space> \\\n+ * <proto>'/'<proto_mask> <space> \\\n+ * <priority>\n+ */\n+\n+static int\n+get_cb_field(char **in, uint32_t *fd, int base, unsigned long lim,\n+\t\tchar dlm)\n+{\n+\tunsigned long val;\n+\tchar *end;\n+\n+\terrno = 0;\n+\tval = strtoul(*in, &end, base);\n+\tif (errno != 0 || end[0] != dlm || val > lim)\n+\t\treturn -EINVAL;\n+\t*fd = (uint32_t)val;\n+\t*in = end + 1;\n+\treturn 0;\n+}\n+\n+static int\n+parse_ipv4_net(char *in, uint32_t *addr, uint32_t *mask_len)\n+{\n+\tuint32_t a, b, c, d, m;\n+\n+\tif (get_cb_field(&in, &a, 0, UINT8_MAX, '.'))\n+\t\treturn -EINVAL;\n+\tif (get_cb_field(&in, &b, 0, UINT8_MAX, '.'))\n+\t\treturn -EINVAL;\n+\tif (get_cb_field(&in, &c, 0, UINT8_MAX, '.'))\n+\t\treturn -EINVAL;\n+\tif (get_cb_field(&in, &d, 0, UINT8_MAX, '/'))\n+\t\treturn -EINVAL;\n+\tif (get_cb_field(&in, &m, 0, sizeof(uint32_t) * CHAR_BIT, 0))\n+\t\treturn -EINVAL;\n+\n+\taddr[0] = IPv4(a, b, c, d);\n+\tmask_len[0] = m;\n+\treturn 0;\n+}\n+\n+static int\n+parse_ipv4_5tuple_rule(char *str, struct rte_eth_ntuple_filter *ntuple_filter)\n+{\n+\tint i, ret;\n+\tchar *s, *sp, *in[CB_FLD_NUM];\n+\tstatic const char *dlm = \" \\t\\n\";\n+\tint dim = CB_FLD_NUM;\n+\tuint32_t temp;\n+\n+\ts = str;\n+\tfor (i = 0; i != dim; i++, s = NULL) {\n+\t\tin[i] = strtok_r(s, dlm, &sp);\n+\t\tif (in[i] == NULL)\n+\t\t\treturn -EINVAL;\n+\t}\n+\n+\tret = parse_ipv4_net(in[CB_FLD_SRC_ADDR],\n+\t\t\t&ntuple_filter->src_ip,\n+\t\t\t&ntuple_filter->src_ip_mask);\n+\tif (ret != 0) {\n+\t\tflow_classify_log(\"failed to read source address/mask: %s\\n\",\n+\t\t\tin[CB_FLD_SRC_ADDR]);\n+\t\treturn ret;\n+\t}\n+\n+\tret = parse_ipv4_net(in[CB_FLD_DST_ADDR],\n+\t\t\t&ntuple_filter->dst_ip,\n+\t\t\t&ntuple_filter->dst_ip_mask);\n+\tif (ret != 0) {\n+\t\tflow_classify_log(\"failed to read source address/mask: %s\\n\",\n+\t\t\tin[CB_FLD_DST_ADDR]);\n+\t\treturn ret;\n+\t}\n+\n+\tif (get_cb_field(&in[CB_FLD_SRC_PORT], &temp, 0, UINT16_MAX, 0))\n+\t\treturn -EINVAL;\n+\tntuple_filter->src_port = (uint16_t)temp;\n+\n+\tif (strncmp(in[CB_FLD_SRC_PORT_DLM], cb_port_delim,\n+\t\t\tsizeof(cb_port_delim)) != 0)\n+\t\treturn -EINVAL;\n+\n+\tif (get_cb_field(&in[CB_FLD_SRC_PORT_MASK], &temp, 0, UINT16_MAX, 0))\n+\t\treturn -EINVAL;\n+\tntuple_filter->src_port_mask = (uint16_t)temp;\n+\n+\tif (get_cb_field(&in[CB_FLD_DST_PORT], &temp, 0, UINT16_MAX, 0))\n+\t\treturn -EINVAL;\n+\tntuple_filter->dst_port = (uint16_t)temp;\n+\n+\tif (strncmp(in[CB_FLD_DST_PORT_DLM], cb_port_delim,\n+\t\t\tsizeof(cb_port_delim)) != 0)\n+\t\treturn -EINVAL;\n+\n+\tif (get_cb_field(&in[CB_FLD_DST_PORT_MASK], &temp, 0, UINT16_MAX, 0))\n+\t\treturn -EINVAL;\n+\tntuple_filter->dst_port_mask = (uint16_t)temp;\n+\n+\tif (get_cb_field(&in[CB_FLD_PROTO], &temp, 0, UINT8_MAX, '/'))\n+\t\treturn -EINVAL;\n+\tntuple_filter->proto = (uint8_t)temp;\n+\n+\tif (get_cb_field(&in[CB_FLD_PROTO], &temp, 0, UINT8_MAX, 0))\n+\t\treturn -EINVAL;\n+\tntuple_filter->proto_mask = (uint8_t)temp;\n+\n+\tif (get_cb_field(&in[CB_FLD_PRIORITY], &temp, 0, UINT16_MAX, 0))\n+\t\treturn -EINVAL;\n+\tntuple_filter->priority = (uint16_t)temp;\n+\tif (ntuple_filter->priority > FLOW_CLASSIFY_MAX_PRIORITY)\n+\t\tret = -EINVAL;\n+\n+\treturn ret;\n+}\n+\n+/* Bypass comment and empty lines */\n+static inline int\n+is_bypass_line(char *buff)\n+{\n+\tint i = 0;\n+\n+\t/* comment line */\n+\tif (buff[0] == COMMENT_LEAD_CHAR)\n+\t\treturn 1;\n+\t/* empty line */\n+\twhile (buff[i] != '\\0') {\n+\t\tif (!isspace(buff[i]))\n+\t\t\treturn 0;\n+\t\ti++;\n+\t}\n+\treturn 1;\n+}\n+\n+static uint32_t\n+convert_depth_to_bitmask(uint32_t depth_val)\n+{\n+\tuint32_t bitmask = 0;\n+\tint i, j;\n+\n+\tfor (i = depth_val, j = 0; i > 0; i--, j++)\n+\t\tbitmask |= (1 << (31 - j));\n+\treturn bitmask;\n+}\n+\n+static int\n+add_classify_rule(struct rte_eth_ntuple_filter *ntuple_filter)\n+{\n+\tint ret = 0;\n+\tstruct rte_flow_error error;\n+\tstruct rte_flow_item_ipv4 ipv4_spec;\n+\tstruct rte_flow_item_ipv4 ipv4_mask;\n+\tstruct rte_flow_item ipv4_udp_item;\n+\tstruct rte_flow_item ipv4_tcp_item;\n+\tstruct rte_flow_item ipv4_sctp_item;\n+\tstruct rte_flow_item_udp udp_spec;\n+\tstruct rte_flow_item_udp udp_mask;\n+\tstruct rte_flow_item udp_item;\n+\tstruct rte_flow_item_tcp tcp_spec;\n+\tstruct rte_flow_item_tcp tcp_mask;\n+\tstruct rte_flow_item tcp_item;\n+\tstruct rte_flow_item_sctp sctp_spec;\n+\tstruct rte_flow_item_sctp sctp_mask;\n+\tstruct rte_flow_item sctp_item;\n+\tstruct rte_flow_item pattern_ipv4_5tuple[4];\n+\tstruct rte_flow_classify *flow_classify;\n+\tuint8_t ipv4_proto;\n+\n+\t/* set up parameters for validate and create */\n+\tmemset(&ipv4_spec, 0, sizeof(ipv4_spec));\n+\tipv4_spec.hdr.next_proto_id = ntuple_filter->proto;\n+\tipv4_spec.hdr.src_addr = ntuple_filter->src_ip;\n+\tipv4_spec.hdr.dst_addr = ntuple_filter->dst_ip;\n+\tipv4_proto = ipv4_spec.hdr.next_proto_id;\n+\n+\tmemset(&ipv4_mask, 0, sizeof(ipv4_mask));\n+\tipv4_mask.hdr.next_proto_id = ntuple_filter->proto_mask;\n+\tipv4_mask.hdr.src_addr = ntuple_filter->src_ip_mask;\n+\tipv4_mask.hdr.src_addr =\n+\t\tconvert_depth_to_bitmask(ipv4_mask.hdr.src_addr);\n+\tipv4_mask.hdr.dst_addr = ntuple_filter->dst_ip_mask;\n+\tipv4_mask.hdr.dst_addr =\n+\t\tconvert_depth_to_bitmask(ipv4_mask.hdr.dst_addr);\n+\n+\tswitch (ipv4_proto) {\n+\tcase PROTO_UDP:\n+\t\tif (udp_num_classify >= MAX_NUM_CLASSIFY) {\n+\t\t\tprintf(\n+\t\t\t\t\"\\nINFO: UDP classify rule capacity %d reached\\n\",\n+\t\t\t\tudp_num_classify);\n+\t\t\tret = -1;\n+\t\t\tbreak;\n+\t\t}\n+\t\tipv4_udp_item.type = RTE_FLOW_ITEM_TYPE_IPV4;\n+\t\tipv4_udp_item.spec = &ipv4_spec;\n+\t\tipv4_udp_item.mask = &ipv4_mask;\n+\t\tipv4_udp_item.last = NULL;\n+\n+\t\tudp_spec.hdr.src_port = ntuple_filter->src_port;\n+\t\tudp_spec.hdr.dst_port = ntuple_filter->dst_port;\n+\t\tudp_spec.hdr.dgram_len = 0;\n+\t\tudp_spec.hdr.dgram_cksum = 0;\n+\n+\t\tudp_mask.hdr.src_port = ntuple_filter->src_port_mask;\n+\t\tudp_mask.hdr.dst_port = ntuple_filter->dst_port_mask;\n+\t\tudp_mask.hdr.dgram_len = 0;\n+\t\tudp_mask.hdr.dgram_cksum = 0;\n+\n+\t\tudp_item.type = RTE_FLOW_ITEM_TYPE_UDP;\n+\t\tudp_item.spec = &udp_spec;\n+\t\tudp_item.mask = &udp_mask;\n+\t\tudp_item.last = NULL;\n+\n+\t\tattr.priority = ntuple_filter->priority;\n+\t\tpattern_ipv4_5tuple[1] = ipv4_udp_item;\n+\t\tpattern_ipv4_5tuple[2] = udp_item;\n+\t\tbreak;\n+\tcase PROTO_TCP:\n+\t\tif (tcp_num_classify >= MAX_NUM_CLASSIFY) {\n+\t\t\tprintf(\n+\t\t\t\t\"\\nINFO: TCP classify rule capacity %d reached\\n\",\n+\t\t\t\ttcp_num_classify);\n+\t\t\tret = -1;\n+\t\t\tbreak;\n+\t\t}\n+\t\tipv4_tcp_item.type = RTE_FLOW_ITEM_TYPE_IPV4;\n+\t\tipv4_tcp_item.spec = &ipv4_spec;\n+\t\tipv4_tcp_item.mask = &ipv4_mask;\n+\t\tipv4_tcp_item.last = NULL;\n+\n+\t\tmemset(&tcp_spec, 0, sizeof(tcp_spec));\n+\t\ttcp_spec.hdr.src_port = ntuple_filter->src_port;\n+\t\ttcp_spec.hdr.dst_port = ntuple_filter->dst_port;\n+\n+\t\tmemset(&tcp_mask, 0, sizeof(tcp_mask));\n+\t\ttcp_mask.hdr.src_port = ntuple_filter->src_port_mask;\n+\t\ttcp_mask.hdr.dst_port = ntuple_filter->dst_port_mask;\n+\n+\t\ttcp_item.type = RTE_FLOW_ITEM_TYPE_TCP;\n+\t\ttcp_item.spec = &tcp_spec;\n+\t\ttcp_item.mask = &tcp_mask;\n+\t\ttcp_item.last = NULL;\n+\n+\t\tattr.priority = ntuple_filter->priority;\n+\t\tpattern_ipv4_5tuple[1] = ipv4_tcp_item;\n+\t\tpattern_ipv4_5tuple[2] = tcp_item;\n+\t\tbreak;\n+\tcase PROTO_SCTP:\n+\t\tif (sctp_num_classify >= MAX_NUM_CLASSIFY) {\n+\t\t\tprintf(\n+\t\t\t\t\"\\nINFO: SCTP classify rule capacity %d reached\\n\",\n+\t\t\t\tsctp_num_classify);\n+\t\t\tret = -1;\n+\t\t\tbreak;\n+\t\t}\n+\t\tipv4_sctp_item.type = RTE_FLOW_ITEM_TYPE_IPV4;\n+\t\tipv4_sctp_item.spec = &ipv4_spec;\n+\t\tipv4_sctp_item.mask = &ipv4_mask;\n+\t\tipv4_sctp_item.last = NULL;\n+\n+\t\tsctp_spec.hdr.src_port = ntuple_filter->src_port;\n+\t\tsctp_spec.hdr.dst_port = ntuple_filter->dst_port;\n+\t\tsctp_spec.hdr.cksum = 0;\n+\t\tsctp_spec.hdr.tag = 0;\n+\n+\t\tsctp_mask.hdr.src_port = ntuple_filter->src_port_mask;\n+\t\tsctp_mask.hdr.dst_port = ntuple_filter->dst_port_mask;\n+\t\tsctp_mask.hdr.cksum = 0;\n+\t\tsctp_mask.hdr.tag = 0;\n+\n+\t\tsctp_item.type = RTE_FLOW_ITEM_TYPE_SCTP;\n+\t\tsctp_item.spec = &sctp_spec;\n+\t\tsctp_item.mask = &sctp_mask;\n+\t\tsctp_item.last = NULL;\n+\n+\t\tattr.priority = ntuple_filter->priority;\n+\t\tpattern_ipv4_5tuple[1] = ipv4_sctp_item;\n+\t\tpattern_ipv4_5tuple[2] = sctp_item;\n+\t\tbreak;\n+\tdefault:\n+\t\tbreak;\n+\t}\n+\n+\tif (ret == -1)\n+\t\treturn 0;\n+\n+\tattr.ingress = 1;\n+\tpattern_ipv4_5tuple[0] = eth_item;\n+\tpattern_ipv4_5tuple[3] = end_item;\n+\tactions[0] = count_action;\n+\tactions[1] = end_action;\n+\n+\tret = rte_flow_classify_validate(table_acl, &attr, pattern_ipv4_5tuple,\n+\t\t\tactions, &error);\n+\tif (ret)\n+\t\trte_exit(EXIT_FAILURE,\n+\t\t\t\"flow classify validate failed ipv4_proto = %u\\n\",\n+\t\t\tipv4_proto);\n+\n+\tflow_classify = rte_flow_classify_create(\n+\t\t\ttable_acl, entry_size, &attr, pattern_ipv4_5tuple,\n+\t\t\tactions, &error);\n+\tif (flow_classify == NULL)\n+\t\trte_exit(EXIT_FAILURE,\n+\t\t\t\"flow classify create failed ipv4_proto = %u\\n\",\n+\t\t\tipv4_proto);\n+\n+\tswitch (ipv4_proto) {\n+\tcase PROTO_UDP:\n+\t\tudp_flow_classify[udp_num_classify] = flow_classify;\n+\t\tudp_num_classify++;\n+\t\tbreak;\n+\tcase PROTO_TCP:\n+\t\ttcp_flow_classify[tcp_num_classify] = flow_classify;\n+\t\ttcp_num_classify++;\n+\t\tbreak;\n+\tcase PROTO_SCTP:\n+\t\tsctp_flow_classify[sctp_num_classify] = flow_classify;\n+\t\tsctp_num_classify++;\n+\t\tbreak;\n+\tdefault:\n+\t\tbreak;\n+\t}\n+\treturn 0;\n+}\n+\n+static int\n+add_rules(const char *rule_path)\n+{\n+\tFILE *fh;\n+\tchar buff[LINE_MAX];\n+\tunsigned int i = 0;\n+\tunsigned int total_num = 0;\n+\tstruct rte_eth_ntuple_filter ntuple_filter;\n+\n+\tfh = fopen(rule_path, \"rb\");\n+\tif (fh == NULL)\n+\t\trte_exit(EXIT_FAILURE, \"%s: Open %s failed\\n\", __func__,\n+\t\t\trule_path);\n+\n+\tfseek(fh, 0, SEEK_SET);\n+\n+\ti = 0;\n+\twhile (fgets(buff, LINE_MAX, fh) != NULL) {\n+\t\ti++;\n+\n+\t\tif (is_bypass_line(buff))\n+\t\t\tcontinue;\n+\n+\t\tif (total_num >= FLOW_CLASSIFY_MAX_RULE_NUM - 1) {\n+\t\t\tprintf(\"\\nINFO: classify rule capacity %d reached\\n\",\n+\t\t\t\ttotal_num);\n+\t\t\tbreak;\n+\t\t}\n+\n+\t\tif (parse_ipv4_5tuple_rule(buff, &ntuple_filter) != 0)\n+\t\t\trte_exit(EXIT_FAILURE,\n+\t\t\t\t\"%s Line %u: parse rules error\\n\",\n+\t\t\t\trule_path, i);\n+\n+\t\tif (add_classify_rule(&ntuple_filter) != 0)\n+\t\t\trte_exit(EXIT_FAILURE, \"add rule error\\n\");\n+\n+\t\ttotal_num++;\n+\t}\n+\n+\tfclose(fh);\n+\treturn 0;\n+}\n+\n+/* display usage */\n+static void\n+print_usage(const char *prgname)\n+{\n+\tprintf(\"%s usage:\\n\", prgname);\n+\tprintf(\"[EAL options] --  --\"OPTION_RULE_IPV4\"=FILE: \");\n+\tprintf(\"specify the ipv4 rules file.\\n\");\n+\tprintf(\"Each rule occupies one line in the file.\\n\");\n+}\n+\n+/* Parse the argument given in the command line of the application */\n+static int\n+parse_args(int argc, char **argv)\n+{\n+\tint opt, ret;\n+\tchar **argvopt;\n+\tint option_index;\n+\tchar *prgname = argv[0];\n+\tstatic struct option lgopts[] = {\n+\t\t{OPTION_RULE_IPV4, 1, 0, 0},\n+\t\t{NULL, 0, 0, 0}\n+\t};\n+\n+\targvopt = argv;\n+\n+\twhile ((opt = getopt_long(argc, argvopt, \"\",\n+\t\t\t\tlgopts, &option_index)) != EOF) {\n+\n+\t\tswitch (opt) {\n+\t\t/* long options */\n+\t\tcase 0:\n+\t\t\tif (!strncmp(lgopts[option_index].name,\n+\t\t\t\t\tOPTION_RULE_IPV4,\n+\t\t\t\t\tsizeof(OPTION_RULE_IPV4)))\n+\t\t\t\tparm_config.rule_ipv4_name = optarg;\n+\t\t\tbreak;\n+\t\tdefault:\n+\t\t\tprint_usage(prgname);\n+\t\t\treturn -1;\n+\t\t}\n+\t}\n+\n+\tif (optind >= 0)\n+\t\targv[optind-1] = prgname;\n+\n+\tret = optind-1;\n+\toptind = 1; /* reset getopt lib */\n+\treturn ret;\n+}\n+\n+/*\n+ * The main function, which does initialization and calls the per-lcore\n+ * functions.\n+ */\n+int\n+main(int argc, char *argv[])\n+{\n+\tstruct rte_mempool *mbuf_pool;\n+\tuint8_t nb_ports;\n+\tuint8_t portid;\n+\tint ret;\n+\tint socket_id;\n+\tstruct rte_table_acl_params table_acl_params;\n+\n+\t/* Initialize the Environment Abstraction Layer (EAL). */\n+\tret = rte_eal_init(argc, argv);\n+\tif (ret < 0)\n+\t\trte_exit(EXIT_FAILURE, \"Error with EAL initialization\\n\");\n+\n+\targc -= ret;\n+\targv += ret;\n+\n+\t/* parse application arguments (after the EAL ones) */\n+\tret = parse_args(argc, argv);\n+\tif (ret < 0)\n+\t\trte_exit(EXIT_FAILURE, \"Invalid flow_classify parameters\\n\");\n+\n+\t/* Check that there is an even number of ports to send/receive on. */\n+\tnb_ports = rte_eth_dev_count();\n+\tif (nb_ports < 2 || (nb_ports & 1))\n+\t\trte_exit(EXIT_FAILURE, \"Error: number of ports must be even\\n\");\n+\n+\t/* Creates a new mempool in memory to hold the mbufs. */\n+\tmbuf_pool = rte_pktmbuf_pool_create(\"MBUF_POOL\", NUM_MBUFS * nb_ports,\n+\t\tMBUF_CACHE_SIZE, 0, RTE_MBUF_DEFAULT_BUF_SIZE, rte_socket_id());\n+\n+\tif (mbuf_pool == NULL)\n+\t\trte_exit(EXIT_FAILURE, \"Cannot create mbuf pool\\n\");\n+\n+\t/* Initialize all ports. */\n+\tfor (portid = 0; portid < nb_ports; portid++)\n+\t\tif (port_init(portid, mbuf_pool) != 0)\n+\t\t\trte_exit(EXIT_FAILURE, \"Cannot init port %\"PRIu8 \"\\n\",\n+\t\t\t\t\tportid);\n+\n+\tif (rte_lcore_count() > 1)\n+\t\tprintf(\"\\nWARNING: Too many lcores enabled. Only 1 used.\\n\");\n+\n+\tsocket_id = rte_eth_dev_socket_id(0);\n+\n+\t/* initialise ACL table params */\n+\ttable_acl_params.n_rule_fields = RTE_DIM(ipv4_defs);\n+\ttable_acl_params.name = \"table_acl_ipv4_5tuple\";\n+\ttable_acl_params.n_rules = FLOW_CLASSIFY_MAX_RULE_NUM;\n+\tmemcpy(table_acl_params.field_format, ipv4_defs, sizeof(ipv4_defs));\n+\tentry_size = RTE_ACL_RULE_SZ(RTE_DIM(ipv4_defs));\n+\n+\ttable_acl = rte_table_acl_ops.f_create(&table_acl_params, socket_id,\n+\t\t\t\t\t\tentry_size);\n+\tif (table_acl == NULL)\n+\t\trte_exit(EXIT_FAILURE, \"Failed to create table_acl\\n\");\n+\n+\t/* read file of IPv4 5 tuple rules and initialise parameters\n+\t * for rte_flow_classify_validate and rte_flow_classify_create\n+\t */\n+\n+\tif (add_rules(parm_config.rule_ipv4_name))\n+\t\trte_exit(EXIT_FAILURE, \"Failed to add rules\\n\");\n+\n+\t/* Call lcore_main on the master core only. */\n+\tlcore_main();\n+\n+\treturn 0;\n+}\ndiff --git a/examples/flow_classify/ipv4_rules_file.txt b/examples/flow_classify/ipv4_rules_file.txt\nnew file mode 100644\nindex 0000000..dfa0631\n--- /dev/null\n+++ b/examples/flow_classify/ipv4_rules_file.txt\n@@ -0,0 +1,14 @@\n+#file format:\n+#src_ip/masklen dst_ip/masklen src_port : mask dst_port : mask proto/mask priority\n+#\n+2.2.2.3/24 2.2.2.7/24 32 : 0xffff 33 : 0xffff 17/0xff 0\n+9.9.9.3/24 9.9.9.7/24 32 : 0xffff 33 : 0xffff 17/0xff 1\n+9.9.9.3/24 9.9.9.7/24 32 : 0xffff 33 : 0xffff 6/0xff 2\n+9.9.8.3/24 9.9.8.7/24 32 : 0xffff 33 : 0xffff 6/0xff 3\n+6.7.8.9/24 2.3.4.5/24 32 : 0x0000 33 : 0x0000 132/0xff 4\n+6.7.8.9/32 192.168.0.36/32 10 : 0xffff 11 : 0xffff 6/0xfe 5\n+6.7.8.9/24 192.168.0.36/24 10 : 0xffff 11 : 0xffff 6/0xfe 6\n+6.7.8.9/16 192.168.0.36/16 10 : 0xffff 11 : 0xffff 6/0xfe 7\n+6.7.8.9/8 192.168.0.36/8 10 : 0xffff 11 : 0xffff 6/0xfe 8\n+#error rules\n+#9.8.7.6/8 192.168.0.36/8 10 : 0xffff 11 : 0xffff 6/0xfe 9\n\\ No newline at end of file\n",
    "prefixes": [
        "dpdk-dev",
        "v7",
        "2/4"
    ]
}